diff options
| author | Ted Gould <ted@gould.cx> | 2008-10-27 18:03:09 +0000 |
|---|---|---|
| committer | Ted Gould <ted@canonical.com> | 2008-10-27 18:03:09 +0000 |
| commit | 7dbe11bc23efa5f51a9b84e7d0f6dd16e63e0902 (patch) | |
| tree | 7d3a2b95b84a03a19cb132cdf88bea0ab6dc4773 /src/svg | |
| parent | Merging from trunk (diff) | |
| download | inkscape-7dbe11bc23efa5f51a9b84e7d0f6dd16e63e0902.tar.gz inkscape-7dbe11bc23efa5f51a9b84e7d0f6dd16e63e0902.zip | |
From trunk
(bzr r6885)
Diffstat (limited to 'src/svg')
| -rw-r--r-- | src/svg/css-ostringstream.cpp | 5 | ||||
| -rw-r--r-- | src/svg/path-string.cpp | 11 | ||||
| -rw-r--r-- | src/svg/stringstream.cpp | 5 | ||||
| -rw-r--r-- | src/svg/svg-affine.cpp | 11 | ||||
| -rw-r--r-- | src/svg/svg-color-test.h | 7 | ||||
| -rw-r--r-- | src/svg/svg-color.cpp | 5 | ||||
| -rw-r--r-- | src/svg/svg-path-geom-test.h | 13 |
7 files changed, 31 insertions, 26 deletions
diff --git a/src/svg/css-ostringstream.cpp b/src/svg/css-ostringstream.cpp index 362eb7662..a6eb2783e 100644 --- a/src/svg/css-ostringstream.cpp +++ b/src/svg/css-ostringstream.cpp @@ -1,6 +1,6 @@ #include "svg/css-ostringstream.h" #include "svg/strip-trailing-zeros.h" -#include "prefs-utils.h" +#include "preferences.h" #include <glib/gmessages.h> #include <glib/gstrfuncs.h> @@ -14,7 +14,8 @@ Inkscape::CSSOStringStream::CSSOStringStream() /* This one is (currently) needed though, as we currently use ostr.precision as a sort of variable for storing the desired precision: see our two precision methods and our operator<< methods for float and double. */ - ostr.precision(prefs_get_int_attribute("options.svgoutput", "numericprecision", 8)); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + ostr.precision(prefs->getInt("/options/svgoutput/numericprecision", 8)); } static void diff --git a/src/svg/path-string.cpp b/src/svg/path-string.cpp index 6f6a1f20f..c0e33fddd 100644 --- a/src/svg/path-string.cpp +++ b/src/svg/path-string.cpp @@ -15,7 +15,7 @@ #include "svg/path-string.h" #include "svg/stringstream.h" #include "svg/svg.h" -#include "prefs-utils.h" +#include "preferences.h" #include <algorithm> // 1<=numericprecision<=16, doubles are only accurate upto (slightly less than) 16 digits (and less than one digit doesn't make sense) @@ -27,11 +27,12 @@ int Inkscape::SVG::PathString::numericprecision; int Inkscape::SVG::PathString::minimumexponent; Inkscape::SVG::PathString::PathString() : - allow_relative_coordinates(0 != prefs_get_int_attribute("options.svgoutput", "allowrelativecoordinates", 1)), - force_repeat_commands(0 != prefs_get_int_attribute("options.svgoutput", "forcerepeatcommands", 0)) + allow_relative_coordinates(Inkscape::Preferences::get()->getBool("/options/svgoutput/allowrelativecoordinates", true)), + force_repeat_commands(Inkscape::Preferences::get()->getBool("/options/svgoutput/forcerepeatcommands")) { - numericprecision = std::max<int>(minprec,std::min<int>(maxprec,prefs_get_int_attribute("options.svgoutput", "numericprecision", 8))); - minimumexponent = prefs_get_int_attribute("options.svgoutput", "minimumexponent", -8); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + numericprecision = std::max<int>(minprec,std::min<int>(maxprec, prefs->getInt("/options/svgoutput/numericprecision", 8))); + minimumexponent = prefs->getInt("/options/svgoutput/minimumexponent", -8); } void Inkscape::SVG::PathString::_appendOp(char abs_op, char rel_op) { diff --git a/src/svg/stringstream.cpp b/src/svg/stringstream.cpp index 62e20961a..6b9e512a1 100644 --- a/src/svg/stringstream.cpp +++ b/src/svg/stringstream.cpp @@ -1,6 +1,6 @@ #include "svg/stringstream.h" #include "svg/strip-trailing-zeros.h" -#include "prefs-utils.h" +#include "preferences.h" #include <2geom/point.h> Inkscape::SVGOStringStream::SVGOStringStream() @@ -13,7 +13,8 @@ Inkscape::SVGOStringStream::SVGOStringStream() /* This one is (currently) needed though, as we currently use ostr.precision as a sort of variable for storing the desired precision: see our two precision methods and our operator<< methods for float and double. */ - ostr.precision(prefs_get_int_attribute("options.svgoutput", "numericprecision", 8)); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + ostr.precision(prefs->getInt("/options/svgoutput/numericprecision", 8)); } Inkscape::SVGOStringStream & diff --git a/src/svg/svg-affine.cpp b/src/svg/svg-affine.cpp index 2445135c3..2b9a79d3d 100644 --- a/src/svg/svg-affine.cpp +++ b/src/svg/svg-affine.cpp @@ -28,7 +28,7 @@ #include <2geom/angle.h> #include <libnr/nr-convert2geom.h> #include "svg.h" -#include "prefs-utils.h" +#include "preferences.h" #ifndef M_PI # define M_PI 3.14159265358979323846 @@ -194,15 +194,14 @@ sp_svg_transform_write(NR::Matrix const &transform) gchar * sp_svg_transform_write(NR::Matrix const *transform) { - double e; - if (!transform) { return NULL; } + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - e = 0.000001 * NR::expansion(*transform); - int prec = prefs_get_int_attribute("options.svgoutput", "numericprecision", 8); - int min_exp = prefs_get_int_attribute("options.svgoutput", "minimumexponent", -8); + double e = 0.000001 * NR::expansion(*transform); + int prec = prefs->getInt("/options/svgoutput/numericprecision", 8); + int min_exp = prefs->getInt("/options/svgoutput/minimumexponent", -8); /* fixme: We could use t1 * t1 + t2 * t2 here instead */ if (NR_DF_TEST_CLOSE ((*transform)[1], 0.0, e) && NR_DF_TEST_CLOSE ((*transform)[2], 0.0, e)) { diff --git a/src/svg/svg-color-test.h b/src/svg/svg-color-test.h index dbefa1af5..d249c675c 100644 --- a/src/svg/svg-color-test.h +++ b/src/svg/svg-color-test.h @@ -2,7 +2,7 @@ #include <cassert> #include <cstdlib> -#include "prefs-utils.h" +#include "preferences.h" #include "svg/svg-color.h" #include "svg/svg-icc-color.h" @@ -18,12 +18,13 @@ class SVGColorTest : public CxxTest::TestSuite public: void check_rgb24(unsigned const rgb24) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); char css[8]; - prefs_set_int_attribute("options.svgoutput", "usenamedcolors", 0); + prefs->setBool("/options/svgoutput/usenamedcolors", false); sp_svg_write_color(css, sizeof(css), rgb24 << 8); TS_ASSERT_EQUALS(sp_svg_read_color(css, 0xff), rgb24 << 8); - prefs_set_int_attribute("options.svgoutput", "usenamedcolors", 1); + prefs->setBool("/options/svgoutput/usenamedcolors", true); sp_svg_write_color(css, sizeof(css), rgb24 << 8); TS_ASSERT_EQUALS(sp_svg_read_color(css, 0xff), rgb24 << 8); diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp index e1f87fdb9..9040d6e43 100644 --- a/src/svg/svg-color.cpp +++ b/src/svg/svg-color.cpp @@ -32,7 +32,7 @@ #include <errno.h> #include "strneq.h" -#include "prefs-utils.h" +#include "preferences.h" #include "svg-color.h" #include "svg-icc-color.h" @@ -431,8 +431,9 @@ sp_svg_write_color(gchar *buf, unsigned const buflen, guint32 const rgba32) { g_assert(8 <= buflen); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); unsigned const rgb24 = rgba32 >> 8; - if (prefs_get_int_attribute("options.svgoutput", "usenamedcolors", 0)) { + if (prefs->getBool("/options/svgoutput/usenamedcolors")) { rgb24_to_css(buf, rgb24); } else { g_snprintf(buf, buflen, "#%06x", rgb24); diff --git a/src/svg/svg-path-geom-test.h b/src/svg/svg-path-geom-test.h index 32a2ed231..7358c6d69 100644 --- a/src/svg/svg-path-geom-test.h +++ b/src/svg/svg-path-geom-test.h @@ -3,7 +3,7 @@ #include "2geom/curves.h"
#include "2geom/pathvector.h"
#include "svg/svg.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "streq.h"
#include <stdio.h>
#include <string>
@@ -391,11 +391,12 @@ public: void testMinexpPrecision() {
Geom::PathVector pv;
char * path_str;
- // Default values
- prefs_set_int_attribute("options.svgoutput", "allowrelativecoordinates", 1);
- prefs_set_int_attribute("options.svgoutput", "forcerepeatcommands", 0);
- prefs_set_int_attribute("options.svgoutput", "numericprecision", 8);
- prefs_set_int_attribute("options.svgoutput", "minimumexponent", -8);
+ // Default values + Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("/options/svgoutput/allowrelativecoordinates", true);
+ prefs->setBool("/options/svgoutput/forcerepeatcommands", false);
+ prefs->setInt("/options/svgoutput/numericprecision", 8);
+ prefs->setInt("/options/svgoutput/minimumexponent", -8);
pv = sp_svg_read_pathv("M 123456781,1.23456781e-8 L 123456782,1.23456782e-8 L 123456785,1.23456785e-8 L 10123456400,1.23456785e-8 L 123456789,1.23456789e-8 L 123456789,101.234564e-8 L 123456789,1.23456789e-8");
path_str = sp_svg_write_path(pv);
TS_ASSERT_RELATION( streq_rel , "m 123456780,1.2345678e-8 0,0 10,1e-15 9999999210,0 -9999999210,0 0,9.99999921e-7 0,-9.99999921e-7" , path_str );
|
