[Libreoffice-commits] core.git: dbaccess/qa dbaccess/source

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 12 17:19:05 UTC 2019


 dbaccess/qa/unit/data/tdf126268.odb              |binary
 dbaccess/qa/unit/tdf126268.cxx                   |    6 ++++--
 dbaccess/source/filter/hsqldb/rowinputbinary.cxx |   20 +++++++++++++++++++-
 3 files changed, 23 insertions(+), 3 deletions(-)

New commits:
commit 25277bcb727994072239c9c2549c271fdd62150e
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Fri Jul 12 12:59:22 2019 +0200
Commit:     Xisco FaulĂ­ <xiscofauli at libreoffice.org>
CommitDate: Fri Jul 12 19:17:41 2019 +0200

    tdf#126268: Add support for negative decimal
    
    basically reintroduce the code deleted in
    2e26ef34bf1a2e5d1293e45cf3b1415d9514b056
    and check at the right place the sign values
    
    Change-Id: Idf613a3a087b428d1f85abe9b43342fb67538a63
    Reviewed-on: https://gerrit.libreoffice.org/75488
    Tested-by: Jenkins
    Reviewed-by: Xisco FaulĂ­ <xiscofauli at libreoffice.org>

diff --git a/dbaccess/qa/unit/data/tdf126268.odb b/dbaccess/qa/unit/data/tdf126268.odb
index ffd00c140791..434a4238ba3b 100644
Binary files a/dbaccess/qa/unit/data/tdf126268.odb and b/dbaccess/qa/unit/data/tdf126268.odb differ
diff --git a/dbaccess/qa/unit/tdf126268.cxx b/dbaccess/qa/unit/tdf126268.cxx
index 967d5e671ff0..ffbe6361a231 100644
--- a/dbaccess/qa/unit/tdf126268.cxx
+++ b/dbaccess/qa/unit/tdf126268.cxx
@@ -49,8 +49,10 @@ struct expect_t
     OUString number;
 };
 
-static const expect_t expect[]
-    = { { 1, "0.00" }, { 2, "25.00" }, { 3, "26.00" }, { 4, "30.4" }, { 5, "45.8" } };
+static const expect_t expect[] = {
+    { 1, "0.00" },   { 2, "25.00" },  { 3, "26.00" }, { 4, "30.4" },  { 5, "45.8" },
+    { 6, "-25.00" }, { 7, "-26.00" }, { 8, "-30.4" }, { 9, "-45.8" },
+};
 
 void Tdf126268Test::testNumbers()
 {
diff --git a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
index a12ab0513abf..b75c8574dccf 100644
--- a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
+++ b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
@@ -89,9 +89,27 @@ OUString lcl_double_dabble(const std::vector<sal_uInt8>& bytes)
 OUString lcl_makeStringFromBigint(const std::vector<sal_uInt8>& bytes)
 {
     std::vector<sal_uInt8> aBytes{ bytes };
+    OUStringBuffer sRet;
 
+    // two's complement
+    if ((bytes[0] & 0x80) != 0)
+    {
+        sRet.append("-");
+        for (auto& byte : aBytes)
+            byte = ~byte;
+        // add 1 to byte array
+        // FIXME e.g. 10000 valid ?
+        for (size_t i = aBytes.size() - 1; i != 0; --i)
+        {
+            aBytes[i] += 1;
+            if (aBytes[i] != 0)
+                break;
+        }
+    }
     // convert binary to BCD
-    return lcl_double_dabble(aBytes);
+    OUString sNum = lcl_double_dabble(aBytes);
+    sRet.append(sNum);
+    return sRet.makeStringAndClear();
 }
 
 OUString lcl_putDot(const OUString& sNum, sal_Int32 nScale)


More information about the Libreoffice-commits mailing list