Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::XML::NodeObserver Class Reference

Interface for XML node observers. More...

#include <node-observer.h>

Inheritance diagram for Inkscape::XML::NodeObserver:
Inkscape::UI::Dialog::AttrDialog Inkscape::UI::Dialog::DocumentProperties::WatchConnection Inkscape::UI::ShapeEditor Inkscape::UI::Toolbar::ArcToolbar Inkscape::UI::Toolbar::Box3DToolbar Inkscape::UI::Toolbar::ConnectorToolbar Inkscape::UI::Toolbar::RectToolbar Inkscape::UI::Toolbar::SpiralToolbar Inkscape::UI::Toolbar::StarToolbar Inkscape::UI::Tools::CCToolLayerNodeObserver Inkscape::UI::Tools::CCToolShapeNodeObserver Inkscape::XML::CompositeNodeObserver Inkscape::XML::SignalObserver Inkscape::XML::SimpleDocument LPENodeObserver Persp3DNodeObserver SPObject SPStyleElemNodeObserver SPStyleElemTextNodeObserver SPTRefReference

Public Member Functions

virtual ~NodeObserver ()=default
 
virtual void notifyChildAdded (Node &node, Node &child, Node *prev)
 Child addition callback.
 
virtual void notifyChildRemoved (Node &node, Node &child, Node *prev)
 Child removal callback.
 
virtual void notifyChildOrderChanged (Node &node, Node &child, Node *old_prev, Node *new_prev)
 Child order change callback.
 
virtual void notifyContentChanged (Node &node, Util::ptr_shared old_content, Util::ptr_shared new_content)
 Content change callback.
 
virtual void notifyAttributeChanged (Node &node, GQuark name, Util::ptr_shared old_value, Util::ptr_shared new_value)
 Attribute change callback.
 
virtual void notifyElementNameChanged (Node &node, GQuark old_name, GQuark new_name)
 Element name change callback.
 

Protected Member Functions

 NodeObserver ()=default
 

Detailed Description

Interface for XML node observers.

This class defines an interface for objects that can receive XML node state change notifications. The observer has to be registered using the Node::addObserver() method to be notified of changes of this node only, or using Node::addSubtreeObserver() to also receive notifications about its descendants. All observer methods are called when the operations in question have been completed, just before returning from the modifying methods.

Be careful when e.g. changing an attribute of node in notifyAttributeChanged(). The method will be called again due to the XML modification performed in it. If you don't take special precautions to ignore the second call, it will result in infinite recursion.

The virtual methods of this class do nothing by default, so you don't need to provide stubs for things you don't use. A good idea is to make the observer register itself on construction and unregister itself on destruction. This will ensure there are no dangling references.

Definition at line 50 of file node-observer.h.

Constructor & Destructor Documentation

◆ NodeObserver()

Inkscape::XML::NodeObserver::NodeObserver ( )
protecteddefault

◆ ~NodeObserver()

virtual Inkscape::XML::NodeObserver::~NodeObserver ( )
virtualdefault

Member Function Documentation

◆ notifyAttributeChanged()

virtual void Inkscape::XML::NodeObserver::notifyAttributeChanged ( Node node,
GQuark  name,
Util::ptr_shared  old_value,
Util::ptr_shared  new_value 
)
inlinevirtual

Attribute change callback.

This method is called whenever one of a node's attributes is changed.

Parameters
nodeThe changed XML node
nameGQuark corresponding to the attribute's name
old_valueOld value of the modified attribute. Is a nullptr when the attribute is added.
new_valueNew value of the modified attribute. Is a nullptr when the attribute is removed.

Reimplemented in Persp3DNodeObserver, Inkscape::UI::Tools::CCToolShapeNodeObserver, LPENodeObserver, SPObject, Inkscape::UI::ShapeEditor, SPTRefReference, Inkscape::XML::SignalObserver, Inkscape::XML::CompositeNodeObserver, Inkscape::XML::SimpleDocument, Inkscape::UI::Toolbar::SpiralToolbar, Inkscape::UI::Dialog::DocumentProperties::WatchConnection, Inkscape::UI::Toolbar::ArcToolbar, Inkscape::UI::Toolbar::Box3DToolbar, Inkscape::UI::Toolbar::ConnectorToolbar, Inkscape::UI::Toolbar::RectToolbar, Inkscape::UI::Toolbar::StarToolbar, and Inkscape::UI::Dialog::AttrDialog.

Definition at line 142 of file node-observer.h.

References name, and node.

Referenced by Inkscape::XML::EventChgAttr::_replayOne(), Inkscape::XML::EventChgAttr::_undoOne(), and Inkscape::XML::SimpleNode::setAttributeImpl().

◆ notifyChildAdded()

virtual void Inkscape::XML::NodeObserver::notifyChildAdded ( Node node,
Node child,
Node prev 
)
inlinevirtual

Child addition callback.

This method is called whenever a child is added to the observed node. The prev parameter is NULL when the newly added child is first in the sibling order.

Parameters
nodeThe changed XML node
childThe newly added child node
prevThe node after which the new child was inserted into the sibling order, or NULL

Reimplemented in SPStyleElemNodeObserver, SPObject, SPTRefReference, Inkscape::XML::SignalObserver, Inkscape::XML::CompositeNodeObserver, Inkscape::XML::SimpleDocument, and Inkscape::UI::Dialog::DocumentProperties::WatchConnection.

Definition at line 69 of file node-observer.h.

References child, and node.

Referenced by Inkscape::XML::EventAdd::_replayOne(), Inkscape::XML::EventDel::_undoOne(), and Inkscape::XML::SimpleNode::addChild().

◆ notifyChildOrderChanged()

virtual void Inkscape::XML::NodeObserver::notifyChildOrderChanged ( Node node,
Node child,
Node old_prev,
Node new_prev 
)
inlinevirtual

Child order change callback.

This method is called whenever the order of a node's children is changed using Node::changeOrder(). The old_prev parameter is NULL if the relocated node was first in the sibling order before the order change, and new_prev is NULL if it was moved to the first position by this operation.

Parameters
nodeThe changed XML node
childThe child node that was relocated in the sibling order
old_prevThe node that was before child prior to the order change
new_prevThe node that is before child after the order change

Reimplemented in SPStyleElemNodeObserver, SPObject, SPTRefReference, Inkscape::XML::SignalObserver, Inkscape::XML::CompositeNodeObserver, and Inkscape::XML::SimpleDocument.

Definition at line 104 of file node-observer.h.

References child, and node.

Referenced by Inkscape::XML::EventChgOrder::_replayOne(), Inkscape::XML::EventChgOrder::_undoOne(), and Inkscape::XML::SimpleNode::changeOrder().

◆ notifyChildRemoved()

virtual void Inkscape::XML::NodeObserver::notifyChildRemoved ( Node node,
Node child,
Node prev 
)
inlinevirtual

Child removal callback.

This method is called whenever a child is removed from the observed node. The prev parameter is NULL when the removed child was first in the sibling order.

Parameters
nodeThe changed XML node
childThe removed child node
prevThe node that was before the removed node in sibling order, or NULL

Reimplemented in SPStyleElemNodeObserver, Inkscape::UI::Tools::CCToolLayerNodeObserver, SPObject, SPTRefReference, Inkscape::XML::SignalObserver, Inkscape::XML::CompositeNodeObserver, Inkscape::XML::SimpleDocument, and Inkscape::UI::Dialog::DocumentProperties::WatchConnection.

Definition at line 85 of file node-observer.h.

References child, and node.

Referenced by Inkscape::XML::EventDel::_replayOne(), and Inkscape::XML::SimpleNode::removeChild().

◆ notifyContentChanged()

virtual void Inkscape::XML::NodeObserver::notifyContentChanged ( Node node,
Util::ptr_shared  old_content,
Util::ptr_shared  new_content 
)
inlinevirtual

Content change callback.

This method is called whenever a node's content is changed using Node::setContent(), e.g. for text or comment nodes.

Parameters
nodeThe changed XML node
old_contentOld content of node
new_contentNew content of node

Reimplemented in SPStyleElemTextNodeObserver, SPTRefReference, SPObject, Inkscape::XML::SignalObserver, Inkscape::XML::CompositeNodeObserver, Inkscape::XML::SimpleDocument, and Inkscape::UI::Dialog::AttrDialog.

Definition at line 122 of file node-observer.h.

References node.

Referenced by Inkscape::XML::EventChgContent::_replayOne(), Inkscape::XML::EventChgContent::_undoOne(), and Inkscape::XML::SimpleNode::setContent().

◆ notifyElementNameChanged()

virtual void Inkscape::XML::NodeObserver::notifyElementNameChanged ( Node node,
GQuark  old_name,
GQuark  new_name 
)
inlinevirtual

Element name change callback.

This method is called whenever an element node's name is changed.

Parameters
nodeThe changed XML node.
old_nameGQuark corresponding to the old element name.
new_nameGQuark corresponding to the new element name.

Reimplemented in SPObject, Inkscape::XML::SignalObserver, Inkscape::XML::CompositeNodeObserver, and Inkscape::XML::SimpleDocument.

Definition at line 160 of file node-observer.h.

References node.

Referenced by Inkscape::XML::EventChgElementName::_replayOne(), Inkscape::XML::EventChgElementName::_undoOne(), and Inkscape::XML::SimpleNode::setCodeUnsafe().


The documentation for this class was generated from the following file: