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 // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <tools/debug.hxx> 32*cdf0e10cSrcweir #include <tools/time.hxx> 33*cdf0e10cSrcweir #include "unointerfacetouniqueidentifiermapper.hxx" 34*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/animations/AnimationTransformType.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimationNodeSupplier.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/presentation/AnimationEffect.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/presentation/AnimationSpeed.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/animations/AnimationNodeType.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/animations/XIterateContainer.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimateMotion.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimateColor.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimateTransform.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/animations/XTransitionFilter.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/animations/XCommand.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/animations/XAudio.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/animations/ValuePair.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/animations/AnimationColorSpace.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/presentation/EffectPresetClass.hpp> 51*cdf0e10cSrcweir #include <com/sun/star/animations/Timing.hpp> 52*cdf0e10cSrcweir #include <com/sun/star/animations/Event.hpp> 53*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 54*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp> 55*cdf0e10cSrcweir #include <com/sun/star/text/XTextCursor.hpp> 56*cdf0e10cSrcweir #include <com/sun/star/text/XTextRangeCompare.hpp> 57*cdf0e10cSrcweir #include <com/sun/star/presentation/ParagraphTarget.hpp> 58*cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp> 59*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 60*cdf0e10cSrcweir #include <com/sun/star/animations/EventTrigger.hpp> 61*cdf0e10cSrcweir #include <com/sun/star/presentation/EffectCommands.hpp> 62*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 63*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir #include <list> 66*cdf0e10cSrcweir #include <xmloff/xmltypes.hxx> 67*cdf0e10cSrcweir #include "sdpropls.hxx" 68*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 69*cdf0e10cSrcweir #include <xmloff/xmlimp.hxx> 70*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 71*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 72*cdf0e10cSrcweir #include <osl/mutex.hxx> 73*cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 74*cdf0e10cSrcweir #include "anim.hxx" 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir #include "animations.hxx" 77*cdf0e10cSrcweir #include "animationimport.hxx" 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir using ::rtl::OUString; 80*cdf0e10cSrcweir using ::rtl::OUStringBuffer; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir using namespace ::std; 83*cdf0e10cSrcweir using namespace ::cppu; 84*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 85*cdf0e10cSrcweir using namespace ::com::sun::star::animations; 86*cdf0e10cSrcweir using namespace ::com::sun::star::presentation; 87*cdf0e10cSrcweir using namespace ::com::sun::star::drawing; 88*cdf0e10cSrcweir using namespace ::xmloff::token; 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir using ::com::sun::star::xml::sax::XAttributeList; 91*cdf0e10cSrcweir using ::com::sun::star::uno::Any; 92*cdf0e10cSrcweir using ::com::sun::star::uno::makeAny; 93*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 94*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW; 95*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 96*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 97*cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 98*cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 99*cdf0e10cSrcweir using ::com::sun::star::uno::XInterface; 100*cdf0e10cSrcweir using ::com::sun::star::uno::Type; 101*cdf0e10cSrcweir using ::com::sun::star::beans::NamedValue; 102*cdf0e10cSrcweir using ::com::sun::star::text::XTextRange; 103*cdf0e10cSrcweir using ::com::sun::star::text::XTextCursor; 104*cdf0e10cSrcweir using ::com::sun::star::text::XTextRangeCompare; 105*cdf0e10cSrcweir using ::com::sun::star::container::XEnumerationAccess; 106*cdf0e10cSrcweir using ::com::sun::star::container::XEnumeration; 107*cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory; 108*cdf0e10cSrcweir using ::com::sun::star::lang::XInitialization; 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir namespace xmloff 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir class AnimationsImportHelperImpl 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir private: 125*cdf0e10cSrcweir SvXMLImport& mrImport; 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir SvXMLTokenMap* mpAnimationNodeTokenMap; 128*cdf0e10cSrcweir SvXMLTokenMap* mpAnimationNodeAttributeTokenMap; 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir public: 131*cdf0e10cSrcweir AnimationsImportHelperImpl( SvXMLImport& rImport ); 132*cdf0e10cSrcweir ~AnimationsImportHelperImpl(); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir const SvXMLTokenMap& getAnimationNodeTokenMap(); 135*cdf0e10cSrcweir const SvXMLTokenMap& getAnimationNodeAttributeTokenMap(); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir Any convertValue( XMLTokenEnum eAttributeName, const OUString& rValue ); 138*cdf0e10cSrcweir Sequence< Any > convertValueSequence( XMLTokenEnum eAttributeName, const OUString& rValue ); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir Any convertTarget( const OUString& rValue ); 141*cdf0e10cSrcweir Any convertPath( const OUString& rValue ); 142*cdf0e10cSrcweir Any convertTiming( const OUString& rValue ); 143*cdf0e10cSrcweir Sequence< double > convertKeyTimes( const OUString& rValue ); 144*cdf0e10cSrcweir Sequence< TimeFilterPair > convertTimeFilter( const OUString& rValue ); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir bool convertAnimationValue( XMLTokenEnum eAttributeName, Any& rValue ); 147*cdf0e10cSrcweir const OUString mastrHSL; 148*cdf0e10cSrcweir }; 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir AnimationsImportHelperImpl::AnimationsImportHelperImpl( SvXMLImport& rImport ) 151*cdf0e10cSrcweir : mrImport( rImport ), 152*cdf0e10cSrcweir mpAnimationNodeTokenMap( NULL ), 153*cdf0e10cSrcweir mpAnimationNodeAttributeTokenMap( NULL ), 154*cdf0e10cSrcweir mastrHSL( RTL_CONSTASCII_USTRINGPARAM( "hsl" ) ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir AnimationsImportHelperImpl::~AnimationsImportHelperImpl() 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir delete mpAnimationNodeTokenMap; 161*cdf0e10cSrcweir delete mpAnimationNodeAttributeTokenMap; 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir const SvXMLTokenMap& AnimationsImportHelperImpl::getAnimationNodeTokenMap() 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir if( mpAnimationNodeTokenMap == NULL ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aAnimationNodeTokenMap[] = 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_PAR, (sal_uInt16)AnimationNodeType::PAR }, 171*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_SEQ, (sal_uInt16)AnimationNodeType::SEQ }, 172*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_ITERATE, (sal_uInt16)AnimationNodeType::ITERATE }, 173*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_ANIMATE, (sal_uInt16)AnimationNodeType::ANIMATE }, 174*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_SET, (sal_uInt16)AnimationNodeType::SET }, 175*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_ANIMATEMOTION, (sal_uInt16)AnimationNodeType::ANIMATEMOTION }, 176*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_ANIMATECOLOR, (sal_uInt16)AnimationNodeType::ANIMATECOLOR }, 177*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_ANIMATETRANSFORM, (sal_uInt16)AnimationNodeType::ANIMATETRANSFORM }, 178*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_TRANSITIONFILTER, (sal_uInt16)AnimationNodeType::TRANSITIONFILTER }, 179*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_AUDIO, (sal_uInt16)AnimationNodeType::AUDIO }, 180*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_COMMAND, (sal_uInt16)AnimationNodeType::COMMAND }, 181*cdf0e10cSrcweir XML_TOKEN_MAP_END 182*cdf0e10cSrcweir }; 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir mpAnimationNodeTokenMap = new SvXMLTokenMap( aAnimationNodeTokenMap ); 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir return *mpAnimationNodeTokenMap; 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir enum AnimationNodeAttributes 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir ANA_Begin, 193*cdf0e10cSrcweir ANA_Dur, 194*cdf0e10cSrcweir ANA_End, 195*cdf0e10cSrcweir ANA_Fill, 196*cdf0e10cSrcweir ANA_FillDefault, 197*cdf0e10cSrcweir ANA_Restart, 198*cdf0e10cSrcweir ANA_RestartDefault, 199*cdf0e10cSrcweir ANA_Accelerate, 200*cdf0e10cSrcweir ANA_Decelerate, 201*cdf0e10cSrcweir ANA_AutoReverse, 202*cdf0e10cSrcweir ANA_RepeatCount, 203*cdf0e10cSrcweir ANA_RepeatDur, 204*cdf0e10cSrcweir ANA_EndSync, 205*cdf0e10cSrcweir ANA_Node_Type, 206*cdf0e10cSrcweir ANA_Preset_ID, 207*cdf0e10cSrcweir ANA_Preset_Sub_Type, 208*cdf0e10cSrcweir ANA_Preset_Class, 209*cdf0e10cSrcweir ANA_After_Effect, 210*cdf0e10cSrcweir ANA_Target, 211*cdf0e10cSrcweir ANA_XLink, 212*cdf0e10cSrcweir ANA_MasterElement, 213*cdf0e10cSrcweir ANA_SubItem, 214*cdf0e10cSrcweir ANA_AttributeName, 215*cdf0e10cSrcweir ANA_Values, 216*cdf0e10cSrcweir ANA_From, 217*cdf0e10cSrcweir ANA_By, 218*cdf0e10cSrcweir ANA_To, 219*cdf0e10cSrcweir ANA_KeyTimes, 220*cdf0e10cSrcweir ANA_CalcMode, 221*cdf0e10cSrcweir ANA_Accumulate, 222*cdf0e10cSrcweir ANA_AdditiveMode, 223*cdf0e10cSrcweir ANA_KeySplines, 224*cdf0e10cSrcweir ANA_Path, 225*cdf0e10cSrcweir ANA_ColorSpace, 226*cdf0e10cSrcweir ANA_ColorDirection, 227*cdf0e10cSrcweir ANA_TransformType, 228*cdf0e10cSrcweir ANA_TransitionType, 229*cdf0e10cSrcweir ANA_TransitionSubType, 230*cdf0e10cSrcweir ANA_Mode, 231*cdf0e10cSrcweir ANA_Direction, 232*cdf0e10cSrcweir ANA_FadeColor, 233*cdf0e10cSrcweir ANA_IterateType, 234*cdf0e10cSrcweir ANA_IterateInterval, 235*cdf0e10cSrcweir ANA_Formula, 236*cdf0e10cSrcweir ANA_ANIMID, 237*cdf0e10cSrcweir ANA_XMLID, 238*cdf0e10cSrcweir ANA_Group_Id, 239*cdf0e10cSrcweir ANA_Command, 240*cdf0e10cSrcweir ANA_Volume 241*cdf0e10cSrcweir }; 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir const SvXMLTokenMap& AnimationsImportHelperImpl::getAnimationNodeAttributeTokenMap() 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir if( mpAnimationNodeAttributeTokenMap == NULL ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aAnimationNodeAttributeTokenMap[] = 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_BEGIN, (sal_uInt16)ANA_Begin }, 250*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_DUR, (sal_uInt16)ANA_Dur }, 251*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_END, (sal_uInt16)ANA_End }, 252*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_FILL, (sal_uInt16)ANA_Fill }, 253*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_FILLDEFAULT, (sal_uInt16)ANA_FillDefault }, 254*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_RESTART, (sal_uInt16)ANA_Restart }, 255*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_RESTARTDEFAULT, (sal_uInt16)ANA_RestartDefault }, 256*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_ACCELERATE, (sal_uInt16)ANA_Accelerate }, 257*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_DECELERATE, (sal_uInt16)ANA_Decelerate }, 258*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_AUTOREVERSE, (sal_uInt16)ANA_AutoReverse }, 259*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_REPEATCOUNT, (sal_uInt16)ANA_RepeatCount }, 260*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_REPEATDUR, (sal_uInt16)ANA_RepeatDur }, 261*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_ENDSYNC, (sal_uInt16)ANA_EndSync }, 262*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_NODE_TYPE, (sal_uInt16)ANA_Node_Type }, 263*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_PRESET_ID, (sal_uInt16)ANA_Preset_ID }, 264*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_PRESET_SUB_TYPE, (sal_uInt16)ANA_Preset_Sub_Type }, 265*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_PRESET_CLASS, (sal_uInt16)ANA_Preset_Class }, 266*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_AFTER_EFFECT, (sal_uInt16)ANA_After_Effect }, 267*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_TARGETELEMENT, (sal_uInt16)ANA_Target }, 268*cdf0e10cSrcweir { XML_NAMESPACE_XLINK, XML_HREF, (sal_uInt16)ANA_XLink }, 269*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_MASTER_ELEMENT, (sal_uInt16)ANA_MasterElement }, 270*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_SUB_ITEM, (sal_uInt16)ANA_SubItem }, 271*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, (sal_uInt16)ANA_AttributeName }, 272*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_VALUES, (sal_uInt16)ANA_Values }, 273*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_FROM, (sal_uInt16)ANA_From }, 274*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_BY, (sal_uInt16)ANA_By }, 275*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_TO, (sal_uInt16)ANA_To }, 276*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_KEYTIMES, (sal_uInt16)ANA_KeyTimes }, 277*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_CALCMODE, (sal_uInt16)ANA_CalcMode }, 278*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_ACCUMULATE, (sal_uInt16)ANA_Accumulate }, 279*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_ADDITIVE, (sal_uInt16)ANA_AdditiveMode }, 280*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_ADDITIVE, (sal_uInt16)ANA_AdditiveMode }, 281*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_KEYSPLINES, (sal_uInt16)ANA_KeySplines }, 282*cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_PATH, (sal_uInt16)ANA_Path }, 283*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_COLOR_INTERPOLATION, (sal_uInt16)ANA_ColorSpace }, 284*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_COLOR_INTERPOLATION_DIRECTION, (sal_uInt16)ANA_ColorDirection }, 285*cdf0e10cSrcweir { XML_NAMESPACE_SVG, XML_TYPE, (sal_uInt16)ANA_TransformType }, 286*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_TYPE, (sal_uInt16)ANA_TransitionType }, 287*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_SUBTYPE, (sal_uInt16)ANA_TransitionSubType }, 288*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_MODE, (sal_uInt16)ANA_Mode }, 289*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_DIRECTION, (sal_uInt16)ANA_Direction }, 290*cdf0e10cSrcweir { XML_NAMESPACE_SMIL, XML_FADECOLOR, (sal_uInt16)ANA_FadeColor }, 291*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_ITERATE_TYPE, (sal_uInt16)ANA_IterateType }, 292*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_ITERATE_INTERVAL, (sal_uInt16)ANA_IterateInterval }, 293*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_FORMULA, (sal_uInt16)ANA_Formula }, 294*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_ID, (sal_uInt16)ANA_ANIMID }, 295*cdf0e10cSrcweir { XML_NAMESPACE_XML, XML_ID, (sal_uInt16)ANA_XMLID }, 296*cdf0e10cSrcweir { XML_NAMESPACE_PRESENTATION, XML_GROUP_ID, (sal_uInt16)ANA_Group_Id }, 297*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_AUDIO_LEVEL, (sal_uInt16)ANA_Volume }, 298*cdf0e10cSrcweir { XML_NAMESPACE_ANIMATION, XML_COMMAND, (sal_uInt16)ANA_Command }, 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir XML_TOKEN_MAP_END 301*cdf0e10cSrcweir }; 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir mpAnimationNodeAttributeTokenMap = new SvXMLTokenMap( aAnimationNodeAttributeTokenMap ); 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir return *mpAnimationNodeAttributeTokenMap; 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir static bool isDouble( const OUString& rValue ) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir sal_Int32 nLength = rValue.getLength(); 312*cdf0e10cSrcweir const sal_Unicode * pStr = rValue.getStr(); 313*cdf0e10cSrcweir while( nLength ) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir if( (*pStr >= '0' && *pStr <= '9') || *pStr == '-' || *pStr == '.' || *pStr == '+' || *pStr == 'e' || *pStr == 'E' ) 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir pStr++; 318*cdf0e10cSrcweir nLength--; 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir else 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir return false; 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir return true; 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir static bool isTime( const OUString& rValue ) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir sal_Int32 nLength = rValue.getLength(); 332*cdf0e10cSrcweir const sal_Unicode * pStr; 333*cdf0e10cSrcweir for( pStr = rValue.getStr(); nLength; pStr++, nLength-- ) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir if( !( (*pStr >= '0' && *pStr <= '9') || *pStr == '-' || *pStr == '.' || *pStr == '+' || *pStr == 'e' || *pStr == 'E' ) ) 336*cdf0e10cSrcweir break; 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir // return true if this is a double (if someone forgot the 's' we silently ignore it) 340*cdf0e10cSrcweir // or if its a double that ends with a 's' or 'S' 341*cdf0e10cSrcweir return (nLength == 0) || ((*pStr == 's' || *pStr == 'S') && (nLength == 1)); 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir static sal_Int32 count_codes( const OUString& rString, sal_Unicode nCode ) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir sal_Int32 nCount = 0; 347*cdf0e10cSrcweir sal_Int32 fromIndex = 0; 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir while(true) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir fromIndex = rString.indexOf( nCode, fromIndex ); 352*cdf0e10cSrcweir if( fromIndex == -1 ) 353*cdf0e10cSrcweir break; 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir fromIndex++; 356*cdf0e10cSrcweir nCount++; 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir return nCount; 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir Any AnimationsImportHelperImpl::convertTarget( const OUString& rValue ) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir try 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir Reference< XInterface > xRef( mrImport.getInterfaceToIdentifierMapper().getReference( rValue ) ); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir Reference< XShape > _xShape( xRef, UNO_QUERY ); 369*cdf0e10cSrcweir if( _xShape.is() ) 370*cdf0e10cSrcweir return makeAny( _xShape ); 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir Reference< XTextCursor > xTextCursor( xRef, UNO_QUERY ); 373*cdf0e10cSrcweir if( xTextCursor.is() ) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir Reference< XTextRange > xStart( xTextCursor->getStart() ), xRange; 376*cdf0e10cSrcweir Reference< XShape > xShape( xTextCursor->getText(), UNO_QUERY_THROW ); 377*cdf0e10cSrcweir Reference< XTextRangeCompare > xTextRangeCompare( xShape, UNO_QUERY_THROW ); 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir Reference< XEnumerationAccess > xParaEnumAccess( xShape, UNO_QUERY_THROW ); 380*cdf0e10cSrcweir Reference< XEnumeration > xEnumeration( xParaEnumAccess->createEnumeration(), UNO_QUERY_THROW ); 381*cdf0e10cSrcweir sal_Int16 nParagraph = 0; 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir while( xEnumeration->hasMoreElements() ) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir xEnumeration->nextElement() >>= xRange; 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir // break if start of selection is prior to end of current paragraph 388*cdf0e10cSrcweir if( xRange.is() && (xTextRangeCompare->compareRegionEnds( xStart, xRange ) >= 0 ) ) 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir return makeAny( ParagraphTarget( xShape, nParagraph ) ); 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir nParagraph++; 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir catch( RuntimeException& ) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir DBG_ERROR( "xmloff::AnimationsImportImpl::convertTarget(), RuntimeException catched!" ); 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir Any aAny; 403*cdf0e10cSrcweir return aAny; 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir Any AnimationsImportHelperImpl::convertValue( XMLTokenEnum eAttributeName, const OUString& rValue ) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir sal_Int32 nCommaPos = -1, nPos; 409*cdf0e10cSrcweir sal_Int32 nOpenBrakets = 0; 410*cdf0e10cSrcweir for( nPos = 0; (nPos < rValue.getLength()) && (nCommaPos == -1); nPos++ ) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir switch( rValue[nPos] ) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir case ',': 415*cdf0e10cSrcweir if( nOpenBrakets == 0 ) 416*cdf0e10cSrcweir nCommaPos = nPos; 417*cdf0e10cSrcweir break; 418*cdf0e10cSrcweir case '(': 419*cdf0e10cSrcweir case '[': 420*cdf0e10cSrcweir case '{': 421*cdf0e10cSrcweir nOpenBrakets++; 422*cdf0e10cSrcweir break; 423*cdf0e10cSrcweir case ')': 424*cdf0e10cSrcweir case ']': 425*cdf0e10cSrcweir case '}': 426*cdf0e10cSrcweir nOpenBrakets--; 427*cdf0e10cSrcweir break; 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir if( nCommaPos >= 0 ) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir ValuePair aPair; 434*cdf0e10cSrcweir aPair.First = convertValue( eAttributeName, rValue.copy( 0, nCommaPos ) ); 435*cdf0e10cSrcweir aPair.Second = convertValue( eAttributeName, rValue.copy( nCommaPos+1, rValue.getLength() - nCommaPos - 1 ) ); 436*cdf0e10cSrcweir return makeAny( aPair ); 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir else 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir Any aAny; 441*cdf0e10cSrcweir sal_Int32 nType = XML_TYPE_STRING; 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir if( rValue.getLength() ) switch( eAttributeName ) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir case XML_X: 446*cdf0e10cSrcweir case XML_Y: 447*cdf0e10cSrcweir case XML_WIDTH: 448*cdf0e10cSrcweir case XML_HEIGHT: 449*cdf0e10cSrcweir case XML_TRANSLATE: 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir return makeAny( rValue ); 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir case XML_SCALE: 455*cdf0e10cSrcweir case XML_SKEWY: 456*cdf0e10cSrcweir case XML_SKEWX: 457*cdf0e10cSrcweir case XML_OPACITY: 458*cdf0e10cSrcweir case XML_ROTATE: nType = XML_TYPE_DOUBLE; break; 459*cdf0e10cSrcweir case XML_TEXT_ROTATION_ANGLE:nType = XML_TYPE_TEXT_ROTATION_ANGLE; break; 460*cdf0e10cSrcweir case XML_FILL_COLOR: 461*cdf0e10cSrcweir case XML_STROKE_COLOR: 462*cdf0e10cSrcweir case XML_DIM: 463*cdf0e10cSrcweir case XML_COLOR: nType = XML_TYPE_COLOR; break; 464*cdf0e10cSrcweir case XML_FILL: nType = XML_SD_TYPE_FILLSTYLE; break; 465*cdf0e10cSrcweir case XML_STROKE: nType = XML_SD_TYPE_STROKE; break; 466*cdf0e10cSrcweir case XML_FONT_WEIGHT: nType = XML_TYPE_TEXT_WEIGHT; break; 467*cdf0e10cSrcweir case XML_FONT_STYLE: nType = XML_TYPE_TEXT_POSTURE; break; 468*cdf0e10cSrcweir case XML_TEXT_UNDERLINE: nType = XML_TYPE_TEXT_UNDERLINE_STYLE; break; 469*cdf0e10cSrcweir case XML_FONT_SIZE: nType = XML_TYPE_DOUBLE_PERCENT; break; 470*cdf0e10cSrcweir case XML_VISIBILITY: nType = XML_SD_TYPE_PRESPAGE_VISIBILITY; break; 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir default: 473*cdf0e10cSrcweir if( rValue.getLength() ) 474*cdf0e10cSrcweir aAny <<= rValue; 475*cdf0e10cSrcweir return aAny; 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir const XMLPropertyHandler* pHandler = mrImport.GetShapeImport()->GetSdPropHdlFactory()->GetPropertyHandler( nType ); 479*cdf0e10cSrcweir if( pHandler ) 480*cdf0e10cSrcweir pHandler->importXML( rValue, aAny, mrImport.GetMM100UnitConverter() ); 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir return aAny; 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir /* 485*cdf0e10cSrcweir if( rValue.getLength() == 0 ) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir Any aAny; 488*cdf0e10cSrcweir return aAny; 489*cdf0e10cSrcweir } 490*cdf0e10cSrcweir else if( rValue.indexOf( '#' ) == 0 ) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir // color 493*cdf0e10cSrcweir Color aColor; 494*cdf0e10cSrcweir SvXMLUnitConverter::convertColor( aColor, rValue ); 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir return makeAny( static_cast< sal_Int32 >( aColor.GetRGBColor() ) ); 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir else if( rValue.indexOf( '$' ) != -1 ) 499*cdf0e10cSrcweir { 500*cdf0e10cSrcweir // formula 501*cdf0e10cSrcweir return makeAny( rValue ); 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir else 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir if( isDouble( rValue ) ) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir return makeAny( rValue.toDouble() ); 508*cdf0e10cSrcweir } 509*cdf0e10cSrcweir else 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir return makeAny( rValue ); 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir */ 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir Sequence< Any > AnimationsImportHelperImpl::convertValueSequence( XMLTokenEnum eAttributeName, const OUString& rValue ) 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir Sequence< Any > aValues; 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir // do we have any value at all? 523*cdf0e10cSrcweir if( rValue.getLength() ) 524*cdf0e10cSrcweir { 525*cdf0e10cSrcweir sal_Int32 nElements = count_codes( rValue, (sal_Unicode)';') + 1; // a non empty string has at least one value 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir // prepare the sequence 528*cdf0e10cSrcweir aValues.realloc( nElements ); 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir // fill the sequence 531*cdf0e10cSrcweir Any* pValues = aValues.getArray(); 532*cdf0e10cSrcweir sal_Int32 nIndex, nElement; 533*cdf0e10cSrcweir for( nIndex = 0, nElement = 0; nElements && (nIndex >= 0); nElements-- ) 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir *pValues++ = convertValue( eAttributeName, rValue.getToken( 0, ';', nIndex ) ); 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir return aValues; 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir Any AnimationsImportHelperImpl::convertTiming( const OUString& rValue ) 543*cdf0e10cSrcweir { 544*cdf0e10cSrcweir Any aAny; 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir // do we have any value at all? 547*cdf0e10cSrcweir if( rValue.getLength() ) 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir // count the values 550*cdf0e10cSrcweir sal_Int32 nElements = count_codes( rValue, (sal_Unicode)';' ) + 1; // a non empty string has at least one value 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir if( nElements == 1 ) 553*cdf0e10cSrcweir { 554*cdf0e10cSrcweir if( IsXMLToken( rValue, XML_MEDIA ) ) 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir aAny <<= Timing_MEDIA; 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir else if( IsXMLToken( rValue, XML_INDEFINITE ) ) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir aAny <<= Timing_INDEFINITE; 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir else if( isTime( rValue ) ) 563*cdf0e10cSrcweir { 564*cdf0e10cSrcweir aAny <<= rValue.toDouble(); 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir else 567*cdf0e10cSrcweir { 568*cdf0e10cSrcweir Event aEvent; 569*cdf0e10cSrcweir aEvent.Repeat = 0; 570*cdf0e10cSrcweir aEvent.Trigger = 0; 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir OUString aEventTrigger; 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir sal_Int32 nPos = rValue.indexOf( (sal_Unicode)'+' ); 575*cdf0e10cSrcweir if( nPos == -1 ) 576*cdf0e10cSrcweir { 577*cdf0e10cSrcweir aEventTrigger = rValue; 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir else 580*cdf0e10cSrcweir { 581*cdf0e10cSrcweir aEventTrigger = rValue.copy( 0, nPos ); 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir // convert offset 584*cdf0e10cSrcweir aEvent.Offset <<= convertTiming( rValue.copy( nPos + 1 ) ); 585*cdf0e10cSrcweir } 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir nPos = aEventTrigger.indexOf( (sal_Unicode)'.' ); 588*cdf0e10cSrcweir if( nPos != -1 ) 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir aEvent.Source <<= mrImport.getInterfaceToIdentifierMapper().getReference( aEventTrigger.copy( 0, nPos ) ); 591*cdf0e10cSrcweir aEventTrigger = aEventTrigger.copy( nPos + 1 ); 592*cdf0e10cSrcweir } 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir sal_uInt16 nEnum; 595*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, aEventTrigger, getAnimationsEnumMap(Animations_EnumMap_EventTrigger) ) ) 596*cdf0e10cSrcweir { 597*cdf0e10cSrcweir aEvent.Trigger = (sal_Int16)nEnum; 598*cdf0e10cSrcweir } 599*cdf0e10cSrcweir else 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir DBG_ERROR("AnimationsImportHelperImpl::convertTiming(), unknown event trigger!"); 602*cdf0e10cSrcweir } 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir aAny <<= aEvent; 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir else 608*cdf0e10cSrcweir { 609*cdf0e10cSrcweir // fill the sequence 610*cdf0e10cSrcweir Sequence< Any > aValues( nElements ); 611*cdf0e10cSrcweir Any* pValues = aValues.getArray(); 612*cdf0e10cSrcweir sal_Int32 nIndex = 0; 613*cdf0e10cSrcweir while( (nElements--) && (nIndex >= 0) ) 614*cdf0e10cSrcweir *pValues++ = convertTiming( rValue.getToken( 0, ';', nIndex ) ); 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir aAny <<= aValues; 617*cdf0e10cSrcweir } 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir return aAny; 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir Sequence< double > AnimationsImportHelperImpl::convertKeyTimes( const OUString& rValue ) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir sal_Int32 nElements = 0; 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir if( rValue.getLength() ) 627*cdf0e10cSrcweir nElements = count_codes( rValue, (sal_Unicode)';' ) + 1; // a non empty string has at least one value 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir Sequence< double > aKeyTimes( nElements ); 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir if( nElements ) 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir double* pValues = aKeyTimes.getArray(); 634*cdf0e10cSrcweir sal_Int32 nIndex = 0; 635*cdf0e10cSrcweir while( (nElements--) && (nIndex >= 0) ) 636*cdf0e10cSrcweir *pValues++ = rValue.getToken( 0, ';', nIndex ).toDouble(); 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir return aKeyTimes; 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir Sequence< TimeFilterPair > AnimationsImportHelperImpl::convertTimeFilter( const OUString& rValue ) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir sal_Int32 nElements = 0; 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir if( rValue.getLength() ) 647*cdf0e10cSrcweir nElements = count_codes( rValue, (sal_Unicode)';' ) + 1; // a non empty string has at least one value 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir Sequence< TimeFilterPair > aTimeFilter( nElements ); 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir if( nElements ) 652*cdf0e10cSrcweir { 653*cdf0e10cSrcweir TimeFilterPair* pValues = aTimeFilter.getArray(); 654*cdf0e10cSrcweir sal_Int32 nIndex = 0; 655*cdf0e10cSrcweir while( (nElements--) && (nIndex >= 0) ) 656*cdf0e10cSrcweir { 657*cdf0e10cSrcweir const OUString aToken( rValue.getToken( 0, ';', nIndex ) ); 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir sal_Int32 nPos = aToken.indexOf( ',' ); 660*cdf0e10cSrcweir if( nPos >= 0 ) 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir pValues->Time = aToken.copy( 0, nPos ).toDouble(); 663*cdf0e10cSrcweir pValues->Progress = aToken.copy( nPos+1, aToken.getLength() - nPos - 1 ).toDouble(); 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir pValues++; 666*cdf0e10cSrcweir } 667*cdf0e10cSrcweir } 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir return aTimeFilter; 670*cdf0e10cSrcweir } 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir Any AnimationsImportHelperImpl::convertPath( const OUString& rValue ) 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir return makeAny( rValue ); 675*cdf0e10cSrcweir } 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 678*cdf0e10cSrcweir 679*cdf0e10cSrcweir TYPEINIT1( AnimationNodeContext, SvXMLImportContext ); 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir AnimationNodeContext::AnimationNodeContext( 682*cdf0e10cSrcweir const Reference< XAnimationNode >& xParentNode, 683*cdf0e10cSrcweir SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLocalName, 684*cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 685*cdf0e10cSrcweir AnimationsImportHelperImpl* pHelper /* = NULL */ ) 686*cdf0e10cSrcweir : SvXMLImportContext(rImport, nPrfx, rLocalName), 687*cdf0e10cSrcweir mpHelper( pHelper ), 688*cdf0e10cSrcweir mbRootContext( pHelper == NULL ) 689*cdf0e10cSrcweir { 690*cdf0e10cSrcweir try 691*cdf0e10cSrcweir { 692*cdf0e10cSrcweir if( mbRootContext ) 693*cdf0e10cSrcweir { 694*cdf0e10cSrcweir mpHelper = new AnimationsImportHelperImpl( rImport ); 695*cdf0e10cSrcweir mxNode = xParentNode; 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir else 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir sal_Int16 nPresetClass = EffectPresetClass::CUSTOM; 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir const sal_Char* pServiceName = 0; 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir sal_Int16 nNodeType = (sal_Int16)mpHelper->getAnimationNodeTokenMap().Get( nPrfx, rLocalName ); 706*cdf0e10cSrcweir switch( nNodeType ) 707*cdf0e10cSrcweir { 708*cdf0e10cSrcweir case AnimationNodeType::SEQ: pServiceName = "com.sun.star.animations.SequenceTimeContainer"; break; 709*cdf0e10cSrcweir case AnimationNodeType::ITERATE: pServiceName = "com.sun.star.animations.IterateContainer"; break; 710*cdf0e10cSrcweir case AnimationNodeType::ANIMATE: pServiceName = "com.sun.star.animations.Animate"; break; 711*cdf0e10cSrcweir case AnimationNodeType::SET: pServiceName = "com.sun.star.animations.AnimateSet"; break; 712*cdf0e10cSrcweir case AnimationNodeType::ANIMATEMOTION: pServiceName = "com.sun.star.animations.AnimateMotion"; break; 713*cdf0e10cSrcweir case AnimationNodeType::ANIMATECOLOR: pServiceName = "com.sun.star.animations.AnimateColor"; break; 714*cdf0e10cSrcweir case AnimationNodeType::ANIMATETRANSFORM: pServiceName = "com.sun.star.animations.AnimateTransform"; break; 715*cdf0e10cSrcweir case AnimationNodeType::TRANSITIONFILTER: pServiceName = "com.sun.star.animations.TransitionFilter"; break; 716*cdf0e10cSrcweir case AnimationNodeType::AUDIO: pServiceName = "com.sun.star.animations.Audio"; break; 717*cdf0e10cSrcweir case AnimationNodeType::COMMAND: pServiceName = "com.sun.star.animations.Command"; break; 718*cdf0e10cSrcweir case AnimationNodeType::PAR: 719*cdf0e10cSrcweir { 720*cdf0e10cSrcweir const sal_Int16 nCount = xAttrList.is() ? xAttrList->getLength() : 0; 721*cdf0e10cSrcweir sal_Int16 nAttribute; 722*cdf0e10cSrcweir for( nAttribute = 0; nAttribute < nCount; nAttribute++ ) 723*cdf0e10cSrcweir { 724*cdf0e10cSrcweir OUString aLocalName; 725*cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( nAttribute ), &aLocalName ); 726*cdf0e10cSrcweir if( (nPrefix == XML_NAMESPACE_PRESENTATION) && IsXMLToken( aLocalName, XML_PRESET_ID ) ) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir const OUString& rValue = xAttrList->getValueByIndex( nAttribute ); 729*cdf0e10cSrcweir if( rValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ooo-entrance-random" ) ) ) 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir nPresetClass = EffectPresetClass::ENTRANCE; 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir else if( rValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ooo-exit-random" ) ) ) 734*cdf0e10cSrcweir { 735*cdf0e10cSrcweir nPresetClass = EffectPresetClass::EXIT; 736*cdf0e10cSrcweir } 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir if( nPresetClass != EffectPresetClass::CUSTOM ) 739*cdf0e10cSrcweir { 740*cdf0e10cSrcweir pServiceName = "com.sun.star.comp.sd.RandomAnimationNode"; 741*cdf0e10cSrcweir break; 742*cdf0e10cSrcweir } 743*cdf0e10cSrcweir } 744*cdf0e10cSrcweir } 745*cdf0e10cSrcweir if( !pServiceName ) 746*cdf0e10cSrcweir pServiceName = "com.sun.star.animations.ParallelTimeContainer"; 747*cdf0e10cSrcweir } 748*cdf0e10cSrcweir break; 749*cdf0e10cSrcweir default: 750*cdf0e10cSrcweir pServiceName = 0; 751*cdf0e10cSrcweir } 752*cdf0e10cSrcweir 753*cdf0e10cSrcweir if( pServiceName && xFactory.is() ) 754*cdf0e10cSrcweir { 755*cdf0e10cSrcweir mxNode = Reference< XAnimationNode >( xFactory->createInstance( 756*cdf0e10cSrcweir OUString::createFromAscii(pServiceName) ), UNO_QUERY_THROW ); 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir if( nPresetClass != EffectPresetClass::CUSTOM ) 759*cdf0e10cSrcweir { 760*cdf0e10cSrcweir Reference< XInitialization > xInit( mxNode, UNO_QUERY_THROW ); 761*cdf0e10cSrcweir const Any aAny( makeAny( nPresetClass ) ); 762*cdf0e10cSrcweir Sequence< Any > aArgs( &aAny, 1 ) ; 763*cdf0e10cSrcweir xInit->initialize( aArgs ); 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir init_node( xAttrList ); 767*cdf0e10cSrcweir 768*cdf0e10cSrcweir Reference< XTimeContainer > xParentContainer( xParentNode, UNO_QUERY_THROW ); 769*cdf0e10cSrcweir xParentContainer->appendChild( mxNode ); 770*cdf0e10cSrcweir } 771*cdf0e10cSrcweir } 772*cdf0e10cSrcweir } 773*cdf0e10cSrcweir catch( RuntimeException& ) 774*cdf0e10cSrcweir { 775*cdf0e10cSrcweir DBG_ERROR( "xmloff::AnimationsImportImpl::AnimationsImportImpl(), RuntimeException catched!" ); 776*cdf0e10cSrcweir } 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir AnimationNodeContext::~AnimationNodeContext() 780*cdf0e10cSrcweir { 781*cdf0e10cSrcweir if( mbRootContext ) 782*cdf0e10cSrcweir delete mpHelper; 783*cdf0e10cSrcweir } 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir void AnimationNodeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& ) 786*cdf0e10cSrcweir { 787*cdf0e10cSrcweir // code of StartElement is moved to init_node that is now called 788*cdf0e10cSrcweir // in c'tor before appending this node to its parent. 789*cdf0e10cSrcweir // This is needed for random nodes that need the correct target 790*cdf0e10cSrcweir // set when child nodes are appended. 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir void AnimationNodeContext::init_node( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) 794*cdf0e10cSrcweir { 795*cdf0e10cSrcweir if( mxNode.is() ) try 796*cdf0e10cSrcweir { 797*cdf0e10cSrcweir const sal_Int16 nNodeType = mxNode->getType(); 798*cdf0e10cSrcweir 799*cdf0e10cSrcweir // query for optional interfaces that are often used later 800*cdf0e10cSrcweir Reference< XAnimate > xAnimate( mxNode, UNO_QUERY ); 801*cdf0e10cSrcweir Reference< XCommand > xCommand( mxNode, UNO_QUERY ); 802*cdf0e10cSrcweir Reference< XTransitionFilter > xTransitionFilter( mxNode, UNO_QUERY ); 803*cdf0e10cSrcweir Reference< XIterateContainer > xIter( mxNode, UNO_QUERY ); 804*cdf0e10cSrcweir 805*cdf0e10cSrcweir std::list< NamedValue > aUserData; 806*cdf0e10cSrcweir XMLTokenEnum meAttributeName = XML_TOKEN_INVALID; 807*cdf0e10cSrcweir OUString aFrom, aBy, aTo, aValues; 808*cdf0e10cSrcweir bool bHaveXmlId( false ); 809*cdf0e10cSrcweir OUString sXmlId; 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir const sal_Int16 nCount = xAttrList.is() ? xAttrList->getLength() : 0; 812*cdf0e10cSrcweir sal_uInt16 nEnum; 813*cdf0e10cSrcweir sal_Int16 nAttribute; 814*cdf0e10cSrcweir for( nAttribute = 0; nAttribute < nCount; nAttribute++ ) 815*cdf0e10cSrcweir { 816*cdf0e10cSrcweir const OUString& rAttrName = xAttrList->getNameByIndex( nAttribute ); 817*cdf0e10cSrcweir const OUString& rValue = xAttrList->getValueByIndex( nAttribute ); 818*cdf0e10cSrcweir 819*cdf0e10cSrcweir OUString aLocalName; 820*cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ); 821*cdf0e10cSrcweir switch( mpHelper->getAnimationNodeAttributeTokenMap().Get( nPrefix, aLocalName ) ) 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir case ANA_Begin: 824*cdf0e10cSrcweir { 825*cdf0e10cSrcweir mxNode->setBegin( mpHelper->convertTiming( rValue ) ); 826*cdf0e10cSrcweir } 827*cdf0e10cSrcweir break; 828*cdf0e10cSrcweir case ANA_Dur: 829*cdf0e10cSrcweir { 830*cdf0e10cSrcweir mxNode->setDuration( mpHelper->convertTiming( rValue ) ); 831*cdf0e10cSrcweir } 832*cdf0e10cSrcweir break; 833*cdf0e10cSrcweir case ANA_End: 834*cdf0e10cSrcweir { 835*cdf0e10cSrcweir mxNode->setEnd( mpHelper->convertTiming( rValue ) ); 836*cdf0e10cSrcweir } 837*cdf0e10cSrcweir break; 838*cdf0e10cSrcweir case ANA_Fill: 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_Fill) ) ) 841*cdf0e10cSrcweir mxNode->setFill( (sal_Int16)nEnum ); 842*cdf0e10cSrcweir } 843*cdf0e10cSrcweir break; 844*cdf0e10cSrcweir case ANA_FillDefault: 845*cdf0e10cSrcweir { 846*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_FillDefault) ) ) 847*cdf0e10cSrcweir mxNode->setFillDefault( (sal_Int16)nEnum ); 848*cdf0e10cSrcweir } 849*cdf0e10cSrcweir break; 850*cdf0e10cSrcweir case ANA_Restart: 851*cdf0e10cSrcweir { 852*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_Restart) ) ) 853*cdf0e10cSrcweir mxNode->setRestart( (sal_Int16)nEnum ); 854*cdf0e10cSrcweir } 855*cdf0e10cSrcweir break; 856*cdf0e10cSrcweir case ANA_RestartDefault: 857*cdf0e10cSrcweir { 858*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_RestartDefault) ) ) 859*cdf0e10cSrcweir mxNode->setRestartDefault( (sal_Int16)nEnum ); 860*cdf0e10cSrcweir } 861*cdf0e10cSrcweir break; 862*cdf0e10cSrcweir case ANA_Accelerate: 863*cdf0e10cSrcweir { 864*cdf0e10cSrcweir if( isDouble( rValue ) ) 865*cdf0e10cSrcweir mxNode->setAcceleration( rValue.toDouble() ); 866*cdf0e10cSrcweir } 867*cdf0e10cSrcweir break; 868*cdf0e10cSrcweir case ANA_Decelerate: 869*cdf0e10cSrcweir { 870*cdf0e10cSrcweir if( isDouble( rValue ) ) 871*cdf0e10cSrcweir mxNode->setDecelerate( rValue.toDouble() ); 872*cdf0e10cSrcweir } 873*cdf0e10cSrcweir break; 874*cdf0e10cSrcweir case ANA_AutoReverse: 875*cdf0e10cSrcweir { 876*cdf0e10cSrcweir sal_Bool bTemp; 877*cdf0e10cSrcweir if( SvXMLUnitConverter::convertBool( bTemp, rValue ) ) 878*cdf0e10cSrcweir mxNode->setAutoReverse( bTemp ); 879*cdf0e10cSrcweir } 880*cdf0e10cSrcweir break; 881*cdf0e10cSrcweir case ANA_RepeatCount: 882*cdf0e10cSrcweir { 883*cdf0e10cSrcweir mxNode->setRepeatCount( mpHelper->convertTiming( rValue ) ); 884*cdf0e10cSrcweir } 885*cdf0e10cSrcweir break; 886*cdf0e10cSrcweir case ANA_RepeatDur: 887*cdf0e10cSrcweir { 888*cdf0e10cSrcweir mxNode->setRepeatDuration( mpHelper->convertTiming( rValue ) ); 889*cdf0e10cSrcweir } 890*cdf0e10cSrcweir break; 891*cdf0e10cSrcweir case ANA_EndSync: 892*cdf0e10cSrcweir { 893*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_Endsync) ) ) 894*cdf0e10cSrcweir mxNode->setEndSync( makeAny( (sal_Int16)nEnum ) ); 895*cdf0e10cSrcweir } 896*cdf0e10cSrcweir break; 897*cdf0e10cSrcweir case ANA_Node_Type: 898*cdf0e10cSrcweir { 899*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_EffectNodeType) ) ) 900*cdf0e10cSrcweir aUserData.push_back( NamedValue( GetXMLToken( XML_NODE_TYPE ), makeAny( (sal_Int16)nEnum ) ) ); 901*cdf0e10cSrcweir } 902*cdf0e10cSrcweir break; 903*cdf0e10cSrcweir case ANA_Preset_ID: 904*cdf0e10cSrcweir { 905*cdf0e10cSrcweir aUserData.push_back( NamedValue( GetXMLToken( XML_PRESET_ID ), makeAny( rValue ) ) ); 906*cdf0e10cSrcweir } 907*cdf0e10cSrcweir break; 908*cdf0e10cSrcweir case ANA_Preset_Sub_Type: 909*cdf0e10cSrcweir { 910*cdf0e10cSrcweir aUserData.push_back( NamedValue( GetXMLToken( XML_PRESET_SUB_TYPE ), makeAny( rValue ) ) ); 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir break; 913*cdf0e10cSrcweir case ANA_Preset_Class: 914*cdf0e10cSrcweir { 915*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_EffectPresetClass) ) ) 916*cdf0e10cSrcweir aUserData.push_back( NamedValue( GetXMLToken( XML_PRESET_CLASS ), makeAny( (sal_Int16)nEnum ) ) ); 917*cdf0e10cSrcweir } 918*cdf0e10cSrcweir break; 919*cdf0e10cSrcweir case ANA_After_Effect: 920*cdf0e10cSrcweir { 921*cdf0e10cSrcweir sal_Bool bTemp; 922*cdf0e10cSrcweir if( SvXMLUnitConverter::convertBool( bTemp, rValue ) ) 923*cdf0e10cSrcweir aUserData.push_back( NamedValue( GetXMLToken( XML_AFTER_EFFECT ), makeAny( bTemp ) ) ); 924*cdf0e10cSrcweir } 925*cdf0e10cSrcweir break; 926*cdf0e10cSrcweir case ANA_XLink: 927*cdf0e10cSrcweir { 928*cdf0e10cSrcweir if( nNodeType == AnimationNodeType::AUDIO ) 929*cdf0e10cSrcweir { 930*cdf0e10cSrcweir Reference< XAudio > xAudio( mxNode, UNO_QUERY_THROW ); 931*cdf0e10cSrcweir xAudio->setSource( makeAny( GetImport().GetAbsoluteReference( rValue ) ) ); 932*cdf0e10cSrcweir break; 933*cdf0e10cSrcweir } 934*cdf0e10cSrcweir 935*cdf0e10cSrcweir } 936*cdf0e10cSrcweir // fall through intented! 937*cdf0e10cSrcweir case ANA_Target: 938*cdf0e10cSrcweir { 939*cdf0e10cSrcweir { 940*cdf0e10cSrcweir Any aTarget( mpHelper->convertTarget( rValue ) ); 941*cdf0e10cSrcweir 942*cdf0e10cSrcweir if( xAnimate.is() ) 943*cdf0e10cSrcweir { 944*cdf0e10cSrcweir xAnimate->setTarget( aTarget ); 945*cdf0e10cSrcweir } 946*cdf0e10cSrcweir else if( xIter.is() ) 947*cdf0e10cSrcweir { 948*cdf0e10cSrcweir xIter->setTarget( aTarget ); 949*cdf0e10cSrcweir } 950*cdf0e10cSrcweir else if( xCommand.is() ) 951*cdf0e10cSrcweir { 952*cdf0e10cSrcweir xCommand->setTarget( aTarget ); 953*cdf0e10cSrcweir } 954*cdf0e10cSrcweir } 955*cdf0e10cSrcweir } 956*cdf0e10cSrcweir break; 957*cdf0e10cSrcweir 958*cdf0e10cSrcweir case ANA_Volume: 959*cdf0e10cSrcweir { 960*cdf0e10cSrcweir if( nNodeType == AnimationNodeType::AUDIO ) 961*cdf0e10cSrcweir { 962*cdf0e10cSrcweir if( isDouble( rValue ) ) 963*cdf0e10cSrcweir { 964*cdf0e10cSrcweir Reference< XAudio > xAudio( mxNode, UNO_QUERY_THROW ); 965*cdf0e10cSrcweir xAudio->setVolume( rValue.toDouble() ); 966*cdf0e10cSrcweir } 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir } 969*cdf0e10cSrcweir break; 970*cdf0e10cSrcweir 971*cdf0e10cSrcweir case ANA_MasterElement: 972*cdf0e10cSrcweir { 973*cdf0e10cSrcweir Reference< XAnimationNode > xMaster( GetImport().getInterfaceToIdentifierMapper().getReference( rValue ), UNO_QUERY ); 974*cdf0e10cSrcweir aUserData.push_back( NamedValue( GetXMLToken( XML_MASTER_ELEMENT ), makeAny( xMaster ) ) ); 975*cdf0e10cSrcweir } 976*cdf0e10cSrcweir break; 977*cdf0e10cSrcweir 978*cdf0e10cSrcweir case ANA_SubItem: 979*cdf0e10cSrcweir { 980*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_SubItem) ) ) 981*cdf0e10cSrcweir { 982*cdf0e10cSrcweir if( xAnimate.is() ) 983*cdf0e10cSrcweir { 984*cdf0e10cSrcweir xAnimate->setSubItem( (sal_Int16)nEnum ); 985*cdf0e10cSrcweir } 986*cdf0e10cSrcweir else if( xIter.is() ) 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir xIter->setSubItem( (sal_Int16)nEnum ); 989*cdf0e10cSrcweir } 990*cdf0e10cSrcweir } 991*cdf0e10cSrcweir } 992*cdf0e10cSrcweir break; 993*cdf0e10cSrcweir 994*cdf0e10cSrcweir case ANA_AttributeName: 995*cdf0e10cSrcweir { 996*cdf0e10cSrcweir if( xAnimate.is() ) 997*cdf0e10cSrcweir { 998*cdf0e10cSrcweir OUString aName( rValue ); 999*cdf0e10cSrcweir 1000*cdf0e10cSrcweir ImplAttributeNameConversion* p = getAnimationAttributeNamesConversionList(); 1001*cdf0e10cSrcweir while( p->mpAPIName ) 1002*cdf0e10cSrcweir { 1003*cdf0e10cSrcweir if( IsXMLToken( aName, p->meXMLToken ) ) 1004*cdf0e10cSrcweir { 1005*cdf0e10cSrcweir aName = OUString::createFromAscii( p->mpAPIName ); 1006*cdf0e10cSrcweir meAttributeName = p->meXMLToken; 1007*cdf0e10cSrcweir break; 1008*cdf0e10cSrcweir } 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir p++; 1011*cdf0e10cSrcweir } 1012*cdf0e10cSrcweir 1013*cdf0e10cSrcweir xAnimate->setAttributeName( aName ); 1014*cdf0e10cSrcweir } 1015*cdf0e10cSrcweir } 1016*cdf0e10cSrcweir break; 1017*cdf0e10cSrcweir 1018*cdf0e10cSrcweir case ANA_Values: 1019*cdf0e10cSrcweir { 1020*cdf0e10cSrcweir aValues = rValue; 1021*cdf0e10cSrcweir } 1022*cdf0e10cSrcweir break; 1023*cdf0e10cSrcweir 1024*cdf0e10cSrcweir case ANA_From: 1025*cdf0e10cSrcweir { 1026*cdf0e10cSrcweir aFrom = rValue; 1027*cdf0e10cSrcweir } 1028*cdf0e10cSrcweir break; 1029*cdf0e10cSrcweir 1030*cdf0e10cSrcweir case ANA_By: 1031*cdf0e10cSrcweir { 1032*cdf0e10cSrcweir aBy = rValue; 1033*cdf0e10cSrcweir } 1034*cdf0e10cSrcweir break; 1035*cdf0e10cSrcweir 1036*cdf0e10cSrcweir case ANA_To: 1037*cdf0e10cSrcweir { 1038*cdf0e10cSrcweir aTo = rValue; 1039*cdf0e10cSrcweir } 1040*cdf0e10cSrcweir break; 1041*cdf0e10cSrcweir 1042*cdf0e10cSrcweir case ANA_KeyTimes: 1043*cdf0e10cSrcweir { 1044*cdf0e10cSrcweir if( xAnimate.is() ) 1045*cdf0e10cSrcweir xAnimate->setKeyTimes( mpHelper->convertKeyTimes( rValue ) ); 1046*cdf0e10cSrcweir } 1047*cdf0e10cSrcweir break; 1048*cdf0e10cSrcweir 1049*cdf0e10cSrcweir case ANA_Formula: 1050*cdf0e10cSrcweir { 1051*cdf0e10cSrcweir if( xAnimate.is() ) 1052*cdf0e10cSrcweir xAnimate->setFormula( rValue ); 1053*cdf0e10cSrcweir } 1054*cdf0e10cSrcweir break; 1055*cdf0e10cSrcweir 1056*cdf0e10cSrcweir case ANA_ANIMID: 1057*cdf0e10cSrcweir { 1058*cdf0e10cSrcweir if (!bHaveXmlId) { sXmlId = rValue; } 1059*cdf0e10cSrcweir } 1060*cdf0e10cSrcweir break; 1061*cdf0e10cSrcweir case ANA_XMLID: 1062*cdf0e10cSrcweir { 1063*cdf0e10cSrcweir sXmlId = rValue; 1064*cdf0e10cSrcweir bHaveXmlId = true; 1065*cdf0e10cSrcweir } 1066*cdf0e10cSrcweir break; 1067*cdf0e10cSrcweir 1068*cdf0e10cSrcweir case ANA_CalcMode: 1069*cdf0e10cSrcweir { 1070*cdf0e10cSrcweir if( xAnimate.is() ) 1071*cdf0e10cSrcweir { 1072*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_CalcMode) ) ) 1073*cdf0e10cSrcweir xAnimate->setCalcMode( (sal_Int16)nEnum ); 1074*cdf0e10cSrcweir } 1075*cdf0e10cSrcweir } 1076*cdf0e10cSrcweir break; 1077*cdf0e10cSrcweir 1078*cdf0e10cSrcweir case ANA_Accumulate: 1079*cdf0e10cSrcweir { 1080*cdf0e10cSrcweir if( xAnimate.is() ) 1081*cdf0e10cSrcweir xAnimate->setAccumulate( IsXMLToken( rValue, XML_SUM ) ); 1082*cdf0e10cSrcweir } 1083*cdf0e10cSrcweir break; 1084*cdf0e10cSrcweir 1085*cdf0e10cSrcweir case ANA_AdditiveMode: 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir if( xAnimate.is() ) 1088*cdf0e10cSrcweir { 1089*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_AdditiveMode) ) ) 1090*cdf0e10cSrcweir xAnimate->setAdditive( (sal_Int16)nEnum ); 1091*cdf0e10cSrcweir } 1092*cdf0e10cSrcweir } 1093*cdf0e10cSrcweir break; 1094*cdf0e10cSrcweir 1095*cdf0e10cSrcweir case ANA_KeySplines: 1096*cdf0e10cSrcweir { 1097*cdf0e10cSrcweir if( xAnimate.is() ) 1098*cdf0e10cSrcweir xAnimate->setTimeFilter( mpHelper->convertTimeFilter( rValue ) ); 1099*cdf0e10cSrcweir } 1100*cdf0e10cSrcweir break; 1101*cdf0e10cSrcweir 1102*cdf0e10cSrcweir case ANA_Path: 1103*cdf0e10cSrcweir { 1104*cdf0e10cSrcweir Reference< XAnimateMotion > xAnimateMotion( mxNode, UNO_QUERY ); 1105*cdf0e10cSrcweir if( xAnimateMotion.is() ) 1106*cdf0e10cSrcweir xAnimateMotion->setPath( mpHelper->convertPath( rValue ) ); 1107*cdf0e10cSrcweir } 1108*cdf0e10cSrcweir break; 1109*cdf0e10cSrcweir 1110*cdf0e10cSrcweir case ANA_ColorSpace: 1111*cdf0e10cSrcweir { 1112*cdf0e10cSrcweir Reference< XAnimateColor > xAnimateColor( mxNode, UNO_QUERY ); 1113*cdf0e10cSrcweir if( xAnimateColor.is() ) 1114*cdf0e10cSrcweir xAnimateColor->setColorInterpolation( IsXMLToken( rValue, XML_HSL ) ? AnimationColorSpace::HSL : AnimationColorSpace::RGB ); 1115*cdf0e10cSrcweir } 1116*cdf0e10cSrcweir break; 1117*cdf0e10cSrcweir 1118*cdf0e10cSrcweir case ANA_ColorDirection: 1119*cdf0e10cSrcweir { 1120*cdf0e10cSrcweir Reference< XAnimateColor > xAnimateColor( mxNode, UNO_QUERY ); 1121*cdf0e10cSrcweir if( xAnimateColor.is() ) 1122*cdf0e10cSrcweir xAnimateColor->setDirection( IsXMLToken( rValue, XML_CLOCKWISE ) ); 1123*cdf0e10cSrcweir } 1124*cdf0e10cSrcweir break; 1125*cdf0e10cSrcweir 1126*cdf0e10cSrcweir case ANA_TransformType: 1127*cdf0e10cSrcweir { 1128*cdf0e10cSrcweir Reference< XAnimateTransform > xTransform( mxNode, UNO_QUERY ); 1129*cdf0e10cSrcweir if( xTransform.is() ) 1130*cdf0e10cSrcweir { 1131*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_TransformType) ) ) 1132*cdf0e10cSrcweir { 1133*cdf0e10cSrcweir xTransform->setTransformType( (sal_Int16)nEnum ); 1134*cdf0e10cSrcweir switch( nEnum ) 1135*cdf0e10cSrcweir { 1136*cdf0e10cSrcweir case AnimationTransformType::SCALE: meAttributeName = XML_SCALE; break; 1137*cdf0e10cSrcweir case AnimationTransformType::ROTATE: meAttributeName = XML_ROTATE; break; 1138*cdf0e10cSrcweir case AnimationTransformType::SKEWX: meAttributeName = XML_SKEWX; break; 1139*cdf0e10cSrcweir case AnimationTransformType::SKEWY: meAttributeName = XML_SKEWY; break; 1140*cdf0e10cSrcweir //case AnimationTransformType::TRANSLATE: 1141*cdf0e10cSrcweir default: 1142*cdf0e10cSrcweir meAttributeName = XML_TRANSLATE; break; 1143*cdf0e10cSrcweir } 1144*cdf0e10cSrcweir } 1145*cdf0e10cSrcweir } 1146*cdf0e10cSrcweir } 1147*cdf0e10cSrcweir break; 1148*cdf0e10cSrcweir 1149*cdf0e10cSrcweir case ANA_TransitionType: 1150*cdf0e10cSrcweir { 1151*cdf0e10cSrcweir if( xTransitionFilter.is() ) 1152*cdf0e10cSrcweir { 1153*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_TransitionType) ) ) 1154*cdf0e10cSrcweir xTransitionFilter->setTransition( (sal_Int16)nEnum ); 1155*cdf0e10cSrcweir } 1156*cdf0e10cSrcweir } 1157*cdf0e10cSrcweir break; 1158*cdf0e10cSrcweir 1159*cdf0e10cSrcweir case ANA_TransitionSubType: 1160*cdf0e10cSrcweir { 1161*cdf0e10cSrcweir if( xTransitionFilter.is() ) 1162*cdf0e10cSrcweir { 1163*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_TransitionSubType) ) ) 1164*cdf0e10cSrcweir xTransitionFilter->setSubtype( (sal_Int16)nEnum ); 1165*cdf0e10cSrcweir } 1166*cdf0e10cSrcweir } 1167*cdf0e10cSrcweir break; 1168*cdf0e10cSrcweir 1169*cdf0e10cSrcweir case ANA_Mode: 1170*cdf0e10cSrcweir { 1171*cdf0e10cSrcweir if( xTransitionFilter.is() ) 1172*cdf0e10cSrcweir xTransitionFilter->setMode( IsXMLToken( rValue, XML_IN ) ); 1173*cdf0e10cSrcweir } 1174*cdf0e10cSrcweir break; 1175*cdf0e10cSrcweir 1176*cdf0e10cSrcweir case ANA_Direction: 1177*cdf0e10cSrcweir { 1178*cdf0e10cSrcweir if( xTransitionFilter.is() ) 1179*cdf0e10cSrcweir xTransitionFilter->setDirection( IsXMLToken( rValue, XML_FORWARD ) ); 1180*cdf0e10cSrcweir } 1181*cdf0e10cSrcweir break; 1182*cdf0e10cSrcweir 1183*cdf0e10cSrcweir case ANA_FadeColor: 1184*cdf0e10cSrcweir { 1185*cdf0e10cSrcweir if( xTransitionFilter.is() ) 1186*cdf0e10cSrcweir { 1187*cdf0e10cSrcweir Color aColor; 1188*cdf0e10cSrcweir SvXMLUnitConverter::convertColor( aColor, rValue ); 1189*cdf0e10cSrcweir xTransitionFilter->setFadeColor( static_cast< sal_Int32 >( aColor.GetRGBColor() ) ); 1190*cdf0e10cSrcweir } 1191*cdf0e10cSrcweir } 1192*cdf0e10cSrcweir break; 1193*cdf0e10cSrcweir 1194*cdf0e10cSrcweir case ANA_IterateType: 1195*cdf0e10cSrcweir { 1196*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_IterateType) ) ) 1197*cdf0e10cSrcweir { 1198*cdf0e10cSrcweir if( xIter.is() ) 1199*cdf0e10cSrcweir xIter->setIterateType( (sal_Int16)nEnum ); 1200*cdf0e10cSrcweir } 1201*cdf0e10cSrcweir } 1202*cdf0e10cSrcweir break; 1203*cdf0e10cSrcweir 1204*cdf0e10cSrcweir case ANA_IterateInterval: 1205*cdf0e10cSrcweir { 1206*cdf0e10cSrcweir if( xIter.is() ) 1207*cdf0e10cSrcweir { 1208*cdf0e10cSrcweir double fInterval = 0.0; 1209*cdf0e10cSrcweir if( rValue.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("P")) ) 1210*cdf0e10cSrcweir { 1211*cdf0e10cSrcweir ::Time aTime; 1212*cdf0e10cSrcweir sal_Int32 nSecondsFraction = 0; 1213*cdf0e10cSrcweir if( SvXMLUnitConverter::convertTimeDuration( rValue, aTime, &nSecondsFraction ) ) 1214*cdf0e10cSrcweir { 1215*cdf0e10cSrcweir fInterval = ((((aTime.GetHour() * 60) + aTime.GetMin()) * 60) + aTime.GetSec()) + (nSecondsFraction / 1000.0); 1216*cdf0e10cSrcweir } 1217*cdf0e10cSrcweir } 1218*cdf0e10cSrcweir else 1219*cdf0e10cSrcweir { 1220*cdf0e10cSrcweir fInterval = rValue.toDouble(); 1221*cdf0e10cSrcweir } 1222*cdf0e10cSrcweir 1223*cdf0e10cSrcweir xIter->setIterateInterval( fInterval ); 1224*cdf0e10cSrcweir } 1225*cdf0e10cSrcweir } 1226*cdf0e10cSrcweir break; 1227*cdf0e10cSrcweir 1228*cdf0e10cSrcweir case ANA_Group_Id: 1229*cdf0e10cSrcweir { 1230*cdf0e10cSrcweir aUserData.push_back( NamedValue( aLocalName, makeAny( rValue.toInt32() ) ) ); 1231*cdf0e10cSrcweir } 1232*cdf0e10cSrcweir break; 1233*cdf0e10cSrcweir 1234*cdf0e10cSrcweir case ANA_Command: 1235*cdf0e10cSrcweir { 1236*cdf0e10cSrcweir if( xCommand.is() && nNodeType == AnimationNodeType::COMMAND ) 1237*cdf0e10cSrcweir { 1238*cdf0e10cSrcweir if( SvXMLUnitConverter::convertEnum( nEnum, rValue, getAnimationsEnumMap(Animations_EnumMap_Command) ) ) 1239*cdf0e10cSrcweir { 1240*cdf0e10cSrcweir xCommand->setCommand( (sal_Int16)nEnum ); 1241*cdf0e10cSrcweir } 1242*cdf0e10cSrcweir } 1243*cdf0e10cSrcweir } 1244*cdf0e10cSrcweir break; 1245*cdf0e10cSrcweir 1246*cdf0e10cSrcweir default: 1247*cdf0e10cSrcweir // push all unknown attributes within the presentation namespace as user data 1248*cdf0e10cSrcweir if( nPrefix == XML_NAMESPACE_PRESENTATION ) 1249*cdf0e10cSrcweir { 1250*cdf0e10cSrcweir aUserData.push_back( NamedValue( aLocalName, makeAny( rValue ) ) ); 1251*cdf0e10cSrcweir } 1252*cdf0e10cSrcweir } 1253*cdf0e10cSrcweir } 1254*cdf0e10cSrcweir 1255*cdf0e10cSrcweir if (sXmlId.getLength()) 1256*cdf0e10cSrcweir { 1257*cdf0e10cSrcweir Reference< XInterface > const xRef( mxNode, UNO_QUERY ); 1258*cdf0e10cSrcweir GetImport().getInterfaceToIdentifierMapper().registerReference( 1259*cdf0e10cSrcweir sXmlId, xRef ); 1260*cdf0e10cSrcweir } 1261*cdf0e10cSrcweir 1262*cdf0e10cSrcweir sal_Int32 nUserDataCount = aUserData.size(); 1263*cdf0e10cSrcweir if( nUserDataCount ) 1264*cdf0e10cSrcweir { 1265*cdf0e10cSrcweir Sequence< NamedValue > aUnoUserData( nUserDataCount ); 1266*cdf0e10cSrcweir NamedValue* pData = aUnoUserData.getArray(); 1267*cdf0e10cSrcweir std::list< NamedValue >::iterator aIter( aUserData.begin() ); 1268*cdf0e10cSrcweir const std::list< NamedValue >::iterator aEnd( aUserData.end() ); 1269*cdf0e10cSrcweir while( aIter != aEnd ) 1270*cdf0e10cSrcweir *pData++ = (*aIter++); 1271*cdf0e10cSrcweir 1272*cdf0e10cSrcweir mxNode->setUserData( aUnoUserData ); 1273*cdf0e10cSrcweir } 1274*cdf0e10cSrcweir 1275*cdf0e10cSrcweir // convert values 1276*cdf0e10cSrcweir if( xAnimate.is() ) 1277*cdf0e10cSrcweir { 1278*cdf0e10cSrcweir if( aFrom.getLength() ) 1279*cdf0e10cSrcweir xAnimate->setFrom( mpHelper->convertValue( meAttributeName, aFrom ) ); 1280*cdf0e10cSrcweir 1281*cdf0e10cSrcweir if( aBy.getLength() ) 1282*cdf0e10cSrcweir xAnimate->setBy( mpHelper->convertValue( meAttributeName, aBy ) ); 1283*cdf0e10cSrcweir 1284*cdf0e10cSrcweir if( aTo.getLength() ) 1285*cdf0e10cSrcweir xAnimate->setTo( mpHelper->convertValue( meAttributeName, aTo ) ); 1286*cdf0e10cSrcweir 1287*cdf0e10cSrcweir if( aValues.getLength() ) 1288*cdf0e10cSrcweir xAnimate->setValues( mpHelper->convertValueSequence( meAttributeName, aValues ) ); 1289*cdf0e10cSrcweir } 1290*cdf0e10cSrcweir } 1291*cdf0e10cSrcweir catch( RuntimeException& ) 1292*cdf0e10cSrcweir { 1293*cdf0e10cSrcweir DBG_ERROR( "xmloff::AnimationNodeContext::StartElement(), RuntimeException catched!" ); 1294*cdf0e10cSrcweir } 1295*cdf0e10cSrcweir } 1296*cdf0e10cSrcweir 1297*cdf0e10cSrcweir SvXMLImportContext * AnimationNodeContext::CreateChildContext( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, 1298*cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList ) 1299*cdf0e10cSrcweir { 1300*cdf0e10cSrcweir if( mxNode.is()) 1301*cdf0e10cSrcweir return new AnimationNodeContext( mxNode, GetImport(), nPrefix, rLocalName, xAttrList, mpHelper ); 1302*cdf0e10cSrcweir else 1303*cdf0e10cSrcweir return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); 1304*cdf0e10cSrcweir } 1305*cdf0e10cSrcweir 1306*cdf0e10cSrcweir // -------------------------------------------------------------------- 1307*cdf0e10cSrcweir 1308*cdf0e10cSrcweir class AnimationsImport: public SvXMLImport, public XAnimationNodeSupplier 1309*cdf0e10cSrcweir { 1310*cdf0e10cSrcweir public: 1311*cdf0e10cSrcweir AnimationsImport( const Reference< XMultiServiceFactory > & rSMgr ); 1312*cdf0e10cSrcweir ~AnimationsImport() throw (); 1313*cdf0e10cSrcweir 1314*cdf0e10cSrcweir SvXMLImportContext* CreateContext(sal_uInt16 nPrefix, const OUString& rLocalName, const Reference<XAttributeList>& xAttrList); 1315*cdf0e10cSrcweir 1316*cdf0e10cSrcweir // XInterface 1317*cdf0e10cSrcweir virtual Any SAL_CALL queryInterface( const Type& aType ) throw (RuntimeException); 1318*cdf0e10cSrcweir virtual void SAL_CALL acquire() throw (); 1319*cdf0e10cSrcweir virtual void SAL_CALL release() throw (); 1320*cdf0e10cSrcweir 1321*cdf0e10cSrcweir // XAnimationNodeSupplier 1322*cdf0e10cSrcweir Reference< XAnimationNode > SAL_CALL getAnimationNode() throw (RuntimeException); 1323*cdf0e10cSrcweir 1324*cdf0e10cSrcweir // XServiceInfo 1325*cdf0e10cSrcweir virtual OUString SAL_CALL getImplementationName() throw(RuntimeException); 1326*cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException); 1327*cdf0e10cSrcweir virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException); 1328*cdf0e10cSrcweir 1329*cdf0e10cSrcweir private: 1330*cdf0e10cSrcweir Reference< XAnimationNode > mxRootNode; 1331*cdf0e10cSrcweir }; 1332*cdf0e10cSrcweir 1333*cdf0e10cSrcweir AnimationsImport::AnimationsImport( const Reference< XMultiServiceFactory > & rSMgr ) 1334*cdf0e10cSrcweir : SvXMLImport( rSMgr, true ) 1335*cdf0e10cSrcweir { 1336*cdf0e10cSrcweir // add namespaces 1337*cdf0e10cSrcweir GetNamespaceMap().Add( 1338*cdf0e10cSrcweir GetXMLToken(XML_NP_PRESENTATION), 1339*cdf0e10cSrcweir GetXMLToken(XML_N_PRESENTATION), 1340*cdf0e10cSrcweir XML_NAMESPACE_PRESENTATION); 1341*cdf0e10cSrcweir 1342*cdf0e10cSrcweir GetNamespaceMap().Add( 1343*cdf0e10cSrcweir GetXMLToken(XML_NP_SMIL), 1344*cdf0e10cSrcweir GetXMLToken(XML_N_SMIL), 1345*cdf0e10cSrcweir XML_NAMESPACE_SMIL); 1346*cdf0e10cSrcweir 1347*cdf0e10cSrcweir GetNamespaceMap().Add( 1348*cdf0e10cSrcweir GetXMLToken(XML_NP_ANIMATION), 1349*cdf0e10cSrcweir GetXMLToken(XML_N_ANIMATION), 1350*cdf0e10cSrcweir XML_NAMESPACE_ANIMATION); 1351*cdf0e10cSrcweir 1352*cdf0e10cSrcweir mxRootNode = Reference< XAnimationNode >::query(rSMgr->createInstance( 1353*cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.animations.SequenceTimeContainer")))); 1354*cdf0e10cSrcweir } 1355*cdf0e10cSrcweir 1356*cdf0e10cSrcweir AnimationsImport::~AnimationsImport() throw () 1357*cdf0e10cSrcweir { 1358*cdf0e10cSrcweir } 1359*cdf0e10cSrcweir 1360*cdf0e10cSrcweir // XInterface 1361*cdf0e10cSrcweir Any SAL_CALL AnimationsImport::queryInterface( const Type& aType ) throw (RuntimeException) 1362*cdf0e10cSrcweir { 1363*cdf0e10cSrcweir if ( aType == ::getCppuType((Reference<XAnimationNodeSupplier> *)0) ) 1364*cdf0e10cSrcweir { 1365*cdf0e10cSrcweir return makeAny( Reference<XAnimationNodeSupplier>( this ) ); 1366*cdf0e10cSrcweir } 1367*cdf0e10cSrcweir else 1368*cdf0e10cSrcweir { 1369*cdf0e10cSrcweir return SvXMLImport::queryInterface( aType ); 1370*cdf0e10cSrcweir } 1371*cdf0e10cSrcweir } 1372*cdf0e10cSrcweir 1373*cdf0e10cSrcweir void SAL_CALL AnimationsImport::acquire() throw () 1374*cdf0e10cSrcweir { 1375*cdf0e10cSrcweir SvXMLImport::acquire(); 1376*cdf0e10cSrcweir } 1377*cdf0e10cSrcweir 1378*cdf0e10cSrcweir void SAL_CALL AnimationsImport::release() throw () 1379*cdf0e10cSrcweir { 1380*cdf0e10cSrcweir SvXMLImport::release(); 1381*cdf0e10cSrcweir } 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir SvXMLImportContext *AnimationsImport::CreateContext(sal_uInt16 nPrefix, const OUString& rLocalName, const Reference<XAttributeList>& xAttrList) 1384*cdf0e10cSrcweir { 1385*cdf0e10cSrcweir SvXMLImportContext* pContext = 0; 1386*cdf0e10cSrcweir 1387*cdf0e10cSrcweir if( (XML_NAMESPACE_ANIMATION == nPrefix) && IsXMLToken( rLocalName, XML_SEQ ) ) 1388*cdf0e10cSrcweir { 1389*cdf0e10cSrcweir pContext = new AnimationNodeContext( mxRootNode, *this, nPrefix, rLocalName, xAttrList ); 1390*cdf0e10cSrcweir } 1391*cdf0e10cSrcweir else 1392*cdf0e10cSrcweir { 1393*cdf0e10cSrcweir pContext = SvXMLImport::CreateContext(nPrefix, rLocalName, xAttrList); 1394*cdf0e10cSrcweir } 1395*cdf0e10cSrcweir 1396*cdf0e10cSrcweir return pContext; 1397*cdf0e10cSrcweir } 1398*cdf0e10cSrcweir 1399*cdf0e10cSrcweir // XAnimationNodeSupplier 1400*cdf0e10cSrcweir Reference< XAnimationNode > SAL_CALL AnimationsImport::getAnimationNode() throw (RuntimeException) 1401*cdf0e10cSrcweir { 1402*cdf0e10cSrcweir return mxRootNode; 1403*cdf0e10cSrcweir } 1404*cdf0e10cSrcweir 1405*cdf0e10cSrcweir void AnimationNodeContext::postProcessRootNode( SvXMLImport& /*rImport*/, const Reference< XAnimationNode >& xRootNode, Reference< XPropertySet >& xPageProps ) 1406*cdf0e10cSrcweir { 1407*cdf0e10cSrcweir if( xRootNode.is() && xPageProps.is() ) try 1408*cdf0e10cSrcweir { 1409*cdf0e10cSrcweir Reference< XEnumerationAccess > xEnumerationAccess( xRootNode, UNO_QUERY_THROW ); 1410*cdf0e10cSrcweir Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW ); 1411*cdf0e10cSrcweir if( xEnumeration->hasMoreElements() ) 1412*cdf0e10cSrcweir { 1413*cdf0e10cSrcweir Reference< XAnimationNode > xNode( xEnumeration->nextElement(), UNO_QUERY_THROW ); 1414*cdf0e10cSrcweir if( xNode->getType() == AnimationNodeType::PAR ) 1415*cdf0e10cSrcweir { 1416*cdf0e10cSrcweir Event aEvent; 1417*cdf0e10cSrcweir if( (xNode->getBegin() >>= aEvent) && (aEvent.Trigger == EventTrigger::BEGIN_EVENT) ) 1418*cdf0e10cSrcweir { 1419*cdf0e10cSrcweir // found transition node 1420*cdf0e10cSrcweir Reference< XEnumerationAccess > xChildEnumerationAccess( xNode, UNO_QUERY_THROW ); 1421*cdf0e10cSrcweir Reference< XEnumeration > xChildEnumeration( xChildEnumerationAccess->createEnumeration(), UNO_QUERY_THROW ); 1422*cdf0e10cSrcweir while( xChildEnumeration->hasMoreElements() ) 1423*cdf0e10cSrcweir { 1424*cdf0e10cSrcweir Reference< XAnimationNode > xChildNode( xChildEnumeration->nextElement(), UNO_QUERY_THROW ); 1425*cdf0e10cSrcweir switch( xChildNode->getType() ) 1426*cdf0e10cSrcweir { 1427*cdf0e10cSrcweir case AnimationNodeType::TRANSITIONFILTER: 1428*cdf0e10cSrcweir { 1429*cdf0e10cSrcweir Reference< XTransitionFilter > xTransFilter( xChildNode, UNO_QUERY_THROW ); 1430*cdf0e10cSrcweir 1431*cdf0e10cSrcweir 1432*cdf0e10cSrcweir xPageProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionType" ) ), Any( xTransFilter->getTransition() ) ); 1433*cdf0e10cSrcweir xPageProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionSubtype" ) ), Any( xTransFilter->getSubtype() ) ); 1434*cdf0e10cSrcweir xPageProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionDirection" ) ), Any( xTransFilter->getDirection() ) ); 1435*cdf0e10cSrcweir xPageProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionFadeColor" ) ), Any( xTransFilter->getFadeColor() ) ); 1436*cdf0e10cSrcweir 1437*cdf0e10cSrcweir double fDuration; 1438*cdf0e10cSrcweir if( xTransFilter->getDuration() >>= fDuration ) 1439*cdf0e10cSrcweir xPageProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionDuration" ) ), Any( fDuration ) ); 1440*cdf0e10cSrcweir 1441*cdf0e10cSrcweir } 1442*cdf0e10cSrcweir break; 1443*cdf0e10cSrcweir 1444*cdf0e10cSrcweir case AnimationNodeType::COMMAND: 1445*cdf0e10cSrcweir { 1446*cdf0e10cSrcweir Reference< XCommand > xCommand( xChildNode, UNO_QUERY_THROW ); 1447*cdf0e10cSrcweir if( xCommand->getCommand() == EffectCommands::STOPAUDIO ) 1448*cdf0e10cSrcweir { 1449*cdf0e10cSrcweir xPageProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ), Any(sal_True) ); 1450*cdf0e10cSrcweir } 1451*cdf0e10cSrcweir } 1452*cdf0e10cSrcweir break; 1453*cdf0e10cSrcweir 1454*cdf0e10cSrcweir case AnimationNodeType::AUDIO: 1455*cdf0e10cSrcweir { 1456*cdf0e10cSrcweir Reference< XAudio > xAudio( xChildNode, UNO_QUERY_THROW ); 1457*cdf0e10cSrcweir OUString sSoundURL; 1458*cdf0e10cSrcweir if( (xAudio->getSource() >>= sSoundURL) && (sSoundURL.getLength() != 0) ) 1459*cdf0e10cSrcweir { 1460*cdf0e10cSrcweir xPageProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ), Any(sSoundURL) ); 1461*cdf0e10cSrcweir 1462*cdf0e10cSrcweir Timing eTiming; 1463*cdf0e10cSrcweir if( (xAudio->getRepeatCount() >>= eTiming) && (eTiming == Timing_INDEFINITE) ) 1464*cdf0e10cSrcweir xPageProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LoopSound" ) ), Any( sal_True ) ); 1465*cdf0e10cSrcweir } 1466*cdf0e10cSrcweir } 1467*cdf0e10cSrcweir break; 1468*cdf0e10cSrcweir 1469*cdf0e10cSrcweir } 1470*cdf0e10cSrcweir } 1471*cdf0e10cSrcweir 1472*cdf0e10cSrcweir Reference< XTimeContainer > xRootContainer( xRootNode, UNO_QUERY_THROW ); 1473*cdf0e10cSrcweir xRootContainer->removeChild( xNode ); 1474*cdf0e10cSrcweir } 1475*cdf0e10cSrcweir } 1476*cdf0e10cSrcweir } 1477*cdf0e10cSrcweir } 1478*cdf0e10cSrcweir catch( Exception& ) 1479*cdf0e10cSrcweir { 1480*cdf0e10cSrcweir DBG_ERROR("xmloff::AnimationsImport::postProcessRootNode(), exception caught!"); 1481*cdf0e10cSrcweir } 1482*cdf0e10cSrcweir } 1483*cdf0e10cSrcweir 1484*cdf0e10cSrcweir } // namespace xmloff 1485*cdf0e10cSrcweir 1486*cdf0e10cSrcweir Sequence< OUString > SAL_CALL AnimationsImport_getSupportedServiceNames() throw() 1487*cdf0e10cSrcweir { 1488*cdf0e10cSrcweir const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Xmloff.AnimationsImport" ) ); 1489*cdf0e10cSrcweir const Sequence< OUString > aSeq( &aServiceName, 1 ); 1490*cdf0e10cSrcweir return aSeq; 1491*cdf0e10cSrcweir } 1492*cdf0e10cSrcweir 1493*cdf0e10cSrcweir OUString SAL_CALL AnimationsImport_getImplementationName() throw() 1494*cdf0e10cSrcweir { 1495*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM( "xmloff::AnimationsImport" ) ); 1496*cdf0e10cSrcweir } 1497*cdf0e10cSrcweir 1498*cdf0e10cSrcweir Reference< XInterface > SAL_CALL AnimationsImport_createInstance(const Reference< XMultiServiceFactory > & rSMgr) throw( Exception ) 1499*cdf0e10cSrcweir { 1500*cdf0e10cSrcweir return (cppu::OWeakObject*)new xmloff::AnimationsImport( rSMgr ); 1501*cdf0e10cSrcweir 1502*cdf0e10cSrcweir } 1503*cdf0e10cSrcweir 1504*cdf0e10cSrcweir namespace xmloff 1505*cdf0e10cSrcweir { 1506*cdf0e10cSrcweir 1507*cdf0e10cSrcweir OUString SAL_CALL AnimationsImport::getImplementationName() throw(RuntimeException) 1508*cdf0e10cSrcweir { 1509*cdf0e10cSrcweir return AnimationsImport_getImplementationName(); 1510*cdf0e10cSrcweir } 1511*cdf0e10cSrcweir 1512*cdf0e10cSrcweir sal_Bool SAL_CALL AnimationsImport::supportsService( const OUString& ServiceName ) throw(RuntimeException) 1513*cdf0e10cSrcweir { 1514*cdf0e10cSrcweir return ServiceName.equalsAscii( "com.sun.star.comp.Xmloff.AnimationsImport" ); 1515*cdf0e10cSrcweir } 1516*cdf0e10cSrcweir 1517*cdf0e10cSrcweir Sequence< OUString > SAL_CALL AnimationsImport::getSupportedServiceNames() throw(RuntimeException) 1518*cdf0e10cSrcweir { 1519*cdf0e10cSrcweir return AnimationsImport_getSupportedServiceNames(); 1520*cdf0e10cSrcweir } 1521*cdf0e10cSrcweir 1522*cdf0e10cSrcweir } // namespace xmloff 1523*cdf0e10cSrcweir 1524