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 .
20 #include <svx/sidebar/AreaPropertyPanelBase.hxx>
21 #include <svx/drawitem.hxx>
22 #include <svx/itemwin.hxx>
23 #include <svx/svxids.hrc>
24 #include <sfx2/objsh.hxx>
25 #include <svx/xfltrit.hxx>
26 #include <svx/xflftrit.hxx>
27 #include <svx/xfilluseslidebackgrounditem.hxx>
28 #include <svx/xtable.hxx>
29 #include <sfx2/sidebar/Panel.hxx>
30 #include <sfx2/opengrf.hxx>
31 #include <sfx2/weldutils.hxx>
32 #include <tools/urlobj.hxx>
33 #include <bitmaps.hlst>
34 #include <comphelper/lok.hxx>
37 using namespace css::uno
;
39 constexpr OUString SIDEBARGRADIENT
= u
"sidebargradient"_ustr
;
41 namespace svx::sidebar
{
58 const sal_Int32
AreaPropertyPanelBase::DEFAULT_CENTERX
= 50;
59 const sal_Int32
AreaPropertyPanelBase::DEFAULT_CENTERY
= 50;
60 const sal_Int32
AreaPropertyPanelBase::DEFAULT_ANGLE
= 0;
61 const sal_Int32
AreaPropertyPanelBase::DEFAULT_STARTVALUE
= 0;
62 const sal_Int32
AreaPropertyPanelBase::DEFAULT_ENDVALUE
= 16777215;
63 const sal_Int32
AreaPropertyPanelBase::DEFAULT_BORDER
= 0;
65 AreaPropertyPanelBase::AreaPropertyPanelBase(
66 weld::Widget
* pParent
,
67 const css::uno::Reference
<css::frame::XFrame
>& rxFrame
)
68 : PanelLayout(pParent
, u
"AreaPropertyPanel"_ustr
, u
"svx/ui/sidebararea.ui"_ustr
),
70 meLastXFS(static_cast<sal_uInt16
>(-1)),
75 mxColorTextFT(m_xBuilder
->weld_label(u
"filllabel"_ustr
)),
76 mxLbFillType(m_xBuilder
->weld_combo_box(u
"fillstylearea"_ustr
)),
77 mxLbFillAttr(m_xBuilder
->weld_combo_box(u
"fillattrhb"_ustr
)),
78 mxLbFillGradFrom(new ColorListBox(m_xBuilder
->weld_menu_button(u
"fillgrad1"_ustr
), [this]{ return GetFrameWeld(); })),
79 mxLbFillGradTo(new ColorListBox(m_xBuilder
->weld_menu_button(u
"fillgrad2"_ustr
), [this]{ return GetFrameWeld(); })),
80 mxToolBoxColor(m_xBuilder
->weld_toolbar(u
"selectcolor"_ustr
)),
81 mxColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxColor
, *m_xBuilder
, rxFrame
)),
82 mxTrspTextFT(m_xBuilder
->weld_label(u
"transparencylabel"_ustr
)),
83 mxLBTransType(m_xBuilder
->weld_combo_box(u
"transtype"_ustr
)),
84 mxMTRTransparent(m_xBuilder
->weld_metric_spin_button(u
"settransparency"_ustr
, FieldUnit::PERCENT
)),
85 mxSldTransparent(m_xBuilder
->weld_scale(u
"transparencyslider"_ustr
)),
86 mxBTNGradient(m_xBuilder
->weld_toolbar(u
"selectgradient"_ustr
)),
87 mxMTRAngle(m_xBuilder
->weld_metric_spin_button(u
"gradangle"_ustr
, FieldUnit::DEGREE
)),
88 mxGradientStyle(m_xBuilder
->weld_combo_box(u
"gradientstyle"_ustr
)),
89 mxBmpImport(m_xBuilder
->weld_button(u
"bmpimport"_ustr
)),
90 maImgAxial(BMP_AXIAL
),
93 maImgRadial(BMP_RADIAL
),
94 maImgSquare(BMP_SQUARE
),
95 maImgLinear(BMP_LINEAR
)
100 AreaPropertyPanelBase::~AreaPropertyPanelBase()
103 mxColorTextFT
.reset();
104 mxLbFillType
.reset();
105 mxLbFillAttr
.reset();
106 mxColorDispatch
.reset();
107 mxToolBoxColor
.reset();
108 mxTrspTextFT
.reset();
109 mxLBTransType
.reset();
110 mxMTRTransparent
.reset();
111 mxSldTransparent
.reset();
112 mxBTNGradient
.reset();
114 mxLbFillGradFrom
.reset();
115 mxLbFillGradTo
.reset();
116 mxGradientStyle
.reset();
120 void AreaPropertyPanelBase::Initialize()
122 SvxFillTypeBox::Fill(*mxLbFillType
);
124 mxLbFillAttr
->set_size_request(42, -1);
126 maGradientLinear
.SetXOffset(DEFAULT_CENTERX
);
127 maGradientLinear
.SetYOffset(DEFAULT_CENTERY
);
128 maGradientLinear
.SetAngle(Degree10(DEFAULT_ANGLE
));
129 maGradientLinear
.SetColorStops(
130 basegfx::BColorStops(
131 Color(DEFAULT_STARTVALUE
).getBColor(),
132 Color(DEFAULT_ENDVALUE
).getBColor()));
133 maGradientLinear
.SetBorder(DEFAULT_BORDER
);
134 maGradientLinear
.SetGradientStyle(css::awt::GradientStyle_LINEAR
);
136 maGradientAxial
= maGradientLinear
;
137 maGradientAxial
.SetGradientStyle(css::awt::GradientStyle_AXIAL
);
139 maGradientRadial
= maGradientLinear
;
140 maGradientRadial
.SetGradientStyle(css::awt::GradientStyle_RADIAL
);
142 maGradientElliptical
= maGradientLinear
;
143 maGradientElliptical
.SetGradientStyle(css::awt::GradientStyle_ELLIPTICAL
);
145 maGradientSquare
= maGradientLinear
;
146 maGradientSquare
.SetGradientStyle(css::awt::GradientStyle_SQUARE
);
148 maGradientRect
= maGradientLinear
;
149 maGradientRect
.SetGradientStyle(css::awt::GradientStyle_RECT
);
152 mxLbFillType
->connect_changed( LINK( this, AreaPropertyPanelBase
, SelectFillTypeHdl
) );
154 Link
<weld::ComboBox
&,void> aLink
= LINK( this, AreaPropertyPanelBase
, SelectFillAttrHdl
);
155 mxLbFillAttr
->connect_changed( aLink
);
156 mxGradientStyle
->connect_changed( aLink
);
157 Link
<ColorListBox
&,void> aLink3
= LINK( this, AreaPropertyPanelBase
, SelectFillColorHdl
);
158 mxLbFillGradFrom
->SetSelectHdl( aLink3
);
159 mxLbFillGradTo
->SetSelectHdl( aLink3
);
160 mxMTRAngle
->connect_value_changed(LINK(this,AreaPropertyPanelBase
, ChangeGradientAngle
));
162 // set a small width to force widgets to take their final width from other widgets in the grid
163 mxLbFillGradFrom
->get_widget().set_size_request(42, -1);
164 mxLbFillGradTo
->get_widget().set_size_request(42, -1);
166 mxLBTransType
->connect_changed(LINK(this, AreaPropertyPanelBase
, ChangeTrgrTypeHdl_Impl
));
168 SetTransparency( 50 );
169 mxMTRTransparent
->connect_value_changed(LINK(this, AreaPropertyPanelBase
, ModifyTransparentHdl_Impl
));
170 mxSldTransparent
->connect_value_changed(LINK(this, AreaPropertyPanelBase
, ModifyTransSliderHdl
));
172 mxTrGrPopup
= std::make_unique
<AreaTransparencyGradientPopup
>(mxFrame
, *this, mxBTNGradient
.get());
174 mxBTNGradient
->set_item_popover(SIDEBARGRADIENT
, mxTrGrPopup
->getTopLevel());
175 mxBTNGradient
->connect_clicked(LINK(this, AreaPropertyPanelBase
, ToolbarHdl_Impl
));
177 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgLinear
);
178 mxBTNGradient
->hide();
179 mxBmpImport
->connect_clicked( LINK(this, AreaPropertyPanelBase
, ClickImportBitmapHdl
));
182 IMPL_LINK_NOARG(AreaPropertyPanelBase
, ToolbarHdl_Impl
, const OUString
&, void)
184 mxBTNGradient
->set_menu_item_active(SIDEBARGRADIENT
, !mxBTNGradient
->get_menu_item_active(SIDEBARGRADIENT
));
187 void AreaPropertyPanelBase::SetTransparency(sal_uInt16 nVal
)
189 mxSldTransparent
->set_value(nVal
);
190 mxMTRTransparent
->set_value(nVal
, FieldUnit::PERCENT
);
193 IMPL_LINK_NOARG(AreaPropertyPanelBase
, ClickImportBitmapHdl
, weld::Button
&, void)
195 SvxOpenGraphicDialog
aDlg(u
"Import"_ustr
, GetFrameWeld());
196 aDlg
.EnableLink(false);
197 if( aDlg
.Execute() != ERRCODE_NONE
)
201 auto xWait
= std::make_unique
<weld::WaitObject
>(m_xContainer
.get());
202 ErrCode nError
= aDlg
.GetGraphic( aGraphic
);
204 if( nError
!= ERRCODE_NONE
)
207 mxLbFillAttr
->clear();
209 if (SfxObjectShell
* pSh
= SfxObjectShell::Current())
211 INetURLObject
aURL(aDlg
.GetPath());
212 OUString aFileName
= aURL
.GetLastName().getToken(0, '.');
213 OUString aName
= aFileName
;
215 XBitmapListRef pList
= pSh
->GetItem(SID_BITMAP_LIST
)->GetBitmapList();
218 bool bValidBitmapName
= false;
219 while( !bValidBitmapName
)
221 bValidBitmapName
= true;
222 for( tools::Long i
= 0; i
< pList
->Count() && bValidBitmapName
; i
++ )
224 if( aName
== pList
->GetBitmap(i
)->GetName() )
226 bValidBitmapName
= false;
227 aName
= aFileName
+ OUString::number(j
++);
232 pList
->Insert(std::make_unique
<XBitmapEntry
>(aGraphic
, aName
));
235 SvxFillAttrBox::Fill(*mxLbFillAttr
, pList
);
237 mxLbFillAttr
->set_active_text(aName
);
238 SelectFillAttrHdl(*mxLbFillAttr
);
242 IMPL_LINK_NOARG(AreaPropertyPanelBase
, SelectFillTypeHdl
, weld::ComboBox
&, void)
244 FillStyleChanged(true);
247 IMPL_LINK_NOARG(AreaPropertyPanelBase
, SelectFillColorHdl
, ColorListBox
&, void)
249 SelectFillAttrHdl_Impl();
252 IMPL_LINK_NOARG(AreaPropertyPanelBase
, SelectFillAttrHdl
, weld::ComboBox
&, void)
254 SelectFillAttrHdl_Impl();
257 IMPL_LINK_NOARG(AreaPropertyPanelBase
, ChangeGradientAngle
, weld::MetricSpinButton
&, void)
259 SelectFillAttrHdl_Impl();
262 void AreaPropertyPanelBase::SelectFillAttrHdl_Impl()
264 sal_Int32 nPosFillStyle
= static_cast<eFillStyle
>(mxLbFillType
->get_active());
265 SfxObjectShell
* pSh
= SfxObjectShell::Current();
267 // #i122676# dependent from bFillStyleChange, do execute a single or two
268 // changes in one Execute call
269 const bool bFillStyleChange(static_cast<eFillStyle
>(meLastXFS
) != static_cast<eFillStyle
>(nPosFillStyle
));
271 switch(nPosFillStyle
)
273 case eFillStyle::NONE
:
277 const XFillStyleItem
aXFillStyleItem(drawing::FillStyle_NONE
);
278 // Need to disable the XFillUseSlideBackgroundItem
279 const XFillUseSlideBackgroundItem
aXFillUseSlideBackgroundItem(false);
280 setFillUseBackground(&aXFillStyleItem
, aXFillUseSlideBackgroundItem
);
284 case eFillStyle::SOLID
:
288 // #i122676# Single FillStyle change call needed here
289 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_SOLID
);
290 setFillStyle(aXFillStyleItem
);
294 case eFillStyle::GRADIENT
:
297 if (pSh
&& pSh
->GetItem(SID_COLOR_TABLE
))
299 basegfx::BGradient
aGradient(createColorStops());
300 aGradient
.SetAngle(Degree10(mxMTRAngle
->get_value(FieldUnit::DEGREE
) * 10));
301 aGradient
.SetGradientStyle(static_cast<css::awt::GradientStyle
>(mxGradientStyle
->get_active()));
303 const XFillGradientItem
aXFillGradientItem(mxLbFillAttr
->get_active_text(), aGradient
);
305 // #i122676# Change FillStyle and Gradient in one call
306 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_GRADIENT
);
307 setFillStyleAndGradient(bFillStyleChange
? &aXFillStyleItem
: nullptr, aXFillGradientItem
);
311 case eFillStyle::HATCH
:
313 sal_Int32 nPos
= mxLbFillAttr
->get_active();
317 nPos
= mnLastPosHatch
;
320 if (nPos
!= -1 && pSh
&& pSh
->GetItem(SID_HATCH_LIST
))
322 const SvxHatchListItem
* pItem
= pSh
->GetItem(SID_HATCH_LIST
);
324 if(nPos
< pItem
->GetHatchList()->Count())
326 const XHatch aHatch
= pItem
->GetHatchList()->GetHatch(nPos
)->GetHatch();
327 const XFillHatchItem
aXFillHatchItem( mxLbFillAttr
->get_active_text(), aHatch
);
329 // #i122676# Change FillStyle and Hatch in one call
330 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_HATCH
);
331 setFillStyleAndHatch(bFillStyleChange
? &aXFillStyleItem
: nullptr, aXFillHatchItem
);
337 mnLastPosHatch
= nPos
;
341 case eFillStyle::BITMAP
:
343 sal_Int32 nPos
= mxLbFillAttr
->get_active();
347 nPos
= mnLastPosBitmap
;
350 if (nPos
!= -1 && pSh
&& pSh
->GetItem(SID_BITMAP_LIST
))
352 const SvxBitmapListItem
* pItem
= pSh
->GetItem(SID_BITMAP_LIST
);
354 if(nPos
< pItem
->GetBitmapList()->Count())
356 const XBitmapEntry
* pXBitmapEntry
= pItem
->GetBitmapList()->GetBitmap(nPos
);
357 const XFillBitmapItem
aXFillBitmapItem(mxLbFillAttr
->get_active_text(), pXBitmapEntry
->GetGraphicObject());
359 // #i122676# Change FillStyle and Bitmap in one call
360 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_BITMAP
);
361 setFillStyleAndBitmap(bFillStyleChange
? &aXFillStyleItem
: nullptr, aXFillBitmapItem
);
367 mnLastPosBitmap
= nPos
;
371 case eFillStyle::PATTERN
:
373 sal_Int32 nPos
= mxLbFillAttr
->get_active();
377 nPos
= mnLastPosPattern
;
380 if (nPos
!= -1 && pSh
&& pSh
->GetItem(SID_PATTERN_LIST
))
382 const SvxPatternListItem
* pItem
= pSh
->GetItem(SID_PATTERN_LIST
);
384 if(nPos
< pItem
->GetPatternList()->Count())
386 const XBitmapEntry
* pXPatternEntry
= pItem
->GetPatternList()->GetBitmap(nPos
);
387 const XFillBitmapItem
aXFillBitmapItem(mxLbFillAttr
->get_active_text(), pXPatternEntry
->GetGraphicObject());
389 // #i122676# Change FillStyle and Bitmap in one call
390 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_BITMAP
);
391 setFillStyleAndBitmap(bFillStyleChange
? &aXFillStyleItem
: nullptr, aXFillBitmapItem
);
397 mnLastPosPattern
= nPos
;
402 if (m_pPanel
&& !comphelper::LibreOfficeKit::isActive())
403 m_pPanel
->TriggerDeckLayouting();
406 void AreaPropertyPanelBase::FillStyleChanged(bool bUpdateModel
)
408 sal_Int32 nPos
= static_cast<eFillStyle
>(mxLbFillType
->get_active());
409 mxLbFillAttr
->clear();
410 SfxObjectShell
* pSh
= SfxObjectShell::Current();
414 bool bShowLbFillAttr
= false;
415 bool bShowLbFillGradFrom
= false;
416 bool bShowLbFillGradTo
= false;
417 bool bShowGradientStyle
= false;
418 bool bShowMTRAngle
= false;
419 bool bShowToolBoxColor
= false;
420 bool bShowBmpImport
= false;
422 // #i122676# Do no longer trigger two Execute calls, one for SID_ATTR_FILL_STYLE
423 // and one for setting the fill attribute itself, but add two SfxPoolItems to the
424 // call to get just one action at the SdrObject and to create only one Undo action, too.
425 // Checked that this works in all apps.
433 const XFillStyleItem
aXFillStyleItem(drawing::FillStyle_NONE
);
434 // Need to disable the XFillUseSlideBackgroundItem
435 const XFillUseSlideBackgroundItem
aXFillUseSlideBackgroundItem(false);
436 setFillUseBackground(&aXFillStyleItem
, aXFillUseSlideBackgroundItem
);
443 bShowToolBoxColor
= true;
447 const Color aColor
= mpColorItem
? mpColorItem
->GetColorValue() : COL_AUTO
;
448 const XFillColorItem
aXFillColorItem(u
""_ustr
, aColor
);
450 // #i122676# change FillStyle and Color in one call
451 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_SOLID
);
452 setFillStyleAndColor(&aXFillStyleItem
, aXFillColorItem
);
458 bShowLbFillGradFrom
= true;
459 bShowLbFillGradTo
= true;
460 bShowGradientStyle
= true;
461 bShowMTRAngle
= true;
463 mxLbFillAttr
->set_sensitive(true);
464 mxLbFillGradTo
->set_sensitive(true);
465 mxLbFillGradFrom
->set_sensitive(true);
466 mxGradientStyle
->set_sensitive(true);
467 mxMTRAngle
->set_sensitive(true);
468 mxLbFillAttr
->clear();
472 mxLbFillAttr
->hide();
473 mxToolBoxColor
->hide();
476 const SvxGradientListItem
* pItem
= pSh
->GetItem(SID_GRADIENT_LIST
);
477 if (pItem
->GetGradientList()->Count() > 0)
479 const basegfx::BGradient aGradient
480 = pItem
->GetGradientList()->GetGradient(0)->GetGradient();
481 const OUString aName
= pItem
->GetGradientList()->GetGradient(0)->GetName();
482 const XFillGradientItem
aXFillGradientItem(aName
, aGradient
);
484 // #i122676# change FillStyle and Gradient in one call
485 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_GRADIENT
);
486 setFillStyleAndGradient(&aXFillStyleItem
, aXFillGradientItem
);
487 mxLbFillGradFrom
->SelectEntry(Color(aGradient
.GetColorStops().front().getStopColor()));
488 mxLbFillGradTo
->SelectEntry(Color(aGradient
.GetColorStops().back().getStopColor()));
490 // MCGR: preserve ColorStops if given
491 // tdf#155901 We need offset of first and last stop, so include them.
492 if (aGradient
.GetColorStops().size() >= 2)
493 maColorStops
= aGradient
.GetColorStops();
495 maColorStops
.clear();
497 mxMTRAngle
->set_value(toDegrees(aGradient
.GetAngle()), FieldUnit::DEGREE
);
498 css::awt::GradientStyle eXGS
= aGradient
.GetGradientStyle();
499 mxGradientStyle
->set_active(sal::static_int_cast
<sal_Int32
>(eXGS
));
504 if (pSh
->GetItem(SID_GRADIENT_LIST
))
506 SvxFillAttrBox::Fill(*mxLbFillAttr
,
507 pSh
->GetItem(SID_GRADIENT_LIST
)->GetGradientList());
508 mxLbFillGradTo
->SetNoSelection();
509 mxLbFillGradFrom
->SetNoSelection();
510 if (mpFillGradientItem
)
512 const OUString
aString(mpFillGradientItem
->GetName());
513 mxLbFillAttr
->set_active_text(aString
);
514 const basegfx::BGradient aGradient
= mpFillGradientItem
->GetGradientValue();
515 mxLbFillGradFrom
->SelectEntry(Color(aGradient
.GetColorStops().front().getStopColor()));
516 mxLbFillGradTo
->SelectEntry(Color(aGradient
.GetColorStops().back().getStopColor()));
518 // MCGR: preserve ColorStops if given
519 // tdf#155901 We need offset of first and last stop, so include them.
520 if (aGradient
.GetColorStops().size() >= 2)
521 maColorStops
= aGradient
.GetColorStops();
523 maColorStops
.clear();
525 mxGradientStyle
->set_active(
526 sal::static_int_cast
<sal_Int32
>(aGradient
.GetGradientStyle()));
527 if (mxGradientStyle
->get_active() == sal_Int32(css::awt::GradientStyle_RADIAL
))
528 mxMTRAngle
->set_sensitive(false);
530 mxMTRAngle
->set_value(toDegrees(aGradient
.GetAngle()),
535 mxLbFillAttr
->set_active(-1);
540 mxLbFillAttr
->set_active(-1);
547 bShowLbFillAttr
= true;
549 const SvxHatchListItem
* pItem(pSh
->GetItem(SID_HATCH_LIST
));
552 const XHatchListRef
& pXHatchList(pItem
->GetHatchList());
553 mxLbFillAttr
->set_sensitive(true);
554 mxLbFillAttr
->clear();
555 SvxFillAttrBox::Fill(*mxLbFillAttr
, pXHatchList
);
557 if (mnLastPosHatch
!= -1)
559 if (mnLastPosHatch
< pXHatchList
->Count())
561 const XHatch aHatch
= pXHatchList
->GetHatch(mnLastPosHatch
)->GetHatch();
562 const OUString aName
= pXHatchList
->GetHatch(mnLastPosHatch
)->GetName();
563 const XFillHatchItem
aXFillHatchItem(aName
, aHatch
);
565 // #i122676# change FillStyle and Hatch in one call
568 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_HATCH
);
569 setFillStyleAndHatch(&aXFillStyleItem
, aXFillHatchItem
);
571 mxLbFillAttr
->set_active(mnLastPosHatch
);
577 mxLbFillAttr
->set_sensitive(false);
584 bShowLbFillAttr
= true;
585 mxLbFillAttr
->set_sensitive(true);
586 mxLbFillAttr
->clear();
589 GraphicObject aBitmap
;
590 if (nPos
== static_cast<sal_Int32
>(BITMAP
))
592 if (!comphelper::LibreOfficeKit::isActive())
593 bShowBmpImport
= true;
594 const SvxBitmapListItem
* pItem
= pSh
->GetItem(SID_BITMAP_LIST
);
597 const XBitmapListRef
& pXBitmapList(pItem
->GetBitmapList());
598 SvxFillAttrBox::Fill(*mxLbFillAttr
, pXBitmapList
);
600 if (mnLastPosBitmap
!= -1)
602 if (mnLastPosBitmap
< pXBitmapList
->Count())
604 const XBitmapEntry
* pXBitmapEntry
605 = pXBitmapList
->GetBitmap(mnLastPosBitmap
);
606 aBitmap
= pXBitmapEntry
->GetGraphicObject();
607 aName
= pXBitmapEntry
->GetName();
608 mxLbFillAttr
->set_active(mnLastPosBitmap
);
614 bShowBmpImport
= false;
617 else if (nPos
== static_cast<sal_Int32
>(PATTERN
))
619 const SvxPatternListItem
* pItem
= pSh
->GetItem(SID_PATTERN_LIST
);
622 const XPatternListRef
& pXPatternList(pItem
->GetPatternList());
623 SvxFillAttrBox::Fill(*mxLbFillAttr
, pXPatternList
);
625 if (mnLastPosPattern
!= -1)
627 if (mnLastPosPattern
< pXPatternList
->Count())
629 const XBitmapEntry
* pXPatternEntry
630 = pXPatternList
->GetBitmap(mnLastPosPattern
);
631 aBitmap
= pXPatternEntry
->GetGraphicObject();
632 aName
= pXPatternEntry
->GetName();
633 mxLbFillAttr
->set_active(mnLastPosPattern
);
639 bShowLbFillAttr
= false;
644 const XFillBitmapItem
aXFillBitmapItem(aName
, aBitmap
);
645 const XFillStyleItem
aXFillStyleItem(drawing::FillStyle_BITMAP
);
646 setFillStyleAndBitmap(&aXFillStyleItem
, aXFillBitmapItem
);
652 // No transparencies here
653 mxLBTransType
->hide();
654 mxTrspTextFT
->hide();
655 mxMTRTransparent
->hide();
656 mxSldTransparent
->hide();
657 mxBTNGradient
->hide();
660 const XFillStyleItem
aXFillStyleItem(drawing::FillStyle_NONE
);
661 const XFillUseSlideBackgroundItem
aXFillUseSlideBackgroundItem(true);
662 setFillUseBackground(&aXFillStyleItem
, aXFillUseSlideBackgroundItem
);
668 mxLbFillAttr
->set_visible(bShowLbFillAttr
);
669 mxLbFillGradFrom
->set_visible(bShowLbFillGradFrom
);
670 mxLbFillGradTo
->set_visible(bShowLbFillGradTo
);
671 mxGradientStyle
->set_visible(bShowGradientStyle
);
672 mxMTRAngle
->set_visible(bShowMTRAngle
);
673 mxToolBoxColor
->set_visible(bShowToolBoxColor
);
674 mxBmpImport
->set_visible(bShowBmpImport
);
676 meLastXFS
= static_cast<sal_uInt16
>(nPos
);
678 if (m_pPanel
&& !comphelper::LibreOfficeKit::isActive())
679 m_pPanel
->TriggerDeckLayouting();
682 void AreaPropertyPanelBase::ImpUpdateTransparencies()
684 if(mpTransparenceItem
|| mpFloatTransparenceItem
)
686 bool bZeroValue(false);
688 if (mpTransparenceItem
)
690 const sal_uInt16
nValue(mpTransparenceItem
->GetValue());
696 else if(nValue
<= 100)
698 mxLBTransType
->set_sensitive(true);
699 mxTrspTextFT
->set_sensitive(true);
700 mxLBTransType
->set_active(1);
701 mxBTNGradient
->hide();
702 mxMTRTransparent
->show();
703 mxSldTransparent
->show();
704 mxMTRTransparent
->set_sensitive(true);
705 mxSldTransparent
->set_sensitive(true);
706 SetTransparency(nValue
);
709 if (!bZeroValue
&& mxTrGrPopup
)
711 mxBTNGradient
->set_menu_item_active(SIDEBARGRADIENT
, false);
715 if(bZeroValue
&& mpFloatTransparenceItem
)
717 if(mpFloatTransparenceItem
->IsEnabled())
719 const basegfx::BGradient
& rGradient
= mpFloatTransparenceItem
->GetGradientValue();
720 sal_Int32
nEntryPos(0);
721 OUString
* pImage
= nullptr;
723 mxLBTransType
->set_sensitive(true);
724 mxTrspTextFT
->set_sensitive(true);
725 mxMTRTransparent
->hide();
726 mxSldTransparent
->hide();
727 mxBTNGradient
->set_sensitive(true);
728 mxBTNGradient
->show();
730 switch(rGradient
.GetGradientStyle())
733 case css::awt::GradientStyle_LINEAR
:
736 pImage
= &maImgLinear
;
739 case css::awt::GradientStyle_AXIAL
:
742 pImage
= &maImgAxial
;
745 case css::awt::GradientStyle_RADIAL
:
748 pImage
= &maImgRadial
;
751 case css::awt::GradientStyle_ELLIPTICAL
:
757 case css::awt::GradientStyle_SQUARE
:
763 case css::awt::GradientStyle_RECT
:
766 pImage
= &maImgSquare
;
770 mxLBTransType
->set_active(nEntryPos
);
771 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, *pImage
);
772 mxTrGrPopup
->Rearrange(mpFloatTransparenceItem
.get());
783 mxLBTransType
->set_sensitive(true);
784 mxTrspTextFT
->set_sensitive(true);
785 mxLBTransType
->set_active(0);
786 mxBTNGradient
->hide();
787 mxMTRTransparent
->set_sensitive(true);
788 mxSldTransparent
->set_sensitive(true);
789 mxMTRTransparent
->show();
790 mxSldTransparent
->show();
796 // no transparency at all
797 mxLBTransType
->set_active(-1);
798 mxLBTransType
->set_sensitive(false);
799 mxTrspTextFT
->set_sensitive(false);
800 mxMTRTransparent
->set_sensitive(false);
801 mxSldTransparent
->set_sensitive(false);
802 mxMTRTransparent
->show();
803 mxSldTransparent
->show();
804 mxBTNGradient
->set_sensitive(false);
805 mxBTNGradient
->hide();
809 void AreaPropertyPanelBase::updateFillTransparence(bool bDisabled
, bool bDefaultOrSet
, const SfxPoolItem
* pState
)
813 mpTransparenceItem
.reset();
816 else if (bDefaultOrSet
)
820 const SfxUInt16Item
* pItem
= static_cast<const SfxUInt16Item
*>(pState
);
821 mpTransparenceItem
.reset(pItem
->Clone());
825 mpTransparenceItem
.reset();
830 mpTransparenceItem
.reset();
833 // update transparency settings dependent of mpTransparenceItem and mpFloatTransparenceItem
834 ImpUpdateTransparencies();
837 void AreaPropertyPanelBase::updateFillFloatTransparence(bool bDisabled
, bool bDefaultOrSet
, const SfxPoolItem
* pState
)
841 mpFloatTransparenceItem
.reset();
849 const XFillFloatTransparenceItem
* pItem
= static_cast<const XFillFloatTransparenceItem
*>(pState
);
850 mpFloatTransparenceItem
.reset(pItem
->Clone());
854 mpFloatTransparenceItem
.reset();
859 mpFloatTransparenceItem
.reset();
862 // update transparency settings dependent of mpTransparenceItem and mpFloatTransparenceItem
863 ImpUpdateTransparencies();
866 void AreaPropertyPanelBase::updateFillStyle(bool bDisabled
, bool bDefaultOrSet
, const SfxPoolItem
* pState
)
870 mxLbFillType
->set_sensitive(false);
871 mxColorTextFT
->set_sensitive(false);
872 mxLbFillType
->set_active(-1);
873 mxLbFillAttr
->show();
874 mxLbFillAttr
->set_sensitive(false);
875 mxLbFillAttr
->set_active(-1);
876 mxToolBoxColor
->hide();
877 meLastXFS
= static_cast<sal_uInt16
>(-1);
880 else if (bDefaultOrSet
&& pState
)
882 const XFillStyleItem
* pItem
= static_cast<const XFillStyleItem
*>(pState
);
883 mpStyleItem
.reset(pItem
->Clone());
884 mxLbFillType
->set_sensitive(true);
885 mxColorTextFT
->set_sensitive(true);
886 drawing::FillStyle eXFS
= mpStyleItem
->GetValue();
887 eFillStyle nPos
= NONE
;
891 case drawing::FillStyle_NONE
:
893 mxLbFillAttr
->hide();
894 // "Use slide background" also uses FillStyle_NONE internally,
895 // don't switch listbox in that case (will be handled by updateFillUseBackground)
896 nPos
= meLastXFS
== USE_BACKGROUND
? USE_BACKGROUND
: NONE
;
899 case drawing::FillStyle_SOLID
:
902 case drawing::FillStyle_GRADIENT
:
905 case drawing::FillStyle_HATCH
:
908 case drawing::FillStyle_BITMAP
:
912 if(!mpBitmapItem
->isPattern())
922 meLastXFS
= static_cast< sal_uInt16
>(mxLbFillType
->get_active());
923 mxLbFillType
->set_active(static_cast< sal_Int32
>(nPos
));
924 FillStyleChanged(false);
928 mxLbFillType
->set_active(-1);
929 mxLbFillAttr
->show();
930 mxLbFillAttr
->set_sensitive(false);
931 mxLbFillAttr
->set_active(-1);
932 mxToolBoxColor
->hide();
933 meLastXFS
= static_cast<sal_uInt16
>(-1);
937 void AreaPropertyPanelBase::updateFillGradient(bool bDisabled
, bool bDefaultOrSet
, const SfxPoolItem
* pState
)
941 const XFillGradientItem
* pItem
= static_cast<const XFillGradientItem
*>(pState
);
942 mpFillGradientItem
.reset(pItem
? pItem
->Clone() : nullptr);
945 if(mpStyleItem
&& drawing::FillStyle_GRADIENT
== mpStyleItem
->GetValue())
947 mxLbFillAttr
->hide();
948 mxLbFillGradFrom
->show();
949 mxLbFillGradTo
->show();
951 mxGradientStyle
->show();
952 mxToolBoxColor
->hide();
956 mxLbFillType
->set_active(GRADIENT
);
957 FillStyleChanged(false);
961 mxLbFillGradFrom
->SetNoSelection();
962 mxLbFillGradTo
->SetNoSelection();
963 mxLbFillGradFrom
->set_sensitive(false);
964 mxLbFillGradTo
->set_sensitive(false);
965 mxMTRAngle
->set_sensitive(false);
966 mxGradientStyle
->set_sensitive(false);
970 mxLbFillGradFrom
->SetNoSelection();
971 mxLbFillGradTo
->SetNoSelection();
976 void AreaPropertyPanelBase::updateFillHatch(bool bDisabled
, bool bDefaultOrSet
, const SfxPoolItem
* pState
)
980 const XFillHatchItem
* pItem
= static_cast<const XFillHatchItem
*>(pState
);
981 mpHatchItem
.reset(pItem
? pItem
->Clone() : nullptr);
984 if(mpStyleItem
&& drawing::FillStyle_HATCH
== mpStyleItem
->GetValue())
986 mxLbFillAttr
->show();
987 mxToolBoxColor
->hide();
991 mxLbFillAttr
->set_sensitive(true);
992 mxLbFillType
->set_active(HATCH
);
993 FillStyleChanged(false);
997 mxLbFillAttr
->set_sensitive(false);
998 mxLbFillAttr
->set_active(-1);
1002 mxLbFillAttr
->set_active(-1);
1005 FillStyleChanged(false);
1008 void AreaPropertyPanelBase::updateFillColor(bool bDefaultOrSet
, const SfxPoolItem
* pState
)
1012 const XFillColorItem
* pItem
= static_cast<const XFillColorItem
*>(pState
);
1013 mpColorItem
.reset(pItem
? pItem
->Clone() : nullptr);
1016 if(mpStyleItem
&& drawing::FillStyle_SOLID
== mpStyleItem
->GetValue())
1018 mxLbFillAttr
->hide();
1019 mxToolBoxColor
->show();
1020 mxLbFillType
->set_active(SOLID
);
1021 FillStyleChanged(false);
1025 void AreaPropertyPanelBase::updateFillBitmap(bool bDisabled
, bool bDefaultOrSet
, const SfxPoolItem
* pState
)
1029 const XFillBitmapItem
* pItem
= static_cast<const XFillBitmapItem
*>(pState
);
1030 mpBitmapItem
.reset(pItem
? pItem
->Clone() : nullptr);
1033 if(mpStyleItem
&& drawing::FillStyle_BITMAP
== mpStyleItem
->GetValue())
1035 mxLbFillAttr
->show();
1036 mxToolBoxColor
->hide();
1040 if(mpBitmapItem
->isPattern())
1041 mxLbFillType
->set_active(PATTERN
);
1043 mxLbFillType
->set_active(BITMAP
);
1044 FillStyleChanged(false);
1048 mxLbFillAttr
->hide();
1049 mxLbFillAttr
->set_active(-1);
1053 mxLbFillAttr
->set_active(-1);
1058 void AreaPropertyPanelBase::updateFillUseBackground(bool bDisabled
, bool bDefaultOrSet
, const SfxPoolItem
* pState
)
1067 const XFillUseSlideBackgroundItem
* pItem
= static_cast<const XFillUseSlideBackgroundItem
*>(pState
);
1068 // When XFillUseSlideBackgroundItem is set, select "Use Background Fill".
1069 // When false, select "None" (only if "Use background fill" was selected beforehand)
1070 int nPos
= pItem
->GetValue() ? USE_BACKGROUND
: NONE
;
1071 if ((nPos
== NONE
&& mxLbFillType
->get_active() == USE_BACKGROUND
) || nPos
== USE_BACKGROUND
)
1073 mxLbFillType
->set_active(nPos
);
1074 FillStyleChanged(false);
1080 void AreaPropertyPanelBase::NotifyItemUpdate(
1082 SfxItemState eState
,
1083 const SfxPoolItem
* pState
)
1085 const bool bDisabled(SfxItemState::DISABLED
== eState
);
1086 const bool bDefaultOrSet(SfxItemState::DEFAULT
<= eState
);
1087 const bool bDefault(SfxItemState::DEFAULT
== eState
);
1091 case SID_ATTR_FILL_TRANSPARENCE
:
1092 updateFillTransparence(bDisabled
, bDefaultOrSet
, pState
);
1094 case SID_ATTR_FILL_FLOATTRANSPARENCE
:
1095 updateFillFloatTransparence(bDisabled
, bDefaultOrSet
, pState
);
1097 case SID_ATTR_FILL_STYLE
:
1098 updateFillStyle(bDisabled
, bDefaultOrSet
, pState
);
1100 case SID_ATTR_FILL_COLOR
:
1101 updateFillColor(bDefaultOrSet
, pState
);
1103 case SID_ATTR_FILL_GRADIENT
:
1104 updateFillGradient(bDisabled
, bDefaultOrSet
, pState
);
1106 case SID_ATTR_FILL_HATCH
:
1107 updateFillHatch(bDisabled
, bDefaultOrSet
, pState
);
1109 case SID_ATTR_FILL_BITMAP
:
1110 updateFillBitmap(bDisabled
, bDefaultOrSet
, pState
);
1112 case SID_ATTR_FILL_USE_SLIDE_BACKGROUND
:
1113 updateFillUseBackground(bDisabled
, bDefaultOrSet
, pState
);
1115 case SID_GRADIENT_LIST
:
1119 if(mpStyleItem
&& drawing::FillStyle_GRADIENT
== mpStyleItem
->GetValue())
1121 if(mpFillGradientItem
)
1123 const OUString
aString( mpFillGradientItem
->GetName() );
1124 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
1125 mxLbFillAttr
->clear();
1128 mxLbFillAttr
->set_sensitive(true);
1129 SvxFillAttrBox::Fill(*mxLbFillAttr
, pSh
->GetItem(SID_GRADIENT_LIST
)->GetGradientList());
1131 mxLbFillAttr
->set_active_text(aString
);
1135 mxLbFillAttr
->set_active(-1);
1141 case SID_HATCH_LIST
:
1145 if(mpStyleItem
&& drawing::FillStyle_HATCH
== mpStyleItem
->GetValue())
1149 const OUString
aString( mpHatchItem
->GetName() );
1150 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
1151 mxLbFillAttr
->clear();
1154 mxLbFillAttr
->set_sensitive(true);
1155 SvxFillAttrBox::Fill(*mxLbFillAttr
, pSh
->GetItem(SID_HATCH_LIST
)->GetHatchList());
1157 mxLbFillAttr
->set_active_text(aString
);
1161 mxLbFillAttr
->set_active(-1);
1167 case SID_BITMAP_LIST
:
1168 case SID_PATTERN_LIST
:
1172 if(mpStyleItem
&& drawing::FillStyle_BITMAP
== mpStyleItem
->GetValue())
1176 const OUString
aString( mpBitmapItem
->GetName() );
1177 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
1178 mxLbFillAttr
->clear();
1179 mxLbFillAttr
->show();
1182 if(nSID
== SID_BITMAP_LIST
)
1183 SvxFillAttrBox::Fill(*mxLbFillAttr
, pSh
->GetItem(SID_BITMAP_LIST
)->GetBitmapList());
1184 else if(nSID
== SID_PATTERN_LIST
)
1185 SvxFillAttrBox::Fill(*mxLbFillAttr
, pSh
->GetItem(SID_PATTERN_LIST
)->GetPatternList());
1187 mxLbFillAttr
->set_active_text(aString
);
1191 mxLbFillAttr
->set_active(-1);
1198 FillStyleChanged(false);
1201 IMPL_LINK_NOARG(AreaPropertyPanelBase
, ModifyTransSliderHdl
, weld::Scale
&, void)
1203 const sal_uInt16 nVal
= mxSldTransparent
->get_value();
1204 SetTransparency(nVal
);
1205 const XFillTransparenceItem
aLinearItem(nVal
);
1206 setFillTransparence(aLinearItem
);
1209 IMPL_LINK_NOARG(AreaPropertyPanelBase
, ChangeTrgrTypeHdl_Impl
, weld::ComboBox
&, void)
1211 sal_Int32 nSelectType
= mxLBTransType
->get_active();
1212 bool bGradient
= false;
1213 sal_uInt16 nTrans
= 0;
1217 mxBTNGradient
->hide();
1218 mxMTRTransparent
->show();
1219 mxSldTransparent
->show();
1220 mxMTRTransparent
->set_sensitive(true);
1221 mxSldTransparent
->set_sensitive(true);
1224 else if(1 == nSelectType
)
1226 mxBTNGradient
->hide();
1227 mxMTRTransparent
->show();
1228 mxSldTransparent
->show();
1229 nTrans
= mnLastTransSolid
;
1230 mxMTRTransparent
->set_value(nTrans
, FieldUnit::PERCENT
);
1231 mxLBTransType
->set_active(1);
1232 mxMTRTransparent
->set_sensitive(true);
1233 mxSldTransparent
->set_sensitive(true);
1237 mxBTNGradient
->show();
1239 switch (nSelectType
)
1242 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgLinear
);
1245 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgAxial
);
1248 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgRadial
);
1251 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgElli
);
1254 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgQuad
);
1257 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgSquare
);
1261 mxMTRTransparent
->hide();
1262 mxSldTransparent
->hide();
1263 mxBTNGradient
->set_sensitive(true);
1267 const XFillTransparenceItem
aLinearItem(nTrans
);
1268 setFillTransparence(aLinearItem
);
1275 basegfx::BGradient aTmpGradient
;
1277 switch(static_cast<css::awt::GradientStyle
>(nSelectType
))
1279 case css::awt::GradientStyle_LINEAR
:
1280 aTmpGradient
= maGradientLinear
;
1282 case css::awt::GradientStyle_AXIAL
:
1283 aTmpGradient
= maGradientAxial
;
1285 case css::awt::GradientStyle_RADIAL
:
1286 aTmpGradient
= maGradientRadial
;
1288 case css::awt::GradientStyle_ELLIPTICAL
:
1289 aTmpGradient
= maGradientElliptical
;
1291 case css::awt::GradientStyle_SQUARE
:
1292 aTmpGradient
= maGradientSquare
;
1294 case css::awt::GradientStyle_RECT
:
1295 aTmpGradient
= maGradientRect
;
1301 const XFillFloatTransparenceItem
aGradientItem(aTmpGradient
, bGradient
);
1302 setFillFloatTransparence(aGradientItem
);
1305 IMPL_LINK_NOARG(AreaPropertyPanelBase
, ModifyTransparentHdl_Impl
, weld::MetricSpinButton
&, void)
1307 const sal_uInt16 nTrans
= static_cast<sal_uInt16
>(mxMTRTransparent
->get_value(FieldUnit::PERCENT
));
1308 mnLastTransSolid
= nTrans
;
1309 SetTransparency(nTrans
);
1310 const sal_Int32 nSelectType
= mxLBTransType
->get_active();
1312 if(nTrans
&& !nSelectType
)
1314 mxLBTransType
->set_active(1);
1317 const XFillTransparenceItem
aLinearItem(nTrans
);
1318 setFillTransparence(aLinearItem
);
1321 const basegfx::BGradient
& AreaPropertyPanelBase::GetGradient (const css::awt::GradientStyle eStyle
) const
1326 case css::awt::GradientStyle_LINEAR
:
1327 return maGradientLinear
;
1328 case css::awt::GradientStyle_AXIAL
:
1329 return maGradientAxial
;
1330 case css::awt::GradientStyle_RADIAL
:
1331 return maGradientRadial
;
1332 case css::awt::GradientStyle_ELLIPTICAL
:
1333 return maGradientElliptical
;
1334 case css::awt::GradientStyle_SQUARE
:
1335 return maGradientSquare
;
1336 case css::awt::GradientStyle_RECT
:
1337 return maGradientRect
;
1341 void AreaPropertyPanelBase::SetGradient (const basegfx::BGradient
& rGradient
)
1343 switch (rGradient
.GetGradientStyle())
1345 case css::awt::GradientStyle_LINEAR
:
1346 maGradientLinear
= rGradient
;
1348 case css::awt::GradientStyle_AXIAL
:
1349 maGradientAxial
= rGradient
;
1351 case css::awt::GradientStyle_RADIAL
:
1352 maGradientRadial
= rGradient
;
1354 case css::awt::GradientStyle_ELLIPTICAL
:
1355 maGradientElliptical
= rGradient
;
1357 case css::awt::GradientStyle_SQUARE
:
1358 maGradientSquare
= rGradient
;
1360 case css::awt::GradientStyle_RECT
:
1361 maGradientRect
= rGradient
;
1368 sal_Int32
AreaPropertyPanelBase::GetSelectedTransparencyTypeIndex() const
1370 return mxLBTransType
->get_active();
1373 basegfx::BColorStops
AreaPropertyPanelBase::createColorStops()
1375 basegfx::BColorStops aColorStops
;
1377 if (maColorStops
.size() >= 2)
1379 aColorStops
= maColorStops
;
1380 aColorStops
.front() = basegfx::BColorStop(maColorStops
.front().getStopOffset(),
1381 mxLbFillGradFrom
->GetSelectEntryColor().getBColor());
1382 aColorStops
.back() = basegfx::BColorStop(maColorStops
.back().getStopOffset(),
1383 mxLbFillGradTo
->GetSelectEntryColor().getBColor());
1387 aColorStops
.emplace_back(0.0, mxLbFillGradFrom
->GetSelectEntryColor().getBColor());
1388 aColorStops
.emplace_back(1.0, mxLbFillGradTo
->GetSelectEntryColor().getBColor());
1394 void AreaPropertyPanelBase::HandleContextChange(
1395 const vcl::EnumContext
& rContext
)
1397 if (maContext
.GetApplication() == rContext
.GetApplication())
1400 maContext
= rContext
;
1402 switch (maContext
.GetApplication())
1404 case vcl::EnumContext::Application::Impress
:
1405 if (!msUseBackgroundText
.isEmpty())
1407 mxLbFillType
->insert_text(USE_BACKGROUND
, msUseBackgroundText
);
1408 msUseBackgroundText
= OUString();
1412 if (msUseBackgroundText
.isEmpty())
1414 msUseBackgroundText
= mxLbFillType
->get_text(USE_BACKGROUND
);
1415 mxLbFillType
->remove(USE_BACKGROUND
);
1421 } // end of namespace svx::sidebar
1423 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */