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 <osl/diagnose.h>
21 #include <svx/sidebar/AreaPropertyPanelBase.hxx>
22 #include <svx/drawitem.hxx>
23 #include <svx/itemwin.hxx>
24 #include <svx/svxids.hrc>
25 #include <sfx2/objsh.hxx>
26 #include <svx/xfltrit.hxx>
27 #include <svx/xflftrit.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 OStringLiteral SIDEBARGRADIENT
= "sidebargradient";
41 namespace svx::sidebar
{
57 const sal_Int32
AreaPropertyPanelBase::DEFAULT_CENTERX
= 50;
58 const sal_Int32
AreaPropertyPanelBase::DEFAULT_CENTERY
= 50;
59 const sal_Int32
AreaPropertyPanelBase::DEFAULT_ANGLE
= 0;
60 const sal_Int32
AreaPropertyPanelBase::DEFAULT_STARTVALUE
= 0;
61 const sal_Int32
AreaPropertyPanelBase::DEFAULT_ENDVALUE
= 16777215;
62 const sal_Int32
AreaPropertyPanelBase::DEFAULT_BORDER
= 0;
64 AreaPropertyPanelBase::AreaPropertyPanelBase(
65 weld::Widget
* pParent
,
66 const css::uno::Reference
<css::frame::XFrame
>& rxFrame
)
67 : PanelLayout(pParent
, "AreaPropertyPanel", "svx/ui/sidebararea.ui"),
68 meLastXFS(static_cast<sal_uInt16
>(-1)),
76 maGradientElliptical(),
79 mxColorTextFT(m_xBuilder
->weld_label("filllabel")),
80 mxLbFillType(m_xBuilder
->weld_combo_box("fillstylearea")),
81 mxLbFillAttr(m_xBuilder
->weld_combo_box("fillattrhb")),
82 mxLbFillGradFrom(new ColorListBox(m_xBuilder
->weld_menu_button("fillgrad1"), [this]{ return GetFrameWeld(); })),
83 mxLbFillGradTo(new ColorListBox(m_xBuilder
->weld_menu_button("fillgrad2"), [this]{ return GetFrameWeld(); })),
84 mxToolBoxColor(m_xBuilder
->weld_toolbar("selectcolor")),
85 mxColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxColor
, *m_xBuilder
, rxFrame
)),
86 mxTrspTextFT(m_xBuilder
->weld_label("transparencylabel")),
87 mxLBTransType(m_xBuilder
->weld_combo_box("transtype")),
88 mxMTRTransparent(m_xBuilder
->weld_metric_spin_button("settransparency", FieldUnit::PERCENT
)),
89 mxSldTransparent(m_xBuilder
->weld_scale("transparencyslider")),
90 mxBTNGradient(m_xBuilder
->weld_toolbar("selectgradient")),
91 mxMTRAngle(m_xBuilder
->weld_metric_spin_button("gradangle", FieldUnit::DEGREE
)),
92 mxGradientStyle(m_xBuilder
->weld_combo_box("gradientstyle")),
93 mxBmpImport(m_xBuilder
->weld_button("bmpimport")),
99 maImgAxial(BMP_AXIAL
),
102 maImgRadial(BMP_RADIAL
),
103 maImgSquare(BMP_SQUARE
),
104 maImgLinear(BMP_LINEAR
),
105 mpFloatTransparenceItem(),
111 AreaPropertyPanelBase::~AreaPropertyPanelBase()
114 mxColorTextFT
.reset();
115 mxLbFillType
.reset();
116 mxLbFillAttr
.reset();
117 mxColorDispatch
.reset();
118 mxToolBoxColor
.reset();
119 mxTrspTextFT
.reset();
120 mxLBTransType
.reset();
121 mxMTRTransparent
.reset();
122 mxSldTransparent
.reset();
123 mxBTNGradient
.reset();
125 mxLbFillGradFrom
.reset();
126 mxLbFillGradTo
.reset();
127 mxGradientStyle
.reset();
131 void AreaPropertyPanelBase::Initialize()
133 SvxFillTypeBox::Fill(*mxLbFillType
);
135 mxLbFillAttr
->set_size_request(42, -1);
137 maGradientLinear
.SetXOffset(DEFAULT_CENTERX
);
138 maGradientLinear
.SetYOffset(DEFAULT_CENTERY
);
139 maGradientLinear
.SetAngle(Degree10(DEFAULT_ANGLE
));
140 maGradientLinear
.SetStartColor(Color(DEFAULT_STARTVALUE
));
141 maGradientLinear
.SetEndColor(Color(DEFAULT_ENDVALUE
));
142 maGradientLinear
.SetBorder(DEFAULT_BORDER
);
143 maGradientLinear
.SetGradientStyle(css::awt::GradientStyle_LINEAR
);
145 maGradientAxial
= maGradientLinear
;
146 maGradientAxial
.SetGradientStyle(css::awt::GradientStyle_AXIAL
);
148 maGradientRadial
= maGradientLinear
;
149 maGradientRadial
.SetGradientStyle(css::awt::GradientStyle_RADIAL
);
151 maGradientElliptical
= maGradientLinear
;
152 maGradientElliptical
.SetGradientStyle(css::awt::GradientStyle_ELLIPTICAL
);
154 maGradientSquare
= maGradientLinear
;
155 maGradientSquare
.SetGradientStyle(css::awt::GradientStyle_SQUARE
);
157 maGradientRect
= maGradientLinear
;
158 maGradientRect
.SetGradientStyle(css::awt::GradientStyle_RECT
);
161 mxLbFillType
->connect_changed( LINK( this, AreaPropertyPanelBase
, SelectFillTypeHdl
) );
163 Link
<weld::ComboBox
&,void> aLink
= LINK( this, AreaPropertyPanelBase
, SelectFillAttrHdl
);
164 mxLbFillAttr
->connect_changed( aLink
);
165 mxGradientStyle
->connect_changed( aLink
);
166 Link
<ColorListBox
&,void> aLink3
= LINK( this, AreaPropertyPanelBase
, SelectFillColorHdl
);
167 mxLbFillGradFrom
->SetSelectHdl( aLink3
);
168 mxLbFillGradTo
->SetSelectHdl( aLink3
);
169 mxMTRAngle
->connect_value_changed(LINK(this,AreaPropertyPanelBase
, ChangeGradientAngle
));
171 // https://gerrit.libreoffice.org/c/core/+/87313 set a small width to force widgets to
172 // take their final width from other widgets in the grid
173 mxLbFillGradFrom
->get_widget().set_size_request(42, -1);
174 mxLbFillGradTo
->get_widget().set_size_request(42, -1);
176 mxLBTransType
->connect_changed(LINK(this, AreaPropertyPanelBase
, ChangeTrgrTypeHdl_Impl
));
178 SetTransparency( 50 );
179 mxMTRTransparent
->connect_value_changed(LINK(this, AreaPropertyPanelBase
, ModifyTransparentHdl_Impl
));
180 mxSldTransparent
->connect_value_changed(LINK(this, AreaPropertyPanelBase
, ModifyTransSliderHdl
));
182 mxTrGrPopup
= std::make_unique
<AreaTransparencyGradientPopup
>(*this, mxBTNGradient
.get());
184 mxBTNGradient
->set_item_popover(SIDEBARGRADIENT
, mxTrGrPopup
->getTopLevel());
185 mxBTNGradient
->connect_clicked(LINK(this, AreaPropertyPanelBase
, ToolbarHdl_Impl
));
187 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgLinear
);
188 mxBTNGradient
->hide();
189 mxBmpImport
->connect_clicked( LINK(this, AreaPropertyPanelBase
, ClickImportBitmapHdl
));
192 IMPL_LINK_NOARG(AreaPropertyPanelBase
, ToolbarHdl_Impl
, const OString
&, void)
194 mxBTNGradient
->set_menu_item_active(SIDEBARGRADIENT
, !mxBTNGradient
->get_menu_item_active(SIDEBARGRADIENT
));
197 void AreaPropertyPanelBase::SetTransparency(sal_uInt16 nVal
)
199 mxSldTransparent
->set_value(nVal
);
200 mxMTRTransparent
->set_value(nVal
, FieldUnit::PERCENT
);
203 IMPL_LINK_NOARG(AreaPropertyPanelBase
, ClickImportBitmapHdl
, weld::Button
&, void)
205 SvxOpenGraphicDialog
aDlg("Import", GetFrameWeld());
206 aDlg
.EnableLink(false);
207 if( aDlg
.Execute() != ERRCODE_NONE
)
211 auto xWait
= std::make_unique
<weld::WaitObject
>(m_xContainer
.get());
212 ErrCode nError
= aDlg
.GetGraphic( aGraphic
);
214 if( nError
!= ERRCODE_NONE
)
217 XBitmapListRef pList
= SfxObjectShell::Current()->GetItem(SID_BITMAP_LIST
)->GetBitmapList();
218 INetURLObject
aURL( aDlg
.GetPath() );
219 OUString aFileName
= aURL
.GetLastName().getToken(0, '.');
220 OUString aName
= aFileName
;
222 bool bValidBitmapName
= false;
223 while( !bValidBitmapName
)
225 bValidBitmapName
= true;
226 for( tools::Long i
= 0; i
< pList
->Count() && bValidBitmapName
; i
++ )
228 if( aName
== pList
->GetBitmap(i
)->GetName() )
230 bValidBitmapName
= false;
231 aName
= aFileName
+ OUString::number(j
++);
236 pList
->Insert(std::make_unique
<XBitmapEntry
>(aGraphic
, aName
));
238 mxLbFillAttr
->clear();
239 SvxFillAttrBox::Fill(*mxLbFillAttr
, pList
);
240 mxLbFillAttr
->set_active_text(aName
);
241 SelectFillAttrHdl(*mxLbFillAttr
);
244 IMPL_LINK_NOARG(AreaPropertyPanelBase
, SelectFillTypeHdl
, weld::ComboBox
&, void)
246 sal_Int32 nPos
= static_cast<eFillStyle
>(mxLbFillType
->get_active());
247 mxLbFillAttr
->clear();
248 SfxObjectShell
* pSh
= SfxObjectShell::Current();
252 // #i122676# Do no longer trigger two Execute calls, one for SID_ATTR_FILL_STYLE
253 // and one for setting the fill attribute itself, but add two SfxPoolItems to the
254 // call to get just one action at the SdrObject and to create only one Undo action, too.
255 // Checked that this works in all apps.
261 mxLbFillAttr
->show();
262 mxLbFillGradFrom
->hide();
263 mxLbFillGradTo
->hide();
264 mxGradientStyle
->hide();
266 mxToolBoxColor
->hide();
268 mxLbFillAttr
->set_sensitive(false);
270 // #i122676# need to call a single SID_ATTR_FILL_STYLE change
271 setFillStyle(XFillStyleItem(drawing::FillStyle_NONE
));
276 mxLbFillAttr
->hide();
277 mxLbFillGradFrom
->hide();
278 mxLbFillGradTo
->hide();
279 mxGradientStyle
->hide();
282 mxToolBoxColor
->show();
283 const Color aColor
= mpColorItem
? mpColorItem
->GetColorValue() : COL_AUTO
;
284 const XFillColorItem
aXFillColorItem( "", aColor
);
286 // #i122676# change FillStyle and Color in one call
287 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_SOLID
);
288 setFillStyleAndColor(&aXFillStyleItem
, aXFillColorItem
);
293 mxLbFillAttr
->hide();
294 mxLbFillGradFrom
->show();
295 mxLbFillGradTo
->show();
296 mxGradientStyle
->show();
298 mxToolBoxColor
->hide();
301 mxLbFillAttr
->set_sensitive(true);
302 mxLbFillGradTo
->set_sensitive(true);
303 mxLbFillGradFrom
->set_sensitive(true);
304 mxGradientStyle
->set_sensitive(true);
305 mxMTRAngle
->set_sensitive(true);
306 mxLbFillAttr
->clear();
308 const SvxGradientListItem
* pItem
= pSh
->GetItem(SID_GRADIENT_LIST
);
310 if(0 < pItem
->GetGradientList()->Count())
312 const XGradient aGradient
= pItem
->GetGradientList()->GetGradient(0)->GetGradient();
313 const OUString aName
= pItem
->GetGradientList()->GetGradient(0)->GetName();
314 const XFillGradientItem
aXFillGradientItem(aName
, aGradient
);
316 // #i122676# change FillStyle and Gradient in one call
317 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_GRADIENT
);
318 setFillStyleAndGradient(&aXFillStyleItem
, aXFillGradientItem
);
319 mxLbFillGradFrom
->SelectEntry(aGradient
.GetStartColor());
320 mxLbFillGradTo
->SelectEntry(aGradient
.GetEndColor());
322 mxMTRAngle
->set_value(aGradient
.GetAngle().get() / 10, FieldUnit::DEGREE
);
323 css::awt::GradientStyle eXGS
= aGradient
.GetGradientStyle();
324 mxGradientStyle
->set_active(sal::static_int_cast
< sal_Int32
>( eXGS
));
330 mxLbFillAttr
->show();
331 mxLbFillGradFrom
->hide();
332 mxLbFillGradTo
->hide();
334 mxGradientStyle
->hide();
335 mxToolBoxColor
->hide();
338 const SvxHatchListItem
* pItem( pSh
->GetItem(SID_HATCH_LIST
) );
341 const XHatchListRef
& pXHatchList(pItem
->GetHatchList());
342 mxLbFillAttr
->set_sensitive(true);
343 mxLbFillAttr
->clear();
344 SvxFillAttrBox::Fill(*mxLbFillAttr
, pXHatchList
);
346 if (mnLastPosHatch
!= -1)
348 if(mnLastPosHatch
< pXHatchList
->Count())
350 const XHatch aHatch
= pXHatchList
->GetHatch(mnLastPosHatch
)->GetHatch();
351 const OUString aName
= pXHatchList
->GetHatch(mnLastPosHatch
)->GetName();
352 const XFillHatchItem
aXFillHatchItem(aName
, aHatch
);
354 // #i122676# change FillStyle and Hatch in one call
355 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_HATCH
);
356 setFillStyleAndHatch(&aXFillStyleItem
, aXFillHatchItem
);
357 mxLbFillAttr
->set_active(mnLastPosHatch
);
363 mxLbFillAttr
->set_sensitive(false);
370 mxLbFillAttr
->show();
371 mxLbFillAttr
->set_sensitive(true);
372 mxLbFillAttr
->clear();
373 mxLbFillGradFrom
->hide();
374 mxLbFillGradTo
->hide();
376 mxGradientStyle
->hide();
377 mxToolBoxColor
->hide();
380 GraphicObject aBitmap
;
381 if(nPos
== static_cast< sal_Int32
>(BITMAP
))
383 if (!comphelper::LibreOfficeKit::isActive())
385 const SvxBitmapListItem
* pItem
= pSh
->GetItem(SID_BITMAP_LIST
);
388 const XBitmapListRef
& pXBitmapList(pItem
->GetBitmapList());
389 SvxFillAttrBox::Fill(*mxLbFillAttr
, pXBitmapList
);
391 if (mnLastPosBitmap
!= -1)
393 if(mnLastPosBitmap
< pXBitmapList
->Count())
395 const XBitmapEntry
* pXBitmapEntry
= pXBitmapList
->GetBitmap(mnLastPosBitmap
);
396 aBitmap
= pXBitmapEntry
->GetGraphicObject();
397 aName
= pXBitmapEntry
->GetName();
398 mxLbFillAttr
->set_active(mnLastPosBitmap
);
404 mxLbFillAttr
->hide();
407 else if(nPos
== static_cast< sal_Int32
>(PATTERN
))
410 const SvxPatternListItem
* pItem
= pSh
->GetItem(SID_PATTERN_LIST
);
413 const XPatternListRef
& pXPatternList(pItem
->GetPatternList());
414 SvxFillAttrBox::Fill(*mxLbFillAttr
, pXPatternList
);
416 if (mnLastPosPattern
!= -1)
418 if(mnLastPosPattern
< pXPatternList
->Count())
420 const XBitmapEntry
* pXPatternEntry
= pXPatternList
->GetBitmap(mnLastPosPattern
);
421 aBitmap
= pXPatternEntry
->GetGraphicObject();
422 aName
= pXPatternEntry
->GetName();
423 mxLbFillAttr
->set_active(mnLastPosPattern
);
429 mxLbFillAttr
->hide();
432 const XFillBitmapItem
aXFillBitmapItem( aName
, aBitmap
);
433 const XFillStyleItem
aXFillStyleItem(drawing::FillStyle_BITMAP
);
434 setFillStyleAndBitmap(&aXFillStyleItem
, aXFillBitmapItem
);
439 meLastXFS
= static_cast<sal_uInt16
>(nPos
);
442 m_pPanel
->TriggerDeckLayouting();
445 IMPL_LINK_NOARG(AreaPropertyPanelBase
, SelectFillColorHdl
, ColorListBox
&, void)
447 SelectFillAttrHdl_Impl();
450 IMPL_LINK_NOARG(AreaPropertyPanelBase
, SelectFillAttrHdl
, weld::ComboBox
&, void)
452 SelectFillAttrHdl_Impl();
455 IMPL_LINK_NOARG(AreaPropertyPanelBase
, ChangeGradientAngle
, weld::MetricSpinButton
&, void)
457 SelectFillAttrHdl_Impl();
460 void AreaPropertyPanelBase::SelectFillAttrHdl_Impl()
462 sal_Int32 nPosFillStyle
= static_cast<eFillStyle
>(mxLbFillType
->get_active());
463 SfxObjectShell
* pSh
= SfxObjectShell::Current();
465 // #i122676# dependent from bFillStyleChange, do execute a single or two
466 // changes in one Execute call
467 const bool bFillStyleChange(static_cast<eFillStyle
>(meLastXFS
) != static_cast<eFillStyle
>(nPosFillStyle
));
469 switch(nPosFillStyle
)
471 case eFillStyle::NONE
:
475 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_NONE
);
476 setFillStyle(aXFillStyleItem
);
480 case eFillStyle::SOLID
:
484 // #i122676# Single FillStyle change call needed here
485 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_SOLID
);
486 setFillStyle(aXFillStyleItem
);
490 case eFillStyle::GRADIENT
:
493 if(pSh
&& pSh
->GetItem(SID_COLOR_TABLE
))
496 aGradient
.SetAngle(Degree10(mxMTRAngle
->get_value(FieldUnit::DEGREE
) * 10));
497 aGradient
.SetGradientStyle(static_cast<css::awt::GradientStyle
>(mxGradientStyle
->get_active()));
498 aGradient
.SetStartColor(mxLbFillGradFrom
->GetSelectEntryColor());
499 aGradient
.SetEndColor(mxLbFillGradTo
->GetSelectEntryColor());
501 const XFillGradientItem
aXFillGradientItem(mxLbFillAttr
->get_active_text(), aGradient
);
503 // #i122676# Change FillStyle and Gradient in one call
504 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_GRADIENT
);
505 setFillStyleAndGradient(bFillStyleChange
? &aXFillStyleItem
: nullptr, aXFillGradientItem
);
509 case eFillStyle::HATCH
:
511 sal_Int32 nPos
= mxLbFillAttr
->get_active();
515 nPos
= mnLastPosHatch
;
518 if (nPos
!= -1 && pSh
&& pSh
->GetItem(SID_HATCH_LIST
))
520 const SvxHatchListItem
* pItem
= pSh
->GetItem(SID_HATCH_LIST
);
522 if(nPos
< pItem
->GetHatchList()->Count())
524 const XHatch aHatch
= pItem
->GetHatchList()->GetHatch(nPos
)->GetHatch();
525 const XFillHatchItem
aXFillHatchItem( mxLbFillAttr
->get_active_text(), aHatch
);
527 // #i122676# Change FillStyle and Hatch in one call
528 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_HATCH
);
529 setFillStyleAndHatch(bFillStyleChange
? &aXFillStyleItem
: nullptr, aXFillHatchItem
);
535 mnLastPosHatch
= nPos
;
539 case eFillStyle::BITMAP
:
541 sal_Int32 nPos
= mxLbFillAttr
->get_active();
545 nPos
= mnLastPosBitmap
;
548 if (nPos
!= -1 && pSh
&& pSh
->GetItem(SID_BITMAP_LIST
))
550 const SvxBitmapListItem
* pItem
= pSh
->GetItem(SID_BITMAP_LIST
);
552 if(nPos
< pItem
->GetBitmapList()->Count())
554 const XBitmapEntry
* pXBitmapEntry
= pItem
->GetBitmapList()->GetBitmap(nPos
);
555 const XFillBitmapItem
aXFillBitmapItem(mxLbFillAttr
->get_active_text(), pXBitmapEntry
->GetGraphicObject());
557 // #i122676# Change FillStyle and Bitmap in one call
558 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_BITMAP
);
559 setFillStyleAndBitmap(bFillStyleChange
? &aXFillStyleItem
: nullptr, aXFillBitmapItem
);
565 mnLastPosBitmap
= nPos
;
569 case eFillStyle::PATTERN
:
571 sal_Int32 nPos
= mxLbFillAttr
->get_active();
575 nPos
= mnLastPosPattern
;
578 if (nPos
!= -1 && pSh
&& pSh
->GetItem(SID_PATTERN_LIST
))
580 const SvxPatternListItem
* pItem
= pSh
->GetItem(SID_PATTERN_LIST
);
582 if(nPos
< pItem
->GetPatternList()->Count())
584 const XBitmapEntry
* pXPatternEntry
= pItem
->GetPatternList()->GetBitmap(nPos
);
585 const XFillBitmapItem
aXFillBitmapItem(mxLbFillAttr
->get_active_text(), pXPatternEntry
->GetGraphicObject());
587 // #i122676# Change FillStyle and Bitmap in one call
588 XFillStyleItem
aXFillStyleItem(drawing::FillStyle_BITMAP
);
589 setFillStyleAndBitmap(bFillStyleChange
? &aXFillStyleItem
: nullptr, aXFillBitmapItem
);
595 mnLastPosPattern
= nPos
;
601 m_pPanel
->TriggerDeckLayouting();
604 void AreaPropertyPanelBase::ImpUpdateTransparencies()
606 if(mpTransparanceItem
|| mpFloatTransparenceItem
)
608 bool bZeroValue(false);
610 if (mpTransparanceItem
)
612 const sal_uInt16
nValue(mpTransparanceItem
->GetValue());
618 else if(nValue
<= 100)
620 mxLBTransType
->set_sensitive(true);
621 mxTrspTextFT
->set_sensitive(true);
622 mxLBTransType
->set_active(1);
623 mxBTNGradient
->hide();
624 mxMTRTransparent
->show();
625 mxSldTransparent
->show();
626 mxMTRTransparent
->set_sensitive(true);
627 mxSldTransparent
->set_sensitive(true);
628 SetTransparency(nValue
);
631 if (!bZeroValue
&& mxTrGrPopup
)
633 mxBTNGradient
->set_menu_item_active(SIDEBARGRADIENT
, false);
637 if(bZeroValue
&& mpFloatTransparenceItem
)
639 if(mpFloatTransparenceItem
->IsEnabled())
641 const XGradient
& rGradient
= mpFloatTransparenceItem
->GetGradientValue();
642 sal_Int32
nEntryPos(0);
643 OUString
* pImage
= nullptr;
645 mxLBTransType
->set_sensitive(true);
646 mxTrspTextFT
->set_sensitive(true);
647 mxMTRTransparent
->hide();
648 mxSldTransparent
->hide();
649 mxBTNGradient
->set_sensitive(true);
650 mxBTNGradient
->show();
652 switch(rGradient
.GetGradientStyle())
655 case css::awt::GradientStyle_LINEAR
:
658 pImage
= &maImgLinear
;
661 case css::awt::GradientStyle_AXIAL
:
664 pImage
= &maImgAxial
;
667 case css::awt::GradientStyle_RADIAL
:
670 pImage
= &maImgRadial
;
673 case css::awt::GradientStyle_ELLIPTICAL
:
679 case css::awt::GradientStyle_SQUARE
:
685 case css::awt::GradientStyle_RECT
:
688 pImage
= &maImgSquare
;
692 mxLBTransType
->set_active(nEntryPos
);
693 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, *pImage
);
694 mxTrGrPopup
->Rearrange(mpFloatTransparenceItem
.get());
705 mxLBTransType
->set_sensitive(true);
706 mxTrspTextFT
->set_sensitive(true);
707 mxLBTransType
->set_active(0);
708 mxBTNGradient
->hide();
709 mxMTRTransparent
->set_sensitive(true);
710 mxSldTransparent
->set_sensitive(true);
711 mxMTRTransparent
->show();
712 mxSldTransparent
->show();
718 // no transparency at all
719 mxLBTransType
->set_active(-1);
720 mxLBTransType
->set_sensitive(false);
721 mxTrspTextFT
->set_sensitive(false);
722 mxMTRTransparent
->set_sensitive(false);
723 mxSldTransparent
->set_sensitive(false);
724 mxMTRTransparent
->show();
725 mxSldTransparent
->show();
726 mxBTNGradient
->set_sensitive(false);
727 mxBTNGradient
->hide();
731 void AreaPropertyPanelBase::updateFillTransparence(bool bDisabled
, bool bDefaultOrSet
, const SfxPoolItem
* pState
)
735 mpTransparanceItem
.reset();
738 else if (bDefaultOrSet
)
742 const SfxUInt16Item
* pItem
= static_cast<const SfxUInt16Item
*>(pState
);
743 mpTransparanceItem
.reset(pItem
->Clone());
747 mpTransparanceItem
.reset();
752 mpTransparanceItem
.reset();
755 // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem
756 ImpUpdateTransparencies();
759 void AreaPropertyPanelBase::updateFillFloatTransparence(bool bDisabled
, bool bDefaultOrSet
, const SfxPoolItem
* pState
)
763 mpFloatTransparenceItem
.reset();
771 const XFillFloatTransparenceItem
* pItem
= static_cast<const XFillFloatTransparenceItem
*>(pState
);
772 mpFloatTransparenceItem
.reset(pItem
->Clone());
776 mpFloatTransparenceItem
.reset();
781 mpFloatTransparenceItem
.reset();
784 // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem
785 ImpUpdateTransparencies();
788 void AreaPropertyPanelBase::updateFillStyle(bool bDisabled
, bool bDefaultOrSet
, const SfxPoolItem
* pState
)
792 mxLbFillType
->set_sensitive(false);
793 mxColorTextFT
->set_sensitive(false);
794 mxLbFillType
->set_active(-1);
795 mxLbFillAttr
->show();
796 mxLbFillAttr
->set_sensitive(false);
797 mxLbFillAttr
->set_active(-1);
798 mxToolBoxColor
->hide();
799 meLastXFS
= static_cast<sal_uInt16
>(-1);
802 else if (bDefaultOrSet
&& pState
)
804 const XFillStyleItem
* pItem
= static_cast<const XFillStyleItem
*>(pState
);
805 mpStyleItem
.reset(pItem
->Clone());
806 mxLbFillType
->set_sensitive(true);
807 mxColorTextFT
->set_sensitive(true);
808 drawing::FillStyle eXFS
= mpStyleItem
->GetValue();
809 eFillStyle nPos
= NONE
;
813 case drawing::FillStyle_NONE
:
815 mxLbFillAttr
->set_active(-1);
816 mxLbFillAttr
->set_sensitive(false);
820 case drawing::FillStyle_SOLID
:
823 case drawing::FillStyle_GRADIENT
:
826 case drawing::FillStyle_HATCH
:
829 case drawing::FillStyle_BITMAP
:
833 if(!mpBitmapItem
->isPattern())
843 meLastXFS
= static_cast< sal_uInt16
>(mxLbFillType
->get_active());
844 mxLbFillType
->set_active(static_cast< sal_Int32
>(nPos
));
849 mxLbFillType
->set_active(-1);
850 mxLbFillAttr
->show();
851 mxLbFillAttr
->set_sensitive(false);
852 mxLbFillAttr
->set_active(-1);
853 mxToolBoxColor
->hide();
854 meLastXFS
= static_cast<sal_uInt16
>(-1);
857 m_pPanel
->TriggerDeckLayouting();
860 void AreaPropertyPanelBase::updateFillGradient(bool bDisabled
, bool bDefaultOrSet
, const SfxPoolItem
* pState
)
864 const XFillGradientItem
* pItem
= static_cast<const XFillGradientItem
*>(pState
);
865 mpFillGradientItem
.reset(pItem
? pItem
->Clone() : nullptr);
868 if(mpStyleItem
&& drawing::FillStyle_GRADIENT
== mpStyleItem
->GetValue())
870 mxLbFillAttr
->hide();
871 mxLbFillGradFrom
->show();
872 mxLbFillGradTo
->show();
874 mxGradientStyle
->show();
875 mxToolBoxColor
->hide();
879 mxLbFillType
->set_active(GRADIENT
);
884 mxLbFillGradFrom
->SetNoSelection();
885 mxLbFillGradTo
->SetNoSelection();
886 mxLbFillGradFrom
->set_sensitive(false);
887 mxLbFillGradTo
->set_sensitive(false);
888 mxMTRAngle
->set_sensitive(false);
889 mxGradientStyle
->set_sensitive(false);
893 mxLbFillGradFrom
->SetNoSelection();
894 mxLbFillGradTo
->SetNoSelection();
898 m_pPanel
->TriggerDeckLayouting();
901 void AreaPropertyPanelBase::updateFillHatch(bool bDisabled
, bool bDefaultOrSet
, const SfxPoolItem
* pState
)
905 const XFillHatchItem
* pItem
= static_cast<const XFillHatchItem
*>(pState
);
906 mpHatchItem
.reset(pItem
? pItem
->Clone() : nullptr);
909 if(mpStyleItem
&& drawing::FillStyle_HATCH
== mpStyleItem
->GetValue())
911 mxLbFillAttr
->show();
912 mxToolBoxColor
->hide();
916 mxLbFillAttr
->set_sensitive(true);
917 mxLbFillType
->set_active(HATCH
);
922 mxLbFillAttr
->set_sensitive(false);
923 mxLbFillAttr
->set_active(-1);
927 mxLbFillAttr
->set_active(-1);
931 m_pPanel
->TriggerDeckLayouting();
934 void AreaPropertyPanelBase::updateFillColor(bool bDefaultOrSet
, const SfxPoolItem
* pState
)
938 const XFillColorItem
* pItem
= static_cast<const XFillColorItem
*>(pState
);
939 mpColorItem
.reset(pItem
? pItem
->Clone() : nullptr);
942 if(mpStyleItem
&& drawing::FillStyle_SOLID
== mpStyleItem
->GetValue())
944 mxLbFillAttr
->hide();
945 mxToolBoxColor
->show();
946 mxLbFillType
->set_active(SOLID
);
950 m_pPanel
->TriggerDeckLayouting();
953 void AreaPropertyPanelBase::updateFillBitmap(bool bDisabled
, bool bDefaultOrSet
, const SfxPoolItem
* pState
)
957 const XFillBitmapItem
* pItem
= static_cast<const XFillBitmapItem
*>(pState
);
958 mpBitmapItem
.reset(pItem
? pItem
->Clone() : nullptr);
961 if(mpStyleItem
&& drawing::FillStyle_BITMAP
== mpStyleItem
->GetValue())
963 mxLbFillAttr
->show();
964 mxToolBoxColor
->hide();
968 if(mpBitmapItem
->isPattern())
969 mxLbFillType
->set_active(PATTERN
);
971 mxLbFillType
->set_active(BITMAP
);
976 mxLbFillAttr
->hide();
977 mxLbFillAttr
->set_active(-1);
981 mxLbFillAttr
->set_active(-1);
985 m_pPanel
->TriggerDeckLayouting();
988 void AreaPropertyPanelBase::NotifyItemUpdate(
991 const SfxPoolItem
* pState
)
993 const bool bDisabled(SfxItemState::DISABLED
== eState
);
994 const bool bDefaultOrSet(SfxItemState::DEFAULT
<= eState
);
995 const bool bDefault(SfxItemState::DEFAULT
== eState
);
999 case SID_ATTR_FILL_TRANSPARENCE
:
1000 updateFillTransparence(bDisabled
, bDefaultOrSet
, pState
);
1002 case SID_ATTR_FILL_FLOATTRANSPARENCE
:
1003 updateFillFloatTransparence(bDisabled
, bDefaultOrSet
, pState
);
1005 case SID_ATTR_FILL_STYLE
:
1006 updateFillStyle(bDisabled
, bDefaultOrSet
, pState
);
1008 case SID_ATTR_FILL_COLOR
:
1009 updateFillColor(bDefaultOrSet
, pState
);
1011 case SID_ATTR_FILL_GRADIENT
:
1012 updateFillGradient(bDisabled
, bDefaultOrSet
, pState
);
1014 case SID_ATTR_FILL_HATCH
:
1015 updateFillHatch(bDisabled
, bDefaultOrSet
, pState
);
1017 case SID_ATTR_FILL_BITMAP
:
1018 updateFillBitmap(bDisabled
, bDefaultOrSet
, pState
);
1020 case SID_GRADIENT_LIST
:
1024 if(mpStyleItem
&& drawing::FillStyle_GRADIENT
== mpStyleItem
->GetValue())
1026 if(mpFillGradientItem
)
1028 const OUString
aString( mpFillGradientItem
->GetName() );
1029 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
1031 mxLbFillAttr
->clear();
1032 mxLbFillAttr
->set_sensitive(true);
1033 SvxFillAttrBox::Fill(*mxLbFillAttr
, pSh
->GetItem(SID_GRADIENT_LIST
)->GetGradientList());
1034 mxLbFillAttr
->set_active_text(aString
);
1038 mxLbFillAttr
->set_active(-1);
1044 case SID_HATCH_LIST
:
1048 if(mpStyleItem
&& drawing::FillStyle_HATCH
== mpStyleItem
->GetValue())
1052 const OUString
aString( mpHatchItem
->GetName() );
1053 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
1055 mxLbFillAttr
->clear();
1056 mxLbFillAttr
->set_sensitive(true);
1057 SvxFillAttrBox::Fill(*mxLbFillAttr
, pSh
->GetItem(SID_HATCH_LIST
)->GetHatchList());
1058 mxLbFillAttr
->set_active_text(aString
);
1062 mxLbFillAttr
->set_active(-1);
1068 case SID_BITMAP_LIST
:
1069 case SID_PATTERN_LIST
:
1073 if(mpStyleItem
&& drawing::FillStyle_BITMAP
== mpStyleItem
->GetValue())
1077 const OUString
aString( mpBitmapItem
->GetName() );
1078 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
1079 mxLbFillAttr
->clear();
1080 mxLbFillAttr
->show();
1081 if(nSID
== SID_BITMAP_LIST
)
1083 SvxFillAttrBox::Fill(*mxLbFillAttr
, pSh
->GetItem(SID_BITMAP_LIST
)->GetBitmapList());
1085 else if(nSID
== SID_PATTERN_LIST
)
1087 SvxFillAttrBox::Fill(*mxLbFillAttr
, pSh
->GetItem(SID_PATTERN_LIST
)->GetPatternList());
1089 mxLbFillAttr
->set_active_text(aString
);
1093 mxLbFillAttr
->set_active(-1);
1102 void AreaPropertyPanelBase::Update()
1104 const eFillStyle eXFS
= static_cast<eFillStyle
>(mxLbFillType
->get_active());
1105 SfxObjectShell
* pSh
= SfxObjectShell::Current();
1109 case eFillStyle::NONE
:
1111 mxLbFillAttr
->show();
1112 mxLbFillGradFrom
->hide();
1113 mxLbFillGradTo
->hide();
1115 mxGradientStyle
->hide();
1116 mxToolBoxColor
->hide();
1117 mxBmpImport
->hide();
1120 case eFillStyle::SOLID
:
1124 mxLbFillAttr
->hide();
1125 mxLbFillGradFrom
->hide();
1126 mxLbFillGradTo
->hide();
1128 mxGradientStyle
->hide();
1129 mxToolBoxColor
->show();
1130 mxBmpImport
->hide();
1134 case eFillStyle::GRADIENT
:
1136 mxLbFillAttr
->hide();
1137 mxLbFillGradFrom
->show();
1138 mxLbFillGradTo
->show();
1139 mxMTRAngle
->set_sensitive(true);
1141 mxGradientStyle
->show();
1142 mxToolBoxColor
->hide();
1143 mxBmpImport
->hide();
1145 if(pSh
&& pSh
->GetItem(SID_GRADIENT_LIST
))
1147 mxLbFillAttr
->set_sensitive(true);
1148 mxLbFillAttr
->clear();
1149 SvxFillAttrBox::Fill(*mxLbFillAttr
, pSh
->GetItem(SID_GRADIENT_LIST
)->GetGradientList());
1150 mxLbFillGradTo
->SetNoSelection();
1151 mxLbFillGradFrom
->SetNoSelection();
1152 if (mpFillGradientItem
)
1154 const OUString
aString(mpFillGradientItem
->GetName());
1155 mxLbFillAttr
->set_active_text(aString
);
1156 const XGradient aGradient
= mpFillGradientItem
->GetGradientValue();
1157 mxLbFillGradFrom
->SelectEntry(aGradient
.GetStartColor());
1158 mxLbFillGradTo
->SelectEntry(aGradient
.GetEndColor());
1159 mxGradientStyle
->set_active(sal::static_int_cast
< sal_Int32
>( aGradient
.GetGradientStyle() ));
1160 if(mxGradientStyle
->get_active() == sal_Int32(GradientStyle::Radial
))
1161 mxMTRAngle
->set_sensitive(false);
1163 mxMTRAngle
->set_value(aGradient
.GetAngle().get() / 10, FieldUnit::DEGREE
);
1167 mxLbFillAttr
->set_active(-1);
1172 mxLbFillAttr
->set_active(-1);
1176 case eFillStyle::HATCH
:
1178 mxLbFillAttr
->show();
1179 mxLbFillGradFrom
->hide();
1180 mxLbFillGradTo
->hide();
1182 mxGradientStyle
->hide();
1183 mxToolBoxColor
->hide();
1184 mxBmpImport
->hide();
1185 mxBmpImport
->hide();
1187 if(pSh
&& pSh
->GetItem(SID_HATCH_LIST
))
1189 mxLbFillAttr
->set_sensitive(true);
1190 mxLbFillAttr
->clear();
1191 SvxFillAttrBox::Fill(*mxLbFillAttr
, pSh
->GetItem(SID_HATCH_LIST
)->GetHatchList());
1195 const OUString
aString(mpHatchItem
->GetName());
1197 mxLbFillAttr
->set_active_text( aString
);
1201 mxLbFillAttr
->set_active(-1);
1206 mxLbFillAttr
->set_active(-1);
1210 case eFillStyle::BITMAP
:
1211 case eFillStyle::PATTERN
:
1213 mxLbFillAttr
->show();
1214 mxLbFillAttr
->set_sensitive(true);
1215 mxLbFillAttr
->clear();
1216 mxToolBoxColor
->hide();
1217 mxLbFillGradFrom
->hide();
1218 mxLbFillGradTo
->hide();
1220 mxGradientStyle
->hide();
1224 if(pSh
&& pSh
->GetItem(SID_BITMAP_LIST
) && eXFS
== BITMAP
)
1226 if (!comphelper::LibreOfficeKit::isActive())
1227 mxBmpImport
->show();
1228 mxLbFillType
->set_active(sal_uInt32(BITMAP
));
1229 SvxFillAttrBox::Fill(*mxLbFillAttr
, pSh
->GetItem(SID_BITMAP_LIST
)->GetBitmapList());
1231 const OUString
aString(mpBitmapItem
->GetName());
1232 mxLbFillAttr
->set_active_text(aString
);
1234 else if(pSh
&& pSh
->GetItem(SID_PATTERN_LIST
) && eXFS
== PATTERN
)
1236 mxBmpImport
->hide();
1237 mxLbFillType
->set_active(sal_uInt32(PATTERN
));
1238 SvxFillAttrBox::Fill(*mxLbFillAttr
, pSh
->GetItem(SID_PATTERN_LIST
)->GetPatternList());
1240 const OUString
aString(mpBitmapItem
->GetName());
1241 mxLbFillAttr
->set_active_text(aString
);
1245 mxLbFillAttr
->set_active(-1);
1249 OSL_ENSURE(false, "Non supported FillType (!)");
1253 m_pPanel
->TriggerDeckLayouting();
1256 IMPL_LINK_NOARG(AreaPropertyPanelBase
, ModifyTransSliderHdl
, weld::Scale
&, void)
1258 const sal_uInt16 nVal
= mxSldTransparent
->get_value();
1259 SetTransparency(nVal
);
1260 const XFillTransparenceItem
aLinearItem(nVal
);
1261 setFillTransparence(aLinearItem
);
1264 IMPL_LINK_NOARG(AreaPropertyPanelBase
, ChangeTrgrTypeHdl_Impl
, weld::ComboBox
&, void)
1266 sal_Int32 nSelectType
= mxLBTransType
->get_active();
1267 bool bGradient
= false;
1268 sal_uInt16 nTrans
= 0;
1272 mxBTNGradient
->hide();
1273 mxMTRTransparent
->show();
1274 mxSldTransparent
->show();
1275 mxMTRTransparent
->set_sensitive(true);
1276 mxSldTransparent
->set_sensitive(true);
1279 else if(1 == nSelectType
)
1281 mxBTNGradient
->hide();
1282 mxMTRTransparent
->show();
1283 mxSldTransparent
->show();
1284 nTrans
= mnLastTransSolid
;
1285 mxMTRTransparent
->set_value(nTrans
, FieldUnit::PERCENT
);
1286 mxLBTransType
->set_active(1);
1287 mxMTRTransparent
->set_sensitive(true);
1288 mxSldTransparent
->set_sensitive(true);
1292 mxBTNGradient
->show();
1294 switch (nSelectType
)
1297 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgLinear
);
1300 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgAxial
);
1303 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgRadial
);
1306 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgElli
);
1309 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgQuad
);
1312 mxBTNGradient
->set_item_icon_name(SIDEBARGRADIENT
, maImgSquare
);
1316 mxMTRTransparent
->hide();
1317 mxSldTransparent
->hide();
1318 mxBTNGradient
->set_sensitive(true);
1322 const XFillTransparenceItem
aLinearItem(nTrans
);
1323 setFillTransparence(aLinearItem
);
1330 XGradient aTmpGradient
;
1332 switch(static_cast<css::awt::GradientStyle
>(nSelectType
))
1334 case css::awt::GradientStyle_LINEAR
:
1335 aTmpGradient
= maGradientLinear
;
1337 case css::awt::GradientStyle_AXIAL
:
1338 aTmpGradient
= maGradientAxial
;
1340 case css::awt::GradientStyle_RADIAL
:
1341 aTmpGradient
= maGradientRadial
;
1343 case css::awt::GradientStyle_ELLIPTICAL
:
1344 aTmpGradient
= maGradientElliptical
;
1346 case css::awt::GradientStyle_SQUARE
:
1347 aTmpGradient
= maGradientSquare
;
1349 case css::awt::GradientStyle_RECT
:
1350 aTmpGradient
= maGradientRect
;
1356 const XFillFloatTransparenceItem
aGradientItem(aTmpGradient
, bGradient
);
1357 setFillFloatTransparence(aGradientItem
);
1360 IMPL_LINK_NOARG(AreaPropertyPanelBase
, ModifyTransparentHdl_Impl
, weld::MetricSpinButton
&, void)
1362 const sal_uInt16 nTrans
= static_cast<sal_uInt16
>(mxMTRTransparent
->get_value(FieldUnit::PERCENT
));
1363 mnLastTransSolid
= nTrans
;
1364 SetTransparency(nTrans
);
1365 const sal_Int32 nSelectType
= mxLBTransType
->get_active();
1367 if(nTrans
&& !nSelectType
)
1369 mxLBTransType
->set_active(1);
1372 const XFillTransparenceItem
aLinearItem(nTrans
);
1373 setFillTransparence(aLinearItem
);
1376 const XGradient
& AreaPropertyPanelBase::GetGradient (const css::awt::GradientStyle eStyle
) const
1381 case css::awt::GradientStyle_LINEAR
:
1382 return maGradientLinear
;
1383 case css::awt::GradientStyle_AXIAL
:
1384 return maGradientAxial
;
1385 case css::awt::GradientStyle_RADIAL
:
1386 return maGradientRadial
;
1387 case css::awt::GradientStyle_ELLIPTICAL
:
1388 return maGradientElliptical
;
1389 case css::awt::GradientStyle_SQUARE
:
1390 return maGradientSquare
;
1391 case css::awt::GradientStyle_RECT
:
1392 return maGradientRect
;
1396 void AreaPropertyPanelBase::SetGradient (const XGradient
& rGradient
)
1398 switch (rGradient
.GetGradientStyle())
1400 case css::awt::GradientStyle_LINEAR
:
1401 maGradientLinear
= rGradient
;
1403 case css::awt::GradientStyle_AXIAL
:
1404 maGradientAxial
= rGradient
;
1406 case css::awt::GradientStyle_RADIAL
:
1407 maGradientRadial
= rGradient
;
1409 case css::awt::GradientStyle_ELLIPTICAL
:
1410 maGradientElliptical
= rGradient
;
1412 case css::awt::GradientStyle_SQUARE
:
1413 maGradientSquare
= rGradient
;
1415 case css::awt::GradientStyle_RECT
:
1416 maGradientRect
= rGradient
;
1423 sal_Int32
AreaPropertyPanelBase::GetSelectedTransparencyTypeIndex() const
1425 return mxLBTransType
->get_active();
1428 } // end of namespace svx::sidebar
1430 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */