bump product version to 4.1.6.2
[LibreOffice.git] / editeng / source / items / textitem.cxx
blobc026f1d951a0b07905999e7308c5e2d578fd2e61
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/style/CaseMap.hpp>
21 #include <com/sun/star/awt/FontDescriptor.hpp>
22 #include <com/sun/star/frame/status/FontHeight.hpp>
23 #include <vcl/bitmapex.hxx>
24 #include <tools/stream.hxx>
25 #include <toolkit/unohlp.hxx>
26 #include <math.h>
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 ) :
154 SfxPoolItem( nId ),
155 pFontList( pFontLst )
157 if ( pFontList )
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;
196 return true;
199 //------------------------------------------------------------------------
201 SfxItemPresentation SvxFontListItem::GetPresentation
203 SfxItemPresentation /*ePres*/,
204 SfxMapUnit /*eCoreUnit*/,
205 SfxMapUnit /*ePresUnit*/,
206 OUString& rText, const IntlWrapper * /*pIntl*/
207 ) const
209 rText = OUString();
210 return SFX_ITEM_PRESENTATION_NONE;
213 // class SvxFontItem -----------------------------------------------------
215 SvxFontItem::SvxFontItem( const sal_uInt16 nId ) :
216 SfxPoolItem( 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 ) :
229 SfxPoolItem( nId ),
231 aFamilyName(aName),
232 aStyleName(aStName)
234 eFamily = eFam;
235 ePitch = eFontPitch;
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();
247 return *this;
249 // -----------------------------------------------------------------------
251 bool SvxFontItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
253 nMemberId &= ~CONVERT_TWIPS;
254 switch(nMemberId)
256 case 0:
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;
266 break;
267 case MID_FONT_FAMILY_NAME :
268 rVal <<= OUString(aFamilyName.GetBuffer());
269 break;
270 case MID_FONT_STYLE_NAME:
271 rVal <<= OUString(aStyleName.GetBuffer());
272 break;
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;
277 return true;
279 // -----------------------------------------------------------------------
280 bool SvxFontItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId)
282 nMemberId &= ~CONVERT_TWIPS;
283 switch(nMemberId)
285 case 0:
287 com::sun::star::awt::FontDescriptor aFontDescriptor;
288 if ( !( rVal >>= aFontDescriptor ))
289 return sal_False;
291 aFamilyName = aFontDescriptor.Name;
292 aStyleName = aFontDescriptor.StyleName;
293 eFamily = (FontFamily)aFontDescriptor.Family;
294 eTextEncoding = (rtl_TextEncoding)aFontDescriptor.CharSet;
295 ePitch = (FontPitch)aFontDescriptor.Pitch;
297 break;
298 case MID_FONT_FAMILY_NAME :
300 OUString aStr;
301 if(!(rVal >>= aStr))
302 return sal_False;
303 aFamilyName = aStr.getStr();
305 break;
306 case MID_FONT_STYLE_NAME:
308 OUString aStr;
309 if(!(rVal >>= aStr))
310 return sal_False;
311 aStyleName = aStr.getStr();
313 break;
314 case MID_FONT_FAMILY :
316 sal_Int16 nFamily = sal_Int16();
317 if(!(rVal >>= nFamily))
318 return sal_False;
319 eFamily = (FontFamily)nFamily;
321 break;
322 case MID_FONT_CHAR_SET :
324 sal_Int16 nSet = sal_Int16();
325 if(!(rVal >>= nSet))
326 return sal_False;
327 eTextEncoding = (rtl_TextEncoding)nSet;
329 break;
330 case MID_FONT_PITCH :
332 sal_Int16 nPitch = sal_Int16();
333 if(!(rVal >>= nPitch))
334 return sal_False;
335 ePitch = (FontPitch)nPitch;
337 break;
339 return true;
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 );
354 if ( bRet )
356 if ( ePitch != rItem.ePitch || eTextEncoding != rItem.eTextEncoding )
358 bRet = sal_False;
359 DBG_WARNING( "FontItem::operator==(): only pitch or rtl_TextEncoding different ");
362 return bRet;
365 // -----------------------------------------------------------------------
367 SfxPoolItem* SvxFontItem::Clone( SfxItemPool * ) const
369 return new SvxFontItem( *this );
372 // -----------------------------------------------------------------------
374 SvStream& SvxFontItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
376 sal_Bool bToBats =
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() );
384 if( bToBats )
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;
393 rStrm << nMagic;
394 rStrm.WriteUniOrByteString( aStoreFamilyName, RTL_TEXTENCODING_UNICODE );
395 rStrm.WriteUniOrByteString( GetStyleName(), RTL_TEXTENCODING_UNICODE );
398 return rStrm;
401 // -----------------------------------------------------------------------
403 SfxPoolItem* SvxFontItem::Create(SvStream& rStrm, sal_uInt16) const
405 sal_uInt8 _eFamily, eFontPitch, eFontTextEncoding;
406 String aName, aStyle;
407 rStrm >> _eFamily;
408 rStrm >> eFontPitch;
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;
427 rStrm >> nMagic;
428 if ( nMagic == STORE_UNICODE_MAGIC_MARKER )
430 aName = rStrm.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE );
431 aStyle = rStrm.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE );
433 else
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*/
452 ) const
454 switch ( ePres )
456 case SFX_ITEM_PRESENTATION_NONE:
457 rText = OUString();
458 return ePres;
459 case SFX_ITEM_PRESENTATION_NAMELESS:
460 case SFX_ITEM_PRESENTATION_COMPLETE:
461 rText = aFamilyName;
462 return ePres;
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();
501 return rStrm;
504 // -----------------------------------------------------------------------
506 SfxPoolItem* SvxPostureItem::Create(SvStream& rStrm, sal_uInt16) const
508 sal_uInt8 nPosture;
509 rStrm >> nPosture;
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*/
521 ) const
523 switch ( ePres )
525 case SFX_ITEM_PRESENTATION_NONE:
526 rText = OUString();
527 return ePres;
528 case SFX_ITEM_PRESENTATION_NAMELESS:
529 case SFX_ITEM_PRESENTATION_COMPLETE:
530 rText = GetValueTextByPos( GetValue() );
531 return ePres;
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;
544 sal_uInt16 nId = 0;
546 switch ( eItalic )
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;
560 switch( nMemberId )
562 case MID_ITALIC:
563 rVal = Bool2Any(GetBoolValue());
564 break;
565 case MID_POSTURE:
566 rVal <<= (awt::FontSlant)GetValue(); // values from awt::FontSlant and FontItalic are equal
567 break;
569 return true;
572 bool SvxPostureItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
574 nMemberId &= ~CONVERT_TWIPS;
575 switch( nMemberId )
577 case MID_ITALIC:
578 SetBoolValue(Any2Bool(rVal));
579 break;
580 case MID_POSTURE:
582 awt::FontSlant eSlant;
583 if(!(rVal >>= eSlant))
585 sal_Int32 nValue = 0;
586 if(!(rVal >>= nValue))
587 return sal_False;
589 eSlant = (awt::FontSlant)nValue;
591 SetValue((sal_uInt16)eSlant);
594 return true;
596 // -----------------------------------------------------------------------
598 int SvxPostureItem::HasBoolValue() const
600 return sal_True;
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
630 return sal_True;
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();
666 return rStrm;
669 // -----------------------------------------------------------------------
671 SfxPoolItem* SvxWeightItem::Create(SvStream& rStrm, sal_uInt16) const
673 sal_uInt8 nWeight;
674 rStrm >> nWeight;
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*/
686 ) const
688 switch ( ePres )
690 case SFX_ITEM_PRESENTATION_NONE:
691 rText = OUString();
692 return ePres;
693 case SFX_ITEM_PRESENTATION_NAMELESS:
694 case SFX_ITEM_PRESENTATION_COMPLETE:
695 rText = GetValueTextByPos( GetValue() );
696 return ePres;
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;
713 switch( nMemberId )
715 case MID_BOLD :
716 rVal = Bool2Any(GetBoolValue());
717 break;
718 case MID_WEIGHT:
720 rVal <<= (float)( VCLUnoHelper::ConvertFontWeight( (FontWeight)GetValue() ) );
722 break;
724 return true;
727 bool SvxWeightItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
729 nMemberId &= ~CONVERT_TWIPS;
730 switch( nMemberId )
732 case MID_BOLD :
733 SetBoolValue(Any2Bool(rVal));
734 break;
735 case MID_WEIGHT:
737 double fValue = 0;
738 if(!(rVal >>= fValue))
740 sal_Int32 nValue = 0;
741 if(!(rVal >>= nValue))
742 return sal_False;
743 fValue = (float)nValue;
745 SetValue( (sal_uInt16)VCLUnoHelper::ConvertFontWeight((float)fValue) );
747 break;
749 return true;
752 // class SvxFontHeightItem -----------------------------------------------
754 SvxFontHeightItem::SvxFontHeightItem( const sal_uLong nSz,
755 const sal_uInt16 nPrp,
756 const sal_uInt16 nId ) :
757 SfxPoolItem( 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();
777 else
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() )
783 _nProp = 100;
784 rStrm << _nProp;
786 return rStrm;
789 // -----------------------------------------------------------------------
791 SfxPoolItem* SvxFontHeightItem::Create( SvStream& rStrm,
792 sal_uInt16 nVersion ) const
794 sal_uInt16 nsize, nprop = 0, nPropUnit = SFX_MAPUNIT_RELATIVE;
796 rStrm >> nsize;
798 if( FONTHEIGHT_16_VERSION <= nVersion )
799 rStrm >> nprop;
800 else
802 sal_uInt8 nP;
803 rStrm >> nP;
804 nprop = (sal_uInt16)nP;
807 if( FONTHEIGHT_UNIT_VERSION <= nVersion )
808 rStrm >> nPropUnit;
810 SvxFontHeightItem* pItem = new SvxFontHeightItem( nsize, 100, Which() );
811 pItem->SetProp( nprop, (SfxMapUnit)nPropUnit );
812 return pItem;
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;
832 switch( nMemberId )
834 case 0:
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.
840 if( bConvert )
842 long nTwips = bConvert ? nHeight : MM100_TO_TWIP_UNSIGNED(nHeight);
843 aFontHeight.Height = (float)( nTwips / 20.0 );
845 else
847 double fPoints = MM100_TO_TWIP_UNSIGNED(nHeight) / 20.0;
848 float fRoundPoints =
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;
856 switch( ePropUnit )
858 case SFX_MAPUNIT_RELATIVE:
859 fRet = 0.;
860 break;
861 case SFX_MAPUNIT_100TH_MM:
862 fRet = MM100_TO_TWIP(fRet);
863 fRet /= 20.;
864 break;
865 case SFX_MAPUNIT_POINT:
867 break;
868 case SFX_MAPUNIT_TWIP:
869 fRet /= 20.;
870 break;
871 default: ;//prevent warning
873 aFontHeight.Diff = fRet;
874 rVal <<= aFontHeight;
876 break;
877 case MID_FONTHEIGHT:
879 // Point (i.e. Twips) is asked for, thus re-calculate if
880 // CONVERT_TWIPS is not set.
881 if( bConvert )
883 long nTwips = bConvert ? nHeight : MM100_TO_TWIP_UNSIGNED(nHeight);
884 rVal <<= (float)( nTwips / 20.0 );
886 else
888 double fPoints = MM100_TO_TWIP_UNSIGNED(nHeight) / 20.0;
889 float fRoundPoints =
890 static_cast<float>(::rtl::math::round(fPoints, 1));
891 rVal <<= fRoundPoints;
894 break;
895 case MID_FONTHEIGHT_PROP:
896 rVal <<= (sal_Int16)(SFX_MAPUNIT_RELATIVE == ePropUnit ? nProp : 100);
897 break;
898 case MID_FONTHEIGHT_DIFF:
900 float fRet = (float)(short)nProp;
901 switch( ePropUnit )
903 case SFX_MAPUNIT_RELATIVE:
904 fRet = 0.;
905 break;
906 case SFX_MAPUNIT_100TH_MM:
907 fRet = MM100_TO_TWIP(fRet);
908 fRet /= 20.;
909 break;
910 case SFX_MAPUNIT_POINT:
912 break;
913 case SFX_MAPUNIT_TWIP:
914 fRet /= 20.;
915 break;
916 default: ;//prevent warning
918 rVal <<= fRet;
920 break;
922 return sal_True;
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;
929 short nDiff = 0;
930 switch( eProp )
932 case SFX_MAPUNIT_RELATIVE:
933 nRet *= 100;
934 nRet /= nProp;
935 break;
936 case SFX_MAPUNIT_POINT:
938 short nTemp = (short)nProp;
939 nDiff = nTemp * 20;
940 if(!bCoreInTwip)
941 nDiff = (short)TWIP_TO_MM100((long)(nDiff));
943 break;
944 case SFX_MAPUNIT_100TH_MM:
945 //then the core is surely also in 1/100 mm
946 nDiff = (short)nProp;
947 break;
948 case SFX_MAPUNIT_TWIP:
949 // Here surely TWIP
950 nDiff = ((short)nProp);
951 break;
952 default: ;//prevent warning
954 nRet -= nDiff;
956 return nRet;
959 bool SvxFontHeightItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
961 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
962 nMemberId &= ~CONVERT_TWIPS;
963 switch( nMemberId )
965 case 0:
967 ::com::sun::star::frame::status::FontHeight aFontHeight;
968 if ( rVal >>= aFontHeight )
970 // Height
971 ePropUnit = SFX_MAPUNIT_RELATIVE;
972 nProp = 100;
973 double fPoint = aFontHeight.Height;
974 if( fPoint < 0. || fPoint > 10000. )
975 return sal_False;
977 nHeight = (long)( fPoint * 20.0 + 0.5 ); // Twips
978 if (!bConvert)
979 nHeight = TWIP_TO_MM100_UNSIGNED(nHeight); // Convert, if the item contains 1/100mm
981 nProp = aFontHeight.Prop;
983 else
984 return sal_False;
986 break;
987 case MID_FONTHEIGHT:
989 ePropUnit = SFX_MAPUNIT_RELATIVE;
990 nProp = 100;
991 double fPoint = 0;
992 if(!(rVal >>= fPoint))
994 sal_Int32 nValue = 0;
995 if(!(rVal >>= nValue))
996 return sal_False;
997 fPoint = (float)nValue;
999 if(fPoint < 0. || fPoint > 10000.)
1000 return sal_False;
1002 nHeight = (long)( fPoint * 20.0 + 0.5 ); // Twips
1003 if (!bConvert)
1004 nHeight = TWIP_TO_MM100_UNSIGNED(nHeight); // Convert, if the item contains 1/100mm
1006 break;
1007 case MID_FONTHEIGHT_PROP:
1009 sal_Int16 nNew = sal_Int16();
1010 if(!(rVal >>= nNew))
1011 return sal_True;
1013 nHeight = lcl_GetRealHeight_Impl(nHeight, nProp, ePropUnit, bConvert);
1015 nHeight *= nNew;
1016 nHeight /= 100;
1017 nProp = nNew;
1018 ePropUnit = SFX_MAPUNIT_RELATIVE;
1020 break;
1021 case MID_FONTHEIGHT_DIFF:
1023 nHeight = lcl_GetRealHeight_Impl(nHeight, nProp, ePropUnit, bConvert);
1024 float fValue = 0;
1025 if(!(rVal >>= fValue))
1027 sal_Int32 nValue = 0;
1028 if(!(rVal >>= nValue))
1029 return sal_False;
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;
1037 break;
1039 return sal_True;
1042 //------------------------------------------------------------------------
1044 SfxItemPresentation SvxFontHeightItem::GetPresentation
1046 SfxItemPresentation ePres,
1047 SfxMapUnit eCoreUnit,
1048 SfxMapUnit /*ePresUnit*/,
1049 OUString& rText, const IntlWrapper *pIntl
1050 ) const
1052 switch ( ePres )
1054 case SFX_ITEM_PRESENTATION_NONE:
1055 rText = OUString();
1056 return ePres;
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));
1073 else
1074 rText = OUString::number( nProp ) + "%";
1075 return ePres;
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 );
1096 return true;
1099 // -----------------------------------------------------------------------
1101 bool SvxFontHeightItem::HasMetrics() const
1103 return true;
1106 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight, const sal_uInt16 nNewProp,
1107 SfxMapUnit eUnit )
1109 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
1111 if( SFX_MAPUNIT_RELATIVE != eUnit )
1112 nHeight = nNewHeight + ::ItemToControl( (short)nNewProp, eUnit,
1113 SFX_FUNIT_TWIP );
1114 else if( 100 != nNewProp )
1115 nHeight = sal_uInt32(( nNewHeight * nNewProp ) / 100 );
1116 else
1117 nHeight = nNewHeight;
1119 nProp = nNewProp;
1120 ePropUnit = eUnit;
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,
1132 eCoreMetric );
1133 else if( 100 != nNewProp )
1134 nHeight = sal_uInt32(( nNewHeight * nNewProp ) / 100 );
1135 else
1136 nHeight = nNewHeight;
1138 nProp = nNewProp;
1139 ePropUnit = eMetric;
1142 // class SvxFontWidthItem -----------------------------------------------
1144 SvxFontWidthItem::SvxFontWidthItem( const sal_uInt16 nSz, const sal_uInt16 nPrp, const sal_uInt16 nId ) :
1145 SfxPoolItem( nId )
1147 nWidth = nSz;
1148 nProp = nPrp;
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();
1163 return rStrm;
1166 // -----------------------------------------------------------------------
1168 bool SvxFontWidthItem::ScaleMetrics( long nMult, long nDiv )
1170 nWidth = (sal_uInt16)Scale( nWidth, nMult, nDiv );
1171 return true;
1174 // -----------------------------------------------------------------------
1176 bool SvxFontWidthItem::HasMetrics() const
1178 return true;
1181 // -----------------------------------------------------------------------
1183 SfxPoolItem* SvxFontWidthItem::Create( SvStream& rStrm,
1184 sal_uInt16 /*nVersion*/ ) const
1186 sal_uInt16 nS;
1187 sal_uInt16 nP;
1189 rStrm >> nS;
1190 rStrm >> nP;
1191 SvxFontWidthItem* pItem = new SvxFontWidthItem( 0, nP, Which() );
1192 pItem->SetWidthValue( nS );
1193 return pItem;
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;
1209 switch(nMemberId)
1211 case MID_FONTWIDTH:
1212 rVal <<= (sal_Int16)(nWidth);
1213 break;
1214 case MID_FONTWIDTH_PROP:
1215 rVal <<= (sal_Int16)(nProp);
1216 break;
1218 return true;
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))
1227 return sal_False;
1229 switch(nMemberId)
1231 case MID_FONTWIDTH:
1232 nProp = nVal;
1233 break;
1234 case MID_FONTWIDTH_PROP:
1235 nWidth = nVal;
1236 break;
1238 return true;
1241 //------------------------------------------------------------------------
1243 SfxItemPresentation SvxFontWidthItem::GetPresentation
1245 SfxItemPresentation ePres,
1246 SfxMapUnit eCoreUnit,
1247 SfxMapUnit /*ePresUnit*/,
1248 OUString& rText, const IntlWrapper *pIntl
1249 ) const
1251 switch ( ePres )
1253 case SFX_ITEM_PRESENTATION_NONE:
1254 rText = OUString();
1255 return ePres;
1256 case SFX_ITEM_PRESENTATION_NAMELESS:
1257 case SFX_ITEM_PRESENTATION_COMPLETE:
1259 if ( 100 == nProp )
1261 rText = GetMetricText( (long)nWidth,
1262 eCoreUnit, SFX_MAPUNIT_POINT, pIntl ) +
1263 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
1265 else
1266 rText = OUString::number( nProp ) + "%";
1267 return ePres;
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
1285 return sal_True;
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() );
1308 return pNew;
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();
1323 return rStrm;
1326 // -----------------------------------------------------------------------
1328 SfxPoolItem* SvxTextLineItem::Create(SvStream& rStrm, sal_uInt16) const
1330 sal_uInt8 nState;
1331 rStrm >> nState;
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*/
1343 ) const
1345 switch ( ePres )
1347 case SFX_ITEM_PRESENTATION_NONE:
1348 rText = OUString();
1349 return ePres;
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 );
1355 return ePres;
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");
1366 return OUString();
1369 bool SvxTextLineItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1371 nMemberId &= ~CONVERT_TWIPS;
1372 switch(nMemberId)
1374 case MID_TEXTLINED:
1375 rVal = Bool2Any(GetBoolValue());
1376 break;
1377 case MID_TL_STYLE:
1378 rVal <<= (sal_Int16)(GetValue());
1379 break;
1380 case MID_TL_COLOR:
1381 rVal <<= (sal_Int32)( mColor.GetColor() );
1382 break;
1383 case MID_TL_HASCOLOR:
1384 rVal = Bool2Any( !mColor.GetTransparency() );
1385 break;
1387 return true;
1391 bool SvxTextLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1393 nMemberId &= ~CONVERT_TWIPS;
1394 sal_Bool bRet = sal_True;
1395 switch(nMemberId)
1397 case MID_TEXTLINED:
1398 SetBoolValue(Any2Bool(rVal));
1399 break;
1400 case MID_TL_STYLE:
1402 sal_Int32 nValue = 0;
1403 if(!(rVal >>= nValue))
1404 bRet = sal_False;
1405 else
1406 SetValue((sal_Int16)nValue);
1408 break;
1409 case MID_TL_COLOR:
1411 sal_Int32 nCol = 0;
1412 if( !( rVal >>= nCol ) )
1413 bRet = sal_False;
1414 else
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 );
1423 break;
1424 case MID_TL_HASCOLOR:
1425 mColor.SetTransparency( Any2Bool( rVal ) ? 0 : 0xff );
1426 break;
1428 return bRet;
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() );
1451 return pNew;
1454 // -----------------------------------------------------------------------
1456 SfxPoolItem* SvxUnderlineItem::Create(SvStream& rStrm, sal_uInt16) const
1458 sal_uInt8 nState;
1459 rStrm >> nState;
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() );
1484 return pNew;
1487 // -----------------------------------------------------------------------
1489 SfxPoolItem* SvxOverlineItem::Create(SvStream& rStrm, sal_uInt16) const
1491 sal_uInt8 nState;
1492 rStrm >> nState;
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
1515 return sal_True;
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();
1551 return rStrm;
1554 // -----------------------------------------------------------------------
1556 SfxPoolItem* SvxCrossedOutItem::Create(SvStream& rStrm, sal_uInt16) const
1558 sal_uInt8 eCross;
1559 rStrm >> eCross;
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*/
1571 ) const
1573 switch ( ePres )
1575 case SFX_ITEM_PRESENTATION_NONE:
1576 rText = OUString();
1577 return ePres;
1578 case SFX_ITEM_PRESENTATION_NAMELESS:
1579 case SFX_ITEM_PRESENTATION_COMPLETE:
1580 rText = GetValueTextByPos( GetValue() );
1581 return ePres;
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;
1598 switch(nMemberId)
1600 case MID_CROSSED_OUT:
1601 rVal = Bool2Any(GetBoolValue());
1602 break;
1603 case MID_CROSS_OUT:
1604 rVal <<= (sal_Int16)(GetValue());
1605 break;
1607 return true;
1610 bool SvxCrossedOutItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1612 nMemberId &= ~CONVERT_TWIPS;
1613 switch(nMemberId)
1615 case MID_CROSSED_OUT:
1616 SetBoolValue(Any2Bool(rVal));
1617 break;
1618 case MID_CROSS_OUT:
1620 sal_Int32 nValue = 0;
1621 if(!(rVal >>= nValue))
1622 return sal_False;
1623 SetValue((sal_Int16)nValue);
1625 break;
1627 return sal_True;
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();
1648 return rStrm;
1651 // -----------------------------------------------------------------------
1653 SfxPoolItem* SvxShadowedItem::Create(SvStream& rStrm, sal_uInt16) const
1655 sal_uInt8 nState;
1656 rStrm >> nState;
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*/
1668 ) const
1670 switch ( ePres )
1672 case SFX_ITEM_PRESENTATION_NONE:
1673 rText = OUString();
1674 return ePres;
1675 case SFX_ITEM_PRESENTATION_NAMELESS:
1676 case SFX_ITEM_PRESENTATION_COMPLETE:
1678 sal_uInt16 nId = RID_SVXITEMS_SHADOWED_FALSE;
1680 if ( GetValue() )
1681 nId = RID_SVXITEMS_SHADOWED_TRUE;
1682 rText = EE_RESSTR(nId);
1683 return ePres;
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();
1709 return rStrm;
1712 // -----------------------------------------------------------------------
1714 SfxPoolItem* SvxAutoKernItem::Create(SvStream& rStrm, sal_uInt16) const
1716 sal_uInt8 nState;
1717 rStrm >> nState;
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*/
1729 ) const
1731 switch ( ePres )
1733 case SFX_ITEM_PRESENTATION_NONE:
1734 rText = OUString();
1735 return ePres;
1736 case SFX_ITEM_PRESENTATION_NAMELESS:
1737 case SFX_ITEM_PRESENTATION_COMPLETE:
1739 sal_uInt16 nId = RID_SVXITEMS_AUTOKERN_FALSE;
1741 if ( GetValue() )
1742 nId = RID_SVXITEMS_AUTOKERN_TRUE;
1743 rText = EE_RESSTR(nId);
1744 return ePres;
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();
1771 return rStrm;
1774 // -----------------------------------------------------------------------
1776 SfxPoolItem* SvxWordLineModeItem::Create(SvStream& rStrm, sal_uInt16) const
1778 sal_Bool bValue;
1779 rStrm >> bValue;
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*/
1791 ) const
1793 switch ( ePres )
1795 case SFX_ITEM_PRESENTATION_NONE:
1796 rText = OUString();
1797 return ePres;
1798 case SFX_ITEM_PRESENTATION_NAMELESS:
1799 case SFX_ITEM_PRESENTATION_COMPLETE:
1801 sal_uInt16 nId = RID_SVXITEMS_WORDLINE_FALSE;
1803 if ( GetValue() )
1804 nId = RID_SVXITEMS_WORDLINE_TRUE;
1805 rText = EE_RESSTR(nId);
1806 return ePres;
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();
1832 return rStrm;
1835 // -----------------------------------------------------------------------
1837 SfxPoolItem* SvxContourItem::Create(SvStream& rStrm, sal_uInt16) const
1839 sal_Bool bValue;
1840 rStrm >> bValue;
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*/
1852 ) const
1854 switch ( ePres )
1856 case SFX_ITEM_PRESENTATION_NONE:
1857 rText = OUString();
1858 return ePres;
1859 case SFX_ITEM_PRESENTATION_NAMELESS:
1860 case SFX_ITEM_PRESENTATION_COMPLETE:
1862 sal_uInt16 nId = RID_SVXITEMS_CONTOUR_FALSE;
1864 if ( GetValue() )
1865 nId = RID_SVXITEMS_CONTOUR_TRUE;
1866 rText = EE_RESSTR(nId);
1867 return ePres;
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();
1893 return rStrm;
1896 // -----------------------------------------------------------------------
1898 SfxPoolItem* SvxPropSizeItem::Create(SvStream& rStrm, sal_uInt16) const
1900 sal_uInt16 nSize;
1901 rStrm >> nSize;
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*/
1913 ) const
1915 rText = OUString();
1916 return SFX_ITEM_PRESENTATION_NONE;
1919 // class SvxColorItem ----------------------------------------------------
1921 SvxColorItem::SvxColorItem( const sal_uInt16 nId ) :
1922 SfxPoolItem( nId ),
1923 mColor( COL_BLACK )
1927 // -----------------------------------------------------------------------
1929 SvxColorItem::SvxColorItem( const Color& rCol, const sal_uInt16 nId ) :
1930 SfxPoolItem( nId ),
1931 mColor( rCol )
1935 // -----------------------------------------------------------------------
1937 SvxColorItem::SvxColorItem( SvStream &rStrm, const sal_uInt16 nId ) :
1938 SfxPoolItem( nId )
1940 Color aColor;
1941 rStrm >> aColor;
1942 mColor = aColor;
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());
1983 return true;
1986 // -----------------------------------------------------------------------
1988 bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
1990 sal_Int32 nColor = 0;
1991 if(!(rVal >>= nColor))
1992 return sal_False;
1994 mColor.SetColor( nColor );
1995 return true;
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 );
2012 else
2013 rStrm << mColor;
2014 return rStrm;
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*/
2032 ) const
2034 switch ( ePres )
2036 case SFX_ITEM_PRESENTATION_NONE:
2037 rText = OUString();
2038 return ePres;
2039 case SFX_ITEM_PRESENTATION_NAMELESS:
2040 case SFX_ITEM_PRESENTATION_COMPLETE:
2041 rText = ::GetColorString( mColor );
2042 return ePres;
2043 default: ; //prevent warning
2045 return SFX_ITEM_PRESENTATION_NONE;
2048 // -----------------------------------------------------------------------
2050 void SvxColorItem::SetValue( const Color& rNewCol )
2052 mColor = 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 ),
2071 eFrom( _eFrom )
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();
2088 return rStrm;
2091 // -----------------------------------------------------------------------
2093 SfxPoolItem* SvxCharSetColorItem::Create(SvStream& rStrm, sal_uInt16) const
2095 sal_uInt8 cSet;
2096 Color aColor;
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*/
2109 ) const
2111 rText = OUString();
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();
2134 return rStrm;
2137 // -----------------------------------------------------------------------
2139 bool SvxKerningItem::ScaleMetrics( long nMult, long nDiv )
2141 SetValue( (sal_Int16)Scale( GetValue(), nMult, nDiv ) );
2142 return true;
2145 // -----------------------------------------------------------------------
2147 bool SvxKerningItem::HasMetrics() const
2149 return true;
2152 // -----------------------------------------------------------------------
2154 SfxPoolItem* SvxKerningItem::Create(SvStream& rStrm, sal_uInt16) const
2156 short nValue;
2157 rStrm >> nValue;
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
2169 ) const
2171 switch ( ePres )
2173 case SFX_ITEM_PRESENTATION_NONE:
2174 rText = OUString();
2175 return ePres;
2176 case SFX_ITEM_PRESENTATION_NAMELESS:
2177 rText = GetMetricText( (long)GetValue(), eCoreUnit, SFX_MAPUNIT_POINT, pIntl ) +
2178 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
2179 return ePres;
2180 case SFX_ITEM_PRESENTATION_COMPLETE:
2182 rText = EE_RESSTR(RID_SVXITEMS_KERNING_COMPLETE);
2183 sal_uInt16 nId = 0;
2185 if ( GetValue() > 0 )
2186 nId = RID_SVXITEMS_KERNING_EXPANDED;
2187 else if ( GetValue() < 0 )
2188 nId = RID_SVXITEMS_KERNING_CONDENSED;
2190 if ( nId )
2191 rText += EE_RESSTR(nId);
2192 rText = rText +
2193 GetMetricText( (long)GetValue(), eCoreUnit, SFX_MAPUNIT_POINT, pIntl ) +
2194 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
2195 return ePres;
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);
2207 rVal <<= nVal;
2208 return true;
2210 // -----------------------------------------------------------------------
2211 bool SvxKerningItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId)
2213 sal_Int16 nVal = sal_Int16();
2214 if(!(rVal >>= nVal))
2215 return false;
2216 if(nMemberId & CONVERT_TWIPS)
2217 nVal = (sal_Int16)MM100_TO_TWIP(nVal);
2218 SetValue(nVal);
2219 return true;
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();
2248 return rStrm;
2251 // -----------------------------------------------------------------------
2253 SfxPoolItem* SvxCaseMapItem::Create(SvStream& rStrm, sal_uInt16) const
2255 sal_uInt8 cMap;
2256 rStrm >> cMap;
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*/
2268 ) const
2270 switch ( ePres )
2272 case SFX_ITEM_PRESENTATION_NONE:
2273 rText = OUString();
2274 return ePres;
2275 case SFX_ITEM_PRESENTATION_NAMELESS:
2276 case SFX_ITEM_PRESENTATION_COMPLETE:
2277 rText = GetValueTextByPos( GetValue() );
2278 return ePres;
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);
2303 return true;
2306 bool SvxCaseMapItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
2308 sal_uInt16 nVal = sal_uInt16();
2309 if(!(rVal >>= nVal))
2310 return sal_False;
2312 switch( 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;
2320 SetValue(nVal);
2321 return true;
2324 // class SvxEscapementItem -----------------------------------------------
2326 SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId ) :
2327 SfxEnumItemInterface( nId ),
2329 nEsc ( 0 ),
2330 nProp ( 100 )
2334 // -----------------------------------------------------------------------
2336 SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape,
2337 const sal_uInt16 nId ) :
2338 SfxEnumItemInterface( nId ),
2339 nProp( 100 )
2341 SetEscapement( eEscape );
2342 if( nEsc )
2343 nProp = 58;
2346 // -----------------------------------------------------------------------
2348 SvxEscapementItem::SvxEscapementItem( const short _nEsc,
2349 const sal_uInt8 _nProp,
2350 const sal_uInt16 nId ) :
2351 SfxEnumItemInterface( nId ),
2352 nEsc ( _nEsc ),
2353 nProp ( _nProp )
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()
2387 << (short) _nEsc;
2388 return rStrm;
2391 // -----------------------------------------------------------------------
2393 SfxPoolItem* SvxEscapementItem::Create(SvStream& rStrm, sal_uInt16) const
2395 sal_uInt8 _nProp;
2396 short _nEsc;
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*/
2416 ) const
2418 switch ( ePres )
2420 case SFX_ITEM_PRESENTATION_NONE:
2421 rText = OUString();
2422 return ePres;
2423 case SFX_ITEM_PRESENTATION_NAMELESS:
2424 case SFX_ITEM_PRESENTATION_COMPLETE:
2426 rText = GetValueTextByPos( GetEnumValue() );
2428 if ( nEsc != 0 )
2430 if( DFLT_ESC_AUTO_SUPER == nEsc || DFLT_ESC_AUTO_SUB == nEsc )
2431 rText += EE_RESSTR(RID_SVXITEMS_ESCAPEMENT_AUTO);
2432 else
2433 rText = rText + OUString::number( nEsc ) + "%";
2435 return ePres;
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
2454 if ( nEsc < 0 )
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;
2471 switch(nMemberId)
2473 case MID_ESC:
2474 rVal <<= (sal_Int16)(nEsc);
2475 break;
2476 case MID_ESC_HEIGHT:
2477 rVal <<= (sal_Int8)(nProp);
2478 break;
2479 case MID_AUTO_ESC:
2480 rVal = Bool2Any(DFLT_ESC_AUTO_SUB == nEsc || DFLT_ESC_AUTO_SUPER == nEsc);
2481 break;
2483 return true;
2486 bool SvxEscapementItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2488 nMemberId &= ~CONVERT_TWIPS;
2489 switch(nMemberId)
2491 case MID_ESC:
2493 sal_Int16 nVal = sal_Int16();
2494 if( (rVal >>= nVal) && (std::abs(nVal) <= 101))
2495 nEsc = nVal;
2496 else
2497 return sal_False;
2499 break;
2500 case MID_ESC_HEIGHT:
2502 sal_Int8 nVal = sal_Int8();
2503 if( (rVal >>= nVal) && (nVal <= 100))
2504 nProp = nVal;
2505 else
2506 return sal_False;
2508 break;
2509 case MID_AUTO_ESC:
2511 sal_Bool bVal = Any2Bool(rVal);
2512 if(bVal)
2514 if(nEsc < 0)
2515 nEsc = DFLT_ESC_AUTO_SUB;
2516 else
2517 nEsc = DFLT_ESC_AUTO_SUPER;
2519 else
2520 if(DFLT_ESC_AUTO_SUPER == nEsc )
2521 --nEsc;
2522 else if(DFLT_ESC_AUTO_SUB == nEsc)
2523 ++nEsc;
2525 break;
2527 return true;
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)?
2546 return 0;
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();
2561 return rStrm;
2564 // -----------------------------------------------------------------------
2566 SfxPoolItem* SvxLanguageItem::Create(SvStream& rStrm, sal_uInt16) const
2568 sal_uInt16 nValue;
2569 rStrm >> nValue;
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*/
2581 ) const
2583 switch ( ePres )
2585 case SFX_ITEM_PRESENTATION_NONE:
2586 rText = OUString();
2587 return ePres;
2588 case SFX_ITEM_PRESENTATION_NAMELESS:
2589 case SFX_ITEM_PRESENTATION_COMPLETE:
2591 SvtLanguageTable aLangTable;
2592 rText = aLangTable.GetString( (LanguageType)GetValue() );
2593 return ePres;
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;
2603 switch(nMemberId)
2605 case MID_LANG_INT: // for basic conversions!
2606 rVal <<= (sal_Int16)(GetValue());
2607 break;
2608 case MID_LANG_LOCALE:
2609 lang::Locale aRet( LanguageTag( GetValue()).getLocale( false));
2610 rVal <<= aRet;
2611 break;
2613 return true;
2616 bool SvxLanguageItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2618 nMemberId &= ~CONVERT_TWIPS;
2619 switch(nMemberId)
2621 case MID_LANG_INT: // for basic conversions!
2623 sal_Int32 nValue = 0;
2624 if(!(rVal >>= nValue))
2625 return false;
2627 SetValue((sal_Int16)nValue);
2629 break;
2630 case MID_LANG_LOCALE:
2632 lang::Locale aLocale;
2633 if(!(rVal >>= aLocale))
2634 return sal_False;
2636 SetValue( LanguageTag( aLocale ).getLanguageType( false));
2638 break;
2640 return true;
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();
2661 return rStrm;
2664 // -----------------------------------------------------------------------
2666 SfxPoolItem* SvxNoLinebreakItem::Create(SvStream& rStrm, sal_uInt16) const
2668 sal_Bool bValue;
2669 rStrm >> bValue;
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*/
2681 ) const
2683 rText = OUString();
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();
2706 return rStrm;
2709 // -----------------------------------------------------------------------
2711 SfxPoolItem* SvxNoHyphenItem::Create( SvStream& rStrm, sal_uInt16 ) const
2713 sal_Bool bValue;
2714 rStrm >> bValue;
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*/
2726 ) const
2728 rText = OUString();
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 ) :
2742 SvxColorItem( 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,
2766 OUString& rText,
2767 const IntlWrapper * pIntlWrapper
2768 ) const
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();
2794 return rStrm;
2797 // -----------------------------------------------------------------------
2799 SfxPoolItem* SvxBlinkItem::Create(SvStream& rStrm, sal_uInt16) const
2801 sal_uInt8 nState;
2802 rStrm >> nState;
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*/
2814 ) const
2816 switch ( ePres )
2818 case SFX_ITEM_PRESENTATION_NONE:
2819 rText = OUString();
2820 return ePres;
2821 case SFX_ITEM_PRESENTATION_NAMELESS:
2822 case SFX_ITEM_PRESENTATION_COMPLETE:
2824 sal_uInt16 nId = RID_SVXITEMS_BLINK_FALSE;
2826 if ( GetValue() )
2827 nId = RID_SVXITEMS_BLINK_TRUE;
2828 rText = EE_RESSTR(nId);
2829 return ePres;
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();
2857 return rStrm;
2860 // -----------------------------------------------------------------------
2862 SfxPoolItem* SvxEmphasisMarkItem::Create( SvStream& rStrm, sal_uInt16 ) const
2864 sal_uInt16 nValue;
2865 rStrm >> nValue;
2866 return new SvxEmphasisMarkItem( (FontEmphasisMark)nValue, Which() );
2869 //------------------------------------------------------------------------
2871 SfxItemPresentation SvxEmphasisMarkItem::GetPresentation
2873 SfxItemPresentation ePres,
2874 SfxMapUnit /*eCoreUnit*/,
2875 SfxMapUnit /*ePresUnit*/,
2876 OUString& rText,
2877 const IntlWrapper * /*pIntl*/
2878 ) const
2880 switch ( ePres )
2882 case SFX_ITEM_PRESENTATION_NONE:
2883 rText = OUString();
2884 return ePres;
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
2895 : 0;
2896 if( nId )
2897 rText += EE_RESSTR( nId );
2898 return ePres;
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;
2910 switch( nMemberId )
2912 case MID_EMPHASIS:
2914 sal_Int16 nValue = GetValue();
2915 sal_Int16 nRet = 0;
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)
2925 nRet += 10;
2926 rVal <<= nRet;
2928 break;
2930 return true;
2933 bool SvxEmphasisMarkItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2935 nMemberId &= ~CONVERT_TWIPS;
2936 sal_Bool bRet = true;
2937 switch( nMemberId )
2939 case MID_EMPHASIS:
2941 sal_Int32 nValue = -1;
2942 rVal >>= nValue;
2943 switch(nValue)
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 );
2958 break;
2960 return bRet;
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 ),
2989 bOn( rAttr.bOn )
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;
3015 switch( nMemberId )
3017 case MID_TWOLINES:
3018 rVal = Bool2Any( bOn );
3019 break;
3020 case MID_START_BRACKET:
3022 OUString s;
3023 if( cStartBracket )
3024 s = OUString( cStartBracket );
3025 rVal <<= s;
3027 break;
3028 case MID_END_BRACKET:
3030 OUString s;
3031 if( cEndBracket )
3032 s = OUString( cEndBracket );
3033 rVal <<= s;
3035 break;
3036 default:
3037 bRet = false;
3038 break;
3040 return bRet;
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;
3048 OUString s;
3049 switch( nMemberId )
3051 case MID_TWOLINES:
3052 bOn = Any2Bool( rVal );
3053 bRet = sal_True;
3054 break;
3055 case MID_START_BRACKET:
3056 if( rVal >>= s )
3058 cStartBracket = s.isEmpty() ? 0 : s[ 0 ];
3059 bRet = sal_True;
3061 break;
3062 case MID_END_BRACKET:
3063 if( rVal >>= s )
3065 cEndBracket = s.isEmpty() ? 0 : s[ 0 ];
3066 bRet = sal_True;
3068 break;
3070 return bRet;
3073 SfxItemPresentation SvxTwoLinesItem::GetPresentation( SfxItemPresentation ePres,
3074 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
3075 OUString &rText, const IntlWrapper* /*pIntl*/ ) const
3077 switch( ePres )
3079 case SFX_ITEM_PRESENTATION_NONE:
3080 rText = OUString();
3081 break;
3082 case SFX_ITEM_PRESENTATION_NAMELESS:
3083 case SFX_ITEM_PRESENTATION_COMPLETE:
3085 if( !GetValue() )
3086 rText = EE_RESSTR( RID_SVXITEMS_TWOLINES_OFF );
3087 else
3089 rText = EE_RESSTR( RID_SVXITEMS_TWOLINES );
3090 if( GetStartBracket() )
3091 rText = OUString(GetStartBracket()) + rText;
3092 if( GetEndBracket() )
3093 rText += OUString(GetEndBracket());
3095 return ePres;
3097 default: ; //prevent warning
3099 return SFX_ITEM_PRESENTATION_NONE;
3103 SfxPoolItem* SvxTwoLinesItem::Create( SvStream & rStrm, sal_uInt16 /*nVer*/) const
3105 sal_Bool _bOn;
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();
3114 return rStrm;
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
3146 sal_uInt16 nVal;
3147 sal_Bool b;
3148 rStrm >> nVal >> b;
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;
3156 return rStrm;
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
3169 switch( ePres )
3171 case SFX_ITEM_PRESENTATION_NONE:
3172 rText = OUString();
3173 break;
3174 case SFX_ITEM_PRESENTATION_NAMELESS:
3175 case SFX_ITEM_PRESENTATION_COMPLETE:
3177 if( !GetValue() )
3178 rText = EE_RESSTR( RID_SVXITEMS_CHARROTATE_OFF );
3179 else
3181 rText = EE_RESSTR( RID_SVXITEMS_CHARROTATE );
3182 rText = rText.replaceFirst( "$(ARG1)",
3183 OUString::number( GetValue() / 10 ));
3184 if( IsFitToLine() )
3185 rText += EE_RESSTR( RID_SVXITEMS_CHARROTATE_FITLINE );
3187 return ePres;
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;
3198 bool bRet = true;
3199 switch( nMemberId )
3201 case MID_ROTATE:
3202 rVal <<= (sal_Int16)GetValue();
3203 break;
3204 case MID_FITTOLINE:
3205 rVal = Bool2Any( IsFitToLine() );
3206 break;
3207 default:
3208 bRet = false;
3209 break;
3211 return bRet;
3214 bool SvxCharRotateItem::PutValue( const com::sun::star::uno::Any& rVal,
3215 sal_uInt8 nMemberId )
3217 nMemberId &= ~CONVERT_TWIPS;
3218 bool bRet = true;
3219 switch( nMemberId )
3221 case MID_ROTATE:
3223 sal_Int16 nVal = 0;
3224 if((rVal >>= nVal) && (0 == nVal || 900 == nVal || 2700 == nVal))
3225 SetValue( (sal_uInt16)nVal );
3226 else
3227 bRet = sal_False;
3228 break;
3231 case MID_FITTOLINE:
3232 SetFitToLine( Any2Bool( rVal ) );
3233 break;
3234 default:
3235 bRet = false;
3237 return bRet;
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
3265 sal_uInt16 nVal;
3266 rStrm >> nVal;
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...
3274 rStrm >> nVal;
3275 sal_uInt16 nTest;
3276 rStrm >> nTest;
3277 if ( nTest == 0x1234 )
3278 pItem->SetValue( nVal );
3279 else
3280 rStrm.SeekRel( -2*(long)sizeof(sal_uInt16) );
3283 return pItem;
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;
3294 rRet << GetValue();
3295 // Really ugly, but not a problem for reading the doc in 5.2
3296 rRet << (sal_uInt16)0x1234;
3298 return rRet;
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
3312 switch( ePres )
3314 case SFX_ITEM_PRESENTATION_NONE:
3315 rText = OUString();
3316 break;
3317 case SFX_ITEM_PRESENTATION_NAMELESS:
3318 case SFX_ITEM_PRESENTATION_COMPLETE:
3320 if( !GetValue() )
3321 rText = EE_RESSTR( RID_SVXITEMS_CHARSCALE_OFF );
3322 else
3324 rText = EE_RESSTR( RID_SVXITEMS_CHARSCALE );
3325 rText = rText.replaceFirst( "$(ARG1)",
3326 OUString::number( GetValue() ));
3328 return ePres;
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 );
3343 return true;
3346 OSL_TRACE( "SvxCharScaleWidthItem::PutValue - Wrong type!" );
3347 return false;
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();
3355 return true;
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
3375 sal_uInt16 nVal;
3376 rStrm >> nVal;
3377 return new SvxCharReliefItem( (FontRelief)nVal, Which() );
3380 SvStream& SvxCharReliefItem::Store(SvStream & rStrm, sal_uInt16 /*nIVer*/) const
3382 sal_uInt16 nVal = GetValue();
3383 rStrm << nVal;
3384 return rStrm;
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,
3395 "enum overflow" );
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*/
3410 ) const
3412 SfxItemPresentation eRet = ePres;
3413 switch( ePres )
3415 case SFX_ITEM_PRESENTATION_NONE:
3416 rText = OUString();
3417 break;
3419 case SFX_ITEM_PRESENTATION_NAMELESS:
3420 case SFX_ITEM_PRESENTATION_COMPLETE:
3421 rText = GetValueTextByPos( GetValue() );
3422 break;
3424 default:
3425 eRet = SFX_ITEM_PRESENTATION_NONE;
3427 return eRet;
3430 bool SvxCharReliefItem::PutValue( const com::sun::star::uno::Any& rVal,
3431 sal_uInt8 nMemberId )
3433 nMemberId &= ~CONVERT_TWIPS;
3434 bool bRet = true;
3435 switch( nMemberId )
3437 case MID_RELIEF:
3439 sal_Int16 nVal = -1;
3440 rVal >>= nVal;
3441 if(nVal >= 0 && nVal <= RELIEF_ENGRAVED)
3442 SetValue( (sal_uInt16)nVal );
3443 else
3444 bRet = false;
3446 break;
3447 default:
3448 bRet = false;
3449 break;
3451 return bRet;
3454 bool SvxCharReliefItem::QueryValue( com::sun::star::uno::Any& rVal,
3455 sal_uInt8 nMemberId ) const
3457 nMemberId &= ~CONVERT_TWIPS;
3458 bool bRet = true;
3459 switch( nMemberId )
3461 case MID_RELIEF:
3462 rVal <<= (sal_Int16)GetValue();
3463 break;
3464 default:
3465 bRet = false;
3466 break;
3468 return bRet;
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 );
3504 return p;
3507 SfxPoolItem* SvxScriptSetItem::Create( SvStream &, sal_uInt16 ) const
3509 return 0;
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;
3519 return pI;
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;
3528 switch( nScript )
3530 default: //no one valid -> match to latin
3531 // case SCRIPTTYPE_LATIN:
3532 pRet = GetItemOfScriptSet( rSet, nLatin );
3533 break;
3534 case SCRIPTTYPE_ASIAN:
3535 pRet = GetItemOfScriptSet( rSet, nAsian );
3536 break;
3537 case SCRIPTTYPE_COMPLEX:
3538 pRet = GetItemOfScriptSet( rSet, nComplex );
3539 break;
3541 case SCRIPTTYPE_LATIN|SCRIPTTYPE_ASIAN:
3542 if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
3543 0 == (pAsn = GetItemOfScriptSet( rSet, nAsian )) ||
3544 *pRet != *pAsn )
3545 pRet = 0;
3546 break;
3548 case SCRIPTTYPE_LATIN|SCRIPTTYPE_COMPLEX:
3549 if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
3550 0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
3551 *pRet != *pCmplx )
3552 pRet = 0;
3553 break;
3555 case SCRIPTTYPE_ASIAN|SCRIPTTYPE_COMPLEX:
3556 if( 0 == (pRet = GetItemOfScriptSet( rSet, nAsian )) ||
3557 0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
3558 *pRet != *pCmplx )
3559 pRet = 0;
3560 break;
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 )
3567 pRet = 0;
3568 break;
3570 return pRet;
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 );
3600 delete 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 )
3621 switch( nSlotId )
3623 default:
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;
3631 break;
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;
3636 break;
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;
3641 break;
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;
3646 break;
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;
3651 break;
3652 case SID_ATTR_CHAR_SHADOWED:
3653 rLatin = SID_ATTR_CHAR_SHADOWED;
3654 rAsian = SID_ATTR_CHAR_SHADOWED;
3655 rComplex = SID_ATTR_CHAR_SHADOWED;
3656 break;
3657 case SID_ATTR_CHAR_STRIKEOUT:
3658 rLatin = SID_ATTR_CHAR_STRIKEOUT;
3659 rAsian = SID_ATTR_CHAR_STRIKEOUT;
3660 rComplex = SID_ATTR_CHAR_STRIKEOUT;
3661 break;
3665 void GetDefaultFonts( SvxFontItem& rLatin, SvxFontItem& rAsian, SvxFontItem& rComplex )
3667 const sal_uInt16 nItemCnt = 3;
3669 static struct
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;
3711 return 0;
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;
3722 return 0;
3725 bool SvxRsidItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const
3727 rVal <<= ( (sal_uInt32)GetValue() );
3728 return true;
3731 bool SvxRsidItem::PutValue( const uno::Any& rVal, sal_uInt8 )
3733 sal_uInt32 nRsid = 0;
3734 if( !( rVal >>= nRsid ) )
3735 return false;
3737 SetValue( nRsid );
3738 return true;
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: */