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 <svgmarkernode.hxx>
21 #include <o3tl/string_view.hxx>
23 namespace svgio::svgreader
25 SvgMarkerNode::SvgMarkerNode(
26 SvgDocument
& rDocument
,
28 : SvgNode(SVGToken::Marker
, rDocument
, pParent
),
29 maSvgStyleAttributes(*this),
32 maMarkerUnits(MarkerUnits::strokeWidth
),
36 maMarkerOrient(MarkerOrient::notset
)
40 SvgMarkerNode::~SvgMarkerNode()
44 const SvgStyleAttributes
* SvgMarkerNode::getSvgStyleAttributes() const
46 return checkForCssStyle("marker", maSvgStyleAttributes
);
49 void SvgMarkerNode::parseAttribute(const OUString
& rTokenName
, SVGToken aSVGToken
, const OUString
& aContent
)
52 SvgNode::parseAttribute(rTokenName
, aSVGToken
, aContent
);
54 // read style attributes
55 maSvgStyleAttributes
.parseStyleAttribute(aSVGToken
, aContent
);
62 readLocalCssStyle(aContent
);
65 case SVGToken::ViewBox
:
67 const basegfx::B2DRange
aRange(readViewBox(aContent
, *this));
75 case SVGToken::PreserveAspectRatio
:
77 maSvgAspectRatio
= readSvgAspectRatio(aContent
);
84 if(readSingleNumber(aContent
, aNum
))
94 if(readSingleNumber(aContent
, aNum
))
100 case SVGToken::MarkerUnits
:
102 if(!aContent
.isEmpty())
104 if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent
), u
"strokeWidth"))
106 setMarkerUnits(MarkerUnits::strokeWidth
);
108 else if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent
), commonStrings::aStrUserSpaceOnUse
))
110 setMarkerUnits(MarkerUnits::userSpaceOnUse
);
115 case SVGToken::MarkerWidth
:
119 if(readSingleNumber(aContent
, aNum
))
121 if(aNum
.isPositive())
123 maMarkerWidth
= aNum
;
128 case SVGToken::MarkerHeight
:
132 if(readSingleNumber(aContent
, aNum
))
134 if(aNum
.isPositive())
136 maMarkerHeight
= aNum
;
141 case SVGToken::Orient
:
143 const sal_Int32
nLen(aContent
.getLength());
147 if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent
), u
"auto"))
149 setMarkerOrient(MarkerOrient::auto_start
);
151 else if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent
), u
"auto-start-reverse"))
153 setMarkerOrient(MarkerOrient::auto_start_reverse
);
160 if(readAngle(aContent
, nPos
, fAngle
, nLen
))
175 const drawinglayer::primitive2d::Primitive2DContainer
& SvgMarkerNode::getMarkerPrimitives() const
177 if(aPrimitives
.empty() && Display::None
!= getDisplay())
179 decomposeSvgNode(const_cast< SvgMarkerNode
* >(this)->aPrimitives
, true);
185 basegfx::B2DRange
SvgMarkerNode::getCurrentViewPort() const
189 return *(getViewBox());
193 return SvgNode::getCurrentViewPort();
197 } // end of namespace svgio::svgreader
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */