Bump version to 4.1-6
[LibreOffice.git] / editeng / source / items / textitem.cxx
blobf9f342e4457531459f94767a72c2a147af2c4e4b
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 = IsStarSymbol( GetFamilyName() );
378 rStrm << (sal_uInt8) GetFamily() << (sal_uInt8) GetPitch()
379 << (sal_uInt8)(bToBats ? RTL_TEXTENCODING_SYMBOL : GetSOStoreTextEncoding(GetCharSet()));
381 String aStoreFamilyName( GetFamilyName() );
382 if( bToBats )
383 aStoreFamilyName = String( "StarBats", sizeof("StarBats")-1, RTL_TEXTENCODING_ASCII_US );
384 rStrm.WriteUniOrByteString(aStoreFamilyName, rStrm.GetStreamCharSet());
385 rStrm.WriteUniOrByteString(GetStyleName(), rStrm.GetStreamCharSet());
387 // cach for EditEngine, only set while creating clipboard stream.
388 if ( bEnableStoreUnicodeNames )
390 sal_uInt32 nMagic = STORE_UNICODE_MAGIC_MARKER;
391 rStrm << nMagic;
392 rStrm.WriteUniOrByteString( aStoreFamilyName, RTL_TEXTENCODING_UNICODE );
393 rStrm.WriteUniOrByteString( GetStyleName(), RTL_TEXTENCODING_UNICODE );
396 return rStrm;
399 // -----------------------------------------------------------------------
401 SfxPoolItem* SvxFontItem::Create(SvStream& rStrm, sal_uInt16) const
403 sal_uInt8 _eFamily, eFontPitch, eFontTextEncoding;
404 String aName, aStyle;
405 rStrm >> _eFamily;
406 rStrm >> eFontPitch;
407 rStrm >> eFontTextEncoding;
409 // UNICODE: rStrm >> aName;
410 aName = rStrm.ReadUniOrByteString(rStrm.GetStreamCharSet());
412 // UNICODE: rStrm >> aStyle;
413 aStyle = rStrm.ReadUniOrByteString(rStrm.GetStreamCharSet());
415 // Set the "correct" textencoding
416 eFontTextEncoding = (sal_uInt8)GetSOLoadTextEncoding( eFontTextEncoding );
418 // at some point, the StarBats changes from ANSI font to SYMBOL font
419 if ( RTL_TEXTENCODING_SYMBOL != eFontTextEncoding && aName.EqualsAscii("StarBats") )
420 eFontTextEncoding = RTL_TEXTENCODING_SYMBOL;
422 // Check if we have stored unicode
423 sal_Size nStreamPos = rStrm.Tell();
424 sal_uInt32 nMagic = STORE_UNICODE_MAGIC_MARKER;
425 rStrm >> nMagic;
426 if ( nMagic == STORE_UNICODE_MAGIC_MARKER )
428 aName = rStrm.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE );
429 aStyle = rStrm.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE );
431 else
433 rStrm.Seek( nStreamPos );
438 return new SvxFontItem( (FontFamily)_eFamily, aName, aStyle,
439 (FontPitch)eFontPitch, (rtl_TextEncoding)eFontTextEncoding, Which() );
442 //------------------------------------------------------------------------
444 SfxItemPresentation SvxFontItem::GetPresentation
446 SfxItemPresentation ePres,
447 SfxMapUnit /*eCoreUnit*/,
448 SfxMapUnit /*ePresUnit*/,
449 OUString& rText, const IntlWrapper * /*pIntl*/
450 ) const
452 switch ( ePres )
454 case SFX_ITEM_PRESENTATION_NONE:
455 rText = OUString();
456 return ePres;
457 case SFX_ITEM_PRESENTATION_NAMELESS:
458 case SFX_ITEM_PRESENTATION_COMPLETE:
459 rText = aFamilyName;
460 return ePres;
461 default: ; //prevent warning
463 return SFX_ITEM_PRESENTATION_NONE;
466 //------------------------------------------------------------------------
468 void SvxFontItem::EnableStoreUnicodeNames( sal_Bool bEnable )
470 bEnableStoreUnicodeNames = bEnable;
473 // class SvxPostureItem --------------------------------------------------
475 SvxPostureItem::SvxPostureItem( const FontItalic ePosture, const sal_uInt16 nId ) :
476 SfxEnumItem( nId, (sal_uInt16)ePosture )
480 // -----------------------------------------------------------------------
482 SfxPoolItem* SvxPostureItem::Clone( SfxItemPool * ) const
484 return new SvxPostureItem( *this );
487 // -----------------------------------------------------------------------
489 sal_uInt16 SvxPostureItem::GetValueCount() const
491 return ITALIC_NORMAL + 1; // ITALIC_NONE also belongs here
494 // -----------------------------------------------------------------------
496 SvStream& SvxPostureItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
498 rStrm << (sal_uInt8)GetValue();
499 return rStrm;
502 // -----------------------------------------------------------------------
504 SfxPoolItem* SvxPostureItem::Create(SvStream& rStrm, sal_uInt16) const
506 sal_uInt8 nPosture;
507 rStrm >> nPosture;
508 return new SvxPostureItem( (const FontItalic)nPosture, Which() );
511 //------------------------------------------------------------------------
513 SfxItemPresentation SvxPostureItem::GetPresentation
515 SfxItemPresentation ePres,
516 SfxMapUnit /*eCoreUnit*/,
517 SfxMapUnit /*ePresUnit*/,
518 OUString& rText, const IntlWrapper * /*pIntl*/
519 ) const
521 switch ( ePres )
523 case SFX_ITEM_PRESENTATION_NONE:
524 rText = OUString();
525 return ePres;
526 case SFX_ITEM_PRESENTATION_NAMELESS:
527 case SFX_ITEM_PRESENTATION_COMPLETE:
528 rText = GetValueTextByPos( GetValue() );
529 return ePres;
530 default: ;//prevent warning
532 return SFX_ITEM_PRESENTATION_NONE;
535 // -----------------------------------------------------------------------
537 OUString SvxPostureItem::GetValueTextByPos( sal_uInt16 nPos ) const
539 DBG_ASSERT( nPos <= (sal_uInt16)ITALIC_NORMAL, "enum overflow!" );
541 FontItalic eItalic = (FontItalic)nPos;
542 sal_uInt16 nId = 0;
544 switch ( eItalic )
546 case ITALIC_NONE: nId = RID_SVXITEMS_ITALIC_NONE; break;
547 case ITALIC_OBLIQUE: nId = RID_SVXITEMS_ITALIC_OBLIQUE; break;
548 case ITALIC_NORMAL: nId = RID_SVXITEMS_ITALIC_NORMAL; break;
549 default: ;//prevent warning
552 return nId ? EE_RESSTR(nId) : OUString();
555 bool SvxPostureItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
557 nMemberId &= ~CONVERT_TWIPS;
558 switch( nMemberId )
560 case MID_ITALIC:
561 rVal = Bool2Any(GetBoolValue());
562 break;
563 case MID_POSTURE:
564 rVal <<= (awt::FontSlant)GetValue(); // values from awt::FontSlant and FontItalic are equal
565 break;
567 return true;
570 bool SvxPostureItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
572 nMemberId &= ~CONVERT_TWIPS;
573 switch( nMemberId )
575 case MID_ITALIC:
576 SetBoolValue(Any2Bool(rVal));
577 break;
578 case MID_POSTURE:
580 awt::FontSlant eSlant;
581 if(!(rVal >>= eSlant))
583 sal_Int32 nValue = 0;
584 if(!(rVal >>= nValue))
585 return sal_False;
587 eSlant = (awt::FontSlant)nValue;
589 SetValue((sal_uInt16)eSlant);
592 return true;
594 // -----------------------------------------------------------------------
596 int SvxPostureItem::HasBoolValue() const
598 return sal_True;
601 // -----------------------------------------------------------------------
603 sal_Bool SvxPostureItem::GetBoolValue() const
605 return ( (FontItalic)GetValue() >= ITALIC_OBLIQUE );
608 // -----------------------------------------------------------------------
610 void SvxPostureItem::SetBoolValue( sal_Bool bVal )
612 SetValue( (sal_uInt16)(bVal ? ITALIC_NORMAL : ITALIC_NONE) );
615 // class SvxWeightItem ---------------------------------------------------
617 SvxWeightItem::SvxWeightItem( const FontWeight eWght, const sal_uInt16 nId ) :
618 SfxEnumItem( nId, (sal_uInt16)eWght )
624 // -----------------------------------------------------------------------
626 int SvxWeightItem::HasBoolValue() const
628 return sal_True;
631 // -----------------------------------------------------------------------
633 sal_Bool SvxWeightItem::GetBoolValue() const
635 return (FontWeight)GetValue() >= WEIGHT_BOLD;
638 // -----------------------------------------------------------------------
640 void SvxWeightItem::SetBoolValue( sal_Bool bVal )
642 SetValue( (sal_uInt16)(bVal ? WEIGHT_BOLD : WEIGHT_NORMAL) );
645 // -----------------------------------------------------------------------
647 sal_uInt16 SvxWeightItem::GetValueCount() const
649 return WEIGHT_BLACK; // WEIGHT_DONTKNOW does not belong
652 // -----------------------------------------------------------------------
654 SfxPoolItem* SvxWeightItem::Clone( SfxItemPool * ) const
656 return new SvxWeightItem( *this );
659 // -----------------------------------------------------------------------
661 SvStream& SvxWeightItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
663 rStrm << (sal_uInt8)GetValue();
664 return rStrm;
667 // -----------------------------------------------------------------------
669 SfxPoolItem* SvxWeightItem::Create(SvStream& rStrm, sal_uInt16) const
671 sal_uInt8 nWeight;
672 rStrm >> nWeight;
673 return new SvxWeightItem( (FontWeight)nWeight, Which() );
676 //------------------------------------------------------------------------
678 SfxItemPresentation SvxWeightItem::GetPresentation
680 SfxItemPresentation ePres,
681 SfxMapUnit /*eCoreUnit*/,
682 SfxMapUnit /*ePresUnit*/,
683 OUString& rText, const IntlWrapper * /*pIntl*/
684 ) const
686 switch ( ePres )
688 case SFX_ITEM_PRESENTATION_NONE:
689 rText = OUString();
690 return ePres;
691 case SFX_ITEM_PRESENTATION_NAMELESS:
692 case SFX_ITEM_PRESENTATION_COMPLETE:
693 rText = GetValueTextByPos( GetValue() );
694 return ePres;
695 default: ;//prevent warning
697 return SFX_ITEM_PRESENTATION_NONE;
700 // -----------------------------------------------------------------------
702 OUString SvxWeightItem::GetValueTextByPos( sal_uInt16 nPos ) const
704 DBG_ASSERT( nPos <= (sal_uInt16)WEIGHT_BLACK, "enum overflow!" );
705 return EE_RESSTR(RID_SVXITEMS_WEIGHT_BEGIN + nPos);
708 bool SvxWeightItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
710 nMemberId &= ~CONVERT_TWIPS;
711 switch( nMemberId )
713 case MID_BOLD :
714 rVal = Bool2Any(GetBoolValue());
715 break;
716 case MID_WEIGHT:
718 rVal <<= (float)( VCLUnoHelper::ConvertFontWeight( (FontWeight)GetValue() ) );
720 break;
722 return true;
725 bool SvxWeightItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
727 nMemberId &= ~CONVERT_TWIPS;
728 switch( nMemberId )
730 case MID_BOLD :
731 SetBoolValue(Any2Bool(rVal));
732 break;
733 case MID_WEIGHT:
735 double fValue = 0;
736 if(!(rVal >>= fValue))
738 sal_Int32 nValue = 0;
739 if(!(rVal >>= nValue))
740 return sal_False;
741 fValue = (float)nValue;
743 SetValue( (sal_uInt16)VCLUnoHelper::ConvertFontWeight((float)fValue) );
745 break;
747 return true;
750 // class SvxFontHeightItem -----------------------------------------------
752 SvxFontHeightItem::SvxFontHeightItem( const sal_uLong nSz,
753 const sal_uInt16 nPrp,
754 const sal_uInt16 nId ) :
755 SfxPoolItem( nId )
757 SetHeight( nSz,nPrp ); // calculate in percentage
760 // -----------------------------------------------------------------------
762 SfxPoolItem* SvxFontHeightItem::Clone( SfxItemPool * ) const
764 return new SvxFontHeightItem( *this );
767 // -----------------------------------------------------------------------
769 SvStream& SvxFontHeightItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
771 rStrm << (sal_uInt16)GetHeight();
773 if( FONTHEIGHT_UNIT_VERSION <= nItemVersion )
774 rStrm << GetProp() << (sal_uInt16)GetPropUnit();
775 else
777 // When exporting to the old versions the relative information is lost
778 // when there is no percentage
779 sal_uInt16 _nProp = GetProp();
780 if( SFX_MAPUNIT_RELATIVE != GetPropUnit() )
781 _nProp = 100;
782 rStrm << _nProp;
784 return rStrm;
787 // -----------------------------------------------------------------------
789 SfxPoolItem* SvxFontHeightItem::Create( SvStream& rStrm,
790 sal_uInt16 nVersion ) const
792 sal_uInt16 nsize, nprop = 0, nPropUnit = SFX_MAPUNIT_RELATIVE;
794 rStrm >> nsize;
796 if( FONTHEIGHT_16_VERSION <= nVersion )
797 rStrm >> nprop;
798 else
800 sal_uInt8 nP;
801 rStrm >> nP;
802 nprop = (sal_uInt16)nP;
805 if( FONTHEIGHT_UNIT_VERSION <= nVersion )
806 rStrm >> nPropUnit;
808 SvxFontHeightItem* pItem = new SvxFontHeightItem( nsize, 100, Which() );
809 pItem->SetProp( nprop, (SfxMapUnit)nPropUnit );
810 return pItem;
813 // -----------------------------------------------------------------------
815 int SvxFontHeightItem::operator==( const SfxPoolItem& rItem ) const
817 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
818 return GetHeight() == ((SvxFontHeightItem&)rItem).GetHeight() &&
819 GetProp() == ((SvxFontHeightItem&)rItem).GetProp() &&
820 GetPropUnit() == ((SvxFontHeightItem&)rItem).GetPropUnit();
823 bool SvxFontHeightItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
825 // In StarOne is the uno::Any always 1/100mm. Through the MemberId it is
826 // controlled if the value in the Item should be 1/100mm or Twips.
828 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
829 nMemberId &= ~CONVERT_TWIPS;
830 switch( nMemberId )
832 case 0:
834 ::com::sun::star::frame::status::FontHeight aFontHeight;
836 // Point (i.e. Twips) is asked for, thus re-calculate if
837 // CONVERT_TWIPS is not set.
838 if( bConvert )
840 long nTwips = bConvert ? nHeight : MM100_TO_TWIP_UNSIGNED(nHeight);
841 aFontHeight.Height = (float)( nTwips / 20.0 );
843 else
845 double fPoints = MM100_TO_TWIP_UNSIGNED(nHeight) / 20.0;
846 float fRoundPoints =
847 static_cast<float>(::rtl::math::round(fPoints, 1));
848 aFontHeight.Height = fRoundPoints;
851 aFontHeight.Prop = (sal_Int16)(SFX_MAPUNIT_RELATIVE == ePropUnit ? nProp : 100);
853 float fRet = (float)(short)nProp;
854 switch( ePropUnit )
856 case SFX_MAPUNIT_RELATIVE:
857 fRet = 0.;
858 break;
859 case SFX_MAPUNIT_100TH_MM:
860 fRet = MM100_TO_TWIP(fRet);
861 fRet /= 20.;
862 break;
863 case SFX_MAPUNIT_POINT:
865 break;
866 case SFX_MAPUNIT_TWIP:
867 fRet /= 20.;
868 break;
869 default: ;//prevent warning
871 aFontHeight.Diff = fRet;
872 rVal <<= aFontHeight;
874 break;
875 case MID_FONTHEIGHT:
877 // Point (i.e. Twips) is asked for, thus re-calculate if
878 // CONVERT_TWIPS is not set.
879 if( bConvert )
881 long nTwips = bConvert ? nHeight : MM100_TO_TWIP_UNSIGNED(nHeight);
882 rVal <<= (float)( nTwips / 20.0 );
884 else
886 double fPoints = MM100_TO_TWIP_UNSIGNED(nHeight) / 20.0;
887 float fRoundPoints =
888 static_cast<float>(::rtl::math::round(fPoints, 1));
889 rVal <<= fRoundPoints;
892 break;
893 case MID_FONTHEIGHT_PROP:
894 rVal <<= (sal_Int16)(SFX_MAPUNIT_RELATIVE == ePropUnit ? nProp : 100);
895 break;
896 case MID_FONTHEIGHT_DIFF:
898 float fRet = (float)(short)nProp;
899 switch( ePropUnit )
901 case SFX_MAPUNIT_RELATIVE:
902 fRet = 0.;
903 break;
904 case SFX_MAPUNIT_100TH_MM:
905 fRet = MM100_TO_TWIP(fRet);
906 fRet /= 20.;
907 break;
908 case SFX_MAPUNIT_POINT:
910 break;
911 case SFX_MAPUNIT_TWIP:
912 fRet /= 20.;
913 break;
914 default: ;//prevent warning
916 rVal <<= fRet;
918 break;
920 return sal_True;
923 // Calculate the relative deviation from the expected height.
924 static sal_uInt32 lcl_GetRealHeight_Impl(sal_uInt32 nHeight, sal_uInt16 nProp, SfxMapUnit eProp, sal_Bool bCoreInTwip)
926 sal_uInt32 nRet = nHeight;
927 short nDiff = 0;
928 switch( eProp )
930 case SFX_MAPUNIT_RELATIVE:
931 nRet *= 100;
932 nRet /= nProp;
933 break;
934 case SFX_MAPUNIT_POINT:
936 short nTemp = (short)nProp;
937 nDiff = nTemp * 20;
938 if(!bCoreInTwip)
939 nDiff = (short)TWIP_TO_MM100((long)(nDiff));
941 break;
942 case SFX_MAPUNIT_100TH_MM:
943 //then the core is surely also in 1/100 mm
944 nDiff = (short)nProp;
945 break;
946 case SFX_MAPUNIT_TWIP:
947 // Here surely TWIP
948 nDiff = ((short)nProp);
949 break;
950 default: ;//prevent warning
952 nRet -= nDiff;
954 return nRet;
957 bool SvxFontHeightItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
959 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
960 nMemberId &= ~CONVERT_TWIPS;
961 switch( nMemberId )
963 case 0:
965 ::com::sun::star::frame::status::FontHeight aFontHeight;
966 if ( rVal >>= aFontHeight )
968 // Height
969 ePropUnit = SFX_MAPUNIT_RELATIVE;
970 nProp = 100;
971 double fPoint = aFontHeight.Height;
972 if( fPoint < 0. || fPoint > 10000. )
973 return sal_False;
975 nHeight = (long)( fPoint * 20.0 + 0.5 ); // Twips
976 if (!bConvert)
977 nHeight = TWIP_TO_MM100_UNSIGNED(nHeight); // Convert, if the item contains 1/100mm
979 nProp = aFontHeight.Prop;
981 else
982 return sal_False;
984 break;
985 case MID_FONTHEIGHT:
987 ePropUnit = SFX_MAPUNIT_RELATIVE;
988 nProp = 100;
989 double fPoint = 0;
990 if(!(rVal >>= fPoint))
992 sal_Int32 nValue = 0;
993 if(!(rVal >>= nValue))
994 return sal_False;
995 fPoint = (float)nValue;
997 if(fPoint < 0. || fPoint > 10000.)
998 return sal_False;
1000 nHeight = (long)( fPoint * 20.0 + 0.5 ); // Twips
1001 if (!bConvert)
1002 nHeight = TWIP_TO_MM100_UNSIGNED(nHeight); // Convert, if the item contains 1/100mm
1004 break;
1005 case MID_FONTHEIGHT_PROP:
1007 sal_Int16 nNew = sal_Int16();
1008 if(!(rVal >>= nNew))
1009 return sal_True;
1011 nHeight = lcl_GetRealHeight_Impl(nHeight, nProp, ePropUnit, bConvert);
1013 nHeight *= nNew;
1014 nHeight /= 100;
1015 nProp = nNew;
1016 ePropUnit = SFX_MAPUNIT_RELATIVE;
1018 break;
1019 case MID_FONTHEIGHT_DIFF:
1021 nHeight = lcl_GetRealHeight_Impl(nHeight, nProp, ePropUnit, bConvert);
1022 float fValue = 0;
1023 if(!(rVal >>= fValue))
1025 sal_Int32 nValue = 0;
1026 if(!(rVal >>= nValue))
1027 return sal_False;
1028 fValue = (float)nValue;
1030 sal_Int16 nCoreDiffValue = (sal_Int16)(fValue * 20.);
1031 nHeight += bConvert ? nCoreDiffValue : TWIP_TO_MM100(nCoreDiffValue);
1032 nProp = (sal_uInt16)((sal_Int16)fValue);
1033 ePropUnit = SFX_MAPUNIT_POINT;
1035 break;
1037 return sal_True;
1040 //------------------------------------------------------------------------
1042 SfxItemPresentation SvxFontHeightItem::GetPresentation
1044 SfxItemPresentation ePres,
1045 SfxMapUnit eCoreUnit,
1046 SfxMapUnit /*ePresUnit*/,
1047 OUString& rText, const IntlWrapper *pIntl
1048 ) const
1050 switch ( ePres )
1052 case SFX_ITEM_PRESENTATION_NONE:
1053 rText = OUString();
1054 return ePres;
1055 case SFX_ITEM_PRESENTATION_NAMELESS:
1056 case SFX_ITEM_PRESENTATION_COMPLETE:
1058 if( SFX_MAPUNIT_RELATIVE != ePropUnit )
1060 rText = OUString::number( (short)nProp ) +
1061 EE_RESSTR( GetMetricId( ePropUnit ) );
1062 if( 0 <= (short)nProp )
1063 rText = "+" + rText;
1065 else if( 100 == nProp )
1067 rText = GetMetricText( (long)nHeight,
1068 eCoreUnit, SFX_MAPUNIT_POINT, pIntl ) +
1069 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
1071 else
1072 rText = OUString::number( nProp ) + "%";
1073 return ePres;
1075 default: ; //prevent warning
1077 return SFX_ITEM_PRESENTATION_NONE;
1080 // -----------------------------------------------------------------------
1082 sal_uInt16 SvxFontHeightItem::GetVersion(sal_uInt16 nFileVersion) const
1084 return (nFileVersion <= SOFFICE_FILEFORMAT_40)
1085 ? FONTHEIGHT_16_VERSION
1086 : FONTHEIGHT_UNIT_VERSION;
1089 // -----------------------------------------------------------------------
1091 bool SvxFontHeightItem::ScaleMetrics( long nMult, long nDiv )
1093 nHeight = (sal_uInt32)Scale( nHeight, nMult, nDiv );
1094 return true;
1097 // -----------------------------------------------------------------------
1099 bool SvxFontHeightItem::HasMetrics() const
1101 return true;
1104 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight, const sal_uInt16 nNewProp,
1105 SfxMapUnit eUnit )
1107 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
1109 if( SFX_MAPUNIT_RELATIVE != eUnit )
1110 nHeight = nNewHeight + ::ItemToControl( (short)nNewProp, eUnit,
1111 SFX_FUNIT_TWIP );
1112 else if( 100 != nNewProp )
1113 nHeight = sal_uInt32(( nNewHeight * nNewProp ) / 100 );
1114 else
1115 nHeight = nNewHeight;
1117 nProp = nNewProp;
1118 ePropUnit = eUnit;
1121 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight, sal_uInt16 nNewProp,
1122 SfxMapUnit eMetric, SfxMapUnit eCoreMetric )
1124 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
1126 if( SFX_MAPUNIT_RELATIVE != eMetric )
1127 nHeight = nNewHeight +
1128 ::ControlToItem( ::ItemToControl((short)nNewProp, eMetric,
1129 SFX_FUNIT_TWIP ), SFX_FUNIT_TWIP,
1130 eCoreMetric );
1131 else if( 100 != nNewProp )
1132 nHeight = sal_uInt32(( nNewHeight * nNewProp ) / 100 );
1133 else
1134 nHeight = nNewHeight;
1136 nProp = nNewProp;
1137 ePropUnit = eMetric;
1140 // class SvxFontWidthItem -----------------------------------------------
1142 SvxFontWidthItem::SvxFontWidthItem( const sal_uInt16 nSz, const sal_uInt16 nPrp, const sal_uInt16 nId ) :
1143 SfxPoolItem( nId )
1145 nWidth = nSz;
1146 nProp = nPrp;
1149 // -----------------------------------------------------------------------
1151 SfxPoolItem* SvxFontWidthItem::Clone( SfxItemPool * ) const
1153 return new SvxFontWidthItem( *this );
1156 // -----------------------------------------------------------------------
1158 SvStream& SvxFontWidthItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1160 rStrm << GetWidth() << GetProp();
1161 return rStrm;
1164 // -----------------------------------------------------------------------
1166 bool SvxFontWidthItem::ScaleMetrics( long nMult, long nDiv )
1168 nWidth = (sal_uInt16)Scale( nWidth, nMult, nDiv );
1169 return true;
1172 // -----------------------------------------------------------------------
1174 bool SvxFontWidthItem::HasMetrics() const
1176 return true;
1179 // -----------------------------------------------------------------------
1181 SfxPoolItem* SvxFontWidthItem::Create( SvStream& rStrm,
1182 sal_uInt16 /*nVersion*/ ) const
1184 sal_uInt16 nS;
1185 sal_uInt16 nP;
1187 rStrm >> nS;
1188 rStrm >> nP;
1189 SvxFontWidthItem* pItem = new SvxFontWidthItem( 0, nP, Which() );
1190 pItem->SetWidthValue( nS );
1191 return pItem;
1194 // -----------------------------------------------------------------------
1196 int SvxFontWidthItem::operator==( const SfxPoolItem& rItem ) const
1198 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
1199 return GetWidth() == ((SvxFontWidthItem&)rItem).GetWidth() &&
1200 GetProp() == ((SvxFontWidthItem&)rItem).GetProp();
1203 bool SvxFontWidthItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1205 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1206 nMemberId &= ~CONVERT_TWIPS;
1207 switch(nMemberId)
1209 case MID_FONTWIDTH:
1210 rVal <<= (sal_Int16)(nWidth);
1211 break;
1212 case MID_FONTWIDTH_PROP:
1213 rVal <<= (sal_Int16)(nProp);
1214 break;
1216 return true;
1219 bool SvxFontWidthItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1221 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1222 nMemberId &= ~CONVERT_TWIPS;
1223 sal_Int16 nVal = sal_Int16();
1224 if(!(rVal >>= nVal))
1225 return sal_False;
1227 switch(nMemberId)
1229 case MID_FONTWIDTH:
1230 nProp = nVal;
1231 break;
1232 case MID_FONTWIDTH_PROP:
1233 nWidth = nVal;
1234 break;
1236 return true;
1239 //------------------------------------------------------------------------
1241 SfxItemPresentation SvxFontWidthItem::GetPresentation
1243 SfxItemPresentation ePres,
1244 SfxMapUnit eCoreUnit,
1245 SfxMapUnit /*ePresUnit*/,
1246 OUString& rText, const IntlWrapper *pIntl
1247 ) const
1249 switch ( ePres )
1251 case SFX_ITEM_PRESENTATION_NONE:
1252 rText = OUString();
1253 return ePres;
1254 case SFX_ITEM_PRESENTATION_NAMELESS:
1255 case SFX_ITEM_PRESENTATION_COMPLETE:
1257 if ( 100 == nProp )
1259 rText = GetMetricText( (long)nWidth,
1260 eCoreUnit, SFX_MAPUNIT_POINT, pIntl ) +
1261 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
1263 else
1264 rText = OUString::number( nProp ) + "%";
1265 return ePres;
1267 default: ; //prevent warning
1269 return SFX_ITEM_PRESENTATION_NONE;
1272 // class SvxTextLineItem ------------------------------------------------
1274 SvxTextLineItem::SvxTextLineItem( const FontUnderline eSt, const sal_uInt16 nId )
1275 : SfxEnumItem( nId, (sal_uInt16)eSt ), mColor( COL_TRANSPARENT )
1279 // -----------------------------------------------------------------------
1281 int SvxTextLineItem::HasBoolValue() const
1283 return sal_True;
1286 // -----------------------------------------------------------------------
1288 sal_Bool SvxTextLineItem::GetBoolValue() const
1290 return (FontUnderline)GetValue() != UNDERLINE_NONE;
1293 // -----------------------------------------------------------------------
1295 void SvxTextLineItem::SetBoolValue( sal_Bool bVal )
1297 SetValue( (sal_uInt16)(bVal ? UNDERLINE_SINGLE : UNDERLINE_NONE) );
1300 // -----------------------------------------------------------------------
1302 SfxPoolItem* SvxTextLineItem::Clone( SfxItemPool * ) const
1304 SvxTextLineItem* pNew = new SvxTextLineItem( *this );
1305 pNew->SetColor( GetColor() );
1306 return pNew;
1309 // -----------------------------------------------------------------------
1311 sal_uInt16 SvxTextLineItem::GetValueCount() const
1313 return UNDERLINE_DOTTED + 1; // UNDERLINE_NONE also belongs here
1316 // -----------------------------------------------------------------------
1318 SvStream& SvxTextLineItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1320 rStrm << (sal_uInt8)GetValue();
1321 return rStrm;
1324 // -----------------------------------------------------------------------
1326 SfxPoolItem* SvxTextLineItem::Create(SvStream& rStrm, sal_uInt16) const
1328 sal_uInt8 nState;
1329 rStrm >> nState;
1330 return new SvxTextLineItem( (FontUnderline)nState, Which() );
1333 //------------------------------------------------------------------------
1335 SfxItemPresentation SvxTextLineItem::GetPresentation
1337 SfxItemPresentation ePres,
1338 SfxMapUnit /*eCoreUnit*/,
1339 SfxMapUnit /*ePresUnit*/,
1340 OUString& rText, const IntlWrapper * /*pIntl*/
1341 ) const
1343 switch ( ePres )
1345 case SFX_ITEM_PRESENTATION_NONE:
1346 rText = OUString();
1347 return ePres;
1348 case SFX_ITEM_PRESENTATION_NAMELESS:
1349 case SFX_ITEM_PRESENTATION_COMPLETE:
1350 rText = GetValueTextByPos( GetValue() );
1351 if( !mColor.GetTransparency() )
1352 rText = rText + OUString(cpDelim) + ::GetColorString( mColor );
1353 return ePres;
1354 default: ; //prevent warning
1356 return SFX_ITEM_PRESENTATION_NONE;
1359 // -----------------------------------------------------------------------
1361 OUString SvxTextLineItem::GetValueTextByPos( sal_uInt16 /*nPos*/ ) const
1363 OSL_FAIL("SvxTextLineItem::GetValueTextByPos: Pure virtual method");
1364 return OUString();
1367 bool SvxTextLineItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1369 nMemberId &= ~CONVERT_TWIPS;
1370 switch(nMemberId)
1372 case MID_TEXTLINED:
1373 rVal = Bool2Any(GetBoolValue());
1374 break;
1375 case MID_TL_STYLE:
1376 rVal <<= (sal_Int16)(GetValue());
1377 break;
1378 case MID_TL_COLOR:
1379 rVal <<= (sal_Int32)( mColor.GetColor() );
1380 break;
1381 case MID_TL_HASCOLOR:
1382 rVal = Bool2Any( !mColor.GetTransparency() );
1383 break;
1385 return true;
1389 bool SvxTextLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1391 nMemberId &= ~CONVERT_TWIPS;
1392 sal_Bool bRet = sal_True;
1393 switch(nMemberId)
1395 case MID_TEXTLINED:
1396 SetBoolValue(Any2Bool(rVal));
1397 break;
1398 case MID_TL_STYLE:
1400 sal_Int32 nValue = 0;
1401 if(!(rVal >>= nValue))
1402 bRet = sal_False;
1403 else
1404 SetValue((sal_Int16)nValue);
1406 break;
1407 case MID_TL_COLOR:
1409 sal_Int32 nCol = 0;
1410 if( !( rVal >>= nCol ) )
1411 bRet = sal_False;
1412 else
1414 // Keep transparence, because it contains the information
1415 // whether the font color or the stored color should be used
1416 sal_uInt8 nTrans = mColor.GetTransparency();
1417 mColor = Color( nCol );
1418 mColor.SetTransparency( nTrans );
1421 break;
1422 case MID_TL_HASCOLOR:
1423 mColor.SetTransparency( Any2Bool( rVal ) ? 0 : 0xff );
1424 break;
1426 return bRet;
1429 int SvxTextLineItem::operator==( const SfxPoolItem& rItem ) const
1431 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
1432 return SfxEnumItem::operator==( rItem ) &&
1433 GetColor() == ((SvxTextLineItem&)rItem).GetColor();
1436 // class SvxUnderlineItem ------------------------------------------------
1438 SvxUnderlineItem::SvxUnderlineItem( const FontUnderline eSt, const sal_uInt16 nId )
1439 : SvxTextLineItem( eSt, nId )
1443 //------------------------------------------------------------------------
1445 SfxPoolItem* SvxUnderlineItem::Clone( SfxItemPool * ) const
1447 SvxUnderlineItem* pNew = new SvxUnderlineItem( *this );
1448 pNew->SetColor( GetColor() );
1449 return pNew;
1452 // -----------------------------------------------------------------------
1454 SfxPoolItem* SvxUnderlineItem::Create(SvStream& rStrm, sal_uInt16) const
1456 sal_uInt8 nState;
1457 rStrm >> nState;
1458 return new SvxUnderlineItem( (FontUnderline)nState, Which() );
1461 // -----------------------------------------------------------------------
1463 OUString SvxUnderlineItem::GetValueTextByPos( sal_uInt16 nPos ) const
1465 DBG_ASSERT( nPos <= (sal_uInt16)UNDERLINE_BOLDWAVE, "enum overflow!" );
1466 return EE_RESSTR(RID_SVXITEMS_UL_BEGIN + nPos);
1469 // class SvxOverlineItem ------------------------------------------------
1471 SvxOverlineItem::SvxOverlineItem( const FontUnderline eSt, const sal_uInt16 nId )
1472 : SvxTextLineItem( eSt, nId )
1476 //------------------------------------------------------------------------
1478 SfxPoolItem* SvxOverlineItem::Clone( SfxItemPool * ) const
1480 SvxOverlineItem* pNew = new SvxOverlineItem( *this );
1481 pNew->SetColor( GetColor() );
1482 return pNew;
1485 // -----------------------------------------------------------------------
1487 SfxPoolItem* SvxOverlineItem::Create(SvStream& rStrm, sal_uInt16) const
1489 sal_uInt8 nState;
1490 rStrm >> nState;
1491 return new SvxOverlineItem( (FontUnderline)nState, Which() );
1494 // -----------------------------------------------------------------------
1496 OUString SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos ) const
1498 DBG_ASSERT( nPos <= (sal_uInt16)UNDERLINE_BOLDWAVE, "enum overflow!" );
1499 return EE_RESSTR(RID_SVXITEMS_OL_BEGIN + nPos);
1502 // class SvxCrossedOutItem -----------------------------------------------
1504 SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt, const sal_uInt16 nId )
1505 : SfxEnumItem( nId, (sal_uInt16)eSt )
1509 // -----------------------------------------------------------------------
1511 int SvxCrossedOutItem::HasBoolValue() const
1513 return sal_True;
1516 // -----------------------------------------------------------------------
1518 sal_Bool SvxCrossedOutItem::GetBoolValue() const
1520 return (FontStrikeout)GetValue() != STRIKEOUT_NONE;
1523 // -----------------------------------------------------------------------
1525 void SvxCrossedOutItem::SetBoolValue( sal_Bool bVal )
1527 SetValue( (sal_uInt16)(bVal ? STRIKEOUT_SINGLE : STRIKEOUT_NONE) );
1530 // -----------------------------------------------------------------------
1532 sal_uInt16 SvxCrossedOutItem::GetValueCount() const
1534 return STRIKEOUT_DOUBLE + 1; // STRIKEOUT_NONE belongs also here
1537 // -----------------------------------------------------------------------
1539 SfxPoolItem* SvxCrossedOutItem::Clone( SfxItemPool * ) const
1541 return new SvxCrossedOutItem( *this );
1544 // -----------------------------------------------------------------------
1546 SvStream& SvxCrossedOutItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1548 rStrm << (sal_uInt8)GetValue();
1549 return rStrm;
1552 // -----------------------------------------------------------------------
1554 SfxPoolItem* SvxCrossedOutItem::Create(SvStream& rStrm, sal_uInt16) const
1556 sal_uInt8 eCross;
1557 rStrm >> eCross;
1558 return new SvxCrossedOutItem( (FontStrikeout)eCross, Which() );
1561 //------------------------------------------------------------------------
1563 SfxItemPresentation SvxCrossedOutItem::GetPresentation
1565 SfxItemPresentation ePres,
1566 SfxMapUnit /*eCoreUnit*/,
1567 SfxMapUnit /*ePresUnit*/,
1568 OUString& rText, const IntlWrapper * /*pIntl*/
1569 ) const
1571 switch ( ePres )
1573 case SFX_ITEM_PRESENTATION_NONE:
1574 rText = OUString();
1575 return ePres;
1576 case SFX_ITEM_PRESENTATION_NAMELESS:
1577 case SFX_ITEM_PRESENTATION_COMPLETE:
1578 rText = GetValueTextByPos( GetValue() );
1579 return ePres;
1580 default: ;//prevent warning
1582 return SFX_ITEM_PRESENTATION_NONE;
1585 // -----------------------------------------------------------------------
1587 OUString SvxCrossedOutItem::GetValueTextByPos( sal_uInt16 nPos ) const
1589 DBG_ASSERT( nPos <= (sal_uInt16)STRIKEOUT_X, "enum overflow!" );
1590 return EE_RESSTR(RID_SVXITEMS_STRIKEOUT_BEGIN + nPos);
1593 bool SvxCrossedOutItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1595 nMemberId &= ~CONVERT_TWIPS;
1596 switch(nMemberId)
1598 case MID_CROSSED_OUT:
1599 rVal = Bool2Any(GetBoolValue());
1600 break;
1601 case MID_CROSS_OUT:
1602 rVal <<= (sal_Int16)(GetValue());
1603 break;
1605 return true;
1608 bool SvxCrossedOutItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1610 nMemberId &= ~CONVERT_TWIPS;
1611 switch(nMemberId)
1613 case MID_CROSSED_OUT:
1614 SetBoolValue(Any2Bool(rVal));
1615 break;
1616 case MID_CROSS_OUT:
1618 sal_Int32 nValue = 0;
1619 if(!(rVal >>= nValue))
1620 return sal_False;
1621 SetValue((sal_Int16)nValue);
1623 break;
1625 return sal_True;
1627 // class SvxShadowedItem -------------------------------------------------
1629 SvxShadowedItem::SvxShadowedItem( const sal_Bool bShadowed, const sal_uInt16 nId ) :
1630 SfxBoolItem( nId, bShadowed )
1634 // -----------------------------------------------------------------------
1636 SfxPoolItem* SvxShadowedItem::Clone( SfxItemPool * ) const
1638 return new SvxShadowedItem( *this );
1641 // -----------------------------------------------------------------------
1643 SvStream& SvxShadowedItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1645 rStrm << (sal_uInt8) GetValue();
1646 return rStrm;
1649 // -----------------------------------------------------------------------
1651 SfxPoolItem* SvxShadowedItem::Create(SvStream& rStrm, sal_uInt16) const
1653 sal_uInt8 nState;
1654 rStrm >> nState;
1655 return new SvxShadowedItem( nState, Which() );
1658 //------------------------------------------------------------------------
1660 SfxItemPresentation SvxShadowedItem::GetPresentation
1662 SfxItemPresentation ePres,
1663 SfxMapUnit /*eCoreUnit*/,
1664 SfxMapUnit /*ePresUnit*/,
1665 OUString& rText, const IntlWrapper * /*pIntl*/
1666 ) const
1668 switch ( ePres )
1670 case SFX_ITEM_PRESENTATION_NONE:
1671 rText = OUString();
1672 return ePres;
1673 case SFX_ITEM_PRESENTATION_NAMELESS:
1674 case SFX_ITEM_PRESENTATION_COMPLETE:
1676 sal_uInt16 nId = RID_SVXITEMS_SHADOWED_FALSE;
1678 if ( GetValue() )
1679 nId = RID_SVXITEMS_SHADOWED_TRUE;
1680 rText = EE_RESSTR(nId);
1681 return ePres;
1683 default: ; //prevent warning
1685 return SFX_ITEM_PRESENTATION_NONE;
1688 // class SvxAutoKernItem -------------------------------------------------
1690 SvxAutoKernItem::SvxAutoKernItem( const sal_Bool bAutoKern, const sal_uInt16 nId ) :
1691 SfxBoolItem( nId, bAutoKern )
1695 // -----------------------------------------------------------------------
1697 SfxPoolItem* SvxAutoKernItem::Clone( SfxItemPool * ) const
1699 return new SvxAutoKernItem( *this );
1702 // -----------------------------------------------------------------------
1704 SvStream& SvxAutoKernItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1706 rStrm << (sal_uInt8) GetValue();
1707 return rStrm;
1710 // -----------------------------------------------------------------------
1712 SfxPoolItem* SvxAutoKernItem::Create(SvStream& rStrm, sal_uInt16) const
1714 sal_uInt8 nState;
1715 rStrm >> nState;
1716 return new SvxAutoKernItem( nState, Which() );
1719 //------------------------------------------------------------------------
1721 SfxItemPresentation SvxAutoKernItem::GetPresentation
1723 SfxItemPresentation ePres,
1724 SfxMapUnit /*eCoreUnit*/,
1725 SfxMapUnit /*ePresUnit*/,
1726 OUString& rText, const IntlWrapper * /*pIntl*/
1727 ) const
1729 switch ( ePres )
1731 case SFX_ITEM_PRESENTATION_NONE:
1732 rText = OUString();
1733 return ePres;
1734 case SFX_ITEM_PRESENTATION_NAMELESS:
1735 case SFX_ITEM_PRESENTATION_COMPLETE:
1737 sal_uInt16 nId = RID_SVXITEMS_AUTOKERN_FALSE;
1739 if ( GetValue() )
1740 nId = RID_SVXITEMS_AUTOKERN_TRUE;
1741 rText = EE_RESSTR(nId);
1742 return ePres;
1744 default: ; //prevent warning
1746 return SFX_ITEM_PRESENTATION_NONE;
1749 // class SvxWordLineModeItem ---------------------------------------------
1751 SvxWordLineModeItem::SvxWordLineModeItem( const sal_Bool bWordLineMode,
1752 const sal_uInt16 nId ) :
1753 SfxBoolItem( nId, bWordLineMode )
1757 // -----------------------------------------------------------------------
1759 SfxPoolItem* SvxWordLineModeItem::Clone( SfxItemPool * ) const
1761 return new SvxWordLineModeItem( *this );
1764 // -----------------------------------------------------------------------
1766 SvStream& SvxWordLineModeItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1768 rStrm << (sal_Bool) GetValue();
1769 return rStrm;
1772 // -----------------------------------------------------------------------
1774 SfxPoolItem* SvxWordLineModeItem::Create(SvStream& rStrm, sal_uInt16) const
1776 sal_Bool bValue;
1777 rStrm >> bValue;
1778 return new SvxWordLineModeItem( bValue, Which() );
1781 //------------------------------------------------------------------------
1783 SfxItemPresentation SvxWordLineModeItem::GetPresentation
1785 SfxItemPresentation ePres,
1786 SfxMapUnit /*eCoreUnit*/,
1787 SfxMapUnit /*ePresUnit*/,
1788 OUString& rText, const IntlWrapper * /*pIntl*/
1789 ) const
1791 switch ( ePres )
1793 case SFX_ITEM_PRESENTATION_NONE:
1794 rText = OUString();
1795 return ePres;
1796 case SFX_ITEM_PRESENTATION_NAMELESS:
1797 case SFX_ITEM_PRESENTATION_COMPLETE:
1799 sal_uInt16 nId = RID_SVXITEMS_WORDLINE_FALSE;
1801 if ( GetValue() )
1802 nId = RID_SVXITEMS_WORDLINE_TRUE;
1803 rText = EE_RESSTR(nId);
1804 return ePres;
1806 default: ; //prevent warning
1808 return SFX_ITEM_PRESENTATION_NONE;
1811 // class SvxContourItem --------------------------------------------------
1813 SvxContourItem::SvxContourItem( const sal_Bool bContoured, const sal_uInt16 nId ) :
1814 SfxBoolItem( nId, bContoured )
1818 // -----------------------------------------------------------------------
1820 SfxPoolItem* SvxContourItem::Clone( SfxItemPool * ) const
1822 return new SvxContourItem( *this );
1825 // -----------------------------------------------------------------------
1827 SvStream& SvxContourItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1829 rStrm << (sal_Bool) GetValue();
1830 return rStrm;
1833 // -----------------------------------------------------------------------
1835 SfxPoolItem* SvxContourItem::Create(SvStream& rStrm, sal_uInt16) const
1837 sal_Bool bValue;
1838 rStrm >> bValue;
1839 return new SvxContourItem( bValue, Which() );
1842 //------------------------------------------------------------------------
1844 SfxItemPresentation SvxContourItem::GetPresentation
1846 SfxItemPresentation ePres,
1847 SfxMapUnit /*eCoreUnit*/,
1848 SfxMapUnit /*ePresUnit*/,
1849 OUString& rText, const IntlWrapper * /*pIntl*/
1850 ) const
1852 switch ( ePres )
1854 case SFX_ITEM_PRESENTATION_NONE:
1855 rText = OUString();
1856 return ePres;
1857 case SFX_ITEM_PRESENTATION_NAMELESS:
1858 case SFX_ITEM_PRESENTATION_COMPLETE:
1860 sal_uInt16 nId = RID_SVXITEMS_CONTOUR_FALSE;
1862 if ( GetValue() )
1863 nId = RID_SVXITEMS_CONTOUR_TRUE;
1864 rText = EE_RESSTR(nId);
1865 return ePres;
1867 default: ; //prevent warning
1869 return SFX_ITEM_PRESENTATION_NONE;
1872 // class SvxPropSizeItem -------------------------------------------------
1874 SvxPropSizeItem::SvxPropSizeItem( const sal_uInt16 nPercent, const sal_uInt16 nId ) :
1875 SfxUInt16Item( nId, nPercent )
1879 // -----------------------------------------------------------------------
1881 SfxPoolItem* SvxPropSizeItem::Clone( SfxItemPool * ) const
1883 return new SvxPropSizeItem( *this );
1886 // -----------------------------------------------------------------------
1888 SvStream& SvxPropSizeItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1890 rStrm << (sal_uInt16) GetValue();
1891 return rStrm;
1894 // -----------------------------------------------------------------------
1896 SfxPoolItem* SvxPropSizeItem::Create(SvStream& rStrm, sal_uInt16) const
1898 sal_uInt16 nSize;
1899 rStrm >> nSize;
1900 return new SvxPropSizeItem( nSize, Which() );
1903 //------------------------------------------------------------------------
1905 SfxItemPresentation SvxPropSizeItem::GetPresentation
1907 SfxItemPresentation /*ePres*/,
1908 SfxMapUnit /*eCoreUnit*/,
1909 SfxMapUnit /*ePresUnit*/,
1910 OUString& rText, const IntlWrapper * /*pIntl*/
1911 ) const
1913 rText = OUString();
1914 return SFX_ITEM_PRESENTATION_NONE;
1917 // class SvxColorItem ----------------------------------------------------
1919 SvxColorItem::SvxColorItem( const sal_uInt16 nId ) :
1920 SfxPoolItem( nId ),
1921 mColor( COL_BLACK )
1925 // -----------------------------------------------------------------------
1927 SvxColorItem::SvxColorItem( const Color& rCol, const sal_uInt16 nId ) :
1928 SfxPoolItem( nId ),
1929 mColor( rCol )
1933 // -----------------------------------------------------------------------
1935 SvxColorItem::SvxColorItem( SvStream &rStrm, const sal_uInt16 nId ) :
1936 SfxPoolItem( nId )
1938 Color aColor;
1939 rStrm >> aColor;
1940 mColor = aColor;
1943 // -----------------------------------------------------------------------
1945 SvxColorItem::SvxColorItem( const SvxColorItem &rCopy ) :
1946 SfxPoolItem( rCopy ),
1947 mColor( rCopy.mColor )
1951 // -----------------------------------------------------------------------
1953 SvxColorItem::~SvxColorItem()
1957 // -----------------------------------------------------------------------
1958 sal_uInt16 SvxColorItem::GetVersion( sal_uInt16 nFFVer ) const
1960 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
1961 SOFFICE_FILEFORMAT_40==nFFVer ||
1962 SOFFICE_FILEFORMAT_50==nFFVer,
1963 "SvxColorItem: Is there a new file format? ");
1964 return SOFFICE_FILEFORMAT_50 >= nFFVer ? VERSION_USEAUTOCOLOR : 0;
1967 // -----------------------------------------------------------------------
1969 int SvxColorItem::operator==( const SfxPoolItem& rAttr ) const
1971 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
1973 return mColor == ( (const SvxColorItem&)rAttr ).mColor;
1976 // -----------------------------------------------------------------------
1978 bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
1980 rVal <<= (sal_Int32)(mColor.GetColor());
1981 return true;
1984 // -----------------------------------------------------------------------
1986 bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
1988 sal_Int32 nColor = 0;
1989 if(!(rVal >>= nColor))
1990 return sal_False;
1992 mColor.SetColor( nColor );
1993 return true;
1996 // -----------------------------------------------------------------------
1998 SfxPoolItem* SvxColorItem::Clone( SfxItemPool * ) const
2000 return new SvxColorItem( *this );
2003 // -----------------------------------------------------------------------
2005 SvStream& SvxColorItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
2007 if( VERSION_USEAUTOCOLOR == nItemVersion &&
2008 COL_AUTO == mColor.GetColor() )
2009 rStrm << Color( COL_BLACK );
2010 else
2011 rStrm << mColor;
2012 return rStrm;
2015 // -----------------------------------------------------------------------
2017 SfxPoolItem* SvxColorItem::Create(SvStream& rStrm, sal_uInt16 /*nVer*/ ) const
2019 return new SvxColorItem( rStrm, Which() );
2022 //------------------------------------------------------------------------
2024 SfxItemPresentation SvxColorItem::GetPresentation
2026 SfxItemPresentation ePres,
2027 SfxMapUnit /*eCoreUnit*/,
2028 SfxMapUnit /*ePresUnit*/,
2029 OUString& rText, const IntlWrapper * /*pIntl*/
2030 ) const
2032 switch ( ePres )
2034 case SFX_ITEM_PRESENTATION_NONE:
2035 rText = OUString();
2036 return ePres;
2037 case SFX_ITEM_PRESENTATION_NAMELESS:
2038 case SFX_ITEM_PRESENTATION_COMPLETE:
2039 rText = ::GetColorString( mColor );
2040 return ePres;
2041 default: ; //prevent warning
2043 return SFX_ITEM_PRESENTATION_NONE;
2046 // -----------------------------------------------------------------------
2048 void SvxColorItem::SetValue( const Color& rNewCol )
2050 mColor = rNewCol;
2053 // class SvxCharSetColorItem ---------------------------------------------
2055 SvxCharSetColorItem::SvxCharSetColorItem( const sal_uInt16 nId ) :
2056 SvxColorItem( nId ),
2058 eFrom( RTL_TEXTENCODING_DONTKNOW )
2062 // -----------------------------------------------------------------------
2064 SvxCharSetColorItem::SvxCharSetColorItem( const Color& rCol,
2065 const rtl_TextEncoding _eFrom,
2066 const sal_uInt16 nId ) :
2067 SvxColorItem( rCol, nId ),
2069 eFrom( _eFrom )
2074 // -----------------------------------------------------------------------
2076 SfxPoolItem* SvxCharSetColorItem::Clone( SfxItemPool * ) const
2078 return new SvxCharSetColorItem( *this );
2081 // -----------------------------------------------------------------------
2083 SvStream& SvxCharSetColorItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2085 rStrm << (sal_uInt8)GetSOStoreTextEncoding(GetCharSet()) << GetValue();
2086 return rStrm;
2089 // -----------------------------------------------------------------------
2091 SfxPoolItem* SvxCharSetColorItem::Create(SvStream& rStrm, sal_uInt16) const
2093 sal_uInt8 cSet;
2094 Color aColor;
2095 rStrm >> cSet >> aColor;
2096 return new SvxCharSetColorItem( aColor, (rtl_TextEncoding)cSet, Which() );
2099 //------------------------------------------------------------------------
2101 SfxItemPresentation SvxCharSetColorItem::GetPresentation
2103 SfxItemPresentation /*ePres*/,
2104 SfxMapUnit /*eCoreUnit*/,
2105 SfxMapUnit /*ePresUnit*/,
2106 OUString& rText, const IntlWrapper * /*pIntl*/
2107 ) const
2109 rText = OUString();
2110 return SFX_ITEM_PRESENTATION_NONE;
2113 // class SvxKerningItem --------------------------------------------------
2115 SvxKerningItem::SvxKerningItem( const short nKern, const sal_uInt16 nId ) :
2116 SfxInt16Item( nId, nKern )
2120 // -----------------------------------------------------------------------
2122 SfxPoolItem* SvxKerningItem::Clone( SfxItemPool * ) const
2124 return new SvxKerningItem( *this );
2127 // -----------------------------------------------------------------------
2129 SvStream& SvxKerningItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2131 rStrm << (short) GetValue();
2132 return rStrm;
2135 // -----------------------------------------------------------------------
2137 bool SvxKerningItem::ScaleMetrics( long nMult, long nDiv )
2139 SetValue( (sal_Int16)Scale( GetValue(), nMult, nDiv ) );
2140 return true;
2143 // -----------------------------------------------------------------------
2145 bool SvxKerningItem::HasMetrics() const
2147 return true;
2150 // -----------------------------------------------------------------------
2152 SfxPoolItem* SvxKerningItem::Create(SvStream& rStrm, sal_uInt16) const
2154 short nValue;
2155 rStrm >> nValue;
2156 return new SvxKerningItem( nValue, Which() );
2159 //------------------------------------------------------------------------
2161 SfxItemPresentation SvxKerningItem::GetPresentation
2163 SfxItemPresentation ePres,
2164 SfxMapUnit eCoreUnit,
2165 SfxMapUnit /*ePresUnit*/,
2166 OUString& rText, const IntlWrapper *pIntl
2167 ) const
2169 switch ( ePres )
2171 case SFX_ITEM_PRESENTATION_NONE:
2172 rText = OUString();
2173 return ePres;
2174 case SFX_ITEM_PRESENTATION_NAMELESS:
2175 rText = GetMetricText( (long)GetValue(), eCoreUnit, SFX_MAPUNIT_POINT, pIntl ) +
2176 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
2177 return ePres;
2178 case SFX_ITEM_PRESENTATION_COMPLETE:
2180 rText = EE_RESSTR(RID_SVXITEMS_KERNING_COMPLETE);
2181 sal_uInt16 nId = 0;
2183 if ( GetValue() > 0 )
2184 nId = RID_SVXITEMS_KERNING_EXPANDED;
2185 else if ( GetValue() < 0 )
2186 nId = RID_SVXITEMS_KERNING_CONDENSED;
2188 if ( nId )
2189 rText += EE_RESSTR(nId);
2190 rText = rText +
2191 GetMetricText( (long)GetValue(), eCoreUnit, SFX_MAPUNIT_POINT, pIntl ) +
2192 EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
2193 return ePres;
2195 default: ; //prevent warning
2197 return SFX_ITEM_PRESENTATION_NONE;
2200 bool SvxKerningItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2202 sal_Int16 nVal = GetValue();
2203 if(nMemberId & CONVERT_TWIPS)
2204 nVal = (sal_Int16)TWIP_TO_MM100(nVal);
2205 rVal <<= nVal;
2206 return true;
2208 // -----------------------------------------------------------------------
2209 bool SvxKerningItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId)
2211 sal_Int16 nVal = sal_Int16();
2212 if(!(rVal >>= nVal))
2213 return false;
2214 if(nMemberId & CONVERT_TWIPS)
2215 nVal = (sal_Int16)MM100_TO_TWIP(nVal);
2216 SetValue(nVal);
2217 return true;
2220 // class SvxCaseMapItem --------------------------------------------------
2222 SvxCaseMapItem::SvxCaseMapItem( const SvxCaseMap eMap, const sal_uInt16 nId ) :
2223 SfxEnumItem( nId, (sal_uInt16)eMap )
2227 // -----------------------------------------------------------------------
2229 sal_uInt16 SvxCaseMapItem::GetValueCount() const
2231 return SVX_CASEMAP_END; // SVX_CASEMAP_KAPITAELCHEN + 1
2234 // -----------------------------------------------------------------------
2236 SfxPoolItem* SvxCaseMapItem::Clone( SfxItemPool * ) const
2238 return new SvxCaseMapItem( *this );
2241 // -----------------------------------------------------------------------
2243 SvStream& SvxCaseMapItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2245 rStrm << (sal_uInt8) GetValue();
2246 return rStrm;
2249 // -----------------------------------------------------------------------
2251 SfxPoolItem* SvxCaseMapItem::Create(SvStream& rStrm, sal_uInt16) const
2253 sal_uInt8 cMap;
2254 rStrm >> cMap;
2255 return new SvxCaseMapItem( (const SvxCaseMap)cMap, Which() );
2258 //------------------------------------------------------------------------
2260 SfxItemPresentation SvxCaseMapItem::GetPresentation
2262 SfxItemPresentation ePres,
2263 SfxMapUnit /*eCoreUnit*/,
2264 SfxMapUnit /*ePresUnit*/,
2265 OUString& rText, const IntlWrapper * /*pIntl*/
2266 ) const
2268 switch ( ePres )
2270 case SFX_ITEM_PRESENTATION_NONE:
2271 rText = OUString();
2272 return ePres;
2273 case SFX_ITEM_PRESENTATION_NAMELESS:
2274 case SFX_ITEM_PRESENTATION_COMPLETE:
2275 rText = GetValueTextByPos( GetValue() );
2276 return ePres;
2277 default: ; //prevent warning
2279 return SFX_ITEM_PRESENTATION_NONE;
2282 // -----------------------------------------------------------------------
2284 OUString SvxCaseMapItem::GetValueTextByPos( sal_uInt16 nPos ) const
2286 DBG_ASSERT( nPos < (sal_uInt16)SVX_CASEMAP_END, "enum overflow!" );
2287 return EE_RESSTR(RID_SVXITEMS_CASEMAP_BEGIN + nPos);
2290 bool SvxCaseMapItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
2292 sal_Int16 nRet = style::CaseMap::NONE;
2293 switch( GetValue() )
2295 case SVX_CASEMAP_VERSALIEN : nRet = style::CaseMap::UPPERCASE; break;
2296 case SVX_CASEMAP_GEMEINE : nRet = style::CaseMap::LOWERCASE; break;
2297 case SVX_CASEMAP_TITEL : nRet = style::CaseMap::TITLE ; break;
2298 case SVX_CASEMAP_KAPITAELCHEN: nRet = style::CaseMap::SMALLCAPS; break;
2300 rVal <<= (sal_Int16)(nRet);
2301 return true;
2304 bool SvxCaseMapItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
2306 sal_uInt16 nVal = sal_uInt16();
2307 if(!(rVal >>= nVal))
2308 return sal_False;
2310 switch( nVal )
2312 case style::CaseMap::NONE : nVal = SVX_CASEMAP_NOT_MAPPED ; break;
2313 case style::CaseMap::UPPERCASE: nVal = SVX_CASEMAP_VERSALIEN ; break;
2314 case style::CaseMap::LOWERCASE: nVal = SVX_CASEMAP_GEMEINE ; break;
2315 case style::CaseMap::TITLE : nVal = SVX_CASEMAP_TITEL ; break;
2316 case style::CaseMap::SMALLCAPS: nVal = SVX_CASEMAP_KAPITAELCHEN; break;
2318 SetValue(nVal);
2319 return true;
2322 // class SvxEscapementItem -----------------------------------------------
2324 SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId ) :
2325 SfxEnumItemInterface( nId ),
2327 nEsc ( 0 ),
2328 nProp ( 100 )
2332 // -----------------------------------------------------------------------
2334 SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape,
2335 const sal_uInt16 nId ) :
2336 SfxEnumItemInterface( nId ),
2337 nProp( 100 )
2339 SetEscapement( eEscape );
2340 if( nEsc )
2341 nProp = 58;
2344 // -----------------------------------------------------------------------
2346 SvxEscapementItem::SvxEscapementItem( const short _nEsc,
2347 const sal_uInt8 _nProp,
2348 const sal_uInt16 nId ) :
2349 SfxEnumItemInterface( nId ),
2350 nEsc ( _nEsc ),
2351 nProp ( _nProp )
2355 // -----------------------------------------------------------------------
2357 int SvxEscapementItem::operator==( const SfxPoolItem& rAttr ) const
2359 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
2361 return( nEsc == ((SvxEscapementItem&)rAttr).nEsc &&
2362 nProp == ((SvxEscapementItem&)rAttr).nProp );
2365 // -----------------------------------------------------------------------
2367 SfxPoolItem* SvxEscapementItem::Clone( SfxItemPool * ) const
2369 return new SvxEscapementItem( *this );
2372 // -----------------------------------------------------------------------
2374 SvStream& SvxEscapementItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2376 short _nEsc = GetEsc();
2377 if( SOFFICE_FILEFORMAT_31 == rStrm.GetVersion() )
2379 if( DFLT_ESC_AUTO_SUPER == _nEsc )
2380 _nEsc = DFLT_ESC_SUPER;
2381 else if( DFLT_ESC_AUTO_SUB == _nEsc )
2382 _nEsc = DFLT_ESC_SUB;
2384 rStrm << (sal_uInt8) GetProp()
2385 << (short) _nEsc;
2386 return rStrm;
2389 // -----------------------------------------------------------------------
2391 SfxPoolItem* SvxEscapementItem::Create(SvStream& rStrm, sal_uInt16) const
2393 sal_uInt8 _nProp;
2394 short _nEsc;
2395 rStrm >> _nProp >> _nEsc;
2396 return new SvxEscapementItem( _nEsc, _nProp, Which() );
2399 // -----------------------------------------------------------------------
2401 sal_uInt16 SvxEscapementItem::GetValueCount() const
2403 return SVX_ESCAPEMENT_END; // SVX_ESCAPEMENT_SUBSCRIPT + 1
2406 //------------------------------------------------------------------------
2408 SfxItemPresentation SvxEscapementItem::GetPresentation
2410 SfxItemPresentation ePres,
2411 SfxMapUnit /*eCoreUnit*/,
2412 SfxMapUnit /*ePresUnit*/,
2413 OUString& rText, const IntlWrapper * /*pIntl*/
2414 ) const
2416 switch ( ePres )
2418 case SFX_ITEM_PRESENTATION_NONE:
2419 rText = OUString();
2420 return ePres;
2421 case SFX_ITEM_PRESENTATION_NAMELESS:
2422 case SFX_ITEM_PRESENTATION_COMPLETE:
2424 rText = GetValueTextByPos( GetEnumValue() );
2426 if ( nEsc != 0 )
2428 if( DFLT_ESC_AUTO_SUPER == nEsc || DFLT_ESC_AUTO_SUB == nEsc )
2429 rText += EE_RESSTR(RID_SVXITEMS_ESCAPEMENT_AUTO);
2430 else
2431 rText = rText + OUString::number( nEsc ) + "%";
2433 return ePres;
2435 default: ; //prevent warning
2437 return SFX_ITEM_PRESENTATION_NONE;
2440 // -----------------------------------------------------------------------
2442 OUString SvxEscapementItem::GetValueTextByPos( sal_uInt16 nPos ) const
2444 DBG_ASSERT( nPos < (sal_uInt16)SVX_ESCAPEMENT_END, "enum overflow!" );
2445 return EE_RESSTR(RID_SVXITEMS_ESCAPEMENT_BEGIN + nPos);
2448 // -----------------------------------------------------------------------
2450 sal_uInt16 SvxEscapementItem::GetEnumValue() const
2452 if ( nEsc < 0 )
2453 return SVX_ESCAPEMENT_SUBSCRIPT;
2454 else if ( nEsc > 0 )
2455 return SVX_ESCAPEMENT_SUPERSCRIPT;
2456 return SVX_ESCAPEMENT_OFF;
2459 // -----------------------------------------------------------------------
2461 void SvxEscapementItem::SetEnumValue( sal_uInt16 nVal )
2463 SetEscapement( (const SvxEscapement)nVal );
2466 bool SvxEscapementItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2468 nMemberId &= ~CONVERT_TWIPS;
2469 switch(nMemberId)
2471 case MID_ESC:
2472 rVal <<= (sal_Int16)(nEsc);
2473 break;
2474 case MID_ESC_HEIGHT:
2475 rVal <<= (sal_Int8)(nProp);
2476 break;
2477 case MID_AUTO_ESC:
2478 rVal = Bool2Any(DFLT_ESC_AUTO_SUB == nEsc || DFLT_ESC_AUTO_SUPER == nEsc);
2479 break;
2481 return true;
2484 bool SvxEscapementItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2486 nMemberId &= ~CONVERT_TWIPS;
2487 switch(nMemberId)
2489 case MID_ESC:
2491 sal_Int16 nVal = sal_Int16();
2492 if( (rVal >>= nVal) && (std::abs(nVal) <= 101))
2493 nEsc = nVal;
2494 else
2495 return sal_False;
2497 break;
2498 case MID_ESC_HEIGHT:
2500 sal_Int8 nVal = sal_Int8();
2501 if( (rVal >>= nVal) && (nVal <= 100))
2502 nProp = nVal;
2503 else
2504 return sal_False;
2506 break;
2507 case MID_AUTO_ESC:
2509 sal_Bool bVal = Any2Bool(rVal);
2510 if(bVal)
2512 if(nEsc < 0)
2513 nEsc = DFLT_ESC_AUTO_SUB;
2514 else
2515 nEsc = DFLT_ESC_AUTO_SUPER;
2517 else
2518 if(DFLT_ESC_AUTO_SUPER == nEsc )
2519 --nEsc;
2520 else if(DFLT_ESC_AUTO_SUB == nEsc)
2521 ++nEsc;
2523 break;
2525 return true;
2528 // class SvxLanguageItem -------------------------------------------------
2530 SvxLanguageItem::SvxLanguageItem( const LanguageType eLang, const sal_uInt16 nId )
2531 : SfxEnumItem( nId , eLang )
2535 // -----------------------------------------------------------------------
2537 sal_uInt16 SvxLanguageItem::GetValueCount() const
2539 // #i50205# got rid of class International
2540 SAL_WARN( "editeng.items", "SvxLanguageItem::GetValueCount: supposed to return a count of what?");
2541 // FIXME: previously returned LANGUAGE_COUNT from tools/intn.hxx which was wrong anyway.
2542 // Could be SvtLanguageTable::GetEntryCount() (all locales with resource string)?
2543 // Could be LocaleDataWrapper::getInstalledLanguageTypes() (all locales with locale data)?
2544 return 0;
2547 // -----------------------------------------------------------------------
2549 SfxPoolItem* SvxLanguageItem::Clone( SfxItemPool * ) const
2551 return new SvxLanguageItem( *this );
2554 // -----------------------------------------------------------------------
2556 SvStream& SvxLanguageItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2558 rStrm << (sal_uInt16) GetValue();
2559 return rStrm;
2562 // -----------------------------------------------------------------------
2564 SfxPoolItem* SvxLanguageItem::Create(SvStream& rStrm, sal_uInt16) const
2566 sal_uInt16 nValue;
2567 rStrm >> nValue;
2568 return new SvxLanguageItem( (LanguageType)nValue, Which() );
2571 //------------------------------------------------------------------------
2573 SfxItemPresentation SvxLanguageItem::GetPresentation
2575 SfxItemPresentation ePres,
2576 SfxMapUnit /*eCoreUnit*/,
2577 SfxMapUnit /*ePresUnit*/,
2578 OUString& rText, const IntlWrapper * /*pIntl*/
2579 ) const
2581 switch ( ePres )
2583 case SFX_ITEM_PRESENTATION_NONE:
2584 rText = OUString();
2585 return ePres;
2586 case SFX_ITEM_PRESENTATION_NAMELESS:
2587 case SFX_ITEM_PRESENTATION_COMPLETE:
2589 SvtLanguageTable aLangTable;
2590 rText = aLangTable.GetString( (LanguageType)GetValue() );
2591 return ePres;
2593 default: ; //prevent warning
2595 return SFX_ITEM_PRESENTATION_NONE;
2598 bool SvxLanguageItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2600 nMemberId &= ~CONVERT_TWIPS;
2601 switch(nMemberId)
2603 case MID_LANG_INT: // for basic conversions!
2604 rVal <<= (sal_Int16)(GetValue());
2605 break;
2606 case MID_LANG_LOCALE:
2607 lang::Locale aRet( LanguageTag( GetValue()).getLocale( false));
2608 rVal <<= aRet;
2609 break;
2611 return true;
2614 bool SvxLanguageItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2616 nMemberId &= ~CONVERT_TWIPS;
2617 switch(nMemberId)
2619 case MID_LANG_INT: // for basic conversions!
2621 sal_Int32 nValue = 0;
2622 if(!(rVal >>= nValue))
2623 return false;
2625 SetValue((sal_Int16)nValue);
2627 break;
2628 case MID_LANG_LOCALE:
2630 lang::Locale aLocale;
2631 if(!(rVal >>= aLocale))
2632 return sal_False;
2634 SetValue( LanguageTag( aLocale ).getLanguageType( false));
2636 break;
2638 return true;
2641 // class SvxNoLinebreakItem ----------------------------------------------
2642 SvxNoLinebreakItem::SvxNoLinebreakItem( const sal_Bool bBreak, const sal_uInt16 nId ) :
2643 SfxBoolItem( nId, bBreak )
2647 // -----------------------------------------------------------------------
2649 SfxPoolItem* SvxNoLinebreakItem::Clone( SfxItemPool* ) const
2651 return new SvxNoLinebreakItem( *this );
2654 // -----------------------------------------------------------------------
2656 SvStream& SvxNoLinebreakItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2658 rStrm << (sal_Bool)GetValue();
2659 return rStrm;
2662 // -----------------------------------------------------------------------
2664 SfxPoolItem* SvxNoLinebreakItem::Create(SvStream& rStrm, sal_uInt16) const
2666 sal_Bool bValue;
2667 rStrm >> bValue;
2668 return new SvxNoLinebreakItem( bValue, Which() );
2671 //------------------------------------------------------------------------
2673 SfxItemPresentation SvxNoLinebreakItem::GetPresentation
2675 SfxItemPresentation /*ePres*/,
2676 SfxMapUnit /*eCoreUnit*/,
2677 SfxMapUnit /*ePresUnit*/,
2678 OUString& rText, const IntlWrapper * /*pIntl*/
2679 ) const
2681 rText = OUString();
2682 return SFX_ITEM_PRESENTATION_NONE;
2685 // class SvxNoHyphenItem -------------------------------------------------
2687 SvxNoHyphenItem::SvxNoHyphenItem( const sal_Bool bHyphen, const sal_uInt16 nId ) :
2688 SfxBoolItem( nId , bHyphen )
2692 // -----------------------------------------------------------------------
2694 SfxPoolItem* SvxNoHyphenItem::Clone( SfxItemPool* ) const
2696 return new SvxNoHyphenItem( *this );
2699 // -----------------------------------------------------------------------
2701 SvStream& SvxNoHyphenItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2703 rStrm << (sal_Bool) GetValue();
2704 return rStrm;
2707 // -----------------------------------------------------------------------
2709 SfxPoolItem* SvxNoHyphenItem::Create( SvStream& rStrm, sal_uInt16 ) const
2711 sal_Bool bValue;
2712 rStrm >> bValue;
2713 return new SvxNoHyphenItem( bValue, Which() );
2716 //------------------------------------------------------------------------
2718 SfxItemPresentation SvxNoHyphenItem::GetPresentation
2720 SfxItemPresentation /*ePres*/,
2721 SfxMapUnit /*eCoreUnit*/,
2722 SfxMapUnit /*ePresUnit*/,
2723 OUString& rText, const IntlWrapper * /*pIntl*/
2724 ) const
2726 rText = OUString();
2727 return SFX_ITEM_PRESENTATION_NONE;
2731 * Dummy item for ToolBox controls:
2735 // -----------------------------------------------------------------------
2736 // class SvxLineColorItem (== SvxColorItem)
2737 // -----------------------------------------------------------------------
2739 SvxLineColorItem::SvxLineColorItem( const sal_uInt16 nId ) :
2740 SvxColorItem( nId )
2744 // -----------------------------------------------------------------------
2746 SvxLineColorItem::SvxLineColorItem( const SvxLineColorItem &rCopy ) :
2747 SvxColorItem( rCopy )
2751 // -----------------------------------------------------------------------
2753 SvxLineColorItem::~SvxLineColorItem()
2757 //------------------------------------------------------------------------
2759 SfxItemPresentation SvxLineColorItem::GetPresentation
2761 SfxItemPresentation ePres,
2762 SfxMapUnit eCoreUnit,
2763 SfxMapUnit ePresUnit,
2764 OUString& rText,
2765 const IntlWrapper * pIntlWrapper
2766 ) const
2768 return SvxColorItem::GetPresentation( ePres, eCoreUnit, ePresUnit,
2769 rText, pIntlWrapper );
2772 // class SvxBlinkItem -------------------------------------------------
2775 SvxBlinkItem::SvxBlinkItem( const sal_Bool bBlink, const sal_uInt16 nId ) :
2776 SfxBoolItem( nId, bBlink )
2780 // -----------------------------------------------------------------------
2782 SfxPoolItem* SvxBlinkItem::Clone( SfxItemPool * ) const
2784 return new SvxBlinkItem( *this );
2787 // -----------------------------------------------------------------------
2789 SvStream& SvxBlinkItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2791 rStrm << (sal_uInt8) GetValue();
2792 return rStrm;
2795 // -----------------------------------------------------------------------
2797 SfxPoolItem* SvxBlinkItem::Create(SvStream& rStrm, sal_uInt16) const
2799 sal_uInt8 nState;
2800 rStrm >> nState;
2801 return new SvxBlinkItem( nState, Which() );
2804 // -----------------------------------------------------------------------
2806 SfxItemPresentation SvxBlinkItem::GetPresentation
2808 SfxItemPresentation ePres,
2809 SfxMapUnit /*eCoreUnit*/,
2810 SfxMapUnit /*ePresUnit*/,
2811 OUString& rText, const IntlWrapper * /*pIntl*/
2812 ) const
2814 switch ( ePres )
2816 case SFX_ITEM_PRESENTATION_NONE:
2817 rText = OUString();
2818 return ePres;
2819 case SFX_ITEM_PRESENTATION_NAMELESS:
2820 case SFX_ITEM_PRESENTATION_COMPLETE:
2822 sal_uInt16 nId = RID_SVXITEMS_BLINK_FALSE;
2824 if ( GetValue() )
2825 nId = RID_SVXITEMS_BLINK_TRUE;
2826 rText = EE_RESSTR(nId);
2827 return ePres;
2829 default: ; //prevent warning
2831 return SFX_ITEM_PRESENTATION_NONE;
2834 // class SvxEmphaisMarkItem ---------------------------------------------------
2836 SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue,
2837 const sal_uInt16 nId )
2838 : SfxUInt16Item( nId, nValue )
2842 // -----------------------------------------------------------------------
2844 SfxPoolItem* SvxEmphasisMarkItem::Clone( SfxItemPool * ) const
2846 return new SvxEmphasisMarkItem( *this );
2849 // -----------------------------------------------------------------------
2851 SvStream& SvxEmphasisMarkItem::Store( SvStream& rStrm,
2852 sal_uInt16 /*nItemVersion*/ ) const
2854 rStrm << (sal_uInt16)GetValue();
2855 return rStrm;
2858 // -----------------------------------------------------------------------
2860 SfxPoolItem* SvxEmphasisMarkItem::Create( SvStream& rStrm, sal_uInt16 ) const
2862 sal_uInt16 nValue;
2863 rStrm >> nValue;
2864 return new SvxEmphasisMarkItem( (FontEmphasisMark)nValue, Which() );
2867 //------------------------------------------------------------------------
2869 SfxItemPresentation SvxEmphasisMarkItem::GetPresentation
2871 SfxItemPresentation ePres,
2872 SfxMapUnit /*eCoreUnit*/,
2873 SfxMapUnit /*ePresUnit*/,
2874 OUString& rText,
2875 const IntlWrapper * /*pIntl*/
2876 ) const
2878 switch ( ePres )
2880 case SFX_ITEM_PRESENTATION_NONE:
2881 rText = OUString();
2882 return ePres;
2883 case SFX_ITEM_PRESENTATION_NAMELESS:
2884 case SFX_ITEM_PRESENTATION_COMPLETE:
2886 sal_uInt16 nVal = GetValue();
2887 rText = EE_RESSTR( RID_SVXITEMS_EMPHASIS_BEGIN_STYLE +
2888 ( EMPHASISMARK_STYLE & nVal ));
2889 sal_uInt16 nId = ( EMPHASISMARK_POS_ABOVE & nVal )
2890 ? RID_SVXITEMS_EMPHASIS_ABOVE_POS
2891 : ( EMPHASISMARK_POS_BELOW & nVal )
2892 ? RID_SVXITEMS_EMPHASIS_BELOW_POS
2893 : 0;
2894 if( nId )
2895 rText += EE_RESSTR( nId );
2896 return ePres;
2898 default: ; //prevent warning
2900 return SFX_ITEM_PRESENTATION_NONE;
2903 // -----------------------------------------------------------------------
2905 bool SvxEmphasisMarkItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2907 nMemberId &= ~CONVERT_TWIPS;
2908 switch( nMemberId )
2910 case MID_EMPHASIS:
2912 sal_Int16 nValue = GetValue();
2913 sal_Int16 nRet = 0;
2914 switch(nValue & EMPHASISMARK_STYLE)
2916 case EMPHASISMARK_NONE : nRet = FontEmphasis::NONE; break;
2917 case EMPHASISMARK_DOT : nRet = FontEmphasis::DOT_ABOVE; break;
2918 case EMPHASISMARK_CIRCLE : nRet = FontEmphasis::CIRCLE_ABOVE; break;
2919 case EMPHASISMARK_DISC : nRet = FontEmphasis::DISK_ABOVE; break;
2920 case EMPHASISMARK_ACCENT : nRet = FontEmphasis::ACCENT_ABOVE; break;
2922 if(nRet && nValue & EMPHASISMARK_POS_BELOW)
2923 nRet += 10;
2924 rVal <<= nRet;
2926 break;
2928 return true;
2931 bool SvxEmphasisMarkItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2933 nMemberId &= ~CONVERT_TWIPS;
2934 sal_Bool bRet = true;
2935 switch( nMemberId )
2937 case MID_EMPHASIS:
2939 sal_Int32 nValue = -1;
2940 rVal >>= nValue;
2941 switch(nValue)
2943 case FontEmphasis::NONE : nValue = EMPHASISMARK_NONE; break;
2944 case FontEmphasis::DOT_ABOVE : nValue = EMPHASISMARK_DOT|EMPHASISMARK_POS_ABOVE; break;
2945 case FontEmphasis::CIRCLE_ABOVE: nValue = EMPHASISMARK_CIRCLE|EMPHASISMARK_POS_ABOVE; break;
2946 case FontEmphasis::DISK_ABOVE : nValue = EMPHASISMARK_DISC|EMPHASISMARK_POS_ABOVE; break;
2947 case FontEmphasis::ACCENT_ABOVE: nValue = EMPHASISMARK_ACCENT|EMPHASISMARK_POS_ABOVE; break;
2948 case FontEmphasis::DOT_BELOW : nValue = EMPHASISMARK_DOT|EMPHASISMARK_POS_BELOW; break;
2949 case FontEmphasis::CIRCLE_BELOW: nValue = EMPHASISMARK_CIRCLE|EMPHASISMARK_POS_BELOW; break;
2950 case FontEmphasis::DISK_BELOW : nValue = EMPHASISMARK_DISC|EMPHASISMARK_POS_BELOW; break;
2951 case FontEmphasis::ACCENT_BELOW: nValue = EMPHASISMARK_ACCENT|EMPHASISMARK_POS_BELOW; break;
2952 default: return false;
2954 SetValue( (sal_Int16)nValue );
2956 break;
2958 return bRet;
2961 sal_uInt16 SvxEmphasisMarkItem::GetVersion( sal_uInt16 nFFVer ) const
2963 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
2964 SOFFICE_FILEFORMAT_40==nFFVer ||
2965 SOFFICE_FILEFORMAT_50==nFFVer,
2966 "SvxEmphasisMarkItem: Is there a new file format? ");
2968 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
2972 /*************************************************************************
2973 |* class SvxTwoLinesItem
2974 *************************************************************************/
2976 SvxTwoLinesItem::SvxTwoLinesItem( sal_Bool bFlag, sal_Unicode nStartBracket,
2977 sal_Unicode nEndBracket, sal_uInt16 nW )
2978 : SfxPoolItem( nW ),
2979 cStartBracket( nStartBracket ), cEndBracket( nEndBracket ), bOn( bFlag )
2983 SvxTwoLinesItem::SvxTwoLinesItem( const SvxTwoLinesItem& rAttr )
2984 : SfxPoolItem( rAttr.Which() ),
2985 cStartBracket( rAttr.cStartBracket ),
2986 cEndBracket( rAttr.cEndBracket ),
2987 bOn( rAttr.bOn )
2991 SvxTwoLinesItem::~SvxTwoLinesItem()
2995 int SvxTwoLinesItem::operator==( const SfxPoolItem& rAttr ) const
2997 DBG_ASSERT( SfxPoolItem::operator==( rAttr ), "not equal attribute types" );
2998 return bOn == ((SvxTwoLinesItem&)rAttr).bOn &&
2999 cStartBracket == ((SvxTwoLinesItem&)rAttr).cStartBracket &&
3000 cEndBracket == ((SvxTwoLinesItem&)rAttr).cEndBracket;
3003 SfxPoolItem* SvxTwoLinesItem::Clone( SfxItemPool* ) const
3005 return new SvxTwoLinesItem( *this );
3008 bool SvxTwoLinesItem::QueryValue( com::sun::star::uno::Any& rVal,
3009 sal_uInt8 nMemberId ) const
3011 nMemberId &= ~CONVERT_TWIPS;
3012 sal_Bool bRet = true;
3013 switch( nMemberId )
3015 case MID_TWOLINES:
3016 rVal = Bool2Any( bOn );
3017 break;
3018 case MID_START_BRACKET:
3020 OUString s;
3021 if( cStartBracket )
3022 s = OUString( cStartBracket );
3023 rVal <<= s;
3025 break;
3026 case MID_END_BRACKET:
3028 OUString s;
3029 if( cEndBracket )
3030 s = OUString( cEndBracket );
3031 rVal <<= s;
3033 break;
3034 default:
3035 bRet = false;
3036 break;
3038 return bRet;
3041 bool SvxTwoLinesItem::PutValue( const com::sun::star::uno::Any& rVal,
3042 sal_uInt8 nMemberId )
3044 nMemberId &= ~CONVERT_TWIPS;
3045 sal_Bool bRet = sal_False;
3046 OUString s;
3047 switch( nMemberId )
3049 case MID_TWOLINES:
3050 bOn = Any2Bool( rVal );
3051 bRet = sal_True;
3052 break;
3053 case MID_START_BRACKET:
3054 if( rVal >>= s )
3056 cStartBracket = s.isEmpty() ? 0 : s[ 0 ];
3057 bRet = sal_True;
3059 break;
3060 case MID_END_BRACKET:
3061 if( rVal >>= s )
3063 cEndBracket = s.isEmpty() ? 0 : s[ 0 ];
3064 bRet = sal_True;
3066 break;
3068 return bRet;
3071 SfxItemPresentation SvxTwoLinesItem::GetPresentation( SfxItemPresentation ePres,
3072 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
3073 OUString &rText, const IntlWrapper* /*pIntl*/ ) const
3075 switch( ePres )
3077 case SFX_ITEM_PRESENTATION_NONE:
3078 rText = OUString();
3079 break;
3080 case SFX_ITEM_PRESENTATION_NAMELESS:
3081 case SFX_ITEM_PRESENTATION_COMPLETE:
3083 if( !GetValue() )
3084 rText = EE_RESSTR( RID_SVXITEMS_TWOLINES_OFF );
3085 else
3087 rText = EE_RESSTR( RID_SVXITEMS_TWOLINES );
3088 if( GetStartBracket() )
3089 rText = OUString(GetStartBracket()) + rText;
3090 if( GetEndBracket() )
3091 rText += OUString(GetEndBracket());
3093 return ePres;
3095 default: ; //prevent warning
3097 return SFX_ITEM_PRESENTATION_NONE;
3101 SfxPoolItem* SvxTwoLinesItem::Create( SvStream & rStrm, sal_uInt16 /*nVer*/) const
3103 sal_Bool _bOn;
3104 sal_Unicode cStart, cEnd;
3105 rStrm >> _bOn >> cStart >> cEnd;
3106 return new SvxTwoLinesItem( _bOn, cStart, cEnd, Which() );
3109 SvStream& SvxTwoLinesItem::Store(SvStream & rStrm, sal_uInt16 /*nIVer*/) const
3111 rStrm << GetValue() << GetStartBracket() << GetEndBracket();
3112 return rStrm;
3115 sal_uInt16 SvxTwoLinesItem::GetVersion( sal_uInt16 nFFVer ) const
3117 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
3118 SOFFICE_FILEFORMAT_40==nFFVer ||
3119 SOFFICE_FILEFORMAT_50==nFFVer,
3120 "SvxTwoLinesItem: Gibt es ein neues Fileformat?" );
3122 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3126 /*************************************************************************
3127 |* class SvxCharRotateItem
3128 *************************************************************************/
3130 SvxCharRotateItem::SvxCharRotateItem( sal_uInt16 nValue,
3131 sal_Bool bFitIntoLine,
3132 const sal_uInt16 nW )
3133 : SfxUInt16Item( nW, nValue ), bFitToLine( bFitIntoLine )
3137 SfxPoolItem* SvxCharRotateItem::Clone( SfxItemPool* ) const
3139 return new SvxCharRotateItem( GetValue(), IsFitToLine(), Which() );
3142 SfxPoolItem* SvxCharRotateItem::Create( SvStream& rStrm, sal_uInt16 ) const
3144 sal_uInt16 nVal;
3145 sal_Bool b;
3146 rStrm >> nVal >> b;
3147 return new SvxCharRotateItem( nVal, b, Which() );
3150 SvStream& SvxCharRotateItem::Store( SvStream & rStrm, sal_uInt16 ) const
3152 sal_Bool bFlag = IsFitToLine();
3153 rStrm << GetValue() << bFlag;
3154 return rStrm;
3157 sal_uInt16 SvxCharRotateItem::GetVersion( sal_uInt16 nFFVer ) const
3159 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3162 SfxItemPresentation SvxCharRotateItem::GetPresentation(
3163 SfxItemPresentation ePres,
3164 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
3165 OUString &rText, const IntlWrapper* ) const
3167 switch( ePres )
3169 case SFX_ITEM_PRESENTATION_NONE:
3170 rText = OUString();
3171 break;
3172 case SFX_ITEM_PRESENTATION_NAMELESS:
3173 case SFX_ITEM_PRESENTATION_COMPLETE:
3175 if( !GetValue() )
3176 rText = EE_RESSTR( RID_SVXITEMS_CHARROTATE_OFF );
3177 else
3179 rText = EE_RESSTR( RID_SVXITEMS_CHARROTATE );
3180 rText = rText.replaceFirst( "$(ARG1)",
3181 OUString::number( GetValue() / 10 ));
3182 if( IsFitToLine() )
3183 rText += EE_RESSTR( RID_SVXITEMS_CHARROTATE_FITLINE );
3185 return ePres;
3187 default: ; //prevent warning
3189 return SFX_ITEM_PRESENTATION_NONE;
3192 bool SvxCharRotateItem::QueryValue( com::sun::star::uno::Any& rVal,
3193 sal_uInt8 nMemberId ) const
3195 nMemberId &= ~CONVERT_TWIPS;
3196 bool bRet = true;
3197 switch( nMemberId )
3199 case MID_ROTATE:
3200 rVal <<= (sal_Int16)GetValue();
3201 break;
3202 case MID_FITTOLINE:
3203 rVal = Bool2Any( IsFitToLine() );
3204 break;
3205 default:
3206 bRet = false;
3207 break;
3209 return bRet;
3212 bool SvxCharRotateItem::PutValue( const com::sun::star::uno::Any& rVal,
3213 sal_uInt8 nMemberId )
3215 nMemberId &= ~CONVERT_TWIPS;
3216 bool bRet = true;
3217 switch( nMemberId )
3219 case MID_ROTATE:
3221 sal_Int16 nVal = 0;
3222 if((rVal >>= nVal) && (0 == nVal || 900 == nVal || 2700 == nVal))
3223 SetValue( (sal_uInt16)nVal );
3224 else
3225 bRet = sal_False;
3226 break;
3229 case MID_FITTOLINE:
3230 SetFitToLine( Any2Bool( rVal ) );
3231 break;
3232 default:
3233 bRet = false;
3235 return bRet;
3238 int SvxCharRotateItem::operator==( const SfxPoolItem& rItem ) const
3240 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
3241 return SfxUInt16Item::operator==( rItem ) &&
3242 IsFitToLine() == ((const SvxCharRotateItem&)rItem).IsFitToLine();
3246 /*************************************************************************
3247 |* class SvxCharScaleItem
3248 *************************************************************************/
3250 SvxCharScaleWidthItem::SvxCharScaleWidthItem( sal_uInt16 nValue,
3251 const sal_uInt16 nW )
3252 : SfxUInt16Item( nW, nValue )
3256 SfxPoolItem* SvxCharScaleWidthItem::Clone( SfxItemPool* ) const
3258 return new SvxCharScaleWidthItem( GetValue(), Which() );
3261 SfxPoolItem* SvxCharScaleWidthItem::Create( SvStream& rStrm, sal_uInt16 ) const
3263 sal_uInt16 nVal;
3264 rStrm >> nVal;
3265 SvxCharScaleWidthItem* pItem = new SvxCharScaleWidthItem( nVal, Which() );
3267 if ( Which() == EE_CHAR_FONTWIDTH )
3269 // Was a SvxFontWidthItem in 5.2
3270 // sal_uInt16 nFixWidth, sal_uInt16 nPropWidth.
3271 // nFixWidth has never been used...
3272 rStrm >> nVal;
3273 sal_uInt16 nTest;
3274 rStrm >> nTest;
3275 if ( nTest == 0x1234 )
3276 pItem->SetValue( nVal );
3277 else
3278 rStrm.SeekRel( -2*(long)sizeof(sal_uInt16) );
3281 return pItem;
3284 SvStream& SvxCharScaleWidthItem::Store( SvStream& rStream, sal_uInt16 nVer ) const
3286 SvStream& rRet = SfxUInt16Item::Store( rStream, nVer );
3287 if ( Which() == EE_CHAR_FONTWIDTH )
3289 // see comment in Create()....
3290 rRet.SeekRel( -1*(long)sizeof(sal_uInt16) );
3291 rRet << (sal_uInt16)0;
3292 rRet << GetValue();
3293 // Really ugly, but not a problem for reading the doc in 5.2
3294 rRet << (sal_uInt16)0x1234;
3296 return rRet;
3300 sal_uInt16 SvxCharScaleWidthItem::GetVersion( sal_uInt16 nFFVer ) const
3302 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3305 SfxItemPresentation SvxCharScaleWidthItem::GetPresentation(
3306 SfxItemPresentation ePres,
3307 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
3308 OUString &rText, const IntlWrapper* ) const
3310 switch( ePres )
3312 case SFX_ITEM_PRESENTATION_NONE:
3313 rText = OUString();
3314 break;
3315 case SFX_ITEM_PRESENTATION_NAMELESS:
3316 case SFX_ITEM_PRESENTATION_COMPLETE:
3318 if( !GetValue() )
3319 rText = EE_RESSTR( RID_SVXITEMS_CHARSCALE_OFF );
3320 else
3322 rText = EE_RESSTR( RID_SVXITEMS_CHARSCALE );
3323 rText = rText.replaceFirst( "$(ARG1)",
3324 OUString::number( GetValue() ));
3326 return ePres;
3328 default: ; //prevent warning
3330 return SFX_ITEM_PRESENTATION_NONE;
3333 bool SvxCharScaleWidthItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
3335 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
3336 // where we still want this to be a sal_Int16
3337 sal_Int16 nValue = sal_Int16();
3338 if (rVal >>= nValue)
3340 SetValue( (sal_uInt16) nValue );
3341 return true;
3344 OSL_TRACE( "SvxCharScaleWidthItem::PutValue - Wrong type!" );
3345 return false;
3348 bool SvxCharScaleWidthItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
3350 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
3351 // where we still want this to be a sal_Int16
3352 rVal <<= (sal_Int16)GetValue();
3353 return true;
3356 /*************************************************************************
3357 |* class SvxCharReliefItem
3358 *************************************************************************/
3360 SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue,
3361 const sal_uInt16 nId )
3362 : SfxEnumItem( nId, (sal_uInt16)eValue )
3366 SfxPoolItem* SvxCharReliefItem::Clone( SfxItemPool * ) const
3368 return new SvxCharReliefItem( *this );
3371 SfxPoolItem* SvxCharReliefItem::Create(SvStream & rStrm, sal_uInt16) const
3373 sal_uInt16 nVal;
3374 rStrm >> nVal;
3375 return new SvxCharReliefItem( (FontRelief)nVal, Which() );
3378 SvStream& SvxCharReliefItem::Store(SvStream & rStrm, sal_uInt16 /*nIVer*/) const
3380 sal_uInt16 nVal = GetValue();
3381 rStrm << nVal;
3382 return rStrm;
3385 sal_uInt16 SvxCharReliefItem::GetVersion( sal_uInt16 nFFVer ) const
3387 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3390 OUString SvxCharReliefItem::GetValueTextByPos( sal_uInt16 nPos ) const
3392 DBG_ASSERT( RID_SVXITEMS_RELIEF_ENGRAVED - RID_SVXITEMS_RELIEF_NONE,
3393 "enum overflow" );
3394 return EE_RESSTR(RID_SVXITEMS_RELIEF_BEGIN + nPos);
3397 sal_uInt16 SvxCharReliefItem::GetValueCount() const
3399 return RID_SVXITEMS_RELIEF_ENGRAVED - RID_SVXITEMS_RELIEF_NONE;
3402 SfxItemPresentation SvxCharReliefItem::GetPresentation
3404 SfxItemPresentation ePres,
3405 SfxMapUnit /*eCoreUnit*/,
3406 SfxMapUnit /*ePresUnit*/,
3407 OUString& rText, const IntlWrapper * /*pIntl*/
3408 ) const
3410 SfxItemPresentation eRet = ePres;
3411 switch( ePres )
3413 case SFX_ITEM_PRESENTATION_NONE:
3414 rText = OUString();
3415 break;
3417 case SFX_ITEM_PRESENTATION_NAMELESS:
3418 case SFX_ITEM_PRESENTATION_COMPLETE:
3419 rText = GetValueTextByPos( GetValue() );
3420 break;
3422 default:
3423 eRet = SFX_ITEM_PRESENTATION_NONE;
3425 return eRet;
3428 bool SvxCharReliefItem::PutValue( const com::sun::star::uno::Any& rVal,
3429 sal_uInt8 nMemberId )
3431 nMemberId &= ~CONVERT_TWIPS;
3432 bool bRet = true;
3433 switch( nMemberId )
3435 case MID_RELIEF:
3437 sal_Int16 nVal = -1;
3438 rVal >>= nVal;
3439 if(nVal >= 0 && nVal <= RELIEF_ENGRAVED)
3440 SetValue( (sal_uInt16)nVal );
3441 else
3442 bRet = false;
3444 break;
3445 default:
3446 bRet = false;
3447 break;
3449 return bRet;
3452 bool SvxCharReliefItem::QueryValue( com::sun::star::uno::Any& rVal,
3453 sal_uInt8 nMemberId ) const
3455 nMemberId &= ~CONVERT_TWIPS;
3456 bool bRet = true;
3457 switch( nMemberId )
3459 case MID_RELIEF:
3460 rVal <<= (sal_Int16)GetValue();
3461 break;
3462 default:
3463 bRet = false;
3464 break;
3466 return bRet;
3469 /*************************************************************************
3470 |* class SvxScriptTypeItemItem
3471 *************************************************************************/
3473 SvxScriptTypeItem::SvxScriptTypeItem( sal_uInt16 nType )
3474 : SfxUInt16Item( SID_ATTR_CHAR_SCRIPTTYPE, nType )
3477 SfxPoolItem* SvxScriptTypeItem::Clone( SfxItemPool * ) const
3479 return new SvxScriptTypeItem( GetValue() );
3482 /*************************************************************************
3483 |* class SvxScriptSetItem
3484 *************************************************************************/
3486 SvxScriptSetItem::SvxScriptSetItem( sal_uInt16 nSlotId, SfxItemPool& rPool )
3487 : SfxSetItem( nSlotId, new SfxItemSet( rPool,
3488 SID_ATTR_CHAR_FONT, SID_ATTR_CHAR_FONT ))
3490 sal_uInt16 nLatin, nAsian, nComplex;
3491 GetWhichIds( nLatin, nAsian, nComplex );
3492 GetItemSet().MergeRange( nLatin, nLatin );
3493 GetItemSet().MergeRange( nAsian, nAsian );
3494 GetItemSet().MergeRange( nComplex, nComplex );
3495 GetItemSet().MergeRange( SID_ATTR_CHAR_SCRIPTTYPE, SID_ATTR_CHAR_SCRIPTTYPE );
3498 SfxPoolItem* SvxScriptSetItem::Clone( SfxItemPool * ) const
3500 SvxScriptSetItem* p = new SvxScriptSetItem( Which(), *GetItemSet().GetPool() );
3501 p->GetItemSet().Put( GetItemSet(), sal_False );
3502 return p;
3505 SfxPoolItem* SvxScriptSetItem::Create( SvStream &, sal_uInt16 ) const
3507 return 0;
3510 const SfxPoolItem* SvxScriptSetItem::GetItemOfScriptSet(
3511 const SfxItemSet& rSet, sal_uInt16 nId )
3513 const SfxPoolItem* pI;
3514 SfxItemState eSt = rSet.GetItemState( nId, sal_False, &pI );
3515 if( SFX_ITEM_SET != eSt )
3516 pI = SFX_ITEM_DEFAULT == eSt ? &rSet.Get( nId ) : 0;
3517 return pI;
3520 const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId, const SfxItemSet& rSet, sal_uInt16 nScript )
3522 sal_uInt16 nLatin, nAsian, nComplex;
3523 GetWhichIds( nSlotId, rSet, nLatin, nAsian, nComplex );
3525 const SfxPoolItem *pRet, *pAsn, *pCmplx;
3526 switch( nScript )
3528 default: //no one valid -> match to latin
3529 // case SCRIPTTYPE_LATIN:
3530 pRet = GetItemOfScriptSet( rSet, nLatin );
3531 break;
3532 case SCRIPTTYPE_ASIAN:
3533 pRet = GetItemOfScriptSet( rSet, nAsian );
3534 break;
3535 case SCRIPTTYPE_COMPLEX:
3536 pRet = GetItemOfScriptSet( rSet, nComplex );
3537 break;
3539 case SCRIPTTYPE_LATIN|SCRIPTTYPE_ASIAN:
3540 if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
3541 0 == (pAsn = GetItemOfScriptSet( rSet, nAsian )) ||
3542 *pRet != *pAsn )
3543 pRet = 0;
3544 break;
3546 case SCRIPTTYPE_LATIN|SCRIPTTYPE_COMPLEX:
3547 if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
3548 0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
3549 *pRet != *pCmplx )
3550 pRet = 0;
3551 break;
3553 case SCRIPTTYPE_ASIAN|SCRIPTTYPE_COMPLEX:
3554 if( 0 == (pRet = GetItemOfScriptSet( rSet, nAsian )) ||
3555 0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
3556 *pRet != *pCmplx )
3557 pRet = 0;
3558 break;
3560 case SCRIPTTYPE_LATIN|SCRIPTTYPE_ASIAN|SCRIPTTYPE_COMPLEX:
3561 if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
3562 0 == (pAsn = GetItemOfScriptSet( rSet, nAsian )) ||
3563 0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
3564 *pRet != *pAsn || *pRet != *pCmplx )
3565 pRet = 0;
3566 break;
3568 return pRet;
3571 const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nScript ) const
3573 return GetItemOfScript( Which(), GetItemSet(), nScript );
3576 void SvxScriptSetItem::PutItemForScriptType( sal_uInt16 nScriptType,
3577 const SfxPoolItem& rItem )
3579 sal_uInt16 nLatin, nAsian, nComplex;
3580 GetWhichIds( nLatin, nAsian, nComplex );
3582 SfxPoolItem* pCpy = rItem.Clone();
3583 if( SCRIPTTYPE_LATIN & nScriptType )
3585 pCpy->SetWhich( nLatin );
3586 GetItemSet().Put( *pCpy );
3588 if( SCRIPTTYPE_ASIAN & nScriptType )
3590 pCpy->SetWhich( nAsian );
3591 GetItemSet().Put( *pCpy );
3593 if( SCRIPTTYPE_COMPLEX & nScriptType )
3595 pCpy->SetWhich( nComplex );
3596 GetItemSet().Put( *pCpy );
3598 delete pCpy;
3601 void SvxScriptSetItem::GetWhichIds( sal_uInt16 nSlotId, const SfxItemSet& rSet, sal_uInt16& rLatin, sal_uInt16& rAsian, sal_uInt16& rComplex )
3603 const SfxItemPool& rPool = *rSet.GetPool();
3604 GetSlotIds( nSlotId, rLatin, rAsian, rComplex );
3605 rLatin = rPool.GetWhich( rLatin );
3606 rAsian = rPool.GetWhich( rAsian );
3607 rComplex = rPool.GetWhich( rComplex );
3610 void SvxScriptSetItem::GetWhichIds( sal_uInt16& rLatin, sal_uInt16& rAsian,
3611 sal_uInt16& rComplex ) const
3613 GetWhichIds( Which(), GetItemSet(), rLatin, rAsian, rComplex );
3616 void SvxScriptSetItem::GetSlotIds( sal_uInt16 nSlotId, sal_uInt16& rLatin,
3617 sal_uInt16& rAsian, sal_uInt16& rComplex )
3619 switch( nSlotId )
3621 default:
3622 DBG_ASSERT( sal_False, "wrong SlotId for class SvxScriptSetItem" );
3623 // no break - default to font - Id Range !!
3625 case SID_ATTR_CHAR_FONT:
3626 rLatin = SID_ATTR_CHAR_FONT;
3627 rAsian = SID_ATTR_CHAR_CJK_FONT;
3628 rComplex = SID_ATTR_CHAR_CTL_FONT;
3629 break;
3630 case SID_ATTR_CHAR_FONTHEIGHT:
3631 rLatin = SID_ATTR_CHAR_FONTHEIGHT;
3632 rAsian = SID_ATTR_CHAR_CJK_FONTHEIGHT;
3633 rComplex = SID_ATTR_CHAR_CTL_FONTHEIGHT;
3634 break;
3635 case SID_ATTR_CHAR_WEIGHT:
3636 rLatin = SID_ATTR_CHAR_WEIGHT;
3637 rAsian = SID_ATTR_CHAR_CJK_WEIGHT;
3638 rComplex = SID_ATTR_CHAR_CTL_WEIGHT;
3639 break;
3640 case SID_ATTR_CHAR_POSTURE:
3641 rLatin = SID_ATTR_CHAR_POSTURE;
3642 rAsian = SID_ATTR_CHAR_CJK_POSTURE;
3643 rComplex = SID_ATTR_CHAR_CTL_POSTURE;
3644 break;
3645 case SID_ATTR_CHAR_LANGUAGE:
3646 rLatin = SID_ATTR_CHAR_LANGUAGE;
3647 rAsian = SID_ATTR_CHAR_CJK_LANGUAGE;
3648 rComplex = SID_ATTR_CHAR_CTL_LANGUAGE;
3649 break;
3650 case SID_ATTR_CHAR_SHADOWED:
3651 rLatin = SID_ATTR_CHAR_SHADOWED;
3652 rAsian = SID_ATTR_CHAR_SHADOWED;
3653 rComplex = SID_ATTR_CHAR_SHADOWED;
3654 break;
3655 case SID_ATTR_CHAR_STRIKEOUT:
3656 rLatin = SID_ATTR_CHAR_STRIKEOUT;
3657 rAsian = SID_ATTR_CHAR_STRIKEOUT;
3658 rComplex = SID_ATTR_CHAR_STRIKEOUT;
3659 break;
3663 void GetDefaultFonts( SvxFontItem& rLatin, SvxFontItem& rAsian, SvxFontItem& rComplex )
3665 const sal_uInt16 nItemCnt = 3;
3667 static struct
3669 sal_uInt16 nFontType;
3670 sal_uInt16 nLanguage;
3672 aOutTypeArr[ nItemCnt ] =
3674 { DEFAULTFONT_LATIN_TEXT, LANGUAGE_ENGLISH_US },
3675 { DEFAULTFONT_CJK_TEXT, LANGUAGE_ENGLISH_US },
3676 { DEFAULTFONT_CTL_TEXT, LANGUAGE_ARABIC_SAUDI_ARABIA }
3679 SvxFontItem* aItemArr[ nItemCnt ] = { &rLatin, &rAsian, &rComplex };
3681 for ( sal_uInt16 n = 0; n < nItemCnt; ++n )
3683 Font aFont( OutputDevice::GetDefaultFont( aOutTypeArr[ n ].nFontType,
3684 aOutTypeArr[ n ].nLanguage,
3685 DEFAULTFONT_FLAGS_ONLYONE, 0 ) );
3686 SvxFontItem* pItem = aItemArr[ n ];
3687 pItem->SetFamily( aFont.GetFamily() );
3688 pItem->SetFamilyName( aFont.GetName() );
3689 pItem->SetStyleName( String() );
3690 pItem->SetPitch( aFont.GetPitch());
3691 pItem->SetCharSet(aFont.GetCharSet());
3696 sal_uInt16 GetI18NScriptTypeOfLanguage( sal_uInt16 nLang )
3698 return GetI18NScriptType( SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ) );
3701 sal_uInt16 GetItemScriptType( short nI18NType )
3703 switch ( nI18NType )
3705 case i18n::ScriptType::LATIN: return SCRIPTTYPE_LATIN;
3706 case i18n::ScriptType::ASIAN: return SCRIPTTYPE_ASIAN;
3707 case i18n::ScriptType::COMPLEX: return SCRIPTTYPE_COMPLEX;
3709 return 0;
3712 short GetI18NScriptType( sal_uInt16 nItemType )
3714 switch ( nItemType )
3716 case SCRIPTTYPE_LATIN: return i18n::ScriptType::LATIN;
3717 case SCRIPTTYPE_ASIAN: return i18n::ScriptType::ASIAN;
3718 case SCRIPTTYPE_COMPLEX: return i18n::ScriptType::COMPLEX;
3720 return 0;
3723 bool SvxRsidItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const
3725 rVal <<= ( (sal_uInt32)GetValue() );
3726 return true;
3729 bool SvxRsidItem::PutValue( const uno::Any& rVal, sal_uInt8 )
3731 sal_uInt32 nRsid = 0;
3732 if( !( rVal >>= nRsid ) )
3733 return false;
3735 SetValue( nRsid );
3736 return true;
3739 SfxPoolItem* SvxRsidItem::Clone( SfxItemPool * ) const
3741 return new SvxRsidItem( *this );
3744 SfxPoolItem* SvxRsidItem::Create(SvStream& rIn, sal_uInt16 ) const
3746 return new SvxRsidItem( rIn, Which() );
3748 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */