From e0490724aa071b1d86006e859194bcbb28e9b697 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Fri, 12 Aug 2016 13:28:51 +0200 Subject: [PATCH] tdf#101077 make double->str conv. locale-agnostic --- ...double-string-conversion-locale-agno.patch | 58 +++++++++++++++++++ libodfgen.spec | 9 ++- 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 0001-tdf-101077-make-double-string-conversion-locale-agno.patch diff --git a/0001-tdf-101077-make-double-string-conversion-locale-agno.patch b/0001-tdf-101077-make-double-string-conversion-locale-agno.patch new file mode 100644 index 0000000..1fc4e6b --- /dev/null +++ b/0001-tdf-101077-make-double-string-conversion-locale-agno.patch @@ -0,0 +1,58 @@ +From 68e0c8e4c834df57bc9a0e8da72151f69ff5e7a6 Mon Sep 17 00:00:00 2001 +From: David Tardon +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 + ++#include ++#include + #include + #include + #include +@@ -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/libodfgen.spec b/libodfgen.spec index 8e7ff1e..87d4a1e 100644 --- a/libodfgen.spec +++ b/libodfgen.spec @@ -2,7 +2,7 @@ Name: libodfgen Version: 0.1.6 -Release: 3%{?dist} +Release: 4%{?dist} Summary: An ODF generator library License: LGPLv2+ or MPLv2.0 @@ -12,6 +12,8 @@ Source: http://downloads.sourceforge.net/libwpd/%{name}-%{version}.tar.xz BuildRequires: doxygen BuildRequires: pkgconfig(librevenge-0.0) +Patch0: 0001-tdf-101077-make-double-string-conversion-locale-agno.patch + %description %{name} is a library for generating ODF documents. It is directly pluggable into input filters based on librevenge. It is used in @@ -33,7 +35,7 @@ BuildArch: noarch The %{name}-doc package contains documentation files for %{name}. %prep -%setup -q +%autosetup -p1 %build %configure --disable-silent-rules --disable-static --disable-werror --with-sharedptr=c++11 @@ -68,6 +70,9 @@ rm -rf %{buildroot}/%{_docdir}/%{name} %doc docs/doxygen/html %changelog +* Fri Aug 12 2016 David Tardon - 0.1.6-4 +- Resolves: tdf#101077 make double->str conv. locale-agnostic + * Thu Feb 04 2016 Fedora Release Engineering - 0.1.6-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild