diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index e5f77e16441f..91b4cac5dd78 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -1121,6 +1121,12 @@ void ScInputHandler::NextFormulaEntry( bool bBack ) } namespace { + +bool needToExtendSelection(const OUString& rSelectedText, const OUString& rInsertText) +{ + SAL_DEBUG(rSelectedText); + return !rInsertText.startsWithIgnoreAsciiCase(rSelectedText); +} void completeFunction( EditView* pView, const OUString& rInsert, bool& rParInserted ) { @@ -1132,6 +1138,28 @@ void completeFunction( EditView* pView, const OUString& rInsert, bool& rParInser pView->SetSelection(aSel); pView->SelectCurrentWord(); + // a dot is a word separator so we need special + // treatment for any formula containing a dot + if(rInsert.indexOf(".") != -1) + { + // need to make sure that we replace also the part before the dot + // incrementally go through the word to find the match with the insert string + aSel = pView->GetSelection(); + ESelection aOldSelection = aSel; + OUString aSelectedText = pView->GetSelected(); + while(needToExtendSelection(aSelectedText, rInsert)) + { + assert(aSel.nStartPos > 0); + --aSel.nStartPos; + --aSel.nEndPos = aSel.nStartPos; + pView->SetSelection(aSel); + pView->SelectCurrentWord(); + aSelectedText = pView->GetSelected(); + } + aSel.nEndPos = aOldSelection.nEndPos; + pView->SetSelection(aSel); + } + OUString aInsStr = rInsert; sal_Int32 nInsLen = aInsStr.getLength(); bool bDoParen = ( nInsLen > 1 && aInsStr[nInsLen-2] == '(' |