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