summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShlomi Fish <shlomif@shlomifish.org>2016-09-23 12:51:11 +0000
committerShlomi Fish <shlomif@shlomifish.org>2016-09-23 12:51:11 +0000
commit23fe0d70dbef6ac9b12090c36c50abdc5387c547 (patch)
tree6c67e18c9e92508ceb0babbd1d4d27991db7d9e6 /src
parentRemove "== true"s (diff)
parentRemove properties with default values from 'style' entries in users preferenc... (diff)
downloadinkscape-23fe0d70dbef6ac9b12090c36c50abdc5387c547.tar.gz
inkscape-23fe0d70dbef6ac9b12090c36c50abdc5387c547.zip
Merged.
(bzr r15100.1.20)
Diffstat (limited to 'src')
-rw-r--r--src/attribute-rel-util.cpp36
-rw-r--r--src/attribute-rel-util.h5
-rw-r--r--src/extension/internal/gdkpixbuf-input.cpp7
-rw-r--r--src/preferences.cpp2
-rw-r--r--src/selection-chemistry.cpp24
-rw-r--r--src/style.cpp2
6 files changed, 66 insertions, 10 deletions
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
@@ -263,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) {
diff --git a/src/attribute-rel-util.h b/src/attribute-rel-util.h
index 604987779..b8b1f6875 100644
--- a/src/attribute-rel-util.h
+++ b/src/attribute-rel-util.h
@@ -68,6 +68,11 @@ Glib::ustring sp_attribute_clean_style(Node *repr, gchar const *string, unsigned
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);
+
+/**
* Check one attribute on an element
*/
bool sp_attribute_check_attribute(Glib::ustring element, Glib::ustring id, Glib::ustring attribute, bool warn);
diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp
index b30c67a4d..e0dc90981 100644
--- a/src/extension/internal/gdkpixbuf-input.cpp
+++ b/src/extension/internal/gdkpixbuf-input.cpp
@@ -134,8 +134,13 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
}
// Add it to the current layer
- doc->getRoot()->appendChildRepr(image_node);
+ Inkscape::XML::Node *layer_node = xml_doc->createElement("svg:g");
+ layer_node->setAttribute("inkscape:groupmode", "layer");
+ layer_node->setAttribute("inkscape:label", "Image");
+ doc->getRoot()->appendChildRepr(layer_node);
+ layer_node->appendChild(image_node);
Inkscape::GC::release(image_node);
+ Inkscape::GC::release(layer_node);
fit_canvas_to_drawing(doc);
// Set viewBox if it doesn't exist
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 988604a14..4d522a1d8 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -24,6 +24,7 @@
#include "xml/node-iterators.h"
#include "xml/attribute-record.h"
#include "util/units.h"
+#include "attribute-rel-util.h"
#define PREFERENCES_FILE_NAME "preferences.xml"
@@ -495,6 +496,7 @@ void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style)
{
SPCSSAttr *current = getStyle(pref_path);
sp_repr_css_merge(current, style);
+ sp_attribute_purge_default_style(current, SP_ATTR_CLEAN_DEFAULT_REMOVE);
Glib::ustring css_str;
sp_repr_css_write_string(current, css_str);
_setRawValue(pref_path, css_str);
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 37a0e42e1..834f82edc 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -497,6 +497,8 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone, bool duplicat
const gchar *id = old_ids[i];
SPObject *old_clone = doc->getObjectById(id);
SPUse *use = dynamic_cast<SPUse *>(old_clone);
+ SPOffset *offset = dynamic_cast<SPOffset *>(old_clone);
+ SPText *text = dynamic_cast<SPText *>(old_clone);
if (use) {
SPItem *orig = use->get_original();
if (!orig) // orphaned
@@ -510,14 +512,20 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone, bool duplicat
new_clone->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
}
- } else {
- SPOffset *offset = dynamic_cast<SPOffset *>(old_clone);
- if (offset) {
- for (guint j = 0; j < old_ids.size(); j++) {
- gchar *source_href = offset->sourceHref;
- if (source_href && source_href[0]=='#' && !strcmp(source_href+1, old_ids[j])) {
- doc->getObjectById(new_ids[i])->getRepr()->setAttribute("xlink:href", Glib::ustring("#") + new_ids[j]);
- }
+ } else if (offset) {
+ gchar *source_href = offset->sourceHref;
+ for (guint j = 0; j < old_ids.size(); j++) {
+ if (source_href && source_href[0]=='#' && !strcmp(source_href+1, old_ids[j])) {
+ doc->getObjectById(new_ids[i])->getRepr()->setAttribute("xlink:href", Glib::ustring("#") + new_ids[j]);
+ }
+ }
+ } else if (text) {
+ SPTextPath *textpath = dynamic_cast<SPTextPath *>(text->firstChild());
+ if (!textpath) continue;
+ const gchar *source_href = sp_textpath_get_path_item(textpath)->getId();
+ for (guint j = 0; j < old_ids.size(); j++) {
+ if (!strcmp(source_href, old_ids[j])) {
+ doc->getObjectById(new_ids[i])->firstChild()->getRepr()->setAttribute("xlink:href", Glib::ustring("#") + new_ids[j]);
}
}
}
diff --git a/src/style.cpp b/src/style.cpp
index e51733cf0..930e271ad 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -110,7 +110,7 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
font_variant_caps( "font-variant-caps", enum_font_variant_caps, SP_CSS_FONT_VARIANT_CAPS_NORMAL ),
font_variant_numeric( "font-variant-numeric", enum_font_variant_numeric ),
font_variant_alternates("font-variant-alternates", enum_font_variant_alternates, SP_CSS_FONT_VARIANT_ALTERNATES_NORMAL ),
- font_variant_east_asian("font-variant-east_asian", enum_font_variant_east_asian, SP_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL ),
+ font_variant_east_asian("font-variant-east-asian", enum_font_variant_east_asian, SP_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL ),
font_feature_settings( "font-feature-settings", "normal" ),
// Text related properties