summaryrefslogtreecommitdiff
path: root/sc/source/ui/app
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2020-05-07 15:47:49 +0200
committerAndras Timar <andras.timar@collabora.com>2020-05-10 21:43:51 +0200
commitc6a3f51a89449f61ad20a1787c0a3cb41fa91466 (patch)
tree8b2fb0f7c67a8c500d0a94ba74ea99e7740ff822 /sc/source/ui/app
parent4a1ceb06ca19a5c89895015e0fc73c8fa897294e (diff)
formula bar: Change completeFunction() to accept string instead of index.
The 'index' is unsafe, because the set it tries to index can change in the meantime. Instead, use the function name and search for it in the set, to get the recent index. Change-Id: Id2a021c32f421057c87b6f7f4fffcc1c98009acb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93666 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93910 Tested-by: Jenkins
Diffstat (limited to 'sc/source/ui/app')
-rw-r--r--sc/source/ui/app/inputhdl.cxx16
1 files changed, 10 insertions, 6 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index d3f8aa8ec392..83079851a552 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1637,7 +1637,7 @@ void ScInputHandler::PasteFunctionData()
pActiveView->ShowCursor();
}
-void ScInputHandler::LOKPasteFunctionData( sal_uInt32 nIndex )
+void ScInputHandler::LOKPasteFunctionData(const OUString& rFunctionName)
{
if (pActiveViewSh && (pTopView || pTableView))
{
@@ -1660,12 +1660,16 @@ void ScInputHandler::LOKPasteFunctionData( sal_uInt32 nIndex )
InputReplaceSelection( aNewFormula );
}
- if (pFormulaData && nIndex < pFormulaData->size())
+ if (pFormulaData)
{
- auto aPos = pFormulaData->begin();
- std::advance(aPos, nIndex);
- miAutoPosFormula = aPos;
- PasteFunctionData();
+ OUString aNew;
+ ScTypedCaseStrSet::const_iterator aPos = findText(*pFormulaData, pFormulaData->begin(), rFunctionName, aNew, /* backward = */false);
+
+ if (aPos != pFormulaData->end())
+ {
+ miAutoPosFormula = aPos;
+ PasteFunctionData();
+ }
}
}
}