Code

change uint to more portable unsigned int
[inkscape.git] / src / sp-conn-end-pair.cpp
index ff1005a1636e474c130a08289008ef803c731cb0..85d9ccce22bce79e97227003b211820c5fcec779 100644 (file)
@@ -17,6 +17,8 @@
 #include "xml/repr.h"
 #include "sp-path.h"
 #include "libavoid/vertices.h"
+#include "libavoid/router.h"
+#include "document.h"
 
 
 SPConnEndPair::SPConnEndPair(SPPath *const owner)
@@ -93,8 +95,9 @@ SPConnEndPair::setAttr(unsigned const key, gchar const *const value)
         if (value && (strcmp(value, "polyline") == 0)) {
             _connType = SP_CONNECTOR_POLYLINE;
             
+            Avoid::Router *router = _path->document->router;
             GQuark itemID = g_quark_from_string(SP_OBJECT(_path)->id);
-            _connRef = new Avoid::ConnRef(itemID);
+            _connRef = new Avoid::ConnRef(router, itemID);
             _invalid_path_connection = connectInvalidPath(
                     sigc::ptr_fun(&sp_conn_adjust_invalid_path));
             _transformed_connection = _path->connectTransformed(
@@ -211,9 +214,34 @@ SPConnEndPair::update(void)
             _connRef->lateSetup(src, dst);
             _connRef->setCallback(&emitPathInvalidationNotification, _path);
         }
+        // Store the ID of the objects attached to the connector.
+        storeIds();
     }
 }
-    
+
+
+void SPConnEndPair::storeIds(void)
+{
+    if (_connEnd[0]->href) {
+        // href begins with a '#' which we don't want.
+        const char *startId = _connEnd[0]->href + 1;
+        GQuark itemId = g_quark_from_string(startId);
+        _connRef->setEndPointId(Avoid::VertID::src, itemId);
+    }
+    else {
+        _connRef->setEndPointId(Avoid::VertID::src, 0);
+    }
+    if (_connEnd[1]->href) {
+        // href begins with a '#' which we don't want.
+        const char *endId = _connEnd[1]->href + 1;
+        GQuark itemId = g_quark_from_string(endId);
+        _connRef->setEndPointId(Avoid::VertID::tar, itemId);
+    }
+    else {
+        _connRef->setEndPointId(Avoid::VertID::tar, 0);
+    }
+}
+
 
 bool
 SPConnEndPair::isAutoRoutingConn(void)