diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2020-04-22 22:37:21 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2020-04-23 16:40:38 +0200 |
commit | 2aab1c47df5648a3667c75efcdd1c1a4f08d6146 (patch) | |
tree | 492e935d09e6c662a78c3b1d906d97fca9a290b2 /formula/source/ui/dlg/formula.cxx | |
parent | 7690f3269c89140930f49068133e7d061d475948 (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/ui/dlg/formula.cxx')
-rw-r--r-- | formula/source/ui/dlg/formula.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
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); |