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