Code

Connector tool: make connectors avoid the convex hull of shapes.
[inkscape.git] / src / jabber_whiteboard / inkboard-node.cpp
index 5f40e38088991561d984766643860713939b305f..4d24cf72a309ebcd2cd2a6eef21dac1cbe0e515e 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "pedro/pedrodom.h"
 
+#include "xml/node.h"
 #include "xml/attribute-record.h"
 #include "xml/element-node.h"
 #include "xml/text-node.h"
@@ -43,7 +44,6 @@ InkboardDocument::composeNewMessage(Inkscape::XML::Node *node)
 {
     Glib::ustring parentKey;
     Glib::ustring key = this->tracker->get(node);
-    Inkscape::XML::Node *parent = node->parent();
 
     Glib::ustring tempParentKey = this->tracker->get(node->parent());
     if(tempParentKey.size() < 1)
@@ -51,7 +51,7 @@ InkboardDocument::composeNewMessage(Inkscape::XML::Node *node)
     else
         parentKey = tempParentKey;
 
-    unsigned int index = parent->_childPosition(*node);
+    unsigned int index = node->position();
 
     Message::Message nodeMessage = MessageUtilities::objectToString(node);
     Message::Message message = String::ucompose(Vars::NEW_MESSAGE,parentKey,key,index,0,nodeMessage);
@@ -60,13 +60,14 @@ InkboardDocument::composeNewMessage(Inkscape::XML::Node *node)
 }
 
 void
-InkboardDocument::changeConfigureText(Glib::ustring target, unsigned int version,
-        Glib::ustring text)
+InkboardDocument::changeConfigureText(Glib::ustring target,
+                                      unsigned int /*version*/,
+                                      Glib::ustring text)
 {
     XML::Node *node = this->tracker->get(target);
-    unsigned int elementVersion = this->tracker->getVersion(node);
+    //unsigned int elementVersion = this->tracker->getVersion(node);
 
-    if(node && version == (elementVersion + 1))
+    if(node)// && version == (elementVersion + 1))
     {
         this->tracker->incrementVersion(node);
         this->tracker->addHistory(node, "text", text);
@@ -75,23 +76,27 @@ InkboardDocument::changeConfigureText(Glib::ustring target, unsigned int version
 }
 
 void
-InkboardDocument::changeConfigure(Glib::ustring target, unsigned int version, 
-        Glib::ustring attribute, Glib::ustring value)
+InkboardDocument::changeConfigure(Glib::ustring target,
+                                  unsigned int /*version*/, 
+                                  Glib::ustring attribute,
+                                                                 Glib::ustring value)
 {
     XML::Node *node = this->tracker->get(target);
-    unsigned int elementVersion = this->tracker->getVersion(node);
+    //unsigned int elementVersion = this->tracker->getVersion(node);
 
-    if(node && version == (elementVersion + 1))
+    if(node)// && version == (elementVersion + 1))
     {
         this->tracker->incrementVersion(node);
-        this->tracker->addHistory(node, attribute, node->attribute(attribute.c_str()));
-        node->setAttribute(attribute.c_str(),value.c_str());
+        this->tracker->addHistory(node, attribute, value.c_str());
+
+        if(attribute != "transform")
+            node->setAttribute(attribute.c_str(),value.c_str());
     }
 }
 
 void 
 InkboardDocument::changeNew(Glib::ustring parentid, Glib::ustring id, 
-        signed int index, Pedro::Element* data)
+        signed int /*index*/, Pedro::Element* data)
 {
 
     Glib::ustring name(data->getName());
@@ -99,7 +104,7 @@ InkboardDocument::changeNew(Glib::ustring parentid, Glib::ustring id,
     if(name == "text")
     { 
         XML::Node *parent = this->tracker->get(parentid);
-        XML::Node *node = new XML::TextNode(Util::share_string(data->getValue().c_str()));
+        XML::Node *node = new XML::TextNode(Util::share_string(data->getValue().c_str()), this);
 
         if(parent && node)
         {
@@ -108,7 +113,7 @@ InkboardDocument::changeNew(Glib::ustring parentid, Glib::ustring id,
         }
     }else
     {
-        XML::Node *node = new XML::ElementNode(g_quark_from_string(name.c_str()));
+        XML::Node *node = new XML::ElementNode(g_quark_from_string(name.c_str()), this);
         this->tracker->put(id,node);
 
         XML::Node *parent = (parentid != "ROOT")