diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2023-05-12 15:32:51 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2023-05-15 15:19:53 +0200 |
commit | 438f0752deaf7d6e6d9d1df381b64aca4628e944 (patch) | |
tree | f1907b25dad1cbf2604b16c657e11f5623c8b5b2 /svx/source | |
parent | efa965969c6d3dfe5745a535605a6b9a482a03bd (diff) |
MCGR: consolidations/cleanups for changes so far
Change-Id: I85cf40e4803b0485bb40349d8e81adc8123666c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151706
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShape2d.cxx | 11 | ||||
-rw-r--r-- | svx/source/sdr/primitive2d/sdrattributecreator.cxx | 317 | ||||
-rw-r--r-- | svx/source/sidebar/area/AreaPropertyPanelBase.cxx | 24 | ||||
-rw-r--r-- | svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx | 13 | ||||
-rw-r--r-- | svx/source/svdraw/gradtrns.cxx | 8 | ||||
-rw-r--r-- | svx/source/svdraw/gradtrns.hxx | 5 | ||||
-rw-r--r-- | svx/source/svdraw/svdetc.cxx | 3 | ||||
-rw-r--r-- | svx/source/svdraw/svdfmtf.cxx | 31 | ||||
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 3 | ||||
-rw-r--r-- | svx/source/svdraw/svdoashp.cxx | 4 | ||||
-rw-r--r-- | svx/source/tbxctrls/fillctrl.cxx | 4 | ||||
-rw-r--r-- | svx/source/unodraw/XPropertyTable.cxx | 55 | ||||
-rw-r--r-- | svx/source/unodraw/unobrushitemhelper.cxx | 8 | ||||
-rw-r--r-- | svx/source/xoutdev/xattr.cxx | 301 | ||||
-rw-r--r-- | svx/source/xoutdev/xpool.cxx | 8 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabgrdt.cxx | 21 | ||||
-rw-r--r-- | svx/source/xoutdev/xtable.cxx | 2 |
17 files changed, 165 insertions, 653 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index e6b0173c5bc2..bca864f05fe3 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -41,7 +41,6 @@ #include <svx/xflgrit.hxx> #include <svx/xflhtit.hxx> #include <svx/xbtmpit.hxx> -#include <svx/xgrad.hxx> #include <svx/xhatch.hxx> #include <svx/sdshitm.hxx> #include <com/sun/star/awt/Size.hpp> @@ -2800,24 +2799,24 @@ void EnhancedCustomShape2d::AdaptObjColor( } case drawing::FillStyle_GRADIENT: { - XGradient aXGradient(rObj.GetMergedItem(XATTR_FILLGRADIENT).GetGradientValue()); + basegfx::BGradient aBGradient(rObj.GetMergedItem(XATTR_FILLGRADIENT).GetGradientValue()); if ( nColorCount || 0.0 != dBrightness ) { - basegfx::ColorStops aColorStops(aXGradient.GetColorStops()); + basegfx::BColorStops aColorStops(aBGradient.GetColorStops()); for (auto& candidate : aColorStops) { - candidate = basegfx::ColorStop( + candidate = basegfx::BColorStop( candidate.getStopOffset(), GetColorData( Color(candidate.getStopColor()), std::min(nColorIndex, nColorCount-1), dBrightness ).getBColor()); } - aXGradient.SetColorStops(aColorStops); + aBGradient.SetColorStops(aColorStops); } - rObj.SetMergedItem( XFillGradientItem( "", aXGradient ) ); + rObj.SetMergedItem( XFillGradientItem( "", aBGradient ) ); break; } case drawing::FillStyle_HATCH: diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx index d620f8468395..aad8ba4576e4 100644 --- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx +++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx @@ -415,9 +415,9 @@ namespace drawinglayer::primitive2d if((pGradientItem = rSet.GetItemIfSet(XATTR_FILLFLOATTRANSPARENCE, true)) && pGradientItem->IsEnabled()) { - const XGradient& rGradient = pGradientItem->GetGradientValue(); + const basegfx::BGradient& rGradient = pGradientItem->GetGradientValue(); basegfx::BColor aSingleColor; - const bool bSingleColor(basegfx::utils::isSingleColor(rGradient.GetColorStops(), aSingleColor)); + const bool bSingleColor(rGradient.GetColorStops().isSingleColor(aSingleColor)); const bool bCompletelyTransparent(bSingleColor && basegfx::fTools::equal(aSingleColor.luminance(), 1.0)); if(bCompletelyTransparent) @@ -443,309 +443,27 @@ namespace drawinglayer::primitive2d } case drawing::FillStyle_GRADIENT : { - XGradient aXGradient(rSet.Get(XATTR_FILLGRADIENT).GetGradientValue()); - basegfx::ColorStops aColorStops(aXGradient.GetColorStops()); + basegfx::BGradient aBGradient(rSet.Get(XATTR_FILLGRADIENT).GetGradientValue()); + basegfx::BColorStops aColorStops(aBGradient.GetColorStops()); - // test code here, can/will be removed later - static const char* pUseGradientSteps(std::getenv("MCGR_TEST")); - static int nUseGradientSteps(pUseGradientSteps ? std::atoi(pUseGradientSteps) : 0); - switch(nUseGradientSteps) - { - case 1: - { - // just test a nice valid gradient - aColorStops.clear(); - aColorStops.emplace_back(0.0, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.25, COL_LIGHTGREEN.getBColor()); // green@25% - aColorStops.emplace_back(0.50, COL_YELLOW.getBColor()); // yellow@50% - aColorStops.emplace_back(0.75, COL_LIGHTMAGENTA.getBColor()); // pink@75% - aColorStops.emplace_back(1.0, COL_LIGHTBLUE.getBColor()); // blue - break; - } - - case 2: - { - // single added in-between, no change of start/end - aColorStops.clear(); - aColorStops.emplace_back(0.0, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.5, COL_YELLOW.getBColor()); // yellow@50% - aColorStops.emplace_back(1.0, COL_LIGHTBLUE.getBColor()); // blue - break; - } - - case 3: - { - // check additional StartColor, the second one has to win - aColorStops.clear(); - aColorStops.emplace_back(0.0, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.0, COL_YELLOW.getBColor()); // yellow@50% - aColorStops.emplace_back(1.0, COL_LIGHTBLUE.getBColor()); // blue - break; - } - - case 4: - { - // check additional EndColor, the first one has to win - aColorStops.clear(); - aColorStops.emplace_back(0.0, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(1.0, COL_YELLOW.getBColor()); // yellow@50% - aColorStops.emplace_back(1.0, COL_LIGHTBLUE.getBColor()); // blue - break; - } - - case 5: - { - // check invalid color (too low index), has to be ignored - aColorStops.clear(); - aColorStops.emplace_back(0.0, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(1.0, COL_LIGHTBLUE.getBColor()); // blue - aColorStops.emplace_back(-1.0, COL_YELLOW.getBColor()); // yellow@50% - break; - } - - case 6: - { - // check invalid color (too high index), has to be ignored - aColorStops.clear(); - aColorStops.emplace_back(0.0, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(1.0, COL_LIGHTBLUE.getBColor()); // blue - aColorStops.emplace_back(2.0, COL_YELLOW.getBColor()); // yellow@50% - break; - } - - case 7: - { - // check in-between single-color section - aColorStops.clear(); - aColorStops.emplace_back(0.0, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.3, COL_YELLOW.getBColor()); // yellow@50% - aColorStops.emplace_back(0.7, COL_YELLOW.getBColor()); // yellow@50% - aColorStops.emplace_back(1.0, COL_LIGHTBLUE.getBColor()); // blue - break; - } - - case 8: - { - // check in-between single-color sections - aColorStops.clear(); - aColorStops.emplace_back(0.0, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.2, COL_YELLOW.getBColor()); // yellow@50% - aColorStops.emplace_back(0.4, COL_YELLOW.getBColor()); // yellow@50% - aColorStops.emplace_back(0.5, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.6, COL_YELLOW.getBColor()); // yellow@50% - aColorStops.emplace_back(0.8, COL_YELLOW.getBColor()); // yellow@50% - aColorStops.emplace_back(1.0, COL_LIGHTBLUE.getBColor()); // blue - break; - } - - case 9: - { - // check single-color start area - aColorStops.clear(); - aColorStops.emplace_back(0.0, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.6, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(1.0, COL_LIGHTBLUE.getBColor()); // blue - break; - } - - case 10: - { - // check single-color end area - aColorStops.clear(); - aColorStops.emplace_back(0.0, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.4, COL_LIGHTBLUE.getBColor()); // blue - aColorStops.emplace_back(1.0, COL_LIGHTBLUE.getBColor()); // blue - break; - } - - case 11: - { - // check case without direct Start/EndColor - aColorStops.clear(); - aColorStops.emplace_back(0.4, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.6, COL_LIGHTBLUE.getBColor()); // blue - break; - } - - case 12: - { - // check case without colors at all - aColorStops.clear(); - break; - } - - case 13: - { - // check case with single stop - aColorStops.clear(); - aColorStops.emplace_back(0.5, COL_LIGHTRED.getBColor()); // red - break; - } - - case 14: - { - // check case with single-double stop - aColorStops.clear(); - aColorStops.emplace_back(0.5, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.5, COL_LIGHTRED.getBColor()); // red - break; - } - - case 15: - { - // check case with single stop diff colors - aColorStops.clear(); - aColorStops.emplace_back(0.5, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.5, COL_LIGHTBLUE.getBColor()); // blue - break; - } - - case 16: - { - // check case with gradient, hard change, gradient - aColorStops.clear(); - aColorStops.emplace_back(0.0, COL_LIGHTGREEN.getBColor()); // green - aColorStops.emplace_back(0.2, COL_LIGHTGREEN.getBColor()); // green - aColorStops.emplace_back(0.2, COL_LIGHTBLUE.getBColor()); // blue - aColorStops.emplace_back(0.5, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.5, COL_LIGHTBLUE.getBColor()); // blue - aColorStops.emplace_back(0.8, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.8, COL_LIGHTGREEN.getBColor()); // green - aColorStops.emplace_back(1.0, COL_LIGHTGREEN.getBColor()); // green - break; - } - - case 17: - { - // check case with single stop < 0.0 - aColorStops.clear(); - aColorStops.emplace_back(-0.5, COL_LIGHTRED.getBColor()); // red - break; - } - - case 18: - { - // check case with single stop > 1.0 - aColorStops.clear(); - aColorStops.emplace_back(1.5, COL_LIGHTRED.getBColor()); // red - break; - } - - case 19: - { - // check case with stops overlapping 0.0 - aColorStops.clear(); - aColorStops.emplace_back(-0.5, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.5, COL_LIGHTBLUE.getBColor()); // blue - break; - } - - case 20: - { - // check case with stops overlapping 1.0 - aColorStops.clear(); - aColorStops.emplace_back(0.5, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(1.5, COL_LIGHTBLUE.getBColor()); // blue - break; - } - - case 21: - { - // check case with multiple stops < 0.0 - aColorStops.clear(); - aColorStops.emplace_back(-0.5, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(-0.4, COL_LIGHTBLUE.getBColor()); // blue - aColorStops.emplace_back(-0.3, COL_LIGHTGREEN.getBColor()); // green - break; - } - - case 22: - { - // check case with multiple stops > 1.0 - aColorStops.clear(); - aColorStops.emplace_back(1.3, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(1.4, COL_LIGHTBLUE.getBColor()); // blue - aColorStops.emplace_back(1.5, COL_LIGHTGREEN.getBColor()); // green - break; - } - - case 23: - { - // check case with stops overlapping 0.0 and 1.0 - aColorStops.clear(); - aColorStops.emplace_back(-0.5, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.5, COL_LIGHTBLUE.getBColor()); // blue - aColorStops.emplace_back(0.5, COL_LIGHTGREEN.getBColor()); // green - aColorStops.emplace_back(1.5, COL_LIGHTRED.getBColor()); // red - break; - } - - case 24: - { - // check case with stops overlapping 0.0 and 1.0 and multiple entries - aColorStops.clear(); - aColorStops.emplace_back(-0.5, COL_LIGHTGREEN.getBColor()); // green - aColorStops.emplace_back(-0.5, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(0.4, COL_LIGHTBLUE.getBColor()); // blue - aColorStops.emplace_back(0.5, COL_YELLOW.getBColor()); // yellow - aColorStops.emplace_back(0.6, COL_LIGHTGREEN.getBColor()); // green - aColorStops.emplace_back(1.5, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(1.5, COL_LIGHTGREEN.getBColor()); // green - break; - } - - case 25: - { - // check case with just two stops overlapping 0.0 and 1.0 - aColorStops.clear(); - aColorStops.emplace_back(-0.5, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(1.5, COL_LIGHTGREEN.getBColor()); // green - break; - } - - case 26: - { - // check case with just two stops overlapping 0.0 and 1.0 faaaar out - aColorStops.clear(); - aColorStops.emplace_back(-5.5, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(5.5, COL_LIGHTGREEN.getBColor()); // green - break; - } - - case 27: - { - // check case with just two stops overlapping 0.0 and 1.0 faaaar out but closer to one - aColorStops.clear(); - aColorStops.emplace_back(-1.5, COL_LIGHTRED.getBColor()); // red - aColorStops.emplace_back(5.5, COL_LIGHTGREEN.getBColor()); // green - break; - } - - default: - { - break; - } - } - - if (aXGradient.GetStartIntens() != 100 || aXGradient.GetEndIntens() != 100) + if (aBGradient.GetStartIntens() != 100 || aBGradient.GetEndIntens() != 100) { // Need to do the (old, crazy) blend against black for a // used intensity, but now for all ColorStops relative to their // offsets, where 0 means black and 100 means original color - basegfx::utils::blendColorStopsToIntensity( - aColorStops, - aXGradient.GetStartIntens() * 0.01, - aXGradient.GetEndIntens() * 0.01, + aColorStops.blendToIntensity( + aBGradient.GetStartIntens() * 0.01, + aBGradient.GetEndIntens() * 0.01, basegfx::BColor()); // COL_BLACK } aGradient = attribute::FillGradientAttribute( - aXGradient.GetGradientStyle(), - static_cast<double>(aXGradient.GetBorder()) * 0.01, - static_cast<double>(aXGradient.GetXOffset()) * 0.01, - static_cast<double>(aXGradient.GetYOffset()) * 0.01, - toRadians(aXGradient.GetAngle()), + aBGradient.GetGradientStyle(), + static_cast<double>(aBGradient.GetBorder()) * 0.01, + static_cast<double>(aBGradient.GetXOffset()) * 0.01, + static_cast<double>(aBGradient.GetYOffset()) * 0.01, + toRadians(aBGradient.GetAngle()), aColorStops, rSet.Get(XATTR_GRADIENTSTEPCOUNT).GetValue()); @@ -885,9 +603,9 @@ namespace drawinglayer::primitive2d && pGradientItem->IsEnabled()) { // test if float transparency is completely transparent - const XGradient& rGradient(pGradientItem->GetGradientValue()); + const basegfx::BGradient& rGradient(pGradientItem->GetGradientValue()); basegfx::BColor aSingleColor; - const bool bSingleColor(basegfx::utils::isSingleColor(rGradient.GetColorStops(), aSingleColor)); + const bool bSingleColor(rGradient.GetColorStops().isSingleColor(aSingleColor)); const bool bCompletelyTransparent(bSingleColor && basegfx::fTools::equal(aSingleColor.luminance(), 1.0)); const bool bNotTransparent(bSingleColor && basegfx::fTools::equalZero(aSingleColor.luminance())); @@ -897,13 +615,12 @@ namespace drawinglayer::primitive2d // Both cases are optimizations, always creating FillGradientAttribute will work, too if (!bNotTransparent && !bCompletelyTransparent) { - basegfx::ColorStops aColorStops(rGradient.GetColorStops()); + basegfx::BColorStops aColorStops(rGradient.GetColorStops()); if (rGradient.GetStartIntens() != 100 || rGradient.GetEndIntens() != 100) { // this may also be set for transparence, so need to take care of it - basegfx::utils::blendColorStopsToIntensity( - aColorStops, + aColorStops.blendToIntensity( rGradient.GetStartIntens() * 0.01, rGradient.GetEndIntens() * 0.01, basegfx::BColor()); // COL_BLACK diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx index bb79b0086fd6..a1ff31c7186a 100644 --- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx +++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx @@ -128,7 +128,7 @@ void AreaPropertyPanelBase::Initialize() maGradientLinear.SetYOffset(DEFAULT_CENTERY); maGradientLinear.SetAngle(Degree10(DEFAULT_ANGLE)); maGradientLinear.SetColorStops( - basegfx::utils::createColorStopsFromStartEndColor( + basegfx::BColorStops( Color(DEFAULT_STARTVALUE).getBColor(), Color(DEFAULT_ENDVALUE).getBColor())); maGradientLinear.SetBorder(DEFAULT_BORDER); @@ -297,7 +297,7 @@ void AreaPropertyPanelBase::SelectFillAttrHdl_Impl() if (pSh && pSh->GetItem(SID_COLOR_TABLE)) { - XGradient aGradient(createColorStops()); + basegfx::BGradient aGradient(createColorStops()); aGradient.SetAngle(Degree10(mxMTRAngle->get_value(FieldUnit::DEGREE) * 10)); aGradient.SetGradientStyle(static_cast<css::awt::GradientStyle>(mxGradientStyle->get_active())); @@ -477,7 +477,7 @@ void AreaPropertyPanelBase::FillStyleChanged(bool bUpdateModel) const SvxGradientListItem* pItem = pSh->GetItem(SID_GRADIENT_LIST); if (pItem->GetGradientList()->Count() > 0) { - const XGradient aGradient + const basegfx::BGradient aGradient = pItem->GetGradientList()->GetGradient(0)->GetGradient(); const OUString aName = pItem->GetGradientList()->GetGradient(0)->GetName(); const XFillGradientItem aXFillGradientItem(aName, aGradient); @@ -490,7 +490,7 @@ void AreaPropertyPanelBase::FillStyleChanged(bool bUpdateModel) // MCGR: preserve in-between ColorStops if given if (aGradient.GetColorStops().size() > 2) - maColorStops = basegfx::ColorStops(aGradient.GetColorStops().begin() + 1, aGradient.GetColorStops().end() - 1); + maColorStops = basegfx::BColorStops(aGradient.GetColorStops().begin() + 1, aGradient.GetColorStops().end() - 1); else maColorStops.clear(); @@ -511,13 +511,13 @@ void AreaPropertyPanelBase::FillStyleChanged(bool bUpdateModel) { const OUString aString(mpFillGradientItem->GetName()); mxLbFillAttr->set_active_text(aString); - const XGradient aGradient = mpFillGradientItem->GetGradientValue(); + const basegfx::BGradient aGradient = mpFillGradientItem->GetGradientValue(); 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::ColorStops(aGradient.GetColorStops().begin() + 1, aGradient.GetColorStops().end() - 1); + maColorStops = basegfx::BColorStops(aGradient.GetColorStops().begin() + 1, aGradient.GetColorStops().end() - 1); else maColorStops.clear(); @@ -715,7 +715,7 @@ void AreaPropertyPanelBase::ImpUpdateTransparencies() { if(mpFloatTransparenceItem->IsEnabled()) { - const XGradient& rGradient = mpFloatTransparenceItem->GetGradientValue(); + const basegfx::BGradient& rGradient = mpFloatTransparenceItem->GetGradientValue(); sal_Int32 nEntryPos(0); OUString* pImage = nullptr; @@ -1267,7 +1267,7 @@ IMPL_LINK_NOARG(AreaPropertyPanelBase, ChangeTrgrTypeHdl_Impl, weld::ComboBox&, nSelectType -= 2; } - XGradient aTmpGradient; + basegfx::BGradient aTmpGradient; switch(static_cast<css::awt::GradientStyle>(nSelectType)) { @@ -1313,7 +1313,7 @@ IMPL_LINK_NOARG(AreaPropertyPanelBase, ModifyTransparentHdl_Impl, weld::MetricSp setFillTransparence(aLinearItem); } -const XGradient& AreaPropertyPanelBase::GetGradient (const css::awt::GradientStyle eStyle) const +const basegfx::BGradient& AreaPropertyPanelBase::GetGradient (const css::awt::GradientStyle eStyle) const { switch (eStyle) { @@ -1333,7 +1333,7 @@ const XGradient& AreaPropertyPanelBase::GetGradient (const css::awt::GradientSty } } -void AreaPropertyPanelBase::SetGradient (const XGradient& rGradient) +void AreaPropertyPanelBase::SetGradient (const basegfx::BGradient& rGradient) { switch (rGradient.GetGradientStyle()) { @@ -1365,9 +1365,9 @@ sal_Int32 AreaPropertyPanelBase::GetSelectedTransparencyTypeIndex() const return mxLBTransType->get_active(); } -basegfx::ColorStops AreaPropertyPanelBase::createColorStops() +basegfx::BColorStops AreaPropertyPanelBase::createColorStops() { - basegfx::ColorStops aColorStops; + basegfx::BColorStops aColorStops; aColorStops.emplace_back(0.0, mxLbFillGradFrom->GetSelectEntryColor().getBColor()); diff --git a/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx b/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx index 34d618e8a2cd..df943359ff19 100644 --- a/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx +++ b/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx @@ -20,7 +20,6 @@ #include <svx/sidebar/AreaTransparencyGradientPopup.hxx> #include <svx/sidebar/AreaPropertyPanelBase.hxx> #include <svx/xflftrit.hxx> -#include <svx/xgrad.hxx> namespace svx::sidebar { @@ -56,9 +55,9 @@ AreaTransparencyGradientPopup::~AreaTransparencyGradientPopup() void AreaTransparencyGradientPopup::InitStatus(XFillFloatTransparenceItem const * pGradientItem) { - const XGradient& rGradient = pGradientItem->GetGradientValue(); + const basegfx::BGradient& rGradient = pGradientItem->GetGradientValue(); - XGradient aGradient; + basegfx::BGradient aGradient; Color aStart(rGradient.GetColorStops().front().getStopColor()); Color aEnd(rGradient.GetColorStops().back().getStopColor()); @@ -87,7 +86,7 @@ void AreaTransparencyGradientPopup::InitStatus(XFillFloatTransparenceItem const // MCGR: preserve in-between ColorStops if given if (aGradient.GetColorStops().size() > 2) - maColorStops = basegfx::ColorStops(aGradient.GetColorStops().begin() + 1, aGradient.GetColorStops().end() - 1); + maColorStops = basegfx::BColorStops(aGradient.GetColorStops().begin() + 1, aGradient.GetColorStops().end() - 1); else maColorStops.clear(); @@ -97,7 +96,7 @@ void AreaTransparencyGradientPopup::InitStatus(XFillFloatTransparenceItem const void AreaTransparencyGradientPopup::Rearrange(XFillFloatTransparenceItem const * pGradientItem) { InitStatus(pGradientItem); - const XGradient& rGradient = pGradientItem->GetGradientValue(); + const basegfx::BGradient& rGradient = pGradientItem->GetGradientValue(); css::awt::GradientStyle eXGS(rGradient.GetGradientStyle()); switch(eXGS) @@ -133,13 +132,13 @@ void AreaTransparencyGradientPopup::ExecuteValueModify(sal_uInt8 nStartCol, sal_ mxMtrTrgrAngle->set_value(nVal, FieldUnit::DEGREE); //End of new code - basegfx::ColorStops aColorStops; + 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()); - XGradient aTmpGradient( + basegfx::BGradient aTmpGradient( aColorStops, static_cast<css::awt::GradientStyle>(mrAreaPropertyPanel.GetSelectedTransparencyTypeIndex()-2), Degree10(static_cast<sal_Int16>(mxMtrTrgrAngle->get_value(FieldUnit::DEGREE)) * 10), diff --git a/svx/source/svdraw/gradtrns.cxx b/svx/source/svdraw/gradtrns.cxx index c559e580cf67..82a4ea0a29d1 100644 --- a/svx/source/svdraw/gradtrns.cxx +++ b/svx/source/svdraw/gradtrns.cxx @@ -188,15 +188,15 @@ void GradTransformer::VecToGrad(GradTransVector const & rV, GradTransGradient& r // handle color changes if(rV.aCol1 != Color(rGOld.aGradient.GetColorStops().front().getStopColor())) { - basegfx::ColorStops aNewColorStops(rG.aGradient.GetColorStops()); - basegfx::utils::replaceStartColor(aNewColorStops, rV.aCol1.getBColor()); + basegfx::BColorStops aNewColorStops(rG.aGradient.GetColorStops()); + aNewColorStops.replaceStartColor(rV.aCol1.getBColor()); rG.aGradient.SetColorStops(aNewColorStops); rG.aGradient.SetStartIntens(100); } if(rV.aCol2 != Color(rGOld.aGradient.GetColorStops().back().getStopColor())) { - basegfx::ColorStops aNewColorStops(rG.aGradient.GetColorStops()); - basegfx::utils::replaceEndColor(aNewColorStops, rV.aCol2.getBColor()); + basegfx::BColorStops aNewColorStops(rG.aGradient.GetColorStops()); + aNewColorStops.replaceEndColor(rV.aCol2.getBColor()); rG.aGradient.SetColorStops(aNewColorStops); rG.aGradient.SetEndIntens(100); } diff --git a/svx/source/svdraw/gradtrns.hxx b/svx/source/svdraw/gradtrns.hxx index eee35582a9b0..f53e236b73d7 100644 --- a/svx/source/svdraw/gradtrns.hxx +++ b/svx/source/svdraw/gradtrns.hxx @@ -20,8 +20,9 @@ #ifndef INCLUDED_SVX_SOURCE_SVDRAW_GRADTRNS_HXX #define INCLUDED_SVX_SOURCE_SVDRAW_GRADTRNS_HXX -#include <svx/xgrad.hxx> +#include <tools/color.hxx> #include <basegfx/point/b2dpoint.hxx> +#include <basegfx/utils/bgradient.hxx> class SdrObject; @@ -37,7 +38,7 @@ public: class GradTransGradient { public: - XGradient aGradient; + basegfx::BGradient aGradient; }; struct GradTransformer diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx index 97da36957306..acd15f7cc265 100644 --- a/svx/source/svdraw/svdetc.cxx +++ b/svx/source/svdraw/svdetc.cxx @@ -31,7 +31,6 @@ #include <editeng/eeitem.hxx> #include <svl/itemset.hxx> #include <svl/whiter.hxx> -#include <svx/xgrad.hxx> #include <svx/xfillit0.hxx> #include <svx/xflclit.hxx> #include <svx/xflhtit.hxx> @@ -271,7 +270,7 @@ bool GetDraftFillColor(const SfxItemSet& rSet, Color& rCol) break; } case drawing::FillStyle_GRADIENT: { - const XGradient& rGrad=rSet.Get(XATTR_FILLGRADIENT).GetGradientValue(); + const basegfx::BGradient& rGrad=rSet.Get(XATTR_FILLGRADIENT).GetGradientValue(); Color aCol1(Color(rGrad.GetColorStops().front().getStopColor())); Color aCol2(Color(rGrad.GetColorStops().back().getStopColor())); const basegfx::BColor aAverageColor(basegfx::average(aCol1.getBColor(), aCol2.getBColor())); diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index acd8b321a7f8..839fff3bdb15 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -32,7 +32,6 @@ #include <svx/xlnwtit.hxx> #include <svx/xfillit0.hxx> #include <svx/xflclit.hxx> -#include <svx/xgrad.hxx> #include <svx/xflgrit.hxx> #include <editeng/fontitem.hxx> #include <editeng/wrlmitem.hxx> @@ -1245,19 +1244,19 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction const & rAct, GDIMetaF std::move(aSource)); // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet SfxItemSet aGradAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges()); - XGradient aXGradient( - basegfx::utils::createColorStopsFromStartEndColor( + basegfx::BGradient aBGradient( + basegfx::BColorStops( rGrad.GetStartColor().getBColor(), rGrad.GetEndColor().getBColor())); - aXGradient.SetGradientStyle(rGrad.GetStyle()); - aXGradient.SetAngle(rGrad.GetAngle()); - aXGradient.SetBorder(rGrad.GetBorder()); - aXGradient.SetXOffset(rGrad.GetOfsX()); - aXGradient.SetYOffset(rGrad.GetOfsY()); - aXGradient.SetStartIntens(rGrad.GetStartIntensity()); - aXGradient.SetEndIntens(rGrad.GetEndIntensity()); - aXGradient.SetSteps(rGrad.GetSteps()); + aBGradient.SetGradientStyle(rGrad.GetStyle()); + aBGradient.SetAngle(rGrad.GetAngle()); + aBGradient.SetBorder(rGrad.GetBorder()); + aBGradient.SetXOffset(rGrad.GetOfsX()); + aBGradient.SetYOffset(rGrad.GetOfsY()); + aBGradient.SetStartIntens(rGrad.GetStartIntensity()); + aBGradient.SetEndIntens(rGrad.GetEndIntensity()); + aBGradient.SetSteps(rGrad.GetSteps()); // no need to use SetAttributes(..) here since line and fill style // need to be set individually @@ -1269,7 +1268,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction const & rAct, GDIMetaF // add detected gradient fillstyle aGradAttr.Put(XFillStyleItem(drawing::FillStyle_GRADIENT)); - aGradAttr.Put(XFillGradientItem(aXGradient)); + aGradAttr.Put(XFillGradientItem(aBGradient)); pPath->SetMergedItemSet(aGradAttr); @@ -1413,8 +1412,8 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction const & rAct) // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet SfxItemSet aGradientAttr(mpModel->GetItemPool(), pRect->GetMergedItemSet().GetRanges()); const XFillGradientItem aXFillGradientItem( - XGradient( - basegfx::utils::createColorStopsFromStartEndColor( + basegfx::BGradient( + basegfx::BColorStops( rGradient.GetStartColor().getBColor(), rGradient.GetEndColor().getBColor()), rGradient.GetStyle(), @@ -1475,8 +1474,8 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction const & rAct) // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet SfxItemSet aGradientAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges()); const XFillGradientItem aXFillGradientItem( - XGradient( - basegfx::utils::createColorStopsFromStartEndColor( + basegfx::BGradient( + basegfx::BColorStops( rGradient.GetStartColor().getBColor(), rGradient.GetEndColor().getBColor()), rGradient.GetStyle(), diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index 5d6ccea9a55c..fa0ec5aa084f 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -29,7 +29,6 @@ #include <osl/thread.h> #include <rtl/strbuf.hxx> #include <svx/svdoole2.hxx> -#include <svx/xgrad.hxx> #include <svx/xfillit0.hxx> #include <svx/xflgrit.hxx> #include "gradtrns.hxx" @@ -1559,7 +1558,7 @@ void SdrMarkView::AddDragModeHdl(SdrDragMode eMode) { // add this item, it's not yet there XFillFloatTransparenceItem aNewItem(rSet.Get(XATTR_FILLFLOATTRANSPARENCE)); - XGradient aGrad = aNewItem.GetGradientValue(); + basegfx::BGradient aGrad = aNewItem.GetGradientValue(); aNewItem.SetEnabled(true); aGrad.SetStartIntens(100); diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index a2db44a795c6..c86c9ad0e194 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -302,7 +302,7 @@ static rtl::Reference<SdrObject> ImpCreateShadowObjectClone(const SdrObject& rOr // gradient and transparency like shadow if(bGradientFillUsed) { - XGradient aGradient(rOriginalSet.Get(XATTR_FILLGRADIENT).GetGradientValue()); + basegfx::BGradient aGradient(rOriginalSet.Get(XATTR_FILLGRADIENT).GetGradientValue()); sal_uInt8 nStartLuminance(Color(aGradient.GetColorStops().front().getStopColor()).GetLuminance()); sal_uInt8 nEndLuminance(Color(aGradient.GetColorStops().back().getStopColor()).GetLuminance()); @@ -327,7 +327,7 @@ static rtl::Reference<SdrObject> ImpCreateShadowObjectClone(const SdrObject& rOr static_cast<sal_uInt8>((nEndLuminance * aShadowColor.GetBlue()) / 256)); aGradient.SetColorStops( - basegfx::utils::createColorStopsFromStartEndColor( + basegfx::BColorStops( aStartColor.getBColor(), aEndColor.getBColor())); aTempSet.Put(XFillGradientItem(aGradient)); diff --git a/svx/source/tbxctrls/fillctrl.cxx b/svx/source/tbxctrls/fillctrl.cxx index ced69cbdf2c7..9ca978e07331 100644 --- a/svx/source/tbxctrls/fillctrl.cxx +++ b/svx/source/tbxctrls/fillctrl.cxx @@ -765,7 +765,7 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, weld::ComboBox&, void) if(mnLastPosGradient < pItem->GetGradientList()->Count()) { - const XGradient aGradient = pItem->GetGradientList()->GetGradient(mnLastPosGradient)->GetGradient(); + const basegfx::BGradient aGradient = pItem->GetGradientList()->GetGradient(mnLastPosGradient)->GetGradient(); const XFillGradientItem aXFillGradientItem(mpLbFillAttr->get_text(mnLastPosGradient), aGradient); // #i122676# change FillStyle and Gradient in one call @@ -941,7 +941,7 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, weld::ComboBox&, void) if(nPos < pItem->GetGradientList()->Count()) { - const XGradient aGradient = pItem->GetGradientList()->GetGradient(nPos)->GetGradient(); + const basegfx::BGradient aGradient = pItem->GetGradientList()->GetGradient(nPos)->GetGradient(); const XFillGradientItem aXFillGradientItem(mpLbFillAttr->get_active_text(), aGradient); // #i122676# Change FillStyle and Gradient in one call diff --git a/svx/source/unodraw/XPropertyTable.cxx b/svx/source/unodraw/XPropertyTable.cxx index 45b0cd39c1ed..d88a37c4462d 100644 --- a/svx/source/unodraw/XPropertyTable.cxx +++ b/svx/source/unodraw/XPropertyTable.cxx @@ -532,29 +532,27 @@ uno::Reference< container::XNameContainer > SvxUnoXGradientTable_createInstance( // SvxUnoXPropertyTable uno::Any SvxUnoXGradientTable::getAny( const XPropertyEntry* pEntry ) const noexcept { - const XGradient& aXGradient = static_cast<const XGradientEntry*>(pEntry)->GetGradient(); + const basegfx::BGradient& aBGradient = static_cast<const XGradientEntry*>(pEntry)->GetGradient(); awt::Gradient2 aGradient; assert(aGradient.ColorStops.get() && "cid#1524745 aGradient.ColorStops._pSequence won't be null here"); // standard values - aGradient.Style = aXGradient.GetGradientStyle(); - // aGradient.StartColor = static_cast<sal_Int32>(Color(aXGradient.GetColorStops().front().getStopColor())); - // aGradient.EndColor = static_cast<sal_Int32>(Color(aXGradient.GetColorStops().back().getStopColor())); - aGradient.Angle = static_cast<short>(aXGradient.GetAngle()); - aGradient.Border = aXGradient.GetBorder(); - aGradient.XOffset = aXGradient.GetXOffset(); - aGradient.YOffset = aXGradient.GetYOffset(); - aGradient.StartIntensity = aXGradient.GetStartIntens(); - aGradient.EndIntensity = aXGradient.GetEndIntens(); - aGradient.StepCount = aXGradient.GetSteps(); + aGradient.Style = aBGradient.GetGradientStyle(); + aGradient.Angle = static_cast<short>(aBGradient.GetAngle()); + aGradient.Border = aBGradient.GetBorder(); + aGradient.XOffset = aBGradient.GetXOffset(); + aGradient.YOffset = aBGradient.GetYOffset(); + aGradient.StartIntensity = aBGradient.GetStartIntens(); + aGradient.EndIntensity = aBGradient.GetEndIntens(); + aGradient.StepCount = aBGradient.GetSteps(); // for compatibility, still set StartColor/EndColor - const basegfx::ColorStops& rColorStops(aXGradient.GetColorStops()); - aGradient.StartColor = static_cast<sal_Int32>(Color(rColorStops.front().getStopColor())); - aGradient.EndColor = static_cast<sal_Int32>(Color(rColorStops.back().getStopColor())); + const basegfx::BColorStops& rBColorStops(aBGradient.GetColorStops()); + aGradient.StartColor = static_cast<sal_Int32>(Color(rBColorStops.front().getStopColor())); + aGradient.EndColor = static_cast<sal_Int32>(Color(rBColorStops.back().getStopColor())); // fill ColorStops to extended Gradient2 - basegfx::utils::fillColorStopSequenceFromColorStops(aGradient.ColorStops, rColorStops); + aGradient.ColorStops = rBColorStops.getAsColorStopSequence(); return uno::Any(aGradient); } @@ -565,27 +563,26 @@ std::unique_ptr<XPropertyEntry> SvxUnoXGradientTable::createEntry(const OUString if(!(rAny >>= aGradient)) return std::unique_ptr<XPropertyEntry>(); - XGradient aXGradient( - basegfx::utils::createColorStopsFromStartEndColor( + basegfx::BGradient aBGradient( + basegfx::BColorStops( Color(ColorTransparency, aGradient.StartColor).getBColor(), Color(ColorTransparency, aGradient.EndColor).getBColor())); - aXGradient.SetGradientStyle( aGradient.Style ); - aXGradient.SetAngle( Degree10(aGradient.Angle) ); - aXGradient.SetBorder( aGradient.Border ); - aXGradient.SetXOffset( aGradient.XOffset ); - aXGradient.SetYOffset( aGradient.YOffset ); - aXGradient.SetStartIntens( aGradient.StartIntensity ); - aXGradient.SetEndIntens( aGradient.EndIntensity ); - aXGradient.SetSteps( aGradient.StepCount ); + aBGradient.SetGradientStyle( aGradient.Style ); + aBGradient.SetAngle( Degree10(aGradient.Angle) ); + aBGradient.SetBorder( aGradient.Border ); + aBGradient.SetXOffset( aGradient.XOffset ); + aBGradient.SetYOffset( aGradient.YOffset ); + aBGradient.SetStartIntens( aGradient.StartIntensity ); + aBGradient.SetEndIntens( aGradient.EndIntensity ); + aBGradient.SetSteps( aGradient.StepCount ); // check if we have a awt::Gradient2 with a ColorStopSequence - basegfx::ColorStops aColorStops; - basegfx::utils::fillColorStopsFromAny(aColorStops, rAny); + const basegfx::BColorStops aColorStops(rAny); if (!aColorStops.empty()) - aXGradient.SetColorStops(aColorStops); + aBGradient.SetColorStops(aColorStops); - return std::make_unique<XGradientEntry>(aXGradient, rName); + return std::make_unique<XGradientEntry>(aBGradient, rName); } // XElementAccess diff --git a/svx/source/unodraw/unobrushitemhelper.cxx b/svx/source/unodraw/unobrushitemhelper.cxx index ba0924be803f..65d80cf282ca 100644 --- a/svx/source/unodraw/unobrushitemhelper.cxx +++ b/svx/source/unodraw/unobrushitemhelper.cxx @@ -156,7 +156,7 @@ static sal_uInt16 getTransparenceForSvxBrushItem(const SfxItemSet& rSourceSet, b if((pGradientItem = rSourceSet.GetItemIfSet(XATTR_FILLFLOATTRANSPARENCE, bSearchInParents)) && pGradientItem->IsEnabled()) { - const XGradient& rGradient = pGradientItem->GetGradientValue(); + const basegfx::BGradient& rGradient = pGradientItem->GetGradientValue(); const sal_uInt16 nStartLuminance(Color(rGradient.GetColorStops().front().getStopColor()).GetLuminance()); const sal_uInt16 nEndLuminance(Color(rGradient.GetColorStops().back().getStopColor()).GetLuminance()); @@ -223,9 +223,9 @@ std::unique_ptr<SvxBrushItem> getSvxBrushItemFromSourceSet(const SfxItemSet& rSo case drawing::FillStyle_GRADIENT: { // cannot be directly supported, but do the best possible - const XGradient aXGradient(rSourceSet.Get(XATTR_FILLGRADIENT).GetGradientValue()); - const basegfx::BColor aStartColor(aXGradient.GetColorStops().front().getStopColor() * (aXGradient.GetStartIntens() * 0.01)); - const basegfx::BColor aEndColor(aXGradient.GetColorStops().back().getStopColor() * (aXGradient.GetEndIntens() * 0.01)); + const basegfx::BGradient aBGradient(rSourceSet.Get(XATTR_FILLGRADIENT).GetGradientValue()); + const basegfx::BColor aStartColor(aBGradient.GetColorStops().front().getStopColor() * (aBGradient.GetStartIntens() * 0.01)); + const basegfx::BColor aEndColor(aBGradient.GetColorStops().back().getStopColor() * (aBGradient.GetEndIntens() * 0.01)); // use half/half mixed color from gradient start and end Color aMixedColor((aStartColor + aEndColor) * 0.5); diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx index 3b31b852a835..8c4c7af9eb11 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -2092,209 +2092,17 @@ bool XSecondaryFillColorItem::GetPresentation return true; } -std::string XGradient::GradientStyleToString(css::awt::GradientStyle eStyle) -{ - switch (eStyle) - { - case css::awt::GradientStyle::GradientStyle_LINEAR: - return "LINEAR"; - - case css::awt::GradientStyle::GradientStyle_AXIAL: - return "AXIAL"; - - case css::awt::GradientStyle::GradientStyle_RADIAL: - return "RADIAL"; - - case css::awt::GradientStyle::GradientStyle_ELLIPTICAL: - return "ELLIPTICAL"; - - case css::awt::GradientStyle::GradientStyle_SQUARE: - return "SQUARE"; - - case css::awt::GradientStyle::GradientStyle_RECT: - return "RECT"; - - case css::awt::GradientStyle::GradientStyle_MAKE_FIXED_SIZE: - return "MAKE_FIXED_SIZE"; - } - - return ""; -} - -namespace -{ - css::awt::GradientStyle lcl_getStyleFromString(std::u16string_view rStyle) - { - if (rStyle == u"LINEAR") - return css::awt::GradientStyle_LINEAR; - else if (rStyle == u"AXIAL") - return css::awt::GradientStyle_AXIAL; - else if (rStyle == u"RADIAL") - return css::awt::GradientStyle_RADIAL; - else if (rStyle == u"ELLIPTICAL") - return css::awt::GradientStyle_ELLIPTICAL; - else if (rStyle == u"SQUARE") - return css::awt::GradientStyle_SQUARE; - else if (rStyle == u"RECT") - return css::awt::GradientStyle_RECT; - - return css::awt::GradientStyle_LINEAR; - } - - StringMap lcl_jsonToStringMap(std::u16string_view rJSON) - { - StringMap aArgs; - if (rJSON.size() && rJSON[0] != '\0') - { - std::stringstream aStream(std::string(OUStringToOString(rJSON, RTL_TEXTENCODING_ASCII_US))); - boost::property_tree::ptree aTree; - boost::property_tree::read_json(aStream, aTree); - - for (const auto& rPair : aTree) - { - aArgs[OUString::fromUtf8(rPair.first)] = OUString::fromUtf8(rPair.second.get_value<std::string>(".")); - } - } - return aArgs; - } - - XGradient lcl_buildGradientFromStringMap(StringMap& rMap) - { - XGradient aGradient( - basegfx::utils::createColorStopsFromStartEndColor( - Color(ColorTransparency, rMap["startcolor"].toInt32(16)).getBColor(), - Color(ColorTransparency, rMap["endcolor"].toInt32(16)).getBColor())); - - aGradient.SetGradientStyle(lcl_getStyleFromString(rMap["style"])); - aGradient.SetAngle(Degree10(rMap["angle"].toInt32())); - - return aGradient; - } -} - -XGradient XGradient::fromJSON(std::u16string_view rJSON) -{ - StringMap aMap(lcl_jsonToStringMap(rJSON)); - return lcl_buildGradientFromStringMap(aMap); -} - -namespace -{ - void fillGradient2FromXGradient(css::awt::Gradient2& rGradient2, const XGradient& rXGradient) - { - // standard values - rGradient2.Style = rXGradient.GetGradientStyle(); - rGradient2.Angle = static_cast<short>(rXGradient.GetAngle()); - rGradient2.Border = rXGradient.GetBorder(); - rGradient2.XOffset = rXGradient.GetXOffset(); - rGradient2.YOffset = rXGradient.GetYOffset(); - rGradient2.StartIntensity = rXGradient.GetStartIntens(); - rGradient2.EndIntensity = rXGradient.GetEndIntens(); - rGradient2.StepCount = rXGradient.GetSteps(); - - // for compatibility, still set StartColor/EndColor - const basegfx::ColorStops& rColorStops(rXGradient.GetColorStops()); - rGradient2.StartColor = static_cast<sal_Int32>(Color(rColorStops.front().getStopColor())); - rGradient2.EndColor = static_cast<sal_Int32>(Color(rColorStops.back().getStopColor())); - - // fill ColorStops to extended Gradient2 - basegfx::utils::fillColorStopSequenceFromColorStops(rGradient2.ColorStops, rColorStops); - } -} - -css::awt::Gradient2 XGradient::toGradientUNO() const -{ - css::awt::Gradient2 aGradient2; - - // fill values - fillGradient2FromXGradient(aGradient2, *this); - - return aGradient2; -} - -XGradient::XGradient() : - eStyle( css::awt::GradientStyle_LINEAR ), - aColorStops(), - nAngle( 0 ), - nBorder( 0 ), - nOfsX( 50 ), - nOfsY( 50 ), - nIntensStart( 100 ), - nIntensEnd( 100 ), - nStepCount( 0 ) -{ - aColorStops.emplace_back(0.0, COL_BLACK.getBColor()); - aColorStops.emplace_back(1.0, COL_WHITE.getBColor()); -} - -XGradient::XGradient(const basegfx::ColorStops& rColorStops, - css::awt::GradientStyle eTheStyle, Degree10 nTheAngle, sal_uInt16 nXOfs, - sal_uInt16 nYOfs, sal_uInt16 nTheBorder, - sal_uInt16 nStartIntens, sal_uInt16 nEndIntens, - sal_uInt16 nSteps) : - eStyle(eTheStyle), - aColorStops(rColorStops), - nAngle(nTheAngle), - nBorder(nTheBorder), - nOfsX(nXOfs), - nOfsY(nYOfs), - nIntensStart(nStartIntens), - nIntensEnd(nEndIntens), - nStepCount(nSteps) -{ - SetColorStops(aColorStops); -} - -bool XGradient::operator==(const XGradient& rGradient) const -{ - return ( eStyle == rGradient.eStyle && - aColorStops == rGradient.aColorStops && - nAngle == rGradient.nAngle && - nBorder == rGradient.nBorder && - nOfsX == rGradient.nOfsX && - nOfsY == rGradient.nOfsY && - nIntensStart == rGradient.nIntensStart && - nIntensEnd == rGradient.nIntensEnd && - nStepCount == rGradient.nStepCount ); -} - -void XGradient::SetColorStops(const basegfx::ColorStops& rSteps) -{ - aColorStops = rSteps; - basegfx::utils::sortAndCorrectColorStops(aColorStops); - if (aColorStops.empty()) - aColorStops.emplace_back(0.0, basegfx::BColor()); -} - -boost::property_tree::ptree XGradient::dumpAsJSON() const -{ - boost::property_tree::ptree aTree; - - aTree.put("style", XGradient::GradientStyleToString(eStyle)); - aTree.put("startcolor", Color(GetColorStops().front().getStopColor()).AsRGBHexString()); - aTree.put("endcolor", Color(GetColorStops().back().getStopColor()).AsRGBHexString()); - aTree.put("angle", std::to_string(nAngle.get())); - aTree.put("border", std::to_string(nBorder)); - aTree.put("x", std::to_string(nOfsX)); - aTree.put("y", std::to_string(nOfsY)); - aTree.put("intensstart", std::to_string(nIntensStart)); - aTree.put("intensend", std::to_string(nIntensEnd)); - aTree.put("stepcount", std::to_string(nStepCount)); - - return aTree; -} - SfxPoolItem* XFillGradientItem::CreateDefault() { return new XFillGradientItem; } XFillGradientItem::XFillGradientItem(sal_Int32 nIndex, - const XGradient& rTheGradient) : + const basegfx::BGradient& rTheGradient) : NameOrIndex(XATTR_FILLGRADIENT, nIndex), aGradient(rTheGradient) { } XFillGradientItem::XFillGradientItem(const OUString& rName, - const XGradient& rTheGradient, TypedWhichId<XFillGradientItem> nWhich) + const basegfx::BGradient& rTheGradient, TypedWhichId<XFillGradientItem> nWhich) : NameOrIndex(nWhich, rName) , aGradient(rTheGradient) { @@ -2306,7 +2114,7 @@ XFillGradientItem::XFillGradientItem(const XFillGradientItem& rItem) : { } -XFillGradientItem::XFillGradientItem( const XGradient& rTheGradient ) +XFillGradientItem::XFillGradientItem( const basegfx::BGradient& rTheGradient ) : NameOrIndex( XATTR_FILLGRADIENT, -1 ), aGradient(rTheGradient) { @@ -2323,7 +2131,7 @@ bool XFillGradientItem::operator==(const SfxPoolItem& rItem) const aGradient == static_cast<const XFillGradientItem&>(rItem).aGradient ); } -const XGradient& XFillGradientItem::GetGradientValue() const // GetValue -> GetGradientValue +const basegfx::BGradient& XFillGradientItem::GetGradientValue() const // GetValue -> GetGradientValue { if (!IsIndex()) return aGradient; @@ -2346,32 +2154,32 @@ bool XFillGradientItem::GetPresentation namespace { - void fillXGradientFromAny(XGradient& rXGradient, const css::uno::Any& rVal) + void fillXGradientFromAny(basegfx::BGradient& rBGradient, const css::uno::Any& rVal) { css::awt::Gradient aGradient; if (!(rVal >>= aGradient)) return; // for compatibility, read and set StartColor/EndColor - rXGradient.SetColorStops(basegfx::utils::createColorStopsFromStartEndColor( - Color(ColorTransparency, aGradient.StartColor).getBColor(), - Color(ColorTransparency, aGradient.EndColor).getBColor())); + rBGradient.SetColorStops( + basegfx::BColorStops( + Color(ColorTransparency, aGradient.StartColor).getBColor(), + Color(ColorTransparency, aGradient.EndColor).getBColor())); // set values - rXGradient.SetGradientStyle( aGradient.Style ); - rXGradient.SetAngle( Degree10(aGradient.Angle) ); - rXGradient.SetBorder( aGradient.Border ); - rXGradient.SetXOffset( aGradient.XOffset ); - rXGradient.SetYOffset( aGradient.YOffset ); - rXGradient.SetStartIntens( aGradient.StartIntensity ); - rXGradient.SetEndIntens( aGradient.EndIntensity ); - rXGradient.SetSteps( aGradient.StepCount ); + rBGradient.SetGradientStyle( aGradient.Style ); + rBGradient.SetAngle( Degree10(aGradient.Angle) ); + rBGradient.SetBorder( aGradient.Border ); + rBGradient.SetXOffset( aGradient.XOffset ); + rBGradient.SetYOffset( aGradient.YOffset ); + rBGradient.SetStartIntens( aGradient.StartIntensity ); + rBGradient.SetEndIntens( aGradient.EndIntensity ); + rBGradient.SetSteps( aGradient.StepCount ); // check if we have a awt::Gradient2 with a ColorStopSequence - basegfx::ColorStops aColorStops; - basegfx::utils::fillColorStopsFromAny(aColorStops, rVal); + const basegfx::BColorStops aColorStops(rVal); if (!aColorStops.empty()) - rXGradient.SetColorStops(aColorStops); + rBGradient.SetColorStops(aColorStops); } } @@ -2382,10 +2190,8 @@ bool XFillGradientItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) c { case 0: { - css::awt::Gradient2 aGradient2; - // fill values - fillGradient2FromXGradient(aGradient2, GetGradientValue()); + const css::awt::Gradient2 aGradient2(GetGradientValue().getAsGradient2()); // create sequence uno::Sequence< beans::PropertyValue > aPropSeq{ @@ -2398,10 +2204,8 @@ bool XFillGradientItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) c case MID_FILLGRADIENT: { - css::awt::Gradient2 aGradient2; - // fill values - fillGradient2FromXGradient(aGradient2, GetGradientValue()); + const css::awt::Gradient2 aGradient2(GetGradientValue().getAsGradient2()); // create sequence rVal <<= aGradient2; @@ -2416,10 +2220,9 @@ bool XFillGradientItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) c case MID_GRADIENT_COLORSTOPSEQUENCE: { - css::awt::ColorStopSequence aColorStopSequence; - // fill values - basegfx::utils::fillColorStopSequenceFromColorStops(aColorStopSequence, GetGradientValue().GetColorStops()); + const css::awt::ColorStopSequence aColorStopSequence( + GetGradientValue().GetColorStops().getAsColorStopSequence()); // create sequence rVal <<= aColorStopSequence; @@ -2470,9 +2273,9 @@ bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId if ( aGradientAny.hasValue() ) { - XGradient aXGradient; - fillXGradientFromAny(aXGradient, aGradientAny); - SetGradientValue(aXGradient); + basegfx::BGradient aBGradient; + fillXGradientFromAny(aBGradient, aGradientAny); + SetGradientValue(aBGradient); } return true; @@ -2492,22 +2295,22 @@ bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId case MID_FILLGRADIENT: { - XGradient aXGradient; - fillXGradientFromAny(aXGradient, rVal); - SetGradientValue(aXGradient); + basegfx::BGradient aBGradient; + fillXGradientFromAny(aBGradient, rVal); + SetGradientValue(aBGradient); break; } case MID_GRADIENT_COLORSTOPSEQUENCE: { // check if we have a awt::Gradient2 with a ColorStopSequence - basegfx::ColorStops aColorStops; - basegfx::utils::fillColorStopsFromAny(aColorStops, rVal); + const basegfx::BColorStops aColorStops(rVal); + if (!aColorStops.empty()) { - XGradient aXGradient(GetGradientValue()); - aXGradient.SetColorStops(aColorStops); - SetGradientValue(aXGradient); + basegfx::BGradient aBGradient(GetGradientValue()); + aBGradient.SetColorStops(aColorStops); + SetGradientValue(aBGradient); } break; } @@ -2519,20 +2322,20 @@ bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId if(!(rVal >>= nVal )) return false; - XGradient aXGradient(GetGradientValue()); - basegfx::ColorStops aNewColorStops(aXGradient.GetColorStops()); + basegfx::BGradient aBGradient(GetGradientValue()); + basegfx::BColorStops aNewColorStops(aBGradient.GetColorStops()); if ( nMemberId == MID_GRADIENT_STARTCOLOR ) { - basegfx::utils::replaceStartColor(aNewColorStops, nVal.getBColor()); + aNewColorStops.replaceStartColor(nVal.getBColor()); } else { - basegfx::utils::replaceEndColor(aNewColorStops, nVal.getBColor()); + aNewColorStops.replaceEndColor(nVal.getBColor()); } - aXGradient.SetColorStops(aNewColorStops); - SetGradientValue( aXGradient ); + aBGradient.SetColorStops(aNewColorStops); + SetGradientValue( aBGradient ); break; } @@ -2549,29 +2352,29 @@ bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId if(!(rVal >>= nVal )) return false; - XGradient aXGradient = GetGradientValue(); + basegfx::BGradient aBGradient = GetGradientValue(); switch ( nMemberId ) { case MID_GRADIENT_STYLE: - aXGradient.SetGradientStyle( static_cast<css::awt::GradientStyle>(nVal) ); break; + aBGradient.SetGradientStyle( static_cast<css::awt::GradientStyle>(nVal) ); break; case MID_GRADIENT_ANGLE: - aXGradient.SetAngle( Degree10(nVal) ); break; + aBGradient.SetAngle( Degree10(nVal) ); break; case MID_GRADIENT_BORDER: - aXGradient.SetBorder( nVal ); break; + aBGradient.SetBorder( nVal ); break; case MID_GRADIENT_STARTINTENSITY: - aXGradient.SetStartIntens( nVal ); break; + aBGradient.SetStartIntens( nVal ); break; case MID_GRADIENT_ENDINTENSITY: - aXGradient.SetEndIntens( nVal ); break; + aBGradient.SetEndIntens( nVal ); break; case MID_GRADIENT_STEPCOUNT: - aXGradient.SetSteps( nVal ); break; + aBGradient.SetSteps( nVal ); break; case MID_GRADIENT_XOFFSET: - aXGradient.SetXOffset( nVal ); break; + aBGradient.SetXOffset( nVal ); break; case MID_GRADIENT_YOFFSET: - aXGradient.SetYOffset( nVal ); break; + aBGradient.SetYOffset( nVal ); break; } - SetGradientValue( aXGradient ); + SetGradientValue( aBGradient ); break; } } @@ -2622,7 +2425,7 @@ XFillFloatTransparenceItem::XFillFloatTransparenceItem() : SetWhich( XATTR_FILLFLOATTRANSPARENCE ); } -XFillFloatTransparenceItem::XFillFloatTransparenceItem(const OUString& rName, const XGradient& rGradient, bool bEnable ) : +XFillFloatTransparenceItem::XFillFloatTransparenceItem(const OUString& rName, const basegfx::BGradient& rGradient, bool bEnable ) : XFillGradientItem ( rName, rGradient ), bEnabled ( bEnable ) { @@ -2636,7 +2439,7 @@ XFillFloatTransparenceItem::XFillFloatTransparenceItem( const XFillFloatTranspar SetWhich( XATTR_FILLFLOATTRANSPARENCE ); } -XFillFloatTransparenceItem::XFillFloatTransparenceItem(const XGradient& rTheGradient, bool bEnable ) +XFillFloatTransparenceItem::XFillFloatTransparenceItem(const basegfx::BGradient& rTheGradient, bool bEnable ) : XFillGradientItem ( -1, rTheGradient ), bEnabled ( bEnable ) { diff --git a/svx/source/xoutdev/xpool.cxx b/svx/source/xoutdev/xpool.cxx index 5294092a3183..e0a280791b30 100644 --- a/svx/source/xoutdev/xpool.cxx +++ b/svx/source/xoutdev/xpool.cxx @@ -109,8 +109,8 @@ XOutdevItemPool::XOutdevItemPool(SfxItemPool* _pMaster) rPoolDefaults[XATTR_FILLSTYLE -XATTR_START] = new XFillStyleItem; rPoolDefaults[XATTR_FILLCOLOR -XATTR_START] = new XFillColorItem (aNullStr,aNullFillCol); - // XGradient() default already creates [COL_BLACK, COL_WHITE] as defaults - rPoolDefaults[XATTR_FILLGRADIENT -XATTR_START] = new XFillGradientItem(XGradient()); + // basegfx::BGradient() default already creates [COL_BLACK, COL_WHITE] as defaults + rPoolDefaults[XATTR_FILLGRADIENT -XATTR_START] = new XFillGradientItem(basegfx::BGradient()); rPoolDefaults[XATTR_FILLHATCH -XATTR_START] = new XFillHatchItem (aNullHatch); rPoolDefaults[XATTR_FILLBITMAP -XATTR_START] = new XFillBitmapItem (Graphic()); @@ -128,8 +128,8 @@ XOutdevItemPool::XOutdevItemPool(SfxItemPool* _pMaster) rPoolDefaults[XATTR_FILLBMP_POSOFFSETY -XATTR_START] = new XFillBmpPosOffsetYItem; rPoolDefaults[XATTR_FILLFLOATTRANSPARENCE -XATTR_START] = new XFillFloatTransparenceItem( - XGradient( - basegfx::utils::createColorStopsFromStartEndColor( + basegfx::BGradient( + basegfx::BColorStops( COL_BLACK.getBColor(), COL_BLACK.getBColor())), false); diff --git a/svx/source/xoutdev/xtabgrdt.cxx b/svx/source/xoutdev/xtabgrdt.cxx index 4ae0bf68ff23..40d881c19dae 100644 --- a/svx/source/xoutdev/xtabgrdt.cxx +++ b/svx/source/xoutdev/xtabgrdt.cxx @@ -70,18 +70,18 @@ bool XGradientList::Create() sal_Int32 nLen = aStr.getLength() - 1; // XGradient() default already creates [COL_BLACK, COL_WHITE] as defaults - Insert(std::make_unique<XGradientEntry>(XGradient(),aStr.toString())); + Insert(std::make_unique<XGradientEntry>(basegfx::BGradient(),aStr.toString())); aStr[nLen] = '2'; - Insert(std::make_unique<XGradientEntry>(XGradient(basegfx::utils::createColorStopsFromStartEndColor(COL_BLUE.getBColor(), COL_RED.getBColor()), css::awt::GradientStyle_AXIAL , 300_deg10,20,20,10,100,100),aStr.toString())); + Insert(std::make_unique<XGradientEntry>(basegfx::BGradient(basegfx::BColorStops(COL_BLUE.getBColor(), COL_RED.getBColor()), css::awt::GradientStyle_AXIAL , 300_deg10,20,20,10,100,100),aStr.toString())); aStr[nLen] = '3'; - Insert(std::make_unique<XGradientEntry>(XGradient(basegfx::utils::createColorStopsFromStartEndColor(COL_RED.getBColor(), COL_YELLOW.getBColor()), css::awt::GradientStyle_RADIAL , 600_deg10,30,30,20,100,100),aStr.toString())); + Insert(std::make_unique<XGradientEntry>(basegfx::BGradient(basegfx::BColorStops(COL_RED.getBColor(), COL_YELLOW.getBColor()), css::awt::GradientStyle_RADIAL , 600_deg10,30,30,20,100,100),aStr.toString())); aStr[nLen] = '4'; - Insert(std::make_unique<XGradientEntry>(XGradient(basegfx::utils::createColorStopsFromStartEndColor(COL_YELLOW.getBColor(), COL_GREEN.getBColor()), css::awt::GradientStyle_ELLIPTICAL, 900_deg10,40,40,30,100,100),aStr.toString())); + Insert(std::make_unique<XGradientEntry>(basegfx::BGradient(basegfx::BColorStops(COL_YELLOW.getBColor(), COL_GREEN.getBColor()), css::awt::GradientStyle_ELLIPTICAL, 900_deg10,40,40,30,100,100),aStr.toString())); aStr[nLen] = '5'; - Insert(std::make_unique<XGradientEntry>(XGradient(basegfx::utils::createColorStopsFromStartEndColor(COL_GREEN.getBColor(), COL_MAGENTA.getBColor()), css::awt::GradientStyle_SQUARE , 1200_deg10,50,50,40,100,100),aStr.toString())); + Insert(std::make_unique<XGradientEntry>(basegfx::BGradient(basegfx::BColorStops(COL_GREEN.getBColor(), COL_MAGENTA.getBColor()), css::awt::GradientStyle_SQUARE , 1200_deg10,50,50,40,100,100),aStr.toString())); aStr[nLen] = '6'; - Insert(std::make_unique<XGradientEntry>(XGradient(basegfx::utils::createColorStopsFromStartEndColor(COL_MAGENTA.getBColor(), COL_YELLOW.getBColor()), css::awt::GradientStyle_RECT , 1900_deg10,60,60,50,100,100),aStr.toString())); + Insert(std::make_unique<XGradientEntry>(basegfx::BGradient(basegfx::BColorStops(COL_MAGENTA.getBColor(), COL_YELLOW.getBColor()), css::awt::GradientStyle_RECT , 1900_deg10,60,60,50,100,100),aStr.toString())); return true; } @@ -100,15 +100,14 @@ BitmapEx XGradientList::CreateBitmap( tools::Long nIndex, const Size& rSize ) co basegfx::utils::createPolygonFromRect( basegfx::B2DRange(0.0, 0.0, rSize.Width(), rSize.Height()))); - const XGradient& rGradient = GetGradient(nIndex)->GetGradient(); - basegfx::ColorStops aColorStops(rGradient.GetColorStops()); + const basegfx::BGradient& rGradient = GetGradient(nIndex)->GetGradient(); + basegfx::BColorStops aColorStops(rGradient.GetColorStops()); if (rGradient.GetStartIntens() != 100 || rGradient.GetEndIntens() != 100) { // Need to do the (old, crazy) blend against black - basegfx::utils::blendColorStopsToIntensity( - aColorStops, - rGradient.GetStartIntens() * 0.01, + aColorStops.blendToIntensity( + rGradient.GetStartIntens() * 0.01, rGradient.GetEndIntens() * 0.01, basegfx::BColor()); // COL_BLACK } diff --git a/svx/source/xoutdev/xtable.cxx b/svx/source/xoutdev/xtable.cxx index bc8834e868b5..9818fd1939f4 100644 --- a/svx/source/xoutdev/xtable.cxx +++ b/svx/source/xoutdev/xtable.cxx @@ -72,7 +72,7 @@ XHatchEntry::XHatchEntry(const XHatchEntry& rOther) { } -XGradientEntry::XGradientEntry(const XGradient& rGradient, const OUString& rName) +XGradientEntry::XGradientEntry(const basegfx::BGradient& rGradient, const OUString& rName) : XPropertyEntry(rName), aGradient(rGradient) { |