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 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_STYLE, SFX_CALLMODE_RECORD, &aXFillStyleItem, 0L); 319 320 switch( eXFS ) 321 { 322 case XFILL_NONE: 323 { 324 mpLbFillAttr->Show(); 325 mpToolBoxColor->Hide(); 326 mpLbFillType->Selected(); 327 mpLbFillAttr->Disable(); 328 break; 329 } 330 case XFILL_SOLID: 331 { 332 mpLbFillAttr->Hide(); 333 mpToolBoxColor->Show(); 334 const String aTmpStr; 335 const Color aColor = maLastColor; 336 const XFillColorItem aXFillColorItem( aTmpStr, aColor ); 337 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_COLOR, SFX_CALLMODE_RECORD, &aXFillColorItem, 0L); 338 break; 339 } 340 case XFILL_GRADIENT: 341 { 342 mpLbFillAttr->Show(); 343 mpToolBoxColor->Hide(); 344 345 if(pSh && pSh->GetItem(SID_GRADIENT_LIST)) 346 { 347 if(!mpLbFillAttr->GetEntryCount()) 348 { 349 const SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); 350 mpLbFillAttr->Enable(); 351 mpLbFillAttr->Clear(); 352 mpLbFillAttr->Fill(aItem.GetGradientList()); 353 } 354 355 mpLbFillAttr->AdaptDropDownLineCountToMaximum(); 356 357 if(LISTBOX_ENTRY_NOTFOUND != mnLastPosGradient) 358 { 359 const SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); 360 361 if(mnLastPosGradient < aItem.GetGradientList()->Count()) 362 { 363 const XGradient aGradient = aItem.GetGradientList()->GetGradient(mnLastPosGradient)->GetGradient(); 364 const XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetEntry(mnLastPosGradient), aGradient); 365 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_GRADIENT, SFX_CALLMODE_RECORD, &aXFillGradientItem, 0L); 366 mpLbFillAttr->SelectEntryPos(mnLastPosGradient); 367 } 368 } 369 } 370 else 371 { 372 mpLbFillAttr->Disable(); 373 } 374 break; 375 } 376 case XFILL_HATCH: 377 { 378 mpLbFillAttr->Show(); 379 mpToolBoxColor->Hide(); 380 381 if(pSh && pSh->GetItem(SID_HATCH_LIST)) 382 { 383 if(!mpLbFillAttr->GetEntryCount()) 384 { 385 const SvxHatchListItem aItem( *(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); 386 mpLbFillAttr->Enable(); 387 mpLbFillAttr->Clear(); 388 mpLbFillAttr->Fill(aItem.GetHatchList()); 389 } 390 391 mpLbFillAttr->AdaptDropDownLineCountToMaximum(); 392 393 if(LISTBOX_ENTRY_NOTFOUND != mnLastPosHatch) 394 { 395 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); 396 397 if(mnLastPosHatch < aItem.GetHatchList()->Count()) 398 { 399 const XHatch aHatch = aItem.GetHatchList()->GetHatch(mnLastPosHatch)->GetHatch(); 400 const XFillHatchItem aXFillHatchItem(mpLbFillAttr->GetSelectEntry(), aHatch); 401 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_HATCH, SFX_CALLMODE_RECORD, &aXFillHatchItem, 0L); 402 mpLbFillAttr->SelectEntryPos(mnLastPosHatch); 403 } 404 } 405 } 406 else 407 { 408 mpLbFillAttr->Disable(); 409 } 410 break; 411 } 412 case XFILL_BITMAP: 413 { 414 mpLbFillAttr->Show(); 415 mpToolBoxColor->Hide(); 416 417 if(pSh && pSh->GetItem(SID_BITMAP_LIST)) 418 { 419 if(!mpLbFillAttr->GetEntryCount()) 420 { 421 const SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); 422 mpLbFillAttr->Enable(); 423 mpLbFillAttr->Clear(); 424 mpLbFillAttr->Fill(aItem.GetBitmapList()); 425 } 426 427 mpLbFillAttr->AdaptDropDownLineCountToMaximum(); 428 429 if(LISTBOX_ENTRY_NOTFOUND != mnLastPosBitmap) 430 { 431 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); 432 433 if(mnLastPosBitmap < aItem.GetBitmapList()->Count()) 434 { 435 const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(mnLastPosBitmap); 436 const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject()); 437 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_BITMAP, SFX_CALLMODE_RECORD, &aXFillBitmapItem, 0L); 438 mpLbFillAttr->SelectEntryPos(mnLastPosBitmap); 439 } 440 } 441 } 442 else 443 { 444 mpLbFillAttr->Disable(); 445 } 446 break; 447 } 448 } 449 450 meLastXFS = (sal_uInt16)eXFS; 451 452 if(XFILL_NONE != eXFS) 453 { 454 if(pToolBox) 455 { 456 mpLbFillType->Selected(); 457 } 458 } 459 460 maLayouter.Layout(); 461 } 462 463 return 0; 464 } 465 466 467 468 IMPL_LINK( AreaPropertyPanel, SelectFillAttrHdl, ListBox*, pToolBox ) 469 { 470 const XFillStyle eXFS = (XFillStyle)mpLbFillType->GetSelectEntryPos(); 471 const XFillStyleItem aXFillStyleItem(eXFS); 472 SfxObjectShell* pSh = SfxObjectShell::Current(); 473 474 if(pToolBox) 475 { 476 if((XFillStyle) meLastXFS != eXFS) 477 { 478 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_STYLE, SFX_CALLMODE_RECORD, &aXFillStyleItem, 0L); 479 } 480 481 switch(eXFS) 482 { 483 case XFILL_SOLID: 484 //{ 485 // //String aTmpStr = mpLbFillAttr->GetSelectEntry(); 486 // //Color aColor = mpLbFillAttr->GetSelectEntryColor(); 487 // //if(aColor.GetColor() == 0 && aTmpStr.Equals(String::CreateFromAscii(""))) 488 // String aTmpStr; 489 // Color aColor = maLastColor; 490 // XFillColorItem aXFillColorItem( aTmpStr, aColor ); 491 // GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_COLOR, SFX_CALLMODE_RECORD, &aXFillColorItem, 0L); 492 // maLastColor = aColor; 493 //} 494 break; 495 496 case XFILL_GRADIENT: 497 { 498 sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos(); 499 500 if(LISTBOX_ENTRY_NOTFOUND == nPos) 501 { 502 nPos = mnLastPosGradient; 503 } 504 505 if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_GRADIENT_LIST)) 506 { 507 const SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); 508 509 if(nPos < aItem.GetGradientList()->Count()) 510 { 511 const XGradient aGradient = aItem.GetGradientList()->GetGradient(nPos)->GetGradient(); 512 const XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetSelectEntry(), aGradient); 513 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_GRADIENT, SFX_CALLMODE_RECORD, &aXFillGradientItem, 0L); 514 } 515 } 516 517 if(LISTBOX_ENTRY_NOTFOUND != nPos) 518 { 519 mnLastPosGradient = nPos; 520 } 521 break; 522 } 523 case XFILL_HATCH: 524 { 525 sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos(); 526 527 if(LISTBOX_ENTRY_NOTFOUND == nPos) 528 { 529 nPos = mnLastPosHatch; 530 } 531 532 if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_HATCH_LIST)) 533 { 534 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); 535 536 if(nPos < aItem.GetHatchList()->Count()) 537 { 538 const XHatch aHatch = aItem.GetHatchList()->GetHatch(nPos)->GetHatch(); 539 const XFillHatchItem aXFillHatchItem( mpLbFillAttr->GetSelectEntry(), aHatch); 540 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_HATCH, SFX_CALLMODE_RECORD, &aXFillHatchItem, 0L); 541 } 542 } 543 544 if(LISTBOX_ENTRY_NOTFOUND != nPos) 545 { 546 mnLastPosHatch = nPos; 547 } 548 break; 549 } 550 case XFILL_BITMAP: 551 { 552 sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos(); 553 554 if(LISTBOX_ENTRY_NOTFOUND == nPos) 555 { 556 nPos = mnLastPosBitmap; 557 } 558 559 if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_BITMAP_LIST)) 560 { 561 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); 562 563 if(nPos < aItem.GetBitmapList()->Count()) 564 { 565 const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(nPos); 566 const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject()); 567 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_BITMAP, SFX_CALLMODE_RECORD, &aXFillBitmapItem, 0L); 568 } 569 } 570 571 if(LISTBOX_ENTRY_NOTFOUND != nPos) 572 { 573 mnLastPosBitmap = nPos; 574 } 575 break; 576 } 577 default: break; 578 } 579 } 580 581 return 0; 582 } 583 584 585 IMPL_LINK(AreaPropertyPanel, ToolBoxColorDropHdl, ToolBox*, pToolBox) 586 { 587 const sal_uInt16 nId = pToolBox->GetCurItemId(); 588 589 if(TBI_COLOR == nId) 590 { 591 maColorPopup.Show(*pToolBox); 592 593 if (mpColorItem) 594 { 595 maColorPopup.SetCurrentColor(mpColorItem->GetColorValue(), mbColorAvail); 596 } 597 else 598 { 599 maColorPopup.SetCurrentColor(COL_WHITE, false); 600 } 601 } 602 603 return 0; 604 } 605 606 607 608 void AreaPropertyPanel::SetColor ( 609 const String& rsColorName, 610 const Color aColor) 611 { 612 const XFillColorItem aXFillColorItem(rsColorName, aColor); 613 mpBindings->GetDispatcher()->Execute(SID_ATTR_FILL_COLOR, SFX_CALLMODE_RECORD, &aXFillColorItem, 0L); 614 maLastColor = aColor; 615 } 616 617 618 619 620 PopupControl* AreaPropertyPanel::CreateTransparencyGradientControl (PopupContainer* pParent) 621 { 622 return new AreaTransparencyGradientControl(pParent, *this); 623 } 624 625 626 627 628 PopupControl* AreaPropertyPanel::CreateColorPopupControl (PopupContainer* pParent) 629 { 630 return new ColorControl( 631 pParent, 632 mpBindings, 633 SVX_RES(RID_POPUPPANEL_AERAPAGE_COLOR), 634 SVX_RES(VS_COLOR), 635 ::boost::bind(&AreaPropertyPanel::GetLastColor, this), 636 ::boost::bind(&AreaPropertyPanel::SetColor, this, _1,_2), 637 pParent, 638 0); 639 } 640 641 642 643 644 void AreaPropertyPanel::SetupIcons(void) 645 { 646 if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons)) 647 { 648 // todo 649 } 650 else 651 { 652 // todo 653 } 654 } 655 656 657 658 AreaPropertyPanel* AreaPropertyPanel::Create ( 659 Window* pParent, 660 const cssu::Reference<css::frame::XFrame>& rxFrame, 661 SfxBindings* pBindings) 662 { 663 if (pParent == NULL) 664 throw lang::IllegalArgumentException(A2S("no parent Window given to AreaPropertyPanel::Create"), NULL, 0); 665 if ( ! rxFrame.is()) 666 throw lang::IllegalArgumentException(A2S("no XFrame given to AreaPropertyPanel::Create"), NULL, 1); 667 if (pBindings == NULL) 668 throw lang::IllegalArgumentException(A2S("no SfxBindings given to AreaPropertyPanel::Create"), NULL, 2); 669 670 return new AreaPropertyPanel( 671 pParent, 672 rxFrame, 673 pBindings); 674 } 675 676 677 678 void AreaPropertyPanel::DataChanged( 679 const DataChangedEvent& rEvent) 680 { 681 (void)rEvent; 682 683 SetupIcons(); 684 } 685 686 687 688 void AreaPropertyPanel::ImpUpdateTransparencies() 689 { 690 if(mpTransparanceItem.get() && mpFloatTransparenceItem.get()) 691 { 692 bool bZeroValue(false); 693 694 if(mpTransparanceItem.get()) 695 { 696 const sal_uInt16 nValue(mpTransparanceItem->GetValue()); 697 698 if(!nValue) 699 { 700 bZeroValue = true; 701 } 702 else if(nValue <= 100) 703 { 704 mpLBTransType->Enable(); 705 mpTrspTextFT->Enable(); 706 mpLBTransType->SelectEntryPos(1); 707 mpBTNGradient->Hide(); 708 mpMTRTransparent->Show(); 709 mpMTRTransparent->Enable(); 710 mpMTRTransparent->SetValue(nValue); 711 } 712 713 if(!bZeroValue) 714 { 715 maTrGrPopup.Hide(); 716 } 717 } 718 719 if(bZeroValue && mpFloatTransparenceItem.get()) 720 { 721 if(mpFloatTransparenceItem->IsEnabled()) 722 { 723 const XGradient& rGradient = mpFloatTransparenceItem->GetGradientValue(); 724 const bool bHighContrast(GetSettings().GetStyleSettings().GetHighContrastMode()); 725 sal_uInt16 nEntryPos(0); 726 Image* pImage = 0; 727 728 mpLBTransType->Enable(); 729 mpTrspTextFT->Enable(); 730 mpMTRTransparent->Hide(); 731 mpBTNGradient->Enable(); 732 mpBTNGradient->Show(); 733 734 switch(rGradient.GetGradientStyle()) 735 { 736 case XGRAD_LINEAR: 737 { 738 nEntryPos = 2; 739 pImage = bHighContrast ? &maImgLinearH : &maImgLinear; 740 break; 741 } 742 case XGRAD_AXIAL: 743 { 744 nEntryPos = 3; 745 pImage = bHighContrast ? &maImgAxialH : &maImgAxial; 746 break; 747 } 748 case XGRAD_RADIAL: 749 { 750 nEntryPos = 4; 751 pImage = bHighContrast ? &maImgRadialH : &maImgRadial; 752 break; 753 } 754 case XGRAD_ELLIPTICAL: 755 { 756 nEntryPos = 5; 757 pImage = bHighContrast ? &maImgElliH : &maImgElli; 758 break; 759 } 760 case XGRAD_SQUARE: 761 { 762 nEntryPos = 6; 763 pImage = bHighContrast ? &maImgQuadH : &maImgQuad; 764 break; 765 } 766 case XGRAD_RECT: 767 { 768 nEntryPos = 7; 769 pImage = bHighContrast ? &maImgSquareH : &maImgSquare; 770 break; 771 } 772 } 773 774 mpLBTransType->SelectEntryPos(nEntryPos); 775 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT, *pImage); 776 bZeroValue = false; 777 } 778 else 779 { 780 bZeroValue = true; 781 } 782 } 783 784 if(bZeroValue) 785 { 786 mpLBTransType->Enable(); 787 mpTrspTextFT->Enable(); 788 mpLBTransType->SelectEntryPos(0); 789 mpBTNGradient->Hide(); 790 mpMTRTransparent->Enable(); 791 mpMTRTransparent->Show(); 792 mpMTRTransparent->SetValue(0); 793 } 794 } 795 else 796 { 797 // no transparency at all 798 mpLBTransType->SetNoSelection(); 799 mpLBTransType->Disable(); 800 mpTrspTextFT->Disable(); 801 mpMTRTransparent->Disable(); 802 mpMTRTransparent->Show(); 803 mpBTNGradient->Disable(); 804 mpBTNGradient->Hide(); 805 } 806 } 807 808 809 810 void AreaPropertyPanel::NotifyItemUpdate( 811 sal_uInt16 nSID, 812 SfxItemState eState, 813 const SfxPoolItem* pState, 814 const bool bIsEnabled) 815 { 816 (void)bIsEnabled; 817 const bool bDisabled(SFX_ITEM_DISABLED == eState); 818 819 switch(nSID) 820 { 821 case SID_ATTR_FILL_TRANSPARENCE: 822 case SID_ATTR_FILL_FLOATTRANSPARENCE: 823 { 824 bool bFillTransparenceChanged(false); 825 826 if(SID_ATTR_FILL_TRANSPARENCE == nSID) 827 { 828 bFillTransparenceChanged = true; 829 830 if(eState >= SFX_ITEM_AVAILABLE) 831 { 832 const SfxUInt16Item* pItem = dynamic_cast< const SfxUInt16Item* >(pState); 833 834 if(pItem && (!mpTransparanceItem || *pItem != *mpTransparanceItem)) 835 { 836 mpTransparanceItem.reset((SfxUInt16Item*)pItem->Clone()); 837 } 838 else 839 { 840 mpTransparanceItem.reset(); 841 } 842 } 843 else 844 { 845 mpTransparanceItem.reset(); 846 } 847 } 848 else // if(SID_ATTR_FILL_FLOATTRANSPARENCE == nSID) 849 { 850 bFillTransparenceChanged = true; 851 852 if(eState >= SFX_ITEM_AVAILABLE) 853 { 854 const XFillFloatTransparenceItem* pItem = dynamic_cast< const XFillFloatTransparenceItem* >(pState); 855 856 if(pItem && (!mpFloatTransparenceItem || *pItem != *mpFloatTransparenceItem)) 857 { 858 mpFloatTransparenceItem.reset((XFillFloatTransparenceItem*)pItem->Clone()); 859 } 860 else 861 { 862 mpFloatTransparenceItem.reset(); 863 } 864 } 865 else 866 { 867 mpFloatTransparenceItem.reset(); 868 } 869 } 870 871 if(bFillTransparenceChanged) 872 { 873 // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem 874 ImpUpdateTransparencies(); 875 } 876 break; 877 } 878 case SID_ATTR_FILL_STYLE: 879 { 880 if(bDisabled) 881 { 882 mpLbFillType->Disable(); 883 mpColorTextFT->Disable(); 884 mpLbFillType->SetNoSelection(); 885 mpLbFillAttr->Show(); 886 mpLbFillAttr->Disable(); 887 mpLbFillAttr->SetNoSelection(); 888 mpToolBoxColor->Hide(); 889 meLastXFS = -1; 890 mpStyleItem.reset(); 891 } 892 893 if(eState >= SFX_ITEM_AVAILABLE) 894 { 895 const XFillStyleItem* pItem = dynamic_cast< const XFillStyleItem* >(pState); 896 897 if(pItem) 898 { 899 mpStyleItem.reset(dynamic_cast< XFillStyleItem* >(pItem->Clone())); 900 mpLbFillType->Enable(); 901 mpColorTextFT->Enable(); 902 XFillStyle eXFS = (XFillStyle)mpStyleItem->GetValue(); 903 meLastXFS = eXFS; 904 mpLbFillType->SelectEntryPos(sal::static_int_cast< sal_uInt16 >(eXFS)); 905 906 if(XFILL_NONE == eXFS) 907 { 908 mpLbFillAttr->SetNoSelection(); 909 mpLbFillAttr->Disable(); 910 } 911 912 Update(); 913 break; 914 } 915 } 916 917 mpLbFillType->SetNoSelection(); 918 mpLbFillAttr->Show(); 919 mpLbFillAttr->Disable(); 920 mpLbFillAttr->SetNoSelection(); 921 mpToolBoxColor->Hide(); 922 meLastXFS = -1; 923 mpStyleItem.reset(); 924 break; 925 } 926 case SID_ATTR_FILL_COLOR: 927 { 928 if(SFX_ITEM_AVAILABLE == eState) 929 { 930 mpColorItem.reset(pState ? (XFillColorItem*)pState->Clone() : 0); 931 } 932 933 if(mpStyleItem && XFILL_SOLID == (XFillStyle)mpStyleItem->GetValue()) 934 { 935 mpLbFillAttr->Hide(); 936 mpToolBoxColor->Show(); 937 938 if(SFX_ITEM_AVAILABLE == eState) 939 { 940 mpToolBoxColor->Enable(); 941 mbColorAvail = true; 942 // maLastColor = mpColorItem->GetColorValue(); 943 Update(); 944 } 945 else if(SFX_ITEM_DISABLED == eState) 946 { 947 mpToolBoxColor->Disable(); 948 mbColorAvail = false; 949 mpColorUpdater->Update(COL_WHITE); 950 } 951 else 952 { 953 mbColorAvail = false; 954 mpColorUpdater->Update(COL_WHITE); 955 } 956 } 957 break; 958 } 959 case SID_ATTR_FILL_GRADIENT: 960 { 961 if(SFX_ITEM_AVAILABLE == eState) 962 { 963 mpFillGradientItem.reset(pState ? (XFillGradientItem*)pState->Clone() : 0); 964 } 965 966 if(mpStyleItem && XFILL_GRADIENT == (XFillStyle)mpStyleItem->GetValue()) 967 { 968 mpLbFillAttr->Show(); 969 mpToolBoxColor->Hide(); 970 971 if(SFX_ITEM_AVAILABLE == eState) 972 { 973 mpLbFillAttr->Enable(); 974 Update(); 975 } 976 else if(SFX_ITEM_DISABLED == eState ) 977 { 978 mpLbFillAttr->Disable(); 979 mpLbFillAttr->SetNoSelection(); 980 } 981 else 982 { 983 mpLbFillAttr->SetNoSelection(); 984 } 985 } 986 break; 987 } 988 case SID_ATTR_FILL_HATCH: 989 { 990 if(SFX_ITEM_AVAILABLE == eState) 991 { 992 mpHatchItem.reset(pState ? (XFillHatchItem*)pState->Clone() : 0); 993 } 994 995 if(mpStyleItem && XFILL_HATCH == (XFillStyle)mpStyleItem->GetValue()) 996 { 997 mpLbFillAttr->Show(); 998 mpToolBoxColor->Hide(); 999 1000 if(SFX_ITEM_AVAILABLE == eState) 1001 { 1002 mpLbFillAttr->Enable(); 1003 Update(); 1004 } 1005 else if(SFX_ITEM_DISABLED == eState ) 1006 { 1007 mpLbFillAttr->Disable(); 1008 mpLbFillAttr->SetNoSelection(); 1009 } 1010 else 1011 { 1012 mpLbFillAttr->SetNoSelection(); 1013 } 1014 } 1015 break; 1016 } 1017 case SID_ATTR_FILL_BITMAP: 1018 { 1019 if(SFX_ITEM_AVAILABLE == eState) 1020 { 1021 mpBitmapItem.reset(pState ? (XFillBitmapItem*)pState->Clone() : 0); 1022 } 1023 1024 if(mpStyleItem && XFILL_BITMAP == (XFillStyle)mpStyleItem->GetValue()) 1025 { 1026 mpLbFillAttr->Show(); 1027 mpToolBoxColor->Hide(); 1028 1029 if(SFX_ITEM_AVAILABLE == eState) 1030 { 1031 mpLbFillAttr->Enable(); 1032 Update(); 1033 } 1034 else if(SFX_ITEM_DISABLED == eState ) 1035 { 1036 mpLbFillAttr->Disable(); 1037 mpLbFillAttr->SetNoSelection(); 1038 } 1039 else 1040 { 1041 mpLbFillAttr->SetNoSelection(); 1042 } 1043 } 1044 break; 1045 } 1046 case SID_COLOR_TABLE: 1047 { 1048 if(SFX_ITEM_AVAILABLE == eState) 1049 { 1050 if(mpStyleItem && XFILL_SOLID == (XFillStyle)mpStyleItem->GetValue()) 1051 { 1052 if(mpColorItem) 1053 { 1054 const Color aColor = mpColorItem->GetColorValue(); 1055 const SfxObjectShell* pSh = SfxObjectShell::Current(); 1056 const SvxColorTableItem aItem(*(const SvxColorTableItem*)(pSh->GetItem(SID_COLOR_TABLE))); 1057 1058 mpLbFillAttr->Clear(); 1059 mpLbFillAttr->Enable(); 1060 mpLbFillAttr->Fill(aItem.GetColorTable()); 1061 mpLbFillAttr->SelectEntry(aColor); 1062 } 1063 else 1064 { 1065 mpLbFillAttr->SetNoSelection(); 1066 } 1067 } 1068 } 1069 break; 1070 } 1071 case SID_GRADIENT_LIST: 1072 { 1073 if(SFX_ITEM_AVAILABLE == eState) 1074 { 1075 if(mpStyleItem && XFILL_GRADIENT == (XFillStyle)mpStyleItem->GetValue()) 1076 { 1077 if(mpFillGradientItem) 1078 { 1079 const String aString( mpFillGradientItem->GetName() ); 1080 const SfxObjectShell* pSh = SfxObjectShell::Current(); 1081 const SvxGradientListItem aItem( *(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); 1082 1083 mpLbFillAttr->Clear(); 1084 mpLbFillAttr->Enable(); 1085 mpLbFillAttr->Fill(aItem.GetGradientList()); 1086 mpLbFillAttr->SelectEntry(aString); 1087 } 1088 else 1089 { 1090 mpLbFillAttr->SetNoSelection(); 1091 } 1092 } 1093 } 1094 break; 1095 } 1096 case SID_HATCH_LIST: 1097 { 1098 if(SFX_ITEM_AVAILABLE == eState) 1099 { 1100 if(mpStyleItem && XFILL_HATCH == (XFillStyle)mpStyleItem->GetValue()) 1101 { 1102 if(mpHatchItem) 1103 { 1104 const String aString( mpHatchItem->GetName() ); 1105 const SfxObjectShell* pSh = SfxObjectShell::Current(); 1106 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); 1107 1108 mpLbFillAttr->Clear(); 1109 mpLbFillAttr->Enable(); 1110 mpLbFillAttr->Fill(aItem.GetHatchList()); 1111 mpLbFillAttr->SelectEntry(aString); 1112 } 1113 else 1114 { 1115 mpLbFillAttr->SetNoSelection(); 1116 } 1117 } 1118 } 1119 break; 1120 } 1121 case SID_BITMAP_LIST: 1122 { 1123 if(SFX_ITEM_AVAILABLE == eState) 1124 { 1125 if(mpStyleItem && XFILL_BITMAP == (XFillStyle)mpStyleItem->GetValue()) 1126 { 1127 if(mpBitmapItem) 1128 { 1129 const String aString( mpBitmapItem->GetName() ); 1130 const SfxObjectShell* pSh = SfxObjectShell::Current(); 1131 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); 1132 1133 mpLbFillAttr->Clear(); 1134 mpLbFillAttr->Enable(); 1135 mpLbFillAttr->Fill(aItem.GetBitmapList()); 1136 mpLbFillAttr->SelectEntry(aString); 1137 } 1138 else 1139 { 1140 mpLbFillAttr->SetNoSelection(); 1141 } 1142 } 1143 } 1144 break; 1145 } 1146 } 1147 1148 maLayouter.Layout(); 1149 } 1150 1151 1152 1153 SfxBindings* AreaPropertyPanel::GetBindings() 1154 { 1155 return mpBindings; 1156 } 1157 1158 1159 1160 void AreaPropertyPanel::Update() 1161 { 1162 if(mpStyleItem) 1163 { 1164 const XFillStyle eXFS = (XFillStyle)mpStyleItem->GetValue(); 1165 SfxObjectShell* pSh = SfxObjectShell::Current(); 1166 1167 switch( eXFS ) 1168 { 1169 case XFILL_NONE: 1170 { 1171 mpLbFillAttr->Show(); 1172 mpToolBoxColor->Hide(); 1173 break; 1174 } 1175 case XFILL_SOLID: 1176 { 1177 if(mpColorItem) 1178 { 1179 mpLbFillAttr->Hide(); 1180 mpToolBoxColor->Show(); 1181 mpColorUpdater->Update(mpColorItem->GetColorValue()); 1182 } 1183 else 1184 { 1185 mpColorUpdater->Update(COL_WHITE); 1186 } 1187 break; 1188 } 1189 case XFILL_GRADIENT: 1190 { 1191 mpLbFillAttr->Show(); 1192 mpToolBoxColor->Hide(); 1193 1194 if(pSh && pSh->GetItem(SID_GRADIENT_LIST)) 1195 { 1196 const SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); 1197 mpLbFillAttr->Enable(); 1198 mpLbFillAttr->Clear(); 1199 mpLbFillAttr->Fill(aItem.GetGradientList()); 1200 1201 if(mpFillGradientItem) 1202 { 1203 const String aString(mpFillGradientItem->GetName()); 1204 1205 mpLbFillAttr->SelectEntry(aString); 1206 } 1207 else 1208 { 1209 mpLbFillAttr->SetNoSelection(); 1210 } 1211 } 1212 else 1213 { 1214 mpLbFillAttr->SetNoSelection(); 1215 } 1216 break; 1217 } 1218 case XFILL_HATCH: 1219 { 1220 mpLbFillAttr->Show(); 1221 mpToolBoxColor->Hide(); 1222 1223 if(pSh && pSh->GetItem(SID_HATCH_LIST)) 1224 { 1225 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); 1226 mpLbFillAttr->Enable(); 1227 mpLbFillAttr->Clear(); 1228 mpLbFillAttr->Fill(aItem.GetHatchList()); 1229 1230 if(mpHatchItem) 1231 { 1232 const String aString(mpHatchItem->GetName()); 1233 1234 mpLbFillAttr->SelectEntry( aString ); 1235 } 1236 else 1237 { 1238 mpLbFillAttr->SetNoSelection(); 1239 } 1240 } 1241 else 1242 { 1243 mpLbFillAttr->SetNoSelection(); 1244 } 1245 break; 1246 } 1247 case XFILL_BITMAP: 1248 { 1249 mpLbFillAttr->Show(); 1250 mpToolBoxColor->Hide(); 1251 1252 if(pSh && pSh->GetItem(SID_BITMAP_LIST)) 1253 { 1254 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); 1255 mpLbFillAttr->Enable(); 1256 mpLbFillAttr->Clear(); 1257 mpLbFillAttr->Fill(aItem.GetBitmapList()); 1258 1259 if(mpBitmapItem) 1260 { 1261 const String aString(mpBitmapItem->GetName()); 1262 1263 mpLbFillAttr->SelectEntry(aString); 1264 } 1265 else 1266 { 1267 mpLbFillAttr->SetNoSelection(); 1268 } 1269 } 1270 else 1271 { 1272 mpLbFillAttr->SetNoSelection(); 1273 } 1274 break; 1275 } 1276 default: 1277 DBG_ERROR( "Non supported FillType (!)" ); 1278 break; 1279 } 1280 } 1281 } 1282 1283 1284 1285 IMPL_LINK( AreaPropertyPanel, ImplPopupModeEndHdl, FloatingWindow*, EMPTYARG ) 1286 { 1287 return 0; 1288 } 1289 1290 1291 1292 IMPL_LINK( AreaPropertyPanel, ClickTrGrHdl_Impl, ToolBox*, pToolBox ) 1293 { 1294 maTrGrPopup.Rearrange(mpFloatTransparenceItem.get()); 1295 OSL_ASSERT(pToolBox->GetCurItemId() == TBI_BTX_GRADIENT); 1296 maTrGrPopup.Show(*pToolBox); 1297 1298 return (0L); 1299 } 1300 1301 1302 1303 IMPL_LINK(AreaPropertyPanel, ChangeTrgrTypeHdl_Impl, void *, EMPTYARG) 1304 { 1305 sal_uInt16 nSelectType = mpLBTransType->GetSelectEntryPos(); 1306 bool bGradient = false; 1307 sal_uInt16 nTrans = 0; 1308 1309 if(!nSelectType) 1310 { 1311 mpBTNGradient->Hide(); 1312 mpMTRTransparent->Show(); 1313 mpMTRTransparent->Enable(); 1314 mpMTRTransparent->SetValue(0); 1315 } 1316 else if(1 == nSelectType) 1317 { 1318 mpBTNGradient->Hide(); 1319 mpMTRTransparent->Show(); 1320 nTrans = mnLastTransSolid; 1321 mpMTRTransparent->SetValue(nTrans); 1322 mpLBTransType->SelectEntryPos(1); 1323 mpMTRTransparent->Enable(); 1324 } 1325 else 1326 { 1327 mpBTNGradient->Show(); 1328 1329 switch (nSelectType) 1330 { 1331 case 2: 1332 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgLinearH : maImgLinear); 1333 break; 1334 case 3: 1335 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgAxialH : maImgAxial); 1336 break; 1337 case 4: 1338 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgRadialH : maImgRadial); 1339 break; 1340 case 5: 1341 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgElliH : maImgElli ); 1342 break; 1343 case 6: 1344 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgQuadH : maImgQuad ); 1345 break; 1346 case 7: 1347 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgSquareH : maImgSquare); 1348 break; 1349 } 1350 1351 mpMTRTransparent->Hide(); 1352 mpBTNGradient->Enable(); 1353 bGradient = true; 1354 } 1355 1356 const XFillTransparenceItem aLinearItem(nTrans); 1357 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE, SFX_CALLMODE_RECORD, &aLinearItem, 0L ); 1358 1359 if(nSelectType > 1) 1360 { 1361 nSelectType -= 2; 1362 } 1363 1364 XGradient aTmpGradient; 1365 1366 switch(nSelectType) 1367 { 1368 case XGRAD_LINEAR: 1369 aTmpGradient = maGradientLinear; 1370 break; 1371 case XGRAD_AXIAL: 1372 aTmpGradient = maGradientAxial; 1373 break; 1374 case XGRAD_RADIAL: 1375 aTmpGradient = maGradientRadial; 1376 break; 1377 case XGRAD_ELLIPTICAL: 1378 aTmpGradient = maGradientElliptical; 1379 break; 1380 case XGRAD_SQUARE: 1381 aTmpGradient = maGradientSquare; 1382 break; 1383 case XGRAD_RECT: 1384 aTmpGradient = maGradientRect; 1385 break; 1386 } 1387 1388 SfxItemPool* pPool = 0; 1389 const XFillFloatTransparenceItem aGradientItem(pPool, aTmpGradient, sal_Bool(bGradient)); 1390 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_FLOATTRANSPARENCE, SFX_CALLMODE_RECORD, &aGradientItem, 0L ); 1391 1392 return( 0L ); 1393 } 1394 1395 1396 1397 IMPL_LINK(AreaPropertyPanel, ModifyTransparentHdl_Impl, void*, EMPTYARG) 1398 { 1399 const sal_uInt16 nTrans = (sal_uInt16)mpMTRTransparent->GetValue(); 1400 mnLastTransSolid = nTrans; 1401 const sal_uInt16 nSelectType = mpLBTransType->GetSelectEntryPos(); 1402 1403 if(nTrans && !nSelectType) 1404 { 1405 mpLBTransType->SelectEntryPos(1); 1406 } 1407 1408 const XFillTransparenceItem aLinearItem(nTrans); 1409 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE, SFX_CALLMODE_RECORD, &aLinearItem, 0L ); 1410 1411 return 0L; 1412 } 1413 1414 1415 Color AreaPropertyPanel::GetLastColor (void) const 1416 { 1417 return maLastColor; 1418 } 1419 1420 1421 1422 1423 XGradient AreaPropertyPanel::GetGradient (const XGradientStyle eStyle) const 1424 { 1425 switch (eStyle) 1426 { 1427 default: 1428 case XGRAD_LINEAR: 1429 return maGradientLinear; 1430 case XGRAD_AXIAL: 1431 return maGradientAxial; 1432 case XGRAD_RADIAL: 1433 return maGradientRadial; 1434 case XGRAD_ELLIPTICAL: 1435 return maGradientElliptical; 1436 case XGRAD_SQUARE: 1437 return maGradientSquare; 1438 case XGRAD_RECT: 1439 return maGradientRect; 1440 } 1441 } 1442 1443 1444 1445 1446 void AreaPropertyPanel::SetGradient (const XGradient& rGradient) 1447 { 1448 switch (rGradient.GetGradientStyle()) 1449 { 1450 case XGRAD_LINEAR: 1451 maGradientLinear = rGradient; 1452 break; 1453 case XGRAD_AXIAL: 1454 maGradientAxial = rGradient; 1455 break; 1456 case XGRAD_RADIAL: 1457 maGradientRadial = rGradient; 1458 break; 1459 case XGRAD_ELLIPTICAL: 1460 maGradientElliptical = rGradient; 1461 break; 1462 case XGRAD_SQUARE: 1463 maGradientSquare = rGradient; 1464 break; 1465 case XGRAD_RECT: 1466 maGradientRect = rGradient; 1467 break; 1468 } 1469 } 1470 1471 1472 1473 1474 sal_Int32 AreaPropertyPanel::GetSelectedTransparencyTypeIndex (void) const 1475 { 1476 return mpLBTransType->GetSelectEntryPos(); 1477 } 1478 1479 1480 1481 1482 void AreaPropertyPanel::Resize (void) 1483 { 1484 maLayouter.Layout(); 1485 } 1486 1487 1488 1489 } } // end of namespace svx::sidebar 1490 1491 // eof 1492