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.AddItem( maImgCus, 0, maStrCus, 0 ); 156 157 SetAllNoSel(); 158 Link aLink = LINK(this, ParaLineSpacingControl,VSSelHdl ); 159 maLineSpacing.SetSelectHdl(aLink); 160 maLineSpacing.StartSelection(); 161 maLineSpacing.Show(); 162 163 aLink = LINK( this, ParaLineSpacingControl, LineSPDistHdl_Impl ); 164 aLineDist.SetSelectHdl(aLink); 165 aLineDist.SelectEntryPos( LLINESPACE_1 ) ; 166 aLink = LINK( this, ParaLineSpacingControl, LineSPDistAtHdl_Impl ); 167 aLineDistAtPercentBox.SetModifyHdl( aLink ); 168 aLineDistAtMetricBox.SetModifyHdl( aLink ); 169 } 170 void ParaLineSpacingControl::ToGetFocus(bool bType) 171 { 172 if(!bType) 173 aLineDist.GrabFocus(); 174 else 175 maLineSpacing.GrabFocus(); //wj 176 } 177 178 void ParaLineSpacingControl::PopupModeEndCallback() 179 { 180 if( mbUseLineSPCustom ) 181 { 182 //maLinePos = mpLineSPPage->maPos; 183 //maLineValue = mpLineSPPage->maValue; 184 185 SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE ); 186 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1); 187 aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("maLinePos") ); 188 aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( maPos )); 189 aWinOpt.SetUserData( aSeq ); 190 191 SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE ); 192 aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("maLineValue") ); 193 aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( maValue )); 194 aWinOpt2.SetUserData( aSeq ); 195 } 196 } 197 198 void ParaLineSpacingControl::Rearrange(SfxItemState currSPState,FieldUnit currMetricUnit,SvxLineSpacingItem* currSPItem,const ::sfx2::sidebar::EnumContext currentContext) 199 { 200 SvtViewOptions aWinOpt( E_WINDOW, LSP_POS_GLOBAL_VALUE ); 201 if ( aWinOpt.Exists() ) 202 { 203 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData(); 204 ::rtl::OUString aTmp; 205 if ( aSeq.getLength()) 206 aSeq[0].Value >>= aTmp; 207 208 String aWinData( aTmp ); 209 maPos = (sal_uInt16)aWinData.ToInt32(); 210 } 211 212 SvtViewOptions aWinOpt2( E_WINDOW, LSP_LV_GLOBAL_VALUE ); 213 if ( aWinOpt2.Exists() ) 214 { 215 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt2.GetUserData(); 216 ::rtl::OUString aTmp; 217 if ( aSeq.getLength()) 218 aSeq[0].Value >>= aTmp; 219 220 String aWinData( aTmp ); 221 maValue = (sal_uInt16)aWinData.ToInt32(); 222 } 223 String sHelpText; 224 switch(maPos) 225 { 226 case LLINESPACE_1: 227 sHelpText += mpStrTip[0]; 228 break; 229 case LLINESPACE_15: 230 sHelpText += mpStrTip[2]; 231 break; 232 case LLINESPACE_2: 233 sHelpText += mpStrTip[3]; 234 break; 235 case LLINESPACE_PROP: 236 sHelpText +=maLine; 237 sHelpText.Append(String("Proportion: ", 12, RTL_TEXTENCODING_ASCII_US)); 238 sHelpText += maOf; 239 sHelpText.Append( String::CreateFromInt64( maValue )); 240 break; 241 case LLINESPACE_MIN: 242 sHelpText += maLine; 243 sHelpText.Append(String("At Least: ", 10, RTL_TEXTENCODING_ASCII_US)); 244 sHelpText += maOf; 245 sHelpText.Append( String::CreateFromInt64( maValue )); 246 break; 247 case LLINESPACE_DURCH: 248 sHelpText += maLine; 249 sHelpText.Append(String("Leading: ", 9, RTL_TEXTENCODING_ASCII_US)); 250 sHelpText += maOf; 251 sHelpText.Append( String::CreateFromInt64( maValue )); 252 break; 253 case LLINESPACE_FIX: 254 sHelpText += maLine; 255 sHelpText.Append(String("Fixed: ", 7, RTL_TEXTENCODING_ASCII_US)); 256 sHelpText += maOf; 257 sHelpText.Append( String::CreateFromInt64( maValue )); 258 break; 259 } 260 if( !aWinOpt.Exists() && !aWinOpt2.Exists() ) 261 mbLineSPDisable = sal_True; 262 else 263 mbLineSPDisable = sal_False; 264 265 if( mbLineSPDisable ) 266 maLineSpacing.ReplaceItemImages(5, maImgCusGrey,0); 267 else 268 { 269 maLineSpacing.ReplaceItemImages(5, maImgCus,0); 270 maLineSpacing.SetItemText(5,sHelpText); 271 } 272 273 SfxItemState eState = currSPState; 274 275 SetFieldUnit( aLineDistAtMetricBox, currMetricUnit ); 276 277 // mpLineSPPage->SetAllNoSel(); 278 aLineDist.Enable(); 279 pActLineDistFld->Enable(); 280 pActLineDistFld->SetText( String() ); 281 bool bValueSetFocus = sal_False; //wj 282 283 if( eState >= SFX_ITEM_AVAILABLE ) 284 { 285 // SfxMapUnit eUnit = maLNSpaceControl.GetCoreMetric(); 286 SfxMapUnit eUnit = SFX_MAPUNIT_100TH_MM; 287 m_eLNSpaceUnit = eUnit; 288 289 switch( currSPItem->GetLineSpaceRule() ) 290 { 291 case SVX_LINE_SPACE_AUTO: 292 { 293 SvxInterLineSpace eInter = currSPItem->GetInterLineSpaceRule(); 294 295 switch( eInter ) 296 { 297 case SVX_INTER_LINE_SPACE_OFF: 298 { 299 aLineDist.SelectEntryPos( LLINESPACE_1 ); 300 pActLineDistFld->Disable(); 301 pActLineDistFld->SetText( String() ); 302 mbUseLineSPCustom = DO_NOT_CUSTOM; 303 if ( LINESPACE_1 == currSPItem->GetPropLineSpace() ) 304 { 305 maLineSpacing.SelectItem(1); 306 bValueSetFocus = sal_True; //wj 307 } 308 } 309 break; 310 311 case SVX_INTER_LINE_SPACE_PROP: 312 { 313 if ( LINESPACE_1 == currSPItem->GetPropLineSpace() ) 314 { 315 aLineDist.SelectEntryPos( LLINESPACE_1 ); 316 pActLineDistFld->Disable(); 317 pActLineDistFld->SetText( String() ); 318 mbUseLineSPCustom = DO_NOT_CUSTOM; 319 maLineSpacing.SelectItem(1); 320 bValueSetFocus = sal_True; //wj 321 break; 322 } 323 if ( LINESPACE_15 == currSPItem->GetPropLineSpace() ) 324 { 325 aLineDist.SelectEntryPos( LLINESPACE_15 ); 326 pActLineDistFld->Disable(); 327 pActLineDistFld->SetText( String() ); 328 329 mbUseLineSPCustom = DO_NOT_CUSTOM; 330 maLineSpacing.SelectItem(3); 331 bValueSetFocus = sal_True; //wj 332 break; 333 } 334 if ( LINESPACE_2 == currSPItem->GetPropLineSpace() ) 335 { 336 aLineDist.SelectEntryPos( LLINESPACE_2 ); 337 pActLineDistFld->Disable(); 338 pActLineDistFld->SetText( String() ); 339 340 mbUseLineSPCustom = DO_NOT_CUSTOM; 341 maLineSpacing.SelectItem(4); 342 bValueSetFocus = sal_True; //wj 343 break; 344 } 345 346 aLineDist.SelectEntryPos( LLINESPACE_PROP ); 347 if(pActLineDistFld != &(aLineDistAtPercentBox)) 348 { 349 pActLineDistFld->Disable(); 350 pActLineDistFld->Hide(); 351 pActLineDistFld = &(aLineDistAtPercentBox); 352 } 353 else 354 { 355 pActLineDistFld = &(aLineDistAtMetricBox); 356 pActLineDistFld->Disable(); 357 pActLineDistFld->Hide(); 358 pActLineDistFld = &(aLineDistAtPercentBox); 359 } 360 pActLineDistFld->Enable(); 361 pActLineDistFld->Show(); 362 aLineDistAtPercentBox. 363 SetValue( aLineDistAtPercentBox.Normalize( 364 currSPItem->GetPropLineSpace() ) ); 365 366 if( currSPItem->GetPropLineSpace() == LINESPACE_115 ) 367 { 368 mbUseLineSPCustom = DO_NOT_CUSTOM; 369 maLineSpacing.SelectItem(2); 370 bValueSetFocus = sal_True; //wj 371 } 372 else 373 { 374 mbUseLineSPCustom = USE_CUSTOM; 375 maLineSpacing.SetNoSelection(); 376 maLineSpacing.SelectItem(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.SetNoSelection(); 399 maLineSpacing.SelectItem(0); 400 401 SetMetricValue( aLineDistAtMetricBox, 402 currSPItem->GetInterLineSpace(), eUnit ); 403 aLineDist.SelectEntryPos( LLINESPACE_DURCH ); 404 405 mbUseLineSPCustom = USE_CUSTOM; 406 } 407 break; 408 } 409 } 410 break; 411 case SVX_LINE_SPACE_FIX: 412 { 413 if(pActLineDistFld != &(aLineDistAtMetricBox)) 414 { 415 pActLineDistFld->Disable(); 416 pActLineDistFld->Hide(); 417 pActLineDistFld = &(aLineDistAtMetricBox); 418 } 419 else 420 { 421 pActLineDistFld = &(aLineDistAtPercentBox); 422 pActLineDistFld->Disable(); 423 pActLineDistFld->Hide(); 424 pActLineDistFld = &(aLineDistAtMetricBox); 425 } 426 pActLineDistFld->Enable(); 427 pActLineDistFld->Show(); 428 maLineSpacing.SetNoSelection(); 429 maLineSpacing.SelectItem(0); 430 431 SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit); 432 aLineDist.SelectEntryPos( LLINESPACE_FIX ); 433 434 mbUseLineSPCustom = USE_CUSTOM; 435 } 436 break; 437 438 case SVX_LINE_SPACE_MIN: 439 { 440 if(pActLineDistFld != &(aLineDistAtMetricBox)) 441 { 442 pActLineDistFld->Disable(); 443 pActLineDistFld->Hide(); 444 pActLineDistFld = &(aLineDistAtMetricBox); 445 } 446 else 447 { 448 pActLineDistFld = &(aLineDistAtPercentBox); 449 pActLineDistFld->Disable(); 450 pActLineDistFld->Hide(); 451 pActLineDistFld = &(aLineDistAtMetricBox); 452 } 453 pActLineDistFld->Enable(); 454 pActLineDistFld->Show(); 455 maLineSpacing.SetNoSelection(); 456 maLineSpacing.SelectItem(0); 457 458 SetMetricValue(aLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit); 459 aLineDist.SelectEntryPos( LLINESPACE_MIN ); 460 mbUseLineSPCustom = USE_CUSTOM; 461 } 462 break; 463 } 464 } 465 else if( eState == SFX_ITEM_DISABLED ) 466 { 467 aLineDist.Disable(); 468 pActLineDistFld->Enable(sal_False); 469 pActLineDistFld->SetText( String() ); 470 maLineSpacing.SetNoSelection(); 471 maLineSpacing.SelectItem(0); 472 473 mbUseLineSPCustom = DO_NOT_CUSTOM; 474 } 475 else 476 { 477 pActLineDistFld->Enable(sal_False); 478 pActLineDistFld->SetText( String() ); 479 aLineDist.SetNoSelection(); 480 maLineSpacing.SetNoSelection(); 481 maLineSpacing.SelectItem(0); 482 mbUseLineSPCustom = DO_NOT_CUSTOM; 483 } 484 485 aLineDist.SaveValue(); 486 487 /*sal_uInt16 nID = pBox->GetCurItemId(); 488 pBox->SetItemDown(nID, sal_True); 489 490 Size aFloatSz = GetOutputSizePixel(); 491 492 GetLineSPFloatWin()->SetSizePixel( aFloatSz ); 493 494 Point aPos=maLineSPTbx->GetPosPixel(); 495 aPos.setX(aPos.getX()); 496 aPos = OutputToScreenPixel( aPos ); 497 Size aSize = maLineSPTbx->GetSizePixel(); 498 Rectangle aRect( aPos, aSize ); 499 500 GetLineSPFloatWin()->StartPopupMode( aRect, FLOATWIN_POPUPMODE_DOWN | FLOATWIN_POPUPMODE_NOFOCUSCLOSE); 501 GetLineSPFloatWin()->SetPopupModeFlags(GetLineSPFloatWin()->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE ); 502 503 pLineSPPage->ToGetFocus(bValueSetFocus); 504 */ 505 sal_uInt16 uCount = aLineDist.GetEntryCount(); 506 if( uCount == LLINESPACE_FIX + 1 ) 507 { 508 switch (currentContext.GetCombinedContext()) 509 { 510 case CombinedEnumContext(Application_Impress, Context_Table): 511 case CombinedEnumContext(Application_Draw, Context_Table): 512 case CombinedEnumContext(Application_Writer, Context_DrawText): 513 case CombinedEnumContext(Application_Calc, Context_DrawText): 514 case CombinedEnumContext(Application_Draw, Context_DrawText): 515 case CombinedEnumContext(Application_Impress, Context_DrawText): 516 case CombinedEnumContext(Application_Writer, Context_Annotation): 517 case CombinedEnumContext(Application_Draw, Context_Draw): 518 case CombinedEnumContext(Application_Draw, Context_TextObject): 519 case CombinedEnumContext(Application_Draw, Context_Graphic): 520 case CombinedEnumContext(Application_Impress, Context_Draw): 521 case CombinedEnumContext(Application_Impress, Context_TextObject): 522 case CombinedEnumContext(Application_Impress, Context_Graphic): 523 { 524 aLineDist.RemoveEntry(LLINESPACE_FIX); 525 } 526 } 527 } 528 else if( uCount == LLINESPACE_FIX) 529 { 530 switch (currentContext.GetCombinedContext()) 531 { 532 case CombinedEnumContext(Application_Writer, Context_Default): 533 case CombinedEnumContext(Application_Writer, Context_Text): 534 case CombinedEnumContext(Application_Writer, Context_Table): 535 { 536 aLineDist.InsertEntry(String::CreateFromAscii("Fixed"), LLINESPACE_FIX); 537 } 538 } 539 } 540 maLineSpacing.Format(); 541 maLineSpacing.StartSelection(); 542 } 543 544 void ParaLineSpacingControl::SetAllNoSel() 545 { 546 maLineSpacing.SelectItem(1); 547 maLineSpacing.SetNoSelection(); 548 } 549 550 IMPL_LINK( ParaLineSpacingControl, LineSPDistHdl_Impl, ListBox*, pBox ) 551 { 552 maLineSpacing.SetNoSelection(); 553 maLineSpacing.SelectItem(0); 554 maLineSpacing.Format(); 555 maLineSpacing.StartSelection(); 556 557 switch( pBox->GetSelectEntryPos() ) 558 { 559 case LLINESPACE_1: 560 case LLINESPACE_15: 561 case LLINESPACE_2: 562 pActLineDistFld->Enable(sal_False); 563 pActLineDistFld->SetText( String() ); 564 break; 565 566 case LLINESPACE_DURCH: 567 aLineDistAtPercentBox.Hide(); 568 pActLineDistFld = &aLineDistAtMetricBox; 569 aLineDistAtMetricBox.SetMin(0); 570 571 572 if ( !aLineDistAtMetricBox.GetText().Len() ) 573 aLineDistAtMetricBox.SetValue( 574 aLineDistAtMetricBox.Normalize( 0 ) ); 575 aLineDistAtPercentBox.Hide(); 576 pActLineDistFld->Show(); 577 pActLineDistFld->Enable(); 578 break; 579 580 case LLINESPACE_MIN: 581 aLineDistAtPercentBox.Hide(); 582 pActLineDistFld = &aLineDistAtMetricBox; 583 aLineDistAtMetricBox.SetMin(0); 584 585 if ( !aLineDistAtMetricBox.GetText().Len() ) 586 aLineDistAtMetricBox.SetValue( 587 aLineDistAtMetricBox.Normalize( 0 ), FUNIT_TWIP ); 588 aLineDistAtPercentBox.Hide(); 589 pActLineDistFld->Show(); 590 pActLineDistFld->Enable(); 591 break; 592 593 case LLINESPACE_PROP: 594 aLineDistAtMetricBox.Hide(); 595 pActLineDistFld = &aLineDistAtPercentBox; 596 597 if ( !aLineDistAtPercentBox.GetText().Len() ) 598 aLineDistAtPercentBox.SetValue( 599 aLineDistAtPercentBox.Normalize( 100 ), FUNIT_TWIP ); 600 aLineDistAtMetricBox.Hide(); 601 pActLineDistFld->Show(); 602 pActLineDistFld->Enable(); 603 break; 604 case LLINESPACE_FIX: 605 { 606 aLineDistAtPercentBox.Hide(); 607 pActLineDistFld = &aLineDistAtMetricBox; 608 sal_Int64 nTemp = aLineDistAtMetricBox.GetValue(); 609 aLineDistAtMetricBox.SetMin(aLineDistAtMetricBox.Normalize(nMinFixDist), FUNIT_TWIP); 610 611 if ( aLineDistAtMetricBox.GetValue() != nTemp ) 612 SetMetricValue( aLineDistAtMetricBox, 613 FIX_DIST_DEF, SFX_MAPUNIT_TWIP ); 614 aLineDistAtPercentBox.Hide(); 615 pActLineDistFld->Show(); 616 pActLineDistFld->Enable(); 617 } 618 break; 619 } 620 ExecuteLineSpace(); 621 return 0; 622 } 623 624 IMPL_LINK( ParaLineSpacingControl, LineSPDistAtHdl_Impl, MetricField*, /* pBox */ ) 625 { 626 ExecuteLineSpace(); 627 return (0L); 628 } 629 630 void ParaLineSpacingControl::ExecuteLineSpace() 631 { 632 aLineDist.SaveValue(); 633 maLineSpacing.SetNoSelection(); 634 635 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 636 sal_uInt16 nPos = aLineDist.GetSelectEntryPos(); 637 638 switch ( nPos ) 639 { 640 case LLINESPACE_1: 641 case LLINESPACE_15: 642 case LLINESPACE_2: 643 { 644 SetLineSpace( aSpacing, nPos ); 645 maPos = nPos; 646 } 647 break; 648 649 case LLINESPACE_PROP: 650 { 651 SetLineSpace( aSpacing, nPos, 652 aLineDistAtPercentBox.Denormalize( 653 (long)aLineDistAtPercentBox.GetValue() ) ); 654 maPos = nPos; 655 maValue =aLineDistAtPercentBox.GetValue(); 656 } 657 break; 658 659 case LLINESPACE_MIN: 660 case LLINESPACE_DURCH: 661 case LLINESPACE_FIX: 662 { 663 SetLineSpace( aSpacing, nPos, 664 GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ) ); 665 maPos = nPos; 666 maValue = GetCoreValue( aLineDistAtMetricBox, m_eLNSpaceUnit ); 667 } 668 break; 669 670 default: 671 DBG_ERROR( "error!!" ); 672 break; 673 } 674 675 mpBindings->GetDispatcher()->Execute( 676 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 677 678 mbUseLineSPCustom = USE_CUSTOM; 679 } 680 681 void ParaLineSpacingControl::SetLineSpace( SvxLineSpacingItem& rLineSpace, 682 int eSpace, long lValue ) 683 { 684 switch ( eSpace ) 685 { 686 case LLINESPACE_1: 687 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 688 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 689 break; 690 691 case LLINESPACE_15: 692 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 693 rLineSpace.SetPropLineSpace( LINESPACE_15 ); 694 break; 695 696 case LLINESPACE_2: 697 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 698 rLineSpace.SetPropLineSpace( LINESPACE_2 ); 699 break; 700 701 case LLINESPACE_PROP: 702 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 703 rLineSpace.SetPropLineSpace( (sal_uInt8)lValue ); 704 break; 705 706 case LLINESPACE_MIN: 707 rLineSpace.SetLineHeight( (sal_uInt16)lValue ); 708 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 709 break; 710 711 case LLINESPACE_DURCH: 712 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 713 rLineSpace.SetInterLineSpace( (sal_uInt16)lValue ); 714 break; 715 716 case LLINESPACE_FIX: 717 rLineSpace.SetLineHeight((sal_uInt16)lValue); 718 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_FIX; 719 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 720 break; 721 } 722 } 723 724 IMPL_LINK(ParaLineSpacingControl, VSSelHdl, void *, pControl) 725 { 726 maLineSpacing.SetNoSelection(); 727 bool bClosePop = true; 728 if(pControl == &maLineSpacing) 729 { 730 sal_uInt16 iPos = maLineSpacing.GetSelectItemId(); 731 switch ( iPos ) 732 { 733 case 1: 734 ExecuteLineSpacing( 0, 0 ); 735 break; 736 case 2: 737 ExecuteLineSpacing( 0, 3 ); 738 break; 739 case 3: 740 ExecuteLineSpacing( 0, 1 ); 741 break; 742 case 4: 743 ExecuteLineSpacing( 0, 2 ); 744 break; 745 case 5: 746 { 747 if(!(mbLineSPDisable)) 748 { 749 //maPos = mrParaPropertyPanel.maLinePos; 750 aLineDist.SelectEntryPos( maPos ) ; 751 aLineDist.SaveValue(); 752 //maValue = mrParaPropertyPanel.maLineValue; 753 754 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 755 switch(maPos) 756 { 757 case LLINESPACE_1: 758 case LLINESPACE_15: 759 case LLINESPACE_2: 760 SetLineSpace( aSpacing, maPos ); 761 break; 762 763 case LLINESPACE_PROP: 764 SetLineSpace( aSpacing, maPos, 765 aLineDistAtPercentBox.Denormalize( (long)maValue ) ); 766 break; 767 768 case LLINESPACE_MIN: 769 case LLINESPACE_DURCH: 770 case LLINESPACE_FIX: 771 SetLineSpace( aSpacing, maPos, (long)maValue ); 772 break; 773 } 774 775 mpBindings->GetDispatcher()->Execute( 776 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 777 778 ExecuteLineSpacing( USE_CUSTOM, 0 ); 779 } 780 else 781 bClosePop = sal_False; 782 } 783 break; 784 } 785 } 786 if(bClosePop) 787 mrParaPropertyPanel.EndSpacingPopupMode(); 788 return 0; 789 } 790 791 void ParaLineSpacingControl::ExecuteLineSpacing( sal_uInt16 aIsCustom, sal_uInt16 aEntry ) 792 { 793 if( !aIsCustom ) 794 { 795 aLineDist.SelectEntryPos( aEntry ) ; 796 aLineDist.SaveValue(); 797 SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); 798 sal_uInt16 nPos = aEntry; 799 if( aEntry == LLINESPACE_PROP ) 800 SetLineSpace( aSpacing, nPos, aLineDistAtPercentBox.Denormalize( (long)115 ) ); 801 else 802 SetLineSpace( aSpacing, nPos ); 803 804 mpBindings->GetDispatcher()->Execute( 805 SID_ATTR_PARA_LINESPACE, SFX_CALLMODE_RECORD, &aSpacing, 0L); 806 } 807 808 if( !aIsCustom ) 809 { 810 mbUseLineSPCustom = DO_NOT_CUSTOM; 811 mrParaPropertyPanel.EndSpacingPopupMode(); 812 } 813 maLineSpacing.SetNoSelection(); 814 } 815 816 }} // end of namespace sidebar 817 818