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