Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-object.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef SP_OBJECT_H_SEEN
3#define SP_OBJECT_H_SEEN
4
5/*
6 * Authors:
7 * Lauris Kaplinski <lauris@kaplinski.com>
8 * Jon A. Cruz <jon@joncruz.org>
9 * Abhishek Sharma
10 * Adrian Boguszewski
11 *
12 * Copyright (C) 1999-2016 authors
13 * Copyright (C) 2001-2002 Ximian, Inc.
14 *
15 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
16 */
17
18#include <set>
19#include <glibmm/ustring.h>
20#include "util/const_char_ptr.h"
21#include "xml/node-observer.h"
22/* SPObject flags */
23
24class SPObject;
25
26/* Async modification flags */
27#define SP_OBJECT_MODIFIED_FLAG (1 << 0)
28#define SP_OBJECT_CHILD_MODIFIED_FLAG (1 << 1)
29#define SP_OBJECT_PARENT_MODIFIED_FLAG (1 << 2)
30#define SP_OBJECT_STYLE_MODIFIED_FLAG (1 << 3)
31#define SP_OBJECT_VIEWPORT_MODIFIED_FLAG (1 << 4)
32#define SP_OBJECT_USER_MODIFIED_FLAG_A (1 << 5)
33#define SP_OBJECT_USER_MODIFIED_FLAG_B (1 << 6)
34#define SP_OBJECT_STYLESHEET_MODIFIED_FLAG (1 << 7)
35
36/* Convenience */
37#define SP_OBJECT_FLAGS_ALL 0xff
38
39// Tags that can be passed along with other "modified" flags.
40// Client code can use them to track senders of modification requests.
41// Tags themselves do not signify any modification to the object(s).
42#define SP_OBJECT_USER_MODIFIED_TAG_1 (1 << 8)
43#define SP_OBJECT_USER_MODIFIED_TAG_2 (1 << 9)
44#define SP_OBJECT_USER_MODIFIED_TAG_3 (1 << 10)
45#define SP_OBJECT_USER_MODIFIED_TAG_4 (1 << 11)
46#define SP_OBJECT_USER_MODIFIED_TAG_5 (1 << 12)
47#define SP_OBJECT_USER_MODIFIED_TAG_6 (1 << 13)
48#define SP_OBJECT_USER_MODIFIED_TAG_7 (1 << 14)
49#define SP_OBJECT_USER_MODIFIED_TAG_8 (1 << 15)
50
51#define SP_OBJECT_USER_TAGS_ALL 0xff00
52
53/* Flags that mark object as modified */
54/* Object, Child, Style, Viewport, User */
55#define SP_OBJECT_MODIFIED_STATE (SP_OBJECT_FLAGS_ALL & ~(SP_OBJECT_PARENT_MODIFIED_FLAG))
56
57/* Flags that will propagate downstreams */
58/* Parent, Style, Viewport, User */
59#define SP_OBJECT_MODIFIED_CASCADE ((SP_OBJECT_FLAGS_ALL | SP_OBJECT_USER_TAGS_ALL) & ~(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))
60inline unsigned cascade_flags(unsigned flags)
61{
62 // Unset object-modified and child-modified, set parent-modified if object-modified.
63 static_assert(SP_OBJECT_PARENT_MODIFIED_FLAG == SP_OBJECT_MODIFIED_FLAG << 2);
64 return (flags & SP_OBJECT_MODIFIED_CASCADE) | (flags & SP_OBJECT_MODIFIED_FLAG) << 2;
65}
66
67/* Write flags */
68#define SP_OBJECT_WRITE_BUILD (1 << 0)
69#define SP_OBJECT_WRITE_EXT (1 << 1)
70#define SP_OBJECT_WRITE_ALL (1 << 2)
71#define SP_OBJECT_WRITE_NO_CHILDREN (1 << 3)
72
73#include <vector>
74#include <cassert>
75#include <cstddef>
76#include <boost/intrusive/list.hpp>
77#include <2geom/point.h> // Used for dpi only
78#include <sigc++/connection.h>
79#include <sigc++/functors/slot.h>
80#include <sigc++/signal.h>
82#include "tags.h"
83#include "version.h"
84
85enum class SPAttr;
86
87class SPCSSAttr;
88class SPStyle;
89
90namespace Inkscape::XML { class Node; struct Document; }
91
93struct SPCtx
94{
95 unsigned int flags;
96};
97
98enum
99{
103
104class SPDocument;
105
108public:
110 unsigned int set : 1;
111 unsigned int value : 1;
112};
113
114/*
115 * Refcounting
116 *
117 * Owner is here for debug reasons, you can set it to NULL safely
118 * Ref should return object, NULL is error, unref return always NULL
119 */
120
129SPObject *sp_object_ref(SPObject *object, SPObject *owner=nullptr);
130
140SPObject *sp_object_unref(SPObject *object, SPObject *owner=nullptr);
141
160{
161public:
168 {
169 DEPENDENT = -1,
170 ANY = 0,
171 DEPENDENCY = 1,
172 };
173
174 SPObject();
175 SPObject(SPObject const &) = delete;
176 SPObject &operator=(SPObject const &) = delete;
177 ~SPObject() override;
178 virtual int tag() const { return tag_of<decltype(*this)>; }
179
180 unsigned int cloned : 1;
182 unsigned int uflags : 16;
183 unsigned int mflags : 16;
185 Glib::ustring lang;
186 unsigned int hrefcount{0}; /* number of xlink:href references */
187 unsigned int _total_hrefcount{0}; /* our hrefcount + total descendants */
188 SPDocument *document{nullptr}; /* Document we are part of */
189 SPObject *parent{nullptr}; /* Our parent (only one allowed) */
190
191private:
192 char *id{nullptr}; /* Our very own unique id */
193 Inkscape::XML::Node *repr{nullptr}; /* Our xml representation */
194
195public:
196 int refCount{1};
197 std::list<SPObject *> hrefList;
198
202 char const* getId() const;
203
204 void getIds(std::set<std::string> &ret) const;
205
209 std::string getUrl() const;
210
214//protected:
216
220 Inkscape::XML::Node const* getRepr() const;
221
222public:
223
228 void releaseReferences();
229
237 sigc::connection connectRelease(sigc::slot<void (SPObject *)> slot) {
238 return _release_signal.connect(slot);
239 }
240
249
254
257 static SPObject const *next(SPObject const *object) {
258 return object->parent;
259 }
260 };
261
264
265 bool isSiblingOf(SPObject const *object) const {
266 if (object == nullptr) return false;
267 return this->parent && this->parent == object->parent;
268 }
269
276 virtual void getLinked(std::vector<SPObject *> &objects, LinkedObjectNature direction = LinkedObjectNature::ANY) const;
277
284 std::vector<SPObject *> getLinked(LinkedObjectNature direction = LinkedObjectNature::ANY) const {
285 std::vector<SPObject *> ret;
286 getLinked(ret, direction);
287 return ret;
288 }
289
293 bool isAncestorOf(SPObject const *object) const;
294
298 SPObject const *nearestCommonAncestor(SPObject const *object) const;
299
303 SPObject const * getTopAncestorNonLayer() const;
304
305 /* Returns next object in sibling list or NULL. */
306 SPObject *getNext();
307
311 SPObject *getPrev();
312
313 bool hasChildren() const { return ( children.size() > 0 ); }
314
315 SPObject *firstChild() { return children.empty() ? nullptr : &children.front(); }
316 SPObject const *firstChild() const { return children.empty() ? nullptr : &children.front(); }
317
318 SPObject *lastChild() { return children.empty() ? nullptr : &children.back(); }
319 SPObject const *lastChild() const { return children.empty() ? nullptr : &children.back(); }
320
321 SPObject *nthChild(unsigned index);
322 SPObject const *nthChild(unsigned index) const;
323
325
330 std::vector<SPObject*> childList(bool add_ref, Action action = ActionGeneral);
331
332
337 std::vector<SPObject*> ancestorList(bool root_to_tip);
338
344
349 char const *label() const;
350
354 char const *defaultLabel() const;
355
361 void setLabel(char const *label);
362
368 char *title() const;
369
376 bool setTitle(char const *title, bool verbatim = false);
377
383 char *desc() const;
384
391 bool setDesc(char const *desc, bool verbatim=false);
392
396 Glib::ustring getExportFilename() const;
397 void setExportFilename(Glib::ustring filename);
398
403 void setExportDpi(Geom::Point dpi);
404
426
435 _collection_policy = policy;
436 }
437
449
460 if ( _total_hrefcount == 0 ) {
461 deleteObject(false);
462 }
463 }
464
474 void hrefObject(SPObject* owner = nullptr);
475
484 void unhrefObject(SPObject* owner = nullptr);
485
489 bool isReferenced() { return ( _total_hrefcount > 0 ); }
490
501 void deleteObject(bool propagate, bool propagate_descendants);
502
509 void deleteObject(bool propagate = true)
510 {
511 deleteObject(propagate, propagate);
512 }
513
517 void cropToObject(SPObject *except);
518 void cropToObjects(std::vector<SPObject *> except_objects);
519
523 void getObjectsExcept(std::vector<SPObject *> &objects, const std::vector<SPObject *> &except);
524
531 void getLinkedRecursive(std::vector<SPObject *> &objects, LinkedObjectNature direction = LinkedObjectNature::ANY) const;
532
545 sigc::connection connectDelete(sigc::slot<void (SPObject *)> slot) {
546 return _delete_signal.connect(slot);
547 }
548
549 sigc::connection connectPositionChanged(sigc::slot<void (SPObject *)> slot) {
550 return _position_changed_signal.connect(slot);
551 }
552
560
565 assert(successor != NULL);
566 assert(_successor == NULL);
567 assert(successor->_successor == NULL);
568 sp_object_ref(successor, nullptr);
570 }
571
575 void setTmpSuccessor(SPObject *tmpsuccessor);
576
580 void unsetTmpSuccessor();
581
585 void fixTmpSuccessors();
586
587 /* modifications; all three sets of methods should probably ultimately be protected, as they
588 * are not really part of its public interface. However, other parts of the code to
589 * occasionally use them at present. */
590
591 /* the no-argument version of updateRepr() is intended to be a bit more public, however -- it
592 * essentially just flushes any changes back to the backing store (the repr layer); maybe it
593 * should be called something else and made public at that point. */
594
605 Inkscape::XML::Node *updateRepr(unsigned int flags = SP_OBJECT_WRITE_EXT);
606
632
654 void requestDisplayUpdate(unsigned int flags);
655
674 void updateDisplay(SPCtx *ctx, unsigned int flags);
675
686 void requestModified(unsigned int flags);
687
696 void emitModified(unsigned int flags);
697
705 sigc::connection connectModified(
706 sigc::slot<void (SPObject *, unsigned int)> slot
707 ) {
708 return _modified_signal.connect(slot);
709 }
710
713
717 void _updateTotalHRefCount(int increment);
718
719 void _requireSVGVersion(unsigned major, unsigned minor) { _requireSVGVersion(Inkscape::Version(major, minor)); }
720
725
726 sigc::signal<void (SPObject *)> _release_signal;
727 sigc::signal<void (SPObject *)> _delete_signal;
728 sigc::signal<void (SPObject *)> _position_changed_signal;
729 sigc::signal<void (SPObject *, unsigned int)> _modified_signal;
733 char *_label{nullptr};
734 mutable char *_default_label{nullptr};
735
736 // WARNING:
737 // Methods below should not be used outside of the SP tree,
738 // as they operate directly on the XML representation.
739 // In future, they will be made protected.
740
745 void attach(SPObject *object, SPObject *prev);
746
750 void reorder(SPObject* obj, SPObject *prev);
751
755 void detach(SPObject *object);
756
761
763
764 int getIntAttribute(char const *key, int def);
765
766 unsigned getPosition();
767
768 char const * getAttribute(char const *name) const;
769
771
773
777 void setKeyValue(SPAttr key, char const *value);
778
779
782
784
787 this->setAttribute(key.data(),
788 (value.data() == nullptr || value.data()[0]=='\0') ? nullptr : value.data());
789 }
790
794 void readAttr(char const *key);
795 void readAttr(SPAttr keyid);
796
797 char const *getTagName() const;
798
799 void removeAttribute(char const *key);
800
801 void setCSS(SPCSSAttr *css, char const *attr);
802
803 void changeCSS(SPCSSAttr *css, char const *attr);
804
805 bool storeAsDouble( char const *key, double *val ) const;
806
807private:
808 // Private member functions used in the definitions of setTitle(),
809 // setDesc(), title() and desc().
810
828 bool setTitleOrDesc(char const *value, char const *svg_tagname, bool verbatim);
829
840 char * getTitleOrDesc(char const *svg_tagname) const;
841
846 SPObject * findFirstChild(char const *tagname) const;
847
853 Glib::ustring textualContent() const;
854
855 /* Real handlers of repr signals */
856
857private:
858 // XML::NodeObserver functions
860 Inkscape::Util::ptr_shared newval) final;
861
863 Inkscape::Util::ptr_shared newcontent) final;
864
866 Inkscape::XML::Node *prev) final;
867
869 Inkscape::XML::Node *prev) final;
870
872 Inkscape::XML::Node *new_prev) final;
873
874 void notifyElementNameChanged(Inkscape::XML::Node &node, GQuark old_name, GQuark new_name) final;
875
876 friend class SPObjectImpl;
877
878protected:
879 virtual void build(SPDocument *doc, Inkscape::XML::Node *repr);
880 virtual void release();
881
884
886 Inkscape::XML::Node *new_repr);
887 virtual void tag_name_changed(gchar const *oldname, gchar const *newname);
888
889 virtual void set(SPAttr key, const char *value);
890
891 virtual void update(SPCtx *ctx, unsigned int flags);
892 virtual void modified(unsigned int flags);
893
894 virtual Inkscape::XML::Node *write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags);
895
896 typedef boost::intrusive::list_member_hook<> ListHook;
898
899public:
900 using ChildrenList = boost::intrusive::list<
901 SPObject,
902 boost::intrusive::member_hook<
903 SPObject,
904 ListHook,
906 >>;
908 virtual void read_content();
909
910 void recursivePrintTree(unsigned level = 0); // For debugging
911 void objectTrace(std::string const &, bool in = true, unsigned flags = 0);
912
920 std::string generate_unique_id(char const *default_id = nullptr) const;
921};
922
923std::ostream &operator<<(std::ostream &out, const SPObject &o);
924
934int sp_object_compare_position(SPObject const *first, SPObject const *second);
935bool sp_object_compare_position_bool(SPObject const *first, SPObject const *second);
936
937#endif // SP_OBJECT_H_SEEN
938
939/*
940 Local Variables:
941 mode:c++
942 c-file-style:"stroustrup"
943 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
944 indent-tabs-mode:nil
945 fill-column:99
946 End:
947*/
948// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Cartesian point / 2D vector and related operations.
SPAttr
Definition attributes.h:27
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
Two-dimensional point that doubles as a vector.
Definition point.h:66
Non-owning reference to 'const char*' Main-purpose: avoid overloads of type f(char*,...
const char * data() const noexcept
Interface for XML node observers.
Interface for refcounted XML nodes.
Definition node.h:80
Typed SVG document implementation.
Definition document.h:103
Internal class consisting of two bits.
Definition sp-object.h:107
unsigned int value
Definition sp-object.h:111
unsigned int set
Definition sp-object.h:110
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
SPObject & operator=(SPObject const &)=delete
CollectionPolicy collectionPolicy() const
Set the policy under which this object will be orphan-collected.
Definition sp-object.h:425
Inkscape::Util::ForwardPointerIterator< SPObject const, ParentIteratorStrategy > ConstParentIterator
Definition sp-object.h:263
char const * label() const
Gets the author-visible label property for the object or a default if no label is defined.
SPObject * getNext()
int getIntAttribute(char const *key, int def)
Inkscape::XML::Node * repr
Definition sp-object.h:193
SPObject * _successor
Definition sp-object.h:730
virtual int tag() const
Definition sp-object.h:178
char * desc() const
Returns the description of this object, or NULL if there is none.
friend class SPObjectImpl
Definition sp-object.h:876
boost::intrusive::list< SPObject, boost::intrusive::member_hook< SPObject, ListHook, &SPObject::_child_hook > > ChildrenList
Definition sp-object.h:906
void requestOrphanCollection()
Requests a later automatic call to collectOrphan().
Inkscape::Util::ForwardPointerIterator< SPObject, ParentIteratorStrategy > ParentIterator
Definition sp-object.h:262
void setAttributeOrRemoveIfEmpty(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
Definition sp-object.h:785
unsigned int uflags
Definition sp-object.h:182
void setAttributeDouble(Inkscape::Util::const_char_ptr key, double value)
void appendChild(Inkscape::XML::Node *child)
void _updateTotalHRefCount(int increment)
Adds increment to _total_hrefcount of object and its parents.
bool storeAsDouble(char const *key, double *val) const
void setAttribute(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
std::vector< SPObject * > getLinked(LinkedObjectNature direction=LinkedObjectNature::ANY) const
Get objects which are linked, like above.
Definition sp-object.h:284
SPObject()
Constructor, sets all attributes to default values.
SPObject * clone_original
Definition sp-object.h:181
void detach(SPObject *object)
Remove object from parent's children, release and unref it.
void requestModified(unsigned int flags)
Requests that a modification notification signal be emitted later (e.g.
void removeAttribute(char const *key)
Glib::ustring getExportFilename() const
Get and set the exportable filename on this object.
Geom::Point getExportDpi() const
Get and set the exported DPI for this objet, if available.
void notifyChildOrderChanged(Inkscape::XML::Node &node, Inkscape::XML::Node &child, Inkscape::XML::Node *old_prev, Inkscape::XML::Node *new_prev) final
Child order change callback.
void setKeyValue(SPAttr key, char const *value)
Call virtual set() function of object.
bool setDesc(char const *desc, bool verbatim=false)
Sets the description of this object.
void setExportDpi(Geom::Point dpi)
SPIXmlSpace xml_space
Definition sp-object.h:184
void deleteObject(bool propagate=true)
Deletes on object.
Definition sp-object.h:509
void setExportFilename(Glib::ustring filename)
sigc::connection connectDelete(sigc::slot< void(SPObject *)> slot)
Connects a slot to be called when an object is deleted.
Definition sp-object.h:545
std::vector< SPObject * > childList(bool add_ref, Action action=ActionGeneral)
Retrieves the children as a std vector object, optionally ref'ing the children in the process,...
void setTmpSuccessor(SPObject *tmpsuccessor)
Indicates that another object supercedes temporaty this one.
sigc::connection connectPositionChanged(sigc::slot< void(SPObject *)> slot)
Definition sp-object.h:549
char * getTitleOrDesc(char const *svg_tagname) const
Returns the title or description of this object, or NULL if there is none.
void getObjectsExcept(std::vector< SPObject * > &objects, const std::vector< SPObject * > &except)
Get all child objects except for any in the list.
SPObject * lastChild()
Definition sp-object.h:318
SPObject * get_child_by_repr(Inkscape::XML::Node *repr)
Return object's child whose node pointer equals repr.
Glib::ustring lang
Definition sp-object.h:185
virtual void read_content()
unsigned int mflags
Definition sp-object.h:183
void invoke_build(SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned)
void notifyAttributeChanged(Inkscape::XML::Node &node, GQuark key, Inkscape::Util::ptr_shared oldval, Inkscape::Util::ptr_shared newval) final
Attribute change callback.
void attach(SPObject *object, SPObject *prev)
Put object into object tree, under parent, and behind prev; also update object's XML space.
ListHook _child_hook
Definition sp-object.h:897
SPDocument * document
Definition sp-object.h:188
void updateDisplay(SPCtx *ctx, unsigned int flags)
Updates the object's display immediately.
SPObject * _tmpsuccessor
Definition sp-object.h:731
bool isReferenced()
Check if object is referenced by any other object.
Definition sp-object.h:489
virtual void remove_child(Inkscape::XML::Node *child)
SPObject * firstChild()
Definition sp-object.h:315
void emitModified(unsigned int flags)
Emits the MODIFIED signal with the object's flags.
void getLinkedRecursive(std::vector< SPObject * > &objects, LinkedObjectNature direction=LinkedObjectNature::ANY) const
Grows the input list with all linked items recursively in both child nodes and links of links.
char const * getId() const
Returns the objects current ID string.
bool setTitleOrDesc(char const *value, char const *svg_tagname, bool verbatim)
Sets or deletes the title or description of this object.
void changeCSS(SPCSSAttr *css, char const *attr)
void notifyChildRemoved(Inkscape::XML::Node &node, Inkscape::XML::Node &child, Inkscape::XML::Node *prev) final
Child removal callback.
void recursivePrintTree(unsigned level=0)
sigc::signal< void(SPObject *)> _position_changed_signal
Definition sp-object.h:728
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
Definition sp-object.h:248
sigc::connection connectRelease(sigc::slot< void(SPObject *)> slot)
Connects to the release request signal.
Definition sp-object.h:237
bool setTitle(char const *title, bool verbatim=false)
Sets the title of this object.
std::vector< SPObject * > ancestorList(bool root_to_tip)
Retrieves a list of ancestors of the object, as an easy to use vector.
virtual Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags)
void notifyChildAdded(Inkscape::XML::Node &node, Inkscape::XML::Node &child, Inkscape::XML::Node *prev) final
Child addition callback.
char * _label
Definition sp-object.h:733
SPObject const * lastChild() const
Definition sp-object.h:319
CollectionPolicy _collection_policy
Definition sp-object.h:732
Glib::ustring textualContent() const
Return the full textual content of an element (typically all the content except the tags).
sigc::signal< void(SPObject *, unsigned int)> _modified_signal
Definition sp-object.h:729
void setSuccessor(SPObject *successor)
Indicates that another object supercedes this one.
Definition sp-object.h:564
boost::intrusive::list_member_hook ListHook
Definition sp-object.h:896
~SPObject() override
Destructor, frees the used memory and unreferences a potential successor of the object.
SPObject * getPrev()
Returns previous object in sibling list or NULL.
char const * defaultLabel() const
Returns a default label property for this object.
SPObject * parent
Definition sp-object.h:189
unsigned getPosition()
void setLabel(char const *label)
Sets the author-visible label for this object.
virtual void update(SPCtx *ctx, unsigned int flags)
virtual void release()
SPStyle * context_style
Represents the style that should be used to resolve 'context-fill' and 'context-stroke'.
Definition sp-object.h:253
SPObject * findFirstChild(char const *tagname) const
Find the first child of this object with a given tag name, and return it.
void unhrefObject(SPObject *owner=nullptr)
Decrease weak refcount.
Inkscape::XML::Node * updateRepr(unsigned int flags=SP_OBJECT_WRITE_EXT)
Updates the object's repr based on the object's state.
void _requireSVGVersion(unsigned major, unsigned minor)
Definition sp-object.h:719
SPObject * successor()
Returns the object which supercedes this one (if any).
Definition sp-object.h:559
@ COLLECT_WITH_PARENT
Definition sp-object.h:164
@ ALWAYS_COLLECT
Definition sp-object.h:165
virtual void modified(unsigned int flags)
void readAttr(char const *key)
Read value of key attribute from XML node into object.
SPObject(SPObject const &)=delete
void _sendDeleteSignalRecursive()
Sends the delete signal to all children of this object recursively.
void reorder(SPObject *obj, SPObject *prev)
In list of object's children, move object behind prev.
sigc::signal< void(SPObject *)> _delete_signal
Definition sp-object.h:727
bool hasChildren() const
Definition sp-object.h:313
std::string generate_unique_id(char const *default_id=nullptr) const
Generate a document-wide unique id for this object.
void hrefObject(SPObject *owner=nullptr)
Increase weak refcount.
void deleteObject(bool propagate, bool propagate_descendants)
Deletes an object, unparenting it from its parent.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
virtual void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
char const * getAttribute(char const *name) const
bool isSiblingOf(SPObject const *object) const
Definition sp-object.h:265
void fixTmpSuccessors()
Fix temporary successors in duple stamp.
char * title() const
Returns the title of this object, or NULL if there is none.
void cropToObjects(std::vector< SPObject * > except_objects)
Removes objects which are not related to given list of objects.
virtual void getLinked(std::vector< SPObject * > &objects, LinkedObjectNature direction=LinkedObjectNature::ANY) const
Get objects which are linked to this object as either a source or a target.
SPObject * appendChildRepr(Inkscape::XML::Node *repr)
Append repr as child of this object.
void setCollectionPolicy(CollectionPolicy policy)
Sets the orphan-collection policy in effect for this object.
Definition sp-object.h:434
bool isAncestorOf(SPObject const *object) const
True if object is non-NULL and this is some in/direct parent of object.
unsigned int cloned
Definition sp-object.h:180
LinkedObjectNature
Definition sp-object.h:168
std::string getUrl() const
Get the id in a URL format.
void objectTrace(std::string const &, bool in=true, unsigned flags=0)
SPObject * nthChild(unsigned index)
void cropToObject(SPObject *except)
Removes all children except for the given object, it's children and it's ancesstors.
void collectOrphan()
Unconditionally delete the object if it is not referenced.
Definition sp-object.h:459
void addChild(Inkscape::XML::Node *child, Inkscape::XML::Node *prev=nullptr)
std::list< SPObject * > hrefList
Definition sp-object.h:197
char * _default_label
Definition sp-object.h:734
virtual void build(SPDocument *doc, Inkscape::XML::Node *repr)
SPObject const * nearestCommonAncestor(SPObject const *object) const
Returns youngest object being parent to this and object.
void getIds(std::set< std::string > &ret) const
Accumulate this id and all it's descendants ids.
@ ActionUpdate
Definition sp-object.h:324
@ ActionGeneral
Definition sp-object.h:324
void unsetTmpSuccessor()
Unset object supercedes.
sigc::connection connectModified(sigc::slot< void(SPObject *, unsigned int)> slot)
Connects to the modification notification signal.
Definition sp-object.h:705
virtual void order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old_repr, Inkscape::XML::Node *new_repr)
char const * getTagName() const
ChildrenList children
Definition sp-object.h:907
SPObject const * getTopAncestorNonLayer() const
Returns ancestor non layer.
int refCount
Definition sp-object.h:196
void setCSS(SPCSSAttr *css, char const *attr)
sigc::signal< void(SPObject *)> _release_signal
Definition sp-object.h:726
void notifyContentChanged(Inkscape::XML::Node &node, Inkscape::Util::ptr_shared oldcontent, Inkscape::Util::ptr_shared newcontent) final
Content change callback.
void notifyElementNameChanged(Inkscape::XML::Node &node, GQuark old_name, GQuark new_name) final
Element name change callback.
unsigned int hrefcount
Definition sp-object.h:186
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
SPObject const * nthChild(unsigned index) const
virtual void tag_name_changed(gchar const *oldname, gchar const *newname)
void releaseReferences()
Cleans up an SPObject, releasing its references and requesting that references to it be released.
unsigned int _total_hrefcount
Definition sp-object.h:187
SPObject const * firstChild() const
Definition sp-object.h:316
An SVG style object.
Definition style.h:45
Provides const_char_ptr
std::shared_ptr< Css const > css
Inkscape::XML::Node * node
@Inkscape XML tree.
Interface for XML node observers.
static cairo_user_data_key_t key
Ocnode * child[8]
Definition quantize.cpp:33
Ocnode ** ref
Definition quantize.cpp:32
guint32 GQuark
bool sp_object_compare_position_bool(SPObject const *first, SPObject const *second)
@ SP_XML_SPACE_PRESERVE
Definition sp-object.h:101
@ SP_XML_SPACE_DEFAULT
Definition sp-object.h:100
SPObject * sp_object_unref(SPObject *object, SPObject *owner=nullptr)
Decrease reference count of object, with possible debugging and finalization.
unsigned cascade_flags(unsigned flags)
Definition sp-object.h:60
int sp_object_compare_position(SPObject const *first, SPObject const *second)
Compares height of objects in tree.
SPObject * sp_object_ref(SPObject *object, SPObject *owner=nullptr)
Increase reference count of object, with possible debugging.
Interface for XML documents.
Definition document.h:43
Unused.
Definition sp-object.h:94
unsigned int flags
Definition sp-object.h:95
Switch containing next() method.
Definition sp-object.h:256
static SPObject const * next(SPObject const *object)
Definition sp-object.h:257
int index
Glib::ustring name
Definition toolbars.cpp:55