1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
24 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
25 #include <com/sun/star/drawing/Hatch.hpp>
26 #include <com/sun/star/drawing/LineStyle.hpp>
27 #include <com/sun/star/drawing/LineDash.hpp>
28 #include <com/sun/star/drawing/DashStyle.hpp>
29 #include <com/sun/star/drawing/FillStyle.hpp>
30 #include <com/sun/star/awt/Gradient.hpp>
31 #include <com/sun/star/uno/Sequence.hxx>
32 #include <com/sun/star/beans/PropertyValue.hpp>
34 #include <comphelper/propertyvalue.hxx>
35 #include <o3tl/any.hxx>
36 #include <svl/itempool.hxx>
37 #include <editeng/memberids.h>
38 #include <tools/mapunit.hxx>
39 #include <tools/UnitConversion.hxx>
40 #include <osl/diagnose.h>
42 #include <svx/unoapi.hxx>
43 #include <svl/style.hxx>
45 #include <tools/bigint.hxx>
46 #include <svl/itemset.hxx>
47 #include <svx/strings.hrc>
48 #include <svx/xfillit0.hxx>
49 #include <svx/xflasit.hxx>
50 #include <svx/xlineit0.hxx>
51 #include <svx/xlnasit.hxx>
52 #include <svx/xtextit0.hxx>
53 #include <svx/xtable.hxx>
54 #include <svx/dialmgr.hxx>
55 #include <svx/xflclit.hxx>
56 #include <svx/xflgrit.hxx>
57 #include <svx/xflftrit.hxx>
58 #include <svx/xsflclit.hxx>
59 #include <svx/xflhtit.hxx>
60 #include <svx/xbtmpit.hxx>
61 #include <svx/xlndsit.hxx>
62 #include <svx/xlnwtit.hxx>
63 #include <svx/xlnclit.hxx>
64 #include <svx/xlnstit.hxx>
65 #include <svx/xlnedit.hxx>
66 #include <svx/xlnstwit.hxx>
67 #include <svx/xlnedwit.hxx>
68 #include <svx/xlnstcit.hxx>
69 #include <svx/xlnedcit.hxx>
70 #include <editeng/itemtype.hxx>
71 #include <editeng/eerdll.hxx>
72 #include <svx/xdef.hxx>
73 #include <svx/unomid.hxx>
74 #include <svx/svdmodel.hxx>
75 #include <svx/xftdiit.hxx>
76 #include <svx/xftstit.hxx>
77 #include <svx/xftmrit.hxx>
78 #include <svx/xftouit.hxx>
79 #include <svx/xftshit.hxx>
80 #include <svx/xftshcit.hxx>
81 #include <svx/xftshxy.hxx>
82 #include <svx/xftadit.hxx>
83 #include <svx/svddef.hxx>
84 #include <basegfx/polygon/b2dpolypolygontools.hxx>
85 #include <unotools/intlwrapper.hxx>
86 #include <unotools/syslocale.hxx>
89 #include <boost/property_tree/json_parser.hpp>
90 #include <libxml/xmlwriter.h>
92 using namespace ::com::sun::star
;
94 typedef std::map
<OUString
, OUString
> StringMap
;
96 NameOrIndex::NameOrIndex(sal_uInt16 _nWhich
, sal_Int32 nIndex
) :
97 SfxStringItem(_nWhich
, OUString()),
102 NameOrIndex::NameOrIndex(sal_uInt16 _nWhich
, const OUString
& rName
) :
103 SfxStringItem(_nWhich
, rName
),
108 NameOrIndex::NameOrIndex(const NameOrIndex
& rNameOrIndex
) :
109 SfxStringItem(rNameOrIndex
),
110 nPalIndex(rNameOrIndex
.nPalIndex
)
114 bool NameOrIndex::operator==(const SfxPoolItem
& rItem
) const
116 return ( SfxStringItem::operator==(rItem
) &&
117 static_cast<const NameOrIndex
&>(rItem
).nPalIndex
== nPalIndex
);
120 NameOrIndex
* NameOrIndex::Clone(SfxItemPool
* /*pPool*/) const
122 return new NameOrIndex(*this);
125 /** this static checks if the given NameOrIndex item has a unique name for its value.
126 The returned String is a unique name for an item with this value in both given pools.
127 Argument pPool2 can be null.
128 If returned string equals NameOrIndex->GetName(), the name was already unique.
130 OUString
NameOrIndex::CheckNamedItem( const NameOrIndex
* pCheckItem
, const sal_uInt16 nWhich
, const SfxItemPool
* pPool1
, SvxCompareValueFunc pCompareValueFunc
, TranslateId pPrefixResId
, const XPropertyListRef
&pDefaults
)
132 bool bForceNew
= false;
134 OUString aUniqueName
= SvxUnogetInternalNameForItem(nWhich
, pCheckItem
->GetName());
136 // 2. if we have a name check if there is already an item with the
137 // same name in the documents pool with a different line end or start
139 if (!aUniqueName
.isEmpty() && pPool1
)
141 for (const SfxPoolItem
* pItem
: pPool1
->GetItemSurrogates(nWhich
))
143 const NameOrIndex
*pNameOrIndex
= static_cast<const NameOrIndex
*>(pItem
);
145 if( pNameOrIndex
->GetName() == pCheckItem
->GetName() )
147 // if there is already an item with the same name and the same
148 // value it's ok to set it
149 if( !pCompareValueFunc( pNameOrIndex
, pCheckItem
) )
151 // same name but different value, we need a new name for this item
160 // if we have no name yet, find existing item with same content or
161 // create a unique name
162 if (aUniqueName
.isEmpty())
164 sal_Int32 nUserIndex
= 1;
165 const OUString
aUser(SvxResId(pPrefixResId
) + " ");
169 const int nCount
= pDefaults
->Count();
171 for( nIndex
= 0; nIndex
< nCount
; nIndex
++ )
173 const XPropertyEntry
* pEntry
= pDefaults
->Get(nIndex
);
180 case XATTR_FILLBITMAP
:
182 const GraphicObject
& rGraphicObjectA(static_cast<const XFillBitmapItem
*>(pCheckItem
)->GetGraphicObject());
183 const GraphicObject
& rGraphicObjectB(static_cast<const XBitmapEntry
*>(pEntry
)->GetGraphicObject());
185 bFound
= (rGraphicObjectA
== rGraphicObjectB
);
189 bFound
= static_cast<const XLineDashItem
*>(pCheckItem
)->GetDashValue() == static_cast<const XDashEntry
*>(pEntry
)->GetDash();
191 case XATTR_LINESTART
:
192 bFound
= static_cast<const XLineStartItem
*>(pCheckItem
)->GetLineStartValue() == static_cast<const XLineEndEntry
*>(pEntry
)->GetLineEnd();
195 bFound
= static_cast<const XLineEndItem
*>(pCheckItem
)->GetLineEndValue() == static_cast<const XLineEndEntry
*>(pEntry
)->GetLineEnd();
197 case XATTR_FILLGRADIENT
:
198 bFound
= static_cast<const XFillGradientItem
*>(pCheckItem
)->GetGradientValue() == static_cast<const XGradientEntry
*>(pEntry
)->GetGradient();
200 case XATTR_FILLHATCH
:
201 bFound
= static_cast<const XFillHatchItem
*>(pCheckItem
)->GetHatchValue() == static_cast<const XHatchEntry
*>(pEntry
)->GetHatch();
207 aUniqueName
= pEntry
->GetName();
212 const OUString
& aEntryName
= pEntry
->GetName();
213 if(aEntryName
.getLength() >= aUser
.getLength())
215 sal_Int32 nThisIndex
= aEntryName
.copy( aUser
.getLength() ).toInt32();
216 if( nThisIndex
>= nUserIndex
)
217 nUserIndex
= nThisIndex
+ 1;
224 if (aUniqueName
.isEmpty() && pPool1
)
226 for (const SfxPoolItem
* pItem
: pPool1
->GetItemSurrogates(nWhich
))
228 const NameOrIndex
*pNameOrIndex
= static_cast<const NameOrIndex
*>(pItem
);
230 if( !pNameOrIndex
->GetName().isEmpty() )
232 if( !bForceNew
&& pCompareValueFunc( pNameOrIndex
, pCheckItem
) )
233 return pNameOrIndex
->GetName();
235 if( pNameOrIndex
->GetName().startsWith( aUser
) )
237 sal_Int32 nThisIndex
= pNameOrIndex
->GetName().copy( aUser
.getLength() ).toInt32();
238 if( nThisIndex
>= nUserIndex
)
239 nUserIndex
= nThisIndex
+ 1;
243 aUniqueName
= aUser
+ OUString::number( nUserIndex
);
250 void NameOrIndex::dumpAsXml(xmlTextWriterPtr pWriter
) const
252 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("NameOrIndex"));
253 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
254 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("isIndex"), BAD_CAST(OString::boolean(IsIndex()).getStr()));
255 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("name"), BAD_CAST(GetName().toUtf8().getStr()));
256 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("index"), BAD_CAST(OString::number(nPalIndex
).getStr()));
257 (void)xmlTextWriterEndElement(pWriter
);
260 SfxPoolItem
* XColorItem::CreateDefault() { return new XColorItem
; }
262 XColorItem::XColorItem(sal_uInt16 _nWhich
, sal_Int32 nIndex
, const Color
& rTheColor
) :
263 NameOrIndex(_nWhich
, nIndex
),
268 XColorItem::XColorItem(sal_uInt16 _nWhich
, const OUString
& rName
, const Color
& rTheColor
) :
269 NameOrIndex(_nWhich
, rName
),
274 XColorItem::XColorItem(sal_uInt16 _nWhich
, const Color
& rTheColor
)
275 : NameOrIndex(_nWhich
, OUString())
280 XColorItem::XColorItem(const XColorItem
& rItem
) :
286 XColorItem
* XColorItem::Clone(SfxItemPool
* /*pPool*/) const
288 return new XColorItem(*this);
291 bool XColorItem::operator==(const SfxPoolItem
& rItem
) const
293 return ( NameOrIndex::operator==(rItem
) &&
294 static_cast<const XColorItem
&>(rItem
).aColor
== aColor
);
297 const Color
& XColorItem::GetColorValue() const
304 bool XColorItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
306 rVal
<<= GetColorValue().GetRGBColor();
310 bool XColorItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
314 SetColorValue( nValue
);
319 void XColorItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
321 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("XColorItem"));
322 if (Which() == SDRATTR_SHADOWCOLOR
)
324 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST("SDRATTR_SHADOWCOLOR"));
326 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("aColor"),
327 BAD_CAST(aColor
.AsRGBHexString().toUtf8().getStr()));
329 NameOrIndex::dumpAsXml(pWriter
);
331 (void)xmlTextWriterEndElement(pWriter
);
334 // --- line attributes ---
337 SfxPoolItem
* XLineStyleItem::CreateDefault() { return new XLineStyleItem
; }
339 XLineStyleItem::XLineStyleItem(css::drawing::LineStyle eTheLineStyle
) :
340 SfxEnumItem(XATTR_LINESTYLE
, eTheLineStyle
)
344 XLineStyleItem
* XLineStyleItem::Clone(SfxItemPool
* /*pPool*/) const
346 return new XLineStyleItem( *this );
349 bool XLineStyleItem::GetPresentation
351 SfxItemPresentation
/*ePres*/,
352 MapUnit
/*eCoreUnit*/,
353 MapUnit
/*ePresUnit*/,
354 OUString
& rText
, const IntlWrapper
&
363 case css::drawing::LineStyle_NONE
:
364 pId
= RID_SVXSTR_INVISIBLE
;
366 case css::drawing::LineStyle_SOLID
:
367 pId
= RID_SVXSTR_SOLID
;
373 rText
= SvxResId(pId
);
377 bool XLineStyleItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
379 css::drawing::LineStyle eLS
= GetValue();
384 bool XLineStyleItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
386 css::drawing::LineStyle eLS
;
389 // also try an int (for Basic)
393 eLS
= static_cast<css::drawing::LineStyle
>(nLS
);
400 sal_uInt16
XLineStyleItem::GetValueCount() const
405 XDash::XDash(css::drawing::DashStyle eTheDash
, sal_uInt16 nTheDots
, double nTheDotLen
,
406 sal_uInt16 nTheDashes
, double nTheDashLen
, double nTheDistance
) :
411 nDashLen(nTheDashLen
),
412 nDistance(nTheDistance
)
416 bool XDash::operator==(const XDash
& rDash
) const
418 return ( eDash
== rDash
.eDash
&&
419 nDots
== rDash
.nDots
&&
420 nDotLen
== rDash
.nDotLen
&&
421 nDashes
== rDash
.nDashes
&&
422 nDashLen
== rDash
.nDashLen
&&
423 nDistance
== rDash
.nDistance
);
426 // XDash is translated into an array of doubles which describe the lengths of the
427 // dashes, dots and empty passages. It returns the complete length of the full DashDot
428 // sequence and fills the given vetor of doubles accordingly (also resizing, so deleting it).
429 const double SMALLEST_DASH_WIDTH(26.95);
431 double XDash::CreateDotDashArray(::std::vector
< double >& rDotDashArray
, double fLineWidth
) const
433 double fFullDotDashLen(0.0);
434 const sal_uInt16 nNumDotDashArray
= (GetDots() + GetDashes()) * 2;
435 rDotDashArray
.resize( nNumDotDashArray
, 0.0 );
438 double fDashDotDistance
= GetDistance();
439 double fSingleDashLen
= GetDashLen();
440 double fSingleDotLen
= GetDotLen();
442 if (fLineWidth
== 0.0)
443 fLineWidth
= SMALLEST_DASH_WIDTH
;
445 if(GetDashStyle() == css::drawing::DashStyle_RECTRELATIVE
|| GetDashStyle() == css::drawing::DashStyle_ROUNDRELATIVE
)
447 double fFactor
= fLineWidth
/ 100.0;
454 fSingleDashLen
*= fFactor
;
459 fSingleDashLen
= fLineWidth
;
468 fSingleDotLen
*= fFactor
;
473 fSingleDotLen
= fLineWidth
;
477 if(GetDashes() || GetDots())
482 fDashDotDistance
*= fFactor
;
487 fDashDotDistance
= fLineWidth
;
499 if(fSingleDashLen
< SMALLEST_DASH_WIDTH
)
501 fSingleDashLen
= SMALLEST_DASH_WIDTH
;
507 if(fSingleDashLen
< fLineWidth
)
509 fSingleDashLen
= fLineWidth
;
519 if(fSingleDotLen
< SMALLEST_DASH_WIDTH
)
521 fSingleDotLen
= SMALLEST_DASH_WIDTH
;
527 if(fSingleDotLen
< fLineWidth
)
529 fSingleDotLen
= fLineWidth
;
534 if(GetDashes() || GetDots())
539 if(fDashDotDistance
< SMALLEST_DASH_WIDTH
)
541 fDashDotDistance
= SMALLEST_DASH_WIDTH
;
547 if(fDashDotDistance
< fLineWidth
)
549 fDashDotDistance
= fLineWidth
;
555 for(a
=0;a
<GetDots();a
++)
557 rDotDashArray
[nIns
++] = fSingleDotLen
;
558 fFullDotDashLen
+= fSingleDotLen
;
559 rDotDashArray
[nIns
++] = fDashDotDistance
;
560 fFullDotDashLen
+= fDashDotDistance
;
563 for(a
=0;a
<GetDashes();a
++)
565 rDotDashArray
[nIns
++] = fSingleDashLen
;
566 fFullDotDashLen
+= fSingleDashLen
;
567 rDotDashArray
[nIns
++] = fDashDotDistance
;
568 fFullDotDashLen
+= fDashDotDistance
;
571 return fFullDotDashLen
;
574 SfxPoolItem
* XLineDashItem::CreateDefault() {return new XLineDashItem
;}
576 XLineDashItem::XLineDashItem(const OUString
& rName
, const XDash
& rTheDash
) :
577 NameOrIndex(XATTR_LINEDASH
, rName
),
582 XLineDashItem::XLineDashItem(const XLineDashItem
& rItem
) :
588 XLineDashItem::XLineDashItem(const XDash
& rTheDash
)
589 : NameOrIndex( XATTR_LINEDASH
, -1 ),
594 XLineDashItem
* XLineDashItem::Clone(SfxItemPool
* /*pPool*/) const
596 return new XLineDashItem(*this);
599 bool XLineDashItem::operator==(const SfxPoolItem
& rItem
) const
601 return ( NameOrIndex::operator==(rItem
) &&
602 aDash
== static_cast<const XLineDashItem
&>(rItem
).aDash
);
605 bool XLineDashItem::GetPresentation
607 SfxItemPresentation
/*ePres*/,
608 MapUnit
/*eCoreUnit*/,
609 MapUnit
/*ePresUnit*/,
610 OUString
& rText
, const IntlWrapper
&
617 bool XLineDashItem::HasMetrics() const
622 void XLineDashItem::ScaleMetrics(tools::Long nMul
, tools::Long nDiv
)
624 aDash
.SetDotLen( BigInt::Scale( aDash
.GetDotLen(), nMul
, nDiv
) );
625 aDash
.SetDashLen( BigInt::Scale( aDash
.GetDashLen(), nMul
, nDiv
) );
626 aDash
.SetDistance( BigInt::Scale( aDash
.GetDistance(), nMul
, nDiv
) );
629 bool XLineDashItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
) const
631 nMemberId
&= ~CONVERT_TWIPS
;
637 css::drawing::LineDash aLineDash
;
639 const XDash
& rXD
= GetDashValue();
640 aLineDash
.Style
= static_cast<css::drawing::DashStyle
>(static_cast<sal_uInt16
>(rXD
.GetDashStyle()));
641 aLineDash
.Dots
= rXD
.GetDots();
642 aLineDash
.DotLen
= rXD
.GetDotLen();
643 aLineDash
.Dashes
= rXD
.GetDashes();
644 aLineDash
.DashLen
= rXD
.GetDashLen();
645 aLineDash
.Distance
= rXD
.GetDistance();
647 uno::Sequence
< beans::PropertyValue
> aPropSeq
{
648 comphelper::makePropertyValue("Name", SvxUnogetApiNameForItem(Which(), GetName())),
649 comphelper::makePropertyValue("LineDash", aLineDash
)
657 rVal
<<= SvxUnogetApiNameForItem(Which(), GetName());
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();
678 case MID_LINEDASH_STYLE
:
680 const XDash
& rXD
= GetDashValue();
681 rVal
<<= static_cast<css::drawing::DashStyle
>(static_cast<sal_Int16
>(rXD
.GetDashStyle()));
685 case MID_LINEDASH_DOTS
:
687 const XDash
& rXD
= GetDashValue();
688 rVal
<<= rXD
.GetDots();
692 case MID_LINEDASH_DOTLEN
:
694 const XDash
& rXD
= GetDashValue();
695 rVal
<<= rXD
.GetDotLen();
699 case MID_LINEDASH_DASHES
:
701 const XDash
& rXD
= GetDashValue();
702 rVal
<<= rXD
.GetDashes();
706 case MID_LINEDASH_DASHLEN
:
708 const XDash
& rXD
= GetDashValue();
709 rVal
<<= rXD
.GetDashLen();
713 case MID_LINEDASH_DISTANCE
:
715 const XDash
& rXD
= GetDashValue();
716 rVal
<<= rXD
.GetDistance();
720 default: OSL_FAIL("Wrong MemberId!"); return false;
726 bool XLineDashItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
728 nMemberId
&= ~CONVERT_TWIPS
;
734 uno::Sequence
< beans::PropertyValue
> aPropSeq
;
736 if ( rVal
>>= aPropSeq
)
738 css::drawing::LineDash aLineDash
;
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
)
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()))
767 SetDashValue( aXDash
);
779 if (!(rVal
>>= aName
))
787 css::drawing::LineDash aLineDash
;
788 if(!(rVal
>>= aLineDash
))
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()))
803 SetDashValue( aXDash
);
807 case MID_LINEDASH_STYLE
:
809 sal_Int16 nVal
= sal_Int16();
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()))
819 SetDashValue( aXDash
);
824 case MID_LINEDASH_DOTS
:
825 case MID_LINEDASH_DASHES
:
827 sal_Int16 nVal
= sal_Int16();
831 XDash aXDash
= GetDashValue();
832 if ( nMemberId
== MID_LINEDASH_DOTS
)
833 aXDash
.SetDots( nVal
);
835 aXDash
.SetDashes( nVal
);
837 if((0 == aXDash
.GetDots()) && (0 == aXDash
.GetDashes()))
840 SetDashValue( aXDash
);
844 case MID_LINEDASH_DOTLEN
:
845 case MID_LINEDASH_DASHLEN
:
846 case MID_LINEDASH_DISTANCE
:
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
);
858 aXDash
.SetDistance( nVal
);
860 if((0 == aXDash
.GetDots()) && (0 == aXDash
.GetDashes()))
863 SetDashValue( aXDash
);
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
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
);
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*/,
910 OUString
& rText
, const IntlWrapper
& rIntl
913 rText
= GetMetricText( static_cast<tools::Long
>(GetValue()),
914 eCoreUnit
, ePresUnit
, &rIntl
) +
915 " " + EditResId( GetMetricId( ePresUnit
) );
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
);
929 bool XLineWidthItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
931 sal_Int32 nValue
= 0;
933 if( 0 != (nMemberId
&CONVERT_TWIPS
) )
934 nValue
= o3tl::toTwips(nValue
, o3tl::Length::mm100
);
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
&
969 bool XLineColorItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
971 rVal
<<= GetColorValue().GetRGBColor();
975 bool XLineColorItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
977 sal_Int32 nValue
= 0;
978 if(!(rVal
>>= nValue
))
981 SetColorValue( Color(ColorTransparency
, nValue
) );
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
&
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());
1042 css::drawing::PolyPolygonBezierCoords aBezier
;
1043 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( maPolyPolygon
, aBezier
);
1050 bool XLineStartItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
1052 nMemberId
&= ~CONVERT_TWIPS
;
1053 if( nMemberId
== MID_NAME
)
1059 maPolyPolygon
.clear();
1061 if( rVal
.hasValue() )
1063 auto pCoords
= o3tl::tryAccess
<css::drawing::PolyPolygonBezierCoords
>(
1068 if( pCoords
->Coordinates
.getLength() > 0 )
1070 maPolyPolygon
= basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( *pCoords
);
1071 // #i72807# close line start/end polygons hard
1072 // maPolyPolygon.setClosed(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
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() )
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();
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();
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();
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();
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;
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;
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
)
1270 pTempItem
->SetName( aUniqueName
);
1275 return std::make_unique
<XLineStartItem
>( aUniqueName
, maPolyPolygon
);
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
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() )
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();
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();
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();
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();
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;
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;
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
)
1509 pTempItem
->SetName( aUniqueName
);
1514 return std::make_unique
<XLineEndItem
>( aUniqueName
, maPolyPolygon
);
1522 bool XLineEndItem::GetPresentation
1524 SfxItemPresentation
/*ePres*/,
1525 MapUnit
/*eCoreUnit*/,
1526 MapUnit
/*ePresUnit*/,
1527 OUString
& rText
, const IntlWrapper
&
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());
1543 css::drawing::PolyPolygonBezierCoords aBezier
;
1544 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( maPolyPolygon
, aBezier
);
1550 bool XLineEndItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
1552 nMemberId
&= ~CONVERT_TWIPS
;
1553 if( nMemberId
== MID_NAME
)
1559 maPolyPolygon
.clear();
1561 if( rVal
.hasValue() )
1563 auto pCoords
= o3tl::tryAccess
<css::drawing::PolyPolygonBezierCoords
>(
1568 if( pCoords
->Coordinates
.getLength() > 0 )
1570 maPolyPolygon
= basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( *pCoords
);
1571 // #i72807# close line start/end polygons hard
1572 // maPolyPolygon.setClosed(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*/,
1595 OUString
& rText
, const IntlWrapper
& rIntl
1598 rText
= GetMetricText( static_cast<tools::Long
>(GetValue()),
1599 eCoreUnit
, ePresUnit
, &rIntl
) +
1600 " " + EditResId( GetMetricId( ePresUnit
) );
1604 bool XLineStartWidthItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
1606 rVal
<<= GetValue();
1610 bool XLineStartWidthItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
1612 sal_Int32 nValue
= 0;
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*/,
1633 OUString
& rText
, const IntlWrapper
& rIntl
1636 rText
= GetMetricText( static_cast<tools::Long
>(GetValue()),
1637 eCoreUnit
, ePresUnit
, &rIntl
) +
1638 " " + EditResId( GetMetricId( ePresUnit
) );
1642 bool XLineEndWidthItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
1644 rVal
<<= GetValue();
1648 bool XLineEndWidthItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
1650 sal_Int32 nValue
= 0;
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
&
1674 rText
= SvxResId(GetValue() ? RID_SVXSTR_CENTERED
: RID_SVXSTR_NOTCENTERED
);
1678 bool XLineStartCenterItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
1680 bool bValue
= GetValue();
1685 bool XLineStartCenterItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
1687 auto b
= o3tl::tryAccess
<bool>(rVal
);
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
&
1713 rText
= SvxResId(GetValue() ? RID_SVXSTR_CENTERED
: RID_SVXSTR_NOTCENTERED
);
1717 bool XLineEndCenterItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
1719 bool bValue
= GetValue();
1724 bool XLineEndCenterItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
1726 auto b
= o3tl::tryAccess
<bool>(rVal
);
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
&
1761 switch( GetValue() )
1763 case drawing::FillStyle_NONE
:
1764 pId
= RID_SVXSTR_INVISIBLE
;
1766 case drawing::FillStyle_SOLID
:
1767 pId
= RID_SVXSTR_SOLID
;
1769 case drawing::FillStyle_GRADIENT
:
1770 pId
= RID_SVXSTR_GRADIENT
;
1772 case drawing::FillStyle_HATCH
:
1773 pId
= RID_SVXSTR_HATCH
;
1775 case drawing::FillStyle_BITMAP
:
1776 pId
= RID_SVXSTR_BITMAP
;
1782 rText
= SvxResId(pId
);
1786 sal_uInt16
XFillStyleItem::GetValueCount() const
1791 bool XFillStyleItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
1793 css::drawing::FillStyle eFS
= GetValue();
1800 bool XFillStyleItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
1802 css::drawing::FillStyle eFS
;
1805 // also try an int (for Basic)
1809 eFS
= static_cast<css::drawing::FillStyle
>(nFS
);
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");
1840 switch( GetValue() )
1842 case drawing::FillStyle_NONE
:
1845 case drawing::FillStyle_SOLID
:
1848 case drawing::FillStyle_GRADIENT
:
1849 sValue
= "GRADIENT";
1851 case drawing::FillStyle_HATCH
:
1854 case drawing::FillStyle_BITMAP
:
1860 aTree
.put("state", sValue
);
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
&
1895 bool XFillColorItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
1897 rVal
<<= GetColorValue().GetRGBColor();
1902 bool XFillColorItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
1905 if(!(rVal
>>= nValue
))
1908 SetColorValue( nValue
);
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());
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
&
1954 std::string
XGradient::GradientStyleToString(css::awt::GradientStyle eStyle
)
1958 case css::awt::GradientStyle::GradientStyle_LINEAR
:
1961 case css::awt::GradientStyle::GradientStyle_AXIAL
:
1964 case css::awt::GradientStyle::GradientStyle_RADIAL
:
1967 case css::awt::GradientStyle::GradientStyle_ELLIPTICAL
:
1968 return "ELLIPTICAL";
1970 case css::awt::GradientStyle::GradientStyle_SQUARE
:
1973 case css::awt::GradientStyle::GradientStyle_RECT
:
1976 case css::awt::GradientStyle::GradientStyle_MAKE_FIXED_SIZE
:
1977 return "MAKE_FIXED_SIZE";
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
)
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());
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()));
2033 XGradient
XGradient::fromJSON(const OUString
& rJSON
)
2035 StringMap
aMap(lcl_jsonToStringMap(rJSON
));
2036 return lcl_buildGradientFromStringMap(aMap
);
2039 css::awt::Gradient
XGradient::toGradientUNO() const
2041 css::awt::Gradient aGradient
;
2043 aGradient
.Style
= this->GetGradientStyle();
2044 aGradient
.StartColor
= static_cast<sal_Int32
>(this->GetStartColor());
2045 aGradient
.EndColor
= static_cast<sal_Int32
>(this->GetEndColor());
2046 aGradient
.Angle
= static_cast<short>(this->GetAngle());
2047 aGradient
.Border
= this->GetBorder();
2048 aGradient
.XOffset
= this->GetXOffset();
2049 aGradient
.YOffset
= this->GetYOffset();
2050 aGradient
.StartIntensity
= this->GetStartIntens();
2051 aGradient
.EndIntensity
= this->GetEndIntens();
2052 aGradient
.StepCount
= this->GetSteps();
2057 XGradient::XGradient() :
2058 eStyle( css::awt::GradientStyle_LINEAR
),
2059 aStartColor( COL_BLACK
),
2060 aEndColor( COL_WHITE
),
2065 nIntensStart( 100 ),
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
) :
2077 aStartColor(rStart
),
2080 nBorder(nTheBorder
),
2083 nIntensStart(nStartIntens
),
2084 nIntensEnd(nEndIntens
),
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
));
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
) :
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
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.
2169 bool XFillGradientItem::GetPresentation
2171 SfxItemPresentation
/*ePres*/,
2172 MapUnit
/*eCoreUnit*/,
2173 MapUnit
/*ePresUnit*/,
2174 OUString
& rText
, const IntlWrapper
&
2181 bool XFillGradientItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2183 nMemberId
&= ~CONVERT_TWIPS
;
2184 switch ( nMemberId
)
2188 css::awt::Gradient aGradient2
;
2190 const XGradient
& aXGradient
= GetGradientValue();
2191 aGradient2
.Style
= aXGradient
.GetGradientStyle();
2192 aGradient2
.StartColor
= static_cast<sal_Int32
>(aXGradient
.GetStartColor());
2193 aGradient2
.EndColor
= static_cast<sal_Int32
>(aXGradient
.GetEndColor());
2194 aGradient2
.Angle
= static_cast<short>(aXGradient
.GetAngle());
2195 aGradient2
.Border
= aXGradient
.GetBorder();
2196 aGradient2
.XOffset
= aXGradient
.GetXOffset();
2197 aGradient2
.YOffset
= aXGradient
.GetYOffset();
2198 aGradient2
.StartIntensity
= aXGradient
.GetStartIntens();
2199 aGradient2
.EndIntensity
= aXGradient
.GetEndIntens();
2200 aGradient2
.StepCount
= aXGradient
.GetSteps();
2202 uno::Sequence
< beans::PropertyValue
> aPropSeq
{
2203 comphelper::makePropertyValue("Name", SvxUnogetApiNameForItem(Which(), GetName())),
2204 comphelper::makePropertyValue("FillGradient", aGradient2
)
2210 case MID_FILLGRADIENT
:
2212 const XGradient
& aXGradient
= GetGradientValue();
2213 css::awt::Gradient aGradient2
;
2215 aGradient2
.Style
= aXGradient
.GetGradientStyle();
2216 aGradient2
.StartColor
= static_cast<sal_Int32
>(aXGradient
.GetStartColor());
2217 aGradient2
.EndColor
= static_cast<sal_Int32
>(aXGradient
.GetEndColor());
2218 aGradient2
.Angle
= static_cast<short>(aXGradient
.GetAngle());
2219 aGradient2
.Border
= aXGradient
.GetBorder();
2220 aGradient2
.XOffset
= aXGradient
.GetXOffset();
2221 aGradient2
.YOffset
= aXGradient
.GetYOffset();
2222 aGradient2
.StartIntensity
= aXGradient
.GetStartIntens();
2223 aGradient2
.EndIntensity
= aXGradient
.GetEndIntens();
2224 aGradient2
.StepCount
= aXGradient
.GetSteps();
2226 rVal
<<= aGradient2
;
2232 rVal
<<= SvxUnogetApiNameForItem(Which(), GetName());
2236 case MID_GRADIENT_STYLE
: rVal
<<= static_cast<sal_Int16
>(GetGradientValue().GetGradientStyle()); break;
2237 case MID_GRADIENT_STARTCOLOR
: rVal
<<= GetGradientValue().GetStartColor(); break;
2238 case MID_GRADIENT_ENDCOLOR
: rVal
<<= GetGradientValue().GetEndColor(); break;
2239 case MID_GRADIENT_ANGLE
: rVal
<<= static_cast<sal_Int16
>(GetGradientValue().GetAngle()); break;
2240 case MID_GRADIENT_BORDER
: rVal
<<= GetGradientValue().GetBorder(); break;
2241 case MID_GRADIENT_XOFFSET
: rVal
<<= GetGradientValue().GetXOffset(); break;
2242 case MID_GRADIENT_YOFFSET
: rVal
<<= GetGradientValue().GetYOffset(); break;
2243 case MID_GRADIENT_STARTINTENSITY
: rVal
<<= GetGradientValue().GetStartIntens(); break;
2244 case MID_GRADIENT_ENDINTENSITY
: rVal
<<= GetGradientValue().GetEndIntens(); break;
2245 case MID_GRADIENT_STEPCOUNT
: rVal
<<= GetGradientValue().GetSteps(); break;
2247 default: OSL_FAIL("Wrong MemberId!"); return false;
2253 bool XFillGradientItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
2255 nMemberId
&= ~CONVERT_TWIPS
;
2257 switch ( nMemberId
)
2261 uno::Sequence
< beans::PropertyValue
> aPropSeq
;
2263 if ( rVal
>>= aPropSeq
)
2265 css::awt::Gradient aGradient2
;
2267 bool bGradient( false );
2268 for ( const auto& rProp
: std::as_const(aPropSeq
) )
2270 if ( rProp
.Name
== "Name" )
2271 rProp
.Value
>>= aName
;
2272 else if ( rProp
.Name
== "FillGradient" )
2274 if ( rProp
.Value
>>= aGradient2
)
2282 XGradient aXGradient
;
2284 aXGradient
.SetGradientStyle( aGradient2
.Style
);
2285 aXGradient
.SetStartColor( Color(ColorTransparency
, aGradient2
.StartColor
) );
2286 aXGradient
.SetEndColor( Color(ColorTransparency
, aGradient2
.EndColor
) );
2287 aXGradient
.SetAngle( Degree10(aGradient2
.Angle
) );
2288 aXGradient
.SetBorder( aGradient2
.Border
);
2289 aXGradient
.SetXOffset( aGradient2
.XOffset
);
2290 aXGradient
.SetYOffset( aGradient2
.YOffset
);
2291 aXGradient
.SetStartIntens( aGradient2
.StartIntensity
);
2292 aXGradient
.SetEndIntens( aGradient2
.EndIntensity
);
2293 aXGradient
.SetSteps( aGradient2
.StepCount
);
2295 SetGradientValue( aXGradient
);
2307 if (!(rVal
>>= aName
))
2313 case MID_FILLGRADIENT
:
2315 css::awt::Gradient aGradient2
;
2316 if(!(rVal
>>= aGradient2
))
2319 XGradient aXGradient
;
2321 aXGradient
.SetGradientStyle( aGradient2
.Style
);
2322 aXGradient
.SetStartColor( Color(ColorTransparency
, aGradient2
.StartColor
) );
2323 aXGradient
.SetEndColor( Color(ColorTransparency
, aGradient2
.EndColor
) );
2324 aXGradient
.SetAngle( Degree10(aGradient2
.Angle
) );
2325 aXGradient
.SetBorder( aGradient2
.Border
);
2326 aXGradient
.SetXOffset( aGradient2
.XOffset
);
2327 aXGradient
.SetYOffset( aGradient2
.YOffset
);
2328 aXGradient
.SetStartIntens( aGradient2
.StartIntensity
);
2329 aXGradient
.SetEndIntens( aGradient2
.EndIntensity
);
2330 aXGradient
.SetSteps( aGradient2
.StepCount
);
2332 SetGradientValue( aXGradient
);
2336 case MID_GRADIENT_STARTCOLOR
:
2337 case MID_GRADIENT_ENDCOLOR
:
2340 if(!(rVal
>>= nVal
))
2343 XGradient aXGradient
= GetGradientValue();
2345 if ( nMemberId
== MID_GRADIENT_STARTCOLOR
)
2346 aXGradient
.SetStartColor( nVal
);
2348 aXGradient
.SetEndColor( nVal
);
2349 SetGradientValue( aXGradient
);
2353 case MID_GRADIENT_STYLE
:
2354 case MID_GRADIENT_ANGLE
:
2355 case MID_GRADIENT_BORDER
:
2356 case MID_GRADIENT_STARTINTENSITY
:
2357 case MID_GRADIENT_ENDINTENSITY
:
2358 case MID_GRADIENT_STEPCOUNT
:
2359 case MID_GRADIENT_XOFFSET
:
2360 case MID_GRADIENT_YOFFSET
:
2362 sal_Int16 nVal
= sal_Int16();
2363 if(!(rVal
>>= nVal
))
2366 XGradient aXGradient
= GetGradientValue();
2368 switch ( nMemberId
)
2370 case MID_GRADIENT_STYLE
:
2371 aXGradient
.SetGradientStyle( static_cast<css::awt::GradientStyle
>(nVal
) ); break;
2372 case MID_GRADIENT_ANGLE
:
2373 aXGradient
.SetAngle( Degree10(nVal
) ); break;
2374 case MID_GRADIENT_BORDER
:
2375 aXGradient
.SetBorder( nVal
); break;
2376 case MID_GRADIENT_STARTINTENSITY
:
2377 aXGradient
.SetStartIntens( nVal
); break;
2378 case MID_GRADIENT_ENDINTENSITY
:
2379 aXGradient
.SetEndIntens( nVal
); break;
2380 case MID_GRADIENT_STEPCOUNT
:
2381 aXGradient
.SetSteps( nVal
); break;
2382 case MID_GRADIENT_XOFFSET
:
2383 aXGradient
.SetXOffset( nVal
); break;
2384 case MID_GRADIENT_YOFFSET
:
2385 aXGradient
.SetYOffset( nVal
); break;
2388 SetGradientValue( aXGradient
);
2396 bool XFillGradientItem::CompareValueFunc( const NameOrIndex
* p1
, const NameOrIndex
* p2
)
2398 return static_cast<const XFillGradientItem
*>(p1
)->GetGradientValue() == static_cast<const XFillGradientItem
*>(p2
)->GetGradientValue();
2401 std::unique_ptr
<XFillGradientItem
> XFillGradientItem::checkForUniqueItem( SdrModel
* pModel
) const
2405 const OUString aUniqueName
= NameOrIndex::CheckNamedItem(
2406 this, Which(), &pModel
->GetItemPool(),
2407 XFillGradientItem::CompareValueFunc
, RID_SVXSTR_GRADIENT
,
2408 pModel
->GetPropertyList( XPropertyListType::Gradient
) );
2410 // if the given name is not valid, replace it!
2411 if( aUniqueName
!= GetName() )
2412 return std::make_unique
<XFillGradientItem
>( aUniqueName
, aGradient
, Which() );
2418 boost::property_tree::ptree
XFillGradientItem::dumpAsJSON() const
2420 boost::property_tree::ptree aTree
= SfxPoolItem::dumpAsJSON();
2422 if (Which() == XATTR_FILLGRADIENT
)
2423 aTree
.put("commandName", ".uno:FillGradient");
2425 aTree
.push_back(std::make_pair("state", GetGradientValue().dumpAsJSON()));
2431 SfxPoolItem
* XFillFloatTransparenceItem::CreateDefault() { return new XFillFloatTransparenceItem
; }
2433 XFillFloatTransparenceItem::XFillFloatTransparenceItem() :
2436 SetWhich( XATTR_FILLFLOATTRANSPARENCE
);
2439 XFillFloatTransparenceItem::XFillFloatTransparenceItem(const OUString
& rName
, const XGradient
& rGradient
, bool bEnable
) :
2440 XFillGradientItem ( rName
, rGradient
),
2441 bEnabled ( bEnable
)
2443 SetWhich( XATTR_FILLFLOATTRANSPARENCE
);
2446 XFillFloatTransparenceItem::XFillFloatTransparenceItem( const XFillFloatTransparenceItem
& rItem
) :
2447 XFillGradientItem ( rItem
),
2448 bEnabled ( rItem
.bEnabled
)
2450 SetWhich( XATTR_FILLFLOATTRANSPARENCE
);
2453 XFillFloatTransparenceItem::XFillFloatTransparenceItem(const XGradient
& rTheGradient
, bool bEnable
)
2454 : XFillGradientItem ( -1, rTheGradient
),
2455 bEnabled ( bEnable
)
2457 SetWhich( XATTR_FILLFLOATTRANSPARENCE
);
2460 bool XFillFloatTransparenceItem::operator==( const SfxPoolItem
& rItem
) const
2462 return ( NameOrIndex::operator==(rItem
) ) &&
2463 ( GetGradientValue() == static_cast<const XFillGradientItem
&>(rItem
).GetGradientValue() ) &&
2464 ( bEnabled
== static_cast<const XFillFloatTransparenceItem
&>(rItem
).bEnabled
);
2467 XFillFloatTransparenceItem
* XFillFloatTransparenceItem::Clone( SfxItemPool
* /*pPool*/) const
2469 return new XFillFloatTransparenceItem( *this );
2472 bool XFillFloatTransparenceItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2474 return XFillGradientItem::QueryValue( rVal
, nMemberId
);
2477 bool XFillFloatTransparenceItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
2479 return XFillGradientItem::PutValue( rVal
, nMemberId
);
2482 bool XFillFloatTransparenceItem::GetPresentation( SfxItemPresentation ePres
,
2483 MapUnit eCoreUnit
, MapUnit ePresUnit
,
2485 const IntlWrapper
& rIntlWrapper
) const
2487 return XFillGradientItem::GetPresentation( ePres
, eCoreUnit
, ePresUnit
, rText
, rIntlWrapper
);
2490 bool XFillFloatTransparenceItem::CompareValueFunc( const NameOrIndex
* p1
, const NameOrIndex
* p2
)
2492 return static_cast<const XFillFloatTransparenceItem
*>(p1
)->IsEnabled() == static_cast<const XFillFloatTransparenceItem
*>(p2
)->IsEnabled() &&
2493 static_cast<const XFillFloatTransparenceItem
*>(p1
)->GetGradientValue() == static_cast<const XFillFloatTransparenceItem
*>(p2
)->GetGradientValue();
2496 std::unique_ptr
<XFillFloatTransparenceItem
> XFillFloatTransparenceItem::checkForUniqueItem( SdrModel
* pModel
) const
2498 // #85953# unique name only necessary when enabled
2503 const OUString aUniqueName
= NameOrIndex::CheckNamedItem( this,
2504 XATTR_FILLFLOATTRANSPARENCE
,
2505 &pModel
->GetItemPool(),
2506 XFillFloatTransparenceItem::CompareValueFunc
,
2507 RID_SVXSTR_TRASNGR0
,
2508 XPropertyListRef() );
2510 // if the given name is not valid, replace it!
2511 if( aUniqueName
!= GetName() )
2513 return std::make_unique
<XFillFloatTransparenceItem
>( aUniqueName
, GetGradientValue(), true );
2519 // #85953# if disabled, force name to empty string
2520 if( !GetName().isEmpty() )
2522 return std::make_unique
<XFillFloatTransparenceItem
>(OUString(), GetGradientValue(), false);
2529 boost::property_tree::ptree
XFillFloatTransparenceItem::dumpAsJSON() const
2531 boost::property_tree::ptree aTree
= XFillGradientItem::dumpAsJSON();
2532 aTree
.put("commandName", ".uno:FillFloatTransparence");
2536 boost::property_tree::ptree
& rState
= aTree
.get_child("state");
2537 // When gradient fill is disabled, the intensity fields contain the
2538 // constant encoded percent-transparency. However we use that here to just
2539 // distinguish between 'None' and 'Solid' types and correct the 'style'
2540 // property appropriately.
2541 if (GetGradientValue().GetStartIntens() == 100)
2542 rState
.put("style", "NONE");
2544 rState
.put("style", "SOLID");
2550 XHatch::XHatch(const Color
& rCol
, css::drawing::HatchStyle eTheStyle
, tools::Long nTheDistance
,
2551 Degree10 nTheAngle
) :
2554 nDistance(nTheDistance
),
2559 bool XHatch::operator==(const XHatch
& rHatch
) const
2561 return ( eStyle
== rHatch
.eStyle
&&
2562 aColor
== rHatch
.aColor
&&
2563 nDistance
== rHatch
.nDistance
&&
2564 nAngle
== rHatch
.nAngle
);
2568 SfxPoolItem
* XFillHatchItem::CreateDefault() { return new XFillHatchItem
; }
2570 XFillHatchItem::XFillHatchItem(const OUString
& rName
,
2571 const XHatch
& rTheHatch
) :
2572 NameOrIndex(XATTR_FILLHATCH
, rName
),
2577 XFillHatchItem::XFillHatchItem(const XFillHatchItem
& rItem
) :
2579 aHatch(rItem
.aHatch
)
2583 XFillHatchItem::XFillHatchItem(const XHatch
& rTheHatch
)
2584 : NameOrIndex( XATTR_FILLHATCH
, -1 ),
2589 XFillHatchItem
* XFillHatchItem::Clone(SfxItemPool
* /*pPool*/) const
2591 return new XFillHatchItem(*this);
2594 bool XFillHatchItem::operator==(const SfxPoolItem
& rItem
) const
2596 return ( NameOrIndex::operator==(rItem
) &&
2597 aHatch
== static_cast<const XFillHatchItem
&>(rItem
).aHatch
);
2600 bool XFillHatchItem::GetPresentation
2602 SfxItemPresentation
/*ePres*/,
2603 MapUnit
/*eCoreUnit*/,
2604 MapUnit
/*ePresUnit*/,
2605 OUString
& rText
, const IntlWrapper
&
2612 bool XFillHatchItem::HasMetrics() const
2617 void XFillHatchItem::ScaleMetrics(tools::Long nMul
, tools::Long nDiv
)
2619 aHatch
.SetDistance( BigInt::Scale( aHatch
.GetDistance(), nMul
, nDiv
) );
2622 bool XFillHatchItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2624 nMemberId
&= ~CONVERT_TWIPS
;
2626 switch ( nMemberId
)
2630 css::drawing::Hatch aUnoHatch
;
2632 aUnoHatch
.Style
= aHatch
.GetHatchStyle();
2633 aUnoHatch
.Color
= sal_Int32(aHatch
.GetColor());
2634 aUnoHatch
.Distance
= aHatch
.GetDistance();
2635 aUnoHatch
.Angle
= aHatch
.GetAngle().get();
2637 uno::Sequence
< beans::PropertyValue
> aPropSeq
{
2638 comphelper::makePropertyValue("Name", SvxUnogetApiNameForItem(Which(), GetName())),
2639 comphelper::makePropertyValue("FillHatch", aUnoHatch
)
2647 css::drawing::Hatch aUnoHatch
;
2649 aUnoHatch
.Style
= aHatch
.GetHatchStyle();
2650 aUnoHatch
.Color
= sal_Int32(aHatch
.GetColor());
2651 aUnoHatch
.Distance
= aHatch
.GetDistance();
2652 aUnoHatch
.Angle
= aHatch
.GetAngle().get();
2659 rVal
<<= SvxUnogetApiNameForItem(Which(), GetName());
2663 case MID_HATCH_STYLE
:
2664 rVal
<<= aHatch
.GetHatchStyle(); break;
2665 case MID_HATCH_COLOR
:
2666 rVal
<<= aHatch
.GetColor(); break;
2667 case MID_HATCH_DISTANCE
:
2668 rVal
<<= aHatch
.GetDistance(); break;
2669 case MID_HATCH_ANGLE
:
2670 rVal
<<= aHatch
.GetAngle().get(); break;
2672 default: OSL_FAIL("Wrong MemberId!"); return false;
2678 bool XFillHatchItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
2680 nMemberId
&= ~CONVERT_TWIPS
;
2682 switch ( nMemberId
)
2686 uno::Sequence
< beans::PropertyValue
> aPropSeq
;
2687 if ( rVal
>>= aPropSeq
)
2689 css::drawing::Hatch aUnoHatch
;
2691 bool bHatch( false );
2692 for ( const auto& rProp
: std::as_const(aPropSeq
) )
2694 if ( rProp
.Name
== "Name" )
2695 rProp
.Value
>>= aName
;
2696 else if ( rProp
.Name
== "FillHatch" )
2698 if ( rProp
.Value
>>= aUnoHatch
)
2706 aHatch
.SetHatchStyle( aUnoHatch
.Style
);
2707 aHatch
.SetColor( Color(ColorTransparency
, aUnoHatch
.Color
) );
2708 aHatch
.SetDistance( aUnoHatch
.Distance
);
2709 aHatch
.SetAngle( Degree10(aUnoHatch
.Angle
) );
2720 css::drawing::Hatch aUnoHatch
;
2721 if(!(rVal
>>= aUnoHatch
))
2724 aHatch
.SetHatchStyle( aUnoHatch
.Style
);
2725 aHatch
.SetColor( Color(ColorTransparency
, aUnoHatch
.Color
) );
2726 aHatch
.SetDistance( aUnoHatch
.Distance
);
2727 aHatch
.SetAngle( Degree10(aUnoHatch
.Angle
) );
2734 if (!(rVal
>>= aName
))
2740 case MID_HATCH_STYLE
:
2742 sal_Int16 nVal
= sal_Int16();
2743 if (!(rVal
>>= nVal
))
2745 aHatch
.SetHatchStyle( static_cast<css::drawing::HatchStyle
>(nVal
) );
2749 case MID_HATCH_COLOR
:
2750 case MID_HATCH_DISTANCE
:
2751 case MID_HATCH_ANGLE
:
2754 if (!(rVal
>>= nVal
))
2757 if ( nMemberId
== MID_HATCH_COLOR
)
2758 aHatch
.SetColor( Color(ColorTransparency
, nVal
) );
2759 else if ( nMemberId
== MID_HATCH_DISTANCE
)
2760 aHatch
.SetDistance( nVal
);
2762 aHatch
.SetAngle( Degree10(nVal
) );
2766 default: OSL_FAIL("Wrong MemberId!"); return false;
2772 bool XFillHatchItem::CompareValueFunc( const NameOrIndex
* p1
, const NameOrIndex
* p2
)
2774 return static_cast<const XFillHatchItem
*>(p1
)->GetHatchValue() == static_cast<const XFillHatchItem
*>(p2
)->GetHatchValue();
2777 std::unique_ptr
<XFillHatchItem
> XFillHatchItem::checkForUniqueItem( SdrModel
* pModel
) const
2781 const OUString aUniqueName
= NameOrIndex::CheckNamedItem(
2782 this, XATTR_FILLHATCH
, &pModel
->GetItemPool(),
2783 XFillHatchItem::CompareValueFunc
, RID_SVXSTR_HATCH10
,
2784 pModel
->GetPropertyList( XPropertyListType::Hatch
) );
2786 // if the given name is not valid, replace it!
2787 if( aUniqueName
!= GetName() )
2788 return std::make_unique
<XFillHatchItem
>( aUniqueName
, aHatch
);
2794 // --- form text attributes ---
2797 SfxPoolItem
* XFormTextStyleItem::CreateDefault() { return new XFormTextStyleItem
; }
2799 XFormTextStyleItem::XFormTextStyleItem(XFormTextStyle eTheStyle
) :
2800 SfxEnumItem(XATTR_FORMTXTSTYLE
, eTheStyle
)
2804 XFormTextStyleItem
* XFormTextStyleItem::Clone(SfxItemPool
* /*pPool*/) const
2806 return new XFormTextStyleItem( *this );
2809 sal_uInt16
XFormTextStyleItem::GetValueCount() const
2814 bool XFormTextStyleItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
2816 rVal
<<= static_cast<sal_Int32
>(GetValue());
2820 bool XFormTextStyleItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
2822 sal_Int32 nValue
= 0;
2824 SetValue(static_cast<XFormTextStyle
>(nValue
));
2830 SfxPoolItem
* XFormTextAdjustItem::CreateDefault() { return new XFormTextAdjustItem
; }
2832 XFormTextAdjustItem::XFormTextAdjustItem(XFormTextAdjust eTheAdjust
) :
2833 SfxEnumItem(XATTR_FORMTXTADJUST
, eTheAdjust
)
2837 XFormTextAdjustItem
* XFormTextAdjustItem::Clone(SfxItemPool
* /*pPool*/) const
2839 return new XFormTextAdjustItem( *this );
2842 sal_uInt16
XFormTextAdjustItem::GetValueCount() const
2847 bool XFormTextAdjustItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
2849 rVal
<<= static_cast<sal_Int32
>(GetValue());
2853 bool XFormTextAdjustItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
2855 sal_Int32 nValue
= 0;
2857 SetValue(static_cast<XFormTextAdjust
>(nValue
));
2863 SfxPoolItem
* XFormTextDistanceItem::CreateDefault() { return new XFormTextDistanceItem
; }
2865 XFormTextDistanceItem::XFormTextDistanceItem(tools::Long nDist
) :
2866 SfxMetricItem(XATTR_FORMTXTDISTANCE
, nDist
)
2870 XFormTextDistanceItem
* XFormTextDistanceItem::Clone(SfxItemPool
* /*pPool*/) const
2872 return new XFormTextDistanceItem(*this);
2875 SfxPoolItem
* XFormTextStartItem::CreateDefault() { return new XFormTextStartItem
; }
2877 XFormTextStartItem::XFormTextStartItem(tools::Long nStart
) :
2878 SfxMetricItem(XATTR_FORMTXTSTART
, nStart
)
2882 XFormTextStartItem
* XFormTextStartItem::Clone(SfxItemPool
* /*pPool*/) const
2884 return new XFormTextStartItem(*this);
2887 SfxPoolItem
* XFormTextMirrorItem::CreateDefault() { return new XFormTextMirrorItem
; }
2889 XFormTextMirrorItem::XFormTextMirrorItem(bool bMirror
) :
2890 SfxBoolItem(XATTR_FORMTXTMIRROR
, bMirror
)
2894 XFormTextMirrorItem
* XFormTextMirrorItem::Clone(SfxItemPool
* /*pPool*/) const
2896 return new XFormTextMirrorItem(*this);
2899 SfxPoolItem
* XFormTextOutlineItem::CreateDefault() { return new XFormTextOutlineItem
; }
2901 XFormTextOutlineItem::XFormTextOutlineItem(bool bOutline
) :
2902 SfxBoolItem(XATTR_FORMTXTOUTLINE
, bOutline
)
2906 XFormTextOutlineItem
* XFormTextOutlineItem::Clone(SfxItemPool
* /*pPool*/) const
2908 return new XFormTextOutlineItem(*this);
2911 SfxPoolItem
* XFormTextShadowItem::CreateDefault() { return new XFormTextShadowItem
; }
2913 XFormTextShadowItem::XFormTextShadowItem(XFormTextShadow eFormTextShadow
) :
2914 SfxEnumItem(XATTR_FORMTXTSHADOW
, eFormTextShadow
)
2918 XFormTextShadowItem
* XFormTextShadowItem::Clone(SfxItemPool
* /*pPool*/) const
2920 return new XFormTextShadowItem( *this );
2923 sal_uInt16
XFormTextShadowItem::GetValueCount() const
2928 bool XFormTextShadowItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
2930 rVal
<<= static_cast<sal_Int32
>(GetValue());
2934 bool XFormTextShadowItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
2936 sal_Int32 nValue
= 0;
2938 SetValue(static_cast<XFormTextShadow
>(nValue
));
2944 SfxPoolItem
* XFormTextShadowColorItem::CreateDefault() { return new XFormTextShadowColorItem
; }
2946 XFormTextShadowColorItem::XFormTextShadowColorItem(const OUString
& rName
,
2947 const Color
& rTheColor
) :
2948 XColorItem(XATTR_FORMTXTSHDWCOLOR
, rName
, rTheColor
)
2952 XFormTextShadowColorItem
* XFormTextShadowColorItem::Clone(SfxItemPool
* /*pPool*/) const
2954 return new XFormTextShadowColorItem(*this);
2957 SfxPoolItem
* XFormTextShadowXValItem::CreateDefault() { return new XFormTextShadowXValItem
; }
2959 XFormTextShadowXValItem::XFormTextShadowXValItem(tools::Long nVal
) :
2960 SfxMetricItem(XATTR_FORMTXTSHDWXVAL
, nVal
)
2964 XFormTextShadowXValItem
* XFormTextShadowXValItem::Clone(SfxItemPool
* /*pPool*/) const
2966 return new XFormTextShadowXValItem(*this);
2969 SfxPoolItem
* XFormTextShadowYValItem::CreateDefault() { return new XFormTextShadowYValItem
; }
2971 XFormTextShadowYValItem::XFormTextShadowYValItem(tools::Long nVal
) :
2972 SfxMetricItem(XATTR_FORMTXTSHDWYVAL
, nVal
)
2976 XFormTextShadowYValItem
* XFormTextShadowYValItem::Clone(SfxItemPool
* /*pPool*/) const
2978 return new XFormTextShadowYValItem(*this);
2981 SfxPoolItem
* XFormTextHideFormItem::CreateDefault() { return new XFormTextHideFormItem
; }
2983 XFormTextHideFormItem::XFormTextHideFormItem(bool bHide
) :
2984 SfxBoolItem(XATTR_FORMTXTHIDEFORM
, bHide
)
2988 XFormTextHideFormItem
* XFormTextHideFormItem::Clone(SfxItemPool
* /*pPool*/) const
2990 return new XFormTextHideFormItem(*this);
2996 /// a line attribute set item
2997 XLineAttrSetItem::XLineAttrSetItem( SfxItemSet
&& pItemSet
) :
2998 SfxSetItem( XATTRSET_LINE
, std::move(pItemSet
))
3002 XLineAttrSetItem::XLineAttrSetItem( SfxItemPool
* pItemPool
) :
3003 SfxSetItem( XATTRSET_LINE
,
3004 SfxItemSetFixed
<XATTR_LINE_FIRST
, XATTR_LINE_LAST
>( *pItemPool
))
3008 XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem
& rLineAttr
) :
3009 SfxSetItem( rLineAttr
)
3013 XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem
& rLineAttr
,
3014 SfxItemPool
* pItemPool
) :
3015 SfxSetItem( rLineAttr
, pItemPool
)
3019 XLineAttrSetItem
* XLineAttrSetItem::Clone( SfxItemPool
* pPool
) const
3021 return new XLineAttrSetItem( *this, pPool
);
3024 /// fill attribute set item
3025 XFillAttrSetItem::XFillAttrSetItem( SfxItemSet
&& pItemSet
) :
3026 SfxSetItem( XATTRSET_FILL
, std::move(pItemSet
))
3030 XFillAttrSetItem::XFillAttrSetItem( SfxItemPool
* pItemPool
) :
3031 SfxSetItem( XATTRSET_FILL
,
3032 SfxItemSetFixed
<XATTR_FILL_FIRST
, XATTR_FILL_LAST
>( *pItemPool
))
3036 XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem
& rFillAttr
) :
3037 SfxSetItem( rFillAttr
)
3041 XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem
& rFillAttr
,
3042 SfxItemPool
* pItemPool
) :
3043 SfxSetItem( rFillAttr
, pItemPool
)
3047 XFillAttrSetItem
* XFillAttrSetItem::Clone( SfxItemPool
* pPool
) const
3049 return new XFillAttrSetItem( *this, pPool
);
3052 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */