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