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 mpLBTransType->SelectEntryPos(1); 671 mpBTNGradient->Hide(); 672 mpMTRTransparent->Show(); 673 mpMTRTransparent->Enable(); 674 mpMTRTransparent->SetValue(nValue); 675 } 676 677 if(!bZeroValue) 678 { 679 maTrGrPopup.Hide(); 680 } 681 } 682 683 if(bZeroValue && mpFloatTransparenceItem.get()) 684 { 685 if(mpFloatTransparenceItem->IsEnabled()) 686 { 687 const XGradient& rGradient = mpFloatTransparenceItem->GetGradientValue(); 688 const bool bHighContrast(GetSettings().GetStyleSettings().GetHighContrastMode()); 689 sal_uInt16 nEntryPos(0); 690 Image* pImage = 0; 691 692 mpLBTransType->Enable(); 693 mpMTRTransparent->Hide(); 694 mpBTNGradient->Enable(); 695 mpBTNGradient->Show(); 696 697 switch(rGradient.GetGradientStyle()) 698 { 699 case XGRAD_LINEAR: 700 { 701 nEntryPos = 2; 702 pImage = bHighContrast ? &maImgLinearH : &maImgLinear; 703 break; 704 } 705 case XGRAD_AXIAL: 706 { 707 nEntryPos = 3; 708 pImage = bHighContrast ? &maImgAxialH : &maImgAxial; 709 break; 710 } 711 case XGRAD_RADIAL: 712 { 713 nEntryPos = 4; 714 pImage = bHighContrast ? &maImgRadialH : &maImgRadial; 715 break; 716 } 717 case XGRAD_ELLIPTICAL: 718 { 719 nEntryPos = 5; 720 pImage = bHighContrast ? &maImgElliH : &maImgElli; 721 break; 722 } 723 case XGRAD_SQUARE: 724 { 725 nEntryPos = 6; 726 pImage = bHighContrast ? &maImgQuadH : &maImgQuad; 727 break; 728 } 729 case XGRAD_RECT: 730 { 731 nEntryPos = 7; 732 pImage = bHighContrast ? &maImgSquareH : &maImgSquare; 733 break; 734 } 735 } 736 737 mpLBTransType->SelectEntryPos(nEntryPos); 738 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT, *pImage); 739 bZeroValue = false; 740 } 741 else 742 { 743 bZeroValue = true; 744 } 745 } 746 747 if(bZeroValue) 748 { 749 mpLBTransType->Enable(); 750 mpLBTransType->SelectEntryPos(0); 751 mpBTNGradient->Hide(); 752 mpMTRTransparent->Enable(); 753 mpMTRTransparent->Show(); 754 mpMTRTransparent->SetValue(0); 755 } 756 } 757 else 758 { 759 // no transparency at all 760 mpLBTransType->SetNoSelection(); 761 mpMTRTransparent->Disable(); 762 mpMTRTransparent->Show(); 763 mpBTNGradient->Disable(); 764 mpBTNGradient->Hide(); 765 } 766 } 767 768 769 770 void AreaPropertyPanel::NotifyItemUpdate( 771 sal_uInt16 nSID, 772 SfxItemState eState, 773 const SfxPoolItem* pState, 774 const bool bIsEnabled) 775 { 776 (void)bIsEnabled; 777 const bool bDisabled(SFX_ITEM_DISABLED == eState); 778 779 switch(nSID) 780 { 781 case SID_ATTR_FILL_TRANSPARENCE: 782 case SID_ATTR_FILL_FLOATTRANSPARENCE: 783 { 784 bool bFillTransparenceChanged(false); 785 786 if(SID_ATTR_FILL_TRANSPARENCE == nSID) 787 { 788 bFillTransparenceChanged = true; 789 790 if(eState >= SFX_ITEM_AVAILABLE) 791 { 792 const SfxUInt16Item* pItem = dynamic_cast< const SfxUInt16Item* >(pState); 793 794 if(pItem && (!mpTransparanceItem || *pItem != *mpTransparanceItem)) 795 { 796 mpTransparanceItem.reset((SfxUInt16Item*)pItem->Clone()); 797 } 798 else 799 { 800 mpTransparanceItem.reset(); 801 } 802 } 803 else 804 { 805 mpTransparanceItem.reset(); 806 } 807 } 808 else // if(SID_ATTR_FILL_FLOATTRANSPARENCE == nSID) 809 { 810 bFillTransparenceChanged = true; 811 812 if(eState >= SFX_ITEM_AVAILABLE) 813 { 814 const XFillFloatTransparenceItem* pItem = dynamic_cast< const XFillFloatTransparenceItem* >(pState); 815 816 if(pItem && (!mpFloatTransparenceItem || *pItem != *mpFloatTransparenceItem)) 817 { 818 mpFloatTransparenceItem.reset((XFillFloatTransparenceItem*)pItem->Clone()); 819 } 820 else 821 { 822 mpFloatTransparenceItem.reset(); 823 } 824 } 825 else 826 { 827 mpFloatTransparenceItem.reset(); 828 } 829 } 830 831 if(bFillTransparenceChanged) 832 { 833 // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem 834 ImpUpdateTransparencies(); 835 } 836 break; 837 } 838 case SID_ATTR_FILL_STYLE: 839 { 840 if(bDisabled) 841 { 842 mpLbFillType->Disable(); 843 mpLbFillType->SetNoSelection(); 844 mpLbFillAttr->Show(); 845 mpLbFillAttr->Disable(); 846 mpLbFillAttr->SetNoSelection(); 847 mpToolBoxColor->Hide(); 848 meLastXFS = -1; 849 mpStyleItem.reset(); 850 } 851 852 if(eState >= SFX_ITEM_AVAILABLE) 853 { 854 const XFillStyleItem* pItem = dynamic_cast< const XFillStyleItem* >(pState); 855 856 if(pItem) 857 { 858 mpStyleItem.reset(dynamic_cast< XFillStyleItem* >(pItem->Clone())); 859 mpLbFillType->Enable(); 860 XFillStyle eXFS = (XFillStyle)mpStyleItem->GetValue(); 861 meLastXFS = eXFS; 862 mpLbFillType->SelectEntryPos(sal::static_int_cast< sal_uInt16 >(eXFS)); 863 864 if(XFILL_NONE == eXFS) 865 { 866 mpLbFillAttr->SetNoSelection(); 867 mpLbFillAttr->Disable(); 868 } 869 870 Update(); 871 break; 872 } 873 } 874 875 mpLbFillType->SetNoSelection(); 876 mpLbFillAttr->Show(); 877 mpLbFillAttr->Disable(); 878 mpLbFillAttr->SetNoSelection(); 879 mpToolBoxColor->Hide(); 880 meLastXFS = -1; 881 mpStyleItem.reset(); 882 break; 883 } 884 case SID_ATTR_FILL_COLOR: 885 { 886 if(SFX_ITEM_AVAILABLE == eState) 887 { 888 mpColorItem.reset(pState ? (XFillColorItem*)pState->Clone() : 0); 889 } 890 891 if(mpStyleItem && XFILL_SOLID == (XFillStyle)mpStyleItem->GetValue()) 892 { 893 mpLbFillAttr->Hide(); 894 mpToolBoxColor->Show(); 895 896 if(SFX_ITEM_AVAILABLE == eState) 897 { 898 mpToolBoxColor->Enable(); 899 mbColorAvail = true; 900 // maLastColor = mpColorItem->GetColorValue(); 901 Update(); 902 } 903 else if(SFX_ITEM_DISABLED == eState) 904 { 905 mpToolBoxColor->Disable(); 906 mbColorAvail = false; 907 mpColorUpdater->Update(COL_WHITE); 908 } 909 else 910 { 911 mbColorAvail = false; 912 mpColorUpdater->Update(COL_WHITE); 913 } 914 } 915 break; 916 } 917 case SID_ATTR_FILL_GRADIENT: 918 { 919 if(SFX_ITEM_AVAILABLE == eState) 920 { 921 mpFillGradientItem.reset(pState ? (XFillGradientItem*)pState->Clone() : 0); 922 } 923 924 if(mpStyleItem && XFILL_GRADIENT == (XFillStyle)mpStyleItem->GetValue()) 925 { 926 mpLbFillAttr->Show(); 927 mpToolBoxColor->Hide(); 928 929 if(SFX_ITEM_AVAILABLE == eState) 930 { 931 mpLbFillAttr->Enable(); 932 Update(); 933 } 934 else if(SFX_ITEM_DISABLED == eState ) 935 { 936 mpLbFillAttr->Disable(); 937 mpLbFillAttr->SetNoSelection(); 938 } 939 else 940 { 941 mpLbFillAttr->SetNoSelection(); 942 } 943 } 944 break; 945 } 946 case SID_ATTR_FILL_HATCH: 947 { 948 if(SFX_ITEM_AVAILABLE == eState) 949 { 950 mpHatchItem.reset(pState ? (XFillHatchItem*)pState->Clone() : 0); 951 } 952 953 if(mpStyleItem && XFILL_HATCH == (XFillStyle)mpStyleItem->GetValue()) 954 { 955 mpLbFillAttr->Show(); 956 mpToolBoxColor->Hide(); 957 958 if(SFX_ITEM_AVAILABLE == eState) 959 { 960 mpLbFillAttr->Enable(); 961 Update(); 962 } 963 else if(SFX_ITEM_DISABLED == eState ) 964 { 965 mpLbFillAttr->Disable(); 966 mpLbFillAttr->SetNoSelection(); 967 } 968 else 969 { 970 mpLbFillAttr->SetNoSelection(); 971 } 972 } 973 break; 974 } 975 case SID_ATTR_FILL_BITMAP: 976 { 977 if(SFX_ITEM_AVAILABLE == eState) 978 { 979 mpBitmapItem.reset(pState ? (XFillBitmapItem*)pState->Clone() : 0); 980 } 981 982 if(mpStyleItem && XFILL_BITMAP == (XFillStyle)mpStyleItem->GetValue()) 983 { 984 mpLbFillAttr->Show(); 985 mpToolBoxColor->Hide(); 986 987 if(SFX_ITEM_AVAILABLE == eState) 988 { 989 mpLbFillAttr->Enable(); 990 Update(); 991 } 992 else if(SFX_ITEM_DISABLED == eState ) 993 { 994 mpLbFillAttr->Disable(); 995 mpLbFillAttr->SetNoSelection(); 996 } 997 else 998 { 999 mpLbFillAttr->SetNoSelection(); 1000 } 1001 } 1002 break; 1003 } 1004 case SID_COLOR_TABLE: 1005 { 1006 if(SFX_ITEM_AVAILABLE == eState) 1007 { 1008 if(mpStyleItem && XFILL_SOLID == (XFillStyle)mpStyleItem->GetValue()) 1009 { 1010 if(mpColorItem) 1011 { 1012 const Color aColor = mpColorItem->GetColorValue(); 1013 const SfxObjectShell* pSh = SfxObjectShell::Current(); 1014 const SvxColorTableItem aItem(*(const SvxColorTableItem*)(pSh->GetItem(SID_COLOR_TABLE))); 1015 1016 mpLbFillAttr->Clear(); 1017 mpLbFillAttr->Enable(); 1018 mpLbFillAttr->Fill(aItem.GetColorTable()); 1019 mpLbFillAttr->SelectEntry(aColor); 1020 } 1021 else 1022 { 1023 mpLbFillAttr->SetNoSelection(); 1024 } 1025 } 1026 } 1027 break; 1028 } 1029 case SID_GRADIENT_LIST: 1030 { 1031 if(SFX_ITEM_AVAILABLE == eState) 1032 { 1033 if(mpStyleItem && XFILL_GRADIENT == (XFillStyle)mpStyleItem->GetValue()) 1034 { 1035 if(mpFillGradientItem) 1036 { 1037 const String aString( mpFillGradientItem->GetName() ); 1038 const SfxObjectShell* pSh = SfxObjectShell::Current(); 1039 const SvxGradientListItem aItem( *(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); 1040 1041 mpLbFillAttr->Clear(); 1042 mpLbFillAttr->Enable(); 1043 mpLbFillAttr->Fill(aItem.GetGradientList()); 1044 mpLbFillAttr->SelectEntry(aString); 1045 } 1046 else 1047 { 1048 mpLbFillAttr->SetNoSelection(); 1049 } 1050 } 1051 } 1052 break; 1053 } 1054 case SID_HATCH_LIST: 1055 { 1056 if(SFX_ITEM_AVAILABLE == eState) 1057 { 1058 if(mpStyleItem && XFILL_HATCH == (XFillStyle)mpStyleItem->GetValue()) 1059 { 1060 if(mpHatchItem) 1061 { 1062 const String aString( mpHatchItem->GetName() ); 1063 const SfxObjectShell* pSh = SfxObjectShell::Current(); 1064 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); 1065 1066 mpLbFillAttr->Clear(); 1067 mpLbFillAttr->Enable(); 1068 mpLbFillAttr->Fill(aItem.GetHatchList()); 1069 mpLbFillAttr->SelectEntry(aString); 1070 } 1071 else 1072 { 1073 mpLbFillAttr->SetNoSelection(); 1074 } 1075 } 1076 } 1077 break; 1078 } 1079 case SID_BITMAP_LIST: 1080 { 1081 if(SFX_ITEM_AVAILABLE == eState) 1082 { 1083 if(mpStyleItem && XFILL_BITMAP == (XFillStyle)mpStyleItem->GetValue()) 1084 { 1085 if(mpBitmapItem) 1086 { 1087 const String aString( mpBitmapItem->GetName() ); 1088 const SfxObjectShell* pSh = SfxObjectShell::Current(); 1089 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); 1090 1091 mpLbFillAttr->Clear(); 1092 mpLbFillAttr->Enable(); 1093 mpLbFillAttr->Fill(aItem.GetBitmapList()); 1094 mpLbFillAttr->SelectEntry(aString); 1095 } 1096 else 1097 { 1098 mpLbFillAttr->SetNoSelection(); 1099 } 1100 } 1101 } 1102 break; 1103 } 1104 } 1105 } 1106 1107 1108 1109 SfxBindings* AreaPropertyPanel::GetBindings() 1110 { 1111 return mpBindings; 1112 } 1113 1114 1115 1116 void AreaPropertyPanel::Update() 1117 { 1118 if(mpStyleItem) 1119 { 1120 const XFillStyle eXFS = (XFillStyle)mpStyleItem->GetValue(); 1121 SfxObjectShell* pSh = SfxObjectShell::Current(); 1122 1123 switch( eXFS ) 1124 { 1125 case XFILL_NONE: 1126 { 1127 mpLbFillAttr->Show(); 1128 mpToolBoxColor->Hide(); 1129 break; 1130 } 1131 case XFILL_SOLID: 1132 { 1133 if(mpColorItem) 1134 { 1135 mpLbFillAttr->Hide(); 1136 mpToolBoxColor->Show(); 1137 mpColorUpdater->Update(mpColorItem->GetColorValue()); 1138 } 1139 else 1140 { 1141 mpColorUpdater->Update(COL_WHITE); 1142 } 1143 break; 1144 } 1145 case XFILL_GRADIENT: 1146 { 1147 mpLbFillAttr->Show(); 1148 mpToolBoxColor->Hide(); 1149 1150 if(pSh && pSh->GetItem(SID_GRADIENT_LIST)) 1151 { 1152 const SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); 1153 mpLbFillAttr->Enable(); 1154 mpLbFillAttr->Clear(); 1155 mpLbFillAttr->Fill(aItem.GetGradientList()); 1156 1157 if(mpFillGradientItem) 1158 { 1159 const String aString(mpFillGradientItem->GetName()); 1160 1161 mpLbFillAttr->SelectEntry(aString); 1162 } 1163 else 1164 { 1165 mpLbFillAttr->SetNoSelection(); 1166 } 1167 } 1168 else 1169 { 1170 mpLbFillAttr->SetNoSelection(); 1171 } 1172 break; 1173 } 1174 case XFILL_HATCH: 1175 { 1176 mpLbFillAttr->Show(); 1177 mpToolBoxColor->Hide(); 1178 1179 if(pSh && pSh->GetItem(SID_HATCH_LIST)) 1180 { 1181 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); 1182 mpLbFillAttr->Enable(); 1183 mpLbFillAttr->Clear(); 1184 mpLbFillAttr->Fill(aItem.GetHatchList()); 1185 1186 if(mpHatchItem) 1187 { 1188 const String aString(mpHatchItem->GetName()); 1189 1190 mpLbFillAttr->SelectEntry( aString ); 1191 } 1192 else 1193 { 1194 mpLbFillAttr->SetNoSelection(); 1195 } 1196 } 1197 else 1198 { 1199 mpLbFillAttr->SetNoSelection(); 1200 } 1201 break; 1202 } 1203 case XFILL_BITMAP: 1204 { 1205 mpLbFillAttr->Show(); 1206 mpToolBoxColor->Hide(); 1207 1208 if(pSh && pSh->GetItem(SID_BITMAP_LIST)) 1209 { 1210 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); 1211 mpLbFillAttr->Enable(); 1212 mpLbFillAttr->Clear(); 1213 mpLbFillAttr->Fill(aItem.GetBitmapList()); 1214 1215 if(mpBitmapItem) 1216 { 1217 const String aString(mpBitmapItem->GetName()); 1218 1219 mpLbFillAttr->SelectEntry(aString); 1220 } 1221 else 1222 { 1223 mpLbFillAttr->SetNoSelection(); 1224 } 1225 } 1226 else 1227 { 1228 mpLbFillAttr->SetNoSelection(); 1229 } 1230 break; 1231 } 1232 default: 1233 DBG_ERROR( "Non supported FillType (!)" ); 1234 break; 1235 } 1236 } 1237 } 1238 1239 1240 1241 IMPL_LINK( AreaPropertyPanel, ImplPopupModeEndHdl, FloatingWindow*, EMPTYARG ) 1242 { 1243 return 0; 1244 } 1245 1246 1247 1248 IMPL_LINK( AreaPropertyPanel, ClickTrGrHdl_Impl, ToolBox*, pToolBox ) 1249 { 1250 maTrGrPopup.Rearrange(mpFloatTransparenceItem.get()); 1251 OSL_ASSERT(pToolBox->GetCurItemId() == TBI_BTX_GRADIENT); 1252 maTrGrPopup.Show(*pToolBox); 1253 1254 return (0L); 1255 } 1256 1257 1258 1259 IMPL_LINK(AreaPropertyPanel, ChangeTrgrTypeHdl_Impl, void *, EMPTYARG) 1260 { 1261 sal_uInt16 nSelectType = mpLBTransType->GetSelectEntryPos(); 1262 bool bGradient = false; 1263 sal_uInt16 nTrans = 0; 1264 1265 if(!nSelectType) 1266 { 1267 mpBTNGradient->Hide(); 1268 mpMTRTransparent->Show(); 1269 mpMTRTransparent->Enable(); 1270 mpMTRTransparent->SetValue(0); 1271 } 1272 else if(1 == nSelectType) 1273 { 1274 mpBTNGradient->Hide(); 1275 mpMTRTransparent->Show(); 1276 nTrans = mnLastTransSolid; 1277 mpMTRTransparent->SetValue(nTrans); 1278 mpLBTransType->SelectEntryPos(1); 1279 mpMTRTransparent->Enable(); 1280 } 1281 else 1282 { 1283 mpBTNGradient->Show(); 1284 1285 switch (nSelectType) 1286 { 1287 case 2: 1288 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgLinearH : maImgLinear); 1289 break; 1290 case 3: 1291 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgAxialH : maImgAxial); 1292 break; 1293 case 4: 1294 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgRadialH : maImgRadial); 1295 break; 1296 case 5: 1297 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgElliH : maImgElli ); 1298 break; 1299 case 6: 1300 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgQuadH : maImgQuad ); 1301 break; 1302 case 7: 1303 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgSquareH : maImgSquare); 1304 break; 1305 } 1306 1307 mpMTRTransparent->Hide(); 1308 mpBTNGradient->Enable(); 1309 bGradient = true; 1310 } 1311 1312 const XFillTransparenceItem aLinearItem(nTrans); 1313 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE, SFX_CALLMODE_RECORD, &aLinearItem, 0L ); 1314 1315 if(nSelectType > 1) 1316 { 1317 nSelectType -= 2; 1318 } 1319 1320 XGradient aTmpGradient; 1321 1322 switch(nSelectType) 1323 { 1324 case XGRAD_LINEAR: 1325 aTmpGradient = maGradientLinear; 1326 break; 1327 case XGRAD_AXIAL: 1328 aTmpGradient = maGradientAxial; 1329 break; 1330 case XGRAD_RADIAL: 1331 aTmpGradient = maGradientRadial; 1332 break; 1333 case XGRAD_ELLIPTICAL: 1334 aTmpGradient = maGradientElliptical; 1335 break; 1336 case XGRAD_SQUARE: 1337 aTmpGradient = maGradientSquare; 1338 break; 1339 case XGRAD_RECT: 1340 aTmpGradient = maGradientRect; 1341 break; 1342 } 1343 1344 SfxItemPool* pPool = 0; 1345 const XFillFloatTransparenceItem aGradientItem(pPool, aTmpGradient, sal_Bool(bGradient)); 1346 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_FLOATTRANSPARENCE, SFX_CALLMODE_RECORD, &aGradientItem, 0L ); 1347 1348 return( 0L ); 1349 } 1350 1351 1352 1353 IMPL_LINK(AreaPropertyPanel, ModifyTransparentHdl_Impl, void*, EMPTYARG) 1354 { 1355 const sal_uInt16 nTrans = (sal_uInt16)mpMTRTransparent->GetValue(); 1356 mnLastTransSolid = nTrans; 1357 const sal_uInt16 nSelectType = mpLBTransType->GetSelectEntryPos(); 1358 1359 if(nTrans && !nSelectType) 1360 { 1361 mpLBTransType->SelectEntryPos(1); 1362 } 1363 1364 const XFillTransparenceItem aLinearItem(nTrans); 1365 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE, SFX_CALLMODE_RECORD, &aLinearItem, 0L ); 1366 1367 return 0L; 1368 } 1369 1370 1371 Color AreaPropertyPanel::GetLastColor (void) const 1372 { 1373 return maLastColor; 1374 } 1375 1376 1377 1378 1379 XGradient AreaPropertyPanel::GetGradient (const XGradientStyle eStyle) const 1380 { 1381 switch (eStyle) 1382 { 1383 default: 1384 case XGRAD_LINEAR: 1385 return maGradientLinear; 1386 case XGRAD_AXIAL: 1387 return maGradientAxial; 1388 case XGRAD_RADIAL: 1389 return maGradientRadial; 1390 case XGRAD_ELLIPTICAL: 1391 return maGradientElliptical; 1392 case XGRAD_SQUARE: 1393 return maGradientSquare; 1394 case XGRAD_RECT: 1395 return maGradientRect; 1396 } 1397 } 1398 1399 1400 1401 1402 void AreaPropertyPanel::SetGradient (const XGradient& rGradient) 1403 { 1404 switch (rGradient.GetGradientStyle()) 1405 { 1406 case XGRAD_LINEAR: 1407 maGradientLinear = rGradient; 1408 break; 1409 case XGRAD_AXIAL: 1410 maGradientAxial = rGradient; 1411 break; 1412 case XGRAD_RADIAL: 1413 maGradientRadial = rGradient; 1414 break; 1415 case XGRAD_ELLIPTICAL: 1416 maGradientElliptical = rGradient; 1417 break; 1418 case XGRAD_SQUARE: 1419 maGradientSquare = rGradient; 1420 break; 1421 case XGRAD_RECT: 1422 maGradientRect = rGradient; 1423 break; 1424 } 1425 } 1426 1427 1428 1429 1430 sal_Int32 AreaPropertyPanel::GetSelectedTransparencyTypeIndex (void) const 1431 { 1432 return mpLBTransType->GetSelectEntryPos(); 1433 } 1434 1435 } } // end of namespace svx::sidebar 1436 1437 // eof 1438