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