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>
25 #include <toolkit/helper/vclunohelper.hxx>
27 #include <rtl/math.hxx>
28 #include <unotools/fontdefs.hxx>
29 #include <vcl/outdev.hxx>
30 #include <editeng/eeitem.hxx>
31 #include <svtools/unitconv.hxx>
33 #include <svl/memberid.hrc>
34 #include <editeng/editids.hrc>
35 #include <editeng/editrids.hrc>
36 #include <vcl/vclenum.hxx>
37 #include <tools/tenccvt.hxx>
38 #include <tools/mapunit.hxx>
40 #include <rtl/ustring.hxx>
41 #include <i18nlangtag/languagetag.hxx>
42 #include <svl/itemset.hxx>
44 #include <svtools/langtab.hxx>
45 #include <svl/itempool.hxx>
46 #include <svtools/ctrltool.hxx>
47 #include <vcl/settings.hxx>
48 #include <vcl/svapp.hxx>
49 #include <com/sun/star/awt/SimpleFontMetric.hpp>
50 #include <com/sun/star/awt/FontWeight.hpp>
51 #include <com/sun/star/awt/FontSlant.hpp>
52 #include <com/sun/star/awt/CharSet.hpp>
53 #include <com/sun/star/awt/FontWidth.hpp>
54 #include <com/sun/star/awt/XFont.hpp>
55 #include <com/sun/star/awt/FontType.hpp>
56 #include <com/sun/star/awt/FontUnderline.hpp>
57 #include <com/sun/star/awt/FontStrikeout.hpp>
58 #include <com/sun/star/awt/FontFamily.hpp>
59 #include <com/sun/star/awt/FontPitch.hpp>
60 #include <com/sun/star/lang/Locale.hpp>
61 #include <com/sun/star/text/FontEmphasis.hpp>
62 #include <com/sun/star/i18n/ScriptType.hpp>
63 #include <editeng/rsiditem.hxx>
64 #include <editeng/memberids.hrc>
65 #include <editeng/flstitem.hxx>
66 #include <editeng/fontitem.hxx>
67 #include <editeng/postitem.hxx>
68 #include <editeng/wghtitem.hxx>
69 #include <editeng/fhgtitem.hxx>
70 #include <editeng/fwdtitem.hxx>
71 #include <editeng/udlnitem.hxx>
72 #include <editeng/crossedoutitem.hxx>
73 #include <editeng/shdditem.hxx>
74 #include <editeng/autokernitem.hxx>
75 #include <editeng/wrlmitem.hxx>
76 #include <editeng/contouritem.hxx>
77 #include <editeng/prszitem.hxx>
78 #include <editeng/colritem.hxx>
79 #include <editeng/charsetcoloritem.hxx>
80 #include <editeng/kernitem.hxx>
81 #include <editeng/cmapitem.hxx>
82 #include <editeng/escapementitem.hxx>
83 #include <editeng/langitem.hxx>
84 #include <editeng/nlbkitem.hxx>
85 #include <editeng/nhypitem.hxx>
86 #include <editeng/lcolitem.hxx>
87 #include <editeng/blinkitem.hxx>
88 #include <editeng/emphasismarkitem.hxx>
89 #include <editeng/twolinesitem.hxx>
90 #include <editeng/scripttypeitem.hxx>
91 #include <editeng/charrotateitem.hxx>
92 #include <editeng/charscaleitem.hxx>
93 #include <editeng/charreliefitem.hxx>
94 #include <editeng/itemtype.hxx>
95 #include <editeng/eerdll.hxx>
96 #include <libxml/xmlwriter.h>
98 #define STORE_UNICODE_MAGIC_MARKER 0xFE331188
100 using namespace ::com::sun::star
;
101 using namespace ::com::sun::star::text
;
103 bool SvxFontItem::bEnableStoreUnicodeNames
= false;
105 // STATIC DATA -----------------------------------------------------------
109 TYPEINIT1(SvxFontListItem
, SfxPoolItem
);
110 TYPEINIT1_FACTORY(SvxFontItem
, SfxPoolItem
, new SvxFontItem(0));
111 TYPEINIT1_FACTORY(SvxPostureItem
, SfxEnumItem
, new SvxPostureItem(ITALIC_NONE
, 0));
112 TYPEINIT1_FACTORY(SvxWeightItem
, SfxEnumItem
, new SvxWeightItem(WEIGHT_NORMAL
, 0));
113 TYPEINIT1_FACTORY(SvxFontHeightItem
, SfxPoolItem
, new SvxFontHeightItem(240, 100, 0));
114 TYPEINIT1_FACTORY(SvxFontWidthItem
, SfxPoolItem
, new SvxFontWidthItem(0, 100, 0));
115 TYPEINIT1_FACTORY(SvxTextLineItem
, SfxEnumItem
, new SvxTextLineItem(UNDERLINE_NONE
, 0));
116 TYPEINIT1_FACTORY(SvxUnderlineItem
, SfxEnumItem
, new SvxUnderlineItem(UNDERLINE_NONE
, 0));
117 TYPEINIT1_FACTORY(SvxOverlineItem
, SfxEnumItem
, new SvxOverlineItem(UNDERLINE_NONE
, 0));
118 TYPEINIT1_FACTORY(SvxCrossedOutItem
, SfxEnumItem
, new SvxCrossedOutItem(STRIKEOUT_NONE
, 0));
119 TYPEINIT1_FACTORY(SvxShadowedItem
, SfxBoolItem
, new SvxShadowedItem(false, 0));
120 TYPEINIT1_FACTORY(SvxAutoKernItem
, SfxBoolItem
, new SvxAutoKernItem(false, 0));
121 TYPEINIT1_FACTORY(SvxWordLineModeItem
, SfxBoolItem
, new SvxWordLineModeItem(false, 0));
122 TYPEINIT1_FACTORY(SvxContourItem
, SfxBoolItem
, new SvxContourItem(false, 0));
123 TYPEINIT1_FACTORY(SvxPropSizeItem
, SfxUInt16Item
, new SvxPropSizeItem(100, 0));
124 TYPEINIT1_FACTORY(SvxColorItem
, SfxPoolItem
, new SvxColorItem(0));
125 // XXX: Should 2nd argoment of next line SfxColorItem or SfxPoolItem?
126 TYPEINIT1_FACTORY(SvxBackgroundColorItem
, SvxColorItem
, new SvxBackgroundColorItem(0));
127 TYPEINIT1_FACTORY(SvxCharSetColorItem
, SvxColorItem
, new SvxCharSetColorItem(0));
128 TYPEINIT1_FACTORY(SvxKerningItem
, SfxInt16Item
, new SvxKerningItem(0, 0));
129 TYPEINIT1_FACTORY(SvxCaseMapItem
, SfxEnumItem
, new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED
, 0));
130 TYPEINIT1_FACTORY(SvxEscapementItem
, SfxPoolItem
, new SvxEscapementItem(0));
131 TYPEINIT1_FACTORY(SvxLanguageItem
, SfxEnumItem
, new SvxLanguageItem(LANGUAGE_GERMAN
, 0));
132 TYPEINIT1_FACTORY(SvxNoLinebreakItem
, SfxBoolItem
, new SvxNoLinebreakItem(true, 0));
133 TYPEINIT1_FACTORY(SvxNoHyphenItem
, SfxBoolItem
, new SvxNoHyphenItem(true, 0));
134 TYPEINIT1_FACTORY(SvxLineColorItem
, SvxColorItem
, new SvxLineColorItem(0));
135 TYPEINIT1_FACTORY(SvxBlinkItem
, SfxBoolItem
, new SvxBlinkItem(false, 0));
136 TYPEINIT1_FACTORY(SvxEmphasisMarkItem
, SfxUInt16Item
, new SvxEmphasisMarkItem(EMPHASISMARK_NONE
, 0));
137 TYPEINIT1_FACTORY(SvxTwoLinesItem
, SfxPoolItem
, new SvxTwoLinesItem(true, 0, 0, 0));
138 TYPEINIT1_FACTORY(SvxScriptTypeItem
, SfxUInt16Item
, new SvxScriptTypeItem
);
139 TYPEINIT1_FACTORY(SvxCharRotateItem
, SfxUInt16Item
, new SvxCharRotateItem(0, false, 0));
140 TYPEINIT1_FACTORY(SvxCharScaleWidthItem
, SfxUInt16Item
, new SvxCharScaleWidthItem(100, 0));
141 TYPEINIT1_FACTORY(SvxCharReliefItem
, SfxEnumItem
, new SvxCharReliefItem(RELIEF_NONE
, 0));
142 TYPEINIT1_FACTORY(SvxRsidItem
, SfxUInt32Item
, new SvxRsidItem(0, 0));
144 TYPEINIT1(SvxScriptSetItem
, SfxSetItem
);
147 // class SvxFontListItem -------------------------------------------------
149 SvxFontListItem::SvxFontListItem( const FontList
* pFontLst
,
150 const sal_uInt16 nId
) :
152 pFontList( pFontLst
)
156 sal_Int32 nCount
= pFontList
->GetFontNameCount();
157 aFontNameSeq
.realloc( nCount
);
159 for ( sal_uInt16 i
= 0; i
< nCount
; i
++ )
160 aFontNameSeq
[i
] = pFontList
->GetFontName(i
).GetName();
166 SvxFontListItem::SvxFontListItem( const SvxFontListItem
& rItem
) :
168 SfxPoolItem( rItem
),
169 pFontList( rItem
.GetFontList() ),
170 aFontNameSeq( rItem
.aFontNameSeq
)
176 SfxPoolItem
* SvxFontListItem::Clone( SfxItemPool
* ) const
178 return new SvxFontListItem( *this );
183 bool SvxFontListItem::operator==( const SfxPoolItem
& rAttr
) const
185 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
187 return( pFontList
== static_cast<const SvxFontListItem
&>(rAttr
).pFontList
);
190 bool SvxFontListItem::QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
192 rVal
<<= aFontNameSeq
;
198 bool SvxFontListItem::GetPresentation
200 SfxItemPresentation
/*ePres*/,
201 SfxMapUnit
/*eCoreUnit*/,
202 SfxMapUnit
/*ePresUnit*/,
203 OUString
& rText
, const IntlWrapper
* /*pIntl*/
210 // class SvxFontItem -----------------------------------------------------
212 SvxFontItem::SvxFontItem( const sal_uInt16 nId
) :
215 eFamily
= FAMILY_SWISS
;
216 ePitch
= PITCH_VARIABLE
;
217 eTextEncoding
= RTL_TEXTENCODING_DONTKNOW
;
222 SvxFontItem::SvxFontItem( const FontFamily eFam
, const OUString
& aName
,
223 const OUString
& aStName
, const FontPitch eFontPitch
,
224 const rtl_TextEncoding eFontTextEncoding
, const sal_uInt16 nId
) :
233 eTextEncoding
= eFontTextEncoding
;
237 SvxFontItem
& SvxFontItem::operator=(const SvxFontItem
& rFont
)
239 aFamilyName
= rFont
.GetFamilyName();
240 aStyleName
= rFont
.GetStyleName();
241 eFamily
= rFont
.GetFamily();
242 ePitch
= rFont
.GetPitch();
243 eTextEncoding
= rFont
.GetCharSet();
248 bool SvxFontItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
250 nMemberId
&= ~CONVERT_TWIPS
;
255 com::sun::star::awt::FontDescriptor aFontDescriptor
;
256 aFontDescriptor
.Name
= aFamilyName
;
257 aFontDescriptor
.StyleName
= aStyleName
;
258 aFontDescriptor
.Family
= (sal_Int16
)(eFamily
);
259 aFontDescriptor
.CharSet
= (sal_Int16
)(eTextEncoding
);
260 aFontDescriptor
.Pitch
= (sal_Int16
)(ePitch
);
261 rVal
<<= aFontDescriptor
;
264 case MID_FONT_FAMILY_NAME
:
265 rVal
<<= aFamilyName
;
267 case MID_FONT_STYLE_NAME
:
270 case MID_FONT_FAMILY
: rVal
<<= (sal_Int16
)(eFamily
); break;
271 case MID_FONT_CHAR_SET
: rVal
<<= (sal_Int16
)(eTextEncoding
); break;
272 case MID_FONT_PITCH
: rVal
<<= (sal_Int16
)(ePitch
); break;
277 bool SvxFontItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
279 nMemberId
&= ~CONVERT_TWIPS
;
284 com::sun::star::awt::FontDescriptor aFontDescriptor
;
285 if ( !( rVal
>>= aFontDescriptor
))
288 aFamilyName
= aFontDescriptor
.Name
;
289 aStyleName
= aFontDescriptor
.StyleName
;
290 eFamily
= (FontFamily
)aFontDescriptor
.Family
;
291 eTextEncoding
= (rtl_TextEncoding
)aFontDescriptor
.CharSet
;
292 ePitch
= (FontPitch
)aFontDescriptor
.Pitch
;
295 case MID_FONT_FAMILY_NAME
:
303 case MID_FONT_STYLE_NAME
:
311 case MID_FONT_FAMILY
:
313 sal_Int16 nFamily
= sal_Int16();
314 if(!(rVal
>>= nFamily
))
316 eFamily
= (FontFamily
)nFamily
;
319 case MID_FONT_CHAR_SET
:
321 sal_Int16 nSet
= sal_Int16();
324 eTextEncoding
= (rtl_TextEncoding
)nSet
;
327 case MID_FONT_PITCH
:
329 sal_Int16 nPitch
= sal_Int16();
330 if(!(rVal
>>= nPitch
))
332 ePitch
= (FontPitch
)nPitch
;
341 bool SvxFontItem::operator==( const SfxPoolItem
& rAttr
) const
343 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
345 const SvxFontItem
& rItem
= static_cast<const SvxFontItem
&>(rAttr
);
347 bool bRet
= ( eFamily
== rItem
.eFamily
&&
348 aFamilyName
== rItem
.aFamilyName
&&
349 aStyleName
== rItem
.aStyleName
);
353 if ( ePitch
!= rItem
.ePitch
|| eTextEncoding
!= rItem
.eTextEncoding
)
356 DBG_WARNING( "FontItem::operator==(): only pitch or rtl_TextEncoding different ");
364 SfxPoolItem
* SvxFontItem::Clone( SfxItemPool
* ) const
366 return new SvxFontItem( *this );
371 SvStream
& SvxFontItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
373 bool bToBats
= IsStarSymbol( GetFamilyName() );
375 rStrm
.WriteUChar( GetFamily() ).WriteUChar( GetPitch() )
376 .WriteUChar( bToBats
? RTL_TEXTENCODING_SYMBOL
: GetSOStoreTextEncoding(GetCharSet()) );
378 OUString
aStoreFamilyName( GetFamilyName() );
380 aStoreFamilyName
= "StarBats";
381 rStrm
.WriteUniOrByteString(aStoreFamilyName
, rStrm
.GetStreamCharSet());
382 rStrm
.WriteUniOrByteString(GetStyleName(), rStrm
.GetStreamCharSet());
384 // cach for EditEngine, only set while creating clipboard stream.
385 if ( bEnableStoreUnicodeNames
)
387 sal_uInt32 nMagic
= STORE_UNICODE_MAGIC_MARKER
;
388 rStrm
.WriteUInt32( nMagic
);
389 rStrm
.WriteUniOrByteString( aStoreFamilyName
, RTL_TEXTENCODING_UNICODE
);
390 rStrm
.WriteUniOrByteString( GetStyleName(), RTL_TEXTENCODING_UNICODE
);
398 SfxPoolItem
* SvxFontItem::Create(SvStream
& rStrm
, sal_uInt16
) const
400 sal_uInt8 _eFamily
, eFontPitch
, eFontTextEncoding
;
401 OUString aName
, aStyle
;
402 rStrm
.ReadUChar( _eFamily
);
403 rStrm
.ReadUChar( eFontPitch
);
404 rStrm
.ReadUChar( eFontTextEncoding
);
406 // UNICODE: rStrm >> aName;
407 aName
= rStrm
.ReadUniOrByteString(rStrm
.GetStreamCharSet());
409 // UNICODE: rStrm >> aStyle;
410 aStyle
= rStrm
.ReadUniOrByteString(rStrm
.GetStreamCharSet());
412 // Set the "correct" textencoding
413 eFontTextEncoding
= (sal_uInt8
)GetSOLoadTextEncoding( eFontTextEncoding
);
415 // at some point, the StarBats changes from ANSI font to SYMBOL font
416 if ( RTL_TEXTENCODING_SYMBOL
!= eFontTextEncoding
&& aName
== "StarBats" )
417 eFontTextEncoding
= RTL_TEXTENCODING_SYMBOL
;
419 // Check if we have stored unicode
420 sal_Size nStreamPos
= rStrm
.Tell();
421 sal_uInt32 nMagic
= STORE_UNICODE_MAGIC_MARKER
;
422 rStrm
.ReadUInt32( nMagic
);
423 if ( nMagic
== STORE_UNICODE_MAGIC_MARKER
)
425 aName
= rStrm
.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE
);
426 aStyle
= rStrm
.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE
);
430 rStrm
.Seek( nStreamPos
);
435 return new SvxFontItem( (FontFamily
)_eFamily
, aName
, aStyle
,
436 (FontPitch
)eFontPitch
, (rtl_TextEncoding
)eFontTextEncoding
, Which() );
441 bool SvxFontItem::GetPresentation
443 SfxItemPresentation
/*ePres*/,
444 SfxMapUnit
/*eCoreUnit*/,
445 SfxMapUnit
/*ePresUnit*/,
446 OUString
& rText
, const IntlWrapper
* /*pIntl*/
455 void SvxFontItem::EnableStoreUnicodeNames( bool bEnable
)
457 bEnableStoreUnicodeNames
= bEnable
;
460 void SvxFontItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
462 xmlTextWriterStartElement(pWriter
, BAD_CAST("svxFontItem"));
463 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
464 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("familyName"), BAD_CAST(aFamilyName
.toUtf8().getStr()));
465 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("styleName"), BAD_CAST(aStyleName
.toUtf8().getStr()));
466 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("family"), BAD_CAST(OString::number(eFamily
).getStr()));
467 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("pitch"), BAD_CAST(OString::number(ePitch
).getStr()));
468 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("textEncoding"), BAD_CAST(OString::number(eTextEncoding
).getStr()));
469 xmlTextWriterEndElement(pWriter
);
472 // class SvxPostureItem --------------------------------------------------
474 SvxPostureItem::SvxPostureItem( const FontItalic ePosture
, const sal_uInt16 nId
) :
475 SfxEnumItem( nId
, (sal_uInt16
)ePosture
)
481 SfxPoolItem
* SvxPostureItem::Clone( SfxItemPool
* ) const
483 return new SvxPostureItem( *this );
488 sal_uInt16
SvxPostureItem::GetValueCount() const
490 return ITALIC_NORMAL
+ 1; // ITALIC_NONE also belongs here
495 SvStream
& SvxPostureItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
497 rStrm
.WriteUChar( GetValue() );
503 SfxPoolItem
* SvxPostureItem::Create(SvStream
& rStrm
, sal_uInt16
) const
506 rStrm
.ReadUChar( nPosture
);
507 return new SvxPostureItem( (const FontItalic
)nPosture
, Which() );
512 bool SvxPostureItem::GetPresentation
514 SfxItemPresentation
/*ePres*/,
515 SfxMapUnit
/*eCoreUnit*/,
516 SfxMapUnit
/*ePresUnit*/,
517 OUString
& rText
, const IntlWrapper
* /*pIntl*/
520 rText
= GetValueTextByPos( GetValue() );
526 OUString
SvxPostureItem::GetValueTextByPos( sal_uInt16 nPos
) const
528 DBG_ASSERT( nPos
<= (sal_uInt16
)ITALIC_NORMAL
, "enum overflow!" );
530 FontItalic eItalic
= (FontItalic
)nPos
;
535 case ITALIC_NONE
: nId
= RID_SVXITEMS_ITALIC_NONE
; break;
536 case ITALIC_OBLIQUE
: nId
= RID_SVXITEMS_ITALIC_OBLIQUE
; break;
537 case ITALIC_NORMAL
: nId
= RID_SVXITEMS_ITALIC_NORMAL
; break;
538 default: ;//prevent warning
541 return nId
? EE_RESSTR(nId
) : OUString();
544 bool SvxPostureItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
546 nMemberId
&= ~CONVERT_TWIPS
;
550 rVal
= Bool2Any(GetBoolValue());
553 rVal
<<= (awt::FontSlant
)GetValue(); // values from awt::FontSlant and FontItalic are equal
559 bool SvxPostureItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
561 nMemberId
&= ~CONVERT_TWIPS
;
565 SetBoolValue(Any2Bool(rVal
));
569 awt::FontSlant eSlant
;
570 if(!(rVal
>>= eSlant
))
572 sal_Int32 nValue
= 0;
573 if(!(rVal
>>= nValue
))
576 eSlant
= (awt::FontSlant
)nValue
;
578 SetValue((sal_uInt16
)eSlant
);
585 bool SvxPostureItem::HasBoolValue() const
592 bool SvxPostureItem::GetBoolValue() const
594 return ( (FontItalic
)GetValue() >= ITALIC_OBLIQUE
);
599 void SvxPostureItem::SetBoolValue( bool bVal
)
601 SetValue( (sal_uInt16
)(bVal
? ITALIC_NORMAL
: ITALIC_NONE
) );
604 void SvxPostureItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
606 xmlTextWriterStartElement(pWriter
, BAD_CAST("svxPostureItem"));
607 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
608 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%d", GetValue());
609 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr()));
610 xmlTextWriterEndElement(pWriter
);
613 // class SvxWeightItem ---------------------------------------------------
615 SvxWeightItem::SvxWeightItem( const FontWeight eWght
, const sal_uInt16 nId
) :
616 SfxEnumItem( nId
, (sal_uInt16
)eWght
)
624 bool SvxWeightItem::HasBoolValue() const
631 bool SvxWeightItem::GetBoolValue() const
633 return (FontWeight
)GetValue() >= WEIGHT_BOLD
;
638 void SvxWeightItem::SetBoolValue( bool bVal
)
640 SetValue( (sal_uInt16
)(bVal
? WEIGHT_BOLD
: WEIGHT_NORMAL
) );
645 sal_uInt16
SvxWeightItem::GetValueCount() const
647 return WEIGHT_BLACK
; // WEIGHT_DONTKNOW does not belong
652 SfxPoolItem
* SvxWeightItem::Clone( SfxItemPool
* ) const
654 return new SvxWeightItem( *this );
659 SvStream
& SvxWeightItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
661 rStrm
.WriteUChar( GetValue() );
667 SfxPoolItem
* SvxWeightItem::Create(SvStream
& rStrm
, sal_uInt16
) const
670 rStrm
.ReadUChar( nWeight
);
671 return new SvxWeightItem( (FontWeight
)nWeight
, Which() );
676 bool SvxWeightItem::GetPresentation
678 SfxItemPresentation
/*ePres*/,
679 SfxMapUnit
/*eCoreUnit*/,
680 SfxMapUnit
/*ePresUnit*/,
681 OUString
& rText
, const IntlWrapper
* /*pIntl*/
684 rText
= GetValueTextByPos( GetValue() );
690 OUString
SvxWeightItem::GetValueTextByPos( sal_uInt16 nPos
) const
692 DBG_ASSERT( nPos
<= (sal_uInt16
)WEIGHT_BLACK
, "enum overflow!" );
693 return EE_RESSTR(RID_SVXITEMS_WEIGHT_BEGIN
+ nPos
);
696 bool SvxWeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
698 nMemberId
&= ~CONVERT_TWIPS
;
702 rVal
= Bool2Any(GetBoolValue());
706 rVal
<<= (float)( VCLUnoHelper::ConvertFontWeight( (FontWeight
)GetValue() ) );
713 bool SvxWeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
715 nMemberId
&= ~CONVERT_TWIPS
;
719 SetBoolValue(Any2Bool(rVal
));
724 if(!(rVal
>>= fValue
))
726 sal_Int32 nValue
= 0;
727 if(!(rVal
>>= nValue
))
729 fValue
= (float)nValue
;
731 SetValue( (sal_uInt16
)VCLUnoHelper::ConvertFontWeight((float)fValue
) );
738 void SvxWeightItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
740 xmlTextWriterStartElement(pWriter
, BAD_CAST("svxWeightItem"));
741 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
742 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%d", GetValue());
743 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr()));
744 xmlTextWriterEndElement(pWriter
);
747 // class SvxFontHeightItem -----------------------------------------------
749 SvxFontHeightItem::SvxFontHeightItem( const sal_uLong nSz
,
750 const sal_uInt16 nPrp
,
751 const sal_uInt16 nId
) :
754 SetHeight( nSz
,nPrp
); // calculate in percentage
759 SfxPoolItem
* SvxFontHeightItem::Clone( SfxItemPool
* ) const
761 return new SvxFontHeightItem( *this );
766 SvStream
& SvxFontHeightItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
768 rStrm
.WriteUInt16( GetHeight() );
770 if( FONTHEIGHT_UNIT_VERSION
<= nItemVersion
)
771 rStrm
.WriteUInt16( GetProp() ).WriteUInt16( GetPropUnit() );
774 // When exporting to the old versions the relative information is lost
775 // when there is no percentage
776 sal_uInt16 _nProp
= GetProp();
777 if( SFX_MAPUNIT_RELATIVE
!= GetPropUnit() )
779 rStrm
.WriteUInt16( _nProp
);
786 SfxPoolItem
* SvxFontHeightItem::Create( SvStream
& rStrm
,
787 sal_uInt16 nVersion
) const
789 sal_uInt16 nsize
, nprop
= 0, nPropUnit
= SFX_MAPUNIT_RELATIVE
;
791 rStrm
.ReadUInt16( nsize
);
793 if( FONTHEIGHT_16_VERSION
<= nVersion
)
794 rStrm
.ReadUInt16( nprop
);
798 rStrm
.ReadUChar( nP
);
799 nprop
= (sal_uInt16
)nP
;
802 if( FONTHEIGHT_UNIT_VERSION
<= nVersion
)
803 rStrm
.ReadUInt16( nPropUnit
);
805 SvxFontHeightItem
* pItem
= new SvxFontHeightItem( nsize
, 100, Which() );
806 pItem
->SetProp( nprop
, (SfxMapUnit
)nPropUnit
);
812 bool SvxFontHeightItem::operator==( const SfxPoolItem
& rItem
) const
814 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
815 return GetHeight() == static_cast<const SvxFontHeightItem
&>(rItem
).GetHeight() &&
816 GetProp() == static_cast<const SvxFontHeightItem
&>(rItem
).GetProp() &&
817 GetPropUnit() == static_cast<const SvxFontHeightItem
&>(rItem
).GetPropUnit();
820 bool SvxFontHeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
822 // In StarOne is the uno::Any always 1/100mm. Through the MemberId it is
823 // controlled if the value in the Item should be 1/100mm or Twips.
825 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
826 nMemberId
&= ~CONVERT_TWIPS
;
831 ::com::sun::star::frame::status::FontHeight aFontHeight
;
833 // Point (i.e. Twips) is asked for, thus re-calculate if
834 // CONVERT_TWIPS is not set.
837 aFontHeight
.Height
= (float)( nHeight
/ 20.0 );
841 double fPoints
= convertMm100ToTwip(nHeight
) / 20.0;
843 static_cast<float>(::rtl::math::round(fPoints
, 1));
844 aFontHeight
.Height
= fRoundPoints
;
847 aFontHeight
.Prop
= (sal_Int16
)(SFX_MAPUNIT_RELATIVE
== ePropUnit
? nProp
: 100);
849 float fRet
= (float)(short)nProp
;
852 case SFX_MAPUNIT_RELATIVE
:
855 case SFX_MAPUNIT_100TH_MM
:
856 fRet
= convertMm100ToTwip(fRet
);
859 case SFX_MAPUNIT_POINT
:
862 case SFX_MAPUNIT_TWIP
:
865 default: ;//prevent warning
867 aFontHeight
.Diff
= fRet
;
868 rVal
<<= aFontHeight
;
873 // Point (i.e. Twips) is asked for, thus re-calculate if
874 // CONVERT_TWIPS is not set.
877 rVal
<<= (float)( nHeight
/ 20.0 );
881 double fPoints
= convertMm100ToTwip(nHeight
) / 20.0;
883 static_cast<float>(::rtl::math::round(fPoints
, 1));
884 rVal
<<= fRoundPoints
;
888 case MID_FONTHEIGHT_PROP
:
889 rVal
<<= (sal_Int16
)(SFX_MAPUNIT_RELATIVE
== ePropUnit
? nProp
: 100);
891 case MID_FONTHEIGHT_DIFF
:
893 float fRet
= (float)(short)nProp
;
896 case SFX_MAPUNIT_RELATIVE
:
899 case SFX_MAPUNIT_100TH_MM
:
900 fRet
= convertMm100ToTwip(fRet
);
903 case SFX_MAPUNIT_POINT
:
906 case SFX_MAPUNIT_TWIP
:
909 default: ;//prevent warning
918 // Try to reconstruct the original height input value from the modified height
919 // and the prop data; this seems somewhat futile given the various ways how the
920 // modified height is calculated (with and without conversion between twips and
921 // 100th mm; with an additional eCoreMetric input in one of the SetHeight
922 // overloads), and indeed known to occasionally produce nRet values that would
923 // be negative, so just guard against negative results here and throw the hands
925 static sal_uInt32
lcl_GetRealHeight_Impl(sal_uInt32 nHeight
, sal_uInt16 nProp
, SfxMapUnit eProp
, bool bCoreInTwip
)
927 sal_uInt32 nRet
= nHeight
;
931 case SFX_MAPUNIT_RELATIVE
:
935 case SFX_MAPUNIT_POINT
:
937 short nTemp
= (short)nProp
;
940 nDiff
= (short)convertTwipToMm100((long)(nDiff
));
943 case SFX_MAPUNIT_100TH_MM
:
944 //then the core is surely also in 1/100 mm
945 nDiff
= (short)nProp
;
947 case SFX_MAPUNIT_TWIP
:
949 nDiff
= ((short)nProp
);
951 default: ;//prevent warning
953 nRet
= (nDiff
< 0 || nRet
>= static_cast<unsigned short>(nDiff
))
955 //TODO: overflow in case nDiff < 0 and nRet - nDiff > SAL_MAX_UINT32
960 bool SvxFontHeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
962 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
963 nMemberId
&= ~CONVERT_TWIPS
;
968 ::com::sun::star::frame::status::FontHeight aFontHeight
;
969 if ( rVal
>>= aFontHeight
)
972 ePropUnit
= SFX_MAPUNIT_RELATIVE
;
974 double fPoint
= aFontHeight
.Height
;
975 if( fPoint
< 0. || fPoint
> 10000. )
978 nHeight
= (long)( fPoint
* 20.0 + 0.5 ); // Twips
980 nHeight
= convertTwipToMm100(nHeight
); // Convert, if the item contains 1/100mm
982 nProp
= aFontHeight
.Prop
;
990 ePropUnit
= SFX_MAPUNIT_RELATIVE
;
993 if(!(rVal
>>= fPoint
))
995 sal_Int32 nValue
= 0;
996 if(!(rVal
>>= nValue
))
998 fPoint
= (float)nValue
;
1000 if(fPoint
< 0. || fPoint
> 10000.)
1003 nHeight
= (long)( fPoint
* 20.0 + 0.5 ); // Twips
1005 nHeight
= convertTwipToMm100(nHeight
); // Convert, if the item contains 1/100mm
1008 case MID_FONTHEIGHT_PROP
:
1010 sal_Int16 nNew
= sal_Int16();
1011 if(!(rVal
>>= nNew
))
1014 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
1019 ePropUnit
= SFX_MAPUNIT_RELATIVE
;
1022 case MID_FONTHEIGHT_DIFF
:
1024 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
1026 if(!(rVal
>>= fValue
))
1028 sal_Int32 nValue
= 0;
1029 if(!(rVal
>>= nValue
))
1031 fValue
= (float)nValue
;
1033 sal_Int16 nCoreDiffValue
= (sal_Int16
)(fValue
* 20.);
1034 nHeight
+= bConvert
? nCoreDiffValue
: convertTwipToMm100(nCoreDiffValue
);
1035 nProp
= (sal_uInt16
)((sal_Int16
)fValue
);
1036 ePropUnit
= SFX_MAPUNIT_POINT
;
1045 bool SvxFontHeightItem::GetPresentation
1047 SfxItemPresentation
/*ePres*/,
1048 SfxMapUnit eCoreUnit
,
1049 SfxMapUnit
/*ePresUnit*/,
1050 OUString
& rText
, const IntlWrapper
*pIntl
1053 if( SFX_MAPUNIT_RELATIVE
!= ePropUnit
)
1055 rText
= OUString::number( (short)nProp
) +
1056 " " + EE_RESSTR( GetMetricId( ePropUnit
) );
1057 if( 0 <= (short)nProp
)
1058 rText
= "+" + rText
;
1060 else if( 100 == nProp
)
1062 rText
= GetMetricText( (long)nHeight
,
1063 eCoreUnit
, SFX_MAPUNIT_POINT
, pIntl
) +
1064 " " + EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT
));
1067 rText
= OUString::number( nProp
) + "%";
1073 sal_uInt16
SvxFontHeightItem::GetVersion(sal_uInt16 nFileVersion
) const
1075 return (nFileVersion
<= SOFFICE_FILEFORMAT_40
)
1076 ? FONTHEIGHT_16_VERSION
1077 : FONTHEIGHT_UNIT_VERSION
;
1082 bool SvxFontHeightItem::ScaleMetrics( long nMult
, long nDiv
)
1084 nHeight
= (sal_uInt32
)Scale( nHeight
, nMult
, nDiv
);
1090 bool SvxFontHeightItem::HasMetrics() const
1095 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, const sal_uInt16 nNewProp
,
1098 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
1100 if( SFX_MAPUNIT_RELATIVE
!= eUnit
)
1101 nHeight
= nNewHeight
+ ::ItemToControl( (short)nNewProp
, eUnit
,
1103 else if( 100 != nNewProp
)
1104 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
1106 nHeight
= nNewHeight
;
1112 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, sal_uInt16 nNewProp
,
1113 SfxMapUnit eMetric
, SfxMapUnit eCoreMetric
)
1115 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
1117 if( SFX_MAPUNIT_RELATIVE
!= eMetric
)
1118 nHeight
= nNewHeight
+
1119 ::ControlToItem( ::ItemToControl((short)nNewProp
, eMetric
,
1120 FUNIT_TWIP
), FUNIT_TWIP
,
1122 else if( 100 != nNewProp
)
1123 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
1125 nHeight
= nNewHeight
;
1128 ePropUnit
= eMetric
;
1131 void SvxFontHeightItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1133 xmlTextWriterStartElement(pWriter
, BAD_CAST("svxFontHeightItem"));
1134 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1135 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("height"), BAD_CAST(OString::number(nHeight
).getStr()));
1136 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("prop"), BAD_CAST(OString::number(nProp
).getStr()));
1137 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("propUnit"), BAD_CAST(OString::number(ePropUnit
).getStr()));
1138 xmlTextWriterEndElement(pWriter
);
1141 // class SvxFontWidthItem -----------------------------------------------
1143 SvxFontWidthItem::SvxFontWidthItem( const sal_uInt16 nSz
, const sal_uInt16 nPrp
, const sal_uInt16 nId
) :
1152 SfxPoolItem
* SvxFontWidthItem::Clone( SfxItemPool
* ) const
1154 return new SvxFontWidthItem( *this );
1159 SvStream
& SvxFontWidthItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1161 rStrm
.WriteUInt16( GetWidth() ).WriteUInt16( GetProp() );
1167 bool SvxFontWidthItem::ScaleMetrics( long nMult
, long nDiv
)
1169 nWidth
= (sal_uInt16
)Scale( nWidth
, nMult
, nDiv
);
1175 bool SvxFontWidthItem::HasMetrics() const
1182 SfxPoolItem
* SvxFontWidthItem::Create( SvStream
& rStrm
,
1183 sal_uInt16
/*nVersion*/ ) const
1188 rStrm
.ReadUInt16( nS
);
1189 rStrm
.ReadUInt16( nP
);
1190 SvxFontWidthItem
* pItem
= new SvxFontWidthItem( 0, nP
, Which() );
1191 pItem
->SetWidthValue( nS
);
1197 bool SvxFontWidthItem::operator==( const SfxPoolItem
& rItem
) const
1199 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
1200 return GetWidth() == static_cast<const SvxFontWidthItem
&>(rItem
).GetWidth() &&
1201 GetProp() == static_cast<const SvxFontWidthItem
&>(rItem
).GetProp();
1204 bool SvxFontWidthItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1206 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1207 nMemberId
&= ~CONVERT_TWIPS
;
1211 rVal
<<= (sal_Int16
)(nWidth
);
1213 case MID_FONTWIDTH_PROP
:
1214 rVal
<<= (sal_Int16
)(nProp
);
1220 bool SvxFontWidthItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1222 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1223 nMemberId
&= ~CONVERT_TWIPS
;
1224 sal_Int16 nVal
= sal_Int16();
1225 if(!(rVal
>>= nVal
))
1233 case MID_FONTWIDTH_PROP
:
1242 bool SvxFontWidthItem::GetPresentation
1244 SfxItemPresentation
/*ePres*/,
1245 SfxMapUnit eCoreUnit
,
1246 SfxMapUnit
/*ePresUnit*/,
1247 OUString
& rText
, const IntlWrapper
*pIntl
1252 rText
= GetMetricText( (long)nWidth
,
1253 eCoreUnit
, SFX_MAPUNIT_POINT
, pIntl
) +
1254 " " + EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT
));
1257 rText
= OUString::number( nProp
) + "%";
1261 // class SvxTextLineItem ------------------------------------------------
1263 SvxTextLineItem::SvxTextLineItem( const FontUnderline eSt
, const sal_uInt16 nId
)
1264 : SfxEnumItem( nId
, (sal_uInt16
)eSt
), mColor( COL_TRANSPARENT
)
1270 bool SvxTextLineItem::HasBoolValue() const
1277 bool SvxTextLineItem::GetBoolValue() const
1279 return (FontUnderline
)GetValue() != UNDERLINE_NONE
;
1284 void SvxTextLineItem::SetBoolValue( bool bVal
)
1286 SetValue( (sal_uInt16
)(bVal
? UNDERLINE_SINGLE
: UNDERLINE_NONE
) );
1291 SfxPoolItem
* SvxTextLineItem::Clone( SfxItemPool
* ) const
1293 SvxTextLineItem
* pNew
= new SvxTextLineItem( *this );
1294 pNew
->SetColor( GetColor() );
1300 sal_uInt16
SvxTextLineItem::GetValueCount() const
1302 return UNDERLINE_DOTTED
+ 1; // UNDERLINE_NONE also belongs here
1307 SvStream
& SvxTextLineItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1309 rStrm
.WriteUChar( GetValue() );
1315 SfxPoolItem
* SvxTextLineItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1318 rStrm
.ReadUChar( nState
);
1319 return new SvxTextLineItem( (FontUnderline
)nState
, Which() );
1324 bool SvxTextLineItem::GetPresentation
1326 SfxItemPresentation
/*ePres*/,
1327 SfxMapUnit
/*eCoreUnit*/,
1328 SfxMapUnit
/*ePresUnit*/,
1329 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1332 rText
= GetValueTextByPos( GetValue() );
1333 if( !mColor
.GetTransparency() )
1334 rText
= rText
+ OUString(cpDelim
) + ::GetColorString( mColor
);
1340 OUString
SvxTextLineItem::GetValueTextByPos( sal_uInt16
/*nPos*/ ) const
1342 OSL_FAIL("SvxTextLineItem::GetValueTextByPos: Pure virtual method");
1346 bool SvxTextLineItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1348 nMemberId
&= ~CONVERT_TWIPS
;
1352 rVal
= Bool2Any(GetBoolValue());
1355 rVal
<<= (sal_Int16
)(GetValue());
1358 rVal
<<= (sal_Int32
)( mColor
.GetColor() );
1360 case MID_TL_HASCOLOR
:
1361 rVal
= Bool2Any( !mColor
.GetTransparency() );
1368 bool SvxTextLineItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1370 nMemberId
&= ~CONVERT_TWIPS
;
1375 SetBoolValue(Any2Bool(rVal
));
1379 sal_Int32 nValue
= 0;
1380 if(!(rVal
>>= nValue
))
1383 SetValue((sal_Int16
)nValue
);
1389 if( !( rVal
>>= nCol
) )
1393 // Keep transparence, because it contains the information
1394 // whether the font color or the stored color should be used
1395 sal_uInt8 nTrans
= mColor
.GetTransparency();
1396 mColor
= Color( nCol
);
1397 mColor
.SetTransparency( nTrans
);
1401 case MID_TL_HASCOLOR
:
1402 mColor
.SetTransparency( Any2Bool( rVal
) ? 0 : 0xff );
1408 bool SvxTextLineItem::operator==( const SfxPoolItem
& rItem
) const
1410 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
1411 return SfxEnumItem::operator==( rItem
) &&
1412 GetColor() == static_cast<const SvxTextLineItem
&>(rItem
).GetColor();
1415 // class SvxUnderlineItem ------------------------------------------------
1417 SvxUnderlineItem::SvxUnderlineItem( const FontUnderline eSt
, const sal_uInt16 nId
)
1418 : SvxTextLineItem( eSt
, nId
)
1424 SfxPoolItem
* SvxUnderlineItem::Clone( SfxItemPool
* ) const
1426 SvxUnderlineItem
* pNew
= new SvxUnderlineItem( *this );
1427 pNew
->SetColor( GetColor() );
1433 SfxPoolItem
* SvxUnderlineItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1436 rStrm
.ReadUChar( nState
);
1437 return new SvxUnderlineItem( (FontUnderline
)nState
, Which() );
1442 OUString
SvxUnderlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1444 DBG_ASSERT( nPos
<= (sal_uInt16
)UNDERLINE_BOLDWAVE
, "enum overflow!" );
1445 return EE_RESSTR(RID_SVXITEMS_UL_BEGIN
+ nPos
);
1448 // class SvxOverlineItem ------------------------------------------------
1450 SvxOverlineItem::SvxOverlineItem( const FontUnderline eSt
, const sal_uInt16 nId
)
1451 : SvxTextLineItem( eSt
, nId
)
1457 SfxPoolItem
* SvxOverlineItem::Clone( SfxItemPool
* ) const
1459 SvxOverlineItem
* pNew
= new SvxOverlineItem( *this );
1460 pNew
->SetColor( GetColor() );
1466 SfxPoolItem
* SvxOverlineItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1469 rStrm
.ReadUChar( nState
);
1470 return new SvxOverlineItem( (FontUnderline
)nState
, Which() );
1475 OUString
SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1477 DBG_ASSERT( nPos
<= (sal_uInt16
)UNDERLINE_BOLDWAVE
, "enum overflow!" );
1478 return EE_RESSTR(RID_SVXITEMS_OL_BEGIN
+ nPos
);
1481 // class SvxCrossedOutItem -----------------------------------------------
1483 SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt
, const sal_uInt16 nId
)
1484 : SfxEnumItem( nId
, (sal_uInt16
)eSt
)
1490 bool SvxCrossedOutItem::HasBoolValue() const
1497 bool SvxCrossedOutItem::GetBoolValue() const
1499 return (FontStrikeout
)GetValue() != STRIKEOUT_NONE
;
1504 void SvxCrossedOutItem::SetBoolValue( bool bVal
)
1506 SetValue( (sal_uInt16
)(bVal
? STRIKEOUT_SINGLE
: STRIKEOUT_NONE
) );
1511 sal_uInt16
SvxCrossedOutItem::GetValueCount() const
1513 return STRIKEOUT_DOUBLE
+ 1; // STRIKEOUT_NONE belongs also here
1518 SfxPoolItem
* SvxCrossedOutItem::Clone( SfxItemPool
* ) const
1520 return new SvxCrossedOutItem( *this );
1525 SvStream
& SvxCrossedOutItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1527 rStrm
.WriteUChar( GetValue() );
1533 SfxPoolItem
* SvxCrossedOutItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1536 rStrm
.ReadUChar( eCross
);
1537 return new SvxCrossedOutItem( (FontStrikeout
)eCross
, Which() );
1542 bool SvxCrossedOutItem::GetPresentation
1544 SfxItemPresentation
/*ePres*/,
1545 SfxMapUnit
/*eCoreUnit*/,
1546 SfxMapUnit
/*ePresUnit*/,
1547 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1550 rText
= GetValueTextByPos( GetValue() );
1556 OUString
SvxCrossedOutItem::GetValueTextByPos( sal_uInt16 nPos
) const
1558 DBG_ASSERT( nPos
<= (sal_uInt16
)STRIKEOUT_X
, "enum overflow!" );
1559 return EE_RESSTR(RID_SVXITEMS_STRIKEOUT_BEGIN
+ nPos
);
1562 bool SvxCrossedOutItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1564 nMemberId
&= ~CONVERT_TWIPS
;
1567 case MID_CROSSED_OUT
:
1568 rVal
= Bool2Any(GetBoolValue());
1571 rVal
<<= (sal_Int16
)(GetValue());
1577 bool SvxCrossedOutItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1579 nMemberId
&= ~CONVERT_TWIPS
;
1582 case MID_CROSSED_OUT
:
1583 SetBoolValue(Any2Bool(rVal
));
1587 sal_Int32 nValue
= 0;
1588 if(!(rVal
>>= nValue
))
1590 SetValue((sal_Int16
)nValue
);
1596 // class SvxShadowedItem -------------------------------------------------
1598 SvxShadowedItem::SvxShadowedItem( const bool bShadowed
, const sal_uInt16 nId
) :
1599 SfxBoolItem( nId
, bShadowed
)
1605 SfxPoolItem
* SvxShadowedItem::Clone( SfxItemPool
* ) const
1607 return new SvxShadowedItem( *this );
1612 SvStream
& SvxShadowedItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1614 rStrm
.WriteBool( GetValue() );
1620 SfxPoolItem
* SvxShadowedItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1623 rStrm
.ReadUChar( nState
);
1624 return new SvxShadowedItem( nState
, Which() );
1629 bool SvxShadowedItem::GetPresentation
1631 SfxItemPresentation
/*ePres*/,
1632 SfxMapUnit
/*eCoreUnit*/,
1633 SfxMapUnit
/*ePresUnit*/,
1634 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1637 sal_uInt16 nId
= RID_SVXITEMS_SHADOWED_FALSE
;
1640 nId
= RID_SVXITEMS_SHADOWED_TRUE
;
1641 rText
= EE_RESSTR(nId
);
1645 // class SvxAutoKernItem -------------------------------------------------
1647 SvxAutoKernItem::SvxAutoKernItem( const bool bAutoKern
, const sal_uInt16 nId
) :
1648 SfxBoolItem( nId
, bAutoKern
)
1654 SfxPoolItem
* SvxAutoKernItem::Clone( SfxItemPool
* ) const
1656 return new SvxAutoKernItem( *this );
1661 SvStream
& SvxAutoKernItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1663 rStrm
.WriteBool( GetValue() );
1669 SfxPoolItem
* SvxAutoKernItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1672 rStrm
.ReadUChar( nState
);
1673 return new SvxAutoKernItem( nState
, Which() );
1678 bool SvxAutoKernItem::GetPresentation
1680 SfxItemPresentation
/*ePres*/,
1681 SfxMapUnit
/*eCoreUnit*/,
1682 SfxMapUnit
/*ePresUnit*/,
1683 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1686 sal_uInt16 nId
= RID_SVXITEMS_AUTOKERN_FALSE
;
1689 nId
= RID_SVXITEMS_AUTOKERN_TRUE
;
1690 rText
= EE_RESSTR(nId
);
1694 // class SvxWordLineModeItem ---------------------------------------------
1696 SvxWordLineModeItem::SvxWordLineModeItem( const bool bWordLineMode
,
1697 const sal_uInt16 nId
) :
1698 SfxBoolItem( nId
, bWordLineMode
)
1704 SfxPoolItem
* SvxWordLineModeItem::Clone( SfxItemPool
* ) const
1706 return new SvxWordLineModeItem( *this );
1711 SvStream
& SvxWordLineModeItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1713 rStrm
.WriteBool( GetValue() );
1719 SfxPoolItem
* SvxWordLineModeItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1722 rStrm
.ReadCharAsBool( bValue
);
1723 return new SvxWordLineModeItem( bValue
, Which() );
1728 bool SvxWordLineModeItem::GetPresentation
1730 SfxItemPresentation
/*ePres*/,
1731 SfxMapUnit
/*eCoreUnit*/,
1732 SfxMapUnit
/*ePresUnit*/,
1733 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1736 sal_uInt16 nId
= RID_SVXITEMS_WORDLINE_FALSE
;
1739 nId
= RID_SVXITEMS_WORDLINE_TRUE
;
1740 rText
= EE_RESSTR(nId
);
1744 // class SvxContourItem --------------------------------------------------
1746 SvxContourItem::SvxContourItem( const bool bContoured
, const sal_uInt16 nId
) :
1747 SfxBoolItem( nId
, bContoured
)
1753 SfxPoolItem
* SvxContourItem::Clone( SfxItemPool
* ) const
1755 return new SvxContourItem( *this );
1760 SvStream
& SvxContourItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1762 rStrm
.WriteBool( GetValue() );
1768 SfxPoolItem
* SvxContourItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1771 rStrm
.ReadCharAsBool( bValue
);
1772 return new SvxContourItem( bValue
, Which() );
1777 bool SvxContourItem::GetPresentation
1779 SfxItemPresentation
/*ePres*/,
1780 SfxMapUnit
/*eCoreUnit*/,
1781 SfxMapUnit
/*ePresUnit*/,
1782 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1785 sal_uInt16 nId
= RID_SVXITEMS_CONTOUR_FALSE
;
1788 nId
= RID_SVXITEMS_CONTOUR_TRUE
;
1789 rText
= EE_RESSTR(nId
);
1793 // class SvxPropSizeItem -------------------------------------------------
1795 SvxPropSizeItem::SvxPropSizeItem( const sal_uInt16 nPercent
, const sal_uInt16 nId
) :
1796 SfxUInt16Item( nId
, nPercent
)
1802 SfxPoolItem
* SvxPropSizeItem::Clone( SfxItemPool
* ) const
1804 return new SvxPropSizeItem( *this );
1809 SvStream
& SvxPropSizeItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1811 rStrm
.WriteUInt16( GetValue() );
1817 SfxPoolItem
* SvxPropSizeItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1820 rStrm
.ReadUInt16( nSize
);
1821 return new SvxPropSizeItem( nSize
, Which() );
1826 bool SvxPropSizeItem::GetPresentation
1828 SfxItemPresentation
/*ePres*/,
1829 SfxMapUnit
/*eCoreUnit*/,
1830 SfxMapUnit
/*ePresUnit*/,
1831 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1838 // class SvxBackgroundColorItem -----------------------------------------
1840 SvxBackgroundColorItem::SvxBackgroundColorItem( const sal_uInt16 nId
) :
1847 SvxBackgroundColorItem::SvxBackgroundColorItem( const Color
& rCol
,
1848 const sal_uInt16 nId
) :
1849 SvxColorItem( rCol
, nId
)
1853 SvxBackgroundColorItem::SvxBackgroundColorItem(SvStream
& rStrm
, const sal_uInt16 nId
)
1861 SvxBackgroundColorItem::SvxBackgroundColorItem( const SvxBackgroundColorItem
& rCopy
) :
1862 SvxColorItem( rCopy
)
1866 SfxPoolItem
* SvxBackgroundColorItem::Clone( SfxItemPool
* ) const
1868 return new SvxBackgroundColorItem(*this);
1871 SvStream
& SvxBackgroundColorItem::Store(SvStream
& rStrm
, sal_uInt16
) const
1873 GetValue().Write(rStrm
);
1877 SfxPoolItem
* SvxBackgroundColorItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1879 return new SvxBackgroundColorItem( rStrm
, Which() );
1882 bool SvxBackgroundColorItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1884 nMemberId
&= ~CONVERT_TWIPS
;
1885 Color aColor
= SvxColorItem::GetValue();
1889 case MID_GRAPHIC_TRANSPARENT
:
1891 rVal
<<= Bool2Any (aColor
.GetTransparency() == 0xff);
1896 rVal
<<= (sal_Int32
)(aColor
.GetColor());
1903 bool SvxBackgroundColorItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1905 nMemberId
&= ~CONVERT_TWIPS
;
1906 sal_Int32 nColor
= 0;
1907 Color aColor
= SvxColorItem::GetValue();
1911 case MID_GRAPHIC_TRANSPARENT
:
1913 aColor
.SetTransparency( Any2Bool( rVal
) ? 0xff : 0 );
1914 SvxColorItem::SetValue( aColor
);
1919 if(!(rVal
>>= nColor
))
1921 SvxColorItem::SetValue( Color(nColor
) );
1928 // class SvxColorItem ----------------------------------------------------
1929 SvxColorItem::SvxColorItem( const sal_uInt16 nId
) :
1935 SvxColorItem::SvxColorItem( const Color
& rCol
, const sal_uInt16 nId
) :
1941 SvxColorItem::SvxColorItem( SvStream
&rStrm
, const sal_uInt16 nId
) :
1945 ReadColor( rStrm
, aColor
);
1949 SvxColorItem::SvxColorItem( const SvxColorItem
&rCopy
) :
1950 SfxPoolItem( rCopy
),
1951 mColor( rCopy
.mColor
)
1955 SvxColorItem::~SvxColorItem()
1959 sal_uInt16
SvxColorItem::GetVersion( sal_uInt16 nFFVer
) const
1961 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
1962 SOFFICE_FILEFORMAT_40
==nFFVer
||
1963 SOFFICE_FILEFORMAT_50
==nFFVer
,
1964 "SvxColorItem: Is there a new file format? ");
1965 return SOFFICE_FILEFORMAT_50
>= nFFVer
? VERSION_USEAUTOCOLOR
: 0;
1968 bool SvxColorItem::operator==( const SfxPoolItem
& rAttr
) const
1970 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1972 return mColor
== static_cast<const SvxColorItem
&>( rAttr
).mColor
;
1975 bool SvxColorItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
1977 rVal
<<= (sal_Int32
)(mColor
.GetColor());
1981 bool SvxColorItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
1983 sal_Int32 nColor
= 0;
1984 if(!(rVal
>>= nColor
))
1987 mColor
.SetColor( nColor
);
1991 SfxPoolItem
* SvxColorItem::Clone( SfxItemPool
* ) const
1993 return new SvxColorItem( *this );
1996 SvStream
& SvxColorItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
1998 if( VERSION_USEAUTOCOLOR
== nItemVersion
&&
1999 COL_AUTO
== mColor
.GetColor() )
2000 WriteColor( rStrm
, Color( COL_BLACK
) );
2002 WriteColor( rStrm
, mColor
);
2006 SfxPoolItem
* SvxColorItem::Create(SvStream
& rStrm
, sal_uInt16
/*nVer*/ ) const
2008 return new SvxColorItem( rStrm
, Which() );
2011 bool SvxColorItem::GetPresentation
2013 SfxItemPresentation
/*ePres*/,
2014 SfxMapUnit
/*eCoreUnit*/,
2015 SfxMapUnit
/*ePresUnit*/,
2016 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2019 rText
= ::GetColorString( mColor
);
2025 void SvxColorItem::SetValue( const Color
& rNewCol
)
2030 // class SvxCharSetColorItem ---------------------------------------------
2032 SvxCharSetColorItem::SvxCharSetColorItem( const sal_uInt16 nId
) :
2033 SvxColorItem( nId
),
2035 eFrom( RTL_TEXTENCODING_DONTKNOW
)
2041 SvxCharSetColorItem::SvxCharSetColorItem( const Color
& rCol
,
2042 const rtl_TextEncoding _eFrom
,
2043 const sal_uInt16 nId
) :
2044 SvxColorItem( rCol
, nId
),
2053 SfxPoolItem
* SvxCharSetColorItem::Clone( SfxItemPool
* ) const
2055 return new SvxCharSetColorItem( *this );
2060 SvStream
& SvxCharSetColorItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2062 rStrm
.WriteUChar( GetSOStoreTextEncoding(GetCharSet()) );
2063 WriteColor( rStrm
, GetValue() );
2069 SfxPoolItem
* SvxCharSetColorItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2073 rStrm
.ReadUChar( cSet
);
2074 ReadColor( rStrm
, aColor
);
2075 return new SvxCharSetColorItem( aColor
, (rtl_TextEncoding
)cSet
, Which() );
2080 bool SvxCharSetColorItem::GetPresentation
2082 SfxItemPresentation
/*ePres*/,
2083 SfxMapUnit
/*eCoreUnit*/,
2084 SfxMapUnit
/*ePresUnit*/,
2085 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2092 // class SvxKerningItem --------------------------------------------------
2094 SvxKerningItem::SvxKerningItem( const short nKern
, const sal_uInt16 nId
) :
2095 SfxInt16Item( nId
, nKern
)
2101 SfxPoolItem
* SvxKerningItem::Clone( SfxItemPool
* ) const
2103 return new SvxKerningItem( *this );
2108 SvStream
& SvxKerningItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2110 rStrm
.WriteInt16( GetValue() );
2116 bool SvxKerningItem::ScaleMetrics( long nMult
, long nDiv
)
2118 SetValue( (sal_Int16
)Scale( GetValue(), nMult
, nDiv
) );
2124 bool SvxKerningItem::HasMetrics() const
2131 SfxPoolItem
* SvxKerningItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2134 rStrm
.ReadInt16( nValue
);
2135 return new SvxKerningItem( nValue
, Which() );
2140 bool SvxKerningItem::GetPresentation
2142 SfxItemPresentation ePres
,
2143 SfxMapUnit eCoreUnit
,
2144 SfxMapUnit
/*ePresUnit*/,
2145 OUString
& rText
, const IntlWrapper
*pIntl
2150 case SFX_ITEM_PRESENTATION_NAMELESS
:
2151 rText
= GetMetricText( (long)GetValue(), eCoreUnit
, SFX_MAPUNIT_POINT
, pIntl
) +
2152 " " + EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT
));
2154 case SFX_ITEM_PRESENTATION_COMPLETE
:
2156 rText
= EE_RESSTR(RID_SVXITEMS_KERNING_COMPLETE
);
2159 if ( GetValue() > 0 )
2160 nId
= RID_SVXITEMS_KERNING_EXPANDED
;
2161 else if ( GetValue() < 0 )
2162 nId
= RID_SVXITEMS_KERNING_CONDENSED
;
2165 rText
+= EE_RESSTR(nId
);
2167 GetMetricText( (long)GetValue(), eCoreUnit
, SFX_MAPUNIT_POINT
, pIntl
) +
2168 " " + EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT
));
2171 default: ; //prevent warning
2176 bool SvxKerningItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2178 sal_Int16 nVal
= GetValue();
2179 if(nMemberId
& CONVERT_TWIPS
)
2180 nVal
= (sal_Int16
)convertTwipToMm100(nVal
);
2185 bool SvxKerningItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2187 sal_Int16 nVal
= sal_Int16();
2188 if(!(rVal
>>= nVal
))
2190 if(nMemberId
& CONVERT_TWIPS
)
2191 nVal
= (sal_Int16
)convertMm100ToTwip(nVal
);
2196 // class SvxCaseMapItem --------------------------------------------------
2198 SvxCaseMapItem::SvxCaseMapItem( const SvxCaseMap eMap
, const sal_uInt16 nId
) :
2199 SfxEnumItem( nId
, (sal_uInt16
)eMap
)
2205 sal_uInt16
SvxCaseMapItem::GetValueCount() const
2207 return SVX_CASEMAP_END
; // SVX_CASEMAP_KAPITAELCHEN + 1
2212 SfxPoolItem
* SvxCaseMapItem::Clone( SfxItemPool
* ) const
2214 return new SvxCaseMapItem( *this );
2219 SvStream
& SvxCaseMapItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2221 rStrm
.WriteUChar( GetValue() );
2227 SfxPoolItem
* SvxCaseMapItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2230 rStrm
.ReadUChar( cMap
);
2231 return new SvxCaseMapItem( (const SvxCaseMap
)cMap
, Which() );
2236 bool SvxCaseMapItem::GetPresentation
2238 SfxItemPresentation
/*ePres*/,
2239 SfxMapUnit
/*eCoreUnit*/,
2240 SfxMapUnit
/*ePresUnit*/,
2241 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2244 rText
= GetValueTextByPos( GetValue() );
2250 OUString
SvxCaseMapItem::GetValueTextByPos( sal_uInt16 nPos
) const
2252 DBG_ASSERT( nPos
< (sal_uInt16
)SVX_CASEMAP_END
, "enum overflow!" );
2253 return EE_RESSTR(RID_SVXITEMS_CASEMAP_BEGIN
+ nPos
);
2256 bool SvxCaseMapItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
2258 sal_Int16 nRet
= style::CaseMap::NONE
;
2259 switch( GetValue() )
2261 case SVX_CASEMAP_VERSALIEN
: nRet
= style::CaseMap::UPPERCASE
; break;
2262 case SVX_CASEMAP_GEMEINE
: nRet
= style::CaseMap::LOWERCASE
; break;
2263 case SVX_CASEMAP_TITEL
: nRet
= style::CaseMap::TITLE
; break;
2264 case SVX_CASEMAP_KAPITAELCHEN
: nRet
= style::CaseMap::SMALLCAPS
; break;
2266 rVal
<<= (sal_Int16
)(nRet
);
2270 bool SvxCaseMapItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
2272 sal_uInt16 nVal
= sal_uInt16();
2273 if(!(rVal
>>= nVal
))
2278 case style::CaseMap::NONE
: nVal
= SVX_CASEMAP_NOT_MAPPED
; break;
2279 case style::CaseMap::UPPERCASE
: nVal
= SVX_CASEMAP_VERSALIEN
; break;
2280 case style::CaseMap::LOWERCASE
: nVal
= SVX_CASEMAP_GEMEINE
; break;
2281 case style::CaseMap::TITLE
: nVal
= SVX_CASEMAP_TITEL
; break;
2282 case style::CaseMap::SMALLCAPS
: nVal
= SVX_CASEMAP_KAPITAELCHEN
; break;
2288 // class SvxEscapementItem -----------------------------------------------
2290 SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId
) :
2291 SfxEnumItemInterface( nId
),
2300 SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape
,
2301 const sal_uInt16 nId
) :
2302 SfxEnumItemInterface( nId
),
2305 SetEscapement( eEscape
);
2312 SvxEscapementItem::SvxEscapementItem( const short _nEsc
,
2313 const sal_uInt8 _nProp
,
2314 const sal_uInt16 nId
) :
2315 SfxEnumItemInterface( nId
),
2323 bool SvxEscapementItem::operator==( const SfxPoolItem
& rAttr
) const
2325 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
2327 return( nEsc
== static_cast<const SvxEscapementItem
&>(rAttr
).nEsc
&&
2328 nProp
== static_cast<const SvxEscapementItem
&>(rAttr
).nProp
);
2333 SfxPoolItem
* SvxEscapementItem::Clone( SfxItemPool
* ) const
2335 return new SvxEscapementItem( *this );
2340 SvStream
& SvxEscapementItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2342 short _nEsc
= GetEsc();
2343 if( SOFFICE_FILEFORMAT_31
== rStrm
.GetVersion() )
2345 if( DFLT_ESC_AUTO_SUPER
== _nEsc
)
2346 _nEsc
= DFLT_ESC_SUPER
;
2347 else if( DFLT_ESC_AUTO_SUB
== _nEsc
)
2348 _nEsc
= DFLT_ESC_SUB
;
2350 rStrm
.WriteUChar( GetProp() )
2351 .WriteInt16( _nEsc
);
2357 SfxPoolItem
* SvxEscapementItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2361 rStrm
.ReadUChar( _nProp
).ReadInt16( _nEsc
);
2362 return new SvxEscapementItem( _nEsc
, _nProp
, Which() );
2367 sal_uInt16
SvxEscapementItem::GetValueCount() const
2369 return SVX_ESCAPEMENT_END
; // SVX_ESCAPEMENT_SUBSCRIPT + 1
2374 bool SvxEscapementItem::GetPresentation
2376 SfxItemPresentation
/*ePres*/,
2377 SfxMapUnit
/*eCoreUnit*/,
2378 SfxMapUnit
/*ePresUnit*/,
2379 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2382 rText
= GetValueTextByPos( GetEnumValue() );
2386 if( DFLT_ESC_AUTO_SUPER
== nEsc
|| DFLT_ESC_AUTO_SUB
== nEsc
)
2387 rText
+= EE_RESSTR(RID_SVXITEMS_ESCAPEMENT_AUTO
);
2389 rText
= rText
+ OUString::number( nEsc
) + "%";
2396 OUString
SvxEscapementItem::GetValueTextByPos( sal_uInt16 nPos
) const
2398 DBG_ASSERT( nPos
< (sal_uInt16
)SVX_ESCAPEMENT_END
, "enum overflow!" );
2399 return EE_RESSTR(RID_SVXITEMS_ESCAPEMENT_BEGIN
+ nPos
);
2404 sal_uInt16
SvxEscapementItem::GetEnumValue() const
2407 return SVX_ESCAPEMENT_SUBSCRIPT
;
2408 else if ( nEsc
> 0 )
2409 return SVX_ESCAPEMENT_SUPERSCRIPT
;
2410 return SVX_ESCAPEMENT_OFF
;
2415 void SvxEscapementItem::SetEnumValue( sal_uInt16 nVal
)
2417 SetEscapement( (const SvxEscapement
)nVal
);
2420 bool SvxEscapementItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2422 nMemberId
&= ~CONVERT_TWIPS
;
2426 rVal
<<= (sal_Int16
)(nEsc
);
2428 case MID_ESC_HEIGHT
:
2429 rVal
<<= (sal_Int8
)(nProp
);
2432 rVal
= Bool2Any(DFLT_ESC_AUTO_SUB
== nEsc
|| DFLT_ESC_AUTO_SUPER
== nEsc
);
2438 bool SvxEscapementItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2440 nMemberId
&= ~CONVERT_TWIPS
;
2445 sal_Int16 nVal
= sal_Int16();
2446 if( (rVal
>>= nVal
) && (std::abs(nVal
) <= 101))
2452 case MID_ESC_HEIGHT
:
2454 sal_Int8 nVal
= sal_Int8();
2455 if( (rVal
>>= nVal
) && (nVal
<= 100))
2463 bool bVal
= Any2Bool(rVal
);
2467 nEsc
= DFLT_ESC_AUTO_SUB
;
2469 nEsc
= DFLT_ESC_AUTO_SUPER
;
2472 if(DFLT_ESC_AUTO_SUPER
== nEsc
)
2474 else if(DFLT_ESC_AUTO_SUB
== nEsc
)
2482 // class SvxLanguageItem -------------------------------------------------
2484 SvxLanguageItem::SvxLanguageItem( const LanguageType eLang
, const sal_uInt16 nId
)
2485 : SfxEnumItem( nId
, eLang
)
2491 sal_uInt16
SvxLanguageItem::GetValueCount() const
2493 // #i50205# got rid of class International
2494 SAL_WARN( "editeng.items", "SvxLanguageItem::GetValueCount: supposed to return a count of what?");
2495 // FIXME: previously returned LANGUAGE_COUNT from tools/intn.hxx which was wrong anyway.
2496 // Could be SvtLanguageTable::GetEntryCount() (all locales with resource string)?
2497 // Could be LocaleDataWrapper::getInstalledLanguageTypes() (all locales with locale data)?
2503 SfxPoolItem
* SvxLanguageItem::Clone( SfxItemPool
* ) const
2505 return new SvxLanguageItem( *this );
2510 SvStream
& SvxLanguageItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2512 rStrm
.WriteUInt16( GetValue() );
2518 SfxPoolItem
* SvxLanguageItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2521 rStrm
.ReadUInt16( nValue
);
2522 return new SvxLanguageItem( (LanguageType
)nValue
, Which() );
2527 bool SvxLanguageItem::GetPresentation
2529 SfxItemPresentation
/*ePres*/,
2530 SfxMapUnit
/*eCoreUnit*/,
2531 SfxMapUnit
/*ePresUnit*/,
2532 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2535 rText
= SvtLanguageTable::GetLanguageString( (LanguageType
)GetValue() );
2539 bool SvxLanguageItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2541 nMemberId
&= ~CONVERT_TWIPS
;
2544 case MID_LANG_INT
: // for basic conversions!
2545 rVal
<<= (sal_Int16
)(GetValue());
2547 case MID_LANG_LOCALE
:
2548 lang::Locale
aRet( LanguageTag( GetValue()).getLocale( false));
2555 bool SvxLanguageItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2557 nMemberId
&= ~CONVERT_TWIPS
;
2560 case MID_LANG_INT
: // for basic conversions!
2562 sal_Int32 nValue
= 0;
2563 if(!(rVal
>>= nValue
))
2566 SetValue((sal_Int16
)nValue
);
2569 case MID_LANG_LOCALE
:
2571 lang::Locale aLocale
;
2572 if(!(rVal
>>= aLocale
))
2575 SetValue( LanguageTag::convertToLanguageType( aLocale
, false));
2582 // class SvxNoLinebreakItem ----------------------------------------------
2583 SvxNoLinebreakItem::SvxNoLinebreakItem( const bool bBreak
, const sal_uInt16 nId
) :
2584 SfxBoolItem( nId
, bBreak
)
2590 SfxPoolItem
* SvxNoLinebreakItem::Clone( SfxItemPool
* ) const
2592 return new SvxNoLinebreakItem( *this );
2597 SvStream
& SvxNoLinebreakItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2599 rStrm
.WriteBool( GetValue() );
2605 SfxPoolItem
* SvxNoLinebreakItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2608 rStrm
.ReadCharAsBool( bValue
);
2609 return new SvxNoLinebreakItem( bValue
, Which() );
2614 bool SvxNoLinebreakItem::GetPresentation
2616 SfxItemPresentation
/*ePres*/,
2617 SfxMapUnit
/*eCoreUnit*/,
2618 SfxMapUnit
/*ePresUnit*/,
2619 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2626 // class SvxNoHyphenItem -------------------------------------------------
2628 SvxNoHyphenItem::SvxNoHyphenItem( const bool bHyphen
, const sal_uInt16 nId
) :
2629 SfxBoolItem( nId
, bHyphen
)
2635 SfxPoolItem
* SvxNoHyphenItem::Clone( SfxItemPool
* ) const
2637 return new SvxNoHyphenItem( *this );
2642 SvStream
& SvxNoHyphenItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2644 rStrm
.WriteBool( GetValue() );
2650 SfxPoolItem
* SvxNoHyphenItem::Create( SvStream
& rStrm
, sal_uInt16
) const
2653 rStrm
.ReadCharAsBool( bValue
);
2654 return new SvxNoHyphenItem( bValue
, Which() );
2659 bool SvxNoHyphenItem::GetPresentation
2661 SfxItemPresentation
/*ePres*/,
2662 SfxMapUnit
/*eCoreUnit*/,
2663 SfxMapUnit
/*ePresUnit*/,
2664 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2672 * Dummy item for ToolBox controls:
2677 // class SvxLineColorItem (== SvxColorItem)
2680 SvxLineColorItem::SvxLineColorItem( const sal_uInt16 nId
) :
2687 SvxLineColorItem::SvxLineColorItem( const SvxLineColorItem
&rCopy
) :
2688 SvxColorItem( rCopy
)
2694 SvxLineColorItem::~SvxLineColorItem()
2700 bool SvxLineColorItem::GetPresentation
2702 SfxItemPresentation ePres
,
2703 SfxMapUnit eCoreUnit
,
2704 SfxMapUnit ePresUnit
,
2706 const IntlWrapper
* pIntlWrapper
2709 return SvxColorItem::GetPresentation( ePres
, eCoreUnit
, ePresUnit
,
2710 rText
, pIntlWrapper
);
2713 // class SvxBlinkItem -------------------------------------------------
2716 SvxBlinkItem::SvxBlinkItem( const bool bBlink
, const sal_uInt16 nId
) :
2717 SfxBoolItem( nId
, bBlink
)
2723 SfxPoolItem
* SvxBlinkItem::Clone( SfxItemPool
* ) const
2725 return new SvxBlinkItem( *this );
2730 SvStream
& SvxBlinkItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2732 rStrm
.WriteBool( GetValue() );
2738 SfxPoolItem
* SvxBlinkItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2741 rStrm
.ReadUChar( nState
);
2742 return new SvxBlinkItem( nState
, Which() );
2747 bool SvxBlinkItem::GetPresentation
2749 SfxItemPresentation
/*ePres*/,
2750 SfxMapUnit
/*eCoreUnit*/,
2751 SfxMapUnit
/*ePresUnit*/,
2752 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2755 sal_uInt16 nId
= RID_SVXITEMS_BLINK_FALSE
;
2758 nId
= RID_SVXITEMS_BLINK_TRUE
;
2759 rText
= EE_RESSTR(nId
);
2763 // class SvxEmphaisMarkItem ---------------------------------------------------
2765 SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue
,
2766 const sal_uInt16 nId
)
2767 : SfxUInt16Item( nId
, nValue
)
2773 SfxPoolItem
* SvxEmphasisMarkItem::Clone( SfxItemPool
* ) const
2775 return new SvxEmphasisMarkItem( *this );
2780 SvStream
& SvxEmphasisMarkItem::Store( SvStream
& rStrm
,
2781 sal_uInt16
/*nItemVersion*/ ) const
2783 rStrm
.WriteUInt16( GetValue() );
2789 SfxPoolItem
* SvxEmphasisMarkItem::Create( SvStream
& rStrm
, sal_uInt16
) const
2792 rStrm
.ReadUInt16( nValue
);
2793 return new SvxEmphasisMarkItem( (FontEmphasisMark
)nValue
, Which() );
2798 bool SvxEmphasisMarkItem::GetPresentation
2800 SfxItemPresentation
/*ePres*/,
2801 SfxMapUnit
/*eCoreUnit*/,
2802 SfxMapUnit
/*ePresUnit*/,
2804 const IntlWrapper
* /*pIntl*/
2807 sal_uInt16 nVal
= GetValue();
2808 rText
= EE_RESSTR( RID_SVXITEMS_EMPHASIS_BEGIN_STYLE
+
2809 ( EMPHASISMARK_STYLE
& nVal
));
2810 sal_uInt16 nId
= ( EMPHASISMARK_POS_ABOVE
& nVal
)
2811 ? RID_SVXITEMS_EMPHASIS_ABOVE_POS
2812 : ( EMPHASISMARK_POS_BELOW
& nVal
)
2813 ? RID_SVXITEMS_EMPHASIS_BELOW_POS
2816 rText
+= EE_RESSTR( nId
);
2822 bool SvxEmphasisMarkItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2824 nMemberId
&= ~CONVERT_TWIPS
;
2829 sal_Int16 nValue
= GetValue();
2831 switch(nValue
& EMPHASISMARK_STYLE
)
2833 case EMPHASISMARK_NONE
: nRet
= FontEmphasis::NONE
; break;
2834 case EMPHASISMARK_DOT
: nRet
= FontEmphasis::DOT_ABOVE
; break;
2835 case EMPHASISMARK_CIRCLE
: nRet
= FontEmphasis::CIRCLE_ABOVE
; break;
2836 case EMPHASISMARK_DISC
: nRet
= FontEmphasis::DISK_ABOVE
; break;
2837 case EMPHASISMARK_ACCENT
: nRet
= FontEmphasis::ACCENT_ABOVE
; break;
2839 if(nRet
&& nValue
& EMPHASISMARK_POS_BELOW
)
2848 bool SvxEmphasisMarkItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2850 nMemberId
&= ~CONVERT_TWIPS
;
2856 sal_Int32 nValue
= -1;
2860 case FontEmphasis::NONE
: nValue
= EMPHASISMARK_NONE
; break;
2861 case FontEmphasis::DOT_ABOVE
: nValue
= EMPHASISMARK_DOT
|EMPHASISMARK_POS_ABOVE
; break;
2862 case FontEmphasis::CIRCLE_ABOVE
: nValue
= EMPHASISMARK_CIRCLE
|EMPHASISMARK_POS_ABOVE
; break;
2863 case FontEmphasis::DISK_ABOVE
: nValue
= EMPHASISMARK_DISC
|EMPHASISMARK_POS_ABOVE
; break;
2864 case FontEmphasis::ACCENT_ABOVE
: nValue
= EMPHASISMARK_ACCENT
|EMPHASISMARK_POS_ABOVE
; break;
2865 case FontEmphasis::DOT_BELOW
: nValue
= EMPHASISMARK_DOT
|EMPHASISMARK_POS_BELOW
; break;
2866 case FontEmphasis::CIRCLE_BELOW
: nValue
= EMPHASISMARK_CIRCLE
|EMPHASISMARK_POS_BELOW
; break;
2867 case FontEmphasis::DISK_BELOW
: nValue
= EMPHASISMARK_DISC
|EMPHASISMARK_POS_BELOW
; break;
2868 case FontEmphasis::ACCENT_BELOW
: nValue
= EMPHASISMARK_ACCENT
|EMPHASISMARK_POS_BELOW
; break;
2869 default: return false;
2871 SetValue( (sal_Int16
)nValue
);
2878 sal_uInt16
SvxEmphasisMarkItem::GetVersion( sal_uInt16 nFFVer
) const
2880 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
2881 SOFFICE_FILEFORMAT_40
==nFFVer
||
2882 SOFFICE_FILEFORMAT_50
==nFFVer
,
2883 "SvxEmphasisMarkItem: Is there a new file format? ");
2885 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
2889 /*************************************************************************
2890 |* class SvxTwoLinesItem
2891 *************************************************************************/
2893 SvxTwoLinesItem::SvxTwoLinesItem( bool bFlag
, sal_Unicode nStartBracket
,
2894 sal_Unicode nEndBracket
, sal_uInt16 nW
)
2895 : SfxPoolItem( nW
),
2896 cStartBracket( nStartBracket
), cEndBracket( nEndBracket
), bOn( bFlag
)
2900 SvxTwoLinesItem::SvxTwoLinesItem( const SvxTwoLinesItem
& rAttr
)
2901 : SfxPoolItem( rAttr
.Which() ),
2902 cStartBracket( rAttr
.cStartBracket
),
2903 cEndBracket( rAttr
.cEndBracket
),
2908 SvxTwoLinesItem::~SvxTwoLinesItem()
2912 bool SvxTwoLinesItem::operator==( const SfxPoolItem
& rAttr
) const
2914 DBG_ASSERT( SfxPoolItem::operator==( rAttr
), "not equal attribute types" );
2915 return bOn
== static_cast<const SvxTwoLinesItem
&>(rAttr
).bOn
&&
2916 cStartBracket
== static_cast<const SvxTwoLinesItem
&>(rAttr
).cStartBracket
&&
2917 cEndBracket
== static_cast<const SvxTwoLinesItem
&>(rAttr
).cEndBracket
;
2920 SfxPoolItem
* SvxTwoLinesItem::Clone( SfxItemPool
* ) const
2922 return new SvxTwoLinesItem( *this );
2925 bool SvxTwoLinesItem::QueryValue( com::sun::star::uno::Any
& rVal
,
2926 sal_uInt8 nMemberId
) const
2928 nMemberId
&= ~CONVERT_TWIPS
;
2933 rVal
= Bool2Any( bOn
);
2935 case MID_START_BRACKET
:
2939 s
= OUString( cStartBracket
);
2943 case MID_END_BRACKET
:
2947 s
= OUString( cEndBracket
);
2958 bool SvxTwoLinesItem::PutValue( const com::sun::star::uno::Any
& rVal
,
2959 sal_uInt8 nMemberId
)
2961 nMemberId
&= ~CONVERT_TWIPS
;
2967 bOn
= Any2Bool( rVal
);
2970 case MID_START_BRACKET
:
2973 cStartBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
2977 case MID_END_BRACKET
:
2980 cEndBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
2988 bool SvxTwoLinesItem::GetPresentation( SfxItemPresentation
/*ePres*/,
2989 SfxMapUnit
/*eCoreMetric*/, SfxMapUnit
/*ePresMetric*/,
2990 OUString
&rText
, const IntlWrapper
* /*pIntl*/ ) const
2993 rText
= EE_RESSTR( RID_SVXITEMS_TWOLINES_OFF
);
2996 rText
= EE_RESSTR( RID_SVXITEMS_TWOLINES
);
2997 if( GetStartBracket() )
2998 rText
= OUString(GetStartBracket()) + rText
;
2999 if( GetEndBracket() )
3000 rText
+= OUString(GetEndBracket());
3006 SfxPoolItem
* SvxTwoLinesItem::Create( SvStream
& rStrm
, sal_uInt16
/*nVer*/) const
3009 sal_Unicode cStart
, cEnd
;
3010 rStrm
.ReadCharAsBool( _bOn
).ReadUInt16( cStart
).ReadUInt16( cEnd
);
3011 return new SvxTwoLinesItem( _bOn
, cStart
, cEnd
, Which() );
3014 SvStream
& SvxTwoLinesItem::Store(SvStream
& rStrm
, sal_uInt16
/*nIVer*/) const
3016 rStrm
.WriteBool( GetValue() ).WriteUInt16( GetStartBracket() ).WriteUInt16( GetEndBracket() );
3020 sal_uInt16
SvxTwoLinesItem::GetVersion( sal_uInt16 nFFVer
) const
3022 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
3023 SOFFICE_FILEFORMAT_40
==nFFVer
||
3024 SOFFICE_FILEFORMAT_50
==nFFVer
,
3025 "SvxTwoLinesItem: Gibt es ein neues Fileformat?" );
3027 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
3031 /*************************************************************************
3032 |* class SvxCharRotateItem
3033 *************************************************************************/
3035 SvxCharRotateItem::SvxCharRotateItem( sal_uInt16 nValue
,
3037 const sal_uInt16 nW
)
3038 : SfxUInt16Item( nW
, nValue
), bFitToLine( bFitIntoLine
)
3042 SfxPoolItem
* SvxCharRotateItem::Clone( SfxItemPool
* ) const
3044 return new SvxCharRotateItem( GetValue(), IsFitToLine(), Which() );
3047 SfxPoolItem
* SvxCharRotateItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3051 rStrm
.ReadUInt16( nVal
).ReadCharAsBool( b
);
3052 return new SvxCharRotateItem( nVal
, b
, Which() );
3055 SvStream
& SvxCharRotateItem::Store( SvStream
& rStrm
, sal_uInt16
) const
3057 bool bFlag
= IsFitToLine();
3058 rStrm
.WriteUInt16( GetValue() ).WriteBool( bFlag
);
3062 sal_uInt16
SvxCharRotateItem::GetVersion( sal_uInt16 nFFVer
) const
3064 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
3067 bool SvxCharRotateItem::GetPresentation(
3068 SfxItemPresentation
/*ePres*/,
3069 SfxMapUnit
/*eCoreMetric*/, SfxMapUnit
/*ePresMetric*/,
3070 OUString
&rText
, const IntlWrapper
* ) const
3073 rText
= EE_RESSTR( RID_SVXITEMS_CHARROTATE_OFF
);
3076 rText
= EE_RESSTR( RID_SVXITEMS_CHARROTATE
);
3077 rText
= rText
.replaceFirst( "$(ARG1)",
3078 OUString::number( GetValue() / 10 ));
3080 rText
+= EE_RESSTR( RID_SVXITEMS_CHARROTATE_FITLINE
);
3085 bool SvxCharRotateItem::QueryValue( com::sun::star::uno::Any
& rVal
,
3086 sal_uInt8 nMemberId
) const
3088 nMemberId
&= ~CONVERT_TWIPS
;
3093 rVal
<<= (sal_Int16
)GetValue();
3096 rVal
= Bool2Any( IsFitToLine() );
3105 bool SvxCharRotateItem::PutValue( const com::sun::star::uno::Any
& rVal
,
3106 sal_uInt8 nMemberId
)
3108 nMemberId
&= ~CONVERT_TWIPS
;
3115 if((rVal
>>= nVal
) && (0 == nVal
|| 900 == nVal
|| 2700 == nVal
))
3116 SetValue( (sal_uInt16
)nVal
);
3123 SetFitToLine( Any2Bool( rVal
) );
3131 bool SvxCharRotateItem::operator==( const SfxPoolItem
& rItem
) const
3133 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
3134 return SfxUInt16Item::operator==( rItem
) &&
3135 IsFitToLine() == static_cast<const SvxCharRotateItem
&>(rItem
).IsFitToLine();
3138 void SvxCharRotateItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
3140 xmlTextWriterStartElement(pWriter
, BAD_CAST("svxCharRotateItem"));
3141 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
3142 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
3143 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("fitToLine"), BAD_CAST(OString::boolean(IsFitToLine()).getStr()));
3144 xmlTextWriterEndElement(pWriter
);
3147 /*************************************************************************
3148 |* class SvxCharScaleItem
3149 *************************************************************************/
3151 SvxCharScaleWidthItem::SvxCharScaleWidthItem( sal_uInt16 nValue
,
3152 const sal_uInt16 nW
)
3153 : SfxUInt16Item( nW
, nValue
)
3157 SfxPoolItem
* SvxCharScaleWidthItem::Clone( SfxItemPool
* ) const
3159 return new SvxCharScaleWidthItem( GetValue(), Which() );
3162 SfxPoolItem
* SvxCharScaleWidthItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3165 rStrm
.ReadUInt16( nVal
);
3166 SvxCharScaleWidthItem
* pItem
= new SvxCharScaleWidthItem( nVal
, Which() );
3168 if ( Which() == EE_CHAR_FONTWIDTH
)
3170 // Was a SvxFontWidthItem in 5.2
3171 // sal_uInt16 nFixWidth, sal_uInt16 nPropWidth.
3172 // nFixWidth has never been used...
3173 rStrm
.ReadUInt16( nVal
);
3175 rStrm
.ReadUInt16( nTest
);
3176 if ( nTest
== 0x1234 )
3177 pItem
->SetValue( nVal
);
3179 rStrm
.SeekRel( -2*(long)sizeof(sal_uInt16
) );
3185 SvStream
& SvxCharScaleWidthItem::Store( SvStream
& rStream
, sal_uInt16 nVer
) const
3187 SvStream
& rRet
= SfxUInt16Item::Store( rStream
, nVer
);
3188 if ( Which() == EE_CHAR_FONTWIDTH
)
3190 // see comment in Create()....
3191 rRet
.SeekRel( -1*(long)sizeof(sal_uInt16
) );
3192 rRet
.WriteUInt16( 0 );
3193 rRet
.WriteUInt16( GetValue() );
3194 // Really ugly, but not a problem for reading the doc in 5.2
3195 rRet
.WriteUInt16( 0x1234 );
3201 sal_uInt16
SvxCharScaleWidthItem::GetVersion( sal_uInt16 nFFVer
) const
3203 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
3206 bool SvxCharScaleWidthItem::GetPresentation(
3207 SfxItemPresentation
/*ePres*/,
3208 SfxMapUnit
/*eCoreMetric*/, SfxMapUnit
/*ePresMetric*/,
3209 OUString
&rText
, const IntlWrapper
* ) const
3212 rText
= EE_RESSTR( RID_SVXITEMS_CHARSCALE_OFF
);
3215 rText
= EE_RESSTR( RID_SVXITEMS_CHARSCALE
);
3216 rText
= rText
.replaceFirst( "$(ARG1)",
3217 OUString::number( GetValue() ));
3222 bool SvxCharScaleWidthItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
3224 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
3225 // where we still want this to be a sal_Int16
3226 sal_Int16 nValue
= sal_Int16();
3227 if (rVal
>>= nValue
)
3229 SetValue( (sal_uInt16
) nValue
);
3233 OSL_TRACE( "SvxCharScaleWidthItem::PutValue - Wrong type!" );
3237 bool SvxCharScaleWidthItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
3239 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
3240 // where we still want this to be a sal_Int16
3241 rVal
<<= (sal_Int16
)GetValue();
3245 /*************************************************************************
3246 |* class SvxCharReliefItem
3247 *************************************************************************/
3249 SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue
,
3250 const sal_uInt16 nId
)
3251 : SfxEnumItem( nId
, (sal_uInt16
)eValue
)
3255 SfxPoolItem
* SvxCharReliefItem::Clone( SfxItemPool
* ) const
3257 return new SvxCharReliefItem( *this );
3260 SfxPoolItem
* SvxCharReliefItem::Create(SvStream
& rStrm
, sal_uInt16
) const
3263 rStrm
.ReadUInt16( nVal
);
3264 return new SvxCharReliefItem( (FontRelief
)nVal
, Which() );
3267 SvStream
& SvxCharReliefItem::Store(SvStream
& rStrm
, sal_uInt16
/*nIVer*/) const
3269 sal_uInt16 nVal
= GetValue();
3270 rStrm
.WriteUInt16( nVal
);
3274 sal_uInt16
SvxCharReliefItem::GetVersion( sal_uInt16 nFFVer
) const
3276 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
3279 OUString
SvxCharReliefItem::GetValueTextByPos( sal_uInt16 nPos
) const
3281 DBG_ASSERT( nPos
< RID_SVXITEMS_RELIEF_ENGRAVED
- RID_SVXITEMS_RELIEF_NONE
,
3283 return EE_RESSTR(RID_SVXITEMS_RELIEF_BEGIN
+ nPos
);
3286 sal_uInt16
SvxCharReliefItem::GetValueCount() const
3288 return RID_SVXITEMS_RELIEF_ENGRAVED
- RID_SVXITEMS_RELIEF_NONE
;
3291 bool SvxCharReliefItem::GetPresentation
3293 SfxItemPresentation
/*ePres*/,
3294 SfxMapUnit
/*eCoreUnit*/,
3295 SfxMapUnit
/*ePresUnit*/,
3296 OUString
& rText
, const IntlWrapper
* /*pIntl*/
3299 rText
= GetValueTextByPos( GetValue() );
3303 bool SvxCharReliefItem::PutValue( const com::sun::star::uno::Any
& rVal
,
3304 sal_uInt8 nMemberId
)
3306 nMemberId
&= ~CONVERT_TWIPS
;
3312 sal_Int16 nVal
= -1;
3314 if(nVal
>= 0 && nVal
<= RELIEF_ENGRAVED
)
3315 SetValue( (sal_uInt16
)nVal
);
3327 bool SvxCharReliefItem::QueryValue( com::sun::star::uno::Any
& rVal
,
3328 sal_uInt8 nMemberId
) const
3330 nMemberId
&= ~CONVERT_TWIPS
;
3335 rVal
<<= (sal_Int16
)GetValue();
3344 /*************************************************************************
3345 |* class SvxScriptTypeItemItem
3346 *************************************************************************/
3348 SvxScriptTypeItem::SvxScriptTypeItem( SvtScriptType nType
)
3349 : SfxUInt16Item( SID_ATTR_CHAR_SCRIPTTYPE
, static_cast<sal_uInt16
>(nType
) )
3352 SfxPoolItem
* SvxScriptTypeItem::Clone( SfxItemPool
* ) const
3354 return new SvxScriptTypeItem( static_cast<SvtScriptType
>(GetValue()) );
3357 /*************************************************************************
3358 |* class SvxScriptSetItem
3359 *************************************************************************/
3361 SvxScriptSetItem::SvxScriptSetItem( sal_uInt16 nSlotId
, SfxItemPool
& rPool
)
3362 : SfxSetItem( nSlotId
, new SfxItemSet( rPool
,
3363 SID_ATTR_CHAR_FONT
, SID_ATTR_CHAR_FONT
))
3365 sal_uInt16 nLatin
, nAsian
, nComplex
;
3366 GetWhichIds( nLatin
, nAsian
, nComplex
);
3367 GetItemSet().MergeRange( nLatin
, nLatin
);
3368 GetItemSet().MergeRange( nAsian
, nAsian
);
3369 GetItemSet().MergeRange( nComplex
, nComplex
);
3370 GetItemSet().MergeRange( SID_ATTR_CHAR_SCRIPTTYPE
, SID_ATTR_CHAR_SCRIPTTYPE
);
3373 SfxPoolItem
* SvxScriptSetItem::Clone( SfxItemPool
* ) const
3375 SvxScriptSetItem
* p
= new SvxScriptSetItem( Which(), *GetItemSet().GetPool() );
3376 p
->GetItemSet().Put( GetItemSet(), false );
3380 SfxPoolItem
* SvxScriptSetItem::Create( SvStream
&, sal_uInt16
) const
3385 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScriptSet(
3386 const SfxItemSet
& rSet
, sal_uInt16 nId
)
3388 const SfxPoolItem
* pI
;
3389 SfxItemState eSt
= rSet
.GetItemState( nId
, false, &pI
);
3390 if( SfxItemState::SET
!= eSt
)
3391 pI
= SfxItemState::DEFAULT
== eSt
? &rSet
.Get( nId
) : 0;
3395 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, SvtScriptType nScript
)
3397 sal_uInt16 nLatin
, nAsian
, nComplex
;
3398 GetWhichIds( nSlotId
, rSet
, nLatin
, nAsian
, nComplex
);
3400 const SfxPoolItem
*pRet
, *pAsn
, *pCmplx
;
3401 if (nScript
== SvtScriptType::ASIAN
)
3403 pRet
= GetItemOfScriptSet( rSet
, nAsian
);
3404 } else if (nScript
== SvtScriptType::COMPLEX
)
3406 pRet
= GetItemOfScriptSet( rSet
, nComplex
);
3407 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::ASIAN
))
3409 if( 0 == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
3410 0 == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
3413 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::COMPLEX
))
3415 if( 0 == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
3416 0 == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
3419 } else if (nScript
== (SvtScriptType::ASIAN
|SvtScriptType::COMPLEX
))
3421 if( 0 == (pRet
= GetItemOfScriptSet( rSet
, nAsian
)) ||
3422 0 == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
3425 } else if (nScript
== (SvtScriptType::LATIN
|SvtScriptType::ASIAN
|SvtScriptType::COMPLEX
))
3427 if( 0 == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
3428 0 == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
3429 0 == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
3430 *pRet
!= *pAsn
|| *pRet
!= *pCmplx
)
3433 //no one valid -> match to latin
3434 pRet
= GetItemOfScriptSet( rSet
, nLatin
);
3439 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( SvtScriptType nScript
) const
3441 return GetItemOfScript( Which(), GetItemSet(), nScript
);
3444 void SvxScriptSetItem::PutItemForScriptType( SvtScriptType nScriptType
,
3445 const SfxPoolItem
& rItem
)
3447 sal_uInt16 nLatin
, nAsian
, nComplex
;
3448 GetWhichIds( nLatin
, nAsian
, nComplex
);
3450 SfxPoolItem
* pCpy
= rItem
.Clone();
3451 if( SvtScriptType::LATIN
& nScriptType
)
3453 pCpy
->SetWhich( nLatin
);
3454 GetItemSet().Put( *pCpy
);
3456 if( SvtScriptType::ASIAN
& nScriptType
)
3458 pCpy
->SetWhich( nAsian
);
3459 GetItemSet().Put( *pCpy
);
3461 if( SvtScriptType::COMPLEX
& nScriptType
)
3463 pCpy
->SetWhich( nComplex
);
3464 GetItemSet().Put( *pCpy
);
3469 void SvxScriptSetItem::GetWhichIds( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, sal_uInt16
& rLatin
, sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
3471 const SfxItemPool
& rPool
= *rSet
.GetPool();
3472 GetSlotIds( nSlotId
, rLatin
, rAsian
, rComplex
);
3473 rLatin
= rPool
.GetWhich( rLatin
);
3474 rAsian
= rPool
.GetWhich( rAsian
);
3475 rComplex
= rPool
.GetWhich( rComplex
);
3478 void SvxScriptSetItem::GetWhichIds( sal_uInt16
& rLatin
, sal_uInt16
& rAsian
,
3479 sal_uInt16
& rComplex
) const
3481 GetWhichIds( Which(), GetItemSet(), rLatin
, rAsian
, rComplex
);
3484 void SvxScriptSetItem::GetSlotIds( sal_uInt16 nSlotId
, sal_uInt16
& rLatin
,
3485 sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
3490 DBG_ASSERT( false, "wrong SlotId for class SvxScriptSetItem" );
3491 // no break - default to font - Id Range !!
3493 case SID_ATTR_CHAR_FONT
:
3494 rLatin
= SID_ATTR_CHAR_FONT
;
3495 rAsian
= SID_ATTR_CHAR_CJK_FONT
;
3496 rComplex
= SID_ATTR_CHAR_CTL_FONT
;
3498 case SID_ATTR_CHAR_FONTHEIGHT
:
3499 rLatin
= SID_ATTR_CHAR_FONTHEIGHT
;
3500 rAsian
= SID_ATTR_CHAR_CJK_FONTHEIGHT
;
3501 rComplex
= SID_ATTR_CHAR_CTL_FONTHEIGHT
;
3503 case SID_ATTR_CHAR_WEIGHT
:
3504 rLatin
= SID_ATTR_CHAR_WEIGHT
;
3505 rAsian
= SID_ATTR_CHAR_CJK_WEIGHT
;
3506 rComplex
= SID_ATTR_CHAR_CTL_WEIGHT
;
3508 case SID_ATTR_CHAR_POSTURE
:
3509 rLatin
= SID_ATTR_CHAR_POSTURE
;
3510 rAsian
= SID_ATTR_CHAR_CJK_POSTURE
;
3511 rComplex
= SID_ATTR_CHAR_CTL_POSTURE
;
3513 case SID_ATTR_CHAR_LANGUAGE
:
3514 rLatin
= SID_ATTR_CHAR_LANGUAGE
;
3515 rAsian
= SID_ATTR_CHAR_CJK_LANGUAGE
;
3516 rComplex
= SID_ATTR_CHAR_CTL_LANGUAGE
;
3518 case SID_ATTR_CHAR_SHADOWED
:
3519 rLatin
= SID_ATTR_CHAR_SHADOWED
;
3520 rAsian
= SID_ATTR_CHAR_SHADOWED
;
3521 rComplex
= SID_ATTR_CHAR_SHADOWED
;
3523 case SID_ATTR_CHAR_STRIKEOUT
:
3524 rLatin
= SID_ATTR_CHAR_STRIKEOUT
;
3525 rAsian
= SID_ATTR_CHAR_STRIKEOUT
;
3526 rComplex
= SID_ATTR_CHAR_STRIKEOUT
;
3531 void GetDefaultFonts( SvxFontItem
& rLatin
, SvxFontItem
& rAsian
, SvxFontItem
& rComplex
)
3533 const sal_uInt16 nItemCnt
= 3;
3537 DefaultFontType nFontType
;
3538 sal_uInt16 nLanguage
;
3540 aOutTypeArr
[ nItemCnt
] =
3542 { DefaultFontType::LATIN_TEXT
, LANGUAGE_ENGLISH_US
},
3543 { DefaultFontType::CJK_TEXT
, LANGUAGE_ENGLISH_US
},
3544 { DefaultFontType::CTL_TEXT
, LANGUAGE_ARABIC_SAUDI_ARABIA
}
3547 SvxFontItem
* aItemArr
[ nItemCnt
] = { &rLatin
, &rAsian
, &rComplex
};
3549 for ( sal_uInt16 n
= 0; n
< nItemCnt
; ++n
)
3551 vcl::Font
aFont( OutputDevice::GetDefaultFont( aOutTypeArr
[ n
].nFontType
,
3552 aOutTypeArr
[ n
].nLanguage
,
3553 GetDefaultFontFlags::OnlyOne
, 0 ) );
3554 SvxFontItem
* pItem
= aItemArr
[ n
];
3555 pItem
->SetFamily( aFont
.GetFamily() );
3556 pItem
->SetFamilyName( aFont
.GetName() );
3557 pItem
->SetStyleName( OUString() );
3558 pItem
->SetPitch( aFont
.GetPitch());
3559 pItem
->SetCharSet(aFont
.GetCharSet());
3564 bool SvxRsidItem::QueryValue( uno::Any
& rVal
, sal_uInt8
) const
3566 rVal
<<= ( (sal_uInt32
)GetValue() );
3570 bool SvxRsidItem::PutValue( const uno::Any
& rVal
, sal_uInt8
)
3572 sal_uInt32 nRsid
= 0;
3573 if( !( rVal
>>= nRsid
) )
3580 SfxPoolItem
* SvxRsidItem::Clone( SfxItemPool
* ) const
3582 return new SvxRsidItem( *this );
3585 SfxPoolItem
* SvxRsidItem::Create(SvStream
& rIn
, sal_uInt16
) const
3587 return new SvxRsidItem( rIn
, Which() );
3590 void SvxRsidItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
3592 xmlTextWriterStartElement(pWriter
, BAD_CAST("svxRsidItem"));
3593 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("whichId"), "%d", Which());
3594 xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("value"), "%" SAL_PRIuUINT32
, GetValue());
3595 xmlTextWriterEndElement(pWriter
);
3598 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */