Coverage Report

Created: 2025-11-16 09:57

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