From 7dbe11bc23efa5f51a9b84e7d0f6dd16e63e0902 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 27 Oct 2008 13:03:09 -0500 Subject: From trunk (bzr r6885) --- src/style.cpp | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'src/style.cpp') diff --git a/src/style.cpp b/src/style.cpp index 966764800..a5b25e6ff 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(); - sp_style_read(style, NULL, repr); + // 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, tempnode); + + Inkscape::GC::release(tempnode); + Inkscape::GC::release(tempdoc); + delete tempdoc; } -- cgit v1.2.3