xref: /AOO41X/main/cui/source/tabpages/chardlg.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
30 
31 // include ---------------------------------------------------------------
32 #include <editeng/unolingu.hxx>
33 #include <vcl/svapp.hxx>
34 #include <unotools/pathoptions.hxx>
35 #include <svtools/ctrltool.hxx>
36 #include <svl/sfontitm.hxx>
37 #include <sfx2/printer.hxx>
38 #include <sfx2/objsh.hxx>
39 #include <sfx2/viewsh.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <sfx2/viewfrm.hxx>
42 #include <vcl/msgbox.hxx>
43 #include <svx/dialmgr.hxx>
44 #include <svx/dialogs.hrc>
45 #include <svtools/unitconv.hxx>
46 
47 #define _SVX_CHARDLG_CXX
48 #include <svl/languageoptions.hxx>
49 
50 #include <cuires.hrc>
51 #include "chardlg.hrc"
52 
53 #include <svx/xtable.hxx>		// XColorTable
54 #include "chardlg.hxx"
55 #include "editeng/fontitem.hxx"
56 #include <editeng/postitem.hxx>
57 #include <editeng/udlnitem.hxx>
58 #include <editeng/crsditem.hxx>
59 #include <editeng/cntritem.hxx>
60 #include <editeng/langitem.hxx>
61 #include <editeng/wghtitem.hxx>
62 #include <editeng/fhgtitem.hxx>
63 #include <editeng/shdditem.hxx>
64 #include <editeng/escpitem.hxx>
65 #include <editeng/prszitem.hxx>
66 #include <editeng/wrlmitem.hxx>
67 #include <editeng/cmapitem.hxx>
68 #include <editeng/kernitem.hxx>
69 #include <editeng/blnkitem.hxx>
70 #include "editeng/flstitem.hxx"
71 #include <editeng/akrnitem.hxx>
72 #include <editeng/brshitem.hxx>
73 #include <editeng/colritem.hxx>
74 #include "svx/drawitem.hxx"
75 #include "svx/dlgutil.hxx"
76 #include <dialmgr.hxx>
77 #include "svx/htmlmode.hxx"
78 #include "cuicharmap.hxx"
79 #include "chardlg.h"
80 #include <editeng/emphitem.hxx>
81 #include <editeng/charreliefitem.hxx>
82 #include <editeng/twolinesitem.hxx>
83 #include <editeng/charhiddenitem.hxx>
84 #include <svl/stritem.hxx>
85 #include <editeng/charscaleitem.hxx>
86 #include <editeng/charrotateitem.hxx>
87 #include <svx/svxdlg.hxx> //CHINA001
88 #include <cuires.hrc> //CHINA001
89 #include <svl/intitem.hxx> //CHINA001
90 #include <sfx2/request.hxx> //CHINA001
91 #include "svx/flagsdef.hxx" //CHINA001
92 
93 using namespace ::com::sun::star;
94 
95 // define ----------------------------------------------------------------
96 
97 #define ISITEMSET	rSet.GetItemState(nWhich)>=SFX_ITEM_DEFAULT
98 
99 #define CLEARTITEM	rSet.InvalidateItem(nWhich)
100 
101 #define LW_NORMAL	0
102 #define LW_GESPERRT 1
103 #define LW_SCHMAL	2
104 
105 // static ----------------------------------------------------------------
106 
107 static sal_uInt16 pNameRanges[] =
108 {
109 	SID_ATTR_CHAR_FONT,
110 	SID_ATTR_CHAR_WEIGHT,
111 	SID_ATTR_CHAR_FONTHEIGHT,
112 	SID_ATTR_CHAR_FONTHEIGHT,
113 	SID_ATTR_CHAR_COLOR,
114 	SID_ATTR_CHAR_COLOR,
115 	SID_ATTR_CHAR_LANGUAGE,
116 	SID_ATTR_CHAR_LANGUAGE,
117 	SID_ATTR_CHAR_CJK_FONT,
118 	SID_ATTR_CHAR_CJK_WEIGHT,
119 	SID_ATTR_CHAR_CTL_FONT,
120 	SID_ATTR_CHAR_CTL_WEIGHT,
121 	0
122 };
123 
124 static sal_uInt16 pEffectsRanges[] =
125 {
126 	SID_ATTR_CHAR_SHADOWED,
127 	SID_ATTR_CHAR_UNDERLINE,
128 	SID_ATTR_CHAR_COLOR,
129 	SID_ATTR_CHAR_COLOR,
130 	SID_ATTR_CHAR_CASEMAP,
131 	SID_ATTR_CHAR_CASEMAP,
132 	SID_ATTR_FLASH,
133 	SID_ATTR_FLASH,
134 	SID_ATTR_CHAR_EMPHASISMARK,
135 	SID_ATTR_CHAR_EMPHASISMARK,
136 	SID_ATTR_CHAR_RELIEF,
137 	SID_ATTR_CHAR_RELIEF,
138 	SID_ATTR_CHAR_HIDDEN,
139 	SID_ATTR_CHAR_HIDDEN,
140 	SID_ATTR_CHAR_OVERLINE,
141 	SID_ATTR_CHAR_OVERLINE,
142 	0
143 };
144 
145 static sal_uInt16 pPositionRanges[] =
146 {
147 	SID_ATTR_CHAR_KERNING,
148 	SID_ATTR_CHAR_KERNING,
149 	SID_ATTR_CHAR_ESCAPEMENT,
150 	SID_ATTR_CHAR_ESCAPEMENT,
151 	SID_ATTR_CHAR_AUTOKERN,
152 	SID_ATTR_CHAR_AUTOKERN,
153 	SID_ATTR_CHAR_ROTATED,
154 	SID_ATTR_CHAR_SCALEWIDTH,
155 	SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
156 	SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
157 	0
158 };
159 
160 static sal_uInt16 pTwoLinesRanges[] =
161 {
162 	SID_ATTR_CHAR_TWO_LINES,
163 	SID_ATTR_CHAR_TWO_LINES,
164 	0
165 };
166 
167 // C-Funktion ------------------------------------------------------------
168 
169 inline sal_Bool StateToAttr( TriState aState )
170 {
171 	return ( STATE_CHECK == aState );
172 }
173 
174 // class SvxCharBasePage -------------------------------------------------
175 
176 inline SvxFont& SvxCharBasePage::GetPreviewFont()
177 {
178 	return m_aPreviewWin.GetFont();
179 }
180 
181 // -----------------------------------------------------------------------
182 
183 inline SvxFont& SvxCharBasePage::GetPreviewCJKFont()
184 {
185 	return m_aPreviewWin.GetCJKFont();
186 }
187 // -----------------------------------------------------------------------
188 
189 inline SvxFont& SvxCharBasePage::GetPreviewCTLFont()
190 {
191 	return m_aPreviewWin.GetCTLFont();
192 }
193 
194 // -----------------------------------------------------------------------
195 
196 SvxCharBasePage::SvxCharBasePage( Window* pParent, const ResId& rResId, const SfxItemSet& rItemset,
197 								 sal_uInt16 nResIdPrewievWin, sal_uInt16 nResIdFontTypeFT ):
198 	SfxTabPage( pParent, rResId, rItemset ),
199     m_aPreviewWin( this, ResId( nResIdPrewievWin, *rResId.GetResMgr() ) ),
200     m_aFontTypeFT( this, ResId( nResIdFontTypeFT, *rResId.GetResMgr() ) ),
201 	m_bPreviewBackgroundToCharacter( sal_False )
202 {
203 }
204 
205 // -----------------------------------------------------------------------
206 
207 SvxCharBasePage::~SvxCharBasePage()
208 {
209 }
210 
211 // -----------------------------------------------------------------------
212 
213 //void SvxCharBasePage::SetPrevFontAttributes( const SfxItemSet& rSet )
214 void SvxCharBasePage::ActivatePage( const SfxItemSet& rSet )
215 {
216 	SvxFont&		rFont = GetPreviewFont();
217     SvxFont&		rCJKFont = GetPreviewCJKFont();
218 	SvxFont&		rCTLFont = GetPreviewCTLFont();
219 	sal_uInt16			nWhich;
220 
221     nWhich = GetWhich( SID_CHAR_DLG_PREVIEW_STRING );
222     if( ISITEMSET )
223     {
224         const SfxStringItem& rItem = ( SfxStringItem& ) rSet.Get( nWhich );
225         ::rtl::OUString aString = rItem.GetValue();
226         if( aString.getLength() != 0 )
227             m_aPreviewWin.SetPreviewText( aString );
228         else
229             m_aPreviewWin.SetFontNameAsPreviewText();
230     }
231 
232 	// Underline
233 	FontUnderline eUnderline;
234 	nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
235 	if( ISITEMSET )
236 	{
237 		const SvxUnderlineItem& rItem = ( SvxUnderlineItem& ) rSet.Get( nWhich );
238 		eUnderline = ( FontUnderline ) rItem.GetValue();
239 		m_aPreviewWin.SetTextLineColor( rItem.GetColor() );
240 	}
241 	else
242 		eUnderline = UNDERLINE_NONE;
243 
244 	rFont.SetUnderline( eUnderline );
245     rCJKFont.SetUnderline( eUnderline );
246 	rCTLFont.SetUnderline( eUnderline );
247 
248 	// Overline
249 	FontUnderline eOverline;
250 	nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
251 	if( ISITEMSET )
252 	{
253 		const SvxOverlineItem& rItem = ( SvxOverlineItem& ) rSet.Get( nWhich );
254 		eOverline = ( FontUnderline ) rItem.GetValue();
255 		m_aPreviewWin.SetOverlineColor( rItem.GetColor() );
256 	}
257 	else
258 		eOverline = UNDERLINE_NONE;
259 
260 	rFont.SetOverline( eOverline );
261     rCJKFont.SetOverline( eOverline );
262 	rCTLFont.SetOverline( eOverline );
263 
264 	//	Strikeout
265 	FontStrikeout eStrikeout;
266 	nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
267 	if( ISITEMSET )
268 	{
269 		const SvxCrossedOutItem& rItem = ( SvxCrossedOutItem& ) rSet.Get( nWhich );
270 		eStrikeout = ( FontStrikeout ) rItem.GetValue();
271 	}
272 	else
273 		eStrikeout = STRIKEOUT_NONE;
274 
275 	rFont.SetStrikeout( eStrikeout );
276     rCJKFont.SetStrikeout( eStrikeout );
277 	rCTLFont.SetStrikeout( eStrikeout );
278 
279 	// WordLineMode
280 	nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
281 	if( ISITEMSET )
282 	{
283 		const SvxWordLineModeItem& rItem = ( SvxWordLineModeItem& ) rSet.Get( nWhich );
284 		rFont.SetWordLineMode( rItem.GetValue() );
285         rCJKFont.SetWordLineMode( rItem.GetValue() );
286 		rCTLFont.SetWordLineMode( rItem.GetValue() );
287 	}
288 
289 	// Emphasis
290 	nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
291 	if( ISITEMSET )
292 	{
293 		const SvxEmphasisMarkItem& rItem = ( SvxEmphasisMarkItem& ) rSet.Get( nWhich );
294 		FontEmphasisMark eMark = rItem.GetEmphasisMark();
295 		rFont.SetEmphasisMark( eMark );
296         rCJKFont.SetEmphasisMark( eMark );
297 		rCTLFont.SetEmphasisMark( eMark );
298 	}
299 
300     // Relief
301     nWhich = GetWhich( SID_ATTR_CHAR_RELIEF );
302     if( ISITEMSET )
303 	{
304         const SvxCharReliefItem& rItem = ( SvxCharReliefItem& ) rSet.Get( nWhich );
305 		FontRelief eFontRelief = ( FontRelief ) rItem.GetValue();
306         rFont.SetRelief( eFontRelief );
307         rCJKFont.SetRelief( eFontRelief );
308 		rCTLFont.SetRelief( eFontRelief );
309     }
310 
311 	// Effects
312 	nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
313 	if( ISITEMSET )
314 	{
315 		const SvxCaseMapItem& rItem = ( SvxCaseMapItem& ) rSet.Get( nWhich );
316 		SvxCaseMap eCaseMap = ( SvxCaseMap ) rItem.GetValue();
317 		rFont.SetCaseMap( eCaseMap );
318         rCJKFont.SetCaseMap( eCaseMap );
319         // #i78474# small caps do not exist in CTL fonts
320         rCTLFont.SetCaseMap( eCaseMap == SVX_CASEMAP_KAPITAELCHEN ? SVX_CASEMAP_NOT_MAPPED : eCaseMap );
321 	}
322 
323 	// Outline
324 	nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
325 	if( ISITEMSET )
326 	{
327 		const SvxContourItem& rItem = ( SvxContourItem& ) rSet.Get( nWhich );
328 		sal_Bool bOutline = rItem.GetValue();
329 		rFont.SetOutline( bOutline );
330         rCJKFont.SetOutline( bOutline );
331 		rCTLFont.SetOutline( bOutline );
332 	}
333 
334 	// Shadow
335 	nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
336 	if( ISITEMSET )
337 	{
338 		const SvxShadowedItem& rItem = ( SvxShadowedItem& ) rSet.Get( nWhich );
339 		sal_Bool bShadow = rItem.GetValue();
340 		rFont.SetShadow( bShadow );
341         rCJKFont.SetShadow( bShadow );
342 		rCTLFont.SetShadow( bShadow );
343 	}
344 
345 	// Background
346 	sal_Bool bTransparent;
347     nWhich = GetWhich( m_bPreviewBackgroundToCharacter ? SID_ATTR_BRUSH : SID_ATTR_BRUSH_CHAR );
348     if( ISITEMSET )
349     {
350          const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich );
351          const Color& rColor = rBrush.GetColor();
352 		 bTransparent = rColor.GetTransparency() > 0;
353          rFont.SetFillColor( rColor );
354          rCJKFont.SetFillColor( rColor );
355 		 rCTLFont.SetFillColor( rColor );
356     }
357     else
358         bTransparent = sal_True;
359 
360     rFont.SetTransparent( bTransparent );
361     rCJKFont.SetTransparent( bTransparent );
362 	rCTLFont.SetTransparent( bTransparent );
363 
364 	Color aBackCol( COL_TRANSPARENT );
365 	if( !m_bPreviewBackgroundToCharacter )
366 	{
367 		nWhich = GetWhich( SID_ATTR_BRUSH );
368 		if( ISITEMSET )
369 		{
370 			const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich );
371 			if( GPOS_NONE == rBrush.GetGraphicPos() )
372 				aBackCol = rBrush.GetColor();
373 		}
374 	}
375 	m_aPreviewWin.SetBackColor( aBackCol );
376 
377 	// Font
378 	SetPrevFont( rSet, SID_ATTR_CHAR_FONT, rFont );
379 	SetPrevFont( rSet, SID_ATTR_CHAR_CJK_FONT, rCJKFont );
380 	SetPrevFont( rSet, SID_ATTR_CHAR_CTL_FONT, rCTLFont );
381 
382 	// Style
383 	SetPrevFontStyle( rSet, SID_ATTR_CHAR_POSTURE, SID_ATTR_CHAR_WEIGHT, rFont );
384 	SetPrevFontStyle( rSet, SID_ATTR_CHAR_CJK_POSTURE, SID_ATTR_CHAR_CJK_WEIGHT, rCJKFont );
385 	SetPrevFontStyle( rSet, SID_ATTR_CHAR_CTL_POSTURE, SID_ATTR_CHAR_CTL_WEIGHT, rCTLFont );
386 
387 	// Size
388 	SetPrevFontSize( rSet, SID_ATTR_CHAR_FONTHEIGHT, rFont );
389 	SetPrevFontSize( rSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, rCJKFont );
390 	SetPrevFontSize( rSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, rCTLFont );
391 
392 	// Color
393 	nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
394 	if( ISITEMSET )
395 	{
396 		const SvxColorItem& rItem = ( SvxColorItem& ) rSet.Get( nWhich );
397 		Color aCol( rItem.GetValue() );
398 		rFont.SetColor( aCol );
399         rCJKFont.SetColor( aCol );
400 		rCTLFont.SetColor( aCol );
401 
402 		m_aPreviewWin.AutoCorrectFontColor();	// handle color COL_AUTO
403 	}
404 
405 	// Kerning
406 	nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
407 	if( ISITEMSET )
408 	{
409 		const SvxKerningItem& rItem = ( SvxKerningItem& ) rSet.Get( nWhich );
410 		short nKern = ( short )
411 						LogicToLogic( rItem.GetValue(), ( MapUnit ) rSet.GetPool()->GetMetric( nWhich ), MAP_TWIP );
412 		rFont.SetFixKerning( nKern );
413         rCJKFont.SetFixKerning( nKern );
414 		rCTLFont.SetFixKerning( nKern );
415 	}
416 
417 	// Escapement
418 	nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
419 	const sal_uInt8 nProp = 100;
420 	short nEsc;
421 	sal_uInt8 nEscProp;
422 	if( ISITEMSET )
423 	{
424 		const SvxEscapementItem& rItem = ( SvxEscapementItem& ) rSet.Get( nWhich );
425 		nEsc = rItem.GetEsc();
426 		nEscProp = rItem.GetProp();
427 
428 		if( nEsc == DFLT_ESC_AUTO_SUPER )
429 			nEsc = DFLT_ESC_SUPER;
430 		else if( nEsc == DFLT_ESC_AUTO_SUB )
431 			nEsc = DFLT_ESC_SUB;
432 	}
433 	else
434 	{
435 		nEsc  = 0;
436 		nEscProp = 100;
437 	}
438 
439 	SetPrevFontEscapement( nProp, nEscProp, nEsc );
440 
441 	// Font width scale
442 	SetPrevFontWidthScale( rSet );
443 
444     m_aPreviewWin.Invalidate();
445 }
446 
447 // -----------------------------------------------------------------------
448 
449 void SvxCharBasePage::SetPrevFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont )
450 {
451 	sal_uInt16 nWhich = GetWhich( nSlot );
452 	long nH;
453 	if( rSet.GetItemState( nWhich ) >= SFX_ITEM_SET )
454 	{
455 		nH = LogicToLogic(	( ( SvxFontHeightItem& ) rSet.Get( nWhich ) ).GetHeight(),
456 							( MapUnit ) rSet.GetPool()->GetMetric( nWhich ),
457 							MAP_TWIP );
458 	}
459 	else
460 		nH = 240;	// as default 12pt
461 
462 	rFont.SetSize( Size( 0, nH ) );
463 }
464 
465 // -----------------------------------------------------------------------
466 
467 void SvxCharBasePage::SetPrevFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont )
468 {
469 	sal_uInt16 nWhich = GetWhich( nSlot );
470 	if( ISITEMSET )
471 	{
472 		const SvxFontItem& rFontItem = ( SvxFontItem& ) rSet.Get( nWhich );
473 		rFont.SetFamily( rFontItem.GetFamily() );
474 		rFont.SetName( rFontItem.GetFamilyName() );
475 		rFont.SetPitch( rFontItem.GetPitch() );
476 		rFont.SetCharSet( rFontItem.GetCharSet() );
477 		rFont.SetStyleName( rFontItem.GetStyleName() );
478 	}
479 }
480 
481 // -----------------------------------------------------------------------
482 
483 void SvxCharBasePage::SetPrevFontStyle( const SfxItemSet& rSet, sal_uInt16 nPosture, sal_uInt16 nWeight, SvxFont& rFont )
484 {
485 	sal_uInt16 nWhich = GetWhich( nPosture );
486 	if( ISITEMSET )
487 	{
488 		const SvxPostureItem& rItem = ( SvxPostureItem& ) rSet.Get( nWhich );
489 		rFont.SetItalic( ( FontItalic ) rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE );
490 	}
491 
492     nWhich = GetWhich( nWeight );
493 	if( ISITEMSET )
494 	{
495 		SvxWeightItem& rItem = ( SvxWeightItem& ) rSet.Get( nWhich );
496 		rFont.SetWeight( ( FontWeight ) rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL );
497 	}
498 }
499 
500 // -----------------------------------------------------------------------
501 
502 void SvxCharBasePage::SetPrevFontWidthScale( const SfxItemSet& rSet )
503 {
504 	sal_uInt16	nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
505 	if( ISITEMSET )
506 	{
507 		const SvxCharScaleWidthItem&	rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich );
508 
509 		m_aPreviewWin.SetFontWidthScale( rItem.GetValue() );
510 	}
511 }
512 
513 // -----------------------------------------------------------------------
514 namespace
515 {
516 	// -----------------------------------------------------------------------
517 	void setPrevFontEscapement(SvxFont& _rFont,sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
518 	{
519 		_rFont.SetPropr( nProp );
520 		_rFont.SetProprRel( nEscProp );
521 		_rFont.SetEscapement( nEsc );
522 	}
523 	// -----------------------------------------------------------------------
524 	// -----------------------------------------------------------------------
525 }
526 // -----------------------------------------------------------------------
527 
528 void SvxCharBasePage::SetPrevFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
529 {
530 	setPrevFontEscapement(GetPreviewFont(),nProp,nEscProp,nEsc);
531 	setPrevFontEscapement(GetPreviewCJKFont(),nProp,nEscProp,nEsc);
532 	setPrevFontEscapement(GetPreviewCTLFont(),nProp,nEscProp,nEsc);
533     m_aPreviewWin.Invalidate();
534 }
535 
536 // SvxCharNamePage_Impl --------------------------------------------------
537 
538 struct SvxCharNamePage_Impl
539 {
540 	Timer			m_aUpdateTimer;
541 	String			m_aNoStyleText;
542 	String			m_aTransparentText;
543 	const FontList*	m_pFontList;
544 	sal_uInt16			m_nExtraEntryPos;
545 	sal_Bool			m_bMustDelete;
546 	sal_Bool			m_bInSearchMode;
547 
548 	SvxCharNamePage_Impl() :
549 
550 		m_pFontList		( NULL ),
551 		m_nExtraEntryPos( LISTBOX_ENTRY_NOTFOUND ),
552 		m_bMustDelete	( sal_False ),
553         m_bInSearchMode ( sal_False )
554 
555 	{
556 		m_aUpdateTimer.SetTimeout( 350 );
557 	}
558 
559 	~SvxCharNamePage_Impl()
560 	{
561 		if ( m_bMustDelete )
562 			delete m_pFontList;
563 	}
564 };
565 
566 // class SvxCharNamePage -------------------------------------------------
567 
568 SvxCharNamePage::SvxCharNamePage( Window* pParent, const SfxItemSet& rInSet ) :
569 
570 	SvxCharBasePage( pParent, CUI_RES( RID_SVXPAGE_CHAR_NAME ), rInSet, WIN_CHAR_PREVIEW, FT_CHAR_FONTTYPE ),
571     m_pImpl                 ( new SvxCharNamePage_Impl )
572 {
573 	m_pImpl->m_aNoStyleText = String( CUI_RES( STR_CHARNAME_NOSTYLE ) );
574 	m_pImpl->m_aTransparentText = String( CUI_RES( STR_CHARNAME_TRANSPARENT ) );
575 
576 	SvtLanguageOptions aLanguageOptions;
577     sal_Bool bCJK = ( aLanguageOptions.IsCJKFontEnabled() || aLanguageOptions.IsCTLFontEnabled() );
578 
579     m_pWestLine         = new FixedLine( this, CUI_RES( FL_WEST ) );
580     m_pWestFontNameFT   = new FixedText( this, CUI_RES( bCJK ? FT_WEST_NAME : FT_WEST_NAME_NOCJK ) );
581     m_pWestFontNameLB   = new FontNameBox( this, CUI_RES( bCJK ? LB_WEST_NAME : LB_WEST_NAME_NOCJK ) );
582     m_pWestFontStyleFT  = new FixedText( this, CUI_RES( bCJK ? FT_WEST_STYLE : FT_WEST_STYLE_NOCJK ) );
583     m_pWestFontStyleLB  = new FontStyleBox( this, CUI_RES( bCJK ? LB_WEST_STYLE : LB_WEST_STYLE_NOCJK ) );
584     m_pWestFontSizeFT   = new FixedText( this, CUI_RES( bCJK ? FT_WEST_SIZE : FT_WEST_SIZE_NOCJK ) );
585     m_pWestFontSizeLB   = new FontSizeBox( this, CUI_RES( bCJK ? LB_WEST_SIZE : LB_WEST_SIZE_NOCJK ) );
586 
587     if( !bCJK )
588     {
589         m_pColorFL  = new FixedLine( this, CUI_RES( FL_COLOR2 ) );
590         m_pColorFT  = new FixedText( this, CUI_RES( FT_COLOR2 ) );
591         m_pColorLB  = new ColorListBox( this, CUI_RES( LB_COLOR2 ) );
592     }
593 
594     m_pWestFontLanguageFT   = new FixedText( this, CUI_RES( bCJK ? FT_WEST_LANG : FT_WEST_LANG_NOCJK ) );
595     m_pWestFontLanguageLB   = new SvxLanguageBox( this, CUI_RES( bCJK ? LB_WEST_LANG : LB_WEST_LANG_NOCJK ) );
596 
597     m_pEastLine             = new FixedLine( this, CUI_RES( FL_EAST ) );
598     m_pEastFontNameFT       = new FixedText( this, CUI_RES( FT_EAST_NAME ) );
599     m_pEastFontNameLB       = new FontNameBox( this, CUI_RES( LB_EAST_NAME ) );
600     m_pEastFontStyleFT      = new FixedText( this, CUI_RES( FT_EAST_STYLE ) );
601     m_pEastFontStyleLB      = new FontStyleBox( this, CUI_RES( LB_EAST_STYLE ) );
602     m_pEastFontSizeFT       = new FixedText( this, CUI_RES( FT_EAST_SIZE ) );
603     m_pEastFontSizeLB       = new FontSizeBox( this, CUI_RES( LB_EAST_SIZE ) );
604     m_pEastFontLanguageFT   = new FixedText( this, CUI_RES( FT_EAST_LANG ) );
605     m_pEastFontLanguageLB   = new SvxLanguageBox( this, CUI_RES( LB_EAST_LANG ) );
606 
607     m_pCTLLine              = new FixedLine( this, CUI_RES( FL_CTL ) );
608     m_pCTLFontNameFT        = new FixedText( this, CUI_RES( FT_CTL_NAME ) );
609     m_pCTLFontNameLB        = new FontNameBox( this, CUI_RES( LB_CTL_NAME ) );
610     m_pCTLFontStyleFT		= new FixedText( this, CUI_RES( FT_CTL_STYLE ) );
611     m_pCTLFontStyleLB		= new FontStyleBox( this, CUI_RES( LB_CTL_STYLE ) );
612     m_pCTLFontSizeFT		= new FixedText( this, CUI_RES( FT_CTL_SIZE ) );
613     m_pCTLFontSizeLB		= new FontSizeBox( this, CUI_RES( LB_CTL_SIZE ) );
614     m_pCTLFontLanguageFT	= new FixedText( this, CUI_RES( FT_CTL_LANG ) );
615     m_pCTLFontLanguageLB	= new SvxLanguageBox( this, CUI_RES( LB_CTL_LANG ) );
616 
617     if( bCJK )
618     {
619         m_pColorFL  = new FixedLine( this, CUI_RES( FL_COLOR2 ) );
620         m_pColorFT  = new FixedText( this, CUI_RES( FT_COLOR2 ) );
621         m_pColorLB  = new ColorListBox( this, CUI_RES( LB_COLOR2 ) );
622     }
623 
624     m_pWestLine             ->Show( bCJK );
625     m_pColorFL              ->Show( bCJK );
626 
627 	bCJK = aLanguageOptions.IsCJKFontEnabled();
628 	m_pEastLine             ->Show( bCJK );
629     m_pEastFontNameFT       ->Show( bCJK );
630     m_pEastFontNameLB       ->Show( bCJK );
631     m_pEastFontStyleFT      ->Show( bCJK );
632     m_pEastFontStyleLB      ->Show( bCJK );
633     m_pEastFontSizeFT       ->Show( bCJK );
634     m_pEastFontSizeLB       ->Show( bCJK );
635     m_pEastFontLanguageFT   ->Show( bCJK );
636     m_pEastFontLanguageLB   ->Show( bCJK );
637 
638 	sal_Bool bShowCTL = aLanguageOptions.IsCTLFontEnabled();
639 	if ( bShowCTL && !bCJK )
640 	{
641 		// move CTL controls to the places of the CJK controls, if these controls aren't visible
642 		m_pCTLLine             ->SetPosPixel( m_pEastLine->GetPosPixel() );
643     	m_pCTLFontNameFT       ->SetPosPixel( m_pEastFontNameFT->GetPosPixel() );
644     	m_pCTLFontNameLB       ->SetPosPixel( m_pEastFontNameLB->GetPosPixel() );
645     	m_pCTLFontStyleFT      ->SetPosPixel( m_pEastFontStyleFT->GetPosPixel() );
646     	m_pCTLFontStyleLB      ->SetPosPixel( m_pEastFontStyleLB->GetPosPixel() );
647     	m_pCTLFontSizeFT       ->SetPosPixel( m_pEastFontSizeFT->GetPosPixel() );
648     	m_pCTLFontSizeLB       ->SetPosPixel( m_pEastFontSizeLB->GetPosPixel() );
649     	m_pCTLFontLanguageFT   ->SetPosPixel( m_pEastFontLanguageFT->GetPosPixel() );
650     	m_pCTLFontLanguageLB   ->SetPosPixel( m_pEastFontLanguageLB->GetPosPixel() );
651 	}
652 	m_pCTLLine             ->Show( bShowCTL );
653     m_pCTLFontNameFT       ->Show( bShowCTL );
654     m_pCTLFontNameLB       ->Show( bShowCTL );
655     m_pCTLFontStyleFT      ->Show( bShowCTL );
656     m_pCTLFontStyleLB      ->Show( bShowCTL );
657     m_pCTLFontSizeFT       ->Show( bShowCTL );
658     m_pCTLFontSizeLB       ->Show( bShowCTL );
659     m_pCTLFontLanguageFT   ->Show( bShowCTL );
660     m_pCTLFontLanguageLB   ->Show( bShowCTL );
661 
662     FreeResource();
663 
664     m_pWestFontLanguageLB->SetLanguageList( LANG_LIST_WESTERN,	sal_True, sal_False, sal_True );
665     m_pEastFontLanguageLB->SetLanguageList( LANG_LIST_CJK,		sal_True, sal_False, sal_True );
666     m_pCTLFontLanguageLB->SetLanguageList( LANG_LIST_CTL,		sal_True, sal_False, sal_True );
667 
668 	Initialize();
669 }
670 
671 // -----------------------------------------------------------------------
672 
673 SvxCharNamePage::~SvxCharNamePage()
674 {
675 	delete m_pImpl;
676 
677     delete m_pWestLine;
678     delete m_pWestFontNameFT;
679     delete m_pWestFontNameLB;
680     delete m_pWestFontStyleFT;
681     delete m_pWestFontStyleLB;
682     delete m_pWestFontSizeFT;
683     delete m_pWestFontSizeLB;
684     delete m_pWestFontLanguageFT;
685     delete m_pWestFontLanguageLB;
686 
687     delete m_pEastLine;
688     delete m_pEastFontNameFT;
689     delete m_pEastFontNameLB;
690     delete m_pEastFontStyleFT;
691     delete m_pEastFontStyleLB;
692     delete m_pEastFontSizeFT;
693     delete m_pEastFontSizeLB;
694     delete m_pEastFontLanguageFT;
695     delete m_pEastFontLanguageLB;
696 
697     delete m_pCTLLine;
698     delete m_pCTLFontNameFT;
699     delete m_pCTLFontNameLB;
700     delete m_pCTLFontStyleFT;
701     delete m_pCTLFontStyleLB;
702     delete m_pCTLFontSizeFT;
703     delete m_pCTLFontSizeLB;
704     delete m_pCTLFontLanguageFT;
705     delete m_pCTLFontLanguageLB;
706 
707     delete m_pColorFL;
708     delete m_pColorFT;
709     delete m_pColorLB;
710 }
711 
712 // -----------------------------------------------------------------------
713 
714 void SvxCharNamePage::Initialize()
715 {
716 	// to handle the changes of the other pages
717 	SetExchangeSupport();
718 
719 	// fill the color box
720 	SfxObjectShell* pDocSh = SfxObjectShell::Current();
721 	//DBG_ASSERT( pDocSh, "DocShell not found!" );
722 	XColorTable* pColorTable = NULL;
723 	FASTBOOL bKillTable = sal_False;
724 	const SfxPoolItem* pItem = NULL;
725 
726 	if ( pDocSh )
727     {
728         pItem = pDocSh->GetItem( SID_COLOR_TABLE );
729         if ( pItem != NULL )
730             pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
731     }
732 
733 	if ( !pColorTable )
734 	{
735 		pColorTable = new XColorTable( SvtPathOptions().GetPalettePath() );
736 		bKillTable = sal_True;
737 	}
738 
739     m_pColorLB->SetUpdateMode( sal_False );
740 
741 	{
742 		SfxPoolItem* pDummy;
743 		SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocSh );
744 		if( !pFrame || SFX_ITEM_DEFAULT > pFrame->GetBindings().QueryState(
745 									SID_ATTR_AUTO_COLOR_INVALID, pDummy ))
746 	    	m_pColorLB->InsertEntry( Color( COL_AUTO ),
747 								 	SVX_RESSTR( RID_SVXSTR_AUTOMATIC ));
748 	}
749     for ( long i = 0; i < pColorTable->Count(); i++ )
750 	{
751         XColorEntry* pEntry = pColorTable->GetColor(i);
752         m_pColorLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
753 	}
754 
755     m_pColorLB->SetUpdateMode( sal_True );
756 
757 	if ( bKillTable )
758 		delete pColorTable;
759 
760     m_pColorLB->SetSelectHdl( LINK( this, SvxCharNamePage, ColorBoxSelectHdl_Impl ) );
761 
762 	Link aLink = LINK( this, SvxCharNamePage, FontModifyHdl_Impl );
763     m_pWestFontNameLB->SetModifyHdl( aLink );
764     m_pWestFontStyleLB->SetModifyHdl( aLink );
765     m_pWestFontSizeLB->SetModifyHdl( aLink );
766     m_pEastFontNameLB->SetModifyHdl( aLink );
767     m_pEastFontStyleLB->SetModifyHdl( aLink );
768     m_pEastFontSizeLB->SetModifyHdl( aLink );
769     m_pCTLFontNameLB->SetModifyHdl( aLink );
770     m_pCTLFontStyleLB->SetModifyHdl( aLink );
771     m_pCTLFontSizeLB->SetModifyHdl( aLink );
772 
773 	m_pImpl->m_aUpdateTimer.SetTimeoutHdl( LINK( this, SvxCharNamePage, UpdateHdl_Impl ) );
774 
775     m_pColorFL->Hide();
776     m_pColorFT->Hide();
777     m_pColorLB->Hide();
778 }
779 
780 // -----------------------------------------------------------------------
781 
782 const FontList* SvxCharNamePage::GetFontList() const
783 {
784     if ( !m_pImpl->m_pFontList )
785     {
786         SfxObjectShell* pDocSh = SfxObjectShell::Current();
787         const SfxPoolItem* pItem;
788 
789         /* #110771# SvxFontListItem::GetFontList can return NULL */
790         if ( pDocSh )
791         {
792             pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
793             if ( pItem != NULL )
794             {
795                 DBG_ASSERT(NULL != ( (SvxFontListItem*)pItem )->GetFontList(),
796                            "Where is the font list?");
797                     m_pImpl->m_pFontList =  static_cast<const SvxFontListItem*>(pItem )->GetFontList()->Clone();
798                 m_pImpl->m_bMustDelete = sal_True;
799             }
800         }
801         if(!m_pImpl->m_pFontList)
802         {
803             m_pImpl->m_pFontList =
804                 new FontList( Application::GetDefaultDevice() );
805             m_pImpl->m_bMustDelete = sal_True;
806         }
807     }
808 
809     return m_pImpl->m_pFontList;
810 }
811 
812 // -----------------------------------------------------------------------------
813 namespace
814 {
815 	FontInfo calcFontInfo(	SvxFont& _rFont,
816 					SvxCharNamePage* _pPage,
817 					const FontNameBox* _pFontNameLB,
818 					const FontStyleBox* _pFontStyleLB,
819 					const FontSizeBox* _pFontSizeLB,
820 					const FontList* _pFontList,
821 					sal_uInt16 _nFontWhich,
822 					sal_uInt16 _nFontHeightWhich)
823 	{
824 		Size aSize = _rFont.GetSize();
825 		aSize.Width() = 0;
826 		FontInfo aFontInfo;
827 		String sFontName(_pFontNameLB->GetText());
828 		sal_Bool bFontAvailable = _pFontList->IsAvailable( sFontName );
829 		if(bFontAvailable  || _pFontNameLB->GetSavedValue() != sFontName)
830 			aFontInfo = _pFontList->Get( sFontName, _pFontStyleLB->GetText() );
831 		else
832 		{
833 			//get the font from itemset
834 			SfxItemState eState = _pPage->GetItemSet().GetItemState( _nFontWhich );
835 			if ( eState >= SFX_ITEM_DEFAULT )
836 			{
837 				const SvxFontItem* pFontItem = (const SvxFontItem*)&( _pPage->GetItemSet().Get( _nFontWhich ) );
838 				aFontInfo.SetName(pFontItem->GetFamilyName());
839 				aFontInfo.SetStyleName(pFontItem->GetStyleName());
840 				aFontInfo.SetFamily(pFontItem->GetFamily());
841 				aFontInfo.SetPitch(pFontItem->GetPitch());
842 				aFontInfo.SetCharSet(pFontItem->GetCharSet());
843 			}
844 		}
845 		if ( _pFontSizeLB->IsRelative() )
846 		{
847 			DBG_ASSERT( _pPage->GetItemSet().GetParent(), "No parent set" );
848 			const SvxFontHeightItem& rOldItem = (SvxFontHeightItem&)_pPage->GetItemSet().GetParent()->Get( _nFontHeightWhich );
849 
850 			// alter Wert, skaliert
851 			long nHeight;
852 			if ( _pFontSizeLB->IsPtRelative() )
853 				nHeight = rOldItem.GetHeight() + PointToTwips( static_cast<long>(_pFontSizeLB->GetValue() / 10) );
854 			else
855 				nHeight = static_cast<long>(rOldItem.GetHeight() * _pFontSizeLB->GetValue() / 100);
856 
857 			// Umrechnung in twips fuer das Beispiel-Window
858 			aSize.Height() =
859 				ItemToControl( nHeight, _pPage->GetItemSet().GetPool()->GetMetric( _nFontHeightWhich ), SFX_FUNIT_TWIP );
860 		}
861 		else if ( _pFontSizeLB->GetText().Len() )
862 			aSize.Height() = PointToTwips( static_cast<long>(_pFontSizeLB->GetValue() / 10) );
863 		else
864 			aSize.Height() = 200;	// default 10pt
865 		aFontInfo.SetSize( aSize );
866 
867 		_rFont.SetFamily( aFontInfo.GetFamily() );
868 		_rFont.SetName( aFontInfo.GetName() );
869 		_rFont.SetStyleName( aFontInfo.GetStyleName() );
870 		_rFont.SetPitch( aFontInfo.GetPitch() );
871 		_rFont.SetCharSet( aFontInfo.GetCharSet() );
872 		_rFont.SetWeight( aFontInfo.GetWeight() );
873 		_rFont.SetItalic( aFontInfo.GetItalic() );
874 		_rFont.SetSize( aFontInfo.GetSize() );
875 
876 		return aFontInfo;
877 	}
878 }
879 
880 // -----------------------------------------------------------------------
881 
882 void SvxCharNamePage::UpdatePreview_Impl()
883 {
884 	SvxFont& rFont = GetPreviewFont();
885     SvxFont& rCJKFont = GetPreviewCJKFont();
886 	SvxFont& rCTLFont = GetPreviewCTLFont();
887 	// Size
888 	Size aSize = rFont.GetSize();
889 	aSize.Width() = 0;
890     Size aCJKSize = rCJKFont.GetSize();
891     aCJKSize.Width() = 0;
892 	Size aCTLSize = rCTLFont.GetSize();
893     aCTLSize.Width() = 0;
894 	// Font
895 	const FontList* pFontList = GetFontList();
896 	FontInfo aFontInfo =
897 		calcFontInfo(rFont,this,m_pWestFontNameLB,m_pWestFontStyleLB,m_pWestFontSizeLB,pFontList,GetWhich( SID_ATTR_CHAR_FONT ),GetWhich( SID_ATTR_CHAR_FONTHEIGHT ));
898 
899 	calcFontInfo(rCJKFont,this,m_pEastFontNameLB,m_pEastFontStyleLB,m_pEastFontSizeLB,pFontList,GetWhich( SID_ATTR_CHAR_CJK_FONT ),GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT ));
900 
901 	calcFontInfo(rCTLFont,this,m_pCTLFontNameLB,m_pCTLFontStyleLB,m_pCTLFontSizeLB,pFontList,GetWhich( SID_ATTR_CHAR_CTL_FONT ),GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT ));
902 
903     m_aPreviewWin.Invalidate();
904     m_aFontTypeFT.SetText( pFontList->GetFontMapText( aFontInfo ) );
905 }
906 
907 // -----------------------------------------------------------------------
908 
909 void SvxCharNamePage::FillStyleBox_Impl( const FontNameBox* pNameBox )
910 {
911 	const FontList* pFontList = GetFontList();
912 	DBG_ASSERT( pFontList, "no fontlist" );
913 
914 	FontStyleBox* pStyleBox = NULL;
915 
916     if ( m_pWestFontNameLB == pNameBox )
917 		pStyleBox = m_pWestFontStyleLB;
918     else if ( m_pEastFontNameLB == pNameBox )
919 		pStyleBox = m_pEastFontStyleLB;
920     else if ( m_pCTLFontNameLB == pNameBox )
921         pStyleBox = m_pCTLFontStyleLB;
922 	else
923 	{
924 		DBG_ERRORFILE( "invalid font name box" );
925 	}
926 
927 	pStyleBox->Fill( pNameBox->GetText(), pFontList );
928 
929 	if ( m_pImpl->m_bInSearchMode )
930 	{
931 		// Bei der Suche zus"atzliche Eintr"age:
932 		// "Nicht Fett" und "Nicht Kursiv"
933 		String aEntry = m_pImpl->m_aNoStyleText;
934 		const sal_Char sS[] = "%1";
935 		aEntry.SearchAndReplaceAscii( sS, pFontList->GetBoldStr() );
936         m_pImpl->m_nExtraEntryPos = pStyleBox->InsertEntry( aEntry );
937 		aEntry = m_pImpl->m_aNoStyleText;
938 		aEntry.SearchAndReplaceAscii( sS, pFontList->GetItalicStr() );
939         pStyleBox->InsertEntry( aEntry );
940 	}
941 }
942 
943 // -----------------------------------------------------------------------
944 
945 void SvxCharNamePage::FillSizeBox_Impl( const FontNameBox* pNameBox )
946 {
947 	const FontList* pFontList = GetFontList();
948 	DBG_ASSERT( pFontList, "no fontlist" );
949 
950 	FontStyleBox* pStyleBox = NULL;
951 	FontSizeBox* pSizeBox = NULL;
952 
953     if ( m_pWestFontNameLB == pNameBox )
954 	{
955 		pStyleBox = m_pWestFontStyleLB;
956 		pSizeBox = m_pWestFontSizeLB;
957 	}
958     else if ( m_pEastFontNameLB == pNameBox )
959 	{
960 		pStyleBox = m_pEastFontStyleLB;
961 		pSizeBox = m_pEastFontSizeLB;
962 	}
963     else if ( m_pCTLFontNameLB == pNameBox )
964 	{
965         pStyleBox = m_pCTLFontStyleLB;
966 		pSizeBox = m_pCTLFontSizeLB;
967 	}
968 	else
969 	{
970 		DBG_ERRORFILE( "invalid font name box" );
971 	}
972 
973 	FontInfo _aFontInfo( pFontList->Get( pNameBox->GetText(), pStyleBox->GetText() ) );
974 	pSizeBox->Fill( &_aFontInfo, pFontList );
975 }
976 
977 // -----------------------------------------------------------------------
978 
979 void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp )
980 {
981     FixedText* pNameLabel = NULL;
982     FontNameBox* pNameBox = NULL;
983     FixedText* pStyleLabel = NULL;
984     FontStyleBox* pStyleBox = NULL;
985     FixedText* pSizeLabel = NULL;
986     FontSizeBox* pSizeBox = NULL;
987     FixedText* pLangFT = NULL;
988     SvxLanguageBox* pLangBox = NULL;
989 	sal_uInt16 nWhich = 0;
990 
991 	switch ( eLangGrp )
992 	{
993 		case Western :
994 			pNameLabel = m_pWestFontNameFT;
995 			pNameBox = m_pWestFontNameLB;
996 			pStyleLabel = m_pWestFontStyleFT;
997 			pStyleBox = m_pWestFontStyleLB;
998 			pSizeLabel = m_pWestFontSizeFT;
999 			pSizeBox = m_pWestFontSizeLB;
1000 			pLangFT = m_pWestFontLanguageFT;
1001 			pLangBox = m_pWestFontLanguageLB;
1002 			nWhich = GetWhich( SID_ATTR_CHAR_FONT );
1003 			break;
1004 
1005 		case Asian :
1006 			pNameLabel = m_pEastFontNameFT;
1007 			pNameBox = m_pEastFontNameLB;
1008 			pStyleLabel = m_pEastFontStyleFT;
1009 			pStyleBox = m_pEastFontStyleLB;
1010 			pSizeLabel = m_pEastFontSizeFT;
1011 			pSizeBox = m_pEastFontSizeLB;
1012 			pLangFT = m_pEastFontLanguageFT;
1013 			pLangBox = m_pEastFontLanguageLB;
1014 			nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONT );
1015 			break;
1016 
1017 		case Ctl :
1018 			pNameLabel = m_pCTLFontNameFT;
1019 			pNameBox = m_pCTLFontNameLB;
1020 			pStyleLabel = m_pCTLFontStyleFT;
1021 			pStyleBox = m_pCTLFontStyleLB;
1022 			pSizeLabel = m_pCTLFontSizeFT;
1023 			pSizeBox = m_pCTLFontSizeLB;
1024 			pLangFT = m_pCTLFontLanguageFT;
1025 			pLangBox = m_pCTLFontLanguageLB;
1026 			nWhich = GetWhich( SID_ATTR_CHAR_CTL_FONT );
1027 			break;
1028 	}
1029 
1030 	// die FontListBox fuellen
1031 	const FontList* pFontList = GetFontList();
1032 	pNameBox->Fill( pFontList );
1033 
1034 	// Font ermitteln
1035 	const SvxFontItem* pFontItem = NULL;
1036 	SfxItemState eState = rSet.GetItemState( nWhich );
1037 
1038 	if ( eState >= SFX_ITEM_DEFAULT )
1039 	{
1040 		pFontItem = (const SvxFontItem*)&( rSet.Get( nWhich ) );
1041 		pNameBox->SetText( pFontItem->GetFamilyName() );
1042 	}
1043 	else
1044 	{
1045 		pNameBox->SetText( String() );
1046 	}
1047 
1048 	FillStyleBox_Impl( pNameBox );
1049 
1050 	FASTBOOL bStyle = sal_False;
1051 	FASTBOOL bStyleAvailable = sal_True;
1052 	FontItalic eItalic = ITALIC_NONE;
1053 	FontWeight eWeight = WEIGHT_NORMAL;
1054 	switch ( eLangGrp )
1055 	{
1056 		case Western : nWhich = GetWhich( SID_ATTR_CHAR_POSTURE ); break;
1057 		case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_POSTURE ); break;
1058 		case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_POSTURE ); break;
1059 	}
1060 	eState = rSet.GetItemState( nWhich );
1061 
1062 	if ( eState >= SFX_ITEM_DEFAULT )
1063 	{
1064 		const SvxPostureItem& rItem = (SvxPostureItem&)rSet.Get( nWhich );
1065 		eItalic = (FontItalic)rItem.GetValue();
1066 		bStyle = sal_True;
1067 	}
1068 	bStyleAvailable = bStyleAvailable && (eState >= SFX_ITEM_DONTCARE);
1069 
1070 	switch ( eLangGrp )
1071 	{
1072 		case Western : nWhich = GetWhich( SID_ATTR_CHAR_WEIGHT ); break;
1073 		case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_WEIGHT ); break;
1074 		case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_WEIGHT ); break;
1075 	}
1076 	eState = rSet.GetItemState( nWhich );
1077 
1078 	if ( eState >= SFX_ITEM_DEFAULT )
1079 	{
1080 		SvxWeightItem& rItem = (SvxWeightItem&)rSet.Get( nWhich );
1081 		eWeight = (FontWeight)rItem.GetValue();
1082 	}
1083 	else
1084 		bStyle = sal_False;
1085 	bStyleAvailable = bStyleAvailable && (eState >= SFX_ITEM_DONTCARE);
1086 
1087 	// Aktuell eingestellter Font
1088 	if ( bStyle && pFontItem )
1089 	{
1090 		FontInfo aInfo = pFontList->Get( pFontItem->GetFamilyName(), eWeight, eItalic );
1091 		pStyleBox->SetText( pFontList->GetStyleName( aInfo ) );
1092 	}
1093 	else if ( !m_pImpl->m_bInSearchMode || !bStyle )
1094 	{
1095 		pStyleBox->SetText( String() );
1096 	}
1097 	else if ( bStyle )
1098 	{
1099 		FontInfo aInfo = pFontList->Get( String(), eWeight, eItalic );
1100 		pStyleBox->SetText( pFontList->GetStyleName( aInfo ) );
1101 	}
1102 	if (!bStyleAvailable)
1103 	{
1104 		pStyleBox->Disable( );
1105 		pStyleLabel->Disable( );
1106 	}
1107 
1108 	// SizeBox fuellen
1109 	FillSizeBox_Impl( pNameBox );
1110 	switch ( eLangGrp )
1111 	{
1112 		case Western : nWhich = GetWhich( SID_ATTR_CHAR_FONTHEIGHT ); break;
1113 		case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT ); break;
1114 		case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT ); break;
1115 	}
1116 	eState = rSet.GetItemState( nWhich );
1117 
1118 	if ( pSizeBox->IsRelativeMode() )
1119 	{
1120 		SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
1121 		const SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get( nWhich );
1122 
1123 		if( rItem.GetProp() != 100 || SFX_MAPUNIT_RELATIVE != rItem.GetPropUnit() )
1124 		{
1125 			sal_Bool bPtRel = SFX_MAPUNIT_POINT == rItem.GetPropUnit();
1126 			pSizeBox->SetPtRelative( bPtRel );
1127 			pSizeBox->SetValue( bPtRel ? ((short)rItem.GetProp()) * 10 : rItem.GetProp() );
1128 		}
1129 		else
1130 		{
1131 			pSizeBox->SetRelative();
1132 			pSizeBox->SetValue( (long)CalcToPoint( rItem.GetHeight(), eUnit, 10 ) );
1133 		}
1134 	}
1135 	else if ( eState >= SFX_ITEM_DEFAULT )
1136 	{
1137 		SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
1138 		const SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get( nWhich );
1139 		pSizeBox->SetValue( (long)CalcToPoint( rItem.GetHeight(), eUnit, 10 ) );
1140 	}
1141 	else
1142 	{
1143 		pSizeBox->SetText( String() );
1144 		if ( eState <= SFX_ITEM_READONLY )
1145 		{
1146 			pSizeBox->Disable( );
1147 			pSizeLabel->Disable( );
1148 		}
1149 	}
1150 
1151 	switch ( eLangGrp )
1152 	{
1153 		case Western : nWhich = GetWhich( SID_ATTR_CHAR_LANGUAGE ); break;
1154 		case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_LANGUAGE ); break;
1155 		case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_LANGUAGE ); break;
1156 	}
1157 	pLangBox->SetNoSelection();
1158 	eState = rSet.GetItemState( nWhich );
1159 
1160 	switch ( eState )
1161 	{
1162 		case SFX_ITEM_UNKNOWN:
1163 			pLangFT->Hide();
1164 			pLangBox->Hide();
1165 			break;
1166 
1167 		case SFX_ITEM_DISABLED:
1168 		case SFX_ITEM_READONLY:
1169 			pLangFT->Disable();
1170 			pLangBox->Disable();
1171 			break;
1172 
1173 		case SFX_ITEM_DEFAULT:
1174 		case SFX_ITEM_SET:
1175 		{
1176 			const SvxLanguageItem& rItem = (SvxLanguageItem&)rSet.Get( nWhich );
1177 			LanguageType eLangType = (LanguageType)rItem.GetValue();
1178 			DBG_ASSERT( eLangType != LANGUAGE_SYSTEM, "LANGUAGE_SYSTEM not allowed" );
1179 			if ( eLangType != LANGUAGE_DONTKNOW )
1180                 pLangBox->SelectLanguage( eLangType );
1181 			break;
1182 		}
1183 	}
1184 
1185 	if ( Western == eLangGrp )
1186         m_aFontTypeFT.SetText( pFontList->GetFontMapText(
1187 			pFontList->Get( pNameBox->GetText(), pStyleBox->GetText() ) ) );
1188 
1189 	// save these settings
1190 	pNameBox->SaveValue();
1191 	pStyleBox->SaveValue();
1192 	pSizeBox->SaveValue();
1193 	pLangBox->SaveValue();
1194 }
1195 
1196 // -----------------------------------------------------------------------
1197 
1198 sal_Bool SvxCharNamePage::FillItemSet_Impl( SfxItemSet& rSet, LanguageGroup eLangGrp )
1199 {
1200 	sal_Bool bModified = sal_False;
1201 
1202     FontNameBox* pNameBox = NULL;
1203     FontStyleBox* pStyleBox = NULL;
1204     FontSizeBox* pSizeBox = NULL;
1205     SvxLanguageBox* pLangBox = NULL;
1206 	sal_uInt16 nWhich = 0;
1207 	sal_uInt16 nSlot = 0;
1208 
1209 	switch ( eLangGrp )
1210 	{
1211 		case Western :
1212 			pNameBox = m_pWestFontNameLB;
1213 			pStyleBox = m_pWestFontStyleLB;
1214 			pSizeBox = m_pWestFontSizeLB;
1215 			pLangBox = m_pWestFontLanguageLB;
1216 			nSlot = SID_ATTR_CHAR_FONT;
1217 			break;
1218 
1219 		case Asian :
1220 			pNameBox = m_pEastFontNameLB;
1221 			pStyleBox = m_pEastFontStyleLB;
1222 			pSizeBox = m_pEastFontSizeLB;
1223 			pLangBox = m_pEastFontLanguageLB;
1224 			nSlot = SID_ATTR_CHAR_CJK_FONT;
1225 			break;
1226 
1227 		case Ctl :
1228 			pNameBox = m_pCTLFontNameLB;
1229 			pStyleBox = m_pCTLFontStyleLB;
1230 			pSizeBox = m_pCTLFontSizeLB;
1231 			pLangBox = m_pCTLFontLanguageLB;
1232 			nSlot = SID_ATTR_CHAR_CTL_FONT;
1233 			break;
1234 	}
1235 
1236 	nWhich = GetWhich( nSlot );
1237 	const SfxPoolItem* pItem = NULL;
1238 	const SfxItemSet& rOldSet = GetItemSet();
1239 	const SfxPoolItem* pOld = NULL;
1240 
1241 	const SfxItemSet* pExampleSet = GetTabDialog() ? GetTabDialog()->GetExampleSet() : NULL;
1242 
1243 	FASTBOOL bChanged = sal_True;
1244 	const String& rFontName  = pNameBox->GetText();
1245 	const FontList* pFontList = GetFontList();
1246 	String aStyleBoxText =pStyleBox->GetText();
1247 	sal_uInt16 nEntryPos = pStyleBox->GetEntryPos( aStyleBoxText );
1248 	if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
1249 		aStyleBoxText.Erase();
1250 	FontInfo aInfo( pFontList->Get( rFontName, aStyleBoxText ) );
1251 	SvxFontItem aFontItem( aInfo.GetFamily(), aInfo.GetName(), aInfo.GetStyleName(),
1252 						   aInfo.GetPitch(), aInfo.GetCharSet(), nWhich );
1253 	pOld = GetOldItem( rSet, nSlot );
1254 
1255 	if ( pOld )
1256 	{
1257 		const SvxFontItem& rItem = *( (const SvxFontItem*)pOld );
1258 
1259 		if ( rItem.GetFamilyName() == aFontItem.GetFamilyName() )
1260 			bChanged = sal_False;
1261 	}
1262 
1263 	if ( !bChanged )
1264 		bChanged = !pNameBox->GetSavedValue().Len();
1265 
1266 	if ( !bChanged && pExampleSet &&
1267 		 pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
1268 		 ( (SvxFontItem*)pItem )->GetFamilyName() != aFontItem.GetFamilyName() )
1269 		bChanged = sal_True;
1270 
1271 	if ( bChanged && rFontName.Len() )
1272 	{
1273 		rSet.Put( aFontItem );
1274 		bModified |= sal_True;
1275 	}
1276 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
1277 		rSet.ClearItem( nWhich );
1278 
1279 
1280 	bChanged = sal_True;
1281 	switch ( eLangGrp )
1282 	{
1283 		case Western : nSlot = SID_ATTR_CHAR_WEIGHT; break;
1284 		case Asian : nSlot = SID_ATTR_CHAR_CJK_WEIGHT; break;
1285 		case Ctl : nSlot = SID_ATTR_CHAR_CTL_WEIGHT; break;
1286 	}
1287 	nWhich = GetWhich( nSlot );
1288 	FontWeight eWeight = aInfo.GetWeight();
1289 	if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
1290 		eWeight = WEIGHT_NORMAL;
1291 	SvxWeightItem aWeightItem( eWeight, nWhich );
1292 	pOld = GetOldItem( rSet, nSlot );
1293 
1294 	if ( pOld )
1295 	{
1296 		const SvxWeightItem& rItem = *( (const SvxWeightItem*)pOld );
1297 
1298 		if ( rItem.GetValue() == aWeightItem.GetValue() )
1299 			bChanged = sal_False;
1300 	}
1301 
1302 	if ( !bChanged )
1303 	{
1304 		bChanged = !pStyleBox->GetSavedValue().Len();
1305 
1306 		if ( m_pImpl->m_bInSearchMode && bChanged &&
1307 			 aInfo.GetWeight() == WEIGHT_NORMAL && aInfo.GetItalic() != ITALIC_NONE )
1308 			bChanged = sal_False;
1309 	}
1310 
1311 	if ( !bChanged && pExampleSet &&
1312 		 pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
1313 		 ( (SvxWeightItem*)pItem )->GetValue() != aWeightItem.GetValue() )
1314 		bChanged = sal_True;
1315 
1316 	if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
1317 		bChanged = ( nEntryPos == m_pImpl->m_nExtraEntryPos );
1318 
1319 	String aText( pStyleBox->GetText() ); // Tristate, dann Text leer
1320 
1321 	if ( bChanged && aText.Len() )
1322 	{
1323 		rSet.Put( aWeightItem );
1324 		bModified |= sal_True;
1325 	}
1326 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
1327 		CLEARTITEM;
1328 
1329 	bChanged = sal_True;
1330 	switch ( eLangGrp )
1331 	{
1332 		case Western : nSlot = SID_ATTR_CHAR_POSTURE; break;
1333 		case Asian : nSlot = SID_ATTR_CHAR_CJK_POSTURE; break;
1334 		case Ctl : nSlot = SID_ATTR_CHAR_CTL_POSTURE; break;
1335 	}
1336 	nWhich = GetWhich( nSlot );
1337 	FontItalic eItalic = aInfo.GetItalic();
1338 	if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
1339 		eItalic = ITALIC_NONE;
1340 	SvxPostureItem aPostureItem( eItalic, nWhich );
1341 	pOld = GetOldItem( rSet, nSlot );
1342 
1343 	if ( pOld )
1344 	{
1345 		const SvxPostureItem& rItem = *( (const SvxPostureItem*)pOld );
1346 
1347 		if ( rItem.GetValue() == aPostureItem.GetValue() )
1348 			bChanged = sal_False;
1349 	}
1350 
1351 	if ( !bChanged )
1352 	{
1353 		bChanged = !pStyleBox->GetSavedValue().Len();
1354 
1355 		if ( m_pImpl->m_bInSearchMode && bChanged &&
1356 			 aInfo.GetItalic() == ITALIC_NONE && aInfo.GetWeight() != WEIGHT_NORMAL )
1357 			bChanged = sal_False;
1358 	}
1359 
1360 	if ( !bChanged && pExampleSet &&
1361 		 pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
1362 		 ( (SvxPostureItem*)pItem )->GetValue() != aPostureItem.GetValue() )
1363 		bChanged = sal_True;
1364 
1365 	if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
1366 		bChanged = ( nEntryPos == ( m_pImpl->m_nExtraEntryPos + 1 ) );
1367 
1368 	if ( bChanged && aText.Len() )
1369 	{
1370 		rSet.Put( aPostureItem );
1371 		bModified |= sal_True;
1372 	}
1373 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
1374 		CLEARTITEM;
1375 
1376 	// FontSize
1377 	long nSize = static_cast<long>(pSizeBox->GetValue());
1378 
1379 	if ( !pSizeBox->GetText().Len() )	// GetValue() gibt dann Min-Wert zurueck
1380 		nSize = 0;
1381 	long nSavedSize = pSizeBox->GetSavedValue().ToInt32();
1382 	FASTBOOL bRel = sal_True;
1383 
1384 	if ( !pSizeBox->IsRelative() )
1385 	{
1386 		nSavedSize *= 10;
1387 		bRel = sal_False;
1388 	}
1389 
1390 	switch ( eLangGrp )
1391 	{
1392 		case Western : nSlot = SID_ATTR_CHAR_FONTHEIGHT; break;
1393 		case Asian : nSlot = SID_ATTR_CHAR_CJK_FONTHEIGHT; break;
1394 		case Ctl : nSlot = SID_ATTR_CHAR_CTL_FONTHEIGHT; break;
1395 	}
1396 	nWhich = GetWhich( nSlot );
1397 	const SvxFontHeightItem* pOldHeight = (const SvxFontHeightItem*)GetOldItem( rSet, nSlot );
1398 	bChanged = ( nSize != nSavedSize );
1399 
1400 	if ( !bChanged && pExampleSet &&
1401 		 pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET )
1402 	{
1403 		float fSize = (float)nSize / 10;
1404 		long nVal = CalcToUnit( fSize, rSet.GetPool()->GetMetric( nWhich ) );
1405 		if ( ( (SvxFontHeightItem*)pItem )->GetHeight() != (sal_uInt32)nVal )
1406 			bChanged = sal_True;
1407 	}
1408 
1409 	if ( bChanged || !pOldHeight ||
1410 		 bRel != ( SFX_MAPUNIT_RELATIVE != pOldHeight->GetPropUnit() || 100 != pOldHeight->GetProp() ) )
1411 	{
1412 		SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
1413 		if ( pSizeBox->IsRelative() )
1414 		{
1415 			DBG_ASSERT( GetItemSet().GetParent(), "No parent set" );
1416 			const SvxFontHeightItem& rOldItem =
1417 				(const SvxFontHeightItem&)GetItemSet().GetParent()->Get( nWhich );
1418 
1419 			SvxFontHeightItem aHeight( 240, 100, nWhich );
1420 			if ( pSizeBox->IsPtRelative() )
1421 				aHeight.SetHeight( rOldItem.GetHeight(), (sal_uInt16)( nSize / 10 ), SFX_MAPUNIT_POINT, eUnit );
1422 			else
1423 				aHeight.SetHeight( rOldItem.GetHeight(), (sal_uInt16)nSize, SFX_MAPUNIT_RELATIVE );
1424 			rSet.Put( aHeight );
1425 		}
1426 		else
1427 		{
1428 			float fSize = (float)nSize / 10;
1429 			rSet.Put( SvxFontHeightItem( CalcToUnit( fSize, eUnit ), 100, nWhich ) );
1430 		}
1431 		bModified |= sal_True;
1432 	}
1433 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
1434 		CLEARTITEM;
1435 
1436 	bChanged = sal_True;
1437 	switch ( eLangGrp )
1438 	{
1439 		case Western : nSlot = SID_ATTR_CHAR_LANGUAGE; break;
1440 		case Asian : nSlot = SID_ATTR_CHAR_CJK_LANGUAGE; break;
1441 		case Ctl : nSlot = SID_ATTR_CHAR_CTL_LANGUAGE; break;
1442 	}
1443 	nWhich = GetWhich( nSlot );
1444 	pOld = GetOldItem( rSet, nSlot );
1445 	sal_uInt16 nLangPos = pLangBox->GetSelectEntryPos();
1446 	LanguageType eLangType = (LanguageType)(sal_uLong)pLangBox->GetEntryData( nLangPos );
1447 
1448 	if ( pOld )
1449 	{
1450 		const SvxLanguageItem& rItem = *( (const SvxLanguageItem*)pOld );
1451 
1452 		if ( nLangPos == LISTBOX_ENTRY_NOTFOUND || eLangType == (LanguageType)rItem.GetValue() )
1453 			bChanged = sal_False;
1454 	}
1455 
1456 	if ( !bChanged )
1457 		bChanged = ( pLangBox->GetSavedValue() == LISTBOX_ENTRY_NOTFOUND );
1458 
1459 	if ( bChanged && nLangPos != LISTBOX_ENTRY_NOTFOUND )
1460 	{
1461 		rSet.Put( SvxLanguageItem( eLangType, nWhich ) );
1462 		bModified |= sal_True;
1463 	}
1464 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
1465 		CLEARTITEM;
1466 
1467 	return bModified;
1468 }
1469 
1470 // -----------------------------------------------------------------------
1471 
1472 void SvxCharNamePage::ResetColor_Impl( const SfxItemSet& rSet )
1473 {
1474 	sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
1475 	SfxItemState eState = rSet.GetItemState( nWhich );
1476 
1477 	switch ( eState )
1478 	{
1479 		case SFX_ITEM_UNKNOWN:
1480             m_pColorLB->Hide();
1481 			break;
1482 
1483 		case SFX_ITEM_DISABLED:
1484 		case SFX_ITEM_READONLY:
1485             m_pColorLB->Disable();
1486 			break;
1487 
1488 		case SFX_ITEM_DONTCARE:
1489             m_pColorLB->SetNoSelection();
1490 			break;
1491 
1492 		case SFX_ITEM_DEFAULT:
1493 		case SFX_ITEM_SET:
1494 		{
1495 			SvxFont& rFont = GetPreviewFont();
1496             SvxFont& rCJKFont = GetPreviewCJKFont();
1497 			SvxFont& rCTLFont = GetPreviewCTLFont();
1498 			const SvxColorItem& rItem = (SvxColorItem&)rSet.Get( nWhich );
1499 			Color aColor = rItem.GetValue();
1500             rFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
1501             rCJKFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
1502 			rCTLFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
1503 			m_aPreviewWin.Invalidate();
1504             sal_uInt16 nSelPos = m_pColorLB->GetEntryPos( aColor );
1505 			if ( nSelPos == LISTBOX_ENTRY_NOTFOUND && aColor == Color( COL_TRANSPARENT ) )
1506                 nSelPos = m_pColorLB->GetEntryPos( m_pImpl->m_aTransparentText );
1507 
1508 			if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
1509                 m_pColorLB->SelectEntryPos( nSelPos );
1510 			else
1511 			{
1512                 nSelPos = m_pColorLB->GetEntryPos( aColor );
1513 				if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
1514                     m_pColorLB->SelectEntryPos( nSelPos );
1515 				else
1516                     m_pColorLB->SelectEntryPos(
1517                         m_pColorLB->InsertEntry( aColor, String( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) );
1518 			}
1519 			break;
1520 		}
1521 	}
1522 }
1523 
1524 // -----------------------------------------------------------------------
1525 
1526 IMPL_LINK( SvxCharNamePage, UpdateHdl_Impl, Timer*, EMPTYARG )
1527 {
1528 	UpdatePreview_Impl();
1529 	return 0;
1530 }
1531 
1532 // -----------------------------------------------------------------------
1533 
1534 IMPL_LINK( SvxCharNamePage, FontModifyHdl_Impl, void*, pNameBox )
1535 {
1536 	m_pImpl->m_aUpdateTimer.Start();
1537 
1538     if ( m_pWestFontNameLB == pNameBox || m_pEastFontNameLB == pNameBox || m_pCTLFontNameLB == pNameBox )
1539 	{
1540 		FillStyleBox_Impl( (FontNameBox*)pNameBox );
1541 		FillSizeBox_Impl( (FontNameBox*)pNameBox );
1542 	}
1543 	return 0;
1544 }
1545 
1546 // -----------------------------------------------------------------------
1547 
1548 IMPL_LINK( SvxCharNamePage, ColorBoxSelectHdl_Impl, ColorListBox*, pBox )
1549 {
1550 	SvxFont& rFont = GetPreviewFont();
1551     SvxFont& rCJKFont = GetPreviewCJKFont();
1552 	SvxFont& rCTLFont = GetPreviewCTLFont();
1553 	Color aSelectedColor;
1554 	if ( pBox->GetSelectEntry() == m_pImpl->m_aTransparentText )
1555 		aSelectedColor = Color( COL_TRANSPARENT );
1556 	else
1557 		aSelectedColor = pBox->GetSelectEntryColor();
1558     rFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
1559     rCJKFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
1560 	rCTLFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
1561     m_aPreviewWin.Invalidate();
1562 	return 0;
1563 }
1564 
1565 // -----------------------------------------------------------------------
1566 
1567 void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet )
1568 {
1569 	SvxCharBasePage::ActivatePage( rSet );
1570 
1571 	UpdatePreview_Impl();		// instead of asynchronous calling in ctor
1572 }
1573 
1574 // -----------------------------------------------------------------------
1575 
1576 int SvxCharNamePage::DeactivatePage( SfxItemSet* _pSet )
1577 {
1578     if ( _pSet )
1579         FillItemSet( *_pSet );
1580 	return LEAVE_PAGE;
1581 }
1582 
1583 // -----------------------------------------------------------------------
1584 
1585 SfxTabPage* SvxCharNamePage::Create( Window* pParent, const SfxItemSet& rSet )
1586 {
1587 	return new SvxCharNamePage( pParent, rSet );
1588 }
1589 
1590 // -----------------------------------------------------------------------
1591 
1592 sal_uInt16* SvxCharNamePage::GetRanges()
1593 {
1594 	return pNameRanges;
1595 }
1596 
1597 // -----------------------------------------------------------------------
1598 
1599 void SvxCharNamePage::Reset( const SfxItemSet& rSet )
1600 {
1601 	Reset_Impl( rSet, Western );
1602 	Reset_Impl( rSet, Asian );
1603 	Reset_Impl( rSet, Ctl );
1604 	ResetColor_Impl( rSet );
1605     m_pColorLB->SaveValue();
1606 
1607 	SetPrevFontWidthScale( rSet );
1608 	UpdatePreview_Impl();
1609 }
1610 
1611 // -----------------------------------------------------------------------
1612 
1613 sal_Bool SvxCharNamePage::FillItemSet( SfxItemSet& rSet )
1614 {
1615 	sal_Bool bModified = FillItemSet_Impl( rSet, Western );
1616 	bModified |= FillItemSet_Impl( rSet, Asian );
1617 	bModified |= FillItemSet_Impl( rSet, Ctl );
1618 	return bModified;
1619 }
1620 
1621 // -----------------------------------------------------------------------
1622 
1623 void SvxCharNamePage::SetFontList( const SvxFontListItem& rItem )
1624 {
1625 	if ( m_pImpl->m_bMustDelete )
1626 	{
1627 		delete m_pImpl->m_pFontList;
1628 	}
1629     m_pImpl->m_pFontList = rItem.GetFontList()->Clone();
1630     m_pImpl->m_bMustDelete = sal_True;
1631 }
1632 
1633 // -----------------------------------------------------------------------
1634 namespace
1635 {
1636 	void enableRelativeMode( SvxCharNamePage* _pPage, FontSizeBox* _pFontSizeLB, sal_uInt16 _nHeightWhich )
1637 	{
1638 		_pFontSizeLB->EnableRelativeMode( 5, 995, 5 ); // min 5%, max 995%, step 5
1639 
1640 		const SvxFontHeightItem& rHeightItem =
1641 			(SvxFontHeightItem&)_pPage->GetItemSet().GetParent()->Get( _nHeightWhich );
1642 		SfxMapUnit eUnit = _pPage->GetItemSet().GetPool()->GetMetric( _nHeightWhich );
1643 		short nCurHeight =
1644 			static_cast< short >( CalcToPoint( rHeightItem.GetHeight(), eUnit, 1 ) * 10 );
1645 
1646 		// ausgehend von der akt. Hoehe:
1647 		//		- negativ bis minimal 2 pt
1648 		//		- positiv bis maximal 999 pt
1649 		_pFontSizeLB->EnablePtRelativeMode( sal::static_int_cast< short >(-(nCurHeight - 20)), (9999 - nCurHeight), 10 );
1650 	}
1651 }
1652 // -----------------------------------------------------------------------------
1653 
1654 void SvxCharNamePage::EnableRelativeMode()
1655 {
1656 	DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no ParentSet!" );
1657 	enableRelativeMode(this,m_pWestFontSizeLB,GetWhich( SID_ATTR_CHAR_FONTHEIGHT ));
1658 	enableRelativeMode(this,m_pEastFontSizeLB,GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT ));
1659 	enableRelativeMode(this,m_pCTLFontSizeLB,GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT ));
1660 }
1661 
1662 // -----------------------------------------------------------------------
1663 
1664 void SvxCharNamePage::EnableSearchMode()
1665 {
1666 	m_pImpl->m_bInSearchMode = sal_True;
1667 }
1668 // -----------------------------------------------------------------------
1669 void SvxCharNamePage::DisableControls( sal_uInt16 nDisable )
1670 {
1671 	if ( DISABLE_LANGUAGE & nDisable )
1672 	{
1673 		if ( m_pWestFontLanguageFT ) m_pWestFontLanguageFT->Disable();
1674 		if ( m_pWestFontLanguageLB ) m_pWestFontLanguageLB->Disable();
1675 		if ( m_pEastFontLanguageFT ) m_pEastFontLanguageFT->Disable();
1676 		if ( m_pEastFontLanguageLB ) m_pEastFontLanguageLB->Disable();
1677 		if ( m_pCTLFontLanguageFT ) m_pCTLFontLanguageFT->Disable();
1678 		if ( m_pCTLFontLanguageLB ) m_pCTLFontLanguageLB->Disable();
1679 	}
1680 
1681 	if ( DISABLE_HIDE_LANGUAGE & nDisable )
1682 	{
1683 		if ( m_pWestFontLanguageFT ) m_pWestFontLanguageFT->Hide();
1684 		if ( m_pWestFontLanguageLB ) m_pWestFontLanguageLB->Hide();
1685 		if ( m_pEastFontLanguageFT ) m_pEastFontLanguageFT->Hide();
1686 		if ( m_pEastFontLanguageLB ) m_pEastFontLanguageLB->Hide();
1687 		if ( m_pCTLFontLanguageFT ) m_pCTLFontLanguageFT->Hide();
1688 		if ( m_pCTLFontLanguageLB ) m_pCTLFontLanguageLB->Hide();
1689 	}
1690 }
1691 
1692 // -----------------------------------------------------------------------
1693 void SvxCharNamePage::SetPreviewBackgroundToCharacter()
1694 {
1695     m_bPreviewBackgroundToCharacter = sal_True;
1696 }
1697 
1698 // -----------------------------------------------------------------------
1699 void SvxCharNamePage::PageCreated (SfxAllItemSet aSet) //add CHINA001
1700 {
1701 	SFX_ITEMSET_ARG (&aSet,pFontListItem,SvxFontListItem,SID_ATTR_CHAR_FONTLIST,sal_False);
1702 	SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False);
1703 	SFX_ITEMSET_ARG (&aSet,pDisalbeItem,SfxUInt16Item,SID_DISABLE_CTL,sal_False);
1704 	if (pFontListItem)
1705 		SetFontList(*pFontListItem);
1706 		//CHINA001 SetFontList(pFontListItem->GetFontList());
1707 
1708 	if (pFlagItem)
1709 	{
1710 		sal_uInt32 nFlags=pFlagItem->GetValue();
1711 		if ( ( nFlags & SVX_RELATIVE_MODE ) == SVX_RELATIVE_MODE )
1712 			EnableRelativeMode();
1713 		if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
1714 			SetPreviewBackgroundToCharacter();
1715 	}
1716 	if (pDisalbeItem)
1717 		DisableControls(pDisalbeItem->GetValue());
1718 }
1719 // class SvxCharEffectsPage ----------------------------------------------
1720 
1721 SvxCharEffectsPage::SvxCharEffectsPage( Window* pParent, const SfxItemSet& rInSet ) :
1722 
1723 	SvxCharBasePage( pParent, CUI_RES( RID_SVXPAGE_CHAR_EFFECTS ), rInSet, WIN_EFFECTS_PREVIEW, FT_EFFECTS_FONTTYPE ),
1724 
1725     m_aFontColorFT          ( this, CUI_RES( FT_FONTCOLOR ) ),
1726     m_aFontColorLB          ( this, CUI_RES( LB_FONTCOLOR ) ),
1727 
1728 	m_aEffectsFT			( this, CUI_RES( FT_EFFECTS ) ),
1729 	m_aEffectsLB			( this, 0 ),
1730 
1731 	m_aEffects2LB			( this, CUI_RES( LB_EFFECTS2 ) ),
1732 
1733     m_aReliefFT             ( this, CUI_RES( FT_RELIEF ) ),
1734     m_aReliefLB             ( this, CUI_RES( LB_RELIEF ) ),
1735 
1736 	m_aOutlineBtn			( this, CUI_RES( CB_OUTLINE ) ),
1737 	m_aShadowBtn			( this, CUI_RES( CB_SHADOW ) ),
1738 	m_aBlinkingBtn			( this, CUI_RES( CB_BLINKING ) ),
1739     m_aHiddenBtn            ( this, CUI_RES( CB_CHARHIDDEN ) ),
1740 
1741 	m_aVerticalLine			( this, CUI_RES( FL_EFFECTS_VERTICAL ) ),
1742 
1743 	m_aOverlineFT			( this, CUI_RES( FT_OVERLINE ) ),
1744 	m_aOverlineLB			( this, CUI_RES( LB_OVERLINE ) ),
1745 	m_aOverlineColorFT		( this, CUI_RES( FT_OVERLINE_COLOR ) ),
1746 	m_aOverlineColorLB		( this, CUI_RES( LB_OVERLINE_COLOR ) ),
1747 	m_aStrikeoutFT			( this, CUI_RES( FT_STRIKEOUT ) ),
1748 	m_aStrikeoutLB			( this, CUI_RES( LB_STRIKEOUT ) ),
1749 	m_aUnderlineFT			( this, CUI_RES( FT_UNDERLINE ) ),
1750 	m_aUnderlineLB			( this, CUI_RES( LB_UNDERLINE ) ),
1751 	m_aUnderlineColorFT		( this, CUI_RES( FT_UNDERLINE_COLOR ) ),
1752 	m_aUnderlineColorLB		( this, CUI_RES( LB_UNDERLINE_COLOR ) ),
1753 	m_aIndividualWordsBtn	( this, CUI_RES( CB_INDIVIDUALWORDS ) ),
1754 
1755 	m_aAsianLine			( this, CUI_RES( FL_EFFECTS_ASIAN ) ),
1756 
1757 	m_aEmphasisFT			( this, CUI_RES( FT_EMPHASIS ) ),
1758 	m_aEmphasisLB			( this, CUI_RES( LB_EMPHASIS ) ),
1759 	m_aPositionFT			( this, CUI_RES( FT_POSITION ) ),
1760 	m_aPositionLB			( this, CUI_RES( LB_POSITION ) ),
1761 
1762 	m_aTransparentColorName	( CUI_RES( STR_CHARNAME_TRANSPARENT ) )
1763 
1764 {
1765 	m_aEffectsLB.Hide();
1766 	FreeResource();
1767 	Initialize();
1768 }
1769 
1770 // -----------------------------------------------------------------------
1771 
1772 void SvxCharEffectsPage::Initialize()
1773 {
1774 	// to handle the changes of the other pages
1775 	SetExchangeSupport();
1776 
1777 	// HTML-Mode
1778 	const SfxPoolItem* pItem;
1779 	SfxObjectShell* pShell;
1780 	if ( SFX_ITEM_SET == GetItemSet().GetItemState( SID_HTML_MODE, sal_False, &pItem ) ||
1781 		 ( NULL != ( pShell = SfxObjectShell::Current() ) &&
1782 		   NULL != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) )
1783 	{
1784 		m_nHtmlMode = ( (const SfxUInt16Item*)pItem )->GetValue();
1785 		if ( ( m_nHtmlMode & HTMLMODE_ON ) == HTMLMODE_ON )
1786 		{
1787 			//!!! hide some controls please
1788 		}
1789 	}
1790 
1791 	// fill the color box
1792 	SfxObjectShell* pDocSh = SfxObjectShell::Current();
1793 	DBG_ASSERT( pDocSh, "DocShell not found!" );
1794 	XColorTable* pColorTable = NULL;
1795 	FASTBOOL bKillTable = sal_False;
1796 
1797 	if ( pDocSh )
1798     {
1799         pItem = pDocSh->GetItem( SID_COLOR_TABLE );
1800         if ( pItem != NULL )
1801             pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
1802     }
1803 
1804 	if ( !pColorTable )
1805 	{
1806 		pColorTable = new XColorTable( SvtPathOptions().GetPalettePath() );
1807 		bKillTable = sal_True;
1808 	}
1809 
1810 	m_aUnderlineColorLB.SetUpdateMode( sal_False );
1811 	m_aOverlineColorLB.SetUpdateMode( sal_False );
1812 	m_aFontColorLB.SetUpdateMode( sal_False );
1813 
1814 	{
1815 		SfxPoolItem* pDummy;
1816 		SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocSh );
1817 		if ( !pFrame ||
1818 			 SFX_ITEM_DEFAULT > pFrame->GetBindings().QueryState( SID_ATTR_AUTO_COLOR_INVALID, pDummy ) )
1819 		{
1820 			m_aUnderlineColorLB.InsertAutomaticEntry();
1821 			m_aOverlineColorLB.InsertAutomaticEntry();
1822 			m_aFontColorLB.InsertAutomaticEntry();
1823 		}
1824 	}
1825 	for ( long i = 0; i < pColorTable->Count(); i++ )
1826 	{
1827         XColorEntry* pEntry = pColorTable->GetColor(i);
1828 		m_aUnderlineColorLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1829 		m_aOverlineColorLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1830 		m_aFontColorLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1831 	}
1832 
1833 	m_aUnderlineColorLB.SetUpdateMode( sal_True );
1834 	m_aOverlineColorLB.SetUpdateMode( sal_True );
1835 	m_aFontColorLB.SetUpdateMode( sal_True );
1836     m_aFontColorLB.SetSelectHdl( LINK( this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl ) );
1837 
1838 	if ( bKillTable )
1839 		delete pColorTable;
1840 
1841 	// handler
1842 	Link aLink = LINK( this, SvxCharEffectsPage, SelectHdl_Impl );
1843 	m_aUnderlineLB.SetSelectHdl( aLink );
1844     m_aUnderlineColorLB.SetSelectHdl( aLink );
1845 	m_aOverlineLB.SetSelectHdl( aLink );
1846     m_aOverlineColorLB.SetSelectHdl( aLink );
1847 	m_aStrikeoutLB.SetSelectHdl( aLink );
1848 	m_aEmphasisLB.SetSelectHdl( aLink );
1849 	m_aPositionLB.SetSelectHdl( aLink );
1850 	m_aEffects2LB.SetSelectHdl( aLink );
1851     m_aReliefLB.SetSelectHdl( aLink );
1852 
1853 	m_aUnderlineLB.SelectEntryPos( 0 );
1854 	m_aUnderlineColorLB.SelectEntryPos( 0 );
1855 	m_aOverlineLB.SelectEntryPos( 0 );
1856 	m_aOverlineColorLB.SelectEntryPos( 0 );
1857 	m_aStrikeoutLB.SelectEntryPos( 0 );
1858 	m_aEmphasisLB.SelectEntryPos( 0 );
1859 	m_aPositionLB.SelectEntryPos( 0 );
1860 	SelectHdl_Impl( NULL );
1861 	SelectHdl_Impl( &m_aEmphasisLB );
1862 
1863 	m_aEffects2LB.SelectEntryPos( 0 );
1864 
1865     m_aIndividualWordsBtn.SetClickHdl( LINK( this, SvxCharEffectsPage, CbClickHdl_Impl ) );
1866     aLink = LINK( this, SvxCharEffectsPage, TristClickHdl_Impl );
1867 	m_aOutlineBtn.SetClickHdl( aLink );
1868 	m_aShadowBtn.SetClickHdl( aLink );
1869 
1870     if ( !SvtLanguageOptions().IsAsianTypographyEnabled() )
1871     {
1872 		m_aAsianLine.Hide();
1873         m_aEmphasisFT.Hide();
1874         m_aEmphasisLB.Hide();
1875         m_aPositionFT.Hide();
1876         m_aPositionLB.Hide();
1877 	}
1878 }
1879 // -----------------------------------------------------------------------
1880 
1881 void SvxCharEffectsPage::UpdatePreview_Impl()
1882 {
1883 	SvxFont& rFont = GetPreviewFont();
1884     SvxFont& rCJKFont = GetPreviewCJKFont();
1885 	SvxFont& rCTLFont = GetPreviewCTLFont();
1886 
1887 	sal_uInt16 nPos = m_aUnderlineLB.GetSelectEntryPos();
1888 	FontUnderline eUnderline = (FontUnderline)(sal_uLong)m_aUnderlineLB.GetEntryData( nPos );
1889 	nPos = m_aOverlineLB.GetSelectEntryPos();
1890 	FontUnderline eOverline = (FontUnderline)(sal_uLong)m_aOverlineLB.GetEntryData( nPos );
1891 	nPos = m_aStrikeoutLB.GetSelectEntryPos();
1892 	FontStrikeout eStrikeout = (FontStrikeout)(sal_uLong)m_aStrikeoutLB.GetEntryData( nPos );
1893 	rFont.SetUnderline( eUnderline );
1894     rCJKFont.SetUnderline( eUnderline );
1895 	rCTLFont.SetUnderline( eUnderline );
1896 	m_aPreviewWin.SetTextLineColor( m_aUnderlineColorLB.GetSelectEntryColor() );
1897 	rFont.SetOverline( eOverline );
1898     rCJKFont.SetOverline( eOverline );
1899 	rCTLFont.SetOverline( eOverline );
1900 	m_aPreviewWin.SetOverlineColor( m_aOverlineColorLB.GetSelectEntryColor() );
1901 	rFont.SetStrikeout( eStrikeout );
1902     rCJKFont.SetStrikeout( eStrikeout );
1903 	rCTLFont.SetStrikeout( eStrikeout );
1904 
1905 	nPos = m_aPositionLB.GetSelectEntryPos();
1906 	sal_Bool bUnder = ( CHRDLG_POSITION_UNDER == (sal_uLong)m_aPositionLB.GetEntryData( nPos ) );
1907 	FontEmphasisMark eMark = (FontEmphasisMark)m_aEmphasisLB.GetSelectEntryPos();
1908 	eMark |= bUnder ? EMPHASISMARK_POS_BELOW : EMPHASISMARK_POS_ABOVE;
1909 	rFont.SetEmphasisMark( eMark );
1910     rCJKFont.SetEmphasisMark( eMark );
1911 	rCTLFont.SetEmphasisMark( eMark );
1912 
1913     sal_uInt16 nRelief = m_aReliefLB.GetSelectEntryPos();
1914     if(LISTBOX_ENTRY_NOTFOUND != nRelief)
1915     {
1916         rFont.SetRelief( (FontRelief)nRelief );
1917         rCJKFont.SetRelief( (FontRelief)nRelief );
1918 		rCTLFont.SetRelief( (FontRelief)nRelief );
1919     }
1920 
1921     rFont.SetOutline( StateToAttr( m_aOutlineBtn.GetState() ) );
1922     rCJKFont.SetOutline( rFont.IsOutline() );
1923 	rCTLFont.SetOutline( rFont.IsOutline() );
1924 
1925     rFont.SetShadow( StateToAttr( m_aShadowBtn.GetState() ) );
1926     rCJKFont.SetShadow( rFont.IsShadow() );
1927 	rCTLFont.SetShadow( rFont.IsShadow() );
1928 
1929 	sal_uInt16 nCapsPos = m_aEffects2LB.GetSelectEntryPos();
1930 	if ( nCapsPos != LISTBOX_ENTRY_NOTFOUND )
1931     {
1932 		rFont.SetCaseMap( (SvxCaseMap)nCapsPos );
1933         rCJKFont.SetCaseMap( (SvxCaseMap)nCapsPos );
1934         // #i78474# small caps do not exist in CTL fonts
1935         rCTLFont.SetCaseMap( static_cast<SvxCaseMap>( nCapsPos == SVX_CASEMAP_KAPITAELCHEN ? SVX_CASEMAP_NOT_MAPPED : (SvxCaseMap)nCapsPos) );
1936     }
1937 
1938     sal_Bool bWordLine = m_aIndividualWordsBtn.IsChecked();
1939     rFont.SetWordLineMode( bWordLine );
1940     rCJKFont.SetWordLineMode( bWordLine );
1941 	rCTLFont.SetWordLineMode( bWordLine );
1942 
1943     m_aPreviewWin.Invalidate();
1944 }
1945 
1946 // -----------------------------------------------------------------------
1947 
1948 void SvxCharEffectsPage::SetCaseMap_Impl( SvxCaseMap eCaseMap )
1949 {
1950 	if ( SVX_CASEMAP_END > eCaseMap )
1951 		m_aEffects2LB.SelectEntryPos(
1952             sal::static_int_cast< sal_uInt16 >( eCaseMap ) );
1953 	else
1954 	{
1955 		m_aEffects2LB.SetNoSelection();
1956 		eCaseMap = SVX_CASEMAP_NOT_MAPPED;
1957 	}
1958 
1959 	UpdatePreview_Impl();
1960 }
1961 
1962 // -----------------------------------------------------------------------
1963 
1964 void SvxCharEffectsPage::ResetColor_Impl( const SfxItemSet& rSet )
1965 {
1966 	sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
1967 	SfxItemState eState = rSet.GetItemState( nWhich );
1968 
1969 	switch ( eState )
1970 	{
1971 		case SFX_ITEM_UNKNOWN:
1972             m_aFontColorFT.Hide();
1973             m_aFontColorLB.Hide();
1974 			break;
1975 
1976 		case SFX_ITEM_DISABLED:
1977 		case SFX_ITEM_READONLY:
1978             m_aFontColorFT.Disable();
1979             m_aFontColorLB.Disable();
1980 			break;
1981 
1982 		case SFX_ITEM_DONTCARE:
1983             m_aFontColorLB.SetNoSelection();
1984 			break;
1985 
1986 		case SFX_ITEM_DEFAULT:
1987 		case SFX_ITEM_SET:
1988 		{
1989 			SvxFont& rFont = GetPreviewFont();
1990             SvxFont& rCJKFont = GetPreviewCJKFont();
1991 			SvxFont& rCTLFont = GetPreviewCTLFont();
1992 
1993 			const SvxColorItem& rItem = (SvxColorItem&)rSet.Get( nWhich );
1994 			Color aColor = rItem.GetValue();
1995             rFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
1996             rCJKFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
1997 			rCTLFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
1998 
1999 			m_aPreviewWin.Invalidate();
2000             sal_uInt16 nSelPos = m_aFontColorLB.GetEntryPos( aColor );
2001 			if ( nSelPos == LISTBOX_ENTRY_NOTFOUND && aColor == Color( COL_TRANSPARENT ) )
2002 				nSelPos = m_aFontColorLB.GetEntryPos( m_aTransparentColorName );
2003 
2004 			if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
2005                 m_aFontColorLB.SelectEntryPos( nSelPos );
2006 			else
2007 			{
2008                 nSelPos = m_aFontColorLB.GetEntryPos( aColor );
2009 				if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
2010                     m_aFontColorLB.SelectEntryPos( nSelPos );
2011 				else
2012                     m_aFontColorLB.SelectEntryPos(
2013                         m_aFontColorLB.InsertEntry( aColor, String( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) );
2014 			}
2015 			break;
2016 		}
2017 	}
2018 }
2019 
2020 // -----------------------------------------------------------------------
2021 
2022 sal_Bool SvxCharEffectsPage::FillItemSetColor_Impl( SfxItemSet& rSet )
2023 {
2024 	sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
2025 	const SvxColorItem* pOld = (const SvxColorItem*)GetOldItem( rSet, SID_ATTR_CHAR_COLOR );
2026 	const SvxColorItem* pItem = NULL;
2027 	sal_Bool bChanged = sal_True;
2028 	const SfxItemSet* pExampleSet = GetTabDialog() ? GetTabDialog()->GetExampleSet() : NULL;
2029 	const SfxItemSet& rOldSet = GetItemSet();
2030 
2031 	Color aSelectedColor;
2032     if ( m_aFontColorLB.GetSelectEntry() == m_aTransparentColorName )
2033 		aSelectedColor = Color( COL_TRANSPARENT );
2034 	else
2035         aSelectedColor = m_aFontColorLB.GetSelectEntryColor();
2036 
2037 	if ( pOld && pOld->GetValue() == aSelectedColor )
2038 		bChanged = sal_False;
2039 
2040 	if ( !bChanged )
2041         bChanged = ( m_aFontColorLB.GetSavedValue() == LISTBOX_ENTRY_NOTFOUND );
2042 
2043 	if ( !bChanged && pExampleSet &&
2044 		 pExampleSet->GetItemState( nWhich, sal_False, (const SfxPoolItem**)&pItem ) == SFX_ITEM_SET &&
2045 		 ( (SvxColorItem*)pItem )->GetValue() != aSelectedColor )
2046 		bChanged = sal_True;
2047 
2048 	sal_Bool bModified = sal_False;
2049 
2050     if ( bChanged && m_aFontColorLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
2051 	{
2052 		rSet.Put( SvxColorItem( aSelectedColor, nWhich ) );
2053 		bModified = sal_True;
2054 	}
2055 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
2056 		CLEARTITEM;
2057 
2058 	return bModified;
2059 }
2060 
2061 // -----------------------------------------------------------------------
2062 
2063 IMPL_LINK( SvxCharEffectsPage, SelectHdl_Impl, ListBox*, pBox )
2064 {
2065 	if ( &m_aEmphasisLB == pBox )
2066 	{
2067 		sal_uInt16 nEPos = m_aEmphasisLB.GetSelectEntryPos();
2068 		sal_Bool bEnable = ( nEPos > 0 && nEPos != LISTBOX_ENTRY_NOTFOUND );
2069 		m_aPositionFT.Enable( bEnable );
2070 		m_aPositionLB.Enable( bEnable );
2071 	}
2072     else if( &m_aReliefLB == pBox)
2073     {
2074         sal_Bool bEnable = ( pBox->GetSelectEntryPos() == 0 );
2075         m_aOutlineBtn.Enable( bEnable );
2076         m_aShadowBtn.Enable( bEnable );
2077     }
2078     else if ( &m_aPositionLB != pBox )
2079 	{
2080 		sal_uInt16 nUPos = m_aUnderlineLB.GetSelectEntryPos(),
2081                nOPos = m_aOverlineLB.GetSelectEntryPos(),
2082                nSPos = m_aStrikeoutLB.GetSelectEntryPos();
2083         sal_Bool bUEnable = ( nUPos > 0 && nUPos != LISTBOX_ENTRY_NOTFOUND );
2084         sal_Bool bOEnable = ( nOPos > 0 && nOPos != LISTBOX_ENTRY_NOTFOUND );
2085 		m_aUnderlineColorFT.Enable( bUEnable );
2086 		m_aUnderlineColorLB.Enable( bUEnable );
2087 		m_aOverlineColorFT.Enable( bOEnable );
2088 		m_aOverlineColorLB.Enable( bOEnable );
2089         m_aIndividualWordsBtn.Enable( bUEnable || bOEnable || ( nSPos > 0 && nSPos != LISTBOX_ENTRY_NOTFOUND ) );
2090 	}
2091     UpdatePreview_Impl();
2092 	return 0;
2093 }
2094 
2095 // -----------------------------------------------------------------------
2096 
2097 IMPL_LINK( SvxCharEffectsPage, UpdatePreview_Impl, ListBox*, EMPTYARG )
2098 {
2099 	bool bEnable = ( ( m_aUnderlineLB.GetSelectEntryPos() > 0 ) ||
2100 					 ( m_aOverlineLB.GetSelectEntryPos()  > 0 ) ||
2101 					 ( m_aStrikeoutLB.GetSelectEntryPos() > 0 ) );
2102 	m_aIndividualWordsBtn.Enable( bEnable );
2103 
2104     UpdatePreview_Impl();
2105 	return 0;
2106 }
2107 
2108 // -----------------------------------------------------------------------
2109 
2110 IMPL_LINK( SvxCharEffectsPage, CbClickHdl_Impl, CheckBox*, EMPTYARG )
2111 {
2112 	UpdatePreview_Impl();
2113 	return 0;
2114 }
2115 
2116 // -----------------------------------------------------------------------
2117 
2118 IMPL_LINK( SvxCharEffectsPage, TristClickHdl_Impl, TriStateBox*, EMPTYARG )
2119 {
2120 	UpdatePreview_Impl();
2121 	return 0;
2122 }
2123 
2124 // -----------------------------------------------------------------------
2125 
2126 IMPL_LINK( SvxCharEffectsPage, ColorBoxSelectHdl_Impl, ColorListBox*, pBox )
2127 {
2128 	SvxFont& rFont = GetPreviewFont();
2129     SvxFont& rCJKFont = GetPreviewCJKFont();
2130 	SvxFont& rCTLFont = GetPreviewCTLFont();
2131 
2132 	Color aSelectedColor;
2133 	if ( pBox->GetSelectEntry() == m_aTransparentColorName )
2134 		aSelectedColor = Color( COL_TRANSPARENT );
2135 	else
2136 		aSelectedColor = pBox->GetSelectEntryColor();
2137     rFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
2138     rCJKFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
2139 	rCTLFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
2140 
2141     m_aPreviewWin.Invalidate();
2142 	return 0;
2143 }
2144 // -----------------------------------------------------------------------
2145 
2146 int SvxCharEffectsPage::DeactivatePage( SfxItemSet* _pSet )
2147 {
2148     if ( _pSet )
2149         FillItemSet( *_pSet );
2150 	return LEAVE_PAGE;
2151 }
2152 
2153 // -----------------------------------------------------------------------
2154 
2155 SfxTabPage* SvxCharEffectsPage::Create( Window* pParent, const SfxItemSet& rSet )
2156 {
2157 	return new SvxCharEffectsPage( pParent, rSet );
2158 }
2159 
2160 // -----------------------------------------------------------------------
2161 
2162 sal_uInt16* SvxCharEffectsPage::GetRanges()
2163 {
2164 	return pEffectsRanges;
2165 }
2166 
2167 // -----------------------------------------------------------------------
2168 
2169 void SvxCharEffectsPage::Reset( const SfxItemSet& rSet )
2170 {
2171 	SvxFont& rFont = GetPreviewFont();
2172     SvxFont& rCJKFont = GetPreviewCJKFont();
2173 	SvxFont& rCTLFont = GetPreviewCTLFont();
2174 
2175 	sal_Bool bEnable = sal_False;
2176 
2177 	// Underline
2178 	sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
2179 	rFont.SetUnderline( UNDERLINE_NONE );
2180     rCJKFont.SetUnderline( UNDERLINE_NONE );
2181 	rCTLFont.SetUnderline( UNDERLINE_NONE );
2182 
2183 	m_aUnderlineLB.SelectEntryPos( 0 );
2184 	SfxItemState eState = rSet.GetItemState( nWhich );
2185 
2186 	if ( eState >= SFX_ITEM_DONTCARE )
2187 	{
2188 		if ( eState == SFX_ITEM_DONTCARE )
2189 			m_aUnderlineLB.SetNoSelection();
2190 		else
2191 		{
2192 			const SvxUnderlineItem& rItem = (SvxUnderlineItem&)rSet.Get( nWhich );
2193 			FontUnderline eUnderline = (FontUnderline)rItem.GetValue();
2194 			rFont.SetUnderline( eUnderline );
2195             rCJKFont.SetUnderline( eUnderline );
2196 			rCTLFont.SetUnderline( eUnderline );
2197 
2198 			if ( eUnderline != UNDERLINE_NONE )
2199 			{
2200 				for ( sal_uInt16 i = 0; i < m_aUnderlineLB.GetEntryCount(); ++i )
2201 				{
2202 					if ( (FontUnderline)(sal_uLong)m_aUnderlineLB.GetEntryData(i) == eUnderline )
2203 					{
2204 						m_aUnderlineLB.SelectEntryPos(i);
2205 						bEnable |= sal_True;
2206 						break;
2207 					}
2208 				}
2209 
2210 				Color aColor = rItem.GetColor();
2211 				sal_uInt16 nPos = m_aUnderlineColorLB.GetEntryPos( aColor );
2212 
2213 				if ( LISTBOX_ENTRY_NOTFOUND != nPos )
2214 					m_aUnderlineColorLB.SelectEntryPos( nPos );
2215 				else
2216 				{
2217 					nPos = m_aUnderlineColorLB.GetEntryPos( aColor );
2218 					if ( LISTBOX_ENTRY_NOTFOUND != nPos )
2219 						m_aUnderlineColorLB.SelectEntryPos( nPos );
2220 					else
2221 						m_aUnderlineColorLB.SelectEntryPos(
2222 							m_aUnderlineColorLB.InsertEntry( aColor,
2223 								String( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) );
2224 				}
2225 			}
2226 			else
2227 			{
2228 				m_aUnderlineColorLB.SelectEntry( Color( COL_AUTO ));
2229 				m_aUnderlineColorLB.Disable();
2230 			}
2231 		}
2232 	}
2233 
2234 	// Overline
2235 	nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
2236 	rFont.SetOverline( UNDERLINE_NONE );
2237     rCJKFont.SetOverline( UNDERLINE_NONE );
2238 	rCTLFont.SetOverline( UNDERLINE_NONE );
2239 
2240 	m_aOverlineLB.SelectEntryPos( 0 );
2241 	eState = rSet.GetItemState( nWhich );
2242 
2243 	if ( eState >= SFX_ITEM_DONTCARE )
2244 	{
2245 		if ( eState == SFX_ITEM_DONTCARE )
2246 			m_aOverlineLB.SetNoSelection();
2247 		else
2248 		{
2249 			const SvxOverlineItem& rItem = (SvxOverlineItem&)rSet.Get( nWhich );
2250 			FontUnderline eOverline = (FontUnderline)rItem.GetValue();
2251 			rFont.SetOverline( eOverline );
2252             rCJKFont.SetOverline( eOverline );
2253 			rCTLFont.SetOverline( eOverline );
2254 
2255 			if ( eOverline != UNDERLINE_NONE )
2256 			{
2257 				for ( sal_uInt16 i = 0; i < m_aOverlineLB.GetEntryCount(); ++i )
2258 				{
2259 					if ( (FontUnderline)(sal_uLong)m_aOverlineLB.GetEntryData(i) == eOverline )
2260 					{
2261 						m_aOverlineLB.SelectEntryPos(i);
2262 						bEnable |= sal_True;
2263 						break;
2264 					}
2265 				}
2266 
2267 				Color aColor = rItem.GetColor();
2268 				sal_uInt16 nPos = m_aOverlineColorLB.GetEntryPos( aColor );
2269 
2270 				if ( LISTBOX_ENTRY_NOTFOUND != nPos )
2271 					m_aOverlineColorLB.SelectEntryPos( nPos );
2272 				else
2273 				{
2274 					nPos = m_aOverlineColorLB.GetEntryPos( aColor );
2275 					if ( LISTBOX_ENTRY_NOTFOUND != nPos )
2276 						m_aOverlineColorLB.SelectEntryPos( nPos );
2277 					else
2278 						m_aOverlineColorLB.SelectEntryPos(
2279 							m_aOverlineColorLB.InsertEntry( aColor,
2280 								String( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) );
2281 				}
2282 			}
2283 			else
2284 			{
2285 				m_aOverlineColorLB.SelectEntry( Color( COL_AUTO ));
2286 				m_aOverlineColorLB.Disable();
2287 			}
2288 		}
2289 	}
2290 
2291 	//	Strikeout
2292 	nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
2293 	rFont.SetStrikeout( STRIKEOUT_NONE );
2294     rCJKFont.SetStrikeout( STRIKEOUT_NONE );
2295 	rCTLFont.SetStrikeout( STRIKEOUT_NONE );
2296 
2297 	m_aStrikeoutLB.SelectEntryPos( 0 );
2298 	eState = rSet.GetItemState( nWhich );
2299 
2300 	if ( eState >= SFX_ITEM_DONTCARE )
2301 	{
2302 		if ( eState == SFX_ITEM_DONTCARE )
2303 			m_aStrikeoutLB.SetNoSelection();
2304 		else
2305 		{
2306 			const SvxCrossedOutItem& rItem = (SvxCrossedOutItem&)rSet.Get( nWhich );
2307 			FontStrikeout eStrikeout = (FontStrikeout)rItem.GetValue();
2308 			rFont.SetStrikeout( eStrikeout );
2309             rCJKFont.SetStrikeout( eStrikeout );
2310 			rCTLFont.SetStrikeout( eStrikeout );
2311 
2312 			if ( eStrikeout != STRIKEOUT_NONE )
2313 			{
2314 				for ( sal_uInt16 i = 0; i < m_aStrikeoutLB.GetEntryCount(); ++i )
2315 				{
2316 					if ( (FontStrikeout)(sal_uLong)m_aStrikeoutLB.GetEntryData(i) == eStrikeout )
2317 					{
2318 						m_aStrikeoutLB.SelectEntryPos(i);
2319 						bEnable |= sal_True;
2320 						break;
2321 					}
2322 				}
2323 			}
2324 		}
2325 	}
2326 
2327 	// WordLineMode
2328 	nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
2329 	switch ( eState )
2330 	{
2331 		case SFX_ITEM_UNKNOWN:
2332 			m_aIndividualWordsBtn.Hide();
2333 			break;
2334 
2335 		case SFX_ITEM_DISABLED:
2336 		case SFX_ITEM_READONLY:
2337 			m_aIndividualWordsBtn.Disable();
2338 			break;
2339 
2340 		case SFX_ITEM_DONTCARE:
2341 			m_aIndividualWordsBtn.SetState( STATE_DONTKNOW );
2342 			break;
2343 
2344 		case SFX_ITEM_DEFAULT:
2345 		case SFX_ITEM_SET:
2346 		{
2347 			const SvxWordLineModeItem& rItem = (SvxWordLineModeItem&)rSet.Get( nWhich );
2348 			rFont.SetWordLineMode( rItem.GetValue() );
2349         	rCJKFont.SetWordLineMode( rItem.GetValue() );
2350 			rCTLFont.SetWordLineMode( rItem.GetValue() );
2351 
2352 			m_aIndividualWordsBtn.Check( rItem.GetValue() );
2353 			m_aIndividualWordsBtn.Enable( bEnable );
2354 			break;
2355 		}
2356 	}
2357 
2358 	// Emphasis
2359 	nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
2360 	eState = rSet.GetItemState( nWhich );
2361 
2362 	if ( eState >= SFX_ITEM_DEFAULT )
2363 	{
2364 		const SvxEmphasisMarkItem& rItem = (SvxEmphasisMarkItem&)rSet.Get( nWhich );
2365 		FontEmphasisMark eMark = rItem.GetEmphasisMark();
2366 		rFont.SetEmphasisMark( eMark );
2367         rCJKFont.SetEmphasisMark( eMark );
2368 		rCTLFont.SetEmphasisMark( eMark );
2369 
2370 		m_aEmphasisLB.SelectEntryPos( (sal_uInt16)( eMark & EMPHASISMARK_STYLE ) );
2371         eMark &= ~EMPHASISMARK_STYLE;
2372         sal_uLong nEntryData = ( eMark == EMPHASISMARK_POS_ABOVE )
2373 			? CHRDLG_POSITION_OVER
2374 			: ( eMark == EMPHASISMARK_POS_BELOW ) ? CHRDLG_POSITION_UNDER : 0;
2375 
2376         for ( sal_uInt16 i = 0; i < m_aPositionLB.GetEntryCount(); i++ )
2377         {
2378             if ( nEntryData == (sal_uLong)m_aPositionLB.GetEntryData(i) )
2379             {
2380                 m_aPositionLB.SelectEntryPos(i);
2381                 break;
2382             }
2383         }
2384 	}
2385 	else if ( eState == SFX_ITEM_DONTCARE )
2386 		m_aEmphasisLB.SetNoSelection( );
2387 	else if ( eState == SFX_ITEM_UNKNOWN )
2388 	{
2389 		m_aEmphasisFT.Hide();
2390 		m_aEmphasisLB.Hide();
2391 	}
2392 	else // SFX_ITEM_DISABLED or SFX_ITEM_READONLY
2393 	{
2394 		m_aEmphasisFT.Disable();
2395 		m_aEmphasisLB.Disable();
2396 	}
2397 
2398 	// the select handler for the underline/overline/strikeout list boxes
2399 //	SelectHdl_Impl( NULL );
2400 	DBG_ASSERT(m_aUnderlineLB.GetSelectHdl() == m_aOverlineLB.GetSelectHdl(),
2401 		"SvxCharEffectsPage::Reset: inconsistence (1)!");
2402 	DBG_ASSERT(m_aUnderlineLB.GetSelectHdl() == m_aStrikeoutLB.GetSelectHdl(),
2403 		"SvxCharEffectsPage::Reset: inconsistence (1)!");
2404 	m_aUnderlineLB.GetSelectHdl().Call(NULL);
2405 		// don't call SelectHdl_Impl directly!
2406 		// in DisableControls, we may have re-reouted the select handler
2407 		// 30.05.2001 - 86262 - frank.schoenheit@germany.sun.com
2408 
2409 	// the select handler for the emphasis listbox
2410 //	SelectHdl_Impl( &m_aEmphasisLB );
2411 	DBG_ASSERT(m_aEmphasisLB.GetSelectHdl() == LINK(this, SvxCharEffectsPage, SelectHdl_Impl),
2412 		"SvxCharEffectsPage::Reset: inconsistence (2)!");
2413 	m_aEmphasisLB.GetSelectHdl().Call( &m_aEmphasisLB );
2414 		// this is for consistency only. Here it would be allowed to call SelectHdl_Impl directly ...
2415 
2416 	// Effects
2417 	SvxCaseMap eCaseMap = SVX_CASEMAP_END;
2418 	nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
2419 	eState = rSet.GetItemState( nWhich );
2420 	switch ( eState )
2421 	{
2422 		case SFX_ITEM_UNKNOWN:
2423 			m_aEffectsFT.Hide();
2424 			m_aEffects2LB.Hide();
2425 			break;
2426 
2427 		case SFX_ITEM_DISABLED:
2428 		case SFX_ITEM_READONLY:
2429 			m_aEffectsFT.Disable();
2430 			m_aEffects2LB.Disable();
2431 			break;
2432 
2433 		case SFX_ITEM_DONTCARE:
2434 			m_aEffects2LB.SetNoSelection();
2435 			break;
2436 
2437 		case SFX_ITEM_DEFAULT:
2438 		case SFX_ITEM_SET:
2439 		{
2440 			const SvxCaseMapItem& rItem = (const SvxCaseMapItem&)rSet.Get( nWhich );
2441 			eCaseMap = (SvxCaseMap)rItem.GetValue();
2442 			break;
2443 		}
2444 	}
2445 	SetCaseMap_Impl( eCaseMap );
2446 
2447     //Relief
2448     nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
2449 	eState = rSet.GetItemState( nWhich );
2450 	switch ( eState )
2451 	{
2452 		case SFX_ITEM_UNKNOWN:
2453 			m_aReliefFT.Hide();
2454 			m_aReliefLB.Hide();
2455 			break;
2456 
2457 		case SFX_ITEM_DISABLED:
2458 		case SFX_ITEM_READONLY:
2459 			m_aReliefFT.Disable();
2460 			m_aReliefLB.Disable();
2461 			break;
2462 
2463 		case SFX_ITEM_DONTCARE:
2464 			m_aReliefLB.SetNoSelection();
2465 			break;
2466 
2467 		case SFX_ITEM_DEFAULT:
2468 		case SFX_ITEM_SET:
2469 		{
2470         	const SvxCharReliefItem& rItem = (const SvxCharReliefItem&)rSet.Get( nWhich );
2471         	m_aReliefLB.SelectEntryPos(rItem.GetValue());
2472         	SelectHdl_Impl(&m_aReliefLB);
2473 			break;
2474 		}
2475 	}
2476 
2477     // Outline
2478 	nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
2479 	eState = rSet.GetItemState( nWhich );
2480 	switch ( eState )
2481 	{
2482 		case SFX_ITEM_UNKNOWN:
2483 			m_aOutlineBtn.Hide();
2484 			break;
2485 
2486 		case SFX_ITEM_DISABLED:
2487 		case SFX_ITEM_READONLY:
2488 			m_aOutlineBtn.Disable();
2489 			break;
2490 
2491 		case SFX_ITEM_DONTCARE:
2492 			m_aOutlineBtn.SetState( STATE_DONTKNOW );
2493 			break;
2494 
2495 		case SFX_ITEM_DEFAULT:
2496 		case SFX_ITEM_SET:
2497 		{
2498 			const SvxContourItem& rItem = (SvxContourItem&)rSet.Get( nWhich );
2499 			m_aOutlineBtn.SetState( (TriState)rItem.GetValue() );
2500 			m_aOutlineBtn.EnableTriState( sal_False );
2501 			break;
2502 		}
2503 	}
2504 
2505 	// Shadow
2506 	nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
2507 	eState = rSet.GetItemState( nWhich );
2508 
2509 	switch ( eState )
2510 	{
2511 		case SFX_ITEM_UNKNOWN:
2512 			m_aShadowBtn.Hide();
2513 			break;
2514 
2515 		case SFX_ITEM_DISABLED:
2516 		case SFX_ITEM_READONLY:
2517 			m_aShadowBtn.Disable();
2518 			break;
2519 
2520 		case SFX_ITEM_DONTCARE:
2521 			m_aShadowBtn.SetState( STATE_DONTKNOW );
2522 			break;
2523 
2524 		case SFX_ITEM_DEFAULT:
2525 		case SFX_ITEM_SET:
2526 		{
2527 			const SvxShadowedItem& rItem = (SvxShadowedItem&)rSet.Get( nWhich );
2528 			m_aShadowBtn.SetState( (TriState)rItem.GetValue() );
2529 			m_aShadowBtn.EnableTriState( sal_False );
2530 			break;
2531 		}
2532 	}
2533 
2534 	// Blinking
2535 	nWhich = GetWhich( SID_ATTR_FLASH );
2536 	eState = rSet.GetItemState( nWhich );
2537 
2538 	switch ( eState )
2539 	{
2540 		case SFX_ITEM_UNKNOWN:
2541 			m_aBlinkingBtn.Hide();
2542 			break;
2543 
2544 		case SFX_ITEM_DISABLED:
2545 		case SFX_ITEM_READONLY:
2546 			m_aBlinkingBtn.Disable();
2547 			break;
2548 
2549 		case SFX_ITEM_DONTCARE:
2550 			m_aBlinkingBtn.SetState( STATE_DONTKNOW );
2551 			break;
2552 
2553 		case SFX_ITEM_DEFAULT:
2554 		case SFX_ITEM_SET:
2555 		{
2556 			const SvxBlinkItem& rItem = (SvxBlinkItem&)rSet.Get( nWhich );
2557 			m_aBlinkingBtn.SetState( (TriState)rItem.GetValue() );
2558 			m_aBlinkingBtn.EnableTriState( sal_False );
2559 			break;
2560 		}
2561 	}
2562     // Hidden
2563     nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
2564     eState = rSet.GetItemState( nWhich );
2565 
2566     switch ( eState )
2567     {
2568         case SFX_ITEM_UNKNOWN:
2569             m_aHiddenBtn.Hide();
2570             break;
2571 
2572         case SFX_ITEM_DISABLED:
2573         case SFX_ITEM_READONLY:
2574             m_aHiddenBtn.Disable();
2575             break;
2576 
2577         case SFX_ITEM_DONTCARE:
2578             m_aHiddenBtn.SetState( STATE_DONTKNOW );
2579             break;
2580 
2581         case SFX_ITEM_DEFAULT:
2582         case SFX_ITEM_SET:
2583         {
2584             const SvxCharHiddenItem& rItem = (SvxCharHiddenItem&)rSet.Get( nWhich );
2585             m_aHiddenBtn.SetState( (TriState)rItem.GetValue() );
2586             m_aHiddenBtn.EnableTriState( sal_False );
2587             break;
2588         }
2589     }
2590 
2591 	SetPrevFontWidthScale( rSet );
2592 	ResetColor_Impl( rSet );
2593 
2594 	// preview update
2595 	m_aPreviewWin.Invalidate();
2596 
2597 	// save this settings
2598 	m_aUnderlineLB.SaveValue();
2599 	m_aUnderlineColorLB.SaveValue();
2600 	m_aOverlineLB.SaveValue();
2601 	m_aOverlineColorLB.SaveValue();
2602 	m_aStrikeoutLB.SaveValue();
2603 	m_aIndividualWordsBtn.SaveValue();
2604 	m_aEmphasisLB.SaveValue();
2605 	m_aPositionLB.SaveValue();
2606 	m_aEffects2LB.SaveValue();
2607     m_aReliefLB.SaveValue();
2608     m_aOutlineBtn.SaveValue();
2609 	m_aShadowBtn.SaveValue();
2610 	m_aBlinkingBtn.SaveValue();
2611     m_aHiddenBtn.SaveValue();
2612 	m_aFontColorLB.SaveValue();
2613 }
2614 
2615 // -----------------------------------------------------------------------
2616 
2617 sal_Bool SvxCharEffectsPage::FillItemSet( SfxItemSet& rSet )
2618 {
2619 	const SfxPoolItem* pOld = 0;
2620 	const SfxItemSet& rOldSet = GetItemSet();
2621 	sal_Bool bModified = sal_False;
2622 	FASTBOOL bChanged = sal_True;
2623 
2624 	// Underline
2625 	sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
2626 	pOld = GetOldItem( rSet, SID_ATTR_CHAR_UNDERLINE );
2627 	sal_uInt16 nPos = m_aUnderlineLB.GetSelectEntryPos();
2628 	FontUnderline eUnder = (FontUnderline)(sal_uLong)m_aUnderlineLB.GetEntryData( nPos );
2629 
2630 	if ( pOld )
2631 	{
2632         //! if there are different underline styles in the selection the
2633         //! item-state in the 'rOldSet' will be invalid. In this case
2634         //! changing the underline style will be allowed if a style is
2635         //! selected in the listbox.
2636         sal_Bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos  &&
2637                          SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, sal_True );
2638 
2639 		const SvxUnderlineItem& rItem = *( (const SvxUnderlineItem*)pOld );
2640 		if ( (FontUnderline)rItem.GetValue() == eUnder &&
2641              ( UNDERLINE_NONE == eUnder || rItem.GetColor() == m_aUnderlineColorLB.GetSelectEntryColor() ) &&
2642              ! bAllowChg )
2643 			bChanged = sal_False;
2644 	}
2645 
2646 	if ( bChanged )
2647 	{
2648 		SvxUnderlineItem aNewItem( eUnder, nWhich );
2649 		aNewItem.SetColor( m_aUnderlineColorLB.GetSelectEntryColor() );
2650 		rSet.Put( aNewItem );
2651 		bModified |= sal_True;
2652 	}
2653  	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
2654 		CLEARTITEM;
2655 
2656 	bChanged = sal_True;
2657 
2658 	// Overline
2659 	nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
2660 	pOld = GetOldItem( rSet, SID_ATTR_CHAR_OVERLINE );
2661 	nPos = m_aOverlineLB.GetSelectEntryPos();
2662 	FontUnderline eOver = (FontUnderline)(sal_uLong)m_aOverlineLB.GetEntryData( nPos );
2663 
2664 	if ( pOld )
2665 	{
2666         //! if there are different underline styles in the selection the
2667         //! item-state in the 'rOldSet' will be invalid. In this case
2668         //! changing the underline style will be allowed if a style is
2669         //! selected in the listbox.
2670         sal_Bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos  &&
2671                          SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, sal_True );
2672 
2673 		const SvxOverlineItem& rItem = *( (const SvxOverlineItem*)pOld );
2674 		if ( (FontUnderline)rItem.GetValue() == eOver &&
2675              ( UNDERLINE_NONE == eOver || rItem.GetColor() == m_aOverlineColorLB.GetSelectEntryColor() ) &&
2676              ! bAllowChg )
2677 			bChanged = sal_False;
2678 	}
2679 
2680 	if ( bChanged )
2681 	{
2682 		SvxOverlineItem aNewItem( eOver, nWhich );
2683 		aNewItem.SetColor( m_aOverlineColorLB.GetSelectEntryColor() );
2684 		rSet.Put( aNewItem );
2685 		bModified |= sal_True;
2686 	}
2687  	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
2688 		CLEARTITEM;
2689 
2690 	bChanged = sal_True;
2691 
2692 	// Strikeout
2693 	nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
2694 	pOld = GetOldItem( rSet, SID_ATTR_CHAR_STRIKEOUT );
2695 	nPos = m_aStrikeoutLB.GetSelectEntryPos();
2696 	FontStrikeout eStrike = (FontStrikeout)(sal_uLong)m_aStrikeoutLB.GetEntryData( nPos );
2697 
2698 	if ( pOld )
2699 	{
2700         //! if there are different strikeout styles in the selection the
2701         //! item-state in the 'rOldSet' will be invalid. In this case
2702         //! changing the strikeout style will be allowed if a style is
2703         //! selected in the listbox.
2704         sal_Bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos  &&
2705                          SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, sal_True );
2706 
2707 		const SvxCrossedOutItem& rItem = *( (const SvxCrossedOutItem*)pOld );
2708         if ( !m_aStrikeoutLB.IsEnabled()
2709             || ((FontStrikeout)rItem.GetValue() == eStrike  && !bAllowChg) )
2710 			bChanged = sal_False;
2711 	}
2712 
2713 	if ( bChanged )
2714 	{
2715 		rSet.Put( SvxCrossedOutItem( eStrike, nWhich ) );
2716 		bModified |= sal_True;
2717 	}
2718 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
2719 		CLEARTITEM;
2720 
2721 	bChanged = sal_True;
2722 
2723 	// Individual words
2724 	nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
2725 	pOld = GetOldItem( rSet, SID_ATTR_CHAR_WORDLINEMODE );
2726 
2727 	if ( pOld )
2728 	{
2729 		const SvxWordLineModeItem& rItem = *( (const SvxWordLineModeItem*)pOld );
2730 		if ( rItem.GetValue() == m_aIndividualWordsBtn.IsChecked() )
2731 			bChanged = sal_False;
2732 	}
2733 
2734 	if ( rOldSet.GetItemState( nWhich ) == SFX_ITEM_DONTCARE &&
2735 		 m_aIndividualWordsBtn.IsChecked() == m_aIndividualWordsBtn.GetSavedValue() )
2736 		bChanged = sal_False;
2737 
2738 	if ( bChanged )
2739 	{
2740 		rSet.Put( SvxWordLineModeItem( m_aIndividualWordsBtn.IsChecked(), nWhich ) );
2741 		bModified |= sal_True;
2742 	}
2743 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
2744 		CLEARTITEM;
2745 
2746 	bChanged = sal_True;
2747 
2748 	// Emphasis
2749 	nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
2750 	pOld = GetOldItem( rSet, SID_ATTR_CHAR_EMPHASISMARK );
2751 	sal_uInt16 nMarkPos = m_aEmphasisLB.GetSelectEntryPos();
2752 	sal_uInt16 nPosPos = m_aPositionLB.GetSelectEntryPos();
2753 	FontEmphasisMark eMark = (FontEmphasisMark)nMarkPos;
2754 	if ( m_aPositionLB.IsEnabled() )
2755 	{
2756 		eMark |= ( CHRDLG_POSITION_UNDER == (sal_uLong)m_aPositionLB.GetEntryData( nPosPos ) )
2757 			? EMPHASISMARK_POS_BELOW : EMPHASISMARK_POS_ABOVE;
2758 	}
2759 
2760 	if ( pOld )
2761 	{
2762     	if( rOldSet.GetItemState( nWhich ) != SFX_ITEM_DONTCARE )
2763         {
2764 		    const SvxEmphasisMarkItem& rItem = *( (const SvxEmphasisMarkItem*)pOld );
2765 		    if ( rItem.GetEmphasisMark() == eMark )
2766 			    bChanged = sal_False;
2767         }
2768 	}
2769 
2770 	if ( rOldSet.GetItemState( nWhich ) == SFX_ITEM_DONTCARE &&
2771 		 m_aEmphasisLB.GetSavedValue() == nMarkPos && m_aPositionLB.GetSavedValue() == nPosPos )
2772 		bChanged = sal_False;
2773 
2774 	if ( bChanged )
2775 	{
2776 		rSet.Put( SvxEmphasisMarkItem( eMark, nWhich ) );
2777 		bModified |= sal_True;
2778 	}
2779 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
2780 		CLEARTITEM;
2781 
2782 	bChanged = sal_True;
2783 
2784 	// Effects
2785 	nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
2786 	pOld = GetOldItem( rSet, SID_ATTR_CHAR_CASEMAP );
2787 	SvxCaseMap eCaseMap = SVX_CASEMAP_NOT_MAPPED;
2788 	FASTBOOL bChecked = sal_False;
2789 	sal_uInt16 nCapsPos = m_aEffects2LB.GetSelectEntryPos();
2790 	if ( nCapsPos != LISTBOX_ENTRY_NOTFOUND )
2791 	{
2792 		eCaseMap = (SvxCaseMap)nCapsPos;
2793 		bChecked = sal_True;
2794 	}
2795 
2796 	if ( pOld )
2797 	{
2798         //! if there are different effect styles in the selection the
2799         //! item-state in the 'rOldSet' will be invalid. In this case
2800         //! changing the effect style will be allowed if a style is
2801         //! selected in the listbox.
2802         sal_Bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos  &&
2803                          SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, sal_True );
2804 
2805         const SvxCaseMapItem& rItem = *( (const SvxCaseMapItem*)pOld );
2806         if ( (SvxCaseMap)rItem.GetValue() == eCaseMap  &&  !bAllowChg )
2807 			bChanged = sal_False;
2808 	}
2809 
2810 	if ( bChanged && bChecked )
2811 	{
2812 		rSet.Put( SvxCaseMapItem( eCaseMap, nWhich ) );
2813 		bModified |= sal_True;
2814 	}
2815 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
2816 		CLEARTITEM;
2817 
2818 	bChanged = sal_True;
2819 
2820     //Relief
2821     nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
2822     if(m_aReliefLB.GetSelectEntryPos() != m_aReliefLB.GetSavedValue())
2823     {
2824         m_aReliefLB.SaveValue();
2825         SvxCharReliefItem aRelief((FontRelief)m_aReliefLB.GetSelectEntryPos(), nWhich);
2826         rSet.Put(aRelief);
2827     }
2828 
2829     // Outline
2830 	const SfxItemSet* pExampleSet = GetTabDialog() ? GetTabDialog()->GetExampleSet() : NULL;
2831 	nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
2832 	pOld = GetOldItem( rSet, SID_ATTR_CHAR_CONTOUR );
2833 	TriState eState = m_aOutlineBtn.GetState();
2834 	const SfxPoolItem* pItem;
2835 
2836 	if ( pOld )
2837 	{
2838 		const SvxContourItem& rItem = *( (const SvxContourItem*)pOld );
2839 		if ( rItem.GetValue() == StateToAttr( eState ) && m_aOutlineBtn.GetSavedValue() == eState )
2840 			bChanged = sal_False;
2841 	}
2842 
2843 	if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
2844 		 !StateToAttr( eState ) && ( (SvxContourItem*)pItem )->GetValue() )
2845 		bChanged = sal_True;
2846 
2847 	if ( bChanged && eState != STATE_DONTKNOW )
2848 	{
2849 		rSet.Put( SvxContourItem( StateToAttr( eState ), nWhich ) );
2850 		bModified |= sal_True;
2851 	}
2852 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
2853 		CLEARTITEM;
2854 
2855 	bChanged = sal_True;
2856 
2857 	// Shadow
2858 	nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
2859 	pOld = GetOldItem( rSet, SID_ATTR_CHAR_SHADOWED );
2860 	eState = m_aShadowBtn.GetState();
2861 
2862 	if ( pOld )
2863 	{
2864 		const SvxShadowedItem& rItem = *( (const SvxShadowedItem*)pOld );
2865 		if ( rItem.GetValue() == StateToAttr( eState ) && m_aShadowBtn.GetSavedValue() == eState )
2866 			bChanged = sal_False;
2867 	}
2868 
2869 	if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
2870 		 !StateToAttr( eState ) && ( (SvxShadowedItem*)pItem )->GetValue() )
2871 		bChanged = sal_True;
2872 
2873 	if ( bChanged && eState != STATE_DONTKNOW )
2874 	{
2875 		rSet.Put( SvxShadowedItem( StateToAttr( eState ), nWhich ) );
2876 		bModified = sal_True;
2877 	}
2878 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
2879 		CLEARTITEM;
2880 
2881 	bChanged = sal_True;
2882 
2883 	// Blinking
2884 	nWhich = GetWhich( SID_ATTR_FLASH );
2885 	pOld = GetOldItem( rSet, SID_ATTR_FLASH );
2886 	eState = m_aBlinkingBtn.GetState();
2887 
2888 	if ( pOld )
2889 	{
2890 		const SvxBlinkItem& rItem = *( (const SvxBlinkItem*)pOld );
2891 		if ( rItem.GetValue() == StateToAttr( eState ) && m_aBlinkingBtn.GetSavedValue() == eState )
2892 			bChanged = sal_False;
2893 	}
2894 
2895 	if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
2896 		 !StateToAttr( eState ) && ( (SvxBlinkItem*)pItem )->GetValue() )
2897 		bChanged = sal_True;
2898 
2899 	if ( bChanged && eState != STATE_DONTKNOW )
2900 	{
2901 		rSet.Put( SvxBlinkItem( StateToAttr( eState ), nWhich ) );
2902 		bModified = sal_True;
2903 	}
2904 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
2905 		CLEARTITEM;
2906 
2907     // Hidden
2908     nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
2909     pOld = GetOldItem( rSet, SID_ATTR_CHAR_HIDDEN );
2910     eState = m_aHiddenBtn.GetState();
2911 	bChanged = sal_True;
2912 
2913     if ( pOld )
2914     {
2915         const SvxCharHiddenItem& rItem = *( (const SvxCharHiddenItem*)pOld );
2916         if ( rItem.GetValue() == StateToAttr( eState ) && m_aHiddenBtn.GetSavedValue() == eState )
2917             bChanged = sal_False;
2918     }
2919 
2920     if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
2921          !StateToAttr( eState ) && ( (SvxCharHiddenItem*)pItem )->GetValue() )
2922         bChanged = sal_True;
2923 
2924     if ( bChanged && eState != STATE_DONTKNOW )
2925     {
2926         rSet.Put( SvxCharHiddenItem( StateToAttr( eState ), nWhich ) );
2927         bModified = sal_True;
2928     }
2929     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
2930         CLEARTITEM;
2931 
2932 	bModified |= FillItemSetColor_Impl( rSet );
2933 
2934 	return bModified;
2935 }
2936 
2937 void SvxCharEffectsPage::DisableControls( sal_uInt16 nDisable )
2938 {
2939 	if ( ( DISABLE_CASEMAP & nDisable ) == DISABLE_CASEMAP )
2940 	{
2941 		m_aEffectsFT.Disable();
2942 		m_aEffects2LB.Disable();
2943 	}
2944 
2945 	if ( ( DISABLE_WORDLINE & nDisable ) == DISABLE_WORDLINE )
2946 		m_aIndividualWordsBtn.Disable();
2947 
2948 	if ( ( DISABLE_BLINK & nDisable ) == DISABLE_BLINK )
2949 		m_aBlinkingBtn.Disable();
2950 
2951 	if ( ( DISABLE_UNDERLINE_COLOR & nDisable ) == DISABLE_UNDERLINE_COLOR )
2952 	{
2953 		// disable the controls
2954 		m_aUnderlineColorFT.Disable( );
2955 		m_aUnderlineColorLB.Disable( );
2956 		// and reroute the selection handler of the controls which normally would affect the color box dis-/enabling
2957 		m_aUnderlineLB.SetSelectHdl(LINK(this, SvxCharEffectsPage, UpdatePreview_Impl));
2958 		m_aStrikeoutLB.SetSelectHdl(LINK(this, SvxCharEffectsPage, UpdatePreview_Impl));
2959     }
2960 }
2961 
2962 void SvxCharEffectsPage::EnableFlash()
2963 {
2964 	if ( !( ( m_nHtmlMode & HTMLMODE_ON ) && !( m_nHtmlMode & HTMLMODE_BLINK ) ) )
2965 		m_aBlinkingBtn.Show();
2966 }
2967 
2968 // -----------------------------------------------------------------------
2969 void SvxCharEffectsPage::SetPreviewBackgroundToCharacter()
2970 {
2971     m_bPreviewBackgroundToCharacter = sal_True;
2972 }
2973 
2974 // -----------------------------------------------------------------------
2975 void SvxCharEffectsPage::PageCreated (SfxAllItemSet aSet) //add CHINA001
2976 {
2977 	SFX_ITEMSET_ARG (&aSet,pDisableCtlItem,SfxUInt16Item,SID_DISABLE_CTL,sal_False);
2978 	SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False);
2979 	if (pDisableCtlItem)
2980 		DisableControls(pDisableCtlItem->GetValue());
2981 
2982 	if (pFlagItem)
2983 	{
2984 		sal_uInt32 nFlags=pFlagItem->GetValue();
2985 		if ( ( nFlags & SVX_ENABLE_FLASH ) == SVX_ENABLE_FLASH )
2986 			EnableFlash();
2987 		if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
2988 			SetPreviewBackgroundToCharacter();
2989 	}
2990 }
2991 
2992 // class SvxCharPositionPage ---------------------------------------------
2993 
2994 SvxCharPositionPage::SvxCharPositionPage( Window* pParent, const SfxItemSet& rInSet ) :
2995 
2996 	SvxCharBasePage( pParent, CUI_RES( RID_SVXPAGE_CHAR_POSITION ), rInSet, WIN_POS_PREVIEW, FT_POS_FONTTYPE ),
2997 
2998 	m_aPositionLine		( this, CUI_RES( FL_POSITION ) ),
2999 	m_aHighPosBtn		( this, CUI_RES( RB_HIGHPOS ) ),
3000 	m_aNormalPosBtn		( this, CUI_RES( RB_NORMALPOS ) ),
3001 	m_aLowPosBtn		( this, CUI_RES( RB_LOWPOS ) ),
3002 	m_aHighLowFT		( this, CUI_RES( FT_HIGHLOW ) ),
3003 	m_aHighLowEdit		( this, CUI_RES( ED_HIGHLOW ) ),
3004 	m_aHighLowRB		( this, CUI_RES( CB_HIGHLOW ) ),
3005 	m_aFontSizeFT		( this, CUI_RES( FT_FONTSIZE ) ),
3006 	m_aFontSizeEdit		( this, CUI_RES( ED_FONTSIZE ) ),
3007 	m_aRotationScalingFL( this, CUI_RES( FL_ROTATION_SCALING ) ),
3008 	m_aScalingFL		( this, CUI_RES( FL_SCALING ) ),
3009 	m_a0degRB			( this, CUI_RES( RB_0_DEG ) ),
3010 	m_a90degRB			( this, CUI_RES( RB_90_DEG ) ),
3011 	m_a270degRB			( this, CUI_RES( RB_270_DEG ) ),
3012 	m_aFitToLineCB		( this, CUI_RES( CB_FIT_TO_LINE ) ),
3013 	m_aScaleWidthFT		( this, CUI_RES( FT_SCALE_WIDTH ) ),
3014 	m_aScaleWidthMF		( this, CUI_RES( MF_SCALE_WIDTH ) ),
3015 
3016 	m_aKerningLine		( this, CUI_RES( FL_KERNING2 ) ),
3017 	m_aKerningLB		( this, CUI_RES( LB_KERNING2 ) ),
3018 	m_aKerningFT		( this, CUI_RES( FT_KERNING2 ) ),
3019 	m_aKerningEdit		( this, CUI_RES( ED_KERNING2 ) ),
3020 	m_aPairKerningBtn	( this, CUI_RES( CB_PAIRKERNING ) ),
3021 
3022 	m_nSuperEsc			( (short)DFLT_ESC_SUPER ),
3023 	m_nSubEsc			( (short)DFLT_ESC_SUB ),
3024 	m_nScaleWidthItemSetVal	( 100 ),
3025 	m_nScaleWidthInitialVal	( 100 ),
3026 	m_nSuperProp		( (sal_uInt8)DFLT_ESC_PROP ),
3027     m_nSubProp          ( (sal_uInt8)DFLT_ESC_PROP )
3028 {
3029 	FreeResource();
3030 	Initialize();
3031 }
3032 
3033 // -----------------------------------------------------------------------
3034 
3035 void SvxCharPositionPage::Initialize()
3036 {
3037 	// to handle the changes of the other pages
3038 	SetExchangeSupport();
3039 
3040 	GetPreviewFont().SetSize( Size( 0, 240 ) );
3041     GetPreviewCJKFont().SetSize( Size( 0, 240 ) );
3042 	GetPreviewCTLFont().SetSize( Size( 0, 240 ) );
3043 
3044 	m_aNormalPosBtn.Check();
3045 	PositionHdl_Impl( &m_aNormalPosBtn );
3046 	m_aKerningLB.SelectEntryPos( 0 );
3047 	KerningSelectHdl_Impl( NULL );
3048 
3049 	Link aLink = LINK( this, SvxCharPositionPage, PositionHdl_Impl );
3050 	m_aHighPosBtn.SetClickHdl( aLink );
3051 	m_aNormalPosBtn.SetClickHdl( aLink );
3052 	m_aLowPosBtn.SetClickHdl( aLink );
3053 
3054 	aLink = LINK( this, SvxCharPositionPage, RotationHdl_Impl );
3055 	m_a0degRB  .SetClickHdl( aLink );
3056 	m_a90degRB .SetClickHdl( aLink );
3057 	m_a270degRB.SetClickHdl( aLink );
3058 
3059 	aLink = LINK( this, SvxCharPositionPage, FontModifyHdl_Impl );
3060 	m_aHighLowEdit.SetModifyHdl( aLink );
3061 	m_aFontSizeEdit.SetModifyHdl( aLink );
3062 
3063 	aLink = LINK( this, SvxCharPositionPage, LoseFocusHdl_Impl );
3064 	m_aHighLowEdit.SetLoseFocusHdl( aLink );
3065 	m_aFontSizeEdit.SetLoseFocusHdl( aLink );
3066 
3067 	m_aHighLowRB.SetClickHdl( LINK( this, SvxCharPositionPage, AutoPositionHdl_Impl ) );
3068 	m_aFitToLineCB.SetClickHdl( LINK( this, SvxCharPositionPage, FitToLineHdl_Impl ) );
3069 	m_aKerningLB.SetSelectHdl( LINK( this, SvxCharPositionPage, KerningSelectHdl_Impl ) );
3070 	m_aKerningEdit.SetModifyHdl( LINK( this, SvxCharPositionPage, KerningModifyHdl_Impl ) );
3071 	m_aPairKerningBtn.SetClickHdl( LINK( this, SvxCharPositionPage, PairKerningHdl_Impl ) );
3072 	m_aScaleWidthMF.SetModifyHdl( LINK( this, SvxCharPositionPage, ScaleWidthModifyHdl_Impl ) );
3073 }
3074 
3075 // -----------------------------------------------------------------------
3076 
3077 void SvxCharPositionPage::UpdatePreview_Impl( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
3078 {
3079 	SetPrevFontEscapement( nProp, nEscProp, nEsc );
3080 }
3081 
3082 // -----------------------------------------------------------------------
3083 
3084 void SvxCharPositionPage::SetEscapement_Impl( sal_uInt16 nEsc )
3085 {
3086     SvxEscapementItem aEscItm( (SvxEscapement)nEsc, SID_ATTR_CHAR_ESCAPEMENT );
3087 
3088 	if ( SVX_ESCAPEMENT_SUPERSCRIPT == nEsc )
3089 	{
3090 		aEscItm.GetEsc() = m_nSuperEsc;
3091 		aEscItm.GetProp() = m_nSuperProp;
3092 	}
3093 	else if ( SVX_ESCAPEMENT_SUBSCRIPT == nEsc )
3094 	{
3095 		aEscItm.GetEsc() = m_nSubEsc;
3096 		aEscItm.GetProp() = m_nSubProp;
3097 	}
3098 
3099 	short nFac = aEscItm.GetEsc() < 0 ? -1 : 1;
3100 
3101 	m_aHighLowEdit.SetValue( aEscItm.GetEsc() * nFac );
3102 	m_aFontSizeEdit.SetValue( aEscItm.GetProp() );
3103 
3104 	if ( SVX_ESCAPEMENT_OFF == nEsc )
3105 	{
3106 		m_aHighLowFT.Disable();
3107 		m_aHighLowEdit.Disable();
3108 		m_aFontSizeFT.Disable();
3109 		m_aFontSizeEdit.Disable();
3110 		m_aHighLowRB.Disable();
3111 	}
3112 	else
3113 	{
3114 		m_aFontSizeFT.Enable();
3115 		m_aFontSizeEdit.Enable();
3116 		m_aHighLowRB.Enable();
3117 
3118 		if ( !m_aHighLowRB.IsChecked() )
3119 		{
3120 			m_aHighLowFT.Enable();
3121 			m_aHighLowEdit.Enable();
3122 		}
3123 		else
3124 			AutoPositionHdl_Impl( &m_aHighLowRB );
3125 	}
3126 
3127 	UpdatePreview_Impl( 100, aEscItm.GetProp(), aEscItm.GetEsc() );
3128 }
3129 
3130 // -----------------------------------------------------------------------
3131 
3132 IMPL_LINK( SvxCharPositionPage, PositionHdl_Impl, RadioButton*, pBtn )
3133 {
3134 	sal_uInt16 nEsc = SVX_ESCAPEMENT_OFF;	// also when pBtn == NULL
3135 
3136 	if ( &m_aHighPosBtn == pBtn )
3137 		nEsc = SVX_ESCAPEMENT_SUPERSCRIPT;
3138 	else if ( &m_aLowPosBtn == pBtn )
3139 		nEsc = SVX_ESCAPEMENT_SUBSCRIPT;
3140 
3141 	SetEscapement_Impl( nEsc );
3142 	return 0;
3143 }
3144 
3145 // -----------------------------------------------------------------------
3146 
3147 IMPL_LINK( SvxCharPositionPage, RotationHdl_Impl, RadioButton*, pBtn )
3148 {
3149 	sal_Bool bEnable = sal_False;
3150 	if (&m_a90degRB == pBtn  ||  &m_a270degRB == pBtn)
3151 		bEnable = sal_True;
3152 	else
3153 		OSL_ENSURE( &m_a0degRB == pBtn, "unexpected button" );
3154 	m_aFitToLineCB.Enable( bEnable );
3155 	return 0;
3156 }
3157 
3158 // -----------------------------------------------------------------------
3159 
3160 IMPL_LINK( SvxCharPositionPage, FontModifyHdl_Impl, MetricField*, EMPTYARG )
3161 {
3162 	sal_uInt8 nEscProp = (sal_uInt8)m_aFontSizeEdit.GetValue();
3163 	short nEsc	= (short)m_aHighLowEdit.GetValue();
3164 	nEsc *= m_aLowPosBtn.IsChecked() ? -1 : 1;
3165 	UpdatePreview_Impl( 100, nEscProp, nEsc );
3166 	return 0;
3167 }
3168 
3169 // -----------------------------------------------------------------------
3170 
3171 IMPL_LINK( SvxCharPositionPage, AutoPositionHdl_Impl, CheckBox*, pBox )
3172 {
3173 	if ( pBox->IsChecked() )
3174 	{
3175 		m_aHighLowFT.Disable();
3176 		m_aHighLowEdit.Disable();
3177 	}
3178 	else
3179 		PositionHdl_Impl( m_aHighPosBtn.IsChecked() ? &m_aHighPosBtn
3180 													  : m_aLowPosBtn.IsChecked() ? &m_aLowPosBtn
3181 													  							 : &m_aNormalPosBtn );
3182 	return 0;
3183 }
3184 
3185 // -----------------------------------------------------------------------
3186 
3187 IMPL_LINK( SvxCharPositionPage, FitToLineHdl_Impl, CheckBox*, pBox )
3188 {
3189 	if ( &m_aFitToLineCB == pBox)
3190 	{
3191 		sal_uInt16 nVal = m_nScaleWidthInitialVal;
3192 		if (m_aFitToLineCB.IsChecked())
3193 			nVal = m_nScaleWidthItemSetVal;
3194 		m_aScaleWidthMF.SetValue( nVal );
3195 
3196 		m_aPreviewWin.SetFontWidthScale( nVal );
3197 	}
3198 	return 0;
3199 }
3200 
3201 // -----------------------------------------------------------------------
3202 
3203 IMPL_LINK( SvxCharPositionPage, KerningSelectHdl_Impl, ListBox*, EMPTYARG )
3204 {
3205 	if ( m_aKerningLB.GetSelectEntryPos() > 0 )
3206 	{
3207 		m_aKerningFT.Enable();
3208 		m_aKerningEdit.Enable();
3209 
3210 		if ( m_aKerningLB.GetSelectEntryPos() == 2 )
3211 		{
3212 			// Condensed -> max value == 1/6 of the current font height
3213 			SvxFont& rFont = GetPreviewFont();
3214 			long nMax = rFont.GetSize().Height() / 6;
3215 			m_aKerningEdit.SetMax( m_aKerningEdit.Normalize( nMax ), FUNIT_TWIP );
3216 			m_aKerningEdit.SetLast( m_aKerningEdit.GetMax( m_aKerningEdit.GetUnit() ) );
3217 		}
3218 		else
3219 		{
3220             m_aKerningEdit.SetMax( 9999 );
3221 			m_aKerningEdit.SetLast( 9999 );
3222 		}
3223 	}
3224 	else
3225 	{
3226 		m_aKerningEdit.SetValue( 0 );
3227 		m_aKerningFT.Disable();
3228 		m_aKerningEdit.Disable();
3229 	}
3230 
3231 	KerningModifyHdl_Impl( NULL );
3232 
3233 	return 0;
3234 }
3235 
3236 // -----------------------------------------------------------------------
3237 
3238 IMPL_LINK( SvxCharPositionPage, KerningModifyHdl_Impl, MetricField*, EMPTYARG )
3239 {
3240 	long nVal = static_cast<long>(m_aKerningEdit.GetValue());
3241 	nVal = LogicToLogic( nVal, MAP_POINT, MAP_TWIP );
3242 	long nKern = (short)m_aKerningEdit.Denormalize( nVal );
3243 
3244 	// Condensed? -> then negative
3245 	if ( m_aKerningLB.GetSelectEntryPos() == 2 )
3246 		nKern *= -1;
3247 
3248 	SvxFont& rFont = GetPreviewFont();
3249     SvxFont& rCJKFont = GetPreviewCJKFont();
3250 	SvxFont& rCTLFont = GetPreviewCTLFont();
3251 
3252 	rFont.SetFixKerning( (short)nKern );
3253     rCJKFont.SetFixKerning( (short)nKern );
3254 	rCTLFont.SetFixKerning( (short)nKern );
3255 	m_aPreviewWin.Invalidate();
3256 	return 0;
3257 }
3258 
3259 // -----------------------------------------------------------------------
3260 
3261 IMPL_LINK( SvxCharPositionPage, PairKerningHdl_Impl, CheckBox*, EMPTYARG )
3262 {
3263 	return 0;
3264 }
3265 
3266 // -----------------------------------------------------------------------
3267 
3268 IMPL_LINK( SvxCharPositionPage, LoseFocusHdl_Impl, MetricField*, pField )
3269 {
3270 #ifdef DBG_UTIL
3271 	sal_Bool bHigh = m_aHighPosBtn.IsChecked();
3272 #endif
3273 	sal_Bool bLow = m_aLowPosBtn.IsChecked();
3274 	DBG_ASSERT( bHigh || bLow, "normal position is not valid" );
3275 
3276 	if ( &m_aHighLowEdit == pField )
3277 	{
3278 		if ( bLow )
3279 			m_nSubEsc = (short)m_aHighLowEdit.GetValue() * -1;
3280 		else
3281 			m_nSuperEsc = (short)m_aHighLowEdit.GetValue();
3282 	}
3283 	else if ( &m_aFontSizeEdit == pField )
3284 	{
3285 		if ( bLow )
3286 			m_nSubProp = (sal_uInt8)m_aFontSizeEdit.GetValue();
3287 		else
3288 			m_nSuperProp = (sal_uInt8)m_aFontSizeEdit.GetValue();
3289 	}
3290 	return 0;
3291 }
3292 
3293 // -----------------------------------------------------------------------
3294 
3295 IMPL_LINK( SvxCharPositionPage, ScaleWidthModifyHdl_Impl, MetricField*, EMPTYARG )
3296 {
3297 	m_aPreviewWin.SetFontWidthScale( sal_uInt16( m_aScaleWidthMF.GetValue() ) );
3298 
3299 	return 0;
3300 }
3301 
3302 /* -----------------28.08.2003 12:12-----------------
3303 
3304  --------------------------------------------------*/
3305 void  SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
3306 {
3307     //update the preview
3308     SvxCharBasePage::ActivatePage( rSet );
3309 
3310     //the only thing that has to be checked is the max. allowed value for the
3311     //condense edit field
3312     if ( m_aKerningLB.GetSelectEntryPos() == 2 )
3313     {
3314         // Condensed -> max value == 1/6 of the current font height
3315         SvxFont& rFont = GetPreviewFont();
3316         long nMax = rFont.GetSize().Height() / 6;
3317         long nKern = (short)m_aKerningEdit.Denormalize( LogicToLogic( static_cast<long>(m_aKerningEdit.GetValue()), MAP_POINT, MAP_TWIP ) );
3318         m_aKerningEdit.SetMax( m_aKerningEdit.Normalize( nKern > nMax ? nKern : nMax ), FUNIT_TWIP );
3319         m_aKerningEdit.SetLast( m_aKerningEdit.GetMax( m_aKerningEdit.GetUnit() ) );
3320     }
3321 }
3322 
3323 // -----------------------------------------------------------------------
3324 
3325 int SvxCharPositionPage::DeactivatePage( SfxItemSet* _pSet )
3326 {
3327     if ( _pSet )
3328         FillItemSet( *_pSet );
3329 	return LEAVE_PAGE;
3330 }
3331 
3332 // -----------------------------------------------------------------------
3333 
3334 SfxTabPage* SvxCharPositionPage::Create( Window* pParent, const SfxItemSet& rSet )
3335 {
3336 	return new SvxCharPositionPage( pParent, rSet );
3337 }
3338 
3339 // -----------------------------------------------------------------------
3340 
3341 sal_uInt16* SvxCharPositionPage::GetRanges()
3342 {
3343 	return pPositionRanges;
3344 }
3345 
3346 // -----------------------------------------------------------------------
3347 void SvxCharPositionPage::Reset( const SfxItemSet& rSet )
3348 {
3349 	String sUser = GetUserData();
3350 
3351 	if ( sUser.Len() )
3352 	{
3353 		m_nSuperEsc = (short)sUser.GetToken( 0 ).ToInt32();
3354 		m_nSubEsc = (short)sUser.GetToken( 1 ).ToInt32();
3355 		m_nSuperProp = (sal_uInt8)sUser.GetToken( 2 ).ToInt32();
3356 		m_nSubProp = (sal_uInt8)sUser.GetToken( 3 ).ToInt32();
3357 	}
3358 
3359 	short nEsc = 0;
3360 	sal_uInt8 nEscProp = 100;
3361 	sal_uInt8 nProp = 100;
3362 
3363 	m_aHighLowFT.Disable();
3364 	m_aHighLowEdit.Disable();
3365 	m_aFontSizeFT.Disable();
3366 	m_aFontSizeEdit.Disable();
3367 
3368 	SvxFont& rFont = GetPreviewFont();
3369     SvxFont& rCJKFont = GetPreviewCJKFont();
3370 	SvxFont& rCTLFont = GetPreviewCTLFont();
3371 	sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
3372 
3373 	if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
3374 	{
3375 		const SvxEscapementItem& rItem = (SvxEscapementItem&)rSet.Get( nWhich );
3376 		nEsc = rItem.GetEsc();
3377 		nEscProp = rItem.GetProp();
3378 
3379 		if ( nEsc != 0 )
3380 		{
3381 			m_aHighLowFT.Enable();
3382 			m_aHighLowEdit.Enable();
3383 			m_aFontSizeFT.Enable();
3384 			m_aFontSizeEdit.Enable();
3385 
3386 			short nFac;
3387             sal_Bool bAutomatic(sal_False);
3388 
3389 			if ( nEsc > 0 )
3390 			{
3391 				nFac = 1;
3392 				m_aHighPosBtn.Check( sal_True );
3393 				if ( nEsc == DFLT_ESC_AUTO_SUPER )
3394 				{
3395 					nEsc = DFLT_ESC_SUPER;
3396                     bAutomatic = sal_True;
3397 				}
3398 			}
3399 			else
3400 			{
3401 				nFac = -1;
3402 				m_aLowPosBtn.Check( sal_True );
3403 				if ( nEsc == DFLT_ESC_AUTO_SUB )
3404 				{
3405 					nEsc = DFLT_ESC_SUB;
3406                     bAutomatic = sal_True;
3407 				}
3408 			}
3409             if (!m_aHighLowRB.IsEnabled())
3410             {
3411                 m_aHighLowRB.Enable();
3412             }
3413             m_aHighLowRB.Check(bAutomatic);
3414 
3415 			if ( m_aHighLowRB.IsChecked() )
3416 			{
3417 				m_aHighLowFT.Disable();
3418 				m_aHighLowEdit.Disable();
3419 			}
3420 			m_aHighLowEdit.SetValue( m_aHighLowEdit.Normalize( nFac * nEsc ) );
3421 		}
3422 		else
3423 		{
3424 			m_aNormalPosBtn.Check( sal_True );
3425 			m_aHighLowRB.Check( sal_True );
3426 			PositionHdl_Impl( NULL );
3427 		}
3428 	    //the height has to be set after the handler is called to keep the value also if the escapement is zero
3429         m_aFontSizeEdit.SetValue( m_aFontSizeEdit.Normalize( nEscProp ) );
3430 	}
3431 	else
3432 	{
3433 		m_aHighPosBtn.Check( sal_False );
3434 		m_aNormalPosBtn.Check( sal_False );
3435 		m_aLowPosBtn.Check( sal_False );
3436 	}
3437 
3438 	// BspFont setzen
3439 	SetPrevFontEscapement( nProp, nEscProp, nEsc );
3440 
3441 	// Kerning
3442 	nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
3443 
3444 	if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
3445 	{
3446 		const SvxKerningItem& rItem = (SvxKerningItem&)rSet.Get( nWhich );
3447 		SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
3448 		MapUnit eOrgUnit = (MapUnit)eUnit;
3449 		MapUnit ePntUnit( MAP_POINT );
3450 		long nBig = static_cast<long>(m_aKerningEdit.Normalize( static_cast<long>(rItem.GetValue()) ));
3451 		long nKerning = LogicToLogic( nBig, eOrgUnit, ePntUnit );
3452 
3453 		// Kerning am Font setzen, vorher in Twips umrechnen
3454 		long nKern = LogicToLogic( rItem.GetValue(), (MapUnit)eUnit, MAP_TWIP );
3455 		rFont.SetFixKerning( (short)nKern );
3456         rCJKFont.SetFixKerning( (short)nKern );
3457 		rCTLFont.SetFixKerning( (short)nKern );
3458 
3459 		if ( nKerning > 0 )
3460 		{
3461 			m_aKerningLB.SelectEntryPos( LW_GESPERRT );
3462 		}
3463 		else if ( nKerning < 0 )
3464 		{
3465 			m_aKerningLB.SelectEntryPos( LW_SCHMAL );
3466 			nKerning = -nKerning;
3467 		}
3468 		else
3469 		{
3470 			nKerning = 0;
3471 			m_aKerningLB.SelectEntryPos( LW_NORMAL );
3472 		}
3473         //enable/disable and set min/max of the Edit
3474         KerningSelectHdl_Impl(&m_aKerningLB);
3475         //the attribute value must be displayed also if it's above the maximum allowed value
3476         long nVal = static_cast<long>(m_aKerningEdit.GetMax());
3477         if(nVal < nKerning)
3478             m_aKerningEdit.SetMax( nKerning );
3479         m_aKerningEdit.SetValue( nKerning );
3480 	}
3481 	else
3482 		m_aKerningEdit.SetText( String() );
3483 
3484 	// Pair kerning
3485 	nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
3486 
3487 	if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
3488 	{
3489 		const SvxAutoKernItem& rItem = (SvxAutoKernItem&)rSet.Get( nWhich );
3490 		m_aPairKerningBtn.Check( rItem.GetValue() );
3491 	}
3492 	else
3493 		m_aPairKerningBtn.Check( sal_False );
3494 
3495 	// Scale Width
3496 	nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
3497 	if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
3498 	{
3499 		const SvxCharScaleWidthItem& rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich );
3500 		m_nScaleWidthInitialVal = rItem.GetValue();
3501 		m_aScaleWidthMF.SetValue( m_nScaleWidthInitialVal );
3502 	}
3503 	else
3504 		m_aScaleWidthMF.SetValue( 100 );
3505 
3506     nWhich = GetWhich( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE );
3507 	if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
3508 		m_nScaleWidthItemSetVal = ((SfxUInt16Item&) rSet.Get( nWhich )).GetValue();
3509 
3510 	// Rotation
3511 	nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
3512 	SfxItemState eState = rSet.GetItemState( nWhich );
3513 	if( SFX_ITEM_UNKNOWN == eState )
3514 	{
3515 		m_aRotationScalingFL.Hide();
3516 		m_aScalingFL.Show();
3517 		m_a0degRB.Hide();
3518 		m_a90degRB.Hide();
3519 		m_a270degRB.Hide();
3520 		m_aFitToLineCB.Hide();
3521         m_aFitToLineCB .Hide();
3522 
3523 
3524         // move the following controls upwards
3525 		Window* aCntrlArr[] = {
3526 			&m_aScaleWidthFT, &m_aScaleWidthMF, &m_aKerningLine,
3527 			&m_aKerningLB, &m_aKerningFT, &m_aKerningEdit, &m_aPairKerningBtn,
3528 			0 };
3529 
3530         long nDiff = m_aScaleWidthMF.GetPosPixel().Y() -
3531                         m_a0degRB.GetPosPixel().Y();
3532 
3533 		for( Window** ppW = aCntrlArr; *ppW; ++ppW )
3534 		{
3535 			Point aPnt( (*ppW)->GetPosPixel() );
3536 			aPnt.Y() -= nDiff;
3537 			(*ppW)->SetPosPixel( aPnt );
3538 		}
3539 	}
3540 	else
3541 	{
3542 		m_aScalingFL.Hide();
3543 
3544 		Link aOldLink( m_aFitToLineCB.GetClickHdl() );
3545 		m_aFitToLineCB.SetClickHdl( Link() );
3546 		if( eState >= SFX_ITEM_DEFAULT )
3547 		{
3548 			const SvxCharRotateItem& rItem =
3549 					(SvxCharRotateItem&) rSet.Get( nWhich );
3550 			if (rItem.IsBottomToTop())
3551 				m_a90degRB.Check( sal_True );
3552 			else if (rItem.IsTopToBotton())
3553 				m_a270degRB.Check( sal_True );
3554 			else
3555 			{
3556 				DBG_ASSERT( 0 == rItem.GetValue(), "incorrect value" );
3557 				m_a0degRB.Check( sal_True );
3558 			}
3559 			m_aFitToLineCB.Check( rItem.IsFitToLine() );
3560 		}
3561 		else
3562 		{
3563 			if( eState == SFX_ITEM_DONTCARE )
3564 			{
3565 				m_a0degRB.Check( sal_False );
3566 				m_a90degRB.Check( sal_False );
3567 				m_a270degRB.Check( sal_False );
3568 			}
3569 			else
3570 				m_a0degRB.Check( sal_True );
3571 
3572 			m_aFitToLineCB.Check( sal_False );
3573 		}
3574 		m_aFitToLineCB.SetClickHdl( aOldLink );
3575 		m_aFitToLineCB.Enable( !m_a0degRB.IsChecked() );
3576 
3577 		// is this value set?
3578 		if( SFX_ITEM_UNKNOWN == rSet.GetItemState( GetWhich(
3579 										SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ) ))
3580 			m_aFitToLineCB.Hide();
3581 	}
3582 
3583 	m_aHighPosBtn.SaveValue();
3584 	m_aNormalPosBtn.SaveValue();
3585 	m_aLowPosBtn.SaveValue();
3586 	m_a0degRB.SaveValue();
3587 	m_a90degRB.SaveValue();
3588 	m_a270degRB.SaveValue();
3589 	m_aFitToLineCB.SaveValue();
3590 	m_aScaleWidthMF.SaveValue();
3591 	m_aKerningLB.SaveValue();
3592 	m_aKerningEdit.SaveValue();
3593 	m_aPairKerningBtn.SaveValue();
3594 }
3595 
3596 // -----------------------------------------------------------------------
3597 
3598 sal_Bool SvxCharPositionPage::FillItemSet( SfxItemSet& rSet )
3599 {
3600 	//	Position (hoch, normal oder tief)
3601 	const SfxItemSet& rOldSet = GetItemSet();
3602 	sal_Bool bModified = sal_False, bChanged = sal_True;
3603 	sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
3604 	const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_CHAR_ESCAPEMENT );
3605 	const FASTBOOL bHigh = m_aHighPosBtn.IsChecked();
3606 	short nEsc;
3607 	sal_uInt8  nEscProp;
3608 
3609 	if ( bHigh || m_aLowPosBtn.IsChecked() )
3610 	{
3611 		if ( m_aHighLowRB.IsChecked() )
3612 			nEsc = bHigh ? DFLT_ESC_AUTO_SUPER : DFLT_ESC_AUTO_SUB;
3613 		else
3614 		{
3615 			nEsc = (short)m_aHighLowEdit.Denormalize( m_aHighLowEdit.GetValue() );
3616 			nEsc *= bHigh ? 1 : -1;
3617 		}
3618 		nEscProp = (sal_uInt8)m_aFontSizeEdit.Denormalize( m_aFontSizeEdit.GetValue() );
3619 	}
3620 	else
3621 	{
3622 		nEsc  = 0;
3623 		nEscProp = 100;
3624 	}
3625 
3626 	if ( pOld )
3627 	{
3628 		const SvxEscapementItem& rItem = *( (const SvxEscapementItem*)pOld );
3629 		if ( rItem.GetEsc() == nEsc && rItem.GetProp() == nEscProp	)
3630 			bChanged = sal_False;
3631 	}
3632 
3633 	if ( !bChanged && !m_aHighPosBtn.GetSavedValue() &&
3634 		 !m_aNormalPosBtn.GetSavedValue() && !m_aLowPosBtn.GetSavedValue() )
3635 		bChanged = sal_True;
3636 
3637 	if ( bChanged &&
3638 		 ( m_aHighPosBtn.IsChecked() || m_aNormalPosBtn.IsChecked() || m_aLowPosBtn.IsChecked() ) )
3639 	{
3640 		rSet.Put( SvxEscapementItem( nEsc, nEscProp, nWhich ) );
3641 		bModified = sal_True;
3642 	}
3643 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
3644 		CLEARTITEM;
3645 
3646 	bChanged = sal_True;
3647 
3648 	// Kerning
3649 	nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
3650 	pOld = GetOldItem( rSet, SID_ATTR_CHAR_KERNING );
3651 	sal_uInt16 nPos = m_aKerningLB.GetSelectEntryPos();
3652 	short nKerning = 0;
3653 	SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
3654 
3655 	if ( nPos == LW_GESPERRT || nPos == LW_SCHMAL )
3656 	{
3657 		long nTmp = static_cast<long>(m_aKerningEdit.GetValue());
3658 		long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit );
3659 		nKerning = (short)m_aKerningEdit.Denormalize( nVal );
3660 
3661 		if ( nPos == LW_SCHMAL )
3662 			nKerning *= - 1;
3663 	}
3664 
3665 	if ( pOld )
3666 	{
3667 		const SvxKerningItem& rItem = *( (const SvxKerningItem*)pOld );
3668 		if ( rItem.GetValue() == nKerning )
3669 			bChanged = sal_False;
3670 	}
3671 
3672 	if ( !bChanged &&
3673 		 ( m_aKerningLB.GetSavedValue() == LISTBOX_ENTRY_NOTFOUND ||
3674 		   ( !m_aKerningEdit.GetSavedValue().Len() && m_aKerningEdit.IsEnabled() ) ) )
3675 		bChanged = sal_True;
3676 
3677 	if ( bChanged && nPos != LISTBOX_ENTRY_NOTFOUND )
3678 	{
3679 		rSet.Put( SvxKerningItem( nKerning, nWhich ) );
3680 		bModified |= sal_True;
3681 	}
3682 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
3683 		CLEARTITEM;
3684 
3685 	bChanged = sal_True;
3686 
3687 	// Pair-Kerning
3688 	nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
3689 
3690 	if ( m_aPairKerningBtn.IsChecked() != m_aPairKerningBtn.GetSavedValue() )
3691 	{
3692 		rSet.Put( SvxAutoKernItem( m_aPairKerningBtn.IsChecked(), nWhich ) );
3693 		bModified |= sal_True;
3694 	}
3695 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
3696 		CLEARTITEM;
3697 
3698 	// Scale Width
3699 	nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
3700 	if ( m_aScaleWidthMF.GetText() != m_aScaleWidthMF.GetSavedValue() )
3701 	{
3702 		rSet.Put( SvxCharScaleWidthItem( (sal_uInt16)m_aScaleWidthMF.GetValue(), nWhich ) );
3703 		bModified |= sal_True;
3704 	}
3705 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
3706 		CLEARTITEM;
3707 
3708 	// Rotation
3709 	nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
3710 	if ( m_a0degRB     .IsChecked() != m_a0degRB     .GetSavedValue()  ||
3711 		 m_a90degRB    .IsChecked() != m_a90degRB    .GetSavedValue()  ||
3712 		 m_a270degRB   .IsChecked() != m_a270degRB   .GetSavedValue()  ||
3713 		 m_aFitToLineCB.IsChecked() != m_aFitToLineCB.GetSavedValue() )
3714 	{
3715 		SvxCharRotateItem aItem( 0, m_aFitToLineCB.IsChecked(), nWhich );
3716 		if (m_a90degRB.IsChecked())
3717 			aItem.SetBottomToTop();
3718 		else if (m_a270degRB.IsChecked())
3719 			aItem.SetTopToBotton();
3720 		rSet.Put( aItem );
3721 		bModified |= sal_True;
3722 	}
3723 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
3724 		CLEARTITEM;
3725 
3726 	return bModified;
3727 }
3728 
3729 // -----------------------------------------------------------------------
3730 
3731 void SvxCharPositionPage::FillUserData()
3732 {
3733 	const sal_Unicode cTok = ';';
3734 
3735 	String sUser( UniString::CreateFromInt32( m_nSuperEsc ) );
3736 	sUser.Append( cTok );
3737 	sUser.Append( UniString::CreateFromInt32( m_nSubEsc ) );
3738 	sUser.Append( cTok );
3739 	sUser.Append( UniString::CreateFromInt32( m_nSuperProp ) );
3740 	sUser.Append( cTok );
3741 	sUser.Append( UniString::CreateFromInt32( m_nSubProp ) );
3742 	SetUserData( sUser );
3743 }
3744 
3745 // -----------------------------------------------------------------------
3746 void SvxCharPositionPage::SetPreviewBackgroundToCharacter()
3747 {
3748     m_bPreviewBackgroundToCharacter = sal_True;
3749 }
3750 // -----------------------------------------------------------------------
3751 void SvxCharPositionPage::PageCreated (SfxAllItemSet aSet) //add CHINA001
3752 {
3753 	SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False);
3754 	if (pFlagItem)
3755 	{
3756 		sal_uInt32 nFlags=pFlagItem->GetValue();
3757 		if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
3758 			SetPreviewBackgroundToCharacter();
3759 	}
3760 }
3761 // class SvxCharTwoLinesPage ------------------------------------------------
3762 
3763 SvxCharTwoLinesPage::SvxCharTwoLinesPage( Window* pParent, const SfxItemSet& rInSet ) :
3764 
3765 	SvxCharBasePage( pParent, CUI_RES( RID_SVXPAGE_CHAR_TWOLINES ), rInSet, WIN_TWOLINES_PREVIEW, FT_TWOLINES_FONTTYPE ),
3766 
3767 	m_aSwitchOnLine		( this, CUI_RES( FL_SWITCHON ) ),
3768 	m_aTwoLinesBtn		( this, CUI_RES( CB_TWOLINES ) ),
3769 
3770 	m_aEncloseLine		( this, CUI_RES( FL_ENCLOSE ) ),
3771 	m_aStartBracketFT	( this, CUI_RES( FT_STARTBRACKET ) ),
3772 	m_aStartBracketLB	( this, CUI_RES( ED_STARTBRACKET ) ),
3773 	m_aEndBracketFT		( this, CUI_RES( FT_ENDBRACKET ) ),
3774 	m_aEndBracketLB		( this, CUI_RES( ED_ENDBRACKET ) ),
3775 	m_nStartBracketPosition( 0 ),
3776 	m_nEndBracketPosition( 0 )
3777 {
3778 	FreeResource();
3779 	Initialize();
3780 }
3781 
3782 // -----------------------------------------------------------------------
3783 
3784 void SvxCharTwoLinesPage::Initialize()
3785 {
3786 	Size aSize = m_aStartBracketLB.GetSizePixel();
3787     aSize.Height() = m_aStartBracketLB.CalcSize( 1, 6 ).Height();
3788 	m_aStartBracketLB.SetSizePixel( aSize );
3789 	aSize = m_aEndBracketLB.GetSizePixel();
3790     aSize.Height() = m_aEndBracketLB.CalcSize( 1, 6 ).Height();
3791 	m_aEndBracketLB.SetSizePixel( aSize );
3792 
3793 	m_aTwoLinesBtn.Check( sal_False );
3794 	TwoLinesHdl_Impl( NULL );
3795 
3796 	m_aTwoLinesBtn.SetClickHdl( LINK( this, SvxCharTwoLinesPage, TwoLinesHdl_Impl ) );
3797 
3798 	Link aLink = LINK( this, SvxCharTwoLinesPage, CharacterMapHdl_Impl );
3799 	m_aStartBracketLB.SetSelectHdl( aLink );
3800 	m_aEndBracketLB.SetSelectHdl( aLink );
3801 
3802 	SvxFont& rFont = GetPreviewFont();
3803     SvxFont& rCJKFont = GetPreviewCJKFont();
3804 	SvxFont& rCTLFont = GetPreviewCTLFont();
3805 	rFont.SetSize( Size( 0, 220 ) );
3806     rCJKFont.SetSize( Size( 0, 220 ) );
3807 	rCTLFont.SetSize( Size( 0, 220 ) );
3808 }
3809 
3810 // -----------------------------------------------------------------------
3811 
3812 void SvxCharTwoLinesPage::SelectCharacter( ListBox* pBox )
3813 {
3814 	//CHINA001 SvxCharacterMap aDlg( this );
3815     bool bStart = pBox == &m_aStartBracketLB;
3816 	//SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
3817 	//if(pFact)
3818 	{
3819 		//AbstractSvxCharacterMap* aDlg = pFact->CreateSvxCharacterMap( this,  RID_SVXDLG_CHARMAP );
3820 		SvxCharacterMap* aDlg = new SvxCharacterMap( this );
3821 		aDlg->DisableFontSelection();//CHINA001 aDlg.DisableFontSelection();
3822 
3823 		if ( aDlg->Execute() == RET_OK )//CHINA001 ( aDlg.Execute() == RET_OK )
3824 		{
3825 			sal_Unicode cChar = (sal_Unicode) aDlg->GetChar();//CHINA001 aDlg.GetChar();
3826 			SetBracket( cChar, bStart );
3827 		}
3828         else
3829         {
3830             pBox->SelectEntryPos( bStart ? m_nStartBracketPosition : m_nEndBracketPosition );
3831         }
3832 		delete aDlg; //add CHINA001
3833 	}
3834 }
3835 
3836 // -----------------------------------------------------------------------
3837 
3838 void SvxCharTwoLinesPage::SetBracket( sal_Unicode cBracket, sal_Bool bStart )
3839 {
3840     sal_uInt16 nEntryPos = 0;
3841 	ListBox* pBox = bStart ? &m_aStartBracketLB : &m_aEndBracketLB;
3842 	if ( 0 == cBracket )
3843 		pBox->SelectEntryPos(0);
3844 	else
3845 	{
3846 		FASTBOOL bFound = sal_False;
3847 		for ( sal_uInt16 i = 1; i < pBox->GetEntryCount(); ++i )
3848 		{
3849 			if ( (sal_uLong)pBox->GetEntryData(i) != CHRDLG_ENCLOSE_SPECIAL_CHAR )
3850 			{
3851 				const sal_Unicode cChar = pBox->GetEntry(i).GetChar(0);
3852 				if ( cChar == cBracket )
3853 				{
3854 					pBox->SelectEntryPos(i);
3855                     nEntryPos = i;
3856 					bFound = sal_True;
3857 					break;
3858 				}
3859 			}
3860 		}
3861 
3862 		if ( !bFound )
3863 		{
3864             nEntryPos = pBox->InsertEntry( String( cBracket ) );
3865 			pBox->SelectEntryPos( nEntryPos );
3866 		}
3867 	}
3868     if( bStart )
3869         m_nStartBracketPosition = nEntryPos;
3870     else
3871         m_nEndBracketPosition = nEntryPos;
3872 }
3873 
3874 // -----------------------------------------------------------------------
3875 
3876 IMPL_LINK( SvxCharTwoLinesPage, TwoLinesHdl_Impl, CheckBox*, EMPTYARG )
3877 {
3878 	sal_Bool bChecked = m_aTwoLinesBtn.IsChecked();
3879 	m_aStartBracketFT.Enable( bChecked );
3880 	m_aStartBracketLB.Enable( bChecked );
3881 	m_aEndBracketFT.Enable( bChecked );
3882 	m_aEndBracketLB.Enable( bChecked );
3883 
3884 	UpdatePreview_Impl();
3885 	return 0;
3886 }
3887 
3888 // -----------------------------------------------------------------------
3889 
3890 IMPL_LINK( SvxCharTwoLinesPage, CharacterMapHdl_Impl, ListBox*, pBox )
3891 {
3892 	sal_uInt16 nPos = pBox->GetSelectEntryPos();
3893 	if ( CHRDLG_ENCLOSE_SPECIAL_CHAR == (sal_uLong)pBox->GetEntryData( nPos ) )
3894 		SelectCharacter( pBox );
3895     else
3896     {
3897         bool bStart = pBox == &m_aStartBracketLB;
3898         if( bStart )
3899             m_nStartBracketPosition = nPos;
3900         else
3901             m_nEndBracketPosition = nPos;
3902     }
3903 	UpdatePreview_Impl();
3904 	return 0;
3905 }
3906 
3907 // -----------------------------------------------------------------------
3908 
3909 void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
3910 {
3911 	SvxCharBasePage::ActivatePage( rSet );
3912 }
3913 
3914 // -----------------------------------------------------------------------
3915 
3916 int SvxCharTwoLinesPage::DeactivatePage( SfxItemSet* _pSet )
3917 {
3918     if ( _pSet )
3919         FillItemSet( *_pSet );
3920 	return LEAVE_PAGE;
3921 }
3922 
3923 // -----------------------------------------------------------------------
3924 
3925 SfxTabPage* SvxCharTwoLinesPage::Create( Window* pParent, const SfxItemSet& rSet )
3926 {
3927 	return new SvxCharTwoLinesPage( pParent, rSet );
3928 }
3929 
3930 // -----------------------------------------------------------------------
3931 
3932 sal_uInt16* SvxCharTwoLinesPage::GetRanges()
3933 {
3934 	return pTwoLinesRanges;
3935 }
3936 
3937 // -----------------------------------------------------------------------
3938 
3939 void SvxCharTwoLinesPage::Reset( const SfxItemSet& rSet )
3940 {
3941 	m_aTwoLinesBtn.Check( sal_False );
3942 	sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
3943 	SfxItemState eState = rSet.GetItemState( nWhich );
3944 
3945 	if ( eState >= SFX_ITEM_DONTCARE )
3946 	{
3947 		const SvxTwoLinesItem& rItem = (SvxTwoLinesItem&)rSet.Get( nWhich );
3948 		m_aTwoLinesBtn.Check( rItem.GetValue() );
3949 
3950 		if ( rItem.GetValue() )
3951 		{
3952 			SetBracket( rItem.GetStartBracket(), sal_True );
3953 			SetBracket( rItem.GetEndBracket(), sal_False );
3954 		}
3955 	}
3956 	TwoLinesHdl_Impl( NULL );
3957 
3958 	SetPrevFontWidthScale( rSet );
3959 }
3960 
3961 // -----------------------------------------------------------------------
3962 
3963 sal_Bool SvxCharTwoLinesPage::FillItemSet( SfxItemSet& rSet )
3964 {
3965 	const SfxItemSet& rOldSet = GetItemSet();
3966 	sal_Bool bModified = sal_False, bChanged = sal_True;
3967 	sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
3968 	const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_CHAR_TWO_LINES );
3969 	sal_Bool bOn = m_aTwoLinesBtn.IsChecked();
3970 	sal_Unicode cStart = ( bOn && m_aStartBracketLB.GetSelectEntryPos() > 0 )
3971 		? m_aStartBracketLB.GetSelectEntry().GetChar(0) : 0;
3972 	sal_Unicode cEnd = ( bOn && m_aEndBracketLB.GetSelectEntryPos() > 0 )
3973 		? m_aEndBracketLB.GetSelectEntry().GetChar(0) : 0;
3974 
3975 	if ( pOld )
3976 	{
3977 		const SvxTwoLinesItem& rItem = *( (const SvxTwoLinesItem*)pOld );
3978 		if ( rItem.GetValue() ==  bOn &&
3979 			 ( !bOn || ( rItem.GetStartBracket() == cStart && rItem.GetEndBracket() == cEnd ) ) )
3980 			bChanged = sal_False;
3981 	}
3982 
3983 	if ( bChanged )
3984 	{
3985 		rSet.Put( SvxTwoLinesItem( bOn, cStart, cEnd, nWhich ) );
3986 		bModified |= sal_True;
3987 	}
3988 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
3989 		CLEARTITEM;
3990 
3991 	return bModified;
3992 }
3993 /* -----------------------------04.12.00 09:48--------------------------------
3994 
3995  ---------------------------------------------------------------------------*/
3996 void	SvxCharTwoLinesPage::UpdatePreview_Impl()
3997 {
3998 	sal_Unicode cStart = m_aStartBracketLB.GetSelectEntryPos() > 0
3999 		? m_aStartBracketLB.GetSelectEntry().GetChar(0) : 0;
4000 	sal_Unicode cEnd = m_aEndBracketLB.GetSelectEntryPos() > 0
4001 		? m_aEndBracketLB.GetSelectEntry().GetChar(0) : 0;
4002 	m_aPreviewWin.SetBrackets(cStart, cEnd);
4003 	m_aPreviewWin.SetTwoLines(m_aTwoLinesBtn.IsChecked());
4004     m_aPreviewWin.Invalidate();
4005 }
4006 // -----------------------------------------------------------------------
4007 void SvxCharTwoLinesPage::SetPreviewBackgroundToCharacter()
4008 {
4009     m_bPreviewBackgroundToCharacter = sal_True;
4010 }
4011 
4012 // -----------------------------------------------------------------------
4013 void SvxCharTwoLinesPage::PageCreated (SfxAllItemSet aSet) //add CHINA001
4014 {
4015 	SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False);
4016 	if (pFlagItem)
4017 	{
4018 		sal_uInt32 nFlags=pFlagItem->GetValue();
4019 		if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
4020 			SetPreviewBackgroundToCharacter();
4021 	}
4022 }
4023