~inkscape+alexander/inkscape/break

« back to all changes in this revision

Viewing changes to src/xml/repr-util.cpp

  • Committer: Alexander Brock
  • Date: 2015-05-31 17:41:01 UTC
  • mfrom: (13749.1.441 Inkscape)
  • Revision ID: brock.alexander@web.de-20150531174101-2roftkxg6oy1oav5
MergeĀ lp:inkscape

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <2geom/point.h>
33
33
#include "svg/stringstream.h"
34
34
#include "svg/css-ostringstream.h"
 
35
#include "svg/svg-length.h"
35
36
 
36
37
#include "xml/repr.h"
37
38
#include "xml/repr-sorting.h"
309
310
       pjrm */
310
311
}
311
312
 
 
313
bool sp_repr_compare_position_bool(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second){
 
314
    return sp_repr_compare_position(first, second)<0;
 
315
}
 
316
 
 
317
 
312
318
/**
313
319
 * Find an element node using an unique attribute.
314
320
 *
365
371
    return const_cast<Inkscape::XML::Node *>(found);
366
372
}
367
373
 
 
374
std::vector<Inkscape::XML::Node const *> sp_repr_lookup_name_many( Inkscape::XML::Node const *repr, gchar const *name, gint maxdepth )
 
375
{
 
376
    std::vector<Inkscape::XML::Node const *> nodes;
 
377
    std::vector<Inkscape::XML::Node const *> found;
 
378
    g_return_val_if_fail(repr != NULL, nodes);
 
379
    g_return_val_if_fail(name != NULL, nodes);
 
380
 
 
381
    GQuark const quark = g_quark_from_string(name);
 
382
 
 
383
    if ( (GQuark)repr->code() == quark ) {
 
384
        nodes.push_back(repr);
 
385
    }
 
386
 
 
387
    if ( maxdepth != 0 ) {
 
388
        // maxdepth == -1 means unlimited
 
389
        if ( maxdepth == -1 ) {
 
390
            maxdepth = 0;
 
391
        }
 
392
 
 
393
        for (Inkscape::XML::Node const *child = repr->firstChild() ; child; child = child->next() ) {
 
394
            found = sp_repr_lookup_name_many( child, name, maxdepth - 1);
 
395
            nodes.insert(nodes.end(), found.begin(), found.end());
 
396
        }
 
397
    }
 
398
 
 
399
    return nodes;
 
400
}
 
401
 
368
402
/**
369
403
 * Determine if the node is a 'title', 'desc' or 'metadata' element.
370
404
 */
502
536
    return true;
503
537
}
504
538
 
 
539
/**
 
540
 * For attributes where an exponent is allowed.
 
541
 *
 
542
 * Not suitable for property attributes.
 
543
 */
 
544
unsigned int sp_repr_set_svg_length(Inkscape::XML::Node *repr, gchar const *key, SVGLength &val)
 
545
{
 
546
    g_return_val_if_fail(repr != NULL, FALSE);
 
547
    g_return_val_if_fail(key != NULL, FALSE);
 
548
 
 
549
    repr->setAttribute(key, val.write());
 
550
    return true;
 
551
}
 
552
 
505
553
unsigned sp_repr_set_point(Inkscape::XML::Node *repr, gchar const *key, Geom::Point const & val)
506
554
{
507
555
    g_return_val_if_fail(repr != NULL, FALSE);