summaryrefslogtreecommitdiffstats
path: root/src/xml
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-07-24 23:26:11 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-07-24 23:26:11 +0000
commit7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5 (patch)
tree48cae26bf789b11d79f72efc16a6676f960eaaa6 /src/xml
parentupdate to trunk (diff)
parent3D box tool: the shift key must not prevent snapping of the vanishing point. ... (diff)
downloadinkscape-7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5.tar.gz
inkscape-7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5.zip
update to trunk
(bzr r12588.1.45)
Diffstat (limited to 'src/xml')
-rw-r--r--src/xml/repr-util.cpp33
-rw-r--r--src/xml/repr.h7
2 files changed, 40 insertions, 0 deletions
diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp
index 7c5d2d6fc..f7a437163 100644
--- a/src/xml/repr-util.cpp
+++ b/src/xml/repr-util.cpp
@@ -310,6 +310,11 @@ int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::No
pjrm */
}
+bool sp_repr_compare_position_bool(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second){
+ return sp_repr_compare_position(first, second)<0;
+}
+
+
/**
* Find an element node using an unique attribute.
*
@@ -366,6 +371,34 @@ Inkscape::XML::Node *sp_repr_lookup_name( Inkscape::XML::Node *repr, gchar const
return const_cast<Inkscape::XML::Node *>(found);
}
+std::vector<Inkscape::XML::Node const *> sp_repr_lookup_name_many( Inkscape::XML::Node const *repr, gchar const *name, gint maxdepth )
+{
+ std::vector<Inkscape::XML::Node const *> nodes;
+ std::vector<Inkscape::XML::Node const *> found;
+ g_return_val_if_fail(repr != NULL, nodes);
+ g_return_val_if_fail(name != NULL, nodes);
+
+ GQuark const quark = g_quark_from_string(name);
+
+ if ( (GQuark)repr->code() == quark ) {
+ nodes.push_back(repr);
+ }
+
+ if ( maxdepth != 0 ) {
+ // maxdepth == -1 means unlimited
+ if ( maxdepth == -1 ) {
+ maxdepth = 0;
+ }
+
+ for (Inkscape::XML::Node const *child = repr->firstChild() ; child; child = child->next() ) {
+ found = sp_repr_lookup_name_many( child, name, maxdepth - 1);
+ nodes.insert(nodes.end(), found.begin(), found.end());
+ }
+ }
+
+ return nodes;
+}
+
/**
* Determine if the node is a 'title', 'desc' or 'metadata' element.
*/
diff --git a/src/xml/repr.h b/src/xml/repr.h
index c3ba40e45..e84b89813 100644
--- a/src/xml/repr.h
+++ b/src/xml/repr.h
@@ -14,6 +14,7 @@
#ifndef SEEN_SP_REPR_H
#define SEEN_SP_REPR_H
+#include <vector>
#include <glibmm/quark.h>
#include "xml/node.h"
@@ -120,7 +121,9 @@ unsigned sp_repr_set_svg_length(Inkscape::XML::Node *repr, char const *key, SVGL
unsigned sp_repr_set_point(Inkscape::XML::Node *repr, char const *key, Geom::Point const & val);
unsigned sp_repr_get_point(Inkscape::XML::Node *repr, char const *key, Geom::Point *val);
+//c++-style comparison : returns (bool)(a<b)
int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second);
+bool sp_repr_compare_position_bool(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second);
// Searching
/**
@@ -142,6 +145,10 @@ Inkscape::XML::Node *sp_repr_lookup_name(Inkscape::XML::Node *repr,
Inkscape::XML::Node const *sp_repr_lookup_name(Inkscape::XML::Node const *repr,
char const *name,
int maxdepth = -1);
+
+std::vector<Inkscape::XML::Node const *> sp_repr_lookup_name_many(Inkscape::XML::Node const *repr,
+ char const *name,
+ int maxdepth = -1);
Inkscape::XML::Node *sp_repr_lookup_child(Inkscape::XML::Node *repr,
char const *key,