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" // Undo-Action
41 #include "sdundogr.hxx" // Undo Group
43 #include "sdabstdlg.hxx"
44 #include "sdresid.hxx"
45 #include <tools/helpers.hxx>
46 #include <basegfx/polygon/b2dpolygon.hxx>
48 using namespace ::com::sun::star
;
52 TYPEINIT1( FuObjectAnimationParameters
, FuPoor
);
54 #define ATTR_MISSING 0 ///< Attribute missing
55 #define ATTR_MIXED 1 ///< Attribute ambiguous (on multi-selection)
56 #define ATTR_SET 2 ///< Attribute unique
59 FuObjectAnimationParameters::FuObjectAnimationParameters (
65 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
69 FunctionReference
FuObjectAnimationParameters::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
71 FunctionReference
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 sal_uLong nCount
= rMarkList
.GetMarkCount();
82 sal_uLong nObject
= 0;
84 short nAnimationSet
= ATTR_MISSING
;
85 short nEffectSet
= ATTR_MISSING
;
86 short nTextEffectSet
= ATTR_MISSING
;
87 short nSpeedSet
= ATTR_MISSING
;
88 short nFadeColorSet
= ATTR_MISSING
;
89 short nFadeOutSet
= ATTR_MISSING
;
90 short nInvisibleSet
= ATTR_MISSING
;
91 short nSoundOnSet
= ATTR_MISSING
;
92 short nSoundFileSet
= ATTR_MISSING
;
93 short nPlayFullSet
= ATTR_MISSING
;
94 short nClickActionSet
= ATTR_MISSING
;
95 short nBookmarkSet
= ATTR_MISSING
;
97 short nSecondEffectSet
= ATTR_MISSING
;
98 short nSecondSpeedSet
= ATTR_MISSING
;
99 short nSecondSoundOnSet
= ATTR_MISSING
;
100 short nSecondPlayFullSet
= ATTR_MISSING
;
102 // defaults (for Undo-Action)
103 presentation::AnimationEffect eEffect
= presentation::AnimationEffect_NONE
;
104 presentation::AnimationEffect eTextEffect
= presentation::AnimationEffect_NONE
;
105 presentation::AnimationSpeed eSpeed
= presentation::AnimationSpeed_MEDIUM
;
106 sal_Bool bActive
= sal_False
;
107 sal_Bool bFadeOut
= sal_False
;
108 Color aFadeColor
= COL_LIGHTGRAY
;
109 sal_Bool bInvisible
= sal_False
;
110 sal_Bool bSoundOn
= sal_False
;
112 sal_Bool bPlayFull
= sal_False
;
113 presentation::ClickAction eClickAction
= presentation::ClickAction_NONE
;
116 presentation::AnimationEffect eSecondEffect
= presentation::AnimationEffect_NONE
;
117 presentation::AnimationSpeed eSecondSpeed
= presentation::AnimationSpeed_MEDIUM
;
118 sal_Bool bSecondSoundOn
= sal_False
;
119 sal_Bool bSecondPlayFull
= sal_False
;
122 SdAnimationInfo
* pInfo
;
125 // inspect first object
126 pMark
= rMarkList
.GetMark(0);
127 pInfo
= mpDoc
->GetAnimationInfo(pMark
->GetMarkedSdrObj());
130 bActive
= pInfo
->mbActive
;
131 nAnimationSet
= ATTR_SET
;
133 eEffect
= pInfo
->meEffect
;
134 nEffectSet
= ATTR_SET
;
136 eTextEffect
= pInfo
->meTextEffect
;
137 nTextEffectSet
= ATTR_SET
;
139 eSpeed
= pInfo
->meSpeed
;
140 nSpeedSet
= ATTR_SET
;
142 bFadeOut
= pInfo
->mbDimPrevious
;
143 nFadeOutSet
= ATTR_SET
;
145 aFadeColor
= pInfo
->maDimColor
;
146 nFadeColorSet
= ATTR_SET
;
148 bInvisible
= pInfo
->mbDimHide
;
149 nInvisibleSet
= ATTR_SET
;
151 bSoundOn
= pInfo
->mbSoundOn
;
152 nSoundOnSet
= ATTR_SET
;
154 aSound
= pInfo
->maSoundFile
;
155 nSoundFileSet
= ATTR_SET
;
157 bPlayFull
= pInfo
->mbPlayFull
;
158 nPlayFullSet
= ATTR_SET
;
160 eClickAction
= pInfo
->meClickAction
;
161 nClickActionSet
= ATTR_SET
;
163 aBookmark
= pInfo
->GetBookmark();
164 nBookmarkSet
= ATTR_SET
;
166 eSecondEffect
= pInfo
->meSecondEffect
;
167 nSecondEffectSet
= ATTR_SET
;
169 eSecondSpeed
= pInfo
->meSecondSpeed
;
170 nSecondSpeedSet
= ATTR_SET
;
172 bSecondSoundOn
= pInfo
->mbSecondSoundOn
;
173 nSecondSoundOnSet
= ATTR_SET
;
175 bSecondPlayFull
= pInfo
->mbSecondPlayFull
;
176 nSecondPlayFullSet
= ATTR_SET
;
179 // if necessary, inspect more objects
180 for( nObject
= 1; nObject
< nCount
; nObject
++ )
182 pMark
= rMarkList
.GetMark( nObject
);
183 SdrObject
* pObject
= pMark
->GetMarkedSdrObj();
184 pInfo
= mpDoc
->GetAnimationInfo(pObject
);
187 if( bActive
!= pInfo
->mbActive
)
188 nAnimationSet
= ATTR_MIXED
;
190 if( eEffect
!= pInfo
->meEffect
)
191 nEffectSet
= ATTR_MIXED
;
193 if( eTextEffect
!= pInfo
->meTextEffect
)
194 nTextEffectSet
= ATTR_MIXED
;
196 if( eSpeed
!= pInfo
->meSpeed
)
197 nSpeedSet
= ATTR_MIXED
;
199 if( bFadeOut
!= pInfo
->mbDimPrevious
)
200 nFadeOutSet
= ATTR_MIXED
;
202 if( aFadeColor
!= pInfo
->maDimColor
)
203 nFadeColorSet
= ATTR_MIXED
;
205 if( bInvisible
!= pInfo
->mbDimHide
)
206 nInvisibleSet
= ATTR_MIXED
;
208 if( bSoundOn
!= pInfo
->mbSoundOn
)
209 nSoundOnSet
= ATTR_MIXED
;
211 if( aSound
!= pInfo
->maSoundFile
)
212 nSoundFileSet
= ATTR_MIXED
;
214 if( bPlayFull
!= pInfo
->mbPlayFull
)
215 nPlayFullSet
= ATTR_MIXED
;
217 if( eClickAction
!= pInfo
->meClickAction
)
218 nClickActionSet
= ATTR_MIXED
;
220 if( aBookmark
!= pInfo
->GetBookmark() )
221 nBookmarkSet
= ATTR_MIXED
;
223 if( eSecondEffect
!= pInfo
->meSecondEffect
)
224 nSecondEffectSet
= ATTR_MIXED
;
226 if( eSecondSpeed
!= pInfo
->meSecondSpeed
)
227 nSecondSpeedSet
= ATTR_MIXED
;
229 if( bSecondSoundOn
!= pInfo
->mbSecondSoundOn
)
230 nSecondSoundOnSet
= ATTR_MIXED
;
232 if( bSecondPlayFull
!= pInfo
->mbSecondPlayFull
)
233 nSecondPlayFullSet
= ATTR_MIXED
;
237 if (nAnimationSet
== ATTR_SET
&& bActive
== sal_True
)
238 nAnimationSet
= ATTR_MIXED
;
240 if (nEffectSet
== ATTR_SET
&& eEffect
!= presentation::AnimationEffect_NONE
)
241 nEffectSet
= ATTR_MIXED
;
243 if (nTextEffectSet
== ATTR_SET
&& eTextEffect
!= presentation::AnimationEffect_NONE
)
244 nTextEffectSet
= ATTR_MIXED
;
246 if (nSpeedSet
== ATTR_SET
)
247 nSpeedSet
= ATTR_MIXED
;
249 if (nFadeOutSet
== ATTR_SET
&& bFadeOut
== sal_True
)
250 nFadeOutSet
= ATTR_MIXED
;
252 if (nFadeColorSet
== ATTR_SET
)
253 nFadeColorSet
= ATTR_MIXED
;
255 if (nInvisibleSet
== ATTR_SET
&& bInvisible
== sal_True
)
256 nInvisibleSet
= ATTR_MIXED
;
258 if (nSoundOnSet
== ATTR_SET
&& bSoundOn
== sal_True
)
259 nSoundOnSet
= ATTR_MIXED
;
261 if (nSoundFileSet
== ATTR_SET
)
262 nSoundFileSet
= ATTR_MIXED
;
264 if (nPlayFullSet
== ATTR_SET
&& bPlayFull
== sal_True
)
265 nPlayFullSet
= ATTR_MIXED
;
267 if (nClickActionSet
== ATTR_SET
&& eClickAction
!= presentation::ClickAction_NONE
)
268 nClickActionSet
= ATTR_MIXED
;
270 if (nBookmarkSet
== ATTR_SET
)
271 nBookmarkSet
= ATTR_MIXED
;
273 if (nSecondEffectSet
== ATTR_SET
&& eSecondEffect
!= presentation::AnimationEffect_NONE
)
274 nSecondEffectSet
= ATTR_MIXED
;
276 if (nSecondSpeedSet
== ATTR_SET
)
277 nSecondSpeedSet
= ATTR_MIXED
;
279 if (nSecondSoundOnSet
== ATTR_SET
&& bSecondSoundOn
== sal_True
)
280 nSecondSoundOnSet
= ATTR_MIXED
;
282 if (nSecondPlayFullSet
== ATTR_SET
&& bSecondPlayFull
== sal_True
)
283 nSecondPlayFullSet
= ATTR_MIXED
;
287 /* Exactly two objects with path effect?
288 Then, only the animation info at the moved object is valid. */
291 SdrObject
* pObject1
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
292 SdrObject
* pObject2
= rMarkList
.GetMark(1)->GetMarkedSdrObj();
293 SdrObjKind eKind1
= (SdrObjKind
)pObject1
->GetObjIdentifier();
294 SdrObjKind eKind2
= (SdrObjKind
)pObject2
->GetObjIdentifier();
295 SdAnimationInfo
* pInfo1
= mpDoc
->GetAnimationInfo(pObject1
);
296 SdAnimationInfo
* pInfo2
= mpDoc
->GetAnimationInfo(pObject2
);
299 if (pObject1
->GetObjInventor() == SdrInventor
&&
300 ((eKind1
== OBJ_LINE
) || // 2 point line
301 (eKind1
== OBJ_PLIN
) || // Polygon
302 (eKind1
== OBJ_PATHLINE
)) && // Bezier curve
303 (pInfo2
&& pInfo2
->meEffect
== presentation::AnimationEffect_PATH
))
308 if (pObject2
->GetObjInventor() == SdrInventor
&&
309 ((eKind2
== OBJ_LINE
) || // 2 point line
310 (eKind2
== OBJ_PLIN
) || // Polygon
311 (eKind2
== OBJ_PATHLINE
)) && // Bezier curve
312 (pInfo1
&& pInfo1
->meEffect
== presentation::AnimationEffect_PATH
))
319 bActive
= pInfo
->mbActive
; nAnimationSet
= ATTR_SET
;
320 eEffect
= pInfo
->meEffect
; nEffectSet
= ATTR_SET
;
321 eTextEffect
= pInfo
->meTextEffect
; nTextEffectSet
= ATTR_SET
;
322 eSpeed
= pInfo
->meSpeed
; nSpeedSet
= ATTR_SET
;
323 bFadeOut
= pInfo
->mbDimPrevious
; nFadeOutSet
= ATTR_SET
;
324 aFadeColor
= pInfo
->maDimColor
; nFadeColorSet
= ATTR_SET
;
325 bInvisible
= pInfo
->mbDimHide
; nInvisibleSet
= ATTR_SET
;
326 bSoundOn
= pInfo
->mbSoundOn
; nSoundOnSet
= ATTR_SET
;
327 aSound
= pInfo
->maSoundFile
; nSoundFileSet
= ATTR_SET
;
328 bPlayFull
= pInfo
->mbPlayFull
; nPlayFullSet
= ATTR_SET
;
329 eClickAction
= pInfo
->meClickAction
; nClickActionSet
= ATTR_SET
;
330 aBookmark
= pInfo
->GetBookmark(); nBookmarkSet
= ATTR_SET
;
331 eSecondEffect
= pInfo
->meSecondEffect
; nSecondEffectSet
= ATTR_SET
;
332 eSecondSpeed
= pInfo
->meSecondSpeed
; nSecondSpeedSet
= ATTR_SET
;
333 bSecondSoundOn
= pInfo
->mbSecondSoundOn
; nSecondSoundOnSet
= ATTR_SET
;
334 bSecondPlayFull
= pInfo
->mbSecondPlayFull
; nSecondPlayFullSet
= ATTR_SET
;
338 const SfxItemSet
* pArgs
= rReq
.GetArgs();
342 // fill ItemSet for dialog
343 SfxItemSet
aSet(mpDoc
->GetPool(), ATTR_ANIMATION_START
, ATTR_ACTION_END
);
346 if (nAnimationSet
== ATTR_SET
)
347 aSet
.Put( SfxBoolItem( ATTR_ANIMATION_ACTIVE
, bActive
));
348 else if (nAnimationSet
== ATTR_MIXED
)
349 aSet
.InvalidateItem(ATTR_ANIMATION_ACTIVE
);
351 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_ACTIVE
, sal_False
));
353 if (nEffectSet
== ATTR_SET
)
354 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_EFFECT
, (sal_uInt16
)eEffect
));
355 else if (nEffectSet
== ATTR_MIXED
)
356 aSet
.InvalidateItem( ATTR_ANIMATION_EFFECT
);
358 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_EFFECT
, presentation::AnimationEffect_NONE
));
360 if (nTextEffectSet
== ATTR_SET
)
361 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_TEXTEFFECT
, (sal_uInt16
)eTextEffect
));
362 else if (nTextEffectSet
== ATTR_MIXED
)
363 aSet
.InvalidateItem( ATTR_ANIMATION_TEXTEFFECT
);
365 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_TEXTEFFECT
, presentation::AnimationEffect_NONE
));
367 if (nSpeedSet
== ATTR_SET
)
368 aSet
.Put(SfxAllEnumItem(ATTR_ANIMATION_SPEED
, (sal_uInt16
)eSpeed
));
370 aSet
.InvalidateItem(ATTR_ANIMATION_SPEED
);
372 if (nFadeOutSet
== ATTR_SET
)
373 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_FADEOUT
, bFadeOut
));
374 else if (nFadeOutSet
== ATTR_MIXED
)
375 aSet
.InvalidateItem(ATTR_ANIMATION_FADEOUT
);
377 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_FADEOUT
, sal_False
));
379 if (nFadeColorSet
== ATTR_SET
)
380 aSet
.Put(SvxColorItem(aFadeColor
, ATTR_ANIMATION_COLOR
));
381 else if (nFadeColorSet
== ATTR_MIXED
)
382 aSet
.InvalidateItem(ATTR_ANIMATION_COLOR
);
384 aSet
.Put(SvxColorItem(RGB_Color(COL_LIGHTGRAY
), ATTR_ANIMATION_COLOR
));
386 if (nInvisibleSet
== ATTR_SET
)
387 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_INVISIBLE
, bInvisible
));
388 else if (nInvisibleSet
== ATTR_MIXED
)
389 aSet
.InvalidateItem(ATTR_ANIMATION_INVISIBLE
);
391 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_INVISIBLE
, sal_False
));
393 if (nSoundOnSet
== ATTR_SET
)
394 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_SOUNDON
, bSoundOn
));
395 else if (nSoundOnSet
== ATTR_MIXED
)
396 aSet
.InvalidateItem(ATTR_ANIMATION_SOUNDON
);
398 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_SOUNDON
, sal_False
));
400 if (nSoundFileSet
== ATTR_SET
)
401 aSet
.Put(SfxStringItem(ATTR_ANIMATION_SOUNDFILE
, aSound
));
403 aSet
.InvalidateItem(ATTR_ANIMATION_SOUNDFILE
);
405 if (nPlayFullSet
== ATTR_SET
)
406 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_PLAYFULL
, bPlayFull
));
407 else if (nPlayFullSet
== ATTR_MIXED
)
408 aSet
.InvalidateItem(ATTR_ANIMATION_PLAYFULL
);
410 aSet
.Put(SfxBoolItem(ATTR_ANIMATION_PLAYFULL
, sal_False
));
412 if (nClickActionSet
== ATTR_SET
)
413 aSet
.Put(SfxAllEnumItem(ATTR_ACTION
, (sal_uInt16
)eClickAction
));
414 else if (nClickActionSet
== ATTR_MIXED
)
415 aSet
.InvalidateItem(ATTR_ACTION
);
417 aSet
.Put(SfxAllEnumItem(ATTR_ACTION
, presentation::ClickAction_NONE
));
419 if (nBookmarkSet
== ATTR_SET
)
420 aSet
.Put(SfxStringItem(ATTR_ACTION_FILENAME
, aBookmark
));
422 aSet
.InvalidateItem(ATTR_ACTION_FILENAME
);
424 if (nSecondEffectSet
== ATTR_SET
)
425 aSet
.Put(SfxAllEnumItem(ATTR_ACTION_EFFECT
, (sal_uInt16
)eSecondEffect
));
426 else if (nSecondEffectSet
== ATTR_MIXED
)
427 aSet
.InvalidateItem( ATTR_ACTION_EFFECT
);
429 aSet
.Put(SfxAllEnumItem(ATTR_ACTION_EFFECT
, presentation::AnimationEffect_NONE
));
431 if (nSecondSpeedSet
== ATTR_SET
)
432 aSet
.Put(SfxAllEnumItem(ATTR_ACTION_EFFECTSPEED
, (sal_uInt16
)eSecondSpeed
));
434 aSet
.InvalidateItem(ATTR_ACTION_EFFECTSPEED
);
436 if (nSecondSoundOnSet
== ATTR_SET
)
437 aSet
.Put(SfxBoolItem(ATTR_ACTION_SOUNDON
, bSecondSoundOn
));
438 else if (nSecondSoundOnSet
== ATTR_MIXED
)
439 aSet
.InvalidateItem(ATTR_ACTION_SOUNDON
);
441 aSet
.Put(SfxBoolItem(ATTR_ACTION_SOUNDON
, sal_False
));
443 if (nSecondPlayFullSet
== ATTR_SET
)
444 aSet
.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL
, bSecondPlayFull
));
445 else if (nPlayFullSet
== ATTR_MIXED
)
446 aSet
.InvalidateItem(ATTR_ACTION_PLAYFULL
);
448 aSet
.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL
, sal_False
));
450 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
451 SfxAbstractDialog
* pDlg
= pFact
? pFact
->CreatSdActionDialog( NULL
, &aSet
, mpView
) : 0;
453 short nResult
= pDlg
? pDlg
->Execute() : static_cast<short>(RET_CANCEL
);
455 if( nResult
== RET_OK
)
457 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
458 pArgs
= rReq
.GetArgs();
463 if( nResult
!= RET_OK
)
467 // evaluation of the ItemSets
468 if (pArgs
->GetItemState(ATTR_ANIMATION_ACTIVE
) == SFX_ITEM_SET
)
470 bActive
= ((SfxBoolItem
&)pArgs
->Get(ATTR_ANIMATION_ACTIVE
)).GetValue();
471 nAnimationSet
= ATTR_SET
;
474 nAnimationSet
= ATTR_MISSING
;
476 if (pArgs
->GetItemState(ATTR_ANIMATION_EFFECT
) == SFX_ITEM_SET
)
478 eEffect
= (presentation::AnimationEffect
)((SfxAllEnumItem
&) pArgs
->
479 Get(ATTR_ANIMATION_EFFECT
)).GetValue();
480 nEffectSet
= ATTR_SET
;
483 nEffectSet
= ATTR_MISSING
;
485 if (pArgs
->GetItemState(ATTR_ANIMATION_TEXTEFFECT
) == SFX_ITEM_SET
)
487 eTextEffect
= (presentation::AnimationEffect
)((SfxAllEnumItem
&) pArgs
->
488 Get(ATTR_ANIMATION_TEXTEFFECT
)).GetValue();
489 nTextEffectSet
= ATTR_SET
;
492 nTextEffectSet
= ATTR_MISSING
;
494 if (pArgs
->GetItemState(ATTR_ANIMATION_SPEED
) == SFX_ITEM_SET
)
496 eSpeed
= (presentation::AnimationSpeed
)((SfxAllEnumItem
&) pArgs
->
497 Get(ATTR_ANIMATION_SPEED
)).GetValue();
498 nSpeedSet
= ATTR_SET
;
501 nSpeedSet
= ATTR_MISSING
;
503 if (pArgs
->GetItemState(ATTR_ANIMATION_FADEOUT
) == SFX_ITEM_SET
)
505 bFadeOut
= ((SfxBoolItem
&)pArgs
->Get(ATTR_ANIMATION_FADEOUT
)).GetValue();
506 nFadeOutSet
= ATTR_SET
;
509 nFadeOutSet
= ATTR_MISSING
;
511 if (pArgs
->GetItemState(ATTR_ANIMATION_INVISIBLE
) == SFX_ITEM_SET
)
513 bInvisible
= ((SfxBoolItem
&)pArgs
->Get(ATTR_ANIMATION_INVISIBLE
)).GetValue();
514 nInvisibleSet
= ATTR_SET
;
517 nInvisibleSet
= ATTR_MISSING
;
519 if (pArgs
->GetItemState(ATTR_ANIMATION_SOUNDON
) == SFX_ITEM_SET
)
521 bSoundOn
= ((SfxBoolItem
&)pArgs
->Get(ATTR_ANIMATION_SOUNDON
)).GetValue();
522 nSoundOnSet
= ATTR_SET
;
525 nSoundOnSet
= ATTR_MISSING
;
527 if (pArgs
->GetItemState(ATTR_ANIMATION_SOUNDFILE
) == SFX_ITEM_SET
)
529 aSound
= ((SfxStringItem
&)pArgs
->Get(ATTR_ANIMATION_SOUNDFILE
)).GetValue();
530 nSoundFileSet
= ATTR_SET
;
533 nSoundFileSet
= ATTR_MISSING
;
535 if (pArgs
->GetItemState(ATTR_ANIMATION_COLOR
) == SFX_ITEM_SET
)
537 aFadeColor
= ((SvxColorItem
&)pArgs
->Get(ATTR_ANIMATION_COLOR
)).GetValue();
538 nFadeColorSet
= ATTR_SET
;
541 nFadeColorSet
= ATTR_MISSING
;
543 if (pArgs
->GetItemState(ATTR_ANIMATION_PLAYFULL
) == SFX_ITEM_SET
)
545 bPlayFull
= ((SfxBoolItem
&)pArgs
->Get(ATTR_ANIMATION_PLAYFULL
)).GetValue();
546 nPlayFullSet
= ATTR_SET
;
549 nPlayFullSet
= ATTR_MISSING
;
551 if (pArgs
->GetItemState(ATTR_ACTION
) == SFX_ITEM_SET
)
553 eClickAction
= (presentation::ClickAction
)((SfxAllEnumItem
&)pArgs
->
554 Get(ATTR_ACTION
)).GetValue();
555 nClickActionSet
= ATTR_SET
;
558 nClickActionSet
= ATTR_MISSING
;
560 if (pArgs
->GetItemState(ATTR_ACTION_FILENAME
) == SFX_ITEM_SET
)
562 aBookmark
= ((SfxStringItem
&)pArgs
->
563 Get(ATTR_ACTION_FILENAME
)).GetValue();
564 nBookmarkSet
= ATTR_SET
;
567 nBookmarkSet
= ATTR_MISSING
;
569 if (pArgs
->GetItemState(ATTR_ACTION_EFFECT
) == SFX_ITEM_SET
)
571 eSecondEffect
= (presentation::AnimationEffect
)((SfxAllEnumItem
&) pArgs
->
572 Get(ATTR_ACTION_EFFECT
)).GetValue();
573 nSecondEffectSet
= ATTR_SET
;
576 nSecondEffectSet
= ATTR_MISSING
;
578 if (pArgs
->GetItemState(ATTR_ACTION_EFFECTSPEED
) == SFX_ITEM_SET
)
580 eSecondSpeed
= (presentation::AnimationSpeed
)((SfxAllEnumItem
&) pArgs
->
581 Get(ATTR_ACTION_EFFECTSPEED
)).GetValue();
582 nSecondSpeedSet
= ATTR_SET
;
585 nSecondSpeedSet
= ATTR_MISSING
;
587 if (pArgs
->GetItemState(ATTR_ACTION_SOUNDON
) == SFX_ITEM_SET
)
589 bSecondSoundOn
= ((SfxBoolItem
&)pArgs
->Get(ATTR_ACTION_SOUNDON
)).GetValue();
590 nSecondSoundOnSet
= ATTR_SET
;
593 nSecondSoundOnSet
= ATTR_MISSING
;
595 if (pArgs
->GetItemState(ATTR_ACTION_PLAYFULL
) == SFX_ITEM_SET
)
597 bSecondPlayFull
= ((SfxBoolItem
&)pArgs
->Get(ATTR_ACTION_PLAYFULL
)).GetValue();
598 nSecondPlayFullSet
= ATTR_SET
;
601 nSecondPlayFullSet
= ATTR_MISSING
;
603 // if any attribute is chosen
604 if (nEffectSet
== ATTR_SET
||
605 nTextEffectSet
== ATTR_SET
||
606 nSpeedSet
== ATTR_SET
||
607 nAnimationSet
== ATTR_SET
||
608 nFadeOutSet
== ATTR_SET
||
609 nFadeColorSet
== ATTR_SET
||
610 nInvisibleSet
== ATTR_SET
||
611 nSoundOnSet
== ATTR_SET
||
612 nSoundFileSet
== ATTR_SET
||
613 nPlayFullSet
== ATTR_SET
||
614 nClickActionSet
== ATTR_SET
||
615 nBookmarkSet
== ATTR_SET
||
616 nSecondEffectSet
== ATTR_SET
||
617 nSecondSpeedSet
== ATTR_SET
||
618 nSecondSoundOnSet
== ATTR_SET
||
619 nSecondPlayFullSet
== ATTR_SET
)
621 // String for undo-group and list-action
622 String
aComment(SdResId(STR_UNDO_ANIMATION
));
624 // with 'following curves', we have an additional UndoAction
625 // therefore cling? here
626 pUndoMgr
->EnterListAction(aComment
, aComment
);
629 SdUndoGroup
* pUndoGroup
= new SdUndoGroup(mpDoc
);
630 pUndoGroup
->SetComment(aComment
);
633 // for the path effect, remember some stuff
634 SdrObject
* pRunningObj
= NULL
;
635 SdrPathObj
* pPath
= NULL
;
636 if (eEffect
== presentation::AnimationEffect_PATH
&& nEffectSet
== ATTR_SET
)
638 DBG_ASSERT(nCount
== 2, "This effect expects two selected objects");
639 SdrObject
* pObject1
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
640 SdrObject
* pObject2
= rMarkList
.GetMark(1)->GetMarkedSdrObj();
641 SdrObjKind eKind1
= (SdrObjKind
)pObject1
->GetObjIdentifier();
642 SdrObjKind eKind2
= (SdrObjKind
)pObject2
->GetObjIdentifier();
644 if (pObject1
->GetObjInventor() == SdrInventor
&&
645 ((eKind1
== OBJ_LINE
) || // 2 point line
646 (eKind1
== OBJ_PLIN
) || // Polygon
647 (eKind1
== OBJ_PATHLINE
))) // Bezier curve
649 pPath
= (SdrPathObj
*)pObject1
;
650 pRunningObj
= pObject2
;
653 if (pObject2
->GetObjInventor() == SdrInventor
&&
654 ((eKind2
== OBJ_LINE
) || // 2 point line
655 (eKind2
== OBJ_PLIN
) || // Polygon
656 (eKind2
== OBJ_PATHLINE
))) // Bezier curve
658 pPath
= (SdrPathObj
*)pObject2
;
659 pRunningObj
= pObject1
;
662 DBG_ASSERT(pPath
, "no curve found");
665 // push the running object to the end of the curve
666 Rectangle
aCurRect(pRunningObj
->GetLogicRect());
667 Point
aCurCenter(aCurRect
.Center());
668 const ::basegfx::B2DPolyPolygon
& rPolyPolygon
= pPath
->GetPathPoly();
669 sal_uInt32
nNoOfPolygons(rPolyPolygon
.count());
670 const ::basegfx::B2DPolygon
aPolygon(rPolyPolygon
.getB2DPolygon(nNoOfPolygons
- 1L));
671 sal_uInt32
nPoints(aPolygon
.count());
672 const ::basegfx::B2DPoint
aNewB2DCenter(aPolygon
.getB2DPoint(nPoints
- 1L));
673 const Point
aNewCenter(FRound(aNewB2DCenter
.getX()), FRound(aNewB2DCenter
.getY()));
674 Size
aDistance(aNewCenter
.X() - aCurCenter
.X(), aNewCenter
.Y() - aCurCenter
.Y());
675 pRunningObj
->Move(aDistance
);
677 pUndoMgr
->AddUndoAction(mpDoc
->GetSdrUndoFactory().CreateUndoMoveObject( *pRunningObj
, aDistance
));
680 for (nObject
= 0; nObject
< nCount
; nObject
++)
682 SdrObject
* pObject
= rMarkList
.GetMark(nObject
)->GetMarkedSdrObj();
684 pInfo
= mpDoc
->GetAnimationInfo(pObject
);
686 sal_Bool bCreated
= sal_False
;
689 pInfo
= SdDrawDocument::GetShapeUserData(*pObject
,true);
693 // path object for 'following curves'?
694 if (eEffect
== presentation::AnimationEffect_PATH
&& pObject
== pPath
)
696 SdAnimationPrmsUndoAction
* pAction
= new SdAnimationPrmsUndoAction
697 (mpDoc
, pObject
, bCreated
);
698 pAction
->SetActive(pInfo
->mbActive
, pInfo
->mbActive
);
699 pAction
->SetEffect(pInfo
->meEffect
, pInfo
->meEffect
);
700 pAction
->SetTextEffect(pInfo
->meTextEffect
, pInfo
->meTextEffect
);
701 pAction
->SetSpeed(pInfo
->meSpeed
, pInfo
->meSpeed
);
702 pAction
->SetDim(pInfo
->mbDimPrevious
, pInfo
->mbDimPrevious
);
703 pAction
->SetDimColor(pInfo
->maDimColor
, pInfo
->maDimColor
);
704 pAction
->SetDimHide(pInfo
->mbDimHide
, pInfo
->mbDimHide
);
705 pAction
->SetSoundOn(pInfo
->mbSoundOn
, pInfo
->mbSoundOn
);
706 pAction
->SetSound(pInfo
->maSoundFile
, pInfo
->maSoundFile
);
707 pAction
->SetPlayFull(pInfo
->mbPlayFull
, pInfo
->mbPlayFull
);
708 pAction
->SetClickAction(pInfo
->meClickAction
, pInfo
->meClickAction
);
709 pAction
->SetBookmark(pInfo
->GetBookmark(), pInfo
->GetBookmark());
710 pAction
->SetVerb(pInfo
->mnVerb
, pInfo
->mnVerb
);
711 pAction
->SetSecondEffect(pInfo
->meSecondEffect
, pInfo
->meSecondEffect
);
712 pAction
->SetSecondSpeed(pInfo
->meSecondSpeed
, pInfo
->meSecondSpeed
);
713 pAction
->SetSecondSoundOn(pInfo
->mbSecondSoundOn
, pInfo
->mbSecondSoundOn
);
714 pAction
->SetSecondPlayFull(pInfo
->mbSecondPlayFull
, pInfo
->mbSecondPlayFull
);
715 pUndoGroup
->AddAction(pAction
);
721 // create undo action with old and new sizes
722 SdAnimationPrmsUndoAction
* pAction
= new SdAnimationPrmsUndoAction
723 (mpDoc
, pObject
, bCreated
);
724 pAction
->SetActive(pInfo
->mbActive
, bActive
);
725 pAction
->SetEffect(pInfo
->meEffect
, eEffect
);
726 pAction
->SetTextEffect(pInfo
->meTextEffect
, eTextEffect
);
727 pAction
->SetSpeed(pInfo
->meSpeed
, eSpeed
);
728 pAction
->SetDim(pInfo
->mbDimPrevious
, bFadeOut
);
729 pAction
->SetDimColor(pInfo
->maDimColor
, aFadeColor
);
730 pAction
->SetDimHide(pInfo
->mbDimHide
, bInvisible
);
731 pAction
->SetSoundOn(pInfo
->mbSoundOn
, bSoundOn
);
732 pAction
->SetSound(pInfo
->maSoundFile
, aSound
);
733 pAction
->SetPlayFull(pInfo
->mbPlayFull
, bPlayFull
);
734 pAction
->SetPathObj(pInfo
->mpPathObj
, pPath
);
735 pAction
->SetClickAction(pInfo
->meClickAction
, eClickAction
);
736 pAction
->SetBookmark(pInfo
->GetBookmark(), aBookmark
);
737 pAction
->SetVerb(pInfo
->mnVerb
, (sal_uInt16
)pInfo
->GetBookmark().ToInt32() );
738 pAction
->SetSecondEffect(pInfo
->meSecondEffect
, eSecondEffect
);
739 pAction
->SetSecondSpeed(pInfo
->meSecondSpeed
, eSecondSpeed
);
740 pAction
->SetSecondSoundOn(pInfo
->mbSecondSoundOn
, bSecondSoundOn
);
741 pAction
->SetSecondPlayFull(pInfo
->mbSecondPlayFull
,bSecondPlayFull
);
742 pUndoGroup
->AddAction(pAction
);
744 // insert new values at info block of the object
745 if (nAnimationSet
== ATTR_SET
)
746 pInfo
->mbActive
= bActive
;
748 if (nEffectSet
== ATTR_SET
)
749 pInfo
->meEffect
= eEffect
;
751 if (nTextEffectSet
== ATTR_SET
)
752 pInfo
->meTextEffect
= eTextEffect
;
754 if (nSpeedSet
== ATTR_SET
)
755 pInfo
->meSpeed
= eSpeed
;
757 if (nFadeOutSet
== ATTR_SET
)
758 pInfo
->mbDimPrevious
= bFadeOut
;
760 if (nFadeColorSet
== ATTR_SET
)
761 pInfo
->maDimColor
= aFadeColor
;
763 if (nInvisibleSet
== ATTR_SET
)
764 pInfo
->mbDimHide
= bInvisible
;
766 if (nSoundOnSet
== ATTR_SET
)
767 pInfo
->mbSoundOn
= bSoundOn
;
769 if (nSoundFileSet
== ATTR_SET
)
770 pInfo
->maSoundFile
= aSound
;
772 if (nPlayFullSet
== ATTR_SET
)
773 pInfo
->mbPlayFull
= bPlayFull
;
775 if (nClickActionSet
== ATTR_SET
)
776 pInfo
->meClickAction
= eClickAction
;
778 if (nBookmarkSet
== ATTR_SET
)
779 pInfo
->SetBookmark( aBookmark
);
781 if (nSecondEffectSet
== ATTR_SET
)
782 pInfo
->meSecondEffect
= eSecondEffect
;
784 if (nSecondSpeedSet
== ATTR_SET
)
785 pInfo
->meSecondSpeed
= eSecondSpeed
;
787 if (nSecondSoundOnSet
== ATTR_SET
)
788 pInfo
->mbSecondSoundOn
= bSecondSoundOn
;
790 if (nSecondPlayFullSet
== ATTR_SET
)
791 pInfo
->mbSecondPlayFull
= bSecondPlayFull
;
793 if (eClickAction
== presentation::ClickAction_VERB
)
794 pInfo
->mnVerb
= (sal_uInt16
)aBookmark
.ToInt32();
797 // Set the Undo Group in of the Undo Manager
798 pUndoMgr
->AddUndoAction(pUndoGroup
);
799 pUndoMgr
->LeaveListAction();
804 // not seen, therefore we do not need to invalidate at the bindings
807 } // end of namespace sd
809 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */