diff options
Diffstat (limited to 'sc/source/ui/app/inputhdl.cxx')
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 20 |
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 |