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