summaryrefslogtreecommitdiff
path: root/sc
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-08 10:46:09 +0200
commitf56ace63f3bae98dc0185043d85157d366fd9311 (patch)
tree56597a9be713febbeeac47cdfd9b33cbb71d6322 /sc
parentba552ebf17c44b6951f472cce0b2bb318fd8f952 (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>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/docuno.hxx2
-rw-r--r--sc/source/ui/app/inputhdl.cxx16
-rw-r--r--sc/source/ui/inc/inputhdl.hxx2
-rw-r--r--sc/source/ui/unoobj/docuno.cxx6
4 files changed, 15 insertions, 11 deletions
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 5a5cf33bd3e9..3229dd86d720 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -385,7 +385,7 @@ public:
OUString getPostItsPos() override;
/// @see vcl::ITiledRenderable::completeFunction().
- virtual void completeFunction(int nIndex) override;
+ virtual void completeFunction(const OUString& rFunctionName) override;
};
class ScDrawPagesObj : public cppu::WeakImplHelper<
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 8f422831c6a6..68e2f780fc14 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1642,7 +1642,7 @@ void ScInputHandler::PasteFunctionData()
pActiveView->ShowCursor();
}
-void ScInputHandler::LOKPasteFunctionData( sal_uInt32 nIndex )
+void ScInputHandler::LOKPasteFunctionData(const OUString& rFunctionName)
{
// in case we have no top view try to create it
if (!pTopView && pInputWin)
@@ -1675,12 +1675,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 70a1cd6e09d0..4d7bfca86cae 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 89fa194c4770..4145fd55769c 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1083,13 +1083,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);
}
}