1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include "comphelper/anytostring.hxx" 29*cdf0e10cSrcweir #include "cppuhelper/exc_hlp.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/drawing/XMasterPagesSupplier.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPages.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/drawing/XMasterPageTarget.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/presentation/XPresentationPage.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/task/XStatusIndicator.hpp> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include "oox/drawingml/theme.hxx" 41*cdf0e10cSrcweir #include "oox/drawingml/drawingmltypes.hxx" 42*cdf0e10cSrcweir #include "oox/drawingml/themefragmenthandler.hxx" 43*cdf0e10cSrcweir #include "oox/drawingml/textliststylecontext.hxx" 44*cdf0e10cSrcweir #include "oox/ppt/pptshape.hxx" 45*cdf0e10cSrcweir #include "oox/ppt/presentationfragmenthandler.hxx" 46*cdf0e10cSrcweir #include "oox/ppt/slidefragmenthandler.hxx" 47*cdf0e10cSrcweir #include "oox/ppt/layoutfragmenthandler.hxx" 48*cdf0e10cSrcweir #include "oox/ppt/pptimport.hxx" 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir using rtl::OUString; 51*cdf0e10cSrcweir using namespace ::com::sun::star; 52*cdf0e10cSrcweir using namespace ::oox::core; 53*cdf0e10cSrcweir using namespace ::oox::drawingml; 54*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 55*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 56*cdf0e10cSrcweir using namespace ::com::sun::star::drawing; 57*cdf0e10cSrcweir using namespace ::com::sun::star::presentation; 58*cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax; 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir namespace oox { namespace ppt { 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir PresentationFragmentHandler::PresentationFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath ) throw() 63*cdf0e10cSrcweir : FragmentHandler( rFilter, rFragmentPath ) 64*cdf0e10cSrcweir , mpTextListStyle( new TextListStyle ) 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir TextParagraphPropertiesVector& rParagraphDefaulsVector( mpTextListStyle->getListStyle() ); 67*cdf0e10cSrcweir TextParagraphPropertiesVector::iterator aParagraphDefaultIter( rParagraphDefaulsVector.begin() ); 68*cdf0e10cSrcweir while( aParagraphDefaultIter != rParagraphDefaulsVector.end() ) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir // ppt is having zero bottom margin per default, whereas OOo is 0,5cm, 71*cdf0e10cSrcweir // so this attribute needs to be set always 72*cdf0e10cSrcweir (*aParagraphDefaultIter++)->getParaBottomMargin() = TextSpacing( 0 ); 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir PresentationFragmentHandler::~PresentationFragmentHandler() throw() 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir void PresentationFragmentHandler::startDocument() throw (SAXException, RuntimeException) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir void ResolveTextFields( XmlFilterBase& rFilter ) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir const oox::core::TextFieldStack& rTextFields = rFilter.getTextFieldStack(); 87*cdf0e10cSrcweir if ( rTextFields.size() ) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir Reference< frame::XModel > xModel( rFilter.getModel() ); 90*cdf0e10cSrcweir oox::core::TextFieldStack::const_iterator aIter( rTextFields.begin() ); 91*cdf0e10cSrcweir while( aIter != rTextFields.end() ) 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir const OUString sURL = CREATE_OUSTRING( "URL" ); 94*cdf0e10cSrcweir Reference< drawing::XDrawPagesSupplier > xDPS( xModel, uno::UNO_QUERY_THROW ); 95*cdf0e10cSrcweir Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY_THROW ); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir const oox::core::TextField& rTextField( *aIter++ ); 98*cdf0e10cSrcweir Reference< XPropertySet > xPropSet( rTextField.xTextField, UNO_QUERY ); 99*cdf0e10cSrcweir Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); 100*cdf0e10cSrcweir if ( xPropSetInfo->hasPropertyByName( sURL ) ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir rtl::OUString aURL; 103*cdf0e10cSrcweir if ( xPropSet->getPropertyValue( sURL ) >>= aURL ) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir const OUString sSlide = CREATE_OUSTRING( "#Slide " ); 106*cdf0e10cSrcweir const OUString sNotes = CREATE_OUSTRING( "#Notes " ); 107*cdf0e10cSrcweir sal_Bool bNotes = sal_False; 108*cdf0e10cSrcweir sal_Int32 nPageNumber = 0; 109*cdf0e10cSrcweir if ( aURL.match( sSlide ) ) 110*cdf0e10cSrcweir nPageNumber = aURL.copy( sSlide.getLength() ).toInt32(); 111*cdf0e10cSrcweir else if ( aURL.match( sNotes ) ) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir nPageNumber = aURL.copy( sNotes.getLength() ).toInt32(); 114*cdf0e10cSrcweir bNotes = sal_True; 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir if ( nPageNumber ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir try 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir Reference< XDrawPage > xDrawPage; 121*cdf0e10cSrcweir xDrawPages->getByIndex( nPageNumber - 1 ) >>= xDrawPage; 122*cdf0e10cSrcweir if ( bNotes ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir Reference< ::com::sun::star::presentation::XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW ); 125*cdf0e10cSrcweir xDrawPage = xPresentationPage->getNotesPage(); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir Reference< container::XNamed > xNamed( xDrawPage, UNO_QUERY_THROW ); 128*cdf0e10cSrcweir aURL = CREATE_OUSTRING( "#" ).concat( xNamed->getName() ); 129*cdf0e10cSrcweir xPropSet->setPropertyValue( sURL, Any( aURL ) ); 130*cdf0e10cSrcweir Reference< text::XTextContent > xContent( rTextField.xTextField, UNO_QUERY); 131*cdf0e10cSrcweir Reference< text::XTextRange > xTextRange( rTextField.xTextCursor, UNO_QUERY ); 132*cdf0e10cSrcweir rTextField.xText->insertTextContent( xTextRange, xContent, sal_True ); 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir catch( uno::Exception& ) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir void PresentationFragmentHandler::endDocument() throw (SAXException, RuntimeException) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir // todo: localized progress bar text 147*cdf0e10cSrcweir const Reference< task::XStatusIndicator >& rxStatusIndicator( getFilter().getStatusIndicator() ); 148*cdf0e10cSrcweir if ( rxStatusIndicator.is() ) 149*cdf0e10cSrcweir rxStatusIndicator->start( rtl::OUString(), 10000 ); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir try 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() ); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir Reference< frame::XModel > xModel( rFilter.getModel() ); 156*cdf0e10cSrcweir Reference< drawing::XDrawPage > xSlide; 157*cdf0e10cSrcweir sal_uInt32 nSlide; 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir // importing slide pages and its corresponding notes page 160*cdf0e10cSrcweir Reference< drawing::XDrawPagesSupplier > xDPS( xModel, uno::UNO_QUERY_THROW ); 161*cdf0e10cSrcweir Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY_THROW ); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir for( nSlide = 0; nSlide < maSlidesVector.size(); nSlide++ ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir if ( rxStatusIndicator.is() ) 166*cdf0e10cSrcweir rxStatusIndicator->setValue( ( nSlide * 10000 ) / maSlidesVector.size() ); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir if( nSlide == 0 ) 169*cdf0e10cSrcweir xDrawPages->getByIndex( 0 ) >>= xSlide; 170*cdf0e10cSrcweir else 171*cdf0e10cSrcweir xSlide = xDrawPages->insertNewByIndex( nSlide ); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir OUString aSlideFragmentPath = getFragmentPathFromRelId( maSlidesVector[ nSlide ] ); 174*cdf0e10cSrcweir if( aSlideFragmentPath.getLength() > 0 ) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir SlidePersistPtr pMasterPersistPtr; 177*cdf0e10cSrcweir SlidePersistPtr pSlidePersistPtr( new SlidePersist( rFilter, sal_False, sal_False, xSlide, 178*cdf0e10cSrcweir ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) ); 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir FragmentHandlerRef xSlideFragmentHandler( new SlideFragmentHandler( rFilter, aSlideFragmentPath, pSlidePersistPtr, Slide ) ); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir // importing the corresponding masterpage/layout 183*cdf0e10cSrcweir OUString aLayoutFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "slideLayout" ) ); 184*cdf0e10cSrcweir if ( aLayoutFragmentPath.getLength() > 0 ) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir // importing layout 187*cdf0e10cSrcweir RelationsRef xLayoutRelations = rFilter.importRelations( aLayoutFragmentPath ); 188*cdf0e10cSrcweir OUString aMasterFragmentPath = xLayoutRelations->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "slideMaster" ) ); 189*cdf0e10cSrcweir if( aMasterFragmentPath.getLength() ) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir // check if the corresponding masterpage+layout has already been imported 192*cdf0e10cSrcweir std::vector< SlidePersistPtr >& rMasterPages( rFilter.getMasterPages() ); 193*cdf0e10cSrcweir std::vector< SlidePersistPtr >::iterator aIter( rMasterPages.begin() ); 194*cdf0e10cSrcweir while( aIter != rMasterPages.end() ) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir if ( ( (*aIter)->getPath() == aMasterFragmentPath ) && ( (*aIter)->getLayoutPath() == aLayoutFragmentPath ) ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir pMasterPersistPtr = *aIter; 199*cdf0e10cSrcweir break; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir aIter++; 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir if ( aIter == rMasterPages.end() ) 204*cdf0e10cSrcweir { // masterpersist not found, we have to load it 205*cdf0e10cSrcweir Reference< drawing::XDrawPage > xMasterPage; 206*cdf0e10cSrcweir Reference< drawing::XMasterPagesSupplier > xMPS( xModel, uno::UNO_QUERY_THROW ); 207*cdf0e10cSrcweir Reference< drawing::XDrawPages > xMasterPages( xMPS->getMasterPages(), uno::UNO_QUERY_THROW ); 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir if( !(rFilter.getMasterPages().size() )) 210*cdf0e10cSrcweir xMasterPages->getByIndex( 0 ) >>= xMasterPage; 211*cdf0e10cSrcweir else 212*cdf0e10cSrcweir xMasterPage = xMasterPages->insertNewByIndex( xMasterPages->getCount() ); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir pMasterPersistPtr = SlidePersistPtr( new SlidePersist( rFilter, sal_True, sal_False, xMasterPage, 215*cdf0e10cSrcweir ShapePtr( new PPTShape( Master, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) ); 216*cdf0e10cSrcweir pMasterPersistPtr->setLayoutPath( aLayoutFragmentPath ); 217*cdf0e10cSrcweir rFilter.getMasterPages().push_back( pMasterPersistPtr ); 218*cdf0e10cSrcweir rFilter.setActualSlidePersist( pMasterPersistPtr ); 219*cdf0e10cSrcweir FragmentHandlerRef xMasterFragmentHandler( new SlideFragmentHandler( rFilter, aMasterFragmentPath, pMasterPersistPtr, Master ) ); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir // set the correct theme 222*cdf0e10cSrcweir OUString aThemeFragmentPath = xMasterFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "theme" ) ); 223*cdf0e10cSrcweir if( aThemeFragmentPath.getLength() > 0 ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir std::map< OUString, oox::drawingml::ThemePtr >& rThemes( rFilter.getThemes() ); 226*cdf0e10cSrcweir std::map< OUString, oox::drawingml::ThemePtr >::iterator aIter2( rThemes.find( aThemeFragmentPath ) ); 227*cdf0e10cSrcweir if( aIter2 == rThemes.end() ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir oox::drawingml::ThemePtr pThemePtr( new oox::drawingml::Theme() ); 230*cdf0e10cSrcweir pMasterPersistPtr->setTheme( pThemePtr ); 231*cdf0e10cSrcweir rFilter.importFragment( new ThemeFragmentHandler( rFilter, aThemeFragmentPath, *pThemePtr ) ); 232*cdf0e10cSrcweir rThemes[ aThemeFragmentPath ] = pThemePtr; 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir else 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir pMasterPersistPtr->setTheme( (*aIter2).second ); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir importSlide( xMasterFragmentHandler, pMasterPersistPtr ); 240*cdf0e10cSrcweir rFilter.importFragment( new LayoutFragmentHandler( rFilter, aLayoutFragmentPath, pMasterPersistPtr ) ); 241*cdf0e10cSrcweir pMasterPersistPtr->createBackground( rFilter ); 242*cdf0e10cSrcweir pMasterPersistPtr->createXShapes( rFilter ); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir // importing slide page 248*cdf0e10cSrcweir pSlidePersistPtr->setMasterPersist( pMasterPersistPtr ); 249*cdf0e10cSrcweir pSlidePersistPtr->setTheme( pMasterPersistPtr->getTheme() ); 250*cdf0e10cSrcweir Reference< drawing::XMasterPageTarget > xMasterPageTarget( pSlidePersistPtr->getPage(), UNO_QUERY ); 251*cdf0e10cSrcweir if( xMasterPageTarget.is() ) 252*cdf0e10cSrcweir xMasterPageTarget->setMasterPage( pMasterPersistPtr->getPage() ); 253*cdf0e10cSrcweir rFilter.getDrawPages().push_back( pSlidePersistPtr ); 254*cdf0e10cSrcweir rFilter.setActualSlidePersist( pSlidePersistPtr ); 255*cdf0e10cSrcweir importSlide( xSlideFragmentHandler, pSlidePersistPtr ); 256*cdf0e10cSrcweir pSlidePersistPtr->createBackground( rFilter ); 257*cdf0e10cSrcweir pSlidePersistPtr->createXShapes( rFilter ); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir // now importing the notes page 260*cdf0e10cSrcweir OUString aNotesFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "notesSlide" ) ); 261*cdf0e10cSrcweir if( aNotesFragmentPath.getLength() > 0 ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir Reference< XPresentationPage > xPresentationPage( xSlide, UNO_QUERY ); 264*cdf0e10cSrcweir if ( xPresentationPage.is() ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() ); 267*cdf0e10cSrcweir if ( xNotesPage.is() ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir SlidePersistPtr pNotesPersistPtr( new SlidePersist( rFilter, sal_False, sal_True, xNotesPage, 270*cdf0e10cSrcweir ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) ); 271*cdf0e10cSrcweir FragmentHandlerRef xNotesFragmentHandler( new SlideFragmentHandler( getFilter(), aNotesFragmentPath, pNotesPersistPtr, Slide ) ); 272*cdf0e10cSrcweir rFilter.getNotesPages().push_back( pNotesPersistPtr ); 273*cdf0e10cSrcweir rFilter.setActualSlidePersist( pNotesPersistPtr ); 274*cdf0e10cSrcweir importSlide( xNotesFragmentHandler, pNotesPersistPtr ); 275*cdf0e10cSrcweir pNotesPersistPtr->createBackground( rFilter ); 276*cdf0e10cSrcweir pNotesPersistPtr->createXShapes( rFilter ); 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir ResolveTextFields( rFilter ); 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir catch( uno::Exception& ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir OSL_ENSURE( false, 287*cdf0e10cSrcweir (rtl::OString("oox::ppt::PresentationFragmentHandler::EndDocument(), " 288*cdf0e10cSrcweir "exception caught: ") + 289*cdf0e10cSrcweir rtl::OUStringToOString( 290*cdf0e10cSrcweir comphelper::anyToString( cppu::getCaughtException() ), 291*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 )).getStr() ); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir // todo error handling; 296*cdf0e10cSrcweir if ( rxStatusIndicator.is() ) 297*cdf0e10cSrcweir rxStatusIndicator->end(); 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir // CT_Presentation 301*cdf0e10cSrcweir Reference< XFastContextHandler > PresentationFragmentHandler::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 304*cdf0e10cSrcweir switch( aElementToken ) 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir case PPT_TOKEN( presentation ): 307*cdf0e10cSrcweir case PPT_TOKEN( sldMasterIdLst ): 308*cdf0e10cSrcweir case PPT_TOKEN( notesMasterIdLst ): 309*cdf0e10cSrcweir case PPT_TOKEN( sldIdLst ): 310*cdf0e10cSrcweir break; 311*cdf0e10cSrcweir case PPT_TOKEN( sldMasterId ): 312*cdf0e10cSrcweir maSlideMasterVector.push_back( xAttribs->getOptionalValue( R_TOKEN( id ) ) ); 313*cdf0e10cSrcweir break; 314*cdf0e10cSrcweir case PPT_TOKEN( sldId ): 315*cdf0e10cSrcweir maSlidesVector.push_back( xAttribs->getOptionalValue( R_TOKEN( id ) ) ); 316*cdf0e10cSrcweir break; 317*cdf0e10cSrcweir case PPT_TOKEN( notesMasterId ): 318*cdf0e10cSrcweir maNotesMasterVector.push_back( xAttribs->getOptionalValue(R_TOKEN( id ) ) ); 319*cdf0e10cSrcweir break; 320*cdf0e10cSrcweir case PPT_TOKEN( sldSz ): 321*cdf0e10cSrcweir maSlideSize = GetSize2D( xAttribs ); 322*cdf0e10cSrcweir break; 323*cdf0e10cSrcweir case PPT_TOKEN( notesSz ): 324*cdf0e10cSrcweir maNotesSize = GetSize2D( xAttribs ); 325*cdf0e10cSrcweir break; 326*cdf0e10cSrcweir case PPT_TOKEN( custShowLst ): 327*cdf0e10cSrcweir xRet.set( new CustomShowListContext( *this, maCustomShowList ) ); 328*cdf0e10cSrcweir break; 329*cdf0e10cSrcweir case PPT_TOKEN( defaultTextStyle ): 330*cdf0e10cSrcweir xRet.set( new TextListStyleContext( *this, *mpTextListStyle ) ); 331*cdf0e10cSrcweir break; 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir if ( !xRet.is() ) 334*cdf0e10cSrcweir xRet = getFastContextHandler(); 335*cdf0e10cSrcweir return xRet; 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir bool PresentationFragmentHandler::importSlide( const FragmentHandlerRef& rxSlideFragmentHandler, 339*cdf0e10cSrcweir const SlidePersistPtr pSlidePersistPtr ) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir Reference< drawing::XDrawPage > xSlide( pSlidePersistPtr->getPage() ); 342*cdf0e10cSrcweir SlidePersistPtr pMasterPersistPtr( pSlidePersistPtr->getMasterPersist() ); 343*cdf0e10cSrcweir if ( pMasterPersistPtr.get() ) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir const OUString sLayout = CREATE_OUSTRING( "Layout" ); 346*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xSet( xSlide, uno::UNO_QUERY_THROW ); 347*cdf0e10cSrcweir xSet->setPropertyValue( sLayout, Any( pMasterPersistPtr->getLayoutFromValueToken() ) ); 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir while( xSlide->getCount() ) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir Reference< drawing::XShape > xShape; 352*cdf0e10cSrcweir xSlide->getByIndex(0) >>= xShape; 353*cdf0e10cSrcweir xSlide->remove( xShape ); 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir Reference< XPropertySet > xPropertySet( xSlide, UNO_QUERY ); 357*cdf0e10cSrcweir if ( xPropertySet.is() ) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir static const OUString sWidth = CREATE_OUSTRING( "Width" ); 360*cdf0e10cSrcweir static const OUString sHeight = CREATE_OUSTRING( "Height" ); 361*cdf0e10cSrcweir awt::Size& rPageSize( pSlidePersistPtr->isNotesPage() ? maNotesSize : maSlideSize ); 362*cdf0e10cSrcweir xPropertySet->setPropertyValue( sWidth, Any( rPageSize.Width ) ); 363*cdf0e10cSrcweir xPropertySet->setPropertyValue( sHeight, Any( rPageSize.Height ) ); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir oox::ppt::HeaderFooter aHeaderFooter( pSlidePersistPtr->getHeaderFooter() ); 366*cdf0e10cSrcweir if ( !pSlidePersistPtr->isMasterPage() ) 367*cdf0e10cSrcweir aHeaderFooter.mbSlideNumber = aHeaderFooter.mbHeader = aHeaderFooter.mbFooter = aHeaderFooter.mbDateTime = sal_False; 368*cdf0e10cSrcweir try 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir static const OUString sIsHeaderVisible = CREATE_OUSTRING( "IsHeaderVisible" ); 371*cdf0e10cSrcweir static const OUString sIsFooterVisible = CREATE_OUSTRING( "IsFooterVisible" ); 372*cdf0e10cSrcweir static const OUString sIsDateTimeVisible = CREATE_OUSTRING( "IsDateTimeVisible" ); 373*cdf0e10cSrcweir static const OUString sIsPageNumberVisible = CREATE_OUSTRING( "IsPageNumberVisible" ); 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir if ( pSlidePersistPtr->isNotesPage() ) 376*cdf0e10cSrcweir xPropertySet->setPropertyValue( sIsHeaderVisible, Any( aHeaderFooter.mbHeader ) ); 377*cdf0e10cSrcweir xPropertySet->setPropertyValue( sIsFooterVisible, Any( aHeaderFooter.mbFooter ) ); 378*cdf0e10cSrcweir xPropertySet->setPropertyValue( sIsDateTimeVisible, Any( aHeaderFooter.mbDateTime ) ); 379*cdf0e10cSrcweir xPropertySet->setPropertyValue( sIsPageNumberVisible, Any( aHeaderFooter.mbSlideNumber ) ); 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir catch( uno::Exception& ) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir pSlidePersistPtr->setPath( rxSlideFragmentHandler->getFragmentPath() ); 386*cdf0e10cSrcweir return getFilter().importFragment( rxSlideFragmentHandler ); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir } } 390*cdf0e10cSrcweir 391