bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / filter / eppt / epptbase.hxx
blob50fa5f12e4055c7772ee133d18927db342c23286
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SD_SOURCE_FILTER_EPPT_EPPTBASE_HXX
21 #define INCLUDED_SD_SOURCE_FILTER_EPPT_EPPTBASE_HXX
23 #include <vector>
24 #include <boost/ptr_container/ptr_vector.hpp>
26 #include <vcl/mapmod.hxx>
27 #include <tools/stream.hxx>
28 #include <tools/fract.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 #include <vcl/vclptr.hxx>
39 #include <vcl/outdev.hxx>
41 #include "grouptable.hxx"
43 // PLACEMENT_ID
44 enum class EppLayout
46 TITLESLIDE = 0, /* The slide is a title slide */
47 TITLEANDBODYSLIDE = 1, /* Title and body slide */
48 TITLEMASTERSLIDE = 2, /* Title master slide */
49 MASTERSLIDE = 3, /* Master slide layout */
50 MASTERNOTES = 4, /* Master notes layout */
51 NOTESTITLEBODY = 5, /* Notes title/body layout */
52 HANDOUTLAYOUT = 6, /* Handout layout, therefore it doesn't have placeholders except header, footer, and date */
53 ONLYTITLE = 7, /* Only title placeholder */
54 TWOCOLUMNSANDTITLE = 8, /* Body of the slide has 2 columns and a title */
55 TWOROWSANDTITLE = 9, /* Slide's body has 2 rows and a title */
56 RIGHTCOLUMN2ROWS = 10, /* Body contains 2 columns, right column has 2 rows */
57 LEFTCOLUMN2ROWS = 11, /* Body contains 2 columns, left column has 2 rows */
58 BOTTOMROW2COLUMNS = 12, /* Body contains 2 rows, bottom row has 2 columns */
59 TOPROW2COLUMN = 13, /* Body contains 2 rows, top row has 2 columns */
60 FOUROBJECTS = 14, /* 4 objects */
61 BIGOBJECT = 15, /* Big object */
62 BLANCSLIDE = 16, /* Blank slide */
63 TITLERIGHTBODYLEFT = 17, /* Vertical title on the right, body on the left */
64 TITLERIGHT2BODIESLEFT = 18 /* Vertical title on the right, body on the left split into 2 rows */
67 #define EPP_LAYOUT_SIZE 25
69 class PptEscherEx;
71 struct PHLayout
73 EppLayout nLayout;
74 sal_uInt8 nPlaceHolder[ 8 ];
76 sal_uInt8 nUsedObjectPlaceHolder;
77 sal_uInt8 nTypeOfTitle;
78 sal_uInt8 nTypeOfOutliner;
80 bool bTitlePossible;
81 bool bOutlinerPossible;
82 bool bSecOutlinerPossible;
85 enum PageType { NORMAL = 0, MASTER = 1, NOTICE = 2, UNDEFINED = 3, LAYOUT = 4 };
87 class PropValue
89 protected :
91 ::com::sun::star::uno::Any mAny;
93 ::com::sun::star::uno::Reference
94 < ::com::sun::star::beans::XPropertySet > mXPropSet;
96 bool ImplGetPropertyValue( const OUString& rString );
97 bool ImplGetPropertyValue( const ::com::sun::star::uno::Reference
98 < ::com::sun::star::beans::XPropertySet > &, const OUString& );
100 public :
102 PropValue() {}
104 PropValue( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet )
105 : mXPropSet( rXPropSet )
108 ::com::sun::star::uno::Any GetAny() { return mAny; }
110 static bool GetPropertyValue(
111 ::com::sun::star::uno::Any& rAny,
112 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
113 const OUString& rPropertyName,
114 bool bTestPropertyAvailability = false );
116 static ::com::sun::star::beans::PropertyState GetPropertyState(
117 const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > &,
118 const OUString& rPropertyName );
121 class EscherGraphicProvider;
122 class PPTExBulletProvider
124 friend struct PPTExParaSheet;
126 protected :
128 SvMemoryStream aBuExPictureStream;
129 SvMemoryStream aBuExOutlineStream;
130 SvMemoryStream aBuExMasterStream;
132 EscherGraphicProvider* pGraphicProv;
134 public :
136 sal_uInt16 GetId( const OString& rUniqueId, Size& rGraphicSize );
138 PPTExBulletProvider();
139 ~PPTExBulletProvider();
142 struct FontCollectionEntry
144 OUString Name;
145 double Scaling;
146 sal_Int16 Family;
147 sal_Int16 Pitch;
148 sal_Int16 CharSet;
150 OUString Original;
151 bool bIsConverted;
153 FontCollectionEntry( const OUString& rName, sal_Int16 nFamily, sal_Int16 nPitch, sal_Int16 nCharSet ) :
154 Scaling ( 1.0 ),
155 Family ( nFamily ),
156 Pitch ( nPitch ),
157 CharSet ( nCharSet ),
158 Original( rName )
160 ImplInit( rName );
163 FontCollectionEntry( const OUString& rName ) :
164 Scaling ( 1.0 ),
165 Family ( 0 ),
166 Pitch ( 0 ),
167 CharSet ( 0 ),
168 Original( rName )
170 ImplInit( rName );
172 ~FontCollectionEntry();
174 private :
176 FontCollectionEntry() {}
178 void ImplInit( const OUString& rName );
181 class FontCollection
183 public :
185 FontCollection();
187 ~FontCollection();
189 static short GetScriptDirection( const OUString& rText );
191 sal_uInt32 GetId( FontCollectionEntry& rFontDescriptor );
193 inline sal_uInt32 GetCount() const { return maFonts.size(); };
195 const FontCollectionEntry* GetById( sal_uInt32 nId );
197 FontCollectionEntry& GetLast() { return *(maFonts.rbegin()); };
199 private:
201 VclPtr<VirtualDevice> pVDev;
202 boost::ptr_vector<FontCollectionEntry> maFonts;
205 #define PPTEX_STYLESHEETENTRYS 9
207 enum PPTExTextAttr
209 ParaAttr_BulletOn,
210 ParaAttr_BuHardFont,
211 ParaAttr_BuHardColor,
212 ParaAttr_BuHardHeight,
213 ParaAttr_BulletChar,
214 ParaAttr_BulletFont,
215 ParaAttr_BulletHeight,
216 ParaAttr_BulletColor,
217 ParaAttr_Adjust,
218 ParaAttr_LineFeed,
219 ParaAttr_UpperDist,
220 ParaAttr_LowerDist,
221 ParaAttr_TextOfs,
222 ParaAttr_BulletOfs,
223 ParaAttr_DefaultTab,
224 ParaAttr_AsianLB_1,
225 ParaAttr_AsianLB_2,
226 ParaAttr_AsianLB_3,
227 ParaAttr_BiDi,
228 CharAttr_Bold,
229 CharAttr_Italic,
230 CharAttr_Underline,
231 CharAttr_Shadow,
232 CharAttr_Strikeout,
233 CharAttr_Embossed,
234 CharAttr_Font,
235 CharAttr_AsianOrComplexFont,
236 CharAttr_Symbol,
237 CharAttr_FontHeight,
238 CharAttr_FontColor,
239 CharAttr_Escapement
242 struct PPTExCharLevel
244 sal_uInt16 mnFlags;
245 sal_uInt16 mnFont;
246 sal_uInt16 mnAsianOrComplexFont;
247 sal_uInt16 mnFontHeight;
248 sal_uInt16 mnEscapement;
249 sal_uInt32 mnFontColor;
252 struct PPTExCharSheet
254 PPTExCharLevel maCharLevel[ 5 ];
256 PPTExCharSheet( int nInstance );
258 void SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
259 FontCollection& rFontCollection, int nLevel );
260 void Write( SvStream& rSt, PptEscherEx* pEx, sal_uInt16 nLev, bool bFirst, bool bSimpleText,
261 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPagePropSet );
265 struct PPTExParaLevel
267 bool mbIsBullet;
268 sal_uInt16 mnBulletChar;
269 sal_uInt16 mnBulletFont;
270 sal_uInt16 mnBulletHeight;
271 sal_uInt32 mnBulletColor;
273 sal_uInt16 mnAdjust;
274 sal_Int16 mnOOAdjust;
275 sal_uInt16 mnLineFeed;
276 sal_uInt16 mnUpperDist;
277 sal_uInt16 mnLowerDist;
278 sal_uInt16 mnTextOfs;
279 sal_uInt16 mnBulletOfs;
280 sal_uInt16 mnDefaultTab;
282 bool mbExtendedBulletsUsed;
283 sal_uInt16 mnBulletId;
284 sal_uInt16 mnBulletStart;
285 sal_uInt32 mnMappedNumType;
286 sal_uInt32 mnNumberingType;
287 sal_uInt16 mnAsianSettings;
288 sal_uInt16 mnBiDi;
291 struct PPTExParaSheet
293 PPTExBulletProvider* pBuProv;
295 sal_uInt32 mnInstance;
297 PPTExParaLevel maParaLevel[ 5 ];
298 PPTExParaSheet( int nInstance, sal_uInt16 nDefaultTab, PPTExBulletProvider* pProv );
300 void SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
301 FontCollection& rFontCollection, int nLevel, const PPTExCharLevel& rCharLevel );
302 void Write( SvStream& rSt, PptEscherEx* pEx, sal_uInt16 nLev, bool bFirst, bool bSimpleText,
303 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPagePropSet );
306 class PPTExStyleSheet
309 public :
311 PPTExCharSheet* mpCharSheet[ PPTEX_STYLESHEETENTRYS ];
312 PPTExParaSheet* mpParaSheet[ PPTEX_STYLESHEETENTRYS ];
314 PPTExStyleSheet( sal_uInt16 nDefaultTab, PPTExBulletProvider* pBuProv );
315 ~PPTExStyleSheet();
317 PPTExParaSheet& GetParaSheet( int nInstance ) { return *mpParaSheet[ nInstance ]; };
318 PPTExCharSheet& GetCharSheet( int nInstance ) { return *mpCharSheet[ nInstance ]; };
320 void SetStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &,
321 FontCollection& rFontCollection, int nInstance, int nLevel );
322 bool IsHardAttribute( sal_uInt32 nInstance, sal_uInt32 nLevel, PPTExTextAttr eAttr, sal_uInt32 nValue );
324 static sal_uInt32 SizeOfTxCFStyleAtom() { return 24; }
325 void WriteTxCFStyleAtom( SvStream& rSt );
328 class PPTWriterBase : public PropValue, public GroupTable
330 protected:
331 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mXModel;
332 ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > mXStatusIndicator;
334 bool mbStatusIndicator;
336 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPagesSupplier > mXDrawPagesSupplier;
337 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XMasterPagesSupplier > mXMasterPagesSupplier;
338 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPages > mXDrawPages;
339 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mXDrawPage;
340 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mXPagePropSet;
341 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mXBackgroundPropSet;
342 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mXShapes;
343 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mXShape;
344 ::com::sun::star::awt::Size maSize;
345 ::com::sun::star::awt::Point maPosition;
346 Rectangle maRect;
347 OString mType;
348 bool mbPresObj;
349 bool mbEmptyPresObj;
350 bool mbIsBackgroundDark;
351 sal_Int32 mnAngle;
353 sal_uInt32 mnPages; ///< number of Slides ( w/o master pages & notes & handout )
354 sal_uInt32 mnMasterPages;
356 Fraction maFraction;
357 MapMode maMapModeSrc;
358 MapMode maMapModeDest;
359 ::com::sun::star::awt::Size maDestPageSize;
360 ::com::sun::star::awt::Size maPageSize; // #i121183# Keep size in logic coordinates (100th mm)
361 ::com::sun::star::awt::Size maNotesPageSize;
363 PageType meLatestPageType;
364 std::vector< PPTExStyleSheet* > maStyleSheetList;
365 PPTExStyleSheet* mpStyleSheet;
367 FontCollection maFontCollection;
369 virtual void ImplWriteSlide( sal_uInt32 /* nPageNum */, sal_uInt32 /* nMasterNum */, sal_uInt16 /* nMode */,
370 bool /* bHasBackground */, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > /* aXBackgroundPropSet */ ) {}
371 virtual void ImplWriteNotes( sal_uInt32 nPageNum ) = 0;
372 virtual void ImplWriteSlideMaster( sal_uInt32 /* nPageNum */, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > /* aXBackgroundPropSet */ ) {}
373 virtual void ImplWriteLayout( sal_Int32 /* nOffset */, sal_uInt32 /* nMasterNum */ ) {}
375 virtual void exportPPTPre( const std::vector< com::sun::star::beans::PropertyValue >& ) {}
376 virtual void exportPPTPost() {}
378 virtual bool ImplCreateDocument()=0;
379 virtual bool ImplCreateMainNotes()=0;
381 bool GetStyleSheets();
382 bool GetShapeByIndex( sal_uInt32 nIndex, bool bGroup = false );
384 bool CreateMainNotes();
386 ::com::sun::star::awt::Size MapSize( const ::com::sun::star::awt::Size& );
387 ::com::sun::star::awt::Point MapPoint( const ::com::sun::star::awt::Point& );
388 Rectangle MapRectangle( const ::com::sun::star::awt::Rectangle& );
390 bool ContainsOtherShapeThanPlaceholders( bool bForOOMLX );
392 public:
393 PPTWriterBase();
394 PPTWriterBase( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rModel,
395 const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > & rStatInd );
397 virtual ~PPTWriterBase();
399 void exportPPT(const std::vector< com::sun::star::beans::PropertyValue >&);
401 bool InitSOIface();
402 bool GetPageByIndex( sal_uInt32 nIndex, PageType );
403 sal_uInt32 GetMasterIndex( PageType ePageType );
404 bool SetCurrentStyleSheet( sal_uInt32 nPageNum );
406 bool GetPresObj() { return mbPresObj; }
408 static PHLayout& GetLayout( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet );
409 static PHLayout& GetLayout( sal_Int32 nOffset );
410 static sal_Int32 GetLayoutOffset( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet );
411 static sal_Int32 GetLayoutOffsetFixed( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet );
413 bool CreateSlide( sal_uInt32 nPageNum );
414 bool CreateSlideMaster( sal_uInt32 nPageNum );
415 bool CreateNotes( sal_uInt32 nPageNum );
417 static sal_Int8 GetTransition( sal_Int16 nTransitionType, sal_Int16 nTransitionSubtype, ::com::sun::star::presentation::FadeEffect eEffect, sal_uInt8& nDirection );
418 static sal_Int8 GetTransition( ::com::sun::star::presentation::FadeEffect eEffect, sal_uInt8& nDirection );
421 #endif
423 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */