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 #include "epptbase.hxx"
21 #include "epptdef.hxx"
22 #include "../ppt/pptanimations.hxx"
24 #include <o3tl/any.hxx>
25 #include <vcl/outdev.hxx>
26 #include <rtl/ustring.hxx>
27 #include <rtl/strbuf.hxx>
28 #include <rtl/ustrbuf.hxx>
29 #include <sal/log.hxx>
30 #include <tools/UnitConversion.hxx>
31 #include <com/sun/star/awt/Rectangle.hpp>
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
34 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
35 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
36 #include <com/sun/star/drawing/XDrawPages.hpp>
37 #include <com/sun/star/animations/TransitionType.hpp>
38 #include <com/sun/star/animations/TransitionSubType.hpp>
39 #include <com/sun/star/awt/FontFamily.hpp>
40 #include <com/sun/star/awt/FontPitch.hpp>
41 #include <com/sun/star/container/XNamed.hpp>
42 #include <com/sun/star/container/XNameAccess.hpp>
43 #include <com/sun/star/frame/XModel.hpp>
44 #include <com/sun/star/presentation/XPresentationPage.hpp>
45 #include <com/sun/star/text/XSimpleText.hpp>
46 #include <com/sun/star/style/XStyle.hpp>
47 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
48 #include <com/sun/star/task/XStatusIndicator.hpp>
51 using namespace com::sun::star
;
53 using namespace ::com::sun::star::animations
;
54 using namespace ::com::sun::star::awt::FontFamily
;
55 using namespace ::com::sun::star::awt::FontPitch
;
56 using namespace ::com::sun::star::presentation
;
58 using ::com::sun::star::beans::XPropertySet
;
59 using ::com::sun::star::container::XNameAccess
;
60 using ::com::sun::star::container::XNamed
;
61 using ::com::sun::star::drawing::XMasterPageTarget
;
62 using ::com::sun::star::drawing::XDrawPage
;
63 using ::com::sun::star::frame::XModel
;
64 using ::com::sun::star::style::XStyleFamiliesSupplier
;
65 using ::com::sun::star::style::XStyle
;
66 using ::com::sun::star::task::XStatusIndicator
;
67 using ::com::sun::star::text::XSimpleText
;
68 using ::com::sun::star::uno::Any
;
69 using ::com::sun::star::uno::Exception
;
70 using ::com::sun::star::uno::Reference
;
71 using ::com::sun::star::uno::UNO_QUERY
;
73 PHLayout
const pPHLayout
[] =
75 { EppLayout::TITLESLIDE
, { 0x0d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x10, true, true, false },
76 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, true, true, false },
77 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, true, true, false },
78 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x0e, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, true, true, true },
79 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x0e, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, true, true, false },
80 { EppLayout::BLANKSLIDE
, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, false, false, false },
81 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x0e, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, true, true, false },
82 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x14, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, true, true, false },
83 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x15, 0x0d, 0x0e, true, false, false },
84 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x16, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, true, true, false },
85 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
86 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, false, false },
87 { EppLayout::RIGHTCOLUMN2ROWS
, { 0x0d, 0x0e, 0x13, 0x13, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
88 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
89 { EppLayout::TWOROWSANDTITLE
, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
90 { EppLayout::LEFTCOLUMN2ROWS
, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
91 { EppLayout::TOPROW2COLUMN
, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
92 { EppLayout::TWOROWSANDTITLE
, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
93 { EppLayout::FOUROBJECTS
, { 0x0d, 0x13, 0x13, 0x13, 0x13, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, false, false },
94 { EppLayout::ONLYTITLE
, { 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, true, false, false },
95 { EppLayout::BLANKSLIDE
, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, false, false, false },
96 { EppLayout::TITLERIGHT2BODIESLEFT
, { 0x11, 0x12, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x11, 0x12, true, true, false },
97 { EppLayout::TITLERIGHTBODYLEFT
, { 0x11, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x11, 0x12, true, true, false },
98 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x12, true, true, false },
99 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x16, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x12, true, true, false }
102 PPTWriterBase::PPTWriterBase()
103 : mbStatusIndicator(false)
105 , mbEmptyPresObj(false)
106 , mbIsBackgroundDark(false)
111 , maMapModeSrc(MapUnit::Map100thMM
)
112 , maMapModeDest(MapUnit::MapInch
, Point(), maFraction
, maFraction
)
113 , meLatestPageType(NORMAL
)
114 , mpStyleSheet(nullptr)
116 SAL_INFO("sd.eppt", "PPTWriterBase::PPTWriterBase()");
119 PPTWriterBase::PPTWriterBase( const Reference
< XModel
> & rXModel
,
120 const Reference
< XStatusIndicator
> & rXStatInd
)
122 , mXStatusIndicator(rXStatInd
)
123 , mbStatusIndicator(false)
125 , mbEmptyPresObj(false)
126 , mbIsBackgroundDark(false)
131 , maMapModeSrc(MapUnit::Map100thMM
)
132 , maMapModeDest(MapUnit::MapInch
, Point(), maFraction
, maFraction
)
133 , meLatestPageType (NORMAL
)
134 , mpStyleSheet(nullptr)
138 PPTWriterBase::~PPTWriterBase()
140 // Possibly unnecessary sanity check for mXStatusIndicator.is().
141 // In 3.3 we had a bug report of a crash where it was null,
142 // https://bugzilla.novell.com/show_bug.cgi?id=694119 (non-public,
143 // bug report, sorry).
144 if ( mbStatusIndicator
&& mXStatusIndicator
.is() )
145 mXStatusIndicator
->end();
148 void PPTWriterBase::exportPPT( const std::vector
< css::beans::PropertyValue
>& rMediaData
)
150 if ( !InitSOIface() )
153 FontCollectionEntry
aDefaultFontDesc( u
"Times New Roman"_ustr
,
155 awt::FontPitch::VARIABLE
,
156 RTL_TEXTENCODING_MS_1252
);
157 maFontCollection
.GetId( aDefaultFontDesc
); // default is always times new roman
159 if ( !GetPageByIndex( 0, NOTICE
) )
162 sal_Int32 nWidth
= 21000;
163 if ( ImplGetPropertyValue( mXPagePropSet
, u
"Width"_ustr
) )
165 sal_Int32 nHeight
= 29700;
166 if ( ImplGetPropertyValue( mXPagePropSet
, u
"Height"_ustr
) )
169 maNotesPageSize
= MapSize( awt::Size( nWidth
, nHeight
) );
171 if ( !GetPageByIndex( 0, MASTER
) )
175 if ( ImplGetPropertyValue( mXPagePropSet
, u
"Width"_ustr
) )
178 if ( ImplGetPropertyValue( mXPagePropSet
, u
"Height"_ustr
) )
180 maDestPageSize
= MapSize( awt::Size( nWidth
, nHeight
) );
181 maPageSize
= awt::Size(nWidth
, nHeight
);
183 SAL_INFO("sd.eppt", "call exportDocumentPre()");
184 exportPPTPre(rMediaData
);
186 if ( !GetStyleSheets() )
189 if ( !ImplCreateDocument() )
194 for ( i
= 0; i
< mnMasterPages
; i
++ )
196 if ( !CreateSlideMaster( i
) )
199 if ( !CreateMainNotes() )
202 for ( i
= 0; i
< mnPages
; i
++ )
204 SAL_INFO("sd.eppt", "call ImplCreateSlide( " << i
<< " )");
205 if ( !CreateSlide( i
) )
209 for ( i
= 0; i
< mnPages
; i
++ )
211 if ( !CreateNotes( i
) )
215 SAL_INFO("sd.eppt", "call exportDocumentPost()");
219 bool PPTWriterBase::InitSOIface()
223 mXDrawPagesSupplier
.set( mXModel
, UNO_QUERY
);
224 if ( !mXDrawPagesSupplier
.is() )
227 mXMasterPagesSupplier
.set( mXModel
, UNO_QUERY
);
228 if ( !mXMasterPagesSupplier
.is() )
230 mXDrawPages
= mXMasterPagesSupplier
->getMasterPages();
231 if ( !mXDrawPages
.is() )
233 mnMasterPages
= mXDrawPages
->getCount();
234 mXDrawPages
= mXDrawPagesSupplier
->getDrawPages();
235 if( !mXDrawPages
.is() )
237 mnPages
= mXDrawPages
->getCount();
238 if ( !GetPageByIndex( 0, NORMAL
) )
246 bool PPTWriterBase::GetPageByIndex( sal_uInt32 nIndex
, PageType ePageType
)
250 if ( ePageType
!= meLatestPageType
)
257 mXDrawPages
= mXDrawPagesSupplier
->getDrawPages();
258 if( !mXDrawPages
.is() )
265 mXDrawPages
= mXMasterPagesSupplier
->getMasterPages();
266 if( !mXDrawPages
.is() )
273 meLatestPageType
= ePageType
;
275 Any
aAny( mXDrawPages
->getByIndex( nIndex
) );
277 if ( !mXDrawPage
.is() )
279 if ( ePageType
== NOTICE
)
281 Reference
< XPresentationPage
> aXPresentationPage( mXDrawPage
, UNO_QUERY
);
282 if ( !aXPresentationPage
.is() )
284 mXDrawPage
= aXPresentationPage
->getNotesPage();
285 if ( !mXDrawPage
.is() )
288 mXPagePropSet
.set( mXDrawPage
, UNO_QUERY
);
289 if ( !mXPagePropSet
.is() )
292 if (GetPropertyValue( aAny
, mXPagePropSet
, u
"IsBackgroundDark"_ustr
) )
293 aAny
>>= mbIsBackgroundDark
;
295 mXShapes
= mXDrawPage
;
296 if ( !mXShapes
.is() )
299 /* try to get the "real" background PropertySet. If the normal page is not supporting this property, it is
300 taken the property from the master */
301 bool bHasBackground
= GetPropertyValue( aAny
, mXPagePropSet
, u
"Background"_ustr
, true );
302 if ( bHasBackground
)
303 bHasBackground
= ( aAny
>>= mXBackgroundPropSet
);
304 if ( !bHasBackground
)
306 Reference
< XMasterPageTarget
> aXMasterPageTarget( mXDrawPage
, UNO_QUERY
);
307 if ( aXMasterPageTarget
.is() )
309 Reference
< XDrawPage
> aXMasterDrawPage
= aXMasterPageTarget
->getMasterPage();
310 if ( aXMasterDrawPage
.is() )
312 Reference
< XPropertySet
> aXMasterPagePropSet
;
313 aXMasterPagePropSet
.set( aXMasterDrawPage
, UNO_QUERY
);
314 if ( aXMasterPagePropSet
.is() )
316 bool bBackground
= GetPropertyValue( aAny
, aXMasterPagePropSet
, u
"Background"_ustr
);
319 aAny
>>= mXBackgroundPropSet
;
330 bool PPTWriterBase::CreateSlide( sal_uInt32 nPageNum
)
334 if ( !GetPageByIndex( nPageNum
, NORMAL
) )
337 sal_uInt32 nMasterNum
= GetMasterIndex( NORMAL
);
338 SetCurrentStyleSheet( nMasterNum
);
340 Reference
< XPropertySet
> aXBackgroundPropSet
;
341 bool bHasBackground
= GetPropertyValue( aAny
, mXPagePropSet
, u
"Background"_ustr
);
342 if ( bHasBackground
)
343 bHasBackground
= ( aAny
>>= aXBackgroundPropSet
);
345 sal_uInt16 nMode
= 7; // Bit 1: Follow master objects, Bit 2: Follow master scheme, Bit 3: Follow master background
346 if ( bHasBackground
)
349 /* sj: Don't know what's IsBackgroundVisible for, have to ask cl
350 if ( GetPropertyValue( aAny, mXPagePropSet, OUString( "IsBackgroundVisible" ) ) )
352 bool bBackgroundVisible;
353 if ( aAny >>= bBackgroundVisible )
355 if ( bBackgroundVisible )
360 if ( GetPropertyValue( aAny
, mXPagePropSet
, u
"IsBackgroundObjectsVisible"_ustr
) )
362 bool bBackgroundObjectsVisible
= false;
363 if ( aAny
>>= bBackgroundObjectsVisible
)
365 if ( !bBackgroundObjectsVisible
)
370 ImplWriteSlide( nPageNum
, nMasterNum
, nMode
, bHasBackground
, aXBackgroundPropSet
);
375 bool PPTWriterBase::CreateNotes( sal_uInt32 nPageNum
)
377 if ( !GetPageByIndex( nPageNum
, NOTICE
) )
379 SetCurrentStyleSheet( GetMasterIndex( NORMAL
) );
381 ImplWriteNotes( nPageNum
);
386 bool PPTWriterBase::CreateSlideMaster( sal_uInt32 nPageNum
)
388 if ( !GetPageByIndex( nPageNum
, MASTER
) )
390 SetCurrentStyleSheet( nPageNum
);
392 css::uno::Reference
< css::beans::XPropertySet
> aXBackgroundPropSet
;
393 if (ImplGetPropertyValue(mXPagePropSet
, u
"Background"_ustr
)) // load background shape
394 mAny
>>= aXBackgroundPropSet
;
396 ImplWriteSlideMaster( nPageNum
, aXBackgroundPropSet
);
401 sal_Int32
PPTWriterBase::GetLayoutOffset( const css::uno::Reference
< css::beans::XPropertySet
>& rXPropSet
)
404 sal_Int32 nLayout
= 20;
405 if ( GetPropertyValue( aAny
, rXPropSet
, u
"Layout"_ustr
, true ) )
408 SAL_INFO("sd.eppt", "GetLayoutOffset " << nLayout
);
413 sal_Int32
PPTWriterBase::GetLayoutOffsetFixed( const css::uno::Reference
< css::beans::XPropertySet
>& rXPropSet
)
415 sal_Int32 nLayout
= GetLayoutOffset( rXPropSet
);
417 if ( ( nLayout
>= 21 ) && ( nLayout
<= 26 ) ) // NOTES _> HANDOUT6
419 if ( ( nLayout
>= 27 ) && ( nLayout
<= 30 ) ) // VERTICAL LAYOUT
421 else if ( nLayout
> 30 )
427 PHLayout
const & PPTWriterBase::GetLayout( const css::uno::Reference
< css::beans::XPropertySet
>& rXPropSet
)
429 return pPHLayout
[ GetLayoutOffsetFixed( rXPropSet
) ];
432 PHLayout
const & PPTWriterBase::GetLayout( sal_Int32 nOffset
)
434 if( nOffset
>= 0 && nOffset
< EPP_LAYOUT_SIZE
)
435 return pPHLayout
[ nOffset
];
437 SAL_INFO("sd.eppt", "asked " << nOffset
<< " for layout outside of 0, " << EPP_LAYOUT_SIZE
<< " array scope");
439 return pPHLayout
[ 0 ];
442 sal_uInt32
PPTWriterBase::GetMasterIndex( PageType ePageType
)
444 sal_uInt32 nRetValue
= 0;
445 css::uno::Reference
< css::drawing::XMasterPageTarget
>aXMasterPageTarget( mXDrawPage
, css::uno::UNO_QUERY
);
447 if ( aXMasterPageTarget
.is() )
449 css::uno::Reference
< css::drawing::XDrawPage
>aXDrawPage
= aXMasterPageTarget
->getMasterPage();
450 if ( aXDrawPage
.is() )
452 css::uno::Reference
< css::beans::XPropertySet
> aXPropertySet( aXDrawPage
, css::uno::UNO_QUERY
);
453 if ( aXPropertySet
.is() )
455 if ( ImplGetPropertyValue( aXPropertySet
, u
"Number"_ustr
) )
456 nRetValue
|= *o3tl::doAccess
<sal_Int16
>(mAny
);
457 if ( nRetValue
& 0xffff ) // avoid overflow
462 if ( ePageType
== NOTICE
)
463 nRetValue
+= mnMasterPages
;
467 void PPTWriterBase::SetCurrentStyleSheet( sal_uInt32 nPageNum
)
469 if ( nPageNum
>= maStyleSheetList
.size() )
471 mpStyleSheet
= maStyleSheetList
[ nPageNum
].get();
474 bool PPTWriterBase::GetStyleSheets()
476 int nInstance
, nLevel
;
477 bool bRetValue
= false;
480 for ( nPageNum
= 0; nPageNum
< mnMasterPages
; nPageNum
++ )
485 Reference
< XNameAccess
>
488 Reference
< XStyleFamiliesSupplier
>
489 aXStyleFamiliesSupplier( mXModel
, UNO_QUERY
);
491 Reference
< XPropertySet
>
492 aXPropSet( mXModel
, UNO_QUERY
);
494 sal_uInt16 nDefaultTab
= ( aXPropSet
.is() && ImplGetPropertyValue( aXPropSet
, u
"TabStop"_ustr
) )
495 ? static_cast<sal_uInt16
>( convertMm100ToMasterUnit(*o3tl::doAccess
<sal_Int32
>(mAny
)) )
498 maStyleSheetList
.emplace_back( new PPTExStyleSheet( nDefaultTab
, dynamic_cast<PPTExBulletProvider
*>(this) ) );
499 SetCurrentStyleSheet( nPageNum
);
500 if ( GetPageByIndex( nPageNum
, MASTER
) )
501 aXNamed
.set( mXDrawPage
, UNO_QUERY
);
503 if ( aXStyleFamiliesSupplier
.is() )
504 aXNameAccess
= aXStyleFamiliesSupplier
->getStyleFamilies();
506 bRetValue
= aXNamed
.is() && aXNameAccess
.is() && aXStyleFamiliesSupplier
.is();
509 for ( nInstance
= EPP_TEXTTYPE_Title
; nInstance
<= EPP_TEXTTYPE_CenterTitle
; nInstance
++ )
515 case EPP_TEXTTYPE_CenterTitle
:
516 case EPP_TEXTTYPE_Title
:
519 aFamily
= aXNamed
->getName();
522 case EPP_TEXTTYPE_Body
:
524 aStyle
= "outline1"; // SD_LT_SEPARATOR
525 aFamily
= aXNamed
->getName();
528 case EPP_TEXTTYPE_Other
:
531 aFamily
= "graphics";
534 case EPP_TEXTTYPE_CenterBody
:
537 aFamily
= aXNamed
->getName();
541 if ( !aStyle
.isEmpty() && !aFamily
.isEmpty() )
545 Reference
< XNameAccess
>xNameAccess
;
546 if ( aXNameAccess
->hasByName( aFamily
) )
548 Any
aAny( aXNameAccess
->getByName( aFamily
) );
549 xNameAccess
.set(aAny
, css::uno::UNO_QUERY
);
550 if( xNameAccess
.is() )
552 Reference
< XNameAccess
> aXFamily
;
553 if ( aAny
>>= aXFamily
)
555 if ( aXFamily
->hasByName( aStyle
) )
557 aAny
= aXFamily
->getByName( aStyle
);
558 Reference
< XStyle
> xStyle(
559 aAny
, css::uno::UNO_QUERY
);
562 Reference
< XStyle
> aXStyle
;
564 Reference
< XPropertySet
>
565 xPropSet( aXStyle
, UNO_QUERY
);
567 mpStyleSheet
->SetStyleSheet( xPropSet
, maFontCollection
, nInstance
, 0 );
568 for ( nLevel
= 1; nLevel
< 5; nLevel
++ )
570 if ( nInstance
== EPP_TEXTTYPE_Body
)
572 sal_Unicode cTemp
= aStyle
[aStyle
.getLength() - 1];
573 aStyle
= aStyle
.subView(0, aStyle
.getLength() - 1) + OUStringChar(++cTemp
);
574 if ( aXFamily
->hasByName( aStyle
) )
576 aXFamily
->getByName( aStyle
) >>= xStyle
;
579 Reference
< XPropertySet
>
580 xPropertySet( xStyle
, UNO_QUERY
);
581 if ( xPropertySet
.is() )
582 mpStyleSheet
->SetStyleSheet( xPropertySet
, maFontCollection
, nInstance
, nLevel
);
587 mpStyleSheet
->SetStyleSheet( xPropSet
, maFontCollection
, nInstance
, nLevel
);
601 for ( ; nInstance
<= EPP_TEXTTYPE_QuarterBody
; nInstance
++ )
610 bool PPTWriterBase::CreateMainNotes()
612 if ( !GetPageByIndex( 0, NOTICE
) )
614 SetCurrentStyleSheet( 0 );
616 css::uno::Reference
< css::drawing::XMasterPageTarget
> aXMasterPageTarget( mXDrawPage
, css::uno::UNO_QUERY
);
618 if ( !aXMasterPageTarget
.is() )
621 mXDrawPage
= aXMasterPageTarget
->getMasterPage();
622 if ( !mXDrawPage
.is() )
625 mXPropSet
.set( mXDrawPage
, css::uno::UNO_QUERY
);
626 if ( !mXPropSet
.is() )
629 mXShapes
= mXDrawPage
;
630 if ( !mXShapes
.is() )
633 return ImplCreateMainNotes();
636 awt::Size
PPTWriterBase::MapSize( const awt::Size
& rSize
)
638 Size
aRetSize( OutputDevice::LogicToLogic( Size( rSize
.Width
, rSize
.Height
), maMapModeSrc
, maMapModeDest
) );
640 if ( !aRetSize
.Width() )
641 aRetSize
.AdjustWidth( 1 );
642 if ( !aRetSize
.Height() )
643 aRetSize
.AdjustHeight( 1 );
644 return awt::Size( aRetSize
.Width(), aRetSize
.Height() );
647 awt::Point
PPTWriterBase::MapPoint( const awt::Point
& rPoint
)
649 Point
aRet( OutputDevice::LogicToLogic( Point( rPoint
.X
, rPoint
.Y
), maMapModeSrc
, maMapModeDest
) );
650 return awt::Point( aRet
.X(), aRet
.Y() );
653 ::tools::Rectangle
PPTWriterBase::MapRectangle( const awt::Rectangle
& rRect
)
655 css::awt::Point
aPoint( rRect
.X
, rRect
.Y
);
656 css::awt::Size
aSize( rRect
.Width
, rRect
.Height
);
657 css::awt::Point
aP( MapPoint( aPoint
) );
658 css::awt::Size
aS( MapSize( aSize
) );
659 return ::tools::Rectangle( Point( aP
.X
, aP
.Y
), Size( aS
.Width
, aS
.Height
) );
662 bool PPTWriterBase::GetShapeByIndex( sal_uInt32 nIndex
, bool bGroup
)
666 if ( !bGroup
|| ( GetCurrentGroupLevel() == 0 ) )
668 Any
aAny( mXShapes
->getByIndex( nIndex
) );
673 Any
aAny( GetCurrentGroupAccess()->getByIndex( GetCurrentGroupIndex() ) );
679 Any
aAny( mXShape
->queryInterface( cppu::UnoType
<XPropertySet
>::get()));
682 if ( !mXPropSet
.is() )
684 maPosition
= MapPoint( mXShape
->getPosition() );
685 maSize
= MapSize( mXShape
->getSize() );
686 maRect
= ::tools::Rectangle( Point( maPosition
.X
, maPosition
.Y
), Size( maSize
.Width
, maSize
.Height
) );
688 OStringBuffer
aTypeBuffer(OUStringToOString(
689 mXShape
->getShapeType(), RTL_TEXTENCODING_UTF8
));
690 // remove "com.sun.star."
691 aTypeBuffer
.remove(0, RTL_CONSTASCII_LENGTH("com.sun.star."));
693 sal_Int32 nPos
= aTypeBuffer
.toString().indexOf("Shape");
694 aTypeBuffer
.remove(nPos
, RTL_CONSTASCII_LENGTH("Shape"));
695 mType
= aTypeBuffer
.makeStringAndClear();
697 mbPresObj
= mbEmptyPresObj
= false;
698 if ( ImplGetPropertyValue( u
"IsPresentationObject"_ustr
) )
701 if ( mbPresObj
&& ImplGetPropertyValue( u
"IsEmptyPresentationObject"_ustr
) )
702 mAny
>>= mbEmptyPresObj
;
704 mnAngle
= ( PropValue::GetPropertyValue( aAny
,
705 mXPropSet
, u
"RotateAngle"_ustr
, true ) )
706 ? *o3tl::doAccess
<sal_Int32
>(aAny
)
714 sal_Int8
PPTWriterBase::GetTransition( sal_Int16 nTransitionType
, sal_Int16 nTransitionSubtype
, FadeEffect eEffect
,
715 sal_Int32 nTransitionFadeColor
, sal_uInt8
& nDirection
)
717 sal_Int8 nPPTTransitionType
= 0;
720 switch( nTransitionType
)
722 case TransitionType::FADE
:
724 if ( nTransitionSubtype
== TransitionSubType::CROSSFADE
)
725 nPPTTransitionType
= PPT_TRANSITION_TYPE_SMOOTHFADE
;
726 else if ( nTransitionSubtype
== TransitionSubType::FADEOVERCOLOR
)
728 if( nTransitionFadeColor
== static_cast<sal_Int32
>(COL_WHITE
) )
729 nPPTTransitionType
= PPT_TRANSITION_TYPE_FLASH
;
731 nPPTTransitionType
= PPT_TRANSITION_TYPE_FADE
;
735 case TransitionType::PUSHWIPE
:
737 if (nTransitionSubtype
== TransitionSubType::COMBVERTICAL
||
738 nTransitionSubtype
== TransitionSubType::COMBHORIZONTAL
)
740 nPPTTransitionType
= PPT_TRANSITION_TYPE_COMB
;
744 nPPTTransitionType
= PPT_TRANSITION_TYPE_PUSH
;
746 switch (nTransitionSubtype
)
748 case TransitionSubType::FROMRIGHT
: nDirection
= 0; break;
749 case TransitionSubType::FROMBOTTOM
: nDirection
= 1; break;
750 case TransitionSubType::FROMLEFT
: nDirection
= 2; break;
751 case TransitionSubType::FROMTOP
: nDirection
= 3; break;
752 case TransitionSubType::COMBHORIZONTAL
: nDirection
= 0; break;
753 case TransitionSubType::COMBVERTICAL
: nDirection
= 1; break;
757 case TransitionType::PINWHEELWIPE
:
759 nPPTTransitionType
= PPT_TRANSITION_TYPE_WHEEL
;
760 switch( nTransitionSubtype
)
762 case TransitionSubType::ONEBLADE
: nDirection
= 1; break;
763 case TransitionSubType::TWOBLADEVERTICAL
: nDirection
= 2; break;
764 case TransitionSubType::THREEBLADE
: nDirection
= 3; break;
765 case TransitionSubType::FOURBLADE
: nDirection
= 4; break;
766 case TransitionSubType::EIGHTBLADE
: nDirection
= 8; break;
770 case TransitionType::FANWIPE
:
772 nPPTTransitionType
= PPT_TRANSITION_TYPE_WEDGE
;
775 case TransitionType::ELLIPSEWIPE
:
777 switch( nTransitionSubtype
) {
778 case TransitionSubType::VERTICAL
:
779 case TransitionSubType::HORIZONTAL
:
780 // no ellipse or oval in PPT or OOXML, fallback to circle
782 nPPTTransitionType
= PPT_TRANSITION_TYPE_CIRCLE
;
786 case TransitionType::FOURBOXWIPE
:
788 nPPTTransitionType
= PPT_TRANSITION_TYPE_PLUS
;
791 case TransitionType::IRISWIPE
:
793 switch( nTransitionSubtype
) {
794 case TransitionSubType::RECTANGLE
:
795 nPPTTransitionType
= PPT_TRANSITION_TYPE_ZOOM
;
796 nDirection
= (eEffect
== FadeEffect_FADE_FROM_CENTER
) ? 0 : 1;
799 nPPTTransitionType
= PPT_TRANSITION_TYPE_DIAMOND
;
804 case TransitionType::ZOOM
:
806 switch(nTransitionSubtype
)
808 case TransitionSubType::ROTATEIN
:
809 nPPTTransitionType
= PPT_TRANSITION_TYPE_NEWSFLASH
;
818 return nPPTTransitionType
;
821 sal_Int8
PPTWriterBase::GetTransition( FadeEffect eEffect
, sal_uInt8
& nDirection
)
823 sal_Int8 nPPTTransitionType
= 0;
828 case FadeEffect_RANDOM
:
829 nPPTTransitionType
= PPT_TRANSITION_TYPE_RANDOM
;
832 case FadeEffect_HORIZONTAL_STRIPES
:
835 case FadeEffect_VERTICAL_STRIPES
:
836 nPPTTransitionType
= PPT_TRANSITION_TYPE_BLINDS
;
839 case FadeEffect_VERTICAL_CHECKERBOARD
:
842 case FadeEffect_HORIZONTAL_CHECKERBOARD
:
843 nPPTTransitionType
= PPT_TRANSITION_TYPE_CHECKER
;
846 case FadeEffect_MOVE_FROM_UPPERLEFT
:
849 case FadeEffect_MOVE_FROM_UPPERRIGHT
:
852 case FadeEffect_MOVE_FROM_LOWERLEFT
:
855 case FadeEffect_MOVE_FROM_LOWERRIGHT
:
858 case FadeEffect_MOVE_FROM_TOP
:
861 case FadeEffect_MOVE_FROM_LEFT
:
864 case FadeEffect_MOVE_FROM_BOTTOM
:
867 case FadeEffect_MOVE_FROM_RIGHT
:
868 nPPTTransitionType
= PPT_TRANSITION_TYPE_COVER
;
871 case FadeEffect_DISSOLVE
:
872 nPPTTransitionType
= PPT_TRANSITION_TYPE_DISSOLVE
;
875 case FadeEffect_VERTICAL_LINES
:
878 case FadeEffect_HORIZONTAL_LINES
:
879 nPPTTransitionType
= PPT_TRANSITION_TYPE_RANDOM_BARS
;
882 case FadeEffect_CLOSE_HORIZONTAL
:
885 case FadeEffect_OPEN_HORIZONTAL
:
888 case FadeEffect_CLOSE_VERTICAL
:
891 case FadeEffect_OPEN_VERTICAL
:
892 nPPTTransitionType
= PPT_TRANSITION_TYPE_SPLIT
;
895 case FadeEffect_FADE_FROM_UPPERLEFT
:
898 case FadeEffect_FADE_FROM_UPPERRIGHT
:
901 case FadeEffect_FADE_FROM_LOWERLEFT
:
904 case FadeEffect_FADE_FROM_LOWERRIGHT
:
906 nPPTTransitionType
= PPT_TRANSITION_TYPE_STRIPS
;
909 case FadeEffect_UNCOVER_TO_LOWERRIGHT
:
912 case FadeEffect_UNCOVER_TO_LOWERLEFT
:
915 case FadeEffect_UNCOVER_TO_UPPERRIGHT
:
918 case FadeEffect_UNCOVER_TO_UPPERLEFT
:
921 case FadeEffect_UNCOVER_TO_BOTTOM
:
924 case FadeEffect_UNCOVER_TO_RIGHT
:
927 case FadeEffect_UNCOVER_TO_TOP
:
930 case FadeEffect_UNCOVER_TO_LEFT
:
931 nPPTTransitionType
= PPT_TRANSITION_TYPE_PULL
;
934 case FadeEffect_FADE_FROM_TOP
:
937 case FadeEffect_FADE_FROM_LEFT
:
940 case FadeEffect_FADE_FROM_BOTTOM
:
943 case FadeEffect_FADE_FROM_RIGHT
:
944 case FadeEffect_ROLL_FROM_RIGHT
:
945 nPPTTransitionType
= PPT_TRANSITION_TYPE_WIPE
;
948 case FadeEffect_ROLL_FROM_TOP
:
951 case FadeEffect_ROLL_FROM_LEFT
:
954 case FadeEffect_ROLL_FROM_BOTTOM
:
958 case FadeEffect_FADE_TO_CENTER
:
961 case FadeEffect_FADE_FROM_CENTER
:
962 nPPTTransitionType
= PPT_TRANSITION_TYPE_ZOOM
;
965 case FadeEffect_NONE
:
970 return nPPTTransitionType
;
973 bool PPTWriterBase::ContainsOtherShapeThanPlaceholders()
975 sal_uInt32 nShapes
= mXShapes
->getCount();
976 bool bOtherThanPlaceHolders
= false;
979 for ( sal_uInt32 nIndex
= 0; ( nIndex
< nShapes
) && !bOtherThanPlaceHolders
; nIndex
++ )
981 if ( GetShapeByIndex( nIndex
, false ) && mType
!= "drawing.Page" )
983 if( mType
== "presentation.Page" || mType
== "presentation.Notes" )
985 Reference
< XSimpleText
> rXText( mXShape
, UNO_QUERY
);
987 if( rXText
.is() && !rXText
->getString().isEmpty() )
988 bOtherThanPlaceHolders
= true;
991 bOtherThanPlaceHolders
= true;
993 SAL_INFO("sd.eppt", "mType == " << mType
);
996 return bOtherThanPlaceHolders
;
999 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */