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 .
21 #include "epptdef.hxx"
23 #include <tools/globname.hxx>
24 #include <tools/datetime.hxx>
25 #include <tools/poly.hxx>
26 #include <tools/stream.hxx>
27 #include <vcl/graph.hxx>
28 #include <vcl/bmpacc.hxx>
29 #include <vcl/gradient.hxx>
30 #include <vcl/virdev.hxx>
31 #include <rtl/ustring.hxx>
32 #include <rtl/strbuf.hxx>
33 #include <vcl/fltcall.hxx>
34 #include <vcl/wmf.hxx>
35 #include <sfx2/docfile.hxx>
36 #include <sfx2/docinf.hxx>
37 #include <svx/unoapi.hxx>
38 #include <svx/svdobj.hxx>
39 #include <svx/svdoole2.hxx>
40 #include <svx/svdmodel.hxx>
41 #include <svx/svdpage.hxx>
42 #include <com/sun/star/view/PaperOrientation.hpp>
43 #include <com/sun/star/view/PaperFormat.hpp>
44 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
45 #include <com/sun/star/office/XAnnotation.hpp>
46 #include <com/sun/star/office/XAnnotationAccess.hpp>
47 #include <com/sun/star/office/XAnnotationEnumeration.hpp>
48 #include <com/sun/star/geometry/RealPoint2D.hpp>
49 #include <com/sun/star/util/DateTime.hpp>
50 #include <com/sun/star/animations/TransitionType.hpp>
51 #include <com/sun/star/animations/TransitionSubType.hpp>
52 #include <com/sun/star/awt/FontDescriptor.hpp>
53 #include <com/sun/star/awt/FontFamily.hpp>
54 #include <com/sun/star/awt/FontPitch.hpp>
55 #include <com/sun/star/container/XNamed.hpp>
56 #include <com/sun/star/container/XNameAccess.hpp>
57 #include <com/sun/star/presentation/XPresentationPage.hpp>
58 #include <com/sun/star/text/XSimpleText.hpp>
59 #include <com/sun/star/style/XStyle.hpp>
60 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
61 #include <editeng/svxenum.hxx>
62 #include <editeng/flditem.hxx>
63 #include <sot/storinfo.hxx>
64 #include <filter/msfilter/msoleexp.hxx>
65 #include <filter/msfilter/msdffimp.hxx>
66 #include <filter/msfilter/svxmsbas.hxx>
75 using namespace com::sun::star
;
77 using namespace ::com::sun::star::animations
;
78 using namespace ::com::sun::star::awt::FontFamily
;
79 using namespace ::com::sun::star::awt::FontPitch
;
80 using namespace ::com::sun::star::presentation
;
82 using ::com::sun::star::awt::FontDescriptor
;
83 using ::com::sun::star::beans::XPropertySet
;
84 using ::com::sun::star::container::XNameAccess
;
85 using ::com::sun::star::container::XNamed
;
86 using ::com::sun::star::drawing::XDrawPagesSupplier
;
87 using ::com::sun::star::drawing::XMasterPagesSupplier
;
88 using ::com::sun::star::drawing::XShapes
;
89 using ::com::sun::star::drawing::XMasterPageTarget
;
90 using ::com::sun::star::drawing::XDrawPage
;
91 using ::com::sun::star::frame::XModel
;
92 using ::com::sun::star::style::XStyleFamiliesSupplier
;
93 using ::com::sun::star::style::XStyle
;
94 using ::com::sun::star::task::XStatusIndicator
;
95 using ::com::sun::star::text::XSimpleText
;
96 using ::com::sun::star::uno::Any
;
97 using ::com::sun::star::uno::Exception
;
98 using ::com::sun::star::uno::Reference
;
99 using ::com::sun::star::uno::UNO_QUERY
;
101 static PHLayout pPHLayout
[] =
103 { EppLayout::TITLESLIDE
, { 0x0d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x10, true, true, false },
104 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, true, true, false },
105 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, true, true, false },
106 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x0e, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, true, true, true },
107 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x0e, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, true, true, false },
108 { EppLayout::BLANCSLIDE
, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, false, false, false },
109 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x0e, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, true, true, false },
110 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x14, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, true, true, false },
111 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x15, 0x0d, 0x0e, true, false, false },
112 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x16, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, true, true, false },
113 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
114 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, false, false },
115 { EppLayout::RIGHTCOLUMN2ROWS
, { 0x0d, 0x0e, 0x13, 0x13, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
116 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
117 { EppLayout::TWOROWSANDTITLE
, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
118 { EppLayout::LEFTCOLUMN2ROWS
, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
119 { EppLayout::TOPROW2COLUMN
, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
120 { EppLayout::TWOROWSANDTITLE
, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, true, false },
121 { EppLayout::FOUROBJECTS
, { 0x0d, 0x13, 0x13, 0x13, 0x13, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, true, false, false },
122 { EppLayout::ONLYTITLE
, { 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, true, false, false },
123 { EppLayout::BLANCSLIDE
, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, false, false, false },
124 { EppLayout::TITLERIGHT2BODIESLEFT
, { 0x11, 0x12, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x11, 0x12, true, true, false },
125 { EppLayout::TITLERIGHTBODYLEFT
, { 0x11, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x11, 0x12, true, true, false },
126 { EppLayout::TITLEANDBODYSLIDE
, { 0x0d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x12, true, true, false },
127 { EppLayout::TWOCOLUMNSANDTITLE
, { 0x0d, 0x16, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x12, true, true, false }
130 PPTWriterBase::PPTWriterBase()
132 , mXStatusIndicator(0)
133 , mbStatusIndicator(false)
135 , mbEmptyPresObj(false)
136 , mbIsBackgroundDark(false)
141 , maMapModeSrc(MAP_100TH_MM
)
142 , maMapModeDest(MAP_INCH
, Point(), maFraction
, maFraction
)
143 , meLatestPageType(NORMAL
)
146 DBG(printf ("PPTWriterBase::PPTWriterBase()\n"));
149 PPTWriterBase::PPTWriterBase( const Reference
< XModel
> & rXModel
,
150 const Reference
< XStatusIndicator
> & rXStatInd
)
152 , mXStatusIndicator(rXStatInd
)
153 , mbStatusIndicator(false)
155 , mbEmptyPresObj(false)
160 , maMapModeSrc(MAP_100TH_MM
)
161 , maMapModeDest(MAP_INCH
, Point(), maFraction
, maFraction
)
162 , meLatestPageType (NORMAL
)
167 PPTWriterBase::~PPTWriterBase()
169 // Possibly unnecessary sanity check for mXStatusIndicator.is().
170 // In 3.3 we had a bug report of a crash where it was null,
171 // https://bugzilla.novell.com/show_bug.cgi?id=694119 (non-public,
172 // bug report, sorry).
173 if ( mbStatusIndicator
&& mXStatusIndicator
.is() )
174 mXStatusIndicator
->end();
177 void PPTWriterBase::exportPPT( const std::vector
< com::sun::star::beans::PropertyValue
>& rMediaData
)
179 if ( !InitSOIface() )
182 FontCollectionEntry
aDefaultFontDesc( OUString( "Times New Roman" ),
184 awt::FontPitch::VARIABLE
,
185 RTL_TEXTENCODING_MS_1252
);
186 maFontCollection
.GetId( aDefaultFontDesc
); // default is always times new roman
188 if ( !GetPageByIndex( 0, NOTICE
) )
191 sal_Int32 nWidth
= 21000;
192 if ( ImplGetPropertyValue( mXPagePropSet
, OUString( "Width" ) ) )
194 sal_Int32 nHeight
= 29700;
195 if ( ImplGetPropertyValue( mXPagePropSet
, OUString( "Height" ) ) )
198 maNotesPageSize
= MapSize( awt::Size( nWidth
, nHeight
) );
200 if ( !GetPageByIndex( 0, MASTER
) )
204 if ( ImplGetPropertyValue( mXPagePropSet
, OUString( "Width" ) ) )
207 if ( ImplGetPropertyValue( mXPagePropSet
, OUString( "Height" ) ) )
209 maDestPageSize
= MapSize( awt::Size( nWidth
, nHeight
) );
210 maPageSize
= awt::Size(nWidth
, nHeight
);
212 DBG(printf( "call exportDocumentPre()\n"));
213 exportPPTPre(rMediaData
);
215 if ( !GetStyleSheets() )
218 if ( !ImplCreateDocument() )
223 for ( i
= 0; i
< mnPages
; i
++ )
225 if ( GetPageByIndex( i
, NORMAL
) ) {
226 sal_uInt32 nMasterNum
= GetMasterIndex( NORMAL
);
227 ImplWriteLayout( GetLayoutOffset( mXPagePropSet
), nMasterNum
);
231 for ( i
= 0; i
< mnMasterPages
; i
++ )
233 if ( !CreateSlideMaster( i
) )
236 if ( !CreateMainNotes() )
239 for ( i
= 0; i
< mnPages
; i
++ )
241 DBG(printf( "call ImplCreateSlide( %" SAL_PRIuUINT32
" )\n", i
));
242 if ( !CreateSlide( i
) )
246 for ( i
= 0; i
< mnPages
; i
++ )
248 if ( !CreateNotes( i
) )
252 DBG(printf( "call exportDocumentPost()\n"));
256 bool PPTWriterBase::InitSOIface()
260 mXDrawPagesSupplier
= Reference
< XDrawPagesSupplier
>( mXModel
, UNO_QUERY
);
261 if ( !mXDrawPagesSupplier
.is() )
264 mXMasterPagesSupplier
= Reference
< XMasterPagesSupplier
>( mXModel
, UNO_QUERY
);
265 if ( !mXMasterPagesSupplier
.is() )
267 mXDrawPages
= mXMasterPagesSupplier
->getMasterPages();
268 if ( !mXDrawPages
.is() )
270 mnMasterPages
= mXDrawPages
->getCount();
271 mXDrawPages
= mXDrawPagesSupplier
->getDrawPages();
272 if( !mXDrawPages
.is() )
274 mnPages
= mXDrawPages
->getCount();
275 if ( !GetPageByIndex( 0, NORMAL
) )
283 bool PPTWriterBase::GetPageByIndex( sal_uInt32 nIndex
, PageType ePageType
)
287 if ( ePageType
!= meLatestPageType
)
294 mXDrawPages
= mXDrawPagesSupplier
->getDrawPages();
295 if( !mXDrawPages
.is() )
302 mXDrawPages
= mXMasterPagesSupplier
->getMasterPages();
303 if( !mXDrawPages
.is() )
310 meLatestPageType
= ePageType
;
312 Any
aAny( mXDrawPages
->getByIndex( nIndex
) );
314 if ( !mXDrawPage
.is() )
316 if ( ePageType
== NOTICE
)
318 Reference
< XPresentationPage
> aXPresentationPage( mXDrawPage
, UNO_QUERY
);
319 if ( !aXPresentationPage
.is() )
321 mXDrawPage
= aXPresentationPage
->getNotesPage();
322 if ( !mXDrawPage
.is() )
325 mXPagePropSet
= Reference
< XPropertySet
>( mXDrawPage
, UNO_QUERY
);
326 if ( !mXPagePropSet
.is() )
329 if (GetPropertyValue( aAny
, mXPagePropSet
, OUString("IsBackgroundDark") ) )
330 aAny
>>= mbIsBackgroundDark
;
332 mXShapes
= Reference
< XShapes
>( mXDrawPage
, UNO_QUERY
);
333 if ( !mXShapes
.is() )
336 /* try to get the "real" background PropertySet. If the normal page is not supporting this property, it is
337 taken the property from the master */
338 bool bHasBackground
= GetPropertyValue( aAny
, mXPagePropSet
, OUString( "Background" ), true );
339 if ( bHasBackground
)
340 bHasBackground
= ( aAny
>>= mXBackgroundPropSet
);
341 if ( !bHasBackground
)
343 Reference
< XMasterPageTarget
> aXMasterPageTarget( mXDrawPage
, UNO_QUERY
);
344 if ( aXMasterPageTarget
.is() )
346 Reference
< XDrawPage
> aXMasterDrawPage
;
347 aXMasterDrawPage
= aXMasterPageTarget
->getMasterPage();
348 if ( aXMasterDrawPage
.is() )
350 Reference
< XPropertySet
> aXMasterPagePropSet
;
351 aXMasterPagePropSet
= Reference
< XPropertySet
>
352 ( aXMasterDrawPage
, UNO_QUERY
);
353 if ( aXMasterPagePropSet
.is() )
355 bool bBackground
= GetPropertyValue( aAny
, aXMasterPagePropSet
, OUString( "Background" ) );
358 aAny
>>= mXBackgroundPropSet
;
369 bool PPTWriterBase::CreateSlide( sal_uInt32 nPageNum
)
373 if ( !GetPageByIndex( nPageNum
, NORMAL
) )
376 sal_uInt32 nMasterNum
= GetMasterIndex( NORMAL
);
377 SetCurrentStyleSheet( nMasterNum
);
379 Reference
< XPropertySet
> aXBackgroundPropSet
;
380 bool bHasBackground
= GetPropertyValue( aAny
, mXPagePropSet
, OUString( "Background" ) );
381 if ( bHasBackground
)
382 bHasBackground
= ( aAny
>>= aXBackgroundPropSet
);
384 sal_uInt16 nMode
= 7; // Bit 1: Follow master objects, Bit 2: Follow master scheme, Bit 3: Follow master background
385 if ( bHasBackground
)
388 /* sj: Don't know what's IsBackgroundVisible for, have to ask cl
389 if ( GetPropertyValue( aAny, mXPagePropSet, OUString( "IsBackgroundVisible" ) ) )
391 bool bBackgroundVisible;
392 if ( aAny >>= bBackgroundVisible )
394 if ( bBackgroundVisible )
399 if ( GetPropertyValue( aAny
, mXPagePropSet
, OUString( "IsBackgroundObjectsVisible" ) ) )
401 bool bBackgroundObjectsVisible
= false;
402 if ( aAny
>>= bBackgroundObjectsVisible
)
404 if ( !bBackgroundObjectsVisible
)
409 ImplWriteSlide( nPageNum
, nMasterNum
, nMode
, bHasBackground
, aXBackgroundPropSet
);
414 bool PPTWriterBase::CreateNotes( sal_uInt32 nPageNum
)
416 if ( !GetPageByIndex( nPageNum
, NOTICE
) )
418 SetCurrentStyleSheet( GetMasterIndex( NORMAL
) );
420 ImplWriteNotes( nPageNum
);
425 bool PPTWriterBase::CreateSlideMaster( sal_uInt32 nPageNum
)
427 if ( !GetPageByIndex( nPageNum
, MASTER
) )
429 SetCurrentStyleSheet( nPageNum
);
431 if ( !ImplGetPropertyValue( mXPagePropSet
, OUString( "Background" ) ) ) // load background shape
433 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> aXBackgroundPropSet
;
434 if ( !( mAny
>>= aXBackgroundPropSet
) )
437 ImplWriteSlideMaster( nPageNum
, aXBackgroundPropSet
);
442 sal_Int32
PPTWriterBase::GetLayoutOffset( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& rXPropSet
)
444 ::com::sun::star::uno::Any aAny
;
445 sal_Int32 nLayout
= 20;
446 if ( GetPropertyValue( aAny
, rXPropSet
, OUString( "Layout" ), true ) )
449 DBG(printf("GetLayoutOffset %" SAL_PRIdINT32
"\n", nLayout
));
454 sal_Int32
PPTWriterBase::GetLayoutOffsetFixed( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& rXPropSet
)
456 sal_Int32 nLayout
= GetLayoutOffset( rXPropSet
);
458 if ( ( nLayout
>= 21 ) && ( nLayout
<= 26 ) ) // NOTES _> HANDOUT6
460 if ( ( nLayout
>= 27 ) && ( nLayout
<= 30 ) ) // VERTICAL LAYOUT
462 else if ( nLayout
> 30 )
468 PHLayout
& PPTWriterBase::GetLayout( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& rXPropSet
)
470 return pPHLayout
[ GetLayoutOffsetFixed( rXPropSet
) ];
473 PHLayout
& PPTWriterBase::GetLayout( sal_Int32 nOffset
)
475 if( nOffset
>= 0 && nOffset
< EPP_LAYOUT_SIZE
)
476 return pPHLayout
[ nOffset
];
478 DBG(printf("asked %" SAL_PRIdINT32
" for layout outside of 0,%d array scope\n", nOffset
, EPP_LAYOUT_SIZE
));
480 return pPHLayout
[ 0 ];
483 sal_uInt32
PPTWriterBase::GetMasterIndex( PageType ePageType
)
485 sal_uInt32 nRetValue
= 0;
486 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XMasterPageTarget
>
487 aXMasterPageTarget( mXDrawPage
, ::com::sun::star::uno::UNO_QUERY
);
489 if ( aXMasterPageTarget
.is() )
491 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>
492 aXDrawPage
= aXMasterPageTarget
->getMasterPage();
493 if ( aXDrawPage
.is() )
495 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
496 aXPropertySet( aXDrawPage
, ::com::sun::star::uno::UNO_QUERY
);
498 if ( aXPropertySet
.is() )
500 if ( ImplGetPropertyValue( aXPropertySet
, OUString( "Number" ) ) )
501 nRetValue
|= *static_cast<sal_Int16
const *>(mAny
.getValue());
502 if ( nRetValue
& 0xffff ) // avoid overflow
507 if ( ePageType
== NOTICE
)
508 nRetValue
+= mnMasterPages
;
512 bool PPTWriterBase::SetCurrentStyleSheet( sal_uInt32 nPageNum
)
515 if ( nPageNum
>= maStyleSheetList
.size() )
519 mpStyleSheet
= maStyleSheetList
[ nPageNum
];
523 bool PPTWriterBase::GetStyleSheets()
525 int nInstance
, nLevel
;
526 bool bRetValue
= false;
529 for ( nPageNum
= 0; nPageNum
< mnMasterPages
; nPageNum
++ )
534 Reference
< XNameAccess
>
537 Reference
< XStyleFamiliesSupplier
>
538 aXStyleFamiliesSupplier( mXModel
, UNO_QUERY
);
540 Reference
< XPropertySet
>
541 aXPropSet( mXModel
, UNO_QUERY
);
543 sal_uInt16 nDefaultTab
= ( aXPropSet
.is() && ImplGetPropertyValue( aXPropSet
, OUString( "TabStop" ) ) )
544 ? (sal_uInt16
)( *static_cast<sal_Int32
const *>(mAny
.getValue()) / 4.40972 )
547 maStyleSheetList
.push_back( new PPTExStyleSheet( nDefaultTab
, dynamic_cast<PPTExBulletProvider
*>(this) ) );
548 SetCurrentStyleSheet( nPageNum
);
549 if ( GetPageByIndex( nPageNum
, MASTER
) )
550 aXNamed
= Reference
< XNamed
>
551 ( mXDrawPage
, UNO_QUERY
);
553 if ( aXStyleFamiliesSupplier
.is() )
554 aXNameAccess
= aXStyleFamiliesSupplier
->getStyleFamilies();
556 bRetValue
= aXNamed
.is() && aXNameAccess
.is() && aXStyleFamiliesSupplier
.is();
559 for ( nInstance
= EPP_TEXTTYPE_Title
; nInstance
<= EPP_TEXTTYPE_CenterTitle
; nInstance
++ )
565 case EPP_TEXTTYPE_CenterTitle
:
566 case EPP_TEXTTYPE_Title
:
569 aFamily
= aXNamed
->getName();
572 case EPP_TEXTTYPE_Body
:
574 aStyle
= "outline1"; // SD_LT_SEPARATOR
575 aFamily
= aXNamed
->getName();
578 case EPP_TEXTTYPE_Other
:
581 aFamily
= "graphics";
584 case EPP_TEXTTYPE_CenterBody
:
587 aFamily
= aXNamed
->getName();
591 if ( !aStyle
.isEmpty() && !aFamily
.isEmpty() )
595 Reference
< XNameAccess
>xNameAccess
;
596 if ( aXNameAccess
->hasByName( aFamily
) )
598 Any
aAny( aXNameAccess
->getByName( aFamily
) );
599 xNameAccess
.set(aAny
, css::uno::UNO_QUERY
);
600 if( xNameAccess
.is() )
602 Reference
< XNameAccess
> aXFamily
;
603 if ( aAny
>>= aXFamily
)
605 if ( aXFamily
->hasByName( aStyle
) )
607 aAny
= aXFamily
->getByName( aStyle
);
608 Reference
< XStyle
> xStyle(
609 aAny
, css::uno::UNO_QUERY
);
612 Reference
< XStyle
> aXStyle
;
614 Reference
< XPropertySet
>
615 xPropSet( aXStyle
, UNO_QUERY
);
617 mpStyleSheet
->SetStyleSheet( xPropSet
, maFontCollection
, nInstance
, 0 );
618 for ( nLevel
= 1; nLevel
< 5; nLevel
++ )
620 if ( nInstance
== EPP_TEXTTYPE_Body
)
622 sal_Unicode cTemp
= aStyle
[aStyle
.getLength() - 1];
623 aStyle
= aStyle
.copy(0, aStyle
.getLength() - 1) + OUString(++cTemp
);
624 if ( aXFamily
->hasByName( aStyle
) )
626 aXFamily
->getByName( aStyle
) >>= xStyle
;
629 Reference
< XPropertySet
>
630 xPropertySet( xStyle
, UNO_QUERY
);
631 if ( xPropertySet
.is() )
632 mpStyleSheet
->SetStyleSheet( xPropertySet
, maFontCollection
, nInstance
, nLevel
);
637 mpStyleSheet
->SetStyleSheet( xPropSet
, maFontCollection
, nInstance
, nLevel
);
651 for ( ; nInstance
<= EPP_TEXTTYPE_QuarterBody
; nInstance
++ )
660 bool PPTWriterBase::CreateMainNotes()
662 if ( !GetPageByIndex( 0, NOTICE
) )
664 SetCurrentStyleSheet( 0 );
666 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XMasterPageTarget
>
667 aXMasterPageTarget( mXDrawPage
, ::com::sun::star::uno::UNO_QUERY
);
669 if ( !aXMasterPageTarget
.is() )
672 mXDrawPage
= aXMasterPageTarget
->getMasterPage();
673 if ( !mXDrawPage
.is() )
676 mXPropSet
= ::com::sun::star::uno::Reference
<
677 ::com::sun::star::beans::XPropertySet
>
678 ( mXDrawPage
, ::com::sun::star::uno::UNO_QUERY
);
679 if ( !mXPropSet
.is() )
682 mXShapes
= ::com::sun::star::uno::Reference
<
683 ::com::sun::star::drawing::XShapes
>
684 ( mXDrawPage
, ::com::sun::star::uno::UNO_QUERY
);
685 if ( !mXShapes
.is() )
688 return ImplCreateMainNotes();
691 awt::Size
PPTWriterBase::MapSize( const awt::Size
& rSize
)
693 Size
aRetSize( OutputDevice::LogicToLogic( Size( rSize
.Width
, rSize
.Height
), maMapModeSrc
, maMapModeDest
) );
695 if ( !aRetSize
.Width() )
697 if ( !aRetSize
.Height() )
699 return awt::Size( aRetSize
.Width(), aRetSize
.Height() );
702 awt::Point
PPTWriterBase::MapPoint( const awt::Point
& rPoint
)
704 Point
aRet( OutputDevice::LogicToLogic( Point( rPoint
.X
, rPoint
.Y
), maMapModeSrc
, maMapModeDest
) );
705 return awt::Point( aRet
.X(), aRet
.Y() );
708 Rectangle
PPTWriterBase::MapRectangle( const awt::Rectangle
& rRect
)
710 ::com::sun::star::awt::Point
aPoint( rRect
.X
, rRect
.Y
);
711 ::com::sun::star::awt::Size
aSize( rRect
.Width
, rRect
.Height
);
712 ::com::sun::star::awt::Point
aP( MapPoint( aPoint
) );
713 ::com::sun::star::awt::Size
aS( MapSize( aSize
) );
714 return Rectangle( Point( aP
.X
, aP
.Y
), Size( aS
.Width
, aS
.Height
) );
717 bool PPTWriterBase::GetShapeByIndex( sal_uInt32 nIndex
, bool bGroup
)
721 if ( !bGroup
|| ( GetCurrentGroupLevel() == 0 ) )
723 Any
aAny( mXShapes
->getByIndex( nIndex
) );
728 Any
aAny( GetCurrentGroupAccess()->getByIndex( GetCurrentGroupIndex() ) );
734 Any
aAny( mXShape
->queryInterface( cppu::UnoType
<XPropertySet
>::get()));
737 if ( !mXPropSet
.is() )
739 maPosition
= MapPoint( mXShape
->getPosition() );
740 maSize
= MapSize( mXShape
->getSize() );
741 maRect
= Rectangle( Point( maPosition
.X
, maPosition
.Y
), Size( maSize
.Width
, maSize
.Height
) );
743 OStringBuffer
aTypeBuffer(OUStringToOString(
744 mXShape
->getShapeType(), RTL_TEXTENCODING_UTF8
));
745 // remove "com.sun.star."
746 aTypeBuffer
.remove(0, RTL_CONSTASCII_LENGTH("com.sun.star."));
748 sal_Int32 nPos
= aTypeBuffer
.toString().indexOf("Shape");
749 aTypeBuffer
.remove(nPos
, RTL_CONSTASCII_LENGTH("Shape"));
750 mType
= aTypeBuffer
.makeStringAndClear();
752 mbPresObj
= mbEmptyPresObj
= false;
753 if ( ImplGetPropertyValue( OUString( "IsPresentationObject" ) ) )
756 if ( mbPresObj
&& ImplGetPropertyValue( OUString( "IsEmptyPresentationObject" ) ) )
757 mAny
>>= mbEmptyPresObj
;
759 mnAngle
= ( PropValue::GetPropertyValue( aAny
,
760 mXPropSet
, OUString( "RotateAngle" ), true ) )
761 ? *static_cast<sal_Int32
const *>(aAny
.getValue())
769 sal_Int8
PPTWriterBase::GetTransition( sal_Int16 nTransitionType
, sal_Int16 nTransitionSubtype
, FadeEffect eEffect
, sal_uInt8
& nDirection
)
771 sal_Int8 nPPTTransitionType
= 0;
774 switch( nTransitionType
)
776 case TransitionType::FADE
:
778 if ( nTransitionSubtype
== TransitionSubType::CROSSFADE
)
779 nPPTTransitionType
= PPT_TRANSITION_TYPE_SMOOTHFADE
;
780 else if ( nTransitionSubtype
== TransitionSubType::FADEOVERCOLOR
)
781 nPPTTransitionType
= PPT_TRANSITION_TYPE_FADE
;
784 case PPT_TRANSITION_TYPE_COMB
:
786 nPPTTransitionType
= PPT_TRANSITION_TYPE_COMB
;
787 if ( nTransitionSubtype
== TransitionSubType::COMBVERTICAL
)
791 case TransitionType::PUSHWIPE
:
793 nPPTTransitionType
= PPT_TRANSITION_TYPE_PUSH
;
794 switch( nTransitionSubtype
)
796 case TransitionSubType::FROMRIGHT
: nDirection
= 0; break;
797 case TransitionSubType::FROMBOTTOM
: nDirection
= 1; break;
798 case TransitionSubType::FROMLEFT
: nDirection
= 2; break;
799 case TransitionSubType::FROMTOP
: nDirection
= 3; break;
803 case TransitionType::PINWHEELWIPE
:
805 nPPTTransitionType
= PPT_TRANSITION_TYPE_WHEEL
;
806 switch( nTransitionSubtype
)
808 case TransitionSubType::ONEBLADE
: nDirection
= 1; break;
809 case TransitionSubType::TWOBLADEVERTICAL
: nDirection
= 2; break;
810 case TransitionSubType::THREEBLADE
: nDirection
= 3; break;
811 case TransitionSubType::FOURBLADE
: nDirection
= 4; break;
812 case TransitionSubType::EIGHTBLADE
: nDirection
= 8; break;
816 case TransitionType::FANWIPE
:
818 nPPTTransitionType
= PPT_TRANSITION_TYPE_WEDGE
;
821 case TransitionType::ELLIPSEWIPE
:
823 nPPTTransitionType
= PPT_TRANSITION_TYPE_CIRCLE
;
826 case TransitionType::FOURBOXWIPE
:
828 nPPTTransitionType
= PPT_TRANSITION_TYPE_PLUS
;
831 case TransitionType::IRISWIPE
:
833 switch( nTransitionSubtype
) {
834 case TransitionSubType::RECTANGLE
:
835 nPPTTransitionType
= PPT_TRANSITION_TYPE_ZOOM
;
836 nDirection
= (eEffect
== FadeEffect_FADE_FROM_CENTER
) ? 0 : 1;
839 nPPTTransitionType
= PPT_TRANSITION_TYPE_DIAMOND
;
846 return nPPTTransitionType
;
849 sal_Int8
PPTWriterBase::GetTransition( FadeEffect eEffect
, sal_uInt8
& nDirection
)
851 sal_Int8 nPPTTransitionType
= 0;
856 case FadeEffect_RANDOM
:
857 nPPTTransitionType
= PPT_TRANSITION_TYPE_RANDOM
;
860 case FadeEffect_HORIZONTAL_STRIPES
:
862 case FadeEffect_VERTICAL_STRIPES
:
863 nPPTTransitionType
= PPT_TRANSITION_TYPE_BLINDS
;
866 case FadeEffect_VERTICAL_CHECKERBOARD
:
868 case FadeEffect_HORIZONTAL_CHECKERBOARD
:
869 nPPTTransitionType
= PPT_TRANSITION_TYPE_CHECKER
;
872 case FadeEffect_MOVE_FROM_UPPERLEFT
:
874 case FadeEffect_MOVE_FROM_UPPERRIGHT
:
876 case FadeEffect_MOVE_FROM_LOWERLEFT
:
878 case FadeEffect_MOVE_FROM_LOWERRIGHT
:
880 case FadeEffect_MOVE_FROM_TOP
:
882 case FadeEffect_MOVE_FROM_LEFT
:
884 case FadeEffect_MOVE_FROM_BOTTOM
:
886 case FadeEffect_MOVE_FROM_RIGHT
:
887 nPPTTransitionType
= PPT_TRANSITION_TYPE_COVER
;
890 case FadeEffect_DISSOLVE
:
891 nPPTTransitionType
= PPT_TRANSITION_TYPE_DISSOLVE
;
894 case FadeEffect_VERTICAL_LINES
:
896 case FadeEffect_HORIZONTAL_LINES
:
897 nPPTTransitionType
= PPT_TRANSITION_TYPE_RANDOM_BARS
;
900 case FadeEffect_CLOSE_HORIZONTAL
:
902 case FadeEffect_OPEN_HORIZONTAL
:
904 case FadeEffect_CLOSE_VERTICAL
:
906 case FadeEffect_OPEN_VERTICAL
:
907 nPPTTransitionType
= PPT_TRANSITION_TYPE_SPLIT
;
910 case FadeEffect_FADE_FROM_UPPERLEFT
:
912 case FadeEffect_FADE_FROM_UPPERRIGHT
:
914 case FadeEffect_FADE_FROM_LOWERLEFT
:
916 case FadeEffect_FADE_FROM_LOWERRIGHT
:
918 nPPTTransitionType
= PPT_TRANSITION_TYPE_STRIPS
;
921 case FadeEffect_UNCOVER_TO_LOWERRIGHT
:
923 case FadeEffect_UNCOVER_TO_LOWERLEFT
:
925 case FadeEffect_UNCOVER_TO_UPPERRIGHT
:
927 case FadeEffect_UNCOVER_TO_UPPERLEFT
:
929 case FadeEffect_UNCOVER_TO_BOTTOM
:
931 case FadeEffect_UNCOVER_TO_RIGHT
:
933 case FadeEffect_UNCOVER_TO_TOP
:
935 case FadeEffect_UNCOVER_TO_LEFT
:
936 nPPTTransitionType
= PPT_TRANSITION_TYPE_PULL
;
939 case FadeEffect_FADE_FROM_TOP
:
941 case FadeEffect_FADE_FROM_LEFT
:
943 case FadeEffect_FADE_FROM_BOTTOM
:
945 case FadeEffect_FADE_FROM_RIGHT
:
946 nPPTTransitionType
= PPT_TRANSITION_TYPE_WIPE
;
949 case FadeEffect_ROLL_FROM_TOP
:
951 case FadeEffect_ROLL_FROM_LEFT
:
953 case FadeEffect_ROLL_FROM_BOTTOM
:
955 case FadeEffect_ROLL_FROM_RIGHT
:
956 nPPTTransitionType
= PPT_TRANSITION_TYPE_WIPE
;
959 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( bool bForOOMLX
)
975 sal_uInt32 nShapes
= mXShapes
->getCount();
976 bool bOtherThanPlaceHolders
= false;
979 for ( sal_uInt32 nIndex
= 0; ( nIndex
< nShapes
) && !bOtherThanPlaceHolders
; nIndex
++ )
981 if ( GetShapeByIndex( nIndex
) && mType
!= "drawing.Page" )
984 ( mType
== "presentation.Page" ||
985 mType
== "presentation.Notes" ) ) {
986 Reference
< XSimpleText
> rXText( mXShape
, UNO_QUERY
);
988 if( rXText
.is() && !rXText
->getString().isEmpty() )
989 bOtherThanPlaceHolders
= true;
992 bOtherThanPlaceHolders
= true;
994 DBG(printf("mType == %s\n", mType
.getStr()));
997 return bOtherThanPlaceHolders
;
1000 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */