diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-06-06 17:09:36 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-06-07 10:45:44 +0200 |
commit | a4a570222e1270fecf17fba2c35e96907a327dc1 (patch) | |
tree | 08dadee99344fee4be6b84f42c170814e07e8f2f /svgio | |
parent | 756254beedf2220a7602c81059ae1d70589072ac (diff) |
related: tdf#132246: Add basic filter node
Change-Id: Iff451c441f0fe2c2fd2a14db8214f7a7d554dd15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152680
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/Library_svgio.mk | 1 | ||||
-rw-r--r-- | svgio/inc/svgfilternode.hxx | 37 | ||||
-rw-r--r-- | svgio/inc/svgstyleattributes.hxx | 7 | ||||
-rw-r--r-- | svgio/inc/svgtoken.hxx | 1 | ||||
-rw-r--r-- | svgio/source/svgreader/svgdocumenthandler.cxx | 11 | ||||
-rw-r--r-- | svgio/source/svgreader/svgfilternode.cxx | 33 | ||||
-rw-r--r-- | svgio/source/svgreader/svgstyleattributes.cxx | 44 | ||||
-rw-r--r-- | svgio/source/svgreader/svgtoken.cxx | 2 |
8 files changed, 134 insertions, 2 deletions
diff --git a/svgio/Library_svgio.mk b/svgio/Library_svgio.mk index 917f9ea4865e..8770f733d441 100644 --- a/svgio/Library_svgio.mk +++ b/svgio/Library_svgio.mk @@ -57,6 +57,7 @@ $(eval $(call gb_Library_add_exception_objects,svgio,\ svgio/source/svgreader/svgellipsenode \ svgio/source/svgreader/svggnode \ svgio/source/svgreader/svganode \ + svgio/source/svgreader/svgfilternode \ svgio/source/svgreader/svggradientnode \ svgio/source/svgreader/svggradientstopnode \ svgio/source/svgreader/svgimagenode \ diff --git a/svgio/inc/svgfilternode.hxx b/svgio/inc/svgfilternode.hxx new file mode 100644 index 000000000000..e6c24450b4e2 --- /dev/null +++ b/svgio/inc/svgfilternode.hxx @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include "svgnode.hxx" +#include "svgstyleattributes.hxx" +#include <basegfx/matrix/b2dhommatrix.hxx> + +namespace svgio::svgreader +{ +class SvgFilterNode final : public SvgNode +{ +public: + SvgFilterNode(SvgDocument& rDocument, SvgNode* pParent); + virtual ~SvgFilterNode() override; +}; + +} // end of namespace svgio::svgreader + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svgio/inc/svgstyleattributes.hxx b/svgio/inc/svgstyleattributes.hxx index 4455f2311b69..52876ea0576d 100644 --- a/svgio/inc/svgstyleattributes.hxx +++ b/svgio/inc/svgstyleattributes.hxx @@ -34,6 +34,7 @@ namespace svgio::svgreader { class SvgPatternNode; class SvgMarkerNode; class SvgClipPathNode; + class SvgFilterNode; class SvgMaskNode; } @@ -205,6 +206,8 @@ namespace svgio::svgreader /// link to content. If set, the node can be fetched on demand OUString maClipPathXLink; const SvgClipPathNode* mpClipPathXLink; + OUString maFilterXLink; + const SvgFilterNode* mpFilterXLink; OUString maMaskXLink; const SvgMaskNode* mpMaskXLink; @@ -417,6 +420,10 @@ namespace svgio::svgreader OUString getClipPathXLink() const; const SvgClipPathNode* accessClipPathXLink() const; + // FilterXLink content + OUString getFilterXLink() const; + const SvgFilterNode* accessFilterXLink() const; + // MaskXLink content OUString getMaskXLink() const; const SvgMaskNode* accessMaskXLink() const; diff --git a/svgio/inc/svgtoken.hxx b/svgio/inc/svgtoken.hxx index 0a24d272be5f..73c083a620e6 100644 --- a/svgio/inc/svgtoken.hxx +++ b/svgio/inc/svgtoken.hxx @@ -78,6 +78,7 @@ namespace svgio::svgreader Color, ClipPathNode, ClipPathProperty, + Filter, Mask, ClipPathUnits, MaskUnits, diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx b/svgio/source/svgreader/svgdocumenthandler.cxx index dc2dd6fa7c6b..ac866b37f0d2 100644 --- a/svgio/source/svgreader/svgdocumenthandler.cxx +++ b/svgio/source/svgreader/svgdocumenthandler.cxx @@ -41,6 +41,7 @@ #include <svgstylenode.hxx> #include <svgimagenode.hxx> #include <svgclippathnode.hxx> +#include <svgfilternode.hxx> #include <svgmasknode.hxx> #include <svgmarkernode.hxx> #include <svgpatternnode.hxx> @@ -340,6 +341,13 @@ namespace mpTarget->parseAttributes(xAttribs); break; } + case SVGToken::Filter: + { + /// new node for Filter + mpTarget = new SvgFilterNode(maDocument, mpTarget); + mpTarget->parseAttributes(xAttribs); + break; + } /// structural element marker case SVGToken::Marker: @@ -434,8 +442,9 @@ namespace /// styles (as stylesheets) case SVGToken::Style: - /// structural elements clip-path and mask + /// structural elements clip-path, filter and mask case SVGToken::ClipPathNode: + case SVGToken::Filter: case SVGToken::Mask: /// structural element marker diff --git a/svgio/source/svgreader/svgfilternode.cxx b/svgio/source/svgreader/svgfilternode.cxx new file mode 100644 index 000000000000..374feb06247b --- /dev/null +++ b/svgio/source/svgreader/svgfilternode.cxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <svgfilternode.hxx> + +namespace svgio::svgreader +{ +SvgFilterNode::SvgFilterNode(SvgDocument& rDocument, SvgNode* pParent) + : SvgNode(SVGToken::Filter, rDocument, pParent) +{ +} + +SvgFilterNode::~SvgFilterNode() {} + +} // end of namespace svgio::svgreader + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx index ffdebc2f36a4..5a3c9396ae91 100644 --- a/svgio/source/svgreader/svgstyleattributes.cxx +++ b/svgio/source/svgreader/svgstyleattributes.cxx @@ -35,6 +35,7 @@ #include <drawinglayer/processor2d/textaspolygonextractor2d.hxx> #include <basegfx/polygon/b2dpolypolygoncutter.hxx> #include <svgclippathnode.hxx> +#include <svgfilternode.hxx> #include <svgmasknode.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <svgmarkernode.hxx> @@ -1272,6 +1273,7 @@ namespace svgio::svgreader maTextAnchor(TextAnchor::notset), maVisibility(Visibility::notset), mpClipPathXLink(nullptr), + mpFilterXLink(nullptr), mpMaskXLink(nullptr), mpMarkerStartXLink(nullptr), mpMarkerMidXLink(nullptr), @@ -1280,7 +1282,7 @@ namespace svgio::svgreader maClipRule(FillRule::notset), maBaselineShift(BaselineShift::Baseline), maBaselineShiftNumber(0), - maResolvingParent(32, 0), + maResolvingParent(33, 0), mbIsClipPathContent(SVGToken::ClipPathNode == mrOwner.getType()), mbStrokeDasharraySet(false) { @@ -1855,6 +1857,11 @@ namespace svgio::svgreader readLocalUrl(aContent, maClipPathXLink); break; } + case SVGToken::Filter: + { + readLocalUrl(aContent, maFilterXLink); + break; + } case SVGToken::Mask: { readLocalUrl(aContent, maMaskXLink); @@ -2873,6 +2880,41 @@ namespace svgio::svgreader return mpClipPathXLink; } + OUString SvgStyleAttributes::getFilterXLink() const + { + if(!maFilterXLink.isEmpty()) + { + return maFilterXLink; + } + + const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); + + if (pSvgStyleAttributes && maResolvingParent[32] < nStyleDepthLimit) + { + ++maResolvingParent[32]; + auto ret = pSvgStyleAttributes->getFilterXLink(); + --maResolvingParent[32]; + return ret; + } + + return OUString(); + } + + const SvgFilterNode* SvgStyleAttributes::accessFilterXLink() const + { + if(!mpFilterXLink) + { + const OUString aFilter(getFilterXLink()); + + if(!aFilter.isEmpty()) + { + const_cast< SvgStyleAttributes* >(this)->mpFilterXLink = dynamic_cast< const SvgFilterNode* >(mrOwner.getDocument().findSvgNodeById(aFilter)); + } + } + + return mpFilterXLink; + } + OUString SvgStyleAttributes::getMaskXLink() const { if(!maMaskXLink.isEmpty()) diff --git a/svgio/source/svgreader/svgtoken.cxx b/svgio/source/svgreader/svgtoken.cxx index 0b03e2c3f0cd..a472466b3995 100644 --- a/svgio/source/svgreader/svgtoken.cxx +++ b/svgio/source/svgreader/svgtoken.cxx @@ -70,6 +70,7 @@ namespace svgio::svgreader const char aSVGStrColor[] = "color"; const char aSVGStrClipPathNode[] = "clipPath"; const char aSVGStrClipPathProperty[] = "clip-path"; + const char aSVGStrFilter[] = "filter"; const char aSVGStrMask[] = "mask"; const char aSVGStrClipPathUnits[] = "clipPathUnits"; const char aSVGStrMaskUnits[] = "maskUnits"; @@ -217,6 +218,7 @@ namespace svgio::svgreader { aSVGStrColor, SVGToken::Color }, { aSVGStrClipPathNode, SVGToken::ClipPathNode }, { aSVGStrClipPathProperty, SVGToken::ClipPathProperty }, + { aSVGStrFilter, SVGToken::Filter }, { aSVGStrMask, SVGToken::Mask }, { aSVGStrClipPathUnits, SVGToken::ClipPathUnits }, { aSVGStrMaskUnits, SVGToken::MaskUnits }, |