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>
42 #include <boost/bind.hpp>
45 using namespace css::uno
;
46 using ::sfx2::sidebar::Theme
;
48 const char UNO_SIDEBARGRADIENT
[] = ".uno:sidebargradient";
50 namespace svx
{ namespace sidebar
{
52 const sal_Int32
AreaPropertyPanel::DEFAULT_CENTERX
= 50;
53 const sal_Int32
AreaPropertyPanel::DEFAULT_CENTERY
= 50;
54 const sal_Int32
AreaPropertyPanel::DEFAULT_ANGLE
= 0;
55 const sal_Int32
AreaPropertyPanel::DEFAULT_STARTVALUE
= 0;
56 const sal_Int32
AreaPropertyPanel::DEFAULT_ENDVALUE
= 16777215;
57 const sal_Int32
AreaPropertyPanel::DEFAULT_BORDER
= 0;
60 AreaPropertyPanel::AreaPropertyPanel(
62 const css::uno::Reference
<css::frame::XFrame
>& rxFrame
,
63 SfxBindings
* pBindings
)
64 : PanelLayout(pParent
, "AreaPropertyPanel", "svx/ui/sidebararea.ui", rxFrame
),
65 meLastXFS(static_cast<sal_uInt16
>(-1)),
73 maGradientElliptical(),
81 maStyleControl(SID_ATTR_FILL_STYLE
, *pBindings
, *this),
82 maColorControl(SID_ATTR_FILL_COLOR
, *pBindings
, *this),
83 maGradientControl(SID_ATTR_FILL_GRADIENT
, *pBindings
, *this),
84 maHatchControl(SID_ATTR_FILL_HATCH
, *pBindings
, *this),
85 maBitmapControl(SID_ATTR_FILL_BITMAP
, *pBindings
, *this),
86 maGradientListControl(SID_GRADIENT_LIST
, *pBindings
, *this),
87 maHatchListControl(SID_HATCH_LIST
, *pBindings
, *this),
88 maBitmapListControl(SID_BITMAP_LIST
, *pBindings
, *this),
89 maFillTransparenceController(SID_ATTR_FILL_TRANSPARENCE
, *pBindings
, *this),
90 maFillFloatTransparenceController(SID_ATTR_FILL_FLOATTRANSPARENCE
, *pBindings
, *this),
91 maImgAxial(SVX_RES(IMG_AXIAL
)),
92 maImgElli(SVX_RES(IMG_ELLI
)),
93 maImgQuad(SVX_RES(IMG_QUAD
)),
94 maImgRadial(SVX_RES(IMG_RADIAL
)),
95 maImgSquare(SVX_RES(IMG_SQUARE
)),
96 maImgLinear(SVX_RES(IMG_LINEAR
)),
97 maTrGrPopup(this, ::boost::bind(&AreaPropertyPanel::CreateTransparencyGradientControl
, this, _1
)),
98 mpFloatTransparenceItem(),
101 mpBindings(pBindings
)
103 get(mpColorTextFT
, "filllabel");
104 get(mpLbFillType
, "fillstyle");
105 get(mpLbFillAttr
, "fillattr");
106 get(mpTrspTextFT
, "transparencylabel");
107 get(mpToolBoxColor
, "selectcolor");
108 get(mpLBTransType
, "transtype");
109 get(mpMTRTransparent
, "settransparency");
110 get(mpBTNGradient
, "selectgradient");
116 AreaPropertyPanel::~AreaPropertyPanel()
121 void AreaPropertyPanel::dispose()
123 mpColorTextFT
.clear();
124 mpLbFillType
.clear();
125 mpLbFillAttr
.clear();
126 mpToolBoxColor
.clear();
127 mpTrspTextFT
.clear();
128 mpLBTransType
.clear();
129 mpMTRTransparent
.clear();
130 mpBTNGradient
.clear();
132 maStyleControl
.dispose();
133 maColorControl
.dispose();
134 maGradientControl
.dispose();
135 maHatchControl
.dispose();
136 maBitmapControl
.dispose();
137 maGradientListControl
.dispose();
138 maHatchListControl
.dispose();
139 maBitmapListControl
.dispose();
140 maFillTransparenceController
.dispose();
141 maFillFloatTransparenceController
.dispose();
143 PanelLayout::dispose();
146 void AreaPropertyPanel::Initialize()
148 maGradientLinear
.SetXOffset(DEFAULT_CENTERX
);
149 maGradientLinear
.SetYOffset(DEFAULT_CENTERY
);
150 maGradientLinear
.SetAngle(DEFAULT_ANGLE
);
151 maGradientLinear
.SetStartColor(Color(DEFAULT_STARTVALUE
));
152 maGradientLinear
.SetEndColor(Color(DEFAULT_ENDVALUE
));
153 maGradientLinear
.SetBorder(DEFAULT_BORDER
);
154 maGradientLinear
.SetGradientStyle(css::awt::GradientStyle_LINEAR
);
156 maGradientAxial
= maGradientLinear
;
157 maGradientAxial
.SetGradientStyle(css::awt::GradientStyle_AXIAL
);
159 maGradientRadial
= maGradientLinear
;
160 maGradientRadial
.SetGradientStyle(css::awt::GradientStyle_RADIAL
);
162 maGradientElliptical
= maGradientLinear
;
163 maGradientElliptical
.SetGradientStyle(css::awt::GradientStyle_ELLIPTICAL
);
165 maGradientSquare
= maGradientLinear
;
166 maGradientSquare
.SetGradientStyle(css::awt::GradientStyle_SQUARE
);
168 maGradientRect
= maGradientLinear
;
169 maGradientRect
.SetGradientStyle(css::awt::GradientStyle_RECT
);
171 mpLbFillType
->SetAccessibleName(OUString( "Fill")); //wj acc
172 mpLbFillAttr
->SetAccessibleName(OUString( "Fill")); //wj acc
174 Link
<> aLink
= LINK( this, AreaPropertyPanel
, SelectFillTypeHdl
);
175 mpLbFillType
->SetSelectHdl( aLink
);
177 aLink
= LINK( this, AreaPropertyPanel
, SelectFillAttrHdl
);
178 mpLbFillAttr
->SetSelectHdl( aLink
);
180 mpLBTransType
->SetSelectHdl(LINK(this, AreaPropertyPanel
, ChangeTrgrTypeHdl_Impl
));
181 mpLBTransType
->SetAccessibleName(OUString( "Transparency")); //wj acc
183 mpMTRTransparent
->SetValue( 50 );
184 mpMTRTransparent
->SetModifyHdl(LINK(this, AreaPropertyPanel
, ModifyTransparentHdl_Impl
));
185 mpMTRTransparent
->SetAccessibleName(OUString( "Transparency")); //wj acc
187 const sal_uInt16 nIdGradient
= mpBTNGradient
->GetItemId(UNO_SIDEBARGRADIENT
);
188 mpBTNGradient
->SetItemBits( nIdGradient
, mpBTNGradient
->GetItemBits( nIdGradient
) | ToolBoxItemBits::DROPDOWNONLY
);
189 Link
<ToolBox
*, void> aLink2
= LINK( this, AreaPropertyPanel
, ClickTrGrHdl_Impl
);
190 mpBTNGradient
->SetDropdownClickHdl( aLink2
);
191 mpBTNGradient
->SetSelectHdl( aLink2
);
192 mpBTNGradient
->SetItemImage(nIdGradient
,maImgLinear
);
193 mpBTNGradient
->Hide();
195 mpLbFillType
->SetAccessibleRelationLabeledBy(mpColorTextFT
);
196 mpLbFillAttr
->SetAccessibleRelationLabeledBy(mpLbFillAttr
);
197 mpToolBoxColor
->SetAccessibleRelationLabeledBy(mpToolBoxColor
);
198 mpLBTransType
->SetAccessibleRelationLabeledBy(mpTrspTextFT
);
199 mpMTRTransparent
->SetAccessibleRelationLabeledBy(mpMTRTransparent
);
200 mpBTNGradient
->SetAccessibleRelationLabeledBy(mpBTNGradient
);
205 IMPL_LINK(AreaPropertyPanel
, SelectFillTypeHdl
, ListBox
*, pToolBox
)
207 const drawing::FillStyle eXFS
= (drawing::FillStyle
)mpLbFillType
->GetSelectEntryPos();
209 if((drawing::FillStyle
)meLastXFS
!= eXFS
)
211 mpLbFillAttr
->Clear();
212 SfxObjectShell
* pSh
= SfxObjectShell::Current();
213 const XFillStyleItem
aXFillStyleItem(eXFS
);
215 // #i122676# Do no longer trigger two Execute calls, one for SID_ATTR_FILL_STYLE
216 // and one for setting the fill attribute itself, but add two SfxPoolItems to the
217 // call to get just one action at the SdrObject and to create only one Undo action, too.
218 // Checked that this works in all apps.
222 case drawing::FillStyle_NONE
:
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
, SfxCallMode::RECORD
, &aXFillStyleItem
, 0L);
234 case drawing::FillStyle_SOLID
:
236 mpLbFillAttr
->Hide();
237 mpToolBoxColor
->Show();
238 const OUString aTmpStr
;
239 const Color aColor
= mpColorItem
->GetColorValue();
240 const XFillColorItem
aXFillColorItem( aTmpStr
, aColor
);
242 // #i122676# change FillStyle and Color in one call
243 GetBindings()->GetDispatcher()->Execute(
244 SID_ATTR_FILL_COLOR
, SfxCallMode::RECORD
, &aXFillColorItem
, &aXFillStyleItem
, 0L);
247 case drawing::FillStyle_GRADIENT
:
249 mpLbFillAttr
->Show();
250 mpToolBoxColor
->Hide();
252 if(pSh
&& pSh
->GetItem(SID_GRADIENT_LIST
))
254 if(!mpLbFillAttr
->GetEntryCount())
256 const SvxGradientListItem
aItem(*static_cast<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(*static_cast<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
, SfxCallMode::RECORD
, &aXFillGradientItem
, &aXFillStyleItem
, 0L);
276 mpLbFillAttr
->SelectEntryPos(mnLastPosGradient
);
282 mpLbFillAttr
->Disable();
286 case drawing::FillStyle_HATCH
:
288 mpLbFillAttr
->Show();
289 mpToolBoxColor
->Hide();
291 if(pSh
&& pSh
->GetItem(SID_HATCH_LIST
))
293 if(!mpLbFillAttr
->GetEntryCount())
295 const SvxHatchListItem
aItem( *static_cast<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(*static_cast<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
, SfxCallMode::RECORD
, &aXFillHatchItem
, &aXFillStyleItem
, 0L);
315 mpLbFillAttr
->SelectEntryPos(mnLastPosHatch
);
321 mpLbFillAttr
->Disable();
325 case drawing::FillStyle_BITMAP
:
327 mpLbFillAttr
->Show();
328 mpToolBoxColor
->Hide();
330 if(pSh
&& pSh
->GetItem(SID_BITMAP_LIST
))
332 if(!mpLbFillAttr
->GetEntryCount())
334 const SvxBitmapListItem
aItem( *static_cast<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(*static_cast<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
, SfxCallMode::RECORD
, &aXFillBitmapItem
, &aXFillStyleItem
, 0L);
354 mpLbFillAttr
->SelectEntryPos(mnLastPosBitmap
);
360 mpLbFillAttr
->Disable();
366 meLastXFS
= (sal_uInt16
)eXFS
;
368 if(drawing::FillStyle_NONE
!= eXFS
)
372 mpLbFillType
->Selected();
380 IMPL_LINK(AreaPropertyPanel
, SelectFillAttrHdl
, ListBox
*, pToolBox
)
382 const drawing::FillStyle eXFS
= (drawing::FillStyle
)mpLbFillType
->GetSelectEntryPos();
383 const XFillStyleItem
aXFillStyleItem(eXFS
);
384 SfxObjectShell
* pSh
= SfxObjectShell::Current();
388 // #i122676# dependent from bFillStyleChange, do execute a single or two
389 // changes in one Execute call
390 const bool bFillStyleChange((drawing::FillStyle
) meLastXFS
!= eXFS
);
394 case drawing::FillStyle_SOLID
:
398 // #i122676# Single FillStyle change call needed here
399 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_STYLE
, SfxCallMode::RECORD
, &aXFillStyleItem
, 0L);
403 case drawing::FillStyle_GRADIENT
:
405 sal_Int32 nPos
= mpLbFillAttr
->GetSelectEntryPos();
407 if(LISTBOX_ENTRY_NOTFOUND
== nPos
)
409 nPos
= mnLastPosGradient
;
412 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
&& pSh
&& pSh
->GetItem(SID_GRADIENT_LIST
))
414 const SvxGradientListItem
aItem(*static_cast<const SvxGradientListItem
*>(pSh
->GetItem(SID_GRADIENT_LIST
)));
416 if(nPos
< aItem
.GetGradientList()->Count())
418 const XGradient aGradient
= aItem
.GetGradientList()->GetGradient(nPos
)->GetGradient();
419 const XFillGradientItem
aXFillGradientItem(mpLbFillAttr
->GetSelectEntry(), aGradient
);
421 // #i122676# Change FillStale and Gradinet in one call
422 GetBindings()->GetDispatcher()->Execute(
423 SID_ATTR_FILL_GRADIENT
, SfxCallMode::RECORD
, &aXFillGradientItem
,
424 bFillStyleChange
? &aXFillStyleItem
: 0L, 0L);
428 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
430 mnLastPosGradient
= nPos
;
434 case drawing::FillStyle_HATCH
:
436 sal_Int32 nPos
= mpLbFillAttr
->GetSelectEntryPos();
438 if(LISTBOX_ENTRY_NOTFOUND
== nPos
)
440 nPos
= mnLastPosHatch
;
443 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
&& pSh
&& pSh
->GetItem(SID_HATCH_LIST
))
445 const SvxHatchListItem
aItem(*static_cast<const SvxHatchListItem
*>(pSh
->GetItem(SID_HATCH_LIST
)));
447 if(nPos
< aItem
.GetHatchList()->Count())
449 const XHatch aHatch
= aItem
.GetHatchList()->GetHatch(nPos
)->GetHatch();
450 const XFillHatchItem
aXFillHatchItem( mpLbFillAttr
->GetSelectEntry(), aHatch
);
452 // #i122676# Change FillStale and Hatch in one call
453 GetBindings()->GetDispatcher()->Execute(
454 SID_ATTR_FILL_HATCH
, SfxCallMode::RECORD
, &aXFillHatchItem
,
455 bFillStyleChange
? &aXFillStyleItem
: 0L, 0L);
459 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
461 mnLastPosHatch
= nPos
;
465 case drawing::FillStyle_BITMAP
:
467 sal_Int32 nPos
= mpLbFillAttr
->GetSelectEntryPos();
469 if(LISTBOX_ENTRY_NOTFOUND
== nPos
)
471 nPos
= mnLastPosBitmap
;
474 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
&& pSh
&& pSh
->GetItem(SID_BITMAP_LIST
))
476 const SvxBitmapListItem
aItem(*static_cast<const SvxBitmapListItem
*>(pSh
->GetItem(SID_BITMAP_LIST
)));
478 if(nPos
< aItem
.GetBitmapList()->Count())
480 const XBitmapEntry
* pXBitmapEntry
= aItem
.GetBitmapList()->GetBitmap(nPos
);
481 const XFillBitmapItem
aXFillBitmapItem(mpLbFillAttr
->GetSelectEntry(), pXBitmapEntry
->GetGraphicObject());
483 // #i122676# Change FillStale and Bitmap in one call
484 GetBindings()->GetDispatcher()->Execute(
485 SID_ATTR_FILL_BITMAP
, SfxCallMode::RECORD
, &aXFillBitmapItem
,
486 bFillStyleChange
? &aXFillStyleItem
: 0L, 0L);
490 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
492 mnLastPosBitmap
= nPos
;
504 VclPtr
<PopupControl
> AreaPropertyPanel::CreateTransparencyGradientControl (PopupContainer
* pParent
)
506 return VclPtrInstance
<AreaTransparencyGradientControl
>(pParent
, *this);
512 void AreaPropertyPanel::SetupIcons()
514 if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons
))
526 VclPtr
<vcl::Window
> AreaPropertyPanel::Create (
527 vcl::Window
* pParent
,
528 const css::uno::Reference
<css::frame::XFrame
>& rxFrame
,
529 SfxBindings
* pBindings
)
532 throw lang::IllegalArgumentException("no parent Window given to AreaPropertyPanel::Create", NULL
, 0);
534 throw lang::IllegalArgumentException("no XFrame given to AreaPropertyPanel::Create", NULL
, 1);
535 if (pBindings
== NULL
)
536 throw lang::IllegalArgumentException("no SfxBindings given to AreaPropertyPanel::Create", NULL
, 2);
538 return VclPtr
<AreaPropertyPanel
>::Create(
546 void AreaPropertyPanel::DataChanged(
547 const DataChangedEvent
& rEvent
)
556 void AreaPropertyPanel::ImpUpdateTransparencies()
558 if(mpTransparanceItem
.get() && mpFloatTransparenceItem
.get())
560 bool bZeroValue(false);
562 if(mpTransparanceItem
.get())
564 const sal_uInt16
nValue(mpTransparanceItem
->GetValue());
570 else if(nValue
<= 100)
572 mpLBTransType
->Enable();
573 mpTrspTextFT
->Enable();
574 mpLBTransType
->SelectEntryPos(1);
575 mpBTNGradient
->Hide();
576 mpMTRTransparent
->Show();
577 mpMTRTransparent
->Enable();
578 mpMTRTransparent
->SetValue(nValue
);
587 if(bZeroValue
&& mpFloatTransparenceItem
.get())
589 if(mpFloatTransparenceItem
->IsEnabled())
591 const XGradient
& rGradient
= mpFloatTransparenceItem
->GetGradientValue();
592 sal_Int32
nEntryPos(0);
595 mpLBTransType
->Enable();
596 mpTrspTextFT
->Enable();
597 mpMTRTransparent
->Hide();
598 mpBTNGradient
->Enable();
599 mpBTNGradient
->Show();
601 switch(rGradient
.GetGradientStyle())
604 case css::awt::GradientStyle_LINEAR
:
607 pImage
= &maImgLinear
;
610 case css::awt::GradientStyle_AXIAL
:
613 pImage
= &maImgAxial
;
616 case css::awt::GradientStyle_RADIAL
:
619 pImage
= &maImgRadial
;
622 case css::awt::GradientStyle_ELLIPTICAL
:
628 case css::awt::GradientStyle_SQUARE
:
634 case css::awt::GradientStyle_RECT
:
637 pImage
= &maImgSquare
;
642 const sal_uInt16 nIdGradient
= mpBTNGradient
->GetItemId(UNO_SIDEBARGRADIENT
);
643 mpLBTransType
->SelectEntryPos(nEntryPos
);
644 mpBTNGradient
->SetItemImage(nIdGradient
, *pImage
);
655 mpLBTransType
->Enable();
656 mpTrspTextFT
->Enable();
657 mpLBTransType
->SelectEntryPos(0);
658 mpBTNGradient
->Hide();
659 mpMTRTransparent
->Enable();
660 mpMTRTransparent
->Show();
661 mpMTRTransparent
->SetValue(0);
666 // no transparency at all
667 mpLBTransType
->SetNoSelection();
668 mpLBTransType
->Disable();
669 mpTrspTextFT
->Disable();
670 mpMTRTransparent
->Disable();
671 mpMTRTransparent
->Show();
672 mpBTNGradient
->Disable();
673 mpBTNGradient
->Hide();
679 void AreaPropertyPanel::NotifyItemUpdate(
682 const SfxPoolItem
* pState
,
683 const bool bIsEnabled
)
686 const bool bDisabled(SfxItemState::DISABLED
== eState
);
690 case SID_ATTR_FILL_TRANSPARENCE
:
691 case SID_ATTR_FILL_FLOATTRANSPARENCE
:
693 bool bFillTransparenceChanged(false);
695 if(SID_ATTR_FILL_TRANSPARENCE
== nSID
)
697 bFillTransparenceChanged
= true;
699 if(eState
>= SfxItemState::DEFAULT
)
701 const SfxUInt16Item
* pItem
= dynamic_cast< const SfxUInt16Item
* >(pState
);
703 if(pItem
&& (!mpTransparanceItem
|| *pItem
!= *mpTransparanceItem
))
705 mpTransparanceItem
.reset(static_cast<SfxUInt16Item
*>(pItem
->Clone()));
709 mpTransparanceItem
.reset();
714 mpTransparanceItem
.reset();
717 else // if(SID_ATTR_FILL_FLOATTRANSPARENCE == nSID)
719 bFillTransparenceChanged
= true;
721 if(eState
>= SfxItemState::DEFAULT
)
723 const XFillFloatTransparenceItem
* pItem
= dynamic_cast< const XFillFloatTransparenceItem
* >(pState
);
725 if(pItem
&& (!mpFloatTransparenceItem
|| *pItem
!= *mpFloatTransparenceItem
))
727 mpFloatTransparenceItem
.reset(static_cast<XFillFloatTransparenceItem
*>(pItem
->Clone()));
731 mpFloatTransparenceItem
.reset();
736 mpFloatTransparenceItem
.reset();
740 if(bFillTransparenceChanged
)
742 // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem
743 ImpUpdateTransparencies();
747 case SID_ATTR_FILL_STYLE
:
751 mpLbFillType
->Disable();
752 mpColorTextFT
->Disable();
753 mpLbFillType
->SetNoSelection();
754 mpLbFillAttr
->Show();
755 mpLbFillAttr
->Disable();
756 mpLbFillAttr
->SetNoSelection();
757 mpToolBoxColor
->Hide();
758 meLastXFS
= static_cast<sal_uInt16
>(-1);
762 if(eState
>= SfxItemState::DEFAULT
)
764 const XFillStyleItem
* pItem
= dynamic_cast< const XFillStyleItem
* >(pState
);
768 mpStyleItem
.reset(dynamic_cast< XFillStyleItem
* >(pItem
->Clone()));
769 mpLbFillType
->Enable();
770 mpColorTextFT
->Enable();
771 drawing::FillStyle eXFS
= (drawing::FillStyle
)mpStyleItem
->GetValue();
773 mpLbFillType
->SelectEntryPos(sal::static_int_cast
< sal_Int32
>(eXFS
));
775 if(drawing::FillStyle_NONE
== eXFS
)
777 mpLbFillAttr
->SetNoSelection();
778 mpLbFillAttr
->Disable();
786 mpLbFillType
->SetNoSelection();
787 mpLbFillAttr
->Show();
788 mpLbFillAttr
->Disable();
789 mpLbFillAttr
->SetNoSelection();
790 mpToolBoxColor
->Hide();
791 meLastXFS
= static_cast<sal_uInt16
>(-1);
795 case SID_ATTR_FILL_COLOR
:
797 if(SfxItemState::DEFAULT
== eState
)
799 mpColorItem
.reset(pState
? static_cast<XFillColorItem
*>(pState
->Clone()) : 0);
802 if(mpStyleItem
&& drawing::FillStyle_SOLID
== (drawing::FillStyle
)mpStyleItem
->GetValue())
804 mpLbFillAttr
->Hide();
805 mpToolBoxColor
->Show();
811 case SID_ATTR_FILL_GRADIENT
:
813 if(SfxItemState::DEFAULT
== eState
)
815 mpFillGradientItem
.reset(pState
? static_cast<XFillGradientItem
*>(pState
->Clone()) : 0);
818 if(mpStyleItem
&& drawing::FillStyle_GRADIENT
== (drawing::FillStyle
)mpStyleItem
->GetValue())
820 mpLbFillAttr
->Show();
821 mpToolBoxColor
->Hide();
823 if(SfxItemState::DEFAULT
== eState
)
825 mpLbFillAttr
->Enable();
828 else if(SfxItemState::DISABLED
== eState
)
830 mpLbFillAttr
->Disable();
831 mpLbFillAttr
->SetNoSelection();
835 mpLbFillAttr
->SetNoSelection();
840 case SID_ATTR_FILL_HATCH
:
842 if(SfxItemState::DEFAULT
== eState
)
844 mpHatchItem
.reset(pState
? static_cast<XFillHatchItem
*>(pState
->Clone()) : 0);
847 if(mpStyleItem
&& drawing::FillStyle_HATCH
== (drawing::FillStyle
)mpStyleItem
->GetValue())
849 mpLbFillAttr
->Show();
850 mpToolBoxColor
->Hide();
852 if(SfxItemState::DEFAULT
== eState
)
854 mpLbFillAttr
->Enable();
857 else if(SfxItemState::DISABLED
== eState
)
859 mpLbFillAttr
->Disable();
860 mpLbFillAttr
->SetNoSelection();
864 mpLbFillAttr
->SetNoSelection();
869 case SID_ATTR_FILL_BITMAP
:
871 if(SfxItemState::DEFAULT
== eState
)
873 mpBitmapItem
.reset(pState
? static_cast<XFillBitmapItem
*>(pState
->Clone()) : 0);
876 if(mpStyleItem
&& drawing::FillStyle_BITMAP
== (drawing::FillStyle
)mpStyleItem
->GetValue())
878 mpLbFillAttr
->Show();
879 mpToolBoxColor
->Hide();
881 if(SfxItemState::DEFAULT
== eState
)
883 mpLbFillAttr
->Enable();
886 else if(SfxItemState::DISABLED
== eState
)
888 mpLbFillAttr
->Disable();
889 mpLbFillAttr
->SetNoSelection();
893 mpLbFillAttr
->SetNoSelection();
898 case SID_GRADIENT_LIST
:
900 if(SfxItemState::DEFAULT
== eState
)
902 if(mpStyleItem
&& drawing::FillStyle_GRADIENT
== (drawing::FillStyle
)mpStyleItem
->GetValue())
904 if(mpFillGradientItem
)
906 const OUString
aString( mpFillGradientItem
->GetName() );
907 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
908 const SvxGradientListItem
aItem( *static_cast<const SvxGradientListItem
*>(pSh
->GetItem(SID_GRADIENT_LIST
)));
910 mpLbFillAttr
->Clear();
911 mpLbFillAttr
->Enable();
912 mpLbFillAttr
->Fill(aItem
.GetGradientList());
913 mpLbFillAttr
->SelectEntry(aString
);
917 mpLbFillAttr
->SetNoSelection();
925 if(SfxItemState::DEFAULT
== eState
)
927 if(mpStyleItem
&& drawing::FillStyle_HATCH
== (drawing::FillStyle
)mpStyleItem
->GetValue())
931 const OUString
aString( mpHatchItem
->GetName() );
932 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
933 const SvxHatchListItem
aItem(*static_cast<const SvxHatchListItem
*>(pSh
->GetItem(SID_HATCH_LIST
)));
935 mpLbFillAttr
->Clear();
936 mpLbFillAttr
->Enable();
937 mpLbFillAttr
->Fill(aItem
.GetHatchList());
938 mpLbFillAttr
->SelectEntry(aString
);
942 mpLbFillAttr
->SetNoSelection();
948 case SID_BITMAP_LIST
:
950 if(SfxItemState::DEFAULT
== eState
)
952 if(mpStyleItem
&& drawing::FillStyle_BITMAP
== (drawing::FillStyle
)mpStyleItem
->GetValue())
956 const OUString
aString( mpBitmapItem
->GetName() );
957 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
958 const SvxBitmapListItem
aItem(*static_cast<const SvxBitmapListItem
*>(pSh
->GetItem(SID_BITMAP_LIST
)));
960 mpLbFillAttr
->Clear();
961 mpLbFillAttr
->Enable();
962 mpLbFillAttr
->Fill(aItem
.GetBitmapList());
963 mpLbFillAttr
->SelectEntry(aString
);
967 mpLbFillAttr
->SetNoSelection();
981 void AreaPropertyPanel::Update()
985 const drawing::FillStyle eXFS
= (drawing::FillStyle
)mpStyleItem
->GetValue();
986 SfxObjectShell
* pSh
= SfxObjectShell::Current();
990 case drawing::FillStyle_NONE
:
992 mpLbFillAttr
->Show();
993 mpToolBoxColor
->Hide();
996 case drawing::FillStyle_SOLID
:
1000 mpLbFillAttr
->Hide();
1001 mpToolBoxColor
->Show();
1005 case drawing::FillStyle_GRADIENT
:
1007 mpLbFillAttr
->Show();
1008 mpToolBoxColor
->Hide();
1010 if(pSh
&& pSh
->GetItem(SID_GRADIENT_LIST
))
1012 const SvxGradientListItem
aItem(*static_cast<const SvxGradientListItem
*>(pSh
->GetItem(SID_GRADIENT_LIST
)));
1013 mpLbFillAttr
->Enable();
1014 mpLbFillAttr
->Clear();
1015 mpLbFillAttr
->Fill(aItem
.GetGradientList());
1017 if(mpFillGradientItem
)
1019 const OUString
aString(mpFillGradientItem
->GetName());
1021 mpLbFillAttr
->SelectEntry(aString
);
1025 mpLbFillAttr
->SetNoSelection();
1030 mpLbFillAttr
->SetNoSelection();
1034 case drawing::FillStyle_HATCH
:
1036 mpLbFillAttr
->Show();
1037 mpToolBoxColor
->Hide();
1039 if(pSh
&& pSh
->GetItem(SID_HATCH_LIST
))
1041 const SvxHatchListItem
aItem(*static_cast<const SvxHatchListItem
*>(pSh
->GetItem(SID_HATCH_LIST
)));
1042 mpLbFillAttr
->Enable();
1043 mpLbFillAttr
->Clear();
1044 mpLbFillAttr
->Fill(aItem
.GetHatchList());
1048 const OUString
aString(mpHatchItem
->GetName());
1050 mpLbFillAttr
->SelectEntry( aString
);
1054 mpLbFillAttr
->SetNoSelection();
1059 mpLbFillAttr
->SetNoSelection();
1063 case drawing::FillStyle_BITMAP
:
1065 mpLbFillAttr
->Show();
1066 mpToolBoxColor
->Hide();
1068 if(pSh
&& pSh
->GetItem(SID_BITMAP_LIST
))
1070 const SvxBitmapListItem
aItem(*static_cast<const SvxBitmapListItem
*>(pSh
->GetItem(SID_BITMAP_LIST
)));
1071 mpLbFillAttr
->Enable();
1072 mpLbFillAttr
->Clear();
1073 mpLbFillAttr
->Fill(aItem
.GetBitmapList());
1077 const OUString
aString(mpBitmapItem
->GetName());
1079 mpLbFillAttr
->SelectEntry(aString
);
1083 mpLbFillAttr
->SetNoSelection();
1088 mpLbFillAttr
->SetNoSelection();
1093 OSL_ENSURE(false, "Non supported FillType (!)");
1101 IMPL_LINK_TYPED( AreaPropertyPanel
, ClickTrGrHdl_Impl
, ToolBox
*, pToolBox
, void )
1103 maTrGrPopup
.Rearrange(mpFloatTransparenceItem
.get());
1104 OSL_ASSERT( pToolBox
->GetItemCommand(pToolBox
->GetCurItemId()) == UNO_SIDEBARGRADIENT
);
1105 maTrGrPopup
.Show(*pToolBox
);
1110 IMPL_LINK_NOARG(AreaPropertyPanel
, ChangeTrgrTypeHdl_Impl
)
1112 sal_Int32 nSelectType
= mpLBTransType
->GetSelectEntryPos();
1113 bool bGradient
= false;
1114 sal_uInt16 nTrans
= 0;
1118 mpBTNGradient
->Hide();
1119 mpMTRTransparent
->Show();
1120 mpMTRTransparent
->Enable();
1121 mpMTRTransparent
->SetValue(0);
1123 else if(1 == nSelectType
)
1125 mpBTNGradient
->Hide();
1126 mpMTRTransparent
->Show();
1127 nTrans
= mnLastTransSolid
;
1128 mpMTRTransparent
->SetValue(nTrans
);
1129 mpLBTransType
->SelectEntryPos(1);
1130 mpMTRTransparent
->Enable();
1134 mpBTNGradient
->Show();
1136 const sal_uInt16 nIdGradient
= mpBTNGradient
->GetItemId(UNO_SIDEBARGRADIENT
);
1137 switch (nSelectType
)
1140 mpBTNGradient
->SetItemImage(nIdGradient
, maImgLinear
);
1143 mpBTNGradient
->SetItemImage(nIdGradient
, maImgAxial
);
1146 mpBTNGradient
->SetItemImage(nIdGradient
, maImgRadial
);
1149 mpBTNGradient
->SetItemImage(nIdGradient
, maImgElli
);
1152 mpBTNGradient
->SetItemImage(nIdGradient
, maImgQuad
);
1155 mpBTNGradient
->SetItemImage(nIdGradient
, maImgSquare
);
1159 mpMTRTransparent
->Hide();
1160 mpBTNGradient
->Enable();
1164 const XFillTransparenceItem
aLinearItem(nTrans
);
1165 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE
, SfxCallMode::RECORD
, &aLinearItem
, 0L );
1172 XGradient aTmpGradient
;
1176 case css::awt::GradientStyle_LINEAR
:
1177 aTmpGradient
= maGradientLinear
;
1179 case css::awt::GradientStyle_AXIAL
:
1180 aTmpGradient
= maGradientAxial
;
1182 case css::awt::GradientStyle_RADIAL
:
1183 aTmpGradient
= maGradientRadial
;
1185 case css::awt::GradientStyle_ELLIPTICAL
:
1186 aTmpGradient
= maGradientElliptical
;
1188 case css::awt::GradientStyle_SQUARE
:
1189 aTmpGradient
= maGradientSquare
;
1191 case css::awt::GradientStyle_RECT
:
1192 aTmpGradient
= maGradientRect
;
1198 SfxItemPool
* pPool
= 0;
1199 const XFillFloatTransparenceItem
aGradientItem(pPool
, aTmpGradient
, bGradient
);
1200 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_FLOATTRANSPARENCE
, SfxCallMode::RECORD
, &aGradientItem
, 0L );
1207 IMPL_LINK_NOARG(AreaPropertyPanel
, ModifyTransparentHdl_Impl
)
1209 const sal_uInt16 nTrans
= (sal_uInt16
)mpMTRTransparent
->GetValue();
1210 mnLastTransSolid
= nTrans
;
1211 const sal_Int32 nSelectType
= mpLBTransType
->GetSelectEntryPos();
1213 if(nTrans
&& !nSelectType
)
1215 mpLBTransType
->SelectEntryPos(1);
1218 const XFillTransparenceItem
aLinearItem(nTrans
);
1219 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE
, SfxCallMode::RECORD
, &aLinearItem
, 0L );
1229 XGradient
AreaPropertyPanel::GetGradient (const css::awt::GradientStyle eStyle
) const
1234 case css::awt::GradientStyle_LINEAR
:
1235 return maGradientLinear
;
1236 case css::awt::GradientStyle_AXIAL
:
1237 return maGradientAxial
;
1238 case css::awt::GradientStyle_RADIAL
:
1239 return maGradientRadial
;
1240 case css::awt::GradientStyle_ELLIPTICAL
:
1241 return maGradientElliptical
;
1242 case css::awt::GradientStyle_SQUARE
:
1243 return maGradientSquare
;
1244 case css::awt::GradientStyle_RECT
:
1245 return maGradientRect
;
1252 void AreaPropertyPanel::SetGradient (const XGradient
& rGradient
)
1254 switch (rGradient
.GetGradientStyle())
1256 case css::awt::GradientStyle_LINEAR
:
1257 maGradientLinear
= rGradient
;
1259 case css::awt::GradientStyle_AXIAL
:
1260 maGradientAxial
= rGradient
;
1262 case css::awt::GradientStyle_RADIAL
:
1263 maGradientRadial
= rGradient
;
1265 case css::awt::GradientStyle_ELLIPTICAL
:
1266 maGradientElliptical
= rGradient
;
1268 case css::awt::GradientStyle_SQUARE
:
1269 maGradientSquare
= rGradient
;
1271 case css::awt::GradientStyle_RECT
:
1272 maGradientRect
= rGradient
;
1282 sal_Int32
AreaPropertyPanel::GetSelectedTransparencyTypeIndex() const
1284 return mpLBTransType
->GetSelectEntryPos();
1287 } } // end of namespace svx::sidebar
1289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */