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 .
20 #ifndef INCLUDED_SD_SOURCE_FILTER_EPPT_EPPTBASE_HXX
21 #define INCLUDED_SD_SOURCE_FILTER_EPPT_EPPTBASE_HXX
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/awt/Size.hpp>
31 #include <com/sun/star/awt/Point.hpp>
32 #include <com/sun/star/presentation/FadeEffect.hpp>
33 #include <com/sun/star/beans/PropertyState.hpp>
34 #include <vcl/vclptr.hxx>
35 #include <vcl/graph.hxx>
37 #include "grouptable.hxx"
39 namespace com
{ namespace sun
{ namespace star
{ namespace task
{ class XStatusIndicator
; } } } }
40 namespace com
{ namespace sun
{ namespace star
{ namespace frame
{ class XModel
; } } } }
41 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{ struct Rectangle
; } } } }
42 namespace com
{ namespace sun
{ namespace star
{ namespace drawing
{ class XMasterPagesSupplier
; } } } }
43 namespace com
{ namespace sun
{ namespace star
{ namespace drawing
{ class XDrawPage
; } } } }
44 namespace com
{ namespace sun
{ namespace star
{ namespace drawing
{ class XDrawPages
; } } } }
45 namespace com
{ namespace sun
{ namespace star
{ namespace drawing
{ class XDrawPagesSupplier
; } } } }
46 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{ struct PropertyValue
; } } } }
47 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{ class XPropertySet
; } } } }
48 namespace com
{ namespace sun
{ namespace star
{ namespace drawing
{ class XShape
; } } } }
49 namespace com
{ namespace sun
{ namespace star
{ namespace drawing
{ class XShapes
; } } } }
56 TITLESLIDE
= 0, /* The slide is a title slide */
57 TITLEANDBODYSLIDE
= 1, /* Title and body slide */
58 TITLEMASTERSLIDE
= 2, /* Title master slide */
59 MASTERSLIDE
= 3, /* Master slide layout */
60 MASTERNOTES
= 4, /* Master notes layout */
61 NOTESTITLEBODY
= 5, /* Notes title/body layout */
62 HANDOUTLAYOUT
= 6, /* Handout layout, therefore it doesn't have placeholders except header, footer, and date */
63 ONLYTITLE
= 7, /* Only title placeholder */
64 TWOCOLUMNSANDTITLE
= 8, /* Body of the slide has 2 columns and a title */
65 TWOROWSANDTITLE
= 9, /* Slide's body has 2 rows and a title */
66 RIGHTCOLUMN2ROWS
= 10, /* Body contains 2 columns, right column has 2 rows */
67 LEFTCOLUMN2ROWS
= 11, /* Body contains 2 columns, left column has 2 rows */
68 BOTTOMROW2COLUMNS
= 12, /* Body contains 2 rows, bottom row has 2 columns */
69 TOPROW2COLUMN
= 13, /* Body contains 2 rows, top row has 2 columns */
70 FOUROBJECTS
= 14, /* 4 objects */
71 BIGOBJECT
= 15, /* Big object */
72 BLANKSLIDE
= 16, /* Blank slide */
73 TITLERIGHTBODYLEFT
= 17, /* Vertical title on the right, body on the left */
74 TITLERIGHT2BODIESLEFT
= 18 /* Vertical title on the right, body on the left split into 2 rows */
77 #define EPP_LAYOUT_SIZE 25
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 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
151 OUString
const Original
;
153 FontCollectionEntry( const OUString
& rName
, sal_Int16 nFamily
, sal_Int16 nPitch
, sal_Int16 nCharSet
) :
157 CharSet ( nCharSet
),
163 explicit FontCollectionEntry( const OUString
& rName
) :
172 ~FontCollectionEntry();
176 void ImplInit( const OUString
& rName
);
187 static short GetScriptDirection( const OUString
& rText
);
189 sal_uInt32
GetId( FontCollectionEntry
& rFontDescriptor
);
191 sal_uInt32
GetCount() const { return maFonts
.size(); };
193 const FontCollectionEntry
* GetById( sal_uInt32 nId
);
195 FontCollectionEntry
& GetLast() { return *(maFonts
.rbegin()); };
199 VclPtr
<VirtualDevice
> pVDev
;
200 std::vector
<FontCollectionEntry
> maFonts
;
203 #define PPTEX_STYLESHEETENTRIES 9
209 ParaAttr_BuHardColor
,
210 ParaAttr_BuHardHeight
,
213 ParaAttr_BulletHeight
,
214 ParaAttr_BulletColor
,
230 CharAttr_AsianOrComplexFont
,
237 struct PPTExCharLevel
241 sal_uInt16 mnAsianOrComplexFont
;
242 sal_uInt16 mnFontHeight
;
243 sal_uInt16 mnEscapement
;
247 struct PPTExCharSheet
249 PPTExCharLevel maCharLevel
[ 5 ];
251 explicit PPTExCharSheet( int nInstance
);
253 void SetStyleSheet( const css::uno::Reference
< css::beans::XPropertySet
> &,
254 FontCollection
& rFontCollection
, int nLevel
);
255 void Write( SvStream
& rSt
, sal_uInt16 nLev
, bool bSimpleText
,
256 const css::uno::Reference
< css::beans::XPropertySet
> & rPagePropSet
);
260 struct PPTExParaLevel
263 sal_uInt16 mnBulletChar
;
264 sal_uInt16 mnBulletFont
;
265 sal_uInt16 mnBulletHeight
;
266 sal_uInt32 mnBulletColor
;
269 sal_uInt16 mnLineFeed
;
270 sal_uInt16 mnUpperDist
;
271 sal_uInt16 mnLowerDist
;
272 sal_uInt16 mnTextOfs
;
273 sal_uInt16 mnBulletOfs
;
274 sal_uInt16 mnDefaultTab
;
276 bool mbExtendedBulletsUsed
;
277 sal_uInt16 mnBulletId
;
278 sal_uInt16 mnBulletStart
;
279 sal_uInt32 mnMappedNumType
;
280 sal_uInt32 mnNumberingType
;
281 sal_uInt16 mnAsianSettings
;
285 struct PPTExParaSheet
287 PPTExBulletProvider
* pBuProv
;
289 sal_uInt32 mnInstance
;
291 PPTExParaLevel maParaLevel
[ 5 ];
292 PPTExParaSheet( int nInstance
, sal_uInt16 nDefaultTab
, PPTExBulletProvider
* pProv
);
294 void SetStyleSheet( const css::uno::Reference
< css::beans::XPropertySet
> &,
295 FontCollection
& rFontCollection
, int nLevel
, const PPTExCharLevel
& rCharLevel
);
296 void Write( SvStream
& rSt
, sal_uInt16 nLev
, bool bSimpleText
,
297 const css::uno::Reference
< css::beans::XPropertySet
> & rPagePropSet
);
300 class PPTExStyleSheet
305 std::unique_ptr
<PPTExCharSheet
> mpCharSheet
[ PPTEX_STYLESHEETENTRIES
];
306 std::unique_ptr
<PPTExParaSheet
> mpParaSheet
[ PPTEX_STYLESHEETENTRIES
];
308 PPTExStyleSheet( sal_uInt16 nDefaultTab
, PPTExBulletProvider
* pBuProv
);
311 PPTExParaSheet
& GetParaSheet( int nInstance
) { return *mpParaSheet
[ nInstance
]; };
313 void SetStyleSheet( const css::uno::Reference
< css::beans::XPropertySet
> &,
314 FontCollection
& rFontCollection
, int nInstance
, int nLevel
);
315 bool IsHardAttribute( sal_uInt32 nInstance
, sal_uInt32 nLevel
, PPTExTextAttr eAttr
, sal_uInt32 nValue
);
317 static sal_uInt32
SizeOfTxCFStyleAtom() { return 24; }
318 void WriteTxCFStyleAtom( SvStream
& rSt
);
321 class PPTWriterBase
: public PropValue
, public GroupTable
324 css::uno::Reference
< css::frame::XModel
> mXModel
;
325 css::uno::Reference
< css::task::XStatusIndicator
> mXStatusIndicator
;
327 bool mbStatusIndicator
;
329 css::uno::Reference
< css::drawing::XDrawPagesSupplier
> mXDrawPagesSupplier
;
330 css::uno::Reference
< css::drawing::XMasterPagesSupplier
> mXMasterPagesSupplier
;
331 css::uno::Reference
< css::drawing::XDrawPages
> mXDrawPages
;
332 css::uno::Reference
< css::drawing::XDrawPage
> mXDrawPage
;
333 css::uno::Reference
< css::beans::XPropertySet
> mXPagePropSet
;
334 css::uno::Reference
< css::beans::XPropertySet
> mXBackgroundPropSet
;
335 css::uno::Reference
< css::drawing::XShapes
> mXShapes
;
336 css::uno::Reference
< css::drawing::XShape
> mXShape
;
337 css::awt::Size maSize
;
338 css::awt::Point maPosition
;
339 ::tools::Rectangle maRect
;
343 bool mbIsBackgroundDark
;
346 sal_uInt32 mnPages
; ///< number of Slides ( w/o master pages & notes & handout )
347 sal_uInt32 mnMasterPages
;
349 Fraction
const maFraction
;
350 MapMode
const maMapModeSrc
;
351 MapMode
const maMapModeDest
;
352 css::awt::Size maDestPageSize
;
353 css::awt::Size maPageSize
; // #i121183# Keep size in logic coordinates (100th mm)
354 css::awt::Size maNotesPageSize
;
356 PageType meLatestPageType
;
357 std::vector
< std::unique_ptr
<PPTExStyleSheet
> > maStyleSheetList
;
358 PPTExStyleSheet
* mpStyleSheet
;
360 FontCollection maFontCollection
;
362 virtual void ImplWriteSlide( sal_uInt32
/* nPageNum */, sal_uInt32
/* nMasterNum */, sal_uInt16
/* nMode */,
363 bool /* bHasBackground */, css::uno::Reference
< css::beans::XPropertySet
> const & /* aXBackgroundPropSet */ ) {}
364 virtual void ImplWriteNotes( sal_uInt32 nPageNum
) = 0;
365 virtual void ImplWriteSlideMaster( sal_uInt32
/* nPageNum */, css::uno::Reference
< css::beans::XPropertySet
> const & /* aXBackgroundPropSet */ ) {}
367 virtual void exportPPTPre( const std::vector
< css::beans::PropertyValue
>& ) {}
368 virtual void exportPPTPost() {}
370 virtual bool ImplCreateDocument()=0;
371 virtual bool ImplCreateMainNotes()=0;
373 bool GetStyleSheets();
374 bool GetShapeByIndex( sal_uInt32 nIndex
, bool bGroup
);
376 bool CreateMainNotes();
378 css::awt::Size
MapSize( const css::awt::Size
& );
379 css::awt::Point
MapPoint( const css::awt::Point
& );
380 ::tools::Rectangle
MapRectangle( const css::awt::Rectangle
& );
382 bool ContainsOtherShapeThanPlaceholders();
386 PPTWriterBase( const css::uno::Reference
< css::frame::XModel
> & rModel
,
387 const css::uno::Reference
< css::task::XStatusIndicator
> & rStatInd
);
389 virtual ~PPTWriterBase();
391 void exportPPT(const std::vector
< css::beans::PropertyValue
>&);
394 bool GetPageByIndex( sal_uInt32 nIndex
, PageType
);
395 sal_uInt32
GetMasterIndex( PageType ePageType
);
396 void SetCurrentStyleSheet( sal_uInt32 nPageNum
);
398 bool GetPresObj() { return mbPresObj
; }
400 static PHLayout
const & GetLayout( const css::uno::Reference
< css::beans::XPropertySet
>& rXPropSet
);
401 static PHLayout
const & GetLayout( sal_Int32 nOffset
);
402 static sal_Int32
GetLayoutOffset( const css::uno::Reference
< css::beans::XPropertySet
>& rXPropSet
);
403 static sal_Int32
GetLayoutOffsetFixed( const css::uno::Reference
< css::beans::XPropertySet
>& rXPropSet
);
405 bool CreateSlide( sal_uInt32 nPageNum
);
406 bool CreateSlideMaster( sal_uInt32 nPageNum
);
407 bool CreateNotes( sal_uInt32 nPageNum
);
409 static sal_Int8
GetTransition( sal_Int16 nTransitionType
, sal_Int16 nTransitionSubtype
, css::presentation::FadeEffect eEffect
, sal_uInt8
& nDirection
);
410 static sal_Int8
GetTransition( css::presentation::FadeEffect eEffect
, sal_uInt8
& nDirection
);
415 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */