diff options
author | Jan Holesovsky <kendy@collabora.com> | 2020-05-07 15:47:49 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-05-10 21:43:51 +0200 |
commit | c6a3f51a89449f61ad20a1787c0a3cb41fa91466 (patch) | |
tree | 8b2fb0f7c67a8c500d0a94ba74ea99e7740ff822 /sc | |
parent | 4a1ceb06ca19a5c89895015e0fc73c8fa897294e (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')
-rw-r--r-- | sc/inc/docuno.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/inc/inputhdl.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 6 |
4 files changed, 15 insertions, 11 deletions
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index 47757a7503b7..7c9c87a4f109 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -387,7 +387,7 @@ public: OUString getPostItsPos() override; /// @see vcl::ITiledRenderable::completeFunction(). - virtual void completeFunction(int nIndex) override; + virtual void completeFunction(const OUString& rFunctionName) override; }; class ScDrawPagesObj final : public cppu::WeakImplHelper< 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(); + } } } } diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx index c6d681e70e05..a71c810845d4 100644 --- a/sc/source/ui/inc/inputhdl.hxx +++ b/sc/source/ui/inc/inputhdl.hxx @@ -288,7 +288,7 @@ public: long nX1, long nX2, long nY1, long nY2, long nTab, const Color& rColor ); - void LOKPasteFunctionData( sal_uInt32 nIndex ); + void LOKPasteFunctionData(const OUString& rFunctionName); }; // ScInputHdlState diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index da8394343891..2a4153756eb1 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1078,13 +1078,13 @@ OUString ScModelObj::getPostItsPos() return OUString::fromUtf8(aStream.str().c_str()); } -void ScModelObj::completeFunction(int nIndex) +void ScModelObj::completeFunction(const OUString& rFunctionName) { ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); if (pHdl) { - assert(nIndex >= 0); - pHdl->LOKPasteFunctionData(nIndex); + assert(!rFunctionName.isEmpty()); + pHdl->LOKPasteFunctionData(rFunctionName); } } |