diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-10-02 22:44:54 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-10-02 22:44:54 +0000 |
| commit | 90e142963afd950b2868434075890054aef090b3 (patch) | |
| tree | edcaf3d0d85b614e5f327fb58c909ffee5207e26 /src/attribute-rel-util.cpp | |
| parent | Added some widgets from caligraphic tool (diff) | |
| parent | Adjust dock size to minimum width during canvas table size allocation signal. (diff) | |
| download | inkscape-90e142963afd950b2868434075890054aef090b3.tar.gz inkscape-90e142963afd950b2868434075890054aef090b3.zip | |
Update to trunk and some fixes
(bzr r14865.1.14)
Diffstat (limited to 'src/attribute-rel-util.cpp')
| -rw-r--r-- | src/attribute-rel-util.cpp | 37 |
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) { |
