Code

Extensions. Check element now search in the extension directory (see Bug #668895...
[inkscape.git] / src / sp-use-reference.cpp
index 9e304799876e359a48449e9f8ef7687c2a911953..a05dc0e93d498ddbcaef2ea23012b6d80d90e902 100644 (file)
@@ -7,12 +7,16 @@
  * Released under GNU GPL, read the file 'COPYING' for more information.
  */
 
+#include <cstring>
+#include <string>
+#include <string.h>
+
 #include "enums.h"
 #include "sp-use-reference.h"
 
 #include "display/curve.h"
 #include "livarot/Path.h"
-#include "prefs-utils.h"
+#include "preferences.h"
 #include "sp-shape.h"
 #include "sp-text.h"
 #include "uri.h"
@@ -37,9 +41,9 @@ bool SPUseReference::_acceptObject(SPObject * const obj) const
 
 
 static void sp_usepath_href_changed(SPObject *old_ref, SPObject *ref, SPUsePath *offset);
-static void sp_usepath_move_compensate(NR::Matrix const *mp, SPItem *original, SPUsePath *self);
+static void sp_usepath_move_compensate(Geom::Matrix const *mp, SPItem *original, SPUsePath *self);
 static void sp_usepath_delete_self(SPObject *deleted, SPUsePath *offset);
-static void sp_usepath_source_modified(SPObject *iSource, guint flags, SPItem *item);
+static void sp_usepath_source_modified(SPObject *iSource, guint flags, SPUsePath *offset);
 
 SPUsePath::SPUsePath(SPObject* i_owner):SPUseReference(i_owner)
 {
@@ -49,9 +53,6 @@ SPUsePath::SPUsePath(SPObject* i_owner):SPUseReference(i_owner)
     sourceHref = NULL;
     sourceRepr = NULL;
     sourceObject = NULL;
-    new (&_delete_connection) sigc::connection();
-    new (&_changed_connection) sigc::connection();
-    new (&_transformed_connection) sigc::connection();
     _changed_connection = changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_usepath_href_changed), this)); // listening to myself, this should be virtual instead
 
     user_unlink = NULL;
@@ -66,10 +67,6 @@ SPUsePath::~SPUsePath(void)
 
     quit_listening();
     unlink();
-
-    _delete_connection.~connection();
-    _changed_connection.~connection();
-    _transformed_connection.~connection();
 }
 
 void
@@ -113,7 +110,7 @@ SPUsePath::start_listening(SPObject* to)
     sourceRepr = SP_OBJECT_REPR(to);
     _delete_connection = to->connectDelete(sigc::bind(sigc::ptr_fun(&sp_usepath_delete_self), this));
     _transformed_connection = SP_ITEM(to)->connectTransformed(sigc::bind(sigc::ptr_fun(&sp_usepath_move_compensate), this));
-    _modified_connection = g_signal_connect(G_OBJECT(to), "modified", G_CALLBACK(sp_usepath_source_modified), this);
+    _modified_connection = to->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_usepath_source_modified), this));
 }
 
 void
@@ -122,7 +119,7 @@ SPUsePath::quit_listening(void)
     if ( sourceObject == NULL ) {
         return;
     }
-    g_signal_handler_disconnect(sourceObject, _modified_connection);
+    _modified_connection.disconnect();
     _delete_connection.disconnect();
     _transformed_connection.disconnect();
     sourceRepr = NULL;
@@ -142,24 +139,26 @@ sp_usepath_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPUsePath *off
 }
 
 static void
-sp_usepath_move_compensate(NR::Matrix const *mp, SPItem *original, SPUsePath *self)
+sp_usepath_move_compensate(Geom::Matrix const *mp, SPItem *original, SPUsePath *self)
 {
-    guint mode = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_PARALLEL);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    guint mode = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_PARALLEL);
     if (mode == SP_CLONE_COMPENSATION_NONE) {
         return;
     }
     SPItem *item = SP_ITEM(self->owner);
 
+// TODO kill naughty naughty #if 0
 #if 0
-    NR::Matrix m(*mp);
+    Geom::Matrix m(*mp);
     if (!(m.is_translation())) {
         return;
     }
-    NR::Matrix const t(item->transform);
-    NR::Matrix clone_move = t.inverse() * m * t;
+    Geom::Matrix const t(item->transform);
+    Geom::Matrix clone_move = t.inverse() * m * t;
 
     // Calculate the compensation matrix and the advertized movement matrix.
-    NR::Matrix advertized_move;
+    Geom::Matrix advertized_move;
     if (mode == SP_CLONE_COMPENSATION_PARALLEL) {
         //clone_move = clone_move.inverse();
         advertized_move.set_identity();
@@ -173,6 +172,9 @@ sp_usepath_move_compensate(NR::Matrix const *mp, SPItem *original, SPUsePath *se
     // Commit the compensation.
     item->transform *= clone_move;
     sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform, &advertized_move);
+#else
+    (void)mp;
+    (void)original;
 #endif
 
     self->sourceDirty = true;
@@ -182,7 +184,8 @@ sp_usepath_move_compensate(NR::Matrix const *mp, SPItem *original, SPUsePath *se
 static void
 sp_usepath_delete_self(SPObject */*deleted*/, SPUsePath *offset)
 {
-    guint const mode = prefs_get_int_attribute("options.cloneorphans", "value", SP_CLONE_ORPHANS_UNLINK);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    guint const mode = prefs->getInt("/options/cloneorphans/value", SP_CLONE_ORPHANS_UNLINK);
 
     if (mode == SP_CLONE_ORPHANS_UNLINK) {
         // leave it be. just forget about the source
@@ -196,9 +199,8 @@ sp_usepath_delete_self(SPObject */*deleted*/, SPUsePath *offset)
 }
 
 static void
-sp_usepath_source_modified(SPObject *iSource, guint flags, SPItem *item)
+sp_usepath_source_modified(SPObject */*iSource*/, guint /*flags*/, SPUsePath *offset)
 {
-    SPUsePath *offset = (SPUsePath*)item;
     offset->sourceDirty = true;
     offset->owner->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 }
@@ -220,7 +222,7 @@ void SPUsePath::refresh_source()
         return;
     }
     if (SP_IS_SHAPE(item)) {
-        curve = sp_shape_get_curve(SP_SHAPE(item));
+        curve = SP_SHAPE(item)->getCurve();
         if (curve == NULL)
             return;
     }
@@ -231,8 +233,8 @@ void SPUsePath::refresh_source()
         }
     }
     originalPath = new Path;
-    originalPath->LoadArtBPath(SP_CURVE_BPATH(curve), NR::Matrix(item->transform), true);
-    sp_curve_unref(curve);
+    originalPath->LoadPathVector(curve->get_pathvector(), item->transform, true);
+    curve->unref();
 }