[Libreoffice-commits] core.git: formula/source include/formula
Julien Nabet (via logerrit)
logerrit at kemper.freedesktop.org
Thu Apr 23 14:41:14 UTC 2020
formula/source/ui/dlg/FormulaHelper.cxx | 5 +++++
formula/source/ui/dlg/formula.cxx | 9 +++++----
formula/source/ui/dlg/funcpage.cxx | 5 +++++
formula/source/ui/dlg/funcpage.hxx | 1 +
include/formula/formulahelper.hxx | 2 ++
5 files changed, 18 insertions(+), 4 deletions(-)
New commits:
commit 2aab1c47df5648a3667c75efcdd1c1a4f08d6146
Author: Julien Nabet <serval2412 at yahoo.fr>
AuthorDate: Wed Apr 22 22:37:21 2020 +0200
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Thu Apr 23 16:40:38 2020 +0200
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 at redhat.com>
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;
diff --git a/include/formula/formulahelper.hxx b/include/formula/formulahelper.hxx
index 8774bb332eb0..02f757dc3726 100644
--- a/include/formula/formulahelper.hxx
+++ b/include/formula/formulahelper.hxx
@@ -50,6 +50,8 @@ namespace formula
const CharClass* GetCharClass() const { return m_pCharClass; }
+ sal_Int32 GetCategoryCount() const;
+
bool GetNextFunc( const OUString& rFormula,
bool bBack,
sal_Int32& rFStart, // input and output
More information about the Libreoffice-commits
mailing list