36#include <svx/strings.hrc>
43 :
SfxTabPage(pPage, pController,
"cui/ui/gradientpage.ui",
"GradientPage", &rInAttrs)
44 , m_rOutAttrs(rInAttrs)
45 , m_pnGradientListState(nullptr)
46 , m_pnColorListState(nullptr)
47 , m_aXFillAttr(rInAttrs.GetPool())
49 , m_xLbGradientType(m_xBuilder->weld_combo_box(
"gradienttypelb"))
50 , m_xFtCenter(m_xBuilder->weld_label(
"centerft"))
51 , m_xMtrCenterX(m_xBuilder->weld_metric_spin_button(
"centerxmtr",
FieldUnit::
PERCENT))
52 , m_xMtrCenterY(m_xBuilder->weld_metric_spin_button(
"centerymtr",
FieldUnit::
PERCENT))
53 , m_xFtAngle(m_xBuilder->weld_label(
"angleft"))
54 , m_xMtrAngle(m_xBuilder->weld_metric_spin_button(
"anglemtr",
FieldUnit::
DEGREE))
55 , m_xSliderAngle(m_xBuilder->weld_scale(
"angleslider"))
56 , m_xMtrBorder(m_xBuilder->weld_metric_spin_button(
"bordermtr",
FieldUnit::
PERCENT))
57 , m_xSliderBorder(m_xBuilder->weld_scale(
"borderslider"))
58 , m_xLbColorFrom(new
ColorListBox(m_xBuilder->weld_menu_button(
"colorfromlb"),
60 , m_xMtrColorFrom(m_xBuilder->weld_metric_spin_button(
"colorfrommtr", FieldUnit::PERCENT))
61 , m_xLbColorTo(
new ColorListBox(m_xBuilder->weld_menu_button(
"colortolb"),
62 [
this]{ return GetDialogController()->getDialog(); }))
63 , m_xMtrColorTo(m_xBuilder->weld_metric_spin_button(
"colortomtr", FieldUnit::PERCENT))
64 , m_xGradientLB(
new SvxPresetListBox(m_xBuilder->weld_scrolled_window(
"gradientpresetlistwin",
true)))
65 , m_xMtrIncrement(m_xBuilder->weld_spin_button(
"incrementmtr"))
66 , m_xCbIncrement(m_xBuilder->weld_check_button(
"autoincrement"))
67 , m_xBtnAdd(m_xBuilder->weld_button(
"add"))
68 , m_xBtnModify(m_xBuilder->weld_button(
"modify"))
69 , m_xCtlPreview(
new weld::CustomWeld(*m_xBuilder,
"previewctl", m_aCtlPreview))
70 , m_xGradientLBWin(
new weld::CustomWeld(*m_xBuilder,
"gradientpresetlist", *m_xGradientLB))
73 m_xGradientLB->set_size_request(aSize.
Width(), aSize.
Height());
74 m_xCtlPreview->set_size_request(aSize.
Width(), aSize.
Height());
80 m_xMtrColorTo->set_value(100, FieldUnit::PERCENT);
81 m_xMtrColorFrom->set_value(100, FieldUnit::PERCENT);
86 m_aCtlPreview.SetAttributes(m_aXFillAttr.GetItemSet());
97 m_xLbGradientType->connect_changed( aLink2 );
100 m_xMtrCenterX->connect_value_changed( aLink );
101 m_xMtrCenterY->connect_value_changed( aLink );
102 m_xMtrAngle->connect_value_changed( aLink );
104 m_xMtrBorder->connect_value_changed( aLink );
106 m_xMtrColorFrom->connect_value_changed( aLink );
108 m_xLbColorFrom->SetSelectHdl( aLink3 );
109 m_xMtrColorTo->connect_value_changed( aLink );
110 m_xLbColorTo->SetSelectHdl( aLink3 );
112 m_xGradientLB->SetStyle(WB_FLATVALUESET | WB_NO_DIRECTSELECT | WB_TABSTOP);
115 m_aCtlPreview.EnableRTL(
false);
151 OUString aString =
CuiResId( RID_CUISTR_TABLE ) +
": ";
155 SAL_WARN_IF(
aURL.GetProtocol() == INetProtocol::NotValid,
"cui.tabpages",
"invalid URL" );
157 if (
aURL.getBase().getLength() > 18 )
159 aString += OUString::Concat(
aURL.getBase().subView( 0, 15 )) +
"...";
162 aString +=
aURL.getBase();
180 return DeactivateRC::LeavePage;
185 std::unique_ptr<basegfx::BGradient> pBGradient;
197 pBGradient->SetSteps(
nValue);
207 static_cast<sal_uInt16
>(
m_xMtrCenterX->get_value(FieldUnit::NONE)),
208 static_cast<sal_uInt16
>(
m_xMtrCenterY->get_value(FieldUnit::NONE)),
209 static_cast<sal_uInt16
>(
m_xMtrBorder->get_value(FieldUnit::NONE)),
211 static_cast<sal_uInt16
>(
m_xMtrColorTo->get_value(FieldUnit::NONE)),
216 assert( pBGradient &&
"basegfx::BGradient could not be created" );
236 return std::make_unique<SvxGradientTabPage>(pPage, pController, *rOutAttrs);
241 ModifiedHdl_Impl(&rListBox);
243 m_xGradientLB->SetNoSelection();
248 ModifiedHdl_Impl(&rListBox);
249 m_xGradientLB->SetNoSelection();
254 ModifiedHdl_Impl(&rBox);
255 m_xGradientLB->SetNoSelection();
260 ModifiedHdl_Impl(&rBox);
261 m_xGradientLB->SetNoSelection();
266 ModifiedHdl_Impl(&rSlider);
267 m_xGradientLB->SetNoSelection();
272 if (m_xCbIncrement->get_active())
274 m_xMtrIncrement->set_sensitive(
false);
278 m_xMtrIncrement->set_sensitive(
true);
280 ModifiedHdl_Impl(m_xMtrIncrement.get());
294 css::awt::GradientStyle eXGS =
static_cast<css::awt::GradientStyle
>(
m_xLbGradientType->get_active());
304 static_cast<sal_uInt16
>(
m_xMtrCenterX->get_value(FieldUnit::NONE)),
305 static_cast<sal_uInt16
>(
m_xMtrCenterY->get_value(FieldUnit::NONE)),
306 static_cast<sal_uInt16
>(
m_xMtrBorder->get_value(FieldUnit::NONE)),
308 static_cast<sal_uInt16
>(
m_xMtrColorTo->get_value(FieldUnit::NONE)),
325 OUString aNewName(
SvxResId( RID_SVXSTR_GRADIENT ) );
326 OUString aDesc(
CuiResId( RID_CUISTR_DESC_GRADIENT ) );
331 bool bValidGradientName =
false;
333 while( !bValidGradientName )
335 aName = aNewName +
" " + OUString::number( j++ );
336 bValidGradientName = (SearchGradientList(
aName) == -1);
341 sal_uInt16 nError = 1;
343 while (pDlg->Execute() ==
RET_OK)
345 pDlg->GetName(
aName );
347 bValidGradientName = (SearchGradientList(
aName) == -1);
349 if (bValidGradientName)
356 std::unique_ptr<weld::MessageDialog> xWarnBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
357 if (xWarnBox->run() !=
RET_OK)
365 if (!m_xCbIncrement->get_active())
366 nValue = m_xMtrIncrement->get_value();
369 static_cast<css::awt::GradientStyle
>(m_xLbGradientType->get_active()),
370 Degree10(
static_cast<sal_Int16
>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)),
371 static_cast<sal_uInt16
>(m_xMtrCenterX->get_value(FieldUnit::NONE)),
372 static_cast<sal_uInt16
>(m_xMtrCenterY->get_value(FieldUnit::NONE)),
373 static_cast<sal_uInt16
>(m_xMtrBorder->get_value(FieldUnit::NONE)),
374 static_cast<sal_uInt16
>(m_xMtrColorFrom->get_value(FieldUnit::NONE)),
375 static_cast<sal_uInt16
>(m_xMtrColorTo->get_value(FieldUnit::NONE)),
378 m_pGradientList->Insert(std::make_unique<XGradientEntry>(aBGradient,
aName),
nCount);
380 sal_Int32
nId = m_xGradientLB->GetItemId(
nCount - 1);
381 BitmapEx aBitmap = m_pGradientList->GetBitmapForPreview(
nCount, m_xGradientLB->GetIconSize() );
383 m_xGradientLB->SelectItem(
nId + 1 );
384 m_xGradientLB->Resize();
386 *m_pnGradientListState |= ChangeType::MODIFIED;
388 ChangeGradientHdl_Impl();
392 if (m_pGradientList->Count())
393 m_xBtnModify->set_sensitive(
true);
399 sal_uInt16
nId = m_xGradientLB->GetSelectedItemId();
400 size_t nPos = m_xGradientLB->GetSelectItemPos();
405 OUString
aName( m_pGradientList->GetGradient(
static_cast<sal_uInt16
>(
nPos) )->GetName() );
408 if (!m_xCbIncrement->get_active())
409 nValue = m_xMtrIncrement->get_value();
413 static_cast<css::awt::GradientStyle
>(m_xLbGradientType->get_active()),
414 Degree10(
static_cast<sal_Int16
>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)),
415 static_cast<sal_uInt16
>(m_xMtrCenterX->get_value(FieldUnit::NONE)),
416 static_cast<sal_uInt16
>(m_xMtrCenterY->get_value(FieldUnit::NONE)),
417 static_cast<sal_uInt16
>(m_xMtrBorder->get_value(FieldUnit::NONE)),
418 static_cast<sal_uInt16
>(m_xMtrColorFrom->get_value(FieldUnit::NONE)),
419 static_cast<sal_uInt16
>(m_xMtrColorTo->get_value(FieldUnit::NONE)),
422 m_pGradientList->Replace(std::make_unique<XGradientEntry>(aBGradient,
aName),
nPos);
424 BitmapEx aBitmap = m_pGradientList->GetBitmapForPreview(
static_cast<sal_uInt16
>(
nPos), m_xGradientLB->GetIconSize() );
425 m_xGradientLB->RemoveItem(
nId );
426 m_xGradientLB->InsertItem(
nId,
Image(aBitmap),
aName,
static_cast<sal_uInt16
>(
nPos) );
427 m_xGradientLB->SelectItem(
nId );
429 *m_pnGradientListState |= ChangeType::MODIFIED;
434 sal_uInt16
nId = m_xGradientLB->GetSelectedItemId();
435 size_t nPos = m_xGradientLB->GetSelectItemPos();
440 std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog(
"AskDelGradientDialog"));
441 if (xQueryBox->run() ==
RET_YES)
443 m_pGradientList->Remove(
nPos);
444 m_xGradientLB->RemoveItem(
nId );
445 nId = m_xGradientLB->GetItemId( 0 );
446 m_xGradientLB->SelectItem(
nId );
447 m_xGradientLB->Resize();
449 m_aCtlPreview.Invalidate();
451 ChangeGradientHdl_Impl();
453 *m_pnGradientListState |= ChangeType::MODIFIED;
457 if( !m_pGradientList->Count() )
458 m_xBtnModify->set_sensitive(
false);
463 sal_uInt16
nId = m_xGradientLB->GetSelectedItemId();
464 size_t nPos = m_xGradientLB->GetSelectItemPos();
469 OUString aDesc(
CuiResId( RID_CUISTR_DESC_GRADIENT ) );
470 OUString
aName( m_pGradientList->GetGradient(
nPos )->GetName() );
476 while( bLoop && pDlg->Execute() ==
RET_OK )
478 pDlg->GetName(
aName );
479 sal_Int32 nGradientPos = SearchGradientList(
aName);
480 bool bValidGradientName = (nGradientPos ==
static_cast<sal_Int32
>(
nPos) ) || (nGradientPos == -1);
482 if( bValidGradientName )
485 m_pGradientList->GetGradient(
nPos)->SetName(
aName);
487 m_xGradientLB->SetItemText(
nId,
aName );
488 m_xGradientLB->SelectItem(
nId );
490 *m_pnGradientListState |= ChangeType::MODIFIED;
495 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
503 ChangeGradientHdl_Impl();
508 std::unique_ptr<basegfx::BGradient> pGradient;
518 if( ( drawing::FillStyle_GRADIENT == pFillStyleItem->GetValue() ) &&
536 css::awt::GradientStyle eXGS = pGradient->GetGradientStyle();
537 sal_uInt16
nValue = pGradient->GetSteps();
540 nValue = pGradientStepCountItem->GetValue();
554 sal::static_int_cast< sal_Int32 >( eXGS ) );
561 m_xLbColorTo->SelectEntry(
Color(pGradient->GetColorStops().back().getStopColor()));
565 if (pGradient->GetColorStops().size() >= 2)
570 m_xMtrAngle->set_value(pGradient->GetAngle().get() / 10, FieldUnit::NONE);
572 m_xMtrBorder->set_value(pGradient->GetBorder(), FieldUnit::NONE);
574 m_xMtrCenterX->set_value(pGradient->GetXOffset(), FieldUnit::NONE);
575 m_xMtrCenterY->set_value(pGradient->GetYOffset(), FieldUnit::NONE);
576 m_xMtrColorFrom->set_value(pGradient->GetStartIntens(), FieldUnit::NONE);
577 m_xMtrColorTo->set_value(pGradient->GetEndIntens(), FieldUnit::NONE);
594 case css::awt::GradientStyle_LINEAR:
595 case css::awt::GradientStyle_AXIAL:
604 case css::awt::GradientStyle_RADIAL:
613 case css::awt::GradientStyle_ELLIPTICAL:
622 case css::awt::GradientStyle_SQUARE:
623 case css::awt::GradientStyle_RECT:
639 bool bValidGradientName =
true;
647 bValidGradientName =
false;
667 aColorStops.emplace_back(0.0,
m_xLbColorFrom->GetSelectEntryColor().getBColor());
668 aColorStops.emplace_back(1.0,
m_xLbColorTo->GetSelectEntryColor().getBColor());
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SfxOkDialogController * GetDialogController() const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
virtual VclPtr< AbstractSvxNameDialog > CreateSvxNameDialog(weld::Window *pParent, const OUString &rName, const OUString &rDesc)=0
static SvxAbstractDialogFactory * Create()
const XColorListRef & GetNewColorList() const
std::unique_ptr< weld::SpinButton > m_xMtrIncrement
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
basegfx::BColorStops createColorStops()
virtual void Reset(const SfxItemSet *) override
std::unique_ptr< ColorListBox > m_xLbColorFrom
std::unique_ptr< weld::MetricSpinButton > m_xMtrCenterX
virtual void ActivatePage(const SfxItemSet &rSet) override
std::unique_ptr< weld::CustomWeld > m_xGradientLBWin
std::unique_ptr< weld::Label > m_xFtAngle
std::unique_ptr< weld::MetricSpinButton > m_xMtrColorFrom
void SetControlState_Impl(css::awt::GradientStyle eXGS)
std::unique_ptr< weld::CheckButton > m_xCbIncrement
std::unique_ptr< weld::ComboBox > m_xLbGradientType
SvxXRectPreview m_aCtlPreview
void ChangeGradientHdl_Impl()
XFillAttrSetItem m_aXFillAttr
void ModifiedHdl_Impl(void const *)
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
std::unique_ptr< weld::Button > m_xBtnModify
std::unique_ptr< weld::CustomWeld > m_xCtlPreview
std::unique_ptr< ColorListBox > m_xLbColorTo
sal_Int32 SearchGradientList(std::u16string_view rGradientName)
std::unique_ptr< weld::Scale > m_xSliderAngle
std::unique_ptr< weld::Scale > m_xSliderBorder
XGradientListRef m_pGradientList
SvxGradientTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
virtual bool FillItemSet(SfxItemSet *) override
virtual ~SvxGradientTabPage() override
std::unique_ptr< SvxPresetListBox > m_xGradientLB
std::unique_ptr< weld::Label > m_xFtCenter
ChangeType * m_pnColorListState
XColorListRef m_pColorList
std::unique_ptr< weld::MetricSpinButton > m_xMtrColorTo
basegfx::BColorStops m_aColorStops
const SfxItemSet & m_rOutAttrs
std::unique_ptr< weld::MetricSpinButton > m_xMtrBorder
std::unique_ptr< weld::MetricSpinButton > m_xMtrCenterY
std::unique_ptr< weld::MetricSpinButton > m_xMtrAngle
void SetAttributes(const SfxItemSet &rItemSet)
const basegfx::BGradient & GetGradientValue() const
OUString CuiResId(TranslateId aKey)
SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Size SFX2_DLLPUBLIC getDrawPreviewOptimalSize(const OutputDevice &rReference)
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
IMPL_LINK(SvxGradientTabPage, ModifiedListBoxHdl_Impl, weld::ComboBox &, rListBox, void)
IMPL_LINK_NOARG(SvxGradientTabPage, ChangeAutoStepHdl_Impl, weld::Toggleable &, void)
#define VALUESET_ITEM_NOTFOUND
constexpr OUStringLiteral PERCENT(u"Percent")
constexpr TypedWhichId< XGradientStepCountItem > XATTR_GRADIENTSTEPCOUNT(XATTR_FILL_FIRST+6)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)