1*ca5ec200SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ca5ec200SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ca5ec200SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ca5ec200SAndrew Rist * distributed with this work for additional information 6*ca5ec200SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ca5ec200SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ca5ec200SAndrew Rist * "License"); you may not use this file except in compliance 9*ca5ec200SAndrew Rist * with the License. You may obtain a copy of the License at 10*ca5ec200SAndrew Rist * 11*ca5ec200SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ca5ec200SAndrew Rist * 13*ca5ec200SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ca5ec200SAndrew Rist * software distributed under the License is distributed on an 15*ca5ec200SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ca5ec200SAndrew Rist * KIND, either express or implied. See the License for the 17*ca5ec200SAndrew Rist * specific language governing permissions and limitations 18*ca5ec200SAndrew Rist * under the License. 19*ca5ec200SAndrew Rist * 20*ca5ec200SAndrew Rist *************************************************************/ 21*ca5ec200SAndrew Rist 22*ca5ec200SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "oox/ppt/timenodelistcontext.hxx" 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "comphelper/anytostring.hxx" 27cdf0e10cSrcweir #include "cppuhelper/exc_hlp.hxx" 28cdf0e10cSrcweir #include <osl/diagnose.h> 29cdf0e10cSrcweir #include <rtl/math.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <com/sun/star/animations/XTimeContainer.hpp> 32cdf0e10cSrcweir #include <com/sun/star/animations/XAnimationNode.hpp> 33cdf0e10cSrcweir #include <com/sun/star/animations/XAnimateColor.hpp> 34cdf0e10cSrcweir #include <com/sun/star/animations/XAnimateSet.hpp> 35cdf0e10cSrcweir #include <com/sun/star/animations/XAnimateTransform.hpp> 36cdf0e10cSrcweir #include <com/sun/star/animations/AnimationTransformType.hpp> 37cdf0e10cSrcweir #include <com/sun/star/animations/AnimationCalcMode.hpp> 38cdf0e10cSrcweir #include <com/sun/star/animations/AnimationColorSpace.hpp> 39cdf0e10cSrcweir #include <com/sun/star/animations/AnimationNodeType.hpp> 40cdf0e10cSrcweir #include <com/sun/star/animations/XCommand.hpp> 41cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 42cdf0e10cSrcweir #include <com/sun/star/presentation/EffectCommands.hpp> 43cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp> 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include "oox/helper/attributelist.hxx" 46cdf0e10cSrcweir #include "oox/core/xmlfilterbase.hxx" 47cdf0e10cSrcweir #include "oox/drawingml/drawingmltypes.hxx" 48cdf0e10cSrcweir #include "oox/drawingml/colorchoicecontext.hxx" 49cdf0e10cSrcweir #include "oox/ppt/slidetransition.hxx" 50cdf0e10cSrcweir 51cdf0e10cSrcweir #include "animvariantcontext.hxx" 52cdf0e10cSrcweir #include "commonbehaviorcontext.hxx" 53cdf0e10cSrcweir #include "conditioncontext.hxx" 54cdf0e10cSrcweir #include "commontimenodecontext.hxx" 55cdf0e10cSrcweir #include "timeanimvaluecontext.hxx" 56cdf0e10cSrcweir #include "animationtypes.hxx" 57cdf0e10cSrcweir 58cdf0e10cSrcweir using namespace ::oox::core; 59cdf0e10cSrcweir using namespace ::oox::drawingml; 60cdf0e10cSrcweir using namespace ::com::sun::star::uno; 61cdf0e10cSrcweir using namespace ::com::sun::star::lang; 62cdf0e10cSrcweir using namespace ::com::sun::star::animations; 63cdf0e10cSrcweir using namespace ::com::sun::star::presentation; 64cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax; 65cdf0e10cSrcweir using namespace ::com::sun::star::awt; 66cdf0e10cSrcweir using ::com::sun::star::beans::NamedValue; 67cdf0e10cSrcweir 68cdf0e10cSrcweir using ::rtl::OUString; 69cdf0e10cSrcweir 70cdf0e10cSrcweir namespace oox { namespace ppt { 71cdf0e10cSrcweir 72cdf0e10cSrcweir struct AnimColor 73cdf0e10cSrcweir { 74cdf0e10cSrcweir AnimColor(sal_Int16 cs, sal_Int32 o, sal_Int32 t, sal_Int32 th ) 75cdf0e10cSrcweir : colorSpace( cs ), one( o ), two( t ), three( th ) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir } 78cdf0e10cSrcweir 79cdf0e10cSrcweir sal_Int32 get() 80cdf0e10cSrcweir { 81cdf0e10cSrcweir sal_Int32 nColor; 82cdf0e10cSrcweir 83cdf0e10cSrcweir switch( colorSpace ) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir case AnimationColorSpace::HSL: 86cdf0e10cSrcweir nColor = ( ( ( one * 128 ) / 360 ) & 0xff ) << 16 87cdf0e10cSrcweir | ( ( ( two * 128 ) / 1000 ) & 0xff ) << 8 88cdf0e10cSrcweir | ( ( ( three * 128 ) / 1000 ) & 0xff ); 89cdf0e10cSrcweir break; 90cdf0e10cSrcweir case AnimationColorSpace::RGB: 91cdf0e10cSrcweir nColor = ( ( ( one * 128 ) / 1000 ) & 0xff ) << 16 92cdf0e10cSrcweir | ( ( ( two * 128 ) / 1000 ) & 0xff ) << 8 93cdf0e10cSrcweir | ( ( ( three * 128 ) / 1000 ) & 0xff ); 94cdf0e10cSrcweir break; 95cdf0e10cSrcweir default: 96cdf0e10cSrcweir nColor = 0; 97cdf0e10cSrcweir break; 98cdf0e10cSrcweir } 99cdf0e10cSrcweir return nColor; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir sal_Int16 colorSpace; 103cdf0e10cSrcweir sal_Int32 one; 104cdf0e10cSrcweir sal_Int32 two; 105cdf0e10cSrcweir sal_Int32 three; 106cdf0e10cSrcweir }; 107cdf0e10cSrcweir 108cdf0e10cSrcweir 109cdf0e10cSrcweir /** CT_TLMediaNodeAudio 110cdf0e10cSrcweir CT_TLMediaNodeVideo */ 111cdf0e10cSrcweir class MediaNodeContext 112cdf0e10cSrcweir : public TimeNodeContext 113cdf0e10cSrcweir { 114cdf0e10cSrcweir public: 115cdf0e10cSrcweir MediaNodeContext( ContextHandler& rParent, sal_Int32 aElement, 116cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs, 117cdf0e10cSrcweir const TimeNodePtr & pNode ) 118cdf0e10cSrcweir : TimeNodeContext( rParent, aElement, xAttribs, pNode ) 119cdf0e10cSrcweir , mbIsNarration( false ) 120cdf0e10cSrcweir , mbFullScrn( false ) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir AttributeList attribs( xAttribs ); 123cdf0e10cSrcweir 124cdf0e10cSrcweir switch( aElement ) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir case PPT_TOKEN( audio ): 127cdf0e10cSrcweir mbIsNarration = attribs.getBool( XML_isNarration, false ); 128cdf0e10cSrcweir break; 129cdf0e10cSrcweir case PPT_TOKEN( video ): 130cdf0e10cSrcweir mbFullScrn = attribs.getBool( XML_fullScrn, false ); 131cdf0e10cSrcweir break; 132cdf0e10cSrcweir default: 133cdf0e10cSrcweir break; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir virtual void SAL_CALL endFastElement( sal_Int32 aElement ) 138cdf0e10cSrcweir throw ( SAXException, RuntimeException) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir if( aElement == PPT_TOKEN( audio ) ) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir // TODO deal with mbIsNarration 143cdf0e10cSrcweir } 144cdf0e10cSrcweir else if( aElement == PPT_TOKEN( video ) ) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir // TODO deal with mbFullScrn 147cdf0e10cSrcweir } 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, 151cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs ) 152cdf0e10cSrcweir throw ( SAXException, RuntimeException ) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 155cdf0e10cSrcweir 156cdf0e10cSrcweir switch ( aElementToken ) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir case PPT_TOKEN( cBhvr ): 159cdf0e10cSrcweir xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); 160cdf0e10cSrcweir break; 161cdf0e10cSrcweir default: 162cdf0e10cSrcweir break; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir if( !xRet.is() ) 166cdf0e10cSrcweir xRet.set( this ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir return xRet; 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir private: 172cdf0e10cSrcweir bool mbIsNarration; 173cdf0e10cSrcweir bool mbFullScrn; 174cdf0e10cSrcweir }; 175cdf0e10cSrcweir 176cdf0e10cSrcweir 177cdf0e10cSrcweir /** CT_TLSetBehavior 178cdf0e10cSrcweir */ 179cdf0e10cSrcweir class SetTimeNodeContext 180cdf0e10cSrcweir : public TimeNodeContext 181cdf0e10cSrcweir { 182cdf0e10cSrcweir public: 183cdf0e10cSrcweir SetTimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, 184cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs, 185cdf0e10cSrcweir const TimeNodePtr & pNode ) 186cdf0e10cSrcweir : TimeNodeContext( rParent, aElement, xAttribs, pNode ) 187cdf0e10cSrcweir { 188cdf0e10cSrcweir 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir ~SetTimeNodeContext() throw () 192cdf0e10cSrcweir { 193cdf0e10cSrcweir if( maTo.hasValue() ) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir // TODO 196cdf0e10cSrcweir // HACK !!! discard and refactor 197cdf0e10cSrcweir OUString aString; 198cdf0e10cSrcweir if( maTo >>= aString ) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir OSL_TRACE( "Magic conversion %s", OUSTRING_TO_CSTR( aString ) ); 201cdf0e10cSrcweir maTo = makeAny( aString.equalsAscii( "visible" ) ? sal_True : sal_False ); 202cdf0e10cSrcweir if( !maTo.has<sal_Bool>() ) 203cdf0e10cSrcweir OSL_TRACE( "conversion failed" ); 204cdf0e10cSrcweir } 205cdf0e10cSrcweir mpNode->setTo( maTo ); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir virtual void SAL_CALL endFastElement( sal_Int32 /*aElement*/ ) 211cdf0e10cSrcweir throw ( SAXException, RuntimeException) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir 216cdf0e10cSrcweir virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, 217cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs ) 218cdf0e10cSrcweir throw ( SAXException, RuntimeException ) 219cdf0e10cSrcweir { 220cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 221cdf0e10cSrcweir 222cdf0e10cSrcweir switch ( aElementToken ) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir case PPT_TOKEN( cBhvr ): 225cdf0e10cSrcweir xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); 226cdf0e10cSrcweir break; 227cdf0e10cSrcweir case PPT_TOKEN( to ): 228cdf0e10cSrcweir // CT_TLAnimVariant 229cdf0e10cSrcweir xRet.set( new AnimVariantContext( *this, aElementToken, maTo ) ); 230cdf0e10cSrcweir break; 231cdf0e10cSrcweir default: 232cdf0e10cSrcweir break; 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir if( !xRet.is() ) 236cdf0e10cSrcweir xRet.set( this ); 237cdf0e10cSrcweir 238cdf0e10cSrcweir return xRet; 239cdf0e10cSrcweir } 240cdf0e10cSrcweir private: 241cdf0e10cSrcweir Any maTo; 242cdf0e10cSrcweir }; 243cdf0e10cSrcweir 244cdf0e10cSrcweir /** CT_TLCommandBehavior 245cdf0e10cSrcweir */ 246cdf0e10cSrcweir class CmdTimeNodeContext 247cdf0e10cSrcweir : public TimeNodeContext 248cdf0e10cSrcweir { 249cdf0e10cSrcweir public: 250cdf0e10cSrcweir CmdTimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, 251cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs, 252cdf0e10cSrcweir const TimeNodePtr & pNode ) 253cdf0e10cSrcweir : TimeNodeContext( rParent, aElement, xAttribs, pNode ) 254cdf0e10cSrcweir , maType(0) 255cdf0e10cSrcweir { 256cdf0e10cSrcweir switch ( aElement ) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir case PPT_TOKEN( cmd ): 259cdf0e10cSrcweir msCommand = xAttribs->getOptionalValue( XML_cmd ); 260cdf0e10cSrcweir maType = xAttribs->getOptionalValueToken( XML_type, 0 ); 261cdf0e10cSrcweir break; 262cdf0e10cSrcweir default: 263cdf0e10cSrcweir break; 264cdf0e10cSrcweir } 265cdf0e10cSrcweir } 266cdf0e10cSrcweir 267cdf0e10cSrcweir ~CmdTimeNodeContext() throw () 268cdf0e10cSrcweir { 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir virtual void SAL_CALL endFastElement( sal_Int32 aElement ) 272cdf0e10cSrcweir throw ( SAXException, RuntimeException) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir if( aElement == PPT_TOKEN( cmd ) ) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir try { 277cdf0e10cSrcweir // see sd/source/filter/ppt/pptinanimations.cxx 278cdf0e10cSrcweir // in AnimationImporter::importCommandContainer() 279cdf0e10cSrcweir // REFACTOR? 280cdf0e10cSrcweir // a good chunk of this code has been copied verbatim *sigh* 281cdf0e10cSrcweir sal_Int16 nCommand = EffectCommands::CUSTOM; 282cdf0e10cSrcweir NamedValue aParamValue; 283cdf0e10cSrcweir 284cdf0e10cSrcweir switch( maType ) 285cdf0e10cSrcweir { 286cdf0e10cSrcweir case XML_verb: 287cdf0e10cSrcweir aParamValue.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("Verb")); 288cdf0e10cSrcweir // TODO make sure msCommand has what we want 289cdf0e10cSrcweir aParamValue.Value <<= msCommand.toInt32(); 290cdf0e10cSrcweir nCommand = EffectCommands::VERB; 291cdf0e10cSrcweir break; 292cdf0e10cSrcweir case XML_evt: 293cdf0e10cSrcweir case XML_call: 294cdf0e10cSrcweir if( msCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "onstopaudio" ) ) ) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir nCommand = EffectCommands::STOPAUDIO; 297cdf0e10cSrcweir } 298cdf0e10cSrcweir else if( msCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("play") ) ) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir nCommand = EffectCommands::PLAY; 301cdf0e10cSrcweir } 302cdf0e10cSrcweir else if( msCommand.compareToAscii( RTL_CONSTASCII_STRINGPARAM("playFrom") ) == 0 ) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir const OUString aMediaTime( msCommand.copy( 9, msCommand.getLength() - 10 ) ); 305cdf0e10cSrcweir rtl_math_ConversionStatus eStatus; 306cdf0e10cSrcweir double fMediaTime = ::rtl::math::stringToDouble( aMediaTime, (sal_Unicode)('.'), (sal_Unicode)(','), &eStatus, NULL ); 307cdf0e10cSrcweir if( eStatus == rtl_math_ConversionStatus_Ok ) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir aParamValue.Name = CREATE_OUSTRING("MediaTime"); 310cdf0e10cSrcweir aParamValue.Value <<= fMediaTime; 311cdf0e10cSrcweir } 312cdf0e10cSrcweir nCommand = EffectCommands::PLAY; 313cdf0e10cSrcweir } 314cdf0e10cSrcweir else if( msCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("togglePause") ) ) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir nCommand = EffectCommands::TOGGLEPAUSE; 317cdf0e10cSrcweir } 318cdf0e10cSrcweir else if( msCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("stop") ) ) 319cdf0e10cSrcweir { 320cdf0e10cSrcweir nCommand = EffectCommands::STOP; 321cdf0e10cSrcweir } 322cdf0e10cSrcweir break; 323cdf0e10cSrcweir } 324cdf0e10cSrcweir mpNode->getNodeProperties()[ NP_COMMAND ] = makeAny((sal_Int16)nCommand); 325cdf0e10cSrcweir if( nCommand == EffectCommands::CUSTOM ) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir OSL_TRACE("OOX: CmdTimeNodeContext::endFastElement(), unknown command!"); 328cdf0e10cSrcweir aParamValue.Name = CREATE_OUSTRING("UserDefined"); 329cdf0e10cSrcweir aParamValue.Value <<= msCommand; 330cdf0e10cSrcweir } 331cdf0e10cSrcweir if( aParamValue.Value.hasValue() ) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir Sequence< NamedValue > aParamSeq( &aParamValue, 1 ); 334cdf0e10cSrcweir mpNode->getNodeProperties()[ NP_PARAMETER ] = makeAny( aParamSeq ); 335cdf0e10cSrcweir } 336cdf0e10cSrcweir } 337cdf0e10cSrcweir catch( RuntimeException& ) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir OSL_TRACE( "OOX: Exception in CmdTimeNodeContext::endFastElement()" ); 340cdf0e10cSrcweir } 341cdf0e10cSrcweir } 342cdf0e10cSrcweir } 343cdf0e10cSrcweir 344cdf0e10cSrcweir 345cdf0e10cSrcweir virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, 346cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs ) 347cdf0e10cSrcweir throw ( SAXException, RuntimeException ) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 350cdf0e10cSrcweir 351cdf0e10cSrcweir switch ( aElementToken ) 352cdf0e10cSrcweir { 353cdf0e10cSrcweir case PPT_TOKEN( cBhvr ): 354cdf0e10cSrcweir xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); 355cdf0e10cSrcweir break; 356cdf0e10cSrcweir default: 357cdf0e10cSrcweir break; 358cdf0e10cSrcweir } 359cdf0e10cSrcweir 360cdf0e10cSrcweir if( !xRet.is() ) 361cdf0e10cSrcweir xRet.set( this ); 362cdf0e10cSrcweir 363cdf0e10cSrcweir return xRet; 364cdf0e10cSrcweir } 365cdf0e10cSrcweir 366cdf0e10cSrcweir private: 367cdf0e10cSrcweir OUString msCommand; 368cdf0e10cSrcweir sal_Int32 maType; 369cdf0e10cSrcweir }; 370cdf0e10cSrcweir 371cdf0e10cSrcweir 372cdf0e10cSrcweir /** CT_TLTimeNodeSequence 373cdf0e10cSrcweir */ 374cdf0e10cSrcweir class SequenceTimeNodeContext 375cdf0e10cSrcweir : public TimeNodeContext 376cdf0e10cSrcweir { 377cdf0e10cSrcweir public: 378cdf0e10cSrcweir SequenceTimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, 379cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs, 380cdf0e10cSrcweir const TimeNodePtr & pNode ) 381cdf0e10cSrcweir : TimeNodeContext( rParent, aElement, xAttribs, pNode ) 382cdf0e10cSrcweir , mnNextAc(0) 383cdf0e10cSrcweir , mnPrevAc(0) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir AttributeList attribs(xAttribs); 386cdf0e10cSrcweir mbConcurrent = attribs.getBool( XML_concurrent, false ); 387cdf0e10cSrcweir // ST_TLNextActionType { none, seek } 388cdf0e10cSrcweir mnNextAc = xAttribs->getOptionalValueToken( XML_nextAc, 0 ); 389cdf0e10cSrcweir // ST_TLPreviousActionType { none, skipTimed } 390cdf0e10cSrcweir mnPrevAc = xAttribs->getOptionalValueToken( XML_prevAc, 0 ); 391cdf0e10cSrcweir } 392cdf0e10cSrcweir 393cdf0e10cSrcweir ~SequenceTimeNodeContext() throw() 394cdf0e10cSrcweir { 395cdf0e10cSrcweir } 396cdf0e10cSrcweir 397cdf0e10cSrcweir 398cdf0e10cSrcweir virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, 399cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs ) 400cdf0e10cSrcweir throw ( SAXException, RuntimeException ) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 403cdf0e10cSrcweir 404cdf0e10cSrcweir switch ( aElementToken ) 405cdf0e10cSrcweir { 406cdf0e10cSrcweir case PPT_TOKEN( cTn ): 407cdf0e10cSrcweir xRet.set( new CommonTimeNodeContext( *this, aElementToken, xAttribs, mpNode ) ); 408cdf0e10cSrcweir break; 409cdf0e10cSrcweir case PPT_TOKEN( nextCondLst ): 410cdf0e10cSrcweir xRet.set( new CondListContext( *this, aElementToken, xAttribs, mpNode, 411cdf0e10cSrcweir mpNode->getNextCondition() ) ); 412cdf0e10cSrcweir break; 413cdf0e10cSrcweir case PPT_TOKEN( prevCondLst ): 414cdf0e10cSrcweir xRet.set( new CondListContext( *this, aElementToken, xAttribs, mpNode, 415cdf0e10cSrcweir mpNode->getPrevCondition() ) ); 416cdf0e10cSrcweir break; 417cdf0e10cSrcweir default: 418cdf0e10cSrcweir break; 419cdf0e10cSrcweir } 420cdf0e10cSrcweir 421cdf0e10cSrcweir if( !xRet.is() ) 422cdf0e10cSrcweir xRet.set( this ); 423cdf0e10cSrcweir 424cdf0e10cSrcweir return xRet; 425cdf0e10cSrcweir } 426cdf0e10cSrcweir private: 427cdf0e10cSrcweir bool mbConcurrent; 428cdf0e10cSrcweir sal_Int32 mnNextAc, mnPrevAc; 429cdf0e10cSrcweir }; 430cdf0e10cSrcweir 431cdf0e10cSrcweir 432cdf0e10cSrcweir /** CT_TLTimeNodeParallel 433cdf0e10cSrcweir * CT_TLTimeNodeExclusive 434cdf0e10cSrcweir */ 435cdf0e10cSrcweir class ParallelExclTimeNodeContext 436cdf0e10cSrcweir : public TimeNodeContext 437cdf0e10cSrcweir { 438cdf0e10cSrcweir public: 439cdf0e10cSrcweir ParallelExclTimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, 440cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs, 441cdf0e10cSrcweir const TimeNodePtr & pNode ) 442cdf0e10cSrcweir : TimeNodeContext( rParent, aElement, xAttribs, pNode ) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir } 445cdf0e10cSrcweir 446cdf0e10cSrcweir virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, 447cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs ) 448cdf0e10cSrcweir throw ( SAXException, RuntimeException ) 449cdf0e10cSrcweir { 450cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 451cdf0e10cSrcweir 452cdf0e10cSrcweir switch ( aElementToken ) 453cdf0e10cSrcweir { 454cdf0e10cSrcweir case PPT_TOKEN( cTn ): 455cdf0e10cSrcweir xRet.set( new CommonTimeNodeContext( *this, aElementToken, xAttribs, mpNode ) ); 456cdf0e10cSrcweir break; 457cdf0e10cSrcweir default: 458cdf0e10cSrcweir break; 459cdf0e10cSrcweir } 460cdf0e10cSrcweir 461cdf0e10cSrcweir if( !xRet.is() ) 462cdf0e10cSrcweir xRet.set( this ); 463cdf0e10cSrcweir 464cdf0e10cSrcweir return xRet; 465cdf0e10cSrcweir } 466cdf0e10cSrcweir 467cdf0e10cSrcweir protected: 468cdf0e10cSrcweir 469cdf0e10cSrcweir }; 470cdf0e10cSrcweir 471cdf0e10cSrcweir 472cdf0e10cSrcweir /** CT_TLAnimateColorBehavior */ 473cdf0e10cSrcweir class AnimColorContext 474cdf0e10cSrcweir : public TimeNodeContext 475cdf0e10cSrcweir { 476cdf0e10cSrcweir public: 477cdf0e10cSrcweir AnimColorContext( ContextHandler& rParent, sal_Int32 aElement, 478cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs, 479cdf0e10cSrcweir const TimeNodePtr & pNode ) throw() 480cdf0e10cSrcweir : TimeNodeContext( rParent, aElement, xAttribs, pNode ) 481cdf0e10cSrcweir // ST_TLAnimateColorSpace ( XML_rgb, XML_hsl } 482cdf0e10cSrcweir , mnColorSpace( xAttribs->getOptionalValueToken( XML_clrSpc, 0 ) ) 483cdf0e10cSrcweir // ST_TLAnimateColorDirection { XML_cw, XML_ccw } 484cdf0e10cSrcweir , mnDir( xAttribs->getOptionalValueToken( XML_dir, 0 ) ) 485cdf0e10cSrcweir , mbHasByColor( false ) 486cdf0e10cSrcweir , m_byColor( AnimationColorSpace::RGB, 0, 0, 0) 487cdf0e10cSrcweir { 488cdf0e10cSrcweir } 489cdf0e10cSrcweir ~AnimColorContext() throw() 490cdf0e10cSrcweir { 491cdf0e10cSrcweir } 492cdf0e10cSrcweir 493cdf0e10cSrcweir virtual void SAL_CALL endFastElement( sal_Int32 aElement ) throw ( SAXException, RuntimeException) 494cdf0e10cSrcweir { 495cdf0e10cSrcweir //xParentNode 496cdf0e10cSrcweir if( aElement == mnElement ) 497cdf0e10cSrcweir { 498cdf0e10cSrcweir NodePropertyMap & pProps(mpNode->getNodeProperties()); 499cdf0e10cSrcweir pProps[ NP_DIRECTION ] = makeAny( mnDir == XML_cw ); 500cdf0e10cSrcweir pProps[ NP_COLORINTERPOLATION ] = makeAny( mnColorSpace == XML_hsl ? AnimationColorSpace::HSL : AnimationColorSpace::RGB ); 501cdf0e10cSrcweir const GraphicHelper& rGraphicHelper = getFilter().getGraphicHelper(); 502cdf0e10cSrcweir if( maToClr.isUsed() ) 503cdf0e10cSrcweir mpNode->setTo( Any( maToClr.getColor( rGraphicHelper ) ) ); 504cdf0e10cSrcweir if( maFromClr.isUsed() ) 505cdf0e10cSrcweir mpNode->setFrom( Any( maFromClr.getColor( rGraphicHelper ) ) ); 506cdf0e10cSrcweir if( mbHasByColor ) 507cdf0e10cSrcweir mpNode->setBy( Any ( m_byColor.get() ) ); 508cdf0e10cSrcweir } 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir 512cdf0e10cSrcweir virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) 513cdf0e10cSrcweir { 514cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 515cdf0e10cSrcweir 516cdf0e10cSrcweir switch ( aElementToken ) 517cdf0e10cSrcweir { 518cdf0e10cSrcweir case PPT_TOKEN( hsl ): 519cdf0e10cSrcweir // CT_TLByHslColorTransform 520cdf0e10cSrcweir { 521cdf0e10cSrcweir if( mbHasByColor ) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir m_byColor.colorSpace = AnimationColorSpace::HSL; 524cdf0e10cSrcweir m_byColor.one = xAttribs->getOptionalValue( XML_h ).toInt32( ); 525cdf0e10cSrcweir m_byColor.two = xAttribs->getOptionalValue( XML_s ).toInt32( ); 526cdf0e10cSrcweir m_byColor.three = xAttribs->getOptionalValue( XML_l ).toInt32( ); 527cdf0e10cSrcweir } 528cdf0e10cSrcweir xRet.set(this); 529cdf0e10cSrcweir break; 530cdf0e10cSrcweir } 531cdf0e10cSrcweir case PPT_TOKEN( rgb ): 532cdf0e10cSrcweir { 533cdf0e10cSrcweir if( mbHasByColor ) 534cdf0e10cSrcweir { 535cdf0e10cSrcweir // CT_TLByRgbColorTransform 536cdf0e10cSrcweir m_byColor.colorSpace = AnimationColorSpace::RGB; 537cdf0e10cSrcweir m_byColor.one = xAttribs->getOptionalValue( XML_r ).toInt32(); 538cdf0e10cSrcweir m_byColor.two = xAttribs->getOptionalValue( XML_g ).toInt32(); 539cdf0e10cSrcweir m_byColor.three = xAttribs->getOptionalValue( XML_b ).toInt32(); 540cdf0e10cSrcweir } 541cdf0e10cSrcweir xRet.set(this); 542cdf0e10cSrcweir break; 543cdf0e10cSrcweir } 544cdf0e10cSrcweir case PPT_TOKEN( by ): 545cdf0e10cSrcweir // CT_TLByAnimateColorTransform 546cdf0e10cSrcweir mbHasByColor = true; 547cdf0e10cSrcweir xRet.set(this); 548cdf0e10cSrcweir break; 549cdf0e10cSrcweir case PPT_TOKEN( cBhvr ): 550cdf0e10cSrcweir xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); 551cdf0e10cSrcweir break; 552cdf0e10cSrcweir case PPT_TOKEN( to ): 553cdf0e10cSrcweir // CT_Color 554cdf0e10cSrcweir xRet.set( new ColorContext( *this, maToClr ) ); 555cdf0e10cSrcweir break; 556cdf0e10cSrcweir case PPT_TOKEN( from ): 557cdf0e10cSrcweir // CT_Color 558cdf0e10cSrcweir xRet.set( new ColorContext( *this, maFromClr ) ); 559cdf0e10cSrcweir break; 560cdf0e10cSrcweir 561cdf0e10cSrcweir default: 562cdf0e10cSrcweir break; 563cdf0e10cSrcweir } 564cdf0e10cSrcweir 565cdf0e10cSrcweir if( !xRet.is() ) 566cdf0e10cSrcweir xRet.set( this ); 567cdf0e10cSrcweir 568cdf0e10cSrcweir return xRet; 569cdf0e10cSrcweir } 570cdf0e10cSrcweir 571cdf0e10cSrcweir 572cdf0e10cSrcweir private: 573cdf0e10cSrcweir sal_Int32 mnColorSpace; 574cdf0e10cSrcweir sal_Int32 mnDir; 575cdf0e10cSrcweir bool mbHasByColor; 576cdf0e10cSrcweir AnimColor m_byColor; 577cdf0e10cSrcweir oox::drawingml::Color maToClr; 578cdf0e10cSrcweir oox::drawingml::Color maFromClr; 579cdf0e10cSrcweir }; 580cdf0e10cSrcweir 581cdf0e10cSrcweir 582cdf0e10cSrcweir /** CT_TLAnimateBehavior */ 583cdf0e10cSrcweir class AnimContext 584cdf0e10cSrcweir : public TimeNodeContext 585cdf0e10cSrcweir { 586cdf0e10cSrcweir public: 587cdf0e10cSrcweir AnimContext( ContextHandler& rParent, sal_Int32 aElement, 588cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs, 589cdf0e10cSrcweir const TimeNodePtr & pNode ) throw() 590cdf0e10cSrcweir : TimeNodeContext( rParent, aElement, xAttribs, pNode ) 591cdf0e10cSrcweir { 592cdf0e10cSrcweir NodePropertyMap & aProps( pNode->getNodeProperties() ); 593cdf0e10cSrcweir sal_Int32 nCalcMode = xAttribs->getOptionalValueToken( XML_calcmode, 0 ); 594cdf0e10cSrcweir if(nCalcMode) 595cdf0e10cSrcweir { 596cdf0e10cSrcweir sal_Int16 nEnum = 0; 597cdf0e10cSrcweir switch(nCalcMode) 598cdf0e10cSrcweir { 599cdf0e10cSrcweir case XML_discrete: 600cdf0e10cSrcweir nEnum = AnimationCalcMode::DISCRETE; 601cdf0e10cSrcweir break; 602cdf0e10cSrcweir case XML_lin: 603cdf0e10cSrcweir nEnum = AnimationCalcMode::LINEAR; 604cdf0e10cSrcweir break; 605cdf0e10cSrcweir case XML_fmla: 606cdf0e10cSrcweir default: 607cdf0e10cSrcweir // TODO what value is good ? 608cdf0e10cSrcweir nEnum = AnimationCalcMode::DISCRETE; 609cdf0e10cSrcweir break; 610cdf0e10cSrcweir } 611cdf0e10cSrcweir aProps[ NP_CALCMODE ] = makeAny(nEnum); 612cdf0e10cSrcweir } 613cdf0e10cSrcweir OUString aStr; 614cdf0e10cSrcweir aStr = xAttribs->getOptionalValue( XML_from ); 615cdf0e10cSrcweir if( aStr.getLength() ) 616cdf0e10cSrcweir { 617cdf0e10cSrcweir pNode->setFrom( makeAny( aStr ) ); 618cdf0e10cSrcweir } 619cdf0e10cSrcweir aStr = xAttribs->getOptionalValue( XML_by ); 620cdf0e10cSrcweir if( aStr.getLength() ) 621cdf0e10cSrcweir { 622cdf0e10cSrcweir pNode->setBy( makeAny( aStr ) ); 623cdf0e10cSrcweir } 624cdf0e10cSrcweir aStr = xAttribs->getOptionalValue( XML_to ); 625cdf0e10cSrcweir if( aStr.getLength() ) 626cdf0e10cSrcweir { 627cdf0e10cSrcweir pNode->setTo( makeAny( aStr ) ); 628cdf0e10cSrcweir } 629cdf0e10cSrcweir mnValueType = xAttribs->getOptionalValueToken( XML_valueType, 0 ); 630cdf0e10cSrcweir } 631cdf0e10cSrcweir 632cdf0e10cSrcweir 633cdf0e10cSrcweir ~AnimContext() throw () 634cdf0e10cSrcweir { 635cdf0e10cSrcweir ::std::list< TimeAnimationValue >::iterator iter, end; 636cdf0e10cSrcweir int nKeyTimes = maTavList.size(); 637cdf0e10cSrcweir if( nKeyTimes > 0) 638cdf0e10cSrcweir { 639cdf0e10cSrcweir int i; 640cdf0e10cSrcweir Sequence< double > aKeyTimes( nKeyTimes ); 641cdf0e10cSrcweir Sequence< Any > aValues( nKeyTimes ); 642cdf0e10cSrcweir 643cdf0e10cSrcweir NodePropertyMap & aProps( mpNode->getNodeProperties() ); 644cdf0e10cSrcweir end = maTavList.end(); 645cdf0e10cSrcweir for(iter = maTavList.begin(), i=0; iter != end; iter++,i++) 646cdf0e10cSrcweir { 647cdf0e10cSrcweir // TODO what to do if it is Timing_INFINITE ? 648cdf0e10cSrcweir Any aTime = GetTimeAnimateValueTime( iter->msTime ); 649cdf0e10cSrcweir aTime >>= aKeyTimes[i]; 650cdf0e10cSrcweir aValues[i] = iter->maValue; 651cdf0e10cSrcweir 652cdf0e10cSrcweir OUString aTest; 653cdf0e10cSrcweir iter->maValue >>= aTest; 654cdf0e10cSrcweir if( aTest.getLength() != 0 ) 655cdf0e10cSrcweir { 656cdf0e10cSrcweir aValues[i] = iter->maValue; 657cdf0e10cSrcweir } 658cdf0e10cSrcweir else 659cdf0e10cSrcweir { 660cdf0e10cSrcweir aProps[ NP_FORMULA ] <<= iter->msFormula; 661cdf0e10cSrcweir } 662cdf0e10cSrcweir } 663cdf0e10cSrcweir aProps[ NP_VALUES ] <<= aValues; 664cdf0e10cSrcweir aProps[ NP_KEYTIMES ] <<= aKeyTimes; 665cdf0e10cSrcweir } 666cdf0e10cSrcweir } 667cdf0e10cSrcweir 668cdf0e10cSrcweir 669cdf0e10cSrcweir virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) 670cdf0e10cSrcweir { 671cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 672cdf0e10cSrcweir 673cdf0e10cSrcweir switch ( aElementToken ) 674cdf0e10cSrcweir { 675cdf0e10cSrcweir case PPT_TOKEN( cBhvr ): 676cdf0e10cSrcweir xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); 677cdf0e10cSrcweir break; 678cdf0e10cSrcweir case PPT_TOKEN( tavLst ): 679cdf0e10cSrcweir xRet.set( new TimeAnimValueListContext ( *this, xAttribs, maTavList ) ); 680cdf0e10cSrcweir break; 681cdf0e10cSrcweir default: 682cdf0e10cSrcweir break; 683cdf0e10cSrcweir } 684cdf0e10cSrcweir 685cdf0e10cSrcweir if( !xRet.is() ) 686cdf0e10cSrcweir xRet.set( this ); 687cdf0e10cSrcweir 688cdf0e10cSrcweir return xRet; 689cdf0e10cSrcweir } 690cdf0e10cSrcweir private: 691cdf0e10cSrcweir sal_Int32 mnValueType; 692cdf0e10cSrcweir TimeAnimationValueList maTavList; 693cdf0e10cSrcweir }; 694cdf0e10cSrcweir 695cdf0e10cSrcweir 696cdf0e10cSrcweir /** CT_TLAnimateScaleBehavior */ 697cdf0e10cSrcweir class AnimScaleContext 698cdf0e10cSrcweir : public TimeNodeContext 699cdf0e10cSrcweir { 700cdf0e10cSrcweir public: 701cdf0e10cSrcweir AnimScaleContext( ContextHandler& rParent, sal_Int32 aElement, 702cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs, 703cdf0e10cSrcweir const TimeNodePtr & pNode ) throw() 704cdf0e10cSrcweir : TimeNodeContext( rParent, aElement, xAttribs, pNode ) 705cdf0e10cSrcweir , mbZoomContents( false ) 706cdf0e10cSrcweir { 707cdf0e10cSrcweir AttributeList attribs( xAttribs ); 708cdf0e10cSrcweir // TODO what to do with mbZoomContents 709cdf0e10cSrcweir mbZoomContents = attribs.getBool( XML_zoomContents, false ); 710cdf0e10cSrcweir pNode->getNodeProperties()[ NP_TRANSFORMTYPE ] 711cdf0e10cSrcweir = makeAny((sal_Int16)AnimationTransformType::SCALE); 712cdf0e10cSrcweir } 713cdf0e10cSrcweir 714cdf0e10cSrcweir ~AnimScaleContext( ) throw( ) 715cdf0e10cSrcweir { 716cdf0e10cSrcweir } 717cdf0e10cSrcweir 718cdf0e10cSrcweir virtual void SAL_CALL endFastElement( sal_Int32 aElement ) throw ( SAXException, RuntimeException) 719cdf0e10cSrcweir { 720cdf0e10cSrcweir if( aElement == mnElement ) 721cdf0e10cSrcweir { 722cdf0e10cSrcweir if( maTo.hasValue() ) 723cdf0e10cSrcweir { 724cdf0e10cSrcweir mpNode->setTo( maTo ); 725cdf0e10cSrcweir } 726cdf0e10cSrcweir if( maBy.hasValue() ) 727cdf0e10cSrcweir { 728cdf0e10cSrcweir mpNode->setBy( maBy ); 729cdf0e10cSrcweir } 730cdf0e10cSrcweir if( maFrom.hasValue() ) 731cdf0e10cSrcweir { 732cdf0e10cSrcweir mpNode->setFrom( maFrom ); 733cdf0e10cSrcweir } 734cdf0e10cSrcweir } 735cdf0e10cSrcweir } 736cdf0e10cSrcweir 737cdf0e10cSrcweir virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, 738cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs ) 739cdf0e10cSrcweir throw ( SAXException, RuntimeException ) 740cdf0e10cSrcweir { 741cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 742cdf0e10cSrcweir 743cdf0e10cSrcweir switch ( aElementToken ) 744cdf0e10cSrcweir { 745cdf0e10cSrcweir case PPT_TOKEN( cBhvr ): 746cdf0e10cSrcweir xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); 747cdf0e10cSrcweir break; 748cdf0e10cSrcweir case PPT_TOKEN( to ): 749cdf0e10cSrcweir { 750cdf0e10cSrcweir // CT_TLPoint 751cdf0e10cSrcweir Point p = GetPointPercent( xAttribs ); 752cdf0e10cSrcweir maTo <<= p.X; 753cdf0e10cSrcweir maTo <<= p.Y; 754cdf0e10cSrcweir break; 755cdf0e10cSrcweir } 756cdf0e10cSrcweir case PPT_TOKEN( from ): 757cdf0e10cSrcweir { 758cdf0e10cSrcweir // CT_TLPoint 759cdf0e10cSrcweir Point p = GetPointPercent( xAttribs ); 760cdf0e10cSrcweir maFrom <<= p.X; 761cdf0e10cSrcweir maFrom <<= p.Y; 762cdf0e10cSrcweir break; 763cdf0e10cSrcweir } 764cdf0e10cSrcweir case PPT_TOKEN( by ): 765cdf0e10cSrcweir { 766cdf0e10cSrcweir // CT_TLPoint 767cdf0e10cSrcweir Point p = GetPointPercent( xAttribs ); 768cdf0e10cSrcweir maBy <<= p.X; 769cdf0e10cSrcweir maBy <<= p.Y; 770cdf0e10cSrcweir break; 771cdf0e10cSrcweir } 772cdf0e10cSrcweir default: 773cdf0e10cSrcweir break; 774cdf0e10cSrcweir } 775cdf0e10cSrcweir 776cdf0e10cSrcweir if( !xRet.is() ) 777cdf0e10cSrcweir xRet.set( this ); 778cdf0e10cSrcweir 779cdf0e10cSrcweir return xRet; 780cdf0e10cSrcweir } 781cdf0e10cSrcweir private: 782cdf0e10cSrcweir Any maBy; 783cdf0e10cSrcweir Any maFrom; 784cdf0e10cSrcweir Any maTo; 785cdf0e10cSrcweir bool mbZoomContents; 786cdf0e10cSrcweir }; 787cdf0e10cSrcweir 788cdf0e10cSrcweir 789cdf0e10cSrcweir /** CT_TLAnimateRotationBehavior */ 790cdf0e10cSrcweir class AnimRotContext 791cdf0e10cSrcweir : public TimeNodeContext 792cdf0e10cSrcweir { 793cdf0e10cSrcweir public: 794cdf0e10cSrcweir AnimRotContext( ContextHandler& rParent, sal_Int32 aElement, 795cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs, 796cdf0e10cSrcweir const TimeNodePtr & pNode ) throw() 797cdf0e10cSrcweir : TimeNodeContext( rParent, aElement, xAttribs, pNode ) 798cdf0e10cSrcweir { 799cdf0e10cSrcweir AttributeList attribs( xAttribs ); 800cdf0e10cSrcweir 801cdf0e10cSrcweir pNode->getNodeProperties()[ NP_TRANSFORMTYPE ] 802cdf0e10cSrcweir = makeAny((sal_Int16)AnimationTransformType::ROTATE); 803cdf0e10cSrcweir // TODO make sure the units are OK 804cdf0e10cSrcweir if(attribs.hasAttribute( XML_by ) ) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir sal_Int32 nBy = attribs.getInteger( XML_by, 0 ); 807cdf0e10cSrcweir pNode->setBy( makeAny( nBy ) ); 808cdf0e10cSrcweir } 809cdf0e10cSrcweir if(attribs.hasAttribute( XML_from ) ) 810cdf0e10cSrcweir { 811cdf0e10cSrcweir sal_Int32 nFrom = attribs.getInteger( XML_from, 0 ); 812cdf0e10cSrcweir pNode->setFrom( makeAny( nFrom ) ); 813cdf0e10cSrcweir } 814cdf0e10cSrcweir if(attribs.hasAttribute( XML_to ) ) 815cdf0e10cSrcweir { 816cdf0e10cSrcweir sal_Int32 nTo = attribs.getInteger( XML_to, 0 ); 817cdf0e10cSrcweir pNode->setTo( makeAny( nTo ) ); 818cdf0e10cSrcweir } 819cdf0e10cSrcweir } 820cdf0e10cSrcweir 821cdf0e10cSrcweir ~AnimRotContext( ) throw( ) 822cdf0e10cSrcweir { 823cdf0e10cSrcweir } 824cdf0e10cSrcweir 825cdf0e10cSrcweir virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) 826cdf0e10cSrcweir { 827cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 828cdf0e10cSrcweir 829cdf0e10cSrcweir switch ( aElementToken ) 830cdf0e10cSrcweir { 831cdf0e10cSrcweir case PPT_TOKEN( cBhvr ): 832cdf0e10cSrcweir xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); 833cdf0e10cSrcweir break; 834cdf0e10cSrcweir default: 835cdf0e10cSrcweir break; 836cdf0e10cSrcweir } 837cdf0e10cSrcweir 838cdf0e10cSrcweir if( !xRet.is() ) 839cdf0e10cSrcweir xRet.set( this ); 840cdf0e10cSrcweir 841cdf0e10cSrcweir return xRet; 842cdf0e10cSrcweir } 843cdf0e10cSrcweir }; 844cdf0e10cSrcweir 845cdf0e10cSrcweir 846cdf0e10cSrcweir 847cdf0e10cSrcweir /** CT_TLAnimateMotionBehavior */ 848cdf0e10cSrcweir class AnimMotionContext 849cdf0e10cSrcweir : public TimeNodeContext 850cdf0e10cSrcweir { 851cdf0e10cSrcweir public: 852cdf0e10cSrcweir AnimMotionContext( ContextHandler& rParent, sal_Int32 aElement, 853cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs, 854cdf0e10cSrcweir const TimeNodePtr & pNode ) throw() 855cdf0e10cSrcweir : TimeNodeContext( rParent, aElement, xAttribs, pNode ) 856cdf0e10cSrcweir { 857cdf0e10cSrcweir pNode->getNodeProperties()[ NP_TRANSFORMTYPE ] 858cdf0e10cSrcweir = makeAny((sal_Int16)AnimationTransformType::TRANSLATE); 859cdf0e10cSrcweir 860cdf0e10cSrcweir AttributeList attribs( xAttribs ); 861cdf0e10cSrcweir // ST_TLAnimateMotionBehaviorOrigin { parent, layour } 862cdf0e10cSrcweir sal_Int32 nOrigin = xAttribs->getOptionalValueToken( XML_origin, 0 ); 863cdf0e10cSrcweir if( nOrigin != 0 ) 864cdf0e10cSrcweir { 865cdf0e10cSrcweir switch(nOrigin) 866cdf0e10cSrcweir { 867cdf0e10cSrcweir case XML_layout: 868cdf0e10cSrcweir case XML_parent: 869cdf0e10cSrcweir break; 870cdf0e10cSrcweir } 871cdf0e10cSrcweir // TODO 872cdf0e10cSrcweir } 873cdf0e10cSrcweir 874cdf0e10cSrcweir OUString aStr = xAttribs->getOptionalValue( XML_path ); 875cdf0e10cSrcweir aStr = aStr.replace( 'E', ' ' ); 876cdf0e10cSrcweir aStr = aStr.trim(); 877cdf0e10cSrcweir pNode->getNodeProperties()[ NP_PATH ] = makeAny(aStr); 878cdf0e10cSrcweir 879cdf0e10cSrcweir // ST_TLAnimateMotionPathEditMode{ fixed, relative } 880cdf0e10cSrcweir mnPathEditMode = xAttribs->getOptionalValueToken( XML_pathEditMode, 0 ); 881cdf0e10cSrcweir msPtsTypes = xAttribs->getOptionalValue( XML_ptsTypes ); 882cdf0e10cSrcweir mnAngle = attribs.getInteger( XML_rAng, 0 ); 883cdf0e10cSrcweir // TODO make sure the units are right. Likely not. 884cdf0e10cSrcweir } 885cdf0e10cSrcweir 886cdf0e10cSrcweir ~AnimMotionContext( ) throw() 887cdf0e10cSrcweir { 888cdf0e10cSrcweir } 889cdf0e10cSrcweir 890cdf0e10cSrcweir 891cdf0e10cSrcweir virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, 892cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs ) 893cdf0e10cSrcweir throw ( SAXException, RuntimeException ) 894cdf0e10cSrcweir { 895cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 896cdf0e10cSrcweir 897cdf0e10cSrcweir switch ( aElementToken ) 898cdf0e10cSrcweir { 899cdf0e10cSrcweir case PPT_TOKEN( cBhvr ): 900cdf0e10cSrcweir xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); 901cdf0e10cSrcweir break; 902cdf0e10cSrcweir case PPT_TOKEN( to ): 903cdf0e10cSrcweir { 904cdf0e10cSrcweir // CT_TLPoint 905cdf0e10cSrcweir Point p = GetPointPercent( xAttribs ); 906cdf0e10cSrcweir Any rAny; 907cdf0e10cSrcweir rAny <<= p.X; 908cdf0e10cSrcweir rAny <<= p.Y; 909cdf0e10cSrcweir mpNode->setTo( rAny ); 910cdf0e10cSrcweir break; 911cdf0e10cSrcweir } 912cdf0e10cSrcweir case PPT_TOKEN( from ): 913cdf0e10cSrcweir { 914cdf0e10cSrcweir // CT_TLPoint 915cdf0e10cSrcweir Point p = GetPointPercent( xAttribs ); 916cdf0e10cSrcweir Any rAny; 917cdf0e10cSrcweir rAny <<= p.X; 918cdf0e10cSrcweir rAny <<= p.Y; 919cdf0e10cSrcweir mpNode->setFrom( rAny ); 920cdf0e10cSrcweir break; 921cdf0e10cSrcweir } 922cdf0e10cSrcweir case PPT_TOKEN( by ): 923cdf0e10cSrcweir { 924cdf0e10cSrcweir // CT_TLPoint 925cdf0e10cSrcweir Point p = GetPointPercent( xAttribs ); 926cdf0e10cSrcweir Any rAny; 927cdf0e10cSrcweir rAny <<= p.X; 928cdf0e10cSrcweir rAny <<= p.Y; 929cdf0e10cSrcweir mpNode->setBy( rAny ); 930cdf0e10cSrcweir break; 931cdf0e10cSrcweir } 932cdf0e10cSrcweir case PPT_TOKEN( rCtr ): 933cdf0e10cSrcweir { 934cdf0e10cSrcweir // CT_TLPoint 935cdf0e10cSrcweir Point p = GetPointPercent( xAttribs ); 936cdf0e10cSrcweir // TODO push 937cdf0e10cSrcweir break; 938cdf0e10cSrcweir } 939cdf0e10cSrcweir default: 940cdf0e10cSrcweir break; 941cdf0e10cSrcweir } 942cdf0e10cSrcweir 943cdf0e10cSrcweir if( !xRet.is() ) 944cdf0e10cSrcweir xRet.set( this ); 945cdf0e10cSrcweir 946cdf0e10cSrcweir return xRet; 947cdf0e10cSrcweir } 948cdf0e10cSrcweir private: 949cdf0e10cSrcweir OUString msPtsTypes; 950cdf0e10cSrcweir sal_Int32 mnPathEditMode; 951cdf0e10cSrcweir sal_Int32 mnAngle; 952cdf0e10cSrcweir }; 953cdf0e10cSrcweir 954cdf0e10cSrcweir 955cdf0e10cSrcweir /** CT_TLAnimateEffectBehavior */ 956cdf0e10cSrcweir class AnimEffectContext 957cdf0e10cSrcweir : public TimeNodeContext 958cdf0e10cSrcweir { 959cdf0e10cSrcweir public: 960cdf0e10cSrcweir AnimEffectContext( ContextHandler& rParent, sal_Int32 aElement, 961cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs, 962cdf0e10cSrcweir const TimeNodePtr & pNode ) throw() 963cdf0e10cSrcweir : TimeNodeContext( rParent, aElement, xAttribs, pNode ) 964cdf0e10cSrcweir { 965cdf0e10cSrcweir sal_Int32 nDir = xAttribs->getOptionalValueToken( XML_transition, 0 ); 966cdf0e10cSrcweir OUString sFilter = xAttribs->getOptionalValue( XML_filter ); 967cdf0e10cSrcweir // TODO 968cdf0e10cSrcweir // OUString sPrList = xAttribs->getOptionalValue( XML_prLst ); 969cdf0e10cSrcweir 970cdf0e10cSrcweir if( sFilter.getLength() ) 971cdf0e10cSrcweir { 972cdf0e10cSrcweir SlideTransition aFilter( sFilter ); 973cdf0e10cSrcweir aFilter.setMode( nDir == XML_out ? false : true ); 974cdf0e10cSrcweir pNode->setTransitionFilter( aFilter ); 975cdf0e10cSrcweir } 976cdf0e10cSrcweir } 977cdf0e10cSrcweir 978cdf0e10cSrcweir 979cdf0e10cSrcweir ~AnimEffectContext( ) throw() 980cdf0e10cSrcweir { 981cdf0e10cSrcweir } 982cdf0e10cSrcweir 983cdf0e10cSrcweir 984cdf0e10cSrcweir virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) 985cdf0e10cSrcweir { 986cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 987cdf0e10cSrcweir 988cdf0e10cSrcweir switch ( aElementToken ) 989cdf0e10cSrcweir { 990cdf0e10cSrcweir case PPT_TOKEN( cBhvr ): 991cdf0e10cSrcweir xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); 992cdf0e10cSrcweir break; 993cdf0e10cSrcweir case PPT_TOKEN( progress ): 994cdf0e10cSrcweir xRet.set( new AnimVariantContext( *this, aElementToken, maProgress ) ); 995cdf0e10cSrcweir // TODO handle it. 996cdf0e10cSrcweir break; 997cdf0e10cSrcweir default: 998cdf0e10cSrcweir break; 999cdf0e10cSrcweir } 1000cdf0e10cSrcweir 1001cdf0e10cSrcweir if( !xRet.is() ) 1002cdf0e10cSrcweir xRet.set( this ); 1003cdf0e10cSrcweir 1004cdf0e10cSrcweir return xRet; 1005cdf0e10cSrcweir } 1006cdf0e10cSrcweir private: 1007cdf0e10cSrcweir Any maProgress; 1008cdf0e10cSrcweir OUString msFilter; 1009cdf0e10cSrcweir OUString msPrList; 1010cdf0e10cSrcweir }; 1011cdf0e10cSrcweir 1012cdf0e10cSrcweir 1013cdf0e10cSrcweir 1014cdf0e10cSrcweir TimeNodeContext * TimeNodeContext::makeContext( 1015cdf0e10cSrcweir ContextHandler& rParent, sal_Int32 aElement, 1016cdf0e10cSrcweir const Reference< XFastAttributeList >& xAttribs, 1017cdf0e10cSrcweir const TimeNodePtr & pNode ) 1018cdf0e10cSrcweir { 1019cdf0e10cSrcweir TimeNodeContext *pCtx = NULL; 1020cdf0e10cSrcweir switch( aElement ) 1021cdf0e10cSrcweir { 1022cdf0e10cSrcweir case PPT_TOKEN( animClr ): 1023cdf0e10cSrcweir pCtx = new AnimColorContext( rParent, aElement, xAttribs, pNode ); 1024cdf0e10cSrcweir break; 1025cdf0e10cSrcweir case PPT_TOKEN( par ): 1026cdf0e10cSrcweir pCtx = new ParallelExclTimeNodeContext( rParent, aElement, xAttribs, pNode ); 1027cdf0e10cSrcweir break; 1028cdf0e10cSrcweir case PPT_TOKEN( seq ): 1029cdf0e10cSrcweir pCtx = new SequenceTimeNodeContext( rParent, aElement, xAttribs, pNode ); 1030cdf0e10cSrcweir break; 1031cdf0e10cSrcweir case PPT_TOKEN( excl ): 1032cdf0e10cSrcweir pCtx = new ParallelExclTimeNodeContext( rParent, aElement, xAttribs, pNode ); 1033cdf0e10cSrcweir break; 1034cdf0e10cSrcweir case PPT_TOKEN( anim ): 1035cdf0e10cSrcweir pCtx = new AnimContext ( rParent, aElement, xAttribs, pNode ); 1036cdf0e10cSrcweir break; 1037cdf0e10cSrcweir case PPT_TOKEN( animEffect ): 1038cdf0e10cSrcweir pCtx = new AnimEffectContext( rParent, aElement, xAttribs, pNode ); 1039cdf0e10cSrcweir break; 1040cdf0e10cSrcweir case PPT_TOKEN( animMotion ): 1041cdf0e10cSrcweir pCtx = new AnimMotionContext( rParent, aElement, xAttribs, pNode ); 1042cdf0e10cSrcweir break; 1043cdf0e10cSrcweir case PPT_TOKEN( animRot ): 1044cdf0e10cSrcweir pCtx = new AnimRotContext( rParent, aElement, xAttribs, pNode ); 1045cdf0e10cSrcweir break; 1046cdf0e10cSrcweir case PPT_TOKEN( animScale ): 1047cdf0e10cSrcweir pCtx = new AnimScaleContext( rParent, aElement, xAttribs, pNode ); 1048cdf0e10cSrcweir break; 1049cdf0e10cSrcweir case PPT_TOKEN( cmd ): 1050cdf0e10cSrcweir pCtx = new CmdTimeNodeContext( rParent, aElement, xAttribs, pNode ); 1051cdf0e10cSrcweir break; 1052cdf0e10cSrcweir case PPT_TOKEN( set ): 1053cdf0e10cSrcweir pCtx = new SetTimeNodeContext( rParent, aElement, xAttribs, pNode ); 1054cdf0e10cSrcweir break; 1055cdf0e10cSrcweir case PPT_TOKEN( audio ): 1056cdf0e10cSrcweir case PPT_TOKEN( video ): 1057cdf0e10cSrcweir pCtx = new MediaNodeContext( rParent, aElement, xAttribs, pNode ); 1058cdf0e10cSrcweir break; 1059cdf0e10cSrcweir default: 1060cdf0e10cSrcweir break; 1061cdf0e10cSrcweir } 1062cdf0e10cSrcweir return pCtx; 1063cdf0e10cSrcweir } 1064cdf0e10cSrcweir 1065cdf0e10cSrcweir 1066cdf0e10cSrcweir TimeNodeContext::TimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, 1067cdf0e10cSrcweir const Reference< XFastAttributeList >& /*xAttribs*/, 1068cdf0e10cSrcweir const TimeNodePtr & pNode ) throw() 1069cdf0e10cSrcweir : ContextHandler( rParent ) 1070cdf0e10cSrcweir , mnElement( aElement ) 1071cdf0e10cSrcweir , mpNode( pNode ) 1072cdf0e10cSrcweir { 1073cdf0e10cSrcweir } 1074cdf0e10cSrcweir 1075cdf0e10cSrcweir 1076cdf0e10cSrcweir TimeNodeContext::~TimeNodeContext( ) throw() 1077cdf0e10cSrcweir { 1078cdf0e10cSrcweir 1079cdf0e10cSrcweir } 1080cdf0e10cSrcweir 1081cdf0e10cSrcweir 1082cdf0e10cSrcweir TimeNodeListContext::TimeNodeListContext( ContextHandler& rParent, TimeNodePtrList & aList ) 1083cdf0e10cSrcweir throw() 1084cdf0e10cSrcweir : ContextHandler( rParent ) 1085cdf0e10cSrcweir , maList( aList ) 1086cdf0e10cSrcweir { 1087cdf0e10cSrcweir } 1088cdf0e10cSrcweir 1089cdf0e10cSrcweir 1090cdf0e10cSrcweir TimeNodeListContext::~TimeNodeListContext( ) throw() 1091cdf0e10cSrcweir { 1092cdf0e10cSrcweir } 1093cdf0e10cSrcweir 1094cdf0e10cSrcweir 1095cdf0e10cSrcweir Reference< XFastContextHandler > SAL_CALL TimeNodeListContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) 1096cdf0e10cSrcweir { 1097cdf0e10cSrcweir Reference< XFastContextHandler > xRet; 1098cdf0e10cSrcweir 1099cdf0e10cSrcweir sal_Int16 nNodeType; 1100cdf0e10cSrcweir 1101cdf0e10cSrcweir switch( aElementToken ) 1102cdf0e10cSrcweir { 1103cdf0e10cSrcweir case PPT_TOKEN( par ): 1104cdf0e10cSrcweir nNodeType = AnimationNodeType::PAR; 1105cdf0e10cSrcweir break; 1106cdf0e10cSrcweir case PPT_TOKEN( seq ): 1107cdf0e10cSrcweir nNodeType = AnimationNodeType::SEQ; 1108cdf0e10cSrcweir break; 1109cdf0e10cSrcweir case PPT_TOKEN( excl ): 1110cdf0e10cSrcweir // TODO pick the right type. We choose parallel for now as 1111cdf0e10cSrcweir // there does not seem to be an "Exclusive" 1112cdf0e10cSrcweir nNodeType = AnimationNodeType::PAR; 1113cdf0e10cSrcweir break; 1114cdf0e10cSrcweir case PPT_TOKEN( anim ): 1115cdf0e10cSrcweir nNodeType = AnimationNodeType::ANIMATE; 1116cdf0e10cSrcweir break; 1117cdf0e10cSrcweir case PPT_TOKEN( animClr ): 1118cdf0e10cSrcweir nNodeType = AnimationNodeType::ANIMATECOLOR; 1119cdf0e10cSrcweir break; 1120cdf0e10cSrcweir case PPT_TOKEN( animEffect ): 1121cdf0e10cSrcweir nNodeType = AnimationNodeType::TRANSITIONFILTER; 1122cdf0e10cSrcweir break; 1123cdf0e10cSrcweir case PPT_TOKEN( animMotion ): 1124cdf0e10cSrcweir nNodeType = AnimationNodeType::ANIMATEMOTION; 1125cdf0e10cSrcweir break; 1126cdf0e10cSrcweir case PPT_TOKEN( animRot ): 1127cdf0e10cSrcweir case PPT_TOKEN( animScale ): 1128cdf0e10cSrcweir nNodeType = AnimationNodeType::ANIMATETRANSFORM; 1129cdf0e10cSrcweir break; 1130cdf0e10cSrcweir case PPT_TOKEN( cmd ): 1131cdf0e10cSrcweir nNodeType = AnimationNodeType::COMMAND; 1132cdf0e10cSrcweir break; 1133cdf0e10cSrcweir case PPT_TOKEN( set ): 1134cdf0e10cSrcweir nNodeType = AnimationNodeType::SET; 1135cdf0e10cSrcweir break; 1136cdf0e10cSrcweir case PPT_TOKEN( audio ): 1137cdf0e10cSrcweir nNodeType = AnimationNodeType::AUDIO; 1138cdf0e10cSrcweir break; 1139cdf0e10cSrcweir case PPT_TOKEN( video ): 1140cdf0e10cSrcweir nNodeType = AnimationNodeType::AUDIO; 1141cdf0e10cSrcweir OSL_TRACE( "OOX: video requested, gave Audio instead" ); 1142cdf0e10cSrcweir break; 1143cdf0e10cSrcweir 1144cdf0e10cSrcweir default: 1145cdf0e10cSrcweir nNodeType = AnimationNodeType::CUSTOM; 1146cdf0e10cSrcweir OSL_TRACE( "OOX: uhandled token %x", aElementToken ); 1147cdf0e10cSrcweir break; 1148cdf0e10cSrcweir } 1149cdf0e10cSrcweir 1150cdf0e10cSrcweir TimeNodePtr pNode(new TimeNode(nNodeType)); 1151cdf0e10cSrcweir maList.push_back( pNode ); 1152cdf0e10cSrcweir ContextHandler * pContext = TimeNodeContext::makeContext( *this, aElementToken, xAttribs, pNode ); 1153cdf0e10cSrcweir xRet.set( pContext ? pContext : this ); 1154cdf0e10cSrcweir 1155cdf0e10cSrcweir return xRet; 1156cdf0e10cSrcweir } 1157cdf0e10cSrcweir 1158cdf0e10cSrcweir 1159cdf0e10cSrcweir } } 1160