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 : enum class EppLayout
42 : {
43 : TITLESLIDE = 0, /* The slide is a title slide */
44 : TITLEANDBODYSLIDE = 1, /* Title and body slide */
45 : TITLEMASTERSLIDE = 2, /* Title master slide */
46 : MASTERSLIDE = 3, /* Master slide layout */
47 : MASTERNOTES = 4, /* Master notes layout */
48 : NOTESTITLEBODY = 5, /* Notes title/body layout */
49 : HANDOUTLAYOUT = 6, /* Handout layout, therefore it doesn't have placeholders except header, footer, and date */
50 : ONLYTITLE = 7, /* Only title placeholder */
51 : TWOCOLUMNSANDTITLE = 8, /* Body of the slide has 2 columns and a title */
52 : TWOROWSANDTITLE = 9, /* Slide's body has 2 rows and a title */
53 : RIGHTCOLUMN2ROWS = 10, /* Body contains 2 columns, right column has 2 rows */
54 : LEFTCOLUMN2ROWS = 11, /* Body contains 2 columns, left column has 2 rows */
55 : BOTTOMROW2COLUMNS = 12, /* Body contains 2 rows, bottom row has 2 columns */
56 : TOPROW2COLUMN = 13, /* Body contains 2 rows, top row has 2 columns */
57 : FOUROBJECTS = 14, /* 4 objects */
58 : BIGOBJECT = 15, /* Big object */
59 : BLANCSLIDE = 16, /* Blank slide */
60 : TITLERIGHTBODYLEFT = 17, /* Vertical title on the right, body on the left */
61 : TITLERIGHT2BODIESLEFT = 18 /* Vertical title on the right, body on the left split into 2 rows */
62 : };
63 :
64 : #define EPP_LAYOUT_SIZE 25
65 :
66 : class PptEscherEx;
67 :
68 : struct PHLayout
69 : {
70 : EppLayout nLayout;
71 : sal_uInt8 nPlaceHolder[ 8 ];
72 :
73 : sal_uInt8 nUsedObjectPlaceHolder;
74 : sal_uInt8 nTypeOfTitle;
75 : sal_uInt8 nTypeOfOutliner;
76 :
77 : bool bTitlePossible;
78 : bool bOutlinerPossible;
79 : bool bSecOutlinerPossible;
80 : };
81 :
82 : enum PageType { NORMAL = 0, MASTER = 1, NOTICE = 2, UNDEFINED = 3, LAYOUT = 4 };
83 :
84 1020 : class PropValue
85 : {
86 : protected :
87 :
88 : ::com::sun::star::uno::Any mAny;
89 :
90 : ::com::sun::star::uno::Reference
91 : < ::com::sun::star::beans::XPropertySet > mXPropSet;
92 :
93 : bool ImplGetPropertyValue( const OUString& rString );
94 : bool ImplGetPropertyValue( const ::com::sun::star::uno::Reference
95 : < ::com::sun::star::beans::XPropertySet > &, const OUString& );
96 :
97 : public :
98 :
99 1020 : PropValue() {}
100 :
101 : PropValue( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet )
102 : : mXPropSet( rXPropSet )
103 : {}
104 :
105 : ::com::sun::star::uno::Any GetAny() { return mAny; }
106 :
107 : static bool GetPropertyValue(
108 : ::com::sun::star::uno::Any& rAny,
109 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
110 : const OUString& rPropertyName,
111 : bool bTestPropertyAvailability = false );
112 :
113 : static ::com::sun::star::beans::PropertyState GetPropertyState(
114 : const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > &,
115 : const OUString& rPropertyName );
116 : };
117 :
118 : class EscherGraphicProvider;
119 : class PPTExBulletProvider
120 : {
121 : friend struct PPTExParaSheet;
122 :
123 : protected :
124 :
125 : SvMemoryStream aBuExPictureStream;
126 : SvMemoryStream aBuExOutlineStream;
127 : SvMemoryStream aBuExMasterStream;
128 :
129 : EscherGraphicProvider* pGraphicProv;
130 :
131 : public :
132 :
133 : sal_uInt16 GetId( const OString& rUniqueId, Size& rGraphicSize );
134 :
135 : PPTExBulletProvider();
136 : ~PPTExBulletProvider();
137 : };
138 :
139 70 : struct FontCollectionEntry
140 : {
141 : OUString Name;
142 : double Scaling;
143 : sal_Int16 Family;
144 : sal_Int16 Pitch;
145 : sal_Int16 CharSet;
146 :
147 : OUString Original;
148 : bool bIsConverted;
149 :
150 20 : FontCollectionEntry( const OUString& rName, sal_Int16 nFamily, sal_Int16 nPitch, sal_Int16 nCharSet ) :
151 : Scaling ( 1.0 ),
152 : Family ( nFamily ),
153 : Pitch ( nPitch ),
154 : CharSet ( nCharSet ),
155 20 : Original( rName )
156 : {
157 20 : ImplInit( rName );
158 20 : };
159 :
160 1000 : FontCollectionEntry( const OUString& rName ) :
161 : Scaling ( 1.0 ),
162 : Family ( 0 ),
163 : Pitch ( 0 ),
164 : CharSet ( 0 ),
165 1000 : Original( rName )
166 : {
167 1000 : ImplInit( rName );
168 1000 : };
169 : ~FontCollectionEntry();
170 :
171 : private :
172 :
173 : FontCollectionEntry() {}
174 :
175 : void ImplInit( const OUString& rName );
176 : };
177 :
178 : class VirtualDevice;
179 : class FontCollection
180 : {
181 : public :
182 :
183 : FontCollection();
184 :
185 : ~FontCollection();
186 :
187 : short GetScriptDirection( const OUString& rText ) const;
188 :
189 : sal_uInt32 GetId( FontCollectionEntry& rFontDescriptor );
190 :
191 1000 : inline sal_uInt32 GetCount() const { return maFonts.size(); };
192 :
193 : const FontCollectionEntry* GetById( sal_uInt32 nId );
194 :
195 50 : FontCollectionEntry& GetLast() { return *(maFonts.rbegin()); };
196 :
197 : private:
198 :
199 : VirtualDevice* pVDev;
200 : boost::ptr_vector<FontCollectionEntry> maFonts;
201 : };
202 :
203 : #define PPTEX_STYLESHEETENTRYS 9
204 :
205 : enum PPTExTextAttr
206 : {
207 : ParaAttr_BulletOn,
208 : ParaAttr_BuHardFont,
209 : ParaAttr_BuHardColor,
210 : ParaAttr_BuHardHeight,
211 : ParaAttr_BulletChar,
212 : ParaAttr_BulletFont,
213 : ParaAttr_BulletHeight,
214 : ParaAttr_BulletColor,
215 : ParaAttr_Adjust,
216 : ParaAttr_LineFeed,
217 : ParaAttr_UpperDist,
218 : ParaAttr_LowerDist,
219 : ParaAttr_TextOfs,
220 : ParaAttr_BulletOfs,
221 : ParaAttr_DefaultTab,
222 : ParaAttr_AsianLB_1,
223 : ParaAttr_AsianLB_2,
224 : ParaAttr_AsianLB_3,
225 : ParaAttr_BiDi,
226 : CharAttr_Bold,
227 : CharAttr_Italic,
228 : CharAttr_Underline,
229 : CharAttr_Shadow,
230 : CharAttr_Strikeout,
231 : CharAttr_Embossed,
232 : CharAttr_Font,
233 : CharAttr_AsianOrComplexFont,
234 : CharAttr_Symbol,
235 : CharAttr_FontHeight,
236 : CharAttr_FontColor,
237 : CharAttr_Escapement
238 : };
239 :
240 : struct PPTExCharLevel
241 : {
242 : sal_uInt16 mnFlags;
243 : sal_uInt16 mnFont;
244 : sal_uInt16 mnAsianOrComplexFont;
245 : sal_uInt16 mnFontHeight;
246 : sal_uInt16 mnEscapement;
247 : sal_uInt32 mnFontColor;
248 : };
249 :
250 : struct PPTExCharSheet
251 : {
252 : PPTExCharLevel maCharLevel[ 5 ];
253 :
254 : PPTExCharSheet( int nInstance );
255 :
256 : void SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
257 : FontCollection& rFontCollection, int nLevel );
258 : void Write( SvStream& rSt, PptEscherEx* pEx, sal_uInt16 nLev, bool bFirst, bool bSimpleText,
259 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPagePropSet );
260 :
261 : };
262 :
263 : struct PPTExParaLevel
264 : {
265 : bool mbIsBullet;
266 : sal_uInt16 mnBulletChar;
267 : sal_uInt16 mnBulletFont;
268 : sal_uInt16 mnBulletHeight;
269 : sal_uInt32 mnBulletColor;
270 :
271 : sal_uInt16 mnAdjust;
272 : sal_Int16 mnOOAdjust;
273 : sal_uInt16 mnLineFeed;
274 : sal_uInt16 mnUpperDist;
275 : sal_uInt16 mnLowerDist;
276 : sal_uInt16 mnTextOfs;
277 : sal_uInt16 mnBulletOfs;
278 : sal_uInt16 mnDefaultTab;
279 :
280 : bool mbExtendedBulletsUsed;
281 : sal_uInt16 mnBulletId;
282 : sal_uInt16 mnBulletStart;
283 : sal_uInt32 mnMappedNumType;
284 : sal_uInt32 mnNumberingType;
285 : sal_uInt16 mnAsianSettings;
286 : sal_uInt16 mnBiDi;
287 : };
288 :
289 : struct PPTExParaSheet
290 : {
291 : PPTExBulletProvider& rBuProv;
292 :
293 : sal_uInt32 mnInstance;
294 :
295 : PPTExParaLevel maParaLevel[ 5 ];
296 : PPTExParaSheet( int nInstance, sal_uInt16 nDefaultTab, PPTExBulletProvider& rProv );
297 :
298 : void SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
299 : FontCollection& rFontCollection, int nLevel, const PPTExCharLevel& rCharLevel );
300 : void Write( SvStream& rSt, PptEscherEx* pEx, sal_uInt16 nLev, bool bFirst, bool bSimpleText,
301 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPagePropSet );
302 : };
303 :
304 : class PPTExStyleSheet
305 : {
306 :
307 : public :
308 :
309 : PPTExCharSheet* mpCharSheet[ PPTEX_STYLESHEETENTRYS ];
310 : PPTExParaSheet* mpParaSheet[ PPTEX_STYLESHEETENTRYS ];
311 :
312 : PPTExStyleSheet( sal_uInt16 nDefaultTab, PPTExBulletProvider& rBuProv );
313 : ~PPTExStyleSheet();
314 :
315 0 : PPTExParaSheet& GetParaSheet( int nInstance ) { return *mpParaSheet[ nInstance ]; };
316 : PPTExCharSheet& GetCharSheet( int nInstance ) { return *mpCharSheet[ nInstance ]; };
317 :
318 : void SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
319 : FontCollection& rFontCollection, int nInstance, int nLevel );
320 : bool IsHardAttribute( sal_uInt32 nInstance, sal_uInt32 nLevel, PPTExTextAttr eAttr, sal_uInt32 nValue );
321 :
322 : sal_uInt32 SizeOfTxCFStyleAtom() const;
323 : void WriteTxCFStyleAtom( SvStream& rSt );
324 : };
325 :
326 : class PPTWriterBase : public PropValue, public GroupTable
327 : {
328 : protected:
329 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mXModel;
330 : ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > mXStatusIndicator;
331 :
332 : bool mbStatusIndicator;
333 :
334 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPagesSupplier > mXDrawPagesSupplier;
335 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPagesSupplier > mXMasterPagesSupplier;
336 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPages > mXDrawPages;
337 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mXDrawPage;
338 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mXPagePropSet;
339 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mXBackgroundPropSet;
340 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mXShapes;
341 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mXShape;
342 : ::com::sun::star::awt::Size maSize;
343 : ::com::sun::star::awt::Point maPosition;
344 : Rectangle maRect;
345 : OString mType;
346 : bool mbPresObj;
347 : bool mbEmptyPresObj;
348 : sal_Int32 mnAngle;
349 :
350 : sal_uInt32 mnPages; ///< number of Slides ( w/o master pages & notes & handout )
351 : sal_uInt32 mnMasterPages;
352 :
353 : Fraction maFraction;
354 : MapMode maMapModeSrc;
355 : MapMode maMapModeDest;
356 : ::com::sun::star::awt::Size maDestPageSize;
357 : ::com::sun::star::awt::Size maPageSize; // #i121183# Keep size in logic coordinates (100th mm)
358 : ::com::sun::star::awt::Size maNotesPageSize;
359 :
360 : PageType meLatestPageType;
361 : std::vector< PPTExStyleSheet* > maStyleSheetList;
362 : PPTExStyleSheet* mpStyleSheet;
363 :
364 : FontCollection maFontCollection;
365 :
366 0 : virtual void ImplWriteSlide( sal_uInt32 /* nPageNum */, sal_uInt32 /* nMasterNum */, sal_uInt16 /* nMode */,
367 0 : bool /* bHasBackground */, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > /* aXBackgroundPropSet */ ) {}
368 : virtual void ImplWriteNotes( sal_uInt32 nPageNum ) = 0;
369 0 : virtual void ImplWriteSlideMaster( sal_uInt32 /* nPageNum */, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > /* aXBackgroundPropSet */ ) {}
370 0 : virtual void ImplWriteLayout( sal_Int32 /* nOffset */, sal_uInt32 /* nMasterNum */ ) {}
371 :
372 20 : virtual void exportPPTPre( const std::vector< com::sun::star::beans::PropertyValue >& ) {}
373 20 : virtual void exportPPTPost() {}
374 :
375 : virtual bool ImplCreateDocument()=0;
376 : virtual bool ImplCreateMainNotes()=0;
377 :
378 : bool GetStyleSheets();
379 : bool GetShapeByIndex( sal_uInt32 nIndex, bool bGroup = false );
380 :
381 : bool CreateMainNotes();
382 :
383 : ::com::sun::star::awt::Size MapSize( const ::com::sun::star::awt::Size& );
384 : ::com::sun::star::awt::Point MapPoint( const ::com::sun::star::awt::Point& );
385 : Rectangle MapRectangle( const ::com::sun::star::awt::Rectangle& );
386 :
387 : bool ContainsOtherShapeThanPlaceholders( bool bForOOMLX );
388 :
389 : public:
390 : PPTWriterBase();
391 : PPTWriterBase( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rModel,
392 : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > & rStatInd );
393 :
394 : virtual ~PPTWriterBase();
395 :
396 : void exportPPT(const std::vector< com::sun::star::beans::PropertyValue >&);
397 :
398 : bool InitSOIface();
399 : bool GetPageByIndex( sal_uInt32 nIndex, PageType );
400 : sal_uInt32 GetMasterIndex( PageType ePageType );
401 : bool SetCurrentStyleSheet( sal_uInt32 nPageNum );
402 :
403 6 : bool GetPresObj() { return mbPresObj; }
404 :
405 : PHLayout& GetLayout( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const;
406 : PHLayout& GetLayout( sal_Int32 nOffset ) const;
407 : sal_Int32 GetLayoutOffset( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const;
408 : sal_Int32 GetLayoutOffsetFixed( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet ) const;
409 :
410 : bool CreateSlide( sal_uInt32 nPageNum );
411 : bool CreateSlideMaster( sal_uInt32 nPageNum );
412 : bool CreateNotes( sal_uInt32 nPageNum );
413 :
414 : static sal_Int8 GetTransition( sal_Int16 nTransitionType, sal_Int16 nTransitionSubtype, ::com::sun::star::presentation::FadeEffect eEffect, sal_uInt8& nDirection );
415 : static sal_Int8 GetTransition( ::com::sun::star::presentation::FadeEffect eEffect, sal_uInt8& nDirection );
416 : };
417 :
418 : #endif
419 :
420 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|