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 sal_uInt16 uCount = aLineDist.GetEntryCount(); 475 if( uCount == LLINESPACE_FIX + 1 ) 476 { 477 switch (currentContext.GetCombinedContext()) 478 { 479 case CombinedEnumContext(Application_Impress, Context_Table): 480 case CombinedEnumContext(Application_Draw, Context_Table): 481 case CombinedEnumContext(Application_Writer, Context_DrawText): 482 case CombinedEnumContext(Application_Calc, Context_DrawText): 483 case CombinedEnumContext(Application_Draw, Context_DrawText): 484 case CombinedEnumContext(Application_Impress, Context_DrawText): 485 case CombinedEnumContext(Application_Writer, Context_Annotation): 486 case CombinedEnumContext(Application_Draw, Context_Draw): 487 case CombinedEnumContext(Application_Draw, Context_TextObject): 488 case CombinedEnumContext(Application_Draw, Context_Graphic): 489 case CombinedEnumContext(Application_Impress, Context_Draw): 490 case CombinedEnumContext(Application_Impress, Context_TextObject): 491 case CombinedEnumContext(Application_Impress, Context_Graphic): 492 { 493 aLineDist.RemoveEntry(LLINESPACE_FIX); 494 } 495 } 496 } 497 else if( uCount == LLINESPACE_FIX) 498 { 499 switch (currentContext.GetCombinedContext()) 500 { 501 case CombinedEnumContext(Application_Writer, Context_Default): 502 case CombinedEnumContext(Application_Writer, Context_Text): 503 case CombinedEnumContext(Application_Writer, Context_Table): 504 { 505 aLineDist.InsertEntry(String::CreateFromAscii("Fixed"), LLINESPACE_FIX); 506 } 507 } 508 } 509 maLineSpacing.Format(); 510 maLineSpacing.StartSelection(); 511 } 512 513 void ParaLineSpacingControl::SetAllNoSel() 514 { 515 maLineSpacing.SelectItem(1); 516 maLineSpacing.SetNoSelection(); 517 } 518 519 IMPL_LINK( ParaLineSpacingControl, LineSPDistHdl_Impl, ListBox*, pBox ) 520 { 521 maLineSpacing.SetNoSelection(); 522 maLineSpacing.SelectItem(0); 523 maLineSpacing.Format(); 524 maLineSpacing.StartSelection(); 525 526 switch( pBox->GetSelectEntryPos() ) 527 { 528 case LLINESPACE_1: 529 case LLINESPACE_15: 530 case LLINESPACE_2: 531 pActLineDistFld->Enable(sal_False); 532 pActLineDistFld->SetText( String() ); 533 break; 534 535 case LLINESPACE_DURCH: 536 aLineDistAtPercentBox.Hide(); 537 pActLineDistFld = &aLineDistAtMetricBox; 538 aLineDistAtMetricBox.SetMin(0); 539 540 541 if ( !aLineDistAtMetricBox.GetText().Len() ) 542 aLineDistAtMetricBox.SetValue( 543 aLineDistAtMetricBox.Normalize( 0 ) ); 544 aLineDistAtPercentBox.Hide(); 545 pActLineDistFld->Show(); 546 pActLineDistFld->Enable(); 547 break; 548 549 case LLINESPACE_MIN: 550 aLineDistAtPercentBox.Hide(); 551 pActLineDistFld = &aLineDistAtMetricBox; 552 aLineDistAtMetricBox.SetMin(0); 553 554 if ( !aLineDistAtMetricBox.GetText().Len() ) 555 aLineDistAtMetricBox.SetValue( 556 aLineDistAtMetricBox.Normalize( 0 ), FUNIT_TWIP ); 557 aLineDistAtPercentBox.Hide(); 558 pActLineDistFld->Show(); 559 pActLineDistFld->Enable(); 560 break; 561 562 case LLINESPACE_PROP: 563 aLineDistAtMetricBox.Hide(); 564 pActLineDistFld = &aLineDistAtPercentBox; 565 566 if ( !aLineDistAtPercentBox.GetText().Len() ) 567 aLineDistAtPercentBox.SetValue( 568 aLineDistAtPercentBox.Normalize( 100 ), FUNIT_TWIP ); 569 aLineDistAtMetricBox.Hide(); 570 pActLineDistFld->Show(); 571 pActLineDistFld->Enable(); 572 break; 573 case LLINESPACE_FIX: 574 { 575 aLineDistAtPercentBox.Hide(); 576 pActLineDistFld = &aLineDistAtMetricBox; 577 sal_Int64 nTemp = aLineDistAtMetricBox.GetValue(); 578 aLineDistAtMetricBox.SetMin(aLineDistAtMetricBox.Normalize(nMinFixDist), FUNIT_TWIP); 579 580 if ( aLineDistAtMetricBox.GetValue() != nTemp ) 581 SetMetricValue( aLineDistAtMetricBox, 582 FIX_DIST_DEF, SFX_MAPUNIT_TWIP ); 583 aLineDistAtPercentBox.Hide(); 584 pActLineDistFld->Show(); 585 pActLineDistFld->Enable(); 586 } 587 break; 588 } 589 ExecuteLineSpace(); 590 return 0; 591 } 592 593 IMPL_LINK( ParaLineSpacingControl, LineSPDistAtHdl_Impl, MetricField*, /* pBox */ ) 594 { 595 ExecuteLineSpace(); 596 return (0L); 597 } 598 599 void ParaLineSpacingControl::ExecuteLineSpace() 600 { 601 aLineDist.SaveValue(); 602 maLineSpacing.SetNoSelection(); 603 604 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 605 sal_uInt16 nPos = aLineDist.GetSelectEntryPos(); 606 607 switch ( nPos ) 608 { 609 case LLINESPACE_1: 610 case LLINESPACE_15: 611 case LLINESPACE_2: 612 { 613 SetLineSpace( aSpacing, nPos ); 614 maPos = nPos; 615 } 616 break; 617 618 case LLINESPACE_PROP: 619 { 620 SetLineSpace( aSpacing, nPos, 621 aLineDistAtPercentBox.Denormalize( 622 (long)aLineDistAtPercentBox.GetValue() ) ); 623 maPos = nPos; 624 maValue =aLineDistAtPercentBox.GetValue(); 625 } 626 break; 627 628 case LLINESPACE_MIN: 629 case LLINESPACE_DURCH: 630 case LLINESPACE_FIX: 631 { 632 SetLineSpace( aSpacing, nPos, 633 GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ) ); 634 maPos = nPos; 635 maValue = GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ); 636 } 637 break; 638 639 default: 640 DBG_ERROR( "error!!" ); 641 break; 642 } 643 644 mpBindings->GetDispatcher()->Execute( 645 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 646 647 mbUseLineSPCustom = USE_CUSTOM; 648 } 649 650 void ParaLineSpacingControl::SetLineSpace( SvxLineSpacingItem& rLineSpace, 651 int eSpace, long lValue ) 652 { 653 switch ( eSpace ) 654 { 655 case LLINESPACE_1: 656 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 657 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 658 break; 659 660 case LLINESPACE_15: 661 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 662 rLineSpace.SetPropLineSpace( LINESPACE_15 ); 663 break; 664 665 case LLINESPACE_2: 666 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 667 rLineSpace.SetPropLineSpace( LINESPACE_2 ); 668 break; 669 670 case LLINESPACE_PROP: 671 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 672 rLineSpace.SetPropLineSpace( (sal_uInt8)lValue ); 673 break; 674 675 case LLINESPACE_MIN: 676 rLineSpace.SetLineHeight( (sal_uInt16)lValue ); 677 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 678 break; 679 680 case LLINESPACE_DURCH: 681 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 682 rLineSpace.SetInterLineSpace( (sal_uInt16)lValue ); 683 break; 684 685 case LLINESPACE_FIX: 686 rLineSpace.SetLineHeight((sal_uInt16)lValue); 687 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_FIX; 688 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 689 break; 690 } 691 } 692 693 IMPL_LINK(ParaLineSpacingControl, VSSelHdl, void *, pControl) 694 { 695 maLineSpacing.SetNoSelection(); 696 bool bClosePop = true; 697 if(pControl == &maLineSpacing) 698 { 699 sal_uInt16 iPos = maLineSpacing.GetSelectItemId(); 700 switch ( iPos ) 701 { 702 case 1: 703 ExecuteLineSpacing( 0, 0 ); 704 break; 705 case 2: 706 ExecuteLineSpacing( 0, 3 ); 707 break; 708 case 3: 709 ExecuteLineSpacing( 0, 1 ); 710 break; 711 case 4: 712 ExecuteLineSpacing( 0, 2 ); 713 break; 714 case 5: 715 { 716 if(!(mbLineSPDisable)) 717 { 718 //maPos = mrParaPropertyPanel.maLinePos; 719 aLineDist.SelectEntryPos( maPos ) ; 720 aLineDist.SaveValue(); 721 //maValue = mrParaPropertyPanel.maLineValue; 722 723 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 724 switch(maPos) 725 { 726 case LLINESPACE_1: 727 case LLINESPACE_15: 728 case LLINESPACE_2: 729 SetLineSpace( aSpacing, maPos ); 730 break; 731 732 case LLINESPACE_PROP: 733 SetLineSpace( aSpacing, maPos, 734 aLineDistAtPercentBox.Denormalize( (long)maValue ) ); 735 break; 736 737 case LLINESPACE_MIN: 738 case LLINESPACE_DURCH: 739 case LLINESPACE_FIX: 740 SetLineSpace( aSpacing, maPos, (long)maValue ); 741 break; 742 } 743 744 mpBindings->GetDispatcher()->Execute( 745 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 746 747 ExecuteLineSpacing( USE_CUSTOM, 0 ); 748 } 749 else 750 bClosePop = sal_False; 751 } 752 break; 753 } 754 } 755 if(bClosePop) 756 mrParaPropertyPanel.EndSpacingPopupMode(); 757 return 0; 758 } 759 760 void ParaLineSpacingControl::ExecuteLineSpacing( sal_uInt16 aIsCustom, sal_uInt16 aEntry ) 761 { 762 if( !aIsCustom ) 763 { 764 aLineDist.SelectEntryPos( aEntry ) ; 765 aLineDist.SaveValue(); 766 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 767 sal_uInt16 nPos = aEntry; 768 if( aEntry == LLINESPACE_PROP ) 769 SetLineSpace( aSpacing, nPos, aLineDistAtPercentBox.Denormalize( (long)115 ) ); 770 else 771 SetLineSpace( aSpacing, nPos ); 772 773 mpBindings->GetDispatcher()->Execute( 774 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 775 } 776 777 if( !aIsCustom ) 778 { 779 mbUseLineSPCustom = DO_NOT_CUSTOM; 780 mrParaPropertyPanel.EndSpacingPopupMode(); 781 } 782 maLineSpacing.SetNoSelection(); 783 } 784 785 }} // end of namespace sidebar 786 787