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 "svx/sidebar/PopupContainer.hxx" 23 #include "AreaTransparencyGradientControl.hxx" 24 25 #include <sfx2/sidebar/ResourceDefinitions.hrc> 26 #include <sfx2/sidebar/Theme.hxx> 27 #include <sfx2/sidebar/ControlFactory.hxx> 28 #include <sfx2/sidebar/Layouter.hxx> 29 #include <AreaPropertyPanel.hxx> 30 #include <AreaPropertyPanel.hrc> 31 #include <svx/dialogs.hrc> 32 #include <svx/dialmgr.hxx> 33 #include <sfx2/objsh.hxx> 34 #include <svx/xfltrit.hxx> 35 #include <svx/xflftrit.hxx> 36 #include <svx/xtable.hxx> 37 #include <sfx2/dispatch.hxx> 38 #include <sfx2/bindings.hxx> 39 #include <helpid.hrc> 40 #include <svtools/valueset.hxx> 41 #include <unotools/pathoptions.hxx> 42 #include <svx/svxitems.hrc> 43 #include <vcl/toolbox.hxx> 44 #include <svtools/toolbarmenu.hxx> 45 #include <svx/sidebar/ColorControl.hxx> 46 47 #include <boost/bind.hpp> 48 49 using namespace css; 50 using namespace cssu; 51 using ::sfx2::sidebar::Layouter; 52 using ::sfx2::sidebar::Theme; 53 54 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 55 56 57 58 59 namespace svx { namespace sidebar { 60 61 const sal_Int32 AreaPropertyPanel::DEFAULT_CENTERX = 50; 62 const sal_Int32 AreaPropertyPanel::DEFAULT_CENTERY = 50; 63 const sal_Int32 AreaPropertyPanel::DEFAULT_ANGLE = 0; 64 const sal_Int32 AreaPropertyPanel::DEFAULT_STARTVALUE = 0; 65 const sal_Int32 AreaPropertyPanel::DEFAULT_ENDVALUE = 16777215; 66 const sal_Int32 AreaPropertyPanel::DEFAULT_BORDER = 0; 67 68 69 AreaPropertyPanel::AreaPropertyPanel( 70 Window* pParent, 71 const cssu::Reference<css::frame::XFrame>& rxFrame, 72 SfxBindings* pBindings) 73 : Control(pParent, SVX_RES(RID_SIDEBAR_AREA_PANEL)), 74 meLastXFS(-1), 75 maLastColor(Color(COL_DEFAULT_SHAPE_FILLING)), 76 mnLastPosGradient(0), 77 mnLastPosHatch(0), 78 mnLastPosBitmap(0), 79 mnLastTransSolid(50), 80 maGradientLinear(), 81 maGradientAxial(), 82 maGradientRadial(), 83 maGradientElliptical(), 84 maGradientSquare(), 85 maGradientRect(), 86 mpColorTextFT(new FixedText(this, SVX_RES(FT_COLOR_LIST))), 87 mpLbFillType(new SvxFillTypeBox(this)), 88 mpLbFillAttr(new SvxFillAttrBox(this)), 89 mpToolBoxColorBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)), 90 mpToolBoxColor(sfx2::sidebar::ControlFactory::CreateToolBox(mpToolBoxColorBackground.get(), SVX_RES(TB_COLOR))), 91 mpTrspTextFT(new FixedText(this, SVX_RES(FL_TRSP_TEXT))), 92 mpLBTransType(new ListBox(this, SVX_RES(LB_TRGR_TYPES))), 93 mpMTRTransparent(new MetricField(this, SVX_RES(MTR_TRANSPARENT))), 94 mpBTNGradientBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)), 95 mpBTNGradient(sfx2::sidebar::ControlFactory::CreateToolBox(mpBTNGradientBackground.get(), SVX_RES(BTN_GRADIENT))), 96 mpColorUpdater(new ::svx::ToolboxButtonColorUpdater(SID_ATTR_FILL_COLOR, TBI_COLOR, mpToolBoxColor.get(), TBX_UPDATER_MODE_CHAR_COLOR_NEW)), 97 mpStyleItem(), 98 mpColorItem(), 99 mpFillGradientItem(), 100 mpHatchItem(), 101 mpBitmapItem(), 102 maStyleControl(SID_ATTR_FILL_STYLE, *pBindings, *this), 103 maColorControl(SID_ATTR_FILL_COLOR, *pBindings, *this), 104 maGradientControl(SID_ATTR_FILL_GRADIENT, *pBindings, *this), 105 maHatchControl(SID_ATTR_FILL_HATCH, *pBindings, *this), 106 maBitmapControl(SID_ATTR_FILL_BITMAP, *pBindings, *this), 107 maColorTableControl(SID_COLOR_TABLE, *pBindings, *this), 108 maGradientListControl(SID_GRADIENT_LIST, *pBindings, *this), 109 maHatchListControl(SID_HATCH_LIST, *pBindings, *this), 110 maBitmapListControl(SID_BITMAP_LIST, *pBindings, *this), 111 maFillTransparenceController(SID_ATTR_FILL_TRANSPARENCE, *pBindings, *this), 112 maFillFloatTransparenceController(SID_ATTR_FILL_FLOATTRANSPARENCE, *pBindings, *this), 113 maImgAxial(SVX_RES(IMG_AXIAL)), 114 maImgElli(SVX_RES(IMG_ELLI)), 115 maImgQuad(SVX_RES(IMG_QUAD)), 116 maImgRadial(SVX_RES(IMG_RADIAL)), 117 maImgSquare(SVX_RES(IMG_SQUARE)), 118 maImgLinear(SVX_RES(IMG_LINEAR)), 119 maImgColor(SVX_RES(IMG_COLOR)), 120 maImgAxialH(SVX_RES(IMG_AXIAL_H)), 121 maImgElliH(SVX_RES(IMG_ELLI_H)), 122 maImgQuadH(SVX_RES(IMG_QUAD_H)), 123 maImgRadialH(SVX_RES(IMG_RADIAL_H)), 124 maImgSquareH(SVX_RES(IMG_SQUARE_H)), 125 maImgLinearH(SVX_RES(IMG_LINEAR_H)), 126 maImgColorH(SVX_RES(IMG_COLOR_H)), 127 msHelpFillType(SVX_RES(STR_HELP_TYPE)), 128 msHelpFillAttr(SVX_RES(STR_HELP_ATTR)), 129 maTrGrPopup(this, ::boost::bind(&AreaPropertyPanel::CreateTransparencyGradientControl, this, _1)), 130 maColorPopup(this, ::boost::bind(&AreaPropertyPanel::CreateColorPopupControl, this, _1)), 131 mpFloatTransparenceItem(), 132 mpTransparanceItem(), 133 mxFrame(rxFrame), 134 mpBindings(pBindings), 135 mbColorAvail(true), 136 maLayouter(*this) 137 { 138 Initialize(); 139 FreeResource(); 140 141 // Setup the grid layouter. 142 const sal_Int32 nMappedMboxWidth (Layouter::MapWidth(*this, MBOX_WIDTH)); 143 144 maLayouter.GetCell(0,0).SetControl(*mpColorTextFT).SetGridWidth(3); 145 maLayouter.GetCell(1,0).SetControl(*mpLbFillType); 146 maLayouter.GetCell(1,2,0).SetControl(*mpToolBoxColorBackground).SetFixedWidth(); 147 maLayouter.GetCell(1,2,1).SetControl(*mpLbFillAttr); 148 149 maLayouter.GetCell(2,0).SetControl(*mpTrspTextFT).SetGridWidth(3); 150 maLayouter.GetCell(3,0).SetControl(*mpLBTransType); 151 maLayouter.GetCell(3,2,0).SetControl(*mpMTRTransparent); 152 maLayouter.GetCell(3,2,1).SetControl(*mpBTNGradient); 153 154 maLayouter.GetColumn(0) 155 .SetWeight(1) 156 .SetLeftPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL)) 157 .SetMinimumWidth(nMappedMboxWidth); 158 maLayouter.GetColumn(1) 159 .SetWeight(0) 160 .SetMinimumWidth(Layouter::MapWidth(*this, CONTROL_SPACING_HORIZONTAL)); 161 maLayouter.GetColumn(2) 162 .SetWeight(1) 163 .SetMinimumWidth(nMappedMboxWidth) 164 .SetRightPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL)); 165 166 // Make controls that display text handle short widths more 167 // graceful. 168 Layouter::PrepareForLayouting(*mpColorTextFT); 169 Layouter::PrepareForLayouting(*mpTrspTextFT); 170 } 171 172 173 174 AreaPropertyPanel::~AreaPropertyPanel() 175 { 176 // Destroy the toolboxes, then their background windows. 177 mpToolBoxColor.reset(); 178 mpBTNGradient.reset(); 179 mpToolBoxColorBackground.reset(); 180 mpBTNGradientBackground.reset(); 181 } 182 183 184 185 void AreaPropertyPanel::Initialize() 186 { 187 mpColorTextFT->SetBackground(Wallpaper()); 188 mpTrspTextFT->SetBackground(Wallpaper()); 189 190 maGradientLinear.SetXOffset(DEFAULT_CENTERX); 191 maGradientLinear.SetYOffset(DEFAULT_CENTERY); 192 maGradientLinear.SetAngle(DEFAULT_ANGLE); 193 maGradientLinear.SetStartColor(Color(DEFAULT_STARTVALUE)); 194 maGradientLinear.SetEndColor(Color(DEFAULT_ENDVALUE)); 195 maGradientLinear.SetBorder(DEFAULT_BORDER); 196 maGradientLinear.SetGradientStyle(XGRAD_LINEAR); 197 198 maGradientAxial = maGradientLinear; 199 maGradientAxial.SetGradientStyle(XGRAD_AXIAL); 200 201 maGradientRadial = maGradientLinear; 202 maGradientRadial.SetGradientStyle(XGRAD_RADIAL); 203 204 maGradientElliptical = maGradientLinear; 205 maGradientElliptical.SetGradientStyle(XGRAD_ELLIPTICAL); 206 207 maGradientSquare = maGradientLinear; 208 maGradientSquare.SetGradientStyle(XGRAD_SQUARE); 209 210 maGradientRect = maGradientLinear; 211 maGradientRect.SetGradientStyle(XGRAD_RECT); 212 213 Size aLogicalFillSize(MBOX_WIDTH,LISTBOX_HEIGHT); 214 Size aLogicalAttrSize(MBOX_WIDTH + 1,LISTBOX_HEIGHT); 215 216 Point aPoint(SECTIONPAGE_MARGIN_HORIZONTAL,SECTIONPAGE_MARGIN_VERTICAL_TOP + FIXED_TEXT_HEIGHT + TEXT_CONTROL_SPACING_VERTICAL); 217 Point aPoint_Picker(SECTIONPAGE_MARGIN_HORIZONTAL + MBOX_WIDTH + CONTROL_SPACING_HORIZONTAL,SECTIONPAGE_MARGIN_VERTICAL_TOP + FIXED_TEXT_HEIGHT + TEXT_CONTROL_SPACING_VERTICAL); 218 219 Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT)); 220 Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT)); 221 222 Point aTypePoint(LogicToPixel(aPoint, MAP_APPFONT)); 223 Point aAttrPoint(LogicToPixel(aPoint_Picker, MAP_APPFONT)); 224 225 mpLbFillType->SetPosSizePixel(aTypePoint,aTypeSize); 226 mpLbFillAttr->SetPosSizePixel(aAttrPoint,aAttrSize); 227 228 mpLbFillType->SetHelpId(HID_PPROPERTYPANEL_AREA_LB_FILL_TYPES); 229 mpLbFillAttr->SetHelpId(HID_PPROPERTYPANEL_AREA_LB_FILL_ATTR); 230 231 mpLbFillType->SetQuickHelpText(msHelpFillType); 232 mpLbFillAttr->SetQuickHelpText(msHelpFillAttr); 233 234 mpLbFillType->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Fill"))); //wj acc 235 mpLbFillAttr->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Fill"))); //wj acc 236 237 Link aLink = LINK( this, AreaPropertyPanel, SelectFillTypeHdl ); 238 mpLbFillType->SetSelectHdl( aLink ); 239 240 aLink = LINK( this, AreaPropertyPanel, SelectFillAttrHdl ); 241 mpLbFillAttr->SetSelectHdl( aLink ); 242 243 //add for new color picker 244 mpLbFillAttr->Hide(); 245 mpToolBoxColor->SetItemImage(TBI_COLOR, GetDisplayBackground().GetColor().IsDark()? maImgColorH : maImgColor); 246 Size aTbxSize( mpToolBoxColor->CalcWindowSizePixel() ); 247 mpToolBoxColor->SetOutputSizePixel( aTbxSize ); 248 mpToolBoxColor->SetItemBits( TBI_COLOR, mpToolBoxColor->GetItemBits( TBI_COLOR ) | TIB_DROPDOWNONLY ); 249 mpToolBoxColor->SetBackground(Wallpaper()); 250 mpToolBoxColor->SetPaintTransparent(true); 251 mpToolBoxColor->SetQuickHelpText(TBI_COLOR, String(SVX_RES(STR_HELP_COLOR))); //wj acc 252 //mpToolBoxColor->SetItemText(TBI_COLOR, msHelpFillAttr); 253 254 long aHeightLBStyle = mpLbFillType->GetSizePixel().getHeight(); 255 long aLBPosY = mpLbFillType->GetPosPixel().getY(); 256 long aHeightTBAttr = mpToolBoxColor->GetSizePixel().getHeight(); 257 Point aPointTBAttr = mpToolBoxColor->GetPosPixel(); 258 aPointTBAttr.setY( aLBPosY + aHeightLBStyle / 2 - aHeightTBAttr / 2); 259 mpToolBoxColor->SetPosPixel(aPointTBAttr); 260 261 aLink = LINK(this, AreaPropertyPanel, ToolBoxColorDropHdl); 262 mpToolBoxColor->SetDropdownClickHdl ( aLink ); 263 mpToolBoxColor->SetSelectHdl ( aLink ); 264 265 //add end 266 mpLBTransType->SetSelectHdl(LINK(this, AreaPropertyPanel, ChangeTrgrTypeHdl_Impl)); 267 mpLBTransType->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Transparency"))); //wj acc 268 269 mpMTRTransparent->SetValue( 50 ); 270 mpMTRTransparent->SetModifyHdl(LINK(this, AreaPropertyPanel, ModifyTransparentHdl_Impl)); 271 mpMTRTransparent->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Transparency"))); //wj acc 272 273 mpBTNGradient->SetItemBits( TBI_BTX_GRADIENT, mpBTNGradient->GetItemBits( TBI_BTX_GRADIENT ) | TIB_DROPDOWNONLY ); 274 aLink = LINK( this, AreaPropertyPanel, ClickTrGrHdl_Impl ); 275 mpBTNGradient->SetDropdownClickHdl( aLink ); 276 mpBTNGradient->SetSelectHdl( aLink ); 277 aTbxSize = mpBTNGradient->CalcWindowSizePixel(); 278 mpBTNGradient->SetOutputSizePixel( aTbxSize ); 279 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,maImgLinear); 280 mpBTNGradient->SetQuickHelpText(TBI_BTX_GRADIENT, String(SVX_RES(STR_HELP_GRADIENT))); //wj acc 281 mpBTNGradient->Hide(); 282 283 long aHeightLBTrans = mpLBTransType->GetSizePixel().getHeight(); 284 Point aPointLB = mpLBTransType->GetPosPixel(); 285 long aPosY = aPointLB.getY(); 286 287 Point aPointMetric = mpMTRTransparent->GetPosPixel(); 288 Point aPointTB = mpMTRTransparent->GetPosPixel(); 289 long aHeightMetric = mpMTRTransparent->GetSizePixel().getHeight(); 290 long aHeightTool = mpBTNGradient->GetSizePixel().getHeight(); 291 aPointMetric.setY(aPosY+aHeightLBTrans/2-aHeightMetric/2); 292 aPointTB.setY(aPosY+aHeightLBTrans/2-aHeightTool/2); 293 aPointTB.setX(aPointTB.getX()+3); 294 mpMTRTransparent->SetPosPixel(aPointMetric); 295 mpBTNGradient->SetPosPixel(aPointTB); 296 297 mpLbFillType->SetAccessibleRelationLabeledBy(mpColorTextFT.get()); 298 mpLbFillAttr->SetAccessibleRelationLabeledBy(mpLbFillAttr.get()); 299 mpToolBoxColor->SetAccessibleRelationLabeledBy(mpToolBoxColor.get()); 300 mpLBTransType->SetAccessibleRelationLabeledBy(mpTrspTextFT.get()); 301 mpMTRTransparent->SetAccessibleRelationLabeledBy(mpMTRTransparent.get()); 302 mpBTNGradient->SetAccessibleRelationLabeledBy(mpBTNGradient.get()); 303 304 SetupIcons(); 305 } 306 307 308 309 IMPL_LINK( AreaPropertyPanel, SelectFillTypeHdl, ListBox *, pToolBox ) 310 { 311 const XFillStyle eXFS = (XFillStyle)mpLbFillType->GetSelectEntryPos(); 312 313 if((XFillStyle)meLastXFS != eXFS) 314 { 315 mpLbFillAttr->Clear(); 316 SfxObjectShell* pSh = SfxObjectShell::Current(); 317 const XFillStyleItem aXFillStyleItem(eXFS); 318 319 // #122676# Do no longer trigger two Execute calls, one for SID_ATTR_FILL_STYLE 320 // and one for setting the fill attribute itself, but add two SfxPoolItems to the 321 // call to get just one action at the SdrObject and to create only one Undo action, too. 322 // Checked that this works in all apps. 323 switch( eXFS ) 324 { 325 case XFILL_NONE: 326 { 327 mpLbFillAttr->Show(); 328 mpToolBoxColor->Hide(); 329 mpLbFillType->Selected(); 330 mpLbFillAttr->Disable(); 331 332 // #122676# need to call a single SID_ATTR_FILL_STYLE change 333 GetBindings()->GetDispatcher()->Execute( 334 SID_ATTR_FILL_STYLE, SFX_CALLMODE_RECORD, &aXFillStyleItem, 0L); 335 break; 336 } 337 case XFILL_SOLID: 338 { 339 mpLbFillAttr->Hide(); 340 mpToolBoxColor->Show(); 341 const String aTmpStr; 342 const Color aColor = maLastColor; 343 const XFillColorItem aXFillColorItem( aTmpStr, aColor ); 344 345 // #122676# change FillStyle and Color in one call 346 GetBindings()->GetDispatcher()->Execute( 347 SID_ATTR_FILL_COLOR, SFX_CALLMODE_RECORD, &aXFillColorItem, &aXFillStyleItem, 0L); 348 break; 349 } 350 case XFILL_GRADIENT: 351 { 352 mpLbFillAttr->Show(); 353 mpToolBoxColor->Hide(); 354 355 if(pSh && pSh->GetItem(SID_GRADIENT_LIST)) 356 { 357 if(!mpLbFillAttr->GetEntryCount()) 358 { 359 const SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); 360 mpLbFillAttr->Enable(); 361 mpLbFillAttr->Clear(); 362 mpLbFillAttr->Fill(aItem.GetGradientList()); 363 } 364 365 mpLbFillAttr->AdaptDropDownLineCountToMaximum(); 366 367 if(LISTBOX_ENTRY_NOTFOUND != mnLastPosGradient) 368 { 369 const SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); 370 371 if(mnLastPosGradient < aItem.GetGradientList()->Count()) 372 { 373 const XGradient aGradient = aItem.GetGradientList()->GetGradient(mnLastPosGradient)->GetGradient(); 374 const XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetEntry(mnLastPosGradient), aGradient); 375 376 // #122676# change FillStyle and Gradient in one call 377 GetBindings()->GetDispatcher()->Execute( 378 SID_ATTR_FILL_GRADIENT, SFX_CALLMODE_RECORD, &aXFillGradientItem, &aXFillStyleItem, 0L); 379 mpLbFillAttr->SelectEntryPos(mnLastPosGradient); 380 } 381 } 382 } 383 else 384 { 385 mpLbFillAttr->Disable(); 386 } 387 break; 388 } 389 case XFILL_HATCH: 390 { 391 mpLbFillAttr->Show(); 392 mpToolBoxColor->Hide(); 393 394 if(pSh && pSh->GetItem(SID_HATCH_LIST)) 395 { 396 if(!mpLbFillAttr->GetEntryCount()) 397 { 398 const SvxHatchListItem aItem( *(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); 399 mpLbFillAttr->Enable(); 400 mpLbFillAttr->Clear(); 401 mpLbFillAttr->Fill(aItem.GetHatchList()); 402 } 403 404 mpLbFillAttr->AdaptDropDownLineCountToMaximum(); 405 406 if(LISTBOX_ENTRY_NOTFOUND != mnLastPosHatch) 407 { 408 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); 409 410 if(mnLastPosHatch < aItem.GetHatchList()->Count()) 411 { 412 const XHatch aHatch = aItem.GetHatchList()->GetHatch(mnLastPosHatch)->GetHatch(); 413 const XFillHatchItem aXFillHatchItem(mpLbFillAttr->GetSelectEntry(), aHatch); 414 415 // #122676# change FillStyle and Hatch in one call 416 GetBindings()->GetDispatcher()->Execute( 417 SID_ATTR_FILL_HATCH, SFX_CALLMODE_RECORD, &aXFillHatchItem, &aXFillStyleItem, 0L); 418 mpLbFillAttr->SelectEntryPos(mnLastPosHatch); 419 } 420 } 421 } 422 else 423 { 424 mpLbFillAttr->Disable(); 425 } 426 break; 427 } 428 case XFILL_BITMAP: 429 { 430 mpLbFillAttr->Show(); 431 mpToolBoxColor->Hide(); 432 433 if(pSh && pSh->GetItem(SID_BITMAP_LIST)) 434 { 435 if(!mpLbFillAttr->GetEntryCount()) 436 { 437 const SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); 438 mpLbFillAttr->Enable(); 439 mpLbFillAttr->Clear(); 440 mpLbFillAttr->Fill(aItem.GetBitmapList()); 441 } 442 443 mpLbFillAttr->AdaptDropDownLineCountToMaximum(); 444 445 if(LISTBOX_ENTRY_NOTFOUND != mnLastPosBitmap) 446 { 447 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); 448 449 if(mnLastPosBitmap < aItem.GetBitmapList()->Count()) 450 { 451 const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(mnLastPosBitmap); 452 const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject()); 453 454 // #122676# change FillStyle and Bitmap in one call 455 GetBindings()->GetDispatcher()->Execute( 456 SID_ATTR_FILL_BITMAP, SFX_CALLMODE_RECORD, &aXFillBitmapItem, &aXFillStyleItem, 0L); 457 mpLbFillAttr->SelectEntryPos(mnLastPosBitmap); 458 } 459 } 460 } 461 else 462 { 463 mpLbFillAttr->Disable(); 464 } 465 break; 466 } 467 } 468 469 meLastXFS = (sal_uInt16)eXFS; 470 471 if(XFILL_NONE != eXFS) 472 { 473 if(pToolBox) 474 { 475 mpLbFillType->Selected(); 476 } 477 } 478 479 maLayouter.Layout(); 480 } 481 482 return 0; 483 } 484 485 486 487 IMPL_LINK( AreaPropertyPanel, SelectFillAttrHdl, ListBox*, pToolBox ) 488 { 489 const XFillStyle eXFS = (XFillStyle)mpLbFillType->GetSelectEntryPos(); 490 const XFillStyleItem aXFillStyleItem(eXFS); 491 SfxObjectShell* pSh = SfxObjectShell::Current(); 492 493 if(pToolBox) 494 { 495 // #122676# dependent from bFillStyleChange, do execute a single or two 496 // changes in one Execute call 497 const bool bFillStyleChange((XFillStyle) meLastXFS != eXFS); 498 499 switch(eXFS) 500 { 501 case XFILL_SOLID: 502 { 503 if(bFillStyleChange) 504 { 505 // #122676# Single FillStyle change call needed here 506 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_STYLE, SFX_CALLMODE_RECORD, &aXFillStyleItem, 0L); 507 } 508 break; 509 } 510 case XFILL_GRADIENT: 511 { 512 sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos(); 513 514 if(LISTBOX_ENTRY_NOTFOUND == nPos) 515 { 516 nPos = mnLastPosGradient; 517 } 518 519 if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_GRADIENT_LIST)) 520 { 521 const SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); 522 523 if(nPos < aItem.GetGradientList()->Count()) 524 { 525 const XGradient aGradient = aItem.GetGradientList()->GetGradient(nPos)->GetGradient(); 526 const XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetSelectEntry(), aGradient); 527 528 // #122676# Change FillStale and Gradinet in one call 529 GetBindings()->GetDispatcher()->Execute( 530 SID_ATTR_FILL_GRADIENT, SFX_CALLMODE_RECORD, &aXFillGradientItem, 531 bFillStyleChange ? &aXFillStyleItem : 0L, 0L); 532 } 533 } 534 535 if(LISTBOX_ENTRY_NOTFOUND != nPos) 536 { 537 mnLastPosGradient = nPos; 538 } 539 break; 540 } 541 case XFILL_HATCH: 542 { 543 sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos(); 544 545 if(LISTBOX_ENTRY_NOTFOUND == nPos) 546 { 547 nPos = mnLastPosHatch; 548 } 549 550 if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_HATCH_LIST)) 551 { 552 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); 553 554 if(nPos < aItem.GetHatchList()->Count()) 555 { 556 const XHatch aHatch = aItem.GetHatchList()->GetHatch(nPos)->GetHatch(); 557 const XFillHatchItem aXFillHatchItem( mpLbFillAttr->GetSelectEntry(), aHatch); 558 559 // #122676# Change FillStale and Hatch in one call 560 GetBindings()->GetDispatcher()->Execute( 561 SID_ATTR_FILL_HATCH, SFX_CALLMODE_RECORD, &aXFillHatchItem, 562 bFillStyleChange ? &aXFillStyleItem : 0L, 0L); 563 } 564 } 565 566 if(LISTBOX_ENTRY_NOTFOUND != nPos) 567 { 568 mnLastPosHatch = nPos; 569 } 570 break; 571 } 572 case XFILL_BITMAP: 573 { 574 sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos(); 575 576 if(LISTBOX_ENTRY_NOTFOUND == nPos) 577 { 578 nPos = mnLastPosBitmap; 579 } 580 581 if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_BITMAP_LIST)) 582 { 583 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); 584 585 if(nPos < aItem.GetBitmapList()->Count()) 586 { 587 const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(nPos); 588 const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject()); 589 590 // #122676# Change FillStale and Bitmap in one call 591 GetBindings()->GetDispatcher()->Execute( 592 SID_ATTR_FILL_BITMAP, SFX_CALLMODE_RECORD, &aXFillBitmapItem, 593 bFillStyleChange ? &aXFillStyleItem : 0L, 0L); 594 } 595 } 596 597 if(LISTBOX_ENTRY_NOTFOUND != nPos) 598 { 599 mnLastPosBitmap = nPos; 600 } 601 break; 602 } 603 default: break; 604 } 605 } 606 607 return 0; 608 } 609 610 611 IMPL_LINK(AreaPropertyPanel, ToolBoxColorDropHdl, ToolBox*, pToolBox) 612 { 613 const sal_uInt16 nId = pToolBox->GetCurItemId(); 614 615 if(TBI_COLOR == nId) 616 { 617 maColorPopup.Show(*pToolBox); 618 619 if (mpColorItem) 620 { 621 maColorPopup.SetCurrentColor(mpColorItem->GetColorValue(), mbColorAvail); 622 } 623 else 624 { 625 maColorPopup.SetCurrentColor(COL_WHITE, false); 626 } 627 } 628 629 return 0; 630 } 631 632 633 634 void AreaPropertyPanel::SetColor ( 635 const String& rsColorName, 636 const Color aColor) 637 { 638 const XFillColorItem aXFillColorItem(rsColorName, aColor); 639 mpBindings->GetDispatcher()->Execute(SID_ATTR_FILL_COLOR, SFX_CALLMODE_RECORD, &aXFillColorItem, 0L); 640 maLastColor = aColor; 641 } 642 643 644 645 646 PopupControl* AreaPropertyPanel::CreateTransparencyGradientControl (PopupContainer* pParent) 647 { 648 return new AreaTransparencyGradientControl(pParent, *this); 649 } 650 651 652 653 654 PopupControl* AreaPropertyPanel::CreateColorPopupControl (PopupContainer* pParent) 655 { 656 return new ColorControl( 657 pParent, 658 mpBindings, 659 SVX_RES(RID_POPUPPANEL_AERAPAGE_COLOR), 660 SVX_RES(VS_COLOR), 661 ::boost::bind(&AreaPropertyPanel::GetLastColor, this), 662 ::boost::bind(&AreaPropertyPanel::SetColor, this, _1,_2), 663 pParent, 664 0); 665 } 666 667 668 669 670 void AreaPropertyPanel::SetupIcons(void) 671 { 672 if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons)) 673 { 674 // todo 675 } 676 else 677 { 678 // todo 679 } 680 } 681 682 683 684 AreaPropertyPanel* AreaPropertyPanel::Create ( 685 Window* pParent, 686 const cssu::Reference<css::frame::XFrame>& rxFrame, 687 SfxBindings* pBindings) 688 { 689 if (pParent == NULL) 690 throw lang::IllegalArgumentException(A2S("no parent Window given to AreaPropertyPanel::Create"), NULL, 0); 691 if ( ! rxFrame.is()) 692 throw lang::IllegalArgumentException(A2S("no XFrame given to AreaPropertyPanel::Create"), NULL, 1); 693 if (pBindings == NULL) 694 throw lang::IllegalArgumentException(A2S("no SfxBindings given to AreaPropertyPanel::Create"), NULL, 2); 695 696 return new AreaPropertyPanel( 697 pParent, 698 rxFrame, 699 pBindings); 700 } 701 702 703 704 void AreaPropertyPanel::DataChanged( 705 const DataChangedEvent& rEvent) 706 { 707 (void)rEvent; 708 709 SetupIcons(); 710 } 711 712 713 714 void AreaPropertyPanel::ImpUpdateTransparencies() 715 { 716 if(mpTransparanceItem.get() && mpFloatTransparenceItem.get()) 717 { 718 bool bZeroValue(false); 719 720 if(mpTransparanceItem.get()) 721 { 722 const sal_uInt16 nValue(mpTransparanceItem->GetValue()); 723 724 if(!nValue) 725 { 726 bZeroValue = true; 727 } 728 else if(nValue <= 100) 729 { 730 mpLBTransType->Enable(); 731 mpTrspTextFT->Enable(); 732 mpLBTransType->SelectEntryPos(1); 733 mpBTNGradient->Hide(); 734 mpMTRTransparent->Show(); 735 mpMTRTransparent->Enable(); 736 mpMTRTransparent->SetValue(nValue); 737 } 738 739 if(!bZeroValue) 740 { 741 maTrGrPopup.Hide(); 742 } 743 } 744 745 if(bZeroValue && mpFloatTransparenceItem.get()) 746 { 747 if(mpFloatTransparenceItem->IsEnabled()) 748 { 749 const XGradient& rGradient = mpFloatTransparenceItem->GetGradientValue(); 750 const bool bHighContrast(GetSettings().GetStyleSettings().GetHighContrastMode()); 751 sal_uInt16 nEntryPos(0); 752 Image* pImage = 0; 753 754 mpLBTransType->Enable(); 755 mpTrspTextFT->Enable(); 756 mpMTRTransparent->Hide(); 757 mpBTNGradient->Enable(); 758 mpBTNGradient->Show(); 759 760 switch(rGradient.GetGradientStyle()) 761 { 762 case XGRAD_LINEAR: 763 { 764 nEntryPos = 2; 765 pImage = bHighContrast ? &maImgLinearH : &maImgLinear; 766 break; 767 } 768 case XGRAD_AXIAL: 769 { 770 nEntryPos = 3; 771 pImage = bHighContrast ? &maImgAxialH : &maImgAxial; 772 break; 773 } 774 case XGRAD_RADIAL: 775 { 776 nEntryPos = 4; 777 pImage = bHighContrast ? &maImgRadialH : &maImgRadial; 778 break; 779 } 780 case XGRAD_ELLIPTICAL: 781 { 782 nEntryPos = 5; 783 pImage = bHighContrast ? &maImgElliH : &maImgElli; 784 break; 785 } 786 case XGRAD_SQUARE: 787 { 788 nEntryPos = 6; 789 pImage = bHighContrast ? &maImgQuadH : &maImgQuad; 790 break; 791 } 792 case XGRAD_RECT: 793 { 794 nEntryPos = 7; 795 pImage = bHighContrast ? &maImgSquareH : &maImgSquare; 796 break; 797 } 798 } 799 800 mpLBTransType->SelectEntryPos(nEntryPos); 801 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT, *pImage); 802 bZeroValue = false; 803 } 804 else 805 { 806 bZeroValue = true; 807 } 808 } 809 810 if(bZeroValue) 811 { 812 mpLBTransType->Enable(); 813 mpTrspTextFT->Enable(); 814 mpLBTransType->SelectEntryPos(0); 815 mpBTNGradient->Hide(); 816 mpMTRTransparent->Enable(); 817 mpMTRTransparent->Show(); 818 mpMTRTransparent->SetValue(0); 819 } 820 } 821 else 822 { 823 // no transparency at all 824 mpLBTransType->SetNoSelection(); 825 mpLBTransType->Disable(); 826 mpTrspTextFT->Disable(); 827 mpMTRTransparent->Disable(); 828 mpMTRTransparent->Show(); 829 mpBTNGradient->Disable(); 830 mpBTNGradient->Hide(); 831 } 832 } 833 834 835 836 void AreaPropertyPanel::NotifyItemUpdate( 837 sal_uInt16 nSID, 838 SfxItemState eState, 839 const SfxPoolItem* pState, 840 const bool bIsEnabled) 841 { 842 (void)bIsEnabled; 843 const bool bDisabled(SFX_ITEM_DISABLED == eState); 844 845 switch(nSID) 846 { 847 case SID_ATTR_FILL_TRANSPARENCE: 848 case SID_ATTR_FILL_FLOATTRANSPARENCE: 849 { 850 bool bFillTransparenceChanged(false); 851 852 if(SID_ATTR_FILL_TRANSPARENCE == nSID) 853 { 854 bFillTransparenceChanged = true; 855 856 if(eState >= SFX_ITEM_AVAILABLE) 857 { 858 const SfxUInt16Item* pItem = dynamic_cast< const SfxUInt16Item* >(pState); 859 860 if(pItem && (!mpTransparanceItem || *pItem != *mpTransparanceItem)) 861 { 862 mpTransparanceItem.reset((SfxUInt16Item*)pItem->Clone()); 863 } 864 else 865 { 866 mpTransparanceItem.reset(); 867 } 868 } 869 else 870 { 871 mpTransparanceItem.reset(); 872 } 873 } 874 else // if(SID_ATTR_FILL_FLOATTRANSPARENCE == nSID) 875 { 876 bFillTransparenceChanged = true; 877 878 if(eState >= SFX_ITEM_AVAILABLE) 879 { 880 const XFillFloatTransparenceItem* pItem = dynamic_cast< const XFillFloatTransparenceItem* >(pState); 881 882 if(pItem && (!mpFloatTransparenceItem || *pItem != *mpFloatTransparenceItem)) 883 { 884 mpFloatTransparenceItem.reset((XFillFloatTransparenceItem*)pItem->Clone()); 885 } 886 else 887 { 888 mpFloatTransparenceItem.reset(); 889 } 890 } 891 else 892 { 893 mpFloatTransparenceItem.reset(); 894 } 895 } 896 897 if(bFillTransparenceChanged) 898 { 899 // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem 900 ImpUpdateTransparencies(); 901 } 902 break; 903 } 904 case SID_ATTR_FILL_STYLE: 905 { 906 if(bDisabled) 907 { 908 mpLbFillType->Disable(); 909 mpColorTextFT->Disable(); 910 mpLbFillType->SetNoSelection(); 911 mpLbFillAttr->Show(); 912 mpLbFillAttr->Disable(); 913 mpLbFillAttr->SetNoSelection(); 914 mpToolBoxColor->Hide(); 915 meLastXFS = -1; 916 mpStyleItem.reset(); 917 } 918 919 if(eState >= SFX_ITEM_AVAILABLE) 920 { 921 const XFillStyleItem* pItem = dynamic_cast< const XFillStyleItem* >(pState); 922 923 if(pItem) 924 { 925 mpStyleItem.reset(dynamic_cast< XFillStyleItem* >(pItem->Clone())); 926 mpLbFillType->Enable(); 927 mpColorTextFT->Enable(); 928 XFillStyle eXFS = (XFillStyle)mpStyleItem->GetValue(); 929 meLastXFS = eXFS; 930 mpLbFillType->SelectEntryPos(sal::static_int_cast< sal_uInt16 >(eXFS)); 931 932 if(XFILL_NONE == eXFS) 933 { 934 mpLbFillAttr->SetNoSelection(); 935 mpLbFillAttr->Disable(); 936 } 937 938 Update(); 939 break; 940 } 941 } 942 943 mpLbFillType->SetNoSelection(); 944 mpLbFillAttr->Show(); 945 mpLbFillAttr->Disable(); 946 mpLbFillAttr->SetNoSelection(); 947 mpToolBoxColor->Hide(); 948 meLastXFS = -1; 949 mpStyleItem.reset(); 950 break; 951 } 952 case SID_ATTR_FILL_COLOR: 953 { 954 if(SFX_ITEM_AVAILABLE == eState) 955 { 956 mpColorItem.reset(pState ? (XFillColorItem*)pState->Clone() : 0); 957 } 958 959 if(mpStyleItem && XFILL_SOLID == (XFillStyle)mpStyleItem->GetValue()) 960 { 961 mpLbFillAttr->Hide(); 962 mpToolBoxColor->Show(); 963 964 if(SFX_ITEM_AVAILABLE == eState) 965 { 966 mpToolBoxColor->Enable(); 967 mbColorAvail = true; 968 // maLastColor = mpColorItem->GetColorValue(); 969 Update(); 970 } 971 else if(SFX_ITEM_DISABLED == eState) 972 { 973 mpToolBoxColor->Disable(); 974 mbColorAvail = false; 975 mpColorUpdater->Update(COL_WHITE); 976 } 977 else 978 { 979 mbColorAvail = false; 980 mpColorUpdater->Update(COL_WHITE); 981 } 982 } 983 break; 984 } 985 case SID_ATTR_FILL_GRADIENT: 986 { 987 if(SFX_ITEM_AVAILABLE == eState) 988 { 989 mpFillGradientItem.reset(pState ? (XFillGradientItem*)pState->Clone() : 0); 990 } 991 992 if(mpStyleItem && XFILL_GRADIENT == (XFillStyle)mpStyleItem->GetValue()) 993 { 994 mpLbFillAttr->Show(); 995 mpToolBoxColor->Hide(); 996 997 if(SFX_ITEM_AVAILABLE == eState) 998 { 999 mpLbFillAttr->Enable(); 1000 Update(); 1001 } 1002 else if(SFX_ITEM_DISABLED == eState ) 1003 { 1004 mpLbFillAttr->Disable(); 1005 mpLbFillAttr->SetNoSelection(); 1006 } 1007 else 1008 { 1009 mpLbFillAttr->SetNoSelection(); 1010 } 1011 } 1012 break; 1013 } 1014 case SID_ATTR_FILL_HATCH: 1015 { 1016 if(SFX_ITEM_AVAILABLE == eState) 1017 { 1018 mpHatchItem.reset(pState ? (XFillHatchItem*)pState->Clone() : 0); 1019 } 1020 1021 if(mpStyleItem && XFILL_HATCH == (XFillStyle)mpStyleItem->GetValue()) 1022 { 1023 mpLbFillAttr->Show(); 1024 mpToolBoxColor->Hide(); 1025 1026 if(SFX_ITEM_AVAILABLE == eState) 1027 { 1028 mpLbFillAttr->Enable(); 1029 Update(); 1030 } 1031 else if(SFX_ITEM_DISABLED == eState ) 1032 { 1033 mpLbFillAttr->Disable(); 1034 mpLbFillAttr->SetNoSelection(); 1035 } 1036 else 1037 { 1038 mpLbFillAttr->SetNoSelection(); 1039 } 1040 } 1041 break; 1042 } 1043 case SID_ATTR_FILL_BITMAP: 1044 { 1045 if(SFX_ITEM_AVAILABLE == eState) 1046 { 1047 mpBitmapItem.reset(pState ? (XFillBitmapItem*)pState->Clone() : 0); 1048 } 1049 1050 if(mpStyleItem && XFILL_BITMAP == (XFillStyle)mpStyleItem->GetValue()) 1051 { 1052 mpLbFillAttr->Show(); 1053 mpToolBoxColor->Hide(); 1054 1055 if(SFX_ITEM_AVAILABLE == eState) 1056 { 1057 mpLbFillAttr->Enable(); 1058 Update(); 1059 } 1060 else if(SFX_ITEM_DISABLED == eState ) 1061 { 1062 mpLbFillAttr->Disable(); 1063 mpLbFillAttr->SetNoSelection(); 1064 } 1065 else 1066 { 1067 mpLbFillAttr->SetNoSelection(); 1068 } 1069 } 1070 break; 1071 } 1072 case SID_COLOR_TABLE: 1073 { 1074 if(SFX_ITEM_AVAILABLE == eState) 1075 { 1076 if(mpStyleItem && XFILL_SOLID == (XFillStyle)mpStyleItem->GetValue()) 1077 { 1078 if(mpColorItem) 1079 { 1080 const Color aColor = mpColorItem->GetColorValue(); 1081 const SfxObjectShell* pSh = SfxObjectShell::Current(); 1082 const SvxColorTableItem aItem(*(const SvxColorTableItem*)(pSh->GetItem(SID_COLOR_TABLE))); 1083 1084 mpLbFillAttr->Clear(); 1085 mpLbFillAttr->Enable(); 1086 mpLbFillAttr->Fill(aItem.GetColorTable()); 1087 mpLbFillAttr->SelectEntry(aColor); 1088 } 1089 else 1090 { 1091 mpLbFillAttr->SetNoSelection(); 1092 } 1093 } 1094 } 1095 break; 1096 } 1097 case SID_GRADIENT_LIST: 1098 { 1099 if(SFX_ITEM_AVAILABLE == eState) 1100 { 1101 if(mpStyleItem && XFILL_GRADIENT == (XFillStyle)mpStyleItem->GetValue()) 1102 { 1103 if(mpFillGradientItem) 1104 { 1105 const String aString( mpFillGradientItem->GetName() ); 1106 const SfxObjectShell* pSh = SfxObjectShell::Current(); 1107 const SvxGradientListItem aItem( *(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); 1108 1109 mpLbFillAttr->Clear(); 1110 mpLbFillAttr->Enable(); 1111 mpLbFillAttr->Fill(aItem.GetGradientList()); 1112 mpLbFillAttr->SelectEntry(aString); 1113 } 1114 else 1115 { 1116 mpLbFillAttr->SetNoSelection(); 1117 } 1118 } 1119 } 1120 break; 1121 } 1122 case SID_HATCH_LIST: 1123 { 1124 if(SFX_ITEM_AVAILABLE == eState) 1125 { 1126 if(mpStyleItem && XFILL_HATCH == (XFillStyle)mpStyleItem->GetValue()) 1127 { 1128 if(mpHatchItem) 1129 { 1130 const String aString( mpHatchItem->GetName() ); 1131 const SfxObjectShell* pSh = SfxObjectShell::Current(); 1132 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); 1133 1134 mpLbFillAttr->Clear(); 1135 mpLbFillAttr->Enable(); 1136 mpLbFillAttr->Fill(aItem.GetHatchList()); 1137 mpLbFillAttr->SelectEntry(aString); 1138 } 1139 else 1140 { 1141 mpLbFillAttr->SetNoSelection(); 1142 } 1143 } 1144 } 1145 break; 1146 } 1147 case SID_BITMAP_LIST: 1148 { 1149 if(SFX_ITEM_AVAILABLE == eState) 1150 { 1151 if(mpStyleItem && XFILL_BITMAP == (XFillStyle)mpStyleItem->GetValue()) 1152 { 1153 if(mpBitmapItem) 1154 { 1155 const String aString( mpBitmapItem->GetName() ); 1156 const SfxObjectShell* pSh = SfxObjectShell::Current(); 1157 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); 1158 1159 mpLbFillAttr->Clear(); 1160 mpLbFillAttr->Enable(); 1161 mpLbFillAttr->Fill(aItem.GetBitmapList()); 1162 mpLbFillAttr->SelectEntry(aString); 1163 } 1164 else 1165 { 1166 mpLbFillAttr->SetNoSelection(); 1167 } 1168 } 1169 } 1170 break; 1171 } 1172 } 1173 1174 maLayouter.Layout(); 1175 } 1176 1177 1178 1179 SfxBindings* AreaPropertyPanel::GetBindings() 1180 { 1181 return mpBindings; 1182 } 1183 1184 1185 1186 void AreaPropertyPanel::Update() 1187 { 1188 if(mpStyleItem) 1189 { 1190 const XFillStyle eXFS = (XFillStyle)mpStyleItem->GetValue(); 1191 SfxObjectShell* pSh = SfxObjectShell::Current(); 1192 1193 switch( eXFS ) 1194 { 1195 case XFILL_NONE: 1196 { 1197 mpLbFillAttr->Show(); 1198 mpToolBoxColor->Hide(); 1199 break; 1200 } 1201 case XFILL_SOLID: 1202 { 1203 if(mpColorItem) 1204 { 1205 mpLbFillAttr->Hide(); 1206 mpToolBoxColor->Show(); 1207 mpColorUpdater->Update(mpColorItem->GetColorValue()); 1208 } 1209 else 1210 { 1211 mpColorUpdater->Update(COL_WHITE); 1212 } 1213 break; 1214 } 1215 case XFILL_GRADIENT: 1216 { 1217 mpLbFillAttr->Show(); 1218 mpToolBoxColor->Hide(); 1219 1220 if(pSh && pSh->GetItem(SID_GRADIENT_LIST)) 1221 { 1222 const SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); 1223 mpLbFillAttr->Enable(); 1224 mpLbFillAttr->Clear(); 1225 mpLbFillAttr->Fill(aItem.GetGradientList()); 1226 1227 if(mpFillGradientItem) 1228 { 1229 const String aString(mpFillGradientItem->GetName()); 1230 1231 mpLbFillAttr->SelectEntry(aString); 1232 } 1233 else 1234 { 1235 mpLbFillAttr->SetNoSelection(); 1236 } 1237 } 1238 else 1239 { 1240 mpLbFillAttr->SetNoSelection(); 1241 } 1242 break; 1243 } 1244 case XFILL_HATCH: 1245 { 1246 mpLbFillAttr->Show(); 1247 mpToolBoxColor->Hide(); 1248 1249 if(pSh && pSh->GetItem(SID_HATCH_LIST)) 1250 { 1251 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); 1252 mpLbFillAttr->Enable(); 1253 mpLbFillAttr->Clear(); 1254 mpLbFillAttr->Fill(aItem.GetHatchList()); 1255 1256 if(mpHatchItem) 1257 { 1258 const String aString(mpHatchItem->GetName()); 1259 1260 mpLbFillAttr->SelectEntry( aString ); 1261 } 1262 else 1263 { 1264 mpLbFillAttr->SetNoSelection(); 1265 } 1266 } 1267 else 1268 { 1269 mpLbFillAttr->SetNoSelection(); 1270 } 1271 break; 1272 } 1273 case XFILL_BITMAP: 1274 { 1275 mpLbFillAttr->Show(); 1276 mpToolBoxColor->Hide(); 1277 1278 if(pSh && pSh->GetItem(SID_BITMAP_LIST)) 1279 { 1280 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); 1281 mpLbFillAttr->Enable(); 1282 mpLbFillAttr->Clear(); 1283 mpLbFillAttr->Fill(aItem.GetBitmapList()); 1284 1285 if(mpBitmapItem) 1286 { 1287 const String aString(mpBitmapItem->GetName()); 1288 1289 mpLbFillAttr->SelectEntry(aString); 1290 } 1291 else 1292 { 1293 mpLbFillAttr->SetNoSelection(); 1294 } 1295 } 1296 else 1297 { 1298 mpLbFillAttr->SetNoSelection(); 1299 } 1300 break; 1301 } 1302 default: 1303 DBG_ERROR( "Non supported FillType (!)" ); 1304 break; 1305 } 1306 } 1307 } 1308 1309 1310 1311 IMPL_LINK( AreaPropertyPanel, ImplPopupModeEndHdl, FloatingWindow*, EMPTYARG ) 1312 { 1313 return 0; 1314 } 1315 1316 1317 1318 IMPL_LINK( AreaPropertyPanel, ClickTrGrHdl_Impl, ToolBox*, pToolBox ) 1319 { 1320 maTrGrPopup.Rearrange(mpFloatTransparenceItem.get()); 1321 OSL_ASSERT(pToolBox->GetCurItemId() == TBI_BTX_GRADIENT); 1322 maTrGrPopup.Show(*pToolBox); 1323 1324 return (0L); 1325 } 1326 1327 1328 1329 IMPL_LINK(AreaPropertyPanel, ChangeTrgrTypeHdl_Impl, void *, EMPTYARG) 1330 { 1331 sal_uInt16 nSelectType = mpLBTransType->GetSelectEntryPos(); 1332 bool bGradient = false; 1333 sal_uInt16 nTrans = 0; 1334 1335 if(!nSelectType) 1336 { 1337 mpBTNGradient->Hide(); 1338 mpMTRTransparent->Show(); 1339 mpMTRTransparent->Enable(); 1340 mpMTRTransparent->SetValue(0); 1341 } 1342 else if(1 == nSelectType) 1343 { 1344 mpBTNGradient->Hide(); 1345 mpMTRTransparent->Show(); 1346 nTrans = mnLastTransSolid; 1347 mpMTRTransparent->SetValue(nTrans); 1348 mpLBTransType->SelectEntryPos(1); 1349 mpMTRTransparent->Enable(); 1350 } 1351 else 1352 { 1353 mpBTNGradient->Show(); 1354 1355 switch (nSelectType) 1356 { 1357 case 2: 1358 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgLinearH : maImgLinear); 1359 break; 1360 case 3: 1361 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgAxialH : maImgAxial); 1362 break; 1363 case 4: 1364 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgRadialH : maImgRadial); 1365 break; 1366 case 5: 1367 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgElliH : maImgElli ); 1368 break; 1369 case 6: 1370 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgQuadH : maImgQuad ); 1371 break; 1372 case 7: 1373 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgSquareH : maImgSquare); 1374 break; 1375 } 1376 1377 mpMTRTransparent->Hide(); 1378 mpBTNGradient->Enable(); 1379 bGradient = true; 1380 } 1381 1382 const XFillTransparenceItem aLinearItem(nTrans); 1383 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE, SFX_CALLMODE_RECORD, &aLinearItem, 0L ); 1384 1385 if(nSelectType > 1) 1386 { 1387 nSelectType -= 2; 1388 } 1389 1390 XGradient aTmpGradient; 1391 1392 switch(nSelectType) 1393 { 1394 case XGRAD_LINEAR: 1395 aTmpGradient = maGradientLinear; 1396 break; 1397 case XGRAD_AXIAL: 1398 aTmpGradient = maGradientAxial; 1399 break; 1400 case XGRAD_RADIAL: 1401 aTmpGradient = maGradientRadial; 1402 break; 1403 case XGRAD_ELLIPTICAL: 1404 aTmpGradient = maGradientElliptical; 1405 break; 1406 case XGRAD_SQUARE: 1407 aTmpGradient = maGradientSquare; 1408 break; 1409 case XGRAD_RECT: 1410 aTmpGradient = maGradientRect; 1411 break; 1412 } 1413 1414 SfxItemPool* pPool = 0; 1415 const XFillFloatTransparenceItem aGradientItem(pPool, aTmpGradient, sal_Bool(bGradient)); 1416 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_FLOATTRANSPARENCE, SFX_CALLMODE_RECORD, &aGradientItem, 0L ); 1417 1418 return( 0L ); 1419 } 1420 1421 1422 1423 IMPL_LINK(AreaPropertyPanel, ModifyTransparentHdl_Impl, void*, EMPTYARG) 1424 { 1425 const sal_uInt16 nTrans = (sal_uInt16)mpMTRTransparent->GetValue(); 1426 mnLastTransSolid = nTrans; 1427 const sal_uInt16 nSelectType = mpLBTransType->GetSelectEntryPos(); 1428 1429 if(nTrans && !nSelectType) 1430 { 1431 mpLBTransType->SelectEntryPos(1); 1432 } 1433 1434 const XFillTransparenceItem aLinearItem(nTrans); 1435 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE, SFX_CALLMODE_RECORD, &aLinearItem, 0L ); 1436 1437 return 0L; 1438 } 1439 1440 1441 Color AreaPropertyPanel::GetLastColor (void) const 1442 { 1443 return maLastColor; 1444 } 1445 1446 1447 1448 1449 XGradient AreaPropertyPanel::GetGradient (const XGradientStyle eStyle) const 1450 { 1451 switch (eStyle) 1452 { 1453 default: 1454 case XGRAD_LINEAR: 1455 return maGradientLinear; 1456 case XGRAD_AXIAL: 1457 return maGradientAxial; 1458 case XGRAD_RADIAL: 1459 return maGradientRadial; 1460 case XGRAD_ELLIPTICAL: 1461 return maGradientElliptical; 1462 case XGRAD_SQUARE: 1463 return maGradientSquare; 1464 case XGRAD_RECT: 1465 return maGradientRect; 1466 } 1467 } 1468 1469 1470 1471 1472 void AreaPropertyPanel::SetGradient (const XGradient& rGradient) 1473 { 1474 switch (rGradient.GetGradientStyle()) 1475 { 1476 case XGRAD_LINEAR: 1477 maGradientLinear = rGradient; 1478 break; 1479 case XGRAD_AXIAL: 1480 maGradientAxial = rGradient; 1481 break; 1482 case XGRAD_RADIAL: 1483 maGradientRadial = rGradient; 1484 break; 1485 case XGRAD_ELLIPTICAL: 1486 maGradientElliptical = rGradient; 1487 break; 1488 case XGRAD_SQUARE: 1489 maGradientSquare = rGradient; 1490 break; 1491 case XGRAD_RECT: 1492 maGradientRect = rGradient; 1493 break; 1494 } 1495 } 1496 1497 1498 1499 1500 sal_Int32 AreaPropertyPanel::GetSelectedTransparencyTypeIndex (void) const 1501 { 1502 return mpLBTransType->GetSelectEntryPos(); 1503 } 1504 1505 1506 1507 1508 void AreaPropertyPanel::Resize (void) 1509 { 1510 maLayouter.Layout(); 1511 } 1512 1513 1514 1515 } } // end of namespace svx::sidebar 1516 1517 // eof 1518