xref: /trunk/main/editeng/source/items/textitem.cxx (revision b63233d8)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_editeng.hxx"
26 
27 // include ---------------------------------------------------------------
28 #include <com/sun/star/style/CaseMap.hpp>
29 #include <com/sun/star/awt/FontDescriptor.hpp>
30 #include <com/sun/star/frame/status/FontHeight.hpp>
31 #include <vcl/bitmapex.hxx>
32 #include <tools/stream.hxx>
33 #include <toolkit/helper/vclunohelper.hxx>
34 #include <math.h>
35 #include <rtl/math.hxx>
36 #include <unotools/fontdefs.hxx>
37 #include <vcl/outdev.hxx>
38 #include <editeng/eeitem.hxx>
39 #include <svtools/unitconv.hxx>
40 
41 #define GLOBALOVERFLOW3
42 
43 #include <svl/memberid.hrc>
44 #include <editeng/editids.hrc>
45 #include <editeng/editrids.hrc>
46 #include <vcl/vclenum.hxx>
47 #include <tools/bigint.hxx>
48 #include <tools/tenccvt.hxx>
49 
50 #include <rtl/ustring.hxx>
51 #include <i18npool/mslangid.hxx>
52 #include <svl/itemset.hxx>
53 
54 #include <svtools/langtab.hxx>
55 #include <svl/itempool.hxx>
56 #include <svtools/ctrltool.hxx>
57 #include <vcl/settings.hxx>
58 #include <vcl/svapp.hxx>
59 #include <com/sun/star/style/CaseMap.hpp>
60 #include <com/sun/star/awt/SimpleFontMetric.hpp>
61 #include <com/sun/star/awt/FontWeight.hpp>
62 #include <com/sun/star/awt/FontSlant.hpp>
63 #include <com/sun/star/awt/CharSet.hpp>
64 #include <com/sun/star/awt/FontDescriptor.hpp>
65 #include <com/sun/star/awt/FontWidth.hpp>
66 #include <com/sun/star/awt/XFont.hpp>
67 #include <com/sun/star/awt/FontType.hpp>
68 #include <com/sun/star/awt/FontUnderline.hpp>
69 #include <com/sun/star/awt/FontStrikeout.hpp>
70 #include <com/sun/star/awt/FontFamily.hpp>
71 #include <com/sun/star/awt/FontPitch.hpp>
72 #include <com/sun/star/lang/Locale.hpp>
73 #include <com/sun/star/text/FontEmphasis.hpp>
74 #include <com/sun/star/i18n/ScriptType.hpp>
75 #include <editeng/memberids.hrc>
76 #include <editeng/flstitem.hxx>
77 #include <editeng/fontitem.hxx>
78 #include <editeng/postitem.hxx>
79 #include <editeng/wghtitem.hxx>
80 #include <editeng/fhgtitem.hxx>
81 #include <editeng/fwdtitem.hxx>
82 #include <editeng/udlnitem.hxx>
83 #include <editeng/crsditem.hxx>
84 #include <editeng/shdditem.hxx>
85 #include <editeng/akrnitem.hxx>
86 #include <editeng/wrlmitem.hxx>
87 #include <editeng/cntritem.hxx>
88 #include <editeng/prszitem.hxx>
89 #include <editeng/colritem.hxx>
90 #include <editeng/cscoitem.hxx>
91 #include <editeng/kernitem.hxx>
92 #include <editeng/cmapitem.hxx>
93 #include <editeng/escpitem.hxx>
94 #include <editeng/langitem.hxx>
95 #include <editeng/nlbkitem.hxx>
96 #include <editeng/nhypitem.hxx>
97 #include <editeng/lcolitem.hxx>
98 #include <editeng/blnkitem.hxx>
99 #include <editeng/emphitem.hxx>
100 #include <editeng/twolinesitem.hxx>
101 #include <editeng/scripttypeitem.hxx>
102 #include <editeng/charrotateitem.hxx>
103 #include <editeng/charscaleitem.hxx>
104 #include <editeng/charreliefitem.hxx>
105 #include <editeng/itemtype.hxx>
106 #include <editeng/eerdll.hxx>
107 
108 // #90477#
109 #include <tools/tenccvt.hxx>
110 
111 #define STORE_UNICODE_MAGIC_MARKER  0xFE331188
112 
113 using namespace ::rtl;
114 using namespace ::com::sun::star;
115 using namespace ::com::sun::star::text;
116 
117 // Konvertierung fuer UNO
118 #define TWIP_TO_MM100(TWIP) 	((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
119 #define MM100_TO_TWIP(MM100)	((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
120 #define TWIP_TO_MM100_UNSIGNED(TWIP)     ((((TWIP)*127L+36L)/72L))
121 #define MM100_TO_TWIP_UNSIGNED(MM100)    ((((MM100)*72L+63L)/127L))
122 
123 sal_Bool SvxFontItem::bEnableStoreUnicodeNames = sal_False;
124 
125 // STATIC DATA -----------------------------------------------------------
126 
127 // -----------------------------------------------------------------------
128 
129 TYPEINIT1(SvxFontListItem, SfxPoolItem);
130 TYPEINIT1_FACTORY(SvxFontItem, SfxPoolItem, new SvxFontItem(0));
131 TYPEINIT1_FACTORY(SvxPostureItem, SfxEnumItem, new SvxPostureItem(ITALIC_NONE, 0));
132 TYPEINIT1_FACTORY(SvxWeightItem, SfxEnumItem, new SvxWeightItem(WEIGHT_NORMAL, 0));
133 TYPEINIT1_FACTORY(SvxFontHeightItem, SfxPoolItem, new SvxFontHeightItem(240, 100, 0));
134 TYPEINIT1_FACTORY(SvxFontWidthItem, SfxPoolItem, new SvxFontWidthItem(0, 100, 0));
135 TYPEINIT1_FACTORY(SvxTextLineItem, SfxEnumItem, new SvxTextLineItem(UNDERLINE_NONE, 0));
136 TYPEINIT1_FACTORY(SvxUnderlineItem, SfxEnumItem, new SvxUnderlineItem(UNDERLINE_NONE, 0));
137 TYPEINIT1_FACTORY(SvxOverlineItem, SfxEnumItem, new SvxOverlineItem(UNDERLINE_NONE, 0));
138 TYPEINIT1_FACTORY(SvxCrossedOutItem, SfxEnumItem, new SvxCrossedOutItem(STRIKEOUT_NONE, 0));
139 TYPEINIT1_FACTORY(SvxShadowedItem, SfxBoolItem, new SvxShadowedItem(sal_False, 0));
140 TYPEINIT1_FACTORY(SvxAutoKernItem, SfxBoolItem, new SvxAutoKernItem(sal_False, 0));
141 TYPEINIT1_FACTORY(SvxWordLineModeItem, SfxBoolItem, new SvxWordLineModeItem(sal_False, 0));
142 TYPEINIT1_FACTORY(SvxContourItem, SfxBoolItem, new SvxContourItem(sal_False, 0));
143 TYPEINIT1_FACTORY(SvxPropSizeItem, SfxUInt16Item, new SvxPropSizeItem(100, 0));
144 TYPEINIT1_FACTORY(SvxColorItem, SfxPoolItem, new SvxColorItem(0));
145 TYPEINIT1_FACTORY(SvxCharSetColorItem, SvxColorItem, new SvxCharSetColorItem(0));
146 TYPEINIT1_FACTORY(SvxKerningItem, SfxInt16Item, new SvxKerningItem(0, 0));
147 TYPEINIT1_FACTORY(SvxCaseMapItem, SfxEnumItem, new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED, 0));
148 TYPEINIT1_FACTORY(SvxEscapementItem, SfxPoolItem, new SvxEscapementItem(0));
149 TYPEINIT1_FACTORY(SvxLanguageItem, SfxEnumItem, new SvxLanguageItem(LANGUAGE_GERMAN, 0));
150 TYPEINIT1_FACTORY(SvxNoLinebreakItem, SfxBoolItem, new SvxNoLinebreakItem(sal_True, 0));
151 TYPEINIT1_FACTORY(SvxNoHyphenItem, SfxBoolItem, new SvxNoHyphenItem(sal_True, 0));
152 TYPEINIT1_FACTORY(SvxLineColorItem, SvxColorItem, new SvxLineColorItem(0));
153 TYPEINIT1_FACTORY(SvxBlinkItem, SfxBoolItem, new SvxBlinkItem(sal_False, 0));
154 TYPEINIT1_FACTORY(SvxEmphasisMarkItem, SfxUInt16Item, new SvxEmphasisMarkItem(EMPHASISMARK_NONE, 0));
155 TYPEINIT1_FACTORY(SvxTwoLinesItem, SfxPoolItem, new SvxTwoLinesItem(sal_True, 0, 0, 0));
156 TYPEINIT1_FACTORY(SvxScriptTypeItem, SfxUInt16Item, new SvxScriptTypeItem);
157 TYPEINIT1_FACTORY(SvxCharRotateItem, SfxUInt16Item, new SvxCharRotateItem(0, sal_False, 0));
158 TYPEINIT1_FACTORY(SvxCharScaleWidthItem, SfxUInt16Item, new SvxCharScaleWidthItem(100, 0));
159 TYPEINIT1_FACTORY(SvxCharReliefItem, SfxEnumItem, new SvxCharReliefItem(RELIEF_NONE, 0));
160 
161 
162 TYPEINIT1(SvxScriptSetItem, SfxSetItem );
163 
164 
165 // class SvxFontListItem -------------------------------------------------
166 
SvxFontListItem(const FontList * pFontLst,const sal_uInt16 nId)167 SvxFontListItem::SvxFontListItem( const FontList* pFontLst,
168 								  const sal_uInt16 nId ) :
169 	SfxPoolItem( nId ),
170 	pFontList( pFontLst )
171 {
172     if ( pFontList )
173     {
174         sal_Int32 nCount = pFontList->GetFontNameCount();
175         aFontNameSeq.realloc( nCount );
176 
177         for ( sal_uInt16 i = 0; i < nCount; i++ )
178             aFontNameSeq[i] = pFontList->GetFontName(i).GetName();
179     }
180 }
181 
182 // -----------------------------------------------------------------------
183 
SvxFontListItem(const SvxFontListItem & rItem)184 SvxFontListItem::SvxFontListItem( const SvxFontListItem& rItem ) :
185 
186 	SfxPoolItem( rItem ),
187 	pFontList( rItem.GetFontList() ),
188 	aFontNameSeq( rItem.aFontNameSeq )
189 {
190 }
191 
192 // -----------------------------------------------------------------------
193 
Clone(SfxItemPool *) const194 SfxPoolItem* SvxFontListItem::Clone( SfxItemPool* ) const
195 {
196 	return new SvxFontListItem( *this );
197 }
198 
199 // -----------------------------------------------------------------------
200 
operator ==(const SfxPoolItem & rAttr) const201 int SvxFontListItem::operator==( const SfxPoolItem& rAttr ) const
202 {
203 	DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
204 
205 	return( pFontList == ((SvxFontListItem&)rAttr).pFontList );
206 }
207 
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const208 sal_Bool SvxFontListItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
209 {
210     rVal <<= aFontNameSeq;
211 	return sal_True;
212 }
213 
214 //------------------------------------------------------------------------
215 
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const216 SfxItemPresentation SvxFontListItem::GetPresentation
217 (
218     SfxItemPresentation /*ePres*/,
219     SfxMapUnit          /*eCoreUnit*/,
220     SfxMapUnit          /*ePresUnit*/,
221     XubString&          rText, const IntlWrapper * /*pIntl*/
222 )	const
223 {
224 	rText.Erase();
225 	return SFX_ITEM_PRESENTATION_NONE;
226 }
227 
228 // class SvxFontItem -----------------------------------------------------
229 
SvxFontItem(const sal_uInt16 nId)230 SvxFontItem::SvxFontItem( const sal_uInt16 nId ) :
231 	SfxPoolItem( nId )
232 {
233 	eFamily = FAMILY_SWISS;
234 	ePitch = PITCH_VARIABLE;
235 	eTextEncoding = RTL_TEXTENCODING_DONTKNOW;
236 }
237 
238 // -----------------------------------------------------------------------
239 
SvxFontItem(const FontFamily eFam,const XubString & aName,const XubString & aStName,const FontPitch eFontPitch,const rtl_TextEncoding eFontTextEncoding,const sal_uInt16 nId)240 SvxFontItem::SvxFontItem( const FontFamily eFam, const XubString& aName,
241 				  const XubString& aStName, const FontPitch eFontPitch,
242 				  const rtl_TextEncoding eFontTextEncoding, const sal_uInt16 nId ) :
243 
244 	SfxPoolItem( nId ),
245 
246 	aFamilyName(aName),
247 	aStyleName(aStName)
248 {
249 	eFamily = eFam;
250 	ePitch = eFontPitch;
251 	eTextEncoding = eFontTextEncoding;
252 }
253 
254 // -----------------------------------------------------------------------
operator =(const SvxFontItem & rFont)255 SvxFontItem& SvxFontItem::operator=(const SvxFontItem& rFont)
256 {
257     aFamilyName =  rFont.GetFamilyName();
258     aStyleName =   rFont.GetStyleName();
259     eFamily =      rFont.GetFamily();
260     ePitch =   rFont.GetPitch();
261     eTextEncoding = rFont.GetCharSet();
262     return *this;
263 }
264 // -----------------------------------------------------------------------
265 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const266 sal_Bool SvxFontItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
267 {
268 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
269     nMemberId &= ~CONVERT_TWIPS;
270 	switch(nMemberId)
271 	{
272         case 0:
273         {
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;
281         }
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;
292 	}
293 	return sal_True;
294 }
295 // -----------------------------------------------------------------------
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)296 sal_Bool SvxFontItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId)
297 {
298 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
299     nMemberId &= ~CONVERT_TWIPS;
300 	switch(nMemberId)
301 	{
302         case 0:
303         {
304             com::sun::star::awt::FontDescriptor aFontDescriptor;
305             if ( !( rVal >>= aFontDescriptor ))
306                 return sal_False;
307 
308             aFamilyName = aFontDescriptor.Name;
309             aStyleName = aFontDescriptor.StyleName;
310             eFamily = (FontFamily)aFontDescriptor.Family;
311             eTextEncoding = (rtl_TextEncoding)aFontDescriptor.CharSet;
312             ePitch = (FontPitch)aFontDescriptor.Pitch;
313         }
314         break;
315 		case MID_FONT_FAMILY_NAME	:
316 		{
317 			OUString aStr;
318 			if(!(rVal >>= aStr))
319 				return sal_False;
320 			aFamilyName = aStr.getStr();
321 		}
322 		break;
323 		case MID_FONT_STYLE_NAME:
324 		{
325 			OUString aStr;
326 			if(!(rVal >>= aStr))
327 				return sal_False;
328 			aStyleName = aStr.getStr();
329 		}
330 		break;
331 		case MID_FONT_FAMILY :
332 		{
333 			sal_Int16 nFamily = sal_Int16();
334 			if(!(rVal >>= nFamily))
335 				return sal_False;
336 			eFamily = (FontFamily)nFamily;
337 		}
338 		break;
339 		case MID_FONT_CHAR_SET  :
340 		{
341 			sal_Int16 nSet = sal_Int16();
342 			if(!(rVal >>= nSet))
343 				return sal_False;
344 			eTextEncoding = (rtl_TextEncoding)nSet;
345 		}
346 		break;
347 		case MID_FONT_PITCH     :
348 		{
349 			sal_Int16 nPitch = sal_Int16();
350 			if(!(rVal >>= nPitch))
351 				return sal_False;
352 			ePitch =  (FontPitch)nPitch;
353 		}
354 		break;
355 	}
356 	return sal_True;
357 }
358 
359 // -----------------------------------------------------------------------
360 
operator ==(const SfxPoolItem & rAttr) const361 int SvxFontItem::operator==( const SfxPoolItem& rAttr ) const
362 {
363 	DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
364 
365 	const SvxFontItem& rItem = (const SvxFontItem&)rAttr;
366 
367 	int bRet = ( eFamily == rItem.eFamily &&
368 				 aFamilyName == rItem.aFamilyName &&
369 				 aStyleName == rItem.aStyleName );
370 
371 	if ( bRet )
372 	{
373 		if ( ePitch != rItem.ePitch || eTextEncoding != rItem.eTextEncoding )
374 		{
375 			bRet = sal_False;
376 			DBG_WARNING( "FontItem::operator==(): nur Pitch oder rtl_TextEncoding unterschiedlich" );
377 		}
378 	}
379 	return bRet;
380 }
381 
382 // -----------------------------------------------------------------------
383 
Clone(SfxItemPool *) const384 SfxPoolItem* SvxFontItem::Clone( SfxItemPool * ) const
385 {
386 	return new SvxFontItem( *this );
387 }
388 
389 // -----------------------------------------------------------------------
390 
Store(SvStream & rStrm,sal_uInt16) const391 SvStream& SvxFontItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
392 {
393 	sal_Bool bToBats =
394 		GetFamilyName().EqualsAscii( "StarSymbol", 0, sizeof("StarSymbol")-1 ) ||
395 		GetFamilyName().EqualsAscii( "OpenSymbol", 0, sizeof("OpenSymbol")-1 );
396 
397 	// #90477# rStrm << (sal_uInt8) GetFamily()
398 	//	  << (sal_uInt8) GetPitch()
399 	//	  << (sal_uInt8)(bToBats ? RTL_TEXTENCODING_SYMBOL : GetStoreCharSet( GetCharSet(), (sal_uInt16)rStrm.GetVersion() ) );
400 	rStrm << (sal_uInt8) GetFamily() << (sal_uInt8) GetPitch()
401 		  << (sal_uInt8)(bToBats ? RTL_TEXTENCODING_SYMBOL : GetSOStoreTextEncoding(GetCharSet(), (sal_uInt16)rStrm.GetVersion()));
402 
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());
408 
409     // #96441# Kach for EditEngine, only set while creating clipboard stream.
410     if ( bEnableStoreUnicodeNames )
411     {
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 );
416     }
417 
418 	return rStrm;
419 }
420 
421 // -----------------------------------------------------------------------
422 
Create(SvStream & rStrm,sal_uInt16) const423 SfxPoolItem* SvxFontItem::Create(SvStream& rStrm, sal_uInt16) const
424 {
425     sal_uInt8 _eFamily, eFontPitch, eFontTextEncoding;
426 	String aName, aStyle;
427     rStrm >> _eFamily;
428 	rStrm >> eFontPitch;
429 	rStrm >> eFontTextEncoding;
430 
431 	// UNICODE: rStrm >> aName;
432 	rStrm.ReadByteString(aName);
433 
434 	// UNICODE: rStrm >> aStyle;
435 	rStrm.ReadByteString(aStyle);
436 
437 	// Task 91008/90471: set the "correct" textencoding
438 	eFontTextEncoding = (sal_uInt8)GetSOLoadTextEncoding( eFontTextEncoding, (sal_uInt16)rStrm.GetVersion() );
439 
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;
443 
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 )
449     {
450         rStrm.ReadByteString( aName, RTL_TEXTENCODING_UNICODE );
451 	    rStrm.ReadByteString( aStyle, RTL_TEXTENCODING_UNICODE );
452     }
453     else
454     {
455         rStrm.Seek( nStreamPos );
456     }
457 
458 
459 
460     return new SvxFontItem( (FontFamily)_eFamily, aName, aStyle,
461 							(FontPitch)eFontPitch, (rtl_TextEncoding)eFontTextEncoding,	Which() );
462 }
463 
464 //------------------------------------------------------------------------
465 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const466 SfxItemPresentation SvxFontItem::GetPresentation
467 (
468 	SfxItemPresentation ePres,
469     SfxMapUnit          /*eCoreUnit*/,
470     SfxMapUnit          /*ePresUnit*/,
471     XubString&          rText, const IntlWrapper * /*pIntl*/
472 )	const
473 {
474 	switch ( ePres )
475 	{
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
484 	}
485 	return SFX_ITEM_PRESENTATION_NONE;
486 }
487 
488 //------------------------------------------------------------------------
489 
EnableStoreUnicodeNames(sal_Bool bEnable)490 void SvxFontItem::EnableStoreUnicodeNames( sal_Bool bEnable )
491 {
492     bEnableStoreUnicodeNames = bEnable;
493 }
494 
495 // class SvxPostureItem --------------------------------------------------
496 
SvxPostureItem(const FontItalic ePosture,const sal_uInt16 nId)497 SvxPostureItem::SvxPostureItem( const FontItalic ePosture, const sal_uInt16 nId ) :
498 	SfxEnumItem( nId, (sal_uInt16)ePosture )
499 {
500 }
501 
502 // -----------------------------------------------------------------------
503 
Clone(SfxItemPool *) const504 SfxPoolItem* SvxPostureItem::Clone( SfxItemPool * ) const
505 {
506 	return new SvxPostureItem( *this );
507 }
508 
509 // -----------------------------------------------------------------------
510 
GetValueCount() const511 sal_uInt16 SvxPostureItem::GetValueCount() const
512 {
513 	return ITALIC_NORMAL + 1;	// auch ITALIC_NONE geh"ort dazu
514 }
515 
516 // -----------------------------------------------------------------------
517 
Store(SvStream & rStrm,sal_uInt16) const518 SvStream& SvxPostureItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
519 {
520 	rStrm << (sal_uInt8)GetValue();
521 	return rStrm;
522 }
523 
524 // -----------------------------------------------------------------------
525 
Create(SvStream & rStrm,sal_uInt16) const526 SfxPoolItem* SvxPostureItem::Create(SvStream& rStrm, sal_uInt16) const
527 {
528 	sal_uInt8 nPosture;
529 	rStrm >> nPosture;
530 	return new SvxPostureItem( (const FontItalic)nPosture, Which() );
531 }
532 
533 //------------------------------------------------------------------------
534 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const535 SfxItemPresentation SvxPostureItem::GetPresentation
536 (
537 	SfxItemPresentation ePres,
538     SfxMapUnit          /*eCoreUnit*/,
539     SfxMapUnit          /*ePresUnit*/,
540     XubString&          rText, const IntlWrapper * /*pIntl*/
541 )	const
542 {
543 	switch ( ePres )
544 	{
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
553 	}
554 	return SFX_ITEM_PRESENTATION_NONE;
555 }
556 
557 // -----------------------------------------------------------------------
558 
GetValueTextByPos(sal_uInt16 nPos) const559 XubString SvxPostureItem::GetValueTextByPos( sal_uInt16 nPos ) const
560 {
561 	DBG_ASSERT( nPos <= (sal_uInt16)ITALIC_NORMAL, "enum overflow!" );
562 
563 	XubString sTxt;
564 	FontItalic eItalic = (FontItalic)nPos;
565 	sal_uInt16 nId = 0;
566 
567 	switch ( eItalic )
568 	{
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
573     }
574 
575 	if ( nId )
576 		sTxt = EditResId( nId );
577 	return sTxt;
578 }
579 
580 
581 /*-----------------13.03.98 14:28-------------------
582 
583 --------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const584 sal_Bool SvxPostureItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
585 {
586 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
587     nMemberId &= ~CONVERT_TWIPS;
588 	switch( nMemberId )
589 	{
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;
596 	}
597 	return sal_True;
598 }
599 /*-----------------13.03.98 14:28-------------------
600 
601 --------------------------------------------------*/
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)602 sal_Bool SvxPostureItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
603 {
604 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
605     nMemberId &= ~CONVERT_TWIPS;
606 	switch( nMemberId )
607 	{
608 		case MID_ITALIC:
609 			SetBoolValue(Any2Bool(rVal));
610 		break;
611 		case MID_POSTURE:
612 		{
613 			awt::FontSlant eSlant;
614 			if(!(rVal >>= eSlant))
615 			{
616 				sal_Int32 nValue = 0;
617 				if(!(rVal >>= nValue))
618 					return sal_False;
619 
620 				eSlant = (awt::FontSlant)nValue;
621 			}
622 			SetValue((sal_uInt16)eSlant);
623 		}
624 	}
625 	return sal_True;
626 }
627 // -----------------------------------------------------------------------
628 
HasBoolValue() const629 int SvxPostureItem::HasBoolValue() const
630 {
631 	return sal_True;
632 }
633 
634 // -----------------------------------------------------------------------
635 
GetBoolValue() const636 sal_Bool SvxPostureItem::GetBoolValue() const
637 {
638 	return ( (FontItalic)GetValue() >= ITALIC_OBLIQUE );
639 }
640 
641 // -----------------------------------------------------------------------
642 
SetBoolValue(sal_Bool bVal)643 void SvxPostureItem::SetBoolValue( sal_Bool bVal )
644 {
645 	SetValue( (sal_uInt16)(bVal ? ITALIC_NORMAL : ITALIC_NONE) );
646 }
647 
648 // class SvxWeightItem ---------------------------------------------------
649 
SvxWeightItem(const FontWeight eWght,const sal_uInt16 nId)650 SvxWeightItem::SvxWeightItem( const FontWeight eWght, const sal_uInt16 nId ) :
651 	SfxEnumItem( nId, (sal_uInt16)eWght )
652 {
653 }
654 
655 
656 
657 // -----------------------------------------------------------------------
658 
HasBoolValue() const659 int SvxWeightItem::HasBoolValue() const
660 {
661 	return sal_True;
662 }
663 
664 // -----------------------------------------------------------------------
665 
GetBoolValue() const666 sal_Bool SvxWeightItem::GetBoolValue() const
667 {
668 	return  (FontWeight)GetValue() >= WEIGHT_BOLD;
669 }
670 
671 // -----------------------------------------------------------------------
672 
SetBoolValue(sal_Bool bVal)673 void SvxWeightItem::SetBoolValue( sal_Bool bVal )
674 {
675 	SetValue( (sal_uInt16)(bVal ? WEIGHT_BOLD : WEIGHT_NORMAL) );
676 }
677 
678 // -----------------------------------------------------------------------
679 
GetValueCount() const680 sal_uInt16 SvxWeightItem::GetValueCount() const
681 {
682 	return WEIGHT_BLACK;	// WEIGHT_DONTKNOW geh"ort nicht dazu
683 }
684 
685 // -----------------------------------------------------------------------
686 
Clone(SfxItemPool *) const687 SfxPoolItem* SvxWeightItem::Clone( SfxItemPool * ) const
688 {
689 	return new SvxWeightItem( *this );
690 }
691 
692 // -----------------------------------------------------------------------
693 
Store(SvStream & rStrm,sal_uInt16) const694 SvStream& SvxWeightItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
695 {
696 	rStrm << (sal_uInt8)GetValue();
697 	return rStrm;
698 }
699 
700 // -----------------------------------------------------------------------
701 
Create(SvStream & rStrm,sal_uInt16) const702 SfxPoolItem* SvxWeightItem::Create(SvStream& rStrm, sal_uInt16) const
703 {
704 	sal_uInt8 nWeight;
705 	rStrm >> nWeight;
706 	return new SvxWeightItem( (FontWeight)nWeight, Which() );
707 }
708 
709 //------------------------------------------------------------------------
710 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const711 SfxItemPresentation SvxWeightItem::GetPresentation
712 (
713 	SfxItemPresentation ePres,
714     SfxMapUnit          /*eCoreUnit*/,
715     SfxMapUnit          /*ePresUnit*/,
716     XubString&          rText, const IntlWrapper * /*pIntl*/
717 )	const
718 {
719 	switch ( ePres )
720 	{
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
729     }
730 	return SFX_ITEM_PRESENTATION_NONE;
731 }
732 
733 // -----------------------------------------------------------------------
734 
GetValueTextByPos(sal_uInt16 nPos) const735 XubString SvxWeightItem::GetValueTextByPos( sal_uInt16 nPos ) const
736 {
737 	DBG_ASSERT( nPos <= (sal_uInt16)WEIGHT_BLACK, "enum overflow!" );
738 	return EE_RESSTR( RID_SVXITEMS_WEIGHT_BEGIN + nPos );
739 }
740 
741 /*-----------------13.03.98 14:18-------------------
742 
743 --------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const744 sal_Bool SvxWeightItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
745 {
746 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
747     nMemberId &= ~CONVERT_TWIPS;
748 	switch( nMemberId )
749 	{
750 		case MID_BOLD	:
751 			rVal = Bool2Any(GetBoolValue());
752 		break;
753 		case MID_WEIGHT:
754 		{
755 			rVal <<= (float)( VCLUnoHelper::ConvertFontWeight( (FontWeight)GetValue() ) );
756 		}
757 		break;
758 	}
759 	return sal_True;
760 }
761 /*-----------------13.03.98 14:18-------------------
762 
763 --------------------------------------------------*/
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)764 sal_Bool SvxWeightItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
765 {
766 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
767     nMemberId &= ~CONVERT_TWIPS;
768 	switch( nMemberId )
769 	{
770 		case MID_BOLD	:
771 			SetBoolValue(Any2Bool(rVal));
772 		break;
773 		case MID_WEIGHT:
774 		{
775             double fValue = 0;
776 			if(!(rVal >>= fValue))
777 			{
778 				sal_Int32 nValue = 0;
779 				if(!(rVal >>= nValue))
780 					return sal_False;
781 				fValue = (float)nValue;
782 			}
783 			SetValue( (sal_uInt16)VCLUnoHelper::ConvertFontWeight((float)fValue) );
784 		}
785 		break;
786 	}
787 	return sal_True;
788 }
789 
790 // class SvxFontHeightItem -----------------------------------------------
791 
SvxFontHeightItem(const sal_uLong nSz,const sal_uInt16 nPrp,const sal_uInt16 nId)792 SvxFontHeightItem::SvxFontHeightItem( const sal_uLong nSz,
793 									  const sal_uInt16 nPrp,
794 									  const sal_uInt16 nId ) :
795 	SfxPoolItem( nId )
796 {
797 	SetHeight( nSz,nPrp );	// mit den Prozenten rechnen
798 }
799 
800 // -----------------------------------------------------------------------
801 
Clone(SfxItemPool *) const802 SfxPoolItem* SvxFontHeightItem::Clone( SfxItemPool * ) const
803 {
804 	return new SvxFontHeightItem( *this );
805 }
806 
807 // -----------------------------------------------------------------------
808 
Store(SvStream & rStrm,sal_uInt16 nItemVersion) const809 SvStream& SvxFontHeightItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
810 {
811 	rStrm << (sal_uInt16)GetHeight();
812 
813 	if( FONTHEIGHT_UNIT_VERSION <= nItemVersion )
814 		rStrm << GetProp() << (sal_uInt16)GetPropUnit();
815 	else
816 	{
817 		// JP 30.06.98: beim Export in alte Versionen geht die relative
818 		// Angabe verloren, wenn es keine Prozentuale ist
819         sal_uInt16 _nProp = GetProp();
820 		if( SFX_MAPUNIT_RELATIVE != GetPropUnit() )
821             _nProp = 100;
822         rStrm << _nProp;
823 	}
824 	return rStrm;
825 }
826 
827 // -----------------------------------------------------------------------
828 
Create(SvStream & rStrm,sal_uInt16 nVersion) const829 SfxPoolItem* SvxFontHeightItem::Create( SvStream& rStrm,
830 												 sal_uInt16 nVersion ) const
831 {
832 	sal_uInt16 nsize, nprop = 0, nPropUnit = SFX_MAPUNIT_RELATIVE;
833 
834 	rStrm >> nsize;
835 
836 	if( FONTHEIGHT_16_VERSION <= nVersion )
837 		rStrm >> nprop;
838 	else
839 	{
840 		sal_uInt8 nP;
841 		rStrm  >> nP;
842 		nprop = (sal_uInt16)nP;
843 	}
844 
845 	if( FONTHEIGHT_UNIT_VERSION <= nVersion )
846 		rStrm >> nPropUnit;
847 
848 	SvxFontHeightItem* pItem = new SvxFontHeightItem( nsize, 100, Which() );
849 	pItem->SetProp( nprop, (SfxMapUnit)nPropUnit );
850 	return pItem;
851 }
852 
853 // -----------------------------------------------------------------------
854 
operator ==(const SfxPoolItem & rItem) const855 int SvxFontHeightItem::operator==( const SfxPoolItem& rItem ) const
856 {
857 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
858 	return GetHeight() == ((SvxFontHeightItem&)rItem).GetHeight() &&
859 			GetProp() == ((SvxFontHeightItem&)rItem).GetProp() &&
860 			GetPropUnit() == ((SvxFontHeightItem&)rItem).GetPropUnit();
861 }
862 
863 /*-----------------13.03.98 14:53-------------------
864 
865 --------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const866 sal_Bool SvxFontHeightItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
867 {
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.
870 
871 	sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
872 	nMemberId &= ~CONVERT_TWIPS;
873 	switch( nMemberId )
874 	{
875 		case 0:
876 		{
877 		    ::com::sun::star::frame::status::FontHeight aFontHeight;
878 
879 			//	Point (also Twips) sind gefragt,
880 			//	also umrechnen, wenn CONVERT_TWIPS nicht gesetzt ist
881 			if( bConvert )
882 			{
883                 long nTwips = bConvert ? nHeight : MM100_TO_TWIP_UNSIGNED(nHeight);
884 				aFontHeight.Height = (float)( nTwips / 20.0 );
885 			}
886 			else
887 			{
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;
892 			}
893 
894             aFontHeight.Prop = (sal_Int16)(SFX_MAPUNIT_RELATIVE == ePropUnit ? nProp : 100);
895 
896 			float fRet = (float)(short)nProp;
897 			switch( ePropUnit )
898 			{
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:
907 
908 				break;
909 				case SFX_MAPUNIT_TWIP:
910 					fRet /= 20.;
911 				break;
912                 default: ;//prevent warning
913             }
914 			aFontHeight.Diff = fRet;
915 			rVal <<= aFontHeight;
916 		}
917 		break;
918 		case MID_FONTHEIGHT:
919 		{
920 			//	Point (also Twips) sind gefragt,
921 			//	also umrechnen, wenn CONVERT_TWIPS nicht gesetzt ist
922 			if( bConvert )
923 			{
924                 long nTwips = bConvert ? nHeight : MM100_TO_TWIP_UNSIGNED(nHeight);
925 				rVal <<= (float)( nTwips / 20.0 );
926 			}
927 			else
928 			{
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;
933 			}
934 		}
935 		break;
936 		case MID_FONTHEIGHT_PROP:
937 			rVal <<= (sal_Int16)(SFX_MAPUNIT_RELATIVE == ePropUnit ? nProp : 100);
938 		break;
939 		case MID_FONTHEIGHT_DIFF:
940 		{
941 			float fRet = (float)(short)nProp;
942 			switch( ePropUnit )
943 			{
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:
952 
953 				break;
954 				case SFX_MAPUNIT_TWIP:
955 					fRet /= 20.;
956 				break;
957                 default: ;//prevent warning
958             }
959 			rVal <<= fRet;
960 		}
961 		break;
962 	}
963 	return sal_True;
964 }
965 /* -----------------01.07.98 13:43-------------------
966  * 	Relative Abweichung aus der Hoehe herausrechnen
967  * --------------------------------------------------*/
lcl_GetRealHeight_Impl(sal_uInt32 nHeight,sal_uInt16 nProp,SfxMapUnit eProp,sal_Bool bCoreInTwip)968 sal_uInt32 lcl_GetRealHeight_Impl(sal_uInt32 nHeight, sal_uInt16 nProp, SfxMapUnit eProp, sal_Bool bCoreInTwip)
969 {
970 	sal_uInt32 nRet = nHeight;
971 	short nDiff = 0;
972 	switch( eProp )
973 	{
974 		case SFX_MAPUNIT_RELATIVE:
975 			nRet *= 100;
976 			nRet /= nProp;
977 		break;
978 		case SFX_MAPUNIT_POINT:
979 		{
980 			short nTemp = (short)nProp;
981 			nDiff = nTemp * 20;
982 			if(!bCoreInTwip)
983 				nDiff = (short)TWIP_TO_MM100((long)(nDiff));
984 		}
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
995     }
996 	nRet -= nDiff;
997 
998 	return nRet;
999 }
1000 
1001 /*-----------------13.03.98 14:53-------------------
1002 
1003 --------------------------------------------------*/
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)1004 sal_Bool SvxFontHeightItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1005 {
1006 	sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1007 	nMemberId &= ~CONVERT_TWIPS;
1008 	switch( nMemberId )
1009 	{
1010         case 0:
1011         {
1012 		    ::com::sun::star::frame::status::FontHeight aFontHeight;
1013 		    if ( rVal >>= aFontHeight )
1014 		    {
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;
1021 
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
1025 
1026                 nProp = aFontHeight.Prop;
1027 		    }
1028 		    else
1029 		        return sal_False;
1030         }
1031         break;
1032 		case MID_FONTHEIGHT:
1033 		{
1034 			ePropUnit = SFX_MAPUNIT_RELATIVE;
1035 			nProp = 100;
1036             double fPoint = 0;
1037 			if(!(rVal >>= fPoint))
1038 			{
1039 				sal_Int32 nValue = 0;
1040                 if(!(rVal >>= nValue))
1041 					return sal_False;
1042 				fPoint = (float)nValue;
1043 			}
1044             if(fPoint < 0. || fPoint > 10000.)
1045 					return sal_False;
1046 
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
1050 		}
1051 		break;
1052 		case MID_FONTHEIGHT_PROP:
1053 		{
1054 			sal_Int16 nNew = sal_Int16();
1055 			if(!(rVal >>= nNew))
1056 				return sal_True;
1057 
1058 			nHeight = lcl_GetRealHeight_Impl(nHeight, nProp, ePropUnit, bConvert);
1059 
1060 			nHeight *= nNew;
1061 			nHeight /= 100;
1062 			nProp = nNew;
1063 			ePropUnit = SFX_MAPUNIT_RELATIVE;
1064 		}
1065 		break;
1066 		case MID_FONTHEIGHT_DIFF:
1067 		{
1068 			nHeight = lcl_GetRealHeight_Impl(nHeight, nProp, ePropUnit, bConvert);
1069 			float fValue = 0;
1070 			if(!(rVal >>= fValue))
1071 			{
1072 				sal_Int32 nValue = 0;
1073 				if(!(rVal >>= nValue))
1074 					return sal_False;
1075 				fValue = (float)nValue;
1076 			}
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;
1081 		}
1082 		break;
1083 	}
1084 	return sal_True;
1085 }
1086 
1087 //------------------------------------------------------------------------
1088 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit,XubString & rText,const IntlWrapper * pIntl) const1089 SfxItemPresentation SvxFontHeightItem::GetPresentation
1090 (
1091 	SfxItemPresentation ePres,
1092 	SfxMapUnit			eCoreUnit,
1093     SfxMapUnit          /*ePresUnit*/,
1094     XubString&          rText, const IntlWrapper *pIntl
1095 )	const
1096 {
1097 #ifndef SVX_LIGHT
1098 	switch ( ePres )
1099 	{
1100 		case SFX_ITEM_PRESENTATION_NONE:
1101 			rText.Erase();
1102 			return ePres;
1103 		case SFX_ITEM_PRESENTATION_NAMELESS:
1104 		case SFX_ITEM_PRESENTATION_COMPLETE:
1105 		{
1106 			if( SFX_MAPUNIT_RELATIVE != ePropUnit )
1107 			{
1108 				rText = String::CreateFromInt32( (short)nProp );
1109 				rText += sal_Unicode(' ');
1110 				rText += EE_RESSTR( GetMetricId( ePropUnit ) );
1111 				if( 0 <= (short)nProp )
1112 					rText.Insert( sal_Unicode('+'), 0 );
1113 			}
1114 			else if( 100 == nProp )
1115 			{
1116 				rText = GetMetricText( (long)nHeight,
1117                                         eCoreUnit, SFX_MAPUNIT_POINT, pIntl );
1118 				rText += sal_Unicode(' ');
1119 				rText += EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
1120 			}
1121 			else
1122 				( rText = String::CreateFromInt32( nProp )) += sal_Unicode('%');
1123             return ePres;
1124 		}
1125         default: ; //prevent warning
1126     }
1127 #endif
1128 	return SFX_ITEM_PRESENTATION_NONE;
1129 }
1130 
1131 // -----------------------------------------------------------------------
1132 
GetVersion(sal_uInt16 nFileVersion) const1133 sal_uInt16 SvxFontHeightItem::GetVersion(sal_uInt16 nFileVersion) const
1134 {
1135 	return (nFileVersion <= SOFFICE_FILEFORMAT_40)
1136 			   ? FONTHEIGHT_16_VERSION
1137 			   : FONTHEIGHT_UNIT_VERSION;
1138 }
1139 
1140 // -----------------------------------------------------------------------
1141 
ScaleMetrics(long nMult,long nDiv)1142 int SvxFontHeightItem::ScaleMetrics( long nMult, long nDiv )
1143 {
1144 	nHeight = (sal_uInt32)Scale( nHeight, nMult, nDiv );
1145 	return 1;
1146 }
1147 
1148 // -----------------------------------------------------------------------
1149 
HasMetrics() const1150 int SvxFontHeightItem::HasMetrics() const
1151 {
1152 	return 1;
1153 }
1154 
SetHeight(sal_uInt32 nNewHeight,const sal_uInt16 nNewProp,SfxMapUnit eUnit)1155 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight, const sal_uInt16 nNewProp,
1156 									SfxMapUnit eUnit )
1157 {
1158 	DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
1159 
1160 #ifndef SVX_LIGHT
1161 	if( SFX_MAPUNIT_RELATIVE != eUnit )
1162 		nHeight = nNewHeight + ::ItemToControl( (short)nNewProp, eUnit,
1163 												SFX_FUNIT_TWIP );
1164 	else
1165 #endif // !SVX_LIGHT
1166 	if( 100 != nNewProp )
1167 		nHeight = sal_uInt32(( nNewHeight * nNewProp ) / 100 );
1168 	else
1169 		nHeight = nNewHeight;
1170 
1171 	nProp = nNewProp;
1172 	ePropUnit = eUnit;
1173 }
1174 
SetHeight(sal_uInt32 nNewHeight,sal_uInt16 nNewProp,SfxMapUnit eMetric,SfxMapUnit eCoreMetric)1175 void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight, sal_uInt16 nNewProp,
1176 								 SfxMapUnit eMetric, SfxMapUnit eCoreMetric )
1177 {
1178 	DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
1179 
1180 #ifndef SVX_LIGHT
1181 	if( SFX_MAPUNIT_RELATIVE != eMetric )
1182 		nHeight = nNewHeight +
1183 				::ControlToItem( ::ItemToControl((short)nNewProp, eMetric,
1184 										SFX_FUNIT_TWIP ), SFX_FUNIT_TWIP,
1185 										eCoreMetric );
1186 	else
1187 #endif // !SVX_LIGHT
1188 	if( 100 != nNewProp )
1189 		nHeight = sal_uInt32(( nNewHeight * nNewProp ) / 100 );
1190 	else
1191 		nHeight = nNewHeight;
1192 
1193 	nProp = nNewProp;
1194 	ePropUnit = eMetric;
1195 }
1196 
1197 // class SvxFontWidthItem -----------------------------------------------
1198 
SvxFontWidthItem(const sal_uInt16 nSz,const sal_uInt16 nPrp,const sal_uInt16 nId)1199 SvxFontWidthItem::SvxFontWidthItem( const sal_uInt16 nSz, const sal_uInt16 nPrp, const sal_uInt16 nId ) :
1200 	SfxPoolItem( nId )
1201 {
1202 	nWidth = nSz;
1203 	nProp = nPrp;
1204 }
1205 
1206 // -----------------------------------------------------------------------
1207 
Clone(SfxItemPool *) const1208 SfxPoolItem* SvxFontWidthItem::Clone( SfxItemPool * ) const
1209 {
1210 	return new SvxFontWidthItem( *this );
1211 }
1212 
1213 // -----------------------------------------------------------------------
1214 
Store(SvStream & rStrm,sal_uInt16) const1215 SvStream& SvxFontWidthItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1216 {
1217 	rStrm << GetWidth() << GetProp();
1218 	return rStrm;
1219 }
1220 
1221 // -----------------------------------------------------------------------
1222 
ScaleMetrics(long nMult,long nDiv)1223 int SvxFontWidthItem::ScaleMetrics( long nMult, long nDiv )
1224 {
1225 	nWidth = (sal_uInt16)Scale( nWidth, nMult, nDiv );
1226 	return 1;
1227 }
1228 
1229 // -----------------------------------------------------------------------
1230 
HasMetrics() const1231 int SvxFontWidthItem::HasMetrics() const
1232 {
1233 	return 1;
1234 }
1235 
1236 // -----------------------------------------------------------------------
1237 
Create(SvStream & rStrm,sal_uInt16) const1238 SfxPoolItem* SvxFontWidthItem::Create( SvStream& rStrm,
1239                                                  sal_uInt16 /*nVersion*/ ) const
1240 {
1241 	sal_uInt16 nS;
1242 	sal_uInt16 nP;
1243 
1244 	rStrm >> nS;
1245 	rStrm >> nP;
1246 	SvxFontWidthItem* pItem = new SvxFontWidthItem( 0, nP, Which() );
1247 	pItem->SetWidthValue( nS );
1248 	return pItem;
1249 }
1250 
1251 // -----------------------------------------------------------------------
1252 
operator ==(const SfxPoolItem & rItem) const1253 int SvxFontWidthItem::operator==( const SfxPoolItem& rItem ) const
1254 {
1255 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
1256 	return GetWidth() == ((SvxFontWidthItem&)rItem).GetWidth() &&
1257 			GetProp() == ((SvxFontWidthItem&)rItem).GetProp();
1258 }
1259 
1260 /*-----------------13.03.98 16:03-------------------
1261 
1262 --------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1263 sal_Bool SvxFontWidthItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1264 {
1265 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1266     nMemberId &= ~CONVERT_TWIPS;
1267 	switch(nMemberId)
1268 	{
1269 		case MID_FONTWIDTH:
1270 			rVal <<= (sal_Int16)(nWidth);
1271 		break;
1272 		case MID_FONTWIDTH_PROP:
1273 			rVal <<= (sal_Int16)(nProp);
1274 		break;
1275 	}
1276 	return sal_True;
1277 }
1278 /*-----------------13.03.98 16:03-------------------
1279 
1280 --------------------------------------------------*/
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)1281 sal_Bool SvxFontWidthItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1282 {
1283 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1284     nMemberId &= ~CONVERT_TWIPS;
1285 	sal_Int16 nVal = sal_Int16();
1286 	if(!(rVal >>= nVal))
1287 		return sal_False;
1288 
1289 	switch(nMemberId)
1290 	{
1291 		case MID_FONTWIDTH:
1292 			nProp = nVal;
1293 		break;
1294 		case MID_FONTWIDTH_PROP:
1295 			nWidth = nVal;
1296 		break;
1297 	}
1298 	return sal_True;
1299 }
1300 
1301 //------------------------------------------------------------------------
1302 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit,XubString & rText,const IntlWrapper * pIntl) const1303 SfxItemPresentation SvxFontWidthItem::GetPresentation
1304 (
1305 	SfxItemPresentation ePres,
1306 	SfxMapUnit			eCoreUnit,
1307     SfxMapUnit          /*ePresUnit*/,
1308     XubString&          rText, const IntlWrapper *pIntl
1309 )	const
1310 {
1311 #ifndef SVX_LIGHT
1312 	switch ( ePres )
1313 	{
1314 		case SFX_ITEM_PRESENTATION_NONE:
1315 			rText.Erase();
1316 			return ePres;
1317 		case SFX_ITEM_PRESENTATION_NAMELESS:
1318 		case SFX_ITEM_PRESENTATION_COMPLETE:
1319 		{
1320 			if ( 100 == nProp )
1321 			{
1322 				rText = GetMetricText( (long)nWidth,
1323                                         eCoreUnit, SFX_MAPUNIT_POINT, pIntl );
1324 				rText += sal_Unicode(' ');
1325 				rText += EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
1326 			}
1327 			else
1328 				( rText = String::CreateFromInt32( nProp )) += sal_Unicode('%');
1329 			return ePres;
1330 		}
1331         default: ; //prevent warning
1332     }
1333 #endif
1334 	return SFX_ITEM_PRESENTATION_NONE;
1335 }
1336 
1337 // class SvxTextLineItem ------------------------------------------------
1338 
SvxTextLineItem(const FontUnderline eSt,const sal_uInt16 nId)1339 SvxTextLineItem::SvxTextLineItem( const FontUnderline eSt, const sal_uInt16 nId )
1340 	: SfxEnumItem( nId, (sal_uInt16)eSt ), mColor( COL_TRANSPARENT )
1341 {
1342 }
1343 
1344 // -----------------------------------------------------------------------
1345 
HasBoolValue() const1346 int SvxTextLineItem::HasBoolValue() const
1347 {
1348 	return sal_True;
1349 }
1350 
1351 // -----------------------------------------------------------------------
1352 
GetBoolValue() const1353 sal_Bool SvxTextLineItem::GetBoolValue() const
1354 {
1355 	return  (FontUnderline)GetValue() != UNDERLINE_NONE;
1356 }
1357 
1358 // -----------------------------------------------------------------------
1359 
SetBoolValue(sal_Bool bVal)1360 void SvxTextLineItem::SetBoolValue( sal_Bool bVal )
1361 {
1362 	SetValue( (sal_uInt16)(bVal ? UNDERLINE_SINGLE : UNDERLINE_NONE) );
1363 }
1364 
1365 // -----------------------------------------------------------------------
1366 
Clone(SfxItemPool *) const1367 SfxPoolItem* SvxTextLineItem::Clone( SfxItemPool * ) const
1368 {
1369 	SvxTextLineItem* pNew = new SvxTextLineItem( *this );
1370 	pNew->SetColor( GetColor() );
1371 	return pNew;
1372 }
1373 
1374 // -----------------------------------------------------------------------
1375 
GetValueCount() const1376 sal_uInt16 SvxTextLineItem::GetValueCount() const
1377 {
1378 	return UNDERLINE_DOTTED + 1;	// auch UNDERLINE_NONE geh"ort dazu
1379 }
1380 
1381 // -----------------------------------------------------------------------
1382 
Store(SvStream & rStrm,sal_uInt16) const1383 SvStream& SvxTextLineItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1384 {
1385 	rStrm << (sal_uInt8)GetValue();
1386 	return rStrm;
1387 }
1388 
1389 // -----------------------------------------------------------------------
1390 
Create(SvStream & rStrm,sal_uInt16) const1391 SfxPoolItem* SvxTextLineItem::Create(SvStream& rStrm, sal_uInt16) const
1392 {
1393 	sal_uInt8 nState;
1394 	rStrm >> nState;
1395 	return new SvxTextLineItem(  (FontUnderline)nState, Which() );
1396 }
1397 
1398 //------------------------------------------------------------------------
1399 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const1400 SfxItemPresentation SvxTextLineItem::GetPresentation
1401 (
1402 	SfxItemPresentation ePres,
1403     SfxMapUnit          /*eCoreUnit*/,
1404     SfxMapUnit          /*ePresUnit*/,
1405     XubString&          rText, const IntlWrapper * /*pIntl*/
1406 )	const
1407 {
1408 #ifndef SVX_LIGHT
1409 	switch ( ePres )
1410 	{
1411 		case SFX_ITEM_PRESENTATION_NONE:
1412 			rText.Erase();
1413 			return ePres;
1414 		case SFX_ITEM_PRESENTATION_NAMELESS:
1415 		case SFX_ITEM_PRESENTATION_COMPLETE:
1416 			rText = GetValueTextByPos( GetValue() );
1417 			if( !mColor.GetTransparency() )
1418 				( rText += cpDelim ) += ::GetColorString( mColor );
1419 			return ePres;
1420         default: ; //prevent warning
1421     }
1422 #endif
1423 	return SFX_ITEM_PRESENTATION_NONE;
1424 }
1425 
1426 // -----------------------------------------------------------------------
1427 
GetValueTextByPos(sal_uInt16) const1428 XubString SvxTextLineItem::GetValueTextByPos( sal_uInt16 /*nPos*/ ) const
1429 {
1430 	DBG_ERROR("SvxTextLineItem::GetValueTextByPos: Pure virtual method");
1431 	return XubString();
1432 }
1433 
1434 /*-----------------13.03.98 16:25-------------------
1435 
1436 --------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1437 sal_Bool SvxTextLineItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1438 {
1439 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1440     nMemberId &= ~CONVERT_TWIPS;
1441 	switch(nMemberId)
1442 	{
1443 	case MID_TEXTLINED:
1444 		rVal = Bool2Any(GetBoolValue());
1445 		break;
1446 	case MID_TL_STYLE:
1447 		rVal <<= (sal_Int16)(GetValue());
1448 		break;
1449 	case MID_TL_COLOR:
1450 		rVal <<= (sal_Int32)( mColor.GetColor() );
1451 		break;
1452 	case MID_TL_HASCOLOR:
1453 		rVal = Bool2Any( !mColor.GetTransparency() );
1454 		break;
1455 	}
1456 	return sal_True;
1457 
1458 }
1459 /*-----------------13.03.98 16:28-------------------
1460 
1461 --------------------------------------------------*/
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)1462 sal_Bool SvxTextLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1463 {
1464 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1465     nMemberId &= ~CONVERT_TWIPS;
1466 	sal_Bool bRet = sal_True;
1467 	switch(nMemberId)
1468 	{
1469 	case MID_TEXTLINED:
1470 		SetBoolValue(Any2Bool(rVal));
1471 	break;
1472 	case MID_TL_STYLE:
1473 	{
1474 		sal_Int32 nValue = 0;
1475 		if(!(rVal >>= nValue))
1476 			bRet = sal_False;
1477 		else
1478 			SetValue((sal_Int16)nValue);
1479 	}
1480 	break;
1481 	case MID_TL_COLOR:
1482 	{
1483 		sal_Int32 nCol = 0;
1484 		if( !( rVal >>= nCol ) )
1485 			bRet = sal_False;
1486 		else
1487 		{
1488 			// Keep transparence, because it contains the information
1489 			// whether the font color or the stored color should be used
1490 			sal_uInt8 nTrans = mColor.GetTransparency();
1491 			mColor = Color( nCol );
1492 			mColor.SetTransparency( nTrans );
1493 		}
1494 	}
1495 	break;
1496 	case MID_TL_HASCOLOR:
1497 		mColor.SetTransparency( Any2Bool( rVal ) ? 0 : 0xff );
1498 	break;
1499 	}
1500 	return bRet;
1501 }
1502 
operator ==(const SfxPoolItem & rItem) const1503 int SvxTextLineItem::operator==( const SfxPoolItem& rItem ) const
1504 {
1505 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
1506 	return SfxEnumItem::operator==( rItem ) &&
1507 		   GetColor() == ((SvxTextLineItem&)rItem).GetColor();
1508 }
1509 
1510 // class SvxUnderlineItem ------------------------------------------------
1511 
SvxUnderlineItem(const FontUnderline eSt,const sal_uInt16 nId)1512 SvxUnderlineItem::SvxUnderlineItem( const FontUnderline eSt, const sal_uInt16 nId )
1513 	: SvxTextLineItem( eSt, nId )
1514 {
1515 }
1516 
1517 //------------------------------------------------------------------------
1518 
Clone(SfxItemPool *) const1519 SfxPoolItem* SvxUnderlineItem::Clone( SfxItemPool * ) const
1520 {
1521 	SvxUnderlineItem* pNew = new SvxUnderlineItem( *this );
1522 	pNew->SetColor( GetColor() );
1523 	return pNew;
1524 }
1525 
1526 // -----------------------------------------------------------------------
1527 
Create(SvStream & rStrm,sal_uInt16) const1528 SfxPoolItem* SvxUnderlineItem::Create(SvStream& rStrm, sal_uInt16) const
1529 {
1530 	sal_uInt8 nState;
1531 	rStrm >> nState;
1532 	return new SvxUnderlineItem(  (FontUnderline)nState, Which() );
1533 }
1534 
1535 // -----------------------------------------------------------------------
1536 
GetValueTextByPos(sal_uInt16 nPos) const1537 XubString SvxUnderlineItem::GetValueTextByPos( sal_uInt16 nPos ) const
1538 {
1539 	DBG_ASSERT( nPos <= (sal_uInt16)UNDERLINE_BOLDWAVE, "enum overflow!" );
1540 	return EE_RESSTR( RID_SVXITEMS_UL_BEGIN + nPos );
1541 }
1542 
1543 // class SvxOverlineItem ------------------------------------------------
1544 
SvxOverlineItem(const FontUnderline eSt,const sal_uInt16 nId)1545 SvxOverlineItem::SvxOverlineItem( const FontUnderline eSt, const sal_uInt16 nId )
1546 	: SvxTextLineItem( eSt, nId )
1547 {
1548 }
1549 
1550 //------------------------------------------------------------------------
1551 
Clone(SfxItemPool *) const1552 SfxPoolItem* SvxOverlineItem::Clone( SfxItemPool * ) const
1553 {
1554 	SvxOverlineItem* pNew = new SvxOverlineItem( *this );
1555 	pNew->SetColor( GetColor() );
1556 	return pNew;
1557 }
1558 
1559 // -----------------------------------------------------------------------
1560 
Create(SvStream & rStrm,sal_uInt16) const1561 SfxPoolItem* SvxOverlineItem::Create(SvStream& rStrm, sal_uInt16) const
1562 {
1563 	sal_uInt8 nState;
1564 	rStrm >> nState;
1565 	return new SvxOverlineItem(  (FontUnderline)nState, Which() );
1566 }
1567 
1568 // -----------------------------------------------------------------------
1569 
GetValueTextByPos(sal_uInt16 nPos) const1570 XubString SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos ) const
1571 {
1572 	DBG_ASSERT( nPos <= (sal_uInt16)UNDERLINE_BOLDWAVE, "enum overflow!" );
1573 	return EE_RESSTR( RID_SVXITEMS_OL_BEGIN + nPos );
1574 }
1575 
1576 // class SvxCrossedOutItem -----------------------------------------------
1577 
SvxCrossedOutItem(const FontStrikeout eSt,const sal_uInt16 nId)1578 SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt, const sal_uInt16 nId )
1579 	: SfxEnumItem( nId, (sal_uInt16)eSt )
1580 {
1581 }
1582 
1583 // -----------------------------------------------------------------------
1584 
HasBoolValue() const1585 int SvxCrossedOutItem::HasBoolValue() const
1586 {
1587 	return sal_True;
1588 }
1589 
1590 // -----------------------------------------------------------------------
1591 
GetBoolValue() const1592 sal_Bool SvxCrossedOutItem::GetBoolValue() const
1593 {
1594 	return (FontStrikeout)GetValue() != STRIKEOUT_NONE;
1595 }
1596 
1597 // -----------------------------------------------------------------------
1598 
SetBoolValue(sal_Bool bVal)1599 void SvxCrossedOutItem::SetBoolValue( sal_Bool bVal )
1600 {
1601 	SetValue( (sal_uInt16)(bVal ? STRIKEOUT_SINGLE : STRIKEOUT_NONE) );
1602 }
1603 
1604 // -----------------------------------------------------------------------
1605 
GetValueCount() const1606 sal_uInt16 SvxCrossedOutItem::GetValueCount() const
1607 {
1608 	return STRIKEOUT_DOUBLE + 1;	// auch STRIKEOUT_NONE geh"ort dazu
1609 }
1610 
1611 // -----------------------------------------------------------------------
1612 
Clone(SfxItemPool *) const1613 SfxPoolItem* SvxCrossedOutItem::Clone( SfxItemPool * ) const
1614 {
1615 	return new SvxCrossedOutItem( *this );
1616 }
1617 
1618 // -----------------------------------------------------------------------
1619 
Store(SvStream & rStrm,sal_uInt16) const1620 SvStream& SvxCrossedOutItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1621 {
1622 	rStrm << (sal_uInt8)GetValue();
1623 	return rStrm;
1624 }
1625 
1626 // -----------------------------------------------------------------------
1627 
Create(SvStream & rStrm,sal_uInt16) const1628 SfxPoolItem* SvxCrossedOutItem::Create(SvStream& rStrm, sal_uInt16) const
1629 {
1630 	sal_uInt8 eCross;
1631 	rStrm >> eCross;
1632 	return new SvxCrossedOutItem(  (FontStrikeout)eCross, Which() );
1633 }
1634 
1635 //------------------------------------------------------------------------
1636 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const1637 SfxItemPresentation SvxCrossedOutItem::GetPresentation
1638 (
1639 	SfxItemPresentation ePres,
1640     SfxMapUnit          /*eCoreUnit*/,
1641     SfxMapUnit          /*ePresUnit*/,
1642     XubString&          rText, const IntlWrapper * /*pIntl*/
1643 )	const
1644 {
1645 	switch ( ePres )
1646 	{
1647 		case SFX_ITEM_PRESENTATION_NONE:
1648 			rText.Erase();
1649 			return ePres;
1650 		case SFX_ITEM_PRESENTATION_NAMELESS:
1651 		case SFX_ITEM_PRESENTATION_COMPLETE:
1652 			rText = GetValueTextByPos( GetValue() );
1653 			return ePres;
1654         default: ;//prevent warning
1655     }
1656 	return SFX_ITEM_PRESENTATION_NONE;
1657 }
1658 
1659 // -----------------------------------------------------------------------
1660 
GetValueTextByPos(sal_uInt16 nPos) const1661 XubString SvxCrossedOutItem::GetValueTextByPos( sal_uInt16 nPos ) const
1662 {
1663 	DBG_ASSERT( nPos <= (sal_uInt16)STRIKEOUT_X, "enum overflow!" );
1664 	return EE_RESSTR( RID_SVXITEMS_STRIKEOUT_BEGIN + nPos );
1665 }
1666 
1667 /*-----------------13.03.98 16:28-------------------
1668 
1669 --------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1670 sal_Bool SvxCrossedOutItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1671 {
1672 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1673     nMemberId &= ~CONVERT_TWIPS;
1674 	switch(nMemberId)
1675 	{
1676 		case MID_CROSSED_OUT:
1677 			rVal = Bool2Any(GetBoolValue());
1678 		break;
1679 		case MID_CROSS_OUT:
1680 			rVal <<= (sal_Int16)(GetValue());
1681 		break;
1682 	}
1683 	return sal_True;
1684 }
1685 /*-----------------13.03.98 16:29-------------------
1686 
1687 --------------------------------------------------*/
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)1688 sal_Bool SvxCrossedOutItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1689 {
1690 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1691     nMemberId &= ~CONVERT_TWIPS;
1692 	switch(nMemberId)
1693 	{
1694 		case MID_CROSSED_OUT:
1695 			SetBoolValue(Any2Bool(rVal));
1696 		break;
1697 		case MID_CROSS_OUT:
1698 		{
1699 			sal_Int32 nValue = 0;
1700 			if(!(rVal >>= nValue))
1701 				return sal_False;
1702 			SetValue((sal_Int16)nValue);
1703 		}
1704 		break;
1705 	}
1706 	return sal_True;
1707 }
1708 // class SvxShadowedItem -------------------------------------------------
1709 
SvxShadowedItem(const sal_Bool bShadowed,const sal_uInt16 nId)1710 SvxShadowedItem::SvxShadowedItem( const sal_Bool bShadowed, const sal_uInt16 nId ) :
1711 	SfxBoolItem( nId, bShadowed )
1712 {
1713 }
1714 
1715 // -----------------------------------------------------------------------
1716 
Clone(SfxItemPool *) const1717 SfxPoolItem* SvxShadowedItem::Clone( SfxItemPool * ) const
1718 {
1719 	return new SvxShadowedItem( *this );
1720 }
1721 
1722 // -----------------------------------------------------------------------
1723 
Store(SvStream & rStrm,sal_uInt16) const1724 SvStream& SvxShadowedItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1725 {
1726 	rStrm << (sal_uInt8) GetValue();
1727 	return rStrm;
1728 }
1729 
1730 // -----------------------------------------------------------------------
1731 
Create(SvStream & rStrm,sal_uInt16) const1732 SfxPoolItem* SvxShadowedItem::Create(SvStream& rStrm, sal_uInt16) const
1733 {
1734 	sal_uInt8 nState;
1735 	rStrm >> nState;
1736 	return new SvxShadowedItem( nState, Which() );
1737 }
1738 
1739 //------------------------------------------------------------------------
1740 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const1741 SfxItemPresentation SvxShadowedItem::GetPresentation
1742 (
1743 	SfxItemPresentation ePres,
1744     SfxMapUnit          /*eCoreUnit*/,
1745     SfxMapUnit          /*ePresUnit*/,
1746     XubString&          rText, const IntlWrapper * /*pIntl*/
1747 )	const
1748 {
1749 	switch ( ePres )
1750 	{
1751 		case SFX_ITEM_PRESENTATION_NONE:
1752 			rText.Erase();
1753 			return ePres;
1754 		case SFX_ITEM_PRESENTATION_NAMELESS:
1755 		case SFX_ITEM_PRESENTATION_COMPLETE:
1756 		{
1757 			sal_uInt16 nId = RID_SVXITEMS_SHADOWED_FALSE;
1758 
1759 			if ( GetValue() )
1760 				nId = RID_SVXITEMS_SHADOWED_TRUE;
1761 			rText = EE_RESSTR(nId);
1762 			return ePres;
1763 		}
1764         default: ; //prevent warning
1765     }
1766 	return SFX_ITEM_PRESENTATION_NONE;
1767 }
1768 
1769 // class SvxAutoKernItem -------------------------------------------------
1770 
SvxAutoKernItem(const sal_Bool bAutoKern,const sal_uInt16 nId)1771 SvxAutoKernItem::SvxAutoKernItem( const sal_Bool bAutoKern, const sal_uInt16 nId ) :
1772 	SfxBoolItem( nId, bAutoKern )
1773 {
1774 }
1775 
1776 // -----------------------------------------------------------------------
1777 
Clone(SfxItemPool *) const1778 SfxPoolItem* SvxAutoKernItem::Clone( SfxItemPool * ) const
1779 {
1780 	return new SvxAutoKernItem( *this );
1781 }
1782 
1783 // -----------------------------------------------------------------------
1784 
Store(SvStream & rStrm,sal_uInt16) const1785 SvStream& SvxAutoKernItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1786 {
1787 	rStrm << (sal_uInt8) GetValue();
1788 	return rStrm;
1789 }
1790 
1791 // -----------------------------------------------------------------------
1792 
Create(SvStream & rStrm,sal_uInt16) const1793 SfxPoolItem* SvxAutoKernItem::Create(SvStream& rStrm, sal_uInt16) const
1794 {
1795 	sal_uInt8 nState;
1796 	rStrm >> nState;
1797 	return new SvxAutoKernItem( nState, Which() );
1798 }
1799 
1800 //------------------------------------------------------------------------
1801 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const1802 SfxItemPresentation SvxAutoKernItem::GetPresentation
1803 (
1804 	SfxItemPresentation ePres,
1805     SfxMapUnit          /*eCoreUnit*/,
1806     SfxMapUnit          /*ePresUnit*/,
1807     XubString&          rText, const IntlWrapper * /*pIntl*/
1808 )	const
1809 {
1810 	switch ( ePres )
1811 	{
1812 		case SFX_ITEM_PRESENTATION_NONE:
1813 			rText.Erase();
1814 			return ePres;
1815 		case SFX_ITEM_PRESENTATION_NAMELESS:
1816 		case SFX_ITEM_PRESENTATION_COMPLETE:
1817 		{
1818 			sal_uInt16 nId = RID_SVXITEMS_AUTOKERN_FALSE;
1819 
1820 			if ( GetValue() )
1821 				nId = RID_SVXITEMS_AUTOKERN_TRUE;
1822 			rText = EE_RESSTR(nId);
1823 			return ePres;
1824 		}
1825         default: ; //prevent warning
1826     }
1827 	return SFX_ITEM_PRESENTATION_NONE;
1828 }
1829 
1830 // class SvxWordLineModeItem ---------------------------------------------
1831 
SvxWordLineModeItem(const sal_Bool bWordLineMode,const sal_uInt16 nId)1832 SvxWordLineModeItem::SvxWordLineModeItem( const sal_Bool bWordLineMode,
1833 										  const sal_uInt16 nId ) :
1834 	SfxBoolItem( nId, bWordLineMode )
1835 {
1836 }
1837 
1838 // -----------------------------------------------------------------------
1839 
Clone(SfxItemPool *) const1840 SfxPoolItem* SvxWordLineModeItem::Clone( SfxItemPool * ) const
1841 {
1842 	return new SvxWordLineModeItem( *this );
1843 }
1844 
1845 // -----------------------------------------------------------------------
1846 
Store(SvStream & rStrm,sal_uInt16) const1847 SvStream& SvxWordLineModeItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1848 {
1849 	rStrm << (sal_Bool) GetValue();
1850 	return rStrm;
1851 }
1852 
1853 // -----------------------------------------------------------------------
1854 
Create(SvStream & rStrm,sal_uInt16) const1855 SfxPoolItem* SvxWordLineModeItem::Create(SvStream& rStrm, sal_uInt16) const
1856 {
1857 	sal_Bool bValue;
1858 	rStrm >> bValue;
1859 	return new SvxWordLineModeItem( bValue, Which() );
1860 }
1861 
1862 //------------------------------------------------------------------------
1863 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const1864 SfxItemPresentation SvxWordLineModeItem::GetPresentation
1865 (
1866 	SfxItemPresentation ePres,
1867     SfxMapUnit          /*eCoreUnit*/,
1868     SfxMapUnit          /*ePresUnit*/,
1869     XubString&          rText, const IntlWrapper * /*pIntl*/
1870 )	const
1871 {
1872 	switch ( ePres )
1873 	{
1874 		case SFX_ITEM_PRESENTATION_NONE:
1875 			rText.Erase();
1876 			return ePres;
1877 		case SFX_ITEM_PRESENTATION_NAMELESS:
1878 		case SFX_ITEM_PRESENTATION_COMPLETE:
1879 		{
1880 			sal_uInt16 nId = RID_SVXITEMS_WORDLINE_FALSE;
1881 
1882 			if ( GetValue() )
1883 				nId = RID_SVXITEMS_WORDLINE_TRUE;
1884 			rText = EE_RESSTR(nId);
1885 			return ePres;
1886 		}
1887         default: ; //prevent warning
1888     }
1889 	return SFX_ITEM_PRESENTATION_NONE;
1890 }
1891 
1892 // class SvxContourItem --------------------------------------------------
1893 
SvxContourItem(const sal_Bool bContoured,const sal_uInt16 nId)1894 SvxContourItem::SvxContourItem( const sal_Bool bContoured, const sal_uInt16 nId ) :
1895 	SfxBoolItem( nId, bContoured )
1896 {
1897 }
1898 
1899 // -----------------------------------------------------------------------
1900 
Clone(SfxItemPool *) const1901 SfxPoolItem* SvxContourItem::Clone( SfxItemPool * ) const
1902 {
1903 	return new SvxContourItem( *this );
1904 }
1905 
1906 // -----------------------------------------------------------------------
1907 
Store(SvStream & rStrm,sal_uInt16) const1908 SvStream& SvxContourItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1909 {
1910 	rStrm << (sal_Bool) GetValue();
1911 	return rStrm;
1912 }
1913 
1914 // -----------------------------------------------------------------------
1915 
Create(SvStream & rStrm,sal_uInt16) const1916 SfxPoolItem* SvxContourItem::Create(SvStream& rStrm, sal_uInt16) const
1917 {
1918 	sal_Bool bValue;
1919 	rStrm >> bValue;
1920 	return new SvxContourItem( bValue, Which() );
1921 }
1922 
1923 //------------------------------------------------------------------------
1924 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const1925 SfxItemPresentation SvxContourItem::GetPresentation
1926 (
1927 	SfxItemPresentation ePres,
1928     SfxMapUnit          /*eCoreUnit*/,
1929     SfxMapUnit          /*ePresUnit*/,
1930     XubString&          rText, const IntlWrapper * /*pIntl*/
1931 )	const
1932 {
1933 	switch ( ePres )
1934 	{
1935 		case SFX_ITEM_PRESENTATION_NONE:
1936 			rText.Erase();
1937 			return ePres;
1938 		case SFX_ITEM_PRESENTATION_NAMELESS:
1939 		case SFX_ITEM_PRESENTATION_COMPLETE:
1940 		{
1941 			sal_uInt16 nId = RID_SVXITEMS_CONTOUR_FALSE;
1942 
1943 			if ( GetValue() )
1944 				nId = RID_SVXITEMS_CONTOUR_TRUE;
1945 			rText = EE_RESSTR(nId);
1946 			return ePres;
1947 		}
1948         default: ; //prevent warning
1949     }
1950 	return SFX_ITEM_PRESENTATION_NONE;
1951 }
1952 
1953 // class SvxPropSizeItem -------------------------------------------------
1954 
SvxPropSizeItem(const sal_uInt16 nPercent,const sal_uInt16 nId)1955 SvxPropSizeItem::SvxPropSizeItem( const sal_uInt16 nPercent, const sal_uInt16 nId ) :
1956 	SfxUInt16Item( nId, nPercent )
1957 {
1958 }
1959 
1960 // -----------------------------------------------------------------------
1961 
Clone(SfxItemPool *) const1962 SfxPoolItem* SvxPropSizeItem::Clone( SfxItemPool * ) const
1963 {
1964 	return new SvxPropSizeItem( *this );
1965 }
1966 
1967 // -----------------------------------------------------------------------
1968 
Store(SvStream & rStrm,sal_uInt16) const1969 SvStream& SvxPropSizeItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1970 {
1971 	rStrm << (sal_uInt16) GetValue();
1972 	return rStrm;
1973 }
1974 
1975 // -----------------------------------------------------------------------
1976 
Create(SvStream & rStrm,sal_uInt16) const1977 SfxPoolItem* SvxPropSizeItem::Create(SvStream& rStrm, sal_uInt16) const
1978 {
1979 	sal_uInt16 nSize;
1980 	rStrm >> nSize;
1981 	return new SvxPropSizeItem( nSize, Which() );
1982 }
1983 
1984 //------------------------------------------------------------------------
1985 
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const1986 SfxItemPresentation SvxPropSizeItem::GetPresentation
1987 (
1988     SfxItemPresentation /*ePres*/,
1989     SfxMapUnit          /*eCoreUnit*/,
1990     SfxMapUnit          /*ePresUnit*/,
1991     XubString&          rText, const IntlWrapper * /*pIntl*/
1992 )	const
1993 {
1994 	rText.Erase();
1995 	return SFX_ITEM_PRESENTATION_NONE;
1996 }
1997 
1998 // class SvxColorItem ----------------------------------------------------
1999 
SvxColorItem(const sal_uInt16 nId)2000 SvxColorItem::SvxColorItem( const sal_uInt16 nId ) :
2001 	SfxPoolItem( nId ),
2002 	mColor( COL_BLACK )
2003 {
2004 }
2005 
2006 // -----------------------------------------------------------------------
2007 
SvxColorItem(const Color & rCol,const sal_uInt16 nId)2008 SvxColorItem::SvxColorItem( const Color& rCol, const sal_uInt16 nId ) :
2009 	SfxPoolItem( nId ),
2010 	mColor( rCol )
2011 {
2012 }
2013 
2014 // -----------------------------------------------------------------------
2015 
SvxColorItem(SvStream & rStrm,const sal_uInt16 nId)2016 SvxColorItem::SvxColorItem( SvStream &rStrm, const sal_uInt16 nId ) :
2017 	SfxPoolItem( nId )
2018 {
2019 	Color aColor;
2020 	rStrm >> aColor;
2021 	mColor = aColor;
2022 }
2023 
2024 // -----------------------------------------------------------------------
2025 
SvxColorItem(const SvxColorItem & rCopy)2026 SvxColorItem::SvxColorItem( const SvxColorItem &rCopy ) :
2027 	SfxPoolItem( rCopy ),
2028 	mColor( rCopy.mColor )
2029 {
2030 }
2031 
2032 // -----------------------------------------------------------------------
2033 
~SvxColorItem()2034 SvxColorItem::~SvxColorItem()
2035 {
2036 }
2037 
2038 // -----------------------------------------------------------------------
GetVersion(sal_uInt16 nFFVer) const2039 sal_uInt16 SvxColorItem::GetVersion( sal_uInt16 nFFVer ) const
2040 {
2041 	DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
2042 			SOFFICE_FILEFORMAT_40==nFFVer ||
2043 			SOFFICE_FILEFORMAT_50==nFFVer,
2044 			"SvxColorItem: Gibt es ein neues Fileformat?" );
2045 	return  SOFFICE_FILEFORMAT_50 >= nFFVer ? VERSION_USEAUTOCOLOR : 0;
2046 }
2047 
2048 // -----------------------------------------------------------------------
2049 
operator ==(const SfxPoolItem & rAttr) const2050 int SvxColorItem::operator==( const SfxPoolItem& rAttr ) const
2051 {
2052 	DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
2053 
2054 	return	mColor == ( (const SvxColorItem&)rAttr ).mColor;
2055 }
2056 
2057 // -----------------------------------------------------------------------
2058 
QueryValue(uno::Any & rVal,sal_uInt8) const2059 sal_Bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
2060 {
2061 	rVal <<= (sal_Int32)(mColor.GetColor());
2062 	return sal_True;
2063 }
2064 
2065 // -----------------------------------------------------------------------
2066 
PutValue(const uno::Any & rVal,sal_uInt8)2067 sal_Bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
2068 {
2069 	sal_Int32 nColor = 0;
2070 	if(!(rVal >>= nColor))
2071 		return sal_False;
2072 
2073 	mColor.SetColor( nColor );
2074 	return sal_True;
2075 }
2076 
2077 // -----------------------------------------------------------------------
2078 
Clone(SfxItemPool *) const2079 SfxPoolItem* SvxColorItem::Clone( SfxItemPool * ) const
2080 {
2081 	return new SvxColorItem( *this );
2082 }
2083 
2084 // -----------------------------------------------------------------------
2085 
Store(SvStream & rStrm,sal_uInt16 nItemVersion) const2086 SvStream& SvxColorItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
2087 {
2088 	if( VERSION_USEAUTOCOLOR == nItemVersion &&
2089 		COL_AUTO == mColor.GetColor() )
2090 		rStrm << Color( COL_BLACK );
2091 	else
2092 		rStrm << mColor;
2093 	return rStrm;
2094 }
2095 
2096 // -----------------------------------------------------------------------
2097 
Create(SvStream & rStrm,sal_uInt16) const2098 SfxPoolItem* SvxColorItem::Create(SvStream& rStrm, sal_uInt16 /*nVer*/ ) const
2099 {
2100 	return new SvxColorItem( rStrm, Which() );
2101 }
2102 
2103 //------------------------------------------------------------------------
2104 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const2105 SfxItemPresentation SvxColorItem::GetPresentation
2106 (
2107 	SfxItemPresentation ePres,
2108     SfxMapUnit          /*eCoreUnit*/,
2109     SfxMapUnit          /*ePresUnit*/,
2110     XubString&          rText, const IntlWrapper * /*pIntl*/
2111 )	const
2112 {
2113 #ifndef SVX_LIGHT
2114 	switch ( ePres )
2115 	{
2116 		case SFX_ITEM_PRESENTATION_NONE:
2117 			rText.Erase();
2118 			return ePres;
2119 		case SFX_ITEM_PRESENTATION_NAMELESS:
2120 		case SFX_ITEM_PRESENTATION_COMPLETE:
2121 			rText = ::GetColorString( mColor );
2122 			return ePres;
2123         default: ; //prevent warning
2124     }
2125 #endif
2126 	return SFX_ITEM_PRESENTATION_NONE;
2127 }
2128 
2129 // -----------------------------------------------------------------------
2130 
SetValue(const Color & rNewCol)2131 void SvxColorItem::SetValue( const Color& rNewCol )
2132 {
2133 	mColor = rNewCol;
2134 }
2135 
2136 // class SvxCharSetColorItem ---------------------------------------------
2137 
SvxCharSetColorItem(const sal_uInt16 nId)2138 SvxCharSetColorItem::SvxCharSetColorItem( const sal_uInt16 nId ) :
2139 	SvxColorItem( nId ),
2140 
2141 	eFrom( RTL_TEXTENCODING_DONTKNOW )
2142 {
2143 }
2144 
2145 // -----------------------------------------------------------------------
2146 
SvxCharSetColorItem(const Color & rCol,const rtl_TextEncoding _eFrom,const sal_uInt16 nId)2147 SvxCharSetColorItem::SvxCharSetColorItem( const Color& rCol,
2148                                           const rtl_TextEncoding _eFrom,
2149 										  const sal_uInt16 nId ) :
2150 	SvxColorItem( rCol, nId ),
2151 
2152     eFrom( _eFrom )
2153 {
2154 }
2155 
2156 
2157 // -----------------------------------------------------------------------
2158 
Clone(SfxItemPool *) const2159 SfxPoolItem* SvxCharSetColorItem::Clone( SfxItemPool * ) const
2160 {
2161 	return new SvxCharSetColorItem( *this );
2162 }
2163 
2164 // -----------------------------------------------------------------------
2165 
Store(SvStream & rStrm,sal_uInt16) const2166 SvStream& SvxCharSetColorItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2167 {
2168 	// #90477# rStrm << (sal_uInt8) GetStoreCharSet( GetCharSet(), (sal_uInt16)rStrm.GetVersion() )
2169 	//	  << GetValue();
2170 	rStrm << (sal_uInt8)GetSOStoreTextEncoding(GetCharSet(), (sal_uInt16)rStrm.GetVersion())
2171 		  << GetValue();
2172 	return rStrm;
2173 }
2174 
2175 // -----------------------------------------------------------------------
2176 
Create(SvStream & rStrm,sal_uInt16) const2177 SfxPoolItem* SvxCharSetColorItem::Create(SvStream& rStrm, sal_uInt16) const
2178 {
2179 	sal_uInt8 cSet;
2180 	Color aColor;
2181 	rStrm >> cSet >> aColor;
2182 	return new SvxCharSetColorItem( aColor,  (rtl_TextEncoding)cSet, Which() );
2183 }
2184 
2185 //------------------------------------------------------------------------
2186 
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const2187 SfxItemPresentation SvxCharSetColorItem::GetPresentation
2188 (
2189     SfxItemPresentation /*ePres*/,
2190     SfxMapUnit          /*eCoreUnit*/,
2191     SfxMapUnit          /*ePresUnit*/,
2192     XubString&          rText, const IntlWrapper * /*pIntl*/
2193 )	const
2194 {
2195 	rText.Erase();
2196 	return SFX_ITEM_PRESENTATION_NONE;
2197 }
2198 
2199 // class SvxKerningItem --------------------------------------------------
2200 
SvxKerningItem(const short nKern,const sal_uInt16 nId)2201 SvxKerningItem::SvxKerningItem( const short nKern, const sal_uInt16 nId ) :
2202 	SfxInt16Item( nId, nKern )
2203 {
2204 }
2205 
2206 // -----------------------------------------------------------------------
2207 
Clone(SfxItemPool *) const2208 SfxPoolItem* SvxKerningItem::Clone( SfxItemPool * ) const
2209 {
2210 	return new SvxKerningItem( *this );
2211 }
2212 
2213 // -----------------------------------------------------------------------
2214 
Store(SvStream & rStrm,sal_uInt16) const2215 SvStream& SvxKerningItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2216 {
2217 	rStrm << (short) GetValue();
2218 	return rStrm;
2219 }
2220 
2221 // -----------------------------------------------------------------------
2222 
ScaleMetrics(long nMult,long nDiv)2223 int SvxKerningItem::ScaleMetrics( long nMult, long nDiv )
2224 {
2225 	SetValue( (sal_Int16)Scale( GetValue(), nMult, nDiv ) );
2226 	return 1;
2227 }
2228 
2229 // -----------------------------------------------------------------------
2230 
HasMetrics() const2231 int SvxKerningItem::HasMetrics() const
2232 {
2233 	return 1;
2234 }
2235 
2236 // -----------------------------------------------------------------------
2237 
Create(SvStream & rStrm,sal_uInt16) const2238 SfxPoolItem* SvxKerningItem::Create(SvStream& rStrm, sal_uInt16) const
2239 {
2240 	short nValue;
2241 	rStrm >> nValue;
2242 	return new SvxKerningItem( nValue, Which() );
2243 }
2244 
2245 //------------------------------------------------------------------------
2246 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit,XubString & rText,const IntlWrapper * pIntl) const2247 SfxItemPresentation SvxKerningItem::GetPresentation
2248 (
2249 	SfxItemPresentation ePres,
2250 	SfxMapUnit			eCoreUnit,
2251     SfxMapUnit          /*ePresUnit*/,
2252     XubString&          rText, const IntlWrapper *pIntl
2253 )	const
2254 {
2255 #ifndef SVX_LIGHT
2256 	switch ( ePres )
2257 	{
2258 		case SFX_ITEM_PRESENTATION_NONE:
2259 			rText.Erase();
2260 			return ePres;
2261 		case SFX_ITEM_PRESENTATION_NAMELESS:
2262             rText = GetMetricText( (long)GetValue(), eCoreUnit, SFX_MAPUNIT_POINT, pIntl );
2263             rText += sal_Unicode(' ');
2264             rText += EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
2265 			return ePres;
2266 		case SFX_ITEM_PRESENTATION_COMPLETE:
2267 		{
2268 			rText = EE_RESSTR(RID_SVXITEMS_KERNING_COMPLETE);
2269 			sal_uInt16 nId = 0;
2270 
2271 			if ( GetValue() > 0 )
2272 				nId = RID_SVXITEMS_KERNING_EXPANDED;
2273 			else if ( GetValue() < 0 )
2274 				nId = RID_SVXITEMS_KERNING_CONDENSED;
2275 
2276 			if ( nId )
2277 				rText += EE_RESSTR(nId);
2278             rText += GetMetricText( (long)GetValue(), eCoreUnit, SFX_MAPUNIT_POINT, pIntl );
2279             rText += sal_Unicode(' ');
2280             rText += EE_RESSTR(GetMetricId(SFX_MAPUNIT_POINT));
2281 			return ePres;
2282 		}
2283         default: ; //prevent warning
2284     }
2285 #endif
2286 	return SFX_ITEM_PRESENTATION_NONE;
2287 }
2288 /* -----------------------------19.02.01 12:21--------------------------------
2289 
2290  ---------------------------------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const2291 sal_Bool SvxKerningItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2292 {
2293 	sal_Int16 nVal = GetValue();
2294 	if(nMemberId & CONVERT_TWIPS)
2295 		nVal = (sal_Int16)TWIP_TO_MM100(nVal);
2296 	rVal <<= nVal;
2297 	return sal_True;
2298 }
2299 // -----------------------------------------------------------------------
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)2300 sal_Bool SvxKerningItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId)
2301 {
2302 	sal_Int16 nVal = sal_Int16();
2303 	if(!(rVal >>= nVal))
2304 		return sal_False;
2305 	if(nMemberId & CONVERT_TWIPS)
2306 		nVal = (sal_Int16)MM100_TO_TWIP(nVal);
2307 	SetValue(nVal);
2308 	return sal_True;
2309 }
2310 
2311 // class SvxCaseMapItem --------------------------------------------------
2312 
SvxCaseMapItem(const SvxCaseMap eMap,const sal_uInt16 nId)2313 SvxCaseMapItem::SvxCaseMapItem( const SvxCaseMap eMap, const sal_uInt16 nId ) :
2314 	SfxEnumItem( nId, (sal_uInt16)eMap )
2315 {
2316 }
2317 
2318 // -----------------------------------------------------------------------
2319 
GetValueCount() const2320 sal_uInt16 SvxCaseMapItem::GetValueCount() const
2321 {
2322 	return SVX_CASEMAP_END;	// SVX_CASEMAP_KAPITAELCHEN	+ 1
2323 }
2324 
2325 // -----------------------------------------------------------------------
2326 
Clone(SfxItemPool *) const2327 SfxPoolItem* SvxCaseMapItem::Clone( SfxItemPool * ) const
2328 {
2329 	return new SvxCaseMapItem( *this );
2330 }
2331 
2332 // -----------------------------------------------------------------------
2333 
Store(SvStream & rStrm,sal_uInt16) const2334 SvStream& SvxCaseMapItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2335 {
2336 	rStrm << (sal_uInt8) GetValue();
2337 	return rStrm;
2338 }
2339 
2340 // -----------------------------------------------------------------------
2341 
Create(SvStream & rStrm,sal_uInt16) const2342 SfxPoolItem* SvxCaseMapItem::Create(SvStream& rStrm, sal_uInt16) const
2343 {
2344 	sal_uInt8 cMap;
2345 	rStrm >> cMap;
2346 	return new SvxCaseMapItem( (const SvxCaseMap)cMap, Which() );
2347 }
2348 
2349 //------------------------------------------------------------------------
2350 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const2351 SfxItemPresentation SvxCaseMapItem::GetPresentation
2352 (
2353 	SfxItemPresentation ePres,
2354     SfxMapUnit          /*eCoreUnit*/,
2355     SfxMapUnit          /*ePresUnit*/,
2356     XubString&          rText, const IntlWrapper * /*pIntl*/
2357 )	const
2358 {
2359 	switch ( ePres )
2360 	{
2361 		case SFX_ITEM_PRESENTATION_NONE:
2362 			rText.Erase();
2363 			return ePres;
2364 		case SFX_ITEM_PRESENTATION_NAMELESS:
2365 		case SFX_ITEM_PRESENTATION_COMPLETE:
2366 			rText = GetValueTextByPos( GetValue() );
2367 			return ePres;
2368         default: ; //prevent warning
2369     }
2370 	return SFX_ITEM_PRESENTATION_NONE;
2371 }
2372 
2373 // -----------------------------------------------------------------------
2374 
GetValueTextByPos(sal_uInt16 nPos) const2375 XubString SvxCaseMapItem::GetValueTextByPos( sal_uInt16 nPos ) const
2376 {
2377 	DBG_ASSERT( nPos < (sal_uInt16)SVX_CASEMAP_END, "enum overflow!" );
2378 	return EE_RESSTR( RID_SVXITEMS_CASEMAP_BEGIN + nPos );
2379 }
2380 
2381 /*-----------------13.03.98 16:29-------------------
2382 
2383 --------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8) const2384 sal_Bool SvxCaseMapItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
2385 {
2386 	sal_Int16 nRet = style::CaseMap::NONE;
2387 	switch( GetValue() )
2388 	{
2389 //		case SVX_CASEMAP_NOT_MAPPED  :		nRet = style::CaseMap::NONE 	; break;
2390 		case SVX_CASEMAP_VERSALIEN   :      nRet = style::CaseMap::UPPERCASE; break;
2391 		case SVX_CASEMAP_GEMEINE     :      nRet = style::CaseMap::LOWERCASE; break;
2392 		case SVX_CASEMAP_TITEL       :      nRet = style::CaseMap::TITLE    ; break;
2393 		case SVX_CASEMAP_KAPITAELCHEN:      nRet = style::CaseMap::SMALLCAPS; break;
2394 	}
2395 	rVal <<= (sal_Int16)(nRet);
2396 	return sal_True;
2397 }
2398 /*-----------------13.03.98 16:29-------------------
2399 
2400 --------------------------------------------------*/
PutValue(const uno::Any & rVal,sal_uInt8)2401 sal_Bool SvxCaseMapItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
2402 {
2403 	sal_uInt16 nVal = sal_uInt16();
2404 	if(!(rVal >>= nVal))
2405 		return sal_False;
2406 
2407 	switch( nVal )
2408 	{
2409 	case style::CaseMap::NONE 	 :  nVal = SVX_CASEMAP_NOT_MAPPED  ; break;
2410 	case style::CaseMap::UPPERCASE:  nVal = SVX_CASEMAP_VERSALIEN   ; break;
2411 	case style::CaseMap::LOWERCASE:  nVal = SVX_CASEMAP_GEMEINE     ; break;
2412 	case style::CaseMap::TITLE    :  nVal = SVX_CASEMAP_TITEL       ; break;
2413 	case style::CaseMap::SMALLCAPS:  nVal = SVX_CASEMAP_KAPITAELCHEN; break;
2414 	}
2415 	SetValue(nVal);
2416 	return sal_True;
2417 }
2418 
2419 // class SvxEscapementItem -----------------------------------------------
2420 
SvxEscapementItem(const sal_uInt16 nId)2421 SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId ) :
2422 	SfxEnumItemInterface( nId ),
2423 
2424 	nEsc	( 0 ),
2425 	nProp	( 100 )
2426 {
2427 }
2428 
2429 // -----------------------------------------------------------------------
2430 
SvxEscapementItem(const SvxEscapement eEscape,const sal_uInt16 nId)2431 SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape,
2432 									  const sal_uInt16 nId ) :
2433 	SfxEnumItemInterface( nId ),
2434 	nProp( 100 )
2435 {
2436 	SetEscapement( eEscape );
2437 	if( nEsc )
2438 		nProp = 58;
2439 }
2440 
2441 // -----------------------------------------------------------------------
2442 
SvxEscapementItem(const short _nEsc,const sal_uInt8 _nProp,const sal_uInt16 nId)2443 SvxEscapementItem::SvxEscapementItem( const short _nEsc,
2444                                       const sal_uInt8 _nProp,
2445 									  const sal_uInt16 nId ) :
2446 	SfxEnumItemInterface( nId ),
2447     nEsc    ( _nEsc ),
2448     nProp   ( _nProp )
2449 {
2450 }
2451 
2452 // -----------------------------------------------------------------------
2453 
operator ==(const SfxPoolItem & rAttr) const2454 int SvxEscapementItem::operator==( const SfxPoolItem& rAttr ) const
2455 {
2456 	DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
2457 
2458 	return( nEsc  == ((SvxEscapementItem&)rAttr).nEsc &&
2459 			nProp == ((SvxEscapementItem&)rAttr).nProp );
2460 }
2461 
2462 // -----------------------------------------------------------------------
2463 
Clone(SfxItemPool *) const2464 SfxPoolItem* SvxEscapementItem::Clone( SfxItemPool * ) const
2465 {
2466 	return new SvxEscapementItem( *this );
2467 }
2468 
2469 // -----------------------------------------------------------------------
2470 
Store(SvStream & rStrm,sal_uInt16) const2471 SvStream& SvxEscapementItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2472 {
2473     short _nEsc = GetEsc();
2474 	if( SOFFICE_FILEFORMAT_31 == rStrm.GetVersion() )
2475 	{
2476         if( DFLT_ESC_AUTO_SUPER == _nEsc )
2477             _nEsc = DFLT_ESC_SUPER;
2478         else if( DFLT_ESC_AUTO_SUB == _nEsc )
2479             _nEsc = DFLT_ESC_SUB;
2480 	}
2481 	rStrm << (sal_uInt8) GetProp()
2482           << (short) _nEsc;
2483 	return rStrm;
2484 }
2485 
2486 // -----------------------------------------------------------------------
2487 
Create(SvStream & rStrm,sal_uInt16) const2488 SfxPoolItem* SvxEscapementItem::Create(SvStream& rStrm, sal_uInt16) const
2489 {
2490     sal_uInt8 _nProp;
2491     short _nEsc;
2492     rStrm >> _nProp >> _nEsc;
2493     return new SvxEscapementItem( _nEsc, _nProp, Which() );
2494 }
2495 
2496 // -----------------------------------------------------------------------
2497 
GetValueCount() const2498 sal_uInt16 SvxEscapementItem::GetValueCount() const
2499 {
2500 	return SVX_ESCAPEMENT_END;	// SVX_ESCAPEMENT_SUBSCRIPT + 1
2501 }
2502 
2503 //------------------------------------------------------------------------
2504 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const2505 SfxItemPresentation SvxEscapementItem::GetPresentation
2506 (
2507 	SfxItemPresentation ePres,
2508     SfxMapUnit          /*eCoreUnit*/,
2509     SfxMapUnit          /*ePresUnit*/,
2510     XubString&          rText, const IntlWrapper * /*pIntl*/
2511 )	const
2512 {
2513 	switch ( ePres )
2514 	{
2515 		case SFX_ITEM_PRESENTATION_NONE:
2516 			rText.Erase();
2517 			return ePres;
2518 		case SFX_ITEM_PRESENTATION_NAMELESS:
2519 		case SFX_ITEM_PRESENTATION_COMPLETE:
2520 		{
2521 			rText = GetValueTextByPos( GetEnumValue() );
2522 
2523 			if ( nEsc != 0 )
2524 			{
2525 				if( DFLT_ESC_AUTO_SUPER == nEsc || DFLT_ESC_AUTO_SUB == nEsc )
2526 					rText += String( EE_RESSTR(RID_SVXITEMS_ESCAPEMENT_AUTO) );
2527 				else
2528 					( rText += String::CreateFromInt32( nEsc )) += sal_Unicode('%');
2529 			}
2530 			return ePres;
2531 		}
2532         default: ; //prevent warning
2533     }
2534 	return SFX_ITEM_PRESENTATION_NONE;
2535 }
2536 
2537 // -----------------------------------------------------------------------
2538 
GetValueTextByPos(sal_uInt16 nPos) const2539 XubString SvxEscapementItem::GetValueTextByPos( sal_uInt16 nPos ) const
2540 {
2541 	DBG_ASSERT( nPos < (sal_uInt16)SVX_ESCAPEMENT_END, "enum overflow!" );
2542 	return EE_RESSTR(RID_SVXITEMS_ESCAPEMENT_BEGIN + nPos);
2543 }
2544 
2545 // -----------------------------------------------------------------------
2546 
GetEnumValue() const2547 sal_uInt16 SvxEscapementItem::GetEnumValue() const
2548 {
2549 	if ( nEsc < 0 )
2550 		return SVX_ESCAPEMENT_SUBSCRIPT;
2551 	else if ( nEsc > 0 )
2552 		return SVX_ESCAPEMENT_SUPERSCRIPT;
2553 	return SVX_ESCAPEMENT_OFF;
2554 }
2555 
2556 // -----------------------------------------------------------------------
2557 
SetEnumValue(sal_uInt16 nVal)2558 void SvxEscapementItem::SetEnumValue( sal_uInt16 nVal )
2559 {
2560 	SetEscapement( (const SvxEscapement)nVal );
2561 }
2562 
2563 /*-----------------13.03.98 17:05-------------------
2564 
2565 --------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const2566 sal_Bool SvxEscapementItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2567 {
2568 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2569     nMemberId &= ~CONVERT_TWIPS;
2570 	switch(nMemberId)
2571 	{
2572 		case MID_ESC:
2573 			rVal <<= (sal_Int16)(nEsc);
2574 		break;
2575 		case MID_ESC_HEIGHT:
2576 			rVal <<= (sal_Int8)(nProp);
2577 		break;
2578 		case MID_AUTO_ESC:
2579 			rVal = Bool2Any(DFLT_ESC_AUTO_SUB == nEsc || DFLT_ESC_AUTO_SUPER == nEsc);
2580 		break;
2581 	}
2582 	return sal_True;
2583 }
2584 /*-----------------13.03.98 17:05-------------------
2585 
2586 --------------------------------------------------*/
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)2587 sal_Bool SvxEscapementItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2588 {
2589 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2590     nMemberId &= ~CONVERT_TWIPS;
2591 	switch(nMemberId)
2592 	{
2593 		case MID_ESC:
2594 		{
2595 			sal_Int16 nVal = sal_Int16();
2596 			if( (rVal >>= nVal) && (Abs(nVal) <= 101))
2597 				nEsc = nVal;
2598 			else
2599 				return sal_False;
2600 		}
2601 		break;
2602 		case MID_ESC_HEIGHT:
2603 		{
2604 			sal_Int8 nVal = sal_Int8();
2605 			if( (rVal >>= nVal) && (nVal <= 100))
2606 				nProp = nVal;
2607 			else
2608 				return sal_False;
2609 		}
2610 		break;
2611 		case MID_AUTO_ESC:
2612 		{
2613 			sal_Bool bVal = Any2Bool(rVal);
2614 			if(bVal)
2615 			{
2616 				if(nEsc < 0)
2617 					nEsc = DFLT_ESC_AUTO_SUB;
2618 				else
2619 					nEsc = DFLT_ESC_AUTO_SUPER;
2620 			}
2621 			else
2622 				if(DFLT_ESC_AUTO_SUPER == nEsc )
2623 					--nEsc;
2624 				else if(DFLT_ESC_AUTO_SUB == nEsc)
2625 					++nEsc;
2626 		}
2627 		break;
2628 	}
2629 	return sal_True;
2630 }
2631 
2632 // class SvxLanguageItem -------------------------------------------------
2633 
SvxLanguageItem(const LanguageType eLang,const sal_uInt16 nId)2634 SvxLanguageItem::SvxLanguageItem( const LanguageType eLang, const sal_uInt16 nId )
2635 	: SfxEnumItem( nId , eLang )
2636 {
2637 }
2638 
2639 // -----------------------------------------------------------------------
2640 
GetValueCount() const2641 sal_uInt16 SvxLanguageItem::GetValueCount() const
2642 {
2643     // #i50205# got rid of class International
2644     DBG_ERRORFILE("SvxLanguageItem::GetValueCount: supposed to return a count of what?");
2645     // FIXME: previously returned LANGUAGE_COUNT from tools/intn.hxx which was wrong anyway.
2646     // Could be SvtLanguageTable::GetEntryCount() (all locales with resource string)?
2647     // Could be LocaleDataWrapper::getInstalledLanguageTypes() (all locales with locale data)?
2648 	return 0;
2649 }
2650 
2651 // -----------------------------------------------------------------------
2652 
Clone(SfxItemPool *) const2653 SfxPoolItem* SvxLanguageItem::Clone( SfxItemPool * ) const
2654 {
2655 	return new SvxLanguageItem( *this );
2656 }
2657 
2658 // -----------------------------------------------------------------------
2659 
Store(SvStream & rStrm,sal_uInt16) const2660 SvStream& SvxLanguageItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2661 {
2662 	rStrm << (sal_uInt16) GetValue();
2663 	return rStrm;
2664 }
2665 
2666 // -----------------------------------------------------------------------
2667 
Create(SvStream & rStrm,sal_uInt16) const2668 SfxPoolItem* SvxLanguageItem::Create(SvStream& rStrm, sal_uInt16) const
2669 {
2670 	sal_uInt16 nValue;
2671 	rStrm >> nValue;
2672 	return new SvxLanguageItem( (LanguageType)nValue, Which() );
2673 }
2674 
2675 //------------------------------------------------------------------------
2676 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const2677 SfxItemPresentation SvxLanguageItem::GetPresentation
2678 (
2679 	SfxItemPresentation ePres,
2680     SfxMapUnit          /*eCoreUnit*/,
2681     SfxMapUnit          /*ePresUnit*/,
2682     XubString&          rText, const IntlWrapper * /*pIntl*/
2683 )	const
2684 {
2685 #ifndef SVX_LIGHT
2686 	switch ( ePres )
2687 	{
2688 		case SFX_ITEM_PRESENTATION_NONE:
2689 			rText.Erase();
2690 			return ePres;
2691 		case SFX_ITEM_PRESENTATION_NAMELESS:
2692 		case SFX_ITEM_PRESENTATION_COMPLETE:
2693 		{
2694             SvtLanguageTable aLangTable;
2695 			rText = aLangTable.GetString( (LanguageType)GetValue() );
2696 			return ePres;
2697 		}
2698         default: ; //prevent warning
2699     }
2700 #endif // !SVX_LIGHT
2701 	return SFX_ITEM_PRESENTATION_NONE;
2702 }
2703 
2704 /*-----------------14.03.98 14:13-------------------
2705 
2706 --------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const2707 sal_Bool SvxLanguageItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2708 {
2709 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2710     nMemberId &= ~CONVERT_TWIPS;
2711 	switch(nMemberId)
2712 	{
2713         case MID_LANG_INT:  // for basic conversions!
2714 			rVal <<= (sal_Int16)(GetValue());
2715 		break;
2716 		case MID_LANG_LOCALE:
2717 			lang::Locale aRet( MsLangId::convertLanguageToLocale( GetValue(), false));
2718 			rVal <<= aRet;
2719 		break;
2720 	}
2721 	return sal_True;
2722 }
2723 /*-----------------14.03.98 14:13-------------------
2724 
2725 --------------------------------------------------*/
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)2726 sal_Bool SvxLanguageItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2727 {
2728 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2729     nMemberId &= ~CONVERT_TWIPS;
2730 	switch(nMemberId)
2731 	{
2732         case MID_LANG_INT:  // for basic conversions!
2733 		{
2734 			sal_Int32 nValue = 0;
2735 			if(!(rVal >>= nValue))
2736 				return sal_False;
2737 
2738 			SetValue((sal_Int16)nValue);
2739 		}
2740 		break;
2741 		case MID_LANG_LOCALE:
2742 		{
2743 			lang::Locale aLocale;
2744 			if(!(rVal >>= aLocale))
2745 				return sal_False;
2746 
2747             if (aLocale.Language.getLength() || aLocale.Country.getLength())
2748                 SetValue(MsLangId::convertLocaleToLanguage( aLocale ));
2749             else
2750                 SetValue(LANGUAGE_NONE);
2751 		}
2752 		break;
2753 	}
2754 	return sal_True;
2755 }
2756 
2757 // class SvxNoLinebreakItem ----------------------------------------------
SvxNoLinebreakItem(const sal_Bool bBreak,const sal_uInt16 nId)2758 SvxNoLinebreakItem::SvxNoLinebreakItem( const sal_Bool bBreak, const sal_uInt16 nId ) :
2759       SfxBoolItem( nId, bBreak )
2760 {
2761 }
2762 
2763 // -----------------------------------------------------------------------
2764 
Clone(SfxItemPool *) const2765 SfxPoolItem* SvxNoLinebreakItem::Clone( SfxItemPool* ) const
2766 {
2767 	return new SvxNoLinebreakItem( *this );
2768 }
2769 
2770 // -----------------------------------------------------------------------
2771 
Store(SvStream & rStrm,sal_uInt16) const2772 SvStream& SvxNoLinebreakItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2773 {
2774 	rStrm << (sal_Bool)GetValue();
2775 	return rStrm;
2776 }
2777 
2778 // -----------------------------------------------------------------------
2779 
Create(SvStream & rStrm,sal_uInt16) const2780 SfxPoolItem* SvxNoLinebreakItem::Create(SvStream& rStrm, sal_uInt16) const
2781 {
2782 	sal_Bool bValue;
2783 	rStrm >> bValue;
2784 	return new SvxNoLinebreakItem( bValue, Which() );
2785 }
2786 
2787 //------------------------------------------------------------------------
2788 
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const2789 SfxItemPresentation SvxNoLinebreakItem::GetPresentation
2790 (
2791     SfxItemPresentation /*ePres*/,
2792     SfxMapUnit          /*eCoreUnit*/,
2793     SfxMapUnit          /*ePresUnit*/,
2794     XubString&          rText, const IntlWrapper * /*pIntl*/
2795 )	const
2796 {
2797 	rText.Erase();
2798 	return SFX_ITEM_PRESENTATION_NONE;
2799 }
2800 
2801 // class SvxNoHyphenItem -------------------------------------------------
2802 
SvxNoHyphenItem(const sal_Bool bHyphen,const sal_uInt16 nId)2803 SvxNoHyphenItem::SvxNoHyphenItem( const sal_Bool bHyphen, const sal_uInt16 nId ) :
2804 	SfxBoolItem( nId , bHyphen )
2805 {
2806 }
2807 
2808 // -----------------------------------------------------------------------
2809 
Clone(SfxItemPool *) const2810 SfxPoolItem* SvxNoHyphenItem::Clone( SfxItemPool* ) const
2811 {
2812 	return new SvxNoHyphenItem( *this );
2813 }
2814 
2815 // -----------------------------------------------------------------------
2816 
Store(SvStream & rStrm,sal_uInt16) const2817 SvStream& SvxNoHyphenItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2818 {
2819 	rStrm << (sal_Bool) GetValue();
2820 	return rStrm;
2821 }
2822 
2823 // -----------------------------------------------------------------------
2824 
Create(SvStream & rStrm,sal_uInt16) const2825 SfxPoolItem* SvxNoHyphenItem::Create( SvStream& rStrm, sal_uInt16 ) const
2826 {
2827 	sal_Bool bValue;
2828 	rStrm >> bValue;
2829 	return new SvxNoHyphenItem( bValue, Which() );
2830 }
2831 
2832 //------------------------------------------------------------------------
2833 
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const2834 SfxItemPresentation SvxNoHyphenItem::GetPresentation
2835 (
2836     SfxItemPresentation /*ePres*/,
2837     SfxMapUnit          /*eCoreUnit*/,
2838     SfxMapUnit          /*ePresUnit*/,
2839     XubString&          rText, const IntlWrapper * /*pIntl*/
2840 )	const
2841 {
2842 	rText.Erase();
2843 	return SFX_ITEM_PRESENTATION_NONE;
2844 }
2845 
2846 /*
2847  * Dummy-Item fuer ToolBox-Controls:
2848  *
2849  */
2850 
2851 // -----------------------------------------------------------------------
2852 // class SvxLineColorItem (== SvxColorItem)
2853 // -----------------------------------------------------------------------
2854 
SvxLineColorItem(const sal_uInt16 nId)2855 SvxLineColorItem::SvxLineColorItem( const sal_uInt16 nId ) :
2856 	SvxColorItem( nId )
2857 {
2858 }
2859 
2860 // -----------------------------------------------------------------------
2861 
SvxLineColorItem(const Color & rCol,const sal_uInt16 nId)2862 SvxLineColorItem::SvxLineColorItem( const Color& rCol, const sal_uInt16 nId ) :
2863 	SvxColorItem( rCol, nId )
2864 {
2865 }
2866 
2867 // -----------------------------------------------------------------------
2868 
SvxLineColorItem(SvStream & rStrm,const sal_uInt16 nId)2869 SvxLineColorItem::SvxLineColorItem( SvStream &rStrm, const sal_uInt16 nId ) :
2870 	SvxColorItem( rStrm, nId )
2871 {
2872 }
2873 
2874 // -----------------------------------------------------------------------
2875 
SvxLineColorItem(const SvxLineColorItem & rCopy)2876 SvxLineColorItem::SvxLineColorItem( const SvxLineColorItem &rCopy ) :
2877 	SvxColorItem( rCopy )
2878 {
2879 }
2880 
2881 // -----------------------------------------------------------------------
2882 
~SvxLineColorItem()2883 SvxLineColorItem::~SvxLineColorItem()
2884 {
2885 }
2886 
2887 //------------------------------------------------------------------------
2888 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,XubString & rText,const IntlWrapper * pIntlWrapper) const2889 SfxItemPresentation SvxLineColorItem::GetPresentation
2890 (
2891 	SfxItemPresentation ePres,
2892     SfxMapUnit          eCoreUnit,
2893     SfxMapUnit          ePresUnit,
2894 	XubString& 			rText,
2895     const IntlWrapper * pIntlWrapper
2896 )	const
2897 {
2898 	return SvxColorItem::GetPresentation( ePres, eCoreUnit, ePresUnit,
2899                                           rText, pIntlWrapper );
2900 }
2901 
2902 // class SvxBlinkItem -------------------------------------------------
2903 
2904 
SvxBlinkItem(const sal_Bool bBlink,const sal_uInt16 nId)2905 SvxBlinkItem::SvxBlinkItem( const sal_Bool bBlink, const sal_uInt16 nId ) :
2906 	SfxBoolItem( nId, bBlink )
2907 {
2908 }
2909 
2910 // -----------------------------------------------------------------------
2911 
Clone(SfxItemPool *) const2912 SfxPoolItem* SvxBlinkItem::Clone( SfxItemPool * ) const
2913 {
2914 	return new SvxBlinkItem( *this );
2915 }
2916 
2917 // -----------------------------------------------------------------------
2918 
Store(SvStream & rStrm,sal_uInt16) const2919 SvStream& SvxBlinkItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2920 {
2921 	rStrm << (sal_uInt8) GetValue();
2922 	return rStrm;
2923 }
2924 
2925 // -----------------------------------------------------------------------
2926 
Create(SvStream & rStrm,sal_uInt16) const2927 SfxPoolItem* SvxBlinkItem::Create(SvStream& rStrm, sal_uInt16) const
2928 {
2929 	sal_uInt8 nState;
2930 	rStrm >> nState;
2931 	return new SvxBlinkItem( nState, Which() );
2932 }
2933 
2934 // -----------------------------------------------------------------------
2935 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const2936 SfxItemPresentation SvxBlinkItem::GetPresentation
2937 (
2938 	SfxItemPresentation ePres,
2939     SfxMapUnit          /*eCoreUnit*/,
2940     SfxMapUnit          /*ePresUnit*/,
2941     XubString&          rText, const IntlWrapper * /*pIntl*/
2942 )	const
2943 {
2944 	switch ( ePres )
2945 	{
2946 		case SFX_ITEM_PRESENTATION_NONE:
2947 			rText.Erase();
2948 			return ePres;
2949 		case SFX_ITEM_PRESENTATION_NAMELESS:
2950 		case SFX_ITEM_PRESENTATION_COMPLETE:
2951 		{
2952 			sal_uInt16 nId = RID_SVXITEMS_BLINK_FALSE;
2953 
2954 			if ( GetValue() )
2955 				nId = RID_SVXITEMS_BLINK_TRUE;
2956 			rText = EE_RESSTR(nId);
2957 			return ePres;
2958 		}
2959         default: ; //prevent warning
2960     }
2961 	return SFX_ITEM_PRESENTATION_NONE;
2962 }
2963 
2964 // class SvxEmphaisMarkItem ---------------------------------------------------
2965 
SvxEmphasisMarkItem(const FontEmphasisMark nValue,const sal_uInt16 nId)2966 SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue,
2967 										const sal_uInt16 nId )
2968 	: SfxUInt16Item( nId, nValue )
2969 {
2970 }
2971 
2972 // -----------------------------------------------------------------------
2973 
Clone(SfxItemPool *) const2974 SfxPoolItem* SvxEmphasisMarkItem::Clone( SfxItemPool * ) const
2975 {
2976 	return new SvxEmphasisMarkItem( *this );
2977 }
2978 
2979 // -----------------------------------------------------------------------
2980 
Store(SvStream & rStrm,sal_uInt16) const2981 SvStream& SvxEmphasisMarkItem::Store( SvStream& rStrm,
2982                                      sal_uInt16 /*nItemVersion*/ ) const
2983 {
2984 	rStrm << (sal_uInt16)GetValue();
2985 	return rStrm;
2986 }
2987 
2988 // -----------------------------------------------------------------------
2989 
Create(SvStream & rStrm,sal_uInt16) const2990 SfxPoolItem* SvxEmphasisMarkItem::Create( SvStream& rStrm, sal_uInt16 ) const
2991 {
2992 	sal_uInt16 nValue;
2993 	rStrm >> nValue;
2994 	return new SvxEmphasisMarkItem( (FontEmphasisMark)nValue, Which() );
2995 }
2996 
2997 //------------------------------------------------------------------------
2998 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const2999 SfxItemPresentation SvxEmphasisMarkItem::GetPresentation
3000 (
3001 	SfxItemPresentation ePres,
3002     SfxMapUnit          /*eCoreUnit*/,
3003     SfxMapUnit          /*ePresUnit*/,
3004 	XubString& 			rText,
3005     const IntlWrapper * /*pIntl*/
3006 )	const
3007 {
3008 	switch ( ePres )
3009 	{
3010 		case SFX_ITEM_PRESENTATION_NONE:
3011 			rText.Erase();
3012 			return ePres;
3013 		case SFX_ITEM_PRESENTATION_NAMELESS:
3014 		case SFX_ITEM_PRESENTATION_COMPLETE:
3015 			{
3016 				sal_uInt16 nVal = GetValue();
3017 		    	rText = EE_RESSTR( RID_SVXITEMS_EMPHASIS_BEGIN_STYLE +
3018 										( EMPHASISMARK_STYLE & nVal ));
3019 				sal_uInt16 nId = ( EMPHASISMARK_POS_ABOVE & nVal )
3020 								? RID_SVXITEMS_EMPHASIS_ABOVE_POS
3021 								: ( EMPHASISMARK_POS_BELOW & nVal )
3022 									? RID_SVXITEMS_EMPHASIS_BELOW_POS
3023 									: 0;
3024 				if( nId )
3025 					rText += EE_RESSTR( nId );
3026 				return ePres;
3027 			}
3028         default: ; //prevent warning
3029     }
3030 	return SFX_ITEM_PRESENTATION_NONE;
3031 }
3032 
3033 // -----------------------------------------------------------------------
3034 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const3035 sal_Bool SvxEmphasisMarkItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
3036 {
3037 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3038     nMemberId &= ~CONVERT_TWIPS;
3039 	switch( nMemberId )
3040 	{
3041 	case MID_EMPHASIS:
3042 	{
3043 		sal_Int16 nValue = GetValue();
3044 		sal_Int16 nRet = 0;
3045 		switch(nValue & EMPHASISMARK_STYLE)
3046 		{
3047 			case EMPHASISMARK_NONE   : nRet = FontEmphasis::NONE;			break;
3048 			case EMPHASISMARK_DOT	 : nRet = FontEmphasis::DOT_ABOVE;		break;
3049 			case EMPHASISMARK_CIRCLE : nRet = FontEmphasis::CIRCLE_ABOVE;	break;
3050 			case EMPHASISMARK_DISC	 : nRet = FontEmphasis::DISK_ABOVE;		break;
3051 			case EMPHASISMARK_ACCENT : nRet = FontEmphasis::ACCENT_ABOVE;	break;
3052 		}
3053 		if(nRet && nValue & EMPHASISMARK_POS_BELOW)
3054 			nRet += 10;
3055 		rVal <<= nRet;
3056 	}
3057 	break;
3058 	}
3059 	return sal_True;
3060 }
3061 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)3062 sal_Bool SvxEmphasisMarkItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
3063 {
3064 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3065     nMemberId &= ~CONVERT_TWIPS;
3066 	sal_Bool bRet = sal_True;
3067 	switch( nMemberId )
3068 	{
3069 	case MID_EMPHASIS:
3070 	{
3071 		sal_Int32 nValue = -1;
3072 		rVal >>= nValue;
3073 		switch(nValue)
3074 		{
3075 			case FontEmphasis::NONE 	   : nValue = EMPHASISMARK_NONE;   break;
3076 			case FontEmphasis::DOT_ABOVE   : nValue = EMPHASISMARK_DOT|EMPHASISMARK_POS_ABOVE;    break;
3077 			case FontEmphasis::CIRCLE_ABOVE: nValue = EMPHASISMARK_CIRCLE|EMPHASISMARK_POS_ABOVE; break;
3078 			case FontEmphasis::DISK_ABOVE  : nValue = EMPHASISMARK_DISC|EMPHASISMARK_POS_ABOVE;   break;
3079 			case FontEmphasis::ACCENT_ABOVE: nValue = EMPHASISMARK_ACCENT|EMPHASISMARK_POS_ABOVE; break;
3080 			case FontEmphasis::DOT_BELOW   : nValue = EMPHASISMARK_DOT|EMPHASISMARK_POS_BELOW;    break;
3081 			case FontEmphasis::CIRCLE_BELOW: nValue = EMPHASISMARK_CIRCLE|EMPHASISMARK_POS_BELOW; break;
3082 			case FontEmphasis::DISK_BELOW  : nValue = EMPHASISMARK_DISC|EMPHASISMARK_POS_BELOW;   break;
3083 			case FontEmphasis::ACCENT_BELOW: nValue = EMPHASISMARK_ACCENT|EMPHASISMARK_POS_BELOW; break;
3084 			default: return sal_False;
3085 		}
3086 		SetValue( (sal_Int16)nValue );
3087 	}
3088 	break;
3089 	}
3090 	return bRet;
3091 }
3092 
GetVersion(sal_uInt16 nFFVer) const3093 sal_uInt16 SvxEmphasisMarkItem::GetVersion( sal_uInt16 nFFVer ) const
3094 {
3095 	DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
3096 			SOFFICE_FILEFORMAT_40==nFFVer ||
3097 			SOFFICE_FILEFORMAT_50==nFFVer,
3098 			"SvxEmphasisMarkItem: Gibt es ein neues Fileformat?" );
3099 
3100 	return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3101 }
3102 
3103 
3104 /*************************************************************************
3105 |*    class SvxTwoLinesItem
3106 *************************************************************************/
3107 
SvxTwoLinesItem(sal_Bool bFlag,sal_Unicode nStartBracket,sal_Unicode nEndBracket,sal_uInt16 nW)3108 SvxTwoLinesItem::SvxTwoLinesItem( sal_Bool bFlag, sal_Unicode nStartBracket,
3109 									sal_Unicode nEndBracket, sal_uInt16 nW )
3110 	: SfxPoolItem( nW ),
3111     cStartBracket( nStartBracket ), cEndBracket( nEndBracket ), bOn( bFlag )
3112 {
3113 }
3114 
SvxTwoLinesItem(const SvxTwoLinesItem & rAttr)3115 SvxTwoLinesItem::SvxTwoLinesItem( const SvxTwoLinesItem& rAttr )
3116 	: SfxPoolItem( rAttr.Which() ),
3117     cStartBracket( rAttr.cStartBracket ),
3118     cEndBracket( rAttr.cEndBracket ),
3119     bOn( rAttr.bOn )
3120 {
3121 }
3122 
~SvxTwoLinesItem()3123 SvxTwoLinesItem::~SvxTwoLinesItem()
3124 {
3125 }
3126 
operator ==(const SfxPoolItem & rAttr) const3127 int SvxTwoLinesItem::operator==( const SfxPoolItem& rAttr ) const
3128 {
3129 	DBG_ASSERT( SfxPoolItem::operator==( rAttr ), "not equal attribute types" );
3130 	return bOn == ((SvxTwoLinesItem&)rAttr).bOn &&
3131 		   cStartBracket == ((SvxTwoLinesItem&)rAttr).cStartBracket &&
3132 		   cEndBracket == ((SvxTwoLinesItem&)rAttr).cEndBracket;
3133 }
3134 
Clone(SfxItemPool *) const3135 SfxPoolItem* SvxTwoLinesItem::Clone( SfxItemPool* ) const
3136 {
3137 	return new SvxTwoLinesItem( *this );
3138 }
3139 
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8 nMemberId) const3140 sal_Bool SvxTwoLinesItem::QueryValue( com::sun::star::uno::Any& rVal,
3141 								sal_uInt8 nMemberId ) const
3142 {
3143 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3144     nMemberId &= ~CONVERT_TWIPS;
3145 	sal_Bool bRet = sal_True;
3146 	switch( nMemberId )
3147 	{
3148 	case MID_TWOLINES:
3149 		rVal = Bool2Any( bOn );
3150 		break;
3151 	case MID_START_BRACKET:
3152 		{
3153 			OUString s;
3154 			if( cStartBracket )
3155 				s = OUString( cStartBracket );
3156 			rVal <<= s;
3157 		}
3158 		break;
3159 	case MID_END_BRACKET:
3160 		{
3161 			OUString s;
3162 			if( cEndBracket )
3163 				s = OUString( cEndBracket );
3164 			rVal <<= s;
3165 		}
3166 		break;
3167 	default:
3168 		bRet = sal_False;
3169 		break;
3170 	}
3171 	return bRet;
3172 }
3173 
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8 nMemberId)3174 sal_Bool SvxTwoLinesItem::PutValue( const com::sun::star::uno::Any& rVal,
3175 									sal_uInt8 nMemberId )
3176 {
3177 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3178     nMemberId &= ~CONVERT_TWIPS;
3179 	sal_Bool bRet = sal_False;
3180 	OUString s;
3181 	switch( nMemberId )
3182 	{
3183 	case MID_TWOLINES:
3184 		bOn = Any2Bool( rVal );
3185 		bRet = sal_True;
3186 		break;
3187 	case MID_START_BRACKET:
3188 		if( rVal >>= s )
3189 		{
3190 			cStartBracket = s.getLength() ? s[ 0 ] : 0;
3191 			bRet = sal_True;
3192 		}
3193 		break;
3194 	case MID_END_BRACKET:
3195 		if( rVal >>= s )
3196 		{
3197 			cEndBracket = s.getLength() ? s[ 0 ] : 0;
3198 			bRet = sal_True;
3199 		}
3200 		break;
3201 	}
3202 	return bRet;
3203 }
3204 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,String & rText,const IntlWrapper *) const3205 SfxItemPresentation SvxTwoLinesItem::GetPresentation( SfxItemPresentation ePres,
3206                             SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
3207                             String &rText, const IntlWrapper* /*pIntl*/ ) const
3208 {
3209 	switch( ePres )
3210 	{
3211 	case SFX_ITEM_PRESENTATION_NONE:
3212 		rText.Erase();
3213 		break;
3214 	case SFX_ITEM_PRESENTATION_NAMELESS:
3215 	case SFX_ITEM_PRESENTATION_COMPLETE:
3216 		{
3217 			if( !GetValue() )
3218 				rText = EE_RESSTR( RID_SVXITEMS_TWOLINES_OFF );
3219 			else
3220 			{
3221 				rText = EE_RESSTR( RID_SVXITEMS_TWOLINES );
3222 				if( GetStartBracket() )
3223 					rText.Insert( GetStartBracket(), 0 );
3224 				if( GetEndBracket() )
3225 					rText += GetEndBracket();
3226 			}
3227 			return ePres;
3228 		}
3229         default: ; //prevent warning
3230     }
3231 	return SFX_ITEM_PRESENTATION_NONE;
3232 }
3233 
3234 
Create(SvStream & rStrm,sal_uInt16) const3235 SfxPoolItem* SvxTwoLinesItem::Create( SvStream & rStrm, sal_uInt16 /*nVer*/) const
3236 {
3237     sal_Bool _bOn;
3238 	sal_Unicode cStart, cEnd;
3239     rStrm >> _bOn >> cStart >> cEnd;
3240     return new SvxTwoLinesItem( _bOn, cStart, cEnd, Which() );
3241 }
3242 
Store(SvStream & rStrm,sal_uInt16) const3243 SvStream& SvxTwoLinesItem::Store(SvStream & rStrm, sal_uInt16 /*nIVer*/) const
3244 {
3245 	rStrm << GetValue() << GetStartBracket() << GetEndBracket();
3246 	return rStrm;
3247 }
3248 
GetVersion(sal_uInt16 nFFVer) const3249 sal_uInt16 SvxTwoLinesItem::GetVersion( sal_uInt16 nFFVer ) const
3250 {
3251 	DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
3252 			SOFFICE_FILEFORMAT_40==nFFVer ||
3253 			SOFFICE_FILEFORMAT_50==nFFVer,
3254 			"SvxTwoLinesItem: Gibt es ein neues Fileformat?" );
3255 
3256 	return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3257 }
3258 
3259 
3260 /*************************************************************************
3261 |*    class SvxCharRotateItem
3262 *************************************************************************/
3263 
SvxCharRotateItem(sal_uInt16 nValue,sal_Bool bFitIntoLine,const sal_uInt16 nW)3264 SvxCharRotateItem::SvxCharRotateItem( sal_uInt16 nValue,
3265 					   				sal_Bool bFitIntoLine,
3266 					   				const sal_uInt16 nW )
3267 	: SfxUInt16Item( nW, nValue ), bFitToLine( bFitIntoLine )
3268 {
3269 }
3270 
Clone(SfxItemPool *) const3271 SfxPoolItem* SvxCharRotateItem::Clone( SfxItemPool* ) const
3272 {
3273 	return new SvxCharRotateItem( GetValue(), IsFitToLine(), Which() );
3274 }
3275 
Create(SvStream & rStrm,sal_uInt16) const3276 SfxPoolItem* SvxCharRotateItem::Create( SvStream& rStrm, sal_uInt16 ) const
3277 {
3278 	sal_uInt16 nVal;
3279 	sal_Bool b;
3280 	rStrm >> nVal >> b;
3281 	return new SvxCharRotateItem( nVal, b, Which() );
3282 }
3283 
Store(SvStream & rStrm,sal_uInt16) const3284 SvStream& SvxCharRotateItem::Store( SvStream & rStrm, sal_uInt16 ) const
3285 {
3286 	sal_Bool bFlag = IsFitToLine();
3287 	rStrm << GetValue() << bFlag;
3288 	return rStrm;
3289 }
3290 
GetVersion(sal_uInt16 nFFVer) const3291 sal_uInt16 SvxCharRotateItem::GetVersion( sal_uInt16 nFFVer ) const
3292 {
3293 	return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3294 }
3295 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,String & rText,const IntlWrapper *) const3296 SfxItemPresentation SvxCharRotateItem::GetPresentation(
3297 		SfxItemPresentation ePres,
3298         SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
3299         String &rText, const IntlWrapper*  ) const
3300 {
3301 	switch( ePres )
3302 	{
3303 	case SFX_ITEM_PRESENTATION_NONE:
3304 		rText.Erase();
3305 		break;
3306 	case SFX_ITEM_PRESENTATION_NAMELESS:
3307 	case SFX_ITEM_PRESENTATION_COMPLETE:
3308 		{
3309 			if( !GetValue() )
3310 				rText = EE_RESSTR( RID_SVXITEMS_CHARROTATE_OFF );
3311 			else
3312 			{
3313 				rText = EE_RESSTR( RID_SVXITEMS_CHARROTATE );
3314 				rText.SearchAndReplaceAscii( "$(ARG1)",
3315 							String::CreateFromInt32( GetValue() / 10 ));
3316 				if( IsFitToLine() )
3317 					rText += EE_RESSTR( RID_SVXITEMS_CHARROTATE_FITLINE );
3318 			}
3319 			return ePres;
3320 		}
3321         default: ; //prevent warning
3322     }
3323 	return SFX_ITEM_PRESENTATION_NONE;
3324 }
3325 
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8 nMemberId) const3326 sal_Bool SvxCharRotateItem::QueryValue( com::sun::star::uno::Any& rVal,
3327 								sal_uInt8 nMemberId ) const
3328 {
3329 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3330     nMemberId &= ~CONVERT_TWIPS;
3331 	sal_Bool bRet = sal_True;
3332 	switch( nMemberId )
3333 	{
3334 	case MID_ROTATE:
3335 		rVal <<= (sal_Int16)GetValue();
3336 		break;
3337 	case MID_FITTOLINE:
3338 		rVal = Bool2Any( IsFitToLine() );
3339 		break;
3340 	default:
3341 		bRet = sal_False;
3342 		break;
3343 	}
3344 	return bRet;
3345 }
3346 
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8 nMemberId)3347 sal_Bool SvxCharRotateItem::PutValue( const com::sun::star::uno::Any& rVal,
3348 									sal_uInt8 nMemberId )
3349 {
3350 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3351     nMemberId &= ~CONVERT_TWIPS;
3352 	sal_Bool bRet = sal_True;
3353 	switch( nMemberId )
3354 	{
3355 	case MID_ROTATE:
3356         {
3357             sal_Int16 nVal = 0;
3358             if((rVal >>= nVal) && (0 == nVal || 900 == nVal || 2700 == nVal))
3359                 SetValue( (sal_uInt16)nVal );
3360             else
3361                 bRet = sal_False;
3362             break;
3363         }
3364 
3365 	case MID_FITTOLINE:
3366 		SetFitToLine( Any2Bool( rVal ) );
3367 		break;
3368 	default:
3369 		bRet = sal_False;
3370 	}
3371 	return bRet;
3372 }
3373 
operator ==(const SfxPoolItem & rItem) const3374 int SvxCharRotateItem::operator==( const SfxPoolItem& rItem ) const
3375 {
3376 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
3377 	return SfxUInt16Item::operator==( rItem ) &&
3378 		   IsFitToLine() == ((const SvxCharRotateItem&)rItem).IsFitToLine();
3379 }
3380 
3381 
3382 /*************************************************************************
3383 |*    class SvxCharScaleItem
3384 *************************************************************************/
3385 
SvxCharScaleWidthItem(sal_uInt16 nValue,const sal_uInt16 nW)3386 SvxCharScaleWidthItem::SvxCharScaleWidthItem( sal_uInt16 nValue,
3387 					   						const sal_uInt16 nW )
3388 	: SfxUInt16Item( nW, nValue )
3389 {
3390 }
3391 
Clone(SfxItemPool *) const3392 SfxPoolItem* SvxCharScaleWidthItem::Clone( SfxItemPool* ) const
3393 {
3394 	return new SvxCharScaleWidthItem( GetValue(), Which() );
3395 }
3396 
Create(SvStream & rStrm,sal_uInt16) const3397 SfxPoolItem* SvxCharScaleWidthItem::Create( SvStream& rStrm, sal_uInt16 ) const
3398 {
3399 	sal_uInt16 nVal;
3400 	rStrm >> nVal;
3401 	SvxCharScaleWidthItem* pItem = new SvxCharScaleWidthItem( nVal, Which() );
3402 
3403     if ( Which() == EE_CHAR_FONTWIDTH )
3404     {
3405         // #87271#: Was a SvxFontWidthItem in 5.2
3406         // sal_uInt16 nFixWidth, sal_uInt16 nPropWidth.
3407         // nFixWidth has never been used...
3408 	    rStrm >> nVal;
3409         sal_uInt16 nTest;
3410 	    rStrm >> nTest;
3411         if ( nTest == 0x1234 )
3412 	        pItem->SetValue( nVal );
3413         else
3414             rStrm.SeekRel( -2*(long)sizeof(sal_uInt16) );
3415     }
3416 
3417     return pItem;
3418 }
3419 
Store(SvStream & rStream,sal_uInt16 nVer) const3420 SvStream& SvxCharScaleWidthItem::Store( SvStream& rStream, sal_uInt16 nVer ) const
3421 {
3422     SvStream& rRet = SfxUInt16Item::Store( rStream, nVer );
3423     if ( Which() == EE_CHAR_FONTWIDTH )
3424     {
3425         // see comment in Create()....
3426         rRet.SeekRel( -1*(long)sizeof(sal_uInt16) );
3427         rRet << (sal_uInt16)0;
3428         rRet << GetValue();
3429         // Really ugly, but not a problem for reading the doc in 5.2
3430         rRet << (sal_uInt16)0x1234;
3431     }
3432     return rRet;
3433 }
3434 
3435 
GetVersion(sal_uInt16 nFFVer) const3436 sal_uInt16 SvxCharScaleWidthItem::GetVersion( sal_uInt16 nFFVer ) const
3437 {
3438 	return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3439 }
3440 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,String & rText,const IntlWrapper *) const3441 SfxItemPresentation SvxCharScaleWidthItem::GetPresentation(
3442 		SfxItemPresentation ePres,
3443         SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
3444         String &rText, const IntlWrapper*  ) const
3445 {
3446 	switch( ePres )
3447 	{
3448 	case SFX_ITEM_PRESENTATION_NONE:
3449 		rText.Erase();
3450 		break;
3451 	case SFX_ITEM_PRESENTATION_NAMELESS:
3452 	case SFX_ITEM_PRESENTATION_COMPLETE:
3453 		{
3454 			if( !GetValue() )
3455 				rText = EE_RESSTR( RID_SVXITEMS_CHARSCALE_OFF );
3456 			else
3457 			{
3458 				rText = EE_RESSTR( RID_SVXITEMS_CHARSCALE );
3459 				rText.SearchAndReplaceAscii( "$(ARG1)",
3460 							String::CreateFromInt32( GetValue() ));
3461 			}
3462 			return ePres;
3463 		}
3464         default: ; //prevent warning
3465     }
3466 	return SFX_ITEM_PRESENTATION_NONE;
3467 }
3468 
PutValue(const uno::Any & rVal,sal_uInt8)3469 sal_Bool SvxCharScaleWidthItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
3470 {
3471     // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
3472     // where we still want this to be a sal_Int16
3473     sal_Int16 nValue = sal_Int16();
3474 	if (rVal >>= nValue)
3475 	{
3476         SetValue( (sal_uInt16) nValue );
3477 		return sal_True;
3478 	}
3479 
3480     DBG_ERROR( "SvxCharScaleWidthItem::PutValue - Wrong type!" );
3481 	return sal_False;
3482 }
3483 
QueryValue(uno::Any & rVal,sal_uInt8) const3484 sal_Bool SvxCharScaleWidthItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
3485 {
3486     // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
3487     // where we still want this to be a sal_Int16
3488     rVal <<= (sal_Int16)GetValue();
3489     return sal_True;
3490 }
3491 
3492 /*************************************************************************
3493 |*    class SvxCharReliefItem
3494 *************************************************************************/
3495 
SvxCharReliefItem(FontRelief eValue,const sal_uInt16 nId)3496 SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue,
3497 					   				  const sal_uInt16 nId )
3498 	: SfxEnumItem( nId, (sal_uInt16)eValue )
3499 {
3500 }
3501 
Clone(SfxItemPool *) const3502 SfxPoolItem* SvxCharReliefItem::Clone( SfxItemPool * ) const
3503 {
3504 	return new SvxCharReliefItem( *this );
3505 }
3506 
Create(SvStream & rStrm,sal_uInt16) const3507 SfxPoolItem* SvxCharReliefItem::Create(SvStream & rStrm, sal_uInt16) const
3508 {
3509 	sal_uInt16 nVal;
3510 	rStrm >> nVal;
3511 	return new SvxCharReliefItem( (FontRelief)nVal, Which() );
3512 }
3513 
Store(SvStream & rStrm,sal_uInt16) const3514 SvStream& SvxCharReliefItem::Store(SvStream & rStrm, sal_uInt16 /*nIVer*/) const
3515 {
3516 	sal_uInt16 nVal = GetValue();
3517 	rStrm << nVal;
3518 	return rStrm;
3519 }
3520 
GetVersion(sal_uInt16 nFFVer) const3521 sal_uInt16 SvxCharReliefItem::GetVersion( sal_uInt16 nFFVer ) const
3522 {
3523 	return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
3524 }
3525 
GetValueTextByPos(sal_uInt16 nPos) const3526 String SvxCharReliefItem::GetValueTextByPos( sal_uInt16 nPos ) const
3527 {
3528 	DBG_ASSERT( RID_SVXITEMS_RELIEF_ENGRAVED - RID_SVXITEMS_RELIEF_NONE,
3529 					"enum overflow" );
3530 	return String( EditResId( RID_SVXITEMS_RELIEF_BEGIN + nPos ));
3531 }
3532 
GetValueCount() const3533 sal_uInt16 SvxCharReliefItem::GetValueCount() const
3534 {
3535 	return RID_SVXITEMS_RELIEF_ENGRAVED - RID_SVXITEMS_RELIEF_NONE;
3536 }
3537 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const3538 SfxItemPresentation SvxCharReliefItem::GetPresentation
3539 (
3540     SfxItemPresentation ePres,
3541     SfxMapUnit          /*eCoreUnit*/,
3542     SfxMapUnit          /*ePresUnit*/,
3543     XubString&          rText, const IntlWrapper * /*pIntl*/
3544 )   const
3545 {
3546 	SfxItemPresentation eRet = ePres;
3547     switch( ePres )
3548     {
3549     case SFX_ITEM_PRESENTATION_NONE:
3550         rText.Erase();
3551 		break;
3552 
3553     case SFX_ITEM_PRESENTATION_NAMELESS:
3554     case SFX_ITEM_PRESENTATION_COMPLETE:
3555         rText = GetValueTextByPos( GetValue() );
3556 		break;
3557 
3558 	default:
3559 		eRet = SFX_ITEM_PRESENTATION_NONE;
3560     }
3561     return eRet;
3562 }
3563 
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8 nMemberId)3564 sal_Bool SvxCharReliefItem::PutValue( const com::sun::star::uno::Any& rVal,
3565 										sal_uInt8 nMemberId )
3566 {
3567 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3568     nMemberId &= ~CONVERT_TWIPS;
3569 	sal_Bool bRet = sal_True;
3570 	switch( nMemberId )
3571 	{
3572 	case MID_RELIEF:
3573 		{
3574             sal_Int16 nVal = -1;
3575 			rVal >>= nVal;
3576             if(nVal >= 0 && nVal <= RELIEF_ENGRAVED)
3577                 SetValue( (sal_uInt16)nVal );
3578             else
3579                 bRet = sal_False;
3580 		}
3581 		break;
3582 	default:
3583 		bRet = sal_False;
3584 		break;
3585 	}
3586 	return bRet;
3587 }
3588 
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8 nMemberId) const3589 sal_Bool SvxCharReliefItem::QueryValue( com::sun::star::uno::Any& rVal,
3590 										sal_uInt8 nMemberId ) const
3591 {
3592 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3593     nMemberId &= ~CONVERT_TWIPS;
3594 	sal_Bool bRet = sal_True;
3595 	switch( nMemberId )
3596 	{
3597 	case MID_RELIEF:
3598 		rVal <<= (sal_Int16)GetValue();
3599 		break;
3600 	default:
3601 		bRet = sal_False;
3602 		break;
3603 	}
3604 	return bRet;
3605 }
3606 
3607 /*************************************************************************
3608 |*    class SvxScriptTypeItemItem
3609 *************************************************************************/
3610 
SvxScriptTypeItem(sal_uInt16 nType)3611 SvxScriptTypeItem::SvxScriptTypeItem( sal_uInt16 nType )
3612 	: SfxUInt16Item( SID_ATTR_CHAR_SCRIPTTYPE, nType )
3613 {
3614 }
Clone(SfxItemPool *) const3615 SfxPoolItem* SvxScriptTypeItem::Clone( SfxItemPool * ) const
3616 {
3617 	return new SvxScriptTypeItem( GetValue() );
3618 }
3619 
3620 /*************************************************************************
3621 |*    class SvxScriptSetItem
3622 *************************************************************************/
3623 
SvxScriptSetItem(sal_uInt16 nSlotId,SfxItemPool & rPool)3624 SvxScriptSetItem::SvxScriptSetItem( sal_uInt16 nSlotId, SfxItemPool& rPool )
3625 	: SfxSetItem( nSlotId, new SfxItemSet( rPool,
3626 						SID_ATTR_CHAR_FONT,	SID_ATTR_CHAR_FONT ))
3627 {
3628 	sal_uInt16 nLatin, nAsian, nComplex;
3629 	GetWhichIds( nLatin, nAsian, nComplex );
3630 
3631 	sal_uInt16 aIds[ 9 ] = { 0 };
3632 	aIds[ 0 ] = aIds[ 1 ] = nLatin;
3633 	aIds[ 2 ] = aIds[ 3 ] = nAsian;
3634 	aIds[ 4 ] = aIds[ 5 ] = nComplex;
3635 	aIds[ 6 ] = aIds[ 7 ] = SID_ATTR_CHAR_SCRIPTTYPE;
3636 	aIds[ 8 ] = 0;
3637 
3638 	GetItemSet().SetRanges( aIds );
3639 }
3640 
Clone(SfxItemPool *) const3641 SfxPoolItem* SvxScriptSetItem::Clone( SfxItemPool * ) const
3642 {
3643 	SvxScriptSetItem* p = new SvxScriptSetItem( Which(), *GetItemSet().GetPool() );
3644 	p->GetItemSet().Put( GetItemSet(), sal_False );
3645 	return p;
3646 }
3647 
Create(SvStream &,sal_uInt16) const3648 SfxPoolItem* SvxScriptSetItem::Create( SvStream &, sal_uInt16 ) const
3649 {
3650 	return 0;
3651 }
3652 
GetItemOfScriptSet(const SfxItemSet & rSet,sal_uInt16 nId)3653 const SfxPoolItem* SvxScriptSetItem::GetItemOfScriptSet(
3654 							const SfxItemSet& rSet, sal_uInt16 nId )
3655 {
3656 	const SfxPoolItem* pI;
3657 	SfxItemState eSt = rSet.GetItemState( nId, sal_False, &pI );
3658 	if( SFX_ITEM_SET != eSt )
3659 		pI = SFX_ITEM_DEFAULT == eSt ? &rSet.Get( nId ) : 0;
3660 	return pI;
3661 }
3662 
GetItemOfScript(sal_uInt16 nSlotId,const SfxItemSet & rSet,sal_uInt16 nScript)3663 const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId, const SfxItemSet& rSet, sal_uInt16 nScript )
3664 {
3665 	sal_uInt16 nLatin, nAsian, nComplex;
3666 	GetWhichIds( nSlotId, rSet, nLatin, nAsian, nComplex );
3667 
3668 	const SfxPoolItem *pRet, *pAsn, *pCmplx;
3669 	switch( nScript )
3670 	{
3671 	default:				//no one valid -> match to latin
3672 	//  case SCRIPTTYPE_LATIN:
3673 		pRet = GetItemOfScriptSet( rSet, nLatin );
3674 		break;
3675 	case SCRIPTTYPE_ASIAN:
3676 		pRet = GetItemOfScriptSet( rSet, nAsian );
3677 		break;
3678 	case SCRIPTTYPE_COMPLEX:
3679 		pRet = GetItemOfScriptSet( rSet, nComplex );
3680 		break;
3681 
3682 	case SCRIPTTYPE_LATIN|SCRIPTTYPE_ASIAN:
3683 		if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
3684 			0 == (pAsn = GetItemOfScriptSet( rSet, nAsian )) ||
3685 			*pRet != *pAsn )
3686 			pRet = 0;
3687 		break;
3688 
3689 	case SCRIPTTYPE_LATIN|SCRIPTTYPE_COMPLEX:
3690 		if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
3691 			0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
3692 			*pRet != *pCmplx )
3693 			pRet = 0;
3694 		break;
3695 
3696 	case SCRIPTTYPE_ASIAN|SCRIPTTYPE_COMPLEX:
3697 		if( 0 == (pRet = GetItemOfScriptSet( rSet, nAsian )) ||
3698 			0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
3699 			*pRet != *pCmplx )
3700 			pRet = 0;
3701 		break;
3702 
3703 	case SCRIPTTYPE_LATIN|SCRIPTTYPE_ASIAN|SCRIPTTYPE_COMPLEX:
3704 		if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) ||
3705 			0 == (pAsn = GetItemOfScriptSet( rSet, nAsian )) ||
3706 			0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) ||
3707 			*pRet != *pAsn || *pRet != *pCmplx )
3708 			pRet = 0;
3709 		break;
3710 	}
3711 	return pRet;
3712 }
3713 
GetItemOfScript(sal_uInt16 nScript) const3714 const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nScript ) const
3715 {
3716     return GetItemOfScript( Which(), GetItemSet(), nScript );
3717 }
3718 
PutItemForScriptType(sal_uInt16 nScriptType,const SfxPoolItem & rItem)3719 void SvxScriptSetItem::PutItemForScriptType( sal_uInt16 nScriptType,
3720 											 const SfxPoolItem& rItem )
3721 {
3722 	sal_uInt16 nLatin, nAsian, nComplex;
3723 	GetWhichIds( nLatin, nAsian, nComplex );
3724 
3725 	SfxPoolItem* pCpy = rItem.Clone();
3726 	if( SCRIPTTYPE_LATIN & nScriptType )
3727 	{
3728 		pCpy->SetWhich( nLatin );
3729 		GetItemSet().Put( *pCpy );
3730 	}
3731 	if( SCRIPTTYPE_ASIAN & nScriptType )
3732 	{
3733 		pCpy->SetWhich( nAsian );
3734 		GetItemSet().Put( *pCpy );
3735 	}
3736 	if( SCRIPTTYPE_COMPLEX & nScriptType )
3737 	{
3738 		pCpy->SetWhich( nComplex );
3739 		GetItemSet().Put( *pCpy );
3740 	}
3741 	delete pCpy;
3742 }
3743 
GetWhichIds(sal_uInt16 nSlotId,const SfxItemSet & rSet,sal_uInt16 & rLatin,sal_uInt16 & rAsian,sal_uInt16 & rComplex)3744 void SvxScriptSetItem::GetWhichIds( sal_uInt16 nSlotId, const SfxItemSet& rSet, sal_uInt16& rLatin, sal_uInt16& rAsian, sal_uInt16& rComplex )
3745 {
3746 	const SfxItemPool& rPool = *rSet.GetPool();
3747 	GetSlotIds( nSlotId, rLatin, rAsian, rComplex );
3748 	rLatin = rPool.GetWhich( rLatin );
3749 	rAsian = rPool.GetWhich( rAsian );
3750 	rComplex = rPool.GetWhich( rComplex );
3751 }
3752 
GetWhichIds(sal_uInt16 & rLatin,sal_uInt16 & rAsian,sal_uInt16 & rComplex) const3753 void SvxScriptSetItem::GetWhichIds( sal_uInt16& rLatin, sal_uInt16& rAsian,
3754 									sal_uInt16& rComplex ) const
3755 {
3756     GetWhichIds( Which(), GetItemSet(), rLatin, rAsian, rComplex );
3757 }
3758 
GetSlotIds(sal_uInt16 nSlotId,sal_uInt16 & rLatin,sal_uInt16 & rAsian,sal_uInt16 & rComplex)3759 void SvxScriptSetItem::GetSlotIds( sal_uInt16 nSlotId, sal_uInt16& rLatin,
3760 									sal_uInt16& rAsian, sal_uInt16& rComplex )
3761 {
3762 	switch( nSlotId )
3763 	{
3764 	default:
3765 		DBG_ASSERT( sal_False, "wrong SlotId for class SvxScriptSetItem" );
3766 		// no break - default to font - Id Range !!
3767 
3768 	case SID_ATTR_CHAR_FONT:
3769 		rLatin = SID_ATTR_CHAR_FONT;
3770 		rAsian = SID_ATTR_CHAR_CJK_FONT;
3771 		rComplex = SID_ATTR_CHAR_CTL_FONT;
3772 		break;
3773 	case SID_ATTR_CHAR_FONTHEIGHT:
3774 		rLatin = SID_ATTR_CHAR_FONTHEIGHT;
3775 		rAsian = SID_ATTR_CHAR_CJK_FONTHEIGHT;
3776 		rComplex = SID_ATTR_CHAR_CTL_FONTHEIGHT;
3777 		break;
3778 	case SID_ATTR_CHAR_WEIGHT:
3779 		rLatin = SID_ATTR_CHAR_WEIGHT;
3780 		rAsian = SID_ATTR_CHAR_CJK_WEIGHT;
3781 		rComplex = SID_ATTR_CHAR_CTL_WEIGHT;
3782 		break;
3783 	case SID_ATTR_CHAR_POSTURE:
3784 		rLatin = SID_ATTR_CHAR_POSTURE;
3785 		rAsian = SID_ATTR_CHAR_CJK_POSTURE;
3786 		rComplex = SID_ATTR_CHAR_CTL_POSTURE;
3787 		break;
3788 	case SID_ATTR_CHAR_LANGUAGE:
3789 		rLatin = SID_ATTR_CHAR_LANGUAGE;
3790 		rAsian = SID_ATTR_CHAR_CJK_LANGUAGE;
3791 		rComplex = SID_ATTR_CHAR_CTL_LANGUAGE;
3792 		break;
3793     case SID_ATTR_CHAR_SHADOWED:
3794 		rLatin = SID_ATTR_CHAR_SHADOWED;
3795 		rAsian = SID_ATTR_CHAR_SHADOWED;
3796 		rComplex = SID_ATTR_CHAR_SHADOWED;
3797 		break;
3798 	case SID_ATTR_CHAR_STRIKEOUT:
3799 		rLatin = SID_ATTR_CHAR_STRIKEOUT;
3800 		rAsian = SID_ATTR_CHAR_STRIKEOUT;
3801 		rComplex = SID_ATTR_CHAR_STRIKEOUT;
3802 		break;
3803 	}
3804 }
3805 
GetDefaultFonts(SvxFontItem & rLatin,SvxFontItem & rAsian,SvxFontItem & rComplex)3806 void GetDefaultFonts( SvxFontItem& rLatin, SvxFontItem& rAsian, SvxFontItem& rComplex )
3807 {
3808 	const sal_uInt16 nItemCnt = 3;
3809 
3810 	static struct
3811 	{
3812 		sal_uInt16 nFontType;
3813 		sal_uInt16 nLanguage;
3814 	}
3815 	aOutTypeArr[ nItemCnt ] =
3816 	{
3817 		{  DEFAULTFONT_LATIN_TEXT, LANGUAGE_ENGLISH_US },
3818 		{  DEFAULTFONT_CJK_TEXT, LANGUAGE_ENGLISH_US },
3819 		{  DEFAULTFONT_CTL_TEXT, LANGUAGE_ARABIC_SAUDI_ARABIA }
3820 	};
3821 
3822 	SvxFontItem* aItemArr[ nItemCnt ] = { &rLatin, &rAsian, &rComplex };
3823 
3824 	for ( sal_uInt16 n = 0; n < nItemCnt; ++n )
3825 	{
3826 		Font aFont( OutputDevice::GetDefaultFont( aOutTypeArr[ n ].nFontType,
3827 												  aOutTypeArr[ n ].nLanguage,
3828 												  DEFAULTFONT_FLAGS_ONLYONE, 0 ) );
3829 		SvxFontItem* pItem = aItemArr[ n ];
3830         pItem->SetFamily( aFont.GetFamily() );
3831         pItem->SetFamilyName( aFont.GetName() );
3832         pItem->SetStyleName( String() );
3833         pItem->SetPitch( aFont.GetPitch());
3834         pItem->SetCharSet(aFont.GetCharSet());
3835 	}
3836 }
3837 
3838 
GetI18NScriptTypeOfLanguage(sal_uInt16 nLang)3839 sal_uInt16 GetI18NScriptTypeOfLanguage( sal_uInt16 nLang )
3840 {
3841     return GetI18NScriptType( SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ) );
3842 }
3843 
GetItemScriptType(short nI18NType)3844 sal_uInt16 GetItemScriptType( short nI18NType )
3845 {
3846     switch ( nI18NType )
3847     {
3848 	    case i18n::ScriptType::LATIN:   return SCRIPTTYPE_LATIN;
3849 	    case i18n::ScriptType::ASIAN:   return SCRIPTTYPE_ASIAN;
3850 	    case i18n::ScriptType::COMPLEX: return SCRIPTTYPE_COMPLEX;
3851     }
3852     return 0;
3853 }
3854 
GetI18NScriptType(sal_uInt16 nItemType)3855 short GetI18NScriptType( sal_uInt16 nItemType )
3856 {
3857     switch ( nItemType )
3858     {
3859         case SCRIPTTYPE_LATIN:      return i18n::ScriptType::LATIN;
3860         case SCRIPTTYPE_ASIAN:      return i18n::ScriptType::ASIAN;
3861         case SCRIPTTYPE_COMPLEX:    return i18n::ScriptType::COMPLEX;
3862     }
3863     return 0;
3864 }
3865