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
+= 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 return SfxEnumItem::operator==( rItem
) &&
1044 GetColor() == static_cast<const SvxTextLineItem
&>(rItem
).GetColor();
1047 // class SvxUnderlineItem ------------------------------------------------
1050 SvxUnderlineItem::SvxUnderlineItem( const FontLineStyle eSt
, const sal_uInt16 nId
)
1051 : SvxTextLineItem( eSt
, nId
)
1056 SfxPoolItem
* SvxUnderlineItem::Clone( SfxItemPool
* ) const
1058 return new SvxUnderlineItem( *this );
1062 OUString
SvxUnderlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1064 static const char* RID_SVXITEMS_UL
[] =
1066 RID_SVXITEMS_UL_NONE
,
1067 RID_SVXITEMS_UL_SINGLE
,
1068 RID_SVXITEMS_UL_DOUBLE
,
1069 RID_SVXITEMS_UL_DOTTED
,
1070 RID_SVXITEMS_UL_DONTKNOW
,
1071 RID_SVXITEMS_UL_DASH
,
1072 RID_SVXITEMS_UL_LONGDASH
,
1073 RID_SVXITEMS_UL_DASHDOT
,
1074 RID_SVXITEMS_UL_DASHDOTDOT
,
1075 RID_SVXITEMS_UL_SMALLWAVE
,
1076 RID_SVXITEMS_UL_WAVE
,
1077 RID_SVXITEMS_UL_DOUBLEWAVE
,
1078 RID_SVXITEMS_UL_BOLD
,
1079 RID_SVXITEMS_UL_BOLDDOTTED
,
1080 RID_SVXITEMS_UL_BOLDDASH
,
1081 RID_SVXITEMS_UL_BOLDLONGDASH
,
1082 RID_SVXITEMS_UL_BOLDDASHDOT
,
1083 RID_SVXITEMS_UL_BOLDDASHDOTDOT
,
1084 RID_SVXITEMS_UL_BOLDWAVE
1086 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_UL
) - 1 == LINESTYLE_BOLDWAVE
, "must match");
1087 assert(nPos
<= sal_uInt16(LINESTYLE_BOLDWAVE
) && "enum overflow!");
1088 return EditResId(RID_SVXITEMS_UL
[nPos
]);
1091 // class SvxOverlineItem ------------------------------------------------
1093 SvxOverlineItem::SvxOverlineItem( const FontLineStyle eSt
, const sal_uInt16 nId
)
1094 : SvxTextLineItem( eSt
, nId
)
1099 SfxPoolItem
* SvxOverlineItem::Clone( SfxItemPool
* ) const
1101 return new SvxOverlineItem( *this );
1105 OUString
SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1107 static const char* RID_SVXITEMS_OL
[] =
1109 RID_SVXITEMS_OL_NONE
,
1110 RID_SVXITEMS_OL_SINGLE
,
1111 RID_SVXITEMS_OL_DOUBLE
,
1112 RID_SVXITEMS_OL_DOTTED
,
1113 RID_SVXITEMS_OL_DONTKNOW
,
1114 RID_SVXITEMS_OL_DASH
,
1115 RID_SVXITEMS_OL_LONGDASH
,
1116 RID_SVXITEMS_OL_DASHDOT
,
1117 RID_SVXITEMS_OL_DASHDOTDOT
,
1118 RID_SVXITEMS_OL_SMALLWAVE
,
1119 RID_SVXITEMS_OL_WAVE
,
1120 RID_SVXITEMS_OL_DOUBLEWAVE
,
1121 RID_SVXITEMS_OL_BOLD
,
1122 RID_SVXITEMS_OL_BOLDDOTTED
,
1123 RID_SVXITEMS_OL_BOLDDASH
,
1124 RID_SVXITEMS_OL_BOLDLONGDASH
,
1125 RID_SVXITEMS_OL_BOLDDASHDOT
,
1126 RID_SVXITEMS_OL_BOLDDASHDOTDOT
,
1127 RID_SVXITEMS_OL_BOLDWAVE
1129 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_OL
) - 1 == LINESTYLE_BOLDWAVE
, "must match");
1130 assert(nPos
<= sal_uInt16(LINESTYLE_BOLDWAVE
) && "enum overflow!");
1131 return EditResId(RID_SVXITEMS_OL
[nPos
]);
1134 // class SvxCrossedOutItem -----------------------------------------------
1136 SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt
, const sal_uInt16 nId
)
1137 : SfxEnumItem( nId
, eSt
)
1142 bool SvxCrossedOutItem::HasBoolValue() const
1148 bool SvxCrossedOutItem::GetBoolValue() const
1150 return GetValue() != STRIKEOUT_NONE
;
1154 void SvxCrossedOutItem::SetBoolValue( bool bVal
)
1156 SetValue( bVal
? STRIKEOUT_SINGLE
: STRIKEOUT_NONE
);
1160 sal_uInt16
SvxCrossedOutItem::GetValueCount() const
1162 return STRIKEOUT_DOUBLE
+ 1; // STRIKEOUT_NONE belongs also here
1166 SfxPoolItem
* SvxCrossedOutItem::Clone( SfxItemPool
* ) const
1168 return new SvxCrossedOutItem( *this );
1172 bool SvxCrossedOutItem::GetPresentation
1174 SfxItemPresentation
/*ePres*/,
1175 MapUnit
/*eCoreUnit*/,
1176 MapUnit
/*ePresUnit*/,
1177 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1180 rText
= GetValueTextByPos( GetValue() );
1184 OUString
SvxCrossedOutItem::GetValueTextByPos( sal_uInt16 nPos
)
1186 static const char* RID_SVXITEMS_STRIKEOUT
[] =
1188 RID_SVXITEMS_STRIKEOUT_NONE
,
1189 RID_SVXITEMS_STRIKEOUT_SINGLE
,
1190 RID_SVXITEMS_STRIKEOUT_DOUBLE
,
1191 RID_SVXITEMS_STRIKEOUT_DONTKNOW
,
1192 RID_SVXITEMS_STRIKEOUT_BOLD
,
1193 RID_SVXITEMS_STRIKEOUT_SLASH
,
1194 RID_SVXITEMS_STRIKEOUT_X
1196 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_STRIKEOUT
) - 1 == STRIKEOUT_X
, "must match");
1197 assert(nPos
<= sal_uInt16(STRIKEOUT_X
) && "enum overflow!");
1198 return EditResId(RID_SVXITEMS_STRIKEOUT
[nPos
]);
1201 bool SvxCrossedOutItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1203 nMemberId
&= ~CONVERT_TWIPS
;
1206 case MID_CROSSED_OUT
:
1207 rVal
<<= GetBoolValue();
1210 rVal
<<= static_cast<sal_Int16
>(GetValue());
1216 bool SvxCrossedOutItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1218 nMemberId
&= ~CONVERT_TWIPS
;
1221 case MID_CROSSED_OUT
:
1222 SetBoolValue(Any2Bool(rVal
));
1226 sal_Int32 nValue
= 0;
1227 if(!(rVal
>>= nValue
))
1229 SetValue(static_cast<FontStrikeout
>(nValue
));
1235 // class SvxShadowedItem -------------------------------------------------
1237 SvxShadowedItem::SvxShadowedItem( const bool bShadowed
, const sal_uInt16 nId
) :
1238 SfxBoolItem( nId
, bShadowed
)
1243 SfxPoolItem
* SvxShadowedItem::Clone( SfxItemPool
* ) const
1245 return new SvxShadowedItem( *this );
1249 bool SvxShadowedItem::GetPresentation
1251 SfxItemPresentation
/*ePres*/,
1252 MapUnit
/*eCoreUnit*/,
1253 MapUnit
/*ePresUnit*/,
1254 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1257 const char* pId
= RID_SVXITEMS_SHADOWED_FALSE
;
1260 pId
= RID_SVXITEMS_SHADOWED_TRUE
;
1261 rText
= EditResId(pId
);
1265 // class SvxAutoKernItem -------------------------------------------------
1267 SvxAutoKernItem::SvxAutoKernItem( const bool bAutoKern
, const sal_uInt16 nId
) :
1268 SfxBoolItem( nId
, bAutoKern
)
1273 SfxPoolItem
* SvxAutoKernItem::Clone( SfxItemPool
* ) const
1275 return new SvxAutoKernItem( *this );
1279 bool SvxAutoKernItem::GetPresentation
1281 SfxItemPresentation
/*ePres*/,
1282 MapUnit
/*eCoreUnit*/,
1283 MapUnit
/*ePresUnit*/,
1284 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1287 const char* pId
= RID_SVXITEMS_AUTOKERN_FALSE
;
1290 pId
= RID_SVXITEMS_AUTOKERN_TRUE
;
1291 rText
= EditResId(pId
);
1295 // class SvxWordLineModeItem ---------------------------------------------
1297 SvxWordLineModeItem::SvxWordLineModeItem( const bool bWordLineMode
,
1298 const sal_uInt16 nId
) :
1299 SfxBoolItem( nId
, bWordLineMode
)
1304 SfxPoolItem
* SvxWordLineModeItem::Clone( SfxItemPool
* ) const
1306 return new SvxWordLineModeItem( *this );
1310 bool SvxWordLineModeItem::GetPresentation
1312 SfxItemPresentation
/*ePres*/,
1313 MapUnit
/*eCoreUnit*/,
1314 MapUnit
/*ePresUnit*/,
1315 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1318 const char* pId
= RID_SVXITEMS_WORDLINE_FALSE
;
1321 pId
= RID_SVXITEMS_WORDLINE_TRUE
;
1322 rText
= EditResId(pId
);
1326 // class SvxContourItem --------------------------------------------------
1328 SvxContourItem::SvxContourItem( const bool bContoured
, const sal_uInt16 nId
) :
1329 SfxBoolItem( nId
, bContoured
)
1334 SfxPoolItem
* SvxContourItem::Clone( SfxItemPool
* ) const
1336 return new SvxContourItem( *this );
1340 bool SvxContourItem::GetPresentation
1342 SfxItemPresentation
/*ePres*/,
1343 MapUnit
/*eCoreUnit*/,
1344 MapUnit
/*ePresUnit*/,
1345 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1348 const char* pId
= RID_SVXITEMS_CONTOUR_FALSE
;
1351 pId
= RID_SVXITEMS_CONTOUR_TRUE
;
1352 rText
= EditResId(pId
);
1356 // class SvxBackgroundColorItem -----------------------------------------
1358 SvxBackgroundColorItem::SvxBackgroundColorItem( const sal_uInt16 nId
) :
1364 SvxBackgroundColorItem::SvxBackgroundColorItem( const Color
& rCol
,
1365 const sal_uInt16 nId
) :
1366 SvxColorItem( rCol
, nId
)
1370 SfxPoolItem
* SvxBackgroundColorItem::Clone( SfxItemPool
* ) const
1372 return new SvxBackgroundColorItem(*this);
1375 bool SvxBackgroundColorItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1377 nMemberId
&= ~CONVERT_TWIPS
;
1378 Color aColor
= SvxColorItem::GetValue();
1382 case MID_GRAPHIC_TRANSPARENT
:
1384 rVal
<<= aColor
.GetTransparency() == 0xff;
1396 bool SvxBackgroundColorItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1398 nMemberId
&= ~CONVERT_TWIPS
;
1399 sal_Int32 nColor
= 0;
1400 Color aColor
= SvxColorItem::GetValue();
1404 case MID_GRAPHIC_TRANSPARENT
:
1406 aColor
.SetTransparency( Any2Bool( rVal
) ? 0xff : 0 );
1407 SvxColorItem::SetValue( aColor
);
1412 if(!(rVal
>>= nColor
))
1414 SvxColorItem::SetValue( Color(nColor
) );
1421 // class SvxColorItem ----------------------------------------------------
1422 SvxColorItem::SvxColorItem( const sal_uInt16 nId
) :
1428 SvxColorItem::SvxColorItem( const Color
& rCol
, const sal_uInt16 nId
) :
1434 SvxColorItem::~SvxColorItem()
1438 bool SvxColorItem::operator==( const SfxPoolItem
& rAttr
) const
1440 assert(SfxPoolItem::operator==(rAttr
));
1442 return mColor
== static_cast<const SvxColorItem
&>( rAttr
).mColor
;
1445 bool SvxColorItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
1451 bool SvxColorItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
1453 return (rVal
>>= mColor
);
1456 SfxPoolItem
* SvxColorItem::Clone( SfxItemPool
* ) const
1458 return new SvxColorItem( *this );
1461 bool SvxColorItem::GetPresentation
1463 SfxItemPresentation
/*ePres*/,
1464 MapUnit
/*eCoreUnit*/,
1465 MapUnit
/*ePresUnit*/,
1466 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1469 rText
= ::GetColorString( mColor
);
1473 void SvxColorItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1475 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxColorItem"));
1476 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1478 IntlWrapper
aIntlWrapper(SvtSysLocale().GetUILanguageTag());
1479 GetPresentation( SfxItemPresentation::Complete
, MapUnit::Map100thMM
, MapUnit::Map100thMM
, aStr
, aIntlWrapper
);
1480 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OUStringToOString(aStr
, RTL_TEXTENCODING_UTF8
).getStr()));
1481 xmlTextWriterEndElement(pWriter
);
1486 void SvxColorItem::SetValue( const Color
& rNewCol
)
1491 // class SvxKerningItem --------------------------------------------------
1493 SvxKerningItem::SvxKerningItem( const short nKern
, const sal_uInt16 nId
) :
1494 SfxInt16Item( nId
, nKern
)
1499 SfxPoolItem
* SvxKerningItem::Clone( SfxItemPool
* ) const
1501 return new SvxKerningItem( *this );
1505 void SvxKerningItem::ScaleMetrics( long nMult
, long nDiv
)
1507 SetValue( static_cast<sal_Int16
>(Scale( GetValue(), nMult
, nDiv
)) );
1511 bool SvxKerningItem::HasMetrics() const
1517 bool SvxKerningItem::GetPresentation
1519 SfxItemPresentation ePres
,
1521 MapUnit
/*ePresUnit*/,
1522 OUString
& rText
, const IntlWrapper
& rIntl
1527 case SfxItemPresentation::Nameless
:
1528 rText
= GetMetricText( static_cast<long>(GetValue()), eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
1529 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
1531 case SfxItemPresentation::Complete
:
1533 rText
= EditResId(RID_SVXITEMS_KERNING_COMPLETE
);
1534 const char* pId
= nullptr;
1536 if ( GetValue() > 0 )
1537 pId
= RID_SVXITEMS_KERNING_EXPANDED
;
1538 else if ( GetValue() < 0 )
1539 pId
= RID_SVXITEMS_KERNING_CONDENSED
;
1542 rText
+= EditResId(pId
);
1543 rText
+= GetMetricText( static_cast<long>(GetValue()), eCoreUnit
, MapUnit::MapPoint
, &rIntl
) +
1544 " " + EditResId(GetMetricId(MapUnit::MapPoint
));
1547 default: ; //prevent warning
1552 bool SvxKerningItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1554 sal_Int16 nVal
= GetValue();
1555 if(nMemberId
& CONVERT_TWIPS
)
1556 nVal
= static_cast<sal_Int16
>(convertTwipToMm100(nVal
));
1561 bool SvxKerningItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1563 sal_Int16 nVal
= sal_Int16();
1564 if(!(rVal
>>= nVal
))
1566 if(nMemberId
& CONVERT_TWIPS
)
1567 nVal
= static_cast<sal_Int16
>(convertMm100ToTwip(nVal
));
1572 // class SvxCaseMapItem --------------------------------------------------
1574 SvxCaseMapItem::SvxCaseMapItem( const SvxCaseMap eMap
, const sal_uInt16 nId
) :
1575 SfxEnumItem( nId
, eMap
)
1580 sal_uInt16
SvxCaseMapItem::GetValueCount() const
1582 return sal_uInt16(SvxCaseMap::End
); // SvxCaseMap::SmallCaps + 1
1586 SfxPoolItem
* SvxCaseMapItem::Clone( SfxItemPool
* ) const
1588 return new SvxCaseMapItem( *this );
1592 bool SvxCaseMapItem::GetPresentation
1594 SfxItemPresentation
/*ePres*/,
1595 MapUnit
/*eCoreUnit*/,
1596 MapUnit
/*ePresUnit*/,
1597 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1600 rText
= GetValueTextByPos( static_cast<sal_uInt16
>(GetValue()) );
1604 OUString
SvxCaseMapItem::GetValueTextByPos( sal_uInt16 nPos
)
1606 static const char* RID_SVXITEMS_CASEMAP
[] =
1608 RID_SVXITEMS_CASEMAP_NONE
,
1609 RID_SVXITEMS_CASEMAP_UPPERCASE
,
1610 RID_SVXITEMS_CASEMAP_LOWERCASE
,
1611 RID_SVXITEMS_CASEMAP_TITLE
,
1612 RID_SVXITEMS_CASEMAP_SMALLCAPS
1615 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_CASEMAP
) == size_t(SvxCaseMap::End
), "must match");
1616 assert(nPos
< sal_uInt16(SvxCaseMap::End
) && "enum overflow!");
1617 return EditResId(RID_SVXITEMS_CASEMAP
[nPos
]);
1620 bool SvxCaseMapItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
1622 sal_Int16 nRet
= style::CaseMap::NONE
;
1623 switch( GetValue() )
1625 case SvxCaseMap::Uppercase
: nRet
= style::CaseMap::UPPERCASE
; break;
1626 case SvxCaseMap::Lowercase
: nRet
= style::CaseMap::LOWERCASE
; break;
1627 case SvxCaseMap::Capitalize
: nRet
= style::CaseMap::TITLE
; break;
1628 case SvxCaseMap::SmallCaps
: nRet
= style::CaseMap::SMALLCAPS
; break;
1635 bool SvxCaseMapItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
1637 sal_uInt16 nVal
= sal_uInt16();
1638 if(!(rVal
>>= nVal
))
1644 case style::CaseMap::NONE
: eVal
= SvxCaseMap::NotMapped
; break;
1645 case style::CaseMap::UPPERCASE
: eVal
= SvxCaseMap::Uppercase
; break;
1646 case style::CaseMap::LOWERCASE
: eVal
= SvxCaseMap::Lowercase
; break;
1647 case style::CaseMap::TITLE
: eVal
= SvxCaseMap::Capitalize
; break;
1648 case style::CaseMap::SMALLCAPS
: eVal
= SvxCaseMap::SmallCaps
; break;
1649 default: return false;
1655 // class SvxEscapementItem -----------------------------------------------
1657 SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId
) :
1658 SfxEnumItemInterface( nId
),
1666 SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape
,
1667 const sal_uInt16 nId
) :
1668 SfxEnumItemInterface( nId
),
1671 SetEscapement( eEscape
);
1677 SvxEscapementItem::SvxEscapementItem( const short _nEsc
,
1678 const sal_uInt8 _nProp
,
1679 const sal_uInt16 nId
) :
1680 SfxEnumItemInterface( nId
),
1687 bool SvxEscapementItem::operator==( const SfxPoolItem
& rAttr
) const
1689 assert(SfxPoolItem::operator==(rAttr
));
1691 return( nEsc
== static_cast<const SvxEscapementItem
&>(rAttr
).nEsc
&&
1692 nProp
== static_cast<const SvxEscapementItem
&>(rAttr
).nProp
);
1696 SfxPoolItem
* SvxEscapementItem::Clone( SfxItemPool
* ) const
1698 return new SvxEscapementItem( *this );
1702 sal_uInt16
SvxEscapementItem::GetValueCount() const
1704 return sal_uInt16(SvxEscapement::End
); // SvxEscapement::Subscript + 1
1708 bool SvxEscapementItem::GetPresentation
1710 SfxItemPresentation
/*ePres*/,
1711 MapUnit
/*eCoreUnit*/,
1712 MapUnit
/*ePresUnit*/,
1713 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1716 rText
= GetValueTextByPos( GetEnumValue() );
1720 if( DFLT_ESC_AUTO_SUPER
== nEsc
|| DFLT_ESC_AUTO_SUB
== nEsc
)
1721 rText
+= EditResId(RID_SVXITEMS_ESCAPEMENT_AUTO
);
1723 rText
+= OUString::number( nEsc
) + "%";
1728 OUString
SvxEscapementItem::GetValueTextByPos( sal_uInt16 nPos
)
1730 static const char* RID_SVXITEMS_ESCAPEMENT
[] =
1732 RID_SVXITEMS_ESCAPEMENT_OFF
,
1733 RID_SVXITEMS_ESCAPEMENT_SUPER
,
1734 RID_SVXITEMS_ESCAPEMENT_SUB
1737 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_ESCAPEMENT
) == size_t(SvxEscapement::End
), "must match");
1738 assert(nPos
< sal_uInt16(SvxEscapement::End
) && "enum overflow!");
1739 return EditResId(RID_SVXITEMS_ESCAPEMENT
[nPos
]);
1742 sal_uInt16
SvxEscapementItem::GetEnumValue() const
1745 return sal_uInt16(SvxEscapement::Subscript
);
1746 else if ( nEsc
> 0 )
1747 return sal_uInt16(SvxEscapement::Superscript
);
1748 return sal_uInt16(SvxEscapement::Off
);
1752 void SvxEscapementItem::SetEnumValue( sal_uInt16 nVal
)
1754 SetEscapement( static_cast<SvxEscapement
>(nVal
) );
1757 bool SvxEscapementItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1759 nMemberId
&= ~CONVERT_TWIPS
;
1763 rVal
<<= static_cast<sal_Int16
>(nEsc
);
1765 case MID_ESC_HEIGHT
:
1766 rVal
<<= static_cast<sal_Int8
>(nProp
);
1769 rVal
<<= (DFLT_ESC_AUTO_SUB
== nEsc
|| DFLT_ESC_AUTO_SUPER
== nEsc
);
1775 bool SvxEscapementItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1777 nMemberId
&= ~CONVERT_TWIPS
;
1782 sal_Int16 nVal
= sal_Int16();
1783 // tdf#120412 up to 14400% (eg. 1584 pt with 11 pt letters)
1784 if( (rVal
>>= nVal
) && (std::abs(nVal
) <= 14400))
1790 case MID_ESC_HEIGHT
:
1792 sal_Int8 nVal
= sal_Int8();
1793 if( (rVal
>>= nVal
) && (nVal
<= 100))
1801 bool bVal
= Any2Bool(rVal
);
1805 nEsc
= DFLT_ESC_AUTO_SUB
;
1807 nEsc
= DFLT_ESC_AUTO_SUPER
;
1810 if(DFLT_ESC_AUTO_SUPER
== nEsc
)
1812 else if(DFLT_ESC_AUTO_SUB
== nEsc
)
1820 // class SvxLanguageItem -------------------------------------------------
1822 SvxLanguageItem::SvxLanguageItem( const LanguageType eLang
, const sal_uInt16 nId
)
1823 : SvxLanguageItem_Base( nId
, eLang
)
1828 sal_uInt16
SvxLanguageItem::GetValueCount() const
1830 // #i50205# got rid of class International
1831 SAL_WARN( "editeng.items", "SvxLanguageItem::GetValueCount: supposed to return a count of what?");
1832 // Could be SvtLanguageTable::GetEntryCount() (all locales with resource string)?
1833 // Could be LocaleDataWrapper::getInstalledLanguageTypes() (all locales with locale data)?
1838 SfxPoolItem
* SvxLanguageItem::Clone( SfxItemPool
* ) const
1840 return new SvxLanguageItem( *this );
1844 bool SvxLanguageItem::GetPresentation
1846 SfxItemPresentation
/*ePres*/,
1847 MapUnit
/*eCoreUnit*/,
1848 MapUnit
/*ePresUnit*/,
1849 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1852 rText
= SvtLanguageTable::GetLanguageString( GetValue() );
1856 bool SvxLanguageItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1858 nMemberId
&= ~CONVERT_TWIPS
;
1861 case MID_LANG_INT
: // for basic conversions!
1862 rVal
<<= static_cast<sal_Int16
>(static_cast<sal_uInt16
>(GetValue()));
1864 case MID_LANG_LOCALE
:
1865 lang::Locale
aRet( LanguageTag::convertToLocale( GetValue(), false));
1872 bool SvxLanguageItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1874 nMemberId
&= ~CONVERT_TWIPS
;
1877 case MID_LANG_INT
: // for basic conversions!
1879 sal_Int32 nValue
= 0;
1880 if(!(rVal
>>= nValue
))
1883 SetValue(LanguageType(nValue
));
1886 case MID_LANG_LOCALE
:
1888 lang::Locale aLocale
;
1889 if(!(rVal
>>= aLocale
))
1892 SetValue( LanguageTag::convertToLanguageType( aLocale
, false));
1899 // class SvxNoHyphenItem -------------------------------------------------
1901 SvxNoHyphenItem::SvxNoHyphenItem( const sal_uInt16 nId
) :
1902 SfxBoolItem( nId
, true )
1907 SfxPoolItem
* SvxNoHyphenItem::Clone( SfxItemPool
* ) const
1909 return new SvxNoHyphenItem( *this );
1913 bool SvxNoHyphenItem::GetPresentation
1915 SfxItemPresentation
/*ePres*/,
1916 MapUnit
/*eCoreUnit*/,
1917 MapUnit
/*ePresUnit*/,
1918 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1926 * Dummy item for ToolBox controls:
1931 // class SvxBlinkItem -------------------------------------------------
1934 SvxBlinkItem::SvxBlinkItem( const bool bBlink
, const sal_uInt16 nId
) :
1935 SfxBoolItem( nId
, bBlink
)
1940 SfxPoolItem
* SvxBlinkItem::Clone( SfxItemPool
* ) const
1942 return new SvxBlinkItem( *this );
1946 bool SvxBlinkItem::GetPresentation
1948 SfxItemPresentation
/*ePres*/,
1949 MapUnit
/*eCoreUnit*/,
1950 MapUnit
/*ePresUnit*/,
1951 OUString
& rText
, const IntlWrapper
& /*rIntl*/
1954 const char* pId
= RID_SVXITEMS_BLINK_FALSE
;
1957 pId
= RID_SVXITEMS_BLINK_TRUE
;
1958 rText
= EditResId(pId
);
1962 // class SvxEmphaisMarkItem ---------------------------------------------------
1964 SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue
,
1965 const sal_uInt16 nId
)
1966 : SfxUInt16Item( nId
, static_cast<sal_uInt16
>(nValue
) )
1971 SfxPoolItem
* SvxEmphasisMarkItem::Clone( SfxItemPool
* ) const
1973 return new SvxEmphasisMarkItem( *this );
1977 bool SvxEmphasisMarkItem::GetPresentation
1979 SfxItemPresentation
/*ePres*/,
1980 MapUnit
/*eCoreUnit*/,
1981 MapUnit
/*ePresUnit*/,
1983 const IntlWrapper
& /*rIntl*/
1986 static const char* RID_SVXITEMS_EMPHASIS
[] =
1988 RID_SVXITEMS_EMPHASIS_NONE_STYLE
,
1989 RID_SVXITEMS_EMPHASIS_DOT_STYLE
,
1990 RID_SVXITEMS_EMPHASIS_CIRCLE_STYLE
,
1991 RID_SVXITEMS_EMPHASIS_DISC_STYLE
,
1992 RID_SVXITEMS_EMPHASIS_ACCENT_STYLE
1995 FontEmphasisMark nVal
= GetEmphasisMark();
1996 rText
= EditResId(RID_SVXITEMS_EMPHASIS
[
1997 static_cast<sal_uInt16
>(static_cast<FontEmphasisMark
>( nVal
& FontEmphasisMark::Style
))]);
1998 const char* pId
= ( FontEmphasisMark::PosAbove
& nVal
)
1999 ? RID_SVXITEMS_EMPHASIS_ABOVE_POS
2000 : ( FontEmphasisMark::PosBelow
& nVal
)
2001 ? RID_SVXITEMS_EMPHASIS_BELOW_POS
2004 rText
+= EditResId( pId
);
2008 bool SvxEmphasisMarkItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2010 nMemberId
&= ~CONVERT_TWIPS
;
2015 FontEmphasisMark nValue
= GetEmphasisMark();
2017 switch(nValue
& FontEmphasisMark::Style
)
2019 case FontEmphasisMark::NONE
: nRet
= FontEmphasis::NONE
; break;
2020 case FontEmphasisMark::Dot
: nRet
= FontEmphasis::DOT_ABOVE
; break;
2021 case FontEmphasisMark::Circle
: nRet
= FontEmphasis::CIRCLE_ABOVE
; break;
2022 case FontEmphasisMark::Disc
: nRet
= FontEmphasis::DISK_ABOVE
; break;
2023 case FontEmphasisMark::Accent
: nRet
= FontEmphasis::ACCENT_ABOVE
; break;
2026 if(nRet
&& nValue
& FontEmphasisMark::PosBelow
)
2035 bool SvxEmphasisMarkItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2037 nMemberId
&= ~CONVERT_TWIPS
;
2042 sal_Int32 nValue
= -1;
2044 FontEmphasisMark nMark
;
2047 case FontEmphasis::NONE
: nMark
= FontEmphasisMark::NONE
; break;
2048 case FontEmphasis::DOT_ABOVE
: nMark
= FontEmphasisMark::Dot
|FontEmphasisMark::PosAbove
; break;
2049 case FontEmphasis::CIRCLE_ABOVE
: nMark
= FontEmphasisMark::Circle
|FontEmphasisMark::PosAbove
; break;
2050 case FontEmphasis::DISK_ABOVE
: nMark
= FontEmphasisMark::Disc
|FontEmphasisMark::PosAbove
; break;
2051 case FontEmphasis::ACCENT_ABOVE
: nMark
= FontEmphasisMark::Accent
|FontEmphasisMark::PosAbove
; break;
2052 case FontEmphasis::DOT_BELOW
: nMark
= FontEmphasisMark::Dot
|FontEmphasisMark::PosBelow
; break;
2053 case FontEmphasis::CIRCLE_BELOW
: nMark
= FontEmphasisMark::Circle
|FontEmphasisMark::PosBelow
; break;
2054 case FontEmphasis::DISK_BELOW
: nMark
= FontEmphasisMark::Disc
|FontEmphasisMark::PosBelow
; break;
2055 case FontEmphasis::ACCENT_BELOW
: nMark
= FontEmphasisMark::Accent
|FontEmphasisMark::PosBelow
; break;
2056 default: return false;
2058 SetValue( static_cast<sal_Int16
>(nMark
) );
2065 /*************************************************************************
2066 |* class SvxTwoLinesItem
2067 *************************************************************************/
2069 SvxTwoLinesItem::SvxTwoLinesItem( bool bFlag
, sal_Unicode nStartBracket
,
2070 sal_Unicode nEndBracket
, sal_uInt16 nW
)
2071 : SfxPoolItem( nW
),
2072 cStartBracket( nStartBracket
), cEndBracket( nEndBracket
), bOn( bFlag
)
2076 SvxTwoLinesItem::~SvxTwoLinesItem()
2080 bool SvxTwoLinesItem::operator==( const SfxPoolItem
& rAttr
) const
2082 assert(SfxPoolItem::operator==(rAttr
));
2083 return bOn
== static_cast<const SvxTwoLinesItem
&>(rAttr
).bOn
&&
2084 cStartBracket
== static_cast<const SvxTwoLinesItem
&>(rAttr
).cStartBracket
&&
2085 cEndBracket
== static_cast<const SvxTwoLinesItem
&>(rAttr
).cEndBracket
;
2088 SfxPoolItem
* SvxTwoLinesItem::Clone( SfxItemPool
* ) const
2090 return new SvxTwoLinesItem( *this );
2093 bool SvxTwoLinesItem::QueryValue( css::uno::Any
& rVal
,
2094 sal_uInt8 nMemberId
) const
2096 nMemberId
&= ~CONVERT_TWIPS
;
2103 case MID_START_BRACKET
:
2107 s
= OUString( cStartBracket
);
2111 case MID_END_BRACKET
:
2115 s
= OUString( cEndBracket
);
2126 bool SvxTwoLinesItem::PutValue( const css::uno::Any
& rVal
,
2127 sal_uInt8 nMemberId
)
2129 nMemberId
&= ~CONVERT_TWIPS
;
2135 bOn
= Any2Bool( rVal
);
2138 case MID_START_BRACKET
:
2141 cStartBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
2145 case MID_END_BRACKET
:
2148 cEndBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
2156 bool SvxTwoLinesItem::GetPresentation( SfxItemPresentation
/*ePres*/,
2157 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2158 OUString
&rText
, const IntlWrapper
& /*rIntl*/ ) const
2161 rText
= EditResId( RID_SVXITEMS_TWOLINES_OFF
);
2164 rText
= EditResId( RID_SVXITEMS_TWOLINES
);
2165 if( GetStartBracket() )
2166 rText
= OUStringChar(GetStartBracket()) + rText
;
2167 if( GetEndBracket() )
2168 rText
+= OUStringChar(GetEndBracket());
2174 /*************************************************************************
2175 |* class SvxTextRotateItem
2176 *************************************************************************/
2178 SvxTextRotateItem::SvxTextRotateItem(sal_uInt16 nValue
, const sal_uInt16 nW
)
2179 : SfxUInt16Item(nW
, nValue
)
2183 SfxPoolItem
* SvxTextRotateItem::Clone(SfxItemPool
*) const
2185 return new SvxTextRotateItem(*this);
2188 bool SvxTextRotateItem::GetPresentation(
2189 SfxItemPresentation
/*ePres*/,
2190 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2191 OUString
&rText
, const IntlWrapper
&) const
2194 rText
= EditResId(RID_SVXITEMS_TEXTROTATE_OFF
);
2197 rText
= EditResId(RID_SVXITEMS_TEXTROTATE
);
2198 rText
= rText
.replaceFirst("$(ARG1)",
2199 OUString::number(GetValue() / 10));
2204 bool SvxTextRotateItem::QueryValue(css::uno::Any
& rVal
,
2205 sal_uInt8 nMemberId
) const
2207 nMemberId
&= ~CONVERT_TWIPS
;
2212 rVal
<<= static_cast<sal_Int16
>(GetValue());
2221 bool SvxTextRotateItem::PutValue(const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
2223 nMemberId
&= ~CONVERT_TWIPS
;
2230 if ((rVal
>>= nVal
) && (0 == nVal
|| 900 == nVal
|| 2700 == nVal
))
2231 SetValue(static_cast<sal_uInt16
>(nVal
));
2242 void SvxTextRotateItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2244 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxTextRotateItem"));
2245 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2246 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
2247 xmlTextWriterEndElement(pWriter
);
2251 /*************************************************************************
2252 |* class SvxCharRotateItem
2253 *************************************************************************/
2255 SvxCharRotateItem::SvxCharRotateItem( sal_uInt16 nValue
,
2257 const sal_uInt16 nW
)
2258 : SvxTextRotateItem(nValue
, nW
), bFitToLine( bFitIntoLine
)
2262 SfxPoolItem
* SvxCharRotateItem::Clone( SfxItemPool
* ) const
2264 return new SvxCharRotateItem( *this );
2267 bool SvxCharRotateItem::GetPresentation(
2268 SfxItemPresentation
/*ePres*/,
2269 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2270 OUString
&rText
, const IntlWrapper
&) const
2273 rText
= EditResId( RID_SVXITEMS_CHARROTATE_OFF
);
2276 rText
= EditResId( RID_SVXITEMS_CHARROTATE
);
2277 rText
= rText
.replaceFirst( "$(ARG1)",
2278 OUString::number( GetValue() / 10 ));
2280 rText
+= EditResId( RID_SVXITEMS_CHARROTATE_FITLINE
);
2285 bool SvxCharRotateItem::QueryValue( css::uno::Any
& rVal
,
2286 sal_uInt8 nMemberId
) const
2289 switch(nMemberId
& ~CONVERT_TWIPS
)
2292 SvxTextRotateItem::QueryValue(rVal
, nMemberId
);
2295 rVal
<<= IsFitToLine();
2304 bool SvxCharRotateItem::PutValue( const css::uno::Any
& rVal
,
2305 sal_uInt8 nMemberId
)
2308 switch(nMemberId
& ~CONVERT_TWIPS
)
2312 bRet
= SvxTextRotateItem::PutValue(rVal
, nMemberId
);
2317 SetFitToLine( Any2Bool( rVal
) );
2325 bool SvxCharRotateItem::operator==( const SfxPoolItem
& rItem
) const
2327 assert(SfxPoolItem::operator==(rItem
));
2328 return SvxTextRotateItem::operator==( rItem
) &&
2329 IsFitToLine() == static_cast<const SvxCharRotateItem
&>(rItem
).IsFitToLine();
2332 void SvxCharRotateItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2334 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxCharRotateItem"));
2335 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2336 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
2337 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("fitToLine"), BAD_CAST(OString::boolean(IsFitToLine()).getStr()));
2338 xmlTextWriterEndElement(pWriter
);
2341 /*************************************************************************
2342 |* class SvxCharScaleItem
2343 *************************************************************************/
2345 SvxCharScaleWidthItem::SvxCharScaleWidthItem( sal_uInt16 nValue
,
2346 const sal_uInt16 nW
)
2347 : SfxUInt16Item( nW
, nValue
)
2351 SfxPoolItem
* SvxCharScaleWidthItem::Clone( SfxItemPool
* ) const
2353 return new SvxCharScaleWidthItem( *this );
2357 bool SvxCharScaleWidthItem::GetPresentation(
2358 SfxItemPresentation
/*ePres*/,
2359 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
2360 OUString
&rText
, const IntlWrapper
&) const
2363 rText
= EditResId( RID_SVXITEMS_CHARSCALE_OFF
);
2366 rText
= EditResId( RID_SVXITEMS_CHARSCALE
);
2367 rText
= rText
.replaceFirst( "$(ARG1)",
2368 OUString::number( GetValue() ));
2373 bool SvxCharScaleWidthItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
2375 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
2376 // where we still want this to be a sal_Int16
2377 sal_Int16 nValue
= sal_Int16();
2378 if (rVal
>>= nValue
)
2380 SetValue( static_cast<sal_uInt16
>(nValue
) );
2384 SAL_WARN("editeng.items", "SvxCharScaleWidthItem::PutValue - Wrong type!" );
2388 bool SvxCharScaleWidthItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
2390 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
2391 // where we still want this to be a sal_Int16
2392 rVal
<<= static_cast<sal_Int16
>(GetValue());
2396 /*************************************************************************
2397 |* class SvxCharReliefItem
2398 *************************************************************************/
2400 SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue
,
2401 const sal_uInt16 nId
)
2402 : SfxEnumItem( nId
, eValue
)
2406 SfxPoolItem
* SvxCharReliefItem::Clone( SfxItemPool
* ) const
2408 return new SvxCharReliefItem( *this );
2411 static const char* RID_SVXITEMS_RELIEF
[] =
2413 RID_SVXITEMS_RELIEF_NONE
,
2414 RID_SVXITEMS_RELIEF_EMBOSSED
,
2415 RID_SVXITEMS_RELIEF_ENGRAVED
2418 OUString
SvxCharReliefItem::GetValueTextByPos(sal_uInt16 nPos
)
2420 assert(nPos
< SAL_N_ELEMENTS(RID_SVXITEMS_RELIEF
) && "enum overflow");
2421 return EditResId(RID_SVXITEMS_RELIEF
[nPos
]);
2424 sal_uInt16
SvxCharReliefItem::GetValueCount() const
2426 return SAL_N_ELEMENTS(RID_SVXITEMS_RELIEF
) - 1;
2429 bool SvxCharReliefItem::GetPresentation
2431 SfxItemPresentation
/*ePres*/,
2432 MapUnit
/*eCoreUnit*/,
2433 MapUnit
/*ePresUnit*/,
2434 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2437 rText
= GetValueTextByPos( static_cast<sal_uInt16
>(GetValue()) );
2441 bool SvxCharReliefItem::PutValue( const css::uno::Any
& rVal
,
2442 sal_uInt8 nMemberId
)
2444 nMemberId
&= ~CONVERT_TWIPS
;
2450 sal_Int16 nVal
= -1;
2452 if(nVal
>= 0 && nVal
<= sal_Int16(FontRelief::Engraved
))
2453 SetValue( static_cast<FontRelief
>(nVal
) );
2465 bool SvxCharReliefItem::QueryValue( css::uno::Any
& rVal
,
2466 sal_uInt8 nMemberId
) const
2468 nMemberId
&= ~CONVERT_TWIPS
;
2473 rVal
<<= static_cast<sal_Int16
>(GetValue());
2482 /*************************************************************************
2483 |* class SvxScriptSetItem
2484 *************************************************************************/
2486 SvxScriptSetItem::SvxScriptSetItem( sal_uInt16 nSlotId
, SfxItemPool
& rPool
)
2487 : SfxSetItem( nSlotId
, std::make_unique
<SfxItemSet
>( rPool
,
2488 svl::Items
<SID_ATTR_CHAR_FONT
, SID_ATTR_CHAR_FONT
>{} ))
2490 sal_uInt16 nLatin
, nAsian
, nComplex
;
2491 GetWhichIds( nLatin
, nAsian
, nComplex
);
2492 GetItemSet().MergeRange( nLatin
, nLatin
);
2493 GetItemSet().MergeRange( nAsian
, nAsian
);
2494 GetItemSet().MergeRange( nComplex
, nComplex
);
2497 SfxPoolItem
* SvxScriptSetItem::Clone( SfxItemPool
* ) const
2499 SvxScriptSetItem
* p
= new SvxScriptSetItem( Which(), *GetItemSet().GetPool() );
2500 p
->GetItemSet().Put( GetItemSet(), false );
2504 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScriptSet(
2505 const SfxItemSet
& rSet
, sal_uInt16 nId
)
2507 const SfxPoolItem
* pI
;
2508 SfxItemState eSt
= rSet
.GetItemState( nId
, false, &pI
);
2509 if( SfxItemState::SET
!= eSt
)
2510 pI
= SfxItemState::DEFAULT
== eSt
? &rSet
.Get( nId
) : nullptr;
2514 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, SvtScriptType nScript
)
2516 sal_uInt16 nLatin
, nAsian
, nComplex
;
2517 GetWhichIds( nSlotId
, rSet
, nLatin
, nAsian
, nComplex
);
2519 const SfxPoolItem
*pRet
, *pAsn
, *pCmplx
;
2520 if (nScript
== SvtScriptType::ASIAN
)
2522 pRet
= GetItemOfScriptSet( rSet
, nAsian
);
2523 } else if (nScript
== SvtScriptType::COMPLEX
)
2525 pRet
= GetItemOfScriptSet( rSet
, nComplex
);
2526 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::ASIAN
))
2528 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2529 nullptr == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2532 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::COMPLEX
))
2534 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2535 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2538 } else if (nScript
== (SvtScriptType::ASIAN
|SvtScriptType::COMPLEX
))
2540 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2541 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2544 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::ASIAN
|SvtScriptType::COMPLEX
))
2546 if( nullptr == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
2547 nullptr == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
2548 nullptr == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
2549 *pRet
!= *pAsn
|| *pRet
!= *pCmplx
)
2552 //no one valid -> match to latin
2553 pRet
= GetItemOfScriptSet( rSet
, nLatin
);
2558 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( SvtScriptType nScript
) const
2560 return GetItemOfScript( Which(), GetItemSet(), nScript
);
2563 void SvxScriptSetItem::PutItemForScriptType( SvtScriptType nScriptType
,
2564 const SfxPoolItem
& rItem
)
2566 sal_uInt16 nLatin
, nAsian
, nComplex
;
2567 GetWhichIds( nLatin
, nAsian
, nComplex
);
2569 std::unique_ptr
<SfxPoolItem
> pCpy(rItem
.Clone());
2570 if( SvtScriptType::LATIN
& nScriptType
)
2572 pCpy
->SetWhich( nLatin
);
2573 GetItemSet().Put( *pCpy
);
2575 if( SvtScriptType::ASIAN
& nScriptType
)
2577 pCpy
->SetWhich( nAsian
);
2578 GetItemSet().Put( *pCpy
);
2580 if( SvtScriptType::COMPLEX
& nScriptType
)
2582 pCpy
->SetWhich( nComplex
);
2583 GetItemSet().Put( *pCpy
);
2587 void SvxScriptSetItem::GetWhichIds( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, sal_uInt16
& rLatin
, sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
2589 const SfxItemPool
& rPool
= *rSet
.GetPool();
2590 GetSlotIds( nSlotId
, rLatin
, rAsian
, rComplex
);
2591 rLatin
= rPool
.GetWhich( rLatin
);
2592 rAsian
= rPool
.GetWhich( rAsian
);
2593 rComplex
= rPool
.GetWhich( rComplex
);
2596 void SvxScriptSetItem::GetWhichIds( sal_uInt16
& rLatin
, sal_uInt16
& rAsian
,
2597 sal_uInt16
& rComplex
) const
2599 GetWhichIds( Which(), GetItemSet(), rLatin
, rAsian
, rComplex
);
2602 void SvxScriptSetItem::GetSlotIds( sal_uInt16 nSlotId
, sal_uInt16
& rLatin
,
2603 sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
2608 SAL_WARN( "editeng.items", "wrong SlotId for class SvxScriptSetItem" );
2609 [[fallthrough
]]; // default to font - Id Range !!
2611 case SID_ATTR_CHAR_FONT
:
2612 rLatin
= SID_ATTR_CHAR_FONT
;
2613 rAsian
= SID_ATTR_CHAR_CJK_FONT
;
2614 rComplex
= SID_ATTR_CHAR_CTL_FONT
;
2616 case SID_ATTR_CHAR_FONTHEIGHT
:
2617 rLatin
= SID_ATTR_CHAR_FONTHEIGHT
;
2618 rAsian
= SID_ATTR_CHAR_CJK_FONTHEIGHT
;
2619 rComplex
= SID_ATTR_CHAR_CTL_FONTHEIGHT
;
2621 case SID_ATTR_CHAR_WEIGHT
:
2622 rLatin
= SID_ATTR_CHAR_WEIGHT
;
2623 rAsian
= SID_ATTR_CHAR_CJK_WEIGHT
;
2624 rComplex
= SID_ATTR_CHAR_CTL_WEIGHT
;
2626 case SID_ATTR_CHAR_POSTURE
:
2627 rLatin
= SID_ATTR_CHAR_POSTURE
;
2628 rAsian
= SID_ATTR_CHAR_CJK_POSTURE
;
2629 rComplex
= SID_ATTR_CHAR_CTL_POSTURE
;
2631 case SID_ATTR_CHAR_LANGUAGE
:
2632 rLatin
= SID_ATTR_CHAR_LANGUAGE
;
2633 rAsian
= SID_ATTR_CHAR_CJK_LANGUAGE
;
2634 rComplex
= SID_ATTR_CHAR_CTL_LANGUAGE
;
2636 case SID_ATTR_CHAR_SHADOWED
:
2637 rLatin
= SID_ATTR_CHAR_SHADOWED
;
2638 rAsian
= SID_ATTR_CHAR_SHADOWED
;
2639 rComplex
= SID_ATTR_CHAR_SHADOWED
;
2641 case SID_ATTR_CHAR_STRIKEOUT
:
2642 rLatin
= SID_ATTR_CHAR_STRIKEOUT
;
2643 rAsian
= SID_ATTR_CHAR_STRIKEOUT
;
2644 rComplex
= SID_ATTR_CHAR_STRIKEOUT
;
2649 void GetDefaultFonts( SvxFontItem
& rLatin
, SvxFontItem
& rAsian
, SvxFontItem
& rComplex
)
2651 const sal_uInt16 nItemCnt
= 3;
2655 DefaultFontType nFontType
;
2656 LanguageType nLanguage
;
2658 const aOutTypeArr
[ nItemCnt
] =
2660 { DefaultFontType::LATIN_TEXT
, LANGUAGE_ENGLISH_US
},
2661 { DefaultFontType::CJK_TEXT
, LANGUAGE_ENGLISH_US
},
2662 { DefaultFontType::CTL_TEXT
, LANGUAGE_ARABIC_SAUDI_ARABIA
}
2665 SvxFontItem
* aItemArr
[ nItemCnt
] = { &rLatin
, &rAsian
, &rComplex
};
2667 for ( sal_uInt16 n
= 0; n
< nItemCnt
; ++n
)
2669 vcl::Font
aFont( OutputDevice::GetDefaultFont( aOutTypeArr
[ n
].nFontType
,
2670 aOutTypeArr
[ n
].nLanguage
,
2671 GetDefaultFontFlags::OnlyOne
) );
2672 SvxFontItem
* pItem
= aItemArr
[ n
];
2673 pItem
->SetFamily( aFont
.GetFamilyType() );
2674 pItem
->SetFamilyName( aFont
.GetFamilyName() );
2675 pItem
->SetStyleName( OUString() );
2676 pItem
->SetPitch( aFont
.GetPitch());
2677 pItem
->SetCharSet(aFont
.GetCharSet());
2682 bool SvxRsidItem::QueryValue( uno::Any
& rVal
, sal_uInt8
) const
2684 rVal
<<= GetValue();
2688 bool SvxRsidItem::PutValue( const uno::Any
& rVal
, sal_uInt8
)
2690 sal_uInt32 nRsid
= 0;
2691 if( !( rVal
>>= nRsid
) )
2698 SfxPoolItem
* SvxRsidItem::Clone( SfxItemPool
* ) const
2700 return new SvxRsidItem( *this );
2703 bool SvxRsidItem::GetPresentation
2705 SfxItemPresentation
/*ePres*/,
2706 MapUnit
/*eCoreUnit*/,
2707 MapUnit
/*ePresUnit*/,
2708 OUString
& rText
, const IntlWrapper
& /*rIntl*/
2715 void SvxRsidItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
2717 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxRsidItem"));
2718 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
2719 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%" SAL_PRIuUINT32
, GetValue());
2720 xmlTextWriterEndElement(pWriter
);
2723 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */