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(
159         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMSF,
160 
161         // #56084# variables for selection export
162         const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxSelectedShapes,
163         const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxSelectedDrawPage,
164 
165         sal_Int32 nJPEGCompressMode = -1,
166         sal_Bool bExportOLEAsJPEG = false);
167 	~FlashExporter();
168 
169 	void Flush();
170 
171 	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 );
172 	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);
173 	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 );
174 	sal_uInt16 exportBackgrounds( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > xDrawPage, sal_uInt16 nPage, sal_Bool bExportObjects );
175 
176 #ifdef AUGUSTUS
177 	sal_Bool exportSound( com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > &xOutputStream, const char* wavfilename );
178 #endif
179 
180 	ChecksumCache gMasterCache;
181 	ChecksumCache gPrivateCache;
182 	ChecksumCache gObjectCache;
183 	ChecksumCache gMetafileCache;
184 
185 private:
186 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
187 
188     // #56084# variables for selection export
189     const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mxSelectedShapes;
190     const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mxSelectedDrawPage;
191     bool mbExportSelection;
192 
193     ::com::sun::star::uno::Reference< ::com::sun::star::document::XExporter > mxGraphicExporter;
194 
195 	PageInfoMap maPagesMap;
196 
197 	sal_uInt16 exportDrawPageBackground(sal_uInt16 nPage, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage);
198 	sal_uInt16 exportMasterPageObjects(sal_uInt16 nPage, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xMasterPage);
199 
200 	void exportDrawPageContents( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage, bool bStream, bool bMaster  );
201 	void exportShapes( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes, bool bStream, bool bMaster );
202 	void exportShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, bool bMaster);
203 
204 	sal_uInt32 ActionSummer(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape);
205 	sal_uInt32 ActionSummer(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes);
206 
207 	void animateShape( ShapeAnimationInfo& rAnimInfo );
208 	void animatePage( PageInfo* pPageInfo );
209 
210 	bool getMetaFile( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >&xComponent, GDIMetaFile& rMtf, bool bOnlyBackground = false, bool bExportAsJPEG = false );
211 
212 	Writer* mpWriter;
213 
214 	sal_Int32 mnDocWidth;
215 	sal_Int32 mnDocHeight;
216 
217 	sal_Int32 mnJPEGcompressMode;
218 
219 	sal_Bool mbExportOLEAsJPEG;
220 
221 	sal_Bool mbPresentation;
222 
223 	sal_Int32 mnPageNumber;
224 };
225 
226 }
227 
228 #endif
229