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

susobhang70 susobhang70 at gmail.com
Wed Jan 13 23:37:21 PST 2016


 sfx2/source/view/viewsh.cxx |   62 +-------------------------------------------
 1 file changed, 2 insertions(+), 60 deletions(-)

New commits:
commit 63551177041bd6f632f7e6cc8f6a87365236c658
Author: susobhang70 <susobhang70 at gmail.com>
Date:   Wed Jan 13 00:00:44 2016 +0530

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

diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 8e1fa34..56331df 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -55,6 +55,7 @@
 #include <comphelper/sequenceashashmap.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <vcl/settings.hxx>
+#include <vcl/commandinfoprovider.hxx>
 
 #include <sfx2/app.hxx>
 #include "view.hrc"
@@ -218,65 +219,6 @@ void SAL_CALL SfxClipboardChangeListener::changedContents( const datatransfer::c
     Application::PostUserEvent( LINK( nullptr, SfxClipboardChangeListener, AsyncExecuteHdl_Impl ), pInfo );
 }
 
-
-
-static OUString RetrieveLabelFromCommand(
-    const OUString& rCommandURL,
-    const css::uno::Reference< css::frame::XFrame >& rFrame )
-{
-    static css::uno::WeakReference< frame::XModuleManager2 > s_xModuleManager;
-    static css::uno::WeakReference< container::XNameAccess > s_xNameAccess;
-
-    OUString aLabel;
-    css::uno::Reference< css::frame::XModuleManager2 > xModuleManager( s_xModuleManager );
-    css::uno::Reference< css::container::XNameAccess > xNameAccess( s_xNameAccess );
-    css::uno::Reference< css::uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
-
-    try
-    {
-        if ( !xModuleManager.is() )
-        {
-            xModuleManager = css::frame::ModuleManager::create(xContext);
-            s_xModuleManager = xModuleManager;
-        }
-
-        OUString aModuleIdentifier = xModuleManager->identify( rFrame );
-
-        if ( !xNameAccess.is() )
-        {
-            xNameAccess.set( css::frame::theUICommandDescription::get(xContext),
-                             css::uno::UNO_QUERY_THROW );
-            s_xNameAccess = xNameAccess;
-        }
-
-        css::uno::Any a = xNameAccess->getByName( aModuleIdentifier );
-        css::uno::Reference< css::container::XNameAccess > xUICommands;
-        a >>= xUICommands;
-
-        OUString aStr;
-        css::uno::Sequence< css::beans::PropertyValue > aPropSeq;
-
-        a = xUICommands->getByName( rCommandURL );
-        if ( a >>= aPropSeq )
-        {
-            for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
-            {
-                if ( aPropSeq[i].Name == "Label" )
-                {
-                    aPropSeq[i].Value >>= aStr;
-                    break;
-                }
-            }
-            aLabel = aStr;
-        }
-    }
-    catch (const css::uno::Exception&)
-    {
-    }
-
-    return aLabel;
-}
-
 class SfxInPlaceClientList
 {
     typedef std::vector<SfxInPlaceClient*> DataType;
@@ -853,7 +795,7 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
                             uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() );
 
                             OUStringBuffer aBuffer( 60 );
-                            aBuffer.append( RetrieveLabelFromCommand(
+                            aBuffer.append( vcl::CommandInfoProvider::Instance().GetLabelForCommand(
                                 ".uno:PrintDefault",
                                 xFrame ));
                             aBuffer.append( " (" );


More information about the Libreoffice-commits mailing list