summaryrefslogtreecommitdiffstats
path: root/src/attribute-rel-util.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-10-03 20:51:05 +0000
committerjabiertxof <info@marker.es>2016-10-03 20:51:05 +0000
commit4db35e8a6706ddece9e977e5f26d4a6867ff8cbe (patch)
treef9711f260f694d96e26bf3216fb64f2b38611b2b /src/attribute-rel-util.cpp
parentupdate to trunk (diff)
parentMerge in jabiertxof's hover information for measure tool (diff)
downloadinkscape-4db35e8a6706ddece9e977e5f26d4a6867ff8cbe.tar.gz
inkscape-4db35e8a6706ddece9e977e5f26d4a6867ff8cbe.zip
Update to trunk
(bzr r15017.1.35)
Diffstat (limited to 'src/attribute-rel-util.cpp')
-rw-r--r--src/attribute-rel-util.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/attribute-rel-util.cpp b/src/attribute-rel-util.cpp
index 15c71daa7..5e770d4ae 100644
--- a/src/attribute-rel-util.cpp
+++ b/src/attribute-rel-util.cpp
@@ -11,7 +11,6 @@
#include <fstream>
#include <sstream>
-#include <string>
#include <iostream>
#include "preferences.h"
@@ -264,6 +263,42 @@ void sp_attribute_clean_style(Node* repr, SPCSSAttr *css, unsigned int flags) {
}
/**
+ * Remove CSS style properties with default values.
+ */
+void sp_attribute_purge_default_style(SPCSSAttr *css, unsigned int flags) {
+
+ g_return_if_fail (css != NULL);
+
+ // Loop over all properties in "style" node, keeping track of which to delete.
+ std::set<Glib::ustring> toDelete;
+ for ( List<AttributeRecord const> iter = css->attributeList() ; iter ; ++iter ) {
+
+ gchar const * property = g_quark_to_string(iter->key);
+ gchar const * value = iter->value;
+
+ // If property value is same as default mark for deletion.
+ if ( SPAttributeRelCSS::findIfDefault( property, value ) ) {
+
+ if ( flags & SP_ATTR_CLEAN_DEFAULT_WARN ) {
+ g_warning( "Preferences CSS Style property: \"%s\" with default value (%s) not needed.",
+ property, value );
+ }
+ if ( flags & SP_ATTR_CLEAN_DEFAULT_REMOVE ) {
+ toDelete.insert( property );
+ }
+ continue;
+ }
+
+ } // End loop over style properties
+
+ // Delete unneeded style properties. Do this at the end so as to not perturb List iterator.
+ for( std::set<Glib::ustring>::const_iterator iter_d = toDelete.begin(); iter_d != toDelete.end(); ++iter_d ) {
+ sp_repr_css_set_property( css, (*iter_d).c_str(), NULL );
+ }
+
+}
+
+/**
* Check one attribute on an element
*/
bool sp_attribute_check_attribute(Glib::ustring element, Glib::ustring id, Glib::ustring attribute, bool warn) {