xref: /AOO41X/main/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx (revision 3fca590b7b1a80e862fbaee3892e4f6dc6633ed3)
1766ce4d0SZheng Fan /**************************************************************
2766ce4d0SZheng Fan  *
3766ce4d0SZheng Fan  * Licensed to the Apache Software Foundation (ASF) under one
4766ce4d0SZheng Fan  * or more contributor license agreements.  See the NOTICE file
5766ce4d0SZheng Fan  * distributed with this work for additional information
6766ce4d0SZheng Fan  * regarding copyright ownership.  The ASF licenses this file
7766ce4d0SZheng Fan  * to you under the Apache License, Version 2.0 (the
8766ce4d0SZheng Fan  * "License"); you may not use this file except in compliance
9766ce4d0SZheng Fan  * with the License.  You may obtain a copy of the License at
10766ce4d0SZheng Fan  *
11766ce4d0SZheng Fan  *   http://www.apache.org/licenses/LICENSE-2.0
12766ce4d0SZheng Fan  *
13766ce4d0SZheng Fan  * Unless required by applicable law or agreed to in writing,
14766ce4d0SZheng Fan  * software distributed under the License is distributed on an
15766ce4d0SZheng Fan  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16766ce4d0SZheng Fan  * KIND, either express or implied.  See the License for the
17766ce4d0SZheng Fan  * specific language governing permissions and limitations
18766ce4d0SZheng Fan  * under the License.
19766ce4d0SZheng Fan  *
20766ce4d0SZheng Fan  *************************************************************/
21766ce4d0SZheng Fan 
22766ce4d0SZheng Fan #include "precompiled_svx.hxx"
23766ce4d0SZheng Fan #include "ParaLineSpacingControl.hxx"
24766ce4d0SZheng Fan #include "ParaPropertyPanel.hrc"
25d29c2fc2SAndre Fischer #include <sfx2/sidebar/ResourceDefinitions.hrc>
26766ce4d0SZheng Fan #include <svx/dialogs.hrc>
27766ce4d0SZheng Fan #include <svx/dialmgr.hxx>
28766ce4d0SZheng Fan #include <unotools/viewoptions.hxx>
29766ce4d0SZheng Fan #include <editeng/kernitem.hxx>
30766ce4d0SZheng Fan #include <sfx2/bindings.hxx>
31766ce4d0SZheng Fan #include <sfx2/dispatch.hxx>
32766ce4d0SZheng Fan #include <sfx2/sidebar/Theme.hxx>
33766ce4d0SZheng Fan #include <svtools/unitconv.hxx>
34766ce4d0SZheng Fan 
35766ce4d0SZheng Fan #define _DEFAULT_LINE_SPACING  200
36766ce4d0SZheng Fan #define FIX_DIST_DEF           283
37766ce4d0SZheng Fan #define LINESPACE_1            100
38766ce4d0SZheng Fan #define LINESPACE_15           150
39766ce4d0SZheng Fan #define LINESPACE_2            200
40766ce4d0SZheng Fan #define LINESPACE_115          115
41766ce4d0SZheng Fan 
42766ce4d0SZheng Fan #define LLINESPACE_1          0
43766ce4d0SZheng Fan #define LLINESPACE_15         1
44766ce4d0SZheng Fan #define LLINESPACE_2          2
45766ce4d0SZheng Fan #define LLINESPACE_PROP       3
46766ce4d0SZheng Fan #define LLINESPACE_MIN        4
47766ce4d0SZheng Fan #define LLINESPACE_DURCH      5
48766ce4d0SZheng Fan #define LLINESPACE_FIX        6
49766ce4d0SZheng Fan 
50766ce4d0SZheng Fan #define DO_NOT_CUSTOM          0
51766ce4d0SZheng Fan #define USE_CUSTOM             1
52766ce4d0SZheng Fan 
53766ce4d0SZheng Fan namespace svx { namespace sidebar {
54766ce4d0SZheng Fan 
55766ce4d0SZheng Fan 
56766ce4d0SZheng Fan ParaLineSpacingControl::ParaLineSpacingControl(Window* pParent, svx::sidebar::ParaPropertyPanel& rPanel)
57766ce4d0SZheng Fan :	PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_LINESPACING))
58766ce4d0SZheng Fan ,	mrParaPropertyPanel(rPanel)
59766ce4d0SZheng Fan ,	mpBindings(NULL)
60766ce4d0SZheng Fan ,aLineDist				( this, SVX_RES( LB_LINE_SPACING )),
61766ce4d0SZheng Fan aLineDistAtPercentBox	( this, SVX_RES( ED_SBINDE_LINEDISTPERCENT ) ),
62766ce4d0SZheng Fan aLineDistAtMetricBox	( this, SVX_RES( ED_SBINDE_LINEDISTPOINT ) ),
63766ce4d0SZheng Fan maCustomFT        ( this, SVX_RES( FT_CUSTOM ) ),
64766ce4d0SZheng Fan maLSpacingFT      ( this, SVX_RES( FT_LINE_SPACING ) ),
65766ce4d0SZheng Fan maOfFT            ( this, SVX_RES( FT_OF ) ),
66766ce4d0SZheng Fan maSpacing1       (SVX_RES(IMG_SPACING1)),
67766ce4d0SZheng Fan maSpacing115     (SVX_RES(IMG_SPACING115)),
68766ce4d0SZheng Fan maSpacing15      (SVX_RES(IMG_SPACING15)),
69766ce4d0SZheng Fan maSpacing2       (SVX_RES(IMG_SPACING2)),
70766ce4d0SZheng Fan maSelSpacing1    (SVX_RES(IMG_SEL_SPACING1)),
71766ce4d0SZheng Fan maSelSpacing115  (SVX_RES(IMG_SEL_SPACING115)),
72766ce4d0SZheng Fan maSelSpacing15   (SVX_RES(IMG_SEL_SPACING15)),
73766ce4d0SZheng Fan maSelSpacing2    (SVX_RES(IMG_SEL_SPACING2)),
74766ce4d0SZheng Fan maImgCusGrey	 (SVX_RES(IMG_CUSTOM_GRAY)),
75766ce4d0SZheng Fan maImgCus		 (SVX_RES(IMG_CUSTOM)),
76766ce4d0SZheng Fan maStrCus		 (SVX_RES(STR_LCVALUE)),
77766ce4d0SZheng Fan pActLineDistFld 		( &aLineDistAtPercentBox ),
78766ce4d0SZheng Fan nMinFixDist			    ( BEGIN_VALUE ),
79766ce4d0SZheng Fan maValue                 ( 0 ),
80766ce4d0SZheng Fan maPos                   ( 0 ),
81766ce4d0SZheng Fan maLineSpacing		(ValueSetWithTextControl::IMAGE_TEXT,this, SVX_RES( LINE_SPACING ) ),
82766ce4d0SZheng Fan mpImg			(NULL),
83766ce4d0SZheng Fan mpImgSel		(NULL),
84766ce4d0SZheng Fan mpStr			(NULL),
85766ce4d0SZheng Fan mpStrTip		(NULL),
86766ce4d0SZheng Fan maLine			(SVX_RES(STR_LSPACING)),
87766ce4d0SZheng Fan maOf			(SVX_RES(STR_LS_OF))
88766ce4d0SZheng Fan , mbUseLineSPCustom             (0)
89766ce4d0SZheng Fan , mbLineSPDisable               (0)
90766ce4d0SZheng Fan {
91766ce4d0SZheng Fan 	initial();
92766ce4d0SZheng Fan 	FreeResource();
93766ce4d0SZheng Fan 	mpBindings = mrParaPropertyPanel.GetBindings();
94766ce4d0SZheng Fan //	m_eLNSpaceUnit = mrParaPropertyPanel.maLNSpaceControl.GetCoreMetric();
95766ce4d0SZheng Fan 	m_eLNSpaceUnit = SFX_MAPUNIT_100TH_MM;
96766ce4d0SZheng Fan }
97766ce4d0SZheng Fan ParaLineSpacingControl::~ParaLineSpacingControl()
98766ce4d0SZheng Fan {
99766ce4d0SZheng Fan 	delete[] mpImg;
100766ce4d0SZheng Fan 	delete[] mpImgSel;
101766ce4d0SZheng Fan 	delete[] mpStr;
102766ce4d0SZheng Fan 	delete[] mpStrTip;
103766ce4d0SZheng Fan }
104766ce4d0SZheng Fan 
105766ce4d0SZheng Fan void ParaLineSpacingControl::initial()
106766ce4d0SZheng Fan {
107*3fca590bSOliver-Rainer Wittmann     maLineSpacing.SetStyle( maLineSpacing.GetStyle()| WB_3DLOOK |  WB_NO_DIRECTSELECT  );
108766ce4d0SZheng Fan 
109*3fca590bSOliver-Rainer Wittmann     maLineSpacing.SetControlBackground(
110*3fca590bSOliver-Rainer Wittmann         GetSettings().GetStyleSettings().GetHighContrastMode()
111*3fca590bSOliver-Rainer Wittmann         ? GetSettings().GetStyleSettings().GetMenuColor()
112*3fca590bSOliver-Rainer Wittmann         : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
113*3fca590bSOliver-Rainer Wittmann     maLineSpacing.SetColor(
114*3fca590bSOliver-Rainer Wittmann         GetSettings().GetStyleSettings().GetHighContrastMode()
115*3fca590bSOliver-Rainer Wittmann         ? GetSettings().GetStyleSettings().GetMenuColor()
116*3fca590bSOliver-Rainer Wittmann         : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
117*3fca590bSOliver-Rainer Wittmann     maLineSpacing.SetBackground(
118*3fca590bSOliver-Rainer Wittmann         GetSettings().GetStyleSettings().GetHighContrastMode()
119*3fca590bSOliver-Rainer Wittmann         ? GetSettings().GetStyleSettings().GetMenuColor()
120*3fca590bSOliver-Rainer Wittmann         : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
121766ce4d0SZheng Fan 
122766ce4d0SZheng Fan     mpImg = new Image[4];
123766ce4d0SZheng Fan     mpImg[0] = maSpacing1;
124766ce4d0SZheng Fan     mpImg[1] = maSpacing115;
125766ce4d0SZheng Fan     mpImg[2] = maSpacing15;
126766ce4d0SZheng Fan     mpImg[3] = maSpacing2;
127766ce4d0SZheng Fan 
128766ce4d0SZheng Fan     mpImgSel = new Image[4];
129766ce4d0SZheng Fan     mpImgSel[0] = maSelSpacing1;
130766ce4d0SZheng Fan     mpImgSel[1] = maSelSpacing115;
131766ce4d0SZheng Fan     mpImgSel[2] = maSelSpacing15;
132766ce4d0SZheng Fan     mpImgSel[3] = maSelSpacing2;
133766ce4d0SZheng Fan 
134766ce4d0SZheng Fan     mpStr = new XubString[4];
135766ce4d0SZheng Fan     mpStr[0] = XubString(SVX_RES(STR_SPACING1));
136766ce4d0SZheng Fan     mpStr[1] = XubString(SVX_RES(STR_SPACING115));
137766ce4d0SZheng Fan     mpStr[2] = XubString(SVX_RES(STR_SPACING15));
138766ce4d0SZheng Fan     mpStr[3] = XubString(SVX_RES(STR_SPACING2));
139766ce4d0SZheng Fan 
140766ce4d0SZheng Fan     mpStrTip = new XubString[4];
141766ce4d0SZheng Fan     mpStrTip[0] = XubString(SVX_RES(STR_LS_SINGLE));
142766ce4d0SZheng Fan     mpStrTip[1] = XubString(SVX_RES(STR_LS_115));
143766ce4d0SZheng Fan     mpStrTip[2] = XubString(SVX_RES(STR_LS_15));
144766ce4d0SZheng Fan     mpStrTip[3] = XubString(SVX_RES(STR_LS_DOUBLE));
145766ce4d0SZheng Fan     for (int i=0;i<4;i++)
146766ce4d0SZheng Fan         maLineSpacing.AddItem(mpImg[i], &mpImgSel[i],mpStr[i],&mpStrTip[i]);
147766ce4d0SZheng Fan 
148c1757099SZheng Fan     maLineSpacing.AddItem( maImgCus, 0, maStrCus, 0 );
149766ce4d0SZheng Fan 
150766ce4d0SZheng Fan     SetAllNoSel();
151766ce4d0SZheng Fan     Link aLink = LINK(this, ParaLineSpacingControl,VSSelHdl );
152766ce4d0SZheng Fan     maLineSpacing.SetSelectHdl(aLink);
153766ce4d0SZheng Fan     maLineSpacing.StartSelection();
154766ce4d0SZheng Fan     maLineSpacing.Show();
155766ce4d0SZheng Fan 
156766ce4d0SZheng Fan     aLink = LINK( this, ParaLineSpacingControl, LineSPDistHdl_Impl );
157766ce4d0SZheng Fan     aLineDist.SetSelectHdl(aLink);
158766ce4d0SZheng Fan     aLineDist.SelectEntryPos( LLINESPACE_1 ) ;
159766ce4d0SZheng Fan     aLink = LINK( this, ParaLineSpacingControl, LineSPDistAtHdl_Impl );
160766ce4d0SZheng Fan     aLineDistAtPercentBox.SetModifyHdl( aLink );
161766ce4d0SZheng Fan     aLineDistAtMetricBox.SetModifyHdl( aLink );
162766ce4d0SZheng Fan }
163*3fca590bSOliver-Rainer Wittmann 
164766ce4d0SZheng Fan 
165766ce4d0SZheng Fan void ParaLineSpacingControl::PopupModeEndCallback()
166766ce4d0SZheng Fan {
167766ce4d0SZheng Fan 	if( mbUseLineSPCustom )
168766ce4d0SZheng Fan 	{
169766ce4d0SZheng Fan 		//maLinePos = mpLineSPPage->maPos;
170766ce4d0SZheng Fan 	    //maLineValue = mpLineSPPage->maValue;
171766ce4d0SZheng Fan 
172766ce4d0SZheng Fan 		SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE );
173766ce4d0SZheng Fan 		::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
174766ce4d0SZheng Fan 		aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("maLinePos") );
175766ce4d0SZheng Fan 		aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( maPos ));
176766ce4d0SZheng Fan 		aWinOpt.SetUserData( aSeq );
177766ce4d0SZheng Fan 
178766ce4d0SZheng Fan 		SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE );
179766ce4d0SZheng Fan 		aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("maLineValue") );
180766ce4d0SZheng Fan 		aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( maValue ));
181766ce4d0SZheng Fan 		aWinOpt2.SetUserData( aSeq );
182766ce4d0SZheng Fan 	}
183766ce4d0SZheng Fan }
184766ce4d0SZheng Fan 
185766ce4d0SZheng Fan void ParaLineSpacingControl::Rearrange(SfxItemState currSPState,FieldUnit currMetricUnit,SvxLineSpacingItem* currSPItem,const ::sfx2::sidebar::EnumContext currentContext)
186766ce4d0SZheng Fan {
187766ce4d0SZheng Fan 	SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE );
188766ce4d0SZheng Fan     if ( aWinOpt.Exists() )
189766ce4d0SZheng Fan 	{
190766ce4d0SZheng Fan 		::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData();
191766ce4d0SZheng Fan 		::rtl::OUString aTmp;
192766ce4d0SZheng Fan 		if ( aSeq.getLength())
193766ce4d0SZheng Fan 			aSeq[0].Value >>= aTmp;
194766ce4d0SZheng Fan 
195766ce4d0SZheng Fan 		String aWinData( aTmp );
196766ce4d0SZheng Fan 		maPos = (sal_uInt16)aWinData.ToInt32();
197766ce4d0SZheng Fan 	}
198766ce4d0SZheng Fan 
199766ce4d0SZheng Fan 	SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE );
200766ce4d0SZheng Fan     if ( aWinOpt2.Exists() )
201766ce4d0SZheng Fan 	{
202766ce4d0SZheng Fan 		::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt2.GetUserData();
203766ce4d0SZheng Fan 		::rtl::OUString aTmp;
204766ce4d0SZheng Fan 		if ( aSeq.getLength())
205766ce4d0SZheng Fan 			aSeq[0].Value >>= aTmp;
206766ce4d0SZheng Fan 
207766ce4d0SZheng Fan 		String aWinData( aTmp );
208766ce4d0SZheng Fan 		maValue = (sal_uInt16)aWinData.ToInt32();
209766ce4d0SZheng Fan 	}
210766ce4d0SZheng Fan 	String sHelpText;
211766ce4d0SZheng Fan 	switch(maPos)
212766ce4d0SZheng Fan 	{
213766ce4d0SZheng Fan 		case LLINESPACE_1:
214766ce4d0SZheng Fan 			sHelpText += mpStrTip[0];
215766ce4d0SZheng Fan 			break;
216766ce4d0SZheng Fan 		case LLINESPACE_15:
217766ce4d0SZheng Fan 			sHelpText += mpStrTip[2];
218766ce4d0SZheng Fan 			break;
219766ce4d0SZheng Fan 		case LLINESPACE_2:
220766ce4d0SZheng Fan 			sHelpText += mpStrTip[3];
221766ce4d0SZheng Fan 			break;
222766ce4d0SZheng Fan 		case LLINESPACE_PROP:
223766ce4d0SZheng Fan 			sHelpText +=maLine;
224766ce4d0SZheng Fan 			sHelpText.Append(String("Proportion: ", 12, RTL_TEXTENCODING_ASCII_US));
225766ce4d0SZheng Fan 			sHelpText += maOf;
226766ce4d0SZheng Fan 			sHelpText.Append( String::CreateFromInt64( maValue ));
227766ce4d0SZheng Fan 			break;
228766ce4d0SZheng Fan 		case LLINESPACE_MIN:
229766ce4d0SZheng Fan 			sHelpText += maLine;
230766ce4d0SZheng Fan 			sHelpText.Append(String("At Least: ", 10, RTL_TEXTENCODING_ASCII_US));
231766ce4d0SZheng Fan 			sHelpText += maOf;
232766ce4d0SZheng Fan 			sHelpText.Append( String::CreateFromInt64( maValue ));
233766ce4d0SZheng Fan 			break;
234766ce4d0SZheng Fan 		case LLINESPACE_DURCH:
235766ce4d0SZheng Fan 			sHelpText += maLine;
236766ce4d0SZheng Fan 			sHelpText.Append(String("Leading: ", 9, RTL_TEXTENCODING_ASCII_US));
237766ce4d0SZheng Fan 			sHelpText += maOf;
238766ce4d0SZheng Fan 			sHelpText.Append( String::CreateFromInt64( maValue ));
239766ce4d0SZheng Fan 			break;
240766ce4d0SZheng Fan 		case LLINESPACE_FIX:
241766ce4d0SZheng Fan 			sHelpText += maLine;
242766ce4d0SZheng Fan 			sHelpText.Append(String("Fixed: ", 7, RTL_TEXTENCODING_ASCII_US));
243766ce4d0SZheng Fan 			sHelpText += maOf;
244766ce4d0SZheng Fan 			sHelpText.Append( String::CreateFromInt64( maValue ));
245766ce4d0SZheng Fan 			break;
246766ce4d0SZheng Fan 	}
247766ce4d0SZheng Fan 	if( !aWinOpt.Exists() && !aWinOpt2.Exists() )
248766ce4d0SZheng Fan 		mbLineSPDisable = sal_True;
249766ce4d0SZheng Fan 	else
250766ce4d0SZheng Fan 		mbLineSPDisable = sal_False;
251766ce4d0SZheng Fan 
252766ce4d0SZheng Fan 	if( mbLineSPDisable )
253c1757099SZheng Fan 		maLineSpacing.ReplaceItemImages(5, maImgCusGrey,0);
254766ce4d0SZheng Fan 	else
255766ce4d0SZheng Fan 	{
256c1757099SZheng Fan 		maLineSpacing.ReplaceItemImages(5, maImgCus,0);
257c1757099SZheng Fan 		maLineSpacing.SetItemText(5,sHelpText);
258766ce4d0SZheng Fan 	}
259766ce4d0SZheng Fan 
260766ce4d0SZheng Fan 	SfxItemState eState = currSPState;
261766ce4d0SZheng Fan 
262766ce4d0SZheng Fan 	SetFieldUnit( aLineDistAtMetricBox, currMetricUnit );
263766ce4d0SZheng Fan 
264766ce4d0SZheng Fan //	mpLineSPPage->SetAllNoSel();
265766ce4d0SZheng Fan 	aLineDist.Enable();
266766ce4d0SZheng Fan 	pActLineDistFld->Enable();
267766ce4d0SZheng Fan 	pActLineDistFld->SetText( String() );
268766ce4d0SZheng Fan 	bool bValueSetFocus = sal_False;		//wj
269766ce4d0SZheng Fan 
270766ce4d0SZheng Fan 	if( eState >= SFX_ITEM_AVAILABLE )
271766ce4d0SZheng Fan 	{
272766ce4d0SZheng Fan 	//	SfxMapUnit eUnit = maLNSpaceControl.GetCoreMetric();
273766ce4d0SZheng Fan 		SfxMapUnit eUnit = SFX_MAPUNIT_100TH_MM;
274766ce4d0SZheng Fan 		m_eLNSpaceUnit = eUnit;
275766ce4d0SZheng Fan 
276766ce4d0SZheng Fan 		switch( currSPItem->GetLineSpaceRule() )
277766ce4d0SZheng Fan 		{
278766ce4d0SZheng Fan 		case SVX_LINE_SPACE_AUTO:
279766ce4d0SZheng Fan 			{
280766ce4d0SZheng Fan 				SvxInterLineSpace eInter = currSPItem->GetInterLineSpaceRule();
281766ce4d0SZheng Fan 
282766ce4d0SZheng Fan 				switch( eInter )
283766ce4d0SZheng Fan 				{
284766ce4d0SZheng Fan 				case SVX_INTER_LINE_SPACE_OFF:
285766ce4d0SZheng Fan 					{
286766ce4d0SZheng Fan 						aLineDist.SelectEntryPos( LLINESPACE_1 );
287766ce4d0SZheng Fan 						pActLineDistFld->Disable();
288766ce4d0SZheng Fan 						pActLineDistFld->SetText( String() );
289766ce4d0SZheng Fan 						mbUseLineSPCustom = DO_NOT_CUSTOM;
290766ce4d0SZheng Fan 						if ( LINESPACE_1 == currSPItem->GetPropLineSpace() )
291766ce4d0SZheng Fan 						{
292c1757099SZheng Fan 							maLineSpacing.SelectItem(1);
293766ce4d0SZheng Fan 							bValueSetFocus = sal_True;	//wj
294766ce4d0SZheng Fan 						}
295766ce4d0SZheng Fan 					}
296766ce4d0SZheng Fan 					break;
297766ce4d0SZheng Fan 
298766ce4d0SZheng Fan 				case SVX_INTER_LINE_SPACE_PROP:
299766ce4d0SZheng Fan 					{
300766ce4d0SZheng Fan 						if ( LINESPACE_1 == currSPItem->GetPropLineSpace() )
301766ce4d0SZheng Fan 						{
302766ce4d0SZheng Fan 							aLineDist.SelectEntryPos( LLINESPACE_1 );
303766ce4d0SZheng Fan 							pActLineDistFld->Disable();
304766ce4d0SZheng Fan 							pActLineDistFld->SetText( String() );
305766ce4d0SZheng Fan 							mbUseLineSPCustom = DO_NOT_CUSTOM;
306c1757099SZheng Fan 							maLineSpacing.SelectItem(1);
307766ce4d0SZheng Fan 							bValueSetFocus = sal_True;	//wj
308766ce4d0SZheng Fan 							break;
309766ce4d0SZheng Fan 						}
310766ce4d0SZheng Fan 						if ( LINESPACE_15 == currSPItem->GetPropLineSpace() )
311766ce4d0SZheng Fan 						{
312766ce4d0SZheng Fan 							aLineDist.SelectEntryPos( LLINESPACE_15 );
313766ce4d0SZheng Fan 							pActLineDistFld->Disable();
314766ce4d0SZheng Fan 							pActLineDistFld->SetText( String() );
315766ce4d0SZheng Fan 
316766ce4d0SZheng Fan 							mbUseLineSPCustom = DO_NOT_CUSTOM;
317c1757099SZheng Fan 							maLineSpacing.SelectItem(3);
318766ce4d0SZheng Fan 							bValueSetFocus = sal_True;	//wj
319766ce4d0SZheng Fan 							break;
320766ce4d0SZheng Fan 						}
321766ce4d0SZheng Fan 						if ( LINESPACE_2 == currSPItem->GetPropLineSpace() )
322766ce4d0SZheng Fan 						{
323766ce4d0SZheng Fan 							aLineDist.SelectEntryPos( LLINESPACE_2 );
324766ce4d0SZheng Fan 							pActLineDistFld->Disable();
325766ce4d0SZheng Fan 							pActLineDistFld->SetText( String() );
326766ce4d0SZheng Fan 
327766ce4d0SZheng Fan 							mbUseLineSPCustom = DO_NOT_CUSTOM;
328c1757099SZheng Fan 							maLineSpacing.SelectItem(4);
329766ce4d0SZheng Fan 							bValueSetFocus = sal_True;	//wj
330766ce4d0SZheng Fan 							break;
331766ce4d0SZheng Fan 						}
332766ce4d0SZheng Fan 
333766ce4d0SZheng Fan 						aLineDist.SelectEntryPos( LLINESPACE_PROP );
334766ce4d0SZheng Fan 						if(pActLineDistFld != &(aLineDistAtPercentBox))
335766ce4d0SZheng Fan 						{
336766ce4d0SZheng Fan 							pActLineDistFld->Disable();
337766ce4d0SZheng Fan 							pActLineDistFld->Hide();
338766ce4d0SZheng Fan 							pActLineDistFld = &(aLineDistAtPercentBox);
339766ce4d0SZheng Fan 						}
340766ce4d0SZheng Fan 						else
341766ce4d0SZheng Fan 						{
342766ce4d0SZheng Fan 							pActLineDistFld = &(aLineDistAtMetricBox);
343766ce4d0SZheng Fan 							pActLineDistFld->Disable();
344766ce4d0SZheng Fan 							pActLineDistFld->Hide();
345766ce4d0SZheng Fan 							pActLineDistFld = &(aLineDistAtPercentBox);
346766ce4d0SZheng Fan 						}
347766ce4d0SZheng Fan 						pActLineDistFld->Enable();
348766ce4d0SZheng Fan 						pActLineDistFld->Show();
349766ce4d0SZheng Fan 						aLineDistAtPercentBox.
350766ce4d0SZheng Fan 							SetValue( aLineDistAtPercentBox.Normalize(
351766ce4d0SZheng Fan 							currSPItem->GetPropLineSpace() ) );
352766ce4d0SZheng Fan 
353766ce4d0SZheng Fan 						if( currSPItem->GetPropLineSpace() == LINESPACE_115 )
354766ce4d0SZheng Fan 						{
355766ce4d0SZheng Fan 							mbUseLineSPCustom = DO_NOT_CUSTOM;
356c1757099SZheng Fan 							maLineSpacing.SelectItem(2);
357766ce4d0SZheng Fan 							bValueSetFocus = sal_True;	//wj
358766ce4d0SZheng Fan 						}
359766ce4d0SZheng Fan 						else
360766ce4d0SZheng Fan 						{
361766ce4d0SZheng Fan 							mbUseLineSPCustom = USE_CUSTOM;
362c1757099SZheng Fan 							maLineSpacing.SetNoSelection();
363c1757099SZheng Fan                                                  maLineSpacing.SelectItem(0);
364766ce4d0SZheng Fan 						}
365766ce4d0SZheng Fan 					}
366766ce4d0SZheng Fan 					break;
367766ce4d0SZheng Fan 
368766ce4d0SZheng Fan 				case SVX_INTER_LINE_SPACE_FIX:
369766ce4d0SZheng Fan 					{
370766ce4d0SZheng Fan 						if(pActLineDistFld != &(aLineDistAtMetricBox))
371766ce4d0SZheng Fan 						{
372766ce4d0SZheng Fan 							pActLineDistFld->Disable();
373766ce4d0SZheng Fan 							pActLineDistFld->Hide();
374766ce4d0SZheng Fan 							pActLineDistFld = &(aLineDistAtMetricBox);
375766ce4d0SZheng Fan 						}
376766ce4d0SZheng Fan 						else
377766ce4d0SZheng Fan 						{
378766ce4d0SZheng Fan 							pActLineDistFld = &(aLineDistAtPercentBox);
379766ce4d0SZheng Fan 							pActLineDistFld->Disable();
380766ce4d0SZheng Fan 							pActLineDistFld->Hide();
381766ce4d0SZheng Fan 							pActLineDistFld = &(aLineDistAtMetricBox);
382766ce4d0SZheng Fan 						}
383766ce4d0SZheng Fan 						pActLineDistFld->Enable();
384766ce4d0SZheng Fan 						pActLineDistFld->Show();
385c1757099SZheng Fan 						maLineSpacing.SetNoSelection();
386c1757099SZheng Fan                                           maLineSpacing.SelectItem(0);
387766ce4d0SZheng Fan 
388766ce4d0SZheng Fan 						SetMetricValue( aLineDistAtMetricBox,
389766ce4d0SZheng Fan 							currSPItem->GetInterLineSpace(), eUnit );
390766ce4d0SZheng Fan 						aLineDist.SelectEntryPos( LLINESPACE_DURCH );
391766ce4d0SZheng Fan 
392766ce4d0SZheng Fan 						mbUseLineSPCustom = USE_CUSTOM;
393766ce4d0SZheng Fan 					}
394766ce4d0SZheng Fan 					break;
395766ce4d0SZheng Fan 				}
396766ce4d0SZheng Fan 			}
397766ce4d0SZheng Fan 			break;
398766ce4d0SZheng Fan 		case SVX_LINE_SPACE_FIX:
399766ce4d0SZheng Fan 			{
400766ce4d0SZheng Fan 				if(pActLineDistFld != &(aLineDistAtMetricBox))
401766ce4d0SZheng Fan 				{
402766ce4d0SZheng Fan 					pActLineDistFld->Disable();
403766ce4d0SZheng Fan 					pActLineDistFld->Hide();
404766ce4d0SZheng Fan 					pActLineDistFld = &(aLineDistAtMetricBox);
405766ce4d0SZheng Fan 				}
406766ce4d0SZheng Fan 				else
407766ce4d0SZheng Fan 				{
408766ce4d0SZheng Fan 					pActLineDistFld = &(aLineDistAtPercentBox);
409766ce4d0SZheng Fan 					pActLineDistFld->Disable();
410766ce4d0SZheng Fan 					pActLineDistFld->Hide();
411766ce4d0SZheng Fan 					pActLineDistFld = &(aLineDistAtMetricBox);
412766ce4d0SZheng Fan 				}
413766ce4d0SZheng Fan 				pActLineDistFld->Enable();
414766ce4d0SZheng Fan 				pActLineDistFld->Show();
415c1757099SZheng Fan 				maLineSpacing.SetNoSelection();
416c1757099SZheng Fan                             maLineSpacing.SelectItem(0);
417766ce4d0SZheng Fan 
418766ce4d0SZheng Fan 				SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit);
419766ce4d0SZheng Fan 				aLineDist.SelectEntryPos( LLINESPACE_FIX );
420766ce4d0SZheng Fan 
421766ce4d0SZheng Fan 				mbUseLineSPCustom = USE_CUSTOM;
422766ce4d0SZheng Fan 			}
423766ce4d0SZheng Fan 			break;
424766ce4d0SZheng Fan 
425766ce4d0SZheng Fan 		case SVX_LINE_SPACE_MIN:
426766ce4d0SZheng Fan 			{
427766ce4d0SZheng Fan 				if(pActLineDistFld != &(aLineDistAtMetricBox))
428766ce4d0SZheng Fan 				{
429766ce4d0SZheng Fan 					pActLineDistFld->Disable();
430766ce4d0SZheng Fan 					pActLineDistFld->Hide();
431766ce4d0SZheng Fan 					pActLineDistFld = &(aLineDistAtMetricBox);
432766ce4d0SZheng Fan 				}
433766ce4d0SZheng Fan 				else
434766ce4d0SZheng Fan 				{
435766ce4d0SZheng Fan 					pActLineDistFld = &(aLineDistAtPercentBox);
436766ce4d0SZheng Fan 					pActLineDistFld->Disable();
437766ce4d0SZheng Fan 					pActLineDistFld->Hide();
438766ce4d0SZheng Fan 					pActLineDistFld = &(aLineDistAtMetricBox);
439766ce4d0SZheng Fan 				}
440766ce4d0SZheng Fan 				pActLineDistFld->Enable();
441766ce4d0SZheng Fan 				pActLineDistFld->Show();
442c1757099SZheng Fan 				maLineSpacing.SetNoSelection();
443c1757099SZheng Fan                             maLineSpacing.SelectItem(0);
444766ce4d0SZheng Fan 
445766ce4d0SZheng Fan 				SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit);
446766ce4d0SZheng Fan 				aLineDist.SelectEntryPos( LLINESPACE_MIN );
447766ce4d0SZheng Fan 				mbUseLineSPCustom = USE_CUSTOM;
448766ce4d0SZheng Fan 			}
449766ce4d0SZheng Fan 			break;
450766ce4d0SZheng Fan 		}
451766ce4d0SZheng Fan 	}
452766ce4d0SZheng Fan 	else if( eState == SFX_ITEM_DISABLED )
453766ce4d0SZheng Fan 	{
454766ce4d0SZheng Fan 		aLineDist.Disable();
455766ce4d0SZheng Fan 		pActLineDistFld->Enable(sal_False);
456766ce4d0SZheng Fan 		pActLineDistFld->SetText( String() );
457c1757099SZheng Fan 		maLineSpacing.SetNoSelection();
458c1757099SZheng Fan               maLineSpacing.SelectItem(0);
459766ce4d0SZheng Fan 
460766ce4d0SZheng Fan 	    mbUseLineSPCustom = DO_NOT_CUSTOM;
461766ce4d0SZheng Fan 	}
462766ce4d0SZheng Fan 	else
463766ce4d0SZheng Fan 	{
464766ce4d0SZheng Fan 		pActLineDistFld->Enable(sal_False);
465766ce4d0SZheng Fan 		pActLineDistFld->SetText( String() );
466766ce4d0SZheng Fan 		aLineDist.SetNoSelection();
467c1757099SZheng Fan 		maLineSpacing.SetNoSelection();
468c1757099SZheng Fan               maLineSpacing.SelectItem(0);
469766ce4d0SZheng Fan 		mbUseLineSPCustom = DO_NOT_CUSTOM;
470766ce4d0SZheng Fan 	}
471766ce4d0SZheng Fan 
472766ce4d0SZheng Fan 	aLineDist.SaveValue();
473766ce4d0SZheng Fan 
474766ce4d0SZheng Fan 	sal_uInt16 uCount = aLineDist.GetEntryCount();
475766ce4d0SZheng Fan 	if( uCount == LLINESPACE_FIX + 1 )
476766ce4d0SZheng Fan 	{
477766ce4d0SZheng Fan 		switch (currentContext.GetCombinedContext())
478766ce4d0SZheng Fan 		{
479766ce4d0SZheng Fan 			case CombinedEnumContext(Application_Impress, Context_Table):
480766ce4d0SZheng Fan         		case CombinedEnumContext(Application_Draw, Context_Table):
481766ce4d0SZheng Fan 			case CombinedEnumContext(Application_Writer, Context_DrawText):
482766ce4d0SZheng Fan 			case CombinedEnumContext(Application_Calc, Context_DrawText):
483766ce4d0SZheng Fan 			case CombinedEnumContext(Application_Draw, Context_DrawText):
484766ce4d0SZheng Fan         		case CombinedEnumContext(Application_Impress, Context_DrawText):
485766ce4d0SZheng Fan 			case CombinedEnumContext(Application_Writer, Context_Annotation):
486766ce4d0SZheng Fan 			case CombinedEnumContext(Application_Draw, Context_Draw):
487766ce4d0SZheng Fan 		        case CombinedEnumContext(Application_Draw, Context_TextObject):
488766ce4d0SZheng Fan 		        case CombinedEnumContext(Application_Draw, Context_Graphic):
489766ce4d0SZheng Fan 		        case CombinedEnumContext(Application_Impress, Context_Draw):
490766ce4d0SZheng Fan 		        case CombinedEnumContext(Application_Impress, Context_TextObject):
491766ce4d0SZheng Fan 		        case CombinedEnumContext(Application_Impress, Context_Graphic):
492766ce4d0SZheng Fan 			{
493766ce4d0SZheng Fan 				aLineDist.RemoveEntry(LLINESPACE_FIX);
494766ce4d0SZheng Fan 			}
495766ce4d0SZheng Fan 		}
496766ce4d0SZheng Fan 	}
497766ce4d0SZheng Fan 	else if( uCount == LLINESPACE_FIX)
498766ce4d0SZheng Fan 	{
499766ce4d0SZheng Fan 		switch (currentContext.GetCombinedContext())
500766ce4d0SZheng Fan 		{
501766ce4d0SZheng Fan 			case CombinedEnumContext(Application_Writer, Context_Default):
502766ce4d0SZheng Fan 			case CombinedEnumContext(Application_Writer, Context_Text):
503766ce4d0SZheng Fan 			case CombinedEnumContext(Application_Writer, Context_Table):
504766ce4d0SZheng Fan 			{
505766ce4d0SZheng Fan 				aLineDist.InsertEntry(String::CreateFromAscii("Fixed"), LLINESPACE_FIX);
506766ce4d0SZheng Fan 			}
507766ce4d0SZheng Fan 		}
508766ce4d0SZheng Fan 	}
509766ce4d0SZheng Fan 	maLineSpacing.Format();
510766ce4d0SZheng Fan 	maLineSpacing.StartSelection();
511766ce4d0SZheng Fan }
512766ce4d0SZheng Fan 
513766ce4d0SZheng Fan void ParaLineSpacingControl::SetAllNoSel()
514766ce4d0SZheng Fan {
515c1757099SZheng Fan 	maLineSpacing.SelectItem(1);
516766ce4d0SZheng Fan 	maLineSpacing.SetNoSelection();
517766ce4d0SZheng Fan }
518766ce4d0SZheng Fan 
519766ce4d0SZheng Fan IMPL_LINK( ParaLineSpacingControl, LineSPDistHdl_Impl, ListBox*, pBox )
520766ce4d0SZheng Fan {
521766ce4d0SZheng Fan 	maLineSpacing.SetNoSelection();
522c1757099SZheng Fan        maLineSpacing.SelectItem(0);
523766ce4d0SZheng Fan 	maLineSpacing.Format();
524766ce4d0SZheng Fan 	maLineSpacing.StartSelection();
525766ce4d0SZheng Fan 
526766ce4d0SZheng Fan 	switch( pBox->GetSelectEntryPos() )
527766ce4d0SZheng Fan 	{
528766ce4d0SZheng Fan 		case LLINESPACE_1:
529766ce4d0SZheng Fan 		case LLINESPACE_15:
530766ce4d0SZheng Fan 		case LLINESPACE_2:
531766ce4d0SZheng Fan 			pActLineDistFld->Enable(sal_False);
532766ce4d0SZheng Fan 			pActLineDistFld->SetText( String() );
533766ce4d0SZheng Fan 			break;
534766ce4d0SZheng Fan 
535766ce4d0SZheng Fan 		case LLINESPACE_DURCH:
536766ce4d0SZheng Fan 			aLineDistAtPercentBox.Hide();
537766ce4d0SZheng Fan 			pActLineDistFld = &aLineDistAtMetricBox;
538766ce4d0SZheng Fan 			aLineDistAtMetricBox.SetMin(0);
539766ce4d0SZheng Fan 
540766ce4d0SZheng Fan 
541766ce4d0SZheng Fan 			if ( !aLineDistAtMetricBox.GetText().Len() )
542766ce4d0SZheng Fan 				aLineDistAtMetricBox.SetValue(
543766ce4d0SZheng Fan 					aLineDistAtMetricBox.Normalize( 0 ) );
544766ce4d0SZheng Fan 			aLineDistAtPercentBox.Hide();
545766ce4d0SZheng Fan 			pActLineDistFld->Show();
546766ce4d0SZheng Fan 			pActLineDistFld->Enable();
547766ce4d0SZheng Fan 			break;
548766ce4d0SZheng Fan 
549766ce4d0SZheng Fan 		case LLINESPACE_MIN:
550766ce4d0SZheng Fan 			aLineDistAtPercentBox.Hide();
551766ce4d0SZheng Fan 			pActLineDistFld = &aLineDistAtMetricBox;
552766ce4d0SZheng Fan 			aLineDistAtMetricBox.SetMin(0);
553766ce4d0SZheng Fan 
554766ce4d0SZheng Fan 			if ( !aLineDistAtMetricBox.GetText().Len() )
555766ce4d0SZheng Fan 				aLineDistAtMetricBox.SetValue(
556766ce4d0SZheng Fan 					aLineDistAtMetricBox.Normalize( 0 ), FUNIT_TWIP );
557766ce4d0SZheng Fan 			aLineDistAtPercentBox.Hide();
558766ce4d0SZheng Fan 			pActLineDistFld->Show();
559766ce4d0SZheng Fan 			pActLineDistFld->Enable();
560766ce4d0SZheng Fan 			break;
561766ce4d0SZheng Fan 
562766ce4d0SZheng Fan 		case LLINESPACE_PROP:
563766ce4d0SZheng Fan 			aLineDistAtMetricBox.Hide();
564766ce4d0SZheng Fan 			pActLineDistFld = &aLineDistAtPercentBox;
565766ce4d0SZheng Fan 
566766ce4d0SZheng Fan 			if ( !aLineDistAtPercentBox.GetText().Len() )
567766ce4d0SZheng Fan 				aLineDistAtPercentBox.SetValue(
568766ce4d0SZheng Fan 					aLineDistAtPercentBox.Normalize( 100 ), FUNIT_TWIP );
569766ce4d0SZheng Fan 			aLineDistAtMetricBox.Hide();
570766ce4d0SZheng Fan 			pActLineDistFld->Show();
571766ce4d0SZheng Fan 			pActLineDistFld->Enable();
572766ce4d0SZheng Fan 			break;
573766ce4d0SZheng Fan 		case LLINESPACE_FIX:
574766ce4d0SZheng Fan 		{
575766ce4d0SZheng Fan 			aLineDistAtPercentBox.Hide();
576766ce4d0SZheng Fan 			pActLineDistFld = &aLineDistAtMetricBox;
577766ce4d0SZheng Fan 			sal_Int64 nTemp = aLineDistAtMetricBox.GetValue();
578766ce4d0SZheng Fan 			aLineDistAtMetricBox.SetMin(aLineDistAtMetricBox.Normalize(nMinFixDist), FUNIT_TWIP);
579766ce4d0SZheng Fan 
580766ce4d0SZheng Fan 			if ( aLineDistAtMetricBox.GetValue() != nTemp )
581766ce4d0SZheng Fan 				SetMetricValue( aLineDistAtMetricBox,
582766ce4d0SZheng Fan 									FIX_DIST_DEF, SFX_MAPUNIT_TWIP );
583766ce4d0SZheng Fan 			aLineDistAtPercentBox.Hide();
584766ce4d0SZheng Fan 			pActLineDistFld->Show();
585766ce4d0SZheng Fan 			pActLineDistFld->Enable();
586766ce4d0SZheng Fan 		}
587766ce4d0SZheng Fan 		break;
588766ce4d0SZheng Fan 	}
589766ce4d0SZheng Fan 	ExecuteLineSpace();
590766ce4d0SZheng Fan 	return 0;
591766ce4d0SZheng Fan }
592766ce4d0SZheng Fan 
5936870eca3SPavel Janík IMPL_LINK( ParaLineSpacingControl, LineSPDistAtHdl_Impl, MetricField*, /* pBox */ )
594766ce4d0SZheng Fan {
595766ce4d0SZheng Fan 	ExecuteLineSpace();
596766ce4d0SZheng Fan 	return (0L);
597766ce4d0SZheng Fan }
598766ce4d0SZheng Fan 
599766ce4d0SZheng Fan void ParaLineSpacingControl::ExecuteLineSpace()
600766ce4d0SZheng Fan {
601766ce4d0SZheng Fan 	aLineDist.SaveValue();
602766ce4d0SZheng Fan 	maLineSpacing.SetNoSelection();
603766ce4d0SZheng Fan 
604766ce4d0SZheng Fan 	SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE);
605766ce4d0SZheng Fan 	sal_uInt16 nPos = aLineDist.GetSelectEntryPos();
606766ce4d0SZheng Fan 
607766ce4d0SZheng Fan 	switch ( nPos )
608766ce4d0SZheng Fan 	{
609766ce4d0SZheng Fan 		case LLINESPACE_1:
610766ce4d0SZheng Fan 		case LLINESPACE_15:
611766ce4d0SZheng Fan 		case LLINESPACE_2:
612766ce4d0SZheng Fan 			{
613766ce4d0SZheng Fan 				SetLineSpace( aSpacing, nPos );
614766ce4d0SZheng Fan 				maPos = nPos;
615766ce4d0SZheng Fan 			}
616766ce4d0SZheng Fan 			break;
617766ce4d0SZheng Fan 
618766ce4d0SZheng Fan 		case LLINESPACE_PROP:
619766ce4d0SZheng Fan 			{
620766ce4d0SZheng Fan 				SetLineSpace( aSpacing, nPos,
621766ce4d0SZheng Fan 					aLineDistAtPercentBox.Denormalize(
622766ce4d0SZheng Fan 					(long)aLineDistAtPercentBox.GetValue() ) );
623766ce4d0SZheng Fan 				maPos = nPos;
624766ce4d0SZheng Fan 				maValue =aLineDistAtPercentBox.GetValue();
625766ce4d0SZheng Fan 			}
626766ce4d0SZheng Fan 			break;
627766ce4d0SZheng Fan 
628766ce4d0SZheng Fan 		case LLINESPACE_MIN:
629766ce4d0SZheng Fan 		case LLINESPACE_DURCH:
630766ce4d0SZheng Fan 		case LLINESPACE_FIX:
631766ce4d0SZheng Fan 			{
632766ce4d0SZheng Fan 				SetLineSpace( aSpacing, nPos,
633766ce4d0SZheng Fan 					GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ) );
634766ce4d0SZheng Fan 				maPos = nPos;
635766ce4d0SZheng Fan 				maValue = GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit );
636766ce4d0SZheng Fan 			}
637766ce4d0SZheng Fan 		break;
638766ce4d0SZheng Fan 
639766ce4d0SZheng Fan 		default:
640766ce4d0SZheng Fan 			DBG_ERROR( "error!!" );
641766ce4d0SZheng Fan 			break;
642766ce4d0SZheng Fan 	}
643766ce4d0SZheng Fan 
644766ce4d0SZheng Fan 	mpBindings->GetDispatcher()->Execute(
645766ce4d0SZheng Fan 			SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L);
646766ce4d0SZheng Fan 
647766ce4d0SZheng Fan 	mbUseLineSPCustom = USE_CUSTOM;
648766ce4d0SZheng Fan }
649766ce4d0SZheng Fan 
650766ce4d0SZheng Fan void ParaLineSpacingControl::SetLineSpace( SvxLineSpacingItem& rLineSpace,
651766ce4d0SZheng Fan 						int eSpace, long lValue )
652766ce4d0SZheng Fan {
653766ce4d0SZheng Fan 	switch ( eSpace )
654766ce4d0SZheng Fan 	{
655766ce4d0SZheng Fan 		case LLINESPACE_1:
656766ce4d0SZheng Fan 			rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
657766ce4d0SZheng Fan 			rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
658766ce4d0SZheng Fan 			break;
659766ce4d0SZheng Fan 
660766ce4d0SZheng Fan 		case LLINESPACE_15:
661766ce4d0SZheng Fan 			rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
662766ce4d0SZheng Fan 			rLineSpace.SetPropLineSpace( LINESPACE_15 );
663766ce4d0SZheng Fan 			break;
664766ce4d0SZheng Fan 
665766ce4d0SZheng Fan 		case LLINESPACE_2:
666766ce4d0SZheng Fan 			rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
667766ce4d0SZheng Fan 			rLineSpace.SetPropLineSpace( LINESPACE_2 );
668766ce4d0SZheng Fan 			break;
669766ce4d0SZheng Fan 
670766ce4d0SZheng Fan 		case LLINESPACE_PROP:
671766ce4d0SZheng Fan 			rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
672766ce4d0SZheng Fan 			rLineSpace.SetPropLineSpace( (sal_uInt8)lValue );
673766ce4d0SZheng Fan 			break;
674766ce4d0SZheng Fan 
675766ce4d0SZheng Fan 		case LLINESPACE_MIN:
676766ce4d0SZheng Fan 			rLineSpace.SetLineHeight( (sal_uInt16)lValue );
677766ce4d0SZheng Fan 			rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
678766ce4d0SZheng Fan 			break;
679766ce4d0SZheng Fan 
680766ce4d0SZheng Fan 		case LLINESPACE_DURCH:
681766ce4d0SZheng Fan 			rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
682766ce4d0SZheng Fan 			rLineSpace.SetInterLineSpace( (sal_uInt16)lValue );
683766ce4d0SZheng Fan 			break;
684766ce4d0SZheng Fan 
685766ce4d0SZheng Fan 		case LLINESPACE_FIX:
686766ce4d0SZheng Fan 			rLineSpace.SetLineHeight((sal_uInt16)lValue);
687766ce4d0SZheng Fan 			rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_FIX;
688766ce4d0SZheng Fan 			rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
689766ce4d0SZheng Fan 		break;
690766ce4d0SZheng Fan 	}
691766ce4d0SZheng Fan }
692766ce4d0SZheng Fan 
693766ce4d0SZheng Fan IMPL_LINK(ParaLineSpacingControl, VSSelHdl, void *, pControl)
694766ce4d0SZheng Fan {
695766ce4d0SZheng Fan 	maLineSpacing.SetNoSelection();
696766ce4d0SZheng Fan 	bool bClosePop = true;
697766ce4d0SZheng Fan 	if(pControl == &maLineSpacing)
698766ce4d0SZheng Fan 	{
699766ce4d0SZheng Fan 		sal_uInt16 iPos = maLineSpacing.GetSelectItemId();
700766ce4d0SZheng Fan 		switch ( iPos )
701766ce4d0SZheng Fan 		{
702766ce4d0SZheng Fan 			case 1:
703766ce4d0SZheng Fan 				ExecuteLineSpacing( 0, 0 );
704766ce4d0SZheng Fan 				break;
705766ce4d0SZheng Fan 			case 2:
706766ce4d0SZheng Fan 				ExecuteLineSpacing( 0, 3 );
707766ce4d0SZheng Fan 				break;
708766ce4d0SZheng Fan 			case 3:
709766ce4d0SZheng Fan 				ExecuteLineSpacing( 0, 1 );
710766ce4d0SZheng Fan 				break;
711766ce4d0SZheng Fan 			case 4:
712766ce4d0SZheng Fan 				ExecuteLineSpacing( 0, 2 );
713766ce4d0SZheng Fan 				break;
714766ce4d0SZheng Fan 			case 5:
715766ce4d0SZheng Fan 				{
716766ce4d0SZheng Fan 					if(!(mbLineSPDisable))
717766ce4d0SZheng Fan 					{
718766ce4d0SZheng Fan 						//maPos = mrParaPropertyPanel.maLinePos;
719766ce4d0SZheng Fan 						aLineDist.SelectEntryPos( maPos ) ;
720766ce4d0SZheng Fan 						aLineDist.SaveValue();
721766ce4d0SZheng Fan 						//maValue = mrParaPropertyPanel.maLineValue;
722766ce4d0SZheng Fan 
723766ce4d0SZheng Fan 						SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE);
724766ce4d0SZheng Fan 						switch(maPos)
725766ce4d0SZheng Fan 						{
726766ce4d0SZheng Fan 						case LLINESPACE_1:
727766ce4d0SZheng Fan 						case LLINESPACE_15:
728766ce4d0SZheng Fan 						case LLINESPACE_2:
729766ce4d0SZheng Fan 							SetLineSpace( aSpacing, maPos );
730766ce4d0SZheng Fan 							break;
731766ce4d0SZheng Fan 
732766ce4d0SZheng Fan 						case LLINESPACE_PROP:
733766ce4d0SZheng Fan 							SetLineSpace( aSpacing, maPos,
734766ce4d0SZheng Fan 								aLineDistAtPercentBox.Denormalize( (long)maValue ) );
735766ce4d0SZheng Fan 							break;
736766ce4d0SZheng Fan 
737766ce4d0SZheng Fan 						case LLINESPACE_MIN:
738766ce4d0SZheng Fan 						case LLINESPACE_DURCH:
739766ce4d0SZheng Fan 						case LLINESPACE_FIX:
740766ce4d0SZheng Fan 							SetLineSpace( aSpacing, maPos, (long)maValue );
741766ce4d0SZheng Fan 							break;
742766ce4d0SZheng Fan 						}
743766ce4d0SZheng Fan 
744766ce4d0SZheng Fan 						mpBindings->GetDispatcher()->Execute(
745766ce4d0SZheng Fan 							SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L);
746766ce4d0SZheng Fan 
747766ce4d0SZheng Fan 						ExecuteLineSpacing( USE_CUSTOM, 0 );
748766ce4d0SZheng Fan 					}
749766ce4d0SZheng Fan 					else
750766ce4d0SZheng Fan 						bClosePop = sal_False;
751766ce4d0SZheng Fan 				}
752766ce4d0SZheng Fan 				break;
753766ce4d0SZheng Fan 		}
754766ce4d0SZheng Fan 	}
755766ce4d0SZheng Fan 	if(bClosePop)
756766ce4d0SZheng Fan 		mrParaPropertyPanel.EndSpacingPopupMode();
757766ce4d0SZheng Fan 	return 0;
758766ce4d0SZheng Fan }
759766ce4d0SZheng Fan 
760766ce4d0SZheng Fan void ParaLineSpacingControl::ExecuteLineSpacing( sal_uInt16 aIsCustom, sal_uInt16 aEntry )
761766ce4d0SZheng Fan {
762766ce4d0SZheng Fan 	if( !aIsCustom )
763766ce4d0SZheng Fan 	{
764766ce4d0SZheng Fan 		aLineDist.SelectEntryPos( aEntry ) ;
765766ce4d0SZheng Fan 		aLineDist.SaveValue();
766766ce4d0SZheng Fan 		SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE);
767766ce4d0SZheng Fan 		sal_uInt16 nPos = aEntry;
768766ce4d0SZheng Fan 		if( aEntry == LLINESPACE_PROP )
769766ce4d0SZheng Fan 			SetLineSpace( aSpacing, nPos, aLineDistAtPercentBox.Denormalize( (long)115 ) );
770766ce4d0SZheng Fan 		else
771766ce4d0SZheng Fan 			SetLineSpace( aSpacing, nPos );
772766ce4d0SZheng Fan 
773766ce4d0SZheng Fan 		mpBindings->GetDispatcher()->Execute(
774766ce4d0SZheng Fan 			SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L);
775766ce4d0SZheng Fan 	}
776766ce4d0SZheng Fan 
777766ce4d0SZheng Fan 	if( !aIsCustom )
778766ce4d0SZheng Fan 	{
779766ce4d0SZheng Fan 		mbUseLineSPCustom = DO_NOT_CUSTOM;
780766ce4d0SZheng Fan 		mrParaPropertyPanel.EndSpacingPopupMode();
781766ce4d0SZheng Fan 	}
782766ce4d0SZheng Fan 	maLineSpacing.SetNoSelection();
783766ce4d0SZheng Fan }
784766ce4d0SZheng Fan 
785766ce4d0SZheng Fan }} // end of namespace sidebar
786766ce4d0SZheng Fan 
787