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 #ifndef _SD_CUSTOMANIMATIONEFFECT_HXX
29*cdf0e10cSrcweir #define _SD_CUSTOMANIMATIONEFFECT_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimationNode.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/animations/XTimeContainer.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/animations/XAudio.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/util/XChangesListener.hpp>
36*cdf0e10cSrcweir #include <tools/string.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
41*cdf0e10cSrcweir #include <vcl/timer.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include <sddllapi.h>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #include <list>
46*cdf0e10cSrcweir #include <map>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir class SdrPathObj;
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir namespace sd {
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir // --------------------------------------------------------------------
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir enum EValue { VALUE_FROM, VALUE_TO, VALUE_BY, VALUE_FIRST, VALUE_LAST };
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir class CustomAnimationEffect;
57*cdf0e10cSrcweir class AnimationTrigger;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir class CustomAnimationPreset;
60*cdf0e10cSrcweir typedef boost::shared_ptr< CustomAnimationPreset > CustomAnimationPresetPtr;
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir typedef boost::shared_ptr< CustomAnimationEffect > CustomAnimationEffectPtr;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir typedef std::list< CustomAnimationEffectPtr > EffectSequence;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir class EffectSequenceHelper;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir class CustomAnimationEffect
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir 	friend class MainSequence;
71*cdf0e10cSrcweir 	friend class EffectSequenceHelper;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir public:
74*cdf0e10cSrcweir 	SD_DLLPUBLIC CustomAnimationEffect( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
75*cdf0e10cSrcweir 	SD_DLLPUBLIC virtual ~CustomAnimationEffect();
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& getNode() const { return mxNode; }
78*cdf0e10cSrcweir 	void setNode( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
79*cdf0e10cSrcweir 	void replaceNode( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 	CustomAnimationEffectPtr clone() const;
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 	// attributes
84*cdf0e10cSrcweir 	const rtl::OUString&	getPresetId() const { return maPresetId; }
85*cdf0e10cSrcweir 	const rtl::OUString&	getPresetSubType() const { return maPresetSubType; }
86*cdf0e10cSrcweir 	const rtl::OUString&	getProperty() const { return maProperty; }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	sal_Int16				getPresetClass() const { return mnPresetClass; }
89*cdf0e10cSrcweir 	void					setPresetClass( sal_Int16 nPresetClass );
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	sal_Int16		getNodeType() const { return mnNodeType; }
92*cdf0e10cSrcweir 	SD_DLLPUBLIC void			setNodeType( sal_Int16 nNodeType );
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 	::com::sun::star::uno::Any				getRepeatCount() const;
95*cdf0e10cSrcweir 	void			setRepeatCount( const ::com::sun::star::uno::Any& rRepeatCount );
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 	::com::sun::star::uno::Any				getEnd() const;
98*cdf0e10cSrcweir 	void			setEnd( const ::com::sun::star::uno::Any& rEnd );
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	sal_Int16		getFill() const;
101*cdf0e10cSrcweir 	void			setFill( sal_Int16 nFill );
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 	double			getBegin() const { return mfBegin; }
104*cdf0e10cSrcweir 	SD_DLLPUBLIC void			setBegin( double fBegin );
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 	double			getDuration() const { return mfDuration; }
107*cdf0e10cSrcweir 	SD_DLLPUBLIC void			setDuration( double fDuration );
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	double			getAbsoluteDuration() const { return mfAbsoluteDuration; }
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	const String&	getName() const { return maName; }
112*cdf0e10cSrcweir 	void			setName( const String& rName ) { maName = rName; }
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 	sal_Int16		getIterateType() const { return mnIterateType; }
115*cdf0e10cSrcweir 	SD_DLLPUBLIC void			setIterateType( sal_Int16 nIterateType );
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	double			getIterateInterval() const { return mfIterateInterval; }
118*cdf0e10cSrcweir 	SD_DLLPUBLIC void			setIterateInterval( double fIterateInterval );
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	::com::sun::star::uno::Any	getTarget() const { return maTarget; }
121*cdf0e10cSrcweir 	SD_DLLPUBLIC void						setTarget( const ::com::sun::star::uno::Any& rTarget );
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 	sal_Bool		hasAfterEffect() const { return mbHasAfterEffect; }
124*cdf0e10cSrcweir 	void			setHasAfterEffect( sal_Bool bHasAfterEffect ) { mbHasAfterEffect = bHasAfterEffect; }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 	::com::sun::star::uno::Any	getDimColor() const { return maDimColor; }
127*cdf0e10cSrcweir 	void						setDimColor( ::com::sun::star::uno::Any aDimColor ) { maDimColor = aDimColor; }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 	bool			IsAfterEffectOnNext() const { return mbAfterEffectOnNextEffect; }
130*cdf0e10cSrcweir 	void			setAfterEffectOnNext( bool bOnNextEffect ) { mbAfterEffectOnNextEffect = bOnNextEffect; }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 	sal_Int32		getParaDepth() const { return mnParaDepth; }
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 	sal_Bool		hasText() const { return mbHasText; }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 	sal_Int16		getCommand() const { return mnCommand; }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 	double			getAcceleration() const { return mfAcceleration; }
139*cdf0e10cSrcweir 	void			setAcceleration( double fAcceleration );
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	double			getDecelerate() const { return mfDecelerate; }
142*cdf0e10cSrcweir 	void			setDecelerate( double fDecelerate );
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 	sal_Bool		getAutoReverse() const { return mbAutoReverse; }
145*cdf0e10cSrcweir 	void			setAutoReverse( sal_Bool bAutoReverse );
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 	::com::sun::star::uno::Any	getProperty( sal_Int32 nNodeType, const rtl::OUString& rAttributeName, EValue eValue );
148*cdf0e10cSrcweir 	bool						setProperty( sal_Int32 nNodeType, const rtl::OUString& rAttributeName, EValue eValue, const ::com::sun::star::uno::Any& rValue );
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 	::com::sun::star::uno::Any	getTransformationProperty( sal_Int32 nTransformType, EValue eValue );
151*cdf0e10cSrcweir 	bool						setTransformationProperty( sal_Int32 nTransformType, EValue eValue, const ::com::sun::star::uno::Any& rValue );
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 	::com::sun::star::uno::Any	getColor( sal_Int32 nIndex );
154*cdf0e10cSrcweir 	void						setColor( sal_Int32 nIndex, const ::com::sun::star::uno::Any& rColor );
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 	::com::sun::star::uno::Any	getRotation();
157*cdf0e10cSrcweir 	void						setRotation( const ::com::sun::star::uno::Any& rRotation );
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 	sal_Int32		getGroupId() const { return mnGroupId; }
160*cdf0e10cSrcweir 	void			setGroupId( sal_Int32 nGroupId );
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 	sal_Int16		getTargetSubItem() const { return mnTargetSubItem; }
163*cdf0e10cSrcweir 	SD_DLLPUBLIC void			setTargetSubItem( sal_Int16 nSubItem );
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 	::rtl::OUString	getPath() const;
166*cdf0e10cSrcweir 	void setPath( const ::rtl::OUString& rPath );
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 	bool checkForText();
169*cdf0e10cSrcweir 	bool calculateIterateDuration();
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	void setAudio( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAudio >& xAudio );
172*cdf0e10cSrcweir 	bool getStopAudio() const;
173*cdf0e10cSrcweir 	SD_DLLPUBLIC void setStopAudio();
174*cdf0e10cSrcweir 	SD_DLLPUBLIC void createAudio( const ::com::sun::star::uno::Any& rSource, double fVolume = 1.0 );
175*cdf0e10cSrcweir 	void removeAudio();
176*cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAudio >& getAudio() const { return mxAudio; }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 	EffectSequenceHelper*	getEffectSequence() const { return mpEffectSequence; }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 	// helper
181*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > createAfterEffectNode() const throw (com::sun::star::uno::Exception);
182*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getTargetShape() const;
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 	// static helpers
185*cdf0e10cSrcweir 	static sal_Int32 get_node_type( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
186*cdf0e10cSrcweir 	static sal_Int32 getNumberOfSubitems( const ::com::sun::star::uno::Any& aTarget, sal_Int16 nIterateType );
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 	SdrPathObj* createSdrPathObjFromPath();
189*cdf0e10cSrcweir 	void updateSdrPathObjFromPath( SdrPathObj& rPathObj );
190*cdf0e10cSrcweir 	void updatePathFromSdrPathObj( const SdrPathObj& rPathObj );
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir protected:
193*cdf0e10cSrcweir 	void setEffectSequence( EffectSequenceHelper* pSequence ) { mpEffectSequence = pSequence; }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir private:
196*cdf0e10cSrcweir 	sal_Int16		mnNodeType;
197*cdf0e10cSrcweir 	rtl::OUString	maPresetId;
198*cdf0e10cSrcweir 	rtl::OUString	maPresetSubType;
199*cdf0e10cSrcweir 	rtl::OUString	maProperty;
200*cdf0e10cSrcweir 	sal_Int16		mnPresetClass;
201*cdf0e10cSrcweir 	double			mfBegin;
202*cdf0e10cSrcweir 	double			mfDuration;					// this is the maximum duration of the subeffects
203*cdf0e10cSrcweir 	double			mfAbsoluteDuration;			// this is the maximum duration of the subeffects including possible iterations
204*cdf0e10cSrcweir 	sal_Int32		mnGroupId;
205*cdf0e10cSrcweir 	sal_Int16		mnIterateType;
206*cdf0e10cSrcweir 	double			mfIterateInterval;
207*cdf0e10cSrcweir 	sal_Int32		mnParaDepth;
208*cdf0e10cSrcweir 	sal_Bool		mbHasText;
209*cdf0e10cSrcweir 	double			mfAcceleration;
210*cdf0e10cSrcweir 	double			mfDecelerate;
211*cdf0e10cSrcweir 	sal_Bool		mbAutoReverse;
212*cdf0e10cSrcweir 	sal_Int16		mnTargetSubItem;
213*cdf0e10cSrcweir 	sal_Int16		mnCommand;
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir 	EffectSequenceHelper* mpEffectSequence;
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 	String			maName;
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > mxNode;
220*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::animations::XAudio > mxAudio;
221*cdf0e10cSrcweir 	::com::sun::star::uno::Any maTarget;
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 	sal_Bool		mbHasAfterEffect;
224*cdf0e10cSrcweir 	::com::sun::star::uno::Any maDimColor;
225*cdf0e10cSrcweir 	bool		mbAfterEffectOnNextEffect;
226*cdf0e10cSrcweir };
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir struct stl_CustomAnimationEffect_search_node_predict
229*cdf0e10cSrcweir {
230*cdf0e10cSrcweir 	stl_CustomAnimationEffect_search_node_predict( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xSearchNode );
231*cdf0e10cSrcweir 	bool operator()( CustomAnimationEffectPtr pEffect ) const;
232*cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& mxSearchNode;
233*cdf0e10cSrcweir };
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir enum ESequenceHint { EFFECT_EDITED, EFFECT_REMOVED, EFFECT_ADDED };
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir /** this listener is implemented by UI components to track changes in the animation core */
238*cdf0e10cSrcweir class ISequenceListener
239*cdf0e10cSrcweir {
240*cdf0e10cSrcweir public:
241*cdf0e10cSrcweir 	virtual void notify_change() = 0;
242*cdf0e10cSrcweir };
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir /** this class keeps track of a group of animations that build up
245*cdf0e10cSrcweir 	a text animation for a single shape */
246*cdf0e10cSrcweir class CustomAnimationTextGroup
247*cdf0e10cSrcweir {
248*cdf0e10cSrcweir 	friend class EffectSequenceHelper;
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir public:
251*cdf0e10cSrcweir 	CustomAnimationTextGroup( const ::com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rTarget, sal_Int32 nGroupId );
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir 	void reset();
254*cdf0e10cSrcweir 	void addEffect( CustomAnimationEffectPtr& pEffect );
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& getTarget() const { return maTarget; }
257*cdf0e10cSrcweir 	const EffectSequence& getEffects() const { return maEffects; }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 	/* -1: as single object, 0: all at once, n > 0: by n Th paragraph */
260*cdf0e10cSrcweir 	sal_Int32 getTextGrouping() const { return mnTextGrouping; }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir 	sal_Bool getAnimateForm() const { return mbAnimateForm; }
263*cdf0e10cSrcweir 	sal_Bool getTextReverse() const { return mbTextReverse; }
264*cdf0e10cSrcweir 	double getTextGroupingAuto() const { return mfGroupingAuto; }
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir private:
267*cdf0e10cSrcweir 	EffectSequence maEffects;
268*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< com::sun::star::drawing::XShape > maTarget;
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir 	sal_Int32 mnTextGrouping;
271*cdf0e10cSrcweir 	sal_Bool mbAnimateForm;
272*cdf0e10cSrcweir 	sal_Bool mbTextReverse;
273*cdf0e10cSrcweir 	double mfGroupingAuto;
274*cdf0e10cSrcweir 	sal_Int32 mnLastPara;
275*cdf0e10cSrcweir 	sal_Int8 mnDepthFlags[5];
276*cdf0e10cSrcweir 	sal_Int32 mnGroupId;
277*cdf0e10cSrcweir };
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir typedef boost::shared_ptr< CustomAnimationTextGroup > CustomAnimationTextGroupPtr;
280*cdf0e10cSrcweir typedef std::map< sal_Int32, CustomAnimationTextGroupPtr > CustomAnimationTextGroupMap;
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir class EffectSequenceHelper
283*cdf0e10cSrcweir {
284*cdf0e10cSrcweir friend class MainSequence;
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir public:
287*cdf0e10cSrcweir 	EffectSequenceHelper();
288*cdf0e10cSrcweir 	EffectSequenceHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XTimeContainer >& xSequenceRoot );
289*cdf0e10cSrcweir 	virtual ~EffectSequenceHelper();
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > getRootNode();
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 	CustomAnimationEffectPtr append( const CustomAnimationPresetPtr& pDescriptor, const ::com::sun::star::uno::Any& rTarget, double fDuration = -1.0 );
294*cdf0e10cSrcweir 	CustomAnimationEffectPtr append( const SdrPathObj& rPathObj, const ::com::sun::star::uno::Any& rTarget, double fDuration = -1.0 );
295*cdf0e10cSrcweir 	SD_DLLPUBLIC void append( const CustomAnimationEffectPtr& pEffect );
296*cdf0e10cSrcweir 	void insert( EffectSequence::iterator& rPos, const CustomAnimationEffectPtr& pEffect );
297*cdf0e10cSrcweir 	void replace( const CustomAnimationEffectPtr& pEffect, const CustomAnimationPresetPtr& pDescriptor, double fDuration = -1.0 );
298*cdf0e10cSrcweir 	void replace( const CustomAnimationEffectPtr& pEffect, const CustomAnimationPresetPtr& pDescriptor, const rtl::OUString& rPresetSubType, double fDuration = -1.0 );
299*cdf0e10cSrcweir 	void remove( const CustomAnimationEffectPtr& pEffect );
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir 	void create( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
302*cdf0e10cSrcweir 	void createEffectsequence( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
303*cdf0e10cSrcweir 	void processAfterEffect( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
304*cdf0e10cSrcweir 	void createEffects( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir 	sal_Int32 getCount() const { return sal::static_int_cast< sal_Int32 >( maEffects.size() ); }
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir 	virtual CustomAnimationEffectPtr findEffect( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode ) const;
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 	virtual bool disposeShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape );
311*cdf0e10cSrcweir 	virtual void insertTextRange( const com::sun::star::uno::Any& aTarget );
312*cdf0e10cSrcweir 	virtual void disposeTextRange( const com::sun::star::uno::Any& aTarget );
313*cdf0e10cSrcweir 	virtual bool hasEffect( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape );
314*cdf0e10cSrcweir 	virtual void onTextChanged( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape );
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 	/** this must be called if effects from this sequence are changed.
317*cdf0e10cSrcweir 		the method will call the registered listeners */
318*cdf0e10cSrcweir 	void update( const CustomAnimationEffectPtr& pEffect );
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 	/** this method rebuilds the animation nodes */
321*cdf0e10cSrcweir 	virtual void rebuild();
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 	EffectSequence::iterator getBegin() { return maEffects.begin(); }
324*cdf0e10cSrcweir 	EffectSequence::iterator getEnd() { return maEffects.end(); }
325*cdf0e10cSrcweir 	EffectSequence::iterator find( const CustomAnimationEffectPtr& pEffect );
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir 	EffectSequence& getSequence() { return maEffects; }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 	void addListener( ISequenceListener* pListener );
330*cdf0e10cSrcweir 	void removeListener( ISequenceListener* pListener );
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir 	// text group methods
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir 	CustomAnimationTextGroupPtr findGroup( sal_Int32 nGroupId );
335*cdf0e10cSrcweir 	SD_DLLPUBLIC CustomAnimationTextGroupPtr	createTextGroup( CustomAnimationEffectPtr pEffect, sal_Int32 nTextGrouping, double fTextGroupingAuto, sal_Bool bAnimateForm, sal_Bool bTextReverse );
336*cdf0e10cSrcweir 	void setTextGrouping( CustomAnimationTextGroupPtr pTextGroup, sal_Int32 nTextGrouping );
337*cdf0e10cSrcweir 	void setAnimateForm( CustomAnimationTextGroupPtr pTextGroup, sal_Bool bAnimateForm );
338*cdf0e10cSrcweir 	void setTextGroupingAuto( CustomAnimationTextGroupPtr pTextGroup, double fTextGroupingAuto );
339*cdf0e10cSrcweir 	void setTextReverse( CustomAnimationTextGroupPtr pTextGroup, sal_Bool bAnimateForm );
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 	sal_Int32 getSequenceType() const { return mnSequenceType; }
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getTriggerShape() const { return mxEventSource; }
344*cdf0e10cSrcweir 	void setTriggerShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xTrigger ) { mxEventSource = xTrigger; }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir 	virtual sal_Int32 getOffsetFromEffect( const CustomAnimationEffectPtr& xEffect ) const;
347*cdf0e10cSrcweir 	virtual CustomAnimationEffectPtr getEffectFromOffset( sal_Int32 nOffset ) const;
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir protected:
350*cdf0e10cSrcweir 	virtual void implRebuild();
351*cdf0e10cSrcweir 	virtual void reset();
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir 	void createTextGroupParagraphEffects( CustomAnimationTextGroupPtr pTextGroup, CustomAnimationEffectPtr pEffect, bool bUsed );
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir 	void notify_listeners();
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::animations::XTimeContainer > createParallelTimeContainer() const;
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir 	void updateTextGroups();
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir protected:
362*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::animations::XTimeContainer > mxSequenceRoot;
363*cdf0e10cSrcweir 	EffectSequence maEffects;
364*cdf0e10cSrcweir 	std::list< ISequenceListener* > maListeners;
365*cdf0e10cSrcweir 	CustomAnimationTextGroupMap maGroupMap;
366*cdf0e10cSrcweir 	sal_Int32 mnSequenceType;
367*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mxEventSource;
368*cdf0e10cSrcweir };
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir class MainSequence;
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir class InteractiveSequence : public EffectSequenceHelper
373*cdf0e10cSrcweir {
374*cdf0e10cSrcweir friend class MainSequence;
375*cdf0e10cSrcweir friend class MainSequenceChangeGuard;
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir public:
378*cdf0e10cSrcweir 	InteractiveSequence( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XTimeContainer >& xSequenceRoot, MainSequence* pMainSequence );
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir 	/** this method rebuilds the animation nodes */
381*cdf0e10cSrcweir 	virtual void rebuild();
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir private:
384*cdf0e10cSrcweir 	virtual void implRebuild();
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir 	MainSequence*	mpMainSequence;
387*cdf0e10cSrcweir };
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir typedef boost::shared_ptr< InteractiveSequence > InteractiveSequencePtr;
390*cdf0e10cSrcweir typedef std::list< InteractiveSequencePtr > InteractiveSequenceList;
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir class MainSequence : public EffectSequenceHelper, public ISequenceListener
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir 	friend class UndoAnimation;
395*cdf0e10cSrcweir 	friend class MainSequenceRebuildGuard;
396*cdf0e10cSrcweir 	friend class MainSequenceChangeGuard;
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir public:
399*cdf0e10cSrcweir 	MainSequence();
400*cdf0e10cSrcweir 	MainSequence( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xTimingRootNode );
401*cdf0e10cSrcweir 	~MainSequence();
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > getRootNode();
404*cdf0e10cSrcweir 	void reset( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xTimingRootNode );
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir 	/** this method rebuilds the animation nodes */
407*cdf0e10cSrcweir 	virtual void rebuild();
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir 	virtual CustomAnimationEffectPtr findEffect( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode ) const;
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir 	virtual bool disposeShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape );
412*cdf0e10cSrcweir 	virtual void insertTextRange( const com::sun::star::uno::Any& aTarget );
413*cdf0e10cSrcweir 	virtual void disposeTextRange( const com::sun::star::uno::Any& aTarget );
414*cdf0e10cSrcweir 	virtual bool hasEffect( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape );
415*cdf0e10cSrcweir 	virtual void onTextChanged( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape );
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir 	const InteractiveSequenceList& getInteractiveSequenceList() const { return maInteractiveSequenceList; }
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir 	virtual void notify_change();
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir 	bool setTrigger( const CustomAnimationEffectPtr& pEffect, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xTriggerShape );
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir 	/** starts a timer that recreates the internal structure from the API core after 1 second */
424*cdf0e10cSrcweir 	void startRecreateTimer();
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir 	/** starts a timer that rebuilds the API core from the internal structure after 1 second */
427*cdf0e10cSrcweir 	void startRebuildTimer();
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir 	virtual sal_Int32 getOffsetFromEffect( const CustomAnimationEffectPtr& xEffect ) const;
430*cdf0e10cSrcweir 	virtual CustomAnimationEffectPtr getEffectFromOffset( sal_Int32 nOffset ) const;
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir protected:
433*cdf0e10cSrcweir 	/** permits rebuilds until unlockRebuilds() is called. All rebuild calls during a locked sequence are
434*cdf0e10cSrcweir 		process after unlockRebuilds() call. lockRebuilds() and unlockRebuilds() calls can be nested. */
435*cdf0e10cSrcweir 	void lockRebuilds();
436*cdf0e10cSrcweir 	void unlockRebuilds();
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir 	DECL_LINK( onTimerHdl, Timer * );
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir 	virtual void implRebuild();
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 	void init();
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir 	void createMainSequence();
445*cdf0e10cSrcweir 	virtual void reset();
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir 	InteractiveSequencePtr createInteractiveSequence( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape );
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir 	InteractiveSequenceList maInteractiveSequenceList;
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesListener > mxChangesListener;
452*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::animations::XTimeContainer > mxTimingRootNode;
453*cdf0e10cSrcweir 	Timer maTimer;
454*cdf0e10cSrcweir 	bool mbTimerMode;
455*cdf0e10cSrcweir 	bool mbRebuilding;
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 	long mnRebuildLockGuard;
458*cdf0e10cSrcweir 	bool mbPendingRebuildRequest;
459*cdf0e10cSrcweir 	sal_Int32 mbIgnoreChanges;
460*cdf0e10cSrcweir };
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir typedef boost::shared_ptr< MainSequence > MainSequencePtr;
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir class MainSequenceRebuildGuard
465*cdf0e10cSrcweir {
466*cdf0e10cSrcweir public:
467*cdf0e10cSrcweir 	MainSequenceRebuildGuard( const MainSequencePtr& pMainSequence );
468*cdf0e10cSrcweir 	~MainSequenceRebuildGuard();
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir private:
471*cdf0e10cSrcweir 	MainSequencePtr mpMainSequence;
472*cdf0e10cSrcweir };
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir }
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir #endif // _SD_CUSTOMANIMATIONEFFECT_HXX
477