1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SD_CUSTOMANIMATIONPANE_HXX
29 #define _SD_CUSTOMANIMATIONPANE_HXX
30 
31 #include <com/sun/star/drawing/XDrawView.hpp>
32 #include <com/sun/star/frame/XModel.hpp>
33 #include <vcl/dialog.hxx>
34 #include "CustomAnimationPreset.hxx"
35 #include "CustomAnimationList.hxx"
36 #include "CustomAnimationCreateDialog.hxx"
37 
38 #include "motionpathtag.hxx"
39 #include "misc/scopelock.hxx"
40 
41 #include <vector>
42 
43 class PushButton;
44 class FixedLine;
45 class FixedText;
46 class ListBox;
47 class ComboBox;
48 class CheckBox;
49 class SdDrawDocument;
50 
51 namespace com { namespace sun { namespace star { namespace animations {
52 	class XAnimationNode;
53 } } } }
54 
55 namespace sd { namespace tools {
56 class EventMultiplexerEvent;
57 } }
58 
59 namespace sd {
60 
61 class PropertyControl;
62 class STLPropertySet;
63 class ViewShellBase;
64 
65 typedef std::vector< rtl::Reference< MotionPathTag > > MotionPathTagVector;
66 
67 // --------------------------------------------------------------------
68 
69 class CustomAnimationPane : public Control, public ICustomAnimationListController
70 {
71 	friend class MotionPathTag;
72 public:
73 	CustomAnimationPane( ::Window* pParent, ViewShellBase& rBase, const Size& rMinSize );
74 	virtual ~CustomAnimationPane();
75 
76 	// callbacks
77 	void onSelectionChanged();
78 	void onChangeCurrentPage();
79 	void onChange( bool bCreate );
80 	void onRemove();
81 	void onChangeStart();
82 	void onChangeStart( sal_Int16 nNodeType );
83 	void onChangeProperty();
84 	void onChangeSpeed();
85 
86 	// methods
87 	void preview( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xAnimationNode );
88 	void remove( CustomAnimationEffectPtr& pEffect );
89 
90 	// Control
91 	virtual void Resize();
92 	virtual void StateChanged( StateChangedType nStateChange );
93 	virtual void KeyInput( const KeyEvent& rKEvt );
94 
95 	// ICustomAnimationListController
96 	virtual void onSelect();
97 	virtual void onDoubleClick();
98 	virtual void onContextMenu( sal_uInt16 nSelectedPopupEntry );
99 
100 	void addUndo();
101 
102 	void updatePathFromMotionPathTag( const rtl::Reference< MotionPathTag >& xTag );
103 
104 private:
105 	void addListener();
106 	void removeListener();
107 	void updateLayout();
108 	void updateControls();
109 	void updateMotionPathTags();
110 	void markShapesFromSelectedEffects();
111 
112 	void showOptions( sal_uInt16 nPage = 0 );
113 	void moveSelection( bool bUp );
114 	void onPreview( bool bForcePreview );
115 
116 	void createPath( PathKind eKind, std::vector< ::com::sun::star::uno::Any >& rTargets, double fDuration );
117 
118 	STLPropertySet* createSelectionSet();
119 	void changeSelection( STLPropertySet* pResultSet, STLPropertySet* pOldSet );
120 
121 	::com::sun::star::uno::Any getProperty1Value( sal_Int32 nType, CustomAnimationEffectPtr pEffect );
122 	bool setProperty1Value( sal_Int32 nType, CustomAnimationEffectPtr pEffect, const ::com::sun::star::uno::Any& rValue );
123 
124 	DECL_LINK( implControlHdl, Control* );
125 	DECL_LINK( implPropertyHdl, Control* );
126     DECL_LINK(EventMultiplexerListener, tools::EventMultiplexerEvent*);
127     DECL_LINK(lateInitCallback, Timer*);
128 
129 private:
130 	ViewShellBase& mrBase;
131 
132 	const CustomAnimationPresets* mpCustomAnimationPresets;
133 
134 	FixedLine*	mpFLModify;
135 	PushButton*	mpPBAddEffect;
136 	PushButton* mpPBChangeEffect;
137 	PushButton*	mpPBRemoveEffect;
138 	FixedLine*	mpFLEffect;
139 	FixedText*	mpFTStart;
140 	ListBox*	mpLBStart;
141 	FixedText*	mpFTProperty;
142 	PropertyControl*	mpLBProperty;
143 	PushButton*	mpPBPropertyMore;
144 	FixedText*	mpFTSpeed;
145 	ComboBox*	mpCBSpeed;
146 	CustomAnimationList*	mpCustomAnimationList;
147 	FixedText*	mpFTChangeOrder;
148 	PushButton*	mpPBMoveUp;
149 	PushButton* mpPBMoveDown;
150 	FixedLine*	mpFLSeperator1;
151 	PushButton*	mpPBPlay;
152 	PushButton* mpPBSlideShow;
153 	FixedLine*	mpFLSeperator2;
154 	CheckBox*	mpCBAutoPreview;
155 
156 	String		maStrModify;
157 	String		maStrProperty;
158 
159 	sal_Int32	mnPropertyType;
160 
161 	Size		maMinSize;
162 
163 	EffectSequence maListSelection;
164 	::com::sun::star::uno::Any maViewSelection;
165 
166 	MainSequencePtr	mpMainSequence;
167 
168 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mxCurrentPage;
169 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawView > mxView;
170 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxModel;
171 
172     /** The mpCustomAnimationPresets is initialized either on demand or
173         after a short time after the construction of a new object of this
174         class.  This timer is responsible for the later.
175     */
176     Timer maLateInitTimer;
177 
178     /** This method initializes the mpCustomAnimationPresets on demand and
179         returns a reference to the list.
180     */
181     const CustomAnimationPresets& getPresets (void);
182 
183 	MotionPathTagVector maMotionPathTags;
184 
185 	ScopeLock maSelectionLock;
186 };
187 
188 }
189 
190 #endif // _SD_CUSTOMANIMATIONPANE_HXX
191