Bump version to 24.04.3.4
[LibreOffice.git] / editeng / source / items / textitem.cxx
blobe242566bd36fcdd54d30803594a9c8fda45b7c3c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <math.h>
24 #include <sal/log.hxx>
25 #include <o3tl/safeint.hxx>
26 #include <osl/diagnose.h>
27 #include <unotools/configmgr.hxx>
28 #include <unotools/fontdefs.hxx>
29 #include <unotools/intlwrapper.hxx>
30 #include <unotools/syslocale.hxx>
31 #include <utility>
32 #include <vcl/outdev.hxx>
33 #include <vcl/unohelp.hxx>
34 #include <svtools/unitconv.hxx>
36 #include <editeng/editids.hrc>
37 #include <editeng/editrids.hrc>
38 #include <tools/bigint.hxx>
39 #include <tools/mapunit.hxx>
40 #include <tools/UnitConversion.hxx>
42 #include <rtl/math.hxx>
43 #include <rtl/ustring.hxx>
44 #include <i18nlangtag/languagetag.hxx>
45 #include <svl/itemset.hxx>
47 #include <svtools/langtab.hxx>
48 #include <svl/itempool.hxx>
49 #include <svtools/ctrltool.hxx>
50 #include <com/sun/star/awt/FontSlant.hpp>
51 #include <com/sun/star/lang/Locale.hpp>
52 #include <com/sun/star/text/FontEmphasis.hpp>
53 #include <editeng/rsiditem.hxx>
54 #include <editeng/memberids.h>
55 #include <editeng/flstitem.hxx>
56 #include <editeng/fontitem.hxx>
57 #include <editeng/postitem.hxx>
58 #include <editeng/wghtitem.hxx>
59 #include <editeng/fhgtitem.hxx>
60 #include <editeng/udlnitem.hxx>
61 #include <editeng/crossedoutitem.hxx>
62 #include <editeng/shdditem.hxx>
63 #include <editeng/autokernitem.hxx>
64 #include <editeng/wrlmitem.hxx>
65 #include <editeng/contouritem.hxx>
66 #include <editeng/colritem.hxx>
67 #include <editeng/kernitem.hxx>
68 #include <editeng/cmapitem.hxx>
69 #include <editeng/escapementitem.hxx>
70 #include <editeng/langitem.hxx>
71 #include <editeng/nhypitem.hxx>
72 #include <editeng/blinkitem.hxx>
73 #include <editeng/emphasismarkitem.hxx>
74 #include <editeng/twolinesitem.hxx>
75 #include <editeng/scripttypeitem.hxx>
76 #include <editeng/charrotateitem.hxx>
77 #include <editeng/charscaleitem.hxx>
78 #include <editeng/charreliefitem.hxx>
79 #include <editeng/itemtype.hxx>
80 #include <editeng/eerdll.hxx>
81 #include <docmodel/color/ComplexColorJSON.hxx>
82 #include <docmodel/uno/UnoComplexColor.hxx>
83 #include <docmodel/color/ComplexColor.hxx>
84 #include <libxml/xmlwriter.h>
86 using namespace ::com::sun::star;
87 using namespace ::com::sun::star::text;
89 SfxPoolItem* SvxFontItem::CreateDefault() {return new SvxFontItem(0);}
90 SfxPoolItem* SvxPostureItem::CreateDefault() { return new SvxPostureItem(ITALIC_NONE, 0);}
91 SfxPoolItem* SvxWeightItem::CreateDefault() {return new SvxWeightItem(WEIGHT_NORMAL, 0);}
92 SfxPoolItem* SvxFontHeightItem::CreateDefault() {return new SvxFontHeightItem(240, 100, 0);}
93 SfxPoolItem* SvxUnderlineItem::CreateDefault() {return new SvxUnderlineItem(LINESTYLE_NONE, 0);}
94 SfxPoolItem* SvxOverlineItem::CreateDefault() {return new SvxOverlineItem(LINESTYLE_NONE, 0);}
95 SfxPoolItem* SvxCrossedOutItem::CreateDefault() {return new SvxCrossedOutItem(STRIKEOUT_NONE, 0);}
96 SfxPoolItem* SvxShadowedItem::CreateDefault() {return new SvxShadowedItem(false, 0);}
97 SfxPoolItem* SvxAutoKernItem::CreateDefault() {return new SvxAutoKernItem(false, 0);}
98 SfxPoolItem* SvxWordLineModeItem::CreateDefault() {return new SvxWordLineModeItem(false, 0);}
99 SfxPoolItem* SvxContourItem::CreateDefault() {return new SvxContourItem(false, 0);}
100 SfxPoolItem* SvxColorItem::CreateDefault() {return new SvxColorItem(0);}
101 SfxPoolItem* SvxKerningItem::CreateDefault() {return new SvxKerningItem(0, 0);}
102 SfxPoolItem* SvxCaseMapItem::CreateDefault() {return new SvxCaseMapItem(SvxCaseMap::NotMapped, 0);}
103 SfxPoolItem* SvxEscapementItem::CreateDefault() {return new SvxEscapementItem(0);}
104 SfxPoolItem* SvxLanguageItem::CreateDefault() {return new SvxLanguageItem(LANGUAGE_GERMAN, 0);}
105 SfxPoolItem* SvxEmphasisMarkItem::CreateDefault() {return new SvxEmphasisMarkItem(FontEmphasisMark::NONE, TypedWhichId<SvxEmphasisMarkItem>(0));}
106 SfxPoolItem* SvxCharRotateItem::CreateDefault() {return new SvxCharRotateItem(0_deg10, false, TypedWhichId<SvxCharRotateItem>(0));}
107 SfxPoolItem* SvxCharScaleWidthItem::CreateDefault() {return new SvxCharScaleWidthItem(100, TypedWhichId<SvxCharScaleWidthItem>(0));}
108 SfxPoolItem* SvxCharReliefItem::CreateDefault() {return new SvxCharReliefItem(FontRelief::NONE, 0);}
111 // class SvxFontListItem -------------------------------------------------
113 SvxFontListItem::SvxFontListItem( const FontList* pFontLst,
114 const sal_uInt16 nId ) :
115 SfxPoolItem( nId ),
116 pFontList( pFontLst )
118 if ( pFontList )
120 sal_Int32 nCount = pFontList->GetFontNameCount();
121 aFontNameSeq.realloc( nCount );
122 auto pFontNameSeq = aFontNameSeq.getArray();
124 for ( sal_Int32 i = 0; i < nCount; i++ )
125 pFontNameSeq[i] = pFontList->GetFontName(i).GetFamilyName();
129 SvxFontListItem* SvxFontListItem::Clone( SfxItemPool* ) const
131 return new SvxFontListItem( *this );
134 bool SvxFontListItem::operator==( const SfxPoolItem& rAttr ) const
136 assert(SfxPoolItem::operator==(rAttr));
138 return( pFontList == static_cast<const SvxFontListItem&>(rAttr).pFontList );
141 bool SvxFontListItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
143 rVal <<= aFontNameSeq;
144 return true;
148 bool SvxFontListItem::GetPresentation
150 SfxItemPresentation /*ePres*/,
151 MapUnit /*eCoreUnit*/,
152 MapUnit /*ePresUnit*/,
153 OUString& rText, const IntlWrapper& /*rIntl*/
154 ) const
156 rText.clear();
157 return false;
160 // class SvxFontItem -----------------------------------------------------
162 SvxFontItem::SvxFontItem( const sal_uInt16 nId ) :
163 SfxPoolItem( nId )
165 eFamily = FAMILY_SWISS;
166 ePitch = PITCH_VARIABLE;
167 eTextEncoding = RTL_TEXTENCODING_DONTKNOW;
171 SvxFontItem::SvxFontItem( const FontFamily eFam, OUString aName,
172 OUString aStName, const FontPitch eFontPitch,
173 const rtl_TextEncoding eFontTextEncoding, const sal_uInt16 nId ) :
175 SfxPoolItem( nId ),
177 aFamilyName(std::move(aName)),
178 aStyleName(std::move(aStName))
180 eFamily = eFam;
181 ePitch = eFontPitch;
182 eTextEncoding = eFontTextEncoding;
186 bool SvxFontItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
188 nMemberId &= ~CONVERT_TWIPS;
189 switch(nMemberId)
191 case 0:
193 css::awt::FontDescriptor aFontDescriptor;
194 aFontDescriptor.Name = aFamilyName;
195 aFontDescriptor.StyleName = aStyleName;
196 aFontDescriptor.Family = static_cast<sal_Int16>(eFamily);
197 aFontDescriptor.CharSet = static_cast<sal_Int16>(eTextEncoding);
198 aFontDescriptor.Pitch = static_cast<sal_Int16>(ePitch);
199 rVal <<= aFontDescriptor;
201 break;
202 case MID_FONT_FAMILY_NAME:
203 rVal <<= aFamilyName;
204 break;
205 case MID_FONT_STYLE_NAME:
206 rVal <<= aStyleName;
207 break;
208 case MID_FONT_FAMILY : rVal <<= static_cast<sal_Int16>(eFamily); break;
209 case MID_FONT_CHAR_SET : rVal <<= static_cast<sal_Int16>(eTextEncoding); break;
210 case MID_FONT_PITCH : rVal <<= static_cast<sal_Int16>(ePitch); break;
212 return true;
215 bool SvxFontItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId)
217 nMemberId &= ~CONVERT_TWIPS;
218 switch(nMemberId)
220 case 0:
222 css::awt::FontDescriptor aFontDescriptor;
223 if ( !( rVal >>= aFontDescriptor ))
224 return false;
226 aFamilyName = aFontDescriptor.Name;
227 aStyleName = aFontDescriptor.StyleName;
228 eFamily = static_cast<FontFamily>(aFontDescriptor.Family);
229 eTextEncoding = static_cast<rtl_TextEncoding>(aFontDescriptor.CharSet);
230 ePitch = static_cast<FontPitch>(aFontDescriptor.Pitch);
232 break;
233 case MID_FONT_FAMILY_NAME :
235 OUString aStr;
236 if(!(rVal >>= aStr))
237 return false;
238 aFamilyName = aStr;
240 break;
241 case MID_FONT_STYLE_NAME:
243 OUString aStr;
244 if(!(rVal >>= aStr))
245 return false;
246 aStyleName = aStr;
248 break;
249 case MID_FONT_FAMILY :
251 sal_Int16 nFamily = sal_Int16();
252 if(!(rVal >>= nFamily))
253 return false;
254 eFamily = static_cast<FontFamily>(nFamily);
256 break;
257 case MID_FONT_CHAR_SET :
259 sal_Int16 nSet = sal_Int16();
260 if(!(rVal >>= nSet))
261 return false;
262 eTextEncoding = static_cast<rtl_TextEncoding>(nSet);
264 break;
265 case MID_FONT_PITCH :
267 sal_Int16 nPitch = sal_Int16();
268 if(!(rVal >>= nPitch))
269 return false;
270 ePitch = static_cast<FontPitch>(nPitch);
272 break;
274 return true;
278 bool SvxFontItem::operator==( const SfxPoolItem& rAttr ) const
280 assert(SfxPoolItem::operator==(rAttr));
282 const SvxFontItem& rItem = static_cast<const SvxFontItem&>(rAttr);
284 bool bRet = ( eFamily == rItem.eFamily &&
285 aFamilyName == rItem.aFamilyName &&
286 aStyleName == rItem.aStyleName );
288 if ( bRet )
290 if ( ePitch != rItem.ePitch || eTextEncoding != rItem.eTextEncoding )
292 bRet = false;
293 SAL_INFO( "editeng.items", "FontItem::operator==(): only pitch or rtl_TextEncoding different ");
296 return bRet;
299 SvxFontItem* SvxFontItem::Clone( SfxItemPool * ) const
301 return new SvxFontItem( *this );
304 bool SvxFontItem::GetPresentation
306 SfxItemPresentation /*ePres*/,
307 MapUnit /*eCoreUnit*/,
308 MapUnit /*ePresUnit*/,
309 OUString& rText, const IntlWrapper& /*rIntl*/
310 ) const
312 rText = aFamilyName;
313 return true;
317 void SvxFontItem::dumpAsXml(xmlTextWriterPtr pWriter) const
319 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxFontItem"));
320 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
321 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("familyName"), BAD_CAST(aFamilyName.toUtf8().getStr()));
322 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("styleName"), BAD_CAST(aStyleName.toUtf8().getStr()));
323 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("family"), BAD_CAST(OString::number(eFamily).getStr()));
324 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("pitch"), BAD_CAST(OString::number(ePitch).getStr()));
325 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("textEncoding"), BAD_CAST(OString::number(eTextEncoding).getStr()));
326 (void)xmlTextWriterEndElement(pWriter);
329 // class SvxPostureItem --------------------------------------------------
331 SvxPostureItem::SvxPostureItem( const FontItalic ePosture, const sal_uInt16 nId ) :
332 SfxEnumItem( nId, ePosture )
336 SvxPostureItem* SvxPostureItem::Clone( SfxItemPool * ) const
338 return new SvxPostureItem( *this );
341 sal_uInt16 SvxPostureItem::GetValueCount() const
343 return ITALIC_NORMAL + 1; // ITALIC_NONE also belongs here
347 bool SvxPostureItem::GetPresentation
349 SfxItemPresentation /*ePres*/,
350 MapUnit /*eCoreUnit*/,
351 MapUnit /*ePresUnit*/,
352 OUString& rText, const IntlWrapper& /*rIntl*/
353 ) const
355 rText = GetValueTextByPos( GetValue() );
356 return true;
360 OUString SvxPostureItem::GetValueTextByPos( sal_uInt16 nPos )
362 DBG_ASSERT( nPos <= sal_uInt16(ITALIC_NORMAL), "enum overflow!" );
364 FontItalic eItalic = static_cast<FontItalic>(nPos);
365 TranslateId pId;
367 switch ( eItalic )
369 case ITALIC_NONE: pId = RID_SVXITEMS_ITALIC_NONE; break;
370 case ITALIC_OBLIQUE: pId = RID_SVXITEMS_ITALIC_OBLIQUE; break;
371 case ITALIC_NORMAL: pId = RID_SVXITEMS_ITALIC_NORMAL; break;
372 default: ;//prevent warning
375 return pId ? EditResId(pId) : OUString();
378 bool SvxPostureItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
380 nMemberId &= ~CONVERT_TWIPS;
381 switch( nMemberId )
383 case MID_ITALIC:
384 rVal <<= GetBoolValue();
385 break;
386 case MID_POSTURE:
387 rVal <<= vcl::unohelper::ConvertFontSlant(GetValue());
388 break;
390 return true;
393 bool SvxPostureItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
395 nMemberId &= ~CONVERT_TWIPS;
396 switch( nMemberId )
398 case MID_ITALIC:
399 SetBoolValue(Any2Bool(rVal));
400 break;
401 case MID_POSTURE:
403 awt::FontSlant eSlant;
404 if(!(rVal >>= eSlant))
406 sal_Int32 nValue = 0;
407 if(!(rVal >>= nValue))
408 return false;
410 eSlant = static_cast<awt::FontSlant>(nValue);
412 SetValue(vcl::unohelper::ConvertFontSlant(eSlant));
415 return true;
418 bool SvxPostureItem::HasBoolValue() const
420 return true;
423 bool SvxPostureItem::GetBoolValue() const
425 return ( GetValue() >= ITALIC_OBLIQUE );
428 void SvxPostureItem::SetBoolValue( bool bVal )
430 SetValue( bVal ? ITALIC_NORMAL : ITALIC_NONE );
433 void SvxPostureItem::dumpAsXml(xmlTextWriterPtr pWriter) const
435 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxPostureItem"));
436 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("whichId"), "%d", Which());
437 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("value"), "%d", GetValue());
438 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr()));
439 (void)xmlTextWriterEndElement(pWriter);
442 // class SvxWeightItem ---------------------------------------------------
444 SvxWeightItem::SvxWeightItem( const FontWeight eWght, const sal_uInt16 nId ) :
445 SfxEnumItem( nId, eWght )
450 bool SvxWeightItem::HasBoolValue() const
452 return true;
456 bool SvxWeightItem::GetBoolValue() const
458 return GetValue() >= WEIGHT_BOLD;
462 void SvxWeightItem::SetBoolValue( bool bVal )
464 SetValue( bVal ? WEIGHT_BOLD : WEIGHT_NORMAL );
468 sal_uInt16 SvxWeightItem::GetValueCount() const
470 return WEIGHT_BLACK; // WEIGHT_DONTKNOW does not belong
473 SvxWeightItem* SvxWeightItem::Clone( SfxItemPool * ) const
475 return new SvxWeightItem( *this );
478 bool SvxWeightItem::GetPresentation
480 SfxItemPresentation /*ePres*/,
481 MapUnit /*eCoreUnit*/,
482 MapUnit /*ePresUnit*/,
483 OUString& rText, const IntlWrapper& /*rIntl*/
484 ) const
486 rText = GetValueTextByPos( GetValue() );
487 return true;
490 OUString SvxWeightItem::GetValueTextByPos( sal_uInt16 nPos )
492 static TranslateId RID_SVXITEMS_WEIGHTS[] =
494 RID_SVXITEMS_WEIGHT_DONTKNOW,
495 RID_SVXITEMS_WEIGHT_THIN,
496 RID_SVXITEMS_WEIGHT_ULTRALIGHT,
497 RID_SVXITEMS_WEIGHT_LIGHT,
498 RID_SVXITEMS_WEIGHT_SEMILIGHT,
499 RID_SVXITEMS_WEIGHT_NORMAL,
500 RID_SVXITEMS_WEIGHT_MEDIUM,
501 RID_SVXITEMS_WEIGHT_SEMIBOLD,
502 RID_SVXITEMS_WEIGHT_BOLD,
503 RID_SVXITEMS_WEIGHT_ULTRABOLD,
504 RID_SVXITEMS_WEIGHT_BLACK
507 static_assert(std::size(RID_SVXITEMS_WEIGHTS) - 1 == WEIGHT_BLACK, "must match");
508 assert(nPos <= sal_uInt16(WEIGHT_BLACK) && "enum overflow!" );
509 return EditResId(RID_SVXITEMS_WEIGHTS[nPos]);
512 bool SvxWeightItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
514 nMemberId &= ~CONVERT_TWIPS;
515 switch( nMemberId )
517 case MID_BOLD :
518 rVal <<= GetBoolValue();
519 break;
520 case MID_WEIGHT:
522 rVal <<= vcl::unohelper::ConvertFontWeight( GetValue() );
524 break;
526 return true;
529 bool SvxWeightItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
531 nMemberId &= ~CONVERT_TWIPS;
532 switch( nMemberId )
534 case MID_BOLD :
535 SetBoolValue(Any2Bool(rVal));
536 break;
537 case MID_WEIGHT:
539 double fValue = 0;
540 if(!(rVal >>= fValue))
542 sal_Int32 nValue = 0;
543 if(!(rVal >>= nValue))
544 return false;
545 fValue = static_cast<float>(nValue);
547 SetValue( vcl::unohelper::ConvertFontWeight(static_cast<float>(fValue)) );
549 break;
551 return true;
554 void SvxWeightItem::dumpAsXml(xmlTextWriterPtr pWriter) const
556 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxWeightItem"));
557 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("whichId"), "%d", Which());
558 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("value"), "%d", GetValue());
559 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr()));
560 (void)xmlTextWriterEndElement(pWriter);
563 // class SvxFontHeightItem -----------------------------------------------
565 SvxFontHeightItem::SvxFontHeightItem( const sal_uInt32 nSz,
566 const sal_uInt16 nPrp,
567 const sal_uInt16 nId ) :
568 SfxPoolItem( nId )
570 SetHeight( nSz,nPrp ); // calculate in percentage
573 SvxFontHeightItem* SvxFontHeightItem::Clone( SfxItemPool * ) const
575 return new SvxFontHeightItem( *this );
578 bool SvxFontHeightItem::operator==( const SfxPoolItem& rItem ) const
580 assert(SfxPoolItem::operator==(rItem));
581 return GetHeight() == static_cast<const SvxFontHeightItem&>(rItem).GetHeight() &&
582 GetProp() == static_cast<const SvxFontHeightItem&>(rItem).GetProp() &&
583 GetPropUnit() == static_cast<const SvxFontHeightItem&>(rItem).GetPropUnit();
586 bool SvxFontHeightItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
588 // In StarOne is the uno::Any always 1/100mm. Through the MemberId it is
589 // controlled if the value in the Item should be 1/100mm or Twips.
591 bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
592 nMemberId &= ~CONVERT_TWIPS;
593 switch( nMemberId )
595 case 0:
597 css::frame::status::FontHeight aFontHeight;
599 // Point (i.e. Twips) is asked for, thus re-calculate if
600 // CONVERT_TWIPS is not set.
601 if( bConvert )
603 aFontHeight.Height = o3tl::convert<double>(nHeight, o3tl::Length::twip, o3tl::Length::pt);
605 else
607 double fPoints = o3tl::convert<double>(nHeight, o3tl::Length::mm100, o3tl::Length::pt);
608 aFontHeight.Height = rtl::math::round(fPoints, 1);
611 aFontHeight.Prop = MapUnit::MapRelative == ePropUnit ? nProp : 100;
613 float fRet = nProp;
614 switch( ePropUnit )
616 case MapUnit::MapRelative:
617 fRet = 0.;
618 break;
619 case MapUnit::Map100thMM:
620 fRet = o3tl::convert(fRet, o3tl::Length::mm100, o3tl::Length::pt);
621 break;
622 case MapUnit::MapPoint:
624 break;
625 case MapUnit::MapTwip:
626 fRet = o3tl::convert(fRet, o3tl::Length::twip, o3tl::Length::pt);
627 break;
628 default: ;//prevent warning
630 aFontHeight.Diff = fRet;
631 rVal <<= aFontHeight;
633 break;
634 case MID_FONTHEIGHT:
636 // Point (i.e. Twips) is asked for, thus re-calculate if
637 // CONVERT_TWIPS is not set.
638 if( bConvert )
640 rVal <<= static_cast<float>(o3tl::convert<double>(nHeight, o3tl::Length::twip, o3tl::Length::pt));
642 else
644 double fPoints = o3tl::convert<double>(nHeight, o3tl::Length::mm100, o3tl::Length::pt);
645 rVal <<= static_cast<float>(::rtl::math::round(fPoints, 1));
648 break;
649 case MID_FONTHEIGHT_PROP:
650 rVal <<= static_cast<sal_Int16>(MapUnit::MapRelative == ePropUnit ? nProp : 100);
651 break;
652 case MID_FONTHEIGHT_DIFF:
654 float fRet = nProp;
655 switch( ePropUnit )
657 case MapUnit::MapRelative:
658 fRet = 0.;
659 break;
660 case MapUnit::Map100thMM:
661 fRet = o3tl::convert(fRet, o3tl::Length::mm100, o3tl::Length::pt);
662 break;
663 case MapUnit::MapPoint:
665 break;
666 case MapUnit::MapTwip:
667 fRet = o3tl::convert(fRet, o3tl::Length::twip, o3tl::Length::pt);
668 break;
669 default: ;//prevent warning
671 rVal <<= fRet;
673 break;
675 return true;
678 // Try to reconstruct the original height input value from the modified height
679 // and the prop data; this seems somewhat futile given the various ways how the
680 // modified height is calculated (with and without conversion between twips and
681 // 100th mm; with an additional eCoreMetric input in one of the SetHeight
682 // overloads), and indeed known to occasionally produce nRet values that would
683 // be negative, so just guard against negative results here and throw the hands
684 // up in despair:
685 static sal_uInt32 lcl_GetRealHeight_Impl(sal_uInt32 nHeight, sal_uInt16 nProp, MapUnit eProp, bool bCoreInTwip)
687 sal_uInt32 nRet = nHeight;
688 short nDiff = 0;
689 switch( eProp )
691 case MapUnit::MapRelative:
692 if (nProp)
694 nRet *= 100;
695 nRet /= nProp;
697 break;
698 case MapUnit::MapPoint:
700 short nTemp = static_cast<short>(nProp);
701 nDiff = nTemp * 20;
702 if(!bCoreInTwip)
703 nDiff = static_cast<short>(convertTwipToMm100(static_cast<tools::Long>(nDiff)));
704 break;
706 case MapUnit::Map100thMM:
707 //then the core is surely also in 1/100 mm
708 nDiff = static_cast<short>(nProp);
709 break;
710 case MapUnit::MapTwip:
711 // Here surely TWIP
712 nDiff = static_cast<short>(nProp);
713 break;
714 default:
715 break;
717 nRet = (nDiff < 0 || nRet >= o3tl::make_unsigned(nDiff))
718 ? nRet - nDiff : 0;
719 //TODO: overflow in case nDiff < 0 and nRet - nDiff > SAL_MAX_UINT32
721 return nRet;
724 bool SvxFontHeightItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
726 bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
727 nMemberId &= ~CONVERT_TWIPS;
728 switch( nMemberId )
730 case 0:
732 css::frame::status::FontHeight aFontHeight;
733 if ( rVal >>= aFontHeight )
735 // Height
736 ePropUnit = MapUnit::MapRelative;
737 nProp = 100;
738 double fPoint = aFontHeight.Height;
739 if( fPoint < 0. || fPoint > 10000. )
740 return false;
742 nHeight = static_cast<tools::Long>( fPoint * 20.0 + 0.5 ); // Twips
743 if (!bConvert)
744 nHeight = convertTwipToMm100(nHeight); // Convert, if the item contains 1/100mm
746 nProp = aFontHeight.Prop;
748 else
749 return false;
751 break;
752 case MID_FONTHEIGHT:
754 ePropUnit = MapUnit::MapRelative;
755 nProp = 100;
756 double fPoint = 0;
757 if(!(rVal >>= fPoint))
759 sal_Int32 nValue = 0;
760 if(!(rVal >>= nValue))
761 return false;
762 fPoint = static_cast<float>(nValue);
765 if (fPoint < 0. || fPoint > 10000.)
766 return false;
767 static bool bFuzzing = utl::ConfigManager::IsFuzzing();
768 if (bFuzzing && fPoint > 240)
770 SAL_WARN("editeng.items", "SvxFontHeightItem ignoring font size of " << fPoint << " for performance");
771 return false;
774 nHeight = static_cast<tools::Long>( fPoint * 20.0 + 0.5 ); // Twips
775 if (!bConvert)
776 nHeight = convertTwipToMm100(nHeight); // Convert, if the item contains 1/100mm
778 break;
779 case MID_FONTHEIGHT_PROP:
781 sal_Int16 nNew = sal_Int16();
782 if(!(rVal >>= nNew))
783 return true;
785 nHeight = lcl_GetRealHeight_Impl(nHeight, nProp, ePropUnit, bConvert);
787 nHeight *= nNew;
788 nHeight /= 100;
789 nProp = nNew;
790 ePropUnit = MapUnit::MapRelative;
792 break;
793 case MID_FONTHEIGHT_DIFF:
795 nHeight = lcl_GetRealHeight_Impl(nHeight, nProp, ePropUnit, bConvert);
796 float fValue = 0;
797 if(!(rVal >>= fValue))
799 sal_Int32 nValue = 0;
800 if(!(rVal >>= nValue))
801 return false;
802 fValue = static_cast<float>(nValue);
804 sal_Int16 nCoreDiffValue = static_cast<sal_Int16>(fValue * 20.);
805 nHeight += bConvert ? nCoreDiffValue : convertTwipToMm100(nCoreDiffValue);
806 nProp = static_cast<sal_uInt16>(static_cast<sal_Int16>(fValue));
807 ePropUnit = MapUnit::MapPoint;
809 break;
811 return true;
815 bool SvxFontHeightItem::GetPresentation
817 SfxItemPresentation /*ePres*/,
818 MapUnit eCoreUnit,
819 MapUnit /*ePresUnit*/,
820 OUString& rText, const IntlWrapper& rIntl
821 ) const
823 if( MapUnit::MapRelative != ePropUnit )
825 rText = OUString::number( static_cast<short>(nProp) ) +
826 " " + EditResId( GetMetricId( ePropUnit ) );
827 if( 0 <= static_cast<short>(nProp) )
828 rText = "+" + rText;
830 else if( 100 == nProp )
832 rText = GetMetricText( static_cast<tools::Long>(nHeight),
833 eCoreUnit, MapUnit::MapPoint, &rIntl ) +
834 " " + EditResId(GetMetricId(MapUnit::MapPoint));
836 else
837 rText = OUString::number( nProp ) + "%";
838 return true;
842 void SvxFontHeightItem::ScaleMetrics( tools::Long nMult, tools::Long nDiv )
844 nHeight = static_cast<sal_uInt32>(BigInt::Scale( nHeight, nMult, nDiv ));
848 bool SvxFontHeightItem::HasMetrics() const
850 return true;
853 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight, const sal_uInt16 nNewProp,
854 MapUnit eUnit )
856 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
858 if( MapUnit::MapRelative != eUnit )
859 nHeight = nNewHeight + ::ItemToControl( short(nNewProp), eUnit,
860 FieldUnit::TWIP );
861 else if( 100 != nNewProp )
862 nHeight = sal_uInt32(( nNewHeight * nNewProp ) / 100 );
863 else
864 nHeight = nNewHeight;
866 nProp = nNewProp;
867 ePropUnit = eUnit;
870 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight, sal_uInt16 nNewProp,
871 MapUnit eMetric, MapUnit eCoreMetric )
873 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
875 if( MapUnit::MapRelative != eMetric )
876 nHeight = nNewHeight +
877 ::ControlToItem( ::ItemToControl(static_cast<short>(nNewProp), eMetric,
878 FieldUnit::TWIP ), FieldUnit::TWIP,
879 eCoreMetric );
880 else if( 100 != nNewProp )
881 nHeight = sal_uInt32(( nNewHeight * nNewProp ) / 100 );
882 else
883 nHeight = nNewHeight;
885 nProp = nNewProp;
886 ePropUnit = eMetric;
889 void SvxFontHeightItem::dumpAsXml(xmlTextWriterPtr pWriter) const
891 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxFontHeightItem"));
892 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
893 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("height"), BAD_CAST(OString::number(nHeight).getStr()));
894 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("prop"), BAD_CAST(OString::number(nProp).getStr()));
895 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("propUnit"), BAD_CAST(OString::number(static_cast<int>(ePropUnit)).getStr()));
896 (void)xmlTextWriterEndElement(pWriter);
899 // class SvxTextLineItem ------------------------------------------------
901 SvxTextLineItem::SvxTextLineItem( const FontLineStyle eSt, const sal_uInt16 nId )
902 : SfxEnumItem(nId, eSt)
903 , maColor(COL_TRANSPARENT)
908 bool SvxTextLineItem::HasBoolValue() const
910 return true;
914 bool SvxTextLineItem::GetBoolValue() const
916 return GetValue() != LINESTYLE_NONE;
920 void SvxTextLineItem::SetBoolValue( bool bVal )
922 SetValue( bVal ? LINESTYLE_SINGLE : LINESTYLE_NONE );
925 SvxTextLineItem* SvxTextLineItem::Clone( SfxItemPool * ) const
927 return new SvxTextLineItem( *this );
930 sal_uInt16 SvxTextLineItem::GetValueCount() const
932 return LINESTYLE_DOTTED + 1; // LINESTYLE_NONE also belongs here
936 bool SvxTextLineItem::GetPresentation
938 SfxItemPresentation /*ePres*/,
939 MapUnit /*eCoreUnit*/,
940 MapUnit /*ePresUnit*/,
941 OUString& rText, const IntlWrapper& /*rIntl*/
942 ) const
944 rText = GetValueTextByPos( GetValue() );
945 if( !maColor.IsTransparent() )
946 rText += cpDelim + ::GetColorString(maColor);
947 return true;
951 OUString SvxTextLineItem::GetValueTextByPos( sal_uInt16 /*nPos*/ ) const
953 OSL_FAIL("SvxTextLineItem::GetValueTextByPos: Pure virtual method");
954 return OUString();
957 bool SvxTextLineItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
959 nMemberId &= ~CONVERT_TWIPS;
960 switch(nMemberId)
962 case MID_TEXTLINED:
963 rVal <<= GetBoolValue();
964 break;
965 case MID_TL_STYLE:
966 rVal <<= static_cast<sal_Int16>(GetValue());
967 break;
968 case MID_TL_COLOR:
969 rVal <<= maColor;
970 break;
971 case MID_TL_COMPLEX_COLOR:
973 auto xComplexColor = model::color::createXComplexColor(maComplexColor);
974 rVal <<= xComplexColor;
975 break;
977 case MID_TL_HASCOLOR:
978 rVal <<= maColor.GetAlpha() == 255;
979 break;
981 return true;
984 bool SvxTextLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
986 nMemberId &= ~CONVERT_TWIPS;
987 bool bRet = true;
988 switch(nMemberId)
990 case MID_TEXTLINED:
991 SetBoolValue(Any2Bool(rVal));
992 break;
993 case MID_TL_STYLE:
995 sal_Int32 nValue = 0;
996 if(!(rVal >>= nValue))
997 bRet = false;
998 else
999 SetValue(static_cast<FontLineStyle>(nValue));
1001 break;
1002 case MID_TL_COLOR:
1004 Color nCol;
1005 if( !( rVal >>= nCol ) )
1006 bRet = false;
1007 else
1009 // Keep transparence, because it contains the information
1010 // whether the font color or the stored color should be used
1011 sal_uInt8 nAlpha = maColor.GetAlpha();
1012 maColor = nCol;
1013 maColor.SetAlpha( nAlpha );
1016 break;
1017 case MID_TL_COMPLEX_COLOR:
1019 css::uno::Reference<css::util::XComplexColor> xComplexColor;
1020 if (!(rVal >>= xComplexColor))
1021 return false;
1023 if (xComplexColor.is())
1024 maComplexColor = model::color::getFromXComplexColor(xComplexColor);
1026 break;
1027 case MID_TL_HASCOLOR:
1028 maColor.SetAlpha( Any2Bool( rVal ) ? 255 : 0 );
1029 break;
1031 return bRet;
1034 bool SvxTextLineItem::operator==( const SfxPoolItem& rItem ) const
1036 return SfxEnumItem::operator==( rItem ) &&
1037 maColor == static_cast<const SvxTextLineItem&>(rItem).maColor &&
1038 maComplexColor == static_cast<const SvxTextLineItem&>(rItem).maComplexColor;
1041 // class SvxUnderlineItem ------------------------------------------------
1044 SvxUnderlineItem::SvxUnderlineItem( const FontLineStyle eSt, const sal_uInt16 nId )
1045 : SvxTextLineItem( eSt, nId )
1049 SvxUnderlineItem* SvxUnderlineItem::Clone( SfxItemPool * ) const
1051 return new SvxUnderlineItem( *this );
1054 OUString SvxUnderlineItem::GetValueTextByPos( sal_uInt16 nPos ) const
1056 static TranslateId RID_SVXITEMS_UL[] =
1058 RID_SVXITEMS_UL_NONE,
1059 RID_SVXITEMS_UL_SINGLE,
1060 RID_SVXITEMS_UL_DOUBLE,
1061 RID_SVXITEMS_UL_DOTTED,
1062 RID_SVXITEMS_UL_DONTKNOW,
1063 RID_SVXITEMS_UL_DASH,
1064 RID_SVXITEMS_UL_LONGDASH,
1065 RID_SVXITEMS_UL_DASHDOT,
1066 RID_SVXITEMS_UL_DASHDOTDOT,
1067 RID_SVXITEMS_UL_SMALLWAVE,
1068 RID_SVXITEMS_UL_WAVE,
1069 RID_SVXITEMS_UL_DOUBLEWAVE,
1070 RID_SVXITEMS_UL_BOLD,
1071 RID_SVXITEMS_UL_BOLDDOTTED,
1072 RID_SVXITEMS_UL_BOLDDASH,
1073 RID_SVXITEMS_UL_BOLDLONGDASH,
1074 RID_SVXITEMS_UL_BOLDDASHDOT,
1075 RID_SVXITEMS_UL_BOLDDASHDOTDOT,
1076 RID_SVXITEMS_UL_BOLDWAVE
1078 static_assert(std::size(RID_SVXITEMS_UL) - 1 == LINESTYLE_BOLDWAVE, "must match");
1079 assert(nPos <= sal_uInt16(LINESTYLE_BOLDWAVE) && "enum overflow!");
1080 return EditResId(RID_SVXITEMS_UL[nPos]);
1083 // class SvxOverlineItem ------------------------------------------------
1085 SvxOverlineItem::SvxOverlineItem( const FontLineStyle eSt, const sal_uInt16 nId )
1086 : SvxTextLineItem( eSt, nId )
1090 SvxOverlineItem* SvxOverlineItem::Clone( SfxItemPool * ) const
1092 return new SvxOverlineItem( *this );
1095 OUString SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos ) const
1097 static TranslateId RID_SVXITEMS_OL[] =
1099 RID_SVXITEMS_OL_NONE,
1100 RID_SVXITEMS_OL_SINGLE,
1101 RID_SVXITEMS_OL_DOUBLE,
1102 RID_SVXITEMS_OL_DOTTED,
1103 RID_SVXITEMS_OL_DONTKNOW,
1104 RID_SVXITEMS_OL_DASH,
1105 RID_SVXITEMS_OL_LONGDASH,
1106 RID_SVXITEMS_OL_DASHDOT,
1107 RID_SVXITEMS_OL_DASHDOTDOT,
1108 RID_SVXITEMS_OL_SMALLWAVE,
1109 RID_SVXITEMS_OL_WAVE,
1110 RID_SVXITEMS_OL_DOUBLEWAVE,
1111 RID_SVXITEMS_OL_BOLD,
1112 RID_SVXITEMS_OL_BOLDDOTTED,
1113 RID_SVXITEMS_OL_BOLDDASH,
1114 RID_SVXITEMS_OL_BOLDLONGDASH,
1115 RID_SVXITEMS_OL_BOLDDASHDOT,
1116 RID_SVXITEMS_OL_BOLDDASHDOTDOT,
1117 RID_SVXITEMS_OL_BOLDWAVE
1119 static_assert(std::size(RID_SVXITEMS_OL) - 1 == LINESTYLE_BOLDWAVE, "must match");
1120 assert(nPos <= sal_uInt16(LINESTYLE_BOLDWAVE) && "enum overflow!");
1121 return EditResId(RID_SVXITEMS_OL[nPos]);
1124 // class SvxCrossedOutItem -----------------------------------------------
1126 SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt, const sal_uInt16 nId )
1127 : SfxEnumItem( nId, eSt )
1132 bool SvxCrossedOutItem::HasBoolValue() const
1134 return true;
1138 bool SvxCrossedOutItem::GetBoolValue() const
1140 return GetValue() != STRIKEOUT_NONE;
1144 void SvxCrossedOutItem::SetBoolValue( bool bVal )
1146 SetValue( bVal ? STRIKEOUT_SINGLE : STRIKEOUT_NONE );
1150 sal_uInt16 SvxCrossedOutItem::GetValueCount() const
1152 return STRIKEOUT_DOUBLE + 1; // STRIKEOUT_NONE belongs also here
1155 SvxCrossedOutItem* SvxCrossedOutItem::Clone( SfxItemPool * ) const
1157 return new SvxCrossedOutItem( *this );
1160 bool SvxCrossedOutItem::GetPresentation
1162 SfxItemPresentation /*ePres*/,
1163 MapUnit /*eCoreUnit*/,
1164 MapUnit /*ePresUnit*/,
1165 OUString& rText, const IntlWrapper& /*rIntl*/
1166 ) const
1168 rText = GetValueTextByPos( GetValue() );
1169 return true;
1172 OUString SvxCrossedOutItem::GetValueTextByPos( sal_uInt16 nPos )
1174 static TranslateId RID_SVXITEMS_STRIKEOUT[] =
1176 RID_SVXITEMS_STRIKEOUT_NONE,
1177 RID_SVXITEMS_STRIKEOUT_SINGLE,
1178 RID_SVXITEMS_STRIKEOUT_DOUBLE,
1179 RID_SVXITEMS_STRIKEOUT_DONTKNOW,
1180 RID_SVXITEMS_STRIKEOUT_BOLD,
1181 RID_SVXITEMS_STRIKEOUT_SLASH,
1182 RID_SVXITEMS_STRIKEOUT_X
1184 static_assert(std::size(RID_SVXITEMS_STRIKEOUT) - 1 == STRIKEOUT_X, "must match");
1185 assert(nPos <= sal_uInt16(STRIKEOUT_X) && "enum overflow!");
1186 return EditResId(RID_SVXITEMS_STRIKEOUT[nPos]);
1189 bool SvxCrossedOutItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1191 nMemberId &= ~CONVERT_TWIPS;
1192 switch(nMemberId)
1194 case MID_CROSSED_OUT:
1195 rVal <<= GetBoolValue();
1196 break;
1197 case MID_CROSS_OUT:
1198 rVal <<= static_cast<sal_Int16>(GetValue());
1199 break;
1201 return true;
1204 bool SvxCrossedOutItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1206 nMemberId &= ~CONVERT_TWIPS;
1207 switch(nMemberId)
1209 case MID_CROSSED_OUT:
1210 SetBoolValue(Any2Bool(rVal));
1211 break;
1212 case MID_CROSS_OUT:
1214 sal_Int32 nValue = 0;
1215 if(!(rVal >>= nValue))
1216 return false;
1217 SetValue(static_cast<FontStrikeout>(nValue));
1219 break;
1221 return true;
1223 // class SvxShadowedItem -------------------------------------------------
1225 SvxShadowedItem::SvxShadowedItem( const bool bShadowed, const sal_uInt16 nId ) :
1226 SfxBoolItem( nId, bShadowed )
1230 SvxShadowedItem* SvxShadowedItem::Clone( SfxItemPool * ) const
1232 return new SvxShadowedItem( *this );
1235 bool SvxShadowedItem::GetPresentation
1237 SfxItemPresentation /*ePres*/,
1238 MapUnit /*eCoreUnit*/,
1239 MapUnit /*ePresUnit*/,
1240 OUString& rText, const IntlWrapper& /*rIntl*/
1241 ) const
1243 TranslateId pId = RID_SVXITEMS_SHADOWED_FALSE;
1245 if ( GetValue() )
1246 pId = RID_SVXITEMS_SHADOWED_TRUE;
1247 rText = EditResId(pId);
1248 return true;
1251 // class SvxAutoKernItem -------------------------------------------------
1253 SvxAutoKernItem::SvxAutoKernItem( const bool bAutoKern, const sal_uInt16 nId ) :
1254 SfxBoolItem( nId, bAutoKern )
1258 SvxAutoKernItem* SvxAutoKernItem::Clone( SfxItemPool * ) const
1260 return new SvxAutoKernItem( *this );
1263 bool SvxAutoKernItem::GetPresentation
1265 SfxItemPresentation /*ePres*/,
1266 MapUnit /*eCoreUnit*/,
1267 MapUnit /*ePresUnit*/,
1268 OUString& rText, const IntlWrapper& /*rIntl*/
1269 ) const
1271 TranslateId pId = RID_SVXITEMS_AUTOKERN_FALSE;
1273 if ( GetValue() )
1274 pId = RID_SVXITEMS_AUTOKERN_TRUE;
1275 rText = EditResId(pId);
1276 return true;
1279 // class SvxWordLineModeItem ---------------------------------------------
1281 SvxWordLineModeItem::SvxWordLineModeItem( const bool bWordLineMode,
1282 const sal_uInt16 nId ) :
1283 SfxBoolItem( nId, bWordLineMode )
1287 SvxWordLineModeItem* SvxWordLineModeItem::Clone( SfxItemPool * ) const
1289 return new SvxWordLineModeItem( *this );
1292 bool SvxWordLineModeItem::GetPresentation
1294 SfxItemPresentation /*ePres*/,
1295 MapUnit /*eCoreUnit*/,
1296 MapUnit /*ePresUnit*/,
1297 OUString& rText, const IntlWrapper& /*rIntl*/
1298 ) const
1300 TranslateId pId = RID_SVXITEMS_WORDLINE_FALSE;
1302 if ( GetValue() )
1303 pId = RID_SVXITEMS_WORDLINE_TRUE;
1304 rText = EditResId(pId);
1305 return true;
1308 // class SvxContourItem --------------------------------------------------
1310 SvxContourItem::SvxContourItem( const bool bContoured, const sal_uInt16 nId ) :
1311 SfxBoolItem( nId, bContoured )
1315 SvxContourItem* SvxContourItem::Clone( SfxItemPool * ) const
1317 return new SvxContourItem( *this );
1320 bool SvxContourItem::GetPresentation
1322 SfxItemPresentation /*ePres*/,
1323 MapUnit /*eCoreUnit*/,
1324 MapUnit /*ePresUnit*/,
1325 OUString& rText, const IntlWrapper& /*rIntl*/
1326 ) const
1328 TranslateId pId = RID_SVXITEMS_CONTOUR_FALSE;
1330 if ( GetValue() )
1331 pId = RID_SVXITEMS_CONTOUR_TRUE;
1332 rText = EditResId(pId);
1333 return true;
1336 // class SvxColorItem ----------------------------------------------------
1337 SvxColorItem::SvxColorItem( const sal_uInt16 nId ) :
1338 SfxPoolItem(nId),
1339 mColor( COL_BLACK )
1343 SvxColorItem::SvxColorItem( const Color& rCol, const sal_uInt16 nId ) :
1344 SfxPoolItem( nId ),
1345 mColor( rCol )
1349 SvxColorItem::SvxColorItem(Color const& rColor, model::ComplexColor const& rComplexColor, const sal_uInt16 nId)
1350 : SfxPoolItem(nId)
1351 , mColor(rColor)
1352 , maComplexColor(rComplexColor)
1356 SvxColorItem::~SvxColorItem()
1360 bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const
1362 assert(SfxPoolItem::operator==(rAttr));
1363 const SvxColorItem& rColorItem = static_cast<const SvxColorItem&>(rAttr);
1365 return mColor == rColorItem.mColor &&
1366 maComplexColor == rColorItem.maComplexColor;
1369 bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1371 nMemberId &= ~CONVERT_TWIPS;
1372 switch (nMemberId)
1374 case MID_COLOR_ALPHA:
1376 auto fTransparency = static_cast<double>(255 - mColor.GetAlpha()) * 100 / 255;
1377 rVal <<= static_cast<sal_Int16>(basegfx::fround(fTransparency));
1378 break;
1380 case MID_GRAPHIC_TRANSPARENT:
1382 rVal <<= mColor.GetAlpha() == 0;
1383 break;
1385 case MID_COLOR_THEME_INDEX:
1387 rVal <<= sal_Int16(maComplexColor.getThemeColorType());
1388 break;
1390 case MID_COLOR_TINT_OR_SHADE:
1392 sal_Int16 nValue = 0;
1393 for (auto const& rTransform : maComplexColor.getTransformations())
1395 if (rTransform.meType == model::TransformationType::Tint)
1396 nValue = rTransform.mnValue;
1397 else if (rTransform.meType == model::TransformationType::Shade)
1398 nValue = -rTransform.mnValue;
1400 rVal <<= nValue;
1401 break;
1403 case MID_COLOR_LUM_MOD:
1405 sal_Int16 nValue = 10000;
1406 for (auto const& rTransform : maComplexColor.getTransformations())
1408 if (rTransform.meType == model::TransformationType::LumMod)
1409 nValue = rTransform.mnValue;
1411 rVal <<= nValue;
1412 break;
1414 case MID_COLOR_LUM_OFF:
1416 sal_Int16 nValue = 0;
1417 for (auto const& rTransform : maComplexColor.getTransformations())
1419 if (rTransform.meType == model::TransformationType::LumOff)
1420 nValue = rTransform.mnValue;
1422 rVal <<= nValue;
1423 break;
1425 case MID_COMPLEX_COLOR_JSON:
1427 rVal <<= OStringToOUString(model::color::convertToJSON(maComplexColor), RTL_TEXTENCODING_UTF8);
1428 break;
1430 case MID_COMPLEX_COLOR:
1432 auto xComplexColor = model::color::createXComplexColor(maComplexColor);
1433 rVal <<= xComplexColor;
1434 break;
1436 case MID_COLOR_RGB:
1437 default:
1439 rVal <<= mColor;
1440 break;
1443 return true;
1446 bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1448 nMemberId &= ~CONVERT_TWIPS;
1449 switch(nMemberId)
1451 case MID_COLOR_ALPHA:
1453 sal_Int16 nTransparency = 0;
1454 bool bRet = rVal >>= nTransparency;
1455 if (bRet)
1457 auto fTransparency = static_cast<double>(nTransparency) * 255 / 100;
1458 mColor.SetAlpha(255 - static_cast<sal_uInt8>(basegfx::fround(fTransparency)));
1460 return bRet;
1462 case MID_GRAPHIC_TRANSPARENT:
1464 mColor.SetAlpha( Any2Bool( rVal ) ? 0 : 255 );
1465 return true;
1467 case MID_COLOR_THEME_INDEX:
1469 sal_Int16 nIndex = -1;
1470 if (!(rVal >>= nIndex))
1471 return false;
1472 maComplexColor.setThemeColor(model::convertToThemeColorType(nIndex));
1474 break;
1475 case MID_COLOR_TINT_OR_SHADE:
1477 sal_Int16 nTintShade = 0;
1478 if (!(rVal >>= nTintShade))
1479 return false;
1481 maComplexColor.removeTransformations(model::TransformationType::Tint);
1482 maComplexColor.removeTransformations(model::TransformationType::Shade);
1484 if (nTintShade > 0)
1485 maComplexColor.addTransformation({model::TransformationType::Tint, nTintShade});
1486 else if (nTintShade < 0)
1488 sal_Int16 nShade = o3tl::narrowing<sal_Int16>(-nTintShade);
1489 maComplexColor.addTransformation({model::TransformationType::Shade, nShade});
1492 break;
1493 case MID_COLOR_LUM_MOD:
1495 sal_Int16 nLumMod = 10000;
1496 if (!(rVal >>= nLumMod))
1497 return false;
1498 maComplexColor.removeTransformations(model::TransformationType::LumMod);
1499 maComplexColor.addTransformation({model::TransformationType::LumMod, nLumMod});
1501 break;
1502 case MID_COLOR_LUM_OFF:
1504 sal_Int16 nLumOff = 0;
1505 if (!(rVal >>= nLumOff))
1506 return false;
1507 maComplexColor.removeTransformations(model::TransformationType::LumOff);
1508 maComplexColor.addTransformation({model::TransformationType::LumOff, nLumOff});
1510 break;
1511 case MID_COMPLEX_COLOR_JSON:
1513 OUString sComplexColorJson;
1514 if (!(rVal >>= sComplexColorJson))
1515 return false;
1517 if (sComplexColorJson.isEmpty())
1518 return false;
1520 OString aJSON = OUStringToOString(sComplexColorJson, RTL_TEXTENCODING_ASCII_US);
1521 if (!model::color::convertFromJSON(aJSON, maComplexColor))
1522 return false;
1524 break;
1525 case MID_COMPLEX_COLOR:
1527 css::uno::Reference<css::util::XComplexColor> xComplexColor;
1528 if (!(rVal >>= xComplexColor))
1529 return false;
1531 if (xComplexColor.is())
1532 maComplexColor = model::color::getFromXComplexColor(xComplexColor);
1534 break;
1535 case MID_COLOR_RGB:
1536 default:
1538 if (!(rVal >>= mColor))
1539 return false;
1541 break;
1543 return true;
1546 SvxColorItem* SvxColorItem::Clone( SfxItemPool * ) const
1548 return new SvxColorItem( *this );
1551 bool SvxColorItem::GetPresentation
1553 SfxItemPresentation /*ePres*/,
1554 MapUnit /*eCoreUnit*/,
1555 MapUnit /*ePresUnit*/,
1556 OUString& rText, const IntlWrapper& /*rIntl*/
1557 ) const
1559 rText = ::GetColorString( mColor );
1560 return true;
1563 void SvxColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
1565 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxColorItem"));
1566 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1568 std::stringstream ss;
1569 ss << mColor;
1570 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(ss.str().c_str()));
1572 OUString aStr;
1573 IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
1574 GetPresentation( SfxItemPresentation::Complete, MapUnit::Map100thMM, MapUnit::Map100thMM, aStr, aIntlWrapper);
1575 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), BAD_CAST(OUStringToOString(aStr, RTL_TEXTENCODING_UTF8).getStr()));
1577 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("complex-color"));
1579 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"),
1580 BAD_CAST(OString::number(sal_Int16(maComplexColor.getType())).getStr()));
1582 for (auto const& rTransform : maComplexColor.getTransformations())
1584 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("transformation"));
1585 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"),
1586 BAD_CAST(OString::number(sal_Int16(rTransform.meType)).getStr()));
1587 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
1588 BAD_CAST(OString::number(rTransform.mnValue).getStr()));
1589 (void)xmlTextWriterEndElement(pWriter);
1592 (void)xmlTextWriterEndElement(pWriter);
1594 (void)xmlTextWriterEndElement(pWriter);
1597 // class SvxKerningItem --------------------------------------------------
1599 SvxKerningItem::SvxKerningItem( const short nKern, const sal_uInt16 nId ) :
1600 SfxInt16Item( nId, nKern )
1604 SvxKerningItem* SvxKerningItem::Clone( SfxItemPool * ) const
1606 return new SvxKerningItem( *this );
1609 void SvxKerningItem::ScaleMetrics( tools::Long nMult, tools::Long nDiv )
1611 SetValue( static_cast<sal_Int16>(BigInt::Scale( GetValue(), nMult, nDiv )) );
1615 bool SvxKerningItem::HasMetrics() const
1617 return true;
1621 bool SvxKerningItem::GetPresentation
1623 SfxItemPresentation ePres,
1624 MapUnit eCoreUnit,
1625 MapUnit /*ePresUnit*/,
1626 OUString& rText, const IntlWrapper& rIntl
1627 ) const
1629 switch ( ePres )
1631 case SfxItemPresentation::Nameless:
1632 rText = GetMetricText( static_cast<tools::Long>(GetValue()), eCoreUnit, MapUnit::MapPoint, &rIntl ) +
1633 " " + EditResId(GetMetricId(MapUnit::MapPoint));
1634 return true;
1635 case SfxItemPresentation::Complete:
1637 rText = EditResId(RID_SVXITEMS_KERNING_COMPLETE);
1638 TranslateId pId;
1640 if ( GetValue() > 0 )
1641 pId = RID_SVXITEMS_KERNING_EXPANDED;
1642 else if ( GetValue() < 0 )
1643 pId = RID_SVXITEMS_KERNING_CONDENSED;
1645 if (pId)
1646 rText += EditResId(pId);
1647 rText += GetMetricText( static_cast<tools::Long>(GetValue()), eCoreUnit, MapUnit::MapPoint, &rIntl ) +
1648 " " + EditResId(GetMetricId(MapUnit::MapPoint));
1649 return true;
1651 default: ; //prevent warning
1653 return false;
1656 bool SvxKerningItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1658 sal_Int16 nVal = GetValue();
1659 if(nMemberId & CONVERT_TWIPS)
1660 nVal = static_cast<sal_Int16>(convertTwipToMm100(nVal));
1661 rVal <<= nVal;
1662 return true;
1665 bool SvxKerningItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId)
1667 sal_Int16 nVal = sal_Int16();
1668 if(!(rVal >>= nVal))
1669 return false;
1670 if(nMemberId & CONVERT_TWIPS)
1671 nVal = o3tl::toTwips(nVal, o3tl::Length::mm100);
1672 SetValue(nVal);
1673 return true;
1676 // class SvxCaseMapItem --------------------------------------------------
1678 SvxCaseMapItem::SvxCaseMapItem( const SvxCaseMap eMap, const sal_uInt16 nId ) :
1679 SfxEnumItem( nId, eMap )
1683 sal_uInt16 SvxCaseMapItem::GetValueCount() const
1685 return sal_uInt16(SvxCaseMap::End); // SvxCaseMap::SmallCaps + 1
1688 SvxCaseMapItem* SvxCaseMapItem::Clone( SfxItemPool * ) const
1690 return new SvxCaseMapItem( *this );
1693 bool SvxCaseMapItem::GetPresentation
1695 SfxItemPresentation /*ePres*/,
1696 MapUnit /*eCoreUnit*/,
1697 MapUnit /*ePresUnit*/,
1698 OUString& rText, const IntlWrapper& /*rIntl*/
1699 ) const
1701 rText = GetValueTextByPos( static_cast<sal_uInt16>(GetValue()) );
1702 return true;
1705 OUString SvxCaseMapItem::GetValueTextByPos( sal_uInt16 nPos )
1707 static TranslateId RID_SVXITEMS_CASEMAP[] =
1709 RID_SVXITEMS_CASEMAP_NONE,
1710 RID_SVXITEMS_CASEMAP_UPPERCASE,
1711 RID_SVXITEMS_CASEMAP_LOWERCASE,
1712 RID_SVXITEMS_CASEMAP_TITLE,
1713 RID_SVXITEMS_CASEMAP_SMALLCAPS
1716 static_assert(std::size(RID_SVXITEMS_CASEMAP) == size_t(SvxCaseMap::End), "must match");
1717 assert(nPos < sal_uInt16(SvxCaseMap::End) && "enum overflow!");
1718 return EditResId(RID_SVXITEMS_CASEMAP[nPos]);
1721 bool SvxCaseMapItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
1723 sal_Int16 nRet = style::CaseMap::NONE;
1724 switch( GetValue() )
1726 case SvxCaseMap::Uppercase : nRet = style::CaseMap::UPPERCASE; break;
1727 case SvxCaseMap::Lowercase : nRet = style::CaseMap::LOWERCASE; break;
1728 case SvxCaseMap::Capitalize : nRet = style::CaseMap::TITLE ; break;
1729 case SvxCaseMap::SmallCaps: nRet = style::CaseMap::SMALLCAPS; break;
1730 default: break;
1732 rVal <<= nRet;
1733 return true;
1736 bool SvxCaseMapItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
1738 sal_uInt16 nVal = sal_uInt16();
1739 if(!(rVal >>= nVal))
1740 return false;
1742 SvxCaseMap eVal;
1743 switch( nVal )
1745 case style::CaseMap::NONE : eVal = SvxCaseMap::NotMapped; break;
1746 case style::CaseMap::UPPERCASE: eVal = SvxCaseMap::Uppercase; break;
1747 case style::CaseMap::LOWERCASE: eVal = SvxCaseMap::Lowercase; break;
1748 case style::CaseMap::TITLE : eVal = SvxCaseMap::Capitalize; break;
1749 case style::CaseMap::SMALLCAPS: eVal = SvxCaseMap::SmallCaps; break;
1750 default: return false;
1752 SetValue(eVal);
1753 return true;
1756 // class SvxEscapementItem -----------------------------------------------
1758 SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId ) :
1759 SfxEnumItemInterface( nId ),
1761 nEsc ( 0 ),
1762 nProp ( 100 )
1767 SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape,
1768 const sal_uInt16 nId ) :
1769 SfxEnumItemInterface( nId ),
1770 nProp( 100 )
1772 SetEscapement( eEscape );
1773 if( nEsc )
1774 nProp = DFLT_ESC_PROP;
1778 SvxEscapementItem::SvxEscapementItem( const short _nEsc,
1779 const sal_uInt8 _nProp,
1780 const sal_uInt16 nId ) :
1781 SfxEnumItemInterface( nId ),
1782 nEsc ( _nEsc ),
1783 nProp ( _nProp )
1788 bool SvxEscapementItem::operator==( const SfxPoolItem& rAttr ) const
1790 assert(SfxPoolItem::operator==(rAttr));
1792 return( nEsc == static_cast<const SvxEscapementItem&>(rAttr).nEsc &&
1793 nProp == static_cast<const SvxEscapementItem&>(rAttr).nProp );
1796 SvxEscapementItem* SvxEscapementItem::Clone( SfxItemPool * ) const
1798 return new SvxEscapementItem( *this );
1801 sal_uInt16 SvxEscapementItem::GetValueCount() const
1803 return sal_uInt16(SvxEscapement::End); // SvxEscapement::Subscript + 1
1807 bool SvxEscapementItem::GetPresentation
1809 SfxItemPresentation /*ePres*/,
1810 MapUnit /*eCoreUnit*/,
1811 MapUnit /*ePresUnit*/,
1812 OUString& rText, const IntlWrapper& /*rIntl*/
1813 ) const
1815 rText = GetValueTextByPos( GetEnumValue() );
1817 if ( nEsc != 0 )
1819 if( DFLT_ESC_AUTO_SUPER == nEsc || DFLT_ESC_AUTO_SUB == nEsc )
1820 rText += EditResId(RID_SVXITEMS_ESCAPEMENT_AUTO);
1821 else
1822 rText += OUString::number( nEsc ) + "%";
1824 return true;
1827 OUString SvxEscapementItem::GetValueTextByPos( sal_uInt16 nPos )
1829 static TranslateId RID_SVXITEMS_ESCAPEMENT[] =
1831 RID_SVXITEMS_ESCAPEMENT_OFF,
1832 RID_SVXITEMS_ESCAPEMENT_SUPER,
1833 RID_SVXITEMS_ESCAPEMENT_SUB
1836 static_assert(std::size(RID_SVXITEMS_ESCAPEMENT) == size_t(SvxEscapement::End), "must match");
1837 assert(nPos < sal_uInt16(SvxEscapement::End) && "enum overflow!");
1838 return EditResId(RID_SVXITEMS_ESCAPEMENT[nPos]);
1841 sal_uInt16 SvxEscapementItem::GetEnumValue() const
1843 if ( nEsc < 0 )
1844 return sal_uInt16(SvxEscapement::Subscript);
1845 else if ( nEsc > 0 )
1846 return sal_uInt16(SvxEscapement::Superscript);
1847 return sal_uInt16(SvxEscapement::Off);
1851 void SvxEscapementItem::SetEnumValue( sal_uInt16 nVal )
1853 SetEscapement( static_cast<SvxEscapement>(nVal) );
1856 bool SvxEscapementItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1858 nMemberId &= ~CONVERT_TWIPS;
1859 switch(nMemberId)
1861 case MID_ESC:
1862 rVal <<= static_cast<sal_Int16>(nEsc);
1863 break;
1864 case MID_ESC_HEIGHT:
1865 rVal <<= static_cast<sal_Int8>(nProp);
1866 break;
1867 case MID_AUTO_ESC:
1868 rVal <<= (DFLT_ESC_AUTO_SUB == nEsc || DFLT_ESC_AUTO_SUPER == nEsc);
1869 break;
1871 return true;
1874 bool SvxEscapementItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1876 nMemberId &= ~CONVERT_TWIPS;
1877 switch(nMemberId)
1879 case MID_ESC:
1881 sal_Int16 nVal = sal_Int16();
1882 if( (rVal >>= nVal) && (std::abs(nVal) <= MAX_ESC_POS+1))
1883 nEsc = nVal;
1884 else
1885 return false;
1887 break;
1888 case MID_ESC_HEIGHT:
1890 sal_Int8 nVal = sal_Int8();
1891 if( (rVal >>= nVal) && (nVal <= 100))
1892 nProp = nVal;
1893 else
1894 return false;
1896 break;
1897 case MID_AUTO_ESC:
1899 bool bVal = Any2Bool(rVal);
1900 if(bVal)
1902 if(nEsc < 0)
1903 nEsc = DFLT_ESC_AUTO_SUB;
1904 else
1905 nEsc = DFLT_ESC_AUTO_SUPER;
1907 else
1908 if(DFLT_ESC_AUTO_SUPER == nEsc )
1909 --nEsc;
1910 else if(DFLT_ESC_AUTO_SUB == nEsc)
1911 ++nEsc;
1913 break;
1915 return true;
1918 // class SvxLanguageItem -------------------------------------------------
1920 SvxLanguageItem::SvxLanguageItem( const LanguageType eLang, const sal_uInt16 nId )
1921 : SvxLanguageItem_Base( nId , eLang )
1926 sal_uInt16 SvxLanguageItem::GetValueCount() const
1928 // #i50205# got rid of class International
1929 SAL_WARN( "editeng.items", "SvxLanguageItem::GetValueCount: supposed to return a count of what?");
1930 // Could be SvtLanguageTable::GetEntryCount() (all locales with resource string)?
1931 // Could be LocaleDataWrapper::getInstalledLanguageTypes() (all locales with locale data)?
1932 return 0;
1935 SvxLanguageItem* SvxLanguageItem::Clone( SfxItemPool * ) const
1937 return new SvxLanguageItem( *this );
1940 bool SvxLanguageItem::GetPresentation
1942 SfxItemPresentation /*ePres*/,
1943 MapUnit /*eCoreUnit*/,
1944 MapUnit /*ePresUnit*/,
1945 OUString& rText, const IntlWrapper& /*rIntl*/
1946 ) const
1948 rText = SvtLanguageTable::GetLanguageString( GetValue() );
1949 return true;
1952 bool SvxLanguageItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1954 nMemberId &= ~CONVERT_TWIPS;
1955 switch(nMemberId)
1957 case MID_LANG_INT: // for basic conversions!
1958 rVal <<= static_cast<sal_Int16>(static_cast<sal_uInt16>(GetValue()));
1959 break;
1960 case MID_LANG_LOCALE:
1961 lang::Locale aRet( LanguageTag::convertToLocale( GetValue(), false));
1962 rVal <<= aRet;
1963 break;
1965 return true;
1968 bool SvxLanguageItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1970 nMemberId &= ~CONVERT_TWIPS;
1971 switch(nMemberId)
1973 case MID_LANG_INT: // for basic conversions!
1975 sal_Int32 nValue = 0;
1976 if(!(rVal >>= nValue))
1977 return false;
1979 SetValue(LanguageType(nValue));
1981 break;
1982 case MID_LANG_LOCALE:
1984 lang::Locale aLocale;
1985 if(!(rVal >>= aLocale))
1986 return false;
1988 SetValue( LanguageTag::convertToLanguageType( aLocale, false));
1990 break;
1992 return true;
1995 // class SvxNoHyphenItem -------------------------------------------------
1997 SvxNoHyphenItem::SvxNoHyphenItem( const sal_uInt16 nId ) :
1998 SfxBoolItem( nId , true )
2002 SvxNoHyphenItem* SvxNoHyphenItem::Clone( SfxItemPool* ) const
2004 return new SvxNoHyphenItem( *this );
2007 bool SvxNoHyphenItem::GetPresentation
2009 SfxItemPresentation /*ePres*/,
2010 MapUnit /*eCoreUnit*/,
2011 MapUnit /*ePresUnit*/,
2012 OUString& rText, const IntlWrapper& /*rIntl*/
2013 ) const
2015 rText.clear();
2016 return false;
2020 * Dummy item for ToolBox controls:
2025 // class SvxBlinkItem -------------------------------------------------
2028 SvxBlinkItem::SvxBlinkItem( const bool bBlink, const sal_uInt16 nId ) :
2029 SfxBoolItem( nId, bBlink )
2033 SvxBlinkItem* SvxBlinkItem::Clone( SfxItemPool * ) const
2035 return new SvxBlinkItem( *this );
2038 bool SvxBlinkItem::GetPresentation
2040 SfxItemPresentation /*ePres*/,
2041 MapUnit /*eCoreUnit*/,
2042 MapUnit /*ePresUnit*/,
2043 OUString& rText, const IntlWrapper& /*rIntl*/
2044 ) const
2046 TranslateId pId = RID_SVXITEMS_BLINK_FALSE;
2048 if ( GetValue() )
2049 pId = RID_SVXITEMS_BLINK_TRUE;
2050 rText = EditResId(pId);
2051 return true;
2054 // class SvxEmphaisMarkItem ---------------------------------------------------
2056 SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue,
2057 TypedWhichId<SvxEmphasisMarkItem> nId )
2058 : SfxUInt16Item( nId, static_cast<sal_uInt16>(nValue) )
2062 SvxEmphasisMarkItem* SvxEmphasisMarkItem::Clone( SfxItemPool * ) const
2064 return new SvxEmphasisMarkItem( *this );
2067 bool SvxEmphasisMarkItem::GetPresentation
2069 SfxItemPresentation /*ePres*/,
2070 MapUnit /*eCoreUnit*/,
2071 MapUnit /*ePresUnit*/,
2072 OUString& rText,
2073 const IntlWrapper& /*rIntl*/
2074 ) const
2076 static TranslateId RID_SVXITEMS_EMPHASIS[] =
2078 RID_SVXITEMS_EMPHASIS_NONE_STYLE,
2079 RID_SVXITEMS_EMPHASIS_DOT_STYLE,
2080 RID_SVXITEMS_EMPHASIS_CIRCLE_STYLE,
2081 RID_SVXITEMS_EMPHASIS_DISC_STYLE,
2082 RID_SVXITEMS_EMPHASIS_ACCENT_STYLE
2085 FontEmphasisMark nVal = GetEmphasisMark();
2086 rText = EditResId(RID_SVXITEMS_EMPHASIS[
2087 static_cast<sal_uInt16>(static_cast<FontEmphasisMark>( nVal & FontEmphasisMark::Style ))]);
2088 TranslateId pId = ( FontEmphasisMark::PosAbove & nVal )
2089 ? RID_SVXITEMS_EMPHASIS_ABOVE_POS
2090 : ( FontEmphasisMark::PosBelow & nVal )
2091 ? RID_SVXITEMS_EMPHASIS_BELOW_POS
2092 : TranslateId();
2093 if( pId )
2094 rText += EditResId( pId );
2095 return true;
2098 bool SvxEmphasisMarkItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2100 nMemberId &= ~CONVERT_TWIPS;
2101 switch( nMemberId )
2103 case MID_EMPHASIS:
2105 FontEmphasisMark nValue = GetEmphasisMark();
2106 sal_Int16 nRet = 0;
2107 switch(nValue & FontEmphasisMark::Style)
2109 case FontEmphasisMark::NONE : nRet = FontEmphasis::NONE; break;
2110 case FontEmphasisMark::Dot : nRet = FontEmphasis::DOT_ABOVE; break;
2111 case FontEmphasisMark::Circle : nRet = FontEmphasis::CIRCLE_ABOVE; break;
2112 case FontEmphasisMark::Disc : nRet = FontEmphasis::DISK_ABOVE; break;
2113 case FontEmphasisMark::Accent : nRet = FontEmphasis::ACCENT_ABOVE; break;
2114 default: break;
2116 if(nRet && nValue & FontEmphasisMark::PosBelow)
2117 nRet += 10;
2118 rVal <<= nRet;
2120 break;
2122 return true;
2125 bool SvxEmphasisMarkItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2127 nMemberId &= ~CONVERT_TWIPS;
2128 switch( nMemberId )
2130 case MID_EMPHASIS:
2132 sal_Int32 nValue = -1;
2133 rVal >>= nValue;
2134 FontEmphasisMark nMark;
2135 switch(nValue)
2137 case FontEmphasis::NONE : nMark = FontEmphasisMark::NONE; break;
2138 case FontEmphasis::DOT_ABOVE : nMark = FontEmphasisMark::Dot|FontEmphasisMark::PosAbove; break;
2139 case FontEmphasis::CIRCLE_ABOVE: nMark = FontEmphasisMark::Circle|FontEmphasisMark::PosAbove; break;
2140 case FontEmphasis::DISK_ABOVE : nMark = FontEmphasisMark::Disc|FontEmphasisMark::PosAbove; break;
2141 case FontEmphasis::ACCENT_ABOVE: nMark = FontEmphasisMark::Accent|FontEmphasisMark::PosAbove; break;
2142 case FontEmphasis::DOT_BELOW : nMark = FontEmphasisMark::Dot|FontEmphasisMark::PosBelow; break;
2143 case FontEmphasis::CIRCLE_BELOW: nMark = FontEmphasisMark::Circle|FontEmphasisMark::PosBelow; break;
2144 case FontEmphasis::DISK_BELOW : nMark = FontEmphasisMark::Disc|FontEmphasisMark::PosBelow; break;
2145 case FontEmphasis::ACCENT_BELOW: nMark = FontEmphasisMark::Accent|FontEmphasisMark::PosBelow; break;
2146 default: return false;
2148 SetValue( static_cast<sal_Int16>(nMark) );
2150 break;
2152 return true;
2155 /*************************************************************************
2156 |* class SvxTwoLinesItem
2157 *************************************************************************/
2159 SvxTwoLinesItem::SvxTwoLinesItem( bool bFlag, sal_Unicode nStartBracket,
2160 sal_Unicode nEndBracket, sal_uInt16 nW )
2161 : SfxPoolItem( nW ),
2162 cStartBracket( nStartBracket ), cEndBracket( nEndBracket ), bOn( bFlag )
2166 SvxTwoLinesItem::~SvxTwoLinesItem()
2170 bool SvxTwoLinesItem::operator==( const SfxPoolItem& rAttr ) const
2172 assert(SfxPoolItem::operator==(rAttr));
2173 return bOn == static_cast<const SvxTwoLinesItem&>(rAttr).bOn &&
2174 cStartBracket == static_cast<const SvxTwoLinesItem&>(rAttr).cStartBracket &&
2175 cEndBracket == static_cast<const SvxTwoLinesItem&>(rAttr).cEndBracket;
2178 SvxTwoLinesItem* SvxTwoLinesItem::Clone( SfxItemPool* ) const
2180 return new SvxTwoLinesItem( *this );
2183 bool SvxTwoLinesItem::QueryValue( css::uno::Any& rVal,
2184 sal_uInt8 nMemberId ) const
2186 nMemberId &= ~CONVERT_TWIPS;
2187 bool bRet = true;
2188 switch( nMemberId )
2190 case MID_TWOLINES:
2191 rVal <<= bOn;
2192 break;
2193 case MID_START_BRACKET:
2195 OUString s;
2196 if( cStartBracket )
2197 s = OUString( cStartBracket );
2198 rVal <<= s;
2200 break;
2201 case MID_END_BRACKET:
2203 OUString s;
2204 if( cEndBracket )
2205 s = OUString( cEndBracket );
2206 rVal <<= s;
2208 break;
2209 default:
2210 bRet = false;
2211 break;
2213 return bRet;
2216 bool SvxTwoLinesItem::PutValue( const css::uno::Any& rVal,
2217 sal_uInt8 nMemberId )
2219 nMemberId &= ~CONVERT_TWIPS;
2220 bool bRet = false;
2221 OUString s;
2222 switch( nMemberId )
2224 case MID_TWOLINES:
2225 bOn = Any2Bool( rVal );
2226 bRet = true;
2227 break;
2228 case MID_START_BRACKET:
2229 if( rVal >>= s )
2231 cStartBracket = s.isEmpty() ? 0 : s[ 0 ];
2232 bRet = true;
2234 break;
2235 case MID_END_BRACKET:
2236 if( rVal >>= s )
2238 cEndBracket = s.isEmpty() ? 0 : s[ 0 ];
2239 bRet = true;
2241 break;
2243 return bRet;
2246 bool SvxTwoLinesItem::GetPresentation( SfxItemPresentation /*ePres*/,
2247 MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/,
2248 OUString &rText, const IntlWrapper& /*rIntl*/ ) const
2250 if( !GetValue() )
2251 rText = EditResId( RID_SVXITEMS_TWOLINES_OFF );
2252 else
2254 rText = EditResId( RID_SVXITEMS_TWOLINES );
2255 if( GetStartBracket() )
2256 rText = OUStringChar(GetStartBracket()) + rText;
2257 if( GetEndBracket() )
2258 rText += OUStringChar(GetEndBracket());
2260 return true;
2264 /*************************************************************************
2265 |* class SvxTextRotateItem
2266 *************************************************************************/
2268 SvxTextRotateItem::SvxTextRotateItem(Degree10 nValue, TypedWhichId<SvxTextRotateItem> nW)
2269 : SfxUInt16Item(nW, nValue.get())
2273 SvxTextRotateItem* SvxTextRotateItem::Clone(SfxItemPool*) const
2275 return new SvxTextRotateItem(*this);
2278 bool SvxTextRotateItem::GetPresentation(
2279 SfxItemPresentation /*ePres*/,
2280 MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/,
2281 OUString &rText, const IntlWrapper&) const
2283 if (!GetValue())
2284 rText = EditResId(RID_SVXITEMS_TEXTROTATE_OFF);
2285 else
2287 rText = EditResId(RID_SVXITEMS_TEXTROTATE);
2288 rText = rText.replaceFirst("$(ARG1)",
2289 OUString::number(toDegrees(GetValue())));
2291 return true;
2294 bool SvxTextRotateItem::QueryValue(css::uno::Any& rVal,
2295 sal_uInt8 nMemberId) const
2297 nMemberId &= ~CONVERT_TWIPS;
2298 bool bRet = true;
2299 switch (nMemberId)
2301 case MID_ROTATE:
2302 rVal <<= static_cast<sal_Int16>(GetValue());
2303 break;
2304 default:
2305 bRet = false;
2306 break;
2308 return bRet;
2311 bool SvxTextRotateItem::PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId)
2313 nMemberId &= ~CONVERT_TWIPS;
2314 bool bRet = true;
2315 switch (nMemberId)
2317 case MID_ROTATE:
2319 sal_Int16 nVal = 0;
2320 if ((rVal >>= nVal) && (0 == nVal || 900 == nVal || 2700 == nVal))
2321 SetValue(Degree10(nVal));
2322 else
2323 bRet = false;
2324 break;
2326 default:
2327 bRet = false;
2329 return bRet;
2332 void SvxTextRotateItem::dumpAsXml(xmlTextWriterPtr pWriter) const
2334 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxTextRotateItem"));
2335 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2336 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue().get()).getStr()));
2337 (void)xmlTextWriterEndElement(pWriter);
2341 /*************************************************************************
2342 |* class SvxCharRotateItem
2343 *************************************************************************/
2345 SvxCharRotateItem::SvxCharRotateItem( Degree10 nValue,
2346 bool bFitIntoLine,
2347 TypedWhichId<SvxCharRotateItem> nW )
2348 : SvxTextRotateItem(nValue, nW), bFitToLine( bFitIntoLine )
2352 SvxCharRotateItem* SvxCharRotateItem::Clone( SfxItemPool* ) const
2354 return new SvxCharRotateItem( *this );
2357 bool SvxCharRotateItem::GetPresentation(
2358 SfxItemPresentation /*ePres*/,
2359 MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/,
2360 OUString &rText, const IntlWrapper&) const
2362 if( !GetValue() )
2363 rText = EditResId( RID_SVXITEMS_CHARROTATE_OFF );
2364 else
2366 rText = EditResId( RID_SVXITEMS_CHARROTATE );
2367 rText = rText.replaceFirst( "$(ARG1)",
2368 OUString::number( toDegrees(GetValue()) ));
2369 if( IsFitToLine() )
2370 rText += EditResId( RID_SVXITEMS_CHARROTATE_FITLINE );
2372 return true;
2375 bool SvxCharRotateItem::QueryValue( css::uno::Any& rVal,
2376 sal_uInt8 nMemberId ) const
2378 bool bRet = true;
2379 switch(nMemberId & ~CONVERT_TWIPS)
2381 case MID_ROTATE:
2382 SvxTextRotateItem::QueryValue(rVal, nMemberId);
2383 break;
2384 case MID_FITTOLINE:
2385 rVal <<= IsFitToLine();
2386 break;
2387 default:
2388 bRet = false;
2389 break;
2391 return bRet;
2394 bool SvxCharRotateItem::PutValue( const css::uno::Any& rVal,
2395 sal_uInt8 nMemberId )
2397 bool bRet = true;
2398 switch(nMemberId & ~CONVERT_TWIPS)
2400 case MID_ROTATE:
2402 bRet = SvxTextRotateItem::PutValue(rVal, nMemberId);
2403 break;
2406 case MID_FITTOLINE:
2407 SetFitToLine( Any2Bool( rVal ) );
2408 break;
2409 default:
2410 bRet = false;
2412 return bRet;
2415 bool SvxCharRotateItem::operator==( const SfxPoolItem& rItem ) const
2417 assert(SfxPoolItem::operator==(rItem));
2418 return SvxTextRotateItem::operator==( rItem ) &&
2419 IsFitToLine() == static_cast<const SvxCharRotateItem&>(rItem).IsFitToLine();
2422 void SvxCharRotateItem::dumpAsXml(xmlTextWriterPtr pWriter) const
2424 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxCharRotateItem"));
2425 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
2426 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue().get()).getStr()));
2427 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("fitToLine"), BAD_CAST(OString::boolean(IsFitToLine()).getStr()));
2428 (void)xmlTextWriterEndElement(pWriter);
2431 /*************************************************************************
2432 |* class SvxCharScaleItem
2433 *************************************************************************/
2435 SvxCharScaleWidthItem::SvxCharScaleWidthItem( sal_uInt16 nValue,
2436 TypedWhichId<SvxCharScaleWidthItem> nW )
2437 : SfxUInt16Item( nW, nValue )
2441 SvxCharScaleWidthItem* SvxCharScaleWidthItem::Clone( SfxItemPool* ) const
2443 return new SvxCharScaleWidthItem( *this );
2446 bool SvxCharScaleWidthItem::GetPresentation(
2447 SfxItemPresentation /*ePres*/,
2448 MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/,
2449 OUString &rText, const IntlWrapper&) const
2451 if( !GetValue() )
2452 rText = EditResId( RID_SVXITEMS_CHARSCALE_OFF );
2453 else
2455 rText = EditResId( RID_SVXITEMS_CHARSCALE );
2456 rText = rText.replaceFirst( "$(ARG1)",
2457 OUString::number( GetValue() ));
2459 return true;
2462 bool SvxCharScaleWidthItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
2464 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
2465 // where we still want this to be a sal_Int16
2466 sal_Int16 nValue = sal_Int16();
2467 if (rVal >>= nValue)
2469 SetValue( static_cast<sal_uInt16>(nValue) );
2470 return true;
2473 SAL_WARN("editeng.items", "SvxCharScaleWidthItem::PutValue - Wrong type!" );
2474 return false;
2477 bool SvxCharScaleWidthItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
2479 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
2480 // where we still want this to be a sal_Int16
2481 rVal <<= static_cast<sal_Int16>(GetValue());
2482 return true;
2485 /*************************************************************************
2486 |* class SvxCharReliefItem
2487 *************************************************************************/
2489 SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue,
2490 const sal_uInt16 nId )
2491 : SfxEnumItem( nId, eValue )
2495 SvxCharReliefItem* SvxCharReliefItem::Clone( SfxItemPool * ) const
2497 return new SvxCharReliefItem( *this );
2500 static TranslateId RID_SVXITEMS_RELIEF[] =
2502 RID_SVXITEMS_RELIEF_NONE,
2503 RID_SVXITEMS_RELIEF_EMBOSSED,
2504 RID_SVXITEMS_RELIEF_ENGRAVED
2507 OUString SvxCharReliefItem::GetValueTextByPos(sal_uInt16 nPos)
2509 assert(nPos < std::size(RID_SVXITEMS_RELIEF) && "enum overflow");
2510 return EditResId(RID_SVXITEMS_RELIEF[nPos]);
2513 sal_uInt16 SvxCharReliefItem::GetValueCount() const
2515 return std::size(RID_SVXITEMS_RELIEF) - 1;
2518 bool SvxCharReliefItem::GetPresentation
2520 SfxItemPresentation /*ePres*/,
2521 MapUnit /*eCoreUnit*/,
2522 MapUnit /*ePresUnit*/,
2523 OUString& rText, const IntlWrapper& /*rIntl*/
2524 ) const
2526 rText = GetValueTextByPos( static_cast<sal_uInt16>(GetValue()) );
2527 return true;
2530 bool SvxCharReliefItem::PutValue( const css::uno::Any& rVal,
2531 sal_uInt8 nMemberId )
2533 nMemberId &= ~CONVERT_TWIPS;
2534 bool bRet = true;
2535 switch( nMemberId )
2537 case MID_RELIEF:
2539 sal_Int16 nVal = -1;
2540 rVal >>= nVal;
2541 if(nVal >= 0 && nVal <= sal_Int16(FontRelief::Engraved))
2542 SetValue( static_cast<FontRelief>(nVal) );
2543 else
2544 bRet = false;
2546 break;
2547 default:
2548 bRet = false;
2549 break;
2551 return bRet;
2554 bool SvxCharReliefItem::QueryValue( css::uno::Any& rVal,
2555 sal_uInt8 nMemberId ) const
2557 nMemberId &= ~CONVERT_TWIPS;
2558 bool bRet = true;
2559 switch( nMemberId )
2561 case MID_RELIEF:
2562 rVal <<= static_cast<sal_Int16>(GetValue());
2563 break;
2564 default:
2565 bRet = false;
2566 break;
2568 return bRet;
2571 /*************************************************************************
2572 |* class SvxScriptSetItem
2573 *************************************************************************/
2575 SvxScriptSetItem::SvxScriptSetItem( sal_uInt16 nSlotId, SfxItemPool& rPool )
2576 : SfxSetItem( nSlotId, SfxItemSet( rPool,
2577 svl::Items<SID_ATTR_CHAR_FONT, SID_ATTR_CHAR_FONT> ))
2579 sal_uInt16 nLatin, nAsian, nComplex;
2580 GetWhichIds( nLatin, nAsian, nComplex );
2581 GetItemSet().MergeRange( nLatin, nLatin );
2582 GetItemSet().MergeRange( nAsian, nAsian );
2583 GetItemSet().MergeRange( nComplex, nComplex );
2586 SvxScriptSetItem* SvxScriptSetItem::Clone( SfxItemPool * ) const
2588 SvxScriptSetItem* p = new SvxScriptSetItem( Which(), *GetItemSet().GetPool() );
2589 p->GetItemSet().Put( GetItemSet(), false );
2590 return p;
2593 const SfxPoolItem* SvxScriptSetItem::GetItemOfScriptSet(
2594 const SfxItemSet& rSet, sal_uInt16 nId )
2596 const SfxPoolItem* pI;
2597 SfxItemState eSt = rSet.GetItemState( nId, false, &pI );
2598 if( SfxItemState::SET != eSt )
2599 pI = SfxItemState::DEFAULT == eSt ? &rSet.Get( nId ) : nullptr;
2600 return pI;
2603 const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId, const SfxItemSet& rSet, SvtScriptType nScript )
2605 sal_uInt16 nLatin, nAsian, nComplex;
2606 GetWhichIds( nSlotId, rSet, nLatin, nAsian, nComplex );
2608 const SfxPoolItem *pRet, *pAsn, *pCmplx;
2609 if (nScript == SvtScriptType::ASIAN)
2611 pRet = GetItemOfScriptSet( rSet, nAsian );
2612 } else if (nScript == SvtScriptType::COMPLEX)
2614 pRet = GetItemOfScriptSet( rSet, nComplex );
2615 } else if (nScript == (SvtScriptType::LATIN|SvtScriptType::ASIAN))
2617 if( nullptr == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
2618 nullptr == (pAsn = GetItemOfScriptSet( rSet, nAsian )) ||
2619 *pRet != *pAsn )
2620 pRet = nullptr;
2621 } else if (nScript == (SvtScriptType::LATIN|SvtScriptType::COMPLEX))
2623 if( nullptr == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
2624 nullptr == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
2625 *pRet != *pCmplx )
2626 pRet = nullptr;
2627 } else if (nScript == (SvtScriptType::ASIAN|SvtScriptType::COMPLEX))
2629 if( nullptr == (pRet = GetItemOfScriptSet( rSet, nAsian )) ||
2630 nullptr == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
2631 *pRet != *pCmplx )
2632 pRet = nullptr;
2633 } else if (nScript == (SvtScriptType::LATIN|SvtScriptType::ASIAN|SvtScriptType::COMPLEX))
2635 if( nullptr == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
2636 nullptr == (pAsn = GetItemOfScriptSet( rSet, nAsian )) ||
2637 nullptr == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
2638 *pRet != *pAsn || *pRet != *pCmplx )
2639 pRet = nullptr;
2640 } else {
2641 //no one valid -> match to latin
2642 pRet = GetItemOfScriptSet( rSet, nLatin );
2644 return pRet;
2647 const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( SvtScriptType nScript ) const
2649 return GetItemOfScript( Which(), GetItemSet(), nScript );
2652 void SvxScriptSetItem::PutItemForScriptType( SvtScriptType nScriptType,
2653 const SfxPoolItem& rItem )
2655 sal_uInt16 nLatin, nAsian, nComplex;
2656 GetWhichIds( nLatin, nAsian, nComplex );
2658 if( SvtScriptType::LATIN & nScriptType )
2660 GetItemSet().Put( rItem.CloneSetWhich(nLatin) );
2662 if( SvtScriptType::ASIAN & nScriptType )
2664 GetItemSet().Put( rItem.CloneSetWhich(nAsian) );
2666 if( SvtScriptType::COMPLEX & nScriptType )
2668 GetItemSet().Put( rItem.CloneSetWhich(nComplex) );
2672 void SvxScriptSetItem::GetWhichIds( sal_uInt16 nSlotId, const SfxItemSet& rSet, sal_uInt16& rLatin, sal_uInt16& rAsian, sal_uInt16& rComplex )
2674 const SfxItemPool& rPool = *rSet.GetPool();
2675 GetSlotIds( nSlotId, rLatin, rAsian, rComplex );
2676 rLatin = rPool.GetWhich( rLatin );
2677 rAsian = rPool.GetWhich( rAsian );
2678 rComplex = rPool.GetWhich( rComplex );
2681 void SvxScriptSetItem::GetWhichIds( sal_uInt16& rLatin, sal_uInt16& rAsian,
2682 sal_uInt16& rComplex ) const
2684 GetWhichIds( Which(), GetItemSet(), rLatin, rAsian, rComplex );
2687 void SvxScriptSetItem::GetSlotIds( sal_uInt16 nSlotId, sal_uInt16& rLatin,
2688 sal_uInt16& rAsian, sal_uInt16& rComplex )
2690 switch( nSlotId )
2692 default:
2693 SAL_WARN( "editeng.items", "wrong SlotId for class SvxScriptSetItem" );
2694 [[fallthrough]]; // default to font - Id Range !!
2696 case SID_ATTR_CHAR_FONT:
2697 rLatin = SID_ATTR_CHAR_FONT;
2698 rAsian = SID_ATTR_CHAR_CJK_FONT;
2699 rComplex = SID_ATTR_CHAR_CTL_FONT;
2700 break;
2701 case SID_ATTR_CHAR_FONTHEIGHT:
2702 rLatin = SID_ATTR_CHAR_FONTHEIGHT;
2703 rAsian = SID_ATTR_CHAR_CJK_FONTHEIGHT;
2704 rComplex = SID_ATTR_CHAR_CTL_FONTHEIGHT;
2705 break;
2706 case SID_ATTR_CHAR_WEIGHT:
2707 rLatin = SID_ATTR_CHAR_WEIGHT;
2708 rAsian = SID_ATTR_CHAR_CJK_WEIGHT;
2709 rComplex = SID_ATTR_CHAR_CTL_WEIGHT;
2710 break;
2711 case SID_ATTR_CHAR_POSTURE:
2712 rLatin = SID_ATTR_CHAR_POSTURE;
2713 rAsian = SID_ATTR_CHAR_CJK_POSTURE;
2714 rComplex = SID_ATTR_CHAR_CTL_POSTURE;
2715 break;
2716 case SID_ATTR_CHAR_LANGUAGE:
2717 rLatin = SID_ATTR_CHAR_LANGUAGE;
2718 rAsian = SID_ATTR_CHAR_CJK_LANGUAGE;
2719 rComplex = SID_ATTR_CHAR_CTL_LANGUAGE;
2720 break;
2721 case SID_ATTR_CHAR_SHADOWED:
2722 rLatin = SID_ATTR_CHAR_SHADOWED;
2723 rAsian = SID_ATTR_CHAR_SHADOWED;
2724 rComplex = SID_ATTR_CHAR_SHADOWED;
2725 break;
2726 case SID_ATTR_CHAR_STRIKEOUT:
2727 rLatin = SID_ATTR_CHAR_STRIKEOUT;
2728 rAsian = SID_ATTR_CHAR_STRIKEOUT;
2729 rComplex = SID_ATTR_CHAR_STRIKEOUT;
2730 break;
2734 void GetDefaultFonts( SvxFontItem& rLatin, SvxFontItem& rAsian, SvxFontItem& rComplex )
2736 const sal_uInt16 nItemCnt = 3;
2738 static struct
2740 DefaultFontType nFontType;
2741 LanguageType nLanguage;
2743 const aOutTypeArr[ nItemCnt ] =
2745 { DefaultFontType::LATIN_TEXT, LANGUAGE_ENGLISH_US },
2746 { DefaultFontType::CJK_TEXT, LANGUAGE_ENGLISH_US },
2747 { DefaultFontType::CTL_TEXT, LANGUAGE_ARABIC_SAUDI_ARABIA }
2750 SvxFontItem* aItemArr[ nItemCnt ] = { &rLatin, &rAsian, &rComplex };
2752 for ( sal_uInt16 n = 0; n < nItemCnt; ++n )
2754 vcl::Font aFont( OutputDevice::GetDefaultFont( aOutTypeArr[ n ].nFontType,
2755 aOutTypeArr[ n ].nLanguage,
2756 GetDefaultFontFlags::OnlyOne ) );
2757 SvxFontItem* pItem = aItemArr[ n ];
2758 pItem->SetFamily( aFont.GetFamilyType() );
2759 pItem->SetFamilyName( aFont.GetFamilyName() );
2760 pItem->SetStyleName( OUString() );
2761 pItem->SetPitch( aFont.GetPitch());
2762 pItem->SetCharSet(aFont.GetCharSet());
2767 bool SvxRsidItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const
2769 rVal <<= GetValue();
2770 return true;
2773 bool SvxRsidItem::PutValue( const uno::Any& rVal, sal_uInt8 )
2775 sal_uInt32 nRsid = 0;
2776 if( !( rVal >>= nRsid ) )
2777 return false;
2779 SetValue( nRsid );
2780 return true;
2783 SvxRsidItem* SvxRsidItem::Clone( SfxItemPool * ) const
2785 return new SvxRsidItem( *this );
2788 bool SvxRsidItem::GetPresentation
2790 SfxItemPresentation /*ePres*/,
2791 MapUnit /*eCoreUnit*/,
2792 MapUnit /*ePresUnit*/,
2793 OUString& rText, const IntlWrapper& /*rIntl*/
2794 ) const
2796 rText.clear();
2797 return false;
2800 void SvxRsidItem::dumpAsXml(xmlTextWriterPtr pWriter) const
2802 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxRsidItem"));
2803 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("whichId"), "%d", Which());
2804 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("value"), "%" SAL_PRIuUINT32, GetValue());
2805 (void)xmlTextWriterEndElement(pWriter);
2808 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */