Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef EPPT_EPPTBASE_HXX
30 : : #define EPPT_EPPTBASE_HXX
31 : :
32 : : #include <vector>
33 : : #include <boost/ptr_container/ptr_vector.hpp>
34 : :
35 : : #include <vcl/mapmod.hxx>
36 : : #include <tools/string.hxx>
37 : : #include <tools/stream.hxx>
38 : : #include <tools/gen.hxx>
39 : : #include <com/sun/star/beans/XPropertySet.hpp>
40 : : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
41 : : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
42 : : #include <com/sun/star/drawing/XMasterPageTarget.hpp>
43 : : #include <com/sun/star/frame/XModel.hpp>
44 : : #include <com/sun/star/presentation/XPresentationSupplier.hpp>
45 : : #include <com/sun/star/presentation/FadeEffect.hpp>
46 : : #include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
47 : :
48 : : #include "grouptable.hxx"
49 : :
50 : : // PLACEMENT_ID
51 : : #define EPP_LAYOUT_TITLESLIDE 0 /* The slide is a title slide */
52 : : #define EPP_LAYOUT_TITLEANDBODYSLIDE 1 /* Title and body slide */
53 : : #define EPP_LAYOUT_TITLEMASTERSLIDE 2 /* Title master slide */
54 : : #define EPP_LAYOUT_MASTERSLIDE 3 /* Master slide layout */
55 : : #define EPP_LAYOUT_MASTERNOTES 4 /* Master notes layout */
56 : : #define EPP_LAYOUT_NOTESTITLEBODY 5 /* Notes title/body layout */
57 : : #define EPP_LAYOUT_HANDOUTLAYOUT 6 /* Handout layout, therefore it doesn't have placeholders except header, footer, and date */
58 : : #define EPP_LAYOUT_ONLYTITLE 7 /* Only title placeholder */
59 : : #define EPP_LAYOUT_2COLUMNSANDTITLE 8 /* Body of the slide has 2 columns and a title */
60 : : #define EPP_LAYOUT_2ROWSANDTITLE 9 /* Slide's body has 2 rows and a title */
61 : : #define EPP_LAYOUT_RIGHTCOLUMN2ROWS 10 /* Body contains 2 columns, right column has 2 rows */
62 : : #define EPP_LAYOUT_LEFTCOLUMN2ROWS 11 /* Body contains 2 columns, left column has 2 rows */
63 : : #define EPP_LAYOUT_BOTTOMROW2COLUMNS 12 /* Body contains 2 rows, bottom row has 2 columns */
64 : : #define EPP_LAYOUT_TOPROW2COLUMN 13 /* Body contains 2 rows, top row has 2 columns */
65 : : #define EPP_LAYOUT_4OBJECTS 14 /* 4 objects */
66 : : #define EPP_LAYOUT_BIGOBJECT 15 /* Big object */
67 : : #define EPP_LAYOUT_BLANCSLIDE 16 /* Blank slide */
68 : : #define EPP_LAYOUT_TITLERIGHTBODYLEFT 17 /* Vertical title on the right, body on the left */
69 : : #define EPP_LAYOUT_TITLERIGHT2BODIESLEFT 18 /* Vertical title on the right, body on the left split into 2 rows */
70 : :
71 : : #define EPP_LAYOUT_SIZE 25
72 : :
73 : : class PptEscherEx;
74 : :
75 : : struct PHLayout
76 : : {
77 : : sal_Int32 nLayout;
78 : : sal_uInt8 nPlaceHolder[ 8 ];
79 : :
80 : : sal_uInt8 nUsedObjectPlaceHolder;
81 : : sal_uInt8 nTypeOfTitle;
82 : : sal_uInt8 nTypeOfOutliner;
83 : :
84 : : sal_Bool bTitlePossible;
85 : : sal_Bool bOutlinerPossible;
86 : : sal_Bool bSecOutlinerPossible;
87 : : };
88 : :
89 : : enum PageType { NORMAL = 0, MASTER = 1, NOTICE = 2, UNDEFINED = 3, LAYOUT = 4 };
90 : :
91 : 0 : class PropValue
92 : : {
93 : : protected :
94 : :
95 : : ::com::sun::star::uno::Any mAny;
96 : :
97 : : ::com::sun::star::uno::Reference
98 : : < ::com::sun::star::beans::XPropertySet > mXPropSet;
99 : :
100 : : sal_Bool ImplGetPropertyValue( const String& rString );
101 : : sal_Bool ImplGetPropertyValue( const ::com::sun::star::uno::Reference
102 : : < ::com::sun::star::beans::XPropertySet > &, const String& );
103 : :
104 : : public :
105 : :
106 : 0 : PropValue() {}
107 : :
108 : : PropValue( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet )
109 : : : mXPropSet( rXPropSet )
110 : : {}
111 : :
112 : : ::com::sun::star::uno::Any GetAny() { return mAny; }
113 : :
114 : : static sal_Bool GetPropertyValue(
115 : : ::com::sun::star::uno::Any& rAny,
116 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
117 : : const String& rPropertyName,
118 : : sal_Bool bTestPropertyAvailability = sal_False );
119 : :
120 : : static ::com::sun::star::beans::PropertyState GetPropertyState(
121 : : const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > &,
122 : : const String& rPropertyName );
123 : : };
124 : :
125 : : class EscherGraphicProvider;
126 : : class PPTExBulletProvider
127 : : {
128 : : friend struct PPTExParaSheet;
129 : :
130 : : protected :
131 : :
132 : : SvMemoryStream aBuExPictureStream;
133 : : SvMemoryStream aBuExOutlineStream;
134 : : SvMemoryStream aBuExMasterStream;
135 : :
136 : : EscherGraphicProvider* pGraphicProv;
137 : :
138 : : public :
139 : :
140 : : sal_uInt16 GetId( const rtl::OString& rUniqueId, Size& rGraphicSize );
141 : :
142 : : PPTExBulletProvider();
143 : : ~PPTExBulletProvider();
144 : : };
145 : :
146 [ # # ]: 0 : struct FontCollectionEntry
147 : : {
148 : : String Name;
149 : : double Scaling;
150 : : sal_Int16 Family;
151 : : sal_Int16 Pitch;
152 : : sal_Int16 CharSet;
153 : :
154 : : String Original;
155 : : sal_Bool bIsConverted;
156 : :
157 : 0 : FontCollectionEntry( const String& rName, sal_Int16 nFamily, sal_Int16 nPitch, sal_Int16 nCharSet ) :
158 : : Scaling ( 1.0 ),
159 : : Family ( nFamily ),
160 : : Pitch ( nPitch ),
161 : : CharSet ( nCharSet ),
162 [ # # ]: 0 : Original( rName )
163 : : {
164 [ # # ]: 0 : ImplInit( rName );
165 : 0 : };
166 : :
167 : 0 : FontCollectionEntry( const String& rName ) :
168 : : Scaling ( 1.0 ),
169 [ # # ]: 0 : Original( rName )
170 : : {
171 [ # # ]: 0 : ImplInit( rName );
172 : 0 : };
173 : : ~FontCollectionEntry();
174 : :
175 : : private :
176 : :
177 : : FontCollectionEntry() {};
178 : :
179 : : void ImplInit( const String& rName );
180 : : };
181 : :
182 : : class VirtualDevice;
183 : : class FontCollection
184 : : {
185 : : public :
186 : :
187 : : FontCollection();
188 : :
189 : : ~FontCollection();
190 : :
191 : : short GetScriptDirection( const rtl::OUString& rText ) const;
192 : :
193 : : sal_uInt32 GetId( FontCollectionEntry& rFontDescriptor );
194 : :
195 : 0 : inline sal_uInt32 GetCount() const { return maFonts.size(); };
196 : :
197 : : const FontCollectionEntry* GetById( sal_uInt32 nId );
198 : :
199 [ # # ]: 0 : FontCollectionEntry& GetLast() { return *(maFonts.rbegin()); };
200 : :
201 : : private:
202 : :
203 : : VirtualDevice* pVDev;
204 : : boost::ptr_vector<FontCollectionEntry> maFonts;
205 : : };
206 : :
207 : : // ------------------------------------------------------------------------
208 : :
209 : : #define PPTEX_STYLESHEETENTRYS 9
210 : :
211 : : enum PPTExTextAttr
212 : : {
213 : : ParaAttr_BulletOn,
214 : : ParaAttr_BuHardFont,
215 : : ParaAttr_BuHardColor,
216 : : ParaAttr_BuHardHeight,
217 : : ParaAttr_BulletChar,
218 : : ParaAttr_BulletFont,
219 : : ParaAttr_BulletHeight,
220 : : ParaAttr_BulletColor,
221 : : ParaAttr_Adjust,
222 : : ParaAttr_LineFeed,
223 : : ParaAttr_UpperDist,
224 : : ParaAttr_LowerDist,
225 : : ParaAttr_TextOfs,
226 : : ParaAttr_BulletOfs,
227 : : ParaAttr_DefaultTab,
228 : : ParaAttr_AsianLB_1,
229 : : ParaAttr_AsianLB_2,
230 : : ParaAttr_AsianLB_3,
231 : : ParaAttr_BiDi,
232 : : CharAttr_Bold,
233 : : CharAttr_Italic,
234 : : CharAttr_Underline,
235 : : CharAttr_Shadow,
236 : : CharAttr_Strikeout,
237 : : CharAttr_Embossed,
238 : : CharAttr_Font,
239 : : CharAttr_AsianOrComplexFont,
240 : : CharAttr_Symbol,
241 : : CharAttr_FontHeight,
242 : : CharAttr_FontColor,
243 : : CharAttr_Escapement
244 : : };
245 : :
246 : : struct PPTExCharLevel
247 : : {
248 : : sal_uInt16 mnFlags;
249 : : sal_uInt16 mnFont;
250 : : sal_uInt16 mnAsianOrComplexFont;
251 : : sal_uInt16 mnFontHeight;
252 : : sal_uInt16 mnEscapement;
253 : : sal_uInt32 mnFontColor;
254 : : };
255 : :
256 : : struct PPTExCharSheet
257 : : {
258 : : PPTExCharLevel maCharLevel[ 5 ];
259 : :
260 : : PPTExCharSheet( int nInstance );
261 : :
262 : : void SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
263 : : FontCollection& rFontCollection, int nLevel );
264 : : void Write( SvStream& rSt, PptEscherEx* pEx, sal_uInt16 nLev, sal_Bool bFirst, sal_Bool bSimpleText,
265 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPagePropSet );
266 : :
267 : : };
268 : :
269 : : struct PPTExParaLevel
270 : : {
271 : : sal_Bool mbIsBullet;
272 : : sal_uInt16 mnBulletChar;
273 : : sal_uInt16 mnBulletFont;
274 : : sal_uInt16 mnBulletHeight;
275 : : sal_uInt32 mnBulletColor;
276 : :
277 : : sal_uInt16 mnAdjust;
278 : : sal_Int16 mnOOAdjust;
279 : : sal_uInt16 mnLineFeed;
280 : : sal_uInt16 mnUpperDist;
281 : : sal_uInt16 mnLowerDist;
282 : : sal_uInt16 mnTextOfs;
283 : : sal_uInt16 mnBulletOfs;
284 : : sal_uInt16 mnDefaultTab;
285 : :
286 : : sal_Bool mbExtendedBulletsUsed;
287 : : sal_uInt16 mnBulletId;
288 : : sal_uInt16 mnBulletStart;
289 : : sal_uInt32 mnMappedNumType;
290 : : sal_uInt32 mnNumberingType;
291 : : sal_uInt16 mnAsianSettings;
292 : : sal_uInt16 mnBiDi;
293 : : };
294 : :
295 : : struct PPTExParaSheet
296 : : {
297 : : PPTExBulletProvider& rBuProv;
298 : :
299 : : sal_uInt32 mnInstance;
300 : :
301 : : PPTExParaLevel maParaLevel[ 5 ];
302 : : PPTExParaSheet( int nInstance, sal_uInt16 nDefaultTab, PPTExBulletProvider& rProv );
303 : :
304 : : void SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
305 : : FontCollection& rFontCollection, int nLevel, const PPTExCharLevel& rCharLevel );
306 : : void Write( SvStream& rSt, PptEscherEx* pEx, sal_uInt16 nLev, sal_Bool bFirst, sal_Bool bSimpleText,
307 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPagePropSet );
308 : : };
309 : :
310 : : class PPTExStyleSheet
311 : : {
312 : :
313 : : public :
314 : :
315 : : PPTExCharSheet* mpCharSheet[ PPTEX_STYLESHEETENTRYS ];
316 : : PPTExParaSheet* mpParaSheet[ PPTEX_STYLESHEETENTRYS ];
317 : :
318 : : PPTExStyleSheet( sal_uInt16 nDefaultTab, PPTExBulletProvider& rBuProv );
319 : : ~PPTExStyleSheet();
320 : :
321 : 0 : PPTExParaSheet& GetParaSheet( int nInstance ) { return *mpParaSheet[ nInstance ]; };
322 : : PPTExCharSheet& GetCharSheet( int nInstance ) { return *mpCharSheet[ nInstance ]; };
323 : :
324 : : void SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
325 : : FontCollection& rFontCollection, int nInstance, int nLevel );
326 : : sal_Bool IsHardAttribute( sal_uInt32 nInstance, sal_uInt32 nLevel, PPTExTextAttr eAttr, sal_uInt32 nValue );
327 : :
328 : : sal_uInt32 SizeOfTxCFStyleAtom() const;
329 : : void WriteTxCFStyleAtom( SvStream& rSt );
330 : : };
331 : :
332 : : // ------------------------------------------------------------------------
333 : :
334 : : class PPTWriterBase : public PropValue, public GroupTable
335 : : {
336 : : protected:
337 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mXModel;
338 : : ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > mXStatusIndicator;
339 : :
340 : : sal_Bool mbStatusIndicator;
341 : :
342 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPagesSupplier > mXDrawPagesSupplier;
343 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPagesSupplier > mXMasterPagesSupplier;
344 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPages > mXDrawPages;
345 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mXDrawPage;
346 : : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mXPagePropSet;
347 : : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mXBackgroundPropSet;
348 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mXShapes;
349 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mXShape;
350 : : ::com::sun::star::awt::Size maSize;
351 : : ::com::sun::star::awt::Point maPosition;
352 : : Rectangle maRect;
353 : : rtl::OString mType;
354 : : sal_Bool mbPresObj;
355 : : sal_Bool mbEmptyPresObj;
356 : : sal_Int32 mnAngle;
357 : :
358 : : sal_uInt32 mnPages; ///< number of Slides ( w/o master pages & notes & handout )
359 : : sal_uInt32 mnMasterPages;
360 : :
361 : : Fraction maFraction;
362 : : MapMode maMapModeSrc;
363 : : MapMode maMapModeDest;
364 : : ::com::sun::star::awt::Size maDestPageSize;
365 : : ::com::sun::star::awt::Size maNotesPageSize;
366 : :
367 : : PageType meLatestPageType;
368 : : std::vector< PPTExStyleSheet* > maStyleSheetList;
369 : : PPTExStyleSheet* mpStyleSheet;
370 : :
371 : : FontCollection maFontCollection;
372 : :
373 : 0 : virtual void ImplWriteSlide( sal_uInt32 /* nPageNum */, sal_uInt32 /* nMasterNum */, sal_uInt16 /* nMode */,
374 : 0 : sal_Bool /* bHasBackground */, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > /* aXBackgroundPropSet */ ) {}
375 : : virtual void ImplWriteNotes( sal_uInt32 nPageNum ) = 0;
376 : 0 : virtual void ImplWriteSlideMaster( sal_uInt32 /* nPageNum */, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > /* aXBackgroundPropSet */ ) {}
377 : 0 : virtual void ImplWriteLayout( sal_Int32 /* nOffset */, sal_uInt32 /* nMasterNum */ ) {}
378 : :
379 : 0 : virtual void exportPPTPre( const std::vector< com::sun::star::beans::PropertyValue >& ) {}
380 : 0 : virtual void exportPPTPost() {}
381 : :
382 : : virtual sal_Bool ImplCreateDocument()=0;
383 : : virtual sal_Bool ImplCreateMainNotes()=0;
384 : :
385 : : sal_Bool GetStyleSheets();
386 : : sal_Bool GetShapeByIndex( sal_uInt32 nIndex, sal_Bool bGroup = sal_False );
387 : :
388 : : sal_Bool CreateMainNotes();
389 : :
390 : : ::com::sun::star::awt::Size MapSize( const ::com::sun::star::awt::Size& );
391 : : ::com::sun::star::awt::Point MapPoint( const ::com::sun::star::awt::Point& );
392 : : Rectangle MapRectangle( const ::com::sun::star::awt::Rectangle& );
393 : :
394 : : sal_Bool ContainsOtherShapeThanPlaceholders( sal_Bool bForOOMLX );
395 : :
396 : : public:
397 : : PPTWriterBase();
398 : : PPTWriterBase( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rModel,
399 : : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > & rStatInd );
400 : :
401 : : virtual ~PPTWriterBase();
402 : :
403 : : void exportPPT(const std::vector< com::sun::star::beans::PropertyValue >&);
404 : :
405 : : sal_Bool InitSOIface();
406 : : sal_Bool GetPageByIndex( sal_uInt32 nIndex, PageType );
407 : : sal_uInt32 GetMasterIndex( PageType ePageType );
408 : : sal_Bool SetCurrentStyleSheet( sal_uInt32 nPageNum );
409 : :
410 : 0 : sal_Bool GetPresObj() { return mbPresObj; }
411 : :
412 : : PHLayout& GetLayout( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const;
413 : : PHLayout& GetLayout( sal_Int32 nOffset ) const;
414 : : sal_Int32 GetLayoutOffset( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const;
415 : : sal_Int32 GetLayoutOffsetFixed( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const;
416 : :
417 : : sal_Bool CreateSlide( sal_uInt32 nPageNum );
418 : : sal_Bool CreateSlideMaster( sal_uInt32 nPageNum );
419 : : sal_Bool CreateNotes( sal_uInt32 nPageNum );
420 : :
421 : : static sal_Int8 GetTransition( sal_Int16 nTransitionType, sal_Int16 nTransitionSubtype, ::com::sun::star::presentation::FadeEffect eEffect, sal_uInt8& nDirection );
422 : : static sal_Int8 GetTransition( ::com::sun::star::presentation::FadeEffect eEffect, sal_uInt8& nDirection );
423 : : };
424 : :
425 : : #define PPT_TRANSITION_TYPE_NONE 0
426 : : #define PPT_TRANSITION_TYPE_RANDOM 1
427 : : #define PPT_TRANSITION_TYPE_BLINDS 2
428 : : #define PPT_TRANSITION_TYPE_CHECKER 3
429 : : #define PPT_TRANSITION_TYPE_COVER 4
430 : : #define PPT_TRANSITION_TYPE_DISSOLVE 5
431 : : #define PPT_TRANSITION_TYPE_FADE 6
432 : : #define PPT_TRANSITION_TYPE_PULL 7
433 : : #define PPT_TRANSITION_TYPE_RANDOM_BARS 8
434 : : #define PPT_TRANSITION_TYPE_STRIPS 9
435 : : #define PPT_TRANSITION_TYPE_WIPE 10
436 : : #define PPT_TRANSITION_TYPE_ZOOM 11
437 : : #define PPT_TRANSITION_TYPE_SPLIT 13
438 : :
439 : : // effects, new in xp
440 : : #define PPT_TRANSITION_TYPE_DIAMOND 17
441 : : #define PPT_TRANSITION_TYPE_PLUS 18
442 : : #define PPT_TRANSITION_TYPE_WEDGE 19
443 : : #define PPT_TRANSITION_TYPE_PUSH 20
444 : : #define PPT_TRANSITION_TYPE_COMB 21
445 : : #define PPT_TRANSITION_TYPE_NEWSFLASH 22
446 : : #define PPT_TRANSITION_TYPE_SMOOTHFADE 23
447 : : #define PPT_TRANSITION_TYPE_WHEEL 26
448 : : #define PPT_TRANSITION_TYPE_CIRCLE 27
449 : :
450 : : #endif
451 : :
452 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|