1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "timetargetelementcontext.hxx" 29 30 #include "comphelper/anytostring.hxx" 31 #include "cppuhelper/exc_hlp.hxx" 32 #include <osl/diagnose.h> 33 34 #include <com/sun/star/uno/Any.hxx> 35 36 #include "oox/helper/attributelist.hxx" 37 #include "oox/drawingml/embeddedwavaudiofile.hxx" 38 39 using namespace ::com::sun::star::uno; 40 using namespace ::com::sun::star::xml::sax; 41 using namespace ::oox::core; 42 43 using ::rtl::OUString; 44 45 namespace oox { namespace ppt { 46 47 48 49 // CT_TLShapeTargetElement 50 class ShapeTargetElementContext 51 : public ContextHandler 52 { 53 public: 54 ShapeTargetElementContext( ContextHandler& rParent, ShapeTargetElement & aValue ) 55 : ContextHandler( rParent ) 56 , bTargetSet(false) 57 , maShapeTarget(aValue) 58 { 59 } 60 virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, 61 const Reference< XFastAttributeList >& xAttribs ) 62 throw ( SAXException, RuntimeException ) 63 { 64 Reference< XFastContextHandler > xRet; 65 66 switch( aElementToken ) 67 { 68 case PPT_TOKEN( bg ): 69 bTargetSet = true; 70 maShapeTarget.mnType = XML_bg; 71 break; 72 case PPT_TOKEN( txEl ): 73 bTargetSet = true; 74 maShapeTarget.mnType = XML_txEl; 75 break; 76 case PPT_TOKEN( subSp ): 77 bTargetSet = true; 78 maShapeTarget.mnType = XML_subSp; 79 maShapeTarget.msSubShapeId = xAttribs->getOptionalValue( XML_spid ); 80 break; 81 case PPT_TOKEN( graphicEl ): 82 case PPT_TOKEN( oleChartEl ): 83 bTargetSet = true; 84 // TODO 85 break; 86 case PPT_TOKEN( charRg ): 87 case PPT_TOKEN( pRg ): 88 if( bTargetSet && maShapeTarget.mnType == XML_txEl ) 89 { 90 maShapeTarget.mnRangeType = getBaseToken( aElementToken ); 91 maShapeTarget.maRange = drawingml::GetIndexRange( xAttribs ); 92 } 93 break; 94 default: 95 break; 96 } 97 if( !xRet.is() ) 98 xRet.set( this ); 99 return xRet; 100 } 101 102 private: 103 bool bTargetSet; 104 ShapeTargetElement & maShapeTarget; 105 }; 106 107 108 109 TimeTargetElementContext::TimeTargetElementContext( ContextHandler& rParent, const AnimTargetElementPtr & pValue ) 110 : ContextHandler( rParent ), 111 mpTarget( pValue ) 112 { 113 OSL_ENSURE( mpTarget, "no valid target passed" ); 114 } 115 116 117 TimeTargetElementContext::~TimeTargetElementContext( ) throw( ) 118 { 119 } 120 121 void SAL_CALL TimeTargetElementContext::endFastElement( sal_Int32 /*aElement*/ ) throw ( SAXException, RuntimeException) 122 { 123 } 124 125 Reference< XFastContextHandler > SAL_CALL TimeTargetElementContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) 126 { 127 Reference< XFastContextHandler > xRet; 128 129 switch( aElementToken ) 130 { 131 case PPT_TOKEN( inkTgt ): 132 { 133 mpTarget->mnType = XML_inkTgt; 134 OUString aId = xAttribs->getOptionalValue( XML_spid ); 135 if( aId.getLength() ) 136 { 137 mpTarget->msValue = aId; 138 } 139 break; 140 } 141 case PPT_TOKEN( sldTgt ): 142 mpTarget->mnType = XML_sldTgt; 143 break; 144 case PPT_TOKEN( sndTgt ): 145 { 146 mpTarget->mnType = XML_sndTgt; 147 drawingml::EmbeddedWAVAudioFile aAudio; 148 drawingml::getEmbeddedWAVAudioFile( getRelations(), xAttribs, aAudio); 149 150 OUString sSndName = ( aAudio.mbBuiltIn ? aAudio.msName : aAudio.msEmbed ); 151 mpTarget->msValue = sSndName; 152 break; 153 } 154 case PPT_TOKEN( spTgt ): 155 { 156 mpTarget->mnType = XML_spTgt; 157 OUString aId = xAttribs->getOptionalValue( XML_spid ); 158 mpTarget->msValue = aId; 159 xRet.set( new ShapeTargetElementContext( *this, mpTarget->maShapeTarget ) ); 160 break; 161 } 162 default: 163 OSL_TRACE( "OOX: unhandled tag %ld in TL_TimeTargetElement.", getBaseToken( aElementToken ) ); 164 break; 165 } 166 167 if( !xRet.is() ) 168 xRet.set( this ); 169 170 return xRet; 171 } 172 173 174 } } 175