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