Fix rudimentary Emscripten Qt6 copy -> paste support
[LibreOffice.git] / svgio / source / svgreader / svgpolynode.cxx
blob30ab7ed31185ed1b63b2d56b8342e35e222c1e10
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 SVGToken aType,
29 SvgDocument& rDocument,
30 SvgNode* pParent)
31 : SvgNode(aType, rDocument, pParent),
32 maSvgStyleAttributes(*this)
36 SvgPolyNode::~SvgPolyNode()
40 const SvgStyleAttributes* SvgPolyNode::getSvgStyleAttributes() const
42 return checkForCssStyle(maSvgStyleAttributes);
45 void SvgPolyNode::parseAttribute(SVGToken aSVGToken, const OUString& aContent)
47 // call parent
48 SvgNode::parseAttribute(aSVGToken, aContent);
50 // read style attributes
51 maSvgStyleAttributes.parseStyleAttribute(aSVGToken, aContent);
53 // parse own
54 switch(aSVGToken)
56 case SVGToken::Style:
58 readLocalCssStyle(aContent);
59 break;
61 case SVGToken::Points:
63 basegfx::B2DPolygon aPath;
65 if(basegfx::utils::importFromSvgPoints(aPath, aContent))
67 if(aPath.count())
69 if(getType() == SVGToken::Polygon)
71 aPath.setClosed(true);
74 setPolygon(aPath);
77 break;
79 case SVGToken::Transform:
81 const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
83 if(!aMatrix.isIdentity())
85 setTransform(aMatrix);
87 break;
89 default:
91 break;
96 void SvgPolyNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool /*bReferenced*/) const
98 const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
100 if(pStyle && mpPolygon)
102 drawinglayer::primitive2d::Primitive2DContainer aNewTarget;
104 pStyle->add_path(basegfx::B2DPolyPolygon(*mpPolygon), aNewTarget, nullptr);
106 if(!aNewTarget.empty())
108 pStyle->add_postProcess(rTarget, std::move(aNewTarget), getTransform());
112 } // end of namespace svgio::svgreader
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */