Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "fuoaprms.hxx"
21 :
22 : #include "sdattr.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"
34 :
35 : #include "strings.hrc"
36 : #include "glob.hrc"
37 : #include "drawdoc.hxx"
38 : #include "ViewShell.hxx"
39 : #include "anminfo.hxx"
40 : #include "unoaprms.hxx"
41 : #include "sdundogr.hxx"
42 : #include "View.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>
48 :
49 : using namespace ::com::sun::star;
50 :
51 : namespace sd {
52 :
53 0 : TYPEINIT1( FuObjectAnimationParameters, FuPoor );
54 :
55 : #define ATTR_MISSING 0 ///< Attribute missing
56 : #define ATTR_MIXED 1 ///< Attribute ambiguous (on multi-selection)
57 : #define ATTR_SET 2 ///< Attribute unique
58 :
59 0 : FuObjectAnimationParameters::FuObjectAnimationParameters (
60 : ViewShell* pViewSh,
61 : ::sd::Window* pWin,
62 : ::sd::View* pView,
63 : SdDrawDocument* pDoc,
64 : SfxRequest& rReq)
65 0 : : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
66 : {
67 0 : }
68 :
69 0 : rtl::Reference<FuPoor> FuObjectAnimationParameters::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
70 : {
71 0 : rtl::Reference<FuPoor> xFunc( new FuObjectAnimationParameters( pViewSh, pWin, pView, pDoc, rReq ) );
72 0 : xFunc->DoExecute(rReq);
73 0 : return xFunc;
74 : }
75 :
76 0 : void FuObjectAnimationParameters::DoExecute( SfxRequest& rReq )
77 : {
78 0 : ::svl::IUndoManager* pUndoMgr = mpViewShell->GetViewFrame()->GetObjectShell()->GetUndoManager();
79 :
80 0 : const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
81 0 : const size_t nCount = rMarkList.GetMarkCount();
82 :
83 0 : short nAnimationSet = ATTR_MISSING;
84 0 : short nEffectSet = ATTR_MISSING;
85 0 : short nTextEffectSet = ATTR_MISSING;
86 0 : short nSpeedSet = ATTR_MISSING;
87 0 : short nFadeColorSet = ATTR_MISSING;
88 0 : short nFadeOutSet = ATTR_MISSING;
89 0 : short nInvisibleSet = ATTR_MISSING;
90 0 : short nSoundOnSet = ATTR_MISSING;
91 0 : short nSoundFileSet = ATTR_MISSING;
92 0 : short nPlayFullSet = ATTR_MISSING;
93 0 : short nClickActionSet = ATTR_MISSING;
94 0 : short nBookmarkSet = ATTR_MISSING;
95 :
96 0 : short nSecondEffectSet = ATTR_MISSING;
97 0 : short nSecondSpeedSet = ATTR_MISSING;
98 0 : short nSecondSoundOnSet = ATTR_MISSING;
99 0 : short nSecondPlayFullSet = ATTR_MISSING;
100 :
101 : // defaults (for Undo-Action)
102 0 : presentation::AnimationEffect eEffect = presentation::AnimationEffect_NONE;
103 0 : presentation::AnimationEffect eTextEffect = presentation::AnimationEffect_NONE;
104 0 : presentation::AnimationSpeed eSpeed = presentation::AnimationSpeed_MEDIUM;
105 0 : bool bActive = false;
106 0 : bool bFadeOut = false;
107 0 : Color aFadeColor = COL_LIGHTGRAY;
108 0 : bool bInvisible = false;
109 0 : bool bSoundOn = false;
110 0 : OUString aSound;
111 0 : bool bPlayFull = false;
112 0 : presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
113 0 : OUString aBookmark;
114 :
115 0 : presentation::AnimationEffect eSecondEffect = presentation::AnimationEffect_NONE;
116 0 : presentation::AnimationSpeed eSecondSpeed = presentation::AnimationSpeed_MEDIUM;
117 0 : bool bSecondSoundOn = false;
118 0 : bool bSecondPlayFull = false;
119 :
120 : SdAnimationInfo* pInfo;
121 : SdrMark* pMark;
122 :
123 : // inspect first object
124 0 : pMark = rMarkList.GetMark(0);
125 0 : pInfo = mpDoc->GetAnimationInfo(pMark->GetMarkedSdrObj());
126 0 : if( pInfo )
127 : {
128 0 : bActive = pInfo->mbActive;
129 0 : nAnimationSet = ATTR_SET;
130 :
131 0 : eEffect = pInfo->meEffect;
132 0 : nEffectSet = ATTR_SET;
133 :
134 0 : eTextEffect = pInfo->meTextEffect;
135 0 : nTextEffectSet = ATTR_SET;
136 :
137 0 : eSpeed = pInfo->meSpeed;
138 0 : nSpeedSet = ATTR_SET;
139 :
140 0 : bFadeOut = pInfo->mbDimPrevious;
141 0 : nFadeOutSet = ATTR_SET;
142 :
143 0 : aFadeColor = pInfo->maDimColor;
144 0 : nFadeColorSet = ATTR_SET;
145 :
146 0 : bInvisible = pInfo->mbDimHide;
147 0 : nInvisibleSet = ATTR_SET;
148 :
149 0 : bSoundOn = pInfo->mbSoundOn;
150 0 : nSoundOnSet = ATTR_SET;
151 :
152 0 : aSound = pInfo->maSoundFile;
153 0 : nSoundFileSet = ATTR_SET;
154 :
155 0 : bPlayFull = pInfo->mbPlayFull;
156 0 : nPlayFullSet = ATTR_SET;
157 :
158 0 : eClickAction = pInfo->meClickAction;
159 0 : nClickActionSet = ATTR_SET;
160 :
161 0 : aBookmark = pInfo->GetBookmark();
162 0 : nBookmarkSet = ATTR_SET;
163 :
164 0 : eSecondEffect = pInfo->meSecondEffect;
165 0 : nSecondEffectSet = ATTR_SET;
166 :
167 0 : eSecondSpeed = pInfo->meSecondSpeed;
168 0 : nSecondSpeedSet = ATTR_SET;
169 :
170 0 : bSecondSoundOn = pInfo->mbSecondSoundOn;
171 0 : nSecondSoundOnSet = ATTR_SET;
172 :
173 0 : bSecondPlayFull = pInfo->mbSecondPlayFull;
174 0 : nSecondPlayFullSet = ATTR_SET;
175 : }
176 :
177 : // if necessary, inspect more objects
178 0 : for( size_t nObject = 1; nObject < nCount; ++nObject )
179 : {
180 0 : pMark = rMarkList.GetMark( nObject );
181 0 : SdrObject* pObject = pMark->GetMarkedSdrObj();
182 0 : pInfo = mpDoc->GetAnimationInfo(pObject);
183 0 : if( pInfo )
184 : {
185 0 : if( bActive != pInfo->mbActive )
186 0 : nAnimationSet = ATTR_MIXED;
187 :
188 0 : if( eEffect != pInfo->meEffect )
189 0 : nEffectSet = ATTR_MIXED;
190 :
191 0 : if( eTextEffect != pInfo->meTextEffect )
192 0 : nTextEffectSet = ATTR_MIXED;
193 :
194 0 : if( eSpeed != pInfo->meSpeed )
195 0 : nSpeedSet = ATTR_MIXED;
196 :
197 0 : if( bFadeOut != pInfo->mbDimPrevious )
198 0 : nFadeOutSet = ATTR_MIXED;
199 :
200 0 : if( aFadeColor != pInfo->maDimColor )
201 0 : nFadeColorSet = ATTR_MIXED;
202 :
203 0 : if( bInvisible != pInfo->mbDimHide )
204 0 : nInvisibleSet = ATTR_MIXED;
205 :
206 0 : if( bSoundOn != pInfo->mbSoundOn )
207 0 : nSoundOnSet = ATTR_MIXED;
208 :
209 0 : if( aSound != pInfo->maSoundFile )
210 0 : nSoundFileSet = ATTR_MIXED;
211 :
212 0 : if( bPlayFull != pInfo->mbPlayFull )
213 0 : nPlayFullSet = ATTR_MIXED;
214 :
215 0 : if( eClickAction != pInfo->meClickAction )
216 0 : nClickActionSet = ATTR_MIXED;
217 :
218 0 : if( aBookmark != pInfo->GetBookmark() )
219 0 : nBookmarkSet = ATTR_MIXED;
220 :
221 0 : if( eSecondEffect != pInfo->meSecondEffect )
222 0 : nSecondEffectSet = ATTR_MIXED;
223 :
224 0 : if( eSecondSpeed != pInfo->meSecondSpeed )
225 0 : nSecondSpeedSet = ATTR_MIXED;
226 :
227 0 : if( bSecondSoundOn != pInfo->mbSecondSoundOn )
228 0 : nSecondSoundOnSet = ATTR_MIXED;
229 :
230 0 : if( bSecondPlayFull != pInfo->mbSecondPlayFull )
231 0 : nSecondPlayFullSet = ATTR_MIXED;
232 : }
233 : else
234 : {
235 0 : if (nAnimationSet == ATTR_SET && bActive)
236 0 : nAnimationSet = ATTR_MIXED;
237 :
238 0 : if (nEffectSet == ATTR_SET && eEffect != presentation::AnimationEffect_NONE)
239 0 : nEffectSet = ATTR_MIXED;
240 :
241 0 : if (nTextEffectSet == ATTR_SET && eTextEffect != presentation::AnimationEffect_NONE)
242 0 : nTextEffectSet = ATTR_MIXED;
243 :
244 0 : if (nSpeedSet == ATTR_SET)
245 0 : nSpeedSet = ATTR_MIXED;
246 :
247 0 : if (nFadeOutSet == ATTR_SET && bFadeOut)
248 0 : nFadeOutSet = ATTR_MIXED;
249 :
250 0 : if (nFadeColorSet == ATTR_SET)
251 0 : nFadeColorSet = ATTR_MIXED;
252 :
253 0 : if (nInvisibleSet == ATTR_SET && bInvisible)
254 0 : nInvisibleSet = ATTR_MIXED;
255 :
256 0 : if (nSoundOnSet == ATTR_SET && bSoundOn)
257 0 : nSoundOnSet = ATTR_MIXED;
258 :
259 0 : if (nSoundFileSet == ATTR_SET)
260 0 : nSoundFileSet = ATTR_MIXED;
261 :
262 0 : if (nPlayFullSet == ATTR_SET && bPlayFull)
263 0 : nPlayFullSet = ATTR_MIXED;
264 :
265 0 : if (nClickActionSet == ATTR_SET && eClickAction != presentation::ClickAction_NONE)
266 0 : nClickActionSet = ATTR_MIXED;
267 :
268 0 : if (nBookmarkSet == ATTR_SET)
269 0 : nBookmarkSet = ATTR_MIXED;
270 :
271 0 : if (nSecondEffectSet == ATTR_SET && eSecondEffect != presentation::AnimationEffect_NONE)
272 0 : nSecondEffectSet = ATTR_MIXED;
273 :
274 0 : if (nSecondSpeedSet == ATTR_SET)
275 0 : nSecondSpeedSet = ATTR_MIXED;
276 :
277 0 : if (nSecondSoundOnSet == ATTR_SET && bSecondSoundOn)
278 0 : nSecondSoundOnSet = ATTR_MIXED;
279 :
280 0 : if (nSecondPlayFullSet == ATTR_SET && bSecondPlayFull)
281 0 : nSecondPlayFullSet = ATTR_MIXED;
282 : }
283 : }
284 :
285 : /* Exactly two objects with path effect?
286 : Then, only the animation info at the moved object is valid. */
287 0 : if (nCount == 2)
288 : {
289 0 : SdrObject* pObject1 = rMarkList.GetMark(0)->GetMarkedSdrObj();
290 0 : SdrObject* pObject2 = rMarkList.GetMark(1)->GetMarkedSdrObj();
291 0 : SdrObjKind eKind1 = (SdrObjKind)pObject1->GetObjIdentifier();
292 0 : SdrObjKind eKind2 = (SdrObjKind)pObject2->GetObjIdentifier();
293 0 : SdAnimationInfo* pInfo1 = mpDoc->GetAnimationInfo(pObject1);
294 0 : SdAnimationInfo* pInfo2 = mpDoc->GetAnimationInfo(pObject2);
295 0 : pInfo = NULL;
296 :
297 0 : if (pObject1->GetObjInventor() == SdrInventor &&
298 0 : ((eKind1 == OBJ_LINE) || // 2 point line
299 0 : (eKind1 == OBJ_PLIN) || // Polygon
300 0 : (eKind1 == OBJ_PATHLINE)) && // Bezier curve
301 0 : (pInfo2 && pInfo2->meEffect == presentation::AnimationEffect_PATH))
302 : {
303 0 : pInfo = pInfo2;
304 : }
305 :
306 0 : if (pObject2->GetObjInventor() == SdrInventor &&
307 0 : ((eKind2 == OBJ_LINE) || // 2 point line
308 0 : (eKind2 == OBJ_PLIN) || // Polygon
309 0 : (eKind2 == OBJ_PATHLINE)) && // Bezier curve
310 0 : (pInfo1 && pInfo1->meEffect == presentation::AnimationEffect_PATH))
311 : {
312 0 : pInfo = pInfo1;
313 : }
314 :
315 0 : if (pInfo)
316 : {
317 0 : bActive = pInfo->mbActive; nAnimationSet = ATTR_SET;
318 0 : eEffect = pInfo->meEffect; nEffectSet = ATTR_SET;
319 0 : eTextEffect = pInfo->meTextEffect; nTextEffectSet = ATTR_SET;
320 0 : eSpeed = pInfo->meSpeed; nSpeedSet = ATTR_SET;
321 0 : bFadeOut = pInfo->mbDimPrevious; nFadeOutSet = ATTR_SET;
322 0 : aFadeColor = pInfo->maDimColor; nFadeColorSet = ATTR_SET;
323 0 : bInvisible = pInfo->mbDimHide; nInvisibleSet = ATTR_SET;
324 0 : bSoundOn = pInfo->mbSoundOn; nSoundOnSet = ATTR_SET;
325 0 : aSound = pInfo->maSoundFile; nSoundFileSet = ATTR_SET;
326 0 : bPlayFull = pInfo->mbPlayFull; nPlayFullSet = ATTR_SET;
327 0 : eClickAction = pInfo->meClickAction; nClickActionSet = ATTR_SET;
328 0 : aBookmark = pInfo->GetBookmark(); nBookmarkSet = ATTR_SET;
329 0 : eSecondEffect = pInfo->meSecondEffect; nSecondEffectSet = ATTR_SET;
330 0 : eSecondSpeed = pInfo->meSecondSpeed; nSecondSpeedSet = ATTR_SET;
331 0 : bSecondSoundOn = pInfo->mbSecondSoundOn; nSecondSoundOnSet = ATTR_SET;
332 0 : bSecondPlayFull = pInfo->mbSecondPlayFull; nSecondPlayFullSet = ATTR_SET;
333 : }
334 : }
335 :
336 0 : const SfxItemSet* pArgs = rReq.GetArgs();
337 :
338 0 : if(!pArgs)
339 : {
340 : // fill ItemSet for dialog
341 0 : SfxItemSet aSet(mpDoc->GetPool(), ATTR_ANIMATION_START, ATTR_ACTION_END);
342 :
343 : // fill the set
344 0 : if (nAnimationSet == ATTR_SET)
345 0 : aSet.Put( SfxBoolItem( ATTR_ANIMATION_ACTIVE, bActive));
346 0 : else if (nAnimationSet == ATTR_MIXED)
347 0 : aSet.InvalidateItem(ATTR_ANIMATION_ACTIVE);
348 : else
349 0 : aSet.Put(SfxBoolItem(ATTR_ANIMATION_ACTIVE, false));
350 :
351 0 : if (nEffectSet == ATTR_SET)
352 0 : aSet.Put(SfxAllEnumItem(ATTR_ANIMATION_EFFECT, (sal_uInt16)eEffect));
353 0 : else if (nEffectSet == ATTR_MIXED)
354 0 : aSet.InvalidateItem( ATTR_ANIMATION_EFFECT );
355 : else
356 0 : aSet.Put(SfxAllEnumItem(ATTR_ANIMATION_EFFECT, presentation::AnimationEffect_NONE));
357 :
358 0 : if (nTextEffectSet == ATTR_SET)
359 0 : aSet.Put(SfxAllEnumItem(ATTR_ANIMATION_TEXTEFFECT, (sal_uInt16)eTextEffect));
360 0 : else if (nTextEffectSet == ATTR_MIXED)
361 0 : aSet.InvalidateItem( ATTR_ANIMATION_TEXTEFFECT );
362 : else
363 0 : aSet.Put(SfxAllEnumItem(ATTR_ANIMATION_TEXTEFFECT, presentation::AnimationEffect_NONE));
364 :
365 0 : if (nSpeedSet == ATTR_SET)
366 0 : aSet.Put(SfxAllEnumItem(ATTR_ANIMATION_SPEED, (sal_uInt16)eSpeed));
367 : else
368 0 : aSet.InvalidateItem(ATTR_ANIMATION_SPEED);
369 :
370 0 : if (nFadeOutSet == ATTR_SET)
371 0 : aSet.Put(SfxBoolItem(ATTR_ANIMATION_FADEOUT, bFadeOut));
372 0 : else if (nFadeOutSet == ATTR_MIXED)
373 0 : aSet.InvalidateItem(ATTR_ANIMATION_FADEOUT);
374 : else
375 0 : aSet.Put(SfxBoolItem(ATTR_ANIMATION_FADEOUT, false));
376 :
377 0 : if (nFadeColorSet == ATTR_SET)
378 0 : aSet.Put(SvxColorItem(aFadeColor, ATTR_ANIMATION_COLOR));
379 0 : else if (nFadeColorSet == ATTR_MIXED)
380 0 : aSet.InvalidateItem(ATTR_ANIMATION_COLOR);
381 : else
382 0 : aSet.Put(SvxColorItem(RGB_Color(COL_LIGHTGRAY), ATTR_ANIMATION_COLOR));
383 :
384 0 : if (nInvisibleSet == ATTR_SET)
385 0 : aSet.Put(SfxBoolItem(ATTR_ANIMATION_INVISIBLE, bInvisible));
386 0 : else if (nInvisibleSet == ATTR_MIXED)
387 0 : aSet.InvalidateItem(ATTR_ANIMATION_INVISIBLE);
388 : else
389 0 : aSet.Put(SfxBoolItem(ATTR_ANIMATION_INVISIBLE, false));
390 :
391 0 : if (nSoundOnSet == ATTR_SET)
392 0 : aSet.Put(SfxBoolItem(ATTR_ANIMATION_SOUNDON, bSoundOn));
393 0 : else if (nSoundOnSet == ATTR_MIXED)
394 0 : aSet.InvalidateItem(ATTR_ANIMATION_SOUNDON);
395 : else
396 0 : aSet.Put(SfxBoolItem(ATTR_ANIMATION_SOUNDON, false));
397 :
398 0 : if (nSoundFileSet == ATTR_SET)
399 0 : aSet.Put(SfxStringItem(ATTR_ANIMATION_SOUNDFILE, aSound));
400 : else
401 0 : aSet.InvalidateItem(ATTR_ANIMATION_SOUNDFILE);
402 :
403 0 : if (nPlayFullSet == ATTR_SET)
404 0 : aSet.Put(SfxBoolItem(ATTR_ANIMATION_PLAYFULL, bPlayFull));
405 0 : else if (nPlayFullSet == ATTR_MIXED)
406 0 : aSet.InvalidateItem(ATTR_ANIMATION_PLAYFULL);
407 : else
408 0 : aSet.Put(SfxBoolItem(ATTR_ANIMATION_PLAYFULL, false));
409 :
410 0 : if (nClickActionSet == ATTR_SET)
411 0 : aSet.Put(SfxAllEnumItem(ATTR_ACTION, (sal_uInt16)eClickAction));
412 0 : else if (nClickActionSet == ATTR_MIXED)
413 0 : aSet.InvalidateItem(ATTR_ACTION);
414 : else
415 0 : aSet.Put(SfxAllEnumItem(ATTR_ACTION, presentation::ClickAction_NONE));
416 :
417 0 : if (nBookmarkSet == ATTR_SET)
418 0 : aSet.Put(SfxStringItem(ATTR_ACTION_FILENAME, aBookmark));
419 : else
420 0 : aSet.InvalidateItem(ATTR_ACTION_FILENAME);
421 :
422 0 : if (nSecondEffectSet == ATTR_SET)
423 0 : aSet.Put(SfxAllEnumItem(ATTR_ACTION_EFFECT, (sal_uInt16)eSecondEffect));
424 0 : else if (nSecondEffectSet == ATTR_MIXED)
425 0 : aSet.InvalidateItem( ATTR_ACTION_EFFECT );
426 : else
427 0 : aSet.Put(SfxAllEnumItem(ATTR_ACTION_EFFECT, presentation::AnimationEffect_NONE));
428 :
429 0 : if (nSecondSpeedSet == ATTR_SET)
430 0 : aSet.Put(SfxAllEnumItem(ATTR_ACTION_EFFECTSPEED, (sal_uInt16)eSecondSpeed));
431 : else
432 0 : aSet.InvalidateItem(ATTR_ACTION_EFFECTSPEED);
433 :
434 0 : if (nSecondSoundOnSet == ATTR_SET)
435 0 : aSet.Put(SfxBoolItem(ATTR_ACTION_SOUNDON, bSecondSoundOn));
436 0 : else if (nSecondSoundOnSet == ATTR_MIXED)
437 0 : aSet.InvalidateItem(ATTR_ACTION_SOUNDON);
438 : else
439 0 : aSet.Put(SfxBoolItem(ATTR_ACTION_SOUNDON, false));
440 :
441 0 : if (nSecondPlayFullSet == ATTR_SET)
442 0 : aSet.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL, bSecondPlayFull));
443 0 : else if (nSecondPlayFullSet == ATTR_MIXED)
444 0 : aSet.InvalidateItem(ATTR_ACTION_PLAYFULL);
445 : else
446 0 : aSet.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL, false));
447 :
448 0 : SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
449 0 : boost::scoped_ptr<SfxAbstractDialog> pDlg(pFact ? pFact->CreatSdActionDialog( NULL, &aSet, mpView ) : 0);
450 :
451 0 : short nResult = pDlg ? pDlg->Execute() : static_cast<short>(RET_CANCEL);
452 :
453 0 : if( nResult == RET_OK )
454 : {
455 0 : rReq.Done( *( pDlg->GetOutputItemSet() ) );
456 0 : pArgs = rReq.GetArgs();
457 : }
458 :
459 0 : if( nResult != RET_OK )
460 0 : return;
461 : }
462 :
463 : // evaluation of the ItemSets
464 0 : if (pArgs->GetItemState(ATTR_ANIMATION_ACTIVE) == SfxItemState::SET)
465 : {
466 0 : bActive = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ANIMATION_ACTIVE)).GetValue();
467 0 : nAnimationSet = ATTR_SET;
468 : }
469 : else
470 0 : nAnimationSet = ATTR_MISSING;
471 :
472 0 : if (pArgs->GetItemState(ATTR_ANIMATION_EFFECT) == SfxItemState::SET)
473 : {
474 : eEffect = (presentation::AnimationEffect)static_cast<const SfxAllEnumItem&>( pArgs->
475 0 : Get(ATTR_ANIMATION_EFFECT)).GetValue();
476 0 : nEffectSet = ATTR_SET;
477 : }
478 : else
479 0 : nEffectSet = ATTR_MISSING;
480 :
481 0 : if (pArgs->GetItemState(ATTR_ANIMATION_TEXTEFFECT) == SfxItemState::SET)
482 : {
483 : eTextEffect = (presentation::AnimationEffect)static_cast<const SfxAllEnumItem&>( pArgs->
484 0 : Get(ATTR_ANIMATION_TEXTEFFECT)).GetValue();
485 0 : nTextEffectSet = ATTR_SET;
486 : }
487 : else
488 0 : nTextEffectSet = ATTR_MISSING;
489 :
490 0 : if (pArgs->GetItemState(ATTR_ANIMATION_SPEED) == SfxItemState::SET)
491 : {
492 : eSpeed = (presentation::AnimationSpeed)static_cast<const SfxAllEnumItem&>( pArgs->
493 0 : Get(ATTR_ANIMATION_SPEED)).GetValue();
494 0 : nSpeedSet = ATTR_SET;
495 : }
496 : else
497 0 : nSpeedSet = ATTR_MISSING;
498 :
499 0 : if (pArgs->GetItemState(ATTR_ANIMATION_FADEOUT) == SfxItemState::SET)
500 : {
501 0 : bFadeOut = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ANIMATION_FADEOUT)).GetValue();
502 0 : nFadeOutSet = ATTR_SET;
503 : }
504 : else
505 0 : nFadeOutSet = ATTR_MISSING;
506 :
507 0 : if (pArgs->GetItemState(ATTR_ANIMATION_INVISIBLE) == SfxItemState::SET)
508 : {
509 0 : bInvisible = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ANIMATION_INVISIBLE)).GetValue();
510 0 : nInvisibleSet = ATTR_SET;
511 : }
512 : else
513 0 : nInvisibleSet = ATTR_MISSING;
514 :
515 0 : if (pArgs->GetItemState(ATTR_ANIMATION_SOUNDON) == SfxItemState::SET)
516 : {
517 0 : bSoundOn = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ANIMATION_SOUNDON)).GetValue();
518 0 : nSoundOnSet = ATTR_SET;
519 : }
520 : else
521 0 : nSoundOnSet = ATTR_MISSING;
522 :
523 0 : if (pArgs->GetItemState(ATTR_ANIMATION_SOUNDFILE) == SfxItemState::SET)
524 : {
525 0 : aSound = static_cast<const SfxStringItem&>(pArgs->Get(ATTR_ANIMATION_SOUNDFILE)).GetValue();
526 0 : nSoundFileSet = ATTR_SET;
527 : }
528 : else
529 0 : nSoundFileSet = ATTR_MISSING;
530 :
531 0 : if (pArgs->GetItemState(ATTR_ANIMATION_COLOR) == SfxItemState::SET)
532 : {
533 0 : aFadeColor = static_cast<const SvxColorItem&>(pArgs->Get(ATTR_ANIMATION_COLOR)).GetValue();
534 0 : nFadeColorSet = ATTR_SET;
535 : }
536 : else
537 0 : nFadeColorSet = ATTR_MISSING;
538 :
539 0 : if (pArgs->GetItemState(ATTR_ANIMATION_PLAYFULL) == SfxItemState::SET)
540 : {
541 0 : bPlayFull = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ANIMATION_PLAYFULL)).GetValue();
542 0 : nPlayFullSet = ATTR_SET;
543 : }
544 : else
545 0 : nPlayFullSet = ATTR_MISSING;
546 :
547 0 : if (pArgs->GetItemState(ATTR_ACTION) == SfxItemState::SET)
548 : {
549 : eClickAction = (presentation::ClickAction)static_cast<const SfxAllEnumItem&>(pArgs->
550 0 : Get(ATTR_ACTION)).GetValue();
551 0 : nClickActionSet = ATTR_SET;
552 : }
553 : else
554 0 : nClickActionSet = ATTR_MISSING;
555 :
556 0 : if (pArgs->GetItemState(ATTR_ACTION_FILENAME) == SfxItemState::SET)
557 : {
558 : aBookmark = static_cast<const SfxStringItem&>(pArgs->
559 0 : Get(ATTR_ACTION_FILENAME)).GetValue();
560 0 : nBookmarkSet = ATTR_SET;
561 : }
562 : else
563 0 : nBookmarkSet = ATTR_MISSING;
564 :
565 0 : if (pArgs->GetItemState(ATTR_ACTION_EFFECT) == SfxItemState::SET)
566 : {
567 : eSecondEffect = (presentation::AnimationEffect)static_cast<const SfxAllEnumItem&>( pArgs->
568 0 : Get(ATTR_ACTION_EFFECT)).GetValue();
569 0 : nSecondEffectSet = ATTR_SET;
570 : }
571 : else
572 0 : nSecondEffectSet = ATTR_MISSING;
573 :
574 0 : if (pArgs->GetItemState(ATTR_ACTION_EFFECTSPEED) == SfxItemState::SET)
575 : {
576 : eSecondSpeed = (presentation::AnimationSpeed)static_cast<const SfxAllEnumItem&>( pArgs->
577 0 : Get(ATTR_ACTION_EFFECTSPEED)).GetValue();
578 0 : nSecondSpeedSet = ATTR_SET;
579 : }
580 : else
581 0 : nSecondSpeedSet = ATTR_MISSING;
582 :
583 0 : if (pArgs->GetItemState(ATTR_ACTION_SOUNDON) == SfxItemState::SET)
584 : {
585 0 : bSecondSoundOn = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ACTION_SOUNDON)).GetValue();
586 0 : nSecondSoundOnSet = ATTR_SET;
587 : }
588 : else
589 0 : nSecondSoundOnSet = ATTR_MISSING;
590 :
591 0 : if (pArgs->GetItemState(ATTR_ACTION_PLAYFULL) == SfxItemState::SET)
592 : {
593 0 : bSecondPlayFull = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_ACTION_PLAYFULL)).GetValue();
594 0 : nSecondPlayFullSet = ATTR_SET;
595 : }
596 : else
597 0 : nSecondPlayFullSet = ATTR_MISSING;
598 :
599 : // if any attribute is chosen
600 0 : if (nEffectSet == ATTR_SET ||
601 0 : nTextEffectSet == ATTR_SET ||
602 0 : nSpeedSet == ATTR_SET ||
603 0 : nAnimationSet == ATTR_SET ||
604 0 : nFadeOutSet == ATTR_SET ||
605 0 : nFadeColorSet == ATTR_SET ||
606 0 : nInvisibleSet == ATTR_SET ||
607 0 : nSoundOnSet == ATTR_SET ||
608 0 : nSoundFileSet == ATTR_SET ||
609 0 : nPlayFullSet == ATTR_SET ||
610 0 : nClickActionSet == ATTR_SET ||
611 0 : nBookmarkSet == ATTR_SET ||
612 0 : nSecondEffectSet == ATTR_SET ||
613 0 : nSecondSpeedSet == ATTR_SET ||
614 0 : nSecondSoundOnSet == ATTR_SET ||
615 : nSecondPlayFullSet == ATTR_SET)
616 : {
617 : // String for undo-group and list-action
618 0 : OUString aComment(SdResId(STR_UNDO_ANIMATION));
619 :
620 : // with 'following curves', we have an additional UndoAction
621 : // therefore cling? here
622 0 : pUndoMgr->EnterListAction(aComment, aComment);
623 :
624 : // create undo group
625 0 : SdUndoGroup* pUndoGroup = new SdUndoGroup(mpDoc);
626 0 : pUndoGroup->SetComment(aComment);
627 :
628 : // for the path effect, remember some stuff
629 0 : SdrObject* pRunningObj = NULL;
630 0 : SdrPathObj* pPath = NULL;
631 0 : if (eEffect == presentation::AnimationEffect_PATH && nEffectSet == ATTR_SET)
632 : {
633 : DBG_ASSERT(nCount == 2, "This effect expects two selected objects");
634 0 : SdrObject* pObject1 = rMarkList.GetMark(0)->GetMarkedSdrObj();
635 0 : SdrObject* pObject2 = rMarkList.GetMark(1)->GetMarkedSdrObj();
636 0 : SdrObjKind eKind1 = (SdrObjKind)pObject1->GetObjIdentifier();
637 0 : SdrObjKind eKind2 = (SdrObjKind)pObject2->GetObjIdentifier();
638 :
639 0 : if (pObject1->GetObjInventor() == SdrInventor &&
640 0 : ((eKind1 == OBJ_LINE) || // 2 point line
641 0 : (eKind1 == OBJ_PLIN) || // Polygon
642 : (eKind1 == OBJ_PATHLINE))) // Bezier curve
643 : {
644 0 : pPath = static_cast<SdrPathObj*>(pObject1);
645 0 : pRunningObj = pObject2;
646 : }
647 :
648 0 : if (pObject2->GetObjInventor() == SdrInventor &&
649 0 : ((eKind2 == OBJ_LINE) || // 2 point line
650 0 : (eKind2 == OBJ_PLIN) || // Polygon
651 : (eKind2 == OBJ_PATHLINE))) // Bezier curve
652 : {
653 0 : pPath = static_cast<SdrPathObj*>(pObject2);
654 0 : pRunningObj = pObject1;
655 : }
656 :
657 : assert(pRunningObj && pPath && "no curve found");
658 :
659 : // push the running object to the end of the curve
660 0 : if (pRunningObj)
661 : {
662 0 : Rectangle aCurRect(pRunningObj->GetLogicRect());
663 0 : Point aCurCenter(aCurRect.Center());
664 0 : const ::basegfx::B2DPolyPolygon& rPolyPolygon = pPath->GetPathPoly();
665 0 : sal_uInt32 nNoOfPolygons(rPolyPolygon.count());
666 0 : const ::basegfx::B2DPolygon aPolygon(rPolyPolygon.getB2DPolygon(nNoOfPolygons - 1L));
667 0 : sal_uInt32 nPoints(aPolygon.count());
668 0 : const ::basegfx::B2DPoint aNewB2DCenter(aPolygon.getB2DPoint(nPoints - 1L));
669 0 : const Point aNewCenter(FRound(aNewB2DCenter.getX()), FRound(aNewB2DCenter.getY()));
670 0 : Size aDistance(aNewCenter.X() - aCurCenter.X(), aNewCenter.Y() - aCurCenter.Y());
671 0 : pRunningObj->Move(aDistance);
672 :
673 0 : pUndoMgr->AddUndoAction(mpDoc->GetSdrUndoFactory().CreateUndoMoveObject( *pRunningObj, aDistance));
674 : }
675 : }
676 :
677 0 : for (size_t nObject = 0; nObject < nCount; ++nObject)
678 : {
679 0 : SdrObject* pObject = rMarkList.GetMark(nObject)->GetMarkedSdrObj();
680 :
681 0 : pInfo = mpDoc->GetAnimationInfo(pObject);
682 :
683 0 : bool bCreated = false;
684 0 : if( !pInfo )
685 : {
686 0 : pInfo = SdDrawDocument::GetShapeUserData(*pObject,true);
687 0 : bCreated = true;
688 : }
689 :
690 : // path object for 'following curves'?
691 0 : if (eEffect == presentation::AnimationEffect_PATH && pObject == pPath)
692 : {
693 : SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction
694 0 : (mpDoc, pObject, bCreated);
695 0 : pAction->SetActive(pInfo->mbActive, pInfo->mbActive);
696 0 : pAction->SetEffect(pInfo->meEffect, pInfo->meEffect);
697 0 : pAction->SetTextEffect(pInfo->meTextEffect, pInfo->meTextEffect);
698 0 : pAction->SetSpeed(pInfo->meSpeed, pInfo->meSpeed);
699 0 : pAction->SetDim(pInfo->mbDimPrevious, pInfo->mbDimPrevious);
700 0 : pAction->SetDimColor(pInfo->maDimColor, pInfo->maDimColor);
701 0 : pAction->SetDimHide(pInfo->mbDimHide, pInfo->mbDimHide);
702 0 : pAction->SetSoundOn(pInfo->mbSoundOn, pInfo->mbSoundOn);
703 0 : pAction->SetSound(pInfo->maSoundFile, pInfo->maSoundFile);
704 0 : pAction->SetPlayFull(pInfo->mbPlayFull, pInfo->mbPlayFull);
705 0 : pAction->SetClickAction(pInfo->meClickAction, pInfo->meClickAction);
706 0 : pAction->SetBookmark(pInfo->GetBookmark(), pInfo->GetBookmark());
707 0 : pAction->SetVerb(pInfo->mnVerb, pInfo->mnVerb);
708 0 : pAction->SetSecondEffect(pInfo->meSecondEffect, pInfo->meSecondEffect);
709 0 : pAction->SetSecondSpeed(pInfo->meSecondSpeed, pInfo->meSecondSpeed);
710 0 : pAction->SetSecondSoundOn(pInfo->mbSecondSoundOn, pInfo->mbSecondSoundOn);
711 0 : pAction->SetSecondPlayFull(pInfo->mbSecondPlayFull, pInfo->mbSecondPlayFull);
712 0 : pUndoGroup->AddAction(pAction);
713 :
714 : }
715 : else
716 : {
717 :
718 : // create undo action with old and new sizes
719 : SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction
720 0 : (mpDoc, pObject, bCreated);
721 0 : pAction->SetActive(pInfo->mbActive, bActive);
722 0 : pAction->SetEffect(pInfo->meEffect, eEffect);
723 0 : pAction->SetTextEffect(pInfo->meTextEffect, eTextEffect);
724 0 : pAction->SetSpeed(pInfo->meSpeed, eSpeed);
725 0 : pAction->SetDim(pInfo->mbDimPrevious, bFadeOut);
726 0 : pAction->SetDimColor(pInfo->maDimColor, aFadeColor);
727 0 : pAction->SetDimHide(pInfo->mbDimHide, bInvisible);
728 0 : pAction->SetSoundOn(pInfo->mbSoundOn, bSoundOn);
729 0 : pAction->SetSound(pInfo->maSoundFile, aSound);
730 0 : pAction->SetPlayFull(pInfo->mbPlayFull, bPlayFull);
731 0 : pAction->SetPathObj(pInfo->mpPathObj, pPath);
732 0 : pAction->SetClickAction(pInfo->meClickAction, eClickAction);
733 0 : pAction->SetBookmark(pInfo->GetBookmark(), aBookmark);
734 0 : pAction->SetVerb(pInfo->mnVerb, (sal_uInt16)pInfo->GetBookmark().toInt32() );
735 0 : pAction->SetSecondEffect(pInfo->meSecondEffect, eSecondEffect);
736 0 : pAction->SetSecondSpeed(pInfo->meSecondSpeed, eSecondSpeed);
737 0 : pAction->SetSecondSoundOn(pInfo->mbSecondSoundOn, bSecondSoundOn);
738 0 : pAction->SetSecondPlayFull(pInfo->mbSecondPlayFull,bSecondPlayFull);
739 0 : pUndoGroup->AddAction(pAction);
740 :
741 : // insert new values at info block of the object
742 0 : if (nAnimationSet == ATTR_SET)
743 0 : pInfo->mbActive = bActive;
744 :
745 0 : if (nEffectSet == ATTR_SET)
746 0 : pInfo->meEffect = eEffect;
747 :
748 0 : if (nTextEffectSet == ATTR_SET)
749 0 : pInfo->meTextEffect = eTextEffect;
750 :
751 0 : if (nSpeedSet == ATTR_SET)
752 0 : pInfo->meSpeed = eSpeed;
753 :
754 0 : if (nFadeOutSet == ATTR_SET)
755 0 : pInfo->mbDimPrevious = bFadeOut;
756 :
757 0 : if (nFadeColorSet == ATTR_SET)
758 0 : pInfo->maDimColor = aFadeColor;
759 :
760 0 : if (nInvisibleSet == ATTR_SET)
761 0 : pInfo->mbDimHide = bInvisible;
762 :
763 0 : if (nSoundOnSet == ATTR_SET)
764 0 : pInfo->mbSoundOn = bSoundOn;
765 :
766 0 : if (nSoundFileSet == ATTR_SET)
767 0 : pInfo->maSoundFile = aSound;
768 :
769 0 : if (nPlayFullSet == ATTR_SET)
770 0 : pInfo->mbPlayFull = bPlayFull;
771 :
772 0 : if (nClickActionSet == ATTR_SET)
773 0 : pInfo->meClickAction = eClickAction;
774 :
775 0 : if (nBookmarkSet == ATTR_SET)
776 0 : pInfo->SetBookmark( aBookmark );
777 :
778 0 : if (nSecondEffectSet == ATTR_SET)
779 0 : pInfo->meSecondEffect = eSecondEffect;
780 :
781 0 : if (nSecondSpeedSet == ATTR_SET)
782 0 : pInfo->meSecondSpeed = eSecondSpeed;
783 :
784 0 : if (nSecondSoundOnSet == ATTR_SET)
785 0 : pInfo->mbSecondSoundOn = bSecondSoundOn;
786 :
787 0 : if (nSecondPlayFullSet == ATTR_SET)
788 0 : pInfo->mbSecondPlayFull = bSecondPlayFull;
789 :
790 0 : if (eClickAction == presentation::ClickAction_VERB)
791 0 : pInfo->mnVerb = (sal_uInt16)aBookmark.toInt32();
792 : }
793 : }
794 : // Set the Undo Group in of the Undo Manager
795 0 : pUndoMgr->AddUndoAction(pUndoGroup);
796 0 : pUndoMgr->LeaveListAction();
797 :
798 : // Model changed
799 0 : mpDoc->SetChanged();
800 0 : }
801 : // not seen, therefore we do not need to invalidate at the bindings
802 : }
803 :
804 66 : } // end of namespace sd
805 :
806 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|