diff options
author | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-08-03 18:05:38 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-08-05 01:29:32 +0200 |
commit | 5e2b4da10caaa15ee7e846c42ada2a20218d9591 (patch) | |
tree | cb0a9fb272393db3685092e7011bb48fb231a2e7 /sc | |
parent | 2ee3b6deff5d1e65ca0ba1479a1125fbea73a9ab (diff) |
handle autocomplete with dot in formula name, fdo#80058
The problem is that a dot is a word separator so the break iterator
provided by ICU will think that the dot separates two words whereas it
is part of the name here.
Change-Id: I73cee4304f83888b1645fec7b1851b9f42ef879f
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] == '(' |