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