summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2022-01-17 15:43:07 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-01-17 20:34:26 +0100
commit2492429199670e30d89a81e0e227ae894764baee (patch)
tree659f0da7989580dcc9ace1f6184f835504d7dfc2
parenttdf#145321 Crash scrolling DOCX to bottom (diff)
downloadcore-2492429199670e30d89a81e0e227ae894764baee.tar.gz
core-2492429199670e30d89a81e0e227ae894764baee.zip
Resolves: tdf#146757 Use correct format index keys instead of wrong hack
The hack worked by accident as long as the internal index constants didn't change. Which was the case with commit f7d0c6b42a0a5ec98876006cd5048589219be741 CommitDate: Thu Sep 23 20:28:42 2021 +0200 Sort ZF_STANDARD_NEWEXTENDED_DATE_... into ZF_STANDARD_DATE category convertDateString() Standard + 36 == old ZF_STANDARD_DATE + 6 => DATE_SYS_DDMMYYYY unchanged convertDateTimeString() Standard + 51 == old ZF_STANDARD_DATETIME + 1 => DATETIME_SYS_DDMMYYYY_HHMMSS became wrong nothing (no format assigned, empty DATE slot) convertTimeString() Standard + 41 == old ZF_STANDARD_TIME + 1 => TIME_HHMMSS became wrong ZF_STANDARD_DATE_SYS_DMMMMYYYY (DATE_SYS_DMMMMYYYY) So time 08:00 double 0.33333... was converted to string "30 December 1899" which then numeric was 0. Change-Id: I642e0a977d4e167f78537d20624e86721e518c54 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128507 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit 0d6ab8d4ea7226db53d07dc158e176fe962fd8d9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128527 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Reviewed-by: Lionel Mamane <lionel@mamane.lu>
-rw-r--r--connectivity/source/parse/sqlnode.cxx6
1 files changed, 3 insertions, 3 deletions
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index 02056253c300..5247457d5b3d 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -217,7 +217,7 @@ OUString OSQLParseNode::convertDateString(const SQLParseNodeParameter& rParam, c
Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY);
double fDate = DBTypeConversion::toDouble(aDate,DBTypeConversion::getNULLDate(xSupplier));
- sal_Int32 nKey = xTypes->getStandardIndex(rParam.rLocale) + 36; // XXX hack
+ sal_Int32 nKey = xTypes->getFormatIndex(NumberFormatIndex::DATE_SYS_DDMMYYYY, rParam.rLocale);
return rParam.xFormatter->convertNumberToString(nKey, fDate);
}
@@ -229,7 +229,7 @@ OUString OSQLParseNode::convertDateTimeString(const SQLParseNodeParameter& rPara
Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY);
double fDateTime = DBTypeConversion::toDouble(aDate,DBTypeConversion::getNULLDate(xSupplier));
- sal_Int32 nKey = xTypes->getStandardIndex(rParam.rLocale) + 51; // XXX hack
+ sal_Int32 nKey = xTypes->getFormatIndex(NumberFormatIndex::DATETIME_SYS_DDMMYYYY_HHMMSS, rParam.rLocale);
return rParam.xFormatter->convertNumberToString(nKey, fDateTime);
}
@@ -242,7 +242,7 @@ OUString OSQLParseNode::convertTimeString(const SQLParseNodeParameter& rParam, c
Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY);
double fTime = DBTypeConversion::toDouble(aTime);
- sal_Int32 nKey = xTypes->getStandardIndex(rParam.rLocale) + 41; // XXX hack
+ sal_Int32 nKey = xTypes->getFormatIndex(NumberFormatIndex::TIME_HHMMSS, rParam.rLocale);
return rParam.xFormatter->convertNumberToString(nKey, fTime);
}