Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/svx/source/xoutdev/xattr.cxx
Line
Count
Source (jump to first uncovered line)
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 <sal/config.h>
21
22
#include <utility>
23
24
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
25
#include <com/sun/star/drawing/Hatch.hpp>
26
#include <com/sun/star/drawing/LineStyle.hpp>
27
#include <com/sun/star/drawing/LineDash.hpp>
28
#include <com/sun/star/drawing/DashStyle.hpp>
29
#include <com/sun/star/drawing/FillStyle.hpp>
30
#include <com/sun/star/awt/Gradient2.hpp>
31
#include <com/sun/star/uno/Sequence.hxx>
32
#include <com/sun/star/beans/PropertyValue.hpp>
33
34
#include <comphelper/propertyvalue.hxx>
35
#include <o3tl/string_view.hxx>
36
#include <o3tl/any.hxx>
37
#include <svl/itempool.hxx>
38
#include <editeng/memberids.h>
39
#include <docmodel/uno/UnoGradientTools.hxx>
40
#include <docmodel/uno/UnoComplexColor.hxx>
41
#include <docmodel/color/ComplexColorJSON.hxx>
42
#include <tools/mapunit.hxx>
43
#include <tools/UnitConversion.hxx>
44
#include <osl/diagnose.h>
45
46
#include <svx/unoapi.hxx>
47
#include <svl/style.hxx>
48
49
#include <tools/bigint.hxx>
50
#include <svl/itemset.hxx>
51
#include <svx/strings.hrc>
52
#include <svx/xfillit0.hxx>
53
#include <svx/xflasit.hxx>
54
#include <svx/xlineit0.hxx>
55
#include <svx/xlnasit.hxx>
56
#include <svx/xtextit0.hxx>
57
#include <svx/xtable.hxx>
58
#include <svx/dialmgr.hxx>
59
#include <svx/xflclit.hxx>
60
#include <svx/xflgrit.hxx>
61
#include <svx/xflftrit.hxx>
62
#include <svx/xsflclit.hxx>
63
#include <svx/xflhtit.hxx>
64
#include <svx/xbtmpit.hxx>
65
#include <svx/xlndsit.hxx>
66
#include <svx/xlnwtit.hxx>
67
#include <svx/xlnclit.hxx>
68
#include <svx/xlnstit.hxx>
69
#include <svx/xlnedit.hxx>
70
#include <svx/xlnstwit.hxx>
71
#include <svx/xlnedwit.hxx>
72
#include <svx/xlnstcit.hxx>
73
#include <svx/xlnedcit.hxx>
74
#include <editeng/itemtype.hxx>
75
#include <editeng/eerdll.hxx>
76
#include <svx/xdef.hxx>
77
#include <svx/unomid.hxx>
78
#include <svx/svdmodel.hxx>
79
#include <svx/xftdiit.hxx>
80
#include <svx/xftstit.hxx>
81
#include <svx/xftmrit.hxx>
82
#include <svx/xftouit.hxx>
83
#include <svx/xftshit.hxx>
84
#include <svx/xftshcit.hxx>
85
#include <svx/xftshxy.hxx>
86
#include <svx/xftadit.hxx>
87
#include <svx/svddef.hxx>
88
#include <basegfx/polygon/b2dpolypolygontools.hxx>
89
#include <unotools/intlwrapper.hxx>
90
#include <unotools/syslocale.hxx>
91
#include <string>
92
93
#include <boost/property_tree/ptree.hpp>
94
#include <libxml/xmlwriter.h>
95
96
using namespace ::com::sun::star;
97
98
typedef std::map<OUString, OUString> StringMap;
99
100
NameOrIndex::NameOrIndex(TypedWhichId<NameOrIndex> _nWhich, sal_Int32 nIndex) :
101
421k
    SfxStringItem(_nWhich, OUString()),
102
421k
    m_nPalIndex(nIndex)
103
421k
{
104
421k
    setNameOrIndex();
105
421k
}
106
107
NameOrIndex::NameOrIndex(TypedWhichId<NameOrIndex> _nWhich, const OUString& rName) :
108
2.79M
    SfxStringItem(_nWhich, rName),
109
2.79M
    m_nPalIndex(-1)
110
2.79M
{
111
2.79M
    setNameOrIndex();
112
2.79M
}
113
114
NameOrIndex::NameOrIndex(const NameOrIndex& rNameOrIndex) :
115
1.49M
    SfxStringItem(rNameOrIndex),
116
1.49M
    m_nPalIndex(rNameOrIndex.m_nPalIndex)
117
1.49M
{
118
1.49M
    setNameOrIndex();
119
1.49M
}
120
121
bool NameOrIndex::operator==(const SfxPoolItem& rItem) const
122
3.38M
{
123
3.38M
    return ( SfxStringItem::operator==(rItem) &&
124
3.38M
            static_cast<const NameOrIndex&>(rItem).m_nPalIndex == m_nPalIndex );
125
3.38M
}
126
127
NameOrIndex* NameOrIndex::Clone(SfxItemPool* /*pPool*/) const
128
0
{
129
0
    return new NameOrIndex(*this);
130
0
}
131
132
/** this static checks if the given NameOrIndex item has a unique name for its value.
133
    The returned String is a unique name for an item with this value in both given pools.
134
    Argument pPool2 can be null.
135
    If returned string equals NameOrIndex->GetName(), the name was already unique.
136
*/
137
OUString NameOrIndex::CheckNamedItem(const sal_uInt16 nWhich, const SfxItemPool* pPool1, SvxCompareValueFunc pCompareValueFunc, TranslateId pPrefixResId, const XPropertyListRef &pDefaults) const
138
117k
{
139
117k
    bool bForceNew = false;
140
141
117k
    OUString aUniqueName = SvxUnogetInternalNameForItem(nWhich, GetName());
142
143
    // 2. if we have a name check if there is already an item with the
144
    // same name in the documents pool with a different line end or start
145
146
117k
    if (!aUniqueName.isEmpty() && pPool1)
147
74.7k
    {
148
        // use special version to get buffered NameOrIndex Items
149
74.7k
        for (const SfxPoolItem* pItem : pPool1->GetItemSurrogatesForItem(*this))
150
92.9k
        {
151
92.9k
            const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
152
153
            // need to check for WhichID, GetItemSurrogatesForItem does buffer on type only
154
92.9k
            if( pNameOrIndex != this && pNameOrIndex->Which() == nWhich && pNameOrIndex->GetName() == GetName() )
155
34.4k
            {
156
                // if there is already an item with the same name and the same
157
                // value it's ok to set it
158
34.4k
                if( !pCompareValueFunc( pNameOrIndex, this ) )
159
13
                {
160
                    // same name but different value, we need a new name for this item
161
13
                    aUniqueName.clear();
162
13
                    bForceNew = true;
163
13
                }
164
34.4k
                break;
165
34.4k
            }
166
92.9k
        }
167
74.7k
    }
168
169
    // if we have no name yet, find existing item with same content or
170
    // create a unique name
171
117k
    if (aUniqueName.isEmpty())
172
42.3k
    {
173
42.3k
        sal_Int32 nUserIndex = 1;
174
42.3k
        const OUString aUser(SvxResId(pPrefixResId) + " ");
175
176
42.3k
        if( pDefaults )
177
42.3k
        {
178
42.3k
            const int nCount = pDefaults->Count();
179
42.3k
            int nIndex;
180
209k
            for( nIndex = 0; nIndex < nCount; nIndex++ )
181
168k
            {
182
168k
                const XPropertyEntry* pEntry = pDefaults->Get(nIndex);
183
168k
                if( pEntry )
184
168k
                {
185
168k
                    bool bFound = false;
186
187
168k
                    switch( nWhich )
188
168k
                    {
189
32.3k
                    case XATTR_FILLBITMAP:
190
32.3k
                    {
191
32.3k
                        const GraphicObject& rGraphicObjectA(static_cast<const XFillBitmapItem*>(this)->GetGraphicObject());
192
32.3k
                        const GraphicObject& rGraphicObjectB(static_cast<const XBitmapEntry*>(pEntry)->GetGraphicObject());
193
194
32.3k
                        bFound = (rGraphicObjectA == rGraphicObjectB);
195
32.3k
                        break;
196
0
                    }
197
47.0k
                    case XATTR_LINEDASH:
198
47.0k
                        bFound = static_cast<const XLineDashItem*>(this)->GetDashValue() == static_cast<const XDashEntry*>(pEntry)->GetDash();
199
47.0k
                        break;
200
0
                    case XATTR_LINESTART:
201
0
                        bFound = static_cast<const XLineStartItem*>(this)->GetLineStartValue() == static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd();
202
0
                        break;
203
0
                    case XATTR_LINEEND:
204
0
                        bFound = static_cast<const XLineEndItem*>(this)->GetLineEndValue() == static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd();
205
0
                        break;
206
86.9k
                    case XATTR_FILLGRADIENT:
207
86.9k
                        bFound = static_cast<const XFillGradientItem*>(this)->GetGradientValue() == static_cast<const XGradientEntry*>(pEntry)->GetGradient();
208
86.9k
                        break;
209
1.82k
                    case XATTR_FILLHATCH:
210
1.82k
                        bFound = static_cast<const XFillHatchItem*>(this)->GetHatchValue() == static_cast<const XHatchEntry*>(pEntry)->GetHatch();
211
1.82k
                        break;
212
168k
                    }
213
214
168k
                    if( bFound )
215
619
                    {
216
619
                        aUniqueName = pEntry->GetName();
217
619
                        break;
218
619
                    }
219
167k
                    else
220
167k
                    {
221
167k
                        const OUString& aEntryName = pEntry->GetName();
222
167k
                        if(aEntryName.getLength() >= aUser.getLength())
223
165k
                        {
224
165k
                            sal_Int32 nThisIndex = o3tl::toInt32(aEntryName.subView( aUser.getLength() ));
225
165k
                            if( nThisIndex >= nUserIndex )
226
94.4k
                                nUserIndex = nThisIndex + 1;
227
165k
                        }
228
167k
                    }
229
168k
                }
230
168k
            }
231
42.3k
        }
232
233
42.3k
        if (aUniqueName.isEmpty() && pPool1)
234
41.7k
        {
235
            // use special version to get buffered NameOrIndex Items
236
41.7k
            for (const SfxPoolItem* pItem : pPool1->GetItemSurrogatesForItem(*this))
237
109k
            {
238
109k
                const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
239
240
                // need to check for WhichID, GetItemSurrogatesForItem does buffer on type only
241
109k
                if( pNameOrIndex != this && pNameOrIndex->Which() == nWhich && !pNameOrIndex->GetName().isEmpty() )
242
90.5k
                {
243
90.5k
                    if( !bForceNew && pCompareValueFunc( pNameOrIndex, this ) )
244
32.0k
                        return pNameOrIndex->GetName();
245
246
58.5k
                    if( pNameOrIndex->GetName().startsWith( aUser ) )
247
56.7k
                    {
248
56.7k
                        sal_Int32 nThisIndex = o3tl::toInt32(pNameOrIndex->GetName().subView( aUser.getLength() ));
249
56.7k
                        if( nThisIndex >= nUserIndex )
250
28.0k
                            nUserIndex = nThisIndex + 1;
251
56.7k
                    }
252
58.5k
                }
253
109k
            }
254
9.74k
            aUniqueName = aUser + OUString::number( nUserIndex );
255
9.74k
        }
256
42.3k
    }
257
258
85.1k
    return aUniqueName;
259
117k
}
260
261
void NameOrIndex::dumpAsXml(xmlTextWriterPtr pWriter) const
262
0
{
263
0
    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("NameOrIndex"));
264
0
    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
265
0
    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("isIndex"), BAD_CAST(OString::boolean(IsIndex()).getStr()));
266
0
    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(GetName().toUtf8().getStr()));
267
0
    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("index"), BAD_CAST(OString::number(m_nPalIndex).getStr()));
268
0
    (void)xmlTextWriterEndElement(pWriter);
269
0
}
270
271
0
SfxPoolItem* XColorItem::CreateDefault() { return new XColorItem(); }
272
273
XColorItem::XColorItem(TypedWhichId<XColorItem> _nWhich, sal_Int32 nIndex, const Color& rTheColor) :
274
0
    NameOrIndex(_nWhich, nIndex),
275
0
    m_aColor(rTheColor)
276
0
{
277
0
}
278
279
XColorItem::XColorItem(TypedWhichId<XColorItem> _nWhich, const OUString& rName, const Color& rTheColor) :
280
2.11M
    NameOrIndex(_nWhich, rName),
281
2.11M
    m_aColor(rTheColor)
282
2.11M
{
283
2.11M
}
284
285
XColorItem::XColorItem(TypedWhichId<XColorItem> _nWhich, const Color& rTheColor)
286
436k
    : NameOrIndex(_nWhich, OUString())
287
436k
    , m_aColor(rTheColor)
288
436k
{
289
436k
}
290
291
XColorItem::XColorItem(const XColorItem& rItem) :
292
1.03M
    NameOrIndex(rItem),
293
1.03M
    m_aColor(rItem.m_aColor),
294
1.03M
    maComplexColor(rItem.maComplexColor)
295
1.03M
{
296
1.03M
}
297
298
XColorItem* XColorItem::Clone(SfxItemPool* /*pPool*/) const
299
132k
{
300
132k
    return new XColorItem(*this);
301
132k
}
302
303
bool XColorItem::operator==(const SfxPoolItem& rItem) const
304
2.83M
{
305
2.83M
    return ( NameOrIndex::operator==(rItem) &&
306
2.83M
            static_cast<const XColorItem&>(rItem).m_aColor == m_aColor ) &&
307
2.83M
            static_cast<const XColorItem&>(rItem).maComplexColor == maComplexColor;
308
2.83M
}
309
310
const Color& XColorItem::GetColorValue() const
311
73.5k
{
312
73.5k
    assert(!IsIndex());
313
73.5k
    return m_aColor;
314
315
73.5k
}
316
317
bool XColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId) const
318
607
{
319
607
    nMemberId &= ~CONVERT_TWIPS;
320
607
    switch (nMemberId)
321
607
    {
322
0
        case MID_COMPLEX_COLOR:
323
0
        {
324
0
            auto xComplexColor = model::color::createXComplexColor(getComplexColor());
325
0
            rVal <<= xComplexColor;
326
0
            break;
327
0
        }
328
0
        case MID_COMPLEX_COLOR_JSON:
329
0
        {
330
0
            rVal <<= OStringToOUString(model::color::convertToJSON(getComplexColor()), RTL_TEXTENCODING_UTF8);
331
0
            break;
332
0
        }
333
607
        default:
334
607
        {
335
607
            rVal <<= GetColorValue().GetRGBColor();
336
607
            break;
337
0
        }
338
607
    }
339
607
    return true;
340
607
}
341
342
bool XColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId)
343
1.81k
{
344
1.81k
    nMemberId &= ~CONVERT_TWIPS;
345
1.81k
    switch (nMemberId)
346
1.81k
    {
347
0
        case MID_COMPLEX_COLOR:
348
0
        {
349
0
            css::uno::Reference<css::util::XComplexColor> xComplexColor;
350
0
            if (!(rVal >>= xComplexColor))
351
0
                return false;
352
0
            setComplexColor(model::color::getFromXComplexColor(xComplexColor));
353
0
        }
354
0
        break;
355
0
        case MID_COMPLEX_COLOR_JSON:
356
0
        {
357
0
            OUString sComplexColorJson;
358
0
            if (!(rVal >>= sComplexColorJson))
359
0
                return false;
360
361
0
            if (sComplexColorJson.isEmpty())
362
0
                return false;
363
364
0
            OString aJSON = OUStringToOString(sComplexColorJson, RTL_TEXTENCODING_ASCII_US);
365
0
            model::ComplexColor aComplexColor;
366
0
            model::color::convertFromJSON(aJSON, aComplexColor);
367
0
            setComplexColor(aComplexColor);
368
0
        }
369
0
        break;
370
1.81k
        default:
371
1.81k
        {
372
1.81k
            Color nValue;
373
1.81k
            if(!(rVal >>= nValue ))
374
0
                return false;
375
376
1.81k
            SetColorValue( nValue );
377
378
1.81k
        }
379
0
        break;
380
1.81k
    }
381
1.81k
    return true;
382
1.81k
}
383
384
void XColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
385
0
{
386
0
    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XColorItem"));
387
0
    if (Which() == SDRATTR_SHADOWCOLOR)
388
0
    {
389
0
        (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("SDRATTR_SHADOWCOLOR"));
390
0
    }
391
0
    else if (Which() == XATTR_FILLCOLOR)
392
0
    {
393
0
        (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("XATTR_FILLCOLOR"));
394
0
    }
395
0
    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("aColor"),
396
0
                                BAD_CAST(m_aColor.AsRGBHexString().toUtf8().getStr()));
397
398
0
    NameOrIndex::dumpAsXml(pWriter);
399
400
0
    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("complex-color"));
401
402
0
    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("scheme-index"),
403
0
                                      BAD_CAST(OString::number(sal_Int16(maComplexColor.getThemeColorType())).getStr()));
404
405
0
    for (auto const& rTransform : maComplexColor.getTransformations())
406
0
    {
407
0
        (void)xmlTextWriterStartElement(pWriter, BAD_CAST("transformation"));
408
0
        (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"),
409
0
                                      BAD_CAST(OString::number(sal_Int16(rTransform.meType)).getStr()));
410
0
        (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
411
0
                                      BAD_CAST(OString::number(rTransform.mnValue).getStr()));
412
0
        (void)xmlTextWriterEndElement(pWriter);
413
0
    }
414
415
0
    (void)xmlTextWriterEndElement(pWriter);
416
417
0
    (void)xmlTextWriterEndElement(pWriter);
418
0
}
419
420
// --- line attributes ---
421
422
423
0
SfxPoolItem* XLineStyleItem::CreateDefault() { return new XLineStyleItem; }
424
425
XLineStyleItem::XLineStyleItem(css::drawing::LineStyle eTheLineStyle) :
426
2.27M
    SfxEnumItem(XATTR_LINESTYLE, eTheLineStyle)
427
2.27M
{
428
2.27M
}
429
430
XLineStyleItem* XLineStyleItem::Clone(SfxItemPool* /*pPool*/) const
431
710k
{
432
710k
    return new XLineStyleItem( *this );
433
710k
}
434
435
bool XLineStyleItem::GetPresentation
436
(
437
    SfxItemPresentation /*ePres*/,
438
    MapUnit             /*eCoreUnit*/,
439
    MapUnit             /*ePresUnit*/,
440
    OUString&           rText, const IntlWrapper&
441
)   const
442
0
{
443
0
    rText.clear();
444
445
0
    TranslateId pId;
446
447
0
    switch( GetValue() )
448
0
    {
449
0
        case css::drawing::LineStyle_NONE:
450
0
            pId = RID_SVXSTR_INVISIBLE;
451
0
            break;
452
0
        case css::drawing::LineStyle_SOLID:
453
0
            pId = RID_SVXSTR_SOLID;
454
0
            break;
455
0
        default: break;
456
0
    }
457
458
0
    if (pId)
459
0
        rText = SvxResId(pId);
460
0
    return true;
461
0
}
462
463
bool XLineStyleItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
464
1.16k
{
465
1.16k
    css::drawing::LineStyle eLS = GetValue();
466
1.16k
    rVal <<= eLS;
467
1.16k
    return true;
468
1.16k
}
469
470
bool XLineStyleItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
471
89.2k
{
472
89.2k
    css::drawing::LineStyle eLS;
473
89.2k
    if(!(rVal >>= eLS ))
474
0
    {
475
        // also try an int (for Basic)
476
0
        sal_Int32 nLS = 0;
477
0
        if(!(rVal >>= nLS))
478
0
            return false;
479
0
        eLS = static_cast<css::drawing::LineStyle>(nLS);
480
0
    }
481
482
89.2k
    SetValue( eLS );
483
89.2k
    return true;
484
89.2k
}
485
486
XDash::XDash(css::drawing::DashStyle eTheDash, sal_uInt16 nTheDots, double nTheDotLen,
487
             sal_uInt16 nTheDashes, double nTheDashLen, double nTheDistance) :
488
46.7k
    m_eDash(eTheDash),
489
46.7k
    m_nDots(nTheDots),
490
46.7k
    m_nDashes(nTheDashes),
491
46.7k
    m_nDotLen(nTheDotLen),
492
46.7k
    m_nDashLen(nTheDashLen),
493
46.7k
    m_nDistance(nTheDistance)
494
46.7k
{
495
46.7k
}
496
497
bool XDash::operator==(const XDash& rDash) const
498
90.1k
{
499
90.1k
    return ( m_eDash      == rDash.m_eDash      &&
500
90.1k
             m_nDots      == rDash.m_nDots      &&
501
90.1k
             m_nDotLen    == rDash.m_nDotLen    &&
502
90.1k
             m_nDashes    == rDash.m_nDashes    &&
503
90.1k
             m_nDashLen   == rDash.m_nDashLen   &&
504
90.1k
             m_nDistance  == rDash.m_nDistance );
505
90.1k
}
506
507
// XDash is translated into an array of doubles which describe the lengths of the
508
// dashes, dots and empty passages. It returns the complete length of the full DashDot
509
// sequence and fills the given vector of doubles accordingly (also resizing, so deleting it).
510
const double SMALLEST_DASH_WIDTH(26.95);
511
512
double XDash::CreateDotDashArray(::std::vector< double >& rDotDashArray, double fLineWidth) const
513
0
{
514
0
    double fFullDotDashLen(0.0);
515
0
    const sal_uInt16 nNumDotDashArray = (GetDots() + GetDashes()) * 2;
516
0
    rDotDashArray.resize( nNumDotDashArray, 0.0 );
517
0
    sal_uInt16 a;
518
0
    sal_uInt16 nIns(0);
519
0
    double fDashDotDistance = GetDistance();
520
0
    double fSingleDashLen = GetDashLen();
521
0
    double fSingleDotLen = GetDotLen();
522
523
0
    if (fLineWidth == 0.0)
524
0
        fLineWidth = SMALLEST_DASH_WIDTH;
525
526
0
    if(GetDashStyle() == css::drawing::DashStyle_RECTRELATIVE || GetDashStyle() == css::drawing::DashStyle_ROUNDRELATIVE)
527
0
    {
528
0
        double fFactor = fLineWidth / 100.0;
529
530
0
        if(GetDashes())
531
0
        {
532
0
            if(GetDashLen())
533
0
            {
534
                // is a dash
535
0
                fSingleDashLen *= fFactor;
536
0
            }
537
0
            else
538
0
            {
539
                // is a dot
540
0
                fSingleDashLen = fLineWidth;
541
0
            }
542
0
        }
543
544
0
        if(GetDots())
545
0
        {
546
0
            if(GetDotLen())
547
0
            {
548
                // is a dash
549
0
                fSingleDotLen *= fFactor;
550
0
            }
551
0
            else
552
0
            {
553
                // is a dot
554
0
                fSingleDotLen = fLineWidth;
555
0
            }
556
0
        }
557
558
0
        if(GetDashes() || GetDots())
559
0
        {
560
0
            if(GetDistance())
561
0
            {
562
                // dash as distance
563
0
                fDashDotDistance *= fFactor;
564
0
            }
565
0
            else
566
0
            {
567
                // dot as distance
568
0
                fDashDotDistance = fLineWidth;
569
0
            }
570
0
        }
571
0
    }
572
0
    else
573
0
    {
574
        // absolute values
575
0
        if(GetDashes())
576
0
        {
577
0
            if(GetDashLen())
578
0
            {
579
                // is a dash
580
0
                if(fSingleDashLen < SMALLEST_DASH_WIDTH)
581
0
                {
582
0
                    fSingleDashLen = SMALLEST_DASH_WIDTH;
583
0
                }
584
0
            }
585
0
            else
586
0
            {
587
                // is a dot
588
0
                if(fSingleDashLen < fLineWidth)
589
0
                {
590
0
                    fSingleDashLen = fLineWidth;
591
0
                }
592
0
            }
593
0
        }
594
595
0
        if(GetDots())
596
0
        {
597
0
            if(GetDotLen())
598
0
            {
599
                // is a dash
600
0
                if(fSingleDotLen < SMALLEST_DASH_WIDTH)
601
0
                {
602
0
                    fSingleDotLen = SMALLEST_DASH_WIDTH;
603
0
                }
604
0
            }
605
0
            else
606
0
            {
607
                // is a dot
608
0
                if(fSingleDotLen < fLineWidth)
609
0
                {
610
0
                    fSingleDotLen = fLineWidth;
611
0
                }
612
0
            }
613
0
        }
614
615
0
        if(GetDashes() || GetDots())
616
0
        {
617
0
            if(GetDistance())
618
0
            {
619
                // dash as distance
620
0
                if(fDashDotDistance < SMALLEST_DASH_WIDTH)
621
0
                {
622
0
                    fDashDotDistance = SMALLEST_DASH_WIDTH;
623
0
                }
624
0
            }
625
0
            else
626
0
            {
627
                // dot as distance
628
0
                if(fDashDotDistance < fLineWidth)
629
0
                {
630
0
                    fDashDotDistance = fLineWidth;
631
0
                }
632
0
            }
633
0
        }
634
0
    }
635
636
0
    for(a=0;a<GetDots();a++)
637
0
    {
638
0
        rDotDashArray[nIns++] = fSingleDotLen;
639
0
        fFullDotDashLen += fSingleDotLen;
640
0
        rDotDashArray[nIns++] = fDashDotDistance;
641
0
        fFullDotDashLen += fDashDotDistance;
642
0
    }
643
644
0
    for(a=0;a<GetDashes();a++)
645
0
    {
646
0
        rDotDashArray[nIns++] = fSingleDashLen;
647
0
        fFullDotDashLen += fSingleDashLen;
648
0
        rDotDashArray[nIns++] = fDashDotDistance;
649
0
        fFullDotDashLen += fDashDotDistance;
650
0
    }
651
652
0
    return fFullDotDashLen;
653
0
}
654
655
0
SfxPoolItem* XLineDashItem::CreateDefault() {return new XLineDashItem;}
656
657
XLineDashItem::XLineDashItem(const OUString& rName, const XDash& rTheDash) :
658
30.4k
    NameOrIndex(XATTR_LINEDASH, rName),
659
30.4k
    m_aDash(rTheDash)
660
30.4k
{
661
30.4k
}
662
663
XLineDashItem::XLineDashItem(const XLineDashItem& rItem) :
664
29.2k
    NameOrIndex(rItem),
665
29.2k
    m_aDash(rItem.m_aDash)
666
29.2k
{
667
29.2k
}
668
669
XLineDashItem::XLineDashItem(const XDash& rTheDash)
670
26.9k
:   NameOrIndex( XATTR_LINEDASH, -1 ),
671
26.9k
    m_aDash(rTheDash)
672
26.9k
{
673
26.9k
}
674
675
XLineDashItem* XLineDashItem::Clone(SfxItemPool* /*pPool*/) const
676
29.2k
{
677
29.2k
    return new XLineDashItem(*this);
678
29.2k
}
679
680
bool XLineDashItem::operator==(const SfxPoolItem& rItem) const
681
27.8k
{
682
27.8k
    return ( NameOrIndex::operator==(rItem) &&
683
27.8k
             m_aDash == static_cast<const XLineDashItem&>(rItem).m_aDash );
684
27.8k
}
685
686
bool XLineDashItem::GetPresentation
687
(
688
    SfxItemPresentation /*ePres*/,
689
    MapUnit             /*eCoreUnit*/,
690
    MapUnit             /*ePresUnit*/,
691
    OUString&           rText, const IntlWrapper&
692
)   const
693
0
{
694
0
    rText = GetName();
695
0
    return true;
696
0
}
697
698
bool XLineDashItem::HasMetrics() const
699
0
{
700
0
    return true;
701
0
}
702
703
void XLineDashItem::ScaleMetrics(tools::Long nMul, tools::Long nDiv)
704
0
{
705
0
    m_aDash.SetDotLen( BigInt::Scale( m_aDash.GetDotLen(), nMul, nDiv ) );
706
0
    m_aDash.SetDashLen( BigInt::Scale( m_aDash.GetDashLen(), nMul, nDiv ) );
707
0
    m_aDash.SetDistance( BigInt::Scale( m_aDash.GetDistance(), nMul, nDiv ) );
708
0
}
709
710
bool XLineDashItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
711
0
{
712
0
    nMemberId &= ~CONVERT_TWIPS;
713
714
0
    switch ( nMemberId )
715
0
    {
716
0
        case 0:
717
0
        {
718
0
            css::drawing::LineDash aLineDash;
719
720
0
            const XDash& rXD = GetDashValue();
721
0
            aLineDash.Style = static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(rXD.GetDashStyle()));
722
0
            aLineDash.Dots = rXD.GetDots();
723
0
            aLineDash.DotLen = rXD.GetDotLen();
724
0
            aLineDash.Dashes = rXD.GetDashes();
725
0
            aLineDash.DashLen = rXD.GetDashLen();
726
0
            aLineDash.Distance = rXD.GetDistance();
727
728
0
            uno::Sequence< beans::PropertyValue > aPropSeq{
729
0
                comphelper::makePropertyValue(u"Name"_ustr, SvxUnogetApiNameForItem(Which(), GetName())),
730
0
                comphelper::makePropertyValue(u"LineDash"_ustr, aLineDash)
731
0
            };
732
0
            rVal <<= aPropSeq;
733
0
            break;
734
0
        }
735
736
0
        case MID_NAME:
737
0
        {
738
0
            rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
739
0
            break;
740
0
        }
741
742
0
        case MID_LINEDASH:
743
0
        {
744
0
            const XDash& rXD = GetDashValue();
745
746
0
            css::drawing::LineDash aLineDash;
747
748
0
            aLineDash.Style = static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(rXD.GetDashStyle()));
749
0
            aLineDash.Dots = rXD.GetDots();
750
0
            aLineDash.DotLen = rXD.GetDotLen();
751
0
            aLineDash.Dashes = rXD.GetDashes();
752
0
            aLineDash.DashLen = rXD.GetDashLen();
753
0
            aLineDash.Distance = rXD.GetDistance();
754
755
0
            rVal <<= aLineDash;
756
0
            break;
757
0
        }
758
759
0
        case MID_LINEDASH_STYLE:
760
0
        {
761
0
            const XDash& rXD = GetDashValue();
762
0
            rVal <<= static_cast<css::drawing::DashStyle>(static_cast<sal_Int16>(rXD.GetDashStyle()));
763
0
            break;
764
0
        }
765
766
0
        case MID_LINEDASH_DOTS:
767
0
        {
768
0
            const XDash& rXD = GetDashValue();
769
0
            rVal <<= rXD.GetDots();
770
0
            break;
771
0
        }
772
773
0
        case MID_LINEDASH_DOTLEN:
774
0
        {
775
0
            const XDash& rXD = GetDashValue();
776
0
            rVal <<= rXD.GetDotLen();
777
0
            break;
778
0
        }
779
780
0
        case MID_LINEDASH_DASHES:
781
0
        {
782
0
            const XDash& rXD = GetDashValue();
783
0
            rVal <<= rXD.GetDashes();
784
0
            break;
785
0
        }
786
787
0
        case MID_LINEDASH_DASHLEN:
788
0
        {
789
0
            const XDash& rXD = GetDashValue();
790
0
            rVal <<= rXD.GetDashLen();
791
0
            break;
792
0
        }
793
794
0
        case MID_LINEDASH_DISTANCE:
795
0
        {
796
0
            const XDash& rXD = GetDashValue();
797
0
            rVal <<= rXD.GetDistance();
798
0
            break;
799
0
        }
800
801
0
        default: OSL_FAIL("Wrong MemberId!"); return false;
802
0
    }
803
804
0
    return true;
805
0
}
806
807
bool XLineDashItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
808
693
{
809
693
    nMemberId &= ~CONVERT_TWIPS;
810
811
693
    switch ( nMemberId )
812
693
    {
813
0
        case 0:
814
0
        {
815
0
            uno::Sequence< beans::PropertyValue >   aPropSeq;
816
817
0
            if ( rVal >>= aPropSeq )
818
0
            {
819
0
                css::drawing::LineDash aLineDash;
820
0
                OUString aName;
821
0
                bool bLineDash( false );
822
0
                for (const auto& rProp : aPropSeq)
823
0
                {
824
0
                    if ( rProp.Name == "Name" )
825
0
                        rProp.Value >>= aName;
826
0
                    else if ( rProp.Name == "LineDash" )
827
0
                    {
828
0
                        if ( rProp.Value >>= aLineDash )
829
0
                            bLineDash = true;
830
0
                    }
831
0
                }
832
833
0
                SetName( aName );
834
0
                if ( bLineDash )
835
0
                {
836
0
                    XDash aXDash;
837
838
0
                    aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(aLineDash.Style)));
839
0
                    aXDash.SetDots(aLineDash.Dots);
840
0
                    aXDash.SetDotLen(aLineDash.DotLen);
841
0
                    aXDash.SetDashes(aLineDash.Dashes);
842
0
                    aXDash.SetDashLen(aLineDash.DashLen);
843
0
                    aXDash.SetDistance(aLineDash.Distance);
844
845
0
                    if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
846
0
                        aXDash.SetDots(1);
847
848
0
                    SetDashValue( aXDash );
849
0
                }
850
851
0
                return true;
852
0
            }
853
854
0
            return false;
855
0
        }
856
857
0
        case MID_NAME:
858
0
        {
859
0
            OUString aName;
860
0
            if (!(rVal >>= aName))
861
0
                return false;
862
0
            SetName( aName );
863
0
            break;
864
0
        }
865
866
693
        case MID_LINEDASH:
867
693
        {
868
693
            css::drawing::LineDash aLineDash;
869
693
            if(!(rVal >>= aLineDash))
870
0
                return false;
871
872
693
            XDash aXDash;
873
874
693
            aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(aLineDash.Style)));
875
693
            aXDash.SetDots(aLineDash.Dots);
876
693
            aXDash.SetDotLen(aLineDash.DotLen);
877
693
            aXDash.SetDashes(aLineDash.Dashes);
878
693
            aXDash.SetDashLen(aLineDash.DashLen);
879
693
            aXDash.SetDistance(aLineDash.Distance);
880
881
693
            if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
882
8
                aXDash.SetDots(1);
883
884
693
            SetDashValue( aXDash );
885
693
            break;
886
693
        }
887
888
0
        case MID_LINEDASH_STYLE:
889
0
        {
890
0
            sal_Int16 nVal = sal_Int16();
891
0
            if(!(rVal >>= nVal))
892
0
                return false;
893
894
0
            XDash aXDash = GetDashValue();
895
0
            aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(nVal)));
896
897
0
            if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
898
0
                aXDash.SetDots(1);
899
900
0
            SetDashValue( aXDash );
901
902
0
            break;
903
0
        }
904
905
0
        case MID_LINEDASH_DOTS:
906
0
        case MID_LINEDASH_DASHES:
907
0
        {
908
0
            sal_Int16 nVal = sal_Int16();
909
0
            if(!(rVal >>= nVal))
910
0
                return false;
911
912
0
            XDash aXDash = GetDashValue();
913
0
            if ( nMemberId == MID_LINEDASH_DOTS )
914
0
                aXDash.SetDots( nVal );
915
0
            else
916
0
                aXDash.SetDashes( nVal );
917
918
0
            if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
919
0
                aXDash.SetDots(1);
920
921
0
            SetDashValue( aXDash );
922
0
            break;
923
0
        }
924
925
0
        case MID_LINEDASH_DOTLEN:
926
0
        case MID_LINEDASH_DASHLEN:
927
0
        case MID_LINEDASH_DISTANCE:
928
0
        {
929
0
            sal_uInt32 nVal = 0;
930
0
            if(!(rVal >>= nVal))
931
0
                return false;
932
933
0
            XDash aXDash = GetDashValue();
934
0
            if ( nMemberId == MID_LINEDASH_DOTLEN )
935
0
                aXDash.SetDotLen( nVal );
936
0
            else if ( nMemberId == MID_LINEDASH_DASHLEN )
937
0
                aXDash.SetDashLen( nVal );
938
0
            else
939
0
                aXDash.SetDistance( nVal );
940
941
0
            if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
942
0
                aXDash.SetDots(1);
943
944
0
            SetDashValue( aXDash );
945
0
            break;
946
0
        }
947
693
    }
948
949
693
    return true;
950
693
}
951
952
bool XLineDashItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
953
32.5k
{
954
32.5k
    return static_cast<const XLineDashItem*>(p1)->GetDashValue() == static_cast<const XLineDashItem*>(p2)->GetDashValue();
955
32.5k
}
956
957
std::unique_ptr<XLineDashItem> XLineDashItem::checkForUniqueItem( SdrModel& rModel ) const
958
16.0k
{
959
16.0k
    const OUString aUniqueName(CheckNamedItem(
960
16.0k
        XATTR_LINEDASH, &rModel.GetItemPool(),
961
16.0k
        XLineDashItem::CompareValueFunc, RID_SVXSTR_DASH20,
962
16.0k
        rModel.GetPropertyList(XPropertyListType::Dash)));
963
964
    // if the given name is not valid, replace it!
965
16.0k
    if( aUniqueName != GetName() )
966
15.6k
        return std::make_unique<XLineDashItem>( aUniqueName, m_aDash );
967
968
375
    return nullptr;
969
16.0k
}
970
971
0
SfxPoolItem* XLineWidthItem::CreateDefault() {return new XLineWidthItem;}
972
973
XLineWidthItem::XLineWidthItem(tools::Long nWidth) :
974
258k
    SfxMetricItem(XATTR_LINEWIDTH, nWidth)
975
258k
{
976
258k
}
977
978
XLineWidthItem* XLineWidthItem::Clone(SfxItemPool* /*pPool*/) const
979
189k
{
980
189k
    return new XLineWidthItem(*this);
981
189k
}
982
983
bool XLineWidthItem::GetPresentation
984
(
985
    SfxItemPresentation /*ePres*/,
986
    MapUnit             eCoreUnit,
987
    MapUnit             ePresUnit,
988
    OUString&           rText, const IntlWrapper& rIntl
989
)   const
990
0
{
991
0
    rText = GetMetricText( static_cast<tools::Long>(GetValue()),
992
0
                            eCoreUnit, ePresUnit, &rIntl) +
993
0
            " " + EditResId( GetMetricId( ePresUnit) );
994
0
    return true;
995
0
}
996
997
bool XLineWidthItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
998
309
{
999
309
    sal_Int32 nValue = GetValue();
1000
309
    if( 0 != (nMemberId&CONVERT_TWIPS) )
1001
0
        nValue = convertTwipToMm100(nValue);
1002
1003
309
    rVal <<= nValue;
1004
309
    return true;
1005
309
}
1006
1007
bool XLineWidthItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
1008
85.2k
{
1009
85.2k
    sal_Int32 nValue = 0;
1010
85.2k
    rVal >>= nValue;
1011
85.2k
    if( 0 != (nMemberId&CONVERT_TWIPS) )
1012
0
        nValue = o3tl::toTwips(nValue, o3tl::Length::mm100);
1013
1014
85.2k
    SetValue( nValue );
1015
85.2k
    return true;
1016
85.2k
}
1017
1018
0
SfxPoolItem* XLineColorItem::CreateDefault() { return new XLineColorItem; }
1019
1020
XLineColorItem::XLineColorItem(sal_Int32 nIndex, const Color& rTheColor) :
1021
0
    XColorItem(XATTR_LINECOLOR, nIndex, rTheColor)
1022
0
{
1023
0
}
1024
1025
XLineColorItem::XLineColorItem(const OUString& rName, const Color& rTheColor) :
1026
420k
    XColorItem(XATTR_LINECOLOR, rName, rTheColor)
1027
420k
{
1028
420k
}
1029
1030
XLineColorItem* XLineColorItem::Clone(SfxItemPool* /*pPool*/) const
1031
293k
{
1032
293k
    return new XLineColorItem(*this);
1033
293k
}
1034
1035
bool XLineColorItem::GetPresentation
1036
(
1037
    SfxItemPresentation /*ePres*/,
1038
    MapUnit             /*eCoreUnit*/,
1039
    MapUnit             /*ePresUnit*/,
1040
    OUString&           rText, const IntlWrapper&
1041
)   const
1042
0
{
1043
0
    rText = GetName();
1044
0
    return true;
1045
0
}
1046
1047
bool XLineColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId) const
1048
309
{
1049
309
    nMemberId &= ~CONVERT_TWIPS;
1050
309
    switch (nMemberId)
1051
309
    {
1052
0
        case MID_COMPLEX_COLOR:
1053
0
        {
1054
0
            auto xComplexColor = model::color::createXComplexColor(getComplexColor());
1055
0
            rVal <<= xComplexColor;
1056
0
            break;
1057
0
        }
1058
0
        case MID_COMPLEX_COLOR_JSON:
1059
0
        {
1060
0
            rVal <<= OStringToOUString(model::color::convertToJSON(getComplexColor()), RTL_TEXTENCODING_UTF8);
1061
0
            break;
1062
0
        }
1063
309
        default:
1064
309
        {
1065
309
            rVal <<= GetColorValue().GetRGBColor();
1066
309
            break;
1067
0
        }
1068
309
    }
1069
309
    return true;
1070
309
}
1071
1072
bool XLineColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId)
1073
26.3k
{
1074
26.3k
    nMemberId &= ~CONVERT_TWIPS;
1075
26.3k
    switch(nMemberId)
1076
26.3k
    {
1077
11.2k
        case MID_COMPLEX_COLOR:
1078
11.2k
        {
1079
11.2k
            css::uno::Reference<css::util::XComplexColor> xComplexColor;
1080
11.2k
            if (!(rVal >>= xComplexColor))
1081
0
                return false;
1082
11.2k
            setComplexColor(model::color::getFromXComplexColor(xComplexColor));
1083
11.2k
        }
1084
0
        break;
1085
0
        case MID_COMPLEX_COLOR_JSON:
1086
0
        {
1087
0
            OUString sComplexColorJson;
1088
0
            if (!(rVal >>= sComplexColorJson))
1089
0
                return false;
1090
1091
0
            if (sComplexColorJson.isEmpty())
1092
0
                return false;
1093
0
            model::ComplexColor aComplexColor;
1094
0
            OString aJSON = OUStringToOString(sComplexColorJson, RTL_TEXTENCODING_ASCII_US);
1095
0
            model::color::convertFromJSON(aJSON, aComplexColor);
1096
0
            setComplexColor(aComplexColor);
1097
0
        }
1098
0
        break;
1099
15.1k
        default:
1100
15.1k
        {
1101
15.1k
            sal_Int32 nValue;
1102
15.1k
            if(!(rVal >>= nValue ))
1103
0
                return false;
1104
1105
15.1k
            SetColorValue( Color(ColorTransparency, nValue) );
1106
15.1k
            break;
1107
15.1k
        }
1108
26.3k
    }
1109
26.3k
    return true;
1110
26.3k
}
1111
1112
1113
0
SfxPoolItem* XLineStartItem::CreateDefault() {return new XLineStartItem;}
1114
1115
XLineStartItem::XLineStartItem(sal_Int32 nIndex)
1116
31.5k
:   NameOrIndex(XATTR_LINESTART, nIndex)
1117
31.5k
{
1118
31.5k
}
1119
1120
XLineStartItem::XLineStartItem(const OUString& rName, basegfx::B2DPolyPolygon aPolyPolygon)
1121
100k
:   NameOrIndex(XATTR_LINESTART, rName),
1122
100k
    maPolyPolygon(std::move(aPolyPolygon))
1123
100k
{
1124
100k
}
1125
1126
XLineStartItem::XLineStartItem(const XLineStartItem& rItem)
1127
83.3k
:   NameOrIndex(rItem),
1128
83.3k
    maPolyPolygon(rItem.maPolyPolygon)
1129
83.3k
{
1130
83.3k
}
1131
1132
XLineStartItem::XLineStartItem(basegfx::B2DPolyPolygon aPolyPolygon)
1133
26.9k
:   NameOrIndex( XATTR_LINESTART, -1 ),
1134
26.9k
    maPolyPolygon(std::move(aPolyPolygon))
1135
26.9k
{
1136
26.9k
}
1137
1138
XLineStartItem* XLineStartItem::Clone(SfxItemPool* /*pPool*/) const
1139
83.3k
{
1140
83.3k
    return new XLineStartItem(*this);
1141
83.3k
}
1142
1143
bool XLineStartItem::operator==(const SfxPoolItem& rItem) const
1144
209k
{
1145
209k
    return ( NameOrIndex::operator==(rItem) && static_cast<const XLineStartItem&>(rItem).maPolyPolygon == maPolyPolygon );
1146
209k
}
1147
1148
bool XLineStartItem::GetPresentation
1149
(
1150
    SfxItemPresentation /*ePres*/,
1151
    MapUnit             /*eCoreUnit*/,
1152
    MapUnit             /*ePresUnit*/,
1153
    OUString&           rText, const IntlWrapper&
1154
)   const
1155
0
{
1156
0
    rText = GetName();
1157
0
    return true;
1158
0
}
1159
1160
bool XLineStartItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
1161
0
{
1162
0
    nMemberId &= ~CONVERT_TWIPS;
1163
0
    if( nMemberId == MID_NAME )
1164
0
    {
1165
0
        rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
1166
0
    }
1167
0
    else
1168
0
    {
1169
0
        css::drawing::PolyPolygonBezierCoords aBezier;
1170
0
        basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( maPolyPolygon, aBezier );
1171
0
        rVal <<= aBezier;
1172
0
    }
1173
1174
0
    return true;
1175
0
}
1176
1177
bool XLineStartItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
1178
32.9k
{
1179
32.9k
    nMemberId &= ~CONVERT_TWIPS;
1180
32.9k
    if( nMemberId == MID_NAME )
1181
0
    {
1182
0
        return false;
1183
0
    }
1184
32.9k
    else
1185
32.9k
    {
1186
32.9k
        maPolyPolygon.clear();
1187
1188
32.9k
        if( rVal.hasValue() )
1189
27.8k
        {
1190
27.8k
            auto pCoords = o3tl::tryAccess<css::drawing::PolyPolygonBezierCoords>(
1191
27.8k
                rVal);
1192
27.8k
            if( !pCoords )
1193
0
                return false;
1194
1195
27.8k
            if( pCoords->Coordinates.getLength() > 0 )
1196
27.8k
            {
1197
27.8k
                maPolyPolygon = basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( *pCoords );
1198
                // #i72807# close line start/end polygons hard
1199
                // maPolyPolygon.setClosed(true);
1200
27.8k
            }
1201
27.8k
        }
1202
32.9k
    }
1203
1204
32.9k
    return true;
1205
32.9k
}
1206
1207
static bool HasConflictingStartEndItems(const SfxItemPool& pool, std::u16string_view name,
1208
                                        const basegfx::B2DPolyPolygon& value)
1209
34.6k
{
1210
    // XATTR_LINESTART
1211
34.6k
    for (const SfxPoolItem* p : pool.GetItemSurrogatesForItem(SfxItemType::XLineStartItemType))
1212
63.7k
    {
1213
63.7k
        auto pItem = static_cast<const XLineStartItem*>(p);
1214
1215
63.7k
        if (pItem->GetName() == name)
1216
21.8k
        {
1217
            // if there is already an item with the same name and the same value it's not a conflict
1218
21.8k
            if (pItem->GetLineStartValue() == value)
1219
21.1k
                break;
1220
            // same name but different value
1221
688
            return true;
1222
21.8k
        }
1223
63.7k
    }
1224
    // XATTR_LINEEND
1225
33.9k
    for (const SfxPoolItem* p : pool.GetItemSurrogatesForItem(SfxItemType::XLineEndItemType))
1226
93.8k
    {
1227
93.8k
        auto pItem = static_cast<const XLineEndItem*>(p);
1228
1229
93.8k
        if (pItem->GetName() == name)
1230
29.2k
        {
1231
            // if there is already an item with the same name and the same value it's not a conflict
1232
29.2k
            if (pItem->GetLineEndValue() == value)
1233
28.9k
                break;
1234
            // same name but different value
1235
334
            return true;
1236
29.2k
        }
1237
93.8k
    }
1238
33.6k
    return false;
1239
33.9k
}
1240
1241
/** this function searches in both the models pool and the styles pool for XLineStartItem and
1242
    XLineEndItem with the same name and returns true when it exists and has a different value. */
1243
static bool HasConflictingStartEndItems(const SdrModel& model, std::u16string_view name,
1244
                                        const basegfx::B2DPolyPolygon& value)
1245
20.4k
{
1246
20.4k
    return HasConflictingStartEndItems(model.GetItemPool(), name, value)
1247
20.4k
           || (model.GetStyleSheetPool()
1248
19.4k
               && HasConflictingStartEndItems(model.GetStyleSheetPool()->GetPool(), name, value));
1249
20.4k
}
1250
1251
static OUString CreateNameForValue(const SfxItemPool& pool, const basegfx::B2DPolyPolygon& value,
1252
                                   bool forceNew)
1253
50.8k
{
1254
50.8k
    sal_Int32 nUserIndex = 1;
1255
50.8k
    const OUString aUser(SvxResId(RID_SVXSTR_LINEEND));
1256
1257
    // XATTR_LINEEND first, because previous code preferred existing name from it
1258
50.8k
    for (const SfxPoolItem* p : pool.GetItemSurrogatesForItem(SfxItemType::XLineEndItemType))
1259
63.8k
    {
1260
63.8k
        auto pItem = static_cast<const XLineEndItem*>(p);
1261
1262
63.8k
        if (!pItem->GetName().isEmpty())
1263
48.0k
        {
1264
48.0k
            if (!forceNew && pItem->GetLineEndValue() == value)
1265
20.4k
                return pItem->GetName(); // Found existing
1266
1267
27.6k
            if (pItem->GetName().startsWith(aUser))
1268
16.6k
            {
1269
16.6k
                sal_Int32 nThisIndex = o3tl::toInt32(pItem->GetName().subView(aUser.getLength()));
1270
16.6k
                if (nThisIndex >= nUserIndex)
1271
7.77k
                    nUserIndex = nThisIndex + 1;
1272
16.6k
            }
1273
27.6k
        }
1274
63.8k
    }
1275
1276
    // XATTR_LINESTART
1277
30.3k
    for (const SfxPoolItem* p : pool.GetItemSurrogatesForItem(SfxItemType::XLineStartItemType))
1278
27.0k
    {
1279
27.0k
        auto pItem = static_cast<const XLineStartItem*>(p);
1280
1281
27.0k
        if (!pItem->GetName().isEmpty())
1282
22.1k
        {
1283
22.1k
            if (!forceNew && pItem->GetLineStartValue() == value)
1284
3.68k
                return pItem->GetName(); // Found existing
1285
1286
18.4k
            if (pItem->GetName().startsWith(aUser))
1287
7.37k
            {
1288
7.37k
                sal_Int32 nThisIndex = o3tl::toInt32(pItem->GetName().subView(aUser.getLength()));
1289
7.37k
                if (nThisIndex >= nUserIndex)
1290
877
                    nUserIndex = nThisIndex + 1;
1291
7.37k
            }
1292
18.4k
        }
1293
27.0k
    }
1294
1295
26.6k
    return aUser + " " + OUString::number(nUserIndex);
1296
30.3k
}
1297
1298
/** this function searches in both the models pool and the styles pool for XLineStartItem
1299
    and XLineEndItem with the same value or name and returns an item with the value of
1300
    this item and a unique name for an item with this value. */
1301
std::unique_ptr<XLineStartItem> XLineStartItem::checkForUniqueItem( SdrModel& rModel ) const
1302
43.3k
{
1303
43.3k
    std::unique_ptr<XLineStartItem> pTempItem;
1304
43.3k
    const XLineStartItem* pLineStartItem = this;
1305
1306
43.3k
    OUString aUniqueName( GetName() );
1307
1308
43.3k
    if( !maPolyPolygon.count() )
1309
915
    {
1310
        // if the polygon is empty, check if the name is empty
1311
915
        if( aUniqueName.isEmpty() )
1312
280
            return nullptr;
1313
1314
        // force empty name for empty polygons
1315
635
        return std::make_unique<XLineStartItem>( "", maPolyPolygon );
1316
915
    }
1317
1318
42.4k
    if( maPolyPolygon.count() > 1 )
1319
0
    {
1320
        // check if the polygon is closed
1321
0
        if(!maPolyPolygon.isClosed())
1322
0
        {
1323
            // force a closed polygon
1324
0
            basegfx::B2DPolyPolygon aNew(maPolyPolygon);
1325
0
            aNew.setClosed(true);
1326
0
            pTempItem.reset(new XLineStartItem( aUniqueName, std::move(aNew) ));
1327
0
            pLineStartItem = pTempItem.get();
1328
0
        }
1329
0
    }
1330
1331
42.4k
    bool bForceNew = false;
1332
1333
    // 2. if we have a name check if there is already an item with the
1334
    // same name in the documents pool with a different line end or start
1335
1336
42.4k
    if (!aUniqueName.isEmpty()
1337
42.4k
        && HasConflictingStartEndItems(rModel, pLineStartItem->GetName(),
1338
7.42k
                                       pLineStartItem->GetLineStartValue()))
1339
466
    {
1340
466
        bForceNew = true;
1341
466
        aUniqueName.clear();
1342
466
    }
1343
1344
    // if we have no name yet, find existing item with same content or
1345
    // create a unique name
1346
42.4k
    if( aUniqueName.isEmpty() )
1347
35.5k
    {
1348
35.5k
        aUniqueName = CreateNameForValue(rModel.GetItemPool(), pLineStartItem->GetLineStartValue(),
1349
35.5k
                                         bForceNew);
1350
35.5k
    }
1351
1352
    // if the given name is not valid, replace it!
1353
42.4k
    if( aUniqueName != GetName() || pTempItem )
1354
35.5k
    {
1355
35.5k
        if( pTempItem )
1356
0
        {
1357
0
            pTempItem->SetName( aUniqueName );
1358
0
            return pTempItem;
1359
0
        }
1360
35.5k
        else
1361
35.5k
        {
1362
35.5k
            return std::make_unique<XLineStartItem>( aUniqueName, maPolyPolygon );
1363
35.5k
        }
1364
35.5k
    }
1365
1366
6.95k
    return nullptr;
1367
42.4k
}
1368
1369
0
SfxPoolItem* XLineEndItem::CreateDefault() {return new XLineEndItem;}
1370
1371
XLineEndItem::XLineEndItem(sal_Int32 nIndex)
1372
31.5k
:   NameOrIndex(XATTR_LINEEND, nIndex)
1373
31.5k
{
1374
31.5k
}
1375
1376
XLineEndItem::XLineEndItem(const OUString& rName, basegfx::B2DPolyPolygon aPolyPolygon)
1377
63.6k
:   NameOrIndex(XATTR_LINEEND, rName),
1378
63.6k
    maPolyPolygon(std::move(aPolyPolygon))
1379
63.6k
{
1380
63.6k
}
1381
1382
XLineEndItem::XLineEndItem(const XLineEndItem& rItem)
1383
85.8k
:   NameOrIndex(rItem),
1384
85.8k
    maPolyPolygon(rItem.maPolyPolygon)
1385
85.8k
{
1386
85.8k
}
1387
1388
XLineEndItem::XLineEndItem(basegfx::B2DPolyPolygon aPolyPolygon)
1389
26.9k
:   NameOrIndex( XATTR_LINEEND, -1 ),
1390
26.9k
    maPolyPolygon(std::move(aPolyPolygon))
1391
26.9k
{
1392
26.9k
}
1393
1394
XLineEndItem* XLineEndItem::Clone(SfxItemPool* /*pPool*/) const
1395
85.8k
{
1396
85.8k
    return new XLineEndItem(*this);
1397
85.8k
}
1398
1399
bool XLineEndItem::operator==(const SfxPoolItem& rItem) const
1400
224k
{
1401
224k
    return ( NameOrIndex::operator==(rItem) && static_cast<const XLineEndItem&>(rItem).maPolyPolygon == maPolyPolygon );
1402
224k
}
1403
1404
1405
/** this function searches in both the models pool and the styles pool for XLineStartItem
1406
    and XLineEndItem with the same value or name and returns an item with the value of
1407
    this item and a unique name for an item with this value. */
1408
std::unique_ptr<XLineEndItem> XLineEndItem::checkForUniqueItem( SdrModel& rModel ) const
1409
28.9k
{
1410
28.9k
    std::unique_ptr<XLineEndItem> pTempItem;
1411
28.9k
    const XLineEndItem* pLineEndItem = this;
1412
1413
28.9k
    OUString aUniqueName( GetName() );
1414
1415
28.9k
    if( !maPolyPolygon.count() )
1416
1.06k
    {
1417
        // if the polygon is empty, check if the name is empty
1418
1.06k
        if( aUniqueName.isEmpty() )
1419
319
            return nullptr;
1420
1421
        // force empty name for empty polygons
1422
743
        return std::make_unique<XLineEndItem>( "", maPolyPolygon );
1423
1.06k
    }
1424
1425
27.8k
    if( maPolyPolygon.count() > 1 )
1426
0
    {
1427
        // check if the polygon is closed
1428
0
        if(!maPolyPolygon.isClosed())
1429
0
        {
1430
            // force a closed polygon
1431
0
            basegfx::B2DPolyPolygon aNew(maPolyPolygon);
1432
0
            aNew.setClosed(true);
1433
0
            pTempItem.reset(new XLineEndItem( aUniqueName, std::move(aNew) ));
1434
0
            pLineEndItem = pTempItem.get();
1435
0
        }
1436
0
    }
1437
1438
27.8k
    bool bForceNew = false;
1439
1440
    // 2. if we have a name check if there is already an item with the
1441
    // same name in the documents pool with a different line end or start
1442
1443
27.8k
    if (!aUniqueName.isEmpty()
1444
27.8k
        && HasConflictingStartEndItems(rModel, pLineEndItem->GetName(),
1445
13.0k
                                       pLineEndItem->GetLineEndValue()))
1446
556
    {
1447
556
        bForceNew = true;
1448
556
        aUniqueName.clear();
1449
556
    }
1450
1451
    // if we have no name yet, find existing item with same content or
1452
    // create a unique name
1453
27.8k
    if( aUniqueName.isEmpty() )
1454
15.3k
    {
1455
15.3k
        aUniqueName = CreateNameForValue(rModel.GetItemPool(), pLineEndItem->GetLineEndValue(),
1456
15.3k
                                         bForceNew);
1457
15.3k
    }
1458
1459
    // if the given name is not valid, replace it!
1460
27.8k
    if( aUniqueName != GetName() || pTempItem )
1461
15.3k
    {
1462
15.3k
        if( pTempItem )
1463
0
        {
1464
0
            pTempItem->SetName( aUniqueName );
1465
0
            return pTempItem;
1466
0
        }
1467
15.3k
        else
1468
15.3k
        {
1469
15.3k
            return std::make_unique<XLineEndItem>( aUniqueName, maPolyPolygon );
1470
15.3k
        }
1471
15.3k
    }
1472
1473
12.4k
    return nullptr;
1474
27.8k
}
1475
1476
bool XLineEndItem::GetPresentation
1477
(
1478
    SfxItemPresentation /*ePres*/,
1479
    MapUnit             /*eCoreUnit*/,
1480
    MapUnit             /*ePresUnit*/,
1481
    OUString&           rText, const IntlWrapper&
1482
)   const
1483
0
{
1484
0
    rText = GetName();
1485
0
    return true;
1486
0
}
1487
1488
bool XLineEndItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
1489
0
{
1490
0
    nMemberId &= ~CONVERT_TWIPS;
1491
0
    if( nMemberId == MID_NAME )
1492
0
    {
1493
0
        rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
1494
0
    }
1495
0
    else
1496
0
    {
1497
0
        css::drawing::PolyPolygonBezierCoords aBezier;
1498
0
        basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( maPolyPolygon, aBezier );
1499
0
        rVal <<= aBezier;
1500
0
    }
1501
0
    return true;
1502
0
}
1503
1504
bool XLineEndItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
1505
32.9k
{
1506
32.9k
    nMemberId &= ~CONVERT_TWIPS;
1507
32.9k
    if( nMemberId == MID_NAME )
1508
0
    {
1509
0
        return false;
1510
0
    }
1511
32.9k
    else
1512
32.9k
    {
1513
32.9k
        maPolyPolygon.clear();
1514
1515
32.9k
        if( rVal.hasValue() )
1516
27.8k
        {
1517
27.8k
            auto pCoords = o3tl::tryAccess<css::drawing::PolyPolygonBezierCoords>(
1518
27.8k
                rVal);
1519
27.8k
            if( !pCoords )
1520
0
                return false;
1521
1522
27.8k
            if( pCoords->Coordinates.getLength() > 0 )
1523
27.8k
            {
1524
27.8k
                maPolyPolygon = basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( *pCoords );
1525
                // #i72807# close line start/end polygons hard
1526
                // maPolyPolygon.setClosed(true);
1527
27.8k
            }
1528
27.8k
        }
1529
32.9k
    }
1530
1531
32.9k
    return true;
1532
32.9k
}
1533
1534
XLineStartWidthItem::XLineStartWidthItem(tools::Long nWidth) :
1535
91.4k
    SfxMetricItem(XATTR_LINESTARTWIDTH, nWidth)
1536
91.4k
{
1537
91.4k
}
1538
1539
XLineStartWidthItem* XLineStartWidthItem::Clone(SfxItemPool* /*pPool*/) const
1540
87.1k
{
1541
87.1k
    return new XLineStartWidthItem(*this);
1542
87.1k
}
1543
1544
bool XLineStartWidthItem::GetPresentation
1545
(
1546
    SfxItemPresentation /*ePres*/,
1547
    MapUnit             eCoreUnit,
1548
    MapUnit             ePresUnit,
1549
    OUString&           rText, const IntlWrapper& rIntl
1550
)   const
1551
0
{
1552
0
    rText = GetMetricText( static_cast<tools::Long>(GetValue()),
1553
0
                            eCoreUnit, ePresUnit, &rIntl) +
1554
0
            " " + EditResId( GetMetricId( ePresUnit) );
1555
0
    return true;
1556
0
}
1557
1558
bool XLineStartWidthItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1559
0
{
1560
0
    rVal <<= GetValue();
1561
0
    return true;
1562
0
}
1563
1564
bool XLineStartWidthItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1565
969
{
1566
969
    sal_Int32 nValue = 0;
1567
969
    rVal >>= nValue;
1568
969
    SetValue( nValue );
1569
969
    return true;
1570
969
}
1571
1572
XLineEndWidthItem::XLineEndWidthItem(tools::Long nWidth) :
1573
74.5k
   SfxMetricItem(XATTR_LINEENDWIDTH, nWidth)
1574
74.5k
{
1575
74.5k
}
1576
1577
XLineEndWidthItem* XLineEndWidthItem::Clone(SfxItemPool* /*pPool*/) const
1578
68.4k
{
1579
68.4k
    return new XLineEndWidthItem(*this);
1580
68.4k
}
1581
1582
bool XLineEndWidthItem::GetPresentation
1583
(
1584
    SfxItemPresentation /*ePres*/,
1585
    MapUnit             eCoreUnit,
1586
    MapUnit             ePresUnit,
1587
    OUString&           rText, const IntlWrapper& rIntl
1588
)   const
1589
0
{
1590
0
    rText = GetMetricText( static_cast<tools::Long>(GetValue()),
1591
0
                            eCoreUnit, ePresUnit, &rIntl) +
1592
0
            " " + EditResId( GetMetricId( ePresUnit) );
1593
0
    return true;
1594
0
}
1595
1596
bool XLineEndWidthItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1597
0
{
1598
0
    rVal <<= GetValue();
1599
0
    return true;
1600
0
}
1601
1602
bool XLineEndWidthItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1603
1.63k
{
1604
1.63k
    sal_Int32 nValue = 0;
1605
1.63k
    rVal >>= nValue;
1606
1.63k
    SetValue( nValue );
1607
1.63k
    return true;
1608
1.63k
}
1609
1610
XLineStartCenterItem::XLineStartCenterItem(bool bStartCenter) :
1611
64.4k
    SfxBoolItem(XATTR_LINESTARTCENTER, bStartCenter)
1612
64.4k
{
1613
64.4k
}
1614
1615
XLineStartCenterItem* XLineStartCenterItem::Clone(SfxItemPool* /*pPool*/) const
1616
59.7k
{
1617
59.7k
    return new XLineStartCenterItem(*this);
1618
59.7k
}
1619
1620
bool XLineStartCenterItem::GetPresentation
1621
(
1622
    SfxItemPresentation /*ePres*/,
1623
    MapUnit             /*eCoreUnit*/,
1624
    MapUnit             /*ePresUnit*/,
1625
    OUString&           rText, const IntlWrapper&
1626
)   const
1627
0
{
1628
0
    rText = SvxResId(GetValue() ? RID_SVXSTR_CENTERED : RID_SVXSTR_NOTCENTERED);
1629
0
    return true;
1630
0
}
1631
1632
bool XLineStartCenterItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1633
0
{
1634
0
    bool bValue = GetValue();
1635
0
    rVal <<= bValue;
1636
0
    return true;
1637
0
}
1638
1639
bool XLineStartCenterItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1640
821
{
1641
821
    auto b = o3tl::tryAccess<bool>(rVal);
1642
821
    if( !b.has_value() )
1643
0
        return false;
1644
1645
821
    SetValue( *b );
1646
821
    return true;
1647
821
}
1648
1649
XLineEndCenterItem::XLineEndCenterItem(bool bEndCenter) :
1650
47.6k
    SfxBoolItem(XATTR_LINEENDCENTER, bEndCenter)
1651
47.6k
{
1652
47.6k
}
1653
1654
XLineEndCenterItem* XLineEndCenterItem::Clone(SfxItemPool* /*pPool*/) const
1655
40.9k
{
1656
40.9k
    return new XLineEndCenterItem(*this);
1657
40.9k
}
1658
1659
bool XLineEndCenterItem::GetPresentation
1660
(
1661
    SfxItemPresentation /*ePres*/,
1662
    MapUnit             /*eCoreUnit*/,
1663
    MapUnit             /*ePresUnit*/,
1664
    OUString&           rText, const IntlWrapper&
1665
)   const
1666
0
{
1667
0
    rText = SvxResId(GetValue() ? RID_SVXSTR_CENTERED : RID_SVXSTR_NOTCENTERED);
1668
0
    return true;
1669
0
}
1670
1671
bool XLineEndCenterItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1672
0
{
1673
0
    bool bValue = GetValue();
1674
0
    rVal <<= bValue;
1675
0
    return true;
1676
0
}
1677
1678
bool XLineEndCenterItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1679
1.26k
{
1680
1.26k
    auto b = o3tl::tryAccess<bool>(rVal);
1681
1.26k
    if( !b.has_value() )
1682
0
        return false;
1683
1684
1.26k
    SetValue( *b );
1685
1.26k
    return true;
1686
1.26k
}
1687
1688
// --- fill attributes ---
1689
1690
1691
0
SfxPoolItem* XFillStyleItem::CreateDefault() { return new XFillStyleItem; }
1692
1693
XFillStyleItem::XFillStyleItem(drawing::FillStyle eFillStyle) :
1694
3.30M
    SfxEnumItem(XATTR_FILLSTYLE, eFillStyle)
1695
3.30M
{
1696
3.30M
}
1697
1698
XFillStyleItem* XFillStyleItem::Clone(SfxItemPool* /*pPool*/) const
1699
1.08M
{
1700
1.08M
    return new XFillStyleItem( *this );
1701
1.08M
}
1702
1703
bool XFillStyleItem::GetPresentation
1704
(
1705
    SfxItemPresentation /*ePres*/,
1706
    MapUnit             /*eCoreUnit*/,
1707
    MapUnit             /*ePresUnit*/,
1708
    OUString&           rText, const IntlWrapper&
1709
)   const
1710
0
{
1711
0
    rText.clear();
1712
1713
0
    TranslateId pId;
1714
1715
0
    switch( GetValue() )
1716
0
    {
1717
0
        case drawing::FillStyle_NONE:
1718
0
            pId = RID_SVXSTR_INVISIBLE;
1719
0
            break;
1720
0
        case drawing::FillStyle_SOLID:
1721
0
            pId = RID_SVXSTR_SOLID;
1722
0
            break;
1723
0
        case drawing::FillStyle_GRADIENT:
1724
0
            pId = RID_SVXSTR_GRADIENT;
1725
0
            break;
1726
0
        case drawing::FillStyle_HATCH:
1727
0
            pId = RID_SVXSTR_HATCH;
1728
0
            break;
1729
0
        case drawing::FillStyle_BITMAP:
1730
0
            pId = RID_SVXSTR_BITMAP;
1731
0
            break;
1732
0
        default: break;
1733
0
    }
1734
1735
0
    if (pId)
1736
0
        rText = SvxResId(pId);
1737
0
    return true;
1738
0
}
1739
1740
bool XFillStyleItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1741
21.7k
{
1742
21.7k
    css::drawing::FillStyle eFS = GetValue();
1743
1744
21.7k
    rVal <<= eFS;
1745
1746
21.7k
    return true;
1747
21.7k
}
1748
1749
bool XFillStyleItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1750
179k
{
1751
179k
    css::drawing::FillStyle eFS;
1752
179k
    if(!(rVal >>= eFS))
1753
0
    {
1754
        // also try an int (for Basic)
1755
0
        sal_Int32 nFS = 0;
1756
0
        if(!(rVal >>= nFS))
1757
0
            return false;
1758
0
        eFS = static_cast<css::drawing::FillStyle>(nFS);
1759
0
    }
1760
1761
179k
    SetValue( eFS );
1762
1763
179k
    return true;
1764
179k
}
1765
1766
void XFillStyleItem::dumpAsXml(xmlTextWriterPtr pWriter) const
1767
0
{
1768
0
    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XFillStyleItem"));
1769
0
    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1770
0
    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(static_cast<sal_Int16>(GetValue())).getStr()));
1771
1772
0
    OUString aPresentation;
1773
0
    IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
1774
0
    GetPresentation(SfxItemPresentation::Nameless, MapUnit::Map100thMM, MapUnit::Map100thMM, aPresentation, aIntlWrapper);
1775
0
    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), BAD_CAST(aPresentation.toUtf8().getStr()));
1776
1777
0
    (void)xmlTextWriterEndElement(pWriter);
1778
0
}
1779
1780
boost::property_tree::ptree XFillStyleItem::dumpAsJSON() const
1781
0
{
1782
0
    boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
1783
1784
0
    if (Which() == XATTR_FILLSTYLE)
1785
0
        aTree.put("commandName", ".uno:FillStyle");
1786
1787
0
    OUString sValue;
1788
1789
0
    switch( GetValue() )
1790
0
    {
1791
0
        case drawing::FillStyle_NONE:
1792
0
            sValue = "NONE";
1793
0
            break;
1794
0
        case drawing::FillStyle_SOLID:
1795
0
            sValue = "SOLID";
1796
0
            break;
1797
0
        case drawing::FillStyle_GRADIENT:
1798
0
            sValue = "GRADIENT";
1799
0
            break;
1800
0
        case drawing::FillStyle_HATCH:
1801
0
            sValue = "HATCH";
1802
0
            break;
1803
0
        case drawing::FillStyle_BITMAP:
1804
0
            sValue = "BITMAP";
1805
0
            break;
1806
0
        default: break;
1807
0
    }
1808
1809
0
    aTree.put("state", sValue);
1810
1811
0
    return aTree;
1812
0
}
1813
1814
1815
0
SfxPoolItem* XFillColorItem::CreateDefault() { return new XFillColorItem; }
1816
1817
XFillColorItem::XFillColorItem(sal_Int32 nIndex, const Color& rTheColor) :
1818
0
    XColorItem(XATTR_FILLCOLOR, nIndex, rTheColor)
1819
0
{
1820
0
}
1821
1822
XFillColorItem::XFillColorItem(const OUString& rName, const Color& rTheColor) :
1823
1.69M
    XColorItem(XATTR_FILLCOLOR, rName, rTheColor)
1824
1.69M
{
1825
1.69M
}
1826
1827
XFillColorItem* XFillColorItem::Clone(SfxItemPool* /*pPool*/) const
1828
603k
{
1829
603k
    return new XFillColorItem(*this);
1830
603k
}
1831
1832
bool XFillColorItem::GetPresentation
1833
(
1834
    SfxItemPresentation /*ePres*/,
1835
    MapUnit             /*eCoreUnit*/,
1836
    MapUnit             /*ePresUnit*/,
1837
    OUString&           rText, const IntlWrapper&
1838
)   const
1839
0
{
1840
0
    rText = GetName();
1841
0
    return true;
1842
0
}
1843
1844
bool XFillColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
1845
1.34k
{
1846
1.34k
    nMemberId &= ~CONVERT_TWIPS;
1847
1.34k
    switch (nMemberId)
1848
1.34k
    {
1849
0
        case MID_COLOR_THEME_INDEX:
1850
0
        {
1851
0
            rVal <<= sal_Int16(getComplexColor().getThemeColorType());
1852
0
            break;
1853
0
        }
1854
0
        case MID_COLOR_LUM_MOD:
1855
0
        {
1856
0
            sal_Int16 nValue = 10000;
1857
0
            for (auto const& rTransform : getComplexColor().getTransformations())
1858
0
            {
1859
0
                if (rTransform.meType == model::TransformationType::LumMod)
1860
0
                    nValue = rTransform.mnValue;
1861
0
            }
1862
0
            rVal <<= nValue;
1863
0
            break;
1864
0
        }
1865
0
        case MID_COLOR_LUM_OFF:
1866
0
        {
1867
0
            sal_Int16 nValue = 0;
1868
0
            for (auto const& rTransform : getComplexColor().getTransformations())
1869
0
            {
1870
0
                if (rTransform.meType == model::TransformationType::LumOff)
1871
0
                    nValue = rTransform.mnValue;
1872
0
            }
1873
0
            rVal <<= nValue;
1874
0
            break;
1875
0
        }
1876
591
        case MID_COMPLEX_COLOR:
1877
591
        {
1878
591
            auto xComplexColor = model::color::createXComplexColor(getComplexColor());
1879
591
            rVal <<= xComplexColor;
1880
591
            break;
1881
0
        }
1882
0
        case MID_COMPLEX_COLOR_JSON:
1883
0
        {
1884
0
            rVal <<= OStringToOUString(model::color::convertToJSON(getComplexColor()), RTL_TEXTENCODING_UTF8);
1885
0
            break;
1886
0
        }
1887
749
        default:
1888
749
        {
1889
749
            rVal <<= GetColorValue().GetRGBColor();
1890
749
            break;
1891
0
        }
1892
1.34k
    }
1893
1894
1.34k
    return true;
1895
1.34k
}
1896
1897
bool XFillColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
1898
52.6k
{
1899
52.6k
    nMemberId &= ~CONVERT_TWIPS;
1900
52.6k
    switch(nMemberId)
1901
52.6k
    {
1902
0
        case MID_COLOR_THEME_INDEX:
1903
0
        {
1904
0
            sal_Int16 nIndex = -1;
1905
0
            if (!(rVal >>= nIndex))
1906
0
                return false;
1907
0
            getComplexColor().setThemeColor(model::convertToThemeColorType(nIndex));
1908
0
        }
1909
0
        break;
1910
0
        case MID_COLOR_LUM_MOD:
1911
0
        {
1912
0
            sal_Int16 nLumMod = 10000;
1913
0
            if (!(rVal >>= nLumMod))
1914
0
                return false;
1915
0
            getComplexColor().removeTransformations(model::TransformationType::LumMod);
1916
0
            getComplexColor().addTransformation({model::TransformationType::LumMod, nLumMod});
1917
0
        }
1918
0
        break;
1919
0
        case MID_COLOR_LUM_OFF:
1920
0
        {
1921
0
            sal_Int16 nLumOff = 0;
1922
0
            if (!(rVal >>= nLumOff))
1923
0
                return false;
1924
0
            getComplexColor().removeTransformations(model::TransformationType::LumOff);
1925
0
            getComplexColor().addTransformation({model::TransformationType::LumOff, nLumOff});
1926
0
        }
1927
0
        break;
1928
18.0k
        case MID_COMPLEX_COLOR:
1929
18.0k
        {
1930
18.0k
            css::uno::Reference<css::util::XComplexColor> xComplexColor;
1931
18.0k
            if (!(rVal >>= xComplexColor))
1932
0
                return false;
1933
18.0k
            setComplexColor(model::color::getFromXComplexColor(xComplexColor));
1934
18.0k
        }
1935
0
        break;
1936
0
        case MID_COMPLEX_COLOR_JSON:
1937
0
        {
1938
0
            OUString sComplexColorJson;
1939
0
            if (!(rVal >>= sComplexColorJson))
1940
0
                return false;
1941
1942
0
            if (sComplexColorJson.isEmpty())
1943
0
                return false;
1944
1945
0
            OString aJSON = OUStringToOString(sComplexColorJson, RTL_TEXTENCODING_ASCII_US);
1946
0
            model::ComplexColor aComplexColor;
1947
0
            model::color::convertFromJSON(aJSON, aComplexColor);
1948
0
            setComplexColor(aComplexColor);
1949
0
        }
1950
0
        break;
1951
34.5k
        default:
1952
34.5k
        {
1953
34.5k
            Color nValue;
1954
34.5k
            if(!(rVal >>= nValue ))
1955
0
                return false;
1956
1957
34.5k
            SetColorValue( nValue );
1958
1959
34.5k
        }
1960
0
        break;
1961
52.6k
    }
1962
52.6k
    return true;
1963
52.6k
}
1964
1965
void XFillColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
1966
0
{
1967
0
    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XFillColorItem"));
1968
0
    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1969
1970
0
    XColorItem::dumpAsXml(pWriter);
1971
1972
0
    (void)xmlTextWriterEndElement(pWriter);
1973
0
}
1974
1975
boost::property_tree::ptree XFillColorItem::dumpAsJSON() const
1976
0
{
1977
0
    boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
1978
1979
0
    if (Which() == XATTR_FILLCOLOR)
1980
0
        aTree.put("commandName", ".uno:FillPageColor");
1981
1982
0
    aTree.put("state", GetColorValue().AsRGBHexString());
1983
1984
0
    return aTree;
1985
0
}
1986
1987
XSecondaryFillColorItem::XSecondaryFillColorItem(const OUString& rName, const Color& rTheColor) :
1988
1.47k
    XColorItem(XATTR_SECONDARYFILLCOLOR, rName, rTheColor)
1989
1.47k
{
1990
1.47k
}
1991
1992
XSecondaryFillColorItem* XSecondaryFillColorItem::Clone(SfxItemPool* /*pPool*/) const
1993
1.50k
{
1994
1.50k
    return new XSecondaryFillColorItem(*this);
1995
1.50k
}
1996
1997
bool XSecondaryFillColorItem::GetPresentation
1998
(
1999
    SfxItemPresentation /*ePres*/,
2000
    MapUnit             /*eCoreUnit*/,
2001
    MapUnit             /*ePresUnit*/,
2002
    OUString&           rText, const IntlWrapper&
2003
)   const
2004
0
{
2005
0
    rText = GetName();
2006
0
    return true;
2007
0
}
2008
2009
0
SfxPoolItem* XFillGradientItem::CreateDefault() { return new XFillGradientItem; }
2010
2011
XFillGradientItem::XFillGradientItem(sal_Int32 nIndex,
2012
                                   const basegfx::BGradient& rTheGradient,
2013
                                   TypedWhichId<XFillGradientItem> nWhich) :
2014
582
    NameOrIndex(nWhich, nIndex),
2015
582
    m_aGradient(rTheGradient)
2016
582
{
2017
582
}
2018
2019
XFillGradientItem::XFillGradientItem(const OUString& rName,
2020
                                   const basegfx::BGradient& rTheGradient,
2021
                                   TypedWhichId<XFillGradientItem> nWhich)
2022
26.8k
    : NameOrIndex(nWhich, rName)
2023
26.8k
    , m_aGradient(rTheGradient)
2024
26.8k
{
2025
26.8k
}
2026
2027
XFillGradientItem::XFillGradientItem(const XFillGradientItem& rItem) :
2028
203k
    NameOrIndex(rItem),
2029
203k
    m_aGradient(rItem.m_aGradient)
2030
203k
{
2031
203k
}
2032
2033
XFillGradientItem::XFillGradientItem( const basegfx::BGradient& rTheGradient,
2034
                                    TypedWhichId<XFillGradientItem> nWhich)
2035
27.5k
:   NameOrIndex( nWhich, -1 ),
2036
27.5k
    m_aGradient(rTheGradient)
2037
27.5k
{
2038
27.5k
}
2039
2040
XFillGradientItem* XFillGradientItem::Clone(SfxItemPool* /*pPool*/) const
2041
203k
{
2042
203k
    return new XFillGradientItem(*this);
2043
203k
}
2044
2045
bool XFillGradientItem::operator==(const SfxPoolItem& rItem) const
2046
67.8k
{
2047
67.8k
    return ( NameOrIndex::operator==(rItem) &&
2048
67.8k
             m_aGradient == static_cast<const XFillGradientItem&>(rItem).m_aGradient );
2049
67.8k
}
2050
2051
const basegfx::BGradient& XFillGradientItem::GetGradientValue() const // GetValue -> GetGradientValue
2052
179k
{
2053
179k
    if (!IsIndex())
2054
179k
        return m_aGradient;
2055
    // ToDo: This should fail. We never called this code with a table so this should always
2056
    // have failed. Thus, I'm thinking that XFillGradientItem can't be an Index.
2057
0
    return m_aGradient;
2058
179k
}
2059
2060
bool XFillGradientItem::GetPresentation
2061
(
2062
    SfxItemPresentation /*ePres*/,
2063
    MapUnit             /*eCoreUnit*/,
2064
    MapUnit             /*ePresUnit*/,
2065
    OUString&           rText, const IntlWrapper&
2066
)   const
2067
0
{
2068
0
    rText = GetName();
2069
0
    return true;
2070
0
}
2071
2072
bool XFillGradientItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2073
1.25k
{
2074
1.25k
    nMemberId &= ~CONVERT_TWIPS;
2075
1.25k
    switch ( nMemberId )
2076
1.25k
    {
2077
0
        case 0:
2078
0
        {
2079
            // fill values
2080
0
            const css::awt::Gradient2 aGradient2 = model::gradient::createUnoGradient2(GetGradientValue());
2081
2082
            // create sequence
2083
0
            uno::Sequence< beans::PropertyValue > aPropSeq{
2084
0
                comphelper::makePropertyValue(u"Name"_ustr, SvxUnogetApiNameForItem(Which(), GetName())),
2085
0
                comphelper::makePropertyValue(u"FillGradient"_ustr, aGradient2)
2086
0
            };
2087
0
            rVal <<= aPropSeq;
2088
0
            break;
2089
0
        }
2090
2091
1.21k
        case MID_FILLGRADIENT:
2092
1.21k
        {
2093
            // fill values
2094
1.21k
            const css::awt::Gradient2 aGradient2 = model::gradient::createUnoGradient2(GetGradientValue());
2095
2096
            // create sequence
2097
1.21k
            rVal <<= aGradient2;
2098
1.21k
            break;
2099
0
        }
2100
2101
43
        case MID_NAME:
2102
43
        {
2103
43
            rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
2104
43
            break;
2105
0
        }
2106
2107
0
        case MID_GRADIENT_COLORSTOPSEQUENCE:
2108
0
        {
2109
            // fill values
2110
0
            const css::awt::ColorStopSequence aColorStopSequence = model::gradient::createColorStopSequence(GetGradientValue().GetColorStops());
2111
2112
            // create sequence
2113
0
            rVal <<= aColorStopSequence;
2114
0
            break;
2115
0
        }
2116
2117
0
        case MID_GRADIENT_STYLE: rVal <<= static_cast<sal_Int16>(GetGradientValue().GetGradientStyle()); break;
2118
0
        case MID_GRADIENT_STARTCOLOR: rVal <<= Color(GetGradientValue().GetColorStops().front().getStopColor()); break;
2119
0
        case MID_GRADIENT_ENDCOLOR: rVal <<= Color(GetGradientValue().GetColorStops().back().getStopColor()); break;
2120
0
        case MID_GRADIENT_ANGLE: rVal <<= static_cast<sal_Int16>(GetGradientValue().GetAngle()); break;
2121
0
        case MID_GRADIENT_BORDER: rVal <<= GetGradientValue().GetBorder(); break;
2122
0
        case MID_GRADIENT_XOFFSET: rVal <<= GetGradientValue().GetXOffset(); break;
2123
0
        case MID_GRADIENT_YOFFSET: rVal <<= GetGradientValue().GetYOffset(); break;
2124
0
        case MID_GRADIENT_STARTINTENSITY: rVal <<= GetGradientValue().GetStartIntens(); break;
2125
0
        case MID_GRADIENT_ENDINTENSITY: rVal <<= GetGradientValue().GetEndIntens(); break;
2126
0
        case MID_GRADIENT_STEPCOUNT: rVal <<= GetGradientValue().GetSteps(); break;
2127
2128
0
        default: OSL_FAIL("Wrong MemberId!"); return false;
2129
1.25k
    }
2130
2131
1.25k
    return true;
2132
1.25k
}
2133
2134
bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2135
4.44k
{
2136
4.44k
    nMemberId &= ~CONVERT_TWIPS;
2137
2138
4.44k
    switch ( nMemberId )
2139
4.44k
    {
2140
0
        case 0:
2141
0
        {
2142
0
            uno::Sequence< beans::PropertyValue >   aPropSeq;
2143
0
            css::uno::Any aGradientAny;
2144
2145
0
            if ( rVal >>= aPropSeq )
2146
0
            {
2147
0
                OUString aName;
2148
2149
0
                for (const auto& rProp : aPropSeq)
2150
0
                {
2151
0
                    if ( rProp.Name == "Name" )
2152
0
                        rProp.Value >>= aName;
2153
0
                    else if ( rProp.Name == "FillGradient" )
2154
0
                        aGradientAny = rProp.Value;
2155
0
                }
2156
2157
0
                SetName( aName );
2158
2159
0
                if (aGradientAny.hasValue() && (aGradientAny.has<css::awt::Gradient>() || aGradientAny.has<css::awt::Gradient2>()))
2160
0
                {
2161
0
                    SetGradientValue(model::gradient::getFromAny(aGradientAny));
2162
0
                }
2163
2164
0
                return true;
2165
0
            }
2166
2167
0
            return false;
2168
0
        }
2169
2170
0
        case MID_NAME:
2171
0
        {
2172
0
            OUString aName;
2173
0
            if (!(rVal >>= aName ))
2174
0
                return false;
2175
0
            SetName( aName );
2176
0
            break;
2177
0
        }
2178
2179
4.44k
        case MID_FILLGRADIENT:
2180
4.44k
        {
2181
4.44k
            if (rVal.hasValue() && (rVal.has<css::awt::Gradient>() || rVal.has<css::awt::Gradient2>()))
2182
4.44k
            {
2183
4.44k
                SetGradientValue(model::gradient::getFromAny(rVal));
2184
4.44k
            }
2185
2186
4.44k
            break;
2187
0
        }
2188
2189
0
        case MID_GRADIENT_COLORSTOPSEQUENCE:
2190
0
        {
2191
            // check if we have a awt::ColorStopSequence
2192
0
            if (rVal.hasValue() && rVal.has<css::awt::ColorStopSequence>())
2193
0
            {
2194
2195
0
                const basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromAny(rVal);
2196
2197
0
                if (!aColorStops.empty())
2198
0
                {
2199
0
                    basegfx::BGradient aBGradient(GetGradientValue());
2200
0
                    aBGradient.SetColorStops(aColorStops);
2201
0
                    SetGradientValue(aBGradient);
2202
0
                }
2203
0
            }
2204
0
            break;
2205
0
        }
2206
2207
0
        case MID_GRADIENT_STARTCOLOR:
2208
0
        case MID_GRADIENT_ENDCOLOR:
2209
0
        {
2210
0
            Color nVal;
2211
0
            if(!(rVal >>= nVal ))
2212
0
                return false;
2213
2214
0
            basegfx::BGradient aBGradient(GetGradientValue());
2215
0
            basegfx::BColorStops aNewColorStops(aBGradient.GetColorStops());
2216
2217
0
            if ( nMemberId == MID_GRADIENT_STARTCOLOR )
2218
0
            {
2219
0
                aNewColorStops.replaceStartColor(nVal.getBColor());
2220
0
            }
2221
0
            else
2222
0
            {
2223
0
                aNewColorStops.replaceEndColor(nVal.getBColor());
2224
0
            }
2225
2226
0
            aBGradient.SetColorStops(aNewColorStops);
2227
0
            SetGradientValue( aBGradient );
2228
0
            break;
2229
0
        }
2230
2231
0
        case MID_GRADIENT_STYLE:
2232
0
        case MID_GRADIENT_ANGLE:
2233
0
        case MID_GRADIENT_BORDER:
2234
0
        case MID_GRADIENT_STARTINTENSITY:
2235
0
        case MID_GRADIENT_ENDINTENSITY:
2236
0
        case MID_GRADIENT_STEPCOUNT:
2237
0
        case MID_GRADIENT_XOFFSET:
2238
0
        case MID_GRADIENT_YOFFSET:
2239
0
        {
2240
0
            sal_Int16 nVal = sal_Int16();
2241
0
            if(!(rVal >>= nVal ))
2242
0
                return false;
2243
2244
0
            basegfx::BGradient aBGradient = GetGradientValue();
2245
2246
0
            switch ( nMemberId )
2247
0
            {
2248
0
                case MID_GRADIENT_STYLE:
2249
0
                    aBGradient.SetGradientStyle( static_cast<css::awt::GradientStyle>(nVal) ); break;
2250
0
                case MID_GRADIENT_ANGLE:
2251
0
                    aBGradient.SetAngle( Degree10(nVal) ); break;
2252
0
                case MID_GRADIENT_BORDER:
2253
0
                    aBGradient.SetBorder( nVal ); break;
2254
0
                case MID_GRADIENT_STARTINTENSITY:
2255
0
                    aBGradient.SetStartIntens( nVal ); break;
2256
0
                case MID_GRADIENT_ENDINTENSITY:
2257
0
                    aBGradient.SetEndIntens( nVal ); break;
2258
0
                case MID_GRADIENT_STEPCOUNT:
2259
0
                    aBGradient.SetSteps( nVal ); break;
2260
0
                case MID_GRADIENT_XOFFSET:
2261
0
                    aBGradient.SetXOffset( nVal ); break;
2262
0
                case MID_GRADIENT_YOFFSET:
2263
0
                    aBGradient.SetYOffset( nVal ); break;
2264
0
            }
2265
2266
0
            SetGradientValue( aBGradient );
2267
0
            break;
2268
0
        }
2269
4.44k
    }
2270
2271
4.44k
    return true;
2272
4.44k
}
2273
2274
bool XFillGradientItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2275
45.1k
{
2276
45.1k
    return static_cast<const XFillGradientItem*>(p1)->GetGradientValue() == static_cast<const XFillGradientItem*>(p2)->GetGradientValue();
2277
45.1k
}
2278
2279
std::unique_ptr<XFillGradientItem> XFillGradientItem::checkForUniqueItem( SdrModel& rModel ) const
2280
41.7k
{
2281
41.7k
    const OUString aUniqueName(CheckNamedItem(
2282
41.7k
        Which(), &rModel.GetItemPool(),
2283
41.7k
        XFillGradientItem::CompareValueFunc, RID_SVXSTR_GRADIENT,
2284
41.7k
        rModel.GetPropertyList(XPropertyListType::Gradient)));
2285
2286
    // if the given name is not valid, replace it!
2287
41.7k
    if( aUniqueName != GetName() )
2288
15.0k
        return std::make_unique<XFillGradientItem>( aUniqueName, m_aGradient, TypedWhichId<XFillGradientItem>(Which()) );
2289
2290
26.6k
    return nullptr;
2291
41.7k
}
2292
2293
boost::property_tree::ptree XFillGradientItem::dumpAsJSON() const
2294
0
{
2295
0
    boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
2296
2297
0
    if (Which() == XATTR_FILLGRADIENT)
2298
0
        aTree.put("commandName", ".uno:FillGradient");
2299
2300
0
    aTree.push_back(std::make_pair("state", GetGradientValue().dumpAsJSON()));
2301
2302
0
    return aTree;
2303
0
}
2304
2305
2306
0
SfxPoolItem* XFillFloatTransparenceItem::CreateDefault() { return new XFillFloatTransparenceItem; }
2307
2308
XFillFloatTransparenceItem::XFillFloatTransparenceItem() :
2309
51
    XFillGradientItem(XATTR_FILLFLOATTRANSPARENCE),
2310
51
    m_bEnabled( false )
2311
51
{
2312
51
}
2313
2314
XFillFloatTransparenceItem::XFillFloatTransparenceItem(const OUString& rName, const basegfx::BGradient& rGradient, bool bEnable ) :
2315
158
    XFillGradientItem   ( rName, rGradient, XATTR_FILLFLOATTRANSPARENCE ),
2316
158
    m_bEnabled            ( bEnable )
2317
158
{
2318
158
}
2319
2320
XFillFloatTransparenceItem::XFillFloatTransparenceItem( const XFillFloatTransparenceItem& rItem ) :
2321
714
    XFillGradientItem   ( rItem ),
2322
714
    m_bEnabled            ( rItem.m_bEnabled )
2323
714
{
2324
714
}
2325
2326
XFillFloatTransparenceItem::XFillFloatTransparenceItem(const basegfx::BGradient& rTheGradient, bool bEnable )
2327
582
:   XFillGradientItem   ( -1, rTheGradient, XATTR_FILLFLOATTRANSPARENCE ),
2328
582
    m_bEnabled            ( bEnable )
2329
582
{
2330
582
}
2331
2332
bool XFillFloatTransparenceItem::operator==( const SfxPoolItem& rItem ) const
2333
311
{
2334
311
    return ( XFillGradientItem::operator==(rItem) ) &&
2335
311
           ( m_bEnabled == static_cast<const XFillFloatTransparenceItem&>(rItem).m_bEnabled );
2336
311
}
2337
2338
XFillFloatTransparenceItem* XFillFloatTransparenceItem::Clone( SfxItemPool* /*pPool*/) const
2339
714
{
2340
714
    return new XFillFloatTransparenceItem( *this );
2341
714
}
2342
2343
bool XFillFloatTransparenceItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2344
650
{
2345
650
    if (MID_GRADIENT_STARTINTENSITY == nMemberId
2346
650
        || MID_GRADIENT_ENDINTENSITY == nMemberId
2347
650
        || MID_GRADIENT_STEPCOUNT == nMemberId)
2348
0
    {
2349
        // tdf#155913 handle attributes not supported by transparency gradient as error
2350
0
        return false;
2351
0
    }
2352
2353
650
    if (!IsEnabled() && nMemberId == MID_NAME)
2354
43
    {
2355
        // make sure that we return empty string in case of query for
2356
        // "FillTransparenceGradientName" if the item is disabled
2357
43
        rVal <<= OUString();
2358
43
        return true;
2359
43
    }
2360
2361
607
    return XFillGradientItem::QueryValue( rVal, nMemberId );
2362
650
}
2363
2364
bool XFillFloatTransparenceItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2365
615
{
2366
615
    if (MID_GRADIENT_STARTINTENSITY == nMemberId
2367
615
        || MID_GRADIENT_ENDINTENSITY == nMemberId
2368
615
        || MID_GRADIENT_STEPCOUNT == nMemberId)
2369
0
    {
2370
        // tdf#155913 handle attributes not supported by transparency gradient as error
2371
0
        return false;
2372
0
    }
2373
2374
615
    return XFillGradientItem::PutValue( rVal, nMemberId );
2375
615
}
2376
2377
bool XFillFloatTransparenceItem::GetPresentation(    SfxItemPresentation ePres,
2378
                                                                    MapUnit eCoreUnit, MapUnit ePresUnit,
2379
                                                                    OUString& rText,
2380
                                                                    const IntlWrapper& rIntlWrapper ) const
2381
0
{
2382
0
    return XFillGradientItem::GetPresentation( ePres, eCoreUnit, ePresUnit, rText, rIntlWrapper );
2383
0
}
2384
2385
bool XFillFloatTransparenceItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2386
35
{
2387
35
    return  static_cast<const XFillFloatTransparenceItem*>(p1)->IsEnabled() == static_cast<const XFillFloatTransparenceItem*>(p2)->IsEnabled() &&
2388
35
            static_cast<const XFillFloatTransparenceItem*>(p1)->GetGradientValue()  == static_cast<const XFillFloatTransparenceItem*>(p2)->GetGradientValue();
2389
35
}
2390
2391
std::unique_ptr<XFillFloatTransparenceItem> XFillFloatTransparenceItem::checkForUniqueItem( SdrModel& rModel ) const
2392
21.6k
{
2393
    // #85953# unique name only necessary when enabled
2394
21.6k
    if(IsEnabled())
2395
132
    {
2396
132
        const OUString aUniqueName(CheckNamedItem(
2397
132
            XATTR_FILLFLOATTRANSPARENCE,
2398
132
            &rModel.GetItemPool(),
2399
132
            XFillFloatTransparenceItem::CompareValueFunc,
2400
132
            RID_SVXSTR_TRASNGR0,
2401
132
            XPropertyListRef()));
2402
2403
        // if the given name is not valid, replace it!
2404
132
        if( aUniqueName != GetName() )
2405
84
        {
2406
84
            return std::make_unique<XFillFloatTransparenceItem>( aUniqueName, GetGradientValue(), true );
2407
84
        }
2408
132
    }
2409
21.4k
    else
2410
21.4k
    {
2411
        // #85953# if disabled, force name to empty string
2412
21.4k
        if( !GetName().isEmpty() )
2413
0
        {
2414
0
            return std::make_unique<XFillFloatTransparenceItem>(OUString(), GetGradientValue(), false);
2415
0
        }
2416
21.4k
    }
2417
2418
21.5k
    return nullptr;
2419
21.6k
}
2420
2421
boost::property_tree::ptree XFillFloatTransparenceItem::dumpAsJSON() const
2422
0
{
2423
0
    boost::property_tree::ptree aTree = XFillGradientItem::dumpAsJSON();
2424
0
    aTree.put("commandName", ".uno:FillFloatTransparence");
2425
2426
0
    if (!m_bEnabled)
2427
0
    {
2428
0
        boost::property_tree::ptree& rState = aTree.get_child("state");
2429
        // When gradient fill is disabled, the intensity fields contain the
2430
        // constant encoded percent-transparency. However we use that here to just
2431
        // distinguish between 'None' and 'Solid' types and correct the 'style'
2432
        // property appropriately.
2433
0
        if (GetGradientValue().GetStartIntens() == 100)
2434
0
            rState.put("style", "NONE");
2435
0
        else
2436
0
            rState.put("style", "SOLID");
2437
0
    }
2438
2439
0
    return aTree;
2440
0
}
2441
2442
XHatch::XHatch(const Color& rCol, css::drawing::HatchStyle eTheStyle, tools::Long nTheDistance,
2443
               Degree10 nTheAngle) :
2444
28.5k
    m_eStyle(eTheStyle),
2445
28.5k
    m_aColor(rCol),
2446
28.5k
    m_nDistance(nTheDistance),
2447
28.5k
    m_nAngle(nTheAngle)
2448
28.5k
{
2449
28.5k
}
2450
2451
bool XHatch::operator==(const XHatch& rHatch) const
2452
12.6k
{
2453
12.6k
    return ( m_eStyle     == rHatch.m_eStyle    &&
2454
12.6k
             m_aColor     == rHatch.m_aColor    &&
2455
12.6k
             m_nDistance  == rHatch.m_nDistance &&
2456
12.6k
             m_nAngle     == rHatch.m_nAngle );
2457
12.6k
}
2458
2459
2460
0
SfxPoolItem* XFillHatchItem::CreateDefault() { return new XFillHatchItem; }
2461
2462
XFillHatchItem::XFillHatchItem(const OUString& rName,
2463
                             const XHatch& rTheHatch) :
2464
607
    NameOrIndex(XATTR_FILLHATCH, rName),
2465
607
    m_aHatch(rTheHatch)
2466
607
{
2467
607
}
2468
2469
XFillHatchItem::XFillHatchItem(const XFillHatchItem& rItem) :
2470
27.5k
    NameOrIndex(rItem),
2471
27.5k
    m_aHatch(rItem.m_aHatch)
2472
27.5k
{
2473
27.5k
}
2474
2475
XFillHatchItem::XFillHatchItem(const XHatch& rTheHatch)
2476
27.5k
:   NameOrIndex( XATTR_FILLHATCH, -1 ),
2477
27.5k
    m_aHatch(rTheHatch)
2478
27.5k
{
2479
27.5k
}
2480
2481
XFillHatchItem* XFillHatchItem::Clone(SfxItemPool* /*pPool*/) const
2482
27.5k
{
2483
27.5k
    return new XFillHatchItem(*this);
2484
27.5k
}
2485
2486
bool XFillHatchItem::operator==(const SfxPoolItem& rItem) const
2487
607
{
2488
607
    return ( NameOrIndex::operator==(rItem) &&
2489
607
             m_aHatch == static_cast<const XFillHatchItem&>(rItem).m_aHatch );
2490
607
}
2491
2492
bool XFillHatchItem::GetPresentation
2493
(
2494
    SfxItemPresentation /*ePres*/,
2495
    MapUnit             /*eCoreUnit*/,
2496
    MapUnit             /*ePresUnit*/,
2497
    OUString&           rText, const IntlWrapper&
2498
)   const
2499
0
{
2500
0
    rText = GetName();
2501
0
    return true;
2502
0
}
2503
2504
bool XFillHatchItem::HasMetrics() const
2505
0
{
2506
0
    return true;
2507
0
}
2508
2509
void XFillHatchItem::ScaleMetrics(tools::Long nMul, tools::Long nDiv)
2510
0
{
2511
0
    m_aHatch.SetDistance( BigInt::Scale( m_aHatch.GetDistance(), nMul, nDiv ) );
2512
0
}
2513
2514
bool XFillHatchItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2515
650
{
2516
650
    nMemberId &= ~CONVERT_TWIPS;
2517
2518
650
    switch ( nMemberId )
2519
650
    {
2520
0
        case 0:
2521
0
        {
2522
0
            css::drawing::Hatch aUnoHatch;
2523
2524
0
            aUnoHatch.Style = m_aHatch.GetHatchStyle();
2525
0
            aUnoHatch.Color = sal_Int32(m_aHatch.GetColor());
2526
0
            aUnoHatch.Distance = m_aHatch.GetDistance();
2527
0
            aUnoHatch.Angle = m_aHatch.GetAngle().get();
2528
2529
0
            uno::Sequence< beans::PropertyValue > aPropSeq{
2530
0
                comphelper::makePropertyValue(u"Name"_ustr, SvxUnogetApiNameForItem(Which(), GetName())),
2531
0
                comphelper::makePropertyValue(u"FillHatch"_ustr, aUnoHatch)
2532
0
            };
2533
0
            rVal <<= aPropSeq;
2534
0
            break;
2535
0
        }
2536
2537
607
        case MID_FILLHATCH:
2538
607
        {
2539
607
            css::drawing::Hatch aUnoHatch;
2540
2541
607
            aUnoHatch.Style = m_aHatch.GetHatchStyle();
2542
607
            aUnoHatch.Color = sal_Int32(m_aHatch.GetColor());
2543
607
            aUnoHatch.Distance = m_aHatch.GetDistance();
2544
607
            aUnoHatch.Angle = m_aHatch.GetAngle().get();
2545
607
            rVal <<= aUnoHatch;
2546
607
            break;
2547
0
        }
2548
2549
43
        case MID_NAME:
2550
43
        {
2551
43
            rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
2552
43
            break;
2553
0
        }
2554
2555
0
        case MID_HATCH_STYLE:
2556
0
            rVal <<= m_aHatch.GetHatchStyle(); break;
2557
0
        case MID_HATCH_COLOR:
2558
0
            rVal <<= m_aHatch.GetColor(); break;
2559
0
        case MID_HATCH_DISTANCE:
2560
0
            rVal <<= m_aHatch.GetDistance(); break;
2561
0
        case MID_HATCH_ANGLE:
2562
0
            rVal <<= m_aHatch.GetAngle().get(); break;
2563
2564
0
        default: OSL_FAIL("Wrong MemberId!"); return false;
2565
650
    }
2566
2567
650
    return true;
2568
650
}
2569
2570
bool XFillHatchItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2571
607
{
2572
607
    nMemberId &= ~CONVERT_TWIPS;
2573
2574
607
    switch ( nMemberId )
2575
607
    {
2576
0
        case 0:
2577
0
        {
2578
0
            uno::Sequence< beans::PropertyValue >   aPropSeq;
2579
0
            if ( rVal >>= aPropSeq )
2580
0
            {
2581
0
                css::drawing::Hatch aUnoHatch;
2582
0
                OUString aName;
2583
0
                bool bHatch( false );
2584
0
                for (const auto& rProp : aPropSeq)
2585
0
                {
2586
0
                    if ( rProp.Name == "Name" )
2587
0
                        rProp.Value >>= aName;
2588
0
                    else if ( rProp.Name == "FillHatch" )
2589
0
                    {
2590
0
                        if ( rProp.Value >>= aUnoHatch )
2591
0
                            bHatch = true;
2592
0
                    }
2593
0
                }
2594
2595
0
                SetName( aName );
2596
0
                if ( bHatch )
2597
0
                {
2598
0
                    m_aHatch.SetHatchStyle( aUnoHatch.Style );
2599
0
                    m_aHatch.SetColor( Color(ColorTransparency, aUnoHatch.Color) );
2600
0
                    m_aHatch.SetDistance( aUnoHatch.Distance );
2601
0
                    m_aHatch.SetAngle( Degree10(aUnoHatch.Angle) );
2602
0
                }
2603
2604
0
                return true;
2605
0
            }
2606
2607
0
            return false;
2608
0
        }
2609
2610
607
        case MID_FILLHATCH:
2611
607
        {
2612
607
            css::drawing::Hatch aUnoHatch;
2613
607
            if(!(rVal >>= aUnoHatch))
2614
0
                return false;
2615
2616
607
            m_aHatch.SetHatchStyle( aUnoHatch.Style );
2617
607
            m_aHatch.SetColor( Color(ColorTransparency, aUnoHatch.Color) );
2618
607
            m_aHatch.SetDistance( aUnoHatch.Distance );
2619
607
            m_aHatch.SetAngle( Degree10(aUnoHatch.Angle) );
2620
607
            break;
2621
607
        }
2622
2623
0
        case MID_NAME:
2624
0
        {
2625
0
            OUString aName;
2626
0
            if (!(rVal >>= aName ))
2627
0
                return false;
2628
0
            SetName( aName );
2629
0
            break;
2630
0
        }
2631
2632
0
        case MID_HATCH_STYLE:
2633
0
        {
2634
0
            sal_Int16 nVal = sal_Int16();
2635
0
            if (!(rVal >>= nVal ))
2636
0
                return false;
2637
0
            m_aHatch.SetHatchStyle( static_cast<css::drawing::HatchStyle>(nVal) );
2638
0
            break;
2639
0
        }
2640
2641
0
        case MID_HATCH_COLOR:
2642
0
        case MID_HATCH_DISTANCE:
2643
0
        case MID_HATCH_ANGLE:
2644
0
        {
2645
0
            sal_Int32 nVal = 0;
2646
0
            if (!(rVal >>= nVal ))
2647
0
                return false;
2648
2649
0
            if ( nMemberId == MID_HATCH_COLOR )
2650
0
                m_aHatch.SetColor( Color(ColorTransparency, nVal) );
2651
0
            else if ( nMemberId == MID_HATCH_DISTANCE )
2652
0
                m_aHatch.SetDistance( nVal );
2653
0
            else
2654
0
                m_aHatch.SetAngle( Degree10(nVal) );
2655
0
            break;
2656
0
        }
2657
2658
0
        default: OSL_FAIL("Wrong MemberId!"); return false;
2659
607
    }
2660
2661
607
    return true;
2662
607
}
2663
2664
bool XFillHatchItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2665
10.8k
{
2666
10.8k
    return static_cast<const XFillHatchItem*>(p1)->GetHatchValue() == static_cast<const XFillHatchItem*>(p2)->GetHatchValue();
2667
10.8k
}
2668
2669
std::unique_ptr<XFillHatchItem> XFillHatchItem::checkForUniqueItem( SdrModel& rModel ) const
2670
22.0k
{
2671
22.0k
    const OUString aUniqueName(CheckNamedItem(
2672
22.0k
        XATTR_FILLHATCH, &rModel.GetItemPool(),
2673
22.0k
        XFillHatchItem::CompareValueFunc, RID_SVXSTR_HATCH10,
2674
22.0k
        rModel.GetPropertyList(XPropertyListType::Hatch)));
2675
2676
    // if the given name is not valid, replace it!
2677
22.0k
    if( aUniqueName != GetName() )
2678
607
        return std::make_unique<XFillHatchItem>( aUniqueName, m_aHatch );
2679
2680
21.4k
    return nullptr;
2681
22.0k
}
2682
2683
// --- form text attributes ---
2684
2685
2686
0
SfxPoolItem* XFormTextStyleItem::CreateDefault() { return new XFormTextStyleItem; }
2687
2688
XFormTextStyleItem::XFormTextStyleItem(XFormTextStyle eTheStyle) :
2689
18
    SfxEnumItem(XATTR_FORMTXTSTYLE, eTheStyle)
2690
18
{
2691
18
}
2692
2693
XFormTextStyleItem* XFormTextStyleItem::Clone(SfxItemPool* /*pPool*/) const
2694
0
{
2695
0
    return new XFormTextStyleItem( *this );
2696
0
}
2697
2698
bool XFormTextStyleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2699
0
{
2700
0
    rVal <<= static_cast<sal_Int32>(GetValue());
2701
0
    return true;
2702
0
}
2703
2704
bool XFormTextStyleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2705
0
{
2706
0
    sal_Int32 nValue = 0;
2707
0
    rVal >>= nValue;
2708
0
    SetValue(static_cast<XFormTextStyle>(nValue));
2709
2710
0
    return true;
2711
0
}
2712
2713
2714
0
SfxPoolItem* XFormTextAdjustItem::CreateDefault() { return new XFormTextAdjustItem; }
2715
2716
XFormTextAdjustItem::XFormTextAdjustItem(XFormTextAdjust eTheAdjust) :
2717
18
    SfxEnumItem(XATTR_FORMTXTADJUST, eTheAdjust)
2718
18
{
2719
18
}
2720
2721
XFormTextAdjustItem* XFormTextAdjustItem::Clone(SfxItemPool* /*pPool*/) const
2722
0
{
2723
0
    return new XFormTextAdjustItem( *this );
2724
0
}
2725
2726
bool XFormTextAdjustItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2727
0
{
2728
0
    rVal <<= static_cast<sal_Int32>(GetValue());
2729
0
    return true;
2730
0
}
2731
2732
bool XFormTextAdjustItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2733
0
{
2734
0
    sal_Int32 nValue = 0;
2735
0
    rVal >>= nValue;
2736
0
    SetValue(static_cast<XFormTextAdjust>(nValue));
2737
2738
0
    return true;
2739
0
}
2740
2741
2742
0
SfxPoolItem* XFormTextDistanceItem::CreateDefault() { return new XFormTextDistanceItem; }
2743
2744
XFormTextDistanceItem::XFormTextDistanceItem(tools::Long nDist) :
2745
18
    SfxMetricItem(XATTR_FORMTXTDISTANCE, nDist)
2746
18
{
2747
18
}
2748
2749
XFormTextDistanceItem* XFormTextDistanceItem::Clone(SfxItemPool* /*pPool*/) const
2750
0
{
2751
0
    return new XFormTextDistanceItem(*this);
2752
0
}
2753
2754
0
SfxPoolItem* XFormTextStartItem::CreateDefault() { return new XFormTextStartItem; }
2755
2756
XFormTextStartItem::XFormTextStartItem(tools::Long nStart) :
2757
18
    SfxMetricItem(XATTR_FORMTXTSTART, nStart)
2758
18
{
2759
18
}
2760
2761
XFormTextStartItem* XFormTextStartItem::Clone(SfxItemPool* /*pPool*/) const
2762
0
{
2763
0
    return new XFormTextStartItem(*this);
2764
0
}
2765
2766
0
SfxPoolItem* XFormTextMirrorItem::CreateDefault() { return new XFormTextMirrorItem; }
2767
2768
XFormTextMirrorItem::XFormTextMirrorItem(bool bMirror) :
2769
18
    SfxBoolItem(XATTR_FORMTXTMIRROR, bMirror)
2770
18
{
2771
18
}
2772
2773
XFormTextMirrorItem* XFormTextMirrorItem::Clone(SfxItemPool* /*pPool*/) const
2774
0
{
2775
0
    return new XFormTextMirrorItem(*this);
2776
0
}
2777
2778
0
SfxPoolItem* XFormTextOutlineItem::CreateDefault() { return new XFormTextOutlineItem; }
2779
2780
XFormTextOutlineItem::XFormTextOutlineItem(bool bOutline) :
2781
18
    SfxBoolItem(XATTR_FORMTXTOUTLINE, bOutline)
2782
18
{
2783
18
}
2784
2785
XFormTextOutlineItem* XFormTextOutlineItem::Clone(SfxItemPool* /*pPool*/) const
2786
0
{
2787
0
    return new XFormTextOutlineItem(*this);
2788
0
}
2789
2790
0
SfxPoolItem* XFormTextShadowItem::CreateDefault() { return new XFormTextShadowItem; }
2791
2792
XFormTextShadowItem::XFormTextShadowItem(XFormTextShadow eFormTextShadow) :
2793
18
    SfxEnumItem(XATTR_FORMTXTSHADOW, eFormTextShadow)
2794
18
{
2795
18
}
2796
2797
XFormTextShadowItem* XFormTextShadowItem::Clone(SfxItemPool* /*pPool*/) const
2798
0
{
2799
0
    return new XFormTextShadowItem( *this );
2800
0
}
2801
2802
bool XFormTextShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2803
0
{
2804
0
    rVal <<= static_cast<sal_Int32>(GetValue());
2805
0
    return true;
2806
0
}
2807
2808
bool XFormTextShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2809
0
{
2810
0
    sal_Int32 nValue = 0;
2811
0
    rVal >>= nValue;
2812
0
    SetValue(static_cast<XFormTextShadow>(nValue));
2813
2814
0
    return true;
2815
0
}
2816
2817
2818
0
SfxPoolItem* XFormTextShadowColorItem::CreateDefault() { return new XFormTextShadowColorItem; }
2819
2820
XFormTextShadowColorItem::XFormTextShadowColorItem(const OUString& rName,
2821
                                                     const Color& rTheColor) :
2822
18
    XColorItem(XATTR_FORMTXTSHDWCOLOR, rName, rTheColor)
2823
18
{
2824
18
}
2825
2826
XFormTextShadowColorItem* XFormTextShadowColorItem::Clone(SfxItemPool* /*pPool*/) const
2827
0
{
2828
0
    return new XFormTextShadowColorItem(*this);
2829
0
}
2830
2831
0
SfxPoolItem* XFormTextShadowXValItem::CreateDefault() { return new XFormTextShadowXValItem; }
2832
2833
XFormTextShadowXValItem::XFormTextShadowXValItem(tools::Long nVal) :
2834
18
    SfxMetricItem(XATTR_FORMTXTSHDWXVAL, nVal)
2835
18
{
2836
18
}
2837
2838
XFormTextShadowXValItem* XFormTextShadowXValItem::Clone(SfxItemPool* /*pPool*/) const
2839
0
{
2840
0
    return new XFormTextShadowXValItem(*this);
2841
0
}
2842
2843
0
SfxPoolItem* XFormTextShadowYValItem::CreateDefault() { return new XFormTextShadowYValItem; }
2844
2845
XFormTextShadowYValItem::XFormTextShadowYValItem(tools::Long nVal) :
2846
18
    SfxMetricItem(XATTR_FORMTXTSHDWYVAL, nVal)
2847
18
{
2848
18
}
2849
2850
XFormTextShadowYValItem* XFormTextShadowYValItem::Clone(SfxItemPool* /*pPool*/) const
2851
0
{
2852
0
    return new XFormTextShadowYValItem(*this);
2853
0
}
2854
2855
0
SfxPoolItem* XFormTextHideFormItem::CreateDefault() { return new XFormTextHideFormItem; }
2856
2857
XFormTextHideFormItem::XFormTextHideFormItem(bool bHide) :
2858
18
    SfxBoolItem(XATTR_FORMTXTHIDEFORM, bHide)
2859
18
{
2860
18
}
2861
2862
XFormTextHideFormItem* XFormTextHideFormItem::Clone(SfxItemPool* /*pPool*/) const
2863
0
{
2864
0
    return new XFormTextHideFormItem(*this);
2865
0
}
2866
2867
// --- SetItems ---
2868
2869
2870
/// a line attribute set item
2871
XLineAttrSetItem::XLineAttrSetItem( SfxItemSet&& pItemSet ) :
2872
166k
    SfxSetItem( XATTRSET_LINE, std::move(pItemSet))
2873
166k
{
2874
166k
}
2875
2876
XLineAttrSetItem::XLineAttrSetItem( SfxItemPool* pItemPool ) :
2877
0
    SfxSetItem(XATTRSET_LINE,
2878
0
               SfxItemSet::makeFixedSfxItemSet<XATTR_LINE_FIRST, XATTR_LINE_LAST>(*pItemPool))
2879
0
{
2880
0
}
2881
2882
XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr ) :
2883
0
    SfxSetItem( rLineAttr )
2884
0
{
2885
0
}
2886
2887
XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr,
2888
                                    SfxItemPool* pItemPool) :
2889
0
    SfxSetItem( rLineAttr, pItemPool )
2890
0
{
2891
0
}
2892
2893
XLineAttrSetItem* XLineAttrSetItem::Clone( SfxItemPool* pPool ) const
2894
0
{
2895
0
    return new XLineAttrSetItem( *this, pPool );
2896
0
}
2897
2898
/// fill attribute set item
2899
XFillAttrSetItem::XFillAttrSetItem( SfxItemSet&& pItemSet ) :
2900
166k
    SfxSetItem( XATTRSET_FILL, std::move(pItemSet))
2901
166k
{
2902
166k
}
2903
2904
XFillAttrSetItem::XFillAttrSetItem( SfxItemPool* pItemPool ) :
2905
0
    SfxSetItem(XATTRSET_FILL,
2906
0
               SfxItemSet::makeFixedSfxItemSet<XATTR_FILL_FIRST, XATTR_FILL_LAST>(*pItemPool))
2907
0
{
2908
0
}
2909
2910
XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr ) :
2911
0
    SfxSetItem( rFillAttr )
2912
0
{
2913
0
}
2914
2915
XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr,
2916
                                    SfxItemPool* pItemPool ) :
2917
0
    SfxSetItem( rFillAttr, pItemPool )
2918
0
{
2919
0
}
2920
2921
XFillAttrSetItem* XFillAttrSetItem::Clone( SfxItemPool* pPool ) const
2922
0
{
2923
0
    return new XFillAttrSetItem( *this, pPool );
2924
0
}
2925
2926
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */