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 <sal/log.hxx>
29 #include <com/sun/star/awt/Rectangle.hpp>
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
32 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
33 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
34 #include <com/sun/star/drawing/XDrawPages.hpp>
35 #include <com/sun/star/animations/TransitionType.hpp>
36 #include <com/sun/star/animations/TransitionSubType.hpp>
37 #include <com/sun/star/awt/FontFamily.hpp>
38 #include <com/sun/star/awt/FontPitch.hpp>
39 #include <com/sun/star/container/XNamed.hpp>
40 #include <com/sun/star/container/XNameAccess.hpp>
41 #include <com/sun/star/presentation/XPresentationPage.hpp>
42 #include <com/sun/star/text/XSimpleText.hpp>
43 #include <com/sun/star/style/XStyle.hpp>
44 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
45 #include <com/sun/star/task/XStatusIndicator.hpp>
48 using namespace com::sun::star
;
50 using namespace ::com::sun::star::animations
;
51 using namespace ::com::sun::star::awt::FontFamily
;
52 using namespace ::com::sun::star::awt::FontPitch
;
53 using namespace ::com::sun::star::presentation
;
55 using ::com::sun::star::beans::XPropertySet
;
56 using ::com::sun::star::container::XNameAccess
;
57 using ::com::sun::star::container::XNamed
;
58 using ::com::sun::star::drawing::XMasterPageTarget
;
59 using ::com::sun::star::drawing::XDrawPage
;
60 using ::com::sun::star::frame::XModel
;
61 using ::com::sun::star::style::XStyleFamiliesSupplier
;
62 using ::com::sun::star::style::XStyle
;
63 using ::com::sun::star::task::XStatusIndicator
;
64 using ::com::sun::star::text::XSimpleText
;
65 using ::com::sun::star::uno::Any
;
66 using ::com::sun::star::uno::Exception
;
67 using ::com::sun::star::uno::Reference
;
68 using ::com::sun::star::uno::UNO_QUERY
;
70 static PHLayout
const pPHLayout
[] =
72 { EppLayout::TITLESLIDE
, { 0x0d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x10, true, true, false },
73 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, true, true, false },
74 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, true, true, false },
75 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x0e, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, true, true, true },
76 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x0e, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, true, true, false },
77 { EppLayout::BLANKSLIDE
, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, false, false, false },
78 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x0e, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, true, true, false },
79 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x14, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, true, true, false },
80 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x15, 0x0d, 0x0e, true, false, false },
81 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x16, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, true, true, false },
82 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
83 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, false, false },
84 { EppLayout::RIGHTCOLUMN2ROWS
, { 0x0d, 0x0e, 0x13, 0x13, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
85 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
86 { EppLayout::TWOROWSANDTITLE
, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
87 { EppLayout::LEFTCOLUMN2ROWS
, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
88 { EppLayout::TOPROW2COLUMN
, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
89 { EppLayout::TWOROWSANDTITLE
, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
90 { EppLayout::FOUROBJECTS
, { 0x0d, 0x13, 0x13, 0x13, 0x13, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, false, false },
91 { EppLayout::ONLYTITLE
, { 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, true, false, false },
92 { EppLayout::BLANKSLIDE
, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, false, false, false },
93 { EppLayout::TITLERIGHT2BODIESLEFT
, { 0x11, 0x12, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x11, 0x12, true, true, false },
94 { EppLayout::TITLERIGHTBODYLEFT
, { 0x11, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x11, 0x12, true, true, false },
95 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x12, true, true, false },
96 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x16, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x12, true, true, false }
99 PPTWriterBase::PPTWriterBase()
100 : mbStatusIndicator(false)
102 , mbEmptyPresObj(false)
103 , mbIsBackgroundDark(false)
108 , maMapModeSrc(MapUnit::Map100thMM
)
109 , maMapModeDest(MapUnit::MapInch
, Point(), maFraction
, maFraction
)
110 , meLatestPageType(NORMAL
)
111 , mpStyleSheet(nullptr)
113 SAL_INFO("sd.eppt", "PPTWriterBase::PPTWriterBase()");
116 PPTWriterBase::PPTWriterBase( const Reference
< XModel
> & rXModel
,
117 const Reference
< XStatusIndicator
> & rXStatInd
)
119 , mXStatusIndicator(rXStatInd
)
120 , mbStatusIndicator(false)
122 , mbEmptyPresObj(false)
123 , mbIsBackgroundDark(false)
128 , maMapModeSrc(MapUnit::Map100thMM
)
129 , maMapModeDest(MapUnit::MapInch
, Point(), maFraction
, maFraction
)
130 , meLatestPageType (NORMAL
)
131 , mpStyleSheet(nullptr)
135 PPTWriterBase::~PPTWriterBase()
137 // Possibly unnecessary sanity check for mXStatusIndicator.is().
138 // In 3.3 we had a bug report of a crash where it was null,
139 // https://bugzilla.novell.com/show_bug.cgi?id=694119 (non-public,
140 // bug report, sorry).
141 if ( mbStatusIndicator
&& mXStatusIndicator
.is() )
142 mXStatusIndicator
->end();
145 void PPTWriterBase::exportPPT( const std::vector
< css::beans::PropertyValue
>& rMediaData
)
147 if ( !InitSOIface() )
150 FontCollectionEntry
aDefaultFontDesc( "Times New Roman",
152 awt::FontPitch::VARIABLE
,
153 RTL_TEXTENCODING_MS_1252
);
154 maFontCollection
.GetId( aDefaultFontDesc
); // default is always times new roman
156 if ( !GetPageByIndex( 0, NOTICE
) )
159 sal_Int32 nWidth
= 21000;
160 if ( ImplGetPropertyValue( mXPagePropSet
, "Width" ) )
162 sal_Int32 nHeight
= 29700;
163 if ( ImplGetPropertyValue( mXPagePropSet
, "Height" ) )
166 maNotesPageSize
= MapSize( awt::Size( nWidth
, nHeight
) );
168 if ( !GetPageByIndex( 0, MASTER
) )
172 if ( ImplGetPropertyValue( mXPagePropSet
, "Width" ) )
175 if ( ImplGetPropertyValue( mXPagePropSet
, "Height" ) )
177 maDestPageSize
= MapSize( awt::Size( nWidth
, nHeight
) );
178 maPageSize
= awt::Size(nWidth
, nHeight
);
180 SAL_INFO("sd.eppt", "call exportDocumentPre()");
181 exportPPTPre(rMediaData
);
183 if ( !GetStyleSheets() )
186 if ( !ImplCreateDocument() )
191 for ( i
= 0; i
< mnMasterPages
; i
++ )
193 if ( !CreateSlideMaster( i
) )
196 if ( !CreateMainNotes() )
199 for ( i
= 0; i
< mnPages
; i
++ )
201 SAL_INFO("sd.eppt", "call ImplCreateSlide( " << i
<< " )");
202 if ( !CreateSlide( i
) )
206 for ( i
= 0; i
< mnPages
; i
++ )
208 if ( !CreateNotes( i
) )
212 SAL_INFO("sd.eppt", "call exportDocumentPost()");
216 bool PPTWriterBase::InitSOIface()
220 mXDrawPagesSupplier
.set( mXModel
, UNO_QUERY
);
221 if ( !mXDrawPagesSupplier
.is() )
224 mXMasterPagesSupplier
.set( mXModel
, UNO_QUERY
);
225 if ( !mXMasterPagesSupplier
.is() )
227 mXDrawPages
= mXMasterPagesSupplier
->getMasterPages();
228 if ( !mXDrawPages
.is() )
230 mnMasterPages
= mXDrawPages
->getCount();
231 mXDrawPages
= mXDrawPagesSupplier
->getDrawPages();
232 if( !mXDrawPages
.is() )
234 mnPages
= mXDrawPages
->getCount();
235 if ( !GetPageByIndex( 0, NORMAL
) )
243 bool PPTWriterBase::GetPageByIndex( sal_uInt32 nIndex
, PageType ePageType
)
247 if ( ePageType
!= meLatestPageType
)
254 mXDrawPages
= mXDrawPagesSupplier
->getDrawPages();
255 if( !mXDrawPages
.is() )
262 mXDrawPages
= mXMasterPagesSupplier
->getMasterPages();
263 if( !mXDrawPages
.is() )
270 meLatestPageType
= ePageType
;
272 Any
aAny( mXDrawPages
->getByIndex( nIndex
) );
274 if ( !mXDrawPage
.is() )
276 if ( ePageType
== NOTICE
)
278 Reference
< XPresentationPage
> aXPresentationPage( mXDrawPage
, UNO_QUERY
);
279 if ( !aXPresentationPage
.is() )
281 mXDrawPage
= aXPresentationPage
->getNotesPage();
282 if ( !mXDrawPage
.is() )
285 mXPagePropSet
.set( mXDrawPage
, UNO_QUERY
);
286 if ( !mXPagePropSet
.is() )
289 if (GetPropertyValue( aAny
, mXPagePropSet
, "IsBackgroundDark" ) )
290 aAny
>>= mbIsBackgroundDark
;
292 mXShapes
.set( mXDrawPage
, UNO_QUERY
);
293 if ( !mXShapes
.is() )
296 /* try to get the "real" background PropertySet. If the normal page is not supporting this property, it is
297 taken the property from the master */
298 bool bHasBackground
= GetPropertyValue( aAny
, mXPagePropSet
, "Background", true );
299 if ( bHasBackground
)
300 bHasBackground
= ( aAny
>>= mXBackgroundPropSet
);
301 if ( !bHasBackground
)
303 Reference
< XMasterPageTarget
> aXMasterPageTarget( mXDrawPage
, UNO_QUERY
);
304 if ( aXMasterPageTarget
.is() )
306 Reference
< XDrawPage
> aXMasterDrawPage
= aXMasterPageTarget
->getMasterPage();
307 if ( aXMasterDrawPage
.is() )
309 Reference
< XPropertySet
> aXMasterPagePropSet
;
310 aXMasterPagePropSet
.set( aXMasterDrawPage
, UNO_QUERY
);
311 if ( aXMasterPagePropSet
.is() )
313 bool bBackground
= GetPropertyValue( aAny
, aXMasterPagePropSet
, "Background" );
316 aAny
>>= mXBackgroundPropSet
;
327 bool PPTWriterBase::CreateSlide( sal_uInt32 nPageNum
)
331 if ( !GetPageByIndex( nPageNum
, NORMAL
) )
334 sal_uInt32 nMasterNum
= GetMasterIndex( NORMAL
);
335 SetCurrentStyleSheet( nMasterNum
);
337 Reference
< XPropertySet
> aXBackgroundPropSet
;
338 bool bHasBackground
= GetPropertyValue( aAny
, mXPagePropSet
, "Background" );
339 if ( bHasBackground
)
340 bHasBackground
= ( aAny
>>= aXBackgroundPropSet
);
342 sal_uInt16 nMode
= 7; // Bit 1: Follow master objects, Bit 2: Follow master scheme, Bit 3: Follow master background
343 if ( bHasBackground
)
346 /* sj: Don't know what's IsBackgroundVisible for, have to ask cl
347 if ( GetPropertyValue( aAny, mXPagePropSet, OUString( "IsBackgroundVisible" ) ) )
349 bool bBackgroundVisible;
350 if ( aAny >>= bBackgroundVisible )
352 if ( bBackgroundVisible )
357 if ( GetPropertyValue( aAny
, mXPagePropSet
, "IsBackgroundObjectsVisible" ) )
359 bool bBackgroundObjectsVisible
= false;
360 if ( aAny
>>= bBackgroundObjectsVisible
)
362 if ( !bBackgroundObjectsVisible
)
367 ImplWriteSlide( nPageNum
, nMasterNum
, nMode
, bHasBackground
, aXBackgroundPropSet
);
372 bool PPTWriterBase::CreateNotes( sal_uInt32 nPageNum
)
374 if ( !GetPageByIndex( nPageNum
, NOTICE
) )
376 SetCurrentStyleSheet( GetMasterIndex( NORMAL
) );
378 ImplWriteNotes( nPageNum
);
383 bool PPTWriterBase::CreateSlideMaster( sal_uInt32 nPageNum
)
385 if ( !GetPageByIndex( nPageNum
, MASTER
) )
387 SetCurrentStyleSheet( nPageNum
);
389 if ( !ImplGetPropertyValue( mXPagePropSet
, "Background" ) ) // load background shape
391 css::uno::Reference
< css::beans::XPropertySet
> aXBackgroundPropSet
;
392 if ( !( mAny
>>= aXBackgroundPropSet
) )
395 ImplWriteSlideMaster( nPageNum
, aXBackgroundPropSet
);
400 sal_Int32
PPTWriterBase::GetLayoutOffset( const css::uno::Reference
< css::beans::XPropertySet
>& rXPropSet
)
403 sal_Int32 nLayout
= 20;
404 if ( GetPropertyValue( aAny
, rXPropSet
, "Layout", true ) )
407 SAL_INFO("sd.eppt", "GetLayoutOffset " << nLayout
);
412 sal_Int32
PPTWriterBase::GetLayoutOffsetFixed( const css::uno::Reference
< css::beans::XPropertySet
>& rXPropSet
)
414 sal_Int32 nLayout
= GetLayoutOffset( rXPropSet
);
416 if ( ( nLayout
>= 21 ) && ( nLayout
<= 26 ) ) // NOTES _> HANDOUT6
418 if ( ( nLayout
>= 27 ) && ( nLayout
<= 30 ) ) // VERTICAL LAYOUT
420 else if ( nLayout
> 30 )
426 PHLayout
const & PPTWriterBase::GetLayout( const css::uno::Reference
< css::beans::XPropertySet
>& rXPropSet
)
428 return pPHLayout
[ GetLayoutOffsetFixed( rXPropSet
) ];
431 PHLayout
const & PPTWriterBase::GetLayout( sal_Int32 nOffset
)
433 if( nOffset
>= 0 && nOffset
< EPP_LAYOUT_SIZE
)
434 return pPHLayout
[ nOffset
];
436 SAL_INFO("sd.eppt", "asked " << nOffset
<< " for layout outside of 0, " << EPP_LAYOUT_SIZE
<< " array scope");
438 return pPHLayout
[ 0 ];
441 sal_uInt32
PPTWriterBase::GetMasterIndex( PageType ePageType
)
443 sal_uInt32 nRetValue
= 0;
444 css::uno::Reference
< css::drawing::XMasterPageTarget
>aXMasterPageTarget( mXDrawPage
, css::uno::UNO_QUERY
);
446 if ( aXMasterPageTarget
.is() )
448 css::uno::Reference
< css::drawing::XDrawPage
>aXDrawPage
= aXMasterPageTarget
->getMasterPage();
449 if ( aXDrawPage
.is() )
451 css::uno::Reference
< css::beans::XPropertySet
> aXPropertySet( aXDrawPage
, css::uno::UNO_QUERY
);
452 if ( aXPropertySet
.is() )
454 if ( ImplGetPropertyValue( aXPropertySet
, "Number" ) )
455 nRetValue
|= *o3tl::doAccess
<sal_Int16
>(mAny
);
456 if ( nRetValue
& 0xffff ) // avoid overflow
461 if ( ePageType
== NOTICE
)
462 nRetValue
+= mnMasterPages
;
466 void PPTWriterBase::SetCurrentStyleSheet( sal_uInt32 nPageNum
)
468 if ( nPageNum
>= maStyleSheetList
.size() )
470 mpStyleSheet
= maStyleSheetList
[ nPageNum
].get();
473 bool PPTWriterBase::GetStyleSheets()
475 int nInstance
, nLevel
;
476 bool bRetValue
= false;
479 for ( nPageNum
= 0; nPageNum
< mnMasterPages
; nPageNum
++ )
484 Reference
< XNameAccess
>
487 Reference
< XStyleFamiliesSupplier
>
488 aXStyleFamiliesSupplier( mXModel
, UNO_QUERY
);
490 Reference
< XPropertySet
>
491 aXPropSet( mXModel
, UNO_QUERY
);
493 sal_uInt16 nDefaultTab
= ( aXPropSet
.is() && ImplGetPropertyValue( aXPropSet
, "TabStop" ) )
494 ? static_cast<sal_uInt16
>( *o3tl::doAccess
<sal_Int32
>(mAny
) / 4.40972 )
497 maStyleSheetList
.emplace_back( new PPTExStyleSheet( nDefaultTab
, dynamic_cast<PPTExBulletProvider
*>(this) ) );
498 SetCurrentStyleSheet( nPageNum
);
499 if ( GetPageByIndex( nPageNum
, MASTER
) )
500 aXNamed
.set( mXDrawPage
, UNO_QUERY
);
502 if ( aXStyleFamiliesSupplier
.is() )
503 aXNameAccess
= aXStyleFamiliesSupplier
->getStyleFamilies();
505 bRetValue
= aXNamed
.is() && aXNameAccess
.is() && aXStyleFamiliesSupplier
.is();
508 for ( nInstance
= EPP_TEXTTYPE_Title
; nInstance
<= EPP_TEXTTYPE_CenterTitle
; nInstance
++ )
514 case EPP_TEXTTYPE_CenterTitle
:
515 case EPP_TEXTTYPE_Title
:
518 aFamily
= aXNamed
->getName();
521 case EPP_TEXTTYPE_Body
:
523 aStyle
= "outline1"; // SD_LT_SEPARATOR
524 aFamily
= aXNamed
->getName();
527 case EPP_TEXTTYPE_Other
:
530 aFamily
= "graphics";
533 case EPP_TEXTTYPE_CenterBody
:
536 aFamily
= aXNamed
->getName();
540 if ( !aStyle
.isEmpty() && !aFamily
.isEmpty() )
544 Reference
< XNameAccess
>xNameAccess
;
545 if ( aXNameAccess
->hasByName( aFamily
) )
547 Any
aAny( aXNameAccess
->getByName( aFamily
) );
548 xNameAccess
.set(aAny
, css::uno::UNO_QUERY
);
549 if( xNameAccess
.is() )
551 Reference
< XNameAccess
> aXFamily
;
552 if ( aAny
>>= aXFamily
)
554 if ( aXFamily
->hasByName( aStyle
) )
556 aAny
= aXFamily
->getByName( aStyle
);
557 Reference
< XStyle
> xStyle(
558 aAny
, css::uno::UNO_QUERY
);
561 Reference
< XStyle
> aXStyle
;
563 Reference
< XPropertySet
>
564 xPropSet( aXStyle
, UNO_QUERY
);
566 mpStyleSheet
->SetStyleSheet( xPropSet
, maFontCollection
, nInstance
, 0 );
567 for ( nLevel
= 1; nLevel
< 5; nLevel
++ )
569 if ( nInstance
== EPP_TEXTTYPE_Body
)
571 sal_Unicode cTemp
= aStyle
[aStyle
.getLength() - 1];
572 aStyle
= aStyle
.copy(0, aStyle
.getLength() - 1) + OUStringLiteral1(++cTemp
);
573 if ( aXFamily
->hasByName( aStyle
) )
575 aXFamily
->getByName( aStyle
) >>= xStyle
;
578 Reference
< XPropertySet
>
579 xPropertySet( xStyle
, UNO_QUERY
);
580 if ( xPropertySet
.is() )
581 mpStyleSheet
->SetStyleSheet( xPropertySet
, maFontCollection
, nInstance
, nLevel
);
586 mpStyleSheet
->SetStyleSheet( xPropSet
, maFontCollection
, nInstance
, nLevel
);
600 for ( ; nInstance
<= EPP_TEXTTYPE_QuarterBody
; nInstance
++ )
609 bool PPTWriterBase::CreateMainNotes()
611 if ( !GetPageByIndex( 0, NOTICE
) )
613 SetCurrentStyleSheet( 0 );
615 css::uno::Reference
< css::drawing::XMasterPageTarget
> aXMasterPageTarget( mXDrawPage
, css::uno::UNO_QUERY
);
617 if ( !aXMasterPageTarget
.is() )
620 mXDrawPage
= aXMasterPageTarget
->getMasterPage();
621 if ( !mXDrawPage
.is() )
624 mXPropSet
.set( mXDrawPage
, css::uno::UNO_QUERY
);
625 if ( !mXPropSet
.is() )
628 mXShapes
.set( mXDrawPage
, css::uno::UNO_QUERY
);
629 if ( !mXShapes
.is() )
632 return ImplCreateMainNotes();
635 awt::Size
PPTWriterBase::MapSize( const awt::Size
& rSize
)
637 Size
aRetSize( OutputDevice::LogicToLogic( Size( rSize
.Width
, rSize
.Height
), maMapModeSrc
, maMapModeDest
) );
639 if ( !aRetSize
.Width() )
640 aRetSize
.AdjustWidth( 1 );
641 if ( !aRetSize
.Height() )
642 aRetSize
.AdjustHeight( 1 );
643 return awt::Size( aRetSize
.Width(), aRetSize
.Height() );
646 awt::Point
PPTWriterBase::MapPoint( const awt::Point
& rPoint
)
648 Point
aRet( OutputDevice::LogicToLogic( Point( rPoint
.X
, rPoint
.Y
), maMapModeSrc
, maMapModeDest
) );
649 return awt::Point( aRet
.X(), aRet
.Y() );
652 ::tools::Rectangle
PPTWriterBase::MapRectangle( const awt::Rectangle
& rRect
)
654 css::awt::Point
aPoint( rRect
.X
, rRect
.Y
);
655 css::awt::Size
aSize( rRect
.Width
, rRect
.Height
);
656 css::awt::Point
aP( MapPoint( aPoint
) );
657 css::awt::Size
aS( MapSize( aSize
) );
658 return ::tools::Rectangle( Point( aP
.X
, aP
.Y
), Size( aS
.Width
, aS
.Height
) );
661 bool PPTWriterBase::GetShapeByIndex( sal_uInt32 nIndex
, bool bGroup
)
665 if ( !bGroup
|| ( GetCurrentGroupLevel() == 0 ) )
667 Any
aAny( mXShapes
->getByIndex( nIndex
) );
672 Any
aAny( GetCurrentGroupAccess()->getByIndex( GetCurrentGroupIndex() ) );
678 Any
aAny( mXShape
->queryInterface( cppu::UnoType
<XPropertySet
>::get()));
681 if ( !mXPropSet
.is() )
683 maPosition
= MapPoint( mXShape
->getPosition() );
684 maSize
= MapSize( mXShape
->getSize() );
685 maRect
= ::tools::Rectangle( Point( maPosition
.X
, maPosition
.Y
), Size( maSize
.Width
, maSize
.Height
) );
687 OStringBuffer
aTypeBuffer(OUStringToOString(
688 mXShape
->getShapeType(), RTL_TEXTENCODING_UTF8
));
689 // remove "com.sun.star."
690 aTypeBuffer
.remove(0, RTL_CONSTASCII_LENGTH("com.sun.star."));
692 sal_Int32 nPos
= aTypeBuffer
.toString().indexOf("Shape");
693 aTypeBuffer
.remove(nPos
, RTL_CONSTASCII_LENGTH("Shape"));
694 mType
= aTypeBuffer
.makeStringAndClear();
696 mbPresObj
= mbEmptyPresObj
= false;
697 if ( ImplGetPropertyValue( "IsPresentationObject" ) )
700 if ( mbPresObj
&& ImplGetPropertyValue( "IsEmptyPresentationObject" ) )
701 mAny
>>= mbEmptyPresObj
;
703 mnAngle
= ( PropValue::GetPropertyValue( aAny
,
704 mXPropSet
, "RotateAngle", true ) )
705 ? *o3tl::doAccess
<sal_Int32
>(aAny
)
713 sal_Int8
PPTWriterBase::GetTransition( sal_Int16 nTransitionType
, sal_Int16 nTransitionSubtype
, FadeEffect eEffect
, sal_uInt8
& nDirection
)
715 sal_Int8 nPPTTransitionType
= 0;
718 switch( nTransitionType
)
720 case TransitionType::FADE
:
722 if ( nTransitionSubtype
== TransitionSubType::CROSSFADE
)
723 nPPTTransitionType
= PPT_TRANSITION_TYPE_SMOOTHFADE
;
724 else if ( nTransitionSubtype
== TransitionSubType::FADEOVERCOLOR
)
725 nPPTTransitionType
= PPT_TRANSITION_TYPE_FADE
;
728 case TransitionType::PUSHWIPE
:
730 if (nTransitionSubtype
== TransitionSubType::COMBVERTICAL
||
731 nTransitionSubtype
== TransitionSubType::COMBHORIZONTAL
)
733 nPPTTransitionType
= PPT_TRANSITION_TYPE_COMB
;
737 nPPTTransitionType
= PPT_TRANSITION_TYPE_PUSH
;
739 switch (nTransitionSubtype
)
741 case TransitionSubType::FROMRIGHT
: nDirection
= 0; break;
742 case TransitionSubType::FROMBOTTOM
: nDirection
= 1; break;
743 case TransitionSubType::FROMLEFT
: nDirection
= 2; break;
744 case TransitionSubType::FROMTOP
: nDirection
= 3; break;
745 case TransitionSubType::COMBHORIZONTAL
: nDirection
= 0; break;
746 case TransitionSubType::COMBVERTICAL
: nDirection
= 1; break;
750 case TransitionType::PINWHEELWIPE
:
752 nPPTTransitionType
= PPT_TRANSITION_TYPE_WHEEL
;
753 switch( nTransitionSubtype
)
755 case TransitionSubType::ONEBLADE
: nDirection
= 1; break;
756 case TransitionSubType::TWOBLADEVERTICAL
: nDirection
= 2; break;
757 case TransitionSubType::THREEBLADE
: nDirection
= 3; break;
758 case TransitionSubType::FOURBLADE
: nDirection
= 4; break;
759 case TransitionSubType::EIGHTBLADE
: nDirection
= 8; break;
763 case TransitionType::FANWIPE
:
765 nPPTTransitionType
= PPT_TRANSITION_TYPE_WEDGE
;
768 case TransitionType::ELLIPSEWIPE
:
770 switch( nTransitionSubtype
) {
771 case TransitionSubType::VERTICAL
:
772 case TransitionSubType::HORIZONTAL
:
773 // no ellipse or oval in PPT or OOXML, fallback to circle
775 nPPTTransitionType
= PPT_TRANSITION_TYPE_CIRCLE
;
779 case TransitionType::FOURBOXWIPE
:
781 nPPTTransitionType
= PPT_TRANSITION_TYPE_PLUS
;
784 case TransitionType::IRISWIPE
:
786 switch( nTransitionSubtype
) {
787 case TransitionSubType::RECTANGLE
:
788 nPPTTransitionType
= PPT_TRANSITION_TYPE_ZOOM
;
789 nDirection
= (eEffect
== FadeEffect_FADE_FROM_CENTER
) ? 0 : 1;
792 nPPTTransitionType
= PPT_TRANSITION_TYPE_DIAMOND
;
797 case TransitionType::ZOOM
:
799 switch(nTransitionSubtype
)
801 case TransitionSubType::ROTATEIN
:
802 nPPTTransitionType
= PPT_TRANSITION_TYPE_NEWSFLASH
;
811 return nPPTTransitionType
;
814 sal_Int8
PPTWriterBase::GetTransition( FadeEffect eEffect
, sal_uInt8
& nDirection
)
816 sal_Int8 nPPTTransitionType
= 0;
821 case FadeEffect_RANDOM
:
822 nPPTTransitionType
= PPT_TRANSITION_TYPE_RANDOM
;
825 case FadeEffect_HORIZONTAL_STRIPES
:
828 case FadeEffect_VERTICAL_STRIPES
:
829 nPPTTransitionType
= PPT_TRANSITION_TYPE_BLINDS
;
832 case FadeEffect_VERTICAL_CHECKERBOARD
:
835 case FadeEffect_HORIZONTAL_CHECKERBOARD
:
836 nPPTTransitionType
= PPT_TRANSITION_TYPE_CHECKER
;
839 case FadeEffect_MOVE_FROM_UPPERLEFT
:
842 case FadeEffect_MOVE_FROM_UPPERRIGHT
:
845 case FadeEffect_MOVE_FROM_LOWERLEFT
:
848 case FadeEffect_MOVE_FROM_LOWERRIGHT
:
851 case FadeEffect_MOVE_FROM_TOP
:
854 case FadeEffect_MOVE_FROM_LEFT
:
857 case FadeEffect_MOVE_FROM_BOTTOM
:
860 case FadeEffect_MOVE_FROM_RIGHT
:
861 nPPTTransitionType
= PPT_TRANSITION_TYPE_COVER
;
864 case FadeEffect_DISSOLVE
:
865 nPPTTransitionType
= PPT_TRANSITION_TYPE_DISSOLVE
;
868 case FadeEffect_VERTICAL_LINES
:
871 case FadeEffect_HORIZONTAL_LINES
:
872 nPPTTransitionType
= PPT_TRANSITION_TYPE_RANDOM_BARS
;
875 case FadeEffect_CLOSE_HORIZONTAL
:
878 case FadeEffect_OPEN_HORIZONTAL
:
881 case FadeEffect_CLOSE_VERTICAL
:
884 case FadeEffect_OPEN_VERTICAL
:
885 nPPTTransitionType
= PPT_TRANSITION_TYPE_SPLIT
;
888 case FadeEffect_FADE_FROM_UPPERLEFT
:
891 case FadeEffect_FADE_FROM_UPPERRIGHT
:
894 case FadeEffect_FADE_FROM_LOWERLEFT
:
897 case FadeEffect_FADE_FROM_LOWERRIGHT
:
899 nPPTTransitionType
= PPT_TRANSITION_TYPE_STRIPS
;
902 case FadeEffect_UNCOVER_TO_LOWERRIGHT
:
905 case FadeEffect_UNCOVER_TO_LOWERLEFT
:
908 case FadeEffect_UNCOVER_TO_UPPERRIGHT
:
911 case FadeEffect_UNCOVER_TO_UPPERLEFT
:
914 case FadeEffect_UNCOVER_TO_BOTTOM
:
917 case FadeEffect_UNCOVER_TO_RIGHT
:
920 case FadeEffect_UNCOVER_TO_TOP
:
923 case FadeEffect_UNCOVER_TO_LEFT
:
924 nPPTTransitionType
= PPT_TRANSITION_TYPE_PULL
;
927 case FadeEffect_FADE_FROM_TOP
:
930 case FadeEffect_FADE_FROM_LEFT
:
933 case FadeEffect_FADE_FROM_BOTTOM
:
936 case FadeEffect_FADE_FROM_RIGHT
:
937 nPPTTransitionType
= PPT_TRANSITION_TYPE_WIPE
;
940 case FadeEffect_ROLL_FROM_TOP
:
943 case FadeEffect_ROLL_FROM_LEFT
:
946 case FadeEffect_ROLL_FROM_BOTTOM
:
949 case FadeEffect_ROLL_FROM_RIGHT
:
950 nPPTTransitionType
= PPT_TRANSITION_TYPE_WIPE
;
953 case FadeEffect_FADE_TO_CENTER
:
956 case FadeEffect_FADE_FROM_CENTER
:
957 nPPTTransitionType
= PPT_TRANSITION_TYPE_ZOOM
;
960 case FadeEffect_NONE
:
965 return nPPTTransitionType
;
968 bool PPTWriterBase::ContainsOtherShapeThanPlaceholders()
970 sal_uInt32 nShapes
= mXShapes
->getCount();
971 bool bOtherThanPlaceHolders
= false;
974 for ( sal_uInt32 nIndex
= 0; ( nIndex
< nShapes
) && !bOtherThanPlaceHolders
; nIndex
++ )
976 if ( GetShapeByIndex( nIndex
, false ) && mType
!= "drawing.Page" )
978 if( mType
== "presentation.Page" || mType
== "presentation.Notes" )
980 Reference
< XSimpleText
> rXText( mXShape
, UNO_QUERY
);
982 if( rXText
.is() && !rXText
->getString().isEmpty() )
983 bOtherThanPlaceHolders
= true;
986 bOtherThanPlaceHolders
= true;
988 SAL_INFO("sd.eppt", "mType == " << mType
);
991 return bOtherThanPlaceHolders
;
994 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */