From 7a464263cc5c2ca2b7128734ff4860e02d662818 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 23 Aug 2012 18:06:05 +0200 Subject: fdo#46808, Adapt UICommandDescription UNO service to new style Change-Id: Ibca112904f137ff981ae9be3e5bd56aa11aec352 --- desktop/source/app/app.cxx | 74 +++++++++++++++++----------------- desktop/source/migration/migration.cxx | 10 ++--- 2 files changed, 40 insertions(+), 44 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index e107c48b1efe..1ed400fd236b 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -67,6 +67,7 @@ #include #include #include +#include #include #include @@ -2090,8 +2091,8 @@ void Desktop::PreloadModuleData( const CommandLineArgs& rArgs ) void Desktop::PreloadConfigurationData() { Reference< XMultiServiceFactory > rFactory = ::comphelper::getProcessServiceFactory(); - Reference< XNameAccess > xNameAccess( rFactory->createInstance( - rtl::OUString( "com.sun.star.frame.UICommandDescription" )), UNO_QUERY ); + Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + Reference< XNameAccess > xNameAccess( css::ui::UICommandDescription::create(xContext) ); rtl::OUString aWriterDoc( "com.sun.star.text.TextDocument" ); rtl::OUString aCalcDoc( "com.sun.star.sheet.SpreadsheetDocument" ); @@ -2099,47 +2100,44 @@ void Desktop::PreloadConfigurationData() rtl::OUString aImpressDoc( "com.sun.star.presentation.PresentationDocument" ); // preload commands configuration - if ( xNameAccess.is() ) - { - Any a; - Reference< XNameAccess > xCmdAccess; + Any a; + Reference< XNameAccess > xCmdAccess; - try - { - a = xNameAccess->getByName( aWriterDoc ); - a >>= xCmdAccess; - if ( xCmdAccess.is() ) - { - xCmdAccess->getByName( rtl::OUString( ".uno:BasicShapes" )); - xCmdAccess->getByName( rtl::OUString( ".uno:EditGlossary" )); - } - } - catch ( const ::com::sun::star::uno::Exception& ) + try + { + a = xNameAccess->getByName( aWriterDoc ); + a >>= xCmdAccess; + if ( xCmdAccess.is() ) { + xCmdAccess->getByName( rtl::OUString( ".uno:BasicShapes" )); + xCmdAccess->getByName( rtl::OUString( ".uno:EditGlossary" )); } + } + catch ( const ::com::sun::star::uno::Exception& ) + { + } - try - { - a = xNameAccess->getByName( aCalcDoc ); - a >>= xCmdAccess; - if ( xCmdAccess.is() ) - xCmdAccess->getByName( rtl::OUString( ".uno:InsertObjectStarMath" )); - } - catch ( const ::com::sun::star::uno::Exception& ) - { - } + try + { + a = xNameAccess->getByName( aCalcDoc ); + a >>= xCmdAccess; + if ( xCmdAccess.is() ) + xCmdAccess->getByName( rtl::OUString( ".uno:InsertObjectStarMath" )); + } + catch ( const ::com::sun::star::uno::Exception& ) + { + } - try - { - // draw and impress share the same configuration file (DrawImpressCommands.xcu) - a = xNameAccess->getByName( aDrawDoc ); - a >>= xCmdAccess; - if ( xCmdAccess.is() ) - xCmdAccess->getByName( rtl::OUString( ".uno:Polygon" )); - } - catch ( const ::com::sun::star::uno::Exception& ) - { - } + try + { + // draw and impress share the same configuration file (DrawImpressCommands.xcu) + a = xNameAccess->getByName( aDrawDoc ); + a >>= xCmdAccess; + if ( xCmdAccess.is() ) + xCmdAccess->getByName( rtl::OUString( ".uno:Polygon" )); + } + catch ( const ::com::sun::star::uno::Exception& ) + { } // preload window state configuration diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx index 87702bade412..8424f0975400 100644 --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -91,12 +92,9 @@ static const char XDG_CONFIG_PART[] = "/.config"; ::rtl::OUString sLabel; uno::Reference< container::XNameAccess > xUICommands; - uno::Reference< container::XNameAccess > xNameAccess( ::comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.UICommandDescription")) ), uno::UNO_QUERY ); - if ( xNameAccess.is() ) - { - uno::Any a = xNameAccess->getByName( sModuleIdentifier ); - a >>= xUICommands; - } + uno::Reference< container::XNameAccess > xNameAccess( ui::UICommandDescription::create(::comphelper::getProcessComponentContext()) ); + uno::Any a = xNameAccess->getByName( sModuleIdentifier ); + a >>= xUICommands; if (xUICommands.is()) { if ( !sCommand.isEmpty() ) -- cgit