[Libreoffice-commits] core.git: 2 commits - sc/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Mon Aug 4 17:06:02 PDT 2014
sc/source/ui/app/inputhdl.cxx | 38 +++++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)
New commits:
commit 5e2b4da10caaa15ee7e846c42ada2a20218d9591
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
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] == '('
commit 2ee3b6deff5d1e65ca0ba1479a1125fbea73a9ab
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
Change-Id: I8fdd5fb4f21e6c90e352089858ce98a62ac213de
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 2b70202..e5f77e1 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1120,7 +1120,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)
{
@@ -1167,6 +1169,8 @@ static void lcl_CompleteFunction( EditView* pView, const OUString& rInsert, bool
}
}
+}
+
void ScInputHandler::PasteFunctionData()
{
if (pFormulaData && miAutoPosFormula != pFormulaData->end())
@@ -1178,8 +1182,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