diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-07-12 08:12:30 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-07-12 13:23:44 +0200 |
commit | 8d03f1d83d4ca561c11463325f16d7520a36df32 (patch) | |
tree | 5e8a1244af9bce4813197c4ca6618a5042f2d153 /svgio | |
parent | bc662b15bf56bd405cb86e592e4ade9917ab49d1 (diff) |
svgio: re-implement to use virtual function
kudos to Mike Kaganski for the hint
Change-Id: Iea58a31ffa481c4d9579a31f045f2a73d30ad883
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154344
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/inc/svgfecolormatrixnode.hxx | 6 | ||||
-rw-r--r-- | svgio/inc/svgfedropshadownode.hxx | 6 | ||||
-rw-r--r-- | svgio/inc/svgfefloodnode.hxx | 6 | ||||
-rw-r--r-- | svgio/inc/svgfegaussianblurnode.hxx | 6 | ||||
-rw-r--r-- | svgio/inc/svgfeimagenode.hxx | 6 | ||||
-rw-r--r-- | svgio/inc/svgfeoffsetnode.hxx | 6 | ||||
-rw-r--r-- | svgio/inc/svgfilternode.hxx | 6 | ||||
-rw-r--r-- | svgio/source/svgreader/svgdocumenthandler.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgfecolormatrixnode.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgfedropshadownode.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgfefloodnode.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgfegaussianblurnode.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgfeimagenode.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgfeoffsetnode.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgfilternode.cxx | 42 |
15 files changed, 33 insertions, 65 deletions
diff --git a/svgio/inc/svgfecolormatrixnode.hxx b/svgio/inc/svgfecolormatrixnode.hxx index 975d9d082972..b8c3944435b4 100644 --- a/svgio/inc/svgfecolormatrixnode.hxx +++ b/svgio/inc/svgfecolormatrixnode.hxx @@ -19,7 +19,7 @@ #pragma once -#include "svgnode.hxx" +#include "svgfilternode.hxx" #include "svgstyleattributes.hxx" #include <basegfx/matrix/b3dhommatrix.hxx> @@ -33,7 +33,7 @@ enum class ColorType LuminanceToAlpha }; -class SvgFeColorMatrixNode final : public SvgNode +class SvgFeColorMatrixNode final : public SvgFilterNode { private: ColorType maType; @@ -46,7 +46,7 @@ public: virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override; - void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const; + void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const override; }; } // end of namespace svgio::svgreader diff --git a/svgio/inc/svgfedropshadownode.hxx b/svgio/inc/svgfedropshadownode.hxx index 5cc4b51ed797..1f3b62576411 100644 --- a/svgio/inc/svgfedropshadownode.hxx +++ b/svgio/inc/svgfedropshadownode.hxx @@ -19,12 +19,12 @@ #pragma once -#include "svgnode.hxx" +#include "svgfilternode.hxx" #include "svgstyleattributes.hxx" namespace svgio::svgreader { -class SvgFeDropShadowNode final : public SvgNode +class SvgFeDropShadowNode final : public SvgFilterNode { private: SvgNumber maDx; @@ -40,7 +40,7 @@ public: virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override; - void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const; + void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const override; }; } // end of namespace svgio::svgreader diff --git a/svgio/inc/svgfefloodnode.hxx b/svgio/inc/svgfefloodnode.hxx index a8cb2da47e51..cc7a985e4416 100644 --- a/svgio/inc/svgfefloodnode.hxx +++ b/svgio/inc/svgfefloodnode.hxx @@ -19,12 +19,12 @@ #pragma once -#include "svgnode.hxx" +#include "svgfilternode.hxx" #include "svgstyleattributes.hxx" namespace svgio::svgreader { -class SvgFeFloodNode final : public SvgNode +class SvgFeFloodNode final : public SvgFilterNode { private: SvgNumber maX; @@ -41,7 +41,7 @@ public: virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override; - void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const; + void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const override; }; } // end of namespace svgio::svgreader diff --git a/svgio/inc/svgfegaussianblurnode.hxx b/svgio/inc/svgfegaussianblurnode.hxx index 0bef266f9368..7ef7acdc419c 100644 --- a/svgio/inc/svgfegaussianblurnode.hxx +++ b/svgio/inc/svgfegaussianblurnode.hxx @@ -19,13 +19,13 @@ #pragma once -#include "svgnode.hxx" +#include "svgfilternode.hxx" #include "svgstyleattributes.hxx" #include <basegfx/matrix/b2dhommatrix.hxx> namespace svgio::svgreader { -class SvgFeGaussianBlurNode final : public SvgNode +class SvgFeGaussianBlurNode final : public SvgFilterNode { private: SvgNumber maStdDeviation; @@ -37,7 +37,7 @@ public: virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override; - void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const; + void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const override; }; } // end of namespace svgio::svgreader diff --git a/svgio/inc/svgfeimagenode.hxx b/svgio/inc/svgfeimagenode.hxx index ff3c87930a6c..0177cafdf4cd 100644 --- a/svgio/inc/svgfeimagenode.hxx +++ b/svgio/inc/svgfeimagenode.hxx @@ -19,12 +19,12 @@ #pragma once -#include "svgnode.hxx" +#include "svgfilternode.hxx" #include "svgstyleattributes.hxx" namespace svgio::svgreader { -class SvgFeImageNode final : public SvgNode +class SvgFeImageNode final : public SvgFilterNode { private: OUString maUrl; // external link @@ -37,7 +37,7 @@ public: virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override; - void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const; + void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const override; }; } // end of namespace svgio::svgreader diff --git a/svgio/inc/svgfeoffsetnode.hxx b/svgio/inc/svgfeoffsetnode.hxx index 22bf212d7c20..fe83e67cef93 100644 --- a/svgio/inc/svgfeoffsetnode.hxx +++ b/svgio/inc/svgfeoffsetnode.hxx @@ -19,12 +19,12 @@ #pragma once -#include "svgnode.hxx" +#include "svgfilternode.hxx" #include "svgstyleattributes.hxx" namespace svgio::svgreader { -class SvgFeOffsetNode final : public SvgNode +class SvgFeOffsetNode final : public SvgFilterNode { private: SvgNumber maDx; @@ -37,7 +37,7 @@ public: virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override; - void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const; + void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const override; }; } // end of namespace svgio::svgreader diff --git a/svgio/inc/svgfilternode.hxx b/svgio/inc/svgfilternode.hxx index 19ce2cb34b33..0c87ba54b47b 100644 --- a/svgio/inc/svgfilternode.hxx +++ b/svgio/inc/svgfilternode.hxx @@ -25,13 +25,13 @@ namespace svgio::svgreader { -class SvgFilterNode final : public SvgNode +class SvgFilterNode : public SvgNode { public: - SvgFilterNode(SvgDocument& rDocument, SvgNode* pParent); + SvgFilterNode(SVGToken aType, SvgDocument& rDocument, SvgNode* pParent); virtual ~SvgFilterNode() override; - void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const; + virtual void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const; }; } // end of namespace svgio::svgreader diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx b/svgio/source/svgreader/svgdocumenthandler.cxx index 99ca832a34f5..01dc6316b043 100644 --- a/svgio/source/svgreader/svgdocumenthandler.cxx +++ b/svgio/source/svgreader/svgdocumenthandler.cxx @@ -381,7 +381,7 @@ namespace case SVGToken::Filter: { /// new node for Filter - mpTarget = new SvgFilterNode(maDocument, mpTarget); + mpTarget = new SvgFilterNode(aSVGToken, maDocument, mpTarget); mpTarget->parseAttributes(xAttribs); break; } diff --git a/svgio/source/svgreader/svgfecolormatrixnode.cxx b/svgio/source/svgreader/svgfecolormatrixnode.cxx index d08c5ea44280..ba4584aa2554 100644 --- a/svgio/source/svgreader/svgfecolormatrixnode.cxx +++ b/svgio/source/svgreader/svgfecolormatrixnode.cxx @@ -24,7 +24,7 @@ namespace svgio::svgreader { SvgFeColorMatrixNode::SvgFeColorMatrixNode(SvgDocument& rDocument, SvgNode* pParent) - : SvgNode(SVGToken::FeColorMatrix, rDocument, pParent) + : SvgFilterNode(SVGToken::FeColorMatrix, rDocument, pParent) , maType(ColorType::Matrix) { } diff --git a/svgio/source/svgreader/svgfedropshadownode.cxx b/svgio/source/svgreader/svgfedropshadownode.cxx index 56dd5dcf9587..d33583e44a90 100644 --- a/svgio/source/svgreader/svgfedropshadownode.cxx +++ b/svgio/source/svgreader/svgfedropshadownode.cxx @@ -27,7 +27,7 @@ namespace svgio::svgreader { SvgFeDropShadowNode::SvgFeDropShadowNode(SvgDocument& rDocument, SvgNode* pParent) - : SvgNode(SVGToken::FeDropShadow, rDocument, pParent) + : SvgFilterNode(SVGToken::FeDropShadow, rDocument, pParent) , maDx(0.0) , maDy(0.0) , maStdDeviation(0.0) diff --git a/svgio/source/svgreader/svgfefloodnode.cxx b/svgio/source/svgreader/svgfefloodnode.cxx index 3cd1c178f2d4..99b8d111b32b 100644 --- a/svgio/source/svgreader/svgfefloodnode.cxx +++ b/svgio/source/svgreader/svgfefloodnode.cxx @@ -27,7 +27,7 @@ namespace svgio::svgreader { SvgFeFloodNode::SvgFeFloodNode(SvgDocument& rDocument, SvgNode* pParent) - : SvgNode(SVGToken::FeFlood, rDocument, pParent) + : SvgFilterNode(SVGToken::FeFlood, rDocument, pParent) , maX(0.0) , maY(0.0) , maWidth(0.0) diff --git a/svgio/source/svgreader/svgfegaussianblurnode.cxx b/svgio/source/svgreader/svgfegaussianblurnode.cxx index 03f3e4298a1b..e2be664be725 100644 --- a/svgio/source/svgreader/svgfegaussianblurnode.cxx +++ b/svgio/source/svgreader/svgfegaussianblurnode.cxx @@ -24,7 +24,7 @@ namespace svgio::svgreader { SvgFeGaussianBlurNode::SvgFeGaussianBlurNode(SvgDocument& rDocument, SvgNode* pParent) - : SvgNode(SVGToken::FeGaussianBlur, rDocument, pParent) + : SvgFilterNode(SVGToken::FeGaussianBlur, rDocument, pParent) , maStdDeviation(SvgNumber(0.0)) { } diff --git a/svgio/source/svgreader/svgfeimagenode.cxx b/svgio/source/svgreader/svgfeimagenode.cxx index 56121739fe87..12938a6e1be7 100644 --- a/svgio/source/svgreader/svgfeimagenode.cxx +++ b/svgio/source/svgreader/svgfeimagenode.cxx @@ -30,7 +30,7 @@ namespace svgio::svgreader { SvgFeImageNode::SvgFeImageNode(SvgDocument& rDocument, SvgNode* pParent) - : SvgNode(SVGToken::FeImage, rDocument, pParent) + : SvgFilterNode(SVGToken::FeImage, rDocument, pParent) { } diff --git a/svgio/source/svgreader/svgfeoffsetnode.cxx b/svgio/source/svgreader/svgfeoffsetnode.cxx index a2129b8f3ee5..17426a348bad 100644 --- a/svgio/source/svgreader/svgfeoffsetnode.cxx +++ b/svgio/source/svgreader/svgfeoffsetnode.cxx @@ -24,7 +24,7 @@ namespace svgio::svgreader { SvgFeOffsetNode::SvgFeOffsetNode(SvgDocument& rDocument, SvgNode* pParent) - : SvgNode(SVGToken::FeOffset, rDocument, pParent) + : SvgFilterNode(SVGToken::FeOffset, rDocument, pParent) , maDx(SvgNumber(0.0)) , maDy(SvgNumber(0.0)) { diff --git a/svgio/source/svgreader/svgfilternode.cxx b/svgio/source/svgreader/svgfilternode.cxx index f7d291b42c79..3e21e9c2adac 100644 --- a/svgio/source/svgreader/svgfilternode.cxx +++ b/svgio/source/svgreader/svgfilternode.cxx @@ -27,8 +27,8 @@ namespace svgio::svgreader { -SvgFilterNode::SvgFilterNode(SvgDocument& rDocument, SvgNode* pParent) - : SvgNode(SVGToken::Filter, rDocument, pParent) +SvgFilterNode::SvgFilterNode(SVGToken aType, SvgDocument& rDocument, SvgNode* pParent) + : SvgNode(aType, rDocument, pParent) { } @@ -45,41 +45,9 @@ void SvgFilterNode::apply(drawinglayer::primitive2d::Primitive2DContainer& rTarg // apply children's filters for (sal_uInt32 a(0); a < nCount; a++) { - SvgNode* pCandidate = rChildren[a].get(); - if (pCandidate->getType() == SVGToken::FeGaussianBlur) - { - const SvgFeGaussianBlurNode& rFeGaussianBlurNode - = dynamic_cast<const SvgFeGaussianBlurNode&>(*pCandidate); - rFeGaussianBlurNode.apply(rTarget); - } - else if (pCandidate->getType() == SVGToken::FeColorMatrix) - { - const SvgFeColorMatrixNode& rFeColorMatrixNode - = dynamic_cast<const SvgFeColorMatrixNode&>(*pCandidate); - rFeColorMatrixNode.apply(rTarget); - } - else if (pCandidate->getType() == SVGToken::FeOffset) - { - const SvgFeOffsetNode& rFeOffsetNode - = dynamic_cast<const SvgFeOffsetNode&>(*pCandidate); - rFeOffsetNode.apply(rTarget); - } - else if (pCandidate->getType() == SVGToken::FeFlood) - { - const SvgFeFloodNode& rFeFloodNode = dynamic_cast<const SvgFeFloodNode&>(*pCandidate); - rFeFloodNode.apply(rTarget); - } - else if (pCandidate->getType() == SVGToken::FeDropShadow) - { - const SvgFeDropShadowNode& rFeDropShadowNode - = dynamic_cast<const SvgFeDropShadowNode&>(*pCandidate); - rFeDropShadowNode.apply(rTarget); - } - else if (pCandidate->getType() == SVGToken::FeImage) - { - const SvgFeImageNode& rFeImageNode = dynamic_cast<const SvgFeImageNode&>(*pCandidate); - rFeImageNode.apply(rTarget); - } + SvgFilterNode* pFilterNode = dynamic_cast<SvgFilterNode*>(rChildren[a].get()); + if (pFilterNode) + pFilterNode->apply(rTarget); } } |