LibreOffice Module svgio (master) 1
svgpolynode.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <svgpolynode.hxx>
24
25namespace svgio::svgreader
26{
28 SVGToken aType,
29 SvgDocument& rDocument,
30 SvgNode* pParent)
31 : SvgNode(aType, rDocument, pParent),
32 maSvgStyleAttributes(*this)
33 {
34 }
35
37 {
38 }
39
41 {
43 }
44
45 void SvgPolyNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
46 {
47 // call parent
48 SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
49
50 // read style attributes
51 maSvgStyleAttributes.parseStyleAttribute(aSVGToken, aContent);
52
53 // parse own
54 switch(aSVGToken)
55 {
56 case SVGToken::Style:
57 {
58 readLocalCssStyle(aContent);
59 break;
60 }
62 {
64
65 if(basegfx::utils::importFromSvgPoints(aPath, aContent))
66 {
67 if(aPath.count())
68 {
70 {
71 aPath.setClosed(true);
72 }
73
74 setPolygon(aPath);
75 }
76 }
77 break;
78 }
80 {
81 const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
82
83 if(!aMatrix.isIdentity())
84 {
85 setTransform(aMatrix);
86 }
87 break;
88 }
89 default:
90 {
91 break;
92 }
93 }
94 }
95
97 {
99
100 if(pStyle && mpPolygon)
101 {
103
104 pStyle->add_path(basegfx::B2DPolyPolygon(*mpPolygon), aNewTarget, nullptr);
105
106 if(!aNewTarget.empty())
107 {
108 pStyle->add_postProcess(rTarget, std::move(aNewTarget), getTransform());
109 }
110 }
111 }
112} // end of namespace svgio::svgreader
113
114/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool isIdentity() const
sal_uInt32 count() const
void setClosed(bool bNew)
SVGToken getType() const
basic data read access
Definition: svgnode.hxx:156
const SvgStyleAttributes * checkForCssStyle(const SvgStyleAttributes &rOriginal) const
helper to evtl. link to css style
Definition: svgnode.cxx:335
virtual void parseAttribute(const OUString &rTokenName, SVGToken aSVGToken, const OUString &aContent)
Definition: svgnode.cxx:534
void readLocalCssStyle(std::u16string_view aContent)
scan helper to read and interpret a local CssStyle to mpLocalCssStyle
Definition: svgnode.cxx:412
void setTransform(const std::optional< basegfx::B2DHomMatrix > &pMatrix)
Definition: svgpolynode.hxx:56
std::optional< basegfx::B2DPolygon > mpPolygon
variable scan values, dependent of given XAttributeList
Definition: svgpolynode.hxx:37
void setPolygon(const std::optional< basegfx::B2DPolygon > &pPolygon)
Polygon content, set if found in current context.
Definition: svgpolynode.hxx:52
const std::optional< basegfx::B2DHomMatrix > & getTransform() const
transform content, set if found in current context
Definition: svgpolynode.hxx:55
SvgPolyNode(SVGToken aType, SvgDocument &rDocument, SvgNode *pParent)
Definition: svgpolynode.cxx:27
SvgStyleAttributes maSvgStyleAttributes
use styles
Definition: svgpolynode.hxx:34
virtual void parseAttribute(const OUString &rTokenName, SVGToken aSVGToken, const OUString &aContent) override
Definition: svgpolynode.cxx:45
virtual const SvgStyleAttributes * getSvgStyleAttributes() const override
Definition: svgpolynode.cxx:40
virtual ~SvgPolyNode() override
Definition: svgpolynode.cxx:36
virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer &rTarget, bool bReferenced) const override
Definition: svgpolynode.cxx:96
void add_postProcess(drawinglayer::primitive2d::Primitive2DContainer &rTarget, drawinglayer::primitive2d::Primitive2DContainer &&rSource, const std::optional< basegfx::B2DHomMatrix > &pTransform) const
void add_path(const basegfx::B2DPolyPolygon &rPath, drawinglayer::primitive2d::Primitive2DContainer &rTarget, const basegfx::utils::PointIndexSet *pHelpPointIndices) const
void parseStyleAttribute(SVGToken aSVGToken, const OUString &rContent)
local attribute scanner
FilterGroup & rTarget
bool importFromSvgPoints(B2DPolygon &o_rPoly, std::u16string_view rSvgPointsAttribute)
basegfx::B2DHomMatrix readTransform(std::u16string_view rCandidate, InfoProvider const &rInfoProvider)
Definition: svgtools.cxx:871