calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / svgio / source / svgreader / svgmarkernode.cxx
blob9cc1cee6ce17f7d9924295099813578511ea9b98
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 <svgmarkernode.hxx>
21 #include <o3tl/string_view.hxx>
23 namespace svgio::svgreader
25 SvgMarkerNode::SvgMarkerNode(
26 SvgDocument& rDocument,
27 SvgNode* pParent)
28 : SvgNode(SVGToken::Marker, rDocument, pParent),
29 maSvgStyleAttributes(*this),
30 maRefX(0),
31 maRefY(0),
32 maMarkerUnits(MarkerUnits::strokeWidth),
33 maMarkerWidth(3),
34 maMarkerHeight(3),
35 mfAngle(0.0),
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)
51 // call parent
52 SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
54 // read style attributes
55 maSvgStyleAttributes.parseStyleAttribute(aSVGToken, aContent);
57 // parse own
58 switch(aSVGToken)
60 case SVGToken::Style:
62 readLocalCssStyle(aContent);
63 break;
65 case SVGToken::ViewBox:
67 const basegfx::B2DRange aRange(readViewBox(aContent, *this));
69 if(!aRange.isEmpty())
71 setViewBox(&aRange);
73 break;
75 case SVGToken::PreserveAspectRatio:
77 maSvgAspectRatio = readSvgAspectRatio(aContent);
78 break;
80 case SVGToken::RefX:
82 SvgNumber aNum;
84 if(readSingleNumber(aContent, aNum))
86 maRefX = aNum;
88 break;
90 case SVGToken::RefY:
92 SvgNumber aNum;
94 if(readSingleNumber(aContent, aNum))
96 maRefY = aNum;
98 break;
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);
113 break;
115 case SVGToken::MarkerWidth:
117 SvgNumber aNum;
119 if(readSingleNumber(aContent, aNum))
121 if(aNum.isPositive())
123 maMarkerWidth = aNum;
126 break;
128 case SVGToken::MarkerHeight:
130 SvgNumber aNum;
132 if(readSingleNumber(aContent, aNum))
134 if(aNum.isPositive())
136 maMarkerHeight = aNum;
139 break;
141 case SVGToken::Orient:
143 const sal_Int32 nLen(aContent.getLength());
145 if(nLen)
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);
155 else
157 sal_Int32 nPos(0);
158 double fAngle(0.0);
160 if(readAngle(aContent, nPos, fAngle, nLen))
162 setAngle(fAngle);
166 break;
168 default:
170 break;
175 const drawinglayer::primitive2d::Primitive2DContainer& SvgMarkerNode::getMarkerPrimitives() const
177 if(aPrimitives.empty() && Display::None != getDisplay())
179 decomposeSvgNode(const_cast< SvgMarkerNode* >(this)->aPrimitives, true);
182 return aPrimitives;
185 basegfx::B2DRange SvgMarkerNode::getCurrentViewPort() const
187 if(getViewBox())
189 return *(getViewBox());
191 else
193 return SvgNode::getCurrentViewPort();
197 } // end of namespace svgio::svgreader
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */