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/configmgr.hxx>
28 #include <unotools/fontdefs.hxx>
29 #include <unotools/intlwrapper.hxx>
30 #include <unotools/syslocale.hxx>
32 #include <vcl/outdev.hxx>
33 #include <vcl/unohelp.hxx>
34 #include <svtools/unitconv.hxx>
36 #include <editeng/editids.hrc>
37 #include <editeng/editrids.hrc>
38 #include <tools/bigint.hxx>
39 #include <tools/mapunit.hxx>
40 #include <tools/UnitConversion.hxx>
42 #include <rtl/math.hxx>
43 #include <rtl/ustring.hxx>
44 #include <i18nlangtag/languagetag.hxx>
45 #include <svl/itemset.hxx>
47 #include <svtools/langtab.hxx>
48 #include <svl/itempool.hxx>
49 #include <svtools/ctrltool.hxx>
50 #include <com/sun/star/awt/FontSlant.hpp>
51 #include <com/sun/star/lang/Locale.hpp>
52 #include <com/sun/star/text/FontEmphasis.hpp>
53 #include <editeng/rsiditem.hxx>
54 #include <editeng/memberids.h>
55 #include <editeng/flstitem.hxx>
56 #include <editeng/fontitem.hxx>
57 #include <editeng/postitem.hxx>
58 #include <editeng/wghtitem.hxx>
59 #include <editeng/fhgtitem.hxx>
60 #include <editeng/udlnitem.hxx>
61 #include <editeng/crossedoutitem.hxx>
62 #include <editeng/shdditem.hxx>
63 #include <editeng/autokernitem.hxx>
64 #include <editeng/wrlmitem.hxx>
65 #include <editeng/contouritem.hxx>
66 #include <editeng/colritem.hxx>
67 #include <editeng/kernitem.hxx>
68 #include <editeng/cmapitem.hxx>
69 #include <editeng/escapementitem.hxx>
70 #include <editeng/langitem.hxx>
71 #include <editeng/nhypitem.hxx>
72 #include <editeng/blinkitem.hxx>
73 #include <editeng/emphasismarkitem.hxx>
74 #include <editeng/twolinesitem.hxx>
75 #include <editeng/scripttypeitem.hxx>
76 #include <editeng/charrotateitem.hxx>
77 #include <editeng/charscaleitem.hxx>
78 #include <editeng/charreliefitem.hxx>
79 #include <editeng/itemtype.hxx>
80 #include <editeng/eerdll.hxx>
81 #include <docmodel/color/ComplexColorJSON.hxx>
82 #include <docmodel/uno/UnoComplexColor.hxx>
83 #include <docmodel/color/ComplexColor.hxx>
84 #include <libxml/xmlwriter.h>
86 using namespace ::com::sun::star
;
87 using namespace ::com::sun::star::text
;
89 SfxPoolItem
* SvxFontItem::CreateDefault() {return new SvxFontItem(0);}
90 SfxPoolItem
* SvxPostureItem::CreateDefault() { return new SvxPostureItem(ITALIC_NONE
, 0);}
91 SfxPoolItem
* SvxWeightItem::CreateDefault() {return new SvxWeightItem(WEIGHT_NORMAL
, 0);}
92 SfxPoolItem
* SvxFontHeightItem::CreateDefault() {return new SvxFontHeightItem(240, 100, 0);}
93 SfxPoolItem
* SvxUnderlineItem::CreateDefault() {return new SvxUnderlineItem(LINESTYLE_NONE
, 0);}
94 SfxPoolItem
* SvxOverlineItem::CreateDefault() {return new SvxOverlineItem(LINESTYLE_NONE
, 0);}
95 SfxPoolItem
* SvxCrossedOutItem::CreateDefault() {return new SvxCrossedOutItem(STRIKEOUT_NONE
, 0);}
96 SfxPoolItem
* SvxShadowedItem::CreateDefault() {return new SvxShadowedItem(false, 0);}
97 SfxPoolItem
* SvxAutoKernItem::CreateDefault() {return new SvxAutoKernItem(false, 0);}
98 SfxPoolItem
* SvxWordLineModeItem::CreateDefault() {return new SvxWordLineModeItem(false, 0);}
99 SfxPoolItem
* SvxContourItem::CreateDefault() {return new SvxContourItem(false, 0);}
100 SfxPoolItem
* SvxColorItem::CreateDefault() {return new SvxColorItem(0);}
101 SfxPoolItem
* SvxKerningItem::CreateDefault() {return new SvxKerningItem(0, 0);}
102 SfxPoolItem
* SvxCaseMapItem::CreateDefault() {return new SvxCaseMapItem(SvxCaseMap::NotMapped
, 0);}
103 SfxPoolItem
* SvxEscapementItem::CreateDefault() {return new SvxEscapementItem(0);}
104 SfxPoolItem
* SvxLanguageItem::CreateDefault() {return new SvxLanguageItem(LANGUAGE_GERMAN
, 0);}
105 SfxPoolItem
* SvxEmphasisMarkItem::CreateDefault() {return new SvxEmphasisMarkItem(FontEmphasisMark::NONE
, TypedWhichId
<SvxEmphasisMarkItem
>(0));}
106 SfxPoolItem
* SvxCharRotateItem::CreateDefault() {return new SvxCharRotateItem(0_deg10
, false, TypedWhichId
<SvxCharRotateItem
>(0));}
107 SfxPoolItem
* SvxCharScaleWidthItem::CreateDefault() {return new SvxCharScaleWidthItem(100, TypedWhichId
<SvxCharScaleWidthItem
>(0));}
108 SfxPoolItem
* SvxCharReliefItem::CreateDefault() {return new SvxCharReliefItem(FontRelief::NONE
, 0);}
111 // class SvxFontListItem -------------------------------------------------
113 SvxFontListItem::SvxFontListItem( const FontList
* pFontLst
,
114 const sal_uInt16 nId
) :
116 pFontList( pFontLst
)
120 sal_Int32 nCount
= pFontList
->GetFontNameCount();
121 aFontNameSeq
.realloc( nCount
);
122 auto pFontNameSeq
= aFontNameSeq
.getArray();
124 for ( sal_Int32 i
= 0; i
< nCount
; i
++ )
125 pFontNameSeq
[i
] = pFontList
->GetFontName(i
).GetFamilyName();
129 SvxFontListItem
* SvxFontListItem::Clone( SfxItemPool
* ) const
131 return new SvxFontListItem( *this );
134 bool SvxFontListItem::operator==( const SfxPoolItem
& rAttr
) const
136 assert(SfxPoolItem::operator==(rAttr
));
138 return( pFontList
== static_cast<const SvxFontListItem
&>(rAttr
).pFontList
);
141 bool SvxFontListItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
143 rVal
<<= aFontNameSeq
;
148 bool SvxFontListItem::GetPresentation
150 SfxItemPresentation
/*ePres*/,
151 MapUnit
/*eCoreUnit*/,
152 MapUnit
/*ePresUnit*/,
153 OUString
& rText
, const IntlWrapper
& /*rIntl*/
160 // class SvxFontItem -----------------------------------------------------
162 SvxFontItem::SvxFontItem( const sal_uInt16 nId
) :
165 eFamily
= FAMILY_SWISS
;
166 ePitch
= PITCH_VARIABLE
;
167 eTextEncoding
= RTL_TEXTENCODING_DONTKNOW
;
171 SvxFontItem::SvxFontItem( const FontFamily eFam
, OUString aName
,
172 OUString aStName
, const FontPitch eFontPitch
,
173 const rtl_TextEncoding eFontTextEncoding
, const sal_uInt16 nId
) :
177 aFamilyName(std::move(aName
)),
178 aStyleName(std::move(aStName
))
182 eTextEncoding
= eFontTextEncoding
;
186 bool SvxFontItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
188 nMemberId
&= ~CONVERT_TWIPS
;
193 css::awt::FontDescriptor aFontDescriptor
;
194 aFontDescriptor
.Name
= aFamilyName
;
195 aFontDescriptor
.StyleName
= aStyleName
;
196 aFontDescriptor
.Family
= static_cast<sal_Int16
>(eFamily
);
197 aFontDescriptor
.CharSet
= static_cast<sal_Int16
>(eTextEncoding
);
198 aFontDescriptor
.Pitch
= static_cast<sal_Int16
>(ePitch
);
199 rVal
<<= aFontDescriptor
;
202 case MID_FONT_FAMILY_NAME
:
203 rVal
<<= aFamilyName
;
205 case MID_FONT_STYLE_NAME
:
208 case MID_FONT_FAMILY
: rVal
<<= static_cast<sal_Int16
>(eFamily
); break;
209 case MID_FONT_CHAR_SET
: rVal
<<= static_cast<sal_Int16
>(eTextEncoding
); break;
210 case MID_FONT_PITCH
: rVal
<<= static_cast<sal_Int16
>(ePitch
); break;
215 bool SvxFontItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
217 nMemberId
&= ~CONVERT_TWIPS
;
222 css::awt::FontDescriptor aFontDescriptor
;
223 if ( !( rVal
>>= aFontDescriptor
))
226 aFamilyName
= aFontDescriptor
.Name
;
227 aStyleName
= aFontDescriptor
.StyleName
;
228 eFamily
= static_cast<FontFamily
>(aFontDescriptor
.Family
);
229 eTextEncoding
= static_cast<rtl_TextEncoding
>(aFontDescriptor
.CharSet
);
230 ePitch
= static_cast<FontPitch
>(aFontDescriptor
.Pitch
);
233 case MID_FONT_FAMILY_NAME
:
241 case MID_FONT_STYLE_NAME
:
249 case MID_FONT_FAMILY
:
251 sal_Int16 nFamily
= sal_Int16();
252 if(!(rVal
>>= nFamily
))
254 eFamily
= static_cast<FontFamily
>(nFamily
);
257 case MID_FONT_CHAR_SET
:
259 sal_Int16 nSet
= sal_Int16();
262 eTextEncoding
= static_cast<rtl_TextEncoding
>(nSet
);
265 case MID_FONT_PITCH
:
267 sal_Int16 nPitch
= sal_Int16();
268 if(!(rVal
>>= nPitch
))
270 ePitch
= static_cast<FontPitch
>(nPitch
);
278 bool SvxFontItem::operator==( const SfxPoolItem
& rAttr
) const
280 assert(SfxPoolItem::operator==(rAttr
));
282 const SvxFontItem
& rItem
= static_cast<const SvxFontItem
&>(rAttr
);
284 bool bRet
= ( eFamily
== rItem
.eFamily
&&
285 aFamilyName
== rItem
.aFamilyName
&&
286 aStyleName
== rItem
.aStyleName
);
290 if ( ePitch
!= rItem
.ePitch
|| eTextEncoding
!= rItem
.eTextEncoding
)
293 SAL_INFO( "editeng.items", "FontItem::operator==(): only pitch or rtl_TextEncoding different ");
299 SvxFontItem
* SvxFontItem::Clone( SfxItemPool
* ) const
301 return new SvxFontItem( *this );
304 bool SvxFontItem::GetPresentation
306 SfxItemPresentation
/*ePres*/,
307 MapUnit
/*eCoreUnit*/,
308 MapUnit
/*ePresUnit*/,
309 OUString
& rText
, const IntlWrapper
& /*rIntl*/
317 void SvxFontItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
319 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxFontItem"));
320 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
321 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("familyName"), BAD_CAST(aFamilyName
.toUtf8().getStr()));
322 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("styleName"), BAD_CAST(aStyleName
.toUtf8().getStr()));
323 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("family"), BAD_CAST(OString::number(eFamily
).getStr()));
324 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("pitch"), BAD_CAST(OString::number(ePitch
).getStr()));
325 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("textEncoding"), BAD_CAST(OString::number(eTextEncoding
).getStr()));
326 (void)xmlTextWriterEndElement(pWriter
);
329 // class SvxPostureItem --------------------------------------------------
331 SvxPostureItem::SvxPostureItem( const FontItalic ePosture
, const sal_uInt16 nId
) :
332 SfxEnumItem( nId
, ePosture
)
336 SvxPostureItem
* SvxPostureItem::Clone( SfxItemPool
* ) const
338 return new SvxPostureItem( *this );
341 sal_uInt16
SvxPostureItem::GetValueCount() const
343 return ITALIC_NORMAL
+ 1; // ITALIC_NONE also belongs here
347 bool SvxPostureItem::GetPresentation
349 SfxItemPresentation
/*ePres*/,
350 MapUnit
/*eCoreUnit*/,
351 MapUnit
/*ePresUnit*/,
352 OUString
& rText
, const IntlWrapper
& /*rIntl*/
355 rText
= GetValueTextByPos( GetValue() );
360 OUString
SvxPostureItem::GetValueTextByPos( sal_uInt16 nPos
)
362 DBG_ASSERT( nPos
<= sal_uInt16(ITALIC_NORMAL
), "enum overflow!" );
364 FontItalic eItalic
= static_cast<FontItalic
>(nPos
);
369 case ITALIC_NONE
: pId
= RID_SVXITEMS_ITALIC_NONE
; break;
370 case ITALIC_OBLIQUE
: pId
= RID_SVXITEMS_ITALIC_OBLIQUE
; break;
371 case ITALIC_NORMAL
: pId
= RID_SVXITEMS_ITALIC_NORMAL
; break;
372 default: ;//prevent warning
375 return pId
? EditResId(pId
) : OUString();
378 bool SvxPostureItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
380 nMemberId
&= ~CONVERT_TWIPS
;
384 rVal
<<= GetBoolValue();
387 rVal
<<= vcl::unohelper::ConvertFontSlant(GetValue());
393 bool SvxPostureItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
395 nMemberId
&= ~CONVERT_TWIPS
;
399 SetBoolValue(Any2Bool(rVal
));
403 awt::FontSlant eSlant
;
404 if(!(rVal
>>= eSlant
))
406 sal_Int32 nValue
= 0;
407 if(!(rVal
>>= nValue
))
410 eSlant
= static_cast<awt::FontSlant
>(nValue
);
412 SetValue(vcl::unohelper::ConvertFontSlant(eSlant
));
418 bool SvxPostureItem::HasBoolValue() const
423 bool SvxPostureItem::GetBoolValue() const
425 return ( GetValue() >= ITALIC_OBLIQUE
);
428 void SvxPostureItem::SetBoolValue( bool bVal
)
430 SetValue( bVal
? ITALIC_NORMAL
: ITALIC_NONE
);
433 void SvxPostureItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
435 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxPostureItem"));
436 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
437 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%d", GetValue());
438 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr()));
439 (void)xmlTextWriterEndElement(pWriter
);
442 // class SvxWeightItem ---------------------------------------------------
444 SvxWeightItem::SvxWeightItem( const FontWeight eWght
, const sal_uInt16 nId
) :
445 SfxEnumItem( nId
, eWght
)
450 bool SvxWeightItem::HasBoolValue() const
456 bool SvxWeightItem::GetBoolValue() const
458 return GetValue() >= WEIGHT_BOLD
;
462 void SvxWeightItem::SetBoolValue( bool bVal
)
464 SetValue( bVal
? WEIGHT_BOLD
: WEIGHT_NORMAL
);
468 sal_uInt16
SvxWeightItem::GetValueCount() const
470 return WEIGHT_BLACK
; // WEIGHT_DONTKNOW does not belong
473 SvxWeightItem
* SvxWeightItem::Clone( SfxItemPool
* ) const
475 return new SvxWeightItem( *this );
478 bool SvxWeightItem::GetPresentation
480 SfxItemPresentation
/*ePres*/,
481 MapUnit
/*eCoreUnit*/,
482 MapUnit
/*ePresUnit*/,
483 OUString
& rText
, const IntlWrapper
& /*rIntl*/
486 rText
= GetValueTextByPos( GetValue() );
490 OUString
SvxWeightItem::GetValueTextByPos( sal_uInt16 nPos
)
492 static TranslateId RID_SVXITEMS_WEIGHTS
[] =
494 RID_SVXITEMS_WEIGHT_DONTKNOW
,
495 RID_SVXITEMS_WEIGHT_THIN
,
496 RID_SVXITEMS_WEIGHT_ULTRALIGHT
,
497 RID_SVXITEMS_WEIGHT_LIGHT
,
498 RID_SVXITEMS_WEIGHT_SEMILIGHT
,
499 RID_SVXITEMS_WEIGHT_NORMAL
,
500 RID_SVXITEMS_WEIGHT_MEDIUM
,
501 RID_SVXITEMS_WEIGHT_SEMIBOLD
,
502 RID_SVXITEMS_WEIGHT_BOLD
,
503 RID_SVXITEMS_WEIGHT_ULTRABOLD
,
504 RID_SVXITEMS_WEIGHT_BLACK
507 static_assert(std::size(RID_SVXITEMS_WEIGHTS
) - 1 == WEIGHT_BLACK
, "must match");
508 assert(nPos
<= sal_uInt16(WEIGHT_BLACK
) && "enum overflow!" );
509 return EditResId(RID_SVXITEMS_WEIGHTS
[nPos
]);
512 bool SvxWeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
514 nMemberId
&= ~CONVERT_TWIPS
;
518 rVal
<<= GetBoolValue();
522 rVal
<<= vcl::unohelper::ConvertFontWeight( GetValue() );
529 bool SvxWeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
531 nMemberId
&= ~CONVERT_TWIPS
;
535 SetBoolValue(Any2Bool(rVal
));
540 if(!(rVal
>>= fValue
))
542 sal_Int32 nValue
= 0;
543 if(!(rVal
>>= nValue
))
545 fValue
= static_cast<float>(nValue
);
547 SetValue( vcl::unohelper::ConvertFontWeight(static_cast<float>(fValue
)) );
554 void SvxWeightItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
556 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxWeightItem"));
557 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
558 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%d", GetValue());
559 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr()));
560 (void)xmlTextWriterEndElement(pWriter
);
563 // class SvxFontHeightItem -----------------------------------------------
565 SvxFontHeightItem::SvxFontHeightItem( const sal_uInt32 nSz
,
566 const sal_uInt16 nPrp
,
567 const sal_uInt16 nId
) :
570 SetHeight( nSz
,nPrp
); // calculate in percentage
573 SvxFontHeightItem
* SvxFontHeightItem::Clone( SfxItemPool
* ) const
575 return new SvxFontHeightItem( *this );
578 bool SvxFontHeightItem::operator==( const SfxPoolItem
& rItem
) const
580 assert(SfxPoolItem::operator==(rItem
));
581 return GetHeight() == static_cast<const SvxFontHeightItem
&>(rItem
).GetHeight() &&
582 GetProp() == static_cast<const SvxFontHeightItem
&>(rItem
).GetProp() &&
583 GetPropUnit() == static_cast<const SvxFontHeightItem
&>(rItem
).GetPropUnit();
586 bool SvxFontHeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
588 // In StarOne is the uno::Any always 1/100mm. Through the MemberId it is
589 // controlled if the value in the Item should be 1/100mm or Twips.
591 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
592 nMemberId
&= ~CONVERT_TWIPS
;
597 css::frame::status::FontHeight aFontHeight
;
599 // Point (i.e. Twips) is asked for, thus re-calculate if
600 // CONVERT_TWIPS is not set.
603 aFontHeight
.Height
= o3tl::convert
<double>(nHeight
, o3tl::Length::twip
, o3tl::Length::pt
);
607 double fPoints
= o3tl::convert
<double>(nHeight
, o3tl::Length::mm100
, o3tl::Length::pt
);
608 aFontHeight
.Height
= rtl::math::round(fPoints
, 1);
611 aFontHeight
.Prop
= MapUnit::MapRelative
== ePropUnit
? nProp
: 100;
616 case MapUnit::MapRelative
:
619 case MapUnit::Map100thMM
:
620 fRet
= o3tl::convert(fRet
, o3tl::Length::mm100
, o3tl::Length::pt
);
622 case MapUnit::MapPoint
:
625 case MapUnit::MapTwip
:
626 fRet
= o3tl::convert(fRet
, o3tl::Length::twip
, o3tl::Length::pt
);
628 default: ;//prevent warning
630 aFontHeight
.Diff
= fRet
;
631 rVal
<<= aFontHeight
;
636 // Point (i.e. Twips) is asked for, thus re-calculate if
637 // CONVERT_TWIPS is not set.
640 rVal
<<= static_cast<float>(o3tl::convert
<double>(nHeight
, o3tl::Length::twip
, o3tl::Length::pt
));
644 double fPoints
= o3tl::convert
<double>(nHeight
, o3tl::Length::mm100
, o3tl::Length::pt
);
645 rVal
<<= static_cast<float>(::rtl::math::round(fPoints
, 1));
649 case MID_FONTHEIGHT_PROP
:
650 rVal
<<= static_cast<sal_Int16
>(MapUnit::MapRelative
== ePropUnit
? nProp
: 100);
652 case MID_FONTHEIGHT_DIFF
:
657 case MapUnit::MapRelative
:
660 case MapUnit::Map100thMM
:
661 fRet
= o3tl::convert(fRet
, o3tl::Length::mm100
, o3tl::Length::pt
);
663 case MapUnit::MapPoint
:
666 case MapUnit::MapTwip
:
667 fRet
= o3tl::convert(fRet
, o3tl::Length::twip
, o3tl::Length::pt
);
669 default: ;//prevent warning
678 // Try to reconstruct the original height input value from the modified height
679 // and the prop data; this seems somewhat futile given the various ways how the
680 // modified height is calculated (with and without conversion between twips and
681 // 100th mm; with an additional eCoreMetric input in one of the SetHeight
682 // overloads), and indeed known to occasionally produce nRet values that would
683 // be negative, so just guard against negative results here and throw the hands
685 static sal_uInt32
lcl_GetRealHeight_Impl(sal_uInt32 nHeight
, sal_uInt16 nProp
, MapUnit eProp
, bool bCoreInTwip
)
687 sal_uInt32 nRet
= nHeight
;
691 case MapUnit::MapRelative
:
698 case MapUnit::MapPoint
:
700 short nTemp
= static_cast<short>(nProp
);
703 nDiff
= static_cast<short>(convertTwipToMm100(static_cast<tools::Long
>(nDiff
)));
706 case MapUnit::Map100thMM
:
707 //then the core is surely also in 1/100 mm
708 nDiff
= static_cast<short>(nProp
);
710 case MapUnit::MapTwip
:
712 nDiff
= static_cast<short>(nProp
);
717 nRet
= (nDiff
< 0 || nRet
>= o3tl::make_unsigned(nDiff
))
719 //TODO: overflow in case nDiff < 0 and nRet - nDiff > SAL_MAX_UINT32
724 bool SvxFontHeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
726 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
727 nMemberId
&= ~CONVERT_TWIPS
;
732 css::frame::status::FontHeight aFontHeight
;
733 if ( rVal
>>= aFontHeight
)
736 ePropUnit
= MapUnit::MapRelative
;
738 double fPoint
= aFontHeight
.Height
;
739 if( fPoint
< 0. || fPoint
> 10000. )
742 nHeight
= static_cast<tools::Long
>( fPoint
* 20.0 + 0.5 ); // Twips
744 nHeight
= convertTwipToMm100(nHeight
); // Convert, if the item contains 1/100mm
746 nProp
= aFontHeight
.Prop
;
754 ePropUnit
= MapUnit::MapRelative
;
757 if(!(rVal
>>= fPoint
))
759 sal_Int32 nValue
= 0;
760 if(!(rVal
>>= nValue
))
762 fPoint
= static_cast<float>(nValue
);
765 if (fPoint
< 0. || fPoint
> 10000.)
767 static bool bFuzzing
= utl::ConfigManager::IsFuzzing();
768 if (bFuzzing
&& fPoint
> 240)
770 SAL_WARN("editeng.items", "SvxFontHeightItem ignoring font size of " << fPoint
<< " for performance");
774 nHeight
= static_cast<tools::Long
>( fPoint
* 20.0 + 0.5 ); // Twips
776 nHeight
= convertTwipToMm100(nHeight
); // Convert, if the item contains 1/100mm
779 case MID_FONTHEIGHT_PROP
:
781 sal_Int16 nNew
= sal_Int16();
785 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
790 ePropUnit
= MapUnit::MapRelative
;
793 case MID_FONTHEIGHT_DIFF
:
795 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
797 if(!(rVal
>>= fValue
))
799 sal_Int32 nValue
= 0;
800 if(!(rVal
>>= nValue
))
802 fValue
= static_cast<float>(nValue
);
804 sal_Int16 nCoreDiffValue
= static_cast<sal_Int16
>(fValue
* 20.);
805 nHeight
+= bConvert
? nCoreDiffValue
: convertTwipToMm100(nCoreDiffValue
);
806 nProp
= static_cast<sal_uInt16
>(static_cast<sal_Int16
>(fValue
));
807 ePropUnit
= MapUnit::MapPoint
;
815 bool SvxFontHeightItem::GetPresentation
817 SfxItemPresentation
/*ePres*/,
819 MapUnit
/*ePresUnit*/,
820 OUString
& rText
, const IntlWrapper
& rIntl
823 if( MapUnit::MapRelative
!= ePropUnit
)
825 rText
= OUString::number( static_cast<short>(nProp
) ) +
826 " " + EditResId( GetMetricId( ePropUnit
) );
827 if( 0 <= static_cast<short>(nProp
) )
830 else if( 100 == nProp
)
832 rText
= GetMetricText( static_cast<tools::Long
>(nHeight
),
833 eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
834 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
837 rText
= OUString::number( nProp
) + "%";
842 void SvxFontHeightItem::ScaleMetrics( tools::Long nMult
, tools::Long nDiv
)
844 nHeight
= static_cast<sal_uInt32
>(BigInt::Scale( nHeight
, nMult
, nDiv
));
848 bool SvxFontHeightItem::HasMetrics() const
853 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, const sal_uInt16 nNewProp
,
856 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
858 if( MapUnit::MapRelative
!= eUnit
)
859 nHeight
= nNewHeight
+ ::ItemToControl( short(nNewProp
), eUnit
,
861 else if( 100 != nNewProp
)
862 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
864 nHeight
= nNewHeight
;
870 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, sal_uInt16 nNewProp
,
871 MapUnit eMetric
, MapUnit eCoreMetric
)
873 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
875 if( MapUnit::MapRelative
!= eMetric
)
876 nHeight
= nNewHeight
+
877 ::ControlToItem( ::ItemToControl(static_cast<short>(nNewProp
), eMetric
,
878 FieldUnit::TWIP
), FieldUnit::TWIP
,
880 else if( 100 != nNewProp
)
881 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
883 nHeight
= nNewHeight
;
889 void SvxFontHeightItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
891 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxFontHeightItem"));
892 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
893 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("height"), BAD_CAST(OString::number(nHeight
).getStr()));
894 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("prop"), BAD_CAST(OString::number(nProp
).getStr()));
895 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("propUnit"), BAD_CAST(OString::number(static_cast<int>(ePropUnit
)).getStr()));
896 (void)xmlTextWriterEndElement(pWriter
);
899 // class SvxTextLineItem ------------------------------------------------
901 SvxTextLineItem::SvxTextLineItem( const FontLineStyle eSt
, const sal_uInt16 nId
)
902 : SfxEnumItem(nId
, eSt
)
903 , maColor(COL_TRANSPARENT
)
908 bool SvxTextLineItem::HasBoolValue() const
914 bool SvxTextLineItem::GetBoolValue() const
916 return GetValue() != LINESTYLE_NONE
;
920 void SvxTextLineItem::SetBoolValue( bool bVal
)
922 SetValue( bVal
? LINESTYLE_SINGLE
: LINESTYLE_NONE
);
925 SvxTextLineItem
* SvxTextLineItem::Clone( SfxItemPool
* ) const
927 return new SvxTextLineItem( *this );
930 sal_uInt16
SvxTextLineItem::GetValueCount() const
932 return LINESTYLE_DOTTED
+ 1; // LINESTYLE_NONE also belongs here
936 bool SvxTextLineItem::GetPresentation
938 SfxItemPresentation
/*ePres*/,
939 MapUnit
/*eCoreUnit*/,
940 MapUnit
/*ePresUnit*/,
941 OUString
& rText
, const IntlWrapper
& /*rIntl*/
944 rText
= GetValueTextByPos( GetValue() );
945 if( !maColor
.IsTransparent() )
946 rText
+= cpDelim
+ ::GetColorString(maColor
);
951 OUString
SvxTextLineItem::GetValueTextByPos( sal_uInt16
/*nPos*/ ) const
953 OSL_FAIL("SvxTextLineItem::GetValueTextByPos: Pure virtual method");
957 bool SvxTextLineItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
959 nMemberId
&= ~CONVERT_TWIPS
;
963 rVal
<<= GetBoolValue();
966 rVal
<<= static_cast<sal_Int16
>(GetValue());
971 case MID_TL_COMPLEX_COLOR
:
973 auto xComplexColor
= model::color::createXComplexColor(maComplexColor
);
974 rVal
<<= xComplexColor
;
977 case MID_TL_HASCOLOR
:
978 rVal
<<= maColor
.GetAlpha() == 255;
984 bool SvxTextLineItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
986 nMemberId
&= ~CONVERT_TWIPS
;
991 SetBoolValue(Any2Bool(rVal
));
995 sal_Int32 nValue
= 0;
996 if(!(rVal
>>= nValue
))
999 SetValue(static_cast<FontLineStyle
>(nValue
));
1005 if( !( rVal
>>= nCol
) )
1009 // Keep transparence, because it contains the information
1010 // whether the font color or the stored color should be used
1011 sal_uInt8 nAlpha
= maColor
.GetAlpha();
1013 maColor
.SetAlpha( nAlpha
);
1017 case MID_TL_COMPLEX_COLOR
:
1019 css::uno::Reference
<css::util::XComplexColor
> xComplexColor
;
1020 if (!(rVal
>>= xComplexColor
))
1023 if (xComplexColor
.is())
1024 maComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
1027 case MID_TL_HASCOLOR
:
1028 maColor
.SetAlpha( Any2Bool( rVal
) ? 255 : 0 );
1034 bool SvxTextLineItem::operator==( const SfxPoolItem
& rItem
) const
1036 return SfxEnumItem::operator==( rItem
) &&
1037 maColor
== static_cast<const SvxTextLineItem
&>(rItem
).maColor
&&
1038 maComplexColor
== static_cast<const SvxTextLineItem
&>(rItem
).maComplexColor
;
1041 // class SvxUnderlineItem ------------------------------------------------
1044 SvxUnderlineItem::SvxUnderlineItem( const FontLineStyle eSt
, const sal_uInt16 nId
)
1045 : SvxTextLineItem( eSt
, nId
)
1049 SvxUnderlineItem
* SvxUnderlineItem::Clone( SfxItemPool
* ) const
1051 return new SvxUnderlineItem( *this );
1054 OUString
SvxUnderlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1056 static TranslateId RID_SVXITEMS_UL
[] =
1058 RID_SVXITEMS_UL_NONE
,
1059 RID_SVXITEMS_UL_SINGLE
,
1060 RID_SVXITEMS_UL_DOUBLE
,
1061 RID_SVXITEMS_UL_DOTTED
,
1062 RID_SVXITEMS_UL_DONTKNOW
,
1063 RID_SVXITEMS_UL_DASH
,
1064 RID_SVXITEMS_UL_LONGDASH
,
1065 RID_SVXITEMS_UL_DASHDOT
,
1066 RID_SVXITEMS_UL_DASHDOTDOT
,
1067 RID_SVXITEMS_UL_SMALLWAVE
,
1068 RID_SVXITEMS_UL_WAVE
,
1069 RID_SVXITEMS_UL_DOUBLEWAVE
,
1070 RID_SVXITEMS_UL_BOLD
,
1071 RID_SVXITEMS_UL_BOLDDOTTED
,
1072 RID_SVXITEMS_UL_BOLDDASH
,
1073 RID_SVXITEMS_UL_BOLDLONGDASH
,
1074 RID_SVXITEMS_UL_BOLDDASHDOT
,
1075 RID_SVXITEMS_UL_BOLDDASHDOTDOT
,
1076 RID_SVXITEMS_UL_BOLDWAVE
1078 static_assert(std::size(RID_SVXITEMS_UL
) - 1 == LINESTYLE_BOLDWAVE
, "must match");
1079 assert(nPos
<= sal_uInt16(LINESTYLE_BOLDWAVE
) && "enum overflow!");
1080 return EditResId(RID_SVXITEMS_UL
[nPos
]);
1083 // class SvxOverlineItem ------------------------------------------------
1085 SvxOverlineItem::SvxOverlineItem( const FontLineStyle eSt
, const sal_uInt16 nId
)
1086 : SvxTextLineItem( eSt
, nId
)
1090 SvxOverlineItem
* SvxOverlineItem::Clone( SfxItemPool
* ) const
1092 return new SvxOverlineItem( *this );
1095 OUString
SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1097 static TranslateId RID_SVXITEMS_OL
[] =
1099 RID_SVXITEMS_OL_NONE
,
1100 RID_SVXITEMS_OL_SINGLE
,
1101 RID_SVXITEMS_OL_DOUBLE
,
1102 RID_SVXITEMS_OL_DOTTED
,
1103 RID_SVXITEMS_OL_DONTKNOW
,
1104 RID_SVXITEMS_OL_DASH
,
1105 RID_SVXITEMS_OL_LONGDASH
,
1106 RID_SVXITEMS_OL_DASHDOT
,
1107 RID_SVXITEMS_OL_DASHDOTDOT
,
1108 RID_SVXITEMS_OL_SMALLWAVE
,
1109 RID_SVXITEMS_OL_WAVE
,
1110 RID_SVXITEMS_OL_DOUBLEWAVE
,
1111 RID_SVXITEMS_OL_BOLD
,
1112 RID_SVXITEMS_OL_BOLDDOTTED
,
1113 RID_SVXITEMS_OL_BOLDDASH
,
1114 RID_SVXITEMS_OL_BOLDLONGDASH
,
1115 RID_SVXITEMS_OL_BOLDDASHDOT
,
1116 RID_SVXITEMS_OL_BOLDDASHDOTDOT
,
1117 RID_SVXITEMS_OL_BOLDWAVE
1119 static_assert(std::size(RID_SVXITEMS_OL
) - 1 == LINESTYLE_BOLDWAVE
, "must match");
1120 assert(nPos
<= sal_uInt16(LINESTYLE_BOLDWAVE
) && "enum overflow!");
1121 return EditResId(RID_SVXITEMS_OL
[nPos
]);
1124 // class SvxCrossedOutItem -----------------------------------------------
1126 SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt
, const sal_uInt16 nId
)
1127 : SfxEnumItem( nId
, eSt
)
1132 bool SvxCrossedOutItem::HasBoolValue() const
1138 bool SvxCrossedOutItem::GetBoolValue() const
1140 return GetValue() != STRIKEOUT_NONE
;
1144 void SvxCrossedOutItem::SetBoolValue( bool bVal
)
1146 SetValue( bVal
? STRIKEOUT_SINGLE
: STRIKEOUT_NONE
);
1150 sal_uInt16
SvxCrossedOutItem::GetValueCount() const
1152 return STRIKEOUT_DOUBLE
+ 1; // STRIKEOUT_NONE belongs also here
1155 SvxCrossedOutItem
* SvxCrossedOutItem::Clone( SfxItemPool
* ) const
1157 return new SvxCrossedOutItem( *this );
1160 bool SvxCrossedOutItem::GetPresentation
1162 SfxItemPresentation
/*ePres*/,
1163 MapUnit
/*eCoreUnit*/,
1164 MapUnit
/*ePresUnit*/,
1165 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1168 rText
= GetValueTextByPos( GetValue() );
1172 OUString
SvxCrossedOutItem::GetValueTextByPos( sal_uInt16 nPos
)
1174 static TranslateId RID_SVXITEMS_STRIKEOUT
[] =
1176 RID_SVXITEMS_STRIKEOUT_NONE
,
1177 RID_SVXITEMS_STRIKEOUT_SINGLE
,
1178 RID_SVXITEMS_STRIKEOUT_DOUBLE
,
1179 RID_SVXITEMS_STRIKEOUT_DONTKNOW
,
1180 RID_SVXITEMS_STRIKEOUT_BOLD
,
1181 RID_SVXITEMS_STRIKEOUT_SLASH
,
1182 RID_SVXITEMS_STRIKEOUT_X
1184 static_assert(std::size(RID_SVXITEMS_STRIKEOUT
) - 1 == STRIKEOUT_X
, "must match");
1185 assert(nPos
<= sal_uInt16(STRIKEOUT_X
) && "enum overflow!");
1186 return EditResId(RID_SVXITEMS_STRIKEOUT
[nPos
]);
1189 bool SvxCrossedOutItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1191 nMemberId
&= ~CONVERT_TWIPS
;
1194 case MID_CROSSED_OUT
:
1195 rVal
<<= GetBoolValue();
1198 rVal
<<= static_cast<sal_Int16
>(GetValue());
1204 bool SvxCrossedOutItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1206 nMemberId
&= ~CONVERT_TWIPS
;
1209 case MID_CROSSED_OUT
:
1210 SetBoolValue(Any2Bool(rVal
));
1214 sal_Int32 nValue
= 0;
1215 if(!(rVal
>>= nValue
))
1217 SetValue(static_cast<FontStrikeout
>(nValue
));
1223 // class SvxShadowedItem -------------------------------------------------
1225 SvxShadowedItem::SvxShadowedItem( const bool bShadowed
, const sal_uInt16 nId
) :
1226 SfxBoolItem( nId
, bShadowed
)
1230 SvxShadowedItem
* SvxShadowedItem::Clone( SfxItemPool
* ) const
1232 return new SvxShadowedItem( *this );
1235 bool SvxShadowedItem::GetPresentation
1237 SfxItemPresentation
/*ePres*/,
1238 MapUnit
/*eCoreUnit*/,
1239 MapUnit
/*ePresUnit*/,
1240 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1243 TranslateId pId
= RID_SVXITEMS_SHADOWED_FALSE
;
1246 pId
= RID_SVXITEMS_SHADOWED_TRUE
;
1247 rText
= EditResId(pId
);
1251 // class SvxAutoKernItem -------------------------------------------------
1253 SvxAutoKernItem::SvxAutoKernItem( const bool bAutoKern
, const sal_uInt16 nId
) :
1254 SfxBoolItem( nId
, bAutoKern
)
1258 SvxAutoKernItem
* SvxAutoKernItem::Clone( SfxItemPool
* ) const
1260 return new SvxAutoKernItem( *this );
1263 bool SvxAutoKernItem::GetPresentation
1265 SfxItemPresentation
/*ePres*/,
1266 MapUnit
/*eCoreUnit*/,
1267 MapUnit
/*ePresUnit*/,
1268 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1271 TranslateId pId
= RID_SVXITEMS_AUTOKERN_FALSE
;
1274 pId
= RID_SVXITEMS_AUTOKERN_TRUE
;
1275 rText
= EditResId(pId
);
1279 // class SvxWordLineModeItem ---------------------------------------------
1281 SvxWordLineModeItem::SvxWordLineModeItem( const bool bWordLineMode
,
1282 const sal_uInt16 nId
) :
1283 SfxBoolItem( nId
, bWordLineMode
)
1287 SvxWordLineModeItem
* SvxWordLineModeItem::Clone( SfxItemPool
* ) const
1289 return new SvxWordLineModeItem( *this );
1292 bool SvxWordLineModeItem::GetPresentation
1294 SfxItemPresentation
/*ePres*/,
1295 MapUnit
/*eCoreUnit*/,
1296 MapUnit
/*ePresUnit*/,
1297 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1300 TranslateId pId
= RID_SVXITEMS_WORDLINE_FALSE
;
1303 pId
= RID_SVXITEMS_WORDLINE_TRUE
;
1304 rText
= EditResId(pId
);
1308 // class SvxContourItem --------------------------------------------------
1310 SvxContourItem::SvxContourItem( const bool bContoured
, const sal_uInt16 nId
) :
1311 SfxBoolItem( nId
, bContoured
)
1315 SvxContourItem
* SvxContourItem::Clone( SfxItemPool
* ) const
1317 return new SvxContourItem( *this );
1320 bool SvxContourItem::GetPresentation
1322 SfxItemPresentation
/*ePres*/,
1323 MapUnit
/*eCoreUnit*/,
1324 MapUnit
/*ePresUnit*/,
1325 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1328 TranslateId pId
= RID_SVXITEMS_CONTOUR_FALSE
;
1331 pId
= RID_SVXITEMS_CONTOUR_TRUE
;
1332 rText
= EditResId(pId
);
1336 // class SvxColorItem ----------------------------------------------------
1337 SvxColorItem::SvxColorItem( const sal_uInt16 nId
) :
1343 SvxColorItem::SvxColorItem( const Color
& rCol
, const sal_uInt16 nId
) :
1349 SvxColorItem::SvxColorItem(Color
const& rColor
, model::ComplexColor
const& rComplexColor
, const sal_uInt16 nId
)
1352 , maComplexColor(rComplexColor
)
1356 SvxColorItem::~SvxColorItem()
1360 bool SvxColorItem::operator==( const SfxPoolItem
& rAttr
) const
1362 assert(SfxPoolItem::operator==(rAttr
));
1363 const SvxColorItem
& rColorItem
= static_cast<const SvxColorItem
&>(rAttr
);
1365 return mColor
== rColorItem
.mColor
&&
1366 maComplexColor
== rColorItem
.maComplexColor
;
1369 bool SvxColorItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1371 nMemberId
&= ~CONVERT_TWIPS
;
1374 case MID_COLOR_ALPHA
:
1376 auto fTransparency
= static_cast<double>(255 - mColor
.GetAlpha()) * 100 / 255;
1377 rVal
<<= static_cast<sal_Int16
>(basegfx::fround(fTransparency
));
1380 case MID_GRAPHIC_TRANSPARENT
:
1382 rVal
<<= mColor
.GetAlpha() == 0;
1385 case MID_COLOR_THEME_INDEX
:
1387 rVal
<<= sal_Int16(maComplexColor
.getThemeColorType());
1390 case MID_COLOR_TINT_OR_SHADE
:
1392 sal_Int16 nValue
= 0;
1393 for (auto const& rTransform
: maComplexColor
.getTransformations())
1395 if (rTransform
.meType
== model::TransformationType::Tint
)
1396 nValue
= rTransform
.mnValue
;
1397 else if (rTransform
.meType
== model::TransformationType::Shade
)
1398 nValue
= -rTransform
.mnValue
;
1403 case MID_COLOR_LUM_MOD
:
1405 sal_Int16 nValue
= 10000;
1406 for (auto const& rTransform
: maComplexColor
.getTransformations())
1408 if (rTransform
.meType
== model::TransformationType::LumMod
)
1409 nValue
= rTransform
.mnValue
;
1414 case MID_COLOR_LUM_OFF
:
1416 sal_Int16 nValue
= 0;
1417 for (auto const& rTransform
: maComplexColor
.getTransformations())
1419 if (rTransform
.meType
== model::TransformationType::LumOff
)
1420 nValue
= rTransform
.mnValue
;
1425 case MID_COMPLEX_COLOR_JSON
:
1427 rVal
<<= OStringToOUString(model::color::convertToJSON(maComplexColor
), RTL_TEXTENCODING_UTF8
);
1430 case MID_COMPLEX_COLOR
:
1432 auto xComplexColor
= model::color::createXComplexColor(maComplexColor
);
1433 rVal
<<= xComplexColor
;
1446 bool SvxColorItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1448 nMemberId
&= ~CONVERT_TWIPS
;
1451 case MID_COLOR_ALPHA
:
1453 sal_Int16 nTransparency
= 0;
1454 bool bRet
= rVal
>>= nTransparency
;
1457 auto fTransparency
= static_cast<double>(nTransparency
) * 255 / 100;
1458 mColor
.SetAlpha(255 - static_cast<sal_uInt8
>(basegfx::fround(fTransparency
)));
1462 case MID_GRAPHIC_TRANSPARENT
:
1464 mColor
.SetAlpha( Any2Bool( rVal
) ? 0 : 255 );
1467 case MID_COLOR_THEME_INDEX
:
1469 sal_Int16 nIndex
= -1;
1470 if (!(rVal
>>= nIndex
))
1472 maComplexColor
.setThemeColor(model::convertToThemeColorType(nIndex
));
1475 case MID_COLOR_TINT_OR_SHADE
:
1477 sal_Int16 nTintShade
= 0;
1478 if (!(rVal
>>= nTintShade
))
1481 maComplexColor
.removeTransformations(model::TransformationType::Tint
);
1482 maComplexColor
.removeTransformations(model::TransformationType::Shade
);
1485 maComplexColor
.addTransformation({model::TransformationType::Tint
, nTintShade
});
1486 else if (nTintShade
< 0)
1488 sal_Int16 nShade
= o3tl::narrowing
<sal_Int16
>(-nTintShade
);
1489 maComplexColor
.addTransformation({model::TransformationType::Shade
, nShade
});
1493 case MID_COLOR_LUM_MOD
:
1495 sal_Int16 nLumMod
= 10000;
1496 if (!(rVal
>>= nLumMod
))
1498 maComplexColor
.removeTransformations(model::TransformationType::LumMod
);
1499 maComplexColor
.addTransformation({model::TransformationType::LumMod
, nLumMod
});
1502 case MID_COLOR_LUM_OFF
:
1504 sal_Int16 nLumOff
= 0;
1505 if (!(rVal
>>= nLumOff
))
1507 maComplexColor
.removeTransformations(model::TransformationType::LumOff
);
1508 maComplexColor
.addTransformation({model::TransformationType::LumOff
, nLumOff
});
1511 case MID_COMPLEX_COLOR_JSON
:
1513 OUString sComplexColorJson
;
1514 if (!(rVal
>>= sComplexColorJson
))
1517 if (sComplexColorJson
.isEmpty())
1520 OString aJSON
= OUStringToOString(sComplexColorJson
, RTL_TEXTENCODING_ASCII_US
);
1521 if (!model::color::convertFromJSON(aJSON
, maComplexColor
))
1525 case MID_COMPLEX_COLOR
:
1527 css::uno::Reference
<css::util::XComplexColor
> xComplexColor
;
1528 if (!(rVal
>>= xComplexColor
))
1531 if (xComplexColor
.is())
1532 maComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
1538 if (!(rVal
>>= mColor
))
1546 SvxColorItem
* SvxColorItem::Clone( SfxItemPool
* ) const
1548 return new SvxColorItem( *this );
1551 bool SvxColorItem::GetPresentation
1553 SfxItemPresentation
/*ePres*/,
1554 MapUnit
/*eCoreUnit*/,
1555 MapUnit
/*ePresUnit*/,
1556 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1559 rText
= ::GetColorString( mColor
);
1563 void SvxColorItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1565 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxColorItem"));
1566 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1568 std::stringstream ss
;
1570 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(ss
.str().c_str()));
1573 IntlWrapper
aIntlWrapper(SvtSysLocale().GetUILanguageTag());
1574 GetPresentation( SfxItemPresentation::Complete
, MapUnit::Map100thMM
, MapUnit::Map100thMM
, aStr
, aIntlWrapper
);
1575 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(OUStringToOString(aStr
, RTL_TEXTENCODING_UTF8
).getStr()));
1577 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("complex-color"));
1579 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("type"),
1580 BAD_CAST(OString::number(sal_Int16(maComplexColor
.getType())).getStr()));
1582 for (auto const& rTransform
: maComplexColor
.getTransformations())
1584 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("transformation"));
1585 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("type"),
1586 BAD_CAST(OString::number(sal_Int16(rTransform
.meType
)).getStr()));
1587 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"),
1588 BAD_CAST(OString::number(rTransform
.mnValue
).getStr()));
1589 (void)xmlTextWriterEndElement(pWriter
);
1592 (void)xmlTextWriterEndElement(pWriter
);
1594 (void)xmlTextWriterEndElement(pWriter
);
1597 // class SvxKerningItem --------------------------------------------------
1599 SvxKerningItem::SvxKerningItem( const short nKern
, const sal_uInt16 nId
) :
1600 SfxInt16Item( nId
, nKern
)
1604 SvxKerningItem
* SvxKerningItem::Clone( SfxItemPool
* ) const
1606 return new SvxKerningItem( *this );
1609 void SvxKerningItem::ScaleMetrics( tools::Long nMult
, tools::Long nDiv
)
1611 SetValue( static_cast<sal_Int16
>(BigInt::Scale( GetValue(), nMult
, nDiv
)) );
1615 bool SvxKerningItem::HasMetrics() const
1621 bool SvxKerningItem::GetPresentation
1623 SfxItemPresentation ePres
,
1625 MapUnit
/*ePresUnit*/,
1626 OUString
& rText
, const IntlWrapper
& rIntl
1631 case SfxItemPresentation::Nameless
:
1632 rText
= GetMetricText( static_cast<tools::Long
>(GetValue()), eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
1633 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
1635 case SfxItemPresentation::Complete
:
1637 rText
= EditResId(RID_SVXITEMS_KERNING_COMPLETE
);
1640 if ( GetValue() > 0 )
1641 pId
= RID_SVXITEMS_KERNING_EXPANDED
;
1642 else if ( GetValue() < 0 )
1643 pId
= RID_SVXITEMS_KERNING_CONDENSED
;
1646 rText
+= EditResId(pId
);
1647 rText
+= GetMetricText( static_cast<tools::Long
>(GetValue()), eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
1648 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
1651 default: ; //prevent warning
1656 bool SvxKerningItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1658 sal_Int16 nVal
= GetValue();
1659 if(nMemberId
& CONVERT_TWIPS
)
1660 nVal
= static_cast<sal_Int16
>(convertTwipToMm100(nVal
));
1665 bool SvxKerningItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1667 sal_Int16 nVal
= sal_Int16();
1668 if(!(rVal
>>= nVal
))
1670 if(nMemberId
& CONVERT_TWIPS
)
1671 nVal
= o3tl::toTwips(nVal
, o3tl::Length::mm100
);
1676 // class SvxCaseMapItem --------------------------------------------------
1678 SvxCaseMapItem::SvxCaseMapItem( const SvxCaseMap eMap
, const sal_uInt16 nId
) :
1679 SfxEnumItem( nId
, eMap
)
1683 sal_uInt16
SvxCaseMapItem::GetValueCount() const
1685 return sal_uInt16(SvxCaseMap::End
); // SvxCaseMap::SmallCaps + 1
1688 SvxCaseMapItem
* SvxCaseMapItem::Clone( SfxItemPool
* ) const
1690 return new SvxCaseMapItem( *this );
1693 bool SvxCaseMapItem::GetPresentation
1695 SfxItemPresentation
/*ePres*/,
1696 MapUnit
/*eCoreUnit*/,
1697 MapUnit
/*ePresUnit*/,
1698 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1701 rText
= GetValueTextByPos( static_cast<sal_uInt16
>(GetValue()) );
1705 OUString
SvxCaseMapItem::GetValueTextByPos( sal_uInt16 nPos
)
1707 static TranslateId RID_SVXITEMS_CASEMAP
[] =
1709 RID_SVXITEMS_CASEMAP_NONE
,
1710 RID_SVXITEMS_CASEMAP_UPPERCASE
,
1711 RID_SVXITEMS_CASEMAP_LOWERCASE
,
1712 RID_SVXITEMS_CASEMAP_TITLE
,
1713 RID_SVXITEMS_CASEMAP_SMALLCAPS
1716 static_assert(std::size(RID_SVXITEMS_CASEMAP
) == size_t(SvxCaseMap::End
), "must match");
1717 assert(nPos
< sal_uInt16(SvxCaseMap::End
) && "enum overflow!");
1718 return EditResId(RID_SVXITEMS_CASEMAP
[nPos
]);
1721 bool SvxCaseMapItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
1723 sal_Int16 nRet
= style::CaseMap::NONE
;
1724 switch( GetValue() )
1726 case SvxCaseMap::Uppercase
: nRet
= style::CaseMap::UPPERCASE
; break;
1727 case SvxCaseMap::Lowercase
: nRet
= style::CaseMap::LOWERCASE
; break;
1728 case SvxCaseMap::Capitalize
: nRet
= style::CaseMap::TITLE
; break;
1729 case SvxCaseMap::SmallCaps
: nRet
= style::CaseMap::SMALLCAPS
; break;
1736 bool SvxCaseMapItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
1738 sal_uInt16 nVal
= sal_uInt16();
1739 if(!(rVal
>>= nVal
))
1745 case style::CaseMap::NONE
: eVal
= SvxCaseMap::NotMapped
; break;
1746 case style::CaseMap::UPPERCASE
: eVal
= SvxCaseMap::Uppercase
; break;
1747 case style::CaseMap::LOWERCASE
: eVal
= SvxCaseMap::Lowercase
; break;
1748 case style::CaseMap::TITLE
: eVal
= SvxCaseMap::Capitalize
; break;
1749 case style::CaseMap::SMALLCAPS
: eVal
= SvxCaseMap::SmallCaps
; break;
1750 default: return false;
1756 // class SvxEscapementItem -----------------------------------------------
1758 SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId
) :
1759 SfxEnumItemInterface( nId
),
1767 SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape
,
1768 const sal_uInt16 nId
) :
1769 SfxEnumItemInterface( nId
),
1772 SetEscapement( eEscape
);
1774 nProp
= DFLT_ESC_PROP
;
1778 SvxEscapementItem::SvxEscapementItem( const short _nEsc
,
1779 const sal_uInt8 _nProp
,
1780 const sal_uInt16 nId
) :
1781 SfxEnumItemInterface( nId
),
1788 bool SvxEscapementItem::operator==( const SfxPoolItem
& rAttr
) const
1790 assert(SfxPoolItem::operator==(rAttr
));
1792 return( nEsc
== static_cast<const SvxEscapementItem
&>(rAttr
).nEsc
&&
1793 nProp
== static_cast<const SvxEscapementItem
&>(rAttr
).nProp
);
1796 SvxEscapementItem
* SvxEscapementItem::Clone( SfxItemPool
* ) const
1798 return new SvxEscapementItem( *this );
1801 sal_uInt16
SvxEscapementItem::GetValueCount() const
1803 return sal_uInt16(SvxEscapement::End
); // SvxEscapement::Subscript + 1
1807 bool SvxEscapementItem::GetPresentation
1809 SfxItemPresentation
/*ePres*/,
1810 MapUnit
/*eCoreUnit*/,
1811 MapUnit
/*ePresUnit*/,
1812 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1815 rText
= GetValueTextByPos( GetEnumValue() );
1819 if( DFLT_ESC_AUTO_SUPER
== nEsc
|| DFLT_ESC_AUTO_SUB
== nEsc
)
1820 rText
+= EditResId(RID_SVXITEMS_ESCAPEMENT_AUTO
);
1822 rText
+= OUString::number( nEsc
) + "%";
1827 OUString
SvxEscapementItem::GetValueTextByPos( sal_uInt16 nPos
)
1829 static TranslateId RID_SVXITEMS_ESCAPEMENT
[] =
1831 RID_SVXITEMS_ESCAPEMENT_OFF
,
1832 RID_SVXITEMS_ESCAPEMENT_SUPER
,
1833 RID_SVXITEMS_ESCAPEMENT_SUB
1836 static_assert(std::size(RID_SVXITEMS_ESCAPEMENT
) == size_t(SvxEscapement::End
), "must match");
1837 assert(nPos
< sal_uInt16(SvxEscapement::End
) && "enum overflow!");
1838 return EditResId(RID_SVXITEMS_ESCAPEMENT
[nPos
]);
1841 sal_uInt16
SvxEscapementItem::GetEnumValue() const
1844 return sal_uInt16(SvxEscapement::Subscript
);
1845 else if ( nEsc
> 0 )
1846 return sal_uInt16(SvxEscapement::Superscript
);
1847 return sal_uInt16(SvxEscapement::Off
);
1851 void SvxEscapementItem::SetEnumValue( sal_uInt16 nVal
)
1853 SetEscapement( static_cast<SvxEscapement
>(nVal
) );
1856 bool SvxEscapementItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1858 nMemberId
&= ~CONVERT_TWIPS
;
1862 rVal
<<= static_cast<sal_Int16
>(nEsc
);
1864 case MID_ESC_HEIGHT
:
1865 rVal
<<= static_cast<sal_Int8
>(nProp
);
1868 rVal
<<= (DFLT_ESC_AUTO_SUB
== nEsc
|| DFLT_ESC_AUTO_SUPER
== nEsc
);
1874 bool SvxEscapementItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1876 nMemberId
&= ~CONVERT_TWIPS
;
1881 sal_Int16 nVal
= sal_Int16();
1882 if( (rVal
>>= nVal
) && (std::abs(nVal
) <= MAX_ESC_POS
+1))
1888 case MID_ESC_HEIGHT
:
1890 sal_Int8 nVal
= sal_Int8();
1891 if( (rVal
>>= nVal
) && (nVal
<= 100))
1899 bool bVal
= Any2Bool(rVal
);
1903 nEsc
= DFLT_ESC_AUTO_SUB
;
1905 nEsc
= DFLT_ESC_AUTO_SUPER
;
1908 if(DFLT_ESC_AUTO_SUPER
== nEsc
)
1910 else if(DFLT_ESC_AUTO_SUB
== nEsc
)
1918 // class SvxLanguageItem -------------------------------------------------
1920 SvxLanguageItem::SvxLanguageItem( const LanguageType eLang
, const sal_uInt16 nId
)
1921 : SvxLanguageItem_Base( nId
, eLang
)
1926 sal_uInt16
SvxLanguageItem::GetValueCount() const
1928 // #i50205# got rid of class International
1929 SAL_WARN( "editeng.items", "SvxLanguageItem::GetValueCount: supposed to return a count of what?");
1930 // Could be SvtLanguageTable::GetEntryCount() (all locales with resource string)?
1931 // Could be LocaleDataWrapper::getInstalledLanguageTypes() (all locales with locale data)?
1935 SvxLanguageItem
* SvxLanguageItem::Clone( SfxItemPool
* ) const
1937 return new SvxLanguageItem( *this );
1940 bool SvxLanguageItem::GetPresentation
1942 SfxItemPresentation
/*ePres*/,
1943 MapUnit
/*eCoreUnit*/,
1944 MapUnit
/*ePresUnit*/,
1945 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1948 rText
= SvtLanguageTable::GetLanguageString( GetValue() );
1952 bool SvxLanguageItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1954 nMemberId
&= ~CONVERT_TWIPS
;
1957 case MID_LANG_INT
: // for basic conversions!
1958 rVal
<<= static_cast<sal_Int16
>(static_cast<sal_uInt16
>(GetValue()));
1960 case MID_LANG_LOCALE
:
1961 lang::Locale
aRet( LanguageTag::convertToLocale( GetValue(), false));
1968 bool SvxLanguageItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1970 nMemberId
&= ~CONVERT_TWIPS
;
1973 case MID_LANG_INT
: // for basic conversions!
1975 sal_Int32 nValue
= 0;
1976 if(!(rVal
>>= nValue
))
1979 SetValue(LanguageType(nValue
));
1982 case MID_LANG_LOCALE
:
1984 lang::Locale aLocale
;
1985 if(!(rVal
>>= aLocale
))
1988 SetValue( LanguageTag::convertToLanguageType( aLocale
, false));
1995 // class SvxNoHyphenItem -------------------------------------------------
1997 SvxNoHyphenItem::SvxNoHyphenItem( const sal_uInt16 nId
) :
1998 SfxBoolItem( nId
, true )
2002 SvxNoHyphenItem
* SvxNoHyphenItem::Clone( SfxItemPool
* ) const
2004 return new SvxNoHyphenItem( *this );
2007 bool SvxNoHyphenItem::GetPresentation
2009 SfxItemPresentation
/*ePres*/,
2010 MapUnit
/*eCoreUnit*/,
2011 MapUnit
/*ePresUnit*/,
2012 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2020 * Dummy item for ToolBox controls:
2025 // class SvxBlinkItem -------------------------------------------------
2028 SvxBlinkItem::SvxBlinkItem( const bool bBlink
, const sal_uInt16 nId
) :
2029 SfxBoolItem( nId
, bBlink
)
2033 SvxBlinkItem
* SvxBlinkItem::Clone( SfxItemPool
* ) const
2035 return new SvxBlinkItem( *this );
2038 bool SvxBlinkItem::GetPresentation
2040 SfxItemPresentation
/*ePres*/,
2041 MapUnit
/*eCoreUnit*/,
2042 MapUnit
/*ePresUnit*/,
2043 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2046 TranslateId pId
= RID_SVXITEMS_BLINK_FALSE
;
2049 pId
= RID_SVXITEMS_BLINK_TRUE
;
2050 rText
= EditResId(pId
);
2054 // class SvxEmphaisMarkItem ---------------------------------------------------
2056 SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue
,
2057 TypedWhichId
<SvxEmphasisMarkItem
> nId
)
2058 : SfxUInt16Item( nId
, static_cast<sal_uInt16
>(nValue
) )
2062 SvxEmphasisMarkItem
* SvxEmphasisMarkItem::Clone( SfxItemPool
* ) const
2064 return new SvxEmphasisMarkItem( *this );
2067 bool SvxEmphasisMarkItem::GetPresentation
2069 SfxItemPresentation
/*ePres*/,
2070 MapUnit
/*eCoreUnit*/,
2071 MapUnit
/*ePresUnit*/,
2073 const IntlWrapper
& /*rIntl*/
2076 static TranslateId RID_SVXITEMS_EMPHASIS
[] =
2078 RID_SVXITEMS_EMPHASIS_NONE_STYLE
,
2079 RID_SVXITEMS_EMPHASIS_DOT_STYLE
,
2080 RID_SVXITEMS_EMPHASIS_CIRCLE_STYLE
,
2081 RID_SVXITEMS_EMPHASIS_DISC_STYLE
,
2082 RID_SVXITEMS_EMPHASIS_ACCENT_STYLE
2085 FontEmphasisMark nVal
= GetEmphasisMark();
2086 rText
= EditResId(RID_SVXITEMS_EMPHASIS
[
2087 static_cast<sal_uInt16
>(static_cast<FontEmphasisMark
>( nVal
& FontEmphasisMark::Style
))]);
2088 TranslateId pId
= ( FontEmphasisMark::PosAbove
& nVal
)
2089 ? RID_SVXITEMS_EMPHASIS_ABOVE_POS
2090 : ( FontEmphasisMark::PosBelow
& nVal
)
2091 ? RID_SVXITEMS_EMPHASIS_BELOW_POS
2094 rText
+= EditResId( pId
);
2098 bool SvxEmphasisMarkItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2100 nMemberId
&= ~CONVERT_TWIPS
;
2105 FontEmphasisMark nValue
= GetEmphasisMark();
2107 switch(nValue
& FontEmphasisMark::Style
)
2109 case FontEmphasisMark::NONE
: nRet
= FontEmphasis::NONE
; break;
2110 case FontEmphasisMark::Dot
: nRet
= FontEmphasis::DOT_ABOVE
; break;
2111 case FontEmphasisMark::Circle
: nRet
= FontEmphasis::CIRCLE_ABOVE
; break;
2112 case FontEmphasisMark::Disc
: nRet
= FontEmphasis::DISK_ABOVE
; break;
2113 case FontEmphasisMark::Accent
: nRet
= FontEmphasis::ACCENT_ABOVE
; break;
2116 if(nRet
&& nValue
& FontEmphasisMark::PosBelow
)
2125 bool SvxEmphasisMarkItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2127 nMemberId
&= ~CONVERT_TWIPS
;
2132 sal_Int32 nValue
= -1;
2134 FontEmphasisMark nMark
;
2137 case FontEmphasis::NONE
: nMark
= FontEmphasisMark::NONE
; break;
2138 case FontEmphasis::DOT_ABOVE
: nMark
= FontEmphasisMark::Dot
|FontEmphasisMark::PosAbove
; break;
2139 case FontEmphasis::CIRCLE_ABOVE
: nMark
= FontEmphasisMark::Circle
|FontEmphasisMark::PosAbove
; break;
2140 case FontEmphasis::DISK_ABOVE
: nMark
= FontEmphasisMark::Disc
|FontEmphasisMark::PosAbove
; break;
2141 case FontEmphasis::ACCENT_ABOVE
: nMark
= FontEmphasisMark::Accent
|FontEmphasisMark::PosAbove
; break;
2142 case FontEmphasis::DOT_BELOW
: nMark
= FontEmphasisMark::Dot
|FontEmphasisMark::PosBelow
; break;
2143 case FontEmphasis::CIRCLE_BELOW
: nMark
= FontEmphasisMark::Circle
|FontEmphasisMark::PosBelow
; break;
2144 case FontEmphasis::DISK_BELOW
: nMark
= FontEmphasisMark::Disc
|FontEmphasisMark::PosBelow
; break;
2145 case FontEmphasis::ACCENT_BELOW
: nMark
= FontEmphasisMark::Accent
|FontEmphasisMark::PosBelow
; break;
2146 default: return false;
2148 SetValue( static_cast<sal_Int16
>(nMark
) );
2155 /*************************************************************************
2156 |* class SvxTwoLinesItem
2157 *************************************************************************/
2159 SvxTwoLinesItem::SvxTwoLinesItem( bool bFlag
, sal_Unicode nStartBracket
,
2160 sal_Unicode nEndBracket
, sal_uInt16 nW
)
2161 : SfxPoolItem( nW
),
2162 cStartBracket( nStartBracket
), cEndBracket( nEndBracket
), bOn( bFlag
)
2166 SvxTwoLinesItem::~SvxTwoLinesItem()
2170 bool SvxTwoLinesItem::operator==( const SfxPoolItem
& rAttr
) const
2172 assert(SfxPoolItem::operator==(rAttr
));
2173 return bOn
== static_cast<const SvxTwoLinesItem
&>(rAttr
).bOn
&&
2174 cStartBracket
== static_cast<const SvxTwoLinesItem
&>(rAttr
).cStartBracket
&&
2175 cEndBracket
== static_cast<const SvxTwoLinesItem
&>(rAttr
).cEndBracket
;
2178 SvxTwoLinesItem
* SvxTwoLinesItem::Clone( SfxItemPool
* ) const
2180 return new SvxTwoLinesItem( *this );
2183 bool SvxTwoLinesItem::QueryValue( css::uno::Any
& rVal
,
2184 sal_uInt8 nMemberId
) const
2186 nMemberId
&= ~CONVERT_TWIPS
;
2193 case MID_START_BRACKET
:
2197 s
= OUString( cStartBracket
);
2201 case MID_END_BRACKET
:
2205 s
= OUString( cEndBracket
);
2216 bool SvxTwoLinesItem::PutValue( const css::uno::Any
& rVal
,
2217 sal_uInt8 nMemberId
)
2219 nMemberId
&= ~CONVERT_TWIPS
;
2225 bOn
= Any2Bool( rVal
);
2228 case MID_START_BRACKET
:
2231 cStartBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
2235 case MID_END_BRACKET
:
2238 cEndBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
2246 bool SvxTwoLinesItem::GetPresentation( SfxItemPresentation
/*ePres*/,
2247 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2248 OUString
&rText
, const IntlWrapper
& /*rIntl*/ ) const
2251 rText
= EditResId( RID_SVXITEMS_TWOLINES_OFF
);
2254 rText
= EditResId( RID_SVXITEMS_TWOLINES
);
2255 if( GetStartBracket() )
2256 rText
= OUStringChar(GetStartBracket()) + rText
;
2257 if( GetEndBracket() )
2258 rText
+= OUStringChar(GetEndBracket());
2264 /*************************************************************************
2265 |* class SvxTextRotateItem
2266 *************************************************************************/
2268 SvxTextRotateItem::SvxTextRotateItem(Degree10 nValue
, TypedWhichId
<SvxTextRotateItem
> nW
)
2269 : SfxUInt16Item(nW
, nValue
.get())
2273 SvxTextRotateItem
* SvxTextRotateItem::Clone(SfxItemPool
*) const
2275 return new SvxTextRotateItem(*this);
2278 bool SvxTextRotateItem::GetPresentation(
2279 SfxItemPresentation
/*ePres*/,
2280 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2281 OUString
&rText
, const IntlWrapper
&) const
2284 rText
= EditResId(RID_SVXITEMS_TEXTROTATE_OFF
);
2287 rText
= EditResId(RID_SVXITEMS_TEXTROTATE
);
2288 rText
= rText
.replaceFirst("$(ARG1)",
2289 OUString::number(toDegrees(GetValue())));
2294 bool SvxTextRotateItem::QueryValue(css::uno::Any
& rVal
,
2295 sal_uInt8 nMemberId
) const
2297 nMemberId
&= ~CONVERT_TWIPS
;
2302 rVal
<<= static_cast<sal_Int16
>(GetValue());
2311 bool SvxTextRotateItem::PutValue(const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
2313 nMemberId
&= ~CONVERT_TWIPS
;
2320 if ((rVal
>>= nVal
) && (0 == nVal
|| 900 == nVal
|| 2700 == nVal
))
2321 SetValue(Degree10(nVal
));
2332 void SvxTextRotateItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2334 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxTextRotateItem"));
2335 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2336 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue().get()).getStr()));
2337 (void)xmlTextWriterEndElement(pWriter
);
2341 /*************************************************************************
2342 |* class SvxCharRotateItem
2343 *************************************************************************/
2345 SvxCharRotateItem::SvxCharRotateItem( Degree10 nValue
,
2347 TypedWhichId
<SvxCharRotateItem
> nW
)
2348 : SvxTextRotateItem(nValue
, nW
), bFitToLine( bFitIntoLine
)
2352 SvxCharRotateItem
* SvxCharRotateItem::Clone( SfxItemPool
* ) const
2354 return new SvxCharRotateItem( *this );
2357 bool SvxCharRotateItem::GetPresentation(
2358 SfxItemPresentation
/*ePres*/,
2359 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2360 OUString
&rText
, const IntlWrapper
&) const
2363 rText
= EditResId( RID_SVXITEMS_CHARROTATE_OFF
);
2366 rText
= EditResId( RID_SVXITEMS_CHARROTATE
);
2367 rText
= rText
.replaceFirst( "$(ARG1)",
2368 OUString::number( toDegrees(GetValue()) ));
2370 rText
+= EditResId( RID_SVXITEMS_CHARROTATE_FITLINE
);
2375 bool SvxCharRotateItem::QueryValue( css::uno::Any
& rVal
,
2376 sal_uInt8 nMemberId
) const
2379 switch(nMemberId
& ~CONVERT_TWIPS
)
2382 SvxTextRotateItem::QueryValue(rVal
, nMemberId
);
2385 rVal
<<= IsFitToLine();
2394 bool SvxCharRotateItem::PutValue( const css::uno::Any
& rVal
,
2395 sal_uInt8 nMemberId
)
2398 switch(nMemberId
& ~CONVERT_TWIPS
)
2402 bRet
= SvxTextRotateItem::PutValue(rVal
, nMemberId
);
2407 SetFitToLine( Any2Bool( rVal
) );
2415 bool SvxCharRotateItem::operator==( const SfxPoolItem
& rItem
) const
2417 assert(SfxPoolItem::operator==(rItem
));
2418 return SvxTextRotateItem::operator==( rItem
) &&
2419 IsFitToLine() == static_cast<const SvxCharRotateItem
&>(rItem
).IsFitToLine();
2422 void SvxCharRotateItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2424 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxCharRotateItem"));
2425 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2426 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue().get()).getStr()));
2427 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("fitToLine"), BAD_CAST(OString::boolean(IsFitToLine()).getStr()));
2428 (void)xmlTextWriterEndElement(pWriter
);
2431 /*************************************************************************
2432 |* class SvxCharScaleItem
2433 *************************************************************************/
2435 SvxCharScaleWidthItem::SvxCharScaleWidthItem( sal_uInt16 nValue
,
2436 TypedWhichId
<SvxCharScaleWidthItem
> nW
)
2437 : SfxUInt16Item( nW
, nValue
)
2441 SvxCharScaleWidthItem
* SvxCharScaleWidthItem::Clone( SfxItemPool
* ) const
2443 return new SvxCharScaleWidthItem( *this );
2446 bool SvxCharScaleWidthItem::GetPresentation(
2447 SfxItemPresentation
/*ePres*/,
2448 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2449 OUString
&rText
, const IntlWrapper
&) const
2452 rText
= EditResId( RID_SVXITEMS_CHARSCALE_OFF
);
2455 rText
= EditResId( RID_SVXITEMS_CHARSCALE
);
2456 rText
= rText
.replaceFirst( "$(ARG1)",
2457 OUString::number( GetValue() ));
2462 bool SvxCharScaleWidthItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
2464 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
2465 // where we still want this to be a sal_Int16
2466 sal_Int16 nValue
= sal_Int16();
2467 if (rVal
>>= nValue
)
2469 SetValue( static_cast<sal_uInt16
>(nValue
) );
2473 SAL_WARN("editeng.items", "SvxCharScaleWidthItem::PutValue - Wrong type!" );
2477 bool SvxCharScaleWidthItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
2479 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
2480 // where we still want this to be a sal_Int16
2481 rVal
<<= static_cast<sal_Int16
>(GetValue());
2485 /*************************************************************************
2486 |* class SvxCharReliefItem
2487 *************************************************************************/
2489 SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue
,
2490 const sal_uInt16 nId
)
2491 : SfxEnumItem( nId
, eValue
)
2495 SvxCharReliefItem
* SvxCharReliefItem::Clone( SfxItemPool
* ) const
2497 return new SvxCharReliefItem( *this );
2500 static TranslateId RID_SVXITEMS_RELIEF
[] =
2502 RID_SVXITEMS_RELIEF_NONE
,
2503 RID_SVXITEMS_RELIEF_EMBOSSED
,
2504 RID_SVXITEMS_RELIEF_ENGRAVED
2507 OUString
SvxCharReliefItem::GetValueTextByPos(sal_uInt16 nPos
)
2509 assert(nPos
< std::size(RID_SVXITEMS_RELIEF
) && "enum overflow");
2510 return EditResId(RID_SVXITEMS_RELIEF
[nPos
]);
2513 sal_uInt16
SvxCharReliefItem::GetValueCount() const
2515 return std::size(RID_SVXITEMS_RELIEF
) - 1;
2518 bool SvxCharReliefItem::GetPresentation
2520 SfxItemPresentation
/*ePres*/,
2521 MapUnit
/*eCoreUnit*/,
2522 MapUnit
/*ePresUnit*/,
2523 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2526 rText
= GetValueTextByPos( static_cast<sal_uInt16
>(GetValue()) );
2530 bool SvxCharReliefItem::PutValue( const css::uno::Any
& rVal
,
2531 sal_uInt8 nMemberId
)
2533 nMemberId
&= ~CONVERT_TWIPS
;
2539 sal_Int16 nVal
= -1;
2541 if(nVal
>= 0 && nVal
<= sal_Int16(FontRelief::Engraved
))
2542 SetValue( static_cast<FontRelief
>(nVal
) );
2554 bool SvxCharReliefItem::QueryValue( css::uno::Any
& rVal
,
2555 sal_uInt8 nMemberId
) const
2557 nMemberId
&= ~CONVERT_TWIPS
;
2562 rVal
<<= static_cast<sal_Int16
>(GetValue());
2571 /*************************************************************************
2572 |* class SvxScriptSetItem
2573 *************************************************************************/
2575 SvxScriptSetItem::SvxScriptSetItem( sal_uInt16 nSlotId
, SfxItemPool
& rPool
)
2576 : SfxSetItem( nSlotId
, SfxItemSet( rPool
,
2577 svl::Items
<SID_ATTR_CHAR_FONT
, SID_ATTR_CHAR_FONT
> ))
2579 sal_uInt16 nLatin
, nAsian
, nComplex
;
2580 GetWhichIds( nLatin
, nAsian
, nComplex
);
2581 GetItemSet().MergeRange( nLatin
, nLatin
);
2582 GetItemSet().MergeRange( nAsian
, nAsian
);
2583 GetItemSet().MergeRange( nComplex
, nComplex
);
2586 SvxScriptSetItem
* SvxScriptSetItem::Clone( SfxItemPool
* ) const
2588 SvxScriptSetItem
* p
= new SvxScriptSetItem( Which(), *GetItemSet().GetPool() );
2589 p
->GetItemSet().Put( GetItemSet(), false );
2593 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScriptSet(
2594 const SfxItemSet
& rSet
, sal_uInt16 nId
)
2596 const SfxPoolItem
* pI
;
2597 SfxItemState eSt
= rSet
.GetItemState( nId
, false, &pI
);
2598 if( SfxItemState::SET
!= eSt
)
2599 pI
= SfxItemState::DEFAULT
== eSt
? &rSet
.Get( nId
) : nullptr;
2603 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, SvtScriptType nScript
)
2605 sal_uInt16 nLatin
, nAsian
, nComplex
;
2606 GetWhichIds( nSlotId
, rSet
, nLatin
, nAsian
, nComplex
);
2608 const SfxPoolItem
*pRet
, *pAsn
, *pCmplx
;
2609 if (nScript
== SvtScriptType::ASIAN
)
2611 pRet
= GetItemOfScriptSet( rSet
, nAsian
);
2612 } else if (nScript
== SvtScriptType::COMPLEX
)
2614 pRet
= GetItemOfScriptSet( rSet
, nComplex
);
2615 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::ASIAN
))
2617 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2618 nullptr == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2621 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::COMPLEX
))
2623 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2624 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2627 } else if (nScript
== (SvtScriptType::ASIAN
|SvtScriptType::COMPLEX
))
2629 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2630 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2633 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::ASIAN
|SvtScriptType::COMPLEX
))
2635 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2636 nullptr == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2637 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2638 *pRet
!= *pAsn
|| *pRet
!= *pCmplx
)
2641 //no one valid -> match to latin
2642 pRet
= GetItemOfScriptSet( rSet
, nLatin
);
2647 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( SvtScriptType nScript
) const
2649 return GetItemOfScript( Which(), GetItemSet(), nScript
);
2652 void SvxScriptSetItem::PutItemForScriptType( SvtScriptType nScriptType
,
2653 const SfxPoolItem
& rItem
)
2655 sal_uInt16 nLatin
, nAsian
, nComplex
;
2656 GetWhichIds( nLatin
, nAsian
, nComplex
);
2658 if( SvtScriptType::LATIN
& nScriptType
)
2660 GetItemSet().Put( rItem
.CloneSetWhich(nLatin
) );
2662 if( SvtScriptType::ASIAN
& nScriptType
)
2664 GetItemSet().Put( rItem
.CloneSetWhich(nAsian
) );
2666 if( SvtScriptType::COMPLEX
& nScriptType
)
2668 GetItemSet().Put( rItem
.CloneSetWhich(nComplex
) );
2672 void SvxScriptSetItem::GetWhichIds( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, sal_uInt16
& rLatin
, sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
2674 const SfxItemPool
& rPool
= *rSet
.GetPool();
2675 GetSlotIds( nSlotId
, rLatin
, rAsian
, rComplex
);
2676 rLatin
= rPool
.GetWhich( rLatin
);
2677 rAsian
= rPool
.GetWhich( rAsian
);
2678 rComplex
= rPool
.GetWhich( rComplex
);
2681 void SvxScriptSetItem::GetWhichIds( sal_uInt16
& rLatin
, sal_uInt16
& rAsian
,
2682 sal_uInt16
& rComplex
) const
2684 GetWhichIds( Which(), GetItemSet(), rLatin
, rAsian
, rComplex
);
2687 void SvxScriptSetItem::GetSlotIds( sal_uInt16 nSlotId
, sal_uInt16
& rLatin
,
2688 sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
2693 SAL_WARN( "editeng.items", "wrong SlotId for class SvxScriptSetItem" );
2694 [[fallthrough
]]; // default to font - Id Range !!
2696 case SID_ATTR_CHAR_FONT
:
2697 rLatin
= SID_ATTR_CHAR_FONT
;
2698 rAsian
= SID_ATTR_CHAR_CJK_FONT
;
2699 rComplex
= SID_ATTR_CHAR_CTL_FONT
;
2701 case SID_ATTR_CHAR_FONTHEIGHT
:
2702 rLatin
= SID_ATTR_CHAR_FONTHEIGHT
;
2703 rAsian
= SID_ATTR_CHAR_CJK_FONTHEIGHT
;
2704 rComplex
= SID_ATTR_CHAR_CTL_FONTHEIGHT
;
2706 case SID_ATTR_CHAR_WEIGHT
:
2707 rLatin
= SID_ATTR_CHAR_WEIGHT
;
2708 rAsian
= SID_ATTR_CHAR_CJK_WEIGHT
;
2709 rComplex
= SID_ATTR_CHAR_CTL_WEIGHT
;
2711 case SID_ATTR_CHAR_POSTURE
:
2712 rLatin
= SID_ATTR_CHAR_POSTURE
;
2713 rAsian
= SID_ATTR_CHAR_CJK_POSTURE
;
2714 rComplex
= SID_ATTR_CHAR_CTL_POSTURE
;
2716 case SID_ATTR_CHAR_LANGUAGE
:
2717 rLatin
= SID_ATTR_CHAR_LANGUAGE
;
2718 rAsian
= SID_ATTR_CHAR_CJK_LANGUAGE
;
2719 rComplex
= SID_ATTR_CHAR_CTL_LANGUAGE
;
2721 case SID_ATTR_CHAR_SHADOWED
:
2722 rLatin
= SID_ATTR_CHAR_SHADOWED
;
2723 rAsian
= SID_ATTR_CHAR_SHADOWED
;
2724 rComplex
= SID_ATTR_CHAR_SHADOWED
;
2726 case SID_ATTR_CHAR_STRIKEOUT
:
2727 rLatin
= SID_ATTR_CHAR_STRIKEOUT
;
2728 rAsian
= SID_ATTR_CHAR_STRIKEOUT
;
2729 rComplex
= SID_ATTR_CHAR_STRIKEOUT
;
2734 void GetDefaultFonts( SvxFontItem
& rLatin
, SvxFontItem
& rAsian
, SvxFontItem
& rComplex
)
2736 const sal_uInt16 nItemCnt
= 3;
2740 DefaultFontType nFontType
;
2741 LanguageType nLanguage
;
2743 const aOutTypeArr
[ nItemCnt
] =
2745 { DefaultFontType::LATIN_TEXT
, LANGUAGE_ENGLISH_US
},
2746 { DefaultFontType::CJK_TEXT
, LANGUAGE_ENGLISH_US
},
2747 { DefaultFontType::CTL_TEXT
, LANGUAGE_ARABIC_SAUDI_ARABIA
}
2750 SvxFontItem
* aItemArr
[ nItemCnt
] = { &rLatin
, &rAsian
, &rComplex
};
2752 for ( sal_uInt16 n
= 0; n
< nItemCnt
; ++n
)
2754 vcl::Font
aFont( OutputDevice::GetDefaultFont( aOutTypeArr
[ n
].nFontType
,
2755 aOutTypeArr
[ n
].nLanguage
,
2756 GetDefaultFontFlags::OnlyOne
) );
2757 SvxFontItem
* pItem
= aItemArr
[ n
];
2758 pItem
->SetFamily( aFont
.GetFamilyType() );
2759 pItem
->SetFamilyName( aFont
.GetFamilyName() );
2760 pItem
->SetStyleName( OUString() );
2761 pItem
->SetPitch( aFont
.GetPitch());
2762 pItem
->SetCharSet(aFont
.GetCharSet());
2767 bool SvxRsidItem::QueryValue( uno::Any
& rVal
, sal_uInt8
) const
2769 rVal
<<= GetValue();
2773 bool SvxRsidItem::PutValue( const uno::Any
& rVal
, sal_uInt8
)
2775 sal_uInt32 nRsid
= 0;
2776 if( !( rVal
>>= nRsid
) )
2783 SvxRsidItem
* SvxRsidItem::Clone( SfxItemPool
* ) const
2785 return new SvxRsidItem( *this );
2788 bool SvxRsidItem::GetPresentation
2790 SfxItemPresentation
/*ePres*/,
2791 MapUnit
/*eCoreUnit*/,
2792 MapUnit
/*ePresUnit*/,
2793 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2800 void SvxRsidItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2802 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxRsidItem"));
2803 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
2804 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%" SAL_PRIuUINT32
, GetValue());
2805 (void)xmlTextWriterEndElement(pWriter
);
2808 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */