1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SD_CUSTOMANIMATIONPANE_HXX
25 #define _SD_CUSTOMANIMATIONPANE_HXX
26 
27 #include <com/sun/star/drawing/XDrawView.hpp>
28 #include <com/sun/star/frame/XModel.hpp>
29 #include <vcl/dialog.hxx>
30 #include "CustomAnimationPreset.hxx"
31 #include "CustomAnimationList.hxx"
32 #include "CustomAnimationCreateDialog.hxx"
33 
34 #include "motionpathtag.hxx"
35 #include "misc/scopelock.hxx"
36 
37 #include <vector>
38 
39 class PushButton;
40 class FixedLine;
41 class FixedText;
42 class ListBox;
43 class ComboBox;
44 class CheckBox;
45 class SdDrawDocument;
46 
47 namespace com { namespace sun { namespace star { namespace animations {
48 	class XAnimationNode;
49 } } } }
50 
51 namespace sd { namespace tools {
52 class EventMultiplexerEvent;
53 } }
54 
55 namespace sd {
56 
57 class PropertyControl;
58 class STLPropertySet;
59 class ViewShellBase;
60 
61 typedef std::vector< rtl::Reference< MotionPathTag > > MotionPathTagVector;
62 
63 // --------------------------------------------------------------------
64 
65 class CustomAnimationPane : public Control, public ICustomAnimationListController
66 {
67 	friend class MotionPathTag;
68 public:
69 	CustomAnimationPane( ::Window* pParent, ViewShellBase& rBase, const Size& rMinSize );
70 	virtual ~CustomAnimationPane();
71 
72 	// callbacks
73 	void onSelectionChanged();
74 	void onChangeCurrentPage();
75 	void onChange( bool bCreate );
76 	void onRemove();
77 	void onChangeStart();
78 	void onChangeStart( sal_Int16 nNodeType );
79 	void onChangeProperty();
80 	void onChangeSpeed();
81 
82 	// methods
83 	void preview( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xAnimationNode );
84 	void remove( CustomAnimationEffectPtr& pEffect );
85 
86 	// Control
87 	virtual void Resize();
88 	virtual void StateChanged( StateChangedType nStateChange );
89 	virtual void KeyInput( const KeyEvent& rKEvt );
90 
91 	// ICustomAnimationListController
92 	virtual void onSelect();
93 	virtual void onDoubleClick();
94 	virtual void onContextMenu( sal_uInt16 nSelectedPopupEntry );
95 
96 	void addUndo();
97 
98 	void updatePathFromMotionPathTag( const rtl::Reference< MotionPathTag >& xTag );
99 
100 private:
101 	void addListener();
102 	void removeListener();
103 	void updateLayout();
104 	void updateControls();
105 	void updateMotionPathTags();
106 	void markShapesFromSelectedEffects();
107 
108 	void showOptions( sal_uInt16 nPage = 0 );
109 	void moveSelection( bool bUp );
110 	void onPreview( bool bForcePreview );
111 
112 	void createPath( PathKind eKind, std::vector< ::com::sun::star::uno::Any >& rTargets, double fDuration );
113 
114 	STLPropertySet* createSelectionSet();
115 	void changeSelection( STLPropertySet* pResultSet, STLPropertySet* pOldSet );
116 
117 	::com::sun::star::uno::Any getProperty1Value( sal_Int32 nType, CustomAnimationEffectPtr pEffect );
118 	bool setProperty1Value( sal_Int32 nType, CustomAnimationEffectPtr pEffect, const ::com::sun::star::uno::Any& rValue );
119 
120 	DECL_LINK( implControlHdl, Control* );
121 	DECL_LINK( implPropertyHdl, Control* );
122     DECL_LINK(EventMultiplexerListener, tools::EventMultiplexerEvent*);
123     DECL_LINK(lateInitCallback, Timer*);
124 
125 private:
126 	ViewShellBase& mrBase;
127 
128 	const CustomAnimationPresets* mpCustomAnimationPresets;
129 
130 	FixedLine*	mpFLModify;
131 	PushButton*	mpPBAddEffect;
132 	PushButton* mpPBChangeEffect;
133 	PushButton*	mpPBRemoveEffect;
134 	FixedLine*	mpFLEffect;
135 	FixedText*	mpFTStart;
136 	ListBox*	mpLBStart;
137 	FixedText*	mpFTProperty;
138 	PropertyControl*	mpLBProperty;
139 	PushButton*	mpPBPropertyMore;
140 	FixedText*	mpFTSpeed;
141 	ComboBox*	mpCBSpeed;
142 	CustomAnimationList*	mpCustomAnimationList;
143 	FixedText*	mpFTChangeOrder;
144 	PushButton*	mpPBMoveUp;
145 	PushButton* mpPBMoveDown;
146 	FixedLine*	mpFLSeperator1;
147 	PushButton*	mpPBPlay;
148 	PushButton* mpPBSlideShow;
149 	FixedLine*	mpFLSeperator2;
150 	CheckBox*	mpCBAutoPreview;
151 
152 	String		maStrModify;
153 	String		maStrProperty;
154 
155 	sal_Int32	mnPropertyType;
156 
157 	Size		maMinSize;
158 
159 	EffectSequence maListSelection;
160 	::com::sun::star::uno::Any maViewSelection;
161 
162 	MainSequencePtr	mpMainSequence;
163 
164 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mxCurrentPage;
165 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawView > mxView;
166 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxModel;
167 
168     /** The mpCustomAnimationPresets is initialized either on demand or
169         after a short time after the construction of a new object of this
170         class.  This timer is responsible for the later.
171     */
172     Timer maLateInitTimer;
173 
174     /** This method initializes the mpCustomAnimationPresets on demand and
175         returns a reference to the list.
176     */
177     const CustomAnimationPresets& getPresets (void);
178 
179 	MotionPathTagVector maMotionPathTags;
180 
181 	ScopeLock maSelectionLock;
182 };
183 
184 }
185 
186 #endif // _SD_CUSTOMANIMATIONPANE_HXX
187