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