Kaydet (Commit) 57de8158 authored tarafından Xisco Fauli's avatar Xisco Fauli Kaydeden (comit) Xisco Faulí

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/22822Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarXisco Faulí <anistenis@gmail.com>
üst ad82b7ba
...@@ -51,6 +51,7 @@ $(eval $(call gb_Library_add_exception_objects,svgio,\ ...@@ -51,6 +51,7 @@ $(eval $(call gb_Library_add_exception_objects,svgio,\
svgio/source/svgreader/svgdocumenthandler \ svgio/source/svgreader/svgdocumenthandler \
svgio/source/svgreader/svgellipsenode \ svgio/source/svgreader/svgellipsenode \
svgio/source/svgreader/svggnode \ svgio/source/svgreader/svggnode \
svgio/source/svgreader/svganode \
svgio/source/svgreader/svggradientnode \ svgio/source/svgreader/svggradientnode \
svgio/source/svgreader/svggradientstopnode \ svgio/source/svgreader/svggradientstopnode \
svgio/source/svgreader/svgimagenode \ svgio/source/svgreader/svgimagenode \
......
/* -*- 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: */
...@@ -127,6 +127,7 @@ namespace svgio ...@@ -127,6 +127,7 @@ namespace svgio
SVGTokenSvg, SVGTokenSvg,
SVGTokenSymbol, SVGTokenSymbol,
SVGTokenUse, SVGTokenUse,
SVGTokenA,
// shape elements // shape elements
SVGTokenCircle, SVGTokenCircle,
......
/* -*- 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: */
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <svgio/svgreader/svgtoken.hxx> #include <svgio/svgreader/svgtoken.hxx>
#include <svgio/svgreader/svgsvgnode.hxx> #include <svgio/svgreader/svgsvgnode.hxx>
#include <svgio/svgreader/svggnode.hxx> #include <svgio/svgreader/svggnode.hxx>
#include <svgio/svgreader/svganode.hxx>
#include <svgio/svgreader/svgnode.hxx> #include <svgio/svgreader/svgnode.hxx>
#include <svgio/svgreader/svgpathnode.hxx> #include <svgio/svgreader/svgpathnode.hxx>
#include <svgio/svgreader/svgrectnode.hxx> #include <svgio/svgreader/svgrectnode.hxx>
...@@ -206,6 +207,13 @@ namespace svgio ...@@ -206,6 +207,13 @@ namespace svgio
mpTarget->parseAttributes(xAttribs); mpTarget->parseAttributes(xAttribs);
break; break;
} }
case SVGTokenA:
{
/// new node for A
mpTarget = new SvgANode(maDocument, mpTarget);
mpTarget->parseAttributes(xAttribs);
break;
}
/// shape elements /// shape elements
case SVGTokenCircle: case SVGTokenCircle:
...@@ -427,6 +435,7 @@ namespace svgio ...@@ -427,6 +435,7 @@ namespace svgio
case SVGTokenSvg: case SVGTokenSvg:
case SVGTokenSymbol: case SVGTokenSymbol:
case SVGTokenUse: case SVGTokenUse:
case SVGTokenA:
/// shape elements /// shape elements
case SVGTokenCircle: case SVGTokenCircle:
......
...@@ -116,6 +116,7 @@ namespace svgio ...@@ -116,6 +116,7 @@ namespace svgio
static const char aSVGStrSvg[] = "svg"; static const char aSVGStrSvg[] = "svg";
static const char aSVGStrSymbol[] = "symbol"; static const char aSVGStrSymbol[] = "symbol";
static const char aSVGStrUse[] = "use"; static const char aSVGStrUse[] = "use";
static const char aSVGStrA[] = "a";
static const char aSVGStrCircle[] = "circle"; static const char aSVGStrCircle[] = "circle";
static const char aSVGStrEllipse[] = "ellipse"; static const char aSVGStrEllipse[] = "ellipse";
...@@ -264,6 +265,7 @@ namespace svgio ...@@ -264,6 +265,7 @@ namespace svgio
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrSvg, SVGTokenSvg)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrSvg, SVGTokenSvg));
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrSymbol, SVGTokenSymbol)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrSymbol, SVGTokenSymbol));
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrUse, SVGTokenUse)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrUse, SVGTokenUse));
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrA, SVGTokenA));
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrCircle, SVGTokenCircle)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrCircle, SVGTokenCircle));
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrEllipse, SVGTokenEllipse)); aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrEllipse, SVGTokenEllipse));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment