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 <comphelper/configuration.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>
85 #include <unordered_map>
87 using namespace ::com::sun::star
;
88 using namespace ::com::sun::star::text
;
90 SfxPoolItem
* SvxFontItem::CreateDefault() {return new SvxFontItem(0);}
91 SfxPoolItem
* SvxPostureItem::CreateDefault() { return new SvxPostureItem(ITALIC_NONE
, 0);}
92 SfxPoolItem
* SvxWeightItem::CreateDefault() {return new SvxWeightItem(WEIGHT_NORMAL
, 0);}
93 SfxPoolItem
* SvxFontHeightItem::CreateDefault() {return new SvxFontHeightItem(240, 100, 0);}
94 SfxPoolItem
* SvxUnderlineItem::CreateDefault() {return new SvxUnderlineItem(LINESTYLE_NONE
, 0);}
95 SfxPoolItem
* SvxOverlineItem::CreateDefault() {return new SvxOverlineItem(LINESTYLE_NONE
, 0);}
96 SfxPoolItem
* SvxCrossedOutItem::CreateDefault() {return new SvxCrossedOutItem(STRIKEOUT_NONE
, 0);}
97 SfxPoolItem
* SvxShadowedItem::CreateDefault() {return new SvxShadowedItem(false, 0);}
98 SfxPoolItem
* SvxAutoKernItem::CreateDefault() {return new SvxAutoKernItem(false, 0);}
99 SfxPoolItem
* SvxWordLineModeItem::CreateDefault() {return new SvxWordLineModeItem(false, 0);}
100 SfxPoolItem
* SvxContourItem::CreateDefault() {return new SvxContourItem(false, 0);}
101 SfxPoolItem
* SvxColorItem::CreateDefault() {return new SvxColorItem(0);}
102 SfxPoolItem
* SvxKerningItem::CreateDefault() {return new SvxKerningItem(0, 0);}
103 SfxPoolItem
* SvxCaseMapItem::CreateDefault() {return new SvxCaseMapItem(SvxCaseMap::NotMapped
, 0);}
104 SfxPoolItem
* SvxEscapementItem::CreateDefault() {return new SvxEscapementItem(0);}
105 SfxPoolItem
* SvxLanguageItem::CreateDefault() {return new SvxLanguageItem(LANGUAGE_GERMAN
, 0);}
106 SfxPoolItem
* SvxEmphasisMarkItem::CreateDefault() {return new SvxEmphasisMarkItem(FontEmphasisMark::NONE
, TypedWhichId
<SvxEmphasisMarkItem
>(0));}
107 SfxPoolItem
* SvxCharRotateItem::CreateDefault() {return new SvxCharRotateItem(0_deg10
, false, TypedWhichId
<SvxCharRotateItem
>(0));}
108 SfxPoolItem
* SvxCharScaleWidthItem::CreateDefault() {return new SvxCharScaleWidthItem(100, TypedWhichId
<SvxCharScaleWidthItem
>(0));}
109 SfxPoolItem
* SvxCharReliefItem::CreateDefault() {return new SvxCharReliefItem(FontRelief::NONE
, 0);}
111 // class SvxFontListItem -------------------------------------------------
113 SvxFontListItem::SvxFontListItem( const FontList
* pFontLst
,
114 const sal_uInt16 nId
) :
115 SfxPoolItem( nId
, SfxItemType::SvxFontListItemType
),
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 ItemInstanceManager
* SvxFontItem::getItemInstanceManager() const
164 static HashedItemInstanceManager
aInstanceManager(ItemType());
165 return &aInstanceManager
;
168 size_t SvxFontItem::hashCode() const
171 o3tl::hash_combine(seed
, Which());
172 o3tl::hash_combine(seed
, GetFamilyName().hashCode());
173 o3tl::hash_combine(seed
, GetStyleName().hashCode());
174 o3tl::hash_combine(seed
, GetFamily());
175 o3tl::hash_combine(seed
, GetPitch());
176 o3tl::hash_combine(seed
, GetCharSet());
180 SvxFontItem::SvxFontItem(
181 const sal_uInt16 nId
)
182 : SfxPoolItem( nId
, SfxItemType::SvxFontItemType
)
185 , eFamily(FAMILY_SWISS
)
186 , ePitch(PITCH_VARIABLE
)
187 , eTextEncoding(RTL_TEXTENCODING_DONTKNOW
)
191 SvxFontItem::SvxFontItem(
192 const FontFamily eFam
,
195 const FontPitch eFontPitch
,
196 const rtl_TextEncoding eFontTextEncoding
,
197 const sal_uInt16 nId
)
198 : SfxPoolItem( nId
, SfxItemType::SvxFontItemType
)
199 , aFamilyName(std::move(aName
))
200 , aStyleName(std::move(aStName
))
203 , eTextEncoding(eFontTextEncoding
)
207 bool SvxFontItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
209 nMemberId
&= ~CONVERT_TWIPS
;
214 css::awt::FontDescriptor aFontDescriptor
;
215 aFontDescriptor
.Name
= aFamilyName
;
216 aFontDescriptor
.StyleName
= aStyleName
;
217 aFontDescriptor
.Family
= static_cast<sal_Int16
>(eFamily
);
218 aFontDescriptor
.CharSet
= static_cast<sal_Int16
>(eTextEncoding
);
219 aFontDescriptor
.Pitch
= static_cast<sal_Int16
>(ePitch
);
220 rVal
<<= aFontDescriptor
;
223 case MID_FONT_FAMILY_NAME
:
224 rVal
<<= aFamilyName
;
226 case MID_FONT_STYLE_NAME
:
229 case MID_FONT_FAMILY
: rVal
<<= static_cast<sal_Int16
>(eFamily
); break;
230 case MID_FONT_CHAR_SET
: rVal
<<= static_cast<sal_Int16
>(eTextEncoding
); break;
231 case MID_FONT_PITCH
: rVal
<<= static_cast<sal_Int16
>(ePitch
); break;
236 bool SvxFontItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
238 nMemberId
&= ~CONVERT_TWIPS
;
243 css::awt::FontDescriptor aFontDescriptor
;
244 if ( !( rVal
>>= aFontDescriptor
))
247 ASSERT_CHANGE_REFCOUNTED_ITEM
;
248 aFamilyName
= aFontDescriptor
.Name
;
249 aStyleName
= aFontDescriptor
.StyleName
;
250 eFamily
= static_cast<FontFamily
>(aFontDescriptor
.Family
);
251 eTextEncoding
= static_cast<rtl_TextEncoding
>(aFontDescriptor
.CharSet
);
252 ePitch
= static_cast<FontPitch
>(aFontDescriptor
.Pitch
);
255 case MID_FONT_FAMILY_NAME
:
260 ASSERT_CHANGE_REFCOUNTED_ITEM
;
264 case MID_FONT_STYLE_NAME
:
269 ASSERT_CHANGE_REFCOUNTED_ITEM
;
273 case MID_FONT_FAMILY
:
275 sal_Int16 nFamily
= sal_Int16();
276 if(!(rVal
>>= nFamily
))
278 ASSERT_CHANGE_REFCOUNTED_ITEM
;
279 eFamily
= static_cast<FontFamily
>(nFamily
);
282 case MID_FONT_CHAR_SET
:
284 sal_Int16 nSet
= sal_Int16();
287 ASSERT_CHANGE_REFCOUNTED_ITEM
;
288 eTextEncoding
= static_cast<rtl_TextEncoding
>(nSet
);
291 case MID_FONT_PITCH
:
293 sal_Int16 nPitch
= sal_Int16();
294 if(!(rVal
>>= nPitch
))
296 ASSERT_CHANGE_REFCOUNTED_ITEM
;
297 ePitch
= static_cast<FontPitch
>(nPitch
);
304 void SvxFontItem::SetFamilyName(const OUString
& rFamilyName
)
306 if (aFamilyName
== rFamilyName
)
309 ASSERT_CHANGE_REFCOUNTED_ITEM
;
310 aFamilyName
= rFamilyName
;
313 void SvxFontItem::SetStyleName(const OUString
&rStyleName
)
315 if (aStyleName
== rStyleName
)
318 ASSERT_CHANGE_REFCOUNTED_ITEM
;
319 aStyleName
= rStyleName
;
322 void SvxFontItem::SetFamily(FontFamily _eFamily
)
324 if (eFamily
== _eFamily
)
327 ASSERT_CHANGE_REFCOUNTED_ITEM
;
331 void SvxFontItem::SetPitch(FontPitch _ePitch
)
333 if (ePitch
== _ePitch
)
336 ASSERT_CHANGE_REFCOUNTED_ITEM
;
340 void SvxFontItem::SetCharSet(rtl_TextEncoding _eEncoding
)
342 if (eTextEncoding
== _eEncoding
)
345 ASSERT_CHANGE_REFCOUNTED_ITEM
;
346 eTextEncoding
= _eEncoding
;
349 bool SvxFontItem::operator==( const SfxPoolItem
& rAttr
) const
354 assert(SfxPoolItem::operator==(rAttr
));
355 const SvxFontItem
& rItem(static_cast<const SvxFontItem
&>(rAttr
));
356 bool bRet
= ( eFamily
== rItem
.eFamily
&&
357 aFamilyName
== rItem
.aFamilyName
&&
358 aStyleName
== rItem
.aStyleName
);
362 if ( ePitch
!= rItem
.ePitch
|| eTextEncoding
!= rItem
.eTextEncoding
)
365 SAL_INFO( "editeng.items", "FontItem::operator==(): only pitch or rtl_TextEncoding different ");
372 SvxFontItem
* SvxFontItem::Clone( SfxItemPool
* ) const
374 return new SvxFontItem( *this );
377 bool SvxFontItem::GetPresentation
379 SfxItemPresentation
/*ePres*/,
380 MapUnit
/*eCoreUnit*/,
381 MapUnit
/*ePresUnit*/,
382 OUString
& rText
, const IntlWrapper
& /*rIntl*/
390 void SvxFontItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
392 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxFontItem"));
393 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
394 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("familyName"), BAD_CAST(aFamilyName
.toUtf8().getStr()));
395 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("styleName"), BAD_CAST(aStyleName
.toUtf8().getStr()));
396 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("family"), BAD_CAST(OString::number(eFamily
).getStr()));
397 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("pitch"), BAD_CAST(OString::number(ePitch
).getStr()));
398 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("textEncoding"), BAD_CAST(OString::number(eTextEncoding
).getStr()));
399 (void)xmlTextWriterEndElement(pWriter
);
402 // class SvxPostureItem --------------------------------------------------
404 ItemInstanceManager
* SvxPostureItem::getItemInstanceManager() const
406 static HashedItemInstanceManager
aInstanceManager(ItemType());
407 return &aInstanceManager
;
410 SvxPostureItem::SvxPostureItem( const FontItalic ePosture
, const sal_uInt16 nId
) :
411 SfxEnumItem( nId
, SfxItemType::SvxPostureItemType
, ePosture
)
415 SvxPostureItem
* SvxPostureItem::Clone( SfxItemPool
* ) const
417 return new SvxPostureItem( *this );
420 sal_uInt16
SvxPostureItem::GetValueCount() const
422 return ITALIC_NORMAL
+ 1; // ITALIC_NONE also belongs here
426 bool SvxPostureItem::GetPresentation
428 SfxItemPresentation
/*ePres*/,
429 MapUnit
/*eCoreUnit*/,
430 MapUnit
/*ePresUnit*/,
431 OUString
& rText
, const IntlWrapper
& /*rIntl*/
434 rText
= GetValueTextByPos( GetValue() );
439 OUString
SvxPostureItem::GetValueTextByPos( sal_uInt16 nPos
)
441 DBG_ASSERT( nPos
<= sal_uInt16(ITALIC_NORMAL
), "enum overflow!" );
443 FontItalic eItalic
= static_cast<FontItalic
>(nPos
);
448 case ITALIC_NONE
: pId
= RID_SVXITEMS_ITALIC_NONE
; break;
449 case ITALIC_OBLIQUE
: pId
= RID_SVXITEMS_ITALIC_OBLIQUE
; break;
450 case ITALIC_NORMAL
: pId
= RID_SVXITEMS_ITALIC_NORMAL
; break;
451 default: ;//prevent warning
454 return pId
? EditResId(pId
) : OUString();
457 bool SvxPostureItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
459 nMemberId
&= ~CONVERT_TWIPS
;
463 rVal
<<= GetBoolValue();
466 rVal
<<= vcl::unohelper::ConvertFontSlant(GetValue());
472 bool SvxPostureItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
474 nMemberId
&= ~CONVERT_TWIPS
;
478 ASSERT_CHANGE_REFCOUNTED_ITEM
;
479 SetBoolValue(Any2Bool(rVal
));
483 awt::FontSlant eSlant
;
484 if(!(rVal
>>= eSlant
))
486 sal_Int32 nValue
= 0;
487 if(!(rVal
>>= nValue
))
490 eSlant
= static_cast<awt::FontSlant
>(nValue
);
492 ASSERT_CHANGE_REFCOUNTED_ITEM
;
493 SetValue(vcl::unohelper::ConvertFontSlant(eSlant
));
499 bool SvxPostureItem::HasBoolValue() const
504 bool SvxPostureItem::GetBoolValue() const
506 return ( GetValue() >= ITALIC_OBLIQUE
);
509 void SvxPostureItem::SetBoolValue( bool bVal
)
511 ASSERT_CHANGE_REFCOUNTED_ITEM
;
512 SetValue( bVal
? ITALIC_NORMAL
: ITALIC_NONE
);
515 void SvxPostureItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
517 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxPostureItem"));
518 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
519 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%d", GetValue());
520 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr()));
521 (void)xmlTextWriterEndElement(pWriter
);
524 // class SvxWeightItem ---------------------------------------------------
526 ItemInstanceManager
* SvxWeightItem::getItemInstanceManager() const
528 static DefaultItemInstanceManager
aInstanceManager(ItemType());
529 return &aInstanceManager
;
532 SvxWeightItem::SvxWeightItem( const FontWeight eWght
, const sal_uInt16 nId
) :
533 SfxEnumItem( nId
, SfxItemType::SvxWeightItemType
, eWght
)
538 bool SvxWeightItem::HasBoolValue() const
544 bool SvxWeightItem::GetBoolValue() const
546 return GetValue() >= WEIGHT_BOLD
;
550 void SvxWeightItem::SetBoolValue( bool bVal
)
552 ASSERT_CHANGE_REFCOUNTED_ITEM
;
553 SetValue( bVal
? WEIGHT_BOLD
: WEIGHT_NORMAL
);
557 sal_uInt16
SvxWeightItem::GetValueCount() const
559 return WEIGHT_BLACK
; // WEIGHT_DONTKNOW does not belong
562 SvxWeightItem
* SvxWeightItem::Clone( SfxItemPool
* ) const
564 return new SvxWeightItem( *this );
567 bool SvxWeightItem::GetPresentation
569 SfxItemPresentation
/*ePres*/,
570 MapUnit
/*eCoreUnit*/,
571 MapUnit
/*ePresUnit*/,
572 OUString
& rText
, const IntlWrapper
& /*rIntl*/
575 rText
= GetValueTextByPos( GetValue() );
579 OUString
SvxWeightItem::GetValueTextByPos( sal_uInt16 nPos
)
581 static TranslateId RID_SVXITEMS_WEIGHTS
[] =
583 RID_SVXITEMS_WEIGHT_DONTKNOW
,
584 RID_SVXITEMS_WEIGHT_THIN
,
585 RID_SVXITEMS_WEIGHT_ULTRALIGHT
,
586 RID_SVXITEMS_WEIGHT_LIGHT
,
587 RID_SVXITEMS_WEIGHT_SEMILIGHT
,
588 RID_SVXITEMS_WEIGHT_NORMAL
,
589 RID_SVXITEMS_WEIGHT_MEDIUM
,
590 RID_SVXITEMS_WEIGHT_SEMIBOLD
,
591 RID_SVXITEMS_WEIGHT_BOLD
,
592 RID_SVXITEMS_WEIGHT_ULTRABOLD
,
593 RID_SVXITEMS_WEIGHT_BLACK
596 static_assert(std::size(RID_SVXITEMS_WEIGHTS
) - 1 == WEIGHT_BLACK
, "must match");
597 assert(nPos
<= sal_uInt16(WEIGHT_BLACK
) && "enum overflow!" );
598 return EditResId(RID_SVXITEMS_WEIGHTS
[nPos
]);
601 bool SvxWeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
603 nMemberId
&= ~CONVERT_TWIPS
;
607 rVal
<<= GetBoolValue();
611 rVal
<<= vcl::unohelper::ConvertFontWeight( GetValue() );
618 bool SvxWeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
620 nMemberId
&= ~CONVERT_TWIPS
;
624 ASSERT_CHANGE_REFCOUNTED_ITEM
;
625 SetBoolValue(Any2Bool(rVal
));
630 if(!(rVal
>>= fValue
))
632 sal_Int32 nValue
= 0;
633 if(!(rVal
>>= nValue
))
635 fValue
= static_cast<float>(nValue
);
637 ASSERT_CHANGE_REFCOUNTED_ITEM
;
638 SetValue( vcl::unohelper::ConvertFontWeight(static_cast<float>(fValue
)) );
645 void SvxWeightItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
647 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxWeightItem"));
648 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
649 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%d", GetValue());
650 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr()));
651 (void)xmlTextWriterEndElement(pWriter
);
654 // class SvxFontHeightItem -----------------------------------------------
656 ItemInstanceManager
* SvxFontHeightItem::getItemInstanceManager() const
658 static HashedItemInstanceManager
aInstanceManager(ItemType());
659 return &aInstanceManager
;
662 size_t SvxFontHeightItem::hashCode() const
665 o3tl::hash_combine(seed
, Which());
666 o3tl::hash_combine(seed
, GetHeight());
667 o3tl::hash_combine(seed
, GetProp());
668 o3tl::hash_combine(seed
, GetPropUnit());
672 SvxFontHeightItem::SvxFontHeightItem( const sal_uInt32 nSz
,
673 const sal_uInt16 nPrp
,
674 const sal_uInt16 nId
) :
675 SfxPoolItem( nId
, SfxItemType::SvxFontHeightItemType
)
677 SetHeight( nSz
,nPrp
); // calculate in percentage
680 SvxFontHeightItem
* SvxFontHeightItem::Clone( SfxItemPool
* ) const
682 return new SvxFontHeightItem( *this );
685 bool SvxFontHeightItem::operator==( const SfxPoolItem
& rItem
) const
687 assert(SfxPoolItem::operator==(rItem
));
688 return GetHeight() == static_cast<const SvxFontHeightItem
&>(rItem
).GetHeight() &&
689 GetProp() == static_cast<const SvxFontHeightItem
&>(rItem
).GetProp() &&
690 GetPropUnit() == static_cast<const SvxFontHeightItem
&>(rItem
).GetPropUnit();
693 bool SvxFontHeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
695 // In StarOne is the uno::Any always 1/100mm. Through the MemberId it is
696 // controlled if the value in the Item should be 1/100mm or Twips.
698 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
699 nMemberId
&= ~CONVERT_TWIPS
;
704 css::frame::status::FontHeight aFontHeight
;
706 // Point (i.e. Twips) is asked for, thus re-calculate if
707 // CONVERT_TWIPS is not set.
710 aFontHeight
.Height
= o3tl::convert
<double>(nHeight
, o3tl::Length::twip
, o3tl::Length::pt
);
714 double fPoints
= o3tl::convert
<double>(nHeight
, o3tl::Length::mm100
, o3tl::Length::pt
);
715 aFontHeight
.Height
= rtl::math::round(fPoints
, 1);
718 aFontHeight
.Prop
= MapUnit::MapRelative
== ePropUnit
? nProp
: 100;
723 case MapUnit::MapRelative
:
726 case MapUnit::Map100thMM
:
727 fRet
= o3tl::convert(fRet
, o3tl::Length::mm100
, o3tl::Length::pt
);
729 case MapUnit::MapPoint
:
732 case MapUnit::MapTwip
:
733 fRet
= o3tl::convert(fRet
, o3tl::Length::twip
, o3tl::Length::pt
);
735 default: ;//prevent warning
737 aFontHeight
.Diff
= fRet
;
738 rVal
<<= aFontHeight
;
743 // Point (i.e. Twips) is asked for, thus re-calculate if
744 // CONVERT_TWIPS is not set.
747 rVal
<<= static_cast<float>(o3tl::convert
<double>(nHeight
, o3tl::Length::twip
, o3tl::Length::pt
));
751 double fPoints
= o3tl::convert
<double>(nHeight
, o3tl::Length::mm100
, o3tl::Length::pt
);
752 rVal
<<= static_cast<float>(::rtl::math::round(fPoints
, 1));
756 case MID_FONTHEIGHT_PROP
:
757 rVal
<<= static_cast<sal_Int16
>(MapUnit::MapRelative
== ePropUnit
? nProp
: 100);
759 case MID_FONTHEIGHT_DIFF
:
764 case MapUnit::MapRelative
:
767 case MapUnit::Map100thMM
:
768 fRet
= o3tl::convert(fRet
, o3tl::Length::mm100
, o3tl::Length::pt
);
770 case MapUnit::MapPoint
:
773 case MapUnit::MapTwip
:
774 fRet
= o3tl::convert(fRet
, o3tl::Length::twip
, o3tl::Length::pt
);
776 default: ;//prevent warning
785 // Try to reconstruct the original height input value from the modified height
786 // and the prop data; this seems somewhat futile given the various ways how the
787 // modified height is calculated (with and without conversion between twips and
788 // 100th mm; with an additional eCoreMetric input in one of the SetHeight
789 // overloads), and indeed known to occasionally produce nRet values that would
790 // be negative, so just guard against negative results here and throw the hands
792 static sal_uInt32
lcl_GetRealHeight_Impl(sal_uInt32 nHeight
, sal_uInt16 nProp
, MapUnit eProp
, bool bCoreInTwip
)
794 sal_uInt32 nRet
= nHeight
;
798 case MapUnit::MapRelative
:
805 case MapUnit::MapPoint
:
807 short nTemp
= static_cast<short>(nProp
);
810 nDiff
= static_cast<short>(convertTwipToMm100(nDiff
));
813 case MapUnit::Map100thMM
:
814 case MapUnit::MapTwip
:
815 // In both cases, the units match core
816 nDiff
= static_cast<short>(nProp
);
821 nRet
= (nDiff
< 0 || nRet
>= o3tl::make_unsigned(nDiff
))
823 //TODO: overflow in case nDiff < 0 and nRet - nDiff > SAL_MAX_UINT32
828 bool SvxFontHeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
830 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
831 nMemberId
&= ~CONVERT_TWIPS
;
836 css::frame::status::FontHeight aFontHeight
;
837 if ( rVal
>>= aFontHeight
)
840 ePropUnit
= MapUnit::MapRelative
;
842 double fPoint
= aFontHeight
.Height
;
843 if( fPoint
< 0. || fPoint
> 10000. )
846 ASSERT_CHANGE_REFCOUNTED_ITEM
;
847 nHeight
= static_cast<tools::Long
>( fPoint
* 20.0 + 0.5 ); // Twips
849 nHeight
= convertTwipToMm100(nHeight
); // Convert, if the item contains 1/100mm
851 nProp
= aFontHeight
.Prop
;
859 ePropUnit
= MapUnit::MapRelative
;
862 if(!(rVal
>>= fPoint
))
864 sal_Int32 nValue
= 0;
865 if(!(rVal
>>= nValue
))
867 fPoint
= static_cast<float>(nValue
);
870 if (fPoint
< 0. || fPoint
> 10000.)
872 static bool bFuzzing
= comphelper::IsFuzzing();
873 if (bFuzzing
&& fPoint
> 120)
875 SAL_WARN("editeng.items", "SvxFontHeightItem ignoring font size of " << fPoint
<< " for performance");
879 ASSERT_CHANGE_REFCOUNTED_ITEM
;
880 nHeight
= static_cast<tools::Long
>( fPoint
* 20.0 + 0.5 ); // Twips
882 nHeight
= convertTwipToMm100(nHeight
); // Convert, if the item contains 1/100mm
885 case MID_FONTHEIGHT_PROP
:
887 sal_Int16 nNew
= sal_Int16();
891 ASSERT_CHANGE_REFCOUNTED_ITEM
;
892 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
897 ePropUnit
= MapUnit::MapRelative
;
900 case MID_FONTHEIGHT_DIFF
:
902 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
904 if(!(rVal
>>= fValue
))
906 sal_Int32 nValue
= 0;
907 if(!(rVal
>>= nValue
))
909 fValue
= static_cast<float>(nValue
);
911 ASSERT_CHANGE_REFCOUNTED_ITEM
;
912 sal_Int16 nCoreDiffValue
= static_cast<sal_Int16
>(fValue
* 20.);
913 nHeight
+= bConvert
? nCoreDiffValue
: convertTwipToMm100(nCoreDiffValue
);
914 nProp
= static_cast<sal_uInt16
>(static_cast<sal_Int16
>(fValue
));
915 ePropUnit
= MapUnit::MapPoint
;
923 bool SvxFontHeightItem::GetPresentation
925 SfxItemPresentation
/*ePres*/,
927 MapUnit
/*ePresUnit*/,
928 OUString
& rText
, const IntlWrapper
& rIntl
931 if( MapUnit::MapRelative
!= ePropUnit
)
933 rText
= OUString::number( static_cast<short>(nProp
) ) +
934 " " + EditResId( GetMetricId( ePropUnit
) );
935 if( 0 <= static_cast<short>(nProp
) )
938 else if( 100 == nProp
)
940 rText
= GetMetricText( static_cast<tools::Long
>(nHeight
),
941 eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
942 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
945 rText
= OUString::number( nProp
) + "%";
950 void SvxFontHeightItem::ScaleMetrics( tools::Long nMult
, tools::Long nDiv
)
952 ASSERT_CHANGE_REFCOUNTED_ITEM
;
953 nHeight
= static_cast<sal_uInt32
>(BigInt::Scale( nHeight
, nMult
, nDiv
));
957 bool SvxFontHeightItem::HasMetrics() const
962 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, const sal_uInt16 nNewProp
,
965 ASSERT_CHANGE_REFCOUNTED_ITEM
;
967 if( MapUnit::MapRelative
!= eUnit
)
968 nHeight
= nNewHeight
+ ::ItemToControl( short(nNewProp
), eUnit
,
970 else if( 100 != nNewProp
)
971 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
973 nHeight
= nNewHeight
;
979 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, sal_uInt16 nNewProp
,
980 MapUnit eMetric
, MapUnit eCoreMetric
)
982 ASSERT_CHANGE_REFCOUNTED_ITEM
;
984 if( MapUnit::MapRelative
!= eMetric
)
985 nHeight
= nNewHeight
+
986 ::ControlToItem( ::ItemToControl(static_cast<short>(nNewProp
), eMetric
,
987 FieldUnit::TWIP
), FieldUnit::TWIP
,
989 else if( 100 != nNewProp
)
990 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
992 nHeight
= nNewHeight
;
998 void SvxFontHeightItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1000 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxFontHeightItem"));
1001 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1002 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("height"), BAD_CAST(OString::number(nHeight
).getStr()));
1003 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("prop"), BAD_CAST(OString::number(nProp
).getStr()));
1004 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("propUnit"), BAD_CAST(OString::number(static_cast<int>(ePropUnit
)).getStr()));
1005 (void)xmlTextWriterEndElement(pWriter
);
1008 // class SvxTextLineItem ------------------------------------------------
1010 SvxTextLineItem::SvxTextLineItem( const FontLineStyle eSt
, const sal_uInt16 nId
, SfxItemType eItemType
)
1011 : SfxEnumItem(nId
, eItemType
, eSt
)
1012 , maColor(COL_TRANSPARENT
)
1017 bool SvxTextLineItem::HasBoolValue() const
1023 bool SvxTextLineItem::GetBoolValue() const
1025 return GetValue() != LINESTYLE_NONE
;
1029 void SvxTextLineItem::SetBoolValue( bool bVal
)
1031 ASSERT_CHANGE_REFCOUNTED_ITEM
;
1032 SetValue( bVal
? LINESTYLE_SINGLE
: LINESTYLE_NONE
);
1035 SvxTextLineItem
* SvxTextLineItem::Clone( SfxItemPool
* ) const
1037 return new SvxTextLineItem( *this );
1040 sal_uInt16
SvxTextLineItem::GetValueCount() const
1042 return LINESTYLE_DOTTED
+ 1; // LINESTYLE_NONE also belongs here
1046 bool SvxTextLineItem::GetPresentation
1048 SfxItemPresentation
/*ePres*/,
1049 MapUnit
/*eCoreUnit*/,
1050 MapUnit
/*ePresUnit*/,
1051 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1054 rText
= GetValueTextByPos( GetValue() );
1055 if( !maColor
.IsTransparent() )
1056 rText
+= cpDelim
+ ::GetColorString(maColor
);
1061 OUString
SvxTextLineItem::GetValueTextByPos( sal_uInt16
/*nPos*/ ) const
1063 OSL_FAIL("SvxTextLineItem::GetValueTextByPos: Pure virtual method");
1067 bool SvxTextLineItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1069 nMemberId
&= ~CONVERT_TWIPS
;
1073 rVal
<<= GetBoolValue();
1076 rVal
<<= static_cast<sal_Int16
>(GetValue());
1081 case MID_TL_COMPLEX_COLOR
:
1083 auto xComplexColor
= model::color::createXComplexColor(maComplexColor
);
1084 rVal
<<= xComplexColor
;
1087 case MID_TL_HASCOLOR
:
1088 rVal
<<= maColor
.GetAlpha() == 255;
1094 bool SvxTextLineItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1096 nMemberId
&= ~CONVERT_TWIPS
;
1101 ASSERT_CHANGE_REFCOUNTED_ITEM
;
1102 SetBoolValue(Any2Bool(rVal
));
1106 sal_Int32 nValue
= 0;
1107 if(!(rVal
>>= nValue
))
1111 ASSERT_CHANGE_REFCOUNTED_ITEM
;
1112 SetValue(static_cast<FontLineStyle
>(nValue
));
1119 if( !( rVal
>>= nCol
) )
1123 // Keep transparence, because it contains the information
1124 // whether the font color or the stored color should be used
1125 ASSERT_CHANGE_REFCOUNTED_ITEM
;
1126 sal_uInt8 nAlpha
= maColor
.GetAlpha();
1128 maColor
.SetAlpha( nAlpha
);
1132 case MID_TL_COMPLEX_COLOR
:
1134 css::uno::Reference
<css::util::XComplexColor
> xComplexColor
;
1135 if (!(rVal
>>= xComplexColor
))
1138 if (xComplexColor
.is())
1140 ASSERT_CHANGE_REFCOUNTED_ITEM
;
1141 maComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
1145 case MID_TL_HASCOLOR
:
1146 ASSERT_CHANGE_REFCOUNTED_ITEM
;
1147 maColor
.SetAlpha( Any2Bool( rVal
) ? 255 : 0 );
1153 bool SvxTextLineItem::operator==( const SfxPoolItem
& rItem
) const
1155 return SfxEnumItem::operator==( rItem
) &&
1156 maColor
== static_cast<const SvxTextLineItem
&>(rItem
).maColor
&&
1157 maComplexColor
== static_cast<const SvxTextLineItem
&>(rItem
).maComplexColor
;
1160 // class SvxUnderlineItem ------------------------------------------------
1162 ItemInstanceManager
* SvxUnderlineItem::getItemInstanceManager() const
1164 static DefaultItemInstanceManager
aInstanceManager(ItemType());
1165 return &aInstanceManager
;
1168 SvxUnderlineItem::SvxUnderlineItem( const FontLineStyle eSt
, const sal_uInt16 nId
)
1169 : SvxTextLineItem( eSt
, nId
, SfxItemType::SvxUnderlineItemType
)
1173 SvxUnderlineItem
* SvxUnderlineItem::Clone( SfxItemPool
* ) const
1175 return new SvxUnderlineItem( *this );
1178 OUString
SvxUnderlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1180 static TranslateId RID_SVXITEMS_UL
[] =
1182 RID_SVXITEMS_UL_NONE
,
1183 RID_SVXITEMS_UL_SINGLE
,
1184 RID_SVXITEMS_UL_DOUBLE
,
1185 RID_SVXITEMS_UL_DOTTED
,
1186 RID_SVXITEMS_UL_DONTKNOW
,
1187 RID_SVXITEMS_UL_DASH
,
1188 RID_SVXITEMS_UL_LONGDASH
,
1189 RID_SVXITEMS_UL_DASHDOT
,
1190 RID_SVXITEMS_UL_DASHDOTDOT
,
1191 RID_SVXITEMS_UL_SMALLWAVE
,
1192 RID_SVXITEMS_UL_WAVE
,
1193 RID_SVXITEMS_UL_DOUBLEWAVE
,
1194 RID_SVXITEMS_UL_BOLD
,
1195 RID_SVXITEMS_UL_BOLDDOTTED
,
1196 RID_SVXITEMS_UL_BOLDDASH
,
1197 RID_SVXITEMS_UL_BOLDLONGDASH
,
1198 RID_SVXITEMS_UL_BOLDDASHDOT
,
1199 RID_SVXITEMS_UL_BOLDDASHDOTDOT
,
1200 RID_SVXITEMS_UL_BOLDWAVE
1202 static_assert(std::size(RID_SVXITEMS_UL
) - 1 == LINESTYLE_BOLDWAVE
, "must match");
1203 assert(nPos
<= sal_uInt16(LINESTYLE_BOLDWAVE
) && "enum overflow!");
1204 return EditResId(RID_SVXITEMS_UL
[nPos
]);
1207 // class SvxOverlineItem ------------------------------------------------
1209 ItemInstanceManager
* SvxOverlineItem::getItemInstanceManager() const
1211 static DefaultItemInstanceManager
aInstanceManager(ItemType());
1212 return &aInstanceManager
;
1215 SvxOverlineItem::SvxOverlineItem( const FontLineStyle eSt
, const sal_uInt16 nId
)
1216 : SvxTextLineItem( eSt
, nId
, SfxItemType::SvxOverlineItemType
)
1220 SvxOverlineItem
* SvxOverlineItem::Clone( SfxItemPool
* ) const
1222 return new SvxOverlineItem( *this );
1225 OUString
SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1227 static TranslateId RID_SVXITEMS_OL
[] =
1229 RID_SVXITEMS_OL_NONE
,
1230 RID_SVXITEMS_OL_SINGLE
,
1231 RID_SVXITEMS_OL_DOUBLE
,
1232 RID_SVXITEMS_OL_DOTTED
,
1233 RID_SVXITEMS_OL_DONTKNOW
,
1234 RID_SVXITEMS_OL_DASH
,
1235 RID_SVXITEMS_OL_LONGDASH
,
1236 RID_SVXITEMS_OL_DASHDOT
,
1237 RID_SVXITEMS_OL_DASHDOTDOT
,
1238 RID_SVXITEMS_OL_SMALLWAVE
,
1239 RID_SVXITEMS_OL_WAVE
,
1240 RID_SVXITEMS_OL_DOUBLEWAVE
,
1241 RID_SVXITEMS_OL_BOLD
,
1242 RID_SVXITEMS_OL_BOLDDOTTED
,
1243 RID_SVXITEMS_OL_BOLDDASH
,
1244 RID_SVXITEMS_OL_BOLDLONGDASH
,
1245 RID_SVXITEMS_OL_BOLDDASHDOT
,
1246 RID_SVXITEMS_OL_BOLDDASHDOTDOT
,
1247 RID_SVXITEMS_OL_BOLDWAVE
1249 static_assert(std::size(RID_SVXITEMS_OL
) - 1 == LINESTYLE_BOLDWAVE
, "must match");
1250 assert(nPos
<= sal_uInt16(LINESTYLE_BOLDWAVE
) && "enum overflow!");
1251 return EditResId(RID_SVXITEMS_OL
[nPos
]);
1254 // class SvxCrossedOutItem -----------------------------------------------
1256 ItemInstanceManager
* SvxCrossedOutItem::getItemInstanceManager() const
1258 static DefaultItemInstanceManager
aInstanceManager(ItemType());
1259 return &aInstanceManager
;
1262 SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt
, const sal_uInt16 nId
)
1263 : SfxEnumItem( nId
, SfxItemType::SvxCrossedOutItemType
, eSt
)
1268 bool SvxCrossedOutItem::HasBoolValue() const
1274 bool SvxCrossedOutItem::GetBoolValue() const
1276 return GetValue() != STRIKEOUT_NONE
;
1280 void SvxCrossedOutItem::SetBoolValue( bool bVal
)
1282 ASSERT_CHANGE_REFCOUNTED_ITEM
;
1283 SetValue( bVal
? STRIKEOUT_SINGLE
: STRIKEOUT_NONE
);
1287 sal_uInt16
SvxCrossedOutItem::GetValueCount() const
1289 return STRIKEOUT_DOUBLE
+ 1; // STRIKEOUT_NONE belongs also here
1292 SvxCrossedOutItem
* SvxCrossedOutItem::Clone( SfxItemPool
* ) const
1294 return new SvxCrossedOutItem( *this );
1297 bool SvxCrossedOutItem::GetPresentation
1299 SfxItemPresentation
/*ePres*/,
1300 MapUnit
/*eCoreUnit*/,
1301 MapUnit
/*ePresUnit*/,
1302 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1305 rText
= GetValueTextByPos( GetValue() );
1309 OUString
SvxCrossedOutItem::GetValueTextByPos( sal_uInt16 nPos
)
1311 static TranslateId RID_SVXITEMS_STRIKEOUT
[] =
1313 RID_SVXITEMS_STRIKEOUT_NONE
,
1314 RID_SVXITEMS_STRIKEOUT_SINGLE
,
1315 RID_SVXITEMS_STRIKEOUT_DOUBLE
,
1316 RID_SVXITEMS_STRIKEOUT_DONTKNOW
,
1317 RID_SVXITEMS_STRIKEOUT_BOLD
,
1318 RID_SVXITEMS_STRIKEOUT_SLASH
,
1319 RID_SVXITEMS_STRIKEOUT_X
1321 static_assert(std::size(RID_SVXITEMS_STRIKEOUT
) - 1 == STRIKEOUT_X
, "must match");
1322 assert(nPos
<= sal_uInt16(STRIKEOUT_X
) && "enum overflow!");
1323 return EditResId(RID_SVXITEMS_STRIKEOUT
[nPos
]);
1326 bool SvxCrossedOutItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1328 nMemberId
&= ~CONVERT_TWIPS
;
1331 case MID_CROSSED_OUT
:
1332 rVal
<<= GetBoolValue();
1335 rVal
<<= static_cast<sal_Int16
>(GetValue());
1341 bool SvxCrossedOutItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1343 nMemberId
&= ~CONVERT_TWIPS
;
1346 case MID_CROSSED_OUT
:
1347 SetBoolValue(Any2Bool(rVal
));
1351 sal_Int32 nValue
= 0;
1352 if(!(rVal
>>= nValue
))
1354 ASSERT_CHANGE_REFCOUNTED_ITEM
;
1355 SetValue(static_cast<FontStrikeout
>(nValue
));
1361 // class SvxShadowedItem -------------------------------------------------
1363 SvxShadowedItem::SvxShadowedItem( const bool bShadowed
, const sal_uInt16 nId
) :
1364 SfxBoolItem( nId
, bShadowed
, SfxItemType::SvxShadowedItemType
)
1368 SvxShadowedItem
* SvxShadowedItem::Clone( SfxItemPool
* ) const
1370 return new SvxShadowedItem( *this );
1373 bool SvxShadowedItem::GetPresentation
1375 SfxItemPresentation
/*ePres*/,
1376 MapUnit
/*eCoreUnit*/,
1377 MapUnit
/*ePresUnit*/,
1378 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1381 TranslateId pId
= RID_SVXITEMS_SHADOWED_FALSE
;
1384 pId
= RID_SVXITEMS_SHADOWED_TRUE
;
1385 rText
= EditResId(pId
);
1389 // class SvxAutoKernItem -------------------------------------------------
1391 SvxAutoKernItem::SvxAutoKernItem( const bool bAutoKern
, const sal_uInt16 nId
) :
1392 SfxBoolItem( nId
, bAutoKern
, SfxItemType::SvxAutoKernItemType
)
1396 SvxAutoKernItem
* SvxAutoKernItem::Clone( SfxItemPool
* ) const
1398 return new SvxAutoKernItem( *this );
1401 bool SvxAutoKernItem::GetPresentation
1403 SfxItemPresentation
/*ePres*/,
1404 MapUnit
/*eCoreUnit*/,
1405 MapUnit
/*ePresUnit*/,
1406 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1409 TranslateId pId
= RID_SVXITEMS_AUTOKERN_FALSE
;
1412 pId
= RID_SVXITEMS_AUTOKERN_TRUE
;
1413 rText
= EditResId(pId
);
1417 // class SvxWordLineModeItem ---------------------------------------------
1419 SvxWordLineModeItem::SvxWordLineModeItem( const bool bWordLineMode
,
1420 const sal_uInt16 nId
) :
1421 SfxBoolItem( nId
, bWordLineMode
, SfxItemType::SvxWordLineItemType
)
1425 SvxWordLineModeItem
* SvxWordLineModeItem::Clone( SfxItemPool
* ) const
1427 return new SvxWordLineModeItem( *this );
1430 bool SvxWordLineModeItem::GetPresentation
1432 SfxItemPresentation
/*ePres*/,
1433 MapUnit
/*eCoreUnit*/,
1434 MapUnit
/*ePresUnit*/,
1435 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1438 TranslateId pId
= RID_SVXITEMS_WORDLINE_FALSE
;
1441 pId
= RID_SVXITEMS_WORDLINE_TRUE
;
1442 rText
= EditResId(pId
);
1446 // class SvxContourItem --------------------------------------------------
1448 SvxContourItem::SvxContourItem( const bool bContoured
, const sal_uInt16 nId
) :
1449 SfxBoolItem( nId
, bContoured
, SfxItemType::SvxContourItemType
)
1453 SvxContourItem
* SvxContourItem::Clone( SfxItemPool
* ) const
1455 return new SvxContourItem( *this );
1458 bool SvxContourItem::GetPresentation
1460 SfxItemPresentation
/*ePres*/,
1461 MapUnit
/*eCoreUnit*/,
1462 MapUnit
/*ePresUnit*/,
1463 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1466 TranslateId pId
= RID_SVXITEMS_CONTOUR_FALSE
;
1469 pId
= RID_SVXITEMS_CONTOUR_TRUE
;
1470 rText
= EditResId(pId
);
1474 // class SvxColorItem ----------------------------------------------------
1475 SvxColorItem::SvxColorItem( const sal_uInt16 nId
) :
1476 SfxPoolItem(nId
, SfxItemType::SvxColorItemType
),
1481 SvxColorItem::SvxColorItem( const Color
& rCol
, const sal_uInt16 nId
) :
1482 SfxPoolItem( nId
, SfxItemType::SvxColorItemType
),
1487 SvxColorItem::SvxColorItem(Color
const& rColor
, model::ComplexColor
const& rComplexColor
, const sal_uInt16 nId
)
1488 : SfxPoolItem(nId
, SfxItemType::SvxColorItemType
)
1490 , maComplexColor(rComplexColor
)
1494 SvxColorItem::~SvxColorItem()
1498 bool SvxColorItem::operator==( const SfxPoolItem
& rAttr
) const
1500 assert(SfxPoolItem::operator==(rAttr
));
1501 const SvxColorItem
& rColorItem
= static_cast<const SvxColorItem
&>(rAttr
);
1503 return mColor
== rColorItem
.mColor
&&
1504 maComplexColor
== rColorItem
.maComplexColor
;
1507 size_t SvxColorItem::hashCode() const
1509 std::size_t seed(0);
1510 o3tl::hash_combine(seed
, static_cast<sal_Int32
>(mColor
));
1511 o3tl::hash_combine(seed
, maComplexColor
);
1515 bool SvxColorItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1517 nMemberId
&= ~CONVERT_TWIPS
;
1520 case MID_COLOR_ALPHA
:
1522 auto fTransparency
= static_cast<double>(255 - mColor
.GetAlpha()) * 100 / 255;
1523 rVal
<<= static_cast<sal_Int16
>(basegfx::fround(fTransparency
));
1526 case MID_GRAPHIC_TRANSPARENT
:
1528 rVal
<<= mColor
.GetAlpha() == 0;
1531 case MID_COLOR_THEME_INDEX
:
1533 rVal
<<= sal_Int16(maComplexColor
.getThemeColorType());
1536 case MID_COLOR_TINT_OR_SHADE
:
1538 sal_Int16 nValue
= 0;
1539 for (auto const& rTransform
: maComplexColor
.getTransformations())
1541 if (rTransform
.meType
== model::TransformationType::Tint
)
1542 nValue
= rTransform
.mnValue
;
1543 else if (rTransform
.meType
== model::TransformationType::Shade
)
1544 nValue
= -rTransform
.mnValue
;
1549 case MID_COLOR_LUM_MOD
:
1551 sal_Int16 nValue
= 10000;
1552 for (auto const& rTransform
: maComplexColor
.getTransformations())
1554 if (rTransform
.meType
== model::TransformationType::LumMod
)
1555 nValue
= rTransform
.mnValue
;
1560 case MID_COLOR_LUM_OFF
:
1562 sal_Int16 nValue
= 0;
1563 for (auto const& rTransform
: maComplexColor
.getTransformations())
1565 if (rTransform
.meType
== model::TransformationType::LumOff
)
1566 nValue
= rTransform
.mnValue
;
1571 case MID_COMPLEX_COLOR_JSON
:
1573 rVal
<<= OStringToOUString(model::color::convertToJSON(maComplexColor
), RTL_TEXTENCODING_UTF8
);
1576 case MID_COMPLEX_COLOR
:
1578 auto xComplexColor
= model::color::createXComplexColor(maComplexColor
);
1579 rVal
<<= xComplexColor
;
1592 bool SvxColorItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1594 ASSERT_CHANGE_REFCOUNTED_ITEM
;
1595 nMemberId
&= ~CONVERT_TWIPS
;
1598 case MID_COLOR_ALPHA
:
1600 sal_Int16 nTransparency
= 0;
1601 bool bRet
= rVal
>>= nTransparency
;
1604 auto fTransparency
= static_cast<double>(nTransparency
) * 255 / 100;
1605 mColor
.SetAlpha(255 - static_cast<sal_uInt8
>(basegfx::fround(fTransparency
)));
1609 case MID_GRAPHIC_TRANSPARENT
:
1611 mColor
.SetAlpha( Any2Bool( rVal
) ? 0 : 255 );
1614 case MID_COLOR_THEME_INDEX
:
1616 sal_Int16 nIndex
= -1;
1617 if (!(rVal
>>= nIndex
))
1619 maComplexColor
.setThemeColor(model::convertToThemeColorType(nIndex
));
1622 case MID_COLOR_TINT_OR_SHADE
:
1624 sal_Int16 nTintShade
= 0;
1625 if (!(rVal
>>= nTintShade
))
1628 maComplexColor
.removeTransformations(model::TransformationType::Tint
);
1629 maComplexColor
.removeTransformations(model::TransformationType::Shade
);
1632 maComplexColor
.addTransformation({model::TransformationType::Tint
, nTintShade
});
1633 else if (nTintShade
< 0)
1635 sal_Int16 nShade
= o3tl::narrowing
<sal_Int16
>(-nTintShade
);
1636 maComplexColor
.addTransformation({model::TransformationType::Shade
, nShade
});
1640 case MID_COLOR_LUM_MOD
:
1642 sal_Int16 nLumMod
= 10000;
1643 if (!(rVal
>>= nLumMod
))
1645 maComplexColor
.removeTransformations(model::TransformationType::LumMod
);
1646 maComplexColor
.addTransformation({model::TransformationType::LumMod
, nLumMod
});
1649 case MID_COLOR_LUM_OFF
:
1651 sal_Int16 nLumOff
= 0;
1652 if (!(rVal
>>= nLumOff
))
1654 maComplexColor
.removeTransformations(model::TransformationType::LumOff
);
1655 maComplexColor
.addTransformation({model::TransformationType::LumOff
, nLumOff
});
1658 case MID_COMPLEX_COLOR_JSON
:
1660 OUString sComplexColorJson
;
1661 if (!(rVal
>>= sComplexColorJson
))
1664 if (sComplexColorJson
.isEmpty())
1667 OString aJSON
= OUStringToOString(sComplexColorJson
, RTL_TEXTENCODING_ASCII_US
);
1668 if (!model::color::convertFromJSON(aJSON
, maComplexColor
))
1672 case MID_COMPLEX_COLOR
:
1674 css::uno::Reference
<css::util::XComplexColor
> xComplexColor
;
1675 if (!(rVal
>>= xComplexColor
))
1678 if (xComplexColor
.is())
1679 maComplexColor
= model::color::getFromXComplexColor(xComplexColor
);
1685 if (!(rVal
>>= mColor
))
1693 SvxColorItem
* SvxColorItem::Clone( SfxItemPool
* ) const
1695 return new SvxColorItem( *this );
1698 bool SvxColorItem::GetPresentation
1700 SfxItemPresentation
/*ePres*/,
1701 MapUnit
/*eCoreUnit*/,
1702 MapUnit
/*ePresUnit*/,
1703 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1706 rText
= ::GetColorString( mColor
);
1710 void SvxColorItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1712 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxColorItem"));
1713 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1715 std::stringstream ss
;
1717 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(ss
.str().c_str()));
1720 IntlWrapper
aIntlWrapper(SvtSysLocale().GetUILanguageTag());
1721 GetPresentation( SfxItemPresentation::Complete
, MapUnit::Map100thMM
, MapUnit::Map100thMM
, aStr
, aIntlWrapper
);
1722 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(OUStringToOString(aStr
, RTL_TEXTENCODING_UTF8
).getStr()));
1724 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("complex-color"));
1726 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("type"),
1727 BAD_CAST(OString::number(sal_Int16(maComplexColor
.getType())).getStr()));
1729 for (auto const& rTransform
: maComplexColor
.getTransformations())
1731 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("transformation"));
1732 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("type"),
1733 BAD_CAST(OString::number(sal_Int16(rTransform
.meType
)).getStr()));
1734 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"),
1735 BAD_CAST(OString::number(rTransform
.mnValue
).getStr()));
1736 (void)xmlTextWriterEndElement(pWriter
);
1739 (void)xmlTextWriterEndElement(pWriter
);
1741 (void)xmlTextWriterEndElement(pWriter
);
1744 // class SvxKerningItem --------------------------------------------------
1746 SvxKerningItem::SvxKerningItem( const short nKern
, const sal_uInt16 nId
) :
1747 SfxInt16Item( nId
, nKern
, SfxItemType::SvxKerningItemType
)
1751 SvxKerningItem
* SvxKerningItem::Clone( SfxItemPool
* ) const
1753 return new SvxKerningItem( *this );
1756 void SvxKerningItem::ScaleMetrics( tools::Long nMult
, tools::Long nDiv
)
1758 SetValue( static_cast<sal_Int16
>(BigInt::Scale( GetValue(), nMult
, nDiv
)) );
1762 bool SvxKerningItem::HasMetrics() const
1768 bool SvxKerningItem::GetPresentation
1770 SfxItemPresentation ePres
,
1772 MapUnit
/*ePresUnit*/,
1773 OUString
& rText
, const IntlWrapper
& rIntl
1778 case SfxItemPresentation::Nameless
:
1779 rText
= GetMetricText( static_cast<tools::Long
>(GetValue()), eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
1780 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
1782 case SfxItemPresentation::Complete
:
1784 rText
= EditResId(RID_SVXITEMS_KERNING_COMPLETE
);
1787 if ( GetValue() > 0 )
1788 pId
= RID_SVXITEMS_KERNING_EXPANDED
;
1789 else if ( GetValue() < 0 )
1790 pId
= RID_SVXITEMS_KERNING_CONDENSED
;
1793 rText
+= EditResId(pId
);
1794 rText
+= GetMetricText( static_cast<tools::Long
>(GetValue()), eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
1795 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
1798 default: ; //prevent warning
1803 bool SvxKerningItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1805 sal_Int16 nVal
= GetValue();
1806 if(nMemberId
& CONVERT_TWIPS
)
1807 nVal
= static_cast<sal_Int16
>(convertTwipToMm100(nVal
));
1812 bool SvxKerningItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1814 sal_Int16 nVal
= sal_Int16();
1815 if(!(rVal
>>= nVal
))
1817 if(nMemberId
& CONVERT_TWIPS
)
1818 nVal
= o3tl::toTwips(nVal
, o3tl::Length::mm100
);
1823 // class SvxCaseMapItem --------------------------------------------------
1825 SvxCaseMapItem::SvxCaseMapItem( const SvxCaseMap eMap
, const sal_uInt16 nId
) :
1826 SfxEnumItem( nId
, SfxItemType::SvxCaseMapItemType
, eMap
)
1830 sal_uInt16
SvxCaseMapItem::GetValueCount() const
1832 return sal_uInt16(SvxCaseMap::End
); // SvxCaseMap::SmallCaps + 1
1835 SvxCaseMapItem
* SvxCaseMapItem::Clone( SfxItemPool
* ) const
1837 return new SvxCaseMapItem( *this );
1840 bool SvxCaseMapItem::GetPresentation
1842 SfxItemPresentation
/*ePres*/,
1843 MapUnit
/*eCoreUnit*/,
1844 MapUnit
/*ePresUnit*/,
1845 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1848 rText
= GetValueTextByPos( static_cast<sal_uInt16
>(GetValue()) );
1852 OUString
SvxCaseMapItem::GetValueTextByPos( sal_uInt16 nPos
)
1854 static TranslateId RID_SVXITEMS_CASEMAP
[] =
1856 RID_SVXITEMS_CASEMAP_NONE
,
1857 RID_SVXITEMS_CASEMAP_UPPERCASE
,
1858 RID_SVXITEMS_CASEMAP_LOWERCASE
,
1859 RID_SVXITEMS_CASEMAP_TITLE
,
1860 RID_SVXITEMS_CASEMAP_SMALLCAPS
1863 static_assert(std::size(RID_SVXITEMS_CASEMAP
) == size_t(SvxCaseMap::End
), "must match");
1864 assert(nPos
< sal_uInt16(SvxCaseMap::End
) && "enum overflow!");
1865 return EditResId(RID_SVXITEMS_CASEMAP
[nPos
]);
1868 bool SvxCaseMapItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
1870 sal_Int16 nRet
= style::CaseMap::NONE
;
1871 switch( GetValue() )
1873 case SvxCaseMap::Uppercase
: nRet
= style::CaseMap::UPPERCASE
; break;
1874 case SvxCaseMap::Lowercase
: nRet
= style::CaseMap::LOWERCASE
; break;
1875 case SvxCaseMap::Capitalize
: nRet
= style::CaseMap::TITLE
; break;
1876 case SvxCaseMap::SmallCaps
: nRet
= style::CaseMap::SMALLCAPS
; break;
1883 bool SvxCaseMapItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
1885 sal_uInt16 nVal
= sal_uInt16();
1886 if(!(rVal
>>= nVal
))
1892 case style::CaseMap::NONE
: eVal
= SvxCaseMap::NotMapped
; break;
1893 case style::CaseMap::UPPERCASE
: eVal
= SvxCaseMap::Uppercase
; break;
1894 case style::CaseMap::LOWERCASE
: eVal
= SvxCaseMap::Lowercase
; break;
1895 case style::CaseMap::TITLE
: eVal
= SvxCaseMap::Capitalize
; break;
1896 case style::CaseMap::SMALLCAPS
: eVal
= SvxCaseMap::SmallCaps
; break;
1897 default: return false;
1903 // class SvxEscapementItem -----------------------------------------------
1905 SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId
) :
1906 SfxEnumItemInterface( nId
, SfxItemType::SvxEscapementItemType
),
1914 SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape
,
1915 const sal_uInt16 nId
) :
1916 SfxEnumItemInterface( nId
, SfxItemType::SvxEscapementItemType
),
1919 SetEscapement( eEscape
);
1921 nProp
= DFLT_ESC_PROP
;
1925 SvxEscapementItem::SvxEscapementItem( const short _nEsc
,
1926 const sal_uInt8 _nProp
,
1927 const sal_uInt16 nId
) :
1928 SfxEnumItemInterface( nId
, SfxItemType::SvxEscapementItemType
),
1934 bool SvxEscapementItem::operator==( const SfxPoolItem
& rAttr
) const
1936 assert(SfxPoolItem::operator==(rAttr
));
1938 return( nEsc
== static_cast<const SvxEscapementItem
&>(rAttr
).nEsc
&&
1939 nProp
== static_cast<const SvxEscapementItem
&>(rAttr
).nProp
);
1942 SvxEscapementItem
* SvxEscapementItem::Clone( SfxItemPool
* ) const
1944 return new SvxEscapementItem( *this );
1947 sal_uInt16
SvxEscapementItem::GetValueCount() const
1949 return sal_uInt16(SvxEscapement::End
); // SvxEscapement::Subscript + 1
1953 bool SvxEscapementItem::GetPresentation
1955 SfxItemPresentation
/*ePres*/,
1956 MapUnit
/*eCoreUnit*/,
1957 MapUnit
/*ePresUnit*/,
1958 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1961 rText
= GetValueTextByPos( GetEnumValue() );
1965 if( DFLT_ESC_AUTO_SUPER
== nEsc
|| DFLT_ESC_AUTO_SUB
== nEsc
)
1966 rText
+= EditResId(RID_SVXITEMS_ESCAPEMENT_AUTO
);
1968 rText
+= OUString::number( nEsc
) + "%";
1973 OUString
SvxEscapementItem::GetValueTextByPos( sal_uInt16 nPos
)
1975 static TranslateId RID_SVXITEMS_ESCAPEMENT
[] =
1977 RID_SVXITEMS_ESCAPEMENT_OFF
,
1978 RID_SVXITEMS_ESCAPEMENT_SUPER
,
1979 RID_SVXITEMS_ESCAPEMENT_SUB
1982 static_assert(std::size(RID_SVXITEMS_ESCAPEMENT
) == size_t(SvxEscapement::End
), "must match");
1983 assert(nPos
< sal_uInt16(SvxEscapement::End
) && "enum overflow!");
1984 return EditResId(RID_SVXITEMS_ESCAPEMENT
[nPos
]);
1987 sal_uInt16
SvxEscapementItem::GetEnumValue() const
1990 return sal_uInt16(SvxEscapement::Subscript
);
1991 else if ( nEsc
> 0 )
1992 return sal_uInt16(SvxEscapement::Superscript
);
1993 return sal_uInt16(SvxEscapement::Off
);
1997 void SvxEscapementItem::SetEnumValue( sal_uInt16 nVal
)
1999 SetEscapement( static_cast<SvxEscapement
>(nVal
) );
2002 bool SvxEscapementItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2004 nMemberId
&= ~CONVERT_TWIPS
;
2008 rVal
<<= static_cast<sal_Int16
>(nEsc
);
2010 case MID_ESC_HEIGHT
:
2011 rVal
<<= static_cast<sal_Int8
>(nProp
);
2014 rVal
<<= (DFLT_ESC_AUTO_SUB
== nEsc
|| DFLT_ESC_AUTO_SUPER
== nEsc
);
2020 bool SvxEscapementItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2022 ASSERT_CHANGE_REFCOUNTED_ITEM
;
2023 nMemberId
&= ~CONVERT_TWIPS
;
2028 sal_Int16 nVal
= sal_Int16();
2029 if( (rVal
>>= nVal
) && (std::abs(nVal
) <= MAX_ESC_POS
+1))
2035 case MID_ESC_HEIGHT
:
2037 sal_Int8 nVal
= sal_Int8();
2038 if( (rVal
>>= nVal
) && (nVal
<= 100))
2046 bool bVal
= Any2Bool(rVal
);
2050 nEsc
= DFLT_ESC_AUTO_SUB
;
2052 nEsc
= DFLT_ESC_AUTO_SUPER
;
2055 if(DFLT_ESC_AUTO_SUPER
== nEsc
)
2057 else if(DFLT_ESC_AUTO_SUB
== nEsc
)
2065 // class SvxLanguageItem -------------------------------------------------
2067 ItemInstanceManager
* SvxLanguageItem::getItemInstanceManager() const
2069 static DefaultItemInstanceManager
aInstanceManager(ItemType());
2070 return &aInstanceManager
;
2073 SvxLanguageItem::SvxLanguageItem( const LanguageType eLang
, const sal_uInt16 nId
)
2074 : SvxLanguageItem_Base( nId
, SfxItemType::SvxLanguageItemType
, eLang
)
2079 sal_uInt16
SvxLanguageItem::GetValueCount() const
2081 // #i50205# got rid of class International
2082 SAL_WARN( "editeng.items", "SvxLanguageItem::GetValueCount: supposed to return a count of what?");
2083 // Could be SvtLanguageTable::GetEntryCount() (all locales with resource string)?
2084 // Could be LocaleDataWrapper::getInstalledLanguageTypes() (all locales with locale data)?
2088 SvxLanguageItem
* SvxLanguageItem::Clone( SfxItemPool
* ) const
2090 return new SvxLanguageItem( *this );
2093 bool SvxLanguageItem::GetPresentation
2095 SfxItemPresentation
/*ePres*/,
2096 MapUnit
/*eCoreUnit*/,
2097 MapUnit
/*ePresUnit*/,
2098 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2101 rText
= SvtLanguageTable::GetLanguageString( GetValue() );
2105 bool SvxLanguageItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2107 nMemberId
&= ~CONVERT_TWIPS
;
2110 case MID_LANG_INT
: // for basic conversions!
2111 rVal
<<= static_cast<sal_Int16
>(static_cast<sal_uInt16
>(GetValue()));
2113 case MID_LANG_LOCALE
:
2114 lang::Locale
aRet( LanguageTag::convertToLocale( GetValue(), false));
2121 bool SvxLanguageItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2123 nMemberId
&= ~CONVERT_TWIPS
;
2126 case MID_LANG_INT
: // for basic conversions!
2128 sal_Int32 nValue
= 0;
2129 if(!(rVal
>>= nValue
))
2132 ASSERT_CHANGE_REFCOUNTED_ITEM
;
2133 SetValue(LanguageType(nValue
));
2136 case MID_LANG_LOCALE
:
2138 lang::Locale aLocale
;
2139 if(!(rVal
>>= aLocale
))
2142 ASSERT_CHANGE_REFCOUNTED_ITEM
;
2143 SetValue( LanguageTag::convertToLanguageType( aLocale
, false));
2150 // class SvxNoHyphenItem -------------------------------------------------
2152 SvxNoHyphenItem::SvxNoHyphenItem( const bool bNoHyphen
, const sal_uInt16 nId
) :
2153 SfxBoolItem( nId
, bNoHyphen
, SfxItemType::SvxNoHyphenItemType
)
2157 SvxNoHyphenItem
* SvxNoHyphenItem::Clone( SfxItemPool
* ) const
2159 return new SvxNoHyphenItem( *this );
2162 bool SvxNoHyphenItem::GetPresentation
2164 SfxItemPresentation
/*ePres*/,
2165 MapUnit
/*eCoreUnit*/,
2166 MapUnit
/*ePresUnit*/,
2167 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2171 rText
= EditResId(RID_SVXITEMS_NOHYPHENATION_TRUE
);
2179 * Dummy item for ToolBox controls:
2184 // class SvxBlinkItem -------------------------------------------------
2187 SvxBlinkItem::SvxBlinkItem( const bool bBlink
, const sal_uInt16 nId
) :
2188 SfxBoolItem( nId
, bBlink
, SfxItemType::SvxBlinkItemType
)
2192 SvxBlinkItem
* SvxBlinkItem::Clone( SfxItemPool
* ) const
2194 return new SvxBlinkItem( *this );
2197 bool SvxBlinkItem::GetPresentation
2199 SfxItemPresentation
/*ePres*/,
2200 MapUnit
/*eCoreUnit*/,
2201 MapUnit
/*ePresUnit*/,
2202 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2205 TranslateId pId
= RID_SVXITEMS_BLINK_FALSE
;
2208 pId
= RID_SVXITEMS_BLINK_TRUE
;
2209 rText
= EditResId(pId
);
2213 // class SvxEmphaisMarkItem ---------------------------------------------------
2215 ItemInstanceManager
* SvxEmphasisMarkItem::getItemInstanceManager() const
2217 static DefaultItemInstanceManager
aInstanceManager(ItemType());
2218 return &aInstanceManager
;
2221 SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue
,
2222 TypedWhichId
<SvxEmphasisMarkItem
> nId
)
2223 : SfxUInt16Item( nId
, static_cast<sal_uInt16
>(nValue
), SfxItemType::SvxEmphasisMarkItemType
)
2227 SvxEmphasisMarkItem
* SvxEmphasisMarkItem::Clone( SfxItemPool
* ) const
2229 return new SvxEmphasisMarkItem( *this );
2232 bool SvxEmphasisMarkItem::GetPresentation
2234 SfxItemPresentation
/*ePres*/,
2235 MapUnit
/*eCoreUnit*/,
2236 MapUnit
/*ePresUnit*/,
2238 const IntlWrapper
& /*rIntl*/
2241 static TranslateId RID_SVXITEMS_EMPHASIS
[] =
2243 RID_SVXITEMS_EMPHASIS_NONE_STYLE
,
2244 RID_SVXITEMS_EMPHASIS_DOT_STYLE
,
2245 RID_SVXITEMS_EMPHASIS_CIRCLE_STYLE
,
2246 RID_SVXITEMS_EMPHASIS_DISC_STYLE
,
2247 RID_SVXITEMS_EMPHASIS_ACCENT_STYLE
2250 FontEmphasisMark nVal
= GetEmphasisMark();
2251 rText
= EditResId(RID_SVXITEMS_EMPHASIS
[
2252 static_cast<sal_uInt16
>(static_cast<FontEmphasisMark
>( nVal
& FontEmphasisMark::Style
))]);
2253 TranslateId pId
= ( FontEmphasisMark::PosAbove
& nVal
)
2254 ? RID_SVXITEMS_EMPHASIS_ABOVE_POS
2255 : ( FontEmphasisMark::PosBelow
& nVal
)
2256 ? RID_SVXITEMS_EMPHASIS_BELOW_POS
2259 rText
+= EditResId( pId
);
2263 bool SvxEmphasisMarkItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2265 nMemberId
&= ~CONVERT_TWIPS
;
2270 FontEmphasisMark nValue
= GetEmphasisMark();
2272 switch(nValue
& FontEmphasisMark::Style
)
2274 case FontEmphasisMark::NONE
: nRet
= FontEmphasis::NONE
; break;
2275 case FontEmphasisMark::Dot
: nRet
= FontEmphasis::DOT_ABOVE
; break;
2276 case FontEmphasisMark::Circle
: nRet
= FontEmphasis::CIRCLE_ABOVE
; break;
2277 case FontEmphasisMark::Disc
: nRet
= FontEmphasis::DISK_ABOVE
; break;
2278 case FontEmphasisMark::Accent
: nRet
= FontEmphasis::ACCENT_ABOVE
; break;
2281 if(nRet
&& nValue
& FontEmphasisMark::PosBelow
)
2290 bool SvxEmphasisMarkItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2292 nMemberId
&= ~CONVERT_TWIPS
;
2297 sal_Int32 nValue
= -1;
2299 FontEmphasisMark nMark
;
2302 case FontEmphasis::NONE
: nMark
= FontEmphasisMark::NONE
; break;
2303 case FontEmphasis::DOT_ABOVE
: nMark
= FontEmphasisMark::Dot
|FontEmphasisMark::PosAbove
; break;
2304 case FontEmphasis::CIRCLE_ABOVE
: nMark
= FontEmphasisMark::Circle
|FontEmphasisMark::PosAbove
; break;
2305 case FontEmphasis::DISK_ABOVE
: nMark
= FontEmphasisMark::Disc
|FontEmphasisMark::PosAbove
; break;
2306 case FontEmphasis::ACCENT_ABOVE
: nMark
= FontEmphasisMark::Accent
|FontEmphasisMark::PosAbove
; break;
2307 case FontEmphasis::DOT_BELOW
: nMark
= FontEmphasisMark::Dot
|FontEmphasisMark::PosBelow
; break;
2308 case FontEmphasis::CIRCLE_BELOW
: nMark
= FontEmphasisMark::Circle
|FontEmphasisMark::PosBelow
; break;
2309 case FontEmphasis::DISK_BELOW
: nMark
= FontEmphasisMark::Disc
|FontEmphasisMark::PosBelow
; break;
2310 case FontEmphasis::ACCENT_BELOW
: nMark
= FontEmphasisMark::Accent
|FontEmphasisMark::PosBelow
; break;
2311 default: return false;
2313 ASSERT_CHANGE_REFCOUNTED_ITEM
;
2314 SetValue( static_cast<sal_Int16
>(nMark
) );
2321 /*************************************************************************
2322 |* class SvxTwoLinesItem
2323 *************************************************************************/
2325 SvxTwoLinesItem::SvxTwoLinesItem( bool bFlag
, sal_Unicode nStartBracket
,
2326 sal_Unicode nEndBracket
, sal_uInt16 nW
)
2327 : SfxPoolItem( nW
, SfxItemType::SvxTwoLinesItemType
),
2328 cStartBracket( nStartBracket
), cEndBracket( nEndBracket
), bOn( bFlag
)
2332 SvxTwoLinesItem::~SvxTwoLinesItem()
2336 bool SvxTwoLinesItem::operator==( const SfxPoolItem
& rAttr
) const
2338 assert(SfxPoolItem::operator==(rAttr
));
2339 return bOn
== static_cast<const SvxTwoLinesItem
&>(rAttr
).bOn
&&
2340 cStartBracket
== static_cast<const SvxTwoLinesItem
&>(rAttr
).cStartBracket
&&
2341 cEndBracket
== static_cast<const SvxTwoLinesItem
&>(rAttr
).cEndBracket
;
2344 SvxTwoLinesItem
* SvxTwoLinesItem::Clone( SfxItemPool
* ) const
2346 return new SvxTwoLinesItem( *this );
2349 bool SvxTwoLinesItem::QueryValue( css::uno::Any
& rVal
,
2350 sal_uInt8 nMemberId
) const
2352 nMemberId
&= ~CONVERT_TWIPS
;
2359 case MID_START_BRACKET
:
2363 s
= OUString( cStartBracket
);
2367 case MID_END_BRACKET
:
2371 s
= OUString( cEndBracket
);
2382 bool SvxTwoLinesItem::PutValue( const css::uno::Any
& rVal
,
2383 sal_uInt8 nMemberId
)
2385 nMemberId
&= ~CONVERT_TWIPS
;
2391 bOn
= Any2Bool( rVal
);
2394 case MID_START_BRACKET
:
2397 cStartBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
2401 case MID_END_BRACKET
:
2404 cEndBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
2412 bool SvxTwoLinesItem::GetPresentation( SfxItemPresentation
/*ePres*/,
2413 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2414 OUString
&rText
, const IntlWrapper
& /*rIntl*/ ) const
2417 rText
= EditResId( RID_SVXITEMS_TWOLINES_OFF
);
2420 rText
= EditResId( RID_SVXITEMS_TWOLINES
);
2421 if( GetStartBracket() )
2422 rText
= OUStringChar(GetStartBracket()) + rText
;
2423 if( GetEndBracket() )
2424 rText
+= OUStringChar(GetEndBracket());
2430 /*************************************************************************
2431 |* class SvxTextRotateItem
2432 *************************************************************************/
2434 SvxTextRotateItem::SvxTextRotateItem(Degree10 nValue
, TypedWhichId
<SvxTextRotateItem
> nW
, SfxItemType eItemType
)
2435 : SfxUInt16Item(nW
, nValue
.get(), eItemType
)
2439 SvxTextRotateItem
* SvxTextRotateItem::Clone(SfxItemPool
*) const
2441 return new SvxTextRotateItem(*this);
2444 bool SvxTextRotateItem::GetPresentation(
2445 SfxItemPresentation
/*ePres*/,
2446 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2447 OUString
&rText
, const IntlWrapper
&) const
2450 rText
= EditResId(RID_SVXITEMS_TEXTROTATE_OFF
);
2453 rText
= EditResId(RID_SVXITEMS_TEXTROTATE
);
2454 rText
= rText
.replaceFirst("$(ARG1)",
2455 OUString::number(toDegrees(GetValue())));
2460 bool SvxTextRotateItem::QueryValue(css::uno::Any
& rVal
,
2461 sal_uInt8 nMemberId
) const
2463 nMemberId
&= ~CONVERT_TWIPS
;
2468 rVal
<<= static_cast<sal_Int16
>(GetValue());
2477 bool SvxTextRotateItem::PutValue(const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
2479 nMemberId
&= ~CONVERT_TWIPS
;
2486 if ((rVal
>>= nVal
) && (0 == nVal
|| 900 == nVal
|| 2700 == nVal
))
2487 SetValue(Degree10(nVal
));
2498 void SvxTextRotateItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2500 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxTextRotateItem"));
2501 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2502 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue().get()).getStr()));
2503 (void)xmlTextWriterEndElement(pWriter
);
2507 /*************************************************************************
2508 |* class SvxCharRotateItem
2509 *************************************************************************/
2511 SvxCharRotateItem::SvxCharRotateItem( Degree10 nValue
,
2513 TypedWhichId
<SvxCharRotateItem
> nW
)
2514 : SvxTextRotateItem(nValue
, nW
, SfxItemType::SvxCharRotateItemType
),
2515 bFitToLine( bFitIntoLine
)
2519 SvxCharRotateItem
* SvxCharRotateItem::Clone( SfxItemPool
* ) const
2521 return new SvxCharRotateItem( *this );
2524 bool SvxCharRotateItem::GetPresentation(
2525 SfxItemPresentation
/*ePres*/,
2526 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2527 OUString
&rText
, const IntlWrapper
&) const
2530 rText
= EditResId( RID_SVXITEMS_CHARROTATE_OFF
);
2533 rText
= EditResId( RID_SVXITEMS_CHARROTATE
);
2534 rText
= rText
.replaceFirst( "$(ARG1)",
2535 OUString::number( toDegrees(GetValue()) ));
2537 rText
+= EditResId( RID_SVXITEMS_CHARROTATE_FITLINE
);
2542 bool SvxCharRotateItem::QueryValue( css::uno::Any
& rVal
,
2543 sal_uInt8 nMemberId
) const
2546 switch(nMemberId
& ~CONVERT_TWIPS
)
2549 SvxTextRotateItem::QueryValue(rVal
, nMemberId
);
2552 rVal
<<= IsFitToLine();
2561 bool SvxCharRotateItem::PutValue( const css::uno::Any
& rVal
,
2562 sal_uInt8 nMemberId
)
2565 switch(nMemberId
& ~CONVERT_TWIPS
)
2569 bRet
= SvxTextRotateItem::PutValue(rVal
, nMemberId
);
2574 SetFitToLine( Any2Bool( rVal
) );
2582 bool SvxCharRotateItem::operator==( const SfxPoolItem
& rItem
) const
2584 assert(SfxPoolItem::operator==(rItem
));
2585 return SvxTextRotateItem::operator==( rItem
) &&
2586 IsFitToLine() == static_cast<const SvxCharRotateItem
&>(rItem
).IsFitToLine();
2589 void SvxCharRotateItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2591 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxCharRotateItem"));
2592 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2593 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue().get()).getStr()));
2594 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("fitToLine"), BAD_CAST(OString::boolean(IsFitToLine()).getStr()));
2595 (void)xmlTextWriterEndElement(pWriter
);
2598 /*************************************************************************
2599 |* class SvxCharScaleItem
2600 *************************************************************************/
2602 SvxCharScaleWidthItem::SvxCharScaleWidthItem( sal_uInt16 nValue
,
2603 TypedWhichId
<SvxCharScaleWidthItem
> nW
)
2604 : SfxUInt16Item( nW
, nValue
, SfxItemType::SvxCharScaleWidthItemType
)
2608 SvxCharScaleWidthItem
* SvxCharScaleWidthItem::Clone( SfxItemPool
* ) const
2610 return new SvxCharScaleWidthItem( *this );
2613 bool SvxCharScaleWidthItem::GetPresentation(
2614 SfxItemPresentation
/*ePres*/,
2615 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2616 OUString
&rText
, const IntlWrapper
&) const
2619 rText
= EditResId( RID_SVXITEMS_CHARSCALE_OFF
);
2622 rText
= EditResId( RID_SVXITEMS_CHARSCALE
);
2623 rText
= rText
.replaceFirst( "$(ARG1)",
2624 OUString::number( GetValue() ));
2629 bool SvxCharScaleWidthItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
2631 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
2632 // where we still want this to be a sal_Int16
2633 sal_Int16 nValue
= sal_Int16();
2634 if (rVal
>>= nValue
)
2636 SetValue( static_cast<sal_uInt16
>(nValue
) );
2640 SAL_WARN("editeng.items", "SvxCharScaleWidthItem::PutValue - Wrong type!" );
2644 bool SvxCharScaleWidthItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
2646 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
2647 // where we still want this to be a sal_Int16
2648 rVal
<<= static_cast<sal_Int16
>(GetValue());
2652 /*************************************************************************
2653 |* class SvxCharReliefItem
2654 *************************************************************************/
2656 ItemInstanceManager
* SvxCharReliefItem::getItemInstanceManager() const
2658 static DefaultItemInstanceManager
aInstanceManager(ItemType());
2659 return &aInstanceManager
;
2662 SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue
,
2663 const sal_uInt16 nId
)
2664 : SfxEnumItem( nId
, SfxItemType::SvxCharReliefItemType
, eValue
)
2668 SvxCharReliefItem
* SvxCharReliefItem::Clone( SfxItemPool
* ) const
2670 return new SvxCharReliefItem( *this );
2673 static TranslateId RID_SVXITEMS_RELIEF
[] =
2675 RID_SVXITEMS_RELIEF_NONE
,
2676 RID_SVXITEMS_RELIEF_EMBOSSED
,
2677 RID_SVXITEMS_RELIEF_ENGRAVED
2680 OUString
SvxCharReliefItem::GetValueTextByPos(sal_uInt16 nPos
)
2682 assert(nPos
< std::size(RID_SVXITEMS_RELIEF
) && "enum overflow");
2683 return EditResId(RID_SVXITEMS_RELIEF
[nPos
]);
2686 sal_uInt16
SvxCharReliefItem::GetValueCount() const
2688 return std::size(RID_SVXITEMS_RELIEF
) - 1;
2691 bool SvxCharReliefItem::GetPresentation
2693 SfxItemPresentation
/*ePres*/,
2694 MapUnit
/*eCoreUnit*/,
2695 MapUnit
/*ePresUnit*/,
2696 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2699 rText
= GetValueTextByPos( static_cast<sal_uInt16
>(GetValue()) );
2703 bool SvxCharReliefItem::PutValue( const css::uno::Any
& rVal
,
2704 sal_uInt8 nMemberId
)
2706 nMemberId
&= ~CONVERT_TWIPS
;
2712 sal_Int16 nVal
= -1;
2714 if(nVal
>= 0 && nVal
<= sal_Int16(FontRelief::Engraved
))
2716 ASSERT_CHANGE_REFCOUNTED_ITEM
;
2717 SetValue( static_cast<FontRelief
>(nVal
) );
2730 bool SvxCharReliefItem::QueryValue( css::uno::Any
& rVal
,
2731 sal_uInt8 nMemberId
) const
2733 nMemberId
&= ~CONVERT_TWIPS
;
2738 rVal
<<= static_cast<sal_Int16
>(GetValue());
2747 /*************************************************************************
2748 |* class SvxScriptSetItem
2749 *************************************************************************/
2751 SvxScriptSetItem::SvxScriptSetItem( sal_uInt16 nSlotId
, SfxItemPool
& rPool
)
2752 : SfxSetItem( nSlotId
, SfxItemSet( rPool
,
2753 svl::Items
<SID_ATTR_CHAR_FONT
, SID_ATTR_CHAR_FONT
> ),
2754 SfxItemType::SvxScriptSetItemType
)
2756 sal_uInt16 nLatin
, nAsian
, nComplex
;
2757 GetWhichIds( nLatin
, nAsian
, nComplex
);
2758 GetItemSet().MergeRange( nLatin
, nLatin
);
2759 GetItemSet().MergeRange( nAsian
, nAsian
);
2760 GetItemSet().MergeRange( nComplex
, nComplex
);
2763 SvxScriptSetItem
* SvxScriptSetItem::Clone( SfxItemPool
* ) const
2765 SvxScriptSetItem
* p
= new SvxScriptSetItem( Which(), *GetItemSet().GetPool() );
2766 p
->GetItemSet().Put( GetItemSet(), false );
2770 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScriptSet(
2771 const SfxItemSet
& rSet
, sal_uInt16 nId
)
2773 const SfxPoolItem
* pI
;
2774 SfxItemState eSt
= rSet
.GetItemState( nId
, false, &pI
);
2775 if( SfxItemState::SET
!= eSt
)
2776 pI
= SfxItemState::DEFAULT
== eSt
? &rSet
.Get( nId
) : nullptr;
2780 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, SvtScriptType nScript
)
2782 sal_uInt16 nLatin
, nAsian
, nComplex
;
2783 GetWhichIds( nSlotId
, rSet
, nLatin
, nAsian
, nComplex
);
2785 const SfxPoolItem
*pRet
, *pAsn
, *pCmplx
;
2786 if (nScript
== SvtScriptType::ASIAN
)
2788 pRet
= GetItemOfScriptSet( rSet
, nAsian
);
2789 } else if (nScript
== SvtScriptType::COMPLEX
)
2791 pRet
= GetItemOfScriptSet( rSet
, nComplex
);
2792 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::ASIAN
))
2794 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2795 nullptr == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2798 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::COMPLEX
))
2800 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2801 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2804 } else if (nScript
== (SvtScriptType::ASIAN
|SvtScriptType::COMPLEX
))
2806 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2807 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2810 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::ASIAN
|SvtScriptType::COMPLEX
))
2812 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2813 nullptr == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2814 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2815 *pRet
!= *pAsn
|| *pRet
!= *pCmplx
)
2818 //no one valid -> match to latin
2819 pRet
= GetItemOfScriptSet( rSet
, nLatin
);
2824 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( SvtScriptType nScript
) const
2826 return GetItemOfScript( Which(), GetItemSet(), nScript
);
2829 void SvxScriptSetItem::PutItemForScriptType( SvtScriptType nScriptType
,
2830 const SfxPoolItem
& rItem
)
2832 sal_uInt16 nLatin
, nAsian
, nComplex
;
2833 GetWhichIds( nLatin
, nAsian
, nComplex
);
2835 if( SvtScriptType::LATIN
& nScriptType
)
2837 GetItemSet().Put( rItem
.CloneSetWhich(nLatin
) );
2839 if( SvtScriptType::ASIAN
& nScriptType
)
2841 GetItemSet().Put( rItem
.CloneSetWhich(nAsian
) );
2843 if( SvtScriptType::COMPLEX
& nScriptType
)
2845 GetItemSet().Put( rItem
.CloneSetWhich(nComplex
) );
2849 void SvxScriptSetItem::GetWhichIds( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, sal_uInt16
& rLatin
, sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
2851 const SfxItemPool
& rPool
= *rSet
.GetPool();
2852 GetSlotIds( nSlotId
, rLatin
, rAsian
, rComplex
);
2853 rLatin
= rPool
.GetWhichIDFromSlotID( rLatin
);
2854 rAsian
= rPool
.GetWhichIDFromSlotID( rAsian
);
2855 rComplex
= rPool
.GetWhichIDFromSlotID( rComplex
);
2858 void SvxScriptSetItem::GetWhichIds( sal_uInt16
& rLatin
, sal_uInt16
& rAsian
,
2859 sal_uInt16
& rComplex
) const
2861 GetWhichIds( Which(), GetItemSet(), rLatin
, rAsian
, rComplex
);
2864 void SvxScriptSetItem::GetSlotIds( sal_uInt16 nSlotId
, sal_uInt16
& rLatin
,
2865 sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
2870 SAL_WARN( "editeng.items", "wrong SlotId for class SvxScriptSetItem" );
2871 [[fallthrough
]]; // default to font - Id Range !!
2873 case SID_ATTR_CHAR_FONT
:
2874 rLatin
= SID_ATTR_CHAR_FONT
;
2875 rAsian
= SID_ATTR_CHAR_CJK_FONT
;
2876 rComplex
= SID_ATTR_CHAR_CTL_FONT
;
2878 case SID_ATTR_CHAR_FONTHEIGHT
:
2879 rLatin
= SID_ATTR_CHAR_FONTHEIGHT
;
2880 rAsian
= SID_ATTR_CHAR_CJK_FONTHEIGHT
;
2881 rComplex
= SID_ATTR_CHAR_CTL_FONTHEIGHT
;
2883 case SID_ATTR_CHAR_WEIGHT
:
2884 rLatin
= SID_ATTR_CHAR_WEIGHT
;
2885 rAsian
= SID_ATTR_CHAR_CJK_WEIGHT
;
2886 rComplex
= SID_ATTR_CHAR_CTL_WEIGHT
;
2888 case SID_ATTR_CHAR_POSTURE
:
2889 rLatin
= SID_ATTR_CHAR_POSTURE
;
2890 rAsian
= SID_ATTR_CHAR_CJK_POSTURE
;
2891 rComplex
= SID_ATTR_CHAR_CTL_POSTURE
;
2893 case SID_ATTR_CHAR_LANGUAGE
:
2894 rLatin
= SID_ATTR_CHAR_LANGUAGE
;
2895 rAsian
= SID_ATTR_CHAR_CJK_LANGUAGE
;
2896 rComplex
= SID_ATTR_CHAR_CTL_LANGUAGE
;
2898 case SID_ATTR_CHAR_SHADOWED
:
2899 rLatin
= SID_ATTR_CHAR_SHADOWED
;
2900 rAsian
= SID_ATTR_CHAR_SHADOWED
;
2901 rComplex
= SID_ATTR_CHAR_SHADOWED
;
2903 case SID_ATTR_CHAR_STRIKEOUT
:
2904 rLatin
= SID_ATTR_CHAR_STRIKEOUT
;
2905 rAsian
= SID_ATTR_CHAR_STRIKEOUT
;
2906 rComplex
= SID_ATTR_CHAR_STRIKEOUT
;
2911 void GetDefaultFonts( SvxFontItem
& rLatin
, SvxFontItem
& rAsian
, SvxFontItem
& rComplex
)
2913 const sal_uInt16 nItemCnt
= 3;
2917 DefaultFontType nFontType
;
2918 LanguageType nLanguage
;
2920 const aOutTypeArr
[ nItemCnt
] =
2922 { DefaultFontType::LATIN_TEXT
, LANGUAGE_ENGLISH_US
},
2923 { DefaultFontType::CJK_TEXT
, LANGUAGE_ENGLISH_US
},
2924 { DefaultFontType::CTL_TEXT
, LANGUAGE_ARABIC_SAUDI_ARABIA
}
2927 SvxFontItem
* aItemArr
[ nItemCnt
] = { &rLatin
, &rAsian
, &rComplex
};
2929 for ( sal_uInt16 n
= 0; n
< nItemCnt
; ++n
)
2931 vcl::Font
aFont( OutputDevice::GetDefaultFont( aOutTypeArr
[ n
].nFontType
,
2932 aOutTypeArr
[ n
].nLanguage
,
2933 GetDefaultFontFlags::OnlyOne
) );
2934 SvxFontItem
* pItem
= aItemArr
[ n
];
2935 pItem
->SetFamily( aFont
.GetFamilyType() );
2936 pItem
->SetFamilyName( aFont
.GetFamilyName() );
2937 pItem
->SetStyleName( OUString() );
2938 pItem
->SetPitch( aFont
.GetPitch());
2939 pItem
->SetCharSet(aFont
.GetCharSet());
2943 // class SvxRsidItem -----------------------------------------------------
2945 ItemInstanceManager
* SvxRsidItem::getItemInstanceManager() const
2947 static HashedItemInstanceManager
aInstanceManager(ItemType());
2948 return &aInstanceManager
;
2951 bool SvxRsidItem::QueryValue( uno::Any
& rVal
, sal_uInt8
) const
2953 rVal
<<= GetValue();
2957 bool SvxRsidItem::PutValue( const uno::Any
& rVal
, sal_uInt8
)
2959 sal_uInt32 nRsid
= 0;
2960 if( !( rVal
>>= nRsid
) )
2967 SvxRsidItem
* SvxRsidItem::Clone( SfxItemPool
* ) const
2969 return new SvxRsidItem( *this );
2972 bool SvxRsidItem::GetPresentation
2974 SfxItemPresentation
/*ePres*/,
2975 MapUnit
/*eCoreUnit*/,
2976 MapUnit
/*ePresUnit*/,
2977 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2984 void SvxRsidItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2986 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxRsidItem"));
2987 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
2988 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%" SAL_PRIuUINT32
, GetValue());
2989 (void)xmlTextWriterEndElement(pWriter
);
2992 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */