bump product version to 4.1.6.2
[LibreOffice.git] / svgio / source / svgreader / svgmarkernode.cxx
blobe79b0f07c3ad59709880db508f115512b3bdf25b
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 <svgio/svgreader/svgmarkernode.hxx>
22 //////////////////////////////////////////////////////////////////////////////
24 namespace svgio
26 namespace svgreader
28 SvgMarkerNode::SvgMarkerNode(
29 SvgDocument& rDocument,
30 SvgNode* pParent)
31 : SvgNode(SVGTokenMarker, rDocument, pParent),
32 aPrimitives(),
33 maSvgStyleAttributes(*this),
34 mpViewBox(0),
35 maSvgAspectRatio(),
36 maRefX(0),
37 maRefY(0),
38 maMarkerUnits(strokeWidth),
39 maMarkerWidth(3),
40 maMarkerHeight(3),
41 mfAngle(0.0),
42 mbOrientAuto(false)
46 SvgMarkerNode::~SvgMarkerNode()
48 if(mpViewBox) delete mpViewBox;
51 const SvgStyleAttributes* SvgMarkerNode::getSvgStyleAttributes() const
53 static rtl::OUString aClassStr(rtl::OUString::createFromAscii("marker"));
54 return checkForCssStyle(aClassStr, maSvgStyleAttributes);
57 void SvgMarkerNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
59 // call parent
60 SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
62 // read style attributes
63 maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
65 // parse own
66 switch(aSVGToken)
68 case SVGTokenStyle:
70 maSvgStyleAttributes.readStyle(aContent);
71 break;
73 case SVGTokenViewBox:
75 const basegfx::B2DRange aRange(readViewBox(aContent, *this));
77 if(!aRange.isEmpty())
79 setViewBox(&aRange);
81 break;
83 case SVGTokenPreserveAspectRatio:
85 setSvgAspectRatio(readSvgAspectRatio(aContent));
86 break;
88 case SVGTokenRefX:
90 SvgNumber aNum;
92 if(readSingleNumber(aContent, aNum))
94 setRefX(aNum);
96 break;
98 case SVGTokenRefY:
100 SvgNumber aNum;
102 if(readSingleNumber(aContent, aNum))
104 setRefY(aNum);
106 break;
108 case SVGTokenMarkerUnits:
110 if(aContent.getLength())
112 static OUString aStrStrokeWidth(OUString::createFromAscii("strokeWidth"));
114 if(aContent.match(aStrStrokeWidth, 0))
116 setMarkerUnits(strokeWidth);
118 else if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
120 setMarkerUnits(userSpaceOnUse);
123 break;
125 case SVGTokenMarkerWidth:
127 SvgNumber aNum;
129 if(readSingleNumber(aContent, aNum))
131 if(aNum.isPositive())
133 setMarkerWidth(aNum);
136 break;
138 case SVGTokenMarkerHeight:
140 SvgNumber aNum;
142 if(readSingleNumber(aContent, aNum))
144 if(aNum.isPositive())
146 setMarkerHeight(aNum);
149 break;
151 case SVGTokenOrient:
153 const sal_Int32 nLen(aContent.getLength());
155 if(nLen)
157 static OUString aStrAuto(OUString::createFromAscii("auto"));
159 if(aContent.match(aStrAuto, 0))
161 setOrientAuto(true);
163 else
165 sal_Int32 nPos(0);
166 double fAngle(0.0);
168 if(readAngle(aContent, nPos, fAngle, nLen))
170 setAngle(fAngle);
174 break;
176 default:
178 break;
183 const drawinglayer::primitive2d::Primitive2DSequence& SvgMarkerNode::getMarkerPrimitives() const
185 if(!aPrimitives.hasElements())
187 decomposeSvgNode(const_cast< SvgMarkerNode* >(this)->aPrimitives, true);
190 return aPrimitives;
193 const basegfx::B2DRange* SvgMarkerNode::getCurrentViewPort() const
195 if(getViewBox())
197 return getViewBox();
199 else
201 return SvgNode::getCurrentViewPort();
205 } // end of namespace svgreader
206 } // end of namespace svgio
208 //////////////////////////////////////////////////////////////////////////////
209 // eof
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */