Code

Do not fail when svn client is not installed and .svn directory is
[inkscape.git] / src / sp-line.cpp
index cca470530a8f8412ddc5642e8a75cac92ed52b95..a3964b171daed3db25feccb635b328c00ce6e346 100644 (file)
 #include <glibmm/i18n.h>
 #include <libnr/nr-matrix-fns.h>
 #include <xml/repr.h>
+#include "document.h"
 
 static void sp_line_class_init (SPLineClass *klass);
 static void sp_line_init (SPLine *line);
 
 static void sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr);
 static void sp_line_set (SPObject *object, unsigned int key, const gchar *value);
-static Inkscape::XML::Node *sp_line_write (SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static Inkscape::XML::Node *sp_line_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
 
 static gchar *sp_line_description (SPItem * item);
-static NR::Matrix sp_line_set_transform(SPItem *item, NR::Matrix const &xform);
+static Geom::Matrix sp_line_set_transform(SPItem *item, Geom::Matrix const &xform);
 
 static void sp_line_update (SPObject *object, SPCtx *ctx, guint flags);
 static void sp_line_set_shape (SPShape *shape);
@@ -158,12 +159,12 @@ sp_line_update (SPObject *object, SPCtx *ctx, guint flags)
 
 
 static Inkscape::XML::Node *
-sp_line_write (SPObject *object, Inkscape::XML::Node *repr, guint flags)
+sp_line_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
 {
        SPLine *line  = SP_LINE (object);
 
        if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
-               repr = sp_repr_new ("svg:line");
+               repr = xml_doc->createElement("svg:line");
        }
 
        if (repr != SP_OBJECT_REPR (object)) {
@@ -176,39 +177,39 @@ sp_line_write (SPObject *object, Inkscape::XML::Node *repr, guint flags)
        sp_repr_set_svg_double(repr, "y2", line->y2.computed);
 
        if (((SPObjectClass *) (parent_class))->write)
-               ((SPObjectClass *) (parent_class))->write (object, repr, flags);
+               ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags);
 
        return repr;
 }
 
 static gchar *
-sp_line_description(SPItem *item)
+sp_line_description(SPItem */*item*/)
 {
-       return g_strdup(_("<b>Line</b>"));
+    return g_strdup(_("<b>Line</b>"));
 }
 
-static NR::Matrix
-sp_line_set_transform (SPItem *item, NR::Matrix const &xform)
+static Geom::Matrix
+sp_line_set_transform (SPItem *item, Geom::Matrix const &xform)
 {
        SPLine *line = SP_LINE (item);
-       NR::Point points[2];
+       Geom::Point points[2];
 
-       points[0] = NR::Point(line->x1.computed, line->y1.computed);
-       points[1] = NR::Point(line->x2.computed, line->y2.computed);
+       points[0] = Geom::Point(line->x1.computed, line->y1.computed);
+       points[1] = Geom::Point(line->x2.computed, line->y2.computed);
 
        points[0] *= xform;
        points[1] *= xform;
 
-       line->x1.computed = points[0][NR::X];
-       line->y1.computed = points[0][NR::Y];
-       line->x2.computed = points[1][NR::X];
-       line->y2.computed = points[1][NR::Y];
+       line->x1.computed = points[0][Geom::X];
+       line->y1.computed = points[0][Geom::Y];
+       line->x2.computed = points[1][Geom::X];
+       line->y2.computed = points[1][Geom::Y];
 
-       sp_item_adjust_stroke(item, NR::expansion(xform));
+       sp_item_adjust_stroke(item, xform.descrim());
 
        SP_OBJECT (item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
 
-       return NR::identity();
+       return Geom::identity();
 }
 
 static void
@@ -216,12 +217,12 @@ sp_line_set_shape (SPShape *shape)
 {
        SPLine *line = SP_LINE (shape);
 
-       SPCurve *c = sp_curve_new ();
+       SPCurve *c = new SPCurve ();
 
-       sp_curve_moveto (c, line->x1.computed, line->y1.computed);
-       sp_curve_lineto (c, line->x2.computed, line->y2.computed);
+       c->moveto(line->x1.computed, line->y1.computed);
+       c->lineto(line->x2.computed, line->y2.computed);
 
        sp_shape_set_curve_insync (shape, c, TRUE); // *_insync does not call update, avoiding infinite recursion when set_shape is called by update
 
-       sp_curve_unref (c);
+       c->unref();
 }