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