summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorsusobhang70 <susobhang70@gmail.com>2016-01-13 00:00:44 +0530
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-01-14 07:36:55 +0000
commit63551177041bd6f632f7e6cc8f6a87365236c658 (patch)
treeb78658dbcebc1bc8100d32c559ea9de868bbb047 /sfx2
parentd6318214908b088f8820033f62c47fbc4821c3a1 (diff)
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@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/view/viewsh.cxx62
1 files changed, 2 insertions, 60 deletions
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 <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( " (" );