summaryrefslogtreecommitdiffstats
path: root/svgio/inc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--svgio/inc/pch/precompiled_svgio.cxx12
-rw-r--r--svgio/inc/pch/precompiled_svgio.hxx70
-rw-r--r--svgio/inc/svganode.hxx60
-rw-r--r--svgio/inc/svgcharacternode.hxx167
-rw-r--r--svgio/inc/svgcirclenode.hxx72
-rw-r--r--svgio/inc/svgclippathnode.hxx70
-rw-r--r--svgio/inc/svgdocument.hxx84
-rw-r--r--svgio/inc/svgdocumenthandler.hxx68
-rw-r--r--svgio/inc/svgellipsenode.hxx76
-rw-r--r--svgio/inc/svggnode.hxx61
-rw-r--r--svgio/inc/svggradientnode.hxx123
-rw-r--r--svgio/inc/svggradientstopnode.hxx56
-rw-r--r--svgio/inc/svgimagenode.hxx84
-rw-r--r--svgio/inc/svglinenode.hxx76
-rw-r--r--svgio/inc/svgmarkernode.hxx111
-rw-r--r--svgio/inc/svgmasknode.hxx90
-rw-r--r--svgio/inc/svgnode.hxx201
-rw-r--r--svgio/inc/svgpaint.hxx57
-rw-r--r--svgio/inc/svgpathnode.hxx71
-rw-r--r--svgio/inc/svgpatternnode.hxx121
-rw-r--r--svgio/inc/svgpolynode.hxx67
-rw-r--r--svgio/inc/svgrectnode.hxx84
-rw-r--r--svgio/inc/svgstyleattributes.hxx446
-rw-r--r--svgio/inc/svgstylenode.hxx63
-rw-r--r--svgio/inc/svgsvgnode.hxx98
-rw-r--r--svgio/inc/svgsymbolnode.hxx51
-rw-r--r--svgio/inc/svgtextnode.hxx75
-rw-r--r--svgio/inc/svgtextpathnode.hxx65
-rw-r--r--svgio/inc/svgtitledescnode.hxx54
-rw-r--r--svgio/inc/svgtoken.hxx194
-rw-r--r--svgio/inc/svgtools.hxx228
-rw-r--r--svgio/inc/svgtrefnode.hxx58
-rw-r--r--svgio/inc/svgtspannode.hxx58
-rw-r--r--svgio/inc/svgusenode.hxx78
-rw-r--r--svgio/inc/svgvisitor.hxx41
35 files changed, 3390 insertions, 0 deletions
diff --git a/svgio/inc/pch/precompiled_svgio.cxx b/svgio/inc/pch/precompiled_svgio.cxx
new file mode 100644
index 000000000..843dba73f
--- /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 000000000..67bbe7b60
--- /dev/null
+++ b/svgio/inc/pch/precompiled_svgio.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 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 2020-04-25 20:55:30 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
+*/
+
+#if PCH_LEVEL >= 1
+#include <memory>
+#include <ostream>
+#include <set>
+#include <stddef.h>
+#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/unload.h>
+#include <rtl/uri.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/config.h>
+#include <sal/log.hxx>
+#include <sal/macros.h>
+#include <sal/types.h>
+#include <sal/typesizes.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/baseprimitive2d.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <o3tl/cow_wrapper.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 000000000..677fedf3f
--- /dev/null
+++ b/svgio/inc/svganode.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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGANODE_HXX
+#define INCLUDED_SVGIO_INC_SVGANODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <memory>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgANode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
+
+ public:
+ SvgANode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgANode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// transform content
+ const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGANODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgcharacternode.hxx b/svgio/inc/svgcharacternode.hxx
new file mode 100644
index 000000000..647d32749
--- /dev/null
+++ b/svgio/inc/svgcharacternode.hxx
@@ -0,0 +1,167 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGCHARACTERNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGCHARACTERNODE_HXX
+
+#include "svgnode.hxx"
+
+namespace drawinglayer::primitive2d { class TextSimplePortionPrimitive2D; }
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgTextPositions
+ {
+ private:
+ SvgNumberVector maX;
+ SvgNumberVector maY;
+ SvgNumberVector maDx;
+ SvgNumberVector maDy;
+ SvgNumberVector maRotate;
+ SvgNumber maTextLength;
+
+ bool mbLengthAdjust : 1; // true = spacing, false = spacingAndGlyphs
+
+ public:
+ SvgTextPositions();
+
+ void parseTextPositionAttributes(SVGToken aSVGToken, const OUString& aContent);
+
+ /// X content
+ const SvgNumberVector& getX() const { return maX; }
+ void setX(const SvgNumberVector& aX) { maX = aX; }
+
+ /// Y content
+ const SvgNumberVector& getY() const { return maY; }
+ void setY(const SvgNumberVector& aY) { maY = aY; }
+
+ /// Dx content
+ const SvgNumberVector& getDx() const { return maDx; }
+ void setDx(const SvgNumberVector& aDx) { maDx = aDx; }
+
+ /// Dy content
+ const SvgNumberVector& getDy() const { return maDy; }
+ void setDy(const SvgNumberVector& aDy) { maDy = aDy; }
+
+ /// Rotate content
+ const SvgNumberVector& getRotate() const { return maRotate; }
+ void setRotate(const SvgNumberVector& aRotate) { maRotate = 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; }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgTextPosition
+ {
+ private:
+ SvgTextPosition* mpParent;
+ ::std::vector< double > maX;
+ ::std::vector< double > maY;
+ ::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 InfoProvider& rInfoProvider,
+ const SvgTextPositions& rSvgTextPositions);
+
+ // data read access
+ const SvgTextPosition* getParent() const { return mpParent; }
+ const ::std::vector< double >& getX() const { return maX; }
+ 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 svgreader
+} // end of namespace svgio
+
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgCharacterNode final : public SvgNode
+ {
+ private:
+ /// the string data
+ OUString maText;
+
+ /// local helpers
+ drawinglayer::primitive2d::TextSimplePortionPrimitive2D* 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,
+ const OUString& rText);
+ virtual ~SvgCharacterNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ void decomposeText(drawinglayer::primitive2d::Primitive2DContainer& rTarget, SvgTextPosition& rSvgTextPosition) const;
+ void whiteSpaceHandling();
+ void addGap();
+ void concatenate(const OUString& rText);
+
+ /// Text content
+ const OUString& getText() const { return maText; }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGCHARACTERNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgcirclenode.hxx b/svgio/inc/svgcirclenode.hxx
new file mode 100644
index 000000000..bdca4ba15
--- /dev/null
+++ b/svgio/inc/svgcirclenode.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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGCIRCLENODE_HXX
+#define INCLUDED_SVGIO_INC_SVGCIRCLENODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <memory>
+
+namespace svgio
+{
+ namespace 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::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
+
+ public:
+ SvgCircleNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgCircleNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(const OUString& rTokenName, 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 basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGCIRCLENODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgclippathnode.hxx b/svgio/inc/svgclippathnode.hxx
new file mode 100644
index 000000000..1aeca2655
--- /dev/null
+++ b/svgio/inc/svgclippathnode.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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGCLIPPATHNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGCLIPPATHNODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <memory>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgClipPathNode : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
+ SvgUnits maClipPathUnits;
+
+ public:
+ SvgClipPathNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgClipPathNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(const OUString& rTokenName, 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 basegfx::B2DHomMatrix* pTransform) const;
+
+ /// clipPathUnits content
+ SvgUnits getClipPathUnits() const { return maClipPathUnits; }
+ void setClipPathUnits(const SvgUnits aClipPathUnits) { maClipPathUnits = aClipPathUnits; }
+
+ /// transform content
+ const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGCLIPPATHNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgdocument.hxx b/svgio/inc/svgdocument.hxx
new file mode 100644
index 000000000..e414b1939
--- /dev/null
+++ b/svgio/inc/svgdocument.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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGDOCUMENT_HXX
+#define INCLUDED_SVGIO_INC_SVGDOCUMENT_HXX
+
+#include "svgnode.hxx"
+#include <memory>
+#include <unordered_map>
+#include <vector>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ typedef std::vector< std::unique_ptr<SvgNode> > SvgNodeVector;
+
+ class SvgDocument
+ {
+ private:
+ /// the document hierarchy with all root nodes
+ SvgNodeVector maNodes;
+
+ /// 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(const OUString& rAbsolutePath);
+ ~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; }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGDOCUMENT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgdocumenthandler.hxx b/svgio/inc/svgdocumenthandler.hxx
new file mode 100644
index 000000000..2fd7c1db2
--- /dev/null
+++ b/svgio/inc/svgdocumenthandler.hxx
@@ -0,0 +1,68 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGDOCUMENTHANDLER_HXX
+#define INCLUDED_SVGIO_INC_SVGDOCUMENTHANDLER_HXX
+
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include "svgdocument.hxx"
+#include <cppuhelper/implbase.hxx>
+
+namespace svgio::svgreader { class SvgCharacterNode; }
+
+namespace svgio
+{
+ namespace 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;
+
+ bool bSkip;
+
+ 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 svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGDOCUMENTHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgellipsenode.hxx b/svgio/inc/svgellipsenode.hxx
new file mode 100644
index 000000000..5861b5a64
--- /dev/null
+++ b/svgio/inc/svgellipsenode.hxx
@@ -0,0 +1,76 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGELLIPSENODE_HXX
+#define INCLUDED_SVGIO_INC_SVGELLIPSENODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <memory>
+
+namespace svgio
+{
+ namespace 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::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
+
+ public:
+ SvgEllipseNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgEllipseNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(const OUString& rTokenName, 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 basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGELLIPSENODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svggnode.hxx b/svgio/inc/svggnode.hxx
new file mode 100644
index 000000000..fda850b8c
--- /dev/null
+++ b/svgio/inc/svggnode.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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGGNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGGNODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <memory>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgGNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
+
+ public:
+ SvgGNode(
+ SVGToken aType,
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgGNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// transform content
+ const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGGNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svggradientnode.hxx b/svgio/inc/svggradientnode.hxx
new file mode 100644
index 000000000..c55074f97
--- /dev/null
+++ b/svgio/inc/svggradientnode.hxx
@@ -0,0 +1,123 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGGRADIENTNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGGRADIENTNODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
+#include <memory>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgGradientNode : 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::unique_ptr<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(const OUString& rTokenName, 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
+ const basegfx::B2DHomMatrix* getGradientTransform() const;
+ void setGradientTransform(const basegfx::B2DHomMatrix* pMatrix);
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGGRADIENTNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svggradientstopnode.hxx b/svgio/inc/svggradientstopnode.hxx
new file mode 100644
index 000000000..8d1303d3e
--- /dev/null
+++ b/svgio/inc/svggradientstopnode.hxx
@@ -0,0 +1,56 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGGRADIENTSTOPNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGGRADIENTSTOPNODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+
+namespace svgio
+{
+ namespace 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(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override;
+
+ /// offset content
+ const SvgNumber& getOffset() const { return maOffset; }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGGRADIENTSTOPNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgimagenode.hxx b/svgio/inc/svgimagenode.hxx
new file mode 100644
index 000000000..da9d6d5d0
--- /dev/null
+++ b/svgio/inc/svgimagenode.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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGIMAGENODE_HXX
+#define INCLUDED_SVGIO_INC_SVGIMAGENODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <memory>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgImageNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ SvgAspectRatio maSvgAspectRatio;
+ std::unique_ptr<basegfx::B2DHomMatrix>
+ mpaTransform;
+ SvgNumber maX;
+ SvgNumber maY;
+ SvgNumber maWidth;
+ SvgNumber maHeight;
+
+ OUString maXLink; // internal link
+ OUString maUrl; // external link
+
+ OUString maMimeType; // mimetype and
+ OUString maData; // base64 data
+
+ public:
+ SvgImageNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgImageNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(const OUString& rTokenName, 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 basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*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 svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGIMAGENODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svglinenode.hxx b/svgio/inc/svglinenode.hxx
new file mode 100644
index 000000000..1f7fe3aa5
--- /dev/null
+++ b/svgio/inc/svglinenode.hxx
@@ -0,0 +1,76 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGLINENODE_HXX
+#define INCLUDED_SVGIO_INC_SVGLINENODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <memory>
+
+namespace svgio
+{
+ namespace 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::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
+
+ public:
+ SvgLineNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgLineNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(const OUString& rTokenName, 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 basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGLINENODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgmarkernode.hxx b/svgio/inc/svgmarkernode.hxx
new file mode 100644
index 000000000..135dc3c4f
--- /dev/null
+++ b/svgio/inc/svgmarkernode.hxx
@@ -0,0 +1,111 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGMARKERNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGMARKERNODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <memory>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgMarkerNode : public SvgNode
+ {
+ public:
+ enum class MarkerUnits
+ {
+ strokeWidth,
+ userSpaceOnUse
+ };
+
+ 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;
+
+ bool mbOrientAuto : 1; // true == on, false == fAngle valid
+
+ public:
+ SvgMarkerNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgMarkerNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(const OUString& rTokenName, 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; mbOrientAuto = false; }
+
+ /// OrientAuto content, set if found in current context
+ bool getOrientAuto() const { return mbOrientAuto; }
+
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGMARKERNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgmasknode.hxx b/svgio/inc/svgmasknode.hxx
new file mode 100644
index 000000000..5dc156912
--- /dev/null
+++ b/svgio/inc/svgmasknode.hxx
@@ -0,0 +1,90 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGMASKNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGMASKNODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <memory>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgMaskNode : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ SvgNumber maX;
+ SvgNumber maY;
+ SvgNumber maWidth;
+ SvgNumber maHeight;
+ std::unique_ptr<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(const OUString& rTokenName, 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 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 basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
+
+ /// MaskUnits content
+ void setMaskUnits(const SvgUnits aMaskUnits) { maMaskUnits = aMaskUnits; }
+
+ /// MaskContentUnits content
+ void setMaskContentUnits(const SvgUnits aMaskContentUnits) { maMaskContentUnits = aMaskContentUnits; }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGMASKNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgnode.hxx b/svgio/inc/svgnode.hxx
new file mode 100644
index 000000000..121e7826b
--- /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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGNODE_HXX
+
+#include "svgtools.hxx"
+#include "svgtoken.hxx"
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <memory>
+#include <vector>
+#include <optional>
+
+// predefines
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgNode;
+ class SvgDocument;
+ class SvgStyleAttributes;
+ }
+}
+
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ enum XmlSpace
+ {
+ XmlSpace_notset,
+ XmlSpace_default,
+ XmlSpace_preserve
+ };
+
+ // display property (see SVG 1.1. 11.5), not inheritable
+ enum Display // #i121656#
+ {
+ Display_inline, // the default
+ Display_block,
+ Display_list_item,
+ Display_run_in,
+ Display_compact,
+ Display_marker,
+ Display_table,
+ Display_inline_table,
+ Display_table_row_group,
+ Display_table_header_group,
+ Display_table_footer_group,
+ Display_table_row,
+ Display_table_column_group,
+ Display_table_column,
+ Display_table_cell,
+ Display_table_caption,
+ Display_none,
+ Display_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(const OUString& 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 OUString& rClassStr, const SvgStyleAttributes& rOriginal) const;
+
+ /// helper for filling the CssStyle vector once dependent on mbCssStyleVectorBuilt
+ void fillCssStyleVector(const OUString& rClassStr, const SvgStyleAttributes& rOriginal);
+ void fillCssStyleVectorUsingHierarchyAndSelectors(
+ const OUString& rClassStr,
+ const SvgNode& rCurrent,
+ const OUString& aConcatenated);
+
+ 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(const OUString& aContent);
+
+ /// style helpers
+ void parseAttributes(const css::uno::Reference< css::xml::sax::XAttributeList >& xAttribs);
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const;
+ virtual void parseAttribute(const OUString& rTokenName, 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;
+
+ virtual 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; }
+ };
+
+ class Visitor
+ {
+ public:
+ virtual ~Visitor() = default;
+ virtual void visit(SvgNode const & pNode) = 0;
+ };
+
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgpaint.hxx b/svgio/inc/svgpaint.hxx
new file mode 100644
index 000000000..7f442ce26
--- /dev/null
+++ b/svgio/inc/svgpaint.hxx
@@ -0,0 +1,57 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGPAINT_HXX
+#define INCLUDED_SVGIO_INC_SVGPAINT_HXX
+
+#include <basegfx/color/bcolor.hxx>
+
+namespace svgio
+{
+ namespace 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 svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGPAINT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgpathnode.hxx b/svgio/inc/svgpathnode.hxx
new file mode 100644
index 000000000..a84f92ba5
--- /dev/null
+++ b/svgio/inc/svgpathnode.hxx
@@ -0,0 +1,71 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGPATHNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGPATHNODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgPathNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::unique_ptr<basegfx::B2DPolyPolygon> mpPolyPolygon;
+ std::unique_ptr<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(const OUString& rTokenName, 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 basegfx::B2DPolyPolygon* getPath() const { return mpPolyPolygon.get(); }
+ void setPath(const basegfx::B2DPolyPolygon* pPath) { mpPolyPolygon.reset(); if(pPath) mpPolyPolygon.reset(new basegfx::B2DPolyPolygon(*pPath)); }
+
+ /// transform content, set if found in current context
+ const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset(new basegfx::B2DHomMatrix(*pMatrix)); }
+
+ /// PathLength content
+ const SvgNumber& getPathLength() const { return maPathLength; }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGPATHNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgpatternnode.hxx b/svgio/inc/svgpatternnode.hxx
new file mode 100644
index 000000000..1b9d9e1b2
--- /dev/null
+++ b/svgio/inc/svgpatternnode.hxx
@@ -0,0 +1,121 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGPATTERNNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGPATTERNNODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <memory>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgPatternNode : 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::unique_ptr<SvgUnits>
+ mpPatternUnits;
+ std::unique_ptr<SvgUnits>
+ mpPatternContentUnits;
+ std::unique_ptr<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(const OUString& rTokenName, 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) { mpPatternUnits.reset( new SvgUnits(aPatternUnits) ); }
+
+ /// PatternContentUnits content
+ const SvgUnits* getPatternContentUnits() const;
+ void setPatternContentUnits(const SvgUnits aPatternContentUnits) { mpPatternContentUnits.reset( new SvgUnits(aPatternContentUnits) ); }
+
+ /// PatternTransform content
+ const basegfx::B2DHomMatrix* getPatternTransform() const;
+ void setPatternTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaPatternTransform.reset(); if(pMatrix) mpaPatternTransform.reset(new basegfx::B2DHomMatrix(*pMatrix)); }
+
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGPATTERNNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgpolynode.hxx b/svgio/inc/svgpolynode.hxx
new file mode 100644
index 000000000..fa59312f6
--- /dev/null
+++ b/svgio/inc/svgpolynode.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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGPOLYNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGPOLYNODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgPolyNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::unique_ptr<basegfx::B2DPolygon> mpPolygon;
+ std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
+
+ bool mbIsPolyline : 1; // true = polyline, false = polygon
+
+ public:
+ SvgPolyNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent,
+ bool bIsPolyline);
+ virtual ~SvgPolyNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(const OUString& rTokenName, 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 basegfx::B2DPolygon* pPolygon) { mpPolygon.reset(); if(pPolygon) mpPolygon.reset(new basegfx::B2DPolygon(*pPolygon)); }
+
+ /// transform content, set if found in current context
+ const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset(new basegfx::B2DHomMatrix(*pMatrix)); }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGPOLYNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgrectnode.hxx b/svgio/inc/svgrectnode.hxx
new file mode 100644
index 000000000..5e1c5860c
--- /dev/null
+++ b/svgio/inc/svgrectnode.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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGRECTNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGRECTNODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <memory>
+
+namespace svgio
+{
+ namespace 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::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
+
+ public:
+ SvgRectNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgRectNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(const OUString& rTokenName, 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 basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGRECTNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgstyleattributes.hxx b/svgio/inc/svgstyleattributes.hxx
new file mode 100644
index 000000000..dc0a86a88
--- /dev/null
+++ b/svgio/inc/svgstyleattributes.hxx
@@ -0,0 +1,446 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGSTYLEATTRIBUTES_HXX
+#define INCLUDED_SVGIO_INC_SVGSTYLEATTRIBUTES_HXX
+
+#include "svgpaint.hxx"
+#include "svgnode.hxx"
+#include <tools/fontenum.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+
+
+// predefines
+
+namespace svgio::svgreader {
+ class SvgGradientNode;
+ class SvgPatternNode;
+ class SvgMarkerNode;
+ class SvgClipPathNode;
+ class SvgMaskNode;
+}
+
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ enum StrokeLinecap
+ {
+ StrokeLinecap_notset,
+ StrokeLinecap_butt,
+ StrokeLinecap_round,
+ StrokeLinecap_square
+ };
+
+ enum StrokeLinejoin
+ {
+ StrokeLinejoin_notset,
+ StrokeLinejoin_miter,
+ StrokeLinejoin_round,
+ StrokeLinejoin_bevel
+ };
+
+ enum FontSize
+ {
+ FontSize_notset,
+ FontSize_xx_small,
+ FontSize_x_small,
+ FontSize_small,
+ FontSize_smaller,
+ FontSize_medium,
+ FontSize_large,
+ FontSize_larger,
+ FontSize_x_large,
+ FontSize_xx_large,
+ FontSize_initial
+ };
+
+ enum FontStretch
+ {
+ FontStretch_notset,
+ FontStretch_normal,
+ FontStretch_wider,
+ FontStretch_narrower,
+ FontStretch_ultra_condensed,
+ FontStretch_extra_condensed,
+ FontStretch_condensed,
+ FontStretch_semi_condensed,
+ FontStretch_semi_expanded,
+ FontStretch_expanded,
+ FontStretch_extra_expanded,
+ FontStretch_ultra_expanded
+ };
+
+ FontStretch getWider(FontStretch aSource);
+ FontStretch getNarrower(FontStretch aSource);
+
+ enum FontStyle
+ {
+ FontStyle_notset,
+ FontStyle_normal,
+ FontStyle_italic,
+ FontStyle_oblique
+ };
+
+ enum FontWeight
+ {
+ FontWeight_notset,
+ FontWeight_100,
+ FontWeight_200,
+ FontWeight_300,
+ FontWeight_400, // same as FontWeight_normal
+ FontWeight_500,
+ FontWeight_600,
+ FontWeight_700, // same as FontWeight_bold
+ FontWeight_800,
+ FontWeight_900,
+ FontWeight_bolder,
+ FontWeight_lighter,
+ };
+
+ FontWeight getBolder(FontWeight aSource);
+ FontWeight getLighter(FontWeight aSource);
+ ::FontWeight getVclFontWeight(FontWeight aSource);
+
+ enum TextAlign
+ {
+ TextAlign_notset,
+ TextAlign_left,
+ TextAlign_right,
+ TextAlign_center,
+ TextAlign_justify
+ };
+
+ enum TextDecoration
+ {
+ TextDecoration_notset,
+ TextDecoration_none,
+ TextDecoration_underline,
+ TextDecoration_overline,
+ TextDecoration_line_through,
+ TextDecoration_blink
+ };
+
+ enum TextAnchor
+ {
+ TextAnchor_notset,
+ TextAnchor_start,
+ TextAnchor_middle,
+ TextAnchor_end
+ };
+
+ enum FillRule
+ {
+ FillRule_notset,
+ FillRule_nonzero,
+ FillRule_evenodd
+ };
+
+ enum BaselineShift
+ {
+ BaselineShift_Baseline,
+ BaselineShift_Sub,
+ BaselineShift_Super,
+ BaselineShift_Percentage,
+ BaselineShift_Length
+ };
+
+ enum Visibility
+ {
+ Visibility_notset,
+ Visibility_visible,
+ Visibility_hidden,
+ Visibility_collapse,
+ Visibility_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;
+ const SvgClipPathNode* mpClipPathXLink;
+ OUString maMaskXLink;
+ const SvgMaskNode* mpMaskXLink;
+
+ /// link to markers. If set, the node can be fetched on demand
+ OUString maMarkerStartXLink;
+ const SvgMarkerNode* mpMarkerStartXLink;
+ OUString maMarkerMidXLink;
+ const SvgMarkerNode* mpMarkerMidXLink;
+ OUString maMarkerEndXLink;
+ const SvgMarkerNode* mpMarkerEndXLink;
+
+ /// 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;
+
+ 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,
+ bool bCaseIndependent);
+
+ /// helper which does the necessary with a given path
+ void add_text(
+ drawinglayer::primitive2d::Primitive2DContainer& rTarget,
+ drawinglayer::primitive2d::Primitive2DContainer const & 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,
+ const drawinglayer::primitive2d::Primitive2DContainer& rSource,
+ const 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(const OUString& 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;
+
+ /// 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 const & getClipPathXLink() const;
+ const SvgClipPathNode* accessClipPathXLink() 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 { return maBaselineShift; }
+ SvgNumber getBaselineShiftNumber() const;
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGSTYLEATTRIBUTES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgstylenode.hxx b/svgio/inc/svgstylenode.hxx
new file mode 100644
index 000000000..5582eff10
--- /dev/null
+++ b/svgio/inc/svgstylenode.hxx
@@ -0,0 +1,63 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGSTYLENODE_HXX
+#define INCLUDED_SVGIO_INC_SVGSTYLENODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgStyleNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ std::vector< SvgStyleAttributes* > maSvgStyleAttributes;
+
+ bool mbTextCss : 1; // true == type is 'text/css'
+
+ public:
+ SvgStyleNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgStyleNode() override;
+
+ /// #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(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override;
+
+ /// CssStyleSheet add helpers
+ void addCssStyleSheet(const OUString& aSelectors, const SvgStyleAttributes& rNewStyle);
+ void addCssStyleSheet(const OUString& aSelectors, const OUString& aContent);
+ void addCssStyleSheet(const OUString& aSelectorsAndContent);
+
+ /// textCss access
+ bool isTextCss() const { return mbTextCss; }
+ void setTextCss(bool bNew) { mbTextCss = bNew; }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGSTYLENODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgsvgnode.hxx b/svgio/inc/svgsvgnode.hxx
new file mode 100644
index 000000000..48d225d93
--- /dev/null
+++ b/svgio/inc/svgsvgnode.hxx
@@ -0,0 +1,98 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGSVGNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGSVGNODE_HXX
+
+#include "svgstyleattributes.hxx"
+#include <memory>
+
+namespace svgio
+{
+ namespace 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(const OUString& rTokenName, 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 svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGSVGNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgsymbolnode.hxx b/svgio/inc/svgsymbolnode.hxx
new file mode 100644
index 000000000..516d17e18
--- /dev/null
+++ b/svgio/inc/svgsymbolnode.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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGSYMBOLNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGSYMBOLNODE_HXX
+
+#include "svgstyleattributes.hxx"
+
+namespace svgio
+{
+ namespace 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(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override;
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGSYMBOLNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtextnode.hxx b/svgio/inc/svgtextnode.hxx
new file mode 100644
index 000000000..999e99c2f
--- /dev/null
+++ b/svgio/inc/svgtextnode.hxx
@@ -0,0 +1,75 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGTEXTNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGTEXTNODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include "svgcharacternode.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <memory>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgTextNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::unique_ptr<basegfx::B2DHomMatrix>
+ mpaTransform;
+ SvgTextPositions maSvgTextPositions;
+
+ /// 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 const & rSource);
+
+ public:
+ SvgTextNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgTextNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ virtual double getCurrentFontSize() const override;
+
+ /// transform content, set if found in current context
+ const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGTEXTNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtextpathnode.hxx b/svgio/inc/svgtextpathnode.hxx
new file mode 100644
index 000000000..184f2b051
--- /dev/null
+++ b/svgio/inc/svgtextpathnode.hxx
@@ -0,0 +1,65 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGTEXTPATHNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGTEXTPATHNODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+
+namespace svgio
+{
+ namespace 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(const OUString& rTokenName, 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 svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGTEXTPATHNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtitledescnode.hxx b/svgio/inc/svgtitledescnode.hxx
new file mode 100644
index 000000000..713d5356d
--- /dev/null
+++ b/svgio/inc/svgtitledescnode.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 .
+ */
+#ifndef INCLUDED_SVGIO_INC_SVGTITLEDESCNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGTITLEDESCNODE_HXX
+
+#include "svgnode.hxx"
+
+
+namespace svgio
+{
+ namespace 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(const OUString& rChars);
+
+ /// x content, set if found in current context
+ const OUString& getText() const { return maText; }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+
+#endif // INCLUDED_SVGIO_INC_SVGTITLEDESCNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtoken.hxx b/svgio/inc/svgtoken.hxx
new file mode 100644
index 000000000..b03f28d29
--- /dev/null
+++ b/svgio/inc/svgtoken.hxx
@@ -0,0 +1,194 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGTOKEN_HXX
+#define INCLUDED_SVGIO_INC_SVGTOKEN_HXX
+
+#include <rtl/ustring.hxx>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ // SVG token mapper with hashing
+ enum SVGToken
+ {
+ SVGTokenUnknown = 0,
+
+ // diverse attribute tokens
+ SVGTokenWidth,
+ SVGTokenHeight,
+ SVGTokenViewBox,
+ SVGTokenTransform,
+ SVGTokenStyle,
+ SVGTokenDisplay, // #i121656#
+ SVGTokenD,
+ SVGTokenX,
+ SVGTokenY,
+ SVGTokenXmlns,
+ SVGTokenVersion,
+ SVGTokenId,
+ SVGTokenRx,
+ SVGTokenRy,
+ SVGTokenPoints,
+ SVGTokenDx,
+ SVGTokenDy,
+ SVGTokenRotate,
+ SVGTokenTextLength,
+ SVGTokenLengthAdjust,
+ SVGTokenFont,
+ SVGTokenFontFamily,
+ SVGTokenFontSize,
+ SVGTokenFontSizeAdjust,
+ SVGTokenFontStretch,
+ SVGTokenFontStyle,
+ SVGTokenFontVariant,
+ SVGTokenFontWeight,
+ SVGTokenDirection,
+ SVGTokenLetterSpacing,
+ SVGTokenTextDecoration,
+ SVGTokenUnicodeBidi,
+ SVGTokenWordSpacing,
+ SVGTokenCharacter, // not in the hash, just for simple text handling in SvgCharacterNode
+ SVGTokenTspan,
+ SVGTokenTref,
+ SVGTokenTextPath,
+ SVGTokenStartOffset,
+ SVGTokenMethod,
+ SVGTokenSpacing,
+ SVGTokenTextAlign,
+ SVGTokenPathLength,
+ SVGTokenType,
+ SVGTokenClass,
+ SVGTokenTextAnchor,
+ SVGTokenXmlSpace,
+ SVGTokenColor,
+ SVGTokenClipPathNode,
+ SVGTokenClipPathProperty,
+ SVGTokenMask,
+ SVGTokenClipPathUnits,
+ SVGTokenMaskUnits,
+ SVGTokenMaskContentUnits,
+ SVGTokenClipRule,
+ SVGTokenMarker,
+ SVGTokenMarkerStart,
+ SVGTokenMarkerMid,
+ SVGTokenMarkerEnd,
+ SVGTokenRefX,
+ SVGTokenRefY,
+ SVGTokenMarkerUnits,
+ SVGTokenMarkerWidth,
+ SVGTokenMarkerHeight,
+ SVGTokenOrient,
+ SVGTokenPattern,
+ SVGTokenPatternUnits,
+ SVGTokenPatternContentUnits,
+ SVGTokenPatternTransform,
+ SVGTokenOpacity,
+ SVGTokenVisibility,
+ SVGTokenTitle,
+ SVGTokenDesc,
+
+ // AspectRatio and params
+ SVGTokenPreserveAspectRatio,
+ SVGTokenDefer,
+ SVGTokenNone,
+ SVGTokenXMinYMin,
+ SVGTokenXMidYMin,
+ SVGTokenXMaxYMin,
+ SVGTokenXMinYMid,
+ SVGTokenXMidYMid,
+ SVGTokenXMaxYMid,
+ SVGTokenXMinYMax,
+ SVGTokenXMidYMax,
+ SVGTokenXMaxYMax,
+ SVGTokenMeet,
+ SVGTokenSlice,
+
+ // structural elements
+ SVGTokenDefs,
+ SVGTokenG,
+ SVGTokenSvg,
+ SVGTokenSymbol,
+ SVGTokenUse,
+ SVGTokenA,
+
+ // shape elements
+ SVGTokenCircle,
+ SVGTokenEllipse,
+ SVGTokenLine,
+ SVGTokenPath,
+ SVGTokenPolygon,
+ SVGTokenPolyline,
+ SVGTokenRect,
+ SVGTokenImage,
+
+ // gradient elements and tokens
+ SVGTokenLinearGradient,
+ SVGTokenRadialGradient,
+ SVGTokenStop,
+ SVGTokenOffset,
+ SVGTokenX1,
+ SVGTokenY1,
+ SVGTokenX2,
+ SVGTokenY2,
+ SVGTokenCx,
+ SVGTokenCy,
+ SVGTokenFx,
+ SVGTokenFy,
+ SVGTokenR,
+ SVGTokenGradientUnits,
+ SVGTokenGradientTransform,
+ SVGTokenSpreadMethod,
+ SVGTokenXlinkHref,
+ SVGTokenStopColor,
+ SVGTokenStopOpacity,
+
+ // fill tokens
+ SVGTokenFill,
+ SVGTokenFillOpacity,
+ SVGTokenFillRule,
+
+ // stroke tokens
+ SVGTokenStroke,
+ SVGTokenStrokeDasharray,
+ SVGTokenStrokeDashoffset,
+ SVGTokenStrokeLinecap,
+ SVGTokenStrokeLinejoin,
+ SVGTokenStrokeMiterlimit,
+ SVGTokenStrokeOpacity,
+ SVGTokenStrokeWidth,
+
+ // text tokens
+ SVGTokenText,
+ SVGTokenBaselineShift,
+
+ SVGTokenFlowRoot
+ };
+
+ SVGToken StrToSVGToken(const OUString& rStr, bool bCaseIndependent);
+
+ OUString getStrTitle();
+ OUString getStrDesc();
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGTOKEN_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtools.hxx b/svgio/inc/svgtools.hxx
new file mode 100644
index 000000000..215ea6e87
--- /dev/null
+++ b/svgio/inc/svgtools.hxx
@@ -0,0 +1,228 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGTOOLS_HXX
+#define INCLUDED_SVGIO_INC_SVGTOOLS_HXX
+
+#include <basegfx/color/bcolor.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/vector/b2ivector.hxx>
+#include <rtl/ustrbuf.hxx>
+#include "svgpaint.hxx"
+#include <vector>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+
+// recommended value for this device dependent unit, see CSS2 section 4.3.2 Lengths
+#define F_SVG_PIXEL_PER_INCH 96.0
+
+ // common non-token strings
+ struct commonStrings
+ {
+ static const OUString aStrUserSpaceOnUse;
+ static const OUString aStrObjectBoundingBox;
+ static const OUString aStrNonzero;
+ static const OUString aStrEvenOdd;
+ };
+
+ enum SvgUnits
+ {
+ userSpaceOnUse,
+ objectBoundingBox
+ };
+
+ enum 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 SvgUnit
+ {
+ Unit_em = 0, // relative to current font size
+ Unit_ex, // relative to current x-height
+
+ Unit_px, // 'user unit'
+ Unit_pt, // points, 1.25 px
+ Unit_pc, // 15.0 px
+ Unit_cm, // 35.43307 px
+ Unit_mm, // 3.543307 px
+ Unit_in, // 90 px
+
+ Unit_percent, // relative to range
+ Unit_none // for stroke-miterlimit, which has no unit
+ };
+
+ class SvgNumber
+ {
+ private:
+ double mfNumber;
+ SvgUnit meUnit;
+
+ bool mbSet : 1;
+
+ public:
+ SvgNumber()
+ : mfNumber(0.0),
+ meUnit(Unit_px),
+ mbSet(false)
+ {
+ }
+
+ SvgNumber(double fNum, SvgUnit aSvgUnit = Unit_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;
+
+ // Only usable in cases, when the unit is not Unit_percent, otherwise use method solve
+ double solveNonPercentage(const InfoProvider& rInfoProvider) const;
+
+ double solve(const InfoProvider& rInfoProvider, NumberType aNumberType = length) const;
+
+
+ };
+
+ typedef ::std::vector< SvgNumber > SvgNumberVector;
+
+ enum SvgAlign
+ {
+ Align_none,
+ Align_xMinYMin,
+ Align_xMidYMin,
+ Align_xMaxYMin,
+ Align_xMinYMid,
+ Align_xMidYMid, // default
+ Align_xMaxYMid,
+ Align_xMinYMax,
+ Align_xMidYMax,
+ Align_xMaxYMax
+ };
+
+ class SvgAspectRatio
+ {
+ private:
+ SvgAlign maSvgAlign;
+
+ bool mbMeetOrSlice : 1; // true = meet (default), false = slice
+ bool mbSet : 1;
+
+ public:
+ SvgAspectRatio()
+ : maSvgAlign(Align_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(const OUString& rCandidate, sal_Unicode aChar, sal_Int32& nPos, const sal_Int32 nLen);
+ void skip_char(const OUString& rCandidate, sal_Unicode aCharA, sal_Unicode nCharB, sal_Int32& nPos, const sal_Int32 nLen);
+ void copySign(const OUString& rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen);
+ void copyNumber(const OUString& rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen);
+ void copyHex(const OUString& rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen);
+ void copyString(const OUString& rCandidate, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen);
+ void copyToLimiter(const OUString& rCandidate, sal_Unicode aLimiter, sal_Int32& nPos, OUStringBuffer& rTarget, const sal_Int32 nLen);
+ bool readNumber(const OUString& rCandidate, sal_Int32& nPos, double& fNum, const sal_Int32 nLen);
+ SvgUnit readUnit(const OUString& rCandidate, sal_Int32& nPos, const sal_Int32 nLen);
+ bool readNumberAndUnit(const OUString& rCandidate, sal_Int32& nPos, SvgNumber& aNum, const sal_Int32 nLen);
+ bool readAngle(const OUString& 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 bCaseIndependent);
+ bool read_color(const OUString& rCandidate, basegfx::BColor& rColor, bool bCaseIndependent, SvgNumber& rOpacity);
+ basegfx::B2DRange readViewBox(const OUString& rCandidate, InfoProvider const & rInfoProvider);
+ basegfx::B2DHomMatrix readTransform(const OUString& rCandidate, InfoProvider const & rInfoProvider);
+ bool readSingleNumber(const OUString& rCandidate, SvgNumber& aNum);
+ bool readLocalUrl(const OUString& rCandidate, OUString& rURL);
+ bool readSvgPaint(const OUString& rCandidate, SvgPaint& rSvgPaint, OUString& rURL, bool bCaseIndependent, SvgNumber& rOpacity);
+
+ bool readSvgNumberVector(const OUString& rCandidate, SvgNumberVector& rSvgNumberVector);
+ ::std::vector< double > solveSvgNumberVector(const SvgNumberVector& rInput, const InfoProvider& rInfoProvider);
+
+ SvgAspectRatio readSvgAspectRatio(const OUString& rCandidate);
+
+ typedef ::std::vector< OUString > SvgStringVector;
+ bool readSvgStringVector(const OUString& rCandidate, SvgStringVector& rSvgStringVector);
+
+ void readImageLink(const OUString& rCandidate, OUString& rXLink, OUString& rUrl, OUString& rMimeType, OUString& rData);
+
+ OUString convert(const OUString& rCandidate, sal_Unicode nPattern, sal_Unicode nNew, bool bRemove);
+ OUString consolidateContiguousSpace(const OUString& rCandidate);
+ OUString whiteSpaceHandlingDefault(const OUString& rCandidate);
+ OUString whiteSpaceHandlingPreserve(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 svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGTOOLS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtrefnode.hxx b/svgio/inc/svgtrefnode.hxx
new file mode 100644
index 000000000..f6e1686b8
--- /dev/null
+++ b/svgio/inc/svgtrefnode.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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGTREFNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGTREFNODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include "svgtextnode.hxx"
+
+namespace svgio
+{
+ namespace 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(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override;
+
+ /// access to referenced SvgTextNode
+ const SvgTextNode* getReferencedSvgTextNode() const;
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGTREFNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgtspannode.hxx b/svgio/inc/svgtspannode.hxx
new file mode 100644
index 000000000..b6238d0f5
--- /dev/null
+++ b/svgio/inc/svgtspannode.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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGTSPANNODE_HXX
+#define INCLUDED_SVGIO_INC_SVGTSPANNODE_HXX
+
+#include "svgcharacternode.hxx"
+#include "svgstyleattributes.hxx"
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgTspanNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ SvgTextPositions maSvgTextPositions;
+
+ public:
+ SvgTspanNode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgTspanNode() override;
+
+ virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
+ virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override;
+
+ virtual double getCurrentFontSize() const override;
+
+ /// access to SvgTextPositions
+ const SvgTextPositions& getSvgTextPositions() const { return maSvgTextPositions; }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGTSPANNODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgusenode.hxx b/svgio/inc/svgusenode.hxx
new file mode 100644
index 000000000..f864791f7
--- /dev/null
+++ b/svgio/inc/svgusenode.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 .
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGUSENODE_HXX
+#define INCLUDED_SVGIO_INC_SVGUSENODE_HXX
+
+#include "svgnode.hxx"
+#include "svgstyleattributes.hxx"
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <memory>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgUseNode final : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ std::unique_ptr<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(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override;
+ virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
+
+ /// transform content
+ const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
+
+ /// x content
+ const SvgNumber& getX() const { return maX; }
+
+ /// y content
+ const SvgNumber& getY() const { return maY; }
+
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGUSENODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgvisitor.hxx b/svgio/inc/svgvisitor.hxx
new file mode 100644
index 000000000..d643a2a20
--- /dev/null
+++ b/svgio/inc/svgvisitor.hxx
@@ -0,0 +1,41 @@
+/* -*- 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/.
+ *
+ */
+
+#ifndef INCLUDED_SVGIO_INC_SVGVISITOR_HXX
+#define INCLUDED_SVGIO_INC_SVGVISITOR_HXX
+
+#include <basegfx/DrawCommands.hxx>
+#include <memory>
+#include "svgnode.hxx"
+
+namespace svgio
+{
+namespace 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; }
+};
+}
+}
+
+#endif // INCLUDED_SVGIO_INC_SVGVISITOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */