Prepare for removal of non-const operator[] from Sequence in svx
[LibreOffice.git] / svx / source / xoutdev / xattr.cxx
blob2fcb40379b65aae75cd76f617dde11b200330aae
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/Gradient.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/any.hxx>
36 #include <svl/itempool.hxx>
37 #include <editeng/memberids.h>
38 #include <tools/mapunit.hxx>
39 #include <tools/UnitConversion.hxx>
40 #include <osl/diagnose.h>
42 #include <svx/unoapi.hxx>
43 #include <svl/style.hxx>
45 #include <tools/bigint.hxx>
46 #include <svl/itemset.hxx>
47 #include <svx/strings.hrc>
48 #include <svx/xfillit0.hxx>
49 #include <svx/xflasit.hxx>
50 #include <svx/xlineit0.hxx>
51 #include <svx/xlnasit.hxx>
52 #include <svx/xtextit0.hxx>
53 #include <svx/xtable.hxx>
54 #include <svx/dialmgr.hxx>
55 #include <svx/xflclit.hxx>
56 #include <svx/xflgrit.hxx>
57 #include <svx/xflftrit.hxx>
58 #include <svx/xsflclit.hxx>
59 #include <svx/xflhtit.hxx>
60 #include <svx/xbtmpit.hxx>
61 #include <svx/xlndsit.hxx>
62 #include <svx/xlnwtit.hxx>
63 #include <svx/xlnclit.hxx>
64 #include <svx/xlnstit.hxx>
65 #include <svx/xlnedit.hxx>
66 #include <svx/xlnstwit.hxx>
67 #include <svx/xlnedwit.hxx>
68 #include <svx/xlnstcit.hxx>
69 #include <svx/xlnedcit.hxx>
70 #include <editeng/itemtype.hxx>
71 #include <editeng/eerdll.hxx>
72 #include <svx/xdef.hxx>
73 #include <svx/unomid.hxx>
74 #include <svx/svdmodel.hxx>
75 #include <svx/xftdiit.hxx>
76 #include <svx/xftstit.hxx>
77 #include <svx/xftmrit.hxx>
78 #include <svx/xftouit.hxx>
79 #include <svx/xftshit.hxx>
80 #include <svx/xftshcit.hxx>
81 #include <svx/xftshxy.hxx>
82 #include <svx/xftadit.hxx>
83 #include <svx/svddef.hxx>
84 #include <basegfx/polygon/b2dpolypolygontools.hxx>
85 #include <unotools/intlwrapper.hxx>
86 #include <unotools/syslocale.hxx>
87 #include <string>
89 #include <boost/property_tree/json_parser.hpp>
90 #include <libxml/xmlwriter.h>
92 using namespace ::com::sun::star;
94 typedef std::map<OUString, OUString> StringMap;
96 NameOrIndex::NameOrIndex(sal_uInt16 _nWhich, sal_Int32 nIndex) :
97 SfxStringItem(_nWhich, OUString()),
98 nPalIndex(nIndex)
102 NameOrIndex::NameOrIndex(sal_uInt16 _nWhich, const OUString& rName) :
103 SfxStringItem(_nWhich, rName),
104 nPalIndex(-1)
108 NameOrIndex::NameOrIndex(const NameOrIndex& rNameOrIndex) :
109 SfxStringItem(rNameOrIndex),
110 nPalIndex(rNameOrIndex.nPalIndex)
114 bool NameOrIndex::operator==(const SfxPoolItem& rItem) const
116 return ( SfxStringItem::operator==(rItem) &&
117 static_cast<const NameOrIndex&>(rItem).nPalIndex == nPalIndex );
120 NameOrIndex* NameOrIndex::Clone(SfxItemPool* /*pPool*/) const
122 return new NameOrIndex(*this);
125 /** this static checks if the given NameOrIndex item has a unique name for its value.
126 The returned String is a unique name for an item with this value in both given pools.
127 Argument pPool2 can be null.
128 If returned string equals NameOrIndex->GetName(), the name was already unique.
130 OUString NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_uInt16 nWhich, const SfxItemPool* pPool1, SvxCompareValueFunc pCompareValueFunc, TranslateId pPrefixResId, const XPropertyListRef &pDefaults )
132 bool bForceNew = false;
134 OUString aUniqueName = SvxUnogetInternalNameForItem(nWhich, pCheckItem->GetName());
136 // 2. if we have a name check if there is already an item with the
137 // same name in the documents pool with a different line end or start
139 if (!aUniqueName.isEmpty() && pPool1)
141 for (const SfxPoolItem* pItem : pPool1->GetItemSurrogates(nWhich))
143 const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
145 if( pNameOrIndex->GetName() == pCheckItem->GetName() )
147 // if there is already an item with the same name and the same
148 // value it's ok to set it
149 if( !pCompareValueFunc( pNameOrIndex, pCheckItem ) )
151 // same name but different value, we need a new name for this item
152 aUniqueName.clear();
153 bForceNew = true;
155 break;
160 // if we have no name yet, find existing item with same content or
161 // create a unique name
162 if (aUniqueName.isEmpty())
164 sal_Int32 nUserIndex = 1;
165 const OUString aUser(SvxResId(pPrefixResId) + " ");
167 if( pDefaults )
169 const int nCount = pDefaults->Count();
170 int nIndex;
171 for( nIndex = 0; nIndex < nCount; nIndex++ )
173 const XPropertyEntry* pEntry = pDefaults->Get(nIndex);
174 if( pEntry )
176 bool bFound = false;
178 switch( nWhich )
180 case XATTR_FILLBITMAP:
182 const GraphicObject& rGraphicObjectA(static_cast<const XFillBitmapItem*>(pCheckItem)->GetGraphicObject());
183 const GraphicObject& rGraphicObjectB(static_cast<const XBitmapEntry*>(pEntry)->GetGraphicObject());
185 bFound = (rGraphicObjectA == rGraphicObjectB);
186 break;
188 case XATTR_LINEDASH:
189 bFound = static_cast<const XLineDashItem*>(pCheckItem)->GetDashValue() == static_cast<const XDashEntry*>(pEntry)->GetDash();
190 break;
191 case XATTR_LINESTART:
192 bFound = static_cast<const XLineStartItem*>(pCheckItem)->GetLineStartValue() == static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd();
193 break;
194 case XATTR_LINEEND:
195 bFound = static_cast<const XLineEndItem*>(pCheckItem)->GetLineEndValue() == static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd();
196 break;
197 case XATTR_FILLGRADIENT:
198 bFound = static_cast<const XFillGradientItem*>(pCheckItem)->GetGradientValue() == static_cast<const XGradientEntry*>(pEntry)->GetGradient();
199 break;
200 case XATTR_FILLHATCH:
201 bFound = static_cast<const XFillHatchItem*>(pCheckItem)->GetHatchValue() == static_cast<const XHatchEntry*>(pEntry)->GetHatch();
202 break;
205 if( bFound )
207 aUniqueName = pEntry->GetName();
208 break;
210 else
212 const OUString& aEntryName = pEntry->GetName();
213 if(aEntryName.getLength() >= aUser.getLength())
215 sal_Int32 nThisIndex = aEntryName.copy( aUser.getLength() ).toInt32();
216 if( nThisIndex >= nUserIndex )
217 nUserIndex = nThisIndex + 1;
224 if (aUniqueName.isEmpty() && pPool1)
226 for (const SfxPoolItem* pItem : pPool1->GetItemSurrogates(nWhich))
228 const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
230 if( !pNameOrIndex->GetName().isEmpty() )
232 if( !bForceNew && pCompareValueFunc( pNameOrIndex, pCheckItem ) )
233 return pNameOrIndex->GetName();
235 if( pNameOrIndex->GetName().startsWith( aUser ) )
237 sal_Int32 nThisIndex = pNameOrIndex->GetName().copy( aUser.getLength() ).toInt32();
238 if( nThisIndex >= nUserIndex )
239 nUserIndex = nThisIndex + 1;
243 aUniqueName = aUser + OUString::number( nUserIndex );
247 return aUniqueName;
250 void NameOrIndex::dumpAsXml(xmlTextWriterPtr pWriter) const
252 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("NameOrIndex"));
253 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
254 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("isIndex"), BAD_CAST(OString::boolean(IsIndex()).getStr()));
255 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(GetName().toUtf8().getStr()));
256 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("index"), BAD_CAST(OString::number(nPalIndex).getStr()));
257 (void)xmlTextWriterEndElement(pWriter);
260 SfxPoolItem* XColorItem::CreateDefault() { return new XColorItem; }
262 XColorItem::XColorItem(sal_uInt16 _nWhich, sal_Int32 nIndex, const Color& rTheColor) :
263 NameOrIndex(_nWhich, nIndex),
264 aColor(rTheColor)
268 XColorItem::XColorItem(sal_uInt16 _nWhich, const OUString& rName, const Color& rTheColor) :
269 NameOrIndex(_nWhich, rName),
270 aColor(rTheColor)
274 XColorItem::XColorItem(sal_uInt16 _nWhich, const Color& rTheColor)
275 : NameOrIndex(_nWhich, OUString())
276 , aColor(rTheColor)
280 XColorItem::XColorItem(const XColorItem& rItem) :
281 NameOrIndex(rItem),
282 aColor(rItem.aColor)
286 XColorItem* XColorItem::Clone(SfxItemPool* /*pPool*/) const
288 return new XColorItem(*this);
291 bool XColorItem::operator==(const SfxPoolItem& rItem) const
293 return ( NameOrIndex::operator==(rItem) &&
294 static_cast<const XColorItem&>(rItem).aColor == aColor );
297 const Color& XColorItem::GetColorValue() const
299 assert(!IsIndex());
300 return aColor;
304 bool XColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
306 rVal <<= GetColorValue().GetRGBColor();
307 return true;
310 bool XColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
312 Color nValue;
313 rVal >>= nValue;
314 SetColorValue( nValue );
316 return true;
319 void XColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
321 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XColorItem"));
322 if (Which() == SDRATTR_SHADOWCOLOR)
324 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("SDRATTR_SHADOWCOLOR"));
326 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("aColor"),
327 BAD_CAST(aColor.AsRGBHexString().toUtf8().getStr()));
329 NameOrIndex::dumpAsXml(pWriter);
331 (void)xmlTextWriterEndElement(pWriter);
334 // --- line attributes ---
337 SfxPoolItem* XLineStyleItem::CreateDefault() { return new XLineStyleItem; }
339 XLineStyleItem::XLineStyleItem(css::drawing::LineStyle eTheLineStyle) :
340 SfxEnumItem(XATTR_LINESTYLE, eTheLineStyle)
344 XLineStyleItem* XLineStyleItem::Clone(SfxItemPool* /*pPool*/) const
346 return new XLineStyleItem( *this );
349 bool XLineStyleItem::GetPresentation
351 SfxItemPresentation /*ePres*/,
352 MapUnit /*eCoreUnit*/,
353 MapUnit /*ePresUnit*/,
354 OUString& rText, const IntlWrapper&
355 ) const
357 rText.clear();
359 TranslateId pId;
361 switch( GetValue() )
363 case css::drawing::LineStyle_NONE:
364 pId = RID_SVXSTR_INVISIBLE;
365 break;
366 case css::drawing::LineStyle_SOLID:
367 pId = RID_SVXSTR_SOLID;
368 break;
369 default: break;
372 if (pId)
373 rText = SvxResId(pId);
374 return true;
377 bool XLineStyleItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
379 css::drawing::LineStyle eLS = GetValue();
380 rVal <<= eLS;
381 return true;
384 bool XLineStyleItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
386 css::drawing::LineStyle eLS;
387 if(!(rVal >>= eLS ))
389 // also try an int (for Basic)
390 sal_Int32 nLS = 0;
391 if(!(rVal >>= nLS))
392 return false;
393 eLS = static_cast<css::drawing::LineStyle>(nLS);
396 SetValue( eLS );
397 return true;
400 sal_uInt16 XLineStyleItem::GetValueCount() const
402 return 3;
405 XDash::XDash(css::drawing::DashStyle eTheDash, sal_uInt16 nTheDots, double nTheDotLen,
406 sal_uInt16 nTheDashes, double nTheDashLen, double nTheDistance) :
407 eDash(eTheDash),
408 nDots(nTheDots),
409 nDashes(nTheDashes),
410 nDotLen(nTheDotLen),
411 nDashLen(nTheDashLen),
412 nDistance(nTheDistance)
416 bool XDash::operator==(const XDash& rDash) const
418 return ( eDash == rDash.eDash &&
419 nDots == rDash.nDots &&
420 nDotLen == rDash.nDotLen &&
421 nDashes == rDash.nDashes &&
422 nDashLen == rDash.nDashLen &&
423 nDistance == rDash.nDistance );
426 // XDash is translated into an array of doubles which describe the lengths of the
427 // dashes, dots and empty passages. It returns the complete length of the full DashDot
428 // sequence and fills the given vetor of doubles accordingly (also resizing, so deleting it).
429 const double SMALLEST_DASH_WIDTH(26.95);
431 double XDash::CreateDotDashArray(::std::vector< double >& rDotDashArray, double fLineWidth) const
433 double fFullDotDashLen(0.0);
434 const sal_uInt16 nNumDotDashArray = (GetDots() + GetDashes()) * 2;
435 rDotDashArray.resize( nNumDotDashArray, 0.0 );
436 sal_uInt16 a;
437 sal_uInt16 nIns(0);
438 double fDashDotDistance = GetDistance();
439 double fSingleDashLen = GetDashLen();
440 double fSingleDotLen = GetDotLen();
442 if (fLineWidth == 0.0)
443 fLineWidth = SMALLEST_DASH_WIDTH;
445 if(GetDashStyle() == css::drawing::DashStyle_RECTRELATIVE || GetDashStyle() == css::drawing::DashStyle_ROUNDRELATIVE)
447 double fFactor = fLineWidth / 100.0;
449 if(GetDashes())
451 if(GetDashLen())
453 // is a dash
454 fSingleDashLen *= fFactor;
456 else
458 // is a dot
459 fSingleDashLen = fLineWidth;
463 if(GetDots())
465 if(GetDotLen())
467 // is a dash
468 fSingleDotLen *= fFactor;
470 else
472 // is a dot
473 fSingleDotLen = fLineWidth;
477 if(GetDashes() || GetDots())
479 if(GetDistance())
481 // dash as distance
482 fDashDotDistance *= fFactor;
484 else
486 // dot as distance
487 fDashDotDistance = fLineWidth;
491 else
493 // absolute values
494 if(GetDashes())
496 if(GetDashLen())
498 // is a dash
499 if(fSingleDashLen < SMALLEST_DASH_WIDTH)
501 fSingleDashLen = SMALLEST_DASH_WIDTH;
504 else
506 // is a dot
507 if(fSingleDashLen < fLineWidth)
509 fSingleDashLen = fLineWidth;
514 if(GetDots())
516 if(GetDotLen())
518 // is a dash
519 if(fSingleDotLen < SMALLEST_DASH_WIDTH)
521 fSingleDotLen = SMALLEST_DASH_WIDTH;
524 else
526 // is a dot
527 if(fSingleDotLen < fLineWidth)
529 fSingleDotLen = fLineWidth;
534 if(GetDashes() || GetDots())
536 if(GetDistance())
538 // dash as distance
539 if(fDashDotDistance < SMALLEST_DASH_WIDTH)
541 fDashDotDistance = SMALLEST_DASH_WIDTH;
544 else
546 // dot as distance
547 if(fDashDotDistance < fLineWidth)
549 fDashDotDistance = fLineWidth;
555 for(a=0;a<GetDots();a++)
557 rDotDashArray[nIns++] = fSingleDotLen;
558 fFullDotDashLen += fSingleDotLen;
559 rDotDashArray[nIns++] = fDashDotDistance;
560 fFullDotDashLen += fDashDotDistance;
563 for(a=0;a<GetDashes();a++)
565 rDotDashArray[nIns++] = fSingleDashLen;
566 fFullDotDashLen += fSingleDashLen;
567 rDotDashArray[nIns++] = fDashDotDistance;
568 fFullDotDashLen += fDashDotDistance;
571 return fFullDotDashLen;
574 SfxPoolItem* XLineDashItem::CreateDefault() {return new XLineDashItem;}
576 XLineDashItem::XLineDashItem(const OUString& rName, const XDash& rTheDash) :
577 NameOrIndex(XATTR_LINEDASH, rName),
578 aDash(rTheDash)
582 XLineDashItem::XLineDashItem(const XLineDashItem& rItem) :
583 NameOrIndex(rItem),
584 aDash(rItem.aDash)
588 XLineDashItem::XLineDashItem(const XDash& rTheDash)
589 : NameOrIndex( XATTR_LINEDASH, -1 ),
590 aDash(rTheDash)
594 XLineDashItem* XLineDashItem::Clone(SfxItemPool* /*pPool*/) const
596 return new XLineDashItem(*this);
599 bool XLineDashItem::operator==(const SfxPoolItem& rItem) const
601 return ( NameOrIndex::operator==(rItem) &&
602 aDash == static_cast<const XLineDashItem&>(rItem).aDash );
605 bool XLineDashItem::GetPresentation
607 SfxItemPresentation /*ePres*/,
608 MapUnit /*eCoreUnit*/,
609 MapUnit /*ePresUnit*/,
610 OUString& rText, const IntlWrapper&
611 ) const
613 rText = GetName();
614 return true;
617 bool XLineDashItem::HasMetrics() const
619 return true;
622 void XLineDashItem::ScaleMetrics(tools::Long nMul, tools::Long nDiv)
624 aDash.SetDotLen( BigInt::Scale( aDash.GetDotLen(), nMul, nDiv ) );
625 aDash.SetDashLen( BigInt::Scale( aDash.GetDashLen(), nMul, nDiv ) );
626 aDash.SetDistance( BigInt::Scale( aDash.GetDistance(), nMul, nDiv ) );
629 bool XLineDashItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
631 nMemberId &= ~CONVERT_TWIPS;
633 switch ( nMemberId )
635 case 0:
637 css::drawing::LineDash aLineDash;
639 const XDash& rXD = GetDashValue();
640 aLineDash.Style = static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(rXD.GetDashStyle()));
641 aLineDash.Dots = rXD.GetDots();
642 aLineDash.DotLen = rXD.GetDotLen();
643 aLineDash.Dashes = rXD.GetDashes();
644 aLineDash.DashLen = rXD.GetDashLen();
645 aLineDash.Distance = rXD.GetDistance();
647 uno::Sequence< beans::PropertyValue > aPropSeq{
648 comphelper::makePropertyValue("Name", SvxUnogetApiNameForItem(Which(), GetName())),
649 comphelper::makePropertyValue("LineDash", aLineDash)
651 rVal <<= aPropSeq;
652 break;
655 case MID_NAME:
657 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
658 break;
661 case MID_LINEDASH:
663 const XDash& rXD = GetDashValue();
665 css::drawing::LineDash aLineDash;
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 rVal <<= aLineDash;
675 break;
678 case MID_LINEDASH_STYLE:
680 const XDash& rXD = GetDashValue();
681 rVal <<= static_cast<css::drawing::DashStyle>(static_cast<sal_Int16>(rXD.GetDashStyle()));
682 break;
685 case MID_LINEDASH_DOTS:
687 const XDash& rXD = GetDashValue();
688 rVal <<= rXD.GetDots();
689 break;
692 case MID_LINEDASH_DOTLEN:
694 const XDash& rXD = GetDashValue();
695 rVal <<= rXD.GetDotLen();
696 break;
699 case MID_LINEDASH_DASHES:
701 const XDash& rXD = GetDashValue();
702 rVal <<= rXD.GetDashes();
703 break;
706 case MID_LINEDASH_DASHLEN:
708 const XDash& rXD = GetDashValue();
709 rVal <<= rXD.GetDashLen();
710 break;
713 case MID_LINEDASH_DISTANCE:
715 const XDash& rXD = GetDashValue();
716 rVal <<= rXD.GetDistance();
717 break;
720 default: OSL_FAIL("Wrong MemberId!"); return false;
723 return true;
726 bool XLineDashItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
728 nMemberId &= ~CONVERT_TWIPS;
730 switch ( nMemberId )
732 case 0:
734 uno::Sequence< beans::PropertyValue > aPropSeq;
736 if ( rVal >>= aPropSeq )
738 css::drawing::LineDash aLineDash;
739 OUString aName;
740 bool bLineDash( false );
741 for ( const auto& rProp : std::as_const(aPropSeq) )
743 if ( rProp.Name == "Name" )
744 rProp.Value >>= aName;
745 else if ( rProp.Name == "LineDash" )
747 if ( rProp.Value >>= aLineDash )
748 bLineDash = true;
752 SetName( aName );
753 if ( bLineDash )
755 XDash aXDash;
757 aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(aLineDash.Style)));
758 aXDash.SetDots(aLineDash.Dots);
759 aXDash.SetDotLen(aLineDash.DotLen);
760 aXDash.SetDashes(aLineDash.Dashes);
761 aXDash.SetDashLen(aLineDash.DashLen);
762 aXDash.SetDistance(aLineDash.Distance);
764 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
765 aXDash.SetDots(1);
767 SetDashValue( aXDash );
770 return true;
773 return false;
776 case MID_NAME:
778 OUString aName;
779 if (!(rVal >>= aName))
780 return false;
781 SetName( aName );
782 break;
785 case MID_LINEDASH:
787 css::drawing::LineDash aLineDash;
788 if(!(rVal >>= aLineDash))
789 return false;
791 XDash aXDash;
793 aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(aLineDash.Style)));
794 aXDash.SetDots(aLineDash.Dots);
795 aXDash.SetDotLen(aLineDash.DotLen);
796 aXDash.SetDashes(aLineDash.Dashes);
797 aXDash.SetDashLen(aLineDash.DashLen);
798 aXDash.SetDistance(aLineDash.Distance);
800 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
801 aXDash.SetDots(1);
803 SetDashValue( aXDash );
804 break;
807 case MID_LINEDASH_STYLE:
809 sal_Int16 nVal = sal_Int16();
810 if(!(rVal >>= nVal))
811 return false;
813 XDash aXDash = GetDashValue();
814 aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(nVal)));
816 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
817 aXDash.SetDots(1);
819 SetDashValue( aXDash );
821 break;
824 case MID_LINEDASH_DOTS:
825 case MID_LINEDASH_DASHES:
827 sal_Int16 nVal = sal_Int16();
828 if(!(rVal >>= nVal))
829 return false;
831 XDash aXDash = GetDashValue();
832 if ( nMemberId == MID_LINEDASH_DOTS )
833 aXDash.SetDots( nVal );
834 else
835 aXDash.SetDashes( nVal );
837 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
838 aXDash.SetDots(1);
840 SetDashValue( aXDash );
841 break;
844 case MID_LINEDASH_DOTLEN:
845 case MID_LINEDASH_DASHLEN:
846 case MID_LINEDASH_DISTANCE:
848 sal_uInt32 nVal = 0;
849 if(!(rVal >>= nVal))
850 return false;
852 XDash aXDash = GetDashValue();
853 if ( nMemberId == MID_LINEDASH_DOTLEN )
854 aXDash.SetDotLen( nVal );
855 else if ( nMemberId == MID_LINEDASH_DASHLEN )
856 aXDash.SetDashLen( nVal );
857 else
858 aXDash.SetDistance( nVal );
860 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
861 aXDash.SetDots(1);
863 SetDashValue( aXDash );
864 break;
868 return true;
871 bool XLineDashItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
873 return static_cast<const XLineDashItem*>(p1)->GetDashValue() == static_cast<const XLineDashItem*>(p2)->GetDashValue();
876 std::unique_ptr<XLineDashItem> XLineDashItem::checkForUniqueItem( SdrModel* pModel ) const
878 if( pModel )
880 const OUString aUniqueName = NameOrIndex::CheckNamedItem(
881 this, XATTR_LINEDASH, &pModel->GetItemPool(),
882 XLineDashItem::CompareValueFunc, RID_SVXSTR_DASH20,
883 pModel->GetPropertyList( XPropertyListType::Dash ) );
885 // if the given name is not valid, replace it!
886 if( aUniqueName != GetName() )
887 return std::make_unique<XLineDashItem>( aUniqueName, aDash );
890 return nullptr;
893 SfxPoolItem* XLineWidthItem::CreateDefault() {return new XLineWidthItem;}
895 XLineWidthItem::XLineWidthItem(tools::Long nWidth) :
896 SfxMetricItem(XATTR_LINEWIDTH, nWidth)
900 XLineWidthItem* XLineWidthItem::Clone(SfxItemPool* /*pPool*/) const
902 return new XLineWidthItem(*this);
905 bool XLineWidthItem::GetPresentation
907 SfxItemPresentation /*ePres*/,
908 MapUnit eCoreUnit,
909 MapUnit ePresUnit,
910 OUString& rText, const IntlWrapper& rIntl
911 ) const
913 rText = GetMetricText( static_cast<tools::Long>(GetValue()),
914 eCoreUnit, ePresUnit, &rIntl) +
915 " " + EditResId( GetMetricId( ePresUnit) );
916 return true;
919 bool XLineWidthItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
921 sal_Int32 nValue = GetValue();
922 if( 0 != (nMemberId&CONVERT_TWIPS) )
923 nValue = convertTwipToMm100(nValue);
925 rVal <<= nValue;
926 return true;
929 bool XLineWidthItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
931 sal_Int32 nValue = 0;
932 rVal >>= nValue;
933 if( 0 != (nMemberId&CONVERT_TWIPS) )
934 nValue = o3tl::toTwips(nValue, o3tl::Length::mm100);
936 SetValue( nValue );
937 return true;
940 SfxPoolItem* XLineColorItem::CreateDefault() { return new XLineColorItem; }
942 XLineColorItem::XLineColorItem(sal_Int32 nIndex, const Color& rTheColor) :
943 XColorItem(XATTR_LINECOLOR, nIndex, rTheColor)
947 XLineColorItem::XLineColorItem(const OUString& rName, const Color& rTheColor) :
948 XColorItem(XATTR_LINECOLOR, rName, rTheColor)
952 XLineColorItem* XLineColorItem::Clone(SfxItemPool* /*pPool*/) const
954 return new XLineColorItem(*this);
957 bool XLineColorItem::GetPresentation
959 SfxItemPresentation /*ePres*/,
960 MapUnit /*eCoreUnit*/,
961 MapUnit /*ePresUnit*/,
962 OUString& rText, const IntlWrapper&
963 ) const
965 rText = GetName();
966 return true;
969 bool XLineColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
971 rVal <<= GetColorValue().GetRGBColor();
972 return true;
975 bool XLineColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
977 sal_Int32 nValue = 0;
978 if(!(rVal >>= nValue))
979 return false;
981 SetColorValue( Color(ColorTransparency, nValue) );
982 return true;
986 SfxPoolItem* XLineStartItem::CreateDefault() {return new XLineStartItem;}
988 XLineStartItem::XLineStartItem(sal_Int32 nIndex)
989 : NameOrIndex(XATTR_LINESTART, nIndex)
993 XLineStartItem::XLineStartItem(const OUString& rName, const basegfx::B2DPolyPolygon& rPolyPolygon)
994 : NameOrIndex(XATTR_LINESTART, rName),
995 maPolyPolygon(rPolyPolygon)
999 XLineStartItem::XLineStartItem(const XLineStartItem& rItem)
1000 : NameOrIndex(rItem),
1001 maPolyPolygon(rItem.maPolyPolygon)
1005 XLineStartItem::XLineStartItem(const basegfx::B2DPolyPolygon& rPolyPolygon)
1006 : NameOrIndex( XATTR_LINESTART, -1 ),
1007 maPolyPolygon(rPolyPolygon)
1011 XLineStartItem* XLineStartItem::Clone(SfxItemPool* /*pPool*/) const
1013 return new XLineStartItem(*this);
1016 bool XLineStartItem::operator==(const SfxPoolItem& rItem) const
1018 return ( NameOrIndex::operator==(rItem) && static_cast<const XLineStartItem&>(rItem).maPolyPolygon == maPolyPolygon );
1021 bool XLineStartItem::GetPresentation
1023 SfxItemPresentation /*ePres*/,
1024 MapUnit /*eCoreUnit*/,
1025 MapUnit /*ePresUnit*/,
1026 OUString& rText, const IntlWrapper&
1027 ) const
1029 rText = GetName();
1030 return true;
1033 bool XLineStartItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
1035 nMemberId &= ~CONVERT_TWIPS;
1036 if( nMemberId == MID_NAME )
1038 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
1040 else
1042 css::drawing::PolyPolygonBezierCoords aBezier;
1043 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( maPolyPolygon, aBezier );
1044 rVal <<= aBezier;
1047 return true;
1050 bool XLineStartItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
1052 nMemberId &= ~CONVERT_TWIPS;
1053 if( nMemberId == MID_NAME )
1055 return false;
1057 else
1059 maPolyPolygon.clear();
1061 if( rVal.hasValue() )
1063 auto pCoords = o3tl::tryAccess<css::drawing::PolyPolygonBezierCoords>(
1064 rVal);
1065 if( !pCoords )
1066 return false;
1068 if( pCoords->Coordinates.getLength() > 0 )
1070 maPolyPolygon = basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( *pCoords );
1071 // #i72807# close line start/end polygons hard
1072 // maPolyPolygon.setClosed(true);
1077 return true;
1080 /** this function searches in both the models pool and the styles pool for XLineStartItem
1081 and XLineEndItem with the same value or name and returns an item with the value of
1082 this item and a unique name for an item with this value. */
1083 std::unique_ptr<XLineStartItem> XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const
1085 if( pModel )
1087 std::unique_ptr<XLineStartItem> pTempItem;
1088 const XLineStartItem* pLineStartItem = this;
1090 OUString aUniqueName( GetName() );
1092 if( !maPolyPolygon.count() )
1094 // if the polygon is empty, check if the name is empty
1095 if( aUniqueName.isEmpty() )
1096 return nullptr;
1098 // force empty name for empty polygons
1099 return std::make_unique<XLineStartItem>( "", maPolyPolygon );
1102 if( maPolyPolygon.count() > 1 )
1104 // check if the polygon is closed
1105 if(!maPolyPolygon.isClosed())
1107 // force a closed polygon
1108 basegfx::B2DPolyPolygon aNew(maPolyPolygon);
1109 aNew.setClosed(true);
1110 pTempItem.reset(new XLineStartItem( aUniqueName, aNew ));
1111 pLineStartItem = pTempItem.get();
1115 bool bForceNew = false;
1117 // 2. if we have a name check if there is already an item with the
1118 // same name in the documents pool with a different line end or start
1120 const SfxItemPool& rPool1 = pModel->GetItemPool();
1121 if (!aUniqueName.isEmpty())
1123 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
1125 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1127 if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
1129 // if there is already an item with the same name and the same
1130 // value it's ok to set it
1131 if( pItem->GetLineStartValue() != pLineStartItem->GetLineStartValue() )
1133 // same name but different value, we need a new name for this item
1134 aUniqueName.clear();
1135 bForceNew = true;
1137 break;
1141 if( !bForceNew )
1143 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
1145 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1147 if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
1149 // if there is already an item with the same name and the same
1150 // value it's ok to set it
1151 if( pItem->GetLineEndValue() != pLineStartItem->GetLineStartValue() )
1153 // same name but different value, we need a new name for this item
1154 aUniqueName.clear();
1155 bForceNew = true;
1157 break;
1163 const SfxItemPool* pPool2 = pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : nullptr;
1164 if( !aUniqueName.isEmpty() && pPool2)
1166 for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINESTART))
1168 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1170 if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
1172 // if there is already an item with the same name and the same
1173 // value it's ok to set it
1174 if( pItem->GetLineStartValue() != pLineStartItem->GetLineStartValue() )
1176 // same name but different value, we need a new name for this item
1177 aUniqueName.clear();
1178 bForceNew = true;
1180 break;
1184 if( !bForceNew )
1186 for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINEEND))
1188 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1190 if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
1192 // if there is already an item with the same name and the same
1193 // value it's ok to set it
1194 if( pItem->GetLineEndValue() != pLineStartItem->GetLineStartValue() )
1196 // same name but different value, we need a new name for this item
1197 aUniqueName.clear();
1198 bForceNew = true;
1200 break;
1206 // if we have no name yet, find existing item with same content or
1207 // create a unique name
1208 if( aUniqueName.isEmpty() )
1210 bool bFoundExisting = false;
1212 sal_Int32 nUserIndex = 1;
1213 const OUString aUser(SvxResId(RID_SVXSTR_LINEEND));
1215 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
1217 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1219 if (pItem && !pItem->GetName().isEmpty())
1221 if (!bForceNew && pItem->GetLineStartValue() == pLineStartItem->GetLineStartValue())
1223 aUniqueName = pItem->GetName();
1224 bFoundExisting = true;
1225 break;
1228 if (pItem->GetName().startsWith(aUser))
1230 sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32();
1231 if (nThisIndex >= nUserIndex)
1232 nUserIndex = nThisIndex + 1;
1237 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
1239 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1241 if (pItem && !pItem->GetName().isEmpty())
1243 if (!bForceNew && pItem->GetLineEndValue() == pLineStartItem->GetLineStartValue())
1245 aUniqueName = pItem->GetName();
1246 bFoundExisting = true;
1247 break;
1250 if (pItem->GetName().startsWith(aUser))
1252 sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32();
1253 if (nThisIndex >= nUserIndex)
1254 nUserIndex = nThisIndex + 1;
1259 if( !bFoundExisting )
1261 aUniqueName = aUser + " " + OUString::number( nUserIndex );
1265 // if the given name is not valid, replace it!
1266 if( aUniqueName != GetName() || pTempItem )
1268 if( pTempItem )
1270 pTempItem->SetName( aUniqueName );
1271 return pTempItem;
1273 else
1275 return std::make_unique<XLineStartItem>( aUniqueName, maPolyPolygon );
1280 return nullptr;
1283 SfxPoolItem* XLineEndItem::CreateDefault() {return new XLineEndItem;}
1285 XLineEndItem::XLineEndItem(sal_Int32 nIndex)
1286 : NameOrIndex(XATTR_LINEEND, nIndex)
1290 XLineEndItem::XLineEndItem(const OUString& rName, const basegfx::B2DPolyPolygon& rPolyPolygon)
1291 : NameOrIndex(XATTR_LINEEND, rName),
1292 maPolyPolygon(rPolyPolygon)
1296 XLineEndItem::XLineEndItem(const XLineEndItem& rItem)
1297 : NameOrIndex(rItem),
1298 maPolyPolygon(rItem.maPolyPolygon)
1302 XLineEndItem::XLineEndItem(const basegfx::B2DPolyPolygon& rPolyPolygon)
1303 : NameOrIndex( XATTR_LINEEND, -1 ),
1304 maPolyPolygon(rPolyPolygon)
1308 XLineEndItem* XLineEndItem::Clone(SfxItemPool* /*pPool*/) const
1310 return new XLineEndItem(*this);
1313 bool XLineEndItem::operator==(const SfxPoolItem& rItem) const
1315 return ( NameOrIndex::operator==(rItem) && static_cast<const XLineEndItem&>(rItem).maPolyPolygon == maPolyPolygon );
1319 /** this function searches in both the models pool and the styles pool for XLineStartItem
1320 and XLineEndItem with the same value or name and returns an item with the value of
1321 this item and a unique name for an item with this value. */
1322 std::unique_ptr<XLineEndItem> XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const
1324 if( pModel )
1326 std::unique_ptr<XLineEndItem> pTempItem;
1327 const XLineEndItem* pLineEndItem = this;
1329 OUString aUniqueName( GetName() );
1331 if( !maPolyPolygon.count() )
1333 // if the polygon is empty, check if the name is empty
1334 if( aUniqueName.isEmpty() )
1335 return nullptr;
1337 // force empty name for empty polygons
1338 return std::make_unique<XLineEndItem>( "", maPolyPolygon );
1341 if( maPolyPolygon.count() > 1 )
1343 // check if the polygon is closed
1344 if(!maPolyPolygon.isClosed())
1346 // force a closed polygon
1347 basegfx::B2DPolyPolygon aNew(maPolyPolygon);
1348 aNew.setClosed(true);
1349 pTempItem.reset(new XLineEndItem( aUniqueName, aNew ));
1350 pLineEndItem = pTempItem.get();
1354 bool bForceNew = false;
1356 // 2. if we have a name check if there is already an item with the
1357 // same name in the documents pool with a different line end or start
1359 const SfxItemPool& rPool1 = pModel->GetItemPool();
1360 if (!aUniqueName.isEmpty())
1362 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
1364 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1366 if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
1368 // if there is already an item with the same name and the same
1369 // value it's ok to set it
1370 if( pItem->GetLineStartValue() != pLineEndItem->GetLineEndValue() )
1372 // same name but different value, we need a new name for this item
1373 aUniqueName.clear();
1374 bForceNew = true;
1376 break;
1380 if( !bForceNew )
1382 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
1384 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1386 if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
1388 // if there is already an item with the same name and the same
1389 // value it's ok to set it
1390 if( pItem->GetLineEndValue() != pLineEndItem->GetLineEndValue() )
1392 // same name but different value, we need a new name for this item
1393 aUniqueName.clear();
1394 bForceNew = true;
1396 break;
1402 const SfxItemPool* pPool2 = pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : nullptr;
1403 if( !aUniqueName.isEmpty() && pPool2)
1405 for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINESTART))
1407 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1409 if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
1411 // if there is already an item with the same name and the same
1412 // value it's ok to set it
1413 if( pItem->GetLineStartValue() != pLineEndItem->GetLineEndValue() )
1415 // same name but different value, we need a new name for this item
1416 aUniqueName.clear();
1417 bForceNew = true;
1419 break;
1423 if( !bForceNew )
1425 for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINEEND))
1427 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1429 if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
1431 // if there is already an item with the same name and the same
1432 // value it's ok to set it
1433 if( pItem->GetLineEndValue() != pLineEndItem->GetLineEndValue() )
1435 // same name but different value, we need a new name for this item
1436 aUniqueName.clear();
1437 bForceNew = true;
1439 break;
1445 // if we have no name yet, find existing item with same content or
1446 // create a unique name
1447 if( aUniqueName.isEmpty() )
1449 bool bFoundExisting = false;
1451 sal_Int32 nUserIndex = 1;
1452 const OUString aUser(SvxResId(RID_SVXSTR_LINEEND));
1454 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
1456 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1458 if (pItem && !pItem->GetName().isEmpty())
1460 if (!bForceNew && pItem->GetLineStartValue() == pLineEndItem->GetLineEndValue())
1462 aUniqueName = pItem->GetName();
1463 bFoundExisting = true;
1464 break;
1467 if (pItem->GetName().startsWith(aUser))
1469 sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32();
1470 if (nThisIndex >= nUserIndex)
1471 nUserIndex = nThisIndex + 1;
1476 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
1478 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1480 if (pItem && !pItem->GetName().isEmpty())
1482 if (!bForceNew && pItem->GetLineEndValue() == pLineEndItem->GetLineEndValue())
1484 aUniqueName = pItem->GetName();
1485 bFoundExisting = true;
1486 break;
1489 if (pItem->GetName().startsWith(aUser))
1491 sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32();
1492 if (nThisIndex >= nUserIndex)
1493 nUserIndex = nThisIndex + 1;
1498 if( !bFoundExisting )
1500 aUniqueName = aUser + " " + OUString::number( nUserIndex );
1504 // if the given name is not valid, replace it!
1505 if( aUniqueName != GetName() || pTempItem )
1507 if( pTempItem )
1509 pTempItem->SetName( aUniqueName );
1510 return pTempItem;
1512 else
1514 return std::make_unique<XLineEndItem>( aUniqueName, maPolyPolygon );
1519 return nullptr;
1522 bool XLineEndItem::GetPresentation
1524 SfxItemPresentation /*ePres*/,
1525 MapUnit /*eCoreUnit*/,
1526 MapUnit /*ePresUnit*/,
1527 OUString& rText, const IntlWrapper&
1528 ) const
1530 rText = GetName();
1531 return true;
1534 bool XLineEndItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
1536 nMemberId &= ~CONVERT_TWIPS;
1537 if( nMemberId == MID_NAME )
1539 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
1541 else
1543 css::drawing::PolyPolygonBezierCoords aBezier;
1544 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( maPolyPolygon, aBezier );
1545 rVal <<= aBezier;
1547 return true;
1550 bool XLineEndItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
1552 nMemberId &= ~CONVERT_TWIPS;
1553 if( nMemberId == MID_NAME )
1555 return false;
1557 else
1559 maPolyPolygon.clear();
1561 if( rVal.hasValue() )
1563 auto pCoords = o3tl::tryAccess<css::drawing::PolyPolygonBezierCoords>(
1564 rVal);
1565 if( !pCoords )
1566 return false;
1568 if( pCoords->Coordinates.getLength() > 0 )
1570 maPolyPolygon = basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( *pCoords );
1571 // #i72807# close line start/end polygons hard
1572 // maPolyPolygon.setClosed(true);
1577 return true;
1580 XLineStartWidthItem::XLineStartWidthItem(tools::Long nWidth) :
1581 SfxMetricItem(XATTR_LINESTARTWIDTH, nWidth)
1585 XLineStartWidthItem* XLineStartWidthItem::Clone(SfxItemPool* /*pPool*/) const
1587 return new XLineStartWidthItem(*this);
1590 bool XLineStartWidthItem::GetPresentation
1592 SfxItemPresentation /*ePres*/,
1593 MapUnit eCoreUnit,
1594 MapUnit ePresUnit,
1595 OUString& rText, const IntlWrapper& rIntl
1596 ) const
1598 rText = GetMetricText( static_cast<tools::Long>(GetValue()),
1599 eCoreUnit, ePresUnit, &rIntl) +
1600 " " + EditResId( GetMetricId( ePresUnit) );
1601 return true;
1604 bool XLineStartWidthItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1606 rVal <<= GetValue();
1607 return true;
1610 bool XLineStartWidthItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1612 sal_Int32 nValue = 0;
1613 rVal >>= nValue;
1614 SetValue( nValue );
1615 return true;
1618 XLineEndWidthItem::XLineEndWidthItem(tools::Long nWidth) :
1619 SfxMetricItem(XATTR_LINEENDWIDTH, nWidth)
1623 XLineEndWidthItem* XLineEndWidthItem::Clone(SfxItemPool* /*pPool*/) const
1625 return new XLineEndWidthItem(*this);
1628 bool XLineEndWidthItem::GetPresentation
1630 SfxItemPresentation /*ePres*/,
1631 MapUnit eCoreUnit,
1632 MapUnit ePresUnit,
1633 OUString& rText, const IntlWrapper& rIntl
1634 ) const
1636 rText = GetMetricText( static_cast<tools::Long>(GetValue()),
1637 eCoreUnit, ePresUnit, &rIntl) +
1638 " " + EditResId( GetMetricId( ePresUnit) );
1639 return true;
1642 bool XLineEndWidthItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1644 rVal <<= GetValue();
1645 return true;
1648 bool XLineEndWidthItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1650 sal_Int32 nValue = 0;
1651 rVal >>= nValue;
1652 SetValue( nValue );
1653 return true;
1656 XLineStartCenterItem::XLineStartCenterItem(bool bStartCenter) :
1657 SfxBoolItem(XATTR_LINESTARTCENTER, bStartCenter)
1661 XLineStartCenterItem* XLineStartCenterItem::Clone(SfxItemPool* /*pPool*/) const
1663 return new XLineStartCenterItem(*this);
1666 bool XLineStartCenterItem::GetPresentation
1668 SfxItemPresentation /*ePres*/,
1669 MapUnit /*eCoreUnit*/,
1670 MapUnit /*ePresUnit*/,
1671 OUString& rText, const IntlWrapper&
1672 ) const
1674 rText = SvxResId(GetValue() ? RID_SVXSTR_CENTERED : RID_SVXSTR_NOTCENTERED);
1675 return true;
1678 bool XLineStartCenterItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1680 bool bValue = GetValue();
1681 rVal <<= bValue;
1682 return true;
1685 bool XLineStartCenterItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1687 auto b = o3tl::tryAccess<bool>(rVal);
1688 if( !b )
1689 return false;
1691 SetValue( *b );
1692 return true;
1695 XLineEndCenterItem::XLineEndCenterItem(bool bEndCenter) :
1696 SfxBoolItem(XATTR_LINEENDCENTER, bEndCenter)
1700 XLineEndCenterItem* XLineEndCenterItem::Clone(SfxItemPool* /*pPool*/) const
1702 return new XLineEndCenterItem(*this);
1705 bool XLineEndCenterItem::GetPresentation
1707 SfxItemPresentation /*ePres*/,
1708 MapUnit /*eCoreUnit*/,
1709 MapUnit /*ePresUnit*/,
1710 OUString& rText, const IntlWrapper&
1711 ) const
1713 rText = SvxResId(GetValue() ? RID_SVXSTR_CENTERED : RID_SVXSTR_NOTCENTERED);
1714 return true;
1717 bool XLineEndCenterItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1719 bool bValue = GetValue();
1720 rVal <<= bValue;
1721 return true;
1724 bool XLineEndCenterItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1726 auto b = o3tl::tryAccess<bool>(rVal);
1727 if( !b )
1728 return false;
1730 SetValue( *b );
1731 return true;
1734 // --- fill attributes ---
1737 SfxPoolItem* XFillStyleItem::CreateDefault() { return new XFillStyleItem; }
1739 XFillStyleItem::XFillStyleItem(drawing::FillStyle eFillStyle) :
1740 SfxEnumItem(XATTR_FILLSTYLE, eFillStyle)
1744 XFillStyleItem* XFillStyleItem::Clone(SfxItemPool* /*pPool*/) const
1746 return new XFillStyleItem( *this );
1749 bool XFillStyleItem::GetPresentation
1751 SfxItemPresentation /*ePres*/,
1752 MapUnit /*eCoreUnit*/,
1753 MapUnit /*ePresUnit*/,
1754 OUString& rText, const IntlWrapper&
1755 ) const
1757 rText.clear();
1759 TranslateId pId;
1761 switch( GetValue() )
1763 case drawing::FillStyle_NONE:
1764 pId = RID_SVXSTR_INVISIBLE;
1765 break;
1766 case drawing::FillStyle_SOLID:
1767 pId = RID_SVXSTR_SOLID;
1768 break;
1769 case drawing::FillStyle_GRADIENT:
1770 pId = RID_SVXSTR_GRADIENT;
1771 break;
1772 case drawing::FillStyle_HATCH:
1773 pId = RID_SVXSTR_HATCH;
1774 break;
1775 case drawing::FillStyle_BITMAP:
1776 pId = RID_SVXSTR_BITMAP;
1777 break;
1778 default: break;
1781 if (pId)
1782 rText = SvxResId(pId);
1783 return true;
1786 sal_uInt16 XFillStyleItem::GetValueCount() const
1788 return 5;
1791 bool XFillStyleItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1793 css::drawing::FillStyle eFS = GetValue();
1795 rVal <<= eFS;
1797 return true;
1800 bool XFillStyleItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1802 css::drawing::FillStyle eFS;
1803 if(!(rVal >>= eFS))
1805 // also try an int (for Basic)
1806 sal_Int32 nFS = 0;
1807 if(!(rVal >>= nFS))
1808 return false;
1809 eFS = static_cast<css::drawing::FillStyle>(nFS);
1812 SetValue( eFS );
1814 return true;
1817 void XFillStyleItem::dumpAsXml(xmlTextWriterPtr pWriter) const
1819 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XFillStyleItem"));
1820 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1821 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(static_cast<sal_Int16>(GetValue())).getStr()));
1823 OUString aPresentation;
1824 IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
1825 GetPresentation(SfxItemPresentation::Nameless, MapUnit::Map100thMM, MapUnit::Map100thMM, aPresentation, aIntlWrapper);
1826 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), BAD_CAST(aPresentation.toUtf8().getStr()));
1828 (void)xmlTextWriterEndElement(pWriter);
1831 boost::property_tree::ptree XFillStyleItem::dumpAsJSON() const
1833 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
1835 if (Which() == XATTR_FILLSTYLE)
1836 aTree.put("commandName", ".uno:FillStyle");
1838 OUString sValue;
1840 switch( GetValue() )
1842 case drawing::FillStyle_NONE:
1843 sValue = "NONE";
1844 break;
1845 case drawing::FillStyle_SOLID:
1846 sValue = "SOLID";
1847 break;
1848 case drawing::FillStyle_GRADIENT:
1849 sValue = "GRADIENT";
1850 break;
1851 case drawing::FillStyle_HATCH:
1852 sValue = "HATCH";
1853 break;
1854 case drawing::FillStyle_BITMAP:
1855 sValue = "BITMAP";
1856 break;
1857 default: break;
1860 aTree.put("state", sValue);
1862 return aTree;
1866 SfxPoolItem* XFillColorItem::CreateDefault() { return new XFillColorItem; }
1868 XFillColorItem::XFillColorItem(sal_Int32 nIndex, const Color& rTheColor) :
1869 XColorItem(XATTR_FILLCOLOR, nIndex, rTheColor)
1873 XFillColorItem::XFillColorItem(const OUString& rName, const Color& rTheColor) :
1874 XColorItem(XATTR_FILLCOLOR, rName, rTheColor)
1878 XFillColorItem* XFillColorItem::Clone(SfxItemPool* /*pPool*/) const
1880 return new XFillColorItem(*this);
1883 bool XFillColorItem::GetPresentation
1885 SfxItemPresentation /*ePres*/,
1886 MapUnit /*eCoreUnit*/,
1887 MapUnit /*ePresUnit*/,
1888 OUString& rText, const IntlWrapper&
1889 ) const
1891 rText = GetName();
1892 return true;
1895 bool XFillColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1897 rVal <<= GetColorValue().GetRGBColor();
1899 return true;
1902 bool XFillColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1904 Color nValue;
1905 if(!(rVal >>= nValue ))
1906 return false;
1908 SetColorValue( nValue );
1909 return true;
1912 void XFillColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
1914 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XFillColorItem"));
1915 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1916 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(GetColorValue().AsRGBHexString().toUtf8().getStr()));
1917 (void)xmlTextWriterEndElement(pWriter);
1920 boost::property_tree::ptree XFillColorItem::dumpAsJSON() const
1922 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
1924 if (Which() == XATTR_FILLCOLOR)
1925 aTree.put("commandName", ".uno:FillPageColor");
1927 aTree.put("state", GetColorValue().AsRGBHexString());
1929 return aTree;
1932 XSecondaryFillColorItem::XSecondaryFillColorItem(const OUString& rName, const Color& rTheColor) :
1933 XColorItem(XATTR_SECONDARYFILLCOLOR, rName, rTheColor)
1937 XSecondaryFillColorItem* XSecondaryFillColorItem::Clone(SfxItemPool* /*pPool*/) const
1939 return new XSecondaryFillColorItem(*this);
1942 bool XSecondaryFillColorItem::GetPresentation
1944 SfxItemPresentation /*ePres*/,
1945 MapUnit /*eCoreUnit*/,
1946 MapUnit /*ePresUnit*/,
1947 OUString& rText, const IntlWrapper&
1948 ) const
1950 rText = GetName();
1951 return true;
1954 std::string XGradient::GradientStyleToString(css::awt::GradientStyle eStyle)
1956 switch (eStyle)
1958 case css::awt::GradientStyle::GradientStyle_LINEAR:
1959 return "LINEAR";
1961 case css::awt::GradientStyle::GradientStyle_AXIAL:
1962 return "AXIAL";
1964 case css::awt::GradientStyle::GradientStyle_RADIAL:
1965 return "RADIAL";
1967 case css::awt::GradientStyle::GradientStyle_ELLIPTICAL:
1968 return "ELLIPTICAL";
1970 case css::awt::GradientStyle::GradientStyle_SQUARE:
1971 return "SQUARE";
1973 case css::awt::GradientStyle::GradientStyle_RECT:
1974 return "RECT";
1976 case css::awt::GradientStyle::GradientStyle_MAKE_FIXED_SIZE:
1977 return "MAKE_FIXED_SIZE";
1980 return "";
1983 namespace
1985 css::awt::GradientStyle lcl_getStyleFromString(std::u16string_view rStyle)
1987 if (rStyle == u"LINEAR")
1988 return css::awt::GradientStyle_LINEAR;
1989 else if (rStyle == u"AXIAL")
1990 return css::awt::GradientStyle_AXIAL;
1991 else if (rStyle == u"RADIAL")
1992 return css::awt::GradientStyle_RADIAL;
1993 else if (rStyle == u"ELLIPTICAL")
1994 return css::awt::GradientStyle_ELLIPTICAL;
1995 else if (rStyle == u"SQUARE")
1996 return css::awt::GradientStyle_SQUARE;
1997 else if (rStyle == u"RECT")
1998 return css::awt::GradientStyle_RECT;
2000 return css::awt::GradientStyle_LINEAR;
2003 StringMap lcl_jsonToStringMap(const OUString& rJSON)
2005 StringMap aArgs;
2006 if (rJSON.getLength() && rJSON[0] != '\0')
2008 std::stringstream aStream(OUStringToOString(rJSON, RTL_TEXTENCODING_ASCII_US).getStr());
2009 boost::property_tree::ptree aTree;
2010 boost::property_tree::read_json(aStream, aTree);
2012 for (const auto& rPair : aTree)
2014 aArgs[OUString::fromUtf8(rPair.first.c_str())] = OUString::fromUtf8(rPair.second.get_value<std::string>(".").c_str());
2017 return aArgs;
2020 XGradient lcl_buildGradientFromStringMap(StringMap& rMap)
2022 XGradient aGradient;
2024 aGradient.SetStartColor(Color(ColorTransparency, rMap["startcolor"].toInt32(16)));
2025 aGradient.SetEndColor(Color(ColorTransparency, rMap["endcolor"].toInt32(16)));
2026 aGradient.SetGradientStyle(lcl_getStyleFromString(rMap["style"]));
2027 aGradient.SetAngle(Degree10(rMap["angle"].toInt32()));
2029 return aGradient;
2033 XGradient XGradient::fromJSON(const OUString& rJSON)
2035 StringMap aMap(lcl_jsonToStringMap(rJSON));
2036 return lcl_buildGradientFromStringMap(aMap);
2039 css::awt::Gradient XGradient::toGradientUNO() const
2041 css::awt::Gradient aGradient;
2043 aGradient.Style = this->GetGradientStyle();
2044 aGradient.StartColor = static_cast<sal_Int32>(this->GetStartColor());
2045 aGradient.EndColor = static_cast<sal_Int32>(this->GetEndColor());
2046 aGradient.Angle = static_cast<short>(this->GetAngle());
2047 aGradient.Border = this->GetBorder();
2048 aGradient.XOffset = this->GetXOffset();
2049 aGradient.YOffset = this->GetYOffset();
2050 aGradient.StartIntensity = this->GetStartIntens();
2051 aGradient.EndIntensity = this->GetEndIntens();
2052 aGradient.StepCount = this->GetSteps();
2054 return aGradient;
2057 XGradient::XGradient() :
2058 eStyle( css::awt::GradientStyle_LINEAR ),
2059 aStartColor( COL_BLACK ),
2060 aEndColor( COL_WHITE ),
2061 nAngle( 0 ),
2062 nBorder( 0 ),
2063 nOfsX( 50 ),
2064 nOfsY( 50 ),
2065 nIntensStart( 100 ),
2066 nIntensEnd( 100 ),
2067 nStepCount( 0 )
2071 XGradient::XGradient(const Color& rStart, const Color& rEnd,
2072 css::awt::GradientStyle eTheStyle, Degree10 nTheAngle, sal_uInt16 nXOfs,
2073 sal_uInt16 nYOfs, sal_uInt16 nTheBorder,
2074 sal_uInt16 nStartIntens, sal_uInt16 nEndIntens,
2075 sal_uInt16 nSteps) :
2076 eStyle(eTheStyle),
2077 aStartColor(rStart),
2078 aEndColor(rEnd),
2079 nAngle(nTheAngle),
2080 nBorder(nTheBorder),
2081 nOfsX(nXOfs),
2082 nOfsY(nYOfs),
2083 nIntensStart(nStartIntens),
2084 nIntensEnd(nEndIntens),
2085 nStepCount(nSteps)
2089 bool XGradient::operator==(const XGradient& rGradient) const
2091 return ( eStyle == rGradient.eStyle &&
2092 aStartColor == rGradient.aStartColor &&
2093 aEndColor == rGradient.aEndColor &&
2094 nAngle == rGradient.nAngle &&
2095 nBorder == rGradient.nBorder &&
2096 nOfsX == rGradient.nOfsX &&
2097 nOfsY == rGradient.nOfsY &&
2098 nIntensStart == rGradient.nIntensStart &&
2099 nIntensEnd == rGradient.nIntensEnd &&
2100 nStepCount == rGradient.nStepCount );
2103 boost::property_tree::ptree XGradient::dumpAsJSON() const
2105 boost::property_tree::ptree aTree;
2107 aTree.put("style", XGradient::GradientStyleToString(eStyle));
2108 aTree.put("startcolor",aStartColor.AsRGBHexString());
2109 aTree.put("endcolor", aEndColor.AsRGBHexString());
2110 aTree.put("angle", std::to_string(nAngle.get()));
2111 aTree.put("border", std::to_string(nBorder));
2112 aTree.put("x", std::to_string(nOfsX));
2113 aTree.put("y", std::to_string(nOfsY));
2114 aTree.put("intensstart", std::to_string(nIntensStart));
2115 aTree.put("intensend", std::to_string(nIntensEnd));
2116 aTree.put("stepcount", std::to_string(nStepCount));
2118 return aTree;
2121 SfxPoolItem* XFillGradientItem::CreateDefault() { return new XFillGradientItem; }
2123 XFillGradientItem::XFillGradientItem(sal_Int32 nIndex,
2124 const XGradient& rTheGradient) :
2125 NameOrIndex(XATTR_FILLGRADIENT, nIndex),
2126 aGradient(rTheGradient)
2130 XFillGradientItem::XFillGradientItem(const OUString& rName,
2131 const XGradient& rTheGradient, sal_uInt16 nWhich)
2132 : NameOrIndex(nWhich, rName)
2133 , aGradient(rTheGradient)
2137 XFillGradientItem::XFillGradientItem(const XFillGradientItem& rItem) :
2138 NameOrIndex(rItem),
2139 aGradient(rItem.aGradient)
2143 XFillGradientItem::XFillGradientItem( const XGradient& rTheGradient )
2144 : NameOrIndex( XATTR_FILLGRADIENT, -1 ),
2145 aGradient(rTheGradient)
2149 XFillGradientItem* XFillGradientItem::Clone(SfxItemPool* /*pPool*/) const
2151 return new XFillGradientItem(*this);
2154 bool XFillGradientItem::operator==(const SfxPoolItem& rItem) const
2156 return ( NameOrIndex::operator==(rItem) &&
2157 aGradient == static_cast<const XFillGradientItem&>(rItem).aGradient );
2160 const XGradient& XFillGradientItem::GetGradientValue() const // GetValue -> GetGradientValue
2162 if (!IsIndex())
2163 return aGradient;
2164 // ToDo: This should fail. We never called this code with a table so this should always
2165 // have failed. Thus, I'm thinking that XFillGradientItem can't be an Index.
2166 return aGradient;
2169 bool XFillGradientItem::GetPresentation
2171 SfxItemPresentation /*ePres*/,
2172 MapUnit /*eCoreUnit*/,
2173 MapUnit /*ePresUnit*/,
2174 OUString& rText, const IntlWrapper&
2175 ) const
2177 rText = GetName();
2178 return true;
2181 bool XFillGradientItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2183 nMemberId &= ~CONVERT_TWIPS;
2184 switch ( nMemberId )
2186 case 0:
2188 css::awt::Gradient aGradient2;
2190 const XGradient& aXGradient = GetGradientValue();
2191 aGradient2.Style = aXGradient.GetGradientStyle();
2192 aGradient2.StartColor = static_cast<sal_Int32>(aXGradient.GetStartColor());
2193 aGradient2.EndColor = static_cast<sal_Int32>(aXGradient.GetEndColor());
2194 aGradient2.Angle = static_cast<short>(aXGradient.GetAngle());
2195 aGradient2.Border = aXGradient.GetBorder();
2196 aGradient2.XOffset = aXGradient.GetXOffset();
2197 aGradient2.YOffset = aXGradient.GetYOffset();
2198 aGradient2.StartIntensity = aXGradient.GetStartIntens();
2199 aGradient2.EndIntensity = aXGradient.GetEndIntens();
2200 aGradient2.StepCount = aXGradient.GetSteps();
2202 uno::Sequence< beans::PropertyValue > aPropSeq{
2203 comphelper::makePropertyValue("Name", SvxUnogetApiNameForItem(Which(), GetName())),
2204 comphelper::makePropertyValue("FillGradient", aGradient2)
2206 rVal <<= aPropSeq;
2207 break;
2210 case MID_FILLGRADIENT:
2212 const XGradient& aXGradient = GetGradientValue();
2213 css::awt::Gradient aGradient2;
2215 aGradient2.Style = aXGradient.GetGradientStyle();
2216 aGradient2.StartColor = static_cast<sal_Int32>(aXGradient.GetStartColor());
2217 aGradient2.EndColor = static_cast<sal_Int32>(aXGradient.GetEndColor());
2218 aGradient2.Angle = static_cast<short>(aXGradient.GetAngle());
2219 aGradient2.Border = aXGradient.GetBorder();
2220 aGradient2.XOffset = aXGradient.GetXOffset();
2221 aGradient2.YOffset = aXGradient.GetYOffset();
2222 aGradient2.StartIntensity = aXGradient.GetStartIntens();
2223 aGradient2.EndIntensity = aXGradient.GetEndIntens();
2224 aGradient2.StepCount = aXGradient.GetSteps();
2226 rVal <<= aGradient2;
2227 break;
2230 case MID_NAME:
2232 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
2233 break;
2236 case MID_GRADIENT_STYLE: rVal <<= static_cast<sal_Int16>(GetGradientValue().GetGradientStyle()); break;
2237 case MID_GRADIENT_STARTCOLOR: rVal <<= GetGradientValue().GetStartColor(); break;
2238 case MID_GRADIENT_ENDCOLOR: rVal <<= GetGradientValue().GetEndColor(); break;
2239 case MID_GRADIENT_ANGLE: rVal <<= static_cast<sal_Int16>(GetGradientValue().GetAngle()); break;
2240 case MID_GRADIENT_BORDER: rVal <<= GetGradientValue().GetBorder(); break;
2241 case MID_GRADIENT_XOFFSET: rVal <<= GetGradientValue().GetXOffset(); break;
2242 case MID_GRADIENT_YOFFSET: rVal <<= GetGradientValue().GetYOffset(); break;
2243 case MID_GRADIENT_STARTINTENSITY: rVal <<= GetGradientValue().GetStartIntens(); break;
2244 case MID_GRADIENT_ENDINTENSITY: rVal <<= GetGradientValue().GetEndIntens(); break;
2245 case MID_GRADIENT_STEPCOUNT: rVal <<= GetGradientValue().GetSteps(); break;
2247 default: OSL_FAIL("Wrong MemberId!"); return false;
2250 return true;
2253 bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2255 nMemberId &= ~CONVERT_TWIPS;
2257 switch ( nMemberId )
2259 case 0:
2261 uno::Sequence< beans::PropertyValue > aPropSeq;
2263 if ( rVal >>= aPropSeq )
2265 css::awt::Gradient aGradient2;
2266 OUString aName;
2267 bool bGradient( false );
2268 for ( const auto& rProp : std::as_const(aPropSeq) )
2270 if ( rProp.Name == "Name" )
2271 rProp.Value >>= aName;
2272 else if ( rProp.Name == "FillGradient" )
2274 if ( rProp.Value >>= aGradient2 )
2275 bGradient = true;
2279 SetName( aName );
2280 if ( bGradient )
2282 XGradient aXGradient;
2284 aXGradient.SetGradientStyle( aGradient2.Style );
2285 aXGradient.SetStartColor( Color(ColorTransparency, aGradient2.StartColor) );
2286 aXGradient.SetEndColor( Color(ColorTransparency, aGradient2.EndColor) );
2287 aXGradient.SetAngle( Degree10(aGradient2.Angle) );
2288 aXGradient.SetBorder( aGradient2.Border );
2289 aXGradient.SetXOffset( aGradient2.XOffset );
2290 aXGradient.SetYOffset( aGradient2.YOffset );
2291 aXGradient.SetStartIntens( aGradient2.StartIntensity );
2292 aXGradient.SetEndIntens( aGradient2.EndIntensity );
2293 aXGradient.SetSteps( aGradient2.StepCount );
2295 SetGradientValue( aXGradient );
2298 return true;
2301 return false;
2304 case MID_NAME:
2306 OUString aName;
2307 if (!(rVal >>= aName ))
2308 return false;
2309 SetName( aName );
2310 break;
2313 case MID_FILLGRADIENT:
2315 css::awt::Gradient aGradient2;
2316 if(!(rVal >>= aGradient2))
2317 return false;
2319 XGradient aXGradient;
2321 aXGradient.SetGradientStyle( aGradient2.Style );
2322 aXGradient.SetStartColor( Color(ColorTransparency, aGradient2.StartColor) );
2323 aXGradient.SetEndColor( Color(ColorTransparency, aGradient2.EndColor) );
2324 aXGradient.SetAngle( Degree10(aGradient2.Angle) );
2325 aXGradient.SetBorder( aGradient2.Border );
2326 aXGradient.SetXOffset( aGradient2.XOffset );
2327 aXGradient.SetYOffset( aGradient2.YOffset );
2328 aXGradient.SetStartIntens( aGradient2.StartIntensity );
2329 aXGradient.SetEndIntens( aGradient2.EndIntensity );
2330 aXGradient.SetSteps( aGradient2.StepCount );
2332 SetGradientValue( aXGradient );
2333 break;
2336 case MID_GRADIENT_STARTCOLOR:
2337 case MID_GRADIENT_ENDCOLOR:
2339 Color nVal;
2340 if(!(rVal >>= nVal ))
2341 return false;
2343 XGradient aXGradient = GetGradientValue();
2345 if ( nMemberId == MID_GRADIENT_STARTCOLOR )
2346 aXGradient.SetStartColor( nVal );
2347 else
2348 aXGradient.SetEndColor( nVal );
2349 SetGradientValue( aXGradient );
2350 break;
2353 case MID_GRADIENT_STYLE:
2354 case MID_GRADIENT_ANGLE:
2355 case MID_GRADIENT_BORDER:
2356 case MID_GRADIENT_STARTINTENSITY:
2357 case MID_GRADIENT_ENDINTENSITY:
2358 case MID_GRADIENT_STEPCOUNT:
2359 case MID_GRADIENT_XOFFSET:
2360 case MID_GRADIENT_YOFFSET:
2362 sal_Int16 nVal = sal_Int16();
2363 if(!(rVal >>= nVal ))
2364 return false;
2366 XGradient aXGradient = GetGradientValue();
2368 switch ( nMemberId )
2370 case MID_GRADIENT_STYLE:
2371 aXGradient.SetGradientStyle( static_cast<css::awt::GradientStyle>(nVal) ); break;
2372 case MID_GRADIENT_ANGLE:
2373 aXGradient.SetAngle( Degree10(nVal) ); break;
2374 case MID_GRADIENT_BORDER:
2375 aXGradient.SetBorder( nVal ); break;
2376 case MID_GRADIENT_STARTINTENSITY:
2377 aXGradient.SetStartIntens( nVal ); break;
2378 case MID_GRADIENT_ENDINTENSITY:
2379 aXGradient.SetEndIntens( nVal ); break;
2380 case MID_GRADIENT_STEPCOUNT:
2381 aXGradient.SetSteps( nVal ); break;
2382 case MID_GRADIENT_XOFFSET:
2383 aXGradient.SetXOffset( nVal ); break;
2384 case MID_GRADIENT_YOFFSET:
2385 aXGradient.SetYOffset( nVal ); break;
2388 SetGradientValue( aXGradient );
2389 break;
2393 return true;
2396 bool XFillGradientItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2398 return static_cast<const XFillGradientItem*>(p1)->GetGradientValue() == static_cast<const XFillGradientItem*>(p2)->GetGradientValue();
2401 std::unique_ptr<XFillGradientItem> XFillGradientItem::checkForUniqueItem( SdrModel* pModel ) const
2403 if( pModel )
2405 const OUString aUniqueName = NameOrIndex::CheckNamedItem(
2406 this, Which(), &pModel->GetItemPool(),
2407 XFillGradientItem::CompareValueFunc, RID_SVXSTR_GRADIENT,
2408 pModel->GetPropertyList( XPropertyListType::Gradient ) );
2410 // if the given name is not valid, replace it!
2411 if( aUniqueName != GetName() )
2412 return std::make_unique<XFillGradientItem>( aUniqueName, aGradient, Which() );
2415 return nullptr;
2418 boost::property_tree::ptree XFillGradientItem::dumpAsJSON() const
2420 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
2422 if (Which() == XATTR_FILLGRADIENT)
2423 aTree.put("commandName", ".uno:FillGradient");
2425 aTree.push_back(std::make_pair("state", GetGradientValue().dumpAsJSON()));
2427 return aTree;
2431 SfxPoolItem* XFillFloatTransparenceItem::CreateDefault() { return new XFillFloatTransparenceItem; }
2433 XFillFloatTransparenceItem::XFillFloatTransparenceItem() :
2434 bEnabled( false )
2436 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2439 XFillFloatTransparenceItem::XFillFloatTransparenceItem(const OUString& rName, const XGradient& rGradient, bool bEnable ) :
2440 XFillGradientItem ( rName, rGradient ),
2441 bEnabled ( bEnable )
2443 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2446 XFillFloatTransparenceItem::XFillFloatTransparenceItem( const XFillFloatTransparenceItem& rItem ) :
2447 XFillGradientItem ( rItem ),
2448 bEnabled ( rItem.bEnabled )
2450 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2453 XFillFloatTransparenceItem::XFillFloatTransparenceItem(const XGradient& rTheGradient, bool bEnable )
2454 : XFillGradientItem ( -1, rTheGradient ),
2455 bEnabled ( bEnable )
2457 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2460 bool XFillFloatTransparenceItem::operator==( const SfxPoolItem& rItem ) const
2462 return ( NameOrIndex::operator==(rItem) ) &&
2463 ( GetGradientValue() == static_cast<const XFillGradientItem&>(rItem).GetGradientValue() ) &&
2464 ( bEnabled == static_cast<const XFillFloatTransparenceItem&>(rItem).bEnabled );
2467 XFillFloatTransparenceItem* XFillFloatTransparenceItem::Clone( SfxItemPool* /*pPool*/) const
2469 return new XFillFloatTransparenceItem( *this );
2472 bool XFillFloatTransparenceItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2474 return XFillGradientItem::QueryValue( rVal, nMemberId );
2477 bool XFillFloatTransparenceItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2479 return XFillGradientItem::PutValue( rVal, nMemberId );
2482 bool XFillFloatTransparenceItem::GetPresentation( SfxItemPresentation ePres,
2483 MapUnit eCoreUnit, MapUnit ePresUnit,
2484 OUString& rText,
2485 const IntlWrapper& rIntlWrapper ) const
2487 return XFillGradientItem::GetPresentation( ePres, eCoreUnit, ePresUnit, rText, rIntlWrapper );
2490 bool XFillFloatTransparenceItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2492 return static_cast<const XFillFloatTransparenceItem*>(p1)->IsEnabled() == static_cast<const XFillFloatTransparenceItem*>(p2)->IsEnabled() &&
2493 static_cast<const XFillFloatTransparenceItem*>(p1)->GetGradientValue() == static_cast<const XFillFloatTransparenceItem*>(p2)->GetGradientValue();
2496 std::unique_ptr<XFillFloatTransparenceItem> XFillFloatTransparenceItem::checkForUniqueItem( SdrModel* pModel ) const
2498 // #85953# unique name only necessary when enabled
2499 if(IsEnabled())
2501 if( pModel )
2503 const OUString aUniqueName = NameOrIndex::CheckNamedItem( this,
2504 XATTR_FILLFLOATTRANSPARENCE,
2505 &pModel->GetItemPool(),
2506 XFillFloatTransparenceItem::CompareValueFunc,
2507 RID_SVXSTR_TRASNGR0,
2508 XPropertyListRef() );
2510 // if the given name is not valid, replace it!
2511 if( aUniqueName != GetName() )
2513 return std::make_unique<XFillFloatTransparenceItem>( aUniqueName, GetGradientValue(), true );
2517 else
2519 // #85953# if disabled, force name to empty string
2520 if( !GetName().isEmpty() )
2522 return std::make_unique<XFillFloatTransparenceItem>(OUString(), GetGradientValue(), false);
2526 return nullptr;
2529 boost::property_tree::ptree XFillFloatTransparenceItem::dumpAsJSON() const
2531 boost::property_tree::ptree aTree = XFillGradientItem::dumpAsJSON();
2532 aTree.put("commandName", ".uno:FillFloatTransparence");
2534 if (!bEnabled)
2536 boost::property_tree::ptree& rState = aTree.get_child("state");
2537 // When gradient fill is disabled, the intensity fields contain the
2538 // constant encoded percent-transparency. However we use that here to just
2539 // distinguish between 'None' and 'Solid' types and correct the 'style'
2540 // property appropriately.
2541 if (GetGradientValue().GetStartIntens() == 100)
2542 rState.put("style", "NONE");
2543 else
2544 rState.put("style", "SOLID");
2547 return aTree;
2550 XHatch::XHatch(const Color& rCol, css::drawing::HatchStyle eTheStyle, tools::Long nTheDistance,
2551 Degree10 nTheAngle) :
2552 eStyle(eTheStyle),
2553 aColor(rCol),
2554 nDistance(nTheDistance),
2555 nAngle(nTheAngle)
2559 bool XHatch::operator==(const XHatch& rHatch) const
2561 return ( eStyle == rHatch.eStyle &&
2562 aColor == rHatch.aColor &&
2563 nDistance == rHatch.nDistance &&
2564 nAngle == rHatch.nAngle );
2568 SfxPoolItem* XFillHatchItem::CreateDefault() { return new XFillHatchItem; }
2570 XFillHatchItem::XFillHatchItem(const OUString& rName,
2571 const XHatch& rTheHatch) :
2572 NameOrIndex(XATTR_FILLHATCH, rName),
2573 aHatch(rTheHatch)
2577 XFillHatchItem::XFillHatchItem(const XFillHatchItem& rItem) :
2578 NameOrIndex(rItem),
2579 aHatch(rItem.aHatch)
2583 XFillHatchItem::XFillHatchItem(const XHatch& rTheHatch)
2584 : NameOrIndex( XATTR_FILLHATCH, -1 ),
2585 aHatch(rTheHatch)
2589 XFillHatchItem* XFillHatchItem::Clone(SfxItemPool* /*pPool*/) const
2591 return new XFillHatchItem(*this);
2594 bool XFillHatchItem::operator==(const SfxPoolItem& rItem) const
2596 return ( NameOrIndex::operator==(rItem) &&
2597 aHatch == static_cast<const XFillHatchItem&>(rItem).aHatch );
2600 bool XFillHatchItem::GetPresentation
2602 SfxItemPresentation /*ePres*/,
2603 MapUnit /*eCoreUnit*/,
2604 MapUnit /*ePresUnit*/,
2605 OUString& rText, const IntlWrapper&
2606 ) const
2608 rText = GetName();
2609 return true;
2612 bool XFillHatchItem::HasMetrics() const
2614 return true;
2617 void XFillHatchItem::ScaleMetrics(tools::Long nMul, tools::Long nDiv)
2619 aHatch.SetDistance( BigInt::Scale( aHatch.GetDistance(), nMul, nDiv ) );
2622 bool XFillHatchItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2624 nMemberId &= ~CONVERT_TWIPS;
2626 switch ( nMemberId )
2628 case 0:
2630 css::drawing::Hatch aUnoHatch;
2632 aUnoHatch.Style = aHatch.GetHatchStyle();
2633 aUnoHatch.Color = sal_Int32(aHatch.GetColor());
2634 aUnoHatch.Distance = aHatch.GetDistance();
2635 aUnoHatch.Angle = aHatch.GetAngle().get();
2637 uno::Sequence< beans::PropertyValue > aPropSeq{
2638 comphelper::makePropertyValue("Name", SvxUnogetApiNameForItem(Which(), GetName())),
2639 comphelper::makePropertyValue("FillHatch", aUnoHatch)
2641 rVal <<= aPropSeq;
2642 break;
2645 case MID_FILLHATCH:
2647 css::drawing::Hatch aUnoHatch;
2649 aUnoHatch.Style = aHatch.GetHatchStyle();
2650 aUnoHatch.Color = sal_Int32(aHatch.GetColor());
2651 aUnoHatch.Distance = aHatch.GetDistance();
2652 aUnoHatch.Angle = aHatch.GetAngle().get();
2653 rVal <<= aUnoHatch;
2654 break;
2657 case MID_NAME:
2659 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
2660 break;
2663 case MID_HATCH_STYLE:
2664 rVal <<= aHatch.GetHatchStyle(); break;
2665 case MID_HATCH_COLOR:
2666 rVal <<= aHatch.GetColor(); break;
2667 case MID_HATCH_DISTANCE:
2668 rVal <<= aHatch.GetDistance(); break;
2669 case MID_HATCH_ANGLE:
2670 rVal <<= aHatch.GetAngle().get(); break;
2672 default: OSL_FAIL("Wrong MemberId!"); return false;
2675 return true;
2678 bool XFillHatchItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2680 nMemberId &= ~CONVERT_TWIPS;
2682 switch ( nMemberId )
2684 case 0:
2686 uno::Sequence< beans::PropertyValue > aPropSeq;
2687 if ( rVal >>= aPropSeq )
2689 css::drawing::Hatch aUnoHatch;
2690 OUString aName;
2691 bool bHatch( false );
2692 for ( const auto& rProp : std::as_const(aPropSeq) )
2694 if ( rProp.Name == "Name" )
2695 rProp.Value >>= aName;
2696 else if ( rProp.Name == "FillHatch" )
2698 if ( rProp.Value >>= aUnoHatch )
2699 bHatch = true;
2703 SetName( aName );
2704 if ( bHatch )
2706 aHatch.SetHatchStyle( aUnoHatch.Style );
2707 aHatch.SetColor( Color(ColorTransparency, aUnoHatch.Color) );
2708 aHatch.SetDistance( aUnoHatch.Distance );
2709 aHatch.SetAngle( Degree10(aUnoHatch.Angle) );
2712 return true;
2715 return false;
2718 case MID_FILLHATCH:
2720 css::drawing::Hatch aUnoHatch;
2721 if(!(rVal >>= aUnoHatch))
2722 return false;
2724 aHatch.SetHatchStyle( aUnoHatch.Style );
2725 aHatch.SetColor( Color(ColorTransparency, aUnoHatch.Color) );
2726 aHatch.SetDistance( aUnoHatch.Distance );
2727 aHatch.SetAngle( Degree10(aUnoHatch.Angle) );
2728 break;
2731 case MID_NAME:
2733 OUString aName;
2734 if (!(rVal >>= aName ))
2735 return false;
2736 SetName( aName );
2737 break;
2740 case MID_HATCH_STYLE:
2742 sal_Int16 nVal = sal_Int16();
2743 if (!(rVal >>= nVal ))
2744 return false;
2745 aHatch.SetHatchStyle( static_cast<css::drawing::HatchStyle>(nVal) );
2746 break;
2749 case MID_HATCH_COLOR:
2750 case MID_HATCH_DISTANCE:
2751 case MID_HATCH_ANGLE:
2753 sal_Int32 nVal = 0;
2754 if (!(rVal >>= nVal ))
2755 return false;
2757 if ( nMemberId == MID_HATCH_COLOR )
2758 aHatch.SetColor( Color(ColorTransparency, nVal) );
2759 else if ( nMemberId == MID_HATCH_DISTANCE )
2760 aHatch.SetDistance( nVal );
2761 else
2762 aHatch.SetAngle( Degree10(nVal) );
2763 break;
2766 default: OSL_FAIL("Wrong MemberId!"); return false;
2769 return true;
2772 bool XFillHatchItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2774 return static_cast<const XFillHatchItem*>(p1)->GetHatchValue() == static_cast<const XFillHatchItem*>(p2)->GetHatchValue();
2777 std::unique_ptr<XFillHatchItem> XFillHatchItem::checkForUniqueItem( SdrModel* pModel ) const
2779 if( pModel )
2781 const OUString aUniqueName = NameOrIndex::CheckNamedItem(
2782 this, XATTR_FILLHATCH, &pModel->GetItemPool(),
2783 XFillHatchItem::CompareValueFunc, RID_SVXSTR_HATCH10,
2784 pModel->GetPropertyList( XPropertyListType::Hatch ) );
2786 // if the given name is not valid, replace it!
2787 if( aUniqueName != GetName() )
2788 return std::make_unique<XFillHatchItem>( aUniqueName, aHatch );
2791 return nullptr;
2794 // --- form text attributes ---
2797 SfxPoolItem* XFormTextStyleItem::CreateDefault() { return new XFormTextStyleItem; }
2799 XFormTextStyleItem::XFormTextStyleItem(XFormTextStyle eTheStyle) :
2800 SfxEnumItem(XATTR_FORMTXTSTYLE, eTheStyle)
2804 XFormTextStyleItem* XFormTextStyleItem::Clone(SfxItemPool* /*pPool*/) const
2806 return new XFormTextStyleItem( *this );
2809 sal_uInt16 XFormTextStyleItem::GetValueCount() const
2811 return 5;
2814 bool XFormTextStyleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2816 rVal <<= static_cast<sal_Int32>(GetValue());
2817 return true;
2820 bool XFormTextStyleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2822 sal_Int32 nValue = 0;
2823 rVal >>= nValue;
2824 SetValue(static_cast<XFormTextStyle>(nValue));
2826 return true;
2830 SfxPoolItem* XFormTextAdjustItem::CreateDefault() { return new XFormTextAdjustItem; }
2832 XFormTextAdjustItem::XFormTextAdjustItem(XFormTextAdjust eTheAdjust) :
2833 SfxEnumItem(XATTR_FORMTXTADJUST, eTheAdjust)
2837 XFormTextAdjustItem* XFormTextAdjustItem::Clone(SfxItemPool* /*pPool*/) const
2839 return new XFormTextAdjustItem( *this );
2842 sal_uInt16 XFormTextAdjustItem::GetValueCount() const
2844 return 4;
2847 bool XFormTextAdjustItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2849 rVal <<= static_cast<sal_Int32>(GetValue());
2850 return true;
2853 bool XFormTextAdjustItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2855 sal_Int32 nValue = 0;
2856 rVal >>= nValue;
2857 SetValue(static_cast<XFormTextAdjust>(nValue));
2859 return true;
2863 SfxPoolItem* XFormTextDistanceItem::CreateDefault() { return new XFormTextDistanceItem; }
2865 XFormTextDistanceItem::XFormTextDistanceItem(tools::Long nDist) :
2866 SfxMetricItem(XATTR_FORMTXTDISTANCE, nDist)
2870 XFormTextDistanceItem* XFormTextDistanceItem::Clone(SfxItemPool* /*pPool*/) const
2872 return new XFormTextDistanceItem(*this);
2875 SfxPoolItem* XFormTextStartItem::CreateDefault() { return new XFormTextStartItem; }
2877 XFormTextStartItem::XFormTextStartItem(tools::Long nStart) :
2878 SfxMetricItem(XATTR_FORMTXTSTART, nStart)
2882 XFormTextStartItem* XFormTextStartItem::Clone(SfxItemPool* /*pPool*/) const
2884 return new XFormTextStartItem(*this);
2887 SfxPoolItem* XFormTextMirrorItem::CreateDefault() { return new XFormTextMirrorItem; }
2889 XFormTextMirrorItem::XFormTextMirrorItem(bool bMirror) :
2890 SfxBoolItem(XATTR_FORMTXTMIRROR, bMirror)
2894 XFormTextMirrorItem* XFormTextMirrorItem::Clone(SfxItemPool* /*pPool*/) const
2896 return new XFormTextMirrorItem(*this);
2899 SfxPoolItem* XFormTextOutlineItem::CreateDefault() { return new XFormTextOutlineItem; }
2901 XFormTextOutlineItem::XFormTextOutlineItem(bool bOutline) :
2902 SfxBoolItem(XATTR_FORMTXTOUTLINE, bOutline)
2906 XFormTextOutlineItem* XFormTextOutlineItem::Clone(SfxItemPool* /*pPool*/) const
2908 return new XFormTextOutlineItem(*this);
2911 SfxPoolItem* XFormTextShadowItem::CreateDefault() { return new XFormTextShadowItem; }
2913 XFormTextShadowItem::XFormTextShadowItem(XFormTextShadow eFormTextShadow) :
2914 SfxEnumItem(XATTR_FORMTXTSHADOW, eFormTextShadow)
2918 XFormTextShadowItem* XFormTextShadowItem::Clone(SfxItemPool* /*pPool*/) const
2920 return new XFormTextShadowItem( *this );
2923 sal_uInt16 XFormTextShadowItem::GetValueCount() const
2925 return 3;
2928 bool XFormTextShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2930 rVal <<= static_cast<sal_Int32>(GetValue());
2931 return true;
2934 bool XFormTextShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2936 sal_Int32 nValue = 0;
2937 rVal >>= nValue;
2938 SetValue(static_cast<XFormTextShadow>(nValue));
2940 return true;
2944 SfxPoolItem* XFormTextShadowColorItem::CreateDefault() { return new XFormTextShadowColorItem; }
2946 XFormTextShadowColorItem::XFormTextShadowColorItem(const OUString& rName,
2947 const Color& rTheColor) :
2948 XColorItem(XATTR_FORMTXTSHDWCOLOR, rName, rTheColor)
2952 XFormTextShadowColorItem* XFormTextShadowColorItem::Clone(SfxItemPool* /*pPool*/) const
2954 return new XFormTextShadowColorItem(*this);
2957 SfxPoolItem* XFormTextShadowXValItem::CreateDefault() { return new XFormTextShadowXValItem; }
2959 XFormTextShadowXValItem::XFormTextShadowXValItem(tools::Long nVal) :
2960 SfxMetricItem(XATTR_FORMTXTSHDWXVAL, nVal)
2964 XFormTextShadowXValItem* XFormTextShadowXValItem::Clone(SfxItemPool* /*pPool*/) const
2966 return new XFormTextShadowXValItem(*this);
2969 SfxPoolItem* XFormTextShadowYValItem::CreateDefault() { return new XFormTextShadowYValItem; }
2971 XFormTextShadowYValItem::XFormTextShadowYValItem(tools::Long nVal) :
2972 SfxMetricItem(XATTR_FORMTXTSHDWYVAL, nVal)
2976 XFormTextShadowYValItem* XFormTextShadowYValItem::Clone(SfxItemPool* /*pPool*/) const
2978 return new XFormTextShadowYValItem(*this);
2981 SfxPoolItem* XFormTextHideFormItem::CreateDefault() { return new XFormTextHideFormItem; }
2983 XFormTextHideFormItem::XFormTextHideFormItem(bool bHide) :
2984 SfxBoolItem(XATTR_FORMTXTHIDEFORM, bHide)
2988 XFormTextHideFormItem* XFormTextHideFormItem::Clone(SfxItemPool* /*pPool*/) const
2990 return new XFormTextHideFormItem(*this);
2993 // --- SetItems ---
2996 /// a line attribute set item
2997 XLineAttrSetItem::XLineAttrSetItem( SfxItemSet&& pItemSet ) :
2998 SfxSetItem( XATTRSET_LINE, std::move(pItemSet))
3002 XLineAttrSetItem::XLineAttrSetItem( SfxItemPool* pItemPool ) :
3003 SfxSetItem( XATTRSET_LINE,
3004 SfxItemSetFixed<XATTR_LINE_FIRST, XATTR_LINE_LAST>( *pItemPool ))
3008 XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr ) :
3009 SfxSetItem( rLineAttr )
3013 XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr,
3014 SfxItemPool* pItemPool) :
3015 SfxSetItem( rLineAttr, pItemPool )
3019 XLineAttrSetItem* XLineAttrSetItem::Clone( SfxItemPool* pPool ) const
3021 return new XLineAttrSetItem( *this, pPool );
3024 /// fill attribute set item
3025 XFillAttrSetItem::XFillAttrSetItem( SfxItemSet&& pItemSet ) :
3026 SfxSetItem( XATTRSET_FILL, std::move(pItemSet))
3030 XFillAttrSetItem::XFillAttrSetItem( SfxItemPool* pItemPool ) :
3031 SfxSetItem( XATTRSET_FILL,
3032 SfxItemSetFixed<XATTR_FILL_FIRST, XATTR_FILL_LAST>( *pItemPool ))
3036 XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr ) :
3037 SfxSetItem( rFillAttr )
3041 XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr,
3042 SfxItemPool* pItemPool ) :
3043 SfxSetItem( rFillAttr, pItemPool )
3047 XFillAttrSetItem* XFillAttrSetItem::Clone( SfxItemPool* pPool ) const
3049 return new XFillAttrSetItem( *this, pPool );
3052 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */