diff options
| author | bulia byak <buliabyak@gmail.com> | 2006-10-31 21:21:41 +0000 |
|---|---|---|
| committer | buliabyak <buliabyak@users.sourceforge.net> | 2006-10-31 21:21:41 +0000 |
| commit | b9aac57805b343c602e06be66bc87ede91ad44de (patch) | |
| tree | 73f42108a3faf67accb389e0c6c98280bd6c551e /src/svg/css-ostringstream.cpp | |
| parent | fix off-by-one error: setting tprec to 6 was actually writing 7 digits (diff) | |
| download | inkscape-b9aac57805b343c602e06be66bc87ede91ad44de.tar.gz inkscape-b9aac57805b343c602e06be66bc87ede91ad44de.zip | |
make svg numeric precision, minimum exponent, and the use of named colors (as well as shortened color triads like #ccc) configurable via prefs
(bzr r1877)
Diffstat (limited to 'src/svg/css-ostringstream.cpp')
| -rw-r--r-- | src/svg/css-ostringstream.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/svg/css-ostringstream.cpp b/src/svg/css-ostringstream.cpp index 91b1cfcfb..d59b8083a 100644 --- a/src/svg/css-ostringstream.cpp +++ b/src/svg/css-ostringstream.cpp @@ -1,5 +1,6 @@ #include "svg/css-ostringstream.h" #include "svg/strip-trailing-zeros.h" +#include "prefs-utils.h" #include <glib/gmessages.h> #include <glib/gstrfuncs.h> @@ -13,21 +14,26 @@ 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(8); + ostr.precision(prefs_get_int_attribute("options.svgoutput", "numericprecision", 8)); } static void write_num(Inkscape::CSSOStringStream &os, unsigned const prec, double const d) { char buf[32]; // haven't thought about how much is really required. - if (prec != 8) { - static bool warned; - if (!warned) { - g_warning("Using precision of 8 instead of the requested %u. Won't re-warn.", prec); - warned = true; - } + switch (prec) { + case 10: g_ascii_formatd(buf, sizeof(buf), "%.10f", d); + case 9: g_ascii_formatd(buf, sizeof(buf), "%.9f", d); + case 8: g_ascii_formatd(buf, sizeof(buf), "%.8f", d); + case 7: g_ascii_formatd(buf, sizeof(buf), "%.7f", d); + case 6: g_ascii_formatd(buf, sizeof(buf), "%.6f", d); + case 5: g_ascii_formatd(buf, sizeof(buf), "%.5f", d); + case 4: g_ascii_formatd(buf, sizeof(buf), "%.4f", d); + case 3: g_ascii_formatd(buf, sizeof(buf), "%.3f", d); + case 2: g_ascii_formatd(buf, sizeof(buf), "%.2f", d); + case 1: g_ascii_formatd(buf, sizeof(buf), "%.1f", d); + case 0: g_ascii_formatd(buf, sizeof(buf), "%.0f", d); } - g_ascii_formatd(buf, sizeof(buf), "%.8f", d); os << strip_trailing_zeros(buf); } |
