diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-06-15 12:19:39 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-06-22 08:23:53 +0200 |
commit | a62513e1e80e39f9928e9e1815a84761403a4f2b (patch) | |
tree | 7d0cc6030242c41986838922fd5149f31d28cb40 /svgio | |
parent | 25aa310b923ac26b62a97c0e95549e053d294da4 (diff) |
tdf#155735: Add support for hueRotate type
Change-Id: I9c7ada2908c0739708fbc9e28ac58430350da7a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153112
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/inc/svgfecolormatrixnode.hxx | 3 | ||||
-rw-r--r-- | svgio/qa/cppunit/SvgImportTest.cxx | 4 | ||||
-rw-r--r-- | svgio/source/svgreader/svgfecolormatrixnode.cxx | 27 |
3 files changed, 23 insertions, 11 deletions
diff --git a/svgio/inc/svgfecolormatrixnode.hxx b/svgio/inc/svgfecolormatrixnode.hxx index 631da8877372..a63d44715457 100644 --- a/svgio/inc/svgfecolormatrixnode.hxx +++ b/svgio/inc/svgfecolormatrixnode.hxx @@ -28,6 +28,7 @@ namespace svgio::svgreader enum class ColorType { None, + HueRotate, Saturate, LuminanceToAlpha }; @@ -36,7 +37,7 @@ class SvgFeColorMatrixNode final : public SvgNode { private: ColorType maType; - SvgNumber maValues; + OUString maValuesContent; public: SvgFeColorMatrixNode(SvgDocument& rDocument, SvgNode* pParent); diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 87c99ba72509..87beb7742405 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -165,8 +165,8 @@ CPPUNIT_TEST_FIXTURE(Test, testFeColorMatrix) //assertXPath(pDocument, "/primitive2D/transform/mask/modifiedColor", "modifier", "matrix"); assertXPath(pDocument, "/primitive2D/transform/mask/modifiedColor[1]", "modifier", "saturate"); - //assertXPath(pDocument, "/primitive2D/transform/mask/modifiedColor", "modifier", "hueRotate"); - assertXPath(pDocument, "/primitive2D/transform/mask/modifiedColor[2]", "modifier", "luminance_to_alpha"); + assertXPath(pDocument, "/primitive2D/transform/mask/modifiedColor[2]", "modifier", "hueRotate"); + assertXPath(pDocument, "/primitive2D/transform/mask/modifiedColor[3]", "modifier", "luminance_to_alpha"); } CPPUNIT_TEST_FIXTURE(Test, testFilterFeGaussianBlur) diff --git a/svgio/source/svgreader/svgfecolormatrixnode.cxx b/svgio/source/svgreader/svgfecolormatrixnode.cxx index 2a02ddc3c0bd..42611e48efdd 100644 --- a/svgio/source/svgreader/svgfecolormatrixnode.cxx +++ b/svgio/source/svgreader/svgfecolormatrixnode.cxx @@ -26,7 +26,6 @@ namespace svgio::svgreader SvgFeColorMatrixNode::SvgFeColorMatrixNode(SvgDocument& rDocument, SvgNode* pParent) : SvgNode(SVGToken::FeColorMatrix, rDocument, pParent) , maType(ColorType::None) - , maValues(1.0) { } @@ -50,17 +49,16 @@ void SvgFeColorMatrixNode::parseAttribute(const OUString& /*rTokenName*/, SVGTok { maType = ColorType::Saturate; } + else if (o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"hueRotate")) + { + maType = ColorType::HueRotate; + } } break; } case SVGToken::Values: { - SvgNumber aNum; - - if (readSingleNumber(aContent, aNum)) - { - maValues = aNum; - } + maValuesContent = aContent; break; } default: @@ -82,10 +80,23 @@ void SvgFeColorMatrixNode::apply(drawinglayer::primitive2d::Primitive2DContainer } else if (maType == ColorType::Saturate) { + SvgNumber aNum(1.0); + readSingleNumber(maValuesContent, aNum); + const drawinglayer::primitive2d::Primitive2DReference xRef( new drawinglayer::primitive2d::ModifiedColorPrimitive2D( std::move(rTarget), - std::make_shared<basegfx::BColorModifier_saturate>(maValues.getNumber()))); + std::make_shared<basegfx::BColorModifier_saturate>(aNum.getNumber()))); + rTarget = drawinglayer::primitive2d::Primitive2DContainer{ xRef }; + } + else if (maType == ColorType::HueRotate) + { + SvgNumber aNum(0.0); + readSingleNumber(maValuesContent, aNum); + const drawinglayer::primitive2d::Primitive2DReference xRef( + new drawinglayer::primitive2d::ModifiedColorPrimitive2D( + std::move(rTarget), std::make_shared<basegfx::BColorModifier_hueRotate>( + basegfx::deg2rad(aNum.getNumber())))); rTarget = drawinglayer::primitive2d::Primitive2DContainer{ xRef }; } } |