Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
attribute-rel-util.h File Reference

Utility functions related to parsing and validation of XML attributes. More...

Go to the source code of this file.

Enumerations

enum  SPAttrClean {
  SP_ATTRCLEAN_ATTR_WARN = 1 , SP_ATTRCLEAN_ATTR_REMOVE = 2 , SP_ATTRCLEAN_STYLE_WARN = 4 , SP_ATTRCLEAN_STYLE_REMOVE = 8 ,
  SP_ATTRCLEAN_DEFAULT_WARN = 16 , SP_ATTRCLEAN_DEFAULT_REMOVE = 32
}
 Utility functions for cleaning XML tree. More...
 

Functions

unsigned int sp_attribute_clean_get_prefs ()
 Get preferences.
 
void sp_attribute_clean_tree (Node *repr)
 Remove or warn about inappropriate attributes and useless style properties.
 
void sp_attribute_clean_recursive (Node *repr, unsigned int flags)
 Recursively clean.
 
void sp_attribute_clean_element (Node *repr, unsigned int flags)
 Clean one element (attributes and style properties).
 
void sp_attribute_clean_style (Node *repr, unsigned int flags)
 Clean style properties for one element.
 
Glib::ustring sp_attribute_clean_style (Node *repr, gchar const *string, unsigned int flags)
 Clean style properties for one style string.
 
void sp_attribute_clean_style (Node *repr, SPCSSAttr *css, unsigned int flags)
 Clean style properties for one CSS.
 
void sp_attribute_purge_default_style (SPCSSAttr *css, unsigned int flags)
 Remove CSS style properties with default values.
 
bool sp_attribute_check_attribute (Glib::ustring const &element, Glib::ustring const &id, Glib::ustring const &attribute, bool warn)
 Check one attribute on an element.
 
bool sp_is_valid_svg_path_d (Glib::ustring const &d)
 Check whether the 'd' attribute on a <path> element parses correctly.
 

Detailed Description

Utility functions related to parsing and validation of XML attributes.

Definition in file attribute-rel-util.h.

Enumeration Type Documentation

◆ SPAttrClean

Utility functions for cleaning XML tree.

Enum for preferences

Enumerator
SP_ATTRCLEAN_ATTR_WARN 
SP_ATTRCLEAN_ATTR_REMOVE 
SP_ATTRCLEAN_STYLE_WARN 
SP_ATTRCLEAN_STYLE_REMOVE 
SP_ATTRCLEAN_DEFAULT_WARN 
SP_ATTRCLEAN_DEFAULT_REMOVE 

Definition at line 28 of file attribute-rel-util.h.

Function Documentation

◆ sp_attribute_check_attribute()

bool sp_attribute_check_attribute ( Glib::ustring const &  element,
Glib::ustring const &  id,
Glib::ustring const &  attribute,
bool  warn 
)

◆ sp_attribute_clean_element()

void sp_attribute_clean_element ( Node repr,
unsigned int  flags 
)

◆ sp_attribute_clean_get_prefs()

◆ sp_attribute_clean_recursive()

void sp_attribute_clean_recursive ( Node repr,
unsigned int  flags 
)

Recursively clean.

repr: the root node in a document or any other node. pref_attr, pref_style, pref_defaults: ignore, delete, or warn.

Recursively clean.

Definition at line 81 of file attribute-rel-util.cpp.

References child, Inkscape::XML::ELEMENT_NODE, Inkscape::XML::Node::firstChild(), Inkscape::XML::Node::name(), SP_ATTRCLEAN_DEFAULT_REMOVE, SP_ATTRCLEAN_DEFAULT_WARN, sp_attribute_clean_element(), sp_attribute_clean_recursive(), and Inkscape::XML::Node::type().

Referenced by sp_attribute_clean_recursive(), and sp_attribute_clean_tree().

◆ sp_attribute_clean_style() [1/3]

Glib::ustring sp_attribute_clean_style ( Node repr,
gchar const *  string,
unsigned int  flags 
)

Clean style properties for one style string.

Clean style properties for one style string.

Definition at line 162 of file attribute-rel-util.cpp.

References css, Inkscape::XML::ELEMENT_NODE, sp_attribute_clean_style(), sp_repr_css_attr_add_from_string(), sp_repr_css_attr_new(), sp_repr_css_attr_unref(), sp_repr_css_write_string(), and Inkscape::XML::Node::type().

◆ sp_attribute_clean_style() [2/3]

void sp_attribute_clean_style ( Node repr,
SPCSSAttr css,
unsigned int  flags 
)

Clean style properties for one CSS.

Clean style properties for one CSS.

  1. Is a style property appropriate on the given element? e.g, font-size is useless on <svg:rect>
  2. Is the value of the style property useful? Is it the same as the parent and it inherits? Is it the default value (and the property on the parent is not set or does not inherit)?

Definition at line 187 of file attribute-rel-util.cpp.

References Inkscape::XML::Node::attribute(), Inkscape::XML::Node::attributeList(), css, SPAttributeRelCSS::findIfDefault(), SPAttributeRelCSS::findIfInherit(), SPAttributeRelCSS::findIfValid(), Inkscape::XML::Node::name(), Inkscape::XML::Node::parent(), SP_ATTRCLEAN_DEFAULT_REMOVE, SP_ATTRCLEAN_DEFAULT_WARN, SP_ATTRCLEAN_STYLE_REMOVE, SP_ATTRCLEAN_STYLE_WARN, sp_repr_css_attr_inherited(), and sp_repr_css_set_property().

◆ sp_attribute_clean_style() [3/3]

◆ sp_attribute_clean_tree()

void sp_attribute_clean_tree ( Node repr)

Remove or warn about inappropriate attributes and useless style properties.

repr: the root node in a document or any other node.

Remove or warn about inappropriate attributes and useless style properties.

repr: the root node in a document or any other node.

Definition at line 67 of file attribute-rel-util.cpp.

References sp_attribute_clean_get_prefs(), and sp_attribute_clean_recursive().

Referenced by sp_repr_do_read(), and sp_repr_write_stream_root_element().

◆ sp_attribute_purge_default_style()

void sp_attribute_purge_default_style ( SPCSSAttr css,
unsigned int  flags 
)

Remove CSS style properties with default values.

Definition at line 269 of file attribute-rel-util.cpp.

References css, SPAttributeRelCSS::findIfDefault(), SP_ATTRCLEAN_DEFAULT_REMOVE, SP_ATTRCLEAN_DEFAULT_WARN, and sp_repr_css_set_property().

Referenced by Inkscape::Preferences::mergeStyle().

◆ sp_is_valid_svg_path_d()

bool sp_is_valid_svg_path_d ( Glib::ustring const &  d)

Check whether the 'd' attribute on a <path> element parses correctly.

Parameters
dThe value of the 'd' attribute.
Returns
false if the value causes a parser error, true otherwise.

A PathSink going straight to /dev/null

Definition at line 336 of file attribute-rel-util.cpp.

References Geom::PathSink::feed().