summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2016-08-12 13:11:38 +0200
committerAndras Timar <andras.timar@collabora.com>2016-08-23 10:48:18 +0200
commit99512804d2614014831be31f488d17250554d9bc (patch)
treedeff1e6856b309beaf5f1936024c538a0de440de
parent084427ccf6690ab80b7ee58d1475d4e528a30d82 (diff)
tdf#101077 make double->str conv. locale-agnostic
Change-Id: Ibb87f4a14fda6957149ca52083387760ff6e60a3 (cherry picked from commit 8d26a169794083f047a57e5c8d3f5da0aaab2583) Reviewed-on: https://gerrit.libreoffice.org/28081 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit fc79186d80ffa8e734727c555456165af6dd51c4)
-rw-r--r--external/libodfgen/0001-tdf-101077-make-double-string-conversion-locale-agno.patch.158
-rw-r--r--external/libodfgen/UnpackedTarball_libodfgen.mk3
2 files changed, 61 insertions, 0 deletions
diff --git a/external/libodfgen/0001-tdf-101077-make-double-string-conversion-locale-agno.patch.1 b/external/libodfgen/0001-tdf-101077-make-double-string-conversion-locale-agno.patch.1
new file mode 100644
index 000000000000..1fc4e6b9d261
--- /dev/null
+++ b/external/libodfgen/0001-tdf-101077-make-double-string-conversion-locale-agno.patch.1
@@ -0,0 +1,58 @@
+From 68e0c8e4c834df57bc9a0e8da72151f69ff5e7a6 Mon Sep 17 00:00:00 2001
+From: David Tardon <dtardon@redhat.com>
+Date: Fri, 12 Aug 2016 12:50:39 +0200
+Subject: [PATCH] tdf#101077 make double->string conversion locale-agnostic
+
+---
+ src/OdsGenerator.cxx | 19 +++++++++++++++++--
+ 1 file changed, 17 insertions(+), 2 deletions(-)
+
+diff --git a/src/OdsGenerator.cxx b/src/OdsGenerator.cxx
+index 52e135e..8cb7203 100644
+--- a/src/OdsGenerator.cxx
++++ b/src/OdsGenerator.cxx
+@@ -26,6 +26,8 @@
+
+ #include <librevenge/librevenge.h>
+
++#include <iomanip>
++#include <locale>
+ #include <map>
+ #include <stack>
+ #include <sstream>
+@@ -46,6 +48,19 @@
+ #include "OdcGenerator.hxx"
+ #include "OdfGenerator.hxx"
+
++namespace
++{
++
++librevenge::RVNGString makePreciseStr(const double value)
++{
++ std::ostringstream os;
++ os.imbue(std::locale::classic());
++ os << std::fixed << std::setprecision(8) << value;
++ return os.str().c_str();
++}
++
++}
++
+ class OdsGeneratorPrivate : public OdfGenerator
+ {
+ public:
+@@ -968,10 +983,10 @@ void OdsGenerator::openSheetCell(const librevenge::RVNGPropertyList &propList)
+ // we need the maximum precision here, so we must avoid getStr() when possible
+ librevenge::RVNGString value;
+ if (propList["librevenge:value"]->getUnit()==librevenge::RVNG_GENERIC)
+- value.sprintf("%.8f", propList["librevenge:value"]->getDouble());
++ value = makePreciseStr(propList["librevenge:value"]->getDouble());
+ else if (propList["librevenge:value"]->getUnit()==librevenge::RVNG_PERCENT)
+ {
+- value.sprintf("%.8f", propList["librevenge:value"]->getDouble()*100.);
++ value = makePreciseStr(propList["librevenge:value"]->getDouble()*100.);
+ value.append('%');
+ }
+ else
+--
+2.7.4
+
diff --git a/external/libodfgen/UnpackedTarball_libodfgen.mk b/external/libodfgen/UnpackedTarball_libodfgen.mk
index 3cbeb5502d08..f6695d90fb03 100644
--- a/external/libodfgen/UnpackedTarball_libodfgen.mk
+++ b/external/libodfgen/UnpackedTarball_libodfgen.mk
@@ -35,5 +35,8 @@ $(eval $(call gb_UnpackedTarball_add_patches,libodfgen, \
endif
endif
+$(eval $(call gb_UnpackedTarball_add_patches,libodfgen, \
+ external/libodfgen/0001-tdf-101077-make-double-string-conversion-locale-agno.patch.1 \
+))
# vim: set noet sw=4 ts=4: