22#include <glibmm/i18n.h>
35# define debug(f, a...) { g_message("%s(%d) %s:", \
36 __FILE__,__LINE__,__FUNCTION__); \
41# define debug(f, a...)
54 , uriOriginalRef(this)
55 , stringChild(nullptr)
90 debug(
"0x%p %s(%u): '%s'",
this,
101 }
else if ((this->
href && strcmp(value, this->
href) != 0) || (!this->
href)) {
106 this->
href =
nullptr;
109 href = g_strdup(value);
115 g_warning(
"%s", e.what());
130 unsigned childflags = flags;
131 if (flags & SP_OBJECT_MODIFIED_FLAG) {
132 childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
134 childflags &= SP_OBJECT_MODIFIED_CASCADE;
139 if ( childflags || (
child->uflags & SP_OBJECT_MODIFIED_FLAG )) {
148 if (flags & SP_OBJECT_MODIFIED_FLAG) {
149 flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
152 flags &= SP_OBJECT_MODIFIED_CASCADE;
159 if (flags || (
child->mflags & SP_OBJECT_MODIFIED_FLAG)) {
160 child->emitModified(flags);
170 if ((flags & SP_OBJECT_WRITE_BUILD) && !
repr) {
178 auto uri_string = uri.c_str();
179 debug(
"uri_string=%s", uri_string);
193 while ( parent_text && !is<SPText>(parent_text) ) {
194 parent_text = parent_text->
parent;
197 if (parent_text ==
nullptr) {
202 return cast<SPText>(parent_text)->layout.bounds(
transform,
213 return _(
"Cloned Character Data");
222 if (is<SPItem>(referred)) {
223 child_desc = cast<SPItem>(referred)->detailedDescription();
225 child_desc = g_strdup(
"");
228 char *ret = g_strdup_printf(
"%s%s",
229 (is<SPItem>(referred) ? _(
" from ") :
""), child_desc);
235 return g_strdup(_(
"[orphaned]"));
300 bool allowed =
false;
302 if (tref && possible_ref) {
303 if (tref != possible_ref) {
304 bool ancestor =
false;
306 if (possible_ref == obj) {
327 bool fully_contained =
false;
329 if (start_item && end_item) {
334 if (!(is<SPString>(start_item) && is<SPTRef>(start_item->
parent))
335 && !(is<SPString>(end_item) && is<SPTRef>(end_item->
parent))) {
336 fully_contained =
true;
341 else if ((is<SPString>(start_item) && is<SPTRef>(start_item->
parent))
342 && (is<SPString>(end_item) && is<SPTRef>(end_item->
parent))) {
343 if (
start == cast<SPString>(start_item)->
string.begin()
344 &&
end == cast<SPString>(start_item)->
string.
end()) {
345 fully_contained =
true;
351 else if ((is<SPString>(start_item) && is<SPTRef>(start_item->
parent))
352 && !(is<SPString>(end_item) && is<SPTRef>(end_item->
parent))) {
353 if (
start == cast<SPString>(start_item)->
string.begin()) {
354 fully_contained =
true;
359 else if (!(is<SPString>(start_item) && is<SPTRef>(start_item->
parent))
360 && (is<SPString>(end_item) && is<SPTRef>(end_item->
parent))) {
361 if (
end == cast<SPString>(start_item)->
string.
end()) {
362 fully_contained =
true;
367 return fully_contained;
375 Glib::ustring charData =
"";
407 if (
root && retString) {
411 *retString += (
root->content());
413 debug(
"%s", retString->c_str());
440 if (is<SPTRef>(obj)) {
442 auto tref = cast<SPTRef>(obj);
444 if (tref && tref->stringChild) {
454 tref_parent->
addChild(new_tspan_repr, tref_repr);
461 new_tspan_repr->
addChild(new_string_repr,
nullptr);
476 tref->deleteObject(
false);
483 tref->setSuccessor(new_tspan);
491 std::vector<SPObject *> l;
gchar const * sp_attribute_name(SPAttr id)
Get attribute name by id.
Lookup dictionary for attributes/properties.
TODO: insert short description here.
3x3 matrix representing an affine transformation.
Axis-aligned rectangle that can be empty.
URI const * getURI() const
Returns a pointer to a URI containing the currently attached URI, or NULL if no URI is currently atta...
void detach()
Detaches from the currently attached URI target, if any; the current referrent is signaled as NULL.
sigc::signal< void(SPObject *, SPObject *)> changedSignal()
Accessor for the referrent change notification signal; this signal is emitted whenever the URIReferen...
void attach(URI const &uri)
Attaches to a URI, relative to the specified document.
Represents an URI as per RFC 2396.
std::string str(char const *baseuri=nullptr) const
Return the string representation of this URI.
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.
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 char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
Typed SVG document implementation.
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
SPObject * getObjectByRepr(Inkscape::XML::Node *repr) const
Base class for visual SVG elements.
void update(SPCtx *ctx, unsigned int flags) override
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
void set(SPAttr key, char const *value) override
void build(SPDocument *document, Inkscape::XML::Node *repr) override
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Inkscape::XML::Node * repr
void detach(SPObject *object)
Remove object from parent's children, release and unref it.
sigc::connection connectDelete(sigc::slot< void(SPObject *)> slot)
Connects a slot to be called when an object is deleted.
void attach(SPObject *object, SPObject *prev)
Put object into object tree, under parent, and behind prev; also update object's XML space.
void updateDisplay(SPCtx *ctx, unsigned int flags)
Updates the object's display immediately.
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
Inkscape::XML::Node * updateRepr(unsigned int flags=SP_OBJECT_WRITE_EXT)
Updates the object's repr based on the object's state.
void readAttr(char const *key)
Read value of key attribute from XML node into object.
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.
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
void merge(SPStyle const *parent)
Combine style and parent style specifications into a single style specification that preserves (as mu...
void cascade(SPStyle const *parent)
Sets computed values in style, which may involve inheriting from (or in some other way calculating fr...
SPItem * getObject() const
const char * displayName() const override
The item's type name as a translated human string.
SPTRefReference uriOriginalRef
SPObject * getObjectReferredTo()
Return the object referred to via the URI reference.
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
TextTagAttributes attributes
sigc::connection _changed_connection
char * description() const override
Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const override
Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) override
void modified(unsigned int flags) override
const char * typeName() const override
The item's type name, not node tag name.
sigc::connection _delete_connection
void set(SPAttr key, char const *value) override
void update(SPCtx *ctx, unsigned int flags) override
bool readSingleAttribute(SPAttr key, gchar const *value, SPStyle const *style, Geom::Rect const *viewport)
Process the parameters from the set() function of SPObject.
void writeTo(Inkscape::XML::Node *node) const
Write out all the contents of attributes to the given node.
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.
@ TEXT_NODE
Text node, e.g. "Some text" in <group>Some text</group> is represented by a text node.
void setHrefAttribute(XML::Node &node, Util::const_char_ptr value)
If the 'href' attribute already exists for the given node, then set a new value for it.
static cairo_user_data_key_t key
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.
bool sp_tref_fully_contained(SPObject *start_item, Glib::ustring::iterator &start, SPObject *end_item, Glib::ustring::iterator &end)
Returns true if a tref is fully contained in the confines of the given iterators and layout (or if th...
static void build_string_from_root(Inkscape::XML::Node *root, Glib::ustring *retString)
Using depth-first search, build up a string by concatenating all SPStrings found in the tree starting...
bool sp_tref_reference_allowed(SPTRef *tref, SPObject *possible_ref)
Returns true when the given tref is allowed to refer to a particular object.
void sp_tref_update_text(SPTRef *tref)
static void sp_tref_href_changed(SPObject *old_ref, SPObject *ref, SPTRef *tref)
SPObject * sp_tref_convert_to_tspan(SPObject *obj)
This function will create a new tspan element with the same attributes as the tref had and add the sa...
static void sp_tref_delete_self(SPObject *deleted, SPTRef *self)
Delete the tref object.
SVG <tref> implementation, see sp-tref.cpp.
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)
SPStyle - a style object for SPItem objects.
unsigned sp_text_get_length_upto(SPObject const *item, SPObject const *upto)
Recursively gets the length of all the SPStrings at or below the given item, before and not including...