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" 25766ce4d0SZheng Fan #include <sfx2/sidebar/propertypanel.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 maLPCustom (SVX_RES(IMG_SPACINGLCUSTOM)), 71766ce4d0SZheng Fan maSelSpacing1 (SVX_RES(IMG_SEL_SPACING1)), 72766ce4d0SZheng Fan maSelSpacing115 (SVX_RES(IMG_SEL_SPACING115)), 73766ce4d0SZheng Fan maSelSpacing15 (SVX_RES(IMG_SEL_SPACING15)), 74766ce4d0SZheng Fan maSelSpacing2 (SVX_RES(IMG_SEL_SPACING2)), 75766ce4d0SZheng Fan maImgCusGrey (SVX_RES(IMG_CUSTOM_GRAY)), 76766ce4d0SZheng Fan maImgCus (SVX_RES(IMG_CUSTOM)), 77766ce4d0SZheng Fan maStrCus (SVX_RES(STR_LCVALUE)), 78766ce4d0SZheng Fan pActLineDistFld ( &aLineDistAtPercentBox ), 79766ce4d0SZheng Fan nMinFixDist ( BEGIN_VALUE ), 80766ce4d0SZheng Fan maValue ( 0 ), 81766ce4d0SZheng Fan maPos ( 0 ), 82766ce4d0SZheng Fan maLineSpacing (ValueSetWithTextControl::IMAGE_TEXT,this, SVX_RES( LINE_SPACING ) ), 83766ce4d0SZheng Fan mpImg (NULL), 84766ce4d0SZheng Fan mpImgSel (NULL), 85766ce4d0SZheng Fan mpStr (NULL), 86766ce4d0SZheng Fan mpStrTip (NULL), 87766ce4d0SZheng Fan maLine (SVX_RES(STR_LSPACING)), 88766ce4d0SZheng Fan maOf (SVX_RES(STR_LS_OF)) 89766ce4d0SZheng Fan , mbUseLineSPCustom (0) 90766ce4d0SZheng Fan , mbLineSPDisable (0) 91766ce4d0SZheng Fan { 92766ce4d0SZheng Fan initial(); 93766ce4d0SZheng Fan FreeResource(); 94766ce4d0SZheng Fan mpBindings = mrParaPropertyPanel.GetBindings(); 95766ce4d0SZheng Fan // m_eLNSpaceUnit = mrParaPropertyPanel.maLNSpaceControl.GetCoreMetric(); 96766ce4d0SZheng Fan m_eLNSpaceUnit = SFX_MAPUNIT_100TH_MM; 97766ce4d0SZheng Fan } 98766ce4d0SZheng Fan ParaLineSpacingControl::~ParaLineSpacingControl() 99766ce4d0SZheng Fan { 100766ce4d0SZheng Fan delete[] mpImg; 101766ce4d0SZheng Fan delete[] mpImgSel; 102766ce4d0SZheng Fan delete[] mpStr; 103766ce4d0SZheng Fan delete[] mpStrTip; 104766ce4d0SZheng Fan } 105766ce4d0SZheng Fan 106766ce4d0SZheng Fan void ParaLineSpacingControl::initial() 107766ce4d0SZheng Fan { 108766ce4d0SZheng Fan //maLineSpacing.SetStyle( maLineSpacing.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT ); 109766ce4d0SZheng Fan //maLineSpacing.SetControlBackground(GetSettings().GetStyleSettings().GetMenuColor()); 110766ce4d0SZheng Fan //maLineSpacing.SetColor(GetSettings().GetStyleSettings().GetMenuColor()); 111766ce4d0SZheng Fan //maLineSpacing.SetMinFont(); 112766ce4d0SZheng Fan 113766ce4d0SZheng Fan maLineSpacing.SetControlBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 114766ce4d0SZheng Fan GetSettings().GetStyleSettings().GetMenuColor(): 115766ce4d0SZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 116766ce4d0SZheng Fan maLineSpacing.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()? 117766ce4d0SZheng Fan GetSettings().GetStyleSettings().GetMenuColor(): 118766ce4d0SZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 119766ce4d0SZheng Fan maLineSpacing.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 120766ce4d0SZheng Fan GetSettings().GetStyleSettings().GetMenuColor(): 121766ce4d0SZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 122766ce4d0SZheng Fan //maFTSpacing.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 123766ce4d0SZheng Fan //GetSettings().GetStyleSettings().GetMenuColor(): 124766ce4d0SZheng Fan //sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 125766ce4d0SZheng Fan //maFTBy.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 126766ce4d0SZheng Fan //GetSettings().GetStyleSettings().GetMenuColor(): 127766ce4d0SZheng Fan //sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 128766ce4d0SZheng Fan 129766ce4d0SZheng Fan mpImg = new Image[4]; 130766ce4d0SZheng Fan mpImg[0] = maSpacing1; 131766ce4d0SZheng Fan mpImg[1] = maSpacing115; 132766ce4d0SZheng Fan mpImg[2] = maSpacing15; 133766ce4d0SZheng Fan mpImg[3] = maSpacing2; 134766ce4d0SZheng Fan 135766ce4d0SZheng Fan mpImgSel = new Image[4]; 136766ce4d0SZheng Fan mpImgSel[0] = maSelSpacing1; 137766ce4d0SZheng Fan mpImgSel[1] = maSelSpacing115; 138766ce4d0SZheng Fan mpImgSel[2] = maSelSpacing15; 139766ce4d0SZheng Fan mpImgSel[3] = maSelSpacing2; 140766ce4d0SZheng Fan 141766ce4d0SZheng Fan mpStr = new XubString[4]; 142766ce4d0SZheng Fan mpStr[0] = XubString(SVX_RES(STR_SPACING1)); 143766ce4d0SZheng Fan mpStr[1] = XubString(SVX_RES(STR_SPACING115)); 144766ce4d0SZheng Fan mpStr[2] = XubString(SVX_RES(STR_SPACING15)); 145766ce4d0SZheng Fan mpStr[3] = XubString(SVX_RES(STR_SPACING2)); 146766ce4d0SZheng Fan 147766ce4d0SZheng Fan mpStrTip = new XubString[4]; 148766ce4d0SZheng Fan mpStrTip[0] = XubString(SVX_RES(STR_LS_SINGLE)); 149766ce4d0SZheng Fan mpStrTip[1] = XubString(SVX_RES(STR_LS_115)); 150766ce4d0SZheng Fan mpStrTip[2] = XubString(SVX_RES(STR_LS_15)); 151766ce4d0SZheng Fan mpStrTip[3] = XubString(SVX_RES(STR_LS_DOUBLE)); 152766ce4d0SZheng Fan for (int i=0;i<4;i++) 153766ce4d0SZheng Fan maLineSpacing.AddItem(mpImg[i], &mpImgSel[i],mpStr[i],&mpStrTip[i]); 154766ce4d0SZheng Fan 155c1757099SZheng Fan maLineSpacing.AddItem( maImgCus, 0, maStrCus, 0 ); 156766ce4d0SZheng Fan 157766ce4d0SZheng Fan SetAllNoSel(); 158766ce4d0SZheng Fan Link aLink = LINK(this, ParaLineSpacingControl,VSSelHdl ); 159766ce4d0SZheng Fan maLineSpacing.SetSelectHdl(aLink); 160766ce4d0SZheng Fan maLineSpacing.StartSelection(); 161766ce4d0SZheng Fan maLineSpacing.Show(); 162766ce4d0SZheng Fan 163766ce4d0SZheng Fan aLink = LINK( this, ParaLineSpacingControl, LineSPDistHdl_Impl ); 164766ce4d0SZheng Fan aLineDist.SetSelectHdl(aLink); 165766ce4d0SZheng Fan aLineDist.SelectEntryPos( LLINESPACE_1 ) ; 166766ce4d0SZheng Fan aLink = LINK( this, ParaLineSpacingControl, LineSPDistAtHdl_Impl ); 167766ce4d0SZheng Fan aLineDistAtPercentBox.SetModifyHdl( aLink ); 168766ce4d0SZheng Fan aLineDistAtMetricBox.SetModifyHdl( aLink ); 169766ce4d0SZheng Fan } 170766ce4d0SZheng Fan void ParaLineSpacingControl::ToGetFocus(bool bType) 171766ce4d0SZheng Fan { 172766ce4d0SZheng Fan if(!bType) 173766ce4d0SZheng Fan aLineDist.GrabFocus(); 174766ce4d0SZheng Fan else 175766ce4d0SZheng Fan maLineSpacing.GrabFocus(); //wj 176766ce4d0SZheng Fan } 177766ce4d0SZheng Fan 178766ce4d0SZheng Fan void ParaLineSpacingControl::PopupModeEndCallback() 179766ce4d0SZheng Fan { 180766ce4d0SZheng Fan if( mbUseLineSPCustom ) 181766ce4d0SZheng Fan { 182766ce4d0SZheng Fan //maLinePos = mpLineSPPage->maPos; 183766ce4d0SZheng Fan //maLineValue = mpLineSPPage->maValue; 184766ce4d0SZheng Fan 185766ce4d0SZheng Fan SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE ); 186766ce4d0SZheng Fan ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1); 187766ce4d0SZheng Fan aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("maLinePos") ); 188766ce4d0SZheng Fan aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( maPos )); 189766ce4d0SZheng Fan aWinOpt.SetUserData( aSeq ); 190766ce4d0SZheng Fan 191766ce4d0SZheng Fan SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE ); 192766ce4d0SZheng Fan aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("maLineValue") ); 193766ce4d0SZheng Fan aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( maValue )); 194766ce4d0SZheng Fan aWinOpt2.SetUserData( aSeq ); 195766ce4d0SZheng Fan } 196766ce4d0SZheng Fan } 197766ce4d0SZheng Fan 198766ce4d0SZheng Fan void ParaLineSpacingControl::Rearrange(SfxItemState currSPState,FieldUnit currMetricUnit,SvxLineSpacingItem* currSPItem,const ::sfx2::sidebar::EnumContext currentContext) 199766ce4d0SZheng Fan { 200766ce4d0SZheng Fan SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE ); 201766ce4d0SZheng Fan if ( aWinOpt.Exists() ) 202766ce4d0SZheng Fan { 203766ce4d0SZheng Fan ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData(); 204766ce4d0SZheng Fan ::rtl::OUString aTmp; 205766ce4d0SZheng Fan if ( aSeq.getLength()) 206766ce4d0SZheng Fan aSeq[0].Value >>= aTmp; 207766ce4d0SZheng Fan 208766ce4d0SZheng Fan String aWinData( aTmp ); 209766ce4d0SZheng Fan maPos = (sal_uInt16)aWinData.ToInt32(); 210766ce4d0SZheng Fan } 211766ce4d0SZheng Fan 212766ce4d0SZheng Fan SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE ); 213766ce4d0SZheng Fan if ( aWinOpt2.Exists() ) 214766ce4d0SZheng Fan { 215766ce4d0SZheng Fan ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt2.GetUserData(); 216766ce4d0SZheng Fan ::rtl::OUString aTmp; 217766ce4d0SZheng Fan if ( aSeq.getLength()) 218766ce4d0SZheng Fan aSeq[0].Value >>= aTmp; 219766ce4d0SZheng Fan 220766ce4d0SZheng Fan String aWinData( aTmp ); 221766ce4d0SZheng Fan maValue = (sal_uInt16)aWinData.ToInt32(); 222766ce4d0SZheng Fan } 223766ce4d0SZheng Fan String sHelpText; 224766ce4d0SZheng Fan switch(maPos) 225766ce4d0SZheng Fan { 226766ce4d0SZheng Fan case LLINESPACE_1: 227766ce4d0SZheng Fan sHelpText += mpStrTip[0]; 228766ce4d0SZheng Fan break; 229766ce4d0SZheng Fan case LLINESPACE_15: 230766ce4d0SZheng Fan sHelpText += mpStrTip[2]; 231766ce4d0SZheng Fan break; 232766ce4d0SZheng Fan case LLINESPACE_2: 233766ce4d0SZheng Fan sHelpText += mpStrTip[3]; 234766ce4d0SZheng Fan break; 235766ce4d0SZheng Fan case LLINESPACE_PROP: 236766ce4d0SZheng Fan sHelpText +=maLine; 237766ce4d0SZheng Fan sHelpText.Append(String("Proportion: ", 12, RTL_TEXTENCODING_ASCII_US)); 238766ce4d0SZheng Fan sHelpText += maOf; 239766ce4d0SZheng Fan sHelpText.Append( String::CreateFromInt64( maValue )); 240766ce4d0SZheng Fan break; 241766ce4d0SZheng Fan case LLINESPACE_MIN: 242766ce4d0SZheng Fan sHelpText += maLine; 243766ce4d0SZheng Fan sHelpText.Append(String("At Least: ", 10, RTL_TEXTENCODING_ASCII_US)); 244766ce4d0SZheng Fan sHelpText += maOf; 245766ce4d0SZheng Fan sHelpText.Append( String::CreateFromInt64( maValue )); 246766ce4d0SZheng Fan break; 247766ce4d0SZheng Fan case LLINESPACE_DURCH: 248766ce4d0SZheng Fan sHelpText += maLine; 249766ce4d0SZheng Fan sHelpText.Append(String("Leading: ", 9, RTL_TEXTENCODING_ASCII_US)); 250766ce4d0SZheng Fan sHelpText += maOf; 251766ce4d0SZheng Fan sHelpText.Append( String::CreateFromInt64( maValue )); 252766ce4d0SZheng Fan break; 253766ce4d0SZheng Fan case LLINESPACE_FIX: 254766ce4d0SZheng Fan sHelpText += maLine; 255766ce4d0SZheng Fan sHelpText.Append(String("Fixed: ", 7, RTL_TEXTENCODING_ASCII_US)); 256766ce4d0SZheng Fan sHelpText += maOf; 257766ce4d0SZheng Fan sHelpText.Append( String::CreateFromInt64( maValue )); 258766ce4d0SZheng Fan break; 259766ce4d0SZheng Fan } 260766ce4d0SZheng Fan if( !aWinOpt.Exists() && !aWinOpt2.Exists() ) 261766ce4d0SZheng Fan mbLineSPDisable = sal_True; 262766ce4d0SZheng Fan else 263766ce4d0SZheng Fan mbLineSPDisable = sal_False; 264766ce4d0SZheng Fan 265766ce4d0SZheng Fan if( mbLineSPDisable ) 266c1757099SZheng Fan maLineSpacing.ReplaceItemImages(5, maImgCusGrey,0); 267766ce4d0SZheng Fan else 268766ce4d0SZheng Fan { 269c1757099SZheng Fan maLineSpacing.ReplaceItemImages(5, maImgCus,0); 270c1757099SZheng Fan maLineSpacing.SetItemText(5,sHelpText); 271766ce4d0SZheng Fan } 272766ce4d0SZheng Fan 273766ce4d0SZheng Fan SfxItemState eState = currSPState; 274766ce4d0SZheng Fan 275766ce4d0SZheng Fan SetFieldUnit( aLineDistAtMetricBox, currMetricUnit ); 276766ce4d0SZheng Fan 277766ce4d0SZheng Fan // mpLineSPPage->SetAllNoSel(); 278766ce4d0SZheng Fan aLineDist.Enable(); 279766ce4d0SZheng Fan pActLineDistFld->Enable(); 280766ce4d0SZheng Fan pActLineDistFld->SetText( String() ); 281766ce4d0SZheng Fan bool bValueSetFocus = sal_False; //wj 282766ce4d0SZheng Fan 283766ce4d0SZheng Fan if( eState >= SFX_ITEM_AVAILABLE ) 284766ce4d0SZheng Fan { 285766ce4d0SZheng Fan // SfxMapUnit eUnit = maLNSpaceControl.GetCoreMetric(); 286766ce4d0SZheng Fan SfxMapUnit eUnit = SFX_MAPUNIT_100TH_MM; 287766ce4d0SZheng Fan m_eLNSpaceUnit = eUnit; 288766ce4d0SZheng Fan 289766ce4d0SZheng Fan switch( currSPItem->GetLineSpaceRule() ) 290766ce4d0SZheng Fan { 291766ce4d0SZheng Fan case SVX_LINE_SPACE_AUTO: 292766ce4d0SZheng Fan { 293766ce4d0SZheng Fan SvxInterLineSpace eInter = currSPItem->GetInterLineSpaceRule(); 294766ce4d0SZheng Fan 295766ce4d0SZheng Fan switch( eInter ) 296766ce4d0SZheng Fan { 297766ce4d0SZheng Fan case SVX_INTER_LINE_SPACE_OFF: 298766ce4d0SZheng Fan { 299766ce4d0SZheng Fan aLineDist.SelectEntryPos( LLINESPACE_1 ); 300766ce4d0SZheng Fan pActLineDistFld->Disable(); 301766ce4d0SZheng Fan pActLineDistFld->SetText( String() ); 302766ce4d0SZheng Fan mbUseLineSPCustom = DO_NOT_CUSTOM; 303766ce4d0SZheng Fan if ( LINESPACE_1 == currSPItem->GetPropLineSpace() ) 304766ce4d0SZheng Fan { 305c1757099SZheng Fan maLineSpacing.SelectItem(1); 306766ce4d0SZheng Fan bValueSetFocus = sal_True; //wj 307766ce4d0SZheng Fan } 308766ce4d0SZheng Fan } 309766ce4d0SZheng Fan break; 310766ce4d0SZheng Fan 311766ce4d0SZheng Fan case SVX_INTER_LINE_SPACE_PROP: 312766ce4d0SZheng Fan { 313766ce4d0SZheng Fan if ( LINESPACE_1 == currSPItem->GetPropLineSpace() ) 314766ce4d0SZheng Fan { 315766ce4d0SZheng Fan aLineDist.SelectEntryPos( LLINESPACE_1 ); 316766ce4d0SZheng Fan pActLineDistFld->Disable(); 317766ce4d0SZheng Fan pActLineDistFld->SetText( String() ); 318766ce4d0SZheng Fan mbUseLineSPCustom = DO_NOT_CUSTOM; 319c1757099SZheng Fan maLineSpacing.SelectItem(1); 320766ce4d0SZheng Fan bValueSetFocus = sal_True; //wj 321766ce4d0SZheng Fan break; 322766ce4d0SZheng Fan } 323766ce4d0SZheng Fan if ( LINESPACE_15 == currSPItem->GetPropLineSpace() ) 324766ce4d0SZheng Fan { 325766ce4d0SZheng Fan aLineDist.SelectEntryPos( LLINESPACE_15 ); 326766ce4d0SZheng Fan pActLineDistFld->Disable(); 327766ce4d0SZheng Fan pActLineDistFld->SetText( String() ); 328766ce4d0SZheng Fan 329766ce4d0SZheng Fan mbUseLineSPCustom = DO_NOT_CUSTOM; 330c1757099SZheng Fan maLineSpacing.SelectItem(3); 331766ce4d0SZheng Fan bValueSetFocus = sal_True; //wj 332766ce4d0SZheng Fan break; 333766ce4d0SZheng Fan } 334766ce4d0SZheng Fan if ( LINESPACE_2 == currSPItem->GetPropLineSpace() ) 335766ce4d0SZheng Fan { 336766ce4d0SZheng Fan aLineDist.SelectEntryPos( LLINESPACE_2 ); 337766ce4d0SZheng Fan pActLineDistFld->Disable(); 338766ce4d0SZheng Fan pActLineDistFld->SetText( String() ); 339766ce4d0SZheng Fan 340766ce4d0SZheng Fan mbUseLineSPCustom = DO_NOT_CUSTOM; 341c1757099SZheng Fan maLineSpacing.SelectItem(4); 342766ce4d0SZheng Fan bValueSetFocus = sal_True; //wj 343766ce4d0SZheng Fan break; 344766ce4d0SZheng Fan } 345766ce4d0SZheng Fan 346766ce4d0SZheng Fan aLineDist.SelectEntryPos( LLINESPACE_PROP ); 347766ce4d0SZheng Fan if(pActLineDistFld != &(aLineDistAtPercentBox)) 348766ce4d0SZheng Fan { 349766ce4d0SZheng Fan pActLineDistFld->Disable(); 350766ce4d0SZheng Fan pActLineDistFld->Hide(); 351766ce4d0SZheng Fan pActLineDistFld = &(aLineDistAtPercentBox); 352766ce4d0SZheng Fan } 353766ce4d0SZheng Fan else 354766ce4d0SZheng Fan { 355766ce4d0SZheng Fan pActLineDistFld = &(aLineDistAtMetricBox); 356766ce4d0SZheng Fan pActLineDistFld->Disable(); 357766ce4d0SZheng Fan pActLineDistFld->Hide(); 358766ce4d0SZheng Fan pActLineDistFld = &(aLineDistAtPercentBox); 359766ce4d0SZheng Fan } 360766ce4d0SZheng Fan pActLineDistFld->Enable(); 361766ce4d0SZheng Fan pActLineDistFld->Show(); 362766ce4d0SZheng Fan aLineDistAtPercentBox. 363766ce4d0SZheng Fan SetValue( aLineDistAtPercentBox.Normalize( 364766ce4d0SZheng Fan currSPItem->GetPropLineSpace() ) ); 365766ce4d0SZheng Fan 366766ce4d0SZheng Fan if( currSPItem->GetPropLineSpace() == LINESPACE_115 ) 367766ce4d0SZheng Fan { 368766ce4d0SZheng Fan mbUseLineSPCustom = DO_NOT_CUSTOM; 369c1757099SZheng Fan maLineSpacing.SelectItem(2); 370766ce4d0SZheng Fan bValueSetFocus = sal_True; //wj 371766ce4d0SZheng Fan } 372766ce4d0SZheng Fan else 373766ce4d0SZheng Fan { 374766ce4d0SZheng Fan mbUseLineSPCustom = USE_CUSTOM; 375c1757099SZheng Fan maLineSpacing.SetNoSelection(); 376c1757099SZheng Fan maLineSpacing.SelectItem(0); 377766ce4d0SZheng Fan } 378766ce4d0SZheng Fan } 379766ce4d0SZheng Fan break; 380766ce4d0SZheng Fan 381766ce4d0SZheng Fan case SVX_INTER_LINE_SPACE_FIX: 382766ce4d0SZheng Fan { 383766ce4d0SZheng Fan if(pActLineDistFld != &(aLineDistAtMetricBox)) 384766ce4d0SZheng Fan { 385766ce4d0SZheng Fan pActLineDistFld->Disable(); 386766ce4d0SZheng Fan pActLineDistFld->Hide(); 387766ce4d0SZheng Fan pActLineDistFld = &(aLineDistAtMetricBox); 388766ce4d0SZheng Fan } 389766ce4d0SZheng Fan else 390766ce4d0SZheng Fan { 391766ce4d0SZheng Fan pActLineDistFld = &(aLineDistAtPercentBox); 392766ce4d0SZheng Fan pActLineDistFld->Disable(); 393766ce4d0SZheng Fan pActLineDistFld->Hide(); 394766ce4d0SZheng Fan pActLineDistFld = &(aLineDistAtMetricBox); 395766ce4d0SZheng Fan } 396766ce4d0SZheng Fan pActLineDistFld->Enable(); 397766ce4d0SZheng Fan pActLineDistFld->Show(); 398c1757099SZheng Fan maLineSpacing.SetNoSelection(); 399c1757099SZheng Fan maLineSpacing.SelectItem(0); 400766ce4d0SZheng Fan 401766ce4d0SZheng Fan SetMetricValue( aLineDistAtMetricBox, 402766ce4d0SZheng Fan currSPItem->GetInterLineSpace(), eUnit ); 403766ce4d0SZheng Fan aLineDist.SelectEntryPos( LLINESPACE_DURCH ); 404766ce4d0SZheng Fan 405766ce4d0SZheng Fan mbUseLineSPCustom = USE_CUSTOM; 406766ce4d0SZheng Fan } 407766ce4d0SZheng Fan break; 408766ce4d0SZheng Fan } 409766ce4d0SZheng Fan } 410766ce4d0SZheng Fan break; 411766ce4d0SZheng Fan case SVX_LINE_SPACE_FIX: 412766ce4d0SZheng Fan { 413766ce4d0SZheng Fan if(pActLineDistFld != &(aLineDistAtMetricBox)) 414766ce4d0SZheng Fan { 415766ce4d0SZheng Fan pActLineDistFld->Disable(); 416766ce4d0SZheng Fan pActLineDistFld->Hide(); 417766ce4d0SZheng Fan pActLineDistFld = &(aLineDistAtMetricBox); 418766ce4d0SZheng Fan } 419766ce4d0SZheng Fan else 420766ce4d0SZheng Fan { 421766ce4d0SZheng Fan pActLineDistFld = &(aLineDistAtPercentBox); 422766ce4d0SZheng Fan pActLineDistFld->Disable(); 423766ce4d0SZheng Fan pActLineDistFld->Hide(); 424766ce4d0SZheng Fan pActLineDistFld = &(aLineDistAtMetricBox); 425766ce4d0SZheng Fan } 426766ce4d0SZheng Fan pActLineDistFld->Enable(); 427766ce4d0SZheng Fan pActLineDistFld->Show(); 428c1757099SZheng Fan maLineSpacing.SetNoSelection(); 429c1757099SZheng Fan maLineSpacing.SelectItem(0); 430766ce4d0SZheng Fan 431766ce4d0SZheng Fan SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit); 432766ce4d0SZheng Fan aLineDist.SelectEntryPos( LLINESPACE_FIX ); 433766ce4d0SZheng Fan 434766ce4d0SZheng Fan mbUseLineSPCustom = USE_CUSTOM; 435766ce4d0SZheng Fan } 436766ce4d0SZheng Fan break; 437766ce4d0SZheng Fan 438766ce4d0SZheng Fan case SVX_LINE_SPACE_MIN: 439766ce4d0SZheng Fan { 440766ce4d0SZheng Fan if(pActLineDistFld != &(aLineDistAtMetricBox)) 441766ce4d0SZheng Fan { 442766ce4d0SZheng Fan pActLineDistFld->Disable(); 443766ce4d0SZheng Fan pActLineDistFld->Hide(); 444766ce4d0SZheng Fan pActLineDistFld = &(aLineDistAtMetricBox); 445766ce4d0SZheng Fan } 446766ce4d0SZheng Fan else 447766ce4d0SZheng Fan { 448766ce4d0SZheng Fan pActLineDistFld = &(aLineDistAtPercentBox); 449766ce4d0SZheng Fan pActLineDistFld->Disable(); 450766ce4d0SZheng Fan pActLineDistFld->Hide(); 451766ce4d0SZheng Fan pActLineDistFld = &(aLineDistAtMetricBox); 452766ce4d0SZheng Fan } 453766ce4d0SZheng Fan pActLineDistFld->Enable(); 454766ce4d0SZheng Fan pActLineDistFld->Show(); 455c1757099SZheng Fan maLineSpacing.SetNoSelection(); 456c1757099SZheng Fan maLineSpacing.SelectItem(0); 457766ce4d0SZheng Fan 458766ce4d0SZheng Fan SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit); 459766ce4d0SZheng Fan aLineDist.SelectEntryPos( LLINESPACE_MIN ); 460766ce4d0SZheng Fan mbUseLineSPCustom = USE_CUSTOM; 461766ce4d0SZheng Fan } 462766ce4d0SZheng Fan break; 463766ce4d0SZheng Fan } 464766ce4d0SZheng Fan } 465766ce4d0SZheng Fan else if( eState == SFX_ITEM_DISABLED ) 466766ce4d0SZheng Fan { 467766ce4d0SZheng Fan aLineDist.Disable(); 468766ce4d0SZheng Fan pActLineDistFld->Enable(sal_False); 469766ce4d0SZheng Fan pActLineDistFld->SetText( String() ); 470c1757099SZheng Fan maLineSpacing.SetNoSelection(); 471c1757099SZheng Fan maLineSpacing.SelectItem(0); 472766ce4d0SZheng Fan 473766ce4d0SZheng Fan mbUseLineSPCustom = DO_NOT_CUSTOM; 474766ce4d0SZheng Fan } 475766ce4d0SZheng Fan else 476766ce4d0SZheng Fan { 477766ce4d0SZheng Fan pActLineDistFld->Enable(sal_False); 478766ce4d0SZheng Fan pActLineDistFld->SetText( String() ); 479766ce4d0SZheng Fan aLineDist.SetNoSelection(); 480c1757099SZheng Fan maLineSpacing.SetNoSelection(); 481c1757099SZheng Fan maLineSpacing.SelectItem(0); 482766ce4d0SZheng Fan mbUseLineSPCustom = DO_NOT_CUSTOM; 483766ce4d0SZheng Fan } 484766ce4d0SZheng Fan 485766ce4d0SZheng Fan aLineDist.SaveValue(); 486766ce4d0SZheng Fan 487766ce4d0SZheng Fan /*sal_uInt16 nID = pBox->GetCurItemId(); 488766ce4d0SZheng Fan pBox->SetItemDown(nID, sal_True); 489766ce4d0SZheng Fan 490766ce4d0SZheng Fan Size aFloatSz = GetOutputSizePixel(); 491766ce4d0SZheng Fan 492766ce4d0SZheng Fan GetLineSPFloatWin()->SetSizePixel( aFloatSz ); 493766ce4d0SZheng Fan 494766ce4d0SZheng Fan Point aPos=maLineSPTbx->GetPosPixel(); 495766ce4d0SZheng Fan aPos.setX(aPos.getX()); 496766ce4d0SZheng Fan aPos = OutputToScreenPixel( aPos ); 497766ce4d0SZheng Fan Size aSize = maLineSPTbx->GetSizePixel(); 498766ce4d0SZheng Fan Rectangle aRect( aPos, aSize ); 499766ce4d0SZheng Fan 500766ce4d0SZheng Fan GetLineSPFloatWin()->StartPopupMode( aRect, FLOATWIN_POPUPMODE_DOWN | FLOATWIN_POPUPMODE_NOFOCUSCLOSE); 501766ce4d0SZheng Fan GetLineSPFloatWin()->SetPopupModeFlags(GetLineSPFloatWin()->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE ); 502766ce4d0SZheng Fan 503766ce4d0SZheng Fan pLineSPPage->ToGetFocus(bValueSetFocus); 504766ce4d0SZheng Fan */ 505766ce4d0SZheng Fan sal_uInt16 uCount = aLineDist.GetEntryCount(); 506766ce4d0SZheng Fan if( uCount == LLINESPACE_FIX + 1 ) 507766ce4d0SZheng Fan { 508766ce4d0SZheng Fan switch (currentContext.GetCombinedContext()) 509766ce4d0SZheng Fan { 510766ce4d0SZheng Fan case CombinedEnumContext(Application_Impress, Context_Table): 511766ce4d0SZheng Fan case CombinedEnumContext(Application_Draw, Context_Table): 512766ce4d0SZheng Fan case CombinedEnumContext(Application_Writer, Context_DrawText): 513766ce4d0SZheng Fan case CombinedEnumContext(Application_Calc, Context_DrawText): 514766ce4d0SZheng Fan case CombinedEnumContext(Application_Draw, Context_DrawText): 515766ce4d0SZheng Fan case CombinedEnumContext(Application_Impress, Context_DrawText): 516766ce4d0SZheng Fan case CombinedEnumContext(Application_Writer, Context_Annotation): 517766ce4d0SZheng Fan case CombinedEnumContext(Application_Draw, Context_Draw): 518766ce4d0SZheng Fan case CombinedEnumContext(Application_Draw, Context_TextObject): 519766ce4d0SZheng Fan case CombinedEnumContext(Application_Draw, Context_Graphic): 520766ce4d0SZheng Fan case CombinedEnumContext(Application_Impress, Context_Draw): 521766ce4d0SZheng Fan case CombinedEnumContext(Application_Impress, Context_TextObject): 522766ce4d0SZheng Fan case CombinedEnumContext(Application_Impress, Context_Graphic): 523766ce4d0SZheng Fan { 524766ce4d0SZheng Fan aLineDist.RemoveEntry(LLINESPACE_FIX); 525766ce4d0SZheng Fan } 526766ce4d0SZheng Fan } 527766ce4d0SZheng Fan } 528766ce4d0SZheng Fan else if( uCount == LLINESPACE_FIX) 529766ce4d0SZheng Fan { 530766ce4d0SZheng Fan switch (currentContext.GetCombinedContext()) 531766ce4d0SZheng Fan { 532766ce4d0SZheng Fan case CombinedEnumContext(Application_Writer, Context_Default): 533766ce4d0SZheng Fan case CombinedEnumContext(Application_Writer, Context_Text): 534766ce4d0SZheng Fan case CombinedEnumContext(Application_Writer, Context_Table): 535766ce4d0SZheng Fan { 536766ce4d0SZheng Fan aLineDist.InsertEntry(String::CreateFromAscii("Fixed"), LLINESPACE_FIX); 537766ce4d0SZheng Fan } 538766ce4d0SZheng Fan } 539766ce4d0SZheng Fan } 540766ce4d0SZheng Fan maLineSpacing.Format(); 541766ce4d0SZheng Fan maLineSpacing.StartSelection(); 542766ce4d0SZheng Fan } 543766ce4d0SZheng Fan 544766ce4d0SZheng Fan void ParaLineSpacingControl::SetAllNoSel() 545766ce4d0SZheng Fan { 546c1757099SZheng Fan maLineSpacing.SelectItem(1); 547766ce4d0SZheng Fan maLineSpacing.SetNoSelection(); 548766ce4d0SZheng Fan } 549766ce4d0SZheng Fan 550766ce4d0SZheng Fan IMPL_LINK( ParaLineSpacingControl, LineSPDistHdl_Impl, ListBox*, pBox ) 551766ce4d0SZheng Fan { 552766ce4d0SZheng Fan maLineSpacing.SetNoSelection(); 553c1757099SZheng Fan maLineSpacing.SelectItem(0); 554766ce4d0SZheng Fan maLineSpacing.Format(); 555766ce4d0SZheng Fan maLineSpacing.StartSelection(); 556766ce4d0SZheng Fan 557766ce4d0SZheng Fan switch( pBox->GetSelectEntryPos() ) 558766ce4d0SZheng Fan { 559766ce4d0SZheng Fan case LLINESPACE_1: 560766ce4d0SZheng Fan case LLINESPACE_15: 561766ce4d0SZheng Fan case LLINESPACE_2: 562766ce4d0SZheng Fan pActLineDistFld->Enable(sal_False); 563766ce4d0SZheng Fan pActLineDistFld->SetText( String() ); 564766ce4d0SZheng Fan break; 565766ce4d0SZheng Fan 566766ce4d0SZheng Fan case LLINESPACE_DURCH: 567766ce4d0SZheng Fan aLineDistAtPercentBox.Hide(); 568766ce4d0SZheng Fan pActLineDistFld = &aLineDistAtMetricBox; 569766ce4d0SZheng Fan aLineDistAtMetricBox.SetMin(0); 570766ce4d0SZheng Fan 571766ce4d0SZheng Fan 572766ce4d0SZheng Fan if ( !aLineDistAtMetricBox.GetText().Len() ) 573766ce4d0SZheng Fan aLineDistAtMetricBox.SetValue( 574766ce4d0SZheng Fan aLineDistAtMetricBox.Normalize( 0 ) ); 575766ce4d0SZheng Fan aLineDistAtPercentBox.Hide(); 576766ce4d0SZheng Fan pActLineDistFld->Show(); 577766ce4d0SZheng Fan pActLineDistFld->Enable(); 578766ce4d0SZheng Fan break; 579766ce4d0SZheng Fan 580766ce4d0SZheng Fan case LLINESPACE_MIN: 581766ce4d0SZheng Fan aLineDistAtPercentBox.Hide(); 582766ce4d0SZheng Fan pActLineDistFld = &aLineDistAtMetricBox; 583766ce4d0SZheng Fan aLineDistAtMetricBox.SetMin(0); 584766ce4d0SZheng Fan 585766ce4d0SZheng Fan if ( !aLineDistAtMetricBox.GetText().Len() ) 586766ce4d0SZheng Fan aLineDistAtMetricBox.SetValue( 587766ce4d0SZheng Fan aLineDistAtMetricBox.Normalize( 0 ), FUNIT_TWIP ); 588766ce4d0SZheng Fan aLineDistAtPercentBox.Hide(); 589766ce4d0SZheng Fan pActLineDistFld->Show(); 590766ce4d0SZheng Fan pActLineDistFld->Enable(); 591766ce4d0SZheng Fan break; 592766ce4d0SZheng Fan 593766ce4d0SZheng Fan case LLINESPACE_PROP: 594766ce4d0SZheng Fan aLineDistAtMetricBox.Hide(); 595766ce4d0SZheng Fan pActLineDistFld = &aLineDistAtPercentBox; 596766ce4d0SZheng Fan 597766ce4d0SZheng Fan if ( !aLineDistAtPercentBox.GetText().Len() ) 598766ce4d0SZheng Fan aLineDistAtPercentBox.SetValue( 599766ce4d0SZheng Fan aLineDistAtPercentBox.Normalize( 100 ), FUNIT_TWIP ); 600766ce4d0SZheng Fan aLineDistAtMetricBox.Hide(); 601766ce4d0SZheng Fan pActLineDistFld->Show(); 602766ce4d0SZheng Fan pActLineDistFld->Enable(); 603766ce4d0SZheng Fan break; 604766ce4d0SZheng Fan case LLINESPACE_FIX: 605766ce4d0SZheng Fan { 606766ce4d0SZheng Fan aLineDistAtPercentBox.Hide(); 607766ce4d0SZheng Fan pActLineDistFld = &aLineDistAtMetricBox; 608766ce4d0SZheng Fan sal_Int64 nTemp = aLineDistAtMetricBox.GetValue(); 609766ce4d0SZheng Fan aLineDistAtMetricBox.SetMin(aLineDistAtMetricBox.Normalize(nMinFixDist), FUNIT_TWIP); 610766ce4d0SZheng Fan 611766ce4d0SZheng Fan if ( aLineDistAtMetricBox.GetValue() != nTemp ) 612766ce4d0SZheng Fan SetMetricValue( aLineDistAtMetricBox, 613766ce4d0SZheng Fan FIX_DIST_DEF, SFX_MAPUNIT_TWIP ); 614766ce4d0SZheng Fan aLineDistAtPercentBox.Hide(); 615766ce4d0SZheng Fan pActLineDistFld->Show(); 616766ce4d0SZheng Fan pActLineDistFld->Enable(); 617766ce4d0SZheng Fan } 618766ce4d0SZheng Fan break; 619766ce4d0SZheng Fan } 620766ce4d0SZheng Fan ExecuteLineSpace(); 621766ce4d0SZheng Fan return 0; 622766ce4d0SZheng Fan } 623766ce4d0SZheng Fan 624*6870eca3SPavel Janík IMPL_LINK( ParaLineSpacingControl, LineSPDistAtHdl_Impl, MetricField*, /* pBox */ ) 625766ce4d0SZheng Fan { 626766ce4d0SZheng Fan ExecuteLineSpace(); 627766ce4d0SZheng Fan return (0L); 628766ce4d0SZheng Fan } 629766ce4d0SZheng Fan 630766ce4d0SZheng Fan void ParaLineSpacingControl::ExecuteLineSpace() 631766ce4d0SZheng Fan { 632766ce4d0SZheng Fan aLineDist.SaveValue(); 633766ce4d0SZheng Fan maLineSpacing.SetNoSelection(); 634766ce4d0SZheng Fan 635766ce4d0SZheng Fan SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 636766ce4d0SZheng Fan sal_uInt16 nPos = aLineDist.GetSelectEntryPos(); 637766ce4d0SZheng Fan 638766ce4d0SZheng Fan switch ( nPos ) 639766ce4d0SZheng Fan { 640766ce4d0SZheng Fan case LLINESPACE_1: 641766ce4d0SZheng Fan case LLINESPACE_15: 642766ce4d0SZheng Fan case LLINESPACE_2: 643766ce4d0SZheng Fan { 644766ce4d0SZheng Fan SetLineSpace( aSpacing, nPos ); 645766ce4d0SZheng Fan maPos = nPos; 646766ce4d0SZheng Fan } 647766ce4d0SZheng Fan break; 648766ce4d0SZheng Fan 649766ce4d0SZheng Fan case LLINESPACE_PROP: 650766ce4d0SZheng Fan { 651766ce4d0SZheng Fan SetLineSpace( aSpacing, nPos, 652766ce4d0SZheng Fan aLineDistAtPercentBox.Denormalize( 653766ce4d0SZheng Fan (long)aLineDistAtPercentBox.GetValue() ) ); 654766ce4d0SZheng Fan maPos = nPos; 655766ce4d0SZheng Fan maValue =aLineDistAtPercentBox.GetValue(); 656766ce4d0SZheng Fan } 657766ce4d0SZheng Fan break; 658766ce4d0SZheng Fan 659766ce4d0SZheng Fan case LLINESPACE_MIN: 660766ce4d0SZheng Fan case LLINESPACE_DURCH: 661766ce4d0SZheng Fan case LLINESPACE_FIX: 662766ce4d0SZheng Fan { 663766ce4d0SZheng Fan SetLineSpace( aSpacing, nPos, 664766ce4d0SZheng Fan GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ) ); 665766ce4d0SZheng Fan maPos = nPos; 666766ce4d0SZheng Fan maValue = GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ); 667766ce4d0SZheng Fan } 668766ce4d0SZheng Fan break; 669766ce4d0SZheng Fan 670766ce4d0SZheng Fan default: 671766ce4d0SZheng Fan DBG_ERROR( "error!!" ); 672766ce4d0SZheng Fan break; 673766ce4d0SZheng Fan } 674766ce4d0SZheng Fan 675766ce4d0SZheng Fan mpBindings->GetDispatcher()->Execute( 676766ce4d0SZheng Fan SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 677766ce4d0SZheng Fan 678766ce4d0SZheng Fan mbUseLineSPCustom = USE_CUSTOM; 679766ce4d0SZheng Fan } 680766ce4d0SZheng Fan 681766ce4d0SZheng Fan void ParaLineSpacingControl::SetLineSpace( SvxLineSpacingItem& rLineSpace, 682766ce4d0SZheng Fan int eSpace, long lValue ) 683766ce4d0SZheng Fan { 684766ce4d0SZheng Fan switch ( eSpace ) 685766ce4d0SZheng Fan { 686766ce4d0SZheng Fan case LLINESPACE_1: 687766ce4d0SZheng Fan rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 688766ce4d0SZheng Fan rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 689766ce4d0SZheng Fan break; 690766ce4d0SZheng Fan 691766ce4d0SZheng Fan case LLINESPACE_15: 692766ce4d0SZheng Fan rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 693766ce4d0SZheng Fan rLineSpace.SetPropLineSpace( LINESPACE_15 ); 694766ce4d0SZheng Fan break; 695766ce4d0SZheng Fan 696766ce4d0SZheng Fan case LLINESPACE_2: 697766ce4d0SZheng Fan rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 698766ce4d0SZheng Fan rLineSpace.SetPropLineSpace( LINESPACE_2 ); 699766ce4d0SZheng Fan break; 700766ce4d0SZheng Fan 701766ce4d0SZheng Fan case LLINESPACE_PROP: 702766ce4d0SZheng Fan rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 703766ce4d0SZheng Fan rLineSpace.SetPropLineSpace( (sal_uInt8)lValue ); 704766ce4d0SZheng Fan break; 705766ce4d0SZheng Fan 706766ce4d0SZheng Fan case LLINESPACE_MIN: 707766ce4d0SZheng Fan rLineSpace.SetLineHeight( (sal_uInt16)lValue ); 708766ce4d0SZheng Fan rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 709766ce4d0SZheng Fan break; 710766ce4d0SZheng Fan 711766ce4d0SZheng Fan case LLINESPACE_DURCH: 712766ce4d0SZheng Fan rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 713766ce4d0SZheng Fan rLineSpace.SetInterLineSpace( (sal_uInt16)lValue ); 714766ce4d0SZheng Fan break; 715766ce4d0SZheng Fan 716766ce4d0SZheng Fan case LLINESPACE_FIX: 717766ce4d0SZheng Fan rLineSpace.SetLineHeight((sal_uInt16)lValue); 718766ce4d0SZheng Fan rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_FIX; 719766ce4d0SZheng Fan rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 720766ce4d0SZheng Fan break; 721766ce4d0SZheng Fan } 722766ce4d0SZheng Fan } 723766ce4d0SZheng Fan 724766ce4d0SZheng Fan IMPL_LINK(ParaLineSpacingControl, VSSelHdl, void *, pControl) 725766ce4d0SZheng Fan { 726766ce4d0SZheng Fan maLineSpacing.SetNoSelection(); 727766ce4d0SZheng Fan bool bClosePop = true; 728766ce4d0SZheng Fan if(pControl == &maLineSpacing) 729766ce4d0SZheng Fan { 730766ce4d0SZheng Fan sal_uInt16 iPos = maLineSpacing.GetSelectItemId(); 731766ce4d0SZheng Fan switch ( iPos ) 732766ce4d0SZheng Fan { 733766ce4d0SZheng Fan case 1: 734766ce4d0SZheng Fan ExecuteLineSpacing( 0, 0 ); 735766ce4d0SZheng Fan break; 736766ce4d0SZheng Fan case 2: 737766ce4d0SZheng Fan ExecuteLineSpacing( 0, 3 ); 738766ce4d0SZheng Fan break; 739766ce4d0SZheng Fan case 3: 740766ce4d0SZheng Fan ExecuteLineSpacing( 0, 1 ); 741766ce4d0SZheng Fan break; 742766ce4d0SZheng Fan case 4: 743766ce4d0SZheng Fan ExecuteLineSpacing( 0, 2 ); 744766ce4d0SZheng Fan break; 745766ce4d0SZheng Fan case 5: 746766ce4d0SZheng Fan { 747766ce4d0SZheng Fan if(!(mbLineSPDisable)) 748766ce4d0SZheng Fan { 749766ce4d0SZheng Fan //maPos = mrParaPropertyPanel.maLinePos; 750766ce4d0SZheng Fan aLineDist.SelectEntryPos( maPos ) ; 751766ce4d0SZheng Fan aLineDist.SaveValue(); 752766ce4d0SZheng Fan //maValue = mrParaPropertyPanel.maLineValue; 753766ce4d0SZheng Fan 754766ce4d0SZheng Fan SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 755766ce4d0SZheng Fan switch(maPos) 756766ce4d0SZheng Fan { 757766ce4d0SZheng Fan case LLINESPACE_1: 758766ce4d0SZheng Fan case LLINESPACE_15: 759766ce4d0SZheng Fan case LLINESPACE_2: 760766ce4d0SZheng Fan SetLineSpace( aSpacing, maPos ); 761766ce4d0SZheng Fan break; 762766ce4d0SZheng Fan 763766ce4d0SZheng Fan case LLINESPACE_PROP: 764766ce4d0SZheng Fan SetLineSpace( aSpacing, maPos, 765766ce4d0SZheng Fan aLineDistAtPercentBox.Denormalize( (long)maValue ) ); 766766ce4d0SZheng Fan break; 767766ce4d0SZheng Fan 768766ce4d0SZheng Fan case LLINESPACE_MIN: 769766ce4d0SZheng Fan case LLINESPACE_DURCH: 770766ce4d0SZheng Fan case LLINESPACE_FIX: 771766ce4d0SZheng Fan SetLineSpace( aSpacing, maPos, (long)maValue ); 772766ce4d0SZheng Fan break; 773766ce4d0SZheng Fan } 774766ce4d0SZheng Fan 775766ce4d0SZheng Fan mpBindings->GetDispatcher()->Execute( 776766ce4d0SZheng Fan SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 777766ce4d0SZheng Fan 778766ce4d0SZheng Fan ExecuteLineSpacing( USE_CUSTOM, 0 ); 779766ce4d0SZheng Fan } 780766ce4d0SZheng Fan else 781766ce4d0SZheng Fan bClosePop = sal_False; 782766ce4d0SZheng Fan } 783766ce4d0SZheng Fan break; 784766ce4d0SZheng Fan } 785766ce4d0SZheng Fan } 786766ce4d0SZheng Fan if(bClosePop) 787766ce4d0SZheng Fan mrParaPropertyPanel.EndSpacingPopupMode(); 788766ce4d0SZheng Fan return 0; 789766ce4d0SZheng Fan } 790766ce4d0SZheng Fan 791766ce4d0SZheng Fan void ParaLineSpacingControl::ExecuteLineSpacing( sal_uInt16 aIsCustom, sal_uInt16 aEntry ) 792766ce4d0SZheng Fan { 793766ce4d0SZheng Fan if( !aIsCustom ) 794766ce4d0SZheng Fan { 795766ce4d0SZheng Fan aLineDist.SelectEntryPos( aEntry ) ; 796766ce4d0SZheng Fan aLineDist.SaveValue(); 797766ce4d0SZheng Fan SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 798766ce4d0SZheng Fan sal_uInt16 nPos = aEntry; 799766ce4d0SZheng Fan if( aEntry == LLINESPACE_PROP ) 800766ce4d0SZheng Fan SetLineSpace( aSpacing, nPos, aLineDistAtPercentBox.Denormalize( (long)115 ) ); 801766ce4d0SZheng Fan else 802766ce4d0SZheng Fan SetLineSpace( aSpacing, nPos ); 803766ce4d0SZheng Fan 804766ce4d0SZheng Fan mpBindings->GetDispatcher()->Execute( 805766ce4d0SZheng Fan SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 806766ce4d0SZheng Fan } 807766ce4d0SZheng Fan 808766ce4d0SZheng Fan if( !aIsCustom ) 809766ce4d0SZheng Fan { 810766ce4d0SZheng Fan mbUseLineSPCustom = DO_NOT_CUSTOM; 811766ce4d0SZheng Fan mrParaPropertyPanel.EndSpacingPopupMode(); 812766ce4d0SZheng Fan } 813766ce4d0SZheng Fan maLineSpacing.SetNoSelection(); 814766ce4d0SZheng Fan } 815766ce4d0SZheng Fan 816766ce4d0SZheng Fan }} // end of namespace sidebar 817766ce4d0SZheng Fan 818