1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23 #ifndef _FLASH_EXPORTER_HXX
24 #define _FLASH_EXPORTER_HXX
25
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/lang/XComponent.hpp>
28 #include <com/sun/star/io/XOutputStream.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/document/XExporter.hpp>
31 #include <com/sun/star/drawing/XDrawPage.hpp>
32 #include <com/sun/star/presentation/AnimationEffect.hpp>
33 #include <com/sun/star/presentation/AnimationSpeed.hpp>
34 #include <com/sun/star/presentation/ClickAction.hpp>
35 #include <com/sun/star/presentation/FadeEffect.hpp>
36 #include <osl/file.hxx>
37
38 #include <vector>
39 #include <map>
40
41 #include <stdio.h>
42
43 typedef ::std::map<sal_uInt32, sal_uInt16> ChecksumCache;
44
45 class GDIMetaFile;
46
STR(const sal_Char * in)47 inline ::rtl::OUString STR(const sal_Char * in)
48 {
49 return ::rtl::OUString::createFromAscii(in);
50 }
51
VAL(sal_Int32 in)52 inline ::rtl::OUString VAL(sal_Int32 in)
53 {
54 return ::rtl::OUString::valueOf(in);
55 }
56
57 namespace swf {
58
59 class Writer;
60 // -----------------------------------------------------------------------------
61
62 class ShapeInfo
63 {
64 public:
65 sal_uInt16 mnID; // the character id for the sprite definition of this shape
66
67 sal_Int32 mnX;
68 sal_Int32 mnY;
69
70 sal_Int32 mnWidth;
71 sal_Int32 mnHeight;
72
73 ::com::sun::star::presentation::AnimationEffect meEffect;
74 ::com::sun::star::presentation::AnimationEffect meTextEffect;
75 ::com::sun::star::presentation::AnimationSpeed meEffectSpeed;
76
77 sal_Int32 mnPresOrder;
78
79 ::com::sun::star::presentation::ClickAction meClickAction;
80 ::rtl::OUString maBookmark;
81
82 sal_Int32 mnDimColor;
83 sal_Bool mbDimHide;
84 sal_Bool mbDimPrev;
85
86 sal_Bool mbSoundOn;
87 sal_Bool mbPlayFull;
88 ::rtl::OUString maSoundURL;
89
90 sal_Int32 mnBlueScreenColor;
91
ShapeInfo()92 ShapeInfo() :
93 mnID(0), mnX(0), mnY(0),
94 meEffect( ::com::sun::star::presentation::AnimationEffect_NONE ),
95 meTextEffect( ::com::sun::star::presentation::AnimationEffect_NONE ),
96 meEffectSpeed( ::com::sun::star::presentation::AnimationSpeed_MEDIUM ),
97 mnPresOrder( 0 ),
98 meClickAction( ::com::sun::star::presentation::ClickAction_NONE ),
99 mnDimColor( 0 ),
100 mbDimHide( false ),
101 mbDimPrev( false ),
102 mbSoundOn( false ),
103 mbPlayFull( false ),
104 mnBlueScreenColor( 0 ) {}
105 };
106
107 typedef ::std::vector<ShapeInfo*> ShapeInfoVector;
108
109 // -----------------------------------------------------------------------------
110
111 struct ShapeAnimationInfo
112 {
113 ShapeInfo* mpShapeInfo;
114 sal_uInt16 mnDepth;
115
ShapeAnimationInfoswf::ShapeAnimationInfo116 ShapeAnimationInfo( ShapeInfo* pShapeInfo, sal_uInt16 nDepth ) : mpShapeInfo( pShapeInfo ), mnDepth( nDepth ) {}
117 };
118
119 typedef std::vector<ShapeAnimationInfo> ShapeAnimationInfoVector;
120
121 // -----------------------------------------------------------------------------
122
123 struct PageInfo
124 {
125 ::com::sun::star::presentation::FadeEffect meFadeEffect;
126 ::com::sun::star::presentation::AnimationSpeed meFadeSpeed;
127
128 sal_Int32 mnDuration;
129 sal_Int32 mnChange;
130
131 sal_uInt16 mnBackgroundID;
132 sal_uInt16 mnObjectsID;
133 sal_uInt16 mnForegroundID;
134
135 sal_Bool mbBackgroundVisible;
136 sal_Bool mbBackgroundObjectsVisible;
137
138 ShapeInfoVector maShapesVector;
139
140 PageInfo();
141 ~PageInfo();
142
143 #ifdef THEFUTURE
144 void addShape( ShapeInfo* pShapeInfo );
145 #endif
146
147 };
148
149 // -----------------------------------------------------------------------------
150
151 typedef ::std::map<sal_uInt32, PageInfo> PageInfoMap;
152
153 // -----------------------------------------------------------------------------
154
155 class FlashExporter
156 {
157 public:
158 FlashExporter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMSF, sal_Int32 nJPEGCompressMode = -1, sal_Bool bExportOLEAsJPEG = false);
159 ~FlashExporter();
160
161 void Flush();
162
163 sal_Bool exportAll( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xDoc, com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > &xOutputStream, ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator> &xStatusIndicator );
164 sal_Bool exportSlides( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > xDrawPage, com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > &xOutputStream, sal_uInt16 nPage);
165 sal_uInt16 exportBackgrounds( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > xDrawPage, com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > &xOutputStream, sal_uInt16 nPage, sal_Bool bExportObjects );
166 sal_uInt16 exportBackgrounds( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > xDrawPage, sal_uInt16 nPage, sal_Bool bExportObjects );
167
168 #ifdef AUGUSTUS
169 sal_Bool exportSound( com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > &xOutputStream, const char* wavfilename );
170 #endif
171
172 ChecksumCache gMasterCache;
173 ChecksumCache gPrivateCache;
174 ChecksumCache gObjectCache;
175 ChecksumCache gMetafileCache;
176
177 private:
178 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
179 ::com::sun::star::uno::Reference< ::com::sun::star::document::XExporter > mxGraphicExporter;
180
181 PageInfoMap maPagesMap;
182
183 sal_uInt16 exportDrawPageBackground(sal_uInt16 nPage, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage);
184 sal_uInt16 exportMasterPageObjects(sal_uInt16 nPage, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xMasterPage);
185
186 void exportDrawPageContents( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage, bool bStream, bool bMaster );
187 void exportShapes( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes, bool bStream, bool bMaster );
188 void exportShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, bool bMaster);
189
190 sal_uInt32 ActionSummer(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape);
191 sal_uInt32 ActionSummer(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes);
192
193 void animateShape( ShapeAnimationInfo& rAnimInfo );
194 void animatePage( PageInfo* pPageInfo );
195
196 bool getMetaFile( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >&xComponent, GDIMetaFile& rMtf, bool bOnlyBackground = false, bool bExportAsJPEG = false );
197
198 Writer* mpWriter;
199
200 sal_Int32 mnDocWidth;
201 sal_Int32 mnDocHeight;
202
203 sal_Int32 mnJPEGcompressMode;
204
205 sal_Bool mbExportOLEAsJPEG;
206
207 sal_Bool mbPresentation;
208
209 sal_Int32 mnPageNumber;
210 };
211
212 }
213
214 #endif
215