summaryrefslogtreecommitdiffstats
path: root/src/sp-polyline.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
committerMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
commit5a4fb2325f60d292b47330f540b26a3279341c90 (patch)
treed2aa7967be25450b83e625025366c618101ae49f /src/sp-polyline.cpp
parentThe Polar Arrange Tab of the Arrange Dialog now hides the parametric (diff)
parentRemove Snap menu item and improve grid menu item text (diff)
downloadinkscape-5a4fb2325f60d292b47330f540b26a3279341c90.tar.gz
inkscape-5a4fb2325f60d292b47330f540b26a3279341c90.zip
Commit a merge to trunk, with probabal errors
(bzr r11073.1.36)
Diffstat (limited to 'src/sp-polyline.cpp')
-rw-r--r--src/sp-polyline.cpp113
1 files changed, 44 insertions, 69 deletions
diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp
index 8dbed2a22..c80190097 100644
--- a/src/sp-polyline.cpp
+++ b/src/sp-polyline.cpp
@@ -20,64 +20,29 @@
#include "xml/repr.h"
#include "document.h"
-SPShapeClass * SPPolyLineClass::static_parent_class=0;
-
-GType SPPolyLine::sp_polyline_get_type(void)
-{
- static GType polyline_type = 0;
-
- if (!polyline_type) {
- GTypeInfo polyline_info = {
- sizeof (SPPolyLineClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) SPPolyLineClass::sp_polyline_class_init,
- NULL, /* klass_finalize */
- NULL, /* klass_data */
- sizeof (SPPolyLine),
- 16, /* n_preallocs */
- (GInstanceInitFunc) SPPolyLine::init,
- NULL, /* value_table */
- };
- polyline_type = g_type_register_static (SP_TYPE_SHAPE, "SPPolyLine", &polyline_info, (GTypeFlags)0);
- }
- return polyline_type;
-}
-
-void SPPolyLineClass::sp_polyline_class_init(SPPolyLineClass *klass)
-{
- //GObjectClass * gobject_class = (GObjectClass *) klass;
- SPObjectClass * sp_object_class = (SPObjectClass *) klass;
- SPItemClass * item_class = (SPItemClass *) klass;
+#include "sp-factory.h"
- static_parent_class = (SPShapeClass *)g_type_class_ref(SP_TYPE_SHAPE);
-
- sp_object_class->build = SPPolyLine::build;
- sp_object_class->set = SPPolyLine::set;
- sp_object_class->write = SPPolyLine::write;
+namespace {
+ SPObject* createPolyLine() {
+ return new SPPolyLine();
+ }
- item_class->description = SPPolyLine::getDescription;
+ bool polyLineRegistered = SPFactory::instance().registerObject("svg:polyline", createPolyLine);
}
-void SPPolyLine::init(SPPolyLine * /*polyline*/)
-{
- /* Nothing here */
+SPPolyLine::SPPolyLine() : SPShape() {
}
-void SPPolyLine::build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr)
-{
+SPPolyLine::~SPPolyLine() {
+}
- if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->build) {
- ((SPObjectClass *) SPPolyLineClass::static_parent_class)->build (object, document, repr);
- }
+void SPPolyLine::build(SPDocument * document, Inkscape::XML::Node * repr) {
+ SPShape::build(document, repr);
- object->readAttr( "points" );
+ this->readAttr("points");
}
-void SPPolyLine::set(SPObject *object, unsigned int key, const gchar *value)
-{
- SPPolyLine *polyline = SP_POLYLINE(object);
-
+void SPPolyLine::set(unsigned int key, const gchar* value) {
switch (key) {
case SP_ATTR_POINTS: {
SPCurve * curve;
@@ -85,7 +50,10 @@ void SPPolyLine::set(SPObject *object, unsigned int key, const gchar *value)
char * eptr;
gboolean hascpt;
- if (!value) break;
+ if (!value) {
+ break;
+ }
+
curve = new SPCurve ();
hascpt = FALSE;
@@ -98,20 +66,35 @@ void SPPolyLine::set(SPObject *object, unsigned int key, const gchar *value)
while (*cptr != '\0' && (*cptr == ',' || *cptr == '\x20' || *cptr == '\x9' || *cptr == '\xD' || *cptr == '\xA')) {
cptr++;
}
- if (!*cptr) break;
+
+ if (!*cptr) {
+ break;
+ }
x = g_ascii_strtod (cptr, &eptr);
- if (eptr == cptr) break;
+
+ if (eptr == cptr) {
+ break;
+ }
+
cptr = eptr;
while (*cptr != '\0' && (*cptr == ',' || *cptr == '\x20' || *cptr == '\x9' || *cptr == '\xD' || *cptr == '\xA')) {
cptr++;
}
- if (!*cptr) break;
+
+ if (!*cptr) {
+ break;
+ }
y = g_ascii_strtod (cptr, &eptr);
- if (eptr == cptr) break;
+
+ if (eptr == cptr) {
+ break;
+ }
+
cptr = eptr;
+
if (hascpt) {
curve->lineto(x, y);
} else {
@@ -120,40 +103,32 @@ void SPPolyLine::set(SPObject *object, unsigned int key, const gchar *value)
}
}
- (SP_SHAPE (polyline))->setCurve (curve, TRUE);
+ this->setCurve(curve, TRUE);
curve->unref();
break;
}
default:
- if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->set) {
- ((SPObjectClass *) SPPolyLineClass::static_parent_class)->set (object, key, value);
- }
+ SPShape::set(key, value);
break;
}
}
-Inkscape::XML::Node *SPPolyLine::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
-{
- SP_POLYLINE(object);
-
+Inkscape::XML::Node* SPPolyLine::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
repr = xml_doc->createElement("svg:polyline");
}
- if (repr != object->getRepr()) {
- repr->mergeFrom(object->getRepr(), "id");
+ if (repr != this->getRepr()) {
+ repr->mergeFrom(this->getRepr(), "id");
}
- if (((SPObjectClass *) (SPPolyLineClass::static_parent_class))->write) {
- ((SPObjectClass *) (SPPolyLineClass::static_parent_class))->write (object, xml_doc, repr, flags);
- }
+ SPShape::write(xml_doc, repr, flags);
return repr;
}
-gchar *SPPolyLine::getDescription(SPItem * /*item*/)
-{
- return g_strdup(_("<b>Polyline</b>"));
+gchar* SPPolyLine::description() const {
+ return g_strdup(_("<b>Polyline</b>"));
}