lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / svgio / source / svgreader / svgmarkernode.cxx
blob35ac4fff1662d31c5a75f9f51ecc7d0b6698c106
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>
22 namespace svgio
24 namespace svgreader
26 SvgMarkerNode::SvgMarkerNode(
27 SvgDocument& rDocument,
28 SvgNode* pParent)
29 : SvgNode(SVGTokenMarker, rDocument, pParent),
30 aPrimitives(),
31 maSvgStyleAttributes(*this),
32 maSvgAspectRatio(),
33 maRefX(0),
34 maRefY(0),
35 maMarkerUnits(MarkerUnits::strokeWidth),
36 maMarkerWidth(3),
37 maMarkerHeight(3),
38 mfAngle(0.0),
39 mbOrientAuto(false)
43 SvgMarkerNode::~SvgMarkerNode()
47 const SvgStyleAttributes* SvgMarkerNode::getSvgStyleAttributes() const
49 return checkForCssStyle("marker", maSvgStyleAttributes);
52 void SvgMarkerNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
54 // call parent
55 SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
57 // read style attributes
58 maSvgStyleAttributes.parseStyleAttribute(aSVGToken, aContent, false);
60 // parse own
61 switch(aSVGToken)
63 case SVGTokenStyle:
65 readLocalCssStyle(aContent);
66 break;
68 case SVGTokenViewBox:
70 const basegfx::B2DRange aRange(readViewBox(aContent, *this));
72 if(!aRange.isEmpty())
74 setViewBox(&aRange);
76 break;
78 case SVGTokenPreserveAspectRatio:
80 maSvgAspectRatio = readSvgAspectRatio(aContent);
81 break;
83 case SVGTokenRefX:
85 SvgNumber aNum;
87 if(readSingleNumber(aContent, aNum))
89 maRefX = aNum;
91 break;
93 case SVGTokenRefY:
95 SvgNumber aNum;
97 if(readSingleNumber(aContent, aNum))
99 maRefY = aNum;
101 break;
103 case SVGTokenMarkerUnits:
105 if(!aContent.isEmpty())
107 if(aContent.startsWith("strokeWidth"))
109 setMarkerUnits(MarkerUnits::strokeWidth);
111 else if(aContent.match(commonStrings::aStrUserSpaceOnUse))
113 setMarkerUnits(MarkerUnits::userSpaceOnUse);
116 break;
118 case SVGTokenMarkerWidth:
120 SvgNumber aNum;
122 if(readSingleNumber(aContent, aNum))
124 if(aNum.isPositive())
126 maMarkerWidth = aNum;
129 break;
131 case SVGTokenMarkerHeight:
133 SvgNumber aNum;
135 if(readSingleNumber(aContent, aNum))
137 if(aNum.isPositive())
139 maMarkerHeight = aNum;
142 break;
144 case SVGTokenOrient:
146 const sal_Int32 nLen(aContent.getLength());
148 if(nLen)
150 if(aContent.startsWith("auto"))
152 mbOrientAuto = true;
154 else
156 sal_Int32 nPos(0);
157 double fAngle(0.0);
159 if(readAngle(aContent, nPos, fAngle, nLen))
161 setAngle(fAngle);
165 break;
167 default:
169 break;
174 const drawinglayer::primitive2d::Primitive2DContainer& SvgMarkerNode::getMarkerPrimitives() const
176 if(aPrimitives.empty() && Display_none != getDisplay())
178 decomposeSvgNode(const_cast< SvgMarkerNode* >(this)->aPrimitives, true);
181 return aPrimitives;
184 const basegfx::B2DRange SvgMarkerNode::getCurrentViewPort() const
186 if(getViewBox())
188 return *(getViewBox());
190 else
192 return SvgNode::getCurrentViewPort();
196 } // end of namespace svgreader
197 } // end of namespace svgio
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */