summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--formula/source/ui/dlg/funcpage.cxx85
-rw-r--r--formula/source/ui/dlg/funcpage.hxx5
-rw-r--r--formula/uiconfig/ui/functionpage.ui40
3 files changed, 100 insertions, 30 deletions
diff --git a/formula/source/ui/dlg/funcpage.cxx b/formula/source/ui/dlg/funcpage.cxx
index 9a20545c9228..096822499d92 100644
--- a/formula/source/ui/dlg/funcpage.cxx
+++ b/formula/source/ui/dlg/funcpage.cxx
@@ -28,6 +28,8 @@
#include "formdlgs.hrc"
#include "ForResId.hrc"
#include "ModuleHelper.hxx"
+#include <unotools/syslocale.hxx>
+#include <unotools/charclass.hxx>
namespace formula
{
@@ -64,6 +66,7 @@ FuncPage::FuncPage(vcl::Window* pParent,const IFunctionManager* _pFunctionManage
{
get(m_pLbCategory, "category");
get(m_pLbFunction, "function");
+ get(m_plbFunctionSearchString, "search");
m_pLbFunction->SetStyle(m_pLbFunction->GetStyle() | WB_SORT);
Size aSize(LogicToPixel(Size(86 , 162), MapUnit::MapAppFont));
m_pLbFunction->set_height_request(aSize.Height());
@@ -81,10 +84,12 @@ FuncPage::FuncPage(vcl::Window* pParent,const IFunctionManager* _pFunctionManage
m_pLbCategory->SetDropDownLineCount(m_pLbCategory->GetEntryCount());
m_pLbCategory->SelectEntryPos(1);
- UpdateFunctionList();
+ OUString searchStr = m_plbFunctionSearchString->GetText();
+ UpdateFunctionList(searchStr);
m_pLbCategory->SetSelectHdl( LINK( this, FuncPage, SelHdl ) );
m_pLbFunction->SetSelectHdl( LINK( this, FuncPage, SelHdl ) );
m_pLbFunction->SetDoubleClickHdl( LINK( this, FuncPage, DblClkHdl ) );
+ m_plbFunctionSearchString->SetModifyHdl( LINK( this, FuncPage, ModifyHdl ) );
}
FuncPage::~FuncPage()
@@ -96,6 +101,7 @@ void FuncPage::dispose()
{
m_pLbCategory.clear();
m_pLbFunction.clear();
+ m_plbFunctionSearchString.clear();
TabPage::dispose();
}
@@ -111,47 +117,72 @@ void FuncPage::impl_addFunctions(const IFunctionCategory* _pCategory)
}
}
-void FuncPage::UpdateFunctionList()
+//aStr is non-empty when user types in the search box to search some function
+void FuncPage::UpdateFunctionList(const OUString& aStr)
{
- sal_Int32 nSelPos = m_pLbCategory->GetSelectEntryPos();
- const IFunctionCategory* pCategory = static_cast<const IFunctionCategory*>(m_pLbCategory->GetEntryData(nSelPos));
m_pLbFunction->Clear();
m_pLbFunction->SetUpdateMode( false );
-
- if ( nSelPos > 0 )
+ if(aStr.isEmpty())
{
- if ( pCategory == nullptr )
+ sal_Int32 nSelPos = m_pLbCategory->GetSelectEntryPos();
+ const IFunctionCategory* pCategory = static_cast<const IFunctionCategory*>(m_pLbCategory->GetEntryData(nSelPos));
+
+ if ( nSelPos > 0 )
{
- const sal_uInt32 nCount = m_pFunctionManager->getCount();
- for(sal_uInt32 i = 0 ; i < nCount; ++i)
+ if ( pCategory == nullptr )
+ {
+ const sal_uInt32 nCount = m_pFunctionManager->getCount();
+ for(sal_uInt32 i = 0 ; i < nCount; ++i)
+ {
+ impl_addFunctions(m_pFunctionManager->getCategory(i));
+ }
+ }
+ else
{
- impl_addFunctions(m_pFunctionManager->getCategory(i));
+ impl_addFunctions(pCategory);
}
}
- else
+ else // LRU-List
{
- impl_addFunctions(pCategory);
+ ::std::vector< TFunctionDesc >::iterator aIter = aLRUList.begin();
+ ::std::vector< TFunctionDesc >::iterator aEnd = aLRUList.end();
+
+ for ( ; aIter != aEnd; ++aIter )
+ {
+ const IFunctionDescription* pDesc = *aIter;
+ if (pDesc) // may be null if a function is no longer available
+ {
+ m_pLbFunction->SetEntryData(
+ m_pLbFunction->InsertEntry( pDesc->getFunctionName() ), const_cast<IFunctionDescription *>(pDesc) );
+ }
+ }
}
}
- else // LRU-List
+ else
{
- ::std::vector< TFunctionDesc >::iterator aIter = aLRUList.begin();
- ::std::vector< TFunctionDesc >::iterator aEnd = aLRUList.end();
+ SvtSysLocale aSysLocale;
+ const CharClass* pCharClassPtr = aSysLocale.GetCharClassPtr();
+ OUString aSearchStr = pCharClassPtr->uppercase(aStr);
- for ( ; aIter != aEnd; ++aIter )
+ const sal_uInt32 nCategoryCount = m_pFunctionManager->getCount();
+ for (sal_uInt32 i = 0; i < nCategoryCount; i++)
{
- const IFunctionDescription* pDesc = *aIter;
- if (pDesc) // may be null if a function is no longer available
+ const IFunctionCategory* pCategory = m_pFunctionManager->getCategory(i);
+ const sal_uInt32 functionCount = pCategory->getCount();
+ for (sal_uInt32 j = 0; j < functionCount; ++j)
{
- m_pLbFunction->SetEntryData(
- m_pLbFunction->InsertEntry( pDesc->getFunctionName() ), const_cast<IFunctionDescription *>(pDesc) );
+ TFunctionDesc pDesc(pCategory->getFunction(j));
+ if (pCharClassPtr->uppercase(pDesc->getFunctionName()).indexOf(aSearchStr) >= 0)
+ {
+ m_pLbFunction->SetEntryData(
+ m_pLbFunction->InsertEntry(pDesc->getFunctionName()), const_cast<IFunctionDescription *>(pDesc));
+ }
}
}
}
-
m_pLbFunction->SetUpdateMode( true );
// Ensure no function is selected so the Next button doesn't overwrite a
// function that is not in the list with an arbitrary selected one.
@@ -175,8 +206,9 @@ IMPL_LINK( FuncPage, SelHdl, ListBox&, rLb, void )
}
else
{
+ OUString searchStr = m_plbFunctionSearchString->GetText();
m_pLbFunction->SetHelpId(m_aHelpId);
- UpdateFunctionList();
+ UpdateFunctionList(searchStr);
}
}
@@ -185,10 +217,17 @@ IMPL_LINK_NOARG(FuncPage, DblClkHdl, ListBox&, void)
aDoubleClickLink.Call(*this);
}
+IMPL_LINK_NOARG(FuncPage, ModifyHdl, Edit&, void)
+{
+ OUString searchStr = m_plbFunctionSearchString->GetText();
+ UpdateFunctionList(searchStr);
+}
+
void FuncPage::SetCategory(sal_Int32 nCat)
{
+ OUString searchStr = m_plbFunctionSearchString->GetText();
m_pLbCategory->SelectEntryPos(nCat);
- UpdateFunctionList();
+ UpdateFunctionList(searchStr);
}
sal_Int32 FuncPage::GetFuncPos(const IFunctionDescription* _pDesc)
diff --git a/formula/source/ui/dlg/funcpage.hxx b/formula/source/ui/dlg/funcpage.hxx
index b47a6d9f4be8..f2780492458c 100644
--- a/formula/source/ui/dlg/funcpage.hxx
+++ b/formula/source/ui/dlg/funcpage.hxx
@@ -61,8 +61,10 @@ private:
OModuleClient m_aModuleClient;
Link<FuncPage&,void> aDoubleClickLink;
Link<FuncPage&,void> aSelectionLink;
+ Link<FuncPage&, void> aModifyLink;
VclPtr<ListBox> m_pLbCategory;
VclPtr<FormulaListBox> m_pLbFunction;
+ VclPtr<Edit> m_plbFunctionSearchString;
const IFunctionManager* m_pFunctionManager;
::std::vector< TFunctionDesc > aLRUList;
@@ -72,10 +74,11 @@ private:
void impl_addFunctions(const IFunctionCategory* _pCategory);
DECL_LINK( SelHdl, ListBox&, void );
DECL_LINK(DblClkHdl, ListBox&, void);
+ DECL_LINK(ModifyHdl, Edit&, void);
protected:
- void UpdateFunctionList();
+ void UpdateFunctionList(const OUString&);
void InitLRUList();
diff --git a/formula/uiconfig/ui/functionpage.ui b/formula/uiconfig/ui/functionpage.ui
index 00b98df5b869..a382836741a4 100644
--- a/formula/uiconfig/ui/functionpage.ui
+++ b/formula/uiconfig/ui/functionpage.ui
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.0"/>
- <!-- interface-requires LibreOffice 1.0 -->
+ <requires lib="LibreOffice" version="1.0"/>
<object class="GtkBox" id="FunctionPage">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -12,6 +12,34 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
+ <object class="GtkLabel" id="label_search">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">_Search</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">search</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="search">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -23,7 +51,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -39,7 +67,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -54,7 +82,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -70,7 +98,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="position">5</property>
</packing>
</child>
</object>