summaryrefslogtreecommitdiffstats
path: root/svgio/inc
diff options
context:
space:
mode:
Diffstat (limited to 'svgio/inc')
-rw-r--r--svgio/inc/SvgNumber.hxx115
-rw-r--r--svgio/inc/pch/precompiled_svgio.cxx12
-rw-r--r--svgio/inc/pch/precompiled_svgio.hxx69
-rw-r--r--svgio/inc/svganode.hxx54
-rw-r--r--svgio/inc/svgcharacternode.hxx81
-rw-r--r--svgio/inc/svgcirclenode.hxx66
-rw-r--r--svgio/inc/svgclippathnode.hxx64
-rw-r--r--svgio/inc/svgdocument.hxx85
-rw-r--r--svgio/inc/svgdocumenthandler.hxx64
-rw-r--r--svgio/inc/svgellipsenode.hxx70
-rw-r--r--svgio/inc/svgfecolormatrixnode.hxx53
-rw-r--r--svgio/inc/svgfedropshadownode.hxx47
-rw-r--r--svgio/inc/svgfefloodnode.hxx48
-rw-r--r--svgio/inc/svgfegaussianblurnode.hxx44
-rw-r--r--svgio/inc/svgfeimagenode.hxx44
-rw-r--r--svgio/inc/svgfeoffsetnode.hxx44
-rw-r--r--svgio/inc/svgfilternode.hxx39
-rw-r--r--svgio/inc/svggnode.hxx55
-rw-r--r--svgio/inc/svggradientnode.hxx118
-rw-r--r--svgio/inc/svggradientstopnode.hxx51
-rw-r--r--svgio/inc/svgimagenode.hxx77
-rw-r--r--svgio/inc/svglinenode.hxx70
-rw-r--r--svgio/inc/svgmarkernode.hxx113
-rw-r--r--svgio/inc/svgmasknode.hxx84
-rw-r--r--svgio/inc/svgnode.hxx201
-rw-r--r--svgio/inc/svgpaint.hxx52
-rw-r--r--svgio/inc/svgpathnode.hxx67
-rw-r--r--svgio/inc/svgpatternnode.hxx116
-rw-r--r--svgio/inc/svgpolynode.hxx61
-rw-r--r--svgio/inc/svgrectnode.hxx78
-rw-r--r--svgio/inc/svgstyleattributes.hxx458
-rw-r--r--svgio/inc/svgstylenode.hxx58
-rw-r--r--svgio/inc/svgsvgnode.hxx93
-rw-r--r--svgio/inc/svgsymbolnode.hxx46
-rw-r--r--svgio/inc/svgtextnode.hxx62
-rw-r--r--svgio/inc/svgtextpathnode.hxx60
-rw-r--r--svgio/inc/svgtextposition.hxx72
-rw-r--r--svgio/inc/svgtitledescnode.hxx52
-rw-r--r--svgio/inc/svgtoken.hxx200
-rw-r--r--svgio/inc/svgtools.hxx137
-rw-r--r--svgio/inc/svgtrefnode.hxx53
-rw-r--r--svgio/inc/svgtspannode.hxx92
-rw-r--r--svgio/inc/svgusenode.hxx73
-rw-r--r--svgio/inc/svgvisitor.hxx35
44 files changed, 3633 insertions, 0 deletions
diff --git a/svgio/inc/SvgNumber.hxx b/svgio/inc/SvgNumber.hxx
new file mode 100644
index 0000000000..4d03335cf4
--- /dev/null
+++ b/svgio/inc/SvgNumber.hxx
@@ -0,0 +1,115 @@
+/* -*- 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 <basegfx/range/b2drange.hxx>
+#include <vector>
+
+namespace svgio::svgreader
+{
+
+enum class NumberType
+{
+ xcoordinate,
+ ycoordinate,
+ length
+};
+
+class InfoProvider
+{
+public:
+ virtual ~InfoProvider() {}
+ virtual basegfx::B2DRange getCurrentViewPort() const = 0;
+ /// return font size of node inherited from parents
+ virtual double getCurrentFontSizeInherited() const = 0;
+ /// return xheight of node inherited from parents
+ virtual double getCurrentXHeightInherited() const = 0;
+};
+
+enum class SvgUnit
+{
+ em = 0, // relative to current font size
+ ex, // relative to current x-height
+
+ px, // 'user unit'
+ pt, // points, 1/72 in
+ pc, // 1/6 in
+ cm,
+ mm,
+ in,
+
+ percent, // relative to range
+ none // for stroke-miterlimit, which has no unit
+};
+
+class SvgNumber
+{
+private:
+ double mfNumber;
+ SvgUnit meUnit;
+
+ bool mbSet : 1;
+
+public:
+ SvgNumber()
+ : mfNumber(0.0),
+ meUnit(SvgUnit::px),
+ mbSet(false)
+ {
+ }
+
+ SvgNumber(double fNum, SvgUnit aSvgUnit = SvgUnit::px, bool bSet = true)
+ : mfNumber(fNum),
+ meUnit(aSvgUnit),
+ mbSet(bSet)
+ {
+ }
+
+ double getNumber() const
+ {
+ return mfNumber;
+ }
+
+ SvgUnit getUnit() const
+ {
+ return meUnit;
+ }
+
+ bool isSet() const
+ {
+ return mbSet;
+ }
+
+ bool isPositive() const
+ {
+ return basegfx::fTools::moreOrEqual(mfNumber, 0.0);
+ }
+
+ // Only usable in cases, when the unit is not SvgUnit::percent, otherwise use method solve
+ double solveNonPercentage(const InfoProvider& rInfoProvider) const;
+
+ double solve(const InfoProvider& rInfoProvider, NumberType aNumberType = NumberType::length) const;
+};
+
+typedef std::vector<SvgNumber> SvgNumberVector;
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/pch/precompiled_svgio.cxx b/svgio/inc/pch/precompiled_svgio.cxx
new file mode 100644
index 0000000000..843dba73ff
--- /dev/null
+++ b/svgio/inc/pch/precompiled_svgio.cxx
@@ -0,0 +1,12 @@
+/* -*- 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/.
+ */
+
+#include "precompiled_svgio.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/pch/precompiled_svgio.hxx b/svgio/inc/pch/precompiled_svgio.hxx
new file mode 100644
index 0000000000..c9e284ca20
--- /dev/null
+++ b/svgio/inc/pch/precompiled_svgio.hxx
@@ -0,0 +1,69 @@
+/* -*- 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 has been autogenerated by update_pch.sh. It is possible to edit it
+ manually (such as when an include file has been moved/renamed/removed). All such
+ manual changes will be rewritten by the next run of update_pch.sh (which presumably
+ also fixes all possible problems, so it's usually better to use it).
+
+ Generated on 2021-04-11 19:48:19 using:
+ ./bin/update_pch svgio svgio --cutoff=8 --exclude:system --exclude:module --include:local
+
+ If after updating build fails, use the following command to locate conflicting headers:
+ ./bin/update_pch_bisect ./svgio/inc/pch/precompiled_svgio.hxx "make svgio.build" --find-conflicts
+*/
+
+#include <sal/config.h>
+#if PCH_LEVEL >= 1
+#include <memory>
+#include <ostream>
+#include <string_view>
+#include <vector>
+#endif // PCH_LEVEL >= 1
+#if PCH_LEVEL >= 2
+#include <osl/diagnose.h>
+#include <osl/endian.h>
+#include <rtl/instance.hxx>
+#include <rtl/math.hxx>
+#include <rtl/ref.hxx>
+#include <rtl/uri.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/log.hxx>
+#include <sal/types.h>
+#endif // PCH_LEVEL >= 2
+#if PCH_LEVEL >= 3
+#include <basegfx/basegfxdllapi.h>
+#include <basegfx/color/bcolor.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b3dpolypolygon.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <com/sun/star/drawing/PointSequenceSequence.hpp>
+#include <drawinglayer/drawinglayerdllapi.h>
+#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <o3tl/cow_wrapper.hxx>
+#include <o3tl/sorted_vector.hxx>
+#include <tools/fontenum.hxx>
+#include <tools/toolsdllapi.h>
+#endif // PCH_LEVEL >= 3
+#if PCH_LEVEL >= 4
+#include <svgdocument.hxx>
+#include <svgnode.hxx>
+#include <svgpaint.hxx>
+#include <svgstyleattributes.hxx>
+#endif // PCH_LEVEL >= 4
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svganode.hxx b/svgio/inc/svganode.hxx
new file mode 100644
index 0000000000..34bc551a54
--- /dev/null
+++ b/svgio/inc/svganode.hxx
@@ -0,0 +1,54 @@
+/* -*- 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 SvgANode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::optional<basegfx::B2DHomMatrix> mpaTransform;
+
+ public:
+ SvgANode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgANode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// transform content
+ const std::optional<basegfx::B2DHomMatrix>& getTransform() const { return mpaTransform; }
+ void setTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaTransform = pMatrix; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgcharacternode.hxx b/svgio/inc/svgcharacternode.hxx
new file mode 100644
index 0000000000..d81066af47
--- /dev/null
+++ b/svgio/inc/svgcharacternode.hxx
@@ -0,0 +1,81 @@
+/* -*- 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 <sal/config.h>
+#include <rtl/ref.hxx>
+
+#include <string_view>
+
+#include <drawinglayer/attribute/fontattribute.hxx>
+#include "svgtextnode.hxx"
+#include "svgtextposition.hxx"
+
+namespace drawinglayer::primitive2d { class TextSimplePortionPrimitive2D; }
+
+namespace svgio::svgreader
+ {
+ class SvgCharacterNode final : public SvgNode
+ {
+ private:
+ /// the string data
+ OUString maText;
+
+ // keep a copy of string data before space handling
+ OUString maTextBeforeSpaceHandling;
+
+ SvgTspanNode* mpParentLine;
+
+ /// local helpers
+ rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> createSimpleTextPrimitive(
+ SvgTextPosition& rSvgTextPosition,
+ const SvgStyleAttributes& rSvgStyleAttributes) const;
+ void decomposeTextWithStyle(
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ SvgTextPosition& rSvgTextPosition,
+ const SvgStyleAttributes& rSvgStyleAttributes) const;
+
+ public:
+ SvgCharacterNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent,
+ OUString aText);
+ virtual ~SvgCharacterNode() override;
+
+ static drawinglayer::attribute::FontAttribute getFontAttribute(
+ const SvgStyleAttributes& rSvgStyleAttributes);
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+
+ void decomposeText(drawinglayer::primitive2d::Primitive2DContainer& rTarget, SvgTextPosition& rSvgTextPosition) const;
+ void whiteSpaceHandling();
+ SvgCharacterNode* addGap(SvgCharacterNode* pPreviousCharacterNode);
+ void concatenate(std::u16string_view rText);
+
+ /// Text content
+ const OUString& getText() const { return maText; }
+
+ void setParentLine(SvgTspanNode* pParentLine) { mpParentLine = pParentLine; }
+ };
+
+} // end of namespace svgio::svgreader
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgcirclenode.hxx b/svgio/inc/svgcirclenode.hxx
new file mode 100644
index 0000000000..613bf115cf
--- /dev/null
+++ b/svgio/inc/svgcirclenode.hxx
@@ -0,0 +1,66 @@
+/* -*- 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 SvgCircleNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ SvgNumber maCx;
+ SvgNumber maCy;
+ SvgNumber maR;
+ std::optional<basegfx::B2DHomMatrix> mpaTransform;
+
+ public:
+ SvgCircleNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgCircleNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// Cx content, set if found in current context
+ const SvgNumber& getCx() const { return maCx; }
+
+ /// Cy content, set if found in current context
+ const SvgNumber& getCy() const { return maCy; }
+
+ /// R content, set if found in current context
+ const SvgNumber& getR() const { return maR; }
+
+ /// transform content, set if found in current context
+ const std::optional<basegfx::B2DHomMatrix>& getTransform() const { return mpaTransform; }
+ void setTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaTransform = pMatrix; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgclippathnode.hxx b/svgio/inc/svgclippathnode.hxx
new file mode 100644
index 0000000000..8843b9e12f
--- /dev/null
+++ b/svgio/inc/svgclippathnode.hxx
@@ -0,0 +1,64 @@
+/* -*- 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 SvgClipPathNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::optional<basegfx::B2DHomMatrix> mpaTransform;
+ SvgUnits maClipPathUnits;
+
+ public:
+ SvgClipPathNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgClipPathNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// apply contained clipPath to given geometry #i124852# transform may be needed
+ void apply(
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ const std::optional<basegfx::B2DHomMatrix>& pTransform) const;
+
+ /// clipPathUnits content
+ SvgUnits getClipPathUnits() const { return maClipPathUnits; }
+ void setClipPathUnits(const SvgUnits aClipPathUnits) { maClipPathUnits = aClipPathUnits; }
+
+ /// transform content
+ const std::optional<basegfx::B2DHomMatrix>& getTransform() const { return mpaTransform; }
+ void setTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaTransform = pMatrix; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgdocument.hxx b/svgio/inc/svgdocument.hxx
new file mode 100644
index 0000000000..77b4d38911
--- /dev/null
+++ b/svgio/inc/svgdocument.hxx
@@ -0,0 +1,85 @@
+/* -*- 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 <memory>
+#include <unordered_map>
+#include <vector>
+
+namespace svgio::svgreader
+ {
+ typedef std::vector< std::unique_ptr<SvgNode> > SvgNodeVector;
+
+ class SvgDocument
+ {
+ private:
+ /// the document hierarchy with all root nodes
+ SvgNodeVector maNodes;
+
+ /// invalid nodes that have no parent
+ SvgNodeVector maOrphanNodes;
+
+ /// the absolute path of the Svg file in progress (if available)
+ const OUString maAbsolutePath;
+
+ /// hash mapper to find nodes by their id
+ typedef std::unordered_map< OUString, const SvgNode* > IdTokenMapper;
+ IdTokenMapper maIdTokenMapperList;
+
+ /// hash mapper to find css styles by their id
+ typedef std::unordered_map< OUString, const SvgStyleAttributes* > IdStyleTokenMapper;
+ IdStyleTokenMapper maIdStyleTokenMapperList;
+
+ public:
+ explicit SvgDocument(OUString aAbsolutePath);
+ ~SvgDocument();
+
+ SvgDocument(const SvgDocument&) = delete;
+ SvgDocument& operator=(const SvgDocument&) = delete;
+
+ /// append another root node, ownership changes
+ void appendNode(std::unique_ptr<SvgNode> pNode);
+
+ /// add/remove nodes with Id to mapper
+ void addSvgNodeToMapper(const OUString& rStr, const SvgNode& rNode);
+ void removeSvgNodeFromMapper(const OUString& rStr);
+
+ /// find a node by its Id
+ const SvgNode* findSvgNodeById(const OUString& rStr) const;
+
+ /// add/remove styles to mapper
+ void addSvgStyleAttributesToMapper(const OUString& rStr, const SvgStyleAttributes& rSvgStyleAttributes);
+
+ /// find a style by its Id
+ bool hasGlobalCssStyleAttributes() const { return !maIdStyleTokenMapperList.empty(); }
+ const SvgStyleAttributes* findGlobalCssStyleAttributes(const OUString& rStr) const;
+
+ /// data read access
+ const SvgNodeVector& getSvgNodeVector() const { return maNodes; }
+ const OUString& getAbsolutePath() const { return maAbsolutePath; }
+
+ /// invalid nodes that have no parent
+ void addOrphanNode(SvgNode* pOrphan) { maOrphanNodes.emplace_back(pOrphan); }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgdocumenthandler.hxx b/svgio/inc/svgdocumenthandler.hxx
new file mode 100644
index 0000000000..8511a0adfb
--- /dev/null
+++ b/svgio/inc/svgdocumenthandler.hxx
@@ -0,0 +1,64 @@
+/* -*- 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 <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include "svgdocument.hxx"
+#include <cppuhelper/implbase.hxx>
+
+class SvStream;
+namespace svgio::svgreader { class SvgCharacterNode; }
+
+namespace svgio::svgreader
+ {
+ class SvgDocHdl final : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler >
+ {
+ private:
+ // the complete SVG Document
+ SvgDocument maDocument;
+
+ // current node for parsing
+ SvgNode* mpTarget;
+
+ // text collector string stack for css styles
+ std::vector< OUString > maCssContents;
+
+ public:
+ SvgDocHdl(const OUString& rAbsolutePath);
+ virtual ~SvgDocHdl() override;
+
+ // Methods XDocumentHandler
+ virtual void SAL_CALL startDocument( ) override;
+ virtual void SAL_CALL endDocument( ) override;
+ virtual void SAL_CALL startElement( const OUString& aName, const css::uno::Reference< css::xml::sax::XAttributeList >& xAttribs ) override;
+ virtual void SAL_CALL endElement( const OUString& aName ) override;
+ virtual void SAL_CALL characters( const OUString& aChars ) override;
+ virtual void SAL_CALL ignorableWhitespace( const OUString& aWhitespaces ) override;
+ virtual void SAL_CALL processingInstruction( const OUString& aTarget, const OUString& aData ) override;
+ virtual void SAL_CALL setDocumentLocator( const css::uno::Reference< css::xml::sax::XLocator >& xLocator ) override;
+
+ const SvgDocument& getSvgDocument() const { return maDocument; }
+ };
+
+} // end of namespace svgio::svgreader
+
+extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportSVG(SvStream& rStream);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgellipsenode.hxx b/svgio/inc/svgellipsenode.hxx
new file mode 100644
index 0000000000..1aab9bca42
--- /dev/null
+++ b/svgio/inc/svgellipsenode.hxx
@@ -0,0 +1,70 @@
+/* -*- 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 SvgEllipseNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ SvgNumber maCx;
+ SvgNumber maCy;
+ SvgNumber maRx;
+ SvgNumber maRy;
+ std::optional<basegfx::B2DHomMatrix> mpaTransform;
+
+ public:
+ SvgEllipseNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgEllipseNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// Cx content, set if found in current context
+ const SvgNumber& getCx() const { return maCx; }
+
+ /// Cy content, set if found in current context
+ const SvgNumber& getCy() const { return maCy; }
+
+ /// Rx content, set if found in current context
+ const SvgNumber& getRx() const { return maRx; }
+
+ /// Ry content, set if found in current context
+ const SvgNumber& getRy() const { return maRy; }
+
+ /// transform content, set if found in current context
+ const std::optional<basegfx::B2DHomMatrix>& getTransform() const { return mpaTransform; }
+ void setTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaTransform = pMatrix; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgfecolormatrixnode.hxx b/svgio/inc/svgfecolormatrixnode.hxx
new file mode 100644
index 0000000000..e2c74a0374
--- /dev/null
+++ b/svgio/inc/svgfecolormatrixnode.hxx
@@ -0,0 +1,53 @@
+/* -*- 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 "svgfilternode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b3dhommatrix.hxx>
+
+namespace svgio::svgreader
+{
+enum class ColorType
+{
+ HueRotate,
+ Matrix,
+ Saturate,
+ LuminanceToAlpha
+};
+
+class SvgFeColorMatrixNode final : public SvgFilterNode
+{
+private:
+ ColorType maType;
+ OUString maValuesContent;
+
+public:
+ SvgFeColorMatrixNode(SvgDocument& rDocument, SvgNode* pParent);
+ virtual ~SvgFeColorMatrixNode() override;
+
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+
+ void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const override;
+};
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgfedropshadownode.hxx b/svgio/inc/svgfedropshadownode.hxx
new file mode 100644
index 0000000000..04b3190f1d
--- /dev/null
+++ b/svgio/inc/svgfedropshadownode.hxx
@@ -0,0 +1,47 @@
+/* -*- 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 "svgfilternode.hxx"
+#include "svgstyleattributes.hxx"
+
+namespace svgio::svgreader
+{
+class SvgFeDropShadowNode final : public SvgFilterNode
+{
+private:
+ SvgNumber maDx;
+ SvgNumber maDy;
+ SvgNumber maStdDeviation;
+ SvgPaint maFloodColor;
+ SvgNumber maFloodOpacity;
+
+public:
+ SvgFeDropShadowNode(SvgDocument& rDocument, SvgNode* pParent);
+ virtual ~SvgFeDropShadowNode() override;
+
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+
+ void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const override;
+};
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgfefloodnode.hxx b/svgio/inc/svgfefloodnode.hxx
new file mode 100644
index 0000000000..e74794b972
--- /dev/null
+++ b/svgio/inc/svgfefloodnode.hxx
@@ -0,0 +1,48 @@
+/* -*- 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 "svgfilternode.hxx"
+#include "svgstyleattributes.hxx"
+
+namespace svgio::svgreader
+{
+class SvgFeFloodNode final : public SvgFilterNode
+{
+private:
+ SvgNumber maX;
+ SvgNumber maY;
+ SvgNumber maWidth;
+ SvgNumber maHeight;
+ SvgPaint maFloodColor;
+ SvgNumber maFloodOpacity;
+
+public:
+ SvgFeFloodNode(SvgDocument& rDocument, SvgNode* pParent);
+ virtual ~SvgFeFloodNode() override;
+
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+
+ void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const override;
+};
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgfegaussianblurnode.hxx b/svgio/inc/svgfegaussianblurnode.hxx
new file mode 100644
index 0000000000..14732a968e
--- /dev/null
+++ b/svgio/inc/svgfegaussianblurnode.hxx
@@ -0,0 +1,44 @@
+/* -*- 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 "svgfilternode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+
+namespace svgio::svgreader
+{
+class SvgFeGaussianBlurNode final : public SvgFilterNode
+{
+private:
+ SvgNumber maStdDeviation;
+
+public:
+ SvgFeGaussianBlurNode(SvgDocument& rDocument, SvgNode* pParent);
+ virtual ~SvgFeGaussianBlurNode() override;
+
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+
+ void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const override;
+};
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgfeimagenode.hxx b/svgio/inc/svgfeimagenode.hxx
new file mode 100644
index 0000000000..0b05173494
--- /dev/null
+++ b/svgio/inc/svgfeimagenode.hxx
@@ -0,0 +1,44 @@
+/* -*- 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 "svgfilternode.hxx"
+#include "svgstyleattributes.hxx"
+
+namespace svgio::svgreader
+{
+class SvgFeImageNode final : public SvgFilterNode
+{
+private:
+ OUString maUrl; // external link
+ OUString maData; // base64 data
+
+public:
+ SvgFeImageNode(SvgDocument& rDocument, SvgNode* pParent);
+ virtual ~SvgFeImageNode() override;
+
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+
+ void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const override;
+};
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgfeoffsetnode.hxx b/svgio/inc/svgfeoffsetnode.hxx
new file mode 100644
index 0000000000..b56971dfd7
--- /dev/null
+++ b/svgio/inc/svgfeoffsetnode.hxx
@@ -0,0 +1,44 @@
+/* -*- 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 "svgfilternode.hxx"
+#include "svgstyleattributes.hxx"
+
+namespace svgio::svgreader
+{
+class SvgFeOffsetNode final : public SvgFilterNode
+{
+private:
+ SvgNumber maDx;
+ SvgNumber maDy;
+
+public:
+ SvgFeOffsetNode(SvgDocument& rDocument, SvgNode* pParent);
+ virtual ~SvgFeOffsetNode() override;
+
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+
+ void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const override;
+};
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgfilternode.hxx b/svgio/inc/svgfilternode.hxx
new file mode 100644
index 0000000000..0c87ba54b4
--- /dev/null
+++ b/svgio/inc/svgfilternode.hxx
@@ -0,0 +1,39 @@
+/* -*- 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 : public SvgNode
+{
+public:
+ SvgFilterNode(SVGToken aType, SvgDocument& rDocument, SvgNode* pParent);
+ virtual ~SvgFilterNode() override;
+
+ virtual void apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const;
+};
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svggnode.hxx b/svgio/inc/svggnode.hxx
new file mode 100644
index 0000000000..5f1f4f73a2
--- /dev/null
+++ b/svgio/inc/svggnode.hxx
@@ -0,0 +1,55 @@
+/* -*- 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 SvgGNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::optional<basegfx::B2DHomMatrix> mpaTransform;
+
+ public:
+ SvgGNode(
+ SVGToken aType,
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgGNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// transform content
+ const std::optional<basegfx::B2DHomMatrix>& getTransform() const { return mpaTransform; }
+ void setTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaTransform = pMatrix; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svggradientnode.hxx b/svgio/inc/svggradientnode.hxx
new file mode 100644
index 0000000000..6a7f385c00
--- /dev/null
+++ b/svgio/inc/svggradientnode.hxx
@@ -0,0 +1,118 @@
+/* -*- 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 "svgtools.hxx"
+#include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
+
+namespace svgio::svgreader
+ {
+ class SvgGradientNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// linear gradient values
+ SvgNumber maX1;
+ SvgNumber maY1;
+ SvgNumber maX2;
+ SvgNumber maY2;
+
+ /// radial gradient values
+ SvgNumber maCx;
+ SvgNumber maCy;
+ SvgNumber maR;
+ SvgNumber maFx;
+ SvgNumber maFy;
+
+ /// variable scan values, dependent of given XAttributeList
+ SvgUnits maGradientUnits;
+ drawinglayer::primitive2d::SpreadMethod maSpreadMethod;
+ std::optional<basegfx::B2DHomMatrix> mpaGradientTransform;
+
+ /// link to another gradient used as style. If maXLink
+ /// is set, the node can be fetched on demand by using
+ // tryToFindLink (buffered)
+ mutable bool mbResolvingLink; // protect against infinite link recursion
+ OUString maXLink;
+ const SvgGradientNode* mpXLink;
+
+ /// link on demand
+ void tryToFindLink();
+
+ public:
+ SvgGradientNode(
+ SVGToken aType,
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgGradientNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+
+ /// collect gradient stop entries
+ void collectGradientEntries(drawinglayer::primitive2d::SvgGradientEntryVector& aVector) const;
+
+ /// x1 content
+ SvgNumber getX1() const;
+
+ /// y1 content
+ SvgNumber getY1() const;
+
+ /// x2 content
+ SvgNumber getX2() const;
+
+ /// y2 content
+ SvgNumber getY2() const;
+
+ /// Cx content
+ SvgNumber getCx() const;
+
+ /// Cy content
+ SvgNumber getCy() const;
+
+ /// R content
+ SvgNumber getR() const;
+
+ /// Fx content
+ const SvgNumber* getFx() const;
+
+ /// Fy content
+ const SvgNumber* getFy() const;
+
+ /// gradientUnits content
+ SvgUnits getGradientUnits() const { return maGradientUnits; }
+ void setGradientUnits(const SvgUnits aGradientUnits) { maGradientUnits = aGradientUnits; }
+
+ /// SpreadMethod content
+ drawinglayer::primitive2d::SpreadMethod getSpreadMethod() const { return maSpreadMethod; }
+ void setSpreadMethod(const drawinglayer::primitive2d::SpreadMethod aSpreadMethod) { maSpreadMethod = aSpreadMethod; }
+
+ /// transform content, set if found in current context
+ std::optional<basegfx::B2DHomMatrix> getGradientTransform() const;
+ void setGradientTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaGradientTransform = pMatrix; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svggradientstopnode.hxx b/svgio/inc/svggradientstopnode.hxx
new file mode 100644
index 0000000000..7b2b5e445a
--- /dev/null
+++ b/svgio/inc/svggradientstopnode.hxx
@@ -0,0 +1,51 @@
+/* -*- 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"
+
+namespace svgio::svgreader
+ {
+ class SvgGradientStopNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// local attributes
+ SvgNumber maOffset;
+
+ public:
+ SvgGradientStopNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgGradientStopNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+
+ /// offset content
+ const SvgNumber& getOffset() const { return maOffset; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgimagenode.hxx b/svgio/inc/svgimagenode.hxx
new file mode 100644
index 0000000000..fa53c2e9cf
--- /dev/null
+++ b/svgio/inc/svgimagenode.hxx
@@ -0,0 +1,77 @@
+/* -*- 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 SvgImageNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ SvgAspectRatio maSvgAspectRatio;
+ std::optional<basegfx::B2DHomMatrix>
+ mpaTransform;
+ SvgNumber maX;
+ SvgNumber maY;
+ SvgNumber maWidth;
+ SvgNumber maHeight;
+
+ OUString maXLink; // internal link
+ OUString maUrl; // external link
+
+ OUString maData; // base64 data
+
+ public:
+ SvgImageNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgImageNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// transform content, set if found in current context
+ const std::optional<basegfx::B2DHomMatrix>& getTransform() const { return mpaTransform; }
+ void setTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaTransform = pMatrix; }
+
+ /// x content, set if found in current context
+ const SvgNumber& getX() const { return maX; }
+
+ /// y content, set if found in current context
+ const SvgNumber& getY() const { return maY; }
+
+ /// width content, set if found in current context
+ const SvgNumber& getWidth() const { return maWidth; }
+
+ /// height content, set if found in current context
+ const SvgNumber& getHeight() const { return maHeight; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svglinenode.hxx b/svgio/inc/svglinenode.hxx
new file mode 100644
index 0000000000..bce06101fe
--- /dev/null
+++ b/svgio/inc/svglinenode.hxx
@@ -0,0 +1,70 @@
+/* -*- 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 SvgLineNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ SvgNumber maX1;
+ SvgNumber maY1;
+ SvgNumber maX2;
+ SvgNumber maY2;
+ std::optional<basegfx::B2DHomMatrix> mpaTransform;
+
+ public:
+ SvgLineNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgLineNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// X1 content, set if found in current context
+ const SvgNumber& getX1() const { return maX1; }
+
+ /// Y1 content, set if found in current context
+ const SvgNumber& getY1() const { return maY1; }
+
+ /// X2 content, set if found in current context
+ const SvgNumber& getX2() const { return maX2; }
+
+ /// Y2 content, set if found in current context
+ const SvgNumber& getY2() const { return maY2; }
+
+ /// transform content, set if found in current context
+ const std::optional<basegfx::B2DHomMatrix>& getTransform() const { return mpaTransform; }
+ void setTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaTransform = pMatrix; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgmarkernode.hxx b/svgio/inc/svgmarkernode.hxx
new file mode 100644
index 0000000000..b8fa7c000e
--- /dev/null
+++ b/svgio/inc/svgmarkernode.hxx
@@ -0,0 +1,113 @@
+/* -*- 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 <memory>
+
+namespace svgio::svgreader
+ {
+ class SvgMarkerNode final : public SvgNode
+ {
+ public:
+ enum class MarkerUnits
+ {
+ strokeWidth,
+ userSpaceOnUse
+ };
+
+ enum class MarkerOrient
+ {
+ notset,
+ auto_start,
+ auto_start_reverse
+ };
+
+ private:
+ /// buffered decomposition
+ drawinglayer::primitive2d::Primitive2DContainer aPrimitives;
+
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::unique_ptr<basegfx::B2DRange>
+ mpViewBox;
+ SvgAspectRatio maSvgAspectRatio;
+ SvgNumber maRefX;
+ SvgNumber maRefY;
+ MarkerUnits maMarkerUnits;
+ SvgNumber maMarkerWidth;
+ SvgNumber maMarkerHeight;
+ double mfAngle;
+ MarkerOrient maMarkerOrient;
+
+ public:
+ SvgMarkerNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgMarkerNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+
+ /// get marker primitives buffered, uses decomposeSvgNode internally
+ const drawinglayer::primitive2d::Primitive2DContainer& getMarkerPrimitives() const;
+
+ /// InfoProvider support for % values
+ virtual basegfx::B2DRange getCurrentViewPort() const override;
+
+ /// viewBox content
+ const basegfx::B2DRange* getViewBox() const { return mpViewBox.get(); }
+ void setViewBox(const basegfx::B2DRange* pViewBox) { mpViewBox.reset(); if(pViewBox) mpViewBox.reset( new basegfx::B2DRange(*pViewBox) ); }
+
+ /// SvgAspectRatio content
+ const SvgAspectRatio& getSvgAspectRatio() const { return maSvgAspectRatio; }
+
+ /// RefX content, set if found in current context
+ const SvgNumber& getRefX() const { return maRefX; }
+
+ /// RefY content, set if found in current context
+ const SvgNumber& getRefY() const { return maRefY; }
+
+ /// MarkerUnits content
+ MarkerUnits getMarkerUnits() const { return maMarkerUnits; }
+ void setMarkerUnits(const MarkerUnits aMarkerUnits) { maMarkerUnits = aMarkerUnits; }
+
+ /// MarkerWidth content, set if found in current context
+ const SvgNumber& getMarkerWidth() const { return maMarkerWidth; }
+
+ /// MarkerHeight content, set if found in current context
+ const SvgNumber& getMarkerHeight() const { return maMarkerHeight; }
+
+ /// Angle content, set if found in current context
+ double getAngle() const { return mfAngle; }
+ void setAngle(double fAngle) { mfAngle = fAngle;}
+
+ /// MarkerOrient content
+ MarkerOrient getMarkerOrient() const { return maMarkerOrient; }
+ void setMarkerOrient(const MarkerOrient aMarkerOrient) { maMarkerOrient = aMarkerOrient; }
+
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgmasknode.hxx b/svgio/inc/svgmasknode.hxx
new file mode 100644
index 0000000000..386ab9229a
--- /dev/null
+++ b/svgio/inc/svgmasknode.hxx
@@ -0,0 +1,84 @@
+/* -*- 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 SvgMaskNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ SvgNumber maX;
+ SvgNumber maY;
+ SvgNumber maWidth;
+ SvgNumber maHeight;
+ std::optional<basegfx::B2DHomMatrix>
+ mpaTransform;
+ SvgUnits maMaskUnits;
+ SvgUnits maMaskContentUnits;
+
+ public:
+ SvgMaskNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgMaskNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// apply contained clipPath to given geometry #i124852# transform may be needed
+ void apply(
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ const std::optional<basegfx::B2DHomMatrix>& pTransform) const;
+
+ /// x content, set if found in current context
+ const SvgNumber& getX() const { return maX; }
+
+ /// y content, set if found in current context
+ const SvgNumber& getY() const { return maY; }
+
+ /// width content, set if found in current context
+ const SvgNumber& getWidth() const { return maWidth; }
+
+ /// height content, set if found in current context
+ const SvgNumber& getHeight() const { return maHeight; }
+
+ /// transform content
+ const std::optional<basegfx::B2DHomMatrix>& getTransform() const { return mpaTransform; }
+ void setTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaTransform = pMatrix; }
+
+ /// MaskUnits content
+ void setMaskUnits(const SvgUnits aMaskUnits) { maMaskUnits = aMaskUnits; }
+
+ /// MaskContentUnits content
+ void setMaskContentUnits(const SvgUnits aMaskContentUnits) { maMaskContentUnits = aMaskContentUnits; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgnode.hxx b/svgio/inc/svgnode.hxx
new file mode 100644
index 0000000000..63abc4f8cb
--- /dev/null
+++ b/svgio/inc/svgnode.hxx
@@ -0,0 +1,201 @@
+/* -*- 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 "SvgNumber.hxx"
+#include "svgtoken.hxx"
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
+#include <memory>
+#include <string_view>
+#include <vector>
+#include <optional>
+
+// predefines
+namespace svgio::svgreader
+{
+ class SvgNode;
+ class SvgDocument;
+ class SvgStyleAttributes;
+}
+
+
+
+namespace svgio::svgreader
+ {
+ enum class XmlSpace
+ {
+ NotSet,
+ Default,
+ Preserve
+ };
+
+ // display property (see SVG 1.1. 11.5), not inheritable
+ enum class Display // #i121656#
+ {
+ Inline, // the default
+ Block,
+ ListItem,
+ RunIn,
+ Compact,
+ Marker,
+ Table,
+ InlineTable,
+ TableRowGroup,
+ TableHeaderGroup,
+ TableFooterGroup,
+ TableRow,
+ TableColumnGroup,
+ TableColumn,
+ TableCell,
+ TableCaption,
+ None,
+ Inherit
+ };
+
+ // helper to convert a string associated with a token of type SVGTokenDisplay
+ // to the enum Display. Empty strings return the default 'Display_inline' with
+ // which members should be initialized
+ Display getDisplayFromContent(std::u16string_view aContent);
+
+ class Visitor;
+
+ class SvgNode : public InfoProvider
+ {
+ private:
+ /// basic data, Type, document we belong to and parent (if not root)
+ SVGToken maType;
+ SvgDocument& mrDocument;
+ const SvgNode* mpParent;
+ const SvgNode* mpAlternativeParent;
+
+ /// sub hierarchy
+ std::vector< std::unique_ptr<SvgNode> > maChildren;
+
+ /// Id svan value
+ std::optional<OUString> mpId;
+
+ /// Class svan value
+ std::optional<OUString> mpClass;
+
+ /// XmlSpace value
+ XmlSpace maXmlSpace;
+
+ /// Display value #i121656#
+ Display maDisplay;
+
+ // CSS style vector chain, used in decompose phase and built up once per node.
+ // It contains the StyleHierarchy for the local node. Independent from the
+ // node hierarchy itself which also needs to be used in style entry solving
+ ::std::vector< const SvgStyleAttributes* > maCssStyleVector;
+
+ /// possible local CssStyle, e.g. style="fill:red; stroke:red;"
+ std::unique_ptr<SvgStyleAttributes> mpLocalCssStyle;
+
+ mutable bool mbDecomposing;
+
+ // flag if maCssStyleVector is already computed (done only once)
+ bool mbCssStyleVectorBuilt : 1;
+
+ protected:
+ /// helper to evtl. link to css style
+ const SvgStyleAttributes* checkForCssStyle(const SvgStyleAttributes& rOriginal) const;
+
+ /// helper for filling the CssStyle vector once dependent on mbCssStyleVectorBuilt
+ void fillCssStyleVector(const SvgStyleAttributes& rOriginal);
+ void addCssStyle(
+ const SvgDocument& rDocument,
+ const OUString& aConcatenated);
+ void fillCssStyleVectorUsingHierarchyAndSelectors(
+ const SvgNode& rCurrent,
+ std::u16string_view aConcatenated);
+ void fillCssStyleVectorUsingParent(
+ const SvgNode& rCurrent);
+
+ public:
+ SvgNode(
+ SVGToken aType,
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgNode() override;
+ SvgNode(const SvgNode&) = delete;
+ SvgNode& operator=(const SvgNode&) = delete;
+
+ void accept(Visitor& rVisitor);
+
+ /// scan helper to read and interpret a local CssStyle to mpLocalCssStyle
+ void readLocalCssStyle(std::u16string_view aContent);
+
+ /// style helpers
+ void parseAttributes(const css::uno::Reference< css::xml::sax::XAttributeList >& xAttribs);
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent);
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const;
+
+ /// #i125258# tell if this node is allowed to have a parent style (e.g. defs do not)
+ virtual bool supportsParentStyle() const;
+
+ /// basic data read access
+ SVGToken getType() const { return maType; }
+ const SvgDocument& getDocument() const { return mrDocument; }
+ const SvgNode* getParent() const { if(mpAlternativeParent) return mpAlternativeParent; return mpParent; }
+ const std::vector< std::unique_ptr<SvgNode> > & getChildren() const { return maChildren; }
+
+ /// InfoProvider support for %, em and ex values
+ virtual basegfx::B2DRange getCurrentViewPort() const override;
+ virtual double getCurrentFontSizeInherited() const override;
+ virtual double getCurrentXHeightInherited() const override;
+
+ double getCurrentFontSize() const;
+ double getCurrentXHeight() const;
+
+ /// Id access
+ std::optional<OUString> const & getId() const { return mpId; }
+ void setId(OUString const &);
+
+ /// Class access
+ std::optional<OUString> const & getClass() const { return mpClass; }
+ void setClass(OUString const &);
+
+ /// XmlSpace access
+ XmlSpace getXmlSpace() const;
+ void setXmlSpace(XmlSpace eXmlSpace) { maXmlSpace = eXmlSpace; }
+
+ /// Display access #i121656#
+ Display getDisplay() const { return maDisplay; }
+ void setDisplay(Display eDisplay) { maDisplay = eDisplay; }
+
+ /// alternative parent
+ void setAlternativeParent(const SvgNode* pAlternativeParent = nullptr) { mpAlternativeParent = pAlternativeParent; }
+
+ /// Check if there is a local css style
+ bool hasLocalCssStyle() { return static_cast<bool>(mpLocalCssStyle); }
+ };
+
+ class Visitor
+ {
+ public:
+ virtual ~Visitor() = default;
+ virtual void visit(SvgNode const & pNode) = 0;
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgpaint.hxx b/svgio/inc/svgpaint.hxx
new file mode 100644
index 0000000000..ad1c232dfb
--- /dev/null
+++ b/svgio/inc/svgpaint.hxx
@@ -0,0 +1,52 @@
+/* -*- 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 <basegfx/color/bcolor.hxx>
+
+namespace svgio::svgreader
+ {
+ class SvgPaint
+ {
+ private:
+ basegfx::BColor maColor;
+
+ bool mbSet : 1;
+ bool mbOn : 1;
+ bool mbCurrent : 1;
+
+ public:
+ SvgPaint(const basegfx::BColor& rColor = basegfx::BColor(0.0, 0.0, 0.0), bool bSet = false, bool bOn = false, bool bCurrent = false)
+ : maColor(rColor),
+ mbSet(bSet),
+ mbOn(bOn),
+ mbCurrent(bCurrent)
+ {
+ }
+
+ const basegfx::BColor& getBColor() const { return maColor; }
+ bool isSet() const { return mbSet; }
+ bool isOn() const { return mbOn; }
+ bool isCurrent() const { return mbCurrent; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgpathnode.hxx b/svgio/inc/svgpathnode.hxx
new file mode 100644
index 0000000000..5f71c51cd0
--- /dev/null
+++ b/svgio/inc/svgpathnode.hxx
@@ -0,0 +1,67 @@
+/* -*- 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>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <optional>
+
+namespace svgio::svgreader
+ {
+ class SvgPathNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::optional<basegfx::B2DPolyPolygon> mpPolyPolygon;
+ std::optional<basegfx::B2DHomMatrix> mpaTransform;
+ SvgNumber maPathLength;
+ basegfx::utils::PointIndexSet maHelpPointIndices;
+
+ public:
+ SvgPathNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgPathNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// path content, set if found in current context
+ const std::optional<basegfx::B2DPolyPolygon>& getPath() const { return mpPolyPolygon; }
+ void setPath(const std::optional<basegfx::B2DPolyPolygon>& pPath) { mpPolyPolygon = pPath; }
+
+ /// transform content, set if found in current context
+ const std::optional<basegfx::B2DHomMatrix>& getTransform() const { return mpaTransform; }
+ void setTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaTransform = pMatrix; }
+
+ /// PathLength content
+ const SvgNumber& getPathLength() const { return maPathLength; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgpatternnode.hxx b/svgio/inc/svgpatternnode.hxx
new file mode 100644
index 0000000000..7588604080
--- /dev/null
+++ b/svgio/inc/svgpatternnode.hxx
@@ -0,0 +1,116 @@
+/* -*- 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>
+#include <memory>
+
+namespace svgio::svgreader
+ {
+ class SvgPatternNode final : public SvgNode
+ {
+ private:
+ /// buffered decomposition
+ drawinglayer::primitive2d::Primitive2DContainer aPrimitives;
+
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::unique_ptr<basegfx::B2DRange>
+ mpViewBox;
+ SvgAspectRatio maSvgAspectRatio;
+ SvgNumber maX;
+ SvgNumber maY;
+ SvgNumber maWidth;
+ SvgNumber maHeight;
+ std::optional<SvgUnits>
+ moPatternUnits;
+ std::optional<SvgUnits>
+ moPatternContentUnits;
+ std::optional<basegfx::B2DHomMatrix>
+ mpaPatternTransform;
+
+ /// link to another pattern used as style. If maXLink
+ /// is set, the node can be fetched on demand by using
+ // tryToFindLink (buffered)
+ mutable bool mbResolvingLink; // protect against infinite link recursion
+ OUString maXLink;
+ const SvgPatternNode* mpXLink;
+
+ /// link on demand
+ void tryToFindLink();
+
+ public:
+ SvgPatternNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgPatternNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+
+ /// global helpers
+ void getValuesRelative(double& rfX, double& rfY, double& rfW, double& rfH, const basegfx::B2DRange& rGeoRange, SvgNode const & rUser) const;
+
+ /// get pattern primitives buffered, uses decomposeSvgNode internally
+ const drawinglayer::primitive2d::Primitive2DContainer& getPatternPrimitives() const;
+
+ /// InfoProvider support for % values
+ virtual basegfx::B2DRange getCurrentViewPort() const override;
+
+ /// viewBox content
+ const basegfx::B2DRange* getViewBox() const;
+ void setViewBox(const basegfx::B2DRange* pViewBox) { mpViewBox.reset(); if(pViewBox) mpViewBox.reset(new basegfx::B2DRange(*pViewBox)); }
+
+ /// SvgAspectRatio content
+ const SvgAspectRatio& getSvgAspectRatio() const;
+
+ /// X content, set if found in current context
+ const SvgNumber& getX() const;
+
+ /// Y content, set if found in current context
+ const SvgNumber& getY() const;
+
+ /// Width content, set if found in current context
+ const SvgNumber& getWidth() const;
+
+ /// Height content, set if found in current context
+ const SvgNumber& getHeight() const;
+
+ /// PatternUnits content
+ const SvgUnits* getPatternUnits() const;
+ void setPatternUnits(const SvgUnits aPatternUnits) { moPatternUnits = aPatternUnits; }
+
+ /// PatternContentUnits content
+ const SvgUnits* getPatternContentUnits() const;
+ void setPatternContentUnits(const SvgUnits aPatternContentUnits) { moPatternContentUnits = aPatternContentUnits; }
+
+ /// PatternTransform content
+ std::optional<basegfx::B2DHomMatrix> getPatternTransform() const;
+ void setPatternTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaPatternTransform = pMatrix; }
+
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgpolynode.hxx b/svgio/inc/svgpolynode.hxx
new file mode 100644
index 0000000000..f692d2a1de
--- /dev/null
+++ b/svgio/inc/svgpolynode.hxx
@@ -0,0 +1,61 @@
+/* -*- 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>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <optional>
+
+namespace svgio::svgreader
+ {
+ class SvgPolyNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::optional<basegfx::B2DPolygon> mpPolygon;
+ std::optional<basegfx::B2DHomMatrix> mpaTransform;
+
+ public:
+ SvgPolyNode(
+ SVGToken aType,
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgPolyNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// Polygon content, set if found in current context
+ void setPolygon(const std::optional<basegfx::B2DPolygon>& pPolygon) { mpPolygon = pPolygon; }
+
+ /// transform content, set if found in current context
+ const std::optional<basegfx::B2DHomMatrix>& getTransform() const { return mpaTransform; }
+ void setTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaTransform = pMatrix; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgrectnode.hxx b/svgio/inc/svgrectnode.hxx
new file mode 100644
index 0000000000..161d11eb40
--- /dev/null
+++ b/svgio/inc/svgrectnode.hxx
@@ -0,0 +1,78 @@
+/* -*- 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 SvgRectNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ SvgNumber maX;
+ SvgNumber maY;
+ SvgNumber maWidth;
+ SvgNumber maHeight;
+ SvgNumber maRx;
+ SvgNumber maRy;
+ std::optional<basegfx::B2DHomMatrix> mpaTransform;
+
+ public:
+ SvgRectNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgRectNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// x content, set if found in current context
+ const SvgNumber& getX() const { return maX; }
+
+ /// y content, set if found in current context
+ const SvgNumber& getY() const { return maY; }
+
+ /// width content, set if found in current context
+ const SvgNumber& getWidth() const { return maWidth; }
+
+ /// height content, set if found in current context
+ const SvgNumber& getHeight() const { return maHeight; }
+
+ /// Rx content, set if found in current context
+ const SvgNumber& getRx() const { return maRx; }
+
+ /// Ry content, set if found in current context
+ const SvgNumber& getRy() const { return maRy; }
+
+ /// transform content, set if found in current context
+ const std::optional<basegfx::B2DHomMatrix>& getTransform() const { return mpaTransform; }
+ void setTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaTransform = pMatrix; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgstyleattributes.hxx b/svgio/inc/svgstyleattributes.hxx
new file mode 100644
index 0000000000..6078194266
--- /dev/null
+++ b/svgio/inc/svgstyleattributes.hxx
@@ -0,0 +1,458 @@
+/* -*- 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 "svgpaint.hxx"
+#include "svgnode.hxx"
+#include "svgtools.hxx"
+#include <tools/fontenum.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
+
+
+// predefines
+
+namespace svgio::svgreader {
+ class SvgGradientNode;
+ class SvgPatternNode;
+ class SvgMarkerNode;
+ class SvgClipPathNode;
+ class SvgFilterNode;
+ class SvgMaskNode;
+}
+
+
+namespace svgio::svgreader
+ {
+ enum class StrokeLinecap
+ {
+ notset,
+ butt,
+ round,
+ square
+ };
+
+ enum class StrokeLinejoin
+ {
+ notset,
+ miter,
+ round,
+ bevel
+ };
+
+ enum class FontSize
+ {
+ notset,
+ xx_small,
+ x_small,
+ small,
+ smaller,
+ medium,
+ large,
+ larger,
+ x_large,
+ xx_large,
+ initial
+ };
+
+ enum class FontStretch
+ {
+ notset,
+ normal,
+ wider,
+ narrower,
+ ultra_condensed,
+ extra_condensed,
+ condensed,
+ semi_condensed,
+ semi_expanded,
+ expanded,
+ extra_expanded,
+ ultra_expanded
+ };
+
+ FontStretch getWider(FontStretch aSource);
+ FontStretch getNarrower(FontStretch aSource);
+
+ enum class FontStyle
+ {
+ notset,
+ normal,
+ italic,
+ oblique
+ };
+
+ enum class FontWeight
+ {
+ notset,
+ N100,
+ N200,
+ N300,
+ N400, // same as normal
+ N500,
+ N600,
+ N700, // same as bold
+ N800,
+ N900,
+ bolder,
+ lighter,
+ };
+
+ FontWeight getBolder(FontWeight aSource);
+ FontWeight getLighter(FontWeight aSource);
+ ::FontWeight getVclFontWeight(FontWeight aSource);
+
+ enum class TextAlign
+ {
+ notset,
+ left,
+ right,
+ center,
+ justify
+ };
+
+ enum class TextDecoration
+ {
+ notset,
+ none,
+ underline,
+ overline,
+ line_through,
+ blink
+ };
+
+ enum class TextAnchor
+ {
+ notset,
+ start,
+ middle,
+ end
+ };
+
+ enum class FillRule
+ {
+ notset,
+ nonzero,
+ evenodd
+ };
+
+ enum class BaselineShift
+ {
+ Baseline,
+ Sub,
+ Super,
+ Percentage,
+ Length
+ };
+
+ enum class DominantBaseline
+ {
+ Auto,
+ Middle,
+ Hanging
+ };
+
+ enum class Visibility
+ {
+ notset,
+ visible,
+ hidden,
+ collapse,
+ inherit
+ };
+
+ class SvgStyleAttributes
+ {
+ private:
+ SvgNode& mrOwner;
+ const SvgStyleAttributes* mpCssStyleParent;
+ SvgPaint maFill;
+ SvgPaint maStroke;
+ SvgPaint maStopColor;
+ SvgNumber maStrokeWidth;
+ SvgNumber maStopOpacity;
+ SvgNumber maFillOpacity;
+ SvgNumberVector maStrokeDasharray;
+ SvgNumber maStrokeDashOffset;
+ StrokeLinecap maStrokeLinecap;
+ StrokeLinejoin maStrokeLinejoin;
+ SvgNumber maStrokeMiterLimit;
+ SvgNumber maStrokeOpacity;
+ SvgStringVector maFontFamily;
+ FontSize maFontSize;
+ SvgNumber maFontSizeNumber;
+ FontStretch maFontStretch;
+ FontStyle maFontStyle;
+ FontWeight maFontWeight;
+ TextAlign maTextAlign;
+ TextDecoration maTextDecoration;
+ TextAnchor maTextAnchor;
+ SvgPaint maColor;
+ SvgNumber maOpacity;
+ Visibility maVisibility;
+ OUString maTitle;
+ OUString maDesc;
+
+ /// link to content. If set, the node can be fetched on demand
+ OUString maClipPathXLink;
+ OUString maFilterXLink;
+ OUString maMaskXLink;
+
+ /// link to markers. If set, the node can be fetched on demand
+ OUString maMarkerStartXLink;
+ OUString maMarkerMidXLink;
+ OUString maMarkerEndXLink;
+
+ /// fill rule
+ FillRule maFillRule;
+
+ // ClipRule setting (only valid when mbIsClipPathContent == true, default is FillRule_nonzero)
+ FillRule maClipRule;
+
+ // BaselineShift: Type and number (in case of BaselineShift_Percentage or BaselineShift_Length)
+ BaselineShift maBaselineShift;
+ SvgNumber maBaselineShiftNumber;
+
+ DominantBaseline maDominantBaseline;
+
+ mutable std::vector<sal_uInt16> maResolvingParent;
+
+ // defines if this attributes are part of a ClipPath. If yes,
+ // rough geometry will be created on decomposition by patching
+ // values for fill, stroke, strokeWidth and others
+ bool mbIsClipPathContent : 1;
+
+ // #121221# Defines if evtl. an empty array *is* set
+ bool mbStrokeDasharraySet : 1;
+
+ // tdf#94765 Check id references in gradient/pattern getters
+ OUString maNodeFillURL;
+ OUString maNodeStrokeURL;
+
+ /// internal helpers
+ void add_fillGradient(
+ const basegfx::B2DPolyPolygon& rPath,
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ const SvgGradientNode& rFillGradient,
+ const basegfx::B2DRange& rGeoRange) const;
+ void add_fillPatternTransform(
+ const basegfx::B2DPolyPolygon& rPath,
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ const SvgPatternNode& rFillGradient,
+ const basegfx::B2DRange& rGeoRange) const;
+ void add_fillPattern(
+ const basegfx::B2DPolyPolygon& rPath,
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ const SvgPatternNode& rFillGradient,
+ const basegfx::B2DRange& rGeoRange) const;
+ void add_fill(
+ const basegfx::B2DPolyPolygon& rPath,
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ const basegfx::B2DRange& rGeoRange) const;
+ void add_stroke(
+ const basegfx::B2DPolyPolygon& rPath,
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ const basegfx::B2DRange& rGeoRange) const;
+ bool prepare_singleMarker(
+ drawinglayer::primitive2d::Primitive2DContainer& rMarkerPrimitives,
+ basegfx::B2DHomMatrix& rMarkerTransform,
+ basegfx::B2DRange& rClipRange,
+ const SvgMarkerNode& rMarker) const;
+ void add_markers(
+ const basegfx::B2DPolyPolygon& rPath,
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ const basegfx::utils::PointIndexSet* pHelpPointIndices) const;
+
+
+ public:
+ /// local attribute scanner
+ void parseStyleAttribute(SVGToken aSVGToken, const OUString& rContent);
+
+ /// helper which does the necessary with a given path
+ void add_text(
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ drawinglayer::primitive2d::Primitive2DContainer&& rSource) const;
+ void add_path(
+ const basegfx::B2DPolyPolygon& rPath,
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ const basegfx::utils::PointIndexSet* pHelpPointIndices) const;
+ void add_postProcess(
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ drawinglayer::primitive2d::Primitive2DContainer&& rSource,
+ const std::optional<basegfx::B2DHomMatrix>& pTransform) const;
+
+ /// helper to set mpCssStyleParent temporarily for CSS style hierarchies
+ void setCssStyleParent(const SvgStyleAttributes* pNew) { mpCssStyleParent = pNew; }
+ const SvgStyleAttributes* getCssStyleParent() const { return mpCssStyleParent; }
+
+ /// scan helpers
+ void readCssStyle(std::u16string_view rCandidate);
+ const SvgStyleAttributes* getParentStyle() const;
+
+ SvgStyleAttributes(SvgNode& rOwner);
+ ~SvgStyleAttributes();
+
+ /// fill content
+ bool isFillSet() const; // #i125258# ask if fill is a direct hard attribute (no hierarchy)
+ const basegfx::BColor* getFill() const;
+ void setFill(const SvgPaint& rFill) { maFill = rFill; }
+
+ /// stroke content
+ const basegfx::BColor* getStroke() const;
+
+ /// stop color content
+ const basegfx::BColor& getStopColor() const;
+
+ /// stroke-width content
+ SvgNumber getStrokeWidth() const;
+
+ /// stop opacity content
+ SvgNumber getStopOpacity() const;
+
+ /// access to evtl. set fill gradient
+ const SvgGradientNode* getSvgGradientNodeFill() const;
+
+ /// access to evtl. set fill pattern
+ const SvgPatternNode* getSvgPatternNodeFill() const;
+
+ /// access to evtl. set stroke gradient
+ const SvgGradientNode* getSvgGradientNodeStroke() const;
+
+ /// access to evtl. set stroke pattern
+ const SvgPatternNode* getSvgPatternNodeStroke() const;
+
+ /// fill opacity content
+ SvgNumber getFillOpacity() const;
+
+ /// fill rule content
+ FillRule getFillRule() const;
+
+ /// clip rule content
+ FillRule getClipRule() const;
+
+ /// fill StrokeDasharray content
+ const SvgNumberVector& getStrokeDasharray() const;
+
+ /// StrokeDashOffset content
+ SvgNumber getStrokeDashOffset() const;
+
+ /// StrokeLinecap content
+ StrokeLinecap getStrokeLinecap() const;
+ void setStrokeLinecap(const StrokeLinecap aStrokeLinecap) { maStrokeLinecap = aStrokeLinecap; }
+
+ /// StrokeLinejoin content
+ StrokeLinejoin getStrokeLinejoin() const;
+ void setStrokeLinejoin(const StrokeLinejoin aStrokeLinejoin) { maStrokeLinejoin = aStrokeLinejoin; }
+
+ /// StrokeMiterLimit content
+ SvgNumber getStrokeMiterLimit() const;
+
+ /// StrokeOpacity content
+ SvgNumber getStrokeOpacity() const;
+
+ /// Font content
+ const SvgStringVector& getFontFamily() const;
+
+ /// FontSize content
+ void setFontSize(const FontSize aFontSize) { maFontSize = aFontSize; }
+ SvgNumber getFontSizeNumber() const;
+
+ /// FontStretch content
+ FontStretch getFontStretch() const;
+ void setFontStretch(const FontStretch aFontStretch) { maFontStretch = aFontStretch; }
+
+ /// FontStyle content
+ FontStyle getFontStyle() const;
+ void setFontStyle(const FontStyle aFontStyle) { maFontStyle = aFontStyle; }
+
+ /// FontWeight content
+ FontWeight getFontWeight() const;
+ void setFontWeight(const FontWeight aFontWeight) { maFontWeight = aFontWeight; }
+
+ /// TextAlign content
+ TextAlign getTextAlign() const;
+ void setTextAlign(const TextAlign aTextAlign) { maTextAlign = aTextAlign; }
+
+ /// TextDecoration content
+ const SvgStyleAttributes* getTextDecorationDefiningSvgStyleAttributes() const;
+ TextDecoration getTextDecoration() const;
+ void setTextDecoration(const TextDecoration aTextDecoration) { maTextDecoration = aTextDecoration; }
+
+ /// TextAnchor content
+ TextAnchor getTextAnchor() const;
+ void setTextAnchor(const TextAnchor aTextAnchor) { maTextAnchor = aTextAnchor; }
+
+ /// Color content
+ const basegfx::BColor* getColor() const;
+
+ /// Resolve current color (defaults to black if no color is specified)
+ const basegfx::BColor* getCurrentColor() const;
+
+ /// Opacity content
+ SvgNumber getOpacity() const;
+ void setOpacity(const SvgNumber& rOpacity) { maOpacity = rOpacity; }
+
+ /// Visibility
+ Visibility getVisibility() const;
+ void setVisibility(const Visibility aVisibility) { maVisibility = aVisibility; }
+
+ // Title content
+ const OUString& getTitle() const { return maTitle; }
+
+ // Desc content
+ const OUString& getDesc() const { return maDesc; }
+
+ // ClipPathXLink content
+ 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;
+
+ // MarkerStartXLink content
+ OUString getMarkerStartXLink() const;
+ const SvgMarkerNode* accessMarkerStartXLink() const;
+
+ // MarkerMidXLink content
+ OUString getMarkerMidXLink() const;
+ const SvgMarkerNode* accessMarkerMidXLink() const;
+
+ // MarkerEndXLink content
+ OUString getMarkerEndXLink() const;
+ const SvgMarkerNode* accessMarkerEndXLink() const;
+
+ // BaselineShift
+ void setBaselineShift(const BaselineShift aBaselineShift) { maBaselineShift = aBaselineShift; }
+ BaselineShift getBaselineShift() const;
+ SvgNumber getBaselineShiftNumber() const;
+
+ // DominantBaseline
+ void setDominantBaseline(const DominantBaseline aDominantBaseline) { maDominantBaseline = aDominantBaseline; }
+ DominantBaseline getDominantBaseline() const;
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgstylenode.hxx b/svgio/inc/svgstylenode.hxx
new file mode 100644
index 0000000000..cb8768e965
--- /dev/null
+++ b/svgio/inc/svgstylenode.hxx
@@ -0,0 +1,58 @@
+/* -*- 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 <unordered_map>
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+
+namespace svgio::svgreader
+ {
+ class SvgStyleNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ std::unordered_map< OUString, std::unique_ptr<SvgStyleAttributes> > maSvgStyleAttributes;
+
+ bool mbTextCss : 1; // true == type is 'text/css'
+
+ public:
+ SvgStyleNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+
+ /// #i125258# tell if this node is allowed to have a parent style (e.g. defs do not)
+ virtual bool supportsParentStyle() const override;
+
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+
+ /// CssStyleSheet add helpers
+ void addCssStyleSheet(std::u16string_view aSelectors, const SvgStyleAttributes& rNewStyle);
+ void addCssStyleSheet(std::u16string_view aSelectors, std::u16string_view aContent);
+ void addCssStyleSheet(std::u16string_view aSelectorsAndContent);
+
+ /// textCss access
+ bool isTextCss() const { return mbTextCss; }
+ void setTextCss(bool bNew) { mbTextCss = bNew; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgsvgnode.hxx b/svgio/inc/svgsvgnode.hxx
new file mode 100644
index 0000000000..4d0b40d89e
--- /dev/null
+++ b/svgio/inc/svgsvgnode.hxx
@@ -0,0 +1,93 @@
+/* -*- 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 "svgstyleattributes.hxx"
+#include <memory>
+
+namespace svgio::svgreader
+ {
+ class SvgSvgNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::unique_ptr<basegfx::B2DRange>
+ mpViewBox;
+ SvgAspectRatio maSvgAspectRatio;
+ SvgNumber maX;
+ SvgNumber maY;
+ SvgNumber maWidth;
+ SvgNumber maHeight;
+ SvgNumber maVersion;
+
+ /// #i125258# bitfield
+ bool mbStyleAttributesInitialized : 1;
+
+ // #i125258# on-demand init hard attributes when this is the outmost svg element
+ // and more (see implementation)
+ void initializeStyleAttributes();
+
+ public:
+ SvgSvgNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgSvgNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// Seeks width and height of viewport, which is current before the new viewport is set.
+ // needed for percentage unit in x, y, width or height
+ void seekReferenceWidth(double& fWidth, bool& bHasFound) const;
+ void seekReferenceHeight(double& fHeight, bool& bHasFound) const;
+
+ /// InfoProvider support for % values in children
+ // The returned 'CurrentViewPort' is the viewport as it is set by this svg element
+ // and as it is needed to resolve relative values in children
+ // The method does not check for invalid width and height
+ virtual basegfx::B2DRange getCurrentViewPort() const override;
+
+ /// viewBox content
+ const basegfx::B2DRange* getViewBox() const { return mpViewBox.get(); }
+ void setViewBox(const basegfx::B2DRange* pViewBox) { mpViewBox.reset(); if(pViewBox) mpViewBox.reset( new basegfx::B2DRange(*pViewBox) ); }
+
+ /// SvgAspectRatio content
+ const SvgAspectRatio& getSvgAspectRatio() const { return maSvgAspectRatio; }
+
+ /// x content
+ const SvgNumber& getX() const { return maX; }
+
+ /// y content
+ const SvgNumber& getY() const { return maY; }
+
+ /// width content
+ const SvgNumber& getWidth() const { return maWidth; }
+
+ /// height content
+ const SvgNumber& getHeight() const { return maHeight; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgsymbolnode.hxx b/svgio/inc/svgsymbolnode.hxx
new file mode 100644
index 0000000000..7a19b335b7
--- /dev/null
+++ b/svgio/inc/svgsymbolnode.hxx
@@ -0,0 +1,46 @@
+/* -*- 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 "svgstyleattributes.hxx"
+
+namespace svgio::svgreader
+ {
+ class SvgSymbolNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ SvgAspectRatio maSvgAspectRatio;
+
+ public:
+ SvgSymbolNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgSymbolNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtextnode.hxx b/svgio/inc/svgtextnode.hxx
new file mode 100644
index 0000000000..c95857e38f
--- /dev/null
+++ b/svgio/inc/svgtextnode.hxx
@@ -0,0 +1,62 @@
+/* -*- 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 "svgstyleattributes.hxx"
+#include "svgtextposition.hxx"
+#include "svgtspannode.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+
+namespace svgio::svgreader
+ {
+ class SvgTextNode final : public SvgTspanNode
+ {
+ private:
+ /// variable scan values, dependent of given XAttributeList
+ std::optional<basegfx::B2DHomMatrix>
+ mpaTransform;
+
+ /// local helpers
+ void DecomposeChild(
+ const SvgNode& rCandidate,
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ SvgTextPosition& rSvgTextPosition) const;
+ static void addTextPrimitives(
+ const SvgNode& rCandidate,
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ drawinglayer::primitive2d::Primitive2DContainer&& rSource);
+
+ public:
+ SvgTextNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgTextNode() override;
+
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// transform content, set if found in current context
+ const std::optional<basegfx::B2DHomMatrix>& getTransform() const { return mpaTransform; }
+ void setTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaTransform = pMatrix; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtextpathnode.hxx b/svgio/inc/svgtextpathnode.hxx
new file mode 100644
index 0000000000..585b656f64
--- /dev/null
+++ b/svgio/inc/svgtextpathnode.hxx
@@ -0,0 +1,60 @@
+/* -*- 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"
+
+namespace svgio::svgreader
+ {
+ class SvgTextPathNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// link to path content. If maXLink
+ /// is set, the node can be fetched on demand
+ OUString maXLink;
+
+ /// variable scan values, dependent of given XAttributeList
+ SvgNumber maStartOffset;
+
+ public:
+ SvgTextPathNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgTextPathNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ void decomposePathNode(
+ const drawinglayer::primitive2d::Primitive2DContainer& rPathContent,
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ const basegfx::B2DPoint& rTextStart) const;
+ bool isValid() const;
+
+ /// StartOffset content
+ const SvgNumber& getStartOffset() const { return maStartOffset; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtextposition.hxx b/svgio/inc/svgtextposition.hxx
new file mode 100644
index 0000000000..df6adc16ab
--- /dev/null
+++ b/svgio/inc/svgtextposition.hxx
@@ -0,0 +1,72 @@
+/* -*- 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 <sal/config.h>
+#include <rtl/ref.hxx>
+
+#include <string_view>
+
+#include "svgtspannode.hxx"
+
+namespace svgio::svgreader
+{
+class SvgTextPosition
+{
+private:
+ SvgTextPosition* mpParent;
+ ::std::vector<double> maX;
+ ::std::vector<double> maY;
+ ::std::vector<double> maDx;
+ ::std::vector<double> maRotate;
+ double mfTextLength;
+
+ // absolute, current, advancing position
+ basegfx::B2DPoint maPosition;
+
+ // advancing rotation index
+ sal_uInt32 mnRotationIndex;
+
+ bool mbLengthAdjust : 1; // true = spacing, false = spacingAndGlyphs
+ bool mbAbsoluteX : 1;
+
+public:
+ SvgTextPosition(SvgTextPosition* pParent, const SvgTspanNode& rSvgCharacterNode);
+
+ // data read access
+ const SvgTextPosition* getParent() const { return mpParent; }
+ const ::std::vector<double>& getX() const { return maX; }
+ const ::std::vector<double>& getDx() const { return maDx; }
+ double getTextLength() const { return mfTextLength; }
+ bool getLengthAdjust() const { return mbLengthAdjust; }
+ bool getAbsoluteX() const { return mbAbsoluteX; }
+
+ // get/set absolute, current, advancing position
+ const basegfx::B2DPoint& getPosition() const { return maPosition; }
+ void setPosition(const basegfx::B2DPoint& rNew) { maPosition = rNew; }
+
+ // rotation handling
+ bool isRotated() const;
+ double consumeRotation();
+};
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtitledescnode.hxx b/svgio/inc/svgtitledescnode.hxx
new file mode 100644
index 0000000000..78394d81ec
--- /dev/null
+++ b/svgio/inc/svgtitledescnode.hxx
@@ -0,0 +1,52 @@
+/* -*- 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 <sal/config.h>
+
+#include <string_view>
+
+#include "svgnode.hxx"
+
+
+namespace svgio::svgreader
+ {
+ class SvgTitleDescNode final : public SvgNode
+ {
+ private:
+ /// contained chars
+ OUString maText;
+
+ public:
+ SvgTitleDescNode(
+ SVGToken aType,
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgTitleDescNode() override;
+
+ /// add new chars
+ void concatenate(std::u16string_view rChars);
+
+ /// x content, set if found in current context
+ const OUString& getText() const { return maText; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtoken.hxx b/svgio/inc/svgtoken.hxx
new file mode 100644
index 0000000000..3927a27d1d
--- /dev/null
+++ b/svgio/inc/svgtoken.hxx
@@ -0,0 +1,200 @@
+/* -*- 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 <rtl/ustring.hxx>
+
+namespace svgio::svgreader
+ {
+ // SVG token mapper with hashing
+ enum class SVGToken
+ {
+ Unknown = 0,
+
+ // diverse attribute tokens
+ Width,
+ Height,
+ ViewBox,
+ Transform,
+ Style,
+ Display, // #i121656#
+ D,
+ X,
+ Y,
+ Xmlns,
+ Version,
+ Id,
+ In,
+ Rx,
+ Ry,
+ Points,
+ Dx,
+ Dy,
+ Rotate,
+ TextLength,
+ LengthAdjust,
+ Font,
+ FontFamily,
+ FontSize,
+ FontSizeAdjust,
+ FontStretch,
+ FontStyle,
+ FontVariant,
+ FontWeight,
+ Direction,
+ LetterSpacing,
+ TextDecoration,
+ UnicodeBidi,
+ WordSpacing,
+ Character, // not in the hash, just for simple text handling in SvgCharacterNode
+ Tspan,
+ Tref,
+ TextPath,
+ StartOffset,
+ Method,
+ Spacing,
+ StdDeviation,
+ TextAlign,
+ PathLength,
+ Type,
+ Class,
+ TextAnchor,
+ XmlSpace,
+ Color,
+ ClipPathNode,
+ ClipPathProperty,
+ FeColorMatrix,
+ FeDropShadow,
+ FeFlood,
+ FeImage,
+ FeGaussianBlur,
+ FeOffset,
+ Filter,
+ FloodColor,
+ FloodOpacity,
+ Mask,
+ ClipPathUnits,
+ MaskUnits,
+ MaskContentUnits,
+ ClipRule,
+ Marker,
+ MarkerStart,
+ MarkerMid,
+ MarkerEnd,
+ RefX,
+ RefY,
+ MarkerUnits,
+ MarkerWidth,
+ MarkerHeight,
+ Orient,
+ Pattern,
+ PatternUnits,
+ PatternContentUnits,
+ PatternTransform,
+ Opacity,
+ Visibility,
+ Title,
+ Desc,
+
+ // AspectRatio and params
+ PreserveAspectRatio,
+ Defer,
+ None,
+ XMinYMin,
+ XMidYMin,
+ XMaxYMin,
+ XMinYMid,
+ XMidYMid,
+ XMaxYMid,
+ XMinYMax,
+ XMidYMax,
+ XMaxYMax,
+ Meet,
+ Slice,
+ Values,
+
+ // structural elements
+ Defs,
+ G,
+ Svg,
+ Symbol,
+ Switch,
+ Use,
+ A,
+
+ // shape elements
+ Circle,
+ Ellipse,
+ Line,
+ Path,
+ Polygon,
+ Polyline,
+ Rect,
+ Image,
+
+ // gradient elements and tokens
+ LinearGradient,
+ RadialGradient,
+ Stop,
+ Offset,
+ X1,
+ Y1,
+ X2,
+ Y2,
+ Cx,
+ Cy,
+ Fx,
+ Fy,
+ R,
+ GradientUnits,
+ GradientTransform,
+ SpreadMethod,
+ Href,
+ XlinkHref,
+ StopColor,
+ StopOpacity,
+
+ // fill tokens
+ Fill,
+ FillOpacity,
+ FillRule,
+
+ // stroke tokens
+ Stroke,
+ StrokeDasharray,
+ StrokeDashoffset,
+ StrokeLinecap,
+ StrokeLinejoin,
+ StrokeMiterlimit,
+ StrokeOpacity,
+ StrokeWidth,
+
+ // text tokens
+ Text,
+ BaselineShift,
+ DominantBaseline
+ };
+
+ SVGToken StrToSVGToken(std::u16string_view rStr, bool bIgnoreCase);
+ OUString SVGTokenToStr(const SVGToken& rToken);
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtools.hxx b/svgio/inc/svgtools.hxx
new file mode 100644
index 0000000000..6dc882b6af
--- /dev/null
+++ b/svgio/inc/svgtools.hxx
@@ -0,0 +1,137 @@
+/* -*- 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 <basegfx/color/bcolor.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/vector/b2ivector.hxx>
+#include <rtl/ustrbuf.hxx>
+#include "svgpaint.hxx"
+#include "SvgNumber.hxx"
+
+#include <string_view>
+#include <vector>
+
+
+namespace svgio::svgreader
+ {
+ // common non-token strings
+ struct commonStrings
+ {
+ static constexpr OUString aStrUserSpaceOnUse = u"userSpaceOnUse"_ustr;
+ static constexpr OUString aStrObjectBoundingBox = u"objectBoundingBox"_ustr;
+ static constexpr OUString aStrNonzero = u"nonzero"_ustr;
+ static constexpr OUString aStrEvenOdd = u"evenodd"_ustr;
+ };
+
+ enum class SvgUnits
+ {
+ userSpaceOnUse,
+ objectBoundingBox
+ };
+
+ enum class SvgAlign
+ {
+ none,
+ xMinYMin,
+ xMidYMin,
+ xMaxYMin,
+ xMinYMid,
+ xMidYMid, // default
+ xMaxYMid,
+ xMinYMax,
+ xMidYMax,
+ xMaxYMax
+ };
+
+ class SvgAspectRatio
+ {
+ private:
+ SvgAlign maSvgAlign;
+
+ bool mbMeetOrSlice : 1; // true = meet (default), false = slice
+ bool mbSet : 1;
+
+ public:
+ SvgAspectRatio()
+ : maSvgAlign(SvgAlign::xMidYMid),
+ mbMeetOrSlice(true),
+ mbSet(false)
+ {
+ }
+
+ SvgAspectRatio(SvgAlign aSvgAlign, bool bMeetOrSlice)
+ : maSvgAlign(aSvgAlign),
+ mbMeetOrSlice(bMeetOrSlice),
+ mbSet(true)
+ {
+ }
+
+ /// data read access
+ SvgAlign getSvgAlign() const { return maSvgAlign; }
+ bool isMeetOrSlice() const { return mbMeetOrSlice; }
+ bool isSet() const { return mbSet; }
+
+ /// tooling
+ static basegfx::B2DHomMatrix createLinearMapping(const basegfx::B2DRange& rTarget, const basegfx::B2DRange& rSource);
+ basegfx::B2DHomMatrix createMapping(const basegfx::B2DRange& rTarget, const basegfx::B2DRange& rSource) const;
+ };
+
+ void skip_char(std::u16string_view rCandidate, sal_Unicode aChar, sal_Int32& nPos, const sal_Int32 nLen);
+ void skip_char(std::u16string_view rCandidate, sal_Unicode aCharA, sal_Unicode nCharB, sal_Int32& nPos, const sal_Int32 nLen);
+ void copySign(std::u16string_view rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen);
+ void copyNumber(std::u16string_view rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen);
+ void copyHex(std::u16string_view rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen);
+ void copyString(std::u16string_view rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen);
+ void copyToLimiter(std::u16string_view rCandidate, sal_Unicode aLimiter, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen);
+ bool readNumber(std::u16string_view rCandidate, sal_Int32& nPos, double& fNum, const sal_Int32 nLen);
+ SvgUnit readUnit(std::u16string_view rCandidate, sal_Int32& nPos, const sal_Int32 nLen);
+ bool readNumberAndUnit(std::u16string_view rCandidate, sal_Int32& nPos, SvgNumber& aNum, const sal_Int32 nLen);
+ bool readAngle(std::u16string_view rCandidate, sal_Int32& nPos, double& fAngle, const sal_Int32 nLen);
+ sal_Int32 read_hex(sal_Unicode aChar);
+ bool match_colorKeyword(basegfx::BColor& rColor, const OUString& rName);
+ bool read_color(const OUString& rCandidate, basegfx::BColor& rColor, SvgNumber& rOpacity);
+ basegfx::B2DRange readViewBox(std::u16string_view rCandidate, InfoProvider const & rInfoProvider);
+ std::vector<double> readFilterMatrix(std::u16string_view rCandidate, InfoProvider const & rInfoProvider);
+ basegfx::B2DHomMatrix readTransform(std::u16string_view rCandidate, InfoProvider const & rInfoProvider);
+ bool readSingleNumber(std::u16string_view rCandidate, SvgNumber& aNum);
+ bool readLocalLink(std::u16string_view rCandidate, OUString& rURL);
+ bool readLocalUrl(const OUString& rCandidate, OUString& rURL);
+ bool readSvgPaint(const OUString& rCandidate, SvgPaint& rSvgPaint, OUString& rURL, SvgNumber& rOpacity);
+
+ bool readSvgNumberVector(std::u16string_view rCandidate, SvgNumberVector& rSvgNumberVector);
+ ::std::vector< double > solveSvgNumberVector(const SvgNumberVector& rInput, const InfoProvider& rInfoProvider);
+
+ SvgAspectRatio readSvgAspectRatio(std::u16string_view rCandidate);
+
+ typedef ::std::vector< OUString > SvgStringVector;
+ bool readSvgStringVector(std::u16string_view rCandidate, SvgStringVector& rSvgStringVector);
+
+ void readImageLink(const OUString& rCandidate, OUString& rXLink, OUString& rUrl, OUString& rData);
+
+ OUString consolidateContiguousSpace(const OUString& rCandidate);
+
+ // #125325# removes block comment of the general form '/* ... */', returns
+ // an adapted string or the original if no comments included
+ OUString removeBlockComments(const OUString& rCandidate);
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtrefnode.hxx b/svgio/inc/svgtrefnode.hxx
new file mode 100644
index 0000000000..c4701ceec4
--- /dev/null
+++ b/svgio/inc/svgtrefnode.hxx
@@ -0,0 +1,53 @@
+/* -*- 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 "svgtextnode.hxx"
+
+namespace svgio::svgreader
+ {
+ class SvgTrefNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// link to text content. If maXLink
+ /// is set, the node can be fetched on demand
+ OUString maXLink;
+
+ public:
+ SvgTrefNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgTrefNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+
+ /// access to referenced SvgTextNode
+ const SvgTextNode* getReferencedSvgTextNode() const;
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtspannode.hxx b/svgio/inc/svgtspannode.hxx
new file mode 100644
index 0000000000..84033685d8
--- /dev/null
+++ b/svgio/inc/svgtspannode.hxx
@@ -0,0 +1,92 @@
+/* -*- 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"
+
+namespace svgio::svgreader
+ {
+ class SvgTspanNode : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ SvgNumberVector maX;
+ SvgNumberVector maY;
+ SvgNumberVector maDx;
+ SvgNumberVector maDy;
+ SvgNumberVector maRotate;
+ SvgNumber maTextLength;
+
+ bool mbLengthAdjust : 1; // true = spacing, false = spacingAndGlyphs
+
+ // The text line width composed by the different SvgCharacterNode children
+ // it will be used to calculate their alignment
+ double mnTextLineWidth;
+
+ public:
+ SvgTspanNode(
+ SVGToken aType,
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgTspanNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+
+ double getCurrentFontSize() const;
+
+ /// X content
+ const SvgNumberVector& getX() const { return maX; }
+ void setX(SvgNumberVector&& aX) { maX = std::move(aX); }
+
+ /// Y content
+ const SvgNumberVector& getY() const { return maY; }
+ void setY(SvgNumberVector&& aY) { maY = std::move(aY); }
+
+ /// Dx content
+ const SvgNumberVector& getDx() const { return maDx; }
+ void setDx(SvgNumberVector&& aDx) { maDx = std::move(aDx); }
+
+ /// Dy content
+ const SvgNumberVector& getDy() const { return maDy; }
+ void setDy(SvgNumberVector&& aDy) { maDy = std::move(aDy); }
+
+ /// Rotate content
+ const SvgNumberVector& getRotate() const { return maRotate; }
+ void setRotate(SvgNumberVector&& aRotate) { maRotate = std::move(aRotate); }
+
+ /// TextLength content
+ const SvgNumber& getTextLength() const { return maTextLength; }
+ void setTextLength(const SvgNumber& rTextLength) { maTextLength = rTextLength; }
+
+ /// LengthAdjust content
+ bool getLengthAdjust() const { return mbLengthAdjust; }
+ void setLengthAdjust(bool bNew) { mbLengthAdjust = bNew; }
+
+ void concatenateTextLineWidth(double nWidth) {mnTextLineWidth += nWidth;}
+ double getTextLineWidth() const { return mnTextLineWidth; }
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgusenode.hxx b/svgio/inc/svgusenode.hxx
new file mode 100644
index 0000000000..daf6885565
--- /dev/null
+++ b/svgio/inc/svgusenode.hxx
@@ -0,0 +1,73 @@
+/* -*- 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>
+#include <optional>
+
+namespace svgio::svgreader
+ {
+ class SvgUseNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::optional<basegfx::B2DHomMatrix>
+ mpaTransform;
+ SvgNumber maX;
+ SvgNumber maY;
+ SvgNumber maWidth;
+ SvgNumber maHeight;
+
+ /// link to content. If maXLink is set, the node can be fetched
+ // on demand
+ OUString maXLink;
+ /// detect if maXLink causes a loop to ourself during decomposing
+ mutable bool mbDecomposingSvgNode;
+
+ public:
+ SvgUseNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgUseNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// transform content
+ const std::optional<basegfx::B2DHomMatrix>& getTransform() const { return mpaTransform; }
+ void setTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaTransform = pMatrix; }
+
+ /// x content
+ const SvgNumber& getX() const { return maX; }
+
+ /// y content
+ const SvgNumber& getY() const { return maY; }
+
+ };
+
+} // end of namespace svgio::svgreader
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgvisitor.hxx b/svgio/inc/svgvisitor.hxx
new file mode 100644
index 0000000000..2aa1f978fe
--- /dev/null
+++ b/svgio/inc/svgvisitor.hxx
@@ -0,0 +1,35 @@
+/* -*- 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/.
+ *
+ */
+
+#pragma once
+
+#include <basegfx/DrawCommands.hxx>
+#include <memory>
+#include "svgnode.hxx"
+
+namespace svgio::svgreader
+{
+class SvgDrawVisitor final : public Visitor
+{
+private:
+ std::shared_ptr<gfx::DrawRoot> mpDrawRoot;
+ std::shared_ptr<gfx::DrawBase> mpCurrent;
+
+public:
+ SvgDrawVisitor();
+
+ void visit(svgio::svgreader::SvgNode const& rNode) override;
+ void goToChildren(svgio::svgreader::SvgNode const& rNode);
+
+ std::shared_ptr<gfx::DrawRoot> const& getDrawRoot() const { return mpDrawRoot; }
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */