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
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index e5f77e1..91b4cac 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] == '('