xref: /AOO41X/main/sd/source/ui/animations/CustomAnimationPane.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sd.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/presentation/EffectPresetClass.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawView.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/presentation/EffectNodeType.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/presentation/EffectCommands.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/animations/AnimationTransformType.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/text/XTextRangeCompare.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/presentation/ParagraphTarget.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/drawing/FillStyle.hpp>
48*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
49*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
50*cdf0e10cSrcweir #include "STLPropertySet.hxx"
51*cdf0e10cSrcweir #include "CustomAnimationPane.hxx"
52*cdf0e10cSrcweir #include "CustomAnimationDialog.hxx"
53*cdf0e10cSrcweir #include "CustomAnimationCreateDialog.hxx"
54*cdf0e10cSrcweir #include "CustomAnimationPane.hrc"
55*cdf0e10cSrcweir #include "CustomAnimation.hrc"
56*cdf0e10cSrcweir #include "CustomAnimationList.hxx"
57*cdf0e10cSrcweir #include <vcl/lstbox.hxx>
58*cdf0e10cSrcweir #include <vcl/fixed.hxx>
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir #include <vcl/button.hxx>
61*cdf0e10cSrcweir #include <vcl/combobox.hxx>
62*cdf0e10cSrcweir #include <vcl/scrbar.hxx>
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir #include <comphelper/sequence.hxx>
65*cdf0e10cSrcweir #include <sfx2/frame.hxx>
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir #include <svx/unoapi.hxx>
68*cdf0e10cSrcweir #include <svx/svxids.hrc>
69*cdf0e10cSrcweir #include <DrawDocShell.hxx>
70*cdf0e10cSrcweir #include <ViewShellBase.hxx>
71*cdf0e10cSrcweir #include "DrawViewShell.hxx"
72*cdf0e10cSrcweir #include "DrawController.hxx"
73*cdf0e10cSrcweir #include "sdresid.hxx"
74*cdf0e10cSrcweir #include "drawview.hxx"
75*cdf0e10cSrcweir #include "slideshow.hxx"
76*cdf0e10cSrcweir #include "undoanim.hxx"
77*cdf0e10cSrcweir #include "optsitem.hxx"
78*cdf0e10cSrcweir #include "sddll.hxx"
79*cdf0e10cSrcweir #include "framework/FrameworkHelper.hxx"
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir #include "EventMultiplexer.hxx"
82*cdf0e10cSrcweir #include "DialogListBox.hxx"
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir #include "glob.hrc"
85*cdf0e10cSrcweir #include "sdpage.hxx"
86*cdf0e10cSrcweir #include "drawdoc.hxx"
87*cdf0e10cSrcweir #include "app.hrc"
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir #include <memory>
90*cdf0e10cSrcweir #include <algorithm>
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
93*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
94*cdf0e10cSrcweir #include <basegfx/range/b2drange.hxx>
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir using namespace ::com::sun::star;
97*cdf0e10cSrcweir using namespace ::com::sun::star::animations;
98*cdf0e10cSrcweir using namespace ::com::sun::star::presentation;
99*cdf0e10cSrcweir using namespace ::com::sun::star::text;
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir using ::rtl::OUString;
102*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
103*cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
104*cdf0e10cSrcweir using ::com::sun::star::view::XSelectionSupplier;
105*cdf0e10cSrcweir using ::com::sun::star::view::XSelectionChangeListener;
106*cdf0e10cSrcweir using ::com::sun::star::frame::XController;
107*cdf0e10cSrcweir using ::com::sun::star::frame::XModel;
108*cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet;
109*cdf0e10cSrcweir using ::com::sun::star::beans::XPropertyChangeListener;
110*cdf0e10cSrcweir using ::com::sun::star::container::XIndexAccess;
111*cdf0e10cSrcweir using ::com::sun::star::container::XEnumerationAccess;
112*cdf0e10cSrcweir using ::com::sun::star::container::XEnumeration;
113*cdf0e10cSrcweir using ::com::sun::star::text::XText;
114*cdf0e10cSrcweir using ::sd::framework::FrameworkHelper;
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir namespace sd {
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir // --------------------------------------------------------------------
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir void fillDurationComboBox( ComboBox* pBox )
121*cdf0e10cSrcweir {
122*cdf0e10cSrcweir 	static const double gdVerySlow = 5.0;
123*cdf0e10cSrcweir 	static const double gdSlow = 3.0;
124*cdf0e10cSrcweir 	static const double gdNormal = 2.0;
125*cdf0e10cSrcweir 	static const double gdFast = 1.0;
126*cdf0e10cSrcweir 	static const double gdVeryFast = 0.5;
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 	String aVerySlow( SdResId( STR_CUSTOMANIMATION_DURATION_VERY_SLOW ) );
129*cdf0e10cSrcweir 	pBox->SetEntryData( pBox->InsertEntry( aVerySlow ), (void*)&gdVerySlow );
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 	String aSlow( SdResId( STR_CUSTOMANIMATION_DURATION_SLOW ) );
132*cdf0e10cSrcweir 	pBox->SetEntryData( pBox->InsertEntry( aSlow ), (void*)&gdSlow );
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 	String aNormal( SdResId( STR_CUSTOMANIMATION_DURATION_NORMAL ) );
135*cdf0e10cSrcweir 	pBox->SetEntryData( pBox->InsertEntry( aNormal ), (void*)&gdNormal );
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 	String aFast( SdResId( STR_CUSTOMANIMATION_DURATION_FAST ) );
138*cdf0e10cSrcweir 	pBox->SetEntryData( pBox->InsertEntry( aFast ), (void*)&gdFast );
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 	String aVeryFast( SdResId( STR_CUSTOMANIMATION_DURATION_VERY_FAST ) );
141*cdf0e10cSrcweir 	pBox->SetEntryData( pBox->InsertEntry( aVeryFast ), (void*)&gdVeryFast );
142*cdf0e10cSrcweir }
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir void fillRepeatComboBox( ComboBox* pBox )
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir 	String aNone( SdResId( STR_CUSTOMANIMATION_REPEAT_NONE ) );
147*cdf0e10cSrcweir 	pBox->SetEntryData( pBox->InsertEntry( aNone ), (void*)((sal_Int32)0) );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 	pBox->SetEntryData( pBox->InsertEntry( String::CreateFromInt32( 2 ) ), (void*)((sal_Int32)1) );
150*cdf0e10cSrcweir 	pBox->SetEntryData( pBox->InsertEntry( String::CreateFromInt32( 3 ) ), (void*)((sal_Int32)3) );
151*cdf0e10cSrcweir 	pBox->SetEntryData( pBox->InsertEntry( String::CreateFromInt32( 4 ) ), (void*)((sal_Int32)4) );
152*cdf0e10cSrcweir 	pBox->SetEntryData( pBox->InsertEntry( String::CreateFromInt32( 5 ) ), (void*)((sal_Int32)5) );
153*cdf0e10cSrcweir 	pBox->SetEntryData( pBox->InsertEntry( String::CreateFromInt32( 10 ) ), (void*)((sal_Int32)10) );
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 	String aUntilClick( SdResId( STR_CUSTOMANIMATION_REPEAT_UNTIL_NEXT_CLICK ) );
156*cdf0e10cSrcweir 	pBox->SetEntryData( pBox->InsertEntry( aUntilClick ), (void*)((sal_Int32)-1) );
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 	String aEndOfSlide( SdResId( STR_CUSTOMANIMATION_REPEAT_UNTIL_END_OF_SLIDE ) );
159*cdf0e10cSrcweir 	pBox->SetEntryData( pBox->InsertEntry( aEndOfSlide ), (void*)((sal_Int32)-2) );
160*cdf0e10cSrcweir }
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir // --------------------------------------------------------------------
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir CustomAnimationPane::CustomAnimationPane( ::Window* pParent, ViewShellBase& rBase, const Size& rMinSize )
165*cdf0e10cSrcweir :	Control( pParent, SdResId(DLG_CUSTOMANIMATIONPANE) ),
166*cdf0e10cSrcweir 	mrBase( rBase ),
167*cdf0e10cSrcweir 	mpCustomAnimationPresets(NULL),
168*cdf0e10cSrcweir 	mnPropertyType( nPropertyTypeNone ),
169*cdf0e10cSrcweir 	maMinSize( rMinSize ),
170*cdf0e10cSrcweir 	mxModel( rBase.GetDocShell()->GetDoc()->getUnoModel(), UNO_QUERY ),
171*cdf0e10cSrcweir 	maLateInitTimer()
172*cdf0e10cSrcweir {
173*cdf0e10cSrcweir 	// load resources
174*cdf0e10cSrcweir 	mpFLEffect = new FixedLine( this, SdResId( FL_EFFECT ) );
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 	mpPBAddEffect = new PushButton( this, SdResId( PB_ADD_EFFECT ) );
177*cdf0e10cSrcweir 	mpPBChangeEffect = new PushButton( this, SdResId( PB_CHANGE_EFFECT ) );
178*cdf0e10cSrcweir 	mpPBRemoveEffect = new PushButton( this, SdResId( PB_REMOVE_EFFECT ) );
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 	mpFLModify = new FixedLine( this, SdResId( FL_MODIFY ) );
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 	mpFTStart = new FixedText( this, SdResId( FT_START ) );
183*cdf0e10cSrcweir 	mpLBStart = new ListBox( this, SdResId( LB_START ) );
184*cdf0e10cSrcweir 	mpFTProperty = new FixedText( this, SdResId( FT_PROPERTY ) );
185*cdf0e10cSrcweir 	mpLBProperty = new PropertyControl( this, SdResId( LB_PROPERTY ) );
186*cdf0e10cSrcweir 	mpPBPropertyMore = new PushButton( this, SdResId( PB_PROPERTY_MORE ) );
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 	mpFTSpeed = new FixedText( this, SdResId( FT_SPEED ) );
189*cdf0e10cSrcweir 	mpCBSpeed = new ComboBox( this, SdResId( CB_SPEED ) );
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 	mpCustomAnimationList = new CustomAnimationList( this, SdResId( CT_CUSTOM_ANIMATION_LIST ), this );
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 	mpPBMoveUp = new PushButton( this, SdResId( PB_MOVE_UP ) );
194*cdf0e10cSrcweir 	mpPBMoveDown = new PushButton( this, SdResId( PB_MOVE_DOWN ) );
195*cdf0e10cSrcweir 	mpFTChangeOrder = new FixedText( this, SdResId( FT_CHANGE_ORDER ) );
196*cdf0e10cSrcweir 	mpFLSeperator1 = new FixedLine( this, SdResId( FL_SEPERATOR1 ) );
197*cdf0e10cSrcweir 	mpPBPlay = new PushButton( this, SdResId( PB_PLAY ) );
198*cdf0e10cSrcweir 	mpPBSlideShow = new PushButton( this, SdResId( PB_SLIDE_SHOW ) );
199*cdf0e10cSrcweir 	mpFLSeperator2 = new FixedLine( this, SdResId( FL_SEPERATOR2 ) );
200*cdf0e10cSrcweir 	mpCBAutoPreview = new CheckBox( this, SdResId( CB_AUTOPREVIEW ) );
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 	maStrProperty = mpFTProperty->GetText();
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 	FreeResource();
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir     // use bold font for group headings (same font for all fixed lines):
207*cdf0e10cSrcweir     Font font( mpFLEffect->GetFont() );
208*cdf0e10cSrcweir     font.SetWeight( WEIGHT_BOLD );
209*cdf0e10cSrcweir     mpFLEffect->SetFont( font );
210*cdf0e10cSrcweir     mpFLModify->SetFont( font );
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir 	fillDurationComboBox( mpCBSpeed );
213*cdf0e10cSrcweir 	mpPBMoveUp->SetSymbol( SYMBOL_ARROW_UP );
214*cdf0e10cSrcweir 	mpPBMoveDown->SetSymbol( SYMBOL_ARROW_DOWN );
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir 	mpPBAddEffect->SetClickHdl( LINK( this, CustomAnimationPane, implControlHdl ) );
217*cdf0e10cSrcweir 	mpPBChangeEffect->SetClickHdl( LINK( this, CustomAnimationPane, implControlHdl ) );
218*cdf0e10cSrcweir 	mpPBRemoveEffect->SetClickHdl( LINK( this, CustomAnimationPane, implControlHdl ) );
219*cdf0e10cSrcweir 	mpLBStart->SetSelectHdl( LINK( this, CustomAnimationPane, implControlHdl ) );
220*cdf0e10cSrcweir 	mpCBSpeed->SetSelectHdl( LINK( this, CustomAnimationPane, implControlHdl ) );
221*cdf0e10cSrcweir 	mpPBPropertyMore->SetClickHdl( LINK( this, CustomAnimationPane, implControlHdl ) );
222*cdf0e10cSrcweir 	mpPBMoveUp->SetClickHdl( LINK( this, CustomAnimationPane, implControlHdl ) );
223*cdf0e10cSrcweir 	mpPBMoveDown->SetClickHdl( LINK( this, CustomAnimationPane, implControlHdl ) );
224*cdf0e10cSrcweir 	mpPBPlay->SetClickHdl( LINK( this, CustomAnimationPane, implControlHdl ) );
225*cdf0e10cSrcweir 	mpPBSlideShow->SetClickHdl( LINK( this, CustomAnimationPane, implControlHdl ) );
226*cdf0e10cSrcweir 	mpCBAutoPreview->SetClickHdl( LINK( this, CustomAnimationPane, implControlHdl ) );
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 	maStrModify = mpFLEffect->GetText();
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 	// resize controls according to current size
231*cdf0e10cSrcweir 	updateLayout();
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 	// get current controller and initialize listeners
234*cdf0e10cSrcweir 	try
235*cdf0e10cSrcweir 	{
236*cdf0e10cSrcweir 		mxView = Reference< XDrawView >::query(mrBase.GetController());
237*cdf0e10cSrcweir 		addListener();
238*cdf0e10cSrcweir 	}
239*cdf0e10cSrcweir 	catch( Exception& e )
240*cdf0e10cSrcweir 	{
241*cdf0e10cSrcweir 		(void)e;
242*cdf0e10cSrcweir 		DBG_ERROR( "sd::CustomAnimationPane::CustomAnimationPane(), Exception cought!" );
243*cdf0e10cSrcweir 	}
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir 	// get current page and update custom animation list
246*cdf0e10cSrcweir 	onChangeCurrentPage();
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir     // Wait a short time before the presets list is created.  This gives the
249*cdf0e10cSrcweir     // system time to paint the control.
250*cdf0e10cSrcweir     maLateInitTimer.SetTimeout(100);
251*cdf0e10cSrcweir     maLateInitTimer.SetTimeoutHdl(LINK(this, CustomAnimationPane, lateInitCallback));
252*cdf0e10cSrcweir     maLateInitTimer.Start();
253*cdf0e10cSrcweir }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir CustomAnimationPane::~CustomAnimationPane()
256*cdf0e10cSrcweir {
257*cdf0e10cSrcweir     maLateInitTimer.Stop();
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 	removeListener();
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 	MotionPathTagVector aTags;
262*cdf0e10cSrcweir 	aTags.swap( maMotionPathTags );
263*cdf0e10cSrcweir 	MotionPathTagVector::iterator aIter;
264*cdf0e10cSrcweir 	for( aIter = aTags.begin(); aIter != aTags.end(); aIter++ )
265*cdf0e10cSrcweir 		(*aIter)->Dispose();
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir 	delete mpFLModify;
268*cdf0e10cSrcweir 	delete mpPBAddEffect;
269*cdf0e10cSrcweir 	delete mpPBChangeEffect;
270*cdf0e10cSrcweir 	delete mpPBRemoveEffect;
271*cdf0e10cSrcweir 	delete mpFLEffect;
272*cdf0e10cSrcweir 	delete mpFTStart;
273*cdf0e10cSrcweir 	delete mpLBStart;
274*cdf0e10cSrcweir 	delete mpFTProperty;
275*cdf0e10cSrcweir 	delete mpLBProperty;
276*cdf0e10cSrcweir 	delete mpPBPropertyMore;
277*cdf0e10cSrcweir 	delete mpFTSpeed;
278*cdf0e10cSrcweir 	delete mpCBSpeed;
279*cdf0e10cSrcweir 	delete mpCustomAnimationList;
280*cdf0e10cSrcweir 	delete mpFTChangeOrder;
281*cdf0e10cSrcweir 	delete mpPBMoveUp;
282*cdf0e10cSrcweir 	delete mpPBMoveDown;
283*cdf0e10cSrcweir 	delete mpFLSeperator1;
284*cdf0e10cSrcweir 	delete mpPBPlay;
285*cdf0e10cSrcweir 	delete mpPBSlideShow;
286*cdf0e10cSrcweir 	delete mpFLSeperator2;
287*cdf0e10cSrcweir 	delete mpCBAutoPreview;
288*cdf0e10cSrcweir }
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir void CustomAnimationPane::addUndo()
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir 	::svl::IUndoManager* pManager = mrBase.GetDocShell()->GetUndoManager();
293*cdf0e10cSrcweir 	if( pManager )
294*cdf0e10cSrcweir 	{
295*cdf0e10cSrcweir 		SdPage* pPage = SdPage::getImplementation( mxCurrentPage );
296*cdf0e10cSrcweir 		if( pPage )
297*cdf0e10cSrcweir 			pManager->AddUndoAction( new UndoAnimation( mrBase.GetDocShell()->GetDoc(), pPage ) );
298*cdf0e10cSrcweir 	}
299*cdf0e10cSrcweir }
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir void CustomAnimationPane::Resize()
302*cdf0e10cSrcweir {
303*cdf0e10cSrcweir 	updateLayout();
304*cdf0e10cSrcweir }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir void CustomAnimationPane::StateChanged( StateChangedType nStateChange )
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir 	Control::StateChanged( nStateChange );
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 	if( nStateChange == STATE_CHANGE_VISIBLE )
311*cdf0e10cSrcweir 		updateMotionPathTags();
312*cdf0e10cSrcweir }
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir void CustomAnimationPane::KeyInput( const KeyEvent& rKEvt )
315*cdf0e10cSrcweir {
316*cdf0e10cSrcweir 	if( mpCustomAnimationList )
317*cdf0e10cSrcweir 		mpCustomAnimationList->KeyInput( rKEvt );
318*cdf0e10cSrcweir }
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir void CustomAnimationPane::addListener()
321*cdf0e10cSrcweir {
322*cdf0e10cSrcweir 	Link aLink( LINK(this,CustomAnimationPane,EventMultiplexerListener) );
323*cdf0e10cSrcweir     mrBase.GetEventMultiplexer()->AddEventListener (
324*cdf0e10cSrcweir         aLink,
325*cdf0e10cSrcweir         tools::EventMultiplexerEvent::EID_EDIT_VIEW_SELECTION
326*cdf0e10cSrcweir         | tools::EventMultiplexerEvent::EID_CURRENT_PAGE
327*cdf0e10cSrcweir         | tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED
328*cdf0e10cSrcweir         | tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
329*cdf0e10cSrcweir         | tools::EventMultiplexerEvent::EID_DISPOSING
330*cdf0e10cSrcweir         | tools::EventMultiplexerEvent::EID_END_TEXT_EDIT);
331*cdf0e10cSrcweir }
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir void CustomAnimationPane::removeListener()
334*cdf0e10cSrcweir {
335*cdf0e10cSrcweir 	Link aLink( LINK(this,CustomAnimationPane,EventMultiplexerListener) );
336*cdf0e10cSrcweir     mrBase.GetEventMultiplexer()->RemoveEventListener( aLink );
337*cdf0e10cSrcweir }
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir IMPL_LINK(CustomAnimationPane,EventMultiplexerListener,
340*cdf0e10cSrcweir     tools::EventMultiplexerEvent*,pEvent)
341*cdf0e10cSrcweir {
342*cdf0e10cSrcweir     switch (pEvent->meEventId)
343*cdf0e10cSrcweir     {
344*cdf0e10cSrcweir         case tools::EventMultiplexerEvent::EID_EDIT_VIEW_SELECTION:
345*cdf0e10cSrcweir             onSelectionChanged();
346*cdf0e10cSrcweir             break;
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir         case tools::EventMultiplexerEvent::EID_CURRENT_PAGE:
349*cdf0e10cSrcweir             onChangeCurrentPage();
350*cdf0e10cSrcweir             break;
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir         case tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED:
353*cdf0e10cSrcweir             // At this moment the controller may not yet been set at model
354*cdf0e10cSrcweir             // or ViewShellBase.  Take it from the view shell passed with
355*cdf0e10cSrcweir             // the event.
356*cdf0e10cSrcweir             if (mrBase.GetMainViewShell() != NULL)
357*cdf0e10cSrcweir             {
358*cdf0e10cSrcweir 				if( mrBase.GetMainViewShell()->GetShellType() == ViewShell::ST_IMPRESS )
359*cdf0e10cSrcweir 				{
360*cdf0e10cSrcweir 					mxView = Reference<XDrawView>::query(mrBase.GetDrawController());
361*cdf0e10cSrcweir 	                onSelectionChanged();
362*cdf0e10cSrcweir 		            onChangeCurrentPage();
363*cdf0e10cSrcweir 					break;
364*cdf0e10cSrcweir 				}
365*cdf0e10cSrcweir             }
366*cdf0e10cSrcweir 		// fall through intended
367*cdf0e10cSrcweir         case tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED:
368*cdf0e10cSrcweir             mxView = 0;
369*cdf0e10cSrcweir 			mxCurrentPage = 0;
370*cdf0e10cSrcweir 			updateControls();
371*cdf0e10cSrcweir             break;
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir         case tools::EventMultiplexerEvent::EID_DISPOSING:
374*cdf0e10cSrcweir             mxView = Reference<XDrawView>();
375*cdf0e10cSrcweir             onSelectionChanged();
376*cdf0e10cSrcweir             onChangeCurrentPage();
377*cdf0e10cSrcweir             break;
378*cdf0e10cSrcweir 		case tools::EventMultiplexerEvent::EID_END_TEXT_EDIT:
379*cdf0e10cSrcweir 			if( mpMainSequence.get() && pEvent->mpUserData )
380*cdf0e10cSrcweir 				mpCustomAnimationList->update( mpMainSequence );
381*cdf0e10cSrcweir 			break;
382*cdf0e10cSrcweir     }
383*cdf0e10cSrcweir     return 0;
384*cdf0e10cSrcweir }
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir void CustomAnimationPane::updateLayout()
388*cdf0e10cSrcweir {
389*cdf0e10cSrcweir 	Size aPaneSize( GetSizePixel() );
390*cdf0e10cSrcweir 	if( aPaneSize.Width() < maMinSize.Width() )
391*cdf0e10cSrcweir 		aPaneSize.Width() = maMinSize.Width();
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir 	if( aPaneSize.Height() < maMinSize.Height() )
394*cdf0e10cSrcweir 		aPaneSize.Height() = maMinSize.Height();
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir 	Point aOffset( LogicToPixel( Point(3,3), MAP_APPFONT ) );
397*cdf0e10cSrcweir 	Point aCursor( aOffset );
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir 	// place the modify fixed line
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 	// place the "modify effect" fixed line
402*cdf0e10cSrcweir 	Size aSize( mpFLModify->GetSizePixel() );
403*cdf0e10cSrcweir 	aSize.Width() = aPaneSize.Width() - 2 * aOffset.X();
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir 	mpFLModify->SetPosSizePixel( aCursor, aSize );
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir 	aCursor.Y() += aSize.Height() + aOffset.Y();
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir 	const int nButtonExtraWidth = 4 * aOffset.X();
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir 	// the "add effect" button is placed top-left
412*cdf0e10cSrcweir     Size aCtrlSize( mpPBAddEffect->GetSizePixel() );
413*cdf0e10cSrcweir     aCtrlSize.setWidth( mpPBAddEffect->CalcMinimumSize( aSize.Width() ).getWidth() + nButtonExtraWidth );
414*cdf0e10cSrcweir     mpPBAddEffect->SetPosSizePixel( aCursor, aCtrlSize );
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir 	aCursor.X() += aOffset.X() + aCtrlSize.Width();
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir 	// place the "change effect" button
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir 	// if the "change" button does not fit right of the "add effect", put it on the next line
421*cdf0e10cSrcweir     aCtrlSize = mpPBChangeEffect->GetSizePixel();
422*cdf0e10cSrcweir     aCtrlSize.setWidth( mpPBChangeEffect->CalcMinimumSize( aSize.Width() ).getWidth() + nButtonExtraWidth );
423*cdf0e10cSrcweir 	if( ( aCursor.X() + aCtrlSize.Width() + aOffset.X() ) > aPaneSize.Width() )
424*cdf0e10cSrcweir 	{
425*cdf0e10cSrcweir 		aCursor.X() = aOffset.X();
426*cdf0e10cSrcweir 		aCursor.Y() += aCtrlSize.Height() + aOffset.Y();
427*cdf0e10cSrcweir 	}
428*cdf0e10cSrcweir 	mpPBChangeEffect->SetPosSizePixel( aCursor, aCtrlSize );
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir 	aCursor.X() += aOffset.X() + aCtrlSize.Width();
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir 	// place the "remove effect" button
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir 	// if the "remove" button does not fit right of the "add effect", put it on the next line
435*cdf0e10cSrcweir     aCtrlSize = mpPBRemoveEffect->GetSizePixel();
436*cdf0e10cSrcweir     aCtrlSize.setWidth( mpPBRemoveEffect->CalcMinimumSize( aSize.Width() ).getWidth() + nButtonExtraWidth );
437*cdf0e10cSrcweir 	if( ( aCursor.X() + aCtrlSize.Width() + aOffset.X() ) > aPaneSize.Width() )
438*cdf0e10cSrcweir 	{
439*cdf0e10cSrcweir 		aCursor.X() = aOffset.X();
440*cdf0e10cSrcweir 		aCursor.Y() += aCtrlSize.Height() + aOffset.Y();
441*cdf0e10cSrcweir 	}
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir 	mpPBRemoveEffect->SetPosSizePixel( aCursor, aCtrlSize );
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir 	aCursor.X() = aOffset.X();
446*cdf0e10cSrcweir 	aCursor.Y() += aCtrlSize.Height() + 2 * aOffset.Y();
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir 	// place the "modify effect" fixed line
449*cdf0e10cSrcweir 	aSize = mpFLEffect->GetSizePixel();
450*cdf0e10cSrcweir 	aSize.Width() = aPaneSize.Width() - 2 * aOffset.X();
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir 	mpFLEffect->SetPosSizePixel( aCursor, aSize );
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 	aCursor.Y() += aSize.Height() + aOffset.Y();
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir 	// ---------------------------------------------------------------------------
457*cdf0e10cSrcweir 	// place the properties controls
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir 	// calc minimum width for fixedtext
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir 	Size aFixedTextSize( mpFTStart->CalcMinimumSize() );
462*cdf0e10cSrcweir 	long nWidth = aFixedTextSize.Width();
463*cdf0e10cSrcweir     aFixedTextSize = mpFTProperty->CalcMinimumSize();
464*cdf0e10cSrcweir 	nWidth = std::max( nWidth, aFixedTextSize.Width() );
465*cdf0e10cSrcweir     aFixedTextSize = mpFTSpeed->CalcMinimumSize();
466*cdf0e10cSrcweir 	aFixedTextSize.Width() = std::max( nWidth, aFixedTextSize.Width() ) + aOffset.X();
467*cdf0e10cSrcweir 	mpFTStart->SetSizePixel(aFixedTextSize);
468*cdf0e10cSrcweir 	mpFTProperty->SetSizePixel(aFixedTextSize);
469*cdf0e10cSrcweir 	mpFTSpeed->SetSizePixel(aFixedTextSize);
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir 	aSize = mpPBPropertyMore->GetSizePixel();
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir 	// place the "start" fixed text
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir 	Point aFTPos( aCursor );
476*cdf0e10cSrcweir 	Point aLBPos( aCursor );
477*cdf0e10cSrcweir 	Size aListBoxSize( LogicToPixel( Size( 60, 12 ), MAP_APPFONT ) );
478*cdf0e10cSrcweir 	long nDeltaY = aListBoxSize.Height() + aOffset.Y();
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir 	// linebreak?
481*cdf0e10cSrcweir 	if( (aFixedTextSize.Width() + aListBoxSize.Width() + aSize.Width() + 4 * aOffset.X()) > aPaneSize.Width() )
482*cdf0e10cSrcweir 	{
483*cdf0e10cSrcweir 		// y position for list box is below fixed text
484*cdf0e10cSrcweir 		aLBPos.Y() += aFixedTextSize.Height() + aOffset.Y();
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir 		// height of fixed text + list box + something = 2 * list box
487*cdf0e10cSrcweir 		nDeltaY = aListBoxSize.Height() +  aFixedTextSize.Height() + 2*aOffset.Y();
488*cdf0e10cSrcweir 	}
489*cdf0e10cSrcweir 	else
490*cdf0e10cSrcweir 	{
491*cdf0e10cSrcweir 		// x position for list box is right of fixed text
492*cdf0e10cSrcweir 		aLBPos.X() += aFixedTextSize.Width() + aOffset.X();
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir 		if( aListBoxSize.Height() > aFixedTextSize.Height() )
495*cdf0e10cSrcweir 			aFTPos.Y() = aLBPos.Y() + ((aListBoxSize.Height() - aFixedTextSize.Height()) >> 1);
496*cdf0e10cSrcweir 		else
497*cdf0e10cSrcweir 			aLBPos.Y() = aFTPos.Y() + ((aFixedTextSize.Height() - aListBoxSize.Height()) >> 1);
498*cdf0e10cSrcweir 	}
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 	// width of the listbox is from its left side until end of pane
501*cdf0e10cSrcweir 	aListBoxSize.Width() = aPaneSize.Width() - aLBPos.X() - aSize.Width() - 2 * aOffset.X();
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir 	mpFTStart->SetPosPixel( aFTPos );
504*cdf0e10cSrcweir 	mpLBStart->SetPosSizePixel( aLBPos, aListBoxSize );
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir 	aFTPos.Y() += nDeltaY; aLBPos.Y() += nDeltaY;
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir 	mpFTProperty->SetPosPixel( aFTPos );
509*cdf0e10cSrcweir 	mpLBProperty->SetPosSizePixel( aLBPos, aListBoxSize );
510*cdf0e10cSrcweir 	mpLBProperty->Resize();
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir 	Point aMorePos( aLBPos );
513*cdf0e10cSrcweir 	aMorePos.X() += aListBoxSize.Width() + aOffset.X();
514*cdf0e10cSrcweir 	mpPBPropertyMore->SetPosPixel( aMorePos );
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir 	aFTPos.Y() += nDeltaY; aLBPos.Y() += nDeltaY;
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir 	mpFTSpeed->SetPosPixel( aFTPos );
519*cdf0e10cSrcweir 	mpCBSpeed->SetPosSizePixel( aLBPos, aListBoxSize );
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir 	aFTPos.Y() += nDeltaY + aOffset.Y();
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir 	Point aListPos( aFTPos );
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir 	// positionate the buttons on the bottom
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir 	// place the auto preview checkbox
528*cdf0e10cSrcweir 	aCursor = Point( aOffset.X(), aPaneSize.Height() - mpCBAutoPreview->GetSizePixel().Height() - aOffset.Y() );
529*cdf0e10cSrcweir 	mpCBAutoPreview->SetPosPixel( aCursor );
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir 	// place the seperator 2 fixed line
532*cdf0e10cSrcweir 	aCursor.Y() -= /* aOffset.Y() + */ mpFLSeperator2->GetSizePixel().Height();
533*cdf0e10cSrcweir 	aSize = mpFLSeperator2->GetSizePixel();
534*cdf0e10cSrcweir 	aSize.Width() = aPaneSize.Width() - 2 * aOffset.X();
535*cdf0e10cSrcweir 	mpFLSeperator2->SetPosSizePixel( aCursor, aSize );
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir 	// next, layout and place the play and slide show buttons
538*cdf0e10cSrcweir     aCtrlSize = mpPBSlideShow->GetSizePixel();
539*cdf0e10cSrcweir     aCtrlSize.setWidth( mpPBSlideShow->CalcMinimumSize( aSize.Width() ).getWidth() + nButtonExtraWidth );
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir 	Size aPlaySize( mpPBPlay->GetSizePixel() );
542*cdf0e10cSrcweir     aPlaySize.setWidth( mpPBPlay->CalcMinimumSize( aSize.Width() ).getWidth() + nButtonExtraWidth );
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir 	aCursor.Y() -= aCtrlSize.Height() /* + aOffset.Y() */;
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir 	// do we need two lines for the buttons?
547*cdf0e10cSrcweir 	int aTestWidth = aCursor.X() + mpPBPlay->GetSizePixel().Width() + 2 * aOffset.X() + mpPBSlideShow->GetSizePixel().Width();
548*cdf0e10cSrcweir 	if( aTestWidth > aPaneSize.Width() )
549*cdf0e10cSrcweir 	{
550*cdf0e10cSrcweir 		mpPBSlideShow->SetPosSizePixel( aCursor, aCtrlSize );
551*cdf0e10cSrcweir 		aCursor.Y() -= aCtrlSize.Height() + aOffset.Y();
552*cdf0e10cSrcweir 		mpPBPlay->SetPosSizePixel( aCursor, aPlaySize );
553*cdf0e10cSrcweir 	}
554*cdf0e10cSrcweir 	else
555*cdf0e10cSrcweir 	{
556*cdf0e10cSrcweir 		mpPBPlay->SetPosSizePixel( aCursor, aPlaySize );
557*cdf0e10cSrcweir 		aCursor.X() += aPlaySize.Width() + aOffset.X();
558*cdf0e10cSrcweir 		mpPBSlideShow->SetPosSizePixel( aCursor, aCtrlSize );
559*cdf0e10cSrcweir 	}
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir 	// place the seperator 1 fixed line
562*cdf0e10cSrcweir 	aCursor.X() = aOffset.X();
563*cdf0e10cSrcweir 	aCursor.Y() -= /* aOffset.Y() + */ mpFLSeperator1->GetSizePixel().Height();
564*cdf0e10cSrcweir 	aSize = mpFLSeperator1->GetSizePixel();
565*cdf0e10cSrcweir 	aSize.Width() = aPaneSize.Width() - 2 * aOffset.X();
566*cdf0e10cSrcweir 	mpFLSeperator1->SetPosSizePixel( aCursor, aSize );
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir 	// place the move down button
569*cdf0e10cSrcweir 	aSize = mpPBMoveDown->GetSizePixel();
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir 	aCursor.X() = aPaneSize.Width() - aOffset.X() - aSize.Width();
572*cdf0e10cSrcweir 	aCursor.Y() -= aOffset.Y() + aSize.Height();
573*cdf0e10cSrcweir 	mpPBMoveDown->SetPosPixel( aCursor );
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir 	aCursor.X() -= aOffset.X() + aSize.Width();
576*cdf0e10cSrcweir 	mpPBMoveUp->SetPosPixel( aCursor );
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir     // Place the change order label.
579*cdf0e10cSrcweir     // Its width has to be calculated dynamically so that is can be
580*cdf0e10cSrcweir     // displayed flush right without having too much space to the buttons
581*cdf0e10cSrcweir     // with some languages or truncated text with others.
582*cdf0e10cSrcweir 	mpFTChangeOrder->SetSizePixel(mpFTChangeOrder->CalcMinimumSize());
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir 	aCursor.X() -= aOffset.X() + mpFTChangeOrder->GetSizePixel().Width();
585*cdf0e10cSrcweir     aCursor.Y() += (aSize.Height() - mpFTChangeOrder->GetSizePixel().Height()) >> 1;
586*cdf0e10cSrcweir     mpFTChangeOrder->SetPosPixel( aCursor );
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir 	// positionate the custom animation list control
589*cdf0e10cSrcweir 	Size aCustomAnimationListSize( aPaneSize.Width() - aListPos.X() - aOffset.X(), aCursor.Y() - aListPos.Y() - 2 * aOffset.Y() );
590*cdf0e10cSrcweir 	mpCustomAnimationList->SetPosSizePixel( aListPos, aCustomAnimationListSize );
591*cdf0e10cSrcweir }
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir static sal_Int32 getPropertyType( const OUString& rProperty )
594*cdf0e10cSrcweir {
595*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Direction") ) )
596*cdf0e10cSrcweir 		return nPropertyTypeDirection;
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Spokes") ) )
599*cdf0e10cSrcweir 		return nPropertyTypeSpokes;
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Zoom") ) )
602*cdf0e10cSrcweir 		return nPropertyTypeZoom;
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Accelerate") ) )
605*cdf0e10cSrcweir 		return nPropertyTypeAccelerate;
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Decelerate") ) )
608*cdf0e10cSrcweir 		return nPropertyTypeDecelerate;
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Color1") ) )
611*cdf0e10cSrcweir 		return nPropertyTypeFirstColor;
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Color2") ) )
614*cdf0e10cSrcweir 		return nPropertyTypeSecondColor;
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("FillColor") ) )
617*cdf0e10cSrcweir 		return nPropertyTypeFillColor;
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ColorStyle") ) )
620*cdf0e10cSrcweir 		return nPropertyTypeColorStyle;
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AutoReverse") ) )
623*cdf0e10cSrcweir 		return nPropertyTypeAutoReverse;
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("FontStyle") ) )
626*cdf0e10cSrcweir 		return nPropertyTypeFont;
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CharColor") ) )
629*cdf0e10cSrcweir 		return nPropertyTypeCharColor;
630*cdf0e10cSrcweir 
631*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CharHeight") ) )
632*cdf0e10cSrcweir 		return nPropertyTypeCharHeight;
633*cdf0e10cSrcweir 
634*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CharDecoration") ) )
635*cdf0e10cSrcweir 		return nPropertyTypeCharDecoration;
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("LineColor") ) )
638*cdf0e10cSrcweir 		return nPropertyTypeLineColor;
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Rotate") ) )
641*cdf0e10cSrcweir 		return nPropertyTypeRotate;
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Transparency") ) )
644*cdf0e10cSrcweir 		return nPropertyTypeTransparency;
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Color") ) )
647*cdf0e10cSrcweir 		return nPropertyTypeColor;
648*cdf0e10cSrcweir 
649*cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Scale") ) )
650*cdf0e10cSrcweir 		return nPropertyTypeScale;
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir 	return nPropertyTypeNone;
653*cdf0e10cSrcweir }
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir OUString getPropertyName( sal_Int32 nPropertyType )
656*cdf0e10cSrcweir {
657*cdf0e10cSrcweir 	switch( nPropertyType )
658*cdf0e10cSrcweir 	{
659*cdf0e10cSrcweir 	case nPropertyTypeDirection:
660*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_DIRECTION_PROPERTY ) ) );
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir 	case nPropertyTypeSpokes:
663*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_SPOKES_PROPERTY ) ) );
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir 	case nPropertyTypeFirstColor:
666*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_FIRST_COLOR_PROPERTY ) ) );
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir 	case nPropertyTypeSecondColor:
669*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_SECOND_COLOR_PROPERTY ) ) );
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir 	case nPropertyTypeZoom:
672*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_ZOOM_PROPERTY ) ) );
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir 	case nPropertyTypeFillColor:
675*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_FILL_COLOR_PROPERTY ) ) );
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir 	case nPropertyTypeColorStyle:
678*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_STYLE_PROPERTY ) ) );
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir 	case nPropertyTypeFont:
681*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_FONT_PROPERTY ) ) );
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir 	case nPropertyTypeCharHeight:
684*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_SIZE_PROPERTY ) ) );
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir 	case nPropertyTypeCharColor:
687*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_FONT_COLOR_PROPERTY ) ) );
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir 	case nPropertyTypeCharHeightStyle:
690*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_FONT_SIZE_STYLE_PROPERTY ) ) );
691*cdf0e10cSrcweir 
692*cdf0e10cSrcweir 	case nPropertyTypeCharDecoration:
693*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_FONT_STYLE_PROPERTY ) ) );
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir 	case nPropertyTypeLineColor:
696*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_LINE_COLOR_PROPERTY ) ) );
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir 	case nPropertyTypeRotate:
699*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_AMOUNT_PROPERTY ) ) );
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir 	case nPropertyTypeColor:
702*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_COLOR_PROPERTY ) ) );
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir 	case nPropertyTypeTransparency:
705*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_AMOUNT_PROPERTY ) ) );
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir 	case nPropertyTypeScale:
708*cdf0e10cSrcweir 		return OUString( String( SdResId( STR_CUSTOMANIMATION_SCALE_PROPERTY ) ) );
709*cdf0e10cSrcweir 	}
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir 	OUString aStr;
712*cdf0e10cSrcweir 	return aStr;
713*cdf0e10cSrcweir }
714*cdf0e10cSrcweir 
715*cdf0e10cSrcweir void CustomAnimationPane::updateControls()
716*cdf0e10cSrcweir {
717*cdf0e10cSrcweir 	mpFLModify->Enable( mxView.is() );
718*cdf0e10cSrcweir 	mpFTSpeed->Enable( mxView.is() );
719*cdf0e10cSrcweir 	mpCBSpeed->Enable( mxView.is() );
720*cdf0e10cSrcweir 	mpCustomAnimationList->Enable( mxView.is() );
721*cdf0e10cSrcweir 	mpFTChangeOrder->Enable( mxView.is() );
722*cdf0e10cSrcweir 	mpPBMoveUp->Enable( mxView.is() );
723*cdf0e10cSrcweir 	mpPBMoveDown->Enable( mxView.is() );
724*cdf0e10cSrcweir 	mpFLSeperator1->Enable( mxView.is() );
725*cdf0e10cSrcweir 	mpPBPlay->Enable( mxView.is() );
726*cdf0e10cSrcweir 	mpPBSlideShow->Enable( mxView.is() );
727*cdf0e10cSrcweir 	mpFLSeperator2->Enable( mxView.is() );
728*cdf0e10cSrcweir 	mpCBAutoPreview->Enable( mxView.is() );
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir 	if( !mxView.is() )
731*cdf0e10cSrcweir 	{
732*cdf0e10cSrcweir 		mpPBAddEffect->Enable( sal_False );
733*cdf0e10cSrcweir 		mpPBChangeEffect->Enable( sal_False );
734*cdf0e10cSrcweir 		mpPBRemoveEffect->Enable( sal_False );
735*cdf0e10cSrcweir 		mpFLEffect->Enable( sal_False );
736*cdf0e10cSrcweir 		mpFTStart->Enable( sal_False );
737*cdf0e10cSrcweir 		mpLBStart->Enable( sal_False );
738*cdf0e10cSrcweir 		mpPBPropertyMore->Enable( sal_False );
739*cdf0e10cSrcweir 		mpLBProperty->Enable( sal_False );
740*cdf0e10cSrcweir 		mpFTProperty->Enable( sal_False );
741*cdf0e10cSrcweir 		mpCustomAnimationList->clear();
742*cdf0e10cSrcweir 		return;
743*cdf0e10cSrcweir 	}
744*cdf0e10cSrcweir 
745*cdf0e10cSrcweir 	const int nSelectionCount = maListSelection.size();
746*cdf0e10cSrcweir 
747*cdf0e10cSrcweir 	mpPBAddEffect->Enable( maViewSelection.hasValue() );
748*cdf0e10cSrcweir 	mpPBChangeEffect->Enable( nSelectionCount);
749*cdf0e10cSrcweir 	mpPBRemoveEffect->Enable(nSelectionCount);
750*cdf0e10cSrcweir 
751*cdf0e10cSrcweir 	mpFLEffect->Enable(nSelectionCount > 0);
752*cdf0e10cSrcweir 	mpFTStart->Enable(nSelectionCount > 0);
753*cdf0e10cSrcweir 	mpLBStart->Enable(nSelectionCount > 0);
754*cdf0e10cSrcweir 	mpPBPropertyMore->Enable(nSelectionCount > 0);
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir //	mpPBPlay->Enable(nSelectionCount > 0);
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir 	mpFTProperty->SetText( maStrProperty );
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir 	mnPropertyType = nPropertyTypeNone;
761*cdf0e10cSrcweir 
762*cdf0e10cSrcweir 	if( nSelectionCount == 1 )
763*cdf0e10cSrcweir 	{
764*cdf0e10cSrcweir 		CustomAnimationEffectPtr pEffect = maListSelection.front();
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir 		OUString aUIName( getPresets().getUINameForPresetId( pEffect->getPresetId() ) );
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir 		OUString aTemp( maStrModify );
769*cdf0e10cSrcweir 
770*cdf0e10cSrcweir 		if( aUIName.getLength() )
771*cdf0e10cSrcweir 		{
772*cdf0e10cSrcweir 			aTemp += OUString( (sal_Unicode)' ' );
773*cdf0e10cSrcweir 			aTemp += aUIName;
774*cdf0e10cSrcweir 		}
775*cdf0e10cSrcweir 		mpFLEffect->SetText( aTemp );
776*cdf0e10cSrcweir 
777*cdf0e10cSrcweir 		CustomAnimationPresetPtr pDescriptor = getPresets().getEffectDescriptor( pEffect->getPresetId() );
778*cdf0e10cSrcweir 		if( pDescriptor.get() )
779*cdf0e10cSrcweir 		{
780*cdf0e10cSrcweir 			PropertySubControl* pSubControl = NULL;
781*cdf0e10cSrcweir 
782*cdf0e10cSrcweir 			Any aValue;
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir 			UStringList aProperties( pDescriptor->getProperties() );
785*cdf0e10cSrcweir 			if( aProperties.size() >= 1 )
786*cdf0e10cSrcweir 			{
787*cdf0e10cSrcweir 				OUString aProperty( aProperties.front() );
788*cdf0e10cSrcweir 
789*cdf0e10cSrcweir 				mnPropertyType = getPropertyType( aProperties.front() );
790*cdf0e10cSrcweir 
791*cdf0e10cSrcweir 				mpFTProperty->SetText( getPropertyName( mnPropertyType )  );
792*cdf0e10cSrcweir 
793*cdf0e10cSrcweir 				aValue = getProperty1Value( mnPropertyType, pEffect );
794*cdf0e10cSrcweir 			}
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir 			if( aValue.hasValue() )
797*cdf0e10cSrcweir 			{
798*cdf0e10cSrcweir 				pSubControl = mpLBProperty->getSubControl();
799*cdf0e10cSrcweir 				if( !pSubControl || (pSubControl->getControlType() != mnPropertyType) )
800*cdf0e10cSrcweir 				{
801*cdf0e10cSrcweir 					pSubControl = PropertySubControl::create( mnPropertyType, this, aValue, pEffect->getPresetId(), LINK( this, CustomAnimationPane, implPropertyHdl ) );
802*cdf0e10cSrcweir 					mpLBProperty->setSubControl( pSubControl );
803*cdf0e10cSrcweir 				}
804*cdf0e10cSrcweir 				else
805*cdf0e10cSrcweir 				{
806*cdf0e10cSrcweir 					pSubControl->setValue( aValue, pEffect->getPresetId() );
807*cdf0e10cSrcweir 				}
808*cdf0e10cSrcweir 			}
809*cdf0e10cSrcweir 			else
810*cdf0e10cSrcweir 			{
811*cdf0e10cSrcweir 				mpLBProperty->setSubControl( 0 );
812*cdf0e10cSrcweir 			}
813*cdf0e10cSrcweir 
814*cdf0e10cSrcweir 			bool bEnable = (pSubControl != 0) && (pSubControl->getControl()->IsEnabled());
815*cdf0e10cSrcweir 			mpLBProperty->Enable( bEnable );
816*cdf0e10cSrcweir 			mpFTProperty->Enable( bEnable );
817*cdf0e10cSrcweir 		}
818*cdf0e10cSrcweir 		else
819*cdf0e10cSrcweir 		{
820*cdf0e10cSrcweir 			mpLBProperty->setSubControl( 0 );
821*cdf0e10cSrcweir 			mpFTProperty->Enable( sal_False );
822*cdf0e10cSrcweir 			mpLBProperty->Enable( sal_False );
823*cdf0e10cSrcweir 			mpPBPropertyMore->Enable( sal_False );
824*cdf0e10cSrcweir 		}
825*cdf0e10cSrcweir 
826*cdf0e10cSrcweir 		//
827*cdf0e10cSrcweir 		// ---
828*cdf0e10cSrcweir 		//
829*cdf0e10cSrcweir 		sal_uInt16 nPos = 0xffff;
830*cdf0e10cSrcweir 
831*cdf0e10cSrcweir 		sal_Int16 nNodeType = pEffect->getNodeType();
832*cdf0e10cSrcweir 		switch( nNodeType )
833*cdf0e10cSrcweir 		{
834*cdf0e10cSrcweir 		case EffectNodeType::ON_CLICK:			nPos = 0; break;
835*cdf0e10cSrcweir 		case EffectNodeType::WITH_PREVIOUS:		nPos = 1; break;
836*cdf0e10cSrcweir 		case EffectNodeType::AFTER_PREVIOUS:	nPos = 2; break;
837*cdf0e10cSrcweir 		}
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir 		mpLBStart->SelectEntryPos( nPos );
840*cdf0e10cSrcweir 
841*cdf0e10cSrcweir 		double fDuration = pEffect->getDuration();
842*cdf0e10cSrcweir 		const bool bHasSpeed = fDuration > 0.001;
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir 		mpFTSpeed->Enable(bHasSpeed);
845*cdf0e10cSrcweir 		mpCBSpeed->Enable(bHasSpeed);
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir 		if( bHasSpeed )
848*cdf0e10cSrcweir 		{
849*cdf0e10cSrcweir 			if( fDuration == 5.0 )
850*cdf0e10cSrcweir 				nPos = 0;
851*cdf0e10cSrcweir 			else if( fDuration == 3.0 )
852*cdf0e10cSrcweir 				nPos = 1;
853*cdf0e10cSrcweir 			else if( fDuration == 2.0 )
854*cdf0e10cSrcweir 				nPos = 2;
855*cdf0e10cSrcweir 			else if( fDuration == 1.0 )
856*cdf0e10cSrcweir 				nPos = 3;
857*cdf0e10cSrcweir 			else if( fDuration == 0.5 )
858*cdf0e10cSrcweir 				nPos = 4;
859*cdf0e10cSrcweir 			else
860*cdf0e10cSrcweir 				nPos = 0xffff;
861*cdf0e10cSrcweir 
862*cdf0e10cSrcweir 			mpCBSpeed->SelectEntryPos( nPos );
863*cdf0e10cSrcweir 		}
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir 		mpPBPropertyMore->Enable( sal_True );
866*cdf0e10cSrcweir 
867*cdf0e10cSrcweir 		mpFTChangeOrder->Enable( sal_True );
868*cdf0e10cSrcweir 	}
869*cdf0e10cSrcweir 	else
870*cdf0e10cSrcweir 	{
871*cdf0e10cSrcweir 		mpLBProperty->setSubControl( 0 );
872*cdf0e10cSrcweir 		mpFTProperty->Enable( sal_False );
873*cdf0e10cSrcweir 		mpLBProperty->Enable( sal_False );
874*cdf0e10cSrcweir 		mpPBPropertyMore->Enable( sal_False );
875*cdf0e10cSrcweir 		mpFTSpeed->Enable(sal_False);
876*cdf0e10cSrcweir 		mpCBSpeed->Enable(sal_False);
877*cdf0e10cSrcweir 		mpFTChangeOrder->Enable( sal_False );
878*cdf0e10cSrcweir 		mpLBStart->SetNoSelection();
879*cdf0e10cSrcweir 		mpCBSpeed->SetNoSelection();
880*cdf0e10cSrcweir 		mpFLEffect->SetText( maStrModify );
881*cdf0e10cSrcweir 	}
882*cdf0e10cSrcweir 
883*cdf0e10cSrcweir 	bool bEnableUp = true;
884*cdf0e10cSrcweir 	bool bEnableDown = true;
885*cdf0e10cSrcweir 	if( nSelectionCount == 0 )
886*cdf0e10cSrcweir 	{
887*cdf0e10cSrcweir 		bEnableUp = false;
888*cdf0e10cSrcweir 		bEnableDown = false;
889*cdf0e10cSrcweir 	}
890*cdf0e10cSrcweir 	else
891*cdf0e10cSrcweir 	{
892*cdf0e10cSrcweir 		if( mpMainSequence->find( maListSelection.front() ) == mpMainSequence->getBegin() )
893*cdf0e10cSrcweir 			bEnableUp = false;
894*cdf0e10cSrcweir 
895*cdf0e10cSrcweir 		EffectSequence::iterator aIter( mpMainSequence->find( maListSelection.back() ) );
896*cdf0e10cSrcweir 		if( aIter == mpMainSequence->getEnd() )
897*cdf0e10cSrcweir 		{
898*cdf0e10cSrcweir 			bEnableDown = false;
899*cdf0e10cSrcweir 		}
900*cdf0e10cSrcweir 		else
901*cdf0e10cSrcweir 		{
902*cdf0e10cSrcweir 			do
903*cdf0e10cSrcweir 			{
904*cdf0e10cSrcweir 				aIter++;
905*cdf0e10cSrcweir 			}
906*cdf0e10cSrcweir 			while( (aIter != mpMainSequence->getEnd()) && !(mpCustomAnimationList->isExpanded((*aIter)) ) );
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir 			if( aIter == mpMainSequence->getEnd() )
909*cdf0e10cSrcweir 				bEnableDown = false;
910*cdf0e10cSrcweir 		}
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir 		if( bEnableUp || bEnableDown )
913*cdf0e10cSrcweir 		{
914*cdf0e10cSrcweir 			MainSequenceRebuildGuard aGuard( mpMainSequence );
915*cdf0e10cSrcweir 
916*cdf0e10cSrcweir 			EffectSequenceHelper* pSequence = 0;
917*cdf0e10cSrcweir 			EffectSequence::iterator aRebuildIter( maListSelection.begin() );
918*cdf0e10cSrcweir 			const EffectSequence::iterator aRebuildEnd( maListSelection.end() );
919*cdf0e10cSrcweir 			while( aRebuildIter != aRebuildEnd )
920*cdf0e10cSrcweir 			{
921*cdf0e10cSrcweir 				CustomAnimationEffectPtr pEffect = (*aRebuildIter++);
922*cdf0e10cSrcweir 
923*cdf0e10cSrcweir 				if( pEffect.get() )
924*cdf0e10cSrcweir 				{
925*cdf0e10cSrcweir 					if( pSequence == 0 )
926*cdf0e10cSrcweir 					{
927*cdf0e10cSrcweir 						pSequence = pEffect->getEffectSequence();
928*cdf0e10cSrcweir 					}
929*cdf0e10cSrcweir 					else
930*cdf0e10cSrcweir 					{
931*cdf0e10cSrcweir 						if( pSequence != pEffect->getEffectSequence() )
932*cdf0e10cSrcweir 						{
933*cdf0e10cSrcweir 							bEnableUp = false;
934*cdf0e10cSrcweir 							bEnableDown = false;
935*cdf0e10cSrcweir 							break;
936*cdf0e10cSrcweir 						}
937*cdf0e10cSrcweir 					}
938*cdf0e10cSrcweir 				}
939*cdf0e10cSrcweir 			}
940*cdf0e10cSrcweir 		}
941*cdf0e10cSrcweir 	}
942*cdf0e10cSrcweir 
943*cdf0e10cSrcweir 	mpPBMoveUp->Enable(bEnableUp);
944*cdf0e10cSrcweir 	mpPBMoveDown->Enable(bEnableDown);
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir 	SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
947*cdf0e10cSrcweir 	mpCBAutoPreview->Check( pOptions->IsPreviewChangedEffects() == sal_True );
948*cdf0e10cSrcweir 
949*cdf0e10cSrcweir 	updateMotionPathTags();
950*cdf0e10cSrcweir }
951*cdf0e10cSrcweir 
952*cdf0e10cSrcweir static bool updateMotionPathImpl( CustomAnimationPane& rPane, ::sd::View& rView,  EffectSequence::iterator aIter, EffectSequence::iterator aEnd, MotionPathTagVector& rOldTags, MotionPathTagVector& rNewTags )
953*cdf0e10cSrcweir {
954*cdf0e10cSrcweir 	bool bChanges = false;
955*cdf0e10cSrcweir 	while( aIter != aEnd )
956*cdf0e10cSrcweir 	{
957*cdf0e10cSrcweir 		CustomAnimationEffectPtr pEffect( (*aIter++) );
958*cdf0e10cSrcweir 		if( pEffect.get() && pEffect->getPresetClass() == ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH )
959*cdf0e10cSrcweir 		{
960*cdf0e10cSrcweir 			rtl::Reference< MotionPathTag > xMotionPathTag;
961*cdf0e10cSrcweir 			// first try to find if there is already a tag for this
962*cdf0e10cSrcweir 			MotionPathTagVector::iterator aMIter( rOldTags.begin() );
963*cdf0e10cSrcweir 			for( ; aMIter != rOldTags.end(); aMIter++ )
964*cdf0e10cSrcweir 			{
965*cdf0e10cSrcweir 				rtl::Reference< MotionPathTag > xTag( (*aMIter) );
966*cdf0e10cSrcweir 				if( xTag->getEffect() == pEffect )
967*cdf0e10cSrcweir 				{
968*cdf0e10cSrcweir 					if( !xTag->isDisposed() )
969*cdf0e10cSrcweir 					{
970*cdf0e10cSrcweir 						xMotionPathTag = xTag;
971*cdf0e10cSrcweir 						rOldTags.erase( aMIter );
972*cdf0e10cSrcweir 					}
973*cdf0e10cSrcweir 					break;
974*cdf0e10cSrcweir 				}
975*cdf0e10cSrcweir 			}
976*cdf0e10cSrcweir 
977*cdf0e10cSrcweir 			// if not found, create new one
978*cdf0e10cSrcweir 			if( !xMotionPathTag.is() )
979*cdf0e10cSrcweir 			{
980*cdf0e10cSrcweir 				xMotionPathTag.set( new MotionPathTag( rPane, rView, pEffect ) );
981*cdf0e10cSrcweir 				bChanges = true;
982*cdf0e10cSrcweir 			}
983*cdf0e10cSrcweir 
984*cdf0e10cSrcweir 			if( xMotionPathTag.is() )
985*cdf0e10cSrcweir 				rNewTags.push_back( xMotionPathTag );
986*cdf0e10cSrcweir 		}
987*cdf0e10cSrcweir 	}
988*cdf0e10cSrcweir 
989*cdf0e10cSrcweir 	return bChanges;
990*cdf0e10cSrcweir }
991*cdf0e10cSrcweir 
992*cdf0e10cSrcweir void CustomAnimationPane::updateMotionPathTags()
993*cdf0e10cSrcweir {
994*cdf0e10cSrcweir 	bool bChanges = false;
995*cdf0e10cSrcweir 
996*cdf0e10cSrcweir 	MotionPathTagVector aTags;
997*cdf0e10cSrcweir 	aTags.swap( maMotionPathTags );
998*cdf0e10cSrcweir 
999*cdf0e10cSrcweir 	::sd::View* pView = 0;
1000*cdf0e10cSrcweir 
1001*cdf0e10cSrcweir 	if( mxView.is() )
1002*cdf0e10cSrcweir 	{
1003*cdf0e10cSrcweir 		::boost::shared_ptr<ViewShell> xViewShell( mrBase.GetMainViewShell() );
1004*cdf0e10cSrcweir 		if( xViewShell.get() )
1005*cdf0e10cSrcweir 			pView = xViewShell->GetView();
1006*cdf0e10cSrcweir 	}
1007*cdf0e10cSrcweir 
1008*cdf0e10cSrcweir 	if( IsVisible() && mpMainSequence.get() && pView )
1009*cdf0e10cSrcweir 	{
1010*cdf0e10cSrcweir 		bChanges = updateMotionPathImpl( *this, *pView, mpMainSequence->getBegin(), mpMainSequence->getEnd(), aTags, maMotionPathTags );
1011*cdf0e10cSrcweir 
1012*cdf0e10cSrcweir 		const InteractiveSequenceList& rISL = mpMainSequence->getInteractiveSequenceList();
1013*cdf0e10cSrcweir 		InteractiveSequenceList::const_iterator aISI( rISL.begin() );
1014*cdf0e10cSrcweir 		while( aISI != rISL.end() )
1015*cdf0e10cSrcweir 		{
1016*cdf0e10cSrcweir 			InteractiveSequencePtr pIS( (*aISI++) );
1017*cdf0e10cSrcweir 			bChanges |= updateMotionPathImpl( *this, *pView, pIS->getBegin(), pIS->getEnd(), aTags, maMotionPathTags );
1018*cdf0e10cSrcweir 		}
1019*cdf0e10cSrcweir 	}
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir 	if( !aTags.empty() )
1022*cdf0e10cSrcweir 	{
1023*cdf0e10cSrcweir 		bChanges = true;
1024*cdf0e10cSrcweir 		MotionPathTagVector::iterator aIter( aTags.begin() );
1025*cdf0e10cSrcweir 		while( aIter != aTags.end() )
1026*cdf0e10cSrcweir 		{
1027*cdf0e10cSrcweir 			rtl::Reference< MotionPathTag > xTag( (*aIter++) );
1028*cdf0e10cSrcweir 			xTag->Dispose();
1029*cdf0e10cSrcweir 		}
1030*cdf0e10cSrcweir 	}
1031*cdf0e10cSrcweir 
1032*cdf0e10cSrcweir 	if( bChanges && pView )
1033*cdf0e10cSrcweir 		pView->updateHandles();
1034*cdf0e10cSrcweir }
1035*cdf0e10cSrcweir 
1036*cdf0e10cSrcweir void CustomAnimationPane::onSelectionChanged()
1037*cdf0e10cSrcweir {
1038*cdf0e10cSrcweir 	if( !maSelectionLock.isLocked() )
1039*cdf0e10cSrcweir 	{
1040*cdf0e10cSrcweir 		ScopeLockGuard aGuard( maSelectionLock );
1041*cdf0e10cSrcweir 
1042*cdf0e10cSrcweir 		if( mxView.is() ) try
1043*cdf0e10cSrcweir 		{
1044*cdf0e10cSrcweir 			Reference< XSelectionSupplier >  xSel( mxView, UNO_QUERY_THROW );
1045*cdf0e10cSrcweir 			if (xSel.is())
1046*cdf0e10cSrcweir 			{
1047*cdf0e10cSrcweir 				maViewSelection = xSel->getSelection();
1048*cdf0e10cSrcweir 				mpCustomAnimationList->onSelectionChanged( maViewSelection );
1049*cdf0e10cSrcweir 				updateControls();
1050*cdf0e10cSrcweir 			}
1051*cdf0e10cSrcweir 		}
1052*cdf0e10cSrcweir 		catch( Exception& )
1053*cdf0e10cSrcweir 		{
1054*cdf0e10cSrcweir 			DBG_ERROR( "sd::CustomAnimationPane::onSelectionChanged(), Exception catched!" );
1055*cdf0e10cSrcweir 		}
1056*cdf0e10cSrcweir 	}
1057*cdf0e10cSrcweir }
1058*cdf0e10cSrcweir 
1059*cdf0e10cSrcweir void CustomAnimationPane::onDoubleClick()
1060*cdf0e10cSrcweir {
1061*cdf0e10cSrcweir 	showOptions();
1062*cdf0e10cSrcweir }
1063*cdf0e10cSrcweir 
1064*cdf0e10cSrcweir void CustomAnimationPane::onContextMenu( sal_uInt16 nSelectedPopupEntry )
1065*cdf0e10cSrcweir {
1066*cdf0e10cSrcweir 	switch( nSelectedPopupEntry )
1067*cdf0e10cSrcweir 	{
1068*cdf0e10cSrcweir 	case CM_WITH_CLICK:		onChangeStart( EffectNodeType::ON_CLICK ); break;
1069*cdf0e10cSrcweir 	case CM_WITH_PREVIOUS:	onChangeStart( EffectNodeType::WITH_PREVIOUS  ); break;
1070*cdf0e10cSrcweir 	case CM_AFTER_PREVIOUS:	onChangeStart( EffectNodeType::AFTER_PREVIOUS ); break;
1071*cdf0e10cSrcweir 	case CM_OPTIONS:		showOptions(); break;
1072*cdf0e10cSrcweir 	case CM_DURATION:		showOptions(RID_TP_CUSTOMANIMATION_DURATION); break;
1073*cdf0e10cSrcweir 	case CM_REMOVE:			onRemove(); break;
1074*cdf0e10cSrcweir 	case CM_CREATE:			if( maViewSelection.hasValue() ) onChange( true ); break;
1075*cdf0e10cSrcweir 	}
1076*cdf0e10cSrcweir 
1077*cdf0e10cSrcweir 	updateControls();
1078*cdf0e10cSrcweir }
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir void addValue( STLPropertySet* pSet, sal_Int32 nHandle, const Any& rValue )
1081*cdf0e10cSrcweir {
1082*cdf0e10cSrcweir 	switch( pSet->getPropertyState( nHandle ) )
1083*cdf0e10cSrcweir 	{
1084*cdf0e10cSrcweir 	case STLPropertyState_AMBIGUOUS:
1085*cdf0e10cSrcweir 		// value is already ambiguous, do nothing
1086*cdf0e10cSrcweir 		break;
1087*cdf0e10cSrcweir 	case STLPropertyState_DIRECT:
1088*cdf0e10cSrcweir 		// set to ambiguous if existing value is different
1089*cdf0e10cSrcweir 		if( rValue != pSet->getPropertyValue( nHandle ) )
1090*cdf0e10cSrcweir 			pSet->setPropertyState( nHandle, STLPropertyState_AMBIGUOUS );
1091*cdf0e10cSrcweir 		break;
1092*cdf0e10cSrcweir 	case STLPropertyState_DEFAULT:
1093*cdf0e10cSrcweir 		// just set new value
1094*cdf0e10cSrcweir 		pSet->setPropertyValue( nHandle, rValue );
1095*cdf0e10cSrcweir 		break;
1096*cdf0e10cSrcweir 	}
1097*cdf0e10cSrcweir }
1098*cdf0e10cSrcweir 
1099*cdf0e10cSrcweir static sal_Int32 calcMaxParaDepth( Reference< XShape > xTargetShape )
1100*cdf0e10cSrcweir {
1101*cdf0e10cSrcweir 	sal_Int32 nMaxParaDepth = -1;
1102*cdf0e10cSrcweir 
1103*cdf0e10cSrcweir 	if( xTargetShape.is() )
1104*cdf0e10cSrcweir 	{
1105*cdf0e10cSrcweir 		Reference< XEnumerationAccess > xText( xTargetShape, UNO_QUERY );
1106*cdf0e10cSrcweir 		if( xText.is() )
1107*cdf0e10cSrcweir 		{
1108*cdf0e10cSrcweir 			Reference< XPropertySet > xParaSet;
1109*cdf0e10cSrcweir 			const OUString strNumberingLevel( RTL_CONSTASCII_USTRINGPARAM("NumberingLevel") );
1110*cdf0e10cSrcweir 
1111*cdf0e10cSrcweir 			Reference< XEnumeration > xEnumeration( xText->createEnumeration(), UNO_QUERY_THROW );
1112*cdf0e10cSrcweir 			while( xEnumeration->hasMoreElements() )
1113*cdf0e10cSrcweir 			{
1114*cdf0e10cSrcweir 				xEnumeration->nextElement() >>= xParaSet;
1115*cdf0e10cSrcweir 				if( xParaSet.is() )
1116*cdf0e10cSrcweir 				{
1117*cdf0e10cSrcweir 					sal_Int32 nParaDepth = 0;
1118*cdf0e10cSrcweir 					xParaSet->getPropertyValue( strNumberingLevel ) >>= nParaDepth;
1119*cdf0e10cSrcweir 
1120*cdf0e10cSrcweir 					if( nParaDepth > nMaxParaDepth )
1121*cdf0e10cSrcweir 						nMaxParaDepth = nParaDepth;
1122*cdf0e10cSrcweir 				}
1123*cdf0e10cSrcweir 			}
1124*cdf0e10cSrcweir 		}
1125*cdf0e10cSrcweir 	}
1126*cdf0e10cSrcweir 
1127*cdf0e10cSrcweir 	return nMaxParaDepth + 1;
1128*cdf0e10cSrcweir }
1129*cdf0e10cSrcweir 
1130*cdf0e10cSrcweir Any CustomAnimationPane::getProperty1Value( sal_Int32 nType, CustomAnimationEffectPtr pEffect )
1131*cdf0e10cSrcweir {
1132*cdf0e10cSrcweir 	switch( nType )
1133*cdf0e10cSrcweir 	{
1134*cdf0e10cSrcweir 	case nPropertyTypeDirection:
1135*cdf0e10cSrcweir 	case nPropertyTypeSpokes:
1136*cdf0e10cSrcweir 	case nPropertyTypeZoom:
1137*cdf0e10cSrcweir 		return makeAny( pEffect->getPresetSubType() );
1138*cdf0e10cSrcweir 
1139*cdf0e10cSrcweir 	case nPropertyTypeColor:
1140*cdf0e10cSrcweir 	case nPropertyTypeFillColor:
1141*cdf0e10cSrcweir 	case nPropertyTypeFirstColor:
1142*cdf0e10cSrcweir 	case nPropertyTypeSecondColor:
1143*cdf0e10cSrcweir 	case nPropertyTypeCharColor:
1144*cdf0e10cSrcweir 	case nPropertyTypeLineColor:
1145*cdf0e10cSrcweir 		{
1146*cdf0e10cSrcweir 			const sal_Int32 nIndex = (nPropertyTypeFirstColor == nType) ? 0 : 1;
1147*cdf0e10cSrcweir 			return pEffect->getColor( nIndex );
1148*cdf0e10cSrcweir 		}
1149*cdf0e10cSrcweir 
1150*cdf0e10cSrcweir 	case nPropertyTypeFont:
1151*cdf0e10cSrcweir 		return pEffect->getProperty( AnimationNodeType::SET, OUString( RTL_CONSTASCII_USTRINGPARAM("CharFontName") ), VALUE_TO );
1152*cdf0e10cSrcweir 
1153*cdf0e10cSrcweir 	case nPropertyTypeCharHeight:
1154*cdf0e10cSrcweir 		{
1155*cdf0e10cSrcweir 			const OUString aAttributeName( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" ) );
1156*cdf0e10cSrcweir             Any aValue( pEffect->getProperty( AnimationNodeType::SET, aAttributeName, VALUE_TO ) );
1157*cdf0e10cSrcweir 			if( !aValue.hasValue() )
1158*cdf0e10cSrcweir 				aValue = pEffect->getProperty( AnimationNodeType::ANIMATE, aAttributeName, VALUE_TO );
1159*cdf0e10cSrcweir 			return aValue;
1160*cdf0e10cSrcweir 		}
1161*cdf0e10cSrcweir 
1162*cdf0e10cSrcweir 	case nPropertyTypeRotate:
1163*cdf0e10cSrcweir 		return pEffect->getTransformationProperty( AnimationTransformType::ROTATE, VALUE_BY);
1164*cdf0e10cSrcweir 
1165*cdf0e10cSrcweir 	case nPropertyTypeTransparency:
1166*cdf0e10cSrcweir 		return pEffect->getProperty( AnimationNodeType::SET, OUString(RTL_CONSTASCII_USTRINGPARAM("Opacity")), VALUE_TO );
1167*cdf0e10cSrcweir 
1168*cdf0e10cSrcweir 	case nPropertyTypeScale:
1169*cdf0e10cSrcweir 		return pEffect->getTransformationProperty( AnimationTransformType::SCALE, VALUE_BY );
1170*cdf0e10cSrcweir 
1171*cdf0e10cSrcweir 	case nPropertyTypeCharDecoration:
1172*cdf0e10cSrcweir 		{
1173*cdf0e10cSrcweir 			Sequence< Any > aValues(3);
1174*cdf0e10cSrcweir 			aValues[0] = pEffect->getProperty( AnimationNodeType::SET, OUString(RTL_CONSTASCII_USTRINGPARAM("CharWeight")), VALUE_TO );
1175*cdf0e10cSrcweir 			aValues[1] = pEffect->getProperty( AnimationNodeType::SET, OUString(RTL_CONSTASCII_USTRINGPARAM("CharPosture")), VALUE_TO );
1176*cdf0e10cSrcweir 			aValues[2] = pEffect->getProperty( AnimationNodeType::SET, OUString(RTL_CONSTASCII_USTRINGPARAM("CharUnderline")), VALUE_TO );
1177*cdf0e10cSrcweir 			return makeAny( aValues );
1178*cdf0e10cSrcweir 		}
1179*cdf0e10cSrcweir 	}
1180*cdf0e10cSrcweir 
1181*cdf0e10cSrcweir 	Any aAny;
1182*cdf0e10cSrcweir 	return aAny;
1183*cdf0e10cSrcweir }
1184*cdf0e10cSrcweir 
1185*cdf0e10cSrcweir bool CustomAnimationPane::setProperty1Value( sal_Int32 nType, CustomAnimationEffectPtr pEffect, const Any& rValue )
1186*cdf0e10cSrcweir {
1187*cdf0e10cSrcweir 	bool bEffectChanged = false;
1188*cdf0e10cSrcweir 	switch( nType )
1189*cdf0e10cSrcweir 	{
1190*cdf0e10cSrcweir 	case nPropertyTypeDirection:
1191*cdf0e10cSrcweir 	case nPropertyTypeSpokes:
1192*cdf0e10cSrcweir 	case nPropertyTypeZoom:
1193*cdf0e10cSrcweir 		{
1194*cdf0e10cSrcweir 			OUString aPresetSubType;
1195*cdf0e10cSrcweir 			rValue >>= aPresetSubType;
1196*cdf0e10cSrcweir 			if( aPresetSubType != pEffect->getPresetSubType() )
1197*cdf0e10cSrcweir 			{
1198*cdf0e10cSrcweir 				getPresets().changePresetSubType( pEffect, aPresetSubType );
1199*cdf0e10cSrcweir 				bEffectChanged = true;
1200*cdf0e10cSrcweir 			}
1201*cdf0e10cSrcweir 		}
1202*cdf0e10cSrcweir 		break;
1203*cdf0e10cSrcweir 
1204*cdf0e10cSrcweir 	case nPropertyTypeFillColor:
1205*cdf0e10cSrcweir 	case nPropertyTypeColor:
1206*cdf0e10cSrcweir 	case nPropertyTypeFirstColor:
1207*cdf0e10cSrcweir 	case nPropertyTypeSecondColor:
1208*cdf0e10cSrcweir 	case nPropertyTypeCharColor:
1209*cdf0e10cSrcweir 	case nPropertyTypeLineColor:
1210*cdf0e10cSrcweir 		{
1211*cdf0e10cSrcweir 			const sal_Int32 nIndex = (nPropertyTypeFirstColor == nType) ? 0 : 1;
1212*cdf0e10cSrcweir 			Any aOldColor( pEffect->getColor( nIndex ) );
1213*cdf0e10cSrcweir 			if( aOldColor != rValue )
1214*cdf0e10cSrcweir 			{
1215*cdf0e10cSrcweir 				pEffect->setColor( nIndex, rValue );
1216*cdf0e10cSrcweir 				bEffectChanged = true;
1217*cdf0e10cSrcweir 			}
1218*cdf0e10cSrcweir 		}
1219*cdf0e10cSrcweir 		break;
1220*cdf0e10cSrcweir 
1221*cdf0e10cSrcweir 	case nPropertyTypeFont:
1222*cdf0e10cSrcweir 		bEffectChanged = pEffect->setProperty( AnimationNodeType::SET, OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontName" ) ), VALUE_TO, rValue );
1223*cdf0e10cSrcweir 		break;
1224*cdf0e10cSrcweir 
1225*cdf0e10cSrcweir 	case nPropertyTypeCharHeight:
1226*cdf0e10cSrcweir 		{
1227*cdf0e10cSrcweir 			const OUString aAttributeName( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" ) );
1228*cdf0e10cSrcweir 			bEffectChanged = pEffect->setProperty( AnimationNodeType::SET, aAttributeName, VALUE_TO, rValue );
1229*cdf0e10cSrcweir 			if( !bEffectChanged )
1230*cdf0e10cSrcweir 				bEffectChanged = pEffect->setProperty( AnimationNodeType::ANIMATE, aAttributeName, VALUE_TO, rValue );
1231*cdf0e10cSrcweir 		}
1232*cdf0e10cSrcweir 		break;
1233*cdf0e10cSrcweir 	case nPropertyTypeRotate:
1234*cdf0e10cSrcweir 		bEffectChanged = pEffect->setTransformationProperty( AnimationTransformType::ROTATE, VALUE_BY , rValue );
1235*cdf0e10cSrcweir 		break;
1236*cdf0e10cSrcweir 
1237*cdf0e10cSrcweir 	case nPropertyTypeTransparency:
1238*cdf0e10cSrcweir 		bEffectChanged = pEffect->setProperty( AnimationNodeType::SET, OUString( RTL_CONSTASCII_USTRINGPARAM("Opacity") ), VALUE_TO, rValue );
1239*cdf0e10cSrcweir 		break;
1240*cdf0e10cSrcweir 
1241*cdf0e10cSrcweir 	case nPropertyTypeScale:
1242*cdf0e10cSrcweir 		bEffectChanged = pEffect->setTransformationProperty( AnimationTransformType::SCALE, VALUE_BY, rValue );
1243*cdf0e10cSrcweir 		break;
1244*cdf0e10cSrcweir 
1245*cdf0e10cSrcweir 	case nPropertyTypeCharDecoration:
1246*cdf0e10cSrcweir 		{
1247*cdf0e10cSrcweir 			Sequence< Any > aValues(3);
1248*cdf0e10cSrcweir 			rValue >>= aValues;
1249*cdf0e10cSrcweir 			bEffectChanged = pEffect->setProperty( AnimationNodeType::SET, OUString(RTL_CONSTASCII_USTRINGPARAM("CharWeight")), VALUE_TO, aValues[0] );
1250*cdf0e10cSrcweir 			bEffectChanged |= pEffect->setProperty( AnimationNodeType::SET, OUString(RTL_CONSTASCII_USTRINGPARAM("CharPosture")), VALUE_TO, aValues[1] );
1251*cdf0e10cSrcweir 			bEffectChanged |= pEffect->setProperty( AnimationNodeType::SET, OUString(RTL_CONSTASCII_USTRINGPARAM("CharUnderline")), VALUE_TO, aValues[2] );
1252*cdf0e10cSrcweir 		}
1253*cdf0e10cSrcweir 		break;
1254*cdf0e10cSrcweir 
1255*cdf0e10cSrcweir 	}
1256*cdf0e10cSrcweir 
1257*cdf0e10cSrcweir 	return bEffectChanged;
1258*cdf0e10cSrcweir }
1259*cdf0e10cSrcweir 
1260*cdf0e10cSrcweir static sal_Bool hasVisibleShape( const Reference< XShape >& xShape )
1261*cdf0e10cSrcweir {
1262*cdf0e10cSrcweir 	try
1263*cdf0e10cSrcweir 	{
1264*cdf0e10cSrcweir 		const OUString sShapeType( xShape->getShapeType() );
1265*cdf0e10cSrcweir 
1266*cdf0e10cSrcweir 		if( sShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.TitleTextShape") ) ||
1267*cdf0e10cSrcweir 			sShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.OutlinerShape") ) ||
1268*cdf0e10cSrcweir 			sShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.SubtitleShape") ) ||
1269*cdf0e10cSrcweir 			sShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TextShape") ) )
1270*cdf0e10cSrcweir 		{
1271*cdf0e10cSrcweir 			const OUString sFillStyle( RTL_CONSTASCII_USTRINGPARAM("FillStyle" ) );
1272*cdf0e10cSrcweir 			const OUString sLineStyle( RTL_CONSTASCII_USTRINGPARAM("LineStyle" ) );
1273*cdf0e10cSrcweir 			Reference< XPropertySet > xSet( xShape, UNO_QUERY_THROW );
1274*cdf0e10cSrcweir 
1275*cdf0e10cSrcweir 			FillStyle eFillStyle;
1276*cdf0e10cSrcweir 			xSet->getPropertyValue( sFillStyle ) >>= eFillStyle;
1277*cdf0e10cSrcweir 
1278*cdf0e10cSrcweir 			::com::sun::star::drawing::LineStyle eLineStyle;
1279*cdf0e10cSrcweir 			xSet->getPropertyValue( sLineStyle ) >>= eLineStyle;
1280*cdf0e10cSrcweir 
1281*cdf0e10cSrcweir 			return eFillStyle != FillStyle_NONE || eLineStyle != ::com::sun::star::drawing::LineStyle_NONE;
1282*cdf0e10cSrcweir 		}
1283*cdf0e10cSrcweir 	}
1284*cdf0e10cSrcweir 	catch( Exception& e )
1285*cdf0e10cSrcweir 	{
1286*cdf0e10cSrcweir 		(void)e;
1287*cdf0e10cSrcweir 	}
1288*cdf0e10cSrcweir 	return sal_True;
1289*cdf0e10cSrcweir }
1290*cdf0e10cSrcweir 
1291*cdf0e10cSrcweir STLPropertySet* CustomAnimationPane::createSelectionSet()
1292*cdf0e10cSrcweir {
1293*cdf0e10cSrcweir 	STLPropertySet* pSet = CustomAnimationDialog::createDefaultSet();
1294*cdf0e10cSrcweir 
1295*cdf0e10cSrcweir 	pSet->setPropertyValue( nHandleCurrentPage, makeAny( mxCurrentPage ) );
1296*cdf0e10cSrcweir 
1297*cdf0e10cSrcweir 	sal_Int32 nMaxParaDepth = 0;
1298*cdf0e10cSrcweir 
1299*cdf0e10cSrcweir 	// get options from selected effects
1300*cdf0e10cSrcweir 	EffectSequence::iterator aIter( maListSelection.begin() );
1301*cdf0e10cSrcweir 	const EffectSequence::iterator aEnd( maListSelection.end() );
1302*cdf0e10cSrcweir     const CustomAnimationPresets& rPresets (getPresets());
1303*cdf0e10cSrcweir     while( aIter != aEnd )
1304*cdf0e10cSrcweir 	{
1305*cdf0e10cSrcweir 		CustomAnimationEffectPtr pEffect = (*aIter++);
1306*cdf0e10cSrcweir 
1307*cdf0e10cSrcweir 		EffectSequenceHelper* pEffectSequence = pEffect->getEffectSequence();
1308*cdf0e10cSrcweir 		if( !pEffectSequence )
1309*cdf0e10cSrcweir 			pEffectSequence = mpMainSequence.get();
1310*cdf0e10cSrcweir 
1311*cdf0e10cSrcweir 		if( pEffect->hasText() )
1312*cdf0e10cSrcweir 		{
1313*cdf0e10cSrcweir 			sal_Int32 n = calcMaxParaDepth(pEffect->getTargetShape());
1314*cdf0e10cSrcweir 			if( n > nMaxParaDepth )
1315*cdf0e10cSrcweir 				nMaxParaDepth = n;
1316*cdf0e10cSrcweir 		}
1317*cdf0e10cSrcweir 
1318*cdf0e10cSrcweir 		addValue( pSet, nHandleHasAfterEffect, makeAny( pEffect->hasAfterEffect() ) );
1319*cdf0e10cSrcweir 		addValue( pSet, nHandleAfterEffectOnNextEffect, makeAny( pEffect->IsAfterEffectOnNext() ? sal_True : sal_False ) );
1320*cdf0e10cSrcweir 		addValue( pSet, nHandleDimColor, pEffect->getDimColor() );
1321*cdf0e10cSrcweir 		addValue( pSet, nHandleIterateType, makeAny( pEffect->getIterateType() ) );
1322*cdf0e10cSrcweir 
1323*cdf0e10cSrcweir 		// convert absolute time to percentage value
1324*cdf0e10cSrcweir         // This calculation is done in float to avoid some rounding artifacts.
1325*cdf0e10cSrcweir 		float fIterateInterval = (float)pEffect->getIterateInterval();
1326*cdf0e10cSrcweir 		if( pEffect->getDuration() )
1327*cdf0e10cSrcweir 			fIterateInterval = (float)(fIterateInterval / pEffect->getDuration() );
1328*cdf0e10cSrcweir 		fIterateInterval *= 100.0;
1329*cdf0e10cSrcweir 		addValue( pSet, nHandleIterateInterval, makeAny( (double)fIterateInterval ) );
1330*cdf0e10cSrcweir 
1331*cdf0e10cSrcweir 		addValue( pSet, nHandleBegin, makeAny( pEffect->getBegin() ) );
1332*cdf0e10cSrcweir 		addValue( pSet, nHandleDuration, makeAny( pEffect->getDuration() ) );
1333*cdf0e10cSrcweir 		addValue( pSet, nHandleStart, makeAny( pEffect->getNodeType() ) );
1334*cdf0e10cSrcweir 		addValue( pSet, nHandleRepeat, makeAny( pEffect->getRepeatCount() ) );
1335*cdf0e10cSrcweir 		addValue( pSet, nHandleEnd, pEffect->getEnd() );
1336*cdf0e10cSrcweir 		addValue( pSet, nHandleRewind, makeAny( pEffect->getFill() ) );
1337*cdf0e10cSrcweir 
1338*cdf0e10cSrcweir 		addValue( pSet, nHandlePresetId, makeAny( pEffect->getPresetId() ) );
1339*cdf0e10cSrcweir 
1340*cdf0e10cSrcweir 		addValue( pSet, nHandleHasText, makeAny( (sal_Bool)pEffect->hasText() ) );
1341*cdf0e10cSrcweir 
1342*cdf0e10cSrcweir 		addValue( pSet, nHandleHasVisibleShape, Any( hasVisibleShape( pEffect->getTargetShape() ) ) );
1343*cdf0e10cSrcweir 
1344*cdf0e10cSrcweir 		Any aSoundSource;
1345*cdf0e10cSrcweir 		if( pEffect->getAudio().is() )
1346*cdf0e10cSrcweir 		{
1347*cdf0e10cSrcweir 			aSoundSource = pEffect->getAudio()->getSource();
1348*cdf0e10cSrcweir 			addValue( pSet, nHandleSoundVolumne, makeAny( pEffect->getAudio()->getVolume() ) );
1349*cdf0e10cSrcweir // todo		addValue( pSet, nHandleSoundEndAfterSlide, makeAny( pEffect->getAudio()->getEndAfterSlide() ) );
1350*cdf0e10cSrcweir // this is now stored at the XCommand parameter sequence
1351*cdf0e10cSrcweir 		}
1352*cdf0e10cSrcweir 		else if( pEffect->getCommand() == EffectCommands::STOPAUDIO )
1353*cdf0e10cSrcweir 		{
1354*cdf0e10cSrcweir 			aSoundSource = makeAny( (sal_Bool)sal_True );
1355*cdf0e10cSrcweir 		}
1356*cdf0e10cSrcweir 		addValue( pSet, nHandleSoundURL, aSoundSource );
1357*cdf0e10cSrcweir 
1358*cdf0e10cSrcweir 		sal_Int32 nGroupId = pEffect->getGroupId();
1359*cdf0e10cSrcweir 		CustomAnimationTextGroupPtr pTextGroup;
1360*cdf0e10cSrcweir 		if( nGroupId != -1 )
1361*cdf0e10cSrcweir 			pTextGroup = pEffectSequence->findGroup( nGroupId );
1362*cdf0e10cSrcweir 
1363*cdf0e10cSrcweir 		addValue( pSet, nHandleTextGrouping, makeAny( pTextGroup.get() ? pTextGroup->getTextGrouping() : (sal_Int32)-1 ) );
1364*cdf0e10cSrcweir 		addValue( pSet, nHandleAnimateForm, makeAny( pTextGroup.get() ? (sal_Bool)pTextGroup->getAnimateForm() : sal_True ) );
1365*cdf0e10cSrcweir 		addValue( pSet, nHandleTextGroupingAuto, makeAny( pTextGroup.get() ? pTextGroup->getTextGroupingAuto() : (double)-1.0 ) );
1366*cdf0e10cSrcweir 		addValue( pSet, nHandleTextReverse, makeAny( pTextGroup.get() ? (sal_Bool)pTextGroup->getTextReverse() : sal_False ) );
1367*cdf0e10cSrcweir 
1368*cdf0e10cSrcweir 		if( pEffectSequence->getSequenceType() == EffectNodeType::INTERACTIVE_SEQUENCE  )
1369*cdf0e10cSrcweir 		{
1370*cdf0e10cSrcweir 			InteractiveSequence* pIS = static_cast< InteractiveSequence* >( pEffectSequence );
1371*cdf0e10cSrcweir 			addValue( pSet, nHandleTrigger, makeAny( pIS->getTriggerShape() ) );
1372*cdf0e10cSrcweir 		}
1373*cdf0e10cSrcweir 
1374*cdf0e10cSrcweir 		//
1375*cdf0e10cSrcweir 
1376*cdf0e10cSrcweir 		CustomAnimationPresetPtr pDescriptor = rPresets.getEffectDescriptor( pEffect->getPresetId() );
1377*cdf0e10cSrcweir 		if( pDescriptor.get() )
1378*cdf0e10cSrcweir 		{
1379*cdf0e10cSrcweir 			sal_Int32 nType = nPropertyTypeNone;
1380*cdf0e10cSrcweir 
1381*cdf0e10cSrcweir 			UStringList aProperties( pDescriptor->getProperties() );
1382*cdf0e10cSrcweir 			if( aProperties.size() >= 1 )
1383*cdf0e10cSrcweir 				nType = getPropertyType( aProperties.front() );
1384*cdf0e10cSrcweir 
1385*cdf0e10cSrcweir 			if( nType != nPropertyTypeNone )
1386*cdf0e10cSrcweir 			{
1387*cdf0e10cSrcweir 				addValue( pSet, nHandleProperty1Type, makeAny( nType ) );
1388*cdf0e10cSrcweir 				addValue( pSet, nHandleProperty1Value, getProperty1Value( nType, pEffect ) );
1389*cdf0e10cSrcweir 			}
1390*cdf0e10cSrcweir 
1391*cdf0e10cSrcweir 			if( pDescriptor->hasProperty( OUString( RTL_CONSTASCII_USTRINGPARAM( "Accelerate" ) ) ) )
1392*cdf0e10cSrcweir 			{
1393*cdf0e10cSrcweir 				addValue( pSet, nHandleAccelerate, makeAny( pEffect->getAcceleration() ) );
1394*cdf0e10cSrcweir 			}
1395*cdf0e10cSrcweir 
1396*cdf0e10cSrcweir 			if( pDescriptor->hasProperty( OUString( RTL_CONSTASCII_USTRINGPARAM( "Decelerate" ) ) ) )
1397*cdf0e10cSrcweir 			{
1398*cdf0e10cSrcweir 				addValue( pSet, nHandleDecelerate, makeAny( pEffect->getDecelerate() ) );
1399*cdf0e10cSrcweir 			}
1400*cdf0e10cSrcweir 
1401*cdf0e10cSrcweir 			if( pDescriptor->hasProperty( OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoReverse" ) ) ) )
1402*cdf0e10cSrcweir 			{
1403*cdf0e10cSrcweir 				addValue( pSet, nHandleAutoReverse, makeAny( pEffect->getAutoReverse() ) );
1404*cdf0e10cSrcweir 			}
1405*cdf0e10cSrcweir 		}
1406*cdf0e10cSrcweir 	}
1407*cdf0e10cSrcweir 
1408*cdf0e10cSrcweir 	addValue( pSet, nHandleMaxParaDepth, makeAny( nMaxParaDepth ) );
1409*cdf0e10cSrcweir 
1410*cdf0e10cSrcweir 	return pSet;
1411*cdf0e10cSrcweir }
1412*cdf0e10cSrcweir 
1413*cdf0e10cSrcweir void CustomAnimationPane::changeSelection( STLPropertySet* pResultSet, STLPropertySet* pOldSet )
1414*cdf0e10cSrcweir {
1415*cdf0e10cSrcweir 	// change selected effect
1416*cdf0e10cSrcweir 	bool bChanged = false;
1417*cdf0e10cSrcweir 
1418*cdf0e10cSrcweir 	MainSequenceRebuildGuard aGuard( mpMainSequence );
1419*cdf0e10cSrcweir 
1420*cdf0e10cSrcweir 	EffectSequence::iterator aIter( maListSelection.begin() );
1421*cdf0e10cSrcweir 	const EffectSequence::iterator aEnd( maListSelection.end() );
1422*cdf0e10cSrcweir 	while( aIter != aEnd )
1423*cdf0e10cSrcweir 	{
1424*cdf0e10cSrcweir 		CustomAnimationEffectPtr pEffect = (*aIter++);
1425*cdf0e10cSrcweir 
1426*cdf0e10cSrcweir 		DBG_ASSERT( pEffect->getEffectSequence(), "sd::CustomAnimationPane::changeSelection(), dead effect in selection!" );
1427*cdf0e10cSrcweir 		if( !pEffect->getEffectSequence() )
1428*cdf0e10cSrcweir 			continue;
1429*cdf0e10cSrcweir 
1430*cdf0e10cSrcweir 		double fDuration = 0.0; // we might need this for iterate-interval
1431*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleDuration ) == STLPropertyState_DIRECT )
1432*cdf0e10cSrcweir 		{
1433*cdf0e10cSrcweir 			pResultSet->getPropertyValue( nHandleDuration ) >>= fDuration;
1434*cdf0e10cSrcweir 		}
1435*cdf0e10cSrcweir 		else
1436*cdf0e10cSrcweir 		{
1437*cdf0e10cSrcweir 			fDuration = pEffect->getDuration();
1438*cdf0e10cSrcweir 		}
1439*cdf0e10cSrcweir 
1440*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleIterateType ) == STLPropertyState_DIRECT )
1441*cdf0e10cSrcweir 		{
1442*cdf0e10cSrcweir 			sal_Int16 nIterateType = 0;
1443*cdf0e10cSrcweir 			pResultSet->getPropertyValue( nHandleIterateType ) >>= nIterateType;
1444*cdf0e10cSrcweir 			if( pEffect->getIterateType() != nIterateType )
1445*cdf0e10cSrcweir 			{
1446*cdf0e10cSrcweir 				pEffect->setIterateType( nIterateType );
1447*cdf0e10cSrcweir 				bChanged = true;
1448*cdf0e10cSrcweir 			}
1449*cdf0e10cSrcweir 		}
1450*cdf0e10cSrcweir 
1451*cdf0e10cSrcweir 		if( pEffect->getIterateType() )
1452*cdf0e10cSrcweir 		{
1453*cdf0e10cSrcweir 			if( pResultSet->getPropertyState( nHandleIterateInterval ) == STLPropertyState_DIRECT )
1454*cdf0e10cSrcweir 			{
1455*cdf0e10cSrcweir 				double fIterateInterval = 0.0;
1456*cdf0e10cSrcweir 				pResultSet->getPropertyValue( nHandleIterateInterval ) >>= fIterateInterval;
1457*cdf0e10cSrcweir 				if( pEffect->getIterateInterval() != fIterateInterval )
1458*cdf0e10cSrcweir 				{
1459*cdf0e10cSrcweir 					const double f = fIterateInterval * pEffect->getDuration() / 100;
1460*cdf0e10cSrcweir 					pEffect->setIterateInterval( f );
1461*cdf0e10cSrcweir 					bChanged = true;
1462*cdf0e10cSrcweir 				}
1463*cdf0e10cSrcweir 			}
1464*cdf0e10cSrcweir 		}
1465*cdf0e10cSrcweir 
1466*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleBegin ) == STLPropertyState_DIRECT )
1467*cdf0e10cSrcweir 		{
1468*cdf0e10cSrcweir 			double fBegin = 0.0;
1469*cdf0e10cSrcweir 			pResultSet->getPropertyValue( nHandleBegin ) >>= fBegin;
1470*cdf0e10cSrcweir 			if( pEffect->getBegin() != fBegin )
1471*cdf0e10cSrcweir 			{
1472*cdf0e10cSrcweir 				pEffect->setBegin( fBegin );
1473*cdf0e10cSrcweir 				bChanged = true;
1474*cdf0e10cSrcweir 			}
1475*cdf0e10cSrcweir 		}
1476*cdf0e10cSrcweir 
1477*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleDuration ) == STLPropertyState_DIRECT )
1478*cdf0e10cSrcweir 		{
1479*cdf0e10cSrcweir 			if( pEffect->getDuration() != fDuration )
1480*cdf0e10cSrcweir 			{
1481*cdf0e10cSrcweir 				pEffect->setDuration( fDuration );
1482*cdf0e10cSrcweir 				bChanged = true;
1483*cdf0e10cSrcweir 			}
1484*cdf0e10cSrcweir 		}
1485*cdf0e10cSrcweir 
1486*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleStart ) == STLPropertyState_DIRECT )
1487*cdf0e10cSrcweir 		{
1488*cdf0e10cSrcweir 			sal_Int16 nNodeType = 0;
1489*cdf0e10cSrcweir 			pResultSet->getPropertyValue( nHandleStart ) >>= nNodeType;
1490*cdf0e10cSrcweir 			if( pEffect->getNodeType() != nNodeType )
1491*cdf0e10cSrcweir 			{
1492*cdf0e10cSrcweir 				pEffect->setNodeType( nNodeType );
1493*cdf0e10cSrcweir 				bChanged = true;
1494*cdf0e10cSrcweir 			}
1495*cdf0e10cSrcweir 		}
1496*cdf0e10cSrcweir 
1497*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleRepeat ) == STLPropertyState_DIRECT )
1498*cdf0e10cSrcweir 		{
1499*cdf0e10cSrcweir 			Any aRepeatCount( pResultSet->getPropertyValue( nHandleRepeat ) );
1500*cdf0e10cSrcweir 			if( aRepeatCount != pEffect->getRepeatCount() )
1501*cdf0e10cSrcweir 			{
1502*cdf0e10cSrcweir 				pEffect->setRepeatCount( aRepeatCount );
1503*cdf0e10cSrcweir 				bChanged = true;
1504*cdf0e10cSrcweir 			}
1505*cdf0e10cSrcweir 		}
1506*cdf0e10cSrcweir 
1507*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleEnd ) == STLPropertyState_DIRECT )
1508*cdf0e10cSrcweir 		{
1509*cdf0e10cSrcweir 			Any aEndValue( pResultSet->getPropertyValue( nHandleEnd ) );
1510*cdf0e10cSrcweir 			if( pEffect->getEnd() != aEndValue )
1511*cdf0e10cSrcweir 			{
1512*cdf0e10cSrcweir 				pEffect->setEnd( aEndValue );
1513*cdf0e10cSrcweir 				bChanged = true;
1514*cdf0e10cSrcweir 			}
1515*cdf0e10cSrcweir 		}
1516*cdf0e10cSrcweir 
1517*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleRewind ) == STLPropertyState_DIRECT )
1518*cdf0e10cSrcweir 		{
1519*cdf0e10cSrcweir 			sal_Int16 nFill = 0;
1520*cdf0e10cSrcweir 			pResultSet->getPropertyValue( nHandleRewind ) >>= nFill;
1521*cdf0e10cSrcweir 			if( pEffect->getFill() != nFill )
1522*cdf0e10cSrcweir 			{
1523*cdf0e10cSrcweir 				pEffect->setFill( nFill );
1524*cdf0e10cSrcweir 				bChanged = true;
1525*cdf0e10cSrcweir 			}
1526*cdf0e10cSrcweir 		}
1527*cdf0e10cSrcweir 
1528*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleHasAfterEffect ) == STLPropertyState_DIRECT )
1529*cdf0e10cSrcweir 		{
1530*cdf0e10cSrcweir 			sal_Bool bHasAfterEffect = sal_False;
1531*cdf0e10cSrcweir 			if( pResultSet->getPropertyValue( nHandleHasAfterEffect )  >>= bHasAfterEffect )
1532*cdf0e10cSrcweir 			{
1533*cdf0e10cSrcweir 				if( pEffect->hasAfterEffect() != bHasAfterEffect )
1534*cdf0e10cSrcweir 				{
1535*cdf0e10cSrcweir 					pEffect->setHasAfterEffect( bHasAfterEffect );
1536*cdf0e10cSrcweir 					bChanged = true;
1537*cdf0e10cSrcweir 				}
1538*cdf0e10cSrcweir 			}
1539*cdf0e10cSrcweir 		}
1540*cdf0e10cSrcweir 
1541*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleAfterEffectOnNextEffect ) == STLPropertyState_DIRECT )
1542*cdf0e10cSrcweir 		{
1543*cdf0e10cSrcweir 			sal_Bool bAfterEffectOnNextEffect = sal_False;
1544*cdf0e10cSrcweir 			if( (pResultSet->getPropertyValue( nHandleAfterEffectOnNextEffect ) >>= bAfterEffectOnNextEffect) && ((pEffect->IsAfterEffectOnNext() ? sal_True : sal_False) != bAfterEffectOnNextEffect) )
1545*cdf0e10cSrcweir 			{
1546*cdf0e10cSrcweir 				pEffect->setAfterEffectOnNext( bAfterEffectOnNextEffect );
1547*cdf0e10cSrcweir 				bChanged = true;
1548*cdf0e10cSrcweir 			}
1549*cdf0e10cSrcweir 		}
1550*cdf0e10cSrcweir 
1551*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleDimColor ) == STLPropertyState_DIRECT )
1552*cdf0e10cSrcweir 		{
1553*cdf0e10cSrcweir 			Any aDimColor( pResultSet->getPropertyValue( nHandleDimColor ) );
1554*cdf0e10cSrcweir 			if( pEffect->getDimColor() != aDimColor )
1555*cdf0e10cSrcweir 			{
1556*cdf0e10cSrcweir 				pEffect->setDimColor( aDimColor );
1557*cdf0e10cSrcweir 				bChanged = true;
1558*cdf0e10cSrcweir 			}
1559*cdf0e10cSrcweir 		}
1560*cdf0e10cSrcweir 
1561*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleAccelerate ) == STLPropertyState_DIRECT )
1562*cdf0e10cSrcweir 		{
1563*cdf0e10cSrcweir 			double fAccelerate = 0.0;
1564*cdf0e10cSrcweir 			pResultSet->getPropertyValue( nHandleAccelerate ) >>= fAccelerate;
1565*cdf0e10cSrcweir 			if( pEffect->getAcceleration() != fAccelerate )
1566*cdf0e10cSrcweir 			{
1567*cdf0e10cSrcweir 				pEffect->setAcceleration( fAccelerate );
1568*cdf0e10cSrcweir 				bChanged = true;
1569*cdf0e10cSrcweir 			}
1570*cdf0e10cSrcweir 		}
1571*cdf0e10cSrcweir 
1572*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleDecelerate ) == STLPropertyState_DIRECT )
1573*cdf0e10cSrcweir 		{
1574*cdf0e10cSrcweir 			double fDecelerate = 0.0;
1575*cdf0e10cSrcweir 			pResultSet->getPropertyValue( nHandleDecelerate ) >>= fDecelerate;
1576*cdf0e10cSrcweir 			if( pEffect->getDecelerate() != fDecelerate )
1577*cdf0e10cSrcweir 			{
1578*cdf0e10cSrcweir 				pEffect->setDecelerate( fDecelerate );
1579*cdf0e10cSrcweir 				bChanged = true;
1580*cdf0e10cSrcweir 			}
1581*cdf0e10cSrcweir 		}
1582*cdf0e10cSrcweir 
1583*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleAutoReverse ) == STLPropertyState_DIRECT )
1584*cdf0e10cSrcweir 		{
1585*cdf0e10cSrcweir 			sal_Bool bAutoReverse = sal_False;
1586*cdf0e10cSrcweir 			pResultSet->getPropertyValue( nHandleAutoReverse ) >>= bAutoReverse;
1587*cdf0e10cSrcweir 			if( pEffect->getAutoReverse() != bAutoReverse )
1588*cdf0e10cSrcweir 			{
1589*cdf0e10cSrcweir 				pEffect->setAutoReverse( bAutoReverse );
1590*cdf0e10cSrcweir 				bChanged = true;
1591*cdf0e10cSrcweir 			}
1592*cdf0e10cSrcweir 		}
1593*cdf0e10cSrcweir 
1594*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleProperty1Value ) == STLPropertyState_DIRECT )
1595*cdf0e10cSrcweir 		{
1596*cdf0e10cSrcweir 			sal_Int32 nType = 0;
1597*cdf0e10cSrcweir 			pOldSet->getPropertyValue( nHandleProperty1Type ) >>= nType;
1598*cdf0e10cSrcweir 
1599*cdf0e10cSrcweir 			bChanged |= setProperty1Value( nType, pEffect, pResultSet->getPropertyValue( nHandleProperty1Value ) );
1600*cdf0e10cSrcweir 		}
1601*cdf0e10cSrcweir 
1602*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleSoundURL ) == STLPropertyState_DIRECT )
1603*cdf0e10cSrcweir 		{
1604*cdf0e10cSrcweir 			const Any aSoundSource( pResultSet->getPropertyValue( nHandleSoundURL ) );
1605*cdf0e10cSrcweir 
1606*cdf0e10cSrcweir 			if( aSoundSource.getValueType() == ::getCppuType((const sal_Bool*)0) )
1607*cdf0e10cSrcweir 			{
1608*cdf0e10cSrcweir 				pEffect->setStopAudio();
1609*cdf0e10cSrcweir 				bChanged = true;
1610*cdf0e10cSrcweir 			}
1611*cdf0e10cSrcweir 			else
1612*cdf0e10cSrcweir 			{
1613*cdf0e10cSrcweir 				OUString aSoundURL;
1614*cdf0e10cSrcweir 				aSoundSource >>= aSoundURL;
1615*cdf0e10cSrcweir 
1616*cdf0e10cSrcweir 				if( aSoundURL.getLength() )
1617*cdf0e10cSrcweir 				{
1618*cdf0e10cSrcweir 					if( !pEffect->getAudio().is() )
1619*cdf0e10cSrcweir 					{
1620*cdf0e10cSrcweir 						pEffect->createAudio( aSoundSource );
1621*cdf0e10cSrcweir 						bChanged = true;
1622*cdf0e10cSrcweir 					}
1623*cdf0e10cSrcweir 					else
1624*cdf0e10cSrcweir 					{
1625*cdf0e10cSrcweir 						if( pEffect->getAudio()->getSource() != aSoundSource )
1626*cdf0e10cSrcweir 						{
1627*cdf0e10cSrcweir 							pEffect->getAudio()->setSource( aSoundSource );
1628*cdf0e10cSrcweir 							bChanged = true;
1629*cdf0e10cSrcweir 						}
1630*cdf0e10cSrcweir 					}
1631*cdf0e10cSrcweir 				}
1632*cdf0e10cSrcweir 				else
1633*cdf0e10cSrcweir 				{
1634*cdf0e10cSrcweir 					if( pEffect->getAudio().is() || pEffect->getStopAudio() )
1635*cdf0e10cSrcweir 					{
1636*cdf0e10cSrcweir 						pEffect->removeAudio();
1637*cdf0e10cSrcweir 						bChanged = true;
1638*cdf0e10cSrcweir 					}
1639*cdf0e10cSrcweir 				}
1640*cdf0e10cSrcweir 			}
1641*cdf0e10cSrcweir 		}
1642*cdf0e10cSrcweir 
1643*cdf0e10cSrcweir 		if( pResultSet->getPropertyState( nHandleTrigger ) == STLPropertyState_DIRECT )
1644*cdf0e10cSrcweir 		{
1645*cdf0e10cSrcweir 			Reference< XShape > xTriggerShape;
1646*cdf0e10cSrcweir 			pResultSet->getPropertyValue( nHandleTrigger ) >>= xTriggerShape;
1647*cdf0e10cSrcweir 			bChanged |= mpMainSequence->setTrigger( pEffect, xTriggerShape );
1648*cdf0e10cSrcweir 		}
1649*cdf0e10cSrcweir 	}
1650*cdf0e10cSrcweir 
1651*cdf0e10cSrcweir 	const bool bHasTextGrouping = pResultSet->getPropertyState( nHandleTextGrouping ) == STLPropertyState_DIRECT;
1652*cdf0e10cSrcweir 	const bool bHasAnimateForm = pResultSet->getPropertyState( nHandleAnimateForm ) == STLPropertyState_DIRECT;
1653*cdf0e10cSrcweir 	const bool bHasTextGroupingAuto = pResultSet->getPropertyState( nHandleTextGroupingAuto ) == STLPropertyState_DIRECT;
1654*cdf0e10cSrcweir 	const bool bHasTextReverse = pResultSet->getPropertyState( nHandleTextReverse ) == STLPropertyState_DIRECT;
1655*cdf0e10cSrcweir 
1656*cdf0e10cSrcweir 	if( bHasTextGrouping || bHasAnimateForm || bHasTextGroupingAuto || bHasTextReverse )
1657*cdf0e10cSrcweir 	{
1658*cdf0e10cSrcweir 		// we need to do a second pass for text grouping options
1659*cdf0e10cSrcweir 		// since changing them can cause effects to be removed
1660*cdf0e10cSrcweir 		// or replaced, we do this after we aplied all other options
1661*cdf0e10cSrcweir 		// above
1662*cdf0e10cSrcweir 
1663*cdf0e10cSrcweir 		sal_Int32 nTextGrouping = 0;
1664*cdf0e10cSrcweir 		sal_Bool bAnimateForm = sal_True, bTextReverse = sal_False;
1665*cdf0e10cSrcweir 		double fTextGroupingAuto = -1.0;
1666*cdf0e10cSrcweir 
1667*cdf0e10cSrcweir 		if( bHasTextGrouping )
1668*cdf0e10cSrcweir 			pResultSet->getPropertyValue(nHandleTextGrouping) >>= nTextGrouping;
1669*cdf0e10cSrcweir 
1670*cdf0e10cSrcweir 		if( bHasAnimateForm )
1671*cdf0e10cSrcweir 			pResultSet->getPropertyValue(nHandleAnimateForm) >>= bAnimateForm;
1672*cdf0e10cSrcweir 
1673*cdf0e10cSrcweir 		if( bHasTextGroupingAuto )
1674*cdf0e10cSrcweir 			pResultSet->getPropertyValue(nHandleTextGroupingAuto) >>= fTextGroupingAuto;
1675*cdf0e10cSrcweir 
1676*cdf0e10cSrcweir 		if( bHasTextReverse )
1677*cdf0e10cSrcweir 			pResultSet->getPropertyValue(nHandleTextReverse) >>= bTextReverse;
1678*cdf0e10cSrcweir 
1679*cdf0e10cSrcweir 		EffectSequence const aSelectedEffects( maListSelection );
1680*cdf0e10cSrcweir 		EffectSequence::const_iterator iter( aSelectedEffects.begin() );
1681*cdf0e10cSrcweir 		const EffectSequence::const_iterator iEnd( aSelectedEffects.end() );
1682*cdf0e10cSrcweir 		while( iter != iEnd )
1683*cdf0e10cSrcweir 		{
1684*cdf0e10cSrcweir 			CustomAnimationEffectPtr const& pEffect = (*iter++);
1685*cdf0e10cSrcweir 
1686*cdf0e10cSrcweir 			EffectSequenceHelper* pEffectSequence = pEffect->getEffectSequence();
1687*cdf0e10cSrcweir 			if( !pEffectSequence )
1688*cdf0e10cSrcweir 				pEffectSequence = mpMainSequence.get();
1689*cdf0e10cSrcweir 
1690*cdf0e10cSrcweir 			sal_Int32 nGroupId = pEffect->getGroupId();
1691*cdf0e10cSrcweir 			CustomAnimationTextGroupPtr pTextGroup;
1692*cdf0e10cSrcweir 			if( (nGroupId != -1) )
1693*cdf0e10cSrcweir 			{
1694*cdf0e10cSrcweir 				// use existing group
1695*cdf0e10cSrcweir 				pTextGroup = pEffectSequence->findGroup( nGroupId );
1696*cdf0e10cSrcweir 			}
1697*cdf0e10cSrcweir 			else
1698*cdf0e10cSrcweir 			{
1699*cdf0e10cSrcweir 				// somethings changed so we need a group now
1700*cdf0e10cSrcweir 				pTextGroup = pEffectSequence->createTextGroup( pEffect, nTextGrouping, fTextGroupingAuto, bAnimateForm, bTextReverse );
1701*cdf0e10cSrcweir 				bChanged = true;
1702*cdf0e10cSrcweir 			}
1703*cdf0e10cSrcweir 
1704*cdf0e10cSrcweir 			if( bHasTextGrouping )
1705*cdf0e10cSrcweir 			{
1706*cdf0e10cSrcweir 				if( (pTextGroup->getTextGrouping() != nTextGrouping) )
1707*cdf0e10cSrcweir 				{
1708*cdf0e10cSrcweir 					pEffectSequence->setTextGrouping( pTextGroup, nTextGrouping );
1709*cdf0e10cSrcweir 					bChanged = true;
1710*cdf0e10cSrcweir 				}
1711*cdf0e10cSrcweir 			}
1712*cdf0e10cSrcweir 
1713*cdf0e10cSrcweir 			if( bHasAnimateForm )
1714*cdf0e10cSrcweir 			{
1715*cdf0e10cSrcweir 				if( pTextGroup->getAnimateForm() != bAnimateForm )
1716*cdf0e10cSrcweir 				{
1717*cdf0e10cSrcweir 					pEffectSequence->setAnimateForm( pTextGroup, bAnimateForm );
1718*cdf0e10cSrcweir 					bChanged = true;
1719*cdf0e10cSrcweir 				}
1720*cdf0e10cSrcweir 			}
1721*cdf0e10cSrcweir 
1722*cdf0e10cSrcweir 			if( bHasTextGroupingAuto )
1723*cdf0e10cSrcweir 			{
1724*cdf0e10cSrcweir 				if( pTextGroup->getTextGroupingAuto() != fTextGroupingAuto )
1725*cdf0e10cSrcweir 				{
1726*cdf0e10cSrcweir 					pEffectSequence->setTextGroupingAuto( pTextGroup, fTextGroupingAuto );
1727*cdf0e10cSrcweir 					bChanged = true;
1728*cdf0e10cSrcweir 				}
1729*cdf0e10cSrcweir 			}
1730*cdf0e10cSrcweir 
1731*cdf0e10cSrcweir 			if( bHasTextReverse )
1732*cdf0e10cSrcweir 			{
1733*cdf0e10cSrcweir 				if( pTextGroup->getTextReverse() != bTextReverse )
1734*cdf0e10cSrcweir 				{
1735*cdf0e10cSrcweir 					pEffectSequence->setTextReverse( pTextGroup, bTextReverse );
1736*cdf0e10cSrcweir 					bChanged = true;
1737*cdf0e10cSrcweir 				}
1738*cdf0e10cSrcweir 			}
1739*cdf0e10cSrcweir 		}
1740*cdf0e10cSrcweir 	}
1741*cdf0e10cSrcweir 
1742*cdf0e10cSrcweir 	if( bChanged )
1743*cdf0e10cSrcweir 	{
1744*cdf0e10cSrcweir 		mpMainSequence->rebuild();
1745*cdf0e10cSrcweir 		updateControls();
1746*cdf0e10cSrcweir 		mrBase.GetDocShell()->SetModified();
1747*cdf0e10cSrcweir 	}
1748*cdf0e10cSrcweir }
1749*cdf0e10cSrcweir 
1750*cdf0e10cSrcweir void CustomAnimationPane::showOptions( sal_uInt16 nPage /* = 0 */ )
1751*cdf0e10cSrcweir {
1752*cdf0e10cSrcweir 	STLPropertySet* pSet = createSelectionSet();
1753*cdf0e10cSrcweir 
1754*cdf0e10cSrcweir 	CustomAnimationDialog* pDlg = new CustomAnimationDialog( this, pSet, nPage );
1755*cdf0e10cSrcweir 	if( pDlg->Execute() )
1756*cdf0e10cSrcweir 	{
1757*cdf0e10cSrcweir 		addUndo();
1758*cdf0e10cSrcweir 		changeSelection( pDlg->getResultSet(), pSet );
1759*cdf0e10cSrcweir 		updateControls();
1760*cdf0e10cSrcweir 	}
1761*cdf0e10cSrcweir 
1762*cdf0e10cSrcweir 	delete pDlg;
1763*cdf0e10cSrcweir }
1764*cdf0e10cSrcweir 
1765*cdf0e10cSrcweir void CustomAnimationPane::onChangeCurrentPage()
1766*cdf0e10cSrcweir {
1767*cdf0e10cSrcweir 	if( mxView.is() ) try
1768*cdf0e10cSrcweir 	{
1769*cdf0e10cSrcweir 		Reference< XDrawPage > xNewPage( mxView->getCurrentPage() );
1770*cdf0e10cSrcweir 		if( xNewPage != mxCurrentPage )
1771*cdf0e10cSrcweir 		{
1772*cdf0e10cSrcweir 			mxCurrentPage = xNewPage;
1773*cdf0e10cSrcweir 			SdPage* pPage = SdPage::getImplementation( mxCurrentPage );
1774*cdf0e10cSrcweir 			if( pPage )
1775*cdf0e10cSrcweir 			{
1776*cdf0e10cSrcweir 				mpMainSequence = pPage->getMainSequence();
1777*cdf0e10cSrcweir 				mpCustomAnimationList->update( mpMainSequence );
1778*cdf0e10cSrcweir 			}
1779*cdf0e10cSrcweir 			updateControls();
1780*cdf0e10cSrcweir 		}
1781*cdf0e10cSrcweir 	}
1782*cdf0e10cSrcweir 	catch( Exception& )
1783*cdf0e10cSrcweir 	{
1784*cdf0e10cSrcweir 		DBG_ERROR( "sd::CustomAnimationPane::onChangeCurrentPage(), exception catched!" );
1785*cdf0e10cSrcweir 	}
1786*cdf0e10cSrcweir }
1787*cdf0e10cSrcweir 
1788*cdf0e10cSrcweir bool getTextSelection( const Any& rSelection, Reference< XShape >& xShape, std::list< sal_Int16 >& rParaList )
1789*cdf0e10cSrcweir {
1790*cdf0e10cSrcweir 	Reference< XTextRange > xSelectedText;
1791*cdf0e10cSrcweir 	rSelection >>= xSelectedText;
1792*cdf0e10cSrcweir 	if( xSelectedText.is() ) try
1793*cdf0e10cSrcweir 	{
1794*cdf0e10cSrcweir 		xShape.set( xSelectedText->getText(), UNO_QUERY_THROW );
1795*cdf0e10cSrcweir 
1796*cdf0e10cSrcweir 		Reference< XTextRangeCompare > xTextRangeCompare( xShape, UNO_QUERY_THROW );
1797*cdf0e10cSrcweir 		Reference< XEnumerationAccess > xParaEnumAccess( xShape, UNO_QUERY_THROW );
1798*cdf0e10cSrcweir 		Reference< XEnumeration > xParaEnum( xParaEnumAccess->createEnumeration(), UNO_QUERY_THROW );
1799*cdf0e10cSrcweir 		Reference< XTextRange > xRange;
1800*cdf0e10cSrcweir 		Reference< XTextRange > xStart( xSelectedText->getStart() );
1801*cdf0e10cSrcweir 		Reference< XTextRange > xEnd( xSelectedText->getEnd() );
1802*cdf0e10cSrcweir 
1803*cdf0e10cSrcweir 		if( xTextRangeCompare->compareRegionEnds( xStart, xEnd ) < 0 )
1804*cdf0e10cSrcweir 		{
1805*cdf0e10cSrcweir 			Reference< XTextRange > xTemp( xStart );
1806*cdf0e10cSrcweir 			xStart = xEnd;
1807*cdf0e10cSrcweir 			xEnd = xTemp;
1808*cdf0e10cSrcweir 		}
1809*cdf0e10cSrcweir 
1810*cdf0e10cSrcweir 		sal_Int16 nPara = 0;
1811*cdf0e10cSrcweir 		while( xParaEnum->hasMoreElements() )
1812*cdf0e10cSrcweir 		{
1813*cdf0e10cSrcweir 			xParaEnum->nextElement() >>= xRange;
1814*cdf0e10cSrcweir 
1815*cdf0e10cSrcweir 			// break if start of selection is prior to end of current paragraph
1816*cdf0e10cSrcweir 			if( xRange.is() && (xTextRangeCompare->compareRegionEnds( xStart, xRange ) >= 0 ) )
1817*cdf0e10cSrcweir 				break;
1818*cdf0e10cSrcweir 
1819*cdf0e10cSrcweir 			nPara++;
1820*cdf0e10cSrcweir 		}
1821*cdf0e10cSrcweir 
1822*cdf0e10cSrcweir 		while( xRange.is() )
1823*cdf0e10cSrcweir 		{
1824*cdf0e10cSrcweir 			if( xRange.is() && xRange->getString().getLength() )
1825*cdf0e10cSrcweir 				rParaList.push_back( nPara );
1826*cdf0e10cSrcweir 
1827*cdf0e10cSrcweir 			// break if end of selection is before or at end of current paragraph
1828*cdf0e10cSrcweir 			if( xRange.is() && xTextRangeCompare->compareRegionEnds( xEnd, xRange ) >= 0 )
1829*cdf0e10cSrcweir 				break;
1830*cdf0e10cSrcweir 
1831*cdf0e10cSrcweir 			nPara++;
1832*cdf0e10cSrcweir 
1833*cdf0e10cSrcweir 			if( xParaEnum->hasMoreElements() )
1834*cdf0e10cSrcweir 				xParaEnum->nextElement() >>= xRange;
1835*cdf0e10cSrcweir 			else
1836*cdf0e10cSrcweir 				xRange.clear();
1837*cdf0e10cSrcweir 		}
1838*cdf0e10cSrcweir 
1839*cdf0e10cSrcweir 		return true;
1840*cdf0e10cSrcweir 	}
1841*cdf0e10cSrcweir 	catch( Exception& e )
1842*cdf0e10cSrcweir 	{
1843*cdf0e10cSrcweir 		(void)e;
1844*cdf0e10cSrcweir 		DBG_ERROR( "sd::CustomAnimationPane::getTextSelection(), exception cought!" );
1845*cdf0e10cSrcweir 	}
1846*cdf0e10cSrcweir 
1847*cdf0e10cSrcweir 	return false;
1848*cdf0e10cSrcweir }
1849*cdf0e10cSrcweir 
1850*cdf0e10cSrcweir void CustomAnimationPane::onChange( bool bCreate )
1851*cdf0e10cSrcweir {
1852*cdf0e10cSrcweir 	bool bHasText = true;
1853*cdf0e10cSrcweir 
1854*cdf0e10cSrcweir 	// first create vector of targets for dialog preview
1855*cdf0e10cSrcweir 	std::vector< Any > aTargets;
1856*cdf0e10cSrcweir 	OUString sPresetId;
1857*cdf0e10cSrcweir 	double fDuration = 2.0f;
1858*cdf0e10cSrcweir 
1859*cdf0e10cSrcweir 	if( bCreate )
1860*cdf0e10cSrcweir 	{
1861*cdf0e10cSrcweir 		// gather shapes from the selection
1862*cdf0e10cSrcweir 		Reference< XSelectionSupplier >  xSel( mxView, UNO_QUERY_THROW );
1863*cdf0e10cSrcweir 		maViewSelection = xSel->getSelection();
1864*cdf0e10cSrcweir 
1865*cdf0e10cSrcweir 		if( maViewSelection.getValueType() == ::getCppuType((const Reference< XShapes >*)0) )
1866*cdf0e10cSrcweir 		{
1867*cdf0e10cSrcweir 			Reference< XIndexAccess > xShapes;
1868*cdf0e10cSrcweir 			maViewSelection >>= xShapes;
1869*cdf0e10cSrcweir 
1870*cdf0e10cSrcweir 			sal_Int32 nCount = xShapes->getCount();
1871*cdf0e10cSrcweir 			sal_Int32 nIndex;
1872*cdf0e10cSrcweir 			for( nIndex = 0; nIndex < nCount; nIndex++ )
1873*cdf0e10cSrcweir 			{
1874*cdf0e10cSrcweir 				Any aTarget( xShapes->getByIndex( nIndex ) );
1875*cdf0e10cSrcweir 				aTargets.push_back( aTarget );
1876*cdf0e10cSrcweir 				if( bHasText )
1877*cdf0e10cSrcweir 				{
1878*cdf0e10cSrcweir 					Reference< XText > xText;
1879*cdf0e10cSrcweir 					aTarget >>= xText;
1880*cdf0e10cSrcweir 					if( !xText.is() || xText->getString().getLength() == 0 )
1881*cdf0e10cSrcweir 						bHasText = false;
1882*cdf0e10cSrcweir 				}
1883*cdf0e10cSrcweir 			}
1884*cdf0e10cSrcweir 		}
1885*cdf0e10cSrcweir 		else if ( maViewSelection.getValueType() == ::getCppuType((const Reference< XShape >*)0) )
1886*cdf0e10cSrcweir 		{
1887*cdf0e10cSrcweir 			aTargets.push_back( maViewSelection );
1888*cdf0e10cSrcweir 			Reference< XText > xText;
1889*cdf0e10cSrcweir 			maViewSelection >>= xText;
1890*cdf0e10cSrcweir 			if( !xText.is() || xText->getString().getLength() == 0 )
1891*cdf0e10cSrcweir 				bHasText = false;
1892*cdf0e10cSrcweir 		}
1893*cdf0e10cSrcweir 		else if ( maViewSelection.getValueType() == ::getCppuType((const Reference< XTextCursor >*)0) )
1894*cdf0e10cSrcweir 		{
1895*cdf0e10cSrcweir 			Reference< XShape > xShape;
1896*cdf0e10cSrcweir 			std::list< sal_Int16 > aParaList;
1897*cdf0e10cSrcweir 			if( getTextSelection( maViewSelection, xShape, aParaList ) )
1898*cdf0e10cSrcweir 			{
1899*cdf0e10cSrcweir 				ParagraphTarget aParaTarget;
1900*cdf0e10cSrcweir 				aParaTarget.Shape = xShape;
1901*cdf0e10cSrcweir 
1902*cdf0e10cSrcweir 				std::list< sal_Int16 >::iterator aIter( aParaList.begin() );
1903*cdf0e10cSrcweir 				for( ; aIter != aParaList.end(); aIter++ )
1904*cdf0e10cSrcweir 				{
1905*cdf0e10cSrcweir 					aParaTarget.Paragraph = (*aIter);
1906*cdf0e10cSrcweir 					aTargets.push_back( makeAny( aParaTarget ) );
1907*cdf0e10cSrcweir    				}
1908*cdf0e10cSrcweir 			}
1909*cdf0e10cSrcweir 		}
1910*cdf0e10cSrcweir 		else
1911*cdf0e10cSrcweir 		{
1912*cdf0e10cSrcweir 			DBG_ERROR("sd::CustomAnimationPane::onChange(), unknown view selection!" );
1913*cdf0e10cSrcweir 			return;
1914*cdf0e10cSrcweir 		}
1915*cdf0e10cSrcweir 	}
1916*cdf0e10cSrcweir 	else
1917*cdf0e10cSrcweir 	{
1918*cdf0e10cSrcweir 		// get selected effect
1919*cdf0e10cSrcweir 		EffectSequence::iterator aIter( maListSelection.begin() );
1920*cdf0e10cSrcweir 		const EffectSequence::iterator aEnd( maListSelection.end() );
1921*cdf0e10cSrcweir 		while( aIter != aEnd )
1922*cdf0e10cSrcweir 		{
1923*cdf0e10cSrcweir 			if( !bHasText || !(*aIter)->hasText() )
1924*cdf0e10cSrcweir 				bHasText = false;
1925*cdf0e10cSrcweir 
1926*cdf0e10cSrcweir 			if( sPresetId.getLength() == 0 )
1927*cdf0e10cSrcweir 			{
1928*cdf0e10cSrcweir 				sPresetId = (*aIter)->getPresetId();
1929*cdf0e10cSrcweir 				fDuration = (*aIter)->getDuration();
1930*cdf0e10cSrcweir 			}
1931*cdf0e10cSrcweir 
1932*cdf0e10cSrcweir 			aTargets.push_back( (*aIter++)->getTarget() );
1933*cdf0e10cSrcweir 		}
1934*cdf0e10cSrcweir 	}
1935*cdf0e10cSrcweir 
1936*cdf0e10cSrcweir 	CustomAnimationCreateDialog* pDlg = new CustomAnimationCreateDialog( this, this, aTargets, bHasText, sPresetId, fDuration );
1937*cdf0e10cSrcweir 	if( pDlg->Execute() )
1938*cdf0e10cSrcweir 	{
1939*cdf0e10cSrcweir 		addUndo();
1940*cdf0e10cSrcweir 		fDuration = pDlg->getSelectedDuration();
1941*cdf0e10cSrcweir 		CustomAnimationPresetPtr pDescriptor = pDlg->getSelectedPreset();
1942*cdf0e10cSrcweir 		if( pDescriptor.get() )
1943*cdf0e10cSrcweir 		{
1944*cdf0e10cSrcweir 			if( bCreate )
1945*cdf0e10cSrcweir 			{
1946*cdf0e10cSrcweir 				mpCustomAnimationList->SelectAll( sal_False );
1947*cdf0e10cSrcweir 
1948*cdf0e10cSrcweir 				// gather shapes from the selection
1949*cdf0e10cSrcweir 				std::vector< Any >::iterator aIter( aTargets.begin() );
1950*cdf0e10cSrcweir 				const std::vector< Any >::iterator aEnd( aTargets.end() );
1951*cdf0e10cSrcweir 				bool bFirst = true;
1952*cdf0e10cSrcweir 				for( ; aIter != aEnd; aIter++ )
1953*cdf0e10cSrcweir 				{
1954*cdf0e10cSrcweir 					CustomAnimationEffectPtr pCreated = mpMainSequence->append( pDescriptor, (*aIter), fDuration );
1955*cdf0e10cSrcweir 
1956*cdf0e10cSrcweir 					// if only one shape with text and no fill or outline is selected, animate only by first level paragraphs
1957*cdf0e10cSrcweir 					if( bHasText && (aTargets.size() == 1) )
1958*cdf0e10cSrcweir 					{
1959*cdf0e10cSrcweir 						Reference< XShape > xShape( (*aIter), UNO_QUERY );
1960*cdf0e10cSrcweir 						if( xShape.is() && !hasVisibleShape( xShape ) )
1961*cdf0e10cSrcweir 						{
1962*cdf0e10cSrcweir 							mpMainSequence->createTextGroup( pCreated, 1, -1.0, sal_False, sal_False );
1963*cdf0e10cSrcweir 						}
1964*cdf0e10cSrcweir 					}
1965*cdf0e10cSrcweir 
1966*cdf0e10cSrcweir 					if( bFirst )
1967*cdf0e10cSrcweir 						bFirst = false;
1968*cdf0e10cSrcweir 					else
1969*cdf0e10cSrcweir 						pCreated->setNodeType( EffectNodeType::WITH_PREVIOUS );
1970*cdf0e10cSrcweir 
1971*cdf0e10cSrcweir 					if( pCreated.get() )
1972*cdf0e10cSrcweir 					{
1973*cdf0e10cSrcweir 						mpCustomAnimationList->select( pCreated );
1974*cdf0e10cSrcweir 					}
1975*cdf0e10cSrcweir 				}
1976*cdf0e10cSrcweir 			}
1977*cdf0e10cSrcweir 			else
1978*cdf0e10cSrcweir 			{
1979*cdf0e10cSrcweir 				MainSequenceRebuildGuard aGuard( mpMainSequence );
1980*cdf0e10cSrcweir 
1981*cdf0e10cSrcweir 				// get selected effect
1982*cdf0e10cSrcweir 				EffectSequence::iterator aIter( maListSelection.begin() );
1983*cdf0e10cSrcweir 				const EffectSequence::iterator aEnd( maListSelection.end() );
1984*cdf0e10cSrcweir 				while( aIter != aEnd )
1985*cdf0e10cSrcweir 				{
1986*cdf0e10cSrcweir 					CustomAnimationEffectPtr pEffect = (*aIter++);
1987*cdf0e10cSrcweir 
1988*cdf0e10cSrcweir 					EffectSequenceHelper* pEffectSequence = pEffect->getEffectSequence();
1989*cdf0e10cSrcweir 					if( !pEffectSequence )
1990*cdf0e10cSrcweir 						pEffectSequence = mpMainSequence.get();
1991*cdf0e10cSrcweir 
1992*cdf0e10cSrcweir 					pEffectSequence->replace( pEffect, pDescriptor, fDuration );
1993*cdf0e10cSrcweir 				}
1994*cdf0e10cSrcweir 			}
1995*cdf0e10cSrcweir 		}
1996*cdf0e10cSrcweir 		else
1997*cdf0e10cSrcweir 		{
1998*cdf0e10cSrcweir 			PathKind eKind = pDlg->getCreatePathKind();
1999*cdf0e10cSrcweir 			if( eKind != NONE )
2000*cdf0e10cSrcweir 				createPath( eKind, aTargets, fDuration );
2001*cdf0e10cSrcweir 		}
2002*cdf0e10cSrcweir 		mrBase.GetDocShell()->SetModified();
2003*cdf0e10cSrcweir 	}
2004*cdf0e10cSrcweir 
2005*cdf0e10cSrcweir 	delete pDlg;
2006*cdf0e10cSrcweir 
2007*cdf0e10cSrcweir 	updateControls();
2008*cdf0e10cSrcweir 
2009*cdf0e10cSrcweir 	// stop running preview from dialog
2010*cdf0e10cSrcweir 	SlideShow::Stop( mrBase );
2011*cdf0e10cSrcweir }
2012*cdf0e10cSrcweir 
2013*cdf0e10cSrcweir void CustomAnimationPane::createPath( PathKind eKind, std::vector< Any >& rTargets, double fDuration)
2014*cdf0e10cSrcweir {
2015*cdf0e10cSrcweir 	sal_uInt16 nSID = 0;
2016*cdf0e10cSrcweir 
2017*cdf0e10cSrcweir 	switch( eKind )
2018*cdf0e10cSrcweir 	{
2019*cdf0e10cSrcweir 	case CURVE:		nSID = SID_DRAW_BEZIER_NOFILL; break;
2020*cdf0e10cSrcweir 	case POLYGON:	nSID = SID_DRAW_POLYGON_NOFILL; break;
2021*cdf0e10cSrcweir 	case FREEFORM:	nSID = SID_DRAW_FREELINE_NOFILL; break;
2022*cdf0e10cSrcweir 	default: break;
2023*cdf0e10cSrcweir 	}
2024*cdf0e10cSrcweir 
2025*cdf0e10cSrcweir 	if( nSID )
2026*cdf0e10cSrcweir 	{
2027*cdf0e10cSrcweir 		DrawViewShell* pViewShell = dynamic_cast< DrawViewShell* >(
2028*cdf0e10cSrcweir 		    FrameworkHelper::Instance(mrBase)->GetViewShell(FrameworkHelper::msCenterPaneURL).get());
2029*cdf0e10cSrcweir 
2030*cdf0e10cSrcweir 		if( pViewShell )
2031*cdf0e10cSrcweir 		{
2032*cdf0e10cSrcweir 			DrawView* pView = pViewShell->GetDrawView();
2033*cdf0e10cSrcweir 			if( pView )
2034*cdf0e10cSrcweir 				pView->UnmarkAllObj();
2035*cdf0e10cSrcweir 
2036*cdf0e10cSrcweir 			std::vector< Any > aTargets( 1, Any( fDuration ) );
2037*cdf0e10cSrcweir 			aTargets.insert( aTargets.end(), rTargets.begin(), rTargets.end() );
2038*cdf0e10cSrcweir 			Sequence< Any > aTargetSequence( comphelper::containerToSequence( aTargets ) );
2039*cdf0e10cSrcweir 			const SfxUnoAnyItem aItem( SID_ADD_MOTION_PATH, Any( aTargetSequence ) );
2040*cdf0e10cSrcweir 			pViewShell->GetViewFrame()->GetDispatcher()->Execute( nSID, SFX_CALLMODE_ASYNCHRON, &aItem, 0 );
2041*cdf0e10cSrcweir 		}
2042*cdf0e10cSrcweir 	}
2043*cdf0e10cSrcweir }
2044*cdf0e10cSrcweir 
2045*cdf0e10cSrcweir void CustomAnimationPane::onRemove()
2046*cdf0e10cSrcweir {
2047*cdf0e10cSrcweir 	if( !maListSelection.empty() )
2048*cdf0e10cSrcweir 	{
2049*cdf0e10cSrcweir 		addUndo();
2050*cdf0e10cSrcweir 
2051*cdf0e10cSrcweir 		MainSequenceRebuildGuard aGuard( mpMainSequence );
2052*cdf0e10cSrcweir 
2053*cdf0e10cSrcweir 		EffectSequence aList( maListSelection );
2054*cdf0e10cSrcweir 
2055*cdf0e10cSrcweir 		EffectSequence::iterator aIter( aList.begin() );
2056*cdf0e10cSrcweir 		const EffectSequence::iterator aEnd( aList.end() );
2057*cdf0e10cSrcweir 		while( aIter != aEnd )
2058*cdf0e10cSrcweir 		{
2059*cdf0e10cSrcweir 			CustomAnimationEffectPtr pEffect = (*aIter++);
2060*cdf0e10cSrcweir 			if( pEffect->getEffectSequence() )
2061*cdf0e10cSrcweir 				pEffect->getEffectSequence()->remove( pEffect );
2062*cdf0e10cSrcweir 		}
2063*cdf0e10cSrcweir 
2064*cdf0e10cSrcweir 		maListSelection.clear();
2065*cdf0e10cSrcweir 		mrBase.GetDocShell()->SetModified();
2066*cdf0e10cSrcweir 	}
2067*cdf0e10cSrcweir }
2068*cdf0e10cSrcweir 
2069*cdf0e10cSrcweir void CustomAnimationPane::remove( CustomAnimationEffectPtr& pEffect )
2070*cdf0e10cSrcweir {
2071*cdf0e10cSrcweir 	if( pEffect->getEffectSequence() )
2072*cdf0e10cSrcweir 	{
2073*cdf0e10cSrcweir 		addUndo();
2074*cdf0e10cSrcweir 		pEffect->getEffectSequence()->remove( pEffect );
2075*cdf0e10cSrcweir 		mrBase.GetDocShell()->SetModified();
2076*cdf0e10cSrcweir 	}
2077*cdf0e10cSrcweir }
2078*cdf0e10cSrcweir 
2079*cdf0e10cSrcweir void CustomAnimationPane::onChangeStart()
2080*cdf0e10cSrcweir {
2081*cdf0e10cSrcweir 	if( mpLBStart->GetSelectEntryCount() == 1 )
2082*cdf0e10cSrcweir 	{
2083*cdf0e10cSrcweir 		sal_Int16 nNodeType;
2084*cdf0e10cSrcweir 		sal_uInt16 nPos= mpLBStart->GetSelectEntryPos();
2085*cdf0e10cSrcweir 		switch( nPos )
2086*cdf0e10cSrcweir 		{
2087*cdf0e10cSrcweir 		case 0:	nNodeType = EffectNodeType::ON_CLICK; break;
2088*cdf0e10cSrcweir 		case 1:	nNodeType = EffectNodeType::WITH_PREVIOUS; break;
2089*cdf0e10cSrcweir 		case 2:	nNodeType = EffectNodeType::AFTER_PREVIOUS; break;
2090*cdf0e10cSrcweir 		default:
2091*cdf0e10cSrcweir 			return;
2092*cdf0e10cSrcweir 		}
2093*cdf0e10cSrcweir 
2094*cdf0e10cSrcweir 		onChangeStart( nNodeType );
2095*cdf0e10cSrcweir 	}
2096*cdf0e10cSrcweir }
2097*cdf0e10cSrcweir 
2098*cdf0e10cSrcweir void CustomAnimationPane::onChangeStart( sal_Int16 nNodeType )
2099*cdf0e10cSrcweir {
2100*cdf0e10cSrcweir 	addUndo();
2101*cdf0e10cSrcweir 
2102*cdf0e10cSrcweir 	MainSequenceRebuildGuard aGuard( mpMainSequence );
2103*cdf0e10cSrcweir 
2104*cdf0e10cSrcweir 	bool bNeedRebuild = false;
2105*cdf0e10cSrcweir 
2106*cdf0e10cSrcweir 	EffectSequence::iterator aIter( maListSelection.begin() );
2107*cdf0e10cSrcweir 	const EffectSequence::iterator aEnd( maListSelection.end() );
2108*cdf0e10cSrcweir 	while( aIter != aEnd )
2109*cdf0e10cSrcweir 	{
2110*cdf0e10cSrcweir 		CustomAnimationEffectPtr pEffect = (*aIter++);
2111*cdf0e10cSrcweir 		if( pEffect->getNodeType() != nNodeType )
2112*cdf0e10cSrcweir 		{
2113*cdf0e10cSrcweir 			pEffect->setNodeType( nNodeType );
2114*cdf0e10cSrcweir 			bNeedRebuild = true;
2115*cdf0e10cSrcweir 		}
2116*cdf0e10cSrcweir 	}
2117*cdf0e10cSrcweir 
2118*cdf0e10cSrcweir 	if( bNeedRebuild )
2119*cdf0e10cSrcweir 	{
2120*cdf0e10cSrcweir 		mpMainSequence->rebuild();
2121*cdf0e10cSrcweir 		updateControls();
2122*cdf0e10cSrcweir 		mrBase.GetDocShell()->SetModified();
2123*cdf0e10cSrcweir 	}
2124*cdf0e10cSrcweir }
2125*cdf0e10cSrcweir 
2126*cdf0e10cSrcweir void CustomAnimationPane::onChangeProperty()
2127*cdf0e10cSrcweir {
2128*cdf0e10cSrcweir 	if( mpLBProperty->getSubControl() )
2129*cdf0e10cSrcweir 	{
2130*cdf0e10cSrcweir 		addUndo();
2131*cdf0e10cSrcweir 
2132*cdf0e10cSrcweir 		MainSequenceRebuildGuard aGuard( mpMainSequence );
2133*cdf0e10cSrcweir 
2134*cdf0e10cSrcweir 		const Any aValue( mpLBProperty->getSubControl()->getValue() );
2135*cdf0e10cSrcweir 
2136*cdf0e10cSrcweir 		bool bNeedUpdate = false;
2137*cdf0e10cSrcweir 
2138*cdf0e10cSrcweir 		// change selected effect
2139*cdf0e10cSrcweir 		EffectSequence::iterator aIter( maListSelection.begin() );
2140*cdf0e10cSrcweir 		const EffectSequence::iterator aEnd( maListSelection.end() );
2141*cdf0e10cSrcweir 		while( aIter != aEnd )
2142*cdf0e10cSrcweir 		{
2143*cdf0e10cSrcweir 			CustomAnimationEffectPtr pEffect = (*aIter++);
2144*cdf0e10cSrcweir 
2145*cdf0e10cSrcweir 			if( setProperty1Value( mnPropertyType, pEffect, aValue ) )
2146*cdf0e10cSrcweir 				bNeedUpdate = true;
2147*cdf0e10cSrcweir 		}
2148*cdf0e10cSrcweir 
2149*cdf0e10cSrcweir 		if( bNeedUpdate )
2150*cdf0e10cSrcweir 		{
2151*cdf0e10cSrcweir 			mpMainSequence->rebuild();
2152*cdf0e10cSrcweir 			updateControls();
2153*cdf0e10cSrcweir 			mrBase.GetDocShell()->SetModified();
2154*cdf0e10cSrcweir 		}
2155*cdf0e10cSrcweir 
2156*cdf0e10cSrcweir 		onPreview( false );
2157*cdf0e10cSrcweir 	}
2158*cdf0e10cSrcweir }
2159*cdf0e10cSrcweir 
2160*cdf0e10cSrcweir void CustomAnimationPane::onChangeSpeed()
2161*cdf0e10cSrcweir {
2162*cdf0e10cSrcweir 	if( mpCBSpeed->GetSelectEntryCount() == 1 )
2163*cdf0e10cSrcweir 	{
2164*cdf0e10cSrcweir 		addUndo();
2165*cdf0e10cSrcweir 
2166*cdf0e10cSrcweir 		MainSequenceRebuildGuard aGuard( mpMainSequence );
2167*cdf0e10cSrcweir 
2168*cdf0e10cSrcweir 		double fDuration;
2169*cdf0e10cSrcweir 
2170*cdf0e10cSrcweir 		sal_uInt16 nPos= mpCBSpeed->GetSelectEntryPos();
2171*cdf0e10cSrcweir 
2172*cdf0e10cSrcweir 		switch( nPos )
2173*cdf0e10cSrcweir 		{
2174*cdf0e10cSrcweir 		case 0: fDuration = 5.0; break;
2175*cdf0e10cSrcweir 		case 1: fDuration = 3.0; break;
2176*cdf0e10cSrcweir 		case 2: fDuration = 2.0; break;
2177*cdf0e10cSrcweir 		case 3: fDuration = 1.0; break;
2178*cdf0e10cSrcweir 		case 4: fDuration = 0.5; break;
2179*cdf0e10cSrcweir 		default:
2180*cdf0e10cSrcweir 			return;
2181*cdf0e10cSrcweir 		}
2182*cdf0e10cSrcweir 
2183*cdf0e10cSrcweir 		// change selected effect
2184*cdf0e10cSrcweir 		EffectSequence::iterator aIter( maListSelection.begin() );
2185*cdf0e10cSrcweir 		const EffectSequence::iterator aEnd( maListSelection.end() );
2186*cdf0e10cSrcweir 		while( aIter != aEnd )
2187*cdf0e10cSrcweir 		{
2188*cdf0e10cSrcweir 			CustomAnimationEffectPtr pEffect = (*aIter++);
2189*cdf0e10cSrcweir 			pEffect->setDuration( fDuration );
2190*cdf0e10cSrcweir 		}
2191*cdf0e10cSrcweir 
2192*cdf0e10cSrcweir 		mpMainSequence->rebuild();
2193*cdf0e10cSrcweir 		updateControls();
2194*cdf0e10cSrcweir 		mrBase.GetDocShell()->SetModified();
2195*cdf0e10cSrcweir 
2196*cdf0e10cSrcweir 		onPreview( false );
2197*cdf0e10cSrcweir 	}
2198*cdf0e10cSrcweir }
2199*cdf0e10cSrcweir 
2200*cdf0e10cSrcweir /// this link is called when the property box is modified by the user
2201*cdf0e10cSrcweir IMPL_LINK( CustomAnimationPane, implPropertyHdl, Control*, EMPTYARG )
2202*cdf0e10cSrcweir {
2203*cdf0e10cSrcweir 	onChangeProperty();
2204*cdf0e10cSrcweir 	return 0;
2205*cdf0e10cSrcweir }
2206*cdf0e10cSrcweir 
2207*cdf0e10cSrcweir /// this link is called when one of the controls is modified
2208*cdf0e10cSrcweir IMPL_LINK( CustomAnimationPane, implControlHdl, Control*, pControl )
2209*cdf0e10cSrcweir {
2210*cdf0e10cSrcweir 	if( pControl == mpPBAddEffect )
2211*cdf0e10cSrcweir 		onChange(true);
2212*cdf0e10cSrcweir 	else if( pControl == mpPBChangeEffect )
2213*cdf0e10cSrcweir 		onChange(false);
2214*cdf0e10cSrcweir 	else if( pControl == mpPBRemoveEffect )
2215*cdf0e10cSrcweir 		onRemove();
2216*cdf0e10cSrcweir 	else if( pControl == mpLBStart )
2217*cdf0e10cSrcweir 		onChangeStart();
2218*cdf0e10cSrcweir 	else if( pControl == mpCBSpeed )
2219*cdf0e10cSrcweir 		onChangeSpeed();
2220*cdf0e10cSrcweir 	else if( pControl == mpPBPropertyMore )
2221*cdf0e10cSrcweir 		showOptions();
2222*cdf0e10cSrcweir 	else if( pControl == mpPBMoveUp )
2223*cdf0e10cSrcweir 		moveSelection( true );
2224*cdf0e10cSrcweir 	else if( pControl == mpPBMoveDown )
2225*cdf0e10cSrcweir 		moveSelection( false );
2226*cdf0e10cSrcweir 	else if( pControl == mpPBPlay )
2227*cdf0e10cSrcweir 		onPreview( true );
2228*cdf0e10cSrcweir 	else if( pControl == mpPBSlideShow )
2229*cdf0e10cSrcweir 	{
2230*cdf0e10cSrcweir 		mrBase.StartPresentation();
2231*cdf0e10cSrcweir 	}
2232*cdf0e10cSrcweir 	else if( pControl == mpCBAutoPreview )
2233*cdf0e10cSrcweir 	{
2234*cdf0e10cSrcweir 		SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
2235*cdf0e10cSrcweir 		pOptions->SetPreviewChangedEffects( mpCBAutoPreview->IsChecked() ? sal_True : sal_False );
2236*cdf0e10cSrcweir 	}
2237*cdf0e10cSrcweir 
2238*cdf0e10cSrcweir 	updateControls();
2239*cdf0e10cSrcweir 
2240*cdf0e10cSrcweir 	return 0;
2241*cdf0e10cSrcweir }
2242*cdf0e10cSrcweir 
2243*cdf0e10cSrcweir IMPL_LINK(CustomAnimationPane, lateInitCallback, Timer*, EMPTYARG )
2244*cdf0e10cSrcweir {
2245*cdf0e10cSrcweir     // Call getPresets() to initiate the (expensive) construction of the
2246*cdf0e10cSrcweir     // presets list.
2247*cdf0e10cSrcweir     getPresets();
2248*cdf0e10cSrcweir 
2249*cdf0e10cSrcweir     // update selection and control states
2250*cdf0e10cSrcweir     onSelectionChanged();
2251*cdf0e10cSrcweir 
2252*cdf0e10cSrcweir     return 0;
2253*cdf0e10cSrcweir }
2254*cdf0e10cSrcweir 
2255*cdf0e10cSrcweir void CustomAnimationPane::moveSelection( bool bUp )
2256*cdf0e10cSrcweir {
2257*cdf0e10cSrcweir 	if( maListSelection.empty() )
2258*cdf0e10cSrcweir 		return;
2259*cdf0e10cSrcweir 
2260*cdf0e10cSrcweir 	EffectSequenceHelper* pSequence = maListSelection.front()->getEffectSequence();
2261*cdf0e10cSrcweir 	if( pSequence == 0 )
2262*cdf0e10cSrcweir 		return;
2263*cdf0e10cSrcweir 
2264*cdf0e10cSrcweir 	addUndo();
2265*cdf0e10cSrcweir 
2266*cdf0e10cSrcweir 	bool bChanged = false;
2267*cdf0e10cSrcweir 
2268*cdf0e10cSrcweir 	MainSequenceRebuildGuard aGuard( mpMainSequence );
2269*cdf0e10cSrcweir 	EffectSequence& rEffectSequence = pSequence->getSequence();
2270*cdf0e10cSrcweir 
2271*cdf0e10cSrcweir 	if( bUp )
2272*cdf0e10cSrcweir 	{
2273*cdf0e10cSrcweir 		EffectSequence::iterator aIter( maListSelection.begin() );
2274*cdf0e10cSrcweir 		const EffectSequence::iterator aEnd( maListSelection.end() );
2275*cdf0e10cSrcweir 
2276*cdf0e10cSrcweir 		while( aIter != aEnd )
2277*cdf0e10cSrcweir 		{
2278*cdf0e10cSrcweir 			CustomAnimationEffectPtr pEffect = (*aIter++);
2279*cdf0e10cSrcweir 
2280*cdf0e10cSrcweir 			EffectSequence::iterator aEffectPos( pSequence->find( pEffect ) );
2281*cdf0e10cSrcweir 			if( aEffectPos != rEffectSequence.end() )
2282*cdf0e10cSrcweir 			{
2283*cdf0e10cSrcweir 				EffectSequence::iterator aInsertPos( rEffectSequence.erase( aEffectPos ) );
2284*cdf0e10cSrcweir 
2285*cdf0e10cSrcweir 				if( aInsertPos != rEffectSequence.begin() )
2286*cdf0e10cSrcweir 				{
2287*cdf0e10cSrcweir 					aInsertPos--;
2288*cdf0e10cSrcweir 					while( (aInsertPos != rEffectSequence.begin()) && !mpCustomAnimationList->isExpanded(*aInsertPos))
2289*cdf0e10cSrcweir 						aInsertPos--;
2290*cdf0e10cSrcweir 
2291*cdf0e10cSrcweir 					rEffectSequence.insert( aInsertPos, pEffect );
2292*cdf0e10cSrcweir 				}
2293*cdf0e10cSrcweir 				else
2294*cdf0e10cSrcweir 				{
2295*cdf0e10cSrcweir 					rEffectSequence.push_front( pEffect );
2296*cdf0e10cSrcweir 				}
2297*cdf0e10cSrcweir 				bChanged = true;
2298*cdf0e10cSrcweir 			}
2299*cdf0e10cSrcweir 		}
2300*cdf0e10cSrcweir 	}
2301*cdf0e10cSrcweir 	else
2302*cdf0e10cSrcweir 	{
2303*cdf0e10cSrcweir 		EffectSequence::reverse_iterator aIter( maListSelection.rbegin() );
2304*cdf0e10cSrcweir 		const EffectSequence::reverse_iterator aEnd( maListSelection.rend() );
2305*cdf0e10cSrcweir 
2306*cdf0e10cSrcweir 		while( aIter != aEnd )
2307*cdf0e10cSrcweir 		{
2308*cdf0e10cSrcweir 			CustomAnimationEffectPtr pEffect = (*aIter++);
2309*cdf0e10cSrcweir 
2310*cdf0e10cSrcweir 			EffectSequence::iterator aEffectPos( pSequence->find( pEffect ) );
2311*cdf0e10cSrcweir 			if( aEffectPos != rEffectSequence.end() )
2312*cdf0e10cSrcweir 			{
2313*cdf0e10cSrcweir 				EffectSequence::iterator aInsertPos( rEffectSequence.erase( aEffectPos ) );
2314*cdf0e10cSrcweir 
2315*cdf0e10cSrcweir 				if( aInsertPos != rEffectSequence.end() )
2316*cdf0e10cSrcweir 				{
2317*cdf0e10cSrcweir 					aInsertPos++;
2318*cdf0e10cSrcweir 					while( (aInsertPos != rEffectSequence.end()) && !mpCustomAnimationList->isExpanded(*aInsertPos))
2319*cdf0e10cSrcweir 						aInsertPos++;
2320*cdf0e10cSrcweir 
2321*cdf0e10cSrcweir 					rEffectSequence.insert( aInsertPos, pEffect );
2322*cdf0e10cSrcweir 				}
2323*cdf0e10cSrcweir 				else
2324*cdf0e10cSrcweir 				{
2325*cdf0e10cSrcweir 					rEffectSequence.push_back( pEffect );
2326*cdf0e10cSrcweir 				}
2327*cdf0e10cSrcweir 				bChanged = true;
2328*cdf0e10cSrcweir 			}
2329*cdf0e10cSrcweir 		}
2330*cdf0e10cSrcweir 	}
2331*cdf0e10cSrcweir 
2332*cdf0e10cSrcweir 	if( bChanged )
2333*cdf0e10cSrcweir 	{
2334*cdf0e10cSrcweir 		mpMainSequence->rebuild();
2335*cdf0e10cSrcweir 		updateControls();
2336*cdf0e10cSrcweir 		mrBase.GetDocShell()->SetModified();
2337*cdf0e10cSrcweir 	}
2338*cdf0e10cSrcweir }
2339*cdf0e10cSrcweir 
2340*cdf0e10cSrcweir void CustomAnimationPane::onPreview( bool bForcePreview )
2341*cdf0e10cSrcweir {
2342*cdf0e10cSrcweir 	if( !bForcePreview && !mpCBAutoPreview->IsChecked() )
2343*cdf0e10cSrcweir 		return;
2344*cdf0e10cSrcweir 
2345*cdf0e10cSrcweir 	if( maListSelection.empty() )
2346*cdf0e10cSrcweir 	{
2347*cdf0e10cSrcweir 		rtl::Reference< MotionPathTag > xMotionPathTag;
2348*cdf0e10cSrcweir 		MotionPathTagVector::iterator aIter;
2349*cdf0e10cSrcweir 		for( aIter = maMotionPathTags.begin(); aIter != maMotionPathTags.end(); aIter++ )
2350*cdf0e10cSrcweir 		{
2351*cdf0e10cSrcweir 			if( (*aIter)->isSelected() )
2352*cdf0e10cSrcweir 			{
2353*cdf0e10cSrcweir 				xMotionPathTag = (*aIter);
2354*cdf0e10cSrcweir 				break;
2355*cdf0e10cSrcweir 			}
2356*cdf0e10cSrcweir 		}
2357*cdf0e10cSrcweir 
2358*cdf0e10cSrcweir 		if( xMotionPathTag.is() )
2359*cdf0e10cSrcweir 		{
2360*cdf0e10cSrcweir 			MainSequencePtr pSequence( new MainSequence() );
2361*cdf0e10cSrcweir 			pSequence->append( xMotionPathTag->getEffect()->clone() );
2362*cdf0e10cSrcweir 			preview( pSequence->getRootNode() );
2363*cdf0e10cSrcweir 		}
2364*cdf0e10cSrcweir 		else
2365*cdf0e10cSrcweir 		{
2366*cdf0e10cSrcweir 			Reference< XAnimationNodeSupplier > xNodeSupplier( mxCurrentPage, UNO_QUERY );
2367*cdf0e10cSrcweir 			if( !xNodeSupplier.is() )
2368*cdf0e10cSrcweir 				return;
2369*cdf0e10cSrcweir 
2370*cdf0e10cSrcweir 			preview( xNodeSupplier->getAnimationNode() );
2371*cdf0e10cSrcweir 		}
2372*cdf0e10cSrcweir 	}
2373*cdf0e10cSrcweir 	else
2374*cdf0e10cSrcweir 	{
2375*cdf0e10cSrcweir 		MainSequencePtr pSequence( new MainSequence() );
2376*cdf0e10cSrcweir 
2377*cdf0e10cSrcweir 		EffectSequence::iterator aIter( maListSelection.begin() );
2378*cdf0e10cSrcweir 		const EffectSequence::iterator aEnd( maListSelection.end() );
2379*cdf0e10cSrcweir 
2380*cdf0e10cSrcweir 		while( aIter != aEnd )
2381*cdf0e10cSrcweir 		{
2382*cdf0e10cSrcweir 			CustomAnimationEffectPtr pEffect = (*aIter++);
2383*cdf0e10cSrcweir 			pSequence->append( pEffect->clone() );
2384*cdf0e10cSrcweir 		}
2385*cdf0e10cSrcweir 
2386*cdf0e10cSrcweir 		preview( pSequence->getRootNode() );
2387*cdf0e10cSrcweir 	}
2388*cdf0e10cSrcweir }
2389*cdf0e10cSrcweir 
2390*cdf0e10cSrcweir void CustomAnimationPane::preview( const Reference< XAnimationNode >& xAnimationNode )
2391*cdf0e10cSrcweir {
2392*cdf0e10cSrcweir 	Reference< XTimeContainer > xRoot(::comphelper::getProcessServiceFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.animations.ParallelTimeContainer"))), UNO_QUERY);
2393*cdf0e10cSrcweir 	if( xRoot.is() )
2394*cdf0e10cSrcweir 	{
2395*cdf0e10cSrcweir 		Sequence< ::com::sun::star::beans::NamedValue > aUserData( 1 );
2396*cdf0e10cSrcweir 		aUserData[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "node-type" ) );
2397*cdf0e10cSrcweir 		aUserData[0].Value <<= ::com::sun::star::presentation::EffectNodeType::TIMING_ROOT;
2398*cdf0e10cSrcweir 		xRoot->setUserData( aUserData );
2399*cdf0e10cSrcweir 		xRoot->appendChild( xAnimationNode );
2400*cdf0e10cSrcweir 
2401*cdf0e10cSrcweir 		Reference< XAnimationNode > xNode( xRoot, UNO_QUERY );
2402*cdf0e10cSrcweir 		SlideShow::StartPreview( mrBase, mxCurrentPage, xNode );
2403*cdf0e10cSrcweir 	}
2404*cdf0e10cSrcweir }
2405*cdf0e10cSrcweir 
2406*cdf0e10cSrcweir 
2407*cdf0e10cSrcweir // ICustomAnimationListController
2408*cdf0e10cSrcweir void CustomAnimationPane::onSelect()
2409*cdf0e10cSrcweir {
2410*cdf0e10cSrcweir 	maListSelection = mpCustomAnimationList->getSelection();
2411*cdf0e10cSrcweir 	updateControls();
2412*cdf0e10cSrcweir 	markShapesFromSelectedEffects();
2413*cdf0e10cSrcweir }
2414*cdf0e10cSrcweir 
2415*cdf0e10cSrcweir 
2416*cdf0e10cSrcweir 
2417*cdf0e10cSrcweir 
2418*cdf0e10cSrcweir const CustomAnimationPresets& CustomAnimationPane::getPresets (void)
2419*cdf0e10cSrcweir {
2420*cdf0e10cSrcweir     if (mpCustomAnimationPresets == NULL)
2421*cdf0e10cSrcweir         mpCustomAnimationPresets = &CustomAnimationPresets::getCustomAnimationPresets();
2422*cdf0e10cSrcweir     return *mpCustomAnimationPresets;
2423*cdf0e10cSrcweir }
2424*cdf0e10cSrcweir 
2425*cdf0e10cSrcweir 
2426*cdf0e10cSrcweir 
2427*cdf0e10cSrcweir void CustomAnimationPane::markShapesFromSelectedEffects()
2428*cdf0e10cSrcweir {
2429*cdf0e10cSrcweir 	if( !maSelectionLock.isLocked() )
2430*cdf0e10cSrcweir 	{
2431*cdf0e10cSrcweir 		ScopeLockGuard aGuard( maSelectionLock );
2432*cdf0e10cSrcweir 		DrawViewShell* pViewShell = dynamic_cast< DrawViewShell* >(
2433*cdf0e10cSrcweir 			FrameworkHelper::Instance(mrBase)->GetViewShell(FrameworkHelper::msCenterPaneURL).get());
2434*cdf0e10cSrcweir 		DrawView* pView = pViewShell ? pViewShell->GetDrawView() : NULL;
2435*cdf0e10cSrcweir 
2436*cdf0e10cSrcweir 		if( pView )
2437*cdf0e10cSrcweir 		{
2438*cdf0e10cSrcweir 			pView->UnmarkAllObj();
2439*cdf0e10cSrcweir 			EffectSequence::iterator aIter( maListSelection.begin() );
2440*cdf0e10cSrcweir 			const EffectSequence::iterator aEnd( maListSelection.end() );
2441*cdf0e10cSrcweir 			while( aIter != aEnd )
2442*cdf0e10cSrcweir 			{
2443*cdf0e10cSrcweir 				CustomAnimationEffectPtr pEffect = (*aIter++);
2444*cdf0e10cSrcweir 
2445*cdf0e10cSrcweir 				Reference< XShape > xShape( pEffect->getTargetShape() );
2446*cdf0e10cSrcweir 				SdrObject* pObj = GetSdrObjectFromXShape( xShape );
2447*cdf0e10cSrcweir 				if( pObj )
2448*cdf0e10cSrcweir 					pView->MarkObj(pObj, pView->GetSdrPageView(), sal_False, sal_False);
2449*cdf0e10cSrcweir 			}
2450*cdf0e10cSrcweir 		}
2451*cdf0e10cSrcweir 	}
2452*cdf0e10cSrcweir }
2453*cdf0e10cSrcweir 
2454*cdf0e10cSrcweir 
2455*cdf0e10cSrcweir void CustomAnimationPane::updatePathFromMotionPathTag( const rtl::Reference< MotionPathTag >& xTag )
2456*cdf0e10cSrcweir {
2457*cdf0e10cSrcweir 	MainSequenceRebuildGuard aGuard( mpMainSequence );
2458*cdf0e10cSrcweir 	if( xTag.is() )
2459*cdf0e10cSrcweir 	{
2460*cdf0e10cSrcweir 		SdrPathObj* pPathObj = xTag->getPathObj();
2461*cdf0e10cSrcweir 		CustomAnimationEffectPtr pEffect = xTag->getEffect();
2462*cdf0e10cSrcweir 		if( (pPathObj != 0) && pEffect.get() != 0 )
2463*cdf0e10cSrcweir 		{
2464*cdf0e10cSrcweir 			::svl::IUndoManager* pManager = mrBase.GetDocShell()->GetUndoManager();
2465*cdf0e10cSrcweir 			if( pManager )
2466*cdf0e10cSrcweir 			{
2467*cdf0e10cSrcweir 				SdPage* pPage = SdPage::getImplementation( mxCurrentPage );
2468*cdf0e10cSrcweir 				if( pPage )
2469*cdf0e10cSrcweir 					pManager->AddUndoAction( new UndoAnimationPath( mrBase.GetDocShell()->GetDoc(), pPage, pEffect->getNode() ) );
2470*cdf0e10cSrcweir 			}
2471*cdf0e10cSrcweir 
2472*cdf0e10cSrcweir 			pEffect->updatePathFromSdrPathObj( *pPathObj );
2473*cdf0e10cSrcweir 		}
2474*cdf0e10cSrcweir 	}
2475*cdf0e10cSrcweir }
2476*cdf0e10cSrcweir 
2477*cdf0e10cSrcweir // ====================================================================
2478*cdf0e10cSrcweir 
2479*cdf0e10cSrcweir ::Window * createCustomAnimationPanel( ::Window* pParent, ViewShellBase& rBase )
2480*cdf0e10cSrcweir {
2481*cdf0e10cSrcweir 	DialogListBox* pWindow = 0;
2482*cdf0e10cSrcweir 
2483*cdf0e10cSrcweir 	DrawDocShell* pDocSh = rBase.GetDocShell();
2484*cdf0e10cSrcweir 	if( pDocSh )
2485*cdf0e10cSrcweir 	{
2486*cdf0e10cSrcweir 		pWindow = new DialogListBox( pParent, WB_CLIPCHILDREN|WB_TABSTOP|WB_AUTOHSCROLL );
2487*cdf0e10cSrcweir 
2488*cdf0e10cSrcweir 		Size aMinSize( pWindow->LogicToPixel( Size( 80, 256 ), MAP_APPFONT ) );
2489*cdf0e10cSrcweir 		::Window* pPaneWindow = new CustomAnimationPane( pWindow, rBase, aMinSize );
2490*cdf0e10cSrcweir 		pWindow->SetChildWindow( pPaneWindow, aMinSize );
2491*cdf0e10cSrcweir 		pWindow->SetText( pPaneWindow->GetText() );
2492*cdf0e10cSrcweir 	}
2493*cdf0e10cSrcweir 
2494*cdf0e10cSrcweir 	return pWindow;
2495*cdf0e10cSrcweir }
2496*cdf0e10cSrcweir 
2497*cdf0e10cSrcweir 
2498*cdf0e10cSrcweir 
2499*cdf0e10cSrcweir }
2500