1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/style/CaseMap.hpp>
21 #include <com/sun/star/awt/FontDescriptor.hpp>
22 #include <com/sun/star/frame/status/FontHeight.hpp>
24 #include <sal/log.hxx>
25 #include <o3tl/safeint.hxx>
26 #include <osl/diagnose.h>
27 #include <unotools/fontdefs.hxx>
28 #include <unotools/intlwrapper.hxx>
29 #include <unotools/syslocale.hxx>
31 #include <vcl/outdev.hxx>
32 #include <vcl/unohelp.hxx>
33 #include <svtools/unitconv.hxx>
35 #include <editeng/editids.hrc>
36 #include <editeng/editrids.hrc>
37 #include <tools/bigint.hxx>
38 #include <tools/mapunit.hxx>
39 #include <tools/UnitConversion.hxx>
41 #include <rtl/math.hxx>
42 #include <rtl/ustring.hxx>
43 #include <i18nlangtag/languagetag.hxx>
44 #include <svl/itemset.hxx>
46 #include <svtools/langtab.hxx>
47 #include <svl/itempool.hxx>
48 #include <svtools/ctrltool.hxx>
49 #include <com/sun/star/awt/FontSlant.hpp>
50 #include <com/sun/star/lang/Locale.hpp>
51 #include <com/sun/star/text/FontEmphasis.hpp>
52 #include <editeng/rsiditem.hxx>
53 #include <editeng/memberids.h>
54 #include <editeng/flstitem.hxx>
55 #include <editeng/fontitem.hxx>
56 #include <editeng/postitem.hxx>
57 #include <editeng/wghtitem.hxx>
58 #include <editeng/fhgtitem.hxx>
59 #include <editeng/udlnitem.hxx>
60 #include <editeng/crossedoutitem.hxx>
61 #include <editeng/shdditem.hxx>
62 #include <editeng/autokernitem.hxx>
63 #include <editeng/wrlmitem.hxx>
64 #include <editeng/contouritem.hxx>
65 #include <editeng/colritem.hxx>
66 #include <editeng/kernitem.hxx>
67 #include <editeng/cmapitem.hxx>
68 #include <editeng/escapementitem.hxx>
69 #include <editeng/langitem.hxx>
70 #include <editeng/nhypitem.hxx>
71 #include <editeng/blinkitem.hxx>
72 #include <editeng/emphasismarkitem.hxx>
73 #include <editeng/twolinesitem.hxx>
74 #include <editeng/scripttypeitem.hxx>
75 #include <editeng/charrotateitem.hxx>
76 #include <editeng/charscaleitem.hxx>
77 #include <editeng/charreliefitem.hxx>
78 #include <editeng/itemtype.hxx>
79 #include <editeng/eerdll.hxx>
80 #include <docmodel/color/ComplexColorJSON.hxx>
81 #include <docmodel/uno/UnoComplexColor.hxx>
82 #include <docmodel/color/ComplexColor.hxx>
83 #include <libxml/xmlwriter.h>
85 using namespace ::com::sun::star
;
86 using namespace ::com::sun::star::text
;
88 SfxPoolItem
* SvxFontItem::CreateDefault() {return new SvxFontItem(0);}
89 SfxPoolItem
* SvxPostureItem::CreateDefault() { return new SvxPostureItem(ITALIC_NONE
, 0);}
90 SfxPoolItem
* SvxWeightItem::CreateDefault() {return new SvxWeightItem(WEIGHT_NORMAL
, 0);}
91 SfxPoolItem
* SvxFontHeightItem::CreateDefault() {return new SvxFontHeightItem(240, 100, 0);}
92 SfxPoolItem
* SvxUnderlineItem::CreateDefault() {return new SvxUnderlineItem(LINESTYLE_NONE
, 0);}
93 SfxPoolItem
* SvxOverlineItem::CreateDefault() {return new SvxOverlineItem(LINESTYLE_NONE
, 0);}
94 SfxPoolItem
* SvxCrossedOutItem::CreateDefault() {return new SvxCrossedOutItem(STRIKEOUT_NONE
, 0);}
95 SfxPoolItem
* SvxShadowedItem::CreateDefault() {return new SvxShadowedItem(false, 0);}
96 SfxPoolItem
* SvxAutoKernItem::CreateDefault() {return new SvxAutoKernItem(false, 0);}
97 SfxPoolItem
* SvxWordLineModeItem::CreateDefault() {return new SvxWordLineModeItem(false, 0);}
98 SfxPoolItem
* SvxContourItem::CreateDefault() {return new SvxContourItem(false, 0);}
99 SfxPoolItem
* SvxColorItem::CreateDefault() {return new SvxColorItem(0);}
100 SfxPoolItem
* SvxKerningItem::CreateDefault() {return new SvxKerningItem(0, 0);}
101 SfxPoolItem
* SvxCaseMapItem::CreateDefault() {return new SvxCaseMapItem(SvxCaseMap::NotMapped
, 0);}
102 SfxPoolItem
* SvxEscapementItem::CreateDefault() {return new SvxEscapementItem(0);}
103 SfxPoolItem
* SvxLanguageItem::CreateDefault() {return new SvxLanguageItem(LANGUAGE_GERMAN
, 0);}
104 SfxPoolItem
* SvxEmphasisMarkItem::CreateDefault() {return new SvxEmphasisMarkItem(FontEmphasisMark::NONE
, TypedWhichId
<SvxEmphasisMarkItem
>(0));}
105 SfxPoolItem
* SvxCharRotateItem::CreateDefault() {return new SvxCharRotateItem(0_deg10
, false, TypedWhichId
<SvxCharRotateItem
>(0));}
106 SfxPoolItem
* SvxCharScaleWidthItem::CreateDefault() {return new SvxCharScaleWidthItem(100, TypedWhichId
<SvxCharScaleWidthItem
>(0));}
107 SfxPoolItem
* SvxCharReliefItem::CreateDefault() {return new SvxCharReliefItem(FontRelief::NONE
, 0);}
110 // class SvxFontListItem -------------------------------------------------
112 SvxFontListItem::SvxFontListItem( const FontList
* pFontLst
,
113 const sal_uInt16 nId
) :
115 pFontList( pFontLst
)
119 sal_Int32 nCount
= pFontList
->GetFontNameCount();
120 aFontNameSeq
.realloc( nCount
);
121 auto pFontNameSeq
= aFontNameSeq
.getArray();
123 for ( sal_Int32 i
= 0; i
< nCount
; i
++ )
124 pFontNameSeq
[i
] = pFontList
->GetFontName(i
).GetFamilyName();
128 SvxFontListItem
* SvxFontListItem::Clone( SfxItemPool
* ) const
130 return new SvxFontListItem( *this );
133 bool SvxFontListItem::operator==( const SfxPoolItem
& rAttr
) const
135 assert(SfxPoolItem::operator==(rAttr
));
137 return( pFontList
== static_cast<const SvxFontListItem
&>(rAttr
).pFontList
);
140 bool SvxFontListItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
142 rVal
<<= aFontNameSeq
;
147 bool SvxFontListItem::GetPresentation
149 SfxItemPresentation
/*ePres*/,
150 MapUnit
/*eCoreUnit*/,
151 MapUnit
/*ePresUnit*/,
152 OUString
& rText
, const IntlWrapper
& /*rIntl*/
159 // class SvxFontItem -----------------------------------------------------
163 sal_Int32
CompareTo(sal_Int32 nA
, sal_Int32 nB
)
179 SvxFontItem::SvxFontItem( const sal_uInt16 nId
) :
182 eFamily
= FAMILY_SWISS
;
183 ePitch
= PITCH_VARIABLE
;
184 eTextEncoding
= RTL_TEXTENCODING_DONTKNOW
;
188 SvxFontItem::SvxFontItem( const FontFamily eFam
, OUString aName
,
189 OUString aStName
, const FontPitch eFontPitch
,
190 const rtl_TextEncoding eFontTextEncoding
, const sal_uInt16 nId
) :
194 aFamilyName(std::move(aName
)),
195 aStyleName(std::move(aStName
))
199 eTextEncoding
= eFontTextEncoding
;
203 bool SvxFontItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
205 nMemberId
&= ~CONVERT_TWIPS
;
210 css::awt::FontDescriptor aFontDescriptor
;
211 aFontDescriptor
.Name
= aFamilyName
;
212 aFontDescriptor
.StyleName
= aStyleName
;
213 aFontDescriptor
.Family
= static_cast<sal_Int16
>(eFamily
);
214 aFontDescriptor
.CharSet
= static_cast<sal_Int16
>(eTextEncoding
);
215 aFontDescriptor
.Pitch
= static_cast<sal_Int16
>(ePitch
);
216 rVal
<<= aFontDescriptor
;
219 case MID_FONT_FAMILY_NAME
:
220 rVal
<<= aFamilyName
;
222 case MID_FONT_STYLE_NAME
:
225 case MID_FONT_FAMILY
: rVal
<<= static_cast<sal_Int16
>(eFamily
); break;
226 case MID_FONT_CHAR_SET
: rVal
<<= static_cast<sal_Int16
>(eTextEncoding
); break;
227 case MID_FONT_PITCH
: rVal
<<= static_cast<sal_Int16
>(ePitch
); break;
232 bool SvxFontItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
234 nMemberId
&= ~CONVERT_TWIPS
;
239 css::awt::FontDescriptor aFontDescriptor
;
240 if ( !( rVal
>>= aFontDescriptor
))
243 aFamilyName
= aFontDescriptor
.Name
;
244 aStyleName
= aFontDescriptor
.StyleName
;
245 eFamily
= static_cast<FontFamily
>(aFontDescriptor
.Family
);
246 eTextEncoding
= static_cast<rtl_TextEncoding
>(aFontDescriptor
.CharSet
);
247 ePitch
= static_cast<FontPitch
>(aFontDescriptor
.Pitch
);
250 case MID_FONT_FAMILY_NAME
:
258 case MID_FONT_STYLE_NAME
:
266 case MID_FONT_FAMILY
:
268 sal_Int16 nFamily
= sal_Int16();
269 if(!(rVal
>>= nFamily
))
271 eFamily
= static_cast<FontFamily
>(nFamily
);
274 case MID_FONT_CHAR_SET
:
276 sal_Int16 nSet
= sal_Int16();
279 eTextEncoding
= static_cast<rtl_TextEncoding
>(nSet
);
282 case MID_FONT_PITCH
:
284 sal_Int16 nPitch
= sal_Int16();
285 if(!(rVal
>>= nPitch
))
287 ePitch
= static_cast<FontPitch
>(nPitch
);
295 bool SvxFontItem::operator==( const SfxPoolItem
& rAttr
) const
297 assert(SfxPoolItem::operator==(rAttr
));
299 const SvxFontItem
& rItem
= static_cast<const SvxFontItem
&>(rAttr
);
301 bool bRet
= ( eFamily
== rItem
.eFamily
&&
302 aFamilyName
== rItem
.aFamilyName
&&
303 aStyleName
== rItem
.aStyleName
);
307 if ( ePitch
!= rItem
.ePitch
|| eTextEncoding
!= rItem
.eTextEncoding
)
310 SAL_INFO( "editeng.items", "FontItem::operator==(): only pitch or rtl_TextEncoding different ");
316 bool SvxFontItem::operator<(const SfxPoolItem
& rCmp
) const
318 const auto& rOther
= static_cast<const SvxFontItem
&>(rCmp
);
319 sal_Int32 nRet
= GetFamilyName().compareTo(rOther
.GetFamilyName());
325 nRet
= GetStyleName().compareTo(rOther
.GetStyleName());
331 nRet
= CompareTo(GetFamily(), rOther
.GetFamily());
337 nRet
= CompareTo(GetPitch(), rOther
.GetPitch());
343 return GetCharSet() < rOther
.GetCharSet();
346 SvxFontItem
* SvxFontItem::Clone( SfxItemPool
* ) const
348 return new SvxFontItem( *this );
351 bool SvxFontItem::GetPresentation
353 SfxItemPresentation
/*ePres*/,
354 MapUnit
/*eCoreUnit*/,
355 MapUnit
/*ePresUnit*/,
356 OUString
& rText
, const IntlWrapper
& /*rIntl*/
364 void SvxFontItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
366 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxFontItem"));
367 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
368 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("familyName"), BAD_CAST(aFamilyName
.toUtf8().getStr()));
369 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("styleName"), BAD_CAST(aStyleName
.toUtf8().getStr()));
370 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("family"), BAD_CAST(OString::number(eFamily
).getStr()));
371 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("pitch"), BAD_CAST(OString::number(ePitch
).getStr()));
372 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("textEncoding"), BAD_CAST(OString::number(eTextEncoding
).getStr()));
373 (void)xmlTextWriterEndElement(pWriter
);
376 // class SvxPostureItem --------------------------------------------------
378 SvxPostureItem::SvxPostureItem( const FontItalic ePosture
, const sal_uInt16 nId
) :
379 SfxEnumItem( nId
, ePosture
)
383 SvxPostureItem
* SvxPostureItem::Clone( SfxItemPool
* ) const
385 return new SvxPostureItem( *this );
388 sal_uInt16
SvxPostureItem::GetValueCount() const
390 return ITALIC_NORMAL
+ 1; // ITALIC_NONE also belongs here
394 bool SvxPostureItem::GetPresentation
396 SfxItemPresentation
/*ePres*/,
397 MapUnit
/*eCoreUnit*/,
398 MapUnit
/*ePresUnit*/,
399 OUString
& rText
, const IntlWrapper
& /*rIntl*/
402 rText
= GetValueTextByPos( GetValue() );
407 OUString
SvxPostureItem::GetValueTextByPos( sal_uInt16 nPos
)
409 DBG_ASSERT( nPos
<= sal_uInt16(ITALIC_NORMAL
), "enum overflow!" );
411 FontItalic eItalic
= static_cast<FontItalic
>(nPos
);
416 case ITALIC_NONE
: pId
= RID_SVXITEMS_ITALIC_NONE
; break;
417 case ITALIC_OBLIQUE
: pId
= RID_SVXITEMS_ITALIC_OBLIQUE
; break;
418 case ITALIC_NORMAL
: pId
= RID_SVXITEMS_ITALIC_NORMAL
; break;
419 default: ;//prevent warning
422 return pId
? EditResId(pId
) : OUString();
425 bool SvxPostureItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
427 nMemberId
&= ~CONVERT_TWIPS
;
431 rVal
<<= GetBoolValue();
434 rVal
<<= vcl::unohelper::ConvertFontSlant(GetValue());
440 bool SvxPostureItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
442 nMemberId
&= ~CONVERT_TWIPS
;
446 SetBoolValue(Any2Bool(rVal
));
450 awt::FontSlant eSlant
;
451 if(!(rVal
>>= eSlant
))
453 sal_Int32 nValue
= 0;
454 if(!(rVal
>>= nValue
))
457 eSlant
= static_cast<awt::FontSlant
>(nValue
);
459 SetValue(vcl::unohelper::ConvertFontSlant(eSlant
));
465 bool SvxPostureItem::HasBoolValue() const
470 bool SvxPostureItem::GetBoolValue() const
472 return ( GetValue() >= ITALIC_OBLIQUE
);
475 void SvxPostureItem::SetBoolValue( bool bVal
)
477 SetValue( bVal
? ITALIC_NORMAL
: ITALIC_NONE
);
480 void SvxPostureItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
482 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxPostureItem"));
483 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
484 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%d", GetValue());
485 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr()));
486 (void)xmlTextWriterEndElement(pWriter
);
489 // class SvxWeightItem ---------------------------------------------------
491 SvxWeightItem::SvxWeightItem( const FontWeight eWght
, const sal_uInt16 nId
) :
492 SfxEnumItem( nId
, eWght
)
497 bool SvxWeightItem::HasBoolValue() const
503 bool SvxWeightItem::GetBoolValue() const
505 return GetValue() >= WEIGHT_BOLD
;
509 void SvxWeightItem::SetBoolValue( bool bVal
)
511 SetValue( bVal
? WEIGHT_BOLD
: WEIGHT_NORMAL
);
515 sal_uInt16
SvxWeightItem::GetValueCount() const
517 return WEIGHT_BLACK
; // WEIGHT_DONTKNOW does not belong
520 SvxWeightItem
* SvxWeightItem::Clone( SfxItemPool
* ) const
522 return new SvxWeightItem( *this );
525 bool SvxWeightItem::GetPresentation
527 SfxItemPresentation
/*ePres*/,
528 MapUnit
/*eCoreUnit*/,
529 MapUnit
/*ePresUnit*/,
530 OUString
& rText
, const IntlWrapper
& /*rIntl*/
533 rText
= GetValueTextByPos( GetValue() );
537 OUString
SvxWeightItem::GetValueTextByPos( sal_uInt16 nPos
)
539 static TranslateId RID_SVXITEMS_WEIGHTS
[] =
541 RID_SVXITEMS_WEIGHT_DONTKNOW
,
542 RID_SVXITEMS_WEIGHT_THIN
,
543 RID_SVXITEMS_WEIGHT_ULTRALIGHT
,
544 RID_SVXITEMS_WEIGHT_LIGHT
,
545 RID_SVXITEMS_WEIGHT_SEMILIGHT
,
546 RID_SVXITEMS_WEIGHT_NORMAL
,
547 RID_SVXITEMS_WEIGHT_MEDIUM
,
548 RID_SVXITEMS_WEIGHT_SEMIBOLD
,
549 RID_SVXITEMS_WEIGHT_BOLD
,
550 RID_SVXITEMS_WEIGHT_ULTRABOLD
,
551 RID_SVXITEMS_WEIGHT_BLACK
554 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_WEIGHTS
) - 1 == WEIGHT_BLACK
, "must match");
555 assert(nPos
<= sal_uInt16(WEIGHT_BLACK
) && "enum overflow!" );
556 return EditResId(RID_SVXITEMS_WEIGHTS
[nPos
]);
559 bool SvxWeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
561 nMemberId
&= ~CONVERT_TWIPS
;
565 rVal
<<= GetBoolValue();
569 rVal
<<= vcl::unohelper::ConvertFontWeight( GetValue() );
576 bool SvxWeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
578 nMemberId
&= ~CONVERT_TWIPS
;
582 SetBoolValue(Any2Bool(rVal
));
587 if(!(rVal
>>= fValue
))
589 sal_Int32 nValue
= 0;
590 if(!(rVal
>>= nValue
))
592 fValue
= static_cast<float>(nValue
);
594 SetValue( vcl::unohelper::ConvertFontWeight(static_cast<float>(fValue
)) );
601 void SvxWeightItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
603 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxWeightItem"));
604 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
605 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%d", GetValue());
606 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr()));
607 (void)xmlTextWriterEndElement(pWriter
);
610 // class SvxFontHeightItem -----------------------------------------------
612 SvxFontHeightItem::SvxFontHeightItem( const sal_uInt32 nSz
,
613 const sal_uInt16 nPrp
,
614 const sal_uInt16 nId
) :
617 SetHeight( nSz
,nPrp
); // calculate in percentage
620 SvxFontHeightItem
* SvxFontHeightItem::Clone( SfxItemPool
* ) const
622 return new SvxFontHeightItem( *this );
625 bool SvxFontHeightItem::operator==( const SfxPoolItem
& rItem
) const
627 assert(SfxPoolItem::operator==(rItem
));
628 return GetHeight() == static_cast<const SvxFontHeightItem
&>(rItem
).GetHeight() &&
629 GetProp() == static_cast<const SvxFontHeightItem
&>(rItem
).GetProp() &&
630 GetPropUnit() == static_cast<const SvxFontHeightItem
&>(rItem
).GetPropUnit();
633 bool SvxFontHeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
635 // In StarOne is the uno::Any always 1/100mm. Through the MemberId it is
636 // controlled if the value in the Item should be 1/100mm or Twips.
638 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
639 nMemberId
&= ~CONVERT_TWIPS
;
644 css::frame::status::FontHeight aFontHeight
;
646 // Point (i.e. Twips) is asked for, thus re-calculate if
647 // CONVERT_TWIPS is not set.
650 aFontHeight
.Height
= o3tl::convert
<double>(nHeight
, o3tl::Length::twip
, o3tl::Length::pt
);
654 double fPoints
= o3tl::convert
<double>(nHeight
, o3tl::Length::mm100
, o3tl::Length::pt
);
655 aFontHeight
.Height
= rtl::math::round(fPoints
, 1);
658 aFontHeight
.Prop
= MapUnit::MapRelative
== ePropUnit
? nProp
: 100;
663 case MapUnit::MapRelative
:
666 case MapUnit::Map100thMM
:
667 fRet
= o3tl::convert(fRet
, o3tl::Length::mm100
, o3tl::Length::pt
);
669 case MapUnit::MapPoint
:
672 case MapUnit::MapTwip
:
673 fRet
= o3tl::convert(fRet
, o3tl::Length::twip
, o3tl::Length::pt
);
675 default: ;//prevent warning
677 aFontHeight
.Diff
= fRet
;
678 rVal
<<= aFontHeight
;
683 // Point (i.e. Twips) is asked for, thus re-calculate if
684 // CONVERT_TWIPS is not set.
687 rVal
<<= static_cast<float>(o3tl::convert
<double>(nHeight
, o3tl::Length::twip
, o3tl::Length::pt
));
691 double fPoints
= o3tl::convert
<double>(nHeight
, o3tl::Length::mm100
, o3tl::Length::pt
);
692 rVal
<<= static_cast<float>(::rtl::math::round(fPoints
, 1));
696 case MID_FONTHEIGHT_PROP
:
697 rVal
<<= static_cast<sal_Int16
>(MapUnit::MapRelative
== ePropUnit
? nProp
: 100);
699 case MID_FONTHEIGHT_DIFF
:
704 case MapUnit::MapRelative
:
707 case MapUnit::Map100thMM
:
708 fRet
= o3tl::convert(fRet
, o3tl::Length::mm100
, o3tl::Length::pt
);
710 case MapUnit::MapPoint
:
713 case MapUnit::MapTwip
:
714 fRet
= o3tl::convert(fRet
, o3tl::Length::twip
, o3tl::Length::pt
);
716 default: ;//prevent warning
725 // Try to reconstruct the original height input value from the modified height
726 // and the prop data; this seems somewhat futile given the various ways how the
727 // modified height is calculated (with and without conversion between twips and
728 // 100th mm; with an additional eCoreMetric input in one of the SetHeight
729 // overloads), and indeed known to occasionally produce nRet values that would
730 // be negative, so just guard against negative results here and throw the hands
732 static sal_uInt32
lcl_GetRealHeight_Impl(sal_uInt32 nHeight
, sal_uInt16 nProp
, MapUnit eProp
, bool bCoreInTwip
)
734 sal_uInt32 nRet
= nHeight
;
738 case MapUnit::MapRelative
:
745 case MapUnit::MapPoint
:
747 short nTemp
= static_cast<short>(nProp
);
750 nDiff
= static_cast<short>(convertTwipToMm100(static_cast<tools::Long
>(nDiff
)));
753 case MapUnit::Map100thMM
:
754 //then the core is surely also in 1/100 mm
755 nDiff
= static_cast<short>(nProp
);
757 case MapUnit::MapTwip
:
759 nDiff
= static_cast<short>(nProp
);
764 nRet
= (nDiff
< 0 || nRet
>= o3tl::make_unsigned(nDiff
))
766 //TODO: overflow in case nDiff < 0 and nRet - nDiff > SAL_MAX_UINT32
771 bool SvxFontHeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
773 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
774 nMemberId
&= ~CONVERT_TWIPS
;
779 css::frame::status::FontHeight aFontHeight
;
780 if ( rVal
>>= aFontHeight
)
783 ePropUnit
= MapUnit::MapRelative
;
785 double fPoint
= aFontHeight
.Height
;
786 if( fPoint
< 0. || fPoint
> 10000. )
789 nHeight
= static_cast<tools::Long
>( fPoint
* 20.0 + 0.5 ); // Twips
791 nHeight
= convertTwipToMm100(nHeight
); // Convert, if the item contains 1/100mm
793 nProp
= aFontHeight
.Prop
;
801 ePropUnit
= MapUnit::MapRelative
;
804 if(!(rVal
>>= fPoint
))
806 sal_Int32 nValue
= 0;
807 if(!(rVal
>>= nValue
))
809 fPoint
= static_cast<float>(nValue
);
811 if(fPoint
< 0. || fPoint
> 10000.)
814 nHeight
= static_cast<tools::Long
>( fPoint
* 20.0 + 0.5 ); // Twips
816 nHeight
= convertTwipToMm100(nHeight
); // Convert, if the item contains 1/100mm
819 case MID_FONTHEIGHT_PROP
:
821 sal_Int16 nNew
= sal_Int16();
825 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
830 ePropUnit
= MapUnit::MapRelative
;
833 case MID_FONTHEIGHT_DIFF
:
835 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
837 if(!(rVal
>>= fValue
))
839 sal_Int32 nValue
= 0;
840 if(!(rVal
>>= nValue
))
842 fValue
= static_cast<float>(nValue
);
844 sal_Int16 nCoreDiffValue
= static_cast<sal_Int16
>(fValue
* 20.);
845 nHeight
+= bConvert
? nCoreDiffValue
: convertTwipToMm100(nCoreDiffValue
);
846 nProp
= static_cast<sal_uInt16
>(static_cast<sal_Int16
>(fValue
));
847 ePropUnit
= MapUnit::MapPoint
;
855 bool SvxFontHeightItem::GetPresentation
857 SfxItemPresentation
/*ePres*/,
859 MapUnit
/*ePresUnit*/,
860 OUString
& rText
, const IntlWrapper
& rIntl
863 if( MapUnit::MapRelative
!= ePropUnit
)
865 rText
= OUString::number( static_cast<short>(nProp
) ) +
866 " " + EditResId( GetMetricId( ePropUnit
) );
867 if( 0 <= static_cast<short>(nProp
) )
870 else if( 100 == nProp
)
872 rText
= GetMetricText( static_cast<tools::Long
>(nHeight
),
873 eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
874 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
877 rText
= OUString::number( nProp
) + "%";
882 void SvxFontHeightItem::ScaleMetrics( tools::Long nMult
, tools::Long nDiv
)
884 nHeight
= static_cast<sal_uInt32
>(BigInt::Scale( nHeight
, nMult
, nDiv
));
888 bool SvxFontHeightItem::HasMetrics() const
893 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, const sal_uInt16 nNewProp
,
896 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
898 if( MapUnit::MapRelative
!= eUnit
)
899 nHeight
= nNewHeight
+ ::ItemToControl( short(nNewProp
), eUnit
,
901 else if( 100 != nNewProp
)
902 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
904 nHeight
= nNewHeight
;
910 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, sal_uInt16 nNewProp
,
911 MapUnit eMetric
, MapUnit eCoreMetric
)
913 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
915 if( MapUnit::MapRelative
!= eMetric
)
916 nHeight
= nNewHeight
+
917 ::ControlToItem( ::ItemToControl(static_cast<short>(nNewProp
), eMetric
,
918 FieldUnit::TWIP
), FieldUnit::TWIP
,
920 else if( 100 != nNewProp
)
921 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
923 nHeight
= nNewHeight
;
929 void SvxFontHeightItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
931 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxFontHeightItem"));
932 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
933 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("height"), BAD_CAST(OString::number(nHeight
).getStr()));
934 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("prop"), BAD_CAST(OString::number(nProp
).getStr()));
935 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("propUnit"), BAD_CAST(OString::number(static_cast<int>(ePropUnit
)).getStr()));
936 (void)xmlTextWriterEndElement(pWriter
);
939 // class SvxTextLineItem ------------------------------------------------
941 SvxTextLineItem::SvxTextLineItem( const FontLineStyle eSt
, const sal_uInt16 nId
)
942 : SfxEnumItem(nId
, eSt
)
943 , maColor(COL_TRANSPARENT
)
948 bool SvxTextLineItem::HasBoolValue() const
954 bool SvxTextLineItem::GetBoolValue() const
956 return GetValue() != LINESTYLE_NONE
;
960 void SvxTextLineItem::SetBoolValue( bool bVal
)
962 SetValue( bVal
? LINESTYLE_SINGLE
: LINESTYLE_NONE
);
965 SvxTextLineItem
* SvxTextLineItem::Clone( SfxItemPool
* ) const
967 return new SvxTextLineItem( *this );
970 sal_uInt16
SvxTextLineItem::GetValueCount() const
972 return LINESTYLE_DOTTED
+ 1; // LINESTYLE_NONE also belongs here
976 bool SvxTextLineItem::GetPresentation
978 SfxItemPresentation
/*ePres*/,
979 MapUnit
/*eCoreUnit*/,
980 MapUnit
/*ePresUnit*/,
981 OUString
& rText
, const IntlWrapper
& /*rIntl*/
984 rText
= GetValueTextByPos( GetValue() );
985 if( !maColor
.IsTransparent() )
986 rText
+= cpDelim
+ ::GetColorString(maColor
);
991 OUString
SvxTextLineItem::GetValueTextByPos( sal_uInt16
/*nPos*/ ) const
993 OSL_FAIL("SvxTextLineItem::GetValueTextByPos: Pure virtual method");
997 bool SvxTextLineItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
999 nMemberId
&= ~CONVERT_TWIPS
;
1003 rVal
<<= GetBoolValue();
1006 rVal
<<= static_cast<sal_Int16
>(GetValue());
1011 case MID_TL_COMPLEX_COLOR
:
1013 auto xComplexColor
= model::color::createXComplexColor(maComplexColor
);
1014 rVal
<<= xComplexColor
;
1017 case MID_TL_HASCOLOR
:
1018 rVal
<<= maColor
.GetAlpha() == 255;
1024 bool SvxTextLineItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1026 nMemberId
&= ~CONVERT_TWIPS
;
1031 SetBoolValue(Any2Bool(rVal
));
1035 sal_Int32 nValue
= 0;
1036 if(!(rVal
>>= nValue
))
1039 SetValue(static_cast<FontLineStyle
>(nValue
));
1045 if( !( rVal
>>= nCol
) )
1049 // Keep transparence, because it contains the information
1050 // whether the font color or the stored color should be used
1051 sal_uInt8 nAlpha
= maColor
.GetAlpha();
1053 maColor
.SetAlpha( nAlpha
);
1057 case MID_TL_COMPLEX_COLOR
:
1059 css::uno::Reference
<css::util::XComplexColor
> xComplexColor
;
1060 if (!(rVal
>>= xComplexColor
))
1063 if (xComplexColor
.is())
1064 maComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
1067 case MID_TL_HASCOLOR
:
1068 maColor
.SetAlpha( Any2Bool( rVal
) ? 255 : 0 );
1074 bool SvxTextLineItem::operator==( const SfxPoolItem
& rItem
) const
1076 return SfxEnumItem::operator==( rItem
) &&
1077 maColor
== static_cast<const SvxTextLineItem
&>(rItem
).maColor
&&
1078 maComplexColor
== static_cast<const SvxTextLineItem
&>(rItem
).maComplexColor
;
1081 // class SvxUnderlineItem ------------------------------------------------
1084 SvxUnderlineItem::SvxUnderlineItem( const FontLineStyle eSt
, const sal_uInt16 nId
)
1085 : SvxTextLineItem( eSt
, nId
)
1089 SvxUnderlineItem
* SvxUnderlineItem::Clone( SfxItemPool
* ) const
1091 return new SvxUnderlineItem( *this );
1094 OUString
SvxUnderlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1096 static TranslateId RID_SVXITEMS_UL
[] =
1098 RID_SVXITEMS_UL_NONE
,
1099 RID_SVXITEMS_UL_SINGLE
,
1100 RID_SVXITEMS_UL_DOUBLE
,
1101 RID_SVXITEMS_UL_DOTTED
,
1102 RID_SVXITEMS_UL_DONTKNOW
,
1103 RID_SVXITEMS_UL_DASH
,
1104 RID_SVXITEMS_UL_LONGDASH
,
1105 RID_SVXITEMS_UL_DASHDOT
,
1106 RID_SVXITEMS_UL_DASHDOTDOT
,
1107 RID_SVXITEMS_UL_SMALLWAVE
,
1108 RID_SVXITEMS_UL_WAVE
,
1109 RID_SVXITEMS_UL_DOUBLEWAVE
,
1110 RID_SVXITEMS_UL_BOLD
,
1111 RID_SVXITEMS_UL_BOLDDOTTED
,
1112 RID_SVXITEMS_UL_BOLDDASH
,
1113 RID_SVXITEMS_UL_BOLDLONGDASH
,
1114 RID_SVXITEMS_UL_BOLDDASHDOT
,
1115 RID_SVXITEMS_UL_BOLDDASHDOTDOT
,
1116 RID_SVXITEMS_UL_BOLDWAVE
1118 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_UL
) - 1 == LINESTYLE_BOLDWAVE
, "must match");
1119 assert(nPos
<= sal_uInt16(LINESTYLE_BOLDWAVE
) && "enum overflow!");
1120 return EditResId(RID_SVXITEMS_UL
[nPos
]);
1123 // class SvxOverlineItem ------------------------------------------------
1125 SvxOverlineItem::SvxOverlineItem( const FontLineStyle eSt
, const sal_uInt16 nId
)
1126 : SvxTextLineItem( eSt
, nId
)
1130 SvxOverlineItem
* SvxOverlineItem::Clone( SfxItemPool
* ) const
1132 return new SvxOverlineItem( *this );
1135 OUString
SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1137 static TranslateId RID_SVXITEMS_OL
[] =
1139 RID_SVXITEMS_OL_NONE
,
1140 RID_SVXITEMS_OL_SINGLE
,
1141 RID_SVXITEMS_OL_DOUBLE
,
1142 RID_SVXITEMS_OL_DOTTED
,
1143 RID_SVXITEMS_OL_DONTKNOW
,
1144 RID_SVXITEMS_OL_DASH
,
1145 RID_SVXITEMS_OL_LONGDASH
,
1146 RID_SVXITEMS_OL_DASHDOT
,
1147 RID_SVXITEMS_OL_DASHDOTDOT
,
1148 RID_SVXITEMS_OL_SMALLWAVE
,
1149 RID_SVXITEMS_OL_WAVE
,
1150 RID_SVXITEMS_OL_DOUBLEWAVE
,
1151 RID_SVXITEMS_OL_BOLD
,
1152 RID_SVXITEMS_OL_BOLDDOTTED
,
1153 RID_SVXITEMS_OL_BOLDDASH
,
1154 RID_SVXITEMS_OL_BOLDLONGDASH
,
1155 RID_SVXITEMS_OL_BOLDDASHDOT
,
1156 RID_SVXITEMS_OL_BOLDDASHDOTDOT
,
1157 RID_SVXITEMS_OL_BOLDWAVE
1159 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_OL
) - 1 == LINESTYLE_BOLDWAVE
, "must match");
1160 assert(nPos
<= sal_uInt16(LINESTYLE_BOLDWAVE
) && "enum overflow!");
1161 return EditResId(RID_SVXITEMS_OL
[nPos
]);
1164 // class SvxCrossedOutItem -----------------------------------------------
1166 SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt
, const sal_uInt16 nId
)
1167 : SfxEnumItem( nId
, eSt
)
1172 bool SvxCrossedOutItem::HasBoolValue() const
1178 bool SvxCrossedOutItem::GetBoolValue() const
1180 return GetValue() != STRIKEOUT_NONE
;
1184 void SvxCrossedOutItem::SetBoolValue( bool bVal
)
1186 SetValue( bVal
? STRIKEOUT_SINGLE
: STRIKEOUT_NONE
);
1190 sal_uInt16
SvxCrossedOutItem::GetValueCount() const
1192 return STRIKEOUT_DOUBLE
+ 1; // STRIKEOUT_NONE belongs also here
1195 SvxCrossedOutItem
* SvxCrossedOutItem::Clone( SfxItemPool
* ) const
1197 return new SvxCrossedOutItem( *this );
1200 bool SvxCrossedOutItem::GetPresentation
1202 SfxItemPresentation
/*ePres*/,
1203 MapUnit
/*eCoreUnit*/,
1204 MapUnit
/*ePresUnit*/,
1205 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1208 rText
= GetValueTextByPos( GetValue() );
1212 OUString
SvxCrossedOutItem::GetValueTextByPos( sal_uInt16 nPos
)
1214 static TranslateId RID_SVXITEMS_STRIKEOUT
[] =
1216 RID_SVXITEMS_STRIKEOUT_NONE
,
1217 RID_SVXITEMS_STRIKEOUT_SINGLE
,
1218 RID_SVXITEMS_STRIKEOUT_DOUBLE
,
1219 RID_SVXITEMS_STRIKEOUT_DONTKNOW
,
1220 RID_SVXITEMS_STRIKEOUT_BOLD
,
1221 RID_SVXITEMS_STRIKEOUT_SLASH
,
1222 RID_SVXITEMS_STRIKEOUT_X
1224 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_STRIKEOUT
) - 1 == STRIKEOUT_X
, "must match");
1225 assert(nPos
<= sal_uInt16(STRIKEOUT_X
) && "enum overflow!");
1226 return EditResId(RID_SVXITEMS_STRIKEOUT
[nPos
]);
1229 bool SvxCrossedOutItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1231 nMemberId
&= ~CONVERT_TWIPS
;
1234 case MID_CROSSED_OUT
:
1235 rVal
<<= GetBoolValue();
1238 rVal
<<= static_cast<sal_Int16
>(GetValue());
1244 bool SvxCrossedOutItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1246 nMemberId
&= ~CONVERT_TWIPS
;
1249 case MID_CROSSED_OUT
:
1250 SetBoolValue(Any2Bool(rVal
));
1254 sal_Int32 nValue
= 0;
1255 if(!(rVal
>>= nValue
))
1257 SetValue(static_cast<FontStrikeout
>(nValue
));
1263 // class SvxShadowedItem -------------------------------------------------
1265 SvxShadowedItem::SvxShadowedItem( const bool bShadowed
, const sal_uInt16 nId
) :
1266 SfxBoolItem( nId
, bShadowed
)
1270 SvxShadowedItem
* SvxShadowedItem::Clone( SfxItemPool
* ) const
1272 return new SvxShadowedItem( *this );
1275 bool SvxShadowedItem::GetPresentation
1277 SfxItemPresentation
/*ePres*/,
1278 MapUnit
/*eCoreUnit*/,
1279 MapUnit
/*ePresUnit*/,
1280 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1283 TranslateId pId
= RID_SVXITEMS_SHADOWED_FALSE
;
1286 pId
= RID_SVXITEMS_SHADOWED_TRUE
;
1287 rText
= EditResId(pId
);
1291 // class SvxAutoKernItem -------------------------------------------------
1293 SvxAutoKernItem::SvxAutoKernItem( const bool bAutoKern
, const sal_uInt16 nId
) :
1294 SfxBoolItem( nId
, bAutoKern
)
1298 SvxAutoKernItem
* SvxAutoKernItem::Clone( SfxItemPool
* ) const
1300 return new SvxAutoKernItem( *this );
1303 bool SvxAutoKernItem::GetPresentation
1305 SfxItemPresentation
/*ePres*/,
1306 MapUnit
/*eCoreUnit*/,
1307 MapUnit
/*ePresUnit*/,
1308 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1311 TranslateId pId
= RID_SVXITEMS_AUTOKERN_FALSE
;
1314 pId
= RID_SVXITEMS_AUTOKERN_TRUE
;
1315 rText
= EditResId(pId
);
1319 // class SvxWordLineModeItem ---------------------------------------------
1321 SvxWordLineModeItem::SvxWordLineModeItem( const bool bWordLineMode
,
1322 const sal_uInt16 nId
) :
1323 SfxBoolItem( nId
, bWordLineMode
)
1327 SvxWordLineModeItem
* SvxWordLineModeItem::Clone( SfxItemPool
* ) const
1329 return new SvxWordLineModeItem( *this );
1332 bool SvxWordLineModeItem::GetPresentation
1334 SfxItemPresentation
/*ePres*/,
1335 MapUnit
/*eCoreUnit*/,
1336 MapUnit
/*ePresUnit*/,
1337 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1340 TranslateId pId
= RID_SVXITEMS_WORDLINE_FALSE
;
1343 pId
= RID_SVXITEMS_WORDLINE_TRUE
;
1344 rText
= EditResId(pId
);
1348 // class SvxContourItem --------------------------------------------------
1350 SvxContourItem::SvxContourItem( const bool bContoured
, const sal_uInt16 nId
) :
1351 SfxBoolItem( nId
, bContoured
)
1355 SvxContourItem
* SvxContourItem::Clone( SfxItemPool
* ) const
1357 return new SvxContourItem( *this );
1360 bool SvxContourItem::GetPresentation
1362 SfxItemPresentation
/*ePres*/,
1363 MapUnit
/*eCoreUnit*/,
1364 MapUnit
/*ePresUnit*/,
1365 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1368 TranslateId pId
= RID_SVXITEMS_CONTOUR_FALSE
;
1371 pId
= RID_SVXITEMS_CONTOUR_TRUE
;
1372 rText
= EditResId(pId
);
1376 // class SvxColorItem ----------------------------------------------------
1377 SvxColorItem::SvxColorItem( const sal_uInt16 nId
) :
1383 SvxColorItem::SvxColorItem( const Color
& rCol
, const sal_uInt16 nId
) :
1389 SvxColorItem::SvxColorItem(Color
const& rColor
, model::ComplexColor
const& rComplexColor
, const sal_uInt16 nId
)
1392 , maComplexColor(rComplexColor
)
1396 SvxColorItem::~SvxColorItem()
1400 bool SvxColorItem::operator==( const SfxPoolItem
& rAttr
) const
1402 assert(SfxPoolItem::operator==(rAttr
));
1403 const SvxColorItem
& rColorItem
= static_cast<const SvxColorItem
&>(rAttr
);
1405 return mColor
== rColorItem
.mColor
&&
1406 maComplexColor
== rColorItem
.maComplexColor
;
1409 bool SvxColorItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1411 nMemberId
&= ~CONVERT_TWIPS
;
1414 case MID_COLOR_ALPHA
:
1416 auto fTransparency
= static_cast<double>(255 - mColor
.GetAlpha()) * 100 / 255;
1417 rVal
<<= static_cast<sal_Int16
>(basegfx::fround(fTransparency
));
1420 case MID_GRAPHIC_TRANSPARENT
:
1422 rVal
<<= mColor
.GetAlpha() == 0;
1425 case MID_COLOR_THEME_INDEX
:
1427 rVal
<<= sal_Int16(maComplexColor
.meSchemeType
);
1430 case MID_COLOR_TINT_OR_SHADE
:
1432 sal_Int16 nValue
= 0;
1433 for (auto const& rTransform
: maComplexColor
.getTransformations())
1435 if (rTransform
.meType
== model::TransformationType::Tint
)
1436 nValue
= rTransform
.mnValue
;
1437 else if (rTransform
.meType
== model::TransformationType::Shade
)
1438 nValue
= -rTransform
.mnValue
;
1443 case MID_COLOR_LUM_MOD
:
1445 sal_Int16 nValue
= 10000;
1446 for (auto const& rTransform
: maComplexColor
.getTransformations())
1448 if (rTransform
.meType
== model::TransformationType::LumMod
)
1449 nValue
= rTransform
.mnValue
;
1454 case MID_COLOR_LUM_OFF
:
1456 sal_Int16 nValue
= 0;
1457 for (auto const& rTransform
: maComplexColor
.getTransformations())
1459 if (rTransform
.meType
== model::TransformationType::LumOff
)
1460 nValue
= rTransform
.mnValue
;
1465 case MID_COMPLEX_COLOR_JSON
:
1467 rVal
<<= OStringToOUString(model::color::convertToJSON(maComplexColor
), RTL_TEXTENCODING_UTF8
);
1470 case MID_COMPLEX_COLOR
:
1472 auto xComplexColor
= model::color::createXComplexColor(maComplexColor
);
1473 rVal
<<= xComplexColor
;
1486 bool SvxColorItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1488 nMemberId
&= ~CONVERT_TWIPS
;
1491 case MID_COLOR_ALPHA
:
1493 sal_Int16 nTransparency
= 0;
1494 bool bRet
= rVal
>>= nTransparency
;
1497 auto fTransparency
= static_cast<double>(nTransparency
) * 255 / 100;
1498 mColor
.SetAlpha(255 - static_cast<sal_uInt8
>(basegfx::fround(fTransparency
)));
1502 case MID_GRAPHIC_TRANSPARENT
:
1504 mColor
.SetAlpha( Any2Bool( rVal
) ? 0 : 255 );
1507 case MID_COLOR_THEME_INDEX
:
1509 sal_Int16 nIndex
= -1;
1510 if (!(rVal
>>= nIndex
))
1512 maComplexColor
.setSchemeColor(model::convertToThemeColorType(nIndex
));
1515 case MID_COLOR_TINT_OR_SHADE
:
1517 sal_Int16 nTintShade
= 0;
1518 if (!(rVal
>>= nTintShade
))
1521 maComplexColor
.removeTransformations(model::TransformationType::Tint
);
1522 maComplexColor
.removeTransformations(model::TransformationType::Shade
);
1525 maComplexColor
.addTransformation({model::TransformationType::Tint
, nTintShade
});
1526 else if (nTintShade
< 0)
1528 sal_Int16 nShade
= o3tl::narrowing
<sal_Int16
>(-nTintShade
);
1529 maComplexColor
.addTransformation({model::TransformationType::Shade
, nShade
});
1533 case MID_COLOR_LUM_MOD
:
1535 sal_Int16 nLumMod
= 10000;
1536 if (!(rVal
>>= nLumMod
))
1538 maComplexColor
.removeTransformations(model::TransformationType::LumMod
);
1539 maComplexColor
.addTransformation({model::TransformationType::LumMod
, nLumMod
});
1542 case MID_COLOR_LUM_OFF
:
1544 sal_Int16 nLumOff
= 0;
1545 if (!(rVal
>>= nLumOff
))
1547 maComplexColor
.removeTransformations(model::TransformationType::LumOff
);
1548 maComplexColor
.addTransformation({model::TransformationType::LumOff
, nLumOff
});
1551 case MID_COMPLEX_COLOR_JSON
:
1553 OUString sComplexColorJson
;
1554 if (!(rVal
>>= sComplexColorJson
))
1557 if (sComplexColorJson
.isEmpty())
1560 OString aJSON
= OUStringToOString(sComplexColorJson
, RTL_TEXTENCODING_ASCII_US
);
1561 if (!model::color::convertFromJSON(aJSON
, maComplexColor
))
1565 case MID_COMPLEX_COLOR
:
1567 css::uno::Reference
<css::util::XComplexColor
> xComplexColor
;
1568 if (!(rVal
>>= xComplexColor
))
1571 if (xComplexColor
.is())
1572 maComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
1578 if (!(rVal
>>= mColor
))
1586 SvxColorItem
* SvxColorItem::Clone( SfxItemPool
* ) const
1588 return new SvxColorItem( *this );
1591 bool SvxColorItem::GetPresentation
1593 SfxItemPresentation
/*ePres*/,
1594 MapUnit
/*eCoreUnit*/,
1595 MapUnit
/*ePresUnit*/,
1596 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1599 rText
= ::GetColorString( mColor
);
1603 void SvxColorItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1605 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxColorItem"));
1606 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1608 std::stringstream ss
;
1610 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(ss
.str().c_str()));
1613 IntlWrapper
aIntlWrapper(SvtSysLocale().GetUILanguageTag());
1614 GetPresentation( SfxItemPresentation::Complete
, MapUnit::Map100thMM
, MapUnit::Map100thMM
, aStr
, aIntlWrapper
);
1615 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(OUStringToOString(aStr
, RTL_TEXTENCODING_UTF8
).getStr()));
1617 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("complex-color"));
1619 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("type"),
1620 BAD_CAST(OString::number(sal_Int16(maComplexColor
.meType
)).getStr()));
1622 for (auto const& rTransform
: maComplexColor
.getTransformations())
1624 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("transformation"));
1625 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("type"),
1626 BAD_CAST(OString::number(sal_Int16(rTransform
.meType
)).getStr()));
1627 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"),
1628 BAD_CAST(OString::number(rTransform
.mnValue
).getStr()));
1629 (void)xmlTextWriterEndElement(pWriter
);
1632 (void)xmlTextWriterEndElement(pWriter
);
1634 (void)xmlTextWriterEndElement(pWriter
);
1637 // class SvxKerningItem --------------------------------------------------
1639 SvxKerningItem::SvxKerningItem( const short nKern
, const sal_uInt16 nId
) :
1640 SfxInt16Item( nId
, nKern
)
1644 SvxKerningItem
* SvxKerningItem::Clone( SfxItemPool
* ) const
1646 return new SvxKerningItem( *this );
1649 void SvxKerningItem::ScaleMetrics( tools::Long nMult
, tools::Long nDiv
)
1651 SetValue( static_cast<sal_Int16
>(BigInt::Scale( GetValue(), nMult
, nDiv
)) );
1655 bool SvxKerningItem::HasMetrics() const
1661 bool SvxKerningItem::GetPresentation
1663 SfxItemPresentation ePres
,
1665 MapUnit
/*ePresUnit*/,
1666 OUString
& rText
, const IntlWrapper
& rIntl
1671 case SfxItemPresentation::Nameless
:
1672 rText
= GetMetricText( static_cast<tools::Long
>(GetValue()), eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
1673 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
1675 case SfxItemPresentation::Complete
:
1677 rText
= EditResId(RID_SVXITEMS_KERNING_COMPLETE
);
1680 if ( GetValue() > 0 )
1681 pId
= RID_SVXITEMS_KERNING_EXPANDED
;
1682 else if ( GetValue() < 0 )
1683 pId
= RID_SVXITEMS_KERNING_CONDENSED
;
1686 rText
+= EditResId(pId
);
1687 rText
+= GetMetricText( static_cast<tools::Long
>(GetValue()), eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
1688 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
1691 default: ; //prevent warning
1696 bool SvxKerningItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1698 sal_Int16 nVal
= GetValue();
1699 if(nMemberId
& CONVERT_TWIPS
)
1700 nVal
= static_cast<sal_Int16
>(convertTwipToMm100(nVal
));
1705 bool SvxKerningItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1707 sal_Int16 nVal
= sal_Int16();
1708 if(!(rVal
>>= nVal
))
1710 if(nMemberId
& CONVERT_TWIPS
)
1711 nVal
= o3tl::toTwips(nVal
, o3tl::Length::mm100
);
1716 // class SvxCaseMapItem --------------------------------------------------
1718 SvxCaseMapItem::SvxCaseMapItem( const SvxCaseMap eMap
, const sal_uInt16 nId
) :
1719 SfxEnumItem( nId
, eMap
)
1723 sal_uInt16
SvxCaseMapItem::GetValueCount() const
1725 return sal_uInt16(SvxCaseMap::End
); // SvxCaseMap::SmallCaps + 1
1728 SvxCaseMapItem
* SvxCaseMapItem::Clone( SfxItemPool
* ) const
1730 return new SvxCaseMapItem( *this );
1733 bool SvxCaseMapItem::GetPresentation
1735 SfxItemPresentation
/*ePres*/,
1736 MapUnit
/*eCoreUnit*/,
1737 MapUnit
/*ePresUnit*/,
1738 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1741 rText
= GetValueTextByPos( static_cast<sal_uInt16
>(GetValue()) );
1745 OUString
SvxCaseMapItem::GetValueTextByPos( sal_uInt16 nPos
)
1747 static TranslateId RID_SVXITEMS_CASEMAP
[] =
1749 RID_SVXITEMS_CASEMAP_NONE
,
1750 RID_SVXITEMS_CASEMAP_UPPERCASE
,
1751 RID_SVXITEMS_CASEMAP_LOWERCASE
,
1752 RID_SVXITEMS_CASEMAP_TITLE
,
1753 RID_SVXITEMS_CASEMAP_SMALLCAPS
1756 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_CASEMAP
) == size_t(SvxCaseMap::End
), "must match");
1757 assert(nPos
< sal_uInt16(SvxCaseMap::End
) && "enum overflow!");
1758 return EditResId(RID_SVXITEMS_CASEMAP
[nPos
]);
1761 bool SvxCaseMapItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
1763 sal_Int16 nRet
= style::CaseMap::NONE
;
1764 switch( GetValue() )
1766 case SvxCaseMap::Uppercase
: nRet
= style::CaseMap::UPPERCASE
; break;
1767 case SvxCaseMap::Lowercase
: nRet
= style::CaseMap::LOWERCASE
; break;
1768 case SvxCaseMap::Capitalize
: nRet
= style::CaseMap::TITLE
; break;
1769 case SvxCaseMap::SmallCaps
: nRet
= style::CaseMap::SMALLCAPS
; break;
1776 bool SvxCaseMapItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
1778 sal_uInt16 nVal
= sal_uInt16();
1779 if(!(rVal
>>= nVal
))
1785 case style::CaseMap::NONE
: eVal
= SvxCaseMap::NotMapped
; break;
1786 case style::CaseMap::UPPERCASE
: eVal
= SvxCaseMap::Uppercase
; break;
1787 case style::CaseMap::LOWERCASE
: eVal
= SvxCaseMap::Lowercase
; break;
1788 case style::CaseMap::TITLE
: eVal
= SvxCaseMap::Capitalize
; break;
1789 case style::CaseMap::SMALLCAPS
: eVal
= SvxCaseMap::SmallCaps
; break;
1790 default: return false;
1796 // class SvxEscapementItem -----------------------------------------------
1798 SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId
) :
1799 SfxEnumItemInterface( nId
),
1807 SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape
,
1808 const sal_uInt16 nId
) :
1809 SfxEnumItemInterface( nId
),
1812 SetEscapement( eEscape
);
1814 nProp
= DFLT_ESC_PROP
;
1818 SvxEscapementItem::SvxEscapementItem( const short _nEsc
,
1819 const sal_uInt8 _nProp
,
1820 const sal_uInt16 nId
) :
1821 SfxEnumItemInterface( nId
),
1828 bool SvxEscapementItem::operator==( const SfxPoolItem
& rAttr
) const
1830 assert(SfxPoolItem::operator==(rAttr
));
1832 return( nEsc
== static_cast<const SvxEscapementItem
&>(rAttr
).nEsc
&&
1833 nProp
== static_cast<const SvxEscapementItem
&>(rAttr
).nProp
);
1836 SvxEscapementItem
* SvxEscapementItem::Clone( SfxItemPool
* ) const
1838 return new SvxEscapementItem( *this );
1841 sal_uInt16
SvxEscapementItem::GetValueCount() const
1843 return sal_uInt16(SvxEscapement::End
); // SvxEscapement::Subscript + 1
1847 bool SvxEscapementItem::GetPresentation
1849 SfxItemPresentation
/*ePres*/,
1850 MapUnit
/*eCoreUnit*/,
1851 MapUnit
/*ePresUnit*/,
1852 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1855 rText
= GetValueTextByPos( GetEnumValue() );
1859 if( DFLT_ESC_AUTO_SUPER
== nEsc
|| DFLT_ESC_AUTO_SUB
== nEsc
)
1860 rText
+= EditResId(RID_SVXITEMS_ESCAPEMENT_AUTO
);
1862 rText
+= OUString::number( nEsc
) + "%";
1867 OUString
SvxEscapementItem::GetValueTextByPos( sal_uInt16 nPos
)
1869 static TranslateId RID_SVXITEMS_ESCAPEMENT
[] =
1871 RID_SVXITEMS_ESCAPEMENT_OFF
,
1872 RID_SVXITEMS_ESCAPEMENT_SUPER
,
1873 RID_SVXITEMS_ESCAPEMENT_SUB
1876 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_ESCAPEMENT
) == size_t(SvxEscapement::End
), "must match");
1877 assert(nPos
< sal_uInt16(SvxEscapement::End
) && "enum overflow!");
1878 return EditResId(RID_SVXITEMS_ESCAPEMENT
[nPos
]);
1881 sal_uInt16
SvxEscapementItem::GetEnumValue() const
1884 return sal_uInt16(SvxEscapement::Subscript
);
1885 else if ( nEsc
> 0 )
1886 return sal_uInt16(SvxEscapement::Superscript
);
1887 return sal_uInt16(SvxEscapement::Off
);
1891 void SvxEscapementItem::SetEnumValue( sal_uInt16 nVal
)
1893 SetEscapement( static_cast<SvxEscapement
>(nVal
) );
1896 bool SvxEscapementItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1898 nMemberId
&= ~CONVERT_TWIPS
;
1902 rVal
<<= static_cast<sal_Int16
>(nEsc
);
1904 case MID_ESC_HEIGHT
:
1905 rVal
<<= static_cast<sal_Int8
>(nProp
);
1908 rVal
<<= (DFLT_ESC_AUTO_SUB
== nEsc
|| DFLT_ESC_AUTO_SUPER
== nEsc
);
1914 bool SvxEscapementItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1916 nMemberId
&= ~CONVERT_TWIPS
;
1921 sal_Int16 nVal
= sal_Int16();
1922 if( (rVal
>>= nVal
) && (std::abs(nVal
) <= MAX_ESC_POS
+1))
1928 case MID_ESC_HEIGHT
:
1930 sal_Int8 nVal
= sal_Int8();
1931 if( (rVal
>>= nVal
) && (nVal
<= 100))
1939 bool bVal
= Any2Bool(rVal
);
1943 nEsc
= DFLT_ESC_AUTO_SUB
;
1945 nEsc
= DFLT_ESC_AUTO_SUPER
;
1948 if(DFLT_ESC_AUTO_SUPER
== nEsc
)
1950 else if(DFLT_ESC_AUTO_SUB
== nEsc
)
1958 // class SvxLanguageItem -------------------------------------------------
1960 SvxLanguageItem::SvxLanguageItem( const LanguageType eLang
, const sal_uInt16 nId
)
1961 : SvxLanguageItem_Base( nId
, eLang
)
1966 sal_uInt16
SvxLanguageItem::GetValueCount() const
1968 // #i50205# got rid of class International
1969 SAL_WARN( "editeng.items", "SvxLanguageItem::GetValueCount: supposed to return a count of what?");
1970 // Could be SvtLanguageTable::GetEntryCount() (all locales with resource string)?
1971 // Could be LocaleDataWrapper::getInstalledLanguageTypes() (all locales with locale data)?
1975 SvxLanguageItem
* SvxLanguageItem::Clone( SfxItemPool
* ) const
1977 return new SvxLanguageItem( *this );
1980 bool SvxLanguageItem::GetPresentation
1982 SfxItemPresentation
/*ePres*/,
1983 MapUnit
/*eCoreUnit*/,
1984 MapUnit
/*ePresUnit*/,
1985 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1988 rText
= SvtLanguageTable::GetLanguageString( GetValue() );
1992 bool SvxLanguageItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1994 nMemberId
&= ~CONVERT_TWIPS
;
1997 case MID_LANG_INT
: // for basic conversions!
1998 rVal
<<= static_cast<sal_Int16
>(static_cast<sal_uInt16
>(GetValue()));
2000 case MID_LANG_LOCALE
:
2001 lang::Locale
aRet( LanguageTag::convertToLocale( GetValue(), false));
2008 bool SvxLanguageItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2010 nMemberId
&= ~CONVERT_TWIPS
;
2013 case MID_LANG_INT
: // for basic conversions!
2015 sal_Int32 nValue
= 0;
2016 if(!(rVal
>>= nValue
))
2019 SetValue(LanguageType(nValue
));
2022 case MID_LANG_LOCALE
:
2024 lang::Locale aLocale
;
2025 if(!(rVal
>>= aLocale
))
2028 SetValue( LanguageTag::convertToLanguageType( aLocale
, false));
2035 // class SvxNoHyphenItem -------------------------------------------------
2037 SvxNoHyphenItem::SvxNoHyphenItem( const sal_uInt16 nId
) :
2038 SfxBoolItem( nId
, true )
2042 SvxNoHyphenItem
* SvxNoHyphenItem::Clone( SfxItemPool
* ) const
2044 return new SvxNoHyphenItem( *this );
2047 bool SvxNoHyphenItem::GetPresentation
2049 SfxItemPresentation
/*ePres*/,
2050 MapUnit
/*eCoreUnit*/,
2051 MapUnit
/*ePresUnit*/,
2052 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2060 * Dummy item for ToolBox controls:
2065 // class SvxBlinkItem -------------------------------------------------
2068 SvxBlinkItem::SvxBlinkItem( const bool bBlink
, const sal_uInt16 nId
) :
2069 SfxBoolItem( nId
, bBlink
)
2073 SvxBlinkItem
* SvxBlinkItem::Clone( SfxItemPool
* ) const
2075 return new SvxBlinkItem( *this );
2078 bool SvxBlinkItem::GetPresentation
2080 SfxItemPresentation
/*ePres*/,
2081 MapUnit
/*eCoreUnit*/,
2082 MapUnit
/*ePresUnit*/,
2083 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2086 TranslateId pId
= RID_SVXITEMS_BLINK_FALSE
;
2089 pId
= RID_SVXITEMS_BLINK_TRUE
;
2090 rText
= EditResId(pId
);
2094 // class SvxEmphaisMarkItem ---------------------------------------------------
2096 SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue
,
2097 TypedWhichId
<SvxEmphasisMarkItem
> nId
)
2098 : SfxUInt16Item( nId
, static_cast<sal_uInt16
>(nValue
) )
2102 SvxEmphasisMarkItem
* SvxEmphasisMarkItem::Clone( SfxItemPool
* ) const
2104 return new SvxEmphasisMarkItem( *this );
2107 bool SvxEmphasisMarkItem::GetPresentation
2109 SfxItemPresentation
/*ePres*/,
2110 MapUnit
/*eCoreUnit*/,
2111 MapUnit
/*ePresUnit*/,
2113 const IntlWrapper
& /*rIntl*/
2116 static TranslateId RID_SVXITEMS_EMPHASIS
[] =
2118 RID_SVXITEMS_EMPHASIS_NONE_STYLE
,
2119 RID_SVXITEMS_EMPHASIS_DOT_STYLE
,
2120 RID_SVXITEMS_EMPHASIS_CIRCLE_STYLE
,
2121 RID_SVXITEMS_EMPHASIS_DISC_STYLE
,
2122 RID_SVXITEMS_EMPHASIS_ACCENT_STYLE
2125 FontEmphasisMark nVal
= GetEmphasisMark();
2126 rText
= EditResId(RID_SVXITEMS_EMPHASIS
[
2127 static_cast<sal_uInt16
>(static_cast<FontEmphasisMark
>( nVal
& FontEmphasisMark::Style
))]);
2128 TranslateId pId
= ( FontEmphasisMark::PosAbove
& nVal
)
2129 ? RID_SVXITEMS_EMPHASIS_ABOVE_POS
2130 : ( FontEmphasisMark::PosBelow
& nVal
)
2131 ? RID_SVXITEMS_EMPHASIS_BELOW_POS
2134 rText
+= EditResId( pId
);
2138 bool SvxEmphasisMarkItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2140 nMemberId
&= ~CONVERT_TWIPS
;
2145 FontEmphasisMark nValue
= GetEmphasisMark();
2147 switch(nValue
& FontEmphasisMark::Style
)
2149 case FontEmphasisMark::NONE
: nRet
= FontEmphasis::NONE
; break;
2150 case FontEmphasisMark::Dot
: nRet
= FontEmphasis::DOT_ABOVE
; break;
2151 case FontEmphasisMark::Circle
: nRet
= FontEmphasis::CIRCLE_ABOVE
; break;
2152 case FontEmphasisMark::Disc
: nRet
= FontEmphasis::DISK_ABOVE
; break;
2153 case FontEmphasisMark::Accent
: nRet
= FontEmphasis::ACCENT_ABOVE
; break;
2156 if(nRet
&& nValue
& FontEmphasisMark::PosBelow
)
2165 bool SvxEmphasisMarkItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2167 nMemberId
&= ~CONVERT_TWIPS
;
2172 sal_Int32 nValue
= -1;
2174 FontEmphasisMark nMark
;
2177 case FontEmphasis::NONE
: nMark
= FontEmphasisMark::NONE
; break;
2178 case FontEmphasis::DOT_ABOVE
: nMark
= FontEmphasisMark::Dot
|FontEmphasisMark::PosAbove
; break;
2179 case FontEmphasis::CIRCLE_ABOVE
: nMark
= FontEmphasisMark::Circle
|FontEmphasisMark::PosAbove
; break;
2180 case FontEmphasis::DISK_ABOVE
: nMark
= FontEmphasisMark::Disc
|FontEmphasisMark::PosAbove
; break;
2181 case FontEmphasis::ACCENT_ABOVE
: nMark
= FontEmphasisMark::Accent
|FontEmphasisMark::PosAbove
; break;
2182 case FontEmphasis::DOT_BELOW
: nMark
= FontEmphasisMark::Dot
|FontEmphasisMark::PosBelow
; break;
2183 case FontEmphasis::CIRCLE_BELOW
: nMark
= FontEmphasisMark::Circle
|FontEmphasisMark::PosBelow
; break;
2184 case FontEmphasis::DISK_BELOW
: nMark
= FontEmphasisMark::Disc
|FontEmphasisMark::PosBelow
; break;
2185 case FontEmphasis::ACCENT_BELOW
: nMark
= FontEmphasisMark::Accent
|FontEmphasisMark::PosBelow
; break;
2186 default: return false;
2188 SetValue( static_cast<sal_Int16
>(nMark
) );
2195 /*************************************************************************
2196 |* class SvxTwoLinesItem
2197 *************************************************************************/
2199 SvxTwoLinesItem::SvxTwoLinesItem( bool bFlag
, sal_Unicode nStartBracket
,
2200 sal_Unicode nEndBracket
, sal_uInt16 nW
)
2201 : SfxPoolItem( nW
),
2202 cStartBracket( nStartBracket
), cEndBracket( nEndBracket
), bOn( bFlag
)
2206 SvxTwoLinesItem::~SvxTwoLinesItem()
2210 bool SvxTwoLinesItem::operator==( const SfxPoolItem
& rAttr
) const
2212 assert(SfxPoolItem::operator==(rAttr
));
2213 return bOn
== static_cast<const SvxTwoLinesItem
&>(rAttr
).bOn
&&
2214 cStartBracket
== static_cast<const SvxTwoLinesItem
&>(rAttr
).cStartBracket
&&
2215 cEndBracket
== static_cast<const SvxTwoLinesItem
&>(rAttr
).cEndBracket
;
2218 SvxTwoLinesItem
* SvxTwoLinesItem::Clone( SfxItemPool
* ) const
2220 return new SvxTwoLinesItem( *this );
2223 bool SvxTwoLinesItem::QueryValue( css::uno::Any
& rVal
,
2224 sal_uInt8 nMemberId
) const
2226 nMemberId
&= ~CONVERT_TWIPS
;
2233 case MID_START_BRACKET
:
2237 s
= OUString( cStartBracket
);
2241 case MID_END_BRACKET
:
2245 s
= OUString( cEndBracket
);
2256 bool SvxTwoLinesItem::PutValue( const css::uno::Any
& rVal
,
2257 sal_uInt8 nMemberId
)
2259 nMemberId
&= ~CONVERT_TWIPS
;
2265 bOn
= Any2Bool( rVal
);
2268 case MID_START_BRACKET
:
2271 cStartBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
2275 case MID_END_BRACKET
:
2278 cEndBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
2286 bool SvxTwoLinesItem::GetPresentation( SfxItemPresentation
/*ePres*/,
2287 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2288 OUString
&rText
, const IntlWrapper
& /*rIntl*/ ) const
2291 rText
= EditResId( RID_SVXITEMS_TWOLINES_OFF
);
2294 rText
= EditResId( RID_SVXITEMS_TWOLINES
);
2295 if( GetStartBracket() )
2296 rText
= OUStringChar(GetStartBracket()) + rText
;
2297 if( GetEndBracket() )
2298 rText
+= OUStringChar(GetEndBracket());
2304 /*************************************************************************
2305 |* class SvxTextRotateItem
2306 *************************************************************************/
2308 SvxTextRotateItem::SvxTextRotateItem(Degree10 nValue
, TypedWhichId
<SvxTextRotateItem
> nW
)
2309 : SfxUInt16Item(nW
, nValue
.get())
2313 SvxTextRotateItem
* SvxTextRotateItem::Clone(SfxItemPool
*) const
2315 return new SvxTextRotateItem(*this);
2318 bool SvxTextRotateItem::GetPresentation(
2319 SfxItemPresentation
/*ePres*/,
2320 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2321 OUString
&rText
, const IntlWrapper
&) const
2324 rText
= EditResId(RID_SVXITEMS_TEXTROTATE_OFF
);
2327 rText
= EditResId(RID_SVXITEMS_TEXTROTATE
);
2328 rText
= rText
.replaceFirst("$(ARG1)",
2329 OUString::number(toDegrees(GetValue())));
2334 bool SvxTextRotateItem::QueryValue(css::uno::Any
& rVal
,
2335 sal_uInt8 nMemberId
) const
2337 nMemberId
&= ~CONVERT_TWIPS
;
2342 rVal
<<= static_cast<sal_Int16
>(GetValue());
2351 bool SvxTextRotateItem::PutValue(const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
2353 nMemberId
&= ~CONVERT_TWIPS
;
2360 if ((rVal
>>= nVal
) && (0 == nVal
|| 900 == nVal
|| 2700 == nVal
))
2361 SetValue(Degree10(nVal
));
2372 void SvxTextRotateItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2374 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxTextRotateItem"));
2375 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2376 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue().get()).getStr()));
2377 (void)xmlTextWriterEndElement(pWriter
);
2381 /*************************************************************************
2382 |* class SvxCharRotateItem
2383 *************************************************************************/
2385 SvxCharRotateItem::SvxCharRotateItem( Degree10 nValue
,
2387 TypedWhichId
<SvxCharRotateItem
> nW
)
2388 : SvxTextRotateItem(nValue
, nW
), bFitToLine( bFitIntoLine
)
2392 SvxCharRotateItem
* SvxCharRotateItem::Clone( SfxItemPool
* ) const
2394 return new SvxCharRotateItem( *this );
2397 bool SvxCharRotateItem::GetPresentation(
2398 SfxItemPresentation
/*ePres*/,
2399 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2400 OUString
&rText
, const IntlWrapper
&) const
2403 rText
= EditResId( RID_SVXITEMS_CHARROTATE_OFF
);
2406 rText
= EditResId( RID_SVXITEMS_CHARROTATE
);
2407 rText
= rText
.replaceFirst( "$(ARG1)",
2408 OUString::number( toDegrees(GetValue()) ));
2410 rText
+= EditResId( RID_SVXITEMS_CHARROTATE_FITLINE
);
2415 bool SvxCharRotateItem::QueryValue( css::uno::Any
& rVal
,
2416 sal_uInt8 nMemberId
) const
2419 switch(nMemberId
& ~CONVERT_TWIPS
)
2422 SvxTextRotateItem::QueryValue(rVal
, nMemberId
);
2425 rVal
<<= IsFitToLine();
2434 bool SvxCharRotateItem::PutValue( const css::uno::Any
& rVal
,
2435 sal_uInt8 nMemberId
)
2438 switch(nMemberId
& ~CONVERT_TWIPS
)
2442 bRet
= SvxTextRotateItem::PutValue(rVal
, nMemberId
);
2447 SetFitToLine( Any2Bool( rVal
) );
2455 bool SvxCharRotateItem::operator==( const SfxPoolItem
& rItem
) const
2457 assert(SfxPoolItem::operator==(rItem
));
2458 return SvxTextRotateItem::operator==( rItem
) &&
2459 IsFitToLine() == static_cast<const SvxCharRotateItem
&>(rItem
).IsFitToLine();
2462 void SvxCharRotateItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2464 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxCharRotateItem"));
2465 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2466 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue().get()).getStr()));
2467 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("fitToLine"), BAD_CAST(OString::boolean(IsFitToLine()).getStr()));
2468 (void)xmlTextWriterEndElement(pWriter
);
2471 /*************************************************************************
2472 |* class SvxCharScaleItem
2473 *************************************************************************/
2475 SvxCharScaleWidthItem::SvxCharScaleWidthItem( sal_uInt16 nValue
,
2476 TypedWhichId
<SvxCharScaleWidthItem
> nW
)
2477 : SfxUInt16Item( nW
, nValue
)
2481 SvxCharScaleWidthItem
* SvxCharScaleWidthItem::Clone( SfxItemPool
* ) const
2483 return new SvxCharScaleWidthItem( *this );
2486 bool SvxCharScaleWidthItem::GetPresentation(
2487 SfxItemPresentation
/*ePres*/,
2488 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2489 OUString
&rText
, const IntlWrapper
&) const
2492 rText
= EditResId( RID_SVXITEMS_CHARSCALE_OFF
);
2495 rText
= EditResId( RID_SVXITEMS_CHARSCALE
);
2496 rText
= rText
.replaceFirst( "$(ARG1)",
2497 OUString::number( GetValue() ));
2502 bool SvxCharScaleWidthItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
2504 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
2505 // where we still want this to be a sal_Int16
2506 sal_Int16 nValue
= sal_Int16();
2507 if (rVal
>>= nValue
)
2509 SetValue( static_cast<sal_uInt16
>(nValue
) );
2513 SAL_WARN("editeng.items", "SvxCharScaleWidthItem::PutValue - Wrong type!" );
2517 bool SvxCharScaleWidthItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
2519 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
2520 // where we still want this to be a sal_Int16
2521 rVal
<<= static_cast<sal_Int16
>(GetValue());
2525 /*************************************************************************
2526 |* class SvxCharReliefItem
2527 *************************************************************************/
2529 SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue
,
2530 const sal_uInt16 nId
)
2531 : SfxEnumItem( nId
, eValue
)
2535 SvxCharReliefItem
* SvxCharReliefItem::Clone( SfxItemPool
* ) const
2537 return new SvxCharReliefItem( *this );
2540 static TranslateId RID_SVXITEMS_RELIEF
[] =
2542 RID_SVXITEMS_RELIEF_NONE
,
2543 RID_SVXITEMS_RELIEF_EMBOSSED
,
2544 RID_SVXITEMS_RELIEF_ENGRAVED
2547 OUString
SvxCharReliefItem::GetValueTextByPos(sal_uInt16 nPos
)
2549 assert(nPos
< SAL_N_ELEMENTS(RID_SVXITEMS_RELIEF
) && "enum overflow");
2550 return EditResId(RID_SVXITEMS_RELIEF
[nPos
]);
2553 sal_uInt16
SvxCharReliefItem::GetValueCount() const
2555 return SAL_N_ELEMENTS(RID_SVXITEMS_RELIEF
) - 1;
2558 bool SvxCharReliefItem::GetPresentation
2560 SfxItemPresentation
/*ePres*/,
2561 MapUnit
/*eCoreUnit*/,
2562 MapUnit
/*ePresUnit*/,
2563 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2566 rText
= GetValueTextByPos( static_cast<sal_uInt16
>(GetValue()) );
2570 bool SvxCharReliefItem::PutValue( const css::uno::Any
& rVal
,
2571 sal_uInt8 nMemberId
)
2573 nMemberId
&= ~CONVERT_TWIPS
;
2579 sal_Int16 nVal
= -1;
2581 if(nVal
>= 0 && nVal
<= sal_Int16(FontRelief::Engraved
))
2582 SetValue( static_cast<FontRelief
>(nVal
) );
2594 bool SvxCharReliefItem::QueryValue( css::uno::Any
& rVal
,
2595 sal_uInt8 nMemberId
) const
2597 nMemberId
&= ~CONVERT_TWIPS
;
2602 rVal
<<= static_cast<sal_Int16
>(GetValue());
2611 /*************************************************************************
2612 |* class SvxScriptSetItem
2613 *************************************************************************/
2615 SvxScriptSetItem::SvxScriptSetItem( sal_uInt16 nSlotId
, SfxItemPool
& rPool
)
2616 : SfxSetItem( nSlotId
, SfxItemSet( rPool
,
2617 svl::Items
<SID_ATTR_CHAR_FONT
, SID_ATTR_CHAR_FONT
> ))
2619 sal_uInt16 nLatin
, nAsian
, nComplex
;
2620 GetWhichIds( nLatin
, nAsian
, nComplex
);
2621 GetItemSet().MergeRange( nLatin
, nLatin
);
2622 GetItemSet().MergeRange( nAsian
, nAsian
);
2623 GetItemSet().MergeRange( nComplex
, nComplex
);
2626 SvxScriptSetItem
* SvxScriptSetItem::Clone( SfxItemPool
* ) const
2628 SvxScriptSetItem
* p
= new SvxScriptSetItem( Which(), *GetItemSet().GetPool() );
2629 p
->GetItemSet().Put( GetItemSet(), false );
2633 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScriptSet(
2634 const SfxItemSet
& rSet
, sal_uInt16 nId
)
2636 const SfxPoolItem
* pI
;
2637 SfxItemState eSt
= rSet
.GetItemState( nId
, false, &pI
);
2638 if( SfxItemState::SET
!= eSt
)
2639 pI
= SfxItemState::DEFAULT
== eSt
? &rSet
.Get( nId
) : nullptr;
2643 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, SvtScriptType nScript
)
2645 sal_uInt16 nLatin
, nAsian
, nComplex
;
2646 GetWhichIds( nSlotId
, rSet
, nLatin
, nAsian
, nComplex
);
2648 const SfxPoolItem
*pRet
, *pAsn
, *pCmplx
;
2649 if (nScript
== SvtScriptType::ASIAN
)
2651 pRet
= GetItemOfScriptSet( rSet
, nAsian
);
2652 } else if (nScript
== SvtScriptType::COMPLEX
)
2654 pRet
= GetItemOfScriptSet( rSet
, nComplex
);
2655 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::ASIAN
))
2657 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2658 nullptr == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2661 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::COMPLEX
))
2663 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2664 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2667 } else if (nScript
== (SvtScriptType::ASIAN
|SvtScriptType::COMPLEX
))
2669 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2670 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2673 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::ASIAN
|SvtScriptType::COMPLEX
))
2675 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2676 nullptr == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2677 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2678 *pRet
!= *pAsn
|| *pRet
!= *pCmplx
)
2681 //no one valid -> match to latin
2682 pRet
= GetItemOfScriptSet( rSet
, nLatin
);
2687 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( SvtScriptType nScript
) const
2689 return GetItemOfScript( Which(), GetItemSet(), nScript
);
2692 void SvxScriptSetItem::PutItemForScriptType( SvtScriptType nScriptType
,
2693 const SfxPoolItem
& rItem
)
2695 sal_uInt16 nLatin
, nAsian
, nComplex
;
2696 GetWhichIds( nLatin
, nAsian
, nComplex
);
2698 if( SvtScriptType::LATIN
& nScriptType
)
2700 GetItemSet().Put( rItem
.CloneSetWhich(nLatin
) );
2702 if( SvtScriptType::ASIAN
& nScriptType
)
2704 GetItemSet().Put( rItem
.CloneSetWhich(nAsian
) );
2706 if( SvtScriptType::COMPLEX
& nScriptType
)
2708 GetItemSet().Put( rItem
.CloneSetWhich(nComplex
) );
2712 void SvxScriptSetItem::GetWhichIds( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, sal_uInt16
& rLatin
, sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
2714 const SfxItemPool
& rPool
= *rSet
.GetPool();
2715 GetSlotIds( nSlotId
, rLatin
, rAsian
, rComplex
);
2716 rLatin
= rPool
.GetWhich( rLatin
);
2717 rAsian
= rPool
.GetWhich( rAsian
);
2718 rComplex
= rPool
.GetWhich( rComplex
);
2721 void SvxScriptSetItem::GetWhichIds( sal_uInt16
& rLatin
, sal_uInt16
& rAsian
,
2722 sal_uInt16
& rComplex
) const
2724 GetWhichIds( Which(), GetItemSet(), rLatin
, rAsian
, rComplex
);
2727 void SvxScriptSetItem::GetSlotIds( sal_uInt16 nSlotId
, sal_uInt16
& rLatin
,
2728 sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
2733 SAL_WARN( "editeng.items", "wrong SlotId for class SvxScriptSetItem" );
2734 [[fallthrough
]]; // default to font - Id Range !!
2736 case SID_ATTR_CHAR_FONT
:
2737 rLatin
= SID_ATTR_CHAR_FONT
;
2738 rAsian
= SID_ATTR_CHAR_CJK_FONT
;
2739 rComplex
= SID_ATTR_CHAR_CTL_FONT
;
2741 case SID_ATTR_CHAR_FONTHEIGHT
:
2742 rLatin
= SID_ATTR_CHAR_FONTHEIGHT
;
2743 rAsian
= SID_ATTR_CHAR_CJK_FONTHEIGHT
;
2744 rComplex
= SID_ATTR_CHAR_CTL_FONTHEIGHT
;
2746 case SID_ATTR_CHAR_WEIGHT
:
2747 rLatin
= SID_ATTR_CHAR_WEIGHT
;
2748 rAsian
= SID_ATTR_CHAR_CJK_WEIGHT
;
2749 rComplex
= SID_ATTR_CHAR_CTL_WEIGHT
;
2751 case SID_ATTR_CHAR_POSTURE
:
2752 rLatin
= SID_ATTR_CHAR_POSTURE
;
2753 rAsian
= SID_ATTR_CHAR_CJK_POSTURE
;
2754 rComplex
= SID_ATTR_CHAR_CTL_POSTURE
;
2756 case SID_ATTR_CHAR_LANGUAGE
:
2757 rLatin
= SID_ATTR_CHAR_LANGUAGE
;
2758 rAsian
= SID_ATTR_CHAR_CJK_LANGUAGE
;
2759 rComplex
= SID_ATTR_CHAR_CTL_LANGUAGE
;
2761 case SID_ATTR_CHAR_SHADOWED
:
2762 rLatin
= SID_ATTR_CHAR_SHADOWED
;
2763 rAsian
= SID_ATTR_CHAR_SHADOWED
;
2764 rComplex
= SID_ATTR_CHAR_SHADOWED
;
2766 case SID_ATTR_CHAR_STRIKEOUT
:
2767 rLatin
= SID_ATTR_CHAR_STRIKEOUT
;
2768 rAsian
= SID_ATTR_CHAR_STRIKEOUT
;
2769 rComplex
= SID_ATTR_CHAR_STRIKEOUT
;
2774 void GetDefaultFonts( SvxFontItem
& rLatin
, SvxFontItem
& rAsian
, SvxFontItem
& rComplex
)
2776 const sal_uInt16 nItemCnt
= 3;
2780 DefaultFontType nFontType
;
2781 LanguageType nLanguage
;
2783 const aOutTypeArr
[ nItemCnt
] =
2785 { DefaultFontType::LATIN_TEXT
, LANGUAGE_ENGLISH_US
},
2786 { DefaultFontType::CJK_TEXT
, LANGUAGE_ENGLISH_US
},
2787 { DefaultFontType::CTL_TEXT
, LANGUAGE_ARABIC_SAUDI_ARABIA
}
2790 SvxFontItem
* aItemArr
[ nItemCnt
] = { &rLatin
, &rAsian
, &rComplex
};
2792 for ( sal_uInt16 n
= 0; n
< nItemCnt
; ++n
)
2794 vcl::Font
aFont( OutputDevice::GetDefaultFont( aOutTypeArr
[ n
].nFontType
,
2795 aOutTypeArr
[ n
].nLanguage
,
2796 GetDefaultFontFlags::OnlyOne
) );
2797 SvxFontItem
* pItem
= aItemArr
[ n
];
2798 pItem
->SetFamily( aFont
.GetFamilyType() );
2799 pItem
->SetFamilyName( aFont
.GetFamilyName() );
2800 pItem
->SetStyleName( OUString() );
2801 pItem
->SetPitch( aFont
.GetPitch());
2802 pItem
->SetCharSet(aFont
.GetCharSet());
2807 bool SvxRsidItem::QueryValue( uno::Any
& rVal
, sal_uInt8
) const
2809 rVal
<<= GetValue();
2813 bool SvxRsidItem::PutValue( const uno::Any
& rVal
, sal_uInt8
)
2815 sal_uInt32 nRsid
= 0;
2816 if( !( rVal
>>= nRsid
) )
2823 SvxRsidItem
* SvxRsidItem::Clone( SfxItemPool
* ) const
2825 return new SvxRsidItem( *this );
2828 bool SvxRsidItem::GetPresentation
2830 SfxItemPresentation
/*ePres*/,
2831 MapUnit
/*eCoreUnit*/,
2832 MapUnit
/*ePresUnit*/,
2833 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2840 void SvxRsidItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2842 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxRsidItem"));
2843 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
2844 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%" SAL_PRIuUINT32
, GetValue());
2845 (void)xmlTextWriterEndElement(pWriter
);
2848 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */