1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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
; }
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
82 sal_uInt8 nPlaceHolder
[ 8 ];
84 sal_uInt8 nUsedObjectPlaceHolder
;
85 sal_uInt8 nTypeOfTitle
;
86 sal_uInt8 nTypeOfOutliner
;
89 bool bOutlinerPossible
;
90 bool bSecOutlinerPossible
;
93 enum PageType
{ NORMAL
= 0, MASTER
= 1, NOTICE
= 2, UNDEFINED
= 3, LAYOUT
= 4 };
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
& );
110 static bool GetPropertyValue(
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
;
128 SvMemoryStream aBuExPictureStream
;
129 SvMemoryStream aBuExOutlineStream
;
130 SvMemoryStream aBuExMasterStream
;
132 std::unique_ptr
<EscherGraphicProvider
>
137 sal_uInt16
GetId(Graphic
const & rGraphic
, Size
& rGraphicSize
);
139 PPTExBulletProvider();
140 ~PPTExBulletProvider();
143 struct FontCollectionEntry
153 FontCollectionEntry( const OUString
& rName
, sal_Int16 nFamily
, sal_Int16 nPitch
, sal_Int16 nCharSet
) :
157 CharSet ( nCharSet
),
163 explicit FontCollectionEntry( const OUString
& rName
) :
175 void ImplInit( const OUString
& rName
);
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()); };
198 VclPtr
<VirtualDevice
> pVDev
;
199 std::vector
<FontCollectionEntry
> maFonts
;
202 #define PPTEX_STYLESHEETENTRIES 9
208 ParaAttr_BuHardColor
,
209 ParaAttr_BuHardHeight
,
212 ParaAttr_BulletHeight
,
213 ParaAttr_BulletColor
,
229 CharAttr_AsianOrComplexFont
,
236 struct PPTExCharLevel
240 sal_uInt16 mnAsianOrComplexFont
;
241 sal_uInt16 mnFontHeight
;
242 sal_uInt16 mnEscapement
;
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
262 sal_uInt16 mnBulletChar
;
263 sal_uInt16 mnBulletFont
;
264 sal_uInt16 mnBulletHeight
;
265 sal_uInt32 mnBulletColor
;
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
;
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
304 std::unique_ptr
<PPTExCharSheet
> mpCharSheet
[ PPTEX_STYLESHEETENTRIES
];
305 std::unique_ptr
<PPTExParaSheet
> mpParaSheet
[ PPTEX_STYLESHEETENTRIES
];
307 PPTExStyleSheet( sal_uInt16 nDefaultTab
, PPTExBulletProvider
* pBuProv
);
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
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
;
342 bool mbIsBackgroundDark
;
345 sal_uInt32 mnPages
; ///< number of Slides ( w/o master pages & notes & handout )
346 sal_uInt32 mnMasterPages
;
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();
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
>&);
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: */