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 <tools/multisel.hxx>
26 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
27 #include <com/sun/star/drawing/XDrawPages.hpp>
28 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
29 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
30 #include <com/sun/star/io/XInputStream.hpp>
31 #include <com/sun/star/xml/dom/XDocument.hpp>
32 #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
33 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
34 #include <com/sun/star/style/XStyle.hpp>
35 #include <com/sun/star/presentation/XPresentationPage.hpp>
36 #include <com/sun/star/task/XStatusIndicator.hpp>
38 #include <oox/drawingml/theme.hxx>
39 #include <oox/drawingml/drawingmltypes.hxx>
40 #include <oox/drawingml/themefragmenthandler.hxx>
41 #include <drawingml/textliststylecontext.hxx>
42 #include <oox/helper/attributelist.hxx>
43 #include <oox/ole/olestorage.hxx>
44 #include <oox/ole/vbaproject.hxx>
45 #include <oox/ppt/pptshape.hxx>
46 #include <oox/ppt/presentationfragmenthandler.hxx>
47 #include <oox/ppt/slidefragmenthandler.hxx>
48 #include <oox/ppt/layoutfragmenthandler.hxx>
49 #include <oox/ppt/pptimport.hxx>
50 #include <oox/token/namespaces.hxx>
51 #include <oox/token/tokens.hxx>
53 #include <com/sun/star/office/XAnnotation.hpp>
54 #include <com/sun/star/office/XAnnotationAccess.hpp>
56 using namespace ::com::sun::star
;
57 using namespace ::oox::core
;
58 using namespace ::oox::drawingml
;
59 using namespace ::com::sun::star::uno
;
60 using namespace ::com::sun::star::beans
;
61 using namespace ::com::sun::star::drawing
;
62 using namespace ::com::sun::star::presentation
;
63 using namespace ::com::sun::star::xml::sax
;
65 namespace oox
{ namespace ppt
{
67 static std::map
<PredefinedClrSchemeId
, sal_Int32
> PredefinedClrTokens
=
73 { accent1
, XML_accent1
},
74 { accent2
, XML_accent2
},
75 { accent3
, XML_accent3
},
76 { accent4
, XML_accent4
},
77 { accent5
, XML_accent5
},
78 { accent6
, XML_accent6
},
80 { folHlink
, XML_folHlink
}
83 PresentationFragmentHandler::PresentationFragmentHandler(XmlFilterBase
& rFilter
, const OUString
& rFragmentPath
)
84 : FragmentHandler2( rFilter
, rFragmentPath
)
85 , mpTextListStyle( new TextListStyle
)
86 , mbCommentAuthorsRead(false)
89 TextParagraphPropertiesVector
& rParagraphDefaulsVector( mpTextListStyle
->getListStyle() );
90 for (auto const& elem
: rParagraphDefaulsVector
)
92 // ppt is having zero bottom margin per default, whereas OOo is 0,5cm,
93 // so this attribute needs to be set always
94 elem
->getParaBottomMargin() = TextSpacing( 0 );
98 PresentationFragmentHandler::~PresentationFragmentHandler() throw()
102 void ResolveTextFields( XmlFilterBase
const & rFilter
)
104 const oox::core::TextFieldStack
& rTextFields
= rFilter
.getTextFieldStack();
105 if ( !rTextFields
.empty() )
107 Reference
< frame::XModel
> xModel( rFilter
.getModel() );
108 for (auto const& textField
: rTextFields
)
110 const OUString sURL
= "URL";
111 Reference
< drawing::XDrawPagesSupplier
> xDPS( xModel
, uno::UNO_QUERY_THROW
);
112 Reference
< drawing::XDrawPages
> xDrawPages( xDPS
->getDrawPages(), uno::UNO_QUERY_THROW
);
114 const oox::core::TextField
& rTextField( textField
);
115 Reference
< XPropertySet
> xPropSet( rTextField
.xTextField
, UNO_QUERY
);
116 Reference
< XPropertySetInfo
> xPropSetInfo( xPropSet
->getPropertySetInfo() );
117 if ( xPropSetInfo
->hasPropertyByName( sURL
) )
120 if ( xPropSet
->getPropertyValue( sURL
) >>= aURL
)
122 const OUString sSlide
= "#Slide ";
123 const OUString sNotes
= "#Notes ";
125 sal_Int32 nPageNumber
= 0;
126 if ( aURL
.match( sSlide
) )
127 nPageNumber
= aURL
.copy( sSlide
.getLength() ).toInt32();
128 else if ( aURL
.match( sNotes
) )
130 nPageNumber
= aURL
.copy( sNotes
.getLength() ).toInt32();
137 Reference
< XDrawPage
> xDrawPage
;
138 xDrawPages
->getByIndex( nPageNumber
- 1 ) >>= xDrawPage
;
141 Reference
< css::presentation::XPresentationPage
> xPresentationPage( xDrawPage
, UNO_QUERY_THROW
);
142 xDrawPage
= xPresentationPage
->getNotesPage();
144 Reference
< container::XNamed
> xNamed( xDrawPage
, UNO_QUERY_THROW
);
145 aURL
= "#" + xNamed
->getName();
146 xPropSet
->setPropertyValue( sURL
, Any( aURL
) );
147 Reference
< text::XTextContent
> xContent( rTextField
.xTextField
, UNO_QUERY
);
148 Reference
< text::XTextRange
> xTextRange( rTextField
.xTextCursor
, UNO_QUERY
);
149 rTextField
.xText
->insertTextContent( xTextRange
, xContent
, true );
151 catch( uno::Exception
& )
161 void PresentationFragmentHandler::saveThemeToGrabBag(oox::drawingml::ThemePtr pThemePtr
, const OUString
& sTheme
)
168 uno::Reference
<beans::XPropertySet
> xDocProps(getFilter().getModel(), uno::UNO_QUERY
);
171 uno::Reference
<beans::XPropertySetInfo
> xPropsInfo
= xDocProps
->getPropertySetInfo();
173 const OUString aGrabBagPropName
= "InteropGrabBag";
174 if (xPropsInfo
.is() && xPropsInfo
->hasPropertyByName(aGrabBagPropName
))
176 // get existing grab bag
177 comphelper::SequenceAsHashMap
aGrabBag(xDocProps
->getPropertyValue(aGrabBagPropName
));
179 uno::Sequence
<beans::PropertyValue
> aTheme(1);
180 comphelper::SequenceAsHashMap aThemesHashMap
;
182 // create current theme
183 uno::Sequence
<beans::PropertyValue
> aCurrentTheme(PredefinedClrSchemeId::Count
);
185 ClrScheme rClrScheme
= pThemePtr
->getClrScheme();
186 for (int nId
= PredefinedClrSchemeId::dk2
; nId
!= PredefinedClrSchemeId::Count
; nId
++)
188 sal_uInt32 nToken
= PredefinedClrTokens
[static_cast<PredefinedClrSchemeId
>(nId
)];
189 const OUString
& sName
= PredefinedClrNames
[static_cast<PredefinedClrSchemeId
>(nId
)];
192 rClrScheme
.getColor(nToken
, nColor
);
193 const uno::Any
& rColor
= uno::makeAny(nColor
);
195 aCurrentTheme
[nId
].Name
= sName
;
196 aCurrentTheme
[nId
].Value
= rColor
;
199 // add new theme to the sequence
200 aTheme
[0].Name
= sTheme
;
201 const uno::Any
& rCurrentTheme
= makeAny(aCurrentTheme
);
202 aTheme
[0].Value
= rCurrentTheme
;
204 aThemesHashMap
<< aTheme
;
207 aGrabBag
.update(aThemesHashMap
);
209 // put it back to the document
210 xDocProps
->setPropertyValue(aGrabBagPropName
, uno::Any(aGrabBag
.getAsConstPropertyValueList()));
214 catch (const uno::Exception
&)
216 SAL_WARN("oox", "oox::ppt::PresentationFragmentHandler::saveThemeToGrabBag, Failed to save grab bag");
220 void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide
, bool bFirstPage
, bool bImportNotesPage
)
222 PowerPointImport
& rFilter
= dynamic_cast< PowerPointImport
& >( getFilter() );
224 Reference
< frame::XModel
> xModel( rFilter
.getModel() );
225 Reference
< drawing::XDrawPage
> xSlide
;
227 // importing slide pages and its corresponding notes page
228 Reference
< drawing::XDrawPagesSupplier
> xDPS( xModel
, uno::UNO_QUERY_THROW
);
229 Reference
< drawing::XDrawPages
> xDrawPages( xDPS
->getDrawPages(), uno::UNO_QUERY_THROW
);
234 xDrawPages
->getByIndex( 0 ) >>= xSlide
;
236 xSlide
= xDrawPages
->insertNewByIndex( xDrawPages
->getCount() );
238 OUString aSlideFragmentPath
= getFragmentPathFromRelId( maSlidesVector
[ nSlide
] );
239 if( !aSlideFragmentPath
.isEmpty() )
241 SlidePersistPtr pMasterPersistPtr
;
242 SlidePersistPtr
pSlidePersistPtr( new SlidePersist( rFilter
, false, false, xSlide
,
243 ShapePtr( new PPTShape( Slide
, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle
) );
245 FragmentHandlerRef
xSlideFragmentHandler( new SlideFragmentHandler( rFilter
, aSlideFragmentPath
, pSlidePersistPtr
, Slide
) );
247 // importing the corresponding masterpage/layout
248 OUString aLayoutFragmentPath
= xSlideFragmentHandler
->getFragmentPathFromFirstTypeFromOfficeDoc( "slideLayout" );
249 OUString aCommentFragmentPath
= xSlideFragmentHandler
->getFragmentPathFromFirstTypeFromOfficeDoc( "comments" );
250 if ( !aLayoutFragmentPath
.isEmpty() )
253 RelationsRef xLayoutRelations
= rFilter
.importRelations( aLayoutFragmentPath
);
254 OUString aMasterFragmentPath
= xLayoutRelations
->getFragmentPathFromFirstTypeFromOfficeDoc( "slideMaster" );
255 if( !aMasterFragmentPath
.isEmpty() )
257 // check if the corresponding masterpage+layout has already been imported
258 std::vector
< SlidePersistPtr
>& rMasterPages( rFilter
.getMasterPages() );
259 for (auto const& masterPage
: rMasterPages
)
261 if ( ( masterPage
->getPath() == aMasterFragmentPath
) && ( masterPage
->getLayoutPath() == aLayoutFragmentPath
) )
263 pMasterPersistPtr
= masterPage
;
268 if ( !pMasterPersistPtr
.get() )
269 { // masterpersist not found, we have to load it
270 Reference
< drawing::XDrawPage
> xMasterPage
;
271 Reference
< drawing::XMasterPagesSupplier
> xMPS( xModel
, uno::UNO_QUERY_THROW
);
272 Reference
< drawing::XDrawPages
> xMasterPages( xMPS
->getMasterPages(), uno::UNO_QUERY_THROW
);
274 if( rFilter
.getMasterPages().empty() )
275 xMasterPages
->getByIndex( 0 ) >>= xMasterPage
;
277 xMasterPage
= xMasterPages
->insertNewByIndex( xMasterPages
->getCount() );
279 pMasterPersistPtr
= std::make_shared
<SlidePersist
>( rFilter
, true, false, xMasterPage
,
280 ShapePtr( new PPTShape( Master
, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle
);
281 pMasterPersistPtr
->setLayoutPath( aLayoutFragmentPath
);
282 rFilter
.getMasterPages().push_back( pMasterPersistPtr
);
283 rFilter
.setActualSlidePersist( pMasterPersistPtr
);
284 FragmentHandlerRef
xMasterFragmentHandler( new SlideFragmentHandler( rFilter
, aMasterFragmentPath
, pMasterPersistPtr
, Master
) );
286 // set the correct theme
287 OUString aThemeFragmentPath
= xMasterFragmentHandler
->getFragmentPathFromFirstTypeFromOfficeDoc( "theme" );
288 if( !aThemeFragmentPath
.isEmpty() )
290 std::map
< OUString
, oox::drawingml::ThemePtr
>& rThemes( rFilter
.getThemes() );
291 std::map
< OUString
, oox::drawingml::ThemePtr
>::iterator
aIter2( rThemes
.find( aThemeFragmentPath
) );
292 if( aIter2
== rThemes
.end() )
294 oox::drawingml::ThemePtr
pThemePtr( new oox::drawingml::Theme() );
295 pMasterPersistPtr
->setTheme( pThemePtr
);
296 Reference
<xml::dom::XDocument
> xDoc
=
297 rFilter
.importFragment(aThemeFragmentPath
);
299 rFilter
.importFragment(
300 new ThemeFragmentHandler(
301 rFilter
, aThemeFragmentPath
, *pThemePtr
),
302 Reference
<xml::sax::XFastSAXSerializable
>(
305 rThemes
[ aThemeFragmentPath
] = pThemePtr
;
306 pThemePtr
->setFragment(xDoc
);
307 saveThemeToGrabBag(pThemePtr
, aThemeFragmentPath
);
311 pMasterPersistPtr
->setTheme( (*aIter2
).second
);
314 importSlide( xMasterFragmentHandler
, pMasterPersistPtr
);
315 rFilter
.importFragment( new LayoutFragmentHandler( rFilter
, aLayoutFragmentPath
, pMasterPersistPtr
) );
316 pMasterPersistPtr
->createBackground( rFilter
);
317 pMasterPersistPtr
->createXShapes( rFilter
);
322 // importing slide page
323 if (pMasterPersistPtr
.get()) {
324 pSlidePersistPtr
->setMasterPersist( pMasterPersistPtr
);
325 pSlidePersistPtr
->setTheme( pMasterPersistPtr
->getTheme() );
326 Reference
< drawing::XMasterPageTarget
> xMasterPageTarget( pSlidePersistPtr
->getPage(), UNO_QUERY
);
327 if( xMasterPageTarget
.is() )
328 xMasterPageTarget
->setMasterPage( pMasterPersistPtr
->getPage() );
330 rFilter
.getDrawPages().push_back( pSlidePersistPtr
);
331 rFilter
.setActualSlidePersist( pSlidePersistPtr
);
332 importSlide( xSlideFragmentHandler
, pSlidePersistPtr
);
333 pSlidePersistPtr
->createBackground( rFilter
);
334 pSlidePersistPtr
->createXShapes( rFilter
);
336 if(bImportNotesPage
) {
338 // now importing the notes page
339 OUString aNotesFragmentPath
= xSlideFragmentHandler
->getFragmentPathFromFirstTypeFromOfficeDoc( "notesSlide" );
340 if( !aNotesFragmentPath
.isEmpty() )
342 Reference
< XPresentationPage
> xPresentationPage( xSlide
, UNO_QUERY
);
343 if ( xPresentationPage
.is() )
345 Reference
< XDrawPage
> xNotesPage( xPresentationPage
->getNotesPage() );
346 if ( xNotesPage
.is() )
348 SlidePersistPtr
pNotesPersistPtr( new SlidePersist( rFilter
, false, true, xNotesPage
,
349 ShapePtr( new PPTShape( Slide
, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle
) );
350 FragmentHandlerRef
xNotesFragmentHandler( new SlideFragmentHandler( getFilter(), aNotesFragmentPath
, pNotesPersistPtr
, Slide
) );
351 rFilter
.getNotesPages().push_back( pNotesPersistPtr
);
352 rFilter
.setActualSlidePersist( pNotesPersistPtr
);
353 importSlide( xNotesFragmentHandler
, pNotesPersistPtr
);
354 pNotesPersistPtr
->createBackground( rFilter
);
355 pNotesPersistPtr
->createXShapes( rFilter
);
361 if( !mbCommentAuthorsRead
&& !aCommentFragmentPath
.isEmpty() )
363 // Comments are present and commentAuthors.xml has still not been read
364 mbCommentAuthorsRead
= true;
365 OUString aCommentAuthorsFragmentPath
= "ppt/commentAuthors.xml";
366 Reference
< XPresentationPage
> xPresentationPage( xSlide
, UNO_QUERY
);
367 Reference
< XDrawPage
> xCommentAuthorsPage( xPresentationPage
->getNotesPage() );
368 SlidePersistPtr
pCommentAuthorsPersistPtr(
369 new SlidePersist( rFilter
, false, true, xCommentAuthorsPage
,
372 Slide
, "com.sun.star.drawing.GroupShape" ) ),
374 FragmentHandlerRef
xCommentAuthorsFragmentHandler(
375 new SlideFragmentHandler( getFilter(),
376 aCommentAuthorsFragmentPath
,
377 pCommentAuthorsPersistPtr
,
380 getFilter().importFragment( xCommentAuthorsFragmentHandler
);
381 maAuthorList
.setValues( pCommentAuthorsPersistPtr
->getCommentAuthors() );
383 if( !aCommentFragmentPath
.isEmpty() )
385 Reference
< XPresentationPage
> xPresentationPage( xSlide
, UNO_QUERY
);
386 Reference
< XDrawPage
> xCommentsPage( xPresentationPage
->getNotesPage() );
387 SlidePersistPtr
pCommentsPersistPtr(
389 rFilter
, false, true, xCommentsPage
,
392 Slide
, "com.sun.star.drawing.GroupShape" ) ),
395 FragmentHandlerRef
xCommentsFragmentHandler(
396 new SlideFragmentHandler(
398 aCommentFragmentPath
,
401 pCommentsPersistPtr
->getCommentsList().cmLst
.clear();
402 getFilter().importFragment( xCommentsFragmentHandler
);
404 if (!pCommentsPersistPtr
->getCommentsList().cmLst
.empty())
406 //set comment chars for last comment on slide
407 SlideFragmentHandler
* comment_handler
=
408 dynamic_cast<SlideFragmentHandler
*>(xCommentsFragmentHandler
.get());
409 // some comments have no text -> set empty string as text to avoid
410 // crash (back() on empty vector is undefined) and losing other
411 // comment data that might be there (author, position, timestamp etc.)
412 pCommentsPersistPtr
->getCommentsList().cmLst
.back().setText(
413 comment_handler
->getCharVector().empty() ? "" :
414 comment_handler
->getCharVector().back() );
416 pCommentsPersistPtr
->getCommentAuthors().setValues(maAuthorList
);
418 //insert all comments from commentsList
419 for(int i
=0; i
<pCommentsPersistPtr
->getCommentsList().getSize(); i
++)
422 Comment aComment
= pCommentsPersistPtr
->getCommentsList().getCommentAtIndex(i
);
423 uno::Reference
< office::XAnnotationAccess
> xAnnotationAccess( xSlide
, UNO_QUERY_THROW
);
424 uno::Reference
< office::XAnnotation
> xAnnotation( xAnnotationAccess
->createAndInsertAnnotation() );
425 int nPosX
= aComment
.getIntX();
426 int nPosY
= aComment
.getIntY();
427 xAnnotation
->setPosition(
428 geometry::RealPoint2D(
429 ::oox::drawingml::convertEmuToHmm( nPosX
) * 15.87,
430 ::oox::drawingml::convertEmuToHmm( nPosY
) * 15.87 ) );
431 xAnnotation
->setAuthor( aComment
.getAuthor(maAuthorList
) );
432 xAnnotation
->setDateTime( aComment
.getDateTime() );
433 uno::Reference
< text::XText
> xText( xAnnotation
->getTextRange() );
434 xText
->setString( aComment
.get_text());
435 } catch( css::lang::IllegalArgumentException
& ) {}
440 catch( uno::Exception
& )
442 SAL_WARN( "oox", "oox::ppt::PresentationFragmentHandler::EndDocument(), "
443 "exception caught: " << comphelper::anyToString( cppu::getCaughtException() ) );
447 void PresentationFragmentHandler::finalizeImport()
449 PowerPointImport
& rFilter
= dynamic_cast< PowerPointImport
& >( getFilter() );
451 sal_Int32 nPageCount
= maSlidesVector
.size();
453 // we will take the FilterData property "PageRange" if available, otherwise full range is used
454 comphelper::SequenceAsHashMap
& rFilterData
= rFilter
.getFilterData();
456 // writing back the original PageCount of this document, it can be accessed from the XModel
457 // via getArgs after the import.
458 rFilterData
["OriginalPageCount"] <<= nPageCount
;
459 bool bImportNotesPages
= rFilterData
.getUnpackedValueOrDefault("ImportNotesPages", true);
460 OUString aPageRange
= rFilterData
.getUnpackedValueOrDefault("PageRange", OUString());
462 if( !aPageRange
.getLength() )
464 aPageRange
= OUStringBuffer()
465 .append( static_cast< sal_Int32
>( 1 ) )
467 .append( nPageCount
).makeStringAndClear();
470 StringRangeEnumerator
aRangeEnumerator( aPageRange
, 0, nPageCount
- 1 );
471 if (aRangeEnumerator
.size())
473 // todo: localized progress bar text
474 const Reference
< task::XStatusIndicator
>& rxStatusIndicator( getFilter().getStatusIndicator() );
475 if ( rxStatusIndicator
.is() )
476 rxStatusIndicator
->start( OUString(), 10000 );
480 int nPagesImported
= 0;
481 for (auto const& elem
: aRangeEnumerator
)
483 if ( rxStatusIndicator
.is() )
484 rxStatusIndicator
->setValue((nPagesImported
* 10000) / aRangeEnumerator
.size());
486 importSlide(elem
, !nPagesImported
, bImportNotesPages
);
489 ResolveTextFields( rFilter
);
491 catch( uno::Exception
& )
493 SAL_WARN( "oox", "oox::ppt::PresentationFragmentHandler::finalizeImport(), "
494 "exception caught: " << comphelper::anyToString( cppu::getCaughtException() ) );
496 // todo error handling;
497 if ( rxStatusIndicator
.is() )
498 rxStatusIndicator
->end();
501 // open the VBA project storage
502 OUString aVbaFragmentPath
= getFragmentPathFromFirstType(CREATE_MSOFFICE_RELATION_TYPE("vbaProject"));
503 if (!aVbaFragmentPath
.isEmpty())
505 uno::Reference
<io::XInputStream
> xInStrm
= getFilter().openInputStream(aVbaFragmentPath
);
508 StorageRef
xPrjStrg(new oox::ole::OleStorage(getFilter().getComponentContext(), xInStrm
, false));
509 getFilter().getVbaProject().importVbaProject(*xPrjStrg
);
515 ::oox::core::ContextHandlerRef
PresentationFragmentHandler::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
517 switch( aElementToken
)
519 case PPT_TOKEN( presentation
):
520 case PPT_TOKEN( sldMasterIdLst
):
521 case PPT_TOKEN( notesMasterIdLst
):
522 case PPT_TOKEN( sldIdLst
):
524 case PPT_TOKEN( sldMasterId
):
525 maSlideMasterVector
.push_back( rAttribs
.getString( R_TOKEN( id
), OUString() ) );
527 case PPT_TOKEN( sldId
):
528 maSlidesVector
.push_back( rAttribs
.getString( R_TOKEN( id
), OUString() ) );
530 case PPT_TOKEN( notesMasterId
):
531 maNotesMasterVector
.push_back( rAttribs
.getString( R_TOKEN( id
), OUString() ) );
533 case PPT_TOKEN( sldSz
):
534 maSlideSize
= GetSize2D( rAttribs
.getFastAttributeList() );
536 case PPT_TOKEN( notesSz
):
537 maNotesSize
= GetSize2D( rAttribs
.getFastAttributeList() );
539 case PPT_TOKEN( custShowLst
):
540 return new CustomShowListContext( *this, maCustomShowList
);
541 case PPT_TOKEN( defaultTextStyle
):
542 return new TextListStyleContext( *this, *mpTextListStyle
);
547 void PresentationFragmentHandler::importSlide( const FragmentHandlerRef
& rxSlideFragmentHandler
,
548 const SlidePersistPtr
& rSlidePersistPtr
)
550 Reference
< drawing::XDrawPage
> xSlide( rSlidePersistPtr
->getPage() );
551 SlidePersistPtr
pMasterPersistPtr( rSlidePersistPtr
->getMasterPersist() );
552 if ( pMasterPersistPtr
.get() )
554 // Setting "Layout" property adds extra title and outliner preset shapes to the master slide
555 Reference
< drawing::XDrawPage
> xMasterSlide(pMasterPersistPtr
->getPage());
556 const int nCount
= xMasterSlide
->getCount();
558 const OUString sLayout
= "Layout";
559 uno::Reference
< beans::XPropertySet
> xSet( xSlide
, uno::UNO_QUERY_THROW
);
560 xSet
->setPropertyValue( sLayout
, Any( pMasterPersistPtr
->getLayoutFromValueToken() ) );
562 while( nCount
< xMasterSlide
->getCount())
564 Reference
< drawing::XShape
> xShape
;
565 xMasterSlide
->getByIndex(xMasterSlide
->getCount()-1) >>= xShape
;
566 xMasterSlide
->remove(xShape
);
569 while( xSlide
->getCount() )
571 Reference
< drawing::XShape
> xShape
;
572 xSlide
->getByIndex(0) >>= xShape
;
573 xSlide
->remove( xShape
);
576 Reference
< XPropertySet
> xPropertySet( xSlide
, UNO_QUERY
);
577 if ( xPropertySet
.is() )
579 awt::Size
& rPageSize( rSlidePersistPtr
->isNotesPage() ? maNotesSize
: maSlideSize
);
580 xPropertySet
->setPropertyValue( "Width", Any( rPageSize
.Width
) );
581 xPropertySet
->setPropertyValue( "Height", Any( rPageSize
.Height
) );
583 oox::ppt::HeaderFooter
aHeaderFooter( rSlidePersistPtr
->getHeaderFooter() );
584 if ( !rSlidePersistPtr
->isMasterPage() )
585 aHeaderFooter
.mbSlideNumber
= aHeaderFooter
.mbHeader
= aHeaderFooter
.mbFooter
= aHeaderFooter
.mbDateTime
= false;
588 if ( rSlidePersistPtr
->isNotesPage() )
589 xPropertySet
->setPropertyValue( "IsHeaderVisible", Any( aHeaderFooter
.mbHeader
) );
590 xPropertySet
->setPropertyValue( "IsFooterVisible", Any( aHeaderFooter
.mbFooter
) );
591 xPropertySet
->setPropertyValue( "IsDateTimeVisible", Any( aHeaderFooter
.mbDateTime
) );
592 xPropertySet
->setPropertyValue( "IsPageNumberVisible", Any( aHeaderFooter
.mbSlideNumber
) );
594 catch( uno::Exception
& )
598 rSlidePersistPtr
->setPath( rxSlideFragmentHandler
->getFragmentPath() );
599 getFilter().importFragment( rxSlideFragmentHandler
);
604 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */