X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fstyle.cpp;h=ad4e509f6c0ca9129ebbaa350c9a35b7e16b0c5b;hb=63574adfdcf3417bcd5bad3ea3f510feadad3e07;hp=9667648006691ef69b49e07faa91721230eb1bb6;hpb=ca42bed853750b6124eec393c57de0b55bcfab17;p=inkscape.git diff --git a/src/style.cpp b/src/style.cpp index 966764800..ad4e509f6 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -1,9 +1,9 @@ #define __SP_STYLE_C__ -/** \file - * SVG stylesheets implementation. - * - * Authors: +/** @file + * @brief SVG stylesheets implementation. + */ +/* Authors: * Lauris Kaplinski * Peter Moulder * bulia byak @@ -41,9 +41,11 @@ #include "style.h" #include "svg/css-ostringstream.h" #include "xml/repr.h" +#include "xml/simple-document.h" #include "unit-constants.h" #include "2geom/isnan.h" #include "macros.h" +#include "preferences.h" #include "sp-filter-reference.h" @@ -790,15 +792,33 @@ sp_style_read_from_object(SPStyle *style, SPObject *object) /** - * Read style properties from repr only. + * Read style properties from preferences. + * @param style The style to write to + * @param path Preferences directory from which the style should be read */ void -sp_style_read_from_repr(SPStyle *style, Inkscape::XML::Node *repr) +sp_style_read_from_prefs(SPStyle *style, Glib::ustring const &path) { g_return_if_fail(style != NULL); - g_return_if_fail(repr != NULL); + g_return_if_fail(path != ""); + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + + // not optimal: we reconstruct the node based on the prefs, then pass it to + // sp_style_read for actual processing. + Inkscape::XML::SimpleDocument *tempdoc = new Inkscape::XML::SimpleDocument; + Inkscape::XML::Node *tempnode = tempdoc->createElement("temp"); + + std::vector attrs = prefs->getAllEntries(path); + for (std::vector::iterator i = attrs.begin(); i != attrs.end(); ++i) { + tempnode->setAttribute(i->getEntryName().data(), i->getString().data()); + } - sp_style_read(style, NULL, repr); + sp_style_read(style, NULL, tempnode); + + Inkscape::GC::release(tempnode); + Inkscape::GC::release(tempdoc); + delete tempdoc; } @@ -2177,7 +2197,7 @@ sp_style_merge_ifilter(SPStyle *style, SPIFilter const *parent) style->filter.href->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_style_filter_ref_changed), style)); } - if (style->filter.href && parent->href) { + if (style->filter.href && parent->href && parent->href->getObject()) { try { style->filter.href->attach(*parent->href->getURI()); } catch (Inkscape::BadURIException &e) { @@ -3829,13 +3849,15 @@ sp_style_set_property_url (SPObject *item, gchar const *property, SPObject *link if (repr == NULL) return; - g_return_if_fail(linked != NULL); - - gchar *val = g_strdup_printf("url(#%s)", SP_OBJECT_ID(linked)); - SPCSSAttr *css = sp_repr_css_attr_new(); - sp_repr_css_set_property(css, property, val); - g_free(val); + if (linked) { + gchar *val = g_strdup_printf("url(#%s)", SP_OBJECT_ID(linked)); + sp_repr_css_set_property(css, property, val); + g_free(val); + } else { + sp_repr_css_unset_property(css, "filter"); + } + if (recursive) { sp_repr_css_change_recursive(repr, css, "style"); } else {