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 <comphelper/anytostring.hxx>
21 #include <comphelper/sequenceashashmap.hxx>
22 #include <cppuhelper/exc_hlp.hxx>
23 #include <osl/diagnose.h>
24 #include <sal/log.hxx>
25 #include <tools/multisel.hxx>
26 #include <tools/diagnose_ex.h>
28 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
29 #include <com/sun/star/drawing/XDrawPages.hpp>
30 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
31 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
32 #include <com/sun/star/io/XInputStream.hpp>
33 #include <com/sun/star/xml/dom/XDocument.hpp>
34 #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
35 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
36 #include <com/sun/star/style/XStyle.hpp>
37 #include <com/sun/star/presentation/XPresentationPage.hpp>
38 #include <com/sun/star/task/XStatusIndicator.hpp>
40 #include <oox/drawingml/theme.hxx>
41 #include <oox/drawingml/drawingmltypes.hxx>
42 #include <oox/drawingml/themefragmenthandler.hxx>
43 #include <drawingml/textliststylecontext.hxx>
44 #include <oox/helper/attributelist.hxx>
45 #include <oox/ole/olestorage.hxx>
46 #include <oox/ole/vbaproject.hxx>
47 #include <oox/ppt/pptshape.hxx>
48 #include <oox/ppt/presentationfragmenthandler.hxx>
49 #include <oox/ppt/slidefragmenthandler.hxx>
50 #include <oox/ppt/layoutfragmenthandler.hxx>
51 #include <oox/ppt/pptimport.hxx>
52 #include <oox/token/namespaces.hxx>
53 #include <oox/token/tokens.hxx>
55 #include <com/sun/star/office/XAnnotation.hpp>
56 #include <com/sun/star/office/XAnnotationAccess.hpp>
58 using namespace ::com::sun::star
;
59 using namespace ::oox::core
;
60 using namespace ::oox::drawingml
;
61 using namespace ::com::sun::star::uno
;
62 using namespace ::com::sun::star::beans
;
63 using namespace ::com::sun::star::drawing
;
64 using namespace ::com::sun::star::presentation
;
65 using namespace ::com::sun::star::xml::sax
;
67 namespace oox
{ namespace ppt
{
69 static std::map
<PredefinedClrSchemeId
, sal_Int32
> PredefinedClrTokens
=
75 { accent1
, XML_accent1
},
76 { accent2
, XML_accent2
},
77 { accent3
, XML_accent3
},
78 { accent4
, XML_accent4
},
79 { accent5
, XML_accent5
},
80 { accent6
, XML_accent6
},
82 { folHlink
, XML_folHlink
}
85 PresentationFragmentHandler::PresentationFragmentHandler(XmlFilterBase
& rFilter
, const OUString
& rFragmentPath
)
86 : FragmentHandler2( rFilter
, rFragmentPath
)
87 , mpTextListStyle( new TextListStyle
)
88 , mbCommentAuthorsRead(false)
91 TextParagraphPropertiesVector
& rParagraphDefaulsVector( mpTextListStyle
->getListStyle() );
92 for (auto const& elem
: rParagraphDefaulsVector
)
94 // ppt is having zero bottom margin per default, whereas OOo is 0,5cm,
95 // so this attribute needs to be set always
96 elem
->getParaBottomMargin() = TextSpacing( 0 );
100 PresentationFragmentHandler::~PresentationFragmentHandler() throw()
104 static void ResolveTextFields( XmlFilterBase
const & rFilter
)
106 const oox::core::TextFieldStack
& rTextFields
= rFilter
.getTextFieldStack();
107 if ( !rTextFields
.empty() )
109 const Reference
< frame::XModel
>& xModel( rFilter
.getModel() );
110 for (auto const& textField
: rTextFields
)
112 const OUString sURL
= "URL";
113 Reference
< drawing::XDrawPagesSupplier
> xDPS( xModel
, uno::UNO_QUERY_THROW
);
114 Reference
< drawing::XDrawPages
> xDrawPages( xDPS
->getDrawPages(), uno::UNO_SET_THROW
);
116 const oox::core::TextField
& rTextField( textField
);
117 Reference
< XPropertySet
> xPropSet( rTextField
.xTextField
, UNO_QUERY
);
118 Reference
< XPropertySetInfo
> xPropSetInfo( xPropSet
->getPropertySetInfo() );
119 if ( xPropSetInfo
->hasPropertyByName( sURL
) )
122 if ( xPropSet
->getPropertyValue( sURL
) >>= aURL
)
124 const OUString sSlide
= "#Slide ";
125 const OUString sNotes
= "#Notes ";
127 sal_Int32 nPageNumber
= 0;
128 if ( aURL
.match( sSlide
) )
129 nPageNumber
= aURL
.copy( sSlide
.getLength() ).toInt32();
130 else if ( aURL
.match( sNotes
) )
132 nPageNumber
= aURL
.copy( sNotes
.getLength() ).toInt32();
139 Reference
< XDrawPage
> xDrawPage
;
140 xDrawPages
->getByIndex( nPageNumber
- 1 ) >>= xDrawPage
;
143 Reference
< css::presentation::XPresentationPage
> xPresentationPage( xDrawPage
, UNO_QUERY_THROW
);
144 xDrawPage
= xPresentationPage
->getNotesPage();
146 Reference
< container::XNamed
> xNamed( xDrawPage
, UNO_QUERY_THROW
);
147 aURL
= "#" + xNamed
->getName();
148 xPropSet
->setPropertyValue( sURL
, Any( aURL
) );
149 Reference
< text::XTextContent
> xContent( rTextField
.xTextField
, UNO_QUERY
);
150 Reference
< text::XTextRange
> xTextRange
= rTextField
.xTextCursor
;
151 rTextField
.xText
->insertTextContent( xTextRange
, xContent
, true );
153 catch( uno::Exception
& )
163 void PresentationFragmentHandler::saveThemeToGrabBag(const oox::drawingml::ThemePtr
& pThemePtr
,
171 uno::Reference
<beans::XPropertySet
> xDocProps(getFilter().getModel(), uno::UNO_QUERY
);
174 uno::Reference
<beans::XPropertySetInfo
> xPropsInfo
= xDocProps
->getPropertySetInfo();
176 const OUString aGrabBagPropName
= "InteropGrabBag";
177 if (xPropsInfo
.is() && xPropsInfo
->hasPropertyByName(aGrabBagPropName
))
179 // get existing grab bag
180 comphelper::SequenceAsHashMap
aGrabBag(xDocProps
->getPropertyValue(aGrabBagPropName
));
182 uno::Sequence
<beans::PropertyValue
> aTheme(2);
183 comphelper::SequenceAsHashMap aThemesHashMap
;
185 // create current theme
186 uno::Sequence
<beans::PropertyValue
> aCurrentTheme(PredefinedClrSchemeId::Count
);
188 ClrScheme rClrScheme
= pThemePtr
->getClrScheme();
189 for (int nId
= PredefinedClrSchemeId::dk2
; nId
!= PredefinedClrSchemeId::Count
; nId
++)
191 sal_uInt32 nToken
= PredefinedClrTokens
[static_cast<PredefinedClrSchemeId
>(nId
)];
192 const OUString
& sName
= PredefinedClrNames
[static_cast<PredefinedClrSchemeId
>(nId
)];
195 rClrScheme
.getColor(nToken
, nColor
);
196 const uno::Any
& rColor
= uno::makeAny(nColor
);
198 aCurrentTheme
[nId
].Name
= sName
;
199 aCurrentTheme
[nId
].Value
= rColor
;
203 // add new theme to the sequence
204 // Export code uses the master slide's index to find the right theme
205 // so use the same index in the grabbag.
206 aTheme
[0].Name
= "ppt/theme/theme" + OUString::number(nThemeIdx
) + ".xml";
207 const uno::Any
& rCurrentTheme
= makeAny(aCurrentTheme
);
208 aTheme
[0].Value
= rCurrentTheme
;
210 // store DOM fragment for SmartArt re-generation
211 aTheme
[1].Name
= "OOXTheme";
212 const uno::Any
& rOOXTheme
= makeAny(pThemePtr
->getFragment());
213 aTheme
[1].Value
= rOOXTheme
;
215 aThemesHashMap
<< aTheme
;
218 aGrabBag
.update(aThemesHashMap
);
220 // put it back to the document
221 xDocProps
->setPropertyValue(aGrabBagPropName
, uno::Any(aGrabBag
.getAsConstPropertyValueList()));
225 catch (const uno::Exception
&)
227 SAL_WARN("oox", "oox::ppt::PresentationFragmentHandler::saveThemeToGrabBag, Failed to save grab bag");
231 void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide
, bool bFirstPage
, bool bImportNotesPage
)
233 PowerPointImport
& rFilter
= dynamic_cast< PowerPointImport
& >( getFilter() );
235 Reference
< frame::XModel
> xModel( rFilter
.getModel() );
236 Reference
< drawing::XDrawPage
> xSlide
;
238 // importing slide pages and its corresponding notes page
239 Reference
< drawing::XDrawPagesSupplier
> xDPS( xModel
, uno::UNO_QUERY_THROW
);
240 Reference
< drawing::XDrawPages
> xDrawPages( xDPS
->getDrawPages(), uno::UNO_SET_THROW
);
245 xDrawPages
->getByIndex( 0 ) >>= xSlide
;
247 xSlide
= xDrawPages
->insertNewByIndex( xDrawPages
->getCount() );
249 OUString aSlideFragmentPath
= getFragmentPathFromRelId( maSlidesVector
[ nSlide
] );
250 if( !aSlideFragmentPath
.isEmpty() )
252 SlidePersistPtr pMasterPersistPtr
;
253 SlidePersistPtr
pSlidePersistPtr( new SlidePersist( rFilter
, false, false, xSlide
,
254 ShapePtr( new PPTShape( Slide
, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle
) );
256 FragmentHandlerRef
xSlideFragmentHandler( new SlideFragmentHandler( rFilter
, aSlideFragmentPath
, pSlidePersistPtr
, Slide
) );
258 // importing the corresponding masterpage/layout
259 OUString aLayoutFragmentPath
= xSlideFragmentHandler
->getFragmentPathFromFirstTypeFromOfficeDoc( "slideLayout" );
260 OUString aCommentFragmentPath
= xSlideFragmentHandler
->getFragmentPathFromFirstTypeFromOfficeDoc( "comments" );
261 if ( !aLayoutFragmentPath
.isEmpty() )
264 RelationsRef xLayoutRelations
= rFilter
.importRelations( aLayoutFragmentPath
);
265 OUString aMasterFragmentPath
= xLayoutRelations
->getFragmentPathFromFirstTypeFromOfficeDoc( "slideMaster" );
266 if( !aMasterFragmentPath
.isEmpty() )
268 // check if the corresponding masterpage+layout has already been imported
269 std::vector
< SlidePersistPtr
>& rMasterPages( rFilter
.getMasterPages() );
270 for (auto const& masterPage
: rMasterPages
)
272 if ( ( masterPage
->getPath() == aMasterFragmentPath
) && ( masterPage
->getLayoutPath() == aLayoutFragmentPath
) )
274 pMasterPersistPtr
= masterPage
;
279 if ( !pMasterPersistPtr
.get() )
280 { // masterpersist not found, we have to load it
281 Reference
< drawing::XDrawPage
> xMasterPage
;
282 Reference
< drawing::XMasterPagesSupplier
> xMPS( xModel
, uno::UNO_QUERY_THROW
);
283 Reference
< drawing::XDrawPages
> xMasterPages( xMPS
->getMasterPages(), uno::UNO_SET_THROW
);
286 if( rFilter
.getMasterPages().empty() )
289 xMasterPages
->getByIndex( nIndex
) >>= xMasterPage
;
293 nIndex
= xMasterPages
->getCount();
294 xMasterPage
= xMasterPages
->insertNewByIndex( nIndex
);
297 pMasterPersistPtr
= std::make_shared
<SlidePersist
>( rFilter
, true, false, xMasterPage
,
298 ShapePtr( new PPTShape( Master
, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle
);
299 pMasterPersistPtr
->setLayoutPath( aLayoutFragmentPath
);
300 rFilter
.getMasterPages().push_back( pMasterPersistPtr
);
301 rFilter
.setActualSlidePersist( pMasterPersistPtr
);
302 FragmentHandlerRef
xMasterFragmentHandler( new SlideFragmentHandler( rFilter
, aMasterFragmentPath
, pMasterPersistPtr
, Master
) );
304 // set the correct theme
305 OUString aThemeFragmentPath
= xMasterFragmentHandler
->getFragmentPathFromFirstTypeFromOfficeDoc( "theme" );
306 if( !aThemeFragmentPath
.isEmpty() )
308 std::map
< OUString
, oox::drawingml::ThemePtr
>& rThemes( rFilter
.getThemes() );
309 std::map
< OUString
, oox::drawingml::ThemePtr
>::iterator
aIter2( rThemes
.find( aThemeFragmentPath
) );
310 if( aIter2
== rThemes
.end() )
312 oox::drawingml::ThemePtr
pThemePtr( new oox::drawingml::Theme() );
313 pMasterPersistPtr
->setTheme( pThemePtr
);
314 Reference
<xml::dom::XDocument
> xDoc
=
315 rFilter
.importFragment(aThemeFragmentPath
);
317 rFilter
.importFragment(
318 new ThemeFragmentHandler(
319 rFilter
, aThemeFragmentPath
, *pThemePtr
),
320 Reference
<xml::sax::XFastSAXSerializable
>(
323 rThemes
[ aThemeFragmentPath
] = pThemePtr
;
324 pThemePtr
->setFragment(xDoc
);
325 saveThemeToGrabBag(pThemePtr
, nIndex
+ 1);
329 pMasterPersistPtr
->setTheme( (*aIter2
).second
);
332 importSlide( xMasterFragmentHandler
, pMasterPersistPtr
);
333 rFilter
.importFragment( new LayoutFragmentHandler( rFilter
, aLayoutFragmentPath
, pMasterPersistPtr
) );
334 pMasterPersistPtr
->createBackground( rFilter
);
335 pMasterPersistPtr
->createXShapes( rFilter
);
340 // importing slide page
341 if (pMasterPersistPtr
.get()) {
342 pSlidePersistPtr
->setMasterPersist( pMasterPersistPtr
);
343 pSlidePersistPtr
->setTheme( pMasterPersistPtr
->getTheme() );
344 Reference
< drawing::XMasterPageTarget
> xMasterPageTarget( pSlidePersistPtr
->getPage(), UNO_QUERY
);
345 if( xMasterPageTarget
.is() )
346 xMasterPageTarget
->setMasterPage( pMasterPersistPtr
->getPage() );
348 rFilter
.getDrawPages().push_back( pSlidePersistPtr
);
349 rFilter
.setActualSlidePersist( pSlidePersistPtr
);
350 importSlide( xSlideFragmentHandler
, pSlidePersistPtr
);
351 pSlidePersistPtr
->createBackground( rFilter
);
352 pSlidePersistPtr
->createXShapes( rFilter
);
354 if(bImportNotesPage
) {
356 // now importing the notes page
357 OUString aNotesFragmentPath
= xSlideFragmentHandler
->getFragmentPathFromFirstTypeFromOfficeDoc( "notesSlide" );
358 if( !aNotesFragmentPath
.isEmpty() )
360 Reference
< XPresentationPage
> xPresentationPage( xSlide
, UNO_QUERY
);
361 if ( xPresentationPage
.is() )
363 Reference
< XDrawPage
> xNotesPage( xPresentationPage
->getNotesPage() );
364 if ( xNotesPage
.is() )
366 SlidePersistPtr
pNotesPersistPtr( new SlidePersist( rFilter
, false, true, xNotesPage
,
367 ShapePtr( new PPTShape( Slide
, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle
) );
368 FragmentHandlerRef
xNotesFragmentHandler( new SlideFragmentHandler( getFilter(), aNotesFragmentPath
, pNotesPersistPtr
, Slide
) );
369 rFilter
.getNotesPages().push_back( pNotesPersistPtr
);
370 rFilter
.setActualSlidePersist( pNotesPersistPtr
);
371 importSlide( xNotesFragmentHandler
, pNotesPersistPtr
);
372 pNotesPersistPtr
->createBackground( rFilter
);
373 pNotesPersistPtr
->createXShapes( rFilter
);
379 if( !mbCommentAuthorsRead
&& !aCommentFragmentPath
.isEmpty() )
381 // Comments are present and commentAuthors.xml has still not been read
382 mbCommentAuthorsRead
= true;
383 OUString aCommentAuthorsFragmentPath
= "ppt/commentAuthors.xml";
384 Reference
< XPresentationPage
> xPresentationPage( xSlide
, UNO_QUERY
);
385 Reference
< XDrawPage
> xCommentAuthorsPage( xPresentationPage
->getNotesPage() );
386 SlidePersistPtr
pCommentAuthorsPersistPtr(
387 new SlidePersist( rFilter
, false, true, xCommentAuthorsPage
,
390 Slide
, "com.sun.star.drawing.GroupShape" ) ),
392 FragmentHandlerRef
xCommentAuthorsFragmentHandler(
393 new SlideFragmentHandler( getFilter(),
394 aCommentAuthorsFragmentPath
,
395 pCommentAuthorsPersistPtr
,
398 getFilter().importFragment( xCommentAuthorsFragmentHandler
);
399 maAuthorList
.setValues( pCommentAuthorsPersistPtr
->getCommentAuthors() );
401 if( !aCommentFragmentPath
.isEmpty() )
403 Reference
< XPresentationPage
> xPresentationPage( xSlide
, UNO_QUERY
);
404 Reference
< XDrawPage
> xCommentsPage( xPresentationPage
->getNotesPage() );
405 SlidePersistPtr
pCommentsPersistPtr(
407 rFilter
, false, true, xCommentsPage
,
410 Slide
, "com.sun.star.drawing.GroupShape" ) ),
413 FragmentHandlerRef
xCommentsFragmentHandler(
414 new SlideFragmentHandler(
416 aCommentFragmentPath
,
419 pCommentsPersistPtr
->getCommentsList().cmLst
.clear();
420 getFilter().importFragment( xCommentsFragmentHandler
);
422 if (!pCommentsPersistPtr
->getCommentsList().cmLst
.empty())
424 //set comment chars for last comment on slide
425 SlideFragmentHandler
* comment_handler
=
426 dynamic_cast<SlideFragmentHandler
*>(xCommentsFragmentHandler
.get());
427 assert(comment_handler
);
428 // some comments have no text -> set empty string as text to avoid
429 // crash (back() on empty vector is undefined) and losing other
430 // comment data that might be there (author, position, timestamp etc.)
431 pCommentsPersistPtr
->getCommentsList().cmLst
.back().setText(
432 comment_handler
->getCharVector().empty() ? "" :
433 comment_handler
->getCharVector().back() );
435 pCommentsPersistPtr
->getCommentAuthors().setValues(maAuthorList
);
437 //insert all comments from commentsList
438 for(int i
=0; i
<pCommentsPersistPtr
->getCommentsList().getSize(); i
++)
441 Comment aComment
= pCommentsPersistPtr
->getCommentsList().getCommentAtIndex(i
);
442 uno::Reference
< office::XAnnotationAccess
> xAnnotationAccess( xSlide
, UNO_QUERY_THROW
);
443 uno::Reference
< office::XAnnotation
> xAnnotation( xAnnotationAccess
->createAndInsertAnnotation() );
444 int nPosX
= aComment
.getIntX();
445 int nPosY
= aComment
.getIntY();
446 xAnnotation
->setPosition(
447 geometry::RealPoint2D(
448 ::oox::drawingml::convertEmuToHmm( nPosX
) * 15.87,
449 ::oox::drawingml::convertEmuToHmm( nPosY
) * 15.87 ) );
450 xAnnotation
->setAuthor( aComment
.getAuthor(maAuthorList
) );
451 xAnnotation
->setDateTime( aComment
.getDateTime() );
452 uno::Reference
< text::XText
> xText( xAnnotation
->getTextRange() );
453 xText
->setString( aComment
.get_text());
454 } catch( css::lang::IllegalArgumentException
& ) {}
459 catch( uno::Exception
& )
461 TOOLS_WARN_EXCEPTION( "oox", "oox::ppt::PresentationFragmentHandler::EndDocument()" );
465 void PresentationFragmentHandler::finalizeImport()
467 PowerPointImport
& rFilter
= dynamic_cast< PowerPointImport
& >( getFilter() );
469 sal_Int32 nPageCount
= maSlidesVector
.size();
471 // we will take the FilterData property "PageRange" if available, otherwise full range is used
472 comphelper::SequenceAsHashMap
& rFilterData
= rFilter
.getFilterData();
474 // writing back the original PageCount of this document, it can be accessed from the XModel
475 // via getArgs after the import.
476 rFilterData
["OriginalPageCount"] <<= nPageCount
;
477 bool bImportNotesPages
= rFilterData
.getUnpackedValueOrDefault("ImportNotesPages", true);
478 OUString aPageRange
= rFilterData
.getUnpackedValueOrDefault("PageRange", OUString());
480 if( !aPageRange
.getLength() )
482 aPageRange
= OUStringBuffer()
483 .append( static_cast< sal_Int32
>( 1 ) )
485 .append( nPageCount
).makeStringAndClear();
488 StringRangeEnumerator
aRangeEnumerator( aPageRange
, 0, nPageCount
- 1 );
489 if (aRangeEnumerator
.size())
491 // todo: localized progress bar text
492 const Reference
< task::XStatusIndicator
>& rxStatusIndicator( getFilter().getStatusIndicator() );
493 if ( rxStatusIndicator
.is() )
494 rxStatusIndicator
->start( OUString(), 10000 );
498 int nPagesImported
= 0;
499 for (sal_Int32 elem
: aRangeEnumerator
)
501 if ( rxStatusIndicator
.is() )
502 rxStatusIndicator
->setValue((nPagesImported
* 10000) / aRangeEnumerator
.size());
504 importSlide(elem
, !nPagesImported
, bImportNotesPages
);
507 ResolveTextFields( rFilter
);
509 catch( uno::Exception
& )
511 TOOLS_WARN_EXCEPTION( "oox", "oox::ppt::PresentationFragmentHandler::finalizeImport()" );
513 // todo error handling;
514 if ( rxStatusIndicator
.is() )
515 rxStatusIndicator
->end();
518 // open the VBA project storage
519 OUString aVbaFragmentPath
= getFragmentPathFromFirstType(CREATE_MSOFFICE_RELATION_TYPE("vbaProject"));
520 if (!aVbaFragmentPath
.isEmpty())
522 uno::Reference
<io::XInputStream
> xInStrm
= getFilter().openInputStream(aVbaFragmentPath
);
525 StorageRef
xPrjStrg(new oox::ole::OleStorage(getFilter().getComponentContext(), xInStrm
, false));
526 getFilter().getVbaProject().importVbaProject(*xPrjStrg
);
532 ::oox::core::ContextHandlerRef
PresentationFragmentHandler::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
534 switch( aElementToken
)
536 case PPT_TOKEN( presentation
):
537 case PPT_TOKEN( sldMasterIdLst
):
538 case PPT_TOKEN( notesMasterIdLst
):
539 case PPT_TOKEN( sldIdLst
):
541 case PPT_TOKEN( sldMasterId
):
542 maSlideMasterVector
.push_back( rAttribs
.getString( R_TOKEN( id
), OUString() ) );
544 case PPT_TOKEN( sldId
):
545 maSlidesVector
.push_back( rAttribs
.getString( R_TOKEN( id
), OUString() ) );
547 case PPT_TOKEN( notesMasterId
):
548 maNotesMasterVector
.push_back( rAttribs
.getString( R_TOKEN( id
), OUString() ) );
550 case PPT_TOKEN( sldSz
):
551 maSlideSize
= GetSize2D( rAttribs
.getFastAttributeList() );
553 case PPT_TOKEN( notesSz
):
554 maNotesSize
= GetSize2D( rAttribs
.getFastAttributeList() );
556 case PPT_TOKEN( custShowLst
):
557 return new CustomShowListContext( *this, maCustomShowList
);
558 case PPT_TOKEN( defaultTextStyle
):
559 return new TextListStyleContext( *this, *mpTextListStyle
);
564 void PresentationFragmentHandler::importSlide( const FragmentHandlerRef
& rxSlideFragmentHandler
,
565 const SlidePersistPtr
& rSlidePersistPtr
)
567 Reference
< drawing::XDrawPage
> xSlide( rSlidePersistPtr
->getPage() );
568 SlidePersistPtr
pMasterPersistPtr( rSlidePersistPtr
->getMasterPersist() );
569 if ( pMasterPersistPtr
.get() )
571 // Setting "Layout" property adds extra title and outliner preset shapes to the master slide
572 Reference
< drawing::XDrawPage
> xMasterSlide(pMasterPersistPtr
->getPage());
573 const int nCount
= xMasterSlide
->getCount();
575 const OUString sLayout
= "Layout";
576 uno::Reference
< beans::XPropertySet
> xSet( xSlide
, uno::UNO_QUERY_THROW
);
577 xSet
->setPropertyValue( sLayout
, Any( pMasterPersistPtr
->getLayoutFromValueToken() ) );
579 while( nCount
< xMasterSlide
->getCount())
581 Reference
< drawing::XShape
> xShape
;
582 xMasterSlide
->getByIndex(xMasterSlide
->getCount()-1) >>= xShape
;
583 xMasterSlide
->remove(xShape
);
586 while( xSlide
->getCount() )
588 Reference
< drawing::XShape
> xShape
;
589 xSlide
->getByIndex(0) >>= xShape
;
590 xSlide
->remove( xShape
);
593 Reference
< XPropertySet
> xPropertySet( xSlide
, UNO_QUERY
);
594 if ( xPropertySet
.is() )
596 awt::Size
& rPageSize( rSlidePersistPtr
->isNotesPage() ? maNotesSize
: maSlideSize
);
597 xPropertySet
->setPropertyValue( "Width", Any( rPageSize
.Width
) );
598 xPropertySet
->setPropertyValue( "Height", Any( rPageSize
.Height
) );
600 oox::ppt::HeaderFooter
aHeaderFooter( rSlidePersistPtr
->getHeaderFooter() );
601 if ( !rSlidePersistPtr
->isMasterPage() )
602 aHeaderFooter
.mbSlideNumber
= aHeaderFooter
.mbHeader
= aHeaderFooter
.mbFooter
= aHeaderFooter
.mbDateTime
= false;
605 if ( rSlidePersistPtr
->isNotesPage() )
606 xPropertySet
->setPropertyValue( "IsHeaderVisible", Any( aHeaderFooter
.mbHeader
) );
607 xPropertySet
->setPropertyValue( "IsFooterVisible", Any( aHeaderFooter
.mbFooter
) );
608 xPropertySet
->setPropertyValue( "IsDateTimeVisible", Any( aHeaderFooter
.mbDateTime
) );
609 xPropertySet
->setPropertyValue( "IsPageNumberVisible", Any( aHeaderFooter
.mbSlideNumber
) );
611 catch( uno::Exception
& )
615 rSlidePersistPtr
->setPath( rxSlideFragmentHandler
->getFragmentPath() );
616 getFilter().importFragment( rxSlideFragmentHandler
);
621 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */