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 .
22 #include "epptdef.hxx"
24 #include <comphelper/extract.hxx>
25 #include <tools/globname.hxx>
26 #include <tools/datetime.hxx>
27 #include <tools/poly.hxx>
28 #include <tools/stream.hxx>
29 #include <vcl/graph.hxx>
30 #include <vcl/bmpacc.hxx>
31 #include <vcl/gradient.hxx>
32 #include <vcl/virdev.hxx>
33 #include <rtl/ustring.hxx>
34 #include <rtl/strbuf.hxx>
35 #include <vcl/fltcall.hxx>
36 #include <vcl/wmf.hxx>
37 #include <sfx2/docfile.hxx>
38 #include <sfx2/docinf.hxx>
39 #include <svx/unoapi.hxx>
40 #include <svx/svdobj.hxx>
41 #include <svx/svdoole2.hxx>
42 #include <svx/svdmodel.hxx>
43 #include <svx/svdpage.hxx>
44 #include <com/sun/star/view/PaperOrientation.hpp>
45 #include <com/sun/star/view/PaperFormat.hpp>
46 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
47 #include <com/sun/star/office/XAnnotation.hpp>
48 #include <com/sun/star/office/XAnnotationAccess.hpp>
49 #include <com/sun/star/office/XAnnotationEnumeration.hpp>
50 #include <com/sun/star/geometry/RealPoint2D.hpp>
51 #include <com/sun/star/util/DateTime.hpp>
52 #include <com/sun/star/animations/TransitionType.hpp>
53 #include <com/sun/star/animations/TransitionSubType.hpp>
54 #include <com/sun/star/awt/FontDescriptor.hpp>
55 #include <com/sun/star/awt/FontFamily.hpp>
56 #include <com/sun/star/awt/FontPitch.hpp>
57 #include <com/sun/star/container/XNamed.hpp>
58 #include <com/sun/star/container/XNameAccess.hpp>
59 #include <com/sun/star/presentation/XPresentationPage.hpp>
60 #include <com/sun/star/text/XSimpleText.hpp>
61 #include <com/sun/star/style/XStyle.hpp>
62 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
63 #include <editeng/svxenum.hxx>
64 #include <editeng/flditem.hxx>
65 #include <sot/storinfo.hxx>
66 #include <filter/msfilter/msoleexp.hxx>
67 #include <filter/msfilter/msdffimp.hxx>
68 #include <filter/msfilter/svxmsbas.hxx>
77 using namespace com::sun::star
;
79 using namespace ::com::sun::star::animations
;
80 using namespace ::com::sun::star::awt::FontFamily
;
81 using namespace ::com::sun::star::awt::FontPitch
;
82 using namespace ::com::sun::star::presentation
;
84 using ::com::sun::star::awt::FontDescriptor
;
85 using ::com::sun::star::beans::XPropertySet
;
86 using ::com::sun::star::container::XNameAccess
;
87 using ::com::sun::star::container::XNamed
;
88 using ::com::sun::star::drawing::XDrawPagesSupplier
;
89 using ::com::sun::star::drawing::XMasterPagesSupplier
;
90 using ::com::sun::star::drawing::XShapes
;
91 using ::com::sun::star::drawing::XMasterPageTarget
;
92 using ::com::sun::star::drawing::XDrawPage
;
93 using ::com::sun::star::frame::XModel
;
94 using ::com::sun::star::style::XStyleFamiliesSupplier
;
95 using ::com::sun::star::style::XStyle
;
96 using ::com::sun::star::task::XStatusIndicator
;
97 using ::com::sun::star::text::XSimpleText
;
98 using ::com::sun::star::uno::Any
;
99 using ::com::sun::star::uno::Exception
;
100 using ::com::sun::star::uno::Reference
;
101 using ::com::sun::star::uno::UNO_QUERY
;
103 static PHLayout pPHLayout
[] =
105 { EPP_LAYOUT_TITLESLIDE
, { 0x0d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x10, sal_True
, sal_True
, sal_False
},
106 { EPP_LAYOUT_TITLEANDBODYSLIDE
, { 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, sal_True
, sal_True
, sal_False
},
107 { EPP_LAYOUT_TITLEANDBODYSLIDE
, { 0x0d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, sal_True
, sal_True
, sal_False
},
108 { EPP_LAYOUT_2COLUMNSANDTITLE
, { 0x0d, 0x0e, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, sal_True
, sal_True
, sal_True
},
109 { EPP_LAYOUT_2COLUMNSANDTITLE
, { 0x0d, 0x0e, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, sal_True
, sal_True
, sal_False
},
110 { EPP_LAYOUT_BLANCSLIDE
, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, sal_False
, sal_False
, sal_False
},
111 { EPP_LAYOUT_2COLUMNSANDTITLE
, { 0x0d, 0x0e, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, sal_True
, sal_True
, sal_False
},
112 { EPP_LAYOUT_2COLUMNSANDTITLE
, { 0x0d, 0x14, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x0d, 0x0e, sal_True
, sal_True
, sal_False
},
113 { EPP_LAYOUT_TITLEANDBODYSLIDE
, { 0x0d, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x15, 0x0d, 0x0e, sal_True
, sal_False
, sal_False
},
114 { EPP_LAYOUT_2COLUMNSANDTITLE
, { 0x0d, 0x16, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x0e, sal_True
, sal_True
, sal_False
},
115 { EPP_LAYOUT_2COLUMNSANDTITLE
, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, sal_True
, sal_True
, sal_False
},
116 { EPP_LAYOUT_TITLEANDBODYSLIDE
, { 0x0d, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, sal_True
, sal_False
, sal_False
},
117 { EPP_LAYOUT_RIGHTCOLUMN2ROWS
, { 0x0d, 0x0e, 0x13, 0x13, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, sal_True
, sal_True
, sal_False
},
118 { EPP_LAYOUT_2COLUMNSANDTITLE
, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, sal_True
, sal_True
, sal_False
},
119 { EPP_LAYOUT_2ROWSANDTITLE
, { 0x0d, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, sal_True
, sal_True
, sal_False
},
120 { EPP_LAYOUT_LEFTCOLUMN2ROWS
, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, sal_True
, sal_True
, sal_False
},
121 { EPP_LAYOUT_TOPROW2COLUMN
, { 0x0d, 0x13, 0x13, 0x0e, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, sal_True
, sal_True
, sal_False
},
122 { EPP_LAYOUT_2ROWSANDTITLE
, { 0x0d, 0x0e, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, sal_True
, sal_True
, sal_False
},
123 { EPP_LAYOUT_4OBJECTS
, { 0x0d, 0x13, 0x13, 0x13, 0x13, 0x00, 0x00, 0x00 }, 0x13, 0x0d, 0x0e, sal_True
, sal_False
, sal_False
},
124 { EPP_LAYOUT_ONLYTITLE
, { 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, sal_True
, sal_False
, sal_False
},
125 { EPP_LAYOUT_BLANCSLIDE
, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x0e, sal_False
, sal_False
, sal_False
},
126 { EPP_LAYOUT_TITLERIGHT2BODIESLEFT
, { 0x11, 0x12, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x14, 0x11, 0x12, sal_True
, sal_True
, sal_False
},
127 { EPP_LAYOUT_TITLERIGHTBODYLEFT
, { 0x11, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x11, 0x12, sal_True
, sal_True
, sal_False
},
128 { EPP_LAYOUT_TITLEANDBODYSLIDE
, { 0x0d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x00, 0x0d, 0x12, sal_True
, sal_True
, sal_False
},
129 { EPP_LAYOUT_2COLUMNSANDTITLE
, { 0x0d, 0x16, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x12, sal_True
, sal_True
, sal_False
}
132 #define PPT_WRITER_BASE_INIT_VALUES \
133 maFraction ( 1, 576 ), \
134 maMapModeSrc ( MAP_100TH_MM ), \
135 maMapModeDest ( MAP_INCH, Point(), maFraction, maFraction ), \
136 meLatestPageType ( NORMAL )
138 PPTWriterBase::PPTWriterBase() :
139 PPT_WRITER_BASE_INIT_VALUES
141 DBG(printf ("PPTWriterBase::PPTWriterBase()\n"));
144 PPTWriterBase::PPTWriterBase( const Reference
< XModel
> & rXModel
,
145 const Reference
< XStatusIndicator
> & rXStatInd
) :
147 mXStatusIndicator ( rXStatInd
),
148 mbStatusIndicator ( false ),
149 PPT_WRITER_BASE_INIT_VALUES
153 // ---------------------------------------------------------------------------------------------
155 PPTWriterBase::~PPTWriterBase()
157 // Possibly unnecessary sanity check for mXStatusIndicator.is().
158 // In 3.3 we had a bug report of a crash where it was null,
159 // https://bugzilla.novell.com/show_bug.cgi?id=694119 (non-public,
160 // bug report, sorry).
161 if ( mbStatusIndicator
&& mXStatusIndicator
.is() )
162 mXStatusIndicator
->end();
165 // ---------------------------------------------------------------------------------------------
167 void PPTWriterBase::exportPPT( const std::vector
< com::sun::star::beans::PropertyValue
>& rMediaData
)
169 if ( !InitSOIface() )
172 FontCollectionEntry
aDefaultFontDesc( OUString( "Times New Roman" ),
174 awt::FontPitch::VARIABLE
,
175 RTL_TEXTENCODING_MS_1252
);
176 maFontCollection
.GetId( aDefaultFontDesc
); // default is always times new roman
178 if ( !GetPageByIndex( 0, NOTICE
) )
181 sal_Int32 nWidth
= 21000;
182 if ( ImplGetPropertyValue( mXPagePropSet
, OUString( "Width" ) ) )
184 sal_Int32 nHeight
= 29700;
185 if ( ImplGetPropertyValue( mXPagePropSet
, OUString( "Height" ) ) )
188 maNotesPageSize
= MapSize( awt::Size( nWidth
, nHeight
) );
190 if ( !GetPageByIndex( 0, MASTER
) )
194 if ( ImplGetPropertyValue( mXPagePropSet
, OUString( "Width" ) ) )
197 if ( ImplGetPropertyValue( mXPagePropSet
, OUString( "Height" ) ) )
199 maDestPageSize
= MapSize( awt::Size( nWidth
, nHeight
) );
201 DBG(printf( "call exportDocumentPre()\n"));
202 exportPPTPre(rMediaData
);
204 if ( !GetStyleSheets() )
207 if ( !ImplCreateDocument() )
212 for ( i
= 0; i
< mnPages
; i
++ )
214 if ( GetPageByIndex( i
, NORMAL
) ) {
215 sal_uInt32 nMasterNum
= GetMasterIndex( NORMAL
);
216 ImplWriteLayout( GetLayoutOffset( mXPagePropSet
), nMasterNum
);
220 for ( i
= 0; i
< mnMasterPages
; i
++ )
222 if ( !CreateSlideMaster( i
) )
225 if ( !CreateMainNotes() )
228 for ( i
= 0; i
< mnPages
; i
++ )
230 DBG(printf( "call ImplCreateSlide( %" SAL_PRIuUINT32
" )\n", i
));
231 if ( !CreateSlide( i
) )
235 for ( i
= 0; i
< mnPages
; i
++ )
237 if ( !CreateNotes( i
) )
241 DBG(printf( "call exportDocumentPost()\n"));
245 // ---------------------------------------------------------------------------------------------
247 sal_Bool
PPTWriterBase::InitSOIface()
251 mXDrawPagesSupplier
= Reference
< XDrawPagesSupplier
>( mXModel
, UNO_QUERY
);
252 if ( !mXDrawPagesSupplier
.is() )
255 mXMasterPagesSupplier
= Reference
< XMasterPagesSupplier
>( mXModel
, UNO_QUERY
);
256 if ( !mXMasterPagesSupplier
.is() )
258 mXDrawPages
= mXMasterPagesSupplier
->getMasterPages();
259 if ( !mXDrawPages
.is() )
261 mnMasterPages
= mXDrawPages
->getCount();
262 mXDrawPages
= mXDrawPagesSupplier
->getDrawPages();
263 if( !mXDrawPages
.is() )
265 mnPages
= mXDrawPages
->getCount();
266 if ( !GetPageByIndex( 0, NORMAL
) )
274 // ---------------------------------------------------------------------------------------------
276 sal_Bool
PPTWriterBase::GetPageByIndex( sal_uInt32 nIndex
, PageType ePageType
)
280 if ( ePageType
!= meLatestPageType
)
287 mXDrawPages
= mXDrawPagesSupplier
->getDrawPages();
288 if( !mXDrawPages
.is() )
295 mXDrawPages
= mXMasterPagesSupplier
->getMasterPages();
296 if( !mXDrawPages
.is() )
303 meLatestPageType
= ePageType
;
305 Any
aAny( mXDrawPages
->getByIndex( nIndex
) );
307 if ( !mXDrawPage
.is() )
309 if ( ePageType
== NOTICE
)
311 Reference
< XPresentationPage
> aXPresentationPage( mXDrawPage
, UNO_QUERY
);
312 if ( !aXPresentationPage
.is() )
314 mXDrawPage
= aXPresentationPage
->getNotesPage();
315 if ( !mXDrawPage
.is() )
318 mXPagePropSet
= Reference
< XPropertySet
>( mXDrawPage
, UNO_QUERY
);
319 if ( !mXPagePropSet
.is() )
322 mXShapes
= Reference
< XShapes
>( mXDrawPage
, UNO_QUERY
);
323 if ( !mXShapes
.is() )
326 /* try to get the "real" background PropertySet. If the normal page is not supporting this property, it is
327 taken the property from the master */
328 sal_Bool bHasBackground
= GetPropertyValue( aAny
, mXPagePropSet
, OUString( "Background" ), sal_True
);
329 if ( bHasBackground
)
330 bHasBackground
= ( aAny
>>= mXBackgroundPropSet
);
331 if ( !bHasBackground
)
333 Reference
< XMasterPageTarget
> aXMasterPageTarget( mXDrawPage
, UNO_QUERY
);
334 if ( aXMasterPageTarget
.is() )
336 Reference
< XDrawPage
> aXMasterDrawPage
;
337 aXMasterDrawPage
= aXMasterPageTarget
->getMasterPage();
338 if ( aXMasterDrawPage
.is() )
340 Reference
< XPropertySet
> aXMasterPagePropSet
;
341 aXMasterPagePropSet
= Reference
< XPropertySet
>
342 ( aXMasterDrawPage
, UNO_QUERY
);
343 if ( aXMasterPagePropSet
.is() )
345 sal_Bool bBackground
= GetPropertyValue( aAny
, aXMasterPagePropSet
, OUString( "Background" ) );
348 aAny
>>= mXBackgroundPropSet
;
359 // ---------------------------------------------------------------------------------------------
361 sal_Bool
PPTWriterBase::CreateSlide( sal_uInt32 nPageNum
)
365 if ( !GetPageByIndex( nPageNum
, NORMAL
) )
368 sal_uInt32 nMasterNum
= GetMasterIndex( NORMAL
);
369 SetCurrentStyleSheet( nMasterNum
);
371 Reference
< XPropertySet
> aXBackgroundPropSet
;
372 sal_Bool bHasBackground
= GetPropertyValue( aAny
, mXPagePropSet
, OUString( "Background" ) );
373 if ( bHasBackground
)
374 bHasBackground
= ( aAny
>>= aXBackgroundPropSet
);
376 sal_uInt16 nMode
= 7; // Bit 1: Follow master objects, Bit 2: Follow master scheme, Bit 3: Follow master background
377 if ( bHasBackground
)
380 /* sj: Don't know what's IsBackgroundVisible for, have to ask cl
381 if ( GetPropertyValue( aAny, mXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsBackgroundVisible" ) ) ) )
383 sal_Bool bBackgroundVisible;
384 if ( aAny >>= bBackgroundVisible )
386 if ( bBackgroundVisible )
391 if ( GetPropertyValue( aAny
, mXPagePropSet
, OUString( "IsBackgroundObjectsVisible" ) ) )
393 sal_Bool bBackgroundObjectsVisible
= sal_False
;
394 if ( aAny
>>= bBackgroundObjectsVisible
)
396 if ( !bBackgroundObjectsVisible
)
401 ImplWriteSlide( nPageNum
, nMasterNum
, nMode
, bHasBackground
, aXBackgroundPropSet
);
406 // ---------------------------------------------------------------------------------------------
408 sal_Bool
PPTWriterBase::CreateNotes( sal_uInt32 nPageNum
)
410 if ( !GetPageByIndex( nPageNum
, NOTICE
) )
412 SetCurrentStyleSheet( GetMasterIndex( NORMAL
) );
414 ImplWriteNotes( nPageNum
);
419 // ---------------------------------------------------------------------------------------------
421 sal_Bool
PPTWriterBase::CreateSlideMaster( sal_uInt32 nPageNum
)
423 if ( !GetPageByIndex( nPageNum
, MASTER
) )
425 SetCurrentStyleSheet( nPageNum
);
427 if ( !ImplGetPropertyValue( mXPagePropSet
, OUString( "Background" ) ) ) // load background shape
429 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> aXBackgroundPropSet
;
430 if ( !( mAny
>>= aXBackgroundPropSet
) )
433 ImplWriteSlideMaster( nPageNum
, aXBackgroundPropSet
);
438 // ---------------------------------------------------------------------------------------------
440 sal_Int32
PPTWriterBase::GetLayoutOffset( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& rXPropSet
) const
442 ::com::sun::star::uno::Any aAny
;
443 sal_Int32 nLayout
= 20;
444 if ( GetPropertyValue( aAny
, rXPropSet
, OUString( "Layout" ) ), sal_True
)
447 DBG(printf("GetLayoutOffset %" SAL_PRIdINT32
"\n", nLayout
));
452 sal_Int32
PPTWriterBase::GetLayoutOffsetFixed( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& rXPropSet
) const
454 sal_Int32 nLayout
= GetLayoutOffset( rXPropSet
);
456 if ( ( nLayout
>= 21 ) && ( nLayout
<= 26 ) ) // NOTES _> HANDOUT6
458 if ( ( nLayout
>= 27 ) && ( nLayout
<= 30 ) ) // VERTICAL LAYOUT
460 else if ( nLayout
> 30 )
466 PHLayout
& PPTWriterBase::GetLayout( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& rXPropSet
) const
468 return pPHLayout
[ GetLayoutOffsetFixed( rXPropSet
) ];
471 // ---------------------------------------------------------------------------------------------
473 PHLayout
& PPTWriterBase::GetLayout( sal_Int32 nOffset
) const
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 // ---------------------------------------------------------------------------------------------
485 sal_uInt32
PPTWriterBase::GetMasterIndex( PageType ePageType
)
487 sal_uInt32 nRetValue
= 0;
488 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XMasterPageTarget
>
489 aXMasterPageTarget( mXDrawPage
, ::com::sun::star::uno::UNO_QUERY
);
491 if ( aXMasterPageTarget
.is() )
493 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>
494 aXDrawPage
= aXMasterPageTarget
->getMasterPage();
495 if ( aXDrawPage
.is() )
497 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
498 aXPropertySet( aXDrawPage
, ::com::sun::star::uno::UNO_QUERY
);
500 if ( aXPropertySet
.is() )
502 if ( ImplGetPropertyValue( aXPropertySet
, OUString( "Number" ) ) )
503 nRetValue
|= *(sal_Int16
*)mAny
.getValue();
504 if ( nRetValue
& 0xffff ) // avoid overflow
509 if ( ePageType
== NOTICE
)
510 nRetValue
+= mnMasterPages
;
514 // -----------------------------------------------------------------------
516 sal_Bool
PPTWriterBase::SetCurrentStyleSheet( sal_uInt32 nPageNum
)
518 sal_Bool bRet
= sal_False
;
519 if ( nPageNum
>= maStyleSheetList
.size() )
523 mpStyleSheet
= maStyleSheetList
[ nPageNum
];
527 // ---------------------------------------------------------------------------------------------
529 sal_Bool
PPTWriterBase::GetStyleSheets()
531 int nInstance
, nLevel
;
532 sal_Bool bRetValue
= sal_False
;
535 for ( nPageNum
= 0; nPageNum
< mnMasterPages
; nPageNum
++ )
540 Reference
< XNameAccess
>
543 Reference
< XStyleFamiliesSupplier
>
544 aXStyleFamiliesSupplier( mXModel
, UNO_QUERY
);
546 Reference
< XPropertySet
>
547 aXPropSet( mXModel
, UNO_QUERY
);
549 sal_uInt16 nDefaultTab
= ( aXPropSet
.is() && ImplGetPropertyValue( aXPropSet
, OUString( "TabStop" ) ) )
550 ? (sal_uInt16
)( *(sal_Int32
*)mAny
.getValue() / 4.40972 )
553 maStyleSheetList
.push_back( new PPTExStyleSheet( nDefaultTab
, (PPTExBulletProvider
&)*this ) );
554 SetCurrentStyleSheet( nPageNum
);
555 if ( GetPageByIndex( nPageNum
, MASTER
) )
556 aXNamed
= Reference
< XNamed
>
557 ( mXDrawPage
, UNO_QUERY
);
559 if ( aXStyleFamiliesSupplier
.is() )
560 aXNameAccess
= aXStyleFamiliesSupplier
->getStyleFamilies();
562 bRetValue
= aXNamed
.is() && aXNameAccess
.is() && aXStyleFamiliesSupplier
.is();
565 for ( nInstance
= EPP_TEXTTYPE_Title
; nInstance
<= EPP_TEXTTYPE_CenterTitle
; nInstance
++ )
571 case EPP_TEXTTYPE_CenterTitle
:
572 case EPP_TEXTTYPE_Title
:
574 aStyle
= OUString( "title" );
575 aFamily
= aXNamed
->getName();
578 case EPP_TEXTTYPE_Body
:
580 aStyle
= OUString( "outline1" ); // SD_LT_SEPARATOR
581 aFamily
= aXNamed
->getName();
584 case EPP_TEXTTYPE_Other
:
586 aStyle
= OUString( "standard" );
587 aFamily
= OUString( "graphics" );
590 case EPP_TEXTTYPE_CenterBody
:
592 aStyle
= OUString( "subtitle" );
593 aFamily
= aXNamed
->getName();
597 if ( aStyle
.Len() && aFamily
.Len() )
601 Reference
< XNameAccess
>xNameAccess
;
602 if ( aXNameAccess
->hasByName( aFamily
) )
604 Any
aAny( aXNameAccess
->getByName( aFamily
) );
605 if( aAny
.getValue() && ::cppu::extractInterface( xNameAccess
, aAny
) )
607 Reference
< XNameAccess
> aXFamily
;
608 if ( aAny
>>= aXFamily
)
610 if ( aXFamily
->hasByName( aStyle
) )
612 Reference
< XStyle
> xStyle
;
613 aAny
= aXFamily
->getByName( aStyle
);
614 if( aAny
.getValue() && ::cppu::extractInterface( xStyle
, aAny
) )
616 Reference
< XStyle
> aXStyle
;
618 Reference
< XPropertySet
>
619 xPropSet( aXStyle
, UNO_QUERY
);
621 mpStyleSheet
->SetStyleSheet( xPropSet
, maFontCollection
, nInstance
, 0 );
622 for ( nLevel
= 1; nLevel
< 5; nLevel
++ )
624 if ( nInstance
== EPP_TEXTTYPE_Body
)
626 sal_Unicode cTemp
= aStyle
.GetChar( aStyle
.Len() - 1 );
627 aStyle
.SetChar( aStyle
.Len() - 1, ++cTemp
);
628 if ( aXFamily
->hasByName( aStyle
) )
630 aXFamily
->getByName( aStyle
) >>= xStyle
;
633 Reference
< XPropertySet
>
634 xPropertySet( xStyle
, UNO_QUERY
);
635 if ( xPropertySet
.is() )
636 mpStyleSheet
->SetStyleSheet( xPropertySet
, maFontCollection
, nInstance
, nLevel
);
641 mpStyleSheet
->SetStyleSheet( xPropSet
, maFontCollection
, nInstance
, nLevel
);
655 for ( ; nInstance
<= EPP_TEXTTYPE_QuarterBody
; nInstance
++ )
664 // -----------------------------------------------------------------------
666 sal_Bool
PPTWriterBase::CreateMainNotes()
668 if ( !GetPageByIndex( 0, NOTICE
) )
670 SetCurrentStyleSheet( 0 );
672 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XMasterPageTarget
>
673 aXMasterPageTarget( mXDrawPage
, ::com::sun::star::uno::UNO_QUERY
);
675 if ( !aXMasterPageTarget
.is() )
678 mXDrawPage
= aXMasterPageTarget
->getMasterPage();
679 if ( !mXDrawPage
.is() )
682 mXPropSet
= ::com::sun::star::uno::Reference
<
683 ::com::sun::star::beans::XPropertySet
>
684 ( mXDrawPage
, ::com::sun::star::uno::UNO_QUERY
);
685 if ( !mXPropSet
.is() )
688 mXShapes
= ::com::sun::star::uno::Reference
<
689 ::com::sun::star::drawing::XShapes
>
690 ( mXDrawPage
, ::com::sun::star::uno::UNO_QUERY
);
691 if ( !mXShapes
.is() )
694 return ImplCreateMainNotes();
697 // -----------------------------------------------------------------------
699 awt::Size
PPTWriterBase::MapSize( const awt::Size
& rSize
)
701 Size
aRetSize( OutputDevice::LogicToLogic( Size( rSize
.Width
, rSize
.Height
), maMapModeSrc
, maMapModeDest
) );
703 if ( !aRetSize
.Width() )
705 if ( !aRetSize
.Height() )
707 return awt::Size( aRetSize
.Width(), aRetSize
.Height() );
710 // -----------------------------------------------------------------------
712 awt::Point
PPTWriterBase::MapPoint( const awt::Point
& rPoint
)
714 Point
aRet( OutputDevice::LogicToLogic( Point( rPoint
.X
, rPoint
.Y
), maMapModeSrc
, maMapModeDest
) );
715 return awt::Point( aRet
.X(), aRet
.Y() );
718 // -----------------------------------------------------------------------
720 Rectangle
PPTWriterBase::MapRectangle( const awt::Rectangle
& rRect
)
722 ::com::sun::star::awt::Point
aPoint( rRect
.X
, rRect
.Y
);
723 ::com::sun::star::awt::Size
aSize( rRect
.Width
, rRect
.Height
);
724 ::com::sun::star::awt::Point
aP( MapPoint( aPoint
) );
725 ::com::sun::star::awt::Size
aS( MapSize( aSize
) );
726 return Rectangle( Point( aP
.X
, aP
.Y
), Size( aS
.Width
, aS
.Height
) );
729 // -----------------------------------------------------------------------
731 sal_Bool
PPTWriterBase::GetShapeByIndex( sal_uInt32 nIndex
, sal_Bool bGroup
)
735 if ( ( bGroup
== sal_False
) || ( GetCurrentGroupLevel() == 0 ) )
737 Any
aAny( mXShapes
->getByIndex( nIndex
) );
742 Any
aAny( GetCurrentGroupAccess()->getByIndex( GetCurrentGroupIndex() ) );
748 Any
aAny( mXShape
->queryInterface( ::getCppuType( (const Reference
< XPropertySet
>*) 0 ) ));
751 if ( !mXPropSet
.is() )
753 maPosition
= MapPoint( mXShape
->getPosition() );
754 maSize
= MapSize( mXShape
->getSize() );
755 maRect
= Rectangle( Point( maPosition
.X
, maPosition
.Y
), Size( maSize
.Width
, maSize
.Height
) );
757 OStringBuffer
aTypeBuffer(OUStringToOString(
758 mXShape
->getShapeType(), RTL_TEXTENCODING_UTF8
));
759 // remove "com.sun.star."
760 aTypeBuffer
.remove(0, RTL_CONSTASCII_LENGTH("com.sun.star."));
762 sal_Int32 nPos
= aTypeBuffer
.toString().indexOf("Shape");
763 aTypeBuffer
.remove(nPos
, RTL_CONSTASCII_LENGTH("Shape"));
764 mType
= aTypeBuffer
.makeStringAndClear();
766 mbPresObj
= mbEmptyPresObj
= sal_False
;
767 if ( ImplGetPropertyValue( OUString( "IsPresentationObject" ) ) )
770 if ( mbPresObj
&& ImplGetPropertyValue( OUString( "IsEmptyPresentationObject" ) ) )
771 mAny
>>= mbEmptyPresObj
;
773 mnAngle
= ( PropValue::GetPropertyValue( aAny
,
774 mXPropSet
, OUString( "RotateAngle" ), sal_True
) )
775 ? *((sal_Int32
*)aAny
.getValue() )
783 // -----------------------------------------------------------------------
785 sal_Int8
PPTWriterBase::GetTransition( sal_Int16 nTransitionType
, sal_Int16 nTransitionSubtype
, FadeEffect eEffect
, sal_uInt8
& nDirection
)
787 sal_Int8 nPPTTransitionType
= 0;
790 switch( nTransitionType
)
792 case TransitionType::FADE
:
794 if ( nTransitionSubtype
== TransitionSubType::CROSSFADE
)
795 nPPTTransitionType
= PPT_TRANSITION_TYPE_SMOOTHFADE
;
796 else if ( nTransitionSubtype
== TransitionSubType::FADEOVERCOLOR
)
797 nPPTTransitionType
= PPT_TRANSITION_TYPE_FADE
;
800 case PPT_TRANSITION_TYPE_COMB
:
802 nPPTTransitionType
= PPT_TRANSITION_TYPE_COMB
;
803 if ( nTransitionSubtype
== TransitionSubType::COMBVERTICAL
)
807 case TransitionType::PUSHWIPE
:
809 nPPTTransitionType
= PPT_TRANSITION_TYPE_PUSH
;
810 switch( nTransitionSubtype
)
812 case TransitionSubType::FROMRIGHT
: nDirection
= 0; break;
813 case TransitionSubType::FROMBOTTOM
: nDirection
= 1; break;
814 case TransitionSubType::FROMLEFT
: nDirection
= 2; break;
815 case TransitionSubType::FROMTOP
: nDirection
= 3; break;
819 case TransitionType::PINWHEELWIPE
:
821 nPPTTransitionType
= PPT_TRANSITION_TYPE_WHEEL
;
822 switch( nTransitionSubtype
)
824 case TransitionSubType::ONEBLADE
: nDirection
= 1; break;
825 case TransitionSubType::TWOBLADEVERTICAL
: nDirection
= 2; break;
826 case TransitionSubType::THREEBLADE
: nDirection
= 3; break;
827 case TransitionSubType::FOURBLADE
: nDirection
= 4; break;
828 case TransitionSubType::EIGHTBLADE
: nDirection
= 8; break;
832 case TransitionType::FANWIPE
:
834 nPPTTransitionType
= PPT_TRANSITION_TYPE_WEDGE
;
837 case TransitionType::ELLIPSEWIPE
:
839 nPPTTransitionType
= PPT_TRANSITION_TYPE_CIRCLE
;
842 case TransitionType::FOURBOXWIPE
:
844 nPPTTransitionType
= PPT_TRANSITION_TYPE_PLUS
;
847 case TransitionType::IRISWIPE
:
849 switch( nTransitionSubtype
) {
850 case TransitionSubType::RECTANGLE
:
851 nPPTTransitionType
= PPT_TRANSITION_TYPE_ZOOM
;
852 nDirection
= (eEffect
== FadeEffect_FADE_FROM_CENTER
) ? 0 : 1;
855 nPPTTransitionType
= PPT_TRANSITION_TYPE_DIAMOND
;
862 return nPPTTransitionType
;
865 sal_Int8
PPTWriterBase::GetTransition( FadeEffect eEffect
, sal_uInt8
& nDirection
)
867 sal_Int8 nPPTTransitionType
= 0;
872 case FadeEffect_RANDOM
:
873 nPPTTransitionType
= PPT_TRANSITION_TYPE_RANDOM
;
876 case FadeEffect_HORIZONTAL_STRIPES
:
878 case FadeEffect_VERTICAL_STRIPES
:
879 nPPTTransitionType
= PPT_TRANSITION_TYPE_BLINDS
;
882 case FadeEffect_VERTICAL_CHECKERBOARD
:
884 case FadeEffect_HORIZONTAL_CHECKERBOARD
:
885 nPPTTransitionType
= PPT_TRANSITION_TYPE_CHECKER
;
888 case FadeEffect_MOVE_FROM_UPPERLEFT
:
890 case FadeEffect_MOVE_FROM_UPPERRIGHT
:
892 case FadeEffect_MOVE_FROM_LOWERLEFT
:
894 case FadeEffect_MOVE_FROM_LOWERRIGHT
:
896 case FadeEffect_MOVE_FROM_TOP
:
898 case FadeEffect_MOVE_FROM_LEFT
:
900 case FadeEffect_MOVE_FROM_BOTTOM
:
902 case FadeEffect_MOVE_FROM_RIGHT
:
903 nPPTTransitionType
= PPT_TRANSITION_TYPE_COVER
;
906 case FadeEffect_DISSOLVE
:
907 nPPTTransitionType
= PPT_TRANSITION_TYPE_DISSOLVE
;
910 case FadeEffect_VERTICAL_LINES
:
912 case FadeEffect_HORIZONTAL_LINES
:
913 nPPTTransitionType
= PPT_TRANSITION_TYPE_RANDOM_BARS
;
916 case FadeEffect_CLOSE_HORIZONTAL
:
918 case FadeEffect_OPEN_HORIZONTAL
:
920 case FadeEffect_CLOSE_VERTICAL
:
922 case FadeEffect_OPEN_VERTICAL
:
923 nPPTTransitionType
= PPT_TRANSITION_TYPE_SPLIT
;
926 case FadeEffect_FADE_FROM_UPPERLEFT
:
928 case FadeEffect_FADE_FROM_UPPERRIGHT
:
930 case FadeEffect_FADE_FROM_LOWERLEFT
:
932 case FadeEffect_FADE_FROM_LOWERRIGHT
:
934 nPPTTransitionType
= PPT_TRANSITION_TYPE_STRIPS
;
937 case FadeEffect_UNCOVER_TO_LOWERRIGHT
:
939 case FadeEffect_UNCOVER_TO_LOWERLEFT
:
941 case FadeEffect_UNCOVER_TO_UPPERRIGHT
:
943 case FadeEffect_UNCOVER_TO_UPPERLEFT
:
945 case FadeEffect_UNCOVER_TO_BOTTOM
:
947 case FadeEffect_UNCOVER_TO_RIGHT
:
949 case FadeEffect_UNCOVER_TO_TOP
:
951 case FadeEffect_UNCOVER_TO_LEFT
:
952 nPPTTransitionType
= PPT_TRANSITION_TYPE_PULL
;
955 case FadeEffect_FADE_FROM_TOP
:
957 case FadeEffect_FADE_FROM_LEFT
:
959 case FadeEffect_FADE_FROM_BOTTOM
:
961 case FadeEffect_FADE_FROM_RIGHT
:
962 nPPTTransitionType
= PPT_TRANSITION_TYPE_WIPE
;
965 case FadeEffect_ROLL_FROM_TOP
:
967 case FadeEffect_ROLL_FROM_LEFT
:
969 case FadeEffect_ROLL_FROM_BOTTOM
:
971 case FadeEffect_ROLL_FROM_RIGHT
:
972 nPPTTransitionType
= PPT_TRANSITION_TYPE_WIPE
;
975 case FadeEffect_FADE_TO_CENTER
:
977 case FadeEffect_FADE_FROM_CENTER
:
978 nPPTTransitionType
= PPT_TRANSITION_TYPE_ZOOM
;
981 case FadeEffect_NONE
:
986 return nPPTTransitionType
;
989 // -----------------------------------------------------------------------
991 sal_Bool
PPTWriterBase::ContainsOtherShapeThanPlaceholders( sal_Bool bForOOMLX
)
993 sal_uInt32 nShapes
= mXShapes
->getCount();
994 sal_Bool bOtherThanPlaceHolders
= sal_False
;
997 for ( sal_uInt32 nIndex
= 0; ( nIndex
< nShapes
) && ( bOtherThanPlaceHolders
== sal_False
); nIndex
++ )
999 if ( GetShapeByIndex( nIndex
) && mType
!= "drawing.Page" )
1002 ( mType
== "presentation.Page" ||
1003 mType
== "presentation.Notes" ) ) {
1004 Reference
< XSimpleText
> rXText( mXShape
, UNO_QUERY
);
1006 if( rXText
.is() && !rXText
->getString().isEmpty() )
1007 bOtherThanPlaceHolders
= sal_True
;
1010 bOtherThanPlaceHolders
= sal_True
;
1012 DBG(printf("mType == %s\n", mType
.getStr()));
1015 return bOtherThanPlaceHolders
;
1018 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */