diff options
-rw-r--r-- | cui/source/inc/cuitabarea.hxx | 8 | ||||
-rw-r--r-- | cui/source/tabpages/tpgradnt.cxx | 25 | ||||
-rw-r--r-- | cui/source/tabpages/tptrans.cxx | 28 | ||||
-rw-r--r-- | include/svx/sidebar/AreaPropertyPanelBase.hxx | 4 | ||||
-rw-r--r-- | include/svx/sidebar/AreaTransparencyGradientPopup.hxx | 4 | ||||
-rw-r--r-- | sd/source/ui/sidebar/SlideBackground.cxx | 25 | ||||
-rw-r--r-- | sd/source/ui/sidebar/SlideBackground.hxx | 4 | ||||
-rw-r--r-- | svx/source/sidebar/area/AreaPropertyPanelBase.cxx | 33 | ||||
-rw-r--r-- | svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx | 42 |
9 files changed, 105 insertions, 68 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; } diff --git a/include/svx/sidebar/AreaPropertyPanelBase.hxx b/include/svx/sidebar/AreaPropertyPanelBase.hxx index 8e822dfd4f47..c2c967a8333b 100644 --- a/include/svx/sidebar/AreaPropertyPanelBase.hxx +++ b/include/svx/sidebar/AreaPropertyPanelBase.hxx @@ -151,7 +151,7 @@ protected: std::unique_ptr< XFillFloatTransparenceItem > mpFloatTransparenceItem; std::unique_ptr< SfxUInt16Item > mpTransparenceItem; - // 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_DLLPRIVATE_LINK(SelectFillTypeHdl, weld::ComboBox&, void ); @@ -169,7 +169,7 @@ protected: void SelectFillAttrHdl_Impl(); void FillStyleChanged(bool bUpdateModel); - // 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(); }; diff --git a/include/svx/sidebar/AreaTransparencyGradientPopup.hxx b/include/svx/sidebar/AreaTransparencyGradientPopup.hxx index bd6b24b6c828..6caf6487417b 100644 --- a/include/svx/sidebar/AreaTransparencyGradientPopup.hxx +++ b/include/svx/sidebar/AreaTransparencyGradientPopup.hxx @@ -45,11 +45,11 @@ private: std::unique_ptr<weld::MetricSpinButton> mxMtrTrgrEndValue; std::unique_ptr<weld::MetricSpinButton> mxMtrTrgrBorder; - // 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; void InitStatus(XFillFloatTransparenceItem const* pGradientItem); - void ExecuteValueModify(sal_uInt8 nStartCol, sal_uInt8 nEndCol); + void ExecuteValueModify(); DECL_LINK(ModifiedTrgrHdl_Impl, weld::MetricSpinButton&, void); DECL_LINK(Left_Click45_Impl, const OUString&, void); DECL_LINK(Right_Click45_Impl, const OUString&, void); diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx index 274789cf523b..dd2a0f491418 100644 --- a/sd/source/ui/sidebar/SlideBackground.cxx +++ b/sd/source/ui/sidebar/SlideBackground.cxx @@ -403,9 +403,11 @@ void SlideBackground::Update() const Color aEndColor(aBGradient.GetColorStops().back().getStopColor()); mxFillGrad2->SelectEntry(aEndColor); - // MCGR: preserve in-between ColorStops if given - if (aBGradient.GetColorStops().size() > 2) - maColorStops = basegfx::BColorStops(aBGradient.GetColorStops().begin() + 1, aBGradient.GetColorStops().end() - 1); + // MCGR: preserve ColorStops if given. + // tdf#155901 We need offset of first and last stop, so include them. + if (aBGradient.GetColorStops().size() >= 2) + maColorStops = basegfx::BColorStops(aBGradient.GetColorStops().begin(), + aBGradient.GetColorStops().end()); else maColorStops.clear(); } @@ -1289,14 +1291,19 @@ basegfx::BColorStops SlideBackground::createColorStops() { basegfx::BColorStops aColorStops; - aColorStops.emplace_back(0.0, mxFillGrad1->GetSelectEntryColor().getBColor()); - - if(!maColorStops.empty()) + if (maColorStops.size() >= 2) { - aColorStops.insert(aColorStops.begin(), maColorStops.begin(), maColorStops.end()); + aColorStops.emplace_back(maColorStops.front().getStopOffset(), + mxFillGrad1->GetSelectEntryColor().getBColor()); + aColorStops.insert(aColorStops.begin(), maColorStops.begin() + 1, maColorStops.end() - 1); + aColorStops.emplace_back(maColorStops.back().getStopOffset(), + mxFillGrad2->GetSelectEntryColor().getBColor()); + } + else + { + aColorStops.emplace_back(0.0, mxFillGrad1->GetSelectEntryColor().getBColor()); + aColorStops.emplace_back(1.0, mxFillGrad2->GetSelectEntryColor().getBColor()); } - - aColorStops.emplace_back(1.0, mxFillGrad2->GetSelectEntryColor().getBColor()); return aColorStops; } diff --git a/sd/source/ui/sidebar/SlideBackground.hxx b/sd/source/ui/sidebar/SlideBackground.hxx index 3a2dd2475680..8d5932629bcd 100644 --- a/sd/source/ui/sidebar/SlideBackground.hxx +++ b/sd/source/ui/sidebar/SlideBackground.hxx @@ -138,7 +138,7 @@ private: MapUnit meUnit; - // 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(FillBackgroundHdl, weld::ComboBox&, void); @@ -176,7 +176,7 @@ private: static FieldUnit GetCurrentUnit(SfxItemState eState, const SfxPoolItem* pState); - // 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(); }; diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx index a1ff31c7186a..b84f5a45244e 100644 --- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx +++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx @@ -488,9 +488,11 @@ void AreaPropertyPanelBase::FillStyleChanged(bool bUpdateModel) mxLbFillGradFrom->SelectEntry(Color(aGradient.GetColorStops().front().getStopColor())); mxLbFillGradTo->SelectEntry(Color(aGradient.GetColorStops().back().getStopColor())); - // MCGR: preserve in-between ColorStops if given - if (aGradient.GetColorStops().size() > 2) - maColorStops = basegfx::BColorStops(aGradient.GetColorStops().begin() + 1, aGradient.GetColorStops().end() - 1); + // MCGR: preserve ColorStops if given + // tdf#155901 We need offset of first and last stop, so include them. + if (aGradient.GetColorStops().size() >= 2) + maColorStops = basegfx::BColorStops(aGradient.GetColorStops().begin(), + aGradient.GetColorStops().end()); else maColorStops.clear(); @@ -515,9 +517,11 @@ void AreaPropertyPanelBase::FillStyleChanged(bool bUpdateModel) mxLbFillGradFrom->SelectEntry(Color(aGradient.GetColorStops().front().getStopColor())); mxLbFillGradTo->SelectEntry(Color(aGradient.GetColorStops().back().getStopColor())); - // MCGR: preserve in-between ColorStops if given - if (aGradient.GetColorStops().size() > 2) - maColorStops = basegfx::BColorStops(aGradient.GetColorStops().begin() + 1, aGradient.GetColorStops().end() - 1); + // MCGR: preserve ColorStops if given + // tdf#155901 We need offset of first and last stop, so include them. + if (aGradient.GetColorStops().size() >= 2) + maColorStops = basegfx::BColorStops(aGradient.GetColorStops().begin(), + aGradient.GetColorStops().end()); else maColorStops.clear(); @@ -1369,14 +1373,19 @@ basegfx::BColorStops AreaPropertyPanelBase::createColorStops() { basegfx::BColorStops aColorStops; - aColorStops.emplace_back(0.0, mxLbFillGradFrom->GetSelectEntryColor().getBColor()); - - if(!maColorStops.empty()) + if (maColorStops.size() >= 2) { - aColorStops.insert(aColorStops.begin(), maColorStops.begin(), maColorStops.end()); + aColorStops.emplace_back(maColorStops.front().getStopOffset(), + mxLbFillGradFrom->GetSelectEntryColor().getBColor()); + aColorStops.insert(aColorStops.begin(), maColorStops.begin() + 1, maColorStops.end() - 1); + aColorStops.emplace_back(maColorStops.back().getStopOffset(), + mxLbFillGradTo->GetSelectEntryColor().getBColor()); + } + else + { + aColorStops.emplace_back(0.0, mxLbFillGradFrom->GetSelectEntryColor().getBColor()); + aColorStops.emplace_back(1.0, mxLbFillGradTo->GetSelectEntryColor().getBColor()); } - - aColorStops.emplace_back(1.0, mxLbFillGradTo->GetSelectEntryColor().getBColor()); return aColorStops; } diff --git a/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx b/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx index df943359ff19..6a717551e456 100644 --- a/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx +++ b/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx @@ -84,9 +84,11 @@ void AreaTransparencyGradientPopup::InitStatus(XFillFloatTransparenceItem const mxMtrTrgrStartValue->set_value(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(aStart.GetRed()) + 1) * 100) / 255), FieldUnit::PERCENT); mxMtrTrgrEndValue->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 (aGradient.GetColorStops().size() > 2) - maColorStops = basegfx::BColorStops(aGradient.GetColorStops().begin() + 1, aGradient.GetColorStops().end() - 1); + // MCGR: preserve ColorStops if given + // tdf#155901 We need offset of first and last stop, so include them. + if (aGradient.GetColorStops().size() >= 2) + maColorStops = basegfx::BColorStops(aGradient.GetColorStops().begin(), + aGradient.GetColorStops().end()); else maColorStops.clear(); @@ -121,7 +123,7 @@ void AreaTransparencyGradientPopup::Rearrange(XFillFloatTransparenceItem const * } } -void AreaTransparencyGradientPopup::ExecuteValueModify(sal_uInt8 nStartCol, sal_uInt8 nEndCol) +void AreaTransparencyGradientPopup::ExecuteValueModify() { //Added sal_Int16 aMtrValue = static_cast<sal_Int16>(mxMtrTrgrAngle->get_value(FieldUnit::DEGREE)); @@ -133,10 +135,22 @@ void AreaTransparencyGradientPopup::ExecuteValueModify(sal_uInt8 nStartCol, sal_ //End of new code basegfx::BColorStops aColorStops; - aColorStops.emplace_back(0.0, Color(nStartCol, nStartCol, nStartCol).getBColor()); - if(!maColorStops.empty()) - aColorStops.insert(aColorStops.begin(), maColorStops.begin(), maColorStops.end()); - aColorStops.emplace_back(1.0, Color(nEndCol, nEndCol, nEndCol).getBColor()); + basegfx::BColor aStartBColor(mxMtrTrgrStartValue->get_value(FieldUnit::PERCENT) / 100.0); + aStartBColor.clamp(); + basegfx::BColor aEndBColor(mxMtrTrgrEndValue->get_value(FieldUnit::PERCENT) / 100.0); + aEndBColor.clamp(); + + if (maColorStops.size() >= 2) + { + 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); + } basegfx::BGradient aTmpGradient( aColorStops, @@ -156,33 +170,27 @@ void AreaTransparencyGradientPopup::ExecuteValueModify(sal_uInt8 nStartCol, sal_ IMPL_LINK_NOARG(AreaTransparencyGradientPopup, ModifiedTrgrHdl_Impl, weld::MetricSpinButton&, void) { - sal_uInt8 nStartCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(mxMtrTrgrStartValue->get_value(FieldUnit::PERCENT)) * 255) / 100); - sal_uInt8 nEndCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(mxMtrTrgrEndValue->get_value(FieldUnit::PERCENT)) * 255) / 100); - ExecuteValueModify( nStartCol, nEndCol ); + ExecuteValueModify(); } IMPL_LINK_NOARG(AreaTransparencyGradientPopup, Left_Click45_Impl, const OUString&, void) { - sal_uInt8 nStartCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(mxMtrTrgrStartValue->get_value(FieldUnit::PERCENT)) * 255) / 100); - sal_uInt8 nEndCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(mxMtrTrgrEndValue->get_value(FieldUnit::PERCENT)) * 255) / 100); sal_uInt16 nTemp = static_cast<sal_uInt16>(mxMtrTrgrAngle->get_value(FieldUnit::DEGREE)); if (nTemp>=315) nTemp -= 360; nTemp += 45; mxMtrTrgrAngle->set_value(nTemp, FieldUnit::DEGREE); - ExecuteValueModify(nStartCol, nEndCol); + ExecuteValueModify(); } IMPL_LINK_NOARG(AreaTransparencyGradientPopup, Right_Click45_Impl, const OUString&, void) { - sal_uInt8 nStartCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(mxMtrTrgrStartValue->get_value(FieldUnit::PERCENT)) * 255) / 100); - sal_uInt8 nEndCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(mxMtrTrgrEndValue->get_value(FieldUnit::PERCENT)) * 255) / 100); sal_uInt16 nTemp = static_cast<sal_uInt16>(mxMtrTrgrAngle->get_value(FieldUnit::DEGREE)); if (nTemp<45) nTemp += 360; nTemp -= 45; mxMtrTrgrAngle->set_value(nTemp, FieldUnit::DEGREE); - ExecuteValueModify(nStartCol, nEndCol); + ExecuteValueModify(); } void AreaTransparencyGradientPopup::GrabFocus() |