25#include <boost/range/adaptor/transformed.hpp>
54#define noSP_OBJECT_DEBUG_CASCADE
56#define noSP_OBJECT_DEBUG
59# define debug(f, a...) { g_print("%s(%d) %s:", \
60 __FILE__,__LINE__,__FUNCTION__); \
65# define debug(f, a...)
84 static void setIdNull(
SPObject* obj ) {
96 static void setId(
SPObject* obj, gchar
const*
id ) {
97 if (obj && (
id != obj->
id) ) {
103 obj->
id = g_strdup(
id);
117 debug(
"id=%p, typename=%s",
this, g_type_name_from_instance((GTypeInstance *)
this));
119 SPObjectImpl::setIdNull(
this);
151 this->
repr =
nullptr;
165 objectTrace(
"SPObject::modified (default) (empty function)" );
166 objectTrace(
"SPObject::modified (default)",
false );
178class RefCountEvent :
public BaseRefCountEvent {
180 RefCountEvent(
SPObject *
object,
int bias,
char const *
name)
181 : BaseRefCountEvent(
name)
183 _addProperty(
"object",
Util::format(
"%p",
object).pointer());
189class RefEvent :
public RefCountEvent {
192 : RefCountEvent(object, 1,
"sp-object-ref")
196class UnrefEvent :
public RefCountEvent {
199 : RefCountEvent(object, -1,
"sp-object-unref")
214 ret.insert(std::string(
id));
226 return std::string(
"url(#") +
id +
")";
242 g_return_val_if_fail(
object !=
nullptr, NULL);
253 g_return_val_if_fail(
object !=
nullptr, NULL);
271 if (!owner || !owner->
cloned) {
282 if (!owner || !owner->
cloned) {
294 SPObject *topmost_collectable =
nullptr;
297 if ( iter->_total_hrefcount < iter->hrefcount ) {
298 g_critical(
"HRefs overcounted");
300 if ( iter->_total_hrefcount == 0 &&
303 topmost_collectable = iter;
306 if (topmost_collectable) {
316 objects.push_back(linked);
323 g_return_val_if_fail(
object !=
nullptr,
false);
324 object =
object->parent;
326 if (
object ==
this ) {
329 object =
object->parent;
335 g_return_val_if_fail(
object !=
nullptr, NULL);
338 return nearest_common_ancestor<SPObject::ConstParentIterator>(
this,
object,
nullptr);
343 if ( obj && ancestor ) {
344 if (obj->
parent == ancestor) {
356 if (first != second) {
361 if (ancestor == first) {
363 }
else if (ancestor == second) {
387 g_critical(
"Attempt to append repr as child of cloned object");
394 g_assert(this->
getRepr() !=
nullptr);
400 g_assert(this->
getRepr() !=
nullptr);
405 std::vector<SPObject*> l;
417 std::vector<SPObject *> ancestors;
419 ancestors.push_back(iter);
422 std::reverse(ancestors.begin(), ancestors.end());
457 g_return_if_fail(
document !=
nullptr);
461 if (is<SPStyleElem>(
this)) {
463 }
else if (is<SPScript>(
this)) {
465 }
else if (is<SPFont>(
this)) {
467 }
else if (!prefs->
getBool(
"/options/cleanupswatches/value",
false) && is<SPPaintServer>(
this) &&
static_cast<SPPaintServer*
>(
this)->
isSwatch()) {
469 }
else if (is<Inkscape::ColorProfile>(
this)) {
471 }
else if (is<LivePathEffectObject>(
this)) {
493 child._sendDeleteSignalRecursive();
500 if (is<SPLPEItem>(
this)) {
501 cast<SPLPEItem>(
this)->removeAllPathEffects(
false, propagate_descendants);
506 if (propagate_descendants) {
523 std::vector<SPObject *> toDelete;
525 if (is<SPItem>(&
child)) {
526 if (
child.isAncestorOf(except)) {
527 child.cropToObject(except);
528 }
else if (&
child != except) {
530 toDelete.push_back(&
child);
534 for (
auto &i : toDelete) {
535 i->deleteObject(
true,
true);
553 if (except_objects.empty()) {
556 std::vector<SPObject *> links;
557 std::vector<SPObject *> toDelete;
560 for (
auto item : except_objects) {
564 except_objects.insert(except_objects.end(), links.begin(), links.end());
569 for (
auto &i : toDelete) {
571 i->deleteObject(
false,
false);
578 if (is<SPItem>(&
child)) {
580 for (
auto except : excepts) {
581 if (&
child == except) {
585 if (
child.isAncestorOf(except)) {
589 if (child_flag == 1) {
590 objects.push_back(&
child);
591 }
else if (child_flag == 2) {
592 child.getObjectsExcept(objects, excepts);
603 if (std::find(objects.begin(), objects.end(), link) == objects.end()) {
604 objects.push_back(link);
605 link->getLinkedRecursive(objects, direction);
610 if (is<SPItem>(&
child)) {
612 child.getLinkedRecursive(objects, direction);
619 g_return_if_fail(
object !=
nullptr);
620 g_return_if_fail(!prev || prev->
parent ==
this);
621 g_return_if_fail(!object->
parent);
624 object->parent =
this;
628 if (prev !=
nullptr) {
638 g_return_if_fail(obj !=
nullptr);
639 g_return_if_fail(obj->
parent);
640 g_return_if_fail(obj->
parent ==
this);
641 g_return_if_fail(obj != prev);
645 if (prev !=
nullptr) {
654 g_return_if_fail(
object !=
nullptr);
655 g_return_if_fail(object->
parent ==
this);
658 object->releaseReferences();
660 object->parent =
nullptr;
668 g_return_val_if_fail(
repr !=
nullptr, NULL);
716 if (ochild ==
nullptr) {
725 object->attach(ochild, prev);
733 debug(
"id=%p, typename=%s",
object, g_type_name_from_instance((GTypeInstance*)
object));
741 auto tmp =
children | boost::adaptors::transformed([](
SPObject& obj){
return &obj;});
742 std::vector<SPObject *> toRelease(tmp.begin(), tmp.end());
744 for (
auto& p: toRelease) {
750 debug(
"id=%p, typename=%s",
this, g_type_name_from_instance((GTypeInstance*)
this));
764 g_return_if_fail(ochild !=
nullptr);
766 object->reorder(ochild, prev);
771 g_warning(
"XML Element renamed from %s to %s!", oldname, newname);
782 debug(
"id=%p, typename=%s",
object, g_type_name_from_instance((GTypeInstance*)
object));
792 lang =
object->parent->lang;
804 if (
child ==
nullptr) {
827 debug(
"id=%p, typename=%s",
this, g_type_name_from_instance((GTypeInstance*)
this));
830 g_assert(
repr !=
nullptr);
832 g_assert(this->document ==
nullptr);
833 g_assert(this->repr ==
nullptr);
834 g_assert(this->
getId() ==
nullptr);
853 gchar
const *
id = this->repr->
attribute(
"id");
857 SPObjectImpl::setId(
this, realid.c_str());
860 if (!
id || std::strcmp(
id,
getId()) != 0) {
868 SPObjectImpl::setId(
this,
id);
873 g_assert(this->
getId() ==
nullptr);
892 g_assert(this->
repr);
898 g_assert(this->
repr);
904 g_assert(this->
repr);
906 std::vector<SPObject*> l;
920 g_assert(this->
repr);
927 g_assert(this->
repr);
957 this->
repr =
nullptr;
996 auto const oldname = g_quark_to_string(old_name);
997 auto const newname = g_quark_to_string(new_name);
1004 std::stringstream temp;
1022 gchar
const *new_id = value;
1028 if ( conflict && conflict !=
object ) {
1040 if (object->
getId()) {
1042 SPObjectImpl::setId(
object,
nullptr);
1046 SPObjectImpl::setId(
object, new_id);
1051 object->_default_label =
nullptr;
1058 object->_label = g_strdup(value);
1060 object->_label =
nullptr;
1063 object->_default_label =
nullptr;
1067 if ( value && !std::strcmp(value,
"always") ) {
1075 if (value && !std::strcmp(value,
"preserve")) {
1077 object->xml_space.set = TRUE;
1078 }
else if (value && !std::strcmp(value,
"default")) {
1080 object->xml_space.set = TRUE;
1081 }
else if (object->
parent) {
1086 object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
1104 object->style->readFromObject(
object );
1105 object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
1119 this->
set(key, value);
1132 assert(
key !=
nullptr);
1142 g_assert(
key !=
nullptr);
1145 g_assert(this->
getRepr() !=
nullptr);
1158 auto const key = g_quark_to_string(key_);
1187 if (!
repr && (flags & SP_OBJECT_WRITE_BUILD)) {
1189 if (!( flags & SP_OBJECT_WRITE_EXT )) {
1201 if ( flags & SP_OBJECT_WRITE_EXT &&
1214 bool any_written =
false;
1216 for (
auto * prop : properties) {
1220 auto new_val = prop->get_value();
1221 if (new_val.empty() && !val || new_val != val) {
1237 if( prefs->
getBool(
"/options/svgoutput/check_on_editing") ) {
1258 g_warning(
"Item's style is NULL; repr style attribute is %s", style_str);
1274 assert(tmpsuccessor != NULL);
1280 char const *linked_fill_id =
getAttribute(
"inkscape:linked-fill");
1291 if (tmpsuccessorchild && !obj._tmpsuccessor) {
1305 obj.fixTmpSuccessors();
1308 char const *linked_fill_id =
getAttribute(
"inkscape:linked-fill");
1321 object.unsetTmpSuccessor();
1333 auto group = cast<SPGroup>(
parent);
1335 return group->getTopAncestorNonLayer();
1356 g_critical(
"Attempt to update non-existent repr");
1377 g_assert(doc !=
nullptr);
1387 if (!(flags & SP_OBJECT_WRITE_BUILD) && !
repr) {
1405 g_return_if_fail( this->
document !=
nullptr );
1417 g_return_if_fail(!(flags & SP_OBJECT_PARENT_MODIFIED_FLAG));
1418 g_return_if_fail((flags & SP_OBJECT_MODIFIED_FLAG) || (flags & SP_OBJECT_CHILD_MODIFIED_FLAG));
1419 g_return_if_fail(!((flags & SP_OBJECT_MODIFIED_FLAG) && (flags & SP_OBJECT_CHILD_MODIFIED_FLAG)));
1425 bool already_propagated = (!(this->
uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG)));
1427 if ((this->
uflags & flags) != flags ) {
1433 if (already_propagated) {
1444 objectTrace(
"SPObject::requestDisplayUpdate",
false );
1451 g_return_if_fail(!(flags & ~SP_OBJECT_MODIFIED_CASCADE));
1459#ifdef SP_OBJECT_DEBUG_CASCADE
1460 g_print(
"Update %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *)
this),
getId(), flags, this->
uflags, this->
mflags);
1478 if ((flags & SP_OBJECT_STYLESHEET_MODIFIED_FLAG)) {
1480 }
else if (
parent && (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) && (flags & SP_OBJECT_PARENT_MODIFIED_FLAG)) {
1488 this->
update(ctx, flags);
1497 g_warning(
"SPObject::updateDisplay(SPCtx *ctx, unsigned int flags) : throw in ((SPObjectClass *) G_OBJECT_GET_CLASS(this))->update(this, ctx, flags);");
1509 g_return_if_fail( this->
document !=
nullptr );
1513 g_return_if_fail(!(flags & SP_OBJECT_PARENT_MODIFIED_FLAG));
1514 g_return_if_fail((flags & SP_OBJECT_MODIFIED_FLAG) || (flags & SP_OBJECT_CHILD_MODIFIED_FLAG));
1515 g_return_if_fail(!((flags & SP_OBJECT_MODIFIED_FLAG) && (flags & SP_OBJECT_CHILD_MODIFIED_FLAG)));
1521 bool already_propagated = (!(this->
mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG)));
1528 if (already_propagated) {
1536 objectTrace(
"SPObject::requestModified",
false );
1543 g_return_if_fail(!(flags & ~SP_OBJECT_MODIFIED_CASCADE));
1546 objectTrace(
"SPObject::emitModified",
true, flags );
1549#ifdef SP_OBJECT_DEBUG_CASCADE
1550 g_print(
"Modified %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *)
this),
getId(), flags, this->
uflags, this->
mflags);
1573 g_assert(
repr !=
nullptr);
1582 g_assert(this->
repr !=
nullptr);
1592 g_assert(this->
repr !=
nullptr);
1614 g_assert(this->
getRepr()!=
nullptr);
1615 double nan = std::numeric_limits<double>::quiet_NaN();
1617 if (std::isnan(temp_val)) {
1634 if (
auto local = std::strchr(
name,
':')) {
1643 if (
auto root = cast<SPRoot>(
static_cast<SPObject *
>(iter))) {
1644 if (
root->svg.getVersion() < version) {
1645 root->svg.version = version;
1705 bool just_whitespace =
true;
1706 for (
const gchar *cp = value; *cp; ++cp) {
1707 if (!std::strchr(
"\r\n \t", *cp)) {
1708 just_whitespace =
false;
1712 if (just_whitespace) {
1719 if (current_value) {
1720 bool different = std::strcmp(current_value, value);
1721 g_free(current_value);
1731 if (value ==
nullptr) {
1732 if (elem ==
nullptr) {
1745 if (elem ==
nullptr) {
1755 auto tmp = elem->
children | boost::adaptors::transformed([](
SPObject& obj) {
return &obj; });
1756 std::vector<SPObject*> vec(tmp.begin(), tmp.end());
1757 for (
auto &
child: vec) {
1758 child->deleteObject();
1772 !std::strcmp(
child.repr->name(), tagname)) {
1788 text +=
child.textualContent();
1791 text +=
child.repr->content();
1799 if (
auto filename =
repr->
attribute(
"inkscape:export-filename")) {
1800 return Glib::ustring(filename);
1809 std::string base = Glib::path_get_dirname(doc_filename ? doc_filename : filename.c_str());
1824 if (!dpi.
x() || !dpi.
y()) {
1837 std::cout <<
"SP Object Tree" << std::endl;
1839 std::cout <<
"SP: ";
1840 for (
unsigned i = 0; i < level; ++i) {
1843 std::cout << (
getId()?
getId():
"No object id")
1844 <<
" clone: " << std::boolalpha << (
bool)
cloned
1845 <<
" hrefcount: " <<
hrefcount << std::endl;
1847 child.recursivePrintTree(level + 1);
1858 std::cout << text <<
":"
1871 std::cout << text <<
":"
1881std::ostream &operator<<(std::ostream &out,
const SPObject &o)
1884 <<
" cloned: " << std::boolalpha << (
bool)o.
cloned
unsigned int sp_attribute_clean_get_prefs()
Get preferences.
void sp_attribute_clean_style(Node *repr, unsigned int flags)
Clean CSS style on an element.
Utility functions related to parsing and validation of XML attributes.
gchar const * sp_attribute_name(SPAttr id)
Get attribute name by id.
SPAttr sp_attribute_lookup(gchar const *key)
Get attribute id by name.
Lookup dictionary for attributes/properties.
@ INVALID
Must have value 0.
Two-dimensional point that doubles as a vector.
constexpr Coord y() const noexcept
constexpr Coord x() const noexcept
A thin wrapper around std::ostringstream, but writing floating point numbers in the format required b...
unsigned _anchored_refcount() const
Preference storage class.
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
static Preferences * get()
Access the singleton Preferences object.
Non-owning reference to 'const char*' Main-purpose: avoid overloads of type f(char*,...
char const * pointer() const
Interface for refcounted XML nodes.
virtual Node * parent()=0
Get the parent of this node.
virtual void addChild(Node *child, Node *after)=0
Insert another node as a child of this node.
virtual void appendChild(Node *child)=0
Append a node as the last child of this node.
virtual char const * name() const =0
Get the name of the element node.
double getAttributeDouble(Util::const_char_ptr key, double default_value=0.0) const
void setAttributeOrRemoveIfEmpty(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
Change an attribute of this node.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual Node * duplicate(Document *doc) const =0
Create a duplicate of this node.
virtual Node * firstChild()=0
Get the first child of this node.
virtual unsigned position() const =0
Get the index of this node in parent's child order.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
void removeAttribute(Inkscape::Util::const_char_ptr key)
Remove an attribute of this node.
virtual void addObserver(NodeObserver &observer)=0
Add an object that will be notified of the changes to this node.
virtual Document * document()=0
Get the node's associated document.
int getAttributeInt(Util::const_char_ptr key, int default_value=0) const
virtual NodeType type() const =0
Get the type of the node.
virtual void removeObserver(NodeObserver &observer)=0
Remove an object from the list of observers.
bool setAttributeSvgDouble(Util::const_char_ptr key, double val)
For attributes where an exponent is allowed.
Typed SVG document implementation.
char const * getDocumentFilename() const
std::string generate_unique_id(char const *prefix)
Generate a document-wide unique id.
unsigned update_in_progress
For sanity check in SPObject::requestDisplayUpdate.
SPObject * getObjectById(std::string const &id) const
void process_pending_resource_changes()
void bindObjectToId(char const *id, SPObject *object)
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
void bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *object)
void queueForOrphanCollection(SPObject *object)
SPObject * getObjectByRepr(Inkscape::XML::Node *repr) const
SPObject is an abstract base class of all of the document nodes at the SVG document level.
CollectionPolicy collectionPolicy() const
Set the policy under which this object will be orphan-collected.
char const * label() const
Gets the author-visible label property for the object or a default if no label is defined.
int getIntAttribute(char const *key, int def)
Inkscape::XML::Node * repr
char * desc() const
Returns the description of this object, or NULL if there is none.
void requestOrphanCollection()
Requests a later automatic call to collectOrphan().
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)
SPObject()
Constructor, sets all attributes to default values.
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)
void setExportFilename(Glib::ustring filename)
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.
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 * get_child_by_repr(Inkscape::XML::Node *repr)
Return object's child whose node pointer equals repr.
virtual void read_content()
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.
virtual void set(SPAttr key, const char *value)
void updateDisplay(SPCtx *ctx, unsigned int flags)
Updates the object's display immediately.
virtual void remove_child(Inkscape::XML::Node *child)
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
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
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.
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
~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.
void setLabel(char const *label)
Sets the author-visible label for this object.
virtual void update(SPCtx *ctx, unsigned int flags)
SPStyle * context_style
Represents the style that should be used to resolve 'context-fill' and 'context-stroke'.
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)
virtual void modified(unsigned int flags)
void readAttr(char const *key)
Read value of key attribute from XML node into object.
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
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
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.
bool isAncestorOf(SPObject const *object) const
True if object is non-NULL and this is some in/direct parent of object.
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 addChild(Inkscape::XML::Node *child, Inkscape::XML::Node *prev=nullptr)
std::list< SPObject * > hrefList
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.
void unsetTmpSuccessor()
Unset object supercedes.
virtual void order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old_repr, Inkscape::XML::Node *new_repr)
char const * getTagName() const
SPObject const * getTopAncestorNonLayer() const
Returns ancestor non layer.
void setCSS(SPCSSAttr *css, char const *attr)
sigc::signal< void(SPObject *)> _release_signal
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.
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
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
T< SPAttr::FILL, SPIPaint > fill
fill
bool block_filter_bbox_updates
(hack) Temporarily set to true to block filter changes from updating the object's bbox in situations ...
T< SPAttr::STROKE, SPIPaint > stroke
stroke
void readFromObject(SPObject *object)
Read style properties from object's repr.
Glib::ustring write(unsigned flags, SPStyleSrc style_src_req, SPStyle const *base=nullptr) const
const std::vector< SPIBase * > properties()
T< SPAttr::SHAPE_INSIDE, SPIShapes > shape_inside
SVG2 Text Wrapping.
T< SPAttr::FILTER, SPIFilter > filter
Filter effect.
T< SPAttr::SHAPE_SUBTRACT, SPIShapes > shape_subtract
void cascade(SPStyle const *parent)
Sets computed values in style, which may involve inheriting from (or in some other way calculating fr...
SPObject of the color-profile object found a direct child of defs.
TODO: insert short description here.
std::shared_ptr< Css const > css
Inkscape::XML::Node * node
ForwardIterator nearest_common_ancestor(ForwardIterator a, ForwardIterator b, ForwardIterator end)
Time costs:
std::shared_ptr< std::string > demangle(char const *name)
static R & anchor(R &r)
Increments the reference count of a anchored object.
static R & release(R &r)
Decrements the reference count of a anchored object.
Miscellaneous supporting code.
ptr_shared format(char const *format,...) G_GNUC_PRINTF(1
bool id_permitted(Node const *node)
NodeType
Enumeration containing all supported node types.
@ ELEMENT_NODE
Regular element node, e.g. <group />.
@ TEXT_NODE
Text node, e.g. "Some text" in <group>Some text</group> is represented by a text node.
std::pair< char const *, char const * > getHrefAttribute(XML::Node const &node)
Get the 'href' or 'xlink:href' (fallback) attribute from an XML node.
std::string optimizePath(std::string const &path, std::string const &base, unsigned int parents)
Convert an absolute path into a relative one if possible to do in the given number of parent steps.
Helper functions for XML nodes.
static cairo_user_data_key_t key
Singleton class to access the preferences file in a convenient way.
void sp_repr_css_change(Node *repr, SPCSSAttr *css, gchar const *attr)
Creates a new SPCSAttr with the values filled from a repr, merges in properties from the given SPCSAt...
void sp_repr_css_set(Node *repr, SPCSSAttr *css, gchar const *attr)
Sets an attribute (e.g.
int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second)
Works for different-parent objects, so long as they have a common ancestor.
void sp_repr_unparent(Inkscape::XML::Node *repr)
Remove repr from children of its parent node.
bool sp_object_compare_position_bool(SPObject const *first, SPObject const *second)
static SPObject * get_closest_child_by_repr(SPObject &obj, Inkscape::XML::Node *ref)
Get closest child to a reference representation.
static SPObject const * AncestorSon(SPObject const *obj, SPObject const *ancestor)
static unsigned indent_level
int sp_object_compare_position(SPObject const *first, SPObject const *second)
Compares height of objects in tree.
static gchar const * sp_xml_get_space_string(unsigned int space)
Return string representation of space value.
SPObject * sp_object_unref(SPObject *object, SPObject *owner)
Decrease reference count of object, with possible debugging and finalization.
SPObject * sp_object_ref(SPObject *object, SPObject *owner)
Increase reference count of object, with possible debugging.
SPObject * sp_object_unref(SPObject *object, SPObject *owner=nullptr)
Decrease reference count of object, with possible debugging and finalization.
SPObject * sp_object_ref(SPObject *object, SPObject *owner=nullptr)
Increase reference count of object, with possible debugging.
SPRoot: SVG <svg> implementation.
TODO: insert short description here.
TODO: insert short description here.
TODO: insert short description here.
Interface for XML documents.
virtual Node * createTextNode(char const *content)=0
virtual Node * createElement(char const *name)=0
static std::string get_type_string(Inkscape::XML::Node const &node)
static SPObject * createObject(std::string const &id)
static const unsigned SP_STYLE_FLAG_IFSET(1<< 0)
static const unsigned SP_STYLE_FLAG_IFSRC(1<< 3)
SPStyle - a style object for SPItem objects.