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