2
* Inkscape::Whiteboard::InkboardDocument - Inkboard document implementation
5
* Dale Harvey <harveyd@gmail.com>
7
* Copyright (c) 2005 Authors
9
* Released under GNU GPL, read the file 'COPYING' for more information
15
#include "util/ucompose.hpp"
17
#include "pedro/pedrodom.h"
19
#include "xml/attribute-record.h"
20
#include "xml/element-node.h"
21
#include "xml/text-node.h"
23
#include "jabber_whiteboard/message-utilities.h"
24
#include "jabber_whiteboard/defines.h"
25
#include "jabber_whiteboard/inkboard-document.h"
30
namespace Whiteboard {
33
InkboardDocument::addNodeToTracker(Inkscape::XML::Node *node)
35
Glib::ustring rec = this->getRecipient();
36
Glib::ustring key = this->tracker->generateKey(rec);
37
this->tracker->put(key,node);
42
InkboardDocument::composeNewMessage(Inkscape::XML::Node *node)
44
Glib::ustring parentKey;
45
Glib::ustring key = this->tracker->get(node);
46
Inkscape::XML::Node *parent = node->parent();
48
Glib::ustring tempParentKey = this->tracker->get(node->parent());
49
if(tempParentKey.size() < 1)
50
parentKey = Vars::DOCUMENT_ROOT_NODE;
52
parentKey = tempParentKey;
54
unsigned int index = parent->_childPosition(*node);
56
Message::Message nodeMessage = MessageUtilities::objectToString(node);
57
Message::Message message = String::ucompose(Vars::NEW_MESSAGE,parentKey,key,index,0,nodeMessage);
63
InkboardDocument::changeConfigureText(Glib::ustring target, unsigned int version,
66
XML::Node *node = this->tracker->get(target);
67
unsigned int elementVersion = this->tracker->getVersion(node);
69
if(node)// && version == (elementVersion + 1))
71
this->tracker->incrementVersion(node);
72
this->tracker->addHistory(node, "text", text);
73
node->setContent(text.c_str());
78
InkboardDocument::changeConfigure(Glib::ustring target, unsigned int version,
79
Glib::ustring attribute, Glib::ustring value)
81
XML::Node *node = this->tracker->get(target);
82
unsigned int elementVersion = this->tracker->getVersion(node);
84
if(node)// && version == (elementVersion + 1))
86
this->tracker->incrementVersion(node);
87
this->tracker->addHistory(node, attribute, value.c_str());
89
if(attribute != "transform")
90
node->setAttribute(attribute.c_str(),value.c_str());
95
InkboardDocument::changeNew(Glib::ustring parentid, Glib::ustring id,
96
signed int index, Pedro::Element* data)
99
Glib::ustring name(data->getName());
103
XML::Node *parent = this->tracker->get(parentid);
104
XML::Node *node = new XML::TextNode(Util::share_string(data->getValue().c_str()));
108
this->tracker->put(id,node);
109
parent->appendChild(node);
113
XML::Node *node = new XML::ElementNode(g_quark_from_string(name.c_str()));
114
this->tracker->put(id,node);
116
XML::Node *parent = (parentid != "ROOT")
117
? this->tracker->get(parentid.c_str()) : this->root();
119
std::vector<Pedro::Attribute> attributes = data->getAttributes();
121
for (unsigned int i=0; i<attributes.size(); i++)
124
(attributes[i].getName()).c_str(),
125
(attributes[i].getValue()).c_str());
129
parent->appendChild(node);
134
} // namespace Whiteboard
135
} // namespace Inkscape
141
c-file-style:"stroustrup"
142
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
147
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :