tdf#131098 docx export: write fill property of graphic
[LibreOffice.git] / sd / source / filter / eppt / epptbase.hxx
blob70bcd3a4b6cedf1a1f715d33738ca3fabce8bd7f
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 #pragma once
22 #include <memory>
23 #include <vector>
25 #include <vcl/mapmod.hxx>
26 #include <tools/stream.hxx>
27 #include <tools/fract.hxx>
28 #include <tools/gen.hxx>
29 #include <com/sun/star/awt/Size.hpp>
30 #include <com/sun/star/awt/Point.hpp>
31 #include <com/sun/star/presentation/FadeEffect.hpp>
32 #include <com/sun/star/beans/PropertyState.hpp>
33 #include <vcl/vclptr.hxx>
34 #include <vcl/graph.hxx>
36 #include "grouptable.hxx"
38 namespace com::sun::star::task { class XStatusIndicator; }
39 namespace com::sun::star::frame { class XModel; }
40 namespace com::sun::star::awt { struct Rectangle; }
41 namespace com::sun::star::drawing { class XMasterPagesSupplier; }
42 namespace com::sun::star::drawing { class XDrawPage; }
43 namespace com::sun::star::drawing { class XDrawPages; }
44 namespace com::sun::star::drawing { class XDrawPagesSupplier; }
45 namespace com::sun::star::beans { struct PropertyValue; }
46 namespace com::sun::star::beans { class XPropertySet; }
47 namespace com::sun::star::drawing { class XShape; }
48 namespace com::sun::star::drawing { class XShapes; }
50 class VirtualDevice;
52 // PLACEMENT_ID
53 enum class EppLayout
55 TITLESLIDE = 0, /* The slide is a title slide */
56 TITLEANDBODYSLIDE = 1, /* Title and body slide */
57 TITLEMASTERSLIDE = 2, /* Title master slide */
58 MASTERSLIDE = 3, /* Master slide layout */
59 MASTERNOTES = 4, /* Master notes layout */
60 NOTESTITLEBODY = 5, /* Notes title/body layout */
61 HANDOUTLAYOUT = 6, /* Handout layout, therefore it doesn't have placeholders except header, footer, and date */
62 ONLYTITLE = 7, /* Only title placeholder */
63 TWOCOLUMNSANDTITLE = 8, /* Body of the slide has 2 columns and a title */
64 TWOROWSANDTITLE = 9, /* Slide's body has 2 rows and a title */
65 RIGHTCOLUMN2ROWS = 10, /* Body contains 2 columns, right column has 2 rows */
66 LEFTCOLUMN2ROWS = 11, /* Body contains 2 columns, left column has 2 rows */
67 BOTTOMROW2COLUMNS = 12, /* Body contains 2 rows, bottom row has 2 columns */
68 TOPROW2COLUMN = 13, /* Body contains 2 rows, top row has 2 columns */
69 FOUROBJECTS = 14, /* 4 objects */
70 BIGOBJECT = 15, /* Big object */
71 BLANKSLIDE = 16, /* Blank slide */
72 TITLERIGHTBODYLEFT = 17, /* Vertical title on the right, body on the left */
73 TITLERIGHT2BODIESLEFT = 18 /* Vertical title on the right, body on the left split into 2 rows */
76 #define EPP_LAYOUT_SIZE 25
77 #define OOXML_LAYOUT_SIZE 36
79 struct PHLayout
81 EppLayout nLayout;
82 sal_uInt8 nPlaceHolder[ 8 ];
84 sal_uInt8 nUsedObjectPlaceHolder;
85 sal_uInt8 nTypeOfTitle;
86 sal_uInt8 nTypeOfOutliner;
88 bool bTitlePossible;
89 bool bOutlinerPossible;
90 bool bSecOutlinerPossible;
93 enum PageType { NORMAL = 0, MASTER = 1, NOTICE = 2, UNDEFINED = 3, LAYOUT = 4 };
95 class PropValue
97 protected:
99 css::uno::Any mAny;
100 css::uno::Reference< css::beans::XPropertySet > mXPropSet;
102 bool ImplGetPropertyValue( const OUString& rString );
103 bool ImplGetPropertyValue( const css::uno::Reference
104 < css::beans::XPropertySet > &, const OUString& );
106 public:
108 PropValue() {}
110 static bool GetPropertyValue(
111 css::uno::Any& rAny,
112 const css::uno::Reference< css::beans::XPropertySet > &,
113 const OUString& rPropertyName,
114 bool bTestPropertyAvailability = false );
116 static css::beans::PropertyState GetPropertyState(
117 const css::uno::Reference < css::beans::XPropertySet > &,
118 const OUString& rPropertyName );
121 class EscherGraphicProvider;
122 class SAL_LOPLUGIN_ANNOTATE("crosscast") PPTExBulletProvider
124 friend struct PPTExParaSheet;
126 protected:
128 SvMemoryStream aBuExPictureStream;
129 SvMemoryStream aBuExOutlineStream;
130 SvMemoryStream aBuExMasterStream;
132 std::unique_ptr<EscherGraphicProvider>
133 pGraphicProv;
135 public:
137 sal_uInt16 GetId(Graphic const & rGraphic, Size& rGraphicSize);
139 PPTExBulletProvider();
140 ~PPTExBulletProvider();
143 struct FontCollectionEntry
145 OUString Name;
146 double Scaling;
147 sal_Int16 Family;
148 sal_Int16 Pitch;
149 sal_Int16 CharSet;
151 OUString Original;
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 explicit FontCollectionEntry( const OUString& rName ) :
164 Scaling ( 1.0 ),
165 Family ( 0 ),
166 Pitch ( 0 ),
167 CharSet ( 0 ),
168 Original( rName )
170 ImplInit( rName );
173 private:
175 void ImplInit( const OUString& rName );
178 class FontCollection
180 public:
182 FontCollection();
184 ~FontCollection();
186 static short GetScriptDirection( std::u16string_view rText );
188 sal_uInt32 GetId( FontCollectionEntry& rFontDescriptor );
190 sal_uInt32 GetCount() const { return maFonts.size(); };
192 const FontCollectionEntry* GetById( sal_uInt32 nId );
194 FontCollectionEntry& GetLast() { return *(maFonts.rbegin()); };
196 private:
198 VclPtr<VirtualDevice> pVDev;
199 std::vector<FontCollectionEntry> maFonts;
202 #define PPTEX_STYLESHEETENTRIES 9
204 enum PPTExTextAttr
206 ParaAttr_BulletOn,
207 ParaAttr_BuHardFont,
208 ParaAttr_BuHardColor,
209 ParaAttr_BuHardHeight,
210 ParaAttr_BulletChar,
211 ParaAttr_BulletFont,
212 ParaAttr_BulletHeight,
213 ParaAttr_BulletColor,
214 ParaAttr_Adjust,
215 ParaAttr_LineFeed,
216 ParaAttr_UpperDist,
217 ParaAttr_LowerDist,
218 ParaAttr_TextOfs,
219 ParaAttr_BulletOfs,
220 ParaAttr_DefaultTab,
221 ParaAttr_BiDi,
222 CharAttr_Bold,
223 CharAttr_Italic,
224 CharAttr_Underline,
225 CharAttr_Shadow,
226 CharAttr_Strikeout,
227 CharAttr_Embossed,
228 CharAttr_Font,
229 CharAttr_AsianOrComplexFont,
230 CharAttr_Symbol,
231 CharAttr_FontHeight,
232 CharAttr_FontColor,
233 CharAttr_Escapement
236 struct PPTExCharLevel
238 sal_uInt16 mnFlags;
239 sal_uInt16 mnFont;
240 sal_uInt16 mnAsianOrComplexFont;
241 sal_uInt16 mnFontHeight;
242 sal_uInt16 mnEscapement;
243 Color mnFontColor;
246 struct PPTExCharSheet
248 PPTExCharLevel maCharLevel[ 5 ];
250 explicit PPTExCharSheet( int nInstance );
252 void SetStyleSheet( const css::uno::Reference< css::beans::XPropertySet > &,
253 FontCollection& rFontCollection, int nLevel );
254 void Write( SvStream& rSt, sal_uInt16 nLev, bool bSimpleText,
255 const css::uno::Reference< css::beans::XPropertySet > & rPagePropSet );
259 struct PPTExParaLevel
261 bool mbIsBullet;
262 sal_uInt16 mnBulletChar;
263 sal_uInt16 mnBulletFont;
264 sal_uInt16 mnBulletHeight;
265 sal_uInt32 mnBulletColor;
267 sal_uInt16 mnAdjust;
268 sal_uInt16 mnLineFeed;
269 sal_uInt16 mnUpperDist;
270 sal_uInt16 mnLowerDist;
271 sal_uInt16 mnTextOfs;
272 sal_uInt16 mnBulletOfs;
273 sal_uInt16 mnDefaultTab;
275 bool mbExtendedBulletsUsed;
276 sal_uInt16 mnBulletId;
277 sal_uInt16 mnBulletStart;
278 sal_uInt32 mnMappedNumType;
279 sal_uInt32 mnNumberingType;
280 sal_uInt16 mnAsianSettings;
281 sal_uInt16 mnBiDi;
284 struct PPTExParaSheet
286 PPTExBulletProvider* pBuProv;
288 sal_uInt32 mnInstance;
290 PPTExParaLevel maParaLevel[ 5 ];
291 PPTExParaSheet( int nInstance, sal_uInt16 nDefaultTab, PPTExBulletProvider* pProv );
293 void SetStyleSheet( const css::uno::Reference< css::beans::XPropertySet > &,
294 FontCollection& rFontCollection, int nLevel, const PPTExCharLevel& rCharLevel );
295 void Write( SvStream& rSt, sal_uInt16 nLev, bool bSimpleText,
296 const css::uno::Reference< css::beans::XPropertySet > & rPagePropSet );
299 class PPTExStyleSheet
302 public:
304 std::unique_ptr<PPTExCharSheet> mpCharSheet[ PPTEX_STYLESHEETENTRIES ];
305 std::unique_ptr<PPTExParaSheet> mpParaSheet[ PPTEX_STYLESHEETENTRIES ];
307 PPTExStyleSheet( sal_uInt16 nDefaultTab, PPTExBulletProvider* pBuProv );
308 ~PPTExStyleSheet();
310 PPTExParaSheet& GetParaSheet( int nInstance ) { return *mpParaSheet[ nInstance ]; };
312 void SetStyleSheet( const css::uno::Reference< css::beans::XPropertySet > &,
313 FontCollection& rFontCollection, int nInstance, int nLevel );
314 bool IsHardAttribute( sal_uInt32 nInstance, sal_uInt32 nLevel, PPTExTextAttr eAttr, sal_uInt32 nValue );
316 static sal_uInt32 SizeOfTxCFStyleAtom() { return 24; }
317 void WriteTxCFStyleAtom( SvStream& rSt );
320 class PPTWriterBase : public PropValue, public GroupTable
322 protected:
323 css::uno::Reference< css::frame::XModel > mXModel;
324 css::uno::Reference< css::task::XStatusIndicator > mXStatusIndicator;
326 bool mbStatusIndicator;
328 css::uno::Reference< css::drawing::XDrawPagesSupplier > mXDrawPagesSupplier;
329 css::uno::Reference< css::drawing::XMasterPagesSupplier > mXMasterPagesSupplier;
330 css::uno::Reference< css::drawing::XDrawPages > mXDrawPages;
331 css::uno::Reference< css::drawing::XDrawPage > mXDrawPage;
332 css::uno::Reference< css::beans::XPropertySet > mXPagePropSet;
333 css::uno::Reference< css::beans::XPropertySet > mXBackgroundPropSet;
334 css::uno::Reference< css::drawing::XShapes > mXShapes;
335 css::uno::Reference< css::drawing::XShape > mXShape;
336 css::awt::Size maSize;
337 css::awt::Point maPosition;
338 ::tools::Rectangle maRect;
339 OString mType;
340 bool mbPresObj;
341 bool mbEmptyPresObj;
342 bool mbIsBackgroundDark;
343 sal_Int32 mnAngle;
345 sal_uInt32 mnPages; ///< number of Slides ( w/o master pages & notes & handout )
346 sal_uInt32 mnMasterPages;
348 Fraction maFraction;
349 MapMode maMapModeSrc;
350 MapMode maMapModeDest;
351 css::awt::Size maDestPageSize;
352 css::awt::Size maPageSize; // #i121183# Keep size in logic coordinates (100th mm)
353 css::awt::Size maNotesPageSize;
355 PageType meLatestPageType;
356 std::vector< std::unique_ptr<PPTExStyleSheet> > maStyleSheetList;
357 PPTExStyleSheet* mpStyleSheet;
359 FontCollection maFontCollection;
361 virtual void ImplWriteSlide( sal_uInt32 /* nPageNum */, sal_uInt32 /* nMasterNum */, sal_uInt16 /* nMode */,
362 bool /* bHasBackground */, css::uno::Reference< css::beans::XPropertySet > const & /* aXBackgroundPropSet */ ) {}
363 virtual void ImplWriteNotes( sal_uInt32 nPageNum ) = 0;
364 virtual void ImplWriteSlideMaster( sal_uInt32 /* nPageNum */, css::uno::Reference< css::beans::XPropertySet > const & /* aXBackgroundPropSet */ ) {}
366 virtual void exportPPTPre( const std::vector< css::beans::PropertyValue >& ) {}
367 virtual void exportPPTPost() {}
369 virtual bool ImplCreateDocument()=0;
370 virtual bool ImplCreateMainNotes()=0;
372 bool GetStyleSheets();
373 bool GetShapeByIndex( sal_uInt32 nIndex, bool bGroup );
375 bool CreateMainNotes();
377 css::awt::Size MapSize( const css::awt::Size& );
378 css::awt::Point MapPoint( const css::awt::Point& );
379 ::tools::Rectangle MapRectangle( const css::awt::Rectangle& );
381 bool ContainsOtherShapeThanPlaceholders();
383 public:
384 PPTWriterBase();
385 PPTWriterBase( const css::uno::Reference< css::frame::XModel > & rModel,
386 const css::uno::Reference< css::task::XStatusIndicator > & rStatInd );
388 virtual ~PPTWriterBase();
390 void exportPPT(const std::vector< css::beans::PropertyValue >&);
392 bool InitSOIface();
393 bool GetPageByIndex( sal_uInt32 nIndex, PageType );
394 sal_uInt32 GetMasterIndex( PageType ePageType );
395 void SetCurrentStyleSheet( sal_uInt32 nPageNum );
397 bool GetPresObj() const { return mbPresObj; }
399 static PHLayout const & GetLayout( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
400 static PHLayout const & GetLayout( sal_Int32 nOffset );
401 static sal_Int32 GetLayoutOffset( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
402 static sal_Int32 GetLayoutOffsetFixed( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
404 bool CreateSlide( sal_uInt32 nPageNum );
405 bool CreateSlideMaster( sal_uInt32 nPageNum );
406 bool CreateNotes( sal_uInt32 nPageNum );
408 static sal_Int8 GetTransition( sal_Int16 nTransitionType, sal_Int16 nTransitionSubtype, css::presentation::FadeEffect eEffect,
409 sal_Int32 nTransitionFadeColor, sal_uInt8& nDirection );
410 static sal_Int8 GetTransition( css::presentation::FadeEffect eEffect, sal_uInt8& nDirection );
413 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */