bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / func / fuoaprms.cxx
blob7f8b9302f23e17aad36721c6a56e5a096836342d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
21 #include <sdattr.hrc>
23 #include <editeng/colritem.hxx>
24 #include <svx/svdundo.hxx>
25 #include <sfx2/objsh.hxx>
26 #include <sfx2/request.hxx>
27 #include <sfx2/viewfrm.hxx>
28 #include <sfx2/sfxdlg.hxx>
29 #include <svl/aeitem.hxx>
30 #include <svl/stritem.hxx>
31 #include <svx/svdopath.hxx>
32 #include <tools/debug.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>
41 #include <View.hxx>
42 #include <sdabstdlg.hxx>
43 #include <sdresid.hxx>
44 #include <tools/helpers.hxx>
45 #include <basegfx/polygon/b2dpolygon.hxx>
46 #include <memory>
48 using namespace ::com::sun::star;
50 namespace sd {
53 #define ATTR_MISSING 0 ///< Attribute missing
54 #define ATTR_MIXED 1 ///< Attribute ambiguous (on multi-selection)
55 #define ATTR_SET 2 ///< Attribute unique
57 FuObjectAnimationParameters::FuObjectAnimationParameters (
58 ViewShell* pViewSh,
59 ::sd::Window* pWin,
60 ::sd::View* pView,
61 SdDrawDocument* pDoc,
62 SfxRequest& rReq)
63 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
67 rtl::Reference<FuPoor> FuObjectAnimationParameters::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
69 rtl::Reference<FuPoor> xFunc( new FuObjectAnimationParameters( pViewSh, pWin, pView, pDoc, rReq ) );
70 xFunc->DoExecute(rReq);
71 return xFunc;
74 void FuObjectAnimationParameters::DoExecute( SfxRequest& rReq )
76 SfxUndoManager* pUndoMgr = mpViewShell->GetViewFrame()->GetObjectShell()->GetUndoManager();
78 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
79 const size_t nCount = rMarkList.GetMarkCount();
81 short nAnimationSet = ATTR_MISSING;
82 short nEffectSet = ATTR_MISSING;
83 short nTextEffectSet = ATTR_MISSING;
84 short nSpeedSet = ATTR_MISSING;
85 short nFadeColorSet = ATTR_MISSING;
86 short nFadeOutSet = ATTR_MISSING;
87 short nInvisibleSet = ATTR_MISSING;
88 short nSoundOnSet = ATTR_MISSING;
89 short nSoundFileSet = ATTR_MISSING;
90 short nPlayFullSet = ATTR_MISSING;
91 short nClickActionSet = ATTR_MISSING;
92 short nBookmarkSet = ATTR_MISSING;
94 short nSecondEffectSet = ATTR_MISSING;
95 short nSecondSpeedSet = ATTR_MISSING;
96 short nSecondSoundOnSet = ATTR_MISSING;
97 short nSecondPlayFullSet = ATTR_MISSING;
99 // defaults (for Undo-Action)
100 presentation::AnimationEffect eEffect = presentation::AnimationEffect_NONE;
101 presentation::AnimationEffect eTextEffect = presentation::AnimationEffect_NONE;
102 presentation::AnimationSpeed eSpeed = presentation::AnimationSpeed_MEDIUM;
103 bool bActive = false;
104 bool bFadeOut = false;
105 Color aFadeColor = COL_LIGHTGRAY;
106 bool bInvisible = false;
107 bool bSoundOn = false;
108 OUString aSound;
109 bool bPlayFull = false;
110 presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
111 OUString aBookmark;
113 presentation::AnimationEffect eSecondEffect = presentation::AnimationEffect_NONE;
114 presentation::AnimationSpeed eSecondSpeed = presentation::AnimationSpeed_MEDIUM;
115 bool bSecondSoundOn = false;
116 bool bSecondPlayFull = false;
118 SdAnimationInfo* pInfo;
119 SdrMark* pMark;
121 // inspect first object
122 pMark = rMarkList.GetMark(0);
123 pInfo = SdDrawDocument::GetAnimationInfo(pMark->GetMarkedSdrObj());
124 if( pInfo )
126 bActive = pInfo->mbActive;
127 nAnimationSet = ATTR_SET;
129 eEffect = pInfo->meEffect;
130 nEffectSet = ATTR_SET;
132 eTextEffect = pInfo->meTextEffect;
133 nTextEffectSet = ATTR_SET;
135 eSpeed = pInfo->meSpeed;
136 nSpeedSet = ATTR_SET;
138 bFadeOut = pInfo->mbDimPrevious;
139 nFadeOutSet = ATTR_SET;
141 aFadeColor = pInfo->maDimColor;
142 nFadeColorSet = ATTR_SET;
144 bInvisible = pInfo->mbDimHide;
145 nInvisibleSet = ATTR_SET;
147 bSoundOn = pInfo->mbSoundOn;
148 nSoundOnSet = ATTR_SET;
150 aSound = pInfo->maSoundFile;
151 nSoundFileSet = ATTR_SET;
153 bPlayFull = pInfo->mbPlayFull;
154 nPlayFullSet = ATTR_SET;
156 eClickAction = pInfo->meClickAction;
157 nClickActionSet = ATTR_SET;
159 aBookmark = pInfo->GetBookmark();
160 nBookmarkSet = ATTR_SET;
162 eSecondEffect = pInfo->meSecondEffect;
163 nSecondEffectSet = ATTR_SET;
165 eSecondSpeed = pInfo->meSecondSpeed;
166 nSecondSpeedSet = ATTR_SET;
168 bSecondSoundOn = pInfo->mbSecondSoundOn;
169 nSecondSoundOnSet = ATTR_SET;
171 bSecondPlayFull = pInfo->mbSecondPlayFull;
172 nSecondPlayFullSet = ATTR_SET;
175 // if necessary, inspect more objects
176 for( size_t nObject = 1; nObject < nCount; ++nObject )
178 pMark = rMarkList.GetMark( nObject );
179 SdrObject* pObject = pMark->GetMarkedSdrObj();
180 pInfo = SdDrawDocument::GetAnimationInfo(pObject);
181 if( pInfo )
183 if( bActive != pInfo->mbActive )
184 nAnimationSet = ATTR_MIXED;
186 if( eEffect != pInfo->meEffect )
187 nEffectSet = ATTR_MIXED;
189 if( eTextEffect != pInfo->meTextEffect )
190 nTextEffectSet = ATTR_MIXED;
192 if( eSpeed != pInfo->meSpeed )
193 nSpeedSet = ATTR_MIXED;
195 if( bFadeOut != pInfo->mbDimPrevious )
196 nFadeOutSet = ATTR_MIXED;
198 if( aFadeColor != pInfo->maDimColor )
199 nFadeColorSet = ATTR_MIXED;
201 if( bInvisible != pInfo->mbDimHide )
202 nInvisibleSet = ATTR_MIXED;
204 if( bSoundOn != pInfo->mbSoundOn )
205 nSoundOnSet = ATTR_MIXED;
207 if( aSound != pInfo->maSoundFile )
208 nSoundFileSet = ATTR_MIXED;
210 if( bPlayFull != pInfo->mbPlayFull )
211 nPlayFullSet = ATTR_MIXED;
213 if( eClickAction != pInfo->meClickAction )
214 nClickActionSet = ATTR_MIXED;
216 if( aBookmark != pInfo->GetBookmark() )
217 nBookmarkSet = ATTR_MIXED;
219 if( eSecondEffect != pInfo->meSecondEffect )
220 nSecondEffectSet = ATTR_MIXED;
222 if( eSecondSpeed != pInfo->meSecondSpeed )
223 nSecondSpeedSet = ATTR_MIXED;
225 if( bSecondSoundOn != pInfo->mbSecondSoundOn )
226 nSecondSoundOnSet = ATTR_MIXED;
228 if( bSecondPlayFull != pInfo->mbSecondPlayFull )
229 nSecondPlayFullSet = ATTR_MIXED;
231 else
233 if (nAnimationSet == ATTR_SET && bActive)
234 nAnimationSet = ATTR_MIXED;
236 if (nEffectSet == ATTR_SET && eEffect != presentation::AnimationEffect_NONE)
237 nEffectSet = ATTR_MIXED;
239 if (nTextEffectSet == ATTR_SET && eTextEffect != presentation::AnimationEffect_NONE)
240 nTextEffectSet = ATTR_MIXED;
242 if (nSpeedSet == ATTR_SET)
243 nSpeedSet = ATTR_MIXED;
245 if (nFadeOutSet == ATTR_SET && bFadeOut)
246 nFadeOutSet = ATTR_MIXED;
248 if (nFadeColorSet == ATTR_SET)
249 nFadeColorSet = ATTR_MIXED;
251 if (nInvisibleSet == ATTR_SET && bInvisible)
252 nInvisibleSet = ATTR_MIXED;
254 if (nSoundOnSet == ATTR_SET && bSoundOn)
255 nSoundOnSet = ATTR_MIXED;
257 if (nSoundFileSet == ATTR_SET)
258 nSoundFileSet = ATTR_MIXED;
260 if (nPlayFullSet == ATTR_SET && bPlayFull)
261 nPlayFullSet = ATTR_MIXED;
263 if (nClickActionSet == ATTR_SET && eClickAction != presentation::ClickAction_NONE)
264 nClickActionSet = ATTR_MIXED;
266 if (nBookmarkSet == ATTR_SET)
267 nBookmarkSet = ATTR_MIXED;
269 if (nSecondEffectSet == ATTR_SET && eSecondEffect != presentation::AnimationEffect_NONE)
270 nSecondEffectSet = ATTR_MIXED;
272 if (nSecondSpeedSet == ATTR_SET)
273 nSecondSpeedSet = ATTR_MIXED;
275 if (nSecondSoundOnSet == ATTR_SET && bSecondSoundOn)
276 nSecondSoundOnSet = ATTR_MIXED;
278 if (nSecondPlayFullSet == ATTR_SET && bSecondPlayFull)
279 nSecondPlayFullSet = ATTR_MIXED;
283 /* Exactly two objects with path effect?
284 Then, only the animation info at the moved object is valid. */
285 if (nCount == 2)
287 SdrObject* pObject1 = rMarkList.GetMark(0)->GetMarkedSdrObj();
288 SdrObject* pObject2 = rMarkList.GetMark(1)->GetMarkedSdrObj();
289 SdrObjKind eKind1 = static_cast<SdrObjKind>(pObject1->GetObjIdentifier());
290 SdrObjKind eKind2 = static_cast<SdrObjKind>(pObject2->GetObjIdentifier());
291 SdAnimationInfo* pInfo1 = SdDrawDocument::GetAnimationInfo(pObject1);
292 SdAnimationInfo* pInfo2 = SdDrawDocument::GetAnimationInfo(pObject2);
293 pInfo = nullptr;
295 if (pObject1->GetObjInventor() == SdrInventor::Default &&
296 ((eKind1 == OBJ_LINE) || // 2 point line
297 (eKind1 == OBJ_PLIN) || // Polygon
298 (eKind1 == OBJ_PATHLINE)) && // Bezier curve
299 (pInfo2 && pInfo2->meEffect == presentation::AnimationEffect_PATH))
301 pInfo = pInfo2;
304 if (pObject2->GetObjInventor() == SdrInventor::Default &&
305 ((eKind2 == OBJ_LINE) || // 2 point line
306 (eKind2 == OBJ_PLIN) || // Polygon
307 (eKind2 == OBJ_PATHLINE)) && // Bezier curve
308 (pInfo1 && pInfo1->meEffect == presentation::AnimationEffect_PATH))
310 pInfo = pInfo1;
313 if (pInfo)
315 bActive = pInfo->mbActive; nAnimationSet = ATTR_SET;
316 eEffect = pInfo->meEffect; nEffectSet = ATTR_SET;
317 eTextEffect = pInfo->meTextEffect; nTextEffectSet = ATTR_SET;
318 eSpeed = pInfo->meSpeed; nSpeedSet = ATTR_SET;
319 bFadeOut = pInfo->mbDimPrevious; nFadeOutSet = ATTR_SET;
320 aFadeColor = pInfo->maDimColor; nFadeColorSet = ATTR_SET;
321 bInvisible = pInfo->mbDimHide; nInvisibleSet = ATTR_SET;
322 bSoundOn = pInfo->mbSoundOn; nSoundOnSet = ATTR_SET;
323 aSound = pInfo->maSoundFile; nSoundFileSet = ATTR_SET;
324 bPlayFull = pInfo->mbPlayFull; nPlayFullSet = ATTR_SET;
325 eClickAction = pInfo->meClickAction; nClickActionSet = ATTR_SET;
326 aBookmark = pInfo->GetBookmark(); nBookmarkSet = ATTR_SET;
327 eSecondEffect = pInfo->meSecondEffect; nSecondEffectSet = ATTR_SET;
328 eSecondSpeed = pInfo->meSecondSpeed; nSecondSpeedSet = ATTR_SET;
329 bSecondSoundOn = pInfo->mbSecondSoundOn; nSecondSoundOnSet = ATTR_SET;
330 bSecondPlayFull = pInfo->mbSecondPlayFull; nSecondPlayFullSet = ATTR_SET;
334 const SfxItemSet* pArgs = rReq.GetArgs();
336 if(!pArgs)
338 // fill ItemSet for dialog
339 SfxItemSet aSet(mpDoc->GetPool(), svl::Items<ATTR_ANIMATION_START, ATTR_ACTION_END>{});
341 // fill the set
342 if (nAnimationSet == ATTR_SET)
343 aSet.Put( SfxBoolItem( ATTR_ANIMATION_ACTIVE, bActive));
344 else if (nAnimationSet == ATTR_MIXED)
345 aSet.InvalidateItem(ATTR_ANIMATION_ACTIVE);
346 else
347 aSet.Put(SfxBoolItem(ATTR_ANIMATION_ACTIVE, false));
349 if (nEffectSet == ATTR_SET)
350 aSet.Put(SfxAllEnumItem(ATTR_ANIMATION_EFFECT, static_cast<sal_uInt16>(eEffect)));
351 else if (nEffectSet == ATTR_MIXED)
352 aSet.InvalidateItem( ATTR_ANIMATION_EFFECT );
353 else
354 aSet.Put(SfxAllEnumItem(ATTR_ANIMATION_EFFECT, sal_uInt16(presentation::AnimationEffect_NONE)));
356 if (nTextEffectSet == ATTR_SET)
357 aSet.Put(SfxAllEnumItem(ATTR_ANIMATION_TEXTEFFECT, static_cast<sal_uInt16>(eTextEffect)));
358 else if (nTextEffectSet == ATTR_MIXED)
359 aSet.InvalidateItem( ATTR_ANIMATION_TEXTEFFECT );
360 else
361 aSet.Put(SfxAllEnumItem(ATTR_ANIMATION_TEXTEFFECT, sal_uInt16(presentation::AnimationEffect_NONE)));
363 if (nSpeedSet == ATTR_SET)
364 aSet.Put(SfxAllEnumItem(ATTR_ANIMATION_SPEED, static_cast<sal_uInt16>(eSpeed)));
365 else
366 aSet.InvalidateItem(ATTR_ANIMATION_SPEED);
368 if (nFadeOutSet == ATTR_SET)
369 aSet.Put(SfxBoolItem(ATTR_ANIMATION_FADEOUT, bFadeOut));
370 else if (nFadeOutSet == ATTR_MIXED)
371 aSet.InvalidateItem(ATTR_ANIMATION_FADEOUT);
372 else
373 aSet.Put(SfxBoolItem(ATTR_ANIMATION_FADEOUT, false));
375 if (nFadeColorSet == ATTR_SET)
376 aSet.Put(SvxColorItem(aFadeColor, ATTR_ANIMATION_COLOR));
377 else if (nFadeColorSet == ATTR_MIXED)
378 aSet.InvalidateItem(ATTR_ANIMATION_COLOR);
379 else
380 aSet.Put(SvxColorItem(COL_LIGHTGRAY, ATTR_ANIMATION_COLOR));
382 if (nInvisibleSet == ATTR_SET)
383 aSet.Put(SfxBoolItem(ATTR_ANIMATION_INVISIBLE, bInvisible));
384 else if (nInvisibleSet == ATTR_MIXED)
385 aSet.InvalidateItem(ATTR_ANIMATION_INVISIBLE);
386 else
387 aSet.Put(SfxBoolItem(ATTR_ANIMATION_INVISIBLE, false));
389 if (nSoundOnSet == ATTR_SET)
390 aSet.Put(SfxBoolItem(ATTR_ANIMATION_SOUNDON, bSoundOn));
391 else if (nSoundOnSet == ATTR_MIXED)
392 aSet.InvalidateItem(ATTR_ANIMATION_SOUNDON);
393 else
394 aSet.Put(SfxBoolItem(ATTR_ANIMATION_SOUNDON, false));
396 if (nSoundFileSet == ATTR_SET)
397 aSet.Put(SfxStringItem(ATTR_ANIMATION_SOUNDFILE, aSound));
398 else
399 aSet.InvalidateItem(ATTR_ANIMATION_SOUNDFILE);
401 if (nPlayFullSet == ATTR_SET)
402 aSet.Put(SfxBoolItem(ATTR_ANIMATION_PLAYFULL, bPlayFull));
403 else if (nPlayFullSet == ATTR_MIXED)
404 aSet.InvalidateItem(ATTR_ANIMATION_PLAYFULL);
405 else
406 aSet.Put(SfxBoolItem(ATTR_ANIMATION_PLAYFULL, false));
408 if (nClickActionSet == ATTR_SET)
409 aSet.Put(SfxAllEnumItem(ATTR_ACTION, static_cast<sal_uInt16>(eClickAction)));
410 else if (nClickActionSet == ATTR_MIXED)
411 aSet.InvalidateItem(ATTR_ACTION);
412 else
413 aSet.Put(SfxAllEnumItem(ATTR_ACTION, sal_uInt16(presentation::ClickAction_NONE)));
415 if (nBookmarkSet == ATTR_SET)
416 aSet.Put(SfxStringItem(ATTR_ACTION_FILENAME, aBookmark));
417 else
418 aSet.InvalidateItem(ATTR_ACTION_FILENAME);
420 if (nSecondEffectSet == ATTR_SET)
421 aSet.Put(SfxAllEnumItem(ATTR_ACTION_EFFECT, static_cast<sal_uInt16>(eSecondEffect)));
422 else if (nSecondEffectSet == ATTR_MIXED)
423 aSet.InvalidateItem( ATTR_ACTION_EFFECT );
424 else
425 aSet.Put(SfxAllEnumItem(ATTR_ACTION_EFFECT, sal_uInt16(presentation::AnimationEffect_NONE)));
427 if (nSecondSpeedSet == ATTR_SET)
428 aSet.Put(SfxAllEnumItem(ATTR_ACTION_EFFECTSPEED, static_cast<sal_uInt16>(eSecondSpeed)));
429 else
430 aSet.InvalidateItem(ATTR_ACTION_EFFECTSPEED);
432 if (nSecondSoundOnSet == ATTR_SET)
433 aSet.Put(SfxBoolItem(ATTR_ACTION_SOUNDON, bSecondSoundOn));
434 else if (nSecondSoundOnSet == ATTR_MIXED)
435 aSet.InvalidateItem(ATTR_ACTION_SOUNDON);
436 else
437 aSet.Put(SfxBoolItem(ATTR_ACTION_SOUNDON, false));
439 if (nSecondPlayFullSet == ATTR_SET)
440 aSet.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL, bSecondPlayFull));
441 else if (nSecondPlayFullSet == ATTR_MIXED)
442 aSet.InvalidateItem(ATTR_ACTION_PLAYFULL);
443 else
444 aSet.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL, false));
446 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
447 ScopedVclPtr<SfxAbstractDialog> pDlg( pFact->CreatSdActionDialog(mpViewShell->GetFrameWeld(), &aSet, mpView) );
449 short nResult = pDlg->Execute();
451 if( nResult != RET_OK )
452 return;
454 rReq.Done( *( pDlg->GetOutputItemSet() ) );
455 pArgs = rReq.GetArgs();
458 // evaluation of the ItemSets
459 if (pArgs->GetItemState(ATTR_ANIMATION_ACTIVE) == SfxItemState::SET)
461 bActive = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ANIMATION_ACTIVE)).GetValue();
462 nAnimationSet = ATTR_SET;
464 else
465 nAnimationSet = ATTR_MISSING;
467 if (pArgs->GetItemState(ATTR_ANIMATION_EFFECT) == SfxItemState::SET)
469 eEffect = static_cast<presentation::AnimationEffect>(static_cast<const SfxAllEnumItem&>( pArgs->
470 Get(ATTR_ANIMATION_EFFECT)).GetValue());
471 nEffectSet = ATTR_SET;
473 else
474 nEffectSet = ATTR_MISSING;
476 if (pArgs->GetItemState(ATTR_ANIMATION_TEXTEFFECT) == SfxItemState::SET)
478 eTextEffect = static_cast<presentation::AnimationEffect>(static_cast<const SfxAllEnumItem&>( pArgs->
479 Get(ATTR_ANIMATION_TEXTEFFECT)).GetValue());
480 nTextEffectSet = ATTR_SET;
482 else
483 nTextEffectSet = ATTR_MISSING;
485 if (pArgs->GetItemState(ATTR_ANIMATION_SPEED) == SfxItemState::SET)
487 eSpeed = static_cast<presentation::AnimationSpeed>(static_cast<const SfxAllEnumItem&>( pArgs->
488 Get(ATTR_ANIMATION_SPEED)).GetValue());
489 nSpeedSet = ATTR_SET;
491 else
492 nSpeedSet = ATTR_MISSING;
494 if (pArgs->GetItemState(ATTR_ANIMATION_FADEOUT) == SfxItemState::SET)
496 bFadeOut = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ANIMATION_FADEOUT)).GetValue();
497 nFadeOutSet = ATTR_SET;
499 else
500 nFadeOutSet = ATTR_MISSING;
502 if (pArgs->GetItemState(ATTR_ANIMATION_INVISIBLE) == SfxItemState::SET)
504 bInvisible = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ANIMATION_INVISIBLE)).GetValue();
505 nInvisibleSet = ATTR_SET;
507 else
508 nInvisibleSet = ATTR_MISSING;
510 if (pArgs->GetItemState(ATTR_ANIMATION_SOUNDON) == SfxItemState::SET)
512 bSoundOn = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ANIMATION_SOUNDON)).GetValue();
513 nSoundOnSet = ATTR_SET;
515 else
516 nSoundOnSet = ATTR_MISSING;
518 if (pArgs->GetItemState(ATTR_ANIMATION_SOUNDFILE) == SfxItemState::SET)
520 aSound = static_cast<const SfxStringItem&>(pArgs->Get(ATTR_ANIMATION_SOUNDFILE)).GetValue();
521 nSoundFileSet = ATTR_SET;
523 else
524 nSoundFileSet = ATTR_MISSING;
526 if (pArgs->GetItemState(ATTR_ANIMATION_COLOR) == SfxItemState::SET)
528 aFadeColor = static_cast<const SvxColorItem&>(pArgs->Get(ATTR_ANIMATION_COLOR)).GetValue();
529 nFadeColorSet = ATTR_SET;
531 else
532 nFadeColorSet = ATTR_MISSING;
534 if (pArgs->GetItemState(ATTR_ANIMATION_PLAYFULL) == SfxItemState::SET)
536 bPlayFull = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ANIMATION_PLAYFULL)).GetValue();
537 nPlayFullSet = ATTR_SET;
539 else
540 nPlayFullSet = ATTR_MISSING;
542 if (pArgs->GetItemState(ATTR_ACTION) == SfxItemState::SET)
544 eClickAction = static_cast<presentation::ClickAction>(static_cast<const SfxAllEnumItem&>(pArgs->
545 Get(ATTR_ACTION)).GetValue());
546 nClickActionSet = ATTR_SET;
548 else
549 nClickActionSet = ATTR_MISSING;
551 if (pArgs->GetItemState(ATTR_ACTION_FILENAME) == SfxItemState::SET)
553 aBookmark = static_cast<const SfxStringItem&>(pArgs->
554 Get(ATTR_ACTION_FILENAME)).GetValue();
555 nBookmarkSet = ATTR_SET;
557 else
558 nBookmarkSet = ATTR_MISSING;
560 if (pArgs->GetItemState(ATTR_ACTION_EFFECT) == SfxItemState::SET)
562 eSecondEffect = static_cast<presentation::AnimationEffect>(static_cast<const SfxAllEnumItem&>( pArgs->
563 Get(ATTR_ACTION_EFFECT)).GetValue());
564 nSecondEffectSet = ATTR_SET;
566 else
567 nSecondEffectSet = ATTR_MISSING;
569 if (pArgs->GetItemState(ATTR_ACTION_EFFECTSPEED) == SfxItemState::SET)
571 eSecondSpeed = static_cast<presentation::AnimationSpeed>(static_cast<const SfxAllEnumItem&>( pArgs->
572 Get(ATTR_ACTION_EFFECTSPEED)).GetValue());
573 nSecondSpeedSet = ATTR_SET;
575 else
576 nSecondSpeedSet = ATTR_MISSING;
578 if (pArgs->GetItemState(ATTR_ACTION_SOUNDON) == SfxItemState::SET)
580 bSecondSoundOn = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ACTION_SOUNDON)).GetValue();
581 nSecondSoundOnSet = ATTR_SET;
583 else
584 nSecondSoundOnSet = ATTR_MISSING;
586 if (pArgs->GetItemState(ATTR_ACTION_PLAYFULL) == SfxItemState::SET)
588 bSecondPlayFull = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ACTION_PLAYFULL)).GetValue();
589 nSecondPlayFullSet = ATTR_SET;
591 else
592 nSecondPlayFullSet = ATTR_MISSING;
594 // if any attribute is chosen
595 if (!(nEffectSet == ATTR_SET ||
596 nTextEffectSet == ATTR_SET ||
597 nSpeedSet == ATTR_SET ||
598 nAnimationSet == ATTR_SET ||
599 nFadeOutSet == ATTR_SET ||
600 nFadeColorSet == ATTR_SET ||
601 nInvisibleSet == ATTR_SET ||
602 nSoundOnSet == ATTR_SET ||
603 nSoundFileSet == ATTR_SET ||
604 nPlayFullSet == ATTR_SET ||
605 nClickActionSet == ATTR_SET ||
606 nBookmarkSet == ATTR_SET ||
607 nSecondEffectSet == ATTR_SET ||
608 nSecondSpeedSet == ATTR_SET ||
609 nSecondSoundOnSet == ATTR_SET ||
610 nSecondPlayFullSet == ATTR_SET))
611 return;
613 // String for undo-group and list-action
614 OUString aComment(SdResId(STR_UNDO_ANIMATION));
616 // with 'following curves', we have an additional UndoAction
617 // therefore cling? here
618 pUndoMgr->EnterListAction(aComment, aComment, 0, mpViewShell->GetViewShellBase().GetViewShellId());
620 // create undo group
621 std::unique_ptr<SdUndoGroup> pUndoGroup(new SdUndoGroup(mpDoc));
622 pUndoGroup->SetComment(aComment);
624 // for the path effect, remember some stuff
625 SdrPathObj* pPath = nullptr;
626 if (eEffect == presentation::AnimationEffect_PATH && nEffectSet == ATTR_SET)
628 DBG_ASSERT(nCount == 2, "This effect expects two selected objects");
629 SdrObject* pObject1 = rMarkList.GetMark(0)->GetMarkedSdrObj();
630 SdrObject* pObject2 = rMarkList.GetMark(1)->GetMarkedSdrObj();
631 SdrObjKind eKind1 = static_cast<SdrObjKind>(pObject1->GetObjIdentifier());
632 SdrObjKind eKind2 = static_cast<SdrObjKind>(pObject2->GetObjIdentifier());
633 SdrObject* pRunningObj = nullptr;
635 if (pObject1->GetObjInventor() == SdrInventor::Default &&
636 ((eKind1 == OBJ_LINE) || // 2 point line
637 (eKind1 == OBJ_PLIN) || // Polygon
638 (eKind1 == OBJ_PATHLINE))) // Bezier curve
640 pPath = static_cast<SdrPathObj*>(pObject1);
641 pRunningObj = pObject2;
644 if (pObject2->GetObjInventor() == SdrInventor::Default &&
645 ((eKind2 == OBJ_LINE) || // 2 point line
646 (eKind2 == OBJ_PLIN) || // Polygon
647 (eKind2 == OBJ_PATHLINE))) // Bezier curve
649 pPath = static_cast<SdrPathObj*>(pObject2);
650 pRunningObj = pObject1;
653 assert(pRunningObj && pPath && "no curve found");
655 // push the running object to the end of the curve
656 if (pRunningObj)
658 ::tools::Rectangle aCurRect(pRunningObj->GetLogicRect());
659 Point aCurCenter(aCurRect.Center());
660 const ::basegfx::B2DPolyPolygon& rPolyPolygon = pPath->GetPathPoly();
661 sal_uInt32 nNoOfPolygons(rPolyPolygon.count());
662 const ::basegfx::B2DPolygon& aPolygon(rPolyPolygon.getB2DPolygon(nNoOfPolygons - 1));
663 sal_uInt32 nPoints(aPolygon.count());
664 const ::basegfx::B2DPoint aNewB2DCenter(aPolygon.getB2DPoint(nPoints - 1));
665 const Point aNewCenter(FRound(aNewB2DCenter.getX()), FRound(aNewB2DCenter.getY()));
666 Size aDistance(aNewCenter.X() - aCurCenter.X(), aNewCenter.Y() - aCurCenter.Y());
667 pRunningObj->Move(aDistance);
669 pUndoMgr->AddUndoAction(mpDoc->GetSdrUndoFactory().CreateUndoMoveObject( *pRunningObj, aDistance));
673 for (size_t nObject = 0; nObject < nCount; ++nObject)
675 SdrObject* pObject = rMarkList.GetMark(nObject)->GetMarkedSdrObj();
677 pInfo = SdDrawDocument::GetAnimationInfo(pObject);
679 bool bCreated = false;
680 if( !pInfo )
682 pInfo = SdDrawDocument::GetShapeUserData(*pObject,true);
683 bCreated = true;
686 // path object for 'following curves'?
687 if (eEffect == presentation::AnimationEffect_PATH && pObject == pPath)
689 SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction
690 (mpDoc, pObject, bCreated);
691 pAction->SetActive(pInfo->mbActive, pInfo->mbActive);
692 pAction->SetEffect(pInfo->meEffect, pInfo->meEffect);
693 pAction->SetTextEffect(pInfo->meTextEffect, pInfo->meTextEffect);
694 pAction->SetSpeed(pInfo->meSpeed, pInfo->meSpeed);
695 pAction->SetDim(pInfo->mbDimPrevious, pInfo->mbDimPrevious);
696 pAction->SetDimColor(pInfo->maDimColor, pInfo->maDimColor);
697 pAction->SetDimHide(pInfo->mbDimHide, pInfo->mbDimHide);
698 pAction->SetSoundOn(pInfo->mbSoundOn, pInfo->mbSoundOn);
699 pAction->SetSound(pInfo->maSoundFile, pInfo->maSoundFile);
700 pAction->SetPlayFull(pInfo->mbPlayFull, pInfo->mbPlayFull);
701 pAction->SetClickAction(pInfo->meClickAction, pInfo->meClickAction);
702 pAction->SetBookmark(pInfo->GetBookmark(), pInfo->GetBookmark());
703 pAction->SetVerb(pInfo->mnVerb, pInfo->mnVerb);
704 pAction->SetSecondEffect(pInfo->meSecondEffect, pInfo->meSecondEffect);
705 pAction->SetSecondSpeed(pInfo->meSecondSpeed, pInfo->meSecondSpeed);
706 pAction->SetSecondSoundOn(pInfo->mbSecondSoundOn, pInfo->mbSecondSoundOn);
707 pAction->SetSecondPlayFull(pInfo->mbSecondPlayFull, pInfo->mbSecondPlayFull);
708 pUndoGroup->AddAction(pAction);
711 else
714 // create undo action with old and new sizes
715 SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction
716 (mpDoc, pObject, bCreated);
717 pAction->SetActive(pInfo->mbActive, bActive);
718 pAction->SetEffect(pInfo->meEffect, eEffect);
719 pAction->SetTextEffect(pInfo->meTextEffect, eTextEffect);
720 pAction->SetSpeed(pInfo->meSpeed, eSpeed);
721 pAction->SetDim(pInfo->mbDimPrevious, bFadeOut);
722 pAction->SetDimColor(pInfo->maDimColor, aFadeColor);
723 pAction->SetDimHide(pInfo->mbDimHide, bInvisible);
724 pAction->SetSoundOn(pInfo->mbSoundOn, bSoundOn);
725 pAction->SetSound(pInfo->maSoundFile, aSound);
726 pAction->SetPlayFull(pInfo->mbPlayFull, bPlayFull);
727 pAction->SetClickAction(pInfo->meClickAction, eClickAction);
728 pAction->SetBookmark(pInfo->GetBookmark(), aBookmark);
729 pAction->SetVerb(pInfo->mnVerb, static_cast<sal_uInt16>(pInfo->GetBookmark().toInt32()) );
730 pAction->SetSecondEffect(pInfo->meSecondEffect, eSecondEffect);
731 pAction->SetSecondSpeed(pInfo->meSecondSpeed, eSecondSpeed);
732 pAction->SetSecondSoundOn(pInfo->mbSecondSoundOn, bSecondSoundOn);
733 pAction->SetSecondPlayFull(pInfo->mbSecondPlayFull,bSecondPlayFull);
734 pUndoGroup->AddAction(pAction);
736 // insert new values at info block of the object
737 if (nAnimationSet == ATTR_SET)
738 pInfo->mbActive = bActive;
740 if (nEffectSet == ATTR_SET)
741 pInfo->meEffect = eEffect;
743 if (nTextEffectSet == ATTR_SET)
744 pInfo->meTextEffect = eTextEffect;
746 if (nSpeedSet == ATTR_SET)
747 pInfo->meSpeed = eSpeed;
749 if (nFadeOutSet == ATTR_SET)
750 pInfo->mbDimPrevious = bFadeOut;
752 if (nFadeColorSet == ATTR_SET)
753 pInfo->maDimColor = aFadeColor;
755 if (nInvisibleSet == ATTR_SET)
756 pInfo->mbDimHide = bInvisible;
758 if (nSoundOnSet == ATTR_SET)
759 pInfo->mbSoundOn = bSoundOn;
761 if (nSoundFileSet == ATTR_SET)
762 pInfo->maSoundFile = aSound;
764 if (nPlayFullSet == ATTR_SET)
765 pInfo->mbPlayFull = bPlayFull;
767 if (nClickActionSet == ATTR_SET)
768 pInfo->meClickAction = eClickAction;
770 if (nBookmarkSet == ATTR_SET)
771 pInfo->SetBookmark( aBookmark );
773 if (nSecondEffectSet == ATTR_SET)
774 pInfo->meSecondEffect = eSecondEffect;
776 if (nSecondSpeedSet == ATTR_SET)
777 pInfo->meSecondSpeed = eSecondSpeed;
779 if (nSecondSoundOnSet == ATTR_SET)
780 pInfo->mbSecondSoundOn = bSecondSoundOn;
782 if (nSecondPlayFullSet == ATTR_SET)
783 pInfo->mbSecondPlayFull = bSecondPlayFull;
785 if (eClickAction == presentation::ClickAction_VERB)
786 pInfo->mnVerb = static_cast<sal_uInt16>(aBookmark.toInt32());
789 // Set the Undo Group in of the Undo Manager
790 pUndoMgr->AddUndoAction(std::move(pUndoGroup));
791 pUndoMgr->LeaveListAction();
793 // Model changed
794 mpDoc->SetChanged();
795 // not seen, therefore we do not need to invalidate at the bindings
798 } // end of namespace sd
800 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */