1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svgpolynode.hxx>
21 #include <basegfx/polygon/b2dpolygon.hxx>
22 #include <basegfx/polygon/b2dpolygontools.hxx>
23 #include <basegfx/polygon/b2dpolypolygon.hxx>
25 namespace svgio::svgreader
27 SvgPolyNode::SvgPolyNode(
28 SvgDocument
& rDocument
,
31 : SvgNode(SVGToken::Polygon
, rDocument
, pParent
),
32 maSvgStyleAttributes(*this),
33 mbIsPolyline(bIsPolyline
)
37 SvgPolyNode::~SvgPolyNode()
41 const SvgStyleAttributes
* SvgPolyNode::getSvgStyleAttributes() const
43 return checkForCssStyle(mbIsPolyline
? OUString("polyline") : OUString("polygon"), maSvgStyleAttributes
);
46 void SvgPolyNode::parseAttribute(const OUString
& rTokenName
, SVGToken aSVGToken
, const OUString
& aContent
)
49 SvgNode::parseAttribute(rTokenName
, aSVGToken
, aContent
);
51 // read style attributes
52 maSvgStyleAttributes
.parseStyleAttribute(aSVGToken
, aContent
, false);
59 readLocalCssStyle(aContent
);
62 case SVGToken::Points
:
64 basegfx::B2DPolygon aPath
;
66 if(basegfx::utils::importFromSvgPoints(aPath
, aContent
))
72 aPath
.setClosed(true);
80 case SVGToken::Transform
:
82 const basegfx::B2DHomMatrix
aMatrix(readTransform(aContent
, *this));
84 if(!aMatrix
.isIdentity())
86 setTransform(&aMatrix
);
97 void SvgPolyNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer
& rTarget
, bool /*bReferenced*/) const
99 const SvgStyleAttributes
* pStyle
= getSvgStyleAttributes();
101 if(pStyle
&& mpPolygon
)
103 drawinglayer::primitive2d::Primitive2DContainer aNewTarget
;
105 pStyle
->add_path(basegfx::B2DPolyPolygon(*mpPolygon
), aNewTarget
, nullptr);
107 if(!aNewTarget
.empty())
109 pStyle
->add_postProcess(rTarget
, aNewTarget
, getTransform());
113 } // end of namespace svgio::svgreader
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */