summaryrefslogtreecommitdiffstats
path: root/svgio
diff options
context:
space:
mode:
authorXisco Fauli <anistenis@gmail.com>2016-03-02 00:45:14 +0100
committerXisco FaulĂ­ <anistenis@gmail.com>2016-03-03 08:50:40 +0000
commit57de81580dc3a9c53c43871150109181da1bb646 (patch)
tree9427d041385fbab81e593c6172efafddca4755ba /svgio
parentstarmath: Drop ENABLE_DEBUG_DUMPASDOT feature (diff)
downloadcore-57de81580dc3a9c53c43871150109181da1bb646.tar.gz
core-57de81580dc3a9c53c43871150109181da1bb646.zip
tdf#98113: SVGIO: Add SvgANode class to handle transport ...
... attribute in anchor elements. I used Svggnode class a a reference for this. Change-Id: Id2a58bd913f9984dc91163ca0f333c016aa981f1 Reviewed-on: https://gerrit.libreoffice.org/22822 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Xisco FaulĂ­ <anistenis@gmail.com>
Diffstat (limited to 'svgio')
-rw-r--r--svgio/Library_svgio.mk1
-rw-r--r--svgio/inc/svgio/svgreader/svganode.hxx58
-rw-r--r--svgio/inc/svgio/svgreader/svgtoken.hxx1
-rw-r--r--svgio/source/svgreader/svganode.cxx109
-rw-r--r--svgio/source/svgreader/svgdocumenthandler.cxx9
-rw-r--r--svgio/source/svgreader/svgtoken.cxx2
6 files changed, 180 insertions, 0 deletions
diff --git a/svgio/Library_svgio.mk b/svgio/Library_svgio.mk
index bea40ebc1fa2..3ba1891d691b 100644
--- a/svgio/Library_svgio.mk
+++ b/svgio/Library_svgio.mk
@@ -51,6 +51,7 @@ $(eval $(call gb_Library_add_exception_objects,svgio,\
svgio/source/svgreader/svgdocumenthandler \
svgio/source/svgreader/svgellipsenode \
svgio/source/svgreader/svggnode \
+ svgio/source/svgreader/svganode \
svgio/source/svgreader/svggradientnode \
svgio/source/svgreader/svggradientstopnode \
svgio/source/svgreader/svgimagenode \
diff --git a/svgio/inc/svgio/svgreader/svganode.hxx b/svgio/inc/svgio/svgreader/svganode.hxx
new file mode 100644
index 000000000000..d58224a120da
--- /dev/null
+++ b/svgio/inc/svgio/svgreader/svganode.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_SVGIO_SVGREADER_SVGANODE_HXX
+#define INCLUDED_SVGIO_INC_SVGIO_SVGREADER_SVGANODE_HXX
+
+#include <svgio/svgreader/svgnode.hxx>
+#include <svgio/svgreader/svgstyleattributes.hxx>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ class SvgANode : public SvgNode
+ {
+ private:
+ /// use styles
+ SvgStyleAttributes maSvgStyleAttributes;
+
+ /// variable scan values, dependent of given XAttributeList
+ basegfx::B2DHomMatrix* mpaTransform;
+
+ public:
+ SvgANode(
+ SvgDocument& rDocument,
+ SvgNode* pParent);
+ virtual ~SvgANode();
+
+ 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; }
+ void setTransform(const basegfx::B2DHomMatrix* pMatrix = nullptr) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
+ };
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+#endif // INCLUDED_SVGIO_INC_SVGIO_SVGREADER_SVGANODE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/inc/svgio/svgreader/svgtoken.hxx b/svgio/inc/svgio/svgreader/svgtoken.hxx
index adc6783c7704..112102f8b4cc 100644
--- a/svgio/inc/svgio/svgreader/svgtoken.hxx
+++ b/svgio/inc/svgio/svgreader/svgtoken.hxx
@@ -127,6 +127,7 @@ namespace svgio
SVGTokenSvg,
SVGTokenSymbol,
SVGTokenUse,
+ SVGTokenA,
// shape elements
SVGTokenCircle,
diff --git a/svgio/source/svgreader/svganode.cxx b/svgio/source/svgreader/svganode.cxx
new file mode 100644
index 000000000000..70c53d5c0a6f
--- /dev/null
+++ b/svgio/source/svgreader/svganode.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svgio/svgreader/svganode.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
+
+namespace svgio
+{
+ namespace svgreader
+ {
+ SvgANode::SvgANode(
+ SvgDocument& rDocument,
+ SvgNode* pParent)
+ : SvgNode(SVGTokenA, rDocument, pParent),
+ maSvgStyleAttributes(*this),
+ mpaTransform(nullptr)
+ {
+ }
+
+ SvgANode::~SvgANode()
+ {
+ delete mpaTransform;
+ }
+
+ const SvgStyleAttributes* SvgANode::getSvgStyleAttributes() const
+ {
+ return checkForCssStyle("a", maSvgStyleAttributes);
+ }
+
+ void SvgANode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
+ {
+ // call parent
+ SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
+
+ // read style attributes
+ maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
+
+ // parse own
+ switch(aSVGToken)
+ {
+ case SVGTokenStyle:
+ {
+ readLocalCssStyle(aContent);
+ break;
+ }
+ case SVGTokenTransform:
+ {
+ const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
+
+ if(!aMatrix.isIdentity())
+ {
+ setTransform(&aMatrix);
+ }
+ break;
+ }
+ case SVGTokenXlinkHref:
+ //TODO: add support for xlink:href
+ break;
+ default:
+ {
+ break;
+ }
+ }
+ }
+
+ void SvgANode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const
+ {
+ // #i125258# for SVGTokenA decompose children
+ const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
+
+ if(pStyle)
+ {
+ const double fOpacity(pStyle->getOpacity().getNumber());
+
+ if(fOpacity > 0.0 && Display_none != getDisplay())
+ {
+ drawinglayer::primitive2d::Primitive2DContainer aContent;
+
+ // decompose children
+ SvgNode::decomposeSvgNode(aContent, bReferenced);
+
+ if(!aContent.empty())
+ {
+ pStyle->add_postProcess(rTarget, aContent, getTransform());
+ }
+ }
+ }
+ }
+ } // end of namespace svgreader
+} // end of namespace svgio
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx b/svgio/source/svgreader/svgdocumenthandler.cxx
index e35a5713a76e..e53471d59839 100644
--- a/svgio/source/svgreader/svgdocumenthandler.cxx
+++ b/svgio/source/svgreader/svgdocumenthandler.cxx
@@ -21,6 +21,7 @@
#include <svgio/svgreader/svgtoken.hxx>
#include <svgio/svgreader/svgsvgnode.hxx>
#include <svgio/svgreader/svggnode.hxx>
+#include <svgio/svgreader/svganode.hxx>
#include <svgio/svgreader/svgnode.hxx>
#include <svgio/svgreader/svgpathnode.hxx>
#include <svgio/svgreader/svgrectnode.hxx>
@@ -206,6 +207,13 @@ namespace svgio
mpTarget->parseAttributes(xAttribs);
break;
}
+ case SVGTokenA:
+ {
+ /// new node for A
+ mpTarget = new SvgANode(maDocument, mpTarget);
+ mpTarget->parseAttributes(xAttribs);
+ break;
+ }
/// shape elements
case SVGTokenCircle:
@@ -427,6 +435,7 @@ namespace svgio
case SVGTokenSvg:
case SVGTokenSymbol:
case SVGTokenUse:
+ case SVGTokenA:
/// shape elements
case SVGTokenCircle:
diff --git a/svgio/source/svgreader/svgtoken.cxx b/svgio/source/svgreader/svgtoken.cxx
index 945b04588c0e..4c40054182d2 100644
--- a/svgio/source/svgreader/svgtoken.cxx
+++ b/svgio/source/svgreader/svgtoken.cxx
@@ -116,6 +116,7 @@ namespace svgio
static const char aSVGStrSvg[] = "svg";
static const char aSVGStrSymbol[] = "symbol";
static const char aSVGStrUse[] = "use";
+ static const char aSVGStrA[] = "a";
static const char aSVGStrCircle[] = "circle";
static const char aSVGStrEllipse[] = "ellipse";
@@ -264,6 +265,7 @@ namespace svgio
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrSvg, SVGTokenSvg));
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrSymbol, SVGTokenSymbol));
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrUse, SVGTokenUse));
+ aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrA, SVGTokenA));
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrCircle, SVGTokenCircle));
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrEllipse, SVGTokenEllipse));