Code

Cmake: Improve Gtkmm dependency checking, add new files to CMakeLists.txts, remove...
[inkscape.git] / src / sp-offset.cpp
index 2253bf1e1170dd7b869304d8aa30da7b09667ebe..5ff01814f06ae6a1c7fd2fc09ff1c79904799eb7 100644 (file)
@@ -19,6 +19,8 @@
 # include "config.h"
 #endif
 
+#include <cstring>
+#include <string>
 
 #include "svg/svg.h"
 #include "attributes.h"
@@ -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);
 
@@ -262,7 +264,8 @@ sp_offset_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     SPOffset *offset = SP_OFFSET (object);
 
     if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
-        repr = sp_repr_new ("svg:path");
+        Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(object)->document();
+        repr = xml_doc->createElement("svg:path");
     }
 
     if (flags & SP_OBJECT_WRITE_EXT) {
@@ -351,10 +354,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);
@@ -441,7 +444,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;
@@ -530,10 +533,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;
     }
@@ -583,9 +586,9 @@ sp_offset_set_shape(SPShape *shape)
         theRes->ConvertToForme (orig, 1, originaux);
 
         SPItem *item = shape;
-        NR::Rect bbox = sp_item_bbox_desktop (item);
-        if (!bbox.isEmpty()) {
-            gdouble size = L2(bbox.dimensions());
+        NR::Maybe<NR::Rect> bbox = sp_item_bbox_desktop (item);
+        if ( bbox && !bbox->isEmpty() ) {
+            gdouble size = L2(bbox->dimensions());
             gdouble const exp = NR::expansion(item->transform);
             if (exp != 0)
                 size /= exp;
@@ -779,10 +782,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);
     }
@@ -1033,7 +1036,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;
     }
 
@@ -1050,7 +1053,7 @@ sp_offset_top_point (SPOffset * offset, NR::Point *px)
 
     delete theShape;
     delete finalPath;
-    sp_curve_unref (curve);
+    curve->unref();
 }
 
 // the listening functions
@@ -1093,7 +1096,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;
@@ -1141,7 +1144,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;
@@ -1175,7 +1178,7 @@ refresh_offset_source(SPOffset* offset)
            return;
     }
     orig = bpath_to_liv_path (SP_CURVE_BPATH(curve));
-    sp_curve_unref (curve);
+    curve->unref();
 
 
     // Finish up.