Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

void Inkscape::XML::SimpleNode::mergeFrom ( Node const *  src,
gchar const *  key 
) [virtual, inherited]

Merge all children of another node with the current.

This method merges two node hierarchies, where src takes precedence. key is the name of the attribute that determines whether two nodes are corresponding (it must be the same for both, and all of their ancestors). If there is a corresponding node in src hierarchy, their attributes and content override the ones already present in this node's hierarchy. If there is no corresponding node, it is copied from src to this node. This method is used when merging the user's preferences file with the defaults, and has little use beyond that.

Parameters:
src The node to merge into this node
key The attribute to use as the identity attribute

Implements Inkscape::XML::Node.

Definition at line 585 of file simple-node.cpp.

References Inkscape::XML::SimpleNode::appendChild(), Inkscape::XML::Node::attribute(), Inkscape::XML::Node::attributeList(), Inkscape::XML::Node::content(), Inkscape::XML::Node::duplicate(), Inkscape::XML::Node::firstChild(), Inkscape::XML::Node::mergeFrom(), Inkscape::XML::Node::next(), Inkscape::GC::Anchored::release(), Inkscape::XML::SimpleNode::setAttribute(), Inkscape::XML::SimpleNode::setContent(), and Inkscape::XML::Node::sp_repr_lookup_child().

                                                            {
    g_return_if_fail(src != NULL);
    g_return_if_fail(key != NULL);
    g_assert(src != this);

    setContent(src->content());

    for ( Node const *child = src->firstChild() ; child != NULL ; child = child->next() )
    {
        gchar const *id = child->attribute(key);
        if (id) {
            Node *rch=sp_repr_lookup_child(this, key, id);
            if (rch) {
                rch->mergeFrom(child, key);
            } else {
                rch = child->duplicate(_document);
                appendChild(rch);
                rch->release();
            }
        } else {
            Node *rch=child->duplicate(_document);
            appendChild(rch);
            rch->release();
        }
    }

    for ( List<AttributeRecord const> iter = src->attributeList() ;
          iter ; ++iter )
    {
        setAttribute(g_quark_to_string(iter->key), iter->value);
    }
}


Generated by  Doxygen 1.6.0   Back to index