Update ooo320-m1
[ooovba.git] / svx / source / items / textitem.cxx
blob8460558e679896c668ade6feba3220bad3a509a7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: textitem.cxx,v $
10 * $Revision: 1.74.86.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
35 #include <com/sun/star/style/CaseMap.hpp>
36 #include <com/sun/star/awt/FontDescriptor.hpp>
37 #include <com/sun/star/frame/status/FontHeight.hpp>
38 #include <vcl/bitmapex.hxx>
39 #include <tools/stream.hxx>
40 #include <toolkit/unohlp.hxx>
41 #include <math.h>
42 #include <rtl/math.hxx>
44 #include <svx/eeitem.hxx>
46 #include <basic/sbx.hxx>
47 #define GLOBALOVERFLOW3
50 #include <svtools/memberid.hrc>
51 #include <svx/svxids.hrc>
52 #include <svx/svxitems.hrc>
53 #include <vcl/vclenum.hxx>
54 #include <tools/bigint.hxx>
55 #include <tools/tenccvt.hxx>
57 #include <rtl/ustring.hxx>
58 #include <i18npool/mslangid.hxx>
59 #include <svtools/itemset.hxx>
61 #include <svtools/langtab.hxx>
62 #include <svtools/itempool.hxx>
63 #include <svtools/ctrltool.hxx>
64 #include <vcl/settings.hxx>
65 #include <vcl/svapp.hxx>
66 #include <com/sun/star/style/CaseMap.hpp>
67 #include <com/sun/star/awt/SimpleFontMetric.hpp>
68 #include <com/sun/star/awt/FontWeight.hpp>
69 #include <com/sun/star/awt/FontSlant.hpp>
70 #include <com/sun/star/awt/CharSet.hpp>
71 #include <com/sun/star/awt/FontDescriptor.hpp>
72 #include <com/sun/star/awt/FontWidth.hpp>
73 #include <com/sun/star/awt/XFont.hpp>
74 #include <com/sun/star/awt/FontType.hpp>
75 #include <com/sun/star/awt/FontUnderline.hpp>
76 #include <com/sun/star/awt/FontStrikeout.hpp>
77 #include <com/sun/star/awt/FontFamily.hpp>
78 #include <com/sun/star/awt/FontPitch.hpp>
79 #include <com/sun/star/lang/Locale.hpp>
80 #include <com/sun/star/text/FontEmphasis.hpp>
81 #include <com/sun/star/i18n/ScriptType.hpp>
82 #include <svx/unomid.hxx>
85 #include "flstitem.hxx"
86 #include "fontitem.hxx"
87 #include <svx/postitem.hxx>
88 #include <svx/wghtitem.hxx>
89 #include <svx/fhgtitem.hxx>
90 #include "fwdtitem.hxx"
91 #include <svx/udlnitem.hxx>
92 #include <svx/crsditem.hxx>
93 #include <svx/shdditem.hxx>
94 #include <svx/akrnitem.hxx>
95 #include <svx/wrlmitem.hxx>
96 #include <svx/cntritem.hxx>
97 #include <svx/prszitem.hxx>
98 #include <svx/colritem.hxx>
99 #include <svx/cscoitem.hxx>
100 #include <svx/kernitem.hxx>
101 #include <svx/cmapitem.hxx>
102 #include <svx/escpitem.hxx>
103 #include <svx/langitem.hxx>
104 #include "nlbkitem.hxx"
105 #include <svx/nhypitem.hxx>
106 #include <svx/lcolitem.hxx>
107 #include <svx/blnkitem.hxx>
108 #include <svx/emphitem.hxx>
109 #include <svx/twolinesitem.hxx>
110 #include <svx/scripttypeitem.hxx>
111 #include <svx/charrotateitem.hxx>
112 #include <svx/charscaleitem.hxx>
113 #include <svx/charreliefitem.hxx>
114 #include <svx/itemtype.hxx>
115 #include <svx/dialmgr.hxx>
116 #include "dlgutil.hxx"
118 // #90477#
119 #include <tools/tenccvt.hxx>
121 #define STORE_UNICODE_MAGIC_MARKER 0xFE331188
123 using namespace ::rtl;
124 using namespace ::com::sun::star;
125 using namespace ::com::sun::star::text;
127 // Konvertierung fuer UNO
128 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
129 #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
130 #define TWIP_TO_MM100_UNSIGNED(TWIP) ((((TWIP)*127L+36L)/72L))
131 #define MM100_TO_TWIP_UNSIGNED(MM100) ((((MM100)*72L+63L)/127L))
133 BOOL SvxFontItem::bEnableStoreUnicodeNames = FALSE;
135 // STATIC DATA -----------------------------------------------------------
137 // -----------------------------------------------------------------------
139 TYPEINIT1(SvxFontListItem, SfxPoolItem);
140 TYPEINIT1_FACTORY(SvxFontItem, SfxPoolItem, new SvxFontItem(0));
141 TYPEINIT1_FACTORY(SvxPostureItem, SfxEnumItem, new SvxPostureItem(ITALIC_NONE, 0));
142 TYPEINIT1_FACTORY(SvxWeightItem, SfxEnumItem, new SvxWeightItem(WEIGHT_NORMAL, 0));
143 TYPEINIT1_FACTORY(SvxFontHeightItem, SfxPoolItem, new SvxFontHeightItem(240, 100, 0));
144 TYPEINIT1_FACTORY(SvxFontWidthItem, SfxPoolItem, new SvxFontWidthItem(0, 100, 0));
145 TYPEINIT1_FACTORY(SvxTextLineItem, SfxEnumItem, new SvxTextLineItem(UNDERLINE_NONE, 0));
146 TYPEINIT1_FACTORY(SvxUnderlineItem, SfxEnumItem, new SvxUnderlineItem(UNDERLINE_NONE, 0));
147 TYPEINIT1_FACTORY(SvxOverlineItem, SfxEnumItem, new SvxOverlineItem(UNDERLINE_NONE, 0));
148 TYPEINIT1_FACTORY(SvxCrossedOutItem, SfxEnumItem, new SvxCrossedOutItem(STRIKEOUT_NONE, 0));
149 TYPEINIT1_FACTORY(SvxShadowedItem, SfxBoolItem, new SvxShadowedItem(sal_False, 0));
150 TYPEINIT1_FACTORY(SvxAutoKernItem, SfxBoolItem, new SvxAutoKernItem(sal_False, 0));
151 TYPEINIT1_FACTORY(SvxWordLineModeItem, SfxBoolItem, new SvxWordLineModeItem(sal_False, 0));
152 TYPEINIT1_FACTORY(SvxContourItem, SfxBoolItem, new SvxContourItem(sal_False, 0));
153 TYPEINIT1_FACTORY(SvxPropSizeItem, SfxUInt16Item, new SvxPropSizeItem(100, 0));
154 TYPEINIT1_FACTORY(SvxColorItem, SfxPoolItem, new SvxColorItem(0));
155 TYPEINIT1_FACTORY(SvxCharSetColorItem, SvxColorItem, new SvxCharSetColorItem(0));
156 TYPEINIT1_FACTORY(SvxKerningItem, SfxInt16Item, new SvxKerningItem(0, 0));
157 TYPEINIT1_FACTORY(SvxCaseMapItem, SfxEnumItem, new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED, 0));
158 TYPEINIT1_FACTORY(SvxEscapementItem, SfxPoolItem, new SvxEscapementItem(0));
159 TYPEINIT1_FACTORY(SvxLanguageItem, SfxEnumItem, new SvxLanguageItem(LANGUAGE_GERMAN, 0));
160 TYPEINIT1_FACTORY(SvxNoLinebreakItem, SfxBoolItem, new SvxNoLinebreakItem(sal_True, 0));
161 TYPEINIT1_FACTORY(SvxNoHyphenItem, SfxBoolItem, new SvxNoHyphenItem(sal_True, 0));
162 TYPEINIT1_FACTORY(SvxLineColorItem, SvxColorItem, new SvxLineColorItem(0));
163 TYPEINIT1_FACTORY(SvxBlinkItem, SfxBoolItem, new SvxBlinkItem(sal_False, 0));
164 TYPEINIT1_FACTORY(SvxEmphasisMarkItem, SfxUInt16Item, new SvxEmphasisMarkItem(EMPHASISMARK_NONE, 0));
165 TYPEINIT1_FACTORY(SvxTwoLinesItem, SfxPoolItem, new SvxTwoLinesItem(sal_True, 0, 0, 0));
166 TYPEINIT1_FACTORY(SvxScriptTypeItem, SfxUInt16Item, new SvxScriptTypeItem);
167 TYPEINIT1_FACTORY(SvxCharRotateItem, SfxUInt16Item, new SvxCharRotateItem(0, sal_False, 0));
168 TYPEINIT1_FACTORY(SvxCharScaleWidthItem, SfxUInt16Item, new SvxCharScaleWidthItem(100, 0));
169 TYPEINIT1_FACTORY(SvxCharReliefItem, SfxEnumItem, new SvxCharReliefItem(RELIEF_NONE, 0));
172 TYPEINIT1(SvxScriptSetItem, SfxSetItem );
175 // class SvxFontListItem -------------------------------------------------
177 SvxFontListItem::SvxFontListItem( const FontList* pFontLst,
178 const USHORT nId ) :
179 SfxPoolItem( nId ),
180 pFontList( pFontLst )
182 if ( pFontList )
184 sal_Int32 nCount = pFontList->GetFontNameCount();
185 aFontNameSeq.realloc( nCount );
187 for ( USHORT i = 0; i < nCount; i++ )
188 aFontNameSeq[i] = pFontList->GetFontName(i).GetName();
192 // -----------------------------------------------------------------------
194 SvxFontListItem::SvxFontListItem( const SvxFontListItem& rItem ) :
196 SfxPoolItem( rItem ),
197 pFontList( rItem.GetFontList() ),
198 aFontNameSeq( rItem.aFontNameSeq )
202 // -----------------------------------------------------------------------
204 SfxPoolItem* SvxFontListItem::Clone( SfxItemPool* ) const
206 return new SvxFontListItem( *this );
209 // -----------------------------------------------------------------------
211 int SvxFontListItem::operator==( const SfxPoolItem& rAttr ) const
213 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
215 return( pFontList == ((SvxFontListItem&)rAttr).pFontList );
218 sal_Bool SvxFontListItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) const
220 rVal <<= aFontNameSeq;
221 return sal_True;
224 //------------------------------------------------------------------------
226 SfxItemPresentation SvxFontListItem::GetPresentation
228 SfxItemPresentation /*ePres*/,
229 SfxMapUnit /*eCoreUnit*/,
230 SfxMapUnit /*ePresUnit*/,
231 XubString& rText, const IntlWrapper * /*pIntl*/
232 ) const
234 rText.Erase();
235 return SFX_ITEM_PRESENTATION_NONE;
238 // class SvxFontItem -----------------------------------------------------
240 SvxFontItem::SvxFontItem( const USHORT nId ) :
241 SfxPoolItem( nId )
243 eFamily = FAMILY_SWISS;
244 ePitch = PITCH_VARIABLE;
245 eTextEncoding = RTL_TEXTENCODING_DONTKNOW;
248 // -----------------------------------------------------------------------
250 SvxFontItem::SvxFontItem( const FontFamily eFam, const XubString& aName,
251 const XubString& aStName, const FontPitch eFontPitch,
252 const rtl_TextEncoding eFontTextEncoding, const USHORT nId ) :
254 SfxPoolItem( nId ),
256 aFamilyName(aName),
257 aStyleName(aStName)
259 eFamily = eFam;
260 ePitch = eFontPitch;
261 eTextEncoding = eFontTextEncoding;
264 // -----------------------------------------------------------------------
266 sal_Bool SvxFontItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
268 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
269 nMemberId &= ~CONVERT_TWIPS;
270 switch(nMemberId)
272 case 0:
274 com::sun::star::awt::FontDescriptor aFontDescriptor;
275 aFontDescriptor.Name = aFamilyName.GetBuffer();
276 aFontDescriptor.StyleName = aStyleName.GetBuffer();
277 aFontDescriptor.Family = (sal_Int16)(eFamily);
278 aFontDescriptor.CharSet = (sal_Int16)(eTextEncoding);
279 aFontDescriptor.Pitch = (sal_Int16)(ePitch);
280 rVal <<= aFontDescriptor;
282 break;
283 case MID_FONT_FAMILY_NAME :
284 rVal <<= OUString(aFamilyName.GetBuffer());
285 break;
286 case MID_FONT_STYLE_NAME:
287 rVal <<= OUString(aStyleName.GetBuffer());
288 break;
289 case MID_FONT_FAMILY : rVal <<= (sal_Int16)(eFamily); break;
290 case MID_FONT_CHAR_SET : rVal <<= (sal_Int16)(eTextEncoding); break;
291 case MID_FONT_PITCH : rVal <<= (sal_Int16)(ePitch); break;
293 return sal_True;
295 // -----------------------------------------------------------------------
296 sal_Bool SvxFontItem::PutValue( const uno::Any& rVal, BYTE nMemberId)
298 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
299 nMemberId &= ~CONVERT_TWIPS;
300 switch(nMemberId)
302 case 0:
304 com::sun::star::awt::FontDescriptor aFontDescriptor;
305 if ( !( rVal >>= aFontDescriptor ))
306 return sal_False;
308 aFamilyName = aFontDescriptor.Name;
309 aStyleName = aFontDescriptor.StyleName;
310 eFamily = (FontFamily)aFontDescriptor.Family;
311 eTextEncoding = (rtl_TextEncoding)aFontDescriptor.CharSet;
312 ePitch = (FontPitch)aFontDescriptor.Pitch;
314 break;
315 case MID_FONT_FAMILY_NAME :
317 OUString aStr;
318 if(!(rVal >>= aStr))
319 return sal_False;
320 aFamilyName = aStr.getStr();
322 break;
323 case MID_FONT_STYLE_NAME:
325 OUString aStr;
326 if(!(rVal >>= aStr))
327 return sal_False;
328 aStyleName = aStr.getStr();
330 break;
331 case MID_FONT_FAMILY :
333 sal_Int16 nFamily = sal_Int16();
334 if(!(rVal >>= nFamily))
335 return sal_False;
336 eFamily = (FontFamily)nFamily;
338 break;
339 case MID_FONT_CHAR_SET :
341 sal_Int16 nSet = sal_Int16();
342 if(!(rVal >>= nSet))
343 return sal_False;
344 eTextEncoding = (rtl_TextEncoding)nSet;
346 break;
347 case MID_FONT_PITCH :
349 sal_Int16 nPitch = sal_Int16();
350 if(!(rVal >>= nPitch))
351 return sal_False;
352 ePitch = (FontPitch)nPitch;
354 break;
356 return sal_True;
359 // -----------------------------------------------------------------------
361 int SvxFontItem::operator==( const SfxPoolItem& rAttr ) const
363 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
365 const SvxFontItem& rItem = (const SvxFontItem&)rAttr;
367 int bRet = ( eFamily == rItem.eFamily &&
368 aFamilyName == rItem.aFamilyName &&
369 aStyleName == rItem.aStyleName );
371 if ( bRet )
373 if ( ePitch != rItem.ePitch || eTextEncoding != rItem.eTextEncoding )
375 bRet = sal_False;
376 DBG_WARNING( "FontItem::operator==(): nur Pitch oder rtl_TextEncoding unterschiedlich" );
379 return bRet;
382 // -----------------------------------------------------------------------
384 SfxPoolItem* SvxFontItem::Clone( SfxItemPool * ) const
386 return new SvxFontItem( *this );
389 // -----------------------------------------------------------------------
391 SvStream& SvxFontItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
393 BOOL bToBats =
394 GetFamilyName().EqualsAscii( "StarSymbol", 0, sizeof("StarSymbol")-1 ) ||
395 GetFamilyName().EqualsAscii( "OpenSymbol", 0, sizeof("OpenSymbol")-1 );
397 // #90477# rStrm << (BYTE) GetFamily()
398 // << (BYTE) GetPitch()
399 // << (BYTE)(bToBats ? RTL_TEXTENCODING_SYMBOL : GetStoreCharSet( GetCharSet(), (USHORT)rStrm.GetVersion() ) );
400 rStrm << (BYTE) GetFamily() << (BYTE) GetPitch()
401 << (BYTE)(bToBats ? RTL_TEXTENCODING_SYMBOL : GetSOStoreTextEncoding(GetCharSet(), (sal_uInt16)rStrm.GetVersion()));
403 String aStoreFamilyName( GetFamilyName() );
404 if( bToBats )
405 aStoreFamilyName = String( "StarBats", sizeof("StarBats")-1, RTL_TEXTENCODING_ASCII_US );
406 rStrm.WriteByteString(aStoreFamilyName);
407 rStrm.WriteByteString(GetStyleName());
409 // #96441# Kach for EditEngine, only set while creating clipboard stream.
410 if ( bEnableStoreUnicodeNames )
412 sal_uInt32 nMagic = STORE_UNICODE_MAGIC_MARKER;
413 rStrm << nMagic;
414 rStrm.WriteByteString( aStoreFamilyName, RTL_TEXTENCODING_UNICODE );
415 rStrm.WriteByteString( GetStyleName(), RTL_TEXTENCODING_UNICODE );
418 return rStrm;
421 // -----------------------------------------------------------------------
423 SfxPoolItem* SvxFontItem::Create(SvStream& rStrm, USHORT) const
425 BYTE _eFamily, eFontPitch, eFontTextEncoding;
426 String aName, aStyle;
427 rStrm >> _eFamily;
428 rStrm >> eFontPitch;
429 rStrm >> eFontTextEncoding;
431 // UNICODE: rStrm >> aName;
432 rStrm.ReadByteString(aName);
434 // UNICODE: rStrm >> aStyle;
435 rStrm.ReadByteString(aStyle);
437 // Task 91008/90471: set the "correct" textencoding
438 eFontTextEncoding = (BYTE)GetSOLoadTextEncoding( eFontTextEncoding, (USHORT)rStrm.GetVersion() );
440 // irgendwann wandelte sich der StarBats vom ANSI- zum SYMBOL-Font
441 if ( RTL_TEXTENCODING_SYMBOL != eFontTextEncoding && aName.EqualsAscii("StarBats") )
442 eFontTextEncoding = RTL_TEXTENCODING_SYMBOL;
444 // Check if we have stored unicode
445 sal_Size nStreamPos = rStrm.Tell();
446 sal_uInt32 nMagic = STORE_UNICODE_MAGIC_MARKER;
447 rStrm >> nMagic;
448 if ( nMagic == STORE_UNICODE_MAGIC_MARKER )
450 rStrm.ReadByteString( aName, RTL_TEXTENCODING_UNICODE );
451 rStrm.ReadByteString( aStyle, RTL_TEXTENCODING_UNICODE );
453 else
455 rStrm.Seek( nStreamPos );
460 return new SvxFontItem( (FontFamily)_eFamily, aName, aStyle,
461 (FontPitch)eFontPitch, (rtl_TextEncoding)eFontTextEncoding, Which() );
464 //------------------------------------------------------------------------
466 SfxItemPresentation SvxFontItem::GetPresentation
468 SfxItemPresentation ePres,
469 SfxMapUnit /*eCoreUnit*/,
470 SfxMapUnit /*ePresUnit*/,
471 XubString& rText, const IntlWrapper * /*pIntl*/
472 ) const
474 switch ( ePres )
476 case SFX_ITEM_PRESENTATION_NONE:
477 rText.Erase();
478 return ePres;
479 case SFX_ITEM_PRESENTATION_NAMELESS:
480 case SFX_ITEM_PRESENTATION_COMPLETE:
481 rText = aFamilyName;
482 return ePres;
483 default: ; //prevent warning
485 return SFX_ITEM_PRESENTATION_NONE;
488 //------------------------------------------------------------------------
490 void SvxFontItem::EnableStoreUnicodeNames( BOOL bEnable )
492 bEnableStoreUnicodeNames = bEnable;
495 // class SvxPostureItem --------------------------------------------------
497 SvxPostureItem::SvxPostureItem( const FontItalic ePosture, const USHORT nId ) :
498 SfxEnumItem( nId, (USHORT)ePosture )
502 // -----------------------------------------------------------------------
504 SfxPoolItem* SvxPostureItem::Clone( SfxItemPool * ) const
506 return new SvxPostureItem( *this );
509 // -----------------------------------------------------------------------
511 USHORT SvxPostureItem::GetValueCount() const
513 return ITALIC_NORMAL + 1; // auch ITALIC_NONE geh"ort dazu
516 // -----------------------------------------------------------------------
518 SvStream& SvxPostureItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
520 rStrm << (BYTE)GetValue();
521 return rStrm;
524 // -----------------------------------------------------------------------
526 SfxPoolItem* SvxPostureItem::Create(SvStream& rStrm, USHORT) const
528 BYTE nPosture;
529 rStrm >> nPosture;
530 return new SvxPostureItem( (const FontItalic)nPosture, Which() );
533 //------------------------------------------------------------------------
535 SfxItemPresentation SvxPostureItem::GetPresentation
537 SfxItemPresentation ePres,
538 SfxMapUnit /*eCoreUnit*/,
539 SfxMapUnit /*ePresUnit*/,
540 XubString& rText, const IntlWrapper * /*pIntl*/
541 ) const
543 switch ( ePres )
545 case SFX_ITEM_PRESENTATION_NONE:
546 rText.Erase();
547 return ePres;
548 case SFX_ITEM_PRESENTATION_NAMELESS:
549 case SFX_ITEM_PRESENTATION_COMPLETE:
550 rText = GetValueTextByPos( GetValue() );
551 return ePres;
552 default: ;//prevent warning
554 return SFX_ITEM_PRESENTATION_NONE;
557 // -----------------------------------------------------------------------
559 XubString SvxPostureItem::GetValueTextByPos( USHORT nPos ) const
561 DBG_ASSERT( nPos <= (USHORT)ITALIC_NORMAL, "enum overflow!" );
563 XubString sTxt;
564 FontItalic eItalic = (FontItalic)nPos;
565 USHORT nId = 0;
567 switch ( eItalic )
569 case ITALIC_NONE: nId = RID_SVXITEMS_ITALIC_NONE; break;
570 case ITALIC_OBLIQUE: nId = RID_SVXITEMS_ITALIC_OBLIQUE; break;
571 case ITALIC_NORMAL: nId = RID_SVXITEMS_ITALIC_NORMAL; break;
572 default: ;//prevent warning
575 if ( nId )
576 sTxt = SVX_RESSTR( nId );
577 return sTxt;
581 /*-----------------13.03.98 14:28-------------------
583 --------------------------------------------------*/
584 sal_Bool SvxPostureItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
586 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
587 nMemberId &= ~CONVERT_TWIPS;
588 switch( nMemberId )
590 case MID_ITALIC:
591 rVal = Bool2Any(GetBoolValue());
592 break;
593 case MID_POSTURE:
594 rVal <<= (awt::FontSlant)GetValue(); // Werte von awt::FontSlant und FontItalic sind gleich
595 break;
597 return sal_True;
599 /*-----------------13.03.98 14:28-------------------
601 --------------------------------------------------*/
602 sal_Bool SvxPostureItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
604 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
605 nMemberId &= ~CONVERT_TWIPS;
606 switch( nMemberId )
608 case MID_ITALIC:
609 SetBoolValue(Any2Bool(rVal));
610 break;
611 case MID_POSTURE:
613 awt::FontSlant eSlant;
614 if(!(rVal >>= eSlant))
616 sal_Int32 nValue = 0;
617 if(!(rVal >>= nValue))
618 return sal_False;
620 eSlant = (awt::FontSlant)nValue;
622 SetValue((USHORT)eSlant);
625 return sal_True;
627 // -----------------------------------------------------------------------
629 int SvxPostureItem::HasBoolValue() const
631 return sal_True;
634 // -----------------------------------------------------------------------
636 sal_Bool SvxPostureItem::GetBoolValue() const
638 return ( (FontItalic)GetValue() >= ITALIC_OBLIQUE );
641 // -----------------------------------------------------------------------
643 void SvxPostureItem::SetBoolValue( sal_Bool bVal )
645 SetValue( (USHORT)(bVal ? ITALIC_NORMAL : ITALIC_NONE) );
648 // class SvxWeightItem ---------------------------------------------------
650 SvxWeightItem::SvxWeightItem( const FontWeight eWght, const USHORT nId ) :
651 SfxEnumItem( nId, (USHORT)eWght )
657 // -----------------------------------------------------------------------
659 int SvxWeightItem::HasBoolValue() const
661 return sal_True;
664 // -----------------------------------------------------------------------
666 sal_Bool SvxWeightItem::GetBoolValue() const
668 return (FontWeight)GetValue() >= WEIGHT_BOLD;
671 // -----------------------------------------------------------------------
673 void SvxWeightItem::SetBoolValue( sal_Bool bVal )
675 SetValue( (USHORT)(bVal ? WEIGHT_BOLD : WEIGHT_NORMAL) );
678 // -----------------------------------------------------------------------
680 USHORT SvxWeightItem::GetValueCount() const
682 return WEIGHT_BLACK; // WEIGHT_DONTKNOW geh"ort nicht dazu
685 // -----------------------------------------------------------------------
687 SfxPoolItem* SvxWeightItem::Clone( SfxItemPool * ) const
689 return new SvxWeightItem( *this );
692 // -----------------------------------------------------------------------
694 SvStream& SvxWeightItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
696 rStrm << (BYTE)GetValue();
697 return rStrm;
700 // -----------------------------------------------------------------------
702 SfxPoolItem* SvxWeightItem::Create(SvStream& rStrm, USHORT) const
704 BYTE nWeight;
705 rStrm >> nWeight;
706 return new SvxWeightItem( (FontWeight)nWeight, Which() );
709 //------------------------------------------------------------------------
711 SfxItemPresentation SvxWeightItem::GetPresentation
713 SfxItemPresentation ePres,
714 SfxMapUnit /*eCoreUnit*/,
715 SfxMapUnit /*ePresUnit*/,
716 XubString& rText, const IntlWrapper * /*pIntl*/
717 ) const
719 switch ( ePres )
721 case SFX_ITEM_PRESENTATION_NONE:
722 rText.Erase();
723 return ePres;
724 case SFX_ITEM_PRESENTATION_NAMELESS:
725 case SFX_ITEM_PRESENTATION_COMPLETE:
726 rText = GetValueTextByPos( GetValue() );
727 return ePres;
728 default: ;//prevent warning
730 return SFX_ITEM_PRESENTATION_NONE;
733 // -----------------------------------------------------------------------
735 XubString SvxWeightItem::GetValueTextByPos( USHORT nPos ) const
737 DBG_ASSERT( nPos <= (USHORT)WEIGHT_BLACK, "enum overflow!" );
738 return SVX_RESSTR( RID_SVXITEMS_WEIGHT_BEGIN + nPos );
741 /*-----------------13.03.98 14:18-------------------
743 --------------------------------------------------*/
744 sal_Bool SvxWeightItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
746 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
747 nMemberId &= ~CONVERT_TWIPS;
748 switch( nMemberId )
750 case MID_BOLD :
751 rVal = Bool2Any(GetBoolValue());
752 break;
753 case MID_WEIGHT:
755 rVal <<= (float)( VCLUnoHelper::ConvertFontWeight( (FontWeight)GetValue() ) );
757 break;
759 return sal_True;
761 /*-----------------13.03.98 14:18-------------------
763 --------------------------------------------------*/
764 sal_Bool SvxWeightItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
766 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
767 nMemberId &= ~CONVERT_TWIPS;
768 switch( nMemberId )
770 case MID_BOLD :
771 SetBoolValue(Any2Bool(rVal));
772 break;
773 case MID_WEIGHT:
775 double fValue = 0;
776 if(!(rVal >>= fValue))
778 sal_Int32 nValue = 0;
779 if(!(rVal >>= nValue))
780 return sal_False;
781 fValue = (float)nValue;
783 SetValue( (USHORT)VCLUnoHelper::ConvertFontWeight((float)fValue) );
785 break;
787 return sal_True;
790 // class SvxFontHeightItem -----------------------------------------------
792 SvxFontHeightItem::SvxFontHeightItem( const ULONG nSz,
793 const USHORT nPrp,
794 const USHORT nId ) :
795 SfxPoolItem( nId )
797 SetHeight( nSz,nPrp ); // mit den Prozenten rechnen
800 // -----------------------------------------------------------------------
802 SfxPoolItem* SvxFontHeightItem::Clone( SfxItemPool * ) const
804 return new SvxFontHeightItem( *this );
807 // -----------------------------------------------------------------------
809 SvStream& SvxFontHeightItem::Store( SvStream& rStrm , USHORT nItemVersion ) const
811 rStrm << (USHORT)GetHeight();
813 if( FONTHEIGHT_UNIT_VERSION <= nItemVersion )
814 rStrm << GetProp() << (USHORT)GetPropUnit();
815 else
817 // JP 30.06.98: beim Export in alte Versionen geht die relative
818 // Angabe verloren, wenn es keine Prozentuale ist
819 USHORT _nProp = GetProp();
820 if( SFX_MAPUNIT_RELATIVE != GetPropUnit() )
821 _nProp = 100;
822 rStrm << _nProp;
824 return rStrm;
827 // -----------------------------------------------------------------------
829 SfxPoolItem* SvxFontHeightItem::Create( SvStream& rStrm,
830 USHORT nVersion ) const
832 USHORT nsize, nprop = 0, nPropUnit = SFX_MAPUNIT_RELATIVE;
834 rStrm >> nsize;
836 if( FONTHEIGHT_16_VERSION <= nVersion )
837 rStrm >> nprop;
838 else
840 BYTE nP;
841 rStrm >> nP;
842 nprop = (USHORT)nP;
845 if( FONTHEIGHT_UNIT_VERSION <= nVersion )
846 rStrm >> nPropUnit;
848 SvxFontHeightItem* pItem = new SvxFontHeightItem( nsize, 100, Which() );
849 pItem->SetProp( nprop, (SfxMapUnit)nPropUnit );
850 return pItem;
853 // -----------------------------------------------------------------------
855 int SvxFontHeightItem::operator==( const SfxPoolItem& rItem ) const
857 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
858 return GetHeight() == ((SvxFontHeightItem&)rItem).GetHeight() &&
859 GetProp() == ((SvxFontHeightItem&)rItem).GetProp() &&
860 GetPropUnit() == ((SvxFontHeightItem&)rItem).GetPropUnit();
863 /*-----------------13.03.98 14:53-------------------
865 --------------------------------------------------*/
866 sal_Bool SvxFontHeightItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
868 // In StarOne sind im uno::Any immer 1/100mm. Ueber die MemberId wird
869 // gesteuert, ob der Wert im Item 1/100mm oder Twips sind.
871 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
872 nMemberId &= ~CONVERT_TWIPS;
873 switch( nMemberId )
875 case 0:
877 ::com::sun::star::frame::status::FontHeight aFontHeight;
879 // Point (also Twips) sind gefragt,
880 // also umrechnen, wenn CONVERT_TWIPS nicht gesetzt ist
881 if( bConvert )
883 long nTwips = bConvert ? nHeight : MM100_TO_TWIP_UNSIGNED(nHeight);
884 aFontHeight.Height = (float)( nTwips / 20.0 );
886 else
888 double fPoints = MM100_TO_TWIP_UNSIGNED(nHeight) / 20.0;
889 float fRoundPoints =
890 static_cast<float>(::rtl::math::round(fPoints, 1));
891 aFontHeight.Height = fRoundPoints;
894 aFontHeight.Prop = (sal_Int16)(SFX_MAPUNIT_RELATIVE == ePropUnit ? nProp : 100);
896 float fRet = (float)(short)nProp;
897 switch( ePropUnit )
899 case SFX_MAPUNIT_RELATIVE:
900 fRet = 0.;
901 break;
902 case SFX_MAPUNIT_100TH_MM:
903 fRet = MM100_TO_TWIP(fRet);
904 fRet /= 20.;
905 break;
906 case SFX_MAPUNIT_POINT:
908 break;
909 case SFX_MAPUNIT_TWIP:
910 fRet /= 20.;
911 break;
912 default: ;//prevent warning
914 aFontHeight.Diff = fRet;
915 rVal <<= aFontHeight;
917 break;
918 case MID_FONTHEIGHT:
920 // Point (also Twips) sind gefragt,
921 // also umrechnen, wenn CONVERT_TWIPS nicht gesetzt ist
922 if( bConvert )
924 long nTwips = bConvert ? nHeight : MM100_TO_TWIP_UNSIGNED(nHeight);
925 rVal <<= (float)( nTwips / 20.0 );
927 else
929 double fPoints = MM100_TO_TWIP_UNSIGNED(nHeight) / 20.0;
930 float fRoundPoints =
931 static_cast<float>(::rtl::math::round(fPoints, 1));
932 rVal <<= fRoundPoints;
935 break;
936 case MID_FONTHEIGHT_PROP:
937 rVal <<= (sal_Int16)(SFX_MAPUNIT_RELATIVE == ePropUnit ? nProp : 100);
938 break;
939 case MID_FONTHEIGHT_DIFF:
941 float fRet = (float)(short)nProp;
942 switch( ePropUnit )
944 case SFX_MAPUNIT_RELATIVE:
945 fRet = 0.;
946 break;
947 case SFX_MAPUNIT_100TH_MM:
948 fRet = MM100_TO_TWIP(fRet);
949 fRet /= 20.;
950 break;
951 case SFX_MAPUNIT_POINT:
953 break;
954 case SFX_MAPUNIT_TWIP:
955 fRet /= 20.;
956 break;
957 default: ;//prevent warning
959 rVal <<= fRet;
961 break;
963 return sal_True;
965 /* -----------------01.07.98 13:43-------------------
966 * Relative Abweichung aus der Hoehe herausrechnen
967 * --------------------------------------------------*/
968 sal_uInt32 lcl_GetRealHeight_Impl(sal_uInt32 nHeight, sal_uInt16 nProp, SfxMapUnit eProp, sal_Bool bCoreInTwip)
970 sal_uInt32 nRet = nHeight;
971 short nDiff = 0;
972 switch( eProp )
974 case SFX_MAPUNIT_RELATIVE:
975 nRet *= 100;
976 nRet /= nProp;
977 break;
978 case SFX_MAPUNIT_POINT:
980 short nTemp = (short)nProp;
981 nDiff = nTemp * 20;
982 if(!bCoreInTwip)
983 nDiff = (short)TWIP_TO_MM100((long)(nDiff));
985 break;
986 case SFX_MAPUNIT_100TH_MM:
987 //dann ist die Core doch wohl auch in 1/100 mm
988 nDiff = (short)nProp;
989 break;
990 case SFX_MAPUNIT_TWIP:
991 // hier doch sicher TWIP
992 nDiff = ((short)nProp);
993 break;
994 default: ;//prevent warning
996 nRet -= nDiff;
998 return nRet;
1001 /*-----------------13.03.98 14:53-------------------
1003 --------------------------------------------------*/
1004 sal_Bool SvxFontHeightItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
1006 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1007 nMemberId &= ~CONVERT_TWIPS;
1008 switch( nMemberId )
1010 case 0:
1012 ::com::sun::star::frame::status::FontHeight aFontHeight;
1013 if ( rVal >>= aFontHeight )
1015 // Height
1016 ePropUnit = SFX_MAPUNIT_RELATIVE;
1017 nProp = 100;
1018 double fPoint = aFontHeight.Height;
1019 if( fPoint < 0. || fPoint > 10000. )
1020 return sal_False;
1022 nHeight = (long)( fPoint * 20.0 + 0.5 ); // Twips
1023 if (!bConvert)
1024 nHeight = TWIP_TO_MM100_UNSIGNED(nHeight); // umrechnen, wenn das Item 1/100mm enthaelt
1026 nProp = aFontHeight.Prop;
1028 else
1029 return sal_False;
1031 break;
1032 case MID_FONTHEIGHT:
1034 ePropUnit = SFX_MAPUNIT_RELATIVE;
1035 nProp = 100;
1036 double fPoint = 0;
1037 if(!(rVal >>= fPoint))
1039 sal_Int32 nValue = 0;
1040 if(!(rVal >>= nValue))
1041 return sal_False;
1042 fPoint = (float)nValue;
1044 if(fPoint < 0. || fPoint > 10000.)
1045 return sal_False;
1047 nHeight = (long)( fPoint * 20.0 + 0.5 ); // Twips
1048 if (!bConvert)
1049 nHeight = TWIP_TO_MM100_UNSIGNED(nHeight); // umrechnen, wenn das Item 1/100mm enthaelt
1051 break;
1052 case MID_FONTHEIGHT_PROP:
1054 sal_Int16 nNew = sal_Int16();
1055 if(!(rVal >>= nNew))
1056 return sal_True;
1058 nHeight = lcl_GetRealHeight_Impl(nHeight, nProp, ePropUnit, bConvert);
1060 nHeight *= nNew;
1061 nHeight /= 100;
1062 nProp = nNew;
1063 ePropUnit = SFX_MAPUNIT_RELATIVE;
1065 break;
1066 case MID_FONTHEIGHT_DIFF:
1068 nHeight = lcl_GetRealHeight_Impl(nHeight, nProp, ePropUnit, bConvert);
1069 float fValue = 0;
1070 if(!(rVal >>= fValue))
1072 sal_Int32 nValue = 0;
1073 if(!(rVal >>= nValue))
1074 return sal_False;
1075 fValue = (float)nValue;
1077 sal_Int16 nCoreDiffValue = (sal_Int16)(fValue * 20.);
1078 nHeight += bConvert ? nCoreDiffValue : TWIP_TO_MM100(nCoreDiffValue);
1079 nProp = (sal_uInt16)((sal_Int16)fValue);
1080 ePropUnit = SFX_MAPUNIT_POINT;
1082 break;
1084 return sal_True;
1087 //------------------------------------------------------------------------
1089 SfxItemPresentation SvxFontHeightItem::GetPresentation
1091 SfxItemPresentation ePres,
1092 SfxMapUnit eCoreUnit,
1093 SfxMapUnit /*ePresUnit*/,
1094 XubString& rText, const IntlWrapper *pIntl
1095 ) const
1097 #ifndef SVX_LIGHT
1098 switch ( ePres )
1100 case SFX_ITEM_PRESENTATION_NONE:
1101 rText.Erase();
1102 return ePres;
1103 case SFX_ITEM_PRESENTATION_NAMELESS:
1104 case SFX_ITEM_PRESENTATION_COMPLETE:
1106 if( SFX_MAPUNIT_RELATIVE != ePropUnit )
1108 ( rText = String::CreateFromInt32( (short)nProp ) ) +=
1109 SVX_RESSTR( GetMetricId( ePropUnit ) );
1110 if( 0 <= (short)nProp )
1111 rText.Insert( sal_Unicode('+'), 0 );
1113 else if( 100 == nProp )
1115 rText = GetMetricText( (long)nHeight,
1116 eCoreUnit, SFX_MAPUNIT_POINT, pIntl );
1117 rText += SVX_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
1119 else
1120 ( rText = String::CreateFromInt32( nProp )) += sal_Unicode('%');
1121 return ePres;
1123 default: ; //prevent warning
1125 #endif
1126 return SFX_ITEM_PRESENTATION_NONE;
1129 // -----------------------------------------------------------------------
1131 USHORT SvxFontHeightItem::GetVersion(USHORT nFileVersion) const
1133 return (nFileVersion <= SOFFICE_FILEFORMAT_40)
1134 ? FONTHEIGHT_16_VERSION
1135 : FONTHEIGHT_UNIT_VERSION;
1138 // -----------------------------------------------------------------------
1140 int SvxFontHeightItem::ScaleMetrics( long nMult, long nDiv )
1142 nHeight = (sal_uInt32)Scale( nHeight, nMult, nDiv );
1143 return 1;
1146 // -----------------------------------------------------------------------
1148 int SvxFontHeightItem::HasMetrics() const
1150 return 1;
1153 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight, const USHORT nNewProp,
1154 SfxMapUnit eUnit )
1156 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
1158 #ifndef SVX_LIGHT
1159 if( SFX_MAPUNIT_RELATIVE != eUnit )
1160 nHeight = nNewHeight + ::ItemToControl( (short)nNewProp, eUnit,
1161 SFX_FUNIT_TWIP );
1162 else
1163 #endif // !SVX_LIGHT
1164 if( 100 != nNewProp )
1165 nHeight = sal_uInt32(( nNewHeight * nNewProp ) / 100 );
1166 else
1167 nHeight = nNewHeight;
1169 nProp = nNewProp;
1170 ePropUnit = eUnit;
1173 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight, USHORT nNewProp,
1174 SfxMapUnit eMetric, SfxMapUnit eCoreMetric )
1176 DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
1178 #ifndef SVX_LIGHT
1179 if( SFX_MAPUNIT_RELATIVE != eMetric )
1180 nHeight = nNewHeight +
1181 ::ControlToItem( ::ItemToControl((short)nNewProp, eMetric,
1182 SFX_FUNIT_TWIP ), SFX_FUNIT_TWIP,
1183 eCoreMetric );
1184 else
1185 #endif // !SVX_LIGHT
1186 if( 100 != nNewProp )
1187 nHeight = sal_uInt32(( nNewHeight * nNewProp ) / 100 );
1188 else
1189 nHeight = nNewHeight;
1191 nProp = nNewProp;
1192 ePropUnit = eMetric;
1195 // class SvxFontWidthItem -----------------------------------------------
1197 SvxFontWidthItem::SvxFontWidthItem( const USHORT nSz, const USHORT nPrp, const USHORT nId ) :
1198 SfxPoolItem( nId )
1200 nWidth = nSz;
1201 nProp = nPrp;
1204 // -----------------------------------------------------------------------
1206 SfxPoolItem* SvxFontWidthItem::Clone( SfxItemPool * ) const
1208 return new SvxFontWidthItem( *this );
1211 // -----------------------------------------------------------------------
1213 SvStream& SvxFontWidthItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
1215 rStrm << GetWidth() << GetProp();
1216 return rStrm;
1219 // -----------------------------------------------------------------------
1221 int SvxFontWidthItem::ScaleMetrics( long nMult, long nDiv )
1223 nWidth = (USHORT)Scale( nWidth, nMult, nDiv );
1224 return 1;
1227 // -----------------------------------------------------------------------
1229 int SvxFontWidthItem::HasMetrics() const
1231 return 1;
1234 // -----------------------------------------------------------------------
1236 SfxPoolItem* SvxFontWidthItem::Create( SvStream& rStrm,
1237 USHORT /*nVersion*/ ) const
1239 USHORT nS;
1240 USHORT nP;
1242 rStrm >> nS;
1243 rStrm >> nP;
1244 SvxFontWidthItem* pItem = new SvxFontWidthItem( 0, nP, Which() );
1245 pItem->SetWidthValue( nS );
1246 return pItem;
1249 // -----------------------------------------------------------------------
1251 int SvxFontWidthItem::operator==( const SfxPoolItem& rItem ) const
1253 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
1254 return GetWidth() == ((SvxFontWidthItem&)rItem).GetWidth() &&
1255 GetProp() == ((SvxFontWidthItem&)rItem).GetProp();
1258 /*-----------------13.03.98 16:03-------------------
1260 --------------------------------------------------*/
1261 sal_Bool SvxFontWidthItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
1263 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1264 nMemberId &= ~CONVERT_TWIPS;
1265 switch(nMemberId)
1267 case MID_FONTWIDTH:
1268 rVal <<= (sal_Int16)(nWidth);
1269 break;
1270 case MID_FONTWIDTH_PROP:
1271 rVal <<= (sal_Int16)(nProp);
1272 break;
1274 return sal_True;
1276 /*-----------------13.03.98 16:03-------------------
1278 --------------------------------------------------*/
1279 sal_Bool SvxFontWidthItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
1281 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1282 nMemberId &= ~CONVERT_TWIPS;
1283 sal_Int16 nVal = sal_Int16();
1284 if(!(rVal >>= nVal))
1285 return sal_False;
1287 switch(nMemberId)
1289 case MID_FONTWIDTH:
1290 nProp = nVal;
1291 break;
1292 case MID_FONTWIDTH_PROP:
1293 nWidth = nVal;
1294 break;
1296 return sal_True;
1299 //------------------------------------------------------------------------
1301 SfxItemPresentation SvxFontWidthItem::GetPresentation
1303 SfxItemPresentation ePres,
1304 SfxMapUnit eCoreUnit,
1305 SfxMapUnit /*ePresUnit*/,
1306 XubString& rText, const IntlWrapper *pIntl
1307 ) const
1309 #ifndef SVX_LIGHT
1310 switch ( ePres )
1312 case SFX_ITEM_PRESENTATION_NONE:
1313 rText.Erase();
1314 return ePres;
1315 case SFX_ITEM_PRESENTATION_NAMELESS:
1316 case SFX_ITEM_PRESENTATION_COMPLETE:
1318 if ( 100 == nProp )
1320 rText = GetMetricText( (long)nWidth,
1321 eCoreUnit, SFX_MAPUNIT_POINT, pIntl );
1322 rText += SVX_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
1324 else
1325 ( rText = String::CreateFromInt32( nProp )) += sal_Unicode('%');
1326 return ePres;
1328 default: ; //prevent warning
1330 #endif
1331 return SFX_ITEM_PRESENTATION_NONE;
1334 // class SvxTextLineItem ------------------------------------------------
1336 SvxTextLineItem::SvxTextLineItem( const FontUnderline eSt, const USHORT nId )
1337 : SfxEnumItem( nId, (USHORT)eSt ), mColor( COL_TRANSPARENT )
1341 // -----------------------------------------------------------------------
1343 int SvxTextLineItem::HasBoolValue() const
1345 return sal_True;
1348 // -----------------------------------------------------------------------
1350 sal_Bool SvxTextLineItem::GetBoolValue() const
1352 return (FontUnderline)GetValue() != UNDERLINE_NONE;
1355 // -----------------------------------------------------------------------
1357 void SvxTextLineItem::SetBoolValue( sal_Bool bVal )
1359 SetValue( (USHORT)(bVal ? UNDERLINE_SINGLE : UNDERLINE_NONE) );
1362 // -----------------------------------------------------------------------
1364 SfxPoolItem* SvxTextLineItem::Clone( SfxItemPool * ) const
1366 SvxTextLineItem* pNew = new SvxTextLineItem( *this );
1367 pNew->SetColor( GetColor() );
1368 return pNew;
1371 // -----------------------------------------------------------------------
1373 USHORT SvxTextLineItem::GetValueCount() const
1375 return UNDERLINE_DOTTED + 1; // auch UNDERLINE_NONE geh"ort dazu
1378 // -----------------------------------------------------------------------
1380 SvStream& SvxTextLineItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
1382 rStrm << (BYTE)GetValue();
1383 return rStrm;
1386 // -----------------------------------------------------------------------
1388 SfxPoolItem* SvxTextLineItem::Create(SvStream& rStrm, USHORT) const
1390 BYTE nState;
1391 rStrm >> nState;
1392 return new SvxTextLineItem( (FontUnderline)nState, Which() );
1395 //------------------------------------------------------------------------
1397 SfxItemPresentation SvxTextLineItem::GetPresentation
1399 SfxItemPresentation ePres,
1400 SfxMapUnit /*eCoreUnit*/,
1401 SfxMapUnit /*ePresUnit*/,
1402 XubString& rText, const IntlWrapper * /*pIntl*/
1403 ) const
1405 #ifndef SVX_LIGHT
1406 switch ( ePres )
1408 case SFX_ITEM_PRESENTATION_NONE:
1409 rText.Erase();
1410 return ePres;
1411 case SFX_ITEM_PRESENTATION_NAMELESS:
1412 case SFX_ITEM_PRESENTATION_COMPLETE:
1413 rText = GetValueTextByPos( GetValue() );
1414 if( !mColor.GetTransparency() )
1415 ( rText += cpDelim ) += ::GetColorString( mColor );
1416 return ePres;
1417 default: ; //prevent warning
1419 #endif
1420 return SFX_ITEM_PRESENTATION_NONE;
1423 // -----------------------------------------------------------------------
1425 XubString SvxTextLineItem::GetValueTextByPos( USHORT /*nPos*/ ) const
1427 DBG_ERROR("SvxTextLineItem::GetValueTextByPos: Pure virtual method");
1428 return XubString();
1431 /*-----------------13.03.98 16:25-------------------
1433 --------------------------------------------------*/
1434 sal_Bool SvxTextLineItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
1436 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1437 nMemberId &= ~CONVERT_TWIPS;
1438 switch(nMemberId)
1440 case MID_TEXTLINED:
1441 rVal = Bool2Any(GetBoolValue());
1442 break;
1443 case MID_TL_STYLE:
1444 rVal <<= (sal_Int16)(GetValue());
1445 break;
1446 case MID_TL_COLOR:
1447 rVal <<= (sal_Int32)( mColor.GetColor() );
1448 break;
1449 case MID_TL_HASCOLOR:
1450 rVal = Bool2Any( !mColor.GetTransparency() );
1451 break;
1453 return sal_True;
1456 /*-----------------13.03.98 16:28-------------------
1458 --------------------------------------------------*/
1459 sal_Bool SvxTextLineItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
1461 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1462 nMemberId &= ~CONVERT_TWIPS;
1463 sal_Bool bRet = sal_True;
1464 switch(nMemberId)
1466 case MID_TEXTLINED:
1467 SetBoolValue(Any2Bool(rVal));
1468 break;
1469 case MID_TL_STYLE:
1471 sal_Int32 nValue = 0;
1472 if(!(rVal >>= nValue))
1473 bRet = sal_False;
1474 else
1475 SetValue((sal_Int16)nValue);
1477 break;
1478 case MID_TL_COLOR:
1480 sal_Int32 nCol = 0;
1481 if( !( rVal >>= nCol ) )
1482 bRet = sal_False;
1483 else
1485 // Keep transparence, because it contains the information
1486 // whether the font color or the stored color should be used
1487 sal_uInt8 nTrans = mColor.GetTransparency();
1488 mColor = Color( nCol );
1489 mColor.SetTransparency( nTrans );
1492 break;
1493 case MID_TL_HASCOLOR:
1494 mColor.SetTransparency( Any2Bool( rVal ) ? 0 : 0xff );
1495 break;
1497 return bRet;
1500 int SvxTextLineItem::operator==( const SfxPoolItem& rItem ) const
1502 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
1503 return SfxEnumItem::operator==( rItem ) &&
1504 GetColor() == ((SvxTextLineItem&)rItem).GetColor();
1507 // class SvxUnderlineItem ------------------------------------------------
1509 SvxUnderlineItem::SvxUnderlineItem( const FontUnderline eSt, const USHORT nId )
1510 : SvxTextLineItem( eSt, nId )
1514 //------------------------------------------------------------------------
1516 SfxPoolItem* SvxUnderlineItem::Clone( SfxItemPool * ) const
1518 SvxUnderlineItem* pNew = new SvxUnderlineItem( *this );
1519 pNew->SetColor( GetColor() );
1520 return pNew;
1523 // -----------------------------------------------------------------------
1525 SfxPoolItem* SvxUnderlineItem::Create(SvStream& rStrm, USHORT) const
1527 BYTE nState;
1528 rStrm >> nState;
1529 return new SvxUnderlineItem( (FontUnderline)nState, Which() );
1532 // -----------------------------------------------------------------------
1534 XubString SvxUnderlineItem::GetValueTextByPos( USHORT nPos ) const
1536 DBG_ASSERT( nPos <= (USHORT)UNDERLINE_BOLDWAVE, "enum overflow!" );
1537 return SVX_RESSTR( RID_SVXITEMS_UL_BEGIN + nPos );
1540 // class SvxOverlineItem ------------------------------------------------
1542 SvxOverlineItem::SvxOverlineItem( const FontUnderline eSt, const USHORT nId )
1543 : SvxTextLineItem( eSt, nId )
1547 //------------------------------------------------------------------------
1549 SfxPoolItem* SvxOverlineItem::Clone( SfxItemPool * ) const
1551 SvxOverlineItem* pNew = new SvxOverlineItem( *this );
1552 pNew->SetColor( GetColor() );
1553 return pNew;
1556 // -----------------------------------------------------------------------
1558 SfxPoolItem* SvxOverlineItem::Create(SvStream& rStrm, USHORT) const
1560 BYTE nState;
1561 rStrm >> nState;
1562 return new SvxOverlineItem( (FontUnderline)nState, Which() );
1565 // -----------------------------------------------------------------------
1567 XubString SvxOverlineItem::GetValueTextByPos( USHORT nPos ) const
1569 DBG_ASSERT( nPos <= (USHORT)UNDERLINE_BOLDWAVE, "enum overflow!" );
1570 return SVX_RESSTR( RID_SVXITEMS_OL_BEGIN + nPos );
1573 // class SvxCrossedOutItem -----------------------------------------------
1575 SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt, const USHORT nId )
1576 : SfxEnumItem( nId, (USHORT)eSt )
1580 // -----------------------------------------------------------------------
1582 int SvxCrossedOutItem::HasBoolValue() const
1584 return sal_True;
1587 // -----------------------------------------------------------------------
1589 sal_Bool SvxCrossedOutItem::GetBoolValue() const
1591 return (FontStrikeout)GetValue() != STRIKEOUT_NONE;
1594 // -----------------------------------------------------------------------
1596 void SvxCrossedOutItem::SetBoolValue( sal_Bool bVal )
1598 SetValue( (USHORT)(bVal ? STRIKEOUT_SINGLE : STRIKEOUT_NONE) );
1601 // -----------------------------------------------------------------------
1603 USHORT SvxCrossedOutItem::GetValueCount() const
1605 return STRIKEOUT_DOUBLE + 1; // auch STRIKEOUT_NONE geh"ort dazu
1608 // -----------------------------------------------------------------------
1610 SfxPoolItem* SvxCrossedOutItem::Clone( SfxItemPool * ) const
1612 return new SvxCrossedOutItem( *this );
1615 // -----------------------------------------------------------------------
1617 SvStream& SvxCrossedOutItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
1619 rStrm << (BYTE)GetValue();
1620 return rStrm;
1623 // -----------------------------------------------------------------------
1625 SfxPoolItem* SvxCrossedOutItem::Create(SvStream& rStrm, USHORT) const
1627 BYTE eCross;
1628 rStrm >> eCross;
1629 return new SvxCrossedOutItem( (FontStrikeout)eCross, Which() );
1632 //------------------------------------------------------------------------
1634 SfxItemPresentation SvxCrossedOutItem::GetPresentation
1636 SfxItemPresentation ePres,
1637 SfxMapUnit /*eCoreUnit*/,
1638 SfxMapUnit /*ePresUnit*/,
1639 XubString& rText, const IntlWrapper * /*pIntl*/
1640 ) const
1642 switch ( ePres )
1644 case SFX_ITEM_PRESENTATION_NONE:
1645 rText.Erase();
1646 return ePres;
1647 case SFX_ITEM_PRESENTATION_NAMELESS:
1648 case SFX_ITEM_PRESENTATION_COMPLETE:
1649 rText = GetValueTextByPos( GetValue() );
1650 return ePres;
1651 default: ;//prevent warning
1653 return SFX_ITEM_PRESENTATION_NONE;
1656 // -----------------------------------------------------------------------
1658 XubString SvxCrossedOutItem::GetValueTextByPos( USHORT nPos ) const
1660 DBG_ASSERT( nPos <= (USHORT)STRIKEOUT_X, "enum overflow!" );
1661 return SVX_RESSTR( RID_SVXITEMS_STRIKEOUT_BEGIN + nPos );
1664 /*-----------------13.03.98 16:28-------------------
1666 --------------------------------------------------*/
1667 sal_Bool SvxCrossedOutItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
1669 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1670 nMemberId &= ~CONVERT_TWIPS;
1671 switch(nMemberId)
1673 case MID_CROSSED_OUT:
1674 rVal = Bool2Any(GetBoolValue());
1675 break;
1676 case MID_CROSS_OUT:
1677 rVal <<= (sal_Int16)(GetValue());
1678 break;
1680 return sal_True;
1682 /*-----------------13.03.98 16:29-------------------
1684 --------------------------------------------------*/
1685 sal_Bool SvxCrossedOutItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
1687 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1688 nMemberId &= ~CONVERT_TWIPS;
1689 switch(nMemberId)
1691 case MID_CROSSED_OUT:
1692 SetBoolValue(Any2Bool(rVal));
1693 break;
1694 case MID_CROSS_OUT:
1696 sal_Int32 nValue = 0;
1697 if(!(rVal >>= nValue))
1698 return sal_False;
1699 SetValue((sal_Int16)nValue);
1701 break;
1703 return sal_True;
1705 // class SvxShadowedItem -------------------------------------------------
1707 SvxShadowedItem::SvxShadowedItem( const sal_Bool bShadowed, const USHORT nId ) :
1708 SfxBoolItem( nId, bShadowed )
1712 // -----------------------------------------------------------------------
1714 SfxPoolItem* SvxShadowedItem::Clone( SfxItemPool * ) const
1716 return new SvxShadowedItem( *this );
1719 // -----------------------------------------------------------------------
1721 SvStream& SvxShadowedItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
1723 rStrm << (BYTE) GetValue();
1724 return rStrm;
1727 // -----------------------------------------------------------------------
1729 SfxPoolItem* SvxShadowedItem::Create(SvStream& rStrm, USHORT) const
1731 BYTE nState;
1732 rStrm >> nState;
1733 return new SvxShadowedItem( nState, Which() );
1736 //------------------------------------------------------------------------
1738 SfxItemPresentation SvxShadowedItem::GetPresentation
1740 SfxItemPresentation ePres,
1741 SfxMapUnit /*eCoreUnit*/,
1742 SfxMapUnit /*ePresUnit*/,
1743 XubString& rText, const IntlWrapper * /*pIntl*/
1744 ) const
1746 switch ( ePres )
1748 case SFX_ITEM_PRESENTATION_NONE:
1749 rText.Erase();
1750 return ePres;
1751 case SFX_ITEM_PRESENTATION_NAMELESS:
1752 case SFX_ITEM_PRESENTATION_COMPLETE:
1754 USHORT nId = RID_SVXITEMS_SHADOWED_FALSE;
1756 if ( GetValue() )
1757 nId = RID_SVXITEMS_SHADOWED_TRUE;
1758 rText = SVX_RESSTR(nId);
1759 return ePres;
1761 default: ; //prevent warning
1763 return SFX_ITEM_PRESENTATION_NONE;
1766 // class SvxAutoKernItem -------------------------------------------------
1768 SvxAutoKernItem::SvxAutoKernItem( const sal_Bool bAutoKern, const USHORT nId ) :
1769 SfxBoolItem( nId, bAutoKern )
1773 // -----------------------------------------------------------------------
1775 SfxPoolItem* SvxAutoKernItem::Clone( SfxItemPool * ) const
1777 return new SvxAutoKernItem( *this );
1780 // -----------------------------------------------------------------------
1782 SvStream& SvxAutoKernItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
1784 rStrm << (BYTE) GetValue();
1785 return rStrm;
1788 // -----------------------------------------------------------------------
1790 SfxPoolItem* SvxAutoKernItem::Create(SvStream& rStrm, USHORT) const
1792 BYTE nState;
1793 rStrm >> nState;
1794 return new SvxAutoKernItem( nState, Which() );
1797 //------------------------------------------------------------------------
1799 SfxItemPresentation SvxAutoKernItem::GetPresentation
1801 SfxItemPresentation ePres,
1802 SfxMapUnit /*eCoreUnit*/,
1803 SfxMapUnit /*ePresUnit*/,
1804 XubString& rText, const IntlWrapper * /*pIntl*/
1805 ) const
1807 switch ( ePres )
1809 case SFX_ITEM_PRESENTATION_NONE:
1810 rText.Erase();
1811 return ePres;
1812 case SFX_ITEM_PRESENTATION_NAMELESS:
1813 case SFX_ITEM_PRESENTATION_COMPLETE:
1815 USHORT nId = RID_SVXITEMS_AUTOKERN_FALSE;
1817 if ( GetValue() )
1818 nId = RID_SVXITEMS_AUTOKERN_TRUE;
1819 rText = SVX_RESSTR(nId);
1820 return ePres;
1822 default: ; //prevent warning
1824 return SFX_ITEM_PRESENTATION_NONE;
1827 // class SvxWordLineModeItem ---------------------------------------------
1829 SvxWordLineModeItem::SvxWordLineModeItem( const sal_Bool bWordLineMode,
1830 const USHORT nId ) :
1831 SfxBoolItem( nId, bWordLineMode )
1835 // -----------------------------------------------------------------------
1837 SfxPoolItem* SvxWordLineModeItem::Clone( SfxItemPool * ) const
1839 return new SvxWordLineModeItem( *this );
1842 // -----------------------------------------------------------------------
1844 SvStream& SvxWordLineModeItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
1846 rStrm << (sal_Bool) GetValue();
1847 return rStrm;
1850 // -----------------------------------------------------------------------
1852 SfxPoolItem* SvxWordLineModeItem::Create(SvStream& rStrm, USHORT) const
1854 sal_Bool bValue;
1855 rStrm >> bValue;
1856 return new SvxWordLineModeItem( bValue, Which() );
1859 //------------------------------------------------------------------------
1861 SfxItemPresentation SvxWordLineModeItem::GetPresentation
1863 SfxItemPresentation ePres,
1864 SfxMapUnit /*eCoreUnit*/,
1865 SfxMapUnit /*ePresUnit*/,
1866 XubString& rText, const IntlWrapper * /*pIntl*/
1867 ) const
1869 switch ( ePres )
1871 case SFX_ITEM_PRESENTATION_NONE:
1872 rText.Erase();
1873 return ePres;
1874 case SFX_ITEM_PRESENTATION_NAMELESS:
1875 case SFX_ITEM_PRESENTATION_COMPLETE:
1877 USHORT nId = RID_SVXITEMS_WORDLINE_FALSE;
1879 if ( GetValue() )
1880 nId = RID_SVXITEMS_WORDLINE_TRUE;
1881 rText = SVX_RESSTR(nId);
1882 return ePres;
1884 default: ; //prevent warning
1886 return SFX_ITEM_PRESENTATION_NONE;
1889 // class SvxContourItem --------------------------------------------------
1891 SvxContourItem::SvxContourItem( const sal_Bool bContoured, const USHORT nId ) :
1892 SfxBoolItem( nId, bContoured )
1896 // -----------------------------------------------------------------------
1898 SfxPoolItem* SvxContourItem::Clone( SfxItemPool * ) const
1900 return new SvxContourItem( *this );
1903 // -----------------------------------------------------------------------
1905 SvStream& SvxContourItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
1907 rStrm << (sal_Bool) GetValue();
1908 return rStrm;
1911 // -----------------------------------------------------------------------
1913 SfxPoolItem* SvxContourItem::Create(SvStream& rStrm, USHORT) const
1915 sal_Bool bValue;
1916 rStrm >> bValue;
1917 return new SvxContourItem( bValue, Which() );
1920 //------------------------------------------------------------------------
1922 SfxItemPresentation SvxContourItem::GetPresentation
1924 SfxItemPresentation ePres,
1925 SfxMapUnit /*eCoreUnit*/,
1926 SfxMapUnit /*ePresUnit*/,
1927 XubString& rText, const IntlWrapper * /*pIntl*/
1928 ) const
1930 switch ( ePres )
1932 case SFX_ITEM_PRESENTATION_NONE:
1933 rText.Erase();
1934 return ePres;
1935 case SFX_ITEM_PRESENTATION_NAMELESS:
1936 case SFX_ITEM_PRESENTATION_COMPLETE:
1938 USHORT nId = RID_SVXITEMS_CONTOUR_FALSE;
1940 if ( GetValue() )
1941 nId = RID_SVXITEMS_CONTOUR_TRUE;
1942 rText = SVX_RESSTR(nId);
1943 return ePres;
1945 default: ; //prevent warning
1947 return SFX_ITEM_PRESENTATION_NONE;
1950 // class SvxPropSizeItem -------------------------------------------------
1952 SvxPropSizeItem::SvxPropSizeItem( const USHORT nPercent, const USHORT nId ) :
1953 SfxUInt16Item( nId, nPercent )
1957 // -----------------------------------------------------------------------
1959 SfxPoolItem* SvxPropSizeItem::Clone( SfxItemPool * ) const
1961 return new SvxPropSizeItem( *this );
1964 // -----------------------------------------------------------------------
1966 SvStream& SvxPropSizeItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
1968 rStrm << (USHORT) GetValue();
1969 return rStrm;
1972 // -----------------------------------------------------------------------
1974 SfxPoolItem* SvxPropSizeItem::Create(SvStream& rStrm, USHORT) const
1976 USHORT nSize;
1977 rStrm >> nSize;
1978 return new SvxPropSizeItem( nSize, Which() );
1981 //------------------------------------------------------------------------
1983 SfxItemPresentation SvxPropSizeItem::GetPresentation
1985 SfxItemPresentation /*ePres*/,
1986 SfxMapUnit /*eCoreUnit*/,
1987 SfxMapUnit /*ePresUnit*/,
1988 XubString& rText, const IntlWrapper * /*pIntl*/
1989 ) const
1991 rText.Erase();
1992 return SFX_ITEM_PRESENTATION_NONE;
1995 // class SvxColorItem ----------------------------------------------------
1997 SvxColorItem::SvxColorItem( const USHORT nId ) :
1998 SfxPoolItem( nId ),
1999 mColor( COL_BLACK )
2003 // -----------------------------------------------------------------------
2005 SvxColorItem::SvxColorItem( const Color& rCol, const USHORT nId ) :
2006 SfxPoolItem( nId ),
2007 mColor( rCol )
2011 // -----------------------------------------------------------------------
2013 SvxColorItem::SvxColorItem( SvStream &rStrm, const USHORT nId ) :
2014 SfxPoolItem( nId )
2016 Color aColor;
2017 rStrm >> aColor;
2018 mColor = aColor;
2021 // -----------------------------------------------------------------------
2023 SvxColorItem::SvxColorItem( const SvxColorItem &rCopy ) :
2024 SfxPoolItem( rCopy ),
2025 mColor( rCopy.mColor )
2029 // -----------------------------------------------------------------------
2031 SvxColorItem::~SvxColorItem()
2035 // -----------------------------------------------------------------------
2036 USHORT SvxColorItem::GetVersion( USHORT nFFVer ) const
2038 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
2039 SOFFICE_FILEFORMAT_40==nFFVer ||
2040 SOFFICE_FILEFORMAT_50==nFFVer,
2041 "SvxColorItem: Gibt es ein neues Fileformat?" );
2042 return SOFFICE_FILEFORMAT_50 >= nFFVer ? VERSION_USEAUTOCOLOR : 0;
2045 // -----------------------------------------------------------------------
2047 int SvxColorItem::operator==( const SfxPoolItem& rAttr ) const
2049 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
2051 return mColor == ( (const SvxColorItem&)rAttr ).mColor;
2054 // -----------------------------------------------------------------------
2056 sal_Bool SvxColorItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/ ) const
2058 rVal <<= (sal_Int32)(mColor.GetColor());
2059 return sal_True;
2062 // -----------------------------------------------------------------------
2064 sal_Bool SvxColorItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/ )
2066 sal_Int32 nColor = 0;
2067 if(!(rVal >>= nColor))
2068 return sal_False;
2070 mColor.SetColor( nColor );
2071 return sal_True;
2074 // -----------------------------------------------------------------------
2076 SfxPoolItem* SvxColorItem::Clone( SfxItemPool * ) const
2078 return new SvxColorItem( *this );
2081 // -----------------------------------------------------------------------
2083 SvStream& SvxColorItem::Store( SvStream& rStrm , USHORT nItemVersion ) const
2085 if( VERSION_USEAUTOCOLOR == nItemVersion &&
2086 COL_AUTO == mColor.GetColor() )
2087 rStrm << Color( COL_BLACK );
2088 else
2089 rStrm << mColor;
2090 return rStrm;
2093 // -----------------------------------------------------------------------
2095 SfxPoolItem* SvxColorItem::Create(SvStream& rStrm, USHORT /*nVer*/ ) const
2097 return new SvxColorItem( rStrm, Which() );
2100 //------------------------------------------------------------------------
2102 SfxItemPresentation SvxColorItem::GetPresentation
2104 SfxItemPresentation ePres,
2105 SfxMapUnit /*eCoreUnit*/,
2106 SfxMapUnit /*ePresUnit*/,
2107 XubString& rText, const IntlWrapper * /*pIntl*/
2108 ) const
2110 #ifndef SVX_LIGHT
2111 switch ( ePres )
2113 case SFX_ITEM_PRESENTATION_NONE:
2114 rText.Erase();
2115 return ePres;
2116 case SFX_ITEM_PRESENTATION_NAMELESS:
2117 case SFX_ITEM_PRESENTATION_COMPLETE:
2118 rText = ::GetColorString( mColor );
2119 return ePres;
2120 default: ; //prevent warning
2122 #endif
2123 return SFX_ITEM_PRESENTATION_NONE;
2126 // -----------------------------------------------------------------------
2128 void SvxColorItem::SetValue( const Color& rNewCol )
2130 mColor = rNewCol;
2133 // class SvxCharSetColorItem ---------------------------------------------
2135 SvxCharSetColorItem::SvxCharSetColorItem( const USHORT nId ) :
2136 SvxColorItem( nId ),
2138 eFrom( RTL_TEXTENCODING_DONTKNOW )
2142 // -----------------------------------------------------------------------
2144 SvxCharSetColorItem::SvxCharSetColorItem( const Color& rCol,
2145 const rtl_TextEncoding _eFrom,
2146 const USHORT nId ) :
2147 SvxColorItem( rCol, nId ),
2149 eFrom( _eFrom )
2154 // -----------------------------------------------------------------------
2156 SfxPoolItem* SvxCharSetColorItem::Clone( SfxItemPool * ) const
2158 return new SvxCharSetColorItem( *this );
2161 // -----------------------------------------------------------------------
2163 SvStream& SvxCharSetColorItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
2165 // #90477# rStrm << (BYTE) GetStoreCharSet( GetCharSet(), (USHORT)rStrm.GetVersion() )
2166 // << GetValue();
2167 rStrm << (BYTE)GetSOStoreTextEncoding(GetCharSet(), (sal_uInt16)rStrm.GetVersion())
2168 << GetValue();
2169 return rStrm;
2172 // -----------------------------------------------------------------------
2174 SfxPoolItem* SvxCharSetColorItem::Create(SvStream& rStrm, USHORT) const
2176 BYTE cSet;
2177 Color aColor;
2178 rStrm >> cSet >> aColor;
2179 return new SvxCharSetColorItem( aColor, (rtl_TextEncoding)cSet, Which() );
2182 //------------------------------------------------------------------------
2184 SfxItemPresentation SvxCharSetColorItem::GetPresentation
2186 SfxItemPresentation /*ePres*/,
2187 SfxMapUnit /*eCoreUnit*/,
2188 SfxMapUnit /*ePresUnit*/,
2189 XubString& rText, const IntlWrapper * /*pIntl*/
2190 ) const
2192 rText.Erase();
2193 return SFX_ITEM_PRESENTATION_NONE;
2196 // class SvxKerningItem --------------------------------------------------
2198 SvxKerningItem::SvxKerningItem( const short nKern, const USHORT nId ) :
2199 SfxInt16Item( nId, nKern )
2203 // -----------------------------------------------------------------------
2205 SfxPoolItem* SvxKerningItem::Clone( SfxItemPool * ) const
2207 return new SvxKerningItem( *this );
2210 // -----------------------------------------------------------------------
2212 SvStream& SvxKerningItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
2214 rStrm << (short) GetValue();
2215 return rStrm;
2218 // -----------------------------------------------------------------------
2220 int SvxKerningItem::ScaleMetrics( long nMult, long nDiv )
2222 SetValue( (sal_Int16)Scale( GetValue(), nMult, nDiv ) );
2223 return 1;
2226 // -----------------------------------------------------------------------
2228 int SvxKerningItem::HasMetrics() const
2230 return 1;
2233 // -----------------------------------------------------------------------
2235 SfxPoolItem* SvxKerningItem::Create(SvStream& rStrm, USHORT) const
2237 short nValue;
2238 rStrm >> nValue;
2239 return new SvxKerningItem( nValue, Which() );
2242 //------------------------------------------------------------------------
2244 SfxItemPresentation SvxKerningItem::GetPresentation
2246 SfxItemPresentation ePres,
2247 SfxMapUnit eCoreUnit,
2248 SfxMapUnit /*ePresUnit*/,
2249 XubString& rText, const IntlWrapper *pIntl
2250 ) const
2252 #ifndef SVX_LIGHT
2253 switch ( ePres )
2255 case SFX_ITEM_PRESENTATION_NONE:
2256 rText.Erase();
2257 return ePres;
2258 case SFX_ITEM_PRESENTATION_NAMELESS:
2259 rText = GetMetricText( (long)GetValue(), eCoreUnit, SFX_MAPUNIT_POINT, pIntl );
2260 rText += SVX_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
2261 return ePres;
2262 case SFX_ITEM_PRESENTATION_COMPLETE:
2264 rText = SVX_RESSTR(RID_SVXITEMS_KERNING_COMPLETE);
2265 USHORT nId = 0;
2267 if ( GetValue() > 0 )
2268 nId = RID_SVXITEMS_KERNING_EXPANDED;
2269 else if ( GetValue() < 0 )
2270 nId = RID_SVXITEMS_KERNING_CONDENSED;
2272 if ( nId )
2273 rText += SVX_RESSTR(nId);
2274 rText += GetMetricText( (long)GetValue(), eCoreUnit, SFX_MAPUNIT_POINT, pIntl );
2275 rText += SVX_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
2276 return ePres;
2278 default: ; //prevent warning
2280 #endif
2281 return SFX_ITEM_PRESENTATION_NONE;
2283 /* -----------------------------19.02.01 12:21--------------------------------
2285 ---------------------------------------------------------------------------*/
2286 sal_Bool SvxKerningItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
2288 sal_Int16 nVal = GetValue();
2289 if(nMemberId & CONVERT_TWIPS)
2290 nVal = (sal_Int16)TWIP_TO_MM100(nVal);
2291 rVal <<= nVal;
2292 return sal_True;
2294 // -----------------------------------------------------------------------
2295 sal_Bool SvxKerningItem::PutValue( const uno::Any& rVal, BYTE nMemberId)
2297 sal_Int16 nVal = sal_Int16();
2298 if(!(rVal >>= nVal))
2299 return sal_False;
2300 if(nMemberId & CONVERT_TWIPS)
2301 nVal = (sal_Int16)MM100_TO_TWIP(nVal);
2302 SetValue(nVal);
2303 return sal_True;
2306 // class SvxCaseMapItem --------------------------------------------------
2308 SvxCaseMapItem::SvxCaseMapItem( const SvxCaseMap eMap, const USHORT nId ) :
2309 SfxEnumItem( nId, (USHORT)eMap )
2313 // -----------------------------------------------------------------------
2315 USHORT SvxCaseMapItem::GetValueCount() const
2317 return SVX_CASEMAP_END; // SVX_CASEMAP_KAPITAELCHEN + 1
2320 // -----------------------------------------------------------------------
2322 SfxPoolItem* SvxCaseMapItem::Clone( SfxItemPool * ) const
2324 return new SvxCaseMapItem( *this );
2327 // -----------------------------------------------------------------------
2329 SvStream& SvxCaseMapItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
2331 rStrm << (BYTE) GetValue();
2332 return rStrm;
2335 // -----------------------------------------------------------------------
2337 SfxPoolItem* SvxCaseMapItem::Create(SvStream& rStrm, USHORT) const
2339 BYTE cMap;
2340 rStrm >> cMap;
2341 return new SvxCaseMapItem( (const SvxCaseMap)cMap, Which() );
2344 //------------------------------------------------------------------------
2346 SfxItemPresentation SvxCaseMapItem::GetPresentation
2348 SfxItemPresentation ePres,
2349 SfxMapUnit /*eCoreUnit*/,
2350 SfxMapUnit /*ePresUnit*/,
2351 XubString& rText, const IntlWrapper * /*pIntl*/
2352 ) const
2354 switch ( ePres )
2356 case SFX_ITEM_PRESENTATION_NONE:
2357 rText.Erase();
2358 return ePres;
2359 case SFX_ITEM_PRESENTATION_NAMELESS:
2360 case SFX_ITEM_PRESENTATION_COMPLETE:
2361 rText = GetValueTextByPos( GetValue() );
2362 return ePres;
2363 default: ; //prevent warning
2365 return SFX_ITEM_PRESENTATION_NONE;
2368 // -----------------------------------------------------------------------
2370 XubString SvxCaseMapItem::GetValueTextByPos( USHORT nPos ) const
2372 DBG_ASSERT( nPos < (USHORT)SVX_CASEMAP_END, "enum overflow!" );
2373 return SVX_RESSTR( RID_SVXITEMS_CASEMAP_BEGIN + nPos );
2376 /*-----------------13.03.98 16:29-------------------
2378 --------------------------------------------------*/
2379 sal_Bool SvxCaseMapItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/ ) const
2381 sal_Int16 nRet = style::CaseMap::NONE;
2382 switch( GetValue() )
2384 // case SVX_CASEMAP_NOT_MAPPED : nRet = style::CaseMap::NONE ; break;
2385 case SVX_CASEMAP_VERSALIEN : nRet = style::CaseMap::UPPERCASE; break;
2386 case SVX_CASEMAP_GEMEINE : nRet = style::CaseMap::LOWERCASE; break;
2387 case SVX_CASEMAP_TITEL : nRet = style::CaseMap::TITLE ; break;
2388 case SVX_CASEMAP_KAPITAELCHEN: nRet = style::CaseMap::SMALLCAPS; break;
2390 rVal <<= (sal_Int16)(nRet);
2391 return sal_True;
2393 /*-----------------13.03.98 16:29-------------------
2395 --------------------------------------------------*/
2396 sal_Bool SvxCaseMapItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/ )
2398 sal_uInt16 nVal = sal_uInt16();
2399 if(!(rVal >>= nVal))
2400 return sal_False;
2402 switch( nVal )
2404 case style::CaseMap::NONE : nVal = SVX_CASEMAP_NOT_MAPPED ; break;
2405 case style::CaseMap::UPPERCASE: nVal = SVX_CASEMAP_VERSALIEN ; break;
2406 case style::CaseMap::LOWERCASE: nVal = SVX_CASEMAP_GEMEINE ; break;
2407 case style::CaseMap::TITLE : nVal = SVX_CASEMAP_TITEL ; break;
2408 case style::CaseMap::SMALLCAPS: nVal = SVX_CASEMAP_KAPITAELCHEN; break;
2410 SetValue(nVal);
2411 return sal_True;
2414 // class SvxEscapementItem -----------------------------------------------
2416 SvxEscapementItem::SvxEscapementItem( const USHORT nId ) :
2417 SfxEnumItemInterface( nId ),
2419 nEsc ( 0 ),
2420 nProp ( 100 )
2424 // -----------------------------------------------------------------------
2426 SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape,
2427 const USHORT nId ) :
2428 SfxEnumItemInterface( nId ),
2429 nProp( 100 )
2431 SetEscapement( eEscape );
2432 if( nEsc )
2433 nProp = 58;
2436 // -----------------------------------------------------------------------
2438 SvxEscapementItem::SvxEscapementItem( const short _nEsc,
2439 const BYTE _nProp,
2440 const USHORT nId ) :
2441 SfxEnumItemInterface( nId ),
2442 nEsc ( _nEsc ),
2443 nProp ( _nProp )
2447 // -----------------------------------------------------------------------
2449 int SvxEscapementItem::operator==( const SfxPoolItem& rAttr ) const
2451 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
2453 return( nEsc == ((SvxEscapementItem&)rAttr).nEsc &&
2454 nProp == ((SvxEscapementItem&)rAttr).nProp );
2457 // -----------------------------------------------------------------------
2459 SfxPoolItem* SvxEscapementItem::Clone( SfxItemPool * ) const
2461 return new SvxEscapementItem( *this );
2464 // -----------------------------------------------------------------------
2466 SvStream& SvxEscapementItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
2468 short _nEsc = GetEsc();
2469 if( SOFFICE_FILEFORMAT_31 == rStrm.GetVersion() )
2471 if( DFLT_ESC_AUTO_SUPER == _nEsc )
2472 _nEsc = DFLT_ESC_SUPER;
2473 else if( DFLT_ESC_AUTO_SUB == _nEsc )
2474 _nEsc = DFLT_ESC_SUB;
2476 rStrm << (BYTE) GetProp()
2477 << (short) _nEsc;
2478 return rStrm;
2481 // -----------------------------------------------------------------------
2483 SfxPoolItem* SvxEscapementItem::Create(SvStream& rStrm, USHORT) const
2485 BYTE _nProp;
2486 short _nEsc;
2487 rStrm >> _nProp >> _nEsc;
2488 return new SvxEscapementItem( _nEsc, _nProp, Which() );
2491 // -----------------------------------------------------------------------
2493 USHORT SvxEscapementItem::GetValueCount() const
2495 return SVX_ESCAPEMENT_END; // SVX_ESCAPEMENT_SUBSCRIPT + 1
2498 //------------------------------------------------------------------------
2500 SfxItemPresentation SvxEscapementItem::GetPresentation
2502 SfxItemPresentation ePres,
2503 SfxMapUnit /*eCoreUnit*/,
2504 SfxMapUnit /*ePresUnit*/,
2505 XubString& rText, const IntlWrapper * /*pIntl*/
2506 ) const
2508 switch ( ePres )
2510 case SFX_ITEM_PRESENTATION_NONE:
2511 rText.Erase();
2512 return ePres;
2513 case SFX_ITEM_PRESENTATION_NAMELESS:
2514 case SFX_ITEM_PRESENTATION_COMPLETE:
2516 rText = GetValueTextByPos( GetEnumValue() );
2518 if ( nEsc != 0 )
2520 if( DFLT_ESC_AUTO_SUPER == nEsc || DFLT_ESC_AUTO_SUB == nEsc )
2521 rText += String( SVX_RESSTR(RID_SVXITEMS_ESCAPEMENT_AUTO) );
2522 else
2523 ( rText += String::CreateFromInt32( nEsc )) += sal_Unicode('%');
2525 return ePres;
2527 default: ; //prevent warning
2529 return SFX_ITEM_PRESENTATION_NONE;
2532 // -----------------------------------------------------------------------
2534 XubString SvxEscapementItem::GetValueTextByPos( USHORT nPos ) const
2536 DBG_ASSERT( nPos < (USHORT)SVX_ESCAPEMENT_END, "enum overflow!" );
2537 return SVX_RESSTR(RID_SVXITEMS_ESCAPEMENT_BEGIN + nPos);
2540 // -----------------------------------------------------------------------
2542 USHORT SvxEscapementItem::GetEnumValue() const
2544 if ( nEsc < 0 )
2545 return SVX_ESCAPEMENT_SUBSCRIPT;
2546 else if ( nEsc > 0 )
2547 return SVX_ESCAPEMENT_SUPERSCRIPT;
2548 return SVX_ESCAPEMENT_OFF;
2551 // -----------------------------------------------------------------------
2553 void SvxEscapementItem::SetEnumValue( USHORT nVal )
2555 SetEscapement( (const SvxEscapement)nVal );
2558 /*-----------------13.03.98 17:05-------------------
2560 --------------------------------------------------*/
2561 sal_Bool SvxEscapementItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
2563 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2564 nMemberId &= ~CONVERT_TWIPS;
2565 switch(nMemberId)
2567 case MID_ESC:
2568 rVal <<= (sal_Int16)(nEsc);
2569 break;
2570 case MID_ESC_HEIGHT:
2571 rVal <<= (sal_Int8)(nProp);
2572 break;
2573 case MID_AUTO_ESC:
2574 rVal = Bool2Any(DFLT_ESC_AUTO_SUB == nEsc || DFLT_ESC_AUTO_SUPER == nEsc);
2575 break;
2577 return sal_True;
2579 /*-----------------13.03.98 17:05-------------------
2581 --------------------------------------------------*/
2582 sal_Bool SvxEscapementItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
2584 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2585 nMemberId &= ~CONVERT_TWIPS;
2586 switch(nMemberId)
2588 case MID_ESC:
2590 sal_Int16 nVal = sal_Int16();
2591 if( (rVal >>= nVal) && (Abs(nVal) <= 101))
2592 nEsc = nVal;
2593 else
2594 return sal_False;
2596 break;
2597 case MID_ESC_HEIGHT:
2599 sal_Int8 nVal = sal_Int8();
2600 if( (rVal >>= nVal) && (nVal <= 100))
2601 nProp = nVal;
2602 else
2603 return sal_False;
2605 break;
2606 case MID_AUTO_ESC:
2608 BOOL bVal = Any2Bool(rVal);
2609 if(bVal)
2611 if(nEsc < 0)
2612 nEsc = DFLT_ESC_AUTO_SUB;
2613 else
2614 nEsc = DFLT_ESC_AUTO_SUPER;
2616 else
2617 if(DFLT_ESC_AUTO_SUPER == nEsc )
2618 --nEsc;
2619 else if(DFLT_ESC_AUTO_SUB == nEsc)
2620 ++nEsc;
2622 break;
2624 return sal_True;
2627 // class SvxLanguageItem -------------------------------------------------
2629 SvxLanguageItem::SvxLanguageItem( const LanguageType eLang, const USHORT nId )
2630 : SfxEnumItem( nId , eLang )
2634 // -----------------------------------------------------------------------
2636 USHORT SvxLanguageItem::GetValueCount() const
2638 // #i50205# got rid of class International
2639 DBG_ERRORFILE("SvxLanguageItem::GetValueCount: supposed to return a count of what?");
2640 // FIXME: previously returned LANGUAGE_COUNT from tools/intn.hxx which was wrong anyway.
2641 // Could be SvtLanguageTable::GetEntryCount() (all locales with resource string)?
2642 // Could be LocaleDataWrapper::getInstalledLanguageTypes() (all locales with locale data)?
2643 return 0;
2646 // -----------------------------------------------------------------------
2648 SfxPoolItem* SvxLanguageItem::Clone( SfxItemPool * ) const
2650 return new SvxLanguageItem( *this );
2653 // -----------------------------------------------------------------------
2655 SvStream& SvxLanguageItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
2657 rStrm << (USHORT) GetValue();
2658 return rStrm;
2661 // -----------------------------------------------------------------------
2663 SfxPoolItem* SvxLanguageItem::Create(SvStream& rStrm, USHORT) const
2665 USHORT nValue;
2666 rStrm >> nValue;
2667 return new SvxLanguageItem( (LanguageType)nValue, Which() );
2670 //------------------------------------------------------------------------
2672 SfxItemPresentation SvxLanguageItem::GetPresentation
2674 SfxItemPresentation ePres,
2675 SfxMapUnit /*eCoreUnit*/,
2676 SfxMapUnit /*ePresUnit*/,
2677 XubString& rText, const IntlWrapper * /*pIntl*/
2678 ) const
2680 #ifndef SVX_LIGHT
2681 switch ( ePres )
2683 case SFX_ITEM_PRESENTATION_NONE:
2684 rText.Erase();
2685 return ePres;
2686 case SFX_ITEM_PRESENTATION_NAMELESS:
2687 case SFX_ITEM_PRESENTATION_COMPLETE:
2689 SvtLanguageTable aLangTable;
2690 rText = aLangTable.GetString( (LanguageType)GetValue() );
2691 return ePres;
2693 default: ; //prevent warning
2695 #endif // !SVX_LIGHT
2696 return SFX_ITEM_PRESENTATION_NONE;
2699 /*-----------------14.03.98 14:13-------------------
2701 --------------------------------------------------*/
2702 sal_Bool SvxLanguageItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
2704 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2705 nMemberId &= ~CONVERT_TWIPS;
2706 switch(nMemberId)
2708 case MID_LANG_INT: // for basic conversions!
2709 rVal <<= (sal_Int16)(GetValue());
2710 break;
2711 case MID_LANG_LOCALE:
2712 lang::Locale aRet( MsLangId::convertLanguageToLocale( GetValue(), false));
2713 rVal <<= aRet;
2714 break;
2716 return sal_True;
2718 /*-----------------14.03.98 14:13-------------------
2720 --------------------------------------------------*/
2721 sal_Bool SvxLanguageItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
2723 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2724 nMemberId &= ~CONVERT_TWIPS;
2725 switch(nMemberId)
2727 case MID_LANG_INT: // for basic conversions!
2729 sal_Int32 nValue = 0;
2730 if(!(rVal >>= nValue))
2731 return sal_False;
2733 SetValue((sal_Int16)nValue);
2735 break;
2736 case MID_LANG_LOCALE:
2738 lang::Locale aLocale;
2739 if(!(rVal >>= aLocale))
2740 return sal_False;
2742 if (aLocale.Language.getLength() || aLocale.Country.getLength())
2743 SetValue(MsLangId::convertLocaleToLanguage( aLocale ));
2744 else
2745 SetValue(LANGUAGE_NONE);
2747 break;
2749 return sal_True;
2752 // class SvxNoLinebreakItem ----------------------------------------------
2753 SvxNoLinebreakItem::SvxNoLinebreakItem( const sal_Bool bBreak, const USHORT nId ) :
2754 SfxBoolItem( nId, bBreak )
2758 // -----------------------------------------------------------------------
2760 SfxPoolItem* SvxNoLinebreakItem::Clone( SfxItemPool* ) const
2762 return new SvxNoLinebreakItem( *this );
2765 // -----------------------------------------------------------------------
2767 SvStream& SvxNoLinebreakItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
2769 rStrm << (sal_Bool)GetValue();
2770 return rStrm;
2773 // -----------------------------------------------------------------------
2775 SfxPoolItem* SvxNoLinebreakItem::Create(SvStream& rStrm, USHORT) const
2777 sal_Bool bValue;
2778 rStrm >> bValue;
2779 return new SvxNoLinebreakItem( bValue, Which() );
2782 //------------------------------------------------------------------------
2784 SfxItemPresentation SvxNoLinebreakItem::GetPresentation
2786 SfxItemPresentation /*ePres*/,
2787 SfxMapUnit /*eCoreUnit*/,
2788 SfxMapUnit /*ePresUnit*/,
2789 XubString& rText, const IntlWrapper * /*pIntl*/
2790 ) const
2792 rText.Erase();
2793 return SFX_ITEM_PRESENTATION_NONE;
2796 // class SvxNoHyphenItem -------------------------------------------------
2798 SvxNoHyphenItem::SvxNoHyphenItem( const sal_Bool bHyphen, const USHORT nId ) :
2799 SfxBoolItem( nId , bHyphen )
2803 // -----------------------------------------------------------------------
2805 SfxPoolItem* SvxNoHyphenItem::Clone( SfxItemPool* ) const
2807 return new SvxNoHyphenItem( *this );
2810 // -----------------------------------------------------------------------
2812 SvStream& SvxNoHyphenItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
2814 rStrm << (sal_Bool) GetValue();
2815 return rStrm;
2818 // -----------------------------------------------------------------------
2820 SfxPoolItem* SvxNoHyphenItem::Create( SvStream& rStrm, USHORT ) const
2822 sal_Bool bValue;
2823 rStrm >> bValue;
2824 return new SvxNoHyphenItem( bValue, Which() );
2827 //------------------------------------------------------------------------
2829 SfxItemPresentation SvxNoHyphenItem::GetPresentation
2831 SfxItemPresentation /*ePres*/,
2832 SfxMapUnit /*eCoreUnit*/,
2833 SfxMapUnit /*ePresUnit*/,
2834 XubString& rText, const IntlWrapper * /*pIntl*/
2835 ) const
2837 rText.Erase();
2838 return SFX_ITEM_PRESENTATION_NONE;
2842 * Dummy-Item fuer ToolBox-Controls:
2846 // -----------------------------------------------------------------------
2847 // class SvxLineColorItem (== SvxColorItem)
2848 // -----------------------------------------------------------------------
2850 SvxLineColorItem::SvxLineColorItem( const USHORT nId ) :
2851 SvxColorItem( nId )
2855 // -----------------------------------------------------------------------
2857 SvxLineColorItem::SvxLineColorItem( const Color& rCol, const USHORT nId ) :
2858 SvxColorItem( rCol, nId )
2862 // -----------------------------------------------------------------------
2864 SvxLineColorItem::SvxLineColorItem( SvStream &rStrm, const USHORT nId ) :
2865 SvxColorItem( rStrm, nId )
2869 // -----------------------------------------------------------------------
2871 SvxLineColorItem::SvxLineColorItem( const SvxLineColorItem &rCopy ) :
2872 SvxColorItem( rCopy )
2876 // -----------------------------------------------------------------------
2878 SvxLineColorItem::~SvxLineColorItem()
2882 //------------------------------------------------------------------------
2884 SfxItemPresentation SvxLineColorItem::GetPresentation
2886 SfxItemPresentation ePres,
2887 SfxMapUnit eCoreUnit,
2888 SfxMapUnit ePresUnit,
2889 XubString& rText,
2890 const IntlWrapper * pIntlWrapper
2891 ) const
2893 return SvxColorItem::GetPresentation( ePres, eCoreUnit, ePresUnit,
2894 rText, pIntlWrapper );
2897 // class SvxBlinkItem -------------------------------------------------
2900 SvxBlinkItem::SvxBlinkItem( const sal_Bool bBlink, const USHORT nId ) :
2901 SfxBoolItem( nId, bBlink )
2905 // -----------------------------------------------------------------------
2907 SfxPoolItem* SvxBlinkItem::Clone( SfxItemPool * ) const
2909 return new SvxBlinkItem( *this );
2912 // -----------------------------------------------------------------------
2914 SvStream& SvxBlinkItem::Store( SvStream& rStrm , USHORT /*nItemVersion*/ ) const
2916 rStrm << (BYTE) GetValue();
2917 return rStrm;
2920 // -----------------------------------------------------------------------
2922 SfxPoolItem* SvxBlinkItem::Create(SvStream& rStrm, USHORT) const
2924 BYTE nState;
2925 rStrm >> nState;
2926 return new SvxBlinkItem( nState, Which() );
2929 // -----------------------------------------------------------------------
2931 SfxItemPresentation SvxBlinkItem::GetPresentation
2933 SfxItemPresentation ePres,
2934 SfxMapUnit /*eCoreUnit*/,
2935 SfxMapUnit /*ePresUnit*/,
2936 XubString& rText, const IntlWrapper * /*pIntl*/
2937 ) const
2939 switch ( ePres )
2941 case SFX_ITEM_PRESENTATION_NONE:
2942 rText.Erase();
2943 return ePres;
2944 case SFX_ITEM_PRESENTATION_NAMELESS:
2945 case SFX_ITEM_PRESENTATION_COMPLETE:
2947 USHORT nId = RID_SVXITEMS_BLINK_FALSE;
2949 if ( GetValue() )
2950 nId = RID_SVXITEMS_BLINK_TRUE;
2951 rText = SVX_RESSTR(nId);
2952 return ePres;
2954 default: ; //prevent warning
2956 return SFX_ITEM_PRESENTATION_NONE;
2959 // class SvxEmphaisMarkItem ---------------------------------------------------
2961 SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue,
2962 const USHORT nId )
2963 : SfxUInt16Item( nId, nValue )
2967 // -----------------------------------------------------------------------
2969 SfxPoolItem* SvxEmphasisMarkItem::Clone( SfxItemPool * ) const
2971 return new SvxEmphasisMarkItem( *this );
2974 // -----------------------------------------------------------------------
2976 SvStream& SvxEmphasisMarkItem::Store( SvStream& rStrm,
2977 USHORT /*nItemVersion*/ ) const
2979 rStrm << (sal_uInt16)GetValue();
2980 return rStrm;
2983 // -----------------------------------------------------------------------
2985 SfxPoolItem* SvxEmphasisMarkItem::Create( SvStream& rStrm, USHORT ) const
2987 sal_uInt16 nValue;
2988 rStrm >> nValue;
2989 return new SvxEmphasisMarkItem( (FontEmphasisMark)nValue, Which() );
2992 //------------------------------------------------------------------------
2994 SfxItemPresentation SvxEmphasisMarkItem::GetPresentation
2996 SfxItemPresentation ePres,
2997 SfxMapUnit /*eCoreUnit*/,
2998 SfxMapUnit /*ePresUnit*/,
2999 XubString& rText,
3000 const IntlWrapper * /*pIntl*/
3001 ) const
3003 switch ( ePres )
3005 case SFX_ITEM_PRESENTATION_NONE:
3006 rText.Erase();
3007 return ePres;
3008 case SFX_ITEM_PRESENTATION_NAMELESS:
3009 case SFX_ITEM_PRESENTATION_COMPLETE:
3011 sal_uInt16 nVal = GetValue();
3012 rText = SVX_RESSTR( RID_SVXITEMS_EMPHASIS_BEGIN_STYLE +
3013 ( EMPHASISMARK_STYLE & nVal ));
3014 USHORT nId = ( EMPHASISMARK_POS_ABOVE & nVal )
3015 ? RID_SVXITEMS_EMPHASIS_ABOVE_POS
3016 : ( EMPHASISMARK_POS_BELOW & nVal )
3017 ? RID_SVXITEMS_EMPHASIS_BELOW_POS
3018 : 0;
3019 if( nId )
3020 rText += SVX_RESSTR( nId );
3021 return ePres;
3023 default: ; //prevent warning
3025 return SFX_ITEM_PRESENTATION_NONE;
3028 // -----------------------------------------------------------------------
3030 sal_Bool SvxEmphasisMarkItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
3032 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3033 nMemberId &= ~CONVERT_TWIPS;
3034 switch( nMemberId )
3036 case MID_EMPHASIS:
3038 sal_Int16 nValue = GetValue();
3039 sal_Int16 nRet = 0;
3040 switch(nValue & EMPHASISMARK_STYLE)
3042 case EMPHASISMARK_NONE : nRet = FontEmphasis::NONE; break;
3043 case EMPHASISMARK_DOT : nRet = FontEmphasis::DOT_ABOVE; break;
3044 case EMPHASISMARK_CIRCLE : nRet = FontEmphasis::CIRCLE_ABOVE; break;
3045 case EMPHASISMARK_DISC : nRet = FontEmphasis::DISK_ABOVE; break;
3046 case EMPHASISMARK_ACCENT : nRet = FontEmphasis::ACCENT_ABOVE; break;
3048 if(nRet && nValue & EMPHASISMARK_POS_BELOW)
3049 nRet += 10;
3050 rVal <<= nRet;
3052 break;
3054 return sal_True;
3057 sal_Bool SvxEmphasisMarkItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
3059 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3060 nMemberId &= ~CONVERT_TWIPS;
3061 sal_Bool bRet = sal_True;
3062 switch( nMemberId )
3064 case MID_EMPHASIS:
3066 sal_Int32 nValue = -1;
3067 rVal >>= nValue;
3068 switch(nValue)
3070 case FontEmphasis::NONE : nValue = EMPHASISMARK_NONE; break;
3071 case FontEmphasis::DOT_ABOVE : nValue = EMPHASISMARK_DOT|EMPHASISMARK_POS_ABOVE; break;
3072 case FontEmphasis::CIRCLE_ABOVE: nValue = EMPHASISMARK_CIRCLE|EMPHASISMARK_POS_ABOVE; break;
3073 case FontEmphasis::DISK_ABOVE : nValue = EMPHASISMARK_DISC|EMPHASISMARK_POS_ABOVE; break;
3074 case FontEmphasis::ACCENT_ABOVE: nValue = EMPHASISMARK_ACCENT|EMPHASISMARK_POS_ABOVE; break;
3075 case FontEmphasis::DOT_BELOW : nValue = EMPHASISMARK_DOT|EMPHASISMARK_POS_BELOW; break;
3076 case FontEmphasis::CIRCLE_BELOW: nValue = EMPHASISMARK_CIRCLE|EMPHASISMARK_POS_BELOW; break;
3077 case FontEmphasis::DISK_BELOW : nValue = EMPHASISMARK_DISC|EMPHASISMARK_POS_BELOW; break;
3078 case FontEmphasis::ACCENT_BELOW: nValue = EMPHASISMARK_ACCENT|EMPHASISMARK_POS_BELOW; break;
3079 default: return sal_False;
3081 SetValue( (sal_Int16)nValue );
3083 break;
3085 return bRet;
3088 USHORT SvxEmphasisMarkItem::GetVersion( USHORT nFFVer ) const
3090 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
3091 SOFFICE_FILEFORMAT_40==nFFVer ||
3092 SOFFICE_FILEFORMAT_50==nFFVer,
3093 "SvxEmphasisMarkItem: Gibt es ein neues Fileformat?" );
3095 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3099 /*************************************************************************
3100 |* class SvxTwoLinesItem
3101 *************************************************************************/
3103 SvxTwoLinesItem::SvxTwoLinesItem( sal_Bool bFlag, sal_Unicode nStartBracket,
3104 sal_Unicode nEndBracket, sal_uInt16 nW )
3105 : SfxPoolItem( nW ),
3106 cStartBracket( nStartBracket ), cEndBracket( nEndBracket ), bOn( bFlag )
3110 SvxTwoLinesItem::SvxTwoLinesItem( const SvxTwoLinesItem& rAttr )
3111 : SfxPoolItem( rAttr.Which() ),
3112 cStartBracket( rAttr.cStartBracket ),
3113 cEndBracket( rAttr.cEndBracket ),
3114 bOn( rAttr.bOn )
3118 SvxTwoLinesItem::~SvxTwoLinesItem()
3122 int SvxTwoLinesItem::operator==( const SfxPoolItem& rAttr ) const
3124 DBG_ASSERT( SfxPoolItem::operator==( rAttr ), "not equal attribute types" );
3125 return bOn == ((SvxTwoLinesItem&)rAttr).bOn &&
3126 cStartBracket == ((SvxTwoLinesItem&)rAttr).cStartBracket &&
3127 cEndBracket == ((SvxTwoLinesItem&)rAttr).cEndBracket;
3130 SfxPoolItem* SvxTwoLinesItem::Clone( SfxItemPool* ) const
3132 return new SvxTwoLinesItem( *this );
3135 sal_Bool SvxTwoLinesItem::QueryValue( com::sun::star::uno::Any& rVal,
3136 BYTE nMemberId ) const
3138 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3139 nMemberId &= ~CONVERT_TWIPS;
3140 sal_Bool bRet = sal_True;
3141 switch( nMemberId )
3143 case MID_TWOLINES:
3144 rVal = Bool2Any( bOn );
3145 break;
3146 case MID_START_BRACKET:
3148 OUString s;
3149 if( cStartBracket )
3150 s = OUString( cStartBracket );
3151 rVal <<= s;
3153 break;
3154 case MID_END_BRACKET:
3156 OUString s;
3157 if( cEndBracket )
3158 s = OUString( cEndBracket );
3159 rVal <<= s;
3161 break;
3162 default:
3163 bRet = sal_False;
3164 break;
3166 return bRet;
3169 sal_Bool SvxTwoLinesItem::PutValue( const com::sun::star::uno::Any& rVal,
3170 BYTE nMemberId )
3172 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3173 nMemberId &= ~CONVERT_TWIPS;
3174 sal_Bool bRet = sal_False;
3175 OUString s;
3176 switch( nMemberId )
3178 case MID_TWOLINES:
3179 bOn = Any2Bool( rVal );
3180 bRet = sal_True;
3181 break;
3182 case MID_START_BRACKET:
3183 if( rVal >>= s )
3185 cStartBracket = s.getLength() ? s[ 0 ] : 0;
3186 bRet = sal_True;
3188 break;
3189 case MID_END_BRACKET:
3190 if( rVal >>= s )
3192 cEndBracket = s.getLength() ? s[ 0 ] : 0;
3193 bRet = sal_True;
3195 break;
3197 return bRet;
3200 SfxItemPresentation SvxTwoLinesItem::GetPresentation( SfxItemPresentation ePres,
3201 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
3202 String &rText, const IntlWrapper* /*pIntl*/ ) const
3204 switch( ePres )
3206 case SFX_ITEM_PRESENTATION_NONE:
3207 rText.Erase();
3208 break;
3209 case SFX_ITEM_PRESENTATION_NAMELESS:
3210 case SFX_ITEM_PRESENTATION_COMPLETE:
3212 if( !GetValue() )
3213 rText = SVX_RESSTR( RID_SVXITEMS_TWOLINES_OFF );
3214 else
3216 rText = SVX_RESSTR( RID_SVXITEMS_TWOLINES );
3217 if( GetStartBracket() )
3218 rText.Insert( GetStartBracket(), 0 );
3219 if( GetEndBracket() )
3220 rText += GetEndBracket();
3222 return ePres;
3224 default: ; //prevent warning
3226 return SFX_ITEM_PRESENTATION_NONE;
3230 SfxPoolItem* SvxTwoLinesItem::Create( SvStream & rStrm, USHORT /*nVer*/) const
3232 sal_Bool _bOn;
3233 sal_Unicode cStart, cEnd;
3234 rStrm >> _bOn >> cStart >> cEnd;
3235 return new SvxTwoLinesItem( _bOn, cStart, cEnd, Which() );
3238 SvStream& SvxTwoLinesItem::Store(SvStream & rStrm, USHORT /*nIVer*/) const
3240 rStrm << GetValue() << GetStartBracket() << GetEndBracket();
3241 return rStrm;
3244 USHORT SvxTwoLinesItem::GetVersion( USHORT nFFVer ) const
3246 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
3247 SOFFICE_FILEFORMAT_40==nFFVer ||
3248 SOFFICE_FILEFORMAT_50==nFFVer,
3249 "SvxTwoLinesItem: Gibt es ein neues Fileformat?" );
3251 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3255 /*************************************************************************
3256 |* class SvxCharRotateItem
3257 *************************************************************************/
3259 SvxCharRotateItem::SvxCharRotateItem( sal_uInt16 nValue,
3260 sal_Bool bFitIntoLine,
3261 const sal_uInt16 nW )
3262 : SfxUInt16Item( nW, nValue ), bFitToLine( bFitIntoLine )
3266 SfxPoolItem* SvxCharRotateItem::Clone( SfxItemPool* ) const
3268 return new SvxCharRotateItem( GetValue(), IsFitToLine(), Which() );
3271 SfxPoolItem* SvxCharRotateItem::Create( SvStream& rStrm, USHORT ) const
3273 sal_uInt16 nVal;
3274 sal_Bool b;
3275 rStrm >> nVal >> b;
3276 return new SvxCharRotateItem( nVal, b, Which() );
3279 SvStream& SvxCharRotateItem::Store( SvStream & rStrm, USHORT ) const
3281 sal_Bool bFlag = IsFitToLine();
3282 rStrm << GetValue() << bFlag;
3283 return rStrm;
3286 USHORT SvxCharRotateItem::GetVersion( USHORT nFFVer ) const
3288 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3291 SfxItemPresentation SvxCharRotateItem::GetPresentation(
3292 SfxItemPresentation ePres,
3293 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
3294 String &rText, const IntlWrapper* ) const
3296 switch( ePres )
3298 case SFX_ITEM_PRESENTATION_NONE:
3299 rText.Erase();
3300 break;
3301 case SFX_ITEM_PRESENTATION_NAMELESS:
3302 case SFX_ITEM_PRESENTATION_COMPLETE:
3304 if( !GetValue() )
3305 rText = SVX_RESSTR( RID_SVXITEMS_CHARROTATE_OFF );
3306 else
3308 rText = SVX_RESSTR( RID_SVXITEMS_CHARROTATE );
3309 rText.SearchAndReplaceAscii( "$(ARG1)",
3310 String::CreateFromInt32( GetValue() / 10 ));
3311 if( IsFitToLine() )
3312 rText += SVX_RESSTR( RID_SVXITEMS_CHARROTATE_FITLINE );
3314 return ePres;
3316 default: ; //prevent warning
3318 return SFX_ITEM_PRESENTATION_NONE;
3321 sal_Bool SvxCharRotateItem::QueryValue( com::sun::star::uno::Any& rVal,
3322 BYTE nMemberId ) const
3324 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3325 nMemberId &= ~CONVERT_TWIPS;
3326 sal_Bool bRet = sal_True;
3327 switch( nMemberId )
3329 case MID_ROTATE:
3330 rVal <<= (sal_Int16)GetValue();
3331 break;
3332 case MID_FITTOLINE:
3333 rVal = Bool2Any( IsFitToLine() );
3334 break;
3335 default:
3336 bRet = sal_False;
3337 break;
3339 return bRet;
3342 sal_Bool SvxCharRotateItem::PutValue( const com::sun::star::uno::Any& rVal,
3343 BYTE nMemberId )
3345 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3346 nMemberId &= ~CONVERT_TWIPS;
3347 sal_Bool bRet = sal_True;
3348 switch( nMemberId )
3350 case MID_ROTATE:
3352 sal_Int16 nVal = 0;
3353 if((rVal >>= nVal) && (0 == nVal || 900 == nVal || 2700 == nVal))
3354 SetValue( (USHORT)nVal );
3355 else
3356 bRet = sal_False;
3357 break;
3360 case MID_FITTOLINE:
3361 SetFitToLine( Any2Bool( rVal ) );
3362 break;
3363 default:
3364 bRet = sal_False;
3366 return bRet;
3369 int SvxCharRotateItem::operator==( const SfxPoolItem& rItem ) const
3371 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
3372 return SfxUInt16Item::operator==( rItem ) &&
3373 IsFitToLine() == ((const SvxCharRotateItem&)rItem).IsFitToLine();
3377 /*************************************************************************
3378 |* class SvxCharScaleItem
3379 *************************************************************************/
3381 SvxCharScaleWidthItem::SvxCharScaleWidthItem( sal_uInt16 nValue,
3382 const sal_uInt16 nW )
3383 : SfxUInt16Item( nW, nValue )
3387 SfxPoolItem* SvxCharScaleWidthItem::Clone( SfxItemPool* ) const
3389 return new SvxCharScaleWidthItem( GetValue(), Which() );
3392 SfxPoolItem* SvxCharScaleWidthItem::Create( SvStream& rStrm, USHORT ) const
3394 sal_uInt16 nVal;
3395 rStrm >> nVal;
3396 SvxCharScaleWidthItem* pItem = new SvxCharScaleWidthItem( nVal, Which() );
3398 if ( Which() == EE_CHAR_FONTWIDTH )
3400 // #87271#: Was a SvxFontWidthItem in 5.2
3401 // USHORT nFixWidth, USHORT nPropWidth.
3402 // nFixWidth has never been used...
3403 rStrm >> nVal;
3404 USHORT nTest;
3405 rStrm >> nTest;
3406 if ( nTest == 0x1234 )
3407 pItem->SetValue( nVal );
3408 else
3409 rStrm.SeekRel( -2*(long)sizeof(sal_uInt16) );
3412 return pItem;
3415 SvStream& SvxCharScaleWidthItem::Store( SvStream& rStream, USHORT nVer ) const
3417 SvStream& rRet = SfxUInt16Item::Store( rStream, nVer );
3418 if ( Which() == EE_CHAR_FONTWIDTH )
3420 // see comment in Create()....
3421 rRet.SeekRel( -1*(long)sizeof(USHORT) );
3422 rRet << (USHORT)0;
3423 rRet << GetValue();
3424 // Really ugly, but not a problem for reading the doc in 5.2
3425 rRet << (USHORT)0x1234;
3427 return rRet;
3431 USHORT SvxCharScaleWidthItem::GetVersion( USHORT nFFVer ) const
3433 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3436 SfxItemPresentation SvxCharScaleWidthItem::GetPresentation(
3437 SfxItemPresentation ePres,
3438 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
3439 String &rText, const IntlWrapper* ) const
3441 switch( ePres )
3443 case SFX_ITEM_PRESENTATION_NONE:
3444 rText.Erase();
3445 break;
3446 case SFX_ITEM_PRESENTATION_NAMELESS:
3447 case SFX_ITEM_PRESENTATION_COMPLETE:
3449 if( !GetValue() )
3450 rText = SVX_RESSTR( RID_SVXITEMS_CHARSCALE_OFF );
3451 else
3453 rText = SVX_RESSTR( RID_SVXITEMS_CHARSCALE );
3454 rText.SearchAndReplaceAscii( "$(ARG1)",
3455 String::CreateFromInt32( GetValue() ));
3457 return ePres;
3459 default: ; //prevent warning
3461 return SFX_ITEM_PRESENTATION_NONE;
3464 sal_Bool SvxCharScaleWidthItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/ )
3466 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
3467 // where we still want this to be a sal_Int16
3468 sal_Int16 nValue = sal_Int16();
3469 if (rVal >>= nValue)
3471 SetValue( (UINT16) nValue );
3472 return TRUE;
3475 DBG_ERROR( "SvxCharScaleWidthItem::PutValue - Wrong type!" );
3476 return FALSE;
3479 sal_Bool SvxCharScaleWidthItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/ ) const
3481 // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
3482 // where we still want this to be a sal_Int16
3483 rVal <<= (sal_Int16)GetValue();
3484 return TRUE;
3487 /*************************************************************************
3488 |* class SvxCharReliefItem
3489 *************************************************************************/
3491 SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue,
3492 const sal_uInt16 nId )
3493 : SfxEnumItem( nId, (USHORT)eValue )
3497 SfxPoolItem* SvxCharReliefItem::Clone( SfxItemPool * ) const
3499 return new SvxCharReliefItem( *this );
3502 SfxPoolItem* SvxCharReliefItem::Create(SvStream & rStrm, USHORT) const
3504 sal_uInt16 nVal;
3505 rStrm >> nVal;
3506 return new SvxCharReliefItem( (FontRelief)nVal, Which() );
3509 SvStream& SvxCharReliefItem::Store(SvStream & rStrm, USHORT /*nIVer*/) const
3511 sal_uInt16 nVal = GetValue();
3512 rStrm << nVal;
3513 return rStrm;
3516 USHORT SvxCharReliefItem::GetVersion( USHORT nFFVer ) const
3518 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3521 String SvxCharReliefItem::GetValueTextByPos( USHORT nPos ) const
3523 DBG_ASSERT( RID_SVXITEMS_RELIEF_ENGRAVED - RID_SVXITEMS_RELIEF_NONE,
3524 "enum overflow" );
3525 return String( SVX_RES( RID_SVXITEMS_RELIEF_BEGIN + nPos ));
3528 USHORT SvxCharReliefItem::GetValueCount() const
3530 return RID_SVXITEMS_RELIEF_ENGRAVED - RID_SVXITEMS_RELIEF_NONE;
3533 SfxItemPresentation SvxCharReliefItem::GetPresentation
3535 SfxItemPresentation ePres,
3536 SfxMapUnit /*eCoreUnit*/,
3537 SfxMapUnit /*ePresUnit*/,
3538 XubString& rText, const IntlWrapper * /*pIntl*/
3539 ) const
3541 SfxItemPresentation eRet = ePres;
3542 switch( ePres )
3544 case SFX_ITEM_PRESENTATION_NONE:
3545 rText.Erase();
3546 break;
3548 case SFX_ITEM_PRESENTATION_NAMELESS:
3549 case SFX_ITEM_PRESENTATION_COMPLETE:
3550 rText = GetValueTextByPos( GetValue() );
3551 break;
3553 default:
3554 eRet = SFX_ITEM_PRESENTATION_NONE;
3556 return eRet;
3559 sal_Bool SvxCharReliefItem::PutValue( const com::sun::star::uno::Any& rVal,
3560 BYTE nMemberId )
3562 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3563 nMemberId &= ~CONVERT_TWIPS;
3564 sal_Bool bRet = sal_True;
3565 switch( nMemberId )
3567 case MID_RELIEF:
3569 sal_Int16 nVal = -1;
3570 rVal >>= nVal;
3571 if(nVal >= 0 && nVal <= RELIEF_ENGRAVED)
3572 SetValue( (USHORT)nVal );
3573 else
3574 bRet = sal_False;
3576 break;
3577 default:
3578 bRet = sal_False;
3579 break;
3581 return bRet;
3584 sal_Bool SvxCharReliefItem::QueryValue( com::sun::star::uno::Any& rVal,
3585 BYTE nMemberId ) const
3587 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3588 nMemberId &= ~CONVERT_TWIPS;
3589 sal_Bool bRet = sal_True;
3590 switch( nMemberId )
3592 case MID_RELIEF:
3593 rVal <<= (sal_Int16)GetValue();
3594 break;
3595 default:
3596 bRet = sal_False;
3597 break;
3599 return bRet;
3602 /*************************************************************************
3603 |* class SvxScriptTypeItemItem
3604 *************************************************************************/
3606 SvxScriptTypeItem::SvxScriptTypeItem( sal_uInt16 nType )
3607 : SfxUInt16Item( SID_ATTR_CHAR_SCRIPTTYPE, nType )
3610 SfxPoolItem* SvxScriptTypeItem::Clone( SfxItemPool * ) const
3612 return new SvxScriptTypeItem( GetValue() );
3615 /*************************************************************************
3616 |* class SvxScriptSetItem
3617 *************************************************************************/
3619 SvxScriptSetItem::SvxScriptSetItem( USHORT nSlotId, SfxItemPool& rPool )
3620 : SfxSetItem( nSlotId, new SfxItemSet( rPool,
3621 SID_ATTR_CHAR_FONT, SID_ATTR_CHAR_FONT ))
3623 USHORT nLatin, nAsian, nComplex;
3624 GetWhichIds( nLatin, nAsian, nComplex );
3626 USHORT aIds[ 9 ] = { 0 };
3627 aIds[ 0 ] = aIds[ 1 ] = nLatin;
3628 aIds[ 2 ] = aIds[ 3 ] = nAsian;
3629 aIds[ 4 ] = aIds[ 5 ] = nComplex;
3630 aIds[ 6 ] = aIds[ 7 ] = SID_ATTR_CHAR_SCRIPTTYPE;
3631 aIds[ 8 ] = 0;
3633 GetItemSet().SetRanges( aIds );
3636 SfxPoolItem* SvxScriptSetItem::Clone( SfxItemPool * ) const
3638 SvxScriptSetItem* p = new SvxScriptSetItem( Which(), *GetItemSet().GetPool() );
3639 p->GetItemSet().Put( GetItemSet(), FALSE );
3640 return p;
3643 SfxPoolItem* SvxScriptSetItem::Create( SvStream &, USHORT ) const
3645 return 0;
3648 const SfxPoolItem* SvxScriptSetItem::GetItemOfScriptSet(
3649 const SfxItemSet& rSet, USHORT nId )
3651 const SfxPoolItem* pI;
3652 SfxItemState eSt = rSet.GetItemState( nId, FALSE, &pI );
3653 if( SFX_ITEM_SET != eSt )
3654 pI = SFX_ITEM_DEFAULT == eSt ? &rSet.Get( nId ) : 0;
3655 return pI;
3658 const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( USHORT nSlotId, const SfxItemSet& rSet, USHORT nScript )
3660 USHORT nLatin, nAsian, nComplex;
3661 GetWhichIds( nSlotId, rSet, nLatin, nAsian, nComplex );
3663 const SfxPoolItem *pRet, *pAsn, *pCmplx;
3664 switch( nScript )
3666 default: //no one valid -> match to latin
3667 // case SCRIPTTYPE_LATIN:
3668 pRet = GetItemOfScriptSet( rSet, nLatin );
3669 break;
3670 case SCRIPTTYPE_ASIAN:
3671 pRet = GetItemOfScriptSet( rSet, nAsian );
3672 break;
3673 case SCRIPTTYPE_COMPLEX:
3674 pRet = GetItemOfScriptSet( rSet, nComplex );
3675 break;
3677 case SCRIPTTYPE_LATIN|SCRIPTTYPE_ASIAN:
3678 if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
3679 0 == (pAsn = GetItemOfScriptSet( rSet, nAsian )) ||
3680 *pRet != *pAsn )
3681 pRet = 0;
3682 break;
3684 case SCRIPTTYPE_LATIN|SCRIPTTYPE_COMPLEX:
3685 if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
3686 0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
3687 *pRet != *pCmplx )
3688 pRet = 0;
3689 break;
3691 case SCRIPTTYPE_ASIAN|SCRIPTTYPE_COMPLEX:
3692 if( 0 == (pRet = GetItemOfScriptSet( rSet, nAsian )) ||
3693 0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
3694 *pRet != *pCmplx )
3695 pRet = 0;
3696 break;
3698 case SCRIPTTYPE_LATIN|SCRIPTTYPE_ASIAN|SCRIPTTYPE_COMPLEX:
3699 if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
3700 0 == (pAsn = GetItemOfScriptSet( rSet, nAsian )) ||
3701 0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
3702 *pRet != *pAsn || *pRet != *pCmplx )
3703 pRet = 0;
3704 break;
3706 return pRet;
3709 const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( USHORT nScript ) const
3711 return GetItemOfScript( Which(), GetItemSet(), nScript );
3714 void SvxScriptSetItem::PutItemForScriptType( USHORT nScriptType,
3715 const SfxPoolItem& rItem )
3717 USHORT nLatin, nAsian, nComplex;
3718 GetWhichIds( nLatin, nAsian, nComplex );
3720 SfxPoolItem* pCpy = rItem.Clone();
3721 if( SCRIPTTYPE_LATIN & nScriptType )
3723 pCpy->SetWhich( nLatin );
3724 GetItemSet().Put( *pCpy );
3726 if( SCRIPTTYPE_ASIAN & nScriptType )
3728 pCpy->SetWhich( nAsian );
3729 GetItemSet().Put( *pCpy );
3731 if( SCRIPTTYPE_COMPLEX & nScriptType )
3733 pCpy->SetWhich( nComplex );
3734 GetItemSet().Put( *pCpy );
3736 delete pCpy;
3739 void SvxScriptSetItem::GetWhichIds( USHORT nSlotId, const SfxItemSet& rSet, USHORT& rLatin, USHORT& rAsian, USHORT& rComplex )
3741 const SfxItemPool& rPool = *rSet.GetPool();
3742 GetSlotIds( nSlotId, rLatin, rAsian, rComplex );
3743 rLatin = rPool.GetWhich( rLatin );
3744 rAsian = rPool.GetWhich( rAsian );
3745 rComplex = rPool.GetWhich( rComplex );
3748 void SvxScriptSetItem::GetWhichIds( USHORT& rLatin, USHORT& rAsian,
3749 USHORT& rComplex ) const
3751 GetWhichIds( Which(), GetItemSet(), rLatin, rAsian, rComplex );
3754 void SvxScriptSetItem::GetSlotIds( USHORT nSlotId, USHORT& rLatin,
3755 USHORT& rAsian, USHORT& rComplex )
3757 switch( nSlotId )
3759 default:
3760 DBG_ASSERT( FALSE, "wrong SlotId for class SvxScriptSetItem" );
3761 // no break - default to font - Id Range !!
3763 case SID_ATTR_CHAR_FONT:
3764 rLatin = SID_ATTR_CHAR_FONT;
3765 rAsian = SID_ATTR_CHAR_CJK_FONT;
3766 rComplex = SID_ATTR_CHAR_CTL_FONT;
3767 break;
3768 case SID_ATTR_CHAR_FONTHEIGHT:
3769 rLatin = SID_ATTR_CHAR_FONTHEIGHT;
3770 rAsian = SID_ATTR_CHAR_CJK_FONTHEIGHT;
3771 rComplex = SID_ATTR_CHAR_CTL_FONTHEIGHT;
3772 break;
3773 case SID_ATTR_CHAR_WEIGHT:
3774 rLatin = SID_ATTR_CHAR_WEIGHT;
3775 rAsian = SID_ATTR_CHAR_CJK_WEIGHT;
3776 rComplex = SID_ATTR_CHAR_CTL_WEIGHT;
3777 break;
3778 case SID_ATTR_CHAR_POSTURE:
3779 rLatin = SID_ATTR_CHAR_POSTURE;
3780 rAsian = SID_ATTR_CHAR_CJK_POSTURE;
3781 rComplex = SID_ATTR_CHAR_CTL_POSTURE;
3782 break;
3783 case SID_ATTR_CHAR_LANGUAGE:
3784 rLatin = SID_ATTR_CHAR_LANGUAGE;
3785 rAsian = SID_ATTR_CHAR_CJK_LANGUAGE;
3786 rComplex = SID_ATTR_CHAR_CTL_LANGUAGE;
3787 break;
3791 void GetDefaultFonts( SvxFontItem& rLatin, SvxFontItem& rAsian, SvxFontItem& rComplex )
3793 const USHORT nItemCnt = 3;
3795 static struct
3797 USHORT nFontType;
3798 USHORT nLanguage;
3800 aOutTypeArr[ nItemCnt ] =
3802 { DEFAULTFONT_LATIN_TEXT, LANGUAGE_ENGLISH_US },
3803 { DEFAULTFONT_CJK_TEXT, LANGUAGE_ENGLISH_US },
3804 { DEFAULTFONT_CTL_TEXT, LANGUAGE_ARABIC_SAUDI_ARABIA }
3807 SvxFontItem* aItemArr[ nItemCnt ] = { &rLatin, &rAsian, &rComplex };
3809 for ( USHORT n = 0; n < nItemCnt; ++n )
3811 Font aFont( OutputDevice::GetDefaultFont( aOutTypeArr[ n ].nFontType,
3812 aOutTypeArr[ n ].nLanguage,
3813 DEFAULTFONT_FLAGS_ONLYONE, 0 ) );
3814 SvxFontItem* pItem = aItemArr[ n ];
3815 pItem->GetFamily() = aFont.GetFamily();
3816 pItem->GetFamilyName() = aFont.GetName();
3817 pItem->GetStyleName().Erase();
3818 pItem->GetPitch() = aFont.GetPitch();
3819 pItem->GetCharSet() = aFont.GetCharSet();
3824 USHORT GetI18NScriptTypeOfLanguage( USHORT nLang )
3826 return GetI18NScriptType( SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ) );
3829 USHORT GetItemScriptType( short nI18NType )
3831 switch ( nI18NType )
3833 case i18n::ScriptType::LATIN: return SCRIPTTYPE_LATIN;
3834 case i18n::ScriptType::ASIAN: return SCRIPTTYPE_ASIAN;
3835 case i18n::ScriptType::COMPLEX: return SCRIPTTYPE_COMPLEX;
3837 return 0;
3840 short GetI18NScriptType( USHORT nItemType )
3842 switch ( nItemType )
3844 case SCRIPTTYPE_LATIN: return i18n::ScriptType::LATIN;
3845 case SCRIPTTYPE_ASIAN: return i18n::ScriptType::ASIAN;
3846 case SCRIPTTYPE_COMPLEX: return i18n::ScriptType::COMPLEX;
3848 return 0;