[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - 3 commits - sc/source

Winfried Donkers winfrieddonkers at libreoffice.org
Fri Aug 8 05:18:23 PDT 2014


 sc/source/ui/app/inputhdl.cxx |   39 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

New commits:
commit e5dd20508ca49fb6e6aee4a12cbf0dab568d7c16
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
Date:   Thu Aug 7 11:37:02 2014 +0200

    fdo#82241 fix autocompletion for calc functions with
    
    dot or underscore in function name
    
    Change-Id: Id460cad619098265b4ae000894df64a996ef0514
    Reviewed-on: https://gerrit.libreoffice.org/10801
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    (cherry picked from commit 9fc83ae4e479f7e6784dfdce87de35c283fbadd2)
    Signed-off-by: Eike Rathke <erack at redhat.com>

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 6ea8136..9e3bd5a 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1123,7 +1123,7 @@ void ScInputHandler::NextFormulaEntry( bool bBack )
 }
 
 namespace {
-    
+
 bool needToExtendSelection(const OUString& rSelectedText, const OUString& rInsertText)
 {
     SAL_DEBUG(rSelectedText);
@@ -1140,12 +1140,12 @@ 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)
+        // a dot and underscore are word separators so we need special
+        // treatment for any formula containing a dot or underscore
+        if(rInsert.indexOf(".") != -1 || 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
+            // go through the word to find the match with the insert string
             aSel = pView->GetSelection();
             ESelection aOldSelection = aSel;
             OUString aSelectedText = pView->GetSelected();
@@ -1158,6 +1158,7 @@ void completeFunction( EditView* pView, const OUString& rInsert, bool& rParInser
                 pView->SelectCurrentWord();
                 aSelectedText = pView->GetSelected();
             }
+            aSel.nStartPos -= ( aSelectedText.getLength() - 1 );
             aSel.nEndPos = aOldSelection.nEndPos;
             pView->SetSelection(aSel);
         }
commit dceb53e0c6d2e7485cfc3ea59b5c125e6640930b
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun Aug 3 18:05:38 2014 +0200

    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
    (cherry picked from commit 5e2b4da10caaa15ee7e846c42ada2a20218d9591)
    Signed-off-by: Eike Rathke <erack at redhat.com>

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 53582a7..6ea8136 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1123,6 +1123,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 )
 {
@@ -1134,6 +1140,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] == '('
commit e309f112f59b2beafa6967e596280ad35fe04fd0
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Fri Aug 1 01:42:12 2014 +0200

    use a anonymous namespace and sane function names
    
    (cherry picked from commit 2ee3b6deff5d1e65ca0ba1479a1125fbea73a9ab)
    Signed-off-by: Eike Rathke <erack at redhat.com>
    
    Cherry-picked to be able to cherry-pick
    5e2b4da10caaa15ee7e846c42ada2a20218d9591 without merge conflicts.
    
    Change-Id: I8fdd5fb4f21e6c90e352089858ce98a62ac213de

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index be0220d..53582a7 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1122,7 +1122,9 @@ void ScInputHandler::NextFormulaEntry( bool bBack )
         pActiveView->ShowCursor();
 }
 
-static void lcl_CompleteFunction( EditView* pView, const OUString& rInsert, bool& rParInserted )
+namespace {
+
+void completeFunction( EditView* pView, const OUString& rInsert, bool& rParInserted )
 {
     if (pView)
     {
@@ -1169,6 +1171,8 @@ static void lcl_CompleteFunction( EditView* pView, const OUString& rInsert, bool
     }
 }
 
+}
+
 void ScInputHandler::PasteFunctionData()
 {
     if (pFormulaData && miAutoPosFormula != pFormulaData->end())
@@ -1180,8 +1184,8 @@ void ScInputHandler::PasteFunctionData()
         bool bParInserted = false;
 
         DataChanging(); // Cannot be new
-        lcl_CompleteFunction( pTopView, aInsert, bParInserted );
-        lcl_CompleteFunction( pTableView, aInsert, bParInserted );
+        completeFunction( pTopView, aInsert, bParInserted );
+        completeFunction( pTableView, aInsert, bParInserted );
         DataChanged();
         ShowTipCursor();
 


More information about the Libreoffice-commits mailing list