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/beans/XMultiPropertySet.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include "oox/helper/propertyset.hxx" 35*cdf0e10cSrcweir #include "oox/core/xmlfilterbase.hxx" 36*cdf0e10cSrcweir #include "headerfootercontext.hxx" 37*cdf0e10cSrcweir #include "oox/ppt/backgroundproperties.hxx" 38*cdf0e10cSrcweir #include "oox/ppt/slidefragmenthandler.hxx" 39*cdf0e10cSrcweir #include "oox/ppt/slidetimingcontext.hxx" 40*cdf0e10cSrcweir #include "oox/ppt/slidetransitioncontext.hxx" 41*cdf0e10cSrcweir #include "oox/ppt/slidemastertextstylescontext.hxx" 42*cdf0e10cSrcweir #include "oox/ppt/pptshapegroupcontext.hxx" 43*cdf0e10cSrcweir #include "oox/ppt/pptshape.hxx" 44*cdf0e10cSrcweir #include "oox/vml/vmldrawing.hxx" 45*cdf0e10cSrcweir #include "oox/vml/vmldrawingfragment.hxx" 46*cdf0e10cSrcweir #include "oox/drawingml/clrschemecontext.hxx" 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir using rtl::OUString; 50*cdf0e10cSrcweir using namespace ::com::sun::star; 51*cdf0e10cSrcweir using namespace ::oox::core; 52*cdf0e10cSrcweir using namespace ::oox::drawingml; 53*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 54*cdf0e10cSrcweir using namespace ::com::sun::star::drawing; 55*cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax; 56*cdf0e10cSrcweir using namespace ::com::sun::star::container; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir namespace oox { namespace ppt { 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir SlideFragmentHandler::SlideFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath, SlidePersistPtr pPersistPtr, const ShapeLocation eShapeLocation ) throw() 61*cdf0e10cSrcweir : FragmentHandler( rFilter, rFragmentPath ) 62*cdf0e10cSrcweir , mpSlidePersistPtr( pPersistPtr ) 63*cdf0e10cSrcweir , meShapeLocation( eShapeLocation ) 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir OUString aVMLDrawingFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "vmlDrawing" ) ); 66*cdf0e10cSrcweir if( aVMLDrawingFragmentPath.getLength() > 0 ) 67*cdf0e10cSrcweir getFilter().importFragment( new oox::vml::DrawingFragment( 68*cdf0e10cSrcweir getFilter(), aVMLDrawingFragmentPath, *pPersistPtr->getDrawing() ) ); 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir SlideFragmentHandler::~SlideFragmentHandler() throw() 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir // convert and insert all VML shapes (mostly form controls) 74*cdf0e10cSrcweir mpSlidePersistPtr->getDrawing()->convertAndInsert(); 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir Reference< XFastContextHandler > SlideFragmentHandler::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 80*cdf0e10cSrcweir AttributeList aAttribs( xAttribs ); 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir switch( aElementToken ) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir case PPT_TOKEN( sldMaster ): // CT_SlideMaster 85*cdf0e10cSrcweir case PPT_TOKEN( handoutMaster ): // CT_HandoutMaster 86*cdf0e10cSrcweir case PPT_TOKEN( sld ): // CT_CommonSlideData 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir AttributeList attribs( xAttribs ); 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir Reference< XDrawPage > xSlide( mpSlidePersistPtr->getPage() ); 91*cdf0e10cSrcweir PropertyMap aPropMap; 92*cdf0e10cSrcweir PropertySet aSlideProp( xSlide ); 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir aPropMap[ PROP_Visible ] = Any( attribs.getBool( XML_show, sal_True ) ); 95*cdf0e10cSrcweir aSlideProp.setProperties( aPropMap ); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir break; 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir case PPT_TOKEN( notes ): // CT_NotesSlide 100*cdf0e10cSrcweir case PPT_TOKEN( notesMaster ): // CT_NotesMaster 101*cdf0e10cSrcweir break; 102*cdf0e10cSrcweir case PPT_TOKEN( cSld ): // CT_CommonSlideData 103*cdf0e10cSrcweir maSlideName = xAttribs->getOptionalValue(XML_name); 104*cdf0e10cSrcweir break; 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir case PPT_TOKEN( spTree ): // CT_GroupShape 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir xRet.set( new PPTShapeGroupContext( 109*cdf0e10cSrcweir *this, mpSlidePersistPtr, meShapeLocation, mpSlidePersistPtr->getShapes(), 110*cdf0e10cSrcweir oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) ) ) ); 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir break; 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir case PPT_TOKEN( controls ): 115*cdf0e10cSrcweir xRet = getFastContextHandler(); 116*cdf0e10cSrcweir break; 117*cdf0e10cSrcweir case PPT_TOKEN( control ): 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir ::oox::vml::ControlInfo aInfo; 120*cdf0e10cSrcweir aInfo.setShapeId( aAttribs.getInteger( XML_spid, 0 ) ); 121*cdf0e10cSrcweir aInfo.maFragmentPath = getFragmentPathFromRelId( aAttribs.getString( R_TOKEN( id ), OUString() ) ); 122*cdf0e10cSrcweir aInfo.maName = aAttribs.getXString( XML_name, OUString() ); 123*cdf0e10cSrcweir mpSlidePersistPtr->getDrawing()->registerControl( aInfo ); 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir return xRet; 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir case PPT_TOKEN( timing ): // CT_SlideTiming 128*cdf0e10cSrcweir xRet.set( new SlideTimingContext( *this, mpSlidePersistPtr->getTimeNodeList() ) ); 129*cdf0e10cSrcweir break; 130*cdf0e10cSrcweir case PPT_TOKEN( transition ): // CT_SlideTransition 131*cdf0e10cSrcweir xRet.set( new SlideTransitionContext( *this, xAttribs, maSlideProperties ) ); 132*cdf0e10cSrcweir break; 133*cdf0e10cSrcweir case PPT_TOKEN( hf ): 134*cdf0e10cSrcweir xRet.set( new HeaderFooterContext( *this, xAttribs, mpSlidePersistPtr->getHeaderFooter() ) ); 135*cdf0e10cSrcweir break; 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir // BackgroundGroup 138*cdf0e10cSrcweir case PPT_TOKEN( bgPr ): // CT_BackgroundProperties 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir FillPropertiesPtr pFillPropertiesPtr( new FillProperties ); 141*cdf0e10cSrcweir xRet.set( new BackgroundPropertiesContext( *this, *pFillPropertiesPtr ) ); 142*cdf0e10cSrcweir mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr ); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir break; 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir case PPT_TOKEN( bgRef ): // a:CT_StyleMatrixReference 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir FillPropertiesPtr pFillPropertiesPtr( new FillProperties( 149*cdf0e10cSrcweir *mpSlidePersistPtr->getTheme()->getFillStyle( xAttribs->getOptionalValue( XML_idx ).toInt32() ) ) ); 150*cdf0e10cSrcweir xRet.set( new ColorContext( *this, mpSlidePersistPtr->getBackgroundColor() ) ); 151*cdf0e10cSrcweir mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr ); 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir break; 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir case PPT_TOKEN( clrMap ): // CT_ColorMapping 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir oox::drawingml::ClrMapPtr pClrMapPtr( new oox::drawingml::ClrMap() ); 158*cdf0e10cSrcweir xRet.set( new oox::drawingml::clrMapContext( *this, xAttribs, *pClrMapPtr ) ); 159*cdf0e10cSrcweir mpSlidePersistPtr->setClrMap( pClrMapPtr ); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir break; 162*cdf0e10cSrcweir case PPT_TOKEN( clrMapOvr ): // CT_ColorMappingOverride 163*cdf0e10cSrcweir case PPT_TOKEN( sldLayoutIdLst ): // CT_SlideLayoutIdList 164*cdf0e10cSrcweir break; 165*cdf0e10cSrcweir case PPT_TOKEN( txStyles ): // CT_SlideMasterTextStyles 166*cdf0e10cSrcweir xRet.set( new SlideMasterTextStylesContext( *this, mpSlidePersistPtr ) ); 167*cdf0e10cSrcweir break; 168*cdf0e10cSrcweir case PPT_TOKEN( custDataLst ): // CT_CustomerDataList 169*cdf0e10cSrcweir case PPT_TOKEN( tagLst ): // CT_TagList 170*cdf0e10cSrcweir break; 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir if( !xRet.is() ) 174*cdf0e10cSrcweir xRet = getFastContextHandler(); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir return xRet; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir void SAL_CALL SlideFragmentHandler::endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir try 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir Reference< XDrawPage > xSlide( mpSlidePersistPtr->getPage() ); 184*cdf0e10cSrcweir PropertySet aSlideProp( xSlide ); 185*cdf0e10cSrcweir aSlideProp.setProperties( maSlideProperties ); 186*cdf0e10cSrcweir if ( maSlideName.getLength() ) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir Reference< XNamed > xNamed( xSlide, UNO_QUERY ); 189*cdf0e10cSrcweir if( xNamed.is() ) 190*cdf0e10cSrcweir xNamed->setName( maSlideName ); 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir catch( uno::Exception& ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir OSL_ENSURE( false, 196*cdf0e10cSrcweir (rtl::OString("oox::ppt::SlideFragmentHandler::EndElement(), " 197*cdf0e10cSrcweir "exception caught: ") + 198*cdf0e10cSrcweir rtl::OUStringToOString( 199*cdf0e10cSrcweir comphelper::anyToString( cppu::getCaughtException() ), 200*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 )).getStr() ); 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir } } 205*cdf0e10cSrcweir 206