diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp
index 193c1125c631015dd60069127199405cadece0ad..d310639ba2a15fe63a6924e19dfe22484f57b43f 100644 (file)
--- a/src/xml/repr-util.cpp
+++ b/src/xml/repr-util.cpp
#include <glib.h>
-
+#include <2geom/point.h>
#include "svg/stringstream.h"
#include "svg/css-ostringstream.h"
#include "xml/repr.h"
#include "xml/repr-sorting.h"
+
+#define OSB_NS_URI "http://www.openswatchbook.org/uri/2009/osb"
+
+
struct SPXMLNs {
SPXMLNs *next;
unsigned int uri, prefix;
static void
sp_xml_ns_register_defaults()
{
- static SPXMLNs defaults[10];
+ static SPXMLNs defaults[11];
defaults[0].uri = g_quark_from_static_string(SP_SODIPODI_NS_URI);
defaults[0].prefix = g_quark_from_static_string("sodipodi");
defaults[6].prefix = g_quark_from_static_string("dc");
defaults[6].next = &defaults[7];
+ defaults[7].uri = g_quark_from_static_string(OSB_NS_URI);
+ defaults[7].prefix = g_quark_from_static_string("osb");
+ defaults[7].next = &defaults[8];
+
// Inkscape versions prior to 0.44 would write this namespace
// URI instead of the correct sodipodi namespace; by adding this
// entry to the table last (where it gets used for URI -> prefix
// lookups, but not prefix -> URI lookups), we effectively transfer
// elements in this namespace to the correct sodipodi namespace:
- defaults[7].uri = g_quark_from_static_string(SP_BROKEN_SODIPODI_NS_URI);
- defaults[7].prefix = g_quark_from_static_string("sodipodi");
- defaults[7].next = &defaults[8];
+ defaults[8].uri = g_quark_from_static_string(SP_BROKEN_SODIPODI_NS_URI);
+ defaults[8].prefix = g_quark_from_static_string("sodipodi");
+ defaults[8].next = &defaults[9];
// "Duck prion"
// This URL became widespread due to a bug in versions <= 0.43
- defaults[8].uri = g_quark_from_static_string("http://inkscape.sourceforge.net/DTD/s odipodi-0.dtd");
- defaults[8].prefix = g_quark_from_static_string("sodipodi");
- defaults[8].next = &defaults[9];
+ defaults[9].uri = g_quark_from_static_string("http://inkscape.sourceforge.net/DTD/s odipodi-0.dtd");
+ defaults[9].prefix = g_quark_from_static_string("sodipodi");
+ defaults[9].next = &defaults[10];
// This namespace URI is being phased out by Creative Commons
- defaults[9].uri = g_quark_from_static_string(SP_OLD_CC_NS_URI);
- defaults[9].prefix = g_quark_from_static_string("cc");
- defaults[9].next = NULL;
+ defaults[10].uri = g_quark_from_static_string(SP_OLD_CC_NS_URI);
+ defaults[10].prefix = g_quark_from_static_string("cc");
+ defaults[10].next = NULL;
namespaces = &defaults[0];
}
@@ -344,6 +352,7 @@ long long int sp_repr_get_int_attribute(Inkscape::XML::Node *repr, char const *k
* 0 positions are equivalent
* 1 first object's position is greater than the second
* -1 first object's position is less than the second
+ * @todo Rewrite this function's description to be understandable
*/
int
sp_repr_compare_position(Inkscape::XML::Node *first, Inkscape::XML::Node *second)
@@ -397,7 +406,15 @@ sp_repr_compare_position(Inkscape::XML::Node *first, Inkscape::XML::Node *second
}
/**
- * lookup child by \a key, \a value.
+ * @brief Find an element node using an unique attribute
+ *
+ * This function returns the first child of the specified node that has the attribute
+ * @c key equal to @c value. Note that this function does not recurse.
+ *
+ * @param repr The node to start from
+ * @param key The name of the attribute to use for comparisons
+ * @param value The value of the attribute to look for
+ * @relatesalso Inkscape::XML::Node
*/
Inkscape::XML::Node *
sp_repr_lookup_child(Inkscape::XML::Node *repr,
g_return_val_if_fail(repr != NULL, NULL);
for ( Inkscape::XML::Node *child = repr->firstChild() ; child ; child = child->next() ) {
gchar const *child_value = child->attribute(key);
- if ( child_value == value ||
- value && child_value && !strcmp(child_value, value) )
+ if ( (child_value == value) ||
+ (value && child_value && !strcmp(child_value, value)) )
{
return child;
}
}
/**
- * \brief Recursively find the Inkscape::XML::Node matching the given XML name.
- * \return A pointer to the matching Inkscape::XML::Node
- * \param repr The Inkscape::XML::Node to start from
- * \param name The desired XML name
- *
+ * @brief Find an element node with the given name
+ *
+ * This function searches the descendants of the specified node depth-first for
+ * the first XML node with the specified name.
+ *
+ * @param repr The node to start from
+ * @param name The name of the element node to find
+ * @param maxdepth Maximum search depth, or -1 for an unlimited depth
+ * @return A pointer to the matching Inkscape::XML::Node
+ * @relatesalso Inkscape::XML::Node
*/
Inkscape::XML::Node *
sp_repr_lookup_name( Inkscape::XML::Node *repr, gchar const *name, gint maxdepth )
return true;
}
-unsigned sp_repr_set_point(Inkscape::XML::Node *repr, gchar const *key, Geom::Point val)
+unsigned sp_repr_set_point(Inkscape::XML::Node *repr, gchar const *key, Geom::Point const & val)
{
g_return_val_if_fail(repr != NULL, FALSE);
g_return_val_if_fail(key != NULL, FALSE);
@@ -637,4 +659,4 @@ sp_repr_get_point(Inkscape::XML::Node *repr, gchar const *key, Geom::Point *val)
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :