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 .
21 #include <com/sun/star/uno/Any.hxx>
22 #include <com/sun/star/drawing/LineStyle.hpp>
23 #include <com/sun/star/script/Converter.hpp>
24 #include <com/sun/star/table/ShadowLocation.hpp>
25 #include <com/sun/star/table/ShadowFormat.hpp>
26 #include <com/sun/star/table/BorderLine2.hpp>
27 #include <com/sun/star/table/BorderLineStyle.hpp>
28 #include <com/sun/star/style/BreakType.hpp>
29 #include <com/sun/star/style/GraphicLocation.hpp>
30 #include <com/sun/star/awt/Size.hpp>
31 #include <com/sun/star/text/WritingMode2.hpp>
32 #include <com/sun/star/frame/status/UpperLowerMarginScale.hpp>
33 #include <com/sun/star/frame/status/LeftRightMarginScale.hpp>
34 #include <com/sun/star/drawing/ShadingPattern.hpp>
35 #include <com/sun/star/graphic/XGraphic.hpp>
36 #include <com/sun/star/util/XComplexColor.hpp>
38 #include <osl/diagnose.h>
39 #include <i18nutil/unicode.hxx>
40 #include <unotools/ucbstreamhelper.hxx>
41 #include <comphelper/processfactory.hxx>
43 #include <vcl/GraphicObject.hxx>
44 #include <tools/urlobj.hxx>
45 #include <tools/bigint.hxx>
46 #include <svl/memberid.h>
47 #include <rtl/math.hxx>
48 #include <rtl/ustring.hxx>
49 #include <tools/mapunit.hxx>
50 #include <tools/UnitConversion.hxx>
51 #include <vcl/graphicfilter.hxx>
52 #include <vcl/settings.hxx>
53 #include <vcl/svapp.hxx>
54 #include <editeng/editrids.hrc>
55 #include <editeng/pbinitem.hxx>
56 #include <editeng/sizeitem.hxx>
57 #include <editeng/lrspitem.hxx>
58 #include <editeng/ulspitem.hxx>
59 #include <editeng/prntitem.hxx>
60 #include <editeng/opaqitem.hxx>
61 #include <editeng/protitem.hxx>
62 #include <editeng/shaditem.hxx>
63 #include <editeng/borderline.hxx>
64 #include <editeng/boxitem.hxx>
65 #include <editeng/formatbreakitem.hxx>
66 #include <editeng/keepitem.hxx>
67 #include <editeng/lineitem.hxx>
68 #include <editeng/brushitem.hxx>
69 #include <editeng/frmdiritem.hxx>
70 #include <editeng/itemtype.hxx>
71 #include <editeng/eerdll.hxx>
72 #include <editeng/memberids.h>
73 #include <libxml/xmlwriter.h>
74 #include <o3tl/enumrange.hxx>
75 #include <o3tl/safeint.hxx>
76 #include <sal/log.hxx>
77 #include <vcl/GraphicLoader.hxx>
78 #include <unotools/securityoptions.hxx>
79 #include <docmodel/uno/UnoComplexColor.hxx>
81 #include <boost/property_tree/ptree.hpp>
83 using namespace ::editeng
;
84 using namespace ::com::sun::star
;
85 using namespace ::com::sun::star::drawing
;
86 using namespace ::com::sun::star::table::BorderLineStyle
;
89 SfxPoolItem
* SvxPaperBinItem::CreateDefault() { return new SvxPaperBinItem(0);}
90 SfxPoolItem
* SvxSizeItem::CreateDefault() { return new SvxSizeItem(0);}
91 SfxPoolItem
* SvxLRSpaceItem::CreateDefault() { return new SvxLRSpaceItem(0);}
92 SfxPoolItem
* SvxULSpaceItem::CreateDefault() { return new SvxULSpaceItem(0);}
93 SfxPoolItem
* SvxProtectItem::CreateDefault() { return new SvxProtectItem(0);}
94 SfxPoolItem
* SvxBrushItem::CreateDefault() { return new SvxBrushItem(0);}
95 SfxPoolItem
* SvxShadowItem::CreateDefault() { return new SvxShadowItem(0);}
96 SfxPoolItem
* SvxBoxItem::CreateDefault() { return new SvxBoxItem(0);}
97 SfxPoolItem
* SvxBoxInfoItem::CreateDefault() { return new SvxBoxInfoItem(0);}
98 SfxPoolItem
* SvxFormatBreakItem::CreateDefault() { return new SvxFormatBreakItem(SvxBreak::NONE
, 0);}
99 SfxPoolItem
* SvxFormatKeepItem::CreateDefault() { return new SvxFormatKeepItem(false, 0);}
100 SfxPoolItem
* SvxLineItem::CreateDefault() { return new SvxLineItem(0);}
102 SvxPaperBinItem
* SvxPaperBinItem::Clone( SfxItemPool
* ) const
104 return new SvxPaperBinItem( *this );
107 bool SvxPaperBinItem::GetPresentation
109 SfxItemPresentation ePres
,
110 MapUnit
/*eCoreUnit*/,
111 MapUnit
/*ePresUnit*/,
112 OUString
& rText
, const IntlWrapper
&
117 case SfxItemPresentation::Nameless
:
118 rText
= OUString::number( GetValue() );
121 case SfxItemPresentation::Complete
:
123 sal_uInt8 nValue
= GetValue();
125 if ( PAPERBIN_PRINTER_SETTINGS
== nValue
)
126 rText
= EditResId(RID_SVXSTR_PAPERBIN_SETTINGS
);
129 rText
= EditResId(RID_SVXSTR_PAPERBIN
) + " " + OUString::number( nValue
);
134 default: ; //prevent warning
141 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId
, const Size
& rSize
) :
150 bool SvxSizeItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
152 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
153 nMemberId
&= ~CONVERT_TWIPS
;
155 awt::Size
aTmp(m_aSize
.Width(), m_aSize
.Height());
158 aTmp
.Height
= convertTwipToMm100(aTmp
.Height
);
159 aTmp
.Width
= convertTwipToMm100(aTmp
.Width
);
164 case MID_SIZE_SIZE
: rVal
<<= aTmp
; break;
165 case MID_SIZE_WIDTH
: rVal
<<= aTmp
.Width
; break;
166 case MID_SIZE_HEIGHT
: rVal
<<= aTmp
.Height
; break;
167 default: OSL_FAIL("Wrong MemberId!"); return false;
174 bool SvxSizeItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
176 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
177 nMemberId
&= ~CONVERT_TWIPS
;
188 aTmp
.Height
= o3tl::toTwips(aTmp
.Height
, o3tl::Length::mm100
);
189 aTmp
.Width
= o3tl::toTwips(aTmp
.Width
, o3tl::Length::mm100
);
191 m_aSize
= Size( aTmp
.Width
, aTmp
.Height
);
202 if(!(rVal
>>= nVal
))
205 m_aSize
.setWidth( bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
);
208 case MID_SIZE_HEIGHT
:
214 m_aSize
.setHeight( bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
);
217 default: OSL_FAIL("Wrong MemberId!");
224 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId
) :
231 bool SvxSizeItem::operator==( const SfxPoolItem
& rAttr
) const
233 assert(SfxPoolItem::operator==(rAttr
));
235 return ( m_aSize
== static_cast<const SvxSizeItem
&>( rAttr
).GetSize() );
238 SvxSizeItem
* SvxSizeItem::Clone( SfxItemPool
* ) const
240 return new SvxSizeItem( *this );
243 bool SvxSizeItem::GetPresentation
245 SfxItemPresentation ePres
,
248 OUString
& rText
, const IntlWrapper
& rIntl
251 OUString
cpDelimTmp(cpDelim
);
254 case SfxItemPresentation::Nameless
:
255 rText
= GetMetricText( m_aSize
.Width(), eCoreUnit
, ePresUnit
, &rIntl
) +
257 GetMetricText( m_aSize
.Height(), eCoreUnit
, ePresUnit
, &rIntl
);
260 case SfxItemPresentation::Complete
:
261 rText
= EditResId(RID_SVXITEMS_SIZE_WIDTH
) +
262 GetMetricText( m_aSize
.Width(), eCoreUnit
, ePresUnit
, &rIntl
) +
263 " " + EditResId(GetMetricId(ePresUnit
)) +
265 EditResId(RID_SVXITEMS_SIZE_HEIGHT
) +
266 GetMetricText( m_aSize
.Height(), eCoreUnit
, ePresUnit
, &rIntl
) +
267 " " + EditResId(GetMetricId(ePresUnit
));
269 // no break necessary
270 default: ; // prevent warning
277 void SvxSizeItem::ScaleMetrics( tools::Long nMult
, tools::Long nDiv
)
279 m_aSize
.setWidth( BigInt::Scale( m_aSize
.Width(), nMult
, nDiv
) );
280 m_aSize
.setHeight( BigInt::Scale( m_aSize
.Height(), nMult
, nDiv
) );
284 bool SvxSizeItem::HasMetrics() const
290 SvxLRSpaceItem::SvxLRSpaceItem(const sal_uInt16 nId
)
292 , nFirstLineOffset(0)
296 , m_nRightGutterMargin(0),
297 nPropFirstLineOffset( 100 ),
298 nPropLeftMargin( 100 ),
299 nPropRightMargin( 100 ),
300 bAutoFirst ( false ),
301 bExplicitZeroMarginValRight(false),
302 bExplicitZeroMarginValLeft(false)
307 SvxLRSpaceItem::SvxLRSpaceItem( const tools::Long nLeft
, const tools::Long nRight
,
309 const sal_uInt16 nId
)
311 , nFirstLineOffset(nOfset
)
313 , nRightMargin(nRight
)
315 , m_nRightGutterMargin(0),
316 nPropFirstLineOffset( 100 ),
317 nPropLeftMargin( 100 ),
318 nPropRightMargin( 100 ),
319 bAutoFirst ( false ),
320 bExplicitZeroMarginValRight(false),
321 bExplicitZeroMarginValLeft(false)
326 bool SvxLRSpaceItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
329 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
330 nMemberId
&= ~CONVERT_TWIPS
;
336 css::frame::status::LeftRightMarginScale aLRSpace
;
337 aLRSpace
.Left
= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(nLeftMargin
) : nLeftMargin
);
338 aLRSpace
.TextLeft
= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(GetTextLeft()) : GetTextLeft());
339 aLRSpace
.Right
= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(nRightMargin
) : nRightMargin
);
340 aLRSpace
.ScaleLeft
= static_cast<sal_Int16
>(nPropLeftMargin
);
341 aLRSpace
.ScaleRight
= static_cast<sal_Int16
>(nPropRightMargin
);
342 aLRSpace
.FirstLine
= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(nFirstLineOffset
) : nFirstLineOffset
);
343 aLRSpace
.ScaleFirstLine
= static_cast<sal_Int16
>(nPropFirstLineOffset
);
344 aLRSpace
.AutoFirstLine
= IsAutoFirst();
349 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(nLeftMargin
) : nLeftMargin
);
352 case MID_TXT_LMARGIN
:
353 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(GetTextLeft()) : GetTextLeft());
356 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(nRightMargin
) : nRightMargin
);
358 case MID_L_REL_MARGIN
:
359 rVal
<<= static_cast<sal_Int16
>(nPropLeftMargin
);
361 case MID_R_REL_MARGIN
:
362 rVal
<<= static_cast<sal_Int16
>(nPropRightMargin
);
365 case MID_FIRST_LINE_INDENT
:
366 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(nFirstLineOffset
) : nFirstLineOffset
);
369 case MID_FIRST_LINE_REL_INDENT
:
370 rVal
<<= static_cast<sal_Int16
>(nPropFirstLineOffset
);
374 rVal
<<= IsAutoFirst();
377 case MID_GUTTER_MARGIN
:
378 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(m_nGutterMargin
)
384 // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have?
385 OSL_FAIL("unknown MemberId");
391 bool SvxLRSpaceItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
393 bool bConvert
= 0 != (nMemberId
&CONVERT_TWIPS
);
394 nMemberId
&= ~CONVERT_TWIPS
;
396 if( nMemberId
!= 0 && nMemberId
!= MID_FIRST_AUTO
&&
397 nMemberId
!= MID_L_REL_MARGIN
&& nMemberId
!= MID_R_REL_MARGIN
)
405 css::frame::status::LeftRightMarginScale aLRSpace
;
406 if(!(rVal
>>= aLRSpace
))
409 SetLeft( bConvert
? o3tl::toTwips(aLRSpace
.Left
, o3tl::Length::mm100
) : aLRSpace
.Left
);
410 SetTextLeft( bConvert
? o3tl::toTwips(aLRSpace
.TextLeft
, o3tl::Length::mm100
) : aLRSpace
.TextLeft
);
411 SetRight(bConvert
? o3tl::toTwips(aLRSpace
.Right
, o3tl::Length::mm100
) : aLRSpace
.Right
);
412 nPropLeftMargin
= aLRSpace
.ScaleLeft
;
413 nPropRightMargin
= aLRSpace
.ScaleRight
;
414 SetTextFirstLineOffset(bConvert
? o3tl::toTwips(aLRSpace
.FirstLine
, o3tl::Length::mm100
) : aLRSpace
.FirstLine
);
415 SetPropTextFirstLineOffset ( aLRSpace
.ScaleFirstLine
);
416 SetAutoFirst( aLRSpace
.AutoFirstLine
);
420 SetLeft( bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
);
423 case MID_TXT_LMARGIN
:
424 SetTextLeft( bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
);
428 SetRight(bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
);
430 case MID_L_REL_MARGIN
:
431 case MID_R_REL_MARGIN
:
434 if((rVal
>>= nRel
) && nRel
>= 0 && nRel
< SAL_MAX_UINT16
)
436 if(MID_L_REL_MARGIN
== nMemberId
)
437 nPropLeftMargin
= static_cast<sal_uInt16
>(nRel
);
439 nPropRightMargin
= static_cast<sal_uInt16
>(nRel
);
445 case MID_FIRST_LINE_INDENT
:
446 SetTextFirstLineOffset(bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
);
449 case MID_FIRST_LINE_REL_INDENT
:
450 SetPropTextFirstLineOffset ( nVal
);
454 SetAutoFirst( Any2Bool(rVal
) );
457 case MID_GUTTER_MARGIN
:
458 SetGutterMargin(bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
);
462 OSL_FAIL("unknown MemberId");
468 void SvxLeftMarginItem::SetLeft(const tools::Long nL
, const sal_uInt16 nProp
)
470 m_nLeftMargin
= (nL
* nProp
) / 100;
471 m_nPropLeftMargin
= nProp
;
474 void SvxLRSpaceItem::SetLeft(const tools::Long nL
, const sal_uInt16 nProp
)
476 nLeftMargin
= (nL
* nProp
) / 100;
477 SAL_WARN_IF(nFirstLineOffset
!= 0, "editeng", "probably call SetTextLeft instead? looks inconsistent otherwise");
478 nPropLeftMargin
= nProp
;
481 void SvxRightMarginItem::SetRight(const tools::Long nR
, const sal_uInt16 nProp
)
483 m_nRightMargin
= (nR
* nProp
) / 100;
484 m_nPropRightMargin
= nProp
;
487 void SvxLRSpaceItem::SetRight(const tools::Long nR
, const sal_uInt16 nProp
)
491 SetExplicitZeroMarginValRight(true);
493 nRightMargin
= (nR
* nProp
) / 100;
494 nPropRightMargin
= nProp
;
497 void SvxFirstLineIndentItem::SetTextFirstLineOffset(
498 const short nF
, const sal_uInt16 nProp
)
500 m_nFirstLineOffset
= short((tools::Long(nF
) * nProp
) / 100);
501 m_nPropFirstLineOffset
= nProp
;
504 void SvxLRSpaceItem::SetTextFirstLineOffset(const short nF
, const sal_uInt16 nProp
)
506 // note: left margin contains any negative first line offset - preserve it!
507 if (nFirstLineOffset
< 0)
509 nLeftMargin
-= nFirstLineOffset
;
511 nFirstLineOffset
= short((tools::Long(nF
) * nProp
) / 100);
512 nPropFirstLineOffset
= nProp
;
513 if (nFirstLineOffset
< 0)
515 nLeftMargin
+= nFirstLineOffset
;
520 void SvxTextLeftMarginItem::SetLeft(SvxFirstLineIndentItem
const& rFirstLine
,
521 const tools::Long nL
, const sal_uInt16 nProp
)
523 m_nTextLeftMargin
= (nL
* nProp
) / 100;
524 m_nPropLeftMargin
= nProp
;
525 // note: text left margin contains any negative first line offset
526 if (rFirstLine
.GetTextFirstLineOffset() < 0)
528 m_nTextLeftMargin
+= rFirstLine
.GetTextFirstLineOffset();
533 void SvxTextLeftMarginItem::SetTextLeft(const tools::Long nL
, const sal_uInt16 nProp
)
535 m_nTextLeftMargin
= (nL
* nProp
) / 100;
536 m_nPropLeftMargin
= nProp
;
539 void SvxLRSpaceItem::SetTextLeft(const tools::Long nL
, const sal_uInt16 nProp
)
543 SetExplicitZeroMarginValLeft(true);
545 auto const nTxtLeft
= (nL
* nProp
) / 100;
546 nPropLeftMargin
= nProp
;
547 // note: left margin contains any negative first line offset
548 if ( 0 > nFirstLineOffset
)
549 nLeftMargin
= nTxtLeft
+ nFirstLineOffset
;
551 nLeftMargin
= nTxtLeft
;
554 tools::Long
SvxTextLeftMarginItem::GetTextLeft() const
556 return m_nTextLeftMargin
;
559 tools::Long
SvxTextLeftMarginItem::GetLeft(SvxFirstLineIndentItem
const& rFirstLine
) const
561 // add any negative first line offset to text left margin to get left
562 return (rFirstLine
.GetTextFirstLineOffset() < 0)
563 ? m_nTextLeftMargin
+ rFirstLine
.GetTextFirstLineOffset()
567 tools::Long
SvxLRSpaceItem::GetTextLeft() const
569 // remove any negative first line offset from left margin to get text-left
570 return (nFirstLineOffset
< 0)
571 ? nLeftMargin
- nFirstLineOffset
575 SvxLeftMarginItem::SvxLeftMarginItem(const sal_uInt16 nId
)
580 SvxLeftMarginItem::SvxLeftMarginItem(const tools::Long nLeft
, const sal_uInt16 nId
)
582 , m_nLeftMargin(nLeft
)
586 bool SvxLeftMarginItem::QueryValue(uno::Any
& rVal
, sal_uInt8 nMemberId
) const
589 bool bConvert
= 0 != (nMemberId
& CONVERT_TWIPS
);
590 nMemberId
&= ~CONVERT_TWIPS
;
594 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(m_nLeftMargin
) : m_nLeftMargin
);
596 case MID_L_REL_MARGIN
:
597 rVal
<<= static_cast<sal_Int16
>(m_nPropLeftMargin
);
602 // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have?
603 OSL_FAIL("unknown MemberId");
608 bool SvxLeftMarginItem::PutValue(const uno::Any
& rVal
, sal_uInt8 nMemberId
)
610 bool bConvert
= 0 != (nMemberId
& CONVERT_TWIPS
);
611 nMemberId
&= ~CONVERT_TWIPS
;
618 if (!(rVal
>>= nVal
))
622 SetLeft(bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
);
625 case MID_L_REL_MARGIN
:
628 if ((rVal
>>= nRel
) && nRel
>= 0 && nRel
< SAL_MAX_UINT16
)
630 m_nPropLeftMargin
= static_cast<sal_uInt16
>(nRel
);
640 OSL_FAIL("unknown MemberId");
646 bool SvxLeftMarginItem::operator==(const SfxPoolItem
& rAttr
) const
648 assert(SfxPoolItem::operator==(rAttr
));
650 const SvxLeftMarginItem
& rOther
= static_cast<const SvxLeftMarginItem
&>(rAttr
);
652 return (m_nLeftMargin
== rOther
.GetLeft()
653 && m_nPropLeftMargin
== rOther
.GetPropLeft());
656 SvxLeftMarginItem
* SvxLeftMarginItem::Clone(SfxItemPool
*) const
658 return new SvxLeftMarginItem(*this);
661 bool SvxLeftMarginItem::GetPresentation
663 SfxItemPresentation ePres
,
666 OUString
& rText
, const IntlWrapper
& rIntl
671 case SfxItemPresentation::Nameless
:
673 if (100 != m_nPropLeftMargin
)
675 rText
= unicode::formatPercent(m_nPropLeftMargin
,
676 Application::GetSettings().GetUILanguageTag());
680 rText
= GetMetricText(m_nLeftMargin
,
681 eCoreUnit
, ePresUnit
, &rIntl
);
685 case SfxItemPresentation::Complete
:
687 rText
= EditResId(RID_SVXITEMS_LRSPACE_LEFT
);
688 if (100 != m_nPropLeftMargin
)
690 rText
+= unicode::formatPercent(m_nPropLeftMargin
,
691 Application::GetSettings().GetUILanguageTag());
695 rText
+= GetMetricText(m_nLeftMargin
, eCoreUnit
, ePresUnit
, &rIntl
)
696 + " " + EditResId(GetMetricId(ePresUnit
));
700 default: ; // prevent warning
705 void SvxLeftMarginItem::ScaleMetrics(tools::Long
const nMult
, tools::Long
const nDiv
)
707 m_nLeftMargin
= BigInt::Scale(m_nLeftMargin
, nMult
, nDiv
);
710 bool SvxLeftMarginItem::HasMetrics() const
715 void SvxLeftMarginItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
717 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxLeftMarginItem"));
718 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
719 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_nLeftMargin"), BAD_CAST(OString::number(m_nLeftMargin
).getStr()));
720 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_nPropLeftMargin"), BAD_CAST(OString::number(m_nPropLeftMargin
).getStr()));
721 (void)xmlTextWriterEndElement(pWriter
);
724 boost::property_tree::ptree
SvxLeftMarginItem::dumpAsJSON() const
726 boost::property_tree::ptree aTree
= SfxPoolItem::dumpAsJSON();
728 boost::property_tree::ptree aState
;
730 MapUnit eTargetUnit
= MapUnit::MapInch
;
732 OUString sLeft
= GetMetricText(GetLeft(),
733 MapUnit::MapTwip
, eTargetUnit
, nullptr);
735 aState
.put("left", sLeft
);
736 aState
.put("unit", "inch");
738 aTree
.push_back(std::make_pair("state", aState
));
743 SvxTextLeftMarginItem::SvxTextLeftMarginItem(const sal_uInt16 nId
)
748 SvxTextLeftMarginItem::SvxTextLeftMarginItem(const tools::Long nLeft
, const sal_uInt16 nId
)
750 , m_nTextLeftMargin(nLeft
)
754 bool SvxTextLeftMarginItem::QueryValue(uno::Any
& rVal
, sal_uInt8 nMemberId
) const
757 bool bConvert
= 0 != (nMemberId
& CONVERT_TWIPS
);
758 nMemberId
&= ~CONVERT_TWIPS
;
761 // tdf#154282 - return both values for the hardcoded 0 in SfxDispatchController_Impl::StateChanged
764 css::frame::status::LeftRightMarginScale aLRSpace
;
765 aLRSpace
.TextLeft
= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(GetTextLeft()) : GetTextLeft());
766 aLRSpace
.ScaleLeft
= static_cast<sal_Int16
>(m_nPropLeftMargin
);
770 case MID_TXT_LMARGIN
:
771 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(GetTextLeft()) : GetTextLeft());
773 case MID_L_REL_MARGIN
:
774 rVal
<<= static_cast<sal_Int16
>(m_nPropLeftMargin
);
779 // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have?
780 OSL_FAIL("unknown MemberId");
785 bool SvxTextLeftMarginItem::PutValue(const uno::Any
& rVal
, sal_uInt8 nMemberId
)
787 bool bConvert
= 0 != (nMemberId
& CONVERT_TWIPS
);
788 nMemberId
&= ~CONVERT_TWIPS
;
792 case MID_TXT_LMARGIN
:
795 if (!(rVal
>>= nVal
))
799 SetTextLeft(bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
);
802 case MID_L_REL_MARGIN
:
805 if ((rVal
>>= nRel
) && nRel
>= 0 && nRel
< SAL_MAX_UINT16
)
807 m_nPropLeftMargin
= static_cast<sal_uInt16
>(nRel
);
817 OSL_FAIL("unknown MemberId");
823 bool SvxTextLeftMarginItem::operator==(const SfxPoolItem
& rAttr
) const
825 assert(SfxPoolItem::operator==(rAttr
));
827 const SvxTextLeftMarginItem
& rOther
= static_cast<const SvxTextLeftMarginItem
&>(rAttr
);
829 return (m_nTextLeftMargin
== rOther
.GetTextLeft()
830 && m_nPropLeftMargin
== rOther
.GetPropLeft());
833 SvxTextLeftMarginItem
* SvxTextLeftMarginItem::Clone(SfxItemPool
*) const
835 return new SvxTextLeftMarginItem(*this);
838 bool SvxTextLeftMarginItem::GetPresentation
840 SfxItemPresentation ePres
,
843 OUString
& rText
, const IntlWrapper
& rIntl
848 case SfxItemPresentation::Nameless
:
850 if (100 != m_nPropLeftMargin
)
852 rText
= unicode::formatPercent(m_nPropLeftMargin
,
853 Application::GetSettings().GetUILanguageTag());
857 rText
= GetMetricText(m_nTextLeftMargin
,
858 eCoreUnit
, ePresUnit
, &rIntl
);
862 case SfxItemPresentation::Complete
:
864 rText
= EditResId(RID_SVXITEMS_LRSPACE_LEFT
);
865 if (100 != m_nPropLeftMargin
)
867 rText
+= unicode::formatPercent(m_nPropLeftMargin
,
868 Application::GetSettings().GetUILanguageTag());
872 rText
+= GetMetricText(m_nTextLeftMargin
, eCoreUnit
, ePresUnit
, &rIntl
)
873 + " " + EditResId(GetMetricId(ePresUnit
));
877 default: ; // prevent warning
882 void SvxTextLeftMarginItem::ScaleMetrics(tools::Long
const nMult
, tools::Long
const nDiv
)
884 m_nTextLeftMargin
= BigInt::Scale(m_nTextLeftMargin
, nMult
, nDiv
);
887 bool SvxTextLeftMarginItem::HasMetrics() const
892 void SvxTextLeftMarginItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
894 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxTextLeftMarginItem"));
895 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
896 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_nTextLeftMargin"), BAD_CAST(OString::number(m_nTextLeftMargin
).getStr()));
897 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_nPropLeftMargin"), BAD_CAST(OString::number(m_nPropLeftMargin
).getStr()));
898 (void)xmlTextWriterEndElement(pWriter
);
901 boost::property_tree::ptree
SvxTextLeftMarginItem::dumpAsJSON() const
903 boost::property_tree::ptree aTree
= SfxPoolItem::dumpAsJSON();
905 boost::property_tree::ptree aState
;
907 MapUnit eTargetUnit
= MapUnit::MapInch
;
909 OUString sLeft
= GetMetricText(GetTextLeft(),
910 MapUnit::MapTwip
, eTargetUnit
, nullptr);
912 aState
.put("left", sLeft
);
913 aState
.put("unit", "inch");
915 aTree
.push_back(std::make_pair("state", aState
));
920 SvxFirstLineIndentItem::SvxFirstLineIndentItem(const sal_uInt16 nId
)
925 SvxFirstLineIndentItem::SvxFirstLineIndentItem(const short nFirst
, const sal_uInt16 nId
)
927 , m_nFirstLineOffset(nFirst
)
931 bool SvxFirstLineIndentItem::QueryValue(uno::Any
& rVal
, sal_uInt8 nMemberId
) const
934 bool bConvert
= 0 != (nMemberId
& CONVERT_TWIPS
);
935 nMemberId
&= ~CONVERT_TWIPS
;
938 case MID_FIRST_LINE_INDENT
:
939 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(m_nFirstLineOffset
) : m_nFirstLineOffset
);
941 case MID_FIRST_LINE_REL_INDENT
:
942 rVal
<<= static_cast<sal_Int16
>(m_nPropFirstLineOffset
);
945 rVal
<<= IsAutoFirst();
950 // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have?
951 OSL_FAIL("unknown MemberId");
956 bool SvxFirstLineIndentItem::PutValue(const uno::Any
& rVal
, sal_uInt8 nMemberId
)
958 bool bConvert
= 0 != (nMemberId
& CONVERT_TWIPS
);
959 nMemberId
&= ~CONVERT_TWIPS
;
963 case MID_FIRST_LINE_INDENT
:
966 if (!(rVal
>>= nVal
))
970 m_nFirstLineOffset
= bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
;
971 m_nPropFirstLineOffset
= 100;
974 case MID_FIRST_LINE_REL_INDENT
:
977 if ((rVal
>>= nRel
) && nRel
>= 0 && nRel
< SAL_MAX_UINT16
)
979 SetPropTextFirstLineOffset(nRel
);
988 SetAutoFirst(Any2Bool(rVal
));
992 OSL_FAIL("unknown MemberId");
998 bool SvxFirstLineIndentItem::operator==(const SfxPoolItem
& rAttr
) const
1000 assert(SfxPoolItem::operator==(rAttr
));
1002 const SvxFirstLineIndentItem
& rOther
= static_cast<const SvxFirstLineIndentItem
&>(rAttr
);
1004 return (m_nFirstLineOffset
== rOther
.GetTextFirstLineOffset()
1005 && m_nPropFirstLineOffset
== rOther
.GetPropTextFirstLineOffset()
1006 && m_bAutoFirst
== rOther
.IsAutoFirst());
1009 SvxFirstLineIndentItem
* SvxFirstLineIndentItem::Clone(SfxItemPool
*) const
1011 return new SvxFirstLineIndentItem(*this);
1014 bool SvxFirstLineIndentItem::GetPresentation
1016 SfxItemPresentation ePres
,
1019 OUString
& rText
, const IntlWrapper
& rIntl
1024 case SfxItemPresentation::Nameless
:
1026 if (100 != m_nPropFirstLineOffset
)
1028 rText
+= unicode::formatPercent(m_nPropFirstLineOffset
,
1029 Application::GetSettings().GetUILanguageTag());
1033 rText
+= GetMetricText(static_cast<tools::Long
>(m_nFirstLineOffset
),
1034 eCoreUnit
, ePresUnit
, &rIntl
);
1038 case SfxItemPresentation::Complete
:
1040 rText
+= EditResId(RID_SVXITEMS_LRSPACE_FLINE
);
1041 if (100 != m_nPropFirstLineOffset
)
1043 rText
+= unicode::formatPercent(m_nPropFirstLineOffset
,
1044 Application::GetSettings().GetUILanguageTag());
1048 rText
+= GetMetricText(static_cast<tools::Long
>(m_nFirstLineOffset
),
1049 eCoreUnit
, ePresUnit
, &rIntl
)
1050 + " " + EditResId(GetMetricId(ePresUnit
));
1054 default: ; // prevent warning
1059 void SvxFirstLineIndentItem::ScaleMetrics(tools::Long
const nMult
, tools::Long
const nDiv
)
1061 m_nFirstLineOffset
= static_cast<short>(BigInt::Scale(m_nFirstLineOffset
, nMult
, nDiv
));
1064 bool SvxFirstLineIndentItem::HasMetrics() const
1069 void SvxFirstLineIndentItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1071 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxFirstLineIndentItem"));
1072 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1073 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_nFirstLineOffset"), BAD_CAST(OString::number(m_nFirstLineOffset
).getStr()));
1074 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_nPropFirstLineOffset"), BAD_CAST(OString::number(m_nPropFirstLineOffset
).getStr()));
1075 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_bAutoFirst"), BAD_CAST(OString::number(int(m_bAutoFirst
)).getStr()));
1076 (void)xmlTextWriterEndElement(pWriter
);
1079 boost::property_tree::ptree
SvxFirstLineIndentItem::dumpAsJSON() const
1081 boost::property_tree::ptree aTree
= SfxPoolItem::dumpAsJSON();
1083 boost::property_tree::ptree aState
;
1085 MapUnit eTargetUnit
= MapUnit::MapInch
;
1087 OUString sFirstline
= GetMetricText(GetTextFirstLineOffset(),
1088 MapUnit::MapTwip
, eTargetUnit
, nullptr);
1090 aState
.put("firstline", sFirstline
);
1091 aState
.put("unit", "inch");
1093 aTree
.push_back(std::make_pair("state", aState
));
1098 SvxRightMarginItem::SvxRightMarginItem(const sal_uInt16 nId
)
1103 SvxRightMarginItem::SvxRightMarginItem(const tools::Long nRight
, const sal_uInt16 nId
)
1105 , m_nRightMargin(nRight
)
1109 bool SvxRightMarginItem::QueryValue(uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1112 bool bConvert
= 0 != (nMemberId
& CONVERT_TWIPS
);
1113 nMemberId
&= ~CONVERT_TWIPS
;
1116 // tdf#154282 - return both values for the hardcoded 0 in SfxDispatchController_Impl::StateChanged
1119 css::frame::status::LeftRightMarginScale aLRSpace
;
1120 aLRSpace
.Right
= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(m_nRightMargin
) : m_nRightMargin
);
1121 aLRSpace
.ScaleRight
= static_cast<sal_Int16
>(m_nPropRightMargin
);
1126 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(m_nRightMargin
) : m_nRightMargin
);
1128 case MID_R_REL_MARGIN
:
1129 rVal
<<= static_cast<sal_Int16
>(m_nPropRightMargin
);
1134 // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have?
1135 OSL_FAIL("unknown MemberId");
1140 bool SvxRightMarginItem::PutValue(const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1142 bool bConvert
= 0 != (nMemberId
& CONVERT_TWIPS
);
1143 nMemberId
&= ~CONVERT_TWIPS
;
1150 if (!(rVal
>>= nVal
))
1154 SetRight(bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
);
1157 case MID_R_REL_MARGIN
:
1160 if ((rVal
>>= nRel
) && nRel
>= 0 && nRel
< SAL_MAX_UINT16
)
1162 m_nPropRightMargin
= static_cast<sal_uInt16
>(nRel
);
1172 OSL_FAIL("unknown MemberId");
1178 bool SvxRightMarginItem::operator==(const SfxPoolItem
& rAttr
) const
1180 assert(SfxPoolItem::operator==(rAttr
));
1182 const SvxRightMarginItem
& rOther
= static_cast<const SvxRightMarginItem
&>(rAttr
);
1184 return (m_nRightMargin
== rOther
.GetRight()
1185 && m_nPropRightMargin
== rOther
.GetPropRight());
1188 SvxRightMarginItem
* SvxRightMarginItem::Clone(SfxItemPool
*) const
1190 return new SvxRightMarginItem(*this);
1193 bool SvxRightMarginItem::GetPresentation
1195 SfxItemPresentation ePres
,
1198 OUString
& rText
, const IntlWrapper
& rIntl
1203 case SfxItemPresentation::Nameless
:
1205 if (100 != m_nRightMargin
)
1207 rText
+= unicode::formatPercent(m_nRightMargin
,
1208 Application::GetSettings().GetUILanguageTag());
1212 rText
+= GetMetricText(m_nRightMargin
,
1213 eCoreUnit
, ePresUnit
, &rIntl
);
1217 case SfxItemPresentation::Complete
:
1219 rText
+= EditResId(RID_SVXITEMS_LRSPACE_RIGHT
);
1220 if (100 != m_nPropRightMargin
)
1222 rText
+= unicode::formatPercent(m_nPropRightMargin
,
1223 Application::GetSettings().GetUILanguageTag());
1227 rText
+= GetMetricText(m_nRightMargin
,
1228 eCoreUnit
, ePresUnit
, &rIntl
)
1229 + " " + EditResId(GetMetricId(ePresUnit
));
1233 default: ; // prevent warning
1238 void SvxRightMarginItem::ScaleMetrics(tools::Long
const nMult
, tools::Long
const nDiv
)
1240 m_nRightMargin
= BigInt::Scale(m_nRightMargin
, nMult
, nDiv
);
1243 bool SvxRightMarginItem::HasMetrics() const
1248 void SvxRightMarginItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1250 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxRightMarginItem"));
1251 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1252 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_nRightMargin"), BAD_CAST(OString::number(m_nRightMargin
).getStr()));
1253 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_nPropRightMargin"), BAD_CAST(OString::number(m_nPropRightMargin
).getStr()));
1254 (void)xmlTextWriterEndElement(pWriter
);
1257 boost::property_tree::ptree
SvxRightMarginItem::dumpAsJSON() const
1259 boost::property_tree::ptree aTree
= SfxPoolItem::dumpAsJSON();
1261 boost::property_tree::ptree aState
;
1263 MapUnit eTargetUnit
= MapUnit::MapInch
;
1265 OUString sRight
= GetMetricText(GetRight(),
1266 MapUnit::MapTwip
, eTargetUnit
, nullptr);
1268 aState
.put("right", sRight
);
1269 aState
.put("unit", "inch");
1271 aTree
.push_back(std::make_pair("state", aState
));
1276 SvxGutterLeftMarginItem::SvxGutterLeftMarginItem(const sal_uInt16 nId
)
1281 bool SvxGutterLeftMarginItem::QueryValue(uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1284 bool bConvert
= 0 != (nMemberId
& CONVERT_TWIPS
);
1285 nMemberId
&= ~CONVERT_TWIPS
;
1288 case MID_GUTTER_MARGIN
:
1289 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(m_nGutterMargin
)
1295 // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have?
1296 OSL_FAIL("unknown MemberId");
1301 bool SvxGutterLeftMarginItem::PutValue(const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1303 bool bConvert
= 0 != (nMemberId
& CONVERT_TWIPS
);
1304 nMemberId
&= ~CONVERT_TWIPS
;
1308 case MID_GUTTER_MARGIN
:
1311 if (!(rVal
>>= nVal
))
1315 SetGutterMargin(bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
);
1320 OSL_FAIL("unknown MemberId");
1326 bool SvxGutterLeftMarginItem::operator==(const SfxPoolItem
& rAttr
) const
1328 assert(SfxPoolItem::operator==(rAttr
));
1330 const SvxGutterLeftMarginItem
& rOther
= static_cast<const SvxGutterLeftMarginItem
&>(rAttr
);
1332 return (m_nGutterMargin
== rOther
.GetGutterMargin());
1335 SvxGutterLeftMarginItem
* SvxGutterLeftMarginItem::Clone(SfxItemPool
* ) const
1337 return new SvxGutterLeftMarginItem(*this);
1340 bool SvxGutterLeftMarginItem::GetPresentation
1342 SfxItemPresentation
/*ePres*/,
1343 MapUnit
/*eCoreUnit*/,
1344 MapUnit
/*ePresUnit*/,
1345 OUString
& /*rText*/, const IntlWrapper
& /*rIntl*/
1352 void SvxGutterLeftMarginItem::ScaleMetrics(tools::Long
const /*nMult*/, tools::Long
const /*nDiv*/)
1357 bool SvxGutterLeftMarginItem::HasMetrics() const
1362 void SvxGutterLeftMarginItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1364 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxGutterLeftMarginItem"));
1365 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1366 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_nGutterMargin"),
1367 BAD_CAST(OString::number(m_nGutterMargin
).getStr()));
1368 (void)xmlTextWriterEndElement(pWriter
);
1371 boost::property_tree::ptree
SvxGutterLeftMarginItem::dumpAsJSON() const
1373 boost::property_tree::ptree aTree
= SfxPoolItem::dumpAsJSON();
1375 boost::property_tree::ptree aState
;
1378 aState
.put("unit", "inch");
1380 aTree
.push_back(std::make_pair("state", aState
));
1385 SvxGutterRightMarginItem::SvxGutterRightMarginItem(const sal_uInt16 nId
)
1390 bool SvxGutterRightMarginItem::QueryValue(uno::Any
& /*rVal*/, sal_uInt8 nMemberId
) const
1393 //bool bConvert = 0 != (nMemberId & CONVERT_TWIPS);
1394 nMemberId
&= ~CONVERT_TWIPS
;
1402 // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have?
1403 OSL_FAIL("unknown MemberId");
1411 bool SvxGutterRightMarginItem::PutValue(const uno::Any
& /*rVal*/, sal_uInt8 nMemberId
)
1413 //bool bConvert = 0 != (nMemberId & CONVERT_TWIPS);
1414 nMemberId
&= ~CONVERT_TWIPS
;
1422 OSL_FAIL("unknown MemberId");
1432 bool SvxGutterRightMarginItem::operator==(const SfxPoolItem
& rAttr
) const
1434 assert(SfxPoolItem::operator==(rAttr
));
1436 const SvxGutterRightMarginItem
& rOther
= static_cast<const SvxGutterRightMarginItem
&>(rAttr
);
1438 return (m_nRightGutterMargin
== rOther
.GetRightGutterMargin());
1441 SvxGutterRightMarginItem
* SvxGutterRightMarginItem::Clone(SfxItemPool
*) const
1443 return new SvxGutterRightMarginItem(*this);
1446 bool SvxGutterRightMarginItem::GetPresentation
1448 SfxItemPresentation
/*ePres*/,
1449 MapUnit
/*eCoreUnit*/,
1450 MapUnit
/*ePresUnit*/,
1451 OUString
& /*rText*/, const IntlWrapper
& /*rIntl*/
1458 void SvxGutterRightMarginItem::ScaleMetrics(tools::Long
const /*nMult*/, tools::Long
const /*nDiv*/)
1463 bool SvxGutterRightMarginItem::HasMetrics() const
1468 void SvxGutterRightMarginItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1470 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxGutterRightMarginItem"));
1471 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1472 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_nRightGutterMargin"),
1473 BAD_CAST(OString::number(m_nRightGutterMargin
).getStr()));
1474 (void)xmlTextWriterEndElement(pWriter
);
1477 boost::property_tree::ptree
SvxGutterRightMarginItem::dumpAsJSON() const
1479 boost::property_tree::ptree aTree
= SfxPoolItem::dumpAsJSON();
1481 boost::property_tree::ptree aState
;
1484 aState
.put("unit", "inch");
1486 aTree
.push_back(std::make_pair("state", aState
));
1492 bool SvxLRSpaceItem::operator==( const SfxPoolItem
& rAttr
) const
1494 assert(SfxPoolItem::operator==(rAttr
));
1496 const SvxLRSpaceItem
& rOther
= static_cast<const SvxLRSpaceItem
&>(rAttr
);
1499 nFirstLineOffset
== rOther
.GetTextFirstLineOffset() &&
1500 m_nGutterMargin
== rOther
.GetGutterMargin() &&
1501 m_nRightGutterMargin
== rOther
.GetRightGutterMargin() &&
1502 nLeftMargin
== rOther
.GetLeft() &&
1503 nRightMargin
== rOther
.GetRight() &&
1504 nPropFirstLineOffset
== rOther
.GetPropTextFirstLineOffset() &&
1505 nPropLeftMargin
== rOther
.GetPropLeft() &&
1506 nPropRightMargin
== rOther
.GetPropRight() &&
1507 bAutoFirst
== rOther
.IsAutoFirst() &&
1508 bExplicitZeroMarginValRight
== rOther
.IsExplicitZeroMarginValRight() &&
1509 bExplicitZeroMarginValLeft
== rOther
.IsExplicitZeroMarginValLeft() );
1512 SvxLRSpaceItem
* SvxLRSpaceItem::Clone( SfxItemPool
* ) const
1514 return new SvxLRSpaceItem( *this );
1517 bool SvxLRSpaceItem::GetPresentation
1519 SfxItemPresentation ePres
,
1522 OUString
& rText
, const IntlWrapper
& rIntl
1527 case SfxItemPresentation::Nameless
:
1529 if ( 100 != nPropLeftMargin
)
1531 rText
= unicode::formatPercent(nPropLeftMargin
,
1532 Application::GetSettings().GetUILanguageTag());
1535 rText
= GetMetricText( nLeftMargin
,
1536 eCoreUnit
, ePresUnit
, &rIntl
);
1538 if ( 100 != nPropFirstLineOffset
)
1540 rText
+= unicode::formatPercent(nPropFirstLineOffset
,
1541 Application::GetSettings().GetUILanguageTag());
1544 rText
+= GetMetricText( static_cast<tools::Long
>(nFirstLineOffset
),
1545 eCoreUnit
, ePresUnit
, &rIntl
);
1547 if ( 100 != nRightMargin
)
1549 rText
+= unicode::formatPercent(nRightMargin
,
1550 Application::GetSettings().GetUILanguageTag());
1553 rText
+= GetMetricText( nRightMargin
,
1554 eCoreUnit
, ePresUnit
, &rIntl
);
1557 case SfxItemPresentation::Complete
:
1559 rText
= EditResId(RID_SVXITEMS_LRSPACE_LEFT
);
1560 if ( 100 != nPropLeftMargin
)
1561 rText
+= unicode::formatPercent(nPropLeftMargin
,
1562 Application::GetSettings().GetUILanguageTag());
1565 rText
+= GetMetricText( nLeftMargin
, eCoreUnit
, ePresUnit
, &rIntl
) +
1566 " " + EditResId(GetMetricId(ePresUnit
));
1569 if ( 100 != nPropFirstLineOffset
|| nFirstLineOffset
)
1571 rText
+= EditResId(RID_SVXITEMS_LRSPACE_FLINE
);
1572 if ( 100 != nPropFirstLineOffset
)
1573 rText
+= unicode::formatPercent(nPropFirstLineOffset
,
1574 Application::GetSettings().GetUILanguageTag());
1577 rText
+= GetMetricText( static_cast<tools::Long
>(nFirstLineOffset
),
1578 eCoreUnit
, ePresUnit
, &rIntl
) +
1579 " " + EditResId(GetMetricId(ePresUnit
));
1583 rText
+= EditResId(RID_SVXITEMS_LRSPACE_RIGHT
);
1584 if ( 100 != nPropRightMargin
)
1585 rText
+= unicode::formatPercent(nPropRightMargin
,
1586 Application::GetSettings().GetUILanguageTag());
1589 rText
+= GetMetricText( nRightMargin
,
1590 eCoreUnit
, ePresUnit
, &rIntl
) +
1591 " " + EditResId(GetMetricId(ePresUnit
));
1595 default: ; // prevent warning
1601 void SvxLRSpaceItem::ScaleMetrics( tools::Long nMult
, tools::Long nDiv
)
1603 nFirstLineOffset
= static_cast<short>(BigInt::Scale( nFirstLineOffset
, nMult
, nDiv
));
1604 nLeftMargin
= BigInt::Scale( nLeftMargin
, nMult
, nDiv
);
1605 nRightMargin
= BigInt::Scale( nRightMargin
, nMult
, nDiv
);
1609 bool SvxLRSpaceItem::HasMetrics() const
1615 void SvxLRSpaceItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1617 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxLRSpaceItem"));
1618 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1619 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nFirstLineOffset"), BAD_CAST(OString::number(nFirstLineOffset
).getStr()));
1620 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nLeftMargin"), BAD_CAST(OString::number(nLeftMargin
).getStr()));
1621 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nRightMargin"), BAD_CAST(OString::number(nRightMargin
).getStr()));
1622 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_nGutterMargin"),
1623 BAD_CAST(OString::number(m_nGutterMargin
).getStr()));
1624 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_nRightGutterMargin"),
1625 BAD_CAST(OString::number(m_nRightGutterMargin
).getStr()));
1626 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nPropFirstLineOffset"), BAD_CAST(OString::number(nPropFirstLineOffset
).getStr()));
1627 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nPropLeftMargin"), BAD_CAST(OString::number(nPropLeftMargin
).getStr()));
1628 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nPropRightMargin"), BAD_CAST(OString::number(nPropRightMargin
).getStr()));
1629 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("bAutoFirst"), BAD_CAST(OString::number(int(bAutoFirst
)).getStr()));
1630 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("bExplicitZeroMarginValRight"), BAD_CAST(OString::number(int(bExplicitZeroMarginValRight
)).getStr()));
1631 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("bExplicitZeroMarginValLeft"), BAD_CAST(OString::number(int(bExplicitZeroMarginValLeft
)).getStr()));
1632 (void)xmlTextWriterEndElement(pWriter
);
1636 boost::property_tree::ptree
SvxLRSpaceItem::dumpAsJSON() const
1638 boost::property_tree::ptree aTree
= SfxPoolItem::dumpAsJSON();
1640 boost::property_tree::ptree aState
;
1642 MapUnit eTargetUnit
= MapUnit::MapInch
;
1644 OUString sLeft
= GetMetricText(GetLeft(),
1645 MapUnit::MapTwip
, eTargetUnit
, nullptr);
1647 OUString sRight
= GetMetricText(GetRight(),
1648 MapUnit::MapTwip
, eTargetUnit
, nullptr);
1650 OUString sFirstline
= GetMetricText(GetTextFirstLineOffset(),
1651 MapUnit::MapTwip
, eTargetUnit
, nullptr);
1653 aState
.put("left", sLeft
);
1654 aState
.put("right", sRight
);
1655 aState
.put("firstline", sFirstline
);
1656 aState
.put("unit", "inch");
1658 aTree
.push_back(std::make_pair("state", aState
));
1664 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nId
)
1675 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nUp
, const sal_uInt16 nLow
,
1676 const sal_uInt16 nId
)
1687 bool SvxULSpaceItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1689 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1690 nMemberId
&= ~CONVERT_TWIPS
;
1696 css::frame::status::UpperLowerMarginScale aUpperLowerMarginScale
;
1697 aUpperLowerMarginScale
.Upper
= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(nUpper
) : nUpper
);
1698 aUpperLowerMarginScale
.Lower
= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(nLower
) : nPropUpper
);
1699 aUpperLowerMarginScale
.ScaleUpper
= static_cast<sal_Int16
>(nPropUpper
);
1700 aUpperLowerMarginScale
.ScaleLower
= static_cast<sal_Int16
>(nPropLower
);
1701 rVal
<<= aUpperLowerMarginScale
;
1704 case MID_UP_MARGIN
: rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(nUpper
) : nUpper
); break;
1705 case MID_LO_MARGIN
: rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(nLower
) : nLower
); break;
1706 case MID_CTX_MARGIN
: rVal
<<= bContext
; break;
1707 case MID_UP_REL_MARGIN
: rVal
<<= static_cast<sal_Int16
>(nPropUpper
); break;
1708 case MID_LO_REL_MARGIN
: rVal
<<= static_cast<sal_Int16
>(nPropLower
); break;
1714 bool SvxULSpaceItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1716 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1717 nMemberId
&= ~CONVERT_TWIPS
;
1724 css::frame::status::UpperLowerMarginScale aUpperLowerMarginScale
;
1725 if ( !(rVal
>>= aUpperLowerMarginScale
))
1728 SetUpper(bConvert
? o3tl::toTwips(aUpperLowerMarginScale
.Upper
, o3tl::Length::mm100
) : aUpperLowerMarginScale
.Upper
);
1729 SetLower(bConvert
? o3tl::toTwips(aUpperLowerMarginScale
.Lower
, o3tl::Length::mm100
) : aUpperLowerMarginScale
.Lower
);
1730 if( aUpperLowerMarginScale
.ScaleUpper
> 1 )
1731 nPropUpper
= aUpperLowerMarginScale
.ScaleUpper
;
1732 if( aUpperLowerMarginScale
.ScaleLower
> 1 )
1733 nPropUpper
= aUpperLowerMarginScale
.ScaleLower
;
1737 case MID_UP_MARGIN
:
1738 if(!(rVal
>>= nVal
))
1740 SetUpper(bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
);
1742 case MID_LO_MARGIN
:
1743 if(!(rVal
>>= nVal
) || nVal
< 0)
1745 SetLower(bConvert
? o3tl::toTwips(nVal
, o3tl::Length::mm100
) : nVal
);
1747 case MID_CTX_MARGIN
:
1748 if (!(rVal
>>= bVal
))
1750 SetContextValue(bVal
);
1752 case MID_UP_REL_MARGIN
:
1753 case MID_LO_REL_MARGIN
:
1756 if((rVal
>>= nRel
) && nRel
> 1 )
1758 if(MID_UP_REL_MARGIN
== nMemberId
)
1759 nPropUpper
= static_cast<sal_uInt16
>(nRel
);
1761 nPropLower
= static_cast<sal_uInt16
>(nRel
);
1769 OSL_FAIL("unknown MemberId");
1776 bool SvxULSpaceItem::operator==( const SfxPoolItem
& rAttr
) const
1778 assert(SfxPoolItem::operator==(rAttr
));
1780 const SvxULSpaceItem
& rSpaceItem
= static_cast<const SvxULSpaceItem
&>( rAttr
);
1781 return ( nUpper
== rSpaceItem
.nUpper
&&
1782 nLower
== rSpaceItem
.nLower
&&
1783 bContext
== rSpaceItem
.bContext
&&
1784 nPropUpper
== rSpaceItem
.nPropUpper
&&
1785 nPropLower
== rSpaceItem
.nPropLower
);
1788 SvxULSpaceItem
* SvxULSpaceItem::Clone( SfxItemPool
* ) const
1790 return new SvxULSpaceItem( *this );
1793 bool SvxULSpaceItem::GetPresentation
1795 SfxItemPresentation ePres
,
1799 const IntlWrapper
& rIntl
1804 case SfxItemPresentation::Nameless
:
1806 if ( 100 != nPropUpper
)
1808 rText
= unicode::formatPercent(nPropUpper
,
1809 Application::GetSettings().GetUILanguageTag());
1812 rText
= GetMetricText( static_cast<tools::Long
>(nUpper
), eCoreUnit
, ePresUnit
, &rIntl
);
1814 if ( 100 != nPropLower
)
1816 rText
+= unicode::formatPercent(nPropLower
,
1817 Application::GetSettings().GetUILanguageTag());
1820 rText
+= GetMetricText( static_cast<tools::Long
>(nLower
), eCoreUnit
, ePresUnit
, &rIntl
);
1823 case SfxItemPresentation::Complete
:
1825 rText
= EditResId(RID_SVXITEMS_ULSPACE_UPPER
);
1826 if ( 100 != nPropUpper
)
1828 rText
+= unicode::formatPercent(nPropUpper
,
1829 Application::GetSettings().GetUILanguageTag());
1833 rText
+= GetMetricText( static_cast<tools::Long
>(nUpper
), eCoreUnit
, ePresUnit
, &rIntl
) +
1834 " " + EditResId(GetMetricId(ePresUnit
));
1836 rText
+= cpDelim
+ EditResId(RID_SVXITEMS_ULSPACE_LOWER
);
1837 if ( 100 != nPropLower
)
1839 rText
+= unicode::formatPercent(nPropLower
,
1840 Application::GetSettings().GetUILanguageTag());
1844 rText
+= GetMetricText( static_cast<tools::Long
>(nLower
), eCoreUnit
, ePresUnit
, &rIntl
) +
1845 " " + EditResId(GetMetricId(ePresUnit
));
1849 default: ; // prevent warning
1855 void SvxULSpaceItem::ScaleMetrics( tools::Long nMult
, tools::Long nDiv
)
1857 nUpper
= static_cast<sal_uInt16
>(BigInt::Scale( nUpper
, nMult
, nDiv
));
1858 nLower
= static_cast<sal_uInt16
>(BigInt::Scale( nLower
, nMult
, nDiv
));
1862 bool SvxULSpaceItem::HasMetrics() const
1868 void SvxULSpaceItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1870 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxULSpaceItem"));
1871 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1872 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nUpper"), BAD_CAST(OString::number(nUpper
).getStr()));
1873 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nLower"), BAD_CAST(OString::number(nLower
).getStr()));
1874 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("bContext"), BAD_CAST(OString::boolean(bContext
).getStr()));
1875 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nPropUpper"), BAD_CAST(OString::number(nPropUpper
).getStr()));
1876 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nPropLower"), BAD_CAST(OString::number(nPropLower
).getStr()));
1877 (void)xmlTextWriterEndElement(pWriter
);
1880 boost::property_tree::ptree
SvxULSpaceItem::dumpAsJSON() const
1882 boost::property_tree::ptree aTree
= SfxPoolItem::dumpAsJSON();
1884 boost::property_tree::ptree aState
;
1886 MapUnit eTargetUnit
= MapUnit::MapInch
;
1888 OUString sUpper
= GetMetricText(GetUpper(),
1889 MapUnit::MapTwip
, eTargetUnit
, nullptr);
1891 OUString sLower
= GetMetricText(GetLower(),
1892 MapUnit::MapTwip
, eTargetUnit
, nullptr);
1894 aState
.put("upper", sUpper
);
1895 aState
.put("lower", sLower
);
1896 aState
.put("unit", "inch");
1898 aTree
.push_back(std::make_pair("state", aState
));
1903 SvxPrintItem
* SvxPrintItem::Clone( SfxItemPool
* ) const
1905 return new SvxPrintItem( *this );
1908 bool SvxPrintItem::GetPresentation
1910 SfxItemPresentation
/*ePres*/,
1911 MapUnit
/*eCoreUnit*/,
1912 MapUnit
/*ePresUnit*/,
1913 OUString
& rText
, const IntlWrapper
&
1916 TranslateId pId
= RID_SVXITEMS_PRINT_FALSE
;
1919 pId
= RID_SVXITEMS_PRINT_TRUE
;
1920 rText
= EditResId(pId
);
1924 SvxOpaqueItem
* SvxOpaqueItem::Clone( SfxItemPool
* ) const
1926 return new SvxOpaqueItem( *this );
1929 bool SvxOpaqueItem::GetPresentation
1931 SfxItemPresentation
/*ePres*/,
1932 MapUnit
/*eCoreUnit*/,
1933 MapUnit
/*ePresUnit*/,
1934 OUString
& rText
, const IntlWrapper
&
1937 TranslateId pId
= RID_SVXITEMS_OPAQUE_FALSE
;
1940 pId
= RID_SVXITEMS_OPAQUE_TRUE
;
1941 rText
= EditResId(pId
);
1946 bool SvxProtectItem::operator==( const SfxPoolItem
& rAttr
) const
1948 assert(SfxPoolItem::operator==(rAttr
));
1950 const SvxProtectItem
& rItem
= static_cast<const SvxProtectItem
&>(rAttr
);
1951 return ( bCntnt
== rItem
.bCntnt
&&
1952 bSize
== rItem
.bSize
&&
1953 bPos
== rItem
.bPos
);
1957 bool SvxProtectItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1959 nMemberId
&= ~CONVERT_TWIPS
;
1963 case MID_PROTECT_CONTENT
: bValue
= bCntnt
; break;
1964 case MID_PROTECT_SIZE
: bValue
= bSize
; break;
1965 case MID_PROTECT_POSITION
: bValue
= bPos
; break;
1967 OSL_FAIL("Wrong MemberId");
1976 bool SvxProtectItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1978 nMemberId
&= ~CONVERT_TWIPS
;
1979 bool bVal( Any2Bool(rVal
) );
1982 case MID_PROTECT_CONTENT
: bCntnt
= bVal
; break;
1983 case MID_PROTECT_SIZE
: bSize
= bVal
; break;
1984 case MID_PROTECT_POSITION
: bPos
= bVal
; break;
1986 OSL_FAIL("Wrong MemberId");
1992 SvxProtectItem
* SvxProtectItem::Clone( SfxItemPool
* ) const
1994 return new SvxProtectItem( *this );
1997 bool SvxProtectItem::GetPresentation
1999 SfxItemPresentation
/*ePres*/,
2000 MapUnit
/*eCoreUnit*/,
2001 MapUnit
/*ePresUnit*/,
2002 OUString
& rText
, const IntlWrapper
&
2005 TranslateId pId
= RID_SVXITEMS_PROT_CONTENT_FALSE
;
2008 pId
= RID_SVXITEMS_PROT_CONTENT_TRUE
;
2009 rText
= EditResId(pId
) + cpDelim
;
2010 pId
= RID_SVXITEMS_PROT_SIZE_FALSE
;
2013 pId
= RID_SVXITEMS_PROT_SIZE_TRUE
;
2014 rText
+= EditResId(pId
) + cpDelim
;
2015 pId
= RID_SVXITEMS_PROT_POS_FALSE
;
2018 pId
= RID_SVXITEMS_PROT_POS_TRUE
;
2019 rText
+= EditResId(pId
);
2024 void SvxProtectItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2026 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxProtectItem"));
2027 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2028 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("content"), BAD_CAST(OString::boolean(bCntnt
).getStr()));
2029 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("size"), BAD_CAST(OString::boolean(bSize
).getStr()));
2030 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("position"), BAD_CAST(OString::boolean(bPos
).getStr()));
2031 (void)xmlTextWriterEndElement(pWriter
);
2035 SvxShadowItem::SvxShadowItem( const sal_uInt16 nId
,
2036 const Color
*pColor
, const sal_uInt16 nW
,
2037 const SvxShadowLocation eLoc
) :
2038 SfxEnumItemInterface( nId
),
2039 aShadowColor(COL_GRAY
),
2044 aShadowColor
= *pColor
;
2048 bool SvxShadowItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2050 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
2051 nMemberId
&= ~CONVERT_TWIPS
;
2053 table::ShadowFormat aShadow
;
2054 table::ShadowLocation eSet
= table::ShadowLocation_NONE
;
2057 case SvxShadowLocation::TopLeft
: eSet
= table::ShadowLocation_TOP_LEFT
; break;
2058 case SvxShadowLocation::TopRight
: eSet
= table::ShadowLocation_TOP_RIGHT
; break;
2059 case SvxShadowLocation::BottomLeft
: eSet
= table::ShadowLocation_BOTTOM_LEFT
; break;
2060 case SvxShadowLocation::BottomRight
: eSet
= table::ShadowLocation_BOTTOM_RIGHT
; break;
2061 default: ; // prevent warning
2063 aShadow
.Location
= eSet
;
2064 aShadow
.ShadowWidth
= bConvert
? convertTwipToMm100(nWidth
) : nWidth
;
2065 aShadow
.IsTransparent
= aShadowColor
.IsTransparent();
2066 aShadow
.Color
= sal_Int32(aShadowColor
);
2068 sal_Int8 nTransparence
= rtl::math::round((float(255 - aShadowColor
.GetAlpha()) * 100) / 255);
2070 switch ( nMemberId
)
2072 case MID_LOCATION
: rVal
<<= aShadow
.Location
; break;
2073 case MID_WIDTH
: rVal
<<= aShadow
.ShadowWidth
; break;
2074 case MID_TRANSPARENT
: rVal
<<= aShadow
.IsTransparent
; break;
2075 case MID_BG_COLOR
: rVal
<<= aShadow
.Color
; break;
2076 case 0: rVal
<<= aShadow
; break;
2077 case MID_SHADOW_TRANSPARENCE
: rVal
<<= nTransparence
; break;
2078 default: OSL_FAIL("Wrong MemberId!"); return false;
2084 bool SvxShadowItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2086 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
2087 nMemberId
&= ~CONVERT_TWIPS
;
2089 table::ShadowFormat aShadow
;
2091 bool bRet
= QueryValue( aAny
, bConvert
? CONVERT_TWIPS
: 0 ) && ( aAny
>>= aShadow
);
2092 switch ( nMemberId
)
2096 bRet
= (rVal
>>= aShadow
.Location
);
2100 bRet
= (rVal
>>= nVal
);
2101 aShadow
.Location
= static_cast<table::ShadowLocation
>(nVal
);
2107 case MID_WIDTH
: rVal
>>= aShadow
.ShadowWidth
; break;
2108 case MID_TRANSPARENT
: rVal
>>= aShadow
.IsTransparent
; break;
2109 case MID_BG_COLOR
: rVal
>>= aShadow
.Color
; break;
2110 case 0: rVal
>>= aShadow
; break;
2111 case MID_SHADOW_TRANSPARENCE
:
2113 sal_Int32 nTransparence
= 0;
2114 if ((rVal
>>= nTransparence
) && !o3tl::checked_multiply
<sal_Int32
>(nTransparence
, 255, nTransparence
))
2116 Color
aColor(ColorTransparency
, aShadow
.Color
);
2117 aColor
.SetAlpha(255 - rtl::math::round(float(nTransparence
) / 100));
2118 aShadow
.Color
= sal_Int32(aColor
);
2122 default: OSL_FAIL("Wrong MemberId!"); return false;
2127 switch( aShadow
.Location
)
2129 case table::ShadowLocation_NONE
: eLocation
= SvxShadowLocation::NONE
; break;
2130 case table::ShadowLocation_TOP_LEFT
: eLocation
= SvxShadowLocation::TopLeft
; break;
2131 case table::ShadowLocation_TOP_RIGHT
: eLocation
= SvxShadowLocation::TopRight
; break;
2132 case table::ShadowLocation_BOTTOM_LEFT
: eLocation
= SvxShadowLocation::BottomLeft
; break;
2133 case table::ShadowLocation_BOTTOM_RIGHT
: eLocation
= SvxShadowLocation::BottomRight
; break;
2134 default: ; // prevent warning
2137 nWidth
= bConvert
? o3tl::toTwips(aShadow
.ShadowWidth
, o3tl::Length::mm100
) : aShadow
.ShadowWidth
;
2138 Color
aSet(ColorTransparency
, aShadow
.Color
);
2139 aShadowColor
= aSet
;
2146 bool SvxShadowItem::operator==( const SfxPoolItem
& rAttr
) const
2148 assert(SfxPoolItem::operator==(rAttr
));
2150 const SvxShadowItem
& rItem
= static_cast<const SvxShadowItem
&>(rAttr
);
2151 return ( ( aShadowColor
== rItem
.aShadowColor
) &&
2152 ( nWidth
== rItem
.GetWidth() ) &&
2153 ( eLocation
== rItem
.GetLocation() ) );
2156 SvxShadowItem
* SvxShadowItem::Clone( SfxItemPool
* ) const
2158 return new SvxShadowItem( *this );
2161 sal_uInt16
SvxShadowItem::CalcShadowSpace( SvxShadowItemSide nShadow
) const
2163 sal_uInt16 nSpace
= 0;
2167 case SvxShadowItemSide::TOP
:
2168 if ( eLocation
== SvxShadowLocation::TopLeft
||
2169 eLocation
== SvxShadowLocation::TopRight
)
2173 case SvxShadowItemSide::BOTTOM
:
2174 if ( eLocation
== SvxShadowLocation::BottomLeft
||
2175 eLocation
== SvxShadowLocation::BottomRight
)
2179 case SvxShadowItemSide::LEFT
:
2180 if ( eLocation
== SvxShadowLocation::TopLeft
||
2181 eLocation
== SvxShadowLocation::BottomLeft
)
2185 case SvxShadowItemSide::RIGHT
:
2186 if ( eLocation
== SvxShadowLocation::TopRight
||
2187 eLocation
== SvxShadowLocation::BottomRight
)
2192 OSL_FAIL( "wrong shadow" );
2197 static TranslateId RID_SVXITEMS_SHADOW
[] =
2199 RID_SVXITEMS_SHADOW_NONE
,
2200 RID_SVXITEMS_SHADOW_TOPLEFT
,
2201 RID_SVXITEMS_SHADOW_TOPRIGHT
,
2202 RID_SVXITEMS_SHADOW_BOTTOMLEFT
,
2203 RID_SVXITEMS_SHADOW_BOTTOMRIGHT
2206 bool SvxShadowItem::GetPresentation
2208 SfxItemPresentation ePres
,
2211 OUString
& rText
, const IntlWrapper
& rIntl
2216 case SfxItemPresentation::Nameless
:
2218 rText
= ::GetColorString( aShadowColor
) + cpDelim
;
2219 TranslateId pId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
2221 if ( aShadowColor
.IsTransparent() )
2222 pId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
2223 rText
+= EditResId(pId
) +
2225 GetMetricText( static_cast<tools::Long
>(nWidth
), eCoreUnit
, ePresUnit
, &rIntl
) +
2227 EditResId(RID_SVXITEMS_SHADOW
[static_cast<int>(eLocation
)]);
2230 case SfxItemPresentation::Complete
:
2232 rText
= EditResId(RID_SVXITEMS_SHADOW_COMPLETE
) +
2233 ::GetColorString( aShadowColor
) +
2236 TranslateId pId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
2237 if ( aShadowColor
.IsTransparent() )
2238 pId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
2239 rText
+= EditResId(pId
) +
2241 GetMetricText( static_cast<tools::Long
>(nWidth
), eCoreUnit
, ePresUnit
, &rIntl
) +
2242 " " + EditResId(GetMetricId(ePresUnit
)) +
2244 EditResId(RID_SVXITEMS_SHADOW
[static_cast<int>(eLocation
)]);
2247 default: ; // prevent warning
2253 void SvxShadowItem::ScaleMetrics( tools::Long nMult
, tools::Long nDiv
)
2255 nWidth
= static_cast<sal_uInt16
>(BigInt::Scale( nWidth
, nMult
, nDiv
));
2259 bool SvxShadowItem::HasMetrics() const
2265 sal_uInt16
SvxShadowItem::GetValueCount() const
2267 return sal_uInt16(SvxShadowLocation::End
); // SvxShadowLocation::BottomRight + 1
2270 sal_uInt16
SvxShadowItem::GetEnumValue() const
2272 return static_cast<sal_uInt16
>(GetLocation());
2276 void SvxShadowItem::SetEnumValue( sal_uInt16 nVal
)
2278 SetLocation( static_cast<SvxShadowLocation
>(nVal
) );
2281 void SvxShadowItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2283 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxShadowItem"));
2284 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2285 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("aShadowColor"), BAD_CAST(aShadowColor
.AsRGBHexString().toUtf8().getStr()));
2286 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nWidth"), BAD_CAST(OString::number(nWidth
).getStr()));
2287 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("eLocation"), BAD_CAST(OString::number(static_cast<int>(eLocation
)).getStr()));
2288 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(EditResId(RID_SVXITEMS_SHADOW
[static_cast<int>(eLocation
)]).toUtf8().getStr()));
2289 (void)xmlTextWriterEndElement(pWriter
);
2292 // class SvxBoxItem ------------------------------------------------------
2294 SvxBoxItem::SvxBoxItem(const SvxBoxItem
& rCopy
)
2295 : SfxPoolItem (rCopy
)
2296 , mpTopBorderLine(rCopy
.mpTopBorderLine
? new SvxBorderLine(*rCopy
.mpTopBorderLine
) : nullptr)
2297 , mpBottomBorderLine(rCopy
.mpBottomBorderLine
? new SvxBorderLine(*rCopy
.mpBottomBorderLine
) : nullptr)
2298 , mpLeftBorderLine(rCopy
.mpLeftBorderLine
? new SvxBorderLine(*rCopy
.mpLeftBorderLine
) : nullptr)
2299 , mpRightBorderLine(rCopy
.mpRightBorderLine
? new SvxBorderLine(*rCopy
.mpRightBorderLine
) : nullptr)
2300 , mnTopDistance(rCopy
.mnTopDistance
)
2301 , mnBottomDistance(rCopy
.mnBottomDistance
)
2302 , mnLeftDistance(rCopy
.mnLeftDistance
)
2303 , mnRightDistance(rCopy
.mnRightDistance
)
2304 , maTempComplexColors(rCopy
.maTempComplexColors
)
2305 , mbRemoveAdjCellBorder(rCopy
.mbRemoveAdjCellBorder
)
2310 SvxBoxItem::SvxBoxItem(const sal_uInt16 nId
)
2316 SvxBoxItem::~SvxBoxItem()
2320 void SvxBoxItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2322 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxBoxItem"));
2323 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("top-dist"),
2324 BAD_CAST(OString::number(mnTopDistance
).getStr()));
2325 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("bottom-dist"),
2326 BAD_CAST(OString::number(mnBottomDistance
).getStr()));
2327 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("left-dist"),
2328 BAD_CAST(OString::number(mnLeftDistance
).getStr()));
2329 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("right-dist"),
2330 BAD_CAST(OString::number(mnRightDistance
).getStr()));
2331 SfxPoolItem::dumpAsXml(pWriter
);
2332 (void)xmlTextWriterEndElement(pWriter
);
2335 boost::property_tree::ptree
SvxBoxItem::dumpAsJSON() const
2337 boost::property_tree::ptree aTree
;
2339 boost::property_tree::ptree aState
;
2340 aState
.put("top", GetTop() && !GetTop()->isEmpty());
2341 aState
.put("bottom", GetBottom() && !GetBottom()->isEmpty());
2342 aState
.put("left", GetLeft() && !GetLeft()->isEmpty());
2343 aState
.put("right", GetRight() && !GetRight()->isEmpty());
2345 aTree
.push_back(std::make_pair("state", aState
));
2346 aTree
.put("commandName", ".uno:BorderOuter");
2352 static bool CompareBorderLine(const std::unique_ptr
<SvxBorderLine
> & pBrd1
, const SvxBorderLine
* pBrd2
)
2354 if( pBrd1
.get() == pBrd2
)
2356 if( pBrd1
== nullptr || pBrd2
== nullptr)
2358 return *pBrd1
== *pBrd2
;
2362 bool SvxBoxItem::operator==( const SfxPoolItem
& rAttr
) const
2364 assert(SfxPoolItem::operator==(rAttr
));
2366 const SvxBoxItem
& rBoxItem
= static_cast<const SvxBoxItem
&>(rAttr
);
2368 (mnTopDistance
== rBoxItem
.mnTopDistance
) &&
2369 (mnBottomDistance
== rBoxItem
.mnBottomDistance
) &&
2370 (mnLeftDistance
== rBoxItem
.mnLeftDistance
) &&
2371 (mnRightDistance
== rBoxItem
.mnRightDistance
) &&
2372 (mbRemoveAdjCellBorder
== rBoxItem
.mbRemoveAdjCellBorder
) &&
2373 (maTempComplexColors
== rBoxItem
.maTempComplexColors
) &&
2374 CompareBorderLine(mpTopBorderLine
, rBoxItem
.GetTop()) &&
2375 CompareBorderLine(mpBottomBorderLine
, rBoxItem
.GetBottom()) &&
2376 CompareBorderLine(mpLeftBorderLine
, rBoxItem
.GetLeft()) &&
2377 CompareBorderLine(mpRightBorderLine
, rBoxItem
.GetRight()));
2381 table::BorderLine2
SvxBoxItem::SvxLineToLine(const SvxBorderLine
* pLine
, bool bConvert
)
2383 table::BorderLine2 aLine
;
2386 aLine
.Color
= sal_Int32(pLine
->GetColor());
2387 aLine
.InnerLineWidth
= sal_uInt16( bConvert
? convertTwipToMm100(pLine
->GetInWidth() ): pLine
->GetInWidth() );
2388 aLine
.OuterLineWidth
= sal_uInt16( bConvert
? convertTwipToMm100(pLine
->GetOutWidth()): pLine
->GetOutWidth() );
2389 aLine
.LineDistance
= sal_uInt16( bConvert
? convertTwipToMm100(pLine
->GetDistance()): pLine
->GetDistance() );
2390 aLine
.LineStyle
= sal_Int16(pLine
->GetBorderLineStyle());
2391 aLine
.LineWidth
= sal_uInt32( bConvert
? convertTwipToMm100( pLine
->GetWidth( ) ) : pLine
->GetWidth( ) );
2395 aLine
.Color
= aLine
.InnerLineWidth
= aLine
.OuterLineWidth
= aLine
.LineDistance
= 0;
2396 aLine
.LineStyle
= table::BorderLineStyle::NONE
; // 0 is SOLID!
2401 bool SvxBoxItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2403 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
2404 table::BorderLine2 aRetLine
;
2405 sal_Int16 nDist
= 0;
2406 bool bDistMember
= false;
2407 nMemberId
&= ~CONVERT_TWIPS
;
2412 // 4 Borders and 5 distances
2413 uno::Sequence
< uno::Any
> aSeq
{
2414 uno::Any(SvxBoxItem::SvxLineToLine(GetLeft(), bConvert
)),
2415 uno::Any(SvxBoxItem::SvxLineToLine(GetRight(), bConvert
)),
2416 uno::Any(SvxBoxItem::SvxLineToLine(GetBottom(), bConvert
)),
2417 uno::Any(SvxBoxItem::SvxLineToLine(GetTop(), bConvert
)),
2418 uno::Any(static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(GetSmallestDistance()) : GetSmallestDistance())),
2419 uno::Any(static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(mnTopDistance
) : mnTopDistance
)),
2420 uno::Any(static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(mnBottomDistance
) : mnBottomDistance
)),
2421 uno::Any(static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(mnLeftDistance
) : mnLeftDistance
)),
2422 uno::Any(static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(mnRightDistance
) : mnRightDistance
))
2427 case MID_LEFT_BORDER
:
2429 aRetLine
= SvxBoxItem::SvxLineToLine(GetLeft(), bConvert
);
2431 case MID_RIGHT_BORDER
:
2433 aRetLine
= SvxBoxItem::SvxLineToLine(GetRight(), bConvert
);
2435 case MID_BOTTOM_BORDER
:
2437 aRetLine
= SvxBoxItem::SvxLineToLine(GetBottom(), bConvert
);
2439 case MID_TOP_BORDER
:
2441 aRetLine
= SvxBoxItem::SvxLineToLine(GetTop(), bConvert
);
2443 case BORDER_DISTANCE
:
2444 nDist
= GetSmallestDistance();
2447 case TOP_BORDER_DISTANCE
:
2448 nDist
= mnTopDistance
;
2451 case BOTTOM_BORDER_DISTANCE
:
2452 nDist
= mnBottomDistance
;
2455 case LEFT_BORDER_DISTANCE
:
2456 nDist
= mnLeftDistance
;
2459 case RIGHT_BORDER_DISTANCE
:
2460 nDist
= mnRightDistance
;
2463 case MID_BORDER_BOTTOM_COLOR
:
2465 if (mpBottomBorderLine
)
2467 rVal
<<= model::color::createXComplexColor(mpBottomBorderLine
->getComplexColor());
2469 else if (maTempComplexColors
[size_t(SvxBoxItemLine::BOTTOM
)].getType() != model::ColorType::Unused
)
2471 rVal
<<= model::color::createXComplexColor(maTempComplexColors
[size_t(SvxBoxItemLine::BOTTOM
)]);
2475 case MID_BORDER_LEFT_COLOR
:
2477 if (mpLeftBorderLine
)
2479 rVal
<<= model::color::createXComplexColor(mpLeftBorderLine
->getComplexColor());
2481 else if (maTempComplexColors
[size_t(SvxBoxItemLine::LEFT
)].getType() != model::ColorType::Unused
)
2483 rVal
<<= model::color::createXComplexColor(maTempComplexColors
[size_t(SvxBoxItemLine::LEFT
)]);
2487 case MID_BORDER_RIGHT_COLOR
:
2489 if (mpRightBorderLine
)
2491 rVal
<<= model::color::createXComplexColor(mpRightBorderLine
->getComplexColor());
2493 else if (maTempComplexColors
[size_t(SvxBoxItemLine::RIGHT
)].getType() != model::ColorType::Unused
)
2495 rVal
<<= model::color::createXComplexColor(maTempComplexColors
[size_t(SvxBoxItemLine::RIGHT
)]);
2499 case MID_BORDER_TOP_COLOR
:
2501 if (mpTopBorderLine
)
2503 rVal
<<= model::color::createXComplexColor(mpTopBorderLine
->getComplexColor());
2505 else if (maTempComplexColors
[size_t(SvxBoxItemLine::TOP
)].getType() != model::ColorType::Unused
)
2507 rVal
<<= model::color::createXComplexColor(maTempComplexColors
[size_t(SvxBoxItemLine::TOP
)]);
2513 // it doesn't make sense to return a value for these since it's
2514 // probably ambiguous
2519 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(nDist
) : nDist
);
2530 lcl_lineToSvxLine(const table::BorderLine
& rLine
, SvxBorderLine
& rSvxLine
, bool bConvert
, bool bGuessWidth
)
2532 rSvxLine
.SetColor( Color(ColorTransparency
, rLine
.Color
));
2535 rSvxLine
.GuessLinesWidths( rSvxLine
.GetBorderLineStyle(),
2536 bConvert
? o3tl::toTwips(rLine
.OuterLineWidth
, o3tl::Length::mm100
) : rLine
.OuterLineWidth
,
2537 bConvert
? o3tl::toTwips(rLine
.InnerLineWidth
, o3tl::Length::mm100
) : rLine
.InnerLineWidth
,
2538 bConvert
? o3tl::toTwips(rLine
.LineDistance
, o3tl::Length::mm100
) : rLine
.LineDistance
);
2541 bool bRet
= !rSvxLine
.isEmpty();
2548 bool SvxBoxItem::LineToSvxLine(const css::table::BorderLine
& rLine
, SvxBorderLine
& rSvxLine
, bool bConvert
)
2550 return lcl_lineToSvxLine(rLine
, rSvxLine
, bConvert
, true);
2554 SvxBoxItem::LineToSvxLine(const css::table::BorderLine2
& rLine
, SvxBorderLine
& rSvxLine
, bool bConvert
)
2556 SvxBorderLineStyle
const nStyle
=
2557 (rLine
.LineStyle
< 0 || BORDER_LINE_STYLE_MAX
< rLine
.LineStyle
)
2558 ? SvxBorderLineStyle::SOLID
// default
2559 : static_cast<SvxBorderLineStyle
>(rLine
.LineStyle
);
2561 rSvxLine
.SetBorderLineStyle( nStyle
);
2563 bool bGuessWidth
= true;
2564 if ( rLine
.LineWidth
)
2566 rSvxLine
.SetWidth( bConvert
? o3tl::toTwips(rLine
.LineWidth
, o3tl::Length::mm100
) : rLine
.LineWidth
);
2567 // fdo#46112: double does not necessarily mean symmetric
2568 // for backwards compatibility
2569 bGuessWidth
= (SvxBorderLineStyle::DOUBLE
== nStyle
|| SvxBorderLineStyle::DOUBLE_THIN
== nStyle
) &&
2570 (rLine
.InnerLineWidth
> 0) && (rLine
.OuterLineWidth
> 0);
2573 return lcl_lineToSvxLine(rLine
, rSvxLine
, bConvert
, bGuessWidth
);
2581 lcl_extractBorderLine(const uno::Any
& rAny
, table::BorderLine2
& rLine
)
2586 table::BorderLine aBorderLine
;
2587 if (rAny
>>= aBorderLine
)
2589 rLine
.Color
= aBorderLine
.Color
;
2590 rLine
.InnerLineWidth
= aBorderLine
.InnerLineWidth
;
2591 rLine
.OuterLineWidth
= aBorderLine
.OuterLineWidth
;
2592 rLine
.LineDistance
= aBorderLine
.LineDistance
;
2593 rLine
.LineStyle
= table::BorderLineStyle::SOLID
;
2600 template<typename Item
, typename Line
>
2602 lcl_setLine(const uno::Any
& rAny
, Item
& rItem
, Line nLine
, const bool bConvert
)
2605 table::BorderLine2 aBorderLine
;
2606 if (lcl_extractBorderLine(rAny
, aBorderLine
))
2608 SvxBorderLine aLine
;
2609 bool bSet
= SvxBoxItem::LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2610 rItem
.SetLine( bSet
? &aLine
: nullptr, nLine
);
2618 bool SvxBoxItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2620 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
2621 SvxBoxItemLine nLine
= SvxBoxItemLine::TOP
;
2622 bool bDistMember
= false;
2623 nMemberId
&= ~CONVERT_TWIPS
;
2628 uno::Sequence
< uno::Any
> aSeq
;
2629 if (( rVal
>>= aSeq
) && ( aSeq
.getLength() == 9 ))
2631 // 4 Borders and 5 distances
2632 const SvxBoxItemLine aBorders
[] = { SvxBoxItemLine::LEFT
, SvxBoxItemLine::RIGHT
, SvxBoxItemLine::BOTTOM
, SvxBoxItemLine::TOP
};
2633 for (size_t n(0); n
!= std::size(aBorders
); ++n
)
2635 if (!lcl_setLine(aSeq
[n
], *this, aBorders
[n
], bConvert
))
2637 tryMigrateComplexColor(aBorders
[n
]);
2640 // WTH are the borders and the distances saved in different order?
2641 SvxBoxItemLine
const nLines
[4] = { SvxBoxItemLine::TOP
, SvxBoxItemLine::BOTTOM
, SvxBoxItemLine::LEFT
, SvxBoxItemLine::RIGHT
};
2642 for ( sal_Int32 n
= 4; n
< 9; n
++ )
2644 sal_Int32 nDist
= 0;
2645 if ( aSeq
[n
] >>= nDist
)
2648 nDist
= o3tl::toTwips(nDist
, o3tl::Length::mm100
);
2650 SetAllDistances(nDist
);
2652 SetDistance( nDist
, nLines
[n
-5] );
2663 case LEFT_BORDER_DISTANCE
:
2667 case MID_LEFT_BORDER
:
2668 nLine
= SvxBoxItemLine::LEFT
;
2670 case RIGHT_BORDER_DISTANCE
:
2674 case MID_RIGHT_BORDER
:
2675 nLine
= SvxBoxItemLine::RIGHT
;
2677 case BOTTOM_BORDER_DISTANCE
:
2681 case MID_BOTTOM_BORDER
:
2682 nLine
= SvxBoxItemLine::BOTTOM
;
2684 case TOP_BORDER_DISTANCE
:
2688 case MID_TOP_BORDER
:
2689 nLine
= SvxBoxItemLine::TOP
;
2693 drawing::LineStyle eDrawingStyle
;
2694 rVal
>>= eDrawingStyle
;
2695 SvxBorderLineStyle eBorderStyle
= SvxBorderLineStyle::NONE
;
2696 switch ( eDrawingStyle
)
2699 case drawing::LineStyle_NONE
:
2701 case drawing::LineStyle_SOLID
:
2702 eBorderStyle
= SvxBorderLineStyle::SOLID
;
2704 case drawing::LineStyle_DASH
:
2705 eBorderStyle
= SvxBorderLineStyle::DASHED
;
2709 // Set the line style on all borders
2710 for( SvxBoxItemLine n
: o3tl::enumrange
<SvxBoxItemLine
>() )
2712 editeng::SvxBorderLine
* pLine
= const_cast< editeng::SvxBorderLine
* >( GetLine( n
) );
2714 pLine
->SetBorderLineStyle( eBorderStyle
);
2721 // Set the line width on all borders
2722 tools::Long
nWidth(0);
2725 nWidth
= o3tl::toTwips(nWidth
, o3tl::Length::mm100
);
2727 // Set the line Width on all borders
2728 for( SvxBoxItemLine n
: o3tl::enumrange
<SvxBoxItemLine
>() )
2730 editeng::SvxBorderLine
* pLine
= const_cast< editeng::SvxBorderLine
* >( GetLine( n
) );
2732 pLine
->SetWidth( nWidth
);
2736 case MID_BORDER_BOTTOM_COLOR
:
2738 if (mpBottomBorderLine
)
2739 return mpBottomBorderLine
->setComplexColorFromAny(rVal
);
2742 css::uno::Reference
<css::util::XComplexColor
> xComplexColor
;
2743 if (!(rVal
>>= xComplexColor
))
2746 if (xComplexColor
.is())
2747 maTempComplexColors
[size_t(SvxBoxItemLine::BOTTOM
)] = model::color::getFromXComplexColor(xComplexColor
);
2751 case MID_BORDER_LEFT_COLOR
:
2753 if (mpLeftBorderLine
)
2754 return mpLeftBorderLine
->setComplexColorFromAny(rVal
);
2757 css::uno::Reference
<css::util::XComplexColor
> xComplexColor
;
2758 if (!(rVal
>>= xComplexColor
))
2761 if (xComplexColor
.is())
2762 maTempComplexColors
[size_t(SvxBoxItemLine::LEFT
)] = model::color::getFromXComplexColor(xComplexColor
);
2766 case MID_BORDER_RIGHT_COLOR
:
2768 if (mpRightBorderLine
)
2769 return mpRightBorderLine
->setComplexColorFromAny(rVal
);
2772 css::uno::Reference
<css::util::XComplexColor
> xComplexColor
;
2773 if (!(rVal
>>= xComplexColor
))
2776 if (xComplexColor
.is())
2777 maTempComplexColors
[size_t(SvxBoxItemLine::RIGHT
)] = model::color::getFromXComplexColor(xComplexColor
);
2781 case MID_BORDER_TOP_COLOR
:
2783 if (mpTopBorderLine
)
2784 return mpTopBorderLine
->setComplexColorFromAny(rVal
);
2787 css::uno::Reference
<css::util::XComplexColor
> xComplexColor
;
2788 if (!(rVal
>>= xComplexColor
))
2791 if (xComplexColor
.is())
2792 maTempComplexColors
[size_t(SvxBoxItemLine::TOP
)] = model::color::getFromXComplexColor(xComplexColor
);
2798 if( bDistMember
|| nMemberId
== BORDER_DISTANCE
)
2800 sal_Int32 nDist
= 0;
2801 if(!(rVal
>>= nDist
))
2806 nDist
= o3tl::toTwips(nDist
, o3tl::Length::mm100
);
2807 if( nMemberId
== BORDER_DISTANCE
)
2808 SetAllDistances(nDist
);
2810 SetDistance( nDist
, nLine
);
2815 SvxBorderLine aLine
;
2816 if( !rVal
.hasValue() )
2819 table::BorderLine2 aBorderLine
;
2820 if( lcl_extractBorderLine(rVal
, aBorderLine
) )
2824 else if (rVal
.getValueTypeClass() == uno::TypeClass_SEQUENCE
)
2826 // serialization for basic macro recording
2827 uno::Reference
< script::XTypeConverter
> xConverter
2828 ( script::Converter::create(::comphelper::getProcessComponentContext()) );
2829 uno::Sequence
< uno::Any
> aSeq
;
2831 try { aNew
= xConverter
->convertTo( rVal
, cppu::UnoType
<uno::Sequence
< uno::Any
>>::get() ); }
2832 catch (const uno::Exception
&) {}
2835 if (aSeq
.getLength() >= 4 && aSeq
.getLength() <= 6)
2838 if ( aSeq
[0] >>= nVal
)
2839 aBorderLine
.Color
= nVal
;
2840 if ( aSeq
[1] >>= nVal
)
2841 aBorderLine
.InnerLineWidth
= static_cast<sal_Int16
>(nVal
);
2842 if ( aSeq
[2] >>= nVal
)
2843 aBorderLine
.OuterLineWidth
= static_cast<sal_Int16
>(nVal
);
2844 if ( aSeq
[3] >>= nVal
)
2845 aBorderLine
.LineDistance
= static_cast<sal_Int16
>(nVal
);
2846 if (aSeq
.getLength() >= 5) // fdo#40874 added fields
2848 if (aSeq
[4] >>= nVal
)
2850 aBorderLine
.LineStyle
= nVal
;
2852 if (aSeq
.getLength() >= 6)
2854 if (aSeq
[5] >>= nVal
)
2856 aBorderLine
.LineWidth
= nVal
;
2867 bool bSet
= SvxBoxItem::LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2868 SetLine(bSet
? &aLine
: nullptr, nLine
);
2869 tryMigrateComplexColor(nLine
);
2875 SvxBoxItem
* SvxBoxItem::Clone( SfxItemPool
* ) const
2877 return new SvxBoxItem( *this );
2880 bool SvxBoxItem::GetPresentation
2882 SfxItemPresentation ePres
,
2885 OUString
& rText
, const IntlWrapper
& rIntl
2888 OUString
cpDelimTmp(cpDelim
);
2891 case SfxItemPresentation::Nameless
:
2895 if (mpTopBorderLine
)
2897 rText
= mpTopBorderLine
->GetValueString( eCoreUnit
, ePresUnit
, &rIntl
) + cpDelimTmp
;
2899 if ( !(mpTopBorderLine
&& mpBottomBorderLine
&& mpLeftBorderLine
&& mpRightBorderLine
&&
2900 *mpTopBorderLine
== *mpBottomBorderLine
&&
2901 *mpTopBorderLine
== *mpLeftBorderLine
&&
2902 *mpTopBorderLine
== *mpRightBorderLine
))
2904 if (mpBottomBorderLine
)
2906 rText
+= mpBottomBorderLine
->GetValueString( eCoreUnit
, ePresUnit
, &rIntl
) + cpDelimTmp
;
2908 if (mpLeftBorderLine
)
2910 rText
+= mpLeftBorderLine
->GetValueString( eCoreUnit
, ePresUnit
, &rIntl
) + cpDelimTmp
;
2912 if (mpRightBorderLine
)
2914 rText
+= mpRightBorderLine
->GetValueString( eCoreUnit
, ePresUnit
, &rIntl
) + cpDelimTmp
;
2917 rText
+= GetMetricText( static_cast<tools::Long
>(mnTopDistance
), eCoreUnit
, ePresUnit
, &rIntl
);
2918 if (mnTopDistance
!= mnBottomDistance
||
2919 mnTopDistance
!= mnLeftDistance
||
2920 mnTopDistance
!= mnRightDistance
)
2922 rText
+= cpDelimTmp
+
2923 GetMetricText( tools::Long(mnBottomDistance
), eCoreUnit
, ePresUnit
, &rIntl
) +
2925 GetMetricText( tools::Long(mnLeftDistance
), eCoreUnit
, ePresUnit
, &rIntl
) +
2927 GetMetricText( tools::Long(mnRightDistance
), eCoreUnit
, ePresUnit
, &rIntl
);
2931 case SfxItemPresentation::Complete
:
2933 if (!(mpTopBorderLine
|| mpBottomBorderLine
|| mpLeftBorderLine
|| mpRightBorderLine
))
2935 rText
= EditResId(RID_SVXITEMS_BORDER_NONE
) + cpDelimTmp
;
2939 rText
= EditResId(RID_SVXITEMS_BORDER_COMPLETE
);
2940 if (mpTopBorderLine
&& mpBottomBorderLine
&& mpLeftBorderLine
&& mpRightBorderLine
&&
2941 *mpTopBorderLine
== *mpBottomBorderLine
&&
2942 *mpTopBorderLine
== *mpLeftBorderLine
&&
2943 *mpTopBorderLine
== *mpRightBorderLine
)
2945 rText
+= mpTopBorderLine
->GetValueString( eCoreUnit
, ePresUnit
, &rIntl
, true ) + cpDelimTmp
;
2949 if (mpTopBorderLine
)
2951 rText
+= EditResId(RID_SVXITEMS_BORDER_TOP
) +
2952 mpTopBorderLine
->GetValueString( eCoreUnit
, ePresUnit
, &rIntl
, true ) +
2955 if (mpBottomBorderLine
)
2957 rText
+= EditResId(RID_SVXITEMS_BORDER_BOTTOM
) +
2958 mpBottomBorderLine
->GetValueString( eCoreUnit
, ePresUnit
, &rIntl
, true ) +
2961 if (mpLeftBorderLine
)
2963 rText
+= EditResId(RID_SVXITEMS_BORDER_LEFT
) +
2964 mpLeftBorderLine
->GetValueString( eCoreUnit
, ePresUnit
, &rIntl
, true ) +
2967 if (mpRightBorderLine
)
2969 rText
+= EditResId(RID_SVXITEMS_BORDER_RIGHT
) +
2970 mpRightBorderLine
->GetValueString( eCoreUnit
, ePresUnit
, &rIntl
, true ) +
2976 rText
+= EditResId(RID_SVXITEMS_BORDER_DISTANCE
);
2977 if (mnTopDistance
== mnBottomDistance
&&
2978 mnTopDistance
== mnLeftDistance
&&
2979 mnTopDistance
== mnRightDistance
)
2981 rText
+= GetMetricText(tools::Long(mnTopDistance
), eCoreUnit
, ePresUnit
, &rIntl
) +
2982 " " + EditResId(GetMetricId(ePresUnit
));
2986 rText
+= EditResId(RID_SVXITEMS_BORDER_TOP
) +
2987 GetMetricText(tools::Long(mnTopDistance
), eCoreUnit
, ePresUnit
, &rIntl
) +
2988 " " + EditResId(GetMetricId(ePresUnit
)) +
2990 EditResId(RID_SVXITEMS_BORDER_BOTTOM
) +
2991 GetMetricText(tools::Long(mnBottomDistance
), eCoreUnit
, ePresUnit
, &rIntl
) +
2992 " " + EditResId(GetMetricId(ePresUnit
)) +
2994 EditResId(RID_SVXITEMS_BORDER_LEFT
) +
2995 GetMetricText(tools::Long(mnLeftDistance
), eCoreUnit
, ePresUnit
, &rIntl
) +
2996 " " + EditResId(GetMetricId(ePresUnit
)) +
2998 EditResId(RID_SVXITEMS_BORDER_RIGHT
) +
2999 GetMetricText(tools::Long(mnRightDistance
), eCoreUnit
, ePresUnit
, &rIntl
) +
3000 " " + EditResId(GetMetricId(ePresUnit
));
3004 default: ; // prevent warning
3010 void SvxBoxItem::ScaleMetrics( tools::Long nMult
, tools::Long nDiv
)
3012 if (mpTopBorderLine
)
3013 mpTopBorderLine
->ScaleMetrics( nMult
, nDiv
);
3014 if (mpBottomBorderLine
)
3015 mpBottomBorderLine
->ScaleMetrics( nMult
, nDiv
);
3016 if (mpLeftBorderLine
)
3017 mpLeftBorderLine
->ScaleMetrics( nMult
, nDiv
);
3018 if (mpRightBorderLine
)
3019 mpRightBorderLine
->ScaleMetrics( nMult
, nDiv
);
3021 mnTopDistance
= static_cast<sal_Int16
>(BigInt::Scale(mnTopDistance
, nMult
, nDiv
));
3022 mnBottomDistance
= static_cast<sal_Int16
>(BigInt::Scale(mnBottomDistance
, nMult
, nDiv
));
3023 mnLeftDistance
= static_cast<sal_Int16
>(BigInt::Scale(mnLeftDistance
, nMult
, nDiv
));
3024 mnRightDistance
= static_cast<sal_Int16
>(BigInt::Scale(mnRightDistance
, nMult
, nDiv
));
3028 bool SvxBoxItem::HasMetrics() const
3034 const SvxBorderLine
*SvxBoxItem::GetLine( SvxBoxItemLine nLine
) const
3036 const SvxBorderLine
*pRet
= nullptr;
3040 case SvxBoxItemLine::TOP
:
3041 pRet
= mpTopBorderLine
.get();
3043 case SvxBoxItemLine::BOTTOM
:
3044 pRet
= mpBottomBorderLine
.get();
3046 case SvxBoxItemLine::LEFT
:
3047 pRet
= mpLeftBorderLine
.get();
3049 case SvxBoxItemLine::RIGHT
:
3050 pRet
= mpRightBorderLine
.get();
3053 OSL_FAIL( "wrong line" );
3061 void SvxBoxItem::SetLine( const SvxBorderLine
* pNew
, SvxBoxItemLine nLine
)
3063 std::unique_ptr
<SvxBorderLine
> pTmp( pNew
? new SvxBorderLine( *pNew
) : nullptr );
3067 case SvxBoxItemLine::TOP
:
3068 mpTopBorderLine
= std::move(pTmp
);
3070 case SvxBoxItemLine::BOTTOM
:
3071 mpBottomBorderLine
= std::move(pTmp
);
3073 case SvxBoxItemLine::LEFT
:
3074 mpLeftBorderLine
= std::move(pTmp
);
3076 case SvxBoxItemLine::RIGHT
:
3077 mpRightBorderLine
= std::move(pTmp
);
3080 OSL_FAIL( "wrong line" );
3085 sal_uInt16
SvxBoxItem::GetSmallestDistance() const
3087 // The smallest distance that is not 0 will be returned.
3088 sal_uInt16 nDist
= mnTopDistance
;
3089 if (mnBottomDistance
&& (!nDist
|| mnBottomDistance
< nDist
))
3090 nDist
= mnBottomDistance
;
3091 if (mnLeftDistance
&& (!nDist
|| mnLeftDistance
< nDist
))
3092 nDist
= mnLeftDistance
;
3093 if (mnRightDistance
&& (!nDist
|| mnRightDistance
< nDist
))
3094 nDist
= mnRightDistance
;
3100 sal_Int16
SvxBoxItem::GetDistance( SvxBoxItemLine nLine
, bool bAllowNegative
) const
3102 sal_Int16 nDist
= 0;
3105 case SvxBoxItemLine::TOP
:
3106 nDist
= mnTopDistance
;
3108 case SvxBoxItemLine::BOTTOM
:
3109 nDist
= mnBottomDistance
;
3111 case SvxBoxItemLine::LEFT
:
3112 nDist
= mnLeftDistance
;
3114 case SvxBoxItemLine::RIGHT
:
3115 nDist
= mnRightDistance
;
3118 OSL_FAIL( "wrong line" );
3121 if (!bAllowNegative
&& nDist
< 0)
3129 void SvxBoxItem::SetDistance( sal_Int16 nNew
, SvxBoxItemLine nLine
)
3133 case SvxBoxItemLine::TOP
:
3134 mnTopDistance
= nNew
;
3136 case SvxBoxItemLine::BOTTOM
:
3137 mnBottomDistance
= nNew
;
3139 case SvxBoxItemLine::LEFT
:
3140 mnLeftDistance
= nNew
;
3142 case SvxBoxItemLine::RIGHT
:
3143 mnRightDistance
= nNew
;
3146 OSL_FAIL( "wrong line" );
3150 sal_uInt16
SvxBoxItem::CalcLineWidth( SvxBoxItemLine nLine
) const
3152 SvxBorderLine
* pTmp
= nullptr;
3153 sal_uInt16 nWidth
= 0;
3156 case SvxBoxItemLine::TOP
:
3157 pTmp
= mpTopBorderLine
.get();
3159 case SvxBoxItemLine::BOTTOM
:
3160 pTmp
= mpBottomBorderLine
.get();
3162 case SvxBoxItemLine::LEFT
:
3163 pTmp
= mpLeftBorderLine
.get();
3165 case SvxBoxItemLine::RIGHT
:
3166 pTmp
= mpRightBorderLine
.get();
3169 OSL_FAIL( "wrong line" );
3173 nWidth
= pTmp
->GetScaledWidth();
3178 sal_Int16
SvxBoxItem::CalcLineSpace( SvxBoxItemLine nLine
, bool bEvenIfNoLine
, bool bAllowNegative
) const
3180 SvxBorderLine
* pTmp
= nullptr;
3181 sal_Int16 nDist
= 0;
3184 case SvxBoxItemLine::TOP
:
3185 pTmp
= mpTopBorderLine
.get();
3186 nDist
= mnTopDistance
;
3188 case SvxBoxItemLine::BOTTOM
:
3189 pTmp
= mpBottomBorderLine
.get();
3190 nDist
= mnBottomDistance
;
3192 case SvxBoxItemLine::LEFT
:
3193 pTmp
= mpLeftBorderLine
.get();
3194 nDist
= mnLeftDistance
;
3196 case SvxBoxItemLine::RIGHT
:
3197 pTmp
= mpRightBorderLine
.get();
3198 nDist
= mnRightDistance
;
3201 OSL_FAIL( "wrong line" );
3206 nDist
= nDist
+ pTmp
->GetScaledWidth();
3208 else if( !bEvenIfNoLine
)
3211 if (!bAllowNegative
&& nDist
< 0)
3219 void SvxBoxItem::tryMigrateComplexColor(SvxBoxItemLine eLine
)
3221 if (!GetLine(eLine
))
3224 auto nIndex
= size_t(eLine
);
3226 if (maTempComplexColors
[nIndex
].getType() == model::ColorType::Unused
)
3231 case SvxBoxItemLine::TOP
:
3232 mpTopBorderLine
->setComplexColor(maTempComplexColors
[nIndex
]);
3234 case SvxBoxItemLine::BOTTOM
:
3235 mpBottomBorderLine
->setComplexColor(maTempComplexColors
[nIndex
]);
3237 case SvxBoxItemLine::LEFT
:
3238 mpLeftBorderLine
->setComplexColor(maTempComplexColors
[nIndex
]);
3240 case SvxBoxItemLine::RIGHT
:
3241 mpRightBorderLine
->setComplexColor(maTempComplexColors
[nIndex
]);
3245 maTempComplexColors
[nIndex
] = model::ComplexColor();
3248 bool SvxBoxItem::HasBorder( bool bTreatPaddingAsBorder
) const
3250 return CalcLineSpace( SvxBoxItemLine::BOTTOM
, bTreatPaddingAsBorder
)
3251 || CalcLineSpace( SvxBoxItemLine::RIGHT
, bTreatPaddingAsBorder
)
3252 || CalcLineSpace( SvxBoxItemLine::TOP
, bTreatPaddingAsBorder
)
3253 || CalcLineSpace( SvxBoxItemLine::LEFT
, bTreatPaddingAsBorder
);
3256 // class SvxBoxInfoItem --------------------------------------------------
3258 SvxBoxInfoItem::SvxBoxInfoItem(const sal_uInt16 nId
)
3261 , mbMinimumDistance(false)
3267 SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem
& rCopy
)
3268 : SfxPoolItem(rCopy
)
3269 , mpHorizontalLine(rCopy
.mpHorizontalLine
? new SvxBorderLine(*rCopy
.mpHorizontalLine
) : nullptr)
3270 , mpVerticalLine(rCopy
.mpVerticalLine
? new SvxBorderLine(*rCopy
.mpVerticalLine
) : nullptr)
3271 , mbEnableHorizontalLine(rCopy
.mbEnableHorizontalLine
)
3272 , mbEnableVerticalLine(rCopy
.mbEnableVerticalLine
)
3273 , mbDistance(rCopy
.mbDistance
)
3274 , mbMinimumDistance (rCopy
.mbMinimumDistance
)
3275 , mnValidFlags(rCopy
.mnValidFlags
)
3276 , mnDefaultMinimumDistance(rCopy
.mnDefaultMinimumDistance
)
3280 SvxBoxInfoItem::~SvxBoxInfoItem()
3285 boost::property_tree::ptree
SvxBoxInfoItem::dumpAsJSON() const
3287 boost::property_tree::ptree aTree
;
3289 boost::property_tree::ptree aState
;
3290 aState
.put("vertical", GetVert() && !GetVert()->isEmpty());
3291 aState
.put("horizontal", GetHori() && !GetHori()->isEmpty());
3293 aTree
.push_back(std::make_pair("state", aState
));
3294 aTree
.put("commandName", ".uno:BorderInner");
3300 bool SvxBoxInfoItem::operator==( const SfxPoolItem
& rAttr
) const
3302 assert(SfxPoolItem::operator==(rAttr
));
3304 const SvxBoxInfoItem
& rBoxInfo
= static_cast<const SvxBoxInfoItem
&>(rAttr
);
3306 return (mbEnableHorizontalLine
== rBoxInfo
.mbEnableHorizontalLine
3307 && mbEnableVerticalLine
== rBoxInfo
.mbEnableVerticalLine
3308 && mbDistance
== rBoxInfo
.mbDistance
3309 && mbMinimumDistance
== rBoxInfo
.mbMinimumDistance
3310 && mnValidFlags
== rBoxInfo
.mnValidFlags
3311 && mnDefaultMinimumDistance
== rBoxInfo
.mnDefaultMinimumDistance
3312 && CompareBorderLine(mpHorizontalLine
, rBoxInfo
.GetHori())
3313 && CompareBorderLine(mpVerticalLine
, rBoxInfo
.GetVert()));
3317 void SvxBoxInfoItem::SetLine( const SvxBorderLine
* pNew
, SvxBoxInfoItemLine nLine
)
3319 std::unique_ptr
<SvxBorderLine
> pCopy(pNew
? new SvxBorderLine(*pNew
) : nullptr);
3321 if ( SvxBoxInfoItemLine::HORI
== nLine
)
3323 mpHorizontalLine
= std::move(pCopy
);
3325 else if ( SvxBoxInfoItemLine::VERT
== nLine
)
3327 mpVerticalLine
= std::move(pCopy
);
3331 OSL_FAIL( "wrong line" );
3335 SvxBoxInfoItem
* SvxBoxInfoItem::Clone( SfxItemPool
* ) const
3337 return new SvxBoxInfoItem( *this );
3340 bool SvxBoxInfoItem::GetPresentation
3342 SfxItemPresentation
/*ePres*/,
3343 MapUnit
/*eCoreUnit*/,
3344 MapUnit
/*ePresUnit*/,
3345 OUString
& rText
, const IntlWrapper
&
3353 void SvxBoxInfoItem::ScaleMetrics( tools::Long nMult
, tools::Long nDiv
)
3355 if (mpHorizontalLine
)
3356 mpHorizontalLine
->ScaleMetrics(nMult
, nDiv
);
3358 mpVerticalLine
->ScaleMetrics(nMult
, nDiv
);
3359 mnDefaultMinimumDistance
= sal_uInt16(BigInt::Scale(mnDefaultMinimumDistance
, nMult
, nDiv
));
3363 bool SvxBoxInfoItem::HasMetrics() const
3369 void SvxBoxInfoItem::ResetFlags()
3371 mnValidFlags
= static_cast<SvxBoxInfoItemValidFlags
>(0x7F); // all valid except Disable
3374 bool SvxBoxInfoItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
3376 bool bConvert
= 0 != (nMemberId
& CONVERT_TWIPS
);
3377 table::BorderLine2 aRetLine
;
3379 bool bIntMember
= false;
3380 nMemberId
&= ~CONVERT_TWIPS
;
3385 // 2 BorderLines, flags, valid flags and distance
3392 css::uno::Sequence
< css::uno::Any
> aSeq
{
3393 uno::Any(SvxBoxItem::SvxLineToLine(mpHorizontalLine
.get(), bConvert
)),
3394 uno::Any(SvxBoxItem::SvxLineToLine(mpVerticalLine
.get(), bConvert
)),
3396 uno::Any(static_cast<sal_Int16
>(mnValidFlags
)),
3397 uno::Any(static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(GetDefDist()) : GetDefDist()))
3403 case MID_HORIZONTAL
:
3404 aRetLine
= SvxBoxItem::SvxLineToLine(mpHorizontalLine
.get(), bConvert
);
3407 aRetLine
= SvxBoxItem::SvxLineToLine(mpVerticalLine
.get(), bConvert
);
3419 case MID_VALIDFLAGS
:
3421 rVal
<<= static_cast<sal_Int16
>(mnValidFlags
);
3425 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(GetDefDist()) : GetDefDist());
3427 default: OSL_FAIL("Wrong MemberId!"); return false;
3437 bool SvxBoxInfoItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
3439 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
3440 nMemberId
&= ~CONVERT_TWIPS
;
3446 css::uno::Sequence
< css::uno::Any
> aSeq
;
3447 if (( rVal
>>= aSeq
) && ( aSeq
.getLength() == 5 ))
3449 // 2 BorderLines, flags, valid flags and distance
3450 if (!lcl_setLine(aSeq
[0], *this, SvxBoxInfoItemLine::HORI
, bConvert
))
3452 if (!lcl_setLine(aSeq
[1], *this, SvxBoxInfoItemLine::VERT
, bConvert
))
3455 sal_Int16
nFlags( 0 );
3456 sal_Int32
nVal( 0 );
3457 if ( aSeq
[2] >>= nFlags
)
3459 SetTable ( ( nFlags
& 0x01 ) != 0 );
3460 SetDist ( ( nFlags
& 0x02 ) != 0 );
3461 SetMinDist( ( nFlags
& 0x04 ) != 0 );
3465 if ( aSeq
[3] >>= nFlags
)
3466 mnValidFlags
= static_cast<SvxBoxInfoItemValidFlags
>(nFlags
);
3469 if (( aSeq
[4] >>= nVal
) && ( nVal
>= 0 ))
3472 nVal
= o3tl::toTwips(nVal
, o3tl::Length::mm100
);
3479 case MID_HORIZONTAL
:
3482 if( !rVal
.hasValue() )
3485 table::BorderLine2 aBorderLine
;
3486 if( lcl_extractBorderLine(rVal
, aBorderLine
) )
3490 else if (rVal
.getValueTypeClass() == uno::TypeClass_SEQUENCE
)
3492 // serialization for basic macro recording
3493 uno::Reference
< script::XTypeConverter
> xConverter( script::Converter::create(::comphelper::getProcessComponentContext()) );
3495 uno::Sequence
< uno::Any
> aSeq
;
3496 try { aNew
= xConverter
->convertTo( rVal
, cppu::UnoType
<uno::Sequence
< uno::Any
>>::get() ); }
3497 catch (const uno::Exception
&) {}
3499 if ((aNew
>>= aSeq
) &&
3500 aSeq
.getLength() >= 4 && aSeq
.getLength() <= 6)
3503 if ( aSeq
[0] >>= nVal
)
3504 aBorderLine
.Color
= nVal
;
3505 if ( aSeq
[1] >>= nVal
)
3506 aBorderLine
.InnerLineWidth
= static_cast<sal_Int16
>(nVal
);
3507 if ( aSeq
[2] >>= nVal
)
3508 aBorderLine
.OuterLineWidth
= static_cast<sal_Int16
>(nVal
);
3509 if ( aSeq
[3] >>= nVal
)
3510 aBorderLine
.LineDistance
= static_cast<sal_Int16
>(nVal
);
3511 if (aSeq
.getLength() >= 5) // fdo#40874 added fields
3513 if (aSeq
[4] >>= nVal
)
3515 aBorderLine
.LineStyle
= nVal
;
3517 if (aSeq
.getLength() >= 6)
3519 if (aSeq
[5] >>= nVal
)
3521 aBorderLine
.LineWidth
= nVal
;
3529 else if (rVal
.getValueType() == cppu::UnoType
<css::uno::Sequence
< sal_Int16
>>::get() )
3531 // serialization for basic macro recording
3532 css::uno::Sequence
< sal_Int16
> aSeq
;
3534 if (aSeq
.getLength() >= 4 && aSeq
.getLength() <= 6)
3536 aBorderLine
.Color
= aSeq
[0];
3537 aBorderLine
.InnerLineWidth
= aSeq
[1];
3538 aBorderLine
.OuterLineWidth
= aSeq
[2];
3539 aBorderLine
.LineDistance
= aSeq
[3];
3540 if (aSeq
.getLength() >= 5) // fdo#40874 added fields
3542 aBorderLine
.LineStyle
= aSeq
[4];
3543 if (aSeq
.getLength() >= 6)
3545 aBorderLine
.LineWidth
= aSeq
[5];
3555 SvxBorderLine aLine
;
3556 bool bSet
= SvxBoxItem::LineToSvxLine(aBorderLine
, aLine
, bConvert
);
3558 SetLine( &aLine
, nMemberId
== MID_HORIZONTAL
? SvxBoxInfoItemLine::HORI
: SvxBoxInfoItemLine::VERT
);
3563 sal_Int16 nFlags
= sal_Int16();
3564 bRet
= (rVal
>>= nFlags
);
3567 SetTable ( ( nFlags
& 0x01 ) != 0 );
3568 SetDist ( ( nFlags
& 0x02 ) != 0 );
3569 SetMinDist( ( nFlags
& 0x04 ) != 0 );
3574 case MID_VALIDFLAGS
:
3576 sal_Int16 nFlags
= sal_Int16();
3577 bRet
= (rVal
>>= nFlags
);
3579 mnValidFlags
= static_cast<SvxBoxInfoItemValidFlags
>(nFlags
);
3585 bRet
= (rVal
>>= nVal
);
3586 if ( bRet
&& nVal
>=0 )
3589 nVal
= o3tl::toTwips(nVal
, o3tl::Length::mm100
);
3590 SetDefDist( static_cast<sal_uInt16
>(nVal
) );
3594 default: OSL_FAIL("Wrong MemberId!"); return false;
3604 void BorderDistanceFromWord(bool bFromEdge
, sal_Int32
& nMargin
, sal_Int32
& nBorderDistance
,
3605 sal_Int32 nBorderWidth
)
3607 // See https://wiki.openoffice.org/wiki/Writer/MSInteroperability/PageBorder
3609 sal_Int32 nNewMargin
= nMargin
;
3610 sal_Int32 nNewBorderDistance
= nBorderDistance
;
3614 nNewMargin
= nBorderDistance
;
3615 nNewBorderDistance
= nMargin
- nBorderDistance
- nBorderWidth
;
3619 nNewMargin
-= nBorderDistance
+ nBorderWidth
;
3622 // Ensure correct distance from page edge to text in cases not supported by us:
3623 // when border is outside entire page area (!bFromEdge && BorderDistance > Margin),
3624 // and when border is inside page body area (bFromEdge && BorderDistance > Margin)
3628 nNewBorderDistance
= std::max
<sal_Int32
>(nMargin
- nBorderWidth
, 0);
3630 else if (nNewBorderDistance
< 0)
3632 nNewMargin
= nMargin
;
3635 nMargin
= nNewMargin
;
3636 nBorderDistance
= nNewBorderDistance
;
3639 // Heuristics to decide if we need to use "from edge" offset of borders
3641 // There are two cases when we can safely use "from text" or "from edge" offset without distorting
3642 // border position (modulo rounding errors):
3643 // 1. When distance of all borders from text is no greater than 31 pt, we use "from text"
3644 // 2. Otherwise, if distance of all borders from edge is no greater than 31 pt, we use "from edge"
3645 // In all other cases, the position of borders would be distorted on export, because Word doesn't
3646 // support the offset of >31 pts (https://msdn.microsoft.com/en-us/library/ff533820), and we need
3647 // to decide which type of offset would provide less wrong result (i.e., the result would look
3648 // closer to original). Here, we just check sum of distances from text to borders, and if it is
3649 // less than sum of distances from borders to edges. The alternative would be to compare total areas
3650 // between text-and-borders and between borders-and-edges (taking into account different lengths of
3651 // borders, and visual impact of that).
3652 void BorderDistancesToWord(const SvxBoxItem
& rBox
, const WordPageMargins
& rMargins
,
3653 WordBorderDistances
& rDistances
)
3655 // Use signed sal_Int32 that can hold sal_uInt16, to prevent overflow at subtraction below
3656 const sal_Int32 nT
= rBox
.GetDistance(SvxBoxItemLine::TOP
, /*bAllowNegative=*/true);
3657 const sal_Int32 nL
= rBox
.GetDistance(SvxBoxItemLine::LEFT
, /*bAllowNegative=*/true);
3658 const sal_Int32 nB
= rBox
.GetDistance(SvxBoxItemLine::BOTTOM
, /*bAllowNegative=*/true);
3659 const sal_Int32 nR
= rBox
.GetDistance(SvxBoxItemLine::RIGHT
, /*bAllowNegative=*/true);
3661 // Only take into account existing borders
3662 const SvxBorderLine
* pLnT
= rBox
.GetLine(SvxBoxItemLine::TOP
);
3663 const SvxBorderLine
* pLnL
= rBox
.GetLine(SvxBoxItemLine::LEFT
);
3664 const SvxBorderLine
* pLnB
= rBox
.GetLine(SvxBoxItemLine::BOTTOM
);
3665 const SvxBorderLine
* pLnR
= rBox
.GetLine(SvxBoxItemLine::RIGHT
);
3667 // We need to take border widths into account
3668 const tools::Long nWidthT
= pLnT
? pLnT
->GetScaledWidth() : 0;
3669 const tools::Long nWidthL
= pLnL
? pLnL
->GetScaledWidth() : 0;
3670 const tools::Long nWidthB
= pLnB
? pLnB
->GetScaledWidth() : 0;
3671 const tools::Long nWidthR
= pLnR
? pLnR
->GetScaledWidth() : 0;
3673 // Resulting distances from text to borders
3674 const sal_Int32 nT2BT
= pLnT
? nT
: 0;
3675 const sal_Int32 nT2BL
= pLnL
? nL
: 0;
3676 const sal_Int32 nT2BB
= pLnB
? nB
: 0;
3677 const sal_Int32 nT2BR
= pLnR
? nR
: 0;
3679 // Resulting distances from edge to borders
3680 const sal_Int32 nE2BT
= pLnT
? std::max
<sal_Int32
>(rMargins
.nTop
- nT
- nWidthT
, 0) : 0;
3681 const sal_Int32 nE2BL
= pLnL
? std::max
<sal_Int32
>(rMargins
.nLeft
- nL
- nWidthL
, 0) : 0;
3682 const sal_Int32 nE2BB
= pLnB
? std::max
<sal_Int32
>(rMargins
.nBottom
- nB
- nWidthB
, 0) : 0;
3683 const sal_Int32 nE2BR
= pLnR
? std::max
<sal_Int32
>(rMargins
.nRight
- nR
- nWidthR
, 0) : 0;
3685 const sal_Int32 n32pt
= 32 * 20;
3686 // 1. If all borders are in range of 31 pts from text
3687 if (nT2BT
>= 0 && nT2BT
< n32pt
&& nT2BL
>= 0 && nT2BL
< n32pt
&& nT2BB
>= 0 && nT2BB
< n32pt
&& nT2BR
>= 0 && nT2BR
< n32pt
)
3689 rDistances
.bFromEdge
= false;
3693 // 2. If all borders are in range of 31 pts from edge
3694 if (nE2BT
< n32pt
&& nE2BL
< n32pt
&& nE2BB
< n32pt
&& nE2BR
< n32pt
)
3696 rDistances
.bFromEdge
= true;
3700 // Let's try to guess which would be the best approximation
3701 rDistances
.bFromEdge
=
3702 (nT2BT
+ nT2BL
+ nT2BB
+ nT2BR
) > (nE2BT
+ nE2BL
+ nE2BB
+ nE2BR
);
3706 if (rDistances
.bFromEdge
)
3708 rDistances
.nTop
= sal::static_int_cast
<sal_uInt16
>(nE2BT
);
3709 rDistances
.nLeft
= sal::static_int_cast
<sal_uInt16
>(nE2BL
);
3710 rDistances
.nBottom
= sal::static_int_cast
<sal_uInt16
>(nE2BB
);
3711 rDistances
.nRight
= sal::static_int_cast
<sal_uInt16
>(nE2BR
);
3715 rDistances
.nTop
= sal::static_int_cast
<sal_uInt16
>(nT2BT
);
3716 rDistances
.nLeft
= sal::static_int_cast
<sal_uInt16
>(nT2BL
);
3717 rDistances
.nBottom
= sal::static_int_cast
<sal_uInt16
>(nT2BB
);
3718 rDistances
.nRight
= sal::static_int_cast
<sal_uInt16
>(nT2BR
);
3724 // class SvxFormatBreakItem -------------------------------------------------
3726 bool SvxFormatBreakItem::operator==( const SfxPoolItem
& rAttr
) const
3728 assert(SfxPoolItem::operator==(rAttr
));
3730 return GetValue() == static_cast<const SvxFormatBreakItem
&>( rAttr
).GetValue();
3734 bool SvxFormatBreakItem::GetPresentation
3736 SfxItemPresentation
/*ePres*/,
3737 MapUnit
/*eCoreUnit*/,
3738 MapUnit
/*ePresUnit*/,
3739 OUString
& rText
, const IntlWrapper
&
3742 rText
= GetValueTextByPos( GetEnumValue() );
3746 OUString
SvxFormatBreakItem::GetValueTextByPos( sal_uInt16 nPos
)
3748 static TranslateId RID_SVXITEMS_BREAK
[] =
3750 RID_SVXITEMS_BREAK_NONE
,
3751 RID_SVXITEMS_BREAK_COLUMN_BEFORE
,
3752 RID_SVXITEMS_BREAK_COLUMN_AFTER
,
3753 RID_SVXITEMS_BREAK_COLUMN_BOTH
,
3754 RID_SVXITEMS_BREAK_PAGE_BEFORE
,
3755 RID_SVXITEMS_BREAK_PAGE_AFTER
,
3756 RID_SVXITEMS_BREAK_PAGE_BOTH
3758 static_assert(std::size(RID_SVXITEMS_BREAK
) == size_t(SvxBreak::End
), "unexpected size");
3759 assert(nPos
< sal_uInt16(SvxBreak::End
) && "enum overflow!");
3760 return EditResId(RID_SVXITEMS_BREAK
[nPos
]);
3763 bool SvxFormatBreakItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
3765 style::BreakType eBreak
= style::BreakType_NONE
;
3766 switch ( GetBreak() )
3768 case SvxBreak::ColumnBefore
: eBreak
= style::BreakType_COLUMN_BEFORE
; break;
3769 case SvxBreak::ColumnAfter
: eBreak
= style::BreakType_COLUMN_AFTER
; break;
3770 case SvxBreak::ColumnBoth
: eBreak
= style::BreakType_COLUMN_BOTH
; break;
3771 case SvxBreak::PageBefore
: eBreak
= style::BreakType_PAGE_BEFORE
; break;
3772 case SvxBreak::PageAfter
: eBreak
= style::BreakType_PAGE_AFTER
; break;
3773 case SvxBreak::PageBoth
: eBreak
= style::BreakType_PAGE_BOTH
; break;
3774 default: ; // prevent warning
3780 bool SvxFormatBreakItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
3782 style::BreakType nBreak
;
3784 if(!(rVal
>>= nBreak
))
3786 sal_Int32 nValue
= 0;
3787 if(!(rVal
>>= nValue
))
3790 nBreak
= static_cast<style::BreakType
>(nValue
);
3793 SvxBreak eBreak
= SvxBreak::NONE
;
3796 case style::BreakType_COLUMN_BEFORE
: eBreak
= SvxBreak::ColumnBefore
; break;
3797 case style::BreakType_COLUMN_AFTER
: eBreak
= SvxBreak::ColumnAfter
; break;
3798 case style::BreakType_COLUMN_BOTH
: eBreak
= SvxBreak::ColumnBoth
; break;
3799 case style::BreakType_PAGE_BEFORE
: eBreak
= SvxBreak::PageBefore
; break;
3800 case style::BreakType_PAGE_AFTER
: eBreak
= SvxBreak::PageAfter
; break;
3801 case style::BreakType_PAGE_BOTH
: eBreak
= SvxBreak::PageBoth
; break;
3802 default: ; // prevent warning
3809 SvxFormatBreakItem
* SvxFormatBreakItem::Clone( SfxItemPool
* ) const
3811 return new SvxFormatBreakItem( *this );
3814 sal_uInt16
SvxFormatBreakItem::GetValueCount() const
3816 return sal_uInt16(SvxBreak::End
); // SvxBreak::PageBoth + 1
3819 SvxFormatKeepItem
* SvxFormatKeepItem::Clone( SfxItemPool
* ) const
3821 return new SvxFormatKeepItem( *this );
3824 bool SvxFormatKeepItem::GetPresentation
3826 SfxItemPresentation
/*ePres*/,
3827 MapUnit
/*eCoreUnit*/,
3828 MapUnit
/*ePresUnit*/,
3829 OUString
& rText
, const IntlWrapper
&
3832 TranslateId pId
= RID_SVXITEMS_FMTKEEP_FALSE
;
3835 pId
= RID_SVXITEMS_FMTKEEP_TRUE
;
3836 rText
= EditResId(pId
);
3840 void SvxFormatKeepItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
3842 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxFormatKeepItem"));
3844 SfxBoolItem::dumpAsXml(pWriter
);
3846 (void)xmlTextWriterEndElement(pWriter
);
3849 SvxLineItem::SvxLineItem( const sal_uInt16 nId
) :
3855 SvxLineItem::SvxLineItem( const SvxLineItem
& rCpy
) :
3856 SfxPoolItem ( rCpy
),
3857 pLine(rCpy
.pLine
? new SvxBorderLine( *rCpy
.pLine
) : nullptr)
3862 SvxLineItem::~SvxLineItem()
3867 bool SvxLineItem::operator==( const SfxPoolItem
& rAttr
) const
3869 assert(SfxPoolItem::operator==(rAttr
));
3871 return CompareBorderLine(pLine
, static_cast<const SvxLineItem
&>(rAttr
).GetLine());
3874 SvxLineItem
* SvxLineItem::Clone( SfxItemPool
* ) const
3876 return new SvxLineItem( *this );
3879 bool SvxLineItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemId
) const
3881 bool bConvert
= 0!=(nMemId
&CONVERT_TWIPS
);
3882 nMemId
&= ~CONVERT_TWIPS
;
3885 rVal
<<= SvxBoxItem::SvxLineToLine(pLine
.get(), bConvert
);
3892 case MID_FG_COLOR
: rVal
<<= pLine
->GetColor(); break;
3893 case MID_OUTER_WIDTH
: rVal
<<= sal_Int32(pLine
->GetOutWidth()); break;
3894 case MID_INNER_WIDTH
: rVal
<<= sal_Int32(pLine
->GetInWidth( )); break;
3895 case MID_DISTANCE
: rVal
<<= sal_Int32(pLine
->GetDistance()); break;
3897 OSL_FAIL( "Wrong MemberId" );
3906 bool SvxLineItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemId
)
3908 bool bConvert
= 0!=(nMemId
&CONVERT_TWIPS
);
3909 nMemId
&= ~CONVERT_TWIPS
;
3913 table::BorderLine2 aLine
;
3914 if ( lcl_extractBorderLine(rVal
, aLine
) )
3917 pLine
.reset( new SvxBorderLine
);
3918 if( !SvxBoxItem::LineToSvxLine(aLine
, *pLine
, bConvert
) )
3924 else if ( rVal
>>= nVal
)
3927 pLine
.reset( new SvxBorderLine
);
3931 case MID_FG_COLOR
: pLine
->SetColor( Color(ColorTransparency
, nVal
) ); break;
3932 case MID_LINE_STYLE
:
3933 pLine
->SetBorderLineStyle(static_cast<SvxBorderLineStyle
>(nVal
));
3936 OSL_FAIL( "Wrong MemberId" );
3947 bool SvxLineItem::GetPresentation
3949 SfxItemPresentation ePres
,
3952 OUString
& rText
, const IntlWrapper
& rIntl
3958 rText
= pLine
->GetValueString( eCoreUnit
, ePresUnit
, &rIntl
,
3959 (SfxItemPresentation::Complete
== ePres
) );
3964 void SvxLineItem::ScaleMetrics( tools::Long nMult
, tools::Long nDiv
)
3966 if ( pLine
) pLine
->ScaleMetrics( nMult
, nDiv
);
3970 bool SvxLineItem::HasMetrics() const
3976 void SvxLineItem::SetLine( const SvxBorderLine
* pNew
)
3978 pLine
.reset( pNew
? new SvxBorderLine( *pNew
) : nullptr );
3981 SvxBrushItem::SvxBrushItem(sal_uInt16 _nWhich
)
3982 : SfxPoolItem(_nWhich
)
3983 , aColor(COL_TRANSPARENT
)
3984 , aFilterColor(COL_TRANSPARENT
)
3985 , nShadingValue(ShadingPattern::CLEAR
)
3986 , nGraphicTransparency(0)
3987 , eGraphicPos(GPOS_NONE
)
3992 SvxBrushItem::SvxBrushItem(const Color
& rColor
, sal_uInt16 _nWhich
)
3993 : SfxPoolItem(_nWhich
)
3995 , aFilterColor(COL_TRANSPARENT
)
3996 , nShadingValue(ShadingPattern::CLEAR
)
3997 , nGraphicTransparency(0)
3998 , eGraphicPos(GPOS_NONE
)
4003 SvxBrushItem::SvxBrushItem(Color
const& rColor
, model::ComplexColor
const& rComplexColor
, sal_uInt16 nWhich
)
4004 : SfxPoolItem(nWhich
)
4006 , maComplexColor(rComplexColor
)
4007 , aFilterColor(COL_TRANSPARENT
)
4008 , nShadingValue(ShadingPattern::CLEAR
)
4009 , nGraphicTransparency(0)
4010 , eGraphicPos(GPOS_NONE
)
4015 SvxBrushItem::SvxBrushItem(const Graphic
& rGraphic
, SvxGraphicPosition ePos
, sal_uInt16 _nWhich
)
4016 : SfxPoolItem(_nWhich
)
4017 , aColor(COL_TRANSPARENT
)
4018 , aFilterColor(COL_TRANSPARENT
)
4019 , nShadingValue(ShadingPattern::CLEAR
)
4020 , xGraphicObject(new GraphicObject(rGraphic
))
4021 , nGraphicTransparency(0)
4022 , eGraphicPos((GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
)
4025 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
4028 SvxBrushItem::SvxBrushItem(const GraphicObject
& rGraphicObj
, SvxGraphicPosition ePos
, sal_uInt16 _nWhich
)
4029 : SfxPoolItem(_nWhich
)
4030 , aColor(COL_TRANSPARENT
)
4031 , aFilterColor(COL_TRANSPARENT
)
4032 , nShadingValue(ShadingPattern::CLEAR
)
4033 , xGraphicObject(new GraphicObject(rGraphicObj
))
4034 , nGraphicTransparency(0)
4035 , eGraphicPos((GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
)
4038 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
4041 SvxBrushItem::SvxBrushItem(OUString aLink
, OUString aFilter
,
4042 SvxGraphicPosition ePos
, sal_uInt16 _nWhich
)
4043 : SfxPoolItem(_nWhich
)
4044 , aColor(COL_TRANSPARENT
)
4045 , aFilterColor(COL_TRANSPARENT
)
4046 , nShadingValue(ShadingPattern::CLEAR
)
4047 , nGraphicTransparency(0)
4048 , maStrLink(std::move(aLink
))
4049 , maStrFilter(std::move(aFilter
))
4050 , eGraphicPos((GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
)
4053 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
4056 SvxBrushItem::SvxBrushItem(const SvxBrushItem
& rItem
)
4057 : SfxPoolItem(rItem
)
4058 , aColor(rItem
.aColor
)
4059 , maComplexColor(rItem
.maComplexColor
)
4060 , aFilterColor(rItem
.aFilterColor
)
4061 , nShadingValue(rItem
.nShadingValue
)
4062 , xGraphicObject(rItem
.xGraphicObject
? new GraphicObject(*rItem
.xGraphicObject
) : nullptr)
4063 , nGraphicTransparency(rItem
.nGraphicTransparency
)
4064 , maStrLink(rItem
.maStrLink
)
4065 , maStrFilter(rItem
.maStrFilter
)
4066 , eGraphicPos(rItem
.eGraphicPos
)
4067 , bLoadAgain(rItem
.bLoadAgain
)
4071 SvxBrushItem::SvxBrushItem(SvxBrushItem
&& rItem
)
4072 : SfxPoolItem(std::move(rItem
))
4073 , aColor(std::move(rItem
.aColor
))
4074 , maComplexColor(std::move(rItem
.maComplexColor
))
4075 , aFilterColor(std::move(rItem
.aFilterColor
))
4076 , nShadingValue(std::move(rItem
.nShadingValue
))
4077 , xGraphicObject(std::move(rItem
.xGraphicObject
))
4078 , nGraphicTransparency(std::move(rItem
.nGraphicTransparency
))
4079 , maStrLink(std::move(rItem
.maStrLink
))
4080 , maStrFilter(std::move(rItem
.maStrFilter
))
4081 , eGraphicPos(std::move(rItem
.eGraphicPos
))
4082 , bLoadAgain(std::move(rItem
.bLoadAgain
))
4086 SvxBrushItem::~SvxBrushItem()
4090 bool SvxBrushItem::isUsed() const
4092 if (GPOS_NONE
!= GetGraphicPos())
4097 else if (!GetColor().IsFullyTransparent())
4107 static sal_Int8
lcl_PercentToTransparency(tools::Long nPercent
)
4109 // 0xff must not be returned!
4110 return sal_Int8(nPercent
? (50 + 0xfe * nPercent
) / 100 : 0);
4114 sal_Int8
SvxBrushItem::TransparencyToPercent(sal_Int32 nTrans
)
4116 return static_cast<sal_Int8
>((nTrans
* 100 + 127) / 254);
4120 bool SvxBrushItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
4122 nMemberId
&= ~CONVERT_TWIPS
;
4125 case MID_BACK_COLOR
:
4128 case MID_BACK_COLOR_R_G_B
:
4129 rVal
<<= aColor
.GetRGBColor();
4131 case MID_BACK_COLOR_TRANSPARENCY
:
4132 rVal
<<= SvxBrushItem::TransparencyToPercent(255 - aColor
.GetAlpha());
4135 case MID_BACKGROUND_COMPLEX_COLOR
:
4137 auto xComplexColor
= model::color::createXComplexColor(maComplexColor
);
4138 rVal
<<= xComplexColor
;
4143 case MID_GRAPHIC_POSITION
:
4144 rVal
<<= static_cast<style::GraphicLocation
>(static_cast<sal_Int16
>(eGraphicPos
));
4147 case MID_GRAPHIC_TRANSPARENT
:
4148 rVal
<<= ( aColor
.GetAlpha() == 0 );
4151 case MID_GRAPHIC_URL
:
4154 uno::Reference
<graphic::XGraphic
> xGraphic
;
4155 if (!maStrLink
.isEmpty())
4157 Graphic
aGraphic(vcl::graphic::loadFromURL(maStrLink
));
4158 xGraphic
= aGraphic
.GetXGraphic();
4160 else if (xGraphicObject
)
4162 xGraphic
= xGraphicObject
->GetGraphic().GetXGraphic();
4168 case MID_GRAPHIC_FILTER
:
4170 rVal
<<= maStrFilter
;
4174 case MID_GRAPHIC_TRANSPARENCY
:
4175 rVal
<<= nGraphicTransparency
;
4178 case MID_SHADING_VALUE
:
4180 rVal
<<= nShadingValue
;
4189 bool SvxBrushItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
4191 nMemberId
&= ~CONVERT_TWIPS
;
4194 case MID_BACK_COLOR
:
4195 case MID_BACK_COLOR_R_G_B
:
4198 if ( !( rVal
>>= aNewCol
) )
4200 if(MID_BACK_COLOR_R_G_B
== nMemberId
)
4202 aNewCol
.SetAlpha(aColor
.GetAlpha());
4207 case MID_BACK_COLOR_TRANSPARENCY
:
4209 sal_Int32 nTrans
= 0;
4210 if ( !( rVal
>>= nTrans
) || nTrans
< 0 || nTrans
> 100 )
4212 aColor
.SetAlpha(255 - lcl_PercentToTransparency(nTrans
));
4216 case MID_BACKGROUND_COMPLEX_COLOR
:
4218 css::uno::Reference
<css::util::XComplexColor
> xComplexColor
;
4219 if (!(rVal
>>= xComplexColor
))
4222 if (xComplexColor
.is())
4223 maComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
4227 case MID_GRAPHIC_POSITION
:
4229 style::GraphicLocation eLocation
;
4230 if ( !( rVal
>>=eLocation
) )
4232 sal_Int32 nValue
= 0;
4233 if ( !( rVal
>>= nValue
) )
4235 eLocation
= static_cast<style::GraphicLocation
>(nValue
);
4237 SetGraphicPos( static_cast<SvxGraphicPosition
>(static_cast<sal_uInt16
>(eLocation
)) );
4241 case MID_GRAPHIC_TRANSPARENT
:
4242 aColor
.SetAlpha( Any2Bool( rVal
) ? 0 : 255 );
4245 case MID_GRAPHIC_URL
:
4250 if (rVal
.getValueType() == ::cppu::UnoType
<OUString
>::get())
4252 OUString aURL
= rVal
.get
<OUString
>();
4253 aGraphic
= vcl::graphic::loadFromURL(aURL
);
4255 else if (rVal
.getValueType() == cppu::UnoType
<graphic::XGraphic
>::get())
4257 auto xGraphic
= rVal
.get
<uno::Reference
<graphic::XGraphic
>>();
4258 aGraphic
= Graphic(xGraphic
);
4261 if (!aGraphic
.IsNone())
4265 std::unique_ptr
<GraphicObject
> xOldGrfObj(std::move(xGraphicObject
));
4266 xGraphicObject
.reset(new GraphicObject(aGraphic
));
4267 ApplyGraphicTransparency_Impl();
4270 if (!aGraphic
.IsNone() && eGraphicPos
== GPOS_NONE
)
4272 eGraphicPos
= GPOS_MM
;
4274 else if (aGraphic
.IsNone())
4276 eGraphicPos
= GPOS_NONE
;
4282 case MID_GRAPHIC_FILTER
:
4284 if( rVal
.getValueType() == ::cppu::UnoType
<OUString
>::get() )
4288 SetGraphicFilter( sLink
);
4292 case MID_GRAPHIC_TRANSPARENCY
:
4296 if(nTmp
>= 0 && nTmp
<= 100)
4298 nGraphicTransparency
= sal_Int8(nTmp
);
4300 ApplyGraphicTransparency_Impl();
4305 case MID_SHADING_VALUE
:
4308 if (!(rVal
>>= nVal
))
4311 nShadingValue
= nVal
;
4320 bool SvxBrushItem::GetPresentation
4322 SfxItemPresentation
/*ePres*/,
4323 MapUnit
/*eCoreUnit*/,
4324 MapUnit
/*ePresUnit*/,
4325 OUString
& rText
, const IntlWrapper
&
4328 if ( GPOS_NONE
== eGraphicPos
)
4330 rText
= ::GetColorString( aColor
) + cpDelim
;
4331 TranslateId pId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
4333 if ( aColor
.IsTransparent() )
4334 pId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
4335 rText
+= EditResId(pId
);
4339 rText
= EditResId(RID_SVXITEMS_GRAPHIC
);
4345 bool SvxBrushItem::operator==( const SfxPoolItem
& rAttr
) const
4347 assert(SfxPoolItem::operator==(rAttr
));
4349 const SvxBrushItem
& rCmp
= static_cast<const SvxBrushItem
&>(rAttr
);
4351 aColor
== rCmp
.aColor
&&
4352 maComplexColor
== rCmp
.maComplexColor
&&
4353 aFilterColor
== rCmp
.aFilterColor
&&
4354 eGraphicPos
== rCmp
.eGraphicPos
&&
4355 nGraphicTransparency
== rCmp
.nGraphicTransparency
;
4359 if ( GPOS_NONE
!= eGraphicPos
)
4361 bEqual
= maStrLink
== rCmp
.maStrLink
;
4365 bEqual
= maStrFilter
== rCmp
.maStrFilter
;
4370 if (!rCmp
.xGraphicObject
)
4371 bEqual
= !xGraphicObject
;
4373 bEqual
= xGraphicObject
&&
4374 (*xGraphicObject
== *rCmp
.xGraphicObject
);
4380 bEqual
= nShadingValue
== rCmp
.nShadingValue
;
4387 SvxBrushItem
* SvxBrushItem::Clone( SfxItemPool
* ) const
4389 return new SvxBrushItem( *this );
4392 const GraphicObject
* SvxBrushItem::GetGraphicObject(OUString
const & referer
) const
4394 if (bLoadAgain
&& !maStrLink
.isEmpty() && !xGraphicObject
)
4395 // when graphics already loaded, use as a cache
4397 if (SvtSecurityOptions::isUntrustedReferer(referer
)) {
4401 // tdf#94088 prepare graphic and state
4403 bool bGraphicLoaded
= false;
4405 // try to create stream directly from given URL
4406 std::unique_ptr
<SvStream
> xStream(utl::UcbStreamHelper::CreateStream(maStrLink
, StreamMode::STD_READ
));
4407 // tdf#94088 if we have a stream, try to load it directly as graphic
4408 if (xStream
&& !xStream
->GetError())
4410 if (ERRCODE_NONE
== GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic
, maStrLink
, *xStream
,
4411 GRFILTER_FORMAT_DONTKNOW
, nullptr, GraphicFilterImportFlags::DontSetLogsizeForJpeg
))
4413 bGraphicLoaded
= true;
4417 // tdf#94088 if no succeeded, try if the string (which is not empty) contains
4418 // a 'data:' scheme url and try to load that (embedded graphics)
4421 INetURLObject
aGraphicURL( maStrLink
);
4423 if( INetProtocol::Data
== aGraphicURL
.GetProtocol() )
4425 std::unique_ptr
<SvMemoryStream
> const xMemStream(aGraphicURL
.getData());
4428 if (ERRCODE_NONE
== GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic
, u
"", *xMemStream
))
4430 bGraphicLoaded
= true;
4432 // tdf#94088 delete the no longer needed data scheme URL which
4433 // is potentially pretty // large, containing a base64 encoded copy of the graphic
4434 const_cast< SvxBrushItem
* >(this)->maStrLink
.clear();
4440 // tdf#94088 when we got a graphic, set it
4441 if(bGraphicLoaded
&& GraphicType::NONE
!= aGraphic
.GetType())
4443 xGraphicObject
.reset(new GraphicObject
);
4444 xGraphicObject
->SetGraphic(aGraphic
);
4445 const_cast < SvxBrushItem
*> (this)->ApplyGraphicTransparency_Impl();
4453 return xGraphicObject
.get();
4456 void SvxBrushItem::setGraphicTransparency(sal_Int8 nNew
)
4458 if (nNew
!= nGraphicTransparency
)
4460 nGraphicTransparency
= nNew
;
4461 ApplyGraphicTransparency_Impl();
4465 const Graphic
* SvxBrushItem::GetGraphic(OUString
const & referer
) const
4467 const GraphicObject
* pGrafObj
= GetGraphicObject(referer
);
4468 return( pGrafObj
? &( pGrafObj
->GetGraphic() ) : nullptr );
4471 void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew
)
4475 if ( GPOS_NONE
== eGraphicPos
)
4477 xGraphicObject
.reset();
4479 maStrFilter
.clear();
4483 if (!xGraphicObject
&& maStrLink
.isEmpty())
4485 xGraphicObject
.reset(new GraphicObject
); // Creating a dummy
4490 void SvxBrushItem::SetGraphic( const Graphic
& rNew
)
4492 if ( maStrLink
.isEmpty() )
4495 xGraphicObject
->SetGraphic(rNew
);
4497 xGraphicObject
.reset(new GraphicObject(rNew
));
4499 ApplyGraphicTransparency_Impl();
4501 if ( GPOS_NONE
== eGraphicPos
)
4502 eGraphicPos
= GPOS_MM
; // None would be brush, then Default: middle
4506 OSL_FAIL( "SetGraphic() on linked graphic! :-/" );
4510 void SvxBrushItem::SetGraphicObject( const GraphicObject
& rNewObj
)
4512 if ( maStrLink
.isEmpty() )
4515 *xGraphicObject
= rNewObj
;
4517 xGraphicObject
.reset(new GraphicObject(rNewObj
));
4519 ApplyGraphicTransparency_Impl();
4521 if ( GPOS_NONE
== eGraphicPos
)
4522 eGraphicPos
= GPOS_MM
; // None would be brush, then Default: middle
4526 OSL_FAIL( "SetGraphic() on linked graphic! :-/" );
4530 void SvxBrushItem::SetGraphicLink( const OUString
& rNew
)
4532 if ( rNew
.isEmpty() )
4537 xGraphicObject
.reset();
4541 void SvxBrushItem::SetGraphicFilter( const OUString
& rNew
)
4546 void SvxBrushItem::ApplyGraphicTransparency_Impl()
4548 DBG_ASSERT(xGraphicObject
, "no GraphicObject available" );
4551 GraphicAttr
aAttr(xGraphicObject
->GetAttr());
4552 aAttr
.SetAlpha(255 - lcl_PercentToTransparency(
4553 nGraphicTransparency
));
4554 xGraphicObject
->SetAttr(aAttr
);
4558 void SvxBrushItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
4560 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxBrushItem"));
4561 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
4562 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("color"), BAD_CAST(aColor
.AsRGBHexString().toUtf8().getStr()));
4563 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("filtercolor"), BAD_CAST(aFilterColor
.AsRGBHexString().toUtf8().getStr()));
4564 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("shadingValue"), BAD_CAST(OString::number(nShadingValue
).getStr()));
4565 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("link"), BAD_CAST(maStrLink
.toUtf8().getStr()));
4566 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("filter"), BAD_CAST(maStrFilter
.toUtf8().getStr()));
4567 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("graphicPos"), BAD_CAST(OString::number(eGraphicPos
).getStr()));
4568 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("loadAgain"), BAD_CAST(OString::boolean(bLoadAgain
).getStr()));
4569 (void)xmlTextWriterEndElement(pWriter
);
4573 SvxFrameDirectionItem::SvxFrameDirectionItem( SvxFrameDirection nValue
,
4574 sal_uInt16 _nWhich
)
4575 : SfxEnumItem
<SvxFrameDirection
>( _nWhich
, nValue
)
4580 SvxFrameDirectionItem::~SvxFrameDirectionItem()
4584 SvxFrameDirectionItem
* SvxFrameDirectionItem::Clone( SfxItemPool
* ) const
4586 return new SvxFrameDirectionItem( *this );
4589 TranslateId
getFrmDirResId(size_t nIndex
)
4591 TranslateId
const RID_SVXITEMS_FRMDIR
[] =
4593 RID_SVXITEMS_FRMDIR_HORI_LEFT_TOP
,
4594 RID_SVXITEMS_FRMDIR_HORI_RIGHT_TOP
,
4595 RID_SVXITEMS_FRMDIR_VERT_TOP_RIGHT
,
4596 RID_SVXITEMS_FRMDIR_VERT_TOP_LEFT
,
4597 RID_SVXITEMS_FRMDIR_ENVIRONMENT
,
4598 RID_SVXITEMS_FRMDIR_VERT_BOT_LEFT
,
4599 RID_SVXITEMS_FRMDIR_VERT_TOP_RIGHT90
4601 return RID_SVXITEMS_FRMDIR
[nIndex
];
4604 bool SvxFrameDirectionItem::GetPresentation(
4605 SfxItemPresentation
/*ePres*/,
4606 MapUnit
/*eCoreUnit*/,
4607 MapUnit
/*ePresUnit*/,
4608 OUString
& rText
, const IntlWrapper
&) const
4610 rText
= EditResId(getFrmDirResId(GetEnumValue()));
4614 bool SvxFrameDirectionItem::PutValue( const css::uno::Any
& rVal
,
4617 sal_Int16 nVal
= sal_Int16();
4618 bool bRet
= ( rVal
>>= nVal
);
4621 // translate WritingDirection2 constants into SvxFrameDirection
4624 case text::WritingMode2::LR_TB
:
4625 SetValue( SvxFrameDirection::Horizontal_LR_TB
);
4627 case text::WritingMode2::RL_TB
:
4628 SetValue( SvxFrameDirection::Horizontal_RL_TB
);
4630 case text::WritingMode2::TB_RL
:
4631 SetValue( SvxFrameDirection::Vertical_RL_TB
);
4633 case text::WritingMode2::TB_LR
:
4634 SetValue( SvxFrameDirection::Vertical_LR_TB
);
4636 case text::WritingMode2::BT_LR
:
4637 SetValue( SvxFrameDirection::Vertical_LR_BT
);
4639 case text::WritingMode2::TB_RL90
:
4640 SetValue(SvxFrameDirection::Vertical_RL_TB90
);
4642 case text::WritingMode2::PAGE
:
4643 SetValue( SvxFrameDirection::Environment
);
4655 bool SvxFrameDirectionItem::QueryValue( css::uno::Any
& rVal
,
4658 // translate SvxFrameDirection into WritingDirection2
4661 switch( GetValue() )
4663 case SvxFrameDirection::Horizontal_LR_TB
:
4664 nVal
= text::WritingMode2::LR_TB
;
4666 case SvxFrameDirection::Horizontal_RL_TB
:
4667 nVal
= text::WritingMode2::RL_TB
;
4669 case SvxFrameDirection::Vertical_RL_TB
:
4670 nVal
= text::WritingMode2::TB_RL
;
4672 case SvxFrameDirection::Vertical_LR_TB
:
4673 nVal
= text::WritingMode2::TB_LR
;
4675 case SvxFrameDirection::Vertical_LR_BT
:
4676 nVal
= text::WritingMode2::BT_LR
;
4678 case SvxFrameDirection::Vertical_RL_TB90
:
4679 nVal
= text::WritingMode2::TB_RL90
;
4681 case SvxFrameDirection::Environment
:
4682 nVal
= text::WritingMode2::PAGE
;
4685 OSL_FAIL("Unknown SvxFrameDirection value!");
4690 // return value + error state
4698 void SvxFrameDirectionItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
4700 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxFrameDirectionItem"));
4701 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("m_nWhich"),
4702 BAD_CAST(OString::number(Which()).getStr()));
4703 (void)xmlTextWriterWriteAttribute(
4704 pWriter
, BAD_CAST("m_nValue"),
4705 BAD_CAST(OString::number(static_cast<sal_Int16
>(GetValue())).getStr()));
4706 (void)xmlTextWriterEndElement(pWriter
);
4709 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */