summaryrefslogtreecommitdiff
path: root/sc/source/ui/app/inputhdl.cxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2022-06-21 09:49:31 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-06-27 13:30:25 +0200
commitc649ad711ec48d08b0761f420f4584768c82eb74 (patch)
tree851edeff4851c325de83d4994335f4a735edd371 /sc/source/ui/app/inputhdl.cxx
parent50c0e041c06fccb84a84be6d2f457ad0aa0a3c6f (diff)
Resolves: tdf#149589 No "+ or - may start formula" when editing content
If it was a formula already it would start with = anyway. Change-Id: Ib3c0ebcaf99231d387f1aace8e1a5642061de3a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136208 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit 909cdd552199d35f7c10be0a8be370158aea0815) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136173 Tested-by: Eike Rathke <erack@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source/ui/app/inputhdl.cxx')
-rw-r--r--sc/source/ui/app/inputhdl.cxx20
1 files changed, 16 insertions, 4 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index d1a2fea3d482..e2343e052cfe 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -831,6 +831,7 @@ ScInputHandler::ScInputHandler()
bLastIsSymbol( false ),
mbDocumentDisposing(false),
mbPartialPrefix(false),
+ mbEditingExistingContent(false),
nValidation( 0 ),
eAttrAdjust( SvxCellHorJustify::Standard ),
aScaleX( 1,1 ),
@@ -1769,6 +1770,9 @@ void ScInputHandler::LOKPasteFunctionData(const OUString& rFunctionName)
if (pEditEngine)
{
aFormula = pEditEngine->GetText(0);
+ /* TODO: LOK: are you sure you want '+' and '-' let start formulas with
+ * function names? That was meant for "data typist" numeric keyboard
+ * input. */
bEdit = aFormula.getLength() > 1 && (aFormula[0] == '=' || aFormula[0] == '+' || aFormula[0] == '-');
}
@@ -2575,6 +2579,7 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bIn
}
else
aStr = GetEditText(mpEditEngine.get());
+ mbEditingExistingContent = !aStr.isEmpty();
if (aStr.startsWith("{=") && aStr.endsWith("}") ) // Matrix formula?
{
@@ -2589,8 +2594,7 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bIn
if ( bAutoComplete )
GetColData();
- if ( !aStr.isEmpty() && ( aStr[0] == '=' || aStr[0] == '+' || aStr[0] == '-' ) &&
- !cTyped && !bCreatingFuncView )
+ if (!cTyped && !bCreatingFuncView && StartsLikeFormula(aStr))
InitRangeFinder(aStr); // Formula is being edited -> RangeFinder
bNewTable = true; // -> PostEditView Call
@@ -2792,6 +2796,13 @@ void ScInputHandler::DataChanged( bool bFromTopNotify, bool bSetModified )
bInOwnChange = false;
}
+bool ScInputHandler::StartsLikeFormula( std::u16string_view rStr ) const
+{
+ // For new input '+' and '-' may start the dreaded "lazy data typist"
+ // formula input, editing existing formula content can only start with '='.
+ return !rStr.empty() && (rStr[0] == '=' || (!mbEditingExistingContent && (rStr[0] == '+' || rStr[0] == '-')));
+}
+
void ScInputHandler::UpdateFormulaMode()
{
SfxApplication* pSfxApp = SfxGetpApp();
@@ -2800,8 +2811,7 @@ void ScInputHandler::UpdateFormulaMode()
if (bIsFormula)
{
const OUString& rText = mpEditEngine->GetText(0);
- bIsFormula = !rText.isEmpty() &&
- (rText[0] == '=' || rText[0] == '+' || rText[0] == '-');
+ bIsFormula = StartsLikeFormula(rText);
}
if ( bIsFormula )
@@ -3407,6 +3417,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInL
nFormSelStart = nFormSelEnd = 0;
aFormText.clear();
+ mbEditingExistingContent = false;
bInOwnChange = false;
bInEnterHandler = false;
}
@@ -3419,6 +3430,7 @@ void ScInputHandler::CancelHandler()
bModified = false;
mbPartialPrefix = false;
+ mbEditingExistingContent = false;
// Don't rely on ShowRefFrame switching the active view synchronously
// execute the function directly on the correct view's bindings instead