tdf#123591: Firebird: take decimal places into account...

when copying values from Calc to Base

Change-Id: I5dc645e3e9b153f71f2027a205815aaf83c1d6d3
Reviewed-on: https://gerrit.libreoffice.org/75346
Reviewed-by: Lionel Elie Mamane <lionel@mamane.lu>
Tested-by: Jenkins
(cherry picked from commit fb52df57abe51a5923a49fb0818f4b58565dfc25)
Reviewed-on: https://gerrit.libreoffice.org/75350
Reviewed-by: Xisco FaulĂ­ <xiscofauli@libreoffice.org>
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index cf44aa4..737875e 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -422,6 +422,13 @@ void SAL_CALL OPreparedStatement::setDouble(sal_Int32 nIndex, double nValue)
    XSQLVAR* pVar = m_pInSqlda->sqlvar + (nIndex - 1);
    int dType = (pVar->sqltype & ~1); // drop flag bit for now

    // take decimal places into account, later on they are removed in makeNumericString
    // minus because firebird stores scale as a negative number
    int nDecimalCount = -pVar->sqlscale;
    sal_Int64 nDecimalCountExp = pow10Integer(nDecimalCount);

    nValue = static_cast<double>(nValue * nDecimalCountExp);

    // Caller might try to set an integer type here. It makes sense to convert
    // it instead of throwing an error.
    switch(dType)