summaryrefslogtreecommitdiff
path: root/formula/source
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2020-04-22 22:37:21 +0200
committerEike Rathke <erack@redhat.com>2020-04-23 16:40:38 +0200
commit2aab1c47df5648a3667c75efcdd1c1a4f08d6146 (patch)
tree492e935d09e6c662a78c3b1d906d97fca9a290b2 /formula/source
parent7690f3269c89140930f49068133e7d061d475948 (diff)
Related tdf#131169: avoid magic numbers
Change-Id: Ic82f214f22933e3c74b8b0fc4c6a25b19f103fa1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92735 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'formula/source')
-rw-r--r--formula/source/ui/dlg/FormulaHelper.cxx5
-rw-r--r--formula/source/ui/dlg/formula.cxx9
-rw-r--r--formula/source/ui/dlg/funcpage.cxx5
-rw-r--r--formula/source/ui/dlg/funcpage.hxx1
4 files changed, 16 insertions, 4 deletions
diff --git a/formula/source/ui/dlg/FormulaHelper.cxx b/formula/source/ui/dlg/FormulaHelper.cxx
index b3c0b4a204bc..9dbc5d8f7b80 100644
--- a/formula/source/ui/dlg/FormulaHelper.cxx
+++ b/formula/source/ui/dlg/FormulaHelper.cxx
@@ -71,6 +71,11 @@ FormulaHelper::FormulaHelper(const IFunctionManager* _pFunctionManager)
m_pCharClass = m_pSysLocale->GetCharClassPtr();
}
+sal_Int32 FormulaHelper::GetCategoryCount() const
+{
+ return m_pFunctionManager->getCount();
+}
+
bool FormulaHelper::GetNextFunc( const OUString& rFormula,
bool bBack,
sal_Int32& rFStart, // Input and output
diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
index 824df1bfe4c0..f43f95f7e0fb 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -819,10 +819,11 @@ void FormulaDlg_Impl::FillListboxes()
if ( m_pFuncDesc && m_pFuncDesc->getCategory() )
{
// We'll never have more than int32 max categories so this is safe ...
- // m_xFuncPage->GetCategory() takes into account "Last Used" + "All" so 13 categories (0 -> 12)
- // whereas m_pFuncDesc->getCategory()->getNumber() doesn't take into account the 2 first (so only 0->10)
- if ( m_xFuncPage->GetCategory() != static_cast<sal_Int32>(m_pFuncDesc->getCategory()->getNumber() + 2) )
- m_xFuncPage->SetCategory(m_pFuncDesc->getCategory()->getNumber() + 2);
+ // Category listbox holds additional entries for Last Used and All, so
+ // the offset should be two but hard coded numbers are ugly...
+ const sal_Int32 nCategoryOffset = m_xFuncPage->GetCategoryEntryCount() - m_aFormulaHelper.GetCategoryCount();
+ if ( m_xFuncPage->GetCategory() != static_cast<sal_Int32>(m_pFuncDesc->getCategory()->getNumber() + nCategoryOffset) )
+ m_xFuncPage->SetCategory(m_pFuncDesc->getCategory()->getNumber() + nCategoryOffset);
sal_Int32 nPos = m_xFuncPage->GetFuncPos(m_pFuncDesc);
diff --git a/formula/source/ui/dlg/funcpage.cxx b/formula/source/ui/dlg/funcpage.cxx
index 58279485d09b..56162a45a1d9 100644
--- a/formula/source/ui/dlg/funcpage.cxx
+++ b/formula/source/ui/dlg/funcpage.cxx
@@ -242,6 +242,11 @@ sal_Int32 FuncPage::GetCategory() const
return m_xLbCategory->get_active();
}
+sal_Int32 FuncPage::GetCategoryEntryCount() const
+{
+ return m_xLbCategory->get_count();
+}
+
sal_Int32 FuncPage::GetFunction() const
{
return m_xLbFunction->get_selected_index();
diff --git a/formula/source/ui/dlg/funcpage.hxx b/formula/source/ui/dlg/funcpage.hxx
index 95b9e1337b02..319ee7c8ad2c 100644
--- a/formula/source/ui/dlg/funcpage.hxx
+++ b/formula/source/ui/dlg/funcpage.hxx
@@ -68,6 +68,7 @@ public:
void SetFunction(sal_Int32 nFunc);
void SetFocus();
sal_Int32 GetCategory() const;
+ sal_Int32 GetCategoryEntryCount() const;
sal_Int32 GetFunction() const;
sal_Int32 GetFunctionEntryCount() const;