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 56 using namespace css; 57 using namespace cssu; 58 using ::sfx2::sidebar::Theme; 59 60 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 61 62 namespace svx { namespace sidebar { 63 64 #undef HAS_IA2 65 66 67 #define FONT_CONTROL_WIDTH 160 68 #define SIZE_CONTROL_WIDTH 80 69 #define CONTROL_COMBOX_HEIGHT 20 70 #define CONTROL_HEIGHT_5X 120 71 #define SIDEBAR_SPACE_NORMAL 0 72 #define SIDEBAR_SPACE_EXPAND 1 73 #define SIDEBAR_SPACE_CONDENSED 2 74 #define SIDEBAR_SPACING_GLOBAL_VALUE String("PopupPanal_Spacing", 18, RTL_TEXTENCODING_ASCII_US) 75 #define TEXT_SECTIONPAGE_HEIGHT_S SECTIONPAGE_MARGIN_VERTICAL_TOP + CBOX_HEIGHT + ( TOOLBOX_ITEM_HEIGHT + 2 ) + CONTROL_SPACING_VERTICAL * 1 + SECTIONPAGE_MARGIN_VERTICAL_BOT 76 #define TEXT_SECTIONPAGE_HEIGHT SECTIONPAGE_MARGIN_VERTICAL_TOP + CBOX_HEIGHT + ( TOOLBOX_ITEM_HEIGHT + 2 ) * 2 + CONTROL_SPACING_VERTICAL * 2 + SECTIONPAGE_MARGIN_VERTICAL_BOT 77 78 // 79 #define SPACING_NOCUSTOM 0 80 #define SPACING_CLOSE_BY_CLICK_ICON -1 81 #define SPACING_CLOSE_BY_CUS_EDIT 1 82 //end 83 84 85 86 87 88 TextPropertyPanel* TextPropertyPanel::Create ( 89 Window* pParent, 90 const cssu::Reference<css::frame::XFrame>& rxFrame, 91 SfxBindings* pBindings) 92 { 93 if (pParent == NULL) 94 throw lang::IllegalArgumentException(A2S("no parent Window given to TextPropertyPanel::Create"), NULL, 0); 95 if ( ! rxFrame.is()) 96 throw lang::IllegalArgumentException(A2S("no XFrame given to TextPropertyPanel::Create"), NULL, 1); 97 if (pBindings == NULL) 98 throw lang::IllegalArgumentException(A2S("no SfxBindings given to TextPropertyPanel::Create"), NULL, 2); 99 100 return new TextPropertyPanel( 101 pParent, 102 rxFrame, 103 pBindings); 104 } 105 106 107 108 109 TextPropertyPanel::TextPropertyPanel ( 110 Window* pParent, 111 const cssu::Reference<css::frame::XFrame>& rxFrame, 112 SfxBindings* pBindings) 113 : Control(pParent, SVX_RES(RID_SIDEBAR_TEXT_PANEL)), 114 mpFontNameBox (new SvxSBFontNameBox(this, SVX_RES(CB_SBFONT_FONT))), 115 maFontSizeBox (this, SVX_RES(MB_SBFONT_FONTSIZE)), 116 mpToolBoxIncDec(sfx2::sidebar::ControlFactory::CreateToolBox(this, SVX_RES(TB_INCREASE_DECREASE))), 117 mpToolBoxFont(sfx2::sidebar::ControlFactory::CreateToolBox(this, SVX_RES(TB_FONT))), 118 mpToolBoxFontColor(sfx2::sidebar::ControlFactory::CreateToolBox(this, SVX_RES(TB_FONTCOLOR))), 119 mpToolBoxScript(sfx2::sidebar::ControlFactory::CreateToolBox(this, SVX_RES(TB_SCRIPT))), 120 mpToolBoxScriptSw(sfx2::sidebar::ControlFactory::CreateToolBox(this, SVX_RES(TB_SCRIPT_SW))), 121 mpToolBoxSpacing(sfx2::sidebar::ControlFactory::CreateToolBox(this, SVX_RES(TB_SPACING))), 122 mpToolBoxHighlight(sfx2::sidebar::ControlFactory::CreateToolBox(this, SVX_RES(TB_HIGHLIGHT))), 123 mpFontColorUpdater(), 124 mpHighlightUpdater(), 125 126 maFontNameControl (SID_ATTR_CHAR_FONT, *pBindings, *this), 127 maFontSizeControl (SID_ATTR_CHAR_FONTHEIGHT, *pBindings, *this), 128 maWeightControl (SID_ATTR_CHAR_WEIGHT, *pBindings, *this), 129 maItalicControl (SID_ATTR_CHAR_POSTURE, *pBindings, *this), 130 maUnderlineControl (SID_ATTR_CHAR_UNDERLINE, *pBindings, *this), 131 maStrikeControl (SID_ATTR_CHAR_STRIKEOUT, *pBindings, *this), 132 maShadowControl (SID_ATTR_CHAR_SHADOWED, *pBindings, *this), 133 maFontColorControl (SID_ATTR_CHAR_COLOR, *pBindings, *this), 134 maScriptControlSw (SID_ATTR_CHAR_ESCAPEMENT, *pBindings, *this), //for sw 135 maSuperScriptControl (SID_SET_SUPER_SCRIPT, *pBindings, *this), 136 maSubScriptControl (SID_SET_SUB_SCRIPT, *pBindings, *this), 137 maSpacingControl (SID_ATTR_CHAR_KERNING, *pBindings, *this), 138 maHighlightControl (SID_ATTR_BRUSH_CHAR, *pBindings, *this), 139 maSDFontGrow (SID_GROW_FONT_SIZE, *pBindings, *this), 140 maSDFontShrink (SID_SHRINK_FONT_SIZE, *pBindings, *this), 141 142 maImgIncrease (SVX_RES( IMG_INCREASE)), 143 maImgDecrease (SVX_RES( IMG_DECREASE)), 144 maImgBold (SVX_RES( IMG_BOLD )), 145 maImgItalic (SVX_RES( IMG_ITALIC )), 146 maImgUnderline (SVX_RES( IMG_UNDERLINE )), 147 maImgStrike (SVX_RES( IMG_STRIKEOUT )), 148 maImgShadow (SVX_RES( IMG_SHADOWED )), 149 maImgFontColor (SVX_RES( IMG_FONTCOLOR)), 150 maImgSupScript (SVX_RES( IMG_SUPSCRIPT)), 151 maImgSubScript (SVX_RES( IMG_SUBSCRIPT)), 152 maImgHighlight (SVX_RES( IMG_HIGHLIGHT)), 153 154 maImgNormalIcon (SVX_RES(IMG_SPACING_D)), 155 156 maImgIncreaseHigh (SVX_RES( IMG_INCREASE_H )), 157 maImgDecreaseHigh (SVX_RES( IMG_DECREASE_H )), 158 maImgBoldHigh (SVX_RES( IMG_BOLD_H )), 159 maImgItalicHigh (SVX_RES( IMG_ITALIC_H )), 160 maImgUnderlineHigh (SVX_RES( IMG_UNDERLINE_H )), 161 maImgStrikeHigh (SVX_RES( IMG_STRIKEOUT_H )), 162 maImgShadowHigh (SVX_RES( IMG_SHADOWED_H )), 163 maImgFontColorHigh (SVX_RES( IMG_FONTCOLOR_H)), 164 maImgSupScriptHigh (SVX_RES( IMG_SUPSCRIPT_H)), 165 maImgSubScriptHigh (SVX_RES( IMG_SUBSCRIPT_H)), 166 maImgHighlightHigh (SVX_RES( IMG_HIGHLIGHT_H)), 167 168 mpFontList (NULL), 169 mbMustDelete (false), 170 mbFocusOnFontSizeCtrl(false), 171 /*AF 172 mpFloatWinUnderline(NULL), 173 mpPageUnderline(NULL), 174 mpFloatWinFontColor(NULL), 175 mpPageFontColor(NULL), 176 mpFloatWinSpacing(NULL), 177 mpPageSpacing(NULL) 178 */ 179 mxFrame(rxFrame), 180 maContext(), 181 mpBindings(pBindings) 182 { 183 Initialize(); 184 FreeResource(); 185 186 // Let the Pane draw the background. 187 SetBackground(Wallpaper()); 188 } 189 190 191 192 193 TextPropertyPanel::~TextPropertyPanel (void) 194 { 195 if(mbMustDelete) 196 delete mpFontList; 197 198 /*AF 199 delete mpPageUnderline; 200 delete mpFloatWinUnderline; 201 202 delete mpPageFontColor; 203 delete mpFloatWinFontColor; 204 205 delete mpPageSpacing; 206 delete mpFloatWinSpacing; 207 */ 208 } 209 210 211 212 213 Image TextPropertyPanel::GetIcon (const ::rtl::OUString& rsURL) 214 { 215 return GetImage(mxFrame, rsURL, sal_False, Theme::IsHighContrastMode()); 216 } 217 218 219 220 221 void TextPropertyPanel::HandleContextChange ( 222 const ::sfx2::sidebar::EnumContext aContext) 223 { 224 if (maContext == aContext) 225 { 226 // Nothing to do. 227 return; 228 } 229 230 maContext = aContext; 231 switch (maContext.GetCombinedContext()) 232 { 233 case CombinedEnumContext(Application_Calc, Context_Cell): 234 case CombinedEnumContext(Application_Calc, Context_Pivot): 235 { 236 mpToolBoxScript->Hide(); 237 mpToolBoxScriptSw->Hide(); 238 mpToolBoxSpacing->Hide(); 239 mpToolBoxHighlight->Hide(); 240 241 Size aSize(PROPERTYPAGE_WIDTH,TEXT_SECTIONPAGE_HEIGHT_S); 242 aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) ); 243 aSize.setWidth(GetOutputSizePixel().Width()); 244 SetSizePixel(aSize); 245 break; 246 } 247 248 case CombinedEnumContext(Application_Writer, Context_Text): 249 case CombinedEnumContext(Application_Writer, Context_Table): 250 { 251 mpToolBoxScriptSw->Show(); 252 mpToolBoxScript->Hide(); 253 mpToolBoxHighlight->Show(); 254 mpToolBoxSpacing->Show(); 255 256 Size aSize(PROPERTYPAGE_WIDTH, TEXT_SECTIONPAGE_HEIGHT); 257 aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) ); 258 aSize.setWidth(GetOutputSizePixel().Width()); 259 SetSizePixel(aSize); 260 break; 261 } 262 263 case CombinedEnumContext(Application_Writer, Context_DrawText): 264 case CombinedEnumContext(Application_Writer, Context_Annotation): 265 { 266 mpToolBoxScriptSw->Show(); 267 mpToolBoxScript->Hide(); 268 mpToolBoxSpacing->Show(); 269 mpToolBoxHighlight->Hide(); 270 271 Size aSize(PROPERTYPAGE_WIDTH,TEXT_SECTIONPAGE_HEIGHT); 272 aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) ); 273 aSize.setWidth(GetOutputSizePixel().Width()); 274 SetSizePixel(aSize); 275 break; 276 } 277 278 case CombinedEnumContext(Application_Calc, Context_EditCell): 279 case CombinedEnumContext(Application_Calc, Context_DrawText): 280 case CombinedEnumContext(Application_Draw, Context_DrawText): 281 case CombinedEnumContext(Application_Draw, Context_Text): 282 case CombinedEnumContext(Application_Draw, Context_Table): 283 case CombinedEnumContext(Application_Draw, Context_OutlineText): 284 case CombinedEnumContext(Application_Draw, Context_Draw): 285 case CombinedEnumContext(Application_Draw, Context_TextObject): 286 case CombinedEnumContext(Application_Draw, Context_Graphic): 287 case CombinedEnumContext(Application_Impress, Context_DrawText): 288 case CombinedEnumContext(Application_Impress, Context_Text): 289 case CombinedEnumContext(Application_Impress, Context_Table): 290 case CombinedEnumContext(Application_Impress, Context_OutlineText): 291 case CombinedEnumContext(Application_Impress, Context_Draw): 292 case CombinedEnumContext(Application_Impress, Context_TextObject): 293 case CombinedEnumContext(Application_Impress, Context_Graphic): 294 { 295 mpToolBoxScriptSw->Hide(); 296 mpToolBoxScript->Show(); 297 mpToolBoxSpacing->Show(); 298 mpToolBoxHighlight->Hide(); 299 300 Size aSize(PROPERTYPAGE_WIDTH,TEXT_SECTIONPAGE_HEIGHT); 301 aSize = LogicToPixel( aSize,MapMode(MAP_APPFONT) ); 302 aSize.setWidth(GetOutputSizePixel().Width()); 303 SetSizePixel(aSize); 304 break; 305 } 306 307 default: 308 break; 309 } 310 } 311 312 313 314 315 void TextPropertyPanel::DataChanged (const DataChangedEvent& rEvent) 316 { 317 (void)rEvent; 318 319 SetupIcons(); 320 } 321 322 323 324 void TextPropertyPanel::Initialize (void) 325 { 326 //<<modify fill font list 327 SfxObjectShell* pDocSh = SfxObjectShell::Current(); 328 const SfxPoolItem* pItem = NULL; 329 330 if (pDocSh != NULL) 331 pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ); 332 if (pItem != NULL) 333 mpFontList = ( (SvxFontListItem*)pItem )->GetFontList(); 334 else 335 { 336 mpFontList = new FontList( Application::GetDefaultDevice() ); 337 mbMustDelete = 1; 338 } 339 340 mpFontNameBox->SetAccessibleName(mpFontNameBox->GetQuickHelpText()); 341 const FontInfo aFontInfo (mpFontList->Get( String::CreateFromAscii( "" ), String::CreateFromAscii( "" ))); 342 maFontSizeBox.Fill(&aFontInfo,mpFontList); 343 maFontSizeBox.SetAccessibleName(maFontSizeBox.GetQuickHelpText()); 344 345 //toolbox 346 SetupIcons(); 347 InitToolBoxIncDec(); 348 InitToolBoxFont(); 349 InitToolBoxFontColor(); 350 InitToolBoxScript(); 351 InitToolBoxSpacing(); 352 InitToolBoxHighlight(); 353 354 #ifdef HAS_IA2 355 mpFontNameBox->SetAccRelationLabeledBy(&maFontNameBox); 356 mpFontNameBox->SetMpSubEditAccLableBy(&maFontNameBox); 357 maFontSizeBox.SetAccRelationLabeledBy(&maFontSizeBox); 358 maFontSizeBox.SetMpSubEditAccLableBy(&maFontSizeBox); 359 maToolBoxFont.SetAccRelationLabeledBy(&maToolBoxFont); 360 maToolBoxIncDec.SetAccRelationLabeledBy(&maToolBoxIncDec); 361 maToolBoxFontColor.SetAccRelationLabeledBy(&maToolBoxFontColor); 362 maToolBoxScript.SetAccRelationLabeledBy(&maToolBoxScript); 363 maToolBoxScriptSw.SetAccRelationLabeledBy(&maToolBoxScriptSw); 364 maToolBoxSpacing.SetAccRelationLabeledBy(&maToolBoxSpacing); 365 maToolBoxHighlight.SetAccRelationLabeledBy(&maToolBoxHighlight); 366 #endif 367 368 //init state 369 mpHeightItem = NULL; 370 meWeight = WEIGHT_NORMAL; 371 meItalic = ITALIC_NONE; 372 mbShadow = false; 373 meStrike = STRIKEOUT_NONE; 374 mbPostureAvailable = true; 375 mbWeightAvailable = true; 376 meUnderline = UNDERLINE_NONE; 377 meUnderlineColor = COL_AUTO; // 378 maColor = COL_BLACK; 379 mbColorAvailable = true; 380 maBackColor = COL_AUTO; 381 mbBackColorAvailable = true; 382 meColorType = FONT_COLOR; 383 meEscape = SVX_ESCAPEMENT_OFF; 384 mbSuper = false; 385 mbSub = false; 386 mbKernAvailable = true; 387 mbKernLBAvailable = true; 388 mlKerning = 0; 389 mpFontColorUpdater.reset(new ToolboxButtonColorUpdater( 390 SID_ATTR_CHAR_COLOR, 391 TBI_FONTCOLOR, 392 mpToolBoxFontColor.get(), 393 TBX_UPDATER_MODE_CHAR_COLOR_NEW)); 394 mpHighlightUpdater.reset(new ToolboxButtonColorUpdater( 395 SID_ATTR_BRUSH_CHAR, 396 TBI_HIGHLIGHT, 397 mpToolBoxHighlight.get(), 398 TBX_UPDATER_MODE_CHAR_COLOR_NEW)); 399 400 //set handler 401 mpFontNameBox->SetBindings(mpBindings); 402 //add 403 Link aLink = LINK(this, TextPropertyPanel, FontSelHdl); 404 mpFontNameBox->SetSelectHdl(aLink); 405 //add end 406 407 aLink = LINK(this, TextPropertyPanel, FontSizeModifyHdl); 408 maFontSizeBox.SetModifyHdl(aLink); 409 //add 410 aLink = LINK(this, TextPropertyPanel, FontSizeSelHdl); 411 maFontSizeBox.SetSelectHdl(aLink); 412 //add end 413 aLink = LINK(this, TextPropertyPanel, FontSizeLoseFocus); 414 maFontSizeBox.SetLoseFocusHdl(aLink); 415 416 // add 417 long aSizeBoxHeight = maFontSizeBox.GetSizePixel().getHeight();; 418 Point aPosFontSize = maFontSizeBox.GetPosPixel(); 419 long aPosY = aPosFontSize.getY(); 420 Point pTBIncDec = mpToolBoxIncDec->GetPosPixel(); 421 long aIncDecHeight = mpToolBoxIncDec->GetSizePixel().getHeight(); 422 pTBIncDec.setY(aPosY+aSizeBoxHeight/2-aIncDecHeight/2); 423 mpToolBoxIncDec->SetPosPixel(pTBIncDec); 424 //end 425 } 426 427 428 429 430 void TextPropertyPanel::InitToolBoxFont() 431 { 432 mpToolBoxFont->SetQuickHelpText(TBI_BOLD,String(SVX_RES(STR_QH_BOLD))); //Add 433 mpToolBoxFont->SetQuickHelpText(TBI_ITALIC,String(SVX_RES(STR_QH_ITALIC))); //Add 434 mpToolBoxFont->SetQuickHelpText(TBI_UNDERLINE,String(SVX_RES(STR_QH_UNDERLINE))); //Add 435 mpToolBoxFont->SetBackground(Wallpaper()); 436 mpToolBoxFont->SetPaintTransparent(true); 437 438 Size aTbxSize( mpToolBoxFont->CalcWindowSizePixel() ); 439 mpToolBoxFont->SetOutputSizePixel( aTbxSize ); 440 441 Link aLink = LINK(this, TextPropertyPanel, ToolboxFontSelectHandler); 442 mpToolBoxFont->SetSelectHdl ( aLink ); 443 aLink = LINK(this, TextPropertyPanel, ToolBoxUnderlineClickHdl); 444 mpToolBoxFont->SetDropdownClickHdl(aLink); 445 } 446 447 448 449 450 void TextPropertyPanel::InitToolBoxIncDec() 451 { 452 Size aTbxSize( mpToolBoxIncDec->CalcWindowSizePixel() ); 453 mpToolBoxIncDec->SetOutputSizePixel( aTbxSize ); 454 455 Link aLink = LINK(this, TextPropertyPanel, ToolboxIncDecSelectHdl); 456 mpToolBoxIncDec->SetSelectHdl ( aLink ); 457 } 458 459 460 461 462 void TextPropertyPanel::InitToolBoxFontColor() 463 { 464 Size aTbxSize( mpToolBoxFontColor->CalcWindowSizePixel() ); 465 mpToolBoxFontColor->SetOutputSizePixel( aTbxSize ); 466 mpToolBoxFontColor->SetItemBits( TBI_FONTCOLOR, mpToolBoxFontColor->GetItemBits( TBI_FONTCOLOR ) | TIB_DROPDOWNONLY ); 467 468 Link aLink = LINK(this, TextPropertyPanel, ToolBoxFontColorDropHdl); 469 mpToolBoxFontColor->SetDropdownClickHdl ( aLink ); 470 mpToolBoxFontColor->SetSelectHdl ( aLink ); 471 472 } 473 void TextPropertyPanel::InitToolBoxScript() 474 { 475 Size aTbxSize( mpToolBoxScriptSw->CalcWindowSizePixel() ); 476 mpToolBoxScriptSw->SetOutputSizePixel( aTbxSize ); 477 478 Link aLink = LINK(this, TextPropertyPanel, ToolBoxSwScriptSelectHdl); 479 mpToolBoxScriptSw->SetSelectHdl ( aLink ); 480 481 aTbxSize = mpToolBoxScript->CalcWindowSizePixel() ; 482 mpToolBoxScript->SetOutputSizePixel( aTbxSize ); 483 484 aLink = LINK(this, TextPropertyPanel, ToolBoxScriptSelectHdl); 485 mpToolBoxScript->SetSelectHdl ( aLink ); 486 } 487 void TextPropertyPanel::InitToolBoxSpacing() 488 { 489 Size aTbxSize( mpToolBoxSpacing->CalcWindowSizePixel() ); 490 mpToolBoxSpacing->SetOutputSizePixel( aTbxSize ); 491 mpToolBoxSpacing->SetItemBits( TBI_SPACING, mpToolBoxSpacing->GetItemBits( TBI_SPACING ) | TIB_DROPDOWNONLY ); 492 493 Link aLink = LINK(this, TextPropertyPanel, SpacingClickHdl); 494 mpToolBoxSpacing->SetDropdownClickHdl ( aLink ); 495 mpToolBoxSpacing->SetSelectHdl( aLink ); 496 } 497 void TextPropertyPanel::InitToolBoxHighlight() 498 { 499 Size aTbxSize( mpToolBoxHighlight->CalcWindowSizePixel() ); 500 mpToolBoxHighlight->SetOutputSizePixel( aTbxSize ); 501 mpToolBoxHighlight->SetItemBits( TBI_HIGHLIGHT, mpToolBoxHighlight->GetItemBits( TBI_HIGHLIGHT ) | TIB_DROPDOWNONLY ); 502 503 Link aLink = LINK(this, TextPropertyPanel, ToolBoxHighlightDropHdl); 504 mpToolBoxHighlight->SetDropdownClickHdl ( aLink ); 505 mpToolBoxHighlight->SetSelectHdl( aLink ); 506 } 507 508 509 510 511 void TextPropertyPanel::SetupIcons (void) 512 { 513 if (Theme::GetBoolean(Theme::Bool_UseSymphonyIcons)) 514 { 515 mpToolBoxIncDec->SetItemImage(TBI_INCREASE, Application::GetSettings().GetStyleSettings().GetHighContrastMode()? maImgIncreaseHigh : maImgIncrease); 516 mpToolBoxIncDec->SetItemImage(TBI_DECREASE, Application::GetSettings().GetStyleSettings().GetHighContrastMode()? maImgDecreaseHigh : maImgDecrease); 517 mpToolBoxFont->SetItemImage(TBI_BOLD, Application::GetSettings().GetStyleSettings().GetHighContrastMode()? maImgBoldHigh : maImgBold); 518 mpToolBoxFont->SetItemImage(TBI_ITALIC, Application::GetSettings().GetStyleSettings().GetHighContrastMode()? maImgItalicHigh : maImgItalic); 519 mpToolBoxFont->SetItemImage(TBI_UNDERLINE, Application::GetSettings().GetStyleSettings().GetHighContrastMode()? maImgUnderlineHigh : maImgUnderline); 520 mpToolBoxFont->SetItemImage(TBI_STRIKEOUT, Application::GetSettings().GetStyleSettings().GetHighContrastMode()? maImgStrikeHigh : maImgStrike); 521 mpToolBoxFont->SetItemImage(TBI_SHADOWED, Application::GetSettings().GetStyleSettings().GetHighContrastMode()? maImgShadowHigh : maImgShadow); 522 523 mpToolBoxFontColor->SetItemImage(TBI_FONTCOLOR, Application::GetSettings().GetStyleSettings().GetHighContrastMode()? maImgFontColorHigh : maImgFontColor); 524 //for sw 525 mpToolBoxScriptSw->SetItemImage(TBI_SUPER_SW, Application::GetSettings().GetStyleSettings().GetHighContrastMode()? maImgSupScriptHigh : maImgSupScript); 526 mpToolBoxScriptSw->SetItemImage(TBI_SUB_SW, Application::GetSettings().GetStyleSettings().GetHighContrastMode()? maImgSubScriptHigh : maImgSubScript); 527 //for sc and sd 528 mpToolBoxScript->SetItemImage(TBI_SUPER, Application::GetSettings().GetStyleSettings().GetHighContrastMode()? maImgSupScriptHigh : maImgSupScript); 529 mpToolBoxScript->SetItemImage(TBI_SUB, Application::GetSettings().GetStyleSettings().GetHighContrastMode()? maImgSubScriptHigh : maImgSubScript); 530 mpToolBoxSpacing->SetItemImage(TBI_SPACING, maImgNormalIcon); 531 mpToolBoxHighlight->SetItemImage(TBI_HIGHLIGHT, Application::GetSettings().GetStyleSettings().GetHighContrastMode()? maImgHighlightHigh : maImgHighlight); 532 } 533 else 534 { 535 mpToolBoxIncDec->SetItemImage(TBI_INCREASE, GetIcon(A2S(".uno:Grow"))); 536 mpToolBoxIncDec->SetItemImage(TBI_DECREASE, GetIcon(A2S(".uno:Shrink"))); 537 mpToolBoxFont->SetItemImage(TBI_BOLD, GetIcon(A2S(".uno:Bold"))); 538 mpToolBoxFont->SetItemImage(TBI_ITALIC, GetIcon(A2S(".uno:Italic"))); 539 mpToolBoxFont->SetItemImage(TBI_UNDERLINE, GetIcon(A2S(".uno:Underline"))); 540 mpToolBoxFont->SetItemImage(TBI_STRIKEOUT, GetIcon(A2S(".uno:Strikeout"))); 541 mpToolBoxFont->SetItemImage(TBI_SHADOWED, GetIcon(A2S(".uno:Shadowed"))); 542 543 mpToolBoxFontColor->SetItemImage(TBI_FONTCOLOR, GetIcon(A2S(".uno:FontColor"))); 544 //for sw 545 mpToolBoxScriptSw->SetItemImage(TBI_SUPER_SW, GetIcon(A2S(".uno:SuperScript"))); 546 mpToolBoxScriptSw->SetItemImage(TBI_SUB_SW, GetIcon(A2S(".uno:SubScript"))); 547 //for sc and sd 548 mpToolBoxScript->SetItemImage(TBI_SUPER, GetIcon(A2S(".uno:SuperScript"))); 549 mpToolBoxScript->SetItemImage(TBI_SUB, GetIcon(A2S(".uno:SubScript"))); 550 mpToolBoxSpacing->SetItemImage(TBI_SPACING, GetIcon(A2S(".uno:FontworkCharacterSpacingFloater"))); 551 mpToolBoxHighlight->SetItemImage(TBI_HIGHLIGHT, GetIcon(A2S(".uno:BackColor"))); 552 } 553 } 554 555 556 557 558 IMPL_LINK( TextPropertyPanel, FontSelHdl, FontNameBox*, pBox ) 559 { 560 if ( !pBox->IsTravelSelect() ) 561 { 562 if( SfxViewShell::Current() ) 563 { 564 Window* pShellWnd = SfxViewShell::Current()->GetWindow(); 565 566 if ( pShellWnd ) 567 pShellWnd->GrabFocus(); 568 } 569 } 570 return 0; 571 } 572 //add end 573 IMPL_LINK( TextPropertyPanel, FontSizeModifyHdl, FontSizeBox*, pSizeBox ) 574 { 575 if (pSizeBox == &maFontSizeBox) 576 { 577 long nSize = pSizeBox->GetValue(); 578 mbFocusOnFontSizeCtrl = true; 579 580 float fSize = (float)nSize / 10; 581 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric(); 582 SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ; 583 584 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L ); 585 mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false); 586 } 587 return 0; 588 } 589 //add 590 IMPL_LINK( TextPropertyPanel, FontSizeSelHdl, FontSizeBox*, pSizeBox ) 591 { 592 if ( !pSizeBox->IsTravelSelect() ) 593 { 594 if( SfxViewShell::Current() ) 595 { 596 Window* pShellWnd = SfxViewShell::Current()->GetWindow(); 597 598 if ( pShellWnd ) 599 pShellWnd->GrabFocus(); 600 } 601 } 602 603 return 0; 604 } 605 //add end 606 IMPL_LINK(TextPropertyPanel, FontSizeLoseFocus, FontSizeBox*, pSizeBox) 607 { 608 if(pSizeBox == &maFontSizeBox) 609 { 610 mbFocusOnFontSizeCtrl = false; 611 } 612 return 0; 613 } 614 615 IMPL_LINK(TextPropertyPanel, ToolboxFontSelectHandler, ToolBox*, pToolBox) 616 { 617 const sal_uInt16 nId = pToolBox->GetCurItemId(); 618 619 //Bold 620 if(nId == TBI_BOLD) 621 { 622 EndTracking(); 623 if(meWeight != WEIGHT_BOLD) 624 meWeight = WEIGHT_BOLD; 625 else 626 meWeight = WEIGHT_NORMAL; 627 SvxWeightItem aWeightItem(meWeight, SID_ATTR_CHAR_WEIGHT); 628 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_WEIGHT, SFX_CALLMODE_RECORD, &aWeightItem, 0L); 629 UpdateFontBold(); 630 } 631 //Italic 632 else if(nId == TBI_ITALIC) 633 { 634 EndTracking(); 635 if(meItalic != ITALIC_NORMAL) 636 meItalic = ITALIC_NORMAL; 637 else 638 meItalic = ITALIC_NONE; 639 SvxPostureItem aPostureItem(meItalic, SID_ATTR_CHAR_POSTURE); 640 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_POSTURE, SFX_CALLMODE_RECORD, &aPostureItem, 0L); 641 UpdateFontItalic(); 642 } 643 //underline 644 else if(nId == TBI_UNDERLINE) 645 { 646 EndTracking(); 647 //add , keep underline's color 648 if(meUnderline == UNDERLINE_NONE) 649 { 650 //AF: meUnderline = GetDefaultUnderline(); 651 meUnderline = UNDERLINE_SINGLE; 652 //<<modify 653 //SvxTextLineItem aLineItem(meUnderline, SID_ATTR_CHAR_UNDERLINE); 654 SvxUnderlineItem aLineItem(meUnderline, SID_ATTR_CHAR_UNDERLINE); 655 //modify end>> 656 aLineItem.SetColor(meUnderlineColor); 657 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L); 658 } 659 else 660 { 661 meUnderline = UNDERLINE_NONE; 662 //<<modify 663 //SvxTextLineItem aLineItem(meUnderline, SID_ATTR_CHAR_UNDERLINE); 664 SvxUnderlineItem aLineItem(meUnderline, SID_ATTR_CHAR_UNDERLINE); 665 //modify end>> 666 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L); 667 } 668 UpdateFontUnderline(); 669 //add end 670 } 671 //strike out 672 else if(nId == TBI_STRIKEOUT) 673 { 674 EndTracking(); 675 if(meStrike != STRIKEOUT_NONE && meStrike != STRIKEOUT_DONTKNOW) 676 meStrike = STRIKEOUT_NONE; 677 else 678 meStrike = STRIKEOUT_SINGLE; 679 SvxCrossedOutItem aStrikeItem(meStrike,SID_ATTR_CHAR_STRIKEOUT); 680 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_STRIKEOUT, SFX_CALLMODE_RECORD, &aStrikeItem, 0L); 681 UpdateFontStrikeOut(); 682 } 683 //shadowed 684 else if(nId == TBI_SHADOWED) 685 { 686 EndTracking(); 687 mbShadow = !mbShadow; 688 SvxShadowedItem aShadowItem(mbShadow, SID_ATTR_CHAR_SHADOWED); 689 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_SHADOWED, SFX_CALLMODE_RECORD, &aShadowItem, 0L); 690 UpdateFontShadowed(); 691 } 692 return 0; 693 } 694 695 696 697 698 IMPL_LINK(TextPropertyPanel, ToolboxIncDecSelectHdl, ToolBox*, pToolBox) 699 { 700 const sal_uInt16 nId = pToolBox->GetCurItemId(); 701 702 // font size +/- enhancement in sd 703 switch (maContext.GetCombinedContext()) 704 { 705 case CombinedEnumContext(Application_Draw, Context_DrawText): 706 case CombinedEnumContext(Application_Draw, Context_Text): 707 case CombinedEnumContext(Application_Draw, Context_Table): 708 case CombinedEnumContext(Application_Draw, Context_OutlineText): 709 case CombinedEnumContext(Application_Draw, Context_Draw): 710 case CombinedEnumContext(Application_Draw, Context_TextObject): 711 case CombinedEnumContext(Application_Draw, Context_Graphic): 712 case CombinedEnumContext(Application_Impress, Context_DrawText): 713 case CombinedEnumContext(Application_Impress, Context_Text): 714 case CombinedEnumContext(Application_Impress, Context_Table): 715 case CombinedEnumContext(Application_Impress, Context_OutlineText): 716 case CombinedEnumContext(Application_Impress, Context_Draw): 717 case CombinedEnumContext(Application_Impress, Context_TextObject): 718 case CombinedEnumContext(Application_Impress, Context_Graphic): 719 if(nId == TBI_INCREASE) 720 { 721 EndTracking(); 722 SfxVoidItem aItem(SID_GROW_FONT_SIZE); 723 mpBindings->GetDispatcher()->Execute( SID_GROW_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L ); 724 } 725 else if(nId == TBI_DECREASE) 726 { 727 EndTracking(); 728 SfxVoidItem aItem(SID_SHRINK_FONT_SIZE); 729 mpBindings->GetDispatcher()->Execute( SID_SHRINK_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L ); 730 } 731 break; 732 733 default: 734 if(nId == TBI_INCREASE) 735 { 736 EndTracking(); 737 mbFocusOnFontSizeCtrl = false; 738 sal_Int64 iValue = maFontSizeBox.GetValue(); 739 int iPos = maFontSizeBox.GetValuePos(iValue, FUNIT_NONE); 740 long nSize = iValue; 741 if(iPos != LISTBOX_ENTRY_NOTFOUND) 742 nSize = maFontSizeBox.GetValue(iPos+1 , FUNIT_NONE); 743 else if(iValue >= 100 && iValue < 105) 744 nSize = 105; 745 else if(iValue >= 105 && iValue < 110) 746 nSize = 110; 747 else if(iValue < 960) 748 { 749 nSize = (nSize / 10) * 10 + 10; 750 while(maFontSizeBox.GetValuePos(nSize, FUNIT_NONE) == LISTBOX_ENTRY_NOTFOUND) 751 nSize += 10; 752 } 753 else 754 { 755 nSize = iValue; 756 } 757 758 float fSize = (float)nSize / 10; 759 760 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric(); 761 SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ; 762 763 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L ); 764 mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false); 765 //add , update ASAP 766 maFontSizeBox.SetValue( nSize ); 767 if(nSize >= 960) 768 { 769 mpToolBoxIncDec->EnableItem(TBI_INCREASE,false); 770 mpToolBoxIncDec->EnableItem(TBI_DECREASE,true); 771 } 772 else if(nSize <= 60) 773 { 774 mpToolBoxIncDec->EnableItem(TBI_INCREASE,true); 775 mpToolBoxIncDec->EnableItem(TBI_DECREASE,false); 776 } 777 else 778 { 779 mpToolBoxIncDec->EnableItem(TBI_INCREASE,true); 780 mpToolBoxIncDec->EnableItem(TBI_DECREASE,true); 781 } 782 //add end 783 } 784 else if(nId == TBI_DECREASE) 785 { 786 EndTracking(); 787 mbFocusOnFontSizeCtrl = false; 788 sal_Int64 iValue = maFontSizeBox.GetValue(); 789 int iPos = maFontSizeBox.GetValuePos(iValue, FUNIT_NONE); 790 long nSize = iValue; 791 if(iPos != LISTBOX_ENTRY_NOTFOUND) 792 nSize = maFontSizeBox.GetValue(iPos-1 , FUNIT_NONE); 793 else if(iValue > 100 && iValue <= 105) 794 nSize = 100; 795 else if(iValue > 105 && iValue <= 110) 796 nSize = 105; 797 else if(iValue > 960) 798 { 799 nSize = 960; 800 } 801 else if(iValue > 60) 802 { 803 nSize = (nSize / 10) * 10 ; 804 while(maFontSizeBox.GetValuePos(nSize, FUNIT_NONE) == LISTBOX_ENTRY_NOTFOUND) 805 nSize -= 10; 806 } 807 else 808 { 809 nSize = iValue; 810 } 811 812 float fSize = (float)nSize / 10; 813 814 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric(); 815 SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ; 816 817 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L ); 818 mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false); 819 //add 820 maFontSizeBox.SetValue( nSize ); 821 if(nSize >= 960) 822 { 823 mpToolBoxIncDec->EnableItem(TBI_INCREASE,false); 824 mpToolBoxIncDec->EnableItem(TBI_DECREASE,true); 825 } 826 else if(nSize <= 60) 827 { 828 mpToolBoxIncDec->EnableItem(TBI_INCREASE,true); 829 mpToolBoxIncDec->EnableItem(TBI_DECREASE,false); 830 } 831 else 832 { 833 mpToolBoxIncDec->EnableItem(TBI_INCREASE,true); 834 mpToolBoxIncDec->EnableItem(TBI_DECREASE,true); 835 } 836 //add end 837 } 838 } 839 return 0; 840 } 841 842 843 844 845 IMPL_LINK(TextPropertyPanel, ToolBoxUnderlineClickHdl, ToolBox*, pToolBox) 846 { 847 const sal_uInt16 nId = pToolBox->GetCurItemId(); 848 if(nId == TBI_UNDERLINE) 849 { 850 pToolBox->SetItemDown( nId, true ); 851 852 /**AF 853 SvxTextUnderlinePage* pUnderlinePage = GetUnderlinePage(); 854 Size aFloatSz = pUnderlinePage->GetOutputSizePixel(); 855 GetUnderlineFloatWin()->SetSizePixel( aFloatSz ); 856 857 Point aPos = mpToolBoxFont->GetPosPixel(); 858 aPos = OutputToScreenPixel( aPos ); 859 Size aSize = mpToolBoxFont->GetSizePixel(); 860 Rectangle aRect( aPos, aSize ); 861 862 GetUnderlineFloatWin()->StartPopupMode( aRect, FLOATWIN_POPUPMODE_NOFOCUSCLOSE|FLOATWIN_POPUPMODE_DOWN ); 863 GetUnderlineFloatWin()->SetPopupModeFlags(GetUnderlineFloatWin()->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE ); 864 pUnderlinePage->SetUnderlineSelect(meUnderline); 865 */ 866 } 867 return 0; 868 } 869 870 871 872 873 IMPL_LINK(TextPropertyPanel, ToolBoxFontColorDropHdl,ToolBox*, pToolBox) 874 { 875 const sal_uInt16 nId = pToolBox->GetCurItemId(); 876 if(nId == TBI_FONTCOLOR) 877 { 878 meColorType = FONT_COLOR; 879 880 pToolBox->SetItemDown( nId, true ); 881 882 /*AF 883 SvxTextFontColorPage* pFontColorPage = GetFontColorPage(); 884 885 Size aFloatSz = pFontColorPage->GetOutputSizePixel(); 886 GetFontColorFloatWin()->SetSizePixel( aFloatSz ); 887 888 Point aPos = mpToolBoxFontColor->GetPosPixel(); 889 aPos = OutputToScreenPixel( aPos ); 890 Size aSize = mpToolBoxFontColor->GetSizePixel(); 891 Rectangle aRect( aPos, aSize ); 892 893 GetFontColorFloatWin()->StartPopupMode( aRect, FLOATWIN_POPUPMODE_NOFOCUSCLOSE|FLOATWIN_POPUPMODE_DOWN ); 894 GetFontColorFloatWin()->SetPopupModeFlags(GetFontColorFloatWin()->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE ); 895 896 pFontColorPage->GetFocus(); 897 pFontColorPage->SetCurColorSelect(maColor, mbColorAvailable); 898 */ 899 } 900 return 0; 901 } 902 903 904 905 906 IMPL_LINK(TextPropertyPanel, ToolBoxSwScriptSelectHdl, ToolBox*, pToolBox) 907 { 908 const sal_uInt16 nId = pToolBox->GetCurItemId(); 909 if( nId == TBI_SUPER_SW ) 910 { 911 if(meEscape != SVX_ESCAPEMENT_SUPERSCRIPT) 912 { 913 meEscape = SVX_ESCAPEMENT_SUPERSCRIPT; 914 SvxEscapementItem aSupItem(DFLT_ESC_SUPER, DFLT_ESC_PROP, SID_ATTR_CHAR_ESCAPEMENT); 915 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aSupItem, 0L ); 916 } 917 else 918 { 919 meEscape = SVX_ESCAPEMENT_OFF; 920 SvxEscapementItem aNoneItem(0, 100, SID_ATTR_CHAR_ESCAPEMENT); 921 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aNoneItem, 0L ); 922 } 923 } 924 else if(TBI_SUB_SW == nId) 925 { 926 if(meEscape != SVX_ESCAPEMENT_SUBSCRIPT) 927 { 928 meEscape = (SvxEscapement)SVX_ESCAPEMENT_SUBSCRIPT; 929 SvxEscapementItem aSubItem(DFLT_ESC_SUB, DFLT_ESC_PROP, SID_ATTR_CHAR_ESCAPEMENT); 930 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aSubItem, 0L ); 931 } 932 else 933 { 934 meEscape = SVX_ESCAPEMENT_OFF; 935 SvxEscapementItem aNoneItem(0, 100, SID_ATTR_CHAR_ESCAPEMENT); 936 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aNoneItem, 0L ); 937 } 938 } 939 UpdateFontScript(); 940 941 return 0; 942 } 943 944 945 946 947 IMPL_LINK(TextPropertyPanel, ToolBoxScriptSelectHdl, ToolBox*, pToolBox) 948 { 949 const sal_uInt16 nId = pToolBox->GetCurItemId(); 950 if( nId == TBI_SUPER ) 951 { 952 mbSuper = !mbSuper; 953 SfxBoolItem aSupItem(SID_SET_SUPER_SCRIPT, mbSuper); 954 mpBindings->GetDispatcher()->Execute( SID_SET_SUPER_SCRIPT, SFX_CALLMODE_RECORD, &aSupItem, 0L ); 955 } 956 else if(TBI_SUB == nId) 957 { 958 959 mbSub = !mbSub; 960 SfxBoolItem aSubItem(SID_SET_SUB_SCRIPT, mbSub ); 961 mpBindings->GetDispatcher()->Execute( SID_SET_SUB_SCRIPT, SFX_CALLMODE_RECORD, &aSubItem, 0L ); 962 } 963 UpdateFontScript(); 964 return 0; 965 } 966 967 968 969 970 IMPL_LINK(TextPropertyPanel, ToolBoxHighlightDropHdl, ToolBox*, pToolBox) 971 { 972 const sal_uInt16 nId = pToolBox->GetCurItemId(); 973 if(nId == TBI_HIGHLIGHT) 974 { 975 meColorType = BACK_COLOR; 976 977 pToolBox->SetItemDown( nId, true ); 978 979 /*AF 980 SvxTextFontColorPage* pFontColorPage = GetFontColorPage(); 981 982 Size aFloatSz = pFontColorPage->GetOutputSizePixel(); 983 GetFontColorFloatWin()->SetSizePixel( aFloatSz ); 984 985 Point aPos = mpToolBoxHighlight->GetPosPixel(); 986 aPos = OutputToScreenPixel( aPos ); 987 Size aSize = mpToolBoxHighlight->GetSizePixel(); 988 Rectangle aRect( aPos, aSize ); 989 990 GetFontColorFloatWin()->StartPopupMode( aRect, FLOATWIN_POPUPMODE_NOFOCUSCLOSE|FLOATWIN_POPUPMODE_DOWN ); 991 GetFontColorFloatWin()->SetPopupModeFlags(GetFontColorFloatWin()->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE ); 992 993 pFontColorPage->GetFocus(); 994 pFontColorPage->SetCurColorSelect(maBackColor, 995 mbBackColorAvailable); 996 */ 997 } 998 return 0; 999 } 1000 1001 1002 1003 1004 IMPL_LINK(TextPropertyPanel, SpacingClickHdl, ToolBox*, pToolBox) 1005 { 1006 const sal_uInt16 nId = pToolBox->GetCurItemId(); 1007 if(nId == TBI_SPACING) 1008 { 1009 pToolBox->SetItemDown( nId, true ); 1010 1011 /*AF 1012 SvxTextSpacingPage* pSpacingPage = GetSpacingPage(); 1013 pSpacingPage->SetControlState(mbKernLBAvailable,mbKernAvailable,mlKerning); 1014 1015 Size aFloatSz = pSpacingPage->GetOutputSizePixel(); 1016 GetSpacingFloatWin()->SetSizePixel( aFloatSz ); 1017 1018 Point aPos = mpToolBoxSpacing->GetPosPixel(); 1019 aPos = OutputToScreenPixel( aPos ); 1020 Size aSize = mpToolBoxSpacing->GetSizePixel(); 1021 Rectangle aRect( aPos, aSize ); 1022 1023 GetSpacingFloatWin()->StartPopupMode( aRect, FLOATWIN_POPUPMODE_NOFOCUSCLOSE|FLOATWIN_POPUPMODE_DOWN ); 1024 GetSpacingFloatWin()->SetPopupModeFlags(GetSpacingFloatWin()->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE ); 1025 pSpacingPage->GetFocus(); 1026 */ 1027 } 1028 return 0; 1029 } 1030 1031 1032 1033 1034 IMPL_LINK( TextPropertyPanel, ImplPopupModeEndHdl, FloatingWindow*, EMPTYARG ) 1035 { 1036 return 0; 1037 } 1038 1039 1040 1041 1042 IMPL_LINK( TextPropertyPanel, ImplSpacingPopupModeEndHdl, FloatingWindow*, EMPTYARG ) 1043 { 1044 /*AF 1045 if(mpPageSpacing) 1046 { 1047 if( mpPageSpacing->GetLastCustomState() == SPACING_CLOSE_BY_CUS_EDIT) 1048 { 1049 SvtViewOptions aWinOpt( E_WINDOW, SIDEBAR_SPACING_GLOBAL_VALUE ); 1050 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1); 1051 aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Spacing") ); 1052 aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt32( mpPageSpacing->GetLastCustomValue() )); 1053 aWinOpt.SetUserData( aSeq ); 1054 1055 } 1056 } 1057 */ 1058 return 0; 1059 } 1060 1061 1062 1063 1064 void TextPropertyPanel::NotifyItemUpdate ( 1065 const sal_uInt16 nSID, 1066 const SfxItemState eState, 1067 const SfxPoolItem* pState) 1068 { 1069 switch(nSID) 1070 { 1071 case SID_ATTR_CHAR_FONT: 1072 if ( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxFontItem) ) 1073 { 1074 mpFontNameBox->Enable(); 1075 const SvxFontItem* pFontItem = (const SvxFontItem*)pState; 1076 mpFontNameBox->SetText( pFontItem->GetFamilyName() ); 1077 } 1078 else 1079 { 1080 mpFontNameBox->SetText( String() ); 1081 if (SFX_ITEM_DISABLED == eState) 1082 { 1083 mpFontNameBox->Disable(); 1084 } 1085 } 1086 break; 1087 case SID_ATTR_CHAR_FONTHEIGHT: 1088 if ( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxFontHeightItem) ) 1089 { 1090 mpHeightItem = (SvxFontHeightItem*)pState;//const SvxFontHeightItem* 1091 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric(); 1092 long iValue = (long)CalcToPoint( mpHeightItem->GetHeight(), eUnit, 10 ); 1093 mpToolBoxIncDec->Enable(); 1094 1095 // font size +/- enhancement in sd 1096 switch(maContext.GetCombinedContext()) 1097 { 1098 case CombinedEnumContext(Application_Draw, Context_DrawText): 1099 case CombinedEnumContext(Application_Draw, Context_Text): 1100 case CombinedEnumContext(Application_Draw, Context_Table): 1101 case CombinedEnumContext(Application_Draw, Context_OutlineText): 1102 case CombinedEnumContext(Application_Draw, Context_Draw): 1103 case CombinedEnumContext(Application_Draw, Context_TextObject): 1104 case CombinedEnumContext(Application_Draw, Context_Graphic): 1105 case CombinedEnumContext(Application_Impress, Context_DrawText): 1106 case CombinedEnumContext(Application_Impress, Context_Text): 1107 case CombinedEnumContext(Application_Impress, Context_Table): 1108 case CombinedEnumContext(Application_Impress, Context_OutlineText): 1109 case CombinedEnumContext(Application_Impress, Context_Draw): 1110 case CombinedEnumContext(Application_Impress, Context_TextObject): 1111 case CombinedEnumContext(Application_Impress, Context_Graphic): 1112 break; 1113 1114 default: 1115 if(iValue > 60 && iValue < 960 ) 1116 { 1117 mpToolBoxIncDec->EnableItem(TBI_INCREASE,true); 1118 mpToolBoxIncDec->EnableItem(TBI_DECREASE,true); 1119 } 1120 else if (iValue <= 60) 1121 { 1122 mpToolBoxIncDec->EnableItem(TBI_INCREASE,true); 1123 mpToolBoxIncDec->EnableItem(TBI_DECREASE,false); 1124 } 1125 else if (iValue >= 960) 1126 { 1127 mpToolBoxIncDec->EnableItem(TBI_INCREASE,false); 1128 mpToolBoxIncDec->EnableItem(TBI_DECREASE,true); 1129 } 1130 } 1131 mpToolBoxIncDec->SetItemState(TBI_INCREASE, STATE_NOCHECK); 1132 mpToolBoxIncDec->SetItemState(TBI_DECREASE, STATE_NOCHECK); 1133 1134 if( mbFocusOnFontSizeCtrl ) 1135 return; 1136 1137 maFontSizeBox.Enable( ); 1138 maFontSizeBox.SetValue( iValue ); 1139 maFontSizeBox.LoseFocus(); 1140 } 1141 else 1142 { 1143 mpHeightItem = NULL; 1144 maFontSizeBox.SetText( String() ); 1145 //increase decrease diabled when multi-seletion have different font size 1146 1147 // font size +/- enhancement in sd 1148 switch(maContext.GetCombinedContext()) 1149 { 1150 case CombinedEnumContext(Application_Draw, Context_DrawText): 1151 case CombinedEnumContext(Application_Draw, Context_Text): 1152 case CombinedEnumContext(Application_Draw, Context_Table): 1153 case CombinedEnumContext(Application_Draw, Context_OutlineText): 1154 case CombinedEnumContext(Application_Draw, Context_Draw): 1155 case CombinedEnumContext(Application_Draw, Context_TextObject): 1156 case CombinedEnumContext(Application_Draw, Context_Graphic): 1157 case CombinedEnumContext(Application_Impress, Context_DrawText): 1158 case CombinedEnumContext(Application_Impress, Context_Text): 1159 case CombinedEnumContext(Application_Impress, Context_Table): 1160 case CombinedEnumContext(Application_Impress, Context_OutlineText): 1161 case CombinedEnumContext(Application_Impress, Context_Draw): 1162 case CombinedEnumContext(Application_Impress, Context_TextObject): 1163 case CombinedEnumContext(Application_Impress, Context_Graphic): 1164 break; 1165 1166 default: 1167 mpToolBoxIncDec->Disable(); 1168 } 1169 if ( eState <= SFX_ITEM_READONLY ) 1170 { 1171 maFontSizeBox.Disable( ); 1172 } 1173 } 1174 break; 1175 case SID_ATTR_CHAR_WEIGHT: 1176 mbWeightAvailable = (eState >= SFX_ITEM_DONTCARE); 1177 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxWeightItem)) 1178 { 1179 const SvxWeightItem* pItem = (const SvxWeightItem*)pState; 1180 meWeight = (FontWeight)pItem->GetValue(); 1181 TextStyleChanged(); 1182 } 1183 else 1184 { 1185 meWeight = WEIGHT_NORMAL; 1186 TextStyleChanged(); 1187 } 1188 break; 1189 case SID_ATTR_CHAR_POSTURE: 1190 mbPostureAvailable = (eState >= SFX_ITEM_DONTCARE); 1191 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxPostureItem)) 1192 { 1193 const SvxPostureItem* pItem = (const SvxPostureItem*)pState; 1194 meItalic = (FontItalic)pItem->GetValue(); 1195 TextStyleChanged(); 1196 } 1197 else 1198 { 1199 meItalic = ITALIC_NONE; 1200 TextStyleChanged(); 1201 } 1202 break; 1203 case SID_ATTR_CHAR_UNDERLINE: 1204 if( eState >= SFX_ITEM_DEFAULT) //SvxUnderlineItem 1205 { 1206 //<<delete 1207 //if(pState->ISA(SvxTextLineItem)) 1208 //{ 1209 // const SvxTextLineItem* pItem = (const SvxTextLineItem*)pState; 1210 // meUnderline = (FontUnderline)pItem->GetValue(); 1211 // //add , need to record the underline's color, if not the color will turn to auto 1212 // meUnderlineColor = pItem->GetColor(); 1213 // //add end 1214 //} 1215 //else 1216 //delete end>> 1217 if(pState->ISA(SvxUnderlineItem)) 1218 { 1219 const SvxUnderlineItem* pItem = (const SvxUnderlineItem*)pState; 1220 meUnderline = (FontUnderline)pItem->GetValue(); 1221 //add 1222 meUnderlineColor = pItem->GetColor(); 1223 //add end 1224 } 1225 TextStyleChanged(); 1226 } 1227 else 1228 { 1229 meUnderline = UNDERLINE_NONE; 1230 TextStyleChanged(); 1231 } 1232 break; 1233 case SID_ATTR_CHAR_SHADOWED: 1234 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxShadowedItem)) 1235 { 1236 const SvxShadowedItem* pItem = (const SvxShadowedItem*)pState; 1237 mbShadow = pItem->GetValue(); 1238 TextStyleChanged(); 1239 } 1240 else 1241 { 1242 mbShadow = false; 1243 TextStyleChanged(); 1244 } 1245 break; 1246 case SID_ATTR_CHAR_STRIKEOUT: 1247 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxCrossedOutItem)) 1248 { 1249 const SvxCrossedOutItem* pItem = (const SvxCrossedOutItem*)pState; 1250 meStrike = (FontStrikeout)pItem->GetValue(); 1251 1252 TextStyleChanged(); 1253 } 1254 else 1255 { 1256 meStrike = STRIKEOUT_NONE; 1257 TextStyleChanged(); 1258 } 1259 break; 1260 case SID_ATTR_CHAR_COLOR: 1261 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxColorItem)) 1262 { 1263 const SvxBrushItem* pItem = (const SvxBrushItem*)pState; 1264 maColor = pItem->GetColor(); 1265 mbColorAvailable = true; 1266 if (mpFontColorUpdater) 1267 mpFontColorUpdater->Update(maColor); 1268 } 1269 else 1270 { 1271 mbColorAvailable = false; 1272 maColor.SetColor(COL_AUTO); 1273 if (mpFontColorUpdater) 1274 mpFontColorUpdater->Update(maColor); 1275 } 1276 break; 1277 case SID_ATTR_BRUSH_CHAR: 1278 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxBrushItem)) 1279 { 1280 const SvxBrushItem* pItem = (const SvxBrushItem*)pState; 1281 maBackColor = pItem->GetColor(); 1282 mbBackColorAvailable = true; 1283 mpHighlightUpdater->Update(maBackColor); 1284 } 1285 else 1286 { 1287 mbBackColorAvailable = false; 1288 maBackColor.SetColor(COL_AUTO); 1289 mpHighlightUpdater->Update(maBackColor); 1290 } 1291 break; 1292 case SID_ATTR_CHAR_ESCAPEMENT: 1293 if( eState == SFX_ITEM_AVAILABLE) 1294 { 1295 if( pState->ISA(SvxEscapementItem)) 1296 { 1297 const SvxEscapementItem* pItem = (const SvxEscapementItem *)pState; 1298 short nEsc = pItem->GetEsc(); 1299 if(nEsc == 0) 1300 meEscape = SVX_ESCAPEMENT_OFF; 1301 else if(nEsc > 0) 1302 meEscape = SVX_ESCAPEMENT_SUPERSCRIPT; 1303 else 1304 meEscape = SVX_ESCAPEMENT_SUBSCRIPT; 1305 } 1306 else 1307 { 1308 meEscape = SVX_ESCAPEMENT_OFF; 1309 } 1310 TextStyleChanged(); 1311 } 1312 else if(eState == SFX_ITEM_DISABLED) 1313 { 1314 mpToolBoxScriptSw->EnableItem(TBI_SUPER,false); 1315 mpToolBoxScriptSw->EnableItem(TBI_SUB,false); 1316 } 1317 else 1318 { 1319 meEscape = SVX_ESCAPEMENT_OFF; 1320 TextStyleChanged(); 1321 } 1322 break; 1323 case SID_SET_SUB_SCRIPT: 1324 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SfxBoolItem)) 1325 { 1326 const SfxBoolItem* pItem = (const SfxBoolItem*)pState; 1327 mbSub = pItem->GetValue(); 1328 TextStyleChanged(); 1329 } 1330 else 1331 { 1332 mbSub = false; 1333 TextStyleChanged(); 1334 } 1335 break; 1336 case SID_SET_SUPER_SCRIPT: 1337 if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SfxBoolItem)) 1338 { 1339 const SfxBoolItem* pItem = (const SfxBoolItem*)pState; 1340 mbSuper = pItem->GetValue(); 1341 TextStyleChanged(); 1342 } 1343 else 1344 { 1345 mbSuper = false; 1346 TextStyleChanged(); 1347 } 1348 break; 1349 case SID_ATTR_CHAR_KERNING: 1350 if ( SFX_ITEM_AVAILABLE == eState ) 1351 { 1352 mbKernLBAvailable = true; 1353 1354 if(pState->ISA(SvxKerningItem)) 1355 { 1356 const SvxKerningItem* pKerningItem = (const SvxKerningItem*)pState; 1357 mlKerning = (long)pKerningItem->GetValue(); 1358 mbKernAvailable = true; 1359 } 1360 else 1361 { 1362 mlKerning = 0; 1363 mbKernAvailable =false; 1364 } 1365 } 1366 else if (SFX_ITEM_DISABLED == eState) 1367 { 1368 mbKernLBAvailable = false; 1369 mbKernAvailable = false; 1370 mlKerning = 0; 1371 } 1372 else 1373 { 1374 mbKernLBAvailable = true; 1375 mbKernAvailable = false; 1376 mlKerning = 0; 1377 } 1378 break; 1379 1380 // font size +/- enhancement in sd 1381 case SID_SHRINK_FONT_SIZE: 1382 case SID_GROW_FONT_SIZE: 1383 switch(maContext.GetCombinedContext()) 1384 { 1385 case CombinedEnumContext(Application_Draw, Context_DrawText): 1386 case CombinedEnumContext(Application_Draw, Context_Text): 1387 case CombinedEnumContext(Application_Draw, Context_Table): 1388 case CombinedEnumContext(Application_Draw, Context_OutlineText): 1389 case CombinedEnumContext(Application_Draw, Context_Draw): 1390 case CombinedEnumContext(Application_Draw, Context_TextObject): 1391 case CombinedEnumContext(Application_Draw, Context_Graphic): 1392 case CombinedEnumContext(Application_Impress, Context_DrawText): 1393 case CombinedEnumContext(Application_Impress, Context_Text): 1394 case CombinedEnumContext(Application_Impress, Context_Table): 1395 case CombinedEnumContext(Application_Impress, Context_OutlineText): 1396 case CombinedEnumContext(Application_Impress, Context_Draw): 1397 case CombinedEnumContext(Application_Impress, Context_TextObject): 1398 case CombinedEnumContext(Application_Impress, Context_Graphic): 1399 if(eState == SFX_ITEM_DISABLED) 1400 { 1401 mpToolBoxIncDec->Disable(); 1402 } 1403 else 1404 { 1405 mpToolBoxIncDec->Enable(); 1406 } 1407 break; 1408 } 1409 break; 1410 } 1411 } 1412 1413 1414 1415 1416 void TextPropertyPanel::TextStyleChanged() 1417 { 1418 if( !mbWeightAvailable ) 1419 mpToolBoxFont->EnableItem(TBI_BOLD,false); 1420 else 1421 mpToolBoxFont->EnableItem(TBI_BOLD,true); 1422 1423 if(!mbPostureAvailable ) 1424 mpToolBoxFont->EnableItem(TBI_ITALIC,false); 1425 else 1426 mpToolBoxFont->EnableItem(TBI_ITALIC,true); 1427 1428 UpdateFontBold(); 1429 UpdateFontItalic(); 1430 UpdateFontUnderline(); 1431 UpdateFontStrikeOut(); 1432 UpdateFontShadowed(); 1433 UpdateFontScript(); 1434 } 1435 1436 1437 1438 1439 void TextPropertyPanel::UpdateFontBold() 1440 { 1441 if( meWeight == WEIGHT_BOLD ) 1442 { 1443 mpToolBoxFont->SetItemState(TBI_BOLD, STATE_CHECK); 1444 } 1445 else 1446 { 1447 mpToolBoxFont->SetItemState(TBI_BOLD, STATE_NOCHECK); 1448 } 1449 } 1450 void TextPropertyPanel::UpdateFontItalic() 1451 { 1452 if(meItalic == ITALIC_NORMAL) 1453 { 1454 mpToolBoxFont->SetItemState(TBI_ITALIC, STATE_CHECK); 1455 } 1456 else 1457 { 1458 mpToolBoxFont->SetItemState(TBI_ITALIC, STATE_NOCHECK); 1459 } 1460 } 1461 void TextPropertyPanel::UpdateFontUnderline() 1462 { 1463 if(meUnderline == UNDERLINE_NONE) 1464 { 1465 mpToolBoxFont->SetItemState(TBI_UNDERLINE, STATE_NOCHECK); 1466 } 1467 else 1468 { 1469 mpToolBoxFont->SetItemState(TBI_UNDERLINE, STATE_CHECK); 1470 } 1471 } 1472 void TextPropertyPanel::UpdateFontStrikeOut() 1473 { 1474 if(meStrike != STRIKEOUT_NONE && meStrike != STRIKEOUT_DONTKNOW) 1475 { 1476 mpToolBoxFont->SetItemState(TBI_STRIKEOUT, STATE_CHECK); 1477 } 1478 else 1479 { 1480 mpToolBoxFont->SetItemState(TBI_STRIKEOUT, STATE_NOCHECK); 1481 } 1482 } 1483 void TextPropertyPanel::UpdateFontShadowed() 1484 { 1485 if(mbShadow) 1486 { 1487 mpToolBoxFont->SetItemState(TBI_SHADOWED, STATE_CHECK); 1488 } 1489 else 1490 { 1491 mpToolBoxFont->SetItemState(TBI_SHADOWED, STATE_NOCHECK); 1492 } 1493 } 1494 void TextPropertyPanel::UpdateFontScript() 1495 { 1496 //script for sw 1497 mpToolBoxScriptSw->EnableItem(TBI_SUPER,true); 1498 mpToolBoxScriptSw->EnableItem(TBI_SUB,true); 1499 if(meEscape == SVX_ESCAPEMENT_SUPERSCRIPT) 1500 { 1501 mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_CHECK); 1502 mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_NOCHECK); 1503 } 1504 else if(meEscape == SVX_ESCAPEMENT_SUBSCRIPT) 1505 { 1506 mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK); 1507 mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_CHECK); 1508 } 1509 else 1510 { 1511 mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK); 1512 mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_NOCHECK); 1513 } 1514 1515 //script for sc sd 1516 mpToolBoxScript->EnableItem(TBI_SUPER,true); 1517 mpToolBoxScript->EnableItem(TBI_SUB,true); 1518 if(mbSuper) 1519 { 1520 mpToolBoxScript->SetItemState(TBI_SUPER, STATE_CHECK); 1521 mpToolBoxScript->SetItemState(TBI_SUB, STATE_NOCHECK); 1522 } 1523 else if(mbSub) 1524 { 1525 mpToolBoxScript->SetItemState(TBI_SUPER, STATE_NOCHECK); 1526 mpToolBoxScript->SetItemState(TBI_SUB, STATE_CHECK); 1527 } 1528 else 1529 { 1530 mpToolBoxScript->SetItemState(TBI_SUPER, STATE_NOCHECK); 1531 mpToolBoxScript->SetItemState(TBI_SUB, STATE_NOCHECK); 1532 } 1533 } 1534 1535 /* 1536 USHORT TextPropertyPanel::GetCurrColorType() 1537 { 1538 return meColorType; 1539 } 1540 long TextPropertyPanel::GetSelFontSize() 1541 { 1542 long nH = 240; 1543 SfxMapUnit eUnit = maSpacingControl.GetCoreMetric(); 1544 if (mpHeightItem) 1545 nH = LogicToLogic( mpHeightItem->GetHeight(), (MapUnit)eUnit, MAP_TWIP ); 1546 return nH; 1547 } 1548 SfxPropertyPageController TextPropertyPanel::GetSpaceController() 1549 { 1550 return maSpacingControl; 1551 } 1552 1553 //add 1554 Color& TextPropertyPanel::GetUnderlineColor() 1555 { 1556 return meUnderlineColor; 1557 } 1558 //add end 1559 void TextPropertyPanel::SetBackColor(Color aCol) 1560 { 1561 maBackColor = aCol; 1562 } 1563 void TextPropertyPanel::SetColor(Color aCol) 1564 { 1565 maColor = aCol; 1566 } 1567 void TextPropertyPanel::SetUnderline(FontUnderline eUnderline) 1568 { 1569 meUnderline = eUnderline; 1570 } 1571 void TextPropertyPanel::SetSpacing(long nKern) 1572 { 1573 mlKerning = nKern; 1574 } 1575 */ 1576 } } // end of namespace svx::sidebar 1577