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
377 GetFamilyName().EqualsAscii( "StarSymbol", 0, sizeof("StarSymbol")-1 ) ||
378 GetFamilyName().EqualsAscii( "OpenSymbol", 0, sizeof("OpenSymbol")-1 );
380 rStrm
<< (sal_uInt8
) GetFamily() << (sal_uInt8
) GetPitch()
381 << (sal_uInt8
)(bToBats
? RTL_TEXTENCODING_SYMBOL
: GetSOStoreTextEncoding(GetCharSet()));
383 String
aStoreFamilyName( GetFamilyName() );
385 aStoreFamilyName
= String( "StarBats", sizeof("StarBats")-1, RTL_TEXTENCODING_ASCII_US
);
386 rStrm
.WriteUniOrByteString(aStoreFamilyName
, rStrm
.GetStreamCharSet());
387 rStrm
.WriteUniOrByteString(GetStyleName(), rStrm
.GetStreamCharSet());
389 // cach for EditEngine, only set while creating clipboard stream.
390 if ( bEnableStoreUnicodeNames
)
392 sal_uInt32 nMagic
= STORE_UNICODE_MAGIC_MARKER
;
394 rStrm
.WriteUniOrByteString( aStoreFamilyName
, RTL_TEXTENCODING_UNICODE
);
395 rStrm
.WriteUniOrByteString( GetStyleName(), RTL_TEXTENCODING_UNICODE
);
401 // -----------------------------------------------------------------------
403 SfxPoolItem
* SvxFontItem::Create(SvStream
& rStrm
, sal_uInt16
) const
405 sal_uInt8 _eFamily
, eFontPitch
, eFontTextEncoding
;
406 String aName
, aStyle
;
409 rStrm
>> eFontTextEncoding
;
411 // UNICODE: rStrm >> aName;
412 aName
= rStrm
.ReadUniOrByteString(rStrm
.GetStreamCharSet());
414 // UNICODE: rStrm >> aStyle;
415 aStyle
= rStrm
.ReadUniOrByteString(rStrm
.GetStreamCharSet());
417 // Set the "correct" textencoding
418 eFontTextEncoding
= (sal_uInt8
)GetSOLoadTextEncoding( eFontTextEncoding
);
420 // at some point, the StarBats changes from ANSI font to SYMBOL font
421 if ( RTL_TEXTENCODING_SYMBOL
!= eFontTextEncoding
&& aName
.EqualsAscii("StarBats") )
422 eFontTextEncoding
= RTL_TEXTENCODING_SYMBOL
;
424 // Check if we have stored unicode
425 sal_Size nStreamPos
= rStrm
.Tell();
426 sal_uInt32 nMagic
= STORE_UNICODE_MAGIC_MARKER
;
428 if ( nMagic
== STORE_UNICODE_MAGIC_MARKER
)
430 aName
= rStrm
.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE
);
431 aStyle
= rStrm
.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE
);
435 rStrm
.Seek( nStreamPos
);
440 return new SvxFontItem( (FontFamily
)_eFamily
, aName
, aStyle
,
441 (FontPitch
)eFontPitch
, (rtl_TextEncoding
)eFontTextEncoding
, Which() );
444 //------------------------------------------------------------------------
446 SfxItemPresentation
SvxFontItem::GetPresentation
448 SfxItemPresentation ePres
,
449 SfxMapUnit
/*eCoreUnit*/,
450 SfxMapUnit
/*ePresUnit*/,
451 OUString
& rText
, const IntlWrapper
* /*pIntl*/
456 case SFX_ITEM_PRESENTATION_NONE
:
459 case SFX_ITEM_PRESENTATION_NAMELESS
:
460 case SFX_ITEM_PRESENTATION_COMPLETE
:
463 default: ; //prevent warning
465 return SFX_ITEM_PRESENTATION_NONE
;
468 //------------------------------------------------------------------------
470 void SvxFontItem::EnableStoreUnicodeNames( sal_Bool bEnable
)
472 bEnableStoreUnicodeNames
= bEnable
;
475 // class SvxPostureItem --------------------------------------------------
477 SvxPostureItem::SvxPostureItem( const FontItalic ePosture
, const sal_uInt16 nId
) :
478 SfxEnumItem( nId
, (sal_uInt16
)ePosture
)
482 // -----------------------------------------------------------------------
484 SfxPoolItem
* SvxPostureItem::Clone( SfxItemPool
* ) const
486 return new SvxPostureItem( *this );
489 // -----------------------------------------------------------------------
491 sal_uInt16
SvxPostureItem::GetValueCount() const
493 return ITALIC_NORMAL
+ 1; // ITALIC_NONE also belongs here
496 // -----------------------------------------------------------------------
498 SvStream
& SvxPostureItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
500 rStrm
<< (sal_uInt8
)GetValue();
504 // -----------------------------------------------------------------------
506 SfxPoolItem
* SvxPostureItem::Create(SvStream
& rStrm
, sal_uInt16
) const
510 return new SvxPostureItem( (const FontItalic
)nPosture
, Which() );
513 //------------------------------------------------------------------------
515 SfxItemPresentation
SvxPostureItem::GetPresentation
517 SfxItemPresentation ePres
,
518 SfxMapUnit
/*eCoreUnit*/,
519 SfxMapUnit
/*ePresUnit*/,
520 OUString
& rText
, const IntlWrapper
* /*pIntl*/
525 case SFX_ITEM_PRESENTATION_NONE
:
528 case SFX_ITEM_PRESENTATION_NAMELESS
:
529 case SFX_ITEM_PRESENTATION_COMPLETE
:
530 rText
= GetValueTextByPos( GetValue() );
532 default: ;//prevent warning
534 return SFX_ITEM_PRESENTATION_NONE
;
537 // -----------------------------------------------------------------------
539 OUString
SvxPostureItem::GetValueTextByPos( sal_uInt16 nPos
) const
541 DBG_ASSERT( nPos
<= (sal_uInt16
)ITALIC_NORMAL
, "enum overflow!" );
543 FontItalic eItalic
= (FontItalic
)nPos
;
548 case ITALIC_NONE
: nId
= RID_SVXITEMS_ITALIC_NONE
; break;
549 case ITALIC_OBLIQUE
: nId
= RID_SVXITEMS_ITALIC_OBLIQUE
; break;
550 case ITALIC_NORMAL
: nId
= RID_SVXITEMS_ITALIC_NORMAL
; break;
551 default: ;//prevent warning
554 return nId
? EE_RESSTR(nId
) : OUString();
557 bool SvxPostureItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
559 nMemberId
&= ~CONVERT_TWIPS
;
563 rVal
= Bool2Any(GetBoolValue());
566 rVal
<<= (awt::FontSlant
)GetValue(); // values from awt::FontSlant and FontItalic are equal
572 bool SvxPostureItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
574 nMemberId
&= ~CONVERT_TWIPS
;
578 SetBoolValue(Any2Bool(rVal
));
582 awt::FontSlant eSlant
;
583 if(!(rVal
>>= eSlant
))
585 sal_Int32 nValue
= 0;
586 if(!(rVal
>>= nValue
))
589 eSlant
= (awt::FontSlant
)nValue
;
591 SetValue((sal_uInt16
)eSlant
);
596 // -----------------------------------------------------------------------
598 int SvxPostureItem::HasBoolValue() const
603 // -----------------------------------------------------------------------
605 sal_Bool
SvxPostureItem::GetBoolValue() const
607 return ( (FontItalic
)GetValue() >= ITALIC_OBLIQUE
);
610 // -----------------------------------------------------------------------
612 void SvxPostureItem::SetBoolValue( sal_Bool bVal
)
614 SetValue( (sal_uInt16
)(bVal
? ITALIC_NORMAL
: ITALIC_NONE
) );
617 // class SvxWeightItem ---------------------------------------------------
619 SvxWeightItem::SvxWeightItem( const FontWeight eWght
, const sal_uInt16 nId
) :
620 SfxEnumItem( nId
, (sal_uInt16
)eWght
)
626 // -----------------------------------------------------------------------
628 int SvxWeightItem::HasBoolValue() const
633 // -----------------------------------------------------------------------
635 sal_Bool
SvxWeightItem::GetBoolValue() const
637 return (FontWeight
)GetValue() >= WEIGHT_BOLD
;
640 // -----------------------------------------------------------------------
642 void SvxWeightItem::SetBoolValue( sal_Bool bVal
)
644 SetValue( (sal_uInt16
)(bVal
? WEIGHT_BOLD
: WEIGHT_NORMAL
) );
647 // -----------------------------------------------------------------------
649 sal_uInt16
SvxWeightItem::GetValueCount() const
651 return WEIGHT_BLACK
; // WEIGHT_DONTKNOW does not belong
654 // -----------------------------------------------------------------------
656 SfxPoolItem
* SvxWeightItem::Clone( SfxItemPool
* ) const
658 return new SvxWeightItem( *this );
661 // -----------------------------------------------------------------------
663 SvStream
& SvxWeightItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
665 rStrm
<< (sal_uInt8
)GetValue();
669 // -----------------------------------------------------------------------
671 SfxPoolItem
* SvxWeightItem::Create(SvStream
& rStrm
, sal_uInt16
) const
675 return new SvxWeightItem( (FontWeight
)nWeight
, Which() );
678 //------------------------------------------------------------------------
680 SfxItemPresentation
SvxWeightItem::GetPresentation
682 SfxItemPresentation ePres
,
683 SfxMapUnit
/*eCoreUnit*/,
684 SfxMapUnit
/*ePresUnit*/,
685 OUString
& rText
, const IntlWrapper
* /*pIntl*/
690 case SFX_ITEM_PRESENTATION_NONE
:
693 case SFX_ITEM_PRESENTATION_NAMELESS
:
694 case SFX_ITEM_PRESENTATION_COMPLETE
:
695 rText
= GetValueTextByPos( GetValue() );
697 default: ;//prevent warning
699 return SFX_ITEM_PRESENTATION_NONE
;
702 // -----------------------------------------------------------------------
704 OUString
SvxWeightItem::GetValueTextByPos( sal_uInt16 nPos
) const
706 DBG_ASSERT( nPos
<= (sal_uInt16
)WEIGHT_BLACK
, "enum overflow!" );
707 return EE_RESSTR(RID_SVXITEMS_WEIGHT_BEGIN
+ nPos
);
710 bool SvxWeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
712 nMemberId
&= ~CONVERT_TWIPS
;
716 rVal
= Bool2Any(GetBoolValue());
720 rVal
<<= (float)( VCLUnoHelper::ConvertFontWeight( (FontWeight
)GetValue() ) );
727 bool SvxWeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
729 nMemberId
&= ~CONVERT_TWIPS
;
733 SetBoolValue(Any2Bool(rVal
));
738 if(!(rVal
>>= fValue
))
740 sal_Int32 nValue
= 0;
741 if(!(rVal
>>= nValue
))
743 fValue
= (float)nValue
;
745 SetValue( (sal_uInt16
)VCLUnoHelper::ConvertFontWeight((float)fValue
) );
752 // class SvxFontHeightItem -----------------------------------------------
754 SvxFontHeightItem::SvxFontHeightItem( const sal_uLong nSz
,
755 const sal_uInt16 nPrp
,
756 const sal_uInt16 nId
) :
759 SetHeight( nSz
,nPrp
); // calculate in percentage
762 // -----------------------------------------------------------------------
764 SfxPoolItem
* SvxFontHeightItem::Clone( SfxItemPool
* ) const
766 return new SvxFontHeightItem( *this );
769 // -----------------------------------------------------------------------
771 SvStream
& SvxFontHeightItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
773 rStrm
<< (sal_uInt16
)GetHeight();
775 if( FONTHEIGHT_UNIT_VERSION
<= nItemVersion
)
776 rStrm
<< GetProp() << (sal_uInt16
)GetPropUnit();
779 // When exporting to the old versions the relative information is lost
780 // when there is no percentage
781 sal_uInt16 _nProp
= GetProp();
782 if( SFX_MAPUNIT_RELATIVE
!= GetPropUnit() )
789 // -----------------------------------------------------------------------
791 SfxPoolItem
* SvxFontHeightItem::Create( SvStream
& rStrm
,
792 sal_uInt16 nVersion
) const
794 sal_uInt16 nsize
, nprop
= 0, nPropUnit
= SFX_MAPUNIT_RELATIVE
;
798 if( FONTHEIGHT_16_VERSION
<= nVersion
)
804 nprop
= (sal_uInt16
)nP
;
807 if( FONTHEIGHT_UNIT_VERSION
<= nVersion
)
810 SvxFontHeightItem
* pItem
= new SvxFontHeightItem( nsize
, 100, Which() );
811 pItem
->SetProp( nprop
, (SfxMapUnit
)nPropUnit
);
815 // -----------------------------------------------------------------------
817 int SvxFontHeightItem::operator==( const SfxPoolItem
& rItem
) const
819 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
820 return GetHeight() == ((SvxFontHeightItem
&)rItem
).GetHeight() &&
821 GetProp() == ((SvxFontHeightItem
&)rItem
).GetProp() &&
822 GetPropUnit() == ((SvxFontHeightItem
&)rItem
).GetPropUnit();
825 bool SvxFontHeightItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
827 // In StarOne is the uno::Any always 1/100mm. Through the MemberId it is
828 // controlled if the value in the Item should be 1/100mm or Twips.
830 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
831 nMemberId
&= ~CONVERT_TWIPS
;
836 ::com::sun::star::frame::status::FontHeight aFontHeight
;
838 // Point (i.e. Twips) is asked for, thus re-calculate if
839 // CONVERT_TWIPS is not set.
842 long nTwips
= bConvert
? nHeight
: MM100_TO_TWIP_UNSIGNED(nHeight
);
843 aFontHeight
.Height
= (float)( nTwips
/ 20.0 );
847 double fPoints
= MM100_TO_TWIP_UNSIGNED(nHeight
) / 20.0;
849 static_cast<float>(::rtl::math::round(fPoints
, 1));
850 aFontHeight
.Height
= fRoundPoints
;
853 aFontHeight
.Prop
= (sal_Int16
)(SFX_MAPUNIT_RELATIVE
== ePropUnit
? nProp
: 100);
855 float fRet
= (float)(short)nProp
;
858 case SFX_MAPUNIT_RELATIVE
:
861 case SFX_MAPUNIT_100TH_MM
:
862 fRet
= MM100_TO_TWIP(fRet
);
865 case SFX_MAPUNIT_POINT
:
868 case SFX_MAPUNIT_TWIP
:
871 default: ;//prevent warning
873 aFontHeight
.Diff
= fRet
;
874 rVal
<<= aFontHeight
;
879 // Point (i.e. Twips) is asked for, thus re-calculate if
880 // CONVERT_TWIPS is not set.
883 long nTwips
= bConvert
? nHeight
: MM100_TO_TWIP_UNSIGNED(nHeight
);
884 rVal
<<= (float)( nTwips
/ 20.0 );
888 double fPoints
= MM100_TO_TWIP_UNSIGNED(nHeight
) / 20.0;
890 static_cast<float>(::rtl::math::round(fPoints
, 1));
891 rVal
<<= fRoundPoints
;
895 case MID_FONTHEIGHT_PROP
:
896 rVal
<<= (sal_Int16
)(SFX_MAPUNIT_RELATIVE
== ePropUnit
? nProp
: 100);
898 case MID_FONTHEIGHT_DIFF
:
900 float fRet
= (float)(short)nProp
;
903 case SFX_MAPUNIT_RELATIVE
:
906 case SFX_MAPUNIT_100TH_MM
:
907 fRet
= MM100_TO_TWIP(fRet
);
910 case SFX_MAPUNIT_POINT
:
913 case SFX_MAPUNIT_TWIP
:
916 default: ;//prevent warning
925 // Calculate the relative deviation from the expected height.
926 static sal_uInt32
lcl_GetRealHeight_Impl(sal_uInt32 nHeight
, sal_uInt16 nProp
, SfxMapUnit eProp
, sal_Bool bCoreInTwip
)
928 sal_uInt32 nRet
= nHeight
;
932 case SFX_MAPUNIT_RELATIVE
:
936 case SFX_MAPUNIT_POINT
:
938 short nTemp
= (short)nProp
;
941 nDiff
= (short)TWIP_TO_MM100((long)(nDiff
));
944 case SFX_MAPUNIT_100TH_MM
:
945 //then the core is surely also in 1/100 mm
946 nDiff
= (short)nProp
;
948 case SFX_MAPUNIT_TWIP
:
950 nDiff
= ((short)nProp
);
952 default: ;//prevent warning
959 bool SvxFontHeightItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
961 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
962 nMemberId
&= ~CONVERT_TWIPS
;
967 ::com::sun::star::frame::status::FontHeight aFontHeight
;
968 if ( rVal
>>= aFontHeight
)
971 ePropUnit
= SFX_MAPUNIT_RELATIVE
;
973 double fPoint
= aFontHeight
.Height
;
974 if( fPoint
< 0. || fPoint
> 10000. )
977 nHeight
= (long)( fPoint
* 20.0 + 0.5 ); // Twips
979 nHeight
= TWIP_TO_MM100_UNSIGNED(nHeight
); // Convert, if the item contains 1/100mm
981 nProp
= aFontHeight
.Prop
;
989 ePropUnit
= SFX_MAPUNIT_RELATIVE
;
992 if(!(rVal
>>= fPoint
))
994 sal_Int32 nValue
= 0;
995 if(!(rVal
>>= nValue
))
997 fPoint
= (float)nValue
;
999 if(fPoint
< 0. || fPoint
> 10000.)
1002 nHeight
= (long)( fPoint
* 20.0 + 0.5 ); // Twips
1004 nHeight
= TWIP_TO_MM100_UNSIGNED(nHeight
); // Convert, if the item contains 1/100mm
1007 case MID_FONTHEIGHT_PROP
:
1009 sal_Int16 nNew
= sal_Int16();
1010 if(!(rVal
>>= nNew
))
1013 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
1018 ePropUnit
= SFX_MAPUNIT_RELATIVE
;
1021 case MID_FONTHEIGHT_DIFF
:
1023 nHeight
= lcl_GetRealHeight_Impl(nHeight
, nProp
, ePropUnit
, bConvert
);
1025 if(!(rVal
>>= fValue
))
1027 sal_Int32 nValue
= 0;
1028 if(!(rVal
>>= nValue
))
1030 fValue
= (float)nValue
;
1032 sal_Int16 nCoreDiffValue
= (sal_Int16
)(fValue
* 20.);
1033 nHeight
+= bConvert
? nCoreDiffValue
: TWIP_TO_MM100(nCoreDiffValue
);
1034 nProp
= (sal_uInt16
)((sal_Int16
)fValue
);
1035 ePropUnit
= SFX_MAPUNIT_POINT
;
1042 //------------------------------------------------------------------------
1044 SfxItemPresentation
SvxFontHeightItem::GetPresentation
1046 SfxItemPresentation ePres
,
1047 SfxMapUnit eCoreUnit
,
1048 SfxMapUnit
/*ePresUnit*/,
1049 OUString
& rText
, const IntlWrapper
*pIntl
1054 case SFX_ITEM_PRESENTATION_NONE
:
1057 case SFX_ITEM_PRESENTATION_NAMELESS
:
1058 case SFX_ITEM_PRESENTATION_COMPLETE
:
1060 if( SFX_MAPUNIT_RELATIVE
!= ePropUnit
)
1062 rText
= OUString::number( (short)nProp
) +
1063 EE_RESSTR( GetMetricId( ePropUnit
) );
1064 if( 0 <= (short)nProp
)
1065 rText
= "+" + rText
;
1067 else if( 100 == nProp
)
1069 rText
= GetMetricText( (long)nHeight
,
1070 eCoreUnit
, SFX_MAPUNIT_POINT
, pIntl
) +
1071 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT
));
1074 rText
= OUString::number( nProp
) + "%";
1077 default: ; //prevent warning
1079 return SFX_ITEM_PRESENTATION_NONE
;
1082 // -----------------------------------------------------------------------
1084 sal_uInt16
SvxFontHeightItem::GetVersion(sal_uInt16 nFileVersion
) const
1086 return (nFileVersion
<= SOFFICE_FILEFORMAT_40
)
1087 ? FONTHEIGHT_16_VERSION
1088 : FONTHEIGHT_UNIT_VERSION
;
1091 // -----------------------------------------------------------------------
1093 bool SvxFontHeightItem::ScaleMetrics( long nMult
, long nDiv
)
1095 nHeight
= (sal_uInt32
)Scale( nHeight
, nMult
, nDiv
);
1099 // -----------------------------------------------------------------------
1101 bool SvxFontHeightItem::HasMetrics() const
1106 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, const sal_uInt16 nNewProp
,
1109 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
1111 if( SFX_MAPUNIT_RELATIVE
!= eUnit
)
1112 nHeight
= nNewHeight
+ ::ItemToControl( (short)nNewProp
, eUnit
,
1114 else if( 100 != nNewProp
)
1115 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
1117 nHeight
= nNewHeight
;
1123 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight
, sal_uInt16 nNewProp
,
1124 SfxMapUnit eMetric
, SfxMapUnit eCoreMetric
)
1126 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
1128 if( SFX_MAPUNIT_RELATIVE
!= eMetric
)
1129 nHeight
= nNewHeight
+
1130 ::ControlToItem( ::ItemToControl((short)nNewProp
, eMetric
,
1131 SFX_FUNIT_TWIP
), SFX_FUNIT_TWIP
,
1133 else if( 100 != nNewProp
)
1134 nHeight
= sal_uInt32(( nNewHeight
* nNewProp
) / 100 );
1136 nHeight
= nNewHeight
;
1139 ePropUnit
= eMetric
;
1142 // class SvxFontWidthItem -----------------------------------------------
1144 SvxFontWidthItem::SvxFontWidthItem( const sal_uInt16 nSz
, const sal_uInt16 nPrp
, const sal_uInt16 nId
) :
1151 // -----------------------------------------------------------------------
1153 SfxPoolItem
* SvxFontWidthItem::Clone( SfxItemPool
* ) const
1155 return new SvxFontWidthItem( *this );
1158 // -----------------------------------------------------------------------
1160 SvStream
& SvxFontWidthItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1162 rStrm
<< GetWidth() << GetProp();
1166 // -----------------------------------------------------------------------
1168 bool SvxFontWidthItem::ScaleMetrics( long nMult
, long nDiv
)
1170 nWidth
= (sal_uInt16
)Scale( nWidth
, nMult
, nDiv
);
1174 // -----------------------------------------------------------------------
1176 bool SvxFontWidthItem::HasMetrics() const
1181 // -----------------------------------------------------------------------
1183 SfxPoolItem
* SvxFontWidthItem::Create( SvStream
& rStrm
,
1184 sal_uInt16
/*nVersion*/ ) const
1191 SvxFontWidthItem
* pItem
= new SvxFontWidthItem( 0, nP
, Which() );
1192 pItem
->SetWidthValue( nS
);
1196 // -----------------------------------------------------------------------
1198 int SvxFontWidthItem::operator==( const SfxPoolItem
& rItem
) const
1200 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
1201 return GetWidth() == ((SvxFontWidthItem
&)rItem
).GetWidth() &&
1202 GetProp() == ((SvxFontWidthItem
&)rItem
).GetProp();
1205 bool SvxFontWidthItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1207 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1208 nMemberId
&= ~CONVERT_TWIPS
;
1212 rVal
<<= (sal_Int16
)(nWidth
);
1214 case MID_FONTWIDTH_PROP
:
1215 rVal
<<= (sal_Int16
)(nProp
);
1221 bool SvxFontWidthItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1223 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1224 nMemberId
&= ~CONVERT_TWIPS
;
1225 sal_Int16 nVal
= sal_Int16();
1226 if(!(rVal
>>= nVal
))
1234 case MID_FONTWIDTH_PROP
:
1241 //------------------------------------------------------------------------
1243 SfxItemPresentation
SvxFontWidthItem::GetPresentation
1245 SfxItemPresentation ePres
,
1246 SfxMapUnit eCoreUnit
,
1247 SfxMapUnit
/*ePresUnit*/,
1248 OUString
& rText
, const IntlWrapper
*pIntl
1253 case SFX_ITEM_PRESENTATION_NONE
:
1256 case SFX_ITEM_PRESENTATION_NAMELESS
:
1257 case SFX_ITEM_PRESENTATION_COMPLETE
:
1261 rText
= GetMetricText( (long)nWidth
,
1262 eCoreUnit
, SFX_MAPUNIT_POINT
, pIntl
) +
1263 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT
));
1266 rText
= OUString::number( nProp
) + "%";
1269 default: ; //prevent warning
1271 return SFX_ITEM_PRESENTATION_NONE
;
1274 // class SvxTextLineItem ------------------------------------------------
1276 SvxTextLineItem::SvxTextLineItem( const FontUnderline eSt
, const sal_uInt16 nId
)
1277 : SfxEnumItem( nId
, (sal_uInt16
)eSt
), mColor( COL_TRANSPARENT
)
1281 // -----------------------------------------------------------------------
1283 int SvxTextLineItem::HasBoolValue() const
1288 // -----------------------------------------------------------------------
1290 sal_Bool
SvxTextLineItem::GetBoolValue() const
1292 return (FontUnderline
)GetValue() != UNDERLINE_NONE
;
1295 // -----------------------------------------------------------------------
1297 void SvxTextLineItem::SetBoolValue( sal_Bool bVal
)
1299 SetValue( (sal_uInt16
)(bVal
? UNDERLINE_SINGLE
: UNDERLINE_NONE
) );
1302 // -----------------------------------------------------------------------
1304 SfxPoolItem
* SvxTextLineItem::Clone( SfxItemPool
* ) const
1306 SvxTextLineItem
* pNew
= new SvxTextLineItem( *this );
1307 pNew
->SetColor( GetColor() );
1311 // -----------------------------------------------------------------------
1313 sal_uInt16
SvxTextLineItem::GetValueCount() const
1315 return UNDERLINE_DOTTED
+ 1; // UNDERLINE_NONE also belongs here
1318 // -----------------------------------------------------------------------
1320 SvStream
& SvxTextLineItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1322 rStrm
<< (sal_uInt8
)GetValue();
1326 // -----------------------------------------------------------------------
1328 SfxPoolItem
* SvxTextLineItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1332 return new SvxTextLineItem( (FontUnderline
)nState
, Which() );
1335 //------------------------------------------------------------------------
1337 SfxItemPresentation
SvxTextLineItem::GetPresentation
1339 SfxItemPresentation ePres
,
1340 SfxMapUnit
/*eCoreUnit*/,
1341 SfxMapUnit
/*ePresUnit*/,
1342 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1347 case SFX_ITEM_PRESENTATION_NONE
:
1350 case SFX_ITEM_PRESENTATION_NAMELESS
:
1351 case SFX_ITEM_PRESENTATION_COMPLETE
:
1352 rText
= GetValueTextByPos( GetValue() );
1353 if( !mColor
.GetTransparency() )
1354 rText
= rText
+ OUString(cpDelim
) + ::GetColorString( mColor
);
1356 default: ; //prevent warning
1358 return SFX_ITEM_PRESENTATION_NONE
;
1361 // -----------------------------------------------------------------------
1363 OUString
SvxTextLineItem::GetValueTextByPos( sal_uInt16
/*nPos*/ ) const
1365 OSL_FAIL("SvxTextLineItem::GetValueTextByPos: Pure virtual method");
1369 bool SvxTextLineItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1371 nMemberId
&= ~CONVERT_TWIPS
;
1375 rVal
= Bool2Any(GetBoolValue());
1378 rVal
<<= (sal_Int16
)(GetValue());
1381 rVal
<<= (sal_Int32
)( mColor
.GetColor() );
1383 case MID_TL_HASCOLOR
:
1384 rVal
= Bool2Any( !mColor
.GetTransparency() );
1391 bool SvxTextLineItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1393 nMemberId
&= ~CONVERT_TWIPS
;
1394 sal_Bool bRet
= sal_True
;
1398 SetBoolValue(Any2Bool(rVal
));
1402 sal_Int32 nValue
= 0;
1403 if(!(rVal
>>= nValue
))
1406 SetValue((sal_Int16
)nValue
);
1412 if( !( rVal
>>= nCol
) )
1416 // Keep transparence, because it contains the information
1417 // whether the font color or the stored color should be used
1418 sal_uInt8 nTrans
= mColor
.GetTransparency();
1419 mColor
= Color( nCol
);
1420 mColor
.SetTransparency( nTrans
);
1424 case MID_TL_HASCOLOR
:
1425 mColor
.SetTransparency( Any2Bool( rVal
) ? 0 : 0xff );
1431 int SvxTextLineItem::operator==( const SfxPoolItem
& rItem
) const
1433 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
1434 return SfxEnumItem::operator==( rItem
) &&
1435 GetColor() == ((SvxTextLineItem
&)rItem
).GetColor();
1438 // class SvxUnderlineItem ------------------------------------------------
1440 SvxUnderlineItem::SvxUnderlineItem( const FontUnderline eSt
, const sal_uInt16 nId
)
1441 : SvxTextLineItem( eSt
, nId
)
1445 //------------------------------------------------------------------------
1447 SfxPoolItem
* SvxUnderlineItem::Clone( SfxItemPool
* ) const
1449 SvxUnderlineItem
* pNew
= new SvxUnderlineItem( *this );
1450 pNew
->SetColor( GetColor() );
1454 // -----------------------------------------------------------------------
1456 SfxPoolItem
* SvxUnderlineItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1460 return new SvxUnderlineItem( (FontUnderline
)nState
, Which() );
1463 // -----------------------------------------------------------------------
1465 OUString
SvxUnderlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1467 DBG_ASSERT( nPos
<= (sal_uInt16
)UNDERLINE_BOLDWAVE
, "enum overflow!" );
1468 return EE_RESSTR(RID_SVXITEMS_UL_BEGIN
+ nPos
);
1471 // class SvxOverlineItem ------------------------------------------------
1473 SvxOverlineItem::SvxOverlineItem( const FontUnderline eSt
, const sal_uInt16 nId
)
1474 : SvxTextLineItem( eSt
, nId
)
1478 //------------------------------------------------------------------------
1480 SfxPoolItem
* SvxOverlineItem::Clone( SfxItemPool
* ) const
1482 SvxOverlineItem
* pNew
= new SvxOverlineItem( *this );
1483 pNew
->SetColor( GetColor() );
1487 // -----------------------------------------------------------------------
1489 SfxPoolItem
* SvxOverlineItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1493 return new SvxOverlineItem( (FontUnderline
)nState
, Which() );
1496 // -----------------------------------------------------------------------
1498 OUString
SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos
) const
1500 DBG_ASSERT( nPos
<= (sal_uInt16
)UNDERLINE_BOLDWAVE
, "enum overflow!" );
1501 return EE_RESSTR(RID_SVXITEMS_OL_BEGIN
+ nPos
);
1504 // class SvxCrossedOutItem -----------------------------------------------
1506 SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt
, const sal_uInt16 nId
)
1507 : SfxEnumItem( nId
, (sal_uInt16
)eSt
)
1511 // -----------------------------------------------------------------------
1513 int SvxCrossedOutItem::HasBoolValue() const
1518 // -----------------------------------------------------------------------
1520 sal_Bool
SvxCrossedOutItem::GetBoolValue() const
1522 return (FontStrikeout
)GetValue() != STRIKEOUT_NONE
;
1525 // -----------------------------------------------------------------------
1527 void SvxCrossedOutItem::SetBoolValue( sal_Bool bVal
)
1529 SetValue( (sal_uInt16
)(bVal
? STRIKEOUT_SINGLE
: STRIKEOUT_NONE
) );
1532 // -----------------------------------------------------------------------
1534 sal_uInt16
SvxCrossedOutItem::GetValueCount() const
1536 return STRIKEOUT_DOUBLE
+ 1; // STRIKEOUT_NONE belongs also here
1539 // -----------------------------------------------------------------------
1541 SfxPoolItem
* SvxCrossedOutItem::Clone( SfxItemPool
* ) const
1543 return new SvxCrossedOutItem( *this );
1546 // -----------------------------------------------------------------------
1548 SvStream
& SvxCrossedOutItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1550 rStrm
<< (sal_uInt8
)GetValue();
1554 // -----------------------------------------------------------------------
1556 SfxPoolItem
* SvxCrossedOutItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1560 return new SvxCrossedOutItem( (FontStrikeout
)eCross
, Which() );
1563 //------------------------------------------------------------------------
1565 SfxItemPresentation
SvxCrossedOutItem::GetPresentation
1567 SfxItemPresentation ePres
,
1568 SfxMapUnit
/*eCoreUnit*/,
1569 SfxMapUnit
/*ePresUnit*/,
1570 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1575 case SFX_ITEM_PRESENTATION_NONE
:
1578 case SFX_ITEM_PRESENTATION_NAMELESS
:
1579 case SFX_ITEM_PRESENTATION_COMPLETE
:
1580 rText
= GetValueTextByPos( GetValue() );
1582 default: ;//prevent warning
1584 return SFX_ITEM_PRESENTATION_NONE
;
1587 // -----------------------------------------------------------------------
1589 OUString
SvxCrossedOutItem::GetValueTextByPos( sal_uInt16 nPos
) const
1591 DBG_ASSERT( nPos
<= (sal_uInt16
)STRIKEOUT_X
, "enum overflow!" );
1592 return EE_RESSTR(RID_SVXITEMS_STRIKEOUT_BEGIN
+ nPos
);
1595 bool SvxCrossedOutItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1597 nMemberId
&= ~CONVERT_TWIPS
;
1600 case MID_CROSSED_OUT
:
1601 rVal
= Bool2Any(GetBoolValue());
1604 rVal
<<= (sal_Int16
)(GetValue());
1610 bool SvxCrossedOutItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1612 nMemberId
&= ~CONVERT_TWIPS
;
1615 case MID_CROSSED_OUT
:
1616 SetBoolValue(Any2Bool(rVal
));
1620 sal_Int32 nValue
= 0;
1621 if(!(rVal
>>= nValue
))
1623 SetValue((sal_Int16
)nValue
);
1629 // class SvxShadowedItem -------------------------------------------------
1631 SvxShadowedItem::SvxShadowedItem( const sal_Bool bShadowed
, const sal_uInt16 nId
) :
1632 SfxBoolItem( nId
, bShadowed
)
1636 // -----------------------------------------------------------------------
1638 SfxPoolItem
* SvxShadowedItem::Clone( SfxItemPool
* ) const
1640 return new SvxShadowedItem( *this );
1643 // -----------------------------------------------------------------------
1645 SvStream
& SvxShadowedItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1647 rStrm
<< (sal_uInt8
) GetValue();
1651 // -----------------------------------------------------------------------
1653 SfxPoolItem
* SvxShadowedItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1657 return new SvxShadowedItem( nState
, Which() );
1660 //------------------------------------------------------------------------
1662 SfxItemPresentation
SvxShadowedItem::GetPresentation
1664 SfxItemPresentation ePres
,
1665 SfxMapUnit
/*eCoreUnit*/,
1666 SfxMapUnit
/*ePresUnit*/,
1667 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1672 case SFX_ITEM_PRESENTATION_NONE
:
1675 case SFX_ITEM_PRESENTATION_NAMELESS
:
1676 case SFX_ITEM_PRESENTATION_COMPLETE
:
1678 sal_uInt16 nId
= RID_SVXITEMS_SHADOWED_FALSE
;
1681 nId
= RID_SVXITEMS_SHADOWED_TRUE
;
1682 rText
= EE_RESSTR(nId
);
1685 default: ; //prevent warning
1687 return SFX_ITEM_PRESENTATION_NONE
;
1690 // class SvxAutoKernItem -------------------------------------------------
1692 SvxAutoKernItem::SvxAutoKernItem( const sal_Bool bAutoKern
, const sal_uInt16 nId
) :
1693 SfxBoolItem( nId
, bAutoKern
)
1697 // -----------------------------------------------------------------------
1699 SfxPoolItem
* SvxAutoKernItem::Clone( SfxItemPool
* ) const
1701 return new SvxAutoKernItem( *this );
1704 // -----------------------------------------------------------------------
1706 SvStream
& SvxAutoKernItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1708 rStrm
<< (sal_uInt8
) GetValue();
1712 // -----------------------------------------------------------------------
1714 SfxPoolItem
* SvxAutoKernItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1718 return new SvxAutoKernItem( nState
, Which() );
1721 //------------------------------------------------------------------------
1723 SfxItemPresentation
SvxAutoKernItem::GetPresentation
1725 SfxItemPresentation ePres
,
1726 SfxMapUnit
/*eCoreUnit*/,
1727 SfxMapUnit
/*ePresUnit*/,
1728 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1733 case SFX_ITEM_PRESENTATION_NONE
:
1736 case SFX_ITEM_PRESENTATION_NAMELESS
:
1737 case SFX_ITEM_PRESENTATION_COMPLETE
:
1739 sal_uInt16 nId
= RID_SVXITEMS_AUTOKERN_FALSE
;
1742 nId
= RID_SVXITEMS_AUTOKERN_TRUE
;
1743 rText
= EE_RESSTR(nId
);
1746 default: ; //prevent warning
1748 return SFX_ITEM_PRESENTATION_NONE
;
1751 // class SvxWordLineModeItem ---------------------------------------------
1753 SvxWordLineModeItem::SvxWordLineModeItem( const sal_Bool bWordLineMode
,
1754 const sal_uInt16 nId
) :
1755 SfxBoolItem( nId
, bWordLineMode
)
1759 // -----------------------------------------------------------------------
1761 SfxPoolItem
* SvxWordLineModeItem::Clone( SfxItemPool
* ) const
1763 return new SvxWordLineModeItem( *this );
1766 // -----------------------------------------------------------------------
1768 SvStream
& SvxWordLineModeItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1770 rStrm
<< (sal_Bool
) GetValue();
1774 // -----------------------------------------------------------------------
1776 SfxPoolItem
* SvxWordLineModeItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1780 return new SvxWordLineModeItem( bValue
, Which() );
1783 //------------------------------------------------------------------------
1785 SfxItemPresentation
SvxWordLineModeItem::GetPresentation
1787 SfxItemPresentation ePres
,
1788 SfxMapUnit
/*eCoreUnit*/,
1789 SfxMapUnit
/*ePresUnit*/,
1790 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1795 case SFX_ITEM_PRESENTATION_NONE
:
1798 case SFX_ITEM_PRESENTATION_NAMELESS
:
1799 case SFX_ITEM_PRESENTATION_COMPLETE
:
1801 sal_uInt16 nId
= RID_SVXITEMS_WORDLINE_FALSE
;
1804 nId
= RID_SVXITEMS_WORDLINE_TRUE
;
1805 rText
= EE_RESSTR(nId
);
1808 default: ; //prevent warning
1810 return SFX_ITEM_PRESENTATION_NONE
;
1813 // class SvxContourItem --------------------------------------------------
1815 SvxContourItem::SvxContourItem( const sal_Bool bContoured
, const sal_uInt16 nId
) :
1816 SfxBoolItem( nId
, bContoured
)
1820 // -----------------------------------------------------------------------
1822 SfxPoolItem
* SvxContourItem::Clone( SfxItemPool
* ) const
1824 return new SvxContourItem( *this );
1827 // -----------------------------------------------------------------------
1829 SvStream
& SvxContourItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1831 rStrm
<< (sal_Bool
) GetValue();
1835 // -----------------------------------------------------------------------
1837 SfxPoolItem
* SvxContourItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1841 return new SvxContourItem( bValue
, Which() );
1844 //------------------------------------------------------------------------
1846 SfxItemPresentation
SvxContourItem::GetPresentation
1848 SfxItemPresentation ePres
,
1849 SfxMapUnit
/*eCoreUnit*/,
1850 SfxMapUnit
/*ePresUnit*/,
1851 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1856 case SFX_ITEM_PRESENTATION_NONE
:
1859 case SFX_ITEM_PRESENTATION_NAMELESS
:
1860 case SFX_ITEM_PRESENTATION_COMPLETE
:
1862 sal_uInt16 nId
= RID_SVXITEMS_CONTOUR_FALSE
;
1865 nId
= RID_SVXITEMS_CONTOUR_TRUE
;
1866 rText
= EE_RESSTR(nId
);
1869 default: ; //prevent warning
1871 return SFX_ITEM_PRESENTATION_NONE
;
1874 // class SvxPropSizeItem -------------------------------------------------
1876 SvxPropSizeItem::SvxPropSizeItem( const sal_uInt16 nPercent
, const sal_uInt16 nId
) :
1877 SfxUInt16Item( nId
, nPercent
)
1881 // -----------------------------------------------------------------------
1883 SfxPoolItem
* SvxPropSizeItem::Clone( SfxItemPool
* ) const
1885 return new SvxPropSizeItem( *this );
1888 // -----------------------------------------------------------------------
1890 SvStream
& SvxPropSizeItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1892 rStrm
<< (sal_uInt16
) GetValue();
1896 // -----------------------------------------------------------------------
1898 SfxPoolItem
* SvxPropSizeItem::Create(SvStream
& rStrm
, sal_uInt16
) const
1902 return new SvxPropSizeItem( nSize
, Which() );
1905 //------------------------------------------------------------------------
1907 SfxItemPresentation
SvxPropSizeItem::GetPresentation
1909 SfxItemPresentation
/*ePres*/,
1910 SfxMapUnit
/*eCoreUnit*/,
1911 SfxMapUnit
/*ePresUnit*/,
1912 OUString
& rText
, const IntlWrapper
* /*pIntl*/
1916 return SFX_ITEM_PRESENTATION_NONE
;
1919 // class SvxColorItem ----------------------------------------------------
1921 SvxColorItem::SvxColorItem( const sal_uInt16 nId
) :
1927 // -----------------------------------------------------------------------
1929 SvxColorItem::SvxColorItem( const Color
& rCol
, const sal_uInt16 nId
) :
1935 // -----------------------------------------------------------------------
1937 SvxColorItem::SvxColorItem( SvStream
&rStrm
, const sal_uInt16 nId
) :
1945 // -----------------------------------------------------------------------
1947 SvxColorItem::SvxColorItem( const SvxColorItem
&rCopy
) :
1948 SfxPoolItem( rCopy
),
1949 mColor( rCopy
.mColor
)
1953 // -----------------------------------------------------------------------
1955 SvxColorItem::~SvxColorItem()
1959 // -----------------------------------------------------------------------
1960 sal_uInt16
SvxColorItem::GetVersion( sal_uInt16 nFFVer
) const
1962 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
1963 SOFFICE_FILEFORMAT_40
==nFFVer
||
1964 SOFFICE_FILEFORMAT_50
==nFFVer
,
1965 "SvxColorItem: Is there a new file format? ");
1966 return SOFFICE_FILEFORMAT_50
>= nFFVer
? VERSION_USEAUTOCOLOR
: 0;
1969 // -----------------------------------------------------------------------
1971 int SvxColorItem::operator==( const SfxPoolItem
& rAttr
) const
1973 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1975 return mColor
== ( (const SvxColorItem
&)rAttr
).mColor
;
1978 // -----------------------------------------------------------------------
1980 bool SvxColorItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
1982 rVal
<<= (sal_Int32
)(mColor
.GetColor());
1986 // -----------------------------------------------------------------------
1988 bool SvxColorItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
1990 sal_Int32 nColor
= 0;
1991 if(!(rVal
>>= nColor
))
1994 mColor
.SetColor( nColor
);
1998 // -----------------------------------------------------------------------
2000 SfxPoolItem
* SvxColorItem::Clone( SfxItemPool
* ) const
2002 return new SvxColorItem( *this );
2005 // -----------------------------------------------------------------------
2007 SvStream
& SvxColorItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
2009 if( VERSION_USEAUTOCOLOR
== nItemVersion
&&
2010 COL_AUTO
== mColor
.GetColor() )
2011 rStrm
<< Color( COL_BLACK
);
2017 // -----------------------------------------------------------------------
2019 SfxPoolItem
* SvxColorItem::Create(SvStream
& rStrm
, sal_uInt16
/*nVer*/ ) const
2021 return new SvxColorItem( rStrm
, Which() );
2024 //------------------------------------------------------------------------
2026 SfxItemPresentation
SvxColorItem::GetPresentation
2028 SfxItemPresentation ePres
,
2029 SfxMapUnit
/*eCoreUnit*/,
2030 SfxMapUnit
/*ePresUnit*/,
2031 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2036 case SFX_ITEM_PRESENTATION_NONE
:
2039 case SFX_ITEM_PRESENTATION_NAMELESS
:
2040 case SFX_ITEM_PRESENTATION_COMPLETE
:
2041 rText
= ::GetColorString( mColor
);
2043 default: ; //prevent warning
2045 return SFX_ITEM_PRESENTATION_NONE
;
2048 // -----------------------------------------------------------------------
2050 void SvxColorItem::SetValue( const Color
& rNewCol
)
2055 // class SvxCharSetColorItem ---------------------------------------------
2057 SvxCharSetColorItem::SvxCharSetColorItem( const sal_uInt16 nId
) :
2058 SvxColorItem( nId
),
2060 eFrom( RTL_TEXTENCODING_DONTKNOW
)
2064 // -----------------------------------------------------------------------
2066 SvxCharSetColorItem::SvxCharSetColorItem( const Color
& rCol
,
2067 const rtl_TextEncoding _eFrom
,
2068 const sal_uInt16 nId
) :
2069 SvxColorItem( rCol
, nId
),
2076 // -----------------------------------------------------------------------
2078 SfxPoolItem
* SvxCharSetColorItem::Clone( SfxItemPool
* ) const
2080 return new SvxCharSetColorItem( *this );
2083 // -----------------------------------------------------------------------
2085 SvStream
& SvxCharSetColorItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2087 rStrm
<< (sal_uInt8
)GetSOStoreTextEncoding(GetCharSet()) << GetValue();
2091 // -----------------------------------------------------------------------
2093 SfxPoolItem
* SvxCharSetColorItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2097 rStrm
>> cSet
>> aColor
;
2098 return new SvxCharSetColorItem( aColor
, (rtl_TextEncoding
)cSet
, Which() );
2101 //------------------------------------------------------------------------
2103 SfxItemPresentation
SvxCharSetColorItem::GetPresentation
2105 SfxItemPresentation
/*ePres*/,
2106 SfxMapUnit
/*eCoreUnit*/,
2107 SfxMapUnit
/*ePresUnit*/,
2108 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2112 return SFX_ITEM_PRESENTATION_NONE
;
2115 // class SvxKerningItem --------------------------------------------------
2117 SvxKerningItem::SvxKerningItem( const short nKern
, const sal_uInt16 nId
) :
2118 SfxInt16Item( nId
, nKern
)
2122 // -----------------------------------------------------------------------
2124 SfxPoolItem
* SvxKerningItem::Clone( SfxItemPool
* ) const
2126 return new SvxKerningItem( *this );
2129 // -----------------------------------------------------------------------
2131 SvStream
& SvxKerningItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2133 rStrm
<< (short) GetValue();
2137 // -----------------------------------------------------------------------
2139 bool SvxKerningItem::ScaleMetrics( long nMult
, long nDiv
)
2141 SetValue( (sal_Int16
)Scale( GetValue(), nMult
, nDiv
) );
2145 // -----------------------------------------------------------------------
2147 bool SvxKerningItem::HasMetrics() const
2152 // -----------------------------------------------------------------------
2154 SfxPoolItem
* SvxKerningItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2158 return new SvxKerningItem( nValue
, Which() );
2161 //------------------------------------------------------------------------
2163 SfxItemPresentation
SvxKerningItem::GetPresentation
2165 SfxItemPresentation ePres
,
2166 SfxMapUnit eCoreUnit
,
2167 SfxMapUnit
/*ePresUnit*/,
2168 OUString
& rText
, const IntlWrapper
*pIntl
2173 case SFX_ITEM_PRESENTATION_NONE
:
2176 case SFX_ITEM_PRESENTATION_NAMELESS
:
2177 rText
= GetMetricText( (long)GetValue(), eCoreUnit
, SFX_MAPUNIT_POINT
, pIntl
) +
2178 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT
));
2180 case SFX_ITEM_PRESENTATION_COMPLETE
:
2182 rText
= EE_RESSTR(RID_SVXITEMS_KERNING_COMPLETE
);
2185 if ( GetValue() > 0 )
2186 nId
= RID_SVXITEMS_KERNING_EXPANDED
;
2187 else if ( GetValue() < 0 )
2188 nId
= RID_SVXITEMS_KERNING_CONDENSED
;
2191 rText
+= EE_RESSTR(nId
);
2193 GetMetricText( (long)GetValue(), eCoreUnit
, SFX_MAPUNIT_POINT
, pIntl
) +
2194 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT
));
2197 default: ; //prevent warning
2199 return SFX_ITEM_PRESENTATION_NONE
;
2202 bool SvxKerningItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2204 sal_Int16 nVal
= GetValue();
2205 if(nMemberId
& CONVERT_TWIPS
)
2206 nVal
= (sal_Int16
)TWIP_TO_MM100(nVal
);
2210 // -----------------------------------------------------------------------
2211 bool SvxKerningItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2213 sal_Int16 nVal
= sal_Int16();
2214 if(!(rVal
>>= nVal
))
2216 if(nMemberId
& CONVERT_TWIPS
)
2217 nVal
= (sal_Int16
)MM100_TO_TWIP(nVal
);
2222 // class SvxCaseMapItem --------------------------------------------------
2224 SvxCaseMapItem::SvxCaseMapItem( const SvxCaseMap eMap
, const sal_uInt16 nId
) :
2225 SfxEnumItem( nId
, (sal_uInt16
)eMap
)
2229 // -----------------------------------------------------------------------
2231 sal_uInt16
SvxCaseMapItem::GetValueCount() const
2233 return SVX_CASEMAP_END
; // SVX_CASEMAP_KAPITAELCHEN + 1
2236 // -----------------------------------------------------------------------
2238 SfxPoolItem
* SvxCaseMapItem::Clone( SfxItemPool
* ) const
2240 return new SvxCaseMapItem( *this );
2243 // -----------------------------------------------------------------------
2245 SvStream
& SvxCaseMapItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2247 rStrm
<< (sal_uInt8
) GetValue();
2251 // -----------------------------------------------------------------------
2253 SfxPoolItem
* SvxCaseMapItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2257 return new SvxCaseMapItem( (const SvxCaseMap
)cMap
, Which() );
2260 //------------------------------------------------------------------------
2262 SfxItemPresentation
SvxCaseMapItem::GetPresentation
2264 SfxItemPresentation ePres
,
2265 SfxMapUnit
/*eCoreUnit*/,
2266 SfxMapUnit
/*ePresUnit*/,
2267 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2272 case SFX_ITEM_PRESENTATION_NONE
:
2275 case SFX_ITEM_PRESENTATION_NAMELESS
:
2276 case SFX_ITEM_PRESENTATION_COMPLETE
:
2277 rText
= GetValueTextByPos( GetValue() );
2279 default: ; //prevent warning
2281 return SFX_ITEM_PRESENTATION_NONE
;
2284 // -----------------------------------------------------------------------
2286 OUString
SvxCaseMapItem::GetValueTextByPos( sal_uInt16 nPos
) const
2288 DBG_ASSERT( nPos
< (sal_uInt16
)SVX_CASEMAP_END
, "enum overflow!" );
2289 return EE_RESSTR(RID_SVXITEMS_CASEMAP_BEGIN
+ nPos
);
2292 bool SvxCaseMapItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
2294 sal_Int16 nRet
= style::CaseMap::NONE
;
2295 switch( GetValue() )
2297 case SVX_CASEMAP_VERSALIEN
: nRet
= style::CaseMap::UPPERCASE
; break;
2298 case SVX_CASEMAP_GEMEINE
: nRet
= style::CaseMap::LOWERCASE
; break;
2299 case SVX_CASEMAP_TITEL
: nRet
= style::CaseMap::TITLE
; break;
2300 case SVX_CASEMAP_KAPITAELCHEN
: nRet
= style::CaseMap::SMALLCAPS
; break;
2302 rVal
<<= (sal_Int16
)(nRet
);
2306 bool SvxCaseMapItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
2308 sal_uInt16 nVal
= sal_uInt16();
2309 if(!(rVal
>>= nVal
))
2314 case style::CaseMap::NONE
: nVal
= SVX_CASEMAP_NOT_MAPPED
; break;
2315 case style::CaseMap::UPPERCASE
: nVal
= SVX_CASEMAP_VERSALIEN
; break;
2316 case style::CaseMap::LOWERCASE
: nVal
= SVX_CASEMAP_GEMEINE
; break;
2317 case style::CaseMap::TITLE
: nVal
= SVX_CASEMAP_TITEL
; break;
2318 case style::CaseMap::SMALLCAPS
: nVal
= SVX_CASEMAP_KAPITAELCHEN
; break;
2324 // class SvxEscapementItem -----------------------------------------------
2326 SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId
) :
2327 SfxEnumItemInterface( nId
),
2334 // -----------------------------------------------------------------------
2336 SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape
,
2337 const sal_uInt16 nId
) :
2338 SfxEnumItemInterface( nId
),
2341 SetEscapement( eEscape
);
2346 // -----------------------------------------------------------------------
2348 SvxEscapementItem::SvxEscapementItem( const short _nEsc
,
2349 const sal_uInt8 _nProp
,
2350 const sal_uInt16 nId
) :
2351 SfxEnumItemInterface( nId
),
2357 // -----------------------------------------------------------------------
2359 int SvxEscapementItem::operator==( const SfxPoolItem
& rAttr
) const
2361 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
2363 return( nEsc
== ((SvxEscapementItem
&)rAttr
).nEsc
&&
2364 nProp
== ((SvxEscapementItem
&)rAttr
).nProp
);
2367 // -----------------------------------------------------------------------
2369 SfxPoolItem
* SvxEscapementItem::Clone( SfxItemPool
* ) const
2371 return new SvxEscapementItem( *this );
2374 // -----------------------------------------------------------------------
2376 SvStream
& SvxEscapementItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2378 short _nEsc
= GetEsc();
2379 if( SOFFICE_FILEFORMAT_31
== rStrm
.GetVersion() )
2381 if( DFLT_ESC_AUTO_SUPER
== _nEsc
)
2382 _nEsc
= DFLT_ESC_SUPER
;
2383 else if( DFLT_ESC_AUTO_SUB
== _nEsc
)
2384 _nEsc
= DFLT_ESC_SUB
;
2386 rStrm
<< (sal_uInt8
) GetProp()
2391 // -----------------------------------------------------------------------
2393 SfxPoolItem
* SvxEscapementItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2397 rStrm
>> _nProp
>> _nEsc
;
2398 return new SvxEscapementItem( _nEsc
, _nProp
, Which() );
2401 // -----------------------------------------------------------------------
2403 sal_uInt16
SvxEscapementItem::GetValueCount() const
2405 return SVX_ESCAPEMENT_END
; // SVX_ESCAPEMENT_SUBSCRIPT + 1
2408 //------------------------------------------------------------------------
2410 SfxItemPresentation
SvxEscapementItem::GetPresentation
2412 SfxItemPresentation ePres
,
2413 SfxMapUnit
/*eCoreUnit*/,
2414 SfxMapUnit
/*ePresUnit*/,
2415 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2420 case SFX_ITEM_PRESENTATION_NONE
:
2423 case SFX_ITEM_PRESENTATION_NAMELESS
:
2424 case SFX_ITEM_PRESENTATION_COMPLETE
:
2426 rText
= GetValueTextByPos( GetEnumValue() );
2430 if( DFLT_ESC_AUTO_SUPER
== nEsc
|| DFLT_ESC_AUTO_SUB
== nEsc
)
2431 rText
+= EE_RESSTR(RID_SVXITEMS_ESCAPEMENT_AUTO
);
2433 rText
= rText
+ OUString::number( nEsc
) + "%";
2437 default: ; //prevent warning
2439 return SFX_ITEM_PRESENTATION_NONE
;
2442 // -----------------------------------------------------------------------
2444 OUString
SvxEscapementItem::GetValueTextByPos( sal_uInt16 nPos
) const
2446 DBG_ASSERT( nPos
< (sal_uInt16
)SVX_ESCAPEMENT_END
, "enum overflow!" );
2447 return EE_RESSTR(RID_SVXITEMS_ESCAPEMENT_BEGIN
+ nPos
);
2450 // -----------------------------------------------------------------------
2452 sal_uInt16
SvxEscapementItem::GetEnumValue() const
2455 return SVX_ESCAPEMENT_SUBSCRIPT
;
2456 else if ( nEsc
> 0 )
2457 return SVX_ESCAPEMENT_SUPERSCRIPT
;
2458 return SVX_ESCAPEMENT_OFF
;
2461 // -----------------------------------------------------------------------
2463 void SvxEscapementItem::SetEnumValue( sal_uInt16 nVal
)
2465 SetEscapement( (const SvxEscapement
)nVal
);
2468 bool SvxEscapementItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2470 nMemberId
&= ~CONVERT_TWIPS
;
2474 rVal
<<= (sal_Int16
)(nEsc
);
2476 case MID_ESC_HEIGHT
:
2477 rVal
<<= (sal_Int8
)(nProp
);
2480 rVal
= Bool2Any(DFLT_ESC_AUTO_SUB
== nEsc
|| DFLT_ESC_AUTO_SUPER
== nEsc
);
2486 bool SvxEscapementItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2488 nMemberId
&= ~CONVERT_TWIPS
;
2493 sal_Int16 nVal
= sal_Int16();
2494 if( (rVal
>>= nVal
) && (std::abs(nVal
) <= 101))
2500 case MID_ESC_HEIGHT
:
2502 sal_Int8 nVal
= sal_Int8();
2503 if( (rVal
>>= nVal
) && (nVal
<= 100))
2511 sal_Bool bVal
= Any2Bool(rVal
);
2515 nEsc
= DFLT_ESC_AUTO_SUB
;
2517 nEsc
= DFLT_ESC_AUTO_SUPER
;
2520 if(DFLT_ESC_AUTO_SUPER
== nEsc
)
2522 else if(DFLT_ESC_AUTO_SUB
== nEsc
)
2530 // class SvxLanguageItem -------------------------------------------------
2532 SvxLanguageItem::SvxLanguageItem( const LanguageType eLang
, const sal_uInt16 nId
)
2533 : SfxEnumItem( nId
, eLang
)
2537 // -----------------------------------------------------------------------
2539 sal_uInt16
SvxLanguageItem::GetValueCount() const
2541 // #i50205# got rid of class International
2542 SAL_WARN( "editeng.items", "SvxLanguageItem::GetValueCount: supposed to return a count of what?");
2543 // FIXME: previously returned LANGUAGE_COUNT from tools/intn.hxx which was wrong anyway.
2544 // Could be SvtLanguageTable::GetEntryCount() (all locales with resource string)?
2545 // Could be LocaleDataWrapper::getInstalledLanguageTypes() (all locales with locale data)?
2549 // -----------------------------------------------------------------------
2551 SfxPoolItem
* SvxLanguageItem::Clone( SfxItemPool
* ) const
2553 return new SvxLanguageItem( *this );
2556 // -----------------------------------------------------------------------
2558 SvStream
& SvxLanguageItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2560 rStrm
<< (sal_uInt16
) GetValue();
2564 // -----------------------------------------------------------------------
2566 SfxPoolItem
* SvxLanguageItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2570 return new SvxLanguageItem( (LanguageType
)nValue
, Which() );
2573 //------------------------------------------------------------------------
2575 SfxItemPresentation
SvxLanguageItem::GetPresentation
2577 SfxItemPresentation ePres
,
2578 SfxMapUnit
/*eCoreUnit*/,
2579 SfxMapUnit
/*ePresUnit*/,
2580 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2585 case SFX_ITEM_PRESENTATION_NONE
:
2588 case SFX_ITEM_PRESENTATION_NAMELESS
:
2589 case SFX_ITEM_PRESENTATION_COMPLETE
:
2591 SvtLanguageTable aLangTable
;
2592 rText
= aLangTable
.GetString( (LanguageType
)GetValue() );
2595 default: ; //prevent warning
2597 return SFX_ITEM_PRESENTATION_NONE
;
2600 bool SvxLanguageItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2602 nMemberId
&= ~CONVERT_TWIPS
;
2605 case MID_LANG_INT
: // for basic conversions!
2606 rVal
<<= (sal_Int16
)(GetValue());
2608 case MID_LANG_LOCALE
:
2609 lang::Locale
aRet( LanguageTag( GetValue()).getLocale( false));
2616 bool SvxLanguageItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2618 nMemberId
&= ~CONVERT_TWIPS
;
2621 case MID_LANG_INT
: // for basic conversions!
2623 sal_Int32 nValue
= 0;
2624 if(!(rVal
>>= nValue
))
2627 SetValue((sal_Int16
)nValue
);
2630 case MID_LANG_LOCALE
:
2632 lang::Locale aLocale
;
2633 if(!(rVal
>>= aLocale
))
2636 SetValue( LanguageTag( aLocale
).getLanguageType( false));
2643 // class SvxNoLinebreakItem ----------------------------------------------
2644 SvxNoLinebreakItem::SvxNoLinebreakItem( const sal_Bool bBreak
, const sal_uInt16 nId
) :
2645 SfxBoolItem( nId
, bBreak
)
2649 // -----------------------------------------------------------------------
2651 SfxPoolItem
* SvxNoLinebreakItem::Clone( SfxItemPool
* ) const
2653 return new SvxNoLinebreakItem( *this );
2656 // -----------------------------------------------------------------------
2658 SvStream
& SvxNoLinebreakItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2660 rStrm
<< (sal_Bool
)GetValue();
2664 // -----------------------------------------------------------------------
2666 SfxPoolItem
* SvxNoLinebreakItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2670 return new SvxNoLinebreakItem( bValue
, Which() );
2673 //------------------------------------------------------------------------
2675 SfxItemPresentation
SvxNoLinebreakItem::GetPresentation
2677 SfxItemPresentation
/*ePres*/,
2678 SfxMapUnit
/*eCoreUnit*/,
2679 SfxMapUnit
/*ePresUnit*/,
2680 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2684 return SFX_ITEM_PRESENTATION_NONE
;
2687 // class SvxNoHyphenItem -------------------------------------------------
2689 SvxNoHyphenItem::SvxNoHyphenItem( const sal_Bool bHyphen
, const sal_uInt16 nId
) :
2690 SfxBoolItem( nId
, bHyphen
)
2694 // -----------------------------------------------------------------------
2696 SfxPoolItem
* SvxNoHyphenItem::Clone( SfxItemPool
* ) const
2698 return new SvxNoHyphenItem( *this );
2701 // -----------------------------------------------------------------------
2703 SvStream
& SvxNoHyphenItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2705 rStrm
<< (sal_Bool
) GetValue();
2709 // -----------------------------------------------------------------------
2711 SfxPoolItem
* SvxNoHyphenItem::Create( SvStream
& rStrm
, sal_uInt16
) const
2715 return new SvxNoHyphenItem( bValue
, Which() );
2718 //------------------------------------------------------------------------
2720 SfxItemPresentation
SvxNoHyphenItem::GetPresentation
2722 SfxItemPresentation
/*ePres*/,
2723 SfxMapUnit
/*eCoreUnit*/,
2724 SfxMapUnit
/*ePresUnit*/,
2725 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2729 return SFX_ITEM_PRESENTATION_NONE
;
2733 * Dummy item for ToolBox controls:
2737 // -----------------------------------------------------------------------
2738 // class SvxLineColorItem (== SvxColorItem)
2739 // -----------------------------------------------------------------------
2741 SvxLineColorItem::SvxLineColorItem( const sal_uInt16 nId
) :
2746 // -----------------------------------------------------------------------
2748 SvxLineColorItem::SvxLineColorItem( const SvxLineColorItem
&rCopy
) :
2749 SvxColorItem( rCopy
)
2753 // -----------------------------------------------------------------------
2755 SvxLineColorItem::~SvxLineColorItem()
2759 //------------------------------------------------------------------------
2761 SfxItemPresentation
SvxLineColorItem::GetPresentation
2763 SfxItemPresentation ePres
,
2764 SfxMapUnit eCoreUnit
,
2765 SfxMapUnit ePresUnit
,
2767 const IntlWrapper
* pIntlWrapper
2770 return SvxColorItem::GetPresentation( ePres
, eCoreUnit
, ePresUnit
,
2771 rText
, pIntlWrapper
);
2774 // class SvxBlinkItem -------------------------------------------------
2777 SvxBlinkItem::SvxBlinkItem( const sal_Bool bBlink
, const sal_uInt16 nId
) :
2778 SfxBoolItem( nId
, bBlink
)
2782 // -----------------------------------------------------------------------
2784 SfxPoolItem
* SvxBlinkItem::Clone( SfxItemPool
* ) const
2786 return new SvxBlinkItem( *this );
2789 // -----------------------------------------------------------------------
2791 SvStream
& SvxBlinkItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2793 rStrm
<< (sal_uInt8
) GetValue();
2797 // -----------------------------------------------------------------------
2799 SfxPoolItem
* SvxBlinkItem::Create(SvStream
& rStrm
, sal_uInt16
) const
2803 return new SvxBlinkItem( nState
, Which() );
2806 // -----------------------------------------------------------------------
2808 SfxItemPresentation
SvxBlinkItem::GetPresentation
2810 SfxItemPresentation ePres
,
2811 SfxMapUnit
/*eCoreUnit*/,
2812 SfxMapUnit
/*ePresUnit*/,
2813 OUString
& rText
, const IntlWrapper
* /*pIntl*/
2818 case SFX_ITEM_PRESENTATION_NONE
:
2821 case SFX_ITEM_PRESENTATION_NAMELESS
:
2822 case SFX_ITEM_PRESENTATION_COMPLETE
:
2824 sal_uInt16 nId
= RID_SVXITEMS_BLINK_FALSE
;
2827 nId
= RID_SVXITEMS_BLINK_TRUE
;
2828 rText
= EE_RESSTR(nId
);
2831 default: ; //prevent warning
2833 return SFX_ITEM_PRESENTATION_NONE
;
2836 // class SvxEmphaisMarkItem ---------------------------------------------------
2838 SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue
,
2839 const sal_uInt16 nId
)
2840 : SfxUInt16Item( nId
, nValue
)
2844 // -----------------------------------------------------------------------
2846 SfxPoolItem
* SvxEmphasisMarkItem::Clone( SfxItemPool
* ) const
2848 return new SvxEmphasisMarkItem( *this );
2851 // -----------------------------------------------------------------------
2853 SvStream
& SvxEmphasisMarkItem::Store( SvStream
& rStrm
,
2854 sal_uInt16
/*nItemVersion*/ ) const
2856 rStrm
<< (sal_uInt16
)GetValue();
2860 // -----------------------------------------------------------------------
2862 SfxPoolItem
* SvxEmphasisMarkItem::Create( SvStream
& rStrm
, sal_uInt16
) const
2866 return new SvxEmphasisMarkItem( (FontEmphasisMark
)nValue
, Which() );
2869 //------------------------------------------------------------------------
2871 SfxItemPresentation
SvxEmphasisMarkItem::GetPresentation
2873 SfxItemPresentation ePres
,
2874 SfxMapUnit
/*eCoreUnit*/,
2875 SfxMapUnit
/*ePresUnit*/,
2877 const IntlWrapper
* /*pIntl*/
2882 case SFX_ITEM_PRESENTATION_NONE
:
2885 case SFX_ITEM_PRESENTATION_NAMELESS
:
2886 case SFX_ITEM_PRESENTATION_COMPLETE
:
2888 sal_uInt16 nVal
= GetValue();
2889 rText
= EE_RESSTR( RID_SVXITEMS_EMPHASIS_BEGIN_STYLE
+
2890 ( EMPHASISMARK_STYLE
& nVal
));
2891 sal_uInt16 nId
= ( EMPHASISMARK_POS_ABOVE
& nVal
)
2892 ? RID_SVXITEMS_EMPHASIS_ABOVE_POS
2893 : ( EMPHASISMARK_POS_BELOW
& nVal
)
2894 ? RID_SVXITEMS_EMPHASIS_BELOW_POS
2897 rText
+= EE_RESSTR( nId
);
2900 default: ; //prevent warning
2902 return SFX_ITEM_PRESENTATION_NONE
;
2905 // -----------------------------------------------------------------------
2907 bool SvxEmphasisMarkItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2909 nMemberId
&= ~CONVERT_TWIPS
;
2914 sal_Int16 nValue
= GetValue();
2916 switch(nValue
& EMPHASISMARK_STYLE
)
2918 case EMPHASISMARK_NONE
: nRet
= FontEmphasis::NONE
; break;
2919 case EMPHASISMARK_DOT
: nRet
= FontEmphasis::DOT_ABOVE
; break;
2920 case EMPHASISMARK_CIRCLE
: nRet
= FontEmphasis::CIRCLE_ABOVE
; break;
2921 case EMPHASISMARK_DISC
: nRet
= FontEmphasis::DISK_ABOVE
; break;
2922 case EMPHASISMARK_ACCENT
: nRet
= FontEmphasis::ACCENT_ABOVE
; break;
2924 if(nRet
&& nValue
& EMPHASISMARK_POS_BELOW
)
2933 bool SvxEmphasisMarkItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2935 nMemberId
&= ~CONVERT_TWIPS
;
2936 sal_Bool bRet
= true;
2941 sal_Int32 nValue
= -1;
2945 case FontEmphasis::NONE
: nValue
= EMPHASISMARK_NONE
; break;
2946 case FontEmphasis::DOT_ABOVE
: nValue
= EMPHASISMARK_DOT
|EMPHASISMARK_POS_ABOVE
; break;
2947 case FontEmphasis::CIRCLE_ABOVE
: nValue
= EMPHASISMARK_CIRCLE
|EMPHASISMARK_POS_ABOVE
; break;
2948 case FontEmphasis::DISK_ABOVE
: nValue
= EMPHASISMARK_DISC
|EMPHASISMARK_POS_ABOVE
; break;
2949 case FontEmphasis::ACCENT_ABOVE
: nValue
= EMPHASISMARK_ACCENT
|EMPHASISMARK_POS_ABOVE
; break;
2950 case FontEmphasis::DOT_BELOW
: nValue
= EMPHASISMARK_DOT
|EMPHASISMARK_POS_BELOW
; break;
2951 case FontEmphasis::CIRCLE_BELOW
: nValue
= EMPHASISMARK_CIRCLE
|EMPHASISMARK_POS_BELOW
; break;
2952 case FontEmphasis::DISK_BELOW
: nValue
= EMPHASISMARK_DISC
|EMPHASISMARK_POS_BELOW
; break;
2953 case FontEmphasis::ACCENT_BELOW
: nValue
= EMPHASISMARK_ACCENT
|EMPHASISMARK_POS_BELOW
; break;
2954 default: return false;
2956 SetValue( (sal_Int16
)nValue
);
2963 sal_uInt16
SvxEmphasisMarkItem::GetVersion( sal_uInt16 nFFVer
) const
2965 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
2966 SOFFICE_FILEFORMAT_40
==nFFVer
||
2967 SOFFICE_FILEFORMAT_50
==nFFVer
,
2968 "SvxEmphasisMarkItem: Is there a new file format? ");
2970 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
2974 /*************************************************************************
2975 |* class SvxTwoLinesItem
2976 *************************************************************************/
2978 SvxTwoLinesItem::SvxTwoLinesItem( sal_Bool bFlag
, sal_Unicode nStartBracket
,
2979 sal_Unicode nEndBracket
, sal_uInt16 nW
)
2980 : SfxPoolItem( nW
),
2981 cStartBracket( nStartBracket
), cEndBracket( nEndBracket
), bOn( bFlag
)
2985 SvxTwoLinesItem::SvxTwoLinesItem( const SvxTwoLinesItem
& rAttr
)
2986 : SfxPoolItem( rAttr
.Which() ),
2987 cStartBracket( rAttr
.cStartBracket
),
2988 cEndBracket( rAttr
.cEndBracket
),
2993 SvxTwoLinesItem::~SvxTwoLinesItem()
2997 int SvxTwoLinesItem::operator==( const SfxPoolItem
& rAttr
) const
2999 DBG_ASSERT( SfxPoolItem::operator==( rAttr
), "not equal attribute types" );
3000 return bOn
== ((SvxTwoLinesItem
&)rAttr
).bOn
&&
3001 cStartBracket
== ((SvxTwoLinesItem
&)rAttr
).cStartBracket
&&
3002 cEndBracket
== ((SvxTwoLinesItem
&)rAttr
).cEndBracket
;
3005 SfxPoolItem
* SvxTwoLinesItem::Clone( SfxItemPool
* ) const
3007 return new SvxTwoLinesItem( *this );
3010 bool SvxTwoLinesItem::QueryValue( com::sun::star::uno::Any
& rVal
,
3011 sal_uInt8 nMemberId
) const
3013 nMemberId
&= ~CONVERT_TWIPS
;
3014 sal_Bool bRet
= true;
3018 rVal
= Bool2Any( bOn
);
3020 case MID_START_BRACKET
:
3024 s
= OUString( cStartBracket
);
3028 case MID_END_BRACKET
:
3032 s
= OUString( cEndBracket
);
3043 bool SvxTwoLinesItem::PutValue( const com::sun::star::uno::Any
& rVal
,
3044 sal_uInt8 nMemberId
)
3046 nMemberId
&= ~CONVERT_TWIPS
;
3047 sal_Bool bRet
= sal_False
;
3052 bOn
= Any2Bool( rVal
);
3055 case MID_START_BRACKET
:
3058 cStartBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
3062 case MID_END_BRACKET
:
3065 cEndBracket
= s
.isEmpty() ? 0 : s
[ 0 ];
3073 SfxItemPresentation
SvxTwoLinesItem::GetPresentation( SfxItemPresentation ePres
,
3074 SfxMapUnit
/*eCoreMetric*/, SfxMapUnit
/*ePresMetric*/,
3075 OUString
&rText
, const IntlWrapper
* /*pIntl*/ ) const
3079 case SFX_ITEM_PRESENTATION_NONE
:
3082 case SFX_ITEM_PRESENTATION_NAMELESS
:
3083 case SFX_ITEM_PRESENTATION_COMPLETE
:
3086 rText
= EE_RESSTR( RID_SVXITEMS_TWOLINES_OFF
);
3089 rText
= EE_RESSTR( RID_SVXITEMS_TWOLINES
);
3090 if( GetStartBracket() )
3091 rText
= OUString(GetStartBracket()) + rText
;
3092 if( GetEndBracket() )
3093 rText
+= OUString(GetEndBracket());
3097 default: ; //prevent warning
3099 return SFX_ITEM_PRESENTATION_NONE
;
3103 SfxPoolItem
* SvxTwoLinesItem::Create( SvStream
& rStrm
, sal_uInt16
/*nVer*/) const
3106 sal_Unicode cStart
, cEnd
;
3107 rStrm
>> _bOn
>> cStart
>> cEnd
;
3108 return new SvxTwoLinesItem( _bOn
, cStart
, cEnd
, Which() );
3111 SvStream
& SvxTwoLinesItem::Store(SvStream
& rStrm
, sal_uInt16
/*nIVer*/) const
3113 rStrm
<< GetValue() << GetStartBracket() << GetEndBracket();
3117 sal_uInt16
SvxTwoLinesItem::GetVersion( sal_uInt16 nFFVer
) const
3119 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
3120 SOFFICE_FILEFORMAT_40
==nFFVer
||
3121 SOFFICE_FILEFORMAT_50
==nFFVer
,
3122 "SvxTwoLinesItem: Gibt es ein neues Fileformat?" );
3124 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
3128 /*************************************************************************
3129 |* class SvxCharRotateItem
3130 *************************************************************************/
3132 SvxCharRotateItem::SvxCharRotateItem( sal_uInt16 nValue
,
3133 sal_Bool bFitIntoLine
,
3134 const sal_uInt16 nW
)
3135 : SfxUInt16Item( nW
, nValue
), bFitToLine( bFitIntoLine
)
3139 SfxPoolItem
* SvxCharRotateItem::Clone( SfxItemPool
* ) const
3141 return new SvxCharRotateItem( GetValue(), IsFitToLine(), Which() );
3144 SfxPoolItem
* SvxCharRotateItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3149 return new SvxCharRotateItem( nVal
, b
, Which() );
3152 SvStream
& SvxCharRotateItem::Store( SvStream
& rStrm
, sal_uInt16
) const
3154 sal_Bool bFlag
= IsFitToLine();
3155 rStrm
<< GetValue() << bFlag
;
3159 sal_uInt16
SvxCharRotateItem::GetVersion( sal_uInt16 nFFVer
) const
3161 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
3164 SfxItemPresentation
SvxCharRotateItem::GetPresentation(
3165 SfxItemPresentation ePres
,
3166 SfxMapUnit
/*eCoreMetric*/, SfxMapUnit
/*ePresMetric*/,
3167 OUString
&rText
, const IntlWrapper
* ) const
3171 case SFX_ITEM_PRESENTATION_NONE
:
3174 case SFX_ITEM_PRESENTATION_NAMELESS
:
3175 case SFX_ITEM_PRESENTATION_COMPLETE
:
3178 rText
= EE_RESSTR( RID_SVXITEMS_CHARROTATE_OFF
);
3181 rText
= EE_RESSTR( RID_SVXITEMS_CHARROTATE
);
3182 rText
= rText
.replaceFirst( "$(ARG1)",
3183 OUString::number( GetValue() / 10 ));
3185 rText
+= EE_RESSTR( RID_SVXITEMS_CHARROTATE_FITLINE
);
3189 default: ; //prevent warning
3191 return SFX_ITEM_PRESENTATION_NONE
;
3194 bool SvxCharRotateItem::QueryValue( com::sun::star::uno::Any
& rVal
,
3195 sal_uInt8 nMemberId
) const
3197 nMemberId
&= ~CONVERT_TWIPS
;
3202 rVal
<<= (sal_Int16
)GetValue();
3205 rVal
= Bool2Any( IsFitToLine() );
3214 bool SvxCharRotateItem::PutValue( const com::sun::star::uno::Any
& rVal
,
3215 sal_uInt8 nMemberId
)
3217 nMemberId
&= ~CONVERT_TWIPS
;
3224 if((rVal
>>= nVal
) && (0 == nVal
|| 900 == nVal
|| 2700 == nVal
))
3225 SetValue( (sal_uInt16
)nVal
);
3232 SetFitToLine( Any2Bool( rVal
) );
3240 int SvxCharRotateItem::operator==( const SfxPoolItem
& rItem
) const
3242 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
3243 return SfxUInt16Item::operator==( rItem
) &&
3244 IsFitToLine() == ((const SvxCharRotateItem
&)rItem
).IsFitToLine();
3248 /*************************************************************************
3249 |* class SvxCharScaleItem
3250 *************************************************************************/
3252 SvxCharScaleWidthItem::SvxCharScaleWidthItem( sal_uInt16 nValue
,
3253 const sal_uInt16 nW
)
3254 : SfxUInt16Item( nW
, nValue
)
3258 SfxPoolItem
* SvxCharScaleWidthItem::Clone( SfxItemPool
* ) const
3260 return new SvxCharScaleWidthItem( GetValue(), Which() );
3263 SfxPoolItem
* SvxCharScaleWidthItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3267 SvxCharScaleWidthItem
* pItem
= new SvxCharScaleWidthItem( nVal
, Which() );
3269 if ( Which() == EE_CHAR_FONTWIDTH
)
3271 // Was a SvxFontWidthItem in 5.2
3272 // sal_uInt16 nFixWidth, sal_uInt16 nPropWidth.
3273 // nFixWidth has never been used...
3277 if ( nTest
== 0x1234 )
3278 pItem
->SetValue( nVal
);
3280 rStrm
.SeekRel( -2*(long)sizeof(sal_uInt16
) );
3286 SvStream
& SvxCharScaleWidthItem::Store( SvStream
& rStream
, sal_uInt16 nVer
) const
3288 SvStream
& rRet
= SfxUInt16Item::Store( rStream
, nVer
);
3289 if ( Which() == EE_CHAR_FONTWIDTH
)
3291 // see comment in Create()....
3292 rRet
.SeekRel( -1*(long)sizeof(sal_uInt16
) );
3293 rRet
<< (sal_uInt16
)0;
3295 // Really ugly, but not a problem for reading the doc in 5.2
3296 rRet
<< (sal_uInt16
)0x1234;
3302 sal_uInt16
SvxCharScaleWidthItem::GetVersion( sal_uInt16 nFFVer
) const
3304 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
3307 SfxItemPresentation
SvxCharScaleWidthItem::GetPresentation(
3308 SfxItemPresentation ePres
,
3309 SfxMapUnit
/*eCoreMetric*/, SfxMapUnit
/*ePresMetric*/,
3310 OUString
&rText
, const IntlWrapper
* ) const
3314 case SFX_ITEM_PRESENTATION_NONE
:
3317 case SFX_ITEM_PRESENTATION_NAMELESS
:
3318 case SFX_ITEM_PRESENTATION_COMPLETE
:
3321 rText
= EE_RESSTR( RID_SVXITEMS_CHARSCALE_OFF
);
3324 rText
= EE_RESSTR( RID_SVXITEMS_CHARSCALE
);
3325 rText
= rText
.replaceFirst( "$(ARG1)",
3326 OUString::number( GetValue() ));
3330 default: ; //prevent warning
3332 return SFX_ITEM_PRESENTATION_NONE
;
3335 bool SvxCharScaleWidthItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
3337 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
3338 // where we still want this to be a sal_Int16
3339 sal_Int16 nValue
= sal_Int16();
3340 if (rVal
>>= nValue
)
3342 SetValue( (sal_uInt16
) nValue
);
3346 OSL_TRACE( "SvxCharScaleWidthItem::PutValue - Wrong type!" );
3350 bool SvxCharScaleWidthItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
3352 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
3353 // where we still want this to be a sal_Int16
3354 rVal
<<= (sal_Int16
)GetValue();
3358 /*************************************************************************
3359 |* class SvxCharReliefItem
3360 *************************************************************************/
3362 SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue
,
3363 const sal_uInt16 nId
)
3364 : SfxEnumItem( nId
, (sal_uInt16
)eValue
)
3368 SfxPoolItem
* SvxCharReliefItem::Clone( SfxItemPool
* ) const
3370 return new SvxCharReliefItem( *this );
3373 SfxPoolItem
* SvxCharReliefItem::Create(SvStream
& rStrm
, sal_uInt16
) const
3377 return new SvxCharReliefItem( (FontRelief
)nVal
, Which() );
3380 SvStream
& SvxCharReliefItem::Store(SvStream
& rStrm
, sal_uInt16
/*nIVer*/) const
3382 sal_uInt16 nVal
= GetValue();
3387 sal_uInt16
SvxCharReliefItem::GetVersion( sal_uInt16 nFFVer
) const
3389 return SOFFICE_FILEFORMAT_50
> nFFVer
? USHRT_MAX
: 0;
3392 OUString
SvxCharReliefItem::GetValueTextByPos( sal_uInt16 nPos
) const
3394 DBG_ASSERT( RID_SVXITEMS_RELIEF_ENGRAVED
- RID_SVXITEMS_RELIEF_NONE
,
3396 return EE_RESSTR(RID_SVXITEMS_RELIEF_BEGIN
+ nPos
);
3399 sal_uInt16
SvxCharReliefItem::GetValueCount() const
3401 return RID_SVXITEMS_RELIEF_ENGRAVED
- RID_SVXITEMS_RELIEF_NONE
;
3404 SfxItemPresentation
SvxCharReliefItem::GetPresentation
3406 SfxItemPresentation ePres
,
3407 SfxMapUnit
/*eCoreUnit*/,
3408 SfxMapUnit
/*ePresUnit*/,
3409 OUString
& rText
, const IntlWrapper
* /*pIntl*/
3412 SfxItemPresentation eRet
= ePres
;
3415 case SFX_ITEM_PRESENTATION_NONE
:
3419 case SFX_ITEM_PRESENTATION_NAMELESS
:
3420 case SFX_ITEM_PRESENTATION_COMPLETE
:
3421 rText
= GetValueTextByPos( GetValue() );
3425 eRet
= SFX_ITEM_PRESENTATION_NONE
;
3430 bool SvxCharReliefItem::PutValue( const com::sun::star::uno::Any
& rVal
,
3431 sal_uInt8 nMemberId
)
3433 nMemberId
&= ~CONVERT_TWIPS
;
3439 sal_Int16 nVal
= -1;
3441 if(nVal
>= 0 && nVal
<= RELIEF_ENGRAVED
)
3442 SetValue( (sal_uInt16
)nVal
);
3454 bool SvxCharReliefItem::QueryValue( com::sun::star::uno::Any
& rVal
,
3455 sal_uInt8 nMemberId
) const
3457 nMemberId
&= ~CONVERT_TWIPS
;
3462 rVal
<<= (sal_Int16
)GetValue();
3471 /*************************************************************************
3472 |* class SvxScriptTypeItemItem
3473 *************************************************************************/
3475 SvxScriptTypeItem::SvxScriptTypeItem( sal_uInt16 nType
)
3476 : SfxUInt16Item( SID_ATTR_CHAR_SCRIPTTYPE
, nType
)
3479 SfxPoolItem
* SvxScriptTypeItem::Clone( SfxItemPool
* ) const
3481 return new SvxScriptTypeItem( GetValue() );
3484 /*************************************************************************
3485 |* class SvxScriptSetItem
3486 *************************************************************************/
3488 SvxScriptSetItem::SvxScriptSetItem( sal_uInt16 nSlotId
, SfxItemPool
& rPool
)
3489 : SfxSetItem( nSlotId
, new SfxItemSet( rPool
,
3490 SID_ATTR_CHAR_FONT
, SID_ATTR_CHAR_FONT
))
3492 sal_uInt16 nLatin
, nAsian
, nComplex
;
3493 GetWhichIds( nLatin
, nAsian
, nComplex
);
3494 GetItemSet().MergeRange( nLatin
, nLatin
);
3495 GetItemSet().MergeRange( nAsian
, nAsian
);
3496 GetItemSet().MergeRange( nComplex
, nComplex
);
3497 GetItemSet().MergeRange( SID_ATTR_CHAR_SCRIPTTYPE
, SID_ATTR_CHAR_SCRIPTTYPE
);
3500 SfxPoolItem
* SvxScriptSetItem::Clone( SfxItemPool
* ) const
3502 SvxScriptSetItem
* p
= new SvxScriptSetItem( Which(), *GetItemSet().GetPool() );
3503 p
->GetItemSet().Put( GetItemSet(), sal_False
);
3507 SfxPoolItem
* SvxScriptSetItem::Create( SvStream
&, sal_uInt16
) const
3512 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScriptSet(
3513 const SfxItemSet
& rSet
, sal_uInt16 nId
)
3515 const SfxPoolItem
* pI
;
3516 SfxItemState eSt
= rSet
.GetItemState( nId
, sal_False
, &pI
);
3517 if( SFX_ITEM_SET
!= eSt
)
3518 pI
= SFX_ITEM_DEFAULT
== eSt
? &rSet
.Get( nId
) : 0;
3522 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, sal_uInt16 nScript
)
3524 sal_uInt16 nLatin
, nAsian
, nComplex
;
3525 GetWhichIds( nSlotId
, rSet
, nLatin
, nAsian
, nComplex
);
3527 const SfxPoolItem
*pRet
, *pAsn
, *pCmplx
;
3530 default: //no one valid -> match to latin
3531 // case SCRIPTTYPE_LATIN:
3532 pRet
= GetItemOfScriptSet( rSet
, nLatin
);
3534 case SCRIPTTYPE_ASIAN
:
3535 pRet
= GetItemOfScriptSet( rSet
, nAsian
);
3537 case SCRIPTTYPE_COMPLEX
:
3538 pRet
= GetItemOfScriptSet( rSet
, nComplex
);
3541 case SCRIPTTYPE_LATIN
|SCRIPTTYPE_ASIAN
:
3542 if( 0 == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
3543 0 == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
3548 case SCRIPTTYPE_LATIN
|SCRIPTTYPE_COMPLEX
:
3549 if( 0 == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
3550 0 == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
3555 case SCRIPTTYPE_ASIAN
|SCRIPTTYPE_COMPLEX
:
3556 if( 0 == (pRet
= GetItemOfScriptSet( rSet
, nAsian
)) ||
3557 0 == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
3562 case SCRIPTTYPE_LATIN
|SCRIPTTYPE_ASIAN
|SCRIPTTYPE_COMPLEX
:
3563 if( 0 == (pRet
= GetItemOfScriptSet( rSet
, nLatin
)) ||
3564 0 == (pAsn
= GetItemOfScriptSet( rSet
, nAsian
)) ||
3565 0 == (pCmplx
= GetItemOfScriptSet( rSet
, nComplex
)) ||
3566 *pRet
!= *pAsn
|| *pRet
!= *pCmplx
)
3573 const SfxPoolItem
* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nScript
) const
3575 return GetItemOfScript( Which(), GetItemSet(), nScript
);
3578 void SvxScriptSetItem::PutItemForScriptType( sal_uInt16 nScriptType
,
3579 const SfxPoolItem
& rItem
)
3581 sal_uInt16 nLatin
, nAsian
, nComplex
;
3582 GetWhichIds( nLatin
, nAsian
, nComplex
);
3584 SfxPoolItem
* pCpy
= rItem
.Clone();
3585 if( SCRIPTTYPE_LATIN
& nScriptType
)
3587 pCpy
->SetWhich( nLatin
);
3588 GetItemSet().Put( *pCpy
);
3590 if( SCRIPTTYPE_ASIAN
& nScriptType
)
3592 pCpy
->SetWhich( nAsian
);
3593 GetItemSet().Put( *pCpy
);
3595 if( SCRIPTTYPE_COMPLEX
& nScriptType
)
3597 pCpy
->SetWhich( nComplex
);
3598 GetItemSet().Put( *pCpy
);
3603 void SvxScriptSetItem::GetWhichIds( sal_uInt16 nSlotId
, const SfxItemSet
& rSet
, sal_uInt16
& rLatin
, sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
3605 const SfxItemPool
& rPool
= *rSet
.GetPool();
3606 GetSlotIds( nSlotId
, rLatin
, rAsian
, rComplex
);
3607 rLatin
= rPool
.GetWhich( rLatin
);
3608 rAsian
= rPool
.GetWhich( rAsian
);
3609 rComplex
= rPool
.GetWhich( rComplex
);
3612 void SvxScriptSetItem::GetWhichIds( sal_uInt16
& rLatin
, sal_uInt16
& rAsian
,
3613 sal_uInt16
& rComplex
) const
3615 GetWhichIds( Which(), GetItemSet(), rLatin
, rAsian
, rComplex
);
3618 void SvxScriptSetItem::GetSlotIds( sal_uInt16 nSlotId
, sal_uInt16
& rLatin
,
3619 sal_uInt16
& rAsian
, sal_uInt16
& rComplex
)
3624 DBG_ASSERT( sal_False
, "wrong SlotId for class SvxScriptSetItem" );
3625 // no break - default to font - Id Range !!
3627 case SID_ATTR_CHAR_FONT
:
3628 rLatin
= SID_ATTR_CHAR_FONT
;
3629 rAsian
= SID_ATTR_CHAR_CJK_FONT
;
3630 rComplex
= SID_ATTR_CHAR_CTL_FONT
;
3632 case SID_ATTR_CHAR_FONTHEIGHT
:
3633 rLatin
= SID_ATTR_CHAR_FONTHEIGHT
;
3634 rAsian
= SID_ATTR_CHAR_CJK_FONTHEIGHT
;
3635 rComplex
= SID_ATTR_CHAR_CTL_FONTHEIGHT
;
3637 case SID_ATTR_CHAR_WEIGHT
:
3638 rLatin
= SID_ATTR_CHAR_WEIGHT
;
3639 rAsian
= SID_ATTR_CHAR_CJK_WEIGHT
;
3640 rComplex
= SID_ATTR_CHAR_CTL_WEIGHT
;
3642 case SID_ATTR_CHAR_POSTURE
:
3643 rLatin
= SID_ATTR_CHAR_POSTURE
;
3644 rAsian
= SID_ATTR_CHAR_CJK_POSTURE
;
3645 rComplex
= SID_ATTR_CHAR_CTL_POSTURE
;
3647 case SID_ATTR_CHAR_LANGUAGE
:
3648 rLatin
= SID_ATTR_CHAR_LANGUAGE
;
3649 rAsian
= SID_ATTR_CHAR_CJK_LANGUAGE
;
3650 rComplex
= SID_ATTR_CHAR_CTL_LANGUAGE
;
3652 case SID_ATTR_CHAR_SHADOWED
:
3653 rLatin
= SID_ATTR_CHAR_SHADOWED
;
3654 rAsian
= SID_ATTR_CHAR_SHADOWED
;
3655 rComplex
= SID_ATTR_CHAR_SHADOWED
;
3657 case SID_ATTR_CHAR_STRIKEOUT
:
3658 rLatin
= SID_ATTR_CHAR_STRIKEOUT
;
3659 rAsian
= SID_ATTR_CHAR_STRIKEOUT
;
3660 rComplex
= SID_ATTR_CHAR_STRIKEOUT
;
3665 void GetDefaultFonts( SvxFontItem
& rLatin
, SvxFontItem
& rAsian
, SvxFontItem
& rComplex
)
3667 const sal_uInt16 nItemCnt
= 3;
3671 sal_uInt16 nFontType
;
3672 sal_uInt16 nLanguage
;
3674 aOutTypeArr
[ nItemCnt
] =
3676 { DEFAULTFONT_LATIN_TEXT
, LANGUAGE_ENGLISH_US
},
3677 { DEFAULTFONT_CJK_TEXT
, LANGUAGE_ENGLISH_US
},
3678 { DEFAULTFONT_CTL_TEXT
, LANGUAGE_ARABIC_SAUDI_ARABIA
}
3681 SvxFontItem
* aItemArr
[ nItemCnt
] = { &rLatin
, &rAsian
, &rComplex
};
3683 for ( sal_uInt16 n
= 0; n
< nItemCnt
; ++n
)
3685 Font
aFont( OutputDevice::GetDefaultFont( aOutTypeArr
[ n
].nFontType
,
3686 aOutTypeArr
[ n
].nLanguage
,
3687 DEFAULTFONT_FLAGS_ONLYONE
, 0 ) );
3688 SvxFontItem
* pItem
= aItemArr
[ n
];
3689 pItem
->SetFamily( aFont
.GetFamily() );
3690 pItem
->SetFamilyName( aFont
.GetName() );
3691 pItem
->SetStyleName( String() );
3692 pItem
->SetPitch( aFont
.GetPitch());
3693 pItem
->SetCharSet(aFont
.GetCharSet());
3698 sal_uInt16
GetI18NScriptTypeOfLanguage( sal_uInt16 nLang
)
3700 return GetI18NScriptType( SvtLanguageOptions::GetScriptTypeOfLanguage( nLang
) );
3703 sal_uInt16
GetItemScriptType( short nI18NType
)
3705 switch ( nI18NType
)
3707 case i18n::ScriptType::LATIN
: return SCRIPTTYPE_LATIN
;
3708 case i18n::ScriptType::ASIAN
: return SCRIPTTYPE_ASIAN
;
3709 case i18n::ScriptType::COMPLEX
: return SCRIPTTYPE_COMPLEX
;
3714 short GetI18NScriptType( sal_uInt16 nItemType
)
3716 switch ( nItemType
)
3718 case SCRIPTTYPE_LATIN
: return i18n::ScriptType::LATIN
;
3719 case SCRIPTTYPE_ASIAN
: return i18n::ScriptType::ASIAN
;
3720 case SCRIPTTYPE_COMPLEX
: return i18n::ScriptType::COMPLEX
;
3725 bool SvxRsidItem::QueryValue( uno::Any
& rVal
, sal_uInt8
) const
3727 rVal
<<= ( (sal_uInt32
)GetValue() );
3731 bool SvxRsidItem::PutValue( const uno::Any
& rVal
, sal_uInt8
)
3733 sal_uInt32 nRsid
= 0;
3734 if( !( rVal
>>= nRsid
) )
3741 SfxPoolItem
* SvxRsidItem::Clone( SfxItemPool
* ) const
3743 return new SvxRsidItem( *this );
3746 SfxPoolItem
* SvxRsidItem::Create(SvStream
& rIn
, sal_uInt16
) const
3748 return new SvxRsidItem( rIn
, Which() );
3750 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */