2 Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
24 #include "SVGLineElement.h"
26 #include "FloatPoint.h"
27 #include "MappedAttribute.h"
28 #include "RenderPath.h"
29 #include "SVGLength.h"
34 SVGLineElement::SVGLineElement(const QualifiedName
& tagName
, Document
* doc
)
35 : SVGStyledTransformableElement(tagName
, doc
)
38 , SVGExternalResourcesRequired()
39 , m_x1(this, SVGNames::x1Attr
, LengthModeWidth
)
40 , m_y1(this, SVGNames::y1Attr
, LengthModeHeight
)
41 , m_x2(this, SVGNames::x2Attr
, LengthModeWidth
)
42 , m_y2(this, SVGNames::y2Attr
, LengthModeHeight
)
43 , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr
, false)
47 SVGLineElement::~SVGLineElement()
51 void SVGLineElement::parseMappedAttribute(MappedAttribute
* attr
)
53 if (attr
->name() == SVGNames::x1Attr
)
54 setX1BaseValue(SVGLength(LengthModeWidth
, attr
->value()));
55 else if (attr
->name() == SVGNames::y1Attr
)
56 setY1BaseValue(SVGLength(LengthModeHeight
, attr
->value()));
57 else if (attr
->name() == SVGNames::x2Attr
)
58 setX2BaseValue(SVGLength(LengthModeWidth
, attr
->value()));
59 else if (attr
->name() == SVGNames::y2Attr
)
60 setY2BaseValue(SVGLength(LengthModeHeight
, attr
->value()));
62 if (SVGTests::parseMappedAttribute(attr
))
64 if (SVGLangSpace::parseMappedAttribute(attr
))
66 if (SVGExternalResourcesRequired::parseMappedAttribute(attr
))
68 SVGStyledTransformableElement::parseMappedAttribute(attr
);
72 void SVGLineElement::svgAttributeChanged(const QualifiedName
& attrName
)
74 SVGStyledTransformableElement::svgAttributeChanged(attrName
);
79 if (attrName
== SVGNames::x1Attr
|| attrName
== SVGNames::y1Attr
||
80 attrName
== SVGNames::x2Attr
|| attrName
== SVGNames::y2Attr
||
81 SVGTests::isKnownAttribute(attrName
) ||
82 SVGLangSpace::isKnownAttribute(attrName
) ||
83 SVGExternalResourcesRequired::isKnownAttribute(attrName
) ||
84 SVGStyledTransformableElement::isKnownAttribute(attrName
))
85 renderer()->setNeedsLayout(true);
88 Path
SVGLineElement::toPathData() const
90 return Path::createLine(FloatPoint(x1().value(this), y1().value(this)),
91 FloatPoint(x2().value(this), y2().value(this)));
94 bool SVGLineElement::hasRelativeValues() const
96 return (x1().isRelative() || y1().isRelative() ||
97 x2().isRelative() || y2().isRelative());
102 #endif // ENABLE(SVG)