summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cui/source/customize/CommandCategoryListBox.cxx37
-rw-r--r--cui/source/customize/SvxMenuConfigPage.cxx4
-rw-r--r--cui/source/customize/SvxToolbarConfigPage.cxx4
-rw-r--r--cui/source/customize/cfg.cxx12
-rw-r--r--cui/source/inc/CommandCategoryListBox.hxx10
-rw-r--r--cui/source/inc/cfg.hxx2
-rw-r--r--cui/uiconfig/ui/menuassignpage.ui3
7 files changed, 62 insertions, 10 deletions
diff --git a/cui/source/customize/CommandCategoryListBox.cxx b/cui/source/customize/CommandCategoryListBox.cxx
index c1abd3fe7d05..50542739c82e 100644
--- a/cui/source/customize/CommandCategoryListBox.cxx
+++ b/cui/source/customize/CommandCategoryListBox.cxx
@@ -25,15 +25,27 @@
#include <com/sun/star/ui/theUICategoryDescription.hpp>
#include <vcl/builderfactory.hxx>
+// include search util
+#include <com/sun/star/util/SearchFlags.hpp>
+#include <com/sun/star/util/SearchAlgorithms2.hpp>
+#include <unotools/textsearch.hxx>
+
#include "dialmgr.hxx"
#include "strings.hrc"
#include <comphelper/sequenceashashmap.hxx>
#include <o3tl/make_unique.hxx>
+#include <i18nutil/searchopt.hxx>
CommandCategoryListBox::CommandCategoryListBox(vcl::Window* pParent, WinBits nStyle)
: ListBox( pParent, nStyle)
{
SetDropDownLineCount(25);
+
+ //Initialize search util
+ m_searchOptions.AlgorithmType2 = css::util::SearchAlgorithms2::ABSOLUTE;
+ m_searchOptions.transliterateFlags |= TransliterationFlags::IGNORE_CASE;
+ m_searchOptions.searchFlag |= (css::util::SearchFlags::REG_NOT_BEGINOFLINE
+ | css::util::SearchFlags::REG_NOT_ENDOFLINE);
}
VCL_BUILDER_FACTORY(CommandCategoryListBox);
@@ -126,11 +138,25 @@ void CommandCategoryListBox::Init(
void CommandCategoryListBox::FillFunctionsList(
const css::uno::Sequence<css::frame::DispatchInformation>& xCommands,
- const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox)
+ const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox,
+ const OUString& filterTerm )
{
+ // Setup search filter parameters
+ m_searchOptions.searchString = filterTerm;
+ utl::TextSearch textSearch( m_searchOptions );
+
for (const auto & rInfo : xCommands)
{
- OUString sUIName = MapCommand2UIName(rInfo.Command);
+ OUString sUIName = MapCommand2UIName(rInfo.Command);
+ sal_Int32 aStartPos = 0;
+ sal_Int32 aEndPos = sUIName.getLength();
+
+ // Apply the search filter
+ if (!filterTerm.isEmpty()
+ && !textSearch.SearchForward( sUIName, &aStartPos, &aEndPos ) )
+ {
+ continue;
+ }
SvTreeListEntry* pFuncEntry = pFunctionListBox->InsertEntry(sUIName );
@@ -169,7 +195,8 @@ OUString CommandCategoryListBox::MapCommand2UIName(const OUString& sCommand)
return sUIName;
}
-void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox )
+void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox,
+ const OUString& filterTerm )
{
SfxGroupInfo_Impl *pInfo = static_cast<SfxGroupInfo_Impl*>(GetSelectEntryData());
pFunctionListBox->SetUpdateMode(false);
@@ -195,7 +222,7 @@ void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionLis
{
lCommands = xProvider->getConfigurableDispatchInformation(
pCurrentInfo->nUniqueID );
- FillFunctionsList( lCommands, pFunctionListBox );
+ FillFunctionsList( lCommands, pFunctionListBox, filterTerm );
}
catch( css::container::NoSuchElementException& )
{
@@ -213,7 +240,7 @@ void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionLis
xProvider (m_xFrame, css::uno::UNO_QUERY_THROW);
css::uno::Sequence< css::frame::DispatchInformation > lCommands =
xProvider->getConfigurableDispatchInformation(nGroup);
- FillFunctionsList( lCommands, pFunctionListBox );
+ FillFunctionsList( lCommands, pFunctionListBox, filterTerm );
break;
}
case SfxCfgKind::GROUP_SCRIPTCONTAINER:
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 2c6723240fad..3d0bdff25f73 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -289,7 +289,9 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, SelectMenu, ListBox&, void )
IMPL_LINK_NOARG( SvxMenuConfigPage, SelectCategory, ListBox&, void )
{
- m_pCommandCategoryListBox->categorySelected( m_pFunctions );
+ OUString aSearchTerm( m_pSearchEdit->GetText() );
+
+ m_pCommandCategoryListBox->categorySelected( m_pFunctions, aSearchTerm );
}
IMPL_LINK_NOARG( SvxMenuConfigPage, AddCommandHdl, Button *, void )
diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index 5adc6a7f7a0b..76a29b8acced 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -321,7 +321,9 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectToolbarEntry, SvTreeListBox *, void
IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectCategory, ListBox&, void )
{
- m_pCommandCategoryListBox->categorySelected( m_pFunctions );
+ OUString aSearchTerm( m_pSearchEdit->GetText() );
+
+ m_pCommandCategoryListBox->categorySelected( m_pFunctions, aSearchTerm );
}
IMPL_LINK_NOARG( SvxToolbarConfigPage, AddCommandHdl, Button *, void )
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 9c339e395cbe..7883a3c13444 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1133,6 +1133,7 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
, m_pContentsListBox(nullptr)
, m_pSelectorDlg(nullptr)
{
+ get(m_pSearchEdit, "searchEntry");
get(m_pCommandCategoryListBox, "commandcategorylist");
get(m_pFunctions, "functions");
@@ -1155,6 +1156,9 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
m_pDescriptionField->SetControlBackground( GetSettings().GetStyleSettings().GetDialogColor() );
m_pDescriptionField->EnableCursor( false );
+
+ m_pSearchEdit->SetUpdateDataHdl ( LINK( this, SvxConfigPage, SearchUpdateHdl ));
+ m_pSearchEdit->EnableUpdateData();
}
SvxConfigPage::~SvxConfigPage()
@@ -1165,6 +1169,7 @@ SvxConfigPage::~SvxConfigPage()
void SvxConfigPage::dispose()
{
m_pTopLevelListBox.clear();
+ m_pSearchEdit.clear();
m_pCommandCategoryListBox.clear();
m_pContents.clear();
m_pEntries.clear();
@@ -1746,6 +1751,13 @@ IMPL_LINK( SvxConfigPage, MoveHdl, Button *, pButton, void )
MoveEntry(pButton == m_pMoveUpButton);
}
+IMPL_LINK_NOARG(SvxConfigPage, SearchUpdateHdl, Edit&, void)
+{
+ OUString aSearchTerm( m_pSearchEdit->GetText() );
+
+ m_pCommandCategoryListBox->categorySelected( m_pFunctions, aSearchTerm );
+}
+
void SvxConfigPage::MoveEntry( bool bMoveUp )
{
SvTreeListEntry *pSourceEntry = m_pContentsListBox->FirstSelected();
diff --git a/cui/source/inc/CommandCategoryListBox.hxx b/cui/source/inc/CommandCategoryListBox.hxx
index 5afc4ce798d8..a3480af6ae48 100644
--- a/cui/source/inc/CommandCategoryListBox.hxx
+++ b/cui/source/inc/CommandCategoryListBox.hxx
@@ -20,6 +20,7 @@
#define INCLUDED_CUI_SOURCE_INC_COMMANDCATEGORYLISTBOX_HXX
#include <vcl/lstbox.hxx>
+#include <i18nutil/searchopt.hxx>
#include "cfgutil.hxx"
class CommandCategoryListBox : public ListBox
@@ -32,6 +33,9 @@ class CommandCategoryListBox : public ListBox
css::uno::Reference< css::container::XNameAccess > m_xModuleCategoryInfo;
css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription;
+ // For search
+ i18nutil::SearchOptions2 m_searchOptions;
+
public:
CommandCategoryListBox( vcl::Window* pParent, WinBits nBits = WB_BORDER | WB_DROPDOWN );
virtual ~CommandCategoryListBox() override;
@@ -44,7 +48,8 @@ public:
const OUString& sModuleLongName);
void FillFunctionsList(
const css::uno::Sequence< css::frame::DispatchInformation >& xCommands,
- const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox);
+ const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox,
+ const OUString& filterTerm = OUString() );
OUString MapCommand2UIName(const OUString& sCommand);
/**
@@ -52,7 +57,8 @@ public:
And updates the functions list box to include
the commands in the selected category.
*/
- void categorySelected( const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox );
+ void categorySelected( const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox,
+ const OUString& filterTerm = OUString() );
};
#endif // INCLUDED_CUI_SOURCE_INC_COMMANDCATEGORYLISTBOX_HXX
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index f05d8fa74d5c..f951acc8a137 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -379,11 +379,13 @@ private:
DECL_LINK( SelectSaveInLocation, ListBox&, void );
DECL_LINK( AsyncInfoMsg, void*, void );
+ DECL_LINK( SearchUpdateHdl, Edit&, void );
protected:
// Left side of the dialog where command categories and the available
// commands in them are displayed as a searchable list
+ VclPtr<Edit> m_pSearchEdit;
VclPtr<CommandCategoryListBox> m_pCommandCategoryListBox;
VclPtr<SfxConfigFunctionListBox> m_pFunctions;
diff --git a/cui/uiconfig/ui/menuassignpage.ui b/cui/uiconfig/ui/menuassignpage.ui
index 3eb6837c6992..9ad40abc03c9 100644
--- a/cui/uiconfig/ui/menuassignpage.ui
+++ b/cui/uiconfig/ui/menuassignpage.ui
@@ -487,10 +487,11 @@
</packing>
</child>
<child>
- <object class="GtkEntry">
+ <object class="GtkEntry" id="searchEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_bottom">5</property>
+ <property name="placeholder_text" translatable="yes">Type to search</property>
</object>
<packing>
<property name="left_attach">1</property>