Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / sidebar / area / AreaPropertyPanelBase.cxx
blobfdb5ca82a899ed0ca53c5ea2188133cf25711c6d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/xfilluseslidebackgrounditem.hxx>
29 #include <svx/xtable.hxx>
30 #include <sfx2/sidebar/Panel.hxx>
31 #include <sfx2/opengrf.hxx>
32 #include <sfx2/weldutils.hxx>
33 #include <tools/urlobj.hxx>
34 #include <bitmaps.hlst>
35 #include <comphelper/lok.hxx>
37 using namespace css;
38 using namespace css::uno;
40 constexpr OUStringLiteral SIDEBARGRADIENT = u"sidebargradient";
42 namespace svx::sidebar {
44 namespace {
46 enum eFillStyle
48 NONE,
49 SOLID,
50 GRADIENT,
51 HATCH,
52 BITMAP,
53 PATTERN,
54 USE_BACKGROUND
59 const sal_Int32 AreaPropertyPanelBase::DEFAULT_CENTERX = 50;
60 const sal_Int32 AreaPropertyPanelBase::DEFAULT_CENTERY = 50;
61 const sal_Int32 AreaPropertyPanelBase::DEFAULT_ANGLE = 0;
62 const sal_Int32 AreaPropertyPanelBase::DEFAULT_STARTVALUE = 0;
63 const sal_Int32 AreaPropertyPanelBase::DEFAULT_ENDVALUE = 16777215;
64 const sal_Int32 AreaPropertyPanelBase::DEFAULT_BORDER = 0;
66 AreaPropertyPanelBase::AreaPropertyPanelBase(
67 weld::Widget* pParent,
68 const css::uno::Reference<css::frame::XFrame>& rxFrame)
69 : PanelLayout(pParent, "AreaPropertyPanel", "svx/ui/sidebararea.ui"),
70 mxFrame(rxFrame),
71 meLastXFS(static_cast<sal_uInt16>(-1)),
72 mnLastPosHatch(0),
73 mnLastPosBitmap(0),
74 mnLastPosPattern(0),
75 mnLastTransSolid(50),
76 mxColorTextFT(m_xBuilder->weld_label("filllabel")),
77 mxLbFillType(m_xBuilder->weld_combo_box("fillstylearea")),
78 mxLbFillAttr(m_xBuilder->weld_combo_box("fillattrhb")),
79 mxLbFillGradFrom(new ColorListBox(m_xBuilder->weld_menu_button("fillgrad1"), [this]{ return GetFrameWeld(); })),
80 mxLbFillGradTo(new ColorListBox(m_xBuilder->weld_menu_button("fillgrad2"), [this]{ return GetFrameWeld(); })),
81 mxToolBoxColor(m_xBuilder->weld_toolbar("selectcolor")),
82 mxColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxColor, *m_xBuilder, rxFrame)),
83 mxTrspTextFT(m_xBuilder->weld_label("transparencylabel")),
84 mxLBTransType(m_xBuilder->weld_combo_box("transtype")),
85 mxMTRTransparent(m_xBuilder->weld_metric_spin_button("settransparency", FieldUnit::PERCENT)),
86 mxSldTransparent(m_xBuilder->weld_scale("transparencyslider")),
87 mxBTNGradient(m_xBuilder->weld_toolbar("selectgradient")),
88 mxMTRAngle(m_xBuilder->weld_metric_spin_button("gradangle", FieldUnit::DEGREE)),
89 mxGradientStyle(m_xBuilder->weld_combo_box("gradientstyle")),
90 mxBmpImport(m_xBuilder->weld_button("bmpimport")),
91 maImgAxial(BMP_AXIAL),
92 maImgElli(BMP_ELLI),
93 maImgQuad(BMP_QUAD),
94 maImgRadial(BMP_RADIAL),
95 maImgSquare(BMP_SQUARE),
96 maImgLinear(BMP_LINEAR)
98 Initialize();
101 AreaPropertyPanelBase::~AreaPropertyPanelBase()
103 mxTrGrPopup.reset();
104 mxColorTextFT.reset();
105 mxLbFillType.reset();
106 mxLbFillAttr.reset();
107 mxColorDispatch.reset();
108 mxToolBoxColor.reset();
109 mxTrspTextFT.reset();
110 mxLBTransType.reset();
111 mxMTRTransparent.reset();
112 mxSldTransparent.reset();
113 mxBTNGradient.reset();
114 mxMTRAngle.reset();
115 mxLbFillGradFrom.reset();
116 mxLbFillGradTo.reset();
117 mxGradientStyle.reset();
118 mxBmpImport.reset();
121 void AreaPropertyPanelBase::Initialize()
123 SvxFillTypeBox::Fill(*mxLbFillType);
125 mxLbFillAttr->set_size_request(42, -1);
127 maGradientLinear.SetXOffset(DEFAULT_CENTERX);
128 maGradientLinear.SetYOffset(DEFAULT_CENTERY);
129 maGradientLinear.SetAngle(Degree10(DEFAULT_ANGLE));
130 maGradientLinear.SetColorStops(
131 basegfx::BColorStops(
132 Color(DEFAULT_STARTVALUE).getBColor(),
133 Color(DEFAULT_ENDVALUE).getBColor()));
134 maGradientLinear.SetBorder(DEFAULT_BORDER);
135 maGradientLinear.SetGradientStyle(css::awt::GradientStyle_LINEAR);
137 maGradientAxial = maGradientLinear;
138 maGradientAxial.SetGradientStyle(css::awt::GradientStyle_AXIAL);
140 maGradientRadial = maGradientLinear;
141 maGradientRadial.SetGradientStyle(css::awt::GradientStyle_RADIAL);
143 maGradientElliptical = maGradientLinear;
144 maGradientElliptical.SetGradientStyle(css::awt::GradientStyle_ELLIPTICAL);
146 maGradientSquare = maGradientLinear;
147 maGradientSquare.SetGradientStyle(css::awt::GradientStyle_SQUARE);
149 maGradientRect = maGradientLinear;
150 maGradientRect.SetGradientStyle(css::awt::GradientStyle_RECT);
153 mxLbFillType->connect_changed( LINK( this, AreaPropertyPanelBase, SelectFillTypeHdl ) );
155 Link<weld::ComboBox&,void> aLink = LINK( this, AreaPropertyPanelBase, SelectFillAttrHdl );
156 mxLbFillAttr->connect_changed( aLink );
157 mxGradientStyle->connect_changed( aLink );
158 Link<ColorListBox&,void> aLink3 = LINK( this, AreaPropertyPanelBase, SelectFillColorHdl );
159 mxLbFillGradFrom->SetSelectHdl( aLink3 );
160 mxLbFillGradTo->SetSelectHdl( aLink3 );
161 mxMTRAngle->connect_value_changed(LINK(this,AreaPropertyPanelBase, ChangeGradientAngle));
163 // set a small width to force widgets to take their final width from other widgets in the grid
164 mxLbFillGradFrom->get_widget().set_size_request(42, -1);
165 mxLbFillGradTo->get_widget().set_size_request(42, -1);
167 mxLBTransType->connect_changed(LINK(this, AreaPropertyPanelBase, ChangeTrgrTypeHdl_Impl));
169 SetTransparency( 50 );
170 mxMTRTransparent->connect_value_changed(LINK(this, AreaPropertyPanelBase, ModifyTransparentHdl_Impl));
171 mxSldTransparent->connect_value_changed(LINK(this, AreaPropertyPanelBase, ModifyTransSliderHdl));
173 mxTrGrPopup = std::make_unique<AreaTransparencyGradientPopup>(mxFrame, *this, mxBTNGradient.get());
175 mxBTNGradient->set_item_popover(SIDEBARGRADIENT, mxTrGrPopup->getTopLevel());
176 mxBTNGradient->connect_clicked(LINK(this, AreaPropertyPanelBase, ToolbarHdl_Impl));
178 mxBTNGradient->set_item_icon_name(SIDEBARGRADIENT, maImgLinear);
179 mxBTNGradient->hide();
180 mxBmpImport->connect_clicked( LINK(this, AreaPropertyPanelBase, ClickImportBitmapHdl));
183 IMPL_LINK_NOARG(AreaPropertyPanelBase, ToolbarHdl_Impl, const OUString&, void)
185 mxBTNGradient->set_menu_item_active(SIDEBARGRADIENT, !mxBTNGradient->get_menu_item_active(SIDEBARGRADIENT));
188 void AreaPropertyPanelBase::SetTransparency(sal_uInt16 nVal)
190 mxSldTransparent->set_value(nVal);
191 mxMTRTransparent->set_value(nVal, FieldUnit::PERCENT);
194 IMPL_LINK_NOARG(AreaPropertyPanelBase, ClickImportBitmapHdl, weld::Button&, void)
196 SvxOpenGraphicDialog aDlg("Import", GetFrameWeld());
197 aDlg.EnableLink(false);
198 if( aDlg.Execute() != ERRCODE_NONE )
199 return;
201 Graphic aGraphic;
202 auto xWait = std::make_unique<weld::WaitObject>(m_xContainer.get());
203 ErrCode nError = aDlg.GetGraphic( aGraphic );
204 xWait.reset();
205 if( nError != ERRCODE_NONE )
206 return;
208 mxLbFillAttr->clear();
210 if (SfxObjectShell* pSh = SfxObjectShell::Current())
212 INetURLObject aURL(aDlg.GetPath());
213 OUString aFileName = aURL.GetLastName().getToken(0, '.');
214 OUString aName = aFileName;
216 XBitmapListRef pList = pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList();
218 tools::Long j = 1;
219 bool bValidBitmapName = false;
220 while( !bValidBitmapName )
222 bValidBitmapName = true;
223 for( tools::Long i = 0; i < pList->Count() && bValidBitmapName; i++ )
225 if( aName == pList->GetBitmap(i)->GetName() )
227 bValidBitmapName = false;
228 aName = aFileName + OUString::number(j++);
233 pList->Insert(std::make_unique<XBitmapEntry>(aGraphic, aName));
234 pList->Save();
236 SvxFillAttrBox::Fill(*mxLbFillAttr, pList);
238 mxLbFillAttr->set_active_text(aName);
239 SelectFillAttrHdl(*mxLbFillAttr);
243 IMPL_LINK_NOARG(AreaPropertyPanelBase, SelectFillTypeHdl, weld::ComboBox&, void)
245 FillStyleChanged(true);
248 IMPL_LINK_NOARG(AreaPropertyPanelBase, SelectFillColorHdl, ColorListBox&, void)
250 SelectFillAttrHdl_Impl();
253 IMPL_LINK_NOARG(AreaPropertyPanelBase, SelectFillAttrHdl, weld::ComboBox&, void)
255 SelectFillAttrHdl_Impl();
258 IMPL_LINK_NOARG(AreaPropertyPanelBase, ChangeGradientAngle, weld::MetricSpinButton&, void)
260 SelectFillAttrHdl_Impl();
263 void AreaPropertyPanelBase::SelectFillAttrHdl_Impl()
265 sal_Int32 nPosFillStyle = static_cast<eFillStyle>(mxLbFillType->get_active());
266 SfxObjectShell* pSh = SfxObjectShell::Current();
268 // #i122676# dependent from bFillStyleChange, do execute a single or two
269 // changes in one Execute call
270 const bool bFillStyleChange(static_cast<eFillStyle>(meLastXFS) != static_cast<eFillStyle>(nPosFillStyle));
272 switch(nPosFillStyle)
274 case eFillStyle::NONE:
276 if(bFillStyleChange)
278 const XFillStyleItem aXFillStyleItem(drawing::FillStyle_NONE);
279 // Need to disable the XFillUseSlideBackgroundItem
280 const XFillUseSlideBackgroundItem aXFillUseSlideBackgroundItem(false);
281 setFillUseBackground(&aXFillStyleItem, aXFillUseSlideBackgroundItem);
283 break;
285 case eFillStyle::SOLID:
287 if(bFillStyleChange)
289 // #i122676# Single FillStyle change call needed here
290 XFillStyleItem aXFillStyleItem(drawing::FillStyle_SOLID);
291 setFillStyle(aXFillStyleItem);
293 break;
295 case eFillStyle::GRADIENT:
298 if (pSh && pSh->GetItem(SID_COLOR_TABLE))
300 basegfx::BGradient aGradient(createColorStops());
301 aGradient.SetAngle(Degree10(mxMTRAngle->get_value(FieldUnit::DEGREE) * 10));
302 aGradient.SetGradientStyle(static_cast<css::awt::GradientStyle>(mxGradientStyle->get_active()));
304 const XFillGradientItem aXFillGradientItem(mxLbFillAttr->get_active_text(), aGradient);
306 // #i122676# Change FillStyle and Gradient in one call
307 XFillStyleItem aXFillStyleItem(drawing::FillStyle_GRADIENT);
308 setFillStyleAndGradient(bFillStyleChange ? &aXFillStyleItem : nullptr, aXFillGradientItem);
310 break;
312 case eFillStyle::HATCH:
314 sal_Int32 nPos = mxLbFillAttr->get_active();
316 if (nPos == -1)
318 nPos = mnLastPosHatch;
321 if (nPos != -1 && pSh && pSh->GetItem(SID_HATCH_LIST))
323 const SvxHatchListItem * pItem = pSh->GetItem(SID_HATCH_LIST);
325 if(nPos < pItem->GetHatchList()->Count())
327 const XHatch aHatch = pItem->GetHatchList()->GetHatch(nPos)->GetHatch();
328 const XFillHatchItem aXFillHatchItem( mxLbFillAttr->get_active_text(), aHatch);
330 // #i122676# Change FillStyle and Hatch in one call
331 XFillStyleItem aXFillStyleItem(drawing::FillStyle_HATCH);
332 setFillStyleAndHatch(bFillStyleChange ? &aXFillStyleItem : nullptr, aXFillHatchItem);
336 if (nPos != -1)
338 mnLastPosHatch = nPos;
340 break;
342 case eFillStyle::BITMAP:
344 sal_Int32 nPos = mxLbFillAttr->get_active();
346 if (nPos == -1)
348 nPos = mnLastPosBitmap;
351 if (nPos != -1 && pSh && pSh->GetItem(SID_BITMAP_LIST))
353 const SvxBitmapListItem * pItem = pSh->GetItem(SID_BITMAP_LIST);
355 if(nPos < pItem->GetBitmapList()->Count())
357 const XBitmapEntry* pXBitmapEntry = pItem->GetBitmapList()->GetBitmap(nPos);
358 const XFillBitmapItem aXFillBitmapItem(mxLbFillAttr->get_active_text(), pXBitmapEntry->GetGraphicObject());
360 // #i122676# Change FillStyle and Bitmap in one call
361 XFillStyleItem aXFillStyleItem(drawing::FillStyle_BITMAP);
362 setFillStyleAndBitmap(bFillStyleChange ? &aXFillStyleItem : nullptr, aXFillBitmapItem);
366 if (nPos != -1)
368 mnLastPosBitmap = nPos;
370 break;
372 case eFillStyle::PATTERN:
374 sal_Int32 nPos = mxLbFillAttr->get_active();
376 if (nPos == -1)
378 nPos = mnLastPosPattern;
381 if (nPos != -1 && pSh && pSh->GetItem(SID_PATTERN_LIST))
383 const SvxPatternListItem * pItem = pSh->GetItem(SID_PATTERN_LIST);
385 if(nPos < pItem->GetPatternList()->Count())
387 const XBitmapEntry* pXPatternEntry = pItem->GetPatternList()->GetBitmap(nPos);
388 const XFillBitmapItem aXFillBitmapItem(mxLbFillAttr->get_active_text(), pXPatternEntry->GetGraphicObject());
390 // #i122676# Change FillStyle and Bitmap in one call
391 XFillStyleItem aXFillStyleItem(drawing::FillStyle_BITMAP);
392 setFillStyleAndBitmap(bFillStyleChange ? &aXFillStyleItem : nullptr, aXFillBitmapItem);
396 if (nPos != -1)
398 mnLastPosPattern = nPos;
400 break;
403 if (m_pPanel && !comphelper::LibreOfficeKit::isActive())
404 m_pPanel->TriggerDeckLayouting();
407 void AreaPropertyPanelBase::FillStyleChanged(bool bUpdateModel)
409 sal_Int32 nPos = static_cast<eFillStyle>(mxLbFillType->get_active());
410 mxLbFillAttr->clear();
411 SfxObjectShell* pSh = SfxObjectShell::Current();
412 if (!pSh)
413 return;
415 bool bShowLbFillAttr = false;
416 bool bShowLbFillGradFrom = false;
417 bool bShowLbFillGradTo = false;
418 bool bShowGradientStyle = false;
419 bool bShowMTRAngle = false;
420 bool bShowToolBoxColor = false;
421 bool bShowBmpImport = false;
423 // #i122676# Do no longer trigger two Execute calls, one for SID_ATTR_FILL_STYLE
424 // and one for setting the fill attribute itself, but add two SfxPoolItems to the
425 // call to get just one action at the SdrObject and to create only one Undo action, too.
426 // Checked that this works in all apps.
427 switch (nPos)
429 default:
430 case NONE:
432 if (bUpdateModel)
434 const XFillStyleItem aXFillStyleItem(drawing::FillStyle_NONE);
435 // Need to disable the XFillUseSlideBackgroundItem
436 const XFillUseSlideBackgroundItem aXFillUseSlideBackgroundItem(false);
437 setFillUseBackground(&aXFillStyleItem, aXFillUseSlideBackgroundItem);
440 break;
442 case SOLID:
444 bShowToolBoxColor = true;
446 if (bUpdateModel)
448 const Color aColor = mpColorItem ? mpColorItem->GetColorValue() : COL_AUTO;
449 const XFillColorItem aXFillColorItem("", aColor);
451 // #i122676# change FillStyle and Color in one call
452 XFillStyleItem aXFillStyleItem(drawing::FillStyle_SOLID);
453 setFillStyleAndColor(&aXFillStyleItem, aXFillColorItem);
455 break;
457 case GRADIENT:
459 bShowLbFillGradFrom = true;
460 bShowLbFillGradTo = true;
461 bShowGradientStyle = true;
462 bShowMTRAngle = true;
464 mxLbFillAttr->set_sensitive(true);
465 mxLbFillGradTo->set_sensitive(true);
466 mxLbFillGradFrom->set_sensitive(true);
467 mxGradientStyle->set_sensitive(true);
468 mxMTRAngle->set_sensitive(true);
469 mxLbFillAttr->clear();
471 if (bUpdateModel)
473 mxLbFillAttr->hide();
474 mxToolBoxColor->hide();
475 mxBmpImport->hide();
477 const SvxGradientListItem* pItem = pSh->GetItem(SID_GRADIENT_LIST);
478 if (pItem->GetGradientList()->Count() > 0)
480 const basegfx::BGradient aGradient
481 = pItem->GetGradientList()->GetGradient(0)->GetGradient();
482 const OUString aName = pItem->GetGradientList()->GetGradient(0)->GetName();
483 const XFillGradientItem aXFillGradientItem(aName, aGradient);
485 // #i122676# change FillStyle and Gradient in one call
486 XFillStyleItem aXFillStyleItem(drawing::FillStyle_GRADIENT);
487 setFillStyleAndGradient(&aXFillStyleItem, aXFillGradientItem);
488 mxLbFillGradFrom->SelectEntry(Color(aGradient.GetColorStops().front().getStopColor()));
489 mxLbFillGradTo->SelectEntry(Color(aGradient.GetColorStops().back().getStopColor()));
491 // MCGR: preserve ColorStops if given
492 // tdf#155901 We need offset of first and last stop, so include them.
493 if (aGradient.GetColorStops().size() >= 2)
494 maColorStops = aGradient.GetColorStops();
495 else
496 maColorStops.clear();
498 mxMTRAngle->set_value(toDegrees(aGradient.GetAngle()), FieldUnit::DEGREE);
499 css::awt::GradientStyle eXGS = aGradient.GetGradientStyle();
500 mxGradientStyle->set_active(sal::static_int_cast<sal_Int32>(eXGS));
503 else
505 if (pSh->GetItem(SID_GRADIENT_LIST))
507 SvxFillAttrBox::Fill(*mxLbFillAttr,
508 pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList());
509 mxLbFillGradTo->SetNoSelection();
510 mxLbFillGradFrom->SetNoSelection();
511 if (mpFillGradientItem)
513 const OUString aString(mpFillGradientItem->GetName());
514 mxLbFillAttr->set_active_text(aString);
515 const basegfx::BGradient aGradient = mpFillGradientItem->GetGradientValue();
516 mxLbFillGradFrom->SelectEntry(Color(aGradient.GetColorStops().front().getStopColor()));
517 mxLbFillGradTo->SelectEntry(Color(aGradient.GetColorStops().back().getStopColor()));
519 // MCGR: preserve ColorStops if given
520 // tdf#155901 We need offset of first and last stop, so include them.
521 if (aGradient.GetColorStops().size() >= 2)
522 maColorStops = basegfx::BColorStops(aGradient.GetColorStops().begin(),
523 aGradient.GetColorStops().end());
524 else
525 maColorStops.clear();
527 mxGradientStyle->set_active(
528 sal::static_int_cast<sal_Int32>(aGradient.GetGradientStyle()));
529 if (mxGradientStyle->get_active() == sal_Int32(css::awt::GradientStyle_RADIAL))
530 mxMTRAngle->set_sensitive(false);
531 else
532 mxMTRAngle->set_value(toDegrees(aGradient.GetAngle()),
533 FieldUnit::DEGREE);
535 else
537 mxLbFillAttr->set_active(-1);
540 else
542 mxLbFillAttr->set_active(-1);
545 break;
547 case HATCH:
549 bShowLbFillAttr = true;
551 const SvxHatchListItem* pItem(pSh->GetItem(SID_HATCH_LIST));
552 if (pItem)
554 const XHatchListRef& pXHatchList(pItem->GetHatchList());
555 mxLbFillAttr->set_sensitive(true);
556 mxLbFillAttr->clear();
557 SvxFillAttrBox::Fill(*mxLbFillAttr, pXHatchList);
559 if (mnLastPosHatch != -1)
561 if (mnLastPosHatch < pXHatchList->Count())
563 const XHatch aHatch = pXHatchList->GetHatch(mnLastPosHatch)->GetHatch();
564 const OUString aName = pXHatchList->GetHatch(mnLastPosHatch)->GetName();
565 const XFillHatchItem aXFillHatchItem(aName, aHatch);
567 // #i122676# change FillStyle and Hatch in one call
568 if (bUpdateModel)
570 XFillStyleItem aXFillStyleItem(drawing::FillStyle_HATCH);
571 setFillStyleAndHatch(&aXFillStyleItem, aXFillHatchItem);
573 mxLbFillAttr->set_active(mnLastPosHatch);
577 else
579 mxLbFillAttr->set_sensitive(false);
581 break;
583 case BITMAP:
584 case PATTERN:
586 bShowLbFillAttr = true;
587 mxLbFillAttr->set_sensitive(true);
588 mxLbFillAttr->clear();
590 OUString aName;
591 GraphicObject aBitmap;
592 if (nPos == static_cast<sal_Int32>(BITMAP))
594 if (!comphelper::LibreOfficeKit::isActive())
595 bShowBmpImport = true;
596 const SvxBitmapListItem* pItem = pSh->GetItem(SID_BITMAP_LIST);
597 if (pItem)
599 const XBitmapListRef& pXBitmapList(pItem->GetBitmapList());
600 SvxFillAttrBox::Fill(*mxLbFillAttr, pXBitmapList);
602 if (mnLastPosBitmap != -1)
604 if (mnLastPosBitmap < pXBitmapList->Count())
606 const XBitmapEntry* pXBitmapEntry
607 = pXBitmapList->GetBitmap(mnLastPosBitmap);
608 aBitmap = pXBitmapEntry->GetGraphicObject();
609 aName = pXBitmapEntry->GetName();
610 mxLbFillAttr->set_active(mnLastPosBitmap);
614 else
616 bShowBmpImport = false;
619 else if (nPos == static_cast<sal_Int32>(PATTERN))
621 const SvxPatternListItem* pItem = pSh->GetItem(SID_PATTERN_LIST);
622 if (pItem)
624 const XPatternListRef& pXPatternList(pItem->GetPatternList());
625 SvxFillAttrBox::Fill(*mxLbFillAttr, pXPatternList);
627 if (mnLastPosPattern != -1)
629 if (mnLastPosPattern < pXPatternList->Count())
631 const XBitmapEntry* pXPatternEntry
632 = pXPatternList->GetBitmap(mnLastPosPattern);
633 aBitmap = pXPatternEntry->GetGraphicObject();
634 aName = pXPatternEntry->GetName();
635 mxLbFillAttr->set_active(mnLastPosPattern);
639 else
641 bShowLbFillAttr = false;
644 if (bUpdateModel)
646 const XFillBitmapItem aXFillBitmapItem(aName, aBitmap);
647 const XFillStyleItem aXFillStyleItem(drawing::FillStyle_BITMAP);
648 setFillStyleAndBitmap(&aXFillStyleItem, aXFillBitmapItem);
650 break;
652 case USE_BACKGROUND:
654 // No transparencies here
655 mxLBTransType->hide();
656 mxTrspTextFT->hide();
657 mxMTRTransparent->hide();
658 mxSldTransparent->hide();
659 mxBTNGradient->hide();
660 if (bUpdateModel)
662 const XFillStyleItem aXFillStyleItem(drawing::FillStyle_NONE);
663 const XFillUseSlideBackgroundItem aXFillUseSlideBackgroundItem(true);
664 setFillUseBackground(&aXFillStyleItem, aXFillUseSlideBackgroundItem);
665 break;
670 mxLbFillAttr->set_visible(bShowLbFillAttr);
671 mxLbFillGradFrom->set_visible(bShowLbFillGradFrom);
672 mxLbFillGradTo->set_visible(bShowLbFillGradTo);
673 mxGradientStyle->set_visible(bShowGradientStyle);
674 mxMTRAngle->set_visible(bShowMTRAngle);
675 mxToolBoxColor->set_visible(bShowToolBoxColor);
676 mxBmpImport->set_visible(bShowBmpImport);
678 meLastXFS = static_cast<sal_uInt16>(nPos);
680 if (m_pPanel && !comphelper::LibreOfficeKit::isActive())
681 m_pPanel->TriggerDeckLayouting();
684 void AreaPropertyPanelBase::ImpUpdateTransparencies()
686 if(mpTransparenceItem || mpFloatTransparenceItem)
688 bool bZeroValue(false);
690 if (mpTransparenceItem)
692 const sal_uInt16 nValue(mpTransparenceItem->GetValue());
694 if(!nValue)
696 bZeroValue = true;
698 else if(nValue <= 100)
700 mxLBTransType->set_sensitive(true);
701 mxTrspTextFT->set_sensitive(true);
702 mxLBTransType->set_active(1);
703 mxBTNGradient->hide();
704 mxMTRTransparent->show();
705 mxSldTransparent->show();
706 mxMTRTransparent->set_sensitive(true);
707 mxSldTransparent->set_sensitive(true);
708 SetTransparency(nValue);
711 if (!bZeroValue && mxTrGrPopup)
713 mxBTNGradient->set_menu_item_active(SIDEBARGRADIENT, false);
717 if(bZeroValue && mpFloatTransparenceItem)
719 if(mpFloatTransparenceItem->IsEnabled())
721 const basegfx::BGradient& rGradient = mpFloatTransparenceItem->GetGradientValue();
722 sal_Int32 nEntryPos(0);
723 OUString* pImage = nullptr;
725 mxLBTransType->set_sensitive(true);
726 mxTrspTextFT->set_sensitive(true);
727 mxMTRTransparent->hide();
728 mxSldTransparent->hide();
729 mxBTNGradient->set_sensitive(true);
730 mxBTNGradient->show();
732 switch(rGradient.GetGradientStyle())
734 default:
735 case css::awt::GradientStyle_LINEAR:
737 nEntryPos = 2;
738 pImage = &maImgLinear;
739 break;
741 case css::awt::GradientStyle_AXIAL:
743 nEntryPos = 3;
744 pImage = &maImgAxial;
745 break;
747 case css::awt::GradientStyle_RADIAL:
749 nEntryPos = 4;
750 pImage = &maImgRadial;
751 break;
753 case css::awt::GradientStyle_ELLIPTICAL:
755 nEntryPos = 5;
756 pImage = &maImgElli;
757 break;
759 case css::awt::GradientStyle_SQUARE:
761 nEntryPos = 6;
762 pImage = &maImgQuad;
763 break;
765 case css::awt::GradientStyle_RECT:
767 nEntryPos = 7;
768 pImage = &maImgSquare;
769 break;
772 mxLBTransType->set_active(nEntryPos);
773 mxBTNGradient->set_item_icon_name(SIDEBARGRADIENT, *pImage);
774 mxTrGrPopup->Rearrange(mpFloatTransparenceItem.get());
775 bZeroValue = false;
777 else
779 bZeroValue = true;
783 if(bZeroValue)
785 mxLBTransType->set_sensitive(true);
786 mxTrspTextFT->set_sensitive(true);
787 mxLBTransType->set_active(0);
788 mxBTNGradient->hide();
789 mxMTRTransparent->set_sensitive(true);
790 mxSldTransparent->set_sensitive(true);
791 mxMTRTransparent->show();
792 mxSldTransparent->show();
793 SetTransparency(0);
796 else
798 // no transparency at all
799 mxLBTransType->set_active(-1);
800 mxLBTransType->set_sensitive(false);
801 mxTrspTextFT->set_sensitive(false);
802 mxMTRTransparent->set_sensitive(false);
803 mxSldTransparent->set_sensitive(false);
804 mxMTRTransparent->show();
805 mxSldTransparent->show();
806 mxBTNGradient->set_sensitive(false);
807 mxBTNGradient->hide();
811 void AreaPropertyPanelBase::updateFillTransparence(bool bDisabled, bool bDefaultOrSet, const SfxPoolItem* pState)
813 if (bDisabled)
815 mpTransparenceItem.reset();
816 return;
818 else if (bDefaultOrSet)
820 if (pState)
822 const SfxUInt16Item* pItem = static_cast<const SfxUInt16Item*>(pState);
823 mpTransparenceItem.reset(pItem->Clone());
825 else
827 mpTransparenceItem.reset();
830 else
832 mpTransparenceItem.reset();
835 // update transparency settings dependent of mpTransparenceItem and mpFloatTransparenceItem
836 ImpUpdateTransparencies();
839 void AreaPropertyPanelBase::updateFillFloatTransparence(bool bDisabled, bool bDefaultOrSet, const SfxPoolItem* pState)
841 if (bDisabled)
843 mpFloatTransparenceItem.reset();
844 return;
847 if (bDefaultOrSet)
849 if (pState)
851 const XFillFloatTransparenceItem* pItem = static_cast<const XFillFloatTransparenceItem*>(pState);
852 mpFloatTransparenceItem.reset(pItem->Clone());
854 else
856 mpFloatTransparenceItem.reset();
859 else
861 mpFloatTransparenceItem.reset();
864 // update transparency settings dependent of mpTransparenceItem and mpFloatTransparenceItem
865 ImpUpdateTransparencies();
868 void AreaPropertyPanelBase::updateFillStyle(bool bDisabled, bool bDefaultOrSet, const SfxPoolItem* pState)
870 if(bDisabled)
872 mxLbFillType->set_sensitive(false);
873 mxColorTextFT->set_sensitive(false);
874 mxLbFillType->set_active(-1);
875 mxLbFillAttr->show();
876 mxLbFillAttr->set_sensitive(false);
877 mxLbFillAttr->set_active(-1);
878 mxToolBoxColor->hide();
879 meLastXFS = static_cast<sal_uInt16>(-1);
880 mpStyleItem.reset();
882 else if (bDefaultOrSet && pState)
884 const XFillStyleItem* pItem = static_cast<const XFillStyleItem*>(pState);
885 mpStyleItem.reset(pItem->Clone());
886 mxLbFillType->set_sensitive(true);
887 mxColorTextFT->set_sensitive(true);
888 drawing::FillStyle eXFS = mpStyleItem->GetValue();
889 eFillStyle nPos = NONE;
890 switch(eXFS)
892 default:
893 case drawing::FillStyle_NONE:
895 mxLbFillAttr->hide();
896 // "Use slide background" also uses FillStyle_NONE internally,
897 // don't switch listbox in that case (will be handled by updateFillUseBackground)
898 nPos = meLastXFS == USE_BACKGROUND ? USE_BACKGROUND : NONE;
899 break;
901 case drawing::FillStyle_SOLID:
902 nPos = SOLID;
903 break;
904 case drawing::FillStyle_GRADIENT:
905 nPos = GRADIENT;
906 break;
907 case drawing::FillStyle_HATCH:
908 nPos = HATCH;
909 break;
910 case drawing::FillStyle_BITMAP:
912 if(mpBitmapItem)
914 if(!mpBitmapItem->isPattern())
915 nPos = BITMAP;
916 else
917 nPos = PATTERN;
919 else
920 nPos = BITMAP;
921 break;
924 meLastXFS = static_cast< sal_uInt16 >(mxLbFillType->get_active());
925 mxLbFillType->set_active(static_cast< sal_Int32 >(nPos));
926 FillStyleChanged(false);
927 return;
930 mxLbFillType->set_active(-1);
931 mxLbFillAttr->show();
932 mxLbFillAttr->set_sensitive(false);
933 mxLbFillAttr->set_active(-1);
934 mxToolBoxColor->hide();
935 meLastXFS = static_cast<sal_uInt16>(-1);
936 mpStyleItem.reset();
939 void AreaPropertyPanelBase::updateFillGradient(bool bDisabled, bool bDefaultOrSet, const SfxPoolItem* pState)
941 if (bDefaultOrSet)
943 const XFillGradientItem* pItem = static_cast<const XFillGradientItem*>(pState);
944 mpFillGradientItem.reset(pItem ? pItem->Clone() : nullptr);
947 if(mpStyleItem && drawing::FillStyle_GRADIENT == mpStyleItem->GetValue())
949 mxLbFillAttr->hide();
950 mxLbFillGradFrom->show();
951 mxLbFillGradTo->show();
952 mxMTRAngle->show();
953 mxGradientStyle->show();
954 mxToolBoxColor->hide();
956 if (bDefaultOrSet)
958 mxLbFillType->set_active(GRADIENT);
959 FillStyleChanged(false);
961 else if(bDisabled)
963 mxLbFillGradFrom->SetNoSelection();
964 mxLbFillGradTo->SetNoSelection();
965 mxLbFillGradFrom->set_sensitive(false);
966 mxLbFillGradTo->set_sensitive(false);
967 mxMTRAngle->set_sensitive(false);
968 mxGradientStyle->set_sensitive(false);
970 else
972 mxLbFillGradFrom->SetNoSelection();
973 mxLbFillGradTo->SetNoSelection();
978 void AreaPropertyPanelBase::updateFillHatch(bool bDisabled, bool bDefaultOrSet, const SfxPoolItem* pState)
980 if (bDefaultOrSet)
982 const XFillHatchItem* pItem = static_cast<const XFillHatchItem*>(pState);
983 mpHatchItem.reset(pItem ? pItem->Clone() : nullptr);
986 if(mpStyleItem && drawing::FillStyle_HATCH == mpStyleItem->GetValue())
988 mxLbFillAttr->show();
989 mxToolBoxColor->hide();
991 if (bDefaultOrSet)
993 mxLbFillAttr->set_sensitive(true);
994 mxLbFillType->set_active(HATCH);
995 FillStyleChanged(false);
997 else if(bDisabled)
999 mxLbFillAttr->set_sensitive(false);
1000 mxLbFillAttr->set_active(-1);
1002 else
1004 mxLbFillAttr->set_active(-1);
1007 FillStyleChanged(false);
1010 void AreaPropertyPanelBase::updateFillColor(bool bDefaultOrSet, const SfxPoolItem* pState)
1012 if (bDefaultOrSet)
1014 const XFillColorItem* pItem = static_cast<const XFillColorItem*>(pState);
1015 mpColorItem.reset(pItem ? pItem->Clone() : nullptr);
1018 if(mpStyleItem && drawing::FillStyle_SOLID == mpStyleItem->GetValue())
1020 mxLbFillAttr->hide();
1021 mxToolBoxColor->show();
1022 mxLbFillType->set_active(SOLID);
1023 FillStyleChanged(false);
1027 void AreaPropertyPanelBase::updateFillBitmap(bool bDisabled, bool bDefaultOrSet, const SfxPoolItem* pState)
1029 if (bDefaultOrSet)
1031 const XFillBitmapItem* pItem = static_cast<const XFillBitmapItem*>(pState);
1032 mpBitmapItem.reset(pItem ? pItem->Clone() : nullptr);
1035 if(mpStyleItem && drawing::FillStyle_BITMAP == mpStyleItem->GetValue())
1037 mxLbFillAttr->show();
1038 mxToolBoxColor->hide();
1040 if (bDefaultOrSet)
1042 if(mpBitmapItem->isPattern())
1043 mxLbFillType->set_active(PATTERN);
1044 else
1045 mxLbFillType->set_active(BITMAP);
1046 FillStyleChanged(false);
1048 else if(bDisabled)
1050 mxLbFillAttr->hide();
1051 mxLbFillAttr->set_active(-1);
1053 else
1055 mxLbFillAttr->set_active(-1);
1060 void AreaPropertyPanelBase::updateFillUseBackground(bool bDisabled, bool bDefaultOrSet, const SfxPoolItem* pState)
1062 if (bDisabled)
1063 return;
1065 if (bDefaultOrSet)
1067 if (pState)
1069 const XFillUseSlideBackgroundItem* pItem = static_cast<const XFillUseSlideBackgroundItem*>(pState);
1070 // When XFillUseSlideBackgroundItem is set, select "Use Background Fill".
1071 // When false, select "None" (only if "Use background fill" was selected beforehand)
1072 int nPos = pItem->GetValue() ? USE_BACKGROUND : NONE;
1073 if ((nPos == NONE && mxLbFillType->get_active() == USE_BACKGROUND) || nPos == USE_BACKGROUND)
1075 mxLbFillType->set_active(nPos);
1076 FillStyleChanged(false);
1082 void AreaPropertyPanelBase::NotifyItemUpdate(
1083 sal_uInt16 nSID,
1084 SfxItemState eState,
1085 const SfxPoolItem* pState)
1087 const bool bDisabled(SfxItemState::DISABLED == eState);
1088 const bool bDefaultOrSet(SfxItemState::DEFAULT <= eState);
1089 const bool bDefault(SfxItemState::DEFAULT == eState);
1091 switch(nSID)
1093 case SID_ATTR_FILL_TRANSPARENCE:
1094 updateFillTransparence(bDisabled, bDefaultOrSet, pState);
1095 break;
1096 case SID_ATTR_FILL_FLOATTRANSPARENCE:
1097 updateFillFloatTransparence(bDisabled, bDefaultOrSet, pState);
1098 break;
1099 case SID_ATTR_FILL_STYLE:
1100 updateFillStyle(bDisabled, bDefaultOrSet, pState);
1101 break;
1102 case SID_ATTR_FILL_COLOR:
1103 updateFillColor(bDefaultOrSet, pState);
1104 break;
1105 case SID_ATTR_FILL_GRADIENT:
1106 updateFillGradient(bDisabled, bDefaultOrSet, pState);
1107 break;
1108 case SID_ATTR_FILL_HATCH:
1109 updateFillHatch(bDisabled, bDefaultOrSet, pState);
1110 break;
1111 case SID_ATTR_FILL_BITMAP:
1112 updateFillBitmap(bDisabled, bDefaultOrSet, pState);
1113 break;
1114 case SID_ATTR_FILL_USE_SLIDE_BACKGROUND:
1115 updateFillUseBackground(bDisabled, bDefaultOrSet, pState);
1116 break;
1117 case SID_GRADIENT_LIST:
1119 if(bDefault)
1121 if(mpStyleItem && drawing::FillStyle_GRADIENT == mpStyleItem->GetValue())
1123 if(mpFillGradientItem)
1125 const OUString aString( mpFillGradientItem->GetName() );
1126 const SfxObjectShell* pSh = SfxObjectShell::Current();
1127 mxLbFillAttr->clear();
1128 if (pSh)
1130 mxLbFillAttr->set_sensitive(true);
1131 SvxFillAttrBox::Fill(*mxLbFillAttr, pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList());
1133 mxLbFillAttr->set_active_text(aString);
1135 else
1137 mxLbFillAttr->set_active(-1);
1141 break;
1143 case SID_HATCH_LIST:
1145 if(bDefault)
1147 if(mpStyleItem && drawing::FillStyle_HATCH == mpStyleItem->GetValue())
1149 if(mpHatchItem)
1151 const OUString aString( mpHatchItem->GetName() );
1152 const SfxObjectShell* pSh = SfxObjectShell::Current();
1153 mxLbFillAttr->clear();
1154 if (pSh)
1156 mxLbFillAttr->set_sensitive(true);
1157 SvxFillAttrBox::Fill(*mxLbFillAttr, pSh->GetItem(SID_HATCH_LIST)->GetHatchList());
1159 mxLbFillAttr->set_active_text(aString);
1161 else
1163 mxLbFillAttr->set_active(-1);
1167 break;
1169 case SID_BITMAP_LIST:
1170 case SID_PATTERN_LIST:
1172 if(bDefault)
1174 if(mpStyleItem && drawing::FillStyle_BITMAP == mpStyleItem->GetValue())
1176 if(mpBitmapItem)
1178 const OUString aString( mpBitmapItem->GetName() );
1179 const SfxObjectShell* pSh = SfxObjectShell::Current();
1180 mxLbFillAttr->clear();
1181 mxLbFillAttr->show();
1182 if (pSh)
1184 if(nSID == SID_BITMAP_LIST)
1185 SvxFillAttrBox::Fill(*mxLbFillAttr, pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList());
1186 else if(nSID == SID_PATTERN_LIST)
1187 SvxFillAttrBox::Fill(*mxLbFillAttr, pSh->GetItem(SID_PATTERN_LIST)->GetPatternList());
1189 mxLbFillAttr->set_active_text(aString);
1191 else
1193 mxLbFillAttr->set_active(-1);
1197 break;
1200 FillStyleChanged(false);
1203 IMPL_LINK_NOARG(AreaPropertyPanelBase, ModifyTransSliderHdl, weld::Scale&, void)
1205 const sal_uInt16 nVal = mxSldTransparent->get_value();
1206 SetTransparency(nVal);
1207 const XFillTransparenceItem aLinearItem(nVal);
1208 setFillTransparence(aLinearItem);
1211 IMPL_LINK_NOARG(AreaPropertyPanelBase, ChangeTrgrTypeHdl_Impl, weld::ComboBox&, void)
1213 sal_Int32 nSelectType = mxLBTransType->get_active();
1214 bool bGradient = false;
1215 sal_uInt16 nTrans = 0;
1217 if(!nSelectType)
1219 mxBTNGradient->hide();
1220 mxMTRTransparent->show();
1221 mxSldTransparent->show();
1222 mxMTRTransparent->set_sensitive(true);
1223 mxSldTransparent->set_sensitive(true);
1224 SetTransparency(0);
1226 else if(1 == nSelectType)
1228 mxBTNGradient->hide();
1229 mxMTRTransparent->show();
1230 mxSldTransparent->show();
1231 nTrans = mnLastTransSolid;
1232 mxMTRTransparent->set_value(nTrans, FieldUnit::PERCENT);
1233 mxLBTransType->set_active(1);
1234 mxMTRTransparent->set_sensitive(true);
1235 mxSldTransparent->set_sensitive(true);
1237 else
1239 mxBTNGradient->show();
1241 switch (nSelectType)
1243 case 2:
1244 mxBTNGradient->set_item_icon_name(SIDEBARGRADIENT, maImgLinear);
1245 break;
1246 case 3:
1247 mxBTNGradient->set_item_icon_name(SIDEBARGRADIENT, maImgAxial);
1248 break;
1249 case 4:
1250 mxBTNGradient->set_item_icon_name(SIDEBARGRADIENT, maImgRadial);
1251 break;
1252 case 5:
1253 mxBTNGradient->set_item_icon_name(SIDEBARGRADIENT, maImgElli);
1254 break;
1255 case 6:
1256 mxBTNGradient->set_item_icon_name(SIDEBARGRADIENT, maImgQuad);
1257 break;
1258 case 7:
1259 mxBTNGradient->set_item_icon_name(SIDEBARGRADIENT, maImgSquare);
1260 break;
1263 mxMTRTransparent->hide();
1264 mxSldTransparent->hide();
1265 mxBTNGradient->set_sensitive(true);
1266 bGradient = true;
1269 const XFillTransparenceItem aLinearItem(nTrans);
1270 setFillTransparence(aLinearItem);
1272 if(nSelectType > 1)
1274 nSelectType -= 2;
1277 basegfx::BGradient aTmpGradient;
1279 switch(static_cast<css::awt::GradientStyle>(nSelectType))
1281 case css::awt::GradientStyle_LINEAR:
1282 aTmpGradient = maGradientLinear;
1283 break;
1284 case css::awt::GradientStyle_AXIAL:
1285 aTmpGradient = maGradientAxial;
1286 break;
1287 case css::awt::GradientStyle_RADIAL:
1288 aTmpGradient = maGradientRadial;
1289 break;
1290 case css::awt::GradientStyle_ELLIPTICAL:
1291 aTmpGradient = maGradientElliptical;
1292 break;
1293 case css::awt::GradientStyle_SQUARE:
1294 aTmpGradient = maGradientSquare;
1295 break;
1296 case css::awt::GradientStyle_RECT:
1297 aTmpGradient = maGradientRect;
1298 break;
1299 default:
1300 break;
1303 const XFillFloatTransparenceItem aGradientItem(aTmpGradient, bGradient);
1304 setFillFloatTransparence(aGradientItem);
1307 IMPL_LINK_NOARG(AreaPropertyPanelBase, ModifyTransparentHdl_Impl, weld::MetricSpinButton&, void)
1309 const sal_uInt16 nTrans = static_cast<sal_uInt16>(mxMTRTransparent->get_value(FieldUnit::PERCENT));
1310 mnLastTransSolid = nTrans;
1311 SetTransparency(nTrans);
1312 const sal_Int32 nSelectType = mxLBTransType->get_active();
1314 if(nTrans && !nSelectType)
1316 mxLBTransType->set_active(1);
1319 const XFillTransparenceItem aLinearItem(nTrans);
1320 setFillTransparence(aLinearItem);
1323 const basegfx::BGradient& AreaPropertyPanelBase::GetGradient (const css::awt::GradientStyle eStyle) const
1325 switch (eStyle)
1327 default:
1328 case css::awt::GradientStyle_LINEAR:
1329 return maGradientLinear;
1330 case css::awt::GradientStyle_AXIAL:
1331 return maGradientAxial;
1332 case css::awt::GradientStyle_RADIAL:
1333 return maGradientRadial;
1334 case css::awt::GradientStyle_ELLIPTICAL:
1335 return maGradientElliptical;
1336 case css::awt::GradientStyle_SQUARE:
1337 return maGradientSquare;
1338 case css::awt::GradientStyle_RECT:
1339 return maGradientRect;
1343 void AreaPropertyPanelBase::SetGradient (const basegfx::BGradient& rGradient)
1345 switch (rGradient.GetGradientStyle())
1347 case css::awt::GradientStyle_LINEAR:
1348 maGradientLinear = rGradient;
1349 break;
1350 case css::awt::GradientStyle_AXIAL:
1351 maGradientAxial = rGradient;
1352 break;
1353 case css::awt::GradientStyle_RADIAL:
1354 maGradientRadial = rGradient;
1355 break;
1356 case css::awt::GradientStyle_ELLIPTICAL:
1357 maGradientElliptical = rGradient;
1358 break;
1359 case css::awt::GradientStyle_SQUARE:
1360 maGradientSquare = rGradient;
1361 break;
1362 case css::awt::GradientStyle_RECT:
1363 maGradientRect = rGradient;
1364 break;
1365 default:
1366 break;
1370 sal_Int32 AreaPropertyPanelBase::GetSelectedTransparencyTypeIndex() const
1372 return mxLBTransType->get_active();
1375 basegfx::BColorStops AreaPropertyPanelBase::createColorStops()
1377 basegfx::BColorStops aColorStops;
1379 if (maColorStops.size() >= 2)
1381 aColorStops = maColorStops;
1382 aColorStops.front() = basegfx::BColorStop(maColorStops.front().getStopOffset(),
1383 mxLbFillGradFrom->GetSelectEntryColor().getBColor());
1384 aColorStops.back() = basegfx::BColorStop(maColorStops.back().getStopOffset(),
1385 mxLbFillGradTo->GetSelectEntryColor().getBColor());
1387 else
1389 aColorStops.emplace_back(0.0, mxLbFillGradFrom->GetSelectEntryColor().getBColor());
1390 aColorStops.emplace_back(1.0, mxLbFillGradTo->GetSelectEntryColor().getBColor());
1393 return aColorStops;
1396 void AreaPropertyPanelBase::HandleContextChange(
1397 const vcl::EnumContext& rContext)
1399 if (maContext.GetApplication() == rContext.GetApplication())
1400 return;
1402 maContext = rContext;
1404 switch (maContext.GetApplication())
1406 case vcl::EnumContext::Application::Impress:
1407 if (!msUseBackgroundText.isEmpty())
1409 mxLbFillType->insert_text(USE_BACKGROUND, msUseBackgroundText);
1410 msUseBackgroundText = OUString();
1412 break;
1413 default:
1414 if (msUseBackgroundText.isEmpty())
1416 msUseBackgroundText = mxLbFillType->get_text(USE_BACKGROUND);
1417 mxLbFillType->remove(USE_BACKGROUND);
1419 break;
1423 } // end of namespace svx::sidebar
1425 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */