From f35bb1f74a0ffeb5c6477a25e3c4cde87a97bcf1 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 12:06:06 +0200 Subject: Removed unused includes, decrease compilation time (bzr r15025) --- src/attribute-rel-util.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/attribute-rel-util.cpp') diff --git a/src/attribute-rel-util.cpp b/src/attribute-rel-util.cpp index 15c71daa7..cf1140219 100644 --- a/src/attribute-rel-util.cpp +++ b/src/attribute-rel-util.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include "preferences.h" -- cgit v1.2.3 From 43b49e325db73cc19b1731db6c69545664ee8fbe Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 13:26:17 +0200 Subject: Reverted changes to r15024 after many building problems (bzr r15027) --- src/attribute-rel-util.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/attribute-rel-util.cpp') diff --git a/src/attribute-rel-util.cpp b/src/attribute-rel-util.cpp index cf1140219..15c71daa7 100644 --- a/src/attribute-rel-util.cpp +++ b/src/attribute-rel-util.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include "preferences.h" -- cgit v1.2.3 From 35830f456cadaecf8b8e3944e3031a1a93f6cb41 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 3 Aug 2016 15:29:38 +0200 Subject: Removed unused includes, decreased compilation time. Once again (bzr r15034) --- src/attribute-rel-util.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/attribute-rel-util.cpp') diff --git a/src/attribute-rel-util.cpp b/src/attribute-rel-util.cpp index 15c71daa7..cf1140219 100644 --- a/src/attribute-rel-util.cpp +++ b/src/attribute-rel-util.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include "preferences.h" -- cgit v1.2.3 From d48547bafeeaf93e805fac07208a457ef8162a2a Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 20 Sep 2016 13:18:06 +0200 Subject: Add new function that removes properties with default values from SPCSSAttr. (bzr r15122) --- src/attribute-rel-util.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/attribute-rel-util.cpp') diff --git a/src/attribute-rel-util.cpp b/src/attribute-rel-util.cpp index cf1140219..5e770d4ae 100644 --- a/src/attribute-rel-util.cpp +++ b/src/attribute-rel-util.cpp @@ -262,6 +262,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 toDelete; + for ( List 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::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 */ -- cgit v1.2.3