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/ResourceDefinitions.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 maSelSpacing1 (SVX_RES(IMG_SEL_SPACING1)), 71 maSelSpacing115 (SVX_RES(IMG_SEL_SPACING115)), 72 maSelSpacing15 (SVX_RES(IMG_SEL_SPACING15)), 73 maSelSpacing2 (SVX_RES(IMG_SEL_SPACING2)), 74 maImgCusGrey (SVX_RES(IMG_CUSTOM_GRAY)), 75 maImgCus (SVX_RES(IMG_CUSTOM)), 76 maStrCus (SVX_RES(STR_LCVALUE)), 77 pActLineDistFld ( &aLineDistAtPercentBox ), 78 nMinFixDist ( BEGIN_VALUE ), 79 maValue ( 0 ), 80 maPos ( 0 ), 81 maLineSpacing (ValueSetWithTextControl::IMAGE_TEXT,this, SVX_RES( LINE_SPACING ) ), 82 mpImg (NULL), 83 mpImgSel (NULL), 84 mpStr (NULL), 85 mpStrTip (NULL), 86 maLine (SVX_RES(STR_LSPACING)), 87 maOf (SVX_RES(STR_LS_OF)) 88 , mbUseLineSPCustom (0) 89 , mbLineSPDisable (0) 90 { 91 initial(); 92 FreeResource(); 93 mpBindings = mrParaPropertyPanel.GetBindings(); 94 // m_eLNSpaceUnit = mrParaPropertyPanel.maLNSpaceControl.GetCoreMetric(); 95 m_eLNSpaceUnit = SFX_MAPUNIT_100TH_MM; 96 } 97 ParaLineSpacingControl::~ParaLineSpacingControl() 98 { 99 delete[] mpImg; 100 delete[] mpImgSel; 101 delete[] mpStr; 102 delete[] mpStrTip; 103 } 104 105 void ParaLineSpacingControl::initial() 106 { 107 maLineSpacing.SetStyle( maLineSpacing.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT ); 108 109 maLineSpacing.SetControlBackground( 110 GetSettings().GetStyleSettings().GetHighContrastMode() 111 ? GetSettings().GetStyleSettings().GetMenuColor() 112 : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 113 maLineSpacing.SetColor( 114 GetSettings().GetStyleSettings().GetHighContrastMode() 115 ? GetSettings().GetStyleSettings().GetMenuColor() 116 : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 117 maLineSpacing.SetBackground( 118 GetSettings().GetStyleSettings().GetHighContrastMode() 119 ? GetSettings().GetStyleSettings().GetMenuColor() 120 : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 121 122 mpImg = new Image[4]; 123 mpImg[0] = maSpacing1; 124 mpImg[1] = maSpacing115; 125 mpImg[2] = maSpacing15; 126 mpImg[3] = maSpacing2; 127 128 mpImgSel = new Image[4]; 129 mpImgSel[0] = maSelSpacing1; 130 mpImgSel[1] = maSelSpacing115; 131 mpImgSel[2] = maSelSpacing15; 132 mpImgSel[3] = maSelSpacing2; 133 134 mpStr = new XubString[4]; 135 mpStr[0] = XubString(SVX_RES(STR_SPACING1)); 136 mpStr[1] = XubString(SVX_RES(STR_SPACING115)); 137 mpStr[2] = XubString(SVX_RES(STR_SPACING15)); 138 mpStr[3] = XubString(SVX_RES(STR_SPACING2)); 139 140 mpStrTip = new XubString[4]; 141 mpStrTip[0] = XubString(SVX_RES(STR_LS_SINGLE)); 142 mpStrTip[1] = XubString(SVX_RES(STR_LS_115)); 143 mpStrTip[2] = XubString(SVX_RES(STR_LS_15)); 144 mpStrTip[3] = XubString(SVX_RES(STR_LS_DOUBLE)); 145 for (int i=0;i<4;i++) 146 maLineSpacing.AddItem(mpImg[i], &mpImgSel[i],mpStr[i],&mpStrTip[i]); 147 148 maLineSpacing.AddItem( maImgCus, 0, maStrCus, 0 ); 149 150 SetAllNoSel(); 151 Link aLink = LINK(this, ParaLineSpacingControl,VSSelHdl ); 152 maLineSpacing.SetSelectHdl(aLink); 153 maLineSpacing.StartSelection(); 154 maLineSpacing.Show(); 155 156 aLink = LINK( this, ParaLineSpacingControl, LineSPDistHdl_Impl ); 157 aLineDist.SetSelectHdl(aLink); 158 aLineDist.SelectEntryPos( LLINESPACE_1 ) ; 159 aLink = LINK( this, ParaLineSpacingControl, LineSPDistAtHdl_Impl ); 160 aLineDistAtPercentBox.SetModifyHdl( aLink ); 161 aLineDistAtMetricBox.SetModifyHdl( aLink ); 162 } 163 164 165 void ParaLineSpacingControl::PopupModeEndCallback() 166 { 167 if( mbUseLineSPCustom ) 168 { 169 //maLinePos = mpLineSPPage->maPos; 170 //maLineValue = mpLineSPPage->maValue; 171 172 SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE ); 173 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1); 174 aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("maLinePos") ); 175 aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( maPos )); 176 aWinOpt.SetUserData( aSeq ); 177 178 SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE ); 179 aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("maLineValue") ); 180 aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( maValue )); 181 aWinOpt2.SetUserData( aSeq ); 182 } 183 } 184 185 void ParaLineSpacingControl::Rearrange(SfxItemState currSPState,FieldUnit currMetricUnit,SvxLineSpacingItem* currSPItem,const ::sfx2::sidebar::EnumContext currentContext) 186 { 187 SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE ); 188 if ( aWinOpt.Exists() ) 189 { 190 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData(); 191 ::rtl::OUString aTmp; 192 if ( aSeq.getLength()) 193 aSeq[0].Value >>= aTmp; 194 195 String aWinData( aTmp ); 196 maPos = (sal_uInt16)aWinData.ToInt32(); 197 } 198 199 SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE ); 200 if ( aWinOpt2.Exists() ) 201 { 202 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt2.GetUserData(); 203 ::rtl::OUString aTmp; 204 if ( aSeq.getLength()) 205 aSeq[0].Value >>= aTmp; 206 207 String aWinData( aTmp ); 208 maValue = (sal_uInt16)aWinData.ToInt32(); 209 } 210 String sHelpText; 211 switch(maPos) 212 { 213 case LLINESPACE_1: 214 sHelpText += mpStrTip[0]; 215 break; 216 case LLINESPACE_15: 217 sHelpText += mpStrTip[2]; 218 break; 219 case LLINESPACE_2: 220 sHelpText += mpStrTip[3]; 221 break; 222 case LLINESPACE_PROP: 223 sHelpText +=maLine; 224 sHelpText.Append(String("Proportion: ", 12, RTL_TEXTENCODING_ASCII_US)); 225 sHelpText += maOf; 226 sHelpText.Append( String::CreateFromInt64( maValue )); 227 break; 228 case LLINESPACE_MIN: 229 sHelpText += maLine; 230 sHelpText.Append(String("At Least: ", 10, RTL_TEXTENCODING_ASCII_US)); 231 sHelpText += maOf; 232 sHelpText.Append( String::CreateFromInt64( maValue )); 233 break; 234 case LLINESPACE_DURCH: 235 sHelpText += maLine; 236 sHelpText.Append(String("Leading: ", 9, RTL_TEXTENCODING_ASCII_US)); 237 sHelpText += maOf; 238 sHelpText.Append( String::CreateFromInt64( maValue )); 239 break; 240 case LLINESPACE_FIX: 241 sHelpText += maLine; 242 sHelpText.Append(String("Fixed: ", 7, RTL_TEXTENCODING_ASCII_US)); 243 sHelpText += maOf; 244 sHelpText.Append( String::CreateFromInt64( maValue )); 245 break; 246 } 247 if( !aWinOpt.Exists() && !aWinOpt2.Exists() ) 248 mbLineSPDisable = sal_True; 249 else 250 mbLineSPDisable = sal_False; 251 252 if( mbLineSPDisable ) 253 maLineSpacing.ReplaceItemImages(5, maImgCusGrey,0); 254 else 255 { 256 maLineSpacing.ReplaceItemImages(5, maImgCus,0); 257 maLineSpacing.SetItemText(5,sHelpText); 258 } 259 260 SfxItemState eState = currSPState; 261 262 SetFieldUnit( aLineDistAtMetricBox, currMetricUnit ); 263 264 // mpLineSPPage->SetAllNoSel(); 265 aLineDist.Enable(); 266 pActLineDistFld->Enable(); 267 pActLineDistFld->SetText( String() ); 268 bool bValueSetFocus = sal_False; //wj 269 270 if( eState >= SFX_ITEM_AVAILABLE ) 271 { 272 // SfxMapUnit eUnit = maLNSpaceControl.GetCoreMetric(); 273 SfxMapUnit eUnit = SFX_MAPUNIT_100TH_MM; 274 m_eLNSpaceUnit = eUnit; 275 276 switch( currSPItem->GetLineSpaceRule() ) 277 { 278 case SVX_LINE_SPACE_AUTO: 279 { 280 SvxInterLineSpace eInter = currSPItem->GetInterLineSpaceRule(); 281 282 switch( eInter ) 283 { 284 case SVX_INTER_LINE_SPACE_OFF: 285 { 286 aLineDist.SelectEntryPos( LLINESPACE_1 ); 287 pActLineDistFld->Disable(); 288 pActLineDistFld->SetText( String() ); 289 mbUseLineSPCustom = DO_NOT_CUSTOM; 290 if ( LINESPACE_1 == currSPItem->GetPropLineSpace() ) 291 { 292 maLineSpacing.SelectItem(1); 293 bValueSetFocus = sal_True; //wj 294 } 295 } 296 break; 297 298 case SVX_INTER_LINE_SPACE_PROP: 299 { 300 if ( LINESPACE_1 == currSPItem->GetPropLineSpace() ) 301 { 302 aLineDist.SelectEntryPos( LLINESPACE_1 ); 303 pActLineDistFld->Disable(); 304 pActLineDistFld->SetText( String() ); 305 mbUseLineSPCustom = DO_NOT_CUSTOM; 306 maLineSpacing.SelectItem(1); 307 bValueSetFocus = sal_True; //wj 308 break; 309 } 310 if ( LINESPACE_15 == currSPItem->GetPropLineSpace() ) 311 { 312 aLineDist.SelectEntryPos( LLINESPACE_15 ); 313 pActLineDistFld->Disable(); 314 pActLineDistFld->SetText( String() ); 315 316 mbUseLineSPCustom = DO_NOT_CUSTOM; 317 maLineSpacing.SelectItem(3); 318 bValueSetFocus = sal_True; //wj 319 break; 320 } 321 if ( LINESPACE_2 == currSPItem->GetPropLineSpace() ) 322 { 323 aLineDist.SelectEntryPos( LLINESPACE_2 ); 324 pActLineDistFld->Disable(); 325 pActLineDistFld->SetText( String() ); 326 327 mbUseLineSPCustom = DO_NOT_CUSTOM; 328 maLineSpacing.SelectItem(4); 329 bValueSetFocus = sal_True; //wj 330 break; 331 } 332 333 aLineDist.SelectEntryPos( LLINESPACE_PROP ); 334 if(pActLineDistFld != &(aLineDistAtPercentBox)) 335 { 336 pActLineDistFld->Disable(); 337 pActLineDistFld->Hide(); 338 pActLineDistFld = &(aLineDistAtPercentBox); 339 } 340 else 341 { 342 pActLineDistFld = &(aLineDistAtMetricBox); 343 pActLineDistFld->Disable(); 344 pActLineDistFld->Hide(); 345 pActLineDistFld = &(aLineDistAtPercentBox); 346 } 347 pActLineDistFld->Enable(); 348 pActLineDistFld->Show(); 349 aLineDistAtPercentBox. 350 SetValue( aLineDistAtPercentBox.Normalize( 351 currSPItem->GetPropLineSpace() ) ); 352 353 if( currSPItem->GetPropLineSpace() == LINESPACE_115 ) 354 { 355 mbUseLineSPCustom = DO_NOT_CUSTOM; 356 maLineSpacing.SelectItem(2); 357 bValueSetFocus = sal_True; //wj 358 } 359 else 360 { 361 mbUseLineSPCustom = USE_CUSTOM; 362 maLineSpacing.SetNoSelection(); 363 maLineSpacing.SelectItem(0); 364 } 365 } 366 break; 367 368 case SVX_INTER_LINE_SPACE_FIX: 369 { 370 if(pActLineDistFld != &(aLineDistAtMetricBox)) 371 { 372 pActLineDistFld->Disable(); 373 pActLineDistFld->Hide(); 374 pActLineDistFld = &(aLineDistAtMetricBox); 375 } 376 else 377 { 378 pActLineDistFld = &(aLineDistAtPercentBox); 379 pActLineDistFld->Disable(); 380 pActLineDistFld->Hide(); 381 pActLineDistFld = &(aLineDistAtMetricBox); 382 } 383 pActLineDistFld->Enable(); 384 pActLineDistFld->Show(); 385 maLineSpacing.SetNoSelection(); 386 maLineSpacing.SelectItem(0); 387 388 SetMetricValue( aLineDistAtMetricBox, 389 currSPItem->GetInterLineSpace(), eUnit ); 390 aLineDist.SelectEntryPos( LLINESPACE_DURCH ); 391 392 mbUseLineSPCustom = USE_CUSTOM; 393 } 394 break; 395 } 396 } 397 break; 398 case SVX_LINE_SPACE_FIX: 399 { 400 if(pActLineDistFld != &(aLineDistAtMetricBox)) 401 { 402 pActLineDistFld->Disable(); 403 pActLineDistFld->Hide(); 404 pActLineDistFld = &(aLineDistAtMetricBox); 405 } 406 else 407 { 408 pActLineDistFld = &(aLineDistAtPercentBox); 409 pActLineDistFld->Disable(); 410 pActLineDistFld->Hide(); 411 pActLineDistFld = &(aLineDistAtMetricBox); 412 } 413 pActLineDistFld->Enable(); 414 pActLineDistFld->Show(); 415 maLineSpacing.SetNoSelection(); 416 maLineSpacing.SelectItem(0); 417 418 SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit); 419 aLineDist.SelectEntryPos( LLINESPACE_FIX ); 420 421 mbUseLineSPCustom = USE_CUSTOM; 422 } 423 break; 424 425 case SVX_LINE_SPACE_MIN: 426 { 427 if(pActLineDistFld != &(aLineDistAtMetricBox)) 428 { 429 pActLineDistFld->Disable(); 430 pActLineDistFld->Hide(); 431 pActLineDistFld = &(aLineDistAtMetricBox); 432 } 433 else 434 { 435 pActLineDistFld = &(aLineDistAtPercentBox); 436 pActLineDistFld->Disable(); 437 pActLineDistFld->Hide(); 438 pActLineDistFld = &(aLineDistAtMetricBox); 439 } 440 pActLineDistFld->Enable(); 441 pActLineDistFld->Show(); 442 maLineSpacing.SetNoSelection(); 443 maLineSpacing.SelectItem(0); 444 445 SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit); 446 aLineDist.SelectEntryPos( LLINESPACE_MIN ); 447 mbUseLineSPCustom = USE_CUSTOM; 448 } 449 break; 450 } 451 } 452 else if( eState == SFX_ITEM_DISABLED ) 453 { 454 aLineDist.Disable(); 455 pActLineDistFld->Enable(sal_False); 456 pActLineDistFld->SetText( String() ); 457 maLineSpacing.SetNoSelection(); 458 maLineSpacing.SelectItem(0); 459 460 mbUseLineSPCustom = DO_NOT_CUSTOM; 461 } 462 else 463 { 464 pActLineDistFld->Enable(sal_False); 465 pActLineDistFld->SetText( String() ); 466 aLineDist.SetNoSelection(); 467 maLineSpacing.SetNoSelection(); 468 maLineSpacing.SelectItem(0); 469 mbUseLineSPCustom = DO_NOT_CUSTOM; 470 } 471 472 aLineDist.SaveValue(); 473 474 const sal_uInt16 uCount = aLineDist.GetEntryCount(); 475 if( uCount == LLINESPACE_FIX + 1 ) 476 { 477 switch (currentContext.GetCombinedContext_DI()) 478 { 479 case CombinedEnumContext(Application_DrawImpress, Context_Table): 480 case CombinedEnumContext(Application_DrawImpress, Context_DrawText): 481 case CombinedEnumContext(Application_DrawImpress, Context_Draw): 482 case CombinedEnumContext(Application_DrawImpress, Context_TextObject): 483 case CombinedEnumContext(Application_DrawImpress, Context_Graphic): 484 case CombinedEnumContext(Application_Calc, Context_DrawText): 485 case CombinedEnumContext(Application_WriterVariants, Context_DrawText): 486 case CombinedEnumContext(Application_WriterVariants, Context_Annotation): 487 { 488 aLineDist.RemoveEntry(LLINESPACE_FIX); 489 } 490 } 491 } 492 else if( uCount == LLINESPACE_FIX) 493 { 494 switch (currentContext.GetCombinedContext_DI()) 495 { 496 case CombinedEnumContext(Application_WriterVariants, Context_Default): 497 case CombinedEnumContext(Application_WriterVariants, Context_Text): 498 case CombinedEnumContext(Application_WriterVariants, Context_Table): 499 { 500 aLineDist.InsertEntry(String::CreateFromAscii("Fixed"), LLINESPACE_FIX); 501 } 502 } 503 } 504 maLineSpacing.Format(); 505 maLineSpacing.StartSelection(); 506 } 507 508 void ParaLineSpacingControl::SetAllNoSel() 509 { 510 maLineSpacing.SelectItem(1); 511 maLineSpacing.SetNoSelection(); 512 } 513 514 IMPL_LINK( ParaLineSpacingControl, LineSPDistHdl_Impl, ListBox*, pBox ) 515 { 516 maLineSpacing.SetNoSelection(); 517 maLineSpacing.SelectItem(0); 518 maLineSpacing.Format(); 519 maLineSpacing.StartSelection(); 520 521 switch( pBox->GetSelectEntryPos() ) 522 { 523 case LLINESPACE_1: 524 case LLINESPACE_15: 525 case LLINESPACE_2: 526 pActLineDistFld->Enable(sal_False); 527 pActLineDistFld->SetText( String() ); 528 break; 529 530 case LLINESPACE_DURCH: 531 aLineDistAtPercentBox.Hide(); 532 pActLineDistFld = &aLineDistAtMetricBox; 533 aLineDistAtMetricBox.SetMin(0); 534 535 536 if ( !aLineDistAtMetricBox.GetText().Len() ) 537 aLineDistAtMetricBox.SetValue( 538 aLineDistAtMetricBox.Normalize( 0 ) ); 539 aLineDistAtPercentBox.Hide(); 540 pActLineDistFld->Show(); 541 pActLineDistFld->Enable(); 542 break; 543 544 case LLINESPACE_MIN: 545 aLineDistAtPercentBox.Hide(); 546 pActLineDistFld = &aLineDistAtMetricBox; 547 aLineDistAtMetricBox.SetMin(0); 548 549 if ( !aLineDistAtMetricBox.GetText().Len() ) 550 aLineDistAtMetricBox.SetValue( 551 aLineDistAtMetricBox.Normalize( 0 ), FUNIT_TWIP ); 552 aLineDistAtPercentBox.Hide(); 553 pActLineDistFld->Show(); 554 pActLineDistFld->Enable(); 555 break; 556 557 case LLINESPACE_PROP: 558 aLineDistAtMetricBox.Hide(); 559 pActLineDistFld = &aLineDistAtPercentBox; 560 561 if ( !aLineDistAtPercentBox.GetText().Len() ) 562 aLineDistAtPercentBox.SetValue( 563 aLineDistAtPercentBox.Normalize( 100 ), FUNIT_TWIP ); 564 aLineDistAtMetricBox.Hide(); 565 pActLineDistFld->Show(); 566 pActLineDistFld->Enable(); 567 break; 568 case LLINESPACE_FIX: 569 { 570 aLineDistAtPercentBox.Hide(); 571 pActLineDistFld = &aLineDistAtMetricBox; 572 sal_Int64 nTemp = aLineDistAtMetricBox.GetValue(); 573 aLineDistAtMetricBox.SetMin(aLineDistAtMetricBox.Normalize(nMinFixDist), FUNIT_TWIP); 574 575 if ( aLineDistAtMetricBox.GetValue() != nTemp ) 576 SetMetricValue( aLineDistAtMetricBox, 577 FIX_DIST_DEF, SFX_MAPUNIT_TWIP ); 578 aLineDistAtPercentBox.Hide(); 579 pActLineDistFld->Show(); 580 pActLineDistFld->Enable(); 581 } 582 break; 583 } 584 ExecuteLineSpace(); 585 return 0; 586 } 587 588 IMPL_LINK( ParaLineSpacingControl, LineSPDistAtHdl_Impl, MetricField*, /* pBox */ ) 589 { 590 ExecuteLineSpace(); 591 return (0L); 592 } 593 594 void ParaLineSpacingControl::ExecuteLineSpace() 595 { 596 aLineDist.SaveValue(); 597 maLineSpacing.SetNoSelection(); 598 599 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 600 sal_uInt16 nPos = aLineDist.GetSelectEntryPos(); 601 602 switch ( nPos ) 603 { 604 case LLINESPACE_1: 605 case LLINESPACE_15: 606 case LLINESPACE_2: 607 { 608 SetLineSpace( aSpacing, nPos ); 609 maPos = nPos; 610 } 611 break; 612 613 case LLINESPACE_PROP: 614 { 615 SetLineSpace( aSpacing, nPos, 616 aLineDistAtPercentBox.Denormalize( 617 (long)aLineDistAtPercentBox.GetValue() ) ); 618 maPos = nPos; 619 maValue =aLineDistAtPercentBox.GetValue(); 620 } 621 break; 622 623 case LLINESPACE_MIN: 624 case LLINESPACE_DURCH: 625 case LLINESPACE_FIX: 626 { 627 SetLineSpace( aSpacing, nPos, 628 GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ) ); 629 maPos = nPos; 630 maValue = GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ); 631 } 632 break; 633 634 default: 635 DBG_ERROR( "error!!" ); 636 break; 637 } 638 639 mpBindings->GetDispatcher()->Execute( 640 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 641 642 mbUseLineSPCustom = USE_CUSTOM; 643 } 644 645 void ParaLineSpacingControl::SetLineSpace( SvxLineSpacingItem& rLineSpace, 646 int eSpace, long lValue ) 647 { 648 switch ( eSpace ) 649 { 650 case LLINESPACE_1: 651 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 652 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 653 break; 654 655 case LLINESPACE_15: 656 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 657 rLineSpace.SetPropLineSpace( LINESPACE_15 ); 658 break; 659 660 case LLINESPACE_2: 661 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 662 rLineSpace.SetPropLineSpace( LINESPACE_2 ); 663 break; 664 665 case LLINESPACE_PROP: 666 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 667 rLineSpace.SetPropLineSpace( (sal_uInt8)lValue ); 668 break; 669 670 case LLINESPACE_MIN: 671 rLineSpace.SetLineHeight( (sal_uInt16)lValue ); 672 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 673 break; 674 675 case LLINESPACE_DURCH: 676 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 677 rLineSpace.SetInterLineSpace( (sal_uInt16)lValue ); 678 break; 679 680 case LLINESPACE_FIX: 681 rLineSpace.SetLineHeight((sal_uInt16)lValue); 682 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_FIX; 683 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 684 break; 685 } 686 } 687 688 IMPL_LINK(ParaLineSpacingControl, VSSelHdl, void *, pControl) 689 { 690 maLineSpacing.SetNoSelection(); 691 bool bClosePop = true; 692 if(pControl == &maLineSpacing) 693 { 694 sal_uInt16 iPos = maLineSpacing.GetSelectItemId(); 695 switch ( iPos ) 696 { 697 case 1: 698 ExecuteLineSpacing( 0, 0 ); 699 break; 700 case 2: 701 ExecuteLineSpacing( 0, 3 ); 702 break; 703 case 3: 704 ExecuteLineSpacing( 0, 1 ); 705 break; 706 case 4: 707 ExecuteLineSpacing( 0, 2 ); 708 break; 709 case 5: 710 { 711 if(!(mbLineSPDisable)) 712 { 713 //maPos = mrParaPropertyPanel.maLinePos; 714 aLineDist.SelectEntryPos( maPos ) ; 715 aLineDist.SaveValue(); 716 //maValue = mrParaPropertyPanel.maLineValue; 717 718 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 719 switch(maPos) 720 { 721 case LLINESPACE_1: 722 case LLINESPACE_15: 723 case LLINESPACE_2: 724 SetLineSpace( aSpacing, maPos ); 725 break; 726 727 case LLINESPACE_PROP: 728 SetLineSpace( aSpacing, maPos, 729 aLineDistAtPercentBox.Denormalize( (long)maValue ) ); 730 break; 731 732 case LLINESPACE_MIN: 733 case LLINESPACE_DURCH: 734 case LLINESPACE_FIX: 735 SetLineSpace( aSpacing, maPos, (long)maValue ); 736 break; 737 } 738 739 mpBindings->GetDispatcher()->Execute( 740 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 741 742 ExecuteLineSpacing( USE_CUSTOM, 0 ); 743 } 744 else 745 bClosePop = sal_False; 746 } 747 break; 748 } 749 } 750 if(bClosePop) 751 mrParaPropertyPanel.EndSpacingPopupMode(); 752 return 0; 753 } 754 755 void ParaLineSpacingControl::ExecuteLineSpacing( sal_uInt16 aIsCustom, sal_uInt16 aEntry ) 756 { 757 if( !aIsCustom ) 758 { 759 aLineDist.SelectEntryPos( aEntry ) ; 760 aLineDist.SaveValue(); 761 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 762 sal_uInt16 nPos = aEntry; 763 if( aEntry == LLINESPACE_PROP ) 764 SetLineSpace( aSpacing, nPos, aLineDistAtPercentBox.Denormalize( (long)115 ) ); 765 else 766 SetLineSpace( aSpacing, nPos ); 767 768 mpBindings->GetDispatcher()->Execute( 769 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 770 } 771 772 if( !aIsCustom ) 773 { 774 mbUseLineSPCustom = DO_NOT_CUSTOM; 775 mrParaPropertyPanel.EndSpacingPopupMode(); 776 } 777 maLineSpacing.SetNoSelection(); 778 } 779 780 }} // end of namespace sidebar 781 782