Code

new command: relink clone to copied object
[inkscape.git] / src / sp-offset.cpp
index e682f394bb74c41029ce91c6aec088aa84c729ba..d3711a9f6d01e26d60c1d7de3643e3a8a4e9df47 100644 (file)
@@ -19,6 +19,8 @@
 # include "config.h"
 #endif
 
+#include <cstring>
+#include <string>
 
 #include "svg/svg.h"
 #include "attributes.h"
@@ -73,7 +75,7 @@ static void sp_offset_finalize(GObject *obj);
 
 static void sp_offset_build (SPObject * object, SPDocument * document,
                              Inkscape::XML::Node * repr);
-static Inkscape::XML::Node *sp_offset_write (SPObject * object, Inkscape::XML::Node * repr,
+static Inkscape::XML::Node *sp_offset_write (SPObject * object, Inkscape::XML::Document *doc, Inkscape::XML::Node * repr,
                                 guint flags);
 static void sp_offset_set (SPObject * object, unsigned int key,
                            const gchar * value);
@@ -84,7 +86,7 @@ static gchar *sp_offset_description (SPItem * item);
 static void sp_offset_snappoints(SPItem const *item, SnapPointsIter p);
 static void sp_offset_set_shape (SPShape * shape);
 
-Path *bpath_to_liv_path (NArtBpath * bpath);
+Path *bpath_to_liv_path (NArtBpath const * bpath);
 
 static void refresh_offset_source(SPOffset* offset);
 
@@ -257,12 +259,11 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
  * Virtual write: write offset attributes to corresponding repr.
  */
 static Inkscape::XML::Node *
-sp_offset_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
+sp_offset_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
 {
     SPOffset *offset = SP_OFFSET (object);
 
     if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
-        Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(object)->document();
         repr = xml_doc->createElement("svg:path");
     }
 
@@ -285,12 +286,12 @@ sp_offset_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     }
 
     // write that curve to "d"
-    char *d = sp_svg_write_path (SP_CURVE_BPATH(((SPShape *) offset)->curve));
+    char *d = sp_svg_write_path (((SPShape *) offset)->curve->get_pathvector());
     repr->setAttribute("d", d);
     g_free (d);
 
     if (((SPObjectClass *) (parent_class))->write)
-        ((SPObjectClass *) (parent_class))->write (object, repr,
+        ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr,
                                                    flags | SP_SHAPE_WRITE_PATH);
 
     return repr;
@@ -352,10 +353,10 @@ sp_offset_set(SPObject *object, unsigned key, gchar const *value)
                 offset->original = strdup (value);
 
                 bpath = sp_svg_read_path (offset->original);
-                curve = sp_curve_new_from_bpath (bpath);       // curve se chargera de detruire bpath
+                curve = SPCurve::new_from_bpath (bpath);       // curve se chargera de detruire bpath
                 g_assert (curve != NULL);
                 offset->originalPath = bpath_to_liv_path (SP_CURVE_BPATH(curve));
-                sp_curve_unref (curve);
+                curve->unref();
 
                 offset->knotSet = false;
                 if ( offset->isUpdating == false ) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -442,7 +443,7 @@ sp_offset_description(SPItem *item)
  * livarot Path. Duplicate of splivarot.
  */
 Path *
-bpath_to_liv_path(NArtBpath *bpath)
+bpath_to_liv_path(NArtBpath const *bpath)
 {
     if (bpath == NULL)
         return NULL;
@@ -531,10 +532,10 @@ sp_offset_set_shape(SPShape *shape)
         const char *res_d = SP_OBJECT(shape)->repr->attribute("inkscape:original");
         if ( res_d ) {
             NArtBpath *bpath = sp_svg_read_path (res_d);
-            SPCurve *c = sp_curve_new_from_bpath (bpath);
+            SPCurve *c = SPCurve::new_from_bpath (bpath);
             g_assert(c != NULL);
             sp_shape_set_curve_insync ((SPShape *) offset, c, TRUE);
-            sp_curve_unref (c);
+            c->unref();
         }
         return;
     }
@@ -780,10 +781,10 @@ sp_offset_set_shape(SPShape *shape)
         delete orig;
 
         NArtBpath *bpath = sp_svg_read_path (res_d);
-        SPCurve *c = sp_curve_new_from_bpath (bpath);
+        SPCurve *c = SPCurve::new_from_bpath (bpath);
         g_assert(c != NULL);
         sp_shape_set_curve_insync ((SPShape *) offset, c, TRUE);
-        sp_curve_unref (c);
+        c->unref();
 
         free (res_d);
     }
@@ -1034,7 +1035,7 @@ sp_offset_top_point (SPOffset * offset, NR::Point *px)
     Path *finalPath = bpath_to_liv_path (SP_CURVE_BPATH(curve));
     if (finalPath == NULL)
     {
-        sp_curve_unref (curve);
+        curve->unref();
         return;
     }
 
@@ -1051,7 +1052,7 @@ sp_offset_top_point (SPOffset * offset, NR::Point *px)
 
     delete theShape;
     delete finalPath;
-    sp_curve_unref (curve);
+    curve->unref();
 }
 
 // the listening functions
@@ -1094,7 +1095,7 @@ sp_offset_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPOffset *offse
 }
 
 static void
-sp_offset_move_compensate(NR::Matrix const *mp, SPItem *original, SPOffset *self)
+sp_offset_move_compensate(NR::Matrix const *mp, SPItem */*original*/, SPOffset *self)
 {
     guint mode = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_PARALLEL);
     if (mode == SP_CLONE_COMPENSATION_NONE) return;
@@ -1142,7 +1143,7 @@ sp_offset_delete_self(SPObject */*deleted*/, SPOffset *offset)
 }
 
 static void
-sp_offset_source_modified (SPObject *iSource, guint flags, SPItem *item)
+sp_offset_source_modified (SPObject */*iSource*/, guint /*flags*/, SPItem *item)
 {
     SPOffset *offset = SP_OFFSET(item);
     offset->sourceDirty=true;
@@ -1176,7 +1177,7 @@ refresh_offset_source(SPOffset* offset)
            return;
     }
     orig = bpath_to_liv_path (SP_CURVE_BPATH(curve));
-    sp_curve_unref (curve);
+    curve->unref();
 
 
     // Finish up.