[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/inc sc/source
Eike Rathke
erack at redhat.com
Wed Nov 22 08:57:26 UTC 2017
sc/inc/stringutil.hxx | 8 +++++++-
sc/source/core/data/column3.cxx | 12 ++++++++++--
sc/source/ui/undo/undocell.cxx | 4 +++-
3 files changed, 20 insertions(+), 4 deletions(-)
New commits:
commit ad07d83af2a2b7df29223891bc028a4e7aedfe72
Author: Eike Rathke <erack at redhat.com>
Date: Tue Nov 21 15:33:58 2017 +0100
Resolves: tdf#103234 undo replacing text with formula
This is a combination of 3 commits.
tdf#103234 undo replacing text with formula
if this isn't what we want, then presumably ScSetStringParam shouldn't
exist here at all
Reviewed-on: https://gerrit.libreoffice.org/45008
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Eike Rathke <erack at redhat.com>
(cherry picked from commit 466c3564058aae4946cdd21eab9dfef529554d90)
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.
(cherry picked from commit f2f0a7c5a9d8185fedef5c737d1b7479b9fc0c1e)
Keep number format on string cell content Undo, tdf#103234 follow-up
(cherry picked from commit ba9833a1d63747eaa5124271a1ac51cb926bce7a)
c15a900adba0281d1267d95f821e1e898f80f566
18c281211e6eeb4816da13972c360df85d577491
Change-Id: I17318c38948bc19b7148276935830f83356c7ed2
Reviewed-on: https://gerrit.libreoffice.org/45026
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sc/inc/stringutil.hxx b/sc/inc/stringutil.hxx
index 3f9b0dbccaa2..c208332b48f6 100644
--- a/sc/inc/stringutil.hxx
+++ b/sc/inc/stringutil.hxx
@@ -31,7 +31,7 @@ class SvNumberFormatter;
* Store parameters used in the ScDocument::SetString() method. Various
* options for string-setting operation are specified herein.
*/
-struct SC_DLLPUBLIC ScSetStringParam
+struct SAL_WARN_UNUSED SC_DLLPUBLIC ScSetStringParam
{
enum TextFormatPolicy
{
@@ -47,6 +47,12 @@ struct 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/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 7942ad881bc0..28445f7c469a 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1795,7 +1795,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();
@@ -1821,7 +1822,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);
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index a087a20d79c1..c85e2d8aece1 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -459,7 +459,9 @@ void ScUndoSetCell::SetValue( const ScCellValue& rVal )
{
ScSetStringParam aParam;
aParam.setTextInput();
- rDoc.SetString(maPos, rVal.mpString->getString());
+ // Undo only cell content, without setting any number format.
+ aParam.meSetTextNumFormat = ScSetStringParam::Keep;
+ rDoc.SetString(maPos, rVal.mpString->getString(), &aParam);
}
break;
case CELLTYPE_EDIT:
More information about the Libreoffice-commits
mailing list