Code

Correct load order of user icons.svg icons with legacy names.
[inkscape.git] / src / jabber_whiteboard / inkboard-node.cpp
1 /**
2  * Inkscape::Whiteboard::InkboardDocument - Inkboard document implementation
3  *
4  * Authors:
5  * Dale Harvey <harveyd@gmail.com>
6  *
7  * Copyright (c) 2005 Authors
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #include <glib.h>
13 #include <glibmm.h>
15 #include "util/ucompose.hpp"
17 #include "pedro/pedrodom.h"
19 #include "xml/node.h"
20 #include "xml/attribute-record.h"
21 #include "xml/element-node.h"
22 #include "xml/text-node.h"
24 #include "jabber_whiteboard/message-utilities.h"
25 #include "jabber_whiteboard/defines.h"
26 #include "jabber_whiteboard/inkboard-document.h"
29 namespace Inkscape {
31 namespace Whiteboard {
33 Glib::ustring
34 InkboardDocument::addNodeToTracker(Inkscape::XML::Node *node)
35 {
36     Glib::ustring rec = this->getRecipient();
37     Glib::ustring key = this->tracker->generateKey(rec);
38     this->tracker->put(key,node);
39     return key;
40 }
42 Message::Message
43 InkboardDocument::composeNewMessage(Inkscape::XML::Node *node)
44 {
45     Glib::ustring parentKey;
46     Glib::ustring key = this->tracker->get(node);
48     Glib::ustring tempParentKey = this->tracker->get(node->parent());
49     if(tempParentKey.size() < 1)
50         parentKey = Vars::DOCUMENT_ROOT_NODE;
51     else
52         parentKey = tempParentKey;
54     unsigned int index = node->position();
56     Message::Message nodeMessage = MessageUtilities::objectToString(node);
57     Message::Message message = String::ucompose(Vars::NEW_MESSAGE,parentKey,key,index,0,nodeMessage);
59     return message;
60 }
62 void
63 InkboardDocument::changeConfigureText(Glib::ustring target,
64                                       unsigned int /*version*/,
65                                       Glib::ustring text)
66 {
67     XML::Node *node = this->tracker->get(target);
68     //unsigned int elementVersion = this->tracker->getVersion(node);
70     if(node)// && version == (elementVersion + 1))
71     {
72         this->tracker->incrementVersion(node);
73         this->tracker->addHistory(node, "text", text);
74         node->setContent(text.c_str());
75     }
76 }
78 void
79 InkboardDocument::changeConfigure(Glib::ustring target,
80                                   unsigned int /*version*/, 
81                                   Glib::ustring attribute,
82                                                                   Glib::ustring value)
83 {
84     XML::Node *node = this->tracker->get(target);
85     //unsigned int elementVersion = this->tracker->getVersion(node);
87     if(node)// && version == (elementVersion + 1))
88     {
89         this->tracker->incrementVersion(node);
90         this->tracker->addHistory(node, attribute, value.c_str());
92         if(attribute != "transform")
93             node->setAttribute(attribute.c_str(),value.c_str());
94     }
95 }
97 void 
98 InkboardDocument::changeNew(Glib::ustring parentid, Glib::ustring id, 
99         signed int /*index*/, Pedro::Element* data)
102     Glib::ustring name(data->getName());
104     if(name == "text")
105     { 
106         XML::Node *parent = this->tracker->get(parentid);
107         XML::Node *node = new XML::TextNode(Util::share_string(data->getValue().c_str()), this);
109         if(parent && node)
110         {
111             this->tracker->put(id,node);
112             parent->appendChild(node);
113         }
114     }else
115     {
116         XML::Node *node = new XML::ElementNode(g_quark_from_string(name.c_str()), this);
117         this->tracker->put(id,node);
119         XML::Node *parent = (parentid != "ROOT") 
120             ? this->tracker->get(parentid.c_str()) : this->root();
122         std::vector<Pedro::Attribute> attributes = data->getAttributes();
124         for (unsigned int i=0; i<attributes.size(); i++) 
125         {
126             node->setAttribute(
127                 (attributes[i].getName()).c_str(),
128                 (attributes[i].getValue()).c_str());
129         }
131         if(parent != NULL)
132             parent->appendChild(node);
133     }
137 } // namespace Whiteboard
138 } // namespace Inkscape
141 /*
142   Local Variables:
143   mode:c++
144   c-file-style:"stroustrup"
145   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
146   indent-tabs-mode:nil
147   fill-column:99
148   End:
149 */
150 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :