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 24 #include "TextPropertyPanel.hrc" 25 #include "TextPropertyPanel.hxx" 26 #include "SvxSBFontNameBox.hxx" 27 28 #include "svx/dialmgr.hxx" 29 30 #include <editeng/brshitem.hxx> 31 #include <editeng/colritem.hxx> 32 #include <editeng/crsditem.hxx> 33 #include <editeng/escpitem.hxx> 34 #include <editeng/flstitem.hxx> 35 #include <editeng/fontitem.hxx> 36 #include <editeng/kernitem.hxx> 37 #include <editeng/postitem.hxx> 38 #include <editeng/shdditem.hxx> 39 #include <editeng/udlnitem.hxx> 40 #include <editeng/wghtitem.hxx> 41 #include <rtl/ref.hxx> 42 #include <sfx2/dispatch.hxx> 43 #include <sfx2/objsh.hxx> 44 #include <sfx2/viewsh.hxx> 45 #include <sfx2/sidebar/ResourceDefinitions.hrc> 46 #include <sfx2/sidebar/ControlFactory.hxx> 47 #include <sfx2/sidebar/ControllerFactory.hxx> 48 #include <sfx2/sidebar/Theme.hxx> 49 #include <sfx2/sidebar/SidebarToolBox.hxx> 50 #include "sfx2/imagemgr.hxx" 51 #include <svtools/ctrltool.hxx> 52 #include <svtools/unitconv.hxx> 53 54 #include <vcl/gradient.hxx> 55 #include <vcl/svapp.hxx> 56 #include <vcl/toolbox.hxx> 57 #include "TextCharacterSpacingControl.hxx" 58 #include "TextCharacterSpacingPopup.hxx" 59 #include "TextUnderlineControl.hxx" 60 #include "TextUnderlinePopup.hxx" 61 #include <svx/sidebar/ColorControl.hxx> 62 #include <svx/sidebar/PopupContainer.hxx> 63 64 #include <boost/bind.hpp> 65 66 using namespace css; 67 using namespace cssu; 68 using ::sfx2::sidebar::Theme; 69 using ::sfx2::sidebar::ControlFactory; 70 71 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 72 73 namespace svx { namespace sidebar { 74 75 #undef HAS_IA2 76 77 78 79 PopupControl* TextPropertyPanel::CreateCharacterSpacingControl (PopupContainer* pParent) 80 { 81 return new TextCharacterSpacingControl(pParent, *this, mpBindings); 82 } 83 84 PopupControl* TextPropertyPanel::CreateUnderlinePopupControl (PopupContainer* pParent) 85 { 86 return new TextUnderlineControl(pParent, *this, mpBindings); 87 } 88 89 namespace 90 { 91 Color GetAutomaticColor(void) 92 { 93 return COL_AUTO; 94 } 95 } // end of anonymous namespace 96 97 long TextPropertyPanel::GetSelFontSize() 98 { 99 long nH = 240; 100 SfxMapUnit eUnit = maSpacingControl.GetCoreMetric(); 101 if (mpHeightItem) 102 nH = LogicToLogic( mpHeightItem->GetHeight(), (MapUnit)eUnit, MAP_TWIP ); 103 return nH; 104 } 105 106 107 TextPropertyPanel* TextPropertyPanel::Create ( 108 Window* pParent, 109 const cssu::Reference<css::frame::XFrame>& rxFrame, 110 SfxBindings* pBindings, 111 const ::sfx2::sidebar::EnumContext& rContext) 112 { 113 if (pParent == NULL) 114 throw lang::IllegalArgumentException(A2S("no parent Window given to TextPropertyPanel::Create"), NULL, 0); 115 if ( ! rxFrame.is()) 116 throw lang::IllegalArgumentException(A2S("no XFrame given to TextPropertyPanel::Create"), NULL, 1); 117 if (pBindings == NULL) 118 throw lang::IllegalArgumentException(A2S("no SfxBindings given to TextPropertyPanel::Create"), NULL, 2); 119 120 return new TextPropertyPanel( 121 pParent, 122 rxFrame, 123 pBindings, 124 rContext); 125 } 126 127 128 ::sfx2::sidebar::ControllerItem& TextPropertyPanel::GetSpaceController() 129 { 130 return maSpacingControl; 131 } 132 133 TextPropertyPanel::TextPropertyPanel ( 134 Window* pParent, 135 const cssu::Reference<css::frame::XFrame>& rxFrame, 136 SfxBindings* pBindings, 137 const ::sfx2::sidebar::EnumContext& rContext) 138 : Control(pParent, SVX_RES(RID_SIDEBAR_TEXT_PANEL)), 139 mpFontNameBox (new SvxSBFontNameBox(this, SVX_RES(CB_SBFONT_FONT))), 140 maFontSizeBox (this, SVX_RES(MB_SBFONT_FONTSIZE)), 141 mpToolBoxFontBackground(ControlFactory::CreateToolBoxBackground(this)), 142 mpToolBoxFont(ControlFactory::CreateToolBox( 143 mpToolBoxFontBackground.get(), 144 SVX_RES(TB_FONT))), 145 mpToolBoxIncDecBackground(ControlFactory::CreateToolBoxBackground(this)), 146 mpToolBoxIncDec(ControlFactory::CreateToolBox( 147 mpToolBoxIncDecBackground.get(), 148 SVX_RES(TB_INCREASE_DECREASE))), 149 mpToolBoxScriptBackground(ControlFactory::CreateToolBoxBackground(this)), 150 mpToolBoxScript(ControlFactory::CreateToolBox( 151 mpToolBoxScriptBackground.get(), 152 SVX_RES(TB_SCRIPT))), 153 mpToolBoxScriptSwBackground(ControlFactory::CreateToolBoxBackground(this)), 154 mpToolBoxScriptSw(ControlFactory::CreateToolBox( 155 mpToolBoxScriptSwBackground.get(), 156 SVX_RES(TB_SCRIPT_SW))), 157 mpToolBoxSpacingBackground(ControlFactory::CreateToolBoxBackground(this)), 158 mpToolBoxSpacing(ControlFactory::CreateToolBox( 159 mpToolBoxSpacingBackground.get(), 160 SVX_RES(TB_SPACING))), 161 mpToolBoxFontColorBackground(ControlFactory::CreateToolBoxBackground(this)), 162 mpToolBoxFontColor(ControlFactory::CreateToolBox( 163 mpToolBoxFontColorBackground.get(), 164 SVX_RES(TB_FONTCOLOR), 165 rxFrame)), 166 mpToolBoxFontColorBackgroundSW(ControlFactory::CreateToolBoxBackground(this)), 167 mpToolBoxFontColorSW(ControlFactory::CreateToolBox( 168 mpToolBoxFontColorBackgroundSW.get(), 169 SVX_RES(TB_FONTCOLOR_SW), 170 rxFrame)), 171 mpToolBoxHighlightBackground(ControlFactory::CreateToolBoxBackground(this)), 172 mpToolBoxHighlight(ControlFactory::CreateToolBox( 173 mpToolBoxHighlightBackground.get(), 174 SVX_RES(TB_HIGHLIGHT), 175 rxFrame)), 176 mpFontColorUpdater(), 177 mpHighlightUpdater(), 178 179 maFontNameControl (SID_ATTR_CHAR_FONT, *pBindings, *this, A2S("CharFontName"), rxFrame), 180 maFontSizeControl (SID_ATTR_CHAR_FONTHEIGHT, *pBindings, *this, A2S("FontHeight"), rxFrame), 181 maWeightControl (SID_ATTR_CHAR_WEIGHT, *pBindings, *this, A2S("Bold"), rxFrame), 182 maItalicControl (SID_ATTR_CHAR_POSTURE, *pBindings, *this, A2S("Italic"), rxFrame), 183 maUnderlineControl (SID_ATTR_CHAR_UNDERLINE, *pBindings, *this, A2S("Underline"), rxFrame), 184 maStrikeControl (SID_ATTR_CHAR_STRIKEOUT, *pBindings, *this, A2S("Strikeout"), rxFrame), 185 maShadowControl (SID_ATTR_CHAR_SHADOWED, *pBindings, *this, A2S("Shadowed"), rxFrame), 186 maScriptControlSw (SID_ATTR_CHAR_ESCAPEMENT, *pBindings, *this, A2S("Escapement"), rxFrame), 187 maSuperScriptControl(SID_SET_SUPER_SCRIPT, *pBindings, *this, A2S("SuperScript"), rxFrame), 188 maSubScriptControl (SID_SET_SUB_SCRIPT, *pBindings, *this, A2S("SubScript"), rxFrame), 189 maSpacingControl (SID_ATTR_CHAR_KERNING, *pBindings, *this, A2S("Spacing"), rxFrame), 190 maSDFontGrow (SID_GROW_FONT_SIZE, *pBindings, *this, A2S("Grow"), rxFrame), 191 maSDFontShrink (SID_SHRINK_FONT_SIZE, *pBindings, *this, A2S("Shrink"), rxFrame), 192 193 mpFontList (NULL), 194 mbMustDelete (false), 195 mbFocusOnFontSizeCtrl(false), 196 maCharSpacePopup(this, ::boost::bind(&TextPropertyPanel::CreateCharacterSpacingControl, this, _1)), 197 maUnderlinePopup(this, ::boost::bind(&TextPropertyPanel::CreateUnderlinePopupControl, this, _1)), 198 mxFrame(rxFrame), 199 maContext(), 200 mpBindings(pBindings) 201 { 202 Initialize(); 203 204 FreeResource(); 205 206 UpdateFontColorToolbox(rContext); 207 } 208 209 210 211 212 TextPropertyPanel::~TextPropertyPanel (void) 213 { 214 if(mbMustDelete) 215 delete mpFontList; 216 217 // Destroy the toolbox windows. 218 mpToolBoxIncDec.reset(); 219 mpToolBoxFont.reset(); 220 mpToolBoxFontColor.reset(); 221 mpToolBoxFontColorSW.reset(); 222 mpToolBoxScript.reset(); 223 mpToolBoxScriptSw.reset(); 224 mpToolBoxSpacing.reset(); 225 mpToolBoxHighlight.reset(); 226 227 // Destroy the background windows of the toolboxes. 228 mpToolBoxIncDecBackground.reset(); 229 mpToolBoxFontBackground.reset(); 230 mpToolBoxFontColorBackground.reset(); 231 mpToolBoxFontColorBackgroundSW.reset(); 232 mpToolBoxScriptBackground.reset(); 233 mpToolBoxScriptSwBackground.reset(); 234 mpToolBoxSpacingBackground.reset(); 235 mpToolBoxHighlightBackground.reset(); 236 } 237 238 239 240 241 void TextPropertyPanel::SetSpacing(long nKern) 242 { 243 mlKerning = nKern; 244 } 245 246 247 void TextPropertyPanel::HandleContextChange ( 248 const ::sfx2::sidebar::EnumContext aContext) 249 { 250 if (maContext == aContext) 251 { 252 // Nothing to do. 253 return; 254 } 255 256 maContext = aContext; 257 switch (maContext.GetCombinedContext_DI()) 258 { 259 case CombinedEnumContext(Application_Calc, Context_Cell): 260 case CombinedEnumContext(Application_Calc, Context_Pivot): 261 mpToolBoxScriptSw->Hide(); 262 mpToolBoxHighlight->Hide(); 263 mpToolBoxScript->Disable(); 264 mpToolBoxSpacing->Disable(); 265 break; 266 267 case CombinedEnumContext(Application_Calc, Context_EditCell): 268 case CombinedEnumContext(Application_Calc, Context_DrawText): 269 mpToolBoxScriptSw->Hide(); 270 mpToolBoxHighlight->Hide(); 271 mpToolBoxScript->Enable(); 272 mpToolBoxSpacing->Enable(); 273 break; 274 275 case CombinedEnumContext(Application_WriterVariants, Context_Text): 276 case CombinedEnumContext(Application_WriterVariants, Context_Table): 277 mpToolBoxScriptSw->Show(); 278 mpToolBoxScript->Hide(); 279 mpToolBoxHighlight->Show(); 280 mpToolBoxSpacing->Show(); 281 break; 282 283 case CombinedEnumContext(Application_WriterVariants, Context_DrawText): 284 case CombinedEnumContext(Application_WriterVariants, Context_Annotation): 285 mpToolBoxScriptSw->Show(); 286 mpToolBoxScript->Hide(); 287 mpToolBoxSpacing->Show(); 288 mpToolBoxHighlight->Hide(); 289 break; 290 291 case CombinedEnumContext(Application_DrawImpress, Context_DrawText): 292 case CombinedEnumContext(Application_DrawImpress, Context_Text): 293 case CombinedEnumContext(Application_DrawImpress, Context_Table): 294 case CombinedEnumContext(Application_DrawImpress, Context_OutlineText): 295 case CombinedEnumContext(Application_DrawImpress, Context_Draw): 296 case CombinedEnumContext(Application_DrawImpress, Context_TextObject): 297 case CombinedEnumContext(Application_DrawImpress, Context_Graphic): 298 mpToolBoxScriptSw->Hide(); 299 mpToolBoxScript->Show(); 300 mpToolBoxSpacing->Show(); 301 mpToolBoxHighlight->Hide(); 302 break; 303 304 default: 305 break; 306 } 307 308 UpdateFontColorToolbox(aContext); 309 } 310 311 312 313 314 void TextPropertyPanel::UpdateFontColorToolbox ( 315 const ::sfx2::sidebar::EnumContext aContext) 316 { 317 bool bIsWriterFontColor (false); 318 if (maContext.GetApplication_DI() == sfx2::sidebar::EnumContext::Application_WriterVariants) 319 if (maContext.GetContext() != sfx2::sidebar::EnumContext::Context_DrawText) 320 bIsWriterFontColor = true; 321 if (bIsWriterFontColor) 322 { 323 mpToolBoxFontColor->Hide(); 324 mpToolBoxFontColorSW->Show(); 325 } 326 else 327 { 328 mpToolBoxFontColor->Show(); 329 mpToolBoxFontColorSW->Hide(); 330 } 331 } 332 333 334 335 336 void TextPropertyPanel::DataChanged (const DataChangedEvent& rEvent) 337 { 338 (void)rEvent; 339 340 SetupToolboxItems(); 341 } 342 343 344 345 346 void TextPropertyPanel::Initialize (void) 347 { 348 //<<modify fill font list 349 SfxObjectShell* pDocSh = SfxObjectShell::Current(); 350 const SfxPoolItem* pItem = NULL; 351 352 if (pDocSh != NULL) 353 pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ); 354 if (pItem != NULL) 355 mpFontList = ( (SvxFontListItem*)pItem )->GetFontList(); 356 else 357 { 358 mpFontList = new FontList( Application::GetDefaultDevice() ); 359 mbMustDelete = true; 360 } 361 362 mpFontNameBox->SetAccessibleName(mpFontNameBox->GetQuickHelpText()); 363 const FontInfo aFontInfo (mpFontList->Get( String::CreateFromAscii( "" ), String::CreateFromAscii( "" ))); 364 maFontSizeBox.Fill(&aFontInfo,mpFontList); 365 maFontSizeBox.SetAccessibleName(maFontSizeBox.GetQuickHelpText()); 366 367 //toolbox 368 SetupToolboxItems(); 369 InitToolBoxIncDec(); 370 InitToolBoxFont(); 371 InitToolBoxScript(); 372 InitToolBoxSpacing(); 373 374 #ifdef HAS_IA2 375 mpFontNameBox->SetAccRelationLabeledBy(&mpFontNameBox); 376 mpFontNameBox->SetMpSubEditAccLableBy(&mpFontNameBox); 377 maFontSizeBox.SetAccRelationLabeledBy(&maFontSizeBox); 378 maFontSizeBox.SetMpSubEditAccLableBy(&maFontSizeBox); 379 mpToolBoxFont.SetAccRelationLabeledBy(&mpToolBoxFont); 380 mpToolBoxIncDec.SetAccRelationLabeledBy(&mpToolBoxIncDec); 381 mpToolBoxFontColor.SetAccRelationLabeledBy(&mpToolBoxFontColor); 382 mpToolBoxScript.SetAccRelationLabeledBy(&mpToolBoxScript); 383 mpToolBoxScriptSw.SetAccRelationLabeledBy(&mpToolBoxScriptSw); 384 mpToolBoxSpacing.SetAccRelationLabeledBy(&mpToolBoxSpacing); 385 mpToolBoxHighlight.SetAccRelationLabeledBy(&mpToolBoxHighlight); 386 #endif 387 388 //init state 389 mpHeightItem = NULL; 390 meWeight = WEIGHT_NORMAL; 391 meItalic = ITALIC_NONE; 392 mbShadow = false; 393 meStrike = STRIKEOUT_NONE; 394 mbPostureAvailable = true; 395 mbWeightAvailable = true; 396 meUnderline = UNDERLINE_NONE; 397 meUnderlineColor = COL_AUTO; 398 meEscape = SVX_ESCAPEMENT_OFF; 399 mbSuper = false; 400 mbSub = false; 401 mbKernAvailable = true; 402 mbKernLBAvailable = true; 403 mlKerning = 0; 404 405 //set handler 406 mpFontNameBox->SetBindings(mpBindings); 407 Link aLink = LINK(this, TextPropertyPanel, FontSelHdl); 408 mpFontNameBox->SetSelectHdl(aLink); 409 aLink = LINK(this, TextPropertyPanel, FontSizeModifyHdl); 410 maFontSizeBox.SetModifyHdl(aLink); 411 aLink = LINK(this, TextPropertyPanel, FontSizeSelHdl); 412 maFontSizeBox.SetSelectHdl(aLink); 413 aLink = LINK(this, TextPropertyPanel, FontSizeLoseFocus); 414 maFontSizeBox.SetLoseFocusHdl(aLink); 415 } 416 417 void TextPropertyPanel::EndSpacingPopupMode (void) 418 { 419 maCharSpacePopup.Hide(); 420 } 421 422 void TextPropertyPanel::EndUnderlinePopupMode (void) 423 { 424 maUnderlinePopup.Hide(); 425 } 426 427 428 void TextPropertyPanel::InitToolBoxFont() 429 { 430 mpToolBoxFont->SetBackground(Wallpaper()); 431 mpToolBoxFont->SetPaintTransparent(true); 432 433 Size aTbxSize( mpToolBoxFont->CalcWindowSizePixel() ); 434 mpToolBoxFont->SetOutputSizePixel( aTbxSize ); 435 436 Link aLink = LINK(this, TextPropertyPanel, ToolboxFontSelectHandler); 437 mpToolBoxFont->SetSelectHdl ( aLink ); 438 aLink = LINK(this, TextPropertyPanel, ToolBoxUnderlineClickHdl); 439 mpToolBoxFont->SetDropdownClickHdl(aLink); 440 } 441 442 443 444 445 void TextPropertyPanel::InitToolBoxIncDec() 446 { 447 Size aTbxSize( mpToolBoxIncDec->CalcWindowSizePixel() ); 448 mpToolBoxIncDec->SetOutputSizePixel( aTbxSize ); 449 450 Link aLink = LINK(this, TextPropertyPanel, ToolboxIncDecSelectHdl); 451 mpToolBoxIncDec->SetSelectHdl ( aLink ); 452 } 453 454 455 456 457 void TextPropertyPanel::InitToolBoxScript() 458 { 459 Size aTbxSize( mpToolBoxScriptSw->CalcWindowSizePixel() ); 460 mpToolBoxScriptSw->SetOutputSizePixel( aTbxSize ); 461 462 Link aLink = LINK(this, TextPropertyPanel, ToolBoxSwScriptSelectHdl); 463 mpToolBoxScriptSw->SetSelectHdl ( aLink ); 464 465 aTbxSize = mpToolBoxScript->CalcWindowSizePixel() ; 466 mpToolBoxScript->SetOutputSizePixel( aTbxSize ); 467 468 aLink = LINK(this, TextPropertyPanel, ToolBoxScriptSelectHdl); 469 mpToolBoxScript->SetSelectHdl ( aLink ); 470 } 471 void TextPropertyPanel::InitToolBoxSpacing() 472 { 473 Size aTbxSize( mpToolBoxSpacing->CalcWindowSizePixel() ); 474 mpToolBoxSpacing->SetOutputSizePixel( aTbxSize ); 475 mpToolBoxSpacing->SetItemBits( TBI_SPACING, mpToolBoxSpacing->GetItemBits( TBI_SPACING ) | TIB_DROPDOWNONLY ); 476 477 Link aLink = LINK(this, TextPropertyPanel, SpacingClickHdl); 478 mpToolBoxSpacing->SetDropdownClickHdl ( aLink ); 479 mpToolBoxSpacing->SetSelectHdl( aLink ); 480 } 481 482 483 484 485 void TextPropertyPanel::SetupToolboxItems (void) 486 { 487 maSDFontGrow.SetupToolBoxItem(*mpToolBoxIncDec, TBI_INCREASE); 488 maSDFontShrink.SetupToolBoxItem(*mpToolBoxIncDec, TBI_DECREASE); 489 490 maWeightControl.SetupToolBoxItem(*mpToolBoxFont, TBI_BOLD); 491 maItalicControl.SetupToolBoxItem(*mpToolBoxFont, TBI_ITALIC); 492 maUnderlineControl.SetupToolBoxItem(*mpToolBoxFont, TBI_UNDERLINE); 493 maStrikeControl.SetupToolBoxItem(*mpToolBoxFont, TBI_STRIKEOUT); 494 maShadowControl.SetupToolBoxItem(*mpToolBoxFont, TBI_SHADOWED); 495 496 //for sw 497 maSuperScriptControl.SetupToolBoxItem(*mpToolBoxScriptSw, TBI_SUPER_SW); 498 maSubScriptControl.SetupToolBoxItem(*mpToolBoxScriptSw, TBI_SUB_SW); 499 //for sc and sd 500 maSuperScriptControl.SetupToolBoxItem(*mpToolBoxScript, TBI_SUPER); 501 maSubScriptControl.SetupToolBoxItem(*mpToolBoxScript, TBI_SUB); 502 maSpacingControl.SetupToolBoxItem(*mpToolBoxSpacing, TBI_SPACING); 503 } 504 505 506 507 508 IMPL_LINK( TextPropertyPanel, FontSelHdl, FontNameBox*, pBox ) 509 { 510 if ( !pBox->IsTravelSelect() ) 511 { 512 if( SfxViewShell::Current() ) 513 { 514 Window* pShellWnd = SfxViewShell::Current()->GetWindow(); 515 516 if ( pShellWnd ) 517 pShellWnd->GrabFocus(); 518 } 519 } 520 return 0; 521 } 522 523 IMPL_LINK( TextPropertyPanel, FontSizeModifyHdl, FontSizeBox*, pSizeBox ) 524 { 525 if (pSizeBox == &maFontSizeBox) 526 { 527 long nSize = pSizeBox->GetValue(); 528 mbFocusOnFontSizeCtrl = true; 529 530 float fSize = (float)nSize / 10; 531 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric(); 532 SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ; 533 534 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L ); 535 mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false); 536 } 537 return 0; 538 } 539 540 IMPL_LINK( TextPropertyPanel, FontSizeSelHdl, FontSizeBox*, pSizeBox ) 541 { 542 if ( !pSizeBox->IsTravelSelect() ) 543 { 544 if( SfxViewShell::Current() ) 545 { 546 Window* pShellWnd = SfxViewShell::Current()->GetWindow(); 547 548 if ( pShellWnd ) 549 pShellWnd->GrabFocus(); 550 } 551 } 552 553 return 0; 554 } 555 556 IMPL_LINK(TextPropertyPanel, FontSizeLoseFocus, FontSizeBox*, pSizeBox) 557 { 558 if(pSizeBox == &maFontSizeBox) 559 { 560 mbFocusOnFontSizeCtrl = false; 561 } 562 return 0; 563 } 564 565 IMPL_LINK(TextPropertyPanel, ToolboxFontSelectHandler, ToolBox*, pToolBox) 566 { 567 const sal_uInt16 nId = pToolBox->GetCurItemId(); 568 569 switch (nId) 570 { 571 case TBI_BOLD: 572 { 573 EndTracking(); 574 if(meWeight != WEIGHT_BOLD) 575 meWeight = WEIGHT_BOLD; 576 else 577 meWeight = WEIGHT_NORMAL; 578 SvxWeightItem aWeightItem(meWeight, SID_ATTR_CHAR_WEIGHT); 579 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_WEIGHT, SFX_CALLMODE_RECORD, &aWeightItem, 0L); 580 UpdateItem(SID_ATTR_CHAR_WEIGHT); 581 break; 582 } 583 case TBI_ITALIC: 584 { 585 EndTracking(); 586 if(meItalic != ITALIC_NORMAL) 587 meItalic = ITALIC_NORMAL; 588 else 589 meItalic = ITALIC_NONE; 590 SvxPostureItem aPostureItem(meItalic, SID_ATTR_CHAR_POSTURE); 591 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_POSTURE, SFX_CALLMODE_RECORD, &aPostureItem, 0L); 592 UpdateItem(SID_ATTR_CHAR_POSTURE); 593 break; 594 } 595 case TBI_UNDERLINE: 596 { 597 EndTracking(); 598 if(meUnderline == UNDERLINE_NONE) 599 { 600 meUnderline = UNDERLINE_SINGLE; 601 SvxUnderlineItem aLineItem(meUnderline, SID_ATTR_CHAR_UNDERLINE); 602 aLineItem.SetColor(meUnderlineColor); 603 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L); 604 } 605 else 606 { 607 meUnderline = UNDERLINE_NONE; 608 SvxUnderlineItem aLineItem(meUnderline, SID_ATTR_CHAR_UNDERLINE); 609 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L); 610 } 611 UpdateItem(SID_ATTR_CHAR_UNDERLINE); 612 break; 613 } 614 case TBI_STRIKEOUT: 615 { 616 EndTracking(); 617 if(meStrike != STRIKEOUT_NONE && meStrike != STRIKEOUT_DONTKNOW) 618 meStrike = STRIKEOUT_NONE; 619 else 620 meStrike = STRIKEOUT_SINGLE; 621 SvxCrossedOutItem aStrikeItem(meStrike,SID_ATTR_CHAR_STRIKEOUT); 622 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_STRIKEOUT, SFX_CALLMODE_RECORD, &aStrikeItem, 0L); 623 UpdateItem(SID_ATTR_CHAR_STRIKEOUT); 624 break; 625 } 626 case TBI_SHADOWED: 627 { 628 EndTracking(); 629 mbShadow = !mbShadow; 630 SvxShadowedItem aShadowItem(mbShadow, SID_ATTR_CHAR_SHADOWED); 631 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_SHADOWED, SFX_CALLMODE_RECORD, &aShadowItem, 0L); 632 UpdateItem(SID_ATTR_CHAR_SHADOWED); 633 break; 634 } 635 } 636 return 0; 637 } 638 639 640 641 642 IMPL_LINK(TextPropertyPanel, ToolboxIncDecSelectHdl, ToolBox*, pToolBox) 643 { 644 const sal_uInt16 nId = pToolBox->GetCurItemId(); 645 646 // font size +/- enhancement in sd 647 switch (maContext.GetCombinedContext_DI()) 648 { 649 case CombinedEnumContext(Application_DrawImpress, Context_DrawText): 650 case CombinedEnumContext(Application_DrawImpress, Context_Text): 651 case CombinedEnumContext(Application_DrawImpress, Context_Table): 652 case CombinedEnumContext(Application_DrawImpress, Context_OutlineText): 653 case CombinedEnumContext(Application_DrawImpress, Context_Draw): 654 case CombinedEnumContext(Application_DrawImpress, Context_TextObject): 655 case CombinedEnumContext(Application_DrawImpress, Context_Graphic): 656 if(nId == TBI_INCREASE) 657 { 658 EndTracking(); 659 SfxVoidItem aItem(SID_GROW_FONT_SIZE); 660 mpBindings->GetDispatcher()->Execute( SID_GROW_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L ); 661 } 662 else if(nId == TBI_DECREASE) 663 { 664 EndTracking(); 665 SfxVoidItem aItem(SID_SHRINK_FONT_SIZE); 666 mpBindings->GetDispatcher()->Execute( SID_SHRINK_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L ); 667 } 668 break; 669 670 default: 671 if(nId == TBI_INCREASE) 672 { 673 EndTracking(); 674 mbFocusOnFontSizeCtrl = false; 675 sal_Int64 iValue = maFontSizeBox.GetValue(); 676 int iPos = maFontSizeBox.GetValuePos(iValue, FUNIT_NONE); 677 long nSize = iValue; 678 if(iPos != LISTBOX_ENTRY_NOTFOUND) 679 nSize = maFontSizeBox.GetValue(iPos+1 , FUNIT_NONE); 680 else if(iValue >= 100 && iValue < 105) 681 nSize = 105; 682 else if(iValue >= 105 && iValue < 110) 683 nSize = 110; 684 else if(iValue < 960) 685 { 686 nSize = (nSize / 10) * 10 + 10; 687 while(maFontSizeBox.GetValuePos(nSize, FUNIT_NONE) == LISTBOX_ENTRY_NOTFOUND) 688 nSize += 10; 689 } 690 else 691 { 692 nSize = iValue; 693 } 694 695 float fSize = (float)nSize / 10; 696 697 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric(); 698 SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ; 699 700 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L ); 701 mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false); 702 maFontSizeBox.SetValue( nSize ); 703 } 704 else if(nId == TBI_DECREASE) 705 { 706 EndTracking(); 707 mbFocusOnFontSizeCtrl = false; 708 sal_Int64 iValue = maFontSizeBox.GetValue(); 709 int iPos = maFontSizeBox.GetValuePos(iValue, FUNIT_NONE); 710 long nSize = iValue; 711 if(iPos != LISTBOX_ENTRY_NOTFOUND) 712 nSize = maFontSizeBox.GetValue(iPos-1 , FUNIT_NONE); 713 else if(iValue > 100 && iValue <= 105) 714 nSize = 100; 715 else if(iValue > 105 && iValue <= 110) 716 nSize = 105; 717 else if(iValue > 960) 718 { 719 nSize = 960; 720 } 721 else if(iValue > 60) 722 { 723 nSize = (nSize / 10) * 10 ; 724 while(maFontSizeBox.GetValuePos(nSize, FUNIT_NONE) == LISTBOX_ENTRY_NOTFOUND) 725 nSize -= 10; 726 } 727 else 728 { 729 nSize = iValue; 730 } 731 732 float fSize = (float)nSize / 10; 733 734 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric(); 735 SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ; 736 737 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L ); 738 mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false); 739 maFontSizeBox.SetValue( nSize ); 740 } 741 } 742 UpdateItem(SID_ATTR_CHAR_FONTHEIGHT); 743 744 return 0; 745 } 746 747 748 749 IMPL_LINK(TextPropertyPanel, ToolBoxUnderlineClickHdl, ToolBox*, pToolBox) 750 { 751 const sal_uInt16 nId = pToolBox->GetCurItemId(); 752 OSL_ASSERT(nId == TBI_UNDERLINE); 753 if(nId == TBI_UNDERLINE) 754 { 755 pToolBox->SetItemDown( nId, true ); 756 maUnderlinePopup.Rearrange(meUnderline); 757 maUnderlinePopup.Show(*pToolBox); 758 759 } 760 return 0L; 761 } 762 763 764 765 766 IMPL_LINK(TextPropertyPanel, ToolBoxSwScriptSelectHdl, ToolBox*, pToolBox) 767 { 768 const sal_uInt16 nId = pToolBox->GetCurItemId(); 769 if( nId == TBI_SUPER_SW ) 770 { 771 if(meEscape != SVX_ESCAPEMENT_SUPERSCRIPT) 772 { 773 meEscape = SVX_ESCAPEMENT_SUPERSCRIPT; 774 SvxEscapementItem aSupItem(DFLT_ESC_SUPER, DFLT_ESC_PROP, SID_ATTR_CHAR_ESCAPEMENT); 775 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aSupItem, 0L ); 776 } 777 else 778 { 779 meEscape = SVX_ESCAPEMENT_OFF; 780 SvxEscapementItem aNoneItem(0, 100, SID_ATTR_CHAR_ESCAPEMENT); 781 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aNoneItem, 0L ); 782 } 783 } 784 else if(TBI_SUB_SW == nId) 785 { 786 if(meEscape != SVX_ESCAPEMENT_SUBSCRIPT) 787 { 788 meEscape = (SvxEscapement)SVX_ESCAPEMENT_SUBSCRIPT; 789 SvxEscapementItem aSubItem(DFLT_ESC_SUB, DFLT_ESC_PROP, SID_ATTR_CHAR_ESCAPEMENT); 790 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aSubItem, 0L ); 791 } 792 else 793 { 794 meEscape = SVX_ESCAPEMENT_OFF; 795 SvxEscapementItem aNoneItem(0, 100, SID_ATTR_CHAR_ESCAPEMENT); 796 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aNoneItem, 0L ); 797 } 798 } 799 UpdateItem(SID_ATTR_CHAR_ESCAPEMENT); 800 801 return 0; 802 } 803 804 805 806 807 IMPL_LINK(TextPropertyPanel, ToolBoxScriptSelectHdl, ToolBox*, pToolBox) 808 { 809 const sal_uInt16 nId = pToolBox->GetCurItemId(); 810 if( nId == TBI_SUPER ) 811 { 812 mbSuper = !mbSuper; 813 SfxBoolItem aSupItem(SID_SET_SUPER_SCRIPT, mbSuper); 814 mpBindings->GetDispatcher()->Execute( SID_SET_SUPER_SCRIPT, SFX_CALLMODE_RECORD, &aSupItem, 0L ); 815 UpdateItem(SID_SET_SUPER_SCRIPT); 816 } 817 else if(TBI_SUB == nId) 818 { 819 820 mbSub = !mbSub; 821 SfxBoolItem aSubItem(SID_SET_SUB_SCRIPT, mbSub ); 822 mpBindings->GetDispatcher()->Execute( SID_SET_SUB_SCRIPT, SFX_CALLMODE_RECORD, &aSubItem, 0L ); 823 UpdateItem(SID_SET_SUB_SCRIPT); 824 } 825 return 0; 826 } 827 828 829 830 831 IMPL_LINK(TextPropertyPanel, SpacingClickHdl, ToolBox*, pToolBox) 832 { 833 const sal_uInt16 nId = pToolBox->GetCurItemId(); 834 OSL_ASSERT(nId == TBI_SPACING); 835 if(nId == TBI_SPACING) 836 { 837 pToolBox->SetItemDown( nId, true ); 838 maCharSpacePopup.Rearrange(mbKernLBAvailable,mbKernAvailable,mlKerning); 839 maCharSpacePopup.Show(*pToolBox); 840 841 } 842 return 0L; 843 } 844 845 846 847 848 void TextPropertyPanel::NotifyItemUpdate ( 849 const sal_uInt16 nSID, 850 const SfxItemState eState, 851 const SfxPoolItem* pState, 852 const bool bIsEnabled) 853 { 854 switch(nSID) 855 { 856 case SID_ATTR_CHAR_FONT: 857 { 858 bool bIsControlEnabled (bIsEnabled); 859 if ( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxFontItem) ) 860 { 861 const SvxFontItem* pFontItem = (const SvxFontItem*)pState; 862 mpFontNameBox->SetText( pFontItem->GetFamilyName() ); 863 } 864 else 865 { 866 mpFontNameBox->SetText( String() ); 867 if (SFX_ITEM_DISABLED == eState) 868 bIsControlEnabled = false; 869 } 870 mpFontNameBox->Enable(bIsControlEnabled); 871 break; 872 } 873 case SID_ATTR_CHAR_FONTHEIGHT: 874 { 875 bool bIsControlEnabled (bIsEnabled); 876 if ( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxFontHeightItem) ) 877 { 878 mpHeightItem = (SvxFontHeightItem*)pState;//const SvxFontHeightItem* 879 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric(); 880 const sal_Int64 nValue (CalcToPoint(mpHeightItem->GetHeight(), eUnit, 10 )); 881 mpToolBoxIncDec->Enable(); 882 883 mpToolBoxIncDec->SetItemState(TBI_INCREASE, STATE_NOCHECK); 884 mpToolBoxIncDec->SetItemState(TBI_DECREASE, STATE_NOCHECK); 885 886 // For Writer we have to update the states of the 887 // increase and decrease buttons here, because we have 888 // no access to the slots used by Writer. 889 switch(maContext.GetCombinedContext_DI()) 890 { 891 case CombinedEnumContext(Application_DrawImpress, Context_DrawText): 892 case CombinedEnumContext(Application_DrawImpress, Context_Text): 893 case CombinedEnumContext(Application_DrawImpress, Context_Table): 894 case CombinedEnumContext(Application_DrawImpress, Context_OutlineText): 895 case CombinedEnumContext(Application_DrawImpress, Context_Draw): 896 case CombinedEnumContext(Application_DrawImpress, Context_TextObject): 897 case CombinedEnumContext(Application_DrawImpress, Context_Graphic): 898 break; 899 900 default: 901 { 902 mpToolBoxIncDec->EnableItem(TBI_INCREASE, bIsEnabled && nValue<960); 903 mpToolBoxIncDec->EnableItem(TBI_DECREASE, bIsEnabled && nValue>60); 904 break; 905 } 906 } 907 908 if( mbFocusOnFontSizeCtrl ) 909 return; 910 911 maFontSizeBox.SetValue(nValue); 912 maFontSizeBox.LoseFocus(); 913 914 UpdateItem(SID_SHRINK_FONT_SIZE); 915 UpdateItem(SID_GROW_FONT_SIZE); 916 } 917 else 918 { 919 mpHeightItem = NULL; 920 maFontSizeBox.SetText( String() ); 921 //increase decrease diabled when multi-seletion have different font size 922 923 // font size +/- enhancement in sd 924 switch(maContext.GetCombinedContext_DI()) 925 { 926 case CombinedEnumContext(Application_DrawImpress, Context_DrawText): 927 case CombinedEnumContext(Application_DrawImpress, Context_Text): 928 case CombinedEnumContext(Application_DrawImpress, Context_Table): 929 case CombinedEnumContext(Application_DrawImpress, Context_OutlineText): 930 case CombinedEnumContext(Application_DrawImpress, Context_Draw): 931 case CombinedEnumContext(Application_DrawImpress, Context_TextObject): 932 case CombinedEnumContext(Application_DrawImpress, Context_Graphic): 933 break; 934 935 default: 936 mpToolBoxIncDec->Disable(); 937 } 938 if ( eState <= SFX_ITEM_READONLY ) 939 bIsControlEnabled = false; 940 } 941 maFontSizeBox.Enable(bIsControlEnabled); 942 break; 943 } 944 945 case SID_ATTR_CHAR_WEIGHT: 946 mbWeightAvailable = (eState >= SFX_ITEM_DONTCARE); 947 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxWeightItem)) 948 { 949 const SvxWeightItem* pItem = (const SvxWeightItem*)pState; 950 meWeight = (FontWeight)pItem->GetValue(); 951 } 952 else 953 { 954 meWeight = WEIGHT_NORMAL; 955 } 956 mpToolBoxFont->EnableItem(TBI_BOLD, mbWeightAvailable && bIsEnabled); 957 mpToolBoxFont->SetItemState(TBI_BOLD, meWeight==WEIGHT_BOLD ? STATE_CHECK : STATE_NOCHECK); 958 break; 959 960 case SID_ATTR_CHAR_POSTURE: 961 mbPostureAvailable = (eState >= SFX_ITEM_DONTCARE); 962 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxPostureItem)) 963 { 964 const SvxPostureItem* pItem = (const SvxPostureItem*)pState; 965 meItalic = (FontItalic)pItem->GetValue(); 966 } 967 else 968 { 969 meItalic = ITALIC_NONE; 970 } 971 mpToolBoxFont->EnableItem(TBI_ITALIC, mbPostureAvailable && bIsEnabled); 972 mpToolBoxFont->SetItemState(TBI_ITALIC, meItalic==ITALIC_NORMAL ? STATE_CHECK : STATE_NOCHECK); 973 break; 974 975 case SID_ATTR_CHAR_UNDERLINE: 976 if( eState >= SFX_ITEM_DEFAULT) 977 { 978 if(pState->ISA(SvxUnderlineItem)) 979 { 980 const SvxUnderlineItem* pItem = (const SvxUnderlineItem*)pState; 981 meUnderline = (FontUnderline)pItem->GetValue(); 982 meUnderlineColor = pItem->GetColor(); 983 } 984 } 985 else 986 { 987 meUnderline = UNDERLINE_NONE; 988 } 989 mpToolBoxFont->EnableItem(TBI_UNDERLINE, bIsEnabled); 990 mpToolBoxFont->SetItemState(TBI_UNDERLINE, meUnderline==UNDERLINE_NONE ? STATE_NOCHECK : STATE_CHECK); 991 break; 992 993 case SID_ATTR_CHAR_SHADOWED: 994 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxShadowedItem)) 995 { 996 const SvxShadowedItem* pItem = (const SvxShadowedItem*)pState; 997 mbShadow = pItem->GetValue(); 998 } 999 else 1000 { 1001 mbShadow = false; 1002 } 1003 mpToolBoxFont->EnableItem(TBI_SHADOWED, bIsEnabled); 1004 mpToolBoxFont->SetItemState(TBI_SHADOWED, mbShadow ? STATE_CHECK : STATE_NOCHECK); 1005 break; 1006 1007 case SID_ATTR_CHAR_STRIKEOUT: 1008 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxCrossedOutItem)) 1009 { 1010 const SvxCrossedOutItem* pItem = (const SvxCrossedOutItem*)pState; 1011 meStrike = (FontStrikeout)pItem->GetValue(); 1012 } 1013 else 1014 { 1015 meStrike = STRIKEOUT_NONE; 1016 } 1017 mpToolBoxFont->EnableItem(TBI_STRIKEOUT, bIsEnabled); 1018 mpToolBoxFont->SetItemState(TBI_STRIKEOUT, 1019 meStrike!=STRIKEOUT_NONE && meStrike!=STRIKEOUT_DONTKNOW 1020 ? STATE_CHECK 1021 : STATE_NOCHECK); 1022 break; 1023 1024 case SID_ATTR_CHAR_ESCAPEMENT: 1025 { 1026 bool bIsItemEnabled (true); 1027 if (eState == SFX_ITEM_AVAILABLE) 1028 { 1029 if (pState->ISA(SvxEscapementItem)) 1030 { 1031 const SvxEscapementItem* pItem = (const SvxEscapementItem *)pState; 1032 short nEsc = pItem->GetEsc(); 1033 if(nEsc == 0) 1034 { 1035 meEscape = SVX_ESCAPEMENT_OFF; 1036 mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK); 1037 mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_NOCHECK); 1038 } 1039 else if(nEsc > 0) 1040 { 1041 meEscape = SVX_ESCAPEMENT_SUPERSCRIPT; 1042 mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_CHECK); 1043 mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_NOCHECK); 1044 } 1045 else 1046 { 1047 meEscape = SVX_ESCAPEMENT_SUBSCRIPT; 1048 mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK); 1049 mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_CHECK); 1050 } 1051 } 1052 else 1053 { 1054 meEscape = SVX_ESCAPEMENT_OFF; 1055 mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK); 1056 mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_NOCHECK); 1057 } 1058 } 1059 else if (eState == SFX_ITEM_DISABLED) 1060 { 1061 bIsItemEnabled = false; 1062 } 1063 else 1064 { 1065 meEscape = SVX_ESCAPEMENT_OFF; 1066 } 1067 mpToolBoxScriptSw->EnableItem(TBI_SUPER_SW, bIsItemEnabled && bIsEnabled); 1068 mpToolBoxScriptSw->EnableItem(TBI_SUB_SW, bIsItemEnabled && bIsEnabled); 1069 break; 1070 } 1071 1072 case SID_SET_SUB_SCRIPT: 1073 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SfxBoolItem)) 1074 { 1075 const SfxBoolItem* pItem = (const SfxBoolItem*)pState; 1076 mbSub = pItem->GetValue(); 1077 } 1078 else 1079 { 1080 mbSub = false; 1081 } 1082 mpToolBoxScript->EnableItem(TBI_SUB, bIsEnabled); 1083 mpToolBoxScript->SetItemState(TBI_SUB, mbSub ? STATE_CHECK : STATE_NOCHECK); 1084 break; 1085 1086 case SID_SET_SUPER_SCRIPT: 1087 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SfxBoolItem)) 1088 { 1089 const SfxBoolItem* pItem = (const SfxBoolItem*)pState; 1090 mbSuper = pItem->GetValue(); 1091 } 1092 else 1093 { 1094 mbSuper = false; 1095 } 1096 mpToolBoxScript->EnableItem(TBI_SUPER, bIsEnabled); 1097 mpToolBoxScript->SetItemState(TBI_SUPER, mbSuper ? STATE_CHECK : STATE_NOCHECK); 1098 break; 1099 1100 case SID_ATTR_CHAR_KERNING: 1101 if ( SFX_ITEM_AVAILABLE == eState ) 1102 { 1103 mbKernLBAvailable = true; 1104 1105 if(pState->ISA(SvxKerningItem)) 1106 { 1107 const SvxKerningItem* pKerningItem = (const SvxKerningItem*)pState; 1108 mlKerning = (long)pKerningItem->GetValue(); 1109 mbKernAvailable = true; 1110 } 1111 else 1112 { 1113 mlKerning = 0; 1114 mbKernAvailable =false; 1115 } 1116 } 1117 else if (SFX_ITEM_DISABLED == eState) 1118 { 1119 mbKernLBAvailable = false; 1120 mbKernAvailable = false; 1121 mlKerning = 0; 1122 } 1123 else 1124 { 1125 mbKernLBAvailable = true; 1126 mbKernAvailable = false; 1127 mlKerning = 0; 1128 } 1129 mpToolBoxSpacing->EnableItem(TBI_SPACING, bIsEnabled); 1130 break; 1131 1132 // font size +/- enhancement in sd 1133 case SID_SHRINK_FONT_SIZE: 1134 case SID_GROW_FONT_SIZE: 1135 switch(maContext.GetCombinedContext_DI()) 1136 { 1137 case CombinedEnumContext(Application_DrawImpress, Context_DrawText): 1138 case CombinedEnumContext(Application_DrawImpress, Context_Text): 1139 case CombinedEnumContext(Application_DrawImpress, Context_Table): 1140 case CombinedEnumContext(Application_DrawImpress, Context_OutlineText): 1141 case CombinedEnumContext(Application_DrawImpress, Context_Draw): 1142 case CombinedEnumContext(Application_DrawImpress, Context_TextObject): 1143 case CombinedEnumContext(Application_DrawImpress, Context_Graphic): 1144 { 1145 if(eState == SFX_ITEM_DISABLED) 1146 mpToolBoxIncDec->Disable(); 1147 else 1148 mpToolBoxIncDec->Enable(); 1149 const sal_Int64 nSize (maFontSizeBox.GetValue()); 1150 switch(nSID) 1151 { 1152 case SID_GROW_FONT_SIZE: 1153 mpToolBoxIncDec->EnableItem(TBI_INCREASE, bIsEnabled && nSize<960); 1154 break; 1155 1156 case SID_SHRINK_FONT_SIZE: 1157 mpToolBoxIncDec->EnableItem(TBI_DECREASE, bIsEnabled && nSize>60); 1158 break; 1159 1160 default: 1161 break; 1162 } 1163 } 1164 } 1165 break; 1166 } 1167 } 1168 1169 1170 1171 1172 void TextPropertyPanel::UpdateItem (const sal_uInt16 nSlotId) 1173 { 1174 switch (nSlotId) 1175 { 1176 case SID_ATTR_CHAR_FONT: 1177 maFontNameControl.RequestUpdate(); 1178 break; 1179 case SID_ATTR_CHAR_FONTHEIGHT: 1180 maFontSizeControl.RequestUpdate(); 1181 break; 1182 case SID_ATTR_CHAR_WEIGHT: 1183 maWeightControl.RequestUpdate(); 1184 break; 1185 case SID_ATTR_CHAR_POSTURE: 1186 maItalicControl.RequestUpdate(); 1187 break; 1188 case SID_ATTR_CHAR_UNDERLINE: 1189 maUnderlineControl.RequestUpdate(); 1190 break; 1191 case SID_ATTR_CHAR_STRIKEOUT: 1192 maStrikeControl.RequestUpdate(); 1193 break; 1194 case SID_ATTR_CHAR_SHADOWED: 1195 maShadowControl.RequestUpdate(); 1196 break; 1197 case SID_ATTR_CHAR_ESCAPEMENT: 1198 maScriptControlSw.RequestUpdate(); 1199 break; 1200 case SID_SET_SUPER_SCRIPT: 1201 maSuperScriptControl.RequestUpdate(); 1202 break; 1203 case SID_SET_SUB_SCRIPT: 1204 maSubScriptControl.RequestUpdate(); 1205 break; 1206 case SID_ATTR_CHAR_KERNING: 1207 maSpacingControl.RequestUpdate(); 1208 break; 1209 case SID_GROW_FONT_SIZE: 1210 maSDFontGrow.RequestUpdate(); 1211 break; 1212 case SID_SHRINK_FONT_SIZE: 1213 maSDFontShrink.RequestUpdate(); 1214 break; 1215 } 1216 } 1217 1218 1219 1220 1221 1222 Color& TextPropertyPanel::GetUnderlineColor() 1223 { 1224 return meUnderlineColor; 1225 } 1226 1227 void TextPropertyPanel::SetUnderline(FontUnderline eUnderline) 1228 { 1229 meUnderline = eUnderline; 1230 } 1231 1232 1233 1234 } } // end of namespace svx::sidebar 1235