Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / external / libodfgen / 0001-tdf-101077-make-double-string-conversion-locale-agno.patch.1
blob1fc4e6b9d2615ac2fad247196fb0ea51c9d55a79
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
6 ---
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
14 @@ -26,6 +26,8 @@
16  #include <librevenge/librevenge.h>
18 +#include <iomanip>
19 +#include <locale>
20  #include <map>
21  #include <stack>
22  #include <sstream>
23 @@ -46,6 +48,19 @@
24  #include "OdcGenerator.hxx"
25  #include "OdfGenerator.hxx"
27 +namespace
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
41  {
42  public:
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)
50                                         {
51 -                                               value.sprintf("%.8f", propList["librevenge:value"]->getDouble()*100.);
52 +                                               value = makePreciseStr(propList["librevenge:value"]->getDouble()*100.);
53                                                 value.append('%');
54                                         }
55                                         else
56 -- 
57 2.7.4