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/unohlp.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>
39 #include <rtl/ustring.hxx>
40 #include <i18nlangtag/languagetag.hxx>
41 #include <svl/itemset.hxx>
43 #include <svtools/langtab.hxx>
44 #include <svl/itempool.hxx>
45 #include <svtools/ctrltool.hxx>
46 #include <vcl/settings.hxx>
47 #include <vcl/svapp.hxx>
48 #include <com/sun/star/awt/SimpleFontMetric.hpp>
49 #include <com/sun/star/awt/FontWeight.hpp>
50 #include <com/sun/star/awt/FontSlant.hpp>
51 #include <com/sun/star/awt/CharSet.hpp>
52 #include <com/sun/star/awt/FontWidth.hpp>
53 #include <com/sun/star/awt/XFont.hpp>
54 #include <com/sun/star/awt/FontType.hpp>
55 #include <com/sun/star/awt/FontUnderline.hpp>
56 #include <com/sun/star/awt/FontStrikeout.hpp>
57 #include <com/sun/star/awt/FontFamily.hpp>
58 #include <com/sun/star/awt/FontPitch.hpp>
59 #include <com/sun/star/lang/Locale.hpp>
60 #include <com/sun/star/text/FontEmphasis.hpp>
61 #include <com/sun/star/i18n/ScriptType.hpp>
62 #include <editeng/rsiditem.hxx>
63 #include <editeng/memberids.hrc>
64 #include <editeng/flstitem.hxx>
65 #include <editeng/fontitem.hxx>
66 #include <editeng/postitem.hxx>
67 #include <editeng/wghtitem.hxx>
68 #include <editeng/fhgtitem.hxx>
69 #include <editeng/fwdtitem.hxx>
70 #include <editeng/udlnitem.hxx>
71 #include <editeng/crossedoutitem.hxx>
72 #include <editeng/shdditem.hxx>
73 #include <editeng/autokernitem.hxx>
74 #include <editeng/wrlmitem.hxx>
75 #include <editeng/contouritem.hxx>
76 #include <editeng/prszitem.hxx>
77 #include <editeng/colritem.hxx>
78 #include <editeng/charsetcoloritem.hxx>
79 #include <editeng/kernitem.hxx>
80 #include <editeng/cmapitem.hxx>
81 #include <editeng/escapementitem.hxx>
82 #include <editeng/langitem.hxx>
83 #include <editeng/nlbkitem.hxx>
84 #include <editeng/nhypitem.hxx>
85 #include <editeng/lcolitem.hxx>
86 #include <editeng/blinkitem.hxx>
87 #include <editeng/emphasismarkitem.hxx>
88 #include <editeng/twolinesitem.hxx>
89 #include <editeng/scripttypeitem.hxx>
90 #include <editeng/charrotateitem.hxx>
91 #include <editeng/charscaleitem.hxx>
92 #include <editeng/charreliefitem.hxx>
93 #include <editeng/itemtype.hxx>
94 #include <editeng/eerdll.hxx>
96 #define STORE_UNICODE_MAGIC_MARKER 0xFE331188
98 using namespace ::rtl
;
99 using namespace ::com::sun::star
;
100 using namespace ::com::sun::star::text
;
102 // Conversion for UNO
103 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
104 #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
105 #define TWIP_TO_MM100_UNSIGNED(TWIP) ((((TWIP)*127L+36L)/72L))
106 #define MM100_TO_TWIP_UNSIGNED(MM100) ((((MM100)*72L+63L)/127L))
108 sal_Bool
SvxFontItem::bEnableStoreUnicodeNames
= sal_False
;
110 // STATIC DATA -----------------------------------------------------------
112 // -----------------------------------------------------------------------
114 TYPEINIT1(SvxFontListItem
, SfxPoolItem
);
115 TYPEINIT1_FACTORY(SvxFontItem
, SfxPoolItem
, new SvxFontItem(0));
116 TYPEINIT1_FACTORY(SvxPostureItem
, SfxEnumItem
, new SvxPostureItem(ITALIC_NONE
, 0));
117 TYPEINIT1_FACTORY(SvxWeightItem
, SfxEnumItem
, new SvxWeightItem(WEIGHT_NORMAL
, 0));
118 TYPEINIT1_FACTORY(SvxFontHeightItem
, SfxPoolItem
, new SvxFontHeightItem(240, 100, 0));
119 TYPEINIT1_FACTORY(SvxFontWidthItem
, SfxPoolItem
, new SvxFontWidthItem(0, 100, 0));
120 TYPEINIT1_FACTORY(SvxTextLineItem
, SfxEnumItem
, new SvxTextLineItem(UNDERLINE_NONE
, 0));
121 TYPEINIT1_FACTORY(SvxUnderlineItem
, SfxEnumItem
, new SvxUnderlineItem(UNDERLINE_NONE
, 0));
122 TYPEINIT1_FACTORY(SvxOverlineItem
, SfxEnumItem
, new SvxOverlineItem(UNDERLINE_NONE
, 0));
123 TYPEINIT1_FACTORY(SvxCrossedOutItem
, SfxEnumItem
, new SvxCrossedOutItem(STRIKEOUT_NONE
, 0));
124 TYPEINIT1_FACTORY(SvxShadowedItem
, SfxBoolItem
, new SvxShadowedItem(sal_False
, 0));
125 TYPEINIT1_FACTORY(SvxAutoKernItem
, SfxBoolItem
, new SvxAutoKernItem(sal_False
, 0));
126 TYPEINIT1_FACTORY(SvxWordLineModeItem
, SfxBoolItem
, new SvxWordLineModeItem(sal_False
, 0));
127 TYPEINIT1_FACTORY(SvxContourItem
, SfxBoolItem
, new SvxContourItem(sal_False
, 0));
128 TYPEINIT1_FACTORY(SvxPropSizeItem
, SfxUInt16Item
, new SvxPropSizeItem(100, 0));
129 TYPEINIT1_FACTORY(SvxColorItem
, SfxPoolItem
, new SvxColorItem(0));
130 TYPEINIT1_FACTORY(SvxCharSetColorItem
, SvxColorItem
, new SvxCharSetColorItem(0));
131 TYPEINIT1_FACTORY(SvxKerningItem
, SfxInt16Item
, new SvxKerningItem(0, 0));
132 TYPEINIT1_FACTORY(SvxCaseMapItem
, SfxEnumItem
, new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED
, 0));
133 TYPEINIT1_FACTORY(SvxEscapementItem
, SfxPoolItem
, new SvxEscapementItem(0));
134 TYPEINIT1_FACTORY(SvxLanguageItem
, SfxEnumItem
, new SvxLanguageItem(LANGUAGE_GERMAN
, 0));
135 TYPEINIT1_FACTORY(SvxNoLinebreakItem
, SfxBoolItem
, new SvxNoLinebreakItem(sal_True
, 0));
136 TYPEINIT1_FACTORY(SvxNoHyphenItem
, SfxBoolItem
, new SvxNoHyphenItem(sal_True
, 0));
137 TYPEINIT1_FACTORY(SvxLineColorItem
, SvxColorItem
, new SvxLineColorItem(0));
138 TYPEINIT1_FACTORY(SvxBlinkItem
, SfxBoolItem
, new SvxBlinkItem(sal_False
, 0));
139 TYPEINIT1_FACTORY(SvxEmphasisMarkItem
, SfxUInt16Item
, new SvxEmphasisMarkItem(EMPHASISMARK_NONE
, 0));
140 TYPEINIT1_FACTORY(SvxTwoLinesItem
, SfxPoolItem
, new SvxTwoLinesItem(sal_True
, 0, 0, 0));
141 TYPEINIT1_FACTORY(SvxScriptTypeItem
, SfxUInt16Item
, new SvxScriptTypeItem
);
142 TYPEINIT1_FACTORY(SvxCharRotateItem
, SfxUInt16Item
, new SvxCharRotateItem(0, sal_False
, 0));
143 TYPEINIT1_FACTORY(SvxCharScaleWidthItem
, SfxUInt16Item
, new SvxCharScaleWidthItem(100, 0));
144 TYPEINIT1_FACTORY(SvxCharReliefItem
, SfxEnumItem
, new SvxCharReliefItem(RELIEF_NONE
, 0));
145 TYPEINIT1_FACTORY(SvxRsidItem
, SfxUInt32Item
, new SvxRsidItem(0, 0));
147 TYPEINIT1(SvxScriptSetItem
, SfxSetItem
);
150 // class SvxFontListItem -------------------------------------------------
152 SvxFontListItem::SvxFontListItem( const FontList
* pFontLst
,
153 const sal_uInt16 nId
) :
155 pFontList( pFontLst
)
159 sal_Int32 nCount
= pFontList
->GetFontNameCount();
160 aFontNameSeq
.realloc( nCount
);
162 for ( sal_uInt16 i
= 0; i
< nCount
; i
++ )
163 aFontNameSeq
[i
] = pFontList
->GetFontName(i
).GetName();
167 // -----------------------------------------------------------------------
169 SvxFontListItem::SvxFontListItem( const SvxFontListItem
& rItem
) :
171 SfxPoolItem( rItem
),
172 pFontList( rItem
.GetFontList() ),
173 aFontNameSeq( rItem
.aFontNameSeq
)
177 // -----------------------------------------------------------------------
179 SfxPoolItem
* SvxFontListItem::Clone( SfxItemPool
* ) const
181 return new SvxFontListItem( *this );
184 // -----------------------------------------------------------------------
186 int SvxFontListItem::operator==( const SfxPoolItem
& rAttr
) const
188 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
190 return( pFontList
== ((SvxFontListItem
&)rAttr
).pFontList
);
193 bool SvxFontListItem::QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
195 rVal
<<= aFontNameSeq
;
199 //------------------------------------------------------------------------
201 SfxItemPresentation
SvxFontListItem::GetPresentation
203 SfxItemPresentation
/*ePres*/,
204 SfxMapUnit
/*eCoreUnit*/,
205 SfxMapUnit
/*ePresUnit*/,
206 OUString
& rText
, const IntlWrapper
* /*pIntl*/
210 return SFX_ITEM_PRESENTATION_NONE
;
213 // class SvxFontItem -----------------------------------------------------
215 SvxFontItem::SvxFontItem( const sal_uInt16 nId
) :
218 eFamily
= FAMILY_SWISS
;
219 ePitch
= PITCH_VARIABLE
;
220 eTextEncoding
= RTL_TEXTENCODING_DONTKNOW
;
223 // -----------------------------------------------------------------------
225 SvxFontItem::SvxFontItem( const FontFamily eFam
, const XubString
& aName
,
226 const XubString
& aStName
, const FontPitch eFontPitch
,
227 const rtl_TextEncoding eFontTextEncoding
, const sal_uInt16 nId
) :
236 eTextEncoding
= eFontTextEncoding
;
239 // -----------------------------------------------------------------------
240 SvxFontItem
& SvxFontItem::operator=(const SvxFontItem
& rFont
)
242 aFamilyName
= rFont
.GetFamilyName();
243 aStyleName
= rFont
.GetStyleName();
244 eFamily
= rFont
.GetFamily();
245 ePitch
= rFont
.GetPitch();
246 eTextEncoding
= rFont
.GetCharSet();
249 // -----------------------------------------------------------------------
251 bool SvxFontItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
253 nMemberId
&= ~CONVERT_TWIPS
;
258 com::sun::star::awt::FontDescriptor aFontDescriptor
;
259 aFontDescriptor
.Name
= aFamilyName
.GetBuffer();
260 aFontDescriptor
.StyleName
= aStyleName
.GetBuffer();
261 aFontDescriptor
.Family
= (sal_Int16
)(eFamily
);
262 aFontDescriptor
.CharSet
= (sal_Int16
)(eTextEncoding
);
263 aFontDescriptor
.Pitch
= (sal_Int16
)(ePitch
);
264 rVal
<<= aFontDescriptor
;
267 case MID_FONT_FAMILY_NAME
:
268 rVal
<<= OUString(aFamilyName
.GetBuffer());
270 case MID_FONT_STYLE_NAME
:
271 rVal
<<= OUString(aStyleName
.GetBuffer());
273 case MID_FONT_FAMILY
: rVal
<<= (sal_Int16
)(eFamily
); break;
274 case MID_FONT_CHAR_SET
: rVal
<<= (sal_Int16
)(eTextEncoding
); break;
275 case MID_FONT_PITCH
: rVal
<<= (sal_Int16
)(ePitch
); break;
279 // -----------------------------------------------------------------------
280 bool SvxFontItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
282 nMemberId
&= ~CONVERT_TWIPS
;
287 com::sun::star::awt::FontDescriptor aFontDescriptor
;
288 if ( !( rVal
>>= aFontDescriptor
))
291 aFamilyName
= aFontDescriptor
.Name
;
292 aStyleName
= aFontDescriptor
.StyleName
;
293 eFamily
= (FontFamily
)aFontDescriptor
.Family
;
294 eTextEncoding
= (rtl_TextEncoding
)aFontDescriptor
.CharSet
;
295 ePitch
= (FontPitch
)aFontDescriptor
.Pitch
;
298 case MID_FONT_FAMILY_NAME
:
303 aFamilyName
= aStr
.getStr();
306 case MID_FONT_STYLE_NAME
:
311 aStyleName
= aStr
.getStr();
314 case MID_FONT_FAMILY
:
316 sal_Int16 nFamily
= sal_Int16();
317 if(!(rVal
>>= nFamily
))
319 eFamily
= (FontFamily
)nFamily
;
322 case MID_FONT_CHAR_SET
:
324 sal_Int16 nSet
= sal_Int16();
327 eTextEncoding
= (rtl_TextEncoding
)nSet
;
330 case MID_FONT_PITCH
:
332 sal_Int16 nPitch
= sal_Int16();
333 if(!(rVal
>>= nPitch
))
335 ePitch
= (FontPitch
)nPitch
;
342 // -----------------------------------------------------------------------
344 int SvxFontItem::operator==( const SfxPoolItem
& rAttr
) const
346 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
348 const SvxFontItem
& rItem
= (const SvxFontItem
&)rAttr
;
350 int bRet
= ( eFamily
== rItem
.eFamily
&&
351 aFamilyName
== rItem
.aFamilyName
&&
352 aStyleName
== rItem
.aStyleName
);
356 if ( ePitch
!= rItem
.ePitch
|| eTextEncoding
!= rItem
.eTextEncoding
)
359 DBG_WARNING( "FontItem::operator==(): only pitch or rtl_TextEncoding different ");
365 // -----------------------------------------------------------------------
367 SfxPoolItem
* SvxFontItem::Clone( SfxItemPool
* ) const
369 return new SvxFontItem( *this );
372 // -----------------------------------------------------------------------
374 SvStream
& SvxFontItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
376 sal_Bool bToBats
= IsStarSymbol( GetFamilyName() );
378 rStrm
<< (sal_uInt8
) GetFamily() << (sal_uInt8
) GetPitch()
379 << (sal_uInt8
)(bToBats
? RTL_TEXTENCODING_SYMBOL
: GetSOStoreTextEncoding(GetCharSet()));
381 String
aStoreFamilyName( GetFamilyName() );
383 aStoreFamilyName
= String( "StarBats", sizeof("StarBats")-1, RTL_TEXTENCODING_ASCII_US
);
384 rStrm
.WriteUniOrByteString(aStoreFamilyName
, rStrm
.GetStreamCharSet());
385 rStrm
.WriteUniOrByteString(GetStyleName(), rStrm
.GetStreamCharSet());
387 // cach for EditEngine, only set while creating clipboard stream.
388 if ( bEnableStoreUnicodeNames
)
390 sal_uInt32 nMagic
= STORE_UNICODE_MAGIC_MARKER
;
392 rStrm
.WriteUniOrByteString( aStoreFamilyName
, RTL_TEXTENCODING_UNICODE
);
393 rStrm
.WriteUniOrByteString( GetStyleName(), RTL_TEXTENCODING_UNICODE
);
399 // -----------------------------------------------------------------------
401 SfxPoolItem
* SvxFontItem::Create(SvStream
& rStrm
, sal_uInt16
) const
403 sal_uInt8 _eFamily
, eFontPitch
, eFontTextEncoding
;
404 String aName
, aStyle
;
407 rStrm
>> eFontTextEncoding
;
409 // UNICODE: rStrm >> aName;
410 aName
= rStrm
.ReadUniOrByteString(rStrm
.GetStreamCharSet());
412 // UNICODE: rStrm >> aStyle;
413 aStyle
= rStrm
.ReadUniOrByteString(rStrm
.GetStreamCharSet());
415 // Set the "correct" textencoding
416 eFontTextEncoding
= (sal_uInt8
)GetSOLoadTextEncoding( eFontTextEncoding
);
418 // at some point, the StarBats changes from ANSI font to SYMBOL font
419 if ( RTL_TEXTENCODING_SYMBOL
!= eFontTextEncoding
&& aName
.EqualsAscii("StarBats") )
420 eFontTextEncoding
= RTL_TEXTENCODING_SYMBOL
;
422 // Check if we have stored unicode
423 sal_Size nStreamPos
= rStrm
.Tell();
424 sal_uInt32 nMagic
= STORE_UNICODE_MAGIC_MARKER
;
426 if ( nMagic
== STORE_UNICODE_MAGIC_MARKER
)
428 aName
= rStrm
.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE
);
429 aStyle
= rStrm
.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE
);
433 rStrm
.Seek( nStreamPos
);
438 return new SvxFontItem( (FontFamily
)_eFamily
, aName
, aStyle
,
439 (FontPitch
)eFontPitch
, (rtl_TextEncoding
)eFontTextEncoding
, Which() );
442 //------------------------------------------------------------------------
444 SfxItemPresentation
SvxFontItem::GetPresentation
446 SfxItemPresentation ePres
,
447 SfxMapUnit
/*eCoreUnit*/,
448 SfxMapUnit
/*ePresUnit*/,
449 OUString
& rText
, const IntlWrapper
* /*pIntl*/
454 case SFX_ITEM_PRESENTATION_NONE
:
457 case SFX_ITEM_PRESENTATION_NAMELESS
:
458 case SFX_ITEM_PRESENTATION_COMPLETE
:
461 default: ; //prevent warning
463 return SFX_ITEM_PRESENTATION_NONE
;
466 //------------------------------------------------------------------------
468 void SvxFontItem::EnableStoreUnicodeNames( sal_Bool bEnable
)
470 bEnableStoreUnicodeNames
= bEnable
;
473 // class SvxPostureItem --------------------------------------------------
475 SvxPostureItem::SvxPostureItem( const FontItalic ePosture
, const sal_uInt16 nId
) :
476 SfxEnumItem( nId
, (sal_uInt16
)ePosture
)
480 // -----------------------------------------------------------------------
482 SfxPoolItem
* SvxPostureItem::Clone( SfxItemPool
* ) const
484 return new SvxPostureItem( *this );
487 // -----------------------------------------------------------------------
489 sal_uInt16
SvxPostureItem::GetValueCount() const
491 return ITALIC_NORMAL
+ 1; // ITALIC_NONE also belongs here
494 // -----------------------------------------------------------------------
496 SvStream
& SvxPostureItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
498 rStrm
<< (sal_uInt8
)GetValue();
502 // -----------------------------------------------------------------------
504 SfxPoolItem
* SvxPostureItem::Create(SvStream
& rStrm
, sal_uInt16
) const
508 return new SvxPostureItem( (const FontItalic
)nPosture
, Which() );
511 //------------------------------------------------------------------------
513 SfxItemPresentation
SvxPostureItem::GetPresentation
515 SfxItemPresentation ePres
,
516 SfxMapUnit
/*eCoreUnit*/,
517 SfxMapUnit
/*ePresUnit*/,
518 OUString
& rText
, const IntlWrapper
* /*pIntl*/
523 case SFX_ITEM_PRESENTATION_NONE
:
526 case SFX_ITEM_PRESENTATION_NAMELESS
:
527 case SFX_ITEM_PRESENTATION_COMPLETE
:
528 rText
= GetValueTextByPos( GetValue() );
530 default: ;//prevent warning
532 return SFX_ITEM_PRESENTATION_NONE
;
535 // -----------------------------------------------------------------------
537 OUString
SvxPostureItem::GetValueTextByPos( sal_uInt16 nPos
) const
539 DBG_ASSERT( nPos
<= (sal_uInt16
)ITALIC_NORMAL
, "enum overflow!" );
541 FontItalic eItalic
= (FontItalic
)nPos
;
546 case ITALIC_NONE
: nId
= RID_SVXITEMS_ITALIC_NONE
; break;
547 case ITALIC_OBLIQUE
: nId
= RID_SVXITEMS_ITALIC_OBLIQUE
; break;
548 case ITALIC_NORMAL
: nId
= RID_SVXITEMS_ITALIC_NORMAL
; break;
549 default: ;//prevent warning
552 return nId
? EE_RESSTR(nId
) : OUString();
555 bool SvxPostureItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
557 nMemberId
&= ~CONVERT_TWIPS
;
561 rVal
= Bool2Any(GetBoolValue());
564 rVal
<<= (awt::FontSlant
)GetValue(); // values from awt::FontSlant and FontItalic are equal
570 bool SvxPostureItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
572 nMemberId
&= ~CONVERT_TWIPS
;
576 SetBoolValue(Any2Bool(rVal
));
580 awt::FontSlant eSlant
;
581 if(!(rVal
>>= eSlant
))
583 sal_Int32 nValue
= 0;
584 if(!(rVal
>>= nValue
))
587 eSlant
= (awt::FontSlant
)nValue
;
589 SetValue((sal_uInt16
)eSlant
);
594 // -----------------------------------------------------------------------
596 int SvxPostureItem::HasBoolValue() const
601 // -----------------------------------------------------------------------
603 sal_Bool
SvxPostureItem::GetBoolValue() const
605 return ( (FontItalic
)GetValue() >= ITALIC_OBLIQUE
);
608 // -----------------------------------------------------------------------
610 void SvxPostureItem::SetBoolValue( sal_Bool bVal
)
612 SetValue( (sal_uInt16
)(bVal
? ITALIC_NORMAL
: ITALIC_NONE
) );
615 // class SvxWeightItem ---------------------------------------------------
617 SvxWeightItem::SvxWeightItem( const FontWeight eWght
, const sal_uInt16 nId
) :
618 SfxEnumItem( nId
, (sal_uInt16
)eWght
)
624 // -----------------------------------------------------------------------
626 int SvxWeightItem::HasBoolValue() const
631 // -----------------------------------------------------------------------
633 sal_Bool
SvxWeightItem::GetBoolValue() const
635 return (FontWeight
)GetValue() >= WEIGHT_BOLD
;
638 // -----------------------------------------------------------------------
640 void SvxWeightItem::SetBoolValue( sal_Bool bVal
)
642 SetValue( (sal_uInt16
)(bVal
? WEIGHT_BOLD
: WEIGHT_NORMAL
) );
645 // -----------------------------------------------------------------------
647 sal_uInt16
SvxWeightItem::GetValueCount() const
649 return WEIGHT_BLACK
; // WEIGHT_DONTKNOW does not belong
652 // -----------------------------------------------------------------------
654 SfxPoolItem
* SvxWeightItem::Clone( SfxItemPool
* ) const
656 return new SvxWeightItem( *this );
659 // -----------------------------------------------------------------------
661 SvStream
& SvxWeightItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
663 rStrm
<< (sal_uInt8
)GetValue();
667 // -----------------------------------------------------------------------
669 SfxPoolItem
* SvxWeightItem::Create(SvStream
& rStrm
, sal_uInt16
) const
673 return new SvxWeightItem( (FontWeight
)nWeight
, Which() );
676 //------------------------------------------------------------------------
678 SfxItemPresentation
SvxWeightItem::GetPresentation
680 SfxItemPresentation ePres
,
681 SfxMapUnit
/*eCoreUnit*/,
682 SfxMapUnit
/*ePresUnit*/,
683 OUString
& rText
, const IntlWrapper
* /*pIntl*/
688 case SFX_ITEM_PRESENTATION_NONE
:
691 case SFX_ITEM_PRESENTATION_NAMELESS
:
692 case SFX_ITEM_PRESENTATION_COMPLETE
:
693 rText
= GetValueTextByPos( GetValue() );
695 default: ;//prevent warning
697 return SFX_ITEM_PRESENTATION_NONE
;
700 // -----------------------------------------------------------------------
702 OUString
SvxWeightItem::GetValueTextByPos( sal_uInt16 nPos
) const
704 DBG_ASSERT( nPos
<= (sal_uInt16
)WEIGHT_BLACK
, "enum overflow!" );
705 return EE_RESSTR(RID_SVXITEMS_WEIGHT_BEGIN
+ nPos
);
708 bool SvxWeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
710 nMemberId
&= ~CONVERT_TWIPS
;
714 rVal
= Bool2Any(GetBoolValue());
718 rVal
<<= (float)( VCLUnoHelper::ConvertFontWeight( (FontWeight
)GetValue() ) );
725 bool SvxWeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
727 nMemberId
&= ~CONVERT_TWIPS
;
731 SetBoolValue(Any2Bool(rVal
));
736 if(!(rVal
>>= fValue
))
738 sal_Int32 nValue
= 0;
739 if(!(rVal
>>= nValue
))
741 fValue
= (float)nValue
;
743 SetValue( (sal_uInt16
)VCLUnoHelper::ConvertFontWeight((float)fValue
) );
750 // class SvxFontHeightItem -----------------------------------------------
752 SvxFontHeightItem::SvxFontHeightItem( const sal_uLong nSz
,
753 const sal_uInt16 nPrp
,
754 const sal_uInt16 nId
) :
757 SetHeight( nSz
,nPrp
); // calculate in percentage
760 // -----------------------------------------------------------------------
762 SfxPoolItem
* SvxFontHeightItem::Clone( SfxItemPool
* ) const
764 return new SvxFontHeightItem( *this );
767 // -----------------------------------------------------------------------
769 SvStream
& SvxFontHeightItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
771 rStrm
<< (sal_uInt16
)GetHeight();
773 if( FONTHEIGHT_UNIT_VERSION
<= nItemVersion
)
774 rStrm
<< GetProp() << (sal_uInt16
)GetPropUnit();
777 // When exporting to the old versions the relative information is lost
778 // when there is no percentage
779 sal_uInt16 _nProp
= GetProp();
780 if( SFX_MAPUNIT_RELATIVE
!= GetPropUnit() )
787 // -----------------------------------------------------------------------
789 SfxPoolItem
* SvxFontHeightItem::Create( SvStream
& rStrm
,
790 sal_uInt16 nVersion
) const
792 sal_uInt16 nsize
, nprop
= 0, nPropUnit
= SFX_MAPUNIT_RELATIVE
;
796 if( FONTHEIGHT_16_VERSION
<= nVersion
)
802 nprop
= (sal_uInt16
)nP
;
805 if( FONTHEIGHT_UNIT_VERSION
<= nVersion
)
808 SvxFontHeightItem
* pItem
= new SvxFontHeightItem( nsize
, 100, Which() );
809 pItem
->SetProp( nprop
, (SfxMapUnit
)nPropUnit
);
813 // -----------------------------------------------------------------------
815 int SvxFontHeightItem::operator==( const SfxPoolItem
& rItem
) const
817 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
818 return GetHeight() == ((SvxFontHeightItem
&)rItem
).GetHeight() &&
819 GetProp() == ((SvxFontHeightItem
&)rItem
).GetProp() &&
820 GetPropUnit() == ((SvxFontHeightItem
&)rItem
).GetPropUnit();
823 bool SvxFontHeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
825 // In StarOne is the uno::Any always 1/100mm. Through the MemberId it is
826 // controlled if the value in the Item should be 1/100mm or Twips.
828 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
829 nMemberId
&= ~CONVERT_TWIPS
;
834 ::com::sun::star::frame::status::FontHeight aFontHeight
;
836 // Point (i.e. Twips) is asked for, thus re-calculate if
837 // CONVERT_TWIPS is not set.
840 long nTwips
= bConvert
? nHeight
: MM100_TO_TWIP_UNSIGNED(nHeight
);
841 aFontHeight
.Height
= (float)( nTwips
/ 20.0 );
845 double fPoints
= MM100_TO_TWIP_UNSIGNED(nHeight
) / 20.0;
847 static_cast<float>(::rtl::math::round(fPoints
, 1));
848 aFontHeight
.Height
= fRoundPoints
;
851 aFontHeight
.Prop
= (sal_Int16
)(SFX_MAPUNIT_RELATIVE
== ePropUnit
? nProp
: 100);
853 float fRet
= (float)(short)nProp
;
856 case SFX_MAPUNIT_RELATIVE
:
859 case SFX_MAPUNIT_100TH_MM
:
860 fRet
= MM100_TO_TWIP(fRet
);
863 case SFX_MAPUNIT_POINT
:
866 case SFX_MAPUNIT_TWIP
:
869 default: ;//prevent warning
871 aFontHeight
.Diff
= fRet
;
872 rVal
<<= aFontHeight
;
877 // Point (i.e. Twips) is asked for, thus re-calculate if
878 // CONVERT_TWIPS is not set.
881 long nTwips
= bConvert
? nHeight
: MM100_TO_TWIP_UNSIGNED(nHeight
);
882 rVal
<<= (float)( nTwips
/ 20.0 );
886 double fPoints
= MM100_TO_TWIP_UNSIGNED(nHeight
) / 20.0;
888 static_cast<float>(::rtl::math::round(fPoints
, 1));
889 rVal
<<= fRoundPoints
;
893 case MID_FONTHEIGHT_PROP
:
894 rVal
<<= (sal_Int16
)(SFX_MAPUNIT_RELATIVE
== ePropUnit
? nProp
: 100);
896 case MID_FONTHEIGHT_DIFF
:
898 float fRet
= (float)(short)nProp
;
901 case SFX_MAPUNIT_RELATIVE
:
904 case SFX_MAPUNIT_100TH_MM
:
905 fRet
= MM100_TO_TWIP(fRet
);
908 case SFX_MAPUNIT_POINT
:
911 case SFX_MAPUNIT_TWIP
:
914 default: ;//prevent warning
923 // Calculate the relative deviation from the expected height.
924 static sal_uInt32
lcl_GetRealHeight_Impl(sal_uInt32 nHeight
, sal_uInt16 nProp
, SfxMapUnit eProp
, sal_Bool bCoreInTwip
)
926 sal_uInt32 nRet
= nHeight
;
930 case SFX_MAPUNIT_RELATIVE
:
934 case SFX_MAPUNIT_POINT
:
936 short nTemp
= (short)nProp
;
939 nDiff
= (short)TWIP_TO_MM100((long)(nDiff
));
942 case SFX_MAPUNIT_100TH_MM
:
943 //then the core is surely also in 1/100 mm
944 nDiff
= (short)nProp
;
946 case SFX_MAPUNIT_TWIP
:
948 nDiff
= ((short)nProp
);
950 default: ;//prevent warning
957 bool SvxFontHeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
959 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
960 nMemberId
&= ~CONVERT_TWIPS
;
965 ::com::sun::star::frame::status::FontHeight aFontHeight
;
966 if ( rVal
>>= aFontHeight
)
969 ePropUnit
= SFX_MAPUNIT_RELATIVE
;
971 double fPoint
= aFontHeight
.Height
;
972 if( fPoint
< 0. || fPoint
> 10000. )
975 nHeight
= (long)( fPoint
* 20.0 + 0.5 ); // Twips
977 nHeight
= TWIP_TO_MM100_UNSIGNED(nHeight
); // Convert, if the item contains 1/100mm
979 nProp
= aFontHeight
.Prop
;
987 ePropUnit
= SFX_MAPUNIT_RELATIVE
;
990 if(!(rVal
>>= fPoint
))
992 sal_Int32 nValue
= 0;
993 if(!(rVal
>>= nValue
))
995 fPoint
= (float)nValue
;
997 if(fPoint
< 0. || fPoint
> 10000.)
1000 nHeight
= (long)( fPoint
* 20.0 + 0.5 ); // Twips
1002 nHeight
= TWIP_TO_MM100_UNSIGNED(nHeight
); // Convert, if the item contains 1/100mm
1005 case MID_FONTHEIGHT_PROP
:
1007 sal_Int16 nNew
= sal_Int16();
1008 if(!(rVal
>>= nNew
))
1011 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
1016 ePropUnit
= SFX_MAPUNIT_RELATIVE
;
1019 case MID_FONTHEIGHT_DIFF
:
1021 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
1023 if(!(rVal
>>= fValue
))
1025 sal_Int32 nValue
= 0;
1026 if(!(rVal
>>= nValue
))
1028 fValue
= (float)nValue
;
1030 sal_Int16 nCoreDiffValue
= (sal_Int16
)(fValue
* 20.);
1031 nHeight
+= bConvert
? nCoreDiffValue
: TWIP_TO_MM100(nCoreDiffValue
);
1032 nProp
= (sal_uInt16
)((sal_Int16
)fValue
);
1033 ePropUnit
= SFX_MAPUNIT_POINT
;
1040 //------------------------------------------------------------------------
1042 SfxItemPresentation
SvxFontHeightItem::GetPresentation
1044 SfxItemPresentation ePres
,
1045 SfxMapUnit eCoreUnit
,
1046 SfxMapUnit
/*ePresUnit*/,
1047 OUString
& rText
, const IntlWrapper
*pIntl
1052 case SFX_ITEM_PRESENTATION_NONE
:
1055 case SFX_ITEM_PRESENTATION_NAMELESS
:
1056 case SFX_ITEM_PRESENTATION_COMPLETE
:
1058 if( SFX_MAPUNIT_RELATIVE
!= ePropUnit
)
1060 rText
= OUString::number( (short)nProp
) +
1061 EE_RESSTR( GetMetricId( ePropUnit
) );
1062 if( 0 <= (short)nProp
)
1063 rText
= "+" + rText
;
1065 else if( 100 == nProp
)
1067 rText
= GetMetricText( (long)nHeight
,
1068 eCoreUnit
, SFX_MAPUNIT_POINT
, pIntl
) +
1069 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT
));
1072 rText
= OUString::number( nProp
) + "%";
1075 default: ; //prevent warning
1077 return SFX_ITEM_PRESENTATION_NONE
;
1080 // -----------------------------------------------------------------------
1082 sal_uInt16
SvxFontHeightItem::GetVersion(sal_uInt16 nFileVersion
) const
1084 return (nFileVersion
<= SOFFICE_FILEFORMAT_40
)
1085 ? FONTHEIGHT_16_VERSION
1086 : FONTHEIGHT_UNIT_VERSION
;
1089 // -----------------------------------------------------------------------
1091 bool SvxFontHeightItem::ScaleMetrics( long nMult
, long nDiv
)
1093 nHeight
= (sal_uInt32
)Scale( nHeight
, nMult
, nDiv
);
1097 // -----------------------------------------------------------------------
1099 bool SvxFontHeightItem::HasMetrics() const
1104 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, const sal_uInt16 nNewProp
,
1107 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
1109 if( SFX_MAPUNIT_RELATIVE
!= eUnit
)
1110 nHeight
= nNewHeight
+ ::ItemToControl( (short)nNewProp
, eUnit
,
1112 else if( 100 != nNewProp
)
1113 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
1115 nHeight
= nNewHeight
;
1121 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, sal_uInt16 nNewProp
,
1122 SfxMapUnit eMetric
, SfxMapUnit eCoreMetric
)
1124 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
1126 if( SFX_MAPUNIT_RELATIVE
!= eMetric
)
1127 nHeight
= nNewHeight
+
1128 ::ControlToItem( ::ItemToControl((short)nNewProp
, eMetric
,
1129 SFX_FUNIT_TWIP
), SFX_FUNIT_TWIP
,
1131 else if( 100 != nNewProp
)
1132 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
1134 nHeight
= nNewHeight
;
1137 ePropUnit
= eMetric
;
1140 // class SvxFontWidthItem -----------------------------------------------
1142 SvxFontWidthItem::SvxFontWidthItem( const sal_uInt16 nSz
, const sal_uInt16 nPrp
, const sal_uInt16 nId
) :
1149 // -----------------------------------------------------------------------
1151 SfxPoolItem
* SvxFontWidthItem::Clone( SfxItemPool
* ) const
1153 return new SvxFontWidthItem( *this );
1156 // -----------------------------------------------------------------------
1158 SvStream
& SvxFontWidthItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1160 rStrm
<< GetWidth() << GetProp();
1164 // -----------------------------------------------------------------------
1166 bool SvxFontWidthItem::ScaleMetrics( long nMult
, long nDiv
)
1168 nWidth
= (sal_uInt16
)Scale( nWidth
, nMult
, nDiv
);
1172 // -----------------------------------------------------------------------
1174 bool SvxFontWidthItem::HasMetrics() const
1179 // -----------------------------------------------------------------------
1181 SfxPoolItem
* SvxFontWidthItem::Create( SvStream
& rStrm
,
1182 sal_uInt16
/*nVersion*/ ) const
1189 SvxFontWidthItem
* pItem
= new SvxFontWidthItem( 0, nP
, Which() );
1190 pItem
->SetWidthValue( nS
);
1194 // -----------------------------------------------------------------------
1196 int SvxFontWidthItem::operator==( const SfxPoolItem
& rItem
) const
1198 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
1199 return GetWidth() == ((SvxFontWidthItem
&)rItem
).GetWidth() &&
1200 GetProp() == ((SvxFontWidthItem
&)rItem
).GetProp();
1203 bool SvxFontWidthItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1205 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1206 nMemberId
&= ~CONVERT_TWIPS
;
1210 rVal
<<= (sal_Int16
)(nWidth
);
1212 case MID_FONTWIDTH_PROP
:
1213 rVal
<<= (sal_Int16
)(nProp
);
1219 bool SvxFontWidthItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1221 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1222 nMemberId
&= ~CONVERT_TWIPS
;
1223 sal_Int16 nVal
= sal_Int16();
1224 if(!(rVal
>>= nVal
))
1232 case MID_FONTWIDTH_PROP
:
1239 //------------------------------------------------------------------------
1241 SfxItemPresentation
SvxFontWidthItem::GetPresentation
1243 SfxItemPresentation ePres
,
1244 SfxMapUnit eCoreUnit
,
1245 SfxMapUnit
/*ePresUnit*/,
1246 OUString
& rText
, const IntlWrapper
*pIntl
1251 case SFX_ITEM_PRESENTATION_NONE
:
1254 case SFX_ITEM_PRESENTATION_NAMELESS
:
1255 case SFX_ITEM_PRESENTATION_COMPLETE
:
1259 rText
= GetMetricText( (long)nWidth
,
1260 eCoreUnit
, SFX_MAPUNIT_POINT
, pIntl
) +
1261 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT
));
1264 rText
= OUString::number( nProp
) + "%";
1267 default: ; //prevent warning
1269 return SFX_ITEM_PRESENTATION_NONE
;
1272 // class SvxTextLineItem ------------------------------------------------
1274 SvxTextLineItem::SvxTextLineItem( const FontUnderline eSt
, const sal_uInt16 nId
)
1275 : SfxEnumItem( nId
, (sal_uInt16
)eSt
), mColor( COL_TRANSPARENT
)
1279 // -----------------------------------------------------------------------
1281 int SvxTextLineItem::HasBoolValue() const
1286 // -----------------------------------------------------------------------
1288 sal_Bool
SvxTextLineItem::GetBoolValue() const
1290 return (FontUnderline
)GetValue() != UNDERLINE_NONE
;
1293 // -----------------------------------------------------------------------
1295 void SvxTextLineItem::SetBoolValue( sal_Bool bVal
)
1297 SetValue( (sal_uInt16
)(bVal
? UNDERLINE_SINGLE
: UNDERLINE_NONE
) );
1300 // -----------------------------------------------------------------------
1302 SfxPoolItem
* SvxTextLineItem::Clone( SfxItemPool
* ) const
1304 SvxTextLineItem
* pNew
= new SvxTextLineItem( *this );
1305 pNew
->SetColor( GetColor() );
1309 // -----------------------------------------------------------------------
1311 sal_uInt16
SvxTextLineItem::GetValueCount() const
1313 return UNDERLINE_DOTTED
+ 1; // UNDERLINE_NONE also belongs here
1316 // -----------------------------------------------------------------------
1318 SvStream
& SvxTextLineItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1320 rStrm
<< (sal_uInt8
)GetValue();
1324 // -----------------------------------------------------------------------
1326 SfxPoolItem
* SvxTextLineItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1330 return new SvxTextLineItem( (FontUnderline
)nState
, Which() );
1333 //------------------------------------------------------------------------
1335 SfxItemPresentation
SvxTextLineItem::GetPresentation
1337 SfxItemPresentation ePres
,
1338 SfxMapUnit
/*eCoreUnit*/,
1339 SfxMapUnit
/*ePresUnit*/,
1340 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1345 case SFX_ITEM_PRESENTATION_NONE
:
1348 case SFX_ITEM_PRESENTATION_NAMELESS
:
1349 case SFX_ITEM_PRESENTATION_COMPLETE
:
1350 rText
= GetValueTextByPos( GetValue() );
1351 if( !mColor
.GetTransparency() )
1352 rText
= rText
+ OUString(cpDelim
) + ::GetColorString( mColor
);
1354 default: ; //prevent warning
1356 return SFX_ITEM_PRESENTATION_NONE
;
1359 // -----------------------------------------------------------------------
1361 OUString
SvxTextLineItem::GetValueTextByPos( sal_uInt16
/*nPos*/ ) const
1363 OSL_FAIL("SvxTextLineItem::GetValueTextByPos: Pure virtual method");
1367 bool SvxTextLineItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1369 nMemberId
&= ~CONVERT_TWIPS
;
1373 rVal
= Bool2Any(GetBoolValue());
1376 rVal
<<= (sal_Int16
)(GetValue());
1379 rVal
<<= (sal_Int32
)( mColor
.GetColor() );
1381 case MID_TL_HASCOLOR
:
1382 rVal
= Bool2Any( !mColor
.GetTransparency() );
1389 bool SvxTextLineItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1391 nMemberId
&= ~CONVERT_TWIPS
;
1392 sal_Bool bRet
= sal_True
;
1396 SetBoolValue(Any2Bool(rVal
));
1400 sal_Int32 nValue
= 0;
1401 if(!(rVal
>>= nValue
))
1404 SetValue((sal_Int16
)nValue
);
1410 if( !( rVal
>>= nCol
) )
1414 // Keep transparence, because it contains the information
1415 // whether the font color or the stored color should be used
1416 sal_uInt8 nTrans
= mColor
.GetTransparency();
1417 mColor
= Color( nCol
);
1418 mColor
.SetTransparency( nTrans
);
1422 case MID_TL_HASCOLOR
:
1423 mColor
.SetTransparency( Any2Bool( rVal
) ? 0 : 0xff );
1429 int SvxTextLineItem::operator==( const SfxPoolItem
& rItem
) const
1431 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
1432 return SfxEnumItem::operator==( rItem
) &&
1433 GetColor() == ((SvxTextLineItem
&)rItem
).GetColor();
1436 // class SvxUnderlineItem ------------------------------------------------
1438 SvxUnderlineItem::SvxUnderlineItem( const FontUnderline eSt
, const sal_uInt16 nId
)
1439 : SvxTextLineItem( eSt
, nId
)
1443 //------------------------------------------------------------------------
1445 SfxPoolItem
* SvxUnderlineItem::Clone( SfxItemPool
* ) const
1447 SvxUnderlineItem
* pNew
= new SvxUnderlineItem( *this );
1448 pNew
->SetColor( GetColor() );
1452 // -----------------------------------------------------------------------
1454 SfxPoolItem
* SvxUnderlineItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1458 return new SvxUnderlineItem( (FontUnderline
)nState
, Which() );
1461 // -----------------------------------------------------------------------
1463 OUString
SvxUnderlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1465 DBG_ASSERT( nPos
<= (sal_uInt16
)UNDERLINE_BOLDWAVE
, "enum overflow!" );
1466 return EE_RESSTR(RID_SVXITEMS_UL_BEGIN
+ nPos
);
1469 // class SvxOverlineItem ------------------------------------------------
1471 SvxOverlineItem::SvxOverlineItem( const FontUnderline eSt
, const sal_uInt16 nId
)
1472 : SvxTextLineItem( eSt
, nId
)
1476 //------------------------------------------------------------------------
1478 SfxPoolItem
* SvxOverlineItem::Clone( SfxItemPool
* ) const
1480 SvxOverlineItem
* pNew
= new SvxOverlineItem( *this );
1481 pNew
->SetColor( GetColor() );
1485 // -----------------------------------------------------------------------
1487 SfxPoolItem
* SvxOverlineItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1491 return new SvxOverlineItem( (FontUnderline
)nState
, Which() );
1494 // -----------------------------------------------------------------------
1496 OUString
SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1498 DBG_ASSERT( nPos
<= (sal_uInt16
)UNDERLINE_BOLDWAVE
, "enum overflow!" );
1499 return EE_RESSTR(RID_SVXITEMS_OL_BEGIN
+ nPos
);
1502 // class SvxCrossedOutItem -----------------------------------------------
1504 SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt
, const sal_uInt16 nId
)
1505 : SfxEnumItem( nId
, (sal_uInt16
)eSt
)
1509 // -----------------------------------------------------------------------
1511 int SvxCrossedOutItem::HasBoolValue() const
1516 // -----------------------------------------------------------------------
1518 sal_Bool
SvxCrossedOutItem::GetBoolValue() const
1520 return (FontStrikeout
)GetValue() != STRIKEOUT_NONE
;
1523 // -----------------------------------------------------------------------
1525 void SvxCrossedOutItem::SetBoolValue( sal_Bool bVal
)
1527 SetValue( (sal_uInt16
)(bVal
? STRIKEOUT_SINGLE
: STRIKEOUT_NONE
) );
1530 // -----------------------------------------------------------------------
1532 sal_uInt16
SvxCrossedOutItem::GetValueCount() const
1534 return STRIKEOUT_DOUBLE
+ 1; // STRIKEOUT_NONE belongs also here
1537 // -----------------------------------------------------------------------
1539 SfxPoolItem
* SvxCrossedOutItem::Clone( SfxItemPool
* ) const
1541 return new SvxCrossedOutItem( *this );
1544 // -----------------------------------------------------------------------
1546 SvStream
& SvxCrossedOutItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1548 rStrm
<< (sal_uInt8
)GetValue();
1552 // -----------------------------------------------------------------------
1554 SfxPoolItem
* SvxCrossedOutItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1558 return new SvxCrossedOutItem( (FontStrikeout
)eCross
, Which() );
1561 //------------------------------------------------------------------------
1563 SfxItemPresentation
SvxCrossedOutItem::GetPresentation
1565 SfxItemPresentation ePres
,
1566 SfxMapUnit
/*eCoreUnit*/,
1567 SfxMapUnit
/*ePresUnit*/,
1568 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1573 case SFX_ITEM_PRESENTATION_NONE
:
1576 case SFX_ITEM_PRESENTATION_NAMELESS
:
1577 case SFX_ITEM_PRESENTATION_COMPLETE
:
1578 rText
= GetValueTextByPos( GetValue() );
1580 default: ;//prevent warning
1582 return SFX_ITEM_PRESENTATION_NONE
;
1585 // -----------------------------------------------------------------------
1587 OUString
SvxCrossedOutItem::GetValueTextByPos( sal_uInt16 nPos
) const
1589 DBG_ASSERT( nPos
<= (sal_uInt16
)STRIKEOUT_X
, "enum overflow!" );
1590 return EE_RESSTR(RID_SVXITEMS_STRIKEOUT_BEGIN
+ nPos
);
1593 bool SvxCrossedOutItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1595 nMemberId
&= ~CONVERT_TWIPS
;
1598 case MID_CROSSED_OUT
:
1599 rVal
= Bool2Any(GetBoolValue());
1602 rVal
<<= (sal_Int16
)(GetValue());
1608 bool SvxCrossedOutItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1610 nMemberId
&= ~CONVERT_TWIPS
;
1613 case MID_CROSSED_OUT
:
1614 SetBoolValue(Any2Bool(rVal
));
1618 sal_Int32 nValue
= 0;
1619 if(!(rVal
>>= nValue
))
1621 SetValue((sal_Int16
)nValue
);
1627 // class SvxShadowedItem -------------------------------------------------
1629 SvxShadowedItem::SvxShadowedItem( const sal_Bool bShadowed
, const sal_uInt16 nId
) :
1630 SfxBoolItem( nId
, bShadowed
)
1634 // -----------------------------------------------------------------------
1636 SfxPoolItem
* SvxShadowedItem::Clone( SfxItemPool
* ) const
1638 return new SvxShadowedItem( *this );
1641 // -----------------------------------------------------------------------
1643 SvStream
& SvxShadowedItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1645 rStrm
<< (sal_uInt8
) GetValue();
1649 // -----------------------------------------------------------------------
1651 SfxPoolItem
* SvxShadowedItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1655 return new SvxShadowedItem( nState
, Which() );
1658 //------------------------------------------------------------------------
1660 SfxItemPresentation
SvxShadowedItem::GetPresentation
1662 SfxItemPresentation ePres
,
1663 SfxMapUnit
/*eCoreUnit*/,
1664 SfxMapUnit
/*ePresUnit*/,
1665 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1670 case SFX_ITEM_PRESENTATION_NONE
:
1673 case SFX_ITEM_PRESENTATION_NAMELESS
:
1674 case SFX_ITEM_PRESENTATION_COMPLETE
:
1676 sal_uInt16 nId
= RID_SVXITEMS_SHADOWED_FALSE
;
1679 nId
= RID_SVXITEMS_SHADOWED_TRUE
;
1680 rText
= EE_RESSTR(nId
);
1683 default: ; //prevent warning
1685 return SFX_ITEM_PRESENTATION_NONE
;
1688 // class SvxAutoKernItem -------------------------------------------------
1690 SvxAutoKernItem::SvxAutoKernItem( const sal_Bool bAutoKern
, const sal_uInt16 nId
) :
1691 SfxBoolItem( nId
, bAutoKern
)
1695 // -----------------------------------------------------------------------
1697 SfxPoolItem
* SvxAutoKernItem::Clone( SfxItemPool
* ) const
1699 return new SvxAutoKernItem( *this );
1702 // -----------------------------------------------------------------------
1704 SvStream
& SvxAutoKernItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1706 rStrm
<< (sal_uInt8
) GetValue();
1710 // -----------------------------------------------------------------------
1712 SfxPoolItem
* SvxAutoKernItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1716 return new SvxAutoKernItem( nState
, Which() );
1719 //------------------------------------------------------------------------
1721 SfxItemPresentation
SvxAutoKernItem::GetPresentation
1723 SfxItemPresentation ePres
,
1724 SfxMapUnit
/*eCoreUnit*/,
1725 SfxMapUnit
/*ePresUnit*/,
1726 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1731 case SFX_ITEM_PRESENTATION_NONE
:
1734 case SFX_ITEM_PRESENTATION_NAMELESS
:
1735 case SFX_ITEM_PRESENTATION_COMPLETE
:
1737 sal_uInt16 nId
= RID_SVXITEMS_AUTOKERN_FALSE
;
1740 nId
= RID_SVXITEMS_AUTOKERN_TRUE
;
1741 rText
= EE_RESSTR(nId
);
1744 default: ; //prevent warning
1746 return SFX_ITEM_PRESENTATION_NONE
;
1749 // class SvxWordLineModeItem ---------------------------------------------
1751 SvxWordLineModeItem::SvxWordLineModeItem( const sal_Bool bWordLineMode
,
1752 const sal_uInt16 nId
) :
1753 SfxBoolItem( nId
, bWordLineMode
)
1757 // -----------------------------------------------------------------------
1759 SfxPoolItem
* SvxWordLineModeItem::Clone( SfxItemPool
* ) const
1761 return new SvxWordLineModeItem( *this );
1764 // -----------------------------------------------------------------------
1766 SvStream
& SvxWordLineModeItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1768 rStrm
<< (sal_Bool
) GetValue();
1772 // -----------------------------------------------------------------------
1774 SfxPoolItem
* SvxWordLineModeItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1778 return new SvxWordLineModeItem( bValue
, Which() );
1781 //------------------------------------------------------------------------
1783 SfxItemPresentation
SvxWordLineModeItem::GetPresentation
1785 SfxItemPresentation ePres
,
1786 SfxMapUnit
/*eCoreUnit*/,
1787 SfxMapUnit
/*ePresUnit*/,
1788 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1793 case SFX_ITEM_PRESENTATION_NONE
:
1796 case SFX_ITEM_PRESENTATION_NAMELESS
:
1797 case SFX_ITEM_PRESENTATION_COMPLETE
:
1799 sal_uInt16 nId
= RID_SVXITEMS_WORDLINE_FALSE
;
1802 nId
= RID_SVXITEMS_WORDLINE_TRUE
;
1803 rText
= EE_RESSTR(nId
);
1806 default: ; //prevent warning
1808 return SFX_ITEM_PRESENTATION_NONE
;
1811 // class SvxContourItem --------------------------------------------------
1813 SvxContourItem::SvxContourItem( const sal_Bool bContoured
, const sal_uInt16 nId
) :
1814 SfxBoolItem( nId
, bContoured
)
1818 // -----------------------------------------------------------------------
1820 SfxPoolItem
* SvxContourItem::Clone( SfxItemPool
* ) const
1822 return new SvxContourItem( *this );
1825 // -----------------------------------------------------------------------
1827 SvStream
& SvxContourItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1829 rStrm
<< (sal_Bool
) GetValue();
1833 // -----------------------------------------------------------------------
1835 SfxPoolItem
* SvxContourItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1839 return new SvxContourItem( bValue
, Which() );
1842 //------------------------------------------------------------------------
1844 SfxItemPresentation
SvxContourItem::GetPresentation
1846 SfxItemPresentation ePres
,
1847 SfxMapUnit
/*eCoreUnit*/,
1848 SfxMapUnit
/*ePresUnit*/,
1849 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1854 case SFX_ITEM_PRESENTATION_NONE
:
1857 case SFX_ITEM_PRESENTATION_NAMELESS
:
1858 case SFX_ITEM_PRESENTATION_COMPLETE
:
1860 sal_uInt16 nId
= RID_SVXITEMS_CONTOUR_FALSE
;
1863 nId
= RID_SVXITEMS_CONTOUR_TRUE
;
1864 rText
= EE_RESSTR(nId
);
1867 default: ; //prevent warning
1869 return SFX_ITEM_PRESENTATION_NONE
;
1872 // class SvxPropSizeItem -------------------------------------------------
1874 SvxPropSizeItem::SvxPropSizeItem( const sal_uInt16 nPercent
, const sal_uInt16 nId
) :
1875 SfxUInt16Item( nId
, nPercent
)
1879 // -----------------------------------------------------------------------
1881 SfxPoolItem
* SvxPropSizeItem::Clone( SfxItemPool
* ) const
1883 return new SvxPropSizeItem( *this );
1886 // -----------------------------------------------------------------------
1888 SvStream
& SvxPropSizeItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1890 rStrm
<< (sal_uInt16
) GetValue();
1894 // -----------------------------------------------------------------------
1896 SfxPoolItem
* SvxPropSizeItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1900 return new SvxPropSizeItem( nSize
, Which() );
1903 //------------------------------------------------------------------------
1905 SfxItemPresentation
SvxPropSizeItem::GetPresentation
1907 SfxItemPresentation
/*ePres*/,
1908 SfxMapUnit
/*eCoreUnit*/,
1909 SfxMapUnit
/*ePresUnit*/,
1910 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1914 return SFX_ITEM_PRESENTATION_NONE
;
1917 // class SvxColorItem ----------------------------------------------------
1919 SvxColorItem::SvxColorItem( const sal_uInt16 nId
) :
1925 // -----------------------------------------------------------------------
1927 SvxColorItem::SvxColorItem( const Color
& rCol
, const sal_uInt16 nId
) :
1933 // -----------------------------------------------------------------------
1935 SvxColorItem::SvxColorItem( SvStream
&rStrm
, const sal_uInt16 nId
) :
1943 // -----------------------------------------------------------------------
1945 SvxColorItem::SvxColorItem( const SvxColorItem
&rCopy
) :
1946 SfxPoolItem( rCopy
),
1947 mColor( rCopy
.mColor
)
1951 // -----------------------------------------------------------------------
1953 SvxColorItem::~SvxColorItem()
1957 // -----------------------------------------------------------------------
1958 sal_uInt16
SvxColorItem::GetVersion( sal_uInt16 nFFVer
) const
1960 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
1961 SOFFICE_FILEFORMAT_40
==nFFVer
||
1962 SOFFICE_FILEFORMAT_50
==nFFVer
,
1963 "SvxColorItem: Is there a new file format? ");
1964 return SOFFICE_FILEFORMAT_50
>= nFFVer
? VERSION_USEAUTOCOLOR
: 0;
1967 // -----------------------------------------------------------------------
1969 int SvxColorItem::operator==( const SfxPoolItem
& rAttr
) const
1971 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1973 return mColor
== ( (const SvxColorItem
&)rAttr
).mColor
;
1976 // -----------------------------------------------------------------------
1978 bool SvxColorItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
1980 rVal
<<= (sal_Int32
)(mColor
.GetColor());
1984 // -----------------------------------------------------------------------
1986 bool SvxColorItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
1988 sal_Int32 nColor
= 0;
1989 if(!(rVal
>>= nColor
))
1992 mColor
.SetColor( nColor
);
1996 // -----------------------------------------------------------------------
1998 SfxPoolItem
* SvxColorItem::Clone( SfxItemPool
* ) const
2000 return new SvxColorItem( *this );
2003 // -----------------------------------------------------------------------
2005 SvStream
& SvxColorItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
2007 if( VERSION_USEAUTOCOLOR
== nItemVersion
&&
2008 COL_AUTO
== mColor
.GetColor() )
2009 rStrm
<< Color( COL_BLACK
);
2015 // -----------------------------------------------------------------------
2017 SfxPoolItem
* SvxColorItem::Create(SvStream
& rStrm
, sal_uInt16
/*nVer*/ ) const
2019 return new SvxColorItem( rStrm
, Which() );
2022 //------------------------------------------------------------------------
2024 SfxItemPresentation
SvxColorItem::GetPresentation
2026 SfxItemPresentation ePres
,
2027 SfxMapUnit
/*eCoreUnit*/,
2028 SfxMapUnit
/*ePresUnit*/,
2029 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2034 case SFX_ITEM_PRESENTATION_NONE
:
2037 case SFX_ITEM_PRESENTATION_NAMELESS
:
2038 case SFX_ITEM_PRESENTATION_COMPLETE
:
2039 rText
= ::GetColorString( mColor
);
2041 default: ; //prevent warning
2043 return SFX_ITEM_PRESENTATION_NONE
;
2046 // -----------------------------------------------------------------------
2048 void SvxColorItem::SetValue( const Color
& rNewCol
)
2053 // class SvxCharSetColorItem ---------------------------------------------
2055 SvxCharSetColorItem::SvxCharSetColorItem( const sal_uInt16 nId
) :
2056 SvxColorItem( nId
),
2058 eFrom( RTL_TEXTENCODING_DONTKNOW
)
2062 // -----------------------------------------------------------------------
2064 SvxCharSetColorItem::SvxCharSetColorItem( const Color
& rCol
,
2065 const rtl_TextEncoding _eFrom
,
2066 const sal_uInt16 nId
) :
2067 SvxColorItem( rCol
, nId
),
2074 // -----------------------------------------------------------------------
2076 SfxPoolItem
* SvxCharSetColorItem::Clone( SfxItemPool
* ) const
2078 return new SvxCharSetColorItem( *this );
2081 // -----------------------------------------------------------------------
2083 SvStream
& SvxCharSetColorItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2085 rStrm
<< (sal_uInt8
)GetSOStoreTextEncoding(GetCharSet()) << GetValue();
2089 // -----------------------------------------------------------------------
2091 SfxPoolItem
* SvxCharSetColorItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2095 rStrm
>> cSet
>> aColor
;
2096 return new SvxCharSetColorItem( aColor
, (rtl_TextEncoding
)cSet
, Which() );
2099 //------------------------------------------------------------------------
2101 SfxItemPresentation
SvxCharSetColorItem::GetPresentation
2103 SfxItemPresentation
/*ePres*/,
2104 SfxMapUnit
/*eCoreUnit*/,
2105 SfxMapUnit
/*ePresUnit*/,
2106 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2110 return SFX_ITEM_PRESENTATION_NONE
;
2113 // class SvxKerningItem --------------------------------------------------
2115 SvxKerningItem::SvxKerningItem( const short nKern
, const sal_uInt16 nId
) :
2116 SfxInt16Item( nId
, nKern
)
2120 // -----------------------------------------------------------------------
2122 SfxPoolItem
* SvxKerningItem::Clone( SfxItemPool
* ) const
2124 return new SvxKerningItem( *this );
2127 // -----------------------------------------------------------------------
2129 SvStream
& SvxKerningItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2131 rStrm
<< (short) GetValue();
2135 // -----------------------------------------------------------------------
2137 bool SvxKerningItem::ScaleMetrics( long nMult
, long nDiv
)
2139 SetValue( (sal_Int16
)Scale( GetValue(), nMult
, nDiv
) );
2143 // -----------------------------------------------------------------------
2145 bool SvxKerningItem::HasMetrics() const
2150 // -----------------------------------------------------------------------
2152 SfxPoolItem
* SvxKerningItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2156 return new SvxKerningItem( nValue
, Which() );
2159 //------------------------------------------------------------------------
2161 SfxItemPresentation
SvxKerningItem::GetPresentation
2163 SfxItemPresentation ePres
,
2164 SfxMapUnit eCoreUnit
,
2165 SfxMapUnit
/*ePresUnit*/,
2166 OUString
& rText
, const IntlWrapper
*pIntl
2171 case SFX_ITEM_PRESENTATION_NONE
:
2174 case SFX_ITEM_PRESENTATION_NAMELESS
:
2175 rText
= GetMetricText( (long)GetValue(), eCoreUnit
, SFX_MAPUNIT_POINT
, pIntl
) +
2176 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT
));
2178 case SFX_ITEM_PRESENTATION_COMPLETE
:
2180 rText
= EE_RESSTR(RID_SVXITEMS_KERNING_COMPLETE
);
2183 if ( GetValue() > 0 )
2184 nId
= RID_SVXITEMS_KERNING_EXPANDED
;
2185 else if ( GetValue() < 0 )
2186 nId
= RID_SVXITEMS_KERNING_CONDENSED
;
2189 rText
+= EE_RESSTR(nId
);
2191 GetMetricText( (long)GetValue(), eCoreUnit
, SFX_MAPUNIT_POINT
, pIntl
) +
2192 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT
));
2195 default: ; //prevent warning
2197 return SFX_ITEM_PRESENTATION_NONE
;
2200 bool SvxKerningItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2202 sal_Int16 nVal
= GetValue();
2203 if(nMemberId
& CONVERT_TWIPS
)
2204 nVal
= (sal_Int16
)TWIP_TO_MM100(nVal
);
2208 // -----------------------------------------------------------------------
2209 bool SvxKerningItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2211 sal_Int16 nVal
= sal_Int16();
2212 if(!(rVal
>>= nVal
))
2214 if(nMemberId
& CONVERT_TWIPS
)
2215 nVal
= (sal_Int16
)MM100_TO_TWIP(nVal
);
2220 // class SvxCaseMapItem --------------------------------------------------
2222 SvxCaseMapItem::SvxCaseMapItem( const SvxCaseMap eMap
, const sal_uInt16 nId
) :
2223 SfxEnumItem( nId
, (sal_uInt16
)eMap
)
2227 // -----------------------------------------------------------------------
2229 sal_uInt16
SvxCaseMapItem::GetValueCount() const
2231 return SVX_CASEMAP_END
; // SVX_CASEMAP_KAPITAELCHEN + 1
2234 // -----------------------------------------------------------------------
2236 SfxPoolItem
* SvxCaseMapItem::Clone( SfxItemPool
* ) const
2238 return new SvxCaseMapItem( *this );
2241 // -----------------------------------------------------------------------
2243 SvStream
& SvxCaseMapItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2245 rStrm
<< (sal_uInt8
) GetValue();
2249 // -----------------------------------------------------------------------
2251 SfxPoolItem
* SvxCaseMapItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2255 return new SvxCaseMapItem( (const SvxCaseMap
)cMap
, Which() );
2258 //------------------------------------------------------------------------
2260 SfxItemPresentation
SvxCaseMapItem::GetPresentation
2262 SfxItemPresentation ePres
,
2263 SfxMapUnit
/*eCoreUnit*/,
2264 SfxMapUnit
/*ePresUnit*/,
2265 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2270 case SFX_ITEM_PRESENTATION_NONE
:
2273 case SFX_ITEM_PRESENTATION_NAMELESS
:
2274 case SFX_ITEM_PRESENTATION_COMPLETE
:
2275 rText
= GetValueTextByPos( GetValue() );
2277 default: ; //prevent warning
2279 return SFX_ITEM_PRESENTATION_NONE
;
2282 // -----------------------------------------------------------------------
2284 OUString
SvxCaseMapItem::GetValueTextByPos( sal_uInt16 nPos
) const
2286 DBG_ASSERT( nPos
< (sal_uInt16
)SVX_CASEMAP_END
, "enum overflow!" );
2287 return EE_RESSTR(RID_SVXITEMS_CASEMAP_BEGIN
+ nPos
);
2290 bool SvxCaseMapItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
2292 sal_Int16 nRet
= style::CaseMap::NONE
;
2293 switch( GetValue() )
2295 case SVX_CASEMAP_VERSALIEN
: nRet
= style::CaseMap::UPPERCASE
; break;
2296 case SVX_CASEMAP_GEMEINE
: nRet
= style::CaseMap::LOWERCASE
; break;
2297 case SVX_CASEMAP_TITEL
: nRet
= style::CaseMap::TITLE
; break;
2298 case SVX_CASEMAP_KAPITAELCHEN
: nRet
= style::CaseMap::SMALLCAPS
; break;
2300 rVal
<<= (sal_Int16
)(nRet
);
2304 bool SvxCaseMapItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
2306 sal_uInt16 nVal
= sal_uInt16();
2307 if(!(rVal
>>= nVal
))
2312 case style::CaseMap::NONE
: nVal
= SVX_CASEMAP_NOT_MAPPED
; break;
2313 case style::CaseMap::UPPERCASE
: nVal
= SVX_CASEMAP_VERSALIEN
; break;
2314 case style::CaseMap::LOWERCASE
: nVal
= SVX_CASEMAP_GEMEINE
; break;
2315 case style::CaseMap::TITLE
: nVal
= SVX_CASEMAP_TITEL
; break;
2316 case style::CaseMap::SMALLCAPS
: nVal
= SVX_CASEMAP_KAPITAELCHEN
; break;
2322 // class SvxEscapementItem -----------------------------------------------
2324 SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId
) :
2325 SfxEnumItemInterface( nId
),
2332 // -----------------------------------------------------------------------
2334 SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape
,
2335 const sal_uInt16 nId
) :
2336 SfxEnumItemInterface( nId
),
2339 SetEscapement( eEscape
);
2344 // -----------------------------------------------------------------------
2346 SvxEscapementItem::SvxEscapementItem( const short _nEsc
,
2347 const sal_uInt8 _nProp
,
2348 const sal_uInt16 nId
) :
2349 SfxEnumItemInterface( nId
),
2355 // -----------------------------------------------------------------------
2357 int SvxEscapementItem::operator==( const SfxPoolItem
& rAttr
) const
2359 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
2361 return( nEsc
== ((SvxEscapementItem
&)rAttr
).nEsc
&&
2362 nProp
== ((SvxEscapementItem
&)rAttr
).nProp
);
2365 // -----------------------------------------------------------------------
2367 SfxPoolItem
* SvxEscapementItem::Clone( SfxItemPool
* ) const
2369 return new SvxEscapementItem( *this );
2372 // -----------------------------------------------------------------------
2374 SvStream
& SvxEscapementItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2376 short _nEsc
= GetEsc();
2377 if( SOFFICE_FILEFORMAT_31
== rStrm
.GetVersion() )
2379 if( DFLT_ESC_AUTO_SUPER
== _nEsc
)
2380 _nEsc
= DFLT_ESC_SUPER
;
2381 else if( DFLT_ESC_AUTO_SUB
== _nEsc
)
2382 _nEsc
= DFLT_ESC_SUB
;
2384 rStrm
<< (sal_uInt8
) GetProp()
2389 // -----------------------------------------------------------------------
2391 SfxPoolItem
* SvxEscapementItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2395 rStrm
>> _nProp
>> _nEsc
;
2396 return new SvxEscapementItem( _nEsc
, _nProp
, Which() );
2399 // -----------------------------------------------------------------------
2401 sal_uInt16
SvxEscapementItem::GetValueCount() const
2403 return SVX_ESCAPEMENT_END
; // SVX_ESCAPEMENT_SUBSCRIPT + 1
2406 //------------------------------------------------------------------------
2408 SfxItemPresentation
SvxEscapementItem::GetPresentation
2410 SfxItemPresentation ePres
,
2411 SfxMapUnit
/*eCoreUnit*/,
2412 SfxMapUnit
/*ePresUnit*/,
2413 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2418 case SFX_ITEM_PRESENTATION_NONE
:
2421 case SFX_ITEM_PRESENTATION_NAMELESS
:
2422 case SFX_ITEM_PRESENTATION_COMPLETE
:
2424 rText
= GetValueTextByPos( GetEnumValue() );
2428 if( DFLT_ESC_AUTO_SUPER
== nEsc
|| DFLT_ESC_AUTO_SUB
== nEsc
)
2429 rText
+= EE_RESSTR(RID_SVXITEMS_ESCAPEMENT_AUTO
);
2431 rText
= rText
+ OUString::number( nEsc
) + "%";
2435 default: ; //prevent warning
2437 return SFX_ITEM_PRESENTATION_NONE
;
2440 // -----------------------------------------------------------------------
2442 OUString
SvxEscapementItem::GetValueTextByPos( sal_uInt16 nPos
) const
2444 DBG_ASSERT( nPos
< (sal_uInt16
)SVX_ESCAPEMENT_END
, "enum overflow!" );
2445 return EE_RESSTR(RID_SVXITEMS_ESCAPEMENT_BEGIN
+ nPos
);
2448 // -----------------------------------------------------------------------
2450 sal_uInt16
SvxEscapementItem::GetEnumValue() const
2453 return SVX_ESCAPEMENT_SUBSCRIPT
;
2454 else if ( nEsc
> 0 )
2455 return SVX_ESCAPEMENT_SUPERSCRIPT
;
2456 return SVX_ESCAPEMENT_OFF
;
2459 // -----------------------------------------------------------------------
2461 void SvxEscapementItem::SetEnumValue( sal_uInt16 nVal
)
2463 SetEscapement( (const SvxEscapement
)nVal
);
2466 bool SvxEscapementItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2468 nMemberId
&= ~CONVERT_TWIPS
;
2472 rVal
<<= (sal_Int16
)(nEsc
);
2474 case MID_ESC_HEIGHT
:
2475 rVal
<<= (sal_Int8
)(nProp
);
2478 rVal
= Bool2Any(DFLT_ESC_AUTO_SUB
== nEsc
|| DFLT_ESC_AUTO_SUPER
== nEsc
);
2484 bool SvxEscapementItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2486 nMemberId
&= ~CONVERT_TWIPS
;
2491 sal_Int16 nVal
= sal_Int16();
2492 if( (rVal
>>= nVal
) && (std::abs(nVal
) <= 101))
2498 case MID_ESC_HEIGHT
:
2500 sal_Int8 nVal
= sal_Int8();
2501 if( (rVal
>>= nVal
) && (nVal
<= 100))
2509 sal_Bool bVal
= Any2Bool(rVal
);
2513 nEsc
= DFLT_ESC_AUTO_SUB
;
2515 nEsc
= DFLT_ESC_AUTO_SUPER
;
2518 if(DFLT_ESC_AUTO_SUPER
== nEsc
)
2520 else if(DFLT_ESC_AUTO_SUB
== nEsc
)
2528 // class SvxLanguageItem -------------------------------------------------
2530 SvxLanguageItem::SvxLanguageItem( const LanguageType eLang
, const sal_uInt16 nId
)
2531 : SfxEnumItem( nId
, eLang
)
2535 // -----------------------------------------------------------------------
2537 sal_uInt16
SvxLanguageItem::GetValueCount() const
2539 // #i50205# got rid of class International
2540 SAL_WARN( "editeng.items", "SvxLanguageItem::GetValueCount: supposed to return a count of what?");
2541 // FIXME: previously returned LANGUAGE_COUNT from tools/intn.hxx which was wrong anyway.
2542 // Could be SvtLanguageTable::GetEntryCount() (all locales with resource string)?
2543 // Could be LocaleDataWrapper::getInstalledLanguageTypes() (all locales with locale data)?
2547 // -----------------------------------------------------------------------
2549 SfxPoolItem
* SvxLanguageItem::Clone( SfxItemPool
* ) const
2551 return new SvxLanguageItem( *this );
2554 // -----------------------------------------------------------------------
2556 SvStream
& SvxLanguageItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2558 rStrm
<< (sal_uInt16
) GetValue();
2562 // -----------------------------------------------------------------------
2564 SfxPoolItem
* SvxLanguageItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2568 return new SvxLanguageItem( (LanguageType
)nValue
, Which() );
2571 //------------------------------------------------------------------------
2573 SfxItemPresentation
SvxLanguageItem::GetPresentation
2575 SfxItemPresentation ePres
,
2576 SfxMapUnit
/*eCoreUnit*/,
2577 SfxMapUnit
/*ePresUnit*/,
2578 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2583 case SFX_ITEM_PRESENTATION_NONE
:
2586 case SFX_ITEM_PRESENTATION_NAMELESS
:
2587 case SFX_ITEM_PRESENTATION_COMPLETE
:
2589 SvtLanguageTable aLangTable
;
2590 rText
= aLangTable
.GetString( (LanguageType
)GetValue() );
2593 default: ; //prevent warning
2595 return SFX_ITEM_PRESENTATION_NONE
;
2598 bool SvxLanguageItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2600 nMemberId
&= ~CONVERT_TWIPS
;
2603 case MID_LANG_INT
: // for basic conversions!
2604 rVal
<<= (sal_Int16
)(GetValue());
2606 case MID_LANG_LOCALE
:
2607 lang::Locale
aRet( LanguageTag( GetValue()).getLocale( false));
2614 bool SvxLanguageItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2616 nMemberId
&= ~CONVERT_TWIPS
;
2619 case MID_LANG_INT
: // for basic conversions!
2621 sal_Int32 nValue
= 0;
2622 if(!(rVal
>>= nValue
))
2625 SetValue((sal_Int16
)nValue
);
2628 case MID_LANG_LOCALE
:
2630 lang::Locale aLocale
;
2631 if(!(rVal
>>= aLocale
))
2634 SetValue( LanguageTag( aLocale
).getLanguageType( false));
2641 // class SvxNoLinebreakItem ----------------------------------------------
2642 SvxNoLinebreakItem::SvxNoLinebreakItem( const sal_Bool bBreak
, const sal_uInt16 nId
) :
2643 SfxBoolItem( nId
, bBreak
)
2647 // -----------------------------------------------------------------------
2649 SfxPoolItem
* SvxNoLinebreakItem::Clone( SfxItemPool
* ) const
2651 return new SvxNoLinebreakItem( *this );
2654 // -----------------------------------------------------------------------
2656 SvStream
& SvxNoLinebreakItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2658 rStrm
<< (sal_Bool
)GetValue();
2662 // -----------------------------------------------------------------------
2664 SfxPoolItem
* SvxNoLinebreakItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2668 return new SvxNoLinebreakItem( bValue
, Which() );
2671 //------------------------------------------------------------------------
2673 SfxItemPresentation
SvxNoLinebreakItem::GetPresentation
2675 SfxItemPresentation
/*ePres*/,
2676 SfxMapUnit
/*eCoreUnit*/,
2677 SfxMapUnit
/*ePresUnit*/,
2678 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2682 return SFX_ITEM_PRESENTATION_NONE
;
2685 // class SvxNoHyphenItem -------------------------------------------------
2687 SvxNoHyphenItem::SvxNoHyphenItem( const sal_Bool bHyphen
, const sal_uInt16 nId
) :
2688 SfxBoolItem( nId
, bHyphen
)
2692 // -----------------------------------------------------------------------
2694 SfxPoolItem
* SvxNoHyphenItem::Clone( SfxItemPool
* ) const
2696 return new SvxNoHyphenItem( *this );
2699 // -----------------------------------------------------------------------
2701 SvStream
& SvxNoHyphenItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2703 rStrm
<< (sal_Bool
) GetValue();
2707 // -----------------------------------------------------------------------
2709 SfxPoolItem
* SvxNoHyphenItem::Create( SvStream
& rStrm
, sal_uInt16
) const
2713 return new SvxNoHyphenItem( bValue
, Which() );
2716 //------------------------------------------------------------------------
2718 SfxItemPresentation
SvxNoHyphenItem::GetPresentation
2720 SfxItemPresentation
/*ePres*/,
2721 SfxMapUnit
/*eCoreUnit*/,
2722 SfxMapUnit
/*ePresUnit*/,
2723 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2727 return SFX_ITEM_PRESENTATION_NONE
;
2731 * Dummy item for ToolBox controls:
2735 // -----------------------------------------------------------------------
2736 // class SvxLineColorItem (== SvxColorItem)
2737 // -----------------------------------------------------------------------
2739 SvxLineColorItem::SvxLineColorItem( const sal_uInt16 nId
) :
2744 // -----------------------------------------------------------------------
2746 SvxLineColorItem::SvxLineColorItem( const SvxLineColorItem
&rCopy
) :
2747 SvxColorItem( rCopy
)
2751 // -----------------------------------------------------------------------
2753 SvxLineColorItem::~SvxLineColorItem()
2757 //------------------------------------------------------------------------
2759 SfxItemPresentation
SvxLineColorItem::GetPresentation
2761 SfxItemPresentation ePres
,
2762 SfxMapUnit eCoreUnit
,
2763 SfxMapUnit ePresUnit
,
2765 const IntlWrapper
* pIntlWrapper
2768 return SvxColorItem::GetPresentation( ePres
, eCoreUnit
, ePresUnit
,
2769 rText
, pIntlWrapper
);
2772 // class SvxBlinkItem -------------------------------------------------
2775 SvxBlinkItem::SvxBlinkItem( const sal_Bool bBlink
, const sal_uInt16 nId
) :
2776 SfxBoolItem( nId
, bBlink
)
2780 // -----------------------------------------------------------------------
2782 SfxPoolItem
* SvxBlinkItem::Clone( SfxItemPool
* ) const
2784 return new SvxBlinkItem( *this );
2787 // -----------------------------------------------------------------------
2789 SvStream
& SvxBlinkItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2791 rStrm
<< (sal_uInt8
) GetValue();
2795 // -----------------------------------------------------------------------
2797 SfxPoolItem
* SvxBlinkItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2801 return new SvxBlinkItem( nState
, Which() );
2804 // -----------------------------------------------------------------------
2806 SfxItemPresentation
SvxBlinkItem::GetPresentation
2808 SfxItemPresentation ePres
,
2809 SfxMapUnit
/*eCoreUnit*/,
2810 SfxMapUnit
/*ePresUnit*/,
2811 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2816 case SFX_ITEM_PRESENTATION_NONE
:
2819 case SFX_ITEM_PRESENTATION_NAMELESS
:
2820 case SFX_ITEM_PRESENTATION_COMPLETE
:
2822 sal_uInt16 nId
= RID_SVXITEMS_BLINK_FALSE
;
2825 nId
= RID_SVXITEMS_BLINK_TRUE
;
2826 rText
= EE_RESSTR(nId
);
2829 default: ; //prevent warning
2831 return SFX_ITEM_PRESENTATION_NONE
;
2834 // class SvxEmphaisMarkItem ---------------------------------------------------
2836 SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue
,
2837 const sal_uInt16 nId
)
2838 : SfxUInt16Item( nId
, nValue
)
2842 // -----------------------------------------------------------------------
2844 SfxPoolItem
* SvxEmphasisMarkItem::Clone( SfxItemPool
* ) const
2846 return new SvxEmphasisMarkItem( *this );
2849 // -----------------------------------------------------------------------
2851 SvStream
& SvxEmphasisMarkItem::Store( SvStream
& rStrm
,
2852 sal_uInt16
/*nItemVersion*/ ) const
2854 rStrm
<< (sal_uInt16
)GetValue();
2858 // -----------------------------------------------------------------------
2860 SfxPoolItem
* SvxEmphasisMarkItem::Create( SvStream
& rStrm
, sal_uInt16
) const
2864 return new SvxEmphasisMarkItem( (FontEmphasisMark
)nValue
, Which() );
2867 //------------------------------------------------------------------------
2869 SfxItemPresentation
SvxEmphasisMarkItem::GetPresentation
2871 SfxItemPresentation ePres
,
2872 SfxMapUnit
/*eCoreUnit*/,
2873 SfxMapUnit
/*ePresUnit*/,
2875 const IntlWrapper
* /*pIntl*/
2880 case SFX_ITEM_PRESENTATION_NONE
:
2883 case SFX_ITEM_PRESENTATION_NAMELESS
:
2884 case SFX_ITEM_PRESENTATION_COMPLETE
:
2886 sal_uInt16 nVal
= GetValue();
2887 rText
= EE_RESSTR( RID_SVXITEMS_EMPHASIS_BEGIN_STYLE
+
2888 ( EMPHASISMARK_STYLE
& nVal
));
2889 sal_uInt16 nId
= ( EMPHASISMARK_POS_ABOVE
& nVal
)
2890 ? RID_SVXITEMS_EMPHASIS_ABOVE_POS
2891 : ( EMPHASISMARK_POS_BELOW
& nVal
)
2892 ? RID_SVXITEMS_EMPHASIS_BELOW_POS
2895 rText
+= EE_RESSTR( nId
);
2898 default: ; //prevent warning
2900 return SFX_ITEM_PRESENTATION_NONE
;
2903 // -----------------------------------------------------------------------
2905 bool SvxEmphasisMarkItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2907 nMemberId
&= ~CONVERT_TWIPS
;
2912 sal_Int16 nValue
= GetValue();
2914 switch(nValue
& EMPHASISMARK_STYLE
)
2916 case EMPHASISMARK_NONE
: nRet
= FontEmphasis::NONE
; break;
2917 case EMPHASISMARK_DOT
: nRet
= FontEmphasis::DOT_ABOVE
; break;
2918 case EMPHASISMARK_CIRCLE
: nRet
= FontEmphasis::CIRCLE_ABOVE
; break;
2919 case EMPHASISMARK_DISC
: nRet
= FontEmphasis::DISK_ABOVE
; break;
2920 case EMPHASISMARK_ACCENT
: nRet
= FontEmphasis::ACCENT_ABOVE
; break;
2922 if(nRet
&& nValue
& EMPHASISMARK_POS_BELOW
)
2931 bool SvxEmphasisMarkItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2933 nMemberId
&= ~CONVERT_TWIPS
;
2934 sal_Bool bRet
= true;
2939 sal_Int32 nValue
= -1;
2943 case FontEmphasis::NONE
: nValue
= EMPHASISMARK_NONE
; break;
2944 case FontEmphasis::DOT_ABOVE
: nValue
= EMPHASISMARK_DOT
|EMPHASISMARK_POS_ABOVE
; break;
2945 case FontEmphasis::CIRCLE_ABOVE
: nValue
= EMPHASISMARK_CIRCLE
|EMPHASISMARK_POS_ABOVE
; break;
2946 case FontEmphasis::DISK_ABOVE
: nValue
= EMPHASISMARK_DISC
|EMPHASISMARK_POS_ABOVE
; break;
2947 case FontEmphasis::ACCENT_ABOVE
: nValue
= EMPHASISMARK_ACCENT
|EMPHASISMARK_POS_ABOVE
; break;
2948 case FontEmphasis::DOT_BELOW
: nValue
= EMPHASISMARK_DOT
|EMPHASISMARK_POS_BELOW
; break;
2949 case FontEmphasis::CIRCLE_BELOW
: nValue
= EMPHASISMARK_CIRCLE
|EMPHASISMARK_POS_BELOW
; break;
2950 case FontEmphasis::DISK_BELOW
: nValue
= EMPHASISMARK_DISC
|EMPHASISMARK_POS_BELOW
; break;
2951 case FontEmphasis::ACCENT_BELOW
: nValue
= EMPHASISMARK_ACCENT
|EMPHASISMARK_POS_BELOW
; break;
2952 default: return false;
2954 SetValue( (sal_Int16
)nValue
);
2961 sal_uInt16
SvxEmphasisMarkItem::GetVersion( sal_uInt16 nFFVer
) const
2963 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
2964 SOFFICE_FILEFORMAT_40
==nFFVer
||
2965 SOFFICE_FILEFORMAT_50
==nFFVer
,
2966 "SvxEmphasisMarkItem: Is there a new file format? ");
2968 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
2972 /*************************************************************************
2973 |* class SvxTwoLinesItem
2974 *************************************************************************/
2976 SvxTwoLinesItem::SvxTwoLinesItem( sal_Bool bFlag
, sal_Unicode nStartBracket
,
2977 sal_Unicode nEndBracket
, sal_uInt16 nW
)
2978 : SfxPoolItem( nW
),
2979 cStartBracket( nStartBracket
), cEndBracket( nEndBracket
), bOn( bFlag
)
2983 SvxTwoLinesItem::SvxTwoLinesItem( const SvxTwoLinesItem
& rAttr
)
2984 : SfxPoolItem( rAttr
.Which() ),
2985 cStartBracket( rAttr
.cStartBracket
),
2986 cEndBracket( rAttr
.cEndBracket
),
2991 SvxTwoLinesItem::~SvxTwoLinesItem()
2995 int SvxTwoLinesItem::operator==( const SfxPoolItem
& rAttr
) const
2997 DBG_ASSERT( SfxPoolItem::operator==( rAttr
), "not equal attribute types" );
2998 return bOn
== ((SvxTwoLinesItem
&)rAttr
).bOn
&&
2999 cStartBracket
== ((SvxTwoLinesItem
&)rAttr
).cStartBracket
&&
3000 cEndBracket
== ((SvxTwoLinesItem
&)rAttr
).cEndBracket
;
3003 SfxPoolItem
* SvxTwoLinesItem::Clone( SfxItemPool
* ) const
3005 return new SvxTwoLinesItem( *this );
3008 bool SvxTwoLinesItem::QueryValue( com::sun::star::uno::Any
& rVal
,
3009 sal_uInt8 nMemberId
) const
3011 nMemberId
&= ~CONVERT_TWIPS
;
3012 sal_Bool bRet
= true;
3016 rVal
= Bool2Any( bOn
);
3018 case MID_START_BRACKET
:
3022 s
= OUString( cStartBracket
);
3026 case MID_END_BRACKET
:
3030 s
= OUString( cEndBracket
);
3041 bool SvxTwoLinesItem::PutValue( const com::sun::star::uno::Any
& rVal
,
3042 sal_uInt8 nMemberId
)
3044 nMemberId
&= ~CONVERT_TWIPS
;
3045 sal_Bool bRet
= sal_False
;
3050 bOn
= Any2Bool( rVal
);
3053 case MID_START_BRACKET
:
3056 cStartBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
3060 case MID_END_BRACKET
:
3063 cEndBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
3071 SfxItemPresentation
SvxTwoLinesItem::GetPresentation( SfxItemPresentation ePres
,
3072 SfxMapUnit
/*eCoreMetric*/, SfxMapUnit
/*ePresMetric*/,
3073 OUString
&rText
, const IntlWrapper
* /*pIntl*/ ) const
3077 case SFX_ITEM_PRESENTATION_NONE
:
3080 case SFX_ITEM_PRESENTATION_NAMELESS
:
3081 case SFX_ITEM_PRESENTATION_COMPLETE
:
3084 rText
= EE_RESSTR( RID_SVXITEMS_TWOLINES_OFF
);
3087 rText
= EE_RESSTR( RID_SVXITEMS_TWOLINES
);
3088 if( GetStartBracket() )
3089 rText
= OUString(GetStartBracket()) + rText
;
3090 if( GetEndBracket() )
3091 rText
+= OUString(GetEndBracket());
3095 default: ; //prevent warning
3097 return SFX_ITEM_PRESENTATION_NONE
;
3101 SfxPoolItem
* SvxTwoLinesItem::Create( SvStream
& rStrm
, sal_uInt16
/*nVer*/) const
3104 sal_Unicode cStart
, cEnd
;
3105 rStrm
>> _bOn
>> cStart
>> cEnd
;
3106 return new SvxTwoLinesItem( _bOn
, cStart
, cEnd
, Which() );
3109 SvStream
& SvxTwoLinesItem::Store(SvStream
& rStrm
, sal_uInt16
/*nIVer*/) const
3111 rStrm
<< GetValue() << GetStartBracket() << GetEndBracket();
3115 sal_uInt16
SvxTwoLinesItem::GetVersion( sal_uInt16 nFFVer
) const
3117 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
3118 SOFFICE_FILEFORMAT_40
==nFFVer
||
3119 SOFFICE_FILEFORMAT_50
==nFFVer
,
3120 "SvxTwoLinesItem: Gibt es ein neues Fileformat?" );
3122 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
3126 /*************************************************************************
3127 |* class SvxCharRotateItem
3128 *************************************************************************/
3130 SvxCharRotateItem::SvxCharRotateItem( sal_uInt16 nValue
,
3131 sal_Bool bFitIntoLine
,
3132 const sal_uInt16 nW
)
3133 : SfxUInt16Item( nW
, nValue
), bFitToLine( bFitIntoLine
)
3137 SfxPoolItem
* SvxCharRotateItem::Clone( SfxItemPool
* ) const
3139 return new SvxCharRotateItem( GetValue(), IsFitToLine(), Which() );
3142 SfxPoolItem
* SvxCharRotateItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3147 return new SvxCharRotateItem( nVal
, b
, Which() );
3150 SvStream
& SvxCharRotateItem::Store( SvStream
& rStrm
, sal_uInt16
) const
3152 sal_Bool bFlag
= IsFitToLine();
3153 rStrm
<< GetValue() << bFlag
;
3157 sal_uInt16
SvxCharRotateItem::GetVersion( sal_uInt16 nFFVer
) const
3159 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
3162 SfxItemPresentation
SvxCharRotateItem::GetPresentation(
3163 SfxItemPresentation ePres
,
3164 SfxMapUnit
/*eCoreMetric*/, SfxMapUnit
/*ePresMetric*/,
3165 OUString
&rText
, const IntlWrapper
* ) const
3169 case SFX_ITEM_PRESENTATION_NONE
:
3172 case SFX_ITEM_PRESENTATION_NAMELESS
:
3173 case SFX_ITEM_PRESENTATION_COMPLETE
:
3176 rText
= EE_RESSTR( RID_SVXITEMS_CHARROTATE_OFF
);
3179 rText
= EE_RESSTR( RID_SVXITEMS_CHARROTATE
);
3180 rText
= rText
.replaceFirst( "$(ARG1)",
3181 OUString::number( GetValue() / 10 ));
3183 rText
+= EE_RESSTR( RID_SVXITEMS_CHARROTATE_FITLINE
);
3187 default: ; //prevent warning
3189 return SFX_ITEM_PRESENTATION_NONE
;
3192 bool SvxCharRotateItem::QueryValue( com::sun::star::uno::Any
& rVal
,
3193 sal_uInt8 nMemberId
) const
3195 nMemberId
&= ~CONVERT_TWIPS
;
3200 rVal
<<= (sal_Int16
)GetValue();
3203 rVal
= Bool2Any( IsFitToLine() );
3212 bool SvxCharRotateItem::PutValue( const com::sun::star::uno::Any
& rVal
,
3213 sal_uInt8 nMemberId
)
3215 nMemberId
&= ~CONVERT_TWIPS
;
3222 if((rVal
>>= nVal
) && (0 == nVal
|| 900 == nVal
|| 2700 == nVal
))
3223 SetValue( (sal_uInt16
)nVal
);
3230 SetFitToLine( Any2Bool( rVal
) );
3238 int SvxCharRotateItem::operator==( const SfxPoolItem
& rItem
) const
3240 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
3241 return SfxUInt16Item::operator==( rItem
) &&
3242 IsFitToLine() == ((const SvxCharRotateItem
&)rItem
).IsFitToLine();
3246 /*************************************************************************
3247 |* class SvxCharScaleItem
3248 *************************************************************************/
3250 SvxCharScaleWidthItem::SvxCharScaleWidthItem( sal_uInt16 nValue
,
3251 const sal_uInt16 nW
)
3252 : SfxUInt16Item( nW
, nValue
)
3256 SfxPoolItem
* SvxCharScaleWidthItem::Clone( SfxItemPool
* ) const
3258 return new SvxCharScaleWidthItem( GetValue(), Which() );
3261 SfxPoolItem
* SvxCharScaleWidthItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3265 SvxCharScaleWidthItem
* pItem
= new SvxCharScaleWidthItem( nVal
, Which() );
3267 if ( Which() == EE_CHAR_FONTWIDTH
)
3269 // Was a SvxFontWidthItem in 5.2
3270 // sal_uInt16 nFixWidth, sal_uInt16 nPropWidth.
3271 // nFixWidth has never been used...
3275 if ( nTest
== 0x1234 )
3276 pItem
->SetValue( nVal
);
3278 rStrm
.SeekRel( -2*(long)sizeof(sal_uInt16
) );
3284 SvStream
& SvxCharScaleWidthItem::Store( SvStream
& rStream
, sal_uInt16 nVer
) const
3286 SvStream
& rRet
= SfxUInt16Item::Store( rStream
, nVer
);
3287 if ( Which() == EE_CHAR_FONTWIDTH
)
3289 // see comment in Create()....
3290 rRet
.SeekRel( -1*(long)sizeof(sal_uInt16
) );
3291 rRet
<< (sal_uInt16
)0;
3293 // Really ugly, but not a problem for reading the doc in 5.2
3294 rRet
<< (sal_uInt16
)0x1234;
3300 sal_uInt16
SvxCharScaleWidthItem::GetVersion( sal_uInt16 nFFVer
) const
3302 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
3305 SfxItemPresentation
SvxCharScaleWidthItem::GetPresentation(
3306 SfxItemPresentation ePres
,
3307 SfxMapUnit
/*eCoreMetric*/, SfxMapUnit
/*ePresMetric*/,
3308 OUString
&rText
, const IntlWrapper
* ) const
3312 case SFX_ITEM_PRESENTATION_NONE
:
3315 case SFX_ITEM_PRESENTATION_NAMELESS
:
3316 case SFX_ITEM_PRESENTATION_COMPLETE
:
3319 rText
= EE_RESSTR( RID_SVXITEMS_CHARSCALE_OFF
);
3322 rText
= EE_RESSTR( RID_SVXITEMS_CHARSCALE
);
3323 rText
= rText
.replaceFirst( "$(ARG1)",
3324 OUString::number( GetValue() ));
3328 default: ; //prevent warning
3330 return SFX_ITEM_PRESENTATION_NONE
;
3333 bool SvxCharScaleWidthItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
3335 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
3336 // where we still want this to be a sal_Int16
3337 sal_Int16 nValue
= sal_Int16();
3338 if (rVal
>>= nValue
)
3340 SetValue( (sal_uInt16
) nValue
);
3344 OSL_TRACE( "SvxCharScaleWidthItem::PutValue - Wrong type!" );
3348 bool SvxCharScaleWidthItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
3350 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
3351 // where we still want this to be a sal_Int16
3352 rVal
<<= (sal_Int16
)GetValue();
3356 /*************************************************************************
3357 |* class SvxCharReliefItem
3358 *************************************************************************/
3360 SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue
,
3361 const sal_uInt16 nId
)
3362 : SfxEnumItem( nId
, (sal_uInt16
)eValue
)
3366 SfxPoolItem
* SvxCharReliefItem::Clone( SfxItemPool
* ) const
3368 return new SvxCharReliefItem( *this );
3371 SfxPoolItem
* SvxCharReliefItem::Create(SvStream
& rStrm
, sal_uInt16
) const
3375 return new SvxCharReliefItem( (FontRelief
)nVal
, Which() );
3378 SvStream
& SvxCharReliefItem::Store(SvStream
& rStrm
, sal_uInt16
/*nIVer*/) const
3380 sal_uInt16 nVal
= GetValue();
3385 sal_uInt16
SvxCharReliefItem::GetVersion( sal_uInt16 nFFVer
) const
3387 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
3390 OUString
SvxCharReliefItem::GetValueTextByPos( sal_uInt16 nPos
) const
3392 DBG_ASSERT( RID_SVXITEMS_RELIEF_ENGRAVED
- RID_SVXITEMS_RELIEF_NONE
,
3394 return EE_RESSTR(RID_SVXITEMS_RELIEF_BEGIN
+ nPos
);
3397 sal_uInt16
SvxCharReliefItem::GetValueCount() const
3399 return RID_SVXITEMS_RELIEF_ENGRAVED
- RID_SVXITEMS_RELIEF_NONE
;
3402 SfxItemPresentation
SvxCharReliefItem::GetPresentation
3404 SfxItemPresentation ePres
,
3405 SfxMapUnit
/*eCoreUnit*/,
3406 SfxMapUnit
/*ePresUnit*/,
3407 OUString
& rText
, const IntlWrapper
* /*pIntl*/
3410 SfxItemPresentation eRet
= ePres
;
3413 case SFX_ITEM_PRESENTATION_NONE
:
3417 case SFX_ITEM_PRESENTATION_NAMELESS
:
3418 case SFX_ITEM_PRESENTATION_COMPLETE
:
3419 rText
= GetValueTextByPos( GetValue() );
3423 eRet
= SFX_ITEM_PRESENTATION_NONE
;
3428 bool SvxCharReliefItem::PutValue( const com::sun::star::uno::Any
& rVal
,
3429 sal_uInt8 nMemberId
)
3431 nMemberId
&= ~CONVERT_TWIPS
;
3437 sal_Int16 nVal
= -1;
3439 if(nVal
>= 0 && nVal
<= RELIEF_ENGRAVED
)
3440 SetValue( (sal_uInt16
)nVal
);
3452 bool SvxCharReliefItem::QueryValue( com::sun::star::uno::Any
& rVal
,
3453 sal_uInt8 nMemberId
) const
3455 nMemberId
&= ~CONVERT_TWIPS
;
3460 rVal
<<= (sal_Int16
)GetValue();
3469 /*************************************************************************
3470 |* class SvxScriptTypeItemItem
3471 *************************************************************************/
3473 SvxScriptTypeItem::SvxScriptTypeItem( sal_uInt16 nType
)
3474 : SfxUInt16Item( SID_ATTR_CHAR_SCRIPTTYPE
, nType
)
3477 SfxPoolItem
* SvxScriptTypeItem::Clone( SfxItemPool
* ) const
3479 return new SvxScriptTypeItem( GetValue() );
3482 /*************************************************************************
3483 |* class SvxScriptSetItem
3484 *************************************************************************/
3486 SvxScriptSetItem::SvxScriptSetItem( sal_uInt16 nSlotId
, SfxItemPool
& rPool
)
3487 : SfxSetItem( nSlotId
, new SfxItemSet( rPool
,
3488 SID_ATTR_CHAR_FONT
, SID_ATTR_CHAR_FONT
))
3490 sal_uInt16 nLatin
, nAsian
, nComplex
;
3491 GetWhichIds( nLatin
, nAsian
, nComplex
);
3492 GetItemSet().MergeRange( nLatin
, nLatin
);
3493 GetItemSet().MergeRange( nAsian
, nAsian
);
3494 GetItemSet().MergeRange( nComplex
, nComplex
);
3495 GetItemSet().MergeRange( SID_ATTR_CHAR_SCRIPTTYPE
, SID_ATTR_CHAR_SCRIPTTYPE
);
3498 SfxPoolItem
* SvxScriptSetItem::Clone( SfxItemPool
* ) const
3500 SvxScriptSetItem
* p
= new SvxScriptSetItem( Which(), *GetItemSet().GetPool() );
3501 p
->GetItemSet().Put( GetItemSet(), sal_False
);
3505 SfxPoolItem
* SvxScriptSetItem::Create( SvStream
&, sal_uInt16
) const
3510 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScriptSet(
3511 const SfxItemSet
& rSet
, sal_uInt16 nId
)
3513 const SfxPoolItem
* pI
;
3514 SfxItemState eSt
= rSet
.GetItemState( nId
, sal_False
, &pI
);
3515 if( SFX_ITEM_SET
!= eSt
)
3516 pI
= SFX_ITEM_DEFAULT
== eSt
? &rSet
.Get( nId
) : 0;
3520 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, sal_uInt16 nScript
)
3522 sal_uInt16 nLatin
, nAsian
, nComplex
;
3523 GetWhichIds( nSlotId
, rSet
, nLatin
, nAsian
, nComplex
);
3525 const SfxPoolItem
*pRet
, *pAsn
, *pCmplx
;
3528 default: //no one valid -> match to latin
3529 // case SCRIPTTYPE_LATIN:
3530 pRet
= GetItemOfScriptSet( rSet
, nLatin
);
3532 case SCRIPTTYPE_ASIAN
:
3533 pRet
= GetItemOfScriptSet( rSet
, nAsian
);
3535 case SCRIPTTYPE_COMPLEX
:
3536 pRet
= GetItemOfScriptSet( rSet
, nComplex
);
3539 case SCRIPTTYPE_LATIN
|SCRIPTTYPE_ASIAN
:
3540 if( 0 == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
3541 0 == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
3546 case SCRIPTTYPE_LATIN
|SCRIPTTYPE_COMPLEX
:
3547 if( 0 == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
3548 0 == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
3553 case SCRIPTTYPE_ASIAN
|SCRIPTTYPE_COMPLEX
:
3554 if( 0 == (pRet
= GetItemOfScriptSet( rSet
, nAsian
)) ||
3555 0 == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
3560 case SCRIPTTYPE_LATIN
|SCRIPTTYPE_ASIAN
|SCRIPTTYPE_COMPLEX
:
3561 if( 0 == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
3562 0 == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
3563 0 == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
3564 *pRet
!= *pAsn
|| *pRet
!= *pCmplx
)
3571 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nScript
) const
3573 return GetItemOfScript( Which(), GetItemSet(), nScript
);
3576 void SvxScriptSetItem::PutItemForScriptType( sal_uInt16 nScriptType
,
3577 const SfxPoolItem
& rItem
)
3579 sal_uInt16 nLatin
, nAsian
, nComplex
;
3580 GetWhichIds( nLatin
, nAsian
, nComplex
);
3582 SfxPoolItem
* pCpy
= rItem
.Clone();
3583 if( SCRIPTTYPE_LATIN
& nScriptType
)
3585 pCpy
->SetWhich( nLatin
);
3586 GetItemSet().Put( *pCpy
);
3588 if( SCRIPTTYPE_ASIAN
& nScriptType
)
3590 pCpy
->SetWhich( nAsian
);
3591 GetItemSet().Put( *pCpy
);
3593 if( SCRIPTTYPE_COMPLEX
& nScriptType
)
3595 pCpy
->SetWhich( nComplex
);
3596 GetItemSet().Put( *pCpy
);
3601 void SvxScriptSetItem::GetWhichIds( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, sal_uInt16
& rLatin
, sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
3603 const SfxItemPool
& rPool
= *rSet
.GetPool();
3604 GetSlotIds( nSlotId
, rLatin
, rAsian
, rComplex
);
3605 rLatin
= rPool
.GetWhich( rLatin
);
3606 rAsian
= rPool
.GetWhich( rAsian
);
3607 rComplex
= rPool
.GetWhich( rComplex
);
3610 void SvxScriptSetItem::GetWhichIds( sal_uInt16
& rLatin
, sal_uInt16
& rAsian
,
3611 sal_uInt16
& rComplex
) const
3613 GetWhichIds( Which(), GetItemSet(), rLatin
, rAsian
, rComplex
);
3616 void SvxScriptSetItem::GetSlotIds( sal_uInt16 nSlotId
, sal_uInt16
& rLatin
,
3617 sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
3622 DBG_ASSERT( sal_False
, "wrong SlotId for class SvxScriptSetItem" );
3623 // no break - default to font - Id Range !!
3625 case SID_ATTR_CHAR_FONT
:
3626 rLatin
= SID_ATTR_CHAR_FONT
;
3627 rAsian
= SID_ATTR_CHAR_CJK_FONT
;
3628 rComplex
= SID_ATTR_CHAR_CTL_FONT
;
3630 case SID_ATTR_CHAR_FONTHEIGHT
:
3631 rLatin
= SID_ATTR_CHAR_FONTHEIGHT
;
3632 rAsian
= SID_ATTR_CHAR_CJK_FONTHEIGHT
;
3633 rComplex
= SID_ATTR_CHAR_CTL_FONTHEIGHT
;
3635 case SID_ATTR_CHAR_WEIGHT
:
3636 rLatin
= SID_ATTR_CHAR_WEIGHT
;
3637 rAsian
= SID_ATTR_CHAR_CJK_WEIGHT
;
3638 rComplex
= SID_ATTR_CHAR_CTL_WEIGHT
;
3640 case SID_ATTR_CHAR_POSTURE
:
3641 rLatin
= SID_ATTR_CHAR_POSTURE
;
3642 rAsian
= SID_ATTR_CHAR_CJK_POSTURE
;
3643 rComplex
= SID_ATTR_CHAR_CTL_POSTURE
;
3645 case SID_ATTR_CHAR_LANGUAGE
:
3646 rLatin
= SID_ATTR_CHAR_LANGUAGE
;
3647 rAsian
= SID_ATTR_CHAR_CJK_LANGUAGE
;
3648 rComplex
= SID_ATTR_CHAR_CTL_LANGUAGE
;
3650 case SID_ATTR_CHAR_SHADOWED
:
3651 rLatin
= SID_ATTR_CHAR_SHADOWED
;
3652 rAsian
= SID_ATTR_CHAR_SHADOWED
;
3653 rComplex
= SID_ATTR_CHAR_SHADOWED
;
3655 case SID_ATTR_CHAR_STRIKEOUT
:
3656 rLatin
= SID_ATTR_CHAR_STRIKEOUT
;
3657 rAsian
= SID_ATTR_CHAR_STRIKEOUT
;
3658 rComplex
= SID_ATTR_CHAR_STRIKEOUT
;
3663 void GetDefaultFonts( SvxFontItem
& rLatin
, SvxFontItem
& rAsian
, SvxFontItem
& rComplex
)
3665 const sal_uInt16 nItemCnt
= 3;
3669 sal_uInt16 nFontType
;
3670 sal_uInt16 nLanguage
;
3672 aOutTypeArr
[ nItemCnt
] =
3674 { DEFAULTFONT_LATIN_TEXT
, LANGUAGE_ENGLISH_US
},
3675 { DEFAULTFONT_CJK_TEXT
, LANGUAGE_ENGLISH_US
},
3676 { DEFAULTFONT_CTL_TEXT
, LANGUAGE_ARABIC_SAUDI_ARABIA
}
3679 SvxFontItem
* aItemArr
[ nItemCnt
] = { &rLatin
, &rAsian
, &rComplex
};
3681 for ( sal_uInt16 n
= 0; n
< nItemCnt
; ++n
)
3683 Font
aFont( OutputDevice::GetDefaultFont( aOutTypeArr
[ n
].nFontType
,
3684 aOutTypeArr
[ n
].nLanguage
,
3685 DEFAULTFONT_FLAGS_ONLYONE
, 0 ) );
3686 SvxFontItem
* pItem
= aItemArr
[ n
];
3687 pItem
->SetFamily( aFont
.GetFamily() );
3688 pItem
->SetFamilyName( aFont
.GetName() );
3689 pItem
->SetStyleName( String() );
3690 pItem
->SetPitch( aFont
.GetPitch());
3691 pItem
->SetCharSet(aFont
.GetCharSet());
3696 sal_uInt16
GetI18NScriptTypeOfLanguage( sal_uInt16 nLang
)
3698 return GetI18NScriptType( SvtLanguageOptions::GetScriptTypeOfLanguage( nLang
) );
3701 sal_uInt16
GetItemScriptType( short nI18NType
)
3703 switch ( nI18NType
)
3705 case i18n::ScriptType::LATIN
: return SCRIPTTYPE_LATIN
;
3706 case i18n::ScriptType::ASIAN
: return SCRIPTTYPE_ASIAN
;
3707 case i18n::ScriptType::COMPLEX
: return SCRIPTTYPE_COMPLEX
;
3712 short GetI18NScriptType( sal_uInt16 nItemType
)
3714 switch ( nItemType
)
3716 case SCRIPTTYPE_LATIN
: return i18n::ScriptType::LATIN
;
3717 case SCRIPTTYPE_ASIAN
: return i18n::ScriptType::ASIAN
;
3718 case SCRIPTTYPE_COMPLEX
: return i18n::ScriptType::COMPLEX
;
3723 bool SvxRsidItem::QueryValue( uno::Any
& rVal
, sal_uInt8
) const
3725 rVal
<<= ( (sal_uInt32
)GetValue() );
3729 bool SvxRsidItem::PutValue( const uno::Any
& rVal
, sal_uInt8
)
3731 sal_uInt32 nRsid
= 0;
3732 if( !( rVal
>>= nRsid
) )
3739 SfxPoolItem
* SvxRsidItem::Clone( SfxItemPool
* ) const
3741 return new SvxRsidItem( *this );
3744 SfxPoolItem
* SvxRsidItem::Create(SvStream
& rIn
, sal_uInt16
) const
3746 return new SvxRsidItem( rIn
, Which() );
3748 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */