From 63551177041bd6f632f7e6cc8f6a87365236c658 Mon Sep 17 00:00:00 2001 From: susobhang70 Date: Wed, 13 Jan 2016 00:00:44 +0530 Subject: tdf#95845 Use CommandInfoProvider to receive UNO command labels Change-Id: I04227652cc1b94129514ddb61ce66d7d9b365807 Reviewed-on: https://gerrit.libreoffice.org/21402 Reviewed-by: Samuel Mehrbrodt Tested-by: Samuel Mehrbrodt --- sfx2/source/view/viewsh.cxx | 62 ++------------------------------------------- 1 file changed, 2 insertions(+), 60 deletions(-) (limited to 'sfx2/source/view/viewsh.cxx') diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 8e1fa3407409..56331df570db 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -55,6 +55,7 @@ #include #include #include +#include #include #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 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( " (" ); -- cgit