1 From 68e0c8e4c834df57bc9a0e8da72151f69ff5e7a6 Mon Sep 17 00:00:00 2001
2 From: David Tardon <dtardon@redhat.com>
3 Date: Fri, 12 Aug 2016 12:50:39 +0200
4 Subject: [PATCH] tdf#101077 make double->string conversion locale-agnostic
7 src/OdsGenerator.cxx | 19 +++++++++++++++++--
8 1 file changed, 17 insertions(+), 2 deletions(-)
10 diff --git a/src/OdsGenerator.cxx b/src/OdsGenerator.cxx
11 index 52e135e..8cb7203 100644
12 --- a/src/OdsGenerator.cxx
13 +++ b/src/OdsGenerator.cxx
16 #include <librevenge/librevenge.h>
24 #include "OdcGenerator.hxx"
25 #include "OdfGenerator.hxx"
30 +librevenge::RVNGString makePreciseStr(const double value)
32 + std::ostringstream os;
33 + os.imbue(std::locale::classic());
34 + os << std::fixed << std::setprecision(8) << value;
35 + return os.str().c_str();
40 class OdsGeneratorPrivate : public OdfGenerator
43 @@ -968,10 +983,10 @@ void OdsGenerator::openSheetCell(const librevenge::RVNGPropertyList &propList)
44 // we need the maximum precision here, so we must avoid getStr() when possible
45 librevenge::RVNGString value;
46 if (propList["librevenge:value"]->getUnit()==librevenge::RVNG_GENERIC)
47 - value.sprintf("%.8f", propList["librevenge:value"]->getDouble());
48 + value = makePreciseStr(propList["librevenge:value"]->getDouble());
49 else if (propList["librevenge:value"]->getUnit()==librevenge::RVNG_PERCENT)
51 - value.sprintf("%.8f", propList["librevenge:value"]->getDouble()*100.);
52 + value = makePreciseStr(propList["librevenge:value"]->getDouble()*100.);