Inkscape
Vector Graphics Editor
|
Interface for XML documents. More...
#include <document.h>
Public Member Functions | |
Document transactions | |
virtual bool | inTransaction ()=0 |
Checks whether there is an active transaction for this document. | |
virtual void | beginTransaction ()=0 |
Begin a transaction and start recording changes. | |
virtual void | rollback ()=0 |
Restore the state of the document prior to the transaction. | |
virtual void | commit ()=0 |
Commit a transaction and discard change data. | |
virtual Event * | commitUndoable ()=0 |
Commit a transaction and store the events for later use. | |
Create new nodes | |
virtual Node * | createElement (char const *name)=0 |
virtual Node * | createTextNode (char const *content)=0 |
virtual Node * | createTextNode (char const *content, bool is_CData)=0 |
virtual Node * | createComment (char const *content)=0 |
virtual Node * | createPI (char const *target, char const *content)=0 |
virtual NodeObserver * | logger ()=0 |
Get the event logger for this document. | |
![]() | |
Node ()=default | |
~Node () override=default | |
virtual NodeType | type () const =0 |
Get the type of the node. | |
virtual char const * | name () const =0 |
Get the name of the element node. | |
virtual int | code () const =0 |
Get the integer code corresponding to the node's name. | |
virtual unsigned | position () const =0 |
Get the index of this node in parent's child order. | |
virtual unsigned | childCount () const =0 |
Get the number of children of this node. | |
virtual char const * | content () const =0 |
Get the content of a text or comment node. | |
virtual char const * | attribute (char const *key) const =0 |
Get the string representation of a node's attribute. | |
virtual const AttributeVector & | attributeList () const =0 |
Get a list of the node's attributes. | |
virtual bool | matchAttributeName (char const *partial_name) const =0 |
Check whether this node has any attribute that matches a string. | |
virtual void | setPosition (int pos)=0 |
Set the position of this node in parent's child order. | |
virtual void | setContent (char const *value)=0 |
Set the content of a text or comment node. | |
void | setAttribute (Util::const_char_ptr key, Util::const_char_ptr value) |
Change an attribute of this node. | |
bool | copyAttribute (Util::const_char_ptr key, Node const *source_node, bool remove_if_empty=false) |
Copy attribute value from another node to this node. | |
bool | getAttributeBoolean (Util::const_char_ptr key, bool default_value=false) const |
Parses the boolean value of an attribute "key" in repr and sets val accordingly, or to false if the attr is not set. | |
int | getAttributeInt (Util::const_char_ptr key, int default_value=0) const |
double | getAttributeDouble (Util::const_char_ptr key, double default_value=0.0) const |
bool | setAttributeBoolean (Util::const_char_ptr key, bool val) |
bool | setAttributeInt (Util::const_char_ptr key, int val) |
bool | setAttributeCssDouble (Util::const_char_ptr key, double val) |
Set a property attribute to val [slightly rounded], in the format required for CSS properties: in particular, it never uses exponent notation. | |
bool | setAttributeSvgDouble (Util::const_char_ptr key, double val) |
For attributes where an exponent is allowed. | |
bool | setAttributeSvgNonDefaultDouble (Util::const_char_ptr key, double val, double default_value) |
bool | setAttributeSvgLength (Util::const_char_ptr key, SVGLength const &val) |
bool | setAttributePoint (Util::const_char_ptr key, Geom::Point const &val) |
Geom::Point | getAttributePoint (Util::const_char_ptr key, Geom::Point default_value={}) const |
void | setAttributeOrRemoveIfEmpty (Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value) |
Change an attribute of this node. | |
void | removeAttribute (Inkscape::Util::const_char_ptr key) |
Remove an attribute of this node. | |
virtual void | setCodeUnsafe (int code)=0 |
Set the integer GQuark code for the name of the node. | |
virtual Document * | document ()=0 |
Get the node's associated document. | |
virtual Document const * | document () const =0 |
virtual Node * | root ()=0 |
Get the root node of this node's document. | |
virtual Node const * | root () const =0 |
virtual Node * | parent ()=0 |
Get the parent of this node. | |
virtual Node const * | parent () const =0 |
virtual Node * | next ()=0 |
Get the next sibling of this node. | |
virtual Node const * | next () const =0 |
virtual Node * | prev ()=0 |
virtual Node const * | prev () const =0 |
virtual Node * | firstChild ()=0 |
Get the first child of this node. | |
virtual Node const * | firstChild () const =0 |
virtual Node * | lastChild ()=0 |
Get the last child of this node. | |
virtual Node const * | lastChild () const =0 |
virtual Node * | nthChild (unsigned index)=0 |
Get the child of this node with a given index. | |
virtual Node const * | nthChild (unsigned index) const =0 |
virtual Node * | duplicate (Document *doc) const =0 |
Create a duplicate of this node. | |
virtual void | addChild (Node *child, Node *after)=0 |
Insert another node as a child of this node. | |
void | addChildAtPos (Node *child, unsigned pos) |
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 void | removeChild (Node *child)=0 |
Remove a child of this node. | |
virtual void | changeOrder (Node *child, Node *after)=0 |
Move a given node in this node's child order. | |
virtual void | cleanOriginal (Node *src, char const *key)=0 |
Remove all elements that not in src node. | |
virtual bool | equal (Node const *other, bool recursive, bool skip_ids=false)=0 |
Compare 2 nodes equality. | |
virtual void | mergeFrom (Node const *src, char const *key, bool extension=false, bool clean=false)=0 |
Merge all children of another node with the current. | |
virtual void | addObserver (NodeObserver &observer)=0 |
Add an object that will be notified of the changes to this node. | |
virtual void | removeObserver (NodeObserver &observer)=0 |
Remove an object from the list of observers. | |
virtual void | synthesizeEvents (NodeObserver &observer)=0 |
Generate a sequence of events corresponding to the state of this node. | |
virtual void | addSubtreeObserver (NodeObserver &observer)=0 |
Add an object that will be notified of the changes to this node and its descendants. | |
virtual void | removeSubtreeObserver (NodeObserver &observer)=0 |
Remove an object from the subtree observers list. | |
virtual void | recursivePrintTree (unsigned level)=0 |
iterator | begin () |
Iterator over children. | |
iterator | end () |
Helper to use the standard lib container functions. | |
bool | operator== (const std::string &name) const |
Compare a node by looking at its name to a string. | |
template<typename T > | |
Node * | findChildPath (T list) |
depth first search to find a node | |
template<typename iterT > | |
Node * | findChildPath (iterT itr, iterT end) |
template reshuffling to make the more useful findChildPath cleaner | |
![]() | |
void | anchor () const |
void | release () const |
unsigned | _anchored_refcount () const |
Anchored (Anchored const &)=delete | |
void | operator= (Anchored const &)=delete |
Additional Inherited Members | |
![]() | |
using | iterator = Inkscape::XML::NodeSiblingIterator |
![]() | |
Node (Node const &) | |
virtual void | setAttributeImpl (char const *key, char const *value)=0 |
![]() | |
Anchored () | |
virtual | ~Anchored ()=default |
![]() | |
Node * | next_node (Node *node) |
Get the next node in sibling order. | |
Node * | previous_node (Node *node) |
Get the previous node in sibling order. | |
Node * | parent_node (Node *node) |
Get the node's parent. | |
Inkscape::XML::Node * | sp_repr_lookup_child (Inkscape::XML::Node *repr, gchar const *key, gchar const *value) |
Find an element node using an unique attribute. | |
Inkscape::XML::Node * | sp_repr_lookup_name (Inkscape::XML::Node *repr, char const *name, int maxdepth=-1) |
Find an element node with the given name. | |
template<typename Visitor > | |
void | sp_repr_visit_descendants (Inkscape::XML::Node *node, Visitor visitor) |
Visit all descendants recursively. | |
template<typename Visitor > | |
void | sp_repr_visit_descendants (Inkscape::XML::Node *a, Inkscape::XML::Node *b, Visitor visitor) |
Visit descendants of 2 nodes in parallel. | |
Interface for XML documents.
This class represents a complete document tree. You have to go through this class to create new nodes. It also contains transaction support, which forms the base of the undo system.
The document is also a node. It usually contains only two child nodes - a processing instruction node (PINode) containing the XML prolog, and the root node. You can get the root node of the document by calling the root() method.
The name "transaction" can be misleading, because they are not atomic. Their main feature is that they provide rollback. After starting a transaction, all changes made to the document are stored in an internal event log. At any time after starting the transaction, you can call the rollback() method, which restores the document to the state it was before starting the transaction. Calling the commit() method causes the internal event log to be discarded, and you can establish a new "restore point" by calling beginTransaction() again. There can be only one active transaction at a time for a given document.
Definition at line 43 of file document.h.
|
pure virtual |
Begin a transaction and start recording changes.
By calling this method you effectively establish a resotre point. You can undo all changes made to the document after this call using rollback().
Implemented in Inkscape::XML::SimpleDocument.
Referenced by sp_repr_begin_transaction(), and Inkscape::Preferences::temporaryPreferences().
|
pure virtual |
Commit a transaction and discard change data.
This method finishes the active transaction and discards the recorded changes.
Implemented in Inkscape::XML::SimpleDocument.
Referenced by sp_repr_commit().
|
pure virtual |
Commit a transaction and store the events for later use.
This method finishes a transaction and returns an event chain that describes the changes made to the document. This method may return NULL, which means that the document implementation doesn't support event logging, or that no changes were made.
Implemented in Inkscape::XML::SimpleDocument.
Referenced by sp_repr_commit_undoable().
|
pure virtual |
Implemented in Inkscape::XML::SimpleDocument.
Referenced by duplicate_node_without_children(), sp_repr_document_new(), and sp_repr_svg_read_node().
|
pure virtual |
Implemented in Inkscape::XML::SimpleDocument.
Referenced by Inkscape::Extension::Internal::SvgBuilder::_addStopToGradient(), Inkscape::Extension::Internal::SvgBuilder::_addToContainer(), SPGrid::_checkOldGrid(), Inkscape::UI::Tools::EraserTool::_clipErase(), Inkscape::Extension::Internal::SvgBuilder::_createClip(), Inkscape::Extension::Internal::SvgBuilder::_createGradient(), Inkscape::UI::Widget::CanvasGrid::_createGuide(), Inkscape::Extension::Internal::SvgBuilder::_createImage(), Inkscape::Extension::Internal::SvgBuilder::_createMask(), Inkscape::Extension::Internal::SvgBuilder::_createTilingPattern(), Inkscape::UI::Tools::EraserTool::_doWork(), Inkscape::Extension::Internal::SvgBuilder::_flushTextText(), Inkscape::UI::Tools::ConnectorTool::_flushWhite(), Inkscape::Extension::Internal::SvgBuilder::_getColorProfile(), Inkscape::Preferences::_getNode(), Inkscape::ObjectSet::_pathBoolOp(), Inkscape::Extension::Internal::SvgBuilder::_pushContainer(), Inkscape::UI::Tools::TextTool::_setupText(), Inkscape::LivePathEffect::LPEPowerClip::add(), Inkscape::UI::Dialog::CPHistoryXML::add_action_parameter(), Inkscape::UI::Dialog::SvgFontsDialog::add_kerning_pair(), Inkscape::UI::Dialog::CPHistoryXML::add_operation(), Inkscape::UI::Widget::GradientSelector::add_vector_clicked(), Inkscape::UI::Dialog::DocumentProperties::addEmbeddedScript(), Inkscape::UI::Dialog::DocumentProperties::addExternalScript(), Inkscape::UI::Tools::PencilTool::addPowerStrokePencil(), Inkscape::UI::Dialog::CloneTiler::apply(), Inkscape::ObjectSet::breakApart(), Inkscape::ObjectSet::clone(), Inkscape::LivePathEffect::LPECopyRotate::cloneD(), Inkscape::LivePathEffect::LPEMirrorSymmetry::cloneD(), Inkscape::LivePathEffect::LPETiling::cloneD(), Inkscape::ObjectSet::cloneOriginalPathLPE(), Inkscape::ObjectSet::combine(), SPBox3D::convert_to_group(), Box3DSide::convert_to_path(), Inkscape::UI::Dialog::CPHistoryXML::CPHistoryXML(), Inkscape::Extension::Internal::Filter::create_and_apply_filter(), create_flowtext_with_internal_frame(), Inkscape::create_layer(), SPGrid::create_new(), SPFont::create_new_glyph(), Inkscape::UI::Dialog::create_path_from_glyph(), create_text_with_inline_size(), create_text_with_rectangle(), Persp3D::create_xml_element(), Inkscape::LivePathEffect::Effect::createAndApply(), Inkscape::Extension::Implementation::Script::PreviewObserver::createAndSendEvent(), Inkscape::LivePathEffect::LPEMeasureSegments::createArrowMarker(), Inkscape::ObjectSet::createBitmapCopy(), SPBox3D::createBox3D(), Box3DSide::createBox3DSide(), SPDocument::createDoc(), Inkscape::ColorProfile::createFromProfile(), Inkscape::LivePathEffect::LPEMeasureSegments::createLine(), Inkscape::LivePathEffect::LPECopyRotate::createPathBase(), Inkscape::LivePathEffect::LPEMirrorSymmetry::createPathBase(), Inkscape::LivePathEffect::LPESlice::createPathBase(), Inkscape::LivePathEffect::LPETiling::createPathBase(), SPGuide::createSPGuide(), Inkscape::LivePathEffect::LPEMeasureSegments::createTextLabel(), delete_line_break(), Inkscape::UI::Tools::do_trace(), Inkscape::LivePathEffect::LPEBool::doBeforeEffect(), Inkscape::LivePathEffect::LPEMeasureSegments::doOnApply(), Inkscape::UI::Tools::SpiralTool::drag(), Inkscape::UI::Tools::ArcTool::drag(), Inkscape::UI::Tools::RectTool::drag(), Inkscape::UI::Tools::StarTool::drag(), Inkscape::LivePathEffect::LPEBool::dupleNode(), duplicate_node_without_children(), Inkscape::Extension::Internal::BlurEdge::effect(), Inkscape::Extension::Internal::Filter::Filter::effect(), Inkscape::Extension::Internal::Grid::effect(), Inkscape::Extension::Internal::Grid::effect(), file_import(), Inkscape::ObjectSet::fillBetweenMany(), filter_add_primitive(), generate_linked_fill(), generate_marker(), Inkscape::UI::Dialog::get_first_style_text_node(), SPFlowtext::getAsText(), SPDocument::getNamedView(), Inkscape::ObjectSet::group(), insert_hatch_polyfill(), insert_mesh_polyfill(), insert_text_fallback(), item_to_paths(), Inkscape::Extension::Internal::Filter::merge_filters(), modify_filter_gaussian_blur_from_item(), Inkscape::UI::Tools::MeshTool::new_default(), new_filter(), new_filter_blend_gaussian_blur(), new_filter_gaussian_blur(), Inkscape::UI::Dialog::new_font(), Inkscape::PageManager::newPage(), Inkscape::UI::Dialog::FilterEffectsDialog::PrimitiveList::on_click_released(), Inkscape::Extension::Internal::GdkpixbufInput::open(), Inkscape::Extension::Internal::Svg::open(), Inkscape::UI::Toolbar::TextToolbar::prepare_inner(), Inkscape::Extension::Internal::SvgBuilder::pushPage(), recursively_apply_style(), redundant_semi_nesting_processor(), remove_marker_auto_start_reverse(), SPGradient::repr_write_vector(), Inkscape::Extension::Implementation::Script::PreviewObserver::selectionChanged(), Inkscape::UI::Tools::CalligraphicTool::set_to_accumulated(), Inkscape::ObjectSet::setClipGroup(), Inkscape::UI::Tools::MeasureTool::setGuide(), Inkscape::UI::Tools::MeasureTool::setLabelText(), Inkscape::UI::Tools::MeasureTool::setMarker(), Inkscape::LivePathEffect::LPEPowerMask::setMask(), Inkscape::ObjectSet::setMask(), Inkscape::UI::Tools::MeasureTool::setMeasureItem(), SPObject::setTitleOrDesc(), show_output(), sp_document_default_gradient_vector(), sp_gradient_get_private_normalized(), sp_lpe_item_cleanup_original_path_recursive(), sp_repr_document_new(), sp_repr_svg_read_node(), sp_selected_item_to_curved_repr(), sp_selected_path_create_offset_object(), sp_selected_path_do_offset(), Inkscape::UI::Tools::sp_spray_recursive(), sp_te_insert(), sp_te_insert_line(), sp_te_set_repr_text_multiline(), sp_tref_convert_to_tspan(), Inkscape::UI::Tools::spdc_create_single_dot(), Inkscape::UI::Tools::spdc_flush_white(), Inkscape::SelTrans::stamp(), Inkscape::UI::Dialog::XmlTree::stopNodeEditing(), Inkscape::Extension::Internal::SvgBuilder::SvgBuilder(), text_flow_into_shape(), text_put_on_path(), text_unflow(), Inkscape::ObjectSet::tile(), Inkscape::UI::Tools::MeasureTool::toItem(), Inkscape::ObjectSet::toSymbol(), Inkscape::UI::Widget::FillNStroke::updateFromPaint(), verify_grad(), SPFeComposite::write(), SPTag::write(), SPTRef::write(), SPFeBlend::write(), SPFeDisplacementMap::write(), SPClipPath::write(), SPFilter::write(), SPMask::write(), SPTagUse::write(), LivePathEffectObject::write(), Inkscape::ColorProfile::write(), Persp3D::write(), SPFlowtext::write(), SPFontFace::write(), SPFont::write(), SPGlyphKerning::write(), SPGlyph::write(), SPMeshpatch::write(), SPMeshrow::write(), SPMissingGlyph::write(), SPSolidColor::write(), SPStop::write(), SPStyleElem::write(), SPText::write(), SPTextPath::write(), SPTSpan::write(), SPMarker::write(), SPAnchor::write(), SPOffset::write(), Box3DSide::write(), SPBox3D::write(), SPDefs::write(), SPGenericEllipse::write(), SPFlowdiv::write(), SPFlowtspan::write(), SPFlowpara::write(), SPFlowline::write(), SPFlowregionbreak::write(), SPFlowregion::write(), SPFlowregionExclude::write(), SPGroup::write(), SPLine::write(), SPLinearGradient::write(), SPObjectGroup::write(), SPPath::write(), SPPolygon::write(), SPPolyLine::write(), SPRadialGradient::write(), SPSpiral::write(), SPStar::write(), SPMeshNodeArray::write(), and XmlReprActionTest::XmlReprActionTest().
|
pure virtual |
Implemented in Inkscape::XML::SimpleDocument.
Referenced by duplicate_node_without_children(), and sp_repr_svg_read_node().
|
pure virtual |
Implemented in Inkscape::XML::SimpleDocument.
Referenced by Inkscape::Extension::Internal::SvgBuilder::_flushTextText(), Inkscape::UI::Tools::TextTool::_setupText(), Inkscape::UI::Dialog::CPHistoryXML::add_action_parameter(), Inkscape::UI::Dialog::CPHistoryXML::add_operation(), Inkscape::UI::Dialog::XmlTree::cmd_new_text_node(), create_flowtext_with_internal_frame(), create_text_with_inline_size(), create_text_with_rectangle(), Inkscape::LivePathEffect::LPEMeasureSegments::createTextLabel(), Inkscape::LivePathEffect::LPEMeasureSegments::doOnApply(), duplicate_node_without_children(), Inkscape::UI::Dialog::DocumentProperties::editEmbeddedScript(), Inkscape::UI::Dialog::get_first_style_text_node(), SPFlowtext::getAsText(), insert_hatch_polyfill(), insert_mesh_polyfill(), insert_text_fallback(), Inkscape::UI::Toolbar::TextToolbar::prepare_inner(), recursively_apply_style(), Inkscape::UI::Tools::MeasureTool::setLabelText(), SPObject::setTitleOrDesc(), show_output(), sp_repr_svg_read_node(), sp_te_insert(), sp_te_set_repr_text_multiline(), sp_tref_update_text(), text_flow_into_shape(), text_unflow(), Inkscape::ObjectSet::toSymbol(), SPText::write(), SPTextPath::write(), SPTSpan::write(), SPFlowdiv::write(), SPFlowtspan::write(), and SPFlowpara::write().
|
pure virtual |
Implemented in Inkscape::XML::SimpleDocument.
|
pure virtual |
Checks whether there is an active transaction for this document.
Implemented in Inkscape::XML::SimpleDocument.
Referenced by Inkscape::Preferences::temporaryPreferences().
|
pure virtual |
Get the event logger for this document.
This is an implementation detail that should not be used outside of node implementations. It should be made non-public in the future.
Implemented in Inkscape::XML::SimpleDocument.
Referenced by Inkscape::XML::SimpleNode::addChild(), Inkscape::XML::SimpleNode::changeOrder(), Inkscape::XML::SimpleNode::removeChild(), Inkscape::XML::SimpleNode::setAttributeImpl(), Inkscape::XML::SimpleNode::setCodeUnsafe(), and Inkscape::XML::SimpleNode::setContent().
|
pure virtual |
Restore the state of the document prior to the transaction.
This method applies the inverses of all recorded changes in reverse order, restoring the document state from before the transaction. For some implementations, this function may do nothing.
Implemented in Inkscape::XML::SimpleDocument.
Referenced by sp_repr_rollback(), and Inkscape::Preferences::temporaryPreferences().