Code

Export. Fix PS/EPS export (Bug #698340, PS Level Restriction reversed.
[inkscape.git] / src / jabber_whiteboard / node-utilities.cpp
1 /**
2  * Whiteboard session manager
3  * XML node manipulation / retrieval utilities
4  * 
5  * Authors:
6  * David Yip <yipdw@rose-hulman.edu>
7  *
8  * Copyright (c) 2005 Authors
9  *
10  * Released under GNU GPL, read the file 'COPYING' for more information
11  */
13 #include "util/shared-c-string-ptr.h"
14 #include "util/list.h"
16 #include "xml/node-observer.h"
17 #include "xml/attribute-record.h"
18 #include "xml/repr.h"
20 #include "jabber_whiteboard/defines.h"
21 #include "jabber_whiteboard/node-utilities.h"
22 #include "jabber_whiteboard/node-tracker.h"
23 //#include "jabber_whiteboard/node-observer.h"
25 namespace Inkscape {
27 namespace Whiteboard {
29 /*
30 Inkscape::XML::Node*
31 NodeUtilities::lookupReprByValue(Inkscape::XML::Node* root, gchar const* key, Glib::ustring const* value)
32 {
33         GQuark const quark = g_quark_from_string(key);
34         if (root == NULL) {
35                 return NULL;
36         }
38         Inkscape::Util::List<Inkscape::XML::AttributeRecord const> attrlist = root->attributeList();
39         for( ; attrlist ; attrlist++) {
40                 if ((attrlist->key == quark) && (strcmp(attrlist->value, value->data()) == 0)) {
41                         return root;
42                 }
43         }
44         Inkscape::XML::Node* result;
45     for ( Inkscape::XML::Node* child = root->firstChild() ; child != NULL ; child = child->next() ) {
46                 result = NodeUtilities::lookupReprByValue(child, key, value);
47         if(result != NULL) {
48                         return result;
49                 }
50     }
52     return NULL;
53 }
54 */
56 Glib::ustring
57 NodeUtilities::nodeTypeToString(XML::Node const& node)
58 {
59         switch(node.type()) {
60                 case XML::DOCUMENT_NODE:
61                         return NODETYPE_DOCUMENT_STR;
62                 case XML::ELEMENT_NODE:
63                         return NODETYPE_ELEMENT_STR;
64                 case XML::TEXT_NODE:
65                         return NODETYPE_TEXT_STR;
66                 case XML::COMMENT_NODE:
67                 default:
68                         return NODETYPE_COMMENT_STR;
69         }
70 }
72 XML::NodeType
73 NodeUtilities::stringToNodeType(Glib::ustring const& type)
74 {       
75         if (type == NODETYPE_DOCUMENT_STR) {
76                 return XML::DOCUMENT_NODE;
77         } else if (type == NODETYPE_ELEMENT_STR) {
78                 return XML::ELEMENT_NODE;
79         } else if (type == NODETYPE_TEXT_STR) {
80                 return XML::TEXT_NODE;
81         } else {
82                 return XML::COMMENT_NODE;
83         }
84 }
86 Glib::ustring
87 NodeUtilities::findNodeID(XML::Node       const& node, 
88                           XMLNodeTracker* tracker,
89                           KeyNodeTable    const& newnodes)
90 {
91         //g_log(NULL, G_LOG_LEVEL_DEBUG, "Attempting to locate id for %p", &node);
92         Glib::ustring key = newnodes.get((XML::Node *)&node);
93         if (key.size()>0)
94             return key;
96         if (tracker->isTracking(node)) {
97                  //g_log(NULL, G_LOG_LEVEL_DEBUG, "Located id for %p (in tracker): %s", &node, tracker->get(node).c_str());
98                 return tracker->get(node);
99         } else {
100                 //g_log(NULL, G_LOG_LEVEL_DEBUG, "Failed to locate id");
101                 return "";
102         }
109 /*
110   Local Variables:
111   mode:c++
112   c-file-style:"stroustrup"
113   c-file-offsets:((innamespace . 0)(inline-open . 0))
114   indent-tabs-mode:nil
115   fill-column:99
116   End:
117 */
118 // vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :