[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - sc/source
Eike Rathke (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 10 20:46:43 UTC 2019
sc/source/core/data/column3.cxx | 52 +++++++++++++++++++++++++++++++++++++---
1 file changed, 49 insertions(+), 3 deletions(-)
New commits:
commit 4d51531130988d87839bb7b0c077a5df43b2a6be
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Mon May 20 21:44:02 2019 +0200
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Jun 10 22:46:06 2019 +0200
Resolves: tdf#125109 prefer edit format's acceptance patterns and YMD order
Change-Id: I4036061b9e8f01d99f04f20dfbbd2cf23d3a9b59
Reviewed-on: https://gerrit.libreoffice.org/72632
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Jenkins
(cherry picked from commit 478e051f4ea13b15120fdf74faf94a6c2cfcb50c)
Reviewed-on: https://gerrit.libreoffice.org/72848
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 30d9fc26631f..903111b20769 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1947,13 +1947,14 @@ bool ScColumn::ParseString(
sal_uInt32 nIndex = 0;
sal_uInt32 nOldIndex = 0;
+ SvNumFormatType eNumFormatType = SvNumFormatType::ALL;
sal_Unicode cFirstChar;
if (!aParam.mpNumFormatter)
aParam.mpNumFormatter = GetDoc()->GetFormatTable();
nIndex = nOldIndex = GetNumberFormat( GetDoc()->GetNonThreadedContext(), nRow );
if ( rString.getLength() > 1
- && aParam.mpNumFormatter->GetType(nIndex) != SvNumFormatType::TEXT )
+ && (eNumFormatType = aParam.mpNumFormatter->GetType(nIndex)) != SvNumFormatType::TEXT )
cFirstChar = rString[0];
else
cFirstChar = 0; // Text
@@ -2009,11 +2010,56 @@ bool ScColumn::ParseString(
{
if (aParam.mbDetectNumberFormat)
{
- if (!aParam.mpNumFormatter->IsNumberFormat(rString, nIndex, nVal))
+ // Editing a date prefers the format's locale's edit date
+ // format's date acceptance patterns and YMD order.
+ /* TODO: this could be determined already far above when
+ * starting to edit a date "cell" and passed down. A problem
+ * could also be if a new date was typed over or written by a
+ * macro assuming the current locale if that conflicts somehow.
+ * You can't have everything. See tdf#116579 and tdf#125109. */
+ if (eNumFormatType == SvNumFormatType::ALL)
+ eNumFormatType = aParam.mpNumFormatter->GetType(nIndex);
+ bool bForceFormatDate = (eNumFormatType == SvNumFormatType::DATE
+ || eNumFormatType == SvNumFormatType::DATETIME);
+ const SvNumberformat* pOldFormat = nullptr;
+ NfEvalDateFormat eEvalDateFormat = NF_EVALDATEFORMAT_INTL_FORMAT;
+ if (bForceFormatDate)
+ {
+ ScRefCellValue aCell = GetCellValue(nRow);
+ if (aCell.meType == CELLTYPE_VALUE)
+ {
+ // Only for an actual date (serial number), not an
+ // arbitrary string or formula or empty cell.
+ // Also ensure the edit date format's pattern is used,
+ // not the display format's.
+ pOldFormat = aParam.mpNumFormatter->GetEntry( nOldIndex);
+ if (!pOldFormat)
+ bForceFormatDate = false;
+ else
+ {
+ nIndex = aParam.mpNumFormatter->GetEditFormat( aCell.getValue(), nOldIndex, eNumFormatType,
+ pOldFormat->GetLanguage(), pOldFormat);
+ eEvalDateFormat = aParam.mpNumFormatter->GetEvalDateFormat();
+ aParam.mpNumFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL);
+ }
+ }
+ else
+ {
+ bForceFormatDate = false;
+ }
+ }
+
+ const bool bIsNumberFormat = aParam.mpNumFormatter->IsNumberFormat(rString, nIndex, nVal);
+
+ if (bForceFormatDate)
+ aParam.mpNumFormatter->SetEvalDateFormat( eEvalDateFormat);
+
+ if (!bIsNumberFormat)
break;
// convert back to the original language if a built-in format was detected
- const SvNumberformat* pOldFormat = aParam.mpNumFormatter->GetEntry( nOldIndex );
+ if (!pOldFormat)
+ pOldFormat = aParam.mpNumFormatter->GetEntry( nOldIndex );
if ( pOldFormat )
nIndex = aParam.mpNumFormatter->GetFormatForLanguageIfBuiltIn( nIndex, pOldFormat->GetLanguage() );
More information about the Libreoffice-commits
mailing list