diff options
author | Armin Le Grand <Armin.Le.Grand@me.com> | 2020-03-12 13:31:44 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2020-03-12 14:49:39 +0100 |
commit | c20e70d28df21429bba92b6d8a7d7061c2aa5d8b (patch) | |
tree | ff749422b13a242db24e58c8dc0b9cb1d537e369 /drawinglayer/source | |
parent | a3d3e076def075f0a5bced48d89ca0d989a2467c (diff) |
tdf#124424 Corrections at SvgGradientHelper for EMF+
Change-Id: Ibda3568887de5df2bc45a9bc8cb424ba7658a768
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90382
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'drawinglayer/source')
-rw-r--r-- | drawinglayer/source/primitive2d/svggradientprimitive2d.cxx | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx index 4367d8e3eb1a..20d3182e5ba8 100644 --- a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx @@ -240,29 +240,32 @@ namespace drawinglayer::primitive2d double fStart, double fEnd) const { + double fInt(0.0); + double fFrac(0.0); + double fEnd2(0.0); + if(SpreadMethod::Pad == getSpreadMethod()) { if(fStart < 0.0) { + fFrac = std::modf(fStart, &fInt); const SvgGradientEntry& rFront(getGradientEntries().front()); - const SvgGradientEntry aTemp(fStart, rFront.getColor(), rFront.getOpacity()); - createAtom(rTargetColor, rTargetOpacity, aTemp, rFront, 0, 0); + const SvgGradientEntry aTemp(1.0 + fFrac, rFront.getColor(), rFront.getOpacity()); + createAtom(rTargetColor, rTargetOpacity, aTemp, rFront, static_cast<sal_Int32>(fInt - 1), 0); fStart = rFront.getOffset(); } - if(fEnd < 1.0) + if(fEnd > 1.0) { - const SvgGradientEntry& rBack(getGradientEntries().back()); - const SvgGradientEntry aTemp(fEnd, rBack.getColor(), rBack.getOpacity()); - createAtom(rTargetColor, rTargetOpacity, rBack, aTemp, 0, 0); - fEnd = rBack.getOffset(); + // change fEnd early, but create geometry later (after range below) + fEnd2 = fEnd; + fEnd = getGradientEntries().back().getOffset(); } } while(fStart < fEnd) { - double fInt(0.0); - double fFrac(std::modf(fStart, &fInt)); + fFrac = std::modf(fStart, &fInt); if(fFrac < 0.0) { @@ -289,6 +292,15 @@ namespace drawinglayer::primitive2d fStart += 1.0; } } + + if(fEnd2 > 1.0) + { + // create end run for SpreadMethod::Pad late to keep correct creation order + fFrac = std::modf(fEnd2, &fInt); + const SvgGradientEntry& rBack(getGradientEntries().back()); + const SvgGradientEntry aTemp(fFrac, rBack.getColor(), rBack.getOpacity()); + createAtom(rTargetColor, rTargetOpacity, rBack, aTemp, 0, static_cast<sal_Int32>(fInt)); + } } void SvgGradientHelper::createResult( |