1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include "timetargetelementcontext.hxx" 25 26 #include "comphelper/anytostring.hxx" 27 #include "cppuhelper/exc_hlp.hxx" 28 #include <osl/diagnose.h> 29 30 #include <com/sun/star/uno/Any.hxx> 31 32 #include "oox/helper/attributelist.hxx" 33 #include "oox/drawingml/embeddedwavaudiofile.hxx" 34 35 using namespace ::com::sun::star::uno; 36 using namespace ::com::sun::star::xml::sax; 37 using namespace ::oox::core; 38 39 using ::rtl::OUString; 40 41 namespace oox { namespace ppt { 42 43 44 45 // CT_TLShapeTargetElement 46 class ShapeTargetElementContext 47 : public ContextHandler 48 { 49 public: 50 ShapeTargetElementContext( ContextHandler& rParent, ShapeTargetElement & aValue ) 51 : ContextHandler( rParent ) 52 , bTargetSet(false) 53 , maShapeTarget(aValue) 54 { 55 } 56 virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, 57 const Reference< XFastAttributeList >& xAttribs ) 58 { 59 Reference< XFastContextHandler > xRet; 60 61 switch( aElementToken ) 62 { 63 case PPT_TOKEN( bg ): 64 bTargetSet = true; 65 maShapeTarget.mnType = XML_bg; 66 break; 67 case PPT_TOKEN( txEl ): 68 bTargetSet = true; 69 maShapeTarget.mnType = XML_txEl; 70 break; 71 case PPT_TOKEN( subSp ): 72 bTargetSet = true; 73 maShapeTarget.mnType = XML_subSp; 74 maShapeTarget.msSubShapeId = xAttribs->getOptionalValue( XML_spid ); 75 break; 76 case PPT_TOKEN( graphicEl ): 77 case PPT_TOKEN( oleChartEl ): 78 bTargetSet = true; 79 // TODO 80 break; 81 case PPT_TOKEN( charRg ): 82 case PPT_TOKEN( pRg ): 83 if( bTargetSet && maShapeTarget.mnType == XML_txEl ) 84 { 85 maShapeTarget.mnRangeType = getBaseToken( aElementToken ); 86 maShapeTarget.maRange = drawingml::GetIndexRange( xAttribs ); 87 } 88 break; 89 default: 90 break; 91 } 92 if( !xRet.is() ) 93 xRet.set( this ); 94 return xRet; 95 } 96 97 private: 98 bool bTargetSet; 99 ShapeTargetElement & maShapeTarget; 100 }; 101 102 103 104 TimeTargetElementContext::TimeTargetElementContext( ContextHandler& rParent, const AnimTargetElementPtr & pValue ) 105 : ContextHandler( rParent ), 106 mpTarget( pValue ) 107 { 108 OSL_ENSURE( mpTarget, "no valid target passed" ); 109 } 110 111 112 TimeTargetElementContext::~TimeTargetElementContext( ) throw( ) 113 { 114 } 115 116 void SAL_CALL TimeTargetElementContext::endFastElement( sal_Int32 /*aElement*/ ) 117 { 118 } 119 120 Reference< XFastContextHandler > SAL_CALL TimeTargetElementContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) 121 { 122 Reference< XFastContextHandler > xRet; 123 124 switch( aElementToken ) 125 { 126 case PPT_TOKEN( inkTgt ): 127 { 128 mpTarget->mnType = XML_inkTgt; 129 OUString aId = xAttribs->getOptionalValue( XML_spid ); 130 if( aId.getLength() ) 131 { 132 mpTarget->msValue = aId; 133 } 134 break; 135 } 136 case PPT_TOKEN( sldTgt ): 137 mpTarget->mnType = XML_sldTgt; 138 break; 139 case PPT_TOKEN( sndTgt ): 140 { 141 mpTarget->mnType = XML_sndTgt; 142 drawingml::EmbeddedWAVAudioFile aAudio; 143 drawingml::getEmbeddedWAVAudioFile( getRelations(), xAttribs, aAudio); 144 145 OUString sSndName = ( aAudio.mbBuiltIn ? aAudio.msName : aAudio.msEmbed ); 146 mpTarget->msValue = sSndName; 147 break; 148 } 149 case PPT_TOKEN( spTgt ): 150 { 151 mpTarget->mnType = XML_spTgt; 152 OUString aId = xAttribs->getOptionalValue( XML_spid ); 153 mpTarget->msValue = aId; 154 xRet.set( new ShapeTargetElementContext( *this, mpTarget->maShapeTarget ) ); 155 break; 156 } 157 default: 158 OSL_TRACE( "OOX: unhandled tag %ld in TL_TimeTargetElement.", getBaseToken( aElementToken ) ); 159 break; 160 } 161 162 if( !xRet.is() ) 163 xRet.set( this ); 164 165 return xRet; 166 } 167 168 169 } } 170