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 <svl/aeitem.hxx>
32 #include <svx/xtable.hxx>
34 #include <strings.hrc>
35 #include <drawdoc.hxx>
36 #include <ViewShell.hxx>
37 #include <ViewShellBase.hxx>
38 #include <anminfo.hxx>
39 #include <unoaprms.hxx>
40 #include <sdundogr.hxx>
43 #include <sdabstdlg.hxx>
44 #include <sdresid.hxx>
45 #include <tools/helpers.hxx>
46 #include <basegfx/polygon/b2dpolygon.hxx>
49 using namespace ::com::sun::star
;
54 #define ATTR_MISSING 0 ///< Attribute missing
55 #define ATTR_MIXED 1 ///< Attribute ambiguous (on multi-selection)
56 #define ATTR_SET 2 ///< Attribute unique
58 FuObjectAnimationParameters::FuObjectAnimationParameters (
64 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
68 rtl::Reference
<FuPoor
> FuObjectAnimationParameters::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
70 rtl::Reference
<FuPoor
> xFunc( new FuObjectAnimationParameters( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
71 xFunc
->DoExecute(rReq
);
75 void FuObjectAnimationParameters::DoExecute( SfxRequest
& rReq
)
77 ::svl::IUndoManager
* pUndoMgr
= mpViewShell
->GetViewFrame()->GetObjectShell()->GetUndoManager();
79 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
80 const size_t nCount
= rMarkList
.GetMarkCount();
82 short nAnimationSet
= ATTR_MISSING
;
83 short nEffectSet
= ATTR_MISSING
;
84 short nTextEffectSet
= ATTR_MISSING
;
85 short nSpeedSet
= ATTR_MISSING
;
86 short nFadeColorSet
= ATTR_MISSING
;
87 short nFadeOutSet
= ATTR_MISSING
;
88 short nInvisibleSet
= ATTR_MISSING
;
89 short nSoundOnSet
= ATTR_MISSING
;
90 short nSoundFileSet
= ATTR_MISSING
;
91 short nPlayFullSet
= ATTR_MISSING
;
92 short nClickActionSet
= ATTR_MISSING
;
93 short nBookmarkSet
= ATTR_MISSING
;
95 short nSecondEffectSet
= ATTR_MISSING
;
96 short nSecondSpeedSet
= ATTR_MISSING
;
97 short nSecondSoundOnSet
= ATTR_MISSING
;
98 short nSecondPlayFullSet
= ATTR_MISSING
;
100 // defaults (for Undo-Action)
101 presentation::AnimationEffect eEffect
= presentation::AnimationEffect_NONE
;
102 presentation::AnimationEffect eTextEffect
= presentation::AnimationEffect_NONE
;
103 presentation::AnimationSpeed eSpeed
= presentation::AnimationSpeed_MEDIUM
;
104 bool bActive
= false;
105 bool bFadeOut
= false;
106 Color aFadeColor
= COL_LIGHTGRAY
;
107 bool bInvisible
= false;
108 bool bSoundOn
= false;
110 bool bPlayFull
= false;
111 presentation::ClickAction eClickAction
= presentation::ClickAction_NONE
;
114 presentation::AnimationEffect eSecondEffect
= presentation::AnimationEffect_NONE
;
115 presentation::AnimationSpeed eSecondSpeed
= presentation::AnimationSpeed_MEDIUM
;
116 bool bSecondSoundOn
= false;
117 bool bSecondPlayFull
= false;
119 SdAnimationInfo
* pInfo
;
122 // inspect first object
123 pMark
= rMarkList
.GetMark(0);
124 pInfo
= SdDrawDocument::GetAnimationInfo(pMark
->GetMarkedSdrObj());
127 bActive
= pInfo
->mbActive
;
128 nAnimationSet
= ATTR_SET
;
130 eEffect
= pInfo
->meEffect
;
131 nEffectSet
= ATTR_SET
;
133 eTextEffect
= pInfo
->meTextEffect
;
134 nTextEffectSet
= ATTR_SET
;
136 eSpeed
= pInfo
->meSpeed
;
137 nSpeedSet
= ATTR_SET
;
139 bFadeOut
= pInfo
->mbDimPrevious
;
140 nFadeOutSet
= ATTR_SET
;
142 aFadeColor
= pInfo
->maDimColor
;
143 nFadeColorSet
= ATTR_SET
;
145 bInvisible
= pInfo
->mbDimHide
;
146 nInvisibleSet
= ATTR_SET
;
148 bSoundOn
= pInfo
->mbSoundOn
;
149 nSoundOnSet
= ATTR_SET
;
151 aSound
= pInfo
->maSoundFile
;
152 nSoundFileSet
= ATTR_SET
;
154 bPlayFull
= pInfo
->mbPlayFull
;
155 nPlayFullSet
= ATTR_SET
;
157 eClickAction
= pInfo
->meClickAction
;
158 nClickActionSet
= ATTR_SET
;
160 aBookmark
= pInfo
->GetBookmark();
161 nBookmarkSet
= ATTR_SET
;
163 eSecondEffect
= pInfo
->meSecondEffect
;
164 nSecondEffectSet
= ATTR_SET
;
166 eSecondSpeed
= pInfo
->meSecondSpeed
;
167 nSecondSpeedSet
= ATTR_SET
;
169 bSecondSoundOn
= pInfo
->mbSecondSoundOn
;
170 nSecondSoundOnSet
= ATTR_SET
;
172 bSecondPlayFull
= pInfo
->mbSecondPlayFull
;
173 nSecondPlayFullSet
= ATTR_SET
;
176 // if necessary, inspect more objects
177 for( size_t nObject
= 1; nObject
< nCount
; ++nObject
)
179 pMark
= rMarkList
.GetMark( nObject
);
180 SdrObject
* pObject
= pMark
->GetMarkedSdrObj();
181 pInfo
= SdDrawDocument::GetAnimationInfo(pObject
);
184 if( bActive
!= pInfo
->mbActive
)
185 nAnimationSet
= ATTR_MIXED
;
187 if( eEffect
!= pInfo
->meEffect
)
188 nEffectSet
= ATTR_MIXED
;
190 if( eTextEffect
!= pInfo
->meTextEffect
)
191 nTextEffectSet
= ATTR_MIXED
;
193 if( eSpeed
!= pInfo
->meSpeed
)
194 nSpeedSet
= ATTR_MIXED
;
196 if( bFadeOut
!= pInfo
->mbDimPrevious
)
197 nFadeOutSet
= ATTR_MIXED
;
199 if( aFadeColor
!= pInfo
->maDimColor
)
200 nFadeColorSet
= ATTR_MIXED
;
202 if( bInvisible
!= pInfo
->mbDimHide
)
203 nInvisibleSet
= ATTR_MIXED
;
205 if( bSoundOn
!= pInfo
->mbSoundOn
)
206 nSoundOnSet
= ATTR_MIXED
;
208 if( aSound
!= pInfo
->maSoundFile
)
209 nSoundFileSet
= ATTR_MIXED
;
211 if( bPlayFull
!= pInfo
->mbPlayFull
)
212 nPlayFullSet
= ATTR_MIXED
;
214 if( eClickAction
!= pInfo
->meClickAction
)
215 nClickActionSet
= ATTR_MIXED
;
217 if( aBookmark
!= pInfo
->GetBookmark() )
218 nBookmarkSet
= ATTR_MIXED
;
220 if( eSecondEffect
!= pInfo
->meSecondEffect
)
221 nSecondEffectSet
= ATTR_MIXED
;
223 if( eSecondSpeed
!= pInfo
->meSecondSpeed
)
224 nSecondSpeedSet
= ATTR_MIXED
;
226 if( bSecondSoundOn
!= pInfo
->mbSecondSoundOn
)
227 nSecondSoundOnSet
= ATTR_MIXED
;
229 if( bSecondPlayFull
!= pInfo
->mbSecondPlayFull
)
230 nSecondPlayFullSet
= ATTR_MIXED
;
234 if (nAnimationSet
== ATTR_SET
&& bActive
)
235 nAnimationSet
= ATTR_MIXED
;
237 if (nEffectSet
== ATTR_SET
&& eEffect
!= presentation::AnimationEffect_NONE
)
238 nEffectSet
= ATTR_MIXED
;
240 if (nTextEffectSet
== ATTR_SET
&& eTextEffect
!= presentation::AnimationEffect_NONE
)
241 nTextEffectSet
= ATTR_MIXED
;
243 if (nSpeedSet
== ATTR_SET
)
244 nSpeedSet
= ATTR_MIXED
;
246 if (nFadeOutSet
== ATTR_SET
&& bFadeOut
)
247 nFadeOutSet
= ATTR_MIXED
;
249 if (nFadeColorSet
== ATTR_SET
)
250 nFadeColorSet
= ATTR_MIXED
;
252 if (nInvisibleSet
== ATTR_SET
&& bInvisible
)
253 nInvisibleSet
= ATTR_MIXED
;
255 if (nSoundOnSet
== ATTR_SET
&& bSoundOn
)
256 nSoundOnSet
= ATTR_MIXED
;
258 if (nSoundFileSet
== ATTR_SET
)
259 nSoundFileSet
= ATTR_MIXED
;
261 if (nPlayFullSet
== ATTR_SET
&& bPlayFull
)
262 nPlayFullSet
= ATTR_MIXED
;
264 if (nClickActionSet
== ATTR_SET
&& eClickAction
!= presentation::ClickAction_NONE
)
265 nClickActionSet
= ATTR_MIXED
;
267 if (nBookmarkSet
== ATTR_SET
)
268 nBookmarkSet
= ATTR_MIXED
;
270 if (nSecondEffectSet
== ATTR_SET
&& eSecondEffect
!= presentation::AnimationEffect_NONE
)
271 nSecondEffectSet
= ATTR_MIXED
;
273 if (nSecondSpeedSet
== ATTR_SET
)
274 nSecondSpeedSet
= ATTR_MIXED
;
276 if (nSecondSoundOnSet
== ATTR_SET
&& bSecondSoundOn
)
277 nSecondSoundOnSet
= ATTR_MIXED
;
279 if (nSecondPlayFullSet
== ATTR_SET
&& bSecondPlayFull
)
280 nSecondPlayFullSet
= ATTR_MIXED
;
284 /* Exactly two objects with path effect?
285 Then, only the animation info at the moved object is valid. */
288 SdrObject
* pObject1
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
289 SdrObject
* pObject2
= rMarkList
.GetMark(1)->GetMarkedSdrObj();
290 SdrObjKind eKind1
= static_cast<SdrObjKind
>(pObject1
->GetObjIdentifier());
291 SdrObjKind eKind2
= static_cast<SdrObjKind
>(pObject2
->GetObjIdentifier());
292 SdAnimationInfo
* pInfo1
= SdDrawDocument::GetAnimationInfo(pObject1
);
293 SdAnimationInfo
* pInfo2
= SdDrawDocument::GetAnimationInfo(pObject2
);
296 if (pObject1
->GetObjInventor() == SdrInventor::Default
&&
297 ((eKind1
== OBJ_LINE
) || // 2 point line
298 (eKind1
== OBJ_PLIN
) || // Polygon
299 (eKind1
== OBJ_PATHLINE
)) && // Bezier curve
300 (pInfo2
&& pInfo2
->meEffect
== presentation::AnimationEffect_PATH
))
305 if (pObject2
->GetObjInventor() == SdrInventor::Default
&&
306 ((eKind2
== OBJ_LINE
) || // 2 point line
307 (eKind2
== OBJ_PLIN
) || // Polygon
308 (eKind2
== OBJ_PATHLINE
)) && // Bezier curve
309 (pInfo1
&& pInfo1
->meEffect
== presentation::AnimationEffect_PATH
))
316 bActive
= pInfo
->mbActive
; nAnimationSet
= ATTR_SET
;
317 eEffect
= pInfo
->meEffect
; nEffectSet
= ATTR_SET
;
318 eTextEffect
= pInfo
->meTextEffect
; nTextEffectSet
= ATTR_SET
;
319 eSpeed
= pInfo
->meSpeed
; nSpeedSet
= ATTR_SET
;
320 bFadeOut
= pInfo
->mbDimPrevious
; nFadeOutSet
= ATTR_SET
;
321 aFadeColor
= pInfo
->maDimColor
; nFadeColorSet
= ATTR_SET
;
322 bInvisible
= pInfo
->mbDimHide
; nInvisibleSet
= ATTR_SET
;
323 bSoundOn
= pInfo
->mbSoundOn
; nSoundOnSet
= ATTR_SET
;
324 aSound
= pInfo
->maSoundFile
; nSoundFileSet
= ATTR_SET
;
325 bPlayFull
= pInfo
->mbPlayFull
; nPlayFullSet
= ATTR_SET
;
326 eClickAction
= pInfo
->meClickAction
; nClickActionSet
= ATTR_SET
;
327 aBookmark
= pInfo
->GetBookmark(); nBookmarkSet
= ATTR_SET
;
328 eSecondEffect
= pInfo
->meSecondEffect
; nSecondEffectSet
= ATTR_SET
;
329 eSecondSpeed
= pInfo
->meSecondSpeed
; nSecondSpeedSet
= ATTR_SET
;
330 bSecondSoundOn
= pInfo
->mbSecondSoundOn
; nSecondSoundOnSet
= ATTR_SET
;
331 bSecondPlayFull
= pInfo
->mbSecondPlayFull
; nSecondPlayFullSet
= ATTR_SET
;
335 const SfxItemSet
* pArgs
= rReq
.GetArgs();
339 // fill ItemSet for dialog
340 SfxItemSet
aSet(mpDoc
->GetPool(), svl::Items
<ATTR_ANIMATION_START
, ATTR_ACTION_END
>{});
343 if (nAnimationSet
== ATTR_SET
)
344 aSet
.Put( SfxBoolItem( ATTR_ANIMATION_ACTIVE
, bActive
));
345 else if (nAnimationSet
== ATTR_MIXED
)
346 aSet
.InvalidateItem(ATTR_ANIMATION_ACTIVE
);
348 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_ACTIVE
, false));
350 if (nEffectSet
== ATTR_SET
)
351 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_EFFECT
, static_cast<sal_uInt16
>(eEffect
)));
352 else if (nEffectSet
== ATTR_MIXED
)
353 aSet
.InvalidateItem( ATTR_ANIMATION_EFFECT
);
355 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_EFFECT
, sal_uInt16(presentation::AnimationEffect_NONE
)));
357 if (nTextEffectSet
== ATTR_SET
)
358 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_TEXTEFFECT
, static_cast<sal_uInt16
>(eTextEffect
)));
359 else if (nTextEffectSet
== ATTR_MIXED
)
360 aSet
.InvalidateItem( ATTR_ANIMATION_TEXTEFFECT
);
362 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_TEXTEFFECT
, sal_uInt16(presentation::AnimationEffect_NONE
)));
364 if (nSpeedSet
== ATTR_SET
)
365 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_SPEED
, static_cast<sal_uInt16
>(eSpeed
)));
367 aSet
.InvalidateItem(ATTR_ANIMATION_SPEED
);
369 if (nFadeOutSet
== ATTR_SET
)
370 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_FADEOUT
, bFadeOut
));
371 else if (nFadeOutSet
== ATTR_MIXED
)
372 aSet
.InvalidateItem(ATTR_ANIMATION_FADEOUT
);
374 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_FADEOUT
, false));
376 if (nFadeColorSet
== ATTR_SET
)
377 aSet
.Put(SvxColorItem(aFadeColor
, ATTR_ANIMATION_COLOR
));
378 else if (nFadeColorSet
== ATTR_MIXED
)
379 aSet
.InvalidateItem(ATTR_ANIMATION_COLOR
);
381 aSet
.Put(SvxColorItem(COL_LIGHTGRAY
, ATTR_ANIMATION_COLOR
));
383 if (nInvisibleSet
== ATTR_SET
)
384 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_INVISIBLE
, bInvisible
));
385 else if (nInvisibleSet
== ATTR_MIXED
)
386 aSet
.InvalidateItem(ATTR_ANIMATION_INVISIBLE
);
388 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_INVISIBLE
, false));
390 if (nSoundOnSet
== ATTR_SET
)
391 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_SOUNDON
, bSoundOn
));
392 else if (nSoundOnSet
== ATTR_MIXED
)
393 aSet
.InvalidateItem(ATTR_ANIMATION_SOUNDON
);
395 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_SOUNDON
, false));
397 if (nSoundFileSet
== ATTR_SET
)
398 aSet
.Put(SfxStringItem(ATTR_ANIMATION_SOUNDFILE
, aSound
));
400 aSet
.InvalidateItem(ATTR_ANIMATION_SOUNDFILE
);
402 if (nPlayFullSet
== ATTR_SET
)
403 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_PLAYFULL
, bPlayFull
));
404 else if (nPlayFullSet
== ATTR_MIXED
)
405 aSet
.InvalidateItem(ATTR_ANIMATION_PLAYFULL
);
407 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_PLAYFULL
, false));
409 if (nClickActionSet
== ATTR_SET
)
410 aSet
.Put(SfxAllEnumItem(ATTR_ACTION
, static_cast<sal_uInt16
>(eClickAction
)));
411 else if (nClickActionSet
== ATTR_MIXED
)
412 aSet
.InvalidateItem(ATTR_ACTION
);
414 aSet
.Put(SfxAllEnumItem(ATTR_ACTION
, sal_uInt16(presentation::ClickAction_NONE
)));
416 if (nBookmarkSet
== ATTR_SET
)
417 aSet
.Put(SfxStringItem(ATTR_ACTION_FILENAME
, aBookmark
));
419 aSet
.InvalidateItem(ATTR_ACTION_FILENAME
);
421 if (nSecondEffectSet
== ATTR_SET
)
422 aSet
.Put(SfxAllEnumItem(ATTR_ACTION_EFFECT
, static_cast<sal_uInt16
>(eSecondEffect
)));
423 else if (nSecondEffectSet
== ATTR_MIXED
)
424 aSet
.InvalidateItem( ATTR_ACTION_EFFECT
);
426 aSet
.Put(SfxAllEnumItem(ATTR_ACTION_EFFECT
, sal_uInt16(presentation::AnimationEffect_NONE
)));
428 if (nSecondSpeedSet
== ATTR_SET
)
429 aSet
.Put(SfxAllEnumItem(ATTR_ACTION_EFFECTSPEED
, static_cast<sal_uInt16
>(eSecondSpeed
)));
431 aSet
.InvalidateItem(ATTR_ACTION_EFFECTSPEED
);
433 if (nSecondSoundOnSet
== ATTR_SET
)
434 aSet
.Put(SfxBoolItem(ATTR_ACTION_SOUNDON
, bSecondSoundOn
));
435 else if (nSecondSoundOnSet
== ATTR_MIXED
)
436 aSet
.InvalidateItem(ATTR_ACTION_SOUNDON
);
438 aSet
.Put(SfxBoolItem(ATTR_ACTION_SOUNDON
, false));
440 if (nSecondPlayFullSet
== ATTR_SET
)
441 aSet
.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL
, bSecondPlayFull
));
442 else if (nSecondPlayFullSet
== ATTR_MIXED
)
443 aSet
.InvalidateItem(ATTR_ACTION_PLAYFULL
);
445 aSet
.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL
, false));
447 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
448 ScopedVclPtr
<SfxAbstractDialog
> pDlg(pFact
? pFact
->CreatSdActionDialog(mpViewShell
->GetActiveWindow(), &aSet
, mpView
) : nullptr);
450 short nResult
= pDlg
? pDlg
->Execute() : static_cast<short>(RET_CANCEL
);
452 if( nResult
== RET_OK
)
454 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
455 pArgs
= rReq
.GetArgs();
458 if( nResult
!= RET_OK
)
462 // evaluation of the ItemSets
463 if (pArgs
->GetItemState(ATTR_ANIMATION_ACTIVE
) == SfxItemState::SET
)
465 bActive
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ANIMATION_ACTIVE
)).GetValue();
466 nAnimationSet
= ATTR_SET
;
469 nAnimationSet
= ATTR_MISSING
;
471 if (pArgs
->GetItemState(ATTR_ANIMATION_EFFECT
) == SfxItemState::SET
)
473 eEffect
= static_cast<presentation::AnimationEffect
>(static_cast<const SfxAllEnumItem
&>( pArgs
->
474 Get(ATTR_ANIMATION_EFFECT
)).GetValue());
475 nEffectSet
= ATTR_SET
;
478 nEffectSet
= ATTR_MISSING
;
480 if (pArgs
->GetItemState(ATTR_ANIMATION_TEXTEFFECT
) == SfxItemState::SET
)
482 eTextEffect
= static_cast<presentation::AnimationEffect
>(static_cast<const SfxAllEnumItem
&>( pArgs
->
483 Get(ATTR_ANIMATION_TEXTEFFECT
)).GetValue());
484 nTextEffectSet
= ATTR_SET
;
487 nTextEffectSet
= ATTR_MISSING
;
489 if (pArgs
->GetItemState(ATTR_ANIMATION_SPEED
) == SfxItemState::SET
)
491 eSpeed
= static_cast<presentation::AnimationSpeed
>(static_cast<const SfxAllEnumItem
&>( pArgs
->
492 Get(ATTR_ANIMATION_SPEED
)).GetValue());
493 nSpeedSet
= ATTR_SET
;
496 nSpeedSet
= ATTR_MISSING
;
498 if (pArgs
->GetItemState(ATTR_ANIMATION_FADEOUT
) == SfxItemState::SET
)
500 bFadeOut
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ANIMATION_FADEOUT
)).GetValue();
501 nFadeOutSet
= ATTR_SET
;
504 nFadeOutSet
= ATTR_MISSING
;
506 if (pArgs
->GetItemState(ATTR_ANIMATION_INVISIBLE
) == SfxItemState::SET
)
508 bInvisible
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ANIMATION_INVISIBLE
)).GetValue();
509 nInvisibleSet
= ATTR_SET
;
512 nInvisibleSet
= ATTR_MISSING
;
514 if (pArgs
->GetItemState(ATTR_ANIMATION_SOUNDON
) == SfxItemState::SET
)
516 bSoundOn
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ANIMATION_SOUNDON
)).GetValue();
517 nSoundOnSet
= ATTR_SET
;
520 nSoundOnSet
= ATTR_MISSING
;
522 if (pArgs
->GetItemState(ATTR_ANIMATION_SOUNDFILE
) == SfxItemState::SET
)
524 aSound
= static_cast<const SfxStringItem
&>(pArgs
->Get(ATTR_ANIMATION_SOUNDFILE
)).GetValue();
525 nSoundFileSet
= ATTR_SET
;
528 nSoundFileSet
= ATTR_MISSING
;
530 if (pArgs
->GetItemState(ATTR_ANIMATION_COLOR
) == SfxItemState::SET
)
532 aFadeColor
= static_cast<const SvxColorItem
&>(pArgs
->Get(ATTR_ANIMATION_COLOR
)).GetValue();
533 nFadeColorSet
= ATTR_SET
;
536 nFadeColorSet
= ATTR_MISSING
;
538 if (pArgs
->GetItemState(ATTR_ANIMATION_PLAYFULL
) == SfxItemState::SET
)
540 bPlayFull
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ANIMATION_PLAYFULL
)).GetValue();
541 nPlayFullSet
= ATTR_SET
;
544 nPlayFullSet
= ATTR_MISSING
;
546 if (pArgs
->GetItemState(ATTR_ACTION
) == SfxItemState::SET
)
548 eClickAction
= static_cast<presentation::ClickAction
>(static_cast<const SfxAllEnumItem
&>(pArgs
->
549 Get(ATTR_ACTION
)).GetValue());
550 nClickActionSet
= ATTR_SET
;
553 nClickActionSet
= ATTR_MISSING
;
555 if (pArgs
->GetItemState(ATTR_ACTION_FILENAME
) == SfxItemState::SET
)
557 aBookmark
= static_cast<const SfxStringItem
&>(pArgs
->
558 Get(ATTR_ACTION_FILENAME
)).GetValue();
559 nBookmarkSet
= ATTR_SET
;
562 nBookmarkSet
= ATTR_MISSING
;
564 if (pArgs
->GetItemState(ATTR_ACTION_EFFECT
) == SfxItemState::SET
)
566 eSecondEffect
= static_cast<presentation::AnimationEffect
>(static_cast<const SfxAllEnumItem
&>( pArgs
->
567 Get(ATTR_ACTION_EFFECT
)).GetValue());
568 nSecondEffectSet
= ATTR_SET
;
571 nSecondEffectSet
= ATTR_MISSING
;
573 if (pArgs
->GetItemState(ATTR_ACTION_EFFECTSPEED
) == SfxItemState::SET
)
575 eSecondSpeed
= static_cast<presentation::AnimationSpeed
>(static_cast<const SfxAllEnumItem
&>( pArgs
->
576 Get(ATTR_ACTION_EFFECTSPEED
)).GetValue());
577 nSecondSpeedSet
= ATTR_SET
;
580 nSecondSpeedSet
= ATTR_MISSING
;
582 if (pArgs
->GetItemState(ATTR_ACTION_SOUNDON
) == SfxItemState::SET
)
584 bSecondSoundOn
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ACTION_SOUNDON
)).GetValue();
585 nSecondSoundOnSet
= ATTR_SET
;
588 nSecondSoundOnSet
= ATTR_MISSING
;
590 if (pArgs
->GetItemState(ATTR_ACTION_PLAYFULL
) == SfxItemState::SET
)
592 bSecondPlayFull
= static_cast<const SfxBoolItem
&>(pArgs
->Get(ATTR_ACTION_PLAYFULL
)).GetValue();
593 nSecondPlayFullSet
= ATTR_SET
;
596 nSecondPlayFullSet
= ATTR_MISSING
;
598 // if any attribute is chosen
599 if (nEffectSet
== ATTR_SET
||
600 nTextEffectSet
== ATTR_SET
||
601 nSpeedSet
== ATTR_SET
||
602 nAnimationSet
== ATTR_SET
||
603 nFadeOutSet
== ATTR_SET
||
604 nFadeColorSet
== ATTR_SET
||
605 nInvisibleSet
== ATTR_SET
||
606 nSoundOnSet
== ATTR_SET
||
607 nSoundFileSet
== ATTR_SET
||
608 nPlayFullSet
== ATTR_SET
||
609 nClickActionSet
== ATTR_SET
||
610 nBookmarkSet
== ATTR_SET
||
611 nSecondEffectSet
== ATTR_SET
||
612 nSecondSpeedSet
== ATTR_SET
||
613 nSecondSoundOnSet
== ATTR_SET
||
614 nSecondPlayFullSet
== ATTR_SET
)
616 // String for undo-group and list-action
617 OUString
aComment(SdResId(STR_UNDO_ANIMATION
));
619 // with 'following curves', we have an additional UndoAction
620 // therefore cling? here
621 pUndoMgr
->EnterListAction(aComment
, aComment
, 0, mpViewShell
->GetViewShellBase().GetViewShellId());
624 SdUndoGroup
* pUndoGroup
= new SdUndoGroup(mpDoc
);
625 pUndoGroup
->SetComment(aComment
);
627 // for the path effect, remember some stuff
628 SdrPathObj
* pPath
= nullptr;
629 if (eEffect
== presentation::AnimationEffect_PATH
&& nEffectSet
== ATTR_SET
)
631 DBG_ASSERT(nCount
== 2, "This effect expects two selected objects");
632 SdrObject
* pObject1
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
633 SdrObject
* pObject2
= rMarkList
.GetMark(1)->GetMarkedSdrObj();
634 SdrObjKind eKind1
= static_cast<SdrObjKind
>(pObject1
->GetObjIdentifier());
635 SdrObjKind eKind2
= static_cast<SdrObjKind
>(pObject2
->GetObjIdentifier());
636 SdrObject
* pRunningObj
= nullptr;
638 if (pObject1
->GetObjInventor() == SdrInventor::Default
&&
639 ((eKind1
== OBJ_LINE
) || // 2 point line
640 (eKind1
== OBJ_PLIN
) || // Polygon
641 (eKind1
== OBJ_PATHLINE
))) // Bezier curve
643 pPath
= static_cast<SdrPathObj
*>(pObject1
);
644 pRunningObj
= pObject2
;
647 if (pObject2
->GetObjInventor() == SdrInventor::Default
&&
648 ((eKind2
== OBJ_LINE
) || // 2 point line
649 (eKind2
== OBJ_PLIN
) || // Polygon
650 (eKind2
== OBJ_PATHLINE
))) // Bezier curve
652 pPath
= static_cast<SdrPathObj
*>(pObject2
);
653 pRunningObj
= pObject1
;
656 assert(pRunningObj
&& pPath
&& "no curve found");
658 // push the running object to the end of the curve
661 ::tools::Rectangle
aCurRect(pRunningObj
->GetLogicRect());
662 Point
aCurCenter(aCurRect
.Center());
663 const ::basegfx::B2DPolyPolygon
& rPolyPolygon
= pPath
->GetPathPoly();
664 sal_uInt32
nNoOfPolygons(rPolyPolygon
.count());
665 const ::basegfx::B2DPolygon
aPolygon(rPolyPolygon
.getB2DPolygon(nNoOfPolygons
- 1));
666 sal_uInt32
nPoints(aPolygon
.count());
667 const ::basegfx::B2DPoint
aNewB2DCenter(aPolygon
.getB2DPoint(nPoints
- 1));
668 const Point
aNewCenter(FRound(aNewB2DCenter
.getX()), FRound(aNewB2DCenter
.getY()));
669 Size
aDistance(aNewCenter
.X() - aCurCenter
.X(), aNewCenter
.Y() - aCurCenter
.Y());
670 pRunningObj
->Move(aDistance
);
672 pUndoMgr
->AddUndoAction(mpDoc
->GetSdrUndoFactory().CreateUndoMoveObject( *pRunningObj
, aDistance
));
676 for (size_t nObject
= 0; nObject
< nCount
; ++nObject
)
678 SdrObject
* pObject
= rMarkList
.GetMark(nObject
)->GetMarkedSdrObj();
680 pInfo
= SdDrawDocument::GetAnimationInfo(pObject
);
682 bool bCreated
= false;
685 pInfo
= SdDrawDocument::GetShapeUserData(*pObject
,true);
689 // path object for 'following curves'?
690 if (eEffect
== presentation::AnimationEffect_PATH
&& pObject
== pPath
)
692 SdAnimationPrmsUndoAction
* pAction
= new SdAnimationPrmsUndoAction
693 (mpDoc
, pObject
, bCreated
);
694 pAction
->SetActive(pInfo
->mbActive
, pInfo
->mbActive
);
695 pAction
->SetEffect(pInfo
->meEffect
, pInfo
->meEffect
);
696 pAction
->SetTextEffect(pInfo
->meTextEffect
, pInfo
->meTextEffect
);
697 pAction
->SetSpeed(pInfo
->meSpeed
, pInfo
->meSpeed
);
698 pAction
->SetDim(pInfo
->mbDimPrevious
, pInfo
->mbDimPrevious
);
699 pAction
->SetDimColor(pInfo
->maDimColor
, pInfo
->maDimColor
);
700 pAction
->SetDimHide(pInfo
->mbDimHide
, pInfo
->mbDimHide
);
701 pAction
->SetSoundOn(pInfo
->mbSoundOn
, pInfo
->mbSoundOn
);
702 pAction
->SetSound(pInfo
->maSoundFile
, pInfo
->maSoundFile
);
703 pAction
->SetPlayFull(pInfo
->mbPlayFull
, pInfo
->mbPlayFull
);
704 pAction
->SetClickAction(pInfo
->meClickAction
, pInfo
->meClickAction
);
705 pAction
->SetBookmark(pInfo
->GetBookmark(), pInfo
->GetBookmark());
706 pAction
->SetVerb(pInfo
->mnVerb
, pInfo
->mnVerb
);
707 pAction
->SetSecondEffect(pInfo
->meSecondEffect
, pInfo
->meSecondEffect
);
708 pAction
->SetSecondSpeed(pInfo
->meSecondSpeed
, pInfo
->meSecondSpeed
);
709 pAction
->SetSecondSoundOn(pInfo
->mbSecondSoundOn
, pInfo
->mbSecondSoundOn
);
710 pAction
->SetSecondPlayFull(pInfo
->mbSecondPlayFull
, pInfo
->mbSecondPlayFull
);
711 pUndoGroup
->AddAction(pAction
);
717 // create undo action with old and new sizes
718 SdAnimationPrmsUndoAction
* pAction
= new SdAnimationPrmsUndoAction
719 (mpDoc
, pObject
, bCreated
);
720 pAction
->SetActive(pInfo
->mbActive
, bActive
);
721 pAction
->SetEffect(pInfo
->meEffect
, eEffect
);
722 pAction
->SetTextEffect(pInfo
->meTextEffect
, eTextEffect
);
723 pAction
->SetSpeed(pInfo
->meSpeed
, eSpeed
);
724 pAction
->SetDim(pInfo
->mbDimPrevious
, bFadeOut
);
725 pAction
->SetDimColor(pInfo
->maDimColor
, aFadeColor
);
726 pAction
->SetDimHide(pInfo
->mbDimHide
, bInvisible
);
727 pAction
->SetSoundOn(pInfo
->mbSoundOn
, bSoundOn
);
728 pAction
->SetSound(pInfo
->maSoundFile
, aSound
);
729 pAction
->SetPlayFull(pInfo
->mbPlayFull
, bPlayFull
);
730 pAction
->SetClickAction(pInfo
->meClickAction
, eClickAction
);
731 pAction
->SetBookmark(pInfo
->GetBookmark(), aBookmark
);
732 pAction
->SetVerb(pInfo
->mnVerb
, static_cast<sal_uInt16
>(pInfo
->GetBookmark().toInt32()) );
733 pAction
->SetSecondEffect(pInfo
->meSecondEffect
, eSecondEffect
);
734 pAction
->SetSecondSpeed(pInfo
->meSecondSpeed
, eSecondSpeed
);
735 pAction
->SetSecondSoundOn(pInfo
->mbSecondSoundOn
, bSecondSoundOn
);
736 pAction
->SetSecondPlayFull(pInfo
->mbSecondPlayFull
,bSecondPlayFull
);
737 pUndoGroup
->AddAction(pAction
);
739 // insert new values at info block of the object
740 if (nAnimationSet
== ATTR_SET
)
741 pInfo
->mbActive
= bActive
;
743 if (nEffectSet
== ATTR_SET
)
744 pInfo
->meEffect
= eEffect
;
746 if (nTextEffectSet
== ATTR_SET
)
747 pInfo
->meTextEffect
= eTextEffect
;
749 if (nSpeedSet
== ATTR_SET
)
750 pInfo
->meSpeed
= eSpeed
;
752 if (nFadeOutSet
== ATTR_SET
)
753 pInfo
->mbDimPrevious
= bFadeOut
;
755 if (nFadeColorSet
== ATTR_SET
)
756 pInfo
->maDimColor
= aFadeColor
;
758 if (nInvisibleSet
== ATTR_SET
)
759 pInfo
->mbDimHide
= bInvisible
;
761 if (nSoundOnSet
== ATTR_SET
)
762 pInfo
->mbSoundOn
= bSoundOn
;
764 if (nSoundFileSet
== ATTR_SET
)
765 pInfo
->maSoundFile
= aSound
;
767 if (nPlayFullSet
== ATTR_SET
)
768 pInfo
->mbPlayFull
= bPlayFull
;
770 if (nClickActionSet
== ATTR_SET
)
771 pInfo
->meClickAction
= eClickAction
;
773 if (nBookmarkSet
== ATTR_SET
)
774 pInfo
->SetBookmark( aBookmark
);
776 if (nSecondEffectSet
== ATTR_SET
)
777 pInfo
->meSecondEffect
= eSecondEffect
;
779 if (nSecondSpeedSet
== ATTR_SET
)
780 pInfo
->meSecondSpeed
= eSecondSpeed
;
782 if (nSecondSoundOnSet
== ATTR_SET
)
783 pInfo
->mbSecondSoundOn
= bSecondSoundOn
;
785 if (nSecondPlayFullSet
== ATTR_SET
)
786 pInfo
->mbSecondPlayFull
= bSecondPlayFull
;
788 if (eClickAction
== presentation::ClickAction_VERB
)
789 pInfo
->mnVerb
= static_cast<sal_uInt16
>(aBookmark
.toInt32());
792 // Set the Undo Group in of the Undo Manager
793 pUndoMgr
->AddUndoAction(pUndoGroup
);
794 pUndoMgr
->LeaveListAction();
799 // not seen, therefore we do not need to invalidate at the bindings
802 } // end of namespace sd
804 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */