Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-object-group.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Abstract base class for non-item groups
4 *
5 * Authors:
6 * Lauris Kaplinski <lauris@kaplinski.com>
7 * Jon A. Cruz <jon@joncruz.org>
8 * Abhishek Sharma
9 *
10 * Copyright (C) 1999-2003 Authors
11 * Copyright (C) 2001-2002 Ximian, Inc.
12 *
13 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
14 */
15
16#include "sp-object-group.h"
17
18#include "object/sp-object.h" // for SPObject, SP_OBJ...
19#include "xml/document.h" // for Document
20#include "xml/node.h" // for Node
21
24
26
32
33
39
40
42 SPObject::order_changed(child, old_ref, new_ref);
43
44 this->requestModified(SP_OBJECT_MODIFIED_FLAG);
45}
46
47
49 if (flags & SP_OBJECT_WRITE_BUILD) {
50 if (!repr) {
51 repr = xml_doc->createElement("svg:g");
52 }
53
54 std::vector<Inkscape::XML::Node *> l;
55 for (auto& child: children) {
56 Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, nullptr, flags);
57
58 if (crepr) {
59 l.push_back(crepr);
60 }
61 }
62 for (auto i=l.rbegin();i!=l.rend();++i) {
63 repr->addChild(*i, nullptr);
65 }
66 } else {
67 for (auto& child: children) {
68 child.updateRepr(flags);
69 }
70 }
71
72 SPObject::write(xml_doc, repr, flags);
73
74 return repr;
75}
76
77/*
78 Local Variables:
79 mode:c++
80 c-file-style:"stroustrup"
81 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
82 indent-tabs-mode:nil
83 fill-column:99
84 End:
85*/
86// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Interface for refcounted XML nodes.
Definition node.h:80
virtual void addChild(Node *child, Node *after)=0
Insert another node as a child of this node.
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
void order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *new_repr) override
void remove_child(Inkscape::XML::Node *child) override
void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) override
~SPObjectGroup() override
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
Inkscape::XML::Node * repr
Definition sp-object.h:193
void requestModified(unsigned int flags)
Requests that a modification notification signal be emitted later (e.g.
virtual void remove_child(Inkscape::XML::Node *child)
virtual Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags)
virtual void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
virtual void order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old_repr, Inkscape::XML::Node *new_repr)
ChildrenList children
Definition sp-object.h:907
static R & release(R &r)
Decrements the reference count of a anchored object.
Ocnode * child[8]
Definition quantize.cpp:33
Ocnode ** ref
Definition quantize.cpp:32
Interface for XML documents.
Definition document.h:43
virtual Node * createElement(char const *name)=0
Interface for XML documents.
Interface for XML nodes.