[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source
Eike Rathke
erack at redhat.com
Tue Nov 21 14:26:32 UTC 2017
sc/inc/stringutil.hxx | 6 ++++++
sc/source/core/data/column3.cxx | 12 ++++++++++--
sc/source/ui/undo/undocell.cxx | 2 ++
3 files changed, 18 insertions(+), 2 deletions(-)
New commits:
commit ba9833a1d63747eaa5124271a1ac51cb926bce7a
Author: Eike Rathke <erack at redhat.com>
Date: Tue Nov 21 15:24:56 2017 +0100
Keep number format on string cell content Undo, tdf#103234 follow-up
Change-Id: I18c281211e6eeb4816da13972c360df85d577491
diff --git a/sc/inc/stringutil.hxx b/sc/inc/stringutil.hxx
index e02c06bc392c..e44bdcc84e39 100644
--- a/sc/inc/stringutil.hxx
+++ b/sc/inc/stringutil.hxx
@@ -47,6 +47,12 @@ struct SAL_WARN_UNUSED SC_DLLPUBLIC ScSetStringParam
SpecialNumberOnly,
/**
+ * Keep an existing number format, do not set Text number format and do
+ * not set another number format.
+ */
+ Keep,
+
+ /**
* Never set Text number format.
*/
Never
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 129d2fc43191..5c10cd3282aa 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -457,6 +457,8 @@ void ScUndoSetCell::SetValue( const ScCellValue& rVal )
{
ScSetStringParam aParam;
aParam.setTextInput();
+ // Undo only cell content, without setting any number format.
+ aParam.meSetTextNumFormat = ScSetStringParam::Keep;
rDoc.SetString(maPos, rVal.mpString->getString(), &aParam);
}
break;
commit f2f0a7c5a9d8185fedef5c737d1b7479b9fc0c1e
Author: Eike Rathke <erack at redhat.com>
Date: Tue Nov 21 14:55:04 2017 +0100
Invert logic of ScSetStringParam::* enum value checks, tdf#103234 follow-up
In preparation for adding a new enum value to keep existing
formatting in any case.
Change-Id: Ic15a900adba0281d1267d95f821e1e898f80f566
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 9a5a57205436..7a4672978a68 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1796,7 +1796,8 @@ bool ScColumn::ParseString(
}
}
}
- else if (aParam.meSetTextNumFormat != ScSetStringParam::Always)
+ else if (aParam.meSetTextNumFormat == ScSetStringParam::Never ||
+ aParam.meSetTextNumFormat == ScSetStringParam::SpecialNumberOnly)
{
// Only check if the string is a regular number.
const LocaleDataWrapper* pLocale = aParam.mpNumFormatter->GetLocaleData();
@@ -1824,7 +1825,14 @@ bool ScColumn::ParseString(
if (rCell.meType == CELLTYPE_NONE)
{
- if (aParam.meSetTextNumFormat != ScSetStringParam::Never && aParam.mpNumFormatter->IsNumberFormat(rString, nIndex, nVal))
+ // If we reach here with ScSetStringParam::SpecialNumberOnly it
+ // means a simple number was not detected above, so test for
+ // special numbers. In any case ScSetStringParam::Always does not
+ // mean always, but only always for content that could be any
+ // numeric.
+ if ((aParam.meSetTextNumFormat == ScSetStringParam::Always ||
+ aParam.meSetTextNumFormat == ScSetStringParam::SpecialNumberOnly) &&
+ aParam.mpNumFormatter->IsNumberFormat(rString, nIndex, nVal))
{
// Set the cell format type to Text.
applyTextNumFormat(*this, nRow, aParam.mpNumFormatter);
More information about the Libreoffice-commits
mailing list