diff options
| author | Ben Scholzen 'DASPRiD <mail@dasprids.de> | 2015-05-29 17:21:52 +0000 |
|---|---|---|
| committer | Ben Scholzen 'DASPRiD <mail@dasprids.de> | 2015-05-29 17:21:52 +0000 |
| commit | ea3737623c19fa92b97ec6c3e228ea0f8db7a03b (patch) | |
| tree | 2d5423399a5341808db808cecef571aa41773be6 /src/xml/repr-util.cpp | |
| parent | Use more fine-grain fallbacks for Poppler/Cairo PDF imports. (diff) | |
| download | inkscape-ea3737623c19fa92b97ec6c3e228ea0f8db7a03b.tar.gz inkscape-ea3737623c19fa92b97ec6c3e228ea0f8db7a03b.zip | |
Import all defs from clipboard or imported files
Fixed bugs:
- https://launchpad.net/bugs/1460057
(bzr r14185)
Diffstat (limited to '')
| -rw-r--r-- | src/xml/repr-util.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 4cbe930a1..f7a437163 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -371,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. */ |
