summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
Diffstat (limited to 'cui')
-rw-r--r--cui/source/inc/cuitabarea.hxx8
-rw-r--r--cui/source/tabpages/tpgradnt.cxx25
-rw-r--r--cui/source/tabpages/tptrans.cxx28
3 files changed, 37 insertions, 24 deletions
diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx
index 2d6c713236da..4e766c76e57d 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -169,7 +169,7 @@ class SvxTransparenceTabPage : public SfxTabPage
std::unique_ptr<weld::CustomWeld> m_xCtlBitmapPreview;
std::unique_ptr<weld::CustomWeld> m_xCtlXRectPreview;
- // MCGR: Preserve in-between ColorStops until we have an UI to edit these
+ // MCGR: Preserve ColorStops until we have a UI to edit these
basegfx::BColorStops maColorStops;
DECL_LINK(ClickTransOffHdl_Impl, weld::Toggleable&, void);
@@ -187,7 +187,7 @@ class SvxTransparenceTabPage : public SfxTabPage
bool InitPreview ( const SfxItemSet& rSet );
void InvalidatePreview (bool bEnable = true );
- // MCGR: Preserve in-between ColorStops until we have an UI to edit these
+ // MCGR: Preserve ColorStops until we have a UI to edit these
basegfx::BColorStops createColorStops();
public:
@@ -367,7 +367,7 @@ private:
XFillAttrSetItem m_aXFillAttr;
SfxItemSet& m_rXFSet;
- // MCGR: Preserve in-between ColorStops until we have an UI to edit these
+ // MCGR: Preserve ColorStops until we have a UI to edit these
basegfx::BColorStops m_aColorStops;
SvxXRectPreview m_aCtlPreview;
@@ -409,7 +409,7 @@ private:
void SetControlState_Impl( css::awt::GradientStyle eXGS );
sal_Int32 SearchGradientList(std::u16string_view rGradientName);
- // MCGR: Preserve in-between ColorStops until we have an UI to edit these
+ // MCGR: Preserve ColorStops until we have a UI to edit these
basegfx::BColorStops createColorStops();
public:
diff --git a/cui/source/tabpages/tpgradnt.cxx b/cui/source/tabpages/tpgradnt.cxx
index 7f6630747a42..d3d066236ae1 100644
--- a/cui/source/tabpages/tpgradnt.cxx
+++ b/cui/source/tabpages/tpgradnt.cxx
@@ -548,9 +548,11 @@ void SvxGradientTabPage::ChangeGradientHdl_Impl()
m_xLbColorTo->SetNoSelection();
m_xLbColorTo->SelectEntry(Color(pGradient->GetColorStops().back().getStopColor()));
- // MCGR: preserve in-between ColorStops if given
- if (pGradient->GetColorStops().size() > 2)
- m_aColorStops = basegfx::BColorStops(pGradient->GetColorStops().begin() + 1, pGradient->GetColorStops().end() - 1);
+ // MCGR: preserve ColorStops if given.
+ // tdf#155901 We need offset of first and last stop, so include them.
+ if (pGradient->GetColorStops().size() >= 2)
+ m_aColorStops = basegfx::BColorStops(pGradient->GetColorStops().begin(),
+ pGradient->GetColorStops().end());
else
m_aColorStops.clear();
@@ -641,14 +643,19 @@ basegfx::BColorStops SvxGradientTabPage::createColorStops()
{
basegfx::BColorStops aColorStops;
- aColorStops.emplace_back(0.0, m_xLbColorFrom->GetSelectEntryColor().getBColor());
-
- if(!m_aColorStops.empty())
+ if(m_aColorStops.size() >= 2)
{
- aColorStops.insert(aColorStops.begin(), m_aColorStops.begin(), m_aColorStops.end());
+ aColorStops.emplace_back(m_aColorStops.front().getStopOffset(),
+ m_xLbColorFrom->GetSelectEntryColor().getBColor());
+ aColorStops.insert(aColorStops.begin(), m_aColorStops.begin() + 1, m_aColorStops.end() - 1);
+ aColorStops.emplace_back(m_aColorStops.back().getStopOffset(),
+ m_xLbColorTo->GetSelectEntryColor().getBColor());
+ }
+ else
+ {
+ aColorStops.emplace_back(0.0, m_xLbColorFrom->GetSelectEntryColor().getBColor());
+ aColorStops.emplace_back(1.0, m_xLbColorTo->GetSelectEntryColor().getBColor());
}
-
- aColorStops.emplace_back(1.0, m_xLbColorTo->GetSelectEntryColor().getBColor());
return aColorStops;
}
diff --git a/cui/source/tabpages/tptrans.cxx b/cui/source/tabpages/tptrans.cxx
index 1dc675613d12..3d157850a526 100644
--- a/cui/source/tabpages/tptrans.cxx
+++ b/cui/source/tabpages/tptrans.cxx
@@ -367,9 +367,10 @@ void SvxTransparenceTabPage::Reset(const SfxItemSet* rAttrs)
m_xMtrTrgrStartValue->set_value(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(aStart.GetRed()) + 1) * 100) / 255), FieldUnit::PERCENT);
m_xMtrTrgrEndValue->set_value(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(aEnd.GetRed()) + 1) * 100) / 255), FieldUnit::PERCENT);
- // MCGR: preserve in-between ColorStops if given
- if (rGradient.GetColorStops().size() > 2)
- maColorStops = basegfx::BColorStops(rGradient.GetColorStops().begin() + 1, rGradient.GetColorStops().end() - 1);
+ // MCGR: preserve ColorStops if given
+ // tdf#155901 We need offset of first and last stop, so include them.
+ if (rGradient.GetColorStops().size() >= 2)
+ maColorStops = basegfx::BColorStops(rGradient.GetColorStops().begin(), rGradient.GetColorStops().end());
else
maColorStops.clear();
@@ -511,17 +512,22 @@ void SvxTransparenceTabPage::InvalidatePreview (bool bEnable)
basegfx::BColorStops SvxTransparenceTabPage::createColorStops()
{
basegfx::BColorStops aColorStops;
- const sal_uInt8 nStartCol(static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrStartValue->get_value(FieldUnit::PERCENT)) * 255) / 100));
- const sal_uInt8 nEndCol(static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrEndValue->get_value(FieldUnit::PERCENT)) * 255) / 100));
+ basegfx::BColor aStartBColor(m_xMtrTrgrStartValue->get_value(FieldUnit::PERCENT) / 100.0);
+ aStartBColor.clamp();
+ basegfx::BColor aEndBColor(m_xMtrTrgrEndValue->get_value(FieldUnit::PERCENT) / 100.0);
+ aEndBColor.clamp();
- aColorStops.emplace_back(0.0, Color(nStartCol, nStartCol, nStartCol).getBColor());
-
- if(!maColorStops.empty())
+ if(maColorStops.size() >= 2)
{
- aColorStops.insert(aColorStops.begin(), maColorStops.begin(), maColorStops.end());
+ aColorStops.emplace_back(maColorStops.front().getStopOffset(), aStartBColor);
+ aColorStops.insert(aColorStops.begin(), maColorStops.begin() + 1, maColorStops.end() - 1);
+ aColorStops.emplace_back(maColorStops.back().getStopOffset(), aEndBColor);
+ }
+ else
+ {
+ aColorStops.emplace_back(0.0, aStartBColor);
+ aColorStops.emplace_back(1.0, aEndBColor);
}
-
- aColorStops.emplace_back(1.0, Color(nEndCol, nEndCol, nEndCol).getBColor());
return aColorStops;
}