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