1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "svx/sidebar/PopupContainer.hxx"
20 #include "AreaTransparencyGradientControl.hxx"
22 #include <sfx2/sidebar/ResourceDefinitions.hrc>
23 #include <sfx2/sidebar/Theme.hxx>
24 #include <sfx2/sidebar/ControlFactory.hxx>
25 #include <AreaPropertyPanel.hxx>
26 #include <AreaPropertyPanel.hrc>
27 #include <svx/dialogs.hrc>
28 #include <svx/dialmgr.hxx>
29 #include <sfx2/objsh.hxx>
30 #include <svx/xfltrit.hxx>
31 #include <svx/xflftrit.hxx>
32 #include <svx/xtable.hxx>
33 #include <sfx2/dispatch.hxx>
34 #include <sfx2/bindings.hxx>
36 #include <svtools/valueset.hxx>
37 #include <unotools/pathoptions.hxx>
38 #include <svx/svxitems.hrc>
39 #include <vcl/toolbox.hxx>
40 #include <svtools/toolbarmenu.hxx>
41 #include <svx/sidebar/ColorControl.hxx>
43 #include <boost/bind.hpp>
47 using ::sfx2::sidebar::Theme
;
49 const char UNO_SIDEBARCOLOR
[] = ".uno:sidebarcolor";
50 const char UNO_SIDEBARGRADIENT
[] = ".uno:sidebargradient";
52 namespace svx
{ namespace sidebar
{
54 const sal_Int32
AreaPropertyPanel::DEFAULT_CENTERX
= 50;
55 const sal_Int32
AreaPropertyPanel::DEFAULT_CENTERY
= 50;
56 const sal_Int32
AreaPropertyPanel::DEFAULT_ANGLE
= 0;
57 const sal_Int32
AreaPropertyPanel::DEFAULT_STARTVALUE
= 0;
58 const sal_Int32
AreaPropertyPanel::DEFAULT_ENDVALUE
= 16777215;
59 const sal_Int32
AreaPropertyPanel::DEFAULT_BORDER
= 0;
62 AreaPropertyPanel::AreaPropertyPanel(
64 const cssu::Reference
<css::frame::XFrame
>& rxFrame
,
65 SfxBindings
* pBindings
)
66 : PanelLayout(pParent
, "AreaPropertyPanel", "svx/ui/sidebararea.ui", rxFrame
),
68 maLastColor(Color(COL_DEFAULT_SHAPE_FILLING
)),
76 maGradientElliptical(),
84 maStyleControl(SID_ATTR_FILL_STYLE
, *pBindings
, *this),
85 maColorControl(SID_ATTR_FILL_COLOR
, *pBindings
, *this),
86 maGradientControl(SID_ATTR_FILL_GRADIENT
, *pBindings
, *this),
87 maHatchControl(SID_ATTR_FILL_HATCH
, *pBindings
, *this),
88 maBitmapControl(SID_ATTR_FILL_BITMAP
, *pBindings
, *this),
89 maColorTableControl(SID_COLOR_TABLE
, *pBindings
, *this),
90 maGradientListControl(SID_GRADIENT_LIST
, *pBindings
, *this),
91 maHatchListControl(SID_HATCH_LIST
, *pBindings
, *this),
92 maBitmapListControl(SID_BITMAP_LIST
, *pBindings
, *this),
93 maFillTransparenceController(SID_ATTR_FILL_TRANSPARENCE
, *pBindings
, *this),
94 maFillFloatTransparenceController(SID_ATTR_FILL_FLOATTRANSPARENCE
, *pBindings
, *this),
95 maImgAxial(SVX_RES(IMG_AXIAL
)),
96 maImgElli(SVX_RES(IMG_ELLI
)),
97 maImgQuad(SVX_RES(IMG_QUAD
)),
98 maImgRadial(SVX_RES(IMG_RADIAL
)),
99 maImgSquare(SVX_RES(IMG_SQUARE
)),
100 maImgLinear(SVX_RES(IMG_LINEAR
)),
101 maImgColor(SVX_RES(IMG_COLOR
)),
102 maTrGrPopup(this, ::boost::bind(&AreaPropertyPanel::CreateTransparencyGradientControl
, this, _1
)),
103 maColorPopup(this, ::boost::bind(&AreaPropertyPanel::CreateColorPopupControl
, this, _1
)),
104 mpFloatTransparenceItem(),
105 mpTransparanceItem(),
107 mpBindings(pBindings
),
110 get(mpColorTextFT
, "filllabel");
111 get(mpLbFillType
, "fillstyle");
112 get(mpLbFillAttr
, "fillattr");
113 get(mpTrspTextFT
, "transparencylabel");
114 get(mpToolBoxColor
, "selectcolor");
115 get(mpLBTransType
, "transtype");
116 get(mpMTRTransparent
, "settransparency");
117 get(mpBTNGradient
, "selectgradient");
119 const sal_uInt16 nIdColor
= mpToolBoxColor
->GetItemId(UNO_SIDEBARCOLOR
);
120 mpColorUpdater
.reset(new ::svx::ToolboxButtonColorUpdater(SID_ATTR_FILL_COLOR
, nIdColor
, mpToolBoxColor
)),
127 AreaPropertyPanel::~AreaPropertyPanel()
133 void AreaPropertyPanel::Initialize()
135 maGradientLinear
.SetXOffset(DEFAULT_CENTERX
);
136 maGradientLinear
.SetYOffset(DEFAULT_CENTERY
);
137 maGradientLinear
.SetAngle(DEFAULT_ANGLE
);
138 maGradientLinear
.SetStartColor(Color(DEFAULT_STARTVALUE
));
139 maGradientLinear
.SetEndColor(Color(DEFAULT_ENDVALUE
));
140 maGradientLinear
.SetBorder(DEFAULT_BORDER
);
141 maGradientLinear
.SetGradientStyle(XGRAD_LINEAR
);
143 maGradientAxial
= maGradientLinear
;
144 maGradientAxial
.SetGradientStyle(XGRAD_AXIAL
);
146 maGradientRadial
= maGradientLinear
;
147 maGradientRadial
.SetGradientStyle(XGRAD_RADIAL
);
149 maGradientElliptical
= maGradientLinear
;
150 maGradientElliptical
.SetGradientStyle(XGRAD_ELLIPTICAL
);
152 maGradientSquare
= maGradientLinear
;
153 maGradientSquare
.SetGradientStyle(XGRAD_SQUARE
);
155 maGradientRect
= maGradientLinear
;
156 maGradientRect
.SetGradientStyle(XGRAD_RECT
);
158 mpLbFillType
->SetAccessibleName(OUString( "Fill")); //wj acc
159 mpLbFillAttr
->SetAccessibleName(OUString( "Fill")); //wj acc
161 Link aLink
= LINK( this, AreaPropertyPanel
, SelectFillTypeHdl
);
162 mpLbFillType
->SetSelectHdl( aLink
);
164 aLink
= LINK( this, AreaPropertyPanel
, SelectFillAttrHdl
);
165 mpLbFillAttr
->SetSelectHdl( aLink
);
167 //add for new color picker
168 mpLbFillAttr
->Hide();
169 const sal_uInt16 nIdColor
= mpToolBoxColor
->GetItemId(UNO_SIDEBARCOLOR
);
170 mpToolBoxColor
->SetItemImage(nIdColor
, maImgColor
);
171 mpToolBoxColor
->SetItemBits( nIdColor
, mpToolBoxColor
->GetItemBits( nIdColor
) | TIB_DROPDOWNONLY
);
172 mpToolBoxColor
->SetItemText(nIdColor
, msHelpFillAttr
);
174 aLink
= LINK(this, AreaPropertyPanel
, ToolBoxColorDropHdl
);
175 mpToolBoxColor
->SetDropdownClickHdl ( aLink
);
176 mpToolBoxColor
->SetSelectHdl ( aLink
);
179 mpLBTransType
->SetSelectHdl(LINK(this, AreaPropertyPanel
, ChangeTrgrTypeHdl_Impl
));
180 mpLBTransType
->SetAccessibleName(OUString( "Transparency")); //wj acc
182 mpMTRTransparent
->SetValue( 50 );
183 mpMTRTransparent
->SetModifyHdl(LINK(this, AreaPropertyPanel
, ModifyTransparentHdl_Impl
));
184 mpMTRTransparent
->SetAccessibleName(OUString( "Transparency")); //wj acc
186 const sal_uInt16 nIdGradient
= mpBTNGradient
->GetItemId(UNO_SIDEBARGRADIENT
);
187 mpBTNGradient
->SetItemBits( nIdGradient
, mpBTNGradient
->GetItemBits( nIdGradient
) | TIB_DROPDOWNONLY
);
188 aLink
= LINK( this, AreaPropertyPanel
, ClickTrGrHdl_Impl
);
189 mpBTNGradient
->SetDropdownClickHdl( aLink
);
190 mpBTNGradient
->SetSelectHdl( aLink
);
191 mpBTNGradient
->SetItemImage(nIdGradient
,maImgLinear
);
192 mpBTNGradient
->Hide();
194 mpLbFillType
->SetAccessibleRelationLabeledBy(mpColorTextFT
);
195 mpLbFillAttr
->SetAccessibleRelationLabeledBy(mpLbFillAttr
);
196 mpToolBoxColor
->SetAccessibleRelationLabeledBy(mpToolBoxColor
);
197 mpLBTransType
->SetAccessibleRelationLabeledBy(mpTrspTextFT
);
198 mpMTRTransparent
->SetAccessibleRelationLabeledBy(mpMTRTransparent
);
199 mpBTNGradient
->SetAccessibleRelationLabeledBy(mpBTNGradient
);
206 IMPL_LINK( AreaPropertyPanel
, SelectFillTypeHdl
, ListBox
*, pToolBox
)
208 const XFillStyle eXFS
= (XFillStyle
)mpLbFillType
->GetSelectEntryPos();
210 if((XFillStyle
)meLastXFS
!= eXFS
)
212 mpLbFillAttr
->Clear();
213 SfxObjectShell
* pSh
= SfxObjectShell::Current();
214 const XFillStyleItem
aXFillStyleItem(eXFS
);
216 // #i122676# Do no longer trigger two Execute calls, one for SID_ATTR_FILL_STYLE
217 // and one for setting the fill attribute itself, but add two SfxPoolItems to the
218 // call to get just one action at the SdrObject and to create only one Undo action, too.
219 // Checked that this works in all apps.
224 mpLbFillAttr
->Show();
225 mpToolBoxColor
->Hide();
226 mpLbFillType
->Selected();
227 mpLbFillAttr
->Disable();
229 // #i122676# need to call a single SID_ATTR_FILL_STYLE change
230 GetBindings()->GetDispatcher()->Execute(
231 SID_ATTR_FILL_STYLE
, SFX_CALLMODE_RECORD
, &aXFillStyleItem
, 0L);
236 mpLbFillAttr
->Hide();
237 mpToolBoxColor
->Show();
238 const OUString aTmpStr
;
239 const Color aColor
= maLastColor
;
240 const XFillColorItem
aXFillColorItem( aTmpStr
, aColor
);
242 // #i122676# change FillStyle and Color in one call
243 GetBindings()->GetDispatcher()->Execute(
244 SID_ATTR_FILL_COLOR
, SFX_CALLMODE_RECORD
, &aXFillColorItem
, &aXFillStyleItem
, 0L);
249 mpLbFillAttr
->Show();
250 mpToolBoxColor
->Hide();
252 if(pSh
&& pSh
->GetItem(SID_GRADIENT_LIST
))
254 if(!mpLbFillAttr
->GetEntryCount())
256 const SvxGradientListItem
aItem(*(const SvxGradientListItem
*)(pSh
->GetItem(SID_GRADIENT_LIST
)));
257 mpLbFillAttr
->Enable();
258 mpLbFillAttr
->Clear();
259 mpLbFillAttr
->Fill(aItem
.GetGradientList());
262 mpLbFillAttr
->AdaptDropDownLineCountToMaximum();
264 if(LISTBOX_ENTRY_NOTFOUND
!= mnLastPosGradient
)
266 const SvxGradientListItem
aItem(*(const SvxGradientListItem
*)(pSh
->GetItem(SID_GRADIENT_LIST
)));
268 if(mnLastPosGradient
< aItem
.GetGradientList()->Count())
270 const XGradient aGradient
= aItem
.GetGradientList()->GetGradient(mnLastPosGradient
)->GetGradient();
271 const XFillGradientItem
aXFillGradientItem(mpLbFillAttr
->GetEntry(mnLastPosGradient
), aGradient
);
273 // #i122676# change FillStyle and Gradient in one call
274 GetBindings()->GetDispatcher()->Execute(
275 SID_ATTR_FILL_GRADIENT
, SFX_CALLMODE_RECORD
, &aXFillGradientItem
, &aXFillStyleItem
, 0L);
276 mpLbFillAttr
->SelectEntryPos(mnLastPosGradient
);
282 mpLbFillAttr
->Disable();
288 mpLbFillAttr
->Show();
289 mpToolBoxColor
->Hide();
291 if(pSh
&& pSh
->GetItem(SID_HATCH_LIST
))
293 if(!mpLbFillAttr
->GetEntryCount())
295 const SvxHatchListItem
aItem( *(const SvxHatchListItem
*)(pSh
->GetItem(SID_HATCH_LIST
)));
296 mpLbFillAttr
->Enable();
297 mpLbFillAttr
->Clear();
298 mpLbFillAttr
->Fill(aItem
.GetHatchList());
301 mpLbFillAttr
->AdaptDropDownLineCountToMaximum();
303 if(LISTBOX_ENTRY_NOTFOUND
!= mnLastPosHatch
)
305 const SvxHatchListItem
aItem(*(const SvxHatchListItem
*)(pSh
->GetItem(SID_HATCH_LIST
)));
307 if(mnLastPosHatch
< aItem
.GetHatchList()->Count())
309 const XHatch aHatch
= aItem
.GetHatchList()->GetHatch(mnLastPosHatch
)->GetHatch();
310 const XFillHatchItem
aXFillHatchItem(mpLbFillAttr
->GetSelectEntry(), aHatch
);
312 // #i122676# change FillStyle and Hatch in one call
313 GetBindings()->GetDispatcher()->Execute(
314 SID_ATTR_FILL_HATCH
, SFX_CALLMODE_RECORD
, &aXFillHatchItem
, &aXFillStyleItem
, 0L);
315 mpLbFillAttr
->SelectEntryPos(mnLastPosHatch
);
321 mpLbFillAttr
->Disable();
327 mpLbFillAttr
->Show();
328 mpToolBoxColor
->Hide();
330 if(pSh
&& pSh
->GetItem(SID_BITMAP_LIST
))
332 if(!mpLbFillAttr
->GetEntryCount())
334 const SvxBitmapListItem
aItem( *(const SvxBitmapListItem
*)(pSh
->GetItem(SID_BITMAP_LIST
)));
335 mpLbFillAttr
->Enable();
336 mpLbFillAttr
->Clear();
337 mpLbFillAttr
->Fill(aItem
.GetBitmapList());
340 mpLbFillAttr
->AdaptDropDownLineCountToMaximum();
342 if(LISTBOX_ENTRY_NOTFOUND
!= mnLastPosBitmap
)
344 const SvxBitmapListItem
aItem(*(const SvxBitmapListItem
*)(pSh
->GetItem(SID_BITMAP_LIST
)));
346 if(mnLastPosBitmap
< aItem
.GetBitmapList()->Count())
348 const XBitmapEntry
* pXBitmapEntry
= aItem
.GetBitmapList()->GetBitmap(mnLastPosBitmap
);
349 const XFillBitmapItem
aXFillBitmapItem(mpLbFillAttr
->GetSelectEntry(), pXBitmapEntry
->GetGraphicObject());
351 // #i122676# change FillStyle and Bitmap in one call
352 GetBindings()->GetDispatcher()->Execute(
353 SID_ATTR_FILL_BITMAP
, SFX_CALLMODE_RECORD
, &aXFillBitmapItem
, &aXFillStyleItem
, 0L);
354 mpLbFillAttr
->SelectEntryPos(mnLastPosBitmap
);
360 mpLbFillAttr
->Disable();
366 meLastXFS
= (sal_uInt16
)eXFS
;
368 if(XFILL_NONE
!= eXFS
)
372 mpLbFillType
->Selected();
382 IMPL_LINK( AreaPropertyPanel
, SelectFillAttrHdl
, ListBox
*, pToolBox
)
384 const XFillStyle eXFS
= (XFillStyle
)mpLbFillType
->GetSelectEntryPos();
385 const XFillStyleItem
aXFillStyleItem(eXFS
);
386 SfxObjectShell
* pSh
= SfxObjectShell::Current();
390 // #i122676# dependent from bFillStyleChange, do execute a single or two
391 // changes in one Execute call
392 const bool bFillStyleChange((XFillStyle
) meLastXFS
!= eXFS
);
400 // #i122676# Single FillStyle change call needed here
401 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_STYLE
, SFX_CALLMODE_RECORD
, &aXFillStyleItem
, 0L);
407 sal_Int32 nPos
= mpLbFillAttr
->GetSelectEntryPos();
409 if(LISTBOX_ENTRY_NOTFOUND
== nPos
)
411 nPos
= mnLastPosGradient
;
414 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
&& pSh
&& pSh
->GetItem(SID_GRADIENT_LIST
))
416 const SvxGradientListItem
aItem(*(const SvxGradientListItem
*)(pSh
->GetItem(SID_GRADIENT_LIST
)));
418 if(nPos
< aItem
.GetGradientList()->Count())
420 const XGradient aGradient
= aItem
.GetGradientList()->GetGradient(nPos
)->GetGradient();
421 const XFillGradientItem
aXFillGradientItem(mpLbFillAttr
->GetSelectEntry(), aGradient
);
423 // #i122676# Change FillStale and Gradinet in one call
424 GetBindings()->GetDispatcher()->Execute(
425 SID_ATTR_FILL_GRADIENT
, SFX_CALLMODE_RECORD
, &aXFillGradientItem
,
426 bFillStyleChange
? &aXFillStyleItem
: 0L, 0L);
430 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
432 mnLastPosGradient
= nPos
;
438 sal_Int32 nPos
= mpLbFillAttr
->GetSelectEntryPos();
440 if(LISTBOX_ENTRY_NOTFOUND
== nPos
)
442 nPos
= mnLastPosHatch
;
445 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
&& pSh
&& pSh
->GetItem(SID_HATCH_LIST
))
447 const SvxHatchListItem
aItem(*(const SvxHatchListItem
*)(pSh
->GetItem(SID_HATCH_LIST
)));
449 if(nPos
< aItem
.GetHatchList()->Count())
451 const XHatch aHatch
= aItem
.GetHatchList()->GetHatch(nPos
)->GetHatch();
452 const XFillHatchItem
aXFillHatchItem( mpLbFillAttr
->GetSelectEntry(), aHatch
);
454 // #i122676# Change FillStale and Hatch in one call
455 GetBindings()->GetDispatcher()->Execute(
456 SID_ATTR_FILL_HATCH
, SFX_CALLMODE_RECORD
, &aXFillHatchItem
,
457 bFillStyleChange
? &aXFillStyleItem
: 0L, 0L);
461 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
463 mnLastPosHatch
= nPos
;
469 sal_Int32 nPos
= mpLbFillAttr
->GetSelectEntryPos();
471 if(LISTBOX_ENTRY_NOTFOUND
== nPos
)
473 nPos
= mnLastPosBitmap
;
476 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
&& pSh
&& pSh
->GetItem(SID_BITMAP_LIST
))
478 const SvxBitmapListItem
aItem(*(const SvxBitmapListItem
*)(pSh
->GetItem(SID_BITMAP_LIST
)));
480 if(nPos
< aItem
.GetBitmapList()->Count())
482 const XBitmapEntry
* pXBitmapEntry
= aItem
.GetBitmapList()->GetBitmap(nPos
);
483 const XFillBitmapItem
aXFillBitmapItem(mpLbFillAttr
->GetSelectEntry(), pXBitmapEntry
->GetGraphicObject());
485 // #i122676# Change FillStale and Bitmap in one call
486 GetBindings()->GetDispatcher()->Execute(
487 SID_ATTR_FILL_BITMAP
, SFX_CALLMODE_RECORD
, &aXFillBitmapItem
,
488 bFillStyleChange
? &aXFillStyleItem
: 0L, 0L);
492 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
494 mnLastPosBitmap
= nPos
;
506 IMPL_LINK(AreaPropertyPanel
, ToolBoxColorDropHdl
, ToolBox
*, pToolBox
)
508 const OUString
aCommand(pToolBox
->GetItemCommand(pToolBox
->GetCurItemId()));
510 if(UNO_SIDEBARCOLOR
== aCommand
)
512 maColorPopup
.Show(*pToolBox
);
516 maColorPopup
.SetCurrentColor(mpColorItem
->GetColorValue(), mbColorAvail
);
520 maColorPopup
.SetCurrentColor(COL_WHITE
, false);
529 void AreaPropertyPanel::SetColor (
530 const OUString
& rsColorName
,
533 const XFillColorItem
aXFillColorItem(rsColorName
, aColor
);
534 mpBindings
->GetDispatcher()->Execute(SID_ATTR_FILL_COLOR
, SFX_CALLMODE_RECORD
, &aXFillColorItem
, 0L);
535 maLastColor
= aColor
;
541 PopupControl
* AreaPropertyPanel::CreateTransparencyGradientControl (PopupContainer
* pParent
)
543 return new AreaTransparencyGradientControl(pParent
, *this);
549 PopupControl
* AreaPropertyPanel::CreateColorPopupControl (PopupContainer
* pParent
)
551 return new ColorControl(
554 SVX_RES(RID_POPUPPANEL_AERAPAGE_COLOR
),
556 ::boost::bind(&AreaPropertyPanel::GetLastColor
, this),
557 ::boost::bind(&AreaPropertyPanel::SetColor
, this, _1
,_2
),
565 void AreaPropertyPanel::SetupIcons(void)
567 if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons
))
579 AreaPropertyPanel
* AreaPropertyPanel::Create (
581 const cssu::Reference
<css::frame::XFrame
>& rxFrame
,
582 SfxBindings
* pBindings
)
585 throw lang::IllegalArgumentException("no parent Window given to AreaPropertyPanel::Create", NULL
, 0);
587 throw lang::IllegalArgumentException("no XFrame given to AreaPropertyPanel::Create", NULL
, 1);
588 if (pBindings
== NULL
)
589 throw lang::IllegalArgumentException("no SfxBindings given to AreaPropertyPanel::Create", NULL
, 2);
591 return new AreaPropertyPanel(
599 void AreaPropertyPanel::DataChanged(
600 const DataChangedEvent
& rEvent
)
609 void AreaPropertyPanel::ImpUpdateTransparencies()
611 if(mpTransparanceItem
.get() && mpFloatTransparenceItem
.get())
613 bool bZeroValue(false);
615 if(mpTransparanceItem
.get())
617 const sal_uInt16
nValue(mpTransparanceItem
->GetValue());
623 else if(nValue
<= 100)
625 mpLBTransType
->Enable();
626 mpTrspTextFT
->Enable();
627 mpLBTransType
->SelectEntryPos(1);
628 mpBTNGradient
->Hide();
629 mpMTRTransparent
->Show();
630 mpMTRTransparent
->Enable();
631 mpMTRTransparent
->SetValue(nValue
);
640 if(bZeroValue
&& mpFloatTransparenceItem
.get())
642 if(mpFloatTransparenceItem
->IsEnabled())
644 const XGradient
& rGradient
= mpFloatTransparenceItem
->GetGradientValue();
645 sal_Int32
nEntryPos(0);
648 mpLBTransType
->Enable();
649 mpTrspTextFT
->Enable();
650 mpMTRTransparent
->Hide();
651 mpBTNGradient
->Enable();
652 mpBTNGradient
->Show();
654 switch(rGradient
.GetGradientStyle())
659 pImage
= &maImgLinear
;
665 pImage
= &maImgAxial
;
671 pImage
= &maImgRadial
;
674 case XGRAD_ELLIPTICAL
:
689 pImage
= &maImgSquare
;
694 const sal_uInt16 nIdGradient
= mpBTNGradient
->GetItemId(UNO_SIDEBARGRADIENT
);
695 mpLBTransType
->SelectEntryPos(nEntryPos
);
696 mpBTNGradient
->SetItemImage(nIdGradient
, *pImage
);
707 mpLBTransType
->Enable();
708 mpTrspTextFT
->Enable();
709 mpLBTransType
->SelectEntryPos(0);
710 mpBTNGradient
->Hide();
711 mpMTRTransparent
->Enable();
712 mpMTRTransparent
->Show();
713 mpMTRTransparent
->SetValue(0);
718 // no transparency at all
719 mpLBTransType
->SetNoSelection();
720 mpLBTransType
->Disable();
721 mpTrspTextFT
->Disable();
722 mpMTRTransparent
->Disable();
723 mpMTRTransparent
->Show();
724 mpBTNGradient
->Disable();
725 mpBTNGradient
->Hide();
731 void AreaPropertyPanel::NotifyItemUpdate(
734 const SfxPoolItem
* pState
,
735 const bool bIsEnabled
)
738 const bool bDisabled(SFX_ITEM_DISABLED
== eState
);
742 case SID_ATTR_FILL_TRANSPARENCE
:
743 case SID_ATTR_FILL_FLOATTRANSPARENCE
:
745 bool bFillTransparenceChanged(false);
747 if(SID_ATTR_FILL_TRANSPARENCE
== nSID
)
749 bFillTransparenceChanged
= true;
751 if(eState
>= SFX_ITEM_AVAILABLE
)
753 const SfxUInt16Item
* pItem
= dynamic_cast< const SfxUInt16Item
* >(pState
);
755 if(pItem
&& (!mpTransparanceItem
|| *pItem
!= *mpTransparanceItem
))
757 mpTransparanceItem
.reset((SfxUInt16Item
*)pItem
->Clone());
761 mpTransparanceItem
.reset();
766 mpTransparanceItem
.reset();
769 else // if(SID_ATTR_FILL_FLOATTRANSPARENCE == nSID)
771 bFillTransparenceChanged
= true;
773 if(eState
>= SFX_ITEM_AVAILABLE
)
775 const XFillFloatTransparenceItem
* pItem
= dynamic_cast< const XFillFloatTransparenceItem
* >(pState
);
777 if(pItem
&& (!mpFloatTransparenceItem
|| *pItem
!= *mpFloatTransparenceItem
))
779 mpFloatTransparenceItem
.reset((XFillFloatTransparenceItem
*)pItem
->Clone());
783 mpFloatTransparenceItem
.reset();
788 mpFloatTransparenceItem
.reset();
792 if(bFillTransparenceChanged
)
794 // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem
795 ImpUpdateTransparencies();
799 case SID_ATTR_FILL_STYLE
:
803 mpLbFillType
->Disable();
804 mpColorTextFT
->Disable();
805 mpLbFillType
->SetNoSelection();
806 mpLbFillAttr
->Show();
807 mpLbFillAttr
->Disable();
808 mpLbFillAttr
->SetNoSelection();
809 mpToolBoxColor
->Hide();
814 if(eState
>= SFX_ITEM_AVAILABLE
)
816 const XFillStyleItem
* pItem
= dynamic_cast< const XFillStyleItem
* >(pState
);
820 mpStyleItem
.reset(dynamic_cast< XFillStyleItem
* >(pItem
->Clone()));
821 mpLbFillType
->Enable();
822 mpColorTextFT
->Enable();
823 XFillStyle eXFS
= (XFillStyle
)mpStyleItem
->GetValue();
825 mpLbFillType
->SelectEntryPos(sal::static_int_cast
< sal_Int32
>(eXFS
));
827 if(XFILL_NONE
== eXFS
)
829 mpLbFillAttr
->SetNoSelection();
830 mpLbFillAttr
->Disable();
838 mpLbFillType
->SetNoSelection();
839 mpLbFillAttr
->Show();
840 mpLbFillAttr
->Disable();
841 mpLbFillAttr
->SetNoSelection();
842 mpToolBoxColor
->Hide();
847 case SID_ATTR_FILL_COLOR
:
849 if(SFX_ITEM_AVAILABLE
== eState
)
851 mpColorItem
.reset(pState
? (XFillColorItem
*)pState
->Clone() : 0);
854 if(mpStyleItem
&& XFILL_SOLID
== (XFillStyle
)mpStyleItem
->GetValue())
856 mpLbFillAttr
->Hide();
857 mpToolBoxColor
->Show();
859 if(SFX_ITEM_AVAILABLE
== eState
)
861 mpToolBoxColor
->Enable();
863 // maLastColor = mpColorItem->GetColorValue();
866 else if(SFX_ITEM_DISABLED
== eState
)
868 mpToolBoxColor
->Disable();
869 mbColorAvail
= false;
870 mpColorUpdater
->Update(COL_WHITE
);
874 mbColorAvail
= false;
875 mpColorUpdater
->Update(COL_WHITE
);
880 case SID_ATTR_FILL_GRADIENT
:
882 if(SFX_ITEM_AVAILABLE
== eState
)
884 mpFillGradientItem
.reset(pState
? (XFillGradientItem
*)pState
->Clone() : 0);
887 if(mpStyleItem
&& XFILL_GRADIENT
== (XFillStyle
)mpStyleItem
->GetValue())
889 mpLbFillAttr
->Show();
890 mpToolBoxColor
->Hide();
892 if(SFX_ITEM_AVAILABLE
== eState
)
894 mpLbFillAttr
->Enable();
897 else if(SFX_ITEM_DISABLED
== eState
)
899 mpLbFillAttr
->Disable();
900 mpLbFillAttr
->SetNoSelection();
904 mpLbFillAttr
->SetNoSelection();
909 case SID_ATTR_FILL_HATCH
:
911 if(SFX_ITEM_AVAILABLE
== eState
)
913 mpHatchItem
.reset(pState
? (XFillHatchItem
*)pState
->Clone() : 0);
916 if(mpStyleItem
&& XFILL_HATCH
== (XFillStyle
)mpStyleItem
->GetValue())
918 mpLbFillAttr
->Show();
919 mpToolBoxColor
->Hide();
921 if(SFX_ITEM_AVAILABLE
== eState
)
923 mpLbFillAttr
->Enable();
926 else if(SFX_ITEM_DISABLED
== eState
)
928 mpLbFillAttr
->Disable();
929 mpLbFillAttr
->SetNoSelection();
933 mpLbFillAttr
->SetNoSelection();
938 case SID_ATTR_FILL_BITMAP
:
940 if(SFX_ITEM_AVAILABLE
== eState
)
942 mpBitmapItem
.reset(pState
? (XFillBitmapItem
*)pState
->Clone() : 0);
945 if(mpStyleItem
&& XFILL_BITMAP
== (XFillStyle
)mpStyleItem
->GetValue())
947 mpLbFillAttr
->Show();
948 mpToolBoxColor
->Hide();
950 if(SFX_ITEM_AVAILABLE
== eState
)
952 mpLbFillAttr
->Enable();
955 else if(SFX_ITEM_DISABLED
== eState
)
957 mpLbFillAttr
->Disable();
958 mpLbFillAttr
->SetNoSelection();
962 mpLbFillAttr
->SetNoSelection();
967 case SID_COLOR_TABLE
:
969 if(SFX_ITEM_AVAILABLE
== eState
)
971 if(mpStyleItem
&& XFILL_SOLID
== (XFillStyle
)mpStyleItem
->GetValue())
975 const Color aColor
= mpColorItem
->GetColorValue();
976 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
977 const SvxColorListItem
aItem(*(const SvxColorListItem
*)(pSh
->GetItem(SID_COLOR_TABLE
)));
979 mpLbFillAttr
->Clear();
980 mpLbFillAttr
->Enable();
981 mpLbFillAttr
->Fill(aItem
.GetColorList());
982 mpLbFillAttr
->SelectEntry(aColor
);
986 mpLbFillAttr
->SetNoSelection();
992 case SID_GRADIENT_LIST
:
994 if(SFX_ITEM_AVAILABLE
== eState
)
996 if(mpStyleItem
&& XFILL_GRADIENT
== (XFillStyle
)mpStyleItem
->GetValue())
998 if(mpFillGradientItem
)
1000 const OUString
aString( mpFillGradientItem
->GetName() );
1001 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
1002 const SvxGradientListItem
aItem( *(const SvxGradientListItem
*)(pSh
->GetItem(SID_GRADIENT_LIST
)));
1004 mpLbFillAttr
->Clear();
1005 mpLbFillAttr
->Enable();
1006 mpLbFillAttr
->Fill(aItem
.GetGradientList());
1007 mpLbFillAttr
->SelectEntry(aString
);
1011 mpLbFillAttr
->SetNoSelection();
1017 case SID_HATCH_LIST
:
1019 if(SFX_ITEM_AVAILABLE
== eState
)
1021 if(mpStyleItem
&& XFILL_HATCH
== (XFillStyle
)mpStyleItem
->GetValue())
1025 const OUString
aString( mpHatchItem
->GetName() );
1026 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
1027 const SvxHatchListItem
aItem(*(const SvxHatchListItem
*)(pSh
->GetItem(SID_HATCH_LIST
)));
1029 mpLbFillAttr
->Clear();
1030 mpLbFillAttr
->Enable();
1031 mpLbFillAttr
->Fill(aItem
.GetHatchList());
1032 mpLbFillAttr
->SelectEntry(aString
);
1036 mpLbFillAttr
->SetNoSelection();
1042 case SID_BITMAP_LIST
:
1044 if(SFX_ITEM_AVAILABLE
== eState
)
1046 if(mpStyleItem
&& XFILL_BITMAP
== (XFillStyle
)mpStyleItem
->GetValue())
1050 const OUString
aString( mpBitmapItem
->GetName() );
1051 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
1052 const SvxBitmapListItem
aItem(*(const SvxBitmapListItem
*)(pSh
->GetItem(SID_BITMAP_LIST
)));
1054 mpLbFillAttr
->Clear();
1055 mpLbFillAttr
->Enable();
1056 mpLbFillAttr
->Fill(aItem
.GetBitmapList());
1057 mpLbFillAttr
->SelectEntry(aString
);
1061 mpLbFillAttr
->SetNoSelection();
1072 SfxBindings
* AreaPropertyPanel::GetBindings()
1079 void AreaPropertyPanel::Update()
1083 const XFillStyle eXFS
= (XFillStyle
)mpStyleItem
->GetValue();
1084 SfxObjectShell
* pSh
= SfxObjectShell::Current();
1090 mpLbFillAttr
->Show();
1091 mpToolBoxColor
->Hide();
1098 mpLbFillAttr
->Hide();
1099 mpToolBoxColor
->Show();
1100 mpColorUpdater
->Update(mpColorItem
->GetColorValue());
1104 mpColorUpdater
->Update(COL_WHITE
);
1108 case XFILL_GRADIENT
:
1110 mpLbFillAttr
->Show();
1111 mpToolBoxColor
->Hide();
1113 if(pSh
&& pSh
->GetItem(SID_GRADIENT_LIST
))
1115 const SvxGradientListItem
aItem(*(const SvxGradientListItem
*)(pSh
->GetItem(SID_GRADIENT_LIST
)));
1116 mpLbFillAttr
->Enable();
1117 mpLbFillAttr
->Clear();
1118 mpLbFillAttr
->Fill(aItem
.GetGradientList());
1120 if(mpFillGradientItem
)
1122 const OUString
aString(mpFillGradientItem
->GetName());
1124 mpLbFillAttr
->SelectEntry(aString
);
1128 mpLbFillAttr
->SetNoSelection();
1133 mpLbFillAttr
->SetNoSelection();
1139 mpLbFillAttr
->Show();
1140 mpToolBoxColor
->Hide();
1142 if(pSh
&& pSh
->GetItem(SID_HATCH_LIST
))
1144 const SvxHatchListItem
aItem(*(const SvxHatchListItem
*)(pSh
->GetItem(SID_HATCH_LIST
)));
1145 mpLbFillAttr
->Enable();
1146 mpLbFillAttr
->Clear();
1147 mpLbFillAttr
->Fill(aItem
.GetHatchList());
1151 const OUString
aString(mpHatchItem
->GetName());
1153 mpLbFillAttr
->SelectEntry( aString
);
1157 mpLbFillAttr
->SetNoSelection();
1162 mpLbFillAttr
->SetNoSelection();
1168 mpLbFillAttr
->Show();
1169 mpToolBoxColor
->Hide();
1171 if(pSh
&& pSh
->GetItem(SID_BITMAP_LIST
))
1173 const SvxBitmapListItem
aItem(*(const SvxBitmapListItem
*)(pSh
->GetItem(SID_BITMAP_LIST
)));
1174 mpLbFillAttr
->Enable();
1175 mpLbFillAttr
->Clear();
1176 mpLbFillAttr
->Fill(aItem
.GetBitmapList());
1180 const OUString
aString(mpBitmapItem
->GetName());
1182 mpLbFillAttr
->SelectEntry(aString
);
1186 mpLbFillAttr
->SetNoSelection();
1191 mpLbFillAttr
->SetNoSelection();
1196 OSL_ENSURE(false, "Non supported FillType (!)");
1204 IMPL_LINK( AreaPropertyPanel
, ClickTrGrHdl_Impl
, ToolBox
*, pToolBox
)
1206 maTrGrPopup
.Rearrange(mpFloatTransparenceItem
.get());
1207 OSL_ASSERT( pToolBox
->GetItemCommand(pToolBox
->GetCurItemId()) == UNO_SIDEBARGRADIENT
);
1208 maTrGrPopup
.Show(*pToolBox
);
1215 IMPL_LINK(AreaPropertyPanel
, ChangeTrgrTypeHdl_Impl
, void *, EMPTYARG
)
1217 sal_Int32 nSelectType
= mpLBTransType
->GetSelectEntryPos();
1218 bool bGradient
= false;
1219 sal_uInt16 nTrans
= 0;
1223 mpBTNGradient
->Hide();
1224 mpMTRTransparent
->Show();
1225 mpMTRTransparent
->Enable();
1226 mpMTRTransparent
->SetValue(0);
1228 else if(1 == nSelectType
)
1230 mpBTNGradient
->Hide();
1231 mpMTRTransparent
->Show();
1232 nTrans
= mnLastTransSolid
;
1233 mpMTRTransparent
->SetValue(nTrans
);
1234 mpLBTransType
->SelectEntryPos(1);
1235 mpMTRTransparent
->Enable();
1239 mpBTNGradient
->Show();
1241 const sal_uInt16 nIdGradient
= mpBTNGradient
->GetItemId(UNO_SIDEBARGRADIENT
);
1242 switch (nSelectType
)
1245 mpBTNGradient
->SetItemImage(nIdGradient
, maImgLinear
);
1248 mpBTNGradient
->SetItemImage(nIdGradient
, maImgAxial
);
1251 mpBTNGradient
->SetItemImage(nIdGradient
, maImgRadial
);
1254 mpBTNGradient
->SetItemImage(nIdGradient
, maImgElli
);
1257 mpBTNGradient
->SetItemImage(nIdGradient
, maImgQuad
);
1260 mpBTNGradient
->SetItemImage(nIdGradient
, maImgSquare
);
1264 mpMTRTransparent
->Hide();
1265 mpBTNGradient
->Enable();
1269 const XFillTransparenceItem
aLinearItem(nTrans
);
1270 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE
, SFX_CALLMODE_RECORD
, &aLinearItem
, 0L );
1277 XGradient aTmpGradient
;
1282 aTmpGradient
= maGradientLinear
;
1285 aTmpGradient
= maGradientAxial
;
1288 aTmpGradient
= maGradientRadial
;
1290 case XGRAD_ELLIPTICAL
:
1291 aTmpGradient
= maGradientElliptical
;
1294 aTmpGradient
= maGradientSquare
;
1297 aTmpGradient
= maGradientRect
;
1301 SfxItemPool
* pPool
= 0;
1302 const XFillFloatTransparenceItem
aGradientItem(pPool
, aTmpGradient
, bGradient
);
1303 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_FLOATTRANSPARENCE
, SFX_CALLMODE_RECORD
, &aGradientItem
, 0L );
1310 IMPL_LINK(AreaPropertyPanel
, ModifyTransparentHdl_Impl
, void*, EMPTYARG
)
1312 const sal_uInt16 nTrans
= (sal_uInt16
)mpMTRTransparent
->GetValue();
1313 mnLastTransSolid
= nTrans
;
1314 const sal_Int32 nSelectType
= mpLBTransType
->GetSelectEntryPos();
1316 if(nTrans
&& !nSelectType
)
1318 mpLBTransType
->SelectEntryPos(1);
1321 const XFillTransparenceItem
aLinearItem(nTrans
);
1322 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE
, SFX_CALLMODE_RECORD
, &aLinearItem
, 0L );
1328 Color
AreaPropertyPanel::GetLastColor (void) const
1336 XGradient
AreaPropertyPanel::GetGradient (const XGradientStyle eStyle
) const
1342 return maGradientLinear
;
1344 return maGradientAxial
;
1346 return maGradientRadial
;
1347 case XGRAD_ELLIPTICAL
:
1348 return maGradientElliptical
;
1350 return maGradientSquare
;
1352 return maGradientRect
;
1359 void AreaPropertyPanel::SetGradient (const XGradient
& rGradient
)
1361 switch (rGradient
.GetGradientStyle())
1364 maGradientLinear
= rGradient
;
1367 maGradientAxial
= rGradient
;
1370 maGradientRadial
= rGradient
;
1372 case XGRAD_ELLIPTICAL
:
1373 maGradientElliptical
= rGradient
;
1376 maGradientSquare
= rGradient
;
1379 maGradientRect
= rGradient
;
1387 sal_Int32
AreaPropertyPanel::GetSelectedTransparencyTypeIndex (void) const
1389 return mpLBTransType
->GetSelectEntryPos();
1392 } } // end of namespace svx::sidebar
1394 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */