summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--include/formula/formulahelper.hxx2
5 files changed, 18 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;
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