bump product version to 7.2.5.1
[LibreOffice.git] / svx / source / xoutdev / xattr.cxx
blob421094428fb3fdfd0ccca281a7e4ae247a84793d
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 NameOrIndex::NameOrIndex(sal_uInt16 _nWhich, sal_Int32 nIndex) :
95 SfxStringItem(_nWhich, OUString()),
96 nPalIndex(nIndex)
100 NameOrIndex::NameOrIndex(sal_uInt16 _nWhich, const OUString& rName) :
101 SfxStringItem(_nWhich, rName),
102 nPalIndex(-1)
106 NameOrIndex::NameOrIndex(const NameOrIndex& rNameOrIndex) :
107 SfxStringItem(rNameOrIndex),
108 nPalIndex(rNameOrIndex.nPalIndex)
112 bool NameOrIndex::operator==(const SfxPoolItem& rItem) const
114 return ( SfxStringItem::operator==(rItem) &&
115 static_cast<const NameOrIndex&>(rItem).nPalIndex == nPalIndex );
118 NameOrIndex* NameOrIndex::Clone(SfxItemPool* /*pPool*/) const
120 return new NameOrIndex(*this);
123 /** this static checks if the given NameOrIndex item has a unique name for its value.
124 The returned String is a unique name for an item with this value in both given pools.
125 Argument pPool2 can be null.
126 If returned string equals NameOrIndex->GetName(), the name was already unique.
128 OUString NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_uInt16 nWhich, const SfxItemPool* pPool1, SvxCompareValueFunc pCompareValueFunc, const char* pPrefixResId, const XPropertyListRef &pDefaults )
130 bool bForceNew = false;
132 OUString aUniqueName = SvxUnogetInternalNameForItem(nWhich, pCheckItem->GetName());
134 // 2. if we have a name check if there is already an item with the
135 // same name in the documents pool with a different line end or start
137 if (!aUniqueName.isEmpty() && pPool1)
139 for (const SfxPoolItem* pItem : pPool1->GetItemSurrogates(nWhich))
141 const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
143 if( pNameOrIndex->GetName() == pCheckItem->GetName() )
145 // if there is already an item with the same name and the same
146 // value it's ok to set it
147 if( !pCompareValueFunc( pNameOrIndex, pCheckItem ) )
149 // same name but different value, we need a new name for this item
150 aUniqueName.clear();
151 bForceNew = true;
153 break;
158 // if we have no name yet, find existing item with same content or
159 // create a unique name
160 if (aUniqueName.isEmpty())
162 sal_Int32 nUserIndex = 1;
163 const OUString aUser(SvxResId(pPrefixResId) + " ");
165 if( pDefaults )
167 const int nCount = pDefaults->Count();
168 int nIndex;
169 for( nIndex = 0; nIndex < nCount; nIndex++ )
171 const XPropertyEntry* pEntry = pDefaults->Get(nIndex);
172 if( pEntry )
174 bool bFound = false;
176 switch( nWhich )
178 case XATTR_FILLBITMAP:
180 const GraphicObject& rGraphicObjectA(static_cast<const XFillBitmapItem*>(pCheckItem)->GetGraphicObject());
181 const GraphicObject& rGraphicObjectB(static_cast<const XBitmapEntry*>(pEntry)->GetGraphicObject());
183 bFound = (rGraphicObjectA == rGraphicObjectB);
184 break;
186 case XATTR_LINEDASH:
187 bFound = static_cast<const XLineDashItem*>(pCheckItem)->GetDashValue() == static_cast<const XDashEntry*>(pEntry)->GetDash();
188 break;
189 case XATTR_LINESTART:
190 bFound = static_cast<const XLineStartItem*>(pCheckItem)->GetLineStartValue() == static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd();
191 break;
192 case XATTR_LINEEND:
193 bFound = static_cast<const XLineEndItem*>(pCheckItem)->GetLineEndValue() == static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd();
194 break;
195 case XATTR_FILLGRADIENT:
196 bFound = static_cast<const XFillGradientItem*>(pCheckItem)->GetGradientValue() == static_cast<const XGradientEntry*>(pEntry)->GetGradient();
197 break;
198 case XATTR_FILLHATCH:
199 bFound = static_cast<const XFillHatchItem*>(pCheckItem)->GetHatchValue() == static_cast<const XHatchEntry*>(pEntry)->GetHatch();
200 break;
203 if( bFound )
205 aUniqueName = pEntry->GetName();
206 break;
208 else
210 const OUString& aEntryName = pEntry->GetName();
211 if(aEntryName.getLength() >= aUser.getLength())
213 sal_Int32 nThisIndex = aEntryName.copy( aUser.getLength() ).toInt32();
214 if( nThisIndex >= nUserIndex )
215 nUserIndex = nThisIndex + 1;
222 if (aUniqueName.isEmpty() && pPool1)
224 for (const SfxPoolItem* pItem : pPool1->GetItemSurrogates(nWhich))
226 const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
228 if( !pNameOrIndex->GetName().isEmpty() )
230 if( !bForceNew && pCompareValueFunc( pNameOrIndex, pCheckItem ) )
231 return pNameOrIndex->GetName();
233 if( pNameOrIndex->GetName().startsWith( aUser ) )
235 sal_Int32 nThisIndex = pNameOrIndex->GetName().copy( aUser.getLength() ).toInt32();
236 if( nThisIndex >= nUserIndex )
237 nUserIndex = nThisIndex + 1;
241 aUniqueName = aUser + OUString::number( nUserIndex );
245 return aUniqueName;
248 void NameOrIndex::dumpAsXml(xmlTextWriterPtr pWriter) const
250 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("NameOrIndex"));
251 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
252 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("isIndex"), BAD_CAST(OString::boolean(IsIndex()).getStr()));
253 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(GetName().toUtf8().getStr()));
254 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("index"), BAD_CAST(OString::number(nPalIndex).getStr()));
255 (void)xmlTextWriterEndElement(pWriter);
258 SfxPoolItem* XColorItem::CreateDefault() { return new XColorItem; }
260 XColorItem::XColorItem(sal_uInt16 _nWhich, sal_Int32 nIndex, const Color& rTheColor) :
261 NameOrIndex(_nWhich, nIndex),
262 aColor(rTheColor)
266 XColorItem::XColorItem(sal_uInt16 _nWhich, const OUString& rName, const Color& rTheColor) :
267 NameOrIndex(_nWhich, rName),
268 aColor(rTheColor)
272 XColorItem::XColorItem(sal_uInt16 _nWhich, const Color& rTheColor)
273 : NameOrIndex(_nWhich, OUString())
274 , aColor(rTheColor)
278 XColorItem::XColorItem(const XColorItem& rItem) :
279 NameOrIndex(rItem),
280 aColor(rItem.aColor)
284 XColorItem* XColorItem::Clone(SfxItemPool* /*pPool*/) const
286 return new XColorItem(*this);
289 bool XColorItem::operator==(const SfxPoolItem& rItem) const
291 return ( NameOrIndex::operator==(rItem) &&
292 static_cast<const XColorItem&>(rItem).aColor == aColor );
295 const Color& XColorItem::GetColorValue() const
297 assert(!IsIndex());
298 return aColor;
302 bool XColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
304 rVal <<= GetColorValue().GetRGBColor();
305 return true;
308 bool XColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
310 Color nValue;
311 rVal >>= nValue;
312 SetColorValue( nValue );
314 return true;
317 void XColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
319 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XColorItem"));
320 if (Which() == SDRATTR_SHADOWCOLOR)
322 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("SDRATTR_SHADOWCOLOR"));
324 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("aColor"),
325 BAD_CAST(aColor.AsRGBHexString().toUtf8().getStr()));
327 NameOrIndex::dumpAsXml(pWriter);
329 (void)xmlTextWriterEndElement(pWriter);
332 // --- line attributes ---
335 SfxPoolItem* XLineStyleItem::CreateDefault() { return new XLineStyleItem; }
337 XLineStyleItem::XLineStyleItem(css::drawing::LineStyle eTheLineStyle) :
338 SfxEnumItem(XATTR_LINESTYLE, eTheLineStyle)
342 XLineStyleItem* XLineStyleItem::Clone(SfxItemPool* /*pPool*/) const
344 return new XLineStyleItem( *this );
347 bool XLineStyleItem::GetPresentation
349 SfxItemPresentation /*ePres*/,
350 MapUnit /*eCoreUnit*/,
351 MapUnit /*ePresUnit*/,
352 OUString& rText, const IntlWrapper&
353 ) const
355 rText.clear();
357 const char* pId = nullptr;
359 switch( GetValue() )
361 case css::drawing::LineStyle_NONE:
362 pId = RID_SVXSTR_INVISIBLE;
363 break;
364 case css::drawing::LineStyle_SOLID:
365 pId = RID_SVXSTR_SOLID;
366 break;
367 default: break;
370 if (pId)
371 rText = SvxResId(pId);
372 return true;
375 bool XLineStyleItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
377 css::drawing::LineStyle eLS = GetValue();
378 rVal <<= eLS;
379 return true;
382 bool XLineStyleItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
384 css::drawing::LineStyle eLS;
385 if(!(rVal >>= eLS ))
387 // also try an int (for Basic)
388 sal_Int32 nLS = 0;
389 if(!(rVal >>= nLS))
390 return false;
391 eLS = static_cast<css::drawing::LineStyle>(nLS);
394 SetValue( eLS );
395 return true;
398 sal_uInt16 XLineStyleItem::GetValueCount() const
400 return 3;
403 XDash::XDash(css::drawing::DashStyle eTheDash, sal_uInt16 nTheDots, double nTheDotLen,
404 sal_uInt16 nTheDashes, double nTheDashLen, double nTheDistance) :
405 eDash(eTheDash),
406 nDots(nTheDots),
407 nDashes(nTheDashes),
408 nDotLen(nTheDotLen),
409 nDashLen(nTheDashLen),
410 nDistance(nTheDistance)
414 bool XDash::operator==(const XDash& rDash) const
416 return ( eDash == rDash.eDash &&
417 nDots == rDash.nDots &&
418 nDotLen == rDash.nDotLen &&
419 nDashes == rDash.nDashes &&
420 nDashLen == rDash.nDashLen &&
421 nDistance == rDash.nDistance );
424 // XDash is translated into an array of doubles which describe the lengths of the
425 // dashes, dots and empty passages. It returns the complete length of the full DashDot
426 // sequence and fills the given vetor of doubles accordingly (also resizing, so deleting it).
427 const double SMALLEST_DASH_WIDTH(26.95);
429 double XDash::CreateDotDashArray(::std::vector< double >& rDotDashArray, double fLineWidth) const
431 double fFullDotDashLen(0.0);
432 const sal_uInt16 nNumDotDashArray = (GetDots() + GetDashes()) * 2;
433 rDotDashArray.resize( nNumDotDashArray, 0.0 );
434 sal_uInt16 a;
435 sal_uInt16 nIns(0);
436 double fDashDotDistance = GetDistance();
437 double fSingleDashLen = GetDashLen();
438 double fSingleDotLen = GetDotLen();
440 if (fLineWidth == 0.0)
441 fLineWidth = SMALLEST_DASH_WIDTH;
443 if(GetDashStyle() == css::drawing::DashStyle_RECTRELATIVE || GetDashStyle() == css::drawing::DashStyle_ROUNDRELATIVE)
445 double fFactor = fLineWidth / 100.0;
447 if(GetDashes())
449 if(GetDashLen())
451 // is a dash
452 fSingleDashLen *= fFactor;
454 else
456 // is a dot
457 fSingleDashLen = fLineWidth;
461 if(GetDots())
463 if(GetDotLen())
465 // is a dash
466 fSingleDotLen *= fFactor;
468 else
470 // is a dot
471 fSingleDotLen = fLineWidth;
475 if(GetDashes() || GetDots())
477 if(GetDistance())
479 // dash as distance
480 fDashDotDistance *= fFactor;
482 else
484 // dot as distance
485 fDashDotDistance = fLineWidth;
489 else
491 // absolute values
492 if(GetDashes())
494 if(GetDashLen())
496 // is a dash
497 if(fSingleDashLen < SMALLEST_DASH_WIDTH)
499 fSingleDashLen = SMALLEST_DASH_WIDTH;
502 else
504 // is a dot
505 if(fSingleDashLen < fLineWidth)
507 fSingleDashLen = fLineWidth;
512 if(GetDots())
514 if(GetDotLen())
516 // is a dash
517 if(fSingleDotLen < SMALLEST_DASH_WIDTH)
519 fSingleDotLen = SMALLEST_DASH_WIDTH;
522 else
524 // is a dot
525 if(fSingleDotLen < fLineWidth)
527 fSingleDotLen = fLineWidth;
532 if(GetDashes() || GetDots())
534 if(GetDistance())
536 // dash as distance
537 if(fDashDotDistance < SMALLEST_DASH_WIDTH)
539 fDashDotDistance = SMALLEST_DASH_WIDTH;
542 else
544 // dot as distance
545 if(fDashDotDistance < fLineWidth)
547 fDashDotDistance = fLineWidth;
553 for(a=0;a<GetDots();a++)
555 rDotDashArray[nIns++] = fSingleDotLen;
556 fFullDotDashLen += fSingleDotLen;
557 rDotDashArray[nIns++] = fDashDotDistance;
558 fFullDotDashLen += fDashDotDistance;
561 for(a=0;a<GetDashes();a++)
563 rDotDashArray[nIns++] = fSingleDashLen;
564 fFullDotDashLen += fSingleDashLen;
565 rDotDashArray[nIns++] = fDashDotDistance;
566 fFullDotDashLen += fDashDotDistance;
569 return fFullDotDashLen;
572 SfxPoolItem* XLineDashItem::CreateDefault() {return new XLineDashItem;}
574 XLineDashItem::XLineDashItem(const OUString& rName, const XDash& rTheDash) :
575 NameOrIndex(XATTR_LINEDASH, rName),
576 aDash(rTheDash)
580 XLineDashItem::XLineDashItem(const XLineDashItem& rItem) :
581 NameOrIndex(rItem),
582 aDash(rItem.aDash)
586 XLineDashItem::XLineDashItem(const XDash& rTheDash)
587 : NameOrIndex( XATTR_LINEDASH, -1 ),
588 aDash(rTheDash)
592 XLineDashItem* XLineDashItem::Clone(SfxItemPool* /*pPool*/) const
594 return new XLineDashItem(*this);
597 bool XLineDashItem::operator==(const SfxPoolItem& rItem) const
599 return ( NameOrIndex::operator==(rItem) &&
600 aDash == static_cast<const XLineDashItem&>(rItem).aDash );
603 bool XLineDashItem::GetPresentation
605 SfxItemPresentation /*ePres*/,
606 MapUnit /*eCoreUnit*/,
607 MapUnit /*ePresUnit*/,
608 OUString& rText, const IntlWrapper&
609 ) const
611 rText = GetName();
612 return true;
615 bool XLineDashItem::HasMetrics() const
617 return true;
620 void XLineDashItem::ScaleMetrics(tools::Long nMul, tools::Long nDiv)
622 aDash.SetDotLen( BigInt::Scale( aDash.GetDotLen(), nMul, nDiv ) );
623 aDash.SetDashLen( BigInt::Scale( aDash.GetDashLen(), nMul, nDiv ) );
624 aDash.SetDistance( BigInt::Scale( aDash.GetDistance(), nMul, nDiv ) );
627 bool XLineDashItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
629 nMemberId &= ~CONVERT_TWIPS;
631 switch ( nMemberId )
633 case 0:
635 uno::Sequence< beans::PropertyValue > aPropSeq( 2 );
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 aPropSeq[0].Name = "Name";
648 aPropSeq[0].Value <<= SvxUnogetApiNameForItem(Which(), GetName());
649 aPropSeq[1].Name = "LineDash";
650 aPropSeq[1].Value <<= 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 = convertMm100ToTwip(nValue);
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 const char* pId = nullptr;
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()
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 uno::Sequence< beans::PropertyValue > aPropSeq( 2 );
2190 css::awt::Gradient aGradient2;
2192 const XGradient& aXGradient = GetGradientValue();
2193 aGradient2.Style = aXGradient.GetGradientStyle();
2194 aGradient2.StartColor = static_cast<sal_Int32>(aXGradient.GetStartColor());
2195 aGradient2.EndColor = static_cast<sal_Int32>(aXGradient.GetEndColor());
2196 aGradient2.Angle = static_cast<short>(aXGradient.GetAngle());
2197 aGradient2.Border = aXGradient.GetBorder();
2198 aGradient2.XOffset = aXGradient.GetXOffset();
2199 aGradient2.YOffset = aXGradient.GetYOffset();
2200 aGradient2.StartIntensity = aXGradient.GetStartIntens();
2201 aGradient2.EndIntensity = aXGradient.GetEndIntens();
2202 aGradient2.StepCount = aXGradient.GetSteps();
2204 aPropSeq[0].Name = "Name";
2205 aPropSeq[0].Value <<= SvxUnogetApiNameForItem(Which(), GetName());
2206 aPropSeq[1].Name = "FillGradient";
2207 aPropSeq[1].Value <<= aGradient2;
2208 rVal <<= aPropSeq;
2209 break;
2212 case MID_FILLGRADIENT:
2214 const XGradient& aXGradient = GetGradientValue();
2215 css::awt::Gradient aGradient2;
2217 aGradient2.Style = aXGradient.GetGradientStyle();
2218 aGradient2.StartColor = static_cast<sal_Int32>(aXGradient.GetStartColor());
2219 aGradient2.EndColor = static_cast<sal_Int32>(aXGradient.GetEndColor());
2220 aGradient2.Angle = static_cast<short>(aXGradient.GetAngle());
2221 aGradient2.Border = aXGradient.GetBorder();
2222 aGradient2.XOffset = aXGradient.GetXOffset();
2223 aGradient2.YOffset = aXGradient.GetYOffset();
2224 aGradient2.StartIntensity = aXGradient.GetStartIntens();
2225 aGradient2.EndIntensity = aXGradient.GetEndIntens();
2226 aGradient2.StepCount = aXGradient.GetSteps();
2228 rVal <<= aGradient2;
2229 break;
2232 case MID_NAME:
2234 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
2235 break;
2238 case MID_GRADIENT_STYLE: rVal <<= static_cast<sal_Int16>(GetGradientValue().GetGradientStyle()); break;
2239 case MID_GRADIENT_STARTCOLOR: rVal <<= GetGradientValue().GetStartColor(); break;
2240 case MID_GRADIENT_ENDCOLOR: rVal <<= GetGradientValue().GetEndColor(); break;
2241 case MID_GRADIENT_ANGLE: rVal <<= static_cast<sal_Int16>(GetGradientValue().GetAngle()); break;
2242 case MID_GRADIENT_BORDER: rVal <<= GetGradientValue().GetBorder(); break;
2243 case MID_GRADIENT_XOFFSET: rVal <<= GetGradientValue().GetXOffset(); break;
2244 case MID_GRADIENT_YOFFSET: rVal <<= GetGradientValue().GetYOffset(); break;
2245 case MID_GRADIENT_STARTINTENSITY: rVal <<= GetGradientValue().GetStartIntens(); break;
2246 case MID_GRADIENT_ENDINTENSITY: rVal <<= GetGradientValue().GetEndIntens(); break;
2247 case MID_GRADIENT_STEPCOUNT: rVal <<= GetGradientValue().GetSteps(); break;
2249 default: OSL_FAIL("Wrong MemberId!"); return false;
2252 return true;
2255 bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2257 nMemberId &= ~CONVERT_TWIPS;
2259 switch ( nMemberId )
2261 case 0:
2263 uno::Sequence< beans::PropertyValue > aPropSeq;
2265 if ( rVal >>= aPropSeq )
2267 css::awt::Gradient aGradient2;
2268 OUString aName;
2269 bool bGradient( false );
2270 for ( const auto& rProp : std::as_const(aPropSeq) )
2272 if ( rProp.Name == "Name" )
2273 rProp.Value >>= aName;
2274 else if ( rProp.Name == "FillGradient" )
2276 if ( rProp.Value >>= aGradient2 )
2277 bGradient = true;
2281 SetName( aName );
2282 if ( bGradient )
2284 XGradient aXGradient;
2286 aXGradient.SetGradientStyle( aGradient2.Style );
2287 aXGradient.SetStartColor( Color(ColorTransparency, aGradient2.StartColor) );
2288 aXGradient.SetEndColor( Color(ColorTransparency, aGradient2.EndColor) );
2289 aXGradient.SetAngle( Degree10(aGradient2.Angle) );
2290 aXGradient.SetBorder( aGradient2.Border );
2291 aXGradient.SetXOffset( aGradient2.XOffset );
2292 aXGradient.SetYOffset( aGradient2.YOffset );
2293 aXGradient.SetStartIntens( aGradient2.StartIntensity );
2294 aXGradient.SetEndIntens( aGradient2.EndIntensity );
2295 aXGradient.SetSteps( aGradient2.StepCount );
2297 SetGradientValue( aXGradient );
2300 return true;
2303 return false;
2306 case MID_NAME:
2308 OUString aName;
2309 if (!(rVal >>= aName ))
2310 return false;
2311 SetName( aName );
2312 break;
2315 case MID_FILLGRADIENT:
2317 css::awt::Gradient aGradient2;
2318 if(!(rVal >>= aGradient2))
2319 return false;
2321 XGradient aXGradient;
2323 aXGradient.SetGradientStyle( aGradient2.Style );
2324 aXGradient.SetStartColor( Color(ColorTransparency, aGradient2.StartColor) );
2325 aXGradient.SetEndColor( Color(ColorTransparency, aGradient2.EndColor) );
2326 aXGradient.SetAngle( Degree10(aGradient2.Angle) );
2327 aXGradient.SetBorder( aGradient2.Border );
2328 aXGradient.SetXOffset( aGradient2.XOffset );
2329 aXGradient.SetYOffset( aGradient2.YOffset );
2330 aXGradient.SetStartIntens( aGradient2.StartIntensity );
2331 aXGradient.SetEndIntens( aGradient2.EndIntensity );
2332 aXGradient.SetSteps( aGradient2.StepCount );
2334 SetGradientValue( aXGradient );
2335 break;
2338 case MID_GRADIENT_STARTCOLOR:
2339 case MID_GRADIENT_ENDCOLOR:
2341 Color nVal;
2342 if(!(rVal >>= nVal ))
2343 return false;
2345 XGradient aXGradient = GetGradientValue();
2347 if ( nMemberId == MID_GRADIENT_STARTCOLOR )
2348 aXGradient.SetStartColor( nVal );
2349 else
2350 aXGradient.SetEndColor( nVal );
2351 SetGradientValue( aXGradient );
2352 break;
2355 case MID_GRADIENT_STYLE:
2356 case MID_GRADIENT_ANGLE:
2357 case MID_GRADIENT_BORDER:
2358 case MID_GRADIENT_STARTINTENSITY:
2359 case MID_GRADIENT_ENDINTENSITY:
2360 case MID_GRADIENT_STEPCOUNT:
2361 case MID_GRADIENT_XOFFSET:
2362 case MID_GRADIENT_YOFFSET:
2364 sal_Int16 nVal = sal_Int16();
2365 if(!(rVal >>= nVal ))
2366 return false;
2368 XGradient aXGradient = GetGradientValue();
2370 switch ( nMemberId )
2372 case MID_GRADIENT_STYLE:
2373 aXGradient.SetGradientStyle( static_cast<css::awt::GradientStyle>(nVal) ); break;
2374 case MID_GRADIENT_ANGLE:
2375 aXGradient.SetAngle( Degree10(nVal) ); break;
2376 case MID_GRADIENT_BORDER:
2377 aXGradient.SetBorder( nVal ); break;
2378 case MID_GRADIENT_STARTINTENSITY:
2379 aXGradient.SetStartIntens( nVal ); break;
2380 case MID_GRADIENT_ENDINTENSITY:
2381 aXGradient.SetEndIntens( nVal ); break;
2382 case MID_GRADIENT_STEPCOUNT:
2383 aXGradient.SetSteps( nVal ); break;
2384 case MID_GRADIENT_XOFFSET:
2385 aXGradient.SetXOffset( nVal ); break;
2386 case MID_GRADIENT_YOFFSET:
2387 aXGradient.SetYOffset( nVal ); break;
2390 SetGradientValue( aXGradient );
2391 break;
2395 return true;
2398 bool XFillGradientItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2400 return static_cast<const XFillGradientItem*>(p1)->GetGradientValue() == static_cast<const XFillGradientItem*>(p2)->GetGradientValue();
2403 std::unique_ptr<XFillGradientItem> XFillGradientItem::checkForUniqueItem( SdrModel* pModel ) const
2405 if( pModel )
2407 const OUString aUniqueName = NameOrIndex::CheckNamedItem(
2408 this, Which(), &pModel->GetItemPool(),
2409 XFillGradientItem::CompareValueFunc, RID_SVXSTR_GRADIENT,
2410 pModel->GetPropertyList( XPropertyListType::Gradient ) );
2412 // if the given name is not valid, replace it!
2413 if( aUniqueName != GetName() )
2414 return std::make_unique<XFillGradientItem>( aUniqueName, aGradient, Which() );
2417 return nullptr;
2420 boost::property_tree::ptree XFillGradientItem::dumpAsJSON() const
2422 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
2424 if (Which() == XATTR_FILLGRADIENT)
2425 aTree.put("commandName", ".uno:FillGradient");
2427 aTree.push_back(std::make_pair("state", GetGradientValue().dumpAsJSON()));
2429 return aTree;
2433 SfxPoolItem* XFillFloatTransparenceItem::CreateDefault() { return new XFillFloatTransparenceItem; }
2435 XFillFloatTransparenceItem::XFillFloatTransparenceItem() :
2436 bEnabled( false )
2438 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2441 XFillFloatTransparenceItem::XFillFloatTransparenceItem(const OUString& rName, const XGradient& rGradient, bool bEnable ) :
2442 XFillGradientItem ( rName, rGradient ),
2443 bEnabled ( bEnable )
2445 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2448 XFillFloatTransparenceItem::XFillFloatTransparenceItem( const XFillFloatTransparenceItem& rItem ) :
2449 XFillGradientItem ( rItem ),
2450 bEnabled ( rItem.bEnabled )
2452 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2455 XFillFloatTransparenceItem::XFillFloatTransparenceItem(const XGradient& rTheGradient, bool bEnable )
2456 : XFillGradientItem ( -1, rTheGradient ),
2457 bEnabled ( bEnable )
2459 SetWhich( XATTR_FILLFLOATTRANSPARENCE );
2462 bool XFillFloatTransparenceItem::operator==( const SfxPoolItem& rItem ) const
2464 return ( NameOrIndex::operator==(rItem) ) &&
2465 ( GetGradientValue() == static_cast<const XFillGradientItem&>(rItem).GetGradientValue() ) &&
2466 ( bEnabled == static_cast<const XFillFloatTransparenceItem&>(rItem).bEnabled );
2469 XFillFloatTransparenceItem* XFillFloatTransparenceItem::Clone( SfxItemPool* /*pPool*/) const
2471 return new XFillFloatTransparenceItem( *this );
2474 bool XFillFloatTransparenceItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2476 return XFillGradientItem::QueryValue( rVal, nMemberId );
2479 bool XFillFloatTransparenceItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2481 return XFillGradientItem::PutValue( rVal, nMemberId );
2484 bool XFillFloatTransparenceItem::GetPresentation( SfxItemPresentation ePres,
2485 MapUnit eCoreUnit, MapUnit ePresUnit,
2486 OUString& rText,
2487 const IntlWrapper& rIntlWrapper ) const
2489 return XFillGradientItem::GetPresentation( ePres, eCoreUnit, ePresUnit, rText, rIntlWrapper );
2492 bool XFillFloatTransparenceItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2494 return static_cast<const XFillFloatTransparenceItem*>(p1)->IsEnabled() == static_cast<const XFillFloatTransparenceItem*>(p2)->IsEnabled() &&
2495 static_cast<const XFillFloatTransparenceItem*>(p1)->GetGradientValue() == static_cast<const XFillFloatTransparenceItem*>(p2)->GetGradientValue();
2498 std::unique_ptr<XFillFloatTransparenceItem> XFillFloatTransparenceItem::checkForUniqueItem( SdrModel* pModel ) const
2500 // #85953# unique name only necessary when enabled
2501 if(IsEnabled())
2503 if( pModel )
2505 const OUString aUniqueName = NameOrIndex::CheckNamedItem( this,
2506 XATTR_FILLFLOATTRANSPARENCE,
2507 &pModel->GetItemPool(),
2508 XFillFloatTransparenceItem::CompareValueFunc,
2509 RID_SVXSTR_TRASNGR0,
2510 XPropertyListRef() );
2512 // if the given name is not valid, replace it!
2513 if( aUniqueName != GetName() )
2515 return std::make_unique<XFillFloatTransparenceItem>( aUniqueName, GetGradientValue(), true );
2519 else
2521 // #85953# if disabled, force name to empty string
2522 if( !GetName().isEmpty() )
2524 return std::make_unique<XFillFloatTransparenceItem>(OUString(), GetGradientValue(), false);
2528 return nullptr;
2531 boost::property_tree::ptree XFillFloatTransparenceItem::dumpAsJSON() const
2533 boost::property_tree::ptree aTree = XFillGradientItem::dumpAsJSON();
2534 aTree.put("commandName", ".uno:FillFloatTransparence");
2536 if (!bEnabled)
2538 boost::property_tree::ptree& rState = aTree.get_child("state");
2539 // When gradient fill is disabled, the intensity fields contain the
2540 // constant encoded percent-transparency. However we use that here to just
2541 // distinguish between 'None' and 'Solid' types and correct the 'style'
2542 // property appropriately.
2543 if (GetGradientValue().GetStartIntens() == 100)
2544 rState.put("style", "NONE");
2545 else
2546 rState.put("style", "SOLID");
2549 return aTree;
2552 XHatch::XHatch(const Color& rCol, css::drawing::HatchStyle eTheStyle, tools::Long nTheDistance,
2553 Degree10 nTheAngle) :
2554 eStyle(eTheStyle),
2555 aColor(rCol),
2556 nDistance(nTheDistance),
2557 nAngle(nTheAngle)
2561 bool XHatch::operator==(const XHatch& rHatch) const
2563 return ( eStyle == rHatch.eStyle &&
2564 aColor == rHatch.aColor &&
2565 nDistance == rHatch.nDistance &&
2566 nAngle == rHatch.nAngle );
2570 SfxPoolItem* XFillHatchItem::CreateDefault() { return new XFillHatchItem; }
2572 XFillHatchItem::XFillHatchItem(const OUString& rName,
2573 const XHatch& rTheHatch) :
2574 NameOrIndex(XATTR_FILLHATCH, rName),
2575 aHatch(rTheHatch)
2579 XFillHatchItem::XFillHatchItem(const XFillHatchItem& rItem) :
2580 NameOrIndex(rItem),
2581 aHatch(rItem.aHatch)
2585 XFillHatchItem::XFillHatchItem(const XHatch& rTheHatch)
2586 : NameOrIndex( XATTR_FILLHATCH, -1 ),
2587 aHatch(rTheHatch)
2591 XFillHatchItem* XFillHatchItem::Clone(SfxItemPool* /*pPool*/) const
2593 return new XFillHatchItem(*this);
2596 bool XFillHatchItem::operator==(const SfxPoolItem& rItem) const
2598 return ( NameOrIndex::operator==(rItem) &&
2599 aHatch == static_cast<const XFillHatchItem&>(rItem).aHatch );
2602 bool XFillHatchItem::GetPresentation
2604 SfxItemPresentation /*ePres*/,
2605 MapUnit /*eCoreUnit*/,
2606 MapUnit /*ePresUnit*/,
2607 OUString& rText, const IntlWrapper&
2608 ) const
2610 rText = GetName();
2611 return true;
2614 bool XFillHatchItem::HasMetrics() const
2616 return true;
2619 void XFillHatchItem::ScaleMetrics(tools::Long nMul, tools::Long nDiv)
2621 aHatch.SetDistance( BigInt::Scale( aHatch.GetDistance(), nMul, nDiv ) );
2624 bool XFillHatchItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
2626 nMemberId &= ~CONVERT_TWIPS;
2628 switch ( nMemberId )
2630 case 0:
2632 uno::Sequence< beans::PropertyValue > aPropSeq( 2 );
2634 css::drawing::Hatch aUnoHatch;
2636 aUnoHatch.Style = aHatch.GetHatchStyle();
2637 aUnoHatch.Color = sal_Int32(aHatch.GetColor());
2638 aUnoHatch.Distance = aHatch.GetDistance();
2639 aUnoHatch.Angle = aHatch.GetAngle().get();
2641 aPropSeq[0].Name = "Name";
2642 aPropSeq[0].Value <<= SvxUnogetApiNameForItem(Which(), GetName());
2643 aPropSeq[1].Name = "FillHatch";
2644 aPropSeq[1].Value <<= aUnoHatch;
2645 rVal <<= aPropSeq;
2646 break;
2649 case MID_FILLHATCH:
2651 css::drawing::Hatch aUnoHatch;
2653 aUnoHatch.Style = aHatch.GetHatchStyle();
2654 aUnoHatch.Color = sal_Int32(aHatch.GetColor());
2655 aUnoHatch.Distance = aHatch.GetDistance();
2656 aUnoHatch.Angle = aHatch.GetAngle().get();
2657 rVal <<= aUnoHatch;
2658 break;
2661 case MID_NAME:
2663 rVal <<= SvxUnogetApiNameForItem(Which(), GetName());
2664 break;
2667 case MID_HATCH_STYLE:
2668 rVal <<= aHatch.GetHatchStyle(); break;
2669 case MID_HATCH_COLOR:
2670 rVal <<= aHatch.GetColor(); break;
2671 case MID_HATCH_DISTANCE:
2672 rVal <<= aHatch.GetDistance(); break;
2673 case MID_HATCH_ANGLE:
2674 rVal <<= aHatch.GetAngle().get(); break;
2676 default: OSL_FAIL("Wrong MemberId!"); return false;
2679 return true;
2682 bool XFillHatchItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
2684 nMemberId &= ~CONVERT_TWIPS;
2686 switch ( nMemberId )
2688 case 0:
2690 uno::Sequence< beans::PropertyValue > aPropSeq;
2691 if ( rVal >>= aPropSeq )
2693 css::drawing::Hatch aUnoHatch;
2694 OUString aName;
2695 bool bHatch( false );
2696 for ( const auto& rProp : std::as_const(aPropSeq) )
2698 if ( rProp.Name == "Name" )
2699 rProp.Value >>= aName;
2700 else if ( rProp.Name == "FillHatch" )
2702 if ( rProp.Value >>= aUnoHatch )
2703 bHatch = true;
2707 SetName( aName );
2708 if ( bHatch )
2710 aHatch.SetHatchStyle( aUnoHatch.Style );
2711 aHatch.SetColor( Color(ColorTransparency, aUnoHatch.Color) );
2712 aHatch.SetDistance( aUnoHatch.Distance );
2713 aHatch.SetAngle( Degree10(aUnoHatch.Angle) );
2716 return true;
2719 return false;
2722 case MID_FILLHATCH:
2724 css::drawing::Hatch aUnoHatch;
2725 if(!(rVal >>= aUnoHatch))
2726 return false;
2728 aHatch.SetHatchStyle( aUnoHatch.Style );
2729 aHatch.SetColor( Color(ColorTransparency, aUnoHatch.Color) );
2730 aHatch.SetDistance( aUnoHatch.Distance );
2731 aHatch.SetAngle( Degree10(aUnoHatch.Angle) );
2732 break;
2735 case MID_NAME:
2737 OUString aName;
2738 if (!(rVal >>= aName ))
2739 return false;
2740 SetName( aName );
2741 break;
2744 case MID_HATCH_STYLE:
2746 sal_Int16 nVal = sal_Int16();
2747 if (!(rVal >>= nVal ))
2748 return false;
2749 aHatch.SetHatchStyle( static_cast<css::drawing::HatchStyle>(nVal) );
2750 break;
2753 case MID_HATCH_COLOR:
2754 case MID_HATCH_DISTANCE:
2755 case MID_HATCH_ANGLE:
2757 sal_Int32 nVal = 0;
2758 if (!(rVal >>= nVal ))
2759 return false;
2761 if ( nMemberId == MID_HATCH_COLOR )
2762 aHatch.SetColor( Color(ColorTransparency, nVal) );
2763 else if ( nMemberId == MID_HATCH_DISTANCE )
2764 aHatch.SetDistance( nVal );
2765 else
2766 aHatch.SetAngle( Degree10(nVal) );
2767 break;
2770 default: OSL_FAIL("Wrong MemberId!"); return false;
2773 return true;
2776 bool XFillHatchItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
2778 return static_cast<const XFillHatchItem*>(p1)->GetHatchValue() == static_cast<const XFillHatchItem*>(p2)->GetHatchValue();
2781 std::unique_ptr<XFillHatchItem> XFillHatchItem::checkForUniqueItem( SdrModel* pModel ) const
2783 if( pModel )
2785 const OUString aUniqueName = NameOrIndex::CheckNamedItem(
2786 this, XATTR_FILLHATCH, &pModel->GetItemPool(),
2787 XFillHatchItem::CompareValueFunc, RID_SVXSTR_HATCH10,
2788 pModel->GetPropertyList( XPropertyListType::Hatch ) );
2790 // if the given name is not valid, replace it!
2791 if( aUniqueName != GetName() )
2792 return std::make_unique<XFillHatchItem>( aUniqueName, aHatch );
2795 return nullptr;
2798 // --- form text attributes ---
2801 SfxPoolItem* XFormTextStyleItem::CreateDefault() { return new XFormTextStyleItem; }
2803 XFormTextStyleItem::XFormTextStyleItem(XFormTextStyle eTheStyle) :
2804 SfxEnumItem(XATTR_FORMTXTSTYLE, eTheStyle)
2808 XFormTextStyleItem* XFormTextStyleItem::Clone(SfxItemPool* /*pPool*/) const
2810 return new XFormTextStyleItem( *this );
2813 sal_uInt16 XFormTextStyleItem::GetValueCount() const
2815 return 5;
2818 bool XFormTextStyleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2820 rVal <<= static_cast<sal_Int32>(GetValue());
2821 return true;
2824 bool XFormTextStyleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2826 sal_Int32 nValue = 0;
2827 rVal >>= nValue;
2828 SetValue(static_cast<XFormTextStyle>(nValue));
2830 return true;
2834 SfxPoolItem* XFormTextAdjustItem::CreateDefault() { return new XFormTextAdjustItem; }
2836 XFormTextAdjustItem::XFormTextAdjustItem(XFormTextAdjust eTheAdjust) :
2837 SfxEnumItem(XATTR_FORMTXTADJUST, eTheAdjust)
2841 XFormTextAdjustItem* XFormTextAdjustItem::Clone(SfxItemPool* /*pPool*/) const
2843 return new XFormTextAdjustItem( *this );
2846 sal_uInt16 XFormTextAdjustItem::GetValueCount() const
2848 return 4;
2851 bool XFormTextAdjustItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2853 rVal <<= static_cast<sal_Int32>(GetValue());
2854 return true;
2857 bool XFormTextAdjustItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2859 sal_Int32 nValue = 0;
2860 rVal >>= nValue;
2861 SetValue(static_cast<XFormTextAdjust>(nValue));
2863 return true;
2867 SfxPoolItem* XFormTextDistanceItem::CreateDefault() { return new XFormTextDistanceItem; }
2869 XFormTextDistanceItem::XFormTextDistanceItem(tools::Long nDist) :
2870 SfxMetricItem(XATTR_FORMTXTDISTANCE, nDist)
2874 XFormTextDistanceItem* XFormTextDistanceItem::Clone(SfxItemPool* /*pPool*/) const
2876 return new XFormTextDistanceItem(*this);
2879 SfxPoolItem* XFormTextStartItem::CreateDefault() { return new XFormTextStartItem; }
2881 XFormTextStartItem::XFormTextStartItem(tools::Long nStart) :
2882 SfxMetricItem(XATTR_FORMTXTSTART, nStart)
2886 XFormTextStartItem* XFormTextStartItem::Clone(SfxItemPool* /*pPool*/) const
2888 return new XFormTextStartItem(*this);
2891 SfxPoolItem* XFormTextMirrorItem::CreateDefault() { return new XFormTextMirrorItem; }
2893 XFormTextMirrorItem::XFormTextMirrorItem(bool bMirror) :
2894 SfxBoolItem(XATTR_FORMTXTMIRROR, bMirror)
2898 XFormTextMirrorItem* XFormTextMirrorItem::Clone(SfxItemPool* /*pPool*/) const
2900 return new XFormTextMirrorItem(*this);
2903 SfxPoolItem* XFormTextOutlineItem::CreateDefault() { return new XFormTextOutlineItem; }
2905 XFormTextOutlineItem::XFormTextOutlineItem(bool bOutline) :
2906 SfxBoolItem(XATTR_FORMTXTOUTLINE, bOutline)
2910 XFormTextOutlineItem* XFormTextOutlineItem::Clone(SfxItemPool* /*pPool*/) const
2912 return new XFormTextOutlineItem(*this);
2915 SfxPoolItem* XFormTextShadowItem::CreateDefault() { return new XFormTextShadowItem; }
2917 XFormTextShadowItem::XFormTextShadowItem(XFormTextShadow eFormTextShadow) :
2918 SfxEnumItem(XATTR_FORMTXTSHADOW, eFormTextShadow)
2922 XFormTextShadowItem* XFormTextShadowItem::Clone(SfxItemPool* /*pPool*/) const
2924 return new XFormTextShadowItem( *this );
2927 sal_uInt16 XFormTextShadowItem::GetValueCount() const
2929 return 3;
2932 bool XFormTextShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
2934 rVal <<= static_cast<sal_Int32>(GetValue());
2935 return true;
2938 bool XFormTextShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
2940 sal_Int32 nValue = 0;
2941 rVal >>= nValue;
2942 SetValue(static_cast<XFormTextShadow>(nValue));
2944 return true;
2948 SfxPoolItem* XFormTextShadowColorItem::CreateDefault() { return new XFormTextShadowColorItem; }
2950 XFormTextShadowColorItem::XFormTextShadowColorItem(const OUString& rName,
2951 const Color& rTheColor) :
2952 XColorItem(XATTR_FORMTXTSHDWCOLOR, rName, rTheColor)
2956 XFormTextShadowColorItem* XFormTextShadowColorItem::Clone(SfxItemPool* /*pPool*/) const
2958 return new XFormTextShadowColorItem(*this);
2961 SfxPoolItem* XFormTextShadowXValItem::CreateDefault() { return new XFormTextShadowXValItem; }
2963 XFormTextShadowXValItem::XFormTextShadowXValItem(tools::Long nVal) :
2964 SfxMetricItem(XATTR_FORMTXTSHDWXVAL, nVal)
2968 XFormTextShadowXValItem* XFormTextShadowXValItem::Clone(SfxItemPool* /*pPool*/) const
2970 return new XFormTextShadowXValItem(*this);
2973 SfxPoolItem* XFormTextShadowYValItem::CreateDefault() { return new XFormTextShadowYValItem; }
2975 XFormTextShadowYValItem::XFormTextShadowYValItem(tools::Long nVal) :
2976 SfxMetricItem(XATTR_FORMTXTSHDWYVAL, nVal)
2980 XFormTextShadowYValItem* XFormTextShadowYValItem::Clone(SfxItemPool* /*pPool*/) const
2982 return new XFormTextShadowYValItem(*this);
2985 SfxPoolItem* XFormTextHideFormItem::CreateDefault() { return new XFormTextHideFormItem; }
2987 XFormTextHideFormItem::XFormTextHideFormItem(bool bHide) :
2988 SfxBoolItem(XATTR_FORMTXTHIDEFORM, bHide)
2992 XFormTextHideFormItem* XFormTextHideFormItem::Clone(SfxItemPool* /*pPool*/) const
2994 return new XFormTextHideFormItem(*this);
2997 // --- SetItems ---
3000 /// a line attribute set item
3001 XLineAttrSetItem::XLineAttrSetItem( std::unique_ptr<SfxItemSet>&& pItemSet ) :
3002 SfxSetItem( XATTRSET_LINE, std::move(pItemSet))
3006 XLineAttrSetItem::XLineAttrSetItem( SfxItemPool* pItemPool ) :
3007 SfxSetItem( XATTRSET_LINE,
3008 std::make_unique<SfxItemSet>( *pItemPool, svl::Items<XATTR_LINE_FIRST, XATTR_LINE_LAST>{}))
3012 XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr ) :
3013 SfxSetItem( rLineAttr )
3017 XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr,
3018 SfxItemPool* pItemPool) :
3019 SfxSetItem( rLineAttr, pItemPool )
3023 XLineAttrSetItem* XLineAttrSetItem::Clone( SfxItemPool* pPool ) const
3025 return new XLineAttrSetItem( *this, pPool );
3028 /// fill attribute set item
3029 XFillAttrSetItem::XFillAttrSetItem( std::unique_ptr<SfxItemSet>&& pItemSet ) :
3030 SfxSetItem( XATTRSET_FILL, std::move(pItemSet))
3034 XFillAttrSetItem::XFillAttrSetItem( SfxItemPool* pItemPool ) :
3035 SfxSetItem( XATTRSET_FILL,
3036 std::make_unique<SfxItemSet>( *pItemPool, svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}))
3040 XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr ) :
3041 SfxSetItem( rFillAttr )
3045 XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr,
3046 SfxItemPool* pItemPool ) :
3047 SfxSetItem( rFillAttr, pItemPool )
3051 XFillAttrSetItem* XFillAttrSetItem::Clone( SfxItemPool* pPool ) const
3053 return new XFillAttrSetItem( *this, pPool );
3056 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */