Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / xoutdev / xattr.cxx
blobc7e1fed33ac24161de047f1b199ea1be58252034
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <utility>
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>
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>
46 #include <svx/unoapi.hxx>
47 #include <svl/style.hxx>
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>
93 #include <boost/property_tree/json_parser.hpp>
94 #include <libxml/xmlwriter.h>
96 using namespace ::com::sun::star;
98 typedef std::map<OUString, OUString> StringMap;
100 NameOrIndex::NameOrIndex(TypedWhichId<NameOrIndex> _nWhich, sal_Int32 nIndex) :
101 SfxStringItem(_nWhich, OUString()),
102 nPalIndex(nIndex)
106 NameOrIndex::NameOrIndex(TypedWhichId<NameOrIndex> _nWhich, const OUString& rName) :
107 SfxStringItem(_nWhich, rName),
108 nPalIndex(-1)
112 NameOrIndex::NameOrIndex(const NameOrIndex& rNameOrIndex) :
113 SfxStringItem(rNameOrIndex),
114 nPalIndex(rNameOrIndex.nPalIndex)
118 bool NameOrIndex::operator==(const SfxPoolItem& rItem) const
120 return ( SfxStringItem::operator==(rItem) &&
121 static_cast<const NameOrIndex&>(rItem).nPalIndex == nPalIndex );
124 NameOrIndex* NameOrIndex::Clone(SfxItemPool* /*pPool*/) const
126 return new NameOrIndex(*this);
129 /** this static checks if the given NameOrIndex item has a unique name for its value.
130 The returned String is a unique name for an item with this value in both given pools.
131 Argument pPool2 can be null.
132 If returned string equals NameOrIndex->GetName(), the name was already unique.
134 OUString NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_uInt16 nWhich, const SfxItemPool* pPool1, SvxCompareValueFunc pCompareValueFunc, TranslateId pPrefixResId, const XPropertyListRef &pDefaults )
136 bool bForceNew = false;
138 OUString aUniqueName = SvxUnogetInternalNameForItem(nWhich, pCheckItem->GetName());
140 // 2. if we have a name check if there is already an item with the
141 // same name in the documents pool with a different line end or start
143 if (!aUniqueName.isEmpty() && pPool1)
145 for (const SfxPoolItem* pItem : pPool1->GetItemSurrogates(nWhich))
147 const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
149 if( pNameOrIndex->GetName() == pCheckItem->GetName() )
151 // if there is already an item with the same name and the same
152 // value it's ok to set it
153 if( !pCompareValueFunc( pNameOrIndex, pCheckItem ) )
155 // same name but different value, we need a new name for this item
156 aUniqueName.clear();
157 bForceNew = true;
159 break;
164 // if we have no name yet, find existing item with same content or
165 // create a unique name
166 if (aUniqueName.isEmpty())
168 sal_Int32 nUserIndex = 1;
169 const OUString aUser(SvxResId(pPrefixResId) + " ");
171 if( pDefaults )
173 const int nCount = pDefaults->Count();
174 int nIndex;
175 for( nIndex = 0; nIndex < nCount; nIndex++ )
177 const XPropertyEntry* pEntry = pDefaults->Get(nIndex);
178 if( pEntry )
180 bool bFound = false;
182 switch( nWhich )
184 case XATTR_FILLBITMAP:
186 const GraphicObject& rGraphicObjectA(static_cast<const XFillBitmapItem*>(pCheckItem)->GetGraphicObject());
187 const GraphicObject& rGraphicObjectB(static_cast<const XBitmapEntry*>(pEntry)->GetGraphicObject());
189 bFound = (rGraphicObjectA == rGraphicObjectB);
190 break;
192 case XATTR_LINEDASH:
193 bFound = static_cast<const XLineDashItem*>(pCheckItem)->GetDashValue() == static_cast<const XDashEntry*>(pEntry)->GetDash();
194 break;
195 case XATTR_LINESTART:
196 bFound = static_cast<const XLineStartItem*>(pCheckItem)->GetLineStartValue() == static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd();
197 break;
198 case XATTR_LINEEND:
199 bFound = static_cast<const XLineEndItem*>(pCheckItem)->GetLineEndValue() == static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd();
200 break;
201 case XATTR_FILLGRADIENT:
202 bFound = static_cast<const XFillGradientItem*>(pCheckItem)->GetGradientValue() == static_cast<const XGradientEntry*>(pEntry)->GetGradient();
203 break;
204 case XATTR_FILLHATCH:
205 bFound = static_cast<const XFillHatchItem*>(pCheckItem)->GetHatchValue() == static_cast<const XHatchEntry*>(pEntry)->GetHatch();
206 break;
209 if( bFound )
211 aUniqueName = pEntry->GetName();
212 break;
214 else
216 const OUString& aEntryName = pEntry->GetName();
217 if(aEntryName.getLength() >= aUser.getLength())
219 sal_Int32 nThisIndex = o3tl::toInt32(aEntryName.subView( aUser.getLength() ));
220 if( nThisIndex >= nUserIndex )
221 nUserIndex = nThisIndex + 1;
228 if (aUniqueName.isEmpty() && pPool1)
230 for (const SfxPoolItem* pItem : pPool1->GetItemSurrogates(nWhich))
232 const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
234 if( !pNameOrIndex->GetName().isEmpty() )
236 if( !bForceNew && pCompareValueFunc( pNameOrIndex, pCheckItem ) )
237 return pNameOrIndex->GetName();
239 if( pNameOrIndex->GetName().startsWith( aUser ) )
241 sal_Int32 nThisIndex = o3tl::toInt32(pNameOrIndex->GetName().subView( aUser.getLength() ));
242 if( nThisIndex >= nUserIndex )
243 nUserIndex = nThisIndex + 1;
247 aUniqueName = aUser + OUString::number( nUserIndex );
251 return aUniqueName;
254 void NameOrIndex::dumpAsXml(xmlTextWriterPtr pWriter) const
256 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("NameOrIndex"));
257 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
258 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("isIndex"), BAD_CAST(OString::boolean(IsIndex()).getStr()));
259 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(GetName().toUtf8().getStr()));
260 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("index"), BAD_CAST(OString::number(nPalIndex).getStr()));
261 (void)xmlTextWriterEndElement(pWriter);
264 SfxPoolItem* XColorItem::CreateDefault() { return new XColorItem; }
266 XColorItem::XColorItem(TypedWhichId<XColorItem> _nWhich, sal_Int32 nIndex, const Color& rTheColor) :
267 NameOrIndex(_nWhich, nIndex),
268 aColor(rTheColor)
272 XColorItem::XColorItem(TypedWhichId<XColorItem> _nWhich, const OUString& rName, const Color& rTheColor) :
273 NameOrIndex(_nWhich, rName),
274 aColor(rTheColor)
278 XColorItem::XColorItem(TypedWhichId<XColorItem> _nWhich, const Color& rTheColor)
279 : NameOrIndex(_nWhich, OUString())
280 , aColor(rTheColor)
284 XColorItem::XColorItem(const XColorItem& rItem) :
285 NameOrIndex(rItem),
286 aColor(rItem.aColor),
287 maComplexColor(rItem.maComplexColor)
291 XColorItem* XColorItem::Clone(SfxItemPool* /*pPool*/) const
293 return new XColorItem(*this);
296 bool XColorItem::operator==(const SfxPoolItem& rItem) const
298 return ( NameOrIndex::operator==(rItem) &&
299 static_cast<const XColorItem&>(rItem).aColor == aColor ) &&
300 static_cast<const XColorItem&>(rItem).maComplexColor == maComplexColor;
303 const Color& XColorItem::GetColorValue() const
305 assert(!IsIndex());
306 return aColor;
310 bool XColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
312 rVal <<= GetColorValue().GetRGBColor();
313 return true;
316 bool XColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
318 Color nValue;
319 rVal >>= nValue;
320 SetColorValue( nValue );
322 return true;
325 void XColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
327 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XColorItem"));
328 if (Which() == SDRATTR_SHADOWCOLOR)
330 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("SDRATTR_SHADOWCOLOR"));
332 else if (Which() == XATTR_FILLCOLOR)
334 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("XATTR_FILLCOLOR"));
336 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("aColor"),
337 BAD_CAST(aColor.AsRGBHexString().toUtf8().getStr()));
339 NameOrIndex::dumpAsXml(pWriter);
341 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("complex-color"));
343 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("scheme-index"),
344 BAD_CAST(OString::number(sal_Int16(maComplexColor.getSchemeType())).getStr()));
346 for (auto const& rTransform : maComplexColor.getTransformations())
348 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("transformation"));
349 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"),
350 BAD_CAST(OString::number(sal_Int16(rTransform.meType)).getStr()));
351 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
352 BAD_CAST(OString::number(rTransform.mnValue).getStr()));
353 (void)xmlTextWriterEndElement(pWriter);
356 (void)xmlTextWriterEndElement(pWriter);
358 (void)xmlTextWriterEndElement(pWriter);
361 // --- line attributes ---
364 SfxPoolItem* XLineStyleItem::CreateDefault() { return new XLineStyleItem; }
366 XLineStyleItem::XLineStyleItem(css::drawing::LineStyle eTheLineStyle) :
367 SfxEnumItem(XATTR_LINESTYLE, eTheLineStyle)
371 XLineStyleItem* XLineStyleItem::Clone(SfxItemPool* /*pPool*/) const
373 return new XLineStyleItem( *this );
376 bool XLineStyleItem::GetPresentation
378 SfxItemPresentation /*ePres*/,
379 MapUnit /*eCoreUnit*/,
380 MapUnit /*ePresUnit*/,
381 OUString& rText, const IntlWrapper&
382 ) const
384 rText.clear();
386 TranslateId pId;
388 switch( GetValue() )
390 case css::drawing::LineStyle_NONE:
391 pId = RID_SVXSTR_INVISIBLE;
392 break;
393 case css::drawing::LineStyle_SOLID:
394 pId = RID_SVXSTR_SOLID;
395 break;
396 default: break;
399 if (pId)
400 rText = SvxResId(pId);
401 return true;
404 bool XLineStyleItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
406 css::drawing::LineStyle eLS = GetValue();
407 rVal <<= eLS;
408 return true;
411 bool XLineStyleItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
413 css::drawing::LineStyle eLS;
414 if(!(rVal >>= eLS ))
416 // also try an int (for Basic)
417 sal_Int32 nLS = 0;
418 if(!(rVal >>= nLS))
419 return false;
420 eLS = static_cast<css::drawing::LineStyle>(nLS);
423 SetValue( eLS );
424 return true;
427 sal_uInt16 XLineStyleItem::GetValueCount() const
429 return 3;
432 XDash::XDash(css::drawing::DashStyle eTheDash, sal_uInt16 nTheDots, double nTheDotLen,
433 sal_uInt16 nTheDashes, double nTheDashLen, double nTheDistance) :
434 eDash(eTheDash),
435 nDots(nTheDots),
436 nDashes(nTheDashes),
437 nDotLen(nTheDotLen),
438 nDashLen(nTheDashLen),
439 nDistance(nTheDistance)
443 bool XDash::operator==(const XDash& rDash) const
445 return ( eDash == rDash.eDash &&
446 nDots == rDash.nDots &&
447 nDotLen == rDash.nDotLen &&
448 nDashes == rDash.nDashes &&
449 nDashLen == rDash.nDashLen &&
450 nDistance == rDash.nDistance );
453 // XDash is translated into an array of doubles which describe the lengths of the
454 // dashes, dots and empty passages. It returns the complete length of the full DashDot
455 // sequence and fills the given vector of doubles accordingly (also resizing, so deleting it).
456 const double SMALLEST_DASH_WIDTH(26.95);
458 double XDash::CreateDotDashArray(::std::vector< double >& rDotDashArray, double fLineWidth) const
460 double fFullDotDashLen(0.0);
461 const sal_uInt16 nNumDotDashArray = (GetDots() + GetDashes()) * 2;
462 rDotDashArray.resize( nNumDotDashArray, 0.0 );
463 sal_uInt16 a;
464 sal_uInt16 nIns(0);
465 double fDashDotDistance = GetDistance();
466 double fSingleDashLen = GetDashLen();
467 double fSingleDotLen = GetDotLen();
469 if (fLineWidth == 0.0)
470 fLineWidth = SMALLEST_DASH_WIDTH;
472 if(GetDashStyle() == css::drawing::DashStyle_RECTRELATIVE || GetDashStyle() == css::drawing::DashStyle_ROUNDRELATIVE)
474 double fFactor = fLineWidth / 100.0;
476 if(GetDashes())
478 if(GetDashLen())
480 // is a dash
481 fSingleDashLen *= fFactor;
483 else
485 // is a dot
486 fSingleDashLen = fLineWidth;
490 if(GetDots())
492 if(GetDotLen())
494 // is a dash
495 fSingleDotLen *= fFactor;
497 else
499 // is a dot
500 fSingleDotLen = fLineWidth;
504 if(GetDashes() || GetDots())
506 if(GetDistance())
508 // dash as distance
509 fDashDotDistance *= fFactor;
511 else
513 // dot as distance
514 fDashDotDistance = fLineWidth;
518 else
520 // absolute values
521 if(GetDashes())
523 if(GetDashLen())
525 // is a dash
526 if(fSingleDashLen < SMALLEST_DASH_WIDTH)
528 fSingleDashLen = SMALLEST_DASH_WIDTH;
531 else
533 // is a dot
534 if(fSingleDashLen < fLineWidth)
536 fSingleDashLen = fLineWidth;
541 if(GetDots())
543 if(GetDotLen())
545 // is a dash
546 if(fSingleDotLen < SMALLEST_DASH_WIDTH)
548 fSingleDotLen = SMALLEST_DASH_WIDTH;
551 else
553 // is a dot
554 if(fSingleDotLen < fLineWidth)
556 fSingleDotLen = fLineWidth;
561 if(GetDashes() || GetDots())
563 if(GetDistance())
565 // dash as distance
566 if(fDashDotDistance < SMALLEST_DASH_WIDTH)
568 fDashDotDistance = SMALLEST_DASH_WIDTH;
571 else
573 // dot as distance
574 if(fDashDotDistance < fLineWidth)
576 fDashDotDistance = fLineWidth;
582 for(a=0;a<GetDots();a++)
584 rDotDashArray[nIns++] = fSingleDotLen;
585 fFullDotDashLen += fSingleDotLen;
586 rDotDashArray[nIns++] = fDashDotDistance;
587 fFullDotDashLen += fDashDotDistance;
590 for(a=0;a<GetDashes();a++)
592 rDotDashArray[nIns++] = fSingleDashLen;
593 fFullDotDashLen += fSingleDashLen;
594 rDotDashArray[nIns++] = fDashDotDistance;
595 fFullDotDashLen += fDashDotDistance;
598 return fFullDotDashLen;
601 SfxPoolItem* XLineDashItem::CreateDefault() {return new XLineDashItem;}
603 XLineDashItem::XLineDashItem(const OUString& rName, const XDash& rTheDash) :
604 NameOrIndex(XATTR_LINEDASH, rName),
605 aDash(rTheDash)
609 XLineDashItem::XLineDashItem(const XLineDashItem& rItem) :
610 NameOrIndex(rItem),
611 aDash(rItem.aDash)
615 XLineDashItem::XLineDashItem(const XDash& rTheDash)
616 : NameOrIndex( XATTR_LINEDASH, -1 ),
617 aDash(rTheDash)
621 XLineDashItem* XLineDashItem::Clone(SfxItemPool* /*pPool*/) const
623 return new XLineDashItem(*this);
626 bool XLineDashItem::operator==(const SfxPoolItem& rItem) const
628 return ( NameOrIndex::operator==(rItem) &&
629 aDash == static_cast<const XLineDashItem&>(rItem).aDash );
632 bool XLineDashItem::GetPresentation
634 SfxItemPresentation /*ePres*/,
635 MapUnit /*eCoreUnit*/,
636 MapUnit /*ePresUnit*/,
637 OUString& rText, const IntlWrapper&
638 ) const
640 rText = GetName();
641 return true;
644 bool XLineDashItem::HasMetrics() const
646 return true;
649 void XLineDashItem::ScaleMetrics(tools::Long nMul, tools::Long nDiv)
651 aDash.SetDotLen( BigInt::Scale( aDash.GetDotLen(), nMul, nDiv ) );
652 aDash.SetDashLen( BigInt::Scale( aDash.GetDashLen(), nMul, nDiv ) );
653 aDash.SetDistance( BigInt::Scale( aDash.GetDistance(), nMul, nDiv ) );
656 bool XLineDashItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
658 nMemberId &= ~CONVERT_TWIPS;
660 switch ( nMemberId )
662 case 0:
664 css::drawing::LineDash aLineDash;
666 const XDash& rXD = GetDashValue();
667 aLineDash.Style = static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(rXD.GetDashStyle()));
668 aLineDash.Dots = rXD.GetDots();
669 aLineDash.DotLen = rXD.GetDotLen();
670 aLineDash.Dashes = rXD.GetDashes();
671 aLineDash.DashLen = rXD.GetDashLen();
672 aLineDash.Distance = rXD.GetDistance();
674 uno::Sequence< beans::PropertyValue > aPropSeq{
675 comphelper::makePropertyValue("Name", SvxUnogetApiNameForItem(Which(), GetName())),
676 comphelper::makePropertyValue("LineDash", aLineDash)
678 rVal <<= aPropSeq;
679 break;
682 case MID_NAME:
684 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
685 break;
688 case MID_LINEDASH:
690 const XDash& rXD = GetDashValue();
692 css::drawing::LineDash aLineDash;
694 aLineDash.Style = static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(rXD.GetDashStyle()));
695 aLineDash.Dots = rXD.GetDots();
696 aLineDash.DotLen = rXD.GetDotLen();
697 aLineDash.Dashes = rXD.GetDashes();
698 aLineDash.DashLen = rXD.GetDashLen();
699 aLineDash.Distance = rXD.GetDistance();
701 rVal <<= aLineDash;
702 break;
705 case MID_LINEDASH_STYLE:
707 const XDash& rXD = GetDashValue();
708 rVal <<= static_cast<css::drawing::DashStyle>(static_cast<sal_Int16>(rXD.GetDashStyle()));
709 break;
712 case MID_LINEDASH_DOTS:
714 const XDash& rXD = GetDashValue();
715 rVal <<= rXD.GetDots();
716 break;
719 case MID_LINEDASH_DOTLEN:
721 const XDash& rXD = GetDashValue();
722 rVal <<= rXD.GetDotLen();
723 break;
726 case MID_LINEDASH_DASHES:
728 const XDash& rXD = GetDashValue();
729 rVal <<= rXD.GetDashes();
730 break;
733 case MID_LINEDASH_DASHLEN:
735 const XDash& rXD = GetDashValue();
736 rVal <<= rXD.GetDashLen();
737 break;
740 case MID_LINEDASH_DISTANCE:
742 const XDash& rXD = GetDashValue();
743 rVal <<= rXD.GetDistance();
744 break;
747 default: OSL_FAIL("Wrong MemberId!"); return false;
750 return true;
753 bool XLineDashItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
755 nMemberId &= ~CONVERT_TWIPS;
757 switch ( nMemberId )
759 case 0:
761 uno::Sequence< beans::PropertyValue > aPropSeq;
763 if ( rVal >>= aPropSeq )
765 css::drawing::LineDash aLineDash;
766 OUString aName;
767 bool bLineDash( false );
768 for ( const auto& rProp : std::as_const(aPropSeq) )
770 if ( rProp.Name == "Name" )
771 rProp.Value >>= aName;
772 else if ( rProp.Name == "LineDash" )
774 if ( rProp.Value >>= aLineDash )
775 bLineDash = true;
779 SetName( aName );
780 if ( bLineDash )
782 XDash aXDash;
784 aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(aLineDash.Style)));
785 aXDash.SetDots(aLineDash.Dots);
786 aXDash.SetDotLen(aLineDash.DotLen);
787 aXDash.SetDashes(aLineDash.Dashes);
788 aXDash.SetDashLen(aLineDash.DashLen);
789 aXDash.SetDistance(aLineDash.Distance);
791 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
792 aXDash.SetDots(1);
794 SetDashValue( aXDash );
797 return true;
800 return false;
803 case MID_NAME:
805 OUString aName;
806 if (!(rVal >>= aName))
807 return false;
808 SetName( aName );
809 break;
812 case MID_LINEDASH:
814 css::drawing::LineDash aLineDash;
815 if(!(rVal >>= aLineDash))
816 return false;
818 XDash aXDash;
820 aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(aLineDash.Style)));
821 aXDash.SetDots(aLineDash.Dots);
822 aXDash.SetDotLen(aLineDash.DotLen);
823 aXDash.SetDashes(aLineDash.Dashes);
824 aXDash.SetDashLen(aLineDash.DashLen);
825 aXDash.SetDistance(aLineDash.Distance);
827 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
828 aXDash.SetDots(1);
830 SetDashValue( aXDash );
831 break;
834 case MID_LINEDASH_STYLE:
836 sal_Int16 nVal = sal_Int16();
837 if(!(rVal >>= nVal))
838 return false;
840 XDash aXDash = GetDashValue();
841 aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(nVal)));
843 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
844 aXDash.SetDots(1);
846 SetDashValue( aXDash );
848 break;
851 case MID_LINEDASH_DOTS:
852 case MID_LINEDASH_DASHES:
854 sal_Int16 nVal = sal_Int16();
855 if(!(rVal >>= nVal))
856 return false;
858 XDash aXDash = GetDashValue();
859 if ( nMemberId == MID_LINEDASH_DOTS )
860 aXDash.SetDots( nVal );
861 else
862 aXDash.SetDashes( nVal );
864 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
865 aXDash.SetDots(1);
867 SetDashValue( aXDash );
868 break;
871 case MID_LINEDASH_DOTLEN:
872 case MID_LINEDASH_DASHLEN:
873 case MID_LINEDASH_DISTANCE:
875 sal_uInt32 nVal = 0;
876 if(!(rVal >>= nVal))
877 return false;
879 XDash aXDash = GetDashValue();
880 if ( nMemberId == MID_LINEDASH_DOTLEN )
881 aXDash.SetDotLen( nVal );
882 else if ( nMemberId == MID_LINEDASH_DASHLEN )
883 aXDash.SetDashLen( nVal );
884 else
885 aXDash.SetDistance( nVal );
887 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
888 aXDash.SetDots(1);
890 SetDashValue( aXDash );
891 break;
895 return true;
898 bool XLineDashItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
900 return static_cast<const XLineDashItem*>(p1)->GetDashValue() == static_cast<const XLineDashItem*>(p2)->GetDashValue();
903 std::unique_ptr<XLineDashItem> XLineDashItem::checkForUniqueItem( SdrModel* pModel ) const
905 if( pModel )
907 const OUString aUniqueName = NameOrIndex::CheckNamedItem(
908 this, XATTR_LINEDASH, &pModel->GetItemPool(),
909 XLineDashItem::CompareValueFunc, RID_SVXSTR_DASH20,
910 pModel->GetPropertyList( XPropertyListType::Dash ) );
912 // if the given name is not valid, replace it!
913 if( aUniqueName != GetName() )
914 return std::make_unique<XLineDashItem>( aUniqueName, aDash );
917 return nullptr;
920 SfxPoolItem* XLineWidthItem::CreateDefault() {return new XLineWidthItem;}
922 XLineWidthItem::XLineWidthItem(tools::Long nWidth) :
923 SfxMetricItem(XATTR_LINEWIDTH, nWidth)
927 XLineWidthItem* XLineWidthItem::Clone(SfxItemPool* /*pPool*/) const
929 return new XLineWidthItem(*this);
932 bool XLineWidthItem::GetPresentation
934 SfxItemPresentation /*ePres*/,
935 MapUnit eCoreUnit,
936 MapUnit ePresUnit,
937 OUString& rText, const IntlWrapper& rIntl
938 ) const
940 rText = GetMetricText( static_cast<tools::Long>(GetValue()),
941 eCoreUnit, ePresUnit, &rIntl) +
942 " " + EditResId( GetMetricId( ePresUnit) );
943 return true;
946 bool XLineWidthItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
948 sal_Int32 nValue = GetValue();
949 if( 0 != (nMemberId&CONVERT_TWIPS) )
950 nValue = convertTwipToMm100(nValue);
952 rVal <<= nValue;
953 return true;
956 bool XLineWidthItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
958 sal_Int32 nValue = 0;
959 rVal >>= nValue;
960 if( 0 != (nMemberId&CONVERT_TWIPS) )
961 nValue = o3tl::toTwips(nValue, o3tl::Length::mm100);
963 SetValue( nValue );
964 return true;
967 SfxPoolItem* XLineColorItem::CreateDefault() { return new XLineColorItem; }
969 XLineColorItem::XLineColorItem(sal_Int32 nIndex, const Color& rTheColor) :
970 XColorItem(XATTR_LINECOLOR, nIndex, rTheColor)
974 XLineColorItem::XLineColorItem(const OUString& rName, const Color& rTheColor) :
975 XColorItem(XATTR_LINECOLOR, rName, rTheColor)
979 XLineColorItem* XLineColorItem::Clone(SfxItemPool* /*pPool*/) const
981 return new XLineColorItem(*this);
984 bool XLineColorItem::GetPresentation
986 SfxItemPresentation /*ePres*/,
987 MapUnit /*eCoreUnit*/,
988 MapUnit /*ePresUnit*/,
989 OUString& rText, const IntlWrapper&
990 ) const
992 rText = GetName();
993 return true;
996 bool XLineColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId) const
998 nMemberId &= ~CONVERT_TWIPS;
999 switch (nMemberId)
1001 case MID_COMPLEX_COLOR:
1003 auto xComplexColor = model::color::createXComplexColor(getComplexColor());
1004 rVal <<= xComplexColor;
1005 break;
1007 case MID_COMPLEX_COLOR_JSON:
1009 rVal <<= OStringToOUString(model::color::convertToJSON(getComplexColor()), RTL_TEXTENCODING_UTF8);
1010 break;
1012 default:
1014 rVal <<= GetColorValue().GetRGBColor();
1015 break;
1018 return true;
1021 bool XLineColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId)
1023 nMemberId &= ~CONVERT_TWIPS;
1024 switch(nMemberId)
1026 case MID_COMPLEX_COLOR:
1028 css::uno::Reference<css::util::XComplexColor> xComplexColor;
1029 if (!(rVal >>= xComplexColor))
1030 return false;
1031 setComplexColor(model::color::getFromXComplexColor(xComplexColor));
1033 break;
1034 case MID_COMPLEX_COLOR_JSON:
1036 OUString sComplexColorJson;
1037 if (!(rVal >>= sComplexColorJson))
1038 return false;
1040 if (sComplexColorJson.isEmpty())
1041 return false;
1042 model::ComplexColor aComplexColor;
1043 OString aJSON = OUStringToOString(sComplexColorJson, RTL_TEXTENCODING_ASCII_US);
1044 model::color::convertFromJSON(aJSON, aComplexColor);
1045 setComplexColor(aComplexColor);
1047 break;
1048 default:
1050 sal_Int32 nValue;
1051 if(!(rVal >>= nValue ))
1052 return false;
1054 SetColorValue( Color(ColorTransparency, nValue) );
1055 break;
1058 return true;
1062 SfxPoolItem* XLineStartItem::CreateDefault() {return new XLineStartItem;}
1064 XLineStartItem::XLineStartItem(sal_Int32 nIndex)
1065 : NameOrIndex(XATTR_LINESTART, nIndex)
1069 XLineStartItem::XLineStartItem(const OUString& rName, basegfx::B2DPolyPolygon aPolyPolygon)
1070 : NameOrIndex(XATTR_LINESTART, rName),
1071 maPolyPolygon(std::move(aPolyPolygon))
1075 XLineStartItem::XLineStartItem(const XLineStartItem& rItem)
1076 : NameOrIndex(rItem),
1077 maPolyPolygon(rItem.maPolyPolygon)
1081 XLineStartItem::XLineStartItem(basegfx::B2DPolyPolygon aPolyPolygon)
1082 : NameOrIndex( XATTR_LINESTART, -1 ),
1083 maPolyPolygon(std::move(aPolyPolygon))
1087 XLineStartItem* XLineStartItem::Clone(SfxItemPool* /*pPool*/) const
1089 return new XLineStartItem(*this);
1092 bool XLineStartItem::operator==(const SfxPoolItem& rItem) const
1094 return ( NameOrIndex::operator==(rItem) && static_cast<const XLineStartItem&>(rItem).maPolyPolygon == maPolyPolygon );
1097 bool XLineStartItem::GetPresentation
1099 SfxItemPresentation /*ePres*/,
1100 MapUnit /*eCoreUnit*/,
1101 MapUnit /*ePresUnit*/,
1102 OUString& rText, const IntlWrapper&
1103 ) const
1105 rText = GetName();
1106 return true;
1109 bool XLineStartItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
1111 nMemberId &= ~CONVERT_TWIPS;
1112 if( nMemberId == MID_NAME )
1114 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
1116 else
1118 css::drawing::PolyPolygonBezierCoords aBezier;
1119 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( maPolyPolygon, aBezier );
1120 rVal <<= aBezier;
1123 return true;
1126 bool XLineStartItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
1128 nMemberId &= ~CONVERT_TWIPS;
1129 if( nMemberId == MID_NAME )
1131 return false;
1133 else
1135 maPolyPolygon.clear();
1137 if( rVal.hasValue() )
1139 auto pCoords = o3tl::tryAccess<css::drawing::PolyPolygonBezierCoords>(
1140 rVal);
1141 if( !pCoords )
1142 return false;
1144 if( pCoords->Coordinates.getLength() > 0 )
1146 maPolyPolygon = basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( *pCoords );
1147 // #i72807# close line start/end polygons hard
1148 // maPolyPolygon.setClosed(true);
1153 return true;
1156 /** this function searches in both the models pool and the styles pool for XLineStartItem
1157 and XLineEndItem with the same value or name and returns an item with the value of
1158 this item and a unique name for an item with this value. */
1159 std::unique_ptr<XLineStartItem> XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const
1161 if( pModel )
1163 std::unique_ptr<XLineStartItem> pTempItem;
1164 const XLineStartItem* pLineStartItem = this;
1166 OUString aUniqueName( GetName() );
1168 if( !maPolyPolygon.count() )
1170 // if the polygon is empty, check if the name is empty
1171 if( aUniqueName.isEmpty() )
1172 return nullptr;
1174 // force empty name for empty polygons
1175 return std::make_unique<XLineStartItem>( "", maPolyPolygon );
1178 if( maPolyPolygon.count() > 1 )
1180 // check if the polygon is closed
1181 if(!maPolyPolygon.isClosed())
1183 // force a closed polygon
1184 basegfx::B2DPolyPolygon aNew(maPolyPolygon);
1185 aNew.setClosed(true);
1186 pTempItem.reset(new XLineStartItem( aUniqueName, std::move(aNew) ));
1187 pLineStartItem = pTempItem.get();
1191 bool bForceNew = false;
1193 // 2. if we have a name check if there is already an item with the
1194 // same name in the documents pool with a different line end or start
1196 const SfxItemPool& rPool1 = pModel->GetItemPool();
1197 if (!aUniqueName.isEmpty())
1199 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
1201 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1203 if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
1205 // if there is already an item with the same name and the same
1206 // value it's ok to set it
1207 if( pItem->GetLineStartValue() != pLineStartItem->GetLineStartValue() )
1209 // same name but different value, we need a new name for this item
1210 aUniqueName.clear();
1211 bForceNew = true;
1213 break;
1217 if( !bForceNew )
1219 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
1221 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1223 if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
1225 // if there is already an item with the same name and the same
1226 // value it's ok to set it
1227 if( pItem->GetLineEndValue() != pLineStartItem->GetLineStartValue() )
1229 // same name but different value, we need a new name for this item
1230 aUniqueName.clear();
1231 bForceNew = true;
1233 break;
1239 const SfxItemPool* pPool2 = pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : nullptr;
1240 if( !aUniqueName.isEmpty() && pPool2)
1242 for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINESTART))
1244 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1246 if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
1248 // if there is already an item with the same name and the same
1249 // value it's ok to set it
1250 if( pItem->GetLineStartValue() != pLineStartItem->GetLineStartValue() )
1252 // same name but different value, we need a new name for this item
1253 aUniqueName.clear();
1254 bForceNew = true;
1256 break;
1260 if( !bForceNew )
1262 for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINEEND))
1264 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1266 if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
1268 // if there is already an item with the same name and the same
1269 // value it's ok to set it
1270 if( pItem->GetLineEndValue() != pLineStartItem->GetLineStartValue() )
1272 // same name but different value, we need a new name for this item
1273 aUniqueName.clear();
1274 bForceNew = true;
1276 break;
1282 // if we have no name yet, find existing item with same content or
1283 // create a unique name
1284 if( aUniqueName.isEmpty() )
1286 bool bFoundExisting = false;
1288 sal_Int32 nUserIndex = 1;
1289 const OUString aUser(SvxResId(RID_SVXSTR_LINEEND));
1291 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
1293 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1295 if (pItem && !pItem->GetName().isEmpty())
1297 if (!bForceNew && pItem->GetLineStartValue() == pLineStartItem->GetLineStartValue())
1299 aUniqueName = pItem->GetName();
1300 bFoundExisting = true;
1301 break;
1304 if (pItem->GetName().startsWith(aUser))
1306 sal_Int32 nThisIndex = o3tl::toInt32(pItem->GetName().subView(aUser.getLength()));
1307 if (nThisIndex >= nUserIndex)
1308 nUserIndex = nThisIndex + 1;
1313 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
1315 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1317 if (pItem && !pItem->GetName().isEmpty())
1319 if (!bForceNew && pItem->GetLineEndValue() == pLineStartItem->GetLineStartValue())
1321 aUniqueName = pItem->GetName();
1322 bFoundExisting = true;
1323 break;
1326 if (pItem->GetName().startsWith(aUser))
1328 sal_Int32 nThisIndex = o3tl::toInt32(pItem->GetName().subView(aUser.getLength()));
1329 if (nThisIndex >= nUserIndex)
1330 nUserIndex = nThisIndex + 1;
1335 if( !bFoundExisting )
1337 aUniqueName = aUser + " " + OUString::number( nUserIndex );
1341 // if the given name is not valid, replace it!
1342 if( aUniqueName != GetName() || pTempItem )
1344 if( pTempItem )
1346 pTempItem->SetName( aUniqueName );
1347 return pTempItem;
1349 else
1351 return std::make_unique<XLineStartItem>( aUniqueName, maPolyPolygon );
1356 return nullptr;
1359 SfxPoolItem* XLineEndItem::CreateDefault() {return new XLineEndItem;}
1361 XLineEndItem::XLineEndItem(sal_Int32 nIndex)
1362 : NameOrIndex(XATTR_LINEEND, nIndex)
1366 XLineEndItem::XLineEndItem(const OUString& rName, basegfx::B2DPolyPolygon aPolyPolygon)
1367 : NameOrIndex(XATTR_LINEEND, rName),
1368 maPolyPolygon(std::move(aPolyPolygon))
1372 XLineEndItem::XLineEndItem(const XLineEndItem& rItem)
1373 : NameOrIndex(rItem),
1374 maPolyPolygon(rItem.maPolyPolygon)
1378 XLineEndItem::XLineEndItem(basegfx::B2DPolyPolygon aPolyPolygon)
1379 : NameOrIndex( XATTR_LINEEND, -1 ),
1380 maPolyPolygon(std::move(aPolyPolygon))
1384 XLineEndItem* XLineEndItem::Clone(SfxItemPool* /*pPool*/) const
1386 return new XLineEndItem(*this);
1389 bool XLineEndItem::operator==(const SfxPoolItem& rItem) const
1391 return ( NameOrIndex::operator==(rItem) && static_cast<const XLineEndItem&>(rItem).maPolyPolygon == maPolyPolygon );
1395 /** this function searches in both the models pool and the styles pool for XLineStartItem
1396 and XLineEndItem with the same value or name and returns an item with the value of
1397 this item and a unique name for an item with this value. */
1398 std::unique_ptr<XLineEndItem> XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const
1400 if( pModel )
1402 std::unique_ptr<XLineEndItem> pTempItem;
1403 const XLineEndItem* pLineEndItem = this;
1405 OUString aUniqueName( GetName() );
1407 if( !maPolyPolygon.count() )
1409 // if the polygon is empty, check if the name is empty
1410 if( aUniqueName.isEmpty() )
1411 return nullptr;
1413 // force empty name for empty polygons
1414 return std::make_unique<XLineEndItem>( "", maPolyPolygon );
1417 if( maPolyPolygon.count() > 1 )
1419 // check if the polygon is closed
1420 if(!maPolyPolygon.isClosed())
1422 // force a closed polygon
1423 basegfx::B2DPolyPolygon aNew(maPolyPolygon);
1424 aNew.setClosed(true);
1425 pTempItem.reset(new XLineEndItem( aUniqueName, std::move(aNew) ));
1426 pLineEndItem = pTempItem.get();
1430 bool bForceNew = false;
1432 // 2. if we have a name check if there is already an item with the
1433 // same name in the documents pool with a different line end or start
1435 const SfxItemPool& rPool1 = pModel->GetItemPool();
1436 if (!aUniqueName.isEmpty())
1438 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
1440 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1442 if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
1444 // if there is already an item with the same name and the same
1445 // value it's ok to set it
1446 if( pItem->GetLineStartValue() != pLineEndItem->GetLineEndValue() )
1448 // same name but different value, we need a new name for this item
1449 aUniqueName.clear();
1450 bForceNew = true;
1452 break;
1456 if( !bForceNew )
1458 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
1460 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1462 if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
1464 // if there is already an item with the same name and the same
1465 // value it's ok to set it
1466 if( pItem->GetLineEndValue() != pLineEndItem->GetLineEndValue() )
1468 // same name but different value, we need a new name for this item
1469 aUniqueName.clear();
1470 bForceNew = true;
1472 break;
1478 const SfxItemPool* pPool2 = pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : nullptr;
1479 if( !aUniqueName.isEmpty() && pPool2)
1481 for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINESTART))
1483 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1485 if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
1487 // if there is already an item with the same name and the same
1488 // value it's ok to set it
1489 if( pItem->GetLineStartValue() != pLineEndItem->GetLineEndValue() )
1491 // same name but different value, we need a new name for this item
1492 aUniqueName.clear();
1493 bForceNew = true;
1495 break;
1499 if( !bForceNew )
1501 for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINEEND))
1503 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1505 if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
1507 // if there is already an item with the same name and the same
1508 // value it's ok to set it
1509 if( pItem->GetLineEndValue() != pLineEndItem->GetLineEndValue() )
1511 // same name but different value, we need a new name for this item
1512 aUniqueName.clear();
1513 bForceNew = true;
1515 break;
1521 // if we have no name yet, find existing item with same content or
1522 // create a unique name
1523 if( aUniqueName.isEmpty() )
1525 bool bFoundExisting = false;
1527 sal_Int32 nUserIndex = 1;
1528 const OUString aUser(SvxResId(RID_SVXSTR_LINEEND));
1530 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
1532 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1534 if (pItem && !pItem->GetName().isEmpty())
1536 if (!bForceNew && pItem->GetLineStartValue() == pLineEndItem->GetLineEndValue())
1538 aUniqueName = pItem->GetName();
1539 bFoundExisting = true;
1540 break;
1543 if (pItem->GetName().startsWith(aUser))
1545 sal_Int32 nThisIndex = o3tl::toInt32(pItem->GetName().subView(aUser.getLength()));
1546 if (nThisIndex >= nUserIndex)
1547 nUserIndex = nThisIndex + 1;
1552 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
1554 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1556 if (pItem && !pItem->GetName().isEmpty())
1558 if (!bForceNew && pItem->GetLineEndValue() == pLineEndItem->GetLineEndValue())
1560 aUniqueName = pItem->GetName();
1561 bFoundExisting = true;
1562 break;
1565 if (pItem->GetName().startsWith(aUser))
1567 sal_Int32 nThisIndex = o3tl::toInt32(pItem->GetName().subView(aUser.getLength()));
1568 if (nThisIndex >= nUserIndex)
1569 nUserIndex = nThisIndex + 1;
1574 if( !bFoundExisting )
1576 aUniqueName = aUser + " " + OUString::number( nUserIndex );
1580 // if the given name is not valid, replace it!
1581 if( aUniqueName != GetName() || pTempItem )
1583 if( pTempItem )
1585 pTempItem->SetName( aUniqueName );
1586 return pTempItem;
1588 else
1590 return std::make_unique<XLineEndItem>( aUniqueName, maPolyPolygon );
1595 return nullptr;
1598 bool XLineEndItem::GetPresentation
1600 SfxItemPresentation /*ePres*/,
1601 MapUnit /*eCoreUnit*/,
1602 MapUnit /*ePresUnit*/,
1603 OUString& rText, const IntlWrapper&
1604 ) const
1606 rText = GetName();
1607 return true;
1610 bool XLineEndItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
1612 nMemberId &= ~CONVERT_TWIPS;
1613 if( nMemberId == MID_NAME )
1615 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
1617 else
1619 css::drawing::PolyPolygonBezierCoords aBezier;
1620 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( maPolyPolygon, aBezier );
1621 rVal <<= aBezier;
1623 return true;
1626 bool XLineEndItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
1628 nMemberId &= ~CONVERT_TWIPS;
1629 if( nMemberId == MID_NAME )
1631 return false;
1633 else
1635 maPolyPolygon.clear();
1637 if( rVal.hasValue() )
1639 auto pCoords = o3tl::tryAccess<css::drawing::PolyPolygonBezierCoords>(
1640 rVal);
1641 if( !pCoords )
1642 return false;
1644 if( pCoords->Coordinates.getLength() > 0 )
1646 maPolyPolygon = basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( *pCoords );
1647 // #i72807# close line start/end polygons hard
1648 // maPolyPolygon.setClosed(true);
1653 return true;
1656 XLineStartWidthItem::XLineStartWidthItem(tools::Long nWidth) :
1657 SfxMetricItem(XATTR_LINESTARTWIDTH, nWidth)
1661 XLineStartWidthItem* XLineStartWidthItem::Clone(SfxItemPool* /*pPool*/) const
1663 return new XLineStartWidthItem(*this);
1666 bool XLineStartWidthItem::GetPresentation
1668 SfxItemPresentation /*ePres*/,
1669 MapUnit eCoreUnit,
1670 MapUnit ePresUnit,
1671 OUString& rText, const IntlWrapper& rIntl
1672 ) const
1674 rText = GetMetricText( static_cast<tools::Long>(GetValue()),
1675 eCoreUnit, ePresUnit, &rIntl) +
1676 " " + EditResId( GetMetricId( ePresUnit) );
1677 return true;
1680 bool XLineStartWidthItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1682 rVal <<= GetValue();
1683 return true;
1686 bool XLineStartWidthItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1688 sal_Int32 nValue = 0;
1689 rVal >>= nValue;
1690 SetValue( nValue );
1691 return true;
1694 XLineEndWidthItem::XLineEndWidthItem(tools::Long nWidth) :
1695 SfxMetricItem(XATTR_LINEENDWIDTH, nWidth)
1699 XLineEndWidthItem* XLineEndWidthItem::Clone(SfxItemPool* /*pPool*/) const
1701 return new XLineEndWidthItem(*this);
1704 bool XLineEndWidthItem::GetPresentation
1706 SfxItemPresentation /*ePres*/,
1707 MapUnit eCoreUnit,
1708 MapUnit ePresUnit,
1709 OUString& rText, const IntlWrapper& rIntl
1710 ) const
1712 rText = GetMetricText( static_cast<tools::Long>(GetValue()),
1713 eCoreUnit, ePresUnit, &rIntl) +
1714 " " + EditResId( GetMetricId( ePresUnit) );
1715 return true;
1718 bool XLineEndWidthItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1720 rVal <<= GetValue();
1721 return true;
1724 bool XLineEndWidthItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1726 sal_Int32 nValue = 0;
1727 rVal >>= nValue;
1728 SetValue( nValue );
1729 return true;
1732 XLineStartCenterItem::XLineStartCenterItem(bool bStartCenter) :
1733 SfxBoolItem(XATTR_LINESTARTCENTER, bStartCenter)
1737 XLineStartCenterItem* XLineStartCenterItem::Clone(SfxItemPool* /*pPool*/) const
1739 return new XLineStartCenterItem(*this);
1742 bool XLineStartCenterItem::GetPresentation
1744 SfxItemPresentation /*ePres*/,
1745 MapUnit /*eCoreUnit*/,
1746 MapUnit /*ePresUnit*/,
1747 OUString& rText, const IntlWrapper&
1748 ) const
1750 rText = SvxResId(GetValue() ? RID_SVXSTR_CENTERED : RID_SVXSTR_NOTCENTERED);
1751 return true;
1754 bool XLineStartCenterItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1756 bool bValue = GetValue();
1757 rVal <<= bValue;
1758 return true;
1761 bool XLineStartCenterItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1763 auto b = o3tl::tryAccess<bool>(rVal);
1764 if( !b )
1765 return false;
1767 SetValue( *b );
1768 return true;
1771 XLineEndCenterItem::XLineEndCenterItem(bool bEndCenter) :
1772 SfxBoolItem(XATTR_LINEENDCENTER, bEndCenter)
1776 XLineEndCenterItem* XLineEndCenterItem::Clone(SfxItemPool* /*pPool*/) const
1778 return new XLineEndCenterItem(*this);
1781 bool XLineEndCenterItem::GetPresentation
1783 SfxItemPresentation /*ePres*/,
1784 MapUnit /*eCoreUnit*/,
1785 MapUnit /*ePresUnit*/,
1786 OUString& rText, const IntlWrapper&
1787 ) const
1789 rText = SvxResId(GetValue() ? RID_SVXSTR_CENTERED : RID_SVXSTR_NOTCENTERED);
1790 return true;
1793 bool XLineEndCenterItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1795 bool bValue = GetValue();
1796 rVal <<= bValue;
1797 return true;
1800 bool XLineEndCenterItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1802 auto b = o3tl::tryAccess<bool>(rVal);
1803 if( !b )
1804 return false;
1806 SetValue( *b );
1807 return true;
1810 // --- fill attributes ---
1813 SfxPoolItem* XFillStyleItem::CreateDefault() { return new XFillStyleItem; }
1815 XFillStyleItem::XFillStyleItem(drawing::FillStyle eFillStyle) :
1816 SfxEnumItem(XATTR_FILLSTYLE, eFillStyle)
1820 XFillStyleItem* XFillStyleItem::Clone(SfxItemPool* /*pPool*/) const
1822 return new XFillStyleItem( *this );
1825 bool XFillStyleItem::GetPresentation
1827 SfxItemPresentation /*ePres*/,
1828 MapUnit /*eCoreUnit*/,
1829 MapUnit /*ePresUnit*/,
1830 OUString& rText, const IntlWrapper&
1831 ) const
1833 rText.clear();
1835 TranslateId pId;
1837 switch( GetValue() )
1839 case drawing::FillStyle_NONE:
1840 pId = RID_SVXSTR_INVISIBLE;
1841 break;
1842 case drawing::FillStyle_SOLID:
1843 pId = RID_SVXSTR_SOLID;
1844 break;
1845 case drawing::FillStyle_GRADIENT:
1846 pId = RID_SVXSTR_GRADIENT;
1847 break;
1848 case drawing::FillStyle_HATCH:
1849 pId = RID_SVXSTR_HATCH;
1850 break;
1851 case drawing::FillStyle_BITMAP:
1852 pId = RID_SVXSTR_BITMAP;
1853 break;
1854 default: break;
1857 if (pId)
1858 rText = SvxResId(pId);
1859 return true;
1862 sal_uInt16 XFillStyleItem::GetValueCount() const
1864 return 5;
1867 bool XFillStyleItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1869 css::drawing::FillStyle eFS = GetValue();
1871 rVal <<= eFS;
1873 return true;
1876 bool XFillStyleItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1878 css::drawing::FillStyle eFS;
1879 if(!(rVal >>= eFS))
1881 // also try an int (for Basic)
1882 sal_Int32 nFS = 0;
1883 if(!(rVal >>= nFS))
1884 return false;
1885 eFS = static_cast<css::drawing::FillStyle>(nFS);
1888 SetValue( eFS );
1890 return true;
1893 void XFillStyleItem::dumpAsXml(xmlTextWriterPtr pWriter) const
1895 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XFillStyleItem"));
1896 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1897 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(static_cast<sal_Int16>(GetValue())).getStr()));
1899 OUString aPresentation;
1900 IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
1901 GetPresentation(SfxItemPresentation::Nameless, MapUnit::Map100thMM, MapUnit::Map100thMM, aPresentation, aIntlWrapper);
1902 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), BAD_CAST(aPresentation.toUtf8().getStr()));
1904 (void)xmlTextWriterEndElement(pWriter);
1907 boost::property_tree::ptree XFillStyleItem::dumpAsJSON() const
1909 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
1911 if (Which() == XATTR_FILLSTYLE)
1912 aTree.put("commandName", ".uno:FillStyle");
1914 OUString sValue;
1916 switch( GetValue() )
1918 case drawing::FillStyle_NONE:
1919 sValue = "NONE";
1920 break;
1921 case drawing::FillStyle_SOLID:
1922 sValue = "SOLID";
1923 break;
1924 case drawing::FillStyle_GRADIENT:
1925 sValue = "GRADIENT";
1926 break;
1927 case drawing::FillStyle_HATCH:
1928 sValue = "HATCH";
1929 break;
1930 case drawing::FillStyle_BITMAP:
1931 sValue = "BITMAP";
1932 break;
1933 default: break;
1936 aTree.put("state", sValue);
1938 return aTree;
1942 SfxPoolItem* XFillColorItem::CreateDefault() { return new XFillColorItem; }
1944 XFillColorItem::XFillColorItem(sal_Int32 nIndex, const Color& rTheColor) :
1945 XColorItem(XATTR_FILLCOLOR, nIndex, rTheColor)
1949 XFillColorItem::XFillColorItem(const OUString& rName, const Color& rTheColor) :
1950 XColorItem(XATTR_FILLCOLOR, rName, rTheColor)
1954 XFillColorItem* XFillColorItem::Clone(SfxItemPool* /*pPool*/) const
1956 return new XFillColorItem(*this);
1959 bool XFillColorItem::GetPresentation
1961 SfxItemPresentation /*ePres*/,
1962 MapUnit /*eCoreUnit*/,
1963 MapUnit /*ePresUnit*/,
1964 OUString& rText, const IntlWrapper&
1965 ) const
1967 rText = GetName();
1968 return true;
1971 bool XFillColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
1973 nMemberId &= ~CONVERT_TWIPS;
1974 switch (nMemberId)
1976 case MID_COLOR_THEME_INDEX:
1978 rVal <<= sal_Int16(getComplexColor().getSchemeType());
1979 break;
1981 case MID_COLOR_LUM_MOD:
1983 sal_Int16 nValue = 10000;
1984 for (auto const& rTransform : getComplexColor().getTransformations())
1986 if (rTransform.meType == model::TransformationType::LumMod)
1987 nValue = rTransform.mnValue;
1989 rVal <<= nValue;
1990 break;
1992 case MID_COLOR_LUM_OFF:
1994 sal_Int16 nValue = 0;
1995 for (auto const& rTransform : getComplexColor().getTransformations())
1997 if (rTransform.meType == model::TransformationType::LumOff)
1998 nValue = rTransform.mnValue;
2000 rVal <<= nValue;
2001 break;
2003 case MID_COMPLEX_COLOR:
2005 auto xComplexColor = model::color::createXComplexColor(getComplexColor());
2006 rVal <<= xComplexColor;
2007 break;
2009 case MID_COMPLEX_COLOR_JSON:
2011 rVal <<= OStringToOUString(model::color::convertToJSON(getComplexColor()), RTL_TEXTENCODING_UTF8);
2012 break;
2014 default:
2016 rVal <<= GetColorValue().GetRGBColor();
2017 break;
2021 return true;
2024 bool XFillColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2026 nMemberId &= ~CONVERT_TWIPS;
2027 switch(nMemberId)
2029 case MID_COLOR_THEME_INDEX:
2031 sal_Int16 nIndex = -1;
2032 if (!(rVal >>= nIndex))
2033 return false;
2034 getComplexColor().setSchemeColor(model::convertToThemeColorType(nIndex));
2036 break;
2037 case MID_COLOR_LUM_MOD:
2039 sal_Int16 nLumMod = 10000;
2040 if (!(rVal >>= nLumMod))
2041 return false;
2042 getComplexColor().removeTransformations(model::TransformationType::LumMod);
2043 getComplexColor().addTransformation({model::TransformationType::LumMod, nLumMod});
2045 break;
2046 case MID_COLOR_LUM_OFF:
2048 sal_Int16 nLumOff = 0;
2049 if (!(rVal >>= nLumOff))
2050 return false;
2051 getComplexColor().removeTransformations(model::TransformationType::LumOff);
2052 getComplexColor().addTransformation({model::TransformationType::LumOff, nLumOff});
2054 break;
2055 case MID_COMPLEX_COLOR:
2057 css::uno::Reference<css::util::XComplexColor> xComplexColor;
2058 if (!(rVal >>= xComplexColor))
2059 return false;
2060 setComplexColor(model::color::getFromXComplexColor(xComplexColor));
2062 break;
2063 case MID_COMPLEX_COLOR_JSON:
2065 OUString sComplexColorJson;
2066 if (!(rVal >>= sComplexColorJson))
2067 return false;
2069 if (sComplexColorJson.isEmpty())
2070 return false;
2072 OString aJSON = OUStringToOString(sComplexColorJson, RTL_TEXTENCODING_ASCII_US);
2073 model::ComplexColor aComplexColor;
2074 model::color::convertFromJSON(aJSON, aComplexColor);
2075 setComplexColor(aComplexColor);
2077 break;
2078 default:
2080 Color nValue;
2081 if(!(rVal >>= nValue ))
2082 return false;
2084 SetColorValue( nValue );
2087 break;
2089 return true;
2092 void XFillColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
2094 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XFillColorItem"));
2095 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2097 XColorItem::dumpAsXml(pWriter);
2099 (void)xmlTextWriterEndElement(pWriter);
2102 boost::property_tree::ptree XFillColorItem::dumpAsJSON() const
2104 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
2106 if (Which() == XATTR_FILLCOLOR)
2107 aTree.put("commandName", ".uno:FillPageColor");
2109 aTree.put("state", GetColorValue().AsRGBHexString());
2111 return aTree;
2114 XSecondaryFillColorItem::XSecondaryFillColorItem(const OUString& rName, const Color& rTheColor) :
2115 XColorItem(XATTR_SECONDARYFILLCOLOR, rName, rTheColor)
2119 XSecondaryFillColorItem* XSecondaryFillColorItem::Clone(SfxItemPool* /*pPool*/) const
2121 return new XSecondaryFillColorItem(*this);
2124 bool XSecondaryFillColorItem::GetPresentation
2126 SfxItemPresentation /*ePres*/,
2127 MapUnit /*eCoreUnit*/,
2128 MapUnit /*ePresUnit*/,
2129 OUString& rText, const IntlWrapper&
2130 ) const
2132 rText = GetName();
2133 return true;
2136 SfxPoolItem* XFillGradientItem::CreateDefault() { return new XFillGradientItem; }
2138 XFillGradientItem::XFillGradientItem(sal_Int32 nIndex,
2139 const basegfx::BGradient& rTheGradient) :
2140 NameOrIndex(XATTR_FILLGRADIENT, nIndex),
2141 aGradient(rTheGradient)
2145 XFillGradientItem::XFillGradientItem(const OUString& rName,
2146 const basegfx::BGradient& rTheGradient, TypedWhichId<XFillGradientItem> nWhich)
2147 : NameOrIndex(nWhich, rName)
2148 , aGradient(rTheGradient)
2152 XFillGradientItem::XFillGradientItem(const XFillGradientItem& rItem) :
2153 NameOrIndex(rItem),
2154 aGradient(rItem.aGradient)
2158 XFillGradientItem::XFillGradientItem( const basegfx::BGradient& rTheGradient )
2159 : NameOrIndex( XATTR_FILLGRADIENT, -1 ),
2160 aGradient(rTheGradient)
2164 XFillGradientItem* XFillGradientItem::Clone(SfxItemPool* /*pPool*/) const
2166 return new XFillGradientItem(*this);
2169 bool XFillGradientItem::operator==(const SfxPoolItem& rItem) const
2171 return ( NameOrIndex::operator==(rItem) &&
2172 aGradient == static_cast<const XFillGradientItem&>(rItem).aGradient );
2175 const basegfx::BGradient& XFillGradientItem::GetGradientValue() const // GetValue -> GetGradientValue
2177 if (!IsIndex())
2178 return aGradient;
2179 // ToDo: This should fail. We never called this code with a table so this should always
2180 // have failed. Thus, I'm thinking that XFillGradientItem can't be an Index.
2181 return aGradient;
2184 bool XFillGradientItem::GetPresentation
2186 SfxItemPresentation /*ePres*/,
2187 MapUnit /*eCoreUnit*/,
2188 MapUnit /*ePresUnit*/,
2189 OUString& rText, const IntlWrapper&
2190 ) const
2192 rText = GetName();
2193 return true;
2196 bool XFillGradientItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2198 nMemberId &= ~CONVERT_TWIPS;
2199 switch ( nMemberId )
2201 case 0:
2203 // fill values
2204 const css::awt::Gradient2 aGradient2 = model::gradient::createUnoGradient2(GetGradientValue());
2206 // create sequence
2207 uno::Sequence< beans::PropertyValue > aPropSeq{
2208 comphelper::makePropertyValue("Name", SvxUnogetApiNameForItem(Which(), GetName())),
2209 comphelper::makePropertyValue("FillGradient", aGradient2)
2211 rVal <<= aPropSeq;
2212 break;
2215 case MID_FILLGRADIENT:
2217 // fill values
2218 const css::awt::Gradient2 aGradient2 = model::gradient::createUnoGradient2(GetGradientValue());
2220 // create sequence
2221 rVal <<= aGradient2;
2222 break;
2225 case MID_NAME:
2227 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
2228 break;
2231 case MID_GRADIENT_COLORSTOPSEQUENCE:
2233 // fill values
2234 const css::awt::ColorStopSequence aColorStopSequence = model::gradient::createColorStopSequence(GetGradientValue().GetColorStops());
2236 // create sequence
2237 rVal <<= aColorStopSequence;
2238 break;
2241 case MID_GRADIENT_STYLE: rVal <<= static_cast<sal_Int16>(GetGradientValue().GetGradientStyle()); break;
2242 case MID_GRADIENT_STARTCOLOR: rVal <<= Color(GetGradientValue().GetColorStops().front().getStopColor()); break;
2243 case MID_GRADIENT_ENDCOLOR: rVal <<= Color(GetGradientValue().GetColorStops().back().getStopColor()); break;
2244 case MID_GRADIENT_ANGLE: rVal <<= static_cast<sal_Int16>(GetGradientValue().GetAngle()); break;
2245 case MID_GRADIENT_BORDER: rVal <<= GetGradientValue().GetBorder(); break;
2246 case MID_GRADIENT_XOFFSET: rVal <<= GetGradientValue().GetXOffset(); break;
2247 case MID_GRADIENT_YOFFSET: rVal <<= GetGradientValue().GetYOffset(); break;
2248 case MID_GRADIENT_STARTINTENSITY: rVal <<= GetGradientValue().GetStartIntens(); break;
2249 case MID_GRADIENT_ENDINTENSITY: rVal <<= GetGradientValue().GetEndIntens(); break;
2250 case MID_GRADIENT_STEPCOUNT: rVal <<= GetGradientValue().GetSteps(); break;
2252 default: OSL_FAIL("Wrong MemberId!"); return false;
2255 return true;
2258 bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2260 nMemberId &= ~CONVERT_TWIPS;
2262 switch ( nMemberId )
2264 case 0:
2266 uno::Sequence< beans::PropertyValue > aPropSeq;
2267 css::uno::Any aGradientAny;
2269 if ( rVal >>= aPropSeq )
2271 OUString aName;
2273 for ( const auto& rProp : std::as_const(aPropSeq) )
2275 if ( rProp.Name == "Name" )
2276 rProp.Value >>= aName;
2277 else if ( rProp.Name == "FillGradient" )
2278 aGradientAny = rProp.Value;
2281 SetName( aName );
2283 if (aGradientAny.hasValue() && (aGradientAny.has<css::awt::Gradient>() || aGradientAny.has<css::awt::Gradient2>()))
2285 SetGradientValue(model::gradient::getFromAny(aGradientAny));
2288 return true;
2291 return false;
2294 case MID_NAME:
2296 OUString aName;
2297 if (!(rVal >>= aName ))
2298 return false;
2299 SetName( aName );
2300 break;
2303 case MID_FILLGRADIENT:
2305 if (rVal.hasValue() && (rVal.has<css::awt::Gradient>() || rVal.has<css::awt::Gradient2>()))
2307 SetGradientValue(model::gradient::getFromAny(rVal));
2310 break;
2313 case MID_GRADIENT_COLORSTOPSEQUENCE:
2315 // check if we have a awt::ColorStopSequence
2316 if (rVal.hasValue() && rVal.has<css::awt::ColorStopSequence>())
2319 const basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromAny(rVal);
2321 if (!aColorStops.empty())
2323 basegfx::BGradient aBGradient(GetGradientValue());
2324 aBGradient.SetColorStops(aColorStops);
2325 SetGradientValue(aBGradient);
2328 break;
2331 case MID_GRADIENT_STARTCOLOR:
2332 case MID_GRADIENT_ENDCOLOR:
2334 Color nVal;
2335 if(!(rVal >>= nVal ))
2336 return false;
2338 basegfx::BGradient aBGradient(GetGradientValue());
2339 basegfx::BColorStops aNewColorStops(aBGradient.GetColorStops());
2341 if ( nMemberId == MID_GRADIENT_STARTCOLOR )
2343 aNewColorStops.replaceStartColor(nVal.getBColor());
2345 else
2347 aNewColorStops.replaceEndColor(nVal.getBColor());
2350 aBGradient.SetColorStops(aNewColorStops);
2351 SetGradientValue( aBGradient );
2352 break;
2355 case MID_GRADIENT_STYLE:
2356 case MID_GRADIENT_ANGLE:
2357 case MID_GRADIENT_BORDER:
2358 case MID_GRADIENT_STARTINTENSITY:
2359 case MID_GRADIENT_ENDINTENSITY:
2360 case MID_GRADIENT_STEPCOUNT:
2361 case MID_GRADIENT_XOFFSET:
2362 case MID_GRADIENT_YOFFSET:
2364 sal_Int16 nVal = sal_Int16();
2365 if(!(rVal >>= nVal ))
2366 return false;
2368 basegfx::BGradient aBGradient = GetGradientValue();
2370 switch ( nMemberId )
2372 case MID_GRADIENT_STYLE:
2373 aBGradient.SetGradientStyle( static_cast<css::awt::GradientStyle>(nVal) ); break;
2374 case MID_GRADIENT_ANGLE:
2375 aBGradient.SetAngle( Degree10(nVal) ); break;
2376 case MID_GRADIENT_BORDER:
2377 aBGradient.SetBorder( nVal ); break;
2378 case MID_GRADIENT_STARTINTENSITY:
2379 aBGradient.SetStartIntens( nVal ); break;
2380 case MID_GRADIENT_ENDINTENSITY:
2381 aBGradient.SetEndIntens( nVal ); break;
2382 case MID_GRADIENT_STEPCOUNT:
2383 aBGradient.SetSteps( nVal ); break;
2384 case MID_GRADIENT_XOFFSET:
2385 aBGradient.SetXOffset( nVal ); break;
2386 case MID_GRADIENT_YOFFSET:
2387 aBGradient.SetYOffset( nVal ); break;
2390 SetGradientValue( aBGradient );
2391 break;
2395 return true;
2398 bool XFillGradientItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2400 return static_cast<const XFillGradientItem*>(p1)->GetGradientValue() == static_cast<const XFillGradientItem*>(p2)->GetGradientValue();
2403 std::unique_ptr<XFillGradientItem> XFillGradientItem::checkForUniqueItem( SdrModel* pModel ) const
2405 if( pModel )
2407 const OUString aUniqueName = NameOrIndex::CheckNamedItem(
2408 this, Which(), &pModel->GetItemPool(),
2409 XFillGradientItem::CompareValueFunc, RID_SVXSTR_GRADIENT,
2410 pModel->GetPropertyList( XPropertyListType::Gradient ) );
2412 // if the given name is not valid, replace it!
2413 if( aUniqueName != GetName() )
2414 return std::make_unique<XFillGradientItem>( aUniqueName, aGradient, TypedWhichId<XFillGradientItem>(Which()) );
2417 return nullptr;
2420 boost::property_tree::ptree XFillGradientItem::dumpAsJSON() const
2422 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
2424 if (Which() == XATTR_FILLGRADIENT)
2425 aTree.put("commandName", ".uno:FillGradient");
2427 aTree.push_back(std::make_pair("state", GetGradientValue().dumpAsJSON()));
2429 return aTree;
2433 SfxPoolItem* XFillFloatTransparenceItem::CreateDefault() { return new XFillFloatTransparenceItem; }
2435 XFillFloatTransparenceItem::XFillFloatTransparenceItem() :
2436 bEnabled( false )
2438 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2441 XFillFloatTransparenceItem::XFillFloatTransparenceItem(const OUString& rName, const basegfx::BGradient& rGradient, bool bEnable ) :
2442 XFillGradientItem ( rName, rGradient ),
2443 bEnabled ( bEnable )
2445 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2448 XFillFloatTransparenceItem::XFillFloatTransparenceItem( const XFillFloatTransparenceItem& rItem ) :
2449 XFillGradientItem ( rItem ),
2450 bEnabled ( rItem.bEnabled )
2452 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2455 XFillFloatTransparenceItem::XFillFloatTransparenceItem(const basegfx::BGradient& rTheGradient, bool bEnable )
2456 : XFillGradientItem ( -1, rTheGradient ),
2457 bEnabled ( bEnable )
2459 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2462 bool XFillFloatTransparenceItem::operator==( const SfxPoolItem& rItem ) const
2464 return ( NameOrIndex::operator==(rItem) ) &&
2465 ( GetGradientValue() == static_cast<const XFillGradientItem&>(rItem).GetGradientValue() ) &&
2466 ( bEnabled == static_cast<const XFillFloatTransparenceItem&>(rItem).bEnabled );
2469 XFillFloatTransparenceItem* XFillFloatTransparenceItem::Clone( SfxItemPool* /*pPool*/) const
2471 return new XFillFloatTransparenceItem( *this );
2474 bool XFillFloatTransparenceItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2476 if (MID_GRADIENT_STARTINTENSITY == nMemberId
2477 || MID_GRADIENT_ENDINTENSITY == nMemberId
2478 || MID_GRADIENT_STEPCOUNT == nMemberId)
2480 // tdf#155913 handle attributes not suppoted by transparency gradient as error
2481 return false;
2484 if (!IsEnabled() && nMemberId == MID_NAME)
2486 // make sure that we return empty string in case of query for
2487 // "FillTransparenceGradientName" if the item is disabled
2488 rVal <<= OUString();
2489 return true;
2492 return XFillGradientItem::QueryValue( rVal, nMemberId );
2495 bool XFillFloatTransparenceItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2497 if (MID_GRADIENT_STARTINTENSITY == nMemberId
2498 || MID_GRADIENT_ENDINTENSITY == nMemberId
2499 || MID_GRADIENT_STEPCOUNT == nMemberId)
2501 // tdf#155913 handle attributes not suppoted by transparency gradient as error
2502 return false;
2505 return XFillGradientItem::PutValue( rVal, nMemberId );
2508 bool XFillFloatTransparenceItem::GetPresentation( SfxItemPresentation ePres,
2509 MapUnit eCoreUnit, MapUnit ePresUnit,
2510 OUString& rText,
2511 const IntlWrapper& rIntlWrapper ) const
2513 return XFillGradientItem::GetPresentation( ePres, eCoreUnit, ePresUnit, rText, rIntlWrapper );
2516 bool XFillFloatTransparenceItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2518 return static_cast<const XFillFloatTransparenceItem*>(p1)->IsEnabled() == static_cast<const XFillFloatTransparenceItem*>(p2)->IsEnabled() &&
2519 static_cast<const XFillFloatTransparenceItem*>(p1)->GetGradientValue() == static_cast<const XFillFloatTransparenceItem*>(p2)->GetGradientValue();
2522 std::unique_ptr<XFillFloatTransparenceItem> XFillFloatTransparenceItem::checkForUniqueItem( SdrModel* pModel ) const
2524 // #85953# unique name only necessary when enabled
2525 if(IsEnabled())
2527 if( pModel )
2529 const OUString aUniqueName = NameOrIndex::CheckNamedItem( this,
2530 XATTR_FILLFLOATTRANSPARENCE,
2531 &pModel->GetItemPool(),
2532 XFillFloatTransparenceItem::CompareValueFunc,
2533 RID_SVXSTR_TRASNGR0,
2534 XPropertyListRef() );
2536 // if the given name is not valid, replace it!
2537 if( aUniqueName != GetName() )
2539 return std::make_unique<XFillFloatTransparenceItem>( aUniqueName, GetGradientValue(), true );
2543 else
2545 // #85953# if disabled, force name to empty string
2546 if( !GetName().isEmpty() )
2548 return std::make_unique<XFillFloatTransparenceItem>(OUString(), GetGradientValue(), false);
2552 return nullptr;
2555 boost::property_tree::ptree XFillFloatTransparenceItem::dumpAsJSON() const
2557 boost::property_tree::ptree aTree = XFillGradientItem::dumpAsJSON();
2558 aTree.put("commandName", ".uno:FillFloatTransparence");
2560 if (!bEnabled)
2562 boost::property_tree::ptree& rState = aTree.get_child("state");
2563 // When gradient fill is disabled, the intensity fields contain the
2564 // constant encoded percent-transparency. However we use that here to just
2565 // distinguish between 'None' and 'Solid' types and correct the 'style'
2566 // property appropriately.
2567 if (GetGradientValue().GetStartIntens() == 100)
2568 rState.put("style", "NONE");
2569 else
2570 rState.put("style", "SOLID");
2573 return aTree;
2576 XHatch::XHatch(const Color& rCol, css::drawing::HatchStyle eTheStyle, tools::Long nTheDistance,
2577 Degree10 nTheAngle) :
2578 eStyle(eTheStyle),
2579 aColor(rCol),
2580 nDistance(nTheDistance),
2581 nAngle(nTheAngle)
2585 bool XHatch::operator==(const XHatch& rHatch) const
2587 return ( eStyle == rHatch.eStyle &&
2588 aColor == rHatch.aColor &&
2589 nDistance == rHatch.nDistance &&
2590 nAngle == rHatch.nAngle );
2594 SfxPoolItem* XFillHatchItem::CreateDefault() { return new XFillHatchItem; }
2596 XFillHatchItem::XFillHatchItem(const OUString& rName,
2597 const XHatch& rTheHatch) :
2598 NameOrIndex(XATTR_FILLHATCH, rName),
2599 aHatch(rTheHatch)
2603 XFillHatchItem::XFillHatchItem(const XFillHatchItem& rItem) :
2604 NameOrIndex(rItem),
2605 aHatch(rItem.aHatch)
2609 XFillHatchItem::XFillHatchItem(const XHatch& rTheHatch)
2610 : NameOrIndex( XATTR_FILLHATCH, -1 ),
2611 aHatch(rTheHatch)
2615 XFillHatchItem* XFillHatchItem::Clone(SfxItemPool* /*pPool*/) const
2617 return new XFillHatchItem(*this);
2620 bool XFillHatchItem::operator==(const SfxPoolItem& rItem) const
2622 return ( NameOrIndex::operator==(rItem) &&
2623 aHatch == static_cast<const XFillHatchItem&>(rItem).aHatch );
2626 bool XFillHatchItem::GetPresentation
2628 SfxItemPresentation /*ePres*/,
2629 MapUnit /*eCoreUnit*/,
2630 MapUnit /*ePresUnit*/,
2631 OUString& rText, const IntlWrapper&
2632 ) const
2634 rText = GetName();
2635 return true;
2638 bool XFillHatchItem::HasMetrics() const
2640 return true;
2643 void XFillHatchItem::ScaleMetrics(tools::Long nMul, tools::Long nDiv)
2645 aHatch.SetDistance( BigInt::Scale( aHatch.GetDistance(), nMul, nDiv ) );
2648 bool XFillHatchItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2650 nMemberId &= ~CONVERT_TWIPS;
2652 switch ( nMemberId )
2654 case 0:
2656 css::drawing::Hatch aUnoHatch;
2658 aUnoHatch.Style = aHatch.GetHatchStyle();
2659 aUnoHatch.Color = sal_Int32(aHatch.GetColor());
2660 aUnoHatch.Distance = aHatch.GetDistance();
2661 aUnoHatch.Angle = aHatch.GetAngle().get();
2663 uno::Sequence< beans::PropertyValue > aPropSeq{
2664 comphelper::makePropertyValue("Name", SvxUnogetApiNameForItem(Which(), GetName())),
2665 comphelper::makePropertyValue("FillHatch", aUnoHatch)
2667 rVal <<= aPropSeq;
2668 break;
2671 case MID_FILLHATCH:
2673 css::drawing::Hatch aUnoHatch;
2675 aUnoHatch.Style = aHatch.GetHatchStyle();
2676 aUnoHatch.Color = sal_Int32(aHatch.GetColor());
2677 aUnoHatch.Distance = aHatch.GetDistance();
2678 aUnoHatch.Angle = aHatch.GetAngle().get();
2679 rVal <<= aUnoHatch;
2680 break;
2683 case MID_NAME:
2685 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
2686 break;
2689 case MID_HATCH_STYLE:
2690 rVal <<= aHatch.GetHatchStyle(); break;
2691 case MID_HATCH_COLOR:
2692 rVal <<= aHatch.GetColor(); break;
2693 case MID_HATCH_DISTANCE:
2694 rVal <<= aHatch.GetDistance(); break;
2695 case MID_HATCH_ANGLE:
2696 rVal <<= aHatch.GetAngle().get(); break;
2698 default: OSL_FAIL("Wrong MemberId!"); return false;
2701 return true;
2704 bool XFillHatchItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2706 nMemberId &= ~CONVERT_TWIPS;
2708 switch ( nMemberId )
2710 case 0:
2712 uno::Sequence< beans::PropertyValue > aPropSeq;
2713 if ( rVal >>= aPropSeq )
2715 css::drawing::Hatch aUnoHatch;
2716 OUString aName;
2717 bool bHatch( false );
2718 for ( const auto& rProp : std::as_const(aPropSeq) )
2720 if ( rProp.Name == "Name" )
2721 rProp.Value >>= aName;
2722 else if ( rProp.Name == "FillHatch" )
2724 if ( rProp.Value >>= aUnoHatch )
2725 bHatch = true;
2729 SetName( aName );
2730 if ( bHatch )
2732 aHatch.SetHatchStyle( aUnoHatch.Style );
2733 aHatch.SetColor( Color(ColorTransparency, aUnoHatch.Color) );
2734 aHatch.SetDistance( aUnoHatch.Distance );
2735 aHatch.SetAngle( Degree10(aUnoHatch.Angle) );
2738 return true;
2741 return false;
2744 case MID_FILLHATCH:
2746 css::drawing::Hatch aUnoHatch;
2747 if(!(rVal >>= aUnoHatch))
2748 return false;
2750 aHatch.SetHatchStyle( aUnoHatch.Style );
2751 aHatch.SetColor( Color(ColorTransparency, aUnoHatch.Color) );
2752 aHatch.SetDistance( aUnoHatch.Distance );
2753 aHatch.SetAngle( Degree10(aUnoHatch.Angle) );
2754 break;
2757 case MID_NAME:
2759 OUString aName;
2760 if (!(rVal >>= aName ))
2761 return false;
2762 SetName( aName );
2763 break;
2766 case MID_HATCH_STYLE:
2768 sal_Int16 nVal = sal_Int16();
2769 if (!(rVal >>= nVal ))
2770 return false;
2771 aHatch.SetHatchStyle( static_cast<css::drawing::HatchStyle>(nVal) );
2772 break;
2775 case MID_HATCH_COLOR:
2776 case MID_HATCH_DISTANCE:
2777 case MID_HATCH_ANGLE:
2779 sal_Int32 nVal = 0;
2780 if (!(rVal >>= nVal ))
2781 return false;
2783 if ( nMemberId == MID_HATCH_COLOR )
2784 aHatch.SetColor( Color(ColorTransparency, nVal) );
2785 else if ( nMemberId == MID_HATCH_DISTANCE )
2786 aHatch.SetDistance( nVal );
2787 else
2788 aHatch.SetAngle( Degree10(nVal) );
2789 break;
2792 default: OSL_FAIL("Wrong MemberId!"); return false;
2795 return true;
2798 bool XFillHatchItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2800 return static_cast<const XFillHatchItem*>(p1)->GetHatchValue() == static_cast<const XFillHatchItem*>(p2)->GetHatchValue();
2803 std::unique_ptr<XFillHatchItem> XFillHatchItem::checkForUniqueItem( SdrModel* pModel ) const
2805 if( pModel )
2807 const OUString aUniqueName = NameOrIndex::CheckNamedItem(
2808 this, XATTR_FILLHATCH, &pModel->GetItemPool(),
2809 XFillHatchItem::CompareValueFunc, RID_SVXSTR_HATCH10,
2810 pModel->GetPropertyList( XPropertyListType::Hatch ) );
2812 // if the given name is not valid, replace it!
2813 if( aUniqueName != GetName() )
2814 return std::make_unique<XFillHatchItem>( aUniqueName, aHatch );
2817 return nullptr;
2820 // --- form text attributes ---
2823 SfxPoolItem* XFormTextStyleItem::CreateDefault() { return new XFormTextStyleItem; }
2825 XFormTextStyleItem::XFormTextStyleItem(XFormTextStyle eTheStyle) :
2826 SfxEnumItem(XATTR_FORMTXTSTYLE, eTheStyle)
2830 XFormTextStyleItem* XFormTextStyleItem::Clone(SfxItemPool* /*pPool*/) const
2832 return new XFormTextStyleItem( *this );
2835 sal_uInt16 XFormTextStyleItem::GetValueCount() const
2837 return 5;
2840 bool XFormTextStyleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2842 rVal <<= static_cast<sal_Int32>(GetValue());
2843 return true;
2846 bool XFormTextStyleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2848 sal_Int32 nValue = 0;
2849 rVal >>= nValue;
2850 SetValue(static_cast<XFormTextStyle>(nValue));
2852 return true;
2856 SfxPoolItem* XFormTextAdjustItem::CreateDefault() { return new XFormTextAdjustItem; }
2858 XFormTextAdjustItem::XFormTextAdjustItem(XFormTextAdjust eTheAdjust) :
2859 SfxEnumItem(XATTR_FORMTXTADJUST, eTheAdjust)
2863 XFormTextAdjustItem* XFormTextAdjustItem::Clone(SfxItemPool* /*pPool*/) const
2865 return new XFormTextAdjustItem( *this );
2868 sal_uInt16 XFormTextAdjustItem::GetValueCount() const
2870 return 4;
2873 bool XFormTextAdjustItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2875 rVal <<= static_cast<sal_Int32>(GetValue());
2876 return true;
2879 bool XFormTextAdjustItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2881 sal_Int32 nValue = 0;
2882 rVal >>= nValue;
2883 SetValue(static_cast<XFormTextAdjust>(nValue));
2885 return true;
2889 SfxPoolItem* XFormTextDistanceItem::CreateDefault() { return new XFormTextDistanceItem; }
2891 XFormTextDistanceItem::XFormTextDistanceItem(tools::Long nDist) :
2892 SfxMetricItem(XATTR_FORMTXTDISTANCE, nDist)
2896 XFormTextDistanceItem* XFormTextDistanceItem::Clone(SfxItemPool* /*pPool*/) const
2898 return new XFormTextDistanceItem(*this);
2901 SfxPoolItem* XFormTextStartItem::CreateDefault() { return new XFormTextStartItem; }
2903 XFormTextStartItem::XFormTextStartItem(tools::Long nStart) :
2904 SfxMetricItem(XATTR_FORMTXTSTART, nStart)
2908 XFormTextStartItem* XFormTextStartItem::Clone(SfxItemPool* /*pPool*/) const
2910 return new XFormTextStartItem(*this);
2913 SfxPoolItem* XFormTextMirrorItem::CreateDefault() { return new XFormTextMirrorItem; }
2915 XFormTextMirrorItem::XFormTextMirrorItem(bool bMirror) :
2916 SfxBoolItem(XATTR_FORMTXTMIRROR, bMirror)
2920 XFormTextMirrorItem* XFormTextMirrorItem::Clone(SfxItemPool* /*pPool*/) const
2922 return new XFormTextMirrorItem(*this);
2925 SfxPoolItem* XFormTextOutlineItem::CreateDefault() { return new XFormTextOutlineItem; }
2927 XFormTextOutlineItem::XFormTextOutlineItem(bool bOutline) :
2928 SfxBoolItem(XATTR_FORMTXTOUTLINE, bOutline)
2932 XFormTextOutlineItem* XFormTextOutlineItem::Clone(SfxItemPool* /*pPool*/) const
2934 return new XFormTextOutlineItem(*this);
2937 SfxPoolItem* XFormTextShadowItem::CreateDefault() { return new XFormTextShadowItem; }
2939 XFormTextShadowItem::XFormTextShadowItem(XFormTextShadow eFormTextShadow) :
2940 SfxEnumItem(XATTR_FORMTXTSHADOW, eFormTextShadow)
2944 XFormTextShadowItem* XFormTextShadowItem::Clone(SfxItemPool* /*pPool*/) const
2946 return new XFormTextShadowItem( *this );
2949 sal_uInt16 XFormTextShadowItem::GetValueCount() const
2951 return 3;
2954 bool XFormTextShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2956 rVal <<= static_cast<sal_Int32>(GetValue());
2957 return true;
2960 bool XFormTextShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2962 sal_Int32 nValue = 0;
2963 rVal >>= nValue;
2964 SetValue(static_cast<XFormTextShadow>(nValue));
2966 return true;
2970 SfxPoolItem* XFormTextShadowColorItem::CreateDefault() { return new XFormTextShadowColorItem; }
2972 XFormTextShadowColorItem::XFormTextShadowColorItem(const OUString& rName,
2973 const Color& rTheColor) :
2974 XColorItem(XATTR_FORMTXTSHDWCOLOR, rName, rTheColor)
2978 XFormTextShadowColorItem* XFormTextShadowColorItem::Clone(SfxItemPool* /*pPool*/) const
2980 return new XFormTextShadowColorItem(*this);
2983 SfxPoolItem* XFormTextShadowXValItem::CreateDefault() { return new XFormTextShadowXValItem; }
2985 XFormTextShadowXValItem::XFormTextShadowXValItem(tools::Long nVal) :
2986 SfxMetricItem(XATTR_FORMTXTSHDWXVAL, nVal)
2990 XFormTextShadowXValItem* XFormTextShadowXValItem::Clone(SfxItemPool* /*pPool*/) const
2992 return new XFormTextShadowXValItem(*this);
2995 SfxPoolItem* XFormTextShadowYValItem::CreateDefault() { return new XFormTextShadowYValItem; }
2997 XFormTextShadowYValItem::XFormTextShadowYValItem(tools::Long nVal) :
2998 SfxMetricItem(XATTR_FORMTXTSHDWYVAL, nVal)
3002 XFormTextShadowYValItem* XFormTextShadowYValItem::Clone(SfxItemPool* /*pPool*/) const
3004 return new XFormTextShadowYValItem(*this);
3007 SfxPoolItem* XFormTextHideFormItem::CreateDefault() { return new XFormTextHideFormItem; }
3009 XFormTextHideFormItem::XFormTextHideFormItem(bool bHide) :
3010 SfxBoolItem(XATTR_FORMTXTHIDEFORM, bHide)
3014 XFormTextHideFormItem* XFormTextHideFormItem::Clone(SfxItemPool* /*pPool*/) const
3016 return new XFormTextHideFormItem(*this);
3019 // --- SetItems ---
3022 /// a line attribute set item
3023 XLineAttrSetItem::XLineAttrSetItem( SfxItemSet&& pItemSet ) :
3024 SfxSetItem( XATTRSET_LINE, std::move(pItemSet))
3028 XLineAttrSetItem::XLineAttrSetItem( SfxItemPool* pItemPool ) :
3029 SfxSetItem( XATTRSET_LINE,
3030 SfxItemSetFixed<XATTR_LINE_FIRST, XATTR_LINE_LAST>( *pItemPool ))
3034 XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr ) :
3035 SfxSetItem( rLineAttr )
3039 XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr,
3040 SfxItemPool* pItemPool) :
3041 SfxSetItem( rLineAttr, pItemPool )
3045 XLineAttrSetItem* XLineAttrSetItem::Clone( SfxItemPool* pPool ) const
3047 return new XLineAttrSetItem( *this, pPool );
3050 /// fill attribute set item
3051 XFillAttrSetItem::XFillAttrSetItem( SfxItemSet&& pItemSet ) :
3052 SfxSetItem( XATTRSET_FILL, std::move(pItemSet))
3056 XFillAttrSetItem::XFillAttrSetItem( SfxItemPool* pItemPool ) :
3057 SfxSetItem( XATTRSET_FILL,
3058 SfxItemSetFixed<XATTR_FILL_FIRST, XATTR_FILL_LAST>( *pItemPool ))
3062 XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr ) :
3063 SfxSetItem( rFillAttr )
3067 XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr,
3068 SfxItemPool* pItemPool ) :
3069 SfxSetItem( rFillAttr, pItemPool )
3073 XFillAttrSetItem* XFillAttrSetItem::Clone( SfxItemPool* pPool ) const
3075 return new XFillAttrSetItem( *this, pPool );
3078 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */