1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #include "precompiled_svx.hxx" 23 #include "ParaLineSpacingControl.hxx" 24 #include "ParaPropertyPanel.hrc" 25 #include <sfx2/sidebar/propertypanel.hrc> 26 #include <svx/dialogs.hrc> 27 #include <svx/dialmgr.hxx> 28 #include <unotools/viewoptions.hxx> 29 #include <editeng/kernitem.hxx> 30 #include <sfx2/bindings.hxx> 31 #include <sfx2/dispatch.hxx> 32 #include <sfx2/sidebar/Theme.hxx> 33 #include <svtools/unitconv.hxx> 34 35 #define _DEFAULT_LINE_SPACING 200 36 #define FIX_DIST_DEF 283 37 #define LINESPACE_1 100 38 #define LINESPACE_15 150 39 #define LINESPACE_2 200 40 #define LINESPACE_115 115 41 42 #define LLINESPACE_1 0 43 #define LLINESPACE_15 1 44 #define LLINESPACE_2 2 45 #define LLINESPACE_PROP 3 46 #define LLINESPACE_MIN 4 47 #define LLINESPACE_DURCH 5 48 #define LLINESPACE_FIX 6 49 50 #define DO_NOT_CUSTOM 0 51 #define USE_CUSTOM 1 52 53 namespace svx { namespace sidebar { 54 55 56 ParaLineSpacingControl::ParaLineSpacingControl(Window* pParent, svx::sidebar::ParaPropertyPanel& rPanel) 57 : PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_LINESPACING)) 58 , mrParaPropertyPanel(rPanel) 59 , mpBindings(NULL) 60 ,aLineDist ( this, SVX_RES( LB_LINE_SPACING )), 61 aLineDistAtPercentBox ( this, SVX_RES( ED_SBINDE_LINEDISTPERCENT ) ), 62 aLineDistAtMetricBox ( this, SVX_RES( ED_SBINDE_LINEDISTPOINT ) ), 63 maCustomFT ( this, SVX_RES( FT_CUSTOM ) ), 64 maLSpacingFT ( this, SVX_RES( FT_LINE_SPACING ) ), 65 maOfFT ( this, SVX_RES( FT_OF ) ), 66 maSpacing1 (SVX_RES(IMG_SPACING1)), 67 maSpacing115 (SVX_RES(IMG_SPACING115)), 68 maSpacing15 (SVX_RES(IMG_SPACING15)), 69 maSpacing2 (SVX_RES(IMG_SPACING2)), 70 maLPCustom (SVX_RES(IMG_SPACINGLCUSTOM)), 71 maSelSpacing1 (SVX_RES(IMG_SEL_SPACING1)), 72 maSelSpacing115 (SVX_RES(IMG_SEL_SPACING115)), 73 maSelSpacing15 (SVX_RES(IMG_SEL_SPACING15)), 74 maSelSpacing2 (SVX_RES(IMG_SEL_SPACING2)), 75 maImgCusGrey (SVX_RES(IMG_CUSTOM_GRAY)), 76 maImgCus (SVX_RES(IMG_CUSTOM)), 77 maStrCus (SVX_RES(STR_LCVALUE)), 78 pActLineDistFld ( &aLineDistAtPercentBox ), 79 nMinFixDist ( BEGIN_VALUE ), 80 maValue ( 0 ), 81 maPos ( 0 ), 82 maLineSpacing (ValueSetWithTextControl::IMAGE_TEXT,this, SVX_RES( LINE_SPACING ) ), 83 mpImg (NULL), 84 mpImgSel (NULL), 85 mpStr (NULL), 86 mpStrTip (NULL), 87 maLine (SVX_RES(STR_LSPACING)), 88 maOf (SVX_RES(STR_LS_OF)) 89 , mbUseLineSPCustom (0) 90 , mbLineSPDisable (0) 91 { 92 initial(); 93 FreeResource(); 94 mpBindings = mrParaPropertyPanel.GetBindings(); 95 // m_eLNSpaceUnit = mrParaPropertyPanel.maLNSpaceControl.GetCoreMetric(); 96 m_eLNSpaceUnit = SFX_MAPUNIT_100TH_MM; 97 } 98 ParaLineSpacingControl::~ParaLineSpacingControl() 99 { 100 delete[] mpImg; 101 delete[] mpImgSel; 102 delete[] mpStr; 103 delete[] mpStrTip; 104 } 105 106 void ParaLineSpacingControl::initial() 107 { 108 //maLineSpacing.SetStyle( maLineSpacing.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT ); 109 //maLineSpacing.SetControlBackground(GetSettings().GetStyleSettings().GetMenuColor()); 110 //maLineSpacing.SetColor(GetSettings().GetStyleSettings().GetMenuColor()); 111 //maLineSpacing.SetMinFont(); 112 113 maLineSpacing.SetControlBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 114 GetSettings().GetStyleSettings().GetMenuColor(): 115 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 116 maLineSpacing.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()? 117 GetSettings().GetStyleSettings().GetMenuColor(): 118 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 119 maLineSpacing.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 120 GetSettings().GetStyleSettings().GetMenuColor(): 121 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 122 //maFTSpacing.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 123 //GetSettings().GetStyleSettings().GetMenuColor(): 124 //sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 125 //maFTBy.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 126 //GetSettings().GetStyleSettings().GetMenuColor(): 127 //sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 128 129 mpImg = new Image[4]; 130 mpImg[0] = maSpacing1; 131 mpImg[1] = maSpacing115; 132 mpImg[2] = maSpacing15; 133 mpImg[3] = maSpacing2; 134 135 mpImgSel = new Image[4]; 136 mpImgSel[0] = maSelSpacing1; 137 mpImgSel[1] = maSelSpacing115; 138 mpImgSel[2] = maSelSpacing15; 139 mpImgSel[3] = maSelSpacing2; 140 141 mpStr = new XubString[4]; 142 mpStr[0] = XubString(SVX_RES(STR_SPACING1)); 143 mpStr[1] = XubString(SVX_RES(STR_SPACING115)); 144 mpStr[2] = XubString(SVX_RES(STR_SPACING15)); 145 mpStr[3] = XubString(SVX_RES(STR_SPACING2)); 146 147 mpStrTip = new XubString[4]; 148 mpStrTip[0] = XubString(SVX_RES(STR_LS_SINGLE)); 149 mpStrTip[1] = XubString(SVX_RES(STR_LS_115)); 150 mpStrTip[2] = XubString(SVX_RES(STR_LS_15)); 151 mpStrTip[3] = XubString(SVX_RES(STR_LS_DOUBLE)); 152 for (int i=0;i<4;i++) 153 maLineSpacing.AddItem(mpImg[i], &mpImgSel[i],mpStr[i],&mpStrTip[i]); 154 155 maLineSpacing.InsertCustom(maImgCus, maImgCusGrey, maStrCus); 156 maLineSpacing.SetCustomTip(maStrCus); //Add 157 158 SetAllNoSel(); 159 Link aLink = LINK(this, ParaLineSpacingControl,VSSelHdl ); 160 maLineSpacing.SetSelectHdl(aLink); 161 maLineSpacing.StartSelection(); 162 maLineSpacing.Show(); 163 164 aLink = LINK( this, ParaLineSpacingControl, LineSPDistHdl_Impl ); 165 aLineDist.SetSelectHdl(aLink); 166 aLineDist.SelectEntryPos( LLINESPACE_1 ) ; 167 aLink = LINK( this, ParaLineSpacingControl, LineSPDistAtHdl_Impl ); 168 aLineDistAtPercentBox.SetModifyHdl( aLink ); 169 aLineDistAtMetricBox.SetModifyHdl( aLink ); 170 } 171 void ParaLineSpacingControl::ToGetFocus(bool bType) 172 { 173 if(!bType) 174 aLineDist.GrabFocus(); 175 else 176 maLineSpacing.GrabFocus(); //wj 177 } 178 179 void ParaLineSpacingControl::PopupModeEndCallback() 180 { 181 if( mbUseLineSPCustom ) 182 { 183 //maLinePos = mpLineSPPage->maPos; 184 //maLineValue = mpLineSPPage->maValue; 185 186 SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE ); 187 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1); 188 aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("maLinePos") ); 189 aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( maPos )); 190 aWinOpt.SetUserData( aSeq ); 191 192 SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE ); 193 aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("maLineValue") ); 194 aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( maValue )); 195 aWinOpt2.SetUserData( aSeq ); 196 } 197 } 198 199 void ParaLineSpacingControl::Rearrange(SfxItemState currSPState,FieldUnit currMetricUnit,SvxLineSpacingItem* currSPItem,const ::sfx2::sidebar::EnumContext currentContext) 200 { 201 SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE ); 202 if ( aWinOpt.Exists() ) 203 { 204 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData(); 205 ::rtl::OUString aTmp; 206 if ( aSeq.getLength()) 207 aSeq[0].Value >>= aTmp; 208 209 String aWinData( aTmp ); 210 maPos = (sal_uInt16)aWinData.ToInt32(); 211 } 212 213 SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE ); 214 if ( aWinOpt2.Exists() ) 215 { 216 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt2.GetUserData(); 217 ::rtl::OUString aTmp; 218 if ( aSeq.getLength()) 219 aSeq[0].Value >>= aTmp; 220 221 String aWinData( aTmp ); 222 maValue = (sal_uInt16)aWinData.ToInt32(); 223 } 224 String sHelpText; 225 switch(maPos) 226 { 227 case LLINESPACE_1: 228 sHelpText += mpStrTip[0]; 229 break; 230 case LLINESPACE_15: 231 sHelpText += mpStrTip[2]; 232 break; 233 case LLINESPACE_2: 234 sHelpText += mpStrTip[3]; 235 break; 236 case LLINESPACE_PROP: 237 sHelpText +=maLine; 238 sHelpText.Append(String("Proportion: ", 12, RTL_TEXTENCODING_ASCII_US)); 239 sHelpText += maOf; 240 sHelpText.Append( String::CreateFromInt64( maValue )); 241 break; 242 case LLINESPACE_MIN: 243 sHelpText += maLine; 244 sHelpText.Append(String("At Least: ", 10, RTL_TEXTENCODING_ASCII_US)); 245 sHelpText += maOf; 246 sHelpText.Append( String::CreateFromInt64( maValue )); 247 break; 248 case LLINESPACE_DURCH: 249 sHelpText += maLine; 250 sHelpText.Append(String("Leading: ", 9, RTL_TEXTENCODING_ASCII_US)); 251 sHelpText += maOf; 252 sHelpText.Append( String::CreateFromInt64( maValue )); 253 break; 254 case LLINESPACE_FIX: 255 sHelpText += maLine; 256 sHelpText.Append(String("Fixed: ", 7, RTL_TEXTENCODING_ASCII_US)); 257 sHelpText += maOf; 258 sHelpText.Append( String::CreateFromInt64( maValue )); 259 break; 260 } 261 if( !aWinOpt.Exists() && !aWinOpt2.Exists() ) 262 mbLineSPDisable = sal_True; 263 else 264 mbLineSPDisable = sal_False; 265 266 if( mbLineSPDisable ) 267 maLineSpacing.SetCusEnable(0); 268 else 269 { 270 maLineSpacing.SetCusEnable(1); 271 maLineSpacing.SetCustomTip(sHelpText,sal_True);//Modify for Sym2_7266 272 } 273 274 SfxItemState eState = currSPState; 275 276 SetFieldUnit( aLineDistAtMetricBox, currMetricUnit ); 277 278 // mpLineSPPage->SetAllNoSel(); 279 aLineDist.Enable(); 280 pActLineDistFld->Enable(); 281 pActLineDistFld->SetText( String() ); 282 bool bValueSetFocus = sal_False; //wj 283 284 if( eState >= SFX_ITEM_AVAILABLE ) 285 { 286 // SfxMapUnit eUnit = maLNSpaceControl.GetCoreMetric(); 287 SfxMapUnit eUnit = SFX_MAPUNIT_100TH_MM; 288 m_eLNSpaceUnit = eUnit; 289 290 switch( currSPItem->GetLineSpaceRule() ) 291 { 292 case SVX_LINE_SPACE_AUTO: 293 { 294 SvxInterLineSpace eInter = currSPItem->GetInterLineSpaceRule(); 295 296 switch( eInter ) 297 { 298 case SVX_INTER_LINE_SPACE_OFF: 299 { 300 aLineDist.SelectEntryPos( LLINESPACE_1 ); 301 pActLineDistFld->Disable(); 302 pActLineDistFld->SetText( String() ); 303 mbUseLineSPCustom = DO_NOT_CUSTOM; 304 if ( LINESPACE_1 == currSPItem->GetPropLineSpace() ) 305 { 306 maLineSpacing.SetSelItem(1); 307 bValueSetFocus = sal_True; //wj 308 } 309 } 310 break; 311 312 case SVX_INTER_LINE_SPACE_PROP: 313 { 314 if ( LINESPACE_1 == currSPItem->GetPropLineSpace() ) 315 { 316 aLineDist.SelectEntryPos( LLINESPACE_1 ); 317 pActLineDistFld->Disable(); 318 pActLineDistFld->SetText( String() ); 319 mbUseLineSPCustom = DO_NOT_CUSTOM; 320 maLineSpacing.SetSelItem(1); 321 bValueSetFocus = sal_True; //wj 322 break; 323 } 324 if ( LINESPACE_15 == currSPItem->GetPropLineSpace() ) 325 { 326 aLineDist.SelectEntryPos( LLINESPACE_15 ); 327 pActLineDistFld->Disable(); 328 pActLineDistFld->SetText( String() ); 329 330 mbUseLineSPCustom = DO_NOT_CUSTOM; 331 maLineSpacing.SetSelItem(3); 332 bValueSetFocus = sal_True; //wj 333 break; 334 } 335 if ( LINESPACE_2 == currSPItem->GetPropLineSpace() ) 336 { 337 aLineDist.SelectEntryPos( LLINESPACE_2 ); 338 pActLineDistFld->Disable(); 339 pActLineDistFld->SetText( String() ); 340 341 mbUseLineSPCustom = DO_NOT_CUSTOM; 342 maLineSpacing.SetSelItem(4); 343 bValueSetFocus = sal_True; //wj 344 break; 345 } 346 347 aLineDist.SelectEntryPos( LLINESPACE_PROP ); 348 if(pActLineDistFld != &(aLineDistAtPercentBox)) 349 { 350 pActLineDistFld->Disable(); 351 pActLineDistFld->Hide(); 352 pActLineDistFld = &(aLineDistAtPercentBox); 353 } 354 else 355 { 356 pActLineDistFld = &(aLineDistAtMetricBox); 357 pActLineDistFld->Disable(); 358 pActLineDistFld->Hide(); 359 pActLineDistFld = &(aLineDistAtPercentBox); 360 } 361 pActLineDistFld->Enable(); 362 pActLineDistFld->Show(); 363 aLineDistAtPercentBox. 364 SetValue( aLineDistAtPercentBox.Normalize( 365 currSPItem->GetPropLineSpace() ) ); 366 367 if( currSPItem->GetPropLineSpace() == LINESPACE_115 ) 368 { 369 mbUseLineSPCustom = DO_NOT_CUSTOM; 370 maLineSpacing.SetSelItem(2); 371 bValueSetFocus = sal_True; //wj 372 } 373 else 374 { 375 mbUseLineSPCustom = USE_CUSTOM; 376 maLineSpacing.SetSelItem(0); 377 } 378 } 379 break; 380 381 case SVX_INTER_LINE_SPACE_FIX: 382 { 383 if(pActLineDistFld != &(aLineDistAtMetricBox)) 384 { 385 pActLineDistFld->Disable(); 386 pActLineDistFld->Hide(); 387 pActLineDistFld = &(aLineDistAtMetricBox); 388 } 389 else 390 { 391 pActLineDistFld = &(aLineDistAtPercentBox); 392 pActLineDistFld->Disable(); 393 pActLineDistFld->Hide(); 394 pActLineDistFld = &(aLineDistAtMetricBox); 395 } 396 pActLineDistFld->Enable(); 397 pActLineDistFld->Show(); 398 maLineSpacing.SetSelItem(0); 399 400 SetMetricValue( aLineDistAtMetricBox, 401 currSPItem->GetInterLineSpace(), eUnit ); 402 aLineDist.SelectEntryPos( LLINESPACE_DURCH ); 403 404 mbUseLineSPCustom = USE_CUSTOM; 405 } 406 break; 407 } 408 } 409 break; 410 case SVX_LINE_SPACE_FIX: 411 { 412 if(pActLineDistFld != &(aLineDistAtMetricBox)) 413 { 414 pActLineDistFld->Disable(); 415 pActLineDistFld->Hide(); 416 pActLineDistFld = &(aLineDistAtMetricBox); 417 } 418 else 419 { 420 pActLineDistFld = &(aLineDistAtPercentBox); 421 pActLineDistFld->Disable(); 422 pActLineDistFld->Hide(); 423 pActLineDistFld = &(aLineDistAtMetricBox); 424 } 425 pActLineDistFld->Enable(); 426 pActLineDistFld->Show(); 427 maLineSpacing.SetSelItem(0); 428 429 SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit); 430 aLineDist.SelectEntryPos( LLINESPACE_FIX ); 431 432 mbUseLineSPCustom = USE_CUSTOM; 433 } 434 break; 435 436 case SVX_LINE_SPACE_MIN: 437 { 438 if(pActLineDistFld != &(aLineDistAtMetricBox)) 439 { 440 pActLineDistFld->Disable(); 441 pActLineDistFld->Hide(); 442 pActLineDistFld = &(aLineDistAtMetricBox); 443 } 444 else 445 { 446 pActLineDistFld = &(aLineDistAtPercentBox); 447 pActLineDistFld->Disable(); 448 pActLineDistFld->Hide(); 449 pActLineDistFld = &(aLineDistAtMetricBox); 450 } 451 pActLineDistFld->Enable(); 452 pActLineDistFld->Show(); 453 maLineSpacing.SetSelItem(0); 454 455 SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit); 456 aLineDist.SelectEntryPos( LLINESPACE_MIN ); 457 mbUseLineSPCustom = USE_CUSTOM; 458 } 459 break; 460 } 461 } 462 else if( eState == SFX_ITEM_DISABLED ) 463 { 464 aLineDist.Disable(); 465 pActLineDistFld->Enable(sal_False); 466 pActLineDistFld->SetText( String() ); 467 maLineSpacing.SetSelItem(0); 468 469 mbUseLineSPCustom = DO_NOT_CUSTOM; 470 } 471 else 472 { 473 pActLineDistFld->Enable(sal_False); 474 pActLineDistFld->SetText( String() ); 475 aLineDist.SetNoSelection(); 476 maLineSpacing.SetSelItem(0); 477 mbUseLineSPCustom = DO_NOT_CUSTOM; 478 } 479 480 aLineDist.SaveValue(); 481 482 /*sal_uInt16 nID = pBox->GetCurItemId(); 483 pBox->SetItemDown(nID, sal_True); 484 485 Size aFloatSz = GetOutputSizePixel(); 486 487 GetLineSPFloatWin()->SetSizePixel( aFloatSz ); 488 489 Point aPos=maLineSPTbx->GetPosPixel(); 490 aPos.setX(aPos.getX()); 491 aPos = OutputToScreenPixel( aPos ); 492 Size aSize = maLineSPTbx->GetSizePixel(); 493 Rectangle aRect( aPos, aSize ); 494 495 GetLineSPFloatWin()->StartPopupMode( aRect, FLOATWIN_POPUPMODE_DOWN | FLOATWIN_POPUPMODE_NOFOCUSCLOSE); 496 GetLineSPFloatWin()->SetPopupModeFlags(GetLineSPFloatWin()->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE ); 497 498 pLineSPPage->ToGetFocus(bValueSetFocus); 499 */ 500 sal_uInt16 uCount = aLineDist.GetEntryCount(); 501 if( uCount == LLINESPACE_FIX + 1 ) 502 { 503 switch (currentContext.GetCombinedContext()) 504 { 505 case CombinedEnumContext(Application_Impress, Context_Table): 506 case CombinedEnumContext(Application_Draw, Context_Table): 507 case CombinedEnumContext(Application_Writer, Context_DrawText): 508 case CombinedEnumContext(Application_Calc, Context_DrawText): 509 case CombinedEnumContext(Application_Draw, Context_DrawText): 510 case CombinedEnumContext(Application_Impress, Context_DrawText): 511 case CombinedEnumContext(Application_Writer, Context_Annotation): 512 case CombinedEnumContext(Application_Draw, Context_Draw): 513 case CombinedEnumContext(Application_Draw, Context_TextObject): 514 case CombinedEnumContext(Application_Draw, Context_Graphic): 515 case CombinedEnumContext(Application_Impress, Context_Draw): 516 case CombinedEnumContext(Application_Impress, Context_TextObject): 517 case CombinedEnumContext(Application_Impress, Context_Graphic): 518 { 519 aLineDist.RemoveEntry(LLINESPACE_FIX); 520 } 521 } 522 } 523 else if( uCount == LLINESPACE_FIX) 524 { 525 switch (currentContext.GetCombinedContext()) 526 { 527 case CombinedEnumContext(Application_Writer, Context_Default): 528 case CombinedEnumContext(Application_Writer, Context_Text): 529 case CombinedEnumContext(Application_Writer, Context_Table): 530 { 531 aLineDist.InsertEntry(String::CreateFromAscii("Fixed"), LLINESPACE_FIX); 532 } 533 } 534 } 535 maLineSpacing.Format(); 536 maLineSpacing.StartSelection(); 537 } 538 539 void ParaLineSpacingControl::SetAllNoSel() 540 { 541 maLineSpacing.SelectItem(1); //modified by wj for sym2_5397 542 maLineSpacing.SetNoSelection(); 543 } 544 545 IMPL_LINK( ParaLineSpacingControl, LineSPDistHdl_Impl, ListBox*, pBox ) 546 { 547 maLineSpacing.SetNoSelection(); 548 maLineSpacing.SetSelItem(0); 549 maLineSpacing.Format(); 550 maLineSpacing.StartSelection(); 551 552 switch( pBox->GetSelectEntryPos() ) 553 { 554 case LLINESPACE_1: 555 case LLINESPACE_15: 556 case LLINESPACE_2: 557 pActLineDistFld->Enable(sal_False); 558 pActLineDistFld->SetText( String() ); 559 break; 560 561 case LLINESPACE_DURCH: 562 aLineDistAtPercentBox.Hide(); 563 pActLineDistFld = &aLineDistAtMetricBox; 564 aLineDistAtMetricBox.SetMin(0); 565 566 567 if ( !aLineDistAtMetricBox.GetText().Len() ) 568 aLineDistAtMetricBox.SetValue( 569 aLineDistAtMetricBox.Normalize( 0 ) ); 570 aLineDistAtPercentBox.Hide(); 571 pActLineDistFld->Show(); 572 pActLineDistFld->Enable(); 573 break; 574 575 case LLINESPACE_MIN: 576 aLineDistAtPercentBox.Hide(); 577 pActLineDistFld = &aLineDistAtMetricBox; 578 aLineDistAtMetricBox.SetMin(0); 579 580 if ( !aLineDistAtMetricBox.GetText().Len() ) 581 aLineDistAtMetricBox.SetValue( 582 aLineDistAtMetricBox.Normalize( 0 ), FUNIT_TWIP ); 583 aLineDistAtPercentBox.Hide(); 584 pActLineDistFld->Show(); 585 pActLineDistFld->Enable(); 586 break; 587 588 case LLINESPACE_PROP: 589 aLineDistAtMetricBox.Hide(); 590 pActLineDistFld = &aLineDistAtPercentBox; 591 592 if ( !aLineDistAtPercentBox.GetText().Len() ) 593 aLineDistAtPercentBox.SetValue( 594 aLineDistAtPercentBox.Normalize( 100 ), FUNIT_TWIP ); 595 aLineDistAtMetricBox.Hide(); 596 pActLineDistFld->Show(); 597 pActLineDistFld->Enable(); 598 break; 599 case LLINESPACE_FIX: 600 { 601 aLineDistAtPercentBox.Hide(); 602 pActLineDistFld = &aLineDistAtMetricBox; 603 sal_Int64 nTemp = aLineDistAtMetricBox.GetValue(); 604 aLineDistAtMetricBox.SetMin(aLineDistAtMetricBox.Normalize(nMinFixDist), FUNIT_TWIP); 605 606 if ( aLineDistAtMetricBox.GetValue() != nTemp ) 607 SetMetricValue( aLineDistAtMetricBox, 608 FIX_DIST_DEF, SFX_MAPUNIT_TWIP ); 609 aLineDistAtPercentBox.Hide(); 610 pActLineDistFld->Show(); 611 pActLineDistFld->Enable(); 612 } 613 break; 614 } 615 ExecuteLineSpace(); 616 return 0; 617 } 618 619 IMPL_LINK( ParaLineSpacingControl, LineSPDistAtHdl_Impl, MetricField*, pBox ) 620 { 621 ExecuteLineSpace(); 622 return (0L); 623 } 624 625 void ParaLineSpacingControl::ExecuteLineSpace() 626 { 627 aLineDist.SaveValue(); 628 maLineSpacing.SetNoSelection(); 629 630 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 631 sal_uInt16 nPos = aLineDist.GetSelectEntryPos(); 632 633 switch ( nPos ) 634 { 635 case LLINESPACE_1: 636 case LLINESPACE_15: 637 case LLINESPACE_2: 638 { 639 SetLineSpace( aSpacing, nPos ); 640 maPos = nPos; 641 } 642 break; 643 644 case LLINESPACE_PROP: 645 { 646 SetLineSpace( aSpacing, nPos, 647 aLineDistAtPercentBox.Denormalize( 648 (long)aLineDistAtPercentBox.GetValue() ) ); 649 maPos = nPos; 650 maValue =aLineDistAtPercentBox.GetValue(); 651 } 652 break; 653 654 case LLINESPACE_MIN: 655 case LLINESPACE_DURCH: 656 case LLINESPACE_FIX: 657 { 658 SetLineSpace( aSpacing, nPos, 659 GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ) ); 660 maPos = nPos; 661 maValue = GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ); 662 } 663 break; 664 665 default: 666 DBG_ERROR( "error!!" ); 667 break; 668 } 669 670 mpBindings->GetDispatcher()->Execute( 671 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 672 673 mbUseLineSPCustom = USE_CUSTOM; 674 } 675 676 void ParaLineSpacingControl::SetLineSpace( SvxLineSpacingItem& rLineSpace, 677 int eSpace, long lValue ) 678 { 679 switch ( eSpace ) 680 { 681 case LLINESPACE_1: 682 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 683 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 684 break; 685 686 case LLINESPACE_15: 687 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 688 rLineSpace.SetPropLineSpace( LINESPACE_15 ); 689 break; 690 691 case LLINESPACE_2: 692 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 693 rLineSpace.SetPropLineSpace( LINESPACE_2 ); 694 break; 695 696 case LLINESPACE_PROP: 697 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 698 rLineSpace.SetPropLineSpace( (sal_uInt8)lValue ); 699 break; 700 701 case LLINESPACE_MIN: 702 rLineSpace.SetLineHeight( (sal_uInt16)lValue ); 703 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 704 break; 705 706 case LLINESPACE_DURCH: 707 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 708 rLineSpace.SetInterLineSpace( (sal_uInt16)lValue ); 709 break; 710 711 case LLINESPACE_FIX: 712 rLineSpace.SetLineHeight((sal_uInt16)lValue); 713 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_FIX; 714 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 715 break; 716 } 717 } 718 719 IMPL_LINK(ParaLineSpacingControl, VSSelHdl, void *, pControl) 720 { 721 maLineSpacing.SetNoSelection(); 722 bool bClosePop = true; 723 if(pControl == &maLineSpacing) 724 { 725 sal_uInt16 iPos = maLineSpacing.GetSelectItemId(); 726 short nKern = 0; 727 long nVal = 0; 728 switch ( iPos ) 729 { 730 case 1: 731 ExecuteLineSpacing( 0, 0 ); 732 break; 733 case 2: 734 ExecuteLineSpacing( 0, 3 ); 735 break; 736 case 3: 737 ExecuteLineSpacing( 0, 1 ); 738 break; 739 case 4: 740 ExecuteLineSpacing( 0, 2 ); 741 break; 742 case 5: 743 { 744 if(!(mbLineSPDisable)) 745 { 746 //maPos = mrParaPropertyPanel.maLinePos; 747 aLineDist.SelectEntryPos( maPos ) ; 748 aLineDist.SaveValue(); 749 //maValue = mrParaPropertyPanel.maLineValue; 750 751 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 752 switch(maPos) 753 { 754 case LLINESPACE_1: 755 case LLINESPACE_15: 756 case LLINESPACE_2: 757 SetLineSpace( aSpacing, maPos ); 758 break; 759 760 case LLINESPACE_PROP: 761 SetLineSpace( aSpacing, maPos, 762 aLineDistAtPercentBox.Denormalize( (long)maValue ) ); 763 break; 764 765 case LLINESPACE_MIN: 766 case LLINESPACE_DURCH: 767 case LLINESPACE_FIX: 768 SetLineSpace( aSpacing, maPos, (long)maValue ); 769 break; 770 } 771 772 mpBindings->GetDispatcher()->Execute( 773 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 774 775 ExecuteLineSpacing( USE_CUSTOM, 0 ); 776 } 777 else 778 bClosePop = sal_False; 779 } 780 break; 781 } 782 } 783 if(bClosePop) 784 mrParaPropertyPanel.EndSpacingPopupMode(); 785 return 0; 786 } 787 788 void ParaLineSpacingControl::ExecuteLineSpacing( sal_uInt16 aIsCustom, sal_uInt16 aEntry ) 789 { 790 if( !aIsCustom ) 791 { 792 aLineDist.SelectEntryPos( aEntry ) ; 793 aLineDist.SaveValue(); 794 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 795 sal_uInt16 nPos = aEntry; 796 if( aEntry == LLINESPACE_PROP ) 797 SetLineSpace( aSpacing, nPos, aLineDistAtPercentBox.Denormalize( (long)115 ) ); 798 else 799 SetLineSpace( aSpacing, nPos ); 800 801 mpBindings->GetDispatcher()->Execute( 802 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 803 } 804 805 if( !aIsCustom ) 806 { 807 mbUseLineSPCustom = DO_NOT_CUSTOM; 808 mrParaPropertyPanel.EndSpacingPopupMode(); 809 } 810 maLineSpacing.SetNoSelection(); 811 } 812 813 }} // end of namespace sidebar 814 815