Version 7.1.7.1, tag libreoffice-7.1.7.1
[LibreOffice.git] / svx / source / xoutdev / xattr.cxx
blob38040f72e460c2b1d5fbb9c769ac14758b6c227f
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>
33 #include <o3tl/any.hxx>
34 #include <svl/itempool.hxx>
35 #include <editeng/memberids.h>
36 #include <tools/mapunit.hxx>
37 #include <tools/UnitConversion.hxx>
38 #include <osl/diagnose.h>
40 #include <svx/unoapi.hxx>
41 #include <svl/style.hxx>
43 #include <tools/bigint.hxx>
44 #include <svl/itemset.hxx>
45 #include <svx/strings.hrc>
46 #include <svx/xfillit0.hxx>
47 #include <svx/xflasit.hxx>
48 #include <svx/xlineit0.hxx>
49 #include <svx/xlnasit.hxx>
50 #include <svx/xtextit0.hxx>
51 #include <svx/xtable.hxx>
52 #include <svx/dialmgr.hxx>
53 #include <svx/xflclit.hxx>
54 #include <svx/xflgrit.hxx>
55 #include <svx/xflftrit.hxx>
56 #include <svx/xsflclit.hxx>
57 #include <svx/xflhtit.hxx>
58 #include <svx/xbtmpit.hxx>
59 #include <svx/xlndsit.hxx>
60 #include <svx/xlnwtit.hxx>
61 #include <svx/xlnclit.hxx>
62 #include <svx/xlnstit.hxx>
63 #include <svx/xlnedit.hxx>
64 #include <svx/xlnstwit.hxx>
65 #include <svx/xlnedwit.hxx>
66 #include <svx/xlnstcit.hxx>
67 #include <svx/xlnedcit.hxx>
68 #include <editeng/itemtype.hxx>
69 #include <editeng/eerdll.hxx>
70 #include <svx/xdef.hxx>
71 #include <svx/unomid.hxx>
72 #include <svx/svdmodel.hxx>
73 #include <svx/xftdiit.hxx>
74 #include <svx/xftstit.hxx>
75 #include <svx/xftmrit.hxx>
76 #include <svx/xftouit.hxx>
77 #include <svx/xftshit.hxx>
78 #include <svx/xftshcit.hxx>
79 #include <svx/xftshxy.hxx>
80 #include <svx/xftadit.hxx>
81 #include <svx/svddef.hxx>
82 #include <basegfx/polygon/b2dpolypolygontools.hxx>
83 #include <unotools/intlwrapper.hxx>
84 #include <unotools/syslocale.hxx>
85 #include <string>
87 #include <boost/property_tree/json_parser.hpp>
88 #include <libxml/xmlwriter.h>
90 using namespace ::com::sun::star;
92 typedef std::map<OUString, OUString> StringMap;
94 static tools::Long ScaleMetricValue( tools::Long nVal, tools::Long nMul, tools::Long nDiv )
96 BigInt aVal( nVal );
98 aVal *= nMul;
100 if ( aVal.IsNeg() != ( nDiv < 0 ) )
101 aVal-=nDiv/2; // for correct rounding
102 else
103 aVal+=nDiv/2; // for correct rounding
105 aVal/=nDiv;
107 return tools::Long( aVal );
110 NameOrIndex::NameOrIndex(sal_uInt16 _nWhich, sal_Int32 nIndex) :
111 SfxStringItem(_nWhich, OUString()),
112 nPalIndex(nIndex)
116 NameOrIndex::NameOrIndex(sal_uInt16 _nWhich, const OUString& rName) :
117 SfxStringItem(_nWhich, rName),
118 nPalIndex(-1)
122 NameOrIndex::NameOrIndex(const NameOrIndex& rNameOrIndex) :
123 SfxStringItem(rNameOrIndex),
124 nPalIndex(rNameOrIndex.nPalIndex)
128 bool NameOrIndex::operator==(const SfxPoolItem& rItem) const
130 return ( SfxStringItem::operator==(rItem) &&
131 static_cast<const NameOrIndex&>(rItem).nPalIndex == nPalIndex );
134 NameOrIndex* NameOrIndex::Clone(SfxItemPool* /*pPool*/) const
136 return new NameOrIndex(*this);
139 /** this static checks if the given NameOrIndex item has a unique name for its value.
140 The returned String is a unique name for an item with this value in both given pools.
141 Argument pPool2 can be null.
142 If returned string equals NameOrIndex->GetName(), the name was already unique.
144 OUString NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_uInt16 nWhich, const SfxItemPool* pPool1, SvxCompareValueFunc pCompareValueFunc, const char* pPrefixResId, const XPropertyListRef &pDefaults )
146 bool bForceNew = false;
148 OUString aUniqueName = SvxUnogetInternalNameForItem(nWhich, pCheckItem->GetName());
150 // 2. if we have a name check if there is already an item with the
151 // same name in the documents pool with a different line end or start
153 if (!aUniqueName.isEmpty() && pPool1)
155 for (const SfxPoolItem* pItem : pPool1->GetItemSurrogates(nWhich))
157 const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
159 if( pNameOrIndex->GetName() == pCheckItem->GetName() )
161 // if there is already an item with the same name and the same
162 // value it's ok to set it
163 if( !pCompareValueFunc( pNameOrIndex, pCheckItem ) )
165 // same name but different value, we need a new name for this item
166 aUniqueName.clear();
167 bForceNew = true;
169 break;
174 // if we have no name yet, find existing item with same content or
175 // create a unique name
176 if (aUniqueName.isEmpty())
178 sal_Int32 nUserIndex = 1;
179 const OUString aUser(SvxResId(pPrefixResId) + " ");
181 if( pDefaults )
183 const int nCount = pDefaults->Count();
184 int nIndex;
185 for( nIndex = 0; nIndex < nCount; nIndex++ )
187 const XPropertyEntry* pEntry = pDefaults->Get(nIndex);
188 if( pEntry )
190 bool bFound = false;
192 switch( nWhich )
194 case XATTR_FILLBITMAP:
196 const GraphicObject& rGraphicObjectA(static_cast<const XFillBitmapItem*>(pCheckItem)->GetGraphicObject());
197 const GraphicObject& rGraphicObjectB(static_cast<const XBitmapEntry*>(pEntry)->GetGraphicObject());
199 bFound = (rGraphicObjectA == rGraphicObjectB);
200 break;
202 case XATTR_LINEDASH:
203 bFound = static_cast<const XLineDashItem*>(pCheckItem)->GetDashValue() == static_cast<const XDashEntry*>(pEntry)->GetDash();
204 break;
205 case XATTR_LINESTART:
206 bFound = static_cast<const XLineStartItem*>(pCheckItem)->GetLineStartValue() == static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd();
207 break;
208 case XATTR_LINEEND:
209 bFound = static_cast<const XLineEndItem*>(pCheckItem)->GetLineEndValue() == static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd();
210 break;
211 case XATTR_FILLGRADIENT:
212 bFound = static_cast<const XFillGradientItem*>(pCheckItem)->GetGradientValue() == static_cast<const XGradientEntry*>(pEntry)->GetGradient();
213 break;
214 case XATTR_FILLHATCH:
215 bFound = static_cast<const XFillHatchItem*>(pCheckItem)->GetHatchValue() == static_cast<const XHatchEntry*>(pEntry)->GetHatch();
216 break;
219 if( bFound )
221 aUniqueName = pEntry->GetName();
222 break;
224 else
226 const OUString& aEntryName = pEntry->GetName();
227 if(aEntryName.getLength() >= aUser.getLength())
229 sal_Int32 nThisIndex = aEntryName.copy( aUser.getLength() ).toInt32();
230 if( nThisIndex >= nUserIndex )
231 nUserIndex = nThisIndex + 1;
238 if (aUniqueName.isEmpty() && pPool1)
240 for (const SfxPoolItem* pItem : pPool1->GetItemSurrogates(nWhich))
242 const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
244 if( !pNameOrIndex->GetName().isEmpty() )
246 if( !bForceNew && pCompareValueFunc( pNameOrIndex, pCheckItem ) )
247 return pNameOrIndex->GetName();
249 if( pNameOrIndex->GetName().startsWith( aUser ) )
251 sal_Int32 nThisIndex = pNameOrIndex->GetName().copy( aUser.getLength() ).toInt32();
252 if( nThisIndex >= nUserIndex )
253 nUserIndex = nThisIndex + 1;
257 aUniqueName = aUser + OUString::number( nUserIndex );
261 return aUniqueName;
264 void NameOrIndex::dumpAsXml(xmlTextWriterPtr pWriter) const
266 xmlTextWriterStartElement(pWriter, BAD_CAST("NameOrIndex"));
267 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
268 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("isIndex"), BAD_CAST(OString::boolean(IsIndex()).getStr()));
269 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(GetName().toUtf8().getStr()));
270 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("index"), BAD_CAST(OString::number(nPalIndex).getStr()));
271 xmlTextWriterEndElement(pWriter);
274 SfxPoolItem* XColorItem::CreateDefault() { return new XColorItem; }
276 XColorItem::XColorItem(sal_uInt16 _nWhich, sal_Int32 nIndex, const Color& rTheColor) :
277 NameOrIndex(_nWhich, nIndex),
278 aColor(rTheColor)
282 XColorItem::XColorItem(sal_uInt16 _nWhich, const OUString& rName, const Color& rTheColor) :
283 NameOrIndex(_nWhich, rName),
284 aColor(rTheColor)
288 XColorItem::XColorItem(sal_uInt16 _nWhich, const Color& rTheColor)
289 : NameOrIndex(_nWhich, OUString())
290 , aColor(rTheColor)
294 XColorItem::XColorItem(const XColorItem& rItem) :
295 NameOrIndex(rItem),
296 aColor(rItem.aColor)
300 XColorItem* XColorItem::Clone(SfxItemPool* /*pPool*/) const
302 return new XColorItem(*this);
305 bool XColorItem::operator==(const SfxPoolItem& rItem) const
307 return ( NameOrIndex::operator==(rItem) &&
308 static_cast<const XColorItem&>(rItem).aColor == aColor );
311 const Color& XColorItem::GetColorValue() const
313 assert(!IsIndex());
314 return aColor;
318 bool XColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
320 rVal <<= GetColorValue().GetRGBColor();
321 return true;
324 bool XColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
326 sal_Int32 nValue = 0;
327 rVal >>= nValue;
328 SetColorValue( Color(nValue) );
330 return true;
333 void XColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
335 xmlTextWriterStartElement(pWriter, BAD_CAST("XColorItem"));
336 if (Which() == SDRATTR_SHADOWCOLOR)
338 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("SDRATTR_SHADOWCOLOR"));
340 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("aColor"),
341 BAD_CAST(aColor.AsRGBHexString().toUtf8().getStr()));
343 NameOrIndex::dumpAsXml(pWriter);
345 xmlTextWriterEndElement(pWriter);
348 // --- line attributes ---
351 SfxPoolItem* XLineStyleItem::CreateDefault() { return new XLineStyleItem; }
353 XLineStyleItem::XLineStyleItem(css::drawing::LineStyle eTheLineStyle) :
354 SfxEnumItem(XATTR_LINESTYLE, eTheLineStyle)
358 XLineStyleItem* XLineStyleItem::Clone(SfxItemPool* /*pPool*/) const
360 return new XLineStyleItem( *this );
363 bool XLineStyleItem::GetPresentation
365 SfxItemPresentation /*ePres*/,
366 MapUnit /*eCoreUnit*/,
367 MapUnit /*ePresUnit*/,
368 OUString& rText, const IntlWrapper&
369 ) const
371 rText.clear();
373 const char* pId = nullptr;
375 switch( GetValue() )
377 case css::drawing::LineStyle_NONE:
378 pId = RID_SVXSTR_INVISIBLE;
379 break;
380 case css::drawing::LineStyle_SOLID:
381 pId = RID_SVXSTR_SOLID;
382 break;
383 default: break;
386 if (pId)
387 rText = SvxResId(pId);
388 return true;
391 bool XLineStyleItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
393 css::drawing::LineStyle eLS = GetValue();
394 rVal <<= eLS;
395 return true;
398 bool XLineStyleItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
400 css::drawing::LineStyle eLS;
401 if(!(rVal >>= eLS ))
403 // also try an int (for Basic)
404 sal_Int32 nLS = 0;
405 if(!(rVal >>= nLS))
406 return false;
407 eLS = static_cast<css::drawing::LineStyle>(nLS);
410 SetValue( eLS );
411 return true;
414 sal_uInt16 XLineStyleItem::GetValueCount() const
416 return 3;
419 XDash::XDash(css::drawing::DashStyle eTheDash, sal_uInt16 nTheDots, double nTheDotLen,
420 sal_uInt16 nTheDashes, double nTheDashLen, double nTheDistance) :
421 eDash(eTheDash),
422 nDots(nTheDots),
423 nDashes(nTheDashes),
424 nDotLen(nTheDotLen),
425 nDashLen(nTheDashLen),
426 nDistance(nTheDistance)
430 bool XDash::operator==(const XDash& rDash) const
432 return ( eDash == rDash.eDash &&
433 nDots == rDash.nDots &&
434 nDotLen == rDash.nDotLen &&
435 nDashes == rDash.nDashes &&
436 nDashLen == rDash.nDashLen &&
437 nDistance == rDash.nDistance );
440 // XDash is translated into an array of doubles which describe the lengths of the
441 // dashes, dots and empty passages. It returns the complete length of the full DashDot
442 // sequence and fills the given vetor of doubles accordingly (also resizing, so deleting it).
443 const double SMALLEST_DASH_WIDTH(26.95);
445 double XDash::CreateDotDashArray(::std::vector< double >& rDotDashArray, double fLineWidth) const
447 double fFullDotDashLen(0.0);
448 const sal_uInt16 nNumDotDashArray = (GetDots() + GetDashes()) * 2;
449 rDotDashArray.resize( nNumDotDashArray, 0.0 );
450 sal_uInt16 a;
451 sal_uInt16 nIns(0);
452 double fDashDotDistance = GetDistance();
453 double fSingleDashLen = GetDashLen();
454 double fSingleDotLen = GetDotLen();
456 if (fLineWidth == 0.0)
457 fLineWidth = SMALLEST_DASH_WIDTH;
459 if(GetDashStyle() == css::drawing::DashStyle_RECTRELATIVE || GetDashStyle() == css::drawing::DashStyle_ROUNDRELATIVE)
461 double fFactor = fLineWidth / 100.0;
463 if(GetDashes())
465 if(GetDashLen())
467 // is a dash
468 fSingleDashLen *= fFactor;
470 else
472 // is a dot
473 fSingleDashLen = fLineWidth;
477 if(GetDots())
479 if(GetDotLen())
481 // is a dash
482 fSingleDotLen *= fFactor;
484 else
486 // is a dot
487 fSingleDotLen = fLineWidth;
491 if(GetDashes() || GetDots())
493 if(GetDistance())
495 // dash as distance
496 fDashDotDistance *= fFactor;
498 else
500 // dot as distance
501 fDashDotDistance = fLineWidth;
505 else
507 // absolute values
508 if(GetDashes())
510 if(GetDashLen())
512 // is a dash
513 if(fSingleDashLen < SMALLEST_DASH_WIDTH)
515 fSingleDashLen = SMALLEST_DASH_WIDTH;
518 else
520 // is a dot
521 if(fSingleDashLen < fLineWidth)
523 fSingleDashLen = fLineWidth;
528 if(GetDots())
530 if(GetDotLen())
532 // is a dash
533 if(fSingleDotLen < SMALLEST_DASH_WIDTH)
535 fSingleDotLen = SMALLEST_DASH_WIDTH;
538 else
540 // is a dot
541 if(fSingleDotLen < fLineWidth)
543 fSingleDotLen = fLineWidth;
548 if(GetDashes() || GetDots())
550 if(GetDistance())
552 // dash as distance
553 if(fDashDotDistance < SMALLEST_DASH_WIDTH)
555 fDashDotDistance = SMALLEST_DASH_WIDTH;
558 else
560 // dot as distance
561 if(fDashDotDistance < fLineWidth)
563 fDashDotDistance = fLineWidth;
569 for(a=0;a<GetDots();a++)
571 rDotDashArray[nIns++] = fSingleDotLen;
572 fFullDotDashLen += fSingleDotLen;
573 rDotDashArray[nIns++] = fDashDotDistance;
574 fFullDotDashLen += fDashDotDistance;
577 for(a=0;a<GetDashes();a++)
579 rDotDashArray[nIns++] = fSingleDashLen;
580 fFullDotDashLen += fSingleDashLen;
581 rDotDashArray[nIns++] = fDashDotDistance;
582 fFullDotDashLen += fDashDotDistance;
585 return fFullDotDashLen;
588 SfxPoolItem* XLineDashItem::CreateDefault() {return new XLineDashItem;}
590 XLineDashItem::XLineDashItem(const OUString& rName, const XDash& rTheDash) :
591 NameOrIndex(XATTR_LINEDASH, rName),
592 aDash(rTheDash)
596 XLineDashItem::XLineDashItem(const XLineDashItem& rItem) :
597 NameOrIndex(rItem),
598 aDash(rItem.aDash)
602 XLineDashItem::XLineDashItem(const XDash& rTheDash)
603 : NameOrIndex( XATTR_LINEDASH, -1 ),
604 aDash(rTheDash)
608 XLineDashItem* XLineDashItem::Clone(SfxItemPool* /*pPool*/) const
610 return new XLineDashItem(*this);
613 bool XLineDashItem::operator==(const SfxPoolItem& rItem) const
615 return ( NameOrIndex::operator==(rItem) &&
616 aDash == static_cast<const XLineDashItem&>(rItem).aDash );
619 bool XLineDashItem::GetPresentation
621 SfxItemPresentation /*ePres*/,
622 MapUnit /*eCoreUnit*/,
623 MapUnit /*ePresUnit*/,
624 OUString& rText, const IntlWrapper&
625 ) const
627 rText = GetName();
628 return true;
631 bool XLineDashItem::HasMetrics() const
633 return true;
636 void XLineDashItem::ScaleMetrics(tools::Long nMul, tools::Long nDiv)
638 aDash.SetDotLen( ScaleMetricValue( aDash.GetDotLen(), nMul, nDiv ) );
639 aDash.SetDashLen( ScaleMetricValue( aDash.GetDashLen(), nMul, nDiv ) );
640 aDash.SetDistance( ScaleMetricValue( aDash.GetDistance(), nMul, nDiv ) );
643 bool XLineDashItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
645 nMemberId &= ~CONVERT_TWIPS;
647 switch ( nMemberId )
649 case 0:
651 uno::Sequence< beans::PropertyValue > aPropSeq( 2 );
653 css::drawing::LineDash aLineDash;
655 const XDash& rXD = GetDashValue();
656 aLineDash.Style = static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(rXD.GetDashStyle()));
657 aLineDash.Dots = rXD.GetDots();
658 aLineDash.DotLen = rXD.GetDotLen();
659 aLineDash.Dashes = rXD.GetDashes();
660 aLineDash.DashLen = rXD.GetDashLen();
661 aLineDash.Distance = rXD.GetDistance();
663 aPropSeq[0].Name = "Name";
664 aPropSeq[0].Value <<= SvxUnogetApiNameForItem(Which(), GetName());
665 aPropSeq[1].Name = "LineDash";
666 aPropSeq[1].Value <<= aLineDash;
667 rVal <<= aPropSeq;
668 break;
671 case MID_NAME:
673 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
674 break;
677 case MID_LINEDASH:
679 const XDash& rXD = GetDashValue();
681 css::drawing::LineDash aLineDash;
683 aLineDash.Style = static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(rXD.GetDashStyle()));
684 aLineDash.Dots = rXD.GetDots();
685 aLineDash.DotLen = rXD.GetDotLen();
686 aLineDash.Dashes = rXD.GetDashes();
687 aLineDash.DashLen = rXD.GetDashLen();
688 aLineDash.Distance = rXD.GetDistance();
690 rVal <<= aLineDash;
691 break;
694 case MID_LINEDASH_STYLE:
696 const XDash& rXD = GetDashValue();
697 rVal <<= static_cast<css::drawing::DashStyle>(static_cast<sal_Int16>(rXD.GetDashStyle()));
698 break;
701 case MID_LINEDASH_DOTS:
703 const XDash& rXD = GetDashValue();
704 rVal <<= rXD.GetDots();
705 break;
708 case MID_LINEDASH_DOTLEN:
710 const XDash& rXD = GetDashValue();
711 rVal <<= rXD.GetDotLen();
712 break;
715 case MID_LINEDASH_DASHES:
717 const XDash& rXD = GetDashValue();
718 rVal <<= rXD.GetDashes();
719 break;
722 case MID_LINEDASH_DASHLEN:
724 const XDash& rXD = GetDashValue();
725 rVal <<= rXD.GetDashLen();
726 break;
729 case MID_LINEDASH_DISTANCE:
731 const XDash& rXD = GetDashValue();
732 rVal <<= rXD.GetDistance();
733 break;
736 default: OSL_FAIL("Wrong MemberId!"); return false;
739 return true;
742 bool XLineDashItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
744 nMemberId &= ~CONVERT_TWIPS;
746 switch ( nMemberId )
748 case 0:
750 uno::Sequence< beans::PropertyValue > aPropSeq;
752 if ( rVal >>= aPropSeq )
754 css::drawing::LineDash aLineDash;
755 OUString aName;
756 bool bLineDash( false );
757 for ( const auto& rProp : std::as_const(aPropSeq) )
759 if ( rProp.Name == "Name" )
760 rProp.Value >>= aName;
761 else if ( rProp.Name == "LineDash" )
763 if ( rProp.Value >>= aLineDash )
764 bLineDash = true;
768 SetName( aName );
769 if ( bLineDash )
771 XDash aXDash;
773 aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(aLineDash.Style)));
774 aXDash.SetDots(aLineDash.Dots);
775 aXDash.SetDotLen(aLineDash.DotLen);
776 aXDash.SetDashes(aLineDash.Dashes);
777 aXDash.SetDashLen(aLineDash.DashLen);
778 aXDash.SetDistance(aLineDash.Distance);
780 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
781 aXDash.SetDots(1);
783 SetDashValue( aXDash );
786 return true;
789 return false;
792 case MID_NAME:
794 OUString aName;
795 if (!(rVal >>= aName))
796 return false;
797 SetName( aName );
798 break;
801 case MID_LINEDASH:
803 css::drawing::LineDash aLineDash;
804 if(!(rVal >>= aLineDash))
805 return false;
807 XDash aXDash;
809 aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(aLineDash.Style)));
810 aXDash.SetDots(aLineDash.Dots);
811 aXDash.SetDotLen(aLineDash.DotLen);
812 aXDash.SetDashes(aLineDash.Dashes);
813 aXDash.SetDashLen(aLineDash.DashLen);
814 aXDash.SetDistance(aLineDash.Distance);
816 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
817 aXDash.SetDots(1);
819 SetDashValue( aXDash );
820 break;
823 case MID_LINEDASH_STYLE:
825 sal_Int16 nVal = sal_Int16();
826 if(!(rVal >>= nVal))
827 return false;
829 XDash aXDash = GetDashValue();
830 aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(nVal)));
832 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
833 aXDash.SetDots(1);
835 SetDashValue( aXDash );
837 break;
840 case MID_LINEDASH_DOTS:
841 case MID_LINEDASH_DASHES:
843 sal_Int16 nVal = sal_Int16();
844 if(!(rVal >>= nVal))
845 return false;
847 XDash aXDash = GetDashValue();
848 if ( nMemberId == MID_LINEDASH_DOTS )
849 aXDash.SetDots( nVal );
850 else
851 aXDash.SetDashes( nVal );
853 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
854 aXDash.SetDots(1);
856 SetDashValue( aXDash );
857 break;
860 case MID_LINEDASH_DOTLEN:
861 case MID_LINEDASH_DASHLEN:
862 case MID_LINEDASH_DISTANCE:
864 sal_uInt32 nVal = 0;
865 if(!(rVal >>= nVal))
866 return false;
868 XDash aXDash = GetDashValue();
869 if ( nMemberId == MID_LINEDASH_DOTLEN )
870 aXDash.SetDotLen( nVal );
871 else if ( nMemberId == MID_LINEDASH_DASHLEN )
872 aXDash.SetDashLen( nVal );
873 else
874 aXDash.SetDistance( nVal );
876 if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
877 aXDash.SetDots(1);
879 SetDashValue( aXDash );
880 break;
884 return true;
887 bool XLineDashItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
889 return static_cast<const XLineDashItem*>(p1)->GetDashValue() == static_cast<const XLineDashItem*>(p2)->GetDashValue();
892 std::unique_ptr<XLineDashItem> XLineDashItem::checkForUniqueItem( SdrModel* pModel ) const
894 if( pModel )
896 const OUString aUniqueName = NameOrIndex::CheckNamedItem(
897 this, XATTR_LINEDASH, &pModel->GetItemPool(),
898 XLineDashItem::CompareValueFunc, RID_SVXSTR_DASH20,
899 pModel->GetPropertyList( XPropertyListType::Dash ) );
901 // if the given name is not valid, replace it!
902 if( aUniqueName != GetName() )
903 return std::make_unique<XLineDashItem>( aUniqueName, aDash );
906 return nullptr;
909 SfxPoolItem* XLineWidthItem::CreateDefault() {return new XLineWidthItem;}
911 XLineWidthItem::XLineWidthItem(tools::Long nWidth) :
912 SfxMetricItem(XATTR_LINEWIDTH, nWidth)
916 XLineWidthItem* XLineWidthItem::Clone(SfxItemPool* /*pPool*/) const
918 return new XLineWidthItem(*this);
921 bool XLineWidthItem::GetPresentation
923 SfxItemPresentation /*ePres*/,
924 MapUnit eCoreUnit,
925 MapUnit ePresUnit,
926 OUString& rText, const IntlWrapper& rIntl
927 ) const
929 rText = GetMetricText( static_cast<tools::Long>(GetValue()),
930 eCoreUnit, ePresUnit, &rIntl) +
931 " " + EditResId( GetMetricId( ePresUnit) );
932 return true;
935 bool XLineWidthItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
937 sal_Int32 nValue = GetValue();
938 if( 0 != (nMemberId&CONVERT_TWIPS) )
939 nValue = convertTwipToMm100(nValue);
941 rVal <<= nValue;
942 return true;
945 bool XLineWidthItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
947 sal_Int32 nValue = 0;
948 rVal >>= nValue;
949 if( 0 != (nMemberId&CONVERT_TWIPS) )
950 nValue = convertMm100ToTwip(nValue);
952 SetValue( nValue );
953 return true;
956 SfxPoolItem* XLineColorItem::CreateDefault() { return new XLineColorItem; }
958 XLineColorItem::XLineColorItem(sal_Int32 nIndex, const Color& rTheColor) :
959 XColorItem(XATTR_LINECOLOR, nIndex, rTheColor)
963 XLineColorItem::XLineColorItem(const OUString& rName, const Color& rTheColor) :
964 XColorItem(XATTR_LINECOLOR, rName, rTheColor)
968 XLineColorItem* XLineColorItem::Clone(SfxItemPool* /*pPool*/) const
970 return new XLineColorItem(*this);
973 bool XLineColorItem::GetPresentation
975 SfxItemPresentation /*ePres*/,
976 MapUnit /*eCoreUnit*/,
977 MapUnit /*ePresUnit*/,
978 OUString& rText, const IntlWrapper&
979 ) const
981 rText = GetName();
982 return true;
985 bool XLineColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
987 rVal <<= GetColorValue().GetRGBColor();
988 return true;
991 bool XLineColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
993 sal_Int32 nValue = 0;
994 if(!(rVal >>= nValue))
995 return false;
997 SetColorValue( Color(nValue) );
998 return true;
1002 SfxPoolItem* XLineStartItem::CreateDefault() {return new XLineStartItem;}
1004 XLineStartItem::XLineStartItem(sal_Int32 nIndex)
1005 : NameOrIndex(XATTR_LINESTART, nIndex)
1009 XLineStartItem::XLineStartItem(const OUString& rName, const basegfx::B2DPolyPolygon& rPolyPolygon)
1010 : NameOrIndex(XATTR_LINESTART, rName),
1011 maPolyPolygon(rPolyPolygon)
1015 XLineStartItem::XLineStartItem(const XLineStartItem& rItem)
1016 : NameOrIndex(rItem),
1017 maPolyPolygon(rItem.maPolyPolygon)
1021 XLineStartItem::XLineStartItem(const basegfx::B2DPolyPolygon& rPolyPolygon)
1022 : NameOrIndex( XATTR_LINESTART, -1 ),
1023 maPolyPolygon(rPolyPolygon)
1027 XLineStartItem* XLineStartItem::Clone(SfxItemPool* /*pPool*/) const
1029 return new XLineStartItem(*this);
1032 bool XLineStartItem::operator==(const SfxPoolItem& rItem) const
1034 return ( NameOrIndex::operator==(rItem) && static_cast<const XLineStartItem&>(rItem).maPolyPolygon == maPolyPolygon );
1037 bool XLineStartItem::GetPresentation
1039 SfxItemPresentation /*ePres*/,
1040 MapUnit /*eCoreUnit*/,
1041 MapUnit /*ePresUnit*/,
1042 OUString& rText, const IntlWrapper&
1043 ) const
1045 rText = GetName();
1046 return true;
1049 bool XLineStartItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
1051 nMemberId &= ~CONVERT_TWIPS;
1052 if( nMemberId == MID_NAME )
1054 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
1056 else
1058 css::drawing::PolyPolygonBezierCoords aBezier;
1059 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( maPolyPolygon, aBezier );
1060 rVal <<= aBezier;
1063 return true;
1066 bool XLineStartItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
1068 nMemberId &= ~CONVERT_TWIPS;
1069 if( nMemberId == MID_NAME )
1071 return false;
1073 else
1075 maPolyPolygon.clear();
1077 if( rVal.hasValue() )
1079 auto pCoords = o3tl::tryAccess<css::drawing::PolyPolygonBezierCoords>(
1080 rVal);
1081 if( !pCoords )
1082 return false;
1084 if( pCoords->Coordinates.getLength() > 0 )
1086 maPolyPolygon = basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( *pCoords );
1087 // #i72807# close line start/end polygons hard
1088 // maPolyPolygon.setClosed(true);
1093 return true;
1096 /** this function searches in both the models pool and the styles pool for XLineStartItem
1097 and XLineEndItem with the same value or name and returns an item with the value of
1098 this item and a unique name for an item with this value. */
1099 std::unique_ptr<XLineStartItem> XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const
1101 if( pModel )
1103 std::unique_ptr<XLineStartItem> pTempItem;
1104 const XLineStartItem* pLineStartItem = this;
1106 OUString aUniqueName( GetName() );
1108 if( !maPolyPolygon.count() )
1110 // if the polygon is empty, check if the name is empty
1111 if( aUniqueName.isEmpty() )
1112 return nullptr;
1114 // force empty name for empty polygons
1115 return std::make_unique<XLineStartItem>( "", maPolyPolygon );
1118 if( maPolyPolygon.count() > 1 )
1120 // check if the polygon is closed
1121 if(!maPolyPolygon.isClosed())
1123 // force a closed polygon
1124 basegfx::B2DPolyPolygon aNew(maPolyPolygon);
1125 aNew.setClosed(true);
1126 pTempItem.reset(new XLineStartItem( aUniqueName, aNew ));
1127 pLineStartItem = pTempItem.get();
1131 bool bForceNew = false;
1133 // 2. if we have a name check if there is already an item with the
1134 // same name in the documents pool with a different line end or start
1136 const SfxItemPool& rPool1 = pModel->GetItemPool();
1137 if (!aUniqueName.isEmpty())
1139 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
1141 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1143 if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
1145 // if there is already an item with the same name and the same
1146 // value it's ok to set it
1147 if( pItem->GetLineStartValue() != pLineStartItem->GetLineStartValue() )
1149 // same name but different value, we need a new name for this item
1150 aUniqueName.clear();
1151 bForceNew = true;
1153 break;
1157 if( !bForceNew )
1159 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
1161 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1163 if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
1165 // if there is already an item with the same name and the same
1166 // value it's ok to set it
1167 if( pItem->GetLineEndValue() != pLineStartItem->GetLineStartValue() )
1169 // same name but different value, we need a new name for this item
1170 aUniqueName.clear();
1171 bForceNew = true;
1173 break;
1179 const SfxItemPool* pPool2 = pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : nullptr;
1180 if( !aUniqueName.isEmpty() && pPool2)
1182 for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINESTART))
1184 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1186 if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
1188 // if there is already an item with the same name and the same
1189 // value it's ok to set it
1190 if( pItem->GetLineStartValue() != pLineStartItem->GetLineStartValue() )
1192 // same name but different value, we need a new name for this item
1193 aUniqueName.clear();
1194 bForceNew = true;
1196 break;
1200 if( !bForceNew )
1202 for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINEEND))
1204 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1206 if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
1208 // if there is already an item with the same name and the same
1209 // value it's ok to set it
1210 if( pItem->GetLineEndValue() != pLineStartItem->GetLineStartValue() )
1212 // same name but different value, we need a new name for this item
1213 aUniqueName.clear();
1214 bForceNew = true;
1216 break;
1222 // if we have no name yet, find existing item with same content or
1223 // create a unique name
1224 if( aUniqueName.isEmpty() )
1226 bool bFoundExisting = false;
1228 sal_Int32 nUserIndex = 1;
1229 const OUString aUser(SvxResId(RID_SVXSTR_LINEEND));
1231 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
1233 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1235 if (pItem && !pItem->GetName().isEmpty())
1237 if (!bForceNew && pItem->GetLineStartValue() == pLineStartItem->GetLineStartValue())
1239 aUniqueName = pItem->GetName();
1240 bFoundExisting = true;
1241 break;
1244 if (pItem->GetName().startsWith(aUser))
1246 sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32();
1247 if (nThisIndex >= nUserIndex)
1248 nUserIndex = nThisIndex + 1;
1253 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
1255 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1257 if (pItem && !pItem->GetName().isEmpty())
1259 if (!bForceNew && pItem->GetLineEndValue() == pLineStartItem->GetLineStartValue())
1261 aUniqueName = pItem->GetName();
1262 bFoundExisting = true;
1263 break;
1266 if (pItem->GetName().startsWith(aUser))
1268 sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32();
1269 if (nThisIndex >= nUserIndex)
1270 nUserIndex = nThisIndex + 1;
1275 if( !bFoundExisting )
1277 aUniqueName = aUser + " " + OUString::number( nUserIndex );
1281 // if the given name is not valid, replace it!
1282 if( aUniqueName != GetName() || pTempItem )
1284 if( pTempItem )
1286 pTempItem->SetName( aUniqueName );
1287 return pTempItem;
1289 else
1291 return std::make_unique<XLineStartItem>( aUniqueName, maPolyPolygon );
1296 return nullptr;
1299 SfxPoolItem* XLineEndItem::CreateDefault() {return new XLineEndItem;}
1301 XLineEndItem::XLineEndItem(sal_Int32 nIndex)
1302 : NameOrIndex(XATTR_LINEEND, nIndex)
1306 XLineEndItem::XLineEndItem(const OUString& rName, const basegfx::B2DPolyPolygon& rPolyPolygon)
1307 : NameOrIndex(XATTR_LINEEND, rName),
1308 maPolyPolygon(rPolyPolygon)
1312 XLineEndItem::XLineEndItem(const XLineEndItem& rItem)
1313 : NameOrIndex(rItem),
1314 maPolyPolygon(rItem.maPolyPolygon)
1318 XLineEndItem::XLineEndItem(const basegfx::B2DPolyPolygon& rPolyPolygon)
1319 : NameOrIndex( XATTR_LINEEND, -1 ),
1320 maPolyPolygon(rPolyPolygon)
1324 XLineEndItem* XLineEndItem::Clone(SfxItemPool* /*pPool*/) const
1326 return new XLineEndItem(*this);
1329 bool XLineEndItem::operator==(const SfxPoolItem& rItem) const
1331 return ( NameOrIndex::operator==(rItem) && static_cast<const XLineEndItem&>(rItem).maPolyPolygon == maPolyPolygon );
1335 /** this function searches in both the models pool and the styles pool for XLineStartItem
1336 and XLineEndItem with the same value or name and returns an item with the value of
1337 this item and a unique name for an item with this value. */
1338 std::unique_ptr<XLineEndItem> XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const
1340 if( pModel )
1342 std::unique_ptr<XLineEndItem> pTempItem;
1343 const XLineEndItem* pLineEndItem = this;
1345 OUString aUniqueName( GetName() );
1347 if( !maPolyPolygon.count() )
1349 // if the polygon is empty, check if the name is empty
1350 if( aUniqueName.isEmpty() )
1351 return nullptr;
1353 // force empty name for empty polygons
1354 return std::make_unique<XLineEndItem>( "", maPolyPolygon );
1357 if( maPolyPolygon.count() > 1 )
1359 // check if the polygon is closed
1360 if(!maPolyPolygon.isClosed())
1362 // force a closed polygon
1363 basegfx::B2DPolyPolygon aNew(maPolyPolygon);
1364 aNew.setClosed(true);
1365 pTempItem.reset(new XLineEndItem( aUniqueName, aNew ));
1366 pLineEndItem = pTempItem.get();
1370 bool bForceNew = false;
1372 // 2. if we have a name check if there is already an item with the
1373 // same name in the documents pool with a different line end or start
1375 const SfxItemPool& rPool1 = pModel->GetItemPool();
1376 if (!aUniqueName.isEmpty())
1378 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
1380 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1382 if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
1384 // if there is already an item with the same name and the same
1385 // value it's ok to set it
1386 if( pItem->GetLineStartValue() != pLineEndItem->GetLineEndValue() )
1388 // same name but different value, we need a new name for this item
1389 aUniqueName.clear();
1390 bForceNew = true;
1392 break;
1396 if( !bForceNew )
1398 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
1400 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1402 if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
1404 // if there is already an item with the same name and the same
1405 // value it's ok to set it
1406 if( pItem->GetLineEndValue() != pLineEndItem->GetLineEndValue() )
1408 // same name but different value, we need a new name for this item
1409 aUniqueName.clear();
1410 bForceNew = true;
1412 break;
1418 const SfxItemPool* pPool2 = pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : nullptr;
1419 if( !aUniqueName.isEmpty() && pPool2)
1421 for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINESTART))
1423 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1425 if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
1427 // if there is already an item with the same name and the same
1428 // value it's ok to set it
1429 if( pItem->GetLineStartValue() != pLineEndItem->GetLineEndValue() )
1431 // same name but different value, we need a new name for this item
1432 aUniqueName.clear();
1433 bForceNew = true;
1435 break;
1439 if( !bForceNew )
1441 for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINEEND))
1443 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1445 if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
1447 // if there is already an item with the same name and the same
1448 // value it's ok to set it
1449 if( pItem->GetLineEndValue() != pLineEndItem->GetLineEndValue() )
1451 // same name but different value, we need a new name for this item
1452 aUniqueName.clear();
1453 bForceNew = true;
1455 break;
1461 // if we have no name yet, find existing item with same content or
1462 // create a unique name
1463 if( aUniqueName.isEmpty() )
1465 bool bFoundExisting = false;
1467 sal_Int32 nUserIndex = 1;
1468 const OUString aUser(SvxResId(RID_SVXSTR_LINEEND));
1470 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
1472 auto pItem = dynamic_cast<const XLineStartItem*>(p);
1474 if (pItem && !pItem->GetName().isEmpty())
1476 if (!bForceNew && pItem->GetLineStartValue() == pLineEndItem->GetLineEndValue())
1478 aUniqueName = pItem->GetName();
1479 bFoundExisting = true;
1480 break;
1483 if (pItem->GetName().startsWith(aUser))
1485 sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32();
1486 if (nThisIndex >= nUserIndex)
1487 nUserIndex = nThisIndex + 1;
1492 for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
1494 auto pItem = dynamic_cast<const XLineEndItem*>(p);
1496 if (pItem && !pItem->GetName().isEmpty())
1498 if (!bForceNew && pItem->GetLineEndValue() == pLineEndItem->GetLineEndValue())
1500 aUniqueName = pItem->GetName();
1501 bFoundExisting = true;
1502 break;
1505 if (pItem->GetName().startsWith(aUser))
1507 sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32();
1508 if (nThisIndex >= nUserIndex)
1509 nUserIndex = nThisIndex + 1;
1514 if( !bFoundExisting )
1516 aUniqueName = aUser + " " + OUString::number( nUserIndex );
1520 // if the given name is not valid, replace it!
1521 if( aUniqueName != GetName() || pTempItem )
1523 if( pTempItem )
1525 pTempItem->SetName( aUniqueName );
1526 return pTempItem;
1528 else
1530 return std::make_unique<XLineEndItem>( aUniqueName, maPolyPolygon );
1535 return nullptr;
1538 bool XLineEndItem::GetPresentation
1540 SfxItemPresentation /*ePres*/,
1541 MapUnit /*eCoreUnit*/,
1542 MapUnit /*ePresUnit*/,
1543 OUString& rText, const IntlWrapper&
1544 ) const
1546 rText = GetName();
1547 return true;
1550 bool XLineEndItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
1552 nMemberId &= ~CONVERT_TWIPS;
1553 if( nMemberId == MID_NAME )
1555 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
1557 else
1559 css::drawing::PolyPolygonBezierCoords aBezier;
1560 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( maPolyPolygon, aBezier );
1561 rVal <<= aBezier;
1563 return true;
1566 bool XLineEndItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
1568 nMemberId &= ~CONVERT_TWIPS;
1569 if( nMemberId == MID_NAME )
1571 return false;
1573 else
1575 maPolyPolygon.clear();
1577 if( rVal.hasValue() )
1579 auto pCoords = o3tl::tryAccess<css::drawing::PolyPolygonBezierCoords>(
1580 rVal);
1581 if( !pCoords )
1582 return false;
1584 if( pCoords->Coordinates.getLength() > 0 )
1586 maPolyPolygon = basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( *pCoords );
1587 // #i72807# close line start/end polygons hard
1588 // maPolyPolygon.setClosed(true);
1593 return true;
1596 XLineStartWidthItem::XLineStartWidthItem(tools::Long nWidth) :
1597 SfxMetricItem(XATTR_LINESTARTWIDTH, nWidth)
1601 XLineStartWidthItem* XLineStartWidthItem::Clone(SfxItemPool* /*pPool*/) const
1603 return new XLineStartWidthItem(*this);
1606 bool XLineStartWidthItem::GetPresentation
1608 SfxItemPresentation /*ePres*/,
1609 MapUnit eCoreUnit,
1610 MapUnit ePresUnit,
1611 OUString& rText, const IntlWrapper& rIntl
1612 ) const
1614 rText = GetMetricText( static_cast<tools::Long>(GetValue()),
1615 eCoreUnit, ePresUnit, &rIntl) +
1616 " " + EditResId( GetMetricId( ePresUnit) );
1617 return true;
1620 bool XLineStartWidthItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1622 rVal <<= GetValue();
1623 return true;
1626 bool XLineStartWidthItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1628 sal_Int32 nValue = 0;
1629 rVal >>= nValue;
1630 SetValue( nValue );
1631 return true;
1634 XLineEndWidthItem::XLineEndWidthItem(tools::Long nWidth) :
1635 SfxMetricItem(XATTR_LINEENDWIDTH, nWidth)
1639 XLineEndWidthItem* XLineEndWidthItem::Clone(SfxItemPool* /*pPool*/) const
1641 return new XLineEndWidthItem(*this);
1644 bool XLineEndWidthItem::GetPresentation
1646 SfxItemPresentation /*ePres*/,
1647 MapUnit eCoreUnit,
1648 MapUnit ePresUnit,
1649 OUString& rText, const IntlWrapper& rIntl
1650 ) const
1652 rText = GetMetricText( static_cast<tools::Long>(GetValue()),
1653 eCoreUnit, ePresUnit, &rIntl) +
1654 " " + EditResId( GetMetricId( ePresUnit) );
1655 return true;
1658 bool XLineEndWidthItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1660 rVal <<= GetValue();
1661 return true;
1664 bool XLineEndWidthItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1666 sal_Int32 nValue = 0;
1667 rVal >>= nValue;
1668 SetValue( nValue );
1669 return true;
1672 XLineStartCenterItem::XLineStartCenterItem(bool bStartCenter) :
1673 SfxBoolItem(XATTR_LINESTARTCENTER, bStartCenter)
1677 XLineStartCenterItem* XLineStartCenterItem::Clone(SfxItemPool* /*pPool*/) const
1679 return new XLineStartCenterItem(*this);
1682 bool XLineStartCenterItem::GetPresentation
1684 SfxItemPresentation /*ePres*/,
1685 MapUnit /*eCoreUnit*/,
1686 MapUnit /*ePresUnit*/,
1687 OUString& rText, const IntlWrapper&
1688 ) const
1690 rText = SvxResId(GetValue() ? RID_SVXSTR_CENTERED : RID_SVXSTR_NOTCENTERED);
1691 return true;
1694 bool XLineStartCenterItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1696 bool bValue = GetValue();
1697 rVal <<= bValue;
1698 return true;
1701 bool XLineStartCenterItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1703 auto b = o3tl::tryAccess<bool>(rVal);
1704 if( !b )
1705 return false;
1707 SetValue( *b );
1708 return true;
1711 XLineEndCenterItem::XLineEndCenterItem(bool bEndCenter) :
1712 SfxBoolItem(XATTR_LINEENDCENTER, bEndCenter)
1716 XLineEndCenterItem* XLineEndCenterItem::Clone(SfxItemPool* /*pPool*/) const
1718 return new XLineEndCenterItem(*this);
1721 bool XLineEndCenterItem::GetPresentation
1723 SfxItemPresentation /*ePres*/,
1724 MapUnit /*eCoreUnit*/,
1725 MapUnit /*ePresUnit*/,
1726 OUString& rText, const IntlWrapper&
1727 ) const
1729 rText = SvxResId(GetValue() ? RID_SVXSTR_CENTERED : RID_SVXSTR_NOTCENTERED);
1730 return true;
1733 bool XLineEndCenterItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1735 bool bValue = GetValue();
1736 rVal <<= bValue;
1737 return true;
1740 bool XLineEndCenterItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1742 auto b = o3tl::tryAccess<bool>(rVal);
1743 if( !b )
1744 return false;
1746 SetValue( *b );
1747 return true;
1750 // --- fill attributes ---
1753 SfxPoolItem* XFillStyleItem::CreateDefault() { return new XFillStyleItem; }
1755 XFillStyleItem::XFillStyleItem(drawing::FillStyle eFillStyle) :
1756 SfxEnumItem(XATTR_FILLSTYLE, eFillStyle)
1760 XFillStyleItem* XFillStyleItem::Clone(SfxItemPool* /*pPool*/) const
1762 return new XFillStyleItem( *this );
1765 bool XFillStyleItem::GetPresentation
1767 SfxItemPresentation /*ePres*/,
1768 MapUnit /*eCoreUnit*/,
1769 MapUnit /*ePresUnit*/,
1770 OUString& rText, const IntlWrapper&
1771 ) const
1773 rText.clear();
1775 const char* pId = nullptr;
1777 switch( GetValue() )
1779 case drawing::FillStyle_NONE:
1780 pId = RID_SVXSTR_INVISIBLE;
1781 break;
1782 case drawing::FillStyle_SOLID:
1783 pId = RID_SVXSTR_SOLID;
1784 break;
1785 case drawing::FillStyle_GRADIENT:
1786 pId = RID_SVXSTR_GRADIENT;
1787 break;
1788 case drawing::FillStyle_HATCH:
1789 pId = RID_SVXSTR_HATCH;
1790 break;
1791 case drawing::FillStyle_BITMAP:
1792 pId = RID_SVXSTR_BITMAP;
1793 break;
1794 default: break;
1797 if (pId)
1798 rText = SvxResId(pId);
1799 return true;
1802 sal_uInt16 XFillStyleItem::GetValueCount() const
1804 return 5;
1807 bool XFillStyleItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1809 css::drawing::FillStyle eFS = GetValue();
1811 rVal <<= eFS;
1813 return true;
1816 bool XFillStyleItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1818 css::drawing::FillStyle eFS;
1819 if(!(rVal >>= eFS))
1821 // also try an int (for Basic)
1822 sal_Int32 nFS = 0;
1823 if(!(rVal >>= nFS))
1824 return false;
1825 eFS = static_cast<css::drawing::FillStyle>(nFS);
1828 SetValue( eFS );
1830 return true;
1833 void XFillStyleItem::dumpAsXml(xmlTextWriterPtr pWriter) const
1835 xmlTextWriterStartElement(pWriter, BAD_CAST("XFillStyleItem"));
1836 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1837 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(static_cast<sal_Int16>(GetValue())).getStr()));
1839 OUString aPresentation;
1840 IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
1841 GetPresentation(SfxItemPresentation::Nameless, MapUnit::Map100thMM, MapUnit::Map100thMM, aPresentation, aIntlWrapper);
1842 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), BAD_CAST(aPresentation.toUtf8().getStr()));
1844 xmlTextWriterEndElement(pWriter);
1847 boost::property_tree::ptree XFillStyleItem::dumpAsJSON() const
1849 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
1851 if (Which() == XATTR_FILLSTYLE)
1852 aTree.put("commandName", ".uno:FillStyle");
1854 OUString sValue;
1856 switch( GetValue() )
1858 case drawing::FillStyle_NONE:
1859 sValue = "NONE";
1860 break;
1861 case drawing::FillStyle_SOLID:
1862 sValue = "SOLID";
1863 break;
1864 case drawing::FillStyle_GRADIENT:
1865 sValue = "GRADIENT";
1866 break;
1867 case drawing::FillStyle_HATCH:
1868 sValue = "HATCH";
1869 break;
1870 case drawing::FillStyle_BITMAP:
1871 sValue = "BITMAP";
1872 break;
1873 default: break;
1876 aTree.put("state", sValue);
1878 return aTree;
1882 SfxPoolItem* XFillColorItem::CreateDefault() { return new XFillColorItem; }
1884 XFillColorItem::XFillColorItem(sal_Int32 nIndex, const Color& rTheColor) :
1885 XColorItem(XATTR_FILLCOLOR, nIndex, rTheColor)
1889 XFillColorItem::XFillColorItem(const OUString& rName, const Color& rTheColor) :
1890 XColorItem(XATTR_FILLCOLOR, rName, rTheColor)
1894 XFillColorItem* XFillColorItem::Clone(SfxItemPool* /*pPool*/) const
1896 return new XFillColorItem(*this);
1899 bool XFillColorItem::GetPresentation
1901 SfxItemPresentation /*ePres*/,
1902 MapUnit /*eCoreUnit*/,
1903 MapUnit /*ePresUnit*/,
1904 OUString& rText, const IntlWrapper&
1905 ) const
1907 rText = GetName();
1908 return true;
1911 bool XFillColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
1913 rVal <<= GetColorValue().GetRGBColor();
1915 return true;
1918 bool XFillColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
1920 sal_Int32 nValue = 0;
1921 if(!(rVal >>= nValue ))
1922 return false;
1924 SetColorValue( Color(nValue) );
1925 return true;
1928 void XFillColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
1930 xmlTextWriterStartElement(pWriter, BAD_CAST("XFillColorItem"));
1931 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1932 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(GetColorValue().AsRGBHexString().toUtf8().getStr()));
1933 xmlTextWriterEndElement(pWriter);
1936 boost::property_tree::ptree XFillColorItem::dumpAsJSON() const
1938 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
1940 if (Which() == XATTR_FILLCOLOR)
1941 aTree.put("commandName", ".uno:FillPageColor");
1943 aTree.put("state", GetColorValue().AsRGBHexString());
1945 return aTree;
1948 XSecondaryFillColorItem::XSecondaryFillColorItem(const OUString& rName, const Color& rTheColor) :
1949 XColorItem(XATTR_SECONDARYFILLCOLOR, rName, rTheColor)
1953 XSecondaryFillColorItem* XSecondaryFillColorItem::Clone(SfxItemPool* /*pPool*/) const
1955 return new XSecondaryFillColorItem(*this);
1958 bool XSecondaryFillColorItem::GetPresentation
1960 SfxItemPresentation /*ePres*/,
1961 MapUnit /*eCoreUnit*/,
1962 MapUnit /*ePresUnit*/,
1963 OUString& rText, const IntlWrapper&
1964 ) const
1966 rText = GetName();
1967 return true;
1970 std::string XGradient::GradientStyleToString(css::awt::GradientStyle eStyle)
1972 switch (eStyle)
1974 case css::awt::GradientStyle::GradientStyle_LINEAR:
1975 return "LINEAR";
1977 case css::awt::GradientStyle::GradientStyle_AXIAL:
1978 return "AXIAL";
1980 case css::awt::GradientStyle::GradientStyle_RADIAL:
1981 return "RADIAL";
1983 case css::awt::GradientStyle::GradientStyle_ELLIPTICAL:
1984 return "ELLIPTICAL";
1986 case css::awt::GradientStyle::GradientStyle_SQUARE:
1987 return "SQUARE";
1989 case css::awt::GradientStyle::GradientStyle_RECT:
1990 return "RECT";
1992 case css::awt::GradientStyle::GradientStyle_MAKE_FIXED_SIZE:
1993 return "MAKE_FIXED_SIZE";
1996 return "";
1999 namespace
2001 css::awt::GradientStyle lcl_getStyleFromString(const OUString& rStyle)
2003 if (rStyle == "LINEAR")
2004 return css::awt::GradientStyle_LINEAR;
2005 else if (rStyle == "AXIAL")
2006 return css::awt::GradientStyle_AXIAL;
2007 else if (rStyle == "RADIAL")
2008 return css::awt::GradientStyle_RADIAL;
2009 else if (rStyle == "ELLIPTICAL")
2010 return css::awt::GradientStyle_ELLIPTICAL;
2011 else if (rStyle == "SQUARE")
2012 return css::awt::GradientStyle_SQUARE;
2013 else if (rStyle == "RECT")
2014 return css::awt::GradientStyle_RECT;
2016 return css::awt::GradientStyle_LINEAR;
2019 StringMap lcl_jsonToStringMap(const OUString& rJSON)
2021 StringMap aArgs;
2022 if (rJSON.getLength() && rJSON[0] != '\0')
2024 std::stringstream aStream(OUStringToOString(rJSON, RTL_TEXTENCODING_ASCII_US).getStr());
2025 boost::property_tree::ptree aTree;
2026 boost::property_tree::read_json(aStream, aTree);
2028 for (const auto& rPair : aTree)
2030 aArgs[OUString::fromUtf8(rPair.first.c_str())] = OUString::fromUtf8(rPair.second.get_value<std::string>(".").c_str());
2033 return aArgs;
2036 XGradient lcl_buildGradientFromStringMap(StringMap& rMap)
2038 XGradient aGradient;
2040 aGradient.SetStartColor(rMap["startcolor"].toInt32(16));
2041 aGradient.SetEndColor(rMap["endcolor"].toInt32(16));
2042 aGradient.SetGradientStyle(lcl_getStyleFromString(rMap["style"]));
2043 aGradient.SetAngle(Degree10(rMap["angle"].toInt32()));
2045 return aGradient;
2049 XGradient XGradient::fromJSON(const OUString& rJSON)
2051 StringMap aMap(lcl_jsonToStringMap(rJSON));
2052 return lcl_buildGradientFromStringMap(aMap);
2055 css::awt::Gradient XGradient::toGradientUNO()
2057 css::awt::Gradient aGradient;
2059 aGradient.Style = this->GetGradientStyle();
2060 aGradient.StartColor = static_cast<sal_Int32>(this->GetStartColor());
2061 aGradient.EndColor = static_cast<sal_Int32>(this->GetEndColor());
2062 aGradient.Angle = static_cast<short>(this->GetAngle());
2063 aGradient.Border = this->GetBorder();
2064 aGradient.XOffset = this->GetXOffset();
2065 aGradient.YOffset = this->GetYOffset();
2066 aGradient.StartIntensity = this->GetStartIntens();
2067 aGradient.EndIntensity = this->GetEndIntens();
2068 aGradient.StepCount = this->GetSteps();
2070 return aGradient;
2073 XGradient::XGradient() :
2074 eStyle( css::awt::GradientStyle_LINEAR ),
2075 aStartColor( COL_BLACK ),
2076 aEndColor( COL_WHITE ),
2077 nAngle( 0 ),
2078 nBorder( 0 ),
2079 nOfsX( 50 ),
2080 nOfsY( 50 ),
2081 nIntensStart( 100 ),
2082 nIntensEnd( 100 ),
2083 nStepCount( 0 )
2087 XGradient::XGradient(const Color& rStart, const Color& rEnd,
2088 css::awt::GradientStyle eTheStyle, Degree10 nTheAngle, sal_uInt16 nXOfs,
2089 sal_uInt16 nYOfs, sal_uInt16 nTheBorder,
2090 sal_uInt16 nStartIntens, sal_uInt16 nEndIntens,
2091 sal_uInt16 nSteps) :
2092 eStyle(eTheStyle),
2093 aStartColor(rStart),
2094 aEndColor(rEnd),
2095 nAngle(nTheAngle),
2096 nBorder(nTheBorder),
2097 nOfsX(nXOfs),
2098 nOfsY(nYOfs),
2099 nIntensStart(nStartIntens),
2100 nIntensEnd(nEndIntens),
2101 nStepCount(nSteps)
2105 bool XGradient::operator==(const XGradient& rGradient) const
2107 return ( eStyle == rGradient.eStyle &&
2108 aStartColor == rGradient.aStartColor &&
2109 aEndColor == rGradient.aEndColor &&
2110 nAngle == rGradient.nAngle &&
2111 nBorder == rGradient.nBorder &&
2112 nOfsX == rGradient.nOfsX &&
2113 nOfsY == rGradient.nOfsY &&
2114 nIntensStart == rGradient.nIntensStart &&
2115 nIntensEnd == rGradient.nIntensEnd &&
2116 nStepCount == rGradient.nStepCount );
2119 boost::property_tree::ptree XGradient::dumpAsJSON() const
2121 boost::property_tree::ptree aTree;
2123 aTree.put("style", XGradient::GradientStyleToString(eStyle));
2124 aTree.put("startcolor",aStartColor.AsRGBHexString());
2125 aTree.put("endcolor", aEndColor.AsRGBHexString());
2126 aTree.put("angle", std::to_string(nAngle.get()));
2127 aTree.put("border", std::to_string(nBorder));
2128 aTree.put("x", std::to_string(nOfsX));
2129 aTree.put("y", std::to_string(nOfsY));
2130 aTree.put("intensstart", std::to_string(nIntensStart));
2131 aTree.put("intensend", std::to_string(nIntensEnd));
2132 aTree.put("stepcount", std::to_string(nStepCount));
2134 return aTree;
2137 SfxPoolItem* XFillGradientItem::CreateDefault() { return new XFillGradientItem; }
2139 XFillGradientItem::XFillGradientItem(sal_Int32 nIndex,
2140 const XGradient& rTheGradient) :
2141 NameOrIndex(XATTR_FILLGRADIENT, nIndex),
2142 aGradient(rTheGradient)
2146 XFillGradientItem::XFillGradientItem(const OUString& rName,
2147 const XGradient& rTheGradient, sal_uInt16 nWhich)
2148 : NameOrIndex(nWhich, rName)
2149 , aGradient(rTheGradient)
2153 XFillGradientItem::XFillGradientItem(const XFillGradientItem& rItem) :
2154 NameOrIndex(rItem),
2155 aGradient(rItem.aGradient)
2159 XFillGradientItem::XFillGradientItem( const XGradient& rTheGradient )
2160 : NameOrIndex( XATTR_FILLGRADIENT, -1 ),
2161 aGradient(rTheGradient)
2165 XFillGradientItem* XFillGradientItem::Clone(SfxItemPool* /*pPool*/) const
2167 return new XFillGradientItem(*this);
2170 bool XFillGradientItem::operator==(const SfxPoolItem& rItem) const
2172 return ( NameOrIndex::operator==(rItem) &&
2173 aGradient == static_cast<const XFillGradientItem&>(rItem).aGradient );
2176 const XGradient& XFillGradientItem::GetGradientValue() const // GetValue -> GetGradientValue
2178 if (!IsIndex())
2179 return aGradient;
2180 // ToDo: This should fail. We never called this code with a table so this should always
2181 // have failed. Thus, I'm thinking that XFillGradientItem can't be an Index.
2182 return aGradient;
2185 bool XFillGradientItem::GetPresentation
2187 SfxItemPresentation /*ePres*/,
2188 MapUnit /*eCoreUnit*/,
2189 MapUnit /*ePresUnit*/,
2190 OUString& rText, const IntlWrapper&
2191 ) const
2193 rText = GetName();
2194 return true;
2197 bool XFillGradientItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2199 nMemberId &= ~CONVERT_TWIPS;
2200 switch ( nMemberId )
2202 case 0:
2204 uno::Sequence< beans::PropertyValue > aPropSeq( 2 );
2206 css::awt::Gradient aGradient2;
2208 const XGradient& aXGradient = GetGradientValue();
2209 aGradient2.Style = aXGradient.GetGradientStyle();
2210 aGradient2.StartColor = static_cast<sal_Int32>(aXGradient.GetStartColor());
2211 aGradient2.EndColor = static_cast<sal_Int32>(aXGradient.GetEndColor());
2212 aGradient2.Angle = static_cast<short>(aXGradient.GetAngle());
2213 aGradient2.Border = aXGradient.GetBorder();
2214 aGradient2.XOffset = aXGradient.GetXOffset();
2215 aGradient2.YOffset = aXGradient.GetYOffset();
2216 aGradient2.StartIntensity = aXGradient.GetStartIntens();
2217 aGradient2.EndIntensity = aXGradient.GetEndIntens();
2218 aGradient2.StepCount = aXGradient.GetSteps();
2220 aPropSeq[0].Name = "Name";
2221 aPropSeq[0].Value <<= SvxUnogetApiNameForItem(Which(), GetName());
2222 aPropSeq[1].Name = "FillGradient";
2223 aPropSeq[1].Value <<= aGradient2;
2224 rVal <<= aPropSeq;
2225 break;
2228 case MID_FILLGRADIENT:
2230 const XGradient& aXGradient = GetGradientValue();
2231 css::awt::Gradient aGradient2;
2233 aGradient2.Style = aXGradient.GetGradientStyle();
2234 aGradient2.StartColor = static_cast<sal_Int32>(aXGradient.GetStartColor());
2235 aGradient2.EndColor = static_cast<sal_Int32>(aXGradient.GetEndColor());
2236 aGradient2.Angle = static_cast<short>(aXGradient.GetAngle());
2237 aGradient2.Border = aXGradient.GetBorder();
2238 aGradient2.XOffset = aXGradient.GetXOffset();
2239 aGradient2.YOffset = aXGradient.GetYOffset();
2240 aGradient2.StartIntensity = aXGradient.GetStartIntens();
2241 aGradient2.EndIntensity = aXGradient.GetEndIntens();
2242 aGradient2.StepCount = aXGradient.GetSteps();
2244 rVal <<= aGradient2;
2245 break;
2248 case MID_NAME:
2250 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
2251 break;
2254 case MID_GRADIENT_STYLE: rVal <<= static_cast<sal_Int16>(GetGradientValue().GetGradientStyle()); break;
2255 case MID_GRADIENT_STARTCOLOR: rVal <<= GetGradientValue().GetStartColor(); break;
2256 case MID_GRADIENT_ENDCOLOR: rVal <<= GetGradientValue().GetEndColor(); break;
2257 case MID_GRADIENT_ANGLE: rVal <<= static_cast<sal_Int16>(GetGradientValue().GetAngle()); break;
2258 case MID_GRADIENT_BORDER: rVal <<= GetGradientValue().GetBorder(); break;
2259 case MID_GRADIENT_XOFFSET: rVal <<= GetGradientValue().GetXOffset(); break;
2260 case MID_GRADIENT_YOFFSET: rVal <<= GetGradientValue().GetYOffset(); break;
2261 case MID_GRADIENT_STARTINTENSITY: rVal <<= GetGradientValue().GetStartIntens(); break;
2262 case MID_GRADIENT_ENDINTENSITY: rVal <<= GetGradientValue().GetEndIntens(); break;
2263 case MID_GRADIENT_STEPCOUNT: rVal <<= GetGradientValue().GetSteps(); break;
2265 default: OSL_FAIL("Wrong MemberId!"); return false;
2268 return true;
2271 bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2273 nMemberId &= ~CONVERT_TWIPS;
2275 switch ( nMemberId )
2277 case 0:
2279 uno::Sequence< beans::PropertyValue > aPropSeq;
2281 if ( rVal >>= aPropSeq )
2283 css::awt::Gradient aGradient2;
2284 OUString aName;
2285 bool bGradient( false );
2286 for ( const auto& rProp : std::as_const(aPropSeq) )
2288 if ( rProp.Name == "Name" )
2289 rProp.Value >>= aName;
2290 else if ( rProp.Name == "FillGradient" )
2292 if ( rProp.Value >>= aGradient2 )
2293 bGradient = true;
2297 SetName( aName );
2298 if ( bGradient )
2300 XGradient aXGradient;
2302 aXGradient.SetGradientStyle( aGradient2.Style );
2303 aXGradient.SetStartColor( Color(aGradient2.StartColor) );
2304 aXGradient.SetEndColor( Color(aGradient2.EndColor) );
2305 aXGradient.SetAngle( Degree10(aGradient2.Angle) );
2306 aXGradient.SetBorder( aGradient2.Border );
2307 aXGradient.SetXOffset( aGradient2.XOffset );
2308 aXGradient.SetYOffset( aGradient2.YOffset );
2309 aXGradient.SetStartIntens( aGradient2.StartIntensity );
2310 aXGradient.SetEndIntens( aGradient2.EndIntensity );
2311 aXGradient.SetSteps( aGradient2.StepCount );
2313 SetGradientValue( aXGradient );
2316 return true;
2319 return false;
2322 case MID_NAME:
2324 OUString aName;
2325 if (!(rVal >>= aName ))
2326 return false;
2327 SetName( aName );
2328 break;
2331 case MID_FILLGRADIENT:
2333 css::awt::Gradient aGradient2;
2334 if(!(rVal >>= aGradient2))
2335 return false;
2337 XGradient aXGradient;
2339 aXGradient.SetGradientStyle( aGradient2.Style );
2340 aXGradient.SetStartColor( Color(aGradient2.StartColor) );
2341 aXGradient.SetEndColor( Color(aGradient2.EndColor) );
2342 aXGradient.SetAngle( Degree10(aGradient2.Angle) );
2343 aXGradient.SetBorder( aGradient2.Border );
2344 aXGradient.SetXOffset( aGradient2.XOffset );
2345 aXGradient.SetYOffset( aGradient2.YOffset );
2346 aXGradient.SetStartIntens( aGradient2.StartIntensity );
2347 aXGradient.SetEndIntens( aGradient2.EndIntensity );
2348 aXGradient.SetSteps( aGradient2.StepCount );
2350 SetGradientValue( aXGradient );
2351 break;
2354 case MID_GRADIENT_STARTCOLOR:
2355 case MID_GRADIENT_ENDCOLOR:
2357 sal_Int32 nVal = 0;
2358 if(!(rVal >>= nVal ))
2359 return false;
2361 XGradient aXGradient = GetGradientValue();
2363 if ( nMemberId == MID_GRADIENT_STARTCOLOR )
2364 aXGradient.SetStartColor( Color(nVal) );
2365 else
2366 aXGradient.SetEndColor( Color(nVal) );
2367 SetGradientValue( aXGradient );
2368 break;
2371 case MID_GRADIENT_STYLE:
2372 case MID_GRADIENT_ANGLE:
2373 case MID_GRADIENT_BORDER:
2374 case MID_GRADIENT_STARTINTENSITY:
2375 case MID_GRADIENT_ENDINTENSITY:
2376 case MID_GRADIENT_STEPCOUNT:
2377 case MID_GRADIENT_XOFFSET:
2378 case MID_GRADIENT_YOFFSET:
2380 sal_Int16 nVal = sal_Int16();
2381 if(!(rVal >>= nVal ))
2382 return false;
2384 XGradient aXGradient = GetGradientValue();
2386 switch ( nMemberId )
2388 case MID_GRADIENT_STYLE:
2389 aXGradient.SetGradientStyle( static_cast<css::awt::GradientStyle>(nVal) ); break;
2390 case MID_GRADIENT_ANGLE:
2391 aXGradient.SetAngle( Degree10(nVal) ); break;
2392 case MID_GRADIENT_BORDER:
2393 aXGradient.SetBorder( nVal ); break;
2394 case MID_GRADIENT_STARTINTENSITY:
2395 aXGradient.SetStartIntens( nVal ); break;
2396 case MID_GRADIENT_ENDINTENSITY:
2397 aXGradient.SetEndIntens( nVal ); break;
2398 case MID_GRADIENT_STEPCOUNT:
2399 aXGradient.SetSteps( nVal ); break;
2400 case MID_GRADIENT_XOFFSET:
2401 aXGradient.SetXOffset( nVal ); break;
2402 case MID_GRADIENT_YOFFSET:
2403 aXGradient.SetYOffset( nVal ); break;
2406 SetGradientValue( aXGradient );
2407 break;
2411 return true;
2414 bool XFillGradientItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2416 return static_cast<const XFillGradientItem*>(p1)->GetGradientValue() == static_cast<const XFillGradientItem*>(p2)->GetGradientValue();
2419 std::unique_ptr<XFillGradientItem> XFillGradientItem::checkForUniqueItem( SdrModel* pModel ) const
2421 if( pModel )
2423 const OUString aUniqueName = NameOrIndex::CheckNamedItem(
2424 this, Which(), &pModel->GetItemPool(),
2425 XFillGradientItem::CompareValueFunc, RID_SVXSTR_GRADIENT,
2426 pModel->GetPropertyList( XPropertyListType::Gradient ) );
2428 // if the given name is not valid, replace it!
2429 if( aUniqueName != GetName() )
2430 return std::make_unique<XFillGradientItem>( aUniqueName, aGradient, Which() );
2433 return nullptr;
2436 boost::property_tree::ptree XFillGradientItem::dumpAsJSON() const
2438 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
2440 if (Which() == XATTR_FILLGRADIENT)
2441 aTree.put("commandName", ".uno:FillGradient");
2443 aTree.push_back(std::make_pair("state", GetGradientValue().dumpAsJSON()));
2445 return aTree;
2449 SfxPoolItem* XFillFloatTransparenceItem::CreateDefault() { return new XFillFloatTransparenceItem; }
2451 XFillFloatTransparenceItem::XFillFloatTransparenceItem() :
2452 bEnabled( false )
2454 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2457 XFillFloatTransparenceItem::XFillFloatTransparenceItem(const OUString& rName, const XGradient& rGradient, bool bEnable ) :
2458 XFillGradientItem ( rName, rGradient ),
2459 bEnabled ( bEnable )
2461 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2464 XFillFloatTransparenceItem::XFillFloatTransparenceItem( const XFillFloatTransparenceItem& rItem ) :
2465 XFillGradientItem ( rItem ),
2466 bEnabled ( rItem.bEnabled )
2468 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2471 XFillFloatTransparenceItem::XFillFloatTransparenceItem(const XGradient& rTheGradient, bool bEnable )
2472 : XFillGradientItem ( -1, rTheGradient ),
2473 bEnabled ( bEnable )
2475 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2478 bool XFillFloatTransparenceItem::operator==( const SfxPoolItem& rItem ) const
2480 return ( NameOrIndex::operator==(rItem) ) &&
2481 ( GetGradientValue() == static_cast<const XFillGradientItem&>(rItem).GetGradientValue() ) &&
2482 ( bEnabled == static_cast<const XFillFloatTransparenceItem&>(rItem).bEnabled );
2485 XFillFloatTransparenceItem* XFillFloatTransparenceItem::Clone( SfxItemPool* /*pPool*/) const
2487 return new XFillFloatTransparenceItem( *this );
2490 bool XFillFloatTransparenceItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2492 return XFillGradientItem::QueryValue( rVal, nMemberId );
2495 bool XFillFloatTransparenceItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2497 return XFillGradientItem::PutValue( rVal, nMemberId );
2500 bool XFillFloatTransparenceItem::GetPresentation( SfxItemPresentation ePres,
2501 MapUnit eCoreUnit, MapUnit ePresUnit,
2502 OUString& rText,
2503 const IntlWrapper& rIntlWrapper ) const
2505 return XFillGradientItem::GetPresentation( ePres, eCoreUnit, ePresUnit, rText, rIntlWrapper );
2508 bool XFillFloatTransparenceItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2510 return static_cast<const XFillFloatTransparenceItem*>(p1)->IsEnabled() == static_cast<const XFillFloatTransparenceItem*>(p2)->IsEnabled() &&
2511 static_cast<const XFillFloatTransparenceItem*>(p1)->GetGradientValue() == static_cast<const XFillFloatTransparenceItem*>(p2)->GetGradientValue();
2514 std::unique_ptr<XFillFloatTransparenceItem> XFillFloatTransparenceItem::checkForUniqueItem( SdrModel* pModel ) const
2516 // #85953# unique name only necessary when enabled
2517 if(IsEnabled())
2519 if( pModel )
2521 const OUString aUniqueName = NameOrIndex::CheckNamedItem( this,
2522 XATTR_FILLFLOATTRANSPARENCE,
2523 &pModel->GetItemPool(),
2524 XFillFloatTransparenceItem::CompareValueFunc,
2525 RID_SVXSTR_TRASNGR0,
2526 XPropertyListRef() );
2528 // if the given name is not valid, replace it!
2529 if( aUniqueName != GetName() )
2531 return std::make_unique<XFillFloatTransparenceItem>( aUniqueName, GetGradientValue(), true );
2535 else
2537 // #85953# if disabled, force name to empty string
2538 if( !GetName().isEmpty() )
2540 return std::make_unique<XFillFloatTransparenceItem>(OUString(), GetGradientValue(), false);
2544 return nullptr;
2547 boost::property_tree::ptree XFillFloatTransparenceItem::dumpAsJSON() const
2549 boost::property_tree::ptree aTree = XFillGradientItem::dumpAsJSON();
2550 aTree.put("commandName", ".uno:FillFloatTransparence");
2552 if (!bEnabled)
2554 boost::property_tree::ptree& rState = aTree.get_child("state");
2555 // When gradient fill is disabled, the intensity fields contain the
2556 // constant encoded percent-transparency. However we use that here to just
2557 // distinguish between 'None' and 'Solid' types and correct the 'style'
2558 // property appropriately.
2559 if (GetGradientValue().GetStartIntens() == 100)
2560 rState.put("style", "NONE");
2561 else
2562 rState.put("style", "SOLID");
2565 return aTree;
2568 XHatch::XHatch(const Color& rCol, css::drawing::HatchStyle eTheStyle, tools::Long nTheDistance,
2569 Degree10 nTheAngle) :
2570 eStyle(eTheStyle),
2571 aColor(rCol),
2572 nDistance(nTheDistance),
2573 nAngle(nTheAngle)
2577 bool XHatch::operator==(const XHatch& rHatch) const
2579 return ( eStyle == rHatch.eStyle &&
2580 aColor == rHatch.aColor &&
2581 nDistance == rHatch.nDistance &&
2582 nAngle == rHatch.nAngle );
2586 SfxPoolItem* XFillHatchItem::CreateDefault() { return new XFillHatchItem; }
2588 XFillHatchItem::XFillHatchItem(const OUString& rName,
2589 const XHatch& rTheHatch) :
2590 NameOrIndex(XATTR_FILLHATCH, rName),
2591 aHatch(rTheHatch)
2595 XFillHatchItem::XFillHatchItem(const XFillHatchItem& rItem) :
2596 NameOrIndex(rItem),
2597 aHatch(rItem.aHatch)
2601 XFillHatchItem::XFillHatchItem(const XHatch& rTheHatch)
2602 : NameOrIndex( XATTR_FILLHATCH, -1 ),
2603 aHatch(rTheHatch)
2607 XFillHatchItem* XFillHatchItem::Clone(SfxItemPool* /*pPool*/) const
2609 return new XFillHatchItem(*this);
2612 bool XFillHatchItem::operator==(const SfxPoolItem& rItem) const
2614 return ( NameOrIndex::operator==(rItem) &&
2615 aHatch == static_cast<const XFillHatchItem&>(rItem).aHatch );
2618 bool XFillHatchItem::GetPresentation
2620 SfxItemPresentation /*ePres*/,
2621 MapUnit /*eCoreUnit*/,
2622 MapUnit /*ePresUnit*/,
2623 OUString& rText, const IntlWrapper&
2624 ) const
2626 rText = GetName();
2627 return true;
2630 bool XFillHatchItem::HasMetrics() const
2632 return true;
2635 void XFillHatchItem::ScaleMetrics(tools::Long nMul, tools::Long nDiv)
2637 aHatch.SetDistance( ScaleMetricValue( aHatch.GetDistance(), nMul, nDiv ) );
2640 bool XFillHatchItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2642 nMemberId &= ~CONVERT_TWIPS;
2644 switch ( nMemberId )
2646 case 0:
2648 uno::Sequence< beans::PropertyValue > aPropSeq( 2 );
2650 css::drawing::Hatch aUnoHatch;
2652 aUnoHatch.Style = aHatch.GetHatchStyle();
2653 aUnoHatch.Color = sal_Int32(aHatch.GetColor());
2654 aUnoHatch.Distance = aHatch.GetDistance();
2655 aUnoHatch.Angle = aHatch.GetAngle().get();
2657 aPropSeq[0].Name = "Name";
2658 aPropSeq[0].Value <<= SvxUnogetApiNameForItem(Which(), GetName());
2659 aPropSeq[1].Name = "FillHatch";
2660 aPropSeq[1].Value <<= aUnoHatch;
2661 rVal <<= aPropSeq;
2662 break;
2665 case MID_FILLHATCH:
2667 css::drawing::Hatch aUnoHatch;
2669 aUnoHatch.Style = aHatch.GetHatchStyle();
2670 aUnoHatch.Color = sal_Int32(aHatch.GetColor());
2671 aUnoHatch.Distance = aHatch.GetDistance();
2672 aUnoHatch.Angle = aHatch.GetAngle().get();
2673 rVal <<= aUnoHatch;
2674 break;
2677 case MID_NAME:
2679 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
2680 break;
2683 case MID_HATCH_STYLE:
2684 rVal <<= aHatch.GetHatchStyle(); break;
2685 case MID_HATCH_COLOR:
2686 rVal <<= aHatch.GetColor(); break;
2687 case MID_HATCH_DISTANCE:
2688 rVal <<= aHatch.GetDistance(); break;
2689 case MID_HATCH_ANGLE:
2690 rVal <<= aHatch.GetAngle().get(); break;
2692 default: OSL_FAIL("Wrong MemberId!"); return false;
2695 return true;
2698 bool XFillHatchItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2700 nMemberId &= ~CONVERT_TWIPS;
2702 switch ( nMemberId )
2704 case 0:
2706 uno::Sequence< beans::PropertyValue > aPropSeq;
2707 if ( rVal >>= aPropSeq )
2709 css::drawing::Hatch aUnoHatch;
2710 OUString aName;
2711 bool bHatch( false );
2712 for ( const auto& rProp : std::as_const(aPropSeq) )
2714 if ( rProp.Name == "Name" )
2715 rProp.Value >>= aName;
2716 else if ( rProp.Name == "FillHatch" )
2718 if ( rProp.Value >>= aUnoHatch )
2719 bHatch = true;
2723 SetName( aName );
2724 if ( bHatch )
2726 aHatch.SetHatchStyle( aUnoHatch.Style );
2727 aHatch.SetColor( Color(aUnoHatch.Color) );
2728 aHatch.SetDistance( aUnoHatch.Distance );
2729 aHatch.SetAngle( Degree10(aUnoHatch.Angle) );
2732 return true;
2735 return false;
2738 case MID_FILLHATCH:
2740 css::drawing::Hatch aUnoHatch;
2741 if(!(rVal >>= aUnoHatch))
2742 return false;
2744 aHatch.SetHatchStyle( aUnoHatch.Style );
2745 aHatch.SetColor( Color(aUnoHatch.Color) );
2746 aHatch.SetDistance( aUnoHatch.Distance );
2747 aHatch.SetAngle( Degree10(aUnoHatch.Angle) );
2748 break;
2751 case MID_NAME:
2753 OUString aName;
2754 if (!(rVal >>= aName ))
2755 return false;
2756 SetName( aName );
2757 break;
2760 case MID_HATCH_STYLE:
2762 sal_Int16 nVal = sal_Int16();
2763 if (!(rVal >>= nVal ))
2764 return false;
2765 aHatch.SetHatchStyle( static_cast<css::drawing::HatchStyle>(nVal) );
2766 break;
2769 case MID_HATCH_COLOR:
2770 case MID_HATCH_DISTANCE:
2771 case MID_HATCH_ANGLE:
2773 sal_Int32 nVal = 0;
2774 if (!(rVal >>= nVal ))
2775 return false;
2777 if ( nMemberId == MID_HATCH_COLOR )
2778 aHatch.SetColor( Color(nVal) );
2779 else if ( nMemberId == MID_HATCH_DISTANCE )
2780 aHatch.SetDistance( nVal );
2781 else
2782 aHatch.SetAngle( Degree10(nVal) );
2783 break;
2786 default: OSL_FAIL("Wrong MemberId!"); return false;
2789 return true;
2792 bool XFillHatchItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2794 return static_cast<const XFillHatchItem*>(p1)->GetHatchValue() == static_cast<const XFillHatchItem*>(p2)->GetHatchValue();
2797 std::unique_ptr<XFillHatchItem> XFillHatchItem::checkForUniqueItem( SdrModel* pModel ) const
2799 if( pModel )
2801 const OUString aUniqueName = NameOrIndex::CheckNamedItem(
2802 this, XATTR_FILLHATCH, &pModel->GetItemPool(),
2803 XFillHatchItem::CompareValueFunc, RID_SVXSTR_HATCH10,
2804 pModel->GetPropertyList( XPropertyListType::Hatch ) );
2806 // if the given name is not valid, replace it!
2807 if( aUniqueName != GetName() )
2808 return std::make_unique<XFillHatchItem>( aUniqueName, aHatch );
2811 return nullptr;
2814 // --- form text attributes ---
2817 SfxPoolItem* XFormTextStyleItem::CreateDefault() { return new XFormTextStyleItem; }
2819 XFormTextStyleItem::XFormTextStyleItem(XFormTextStyle eTheStyle) :
2820 SfxEnumItem(XATTR_FORMTXTSTYLE, eTheStyle)
2824 XFormTextStyleItem* XFormTextStyleItem::Clone(SfxItemPool* /*pPool*/) const
2826 return new XFormTextStyleItem( *this );
2829 sal_uInt16 XFormTextStyleItem::GetValueCount() const
2831 return 5;
2834 bool XFormTextStyleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2836 rVal <<= static_cast<sal_Int32>(GetValue());
2837 return true;
2840 bool XFormTextStyleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2842 sal_Int32 nValue = 0;
2843 rVal >>= nValue;
2844 SetValue(static_cast<XFormTextStyle>(nValue));
2846 return true;
2850 SfxPoolItem* XFormTextAdjustItem::CreateDefault() { return new XFormTextAdjustItem; }
2852 XFormTextAdjustItem::XFormTextAdjustItem(XFormTextAdjust eTheAdjust) :
2853 SfxEnumItem(XATTR_FORMTXTADJUST, eTheAdjust)
2857 XFormTextAdjustItem* XFormTextAdjustItem::Clone(SfxItemPool* /*pPool*/) const
2859 return new XFormTextAdjustItem( *this );
2862 sal_uInt16 XFormTextAdjustItem::GetValueCount() const
2864 return 4;
2867 bool XFormTextAdjustItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2869 rVal <<= static_cast<sal_Int32>(GetValue());
2870 return true;
2873 bool XFormTextAdjustItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2875 sal_Int32 nValue = 0;
2876 rVal >>= nValue;
2877 SetValue(static_cast<XFormTextAdjust>(nValue));
2879 return true;
2883 SfxPoolItem* XFormTextDistanceItem::CreateDefault() { return new XFormTextDistanceItem; }
2885 XFormTextDistanceItem::XFormTextDistanceItem(tools::Long nDist) :
2886 SfxMetricItem(XATTR_FORMTXTDISTANCE, nDist)
2890 XFormTextDistanceItem* XFormTextDistanceItem::Clone(SfxItemPool* /*pPool*/) const
2892 return new XFormTextDistanceItem(*this);
2895 SfxPoolItem* XFormTextStartItem::CreateDefault() { return new XFormTextStartItem; }
2897 XFormTextStartItem::XFormTextStartItem(tools::Long nStart) :
2898 SfxMetricItem(XATTR_FORMTXTSTART, nStart)
2902 XFormTextStartItem* XFormTextStartItem::Clone(SfxItemPool* /*pPool*/) const
2904 return new XFormTextStartItem(*this);
2907 SfxPoolItem* XFormTextMirrorItem::CreateDefault() { return new XFormTextMirrorItem; }
2909 XFormTextMirrorItem::XFormTextMirrorItem(bool bMirror) :
2910 SfxBoolItem(XATTR_FORMTXTMIRROR, bMirror)
2914 XFormTextMirrorItem* XFormTextMirrorItem::Clone(SfxItemPool* /*pPool*/) const
2916 return new XFormTextMirrorItem(*this);
2919 SfxPoolItem* XFormTextOutlineItem::CreateDefault() { return new XFormTextOutlineItem; }
2921 XFormTextOutlineItem::XFormTextOutlineItem(bool bOutline) :
2922 SfxBoolItem(XATTR_FORMTXTOUTLINE, bOutline)
2926 XFormTextOutlineItem* XFormTextOutlineItem::Clone(SfxItemPool* /*pPool*/) const
2928 return new XFormTextOutlineItem(*this);
2931 SfxPoolItem* XFormTextShadowItem::CreateDefault() { return new XFormTextShadowItem; }
2933 XFormTextShadowItem::XFormTextShadowItem(XFormTextShadow eFormTextShadow) :
2934 SfxEnumItem(XATTR_FORMTXTSHADOW, eFormTextShadow)
2938 XFormTextShadowItem* XFormTextShadowItem::Clone(SfxItemPool* /*pPool*/) const
2940 return new XFormTextShadowItem( *this );
2943 sal_uInt16 XFormTextShadowItem::GetValueCount() const
2945 return 3;
2948 bool XFormTextShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2950 rVal <<= static_cast<sal_Int32>(GetValue());
2951 return true;
2954 bool XFormTextShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2956 sal_Int32 nValue = 0;
2957 rVal >>= nValue;
2958 SetValue(static_cast<XFormTextShadow>(nValue));
2960 return true;
2964 SfxPoolItem* XFormTextShadowColorItem::CreateDefault() { return new XFormTextShadowColorItem; }
2966 XFormTextShadowColorItem::XFormTextShadowColorItem(const OUString& rName,
2967 const Color& rTheColor) :
2968 XColorItem(XATTR_FORMTXTSHDWCOLOR, rName, rTheColor)
2972 XFormTextShadowColorItem* XFormTextShadowColorItem::Clone(SfxItemPool* /*pPool*/) const
2974 return new XFormTextShadowColorItem(*this);
2977 SfxPoolItem* XFormTextShadowXValItem::CreateDefault() { return new XFormTextShadowXValItem; }
2979 XFormTextShadowXValItem::XFormTextShadowXValItem(tools::Long nVal) :
2980 SfxMetricItem(XATTR_FORMTXTSHDWXVAL, nVal)
2984 XFormTextShadowXValItem* XFormTextShadowXValItem::Clone(SfxItemPool* /*pPool*/) const
2986 return new XFormTextShadowXValItem(*this);
2989 SfxPoolItem* XFormTextShadowYValItem::CreateDefault() { return new XFormTextShadowYValItem; }
2991 XFormTextShadowYValItem::XFormTextShadowYValItem(tools::Long nVal) :
2992 SfxMetricItem(XATTR_FORMTXTSHDWYVAL, nVal)
2996 XFormTextShadowYValItem* XFormTextShadowYValItem::Clone(SfxItemPool* /*pPool*/) const
2998 return new XFormTextShadowYValItem(*this);
3001 SfxPoolItem* XFormTextHideFormItem::CreateDefault() { return new XFormTextHideFormItem; }
3003 XFormTextHideFormItem::XFormTextHideFormItem(bool bHide) :
3004 SfxBoolItem(XATTR_FORMTXTHIDEFORM, bHide)
3008 XFormTextHideFormItem* XFormTextHideFormItem::Clone(SfxItemPool* /*pPool*/) const
3010 return new XFormTextHideFormItem(*this);
3013 // --- SetItems ---
3016 /// a line attribute set item
3017 XLineAttrSetItem::XLineAttrSetItem( std::unique_ptr<SfxItemSet>&& pItemSet ) :
3018 SfxSetItem( XATTRSET_LINE, std::move(pItemSet))
3022 XLineAttrSetItem::XLineAttrSetItem( SfxItemPool* pItemPool ) :
3023 SfxSetItem( XATTRSET_LINE,
3024 std::make_unique<SfxItemSet>( *pItemPool, svl::Items<XATTR_LINE_FIRST, XATTR_LINE_LAST>{}))
3028 XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr ) :
3029 SfxSetItem( rLineAttr )
3033 XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr,
3034 SfxItemPool* pItemPool) :
3035 SfxSetItem( rLineAttr, pItemPool )
3039 XLineAttrSetItem* XLineAttrSetItem::Clone( SfxItemPool* pPool ) const
3041 return new XLineAttrSetItem( *this, pPool );
3044 /// fill attribute set item
3045 XFillAttrSetItem::XFillAttrSetItem( std::unique_ptr<SfxItemSet>&& pItemSet ) :
3046 SfxSetItem( XATTRSET_FILL, std::move(pItemSet))
3050 XFillAttrSetItem::XFillAttrSetItem( SfxItemPool* pItemPool ) :
3051 SfxSetItem( XATTRSET_FILL,
3052 std::make_unique<SfxItemSet>( *pItemPool, svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}))
3056 XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr ) :
3057 SfxSetItem( rFillAttr )
3061 XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr,
3062 SfxItemPool* pItemPool ) :
3063 SfxSetItem( rFillAttr, pItemPool )
3067 XFillAttrSetItem* XFillAttrSetItem::Clone( SfxItemPool* pPool ) const
3069 return new XFillAttrSetItem( *this, pPool );
3072 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */