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 <com/sun/star/lang/XServiceInfo.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/presentation/AnimationSpeed.hpp> 34*cdf0e10cSrcweir #include "unointerfacetouniqueidentifiermapper.hxx" 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <list> 37*cdf0e10cSrcweir #include <comphelper/extract.hxx> 38*cdf0e10cSrcweir #include <tools/color.hxx> 39*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 40*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 41*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 42*cdf0e10cSrcweir #include <xmloff/xmlexp.hxx> 43*cdf0e10cSrcweir #include <xmloff/xmlement.hxx> 44*cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 45*cdf0e10cSrcweir #include <xmloff/shapeexport.hxx> 46*cdf0e10cSrcweir #include "anim.hxx" 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir using ::rtl::OUString; 49*cdf0e10cSrcweir using ::rtl::OUStringBuffer; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir using namespace ::std; 52*cdf0e10cSrcweir using namespace ::cppu; 53*cdf0e10cSrcweir using namespace ::com::sun::star; 54*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 55*cdf0e10cSrcweir using namespace ::com::sun::star::drawing; 56*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 57*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 58*cdf0e10cSrcweir using namespace ::com::sun::star::presentation; 59*cdf0e10cSrcweir using namespace ::xmloff::token; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir const struct Effect 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir XMLEffect meKind; 65*cdf0e10cSrcweir XMLEffectDirection meDirection; 66*cdf0e10cSrcweir sal_Int16 mnStartScale; 67*cdf0e10cSrcweir sal_Bool mbIn; 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir AnimationEffectMap[] = 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir { EK_none, ED_none, -1, sal_True }, // AnimationEffect_NONE 72*cdf0e10cSrcweir { EK_fade, ED_from_left, -1, sal_True }, // AnimationEffect_FADE_FROM_LEFT 73*cdf0e10cSrcweir { EK_fade, ED_from_top, -1, sal_True }, // AnimationEffect_FADE_FROM_TOP 74*cdf0e10cSrcweir { EK_fade, ED_from_right, -1, sal_True }, // AnimationEffect_FADE_FROM_RIGHT 75*cdf0e10cSrcweir { EK_fade, ED_from_bottom, -1, sal_True }, // AnimationEffect_FADE_FROM_BOTTOM 76*cdf0e10cSrcweir { EK_fade, ED_to_center, -1, sal_True }, // AnimationEffect_FADE_TO_CENTER 77*cdf0e10cSrcweir { EK_fade, ED_from_center, -1, sal_True }, // AnimationEffect_FADE_FROM_CENTER 78*cdf0e10cSrcweir { EK_move, ED_from_left, -1, sal_True }, // AnimationEffect_MOVE_FROM_LEFT 79*cdf0e10cSrcweir { EK_move, ED_from_top, -1, sal_True }, // AnimationEffect_MOVE_FROM_TOP 80*cdf0e10cSrcweir { EK_move, ED_from_right, -1, sal_True }, // AnimationEffect_MOVE_FROM_RIGHT 81*cdf0e10cSrcweir { EK_move, ED_from_bottom, -1, sal_True }, // AnimationEffect_MOVE_FROM_BOTTOM 82*cdf0e10cSrcweir { EK_stripes, ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_STRIPES 83*cdf0e10cSrcweir { EK_stripes, ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_STRIPES 84*cdf0e10cSrcweir { EK_fade, ED_clockwise, -1, sal_True }, // AnimationEffect_CLOCKWISE 85*cdf0e10cSrcweir { EK_fade, ED_cclockwise, -1, sal_True }, // AnimationEffect_COUNTERCLOCKWISE 86*cdf0e10cSrcweir { EK_fade, ED_from_upperleft, -1, sal_True }, // AnimationEffect_FADE_FROM_UPPERLEFT 87*cdf0e10cSrcweir { EK_fade, ED_from_upperright, -1, sal_True }, // AnimationEffect_FADE_FROM_UPPERRIGHT 88*cdf0e10cSrcweir { EK_fade, ED_from_lowerleft, -1, sal_True }, // AnimationEffect_FADE_FROM_LOWERLEFT 89*cdf0e10cSrcweir { EK_fade, ED_from_lowerright, -1, sal_True }, // AnimationEffect_FADE_FROM_LOWERRIGHT 90*cdf0e10cSrcweir { EK_close,ED_vertical, -1, sal_True }, // AnimationEffect_CLOSE_VERTICAL 91*cdf0e10cSrcweir { EK_close,ED_horizontal, -1, sal_True }, // AnimationEffect_CLOSE_HORIZONTAL 92*cdf0e10cSrcweir { EK_open, ED_vertical, -1, sal_True }, // AnimationEffect_OPEN_VERTICAL 93*cdf0e10cSrcweir { EK_open, ED_horizontal, -1, sal_True }, // AnimationEffect_OPEN_HORIZONTAL 94*cdf0e10cSrcweir { EK_move, ED_path, -1, sal_True }, // AnimationEffect_PATH 95*cdf0e10cSrcweir { EK_move, ED_to_left, -1, sal_False },// AnimationEffect_MOVE_TO_LEFT 96*cdf0e10cSrcweir { EK_move, ED_to_top, -1, sal_False },// AnimationEffect_MOVE_TO_TOP 97*cdf0e10cSrcweir { EK_move, ED_to_right, -1, sal_False },// AnimationEffect_MOVE_TO_RIGHT 98*cdf0e10cSrcweir { EK_move, ED_to_bottom, -1, sal_False },// AnimationEffect_MOVE_TO_BOTTOM 99*cdf0e10cSrcweir { EK_fade, ED_spiral_inward_left, -1, sal_True }, // AnimationEffect_SPIRALIN_LEFT 100*cdf0e10cSrcweir { EK_fade, ED_spiral_inward_right, -1, sal_True }, // AnimationEffect_SPIRALIN_RIGHT 101*cdf0e10cSrcweir { EK_fade, ED_spiral_outward_left, -1, sal_True }, // AnimationEffect_SPIRALOUT_LEFT 102*cdf0e10cSrcweir { EK_fade, ED_spiral_outward_right, -1, sal_True }, // AnimationEffect_SPIRALOUT_RIGHT 103*cdf0e10cSrcweir { EK_dissolve, ED_none, -1, sal_True }, // AnimationEffect_DISSOLVE 104*cdf0e10cSrcweir { EK_wavyline, ED_from_left, -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_LEFT 105*cdf0e10cSrcweir { EK_wavyline, ED_from_top, -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_TOP 106*cdf0e10cSrcweir { EK_wavyline, ED_from_right, -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_RIGHT 107*cdf0e10cSrcweir { EK_wavyline, ED_from_bottom, -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_BOTTOM 108*cdf0e10cSrcweir { EK_random, ED_none, -1, sal_True }, // AnimationEffect_RANDOM 109*cdf0e10cSrcweir { EK_lines, ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_LINES 110*cdf0e10cSrcweir { EK_lines, ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_LINES 111*cdf0e10cSrcweir { EK_laser, ED_from_left, -1, sal_True }, // AnimationEffect_LASER_FROM_LEFT 112*cdf0e10cSrcweir { EK_laser, ED_from_top, -1, sal_True }, // AnimationEffect_LASER_FROM_TOP 113*cdf0e10cSrcweir { EK_laser, ED_from_right, -1, sal_True }, // AnimationEffect_LASER_FROM_RIGHT 114*cdf0e10cSrcweir { EK_laser, ED_from_bottom, -1, sal_True }, // AnimationEffect_LASER_FROM_BOTTOM 115*cdf0e10cSrcweir { EK_laser, ED_from_upperleft, -1, sal_True }, // AnimationEffect_LASER_FROM_UPPERLEFT 116*cdf0e10cSrcweir { EK_laser, ED_from_upperright, -1, sal_True }, // AnimationEffect_LASER_FROM_UPPERRIGHT 117*cdf0e10cSrcweir { EK_laser, ED_from_lowerleft, -1, sal_True }, // AnimationEffect_LASER_FROM_LOWERLEFT 118*cdf0e10cSrcweir { EK_laser, ED_from_lowerright, -1, sal_True }, // AnimationEffect_LASER_FROM_LOWERRIGHT 119*cdf0e10cSrcweir { EK_appear,ED_none, -1, sal_True }, // AnimationEffect_APPEAR 120*cdf0e10cSrcweir { EK_hide, ED_none, -1, sal_False },// AnimationEffect_HIDE 121*cdf0e10cSrcweir { EK_move, ED_from_upperleft, -1, sal_True }, // AnimationEffect_MOVE_FROM_UPPERLEFT 122*cdf0e10cSrcweir { EK_move, ED_from_upperright, -1, sal_True }, // AnimationEffect_MOVE_FROM_UPPERRIGHT 123*cdf0e10cSrcweir { EK_move, ED_from_lowerright, -1, sal_True }, // AnimationEffect_MOVE_FROM_LOWERRIGHT 124*cdf0e10cSrcweir { EK_move, ED_from_lowerleft, -1, sal_True }, // AnimationEffect_MOVE_FROM_LOWERLEFT 125*cdf0e10cSrcweir { EK_move, ED_to_upperleft, -1, sal_False },// AnimationEffect_MOVE_TO_UPPERLEFT 126*cdf0e10cSrcweir { EK_move, ED_to_upperright, -1, sal_False },// AnimationEffect_MOVE_TO_UPPERRIGHT 127*cdf0e10cSrcweir { EK_move, ED_to_lowerright, -1, sal_False },// AnimationEffect_MOVE_TO_LOWERRIGHT 128*cdf0e10cSrcweir { EK_move, ED_to_lowerleft, -1, sal_False },// AnimationEffect_MOVE_TO_LOWERLEFT 129*cdf0e10cSrcweir { EK_move_short, ED_from_left, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_LEFT 130*cdf0e10cSrcweir { EK_move_short, ED_from_upperleft, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT 131*cdf0e10cSrcweir { EK_move_short, ED_from_top, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_TOP 132*cdf0e10cSrcweir { EK_move_short, ED_from_upperright,-1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT 133*cdf0e10cSrcweir { EK_move_short, ED_from_right, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_RIGHT 134*cdf0e10cSrcweir { EK_move_short, ED_from_lowerright,-1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT 135*cdf0e10cSrcweir { EK_move_short, ED_from_bottom, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_BOTTOM 136*cdf0e10cSrcweir { EK_move_short, ED_from_lowerleft, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT 137*cdf0e10cSrcweir { EK_move_short, ED_to_left, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_LEFT 138*cdf0e10cSrcweir { EK_move_short, ED_to_upperleft, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_UPPERLEFT 139*cdf0e10cSrcweir { EK_move_short, ED_to_top, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_TOP 140*cdf0e10cSrcweir { EK_move_short, ED_to_upperright, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT 141*cdf0e10cSrcweir { EK_move_short, ED_to_right, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_RIGHT 142*cdf0e10cSrcweir { EK_move_short, ED_to_lowerright, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT 143*cdf0e10cSrcweir { EK_move_short, ED_to_bottom, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_BOTTOM 144*cdf0e10cSrcweir { EK_move_short, ED_to_lowerleft, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_LOWERLEFT 145*cdf0e10cSrcweir { EK_checkerboard, ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_CHECKERBOARD 146*cdf0e10cSrcweir { EK_checkerboard, ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_CHECKERBOARD 147*cdf0e10cSrcweir { EK_rotate, ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_ROTATE 148*cdf0e10cSrcweir { EK_rotate, ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_ROTATE 149*cdf0e10cSrcweir { EK_stretch,ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_STRETCH 150*cdf0e10cSrcweir { EK_stretch,ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_STRETCH 151*cdf0e10cSrcweir { EK_stretch,ED_from_left, -1, sal_True }, // AnimationEffect_STRETCH_FROM_LEFT 152*cdf0e10cSrcweir { EK_stretch,ED_from_upperleft, -1, sal_True }, // AnimationEffect_STRETCH_FROM_UPPERLEFT 153*cdf0e10cSrcweir { EK_stretch,ED_from_top, -1, sal_True }, // AnimationEffect_STRETCH_FROM_TOP 154*cdf0e10cSrcweir { EK_stretch,ED_from_upperright,-1, sal_True }, // AnimationEffect_STRETCH_FROM_UPPERRIGHT 155*cdf0e10cSrcweir { EK_stretch,ED_from_right, -1, sal_True }, // AnimationEffect_STRETCH_FROM_RIGHT 156*cdf0e10cSrcweir { EK_stretch,ED_from_lowerright,-1, sal_True }, // AnimationEffect_STRETCH_FROM_LOWERRIGHT 157*cdf0e10cSrcweir { EK_stretch,ED_from_bottom, -1, sal_True }, // AnimationEffect_STRETCH_FROM_BOTTOM 158*cdf0e10cSrcweir { EK_stretch,ED_from_lowerleft, -1, sal_True }, // AnimationEffect_STRETCH_FROM_LOWERLEFT 159*cdf0e10cSrcweir { EK_move, ED_none, 0, sal_True }, // AnimationEffect_ZOOM_IN 160*cdf0e10cSrcweir { EK_move, ED_none, 50, sal_True }, // AnimationEffect_ZOOM_IN_SMALL 161*cdf0e10cSrcweir { EK_move, ED_spiral_inward_left, 0, sal_True }, // AnimationEffect_ZOOM_IN_SPIRAL 162*cdf0e10cSrcweir { EK_move, ED_none, 400, sal_True }, // AnimationEffect_ZOOM_OUT 163*cdf0e10cSrcweir { EK_move, ED_none, 200, sal_True }, // AnimationEffect_ZOOM_OUT_SMALL 164*cdf0e10cSrcweir { EK_move, ED_spiral_inward_left, 400, sal_True }, // AnimationEffect_ZOOM_OUT_SPIRAL 165*cdf0e10cSrcweir { EK_move, ED_from_left, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_LEFT 166*cdf0e10cSrcweir { EK_move, ED_from_upperleft, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_UPPERLEFT 167*cdf0e10cSrcweir { EK_move, ED_from_top, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_TOP 168*cdf0e10cSrcweir { EK_move, ED_from_upperright, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT 169*cdf0e10cSrcweir { EK_move, ED_from_right, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_RIGHT 170*cdf0e10cSrcweir { EK_move, ED_from_lowerright, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT 171*cdf0e10cSrcweir { EK_move, ED_from_bottom, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_BOTTOM 172*cdf0e10cSrcweir { EK_move, ED_from_lowerleft, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_LOWERLEFT 173*cdf0e10cSrcweir { EK_move, ED_from_center, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_CENTER 174*cdf0e10cSrcweir { EK_move, ED_from_left, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_LEFT 175*cdf0e10cSrcweir { EK_move, ED_from_upperleft, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT 176*cdf0e10cSrcweir { EK_move, ED_from_top, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_TOP 177*cdf0e10cSrcweir { EK_move, ED_from_upperright,400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT 178*cdf0e10cSrcweir { EK_move, ED_from_right, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_RIGHT 179*cdf0e10cSrcweir { EK_move, ED_from_lowerright,400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT 180*cdf0e10cSrcweir { EK_move, ED_from_bottom, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_BOTTOM 181*cdf0e10cSrcweir { EK_move, ED_from_lowerleft, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT 182*cdf0e10cSrcweir { EK_move, ED_from_center, 400, sal_True } // AnimationEffect_ZOOM_OUT_FROM_CENTER 183*cdf0e10cSrcweir }; 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir void SdXMLImplSetEffect( AnimationEffect eEffect, XMLEffect& eKind, XMLEffectDirection& eDirection, sal_Int16& nStartScale, sal_Bool& bIn ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir if( eEffect < AnimationEffect_NONE || eEffect > AnimationEffect_ZOOM_OUT_FROM_CENTER ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir DBG_ERROR( "unknown animation effect!" ); 190*cdf0e10cSrcweir eEffect = AnimationEffect_NONE; 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir const Effect& rEffect = AnimationEffectMap[eEffect]; 194*cdf0e10cSrcweir eKind = rEffect.meKind; 195*cdf0e10cSrcweir eDirection = rEffect.meDirection; 196*cdf0e10cSrcweir nStartScale = rEffect.mnStartScale; 197*cdf0e10cSrcweir bIn = rEffect.mbIn; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir enum XMLActionKind 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir XMLE_SHOW, 203*cdf0e10cSrcweir XMLE_HIDE, 204*cdf0e10cSrcweir XMLE_DIM, 205*cdf0e10cSrcweir XMLE_PLAY 206*cdf0e10cSrcweir }; 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir struct XMLEffectHint 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir XMLActionKind meKind; 211*cdf0e10cSrcweir sal_Bool mbTextEffect; 212*cdf0e10cSrcweir Reference<XShape> mxShape; 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir XMLEffect meEffect; 215*cdf0e10cSrcweir XMLEffectDirection meDirection; 216*cdf0e10cSrcweir sal_Int16 mnStartScale; 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir AnimationSpeed meSpeed; 219*cdf0e10cSrcweir Color maDimColor; 220*cdf0e10cSrcweir OUString maSoundURL; 221*cdf0e10cSrcweir sal_Bool mbPlayFull; 222*cdf0e10cSrcweir sal_Int32 mnPresId; 223*cdf0e10cSrcweir sal_Int32 mnPathShapeId; 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir int operator<(const XMLEffectHint& rComp) const { return mnPresId < rComp.mnPresId; } 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir XMLEffectHint() 228*cdf0e10cSrcweir : meKind( XMLE_SHOW ), mbTextEffect( sal_False ), 229*cdf0e10cSrcweir meEffect( EK_none ), meDirection( ED_none ), mnStartScale( -1 ), 230*cdf0e10cSrcweir meSpeed( AnimationSpeed_SLOW ), maDimColor(0), mbPlayFull( sal_False ), 231*cdf0e10cSrcweir mnPresId( 0 ), mnPathShapeId( -1 ) 232*cdf0e10cSrcweir {} 233*cdf0e10cSrcweir }; 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir class AnimExpImpl 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir public: 238*cdf0e10cSrcweir list<XMLEffectHint> maEffects; 239*cdf0e10cSrcweir UniReference< XMLShapeExport > mxShapeExp; 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir OUString msDimColor; 242*cdf0e10cSrcweir OUString msDimHide; 243*cdf0e10cSrcweir OUString msDimPrev; 244*cdf0e10cSrcweir OUString msEffect; 245*cdf0e10cSrcweir OUString msPlayFull; 246*cdf0e10cSrcweir OUString msPresOrder; 247*cdf0e10cSrcweir OUString msSound; 248*cdf0e10cSrcweir OUString msSoundOn; 249*cdf0e10cSrcweir OUString msSpeed; 250*cdf0e10cSrcweir OUString msTextEffect; 251*cdf0e10cSrcweir OUString msIsAnimation; 252*cdf0e10cSrcweir OUString msAnimPath; 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir AnimExpImpl() 255*cdf0e10cSrcweir : msDimColor( RTL_CONSTASCII_USTRINGPARAM( "DimColor" ) ), 256*cdf0e10cSrcweir msDimHide( RTL_CONSTASCII_USTRINGPARAM( "DimHide" ) ), 257*cdf0e10cSrcweir msDimPrev( RTL_CONSTASCII_USTRINGPARAM( "DimPrevious" ) ), 258*cdf0e10cSrcweir msEffect( RTL_CONSTASCII_USTRINGPARAM( "Effect" ) ), 259*cdf0e10cSrcweir msPlayFull( RTL_CONSTASCII_USTRINGPARAM( "PlayFull" ) ), 260*cdf0e10cSrcweir msPresOrder( RTL_CONSTASCII_USTRINGPARAM( "PresentationOrder" ) ), 261*cdf0e10cSrcweir msSound( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ), 262*cdf0e10cSrcweir msSoundOn( RTL_CONSTASCII_USTRINGPARAM( "SoundOn" ) ), 263*cdf0e10cSrcweir msSpeed( RTL_CONSTASCII_USTRINGPARAM( "Speed" ) ), 264*cdf0e10cSrcweir msTextEffect( RTL_CONSTASCII_USTRINGPARAM( "TextEffect" ) ), 265*cdf0e10cSrcweir msIsAnimation( RTL_CONSTASCII_USTRINGPARAM( "IsAnimation" ) ), 266*cdf0e10cSrcweir msAnimPath( RTL_CONSTASCII_USTRINGPARAM( "AnimationPath" ) ) 267*cdf0e10cSrcweir {} 268*cdf0e10cSrcweir }; 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir XMLAnimationsExporter::XMLAnimationsExporter( XMLShapeExport* pShapeExp ) 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir mpImpl = new AnimExpImpl; 273*cdf0e10cSrcweir mpImpl->mxShapeExp = pShapeExp; 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir XMLAnimationsExporter::~XMLAnimationsExporter() 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir delete mpImpl; 279*cdf0e10cSrcweir mpImpl = NULL; 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir void XMLAnimationsExporter::prepare( Reference< XShape > xShape, SvXMLExport& ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir try 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir // check for presentation shape service 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir Reference< XServiceInfo > xServiceInfo( xShape, UNO_QUERY ); 289*cdf0e10cSrcweir if( !xServiceInfo.is() || !xServiceInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.Shape" ) ) ) ) 290*cdf0e10cSrcweir return; 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir Reference< XPropertySet > xProps( xShape, UNO_QUERY ); 294*cdf0e10cSrcweir if( xProps.is() ) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir AnimationEffect eEffect; 297*cdf0e10cSrcweir xProps->getPropertyValue( mpImpl->msEffect ) >>= eEffect; 298*cdf0e10cSrcweir if( eEffect == AnimationEffect_PATH ) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir Reference< XShape > xPath; 301*cdf0e10cSrcweir xProps->getPropertyValue( mpImpl->msAnimPath ) >>= xPath; 302*cdf0e10cSrcweir // strip if( xPath.is() ) 303*cdf0e10cSrcweir // strip mrExport.getInterfaceToIdentifierMapper()->registerReference( xShape ); 304*cdf0e10cSrcweir // strip mpImpl->mxShapeExp->createShapeId( xPath ); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir catch( Exception e ) 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir DBG_ERROR("exception catched while collection animation information!"); 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir void XMLAnimationsExporter::collect( Reference< XShape > xShape, SvXMLExport& rExport ) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir try 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir // check for presentation shape service 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir Reference< XServiceInfo > xServiceInfo( xShape, UNO_QUERY ); 321*cdf0e10cSrcweir if( !xServiceInfo.is() || !xServiceInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.Shape" ) ) ) ) 322*cdf0e10cSrcweir return; 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir Reference< XPropertySet > xProps( xShape, UNO_QUERY ); 326*cdf0e10cSrcweir if( xProps.is() ) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir const OUString aEmptyStr; 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir Reference< XPropertySetInfo > xInfo( xProps->getPropertySetInfo() ); 331*cdf0e10cSrcweir AnimationEffect eEffect; 332*cdf0e10cSrcweir XMLEffectHint aEffect; 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir if( any2bool( xProps->getPropertyValue( mpImpl->msSoundOn ) ) ) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir xProps->getPropertyValue( mpImpl->msSound ) >>= aEffect.maSoundURL; 337*cdf0e10cSrcweir xProps->getPropertyValue( mpImpl->msPlayFull ) >>= aEffect.mbPlayFull; 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir xProps->getPropertyValue( mpImpl->msPresOrder ) >>= aEffect.mnPresId; 341*cdf0e10cSrcweir xProps->getPropertyValue( mpImpl->msSpeed ) >>= aEffect.meSpeed; 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir sal_Bool bIsAnimation = false; 345*cdf0e10cSrcweir xProps->getPropertyValue( mpImpl->msIsAnimation ) >>= bIsAnimation; 346*cdf0e10cSrcweir if( bIsAnimation ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir aEffect.meKind = XMLE_PLAY; 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir if( !aEffect.mxShape.is() ) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir rExport.getInterfaceToIdentifierMapper().registerReference( xShape ); 353*cdf0e10cSrcweir aEffect.mxShape = xShape; 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir mpImpl->maEffects.push_back( aEffect ); 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir xProps->getPropertyValue( mpImpl->msEffect ) >>= eEffect; 362*cdf0e10cSrcweir if( eEffect != AnimationEffect_NONE ) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir sal_Bool bIn = sal_True; 365*cdf0e10cSrcweir SdXMLImplSetEffect( eEffect, aEffect.meEffect, aEffect.meDirection, aEffect.mnStartScale, bIn ); 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir aEffect.meKind = bIn ? XMLE_SHOW : XMLE_HIDE; 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir if( !aEffect.mxShape.is() ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir rExport.getInterfaceToIdentifierMapper().registerReference( xShape ); 372*cdf0e10cSrcweir aEffect.mxShape = xShape; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir if( eEffect == AnimationEffect_PATH ) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir Reference< XShape > xPath; 378*cdf0e10cSrcweir xProps->getPropertyValue( mpImpl->msAnimPath ) >>= xPath; 379*cdf0e10cSrcweir if( xPath.is() ) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir // strip mpImpl->mxShapeExp->createShapeId( xPath ); 382*cdf0e10cSrcweir // strip aEffect.mnPathShapeId = mpImpl->mxShapeExp->getShapeId( xPath ); 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir mpImpl->maEffects.push_back( aEffect ); 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir aEffect.mnPathShapeId = -1; 388*cdf0e10cSrcweir aEffect.maSoundURL = aEmptyStr; 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir xProps->getPropertyValue( mpImpl->msTextEffect ) >>= eEffect; 392*cdf0e10cSrcweir if( eEffect != AnimationEffect_NONE ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir sal_Bool bIn = sal_True; 395*cdf0e10cSrcweir SdXMLImplSetEffect( eEffect, aEffect.meEffect, aEffect.meDirection, aEffect.mnStartScale, bIn ); 396*cdf0e10cSrcweir aEffect.meKind = bIn ? XMLE_SHOW : XMLE_HIDE; 397*cdf0e10cSrcweir aEffect.mbTextEffect = sal_True; 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir if( !aEffect.mxShape.is() ) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir rExport.getInterfaceToIdentifierMapper().registerReference( xShape ); 402*cdf0e10cSrcweir aEffect.mxShape = xShape; 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir mpImpl->maEffects.push_back( aEffect ); 406*cdf0e10cSrcweir aEffect.mbTextEffect = sal_False; 407*cdf0e10cSrcweir aEffect.maSoundURL = aEmptyStr; 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir sal_Bool bDimPrev = false; 411*cdf0e10cSrcweir sal_Bool bDimHide = false; 412*cdf0e10cSrcweir xProps->getPropertyValue( mpImpl->msDimPrev ) >>= bDimPrev; 413*cdf0e10cSrcweir xProps->getPropertyValue( mpImpl->msDimHide ) >>= bDimHide; 414*cdf0e10cSrcweir if( bDimPrev || bDimHide ) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir aEffect.meKind = bDimPrev ? XMLE_DIM : XMLE_HIDE; 417*cdf0e10cSrcweir aEffect.meEffect = EK_none; 418*cdf0e10cSrcweir aEffect.meDirection = ED_none; 419*cdf0e10cSrcweir aEffect.meSpeed = AnimationSpeed_MEDIUM; 420*cdf0e10cSrcweir if( bDimPrev ) 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir sal_Int32 nColor = 0; 423*cdf0e10cSrcweir xProps->getPropertyValue( mpImpl->msDimColor ) >>= nColor; 424*cdf0e10cSrcweir aEffect.maDimColor.SetColor( nColor ); 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir if( !aEffect.mxShape.is() ) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir rExport.getInterfaceToIdentifierMapper().registerReference( xShape ); 430*cdf0e10cSrcweir aEffect.mxShape = xShape; 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir mpImpl->maEffects.push_back( aEffect ); 434*cdf0e10cSrcweir aEffect.maSoundURL = aEmptyStr; 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir catch( Exception e ) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir DBG_ERROR("exception catched while collection animation information!"); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir void XMLAnimationsExporter::exportAnimations( SvXMLExport& rExport ) 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir mpImpl->maEffects.sort(); 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir list<XMLEffectHint>::iterator aIter = mpImpl->maEffects.begin(); 450*cdf0e10cSrcweir const list<XMLEffectHint>::iterator aEnd = mpImpl->maEffects.end(); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir OUStringBuffer sTmp; 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir if( aIter != aEnd ) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir SvXMLElementExport aElement( rExport, XML_NAMESPACE_PRESENTATION, XML_ANIMATIONS, sal_True, sal_True ); 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir do 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir XMLEffectHint& rEffect = *aIter; 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir DBG_ASSERT( rEffect.mxShape.is(), "shape id creation failed for animation effect?" ); 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_SHAPE_ID, rExport.getInterfaceToIdentifierMapper().getIdentifier( rEffect.mxShape ) ); 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir if( rEffect.meKind == XMLE_DIM ) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir // export a dim action; 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir SvXMLUnitConverter::convertColor( sTmp, rEffect.maDimColor ); 471*cdf0e10cSrcweir rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_COLOR, sTmp.makeStringAndClear() ); 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_DIM, sal_True, sal_True ); 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir else if( rEffect.meKind == XMLE_PLAY ) 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir if( rEffect.meSpeed != AnimationSpeed_MEDIUM ) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir SvXMLUnitConverter::convertEnum( sTmp, rEffect.meSpeed, aXML_AnimationSpeed_EnumMap ); 480*cdf0e10cSrcweir rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, sTmp.makeStringAndClear() ); 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_PLAY, sal_True, sal_True ); 484*cdf0e10cSrcweir } 485*cdf0e10cSrcweir else 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir if( rEffect.meEffect != EK_none ) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir SvXMLUnitConverter::convertEnum( sTmp, rEffect.meEffect, aXML_AnimationEffect_EnumMap ); 491*cdf0e10cSrcweir rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_EFFECT, sTmp.makeStringAndClear() ); 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir if( rEffect.meDirection != ED_none ) 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir SvXMLUnitConverter::convertEnum( sTmp, rEffect.meDirection, aXML_AnimationDirection_EnumMap ); 497*cdf0e10cSrcweir rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_DIRECTION, sTmp.makeStringAndClear() ); 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir if( rEffect.mnStartScale != -1 ) 501*cdf0e10cSrcweir { 502*cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( sTmp, rEffect.mnStartScale ); 503*cdf0e10cSrcweir rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_START_SCALE, sTmp.makeStringAndClear() ); 504*cdf0e10cSrcweir } 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir if( rEffect.meSpeed != AnimationSpeed_MEDIUM ) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir SvXMLUnitConverter::convertEnum( sTmp, rEffect.meSpeed, aXML_AnimationSpeed_EnumMap ); 509*cdf0e10cSrcweir rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, sTmp.makeStringAndClear() ); 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir if( rEffect.mnPathShapeId != -1 ) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PATH_ID, OUString::valueOf( rEffect.mnPathShapeId ) ); 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir enum XMLTokenEnum eLocalName; 518*cdf0e10cSrcweir if( rEffect.meKind == XMLE_SHOW ) 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir if( rEffect.mbTextEffect ) 521*cdf0e10cSrcweir eLocalName = XML_SHOW_TEXT; 522*cdf0e10cSrcweir else 523*cdf0e10cSrcweir eLocalName = XML_SHOW_SHAPE; 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir else 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir if( rEffect.mbTextEffect ) 528*cdf0e10cSrcweir eLocalName = XML_HIDE_TEXT; 529*cdf0e10cSrcweir else 530*cdf0e10cSrcweir eLocalName = XML_HIDE_SHAPE; 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir SvXMLElementExport aEle( rExport, XML_NAMESPACE_PRESENTATION, eLocalName, sal_True, sal_True ); 534*cdf0e10cSrcweir if( rEffect.maSoundURL.getLength() != 0 ) 535*cdf0e10cSrcweir { 536*cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, rExport.GetRelativeReference(rEffect.maSoundURL) ); 537*cdf0e10cSrcweir rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); 538*cdf0e10cSrcweir rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_NEW ); 539*cdf0e10cSrcweir rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST ); 540*cdf0e10cSrcweir if( rEffect.mbPlayFull ) 541*cdf0e10cSrcweir rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PLAY_FULL, XML_TRUE ); 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_SOUND, sal_True, sal_True ); 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir aIter++; 548*cdf0e10cSrcweir } 549*cdf0e10cSrcweir while( aIter != aEnd ); 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir mpImpl->maEffects.clear(); 553*cdf0e10cSrcweir } 554