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>
23 #include <vcl/bitmapex.hxx>
24 #include <tools/stream.hxx>
26 #include <rtl/math.hxx>
27 #include <sal/log.hxx>
28 #include <osl/diagnose.h>
29 #include <unotools/fontdefs.hxx>
30 #include <unotools/intlwrapper.hxx>
31 #include <unotools/syslocale.hxx>
32 #include <vcl/outdev.hxx>
33 #include <vcl/unohelp.hxx>
34 #include <editeng/eeitem.hxx>
35 #include <svtools/unitconv.hxx>
37 #include <editeng/editids.hrc>
38 #include <editeng/editrids.hrc>
39 #include <vcl/vclenum.hxx>
40 #include <tools/tenccvt.hxx>
41 #include <tools/mapunit.hxx>
43 #include <rtl/ustring.hxx>
44 #include <i18nlangtag/languagetag.hxx>
45 #include <svl/itemset.hxx>
47 #include <comphelper/fileformat.h>
48 #include <svtools/langtab.hxx>
49 #include <svl/itempool.hxx>
50 #include <svtools/ctrltool.hxx>
51 #include <vcl/settings.hxx>
52 #include <vcl/svapp.hxx>
53 #include <com/sun/star/awt/SimpleFontMetric.hpp>
54 #include <com/sun/star/awt/FontWeight.hpp>
55 #include <com/sun/star/awt/FontSlant.hpp>
56 #include <com/sun/star/awt/CharSet.hpp>
57 #include <com/sun/star/awt/FontWidth.hpp>
58 #include <com/sun/star/awt/XFont.hpp>
59 #include <com/sun/star/awt/FontType.hpp>
60 #include <com/sun/star/awt/FontUnderline.hpp>
61 #include <com/sun/star/awt/FontStrikeout.hpp>
62 #include <com/sun/star/awt/FontFamily.hpp>
63 #include <com/sun/star/awt/FontPitch.hpp>
64 #include <com/sun/star/lang/Locale.hpp>
65 #include <com/sun/star/text/FontEmphasis.hpp>
66 #include <com/sun/star/i18n/ScriptType.hpp>
67 #include <editeng/rsiditem.hxx>
68 #include <editeng/memberids.h>
69 #include <editeng/flstitem.hxx>
70 #include <editeng/fontitem.hxx>
71 #include <editeng/postitem.hxx>
72 #include <editeng/wghtitem.hxx>
73 #include <editeng/fhgtitem.hxx>
74 #include <editeng/udlnitem.hxx>
75 #include <editeng/crossedoutitem.hxx>
76 #include <editeng/shdditem.hxx>
77 #include <editeng/autokernitem.hxx>
78 #include <editeng/wrlmitem.hxx>
79 #include <editeng/contouritem.hxx>
80 #include <editeng/colritem.hxx>
81 #include <editeng/kernitem.hxx>
82 #include <editeng/cmapitem.hxx>
83 #include <editeng/escapementitem.hxx>
84 #include <editeng/langitem.hxx>
85 #include <editeng/nhypitem.hxx>
86 #include <editeng/blinkitem.hxx>
87 #include <editeng/emphasismarkitem.hxx>
88 #include <editeng/twolinesitem.hxx>
89 #include <editeng/scripttypeitem.hxx>
90 #include <editeng/charrotateitem.hxx>
91 #include <editeng/charscaleitem.hxx>
92 #include <editeng/charreliefitem.hxx>
93 #include <editeng/itemtype.hxx>
94 #include <editeng/eerdll.hxx>
95 #include <libxml/xmlwriter.h>
97 using namespace ::com::sun::star
;
98 using namespace ::com::sun::star::text
;
100 SfxPoolItem
* SvxFontItem::CreateDefault() {return new SvxFontItem(0);}
101 SfxPoolItem
* SvxPostureItem::CreateDefault() { return new SvxPostureItem(ITALIC_NONE
, 0);}
102 SfxPoolItem
* SvxWeightItem::CreateDefault() {return new SvxWeightItem(WEIGHT_NORMAL
, 0);}
103 SfxPoolItem
* SvxFontHeightItem::CreateDefault() {return new SvxFontHeightItem(240, 100, 0);}
104 SfxPoolItem
* SvxUnderlineItem::CreateDefault() {return new SvxUnderlineItem(LINESTYLE_NONE
, 0);}
105 SfxPoolItem
* SvxOverlineItem::CreateDefault() {return new SvxOverlineItem(LINESTYLE_NONE
, 0);}
106 SfxPoolItem
* SvxCrossedOutItem::CreateDefault() {return new SvxCrossedOutItem(STRIKEOUT_NONE
, 0);}
107 SfxPoolItem
* SvxShadowedItem::CreateDefault() {return new SvxShadowedItem(false, 0);}
108 SfxPoolItem
* SvxAutoKernItem::CreateDefault() {return new SvxAutoKernItem(false, 0);}
109 SfxPoolItem
* SvxWordLineModeItem::CreateDefault() {return new SvxWordLineModeItem(false, 0);}
110 SfxPoolItem
* SvxContourItem::CreateDefault() {return new SvxContourItem(false, 0);}
111 SfxPoolItem
* SvxColorItem::CreateDefault() {return new SvxColorItem(0);}
112 SfxPoolItem
* SvxBackgroundColorItem::CreateDefault() {return new SvxBackgroundColorItem(0);}
113 SfxPoolItem
* SvxKerningItem::CreateDefault() {return new SvxKerningItem(0, 0);}
114 SfxPoolItem
* SvxCaseMapItem::CreateDefault() {return new SvxCaseMapItem(SvxCaseMap::NotMapped
, 0);}
115 SfxPoolItem
* SvxEscapementItem::CreateDefault() {return new SvxEscapementItem(0);}
116 SfxPoolItem
* SvxLanguageItem::CreateDefault() {return new SvxLanguageItem(LANGUAGE_GERMAN
, 0);}
117 SfxPoolItem
* SvxBlinkItem::CreateDefault() {return new SvxBlinkItem(false, 0);}
118 SfxPoolItem
* SvxEmphasisMarkItem::CreateDefault() {return new SvxEmphasisMarkItem(FontEmphasisMark::NONE
, 0);}
119 SfxPoolItem
* SvxCharRotateItem::CreateDefault() {return new SvxCharRotateItem(0, false, 0);}
120 SfxPoolItem
* SvxCharScaleWidthItem::CreateDefault() {return new SvxCharScaleWidthItem(100, 0);}
121 SfxPoolItem
* SvxCharReliefItem::CreateDefault() {return new SvxCharReliefItem(FontRelief::NONE
, 0);}
124 // class SvxFontListItem -------------------------------------------------
126 SvxFontListItem::SvxFontListItem( const FontList
* pFontLst
,
127 const sal_uInt16 nId
) :
129 pFontList( pFontLst
)
133 sal_Int32 nCount
= pFontList
->GetFontNameCount();
134 aFontNameSeq
.realloc( nCount
);
136 for ( sal_Int32 i
= 0; i
< nCount
; i
++ )
137 aFontNameSeq
[i
] = pFontList
->GetFontName(i
).GetFamilyName();
142 SfxPoolItem
* SvxFontListItem::Clone( SfxItemPool
* ) const
144 return new SvxFontListItem( *this );
148 bool SvxFontListItem::operator==( const SfxPoolItem
& rAttr
) const
150 assert(SfxPoolItem::operator==(rAttr
));
152 return( pFontList
== static_cast<const SvxFontListItem
&>(rAttr
).pFontList
);
155 bool SvxFontListItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
157 rVal
<<= aFontNameSeq
;
162 bool SvxFontListItem::GetPresentation
164 SfxItemPresentation
/*ePres*/,
165 MapUnit
/*eCoreUnit*/,
166 MapUnit
/*ePresUnit*/,
167 OUString
& rText
, const IntlWrapper
& /*rIntl*/
174 // class SvxFontItem -----------------------------------------------------
176 SvxFontItem::SvxFontItem( const sal_uInt16 nId
) :
179 eFamily
= FAMILY_SWISS
;
180 ePitch
= PITCH_VARIABLE
;
181 eTextEncoding
= RTL_TEXTENCODING_DONTKNOW
;
185 SvxFontItem::SvxFontItem( const FontFamily eFam
, const OUString
& aName
,
186 const OUString
& aStName
, const FontPitch eFontPitch
,
187 const rtl_TextEncoding eFontTextEncoding
, const sal_uInt16 nId
) :
196 eTextEncoding
= eFontTextEncoding
;
200 bool SvxFontItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
202 nMemberId
&= ~CONVERT_TWIPS
;
207 css::awt::FontDescriptor aFontDescriptor
;
208 aFontDescriptor
.Name
= aFamilyName
;
209 aFontDescriptor
.StyleName
= aStyleName
;
210 aFontDescriptor
.Family
= static_cast<sal_Int16
>(eFamily
);
211 aFontDescriptor
.CharSet
= static_cast<sal_Int16
>(eTextEncoding
);
212 aFontDescriptor
.Pitch
= static_cast<sal_Int16
>(ePitch
);
213 rVal
<<= aFontDescriptor
;
216 case MID_FONT_FAMILY_NAME
:
217 rVal
<<= aFamilyName
;
219 case MID_FONT_STYLE_NAME
:
222 case MID_FONT_FAMILY
: rVal
<<= static_cast<sal_Int16
>(eFamily
); break;
223 case MID_FONT_CHAR_SET
: rVal
<<= static_cast<sal_Int16
>(eTextEncoding
); break;
224 case MID_FONT_PITCH
: rVal
<<= static_cast<sal_Int16
>(ePitch
); break;
229 bool SvxFontItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
231 nMemberId
&= ~CONVERT_TWIPS
;
236 css::awt::FontDescriptor aFontDescriptor
;
237 if ( !( rVal
>>= aFontDescriptor
))
240 aFamilyName
= aFontDescriptor
.Name
;
241 aStyleName
= aFontDescriptor
.StyleName
;
242 eFamily
= static_cast<FontFamily
>(aFontDescriptor
.Family
);
243 eTextEncoding
= static_cast<rtl_TextEncoding
>(aFontDescriptor
.CharSet
);
244 ePitch
= static_cast<FontPitch
>(aFontDescriptor
.Pitch
);
247 case MID_FONT_FAMILY_NAME
:
255 case MID_FONT_STYLE_NAME
:
263 case MID_FONT_FAMILY
:
265 sal_Int16 nFamily
= sal_Int16();
266 if(!(rVal
>>= nFamily
))
268 eFamily
= static_cast<FontFamily
>(nFamily
);
271 case MID_FONT_CHAR_SET
:
273 sal_Int16 nSet
= sal_Int16();
276 eTextEncoding
= static_cast<rtl_TextEncoding
>(nSet
);
279 case MID_FONT_PITCH
:
281 sal_Int16 nPitch
= sal_Int16();
282 if(!(rVal
>>= nPitch
))
284 ePitch
= static_cast<FontPitch
>(nPitch
);
292 bool SvxFontItem::operator==( const SfxPoolItem
& rAttr
) const
294 assert(SfxPoolItem::operator==(rAttr
));
296 const SvxFontItem
& rItem
= static_cast<const SvxFontItem
&>(rAttr
);
298 bool bRet
= ( eFamily
== rItem
.eFamily
&&
299 aFamilyName
== rItem
.aFamilyName
&&
300 aStyleName
== rItem
.aStyleName
);
304 if ( ePitch
!= rItem
.ePitch
|| eTextEncoding
!= rItem
.eTextEncoding
)
307 SAL_INFO( "editeng.items", "FontItem::operator==(): only pitch or rtl_TextEncoding different ");
314 SfxPoolItem
* SvxFontItem::Clone( SfxItemPool
* ) const
316 return new SvxFontItem( *this );
320 bool SvxFontItem::GetPresentation
322 SfxItemPresentation
/*ePres*/,
323 MapUnit
/*eCoreUnit*/,
324 MapUnit
/*ePresUnit*/,
325 OUString
& rText
, const IntlWrapper
& /*rIntl*/
333 void SvxFontItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
335 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxFontItem"));
336 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
337 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("familyName"), BAD_CAST(aFamilyName
.toUtf8().getStr()));
338 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("styleName"), BAD_CAST(aStyleName
.toUtf8().getStr()));
339 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("family"), BAD_CAST(OString::number(eFamily
).getStr()));
340 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("pitch"), BAD_CAST(OString::number(ePitch
).getStr()));
341 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("textEncoding"), BAD_CAST(OString::number(eTextEncoding
).getStr()));
342 xmlTextWriterEndElement(pWriter
);
345 // class SvxPostureItem --------------------------------------------------
347 SvxPostureItem::SvxPostureItem( const FontItalic ePosture
, const sal_uInt16 nId
) :
348 SfxEnumItem( nId
, ePosture
)
353 SfxPoolItem
* SvxPostureItem::Clone( SfxItemPool
* ) const
355 return new SvxPostureItem( *this );
359 sal_uInt16
SvxPostureItem::GetValueCount() const
361 return ITALIC_NORMAL
+ 1; // ITALIC_NONE also belongs here
365 bool SvxPostureItem::GetPresentation
367 SfxItemPresentation
/*ePres*/,
368 MapUnit
/*eCoreUnit*/,
369 MapUnit
/*ePresUnit*/,
370 OUString
& rText
, const IntlWrapper
& /*rIntl*/
373 rText
= GetValueTextByPos( GetValue() );
378 OUString
SvxPostureItem::GetValueTextByPos( sal_uInt16 nPos
)
380 DBG_ASSERT( nPos
<= sal_uInt16(ITALIC_NORMAL
), "enum overflow!" );
382 FontItalic eItalic
= static_cast<FontItalic
>(nPos
);
383 const char* pId
= nullptr;
387 case ITALIC_NONE
: pId
= RID_SVXITEMS_ITALIC_NONE
; break;
388 case ITALIC_OBLIQUE
: pId
= RID_SVXITEMS_ITALIC_OBLIQUE
; break;
389 case ITALIC_NORMAL
: pId
= RID_SVXITEMS_ITALIC_NORMAL
; break;
390 default: ;//prevent warning
393 return pId
? EditResId(pId
) : OUString();
396 bool SvxPostureItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
398 nMemberId
&= ~CONVERT_TWIPS
;
402 rVal
<<= GetBoolValue();
405 rVal
<<= vcl::unohelper::ConvertFontSlant(GetValue());
411 bool SvxPostureItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
413 nMemberId
&= ~CONVERT_TWIPS
;
417 SetBoolValue(Any2Bool(rVal
));
421 awt::FontSlant eSlant
;
422 if(!(rVal
>>= eSlant
))
424 sal_Int32 nValue
= 0;
425 if(!(rVal
>>= nValue
))
428 eSlant
= static_cast<awt::FontSlant
>(nValue
);
430 SetValue(vcl::unohelper::ConvertFontSlant(eSlant
));
436 bool SvxPostureItem::HasBoolValue() const
441 bool SvxPostureItem::GetBoolValue() const
443 return ( GetValue() >= ITALIC_OBLIQUE
);
446 void SvxPostureItem::SetBoolValue( bool bVal
)
448 SetValue( bVal
? ITALIC_NORMAL
: ITALIC_NONE
);
451 void SvxPostureItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
453 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxPostureItem"));
454 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
455 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%d", GetValue());
456 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr()));
457 xmlTextWriterEndElement(pWriter
);
460 // class SvxWeightItem ---------------------------------------------------
462 SvxWeightItem::SvxWeightItem( const FontWeight eWght
, const sal_uInt16 nId
) :
463 SfxEnumItem( nId
, eWght
)
468 bool SvxWeightItem::HasBoolValue() const
474 bool SvxWeightItem::GetBoolValue() const
476 return GetValue() >= WEIGHT_BOLD
;
480 void SvxWeightItem::SetBoolValue( bool bVal
)
482 SetValue( bVal
? WEIGHT_BOLD
: WEIGHT_NORMAL
);
486 sal_uInt16
SvxWeightItem::GetValueCount() const
488 return WEIGHT_BLACK
; // WEIGHT_DONTKNOW does not belong
492 SfxPoolItem
* SvxWeightItem::Clone( SfxItemPool
* ) const
494 return new SvxWeightItem( *this );
498 bool SvxWeightItem::GetPresentation
500 SfxItemPresentation
/*ePres*/,
501 MapUnit
/*eCoreUnit*/,
502 MapUnit
/*ePresUnit*/,
503 OUString
& rText
, const IntlWrapper
& /*rIntl*/
506 rText
= GetValueTextByPos( GetValue() );
510 OUString
SvxWeightItem::GetValueTextByPos( sal_uInt16 nPos
)
512 static const char* RID_SVXITEMS_WEIGHTS
[] =
514 RID_SVXITEMS_WEIGHT_DONTKNOW
,
515 RID_SVXITEMS_WEIGHT_THIN
,
516 RID_SVXITEMS_WEIGHT_ULTRALIGHT
,
517 RID_SVXITEMS_WEIGHT_LIGHT
,
518 RID_SVXITEMS_WEIGHT_SEMILIGHT
,
519 RID_SVXITEMS_WEIGHT_NORMAL
,
520 RID_SVXITEMS_WEIGHT_MEDIUM
,
521 RID_SVXITEMS_WEIGHT_SEMIBOLD
,
522 RID_SVXITEMS_WEIGHT_BOLD
,
523 RID_SVXITEMS_WEIGHT_ULTRABOLD
,
524 RID_SVXITEMS_WEIGHT_BLACK
527 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_WEIGHTS
) - 1 == WEIGHT_BLACK
, "must match");
528 assert(nPos
<= sal_uInt16(WEIGHT_BLACK
) && "enum overflow!" );
529 return EditResId(RID_SVXITEMS_WEIGHTS
[nPos
]);
532 bool SvxWeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
534 nMemberId
&= ~CONVERT_TWIPS
;
538 rVal
<<= GetBoolValue();
542 rVal
<<= vcl::unohelper::ConvertFontWeight( GetValue() );
549 bool SvxWeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
551 nMemberId
&= ~CONVERT_TWIPS
;
555 SetBoolValue(Any2Bool(rVal
));
560 if(!(rVal
>>= fValue
))
562 sal_Int32 nValue
= 0;
563 if(!(rVal
>>= nValue
))
565 fValue
= static_cast<float>(nValue
);
567 SetValue( vcl::unohelper::ConvertFontWeight(static_cast<float>(fValue
)) );
574 void SvxWeightItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
576 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxWeightItem"));
577 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
578 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%d", GetValue());
579 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr()));
580 xmlTextWriterEndElement(pWriter
);
583 // class SvxFontHeightItem -----------------------------------------------
585 SvxFontHeightItem::SvxFontHeightItem( const sal_uLong nSz
,
586 const sal_uInt16 nPrp
,
587 const sal_uInt16 nId
) :
590 SetHeight( nSz
,nPrp
); // calculate in percentage
594 SfxPoolItem
* SvxFontHeightItem::Clone( SfxItemPool
* ) const
596 return new SvxFontHeightItem( *this );
600 bool SvxFontHeightItem::operator==( const SfxPoolItem
& rItem
) const
602 assert(SfxPoolItem::operator==(rItem
));
603 return GetHeight() == static_cast<const SvxFontHeightItem
&>(rItem
).GetHeight() &&
604 GetProp() == static_cast<const SvxFontHeightItem
&>(rItem
).GetProp() &&
605 GetPropUnit() == static_cast<const SvxFontHeightItem
&>(rItem
).GetPropUnit();
608 bool SvxFontHeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
610 // In StarOne is the uno::Any always 1/100mm. Through the MemberId it is
611 // controlled if the value in the Item should be 1/100mm or Twips.
613 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
614 nMemberId
&= ~CONVERT_TWIPS
;
619 css::frame::status::FontHeight aFontHeight
;
621 // Point (i.e. Twips) is asked for, thus re-calculate if
622 // CONVERT_TWIPS is not set.
625 aFontHeight
.Height
= static_cast<float>( nHeight
/ 20.0 );
629 double fPoints
= convertMm100ToTwip(nHeight
) / 20.0;
631 static_cast<float>(::rtl::math::round(fPoints
, 1));
632 aFontHeight
.Height
= fRoundPoints
;
635 aFontHeight
.Prop
= static_cast<sal_Int16
>(MapUnit::MapRelative
== ePropUnit
? nProp
: 100);
637 float fRet
= static_cast<float>(static_cast<short>(nProp
));
640 case MapUnit::MapRelative
:
643 case MapUnit::Map100thMM
:
644 fRet
= convertMm100ToTwip(fRet
);
647 case MapUnit::MapPoint
:
650 case MapUnit::MapTwip
:
653 default: ;//prevent warning
655 aFontHeight
.Diff
= fRet
;
656 rVal
<<= aFontHeight
;
661 // Point (i.e. Twips) is asked for, thus re-calculate if
662 // CONVERT_TWIPS is not set.
665 rVal
<<= static_cast<float>( nHeight
/ 20.0 );
669 double fPoints
= convertMm100ToTwip(nHeight
) / 20.0;
671 static_cast<float>(::rtl::math::round(fPoints
, 1));
672 rVal
<<= fRoundPoints
;
676 case MID_FONTHEIGHT_PROP
:
677 rVal
<<= static_cast<sal_Int16
>(MapUnit::MapRelative
== ePropUnit
? nProp
: 100);
679 case MID_FONTHEIGHT_DIFF
:
681 float fRet
= static_cast<float>(static_cast<short>(nProp
));
684 case MapUnit::MapRelative
:
687 case MapUnit::Map100thMM
:
688 fRet
= convertMm100ToTwip(fRet
);
691 case MapUnit::MapPoint
:
694 case MapUnit::MapTwip
:
697 default: ;//prevent warning
706 // Try to reconstruct the original height input value from the modified height
707 // and the prop data; this seems somewhat futile given the various ways how the
708 // modified height is calculated (with and without conversion between twips and
709 // 100th mm; with an additional eCoreMetric input in one of the SetHeight
710 // overloads), and indeed known to occasionally produce nRet values that would
711 // be negative, so just guard against negative results here and throw the hands
713 static sal_uInt32
lcl_GetRealHeight_Impl(sal_uInt32 nHeight
, sal_uInt16 nProp
, MapUnit eProp
, bool bCoreInTwip
)
715 sal_uInt32 nRet
= nHeight
;
719 case MapUnit::MapRelative
:
726 case MapUnit::MapPoint
:
728 short nTemp
= static_cast<short>(nProp
);
731 nDiff
= static_cast<short>(convertTwipToMm100(static_cast<long>(nDiff
)));
734 case MapUnit::Map100thMM
:
735 //then the core is surely also in 1/100 mm
736 nDiff
= static_cast<short>(nProp
);
738 case MapUnit::MapTwip
:
740 nDiff
= static_cast<short>(nProp
);
745 nRet
= (nDiff
< 0 || nRet
>= static_cast<unsigned short>(nDiff
))
747 //TODO: overflow in case nDiff < 0 and nRet - nDiff > SAL_MAX_UINT32
752 bool SvxFontHeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
754 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
755 nMemberId
&= ~CONVERT_TWIPS
;
760 css::frame::status::FontHeight aFontHeight
;
761 if ( rVal
>>= aFontHeight
)
764 ePropUnit
= MapUnit::MapRelative
;
766 double fPoint
= aFontHeight
.Height
;
767 if( fPoint
< 0. || fPoint
> 10000. )
770 nHeight
= static_cast<long>( fPoint
* 20.0 + 0.5 ); // Twips
772 nHeight
= convertTwipToMm100(nHeight
); // Convert, if the item contains 1/100mm
774 nProp
= aFontHeight
.Prop
;
782 ePropUnit
= MapUnit::MapRelative
;
785 if(!(rVal
>>= fPoint
))
787 sal_Int32 nValue
= 0;
788 if(!(rVal
>>= nValue
))
790 fPoint
= static_cast<float>(nValue
);
792 if(fPoint
< 0. || fPoint
> 10000.)
795 nHeight
= static_cast<long>( fPoint
* 20.0 + 0.5 ); // Twips
797 nHeight
= convertTwipToMm100(nHeight
); // Convert, if the item contains 1/100mm
800 case MID_FONTHEIGHT_PROP
:
802 sal_Int16 nNew
= sal_Int16();
806 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
811 ePropUnit
= MapUnit::MapRelative
;
814 case MID_FONTHEIGHT_DIFF
:
816 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
818 if(!(rVal
>>= fValue
))
820 sal_Int32 nValue
= 0;
821 if(!(rVal
>>= nValue
))
823 fValue
= static_cast<float>(nValue
);
825 sal_Int16 nCoreDiffValue
= static_cast<sal_Int16
>(fValue
* 20.);
826 nHeight
+= bConvert
? nCoreDiffValue
: convertTwipToMm100(nCoreDiffValue
);
827 nProp
= static_cast<sal_uInt16
>(static_cast<sal_Int16
>(fValue
));
828 ePropUnit
= MapUnit::MapPoint
;
836 bool SvxFontHeightItem::GetPresentation
838 SfxItemPresentation
/*ePres*/,
840 MapUnit
/*ePresUnit*/,
841 OUString
& rText
, const IntlWrapper
& rIntl
844 if( MapUnit::MapRelative
!= ePropUnit
)
846 rText
= OUString::number( static_cast<short>(nProp
) ) +
847 " " + EditResId( GetMetricId( ePropUnit
) );
848 if( 0 <= static_cast<short>(nProp
) )
851 else if( 100 == nProp
)
853 rText
= GetMetricText( static_cast<long>(nHeight
),
854 eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
855 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
858 rText
= OUString::number( nProp
) + "%";
863 void SvxFontHeightItem::ScaleMetrics( long nMult
, long nDiv
)
865 nHeight
= static_cast<sal_uInt32
>(Scale( nHeight
, nMult
, nDiv
));
869 bool SvxFontHeightItem::HasMetrics() const
874 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, const sal_uInt16 nNewProp
,
877 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
879 if( MapUnit::MapRelative
!= eUnit
)
880 nHeight
= nNewHeight
+ ::ItemToControl( short(nNewProp
), eUnit
,
882 else if( 100 != nNewProp
)
883 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
885 nHeight
= nNewHeight
;
891 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, sal_uInt16 nNewProp
,
892 MapUnit eMetric
, MapUnit eCoreMetric
)
894 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
896 if( MapUnit::MapRelative
!= eMetric
)
897 nHeight
= nNewHeight
+
898 ::ControlToItem( ::ItemToControl(static_cast<short>(nNewProp
), eMetric
,
899 FieldUnit::TWIP
), FieldUnit::TWIP
,
901 else if( 100 != nNewProp
)
902 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
904 nHeight
= nNewHeight
;
910 void SvxFontHeightItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
912 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxFontHeightItem"));
913 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
914 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("height"), BAD_CAST(OString::number(nHeight
).getStr()));
915 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("prop"), BAD_CAST(OString::number(nProp
).getStr()));
916 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("propUnit"), BAD_CAST(OString::number(static_cast<int>(ePropUnit
)).getStr()));
917 xmlTextWriterEndElement(pWriter
);
920 // class SvxTextLineItem ------------------------------------------------
922 SvxTextLineItem::SvxTextLineItem( const FontLineStyle eSt
, const sal_uInt16 nId
)
923 : SfxEnumItem( nId
, eSt
), mColor( COL_TRANSPARENT
)
928 bool SvxTextLineItem::HasBoolValue() const
934 bool SvxTextLineItem::GetBoolValue() const
936 return GetValue() != LINESTYLE_NONE
;
940 void SvxTextLineItem::SetBoolValue( bool bVal
)
942 SetValue( bVal
? LINESTYLE_SINGLE
: LINESTYLE_NONE
);
946 SfxPoolItem
* SvxTextLineItem::Clone( SfxItemPool
* ) const
948 return new SvxTextLineItem( *this );
952 sal_uInt16
SvxTextLineItem::GetValueCount() const
954 return LINESTYLE_DOTTED
+ 1; // LINESTYLE_NONE also belongs here
958 bool SvxTextLineItem::GetPresentation
960 SfxItemPresentation
/*ePres*/,
961 MapUnit
/*eCoreUnit*/,
962 MapUnit
/*ePresUnit*/,
963 OUString
& rText
, const IntlWrapper
& /*rIntl*/
966 rText
= GetValueTextByPos( GetValue() );
967 if( !mColor
.GetTransparency() )
968 rText
= rText
+ OUString(cpDelim
) + ::GetColorString( mColor
);
973 OUString
SvxTextLineItem::GetValueTextByPos( sal_uInt16
/*nPos*/ ) const
975 OSL_FAIL("SvxTextLineItem::GetValueTextByPos: Pure virtual method");
979 bool SvxTextLineItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
981 nMemberId
&= ~CONVERT_TWIPS
;
985 rVal
<<= GetBoolValue();
988 rVal
<<= static_cast<sal_Int16
>(GetValue());
993 case MID_TL_HASCOLOR
:
994 rVal
<<= !mColor
.GetTransparency();
1001 bool SvxTextLineItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1003 nMemberId
&= ~CONVERT_TWIPS
;
1008 SetBoolValue(Any2Bool(rVal
));
1012 sal_Int32 nValue
= 0;
1013 if(!(rVal
>>= nValue
))
1016 SetValue(static_cast<FontLineStyle
>(nValue
));
1022 if( !( rVal
>>= nCol
) )
1026 // Keep transparence, because it contains the information
1027 // whether the font color or the stored color should be used
1028 sal_uInt8 nTrans
= mColor
.GetTransparency();
1029 mColor
= Color( nCol
);
1030 mColor
.SetTransparency( nTrans
);
1034 case MID_TL_HASCOLOR
:
1035 mColor
.SetTransparency( Any2Bool( rVal
) ? 0 : 0xff );
1041 bool SvxTextLineItem::operator==( const SfxPoolItem
& rItem
) const
1043 assert(SfxPoolItem::operator==(rItem
));
1044 return SfxEnumItem::operator==( static_cast<const SfxEnumItem
<FontLineStyle
>&>(rItem
) ) &&
1045 GetColor() == static_cast<const SvxTextLineItem
&>(rItem
).GetColor();
1048 // class SvxUnderlineItem ------------------------------------------------
1051 SvxUnderlineItem::SvxUnderlineItem( const FontLineStyle eSt
, const sal_uInt16 nId
)
1052 : SvxTextLineItem( eSt
, nId
)
1057 SfxPoolItem
* SvxUnderlineItem::Clone( SfxItemPool
* ) const
1059 return new SvxUnderlineItem( *this );
1063 OUString
SvxUnderlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1065 static const char* RID_SVXITEMS_UL
[] =
1067 RID_SVXITEMS_UL_NONE
,
1068 RID_SVXITEMS_UL_SINGLE
,
1069 RID_SVXITEMS_UL_DOUBLE
,
1070 RID_SVXITEMS_UL_DOTTED
,
1071 RID_SVXITEMS_UL_DONTKNOW
,
1072 RID_SVXITEMS_UL_DASH
,
1073 RID_SVXITEMS_UL_LONGDASH
,
1074 RID_SVXITEMS_UL_DASHDOT
,
1075 RID_SVXITEMS_UL_DASHDOTDOT
,
1076 RID_SVXITEMS_UL_SMALLWAVE
,
1077 RID_SVXITEMS_UL_WAVE
,
1078 RID_SVXITEMS_UL_DOUBLEWAVE
,
1079 RID_SVXITEMS_UL_BOLD
,
1080 RID_SVXITEMS_UL_BOLDDOTTED
,
1081 RID_SVXITEMS_UL_BOLDDASH
,
1082 RID_SVXITEMS_UL_BOLDLONGDASH
,
1083 RID_SVXITEMS_UL_BOLDDASHDOT
,
1084 RID_SVXITEMS_UL_BOLDDASHDOTDOT
,
1085 RID_SVXITEMS_UL_BOLDWAVE
1087 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_UL
) - 1 == LINESTYLE_BOLDWAVE
, "must match");
1088 assert(nPos
<= sal_uInt16(LINESTYLE_BOLDWAVE
) && "enum overflow!");
1089 return EditResId(RID_SVXITEMS_UL
[nPos
]);
1092 // class SvxOverlineItem ------------------------------------------------
1094 SvxOverlineItem::SvxOverlineItem( const FontLineStyle eSt
, const sal_uInt16 nId
)
1095 : SvxTextLineItem( eSt
, nId
)
1100 SfxPoolItem
* SvxOverlineItem::Clone( SfxItemPool
* ) const
1102 return new SvxOverlineItem( *this );
1106 OUString
SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1108 static const char* RID_SVXITEMS_OL
[] =
1110 RID_SVXITEMS_OL_NONE
,
1111 RID_SVXITEMS_OL_SINGLE
,
1112 RID_SVXITEMS_OL_DOUBLE
,
1113 RID_SVXITEMS_OL_DOTTED
,
1114 RID_SVXITEMS_OL_DONTKNOW
,
1115 RID_SVXITEMS_OL_DASH
,
1116 RID_SVXITEMS_OL_LONGDASH
,
1117 RID_SVXITEMS_OL_DASHDOT
,
1118 RID_SVXITEMS_OL_DASHDOTDOT
,
1119 RID_SVXITEMS_OL_SMALLWAVE
,
1120 RID_SVXITEMS_OL_WAVE
,
1121 RID_SVXITEMS_OL_DOUBLEWAVE
,
1122 RID_SVXITEMS_OL_BOLD
,
1123 RID_SVXITEMS_OL_BOLDDOTTED
,
1124 RID_SVXITEMS_OL_BOLDDASH
,
1125 RID_SVXITEMS_OL_BOLDLONGDASH
,
1126 RID_SVXITEMS_OL_BOLDDASHDOT
,
1127 RID_SVXITEMS_OL_BOLDDASHDOTDOT
,
1128 RID_SVXITEMS_OL_BOLDWAVE
1130 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_OL
) - 1 == LINESTYLE_BOLDWAVE
, "must match");
1131 assert(nPos
<= sal_uInt16(LINESTYLE_BOLDWAVE
) && "enum overflow!");
1132 return EditResId(RID_SVXITEMS_OL
[nPos
]);
1135 // class SvxCrossedOutItem -----------------------------------------------
1137 SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt
, const sal_uInt16 nId
)
1138 : SfxEnumItem( nId
, eSt
)
1143 bool SvxCrossedOutItem::HasBoolValue() const
1149 bool SvxCrossedOutItem::GetBoolValue() const
1151 return GetValue() != STRIKEOUT_NONE
;
1155 void SvxCrossedOutItem::SetBoolValue( bool bVal
)
1157 SetValue( bVal
? STRIKEOUT_SINGLE
: STRIKEOUT_NONE
);
1161 sal_uInt16
SvxCrossedOutItem::GetValueCount() const
1163 return STRIKEOUT_DOUBLE
+ 1; // STRIKEOUT_NONE belongs also here
1167 SfxPoolItem
* SvxCrossedOutItem::Clone( SfxItemPool
* ) const
1169 return new SvxCrossedOutItem( *this );
1173 bool SvxCrossedOutItem::GetPresentation
1175 SfxItemPresentation
/*ePres*/,
1176 MapUnit
/*eCoreUnit*/,
1177 MapUnit
/*ePresUnit*/,
1178 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1181 rText
= GetValueTextByPos( GetValue() );
1185 OUString
SvxCrossedOutItem::GetValueTextByPos( sal_uInt16 nPos
)
1187 static const char* RID_SVXITEMS_STRIKEOUT
[] =
1189 RID_SVXITEMS_STRIKEOUT_NONE
,
1190 RID_SVXITEMS_STRIKEOUT_SINGLE
,
1191 RID_SVXITEMS_STRIKEOUT_DOUBLE
,
1192 RID_SVXITEMS_STRIKEOUT_DONTKNOW
,
1193 RID_SVXITEMS_STRIKEOUT_BOLD
,
1194 RID_SVXITEMS_STRIKEOUT_SLASH
,
1195 RID_SVXITEMS_STRIKEOUT_X
1197 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_STRIKEOUT
) - 1 == STRIKEOUT_X
, "must match");
1198 assert(nPos
<= sal_uInt16(STRIKEOUT_X
) && "enum overflow!");
1199 return EditResId(RID_SVXITEMS_STRIKEOUT
[nPos
]);
1202 bool SvxCrossedOutItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1204 nMemberId
&= ~CONVERT_TWIPS
;
1207 case MID_CROSSED_OUT
:
1208 rVal
<<= GetBoolValue();
1211 rVal
<<= static_cast<sal_Int16
>(GetValue());
1217 bool SvxCrossedOutItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1219 nMemberId
&= ~CONVERT_TWIPS
;
1222 case MID_CROSSED_OUT
:
1223 SetBoolValue(Any2Bool(rVal
));
1227 sal_Int32 nValue
= 0;
1228 if(!(rVal
>>= nValue
))
1230 SetValue(static_cast<FontStrikeout
>(nValue
));
1236 // class SvxShadowedItem -------------------------------------------------
1238 SvxShadowedItem::SvxShadowedItem( const bool bShadowed
, const sal_uInt16 nId
) :
1239 SfxBoolItem( nId
, bShadowed
)
1244 SfxPoolItem
* SvxShadowedItem::Clone( SfxItemPool
* ) const
1246 return new SvxShadowedItem( *this );
1250 bool SvxShadowedItem::GetPresentation
1252 SfxItemPresentation
/*ePres*/,
1253 MapUnit
/*eCoreUnit*/,
1254 MapUnit
/*ePresUnit*/,
1255 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1258 const char* pId
= RID_SVXITEMS_SHADOWED_FALSE
;
1261 pId
= RID_SVXITEMS_SHADOWED_TRUE
;
1262 rText
= EditResId(pId
);
1266 // class SvxAutoKernItem -------------------------------------------------
1268 SvxAutoKernItem::SvxAutoKernItem( const bool bAutoKern
, const sal_uInt16 nId
) :
1269 SfxBoolItem( nId
, bAutoKern
)
1274 SfxPoolItem
* SvxAutoKernItem::Clone( SfxItemPool
* ) const
1276 return new SvxAutoKernItem( *this );
1280 bool SvxAutoKernItem::GetPresentation
1282 SfxItemPresentation
/*ePres*/,
1283 MapUnit
/*eCoreUnit*/,
1284 MapUnit
/*ePresUnit*/,
1285 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1288 const char* pId
= RID_SVXITEMS_AUTOKERN_FALSE
;
1291 pId
= RID_SVXITEMS_AUTOKERN_TRUE
;
1292 rText
= EditResId(pId
);
1296 // class SvxWordLineModeItem ---------------------------------------------
1298 SvxWordLineModeItem::SvxWordLineModeItem( const bool bWordLineMode
,
1299 const sal_uInt16 nId
) :
1300 SfxBoolItem( nId
, bWordLineMode
)
1305 SfxPoolItem
* SvxWordLineModeItem::Clone( SfxItemPool
* ) const
1307 return new SvxWordLineModeItem( *this );
1311 bool SvxWordLineModeItem::GetPresentation
1313 SfxItemPresentation
/*ePres*/,
1314 MapUnit
/*eCoreUnit*/,
1315 MapUnit
/*ePresUnit*/,
1316 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1319 const char* pId
= RID_SVXITEMS_WORDLINE_FALSE
;
1322 pId
= RID_SVXITEMS_WORDLINE_TRUE
;
1323 rText
= EditResId(pId
);
1327 // class SvxContourItem --------------------------------------------------
1329 SvxContourItem::SvxContourItem( const bool bContoured
, const sal_uInt16 nId
) :
1330 SfxBoolItem( nId
, bContoured
)
1335 SfxPoolItem
* SvxContourItem::Clone( SfxItemPool
* ) const
1337 return new SvxContourItem( *this );
1341 bool SvxContourItem::GetPresentation
1343 SfxItemPresentation
/*ePres*/,
1344 MapUnit
/*eCoreUnit*/,
1345 MapUnit
/*ePresUnit*/,
1346 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1349 const char* pId
= RID_SVXITEMS_CONTOUR_FALSE
;
1352 pId
= RID_SVXITEMS_CONTOUR_TRUE
;
1353 rText
= EditResId(pId
);
1357 // class SvxBackgroundColorItem -----------------------------------------
1359 SvxBackgroundColorItem::SvxBackgroundColorItem( const sal_uInt16 nId
) :
1365 SvxBackgroundColorItem::SvxBackgroundColorItem( const Color
& rCol
,
1366 const sal_uInt16 nId
) :
1367 SvxColorItem( rCol
, nId
)
1371 SfxPoolItem
* SvxBackgroundColorItem::Clone( SfxItemPool
* ) const
1373 return new SvxBackgroundColorItem(*this);
1376 bool SvxBackgroundColorItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1378 nMemberId
&= ~CONVERT_TWIPS
;
1379 Color aColor
= SvxColorItem::GetValue();
1383 case MID_GRAPHIC_TRANSPARENT
:
1385 rVal
<<= aColor
.GetTransparency() == 0xff;
1397 bool SvxBackgroundColorItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1399 nMemberId
&= ~CONVERT_TWIPS
;
1400 sal_Int32 nColor
= 0;
1401 Color aColor
= SvxColorItem::GetValue();
1405 case MID_GRAPHIC_TRANSPARENT
:
1407 aColor
.SetTransparency( Any2Bool( rVal
) ? 0xff : 0 );
1408 SvxColorItem::SetValue( aColor
);
1413 if(!(rVal
>>= nColor
))
1415 SvxColorItem::SetValue( Color(nColor
) );
1422 // class SvxColorItem ----------------------------------------------------
1423 SvxColorItem::SvxColorItem( const sal_uInt16 nId
) :
1429 SvxColorItem::SvxColorItem( const Color
& rCol
, const sal_uInt16 nId
) :
1435 SvxColorItem::~SvxColorItem()
1439 bool SvxColorItem::operator==( const SfxPoolItem
& rAttr
) const
1441 assert(SfxPoolItem::operator==(rAttr
));
1443 return mColor
== static_cast<const SvxColorItem
&>( rAttr
).mColor
;
1446 bool SvxColorItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
1452 bool SvxColorItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
1454 return (rVal
>>= mColor
);
1457 SfxPoolItem
* SvxColorItem::Clone( SfxItemPool
* ) const
1459 return new SvxColorItem( *this );
1462 bool SvxColorItem::GetPresentation
1464 SfxItemPresentation
/*ePres*/,
1465 MapUnit
/*eCoreUnit*/,
1466 MapUnit
/*ePresUnit*/,
1467 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1470 rText
= ::GetColorString( mColor
);
1474 void SvxColorItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1476 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxColorItem"));
1477 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1479 IntlWrapper
aIntlWrapper(SvtSysLocale().GetUILanguageTag());
1480 GetPresentation( SfxItemPresentation::Complete
, MapUnit::Map100thMM
, MapUnit::Map100thMM
, aStr
, aIntlWrapper
);
1481 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OUStringToOString(aStr
, RTL_TEXTENCODING_UTF8
).getStr()));
1482 xmlTextWriterEndElement(pWriter
);
1487 void SvxColorItem::SetValue( const Color
& rNewCol
)
1492 // class SvxKerningItem --------------------------------------------------
1494 SvxKerningItem::SvxKerningItem( const short nKern
, const sal_uInt16 nId
) :
1495 SfxInt16Item( nId
, nKern
)
1500 SfxPoolItem
* SvxKerningItem::Clone( SfxItemPool
* ) const
1502 return new SvxKerningItem( *this );
1506 void SvxKerningItem::ScaleMetrics( long nMult
, long nDiv
)
1508 SetValue( static_cast<sal_Int16
>(Scale( GetValue(), nMult
, nDiv
)) );
1512 bool SvxKerningItem::HasMetrics() const
1518 bool SvxKerningItem::GetPresentation
1520 SfxItemPresentation ePres
,
1522 MapUnit
/*ePresUnit*/,
1523 OUString
& rText
, const IntlWrapper
& rIntl
1528 case SfxItemPresentation::Nameless
:
1529 rText
= GetMetricText( static_cast<long>(GetValue()), eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
1530 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
1532 case SfxItemPresentation::Complete
:
1534 rText
= EditResId(RID_SVXITEMS_KERNING_COMPLETE
);
1535 const char* pId
= nullptr;
1537 if ( GetValue() > 0 )
1538 pId
= RID_SVXITEMS_KERNING_EXPANDED
;
1539 else if ( GetValue() < 0 )
1540 pId
= RID_SVXITEMS_KERNING_CONDENSED
;
1543 rText
+= EditResId(pId
);
1545 GetMetricText( static_cast<long>(GetValue()), eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
1546 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
1549 default: ; //prevent warning
1554 bool SvxKerningItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1556 sal_Int16 nVal
= GetValue();
1557 if(nMemberId
& CONVERT_TWIPS
)
1558 nVal
= static_cast<sal_Int16
>(convertTwipToMm100(nVal
));
1563 bool SvxKerningItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1565 sal_Int16 nVal
= sal_Int16();
1566 if(!(rVal
>>= nVal
))
1568 if(nMemberId
& CONVERT_TWIPS
)
1569 nVal
= static_cast<sal_Int16
>(convertMm100ToTwip(nVal
));
1574 // class SvxCaseMapItem --------------------------------------------------
1576 SvxCaseMapItem::SvxCaseMapItem( const SvxCaseMap eMap
, const sal_uInt16 nId
) :
1577 SfxEnumItem( nId
, eMap
)
1582 sal_uInt16
SvxCaseMapItem::GetValueCount() const
1584 return sal_uInt16(SvxCaseMap::End
); // SvxCaseMap::SmallCaps + 1
1588 SfxPoolItem
* SvxCaseMapItem::Clone( SfxItemPool
* ) const
1590 return new SvxCaseMapItem( *this );
1594 bool SvxCaseMapItem::GetPresentation
1596 SfxItemPresentation
/*ePres*/,
1597 MapUnit
/*eCoreUnit*/,
1598 MapUnit
/*ePresUnit*/,
1599 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1602 rText
= GetValueTextByPos( static_cast<sal_uInt16
>(GetValue()) );
1606 OUString
SvxCaseMapItem::GetValueTextByPos( sal_uInt16 nPos
)
1608 static const char* RID_SVXITEMS_CASEMAP
[] =
1610 RID_SVXITEMS_CASEMAP_NONE
,
1611 RID_SVXITEMS_CASEMAP_UPPERCASE
,
1612 RID_SVXITEMS_CASEMAP_LOWERCASE
,
1613 RID_SVXITEMS_CASEMAP_TITLE
,
1614 RID_SVXITEMS_CASEMAP_SMALLCAPS
1617 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_CASEMAP
) == size_t(SvxCaseMap::End
), "must match");
1618 assert(nPos
< sal_uInt16(SvxCaseMap::End
) && "enum overflow!");
1619 return EditResId(RID_SVXITEMS_CASEMAP
[nPos
]);
1622 bool SvxCaseMapItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
1624 sal_Int16 nRet
= style::CaseMap::NONE
;
1625 switch( GetValue() )
1627 case SvxCaseMap::Uppercase
: nRet
= style::CaseMap::UPPERCASE
; break;
1628 case SvxCaseMap::Lowercase
: nRet
= style::CaseMap::LOWERCASE
; break;
1629 case SvxCaseMap::Capitalize
: nRet
= style::CaseMap::TITLE
; break;
1630 case SvxCaseMap::SmallCaps
: nRet
= style::CaseMap::SMALLCAPS
; break;
1637 bool SvxCaseMapItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
1639 sal_uInt16 nVal
= sal_uInt16();
1640 if(!(rVal
>>= nVal
))
1646 case style::CaseMap::NONE
: eVal
= SvxCaseMap::NotMapped
; break;
1647 case style::CaseMap::UPPERCASE
: eVal
= SvxCaseMap::Uppercase
; break;
1648 case style::CaseMap::LOWERCASE
: eVal
= SvxCaseMap::Lowercase
; break;
1649 case style::CaseMap::TITLE
: eVal
= SvxCaseMap::Capitalize
; break;
1650 case style::CaseMap::SMALLCAPS
: eVal
= SvxCaseMap::SmallCaps
; break;
1651 default: return false;
1657 // class SvxEscapementItem -----------------------------------------------
1659 SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId
) :
1660 SfxEnumItemInterface( nId
),
1668 SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape
,
1669 const sal_uInt16 nId
) :
1670 SfxEnumItemInterface( nId
),
1673 SetEscapement( eEscape
);
1679 SvxEscapementItem::SvxEscapementItem( const short _nEsc
,
1680 const sal_uInt8 _nProp
,
1681 const sal_uInt16 nId
) :
1682 SfxEnumItemInterface( nId
),
1689 bool SvxEscapementItem::operator==( const SfxPoolItem
& rAttr
) const
1691 assert(SfxPoolItem::operator==(rAttr
));
1693 return( nEsc
== static_cast<const SvxEscapementItem
&>(rAttr
).nEsc
&&
1694 nProp
== static_cast<const SvxEscapementItem
&>(rAttr
).nProp
);
1698 SfxPoolItem
* SvxEscapementItem::Clone( SfxItemPool
* ) const
1700 return new SvxEscapementItem( *this );
1704 sal_uInt16
SvxEscapementItem::GetValueCount() const
1706 return sal_uInt16(SvxEscapement::End
); // SvxEscapement::Subscript + 1
1710 bool SvxEscapementItem::GetPresentation
1712 SfxItemPresentation
/*ePres*/,
1713 MapUnit
/*eCoreUnit*/,
1714 MapUnit
/*ePresUnit*/,
1715 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1718 rText
= GetValueTextByPos( GetEnumValue() );
1722 if( DFLT_ESC_AUTO_SUPER
== nEsc
|| DFLT_ESC_AUTO_SUB
== nEsc
)
1723 rText
+= EditResId(RID_SVXITEMS_ESCAPEMENT_AUTO
);
1725 rText
= rText
+ OUString::number( nEsc
) + "%";
1730 OUString
SvxEscapementItem::GetValueTextByPos( sal_uInt16 nPos
)
1732 static const char* RID_SVXITEMS_ESCAPEMENT
[] =
1734 RID_SVXITEMS_ESCAPEMENT_OFF
,
1735 RID_SVXITEMS_ESCAPEMENT_SUPER
,
1736 RID_SVXITEMS_ESCAPEMENT_SUB
1739 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_ESCAPEMENT
) == size_t(SvxEscapement::End
), "must match");
1740 assert(nPos
< sal_uInt16(SvxEscapement::End
) && "enum overflow!");
1741 return EditResId(RID_SVXITEMS_ESCAPEMENT
[nPos
]);
1744 sal_uInt16
SvxEscapementItem::GetEnumValue() const
1747 return sal_uInt16(SvxEscapement::Subscript
);
1748 else if ( nEsc
> 0 )
1749 return sal_uInt16(SvxEscapement::Superscript
);
1750 return sal_uInt16(SvxEscapement::Off
);
1754 void SvxEscapementItem::SetEnumValue( sal_uInt16 nVal
)
1756 SetEscapement( static_cast<SvxEscapement
>(nVal
) );
1759 bool SvxEscapementItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1761 nMemberId
&= ~CONVERT_TWIPS
;
1765 rVal
<<= static_cast<sal_Int16
>(nEsc
);
1767 case MID_ESC_HEIGHT
:
1768 rVal
<<= static_cast<sal_Int8
>(nProp
);
1771 rVal
<<= (DFLT_ESC_AUTO_SUB
== nEsc
|| DFLT_ESC_AUTO_SUPER
== nEsc
);
1777 bool SvxEscapementItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1779 nMemberId
&= ~CONVERT_TWIPS
;
1784 sal_Int16 nVal
= sal_Int16();
1785 // tdf#120412 up to 14400% (eg. 1584 pt with 11 pt letters)
1786 if( (rVal
>>= nVal
) && (std::abs(nVal
) <= 14400))
1792 case MID_ESC_HEIGHT
:
1794 sal_Int8 nVal
= sal_Int8();
1795 if( (rVal
>>= nVal
) && (nVal
<= 100))
1803 bool bVal
= Any2Bool(rVal
);
1807 nEsc
= DFLT_ESC_AUTO_SUB
;
1809 nEsc
= DFLT_ESC_AUTO_SUPER
;
1812 if(DFLT_ESC_AUTO_SUPER
== nEsc
)
1814 else if(DFLT_ESC_AUTO_SUB
== nEsc
)
1822 // class SvxLanguageItem -------------------------------------------------
1824 SvxLanguageItem::SvxLanguageItem( const LanguageType eLang
, const sal_uInt16 nId
)
1825 : SvxLanguageItem_Base( nId
, eLang
)
1830 sal_uInt16
SvxLanguageItem::GetValueCount() const
1832 // #i50205# got rid of class International
1833 SAL_WARN( "editeng.items", "SvxLanguageItem::GetValueCount: supposed to return a count of what?");
1834 // Could be SvtLanguageTable::GetEntryCount() (all locales with resource string)?
1835 // Could be LocaleDataWrapper::getInstalledLanguageTypes() (all locales with locale data)?
1840 SfxPoolItem
* SvxLanguageItem::Clone( SfxItemPool
* ) const
1842 return new SvxLanguageItem( *this );
1846 bool SvxLanguageItem::GetPresentation
1848 SfxItemPresentation
/*ePres*/,
1849 MapUnit
/*eCoreUnit*/,
1850 MapUnit
/*ePresUnit*/,
1851 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1854 rText
= SvtLanguageTable::GetLanguageString( GetValue() );
1858 bool SvxLanguageItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1860 nMemberId
&= ~CONVERT_TWIPS
;
1863 case MID_LANG_INT
: // for basic conversions!
1864 rVal
<<= static_cast<sal_Int16
>(static_cast<sal_uInt16
>(GetValue()));
1866 case MID_LANG_LOCALE
:
1867 lang::Locale
aRet( LanguageTag::convertToLocale( GetValue(), false));
1874 bool SvxLanguageItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1876 nMemberId
&= ~CONVERT_TWIPS
;
1879 case MID_LANG_INT
: // for basic conversions!
1881 sal_Int32 nValue
= 0;
1882 if(!(rVal
>>= nValue
))
1885 SetValue(LanguageType(nValue
));
1888 case MID_LANG_LOCALE
:
1890 lang::Locale aLocale
;
1891 if(!(rVal
>>= aLocale
))
1894 SetValue( LanguageTag::convertToLanguageType( aLocale
, false));
1901 // class SvxNoHyphenItem -------------------------------------------------
1903 SvxNoHyphenItem::SvxNoHyphenItem( const sal_uInt16 nId
) :
1904 SfxBoolItem( nId
, true )
1909 SfxPoolItem
* SvxNoHyphenItem::Clone( SfxItemPool
* ) const
1911 return new SvxNoHyphenItem( *this );
1915 bool SvxNoHyphenItem::GetPresentation
1917 SfxItemPresentation
/*ePres*/,
1918 MapUnit
/*eCoreUnit*/,
1919 MapUnit
/*ePresUnit*/,
1920 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1928 * Dummy item for ToolBox controls:
1933 // class SvxBlinkItem -------------------------------------------------
1936 SvxBlinkItem::SvxBlinkItem( const bool bBlink
, const sal_uInt16 nId
) :
1937 SfxBoolItem( nId
, bBlink
)
1942 SfxPoolItem
* SvxBlinkItem::Clone( SfxItemPool
* ) const
1944 return new SvxBlinkItem( *this );
1948 bool SvxBlinkItem::GetPresentation
1950 SfxItemPresentation
/*ePres*/,
1951 MapUnit
/*eCoreUnit*/,
1952 MapUnit
/*ePresUnit*/,
1953 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1956 const char* pId
= RID_SVXITEMS_BLINK_FALSE
;
1959 pId
= RID_SVXITEMS_BLINK_TRUE
;
1960 rText
= EditResId(pId
);
1964 // class SvxEmphaisMarkItem ---------------------------------------------------
1966 SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue
,
1967 const sal_uInt16 nId
)
1968 : SfxUInt16Item( nId
, static_cast<sal_uInt16
>(nValue
) )
1973 SfxPoolItem
* SvxEmphasisMarkItem::Clone( SfxItemPool
* ) const
1975 return new SvxEmphasisMarkItem( *this );
1979 bool SvxEmphasisMarkItem::GetPresentation
1981 SfxItemPresentation
/*ePres*/,
1982 MapUnit
/*eCoreUnit*/,
1983 MapUnit
/*ePresUnit*/,
1985 const IntlWrapper
& /*rIntl*/
1988 static const char* RID_SVXITEMS_EMPHASIS
[] =
1990 RID_SVXITEMS_EMPHASIS_NONE_STYLE
,
1991 RID_SVXITEMS_EMPHASIS_DOT_STYLE
,
1992 RID_SVXITEMS_EMPHASIS_CIRCLE_STYLE
,
1993 RID_SVXITEMS_EMPHASIS_DISC_STYLE
,
1994 RID_SVXITEMS_EMPHASIS_ACCENT_STYLE
1997 FontEmphasisMark nVal
= GetEmphasisMark();
1998 rText
= EditResId(RID_SVXITEMS_EMPHASIS
[
1999 static_cast<sal_uInt16
>(static_cast<FontEmphasisMark
>( nVal
& FontEmphasisMark::Style
))]);
2000 const char* pId
= ( FontEmphasisMark::PosAbove
& nVal
)
2001 ? RID_SVXITEMS_EMPHASIS_ABOVE_POS
2002 : ( FontEmphasisMark::PosBelow
& nVal
)
2003 ? RID_SVXITEMS_EMPHASIS_BELOW_POS
2006 rText
+= EditResId( pId
);
2010 bool SvxEmphasisMarkItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2012 nMemberId
&= ~CONVERT_TWIPS
;
2017 FontEmphasisMark nValue
= GetEmphasisMark();
2019 switch(nValue
& FontEmphasisMark::Style
)
2021 case FontEmphasisMark::NONE
: nRet
= FontEmphasis::NONE
; break;
2022 case FontEmphasisMark::Dot
: nRet
= FontEmphasis::DOT_ABOVE
; break;
2023 case FontEmphasisMark::Circle
: nRet
= FontEmphasis::CIRCLE_ABOVE
; break;
2024 case FontEmphasisMark::Disc
: nRet
= FontEmphasis::DISK_ABOVE
; break;
2025 case FontEmphasisMark::Accent
: nRet
= FontEmphasis::ACCENT_ABOVE
; break;
2028 if(nRet
&& nValue
& FontEmphasisMark::PosBelow
)
2037 bool SvxEmphasisMarkItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2039 nMemberId
&= ~CONVERT_TWIPS
;
2044 sal_Int32 nValue
= -1;
2046 FontEmphasisMark nMark
;
2049 case FontEmphasis::NONE
: nMark
= FontEmphasisMark::NONE
; break;
2050 case FontEmphasis::DOT_ABOVE
: nMark
= FontEmphasisMark::Dot
|FontEmphasisMark::PosAbove
; break;
2051 case FontEmphasis::CIRCLE_ABOVE
: nMark
= FontEmphasisMark::Circle
|FontEmphasisMark::PosAbove
; break;
2052 case FontEmphasis::DISK_ABOVE
: nMark
= FontEmphasisMark::Disc
|FontEmphasisMark::PosAbove
; break;
2053 case FontEmphasis::ACCENT_ABOVE
: nMark
= FontEmphasisMark::Accent
|FontEmphasisMark::PosAbove
; break;
2054 case FontEmphasis::DOT_BELOW
: nMark
= FontEmphasisMark::Dot
|FontEmphasisMark::PosBelow
; break;
2055 case FontEmphasis::CIRCLE_BELOW
: nMark
= FontEmphasisMark::Circle
|FontEmphasisMark::PosBelow
; break;
2056 case FontEmphasis::DISK_BELOW
: nMark
= FontEmphasisMark::Disc
|FontEmphasisMark::PosBelow
; break;
2057 case FontEmphasis::ACCENT_BELOW
: nMark
= FontEmphasisMark::Accent
|FontEmphasisMark::PosBelow
; break;
2058 default: return false;
2060 SetValue( static_cast<sal_Int16
>(nMark
) );
2067 /*************************************************************************
2068 |* class SvxTwoLinesItem
2069 *************************************************************************/
2071 SvxTwoLinesItem::SvxTwoLinesItem( bool bFlag
, sal_Unicode nStartBracket
,
2072 sal_Unicode nEndBracket
, sal_uInt16 nW
)
2073 : SfxPoolItem( nW
),
2074 cStartBracket( nStartBracket
), cEndBracket( nEndBracket
), bOn( bFlag
)
2078 SvxTwoLinesItem::~SvxTwoLinesItem()
2082 bool SvxTwoLinesItem::operator==( const SfxPoolItem
& rAttr
) const
2084 assert(SfxPoolItem::operator==(rAttr
));
2085 return bOn
== static_cast<const SvxTwoLinesItem
&>(rAttr
).bOn
&&
2086 cStartBracket
== static_cast<const SvxTwoLinesItem
&>(rAttr
).cStartBracket
&&
2087 cEndBracket
== static_cast<const SvxTwoLinesItem
&>(rAttr
).cEndBracket
;
2090 SfxPoolItem
* SvxTwoLinesItem::Clone( SfxItemPool
* ) const
2092 return new SvxTwoLinesItem( *this );
2095 bool SvxTwoLinesItem::QueryValue( css::uno::Any
& rVal
,
2096 sal_uInt8 nMemberId
) const
2098 nMemberId
&= ~CONVERT_TWIPS
;
2105 case MID_START_BRACKET
:
2109 s
= OUString( cStartBracket
);
2113 case MID_END_BRACKET
:
2117 s
= OUString( cEndBracket
);
2128 bool SvxTwoLinesItem::PutValue( const css::uno::Any
& rVal
,
2129 sal_uInt8 nMemberId
)
2131 nMemberId
&= ~CONVERT_TWIPS
;
2137 bOn
= Any2Bool( rVal
);
2140 case MID_START_BRACKET
:
2143 cStartBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
2147 case MID_END_BRACKET
:
2150 cEndBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
2158 bool SvxTwoLinesItem::GetPresentation( SfxItemPresentation
/*ePres*/,
2159 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2160 OUString
&rText
, const IntlWrapper
& /*rIntl*/ ) const
2163 rText
= EditResId( RID_SVXITEMS_TWOLINES_OFF
);
2166 rText
= EditResId( RID_SVXITEMS_TWOLINES
);
2167 if( GetStartBracket() )
2168 rText
= OUStringLiteral1(GetStartBracket()) + rText
;
2169 if( GetEndBracket() )
2170 rText
+= OUStringLiteral1(GetEndBracket());
2176 /*************************************************************************
2177 |* class SvxTextRotateItem
2178 *************************************************************************/
2180 SvxTextRotateItem::SvxTextRotateItem(sal_uInt16 nValue
, const sal_uInt16 nW
)
2181 : SfxUInt16Item(nW
, nValue
)
2185 SfxPoolItem
* SvxTextRotateItem::Clone(SfxItemPool
*) const
2187 return new SvxTextRotateItem(*this);
2190 bool SvxTextRotateItem::GetPresentation(
2191 SfxItemPresentation
/*ePres*/,
2192 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2193 OUString
&rText
, const IntlWrapper
&) const
2196 rText
= EditResId(RID_SVXITEMS_TEXTROTATE_OFF
);
2199 rText
= EditResId(RID_SVXITEMS_TEXTROTATE
);
2200 rText
= rText
.replaceFirst("$(ARG1)",
2201 OUString::number(GetValue() / 10));
2206 bool SvxTextRotateItem::QueryValue(css::uno::Any
& rVal
,
2207 sal_uInt8 nMemberId
) const
2209 nMemberId
&= ~CONVERT_TWIPS
;
2214 rVal
<<= static_cast<sal_Int16
>(GetValue());
2223 bool SvxTextRotateItem::PutValue(const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
2225 nMemberId
&= ~CONVERT_TWIPS
;
2232 if ((rVal
>>= nVal
) && (0 == nVal
|| 900 == nVal
|| 2700 == nVal
))
2233 SetValue(static_cast<sal_uInt16
>(nVal
));
2244 bool SvxTextRotateItem::operator==(const SfxPoolItem
& rItem
) const
2246 assert(SfxPoolItem::operator==(rItem
));
2247 return SfxUInt16Item::operator==(rItem
);
2250 void SvxTextRotateItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2252 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxTextRotateItem"));
2253 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2254 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
2255 xmlTextWriterEndElement(pWriter
);
2259 /*************************************************************************
2260 |* class SvxCharRotateItem
2261 *************************************************************************/
2263 SvxCharRotateItem::SvxCharRotateItem( sal_uInt16 nValue
,
2265 const sal_uInt16 nW
)
2266 : SvxTextRotateItem(nValue
, nW
), bFitToLine( bFitIntoLine
)
2270 SfxPoolItem
* SvxCharRotateItem::Clone( SfxItemPool
* ) const
2272 return new SvxCharRotateItem( *this );
2275 bool SvxCharRotateItem::GetPresentation(
2276 SfxItemPresentation
/*ePres*/,
2277 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2278 OUString
&rText
, const IntlWrapper
&) const
2281 rText
= EditResId( RID_SVXITEMS_CHARROTATE_OFF
);
2284 rText
= EditResId( RID_SVXITEMS_CHARROTATE
);
2285 rText
= rText
.replaceFirst( "$(ARG1)",
2286 OUString::number( GetValue() / 10 ));
2288 rText
+= EditResId( RID_SVXITEMS_CHARROTATE_FITLINE
);
2293 bool SvxCharRotateItem::QueryValue( css::uno::Any
& rVal
,
2294 sal_uInt8 nMemberId
) const
2297 switch(nMemberId
& ~CONVERT_TWIPS
)
2300 SvxTextRotateItem::QueryValue(rVal
, nMemberId
);
2303 rVal
<<= IsFitToLine();
2312 bool SvxCharRotateItem::PutValue( const css::uno::Any
& rVal
,
2313 sal_uInt8 nMemberId
)
2316 switch(nMemberId
& ~CONVERT_TWIPS
)
2320 bRet
= SvxTextRotateItem::PutValue(rVal
, nMemberId
);
2325 SetFitToLine( Any2Bool( rVal
) );
2333 bool SvxCharRotateItem::operator==( const SfxPoolItem
& rItem
) const
2335 assert(SfxPoolItem::operator==(rItem
));
2336 return SvxTextRotateItem::operator==( rItem
) &&
2337 IsFitToLine() == static_cast<const SvxCharRotateItem
&>(rItem
).IsFitToLine();
2340 void SvxCharRotateItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2342 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxCharRotateItem"));
2343 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2344 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
2345 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("fitToLine"), BAD_CAST(OString::boolean(IsFitToLine()).getStr()));
2346 xmlTextWriterEndElement(pWriter
);
2349 /*************************************************************************
2350 |* class SvxCharScaleItem
2351 *************************************************************************/
2353 SvxCharScaleWidthItem::SvxCharScaleWidthItem( sal_uInt16 nValue
,
2354 const sal_uInt16 nW
)
2355 : SfxUInt16Item( nW
, nValue
)
2359 SfxPoolItem
* SvxCharScaleWidthItem::Clone( SfxItemPool
* ) const
2361 return new SvxCharScaleWidthItem( *this );
2365 bool SvxCharScaleWidthItem::GetPresentation(
2366 SfxItemPresentation
/*ePres*/,
2367 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2368 OUString
&rText
, const IntlWrapper
&) const
2371 rText
= EditResId( RID_SVXITEMS_CHARSCALE_OFF
);
2374 rText
= EditResId( RID_SVXITEMS_CHARSCALE
);
2375 rText
= rText
.replaceFirst( "$(ARG1)",
2376 OUString::number( GetValue() ));
2381 bool SvxCharScaleWidthItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
2383 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
2384 // where we still want this to be a sal_Int16
2385 sal_Int16 nValue
= sal_Int16();
2386 if (rVal
>>= nValue
)
2388 SetValue( static_cast<sal_uInt16
>(nValue
) );
2392 SAL_WARN("editeng.items", "SvxCharScaleWidthItem::PutValue - Wrong type!" );
2396 bool SvxCharScaleWidthItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
2398 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
2399 // where we still want this to be a sal_Int16
2400 rVal
<<= static_cast<sal_Int16
>(GetValue());
2404 /*************************************************************************
2405 |* class SvxCharReliefItem
2406 *************************************************************************/
2408 SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue
,
2409 const sal_uInt16 nId
)
2410 : SfxEnumItem( nId
, eValue
)
2414 SfxPoolItem
* SvxCharReliefItem::Clone( SfxItemPool
* ) const
2416 return new SvxCharReliefItem( *this );
2419 static const char* RID_SVXITEMS_RELIEF
[] =
2421 RID_SVXITEMS_RELIEF_NONE
,
2422 RID_SVXITEMS_RELIEF_EMBOSSED
,
2423 RID_SVXITEMS_RELIEF_ENGRAVED
2426 OUString
SvxCharReliefItem::GetValueTextByPos(sal_uInt16 nPos
)
2428 assert(nPos
< SAL_N_ELEMENTS(RID_SVXITEMS_RELIEF
) && "enum overflow");
2429 return EditResId(RID_SVXITEMS_RELIEF
[nPos
]);
2432 sal_uInt16
SvxCharReliefItem::GetValueCount() const
2434 return SAL_N_ELEMENTS(RID_SVXITEMS_RELIEF
) - 1;
2437 bool SvxCharReliefItem::GetPresentation
2439 SfxItemPresentation
/*ePres*/,
2440 MapUnit
/*eCoreUnit*/,
2441 MapUnit
/*ePresUnit*/,
2442 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2445 rText
= GetValueTextByPos( static_cast<sal_uInt16
>(GetValue()) );
2449 bool SvxCharReliefItem::PutValue( const css::uno::Any
& rVal
,
2450 sal_uInt8 nMemberId
)
2452 nMemberId
&= ~CONVERT_TWIPS
;
2458 sal_Int16 nVal
= -1;
2460 if(nVal
>= 0 && nVal
<= sal_Int16(FontRelief::Engraved
))
2461 SetValue( static_cast<FontRelief
>(nVal
) );
2473 bool SvxCharReliefItem::QueryValue( css::uno::Any
& rVal
,
2474 sal_uInt8 nMemberId
) const
2476 nMemberId
&= ~CONVERT_TWIPS
;
2481 rVal
<<= static_cast<sal_Int16
>(GetValue());
2490 /*************************************************************************
2491 |* class SvxScriptSetItem
2492 *************************************************************************/
2494 SvxScriptSetItem::SvxScriptSetItem( sal_uInt16 nSlotId
, SfxItemPool
& rPool
)
2495 : SfxSetItem( nSlotId
, std::make_unique
<SfxItemSet
>( rPool
,
2496 svl::Items
<SID_ATTR_CHAR_FONT
, SID_ATTR_CHAR_FONT
>{} ))
2498 sal_uInt16 nLatin
, nAsian
, nComplex
;
2499 GetWhichIds( nLatin
, nAsian
, nComplex
);
2500 GetItemSet().MergeRange( nLatin
, nLatin
);
2501 GetItemSet().MergeRange( nAsian
, nAsian
);
2502 GetItemSet().MergeRange( nComplex
, nComplex
);
2505 SfxPoolItem
* SvxScriptSetItem::Clone( SfxItemPool
* ) const
2507 SvxScriptSetItem
* p
= new SvxScriptSetItem( Which(), *GetItemSet().GetPool() );
2508 p
->GetItemSet().Put( GetItemSet(), false );
2512 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScriptSet(
2513 const SfxItemSet
& rSet
, sal_uInt16 nId
)
2515 const SfxPoolItem
* pI
;
2516 SfxItemState eSt
= rSet
.GetItemState( nId
, false, &pI
);
2517 if( SfxItemState::SET
!= eSt
)
2518 pI
= SfxItemState::DEFAULT
== eSt
? &rSet
.Get( nId
) : nullptr;
2522 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, SvtScriptType nScript
)
2524 sal_uInt16 nLatin
, nAsian
, nComplex
;
2525 GetWhichIds( nSlotId
, rSet
, nLatin
, nAsian
, nComplex
);
2527 const SfxPoolItem
*pRet
, *pAsn
, *pCmplx
;
2528 if (nScript
== SvtScriptType::ASIAN
)
2530 pRet
= GetItemOfScriptSet( rSet
, nAsian
);
2531 } else if (nScript
== SvtScriptType::COMPLEX
)
2533 pRet
= GetItemOfScriptSet( rSet
, nComplex
);
2534 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::ASIAN
))
2536 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2537 nullptr == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2540 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::COMPLEX
))
2542 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2543 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2546 } else if (nScript
== (SvtScriptType::ASIAN
|SvtScriptType::COMPLEX
))
2548 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2549 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2552 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::ASIAN
|SvtScriptType::COMPLEX
))
2554 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2555 nullptr == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2556 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2557 *pRet
!= *pAsn
|| *pRet
!= *pCmplx
)
2560 //no one valid -> match to latin
2561 pRet
= GetItemOfScriptSet( rSet
, nLatin
);
2566 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( SvtScriptType nScript
) const
2568 return GetItemOfScript( Which(), GetItemSet(), nScript
);
2571 void SvxScriptSetItem::PutItemForScriptType( SvtScriptType nScriptType
,
2572 const SfxPoolItem
& rItem
)
2574 sal_uInt16 nLatin
, nAsian
, nComplex
;
2575 GetWhichIds( nLatin
, nAsian
, nComplex
);
2577 std::unique_ptr
<SfxPoolItem
> pCpy(rItem
.Clone());
2578 if( SvtScriptType::LATIN
& nScriptType
)
2580 pCpy
->SetWhich( nLatin
);
2581 GetItemSet().Put( *pCpy
);
2583 if( SvtScriptType::ASIAN
& nScriptType
)
2585 pCpy
->SetWhich( nAsian
);
2586 GetItemSet().Put( *pCpy
);
2588 if( SvtScriptType::COMPLEX
& nScriptType
)
2590 pCpy
->SetWhich( nComplex
);
2591 GetItemSet().Put( *pCpy
);
2595 void SvxScriptSetItem::GetWhichIds( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, sal_uInt16
& rLatin
, sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
2597 const SfxItemPool
& rPool
= *rSet
.GetPool();
2598 GetSlotIds( nSlotId
, rLatin
, rAsian
, rComplex
);
2599 rLatin
= rPool
.GetWhich( rLatin
);
2600 rAsian
= rPool
.GetWhich( rAsian
);
2601 rComplex
= rPool
.GetWhich( rComplex
);
2604 void SvxScriptSetItem::GetWhichIds( sal_uInt16
& rLatin
, sal_uInt16
& rAsian
,
2605 sal_uInt16
& rComplex
) const
2607 GetWhichIds( Which(), GetItemSet(), rLatin
, rAsian
, rComplex
);
2610 void SvxScriptSetItem::GetSlotIds( sal_uInt16 nSlotId
, sal_uInt16
& rLatin
,
2611 sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
2616 SAL_WARN( "editeng.items", "wrong SlotId for class SvxScriptSetItem" );
2617 [[fallthrough
]]; // default to font - Id Range !!
2619 case SID_ATTR_CHAR_FONT
:
2620 rLatin
= SID_ATTR_CHAR_FONT
;
2621 rAsian
= SID_ATTR_CHAR_CJK_FONT
;
2622 rComplex
= SID_ATTR_CHAR_CTL_FONT
;
2624 case SID_ATTR_CHAR_FONTHEIGHT
:
2625 rLatin
= SID_ATTR_CHAR_FONTHEIGHT
;
2626 rAsian
= SID_ATTR_CHAR_CJK_FONTHEIGHT
;
2627 rComplex
= SID_ATTR_CHAR_CTL_FONTHEIGHT
;
2629 case SID_ATTR_CHAR_WEIGHT
:
2630 rLatin
= SID_ATTR_CHAR_WEIGHT
;
2631 rAsian
= SID_ATTR_CHAR_CJK_WEIGHT
;
2632 rComplex
= SID_ATTR_CHAR_CTL_WEIGHT
;
2634 case SID_ATTR_CHAR_POSTURE
:
2635 rLatin
= SID_ATTR_CHAR_POSTURE
;
2636 rAsian
= SID_ATTR_CHAR_CJK_POSTURE
;
2637 rComplex
= SID_ATTR_CHAR_CTL_POSTURE
;
2639 case SID_ATTR_CHAR_LANGUAGE
:
2640 rLatin
= SID_ATTR_CHAR_LANGUAGE
;
2641 rAsian
= SID_ATTR_CHAR_CJK_LANGUAGE
;
2642 rComplex
= SID_ATTR_CHAR_CTL_LANGUAGE
;
2644 case SID_ATTR_CHAR_SHADOWED
:
2645 rLatin
= SID_ATTR_CHAR_SHADOWED
;
2646 rAsian
= SID_ATTR_CHAR_SHADOWED
;
2647 rComplex
= SID_ATTR_CHAR_SHADOWED
;
2649 case SID_ATTR_CHAR_STRIKEOUT
:
2650 rLatin
= SID_ATTR_CHAR_STRIKEOUT
;
2651 rAsian
= SID_ATTR_CHAR_STRIKEOUT
;
2652 rComplex
= SID_ATTR_CHAR_STRIKEOUT
;
2657 void GetDefaultFonts( SvxFontItem
& rLatin
, SvxFontItem
& rAsian
, SvxFontItem
& rComplex
)
2659 const sal_uInt16 nItemCnt
= 3;
2663 DefaultFontType nFontType
;
2664 LanguageType nLanguage
;
2666 const aOutTypeArr
[ nItemCnt
] =
2668 { DefaultFontType::LATIN_TEXT
, LANGUAGE_ENGLISH_US
},
2669 { DefaultFontType::CJK_TEXT
, LANGUAGE_ENGLISH_US
},
2670 { DefaultFontType::CTL_TEXT
, LANGUAGE_ARABIC_SAUDI_ARABIA
}
2673 SvxFontItem
* aItemArr
[ nItemCnt
] = { &rLatin
, &rAsian
, &rComplex
};
2675 for ( sal_uInt16 n
= 0; n
< nItemCnt
; ++n
)
2677 vcl::Font
aFont( OutputDevice::GetDefaultFont( aOutTypeArr
[ n
].nFontType
,
2678 aOutTypeArr
[ n
].nLanguage
,
2679 GetDefaultFontFlags::OnlyOne
) );
2680 SvxFontItem
* pItem
= aItemArr
[ n
];
2681 pItem
->SetFamily( aFont
.GetFamilyType() );
2682 pItem
->SetFamilyName( aFont
.GetFamilyName() );
2683 pItem
->SetStyleName( OUString() );
2684 pItem
->SetPitch( aFont
.GetPitch());
2685 pItem
->SetCharSet(aFont
.GetCharSet());
2690 bool SvxRsidItem::QueryValue( uno::Any
& rVal
, sal_uInt8
) const
2692 rVal
<<= GetValue();
2696 bool SvxRsidItem::PutValue( const uno::Any
& rVal
, sal_uInt8
)
2698 sal_uInt32 nRsid
= 0;
2699 if( !( rVal
>>= nRsid
) )
2706 SfxPoolItem
* SvxRsidItem::Clone( SfxItemPool
* ) const
2708 return new SvxRsidItem( *this );
2711 bool SvxRsidItem::GetPresentation
2713 SfxItemPresentation
/*ePres*/,
2714 MapUnit
/*eCoreUnit*/,
2715 MapUnit
/*ePresUnit*/,
2716 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2723 void SvxRsidItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2725 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxRsidItem"));
2726 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
2727 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%" SAL_PRIuUINT32
, GetValue());
2728 xmlTextWriterEndElement(pWriter
);
2731 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */