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 INCLUDED_SD_SOURCE_FILTER_EPPT_EPPTBASE_HXX
21 : #define INCLUDED_SD_SOURCE_FILTER_EPPT_EPPTBASE_HXX
22 :
23 : #include <vector>
24 : #include <boost/ptr_container/ptr_vector.hpp>
25 :
26 : #include <vcl/mapmod.hxx>
27 : #include <tools/stream.hxx>
28 : #include <tools/gen.hxx>
29 : #include <com/sun/star/beans/XPropertySet.hpp>
30 : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
31 : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
32 : #include <com/sun/star/drawing/XMasterPageTarget.hpp>
33 : #include <com/sun/star/frame/XModel.hpp>
34 : #include <com/sun/star/presentation/XPresentationSupplier.hpp>
35 : #include <com/sun/star/presentation/FadeEffect.hpp>
36 : #include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
37 :
38 : #include "grouptable.hxx"
39 :
40 : // PLACEMENT_ID
41 : #define EPP_LAYOUT_TITLESLIDE 0 /* The slide is a title slide */
42 : #define EPP_LAYOUT_TITLEANDBODYSLIDE 1 /* Title and body slide */
43 : #define EPP_LAYOUT_TITLEMASTERSLIDE 2 /* Title master slide */
44 : #define EPP_LAYOUT_MASTERSLIDE 3 /* Master slide layout */
45 : #define EPP_LAYOUT_MASTERNOTES 4 /* Master notes layout */
46 : #define EPP_LAYOUT_NOTESTITLEBODY 5 /* Notes title/body layout */
47 : #define EPP_LAYOUT_HANDOUTLAYOUT 6 /* Handout layout, therefore it doesn't have placeholders except header, footer, and date */
48 : #define EPP_LAYOUT_ONLYTITLE 7 /* Only title placeholder */
49 : #define EPP_LAYOUT_2COLUMNSANDTITLE 8 /* Body of the slide has 2 columns and a title */
50 : #define EPP_LAYOUT_2ROWSANDTITLE 9 /* Slide's body has 2 rows and a title */
51 : #define EPP_LAYOUT_RIGHTCOLUMN2ROWS 10 /* Body contains 2 columns, right column has 2 rows */
52 : #define EPP_LAYOUT_LEFTCOLUMN2ROWS 11 /* Body contains 2 columns, left column has 2 rows */
53 : #define EPP_LAYOUT_BOTTOMROW2COLUMNS 12 /* Body contains 2 rows, bottom row has 2 columns */
54 : #define EPP_LAYOUT_TOPROW2COLUMN 13 /* Body contains 2 rows, top row has 2 columns */
55 : #define EPP_LAYOUT_4OBJECTS 14 /* 4 objects */
56 : #define EPP_LAYOUT_BIGOBJECT 15 /* Big object */
57 : #define EPP_LAYOUT_BLANCSLIDE 16 /* Blank slide */
58 : #define EPP_LAYOUT_TITLERIGHTBODYLEFT 17 /* Vertical title on the right, body on the left */
59 : #define EPP_LAYOUT_TITLERIGHT2BODIESLEFT 18 /* Vertical title on the right, body on the left split into 2 rows */
60 :
61 : #define EPP_LAYOUT_SIZE 25
62 :
63 : class PptEscherEx;
64 :
65 : struct PHLayout
66 : {
67 : sal_Int32 nLayout;
68 : sal_uInt8 nPlaceHolder[ 8 ];
69 :
70 : sal_uInt8 nUsedObjectPlaceHolder;
71 : sal_uInt8 nTypeOfTitle;
72 : sal_uInt8 nTypeOfOutliner;
73 :
74 : sal_Bool bTitlePossible;
75 : sal_Bool bOutlinerPossible;
76 : sal_Bool bSecOutlinerPossible;
77 : };
78 :
79 : enum PageType { NORMAL = 0, MASTER = 1, NOTICE = 2, UNDEFINED = 3, LAYOUT = 4 };
80 :
81 0 : class PropValue
82 : {
83 : protected :
84 :
85 : ::com::sun::star::uno::Any mAny;
86 :
87 : ::com::sun::star::uno::Reference
88 : < ::com::sun::star::beans::XPropertySet > mXPropSet;
89 :
90 : sal_Bool ImplGetPropertyValue( const OUString& rString );
91 : sal_Bool ImplGetPropertyValue( const ::com::sun::star::uno::Reference
92 : < ::com::sun::star::beans::XPropertySet > &, const OUString& );
93 :
94 : public :
95 :
96 0 : PropValue() {}
97 :
98 : PropValue( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet )
99 : : mXPropSet( rXPropSet )
100 : {}
101 :
102 : ::com::sun::star::uno::Any GetAny() { return mAny; }
103 :
104 : static sal_Bool GetPropertyValue(
105 : ::com::sun::star::uno::Any& rAny,
106 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
107 : const OUString& rPropertyName,
108 : sal_Bool bTestPropertyAvailability = sal_False );
109 :
110 : static ::com::sun::star::beans::PropertyState GetPropertyState(
111 : const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > &,
112 : const OUString& rPropertyName );
113 : };
114 :
115 : class EscherGraphicProvider;
116 : class PPTExBulletProvider
117 : {
118 : friend struct PPTExParaSheet;
119 :
120 : protected :
121 :
122 : SvMemoryStream aBuExPictureStream;
123 : SvMemoryStream aBuExOutlineStream;
124 : SvMemoryStream aBuExMasterStream;
125 :
126 : EscherGraphicProvider* pGraphicProv;
127 :
128 : public :
129 :
130 : sal_uInt16 GetId( const OString& rUniqueId, Size& rGraphicSize );
131 :
132 : PPTExBulletProvider();
133 : ~PPTExBulletProvider();
134 : };
135 :
136 0 : struct FontCollectionEntry
137 : {
138 : OUString Name;
139 : double Scaling;
140 : sal_Int16 Family;
141 : sal_Int16 Pitch;
142 : sal_Int16 CharSet;
143 :
144 : OUString Original;
145 : sal_Bool bIsConverted;
146 :
147 0 : FontCollectionEntry( const OUString& rName, sal_Int16 nFamily, sal_Int16 nPitch, sal_Int16 nCharSet ) :
148 : Scaling ( 1.0 ),
149 : Family ( nFamily ),
150 : Pitch ( nPitch ),
151 : CharSet ( nCharSet ),
152 0 : Original( rName )
153 : {
154 0 : ImplInit( rName );
155 0 : };
156 :
157 0 : FontCollectionEntry( const OUString& rName ) :
158 : Scaling ( 1.0 ),
159 : Family ( 0 ),
160 : Pitch ( 0 ),
161 : CharSet ( 0 ),
162 0 : Original( rName )
163 : {
164 0 : ImplInit( rName );
165 0 : };
166 : ~FontCollectionEntry();
167 :
168 : private :
169 :
170 : FontCollectionEntry() {}
171 :
172 : void ImplInit( const OUString& rName );
173 : };
174 :
175 : class VirtualDevice;
176 : class FontCollection
177 : {
178 : public :
179 :
180 : FontCollection();
181 :
182 : ~FontCollection();
183 :
184 : short GetScriptDirection( const OUString& rText ) const;
185 :
186 : sal_uInt32 GetId( FontCollectionEntry& rFontDescriptor );
187 :
188 0 : inline sal_uInt32 GetCount() const { return maFonts.size(); };
189 :
190 : const FontCollectionEntry* GetById( sal_uInt32 nId );
191 :
192 0 : FontCollectionEntry& GetLast() { return *(maFonts.rbegin()); };
193 :
194 : private:
195 :
196 : VirtualDevice* pVDev;
197 : boost::ptr_vector<FontCollectionEntry> maFonts;
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 : class PPTWriterBase : public PropValue, public GroupTable
324 : {
325 : protected:
326 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mXModel;
327 : ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > mXStatusIndicator;
328 :
329 : sal_Bool mbStatusIndicator;
330 :
331 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPagesSupplier > mXDrawPagesSupplier;
332 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPagesSupplier > mXMasterPagesSupplier;
333 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPages > mXDrawPages;
334 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mXDrawPage;
335 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mXPagePropSet;
336 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mXBackgroundPropSet;
337 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mXShapes;
338 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mXShape;
339 : ::com::sun::star::awt::Size maSize;
340 : ::com::sun::star::awt::Point maPosition;
341 : Rectangle maRect;
342 : OString mType;
343 : sal_Bool mbPresObj;
344 : sal_Bool mbEmptyPresObj;
345 : sal_Int32 mnAngle;
346 :
347 : sal_uInt32 mnPages; ///< number of Slides ( w/o master pages & notes & handout )
348 : sal_uInt32 mnMasterPages;
349 :
350 : Fraction maFraction;
351 : MapMode maMapModeSrc;
352 : MapMode maMapModeDest;
353 : ::com::sun::star::awt::Size maDestPageSize;
354 : ::com::sun::star::awt::Size maPageSize; // #i121183# Keep size in logic coordinates (100th mm)
355 : ::com::sun::star::awt::Size maNotesPageSize;
356 :
357 : PageType meLatestPageType;
358 : std::vector< PPTExStyleSheet* > maStyleSheetList;
359 : PPTExStyleSheet* mpStyleSheet;
360 :
361 : FontCollection maFontCollection;
362 :
363 0 : virtual void ImplWriteSlide( sal_uInt32 /* nPageNum */, sal_uInt32 /* nMasterNum */, sal_uInt16 /* nMode */,
364 0 : sal_Bool /* bHasBackground */, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > /* aXBackgroundPropSet */ ) {}
365 : virtual void ImplWriteNotes( sal_uInt32 nPageNum ) = 0;
366 0 : virtual void ImplWriteSlideMaster( sal_uInt32 /* nPageNum */, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > /* aXBackgroundPropSet */ ) {}
367 0 : virtual void ImplWriteLayout( sal_Int32 /* nOffset */, sal_uInt32 /* nMasterNum */ ) {}
368 :
369 0 : virtual void exportPPTPre( const std::vector< com::sun::star::beans::PropertyValue >& ) {}
370 0 : virtual void exportPPTPost() {}
371 :
372 : virtual sal_Bool ImplCreateDocument()=0;
373 : virtual sal_Bool ImplCreateMainNotes()=0;
374 :
375 : sal_Bool GetStyleSheets();
376 : sal_Bool GetShapeByIndex( sal_uInt32 nIndex, sal_Bool bGroup = sal_False );
377 :
378 : sal_Bool CreateMainNotes();
379 :
380 : ::com::sun::star::awt::Size MapSize( const ::com::sun::star::awt::Size& );
381 : ::com::sun::star::awt::Point MapPoint( const ::com::sun::star::awt::Point& );
382 : Rectangle MapRectangle( const ::com::sun::star::awt::Rectangle& );
383 :
384 : sal_Bool ContainsOtherShapeThanPlaceholders( sal_Bool bForOOMLX );
385 :
386 : public:
387 : PPTWriterBase();
388 : PPTWriterBase( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rModel,
389 : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > & rStatInd );
390 :
391 : virtual ~PPTWriterBase();
392 :
393 : void exportPPT(const std::vector< com::sun::star::beans::PropertyValue >&);
394 :
395 : sal_Bool InitSOIface();
396 : sal_Bool GetPageByIndex( sal_uInt32 nIndex, PageType );
397 : sal_uInt32 GetMasterIndex( PageType ePageType );
398 : sal_Bool SetCurrentStyleSheet( sal_uInt32 nPageNum );
399 :
400 0 : sal_Bool GetPresObj() { return mbPresObj; }
401 :
402 : PHLayout& GetLayout( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const;
403 : PHLayout& GetLayout( sal_Int32 nOffset ) const;
404 : sal_Int32 GetLayoutOffset( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const;
405 : sal_Int32 GetLayoutOffsetFixed( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const;
406 :
407 : sal_Bool CreateSlide( sal_uInt32 nPageNum );
408 : sal_Bool CreateSlideMaster( sal_uInt32 nPageNum );
409 : sal_Bool CreateNotes( sal_uInt32 nPageNum );
410 :
411 : static sal_Int8 GetTransition( sal_Int16 nTransitionType, sal_Int16 nTransitionSubtype, ::com::sun::star::presentation::FadeEffect eEffect, sal_uInt8& nDirection );
412 : static sal_Int8 GetTransition( ::com::sun::star::presentation::FadeEffect eEffect, sal_uInt8& nDirection );
413 : };
414 :
415 : #define PPT_TRANSITION_TYPE_NONE 0
416 : #define PPT_TRANSITION_TYPE_RANDOM 1
417 : #define PPT_TRANSITION_TYPE_BLINDS 2
418 : #define PPT_TRANSITION_TYPE_CHECKER 3
419 : #define PPT_TRANSITION_TYPE_COVER 4
420 : #define PPT_TRANSITION_TYPE_DISSOLVE 5
421 : #define PPT_TRANSITION_TYPE_FADE 6
422 : #define PPT_TRANSITION_TYPE_PULL 7
423 : #define PPT_TRANSITION_TYPE_RANDOM_BARS 8
424 : #define PPT_TRANSITION_TYPE_STRIPS 9
425 : #define PPT_TRANSITION_TYPE_WIPE 10
426 : #define PPT_TRANSITION_TYPE_ZOOM 11
427 : #define PPT_TRANSITION_TYPE_SPLIT 13
428 :
429 : // effects, new in xp
430 : #define PPT_TRANSITION_TYPE_DIAMOND 17
431 : #define PPT_TRANSITION_TYPE_PLUS 18
432 : #define PPT_TRANSITION_TYPE_WEDGE 19
433 : #define PPT_TRANSITION_TYPE_PUSH 20
434 : #define PPT_TRANSITION_TYPE_COMB 21
435 : #define PPT_TRANSITION_TYPE_NEWSFLASH 22
436 : #define PPT_TRANSITION_TYPE_SMOOTHFADE 23
437 : #define PPT_TRANSITION_TYPE_WHEEL 26
438 : #define PPT_TRANSITION_TYPE_CIRCLE 27
439 :
440 : #endif
441 :
442 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|