Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/unoidl/unomodel.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 <memory>
21
22
#include <com/sun/star/presentation/XPresentation2.hpp>
23
24
#include <com/sun/star/drawing/FillStyle.hpp>
25
#include <com/sun/star/drawing/LineStyle.hpp>
26
#include <com/sun/star/lang/DisposedException.hpp>
27
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
28
#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
29
#include <com/sun/star/lang/Locale.hpp>
30
#include <com/sun/star/awt/XDevice.hpp>
31
#include <com/sun/star/document/IndexedPropertyValues.hpp>
32
#include <com/sun/star/beans/PropertyAttribute.hpp>
33
#include <com/sun/star/util/XTheme.hpp>
34
#include <com/sun/star/animations/AnimationFill.hpp>
35
#include <com/sun/star/animations/AnimationRestart.hpp>
36
#include <com/sun/star/animations/AnimationEndSync.hpp>
37
#include <com/sun/star/animations/AnimationCalcMode.hpp>
38
#include <com/sun/star/animations/AnimationAdditiveMode.hpp>
39
#include <com/sun/star/animations/AnimationNodeType.hpp>
40
#include <com/sun/star/animations/AnimationTransformType.hpp>
41
#include <com/sun/star/animations/AnimationColorSpace.hpp>
42
#include <com/sun/star/animations/Event.hpp>
43
#include <com/sun/star/animations/EventTrigger.hpp>
44
#include <com/sun/star/animations/Timing.hpp>
45
#include <com/sun/star/animations/TransitionType.hpp>
46
#include <com/sun/star/animations/TransitionSubType.hpp>
47
#include <com/sun/star/animations/ValuePair.hpp>
48
#include <com/sun/star/animations/XAnimate.hpp>
49
#include <com/sun/star/animations/XAnimateMotion.hpp>
50
#include <com/sun/star/animations/XAnimateColor.hpp>
51
#include <com/sun/star/animations/XAnimateTransform.hpp>
52
#include <com/sun/star/animations/XIterateContainer.hpp>
53
#include <com/sun/star/animations/XTimeContainer.hpp>
54
#include <com/sun/star/animations/XTransitionFilter.hpp>
55
#include <com/sun/star/presentation/EffectNodeType.hpp>
56
#include <com/sun/star/presentation/EffectPresetClass.hpp>
57
#include <com/sun/star/presentation/ParagraphTarget.hpp>
58
#include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
59
#include <com/sun/star/presentation/TextAnimationType.hpp>
60
61
62
#include <com/sun/star/embed/Aspects.hpp>
63
64
#include <animations/animationnodehelper.hxx>
65
66
#include <officecfg/Office/Common.hxx>
67
#include <officecfg/Office/Impress.hxx>
68
#include <comphelper/dispatchcommand.hxx>
69
#include <comphelper/indexedpropertyvalues.hxx>
70
#include <comphelper/lok.hxx>
71
#include <comphelper/propertysequence.hxx>
72
#include <comphelper/propertyvalue.hxx>
73
#include <comphelper/sequence.hxx>
74
#include <comphelper/servicehelper.hxx>
75
#include <cppuhelper/supportsservice.hxx>
76
#include <comphelper/processfactory.hxx>
77
#include <comphelper/profilezone.hxx>
78
79
#include <sal/log.hxx>
80
#include <editeng/unofield.hxx>
81
#include <notifydocumentevent.hxx>
82
#include <tpaction.hxx>
83
#include <unomodel.hxx>
84
#include <sdhtmlfilter.hxx>
85
#include "unopool.hxx"
86
#include <sfx2/lokhelper.hxx>
87
#include <sfx2/dispatch.hxx>
88
#include <vcl/ptrstyle.hxx>
89
#include <vcl/themecolors.hxx>
90
#include <vcl/svapp.hxx>
91
#include <Outliner.hxx>
92
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
93
94
#include <editeng/UnoForbiddenCharsTable.hxx>
95
#include <svx/svdoutl.hxx>
96
#include <o3tl/any.hxx>
97
#include <o3tl/safeint.hxx>
98
#include <o3tl/string_view.hxx>
99
#include <o3tl/test_info.hxx>
100
#include <o3tl/unit_conversion.hxx>
101
#include <svx/UnoNamespaceMap.hxx>
102
#include <svx/svdlayer.hxx>
103
#include <svx/svdsob.hxx>
104
#include <svx/svdundo.hxx>
105
#include <svx/svdomedia.hxx>
106
#include <svx/unoapi.hxx>
107
#include <svx/unofill.hxx>
108
#include <svx/sdrpagewindow.hxx>
109
#include <svx/sdrpaintwindow.hxx>
110
#include <editeng/fontitem.hxx>
111
#include <toolkit/awt/vclxdevice.hxx>
112
#include <svx/svdpool.hxx>
113
#include <svx/svdpagv.hxx>
114
#include <svtools/unoimap.hxx>
115
#include <svx/unoshape.hxx>
116
#include <editeng/unonrule.hxx>
117
#include <editeng/eeitem.hxx>
118
#include <i18nlangtag/languagetag.hxx>
119
#include <unotools/datetime.hxx>
120
#include <sax/tools/converter.hxx>
121
#include <xmloff/autolayout.hxx>
122
#include <xmloff/xmltoken.hxx>
123
#include <rtl/math.hxx>
124
#include <tools/helpers.hxx>
125
#include <tools/json_writer.hxx>
126
#include <TransitionPreset.hxx>
127
128
// Support creation of GraphicStorageHandler and EmbeddedObjectResolver
129
#include <svx/xmleohlp.hxx>
130
#include <xmloff/xmlgrhlp.hxx>
131
#include <DrawDocShell.hxx>
132
#include <ViewShellBase.hxx>
133
#include "UnoDocumentSettings.hxx"
134
135
#include <Annotation.hxx>
136
#include <drawdoc.hxx>
137
#include <SlideSectionManager.hxx>
138
#include <sdmod.hxx>
139
#include <sdresid.hxx>
140
#include <sdpage.hxx>
141
#include <slideshow.hxx>
142
143
#include <strings.hrc>
144
#include <strings.hxx>
145
#include <unolayer.hxx>
146
#include <unopage.hxx>
147
#include "unocpres.hxx"
148
#include "unoobj.hxx"
149
#include <stlpool.hxx>
150
#include "unopback.hxx"
151
#include <unokywds.hxx>
152
153
#include <FrameView.hxx>
154
#include <ClientView.hxx>
155
#include <DrawViewShell.hxx>
156
#include <ViewShell.hxx>
157
#include <Window.hxx>
158
#include <optsitem.hxx>
159
#include <SlideshowLayerRenderer.hxx>
160
161
#include <vcl/pdfextoutdevdata.hxx>
162
#include <vcl/pdf/PDFNote.hxx>
163
164
#include <com/sun/star/presentation/AnimationSpeed.hpp>
165
#include <com/sun/star/presentation/ClickAction.hpp>
166
#include <svx/sdr/contact/viewobjectcontact.hxx>
167
#include <svx/sdr/contact/viewcontact.hxx>
168
#include <svx/sdr/contact/displayinfo.hxx>
169
170
#include <com/sun/star/office/XAnnotation.hpp>
171
#include <com/sun/star/office/XAnnotationAccess.hpp>
172
#include <com/sun/star/office/XAnnotationEnumeration.hpp>
173
#include <com/sun/star/geometry/RealPoint2D.hpp>
174
#include <com/sun/star/util/DateTime.hpp>
175
176
#include <drawinglayer/primitive2d/structuretagprimitive2d.hxx>
177
178
#include <sfx2/lokcomponenthelpers.hxx>
179
#include <sfx2/LokControlHandler.hxx>
180
#include <tools/gen.hxx>
181
#include <tools/debug.hxx>
182
#include <tools/urlobj.hxx>
183
#include <comphelper/diagnose_ex.hxx>
184
#include <tools/UnitConversion.hxx>
185
#include <svx/ColorSets.hxx>
186
#include <docmodel/theme/Theme.hxx>
187
188
#include <frozen/bits/defines.h>
189
#include <frozen/bits/elsa_std.h>
190
#include <frozen/unordered_map.h>
191
#include <SlideSorter.hxx>
192
#include <SlideSorterViewShell.hxx>
193
#include <controller/SlideSorterController.hxx>
194
#include <controller/SlsPageSelector.hxx>
195
196
#include <app.hrc>
197
198
using namespace ::cppu;
199
using namespace ::com::sun::star;
200
using namespace ::sd;
201
202
namespace
203
{
204
const TranslateId aTypeResIds[SdLinkTargetType::Count] =
205
{
206
    STR_SD_PAGE,            // SdLinkTargetType::Page
207
    STR_NOTES_MODE,         // SdLinkTargetType::Notes
208
    STR_HANDOUT,            // SdLinkTargetType::Handout
209
    STR_MASTERPAGE_NAME,    // SdLinkTargetType::MasterPage
210
};
211
212
const TranslateId aClickActionResIds[] =
213
{
214
    STR_CLICK_ACTION_NONE,             // ClickAction_NONE
215
    STR_CLICK_ACTION_PREVPAGE,         // ClickAction_PREVPAGE
216
    STR_CLICK_ACTION_NEXTPAGE,         // ClickAction_NEXTPAGE
217
    STR_CLICK_ACTION_FIRSTPAGE,        // ClickAction_FIRSTPAGE
218
    STR_CLICK_ACTION_LASTPAGE,         // ClickAction_LASTPAGE
219
    STR_CLICK_ACTION_BOOKMARK,         // ClickAction_BOOKMARK
220
    STR_CLICK_ACTION_DOCUMENT,         // ClickAction_DOCUMENT
221
    STR_CLICK_ACTION_INVISIBLE,        // ClickAction_INVISIBLE
222
    STR_CLICK_ACTION_SOUND,            // ClickAction_SOUND
223
    STR_CLICK_ACTION_VERB,             // ClickAction_VERB
224
    STR_CLICK_ACTION_VANISH,           // ClickAction_VANISH
225
    STR_CLICK_ACTION_PROGRAM,          // ClickAction_PROGRAM
226
    STR_CLICK_ACTION_MACRO,            // ClickAction_MACRO
227
    STR_CLICK_ACTION_STOPPRESENTATION, // ClickAction_STOPPRESENTATION
228
};
229
230
static_assert(SAL_N_ELEMENTS(aClickActionResIds)
231
              == static_cast<size_t>(presentation::ClickAction_STOPPRESENTATION) + 1,
232
              "aClickActionResIds is missing an entry for a presentation::ClickAction value");
233
}
234
235
TranslateId SdTPAction::GetClickActionSdResId( presentation::ClickAction eCA )
236
0
{
237
0
    auto nIndex = static_cast<size_t>(eCA);
238
0
    assert(nIndex < SAL_N_ELEMENTS(aClickActionResIds) && "ClickAction out of range");
239
0
    return aClickActionResIds[nIndex];
240
0
}
241
242
class SdUnoForbiddenCharsTable : public SvxUnoForbiddenCharsTable,
243
                                 public SfxListener
244
{
245
public:
246
    explicit SdUnoForbiddenCharsTable(SdrModel* pModel);
247
    virtual ~SdUnoForbiddenCharsTable() override;
248
249
    // SfxListener
250
    virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) noexcept override;
251
protected:
252
    virtual void onChange() override;
253
254
private:
255
    SdrModel*   mpModel;
256
};
257
258
namespace {
259
260
class SlideBackgroundInfo
261
{
262
public:
263
    SlideBackgroundInfo(const uno::Reference<drawing::XDrawPage>& xDrawPage,
264
                        const uno::Reference<drawing::XDrawPage>& xMasterPage);
265
0
    bool slideHasOwnBackground() const { return mbIsCustom; }
266
0
    bool hasBackground() const { return bHasBackground; }
267
0
    bool isSolidColor() const { return mbIsSolidColor; }
268
    ::Color getFillColor() const;
269
    sal_Int32 getFillTransparency() const;
270
    OString getFillColorAsRGBA() const;
271
private:
272
    bool getFillStyleImpl(const uno::Reference<drawing::XDrawPage>& xDrawPage);
273
private:
274
    uno::Reference<beans::XPropertySet> mxBackground;
275
    bool mbIsCustom;
276
    bool bHasBackground;
277
    bool mbIsSolidColor;
278
    drawing::FillStyle maFillStyle;
279
};
280
281
SlideBackgroundInfo::SlideBackgroundInfo(
282
        const uno::Reference<drawing::XDrawPage>& xDrawPage,
283
        const uno::Reference<drawing::XDrawPage>& xMasterPage)
284
0
    : mbIsCustom(false)
285
0
    , bHasBackground(false)
286
0
    , mbIsSolidColor(false)
287
0
    , maFillStyle(drawing::FillStyle_NONE)
288
0
{
289
0
    mbIsCustom = getFillStyleImpl(xDrawPage);
290
0
    bHasBackground = mbIsCustom;
291
0
    if (!bHasBackground)
292
0
    {
293
0
        bHasBackground = getFillStyleImpl(xMasterPage);
294
0
    }
295
0
    if (bHasBackground)
296
0
    {
297
0
        if (maFillStyle == drawing::FillStyle_SOLID)
298
0
        {
299
0
            OUString sGradientName;
300
0
            mxBackground->getPropertyValue("FillTransparenceGradientName") >>= sGradientName;
301
0
            if (sGradientName.isEmpty())
302
0
            {
303
0
                mbIsSolidColor = true;
304
0
            }
305
0
        }
306
0
    }
307
0
}
308
309
sal_Int32 SlideBackgroundInfo::getFillTransparency() const
310
0
{
311
0
    if (!mxBackground.is())
312
0
        return 0;
313
0
    sal_Int32 nFillTransparency = 0;
314
0
    mxBackground->getPropertyValue("FillTransparence") >>= nFillTransparency;
315
0
    return nFillTransparency;
316
0
}
317
318
::Color SlideBackgroundInfo::getFillColor() const
319
0
{
320
0
    if (!mxBackground.is())
321
0
        return {};
322
0
    if (sal_Int32 nFillColor; mxBackground->getPropertyValue("FillColor") >>= nFillColor)
323
0
    {
324
0
        return ::Color(ColorTransparency, nFillColor & 0xffffff);
325
0
    }
326
0
    return {};
327
0
}
328
329
OString SlideBackgroundInfo::getFillColorAsRGBA() const
330
0
{
331
0
    ::Color aColor = getFillColor();
332
0
    OString sColor = aColor.AsRGBHEXString().toUtf8();
333
0
    sal_uInt32 nAlpha = std::round((100 - getFillTransparency()) * 255 / 100.0);
334
0
    std::stringstream ss;
335
0
    ss << std::hex << std::uppercase << std::setfill ('0') << std::setw(2) << nAlpha;
336
0
    sColor += ss.str().c_str();
337
0
    return sColor;
338
0
}
339
340
bool SlideBackgroundInfo::getFillStyleImpl(const uno::Reference<drawing::XDrawPage>& xDrawPage)
341
0
{
342
0
    if( xDrawPage.is() )
343
0
    {
344
0
        uno::Reference< beans::XPropertySet > xPropSet( xDrawPage, uno::UNO_QUERY );
345
0
        if( xPropSet.is() )
346
0
        {
347
0
            uno::Reference< beans::XPropertySet > xBackground;
348
0
            if (xPropSet->getPropertySetInfo()->hasPropertyByName("Background"))
349
0
                xPropSet->getPropertyValue( "Background" ) >>= xBackground;
350
0
            if( xBackground.is() )
351
0
            {
352
0
                drawing::FillStyle aFillStyle;
353
0
                if( xBackground->getPropertyValue( "FillStyle" ) >>= aFillStyle )
354
0
                {
355
0
                    maFillStyle = aFillStyle;
356
0
                    if (aFillStyle != drawing::FillStyle_NONE)
357
0
                    {
358
0
                        mxBackground = std::move(xBackground);
359
0
                        return true;
360
0
                    }
361
0
                }
362
0
            }
363
0
        }
364
0
    }
365
0
    return false;
366
0
}
367
368
using namespace ::css::animations;
369
using namespace ::css::beans;
370
using namespace ::css::container;
371
using namespace ::css::uno;
372
using namespace ::xmloff::token;
373
using namespace ::css::presentation;
374
375
template <typename T, std::size_t N>
376
constexpr auto mapEnumToString(std::pair<T, std::string_view> const (&items)[N])
377
0
{
378
0
    return frozen::make_unordered_map<T, std::string_view, N>(items);
379
0
}
Unexecuted instantiation: unomodel.cxx:auto (anonymous namespace)::mapEnumToString<short, 17ul>(std::__1::pair<short, std::__1::basic_string_view<char, std::__1::char_traits<char> > > const (&) [17ul])
Unexecuted instantiation: unomodel.cxx:auto (anonymous namespace)::mapEnumToString<short, 41ul>(std::__1::pair<short, std::__1::basic_string_view<char, std::__1::char_traits<char> > > const (&) [41ul])
Unexecuted instantiation: unomodel.cxx:auto (anonymous namespace)::mapEnumToString<short, 13ul>(std::__1::pair<short, std::__1::basic_string_view<char, std::__1::char_traits<char> > > const (&) [13ul])
Unexecuted instantiation: unomodel.cxx:auto (anonymous namespace)::mapEnumToString<short, 6ul>(std::__1::pair<short, std::__1::basic_string_view<char, std::__1::char_traits<char> > > const (&) [6ul])
Unexecuted instantiation: unomodel.cxx:auto (anonymous namespace)::mapEnumToString<short, 4ul>(std::__1::pair<short, std::__1::basic_string_view<char, std::__1::char_traits<char> > > const (&) [4ul])
Unexecuted instantiation: unomodel.cxx:auto (anonymous namespace)::mapEnumToString<short, 5ul>(std::__1::pair<short, std::__1::basic_string_view<char, std::__1::char_traits<char> > > const (&) [5ul])
Unexecuted instantiation: unomodel.cxx:auto (anonymous namespace)::mapEnumToString<short, 7ul>(std::__1::pair<short, std::__1::basic_string_view<char, std::__1::char_traits<char> > > const (&) [7ul])
Unexecuted instantiation: unomodel.cxx:auto (anonymous namespace)::mapEnumToString<com::sun::star::animations::Timing, 2ul>(std::__1::pair<com::sun::star::animations::Timing, std::__1::basic_string_view<char, std::__1::char_traits<char> > > const (&) [2ul])
Unexecuted instantiation: unomodel.cxx:auto (anonymous namespace)::mapEnumToString<short, 3ul>(std::__1::pair<short, std::__1::basic_string_view<char, std::__1::char_traits<char> > > const (&) [3ul])
Unexecuted instantiation: unomodel.cxx:auto (anonymous namespace)::mapEnumToString<com::sun::star::drawing::FillStyle, 5ul>(std::__1::pair<com::sun::star::drawing::FillStyle, std::__1::basic_string_view<char, std::__1::char_traits<char> > > const (&) [5ul])
Unexecuted instantiation: unomodel.cxx:auto (anonymous namespace)::mapEnumToString<com::sun::star::drawing::LineStyle, 3ul>(std::__1::pair<com::sun::star::drawing::LineStyle, std::__1::basic_string_view<char, std::__1::char_traits<char> > > const (&) [3ul])
380
381
constexpr auto constTransitionTypeToString = mapEnumToString<sal_Int16>({
382
    { animations::TransitionType::BARWIPE, "BarWipe" }, // Wipe
383
    { animations::TransitionType::PINWHEELWIPE, "PineWheelWipe" }, // Wheel
384
    { animations::TransitionType::SLIDEWIPE, "SlideWipe" }, // Cover, Uncover
385
    { animations::TransitionType::RANDOMBARWIPE, "RandomBarWipe" }, // Bars
386
    { animations::TransitionType::CHECKERBOARDWIPE, "CheckerBoardWipe" }, // Checkers
387
    { animations::TransitionType::FOURBOXWIPE, "FourBoxWipe" }, // Shape
388
    { animations::TransitionType::IRISWIPE, "IrisWipe" }, // Box
389
    { animations::TransitionType::FANWIPE, "FanWipe" }, // Wedge
390
    { animations::TransitionType::BLINDSWIPE, "BlindWipe"}, // Venetian
391
    { animations::TransitionType::FADE, "Fade"},
392
    { animations::TransitionType::DISSOLVE, "Dissolve"},
393
    { animations::TransitionType::PUSHWIPE, "PushWipe"}, // Comb
394
    { animations::TransitionType::ELLIPSEWIPE, "EllipseWipe"}, // Shape
395
    { animations::TransitionType::BARNDOORWIPE, "BarnDoorWipe"}, // Split
396
    { animations::TransitionType::WATERFALLWIPE, "WaterfallWipe"}, // Diagonal
397
    { animations::TransitionType::MISCSHAPEWIPE, "MiscShapeWipe"},
398
    { animations::TransitionType::ZOOM, "Zoom"}
399
});
400
401
constexpr auto constTransitionSubTypeToString = mapEnumToString<sal_Int16>({
402
    { animations::TransitionSubType::LEFTTORIGHT, "LeftToRight" },
403
    { animations::TransitionSubType::TOPTOBOTTOM, "TopToBottom" },
404
    { animations::TransitionSubType::EIGHTBLADE, "8Blade" },
405
    { animations::TransitionSubType::FOURBLADE, "4Blade" },
406
    { animations::TransitionSubType::THREEBLADE, "3Blade" },
407
    { animations::TransitionSubType::TWOBLADEVERTICAL, "2BladeVertical" },
408
    { animations::TransitionSubType::ONEBLADE, "1Blade" },
409
    { animations::TransitionSubType::FROMTOPLEFT, "FromTopLeft" },
410
    { animations::TransitionSubType::FROMTOPRIGHT, "FromTopRight"},
411
    { animations::TransitionSubType::FROMBOTTOMLEFT, "FromBottomLeft"},
412
    { animations::TransitionSubType::FROMBOTTOMRIGHT, "FromBottomRight"},
413
    { animations::TransitionSubType::VERTICAL, "Vertical"},
414
    { animations::TransitionSubType::HORIZONTAL, "Horizontal"},
415
    { animations::TransitionSubType::DOWN, "Down"},
416
    { animations::TransitionSubType::ACROSS, "Across"},
417
    { animations::TransitionSubType::CORNERSOUT, "CornersOut"},
418
    { animations::TransitionSubType::DIAMOND, "Diamond"},
419
    { animations::TransitionSubType::CIRCLE, "Circle"},
420
    { animations::TransitionSubType::RECTANGLE, "Rectangle"},
421
    { animations::TransitionSubType::CENTERTOP, "CenterTop"},
422
    { animations::TransitionSubType::CROSSFADE, "CrossFade"},
423
    { animations::TransitionSubType::FADEOVERCOLOR, "FadeOverColor"},
424
    { animations::TransitionSubType::FROMLEFT, "FromLeft"},
425
    { animations::TransitionSubType::FROMRIGHT, "FromRight"},
426
    { animations::TransitionSubType::FROMTOP, "FromTop"},
427
    { animations::TransitionSubType::HORIZONTALLEFT, "HorizontalLeft"},
428
    { animations::TransitionSubType::HORIZONTALRIGHT, "HorizontalRight"},
429
    { animations::TransitionSubType::COMBVERTICAL, "CombVertical"},
430
    { animations::TransitionSubType::COMBHORIZONTAL, "CombHorizontal"},
431
    { animations::TransitionSubType::TOPLEFT, "TopLeft"},
432
    { animations::TransitionSubType::TOPRIGHT, "TopRight"},
433
    { animations::TransitionSubType::BOTTOMRIGHT, "BottomRight"},
434
    { animations::TransitionSubType::BOTTOMLEFT, "BottomLeft"},
435
    { animations::TransitionSubType::TOPCENTER, "TopCenter"},
436
    { animations::TransitionSubType::RIGHTCENTER, "RightCenter"},
437
    { animations::TransitionSubType::BOTTOMCENTER, "BottomCenter"},
438
    { animations::TransitionSubType::FANOUTHORIZONTAL, "FanOutHorizontal"},
439
    { animations::TransitionSubType::CORNERSIN, "CornersIn"},
440
    { animations::TransitionSubType::HEART, "Heart"},
441
    { animations::TransitionSubType::ROTATEIN, "RotateIn"},
442
    { animations::TransitionSubType::AIRPLANE, "Airplane"}
443
});
444
445
constexpr auto constAnimationNodeTypeToString = mapEnumToString<sal_Int16>({
446
    { AnimationNodeType::ANIMATE, "Animate" },
447
    { AnimationNodeType::ANIMATECOLOR, "AnimateColor" },
448
    { AnimationNodeType::ANIMATEMOTION, "AnimateMotion" },
449
    { AnimationNodeType::ANIMATEPHYSICS, "Animate" },
450
    { AnimationNodeType::ANIMATETRANSFORM, "AnimateTransform" },
451
    { AnimationNodeType::AUDIO, "Audio" },
452
    { AnimationNodeType::COMMAND, "Command" },
453
    { AnimationNodeType::CUSTOM, "Custom" },
454
    { AnimationNodeType::ITERATE, "Iterate" },
455
    { AnimationNodeType::PAR, "Par" },
456
    { AnimationNodeType::SEQ, "Seq" },
457
    { AnimationNodeType::SET, "Set" },
458
    { AnimationNodeType::TRANSITIONFILTER, "TransitionFilter" },
459
});
460
461
constexpr auto constFillToString = mapEnumToString<sal_Int16>({
462
    { AnimationFill::DEFAULT, "Default" },
463
    { AnimationFill::REMOVE, "Remove" },
464
    { AnimationFill::FREEZE, "Freeze" },
465
    { AnimationFill::HOLD, "Hold" },
466
    { AnimationFill::TRANSITION, "Transition" },
467
    { AnimationFill::AUTO, "Auto" },
468
});
469
470
constexpr auto constRestartToString = mapEnumToString<sal_Int16>({
471
    { AnimationRestart::DEFAULT, "Default" },
472
    { AnimationRestart::ALWAYS, "Always" },
473
    { AnimationRestart::WHEN_NOT_ACTIVE, "WhenNotActive" },
474
    { AnimationRestart::NEVER, "Never" },
475
});
476
477
constexpr auto constEndSyncToString = mapEnumToString<sal_Int16>({
478
    { AnimationEndSync::FIRST, "First" },
479
    { AnimationEndSync::LAST, "Last" },
480
    { AnimationEndSync::ALL, "All" },
481
    { AnimationEndSync::MEDIA, "Media" },
482
});
483
484
constexpr auto constCalcModeToString = mapEnumToString<sal_Int16>({
485
    { AnimationCalcMode::DISCRETE, "Discrete" },
486
    { AnimationCalcMode::LINEAR, "Linear" },
487
    { AnimationCalcMode::PACED, "Paced" },
488
    { AnimationCalcMode::SPLINE, "Spline" },
489
});
490
491
constexpr auto constAdditiveModeToString = mapEnumToString<sal_Int16>({
492
    { AnimationAdditiveMode::BASE, "Base" },
493
    { AnimationAdditiveMode::SUM, "Sum" },
494
    { AnimationAdditiveMode::REPLACE, "Replace" },
495
    { AnimationAdditiveMode::MULTIPLY, "Multiply" },
496
    { AnimationAdditiveMode::NONE, "None" },
497
});
498
499
constexpr auto constEffectPresetClassToString = mapEnumToString<sal_Int16>({
500
    { EffectPresetClass::CUSTOM, "Custom" },
501
    { EffectPresetClass::ENTRANCE, "Entrance" },
502
    { EffectPresetClass::EXIT, "Exit" },
503
    { EffectPresetClass::EMPHASIS, "Emphasis" },
504
    { EffectPresetClass::MOTIONPATH, "MotionPath" },
505
    { EffectPresetClass::OLEACTION, "OleAction" },
506
    { EffectPresetClass::MEDIACALL, "MediaCall" },
507
});
508
509
constexpr auto constEffectNodeTypeToString = mapEnumToString<sal_Int16>({
510
    { EffectNodeType::DEFAULT, "Default" },
511
    { EffectNodeType::ON_CLICK, "OnClick" },
512
    { EffectNodeType::WITH_PREVIOUS, "WithPrevious" },
513
    { EffectNodeType::AFTER_PREVIOUS, "AfterPrevious" },
514
    { EffectNodeType::MAIN_SEQUENCE, "MainSequence" },
515
    { EffectNodeType::TIMING_ROOT, "TimingRoot" },
516
    { EffectNodeType::INTERACTIVE_SEQUENCE, "InteractiveSequence" },
517
});
518
519
constexpr auto constEventTriggerToString = mapEnumToString<sal_Int16>({
520
    { EventTrigger::BEGIN_EVENT, "BeginEvent" },
521
    { EventTrigger::END_EVENT, "EndEvent" },
522
    { EventTrigger::NONE, "None" },
523
    { EventTrigger::ON_BEGIN, "OnBegin" },
524
    { EventTrigger::ON_CLICK, "OnClick" },
525
    { EventTrigger::ON_DBL_CLICK, "OnDblClick" },
526
    { EventTrigger::ON_END, "OnEnd" },
527
    { EventTrigger::ON_MOUSE_ENTER, "OnMouseEnter" },
528
    { EventTrigger::ON_MOUSE_LEAVE, "OnMouseLeave" },
529
    { EventTrigger::ON_NEXT, "OnNext" },
530
    { EventTrigger::ON_PREV, "OnPrev" },
531
    { EventTrigger::ON_STOP_AUDIO, "OnStopAudio" },
532
    { EventTrigger::REPEAT, "Repeat" },
533
});
534
535
constexpr auto constTimingToString = mapEnumToString<Timing>({
536
    { Timing_INDEFINITE, "indefinite" },
537
    { Timing_MEDIA, "media" },
538
});
539
540
constexpr auto constTransformTypeToString = mapEnumToString<sal_Int16>({
541
    { AnimationTransformType::TRANSLATE, "Translate" },
542
    { AnimationTransformType::SCALE, "Scale" },
543
    { AnimationTransformType::ROTATE, "Rotate" },
544
    { AnimationTransformType::SKEWX, "SkewX" },
545
    { AnimationTransformType::SKEWY, "SkewY" },
546
});
547
548
constexpr auto constSubItemToString = mapEnumToString<sal_Int16>({
549
    { ShapeAnimationSubType::AS_WHOLE, "AsWhole" },
550
    { ShapeAnimationSubType::ONLY_BACKGROUND, "OnlyBackground" },
551
    { ShapeAnimationSubType::ONLY_TEXT, "OnlyText" },
552
});
553
554
constexpr auto constIterateTypeToString = mapEnumToString<sal_Int16>({
555
    { TextAnimationType::BY_PARAGRAPH, "ByParagraph" },
556
    { TextAnimationType::BY_WORD, "ByWord" },
557
    { TextAnimationType::BY_LETTER, "ByLetter" },
558
});
559
560
constexpr auto constFillStyleToString = mapEnumToString<drawing::FillStyle>({
561
    { drawing::FillStyle_NONE, "None" },
562
    { drawing::FillStyle_SOLID, "Solid" },
563
    { drawing::FillStyle_BITMAP, "Bitmap" },
564
    { drawing::FillStyle_GRADIENT, "Gradient" },
565
    { drawing::FillStyle_HATCH, "Hatch" },
566
});
567
568
constexpr auto constLineStyleToString = mapEnumToString<drawing::LineStyle>({
569
    { drawing::LineStyle_NONE, "None" },
570
    { drawing::LineStyle_SOLID, "Solid" },
571
    { drawing::LineStyle_DASH, "Dash" },
572
});
573
574
575
constexpr auto constAttributeNameToXMLEnum
576
    = frozen::make_unordered_map<std::string_view, XMLTokenEnum>({
577
        { "X", XML_X },
578
        { "Y", XML_Y },
579
        { "Width", XML_WIDTH },
580
        { "Height", XML_HEIGHT },
581
        { "Rotate", XML_ROTATE },
582
        { "SkewX", XML_SKEWX },
583
        { "FillColor", XML_FILL_COLOR },
584
        { "FillStyle", XML_FILL },
585
        { "LineColor", XML_STROKE_COLOR },
586
        { "LineStyle",XML_STROKE  },
587
        { "CharColor", XML_COLOR },
588
        { "CharRotation", XML_TEXT_ROTATION_ANGLE },
589
        { "CharWeight", XML_FONT_WEIGHT },
590
        { "CharUnderline", XML_TEXT_UNDERLINE },
591
        { "CharFontName", XML_FONT_FAMILY },
592
        { "CharHeight", XML_FONT_SIZE },
593
        { "CharPosture", XML_FONT_STYLE },
594
        { "Visibility", XML_VISIBILITY },
595
        { "Opacity", XML_OPACITY },
596
        { "DimColor", XML_DIM },
597
});
598
599
class AnimationsExporter
600
{
601
public:
602
    AnimationsExporter(::tools::JsonWriter& rWriter,
603
                       const Reference<drawing::XDrawPage>& xDrawPage);
604
    void exportAnimations();
605
    void exportTriggers() const;
606
0
    [[nodiscard]] bool hasEffects() const { return mbHasEffects; }
607
608
private:
609
    void exportNode(const Reference<XAnimationNode>& xNode);
610
    void exportNodeImpl(const Reference<XAnimationNode>& xNode);
611
    void exportContainer(const Reference<XTimeContainer>& xContainer);
612
613
    void exportAnimate(const Reference<XAnimate>& xAnimate);
614
615
    void convertValue(XMLTokenEnum eAttributeName, OStringBuffer& sTmp, const Any& rValue) const;
616
    void convertTiming(OStringBuffer& sTmp, const Any& rValue);
617
618
    void appendTrigger(const css::uno::Any& rTarget, const OString& rTriggerHash);
619
    void exportTriggersImpl(const uno::Reference<drawing::XShapes>& xShapes) const;
620
621
private:
622
    ::tools::JsonWriter& mrWriter;
623
    Reference<drawing::XDrawPage> mxDrawPage;
624
    Reference<XPropertySet> mxPageProps;
625
    Reference<XAnimationNode> mxRootNode;
626
    bool mbHasEffects;
627
    std::unordered_map<SdrObject*, OString> maEventTriggerSet;
628
};
629
630
AnimationsExporter::AnimationsExporter(::tools::JsonWriter& rWriter,
631
                                       const Reference<drawing::XDrawPage>& xDrawPage)
632
0
    : mrWriter(rWriter)
633
0
    , mxDrawPage(xDrawPage)
634
0
    , mbHasEffects(false)
635
0
{
636
0
    if (!mxDrawPage.is())
637
0
        return;
638
639
0
    try
640
0
    {
641
0
        mxPageProps = Reference<XPropertySet>(xDrawPage, UNO_QUERY);
642
0
        if (!mxPageProps.is())
643
0
            return;
644
645
0
        Reference<XAnimationNodeSupplier> xAnimNodeSupplier(mxDrawPage, UNO_QUERY);
646
0
        if (!xAnimNodeSupplier.is())
647
0
            return;
648
649
0
        Reference<XAnimationNode> xRootNode = xAnimNodeSupplier->getAnimationNode();
650
0
        if (xRootNode.is())
651
0
        {
652
            // first check if there are no animations
653
0
            Reference<XEnumerationAccess> xEnumerationAccess(xRootNode, UNO_QUERY_THROW);
654
0
            Reference<XEnumeration> xEnumeration(xEnumerationAccess->createEnumeration(),
655
0
                                                 css::uno::UNO_SET_THROW);
656
0
            if (xEnumeration->hasMoreElements())
657
0
            {
658
                // first child node may be an empty main sequence, check this
659
0
                Reference<XAnimationNode> xMainNode(xEnumeration->nextElement(), UNO_QUERY_THROW);
660
0
                Reference<XEnumerationAccess> xMainEnumerationAccess(xMainNode, UNO_QUERY_THROW);
661
0
                Reference<XEnumeration> xMainEnumeration(
662
0
                    xMainEnumerationAccess->createEnumeration(), css::uno::UNO_SET_THROW);
663
664
                // only export if the main sequence is not empty or if there are additional
665
                // trigger sequences
666
0
                mbHasEffects
667
0
                    = xMainEnumeration->hasMoreElements() || xEnumeration->hasMoreElements();
668
0
            }
669
0
        }
670
0
        if (mbHasEffects)
671
0
            mxRootNode = std::move(xRootNode);
672
0
    }
673
0
    catch (const RuntimeException&)
674
0
    {
675
0
        TOOLS_WARN_EXCEPTION("sd", "unomodel: AnimationsExporter");
676
0
    }
677
0
}
678
679
template <typename EnumT, size_t N>
680
constexpr bool convertEnum(OStringBuffer& rBuffer, EnumT nValue,
681
                           const frozen::unordered_map<EnumT, std::string_view, N>& rMap)
682
0
{
683
0
    auto iterator = rMap.find(nValue);
684
0
    if (iterator == rMap.end())
685
0
        return false;
686
0
    rBuffer.append(iterator->second);
687
0
    return true;
688
0
}
Unexecuted instantiation: unomodel.cxx:bool (anonymous namespace)::convertEnum<short, 13ul>(rtl::OStringBuffer&, short, frozen::unordered_map<short, std::__1::basic_string_view<char, std::__1::char_traits<char> >, 13ul, frozen::elsa<short>, std::__1::equal_to<short> > const&)
Unexecuted instantiation: unomodel.cxx:bool (anonymous namespace)::convertEnum<short, 6ul>(rtl::OStringBuffer&, short, frozen::unordered_map<short, std::__1::basic_string_view<char, std::__1::char_traits<char> >, 6ul, frozen::elsa<short>, std::__1::equal_to<short> > const&)
Unexecuted instantiation: unomodel.cxx:bool (anonymous namespace)::convertEnum<short, 4ul>(rtl::OStringBuffer&, short, frozen::unordered_map<short, std::__1::basic_string_view<char, std::__1::char_traits<char> >, 4ul, frozen::elsa<short>, std::__1::equal_to<short> > const&)
Unexecuted instantiation: unomodel.cxx:bool (anonymous namespace)::convertEnum<short, 7ul>(rtl::OStringBuffer&, short, frozen::unordered_map<short, std::__1::basic_string_view<char, std::__1::char_traits<char> >, 7ul, frozen::elsa<short>, std::__1::equal_to<short> > const&)
Unexecuted instantiation: unomodel.cxx:bool (anonymous namespace)::convertEnum<short, 3ul>(rtl::OStringBuffer&, short, frozen::unordered_map<short, std::__1::basic_string_view<char, std::__1::char_traits<char> >, 3ul, frozen::elsa<short>, std::__1::equal_to<short> > const&)
Unexecuted instantiation: unomodel.cxx:bool (anonymous namespace)::convertEnum<com::sun::star::drawing::FillStyle, 5ul>(rtl::OStringBuffer&, com::sun::star::drawing::FillStyle, frozen::unordered_map<com::sun::star::drawing::FillStyle, std::__1::basic_string_view<char, std::__1::char_traits<char> >, 5ul, frozen::elsa<com::sun::star::drawing::FillStyle>, std::__1::equal_to<com::sun::star::drawing::FillStyle> > const&)
Unexecuted instantiation: unomodel.cxx:bool (anonymous namespace)::convertEnum<com::sun::star::drawing::LineStyle, 3ul>(rtl::OStringBuffer&, com::sun::star::drawing::LineStyle, frozen::unordered_map<com::sun::star::drawing::LineStyle, std::__1::basic_string_view<char, std::__1::char_traits<char> >, 3ul, frozen::elsa<com::sun::star::drawing::LineStyle>, std::__1::equal_to<com::sun::star::drawing::LineStyle> > const&)
Unexecuted instantiation: unomodel.cxx:bool (anonymous namespace)::convertEnum<short, 5ul>(rtl::OStringBuffer&, short, frozen::unordered_map<short, std::__1::basic_string_view<char, std::__1::char_traits<char> >, 5ul, frozen::elsa<short>, std::__1::equal_to<short> > const&)
Unexecuted instantiation: unomodel.cxx:bool (anonymous namespace)::convertEnum<short, 17ul>(rtl::OStringBuffer&, short, frozen::unordered_map<short, std::__1::basic_string_view<char, std::__1::char_traits<char> >, 17ul, frozen::elsa<short>, std::__1::equal_to<short> > const&)
Unexecuted instantiation: unomodel.cxx:bool (anonymous namespace)::convertEnum<short, 41ul>(rtl::OStringBuffer&, short, frozen::unordered_map<short, std::__1::basic_string_view<char, std::__1::char_traits<char> >, 41ul, frozen::elsa<short>, std::__1::equal_to<short> > const&)
689
690
void convertDouble(OStringBuffer& rBuffer, double fValue)
691
0
{
692
0
        ::rtl::math::doubleToStringBuffer(rBuffer, fValue, rtl_math_StringFormat_Automatic,
693
0
                                          rtl_math_DecimalPlaces_Max, '.', true);
694
0
}
695
696
void convertBool(OStringBuffer& rBuffer, bool bValue)
697
0
{
698
0
    rBuffer.append( bValue );
699
0
}
700
701
void convertPath(OStringBuffer& sTmp, const Any& rPath)
702
0
{
703
0
    OUString aStr;
704
0
    rPath >>= aStr;
705
0
    sTmp = aStr.toUtf8();
706
0
}
707
708
void convertColor(OStringBuffer& rBuffer, sal_Int32 nColor)
709
0
{
710
0
    OUStringBuffer aUBuffer;
711
0
    ::sax::Converter::convertColor(aUBuffer, nColor);
712
0
    rBuffer.append(aUBuffer.makeStringAndClear().toUtf8());
713
0
}
714
715
void convertColor(OStringBuffer& rBuffer, const Any& rValue)
716
0
{
717
0
    sal_Int32 nColor = 0;
718
0
    if (rValue >>= nColor)
719
0
    {
720
0
        convertColor(rBuffer, nColor);
721
0
    }
722
0
    else
723
0
    {
724
0
        Sequence<double> aHSL;
725
0
        if ((rValue >>= aHSL) && (aHSL.getLength() == 3))
726
0
        {
727
0
            rBuffer.append("hsl(" + OString::number(aHSL[0]) + ","
728
0
                           + OString::number(aHSL[1] * 100.0) + "%,"
729
0
                           + OString::number(aHSL[2] * 100.0) + "%)");
730
0
        }
731
0
    }
732
0
}
733
734
bool isValidNode(const Reference<XAnimationNode>& xNode)
735
0
{
736
0
    if (xNode.is())
737
0
    {
738
0
        sal_Int16 nNodeType = xNode->getType();
739
0
        auto iterator = constAnimationNodeTypeToString.find(nNodeType);
740
0
        return iterator != constAnimationNodeTypeToString.end();
741
0
    }
742
0
    return false;
743
0
}
744
745
SdrObject* getObjectForShape(uno::Reference<drawing::XShape> const& xShape)
746
0
{
747
0
    if (!xShape.is())
748
0
        return nullptr;
749
0
    SvxShape* pShape = comphelper::getFromUnoTunnel<SvxShape>(xShape);
750
0
    if (pShape)
751
0
        return pShape->GetSdrObject();
752
0
    return nullptr;
753
0
}
754
755
SdrObject* getTargetObject(const uno::Any& aTargetAny)
756
0
{
757
0
    SdrObject* pObject = nullptr;
758
0
    uno::Reference<drawing::XShape> xShape;
759
760
0
    if ((aTargetAny >>= xShape) && xShape.is())
761
0
    {
762
0
        pObject = getObjectForShape(xShape);
763
0
    }
764
0
    else // if target is not a shape - could be paragraph target containing a shape
765
0
    {
766
0
        presentation::ParagraphTarget aParagraphTarget;
767
0
        if ((aTargetAny >>= aParagraphTarget) && aParagraphTarget.Shape.is())
768
0
        {
769
0
            pObject = getObjectForShape(aParagraphTarget.Shape);
770
0
        }
771
0
    }
772
773
0
    return pObject;
774
0
}
775
776
bool isNodeTargetInShapeGroup(const Reference<XAnimationNode>& xNode)
777
0
{
778
0
    Reference<XAnimate> xAnimate(xNode, UNO_QUERY);
779
0
    if (xAnimate.is())
780
0
    {
781
0
        SdrObject* pObject = getTargetObject(xAnimate->getTarget());
782
0
        if (pObject)
783
0
            return pObject->getParentSdrObjectFromSdrObject() != nullptr;
784
0
    }
785
0
    return false;
786
0
}
787
788
bool isNodeTargetAGroup(const Reference<XAnimationNode>& xNode)
789
0
{
790
0
    Reference<XAnimate> xAnimate(xNode, UNO_QUERY);
791
0
    if (xAnimate.is())
792
0
    {
793
0
        SdrObject* pObject = getTargetObject(xAnimate->getTarget());
794
0
        if (pObject)
795
0
            return pObject->getChildrenOfSdrObject() != nullptr;
796
0
    }
797
0
    return false;
798
0
}
799
800
bool isEffectValidForTarget(const Reference<XAnimationNode>& xNode)
801
0
{
802
0
    const Sequence<NamedValue> aUserData(xNode->getUserData());
803
0
    for (const auto& rValue : aUserData)
804
0
    {
805
0
        if (!IsXMLToken(rValue.Name, XML_PRESET_ID))
806
0
            continue;
807
808
0
        OUString aPresetId;
809
0
        if (rValue.Value >>= aPresetId)
810
0
        {
811
0
            if (constNonValidEffectsForGroupSet.find(aPresetId.toUtf8())
812
0
                != constNonValidEffectsForGroupSet.end())
813
0
            {
814
                // it's in the list, so we need to check if the effect target is a group or not
815
0
                Reference<XTimeContainer> xContainer(xNode, UNO_QUERY);
816
0
                if (xContainer.is())
817
0
                {
818
0
                    Reference<XEnumerationAccess> xEnumerationAccess(xContainer, UNO_QUERY);
819
0
                    Reference<XEnumeration> xEnumeration = xEnumerationAccess->createEnumeration();
820
821
                    // target is the same for all children, check the first one
822
0
                    if (xEnumeration.is() && xEnumeration->hasMoreElements())
823
0
                    {
824
0
                        Reference<XAnimationNode> xChildNode(xEnumeration->nextElement(),
825
0
                                                             UNO_QUERY);
826
0
                        if (isNodeTargetAGroup(xChildNode))
827
0
                            return false;
828
0
                    }
829
0
                }
830
0
            }
831
0
        }
832
        // preset id found and checked, we can exit
833
0
        break;
834
0
    }
835
0
    return true;
836
0
}
837
838
void AnimationsExporter::exportAnimations()
839
0
{
840
0
    if (!mxDrawPage.is() || !mxPageProps.is() || !mxRootNode.is() || !hasEffects())
841
0
        return;
842
843
0
    if (isValidNode(mxRootNode))
844
0
    {
845
0
        auto aNode = mrWriter.startNode("root");
846
0
        exportNodeImpl(mxRootNode);
847
0
    }
848
0
}
849
850
void AnimationsExporter::exportNode(const Reference<XAnimationNode>& xNode)
851
0
{
852
    // afaics, when a shape is part of a group any applied effect is ignored
853
    // moreover, some kind of effect, like the ones based on color animations,
854
    // is ignored when applied to a group
855
0
    if (!isValidNode(xNode) || isNodeTargetInShapeGroup(xNode) || !isEffectValidForTarget(xNode))
856
0
        return;
857
0
    auto aStruct = mrWriter.startStruct();
858
0
    exportNodeImpl(xNode);
859
0
}
860
861
void AnimationsExporter::exportNodeImpl(const Reference<XAnimationNode>& xNode)
862
0
{
863
0
    try
864
0
    {
865
0
        std::string sId = GetInterfaceHash(xNode);
866
0
        mrWriter.put("id", sId);
867
0
        sal_Int16 nNodeType = xNode->getType();
868
0
        auto iterator = constAnimationNodeTypeToString.find(nNodeType);
869
0
        assert(iterator != constAnimationNodeTypeToString.end() && "must be previously checked with isValidNode");
870
0
        mrWriter.put("nodeName", iterator->second);
871
872
        // common properties
873
0
        OStringBuffer sTmp;
874
0
        Any aTemp;
875
0
        double fTemp = 0;
876
0
        sal_Int16 nTemp;
877
878
0
        aTemp = xNode->getBegin();
879
0
        if (aTemp.hasValue())
880
0
        {
881
0
            convertTiming(sTmp, aTemp);
882
0
            mrWriter.put("begin", sTmp.makeStringAndClear());
883
0
        }
884
0
        aTemp = xNode->getDuration();
885
0
        if (aTemp.hasValue())
886
0
        {
887
0
            if (aTemp >>= fTemp)
888
0
            {
889
0
                convertDouble(sTmp, fTemp);
890
0
                sTmp.append('s');
891
0
                mrWriter.put("dur", sTmp.makeStringAndClear());
892
0
            }
893
0
            else
894
0
            {
895
0
                Timing eTiming;
896
0
                if (aTemp >>= eTiming)
897
0
                {
898
0
                    mrWriter.put("dur", eTiming == Timing_INDEFINITE ? "indefinite" : "media");
899
0
                }
900
0
            }
901
0
        }
902
0
        aTemp = xNode->getEnd();
903
0
        if (aTemp.hasValue())
904
0
        {
905
0
            convertTiming(sTmp, aTemp);
906
0
            mrWriter.put("end", sTmp.makeStringAndClear());
907
0
        }
908
0
        nTemp = xNode->getFill();
909
0
        if (nTemp != AnimationFill::DEFAULT)
910
0
        {
911
0
            convertEnum(sTmp, nTemp, constFillToString);
912
0
            mrWriter.put("fill", sTmp.makeStringAndClear());
913
0
        }
914
0
        nTemp = xNode->getFillDefault();
915
0
        if (nTemp != AnimationFill::INHERIT)
916
0
        {
917
0
            convertEnum(sTmp, nTemp, constFillToString);
918
0
            mrWriter.put("fillDefault", sTmp.makeStringAndClear());
919
0
        }
920
0
        nTemp = xNode->getRestart();
921
0
        if (nTemp != AnimationRestart::DEFAULT)
922
0
        {
923
0
            convertEnum(sTmp, nTemp, constRestartToString);
924
0
            mrWriter.put("restart", sTmp.makeStringAndClear());
925
0
        }
926
0
        nTemp = xNode->getRestartDefault();
927
0
        if (nTemp != AnimationRestart::INHERIT)
928
0
        {
929
0
            convertEnum(sTmp, nTemp, constRestartToString);
930
0
            mrWriter.put("restartDefault", sTmp.makeStringAndClear());
931
0
        }
932
0
        fTemp = xNode->getAcceleration();
933
0
        if (fTemp != 0.0)
934
0
        {
935
0
            convertDouble(sTmp, fTemp);
936
0
            mrWriter.put("accelerate", sTmp.makeStringAndClear());
937
0
        }
938
0
        fTemp = xNode->getDecelerate();
939
0
        if (fTemp != 0.0)
940
0
        {
941
0
            convertDouble(sTmp, fTemp);
942
0
            mrWriter.put("decelerate", sTmp.makeStringAndClear());
943
0
        }
944
0
        bool bTemp = xNode->getAutoReverse();
945
0
        if (bTemp)
946
0
        {
947
0
            convertBool(sTmp, bTemp);
948
0
            mrWriter.put("autoreverse", sTmp.makeStringAndClear());
949
0
        }
950
0
        aTemp = xNode->getRepeatCount();
951
0
        if (aTemp.hasValue())
952
0
        {
953
0
            Timing eTiming;
954
0
            if ((aTemp >>= eTiming) && (eTiming == Timing_INDEFINITE))
955
0
            {
956
0
                mrWriter.put("repeatCount", "indefinite");
957
0
            }
958
0
            else if (aTemp >>= fTemp)
959
0
            {
960
0
                convertDouble(sTmp, fTemp);
961
0
                mrWriter.put("repeatCount", sTmp.makeStringAndClear());
962
0
            }
963
0
        }
964
0
        aTemp = xNode->getRepeatDuration();
965
0
        if (aTemp.hasValue())
966
0
        {
967
0
            Timing eTiming;
968
0
            if ((aTemp >>= eTiming) && (eTiming == Timing_INDEFINITE))
969
0
            {
970
0
                mrWriter.put("repeatDur", "indefinite");
971
0
            }
972
0
            else if (aTemp >>= fTemp)
973
0
            {
974
0
                convertDouble(sTmp, fTemp);
975
0
                mrWriter.put("repeatDur", sTmp.makeStringAndClear());
976
0
            }
977
0
        }
978
0
        aTemp = xNode->getEndSync();
979
0
        if (aTemp.hasValue() && (aTemp >>= nTemp))
980
0
        {
981
0
            convertEnum(sTmp, nTemp, constEndSyncToString);
982
0
            mrWriter.put("endSync", sTmp.makeStringAndClear());
983
0
        }
984
985
0
        sal_Int16 nContainerNodeType = EffectNodeType::DEFAULT;
986
0
        const Sequence<NamedValue> aUserData(xNode->getUserData());
987
0
        for (const auto& rValue : aUserData)
988
0
        {
989
0
            if (IsXMLToken(rValue.Name, XML_NODE_TYPE))
990
0
            {
991
0
                if ((rValue.Value >>= nContainerNodeType)
992
0
                    && (nContainerNodeType != EffectNodeType::DEFAULT))
993
0
                {
994
0
                    convertEnum(sTmp, nContainerNodeType, constEffectNodeTypeToString);
995
0
                    mrWriter.put("nodeType", sTmp.makeStringAndClear());
996
0
                }
997
0
            }
998
0
            else if (IsXMLToken(rValue.Name, XML_PRESET_ID))
999
0
            {
1000
0
                OUString aPresetId;
1001
0
                if (rValue.Value >>= aPresetId)
1002
0
                {
1003
0
                    mrWriter.put("presetId", aPresetId);
1004
0
                }
1005
0
            }
1006
0
            else if (IsXMLToken(rValue.Name, XML_PRESET_SUB_TYPE))
1007
0
            {
1008
0
                OUString aPresetSubType;
1009
0
                if (rValue.Value >>= aPresetSubType)
1010
0
                {
1011
0
                    mrWriter.put("presetSubType", aPresetSubType);
1012
0
                }
1013
0
            }
1014
0
            else if (IsXMLToken(rValue.Name, XML_PRESET_CLASS))
1015
0
            {
1016
0
                sal_Int16 nEffectPresetClass = sal_uInt16(0);
1017
0
                if (rValue.Value >>= nEffectPresetClass)
1018
0
                {
1019
0
                    convertEnum(sTmp, nEffectPresetClass, constEffectPresetClassToString);
1020
0
                    mrWriter.put("presetClass", sTmp.makeStringAndClear());
1021
0
                }
1022
0
            }
1023
0
            else if (IsXMLToken(rValue.Name, XML_MASTER_ELEMENT))
1024
0
            {
1025
0
                Reference<XInterface> xMaster;
1026
0
                rValue.Value >>= xMaster;
1027
0
                if (xMaster.is())
1028
0
                {
1029
0
                    const std::string aIdentifier(GetInterfaceHash(xMaster));
1030
0
                    if (!aIdentifier.empty())
1031
0
                        mrWriter.put("masterElement", aIdentifier);
1032
0
                }
1033
0
            }
1034
0
            else if (IsXMLToken(rValue.Name, XML_GROUP_ID))
1035
0
            {
1036
0
                sal_Int32 nGroupId = 0;
1037
0
                if (rValue.Value >>= nGroupId)
1038
0
                    mrWriter.put("groupId", nGroupId);
1039
0
            }
1040
0
            else
1041
0
            {
1042
0
                OUString aTmp;
1043
0
                if (rValue.Value >>= aTmp)
1044
0
                    mrWriter.put(rValue.Name, aTmp);
1045
0
            }
1046
0
        }
1047
1048
0
        switch (nNodeType)
1049
0
        {
1050
0
            case AnimationNodeType::PAR:
1051
0
            case AnimationNodeType::SEQ:
1052
0
            case AnimationNodeType::ITERATE:
1053
0
            {
1054
0
                Reference<XTimeContainer> xContainer(xNode, UNO_QUERY_THROW);
1055
0
                exportContainer(xContainer);
1056
0
            }
1057
0
            break;
1058
1059
0
            case AnimationNodeType::ANIMATE:
1060
0
            case AnimationNodeType::SET:
1061
0
            case AnimationNodeType::ANIMATEMOTION:
1062
0
            case AnimationNodeType::ANIMATEPHYSICS:
1063
0
            case AnimationNodeType::ANIMATECOLOR:
1064
0
            case AnimationNodeType::ANIMATETRANSFORM:
1065
0
            case AnimationNodeType::TRANSITIONFILTER:
1066
0
            {
1067
0
                Reference<XAnimate> xAnimate(xNode, UNO_QUERY_THROW);
1068
0
                exportAnimate(xAnimate);
1069
0
            }
1070
0
            break;
1071
0
            case AnimationNodeType::AUDIO:
1072
0
            {
1073
0
                SAL_WARN("sd", "AnimationsExporter::exportNode(): Audio Node not supported.");
1074
0
            }
1075
0
            break;
1076
0
            case AnimationNodeType::COMMAND:
1077
0
            {
1078
0
                SAL_WARN("sd", "AnimationsExporter::exportNode(): Command Node not supported.");
1079
0
            }
1080
0
            break;
1081
0
            default:
1082
0
            {
1083
0
                OSL_FAIL(
1084
0
                    "sd unomodel: AnimationsExporter::exportNode(), invalid AnimationNodeType!");
1085
0
            }
1086
0
        }
1087
0
    }
1088
0
    catch (const RuntimeException&)
1089
0
    {
1090
0
        TOOLS_WARN_EXCEPTION("sd", "unomodel: AnimationsExporter");
1091
0
    }
1092
0
}
1093
1094
void AnimationsExporter::convertTiming(OStringBuffer& sTmp, const Any& rValue)
1095
0
{
1096
0
    if (!rValue.hasValue())
1097
0
        return;
1098
1099
0
    if (auto pSequence = o3tl::tryAccess<Sequence<Any>>(rValue))
1100
0
    {
1101
0
        const sal_Int32 nLength = pSequence->getLength();
1102
0
        sal_Int32 nElement;
1103
0
        const Any* pAny = pSequence->getConstArray();
1104
1105
0
        OStringBuffer sTmp2;
1106
1107
0
        for (nElement = 0; nElement < nLength; nElement++, pAny++)
1108
0
        {
1109
0
            if (!sTmp.isEmpty())
1110
0
                sTmp.append(';');
1111
0
            convertTiming(sTmp2, *pAny);
1112
0
            sTmp.append(sTmp2);
1113
0
            sTmp2.setLength(0);
1114
0
        }
1115
0
    }
1116
0
    else if (auto x = o3tl::tryAccess<double>(rValue))
1117
0
    {
1118
0
        sTmp.append(*x);
1119
0
        sTmp.append('s');
1120
0
    }
1121
0
    else if (auto pTiming = o3tl::tryAccess<Timing>(rValue))
1122
0
    {
1123
0
        const auto svTiming = (*pTiming == Timing_MEDIA)
1124
0
                                  ? constTimingToString.at(Timing_MEDIA)
1125
0
                                  : constTimingToString.at(Timing_INDEFINITE);
1126
0
        sTmp.append(svTiming);
1127
0
    }
1128
0
    else if (auto pEvent = o3tl::tryAccess<Event>(rValue))
1129
0
    {
1130
0
        OStringBuffer sTmp2;
1131
1132
0
        if (pEvent->Trigger != EventTrigger::NONE)
1133
0
        {
1134
0
            if (pEvent->Source.hasValue())
1135
0
            {
1136
0
                OStringBuffer aTriggerBuffer;
1137
                // hash must not start with a digit or on client it is parsed as a time in seconds
1138
0
                aTriggerBuffer.append("id");
1139
0
                anim::convertTarget(aTriggerBuffer, pEvent->Source);
1140
0
                OString sTriggerHash(aTriggerBuffer.makeStringAndClear());
1141
0
                sTmp.append(sTriggerHash);
1142
0
                sTmp.append('.');
1143
0
                appendTrigger(pEvent->Source, sTriggerHash);
1144
0
            }
1145
1146
0
            convertEnum(sTmp2, pEvent->Trigger, constEventTriggerToString);
1147
1148
0
            sTmp.append(sTmp2);
1149
0
            sTmp2.setLength(0);
1150
0
        }
1151
1152
0
        if (pEvent->Offset.hasValue())
1153
0
        {
1154
0
            convertTiming(sTmp2, pEvent->Offset);
1155
1156
0
            if (!sTmp.isEmpty())
1157
0
                sTmp.append('+');
1158
1159
0
            sTmp.append(sTmp2);
1160
0
            sTmp2.setLength(0);
1161
0
        }
1162
0
    }
1163
0
    else
1164
0
    {
1165
0
        OSL_FAIL("sd.unomodel: AnimationsExporter::convertTiming, invalid value type!");
1166
0
    }
1167
0
}
1168
1169
void AnimationsExporter::appendTrigger(const css::uno::Any& rTarget, const OString& rTriggerHash)
1170
0
{
1171
0
    css::uno::Reference<css::uno::XInterface> xRef;
1172
0
    rTarget >>= xRef;
1173
1174
0
    uno::Reference<drawing::XShape> xShape(xRef, uno::UNO_QUERY);
1175
0
    if (!xShape.is())
1176
0
    {
1177
0
        if (auto xParagraphTarget = o3tl::tryAccess<css::presentation::ParagraphTarget>(rTarget))
1178
0
        {
1179
0
            xShape = xParagraphTarget->Shape;
1180
0
        }
1181
0
    }
1182
0
    if (xShape.is())
1183
0
    {
1184
0
        auto* pObject = SdrObject::getSdrObjectFromXShape(xShape);
1185
0
        maEventTriggerSet[pObject] = rTriggerHash;
1186
0
    }
1187
0
}
1188
1189
void AnimationsExporter::exportTriggersImpl(const uno::Reference<drawing::XShapes>& xShapes) const
1190
0
{
1191
0
    if (!xShapes.is())
1192
0
        return;
1193
1194
0
    sal_Int32 nCount = xShapes->getCount();
1195
0
    for (sal_Int32 i = 0; i < nCount; ++i)
1196
0
    {
1197
0
        auto xObject = xShapes->getByIndex(i);
1198
0
        uno::Reference<drawing::XShape> xShape(xObject, uno::UNO_QUERY);
1199
0
        if (!xShape.is())
1200
0
            continue;
1201
1202
0
        auto* pObject = SdrObject::getSdrObjectFromXShape(xShape);
1203
0
        if (maEventTriggerSet.find(pObject) == maEventTriggerSet.end())
1204
0
            continue;
1205
0
        {
1206
0
            auto aShape = mrWriter.startStruct();
1207
0
            mrWriter.put("hash", maEventTriggerSet.at(pObject));
1208
0
            {
1209
0
                auto const& rRectangle = pObject->GetLogicRect();
1210
0
                auto aRectangle
1211
0
                    = o3tl::convert(rRectangle, o3tl::Length::mm100, o3tl::Length::twip);
1212
0
                auto aRect = mrWriter.startNode("bounds");
1213
0
                mrWriter.put("x", aRectangle.Left());
1214
0
                mrWriter.put("y", aRectangle.Top());
1215
0
                mrWriter.put("width", aRectangle.GetWidth());
1216
0
                mrWriter.put("height", aRectangle.GetHeight());
1217
0
            }
1218
0
        }
1219
0
    }
1220
0
}
1221
1222
void AnimationsExporter::exportTriggers() const
1223
0
{
1224
0
    uno::Reference<drawing::XShapes> const xShapes(mxDrawPage, uno::UNO_QUERY_THROW);
1225
0
    if (!xShapes.is())
1226
0
        return;
1227
1228
0
    auto aTriggerList = mrWriter.startArray("triggers");
1229
0
    exportTriggersImpl(xShapes);
1230
0
}
1231
1232
void AnimationsExporter::convertValue(XMLTokenEnum eAttributeName, OStringBuffer& sTmp,
1233
                                      const Any& rValue) const
1234
0
{
1235
0
    if (!rValue.hasValue())
1236
0
        return;
1237
1238
0
    if (auto pValuePair = o3tl::tryAccess<ValuePair>(rValue))
1239
0
    {
1240
0
        OStringBuffer sTmp2;
1241
0
        convertValue(eAttributeName, sTmp, pValuePair->First);
1242
0
        sTmp.append(',');
1243
0
        convertValue(eAttributeName, sTmp2, pValuePair->Second);
1244
0
        sTmp.append(sTmp2);
1245
0
    }
1246
0
    else if (auto pSequence = o3tl::tryAccess<Sequence<Any>>(rValue))
1247
0
    {
1248
0
        const sal_Int32 nLength = pSequence->getLength();
1249
0
        sal_Int32 nElement;
1250
0
        const Any* pAny = pSequence->getConstArray();
1251
1252
0
        OStringBuffer sTmp2;
1253
1254
0
        for (nElement = 0; nElement < nLength; nElement++, pAny++)
1255
0
        {
1256
0
            if (!sTmp.isEmpty())
1257
0
                sTmp.append(';');
1258
0
            convertValue(eAttributeName, sTmp2, *pAny);
1259
0
            sTmp.append(sTmp2);
1260
0
            sTmp2.setLength(0);
1261
0
        }
1262
0
    }
1263
0
    else
1264
0
    {
1265
0
        switch (eAttributeName)
1266
0
        {
1267
0
            case XML_X:
1268
0
            case XML_Y:
1269
0
            case XML_WIDTH:
1270
0
            case XML_HEIGHT:
1271
0
            case XML_ANIMATETRANSFORM:
1272
0
            case XML_ANIMATEMOTION:
1273
0
            case XML_ANIMATEPHYSICS:
1274
0
            {
1275
0
                if (auto sValue = o3tl::tryAccess<OUString>(rValue))
1276
0
                {
1277
0
                    sTmp.append(sValue->toUtf8());
1278
0
                }
1279
0
                else if (auto aValue = o3tl::tryAccess<double>(rValue))
1280
0
                {
1281
0
                    sTmp.append(*aValue);
1282
0
                }
1283
0
                else
1284
0
                {
1285
0
                    OSL_FAIL("sd::AnimationsExporter::convertValue(), invalid value type!");
1286
0
                }
1287
0
                return;
1288
0
            }
1289
0
            case XML_SKEWX:
1290
0
            case XML_ROTATE:
1291
0
            case XML_OPACITY:
1292
0
            case XML_TRANSITIONFILTER:
1293
0
                if (auto aValue = o3tl::tryAccess<double>(rValue))
1294
0
                {
1295
0
                    sTmp.append(*aValue);
1296
0
                }
1297
0
                break;
1298
0
            case XML_TEXT_ROTATION_ANGLE:
1299
0
                if (auto aValue = o3tl::tryAccess<sal_Int16>(rValue))
1300
0
                {
1301
                    // on win and armv7 platforms compiler complains
1302
                    // that append(sal_Int16) is ambiguous
1303
0
                    sTmp.append(static_cast<sal_Int32>(*aValue));
1304
0
                }
1305
0
                break;
1306
0
            case XML_FILL_COLOR:
1307
0
            case XML_STROKE_COLOR:
1308
0
            case XML_DIM:
1309
0
            case XML_COLOR:
1310
0
            {
1311
0
                convertColor(sTmp, rValue);
1312
0
            }
1313
0
            break;
1314
0
            case XML_FILL:
1315
0
                if (auto aValue = o3tl::tryAccess<drawing::FillStyle>(rValue))
1316
0
                {
1317
0
                    convertEnum(sTmp, *aValue, constFillStyleToString);
1318
0
                }
1319
0
                break;
1320
0
            case XML_STROKE:
1321
0
                if (auto aValue = o3tl::tryAccess<drawing::LineStyle>(rValue))
1322
0
                {
1323
0
                    convertEnum(sTmp, *aValue, constLineStyleToString);
1324
0
                }
1325
0
                break;
1326
0
            case XML_FONTSIZE:
1327
0
                if (auto aValue = o3tl::tryAccess<double>(rValue))
1328
0
                {
1329
0
                    double fValue = *aValue * 100;
1330
0
                    fValue += fValue > 0 ? 0.5 : -0.5;
1331
0
                    auto nValue = static_cast<sal_Int32>(fValue);
1332
0
                    sTmp.append(nValue); // percent
1333
0
                }
1334
0
                break;
1335
0
            case XML_FONT_WEIGHT:
1336
0
            case XML_FONT_STYLE:
1337
0
            case XML_TEXT_UNDERLINE:
1338
0
                SAL_WARN("sd", "AnimationsExporter::convertValue(): value type "
1339
0
                                   << GetXMLToken(eAttributeName) << " not supported");
1340
0
                break;
1341
0
            case XML_VISIBILITY:
1342
0
                if (auto aValue = o3tl::tryAccess<bool>(rValue))
1343
0
                {
1344
0
                    OUString sValue = *aValue ? GetXMLToken(XML_VISIBLE) : GetXMLToken(XML_HIDDEN);
1345
0
                    sTmp.append(sValue.toUtf8());
1346
0
                }
1347
0
                break;
1348
0
            default:
1349
0
                OSL_FAIL("unomodel: AnimationsExporter::convertValue(), invalid AttributeName!");
1350
0
        }
1351
0
    }
1352
0
}
1353
1354
void AnimationsExporter::exportContainer(const Reference<XTimeContainer>& xContainer)
1355
0
{
1356
0
    try
1357
0
    {
1358
0
        const sal_Int32 nNodeType = xContainer->getType();
1359
1360
0
        if (nNodeType == AnimationNodeType::ITERATE)
1361
0
        {
1362
0
            OStringBuffer sTmp;
1363
0
            Reference<XIterateContainer> xIter(xContainer, UNO_QUERY_THROW);
1364
1365
0
            Any aTemp(xIter->getTarget());
1366
0
            if (aTemp.hasValue())
1367
0
            {
1368
0
                anim::convertTarget(sTmp, aTemp);
1369
0
                mrWriter.put("targetElement", sTmp.makeStringAndClear());
1370
0
            }
1371
0
            sal_Int16 nTemp = xIter->getSubItem();
1372
0
            if (nTemp)
1373
0
            {
1374
0
                convertEnum(sTmp, nTemp, constSubItemToString);
1375
0
                mrWriter.put("subItem", sTmp.makeStringAndClear());
1376
0
            }
1377
0
            nTemp = xIter->getIterateType();
1378
0
            if (nTemp)
1379
0
            {
1380
0
                convertEnum(sTmp, nTemp, constIterateTypeToString);
1381
0
                mrWriter.put("iterateType", sTmp.makeStringAndClear());
1382
0
            }
1383
0
            double fTemp = xIter->getIterateInterval();
1384
0
            if (fTemp != 0)
1385
0
            {
1386
0
                OUStringBuffer buf;
1387
0
                ::sax::Converter::convertDuration(buf, fTemp / (24 * 60 * 60));
1388
0
                mrWriter.put("iterateInterval", sTmp.makeStringAndClear());
1389
0
            }
1390
0
        }
1391
1392
0
        auto anArray = mrWriter.startArray("children");
1393
1394
0
        Reference<XEnumerationAccess> xEnumerationAccess(xContainer, UNO_QUERY_THROW);
1395
0
        Reference<XEnumeration> xEnumeration(xEnumerationAccess->createEnumeration(),
1396
0
                                             css::uno::UNO_SET_THROW);
1397
0
        while (xEnumeration->hasMoreElements())
1398
0
        {
1399
0
            Reference<XAnimationNode> xChildNode(xEnumeration->nextElement(), UNO_QUERY_THROW);
1400
0
            exportNode(xChildNode);
1401
0
        }
1402
0
    }
1403
0
    catch (const RuntimeException&)
1404
0
    {
1405
0
        TOOLS_WARN_EXCEPTION("sd", "unomodel: AnimationsExporter");
1406
0
    }
1407
0
}
1408
1409
void AnimationsExporter::exportAnimate(const Reference<XAnimate>& xAnimate)
1410
0
{
1411
0
    try
1412
0
    {
1413
0
        const sal_Int16 nNodeType = xAnimate->getType();
1414
1415
0
        OStringBuffer sTmp;
1416
0
        sal_Int16 nTemp;
1417
0
        bool bTemp;
1418
1419
0
        Any aTemp(xAnimate->getTarget());
1420
0
        if (aTemp.hasValue())
1421
0
        {
1422
0
            anim::convertTarget(sTmp, aTemp);
1423
0
            mrWriter.put("targetElement", sTmp.makeStringAndClear());
1424
0
            SdrObject* pObject = getTargetObject(aTemp);
1425
0
            if (pObject)
1426
0
            {
1427
0
                mrWriter.put("title", pObject->GetTitle());
1428
0
            }
1429
0
        }
1430
0
        nTemp = xAnimate->getSubItem();
1431
0
        if (nTemp)
1432
0
        {
1433
0
            convertEnum(sTmp, nTemp, constSubItemToString);
1434
0
            mrWriter.put("subItem", sTmp.makeStringAndClear());
1435
0
        }
1436
1437
0
        XMLTokenEnum eAttributeName = XML_TOKEN_INVALID;
1438
0
        if (nNodeType == AnimationNodeType::TRANSITIONFILTER)
1439
0
        {
1440
0
            eAttributeName = XML_TRANSITIONFILTER;
1441
0
        }
1442
0
        else if (nNodeType == AnimationNodeType::ANIMATETRANSFORM)
1443
0
        {
1444
0
            eAttributeName = XML_ANIMATETRANSFORM;
1445
0
        }
1446
0
        else if (nNodeType == AnimationNodeType::ANIMATEMOTION)
1447
0
        {
1448
0
            eAttributeName = XML_ANIMATEMOTION;
1449
0
        }
1450
0
        else if (nNodeType == AnimationNodeType::ANIMATEPHYSICS)
1451
0
        {
1452
0
            eAttributeName = XML_ANIMATEPHYSICS;
1453
0
        }
1454
0
        else
1455
0
        {
1456
0
            OString sTemp(xAnimate->getAttributeName().toUtf8());
1457
0
            if (!sTemp.isEmpty())
1458
0
            {
1459
0
                auto iterator = constAttributeNameToXMLEnum.find(sTemp);
1460
0
                if (iterator != constAttributeNameToXMLEnum.end())
1461
0
                {
1462
0
                    eAttributeName = iterator->second;
1463
0
                    mrWriter.put("attributeName", sTemp);
1464
0
                }
1465
0
                else
1466
0
                {
1467
0
                    mrWriter.put("attributeName", "invalid");
1468
0
                }
1469
0
            }
1470
0
        }
1471
1472
0
        Sequence<Any> aValues(xAnimate->getValues());
1473
0
        if (aValues.hasElements())
1474
0
        {
1475
0
            aTemp <<= aValues;
1476
0
            convertValue(eAttributeName, sTmp, aTemp);
1477
0
            mrWriter.put("values", sTmp.makeStringAndClear());
1478
0
        }
1479
0
        else
1480
0
        {
1481
0
            aTemp = xAnimate->getFrom();
1482
0
            if (aTemp.hasValue())
1483
0
            {
1484
0
                convertValue(eAttributeName, sTmp, aTemp);
1485
0
                mrWriter.put("from", sTmp.makeStringAndClear());
1486
0
            }
1487
1488
0
            aTemp = xAnimate->getBy();
1489
0
            if (aTemp.hasValue())
1490
0
            {
1491
0
                convertValue(eAttributeName, sTmp, aTemp);
1492
0
                mrWriter.put("by", sTmp.makeStringAndClear());
1493
0
            }
1494
1495
0
            aTemp = xAnimate->getTo();
1496
0
            if (aTemp.hasValue())
1497
0
            {
1498
0
                convertValue(eAttributeName, sTmp, aTemp);
1499
0
                mrWriter.put("to", sTmp.makeStringAndClear());
1500
0
            }
1501
0
        }
1502
1503
0
        if (nNodeType != AnimationNodeType::SET)
1504
0
        {
1505
0
            const Sequence<double> aKeyTimes(xAnimate->getKeyTimes());
1506
0
            if (aKeyTimes.hasElements())
1507
0
            {
1508
0
                for (const auto& rKeyTime : aKeyTimes)
1509
0
                {
1510
0
                    if (!sTmp.isEmpty())
1511
0
                        sTmp.append(';');
1512
1513
0
                    sTmp.append(rKeyTime);
1514
0
                }
1515
0
                mrWriter.put("keyTimes", sTmp.makeStringAndClear());
1516
0
            }
1517
1518
0
            OUString sTemp(xAnimate->getFormula());
1519
0
            if (!sTemp.isEmpty())
1520
0
            {
1521
0
                mrWriter.put("formula", sTemp);
1522
0
            }
1523
1524
0
            if ((nNodeType != AnimationNodeType::TRANSITIONFILTER)
1525
0
                && (nNodeType != AnimationNodeType::AUDIO))
1526
0
            {
1527
                // calcMode  = "discrete | linear | paced | spline"
1528
0
                nTemp = xAnimate->getCalcMode();
1529
0
                if (((nNodeType == AnimationNodeType::ANIMATEMOTION)
1530
0
                     && (nTemp != AnimationCalcMode::PACED))
1531
0
                    || ((nNodeType != AnimationNodeType::ANIMATEMOTION)
1532
0
                        && (nTemp != AnimationCalcMode::LINEAR)))
1533
0
                {
1534
0
                    convertEnum(sTmp, nTemp, constCalcModeToString);
1535
0
                    mrWriter.put("calcMode", sTmp.makeStringAndClear());
1536
0
                }
1537
1538
0
                bTemp = xAnimate->getAccumulate();
1539
0
                if (bTemp)
1540
0
                {
1541
0
                    mrWriter.put("accumulate", "sum");
1542
0
                }
1543
1544
0
                nTemp = xAnimate->getAdditive();
1545
0
                if (nTemp != AnimationAdditiveMode::REPLACE)
1546
0
                {
1547
0
                    convertEnum(sTmp, nTemp, constAdditiveModeToString);
1548
0
                    mrWriter.put("additive", sTmp.makeStringAndClear());
1549
0
                }
1550
0
            }
1551
1552
0
            const Sequence<TimeFilterPair> aTimeFilter(xAnimate->getTimeFilter());
1553
0
            if (aTimeFilter.hasElements())
1554
0
            {
1555
0
                for (const auto& rPair : aTimeFilter)
1556
0
                {
1557
0
                    if (!sTmp.isEmpty())
1558
0
                        sTmp.append(';');
1559
1560
0
                    sTmp.append(OString::number(rPair.Time) + ","
1561
0
                                + OString::number(rPair.Progress));
1562
0
                }
1563
0
                mrWriter.put("keySplines", sTmp.makeStringAndClear());
1564
0
            }
1565
0
        }
1566
1567
0
        switch (nNodeType)
1568
0
        {
1569
0
            case AnimationNodeType::ANIMATEMOTION:
1570
0
            {
1571
0
                Reference<XAnimateMotion> xAnimateMotion(xAnimate, UNO_QUERY_THROW);
1572
1573
0
                aTemp = xAnimateMotion->getPath();
1574
0
                if (aTemp.hasValue())
1575
0
                {
1576
0
                    convertPath(sTmp, aTemp);
1577
0
                    mrWriter.put("path", sTmp.makeStringAndClear());
1578
0
                }
1579
0
            }
1580
0
            break;
1581
0
            case AnimationNodeType::ANIMATEPHYSICS:
1582
0
            {
1583
0
                SAL_WARN(
1584
0
                    "sd",
1585
0
                    "unomodel: AnimationsExporter::exportAnimate(): AnimatePhysics not supported");
1586
0
            }
1587
0
            break;
1588
0
            case AnimationNodeType::ANIMATECOLOR:
1589
0
            {
1590
0
                Reference<XAnimateColor> xAnimateColor(xAnimate, UNO_QUERY_THROW);
1591
1592
0
                nTemp = xAnimateColor->getColorInterpolation();
1593
0
                mrWriter.put("colorInterpolation",
1594
0
                             (nTemp == AnimationColorSpace::RGB) ? "rgb" : "hsl");
1595
1596
0
                bTemp = xAnimateColor->getDirection();
1597
0
                mrWriter.put("colorInterpolationDirection",
1598
0
                             bTemp ? "clockwise" : "counterClockwise");
1599
0
            }
1600
0
            break;
1601
0
            case AnimationNodeType::ANIMATETRANSFORM:
1602
0
            {
1603
0
                mrWriter.put("attributeName", "transform");
1604
1605
0
                Reference<XAnimateTransform> xTransform(xAnimate, UNO_QUERY_THROW);
1606
0
                nTemp = xTransform->getTransformType();
1607
0
                convertEnum(sTmp, nTemp, constTransformTypeToString);
1608
0
                mrWriter.put("transformType", sTmp.makeStringAndClear());
1609
0
            }
1610
0
            break;
1611
0
            case AnimationNodeType::TRANSITIONFILTER:
1612
0
            {
1613
0
                Reference<XTransitionFilter> xTransitionFilter(xAnimate, UNO_QUERY);
1614
1615
0
                sal_Int16 nTransition = xTransitionFilter->getTransition();
1616
0
                convertEnum(sTmp, nTransition, constTransitionTypeToString);
1617
0
                mrWriter.put("transitionType", sTmp.makeStringAndClear());
1618
1619
0
                sal_Int16 nSubtype = xTransitionFilter->getSubtype();
1620
0
                if (nSubtype != TransitionSubType::DEFAULT)
1621
0
                {
1622
0
                    convertEnum(sTmp, nSubtype, constTransitionSubTypeToString);
1623
0
                    mrWriter.put("transitionSubType", sTmp.makeStringAndClear());
1624
0
                }
1625
1626
0
                bTemp = xTransitionFilter->getMode();
1627
0
                if (!bTemp)
1628
0
                    mrWriter.put("transitionMode", "out");
1629
1630
0
                bTemp = xTransitionFilter->getDirection();
1631
0
                if (!bTemp)
1632
0
                    mrWriter.put("transitionDirection", "reverse");
1633
1634
0
                if ((nTransition == TransitionType::FADE)
1635
0
                    && ((nSubtype == TransitionSubType::FADETOCOLOR)
1636
0
                        || (nSubtype == TransitionSubType::FADEFROMCOLOR)))
1637
0
                {
1638
0
                    sal_Int32 nColor = xTransitionFilter->getFadeColor();
1639
0
                    convertColor(sTmp, nColor);
1640
0
                    mrWriter.put("transitionFadeColor", sTmp.makeStringAndClear());
1641
0
                }
1642
0
            }
1643
0
            break;
1644
0
            default:
1645
0
            {
1646
0
                SAL_WARN("sd",
1647
0
                         "unomodel: AnimationsExporter::exportAnimate(): not supported node type: "
1648
0
                             << nNodeType);
1649
0
            }
1650
0
        }
1651
0
    }
1652
0
    catch (const Exception&)
1653
0
    {
1654
0
        TOOLS_WARN_EXCEPTION("sd", "unomodel: AnimationsExporter");
1655
0
    }
1656
0
}
1657
1658
void GetDocStructureSlides(::tools::JsonWriter& rJsonWriter, const SdXImpressDocument* pDoc,
1659
                           const std::map<OUString, OUString>& rArguments)
1660
0
{
1661
0
    auto it = rArguments.find(u"filter"_ustr);
1662
0
    if (it != rArguments.end())
1663
0
    {
1664
        // If filter is present but we are filtering not to slide information
1665
0
        if (!it->second.equals(u"slides"_ustr))
1666
0
            return;
1667
0
    }
1668
1669
0
    sal_uInt16 nPageCount = pDoc->GetDoc()->GetSdPageCount(PageKind::Standard);
1670
0
    sal_uInt16 nMasterPageCount = pDoc->GetDoc()->GetMasterSdPageCount(PageKind::Standard);
1671
1672
0
    rJsonWriter.put("SlideCount", nPageCount);
1673
0
    rJsonWriter.put("MasterSlideCount", nMasterPageCount);
1674
1675
    // write data of every master slide
1676
0
    if (nMasterPageCount > 0)
1677
0
    {
1678
0
        auto aMasterPagesNode = rJsonWriter.startNode("MasterSlides");
1679
0
        for (int nMPId = 0; nMPId < nMasterPageCount; nMPId++)
1680
0
        {
1681
0
            auto aMasterPageNode = rJsonWriter.startNode("MasterSlide " + std::to_string(nMPId));
1682
0
            const OUString& aMName
1683
0
                = pDoc->GetDoc()->GetMasterSdPage(nMPId, PageKind::Standard)->GetName();
1684
0
            rJsonWriter.put("Name", aMName);
1685
0
        }
1686
0
    }
1687
1688
    // write data of every slide
1689
0
    if (nPageCount > 0)
1690
0
    {
1691
0
        auto aPagesNode = rJsonWriter.startNode("Slides");
1692
0
        for (int nPId = 0; nPId < nPageCount; nPId++)
1693
0
        {
1694
0
            auto aPageNode = rJsonWriter.startNode("Slide " + std::to_string(nPId));
1695
0
            SdPage* pPageStandard = pDoc->GetDoc()->GetSdPage(nPId, PageKind::Standard);
1696
1697
            // Slide Name
1698
0
            rJsonWriter.put("SlideName", pPageStandard->GetName());
1699
1700
            // MasterSlide Name
1701
0
            const FmFormPage* pMasterPage
1702
0
                = dynamic_cast<const FmFormPage*>(&pPageStandard->TRG_GetMasterPage());
1703
1704
0
            if (pMasterPage)
1705
0
            {
1706
0
                rJsonWriter.put("MasterSlideName", pMasterPage->GetName());
1707
0
            }
1708
1709
            // Layout id, and name.
1710
0
            AutoLayout nLayout = pPageStandard->GetAutoLayout();
1711
0
            rJsonWriter.put("LayoutId", static_cast<int>(nLayout));
1712
0
            rJsonWriter.put("LayoutName", SdPage::autoLayoutToString(nLayout));
1713
1714
            // Every Objects in the page
1715
0
            int nObjCount = pPageStandard->GetObjCount();
1716
0
            rJsonWriter.put("ObjectCount", nObjCount);
1717
1718
0
            if (nObjCount > 0)
1719
0
            {
1720
0
                auto aObjectsNode = rJsonWriter.startNode("Objects");
1721
0
                for (int nOId = 0; nOId < nObjCount; nOId++)
1722
0
                {
1723
0
                    auto aObjectNode = rJsonWriter.startNode("Objects " + std::to_string(nOId));
1724
0
                    SdrObject* pSdrObj = pPageStandard->GetObj(nOId);
1725
0
                    SdrTextObj* pSdrTxtObj = DynCastSdrTextObj(pSdrObj);
1726
0
                    if (pSdrTxtObj && pSdrTxtObj->HasText())
1727
0
                    {
1728
0
                        sal_Int32 nTextCount = pSdrTxtObj->getTextCount();
1729
0
                        rJsonWriter.put("TextCount", nTextCount);
1730
0
                        if (nTextCount > 0)
1731
0
                        {
1732
0
                            auto aTextsNode = rJsonWriter.startNode("Texts");
1733
0
                            for (int nTId = 0; nTId < nTextCount; nTId++)
1734
0
                            {
1735
0
                                auto aTextNode
1736
0
                                    = rJsonWriter.startNode("Text " + std::to_string(nTId));
1737
0
                                SdrText* pSdrTxt = pSdrTxtObj->getText(nTId);
1738
0
                                OutlinerParaObject* pOutlinerParaObject
1739
0
                                    = pSdrTxt->GetOutlinerParaObject();
1740
1741
0
                                sal_Int32 nParaCount
1742
0
                                    = pOutlinerParaObject->GetTextObject().GetParagraphCount();
1743
1744
0
                                rJsonWriter.put("ParaCount", nParaCount);
1745
0
                                auto aParasNode = rJsonWriter.startArray("Paragraphs");
1746
0
                                for (int nParaId = 0; nParaId < nParaCount; nParaId++)
1747
0
                                {
1748
0
                                    OUString aParaStr(
1749
0
                                        pOutlinerParaObject->GetTextObject().GetText(nParaId));
1750
1751
0
                                    rJsonWriter.putSimpleValue(aParaStr);
1752
0
                                }
1753
0
                            }
1754
0
                        }
1755
0
                    }
1756
0
                }
1757
0
            }
1758
0
        }
1759
0
    }
1760
0
}
1761
1762
} // end anonymous namespace
1763
1764
SdUnoForbiddenCharsTable::SdUnoForbiddenCharsTable( SdrModel* pModel )
1765
69
: SvxUnoForbiddenCharsTable( pModel->GetForbiddenCharsTable() ), mpModel( pModel )
1766
69
{
1767
69
    StartListening( *pModel );
1768
69
}
1769
1770
void SdUnoForbiddenCharsTable::onChange()
1771
0
{
1772
0
    if( mpModel )
1773
0
    {
1774
0
        mpModel->ReformatAllTextObjects();
1775
0
    }
1776
0
}
1777
1778
SdUnoForbiddenCharsTable::~SdUnoForbiddenCharsTable()
1779
69
{
1780
69
    SolarMutexGuard g;
1781
1782
69
    if( mpModel )
1783
69
        EndListening( *mpModel );
1784
69
}
1785
1786
void SdUnoForbiddenCharsTable::Notify( SfxBroadcaster&, const SfxHint& rHint ) noexcept
1787
0
{
1788
0
    if (rHint.GetId() != SfxHintId::ThisIsAnSdrHint)
1789
0
        return;
1790
0
    const SdrHint* pSdrHint = static_cast<const SdrHint*>( &rHint );
1791
0
    if( SdrHintKind::ModelCleared == pSdrHint->GetKind() )
1792
0
    {
1793
0
        mpModel = nullptr;
1794
0
    }
1795
0
}
1796
1797
const sal_uInt16 WID_MODEL_LANGUAGE           =  1;
1798
const sal_uInt16 WID_MODEL_TABSTOP            =  2;
1799
const sal_uInt16 WID_MODEL_VISAREA            =  3;
1800
const sal_uInt16 WID_MODEL_MAPUNIT            =  4;
1801
const sal_uInt16 WID_MODEL_FORBCHARS          =  5;
1802
const sal_uInt16 WID_MODEL_CONTFOCUS          =  6;
1803
const sal_uInt16 WID_MODEL_DSGNMODE           =  7;
1804
const sal_uInt16 WID_MODEL_BASICLIBS          =  8;
1805
const sal_uInt16 WID_MODEL_RUNTIMEUID         =  9;
1806
const sal_uInt16 WID_MODEL_BUILDID            = 10;
1807
const sal_uInt16 WID_MODEL_HASVALIDSIGNATURES = 11;
1808
const sal_uInt16 WID_MODEL_DIALOGLIBS         = 12;
1809
const sal_uInt16 WID_MODEL_FONTS              = 13;
1810
const sal_uInt16 WID_MODEL_INTEROPGRABBAG     = 14;
1811
const sal_uInt16 WID_MODEL_THEME = 15;
1812
const sal_uInt16 WID_MODEL_ALLOWLINKUPDATE    = 16;
1813
const sal_uInt16 WID_MODEL_SLIDESECTIONS      = 17;
1814
const sal_uInt16 WID_MODEL_ANIMATIONSOUNDLINK = 18;
1815
1816
static const SvxItemPropertySet* ImplGetDrawModelPropertySet()
1817
23.7k
{
1818
    // Attention: the first parameter HAS TO BE sorted!!!
1819
23.7k
    const static SfxItemPropertyMapEntry aDrawModelPropertyMap_Impl[] =
1820
23.7k
    {
1821
23.7k
        { u"BuildId"_ustr,                WID_MODEL_BUILDID,            ::cppu::UnoType<OUString>::get(),                      0, 0},
1822
23.7k
        { sUNO_Prop_CharLocale,           WID_MODEL_LANGUAGE,           ::cppu::UnoType<lang::Locale>::get(),                                  0, 0},
1823
23.7k
        { sUNO_Prop_TabStop,              WID_MODEL_TABSTOP,            ::cppu::UnoType<sal_Int32>::get(),                                     0, 0},
1824
23.7k
        { sUNO_Prop_VisibleArea,          WID_MODEL_VISAREA,            ::cppu::UnoType<awt::Rectangle>::get(),                                0, 0},
1825
23.7k
        { sUNO_Prop_MapUnit,              WID_MODEL_MAPUNIT,            ::cppu::UnoType<sal_Int16>::get(),                                     beans::PropertyAttribute::READONLY, 0},
1826
23.7k
        { sUNO_Prop_ForbiddenCharacters,  WID_MODEL_FORBCHARS,          cppu::UnoType<i18n::XForbiddenCharacters>::get(), beans::PropertyAttribute::READONLY, 0},
1827
23.7k
        { sUNO_Prop_AutomContFocus,       WID_MODEL_CONTFOCUS,          cppu::UnoType<bool>::get(),                                                 0, 0},
1828
23.7k
        { sUNO_Prop_ApplyFrmDsgnMode,     WID_MODEL_DSGNMODE,           cppu::UnoType<bool>::get(),                                                 0, 0},
1829
23.7k
        { u"BasicLibraries"_ustr,         WID_MODEL_BASICLIBS,          cppu::UnoType<script::XLibraryContainer>::get(),  beans::PropertyAttribute::READONLY, 0},
1830
23.7k
        { u"DialogLibraries"_ustr,        WID_MODEL_DIALOGLIBS,         cppu::UnoType<script::XLibraryContainer>::get(),  beans::PropertyAttribute::READONLY, 0},
1831
23.7k
        { sUNO_Prop_RuntimeUID,           WID_MODEL_RUNTIMEUID,         ::cppu::UnoType<OUString>::get(),                      beans::PropertyAttribute::READONLY, 0},
1832
23.7k
        { sUNO_Prop_HasValidSignatures,   WID_MODEL_HASVALIDSIGNATURES, ::cppu::UnoType<sal_Bool>::get(),                      beans::PropertyAttribute::READONLY, 0},
1833
23.7k
        { sUNO_Prop_AllowLinkUpdate,      WID_MODEL_ALLOWLINKUPDATE,    ::cppu::UnoType<sal_Bool>::get(),                      beans::PropertyAttribute::READONLY, 0},
1834
23.7k
        { u"Fonts"_ustr,                  WID_MODEL_FONTS,              cppu::UnoType<uno::Sequence<uno::Any>>::get(),                     beans::PropertyAttribute::READONLY, 0},
1835
23.7k
        { sUNO_Prop_InteropGrabBag,       WID_MODEL_INTEROPGRABBAG,     cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(),       0, 0},
1836
23.7k
        { u"SlideSections"_ustr,          WID_MODEL_SLIDESECTIONS,      cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(),       0, 0},
1837
23.7k
        { u"HasExternalAnimationSoundLink"_ustr, WID_MODEL_ANIMATIONSOUNDLINK, cppu::UnoType<bool>::get(),       0, 0},
1838
23.7k
        { sUNO_Prop_Theme,                WID_MODEL_THEME,              cppu::UnoType<util::XTheme>::get(),       0, 0},
1839
23.7k
    };
1840
23.7k
    static SvxItemPropertySet aDrawModelPropertySet_Impl( aDrawModelPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
1841
23.7k
    return &aDrawModelPropertySet_Impl;
1842
23.7k
}
1843
1844
// this ctor is used from the DocShell
1845
SdXImpressDocument::SdXImpressDocument(::sd::DrawDocShell* pShell, bool bClipBoard)
1846
23.7k
:   SfxBaseModel( pShell ),
1847
23.7k
    mpDocShell( pShell ),
1848
23.7k
    mpDoc( pShell ? pShell->GetDoc() : nullptr ),
1849
23.7k
    mbDisposed(false),
1850
23.7k
    mbImpressDoc( pShell && pShell->GetDoc() && pShell->GetDoc()->GetDocumentType() == DocumentType::Impress ),
1851
23.7k
    mbClipBoard( bClipBoard ),
1852
23.7k
    mpPropSet( ImplGetDrawModelPropertySet() ),
1853
23.7k
    mbPaintTextEdit( true )
1854
23.7k
{
1855
23.7k
    if( mpDoc )
1856
23.7k
    {
1857
23.7k
        StartListening( *mpDoc );
1858
23.7k
    }
1859
0
    else
1860
0
    {
1861
0
        OSL_FAIL("DocShell is invalid");
1862
0
    }
1863
23.7k
}
1864
1865
SdXImpressDocument::SdXImpressDocument(SdDrawDocument* pDoc, bool bClipBoard)
1866
0
:   SfxBaseModel( nullptr ),
1867
0
    mpDocShell( nullptr ),
1868
0
    mpDoc( pDoc ),
1869
0
    mbDisposed(false),
1870
0
    mbImpressDoc( pDoc && pDoc->GetDocumentType() == DocumentType::Impress ),
1871
0
    mbClipBoard( bClipBoard ),
1872
0
    mpPropSet( ImplGetDrawModelPropertySet() ),
1873
0
    mbPaintTextEdit( true )
1874
0
{
1875
0
    if( mpDoc )
1876
0
    {
1877
0
        StartListening( *mpDoc );
1878
0
    }
1879
0
    else
1880
0
    {
1881
0
        OSL_FAIL("SdDrawDocument is invalid");
1882
0
    }
1883
0
}
1884
1885
/***********************************************************************
1886
*                                                                      *
1887
***********************************************************************/
1888
SdXImpressDocument::~SdXImpressDocument() noexcept
1889
23.7k
{
1890
23.7k
}
1891
1892
// XInterface
1893
uno::Any SAL_CALL SdXImpressDocument::queryInterface( const uno::Type & rType )
1894
538k
{
1895
538k
    uno::Any aAny;
1896
1897
538k
    if (rType == cppu::UnoType<lang::XServiceInfo>::get())
1898
69
        aAny <<= uno::Reference<lang::XServiceInfo>(this);
1899
538k
    else if (rType == cppu::UnoType<beans::XPropertySet>::get())
1900
12.1k
        aAny <<= uno::Reference<beans::XPropertySet>(this);
1901
526k
    else if (rType == cppu::UnoType<lang::XMultiServiceFactory>::get())
1902
156k
        aAny <<= uno::Reference<lang::XMultiServiceFactory>(this);
1903
370k
    else if (rType == cppu::UnoType<drawing::XDrawPageDuplicator>::get())
1904
0
        aAny <<= uno::Reference<drawing::XDrawPageDuplicator>(this);
1905
370k
    else if (rType == cppu::UnoType<drawing::XLayerSupplier>::get())
1906
47
        aAny <<= uno::Reference<drawing::XLayerSupplier>(this);
1907
370k
    else if (rType == cppu::UnoType<drawing::XMasterPagesSupplier>::get())
1908
2.24k
        aAny <<= uno::Reference<drawing::XMasterPagesSupplier>(this);
1909
367k
    else if (rType == cppu::UnoType<drawing::XDrawPagesSupplier>::get())
1910
12.0k
        aAny <<= uno::Reference<drawing::XDrawPagesSupplier>(this);
1911
355k
    else if (rType == cppu::UnoType<presentation::XHandoutMasterSupplier>::get())
1912
0
        aAny <<= uno::Reference<presentation::XHandoutMasterSupplier>(this);
1913
355k
    else if (rType == cppu::UnoType<document::XLinkTargetSupplier>::get())
1914
0
        aAny <<= uno::Reference<document::XLinkTargetSupplier>(this);
1915
355k
    else if (rType == cppu::UnoType<style::XStyleFamiliesSupplier>::get())
1916
61.5k
        aAny <<= uno::Reference<style::XStyleFamiliesSupplier>(this);
1917
294k
    else if (rType == cppu::UnoType<css::ucb::XAnyCompareFactory>::get())
1918
323
        aAny <<= uno::Reference<css::ucb::XAnyCompareFactory>(this);
1919
294k
    else if (rType == cppu::UnoType<view::XRenderable>::get())
1920
0
        aAny <<= uno::Reference<view::XRenderable>(this);
1921
294k
    else if (mbImpressDoc && rType == cppu::UnoType<presentation::XPresentationSupplier>::get())
1922
778
        aAny <<= uno::Reference< presentation::XPresentationSupplier >(this);
1923
293k
    else if (mbImpressDoc && rType == cppu::UnoType<presentation::XCustomPresentationSupplier>::get())
1924
0
        aAny <<= uno::Reference< presentation::XCustomPresentationSupplier >(this);
1925
293k
    else
1926
293k
        return SfxBaseModel::queryInterface(rType);
1927
1928
245k
    return aAny;
1929
538k
}
1930
1931
void SAL_CALL SdXImpressDocument::acquire() noexcept
1932
1.16M
{
1933
1.16M
    SfxBaseModel::acquire();
1934
1.16M
}
1935
1936
void SAL_CALL SdXImpressDocument::release() noexcept
1937
1.16M
{
1938
1.16M
    if (osl_atomic_decrement( &m_refCount ) != 0)
1939
1.14M
        return;
1940
1941
    // restore reference count:
1942
23.7k
    osl_atomic_increment( &m_refCount );
1943
23.7k
    if(!mbDisposed)
1944
0
    {
1945
0
        try
1946
0
        {
1947
0
            dispose();
1948
0
        }
1949
0
        catch (const uno::RuntimeException&)
1950
0
        {
1951
            // don't break throw ()
1952
0
            TOOLS_WARN_EXCEPTION( "sd", "" );
1953
0
        }
1954
0
    }
1955
23.7k
    SfxBaseModel::release();
1956
23.7k
}
1957
1958
// XUnoTunnel
1959
const css::uno::Sequence< sal_Int8 > & SdXImpressDocument::getUnoTunnelId() noexcept
1960
437k
{
1961
437k
    static const comphelper::UnoIdInit theSdXImpressDocumentUnoTunnelId;
1962
437k
    return theSdXImpressDocumentUnoTunnelId.getSeq();
1963
437k
}
1964
1965
sal_Int64 SAL_CALL SdXImpressDocument::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier )
1966
218k
{
1967
218k
    if (comphelper::isUnoTunnelId<SdrModel>(rIdentifier))
1968
0
        return comphelper::getSomething_cast(mpDoc);
1969
1970
218k
    if (comphelper::isUnoTunnelId<SfxObjectShell>(rIdentifier))
1971
0
        return comphelper::getSomething_cast(mpDocShell);
1972
1973
218k
    return comphelper::getSomethingImpl(rIdentifier, this,
1974
218k
                                        comphelper::FallbackToGetSomethingOf<SfxBaseModel>{});
1975
218k
}
1976
1977
// XTypeProvider
1978
uno::Sequence< uno::Type > SAL_CALL SdXImpressDocument::getTypes(  )
1979
0
{
1980
0
    ::SolarMutexGuard aGuard;
1981
1982
0
    if( !maTypeSequence.hasElements() )
1983
0
    {
1984
0
        uno::Sequence< uno::Type > aTypes( SfxBaseModel::getTypes() );
1985
0
        aTypes = comphelper::concatSequences(aTypes,
1986
0
            uno::Sequence {
1987
0
                cppu::UnoType<beans::XPropertySet>::get(),
1988
0
                cppu::UnoType<lang::XServiceInfo>::get(),
1989
0
                cppu::UnoType<lang::XMultiServiceFactory>::get(),
1990
0
                cppu::UnoType<drawing::XDrawPageDuplicator>::get(),
1991
0
                cppu::UnoType<drawing::XLayerSupplier>::get(),
1992
0
                cppu::UnoType<drawing::XMasterPagesSupplier>::get(),
1993
0
                cppu::UnoType<drawing::XDrawPagesSupplier>::get(),
1994
0
                cppu::UnoType<document::XLinkTargetSupplier>::get(),
1995
0
                cppu::UnoType<style::XStyleFamiliesSupplier>::get(),
1996
0
                cppu::UnoType<css::ucb::XAnyCompareFactory>::get(),
1997
0
                cppu::UnoType<view::XRenderable>::get() });
1998
0
        if( mbImpressDoc )
1999
0
        {
2000
0
            aTypes = comphelper::concatSequences(aTypes,
2001
0
                uno::Sequence {
2002
0
                    cppu::UnoType<presentation::XPresentationSupplier>::get(),
2003
0
                    cppu::UnoType<presentation::XCustomPresentationSupplier>::get(),
2004
0
                    cppu::UnoType<presentation::XHandoutMasterSupplier>::get() });
2005
0
        }
2006
0
        maTypeSequence = std::move(aTypes);
2007
0
    }
2008
2009
0
    return maTypeSequence;
2010
0
}
2011
2012
uno::Sequence< sal_Int8 > SAL_CALL SdXImpressDocument::getImplementationId(  )
2013
0
{
2014
0
    return css::uno::Sequence<sal_Int8>();
2015
0
}
2016
2017
/***********************************************************************
2018
*                                                                      *
2019
***********************************************************************/
2020
void SdXImpressDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
2021
7.09M
{
2022
7.09M
    if( mpDoc )
2023
7.09M
    {
2024
7.09M
        if (rHint.GetId() == SfxHintId::ThisIsAnSdrHint)
2025
1.70M
        {
2026
1.70M
            const SdrHint* pSdrHint = static_cast<const SdrHint*>( &rHint );
2027
1.70M
            if( hasEventListeners() )
2028
0
            {
2029
0
                document::EventObject aEvent;
2030
0
                if( SvxUnoDrawMSFactory::createEvent( mpDoc, pSdrHint, aEvent ) )
2031
0
                    notifyEvent( aEvent );
2032
0
            }
2033
2034
1.70M
            if( pSdrHint->GetKind() == SdrHintKind::ModelCleared )
2035
0
            {
2036
0
                if( mpDoc )
2037
0
                    EndListening( *mpDoc );
2038
0
                mpDoc = nullptr;
2039
0
                mpDocShell = nullptr;
2040
0
            }
2041
1.70M
        }
2042
5.38M
        else
2043
5.38M
        {
2044
            // did our SdDrawDocument just died?
2045
5.38M
            if(rHint.GetId() == SfxHintId::Dying)
2046
0
            {
2047
                // yes, so we ask for a new one
2048
0
                if( mpDocShell )
2049
0
                {
2050
0
                    SdDrawDocument *pNewDoc = mpDocShell->GetDoc();
2051
2052
                    // is there a new one?
2053
0
                    if( pNewDoc != mpDoc )
2054
0
                    {
2055
0
                        mpDoc = pNewDoc;
2056
0
                        if(mpDoc)
2057
0
                            StartListening( *mpDoc );
2058
0
                    }
2059
0
                }
2060
0
            }
2061
5.38M
        }
2062
7.09M
    }
2063
7.09M
    SfxBaseModel::Notify( rBC, rHint );
2064
7.09M
}
2065
2066
void SdXImpressDocument::getCommandValues(::tools::JsonWriter& rJsonWriter, std::string_view rCommand)
2067
0
{
2068
0
    static constexpr OStringLiteral aExtractDocStructure(".uno:ExtractDocumentStructure");
2069
2070
0
    std::map<OUString, OUString> aMap
2071
0
        = SfxLokHelper::parseCommandParameters(OUString::fromUtf8(rCommand));
2072
2073
0
    if (o3tl::starts_with(rCommand, aExtractDocStructure))
2074
0
    {
2075
0
        auto commentsNode = rJsonWriter.startNode("DocStructure");
2076
0
        GetDocStructureSlides(rJsonWriter, this, aMap);
2077
0
    }
2078
0
}
2079
2080
/******************************************************************************
2081
*                                                                             *
2082
******************************************************************************/
2083
SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate )
2084
188k
{
2085
188k
    sal_uInt16 nPageCount = mpDoc->GetSdPageCount( PageKind::Standard );
2086
188k
    SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
2087
188k
    SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background);
2088
188k
    SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects);
2089
2090
188k
    rtl::Reference<SdPage> pStandardPage;
2091
2092
188k
    if( 0 == nPageCount )
2093
0
    {
2094
        // this is only used for clipboard where we only have one page
2095
0
        pStandardPage = mpDoc->AllocSdPage(false);
2096
2097
0
        Size aDefSize(21000, 29700);   // A4 portrait orientation
2098
0
        pStandardPage->SetSize( aDefSize );
2099
0
        mpDoc->InsertPage(pStandardPage.get(), 0);
2100
0
    }
2101
188k
    else
2102
188k
    {
2103
        // here we determine the page after which we should insert
2104
188k
        SdPage* pPreviousStandardPage = mpDoc->GetSdPage( std::min( static_cast<sal_uInt16>(nPageCount - 1), nPage ), PageKind::Standard );
2105
188k
        SdrLayerIDSet aVisibleLayers = pPreviousStandardPage->TRG_GetMasterPageVisibleLayers();
2106
188k
        bool bIsPageBack = aVisibleLayers.IsSet( aBckgrnd );
2107
188k
        bool bIsPageObj = aVisibleLayers.IsSet( aBckgrndObj );
2108
2109
        // AutoLayouts must be ready
2110
188k
        mpDoc->StopWorkStartupDelay();
2111
2112
        /* First we create a standard page and then a notes page. It is
2113
           guaranteed, that after a standard page the corresponding notes page
2114
           follows. */
2115
2116
188k
        sal_uInt16 nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2;
2117
188k
        SdPage* pPreviousNotesPage = static_cast<SdPage*>( mpDoc->GetPage( nStandardPageNum - 1 ) );
2118
188k
        sal_uInt16 nNotesPageNum = nStandardPageNum + 1;
2119
2120
        /**************************************************************
2121
        * standard page
2122
        **************************************************************/
2123
188k
        if( bDuplicate )
2124
0
            pStandardPage = static_cast<SdPage*>( pPreviousStandardPage->CloneSdrPage(*mpDoc).get() );
2125
188k
        else
2126
188k
            pStandardPage = mpDoc->AllocSdPage(false);
2127
2128
188k
        pStandardPage->SetSize( pPreviousStandardPage->GetSize() );
2129
188k
        pStandardPage->SetBorder( pPreviousStandardPage->GetLeftBorder(),
2130
188k
                                    pPreviousStandardPage->GetUpperBorder(),
2131
188k
                                    pPreviousStandardPage->GetRightBorder(),
2132
188k
                                    pPreviousStandardPage->GetLowerBorder() );
2133
188k
        pStandardPage->SetOrientation( pPreviousStandardPage->GetOrientation() );
2134
188k
        pStandardPage->SetName(OUString());
2135
2136
        // insert page after current page
2137
188k
        mpDoc->InsertPage(pStandardPage.get(), nStandardPageNum);
2138
2139
188k
        if( !bDuplicate )
2140
188k
        {
2141
            // use MasterPage of the current page
2142
188k
            pStandardPage->TRG_SetMasterPage(pPreviousStandardPage->TRG_GetMasterPage());
2143
188k
            pStandardPage->SetLayoutName( pPreviousStandardPage->GetLayoutName() );
2144
188k
            pStandardPage->SetAutoLayout(AUTOLAYOUT_NONE, true );
2145
188k
        }
2146
2147
188k
        aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background);
2148
188k
        aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects);
2149
188k
        aVisibleLayers.Set(aBckgrnd, bIsPageBack);
2150
188k
        aVisibleLayers.Set(aBckgrndObj, bIsPageObj);
2151
188k
        pStandardPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
2152
2153
        /**************************************************************
2154
        * notes page
2155
        **************************************************************/
2156
188k
        rtl::Reference<SdPage> pNotesPage;
2157
2158
188k
        if( bDuplicate )
2159
0
            pNotesPage = static_cast<SdPage*>( pPreviousNotesPage->CloneSdrPage(*mpDoc).get() );
2160
188k
        else
2161
188k
            pNotesPage = mpDoc->AllocSdPage(false);
2162
2163
188k
        pNotesPage->SetSize( pPreviousNotesPage->GetSize() );
2164
188k
        pNotesPage->SetBorder( pPreviousNotesPage->GetLeftBorder(),
2165
188k
                                pPreviousNotesPage->GetUpperBorder(),
2166
188k
                                pPreviousNotesPage->GetRightBorder(),
2167
188k
                                pPreviousNotesPage->GetLowerBorder() );
2168
188k
        pNotesPage->SetOrientation( pPreviousNotesPage->GetOrientation() );
2169
188k
        pNotesPage->SetName(OUString());
2170
188k
        pNotesPage->SetPageKind(PageKind::Notes);
2171
2172
        // insert page after current page
2173
188k
        mpDoc->InsertPage(pNotesPage.get(), nNotesPageNum);
2174
2175
188k
        if( !bDuplicate )
2176
188k
        {
2177
            // use MasterPage of the current page
2178
188k
            pNotesPage->TRG_SetMasterPage(pPreviousNotesPage->TRG_GetMasterPage());
2179
188k
            pNotesPage->SetLayoutName( pPreviousNotesPage->GetLayoutName() );
2180
188k
            pNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true );
2181
188k
        }
2182
188k
    }
2183
2184
188k
    SetModified();
2185
2186
188k
    return pStandardPage.get();
2187
188k
}
2188
2189
void SdXImpressDocument::SetModified() noexcept
2190
1.59M
{
2191
1.59M
    if( mpDoc )
2192
1.59M
        mpDoc->SetChanged();
2193
1.59M
}
2194
2195
// XModel
2196
void SAL_CALL SdXImpressDocument::lockControllers(  )
2197
5.13k
{
2198
5.13k
    ::SolarMutexGuard aGuard;
2199
2200
5.13k
    if( nullptr == mpDoc )
2201
0
        throw lang::DisposedException();
2202
2203
5.13k
    mpDoc->setLock(true);
2204
5.13k
}
2205
2206
void SAL_CALL SdXImpressDocument::unlockControllers(  )
2207
5.13k
{
2208
5.13k
    ::SolarMutexGuard aGuard;
2209
2210
5.13k
    if( nullptr == mpDoc )
2211
0
        throw lang::DisposedException();
2212
2213
5.13k
    if( mpDoc->isLocked() )
2214
5.08k
    {
2215
5.08k
        mpDoc->setLock(false);
2216
5.08k
    }
2217
5.13k
}
2218
2219
sal_Bool SAL_CALL SdXImpressDocument::hasControllersLocked(  )
2220
2.24k
{
2221
2.24k
    ::SolarMutexGuard aGuard;
2222
2223
2.24k
    if( nullptr == mpDoc )
2224
0
        throw lang::DisposedException();
2225
2226
2.24k
    return mpDoc->isLocked();
2227
2.24k
}
2228
2229
uno::Reference < container::XIndexAccess > SAL_CALL SdXImpressDocument::getViewData()
2230
69
{
2231
69
    ::SolarMutexGuard aGuard;
2232
2233
69
    if( nullptr == mpDoc )
2234
0
        throw lang::DisposedException();
2235
2236
69
    uno::Reference < container::XIndexAccess > xRet( SfxBaseModel::getViewData() );
2237
2238
69
    if( !xRet.is() )
2239
69
    {
2240
69
        const std::vector<std::unique_ptr<sd::FrameView>> &rList = mpDoc->GetFrameViewList();
2241
2242
69
        if( !rList.empty() )
2243
0
        {
2244
0
            xRet = new comphelper::IndexedPropertyValuesContainer();
2245
2246
0
            uno::Reference < container::XIndexContainer > xCont( xRet, uno::UNO_QUERY );
2247
0
            DBG_ASSERT( xCont.is(), "SdXImpressDocument::getViewData() failed for OLE object" );
2248
0
            if( xCont.is() )
2249
0
            {
2250
0
                for( sal_uInt32 i = 0, n = rList.size(); i < n; i++ )
2251
0
                {
2252
0
                    ::sd::FrameView* pFrameView = rList[ i ].get();
2253
2254
0
                    uno::Sequence< beans::PropertyValue > aSeq;
2255
0
                    pFrameView->WriteUserDataSequence( aSeq );
2256
0
                    xCont->insertByIndex( i, uno::Any( aSeq ) );
2257
0
                }
2258
0
            }
2259
0
        }
2260
69
    }
2261
2262
69
    return xRet;
2263
69
}
2264
2265
void SAL_CALL SdXImpressDocument::setViewData( const uno::Reference < container::XIndexAccess >& xData )
2266
69
{
2267
69
    ::SolarMutexGuard aGuard;
2268
2269
69
    if( nullptr == mpDoc )
2270
0
        throw lang::DisposedException();
2271
2272
69
    SfxBaseModel::setViewData( xData );
2273
69
    if( !(mpDocShell && (mpDocShell->GetCreateMode() == SfxObjectCreateMode::EMBEDDED) && xData.is()) )
2274
69
        return;
2275
2276
0
    const sal_Int32 nCount = xData->getCount();
2277
2278
0
    std::vector<std::unique_ptr<sd::FrameView>> &rViews = mpDoc->GetFrameViewList();
2279
2280
0
    rViews.clear();
2281
2282
0
    uno::Sequence< beans::PropertyValue > aSeq;
2283
0
    for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
2284
0
    {
2285
0
        if( xData->getByIndex( nIndex ) >>= aSeq )
2286
0
        {
2287
0
            std::unique_ptr<::sd::FrameView> pFrameView(new ::sd::FrameView( mpDoc ));
2288
0
            pFrameView->ReadUserDataSequence( aSeq );
2289
0
            rViews.push_back( std::move(pFrameView) );
2290
0
        }
2291
0
    }
2292
0
}
2293
2294
// XDrawPageDuplicator
2295
uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::duplicate( const uno::Reference< drawing::XDrawPage >& xPage )
2296
0
{
2297
0
    ::SolarMutexGuard aGuard;
2298
2299
0
    if( nullptr == mpDoc )
2300
0
        throw lang::DisposedException();
2301
2302
    // get pPage from xPage and determine the Id (nPos ) afterwards
2303
0
    SvxDrawPage* pSvxPage = comphelper::getFromUnoTunnel<SvxDrawPage>( xPage );
2304
0
    if( pSvxPage )
2305
0
    {
2306
0
        SdPage* pPage = static_cast<SdPage*>( pSvxPage->GetSdrPage() );
2307
0
        sal_uInt16 nPos = pPage->GetPageNum();
2308
0
        nPos = ( nPos - 1 ) / 2;
2309
0
        pPage = InsertSdPage( nPos, true );
2310
0
        if( pPage )
2311
0
        {
2312
0
            uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
2313
0
            return xDrawPage;
2314
0
        }
2315
0
    }
2316
2317
0
    uno::Reference< drawing::XDrawPage > xDrawPage;
2318
0
    return xDrawPage;
2319
0
}
2320
2321
// XDrawPagesSupplier
2322
uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getDrawPages()
2323
12.0k
{
2324
12.0k
    ::SolarMutexGuard aGuard;
2325
2326
12.0k
    return getSdDrawPages();
2327
12.0k
}
2328
2329
rtl::Reference< SdDrawPagesAccess > SdXImpressDocument::getSdDrawPages()
2330
12.0k
{
2331
12.0k
    if( nullptr == mpDoc )
2332
0
        throw lang::DisposedException();
2333
2334
12.0k
    rtl::Reference< SdDrawPagesAccess > xDrawPages( mxDrawPagesAccess );
2335
2336
12.0k
    if( !xDrawPages.is() )
2337
12.0k
    {
2338
12.0k
        initializeDocument();
2339
12.0k
        xDrawPages = new SdDrawPagesAccess(*this);
2340
12.0k
        mxDrawPagesAccess = xDrawPages.get();
2341
12.0k
    }
2342
2343
12.0k
    return xDrawPages;
2344
12.0k
}
2345
2346
// XMasterPagesSupplier
2347
uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getMasterPages()
2348
2.24k
{
2349
2.24k
    ::SolarMutexGuard aGuard;
2350
2351
2.24k
    if( nullptr == mpDoc )
2352
0
        throw lang::DisposedException();
2353
2354
2.24k
    rtl::Reference< SdMasterPagesAccess > xMasterPages( mxMasterPagesAccess );
2355
2356
2.24k
    if( !xMasterPages.is() )
2357
2.24k
    {
2358
2.24k
        if ( !hasControllersLocked() )
2359
69
            initializeDocument();
2360
2.24k
        xMasterPages = new SdMasterPagesAccess(*this);
2361
2.24k
        mxMasterPagesAccess = xMasterPages.get();
2362
2.24k
    }
2363
2364
2.24k
    return xMasterPages;
2365
2.24k
}
2366
2367
// XLayerManagerSupplier
2368
uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLayerManager(  )
2369
47
{
2370
47
    ::SolarMutexGuard aGuard;
2371
2372
47
    if( nullptr == mpDoc )
2373
0
        throw lang::DisposedException();
2374
2375
47
    rtl::Reference< SdLayerManager >  xLayerManager( mxLayerManager );
2376
2377
47
    if( !xLayerManager.is() )
2378
47
    {
2379
47
        xLayerManager = new SdLayerManager(*this);
2380
47
        mxLayerManager = xLayerManager.get();
2381
47
    }
2382
2383
47
    return xLayerManager;
2384
47
}
2385
2386
// XCustomPresentationSupplier
2387
uno::Reference< container::XNameContainer > SAL_CALL SdXImpressDocument::getCustomPresentations()
2388
0
{
2389
0
    ::SolarMutexGuard aGuard;
2390
2391
0
    if( nullptr == mpDoc )
2392
0
        throw lang::DisposedException();
2393
2394
0
    rtl::Reference< SdXCustomPresentationAccess >  xCustomPres( mxCustomPresentationAccess );
2395
2396
0
    if( !xCustomPres.is() )
2397
0
    {
2398
0
        xCustomPres = new SdXCustomPresentationAccess(*this);
2399
0
        mxCustomPresentationAccess = xCustomPres.get();
2400
0
    }
2401
2402
0
    return xCustomPres;
2403
0
}
2404
2405
// XPresentationSupplier and getter for concrete SlideShow
2406
2407
rtl::Reference<sd::SlideShow> SdXImpressDocument::getSlideShow()
2408
778
{
2409
778
    ::SolarMutexGuard aGuard;
2410
2411
778
    if( nullptr == mpDoc )
2412
0
        throw lang::DisposedException();
2413
2414
778
    return mpDoc->getSlideShow();
2415
778
}
2416
2417
uno::Reference<presentation::XPresentation> SAL_CALL SdXImpressDocument::getPresentation()
2418
778
{
2419
778
    return getSlideShow();
2420
778
}
2421
2422
// XHandoutMasterSupplier
2423
uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::getHandoutMasterPage()
2424
0
{
2425
0
    ::SolarMutexGuard aGuard;
2426
2427
0
    if( nullptr == mpDoc )
2428
0
        throw lang::DisposedException();
2429
2430
0
    uno::Reference< drawing::XDrawPage > xPage;
2431
2432
0
    initializeDocument();
2433
0
    SdPage* pPage = mpDoc->GetMasterSdPage(0, PageKind::Handout);
2434
0
    if (pPage)
2435
0
        xPage.set(pPage->getUnoPage(), uno::UNO_QUERY);
2436
0
    return xPage;
2437
0
}
2438
2439
// XMultiServiceFactory ( SvxFmMSFactory )
2440
2441
css::uno::Reference<css::uno::XInterface> SdXImpressDocument::create(
2442
    OUString const & aServiceSpecifier, OUString const & referer)
2443
68.9k
{
2444
68.9k
    ::SolarMutexGuard aGuard;
2445
2446
68.9k
    if( nullptr == mpDoc )
2447
0
        throw lang::DisposedException();
2448
2449
68.9k
    if( aServiceSpecifier == "com.sun.star.drawing.DashTable" )
2450
47
    {
2451
47
        if( !mxDashTable.is() )
2452
47
            mxDashTable = SvxUnoDashTable_createInstance( mpDoc );
2453
2454
47
        return mxDashTable;
2455
47
    }
2456
68.8k
    if( aServiceSpecifier == "com.sun.star.drawing.GradientTable" )
2457
77
    {
2458
77
        if( !mxGradientTable.is() )
2459
77
            mxGradientTable = SvxUnoGradientTable_createInstance( mpDoc );
2460
2461
77
        return mxGradientTable;
2462
77
    }
2463
68.8k
    if( aServiceSpecifier == "com.sun.star.drawing.HatchTable" )
2464
47
    {
2465
47
        if( !mxHatchTable.is() )
2466
47
            mxHatchTable = SvxUnoHatchTable_createInstance( mpDoc );
2467
2468
47
        return mxHatchTable;
2469
47
    }
2470
68.7k
    if( aServiceSpecifier == "com.sun.star.drawing.BitmapTable" )
2471
60
    {
2472
60
        if( !mxBitmapTable.is() )
2473
60
            mxBitmapTable = SvxUnoBitmapTable_createInstance( mpDoc );
2474
2475
60
        return mxBitmapTable;
2476
60
    }
2477
68.6k
    if( aServiceSpecifier == "com.sun.star.drawing.TransparencyGradientTable" )
2478
53
    {
2479
53
        if( !mxTransGradientTable.is() )
2480
53
            mxTransGradientTable = SvxUnoTransGradientTable_createInstance( mpDoc );
2481
2482
53
        return mxTransGradientTable;
2483
53
    }
2484
68.6k
    if( aServiceSpecifier == "com.sun.star.drawing.MarkerTable" )
2485
104
    {
2486
104
        if( !mxMarkerTable.is() )
2487
104
            mxMarkerTable = SvxUnoMarkerTable_createInstance( mpDoc );
2488
2489
104
        return mxMarkerTable;
2490
104
    }
2491
68.5k
    if( aServiceSpecifier == "com.sun.star.text.NumberingRules" )
2492
0
    {
2493
0
        return uno::Reference< uno::XInterface >( SvxCreateNumRule( mpDoc ), uno::UNO_QUERY );
2494
0
    }
2495
68.5k
    if( aServiceSpecifier == "com.sun.star.drawing.Background" )
2496
0
    {
2497
0
        return uno::Reference<uno::XInterface>(cppu::getXWeak(new SdUnoPageBackground(mpDoc)));
2498
0
    }
2499
2500
68.5k
    if( aServiceSpecifier == "com.sun.star.drawing.Defaults" )
2501
47
    {
2502
47
        if( !mxDrawingPool.is() )
2503
47
            mxDrawingPool = SdUnoCreatePool( mpDoc );
2504
2505
47
        return mxDrawingPool;
2506
2507
47
    }
2508
2509
68.4k
    if ( aServiceSpecifier == sUNO_Service_ImageMapRectangleObject )
2510
0
    {
2511
0
        return SvUnoImageMapRectangleObject_createInstance( ImplGetSupportedMacroItems() );
2512
0
    }
2513
2514
68.4k
    if ( aServiceSpecifier == sUNO_Service_ImageMapCircleObject )
2515
0
    {
2516
0
        return SvUnoImageMapCircleObject_createInstance( ImplGetSupportedMacroItems() );
2517
0
    }
2518
2519
68.4k
    if ( aServiceSpecifier == sUNO_Service_ImageMapPolygonObject )
2520
0
    {
2521
0
        return SvUnoImageMapPolygonObject_createInstance( ImplGetSupportedMacroItems() );
2522
0
    }
2523
2524
68.4k
    if( aServiceSpecifier == "com.sun.star.document.Settings" ||
2525
68.3k
        ( !mbImpressDoc && ( aServiceSpecifier == "com.sun.star.drawing.DocumentSettings" ) ) ||
2526
68.3k
        (  mbImpressDoc && ( aServiceSpecifier == "com.sun.star.presentation.DocumentSettings" ) ) )
2527
138
    {
2528
138
        return sd::DocumentSettings_createInstance( this );
2529
138
    }
2530
2531
68.3k
    if( aServiceSpecifier == "com.sun.star.text.TextField.DateTime" ||
2532
64.3k
        aServiceSpecifier == "com.sun.star.text.textfield.DateTime" )
2533
4.02k
    {
2534
4.02k
        return cppu::getXWeak(new SvxUnoTextField(text::textfield::Type::DATE));
2535
4.02k
    }
2536
2537
64.3k
    if( aServiceSpecifier == "com.sun.star.presentation.TextField.Header" ||
2538
64.3k
        aServiceSpecifier == "com.sun.star.presentation.textfield.Header" )
2539
0
    {
2540
0
        return cppu::getXWeak(new SvxUnoTextField(text::textfield::Type::PRESENTATION_HEADER));
2541
0
    }
2542
2543
64.3k
    if( aServiceSpecifier == "com.sun.star.presentation.TextField.Footer" ||
2544
60.1k
        aServiceSpecifier == "com.sun.star.presentation.textfield.Footer" )
2545
4.18k
    {
2546
4.18k
        return cppu::getXWeak(new SvxUnoTextField(text::textfield::Type::PRESENTATION_FOOTER));
2547
4.18k
    }
2548
2549
60.1k
    if( aServiceSpecifier == "com.sun.star.presentation.TextField.DateTime" ||
2550
55.9k
        aServiceSpecifier == "com.sun.star.presentation.textfield.DateTime" )
2551
4.18k
    {
2552
4.18k
        return cppu::getXWeak(new SvxUnoTextField(text::textfield::Type::PRESENTATION_DATE_TIME));
2553
4.18k
    }
2554
2555
55.9k
    if( aServiceSpecifier == "com.sun.star.text.TextField.PageName" ||
2556
55.9k
        aServiceSpecifier == "com.sun.star.text.textfield.PageName" )
2557
0
    {
2558
0
        return cppu::getXWeak(new SvxUnoTextField(text::textfield::Type::PAGE_NAME));
2559
0
    }
2560
2561
55.9k
    if (aServiceSpecifier == "com.sun.star.text.TextField.DocInfo.Custom" ||
2562
55.9k
        aServiceSpecifier == "com.sun.star.text.textfield.DocInfo.Custom")
2563
0
    {
2564
0
        return cppu::getXWeak(new SvxUnoTextField(text::textfield::Type::DOCINFO_CUSTOM));
2565
0
    }
2566
2567
55.9k
    if( aServiceSpecifier == "com.sun.star.xml.NamespaceMap" )
2568
69
    {
2569
69
        static const sal_uInt16 aWhichIds[] = { SDRATTR_XMLATTRIBUTES, EE_CHAR_XMLATTRIBS, EE_PARA_XMLATTRIBS, 0 };
2570
2571
69
        return svx::NamespaceMap_createInstance( aWhichIds, &mpDoc->GetItemPool() );
2572
69
    }
2573
2574
    // Support creation of GraphicStorageHandler and EmbeddedObjectResolver
2575
55.8k
    if (aServiceSpecifier == "com.sun.star.document.ExportGraphicStorageHandler")
2576
0
    {
2577
0
        return cppu::getXWeak(new SvXMLGraphicHelper(SvXMLGraphicHelperMode::Write));
2578
0
    }
2579
2580
55.8k
    if (aServiceSpecifier == "com.sun.star.document.ImportGraphicStorageHandler")
2581
0
    {
2582
0
        return cppu::getXWeak(new SvXMLGraphicHelper(SvXMLGraphicHelperMode::Read));
2583
0
    }
2584
2585
55.8k
    if( aServiceSpecifier == "com.sun.star.document.ExportEmbeddedObjectResolver" )
2586
69
    {
2587
69
        comphelper::IEmbeddedHelper* pPersist = mpDoc->GetPersist();
2588
69
        if( nullptr == pPersist )
2589
0
            throw lang::DisposedException();
2590
2591
69
        return cppu::getXWeak(new SvXMLEmbeddedObjectHelper( *pPersist, SvXMLEmbeddedObjectHelperMode::Write ));
2592
69
    }
2593
2594
55.8k
    if( aServiceSpecifier == "com.sun.star.document.ImportEmbeddedObjectResolver" )
2595
0
    {
2596
0
        comphelper::IEmbeddedHelper* pPersist = mpDoc->GetPersist();
2597
0
        if( nullptr == pPersist )
2598
0
            throw lang::DisposedException();
2599
2600
0
        return cppu::getXWeak(new SvXMLEmbeddedObjectHelper( *pPersist, SvXMLEmbeddedObjectHelperMode::Read ));
2601
0
    }
2602
2603
55.8k
    uno::Reference< uno::XInterface > xRet;
2604
2605
55.8k
    if (std::u16string_view aType; aServiceSpecifier.startsWith("com.sun.star.presentation.", &aType))
2606
36.0k
    {
2607
36.0k
        SdrObjKind nType;
2608
        // create a shape wrapper
2609
36.0k
        if( o3tl::starts_with(aType, u"TitleTextShape" ) )
2610
8.10k
        {
2611
8.10k
            nType = SdrObjKind::Text;
2612
8.10k
        }
2613
27.9k
        else if( o3tl::starts_with(aType, u"OutlinerShape" ) )
2614
13.5k
        {
2615
13.5k
            nType = SdrObjKind::Text;
2616
13.5k
        }
2617
14.4k
        else if( o3tl::starts_with(aType, u"SubtitleShape" ) )
2618
1.31k
        {
2619
1.31k
            nType = SdrObjKind::Text;
2620
1.31k
        }
2621
13.0k
        else if( o3tl::starts_with(aType, u"GraphicObjectShape" ) )
2622
393
        {
2623
393
            nType = SdrObjKind::Graphic;
2624
393
        }
2625
12.6k
        else if( o3tl::starts_with(aType, u"PageShape" ) )
2626
25
        {
2627
25
            nType = SdrObjKind::Page;
2628
25
        }
2629
12.6k
        else if( o3tl::starts_with(aType, u"OLE2Shape" ) )
2630
0
        {
2631
0
            nType = SdrObjKind::OLE2;
2632
0
        }
2633
12.6k
        else if( o3tl::starts_with(aType, u"ChartShape" ) )
2634
0
        {
2635
0
            nType = SdrObjKind::OLE2;
2636
0
        }
2637
12.6k
        else if( o3tl::starts_with(aType, u"CalcShape" ) )
2638
0
        {
2639
0
            nType = SdrObjKind::OLE2;
2640
0
        }
2641
12.6k
        else if( o3tl::starts_with(aType, u"TableShape" ) )
2642
0
        {
2643
0
            nType = SdrObjKind::Table;
2644
0
        }
2645
12.6k
        else if( o3tl::starts_with(aType, u"OrgChartShape" ) )
2646
0
        {
2647
0
            nType = SdrObjKind::OLE2;
2648
0
        }
2649
12.6k
        else if( o3tl::starts_with(aType, u"NotesShape" ) )
2650
85
        {
2651
85
            nType = SdrObjKind::Text;
2652
85
        }
2653
12.5k
        else if( o3tl::starts_with(aType, u"HandoutShape" ) )
2654
0
        {
2655
0
            nType = SdrObjKind::Page;
2656
0
        }
2657
12.5k
        else if( o3tl::starts_with(aType, u"FooterShape" ) )
2658
4.18k
        {
2659
4.18k
            nType = SdrObjKind::Text;
2660
4.18k
        }
2661
8.40k
        else if( o3tl::starts_with(aType, u"HeaderShape" ) )
2662
0
        {
2663
0
            nType = SdrObjKind::Text;
2664
0
        }
2665
8.40k
        else if( o3tl::starts_with(aType, u"SlideNumberShape" ) )
2666
4.21k
        {
2667
4.21k
            nType = SdrObjKind::Text;
2668
4.21k
        }
2669
4.18k
        else if( o3tl::starts_with(aType, u"DateTimeShape" ) )
2670
4.18k
        {
2671
4.18k
            nType = SdrObjKind::Text;
2672
4.18k
        }
2673
0
        else if( o3tl::starts_with(aType, u"MediaShape" ) )
2674
0
        {
2675
0
            nType = SdrObjKind::Media;
2676
0
        }
2677
0
        else
2678
0
        {
2679
0
            throw lang::ServiceNotRegisteredException();
2680
0
        }
2681
2682
        // create the API wrapper
2683
36.0k
        rtl::Reference<SvxShape> pShape = CreateSvxShapeByTypeAndInventor(nType, SdrInventor::Default, referer);
2684
2685
        // set shape type
2686
36.0k
        if( pShape && !mbClipBoard )
2687
36.0k
            pShape->SetShapeType(aServiceSpecifier);
2688
2689
36.0k
        xRet = cppu::getXWeak(pShape.get());
2690
36.0k
    }
2691
19.7k
    else if ( aServiceSpecifier == "com.sun.star.drawing.TableShape" )
2692
116
    {
2693
116
        rtl::Reference<SvxShape> pShape = CreateSvxShapeByTypeAndInventor( SdrObjKind::Table, SdrInventor::Default, referer );
2694
116
        if( pShape && !mbClipBoard )
2695
116
            pShape->SetShapeType(aServiceSpecifier);
2696
2697
116
        xRet = cppu::getXWeak(pShape.get());
2698
116
    }
2699
19.6k
    else
2700
19.6k
    {
2701
19.6k
        xRet = SvxFmMSFactory::createInstance( aServiceSpecifier );
2702
19.6k
    }
2703
2704
55.8k
    uno::Reference< drawing::XShape > xShape( xRet, uno::UNO_QUERY );
2705
55.8k
    SvxShape* pShape = xShape.is() ? comphelper::getFromUnoTunnel<SvxShape>(xShape) : nullptr;
2706
55.8k
    if (pShape)
2707
50.2k
    {
2708
50.2k
        xRet.clear();
2709
50.2k
        new SdXShape( pShape, this );
2710
50.2k
        xRet = xShape;
2711
50.2k
        xShape.clear();
2712
50.2k
    }
2713
2714
55.8k
    return xRet;
2715
55.8k
}
2716
2717
uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( const OUString& aServiceSpecifier )
2718
68.9k
{
2719
68.9k
    return create(aServiceSpecifier, u""_ustr);
2720
68.9k
}
2721
2722
css::uno::Reference<css::uno::XInterface>
2723
SdXImpressDocument::createInstanceWithArguments(
2724
    OUString const & ServiceSpecifier,
2725
    css::uno::Sequence<css::uno::Any> const & Arguments)
2726
0
{
2727
0
    OUString arg;
2728
0
    if ((ServiceSpecifier == "com.sun.star.drawing.GraphicObjectShape"
2729
0
         || ServiceSpecifier == "com.sun.star.drawing.AppletShape"
2730
0
         || ServiceSpecifier == "com.sun.star.drawing.FrameShape"
2731
0
         || ServiceSpecifier == "com.sun.star.drawing.OLE2Shape"
2732
0
         || ServiceSpecifier == "com.sun.star.drawing.MediaShape"
2733
0
         || ServiceSpecifier == "com.sun.star.drawing.PluginShape"
2734
0
         || ServiceSpecifier == "com.sun.star.presentation.MediaShape")
2735
0
        && Arguments.getLength() == 1 && (Arguments[0] >>= arg))
2736
0
    {
2737
0
        return create(ServiceSpecifier, arg);
2738
0
    }
2739
0
    return SvxFmMSFactory::createInstanceWithArguments(
2740
0
        ServiceSpecifier, Arguments);
2741
0
}
2742
2743
uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getAvailableServiceNames()
2744
69
{
2745
69
    ::SolarMutexGuard aGuard;
2746
2747
69
    if( nullptr == mpDoc )
2748
0
        throw lang::DisposedException();
2749
2750
69
    const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() );
2751
2752
69
    uno::Sequence< OUString > aSNS_Common{ u"com.sun.star.drawing.DashTable"_ustr,
2753
69
                                           u"com.sun.star.drawing.GradientTable"_ustr,
2754
69
                                           u"com.sun.star.drawing.HatchTable"_ustr,
2755
69
                                           u"com.sun.star.drawing.BitmapTable"_ustr,
2756
69
                                           u"com.sun.star.drawing.TransparencyGradientTable"_ustr,
2757
69
                                           u"com.sun.star.drawing.MarkerTable"_ustr,
2758
69
                                           u"com.sun.star.text.NumberingRules"_ustr,
2759
69
                                           u"com.sun.star.drawing.Background"_ustr,
2760
69
                                           u"com.sun.star.document.Settings"_ustr,
2761
69
                                           sUNO_Service_ImageMapRectangleObject,
2762
69
                                           sUNO_Service_ImageMapCircleObject,
2763
69
                                           sUNO_Service_ImageMapPolygonObject,
2764
69
                                           u"com.sun.star.xml.NamespaceMap"_ustr,
2765
2766
                                           // Support creation of GraphicStorageHandler and EmbeddedObjectResolver
2767
69
                                           u"com.sun.star.document.ExportGraphicStorageHandler"_ustr,
2768
69
                                           u"com.sun.star.document.ImportGraphicStorageHandler"_ustr,
2769
69
                                           u"com.sun.star.document.ExportEmbeddedObjectResolver"_ustr,
2770
69
                                           u"com.sun.star.document.ImportEmbeddedObjectResolver"_ustr,
2771
69
                                           u"com.sun.star.drawing.TableShape"_ustr };
2772
2773
69
    uno::Sequence< OUString > aSNS_Specific;
2774
2775
69
    if(mbImpressDoc)
2776
0
        aSNS_Specific = { u"com.sun.star.presentation.TitleTextShape"_ustr,
2777
0
                          u"com.sun.star.presentation.OutlinerShape"_ustr,
2778
0
                          u"com.sun.star.presentation.SubtitleShape"_ustr,
2779
0
                          u"com.sun.star.presentation.GraphicObjectShape"_ustr,
2780
0
                          u"com.sun.star.presentation.ChartShape"_ustr,
2781
0
                          u"com.sun.star.presentation.PageShape"_ustr,
2782
0
                          u"com.sun.star.presentation.OLE2Shape"_ustr,
2783
0
                          u"com.sun.star.presentation.TableShape"_ustr,
2784
0
                          u"com.sun.star.presentation.OrgChartShape"_ustr,
2785
0
                          u"com.sun.star.presentation.NotesShape"_ustr,
2786
0
                          u"com.sun.star.presentation.HandoutShape"_ustr,
2787
0
                          u"com.sun.star.presentation.DocumentSettings"_ustr,
2788
0
                          u"com.sun.star.presentation.FooterShape"_ustr,
2789
0
                          u"com.sun.star.presentation.HeaderShape"_ustr,
2790
0
                          u"com.sun.star.presentation.SlideNumberShape"_ustr,
2791
0
                          u"com.sun.star.presentation.DateTimeShape"_ustr,
2792
0
                          u"com.sun.star.presentation.CalcShape"_ustr,
2793
0
                          u"com.sun.star.presentation.MediaShape"_ustr };
2794
69
    else
2795
69
        aSNS_Specific = { u"com.sun.star.drawing.DocumentSettings"_ustr };
2796
2797
69
    return comphelper::concatSequences( aSNS_ORG, aSNS_Common, aSNS_Specific );
2798
69
}
2799
2800
// lang::XServiceInfo
2801
OUString SAL_CALL SdXImpressDocument::getImplementationName()
2802
0
{
2803
0
    return u"SdXImpressDocument"_ustr;
2804
    /* // Matching the .component information:
2805
       return mbImpressDoc
2806
           ? OUString("com.sun.star.comp.Draw.PresentationDocument")
2807
           : OUString("com.sun.star.comp.Draw.DrawingDocument");
2808
    */
2809
0
}
2810
2811
sal_Bool SAL_CALL SdXImpressDocument::supportsService( const OUString& ServiceName )
2812
0
{
2813
0
    return cppu::supportsService(this, ServiceName);
2814
0
}
2815
2816
uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getSupportedServiceNames()
2817
69
{
2818
69
    ::SolarMutexGuard aGuard;
2819
2820
69
    return { u"com.sun.star.document.OfficeDocument"_ustr,
2821
69
             u"com.sun.star.drawing.GenericDrawingDocument"_ustr,
2822
69
             u"com.sun.star.drawing.DrawingDocumentFactory"_ustr,
2823
69
             mbImpressDoc?u"com.sun.star.presentation.PresentationDocument"_ustr:u"com.sun.star.drawing.DrawingDocument"_ustr };
2824
69
}
2825
2826
// XPropertySet
2827
uno::Reference< beans::XPropertySetInfo > SAL_CALL SdXImpressDocument::getPropertySetInfo(  )
2828
11.7k
{
2829
11.7k
    ::SolarMutexGuard aGuard;
2830
11.7k
    return mpPropSet->getPropertySetInfo();
2831
11.7k
}
2832
2833
void SAL_CALL SdXImpressDocument::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
2834
11.7k
{
2835
11.7k
    ::SolarMutexGuard aGuard;
2836
2837
11.7k
    if( nullptr == mpDoc )
2838
0
        throw lang::DisposedException();
2839
2840
11.7k
    const SfxItemPropertyMapEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
2841
2842
11.7k
    switch( pEntry ? pEntry->nWID : -1 )
2843
11.7k
    {
2844
0
        case WID_MODEL_LANGUAGE:
2845
0
        {
2846
0
            lang::Locale aLocale;
2847
0
            if(!(aValue >>= aLocale))
2848
0
                throw lang::IllegalArgumentException();
2849
2850
0
            mpDoc->SetLanguage( LanguageTag::convertToLanguageType(aLocale), EE_CHAR_LANGUAGE );
2851
0
            break;
2852
0
        }
2853
0
        case WID_MODEL_TABSTOP:
2854
0
        {
2855
0
            sal_Int32 nValue = 0;
2856
0
            if(!(aValue >>= nValue) || nValue < 0 )
2857
0
                throw lang::IllegalArgumentException();
2858
2859
0
            mpDoc->SetDefaultTabulator(static_cast<sal_uInt16>(nValue));
2860
0
            break;
2861
0
        }
2862
0
        case WID_MODEL_VISAREA:
2863
0
            {
2864
0
                SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh();
2865
0
                if( !pEmbeddedObj )
2866
0
                    break;
2867
2868
0
                awt::Rectangle aVisArea;
2869
0
                if( !(aValue >>= aVisArea) || (aVisArea.Width < 0) || (aVisArea.Height < 0) )
2870
0
                    throw lang::IllegalArgumentException();
2871
2872
0
                sal_Int32 nRight, nTop;
2873
0
                if (o3tl::checked_add(aVisArea.X, aVisArea.Width, nRight) || o3tl::checked_add(aVisArea.Y, aVisArea.Height, nTop))
2874
0
                    throw lang::IllegalArgumentException();
2875
2876
0
                pEmbeddedObj->SetVisArea(::tools::Rectangle(aVisArea.X, aVisArea.Y, nRight, nTop));
2877
0
            }
2878
0
            break;
2879
0
        case WID_MODEL_CONTFOCUS:
2880
0
            {
2881
0
                bool bFocus = false;
2882
0
                if( !(aValue >>= bFocus ) )
2883
0
                    throw lang::IllegalArgumentException();
2884
0
                mpDoc->SetAutoControlFocus( bFocus );
2885
0
            }
2886
0
            break;
2887
0
        case WID_MODEL_DSGNMODE:
2888
0
            {
2889
0
                bool bMode = false;
2890
0
                if( !(aValue >>= bMode ) )
2891
0
                    throw lang::IllegalArgumentException();
2892
0
                mpDoc->SetOpenInDesignMode( bMode );
2893
0
            }
2894
0
            break;
2895
0
        case WID_MODEL_BUILDID:
2896
0
            aValue >>= maBuildId;
2897
0
            return;
2898
0
        case WID_MODEL_MAPUNIT:
2899
0
        case WID_MODEL_BASICLIBS:
2900
0
        case WID_MODEL_RUNTIMEUID: // is read-only
2901
0
        case WID_MODEL_DIALOGLIBS:
2902
0
        case WID_MODEL_FONTS:
2903
0
            throw beans::PropertyVetoException();
2904
11.7k
        case WID_MODEL_INTEROPGRABBAG:
2905
11.7k
            setGrabBagItem(aValue);
2906
11.7k
            break;
2907
0
        case WID_MODEL_SLIDESECTIONS:
2908
0
        {
2909
0
            uno::Sequence<beans::PropertyValue> aSections;
2910
0
            if (aValue >>= aSections)
2911
0
                mpDoc->GetSectionManager().SetSectionsFromPropertyValues(aSections);
2912
0
            break;
2913
0
        }
2914
0
        case WID_MODEL_ANIMATIONSOUNDLINK:
2915
0
        {
2916
0
            bool bHasLink = false;
2917
0
            if (aValue >>= bHasLink)
2918
0
                mpDoc->SetMaybeHasAnimationSoundLinks(bHasLink);
2919
0
            break;
2920
0
        }
2921
0
        case WID_MODEL_THEME:
2922
0
            getSdrModelFromUnoModel().setTheme(model::Theme::FromAny(aValue));
2923
0
            break;
2924
0
        default:
2925
0
            throw beans::UnknownPropertyException( aPropertyName, static_cast<cppu::OWeakObject*>(this));
2926
11.7k
    }
2927
2928
11.7k
    SetModified();
2929
11.7k
}
2930
2931
uno::Any SAL_CALL SdXImpressDocument::getPropertyValue( const OUString& PropertyName )
2932
12.1k
{
2933
12.1k
    ::SolarMutexGuard aGuard;
2934
2935
12.1k
    uno::Any aAny;
2936
12.1k
    if( nullptr == mpDoc )
2937
0
        throw lang::DisposedException();
2938
2939
12.1k
    const SfxItemPropertyMapEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
2940
2941
12.1k
    switch( pEntry ? pEntry->nWID : -1 )
2942
12.1k
    {
2943
0
        case WID_MODEL_LANGUAGE:
2944
0
        {
2945
0
            LanguageType eLang = mpDoc->GetLanguage( EE_CHAR_LANGUAGE );
2946
0
            aAny <<= LanguageTag::convertToLocale( eLang);
2947
0
            break;
2948
0
        }
2949
0
        case WID_MODEL_TABSTOP:
2950
0
            aAny <<= static_cast<sal_Int32>(mpDoc->GetDefaultTabulator());
2951
0
            break;
2952
69
        case WID_MODEL_VISAREA:
2953
69
            {
2954
69
                SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh();
2955
69
                if( !pEmbeddedObj )
2956
0
                    break;
2957
2958
69
                const ::tools::Rectangle& aRect = pEmbeddedObj->GetVisArea();
2959
69
                awt::Rectangle aVisArea( aRect.Left(), aRect.Top(), aRect.getOpenWidth(), aRect.getOpenHeight() );
2960
69
                aAny <<= aVisArea;
2961
69
            }
2962
0
            break;
2963
0
        case WID_MODEL_MAPUNIT:
2964
0
            {
2965
0
                SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh();
2966
0
                if( !pEmbeddedObj )
2967
0
                    break;
2968
2969
0
                sal_Int16 nMeasureUnit = 0;
2970
0
                SvxMapUnitToMeasureUnit( pEmbeddedObj->GetMapUnit(), nMeasureUnit );
2971
0
                aAny <<= nMeasureUnit;
2972
0
        }
2973
0
        break;
2974
0
        case WID_MODEL_FORBCHARS:
2975
0
        {
2976
0
            aAny <<= getForbiddenCharsTable();
2977
0
        }
2978
0
        break;
2979
0
        case WID_MODEL_CONTFOCUS:
2980
0
            aAny <<= mpDoc->GetAutoControlFocus();
2981
0
            break;
2982
0
        case WID_MODEL_DSGNMODE:
2983
0
            aAny <<= mpDoc->GetOpenInDesignMode();
2984
0
            break;
2985
138
        case WID_MODEL_BASICLIBS:
2986
138
            aAny <<= mpDocShell->GetBasicContainer();
2987
138
            break;
2988
0
        case WID_MODEL_DIALOGLIBS:
2989
0
            aAny <<= mpDocShell->GetDialogContainer();
2990
0
            break;
2991
0
        case WID_MODEL_RUNTIMEUID:
2992
0
            aAny <<= getRuntimeUID();
2993
0
            break;
2994
0
        case WID_MODEL_BUILDID:
2995
0
            return uno::Any( maBuildId );
2996
0
        case WID_MODEL_HASVALIDSIGNATURES:
2997
0
            aAny <<= hasValidSignatures();
2998
0
            break;
2999
0
        case WID_MODEL_ALLOWLINKUPDATE:
3000
0
        {
3001
0
            comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = mpDocShell->getEmbeddedObjectContainer();
3002
0
            aAny <<= rEmbeddedObjectContainer.getUserAllowsLinkUpdate();
3003
0
            break;
3004
0
        }
3005
146
        case WID_MODEL_FONTS:
3006
146
            {
3007
146
                uno::Sequence<uno::Any> aSeq;
3008
146
                int nSeqIndex = 0;
3009
3010
146
                sal_uInt16 const aWhichIds[] { EE_CHAR_FONTINFO, EE_CHAR_FONTINFO_CJK,
3011
146
                                               EE_CHAR_FONTINFO_CTL };
3012
3013
146
                const SfxItemPool& rPool = mpDoc->GetPool();
3014
3015
146
                for(sal_uInt16 nWhichId : aWhichIds)
3016
438
                {
3017
438
                    ItemSurrogates aSurrogates = rPool.GetItemSurrogates(nWhichId);
3018
438
                    const sal_uInt32 nItems(aSurrogates.size());
3019
3020
438
                    aSeq.realloc( aSeq.getLength() + nItems*5 + 5 );
3021
438
                    auto pSeq = aSeq.getArray();
3022
3023
438
                    for (const SfxPoolItem* pItem : aSurrogates)
3024
904
                    {
3025
904
                        const SvxFontItem *pFont = static_cast<const SvxFontItem *>(pItem);
3026
3027
904
                        pSeq[nSeqIndex++] <<= pFont->GetFamilyName();
3028
904
                        pSeq[nSeqIndex++] <<= pFont->GetStyleName();
3029
904
                        pSeq[nSeqIndex++] <<= sal_Int16(pFont->GetFamily());
3030
904
                        pSeq[nSeqIndex++] <<= sal_Int16(pFont->GetPitch());
3031
904
                        pSeq[nSeqIndex++] <<= sal_Int16(pFont->GetCharSet());
3032
904
                    }
3033
3034
438
                    const SvxFontItem& rFont = static_cast<const SvxFontItem&>(rPool.GetUserOrPoolDefaultItem( nWhichId ));
3035
3036
438
                    pSeq[nSeqIndex++] <<= rFont.GetFamilyName();
3037
438
                    pSeq[nSeqIndex++] <<= rFont.GetStyleName();
3038
438
                    pSeq[nSeqIndex++] <<= sal_Int16(rFont.GetFamily());
3039
438
                    pSeq[nSeqIndex++] <<= sal_Int16(rFont.GetPitch());
3040
438
                    pSeq[nSeqIndex++] <<= sal_Int16(rFont.GetCharSet());
3041
3042
438
                }
3043
3044
146
                aAny <<= aSeq;
3045
146
                break;
3046
0
            }
3047
11.7k
        case WID_MODEL_INTEROPGRABBAG:
3048
11.7k
            getGrabBagItem(aAny);
3049
11.7k
            break;
3050
0
        case WID_MODEL_SLIDESECTIONS:
3051
0
            aAny <<= mpDoc->GetSectionManager().GetSectionsAsPropertyValues();
3052
0
            break;
3053
0
        case WID_MODEL_ANIMATIONSOUNDLINK:
3054
0
            aAny <<= mpDoc->MaybeHasAnimationSoundLinks();
3055
0
            break;
3056
0
        case WID_MODEL_THEME:
3057
0
            if (auto const& pTheme = getSdrModelFromUnoModel().getTheme())
3058
0
                pTheme->ToAny(aAny);
3059
0
            break;
3060
47
        default:
3061
47
            throw beans::UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this));
3062
12.1k
    }
3063
3064
12.0k
    return aAny;
3065
12.1k
}
3066
3067
0
void SAL_CALL SdXImpressDocument::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >&  ) {}
3068
0
void SAL_CALL SdXImpressDocument::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >&  ) {}
3069
0
void SAL_CALL SdXImpressDocument::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >&  ) {}
3070
0
void SAL_CALL SdXImpressDocument::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >&  ) {}
3071
3072
// XLinkTargetSupplier
3073
uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLinks()
3074
0
{
3075
0
    ::SolarMutexGuard aGuard;
3076
3077
0
    if( nullptr == mpDoc )
3078
0
        throw lang::DisposedException();
3079
3080
0
    rtl::Reference< SdDocLinkTargets > xLinks( mxLinks );
3081
0
    if( !xLinks.is() )
3082
0
    {
3083
0
        xLinks = new SdDocLinkTargets( *this );
3084
0
        mxLinks = xLinks.get();
3085
0
    }
3086
0
    return xLinks;
3087
0
}
3088
3089
// XStyleFamiliesSupplier
3090
uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getStyleFamilies(  )
3091
66.7k
{
3092
66.7k
    ::SolarMutexGuard aGuard;
3093
3094
66.7k
    if( nullptr == mpDoc )
3095
0
        throw lang::DisposedException();
3096
3097
66.7k
    uno::Reference< container::XNameAccess > xStyles( static_cast< OWeakObject* >( mpDoc->GetStyleSheetPool() ), css::uno::UNO_QUERY );
3098
66.7k
    return xStyles;
3099
66.7k
}
3100
3101
// XAnyCompareFactory
3102
uno::Reference< css::ucb::XAnyCompare > SAL_CALL SdXImpressDocument::createAnyCompareByName( const OUString& )
3103
323
{
3104
323
    return SvxCreateNumRuleCompare();
3105
323
}
3106
3107
// XRenderable
3108
sal_Int32 SAL_CALL SdXImpressDocument::getRendererCount( const uno::Any& rSelection,
3109
                                                         const uno::Sequence< beans::PropertyValue >&  )
3110
0
{
3111
0
    ::SolarMutexGuard aGuard;
3112
0
    sal_Int32   nRet = 0;
3113
3114
0
    if( nullptr == mpDoc )
3115
0
        throw lang::DisposedException();
3116
3117
0
    if (mpDocShell)
3118
0
    {
3119
0
        uno::Reference< frame::XModel > xModel;
3120
3121
0
        rSelection >>= xModel;
3122
3123
0
        if( xModel == mpDocShell->GetModel() )
3124
0
            nRet = mpDoc->GetSdPageCount( PageKind::Standard );
3125
0
        else
3126
0
        {
3127
0
            uno::Reference< drawing::XShapes > xShapes;
3128
3129
0
            rSelection >>= xShapes;
3130
3131
0
            if( xShapes.is() && xShapes->getCount() )
3132
0
                nRet = 1;
3133
0
        }
3134
0
    }
3135
0
    return nRet;
3136
0
}
3137
3138
uno::Sequence< beans::PropertyValue > SAL_CALL SdXImpressDocument::getRenderer( sal_Int32 , const uno::Any& ,
3139
                                                                                const uno::Sequence< beans::PropertyValue >& rxOptions )
3140
0
{
3141
0
    ::SolarMutexGuard aGuard;
3142
3143
0
    if( nullptr == mpDoc )
3144
0
        throw lang::DisposedException();
3145
3146
0
    bool bExportNotesPages = false;
3147
0
    for( const auto& rOption : rxOptions )
3148
0
    {
3149
0
        if ( rOption.Name == "ExportNotesPages" )
3150
0
            rOption.Value >>= bExportNotesPages;
3151
0
    }
3152
0
    uno::Sequence< beans::PropertyValue > aRenderer;
3153
0
    if (mpDocShell)
3154
0
    {
3155
0
        awt::Size aPageSize;
3156
0
        if ( bExportNotesPages )
3157
0
        {
3158
0
            Size aNotesPageSize = mpDoc->GetSdPage( 0, PageKind::Notes )->GetSize();
3159
0
            aPageSize = awt::Size( aNotesPageSize.Width(), aNotesPageSize.Height() );
3160
0
        }
3161
0
        else
3162
0
        {
3163
0
            const ::tools::Rectangle aVisArea( mpDocShell->GetVisArea( embed::Aspects::MSOLE_DOCPRINT ) );
3164
0
            aPageSize = awt::Size( aVisArea.GetWidth(), aVisArea.GetHeight() );
3165
0
        }
3166
0
        aRenderer = { comphelper::makePropertyValue(u"PageSize"_ustr, aPageSize) };
3167
0
    }
3168
0
    return aRenderer;
3169
0
}
3170
3171
namespace {
3172
3173
class ImplRenderPaintProc : public sdr::contact::ViewObjectContactRedirector
3174
{
3175
    const SdrLayerAdmin&    rLayerAdmin;
3176
    SdrPageView*            pSdrPageView;
3177
3178
public:
3179
    bool IsVisible  ( const SdrObject* pObj ) const;
3180
    bool IsPrintable( const SdrObject* pObj ) const;
3181
3182
    ImplRenderPaintProc(const SdrLayerAdmin& rLA, SdrPageView* pView);
3183
3184
    // all default implementations just call the same methods at the original. To do something
3185
    // different, override the method and at least do what the method does.
3186
    virtual void createRedirectedPrimitive2DSequence(
3187
        const sdr::contact::ViewObjectContact& rOriginal,
3188
        const sdr::contact::DisplayInfo& rDisplayInfo,
3189
        drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) override;
3190
};
3191
3192
}
3193
3194
ImplRenderPaintProc::ImplRenderPaintProc(const SdrLayerAdmin& rLA, SdrPageView *const pView)
3195
0
    : rLayerAdmin(rLA)
3196
0
    , pSdrPageView(pView)
3197
0
{
3198
0
}
3199
3200
static sal_Int32 ImplPDFGetBookmarkPage( const OUString& rBookmark, SdDrawDocument const & rDoc )
3201
0
{
3202
0
    sal_Int32 nPage = -1;
3203
3204
0
    OUString aBookmark( rBookmark );
3205
3206
0
    if( rBookmark.startsWith("#") )
3207
0
        aBookmark = rBookmark.copy( 1 );
3208
3209
    // is the bookmark a page ?
3210
0
    bool        bIsMasterPage;
3211
0
    sal_uInt16  nPgNum = rDoc.GetPageByName( aBookmark, bIsMasterPage );
3212
3213
0
    if ( nPgNum == SDRPAGE_NOTFOUND )
3214
0
    {
3215
        // is the bookmark an object ?
3216
0
        SdrObject* pObj = rDoc.GetObj( aBookmark );
3217
0
        if (pObj)
3218
0
            nPgNum = pObj->getSdrPageFromSdrObject()->GetPageNum();
3219
0
    }
3220
0
    if ( nPgNum != SDRPAGE_NOTFOUND )
3221
0
        nPage = ( nPgNum - 1 ) / 2;
3222
0
    return nPage;
3223
0
}
3224
3225
static void ImplPDFExportComments( const uno::Reference< drawing::XDrawPage >& xPage, vcl::PDFExtOutDevData& rPDFExtOutDevData )
3226
0
{
3227
0
    try
3228
0
    {
3229
0
        uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xPage, uno::UNO_QUERY_THROW );
3230
0
        uno::Reference< office::XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
3231
3232
0
        while( xAnnotationEnumeration->hasMoreElements() )
3233
0
        {
3234
0
            uno::Reference<office::XAnnotation> xAnnotation(xAnnotationEnumeration->nextElement());
3235
3236
0
            geometry::RealPoint2D aRealPoint2D(xAnnotation->getPosition());
3237
0
            geometry::RealSize2D aRealSize2D(xAnnotation->getSize());
3238
3239
0
            Point aPoint(aRealPoint2D.X * 100.0, aRealPoint2D.Y * 100.0);
3240
0
            Size aSize(aRealSize2D.Width * 100.0, aRealSize2D.Height * 100.0);
3241
3242
0
            Point aPopupPoint(aPoint.X(), aPoint.Y());
3243
0
            Size aPopupSize(aSize.Width() * 10.0, aSize.Height() * 10.0);
3244
3245
0
            uno::Reference<text::XText> xText(xAnnotation->getTextRange());
3246
3247
0
            vcl::pdf::PDFNote aNote;
3248
0
            aNote.maTitle = xAnnotation->getAuthor();
3249
0
            aNote.maContents = xText->getString();
3250
0
            aNote.maModificationDate = xAnnotation->getDateTime();
3251
0
            auto* pAnnotation = dynamic_cast<sd::Annotation*>(xAnnotation.get());
3252
3253
0
            if (pAnnotation && pAnnotation->getCreationInfo().meType != sdr::annotation::AnnotationType::None)
3254
0
            {
3255
0
                sdr::annotation::CreationInfo const& rCreation = pAnnotation->getCreationInfo();
3256
0
                aNote.maPolygons = rCreation.maPolygons;
3257
0
                aNote.maAnnotationColor = rCreation.maColor;
3258
0
                aNote.maInteriorColor = rCreation.maFillColor;
3259
0
                aNote.mfWidth = rCreation.mnWidth;
3260
0
                switch (rCreation.meType)
3261
0
                {
3262
0
                    case sdr::annotation::AnnotationType::Square:
3263
0
                        aNote.meType = vcl::pdf::PDFAnnotationSubType::Square; break;
3264
0
                    case sdr::annotation::AnnotationType::Circle:
3265
0
                        aNote.meType = vcl::pdf::PDFAnnotationSubType::Circle; break;
3266
0
                    case sdr::annotation::AnnotationType::Polygon:
3267
0
                        aNote.meType = vcl::pdf::PDFAnnotationSubType::Polygon; break;
3268
0
                    case sdr::annotation::AnnotationType::Ink:
3269
0
                        aNote.meType = vcl::pdf::PDFAnnotationSubType::Ink; break;
3270
0
                    case sdr::annotation::AnnotationType::Highlight:
3271
0
                        aNote.meType = vcl::pdf::PDFAnnotationSubType::Highlight; break;
3272
0
                    case sdr::annotation::AnnotationType::Line:
3273
0
                        aNote.meType = vcl::pdf::PDFAnnotationSubType::Line; break;
3274
0
                    case sdr::annotation::AnnotationType::FreeText:
3275
0
                        aNote.meType = vcl::pdf::PDFAnnotationSubType::FreeText; break;
3276
0
                    default:
3277
0
                        aNote.meType = vcl::pdf::PDFAnnotationSubType::Text;
3278
0
                        break;
3279
0
                }
3280
0
            }
3281
3282
0
            rPDFExtOutDevData.CreateNote(::tools::Rectangle(aPoint, aSize), aNote,
3283
0
                                         ::tools::Rectangle(aPopupPoint, aPopupSize));
3284
0
        }
3285
0
    }
3286
0
    catch (const uno::Exception&)
3287
0
    {
3288
0
    }
3289
0
}
3290
3291
static void ImplPDFExportShapeInteraction( const uno::Reference< drawing::XShape >& xShape, SdDrawDocument& rDoc, vcl::PDFExtOutDevData& rPDFExtOutDevData )
3292
0
{
3293
0
    if ( xShape->getShapeType() == "com.sun.star.drawing.GroupShape" )
3294
0
    {
3295
0
        uno::Reference< container::XIndexAccess > xIndexAccess( xShape, uno::UNO_QUERY );
3296
0
        if ( xIndexAccess.is() )
3297
0
        {
3298
0
            sal_Int32 i, nCount = xIndexAccess->getCount();
3299
0
            for ( i = 0; i < nCount; i++ )
3300
0
            {
3301
0
                uno::Reference< drawing::XShape > xSubShape( xIndexAccess->getByIndex( i ), uno::UNO_QUERY );
3302
0
                if ( xSubShape.is() )
3303
0
                    ImplPDFExportShapeInteraction( xSubShape, rDoc, rPDFExtOutDevData );
3304
0
            }
3305
0
        }
3306
0
    }
3307
0
    else
3308
0
    {
3309
0
        uno::Reference< beans::XPropertySet > xShapePropSet( xShape, uno::UNO_QUERY );
3310
0
        if( xShapePropSet.is() )
3311
0
        {
3312
0
            Size        aPageSize( rDoc.GetSdPage( 0, PageKind::Standard )->GetSize() );
3313
0
            Point aPoint( 0, 0 );
3314
0
            ::tools::Rectangle   aPageRect( aPoint, aPageSize );
3315
3316
0
            awt::Point  aShapePos( xShape->getPosition() );
3317
0
            awt::Size   aShapeSize( xShape->getSize() );
3318
0
            ::tools::Rectangle   aLinkRect( Point( aShapePos.X, aShapePos.Y ), Size( aShapeSize.Width, aShapeSize.Height ) );
3319
3320
0
            OUString title;
3321
0
            xShapePropSet->getPropertyValue(u"Title"_ustr) >>= title;
3322
0
            OUString description;
3323
0
            xShapePropSet->getPropertyValue(u"Description"_ustr) >>= description;
3324
0
            OUString const altText(title.isEmpty()
3325
0
                ? description
3326
0
                : description.isEmpty()
3327
0
                    ? title
3328
0
                    : OUString::Concat(title) + OUString::Concat("\n") + OUString::Concat(description));
3329
3330
            // Handle linked videos.
3331
0
            if (xShape->getShapeType() == "com.sun.star.drawing.MediaShape" || xShape->getShapeType() == "com.sun.star.presentation.MediaShape")
3332
0
            {
3333
0
                OUString aMediaURL;
3334
0
                xShapePropSet->getPropertyValue(u"MediaURL"_ustr) >>= aMediaURL;
3335
0
                if (!aMediaURL.isEmpty())
3336
0
                {
3337
0
                    SdrObject const*const pSdrObj(SdrObject::getSdrObjectFromXShape(xShape));
3338
0
                    OUString const mimeType(xShapePropSet->getPropertyValue(u"MediaMimeType"_ustr).get<OUString>());
3339
0
                    sal_Int32 nScreenId = rPDFExtOutDevData.CreateScreen(aLinkRect, altText, mimeType, rPDFExtOutDevData.GetCurrentPageNumber(), pSdrObj);
3340
0
                    if (aMediaURL.startsWith("vnd.sun.star.Package:"))
3341
0
                    {
3342
0
                        OUString aTempFileURL;
3343
0
                        xShapePropSet->getPropertyValue(u"PrivateTempFileURL"_ustr) >>= aTempFileURL;
3344
0
                        rPDFExtOutDevData.SetScreenStream(nScreenId, aTempFileURL);
3345
0
                    }
3346
0
                    else
3347
0
                        rPDFExtOutDevData.SetScreenURL(nScreenId, aMediaURL);
3348
0
                }
3349
0
            }
3350
3351
0
            presentation::ClickAction eCa;
3352
0
            uno::Any aAny( xShapePropSet->getPropertyValue( u"OnClick"_ustr ) );
3353
0
            if ( aAny >>= eCa )
3354
0
            {
3355
                // the link describes itself with the shape's alternative text, else with the action
3356
0
                OUString const linkText(altText.isEmpty()
3357
0
                    ? SdResId(SdTPAction::GetClickActionSdResId(eCa))
3358
0
                    : altText);
3359
0
                switch ( eCa )
3360
0
                {
3361
0
                    case presentation::ClickAction_LASTPAGE :
3362
0
                    {
3363
0
                        sal_Int32 nCount = rDoc.GetSdPageCount( PageKind::Standard );
3364
0
                        sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nCount - 1, vcl::pdf::PDFWriter::DestAreaType::FitRectangle );
3365
0
                        sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink(aLinkRect, linkText);
3366
0
                        rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
3367
0
                    }
3368
0
                    break;
3369
0
                    case presentation::ClickAction_FIRSTPAGE :
3370
0
                    {
3371
0
                        sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, 0, vcl::pdf::PDFWriter::DestAreaType::FitRectangle );
3372
0
                        sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink(aLinkRect, linkText);
3373
0
                        rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
3374
0
                    }
3375
0
                    break;
3376
0
                    case presentation::ClickAction_PREVPAGE :
3377
0
                    {
3378
0
                        sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber();
3379
0
                        if ( nDestPage )
3380
0
                            nDestPage--;
3381
0
                        sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::pdf::PDFWriter::DestAreaType::FitRectangle );
3382
0
                        sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink(aLinkRect, linkText);
3383
0
                        rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
3384
0
                    }
3385
0
                    break;
3386
0
                    case presentation::ClickAction_NEXTPAGE :
3387
0
                    {
3388
0
                        sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber() + 1;
3389
0
                        sal_Int32 nLastPage = rDoc.GetSdPageCount( PageKind::Standard ) - 1;
3390
0
                        if ( nDestPage > nLastPage )
3391
0
                            nDestPage = nLastPage;
3392
0
                        sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::pdf::PDFWriter::DestAreaType::FitRectangle );
3393
0
                        sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink(aLinkRect, linkText);
3394
0
                        rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
3395
0
                    }
3396
0
                    break;
3397
3398
0
                    case presentation::ClickAction_PROGRAM :
3399
0
                    case presentation::ClickAction_BOOKMARK :
3400
0
                    case presentation::ClickAction_DOCUMENT :
3401
0
                    {
3402
0
                        OUString aBookmark;
3403
0
                        xShapePropSet->getPropertyValue( u"Bookmark"_ustr ) >>= aBookmark;
3404
0
                        if( !aBookmark.isEmpty() )
3405
0
                        {
3406
0
                            switch( eCa )
3407
0
                            {
3408
0
                                case presentation::ClickAction_DOCUMENT :
3409
0
                                case presentation::ClickAction_PROGRAM :
3410
0
                                {
3411
0
                                    sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink(aLinkRect, linkText);
3412
0
                                    rPDFExtOutDevData.SetLinkURL( nLinkId, aBookmark );
3413
0
                                }
3414
0
                                break;
3415
0
                                case presentation::ClickAction_BOOKMARK :
3416
0
                                {
3417
0
                                    sal_Int32 nPage = ImplPDFGetBookmarkPage( aBookmark, rDoc );
3418
0
                                    if ( nPage != -1 )
3419
0
                                    {
3420
0
                                        sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nPage, vcl::pdf::PDFWriter::DestAreaType::FitRectangle );
3421
0
                                        sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink(aLinkRect, linkText);
3422
0
                                        rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
3423
0
                                    }
3424
0
                                }
3425
0
                                break;
3426
0
                                default:
3427
0
                                    break;
3428
0
                            }
3429
0
                        }
3430
0
                    }
3431
0
                    break;
3432
3433
0
                    case presentation::ClickAction_STOPPRESENTATION :
3434
0
                    case presentation::ClickAction_SOUND :
3435
0
                    case presentation::ClickAction_INVISIBLE :
3436
0
                    case presentation::ClickAction_VERB :
3437
0
                    case presentation::ClickAction_VANISH :
3438
0
                    case presentation::ClickAction_MACRO :
3439
0
                    default :
3440
0
                    break;
3441
0
                }
3442
0
            }
3443
0
        }
3444
0
    }
3445
0
}
3446
3447
void ImplRenderPaintProc::createRedirectedPrimitive2DSequence(
3448
    const sdr::contact::ViewObjectContact& rOriginal,
3449
    const sdr::contact::DisplayInfo& rDisplayInfo,
3450
    drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor)
3451
0
{
3452
0
    SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
3453
0
    if(!pObject)
3454
0
    {
3455
        // not an object, maybe a page
3456
0
        sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo, rVisitor);
3457
0
        return;
3458
0
    }
3459
0
    SdrPage* pSdrPage(pObject->getSdrPageFromSdrObject());
3460
0
    if(!pSdrPage)
3461
0
        return;
3462
0
    if(!pSdrPage->checkVisibility(rOriginal, rDisplayInfo, false))
3463
0
        return;
3464
0
    if(!IsVisible(pObject) || !IsPrintable(pObject))
3465
0
        return;
3466
3467
0
    sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo, rVisitor);
3468
0
}
3469
3470
bool ImplRenderPaintProc::IsVisible( const SdrObject* pObj ) const
3471
0
{
3472
0
    bool bVisible = true;
3473
0
    SdrLayerID nLayerId = pObj->GetLayer();
3474
0
    if( pSdrPageView )
3475
0
    {
3476
0
        const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId );
3477
0
        if ( pSdrLayer )
3478
0
        {
3479
0
            const OUString& aLayerName = pSdrLayer->GetName();
3480
0
            bVisible = pSdrPageView->IsLayerVisible( aLayerName );
3481
0
        }
3482
0
    }
3483
0
    return bVisible;
3484
0
}
3485
bool ImplRenderPaintProc::IsPrintable( const SdrObject* pObj ) const
3486
0
{
3487
0
    bool bPrintable = true;
3488
0
    SdrLayerID nLayerId = pObj->GetLayer();
3489
0
    if( pSdrPageView )
3490
0
    {
3491
0
        const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId );
3492
0
        if ( pSdrLayer )
3493
0
        {
3494
0
            const OUString& aLayerName = pSdrLayer->GetName();
3495
0
            bPrintable = pSdrPageView->IsLayerPrintable( aLayerName );
3496
0
        }
3497
0
    }
3498
0
    return bPrintable;
3499
3500
0
}
3501
3502
namespace
3503
{
3504
    sal_Int16 CalcOutputPageNum(vcl::PDFExtOutDevData const * pPDFExtOutDevData, SdDrawDocument const *pDoc, sal_Int16 nPageNumber)
3505
0
    {
3506
        //export all pages, simple one to one case
3507
0
        if (pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportHiddenSlides())
3508
0
            return nPageNumber-1;
3509
        //check all preceding pages, and only count non-hidden ones
3510
0
        sal_Int16 nRet = 0;
3511
0
        for (sal_Int16 i = 0; i < nPageNumber-1; ++i)
3512
0
        {
3513
0
           if (!pDoc->GetSdPage(i, PageKind::Standard)->IsExcluded())
3514
0
                ++nRet;
3515
0
        }
3516
0
        return nRet;
3517
0
    }
3518
}
3519
3520
void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& rSelection,
3521
                                          const uno::Sequence< beans::PropertyValue >& rxOptions )
3522
0
{
3523
0
    ::SolarMutexGuard aGuard;
3524
3525
0
    if( nullptr == mpDoc )
3526
0
        throw lang::DisposedException();
3527
3528
0
    if (!mpDocShell)
3529
0
        return;
3530
3531
0
    uno::Reference< awt::XDevice >  xRenderDevice;
3532
0
    const sal_Int32                 nPageNumber = nRenderer + 1;
3533
0
    PageKind                        ePageKind = PageKind::Standard;
3534
0
    bool                        bExportNotesPages = false;
3535
3536
0
    for( const auto& rOption : rxOptions )
3537
0
    {
3538
0
        if ( rOption.Name == "RenderDevice" )
3539
0
            rOption.Value >>= xRenderDevice;
3540
0
        else if ( rOption.Name == "ExportNotesPages" )
3541
0
        {
3542
0
            rOption.Value >>= bExportNotesPages;
3543
0
            if ( bExportNotesPages )
3544
0
                ePageKind = PageKind::Notes;
3545
0
        }
3546
0
    }
3547
3548
0
    if( !(xRenderDevice.is() && nPageNumber && ( nPageNumber <= mpDoc->GetSdPageCount( ePageKind ) )) )
3549
0
        return;
3550
3551
0
    VCLXDevice* pDevice = dynamic_cast<VCLXDevice*>( xRenderDevice.get() );
3552
0
    VclPtr< OutputDevice> pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >();
3553
3554
0
    if( !pOut )
3555
0
        return;
3556
3557
0
    vcl::PDFExtOutDevData* pPDFExtOutDevData = dynamic_cast<vcl::PDFExtOutDevData* >( pOut->GetExtOutDevData() );
3558
3559
0
    if ( mpDoc->GetSdPage(static_cast<sal_Int16>(nPageNumber)-1, PageKind::Standard)->IsExcluded() &&
3560
0
        !(pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportHiddenSlides()) )
3561
0
        return;
3562
3563
0
    if (pPDFExtOutDevData)
3564
0
    {
3565
0
        css::lang::Locale const docLocale(
3566
0
            LanguageTag(mpDoc->GetLanguage(EE_CHAR_LANGUAGE)).getLocale());
3567
0
        pPDFExtOutDevData->SetDocumentLocale(docLocale);
3568
0
    }
3569
3570
0
    ::sd::ClientView aView( mpDocShell, pOut );
3571
0
    ::tools::Rectangle aVisArea( Point(), mpDoc->GetSdPage( static_cast<sal_uInt16>(nPageNumber) - 1, ePageKind )->GetSize() );
3572
0
    vcl::Region                       aRegion( aVisArea );
3573
3574
0
    ::sd::ViewShell* pOldViewSh = mpDocShell->GetViewShell();
3575
0
    ::sd::View* pOldSdView = pOldViewSh ? pOldViewSh->GetView() : nullptr;
3576
3577
0
    if  ( pOldSdView )
3578
0
        pOldSdView->SdrEndTextEdit();
3579
3580
0
    aView.SetHlplVisible( false );
3581
0
    aView.SetGridVisible( false );
3582
0
    aView.SetBordVisible( false );
3583
0
    aView.SetPageVisible( false );
3584
0
    aView.SetGlueVisible( false );
3585
3586
0
    pOut->SetMapMode(MapMode(MapUnit::Map100thMM));
3587
0
    pOut->IntersectClipRegion( aVisArea );
3588
3589
0
    uno::Reference< frame::XModel > xModel;
3590
0
    rSelection >>= xModel;
3591
3592
0
    if( xModel == mpDocShell->GetModel() )
3593
0
    {
3594
0
        aView.ShowSdrPage( mpDoc->GetSdPage( static_cast<sal_uInt16>(nPageNumber) - 1, ePageKind ));
3595
0
        SdrPageView* pPV = aView.GetSdrPageView();
3596
3597
0
        if( pOldSdView )
3598
0
        {
3599
0
            SdrPageView* pOldPV = pOldSdView->GetSdrPageView();
3600
0
            if( pPV && pOldPV )
3601
0
            {
3602
0
                pPV->SetVisibleLayers( pOldPV->GetVisibleLayers() );
3603
0
                pPV->SetPrintableLayers( pOldPV->GetPrintableLayers() );
3604
0
            }
3605
0
        }
3606
3607
0
        ImplRenderPaintProc aImplRenderPaintProc( mpDoc->GetLayerAdmin(),
3608
0
            pPV);
3609
3610
        // background color for outliner :o
3611
0
        SdPage* pPage = pPV ? static_cast<SdPage*>(pPV->GetPage()) : nullptr;
3612
0
        if( pPage )
3613
0
        {
3614
0
            SdrOutliner& rOutl = mpDoc->GetDrawOutliner();
3615
0
            bool bScreenDisplay(true);
3616
3617
            // #i75566# printing; suppress AutoColor BackgroundColor generation
3618
            // for visibility reasons by giving GetPageBackgroundColor()
3619
            // the needed hint
3620
            // #i75566# PDF export; suppress AutoColor BackgroundColor generation (see printing)
3621
0
            if (pOut && ((OUTDEV_PRINTER == pOut->GetOutDevType())
3622
0
                    || (OUTDEV_PDF == pOut->GetOutDevType())))
3623
0
                bScreenDisplay = false;
3624
3625
            // #i75566# Name change GetBackgroundColor -> GetPageBackgroundColor and
3626
            // hint value if screen display. Only then the AutoColor mechanisms shall be applied
3627
0
            rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor( pPV, bScreenDisplay ) );
3628
0
        }
3629
3630
        // produce link annots for media shapes before painting them
3631
0
        if ( pPDFExtOutDevData && pPage )
3632
0
        {
3633
0
            try
3634
0
            {
3635
0
                uno::Any aAny;
3636
0
                uno::Reference< drawing::XDrawPage > xPage( uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() ) );
3637
0
                if ( xPage.is() )
3638
0
                {
3639
0
                    if ( pPDFExtOutDevData->GetIsExportNotes() )
3640
0
                        ImplPDFExportComments( xPage, *pPDFExtOutDevData );
3641
0
                    uno::Reference< beans::XPropertySet > xPagePropSet( xPage, uno::UNO_QUERY );
3642
0
                    if( xPagePropSet.is() )
3643
0
                    {
3644
                        // exporting object interactions to pdf
3645
3646
                        // if necessary, the master page interactions will be exported first
3647
0
                        bool bIsBackgroundObjectsVisible = false;   // #i39428# IsBackgroundObjectsVisible not available for Draw
3648
0
                        if ( mbImpressDoc && xPagePropSet->getPropertySetInfo()->hasPropertyByName( u"IsBackgroundObjectsVisible"_ustr ) )
3649
0
                            xPagePropSet->getPropertyValue( u"IsBackgroundObjectsVisible"_ustr ) >>= bIsBackgroundObjectsVisible;
3650
0
                        if ( bIsBackgroundObjectsVisible && !pPDFExtOutDevData->GetIsExportNotesPages() )
3651
0
                        {
3652
0
                            uno::Reference< drawing::XMasterPageTarget > xMasterPageTarget( xPage, uno::UNO_QUERY );
3653
0
                            if ( xMasterPageTarget.is() )
3654
0
                            {
3655
0
                                uno::Reference< drawing::XDrawPage > xMasterPage = xMasterPageTarget->getMasterPage();
3656
0
                                if ( xMasterPage.is() )
3657
0
                                {
3658
0
                                    sal_Int32 i, nCount = xMasterPage->getCount();
3659
0
                                    for ( i = 0; i < nCount; i++ )
3660
0
                                    {
3661
0
                                        aAny = xMasterPage->getByIndex( i );
3662
0
                                        uno::Reference< drawing::XShape > xShape;
3663
0
                                        if ( aAny >>= xShape )
3664
0
                                            ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData );
3665
0
                                    }
3666
0
                                }
3667
0
                            }
3668
0
                        }
3669
3670
                        // exporting slide page object interactions
3671
0
                        sal_Int32 i, nCount = xPage->getCount();
3672
0
                        for ( i = 0; i < nCount; i++ )
3673
0
                        {
3674
0
                            aAny = xPage->getByIndex( i );
3675
0
                            uno::Reference< drawing::XShape > xShape;
3676
0
                            if ( aAny >>= xShape )
3677
0
                                ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData );
3678
0
                        }
3679
3680
                        // exporting transition effects to pdf
3681
0
                        if ( mbImpressDoc && !pPDFExtOutDevData->GetIsExportNotesPages() && pPDFExtOutDevData->GetIsExportTransitionEffects() )
3682
0
                        {
3683
0
                            static constexpr OUString sEffect( u"Effect"_ustr );
3684
0
                            static constexpr OUString sSpeed ( u"Speed"_ustr );
3685
0
                            sal_Int32 nTime = 800;
3686
0
                            presentation::AnimationSpeed aAs;
3687
0
                            if ( xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sSpeed ) )
3688
0
                            {
3689
0
                                aAny = xPagePropSet->getPropertyValue( sSpeed );
3690
0
                                if ( aAny >>= aAs )
3691
0
                                {
3692
0
                                    switch( aAs )
3693
0
                                    {
3694
0
                                        case presentation::AnimationSpeed_SLOW : nTime = 1500; break;
3695
0
                                        case presentation::AnimationSpeed_FAST : nTime = 300; break;
3696
0
                                        default:
3697
0
                                        case presentation::AnimationSpeed_MEDIUM : nTime = 800;
3698
0
                                    }
3699
0
                                }
3700
0
                            }
3701
0
                            presentation::FadeEffect eFe;
3702
0
                            vcl::pdf::PDFWriter::PageTransition eType = vcl::pdf::PDFWriter::PageTransition::Regular;
3703
0
                            if ( xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sEffect ) )
3704
0
                            {
3705
0
                                aAny = xPagePropSet->getPropertyValue( sEffect );
3706
0
                                if ( aAny >>= eFe )
3707
0
                                {
3708
0
                                    switch( eFe )
3709
0
                                    {
3710
0
                                        case presentation::FadeEffect_HORIZONTAL_LINES :
3711
0
                                        case presentation::FadeEffect_HORIZONTAL_CHECKERBOARD :
3712
0
                                        case presentation::FadeEffect_HORIZONTAL_STRIPES : eType = vcl::pdf::PDFWriter::PageTransition::BlindsHorizontal; break;
3713
3714
0
                                        case presentation::FadeEffect_VERTICAL_LINES :
3715
0
                                        case presentation::FadeEffect_VERTICAL_CHECKERBOARD :
3716
0
                                        case presentation::FadeEffect_VERTICAL_STRIPES : eType = vcl::pdf::PDFWriter::PageTransition::BlindsVertical; break;
3717
3718
0
                                        case presentation::FadeEffect_UNCOVER_TO_RIGHT :
3719
0
                                        case presentation::FadeEffect_UNCOVER_TO_UPPERRIGHT :
3720
0
                                        case presentation::FadeEffect_ROLL_FROM_LEFT :
3721
0
                                        case presentation::FadeEffect_FADE_FROM_UPPERLEFT :
3722
0
                                        case presentation::FadeEffect_MOVE_FROM_UPPERLEFT :
3723
0
                                        case presentation::FadeEffect_FADE_FROM_LEFT :
3724
0
                                        case presentation::FadeEffect_MOVE_FROM_LEFT : eType = vcl::pdf::PDFWriter::PageTransition::WipeLeftToRight; break;
3725
3726
0
                                        case presentation::FadeEffect_UNCOVER_TO_BOTTOM :
3727
0
                                        case presentation::FadeEffect_UNCOVER_TO_LOWERRIGHT :
3728
0
                                        case presentation::FadeEffect_ROLL_FROM_TOP :
3729
0
                                        case presentation::FadeEffect_FADE_FROM_UPPERRIGHT :
3730
0
                                        case presentation::FadeEffect_MOVE_FROM_UPPERRIGHT :
3731
0
                                        case presentation::FadeEffect_FADE_FROM_TOP :
3732
0
                                        case presentation::FadeEffect_MOVE_FROM_TOP : eType = vcl::pdf::PDFWriter::PageTransition::WipeTopToBottom; break;
3733
3734
0
                                        case presentation::FadeEffect_UNCOVER_TO_LEFT :
3735
0
                                        case presentation::FadeEffect_UNCOVER_TO_LOWERLEFT :
3736
0
                                        case presentation::FadeEffect_ROLL_FROM_RIGHT :
3737
3738
0
                                        case presentation::FadeEffect_FADE_FROM_LOWERRIGHT :
3739
0
                                        case presentation::FadeEffect_MOVE_FROM_LOWERRIGHT :
3740
0
                                        case presentation::FadeEffect_FADE_FROM_RIGHT :
3741
0
                                        case presentation::FadeEffect_MOVE_FROM_RIGHT : eType = vcl::pdf::PDFWriter::PageTransition::WipeRightToLeft; break;
3742
3743
0
                                        case presentation::FadeEffect_UNCOVER_TO_TOP :
3744
0
                                        case presentation::FadeEffect_UNCOVER_TO_UPPERLEFT :
3745
0
                                        case presentation::FadeEffect_ROLL_FROM_BOTTOM :
3746
0
                                        case presentation::FadeEffect_FADE_FROM_LOWERLEFT :
3747
0
                                        case presentation::FadeEffect_MOVE_FROM_LOWERLEFT :
3748
0
                                        case presentation::FadeEffect_FADE_FROM_BOTTOM :
3749
0
                                        case presentation::FadeEffect_MOVE_FROM_BOTTOM : eType = vcl::pdf::PDFWriter::PageTransition::WipeBottomToTop; break;
3750
3751
0
                                        case presentation::FadeEffect_OPEN_VERTICAL : eType = vcl::pdf::PDFWriter::PageTransition::SplitHorizontalInward; break;
3752
0
                                        case presentation::FadeEffect_CLOSE_HORIZONTAL : eType = vcl::pdf::PDFWriter::PageTransition::SplitHorizontalOutward; break;
3753
3754
0
                                        case presentation::FadeEffect_OPEN_HORIZONTAL : eType = vcl::pdf::PDFWriter::PageTransition::SplitVerticalInward; break;
3755
0
                                        case presentation::FadeEffect_CLOSE_VERTICAL : eType = vcl::pdf::PDFWriter::PageTransition::SplitVerticalOutward; break;
3756
3757
0
                                        case presentation::FadeEffect_FADE_TO_CENTER : eType = vcl::pdf::PDFWriter::PageTransition::BoxInward; break;
3758
0
                                        case presentation::FadeEffect_FADE_FROM_CENTER : eType = vcl::pdf::PDFWriter::PageTransition::BoxOutward; break;
3759
3760
0
                                        case presentation::FadeEffect_NONE : eType = vcl::pdf::PDFWriter::PageTransition::Regular; break;
3761
3762
0
                                        case presentation::FadeEffect_RANDOM :
3763
0
                                        case presentation::FadeEffect_DISSOLVE :
3764
0
                                        default: eType = vcl::pdf::PDFWriter::PageTransition::Dissolve; break;
3765
0
                                    }
3766
0
                                }
3767
0
                            }
3768
3769
0
                            if ( xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sEffect ) ||
3770
0
                                xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sSpeed ) )
3771
0
                            {
3772
0
                                pPDFExtOutDevData->SetPageTransition( eType, nTime );
3773
0
                            }
3774
0
                        }
3775
0
                    }
3776
0
                }
3777
0
            }
3778
0
            catch (const uno::Exception&)
3779
0
            {
3780
0
            }
3781
0
        }
3782
3783
0
        aView.SdrPaintView::CompleteRedraw(pOut, aRegion, &aImplRenderPaintProc);
3784
3785
0
        if (pPDFExtOutDevData && pPage)
3786
0
        {
3787
0
            try
3788
0
            {
3789
0
                Size        aPageSize( mpDoc->GetSdPage( 0, PageKind::Standard )->GetSize() );
3790
0
                Point aPoint( 0, 0 );
3791
0
                ::tools::Rectangle   aPageRect( aPoint, aPageSize );
3792
3793
                // resolving links found in this page by the method ImpEditEngine::Paint
3794
0
                std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFExtOutDevData->GetBookmarks();
3795
0
                for ( const auto& rBookmark : rBookmarks )
3796
0
                {
3797
0
                    sal_Int32 nPage = ImplPDFGetBookmarkPage( rBookmark.aBookmark, *mpDoc );
3798
0
                    if ( nPage != -1 )
3799
0
                    {
3800
0
                        if ( rBookmark.nLinkId != -1 )
3801
0
                            pPDFExtOutDevData->SetLinkDest( rBookmark.nLinkId, pPDFExtOutDevData->CreateDest( aPageRect, nPage, vcl::pdf::PDFWriter::DestAreaType::FitRectangle ) );
3802
0
                        else
3803
0
                            pPDFExtOutDevData->DescribeRegisteredDest( rBookmark.nDestId, aPageRect, nPage, vcl::pdf::PDFWriter::DestAreaType::FitRectangle );
3804
0
                    }
3805
0
                    else
3806
0
                        pPDFExtOutDevData->SetLinkURL( rBookmark.nLinkId, rBookmark.aBookmark );
3807
0
                }
3808
0
                rBookmarks.clear();
3809
                //---> #i56629, #i40318
3810
                //get the page name, will be used as outline element in PDF bookmark pane
3811
0
                OUString aPageName = mpDoc->GetSdPage( static_cast<sal_uInt16>(nPageNumber) - 1 , PageKind::Standard )->GetName();
3812
0
                if( !aPageName.isEmpty() )
3813
0
                {
3814
                    // Destination PageNum
3815
0
                    const sal_Int32 nDestPageNum = CalcOutputPageNum(pPDFExtOutDevData, mpDoc, nPageNumber);
3816
3817
                    // insert the bookmark to this page into the NamedDestinations
3818
0
                    if( pPDFExtOutDevData->GetIsExportNamedDestinations() )
3819
0
                        pPDFExtOutDevData->CreateNamedDest(aPageName, aPageRect, nDestPageNum);
3820
3821
                    // add the name to the outline, (almost) same code as in sc/source/ui/unoobj/docuno.cxx
3822
                    // issue #i40318.
3823
3824
0
                    if( pPDFExtOutDevData->GetIsExportBookmarks() )
3825
0
                    {
3826
                        // Destination Export
3827
0
                        const sal_Int32 nDestId =
3828
0
                            pPDFExtOutDevData->CreateDest(aPageRect , nDestPageNum);
3829
3830
                        // Create a new outline item:
3831
0
                        pPDFExtOutDevData->CreateOutlineItem( -1 , aPageName, nDestId );
3832
0
                    }
3833
0
                }
3834
                //<--- #i56629, #i40318
3835
0
            }
3836
0
            catch (const uno::Exception&)
3837
0
            {
3838
0
            }
3839
3840
0
        }
3841
0
    }
3842
0
    else
3843
0
    {
3844
0
        uno::Reference< drawing::XShapes > xShapes;
3845
0
        rSelection >>= xShapes;
3846
3847
0
        if( xShapes.is() && xShapes->getCount() )
3848
0
        {
3849
0
            SdrPageView* pPV = nullptr;
3850
3851
0
            ImplRenderPaintProc  aImplRenderPaintProc( mpDoc->GetLayerAdmin(),
3852
0
                            pOldSdView ? pOldSdView->GetSdrPageView() : nullptr);
3853
3854
0
            for( sal_uInt32 i = 0, nCount = xShapes->getCount(); i < nCount; i++ )
3855
0
            {
3856
0
                uno::Reference< drawing::XShape > xShape;
3857
0
                xShapes->getByIndex( i ) >>= xShape;
3858
3859
0
                if( xShape.is() )
3860
0
                {
3861
0
                    SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xShape );
3862
0
                    if( pObj && pObj->getSdrPageFromSdrObject()
3863
0
                        && aImplRenderPaintProc.IsVisible( pObj )
3864
0
                            && aImplRenderPaintProc.IsPrintable( pObj ) )
3865
0
                    {
3866
0
                        if( !pPV )
3867
0
                            pPV = aView.ShowSdrPage( pObj->getSdrPageFromSdrObject() );
3868
3869
0
                        if( pPV )
3870
0
                            aView.MarkObj( pObj, pPV );
3871
0
                    }
3872
0
                }
3873
0
            }
3874
0
            aView.DrawMarkedObj(*pOut);
3875
0
        }
3876
0
    }
3877
0
}
3878
3879
DrawViewShell* SdXImpressDocument::GetViewShell()
3880
0
{
3881
0
    if (!mpDocShell)
3882
0
    {
3883
0
        return nullptr;
3884
0
    }
3885
3886
0
    DrawViewShell* pViewSh = dynamic_cast<DrawViewShell*>(mpDocShell->GetViewShell());
3887
0
    if (!pViewSh)
3888
0
    {
3889
0
        SAL_WARN("sd", "DrawViewShell not available!");
3890
0
        return nullptr;
3891
0
    }
3892
0
    return pViewSh;
3893
0
}
3894
3895
void SdXImpressDocument::paintTile( VirtualDevice& rDevice,
3896
                            int nOutputWidth, int nOutputHeight,
3897
                            int nTilePosX, int nTilePosY,
3898
                            ::tools::Long nTileWidth, ::tools::Long nTileHeight )
3899
0
{
3900
0
    DrawViewShell* pViewSh = GetViewShell();
3901
0
    if (!pViewSh)
3902
0
        return;
3903
3904
    // we need to skip tile invalidation for controls on rendering
3905
0
    comphelper::LibreOfficeKit::setTiledPainting(true);
3906
3907
    // Setup drawing layer to work properly. Since we use a custom VirtualDevice
3908
    // for the drawing, SdrPaintView::BeginCompleteRedraw() will call FindPaintWindow()
3909
    // unsuccessfully and use a temporary window that doesn't keep state. So patch
3910
    // the existing SdrPageWindow to use a temporary, and this way the state will be kept.
3911
    // Well, at least that's how I understand it based on Writer's RenderContextGuard,
3912
    // as the drawing layer classes lack documentation.
3913
0
    SdrPageWindow* patchedPageWindow = nullptr;
3914
0
    SdrPaintWindow* previousPaintWindow = nullptr;
3915
0
    std::unique_ptr<SdrPaintWindow> temporaryPaintWindow;
3916
0
    if(SdrView* pDrawView = pViewSh->GetDrawView())
3917
0
    {
3918
0
        if(SdrPageView* pSdrPageView = pDrawView->GetSdrPageView())
3919
0
        {
3920
0
            pSdrPageView->SetApplicationDocumentColor(pViewSh->GetViewOptions().mnDocBackgroundColor);
3921
0
            patchedPageWindow = pSdrPageView->FindPageWindow(*getDocWindow()->GetOutDev());
3922
0
            temporaryPaintWindow.reset(new SdrPaintWindow(*pDrawView, rDevice));
3923
0
            if (patchedPageWindow)
3924
0
                previousPaintWindow = patchedPageWindow->patchPaintWindow(*temporaryPaintWindow);
3925
0
        }
3926
0
    }
3927
3928
    // Scaling. Must convert from pixels to twips. We know
3929
    // that VirtualDevices use a DPI of 96.
3930
    // We specifically calculate these scales first as we're still
3931
    // in TWIPs, and might as well minimize the number of conversions.
3932
0
    const double scale = conversionFract(o3tl::Length::px, o3tl::Length::twip);
3933
0
    double scaleX = double(nOutputWidth) / nTileWidth * scale;
3934
0
    double scaleY = double(nOutputHeight) / nTileHeight * scale;
3935
3936
    // svx seems to be the only component that works natively in
3937
    // 100th mm rather than TWIP. It makes most sense just to
3938
    // convert here and in getDocumentSize, and leave the tiled
3939
    // rendering API working in TWIPs.
3940
0
    ::tools::Long nTileWidthHMM = convertTwipToMm100( nTileWidth );
3941
0
    ::tools::Long nTileHeightHMM = convertTwipToMm100( nTileHeight );
3942
0
    int nTilePosXHMM = convertTwipToMm100( nTilePosX );
3943
0
    int nTilePosYHMM = convertTwipToMm100( nTilePosY );
3944
3945
0
    MapMode aMapMode = rDevice.GetMapMode();
3946
0
    aMapMode.SetMapUnit( MapUnit::Map100thMM );
3947
0
    aMapMode.SetOrigin( Point( -nTilePosXHMM,
3948
0
                               -nTilePosYHMM) );
3949
0
    aMapMode.SetScaleX( scaleX );
3950
0
    aMapMode.SetScaleY( scaleY );
3951
3952
0
    rDevice.SetMapMode( aMapMode );
3953
3954
0
    rDevice.SetOutputSizePixel( Size(nOutputWidth, nOutputHeight), /*bErase*/false );
3955
3956
0
    Point aPoint(nTilePosXHMM, nTilePosYHMM);
3957
0
    Size aSize(nTileWidthHMM, nTileHeightHMM);
3958
0
    ::tools::Rectangle aRect(aPoint, aSize);
3959
3960
0
    SdrView* pView = pViewSh->GetDrawView();
3961
0
    if (comphelper::LibreOfficeKit::isActive())
3962
0
        pView->SetPaintTextEdit(mbPaintTextEdit);
3963
3964
0
    pViewSh->GetView()->CompleteRedraw(&rDevice, vcl::Region(aRect));
3965
3966
0
    if (comphelper::LibreOfficeKit::isActive())
3967
0
        pView->SetPaintTextEdit(true);
3968
3969
0
    LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight,
3970
0
                                         nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3971
0
    LokStarMathHelper::PaintAllInPlaceOnTile(rDevice, nOutputWidth, nOutputHeight, nTilePosX,
3972
0
                                             nTilePosY, nTileWidth, nTileHeight);
3973
3974
0
    if(patchedPageWindow != nullptr)
3975
0
        patchedPageWindow->unpatchPaintWindow(previousPaintWindow);
3976
3977
    // Draw Form controls
3978
0
    SdrView* pDrawView = pViewSh->GetDrawView();
3979
0
    SdrPageView* pPageView = pDrawView->GetSdrPageView();
3980
0
    if (pPageView != nullptr)
3981
0
    {
3982
0
        SdrPage* pPage = pPageView->GetPage();
3983
0
        ::sd::Window* pActiveWin = pViewSh->GetActiveWindow();
3984
0
        ::tools::Rectangle aTileRect(Point(nTilePosX, nTilePosY), Size(nTileWidth, nTileHeight));
3985
0
        Size aOutputSize(nOutputWidth, nOutputHeight);
3986
0
        LokControlHandler::paintControlTile(pPage, pDrawView, *pActiveWin, rDevice, aOutputSize, aTileRect);
3987
0
    }
3988
3989
0
    comphelper::LibreOfficeKit::setTiledPainting(false);
3990
0
}
3991
3992
OString SdXImpressDocument::getViewRenderState(SfxViewShell* pViewShell)
3993
0
{
3994
0
    OStringBuffer aState;
3995
0
    DrawViewShell* pView = nullptr;
3996
3997
0
    if (ViewShellBase* pShellBase = dynamic_cast<ViewShellBase*>(pViewShell))
3998
0
        pView = dynamic_cast<DrawViewShell*>(pShellBase->GetMainViewShell().get());
3999
0
    else
4000
0
        pView = GetViewShell();
4001
4002
0
    if (pView)
4003
0
    {
4004
0
        const SdViewOptions& pVOpt = pView->GetViewOptions();
4005
0
        if (mpDoc && mpDoc->GetOnlineSpell())
4006
0
            aState.append('S');
4007
0
        if (!ThemeColors::UseOnlyWhiteDocBackground())
4008
0
        {
4009
0
            if (pVOpt.mnDocBackgroundColor
4010
0
                == svtools::ColorConfig::GetDefaultColor(svtools::DOCCOLOR))
4011
0
                aState.append('D');
4012
0
        }
4013
0
        aState.append(';');
4014
4015
0
        OString aThemeName = OUStringToOString(pVOpt.msColorSchemeName, RTL_TEXTENCODING_UTF8);
4016
0
        aState.append(aThemeName);
4017
0
    }
4018
0
    return aState.makeStringAndClear();
4019
0
}
4020
4021
void SdXImpressDocument::selectPart(int nPart, int nSelect)
4022
0
{
4023
0
    DrawViewShell* pViewSh = GetViewShell();
4024
0
    if (!pViewSh)
4025
0
        return;
4026
4027
0
    pViewSh->SelectPage(nPart, nSelect);
4028
0
}
4029
4030
void SdXImpressDocument::moveSelectedParts(int nPosition, bool bDuplicate)
4031
0
{
4032
    // Duplicating is currently unsupported.
4033
0
    if (bDuplicate)
4034
0
        return;
4035
4036
0
    DrawViewShell* pViewSh = GetViewShell();
4037
0
    if (!pViewSh)
4038
0
        return;
4039
4040
0
    auto pSlideSorter
4041
0
        = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(pViewSh->GetViewShellBase());
4042
0
    sd::slidesorter::SharedPageSelection pSelectedPage
4043
0
        = pSlideSorter ? pSlideSorter->GetPageSelection() : nullptr;
4044
0
    if (!pSelectedPage)
4045
0
        return;
4046
0
    mpDoc->MovePages(nPosition, *pSelectedPage);
4047
0
}
4048
4049
OUString SdXImpressDocument::getPartInfo(int nPart)
4050
0
{
4051
0
    DrawViewShell* pViewSh = GetViewShell();
4052
0
    if (!pViewSh)
4053
0
        return OUString();
4054
4055
0
    SdPage* pSdPage = mpDoc->GetSdPage(nPart, pViewSh->GetPageKind());
4056
0
    const sal_Int16 nMasterPageCount= pViewSh->GetDoc()->GetMasterSdPageCount(pViewSh->GetPageKind());
4057
4058
0
    ::tools::JsonWriter jsonWriter;
4059
4060
0
    jsonWriter.put("masterPageCount", nMasterPageCount);
4061
0
    jsonWriter.put("mode", getEditMode());
4062
0
    jsonWriter.put("gridSnapEnabled", pViewSh->GetDrawView()->IsGridSnap());
4063
0
    jsonWriter.put("gridVisible", pViewSh->GetDrawView()->IsGridVisible());
4064
4065
    // Below information is useful when grid snapping is enabled. It let's to calculate the points we can snap to.
4066
0
    const Size gridCoarse = pViewSh->GetDrawView()->GetGridCoarse();
4067
0
    const Size innerDots = pViewSh->GetDrawView()->GetGridFine();
4068
0
    jsonWriter.put("gridCoarseWidth", gridCoarse.getWidth());
4069
0
    jsonWriter.put("gridCoarseHeight", gridCoarse.getHeight());
4070
0
    jsonWriter.put("innerSpacesX", innerDots.getWidth() ? gridCoarse.getWidth() / innerDots.getWidth() : 0);
4071
0
    jsonWriter.put("innerSpacesY", innerDots.getHeight() ? gridCoarse.getHeight() / innerDots.getHeight() : 0);
4072
4073
0
    if (pSdPage)
4074
0
        pSdPage->GetPageInfo(jsonWriter);
4075
0
    else
4076
0
        SAL_WARN("sd", "getPartInfo request for SdPage " << nPart << " that does not exist!");
4077
4078
0
    return OStringToOUString(jsonWriter.finishAndGetAsOString(), RTL_TEXTENCODING_UTF8);
4079
0
}
4080
4081
void SdXImpressDocument::setPart( int nPart, bool bAllowChangeFocus )
4082
0
{
4083
0
    DrawViewShell* pViewSh = GetViewShell();
4084
0
    if (!pViewSh)
4085
0
        return;
4086
4087
0
    pViewSh->SwitchPage( nPart, bAllowChangeFocus );
4088
0
}
4089
4090
int SdXImpressDocument::getParts()
4091
0
{
4092
0
    if (!mpDoc)
4093
0
        return 0;
4094
4095
0
    if (isMasterViewMode())
4096
0
        return mpDoc->GetMasterSdPageCount(PageKind::Standard);
4097
4098
0
    return mpDoc->GetSdPageCount(PageKind::Standard);
4099
0
}
4100
4101
int SdXImpressDocument::getPart()
4102
0
{
4103
0
    DrawViewShell* pViewSh = GetViewShell();
4104
0
    if (!pViewSh)
4105
0
        return 0;
4106
4107
0
    return pViewSh->GetViewShellBase().getPart();
4108
0
}
4109
4110
OUString SdXImpressDocument::getPartName(int nPart)
4111
0
{
4112
0
    SdPage* pPage;
4113
0
    if (isMasterViewMode())
4114
0
        pPage = mpDoc->GetMasterSdPage(nPart, PageKind::Standard);
4115
0
    else
4116
0
        pPage = mpDoc->GetSdPage(nPart, PageKind::Standard);
4117
4118
0
    if (!pPage)
4119
0
    {
4120
0
        SAL_WARN("sd", "DrawViewShell not available!");
4121
0
        return OUString();
4122
0
    }
4123
4124
0
    return pPage->GetName();
4125
0
}
4126
4127
OUString SdXImpressDocument::getPartHash(int nPart)
4128
0
{
4129
0
    SdPage* pPage;
4130
0
    if (isMasterViewMode())
4131
0
        pPage = mpDoc->GetMasterSdPage(nPart, PageKind::Standard);
4132
0
    else
4133
0
        pPage = mpDoc->GetSdPage(nPart, PageKind::Standard);
4134
4135
0
    if (!pPage)
4136
0
    {
4137
0
        SAL_WARN("sd", "DrawViewShell not available!");
4138
0
        return OUString();
4139
0
    }
4140
4141
0
    uno::Reference<drawing::XDrawPage> xDrawPage(pPage->getUnoPage(), uno::UNO_QUERY);
4142
0
    return OUString::fromUtf8(GetInterfaceHash(xDrawPage));
4143
0
}
4144
4145
bool SdXImpressDocument::isMasterViewMode()
4146
0
{
4147
0
    DrawViewShell* pViewSh = GetViewShell();
4148
0
    if (!pViewSh)
4149
0
        return false;
4150
4151
0
    if (pViewSh->GetDispatcher())
4152
0
    {
4153
0
        SfxPoolItemHolder aResult;
4154
0
        pViewSh->GetDispatcher()->QueryState(SID_SLIDE_MASTER_MODE, aResult);
4155
0
        const SfxBoolItem* isMasterViewMode(static_cast<const SfxBoolItem*>(aResult.getItem()));
4156
0
        if (isMasterViewMode && isMasterViewMode->GetValue())
4157
0
            return true;
4158
0
    }
4159
0
    return false;
4160
0
}
4161
4162
VclPtr<vcl::Window> SdXImpressDocument::getDocWindow()
4163
0
{
4164
0
    SolarMutexGuard aGuard;
4165
0
    DrawViewShell* pViewShell = GetViewShell();
4166
0
    if (!pViewShell)
4167
0
        return {};
4168
4169
0
    if (VclPtr<vcl::Window> pWindow = SfxLokHelper::getInPlaceDocWindow(pViewShell->GetViewShell()))
4170
0
        return pWindow;
4171
4172
0
    return pViewShell->GetActiveWindow();
4173
0
}
4174
4175
void SdXImpressDocument::setPartMode( int nPartMode )
4176
0
{
4177
0
    DrawViewShell* pViewSh = GetViewShell();
4178
0
    if (!pViewSh)
4179
0
        return;
4180
4181
0
    PageKind aPageKind( PageKind::Standard );
4182
0
    switch ( nPartMode )
4183
0
    {
4184
0
    case LOK_PARTMODE_SLIDES:
4185
0
        break;
4186
0
    case LOK_PARTMODE_NOTES:
4187
0
        aPageKind = PageKind::Notes;
4188
0
        break;
4189
0
    }
4190
0
    pViewSh->SetPageKind( aPageKind );
4191
    //TODO do the same as setEditMode and then can probably remove the TODOs
4192
    //from doc_setPartMode
4193
0
}
4194
4195
int SdXImpressDocument::getEditMode()
4196
0
{
4197
0
    DrawViewShell* pViewSh = GetViewShell();
4198
0
    if (!pViewSh)
4199
0
        return 0;
4200
4201
0
    return pViewSh->GetViewShellBase().getEditMode();
4202
0
}
4203
4204
void SdXImpressDocument::setEditMode(int nMode)
4205
0
{
4206
0
    SolarMutexGuard aGuard;
4207
4208
0
    DrawViewShell* pViewSh = GetViewShell();
4209
0
    if (!pViewSh)
4210
0
        return;
4211
4212
0
    pViewSh->GetViewShellBase().setEditMode(nMode);
4213
0
}
4214
4215
Size SdXImpressDocument::getDocumentSize()
4216
0
{
4217
0
    DrawViewShell* pViewSh = GetViewShell();
4218
0
    if (!pViewSh)
4219
0
        return Size();
4220
4221
0
    SdrView *pSdrView = pViewSh->GetView();
4222
0
    if (!pSdrView)
4223
0
        return Size();
4224
4225
0
    SdrPageView* pCurPageView = pSdrView->GetSdrPageView();
4226
0
    if (!pCurPageView)
4227
0
        return Size();
4228
4229
0
    Size aSize = pCurPageView->GetPageRect().GetSize();
4230
    // Convert the size in 100th mm to TWIP
4231
    // See paintTile above for further info.
4232
0
    return o3tl::convert(aSize, o3tl::Length::mm100, o3tl::Length::twip);
4233
0
}
4234
4235
Size SdXImpressDocument::getPartSize(int part)
4236
0
{
4237
0
    if (part < 0 || part > 0xFFFF)
4238
0
        return Size(0,0);
4239
4240
0
    const sal_uInt16 nSlideIndex = static_cast<sal_uInt16>(part);
4241
0
    SdPage* pPage = nullptr;
4242
0
    if (mpDoc)
4243
0
    {
4244
0
        if (isMasterViewMode())
4245
0
            pPage = mpDoc->GetMasterSdPage(nSlideIndex, PageKind::Standard);
4246
0
        else
4247
0
        {
4248
0
            DrawViewShell* pViewSh = GetViewShell();
4249
0
            PageKind ePageKind = pViewSh ? pViewSh->GetPageKind() : PageKind::Standard;
4250
0
            pPage = mpDoc->GetSdPage(nSlideIndex, ePageKind);
4251
0
        }
4252
0
    }
4253
4254
0
    if (pPage == nullptr)
4255
0
        return Size(0,0);
4256
4257
0
    Size aRectSize(pPage->GetWidth() + 1, pPage->GetHeight() + 1);
4258
0
    return o3tl::convert(aRectSize, o3tl::Length::mm100, o3tl::Length::twip);
4259
0
}
4260
4261
void SdXImpressDocument::getAllPartSize(::tools::JsonWriter& rJsonWriter)
4262
0
{
4263
0
    auto aArray = rJsonWriter.startArray("parts");
4264
0
    const int nParts = getParts();
4265
0
    for (int i = 0; i < nParts; ++i)
4266
0
    {
4267
0
        const Size aSize = getPartSize(i);
4268
0
        auto aItem = rJsonWriter.startStruct();
4269
0
        rJsonWriter.put("width", aSize.getWidth());
4270
0
        rJsonWriter.put("height", aSize.getHeight());
4271
0
    }
4272
0
}
4273
4274
void SdXImpressDocument::getPostIts(::tools::JsonWriter& rJsonWriter)
4275
0
{
4276
0
    auto commentsNode = rJsonWriter.startNode("comments");
4277
0
    if (!mpDoc)
4278
0
        return;
4279
    // Return annotations on master pages too ?
4280
0
    const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
4281
0
    for (sal_uInt16 nPage = 0; nPage < nMaxPages; ++nPage)
4282
0
    {
4283
0
        SdrPage* pPage = mpDoc->GetPage(nPage);
4284
4285
0
        for (auto const& xAnnotation : pPage->getAnnotations())
4286
0
        {
4287
0
            sal_uInt32 nID = xAnnotation->GetId();
4288
0
            OString nodeName = "comment" + OString::number(nID);
4289
0
            auto commentNode = rJsonWriter.startNode(nodeName);
4290
0
            rJsonWriter.put("id", nID);
4291
0
            rJsonWriter.put("author", xAnnotation->getAuthor());
4292
0
            rJsonWriter.put("dateTime", utl::toISO8601(xAnnotation->getDateTime()));
4293
0
            uno::Reference<text::XText> xText(xAnnotation->getTextRange());
4294
0
            rJsonWriter.put("text", xText->getString());
4295
0
            rJsonWriter.put("parthash", pPage->GetUniqueID());
4296
0
            geometry::RealPoint2D const aPoint = xAnnotation->getPosition();
4297
0
            geometry::RealSize2D const aSize = xAnnotation->getSize();
4298
0
            ::tools::Rectangle aRectangle(Point(aPoint.X * 100.0, aPoint.Y * 100.0), Size(aSize.Width * 100.0, aSize.Height * 100.0));
4299
0
            aRectangle = o3tl::toTwips(aRectangle, o3tl::Length::mm100);
4300
0
            OString sRectangle = aRectangle.toString();
4301
0
            rJsonWriter.put("rectangle", sRectangle.getStr());
4302
0
            if (xAnnotation->IsThreaded())
4303
0
            {
4304
0
                rJsonWriter.put("threaded", "true");
4305
0
                rJsonWriter.put("resolved", xAnnotation->IsResolved() ? "true" : "false");
4306
0
                rJsonWriter.put("parentId", xAnnotation->GetParentId());
4307
0
            }
4308
0
        }
4309
0
    }
4310
0
}
4311
4312
void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
4313
0
{
4314
0
    SolarMutexGuard aGuard;
4315
4316
0
    OUString sThemeName;
4317
0
    OUString sBackgroundThemeName;
4318
4319
0
    if (DrawViewShell* pViewShell = GetViewShell())
4320
0
    {
4321
0
        DrawView* pDrawView = pViewShell->GetDrawView();
4322
0
        for (const beans::PropertyValue& rValue : rArguments)
4323
0
        {
4324
0
            if (rValue.Name == ".uno:ShowBorderShadow" && rValue.Value.has<bool>())
4325
0
                pDrawView->SetPageShadowVisible(rValue.Value.get<bool>());
4326
0
            else if (rValue.Name == ".uno:Author" && rValue.Value.has<OUString>())
4327
0
                pDrawView->SetAuthor(rValue.Value.get<OUString>());
4328
0
            else if (rValue.Name == ".uno:SpellOnline" && rValue.Value.has<bool>())
4329
0
                mpDoc->SetOnlineSpell(rValue.Value.get<bool>());
4330
0
            else if (rValue.Name == ".uno:ChangeTheme" && rValue.Value.has<OUString>())
4331
0
                sThemeName = rValue.Value.get<OUString>();
4332
0
            else if (rValue.Name == ".uno:InvertBackground" && rValue.Value.has<OUString>())
4333
0
                sBackgroundThemeName = rValue.Value.get<OUString>();
4334
0
        }
4335
4336
        // Disable comments if requested
4337
0
        SdOptions* pOptions = SdModule::get()->GetSdOptions(mpDoc->GetDocumentType());
4338
0
        pOptions->SetShowComments(comphelper::LibreOfficeKit::isTiledAnnotations());
4339
4340
0
        pViewShell->SetRuler(false);
4341
0
        pViewShell->SetScrollBarsVisible(false);
4342
4343
0
        if (sd::Window* pWindow = pViewShell->GetActiveWindow())
4344
0
        {
4345
            // get the full page size in pixels
4346
0
            pWindow->EnableMapMode();
4347
0
            Size aSize(pWindow->LogicToPixel(pDrawView->GetSdrPageView()->GetPage()->GetSize()));
4348
            // Disable map mode, so that it's possible to send mouse event
4349
            // coordinates in logic units
4350
0
            pWindow->EnableMapMode(false);
4351
4352
            // arrange UI elements again with new view size
4353
0
            pViewShell->GetParentWindow()->SetSizePixel(aSize);
4354
0
            pViewShell->Resize();
4355
0
        }
4356
4357
        // Forces all images to be swapped in synchronously, this
4358
        // ensures that images are available when paintTile is called
4359
        // (whereas with async loading images start being loaded after
4360
        //  we have painted the tile, resulting in an invalidate, followed
4361
        //  by the tile being rerendered - which is wasteful and ugly).
4362
0
        pDrawView->SetSwapAsynchron(false);
4363
0
    }
4364
4365
    // when the "This document may contain formatting or content that cannot
4366
    // be saved..." dialog appears, it is auto-cancelled with tiled rendering,
4367
    // causing 'Save' being disabled; so let's always save to the original
4368
    // format
4369
0
    auto xChanges = comphelper::ConfigurationChanges::create();
4370
0
    officecfg::Office::Common::Save::Document::WarnAlienFormat::set(false, xChanges);
4371
4372
0
    if (!o3tl::IsRunningUnitTest() || !comphelper::LibreOfficeKit::isActive())
4373
0
        officecfg::Office::Impress::MultiPaneGUI::SlideSorterBar::Visible::ImpressView::set(true,xChanges);
4374
0
    xChanges->commit();
4375
4376
    // if we know what theme the user wants, then we can dispatch that now early
4377
0
    if (!sThemeName.isEmpty())
4378
0
    {
4379
0
        css::uno::Sequence<css::beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
4380
0
        {
4381
0
            { "NewTheme", uno::Any(sThemeName) }
4382
0
        }));
4383
0
        comphelper::dispatchCommand(u".uno:ChangeTheme"_ustr, aPropertyValues);
4384
0
    }
4385
0
    if (!sBackgroundThemeName.isEmpty())
4386
0
    {
4387
0
        css::uno::Sequence<css::beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
4388
0
        {
4389
0
            { "NewTheme", uno::Any(sBackgroundThemeName) }
4390
0
        }));
4391
0
        comphelper::dispatchCommand(".uno:InvertBackground", aPropertyValues);
4392
0
    }
4393
0
}
4394
4395
void SdXImpressDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
4396
0
{
4397
0
    SolarMutexGuard aGuard;
4398
0
    SfxLokHelper::postKeyEventAsync(getDocWindow(), nType, nCharCode, nKeyCode);
4399
0
}
4400
4401
void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
4402
0
{
4403
0
    SolarMutexGuard aGuard;
4404
4405
0
    DrawViewShell* pViewShell = GetViewShell();
4406
0
    if (!pViewShell)
4407
0
        return;
4408
4409
0
    constexpr double fScale = o3tl::convert(1.0, o3tl::Length::twip, o3tl::Length::px);
4410
4411
0
    if (SfxLokHelper::testInPlaceComponentMouseEventHit(
4412
0
            pViewShell->GetViewShell(), nType, nX, nY, nCount, nButtons, nModifier, fScale, fScale))
4413
0
        return;
4414
4415
    // try to forward mouse event to control
4416
0
    const Point aPointTwip(nX, nY);
4417
0
    const Point aPointHMM = o3tl::convert(aPointTwip, o3tl::Length::twip, o3tl::Length::mm100);
4418
0
    SdrView* pDrawView = pViewShell->GetDrawView();
4419
0
    SdrPageView* pPageView = pDrawView->GetSdrPageView();
4420
0
    if (!pPageView)
4421
0
    {
4422
0
        return;
4423
0
    }
4424
4425
0
    SdrPage* pPage = pPageView->GetPage();
4426
0
    ::sd::Window* pActiveWin = pViewShell->GetActiveWindow();
4427
0
    if (!pActiveWin)
4428
0
    {
4429
0
        return;
4430
0
    }
4431
4432
0
    if (LokControlHandler::postMouseEvent(pPage, pDrawView, *pActiveWin, nType, aPointHMM, nCount, nButtons, nModifier))
4433
0
            return;
4434
4435
0
    LokMouseEventData aMouseEventData(nType, aPointHMM, nCount, MouseEventModifiers::SIMPLECLICK,
4436
0
                                      nButtons, nModifier);
4437
0
    SfxLokHelper::postMouseEventAsync(pViewShell->GetActiveWindow(), aMouseEventData);
4438
0
}
4439
4440
void SdXImpressDocument::setTextSelection(int nType, int nX, int nY)
4441
0
{
4442
0
    SolarMutexGuard aGuard;
4443
4444
0
    DrawViewShell* pViewShell = GetViewShell();
4445
0
    if (!pViewShell)
4446
0
        return;
4447
4448
0
    LokChartHelper aChartHelper(pViewShell->GetViewShell());
4449
0
    if (aChartHelper.setTextSelection(nType, nX, nY))
4450
0
        return;
4451
4452
0
    Point aPoint(convertTwipToMm100(nX), convertTwipToMm100(nY));
4453
0
    switch (nType)
4454
0
    {
4455
0
    case LOK_SETTEXTSELECTION_START:
4456
0
        pViewShell->SetCursorMm100Position(aPoint, /*bPoint=*/false, /*bClearMark=*/false);
4457
0
        break;
4458
0
    case LOK_SETTEXTSELECTION_END:
4459
0
        pViewShell->SetCursorMm100Position(aPoint, /*bPoint=*/true, /*bClearMark=*/false);
4460
0
        break;
4461
0
    case LOK_SETTEXTSELECTION_RESET:
4462
0
        pViewShell->SetCursorMm100Position(aPoint, /*bPoint=*/true, /*bClearMark=*/true);
4463
0
        break;
4464
0
    default:
4465
0
        assert(false);
4466
0
        break;
4467
0
    }
4468
0
}
4469
4470
uno::Reference<datatransfer::XTransferable> SdXImpressDocument::getSelection()
4471
0
{
4472
0
    SolarMutexGuard aGuard;
4473
4474
0
    DrawViewShell* pViewShell = GetViewShell();
4475
0
    if (!pViewShell)
4476
0
        return uno::Reference<datatransfer::XTransferable>();
4477
4478
0
    return pViewShell->GetSelectionTransferable();
4479
0
}
4480
4481
void SdXImpressDocument::setGraphicSelection(int nType, int nX, int nY)
4482
0
{
4483
0
    SolarMutexGuard aGuard;
4484
4485
0
    DrawViewShell* pViewShell = GetViewShell();
4486
0
    if (!pViewShell)
4487
0
        return;
4488
4489
0
    constexpr double fScale = o3tl::convert(1.0, o3tl::Length::twip, o3tl::Length::px);
4490
4491
0
    LokChartHelper aChartHelper(pViewShell->GetViewShell());
4492
0
    if (aChartHelper.setGraphicSelection(nType, nX, nY, fScale, fScale))
4493
0
        return;
4494
4495
0
    Point aPoint(convertTwipToMm100(nX), convertTwipToMm100(nY));
4496
0
    switch (nType)
4497
0
    {
4498
0
    case LOK_SETGRAPHICSELECTION_START:
4499
0
        pViewShell->SetGraphicMm100Position(/*bStart=*/true, aPoint);
4500
0
        break;
4501
0
    case LOK_SETGRAPHICSELECTION_END:
4502
0
        pViewShell->SetGraphicMm100Position(/*bStart=*/false, aPoint);
4503
0
        break;
4504
0
    default:
4505
0
        assert(false);
4506
0
        break;
4507
0
    }
4508
0
}
4509
4510
void SdXImpressDocument::resetSelection()
4511
0
{
4512
0
    SolarMutexGuard aGuard;
4513
4514
0
    DrawViewShell* pViewShell = GetViewShell();
4515
0
    if (!pViewShell)
4516
0
        return;
4517
4518
0
    SdrView* pSdrView = pViewShell->GetView();
4519
0
    if (!pSdrView)
4520
0
        return;
4521
4522
0
    if (pSdrView->IsTextEdit())
4523
0
    {
4524
        // Reset the editeng selection.
4525
0
        pSdrView->UnmarkAll();
4526
        // Finish editing.
4527
0
        pSdrView->SdrEndTextEdit();
4528
0
    }
4529
    // Reset graphic selection.
4530
0
    pSdrView->UnmarkAll();
4531
0
}
4532
4533
void SdXImpressDocument::setPageZoom(int nPageZoom)
4534
0
{
4535
0
    SolarMutexGuard aGuard;
4536
0
    DrawViewShell* pViewShell = GetViewShell();
4537
0
    if (!pViewShell)
4538
0
        return;
4539
0
    pViewShell->RememberPageZoom(nPageZoom);
4540
0
}
4541
4542
void SdXImpressDocument::setClientVisibleArea(const ::tools::Rectangle& rRectangle)
4543
0
{
4544
0
    SolarMutexGuard aGuard;
4545
4546
0
    DrawViewShell* pViewShell = GetViewShell();
4547
0
    if (!pViewShell)
4548
0
        return;
4549
4550
0
    pViewShell->GetViewShellBase().setLOKVisibleArea(rRectangle);
4551
4552
0
    if (pViewShell->getCurrentPage()->IsCanvasPage())
4553
0
        pViewShell->RememberCanvasPageVisArea(rRectangle);
4554
0
}
4555
4556
void SdXImpressDocument::setClipboard(const uno::Reference<datatransfer::clipboard::XClipboard>& xClipboard)
4557
0
{
4558
0
    SolarMutexGuard aGuard;
4559
4560
0
    DrawViewShell* pViewShell = GetViewShell();
4561
0
    if (!pViewShell)
4562
0
        return;
4563
4564
0
    pViewShell->GetActiveWindow()->SetClipboard(xClipboard);
4565
0
}
4566
4567
bool SdXImpressDocument::isMimeTypeSupported()
4568
0
{
4569
0
    SolarMutexGuard aGuard;
4570
0
    DrawViewShell* pViewShell = GetViewShell();
4571
0
    if (!pViewShell)
4572
0
        return false;
4573
4574
0
    TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(pViewShell->GetActiveWindow()));
4575
0
    return EditEngine::HasValidData(aDataHelper.GetTransferable());
4576
0
}
4577
4578
PointerStyle SdXImpressDocument::getPointer()
4579
0
{
4580
0
    SolarMutexGuard aGuard;
4581
0
    DrawViewShell* pViewShell = GetViewShell();
4582
0
    if (!pViewShell)
4583
0
        return PointerStyle::Arrow;
4584
4585
0
    Window* pWindow = pViewShell->GetActiveWindow();
4586
0
    if (!pWindow)
4587
0
        return PointerStyle::Arrow;
4588
4589
0
    return pWindow->GetPointer();
4590
0
}
4591
4592
uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable()
4593
69
{
4594
69
    rtl::Reference<SdUnoForbiddenCharsTable> xRef = mxForbiddenCharacters.get();
4595
69
    if( !xRef )
4596
69
    {
4597
69
        xRef = new SdUnoForbiddenCharsTable( mpDoc );
4598
69
        mxForbiddenCharacters = xRef.get();
4599
69
    }
4600
69
    return xRef;
4601
69
}
4602
4603
void SdXImpressDocument::initializeDocument()
4604
12.1k
{
4605
12.1k
    if( mbClipBoard )
4606
0
        return;
4607
4608
12.1k
    switch( mpDoc->GetPageCount() )
4609
12.1k
    {
4610
0
    case 1:
4611
0
    {
4612
        // nasty hack to detect clipboard document
4613
0
        mbClipBoard = true;
4614
0
        break;
4615
0
    }
4616
9.57k
    case 0:
4617
9.57k
    {
4618
9.57k
        mpDoc->CreateFirstPages();
4619
9.57k
        mpDoc->StopWorkStartupDelay();
4620
9.57k
        break;
4621
0
    }
4622
12.1k
    }
4623
12.1k
}
4624
4625
static
4626
void getShapeClickAction(const uno::Reference<drawing::XShape> &xShape, ::tools::JsonWriter& rJsonWriter)
4627
0
{
4628
0
    bool bIsShapeVisible = true;
4629
0
    uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
4630
0
    if (!xShapeProps)
4631
0
        return;
4632
4633
0
    if (!xShapeProps->getPropertySetInfo()->hasPropertyByName( u"Visible"_ustr ))
4634
0
        return;
4635
0
    xShapeProps->getPropertyValue("Visible") >>= bIsShapeVisible;
4636
4637
0
    if (!bIsShapeVisible)
4638
0
        return;
4639
4640
0
    if (!xShapeProps->getPropertySetInfo()->hasPropertyByName( u"OnClick"_ustr ))
4641
0
        return;
4642
4643
0
    presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
4644
0
    xShapeProps->getPropertyValue(u"OnClick"_ustr) >>= eClickAction;
4645
4646
0
    if (eClickAction != presentation::ClickAction_NONE)
4647
0
    {
4648
0
        auto aShape = rJsonWriter.startStruct();
4649
4650
0
        sal_Int32 nVerb = 0;
4651
0
        OUString sBookmark;
4652
4653
0
        if (xShapeProps->getPropertySetInfo()->hasPropertyByName( u"Bookmark"_ustr ))
4654
0
            xShapeProps->getPropertyValue(u"Bookmark"_ustr) >>= sBookmark;
4655
4656
0
        {
4657
0
            auto* pObject = SdrObject::getSdrObjectFromXShape(xShape);
4658
0
            auto const& rRectangle = pObject->GetLogicRect();
4659
0
            auto aRectangle = o3tl::convert(rRectangle, o3tl::Length::mm100, o3tl::Length::twip);
4660
0
            auto aRect = rJsonWriter.startNode("bounds");
4661
0
            rJsonWriter.put("x", aRectangle.Left());
4662
0
            rJsonWriter.put("y", aRectangle.Top());
4663
0
            rJsonWriter.put("width", aRectangle.GetWidth());
4664
0
            rJsonWriter.put("height", aRectangle.GetHeight());
4665
0
        }
4666
4667
0
        {
4668
0
            auto aInteraction = rJsonWriter.startNode("clickAction");
4669
0
            switch (eClickAction)
4670
0
            {
4671
0
            case presentation::ClickAction_BOOKMARK:
4672
0
                rJsonWriter.put("action", "bookmark");
4673
0
                rJsonWriter.put("bookmark", sBookmark);
4674
0
                break;
4675
0
            case presentation::ClickAction_DOCUMENT:
4676
0
                rJsonWriter.put("action", "document");
4677
0
                rJsonWriter.put("document", sBookmark);
4678
0
                break;
4679
4680
0
            case presentation::ClickAction_PREVPAGE:
4681
0
                rJsonWriter.put("action", "prevpage");
4682
0
                break;
4683
0
            case presentation::ClickAction_NEXTPAGE:
4684
0
                rJsonWriter.put("action", "nextpage");
4685
0
                break;
4686
4687
0
            case presentation::ClickAction_FIRSTPAGE:
4688
0
                rJsonWriter.put("action", "firstpage");
4689
0
                break;
4690
0
            case presentation::ClickAction_LASTPAGE:
4691
0
                rJsonWriter.put("action", "lastpage");
4692
0
                break;
4693
4694
0
            case presentation::ClickAction_SOUND:
4695
0
                rJsonWriter.put("action", "sound");
4696
0
                rJsonWriter.put("sound", sBookmark);
4697
0
                break;
4698
4699
0
            case presentation::ClickAction_VERB:
4700
0
                rJsonWriter.put("action", "verb");
4701
0
                xShapeProps->getPropertyValue(u"Verb"_ustr) >>= nVerb;
4702
0
                rJsonWriter.put("verb", nVerb);
4703
0
                break;
4704
4705
0
            case presentation::ClickAction_PROGRAM:
4706
0
                rJsonWriter.put("action", "program");
4707
0
                rJsonWriter.put("program", sBookmark);
4708
0
                break;
4709
4710
0
            case presentation::ClickAction_MACRO:
4711
0
                rJsonWriter.put("action", "macro");
4712
0
                rJsonWriter.put("macro", sBookmark);
4713
0
                break;
4714
4715
0
            case presentation::ClickAction_STOPPRESENTATION:
4716
0
                rJsonWriter.put("action", "stoppresentation");
4717
0
                break;
4718
4719
0
            default:
4720
0
                break;
4721
0
            }
4722
0
        }
4723
0
    }
4724
0
}
4725
4726
OString SdXImpressDocument::getPresentationInfo(bool bAllyState) const
4727
0
{
4728
0
    ::tools::JsonWriter aJsonWriter;
4729
4730
0
    try
4731
0
    {
4732
0
        rtl::Reference<SdDrawPagesAccess> xDrawPages = const_cast<SdXImpressDocument*>(this)->getSdDrawPages();
4733
        // size in twips
4734
0
        Size aDocSize = const_cast<SdXImpressDocument*>(this)->getDocumentSize();
4735
0
        aJsonWriter.put("docWidth", aDocSize.getWidth());
4736
0
        aJsonWriter.put("docHeight", aDocSize.getHeight());
4737
4738
0
        sd::PresentationSettings const& rSettings = mpDoc->getPresentationSettings();
4739
4740
0
        const bool bIsEndless = rSettings.mbEndless;
4741
0
        aJsonWriter.put("isEndless", bIsEndless);
4742
4743
0
        if (bIsEndless) {
4744
0
            const sal_Int32 nPauseTimeout = rSettings.mnPauseTimeout;
4745
0
            aJsonWriter.put("loopAndRepeatDuration", nPauseTimeout);
4746
0
        }
4747
4748
        // Section data for COOL slide panel
4749
0
        {
4750
0
            sd::SlideSectionManager& rSectionMgr = mpDoc->GetSectionManager();
4751
0
            sal_Int32 nSectionCount = rSectionMgr.GetSectionCount();
4752
0
            if (nSectionCount > 0)
4753
0
            {
4754
0
                sal_uInt16 nPageCount = mpDoc->GetSdPageCount(PageKind::Standard);
4755
0
                auto aSectionsArray = aJsonWriter.startArray("sections");
4756
0
                for (sal_Int32 i = 0; i < nSectionCount; ++i)
4757
0
                {
4758
0
                    const sd::SlideSection& rSection = rSectionMgr.GetSection(i);
4759
0
                    sal_Int32 nSectionSlideCount
4760
0
                        = (i + 1 < nSectionCount)
4761
0
                              ? rSectionMgr.GetSection(i + 1).mnStartIndex - rSection.mnStartIndex
4762
0
                              : nPageCount - rSection.mnStartIndex;
4763
4764
0
                    auto aSectionNode = aJsonWriter.startStruct();
4765
0
                    aJsonWriter.put("name", rSection.maName);
4766
0
                    if (!rSection.maId.isEmpty())
4767
0
                        aJsonWriter.put("id", rSection.maId);
4768
0
                    aJsonWriter.put("startIndex", rSection.mnStartIndex);
4769
0
                    aJsonWriter.put("slideCount", nSectionSlideCount);
4770
0
                }
4771
0
            }
4772
0
        }
4773
4774
0
        auto aSlideList = aJsonWriter.startArray("slides");
4775
0
        sal_Int32 nSlideCount = xDrawPages->getCount();
4776
0
        for (sal_Int32 i = 0; i < nSlideCount; ++i)
4777
0
        {
4778
0
            SdGenericDrawPage* pSlide(xDrawPages->getDrawPageByIndex(i));
4779
0
            SdPage* pPage = SdPage::getImplementation(pSlide);
4780
0
            if (!pPage)
4781
0
            {
4782
0
                SAL_WARN("sd", "slide: " << i << " is disposed, skipping");
4783
0
                continue;
4784
0
            }
4785
4786
0
            bool bIsVisible = true; // default visible
4787
0
            pSlide->getPropertyValue("Visible") >>= bIsVisible;
4788
4789
0
            if (!bIsVisible)
4790
0
            {
4791
0
                auto aSlideNode = aJsonWriter.startStruct();
4792
0
                std::string sSlideHash = GetInterfaceHash(cppu::getXWeak(pSlide));
4793
0
                aJsonWriter.put("hash", sSlideHash);
4794
0
                aJsonWriter.put("index", i);
4795
0
                aJsonWriter.put("hidden", true);
4796
0
                aJsonWriter.put("uniqueID", pPage->GetUniqueID());
4797
0
            }
4798
0
            else
4799
0
            {
4800
0
                auto aSlideNode = aJsonWriter.startStruct();
4801
0
                std::string sSlideHash = GetInterfaceHash(cppu::getXWeak(pSlide));
4802
0
                aJsonWriter.put("hash", sSlideHash);
4803
0
                aJsonWriter.put("index", i);
4804
0
                aJsonWriter.put("uniqueID", pPage->GetUniqueID());
4805
4806
0
                auto aName = SdDrawPage::getPageApiNameFromUiName(pPage->GetName());
4807
0
                aJsonWriter.put("name", aName);
4808
4809
0
                if (bAllyState)
4810
0
                {
4811
0
                    OUStringBuffer aHtml;
4812
0
                    SdrOutliner* pOutliner = mpDoc->GetInternalOutliner();
4813
0
                    if (pOutliner)
4814
0
                    {
4815
0
                        SdHTMLFilter::ExportPage(pOutliner, pPage, aHtml);
4816
0
                        aJsonWriter.put("a11y", aHtml.makeStringAndClear());
4817
0
                        pOutliner->Clear();
4818
0
                    }
4819
0
                }
4820
4821
0
                bool bIsDrawPageEmpty = pSlide->getCount() == 0;
4822
0
                aJsonWriter.put("empty", bIsDrawPageEmpty);
4823
4824
                // Notes
4825
0
                SdPage* pNotesPage = mpDoc->GetSdPage((pPage->GetPageNum() - 1) >> 1, PageKind::Notes);
4826
0
                if (pNotesPage)
4827
0
                {
4828
0
                    SdrObject* pItObj = nullptr;
4829
0
                    SdrObject* pNotes = pNotesPage->GetPresObj(PresObjKind::Notes);
4830
4831
0
                    if (!pNotes)
4832
0
                    {
4833
0
                        for (size_t nNote = 0; nNote < pNotesPage->GetObjCount(); nNote++)
4834
0
                        {
4835
0
                            pItObj = pNotesPage->GetObj(nNote);
4836
4837
0
                            if (pItObj && pItObj->HasText() &&
4838
0
                                (pItObj->GetObjIdentifier() == SdrObjKind::Text
4839
0
                                 || pItObj->GetObjIdentifier() == SdrObjKind::TitleText
4840
0
                                 || pItObj->GetObjIdentifier() == SdrObjKind::OutlineText))
4841
0
                            {
4842
0
                                pNotes = pItObj;
4843
0
                                break;
4844
0
                            }
4845
0
                        }
4846
0
                    }
4847
4848
0
                    if (pNotes)
4849
0
                    {
4850
0
                        OUStringBuffer strNotes;
4851
0
                        OutlinerParaObject* pPara = pNotes->GetOutlinerParaObject();
4852
0
                        if (pPara)
4853
0
                        {
4854
0
                            const EditTextObject& rText = pPara->GetTextObject();
4855
0
                            for (sal_Int32 nNote = 0; nNote < rText.GetParagraphCount(); nNote++)
4856
0
                            {
4857
0
                                strNotes.append(rText.GetText(nNote));
4858
0
                            }
4859
0
                            aJsonWriter.put("notes", strNotes.makeStringAndClear());
4860
0
                        }
4861
0
                    }
4862
0
                }
4863
4864
0
                SdMasterPage* pMasterPage = nullptr;
4865
0
                SdDrawPage* pMasterPageTarget(dynamic_cast<SdDrawPage*>(pSlide));
4866
0
                if (pMasterPageTarget)
4867
0
                {
4868
0
                    pMasterPage = pMasterPageTarget->getSdMasterPage();
4869
0
                    if (pMasterPage)
4870
0
                    {
4871
0
                        std::string sMPHash = GetInterfaceHash(cppu::getXWeak(pMasterPage));
4872
0
                        aJsonWriter.put("masterPage", sMPHash);
4873
4874
0
                        bool bBackgroundObjectsVisibility = true; // default visible
4875
0
                        pSlide->getPropertyValue("IsBackgroundObjectsVisible") >>= bBackgroundObjectsVisibility;
4876
0
                        aJsonWriter.put("masterPageObjectsVisibility", bBackgroundObjectsVisibility);
4877
0
                    }
4878
0
                }
4879
4880
0
                bool bBackgroundVisibility = true; // default visible
4881
0
                pSlide->getPropertyValue("IsBackgroundVisible")  >>= bBackgroundVisibility;
4882
0
                if (bBackgroundVisibility)
4883
0
                {
4884
0
                    SlideBackgroundInfo aSlideBackgroundInfo(pSlide, static_cast<SvxDrawPage*>(pMasterPage));
4885
0
                    if (aSlideBackgroundInfo.hasBackground())
4886
0
                    {
4887
0
                        auto aBackgroundNode = aJsonWriter.startNode("background");
4888
0
                        aJsonWriter.put("isCustom", aSlideBackgroundInfo.slideHasOwnBackground());
4889
0
                        if (aSlideBackgroundInfo.isSolidColor())
4890
0
                        {
4891
0
                            aJsonWriter.put("fillColor", aSlideBackgroundInfo.getFillColorAsRGBA());
4892
0
                        }
4893
0
                    }
4894
0
                }
4895
4896
0
                {
4897
0
                    auto aVideoList = aJsonWriter.startArray("videos");
4898
0
                    SdrObjListIter aIterator(pPage, SdrIterMode::DeepWithGroups);
4899
0
                    while (aIterator.IsMore())
4900
0
                    {
4901
0
                        auto* pObject = aIterator.Next();
4902
0
                        if (pObject->GetObjIdentifier() == SdrObjKind::Media)
4903
0
                        {
4904
0
                            auto aVideosNode = aJsonWriter.startStruct();
4905
0
                            auto* pMediaObject = static_cast<SdrMediaObj*>(pObject);
4906
0
                            auto const& rRectangle = pMediaObject->GetLogicRect();
4907
0
                            auto aRectangle = o3tl::convert(rRectangle, o3tl::Length::mm100, o3tl::Length::twip);
4908
0
                            aJsonWriter.put("id", reinterpret_cast<sal_uInt64>(pMediaObject));
4909
0
                            aJsonWriter.put("url", pMediaObject->getTempURL());
4910
0
                            aJsonWriter.put("x", aRectangle.Left());
4911
0
                            aJsonWriter.put("y", aRectangle.Top());
4912
0
                            aJsonWriter.put("width", aRectangle.GetWidth());
4913
0
                            aJsonWriter.put("height", aRectangle.GetHeight());
4914
0
                        }
4915
0
                    }
4916
0
                }
4917
4918
0
                uno::Reference<drawing::XShapes> const xShapes(cppu::getXWeak(pSlide), uno::UNO_QUERY_THROW);
4919
0
                if (xShapes.is())
4920
0
                {
4921
0
                    auto aInteractions = aJsonWriter.startArray("interactions");
4922
0
                    auto count = xShapes->getCount();
4923
0
                    for (auto j = 0; j < count; j++)
4924
0
                    {
4925
0
                        auto xObject = xShapes->getByIndex(j);
4926
0
                        uno::Reference<drawing::XShape> xShape(xObject, uno::UNO_QUERY);
4927
0
                        if (!xShape.is())
4928
0
                        {
4929
0
                            continue;
4930
0
                        }
4931
4932
0
                        getShapeClickAction(xShape, aJsonWriter);
4933
0
                    }
4934
0
                }
4935
4936
0
                sal_Int32 nTransitionType = 0;
4937
0
                pSlide->getPropertyValue("TransitionType") >>= nTransitionType;
4938
4939
0
                if (nTransitionType != 0)
4940
0
                {
4941
0
                    auto iterator = constTransitionTypeToString.find(nTransitionType);
4942
4943
0
                    if (iterator != constTransitionTypeToString.end())
4944
0
                    {
4945
0
                        aJsonWriter.put("transitionType", iterator->second);
4946
4947
0
                        sal_Int32 nTransitionSubtype = 0;
4948
0
                        pSlide->getPropertyValue("TransitionSubtype") >>= nTransitionSubtype;
4949
4950
0
                        auto iteratorSubType = constTransitionSubTypeToString.find(nTransitionSubtype);
4951
0
                        if (iteratorSubType != constTransitionSubTypeToString.end())
4952
0
                        {
4953
0
                            aJsonWriter.put("transitionSubtype", iteratorSubType->second);
4954
0
                        }
4955
0
                        else
4956
0
                        {
4957
0
                            SAL_WARN("sd", "Transition sub-type unknown: " << nTransitionSubtype);
4958
0
                        }
4959
4960
0
                        if (bAllyState)
4961
0
                        {
4962
0
                            const TransitionPresetList& rList = TransitionPreset::getTransitionPresetList();
4963
0
                            auto aTransition = std::find_if(rList.begin(), rList.end(),
4964
0
                                                            [nTransitionType,
4965
0
                                                             nTransitionSubtype](const TransitionPresetPtr& rxPreset) {
4966
0
                                                                return (rxPreset->getTransition() == nTransitionType)
4967
0
                                                                    && (rxPreset->getSubtype() == nTransitionSubtype);
4968
0
                                                            });
4969
4970
0
                            if (aTransition != rList.end())
4971
0
                            {
4972
0
                                aJsonWriter.put("transitionLabel", (*aTransition)->getSetLabel());
4973
0
                            }
4974
0
                        }
4975
4976
0
                        bool nTransitionDirection = false;
4977
0
                        pSlide->getPropertyValue("TransitionDirection") >>= nTransitionDirection;
4978
0
                        aJsonWriter.put("transitionDirection", nTransitionDirection);
4979
4980
                        // fade color
4981
0
                        if ((nTransitionType == TransitionType::FADE)
4982
0
                                && ((nTransitionSubtype == TransitionSubType::FADETOCOLOR)
4983
0
                                    || (nTransitionSubtype == TransitionSubType::FADEFROMCOLOR)
4984
0
                                    || (nTransitionSubtype == TransitionSubType::FADEOVERCOLOR)))
4985
0
                        {
4986
0
                            sal_Int32 nFadeColor = 0;
4987
0
                            pSlide->getPropertyValue("TransitionFadeColor") >>= nFadeColor;
4988
0
                            OUStringBuffer sTmpBuf;
4989
0
                            ::sax::Converter::convertColor(sTmpBuf, nFadeColor);
4990
0
                            aJsonWriter.put("transitionFadeColor", sTmpBuf.makeStringAndClear());
4991
0
                        }
4992
0
                    }
4993
4994
0
                    double nTransitionDuration(0.0);
4995
0
                    if( pSlide->getPropertySetInfo()->hasPropertyByName( "TransitionDuration" ) &&
4996
0
                        (pSlide->getPropertyValue( "TransitionDuration" ) >>= nTransitionDuration ) && nTransitionDuration != 0.0 )
4997
0
                    {
4998
                        // convert transitionDuration time to ms
4999
0
                        aJsonWriter.put("transitionDuration", nTransitionDuration * 1000);
5000
0
                    }
5001
0
                }
5002
5003
0
                sal_Int32 nChange(0);
5004
0
                if( pSlide->getPropertySetInfo()->hasPropertyByName( "Change" ) &&
5005
0
                        (pSlide->getPropertyValue( "Change" ) >>= nChange ) && nChange == 1 )
5006
0
                {
5007
0
                    double fSlideDuration(0);
5008
0
                    if( pSlide->getPropertySetInfo()->hasPropertyByName( "HighResDuration" ) &&
5009
0
                            (pSlide->getPropertyValue( "HighResDuration" ) >>= fSlideDuration) )
5010
0
                    {
5011
                        // convert slide duration time to ms
5012
0
                        aJsonWriter.put("nextSlideDuration", fSlideDuration * 1000);
5013
0
                    }
5014
0
                }
5015
5016
5017
0
                AnimationsExporter aAnimationExporter(aJsonWriter, pSlide);
5018
0
                if (aAnimationExporter.hasEffects())
5019
0
                {
5020
0
                    {
5021
0
                        auto aAnimationsNode = aJsonWriter.startNode("animations");
5022
0
                        aAnimationExporter.exportAnimations();
5023
0
                    }
5024
0
                    aAnimationExporter.exportTriggers();
5025
0
                }
5026
0
            }
5027
0
        }
5028
0
    }
5029
0
    catch (uno::Exception& )
5030
0
    {
5031
0
        TOOLS_WARN_EXCEPTION("sd", "SdXImpressDocument::getSlideShowInfo ... maybe some property can't be retrieved");
5032
0
    }
5033
0
    return aJsonWriter.finishAndGetAsOString();
5034
0
}
5035
5036
namespace
5037
{
5038
bool isRequestedSlideValid(SdDrawDocument* mpDoc, sal_Int32 nSlideNumber, const std::string& slideHash)
5039
0
{
5040
0
    try
5041
0
    {
5042
0
        SdXImpressDocument* pDoc = mpDoc->getUnoModel();
5043
0
        rtl::Reference<SdDrawPagesAccess> xDrawPages = pDoc->getSdDrawPages();
5044
0
        SdGenericDrawPage* pSlide(xDrawPages->getDrawPageByIndex(nSlideNumber));
5045
0
        if (pSlide)
5046
0
        {
5047
0
            return slideHash == GetInterfaceHash(cppu::getXWeak(pSlide));
5048
0
        }
5049
0
    }
5050
0
    catch (uno::Exception&)
5051
0
    {
5052
0
        TOOLS_WARN_EXCEPTION( "sd", "SdXImpressDocument::createLOKSlideRenderer: failed" );
5053
0
    }
5054
0
    return false;
5055
0
}
5056
}
5057
5058
bool SdXImpressDocument::createSlideRenderer(
5059
    const OString& rSlideHash,
5060
    sal_Int32 nSlideNumber, sal_Int32& nViewWidth, sal_Int32& nViewHeight,
5061
    bool bRenderBackground, bool bRenderMasterPage)
5062
0
{
5063
0
    std::string sSlideHash(rSlideHash);
5064
0
    if (!isRequestedSlideValid(mpDoc, nSlideNumber, sSlideHash))
5065
0
        return false;
5066
5067
0
    SdPage* pPage = mpDoc->GetSdPage(sal_uInt16(nSlideNumber), PageKind::Standard);
5068
0
    if (!pPage)
5069
0
        return false;
5070
5071
0
    mpSlideshowLayerRenderer.reset(new SlideshowLayerRenderer(*pPage, rSlideHash, bRenderBackground, bRenderMasterPage));
5072
0
    Size aDesiredSize(nViewWidth, nViewHeight);
5073
0
    Size aCalculatedSize = mpSlideshowLayerRenderer->calculateAndSetSizePixel(aDesiredSize);
5074
0
    nViewWidth = aCalculatedSize.Width();
5075
0
    nViewHeight = aCalculatedSize.Height();
5076
0
    return true;
5077
0
}
5078
5079
void SdXImpressDocument::postSlideshowCleanup()
5080
0
{
5081
0
    DrawViewShell* pViewSh = GetViewShell();
5082
0
    if (!pViewSh)
5083
0
        return;
5084
5085
0
    pViewSh->destroyXSlideShowInstance();
5086
0
}
5087
5088
bool SdXImpressDocument::renderNextSlideLayer(unsigned char* pBuffer, bool& bIsBitmapLayer, double& rScale, OUString& rJsonMsg)
5089
0
{
5090
0
    bool bDone = true;
5091
5092
0
    if (!mpSlideshowLayerRenderer)
5093
0
        return bDone;
5094
5095
0
    OString sMsg;
5096
0
    bool bOK = mpSlideshowLayerRenderer->render(pBuffer, bIsBitmapLayer, rScale, sMsg);
5097
5098
0
    if (bOK)
5099
0
    {
5100
0
        rJsonMsg = OUString::fromUtf8(sMsg);
5101
0
        bDone = false;
5102
0
    }
5103
5104
0
    return bDone;
5105
0
}
5106
5107
SdrModel& SdXImpressDocument::getSdrModelFromUnoModel() const
5108
0
{
5109
0
    OSL_ENSURE(GetDoc(), "No SdrModel in draw/Impress, should not happen");
5110
0
    return *GetDoc(); // TTTT should be reference
5111
0
}
5112
5113
void SAL_CALL SdXImpressDocument::dispose()
5114
23.7k
{
5115
23.7k
    if( mbDisposed )
5116
0
        return;
5117
5118
23.7k
    ::SolarMutexGuard aGuard;
5119
5120
23.7k
    if( mpDoc )
5121
23.7k
    {
5122
23.7k
        EndListening( *mpDoc );
5123
23.7k
        mpDoc = nullptr;
5124
23.7k
    }
5125
5126
    // Call the base class dispose() before setting the mbDisposed flag
5127
    // to true.  The reason for this is that if close() has not yet been
5128
    // called this is done in SfxBaseModel::dispose().  At the end of
5129
    // that dispose() is called again.  It is important to forward this
5130
    // second dispose() to the base class, too.
5131
    // As a consequence the following code has to be able to be run twice.
5132
23.7k
    SfxBaseModel::dispose();
5133
23.7k
    mbDisposed = true;
5134
5135
23.7k
    rtl::Reference< SdDocLinkTargets > xLinks( mxLinks );
5136
23.7k
    if( xLinks.is() )
5137
0
    {
5138
0
        xLinks->dispose();
5139
0
        xLinks = nullptr;
5140
0
    }
5141
5142
23.7k
    rtl::Reference< SdDrawPagesAccess > xDrawPagesAccess( mxDrawPagesAccess );
5143
23.7k
    if( xDrawPagesAccess.is() )
5144
0
    {
5145
0
        xDrawPagesAccess->dispose();
5146
0
        xDrawPagesAccess = nullptr;
5147
0
    }
5148
5149
23.7k
    rtl::Reference< SdMasterPagesAccess > xMasterPagesAccess( mxMasterPagesAccess );
5150
23.7k
    if( xDrawPagesAccess.is() )
5151
0
    {
5152
0
        xMasterPagesAccess->dispose();
5153
0
        xMasterPagesAccess = nullptr;
5154
0
    }
5155
5156
23.7k
    rtl::Reference< SdLayerManager > xLayerManager( mxLayerManager );
5157
23.7k
    if( xLayerManager.is() )
5158
0
    {
5159
0
        xLayerManager->dispose();
5160
0
        xLayerManager = nullptr;
5161
0
    }
5162
5163
23.7k
    mxDashTable = nullptr;
5164
23.7k
    mxGradientTable = nullptr;
5165
23.7k
    mxHatchTable = nullptr;
5166
23.7k
    mxBitmapTable = nullptr;
5167
23.7k
    mxTransGradientTable = nullptr;
5168
23.7k
    mxMarkerTable = nullptr;
5169
23.7k
    mxDrawingPool = nullptr;
5170
23.7k
    mpDocShell = nullptr;
5171
23.7k
}
5172
5173
SdDrawPagesAccess::SdDrawPagesAccess( SdXImpressDocument& rMyModel )  noexcept
5174
12.0k
:   mpModel( &rMyModel)
5175
12.0k
{
5176
12.0k
}
5177
5178
SdDrawPagesAccess::~SdDrawPagesAccess() noexcept
5179
12.0k
{
5180
12.0k
}
5181
5182
// XIndexAccess
5183
sal_Int32 SAL_CALL SdDrawPagesAccess::getCount()
5184
69
{
5185
69
    ::SolarMutexGuard aGuard;
5186
5187
69
    if( nullptr == mpModel )
5188
0
        throw lang::DisposedException();
5189
5190
69
    return mpModel->mpDoc->GetSdPageCount( PageKind::Standard );
5191
69
}
5192
5193
uno::Any SAL_CALL SdDrawPagesAccess::getByIndex( sal_Int32 Index )
5194
9.99k
{
5195
9.99k
    uno::Reference< drawing::XDrawPage > xDrawPage( getDrawPageByIndex(Index) );
5196
9.99k
    return uno::Any(xDrawPage);
5197
9.99k
}
5198
5199
SdGenericDrawPage* SdDrawPagesAccess::getDrawPageByIndex( sal_Int32 Index )
5200
9.99k
{
5201
9.99k
    ::SolarMutexGuard aGuard;
5202
5203
9.99k
    if( nullptr == mpModel )
5204
0
        throw lang::DisposedException();
5205
5206
9.99k
    if( (Index < 0) || (Index >= mpModel->mpDoc->GetSdPageCount( PageKind::Standard ) ) )
5207
0
        throw lang::IndexOutOfBoundsException();
5208
5209
9.99k
    SdPage* pPage = mpModel->mpDoc->GetSdPage( static_cast<sal_uInt16>(Index), PageKind::Standard );
5210
9.99k
    if( pPage )
5211
9.99k
        return dynamic_cast<SdGenericDrawPage*>( pPage->getUnoPage().get() );
5212
5213
0
    return nullptr;
5214
9.99k
}
5215
5216
// XNameAccess
5217
uno::Any SAL_CALL SdDrawPagesAccess::getByName( const OUString& aName )
5218
0
{
5219
0
    ::SolarMutexGuard aGuard;
5220
5221
0
    if( nullptr == mpModel )
5222
0
        throw lang::DisposedException();
5223
5224
0
    if( !aName.isEmpty() )
5225
0
    {
5226
0
        const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PageKind::Standard );
5227
0
        sal_uInt16 nPage;
5228
0
        for( nPage = 0; nPage < nCount; nPage++ )
5229
0
        {
5230
0
            SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PageKind::Standard );
5231
0
            if(nullptr == pPage)
5232
0
                continue;
5233
5234
0
            if( aName == SdDrawPage::getPageApiName( pPage ) )
5235
0
            {
5236
0
                uno::Any aAny;
5237
0
                uno::Reference< drawing::XDrawPage >  xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
5238
0
                aAny <<= xDrawPage;
5239
0
                return aAny;
5240
0
            }
5241
0
        }
5242
0
    }
5243
5244
0
    throw container::NoSuchElementException();
5245
0
}
5246
5247
uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getElementNames()
5248
0
{
5249
0
    ::SolarMutexGuard aGuard;
5250
5251
0
    if( nullptr == mpModel )
5252
0
        throw lang::DisposedException();
5253
5254
0
    const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PageKind::Standard );
5255
0
    uno::Sequence< OUString > aNames( nCount );
5256
0
    OUString* pNames = aNames.getArray();
5257
5258
0
    sal_uInt16 nPage;
5259
0
    for( nPage = 0; nPage < nCount; nPage++ )
5260
0
    {
5261
0
        SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PageKind::Standard );
5262
0
        *pNames++ = SdDrawPage::getPageApiName( pPage );
5263
0
    }
5264
5265
0
    return aNames;
5266
0
}
5267
5268
sal_Bool SAL_CALL SdDrawPagesAccess::hasByName( const OUString& aName )
5269
0
{
5270
0
    ::SolarMutexGuard aGuard;
5271
5272
0
    if( nullptr == mpModel )
5273
0
        throw lang::DisposedException();
5274
5275
0
    const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PageKind::Standard );
5276
0
    sal_uInt16 nPage;
5277
0
    for( nPage = 0; nPage < nCount; nPage++ )
5278
0
    {
5279
0
        SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PageKind::Standard );
5280
0
        if(nullptr == pPage)
5281
0
            continue;
5282
5283
0
        if( aName == SdDrawPage::getPageApiName( pPage ) )
5284
0
            return true;
5285
0
    }
5286
5287
0
    return false;
5288
0
}
5289
5290
// XElementAccess
5291
uno::Type SAL_CALL SdDrawPagesAccess::getElementType()
5292
0
{
5293
0
    return cppu::UnoType<drawing::XDrawPage>::get();
5294
0
}
5295
5296
sal_Bool SAL_CALL SdDrawPagesAccess::hasElements()
5297
0
{
5298
0
    return getCount() > 0;
5299
0
}
5300
5301
// XDrawPages
5302
5303
/**
5304
 * Creates a new page with model at the specified position.
5305
 * @returns corresponding SdDrawPage
5306
 */
5307
uno::Reference< drawing::XDrawPage > SAL_CALL SdDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex )
5308
188k
{
5309
188k
    ::SolarMutexGuard aGuard;
5310
188k
    comphelper::ProfileZone aZone("insertNewByIndex");
5311
5312
188k
    if( nullptr == mpModel )
5313
0
        throw lang::DisposedException();
5314
5315
188k
    if( mpModel->mpDoc )
5316
188k
    {
5317
188k
        SdPage* pPage = mpModel->InsertSdPage( static_cast<sal_uInt16>(nIndex), false );
5318
188k
        if( pPage )
5319
188k
        {
5320
188k
            uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
5321
188k
            return xDrawPage;
5322
188k
        }
5323
188k
    }
5324
0
    uno::Reference< drawing::XDrawPage > xDrawPage;
5325
0
    return xDrawPage;
5326
188k
}
5327
5328
/**
5329
 * Removes the specified SdDrawPage from the model and the internal list. It
5330
 * only works, if there is at least one *normal* page in the model after
5331
 * removing this page.
5332
 */
5333
void SAL_CALL SdDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
5334
0
{
5335
0
    ::SolarMutexGuard aGuard;
5336
5337
0
    if( nullptr == mpModel || mpModel->mpDoc == nullptr )
5338
0
        throw lang::DisposedException();
5339
5340
0
    SdDrawDocument& rDoc = *mpModel->mpDoc;
5341
5342
0
    sal_uInt16 nPageCount = rDoc.GetSdPageCount( PageKind::Standard );
5343
0
    if( nPageCount > 1 )
5344
0
    {
5345
        // get pPage from xPage and determine the Id (nPos ) afterwards
5346
0
        SdDrawPage* pSvxPage = comphelper::getFromUnoTunnel<SdDrawPage>( xPage );
5347
0
        if( pSvxPage )
5348
0
        {
5349
0
            SdPage* pPage = static_cast<SdPage*>(pSvxPage->GetSdrPage());
5350
0
            if(pPage && ( pPage->GetPageKind() == PageKind::Standard ) )
5351
0
            {
5352
0
                sal_uInt16 nPage = pPage->GetPageNum();
5353
5354
0
                SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetPage( nPage+1 ) );
5355
5356
0
                bool bUndo = rDoc.IsUndoEnabled();
5357
0
                if( bUndo )
5358
0
                {
5359
                    // Add undo actions and delete the pages.  The order of adding
5360
                    // the undo actions is important.
5361
0
                    rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) );
5362
0
                    if (pNotesPage)
5363
0
                    {
5364
0
                        rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
5365
0
                    }
5366
0
                    rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
5367
0
                }
5368
5369
0
                rDoc.RemovePage( nPage ); // the page
5370
0
                if (pNotesPage)
5371
0
                {
5372
0
                    rDoc.RemovePage( nPage ); // the notes page
5373
0
                }
5374
5375
0
                if( bUndo )
5376
0
                {
5377
0
                    rDoc.EndUndo();
5378
0
                }
5379
0
            }
5380
0
        }
5381
0
    }
5382
5383
0
    mpModel->SetModified();
5384
0
}
5385
5386
// XServiceInfo
5387
5388
OUString SAL_CALL SdDrawPagesAccess::getImplementationName(  )
5389
0
{
5390
0
    return u"SdDrawPagesAccess"_ustr;
5391
0
}
5392
5393
sal_Bool SAL_CALL SdDrawPagesAccess::supportsService( const OUString& ServiceName )
5394
0
{
5395
0
    return cppu::supportsService(this, ServiceName);
5396
0
}
5397
5398
uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getSupportedServiceNames(  )
5399
0
{
5400
0
    return { u"com.sun.star.drawing.DrawPages"_ustr };
5401
0
}
5402
5403
// XComponent
5404
void SAL_CALL SdDrawPagesAccess::dispose(  )
5405
0
{
5406
0
    mpModel = nullptr;
5407
0
}
5408
5409
void SAL_CALL SdDrawPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >&  )
5410
0
{
5411
0
    OSL_FAIL( "not implemented!" );
5412
0
}
5413
5414
void SAL_CALL SdDrawPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >&  )
5415
0
{
5416
0
    OSL_FAIL( "not implemented!" );
5417
0
}
5418
5419
5420
SdMasterPagesAccess::SdMasterPagesAccess( SdXImpressDocument& rMyModel ) noexcept
5421
2.24k
:   mpModel(&rMyModel)
5422
2.24k
{
5423
2.24k
}
5424
5425
SdMasterPagesAccess::~SdMasterPagesAccess() noexcept
5426
2.24k
{
5427
2.24k
}
5428
5429
// XComponent
5430
void SAL_CALL SdMasterPagesAccess::dispose(  )
5431
0
{
5432
0
    mpModel = nullptr;
5433
0
}
5434
5435
void SAL_CALL SdMasterPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >&  )
5436
0
{
5437
0
    OSL_FAIL( "not implemented!" );
5438
0
}
5439
5440
void SAL_CALL SdMasterPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >&  )
5441
0
{
5442
0
    OSL_FAIL( "not implemented!" );
5443
0
}
5444
5445
// XIndexAccess
5446
sal_Int32 SAL_CALL SdMasterPagesAccess::getCount()
5447
13.2k
{
5448
13.2k
    ::SolarMutexGuard aGuard;
5449
5450
13.2k
    if( nullptr == mpModel->mpDoc )
5451
0
        throw lang::DisposedException();
5452
5453
13.2k
    return mpModel->mpDoc->GetMasterSdPageCount(PageKind::Standard);
5454
13.2k
}
5455
5456
/**
5457
 * Provides a drawing::XDrawPage interface for accessing the Masterpage at the
5458
 * specified position in the model.
5459
 */
5460
uno::Any SAL_CALL SdMasterPagesAccess::getByIndex( sal_Int32 Index )
5461
2.25k
{
5462
2.25k
    ::SolarMutexGuard aGuard;
5463
2.25k
    comphelper::ProfileZone aZone("SdMasterPagesAccess::getByIndex");
5464
5465
2.25k
    if( nullptr == mpModel )
5466
0
        throw lang::DisposedException();
5467
5468
2.25k
    uno::Any aAny;
5469
5470
2.25k
    if( (Index < 0) || (Index >= mpModel->mpDoc->GetMasterSdPageCount( PageKind::Standard ) ) )
5471
0
        throw lang::IndexOutOfBoundsException();
5472
5473
2.25k
    SdPage* pPage = mpModel->mpDoc->GetMasterSdPage( static_cast<sal_uInt16>(Index), PageKind::Standard );
5474
2.25k
    if( pPage )
5475
2.25k
    {
5476
2.25k
        uno::Reference< drawing::XDrawPage >  xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
5477
2.25k
        aAny <<= xDrawPage;
5478
2.25k
    }
5479
5480
2.25k
    return aAny;
5481
2.25k
}
5482
5483
// XElementAccess
5484
uno::Type SAL_CALL SdMasterPagesAccess::getElementType()
5485
0
{
5486
0
    return cppu::UnoType<drawing::XDrawPage>::get();
5487
0
}
5488
5489
sal_Bool SAL_CALL SdMasterPagesAccess::hasElements()
5490
0
{
5491
0
    return getCount() > 0;
5492
0
}
5493
5494
// XDrawPages
5495
uno::Reference< drawing::XDrawPage > SAL_CALL SdMasterPagesAccess::insertNewByIndex( sal_Int32 nInsertPos )
5496
13.1k
{
5497
13.1k
    return insertNewImpl(nInsertPos, std::nullopt);
5498
13.1k
}
5499
5500
// XDrawPages2
5501
uno::Reference< drawing::XDrawPage > SAL_CALL SdMasterPagesAccess::insertNamedNewByIndex( sal_Int32 nInsertPos, const OUString& sName )
5502
0
{
5503
0
    return insertNewImpl(nInsertPos, sName);
5504
0
}
5505
5506
uno::Reference< drawing::XDrawPage > SdMasterPagesAccess::insertNewImpl( sal_Int32 nInsertPos, std::optional<OUString> oPageName )
5507
13.1k
{
5508
13.1k
    ::SolarMutexGuard aGuard;
5509
5510
13.1k
    if( nullptr == mpModel )
5511
0
        throw lang::DisposedException();
5512
5513
13.1k
    uno::Reference< drawing::XDrawPage > xDrawPage;
5514
5515
13.1k
    SdDrawDocument* pDoc = mpModel->mpDoc;
5516
13.1k
    if( pDoc )
5517
13.1k
    {
5518
        // calculate internal index and check for range errors
5519
13.1k
        const sal_Int32 nMPageCount = pDoc->GetMasterPageCount();
5520
13.1k
        nInsertPos = nInsertPos * 2 + 1;
5521
13.1k
        if( nInsertPos < 0 || nInsertPos > nMPageCount )
5522
0
            nInsertPos = nMPageCount;
5523
5524
        // now generate a unique name for the new masterpage
5525
13.1k
        OUString aPrefix;
5526
13.1k
        if (oPageName)
5527
0
            aPrefix = *oPageName;
5528
13.1k
        else
5529
13.1k
        {
5530
13.1k
            const OUString aStdPrefix( SdResId(STR_LAYOUT_DEFAULT_NAME) );
5531
13.1k
            aPrefix = aStdPrefix;
5532
5533
13.1k
            bool bUnique = true;
5534
5535
13.1k
            std::vector<OUString> aPageNames;
5536
163k
            for (sal_Int32 nMaster = 1; nMaster < nMPageCount; ++nMaster)
5537
150k
            {
5538
150k
                const SdPage* pPage = static_cast<const SdPage*>(pDoc->GetMasterPage(static_cast<sal_uInt16>(nMaster)));
5539
150k
                if (!pPage)
5540
0
                    continue;
5541
150k
                aPageNames.push_back(pPage->GetName());
5542
150k
                if (aPageNames.back() == aPrefix)
5543
9.53k
                    bUnique = false;
5544
150k
            }
5545
5546
13.1k
            sal_Int32 i = 0;
5547
40.4k
            while (!bUnique)
5548
27.2k
            {
5549
27.2k
                aPrefix = aStdPrefix + " " + OUString::number(++i);
5550
27.2k
                bUnique = std::find(aPageNames.begin(), aPageNames.end(), aPrefix) == aPageNames.end();
5551
27.2k
            }
5552
13.1k
        }
5553
13.1k
        OUString aLayoutName = aPrefix + SD_LT_SEPARATOR + STR_LAYOUT_OUTLINE;
5554
5555
        // create styles
5556
13.1k
        static_cast<SdStyleSheetPool*>(pDoc->GetStyleSheetPool())->CreateLayoutStyleSheets( aPrefix );
5557
5558
        // get the first page for initial size and border settings
5559
13.1k
        SdPage* pPage = mpModel->mpDoc->GetSdPage( sal_uInt16(0), PageKind::Standard );
5560
13.1k
        SdPage* pRefNotesPage = mpModel->mpDoc->GetSdPage( sal_uInt16(0), PageKind::Notes);
5561
5562
        // create and insert new draw masterpage
5563
13.1k
        rtl::Reference<SdPage> pMPage = mpModel->mpDoc->AllocSdPage(true);
5564
13.1k
        pMPage->SetSize( pPage->GetSize() );
5565
13.1k
        pMPage->SetBorder( pPage->GetLeftBorder(),
5566
13.1k
                           pPage->GetUpperBorder(),
5567
13.1k
                           pPage->GetRightBorder(),
5568
13.1k
                           pPage->GetLowerBorder() );
5569
13.1k
        if (oPageName)
5570
            // no need to update the page URLs on a brand new page
5571
0
            pMPage->SetName(*oPageName, /*bUpdatePageRelativeURLs*/false);
5572
13.1k
        pMPage->SetLayoutName( aLayoutName );
5573
13.1k
        pDoc->InsertMasterPage(pMPage.get(),  static_cast<sal_uInt16>(nInsertPos));
5574
5575
13.1k
        {
5576
            // ensure default MasterPage fill
5577
13.1k
            pMPage->EnsureMasterPageDefaultBackground();
5578
13.1k
        }
5579
5580
13.1k
        xDrawPage.set( pMPage->getUnoPage(), uno::UNO_QUERY );
5581
5582
        // create and insert new notes masterpage
5583
13.1k
        rtl::Reference<SdPage> pMNotesPage = mpModel->mpDoc->AllocSdPage(true);
5584
13.1k
        pMNotesPage->SetSize( pRefNotesPage->GetSize() );
5585
13.1k
        pMNotesPage->SetPageKind(PageKind::Notes);
5586
13.1k
        pMNotesPage->SetBorder( pRefNotesPage->GetLeftBorder(),
5587
13.1k
                                pRefNotesPage->GetUpperBorder(),
5588
13.1k
                                pRefNotesPage->GetRightBorder(),
5589
13.1k
                                pRefNotesPage->GetLowerBorder() );
5590
13.1k
        pMNotesPage->SetLayoutName( aLayoutName );
5591
13.1k
        pDoc->InsertMasterPage(pMNotesPage.get(),  static_cast<sal_uInt16>(nInsertPos) + 1);
5592
13.1k
        pMNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true, true);
5593
13.1k
        mpModel->SetModified();
5594
13.1k
    }
5595
5596
13.1k
    return xDrawPage;
5597
13.1k
}
5598
5599
/**
5600
 * Removes the specified SdMasterPage from the model and the internal list. It
5601
 * only works, if there is no *normal* page using this page as MasterPage in
5602
 * the model.
5603
 */
5604
void SAL_CALL SdMasterPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
5605
0
{
5606
0
    ::SolarMutexGuard aGuard;
5607
5608
0
    if( nullptr == mpModel || mpModel->mpDoc == nullptr )
5609
0
        throw lang::DisposedException();
5610
5611
0
    SdMasterPage* pSdPage = comphelper::getFromUnoTunnel<SdMasterPage>( xPage );
5612
0
    if(pSdPage == nullptr)
5613
0
        return;
5614
5615
0
    SdPage* pPage = dynamic_cast< SdPage* > (pSdPage->GetSdrPage());
5616
5617
0
    DBG_ASSERT( pPage && pPage->IsMasterPage(), "SdMasterPage is not masterpage?");
5618
5619
0
    if( !pPage || !pPage->IsMasterPage() || (mpModel->mpDoc->GetMasterPageUserCount(pPage) > 0))
5620
0
        return; //Todo: this should be excepted
5621
5622
    // only standard pages can be removed directly
5623
0
    if( pPage->GetPageKind() != PageKind::Standard )
5624
0
        return;
5625
5626
0
    sal_uInt16 nPage = pPage->GetPageNum();
5627
5628
0
    SdDrawDocument& rDoc = *mpModel->mpDoc;
5629
5630
0
    SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetMasterPage( nPage+1 ) );
5631
5632
0
    bool bUndo = rDoc.IsUndoEnabled();
5633
0
    if( bUndo )
5634
0
    {
5635
        // Add undo actions and delete the pages.  The order of adding
5636
        // the undo actions is important.
5637
0
        rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) );
5638
0
        rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
5639
0
        rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
5640
0
    }
5641
5642
    // remove both pages
5643
0
    rDoc.RemoveMasterPage( nPage );
5644
0
    rDoc.RemoveMasterPage( nPage );
5645
5646
0
    if( bUndo )
5647
0
    {
5648
0
        rDoc.EndUndo();
5649
0
    }
5650
0
}
5651
5652
// XServiceInfo
5653
5654
OUString SAL_CALL SdMasterPagesAccess::getImplementationName(  )
5655
0
{
5656
0
    return u"SdMasterPagesAccess"_ustr;
5657
0
}
5658
5659
sal_Bool SAL_CALL SdMasterPagesAccess::supportsService( const OUString& ServiceName )
5660
0
{
5661
0
    return cppu::supportsService(this, ServiceName);
5662
0
}
5663
5664
uno::Sequence< OUString > SAL_CALL SdMasterPagesAccess::getSupportedServiceNames(  )
5665
0
{
5666
0
    return { u"com.sun.star.drawing.MasterPages"_ustr };
5667
0
}
5668
5669
SdDocLinkTargets::SdDocLinkTargets(SdXImpressDocument& rMyModel)
5670
0
    : mpModel(&rMyModel)
5671
0
{
5672
0
    for (sal_uInt16 i=0; i < SdLinkTargetType::Count; i++)
5673
0
        aNames[i] = SdResId(aTypeResIds[i]);
5674
0
}
5675
5676
SdDocLinkTargets::~SdDocLinkTargets() noexcept
5677
0
{
5678
0
}
5679
5680
// XComponent
5681
void SAL_CALL SdDocLinkTargets::dispose(  )
5682
0
{
5683
0
    mpModel = nullptr;
5684
0
}
5685
5686
void SAL_CALL SdDocLinkTargets::addEventListener( const uno::Reference< lang::XEventListener >&  )
5687
0
{
5688
0
    OSL_FAIL( "not implemented!" );
5689
0
}
5690
5691
void SAL_CALL SdDocLinkTargets::removeEventListener( const uno::Reference< lang::XEventListener >&  )
5692
0
{
5693
0
    OSL_FAIL( "not implemented!" );
5694
0
}
5695
5696
// XNameAccess
5697
uno::Any SAL_CALL SdDocLinkTargets::getByName( const OUString& aName )
5698
0
{
5699
0
    if (mpModel)
5700
0
    {
5701
0
        for (sal_uInt16 i=0; i < SdLinkTargetType::Count; i++)
5702
0
            if ( aNames[i] == aName )
5703
0
                return uno::Any(uno::Reference< beans::XPropertySet >(new SdDocLinkTargetType( mpModel, i )));
5704
0
    }
5705
5706
0
    throw container::NoSuchElementException();
5707
0
}
5708
5709
uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getElementNames()
5710
0
{
5711
0
    uno::Sequence<OUString> aRet(SdLinkTargetType::Count);
5712
0
    OUString* pArray = aRet.getArray();
5713
0
    for (sal_uInt16 i=0; i < SdLinkTargetType::Count; i++)
5714
0
        pArray[i] = aNames[i];
5715
0
    return aRet;
5716
0
}
5717
5718
sal_Bool SAL_CALL SdDocLinkTargets::hasByName( const OUString& aName )
5719
0
{
5720
0
    for (const auto & i : aNames)
5721
0
        if ( i == aName )
5722
0
            return true;
5723
0
    return false;
5724
0
}
5725
5726
// container::XElementAccess
5727
uno::Type SAL_CALL SdDocLinkTargets::getElementType()
5728
0
{
5729
0
    return cppu::UnoType<beans::XPropertySet>::get();
5730
0
}
5731
5732
sal_Bool SAL_CALL SdDocLinkTargets::hasElements()
5733
0
{
5734
0
    return true;
5735
0
}
5736
5737
SdPage* SdDocLinkTarget::FindPage( std::u16string_view rName ) const
5738
0
{
5739
0
    SdDrawDocument* pDoc = mpModel->GetDoc();
5740
0
    if( pDoc == nullptr )
5741
0
        return nullptr;
5742
5743
0
    const sal_uInt16 nMaxPages = pDoc->GetPageCount();
5744
0
    const sal_uInt16 nMaxMasterPages = pDoc->GetMasterPageCount();
5745
5746
0
    sal_uInt16 nPage;
5747
0
    SdPage* pPage;
5748
5749
0
    const bool bDraw = pDoc->GetDocumentType() == DocumentType::Draw;
5750
5751
    // standard pages
5752
0
    for( nPage = 0; nPage < nMaxPages; nPage++ )
5753
0
    {
5754
0
        pPage = static_cast<SdPage*>(pDoc->GetPage( nPage ));
5755
0
        if( (pPage->GetName() == rName) && (!bDraw || (pPage->GetPageKind() == PageKind::Standard)) )
5756
0
            return pPage;
5757
0
    }
5758
5759
    // master pages
5760
0
    for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
5761
0
    {
5762
0
        pPage = static_cast<SdPage*>(pDoc->GetMasterPage( nPage ));
5763
0
        if( (pPage->GetName() == rName) && (!bDraw || (pPage->GetPageKind() == PageKind::Standard)) )
5764
0
            return pPage;
5765
0
    }
5766
5767
0
    return nullptr;
5768
0
}
5769
5770
// XServiceInfo
5771
OUString SAL_CALL SdDocLinkTargets::getImplementationName()
5772
0
{
5773
0
    return u"SdDocLinkTargets"_ustr;
5774
0
}
5775
5776
sal_Bool SAL_CALL SdDocLinkTargets::supportsService( const OUString& ServiceName )
5777
0
{
5778
0
    return cppu::supportsService( this, ServiceName );
5779
0
}
5780
5781
uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getSupportedServiceNames()
5782
0
{
5783
0
    return { u"com.sun.star.document.LinkTargets"_ustr };
5784
0
}
5785
5786
SdDocLinkTargetType::SdDocLinkTargetType(SdXImpressDocument* pModel, sal_uInt16 nT)
5787
0
    : mpModel(pModel)
5788
0
    , mnType(nT)
5789
0
{
5790
0
    maName = SdResId(aTypeResIds[nT]);
5791
0
}
5792
5793
// beans::XPropertySet
5794
5795
uno::Reference< beans::XPropertySetInfo > SAL_CALL SdDocLinkTargetType::getPropertySetInfo()
5796
0
{
5797
0
    static uno::Reference< beans::XPropertySetInfo > aRef;//(new SfxItemPropertySetInfo( lcl_GetLinkTargetMap() ));
5798
0
    return aRef;
5799
0
}
5800
5801
void SAL_CALL SdDocLinkTargetType::setPropertyValue(const OUString& /* aPropertyName */,
5802
            const uno::Any& /* aValue */)
5803
0
{
5804
    //  everything is read-only
5805
0
}
5806
5807
uno::Any SAL_CALL SdDocLinkTargetType::getPropertyValue(const OUString& PropertyName)
5808
0
{
5809
0
    uno::Any aRet;
5810
0
    if ( PropertyName == "LinkDisplayName" )
5811
0
        aRet <<= maName;
5812
5813
0
    return aRet;
5814
0
}
5815
5816
void SAL_CALL SdDocLinkTargetType::addPropertyChangeListener( const OUString&,
5817
                            const uno::Reference<beans::XPropertyChangeListener>&)
5818
0
{ OSL_FAIL("not implemented"); }
5819
5820
void SAL_CALL SdDocLinkTargetType::removePropertyChangeListener( const OUString&,
5821
                        const uno::Reference<beans::XPropertyChangeListener>&)
5822
0
{ OSL_FAIL("not implemented"); }
5823
5824
void SAL_CALL SdDocLinkTargetType::addVetoableChangeListener( const OUString&,
5825
                        const uno::Reference<beans::XVetoableChangeListener>&)
5826
0
{ OSL_FAIL("not implemented"); }
5827
5828
void SAL_CALL SdDocLinkTargetType::removeVetoableChangeListener( const OUString&,
5829
                        const uno::Reference<beans::XVetoableChangeListener>&)
5830
0
{ OSL_FAIL("not implemented"); }
5831
5832
// document::XLinkTargetSupplier
5833
5834
uno::Reference< container::XNameAccess > SAL_CALL SdDocLinkTargetType::getLinks()
5835
0
{
5836
0
    return new SdDocLinkTarget( mpModel, mnType );
5837
0
}
5838
5839
// XServiceInfo
5840
OUString SAL_CALL SdDocLinkTargetType::getImplementationName()
5841
0
{
5842
0
    return u"SdDocLinkTargetType"_ustr;
5843
0
}
5844
5845
sal_Bool SAL_CALL SdDocLinkTargetType::supportsService( const OUString& ServiceName )
5846
0
{
5847
0
    return cppu::supportsService( this, ServiceName );
5848
0
}
5849
5850
uno::Sequence< OUString > SAL_CALL SdDocLinkTargetType::getSupportedServiceNames()
5851
0
{
5852
0
    return { u"com.sun.star.document.LinkTargetSupplier"_ustr };
5853
0
}
5854
5855
SdDocLinkTarget::SdDocLinkTarget( SdXImpressDocument* pModel, sal_uInt16 nT )
5856
0
    : mpModel(pModel)
5857
0
    , mnType(nT)
5858
0
{
5859
0
}
5860
5861
// container::XNameAccess
5862
5863
uno::Any SAL_CALL SdDocLinkTarget::getByName(const OUString& aName)
5864
0
{
5865
0
    ::SolarMutexGuard aGuard;
5866
5867
0
    if( nullptr == mpModel )
5868
0
        throw lang::DisposedException();
5869
5870
0
    SdPage* pPage = FindPage( aName );
5871
5872
0
    if( pPage == nullptr )
5873
0
        throw container::NoSuchElementException();
5874
5875
0
    uno::Any aAny;
5876
5877
0
    uno::Reference< beans::XPropertySet > xProps( pPage->getUnoPage(), uno::UNO_QUERY );
5878
0
    if( xProps.is() )
5879
0
        aAny <<= xProps;
5880
5881
0
    return aAny;
5882
0
}
5883
5884
uno::Sequence<OUString> SAL_CALL SdDocLinkTarget::getElementNames()
5885
0
{
5886
0
    ::SolarMutexGuard aGuard;
5887
5888
0
    if( nullptr == mpModel )
5889
0
        throw lang::DisposedException();
5890
5891
0
    SdDrawDocument* pDoc = mpModel->GetDoc();
5892
0
    if( pDoc == nullptr )
5893
0
    {
5894
0
        return { };
5895
0
    }
5896
5897
0
    if( pDoc->GetDocumentType() == DocumentType::Draw )
5898
0
    {
5899
0
        const sal_uInt16 nMaxPages = pDoc->GetSdPageCount( PageKind::Standard );
5900
0
        const sal_uInt16 nMaxMasterPages = pDoc->GetMasterSdPageCount( PageKind::Standard );
5901
5902
0
        uno::Sequence< OUString > aSeq( mnType == SdLinkTargetType::Page ? nMaxPages : nMaxMasterPages );
5903
0
        OUString* pStr = aSeq.getArray();
5904
5905
0
        sal_uInt16 nPage;
5906
0
        if (mnType == SdLinkTargetType::Page)
5907
0
        {
5908
            // standard pages
5909
0
            for( nPage = 0; nPage < nMaxPages; nPage++ )
5910
0
                *pStr++ = pDoc->GetSdPage( nPage, PageKind::Standard )->GetName();
5911
0
        }
5912
0
        else
5913
0
        {
5914
            // master pages
5915
0
            for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
5916
0
                *pStr++ = pDoc->GetMasterSdPage( nPage, PageKind::Standard )->GetName();
5917
0
        }
5918
0
        return aSeq;
5919
0
    }
5920
0
    else
5921
0
    {
5922
0
        PageKind eKind;
5923
0
        switch (mnType)
5924
0
        {
5925
0
            case SdLinkTargetType::Notes:
5926
0
                eKind = PageKind::Notes;
5927
0
                break;
5928
0
            case SdLinkTargetType::Handout:
5929
0
                eKind = PageKind::Handout;
5930
0
                break;
5931
0
            default:
5932
0
                eKind = PageKind::Standard;
5933
0
                break;
5934
0
        }
5935
0
        const sal_uInt16 nMaxPages = pDoc->GetSdPageCount( eKind );
5936
0
        const sal_uInt16 nMaxMasterPages = pDoc->GetMasterPageCount();
5937
5938
0
        uno::Sequence< OUString > aSeq( mnType == SdLinkTargetType::MasterPage ? nMaxMasterPages : nMaxPages );
5939
0
        OUString* pStr = aSeq.getArray();
5940
5941
0
        sal_uInt16 nPage;
5942
0
        switch (mnType)
5943
0
        {
5944
0
            case SdLinkTargetType::Page:
5945
0
            {
5946
0
                for( nPage = 0; nPage < nMaxPages; nPage++ )
5947
0
                    *pStr++ = pDoc->GetSdPage( nPage, PageKind::Standard )->GetName();
5948
0
                break;
5949
0
            }
5950
0
            case SdLinkTargetType::Notes:
5951
0
            {
5952
0
                for( nPage = 0; nPage < nMaxPages; nPage++ )
5953
0
                    *pStr++ = pDoc->GetSdPage( nPage, PageKind::Notes )->GetName();
5954
0
                break;
5955
0
            }
5956
0
            case SdLinkTargetType::Handout:
5957
0
            {
5958
0
                for( nPage = 0; nPage < nMaxPages; nPage++ )
5959
0
                    *pStr++ = pDoc->GetSdPage( nPage, PageKind::Handout )->GetName();
5960
0
                break;
5961
0
            }
5962
0
            case SdLinkTargetType::MasterPage:
5963
0
            {
5964
0
                for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
5965
0
                    *pStr++ = static_cast<SdPage*>(pDoc->GetMasterPage( nPage ))->GetName();
5966
0
                break;
5967
0
            }
5968
0
        }
5969
0
        return aSeq;
5970
0
    }
5971
0
}
5972
5973
sal_Bool SAL_CALL SdDocLinkTarget::hasByName(const OUString& aName)
5974
0
{
5975
0
    ::SolarMutexGuard aGuard;
5976
5977
0
    if( nullptr == mpModel )
5978
0
        throw lang::DisposedException();
5979
5980
0
    return FindPage( aName ) != nullptr;
5981
0
}
5982
5983
// container::XElementAccess
5984
5985
uno::Type SAL_CALL SdDocLinkTarget::getElementType()
5986
0
{
5987
0
    return cppu::UnoType<beans::XPropertySet>::get();
5988
0
}
5989
5990
sal_Bool SAL_CALL SdDocLinkTarget::hasElements()
5991
0
{
5992
0
    ::SolarMutexGuard aGuard;
5993
5994
0
    if( nullptr == mpModel )
5995
0
        throw lang::DisposedException();
5996
5997
0
    return mpModel->GetDoc() != nullptr;
5998
0
}
5999
6000
// XServiceInfo
6001
OUString SAL_CALL SdDocLinkTarget::getImplementationName()
6002
0
{
6003
0
    return u"SdDocLinkTarget"_ustr;
6004
0
}
6005
6006
sal_Bool SAL_CALL SdDocLinkTarget::supportsService( const OUString& ServiceName )
6007
0
{
6008
0
    return cppu::supportsService( this, ServiceName );
6009
0
}
6010
6011
uno::Sequence< OUString > SAL_CALL SdDocLinkTarget::getSupportedServiceNames()
6012
0
{
6013
0
    return { u"com.sun.star.document.LinkTargets"_ustr };
6014
0
}
6015
6016
rtl::Reference< SdXImpressDocument > SdXImpressDocument::GetModel( SdDrawDocument const & rDocument )
6017
175
{
6018
175
    rtl::Reference< SdXImpressDocument > xRet;
6019
175
    ::sd::DrawDocShell* pDocShell(rDocument.GetDocSh());
6020
175
    if( pDocShell )
6021
175
    {
6022
175
        uno::Reference<frame::XModel> xModel(pDocShell->GetModel());
6023
6024
175
        xRet.set( dynamic_cast< SdXImpressDocument* >( xModel.get() ) );
6025
175
    }
6026
6027
175
    return xRet;
6028
175
}
6029
6030
void NotifyDocumentEvent(SdDrawDocument const & rDocument, const OUString& rEventName)
6031
0
{
6032
0
    rtl::Reference<SdXImpressDocument> xModel(SdXImpressDocument::GetModel(rDocument));
6033
6034
0
    if (xModel.is())
6035
0
    {
6036
0
        uno::Reference<uno::XInterface> xSource(static_cast<uno::XWeak*>(xModel.get()));
6037
0
        NotifyDocumentEvent(rDocument, rEventName, xSource);
6038
0
    }
6039
0
}
6040
6041
void NotifyDocumentEvent(SdDrawDocument const & rDocument, const OUString& rEventName, const uno::Reference<uno::XInterface>& xSource)
6042
175
{
6043
175
    rtl::Reference<SdXImpressDocument> xModel(SdXImpressDocument::GetModel(rDocument));
6044
6045
175
    if (xModel.is())
6046
175
    {
6047
175
        css::document::EventObject aEvent(xSource, rEventName);
6048
175
        xModel->notifyEvent(aEvent);
6049
175
    }
6050
175
}
6051
6052
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */