diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-11-04 18:36:51 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-11-08 12:09:48 +0100 |
commit | 389c8239c93663fa5546b2f0227a118a3ad091bf (patch) | |
tree | 283ca215c088c682aeb1d492d6f5b7be21921965 /svgio | |
parent | 456300d4fbea0f27453973b50d148753d0315b80 (diff) |
widget theme: Gradient support when drawing widgets
Change-Id: I29239348e36e4963d9708a22ac649b2b1d68bf02
Reviewed-on: https://gerrit.libreoffice.org/82207
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/source/svgreader/svgvisitor.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/svgio/source/svgreader/svgvisitor.cxx b/svgio/source/svgreader/svgvisitor.cxx index 011ce5492fa3..52247be8dd43 100644 --- a/svgio/source/svgreader/svgvisitor.cxx +++ b/svgio/source/svgreader/svgvisitor.cxx @@ -16,6 +16,7 @@ #include <svgsvgnode.hxx> #include <svggnode.hxx> #include <svgpathnode.hxx> +#include <svggradientnode.hxx> #include <svgvisitor.hxx> #include <tools/color.hxx> @@ -77,8 +78,44 @@ void SvgDrawVisitor::visit(svgio::svgreader::SvgNode const& rNode) pRectangle->mnOpacity = rRectNode.getSvgStyleAttributes()->getOpacity().getNumber(); const basegfx::BColor* pFillColor = rRectNode.getSvgStyleAttributes()->getFill(); + const SvgGradientNode* pFillGradient + = rRectNode.getSvgStyleAttributes()->getSvgGradientNodeFill(); if (pFillColor) + { pRectangle->mpFillColor = std::make_shared<basegfx::BColor>(*pFillColor); + } + else if (pFillGradient) + { + drawinglayer::primitive2d::SvgGradientEntryVector aSvgGradientEntryVector; + pFillGradient->collectGradientEntries(aSvgGradientEntryVector); + if (!aSvgGradientEntryVector.empty()) + { + auto aGradientInfo = std::make_shared<gfx::LinearGradientInfo>(); + + aGradientInfo->x1 = pFillGradient->getX1().getNumber(); + aGradientInfo->y1 = pFillGradient->getY1().getNumber(); + aGradientInfo->x2 = pFillGradient->getX2().getNumber(); + aGradientInfo->y2 = pFillGradient->getY2().getNumber(); + + const basegfx::B2DHomMatrix* pGradientTransform + = pFillGradient->getGradientTransform(); + if (pGradientTransform) + { + aGradientInfo->maMatrix = *pGradientTransform; + } + + pRectangle->mpFillGradient = aGradientInfo; + + for (auto const& rEntry : aSvgGradientEntryVector) + { + gfx::GradientStop aStop; + aStop.maColor = rEntry.getColor(); + aStop.mfOffset = rEntry.getOffset(); + aStop.mfOpacity = rEntry.getOpacity(); + pRectangle->mpFillGradient->maGradientStops.push_back(aStop); + } + } + } const basegfx::BColor* pStrokeColor = rRectNode.getSvgStyleAttributes()->getStroke(); if (pStrokeColor) |