[Libreoffice-commits] core.git: framework/inc framework/source

Susobhan Ghosh susobhang70 at gmail.com
Thu Jan 14 07:17:49 PST 2016


 framework/inc/uielement/toolbarsmenucontroller.hxx    |    3 -
 framework/source/uielement/toolbarsmenucontroller.cxx |   50 ------------------
 2 files changed, 2 insertions(+), 51 deletions(-)

New commits:
commit 98887155c0fd209ed60e181f745bf00fb2d69ab7
Author: Susobhan Ghosh <susobhang70 at gmail.com>
Date:   Thu Jan 14 16:18:35 2016 +0530

    tdf#95845 Use CommandInfoProvider to receive UNO command labels
    
    Replaced getUINameFromCommand by GetMenuLabelForCommand
    
    Change-Id: Icd89fed4d9944653996a2218c6ed80af72cefe89
    Reviewed-on: https://gerrit.libreoffice.org/21464
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
    Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/framework/inc/uielement/toolbarsmenucontroller.hxx b/framework/inc/uielement/toolbarsmenucontroller.hxx
index f16a4e4..f8240df 100644
--- a/framework/inc/uielement/toolbarsmenucontroller.hxx
+++ b/framework/inc/uielement/toolbarsmenucontroller.hxx
@@ -85,20 +85,17 @@ namespace framework
         private:
             void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu >& rPopupMenu );
             css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > getLayoutManagerToolbars( const css::uno::Reference< css::frame::XLayoutManager >& rLayoutManager );
-            OUString getUINameFromCommand( const OUString& rCommandURL );
             css::uno::Reference< css::frame::XDispatch > getDispatchFromCommandURL( const OUString& rCommandURL );
             void addCommand( css::uno::Reference< css::awt::XPopupMenu >& rPopupMenu, const OUString& rCommandURL, const OUString& aLabel );
             bool isContextSensitiveToolbarNonVisible() { return m_bResetActive;}
 
             css::uno::Reference< css::uno::XComponentContext >        m_xContext;
             css::uno::Reference< css::container::XNameAccess >        m_xPersistentWindowState;
-            css::uno::Reference< css::container::XNameAccess >        m_xUICommandDescription;
             css::uno::Reference< css::ui::XUIConfigurationManager >   m_xModuleCfgMgr;
             css::uno::Reference< css::ui::XUIConfigurationManager >   m_xDocCfgMgr;
             OUString                                                  m_aModuleIdentifier;
             OUString                                                  m_aPropUIName;
             OUString                                                  m_aPropResourceURL;
-            bool                                                      m_bModuleIdentified;
             bool                                                      m_bResetActive;
             std::vector< OUString >                                   m_aCommandVector;
             IntlWrapper                                               m_aIntlWrapper;
diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx
index ec59424..0094ed6 100644
--- a/framework/source/uielement/toolbarsmenucontroller.cxx
+++ b/framework/source/uielement/toolbarsmenucontroller.cxx
@@ -51,6 +51,7 @@
 #include <rtl/ustrbuf.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <vcl/window.hxx>
+#include <vcl/commandinfoprovider.hxx>
 #include <svtools/menuoptions.hxx>
 #include <unotools/cmdoptions.hxx>
 #include <svtools/miscopt.hxx>
@@ -138,7 +139,6 @@ ToolbarsMenuController::ToolbarsMenuController( const css::uno::Reference< css::
     m_xContext( xContext ),
     m_aPropUIName( "UIName" ),
     m_aPropResourceURL( "ResourceURL" ),
-    m_bModuleIdentified( false ),
     m_bResetActive( false ),
     m_aIntlWrapper( xContext, Application::GetSettings().GetLanguageTag() )
 {
@@ -155,7 +155,7 @@ void ToolbarsMenuController::addCommand(
 
     OUString aLabel;
     if ( rLabel.isEmpty() )
-        aLabel = getUINameFromCommand( rCommandURL );
+        aLabel = vcl::CommandInfoProvider::Instance().GetMenuLabelForCommand( rCommandURL, m_xFrame );
     else
         aLabel = rLabel;
 
@@ -209,52 +209,6 @@ Reference< XDispatch > ToolbarsMenuController::getDispatchFromCommandURL( const
         return Reference< XDispatch >();
 }
 
-// private function
-OUString ToolbarsMenuController::getUINameFromCommand( const OUString& rCommandURL )
-{
-    OUString aLabel;
-
-    if ( !m_bModuleIdentified  )
-    {
-        try
-        {
-            Reference< XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext );
-            m_aModuleIdentifier = xModuleManager->identify( m_xFrame );
-            Reference< XNameAccess > xNameAccess = frame::theUICommandDescription::get( m_xContext );
-            xNameAccess->getByName( m_aModuleIdentifier ) >>= m_xUICommandDescription;
-        }
-        catch ( const Exception& )
-        {
-        }
-    }
-
-    if ( m_xUICommandDescription.is() )
-    {
-        try
-        {
-            Sequence< PropertyValue > aPropSeq;
-            OUString             aStr;
-            if ( m_xUICommandDescription->getByName( rCommandURL ) >>= aPropSeq )
-            {
-                for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
-                {
-                    if ( aPropSeq[i].Name == "Label" )
-                    {
-                        aPropSeq[i].Value >>= aStr;
-                        break;
-                    }
-                }
-            }
-            aLabel = aStr;
-        }
-        catch ( const Exception& )
-        {
-        }
-    }
-
-    return aLabel;
-}
-
 static void fillHashMap( const Sequence< Sequence< css::beans::PropertyValue > >& rSeqToolBars,
                          ToolbarHashMap& rHashMap )
 {


More information about the Libreoffice-commits mailing list