27#include "vtransformcmd.h"
30#include <KoXmlWriter.h>
33VPolyline::VPolyline(
VObject* parent, VState state )
34 :
VPath( parent, state )
54 TQString points = m_points.simplifyWhiteSpace();
55 points.replace(
',',
' ' );
56 points.remove(
'\r' );
57 points.remove(
'\n' );
58 TQStringList pointList = TQStringList::split(
' ', points );
59 TQStringList::Iterator end(pointList.end());
60 for( TQStringList::Iterator it = pointList.begin(); it != end; ++it )
63 point.setX( (*it).toDouble() );
64 point.setY( (*++it).toDouble() );
79 return !result.isEmpty() ? result : i18n(
"Polyline" );
83VPolyline::save( TQDomElement& element )
const
86 if( doc && doc->saveAsPath() )
94 TQDomElement me = element.ownerDocument().createElement(
"POLYLINE" );
95 element.appendChild( me );
99 VTransformCmd cmd( 0L, m_matrix.invert() );
101 path.VObject::save( me );
104 me.setAttribute(
"points", m_points );
106 TQString transform = buildSvgTransform();
107 if( !transform.isEmpty() )
108 me.setAttribute(
"transform", transform );
113VPolyline::saveOasis( KoStore *store, KoXmlWriter *docWriter, KoGenStyles &mainStyles,
int &index )
const
119 docWriter->startElement(
"draw:polyline" );
121 docWriter->addAttribute(
"svg:points", m_points );
125 docWriter->endElement();
129VPolyline::load(
const TQDomElement& element )
133 TQDomNodeList list = element.childNodes();
134 for( uint i = 0; i < list.count(); ++i )
135 if( list.item( i ).isElement() )
138 m_points = element.attribute(
"points" );
142 TQString trafo = element.attribute(
"transform" );
143 if( !trafo.isEmpty() )
148VPolyline::loadOasis(
const TQDomElement &element, KoOasisLoadingContext &context )
152 if( element.localName() ==
"line" )
155 p1.setX( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg,
"x1", TQString() ) ) );
156 p1.setY( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg,
"y1", TQString() ) ) );
157 p2.setX( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg,
"x2", TQString() ) ) );
158 p2.setY( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg,
"y2", TQString() ) ) );
160 m_points = TQString(
"%1,%2 %3,%4" ).arg( p1.x() ).arg( p1.y() ).arg( p2.x() ).arg( p2.y() );
165 else if( element.localName() ==
"polyline" )
167 m_points = element.attributeNS( KoXmlNS::draw,
"points", TQString() );
171 transformByViewbox( element, element.attributeNS( KoXmlNS::svg,
"viewBox", TQString() ) );
173 TQString trafo = element.attributeNS( KoXmlNS::draw,
"transform", TQString() );
174 if( !trafo.isEmpty() )
175 transformOasis( trafo );
183 return new VPolyline( *
this );
The base class for all karbon objects.
virtual void setState(const VState state)
Sets the state to a specified new state.
virtual void saveOasis(KoStore *store, KoXmlWriter *docWriter, KoGenStyles &mainStyles, int &index) const
Save this object's state to OpenDocument.
@ deleted
deleted, nearly dead
@ normal
visible, not active
virtual TQString name() const
Returns the name of the object.
virtual void load(const TQDomElement &element)
Load this object's state from xml and initialize this object accordingly.
VDocument * document() const
Return document the object belongs to.
virtual bool loadOasis(const TQDomElement &element, KoOasisLoadingContext &context)
Load this object's state from OpenDocument and initialize this object accordingly.
VState state() const
Get the state the object is in.
A composite path consists of one or many subpaths.
virtual void save(TQDomElement &element) const
Save this object's state to xml.
virtual VPath * clone() const
Create an exact copy of this object.