1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "fuoaprms.hxx"
23 #include <svx/svdpagv.hxx>
24 #include <editeng/colritem.hxx>
25 #include <svx/svdundo.hxx>
26 #include <vcl/group.hxx>
27 #include <vcl/fixed.hxx>
28 #include <sfx2/objsh.hxx>
29 #include <sfx2/request.hxx>
30 #include <sfx2/viewfrm.hxx>
31 #include <vcl/msgbox.hxx>
32 #include <svl/aeitem.hxx>
33 #include "svx/xtable.hxx"
35 #include "strings.hrc"
37 #include "drawdoc.hxx"
38 #include "ViewShell.hxx"
39 #include "anminfo.hxx"
40 #include "unoaprms.hxx"
41 #include "sdundogr.hxx"
43 #include "sdabstdlg.hxx"
44 #include "sdresid.hxx"
45 #include <tools/helpers.hxx>
46 #include <basegfx/polygon/b2dpolygon.hxx>
47 #include <boost/scoped_ptr.hpp>
49 using namespace ::com::sun::star
;
53 TYPEINIT1( FuObjectAnimationParameters
, FuPoor
);
55 #define ATTR_MISSING 0 ///< Attribute missing
56 #define ATTR_MIXED 1 ///< Attribute ambiguous (on multi-selection)
57 #define ATTR_SET 2 ///< Attribute unique
59 FuObjectAnimationParameters::FuObjectAnimationParameters (
65 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
69 rtl::Reference
<FuPoor
> FuObjectAnimationParameters::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
71 rtl::Reference
<FuPoor
> xFunc( new FuObjectAnimationParameters( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
72 xFunc
->DoExecute(rReq
);
76 void FuObjectAnimationParameters::DoExecute( SfxRequest
& rReq
)
78 ::svl::IUndoManager
* pUndoMgr
= mpViewShell
->GetViewFrame()->GetObjectShell()->GetUndoManager();
80 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
81 const size_t nCount
= rMarkList
.GetMarkCount();
83 short nAnimationSet
= ATTR_MISSING
;
84 short nEffectSet
= ATTR_MISSING
;
85 short nTextEffectSet
= ATTR_MISSING
;
86 short nSpeedSet
= ATTR_MISSING
;
87 short nFadeColorSet
= ATTR_MISSING
;
88 short nFadeOutSet
= ATTR_MISSING
;
89 short nInvisibleSet
= ATTR_MISSING
;
90 short nSoundOnSet
= ATTR_MISSING
;
91 short nSoundFileSet
= ATTR_MISSING
;
92 short nPlayFullSet
= ATTR_MISSING
;
93 short nClickActionSet
= ATTR_MISSING
;
94 short nBookmarkSet
= ATTR_MISSING
;
96 short nSecondEffectSet
= ATTR_MISSING
;
97 short nSecondSpeedSet
= ATTR_MISSING
;
98 short nSecondSoundOnSet
= ATTR_MISSING
;
99 short nSecondPlayFullSet
= ATTR_MISSING
;
101 // defaults (for Undo-Action)
102 presentation::AnimationEffect eEffect
= presentation::AnimationEffect_NONE
;
103 presentation::AnimationEffect eTextEffect
= presentation::AnimationEffect_NONE
;
104 presentation::AnimationSpeed eSpeed
= presentation::AnimationSpeed_MEDIUM
;
105 bool bActive
= false;
106 bool bFadeOut
= false;
107 Color aFadeColor
= COL_LIGHTGRAY
;
108 bool bInvisible
= false;
109 bool bSoundOn
= false;
111 bool bPlayFull
= false;
112 presentation::ClickAction eClickAction
= presentation::ClickAction_NONE
;
115 presentation::AnimationEffect eSecondEffect
= presentation::AnimationEffect_NONE
;
116 presentation::AnimationSpeed eSecondSpeed
= presentation::AnimationSpeed_MEDIUM
;
117 bool bSecondSoundOn
= false;
118 bool bSecondPlayFull
= false;
120 SdAnimationInfo
* pInfo
;
123 // inspect first object
124 pMark
= rMarkList
.GetMark(0);
125 pInfo
= mpDoc
->GetAnimationInfo(pMark
->GetMarkedSdrObj());
128 bActive
= pInfo
->mbActive
;
129 nAnimationSet
= ATTR_SET
;
131 eEffect
= pInfo
->meEffect
;
132 nEffectSet
= ATTR_SET
;
134 eTextEffect
= pInfo
->meTextEffect
;
135 nTextEffectSet
= ATTR_SET
;
137 eSpeed
= pInfo
->meSpeed
;
138 nSpeedSet
= ATTR_SET
;
140 bFadeOut
= pInfo
->mbDimPrevious
;
141 nFadeOutSet
= ATTR_SET
;
143 aFadeColor
= pInfo
->maDimColor
;
144 nFadeColorSet
= ATTR_SET
;
146 bInvisible
= pInfo
->mbDimHide
;
147 nInvisibleSet
= ATTR_SET
;
149 bSoundOn
= pInfo
->mbSoundOn
;
150 nSoundOnSet
= ATTR_SET
;
152 aSound
= pInfo
->maSoundFile
;
153 nSoundFileSet
= ATTR_SET
;
155 bPlayFull
= pInfo
->mbPlayFull
;
156 nPlayFullSet
= ATTR_SET
;
158 eClickAction
= pInfo
->meClickAction
;
159 nClickActionSet
= ATTR_SET
;
161 aBookmark
= pInfo
->GetBookmark();
162 nBookmarkSet
= ATTR_SET
;
164 eSecondEffect
= pInfo
->meSecondEffect
;
165 nSecondEffectSet
= ATTR_SET
;
167 eSecondSpeed
= pInfo
->meSecondSpeed
;
168 nSecondSpeedSet
= ATTR_SET
;
170 bSecondSoundOn
= pInfo
->mbSecondSoundOn
;
171 nSecondSoundOnSet
= ATTR_SET
;
173 bSecondPlayFull
= pInfo
->mbSecondPlayFull
;
174 nSecondPlayFullSet
= ATTR_SET
;
177 // if necessary, inspect more objects
178 for( size_t nObject
= 1; nObject
< nCount
; ++nObject
)
180 pMark
= rMarkList
.GetMark( nObject
);
181 SdrObject
* pObject
= pMark
->GetMarkedSdrObj();
182 pInfo
= mpDoc
->GetAnimationInfo(pObject
);
185 if( bActive
!= pInfo
->mbActive
)
186 nAnimationSet
= ATTR_MIXED
;
188 if( eEffect
!= pInfo
->meEffect
)
189 nEffectSet
= ATTR_MIXED
;
191 if( eTextEffect
!= pInfo
->meTextEffect
)
192 nTextEffectSet
= ATTR_MIXED
;
194 if( eSpeed
!= pInfo
->meSpeed
)
195 nSpeedSet
= ATTR_MIXED
;
197 if( bFadeOut
!= pInfo
->mbDimPrevious
)
198 nFadeOutSet
= ATTR_MIXED
;
200 if( aFadeColor
!= pInfo
->maDimColor
)
201 nFadeColorSet
= ATTR_MIXED
;
203 if( bInvisible
!= pInfo
->mbDimHide
)
204 nInvisibleSet
= ATTR_MIXED
;
206 if( bSoundOn
!= pInfo
->mbSoundOn
)
207 nSoundOnSet
= ATTR_MIXED
;
209 if( aSound
!= pInfo
->maSoundFile
)
210 nSoundFileSet
= ATTR_MIXED
;
212 if( bPlayFull
!= pInfo
->mbPlayFull
)
213 nPlayFullSet
= ATTR_MIXED
;
215 if( eClickAction
!= pInfo
->meClickAction
)
216 nClickActionSet
= ATTR_MIXED
;
218 if( aBookmark
!= pInfo
->GetBookmark() )
219 nBookmarkSet
= ATTR_MIXED
;
221 if( eSecondEffect
!= pInfo
->meSecondEffect
)
222 nSecondEffectSet
= ATTR_MIXED
;
224 if( eSecondSpeed
!= pInfo
->meSecondSpeed
)
225 nSecondSpeedSet
= ATTR_MIXED
;
227 if( bSecondSoundOn
!= pInfo
->mbSecondSoundOn
)
228 nSecondSoundOnSet
= ATTR_MIXED
;
230 if( bSecondPlayFull
!= pInfo
->mbSecondPlayFull
)
231 nSecondPlayFullSet
= ATTR_MIXED
;
235 if (nAnimationSet
== ATTR_SET
&& bActive
)
236 nAnimationSet
= ATTR_MIXED
;
238 if (nEffectSet
== ATTR_SET
&& eEffect
!= presentation::AnimationEffect_NONE
)
239 nEffectSet
= ATTR_MIXED
;
241 if (nTextEffectSet
== ATTR_SET
&& eTextEffect
!= presentation::AnimationEffect_NONE
)
242 nTextEffectSet
= ATTR_MIXED
;
244 if (nSpeedSet
== ATTR_SET
)
245 nSpeedSet
= ATTR_MIXED
;
247 if (nFadeOutSet
== ATTR_SET
&& bFadeOut
)
248 nFadeOutSet
= ATTR_MIXED
;
250 if (nFadeColorSet
== ATTR_SET
)
251 nFadeColorSet
= ATTR_MIXED
;
253 if (nInvisibleSet
== ATTR_SET
&& bInvisible
)
254 nInvisibleSet
= ATTR_MIXED
;
256 if (nSoundOnSet
== ATTR_SET
&& bSoundOn
)
257 nSoundOnSet
= ATTR_MIXED
;
259 if (nSoundFileSet
== ATTR_SET
)
260 nSoundFileSet
= ATTR_MIXED
;
262 if (nPlayFullSet
== ATTR_SET
&& bPlayFull
)
263 nPlayFullSet
= ATTR_MIXED
;
265 if (nClickActionSet
== ATTR_SET
&& eClickAction
!= presentation::ClickAction_NONE
)
266 nClickActionSet
= ATTR_MIXED
;
268 if (nBookmarkSet
== ATTR_SET
)
269 nBookmarkSet
= ATTR_MIXED
;
271 if (nSecondEffectSet
== ATTR_SET
&& eSecondEffect
!= presentation::AnimationEffect_NONE
)
272 nSecondEffectSet
= ATTR_MIXED
;
274 if (nSecondSpeedSet
== ATTR_SET
)
275 nSecondSpeedSet
= ATTR_MIXED
;
277 if (nSecondSoundOnSet
== ATTR_SET
&& bSecondSoundOn
)
278 nSecondSoundOnSet
= ATTR_MIXED
;
280 if (nSecondPlayFullSet
== ATTR_SET
&& bSecondPlayFull
)
281 nSecondPlayFullSet
= ATTR_MIXED
;
285 /* Exactly two objects with path effect?
286 Then, only the animation info at the moved object is valid. */
289 SdrObject
* pObject1
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
290 SdrObject
* pObject2
= rMarkList
.GetMark(1)->GetMarkedSdrObj();
291 SdrObjKind eKind1
= (SdrObjKind
)pObject1
->GetObjIdentifier();
292 SdrObjKind eKind2
= (SdrObjKind
)pObject2
->GetObjIdentifier();
293 SdAnimationInfo
* pInfo1
= mpDoc
->GetAnimationInfo(pObject1
);
294 SdAnimationInfo
* pInfo2
= mpDoc
->GetAnimationInfo(pObject2
);
297 if (pObject1
->GetObjInventor() == SdrInventor
&&
298 ((eKind1
== OBJ_LINE
) || // 2 point line
299 (eKind1
== OBJ_PLIN
) || // Polygon
300 (eKind1
== OBJ_PATHLINE
)) && // Bezier curve
301 (pInfo2
&& pInfo2
->meEffect
== presentation::AnimationEffect_PATH
))
306 if (pObject2
->GetObjInventor() == SdrInventor
&&
307 ((eKind2
== OBJ_LINE
) || // 2 point line
308 (eKind2
== OBJ_PLIN
) || // Polygon
309 (eKind2
== OBJ_PATHLINE
)) && // Bezier curve
310 (pInfo1
&& pInfo1
->meEffect
== presentation::AnimationEffect_PATH
))
317 bActive
= pInfo
->mbActive
; nAnimationSet
= ATTR_SET
;
318 eEffect
= pInfo
->meEffect
; nEffectSet
= ATTR_SET
;
319 eTextEffect
= pInfo
->meTextEffect
; nTextEffectSet
= ATTR_SET
;
320 eSpeed
= pInfo
->meSpeed
; nSpeedSet
= ATTR_SET
;
321 bFadeOut
= pInfo
->mbDimPrevious
; nFadeOutSet
= ATTR_SET
;
322 aFadeColor
= pInfo
->maDimColor
; nFadeColorSet
= ATTR_SET
;
323 bInvisible
= pInfo
->mbDimHide
; nInvisibleSet
= ATTR_SET
;
324 bSoundOn
= pInfo
->mbSoundOn
; nSoundOnSet
= ATTR_SET
;
325 aSound
= pInfo
->maSoundFile
; nSoundFileSet
= ATTR_SET
;
326 bPlayFull
= pInfo
->mbPlayFull
; nPlayFullSet
= ATTR_SET
;
327 eClickAction
= pInfo
->meClickAction
; nClickActionSet
= ATTR_SET
;
328 aBookmark
= pInfo
->GetBookmark(); nBookmarkSet
= ATTR_SET
;
329 eSecondEffect
= pInfo
->meSecondEffect
; nSecondEffectSet
= ATTR_SET
;
330 eSecondSpeed
= pInfo
->meSecondSpeed
; nSecondSpeedSet
= ATTR_SET
;
331 bSecondSoundOn
= pInfo
->mbSecondSoundOn
; nSecondSoundOnSet
= ATTR_SET
;
332 bSecondPlayFull
= pInfo
->mbSecondPlayFull
; nSecondPlayFullSet
= ATTR_SET
;
336 const SfxItemSet
* pArgs
= rReq
.GetArgs();
340 // fill ItemSet for dialog
341 SfxItemSet
aSet(mpDoc
->GetPool(), ATTR_ANIMATION_START
, ATTR_ACTION_END
);
344 if (nAnimationSet
== ATTR_SET
)
345 aSet
.Put( SfxBoolItem( ATTR_ANIMATION_ACTIVE
, bActive
));
346 else if (nAnimationSet
== ATTR_MIXED
)
347 aSet
.InvalidateItem(ATTR_ANIMATION_ACTIVE
);
349 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_ACTIVE
, false));
351 if (nEffectSet
== ATTR_SET
)
352 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_EFFECT
, (sal_uInt16
)eEffect
));
353 else if (nEffectSet
== ATTR_MIXED
)
354 aSet
.InvalidateItem( ATTR_ANIMATION_EFFECT
);
356 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_EFFECT
, presentation::AnimationEffect_NONE
));
358 if (nTextEffectSet
== ATTR_SET
)
359 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_TEXTEFFECT
, (sal_uInt16
)eTextEffect
));
360 else if (nTextEffectSet
== ATTR_MIXED
)
361 aSet
.InvalidateItem( ATTR_ANIMATION_TEXTEFFECT
);
363 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_TEXTEFFECT
, presentation::AnimationEffect_NONE
));
365 if (nSpeedSet
== ATTR_SET
)
366 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_SPEED
, (sal_uInt16
)eSpeed
));
368 aSet
.InvalidateItem(ATTR_ANIMATION_SPEED
);
370 if (nFadeOutSet
== ATTR_SET
)
371 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_FADEOUT
, bFadeOut
));
372 else if (nFadeOutSet
== ATTR_MIXED
)
373 aSet
.InvalidateItem(ATTR_ANIMATION_FADEOUT
);
375 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_FADEOUT
, false));
377 if (nFadeColorSet
== ATTR_SET
)
378 aSet
.Put(SvxColorItem(aFadeColor
, ATTR_ANIMATION_COLOR
));
379 else if (nFadeColorSet
== ATTR_MIXED
)
380 aSet
.InvalidateItem(ATTR_ANIMATION_COLOR
);
382 aSet
.Put(SvxColorItem(RGB_Color(COL_LIGHTGRAY
), ATTR_ANIMATION_COLOR
));
384 if (nInvisibleSet
== ATTR_SET
)
385 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_INVISIBLE
, bInvisible
));
386 else if (nInvisibleSet
== ATTR_MIXED
)
387 aSet
.InvalidateItem(ATTR_ANIMATION_INVISIBLE
);
389 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_INVISIBLE
, false));
391 if (nSoundOnSet
== ATTR_SET
)
392 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_SOUNDON
, bSoundOn
));
393 else if (nSoundOnSet
== ATTR_MIXED
)
394 aSet
.InvalidateItem(ATTR_ANIMATION_SOUNDON
);
396 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_SOUNDON
, false));
398 if (nSoundFileSet
== ATTR_SET
)
399 aSet
.Put(SfxStringItem(ATTR_ANIMATION_SOUNDFILE
, aSound
));
401 aSet
.InvalidateItem(ATTR_ANIMATION_SOUNDFILE
);
403 if (nPlayFullSet
== ATTR_SET
)
404 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_PLAYFULL
, bPlayFull
));
405 else if (nPlayFullSet
== ATTR_MIXED
)
406 aSet
.InvalidateItem(ATTR_ANIMATION_PLAYFULL
);
408 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_PLAYFULL
, false));
410 if (nClickActionSet
== ATTR_SET
)
411 aSet
.Put(SfxAllEnumItem(ATTR_ACTION
, (sal_uInt16
)eClickAction
));
412 else if (nClickActionSet
== ATTR_MIXED
)
413 aSet
.InvalidateItem(ATTR_ACTION
);
415 aSet
.Put(SfxAllEnumItem(ATTR_ACTION
, presentation::ClickAction_NONE
));
417 if (nBookmarkSet
== ATTR_SET
)
418 aSet
.Put(SfxStringItem(ATTR_ACTION_FILENAME
, aBookmark
));
420 aSet
.InvalidateItem(ATTR_ACTION_FILENAME
);
422 if (nSecondEffectSet
== ATTR_SET
)
423 aSet
.Put(SfxAllEnumItem(ATTR_ACTION_EFFECT
, (sal_uInt16
)eSecondEffect
));
424 else if (nSecondEffectSet
== ATTR_MIXED
)
425 aSet
.InvalidateItem( ATTR_ACTION_EFFECT
);
427 aSet
.Put(SfxAllEnumItem(ATTR_ACTION_EFFECT
, presentation::AnimationEffect_NONE
));
429 if (nSecondSpeedSet
== ATTR_SET
)
430 aSet
.Put(SfxAllEnumItem(ATTR_ACTION_EFFECTSPEED
, (sal_uInt16
)eSecondSpeed
));
432 aSet
.InvalidateItem(ATTR_ACTION_EFFECTSPEED
);
434 if (nSecondSoundOnSet
== ATTR_SET
)
435 aSet
.Put(SfxBoolItem(ATTR_ACTION_SOUNDON
, bSecondSoundOn
));
436 else if (nSecondSoundOnSet
== ATTR_MIXED
)
437 aSet
.InvalidateItem(ATTR_ACTION_SOUNDON
);
439 aSet
.Put(SfxBoolItem(ATTR_ACTION_SOUNDON
, false));
441 if (nSecondPlayFullSet
== ATTR_SET
)
442 aSet
.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL
, bSecondPlayFull
));
443 else if (nSecondPlayFullSet
== ATTR_MIXED
)
444 aSet
.InvalidateItem(ATTR_ACTION_PLAYFULL
);
446 aSet
.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL
, false));
448 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
449 boost::scoped_ptr
<SfxAbstractDialog
> pDlg(pFact
? pFact
->CreatSdActionDialog( NULL
, &aSet
, mpView
) : 0);
451 short nResult
= pDlg
? pDlg
->Execute() : static_cast<short>(RET_CANCEL
);
453 if( nResult
== RET_OK
)
455 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
456 pArgs
= rReq
.GetArgs();
459 if( nResult
!= RET_OK
)
463 // evaluation of the ItemSets
464 if (pArgs
->GetItemState(ATTR_ANIMATION_ACTIVE
) == SfxItemState::SET
)
466 bActive
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ANIMATION_ACTIVE
)).GetValue();
467 nAnimationSet
= ATTR_SET
;
470 nAnimationSet
= ATTR_MISSING
;
472 if (pArgs
->GetItemState(ATTR_ANIMATION_EFFECT
) == SfxItemState::SET
)
474 eEffect
= (presentation::AnimationEffect
)static_cast<const SfxAllEnumItem
&>( pArgs
->
475 Get(ATTR_ANIMATION_EFFECT
)).GetValue();
476 nEffectSet
= ATTR_SET
;
479 nEffectSet
= ATTR_MISSING
;
481 if (pArgs
->GetItemState(ATTR_ANIMATION_TEXTEFFECT
) == SfxItemState::SET
)
483 eTextEffect
= (presentation::AnimationEffect
)static_cast<const SfxAllEnumItem
&>( pArgs
->
484 Get(ATTR_ANIMATION_TEXTEFFECT
)).GetValue();
485 nTextEffectSet
= ATTR_SET
;
488 nTextEffectSet
= ATTR_MISSING
;
490 if (pArgs
->GetItemState(ATTR_ANIMATION_SPEED
) == SfxItemState::SET
)
492 eSpeed
= (presentation::AnimationSpeed
)static_cast<const SfxAllEnumItem
&>( pArgs
->
493 Get(ATTR_ANIMATION_SPEED
)).GetValue();
494 nSpeedSet
= ATTR_SET
;
497 nSpeedSet
= ATTR_MISSING
;
499 if (pArgs
->GetItemState(ATTR_ANIMATION_FADEOUT
) == SfxItemState::SET
)
501 bFadeOut
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ANIMATION_FADEOUT
)).GetValue();
502 nFadeOutSet
= ATTR_SET
;
505 nFadeOutSet
= ATTR_MISSING
;
507 if (pArgs
->GetItemState(ATTR_ANIMATION_INVISIBLE
) == SfxItemState::SET
)
509 bInvisible
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ANIMATION_INVISIBLE
)).GetValue();
510 nInvisibleSet
= ATTR_SET
;
513 nInvisibleSet
= ATTR_MISSING
;
515 if (pArgs
->GetItemState(ATTR_ANIMATION_SOUNDON
) == SfxItemState::SET
)
517 bSoundOn
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ANIMATION_SOUNDON
)).GetValue();
518 nSoundOnSet
= ATTR_SET
;
521 nSoundOnSet
= ATTR_MISSING
;
523 if (pArgs
->GetItemState(ATTR_ANIMATION_SOUNDFILE
) == SfxItemState::SET
)
525 aSound
= static_cast<const SfxStringItem
&>(pArgs
->Get(ATTR_ANIMATION_SOUNDFILE
)).GetValue();
526 nSoundFileSet
= ATTR_SET
;
529 nSoundFileSet
= ATTR_MISSING
;
531 if (pArgs
->GetItemState(ATTR_ANIMATION_COLOR
) == SfxItemState::SET
)
533 aFadeColor
= static_cast<const SvxColorItem
&>(pArgs
->Get(ATTR_ANIMATION_COLOR
)).GetValue();
534 nFadeColorSet
= ATTR_SET
;
537 nFadeColorSet
= ATTR_MISSING
;
539 if (pArgs
->GetItemState(ATTR_ANIMATION_PLAYFULL
) == SfxItemState::SET
)
541 bPlayFull
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ANIMATION_PLAYFULL
)).GetValue();
542 nPlayFullSet
= ATTR_SET
;
545 nPlayFullSet
= ATTR_MISSING
;
547 if (pArgs
->GetItemState(ATTR_ACTION
) == SfxItemState::SET
)
549 eClickAction
= (presentation::ClickAction
)static_cast<const SfxAllEnumItem
&>(pArgs
->
550 Get(ATTR_ACTION
)).GetValue();
551 nClickActionSet
= ATTR_SET
;
554 nClickActionSet
= ATTR_MISSING
;
556 if (pArgs
->GetItemState(ATTR_ACTION_FILENAME
) == SfxItemState::SET
)
558 aBookmark
= static_cast<const SfxStringItem
&>(pArgs
->
559 Get(ATTR_ACTION_FILENAME
)).GetValue();
560 nBookmarkSet
= ATTR_SET
;
563 nBookmarkSet
= ATTR_MISSING
;
565 if (pArgs
->GetItemState(ATTR_ACTION_EFFECT
) == SfxItemState::SET
)
567 eSecondEffect
= (presentation::AnimationEffect
)static_cast<const SfxAllEnumItem
&>( pArgs
->
568 Get(ATTR_ACTION_EFFECT
)).GetValue();
569 nSecondEffectSet
= ATTR_SET
;
572 nSecondEffectSet
= ATTR_MISSING
;
574 if (pArgs
->GetItemState(ATTR_ACTION_EFFECTSPEED
) == SfxItemState::SET
)
576 eSecondSpeed
= (presentation::AnimationSpeed
)static_cast<const SfxAllEnumItem
&>( pArgs
->
577 Get(ATTR_ACTION_EFFECTSPEED
)).GetValue();
578 nSecondSpeedSet
= ATTR_SET
;
581 nSecondSpeedSet
= ATTR_MISSING
;
583 if (pArgs
->GetItemState(ATTR_ACTION_SOUNDON
) == SfxItemState::SET
)
585 bSecondSoundOn
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ACTION_SOUNDON
)).GetValue();
586 nSecondSoundOnSet
= ATTR_SET
;
589 nSecondSoundOnSet
= ATTR_MISSING
;
591 if (pArgs
->GetItemState(ATTR_ACTION_PLAYFULL
) == SfxItemState::SET
)
593 bSecondPlayFull
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ACTION_PLAYFULL
)).GetValue();
594 nSecondPlayFullSet
= ATTR_SET
;
597 nSecondPlayFullSet
= ATTR_MISSING
;
599 // if any attribute is chosen
600 if (nEffectSet
== ATTR_SET
||
601 nTextEffectSet
== ATTR_SET
||
602 nSpeedSet
== ATTR_SET
||
603 nAnimationSet
== ATTR_SET
||
604 nFadeOutSet
== ATTR_SET
||
605 nFadeColorSet
== ATTR_SET
||
606 nInvisibleSet
== ATTR_SET
||
607 nSoundOnSet
== ATTR_SET
||
608 nSoundFileSet
== ATTR_SET
||
609 nPlayFullSet
== ATTR_SET
||
610 nClickActionSet
== ATTR_SET
||
611 nBookmarkSet
== ATTR_SET
||
612 nSecondEffectSet
== ATTR_SET
||
613 nSecondSpeedSet
== ATTR_SET
||
614 nSecondSoundOnSet
== ATTR_SET
||
615 nSecondPlayFullSet
== ATTR_SET
)
617 // String for undo-group and list-action
618 OUString
aComment(SdResId(STR_UNDO_ANIMATION
));
620 // with 'following curves', we have an additional UndoAction
621 // therefore cling? here
622 pUndoMgr
->EnterListAction(aComment
, aComment
);
625 SdUndoGroup
* pUndoGroup
= new SdUndoGroup(mpDoc
);
626 pUndoGroup
->SetComment(aComment
);
628 // for the path effect, remember some stuff
629 SdrObject
* pRunningObj
= NULL
;
630 SdrPathObj
* pPath
= NULL
;
631 if (eEffect
== presentation::AnimationEffect_PATH
&& nEffectSet
== ATTR_SET
)
633 DBG_ASSERT(nCount
== 2, "This effect expects two selected objects");
634 SdrObject
* pObject1
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
635 SdrObject
* pObject2
= rMarkList
.GetMark(1)->GetMarkedSdrObj();
636 SdrObjKind eKind1
= (SdrObjKind
)pObject1
->GetObjIdentifier();
637 SdrObjKind eKind2
= (SdrObjKind
)pObject2
->GetObjIdentifier();
639 if (pObject1
->GetObjInventor() == SdrInventor
&&
640 ((eKind1
== OBJ_LINE
) || // 2 point line
641 (eKind1
== OBJ_PLIN
) || // Polygon
642 (eKind1
== OBJ_PATHLINE
))) // Bezier curve
644 pPath
= static_cast<SdrPathObj
*>(pObject1
);
645 pRunningObj
= pObject2
;
648 if (pObject2
->GetObjInventor() == SdrInventor
&&
649 ((eKind2
== OBJ_LINE
) || // 2 point line
650 (eKind2
== OBJ_PLIN
) || // Polygon
651 (eKind2
== OBJ_PATHLINE
))) // Bezier curve
653 pPath
= static_cast<SdrPathObj
*>(pObject2
);
654 pRunningObj
= pObject1
;
657 assert(pRunningObj
&& pPath
&& "no curve found");
659 // push the running object to the end of the curve
662 Rectangle
aCurRect(pRunningObj
->GetLogicRect());
663 Point
aCurCenter(aCurRect
.Center());
664 const ::basegfx::B2DPolyPolygon
& rPolyPolygon
= pPath
->GetPathPoly();
665 sal_uInt32
nNoOfPolygons(rPolyPolygon
.count());
666 const ::basegfx::B2DPolygon
aPolygon(rPolyPolygon
.getB2DPolygon(nNoOfPolygons
- 1L));
667 sal_uInt32
nPoints(aPolygon
.count());
668 const ::basegfx::B2DPoint
aNewB2DCenter(aPolygon
.getB2DPoint(nPoints
- 1L));
669 const Point
aNewCenter(FRound(aNewB2DCenter
.getX()), FRound(aNewB2DCenter
.getY()));
670 Size
aDistance(aNewCenter
.X() - aCurCenter
.X(), aNewCenter
.Y() - aCurCenter
.Y());
671 pRunningObj
->Move(aDistance
);
673 pUndoMgr
->AddUndoAction(mpDoc
->GetSdrUndoFactory().CreateUndoMoveObject( *pRunningObj
, aDistance
));
677 for (size_t nObject
= 0; nObject
< nCount
; ++nObject
)
679 SdrObject
* pObject
= rMarkList
.GetMark(nObject
)->GetMarkedSdrObj();
681 pInfo
= mpDoc
->GetAnimationInfo(pObject
);
683 bool bCreated
= false;
686 pInfo
= SdDrawDocument::GetShapeUserData(*pObject
,true);
690 // path object for 'following curves'?
691 if (eEffect
== presentation::AnimationEffect_PATH
&& pObject
== pPath
)
693 SdAnimationPrmsUndoAction
* pAction
= new SdAnimationPrmsUndoAction
694 (mpDoc
, pObject
, bCreated
);
695 pAction
->SetActive(pInfo
->mbActive
, pInfo
->mbActive
);
696 pAction
->SetEffect(pInfo
->meEffect
, pInfo
->meEffect
);
697 pAction
->SetTextEffect(pInfo
->meTextEffect
, pInfo
->meTextEffect
);
698 pAction
->SetSpeed(pInfo
->meSpeed
, pInfo
->meSpeed
);
699 pAction
->SetDim(pInfo
->mbDimPrevious
, pInfo
->mbDimPrevious
);
700 pAction
->SetDimColor(pInfo
->maDimColor
, pInfo
->maDimColor
);
701 pAction
->SetDimHide(pInfo
->mbDimHide
, pInfo
->mbDimHide
);
702 pAction
->SetSoundOn(pInfo
->mbSoundOn
, pInfo
->mbSoundOn
);
703 pAction
->SetSound(pInfo
->maSoundFile
, pInfo
->maSoundFile
);
704 pAction
->SetPlayFull(pInfo
->mbPlayFull
, pInfo
->mbPlayFull
);
705 pAction
->SetClickAction(pInfo
->meClickAction
, pInfo
->meClickAction
);
706 pAction
->SetBookmark(pInfo
->GetBookmark(), pInfo
->GetBookmark());
707 pAction
->SetVerb(pInfo
->mnVerb
, pInfo
->mnVerb
);
708 pAction
->SetSecondEffect(pInfo
->meSecondEffect
, pInfo
->meSecondEffect
);
709 pAction
->SetSecondSpeed(pInfo
->meSecondSpeed
, pInfo
->meSecondSpeed
);
710 pAction
->SetSecondSoundOn(pInfo
->mbSecondSoundOn
, pInfo
->mbSecondSoundOn
);
711 pAction
->SetSecondPlayFull(pInfo
->mbSecondPlayFull
, pInfo
->mbSecondPlayFull
);
712 pUndoGroup
->AddAction(pAction
);
718 // create undo action with old and new sizes
719 SdAnimationPrmsUndoAction
* pAction
= new SdAnimationPrmsUndoAction
720 (mpDoc
, pObject
, bCreated
);
721 pAction
->SetActive(pInfo
->mbActive
, bActive
);
722 pAction
->SetEffect(pInfo
->meEffect
, eEffect
);
723 pAction
->SetTextEffect(pInfo
->meTextEffect
, eTextEffect
);
724 pAction
->SetSpeed(pInfo
->meSpeed
, eSpeed
);
725 pAction
->SetDim(pInfo
->mbDimPrevious
, bFadeOut
);
726 pAction
->SetDimColor(pInfo
->maDimColor
, aFadeColor
);
727 pAction
->SetDimHide(pInfo
->mbDimHide
, bInvisible
);
728 pAction
->SetSoundOn(pInfo
->mbSoundOn
, bSoundOn
);
729 pAction
->SetSound(pInfo
->maSoundFile
, aSound
);
730 pAction
->SetPlayFull(pInfo
->mbPlayFull
, bPlayFull
);
731 pAction
->SetPathObj(pInfo
->mpPathObj
, pPath
);
732 pAction
->SetClickAction(pInfo
->meClickAction
, eClickAction
);
733 pAction
->SetBookmark(pInfo
->GetBookmark(), aBookmark
);
734 pAction
->SetVerb(pInfo
->mnVerb
, (sal_uInt16
)pInfo
->GetBookmark().toInt32() );
735 pAction
->SetSecondEffect(pInfo
->meSecondEffect
, eSecondEffect
);
736 pAction
->SetSecondSpeed(pInfo
->meSecondSpeed
, eSecondSpeed
);
737 pAction
->SetSecondSoundOn(pInfo
->mbSecondSoundOn
, bSecondSoundOn
);
738 pAction
->SetSecondPlayFull(pInfo
->mbSecondPlayFull
,bSecondPlayFull
);
739 pUndoGroup
->AddAction(pAction
);
741 // insert new values at info block of the object
742 if (nAnimationSet
== ATTR_SET
)
743 pInfo
->mbActive
= bActive
;
745 if (nEffectSet
== ATTR_SET
)
746 pInfo
->meEffect
= eEffect
;
748 if (nTextEffectSet
== ATTR_SET
)
749 pInfo
->meTextEffect
= eTextEffect
;
751 if (nSpeedSet
== ATTR_SET
)
752 pInfo
->meSpeed
= eSpeed
;
754 if (nFadeOutSet
== ATTR_SET
)
755 pInfo
->mbDimPrevious
= bFadeOut
;
757 if (nFadeColorSet
== ATTR_SET
)
758 pInfo
->maDimColor
= aFadeColor
;
760 if (nInvisibleSet
== ATTR_SET
)
761 pInfo
->mbDimHide
= bInvisible
;
763 if (nSoundOnSet
== ATTR_SET
)
764 pInfo
->mbSoundOn
= bSoundOn
;
766 if (nSoundFileSet
== ATTR_SET
)
767 pInfo
->maSoundFile
= aSound
;
769 if (nPlayFullSet
== ATTR_SET
)
770 pInfo
->mbPlayFull
= bPlayFull
;
772 if (nClickActionSet
== ATTR_SET
)
773 pInfo
->meClickAction
= eClickAction
;
775 if (nBookmarkSet
== ATTR_SET
)
776 pInfo
->SetBookmark( aBookmark
);
778 if (nSecondEffectSet
== ATTR_SET
)
779 pInfo
->meSecondEffect
= eSecondEffect
;
781 if (nSecondSpeedSet
== ATTR_SET
)
782 pInfo
->meSecondSpeed
= eSecondSpeed
;
784 if (nSecondSoundOnSet
== ATTR_SET
)
785 pInfo
->mbSecondSoundOn
= bSecondSoundOn
;
787 if (nSecondPlayFullSet
== ATTR_SET
)
788 pInfo
->mbSecondPlayFull
= bSecondPlayFull
;
790 if (eClickAction
== presentation::ClickAction_VERB
)
791 pInfo
->mnVerb
= (sal_uInt16
)aBookmark
.toInt32();
794 // Set the Undo Group in of the Undo Manager
795 pUndoMgr
->AddUndoAction(pUndoGroup
);
796 pUndoMgr
->LeaveListAction();
801 // not seen, therefore we do not need to invalidate at the bindings
804 } // end of namespace sd
806 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */