summaryrefslogtreecommitdiff
path: root/sc/source/ui/app/inputhdl.cxx
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2021-12-07 07:42:52 +0200
committerEike Rathke <erack@redhat.com>2021-12-13 23:29:58 +0100
commita141f91037f9cf29822a369261f9e99dffffb964 (patch)
tree604a5112e8882f5d67f40809f8190d1d769d2309 /sc/source/ui/app/inputhdl.cxx
parentdaf0526ee637a46eec34cc9d086d5c53a1368d51 (diff)
tdf#92010 sc autoFormula: prefer MRU formulas
Prior to 4.3, only MRU formulas were auto-completed. Then it changed to suggest all formulas - alphabetically for the most part. That 4.3 commit 5b0b7553241bb5150b12bbf7625b4b0b36970272 completely removed all reference to MRU. But it makes sense to prefer an MRU over a strictly alphabetical match. This patch depends on LO 7.4 patch "new ScTypedStrData: typically missed argument in CTOR" Change-Id: Id5d860d1401693f43833719977d1c1e4c386385c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126499 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Eike Rathke <erack@redhat.com> (cherry picked from commit b93a6964e0466c1b67d2c233040357a8f6c75214) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126749
Diffstat (limited to 'sc/source/ui/app/inputhdl.cxx')
-rw-r--r--sc/source/ui/app/inputhdl.cxx23
1 files changed, 23 insertions, 0 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index b9ee0d62d02b..307f0f7a6886 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1048,6 +1048,29 @@ void ScInputHandler::GetFormulaData()
pFormulaDataPara->insert(ScTypedStrData(aEntry, 0.0, 0.0, ScTypedStrData::Standard));
}
}
+
+ // Increase suggestion priority of MRU formulas
+ const ScAppOptions& rOpt = SC_MOD()->GetAppOptions();
+ const sal_uInt16 nMRUCount = rOpt.GetLRUFuncListCount();
+ const sal_uInt16* pMRUList = rOpt.GetLRUFuncList();
+ for (sal_uInt16 i = 0; i < nMRUCount; i++)
+ {
+ const sal_uInt16 nId = pMRUList[i];
+ for (sal_uInt32 j = 0; j < nListCount; j++)
+ {
+ const ScFuncDesc* pDesc = pFuncList->GetFunction(j);
+ if (pDesc->nFIndex == nId && pDesc->mxFuncName)
+ {
+ const OUString aEntry = *pDesc->mxFuncName + aParenthesesReplacement;;
+ const ScTypedStrData aData(aEntry, 0.0, 0.0, ScTypedStrData::Standard);
+ auto it = pFormulaData->find(aData);
+ if (it != pFormulaData->end())
+ pFormulaData->erase(it);
+ pFormulaData->insert(ScTypedStrData(aEntry, 0.0, 0.0, ScTypedStrData::MRU));
+ break; // Stop searching
+ }
+ }
+ }
miAutoPosFormula = pFormulaData->end();
rDoc.GetFormulaEntries( *pFormulaData );
rDoc.GetFormulaEntries( *pFormulaDataPara );