summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Trzebiatowski <ubap.dev@gmail.com>2016-03-31 22:54:23 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-04-04 07:04:19 +0000
commitedc63d3abb5c4dae223f745f6384e7d0e5fc717e (patch)
tree62c6c8c0f20dd4364ee2725c5fe2084b2e0918b3
parent3dd9a3027d39ee9932b26abcde12363c881bff6a (diff)
tdf#45129 Customize Toolbars: Add category "All categories"
- added string "All commands" to resources - moved code responsible for flling functions list to a function - defined SVX_CFGGROUP_ALLFUNCTIONS - added "All categories" category Change-Id: I4f03c8bc0af44dba2ef89ddd64b3fac67c5f2695 Reviewed-on: https://gerrit.libreoffice.org/23572 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r--cui/source/customize/selector.cxx178
-rw-r--r--cui/source/dialogs/cuires.src5
-rw-r--r--cui/source/inc/cuires.hrc1
-rw-r--r--cui/source/inc/selector.hxx3
4 files changed, 113 insertions, 74 deletions
diff --git a/cui/source/customize/selector.cxx b/cui/source/customize/selector.cxx
index 21d58e05fcf3..01d4f4246b37 100644
--- a/cui/source/customize/selector.cxx
+++ b/cui/source/customize/selector.cxx
@@ -468,6 +468,14 @@ void SvxConfigGroupListBox::Init(bool bShowSlots, const Reference< frame::XFrame
if ( xModuleCategories.is() )
{
+ SvTreeListEntry *pEntry = InsertEntry( CUI_RES(RID_SVXSTR_ALLFUNCTIONS) );
+
+ SvxGroupInfo_Impl *pInfo =
+ new SvxGroupInfo_Impl( SVX_CFGGROUP_ALLFUNCTIONS, 0 );
+ aArr.push_back( std::unique_ptr<SvxGroupInfo_Impl>(pInfo) );
+
+ pEntry->SetUserData( pInfo );
+
Sequence< sal_Int16 > gids =
xDIP->getSupportedCommandGroups();
@@ -500,10 +508,9 @@ void SvxConfigGroupListBox::Init(bool bShowSlots, const Reference< frame::XFrame
{
}
- SvTreeListEntry *pEntry = InsertEntry( group );
+ pEntry = InsertEntry( group );
- SvxGroupInfo_Impl *pInfo =
- new SvxGroupInfo_Impl( SVX_CFGGROUP_FUNCTION, gids[i] );
+ pInfo = new SvxGroupInfo_Impl( SVX_CFGGROUP_FUNCTION, gids[i] );
aArr.push_back( std::unique_ptr<SvxGroupInfo_Impl>(pInfo) );
pEntry->SetUserData( pInfo );
@@ -636,6 +643,72 @@ SvxConfigGroupListBox::getDocumentModel(
return xModel;
}
+void SvxConfigGroupListBox::fillFunctionList(const Sequence< frame::DispatchInformation >& commands)
+{
+ for ( sal_Int32 i = 0; i < commands.getLength(); ++i )
+ {
+ if ( commands[i].Command.isEmpty() )
+ {
+ continue;
+ }
+
+ Image aImage;
+
+ OUString aCmdURL( commands[i].Command );
+
+ if ( m_pImageProvider )
+ {
+ aImage = m_pImageProvider->GetImage( aCmdURL );
+ }
+
+ OUString aLabel;
+ try
+ {
+ Any a = m_xModuleCommands->getByName( aCmdURL );
+ Sequence< beans::PropertyValue > aPropSeq;
+
+ if ( a >>= aPropSeq )
+ {
+ for ( sal_Int32 k = 0; k < aPropSeq.getLength(); ++k )
+ {
+ if ( aPropSeq[k].Name == "Name" )
+ {
+ aPropSeq[k].Value >>= aLabel;
+ break;
+ }
+ }
+ }
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ }
+
+ if ( aLabel.isEmpty() )
+ {
+ aLabel = commands[i].Command;
+ }
+
+ SvTreeListEntry* pFuncEntry = nullptr;
+ if ( !!aImage )
+ {
+ pFuncEntry = pFunctionListBox->InsertEntry(
+ aLabel, aImage, aImage );
+ }
+ else
+ {
+ pFuncEntry = pFunctionListBox->InsertEntry(
+ aLabel );
+ }
+
+ SvxGroupInfo_Impl *_pGroupInfo = new SvxGroupInfo_Impl(
+ SVX_CFGFUNCTION_SLOT, 123, aCmdURL, OUString() );
+
+ pFunctionListBox->aArr.push_back( std::unique_ptr<SvxGroupInfo_Impl>(_pGroupInfo) );
+
+ pFuncEntry->SetUserData( _pGroupInfo );
+ }
+}
+
void SvxConfigGroupListBox::GroupSelected()
{
SvTreeListEntry *pEntry = FirstSelected();
@@ -643,7 +716,8 @@ void SvxConfigGroupListBox::GroupSelected()
pFunctionListBox->SetUpdateMode(false);
pFunctionListBox->ClearAll();
if ( pInfo->nKind != SVX_CFGGROUP_FUNCTION &&
- pInfo->nKind != SVX_CFGGROUP_SCRIPTCONTAINER )
+ pInfo->nKind != SVX_CFGGROUP_SCRIPTCONTAINER &&
+ pInfo->nKind != SVX_CFGGROUP_ALLFUNCTIONS )
{
pFunctionListBox->SetUpdateMode(true);
return;
@@ -651,90 +725,46 @@ void SvxConfigGroupListBox::GroupSelected()
switch ( pInfo->nKind )
{
- case SVX_CFGGROUP_FUNCTION :
+ case SVX_CFGGROUP_FUNCTION:
{
- SvTreeListEntry *_pEntry = FirstSelected();
- if ( _pEntry != nullptr )
+ Reference< frame::XDispatchInformationProvider > xDIP( m_xFrame, UNO_QUERY );
+ Sequence< frame::DispatchInformation > commands;
+ try
{
- SvxGroupInfo_Impl *_pInfo =
- static_cast<SvxGroupInfo_Impl*>(_pEntry->GetUserData());
-
- Reference< frame::XDispatchInformationProvider > xDIP(
- m_xFrame, UNO_QUERY );
+ commands = xDIP->getConfigurableDispatchInformation( pInfo->nOrd );
+ fillFunctionList(commands);
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ }
- Sequence< frame::DispatchInformation > commands;
- try
- {
- commands = xDIP->getConfigurableDispatchInformation(
- _pInfo->nOrd );
- }
- catch ( container::NoSuchElementException& )
- {
- }
+ break;
+ }
- for ( sal_Int32 i = 0; i < commands.getLength(); ++i )
+ case SVX_CFGGROUP_ALLFUNCTIONS:
+ {
+ Reference< frame::XDispatchInformationProvider > xDIP( m_xFrame, UNO_QUERY );
+ SvTreeListEntry *pCurrEntry = First();
+ while( pCurrEntry )
+ {
+ SvxGroupInfo_Impl *pCurrentInfo = static_cast<SvxGroupInfo_Impl*>(pCurrEntry->GetUserData());
+ if (pCurrentInfo->nKind == SVX_CFGGROUP_FUNCTION)
{
- if ( commands[i].Command.isEmpty() )
- {
- continue;
- }
-
- Image aImage;
- OUString aCmdURL( commands[i].Command );
- if ( m_pImageProvider )
- {
- aImage = m_pImageProvider->GetImage( aCmdURL );
- }
-
- OUString aLabel;
+ Sequence< frame::DispatchInformation > commands;
try
{
- Any a = m_xModuleCommands->getByName( aCmdURL );
- Sequence< beans::PropertyValue > aPropSeq;
-
- if ( a >>= aPropSeq )
- {
- for ( sal_Int32 k = 0; k < aPropSeq.getLength(); ++k )
- {
- if ( aPropSeq[k].Name == "Name" )
- {
- aPropSeq[k].Value >>= aLabel;
- break;
- }
- }
- }
+ commands = xDIP->getConfigurableDispatchInformation( pCurrentInfo->nOrd );
+ fillFunctionList(commands);
}
catch ( container::NoSuchElementException& )
{
}
-
- if ( aLabel.isEmpty() )
- {
- aLabel = commands[i].Command;
- }
-
- SvTreeListEntry* pFuncEntry = nullptr;
- if ( !!aImage )
- {
- pFuncEntry = pFunctionListBox->InsertEntry(
- aLabel, aImage, aImage );
- }
- else
- {
- pFuncEntry = pFunctionListBox->InsertEntry(
- aLabel );
- }
-
- SvxGroupInfo_Impl *_pGroupInfo = new SvxGroupInfo_Impl(
- SVX_CFGFUNCTION_SLOT, 123, aCmdURL, OUString() );
-
- pFunctionListBox->aArr.push_back( std::unique_ptr<SvxGroupInfo_Impl>(_pGroupInfo) );
-
- pFuncEntry->SetUserData( _pGroupInfo );
}
- }
+ pCurrEntry = Next( pCurrEntry );
+ };
+
break;
}
diff --git a/cui/source/dialogs/cuires.src b/cui/source/dialogs/cuires.src
index a738423f593d..b0fa5da214c1 100644
--- a/cui/source/dialogs/cuires.src
+++ b/cui/source/dialogs/cuires.src
@@ -19,6 +19,11 @@ String RID_SVXSTR_SELECT_FILE_IFRAME
Text [ en-US ] = "Select File for Floating Frame" ;
};
+String RID_SVXSTR_ALLFUNCTIONS
+{
+ Text [ en-US ] = "All categories";
+};
+
String RID_SVXSTR_MYMACROS
{
Text [ en-US ] = "My Macros";
diff --git a/cui/source/inc/cuires.hrc b/cui/source/inc/cuires.hrc
index f9b2843c055c..de91c471a379 100644
--- a/cui/source/inc/cuires.hrc
+++ b/cui/source/inc/cuires.hrc
@@ -349,6 +349,7 @@
#define RID_SVXSTR_ROW (RID_SVX_START + 1201)
#define RID_SVXSTR_COL (RID_SVX_START + 1202)
#define RID_SVXSTR_AUTO_ENTRY (RID_SVX_START + 1203)
+#define RID_SVXSTR_ALLFUNCTIONS (RID_SVX_START + 1204)
#define RID_SVXSTR_USE_REPLACE (RID_SVX_START + 1205)
#define RID_SVXSTR_CPTL_STT_WORD (RID_SVX_START + 1206)
diff --git a/cui/source/inc/selector.hxx b/cui/source/inc/selector.hxx
index 2f6b194873af..d9b617290239 100644
--- a/cui/source/inc/selector.hxx
+++ b/cui/source/inc/selector.hxx
@@ -26,6 +26,7 @@
#include <svtools/treelistbox.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/frame/DispatchInformation.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/script/browse/XBrowseNode.hpp>
@@ -38,6 +39,7 @@ class SaveInData;
#define SVX_CFGFUNCTION_SLOT 2
#define SVX_CFGGROUP_SCRIPTCONTAINER 3
#define SVX_CFGFUNCTION_SCRIPT 4
+#define SVX_CFGGROUP_ALLFUNCTIONS 5
struct SvxGroupInfo_Impl
{
@@ -149,6 +151,7 @@ private:
SvTreeListEntry* _pParentEntry,
bool _bCheapChildrenOnDemand
);
+ void fillFunctionList( const com::sun::star::uno::Sequence< com::sun::star::frame::DispatchInformation >& commands );
protected:
virtual void RequestingChildren( SvTreeListEntry *pEntry) override;