/*
5 * Authors: see git history
7 * Copyright (C) 2018 Authors
8 * Released under GNU GPL v2+, read the file
'COPYING' for more information.
43 unsigned int flags = 0;
44 if (prefs->
getBool(
"/options/svgoutput/incorrect_attributes_warn"))
46 if (prefs->
getBool(
"/options/svgoutput/incorrect_attributes_remove") &&
47 !prefs->
getBool(
"/options/svgoutput/disable_optimizations"))
49 if (prefs->
getBool(
"/options/svgoutput/incorrect_style_properties_warn"))
51 if (prefs->
getBool(
"/options/svgoutput/incorrect_style_properties_remove") &&
52 !prefs->
getBool(
"/options/svgoutput/disable_optimizations"))
54 if (prefs->
getBool(
"/options/svgoutput/style_defaults_warn"))
56 if (prefs->
getBool(
"/options/svgoutput/style_defaults_remove") &&
57 !prefs->
getBool(
"/options/svgoutput/disable_optimizations"))
69 g_return_if_fail(repr !=
nullptr);
83 g_return_if_fail(repr !=
nullptr);
86 Glib::ustring element = repr->
name();
89 if (element.substr(0, 4) ==
"svg:") {
96 Glib::ustring element =
child->name();
97 unsigned int flags_temp = flags;
98 if (element.compare(
"svg:defs") == 0 || element.compare(
"svg:symbol") == 0) {
110 g_return_if_fail(repr !=
nullptr);
113 Glib::ustring element = repr->
name();
121 std::set<Glib::ustring> attributesToDelete;
123 Glib::ustring attribute = g_quark_to_string(iter.key);
128 attributesToDelete.insert(attribute);
133 for (
const auto &iter_d : attributesToDelete) {
143 g_return_if_fail(repr !=
nullptr);
164 g_return_val_if_fail(repr !=
nullptr,
"");
170 Glib::ustring string_cleaned;
175 return string_cleaned;
189 g_return_if_fail(repr !=
nullptr);
190 g_return_if_fail(
css !=
nullptr);
192 Glib::ustring element = repr->
name();
202 std::set<Glib::ustring> toDelete;
203 for (
const auto &iter :
css->attributeList()) {
204 Glib::ustring
property = g_quark_to_string(iter.key);
205 gchar
const *value = iter.value;
210 g_warning(
"<%s id=\"%s\">: CSS Style property: \"%s\" is inappropriate.", element.c_str(),
id.c_str(),
214 toDelete.insert(property);
220 gchar
const *value_p =
nullptr;
221 if (css_parent !=
nullptr) {
223 gchar
const *property_p = g_quark_to_string(iter_p.key);
225 if (!g_strcmp0(property.c_str(), property_p)) {
226 value_p = iter_p.value;
235 g_warning(
"<%s id=\"%s\">: CSS Style property: \"%s\" has same value as parent (%s).", element.c_str(),
236 id.c_str(), property.c_str(), value);
239 toDelete.insert(property);
249 g_warning(
"<%s id=\"%s\">: CSS Style property: \"%s\" with default value (%s) not needed.",
250 element.c_str(),
id.c_str(), property.c_str(), value);
253 toDelete.insert(property);
261 for (
const auto &iter_d : toDelete) {
271 g_return_if_fail(
css !=
nullptr);
274 std::set<Glib::ustring> toDelete;
275 for (
const auto &iter :
css->attributeList()) {
276 Glib::ustring
property = g_quark_to_string(iter.key);
277 gchar
const *value = iter.value;
282 g_warning(
"Preferences CSS Style property: \"%s\" with default value (%s) not needed.",
283 property.c_str(), value);
286 toDelete.insert(property);
294 for (
const auto &iter_d : toDelete) {
305 bool is_useful =
true;
315 g_warning(
"<%s id=\"%s\">: Non-useful presentation attribute: \"%s\" found.", element.c_str(),
316 id.c_str(), attribute.c_str());
326 g_warning(
"<%s id=\"%s\">: Invalid attribute: \"%s\" found.", element.c_str(),
id.c_str(),
347 void closePath()
final {}
348 void flush()
final {}
359 validator.parse(
static_cast<std::string
>(d));
TODO: insert short description here.
TODO: insert short description here.
TODO: insert short description here.
unsigned int sp_attribute_clean_get_prefs()
Get preferences.
void sp_attribute_clean_tree(Node *repr)
Remove or warn about inappropriate attributes and useless stype properties.
void sp_attribute_clean_recursive(Node *repr, unsigned int flags)
Clean recursively over all elements.
bool sp_is_valid_svg_path_d(Glib::ustring const &d)
Check whether the 'd' attribute on a <path> element parses correctly.
void sp_attribute_clean_style(Node *repr, unsigned int flags)
Clean CSS style on an element.
void sp_attribute_clean_element(Node *repr, unsigned int flags)
Clean attributes on an element.
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.
void sp_attribute_purge_default_style(SPCSSAttr *css, unsigned int flags)
Remove CSS style properties with default values.
Utility functions related to parsing and validation of XML attributes.
@ SP_ATTRCLEAN_STYLE_WARN
@ SP_ATTRCLEAN_DEFAULT_WARN
@ SP_ATTRCLEAN_ATTR_REMOVE
@ SP_ATTRCLEAN_STYLE_REMOVE
@ SP_ATTRCLEAN_DEFAULT_REMOVE
Set of all points at a fixed distance from the center.
Abstract continuous curve on a plane defined on [0,1].
Set of points with a constant sum of distances from two foci.
Callback interface for processing path data.
virtual void feed(Curve const &c, bool moveto_initial=true)
Sequence of contiguous curves, aka spline.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
Read SVG path data and feed it to a PathSink.
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.
Interface for refcounted XML nodes.
virtual Node * parent()=0
Get the parent of this node.
virtual char const * name() const =0
Get the name of the element node.
virtual const AttributeVector & attributeList() const =0
Get a list of the node's attributes.
void setAttributeOrRemoveIfEmpty(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
Change an attribute 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.
void removeAttribute(Inkscape::Util::const_char_ptr key)
Remove an attribute of this node.
virtual NodeType type() const =0
Get the type of the node.
static bool findIfValid(Glib::ustring const &property, Glib::ustring const &element)
static bool findIfProperty(Glib::ustring const &property)
static bool findIfDefault(Glib::ustring const &property, Glib::ustring const &value)
static bool findIfInherit(Glib::ustring const &property)
static bool findIfValid(Glib::ustring const &attribute, Glib::ustring const &element)
std::shared_ptr< Css const > css
double Coord
Floating point type used to store coordinates.
@ ELEMENT_NODE
Regular element node, e.g. <group />.
callback interface for SVG path data
Singleton class to access the preferences file in a convenient way.
SPCSSAttr * sp_repr_css_attr_new()
Creates an empty SPCSSAttr (a class for manipulating CSS style properties).
void sp_repr_css_write_string(SPCSSAttr *css, Glib::ustring &str)
Write a style attribute string from a list of properties stored in an SPCSAttr object.
SPCSSAttr * sp_repr_css_attr_inherited(Node const *repr, gchar const *attr)
Creates a new SPCSSAttr with one attribute whose value is determined by cascading.
void sp_repr_css_attr_unref(SPCSSAttr *css)
Unreferences an SPCSSAttr (will be garbage collected if no references remain).
SPCSSAttr * sp_repr_css_attr(Node const *repr, gchar const *attr)
Creates a new SPCSSAttr with one attribute (i.e.
void sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value)
Set a style property to a new value (e.g.
void sp_repr_css_attr_add_from_string(SPCSSAttr *css, gchar const *p)
Use libcroco to parse a string for CSS properties and then merge them into an existing SPCSSAttr.
parse SVG path specifications