[Libreoffice-commits] core.git: cui/source

Jakub Trzebiatowski ubap.dev at gmail.com
Mon Apr 4 07:04:44 UTC 2016


 cui/source/customize/selector.cxx |  178 ++++++++++++++++++++++----------------
 cui/source/dialogs/cuires.src     |    5 +
 cui/source/inc/cuires.hrc         |    1 
 cui/source/inc/selector.hxx       |    3 
 4 files changed, 113 insertions(+), 74 deletions(-)

New commits:
commit edc63d3abb5c4dae223f745f6384e7d0e5fc717e
Author: Jakub Trzebiatowski <ubap.dev at gmail.com>
Date:   Thu Mar 31 22:54:23 2016 +0200

    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 at libreoffice.org>
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/cui/source/customize/selector.cxx b/cui/source/customize/selector.cxx
index 21d58e0..01d4f42 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 a738423..b0fa5da 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 f9b2843..de91c47 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 2f6b194..d9b6172 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;


More information about the Libreoffice-commits mailing list