25#include <boost/range/adaptor/transformed.hpp>
27#include "helper/sp-marshal.h"
55#define noSP_OBJECT_DEBUG_CASCADE
57#define noSP_OBJECT_DEBUG
60# define debug(f, a...) { g_print("%s(%d) %s:", \
61 __FILE__,__LINE__,__FUNCTION__); \
66# define debug(f, a...)
85 static void setIdNull(
SPObject* obj ) {
97 static void setId(
SPObject* obj, gchar
const*
id ) {
98 if (obj && (
id != obj->
id) ) {
104 obj->
id = g_strdup(
id);
118 debug(
"id=%p, typename=%s",
this, g_type_name_from_instance((GTypeInstance *)
this));
120 SPObjectImpl::setIdNull(
this);
152 this->
repr =
nullptr;
166 objectTrace(
"SPObject::modified (default) (empty function)" );
167 objectTrace(
"SPObject::modified (default)",
false );
179class RefCountEvent :
public BaseRefCountEvent {
181 RefCountEvent(
SPObject *
object,
int bias,
char const *name)
182 : BaseRefCountEvent(name)
184 _addProperty(
"object",
Util::format(
"%p",
object).pointer());
190class RefEvent :
public RefCountEvent {
193 : RefCountEvent(object, 1,
"sp-object-ref")
197class UnrefEvent :
public RefCountEvent {
200 : RefCountEvent(object, -1,
"sp-object-unref")
215 ret.insert(std::string(
id));
227 return std::string(
"url(#") +
id +
")";
243 g_return_val_if_fail(
object !=
nullptr, NULL);
254 g_return_val_if_fail(
object !=
nullptr, NULL);
272 if (!owner || !owner->
cloned) {
283 if (!owner || !owner->
cloned) {
295 SPObject *topmost_collectable =
nullptr;
298 if ( iter->_total_hrefcount < iter->hrefcount ) {
299 g_critical(
"HRefs overcounted");
301 if ( iter->_total_hrefcount == 0 &&
304 topmost_collectable = iter;
307 if (topmost_collectable) {
317 objects.push_back(linked);
324 g_return_val_if_fail(
object !=
nullptr,
false);
325 object =
object->parent;
327 if (
object ==
this ) {
330 object =
object->parent;
336 g_return_val_if_fail(
object !=
nullptr, NULL);
339 return nearest_common_ancestor<SPObject::ConstParentIterator>(
this,
object,
nullptr);
344 if ( obj && ancestor ) {
345 if (obj->
parent == ancestor) {
357 if (first != second) {
362 if (ancestor == first) {
364 }
else if (ancestor == second) {
388 g_critical(
"Attempt to append repr as child of cloned object");
395 g_assert(this->
getRepr() !=
nullptr);
401 g_assert(this->
getRepr() !=
nullptr);
406 std::vector<SPObject*> l;
418 std::vector<SPObject *> ancestors;
420 ancestors.push_back(iter);
458 g_return_if_fail(
document !=
nullptr);
462 if (is<SPStyleElem>(
this)) {
464 }
else if (is<SPScript>(
this)) {
466 }
else if (is<SPFont>(
this)) {
468 }
else if (!prefs->
getBool(
"/options/cleanupswatches/value",
false) && is<SPPaintServer>(
this) &&
static_cast<SPPaintServer*
>(
this)->
isSwatch()) {
470 }
else if (is<Inkscape::ColorProfile>(
this)) {
472 }
else if (is<LivePathEffectObject>(
this)) {
494 child._sendDeleteSignalRecursive();
501 if (is<SPLPEItem>(
this)) {
502 cast<SPLPEItem>(
this)->removeAllPathEffects(
false, propagate_descendants);
507 if (propagate_descendants) {
524 std::vector<SPObject *> toDelete;
526 if (is<SPItem>(&
child)) {
527 if (
child.isAncestorOf(except)) {
528 child.cropToObject(except);
529 }
else if (&
child != except) {
531 toDelete.push_back(&
child);
535 for (
auto &i : toDelete) {
536 i->deleteObject(
true,
true);
554 if (except_objects.empty()) {
557 std::vector<SPObject *> links;
558 std::vector<SPObject *> toDelete;
561 for (
auto item : except_objects) {
565 except_objects.insert(except_objects.end(), links.begin(), links.end());
570 for (
auto &i : toDelete) {
572 i->deleteObject(
false,
false);
579 if (is<SPItem>(&
child)) {
581 for (
auto except : excepts) {
582 if (&
child == except) {
586 if (
child.isAncestorOf(except)) {
590 if (child_flag == 1) {
591 objects.push_back(&
child);
592 }
else if (child_flag == 2) {
593 child.getObjectsExcept(objects, excepts);
604 if (std::find(objects.begin(), objects.end(), link) == objects.end()) {
605 objects.push_back(link);
606 link->getLinkedRecursive(objects,
direction);
611 if (is<SPItem>(&
child)) {
620 g_return_if_fail(
object !=
nullptr);
621 g_return_if_fail(!prev || prev->
parent ==
this);
622 g_return_if_fail(!object->
parent);
625 object->parent =
this;
629 if (prev !=
nullptr) {
639 g_return_if_fail(obj !=
nullptr);
640 g_return_if_fail(obj->
parent);
641 g_return_if_fail(obj->
parent ==
this);
642 g_return_if_fail(obj != prev);
646 if (prev !=
nullptr) {
655 g_return_if_fail(
object !=
nullptr);
656 g_return_if_fail(object->
parent ==
this);
659 object->releaseReferences();
661 object->parent =
nullptr;
669 g_return_val_if_fail(
repr !=
nullptr, NULL);
717 if (ochild ==
nullptr) {
726 object->attach(ochild, prev);
734 debug(
"id=%p, typename=%s",
object, g_type_name_from_instance((GTypeInstance*)
object));
742 auto tmp =
children | boost::adaptors::transformed([](
SPObject& obj){
return &obj;});
743 std::vector<SPObject *> toRelease(tmp.begin(), tmp.end());
745 for (
auto& p: toRelease) {
751 debug(
"id=%p, typename=%s",
this, g_type_name_from_instance((GTypeInstance*)
this));
765 g_return_if_fail(ochild !=
nullptr);
767 object->reorder(ochild, prev);
772 g_warning(
"XML Element renamed from %s to %s!", oldname, newname);
783 debug(
"id=%p, typename=%s",
object, g_type_name_from_instance((GTypeInstance*)
object));
793 lang =
object->parent->lang;
805 if (
child ==
nullptr) {
828 debug(
"id=%p, typename=%s",
this, g_type_name_from_instance((GTypeInstance*)
this));
831 g_assert(
repr !=
nullptr);
833 g_assert(this->document ==
nullptr);
834 g_assert(this->repr ==
nullptr);
835 g_assert(this->
getId() ==
nullptr);
854 gchar
const *
id = this->repr->
attribute(
"id");
858 SPObjectImpl::setId(
this, realid.c_str());
861 if (!
id || std::strcmp(
id,
getId()) != 0) {
869 SPObjectImpl::setId(
this,
id);
874 g_assert(this->
getId() ==
nullptr);
893 g_assert(this->
repr);
899 g_assert(this->
repr);
905 g_assert(this->
repr);
907 std::vector<SPObject*> l;
921 g_assert(this->
repr);
928 g_assert(this->
repr);
958 this->
repr =
nullptr;
997 auto const oldname = g_quark_to_string(old_name);
998 auto const newname = g_quark_to_string(new_name);
1005 std::stringstream temp;
1023 gchar
const *new_id = value;
1029 if ( conflict && conflict !=
object ) {
1041 if (object->
getId()) {
1043 SPObjectImpl::setId(
object,
nullptr);
1047 SPObjectImpl::setId(
object, new_id);
1052 object->_default_label =
nullptr;
1059 object->_label = g_strdup(value);
1061 object->_label =
nullptr;
1064 object->_default_label =
nullptr;
1068 if ( value && !std::strcmp(value,
"always") ) {
1076 if (value && !std::strcmp(value,
"preserve")) {
1078 object->xml_space.set = TRUE;
1079 }
else if (value && !std::strcmp(value,
"default")) {
1081 object->xml_space.set = TRUE;
1082 }
else if (object->
parent) {
1087 object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
1105 object->style->readFromObject(
object );
1106 object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
1120 this->
set(key, value);
1133 assert(
key !=
nullptr);
1143 g_assert(
key !=
nullptr);
1146 g_assert(this->
getRepr() !=
nullptr);
1159 auto const key = g_quark_to_string(key_);
1188 if (!
repr && (flags & SP_OBJECT_WRITE_BUILD)) {
1190 if (!( flags & SP_OBJECT_WRITE_EXT )) {
1202 if ( flags & SP_OBJECT_WRITE_EXT &&
1215 bool any_written =
false;
1217 for (
auto * prop : properties) {
1221 auto new_val = prop->get_value();
1222 if (new_val.empty() && !val || new_val != val) {
1238 if( prefs->
getBool(
"/options/svgoutput/check_on_editing") ) {
1257 g_warning(
"Item's style is NULL; repr style attribute is %s", style_str);
1273 assert(tmpsuccessor != NULL);
1279 char const *linked_fill_id =
getAttribute(
"inkscape:linked-fill");
1290 if (tmpsuccessorchild && !obj._tmpsuccessor) {
1304 obj.fixTmpSuccessors();
1307 char const *linked_fill_id =
getAttribute(
"inkscape:linked-fill");
1320 object.unsetTmpSuccessor();
1332 auto group = cast<SPGroup>(
parent);
1334 return group->getTopAncestorNonLayer();
1355 g_critical(
"Attempt to update non-existent repr");
1376 g_assert(doc !=
nullptr);
1386 if (!(flags & SP_OBJECT_WRITE_BUILD) && !
repr) {
1404 g_return_if_fail( this->
document !=
nullptr );
1416 g_return_if_fail(!(flags & SP_OBJECT_PARENT_MODIFIED_FLAG));
1417 g_return_if_fail((flags & SP_OBJECT_MODIFIED_FLAG) || (flags & SP_OBJECT_CHILD_MODIFIED_FLAG));
1418 g_return_if_fail(!((flags & SP_OBJECT_MODIFIED_FLAG) && (flags & SP_OBJECT_CHILD_MODIFIED_FLAG)));
1424 bool already_propagated = (!(this->
uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG)));
1426 if ((this->
uflags & flags) != flags ) {
1432 if (already_propagated) {
1443 objectTrace(
"SPObject::requestDisplayUpdate",
false );
1450 g_return_if_fail(!(flags & ~SP_OBJECT_MODIFIED_CASCADE));
1458#ifdef SP_OBJECT_DEBUG_CASCADE
1459 g_print(
"Update %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *)
this),
getId(), flags, this->
uflags, this->
mflags);
1477 if ((flags & SP_OBJECT_STYLESHEET_MODIFIED_FLAG)) {
1479 }
else if (
parent && (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) && (flags & SP_OBJECT_PARENT_MODIFIED_FLAG)) {
1487 this->
update(ctx, flags);
1496 g_warning(
"SPObject::updateDisplay(SPCtx *ctx, unsigned int flags) : throw in ((SPObjectClass *) G_OBJECT_GET_CLASS(this))->update(this, ctx, flags);");
1508 g_return_if_fail( this->
document !=
nullptr );
1512 g_return_if_fail(!(flags & SP_OBJECT_PARENT_MODIFIED_FLAG));
1513 g_return_if_fail((flags & SP_OBJECT_MODIFIED_FLAG) || (flags & SP_OBJECT_CHILD_MODIFIED_FLAG));
1514 g_return_if_fail(!((flags & SP_OBJECT_MODIFIED_FLAG) && (flags & SP_OBJECT_CHILD_MODIFIED_FLAG)));
1520 bool already_propagated = (!(this->
mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG)));
1527 if (already_propagated) {
1535 objectTrace(
"SPObject::requestModified",
false );
1542 g_return_if_fail(!(flags & ~SP_OBJECT_MODIFIED_CASCADE));
1545 objectTrace(
"SPObject::emitModified",
true, flags );
1548#ifdef SP_OBJECT_DEBUG_CASCADE
1549 g_print(
"Modified %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *)
this),
getId(), flags, this->
uflags, this->
mflags);
1572 g_assert(
repr !=
nullptr);
1581 g_assert(this->
repr !=
nullptr);
1591 g_assert(this->
repr !=
nullptr);
1613 g_assert(this->
getRepr()!=
nullptr);
1614 double nan = std::numeric_limits<double>::quiet_NaN();
1616 if (std::isnan(temp_val)) {
1633 if (
auto local = std::strchr(name,
':')) {
1643 if (is<SPRoot>(
object)) {
1644 auto root = cast<SPRoot>(
object);
1645 if (
root->version.svg < version ) {
1646 root->version.svg = version;
1706 bool just_whitespace =
true;
1707 for (
const gchar *cp = value; *cp; ++cp) {
1708 if (!std::strchr(
"\r\n \t", *cp)) {
1709 just_whitespace =
false;
1713 if (just_whitespace) {
1720 if (current_value) {
1721 bool different = std::strcmp(current_value, value);
1722 g_free(current_value);
1732 if (value ==
nullptr) {
1733 if (elem ==
nullptr) {
1746 if (elem ==
nullptr) {
1756 auto tmp = elem->
children | boost::adaptors::transformed([](
SPObject& obj) {
return &obj; });
1757 std::vector<SPObject*> vec(tmp.begin(), tmp.end());
1758 for (
auto &
child: vec) {
1759 child->deleteObject();
1773 !std::strcmp(
child.repr->name(), tagname)) {
1789 text +=
child.textualContent();
1792 text +=
child.repr->content();
1800 if (
auto filename =
repr->
attribute(
"inkscape:export-filename")) {
1801 return Glib::ustring(filename);
1810 std::string base = Glib::path_get_dirname(doc_filename ? doc_filename : filename.c_str());
1825 if (!dpi.
x() || !dpi.
y()) {
1838 std::cout <<
"SP Object Tree" << std::endl;
1840 std::cout <<
"SP: ";
1841 for (
unsigned i = 0; i < level; ++i) {
1844 std::cout << (
getId()?
getId():
"No object id")
1845 <<
" clone: " << std::boolalpha << (
bool)
cloned
1846 <<
" hrefcount: " <<
hrefcount << std::endl;
1848 child.recursivePrintTree(level + 1);
1859 std::cout << text <<
":"
1872 std::cout << text <<
":"
1885 <<
" 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.
std::ostream & operator<<(std::ostream &out_file, const Geom::Affine &m)
Print out the Affine (for debugging).
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 Node * next()=0
Get the next sibling 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...
TODO: insert short description here.
TODO: insert short description here.
std::shared_ptr< Css const > css
Inkscape::XML::Node * node
Bezier reverse(const Bezier &a)
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.
static Geom::Point direction(Geom::Point const &first, Geom::Point const &second)
Computes an unit vector of the direction from first to second control point.
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.
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.
pair< double, double > Point