[Libreoffice-commits] .: 3 commits - basctl/source basic/source cui/source dbaccess/source embeddedobj/source filter/source forms/source framework/inc framework/source offapi/com offapi/UnoApi_offapi.mk sd/source sfx2/inc sfx2/source svtools/source svx/source ucb/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Sep 5 05:57:13 PDT 2012


 basctl/source/basicide/bastype2.cxx                    |   41 +++----
 basic/source/basmgr/vbahelper.cxx                      |   20 +--
 cui/source/customize/acccfg.cxx                        |    9 -
 cui/source/customize/cfg.cxx                           |   69 ++++++-------
 cui/source/customize/cfgutil.cxx                       |   15 --
 cui/source/customize/selector.cxx                      |   21 ----
 cui/source/dialogs/scriptdlg.cxx                       |   11 --
 cui/source/options/treeopt.cxx                         |   13 +-
 dbaccess/source/core/dataaccess/databasedocument.cxx   |    3 
 dbaccess/source/core/dataaccess/databasedocument.hxx   |    4 
 dbaccess/source/core/recovery/subcomponentrecovery.cxx |    7 -
 embeddedobj/source/commonembedding/embedobj.cxx        |    8 -
 embeddedobj/source/general/docholder.cxx               |    7 -
 filter/source/pdf/pdfexport.cxx                        |    8 -
 forms/source/helper/commanddescriptionprovider.cxx     |   22 ++--
 forms/source/helper/commandimageprovider.cxx           |    7 -
 forms/source/inc/commanddescriptionprovider.hxx        |    5 
 forms/source/solar/component/navbarcontrol.cxx         |    3 
 framework/inc/services/modulemanager.hxx               |   68 ++++++++----
 framework/source/lomenubar/FrameHelper.cxx             |    4 
 framework/source/services/modulemanager.cxx            |   89 +++++++++--------
 offapi/UnoApi_offapi.mk                                |    3 
 offapi/com/sun/star/frame/ModuleManager.idl            |   23 ----
 offapi/com/sun/star/frame/XModuleManager2.idl          |   57 ++++++++++
 sd/source/ui/view/ViewShellBase.cxx                    |    4 
 sfx2/inc/guisaveas.hxx                                 |    9 -
 sfx2/source/appl/appserv.cxx                           |    4 
 sfx2/source/appl/imagemgr.cxx                          |   12 --
 sfx2/source/appl/sfxhelp.cxx                           |   17 +--
 sfx2/source/dialog/dockwin.cxx                         |   12 --
 sfx2/source/dialog/mailmodel.cxx                       |   19 +--
 sfx2/source/dialog/recfloat.cxx                        |   39 ++-----
 sfx2/source/dialog/taskpane.cxx                        |   12 +-
 sfx2/source/dialog/templdlg.cxx                        |   31 ++---
 sfx2/source/doc/docfac.cxx                             |    8 -
 sfx2/source/doc/doctemplates.cxx                       |    8 -
 sfx2/source/doc/guisaveas.cxx                          |   28 -----
 sfx2/source/inc/templdgi.hxx                           |    4 
 sfx2/source/view/viewsh.cxx                            |   29 ++---
 svtools/source/misc/acceleratorexecute.cxx             |    7 -
 svtools/source/uno/contextmenuhelper.cxx               |   34 ++----
 svx/source/dialog/srchdlg.cxx                          |   27 ++---
 ucb/source/ucp/tdoc/tdoc_docmgr.cxx                    |   12 --
 ucb/source/ucp/tdoc/tdoc_docmgr.hxx                    |    4 
 44 files changed, 395 insertions(+), 442 deletions(-)

New commits:
commit 24391f605703bda1bcfa99ef06e5a73c6b52d267
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Sep 5 14:55:34 2012 +0200

    Some clean up of previous commit
    
    Change-Id: I14097acf09e9663af7d7abc5f0c9d481880ecc51

diff --git a/basic/source/basmgr/vbahelper.cxx b/basic/source/basmgr/vbahelper.cxx
index 6b07178..d5c2466 100644
--- a/basic/source/basmgr/vbahelper.cxx
+++ b/basic/source/basmgr/vbahelper.cxx
@@ -42,18 +42,10 @@ namespace {
 
 /** Create an instance of a module manager.
  */
-uno::Reference< frame::XModuleManager > lclCreateModuleManager()
+uno::Reference< frame::XModuleManager2 > lclCreateModuleManager()
 {
-    uno::Reference< frame::XModuleManager > xModuleManager;
-    try
-    {
-        uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext(), uno::UNO_QUERY_THROW );
-        xModuleManager.set( frame::ModuleManager::create(xContext), uno::UNO_QUERY );
-    }
-    catch(const uno::Exception& )
-    {
-    }
-    return xModuleManager;
+    uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext(), uno::UNO_QUERY_THROW );
+    return frame::ModuleManager::create(xContext);
 }
 
 // ----------------------------------------------------------------------------
@@ -76,7 +68,7 @@ DocumentsEnumeration::DocumentsEnumeration( const uno::Reference< frame::XModel
 {
     try
     {
-        uno::Reference< frame::XModuleManager > xModuleManager( lclCreateModuleManager(), uno::UNO_SET_THROW );
+        uno::Reference< frame::XModuleManager2 > xModuleManager( lclCreateModuleManager() );
         ::rtl::OUString aIdentifier = xModuleManager->identify( rxModel );
         uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
         uno::Reference< frame::XDesktop > xDesktop( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ), uno::UNO_QUERY_THROW );
@@ -213,7 +205,7 @@ void registerCurrentDirectory( const uno::Reference< frame::XModel >& rxModel, c
         ::osl::MutexGuard aGuard( rPool.maMutex );
         try
         {
-            uno::Reference< frame::XModuleManager > xModuleManager( lclCreateModuleManager(), uno::UNO_SET_THROW );
+            uno::Reference< frame::XModuleManager2 > xModuleManager( lclCreateModuleManager() );
             ::rtl::OUString aIdentifier = xModuleManager->identify( rxModel );
             if( !aIdentifier.isEmpty() )
                 rPool.maCurrDirs[ aIdentifier ] = rPath;
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx
index c12a91a..957eb38 100644
--- a/cui/source/customize/acccfg.cxx
+++ b/cui/source/customize/acccfg.cxx
@@ -864,12 +864,10 @@ void SfxAcceleratorConfigPage::InitAccCfg()
         }
 
         // identify module
-        css::uno::Reference< css::frame::XModuleManager > xModuleManager(
-                 css::frame::ModuleManager::create(comphelper::ComponentContext(m_xSMGR).getUNOContext()),
-                 css::uno::UNO_QUERY_THROW);
-        css::uno::Reference< css::container::XNameAccess > xModuleManagerCont(xModuleManager                                , css::uno::UNO_QUERY_THROW);
+        css::uno::Reference< css::frame::XModuleManager2 > xModuleManager(
+                 css::frame::ModuleManager::create(comphelper::ComponentContext(m_xSMGR).getUNOContext()));
         m_sModuleLongName = xModuleManager->identify(m_xFrame);
-        ::comphelper::SequenceAsHashMap lModuleProps(xModuleManagerCont->getByName(m_sModuleLongName));
+        ::comphelper::SequenceAsHashMap lModuleProps(xModuleManager->getByName(m_sModuleLongName));
         m_sModuleShortName = lModuleProps.getUnpackedValueOrDefault(MODULEPROP_SHORTNAME, ::rtl::OUString());
         m_sModuleUIName    = lModuleProps.getUnpackedValueOrDefault(MODULEPROP_UINAME   , ::rtl::OUString());
 
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 4340091..0a0e706 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -26,6 +26,9 @@
  *
  ************************************************************************/
 
+#include "sal/config.h"
+
+#include <cassert>
 #include <stdlib.h>
 #include <time.h>
 
@@ -447,41 +450,36 @@ OUString GetModuleName( const OUString& aModuleId )
     return ::rtl::OUString();
 }
 
-OUString GetUIModuleName( const OUString& aModuleId, const uno::Reference< css::frame::XModuleManager >& rModuleManager )
+OUString GetUIModuleName( const OUString& aModuleId, const uno::Reference< css::frame::XModuleManager2 >& rModuleManager )
 {
+    assert(rModuleManager.is());
+
     OUString aModuleUIName;
 
-    if ( rModuleManager.is() )
+    try
     {
-        uno::Reference< css::container::XNameAccess > xNameAccess( rModuleManager, uno::UNO_QUERY );
-        if ( xNameAccess.is() )
+        uno::Any a = rModuleManager->getByName( aModuleId );
+        uno::Sequence< beans::PropertyValue > aSeq;
+
+        if ( a >>= aSeq )
         {
-            try
+            for ( sal_Int32 i = 0; i < aSeq.getLength(); ++i )
             {
-                uno::Any a = xNameAccess->getByName( aModuleId );
-                uno::Sequence< beans::PropertyValue > aSeq;
-
-                if ( a >>= aSeq )
+                if ( aSeq[i].Name == "ooSetupFactoryUIName" )
                 {
-                    for ( sal_Int32 i = 0; i < aSeq.getLength(); ++i )
-                    {
-                        if ( aSeq[i].Name == "ooSetupFactoryUIName" )
-                        {
-                            aSeq[i].Value >>= aModuleUIName;
-                            break;
-                        }
-                    }
+                    aSeq[i].Value >>= aModuleUIName;
+                    break;
                 }
             }
-            catch ( uno::RuntimeException& )
-            {
-                throw;
-            }
-            catch ( uno::Exception& )
-            {
-            }
         }
     }
+    catch ( uno::RuntimeException& )
+    {
+        throw;
+    }
+    catch ( uno::Exception& )
+    {
+    }
 
     if ( aModuleUIName.isEmpty() )
         aModuleUIName = GetModuleName( aModuleId );
@@ -777,7 +775,7 @@ sal_Bool impl_showKeyConfigTabPage( const css::uno::Reference< css::frame::XFram
         css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR   = ::comphelper::getProcessServiceFactory();
         css::uno::Reference< css::uno::XComponentContext > xContext   = ::comphelper::getProcessComponentContext();
         css::uno::Reference< css::frame::XFramesSupplier >     xDesktop(xSMGR->createInstance(SERVICENAME_DESKTOP), css::uno::UNO_QUERY_THROW);
-        css::uno::Reference< css::frame::XModuleManager >      xMM     (css::frame::ModuleManager::create(xContext), css::uno::UNO_QUERY_THROW);
+        css::uno::Reference< css::frame::XModuleManager2 >      xMM     (css::frame::ModuleManager::create(xContext));
 
         if (xFrame.is())
         {
@@ -1672,8 +1670,8 @@ void SvxConfigPage::Reset( const SfxItemSet& )
         OUString aModuleId = GetFrameWithDefaultAndIdentify( m_xFrame );
 
         // replace %MODULENAME in the label with the correct module name
-        uno::Reference< css::frame::XModuleManager > xModuleManager(
-            css::frame::ModuleManager::create( xContext ), uno::UNO_QUERY_THROW);
+        uno::Reference< css::frame::XModuleManager2 > xModuleManager(
+            css::frame::ModuleManager::create( xContext ));
         OUString aModuleName = GetUIModuleName( aModuleId, xModuleManager );
 
         OUString title = aTopLevelSeparator.GetText();
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index 4b12b50..44cd36b 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -767,13 +767,11 @@ Image SfxConfigGroupListBox_Impl::GetImage(
             if ( xDocumentModel.is() )
             {
                 Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xCtx) );
-                Reference<container::XNameAccess> xModuleConfig(
-                    xModuleManager, UNO_QUERY_THROW );
                 // get the long name of the document:
                 ::rtl::OUString appModule( xModuleManager->identify(
                                     xDocumentModel ) );
                 Sequence<beans::PropertyValue> moduleDescr;
-                Any aAny = xModuleConfig->getByName(appModule);
+                Any aAny = xModuleManager->getByName(appModule);
                 if( sal_True != ( aAny >>= moduleDescr ) )
                 {
                     throw RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SFTreeListBox::Init: failed to get PropertyValue") ), Reference< XInterface >());
diff --git a/cui/source/customize/selector.cxx b/cui/source/customize/selector.cxx
index 67bc1bf..8ccafd2 100644
--- a/cui/source/customize/selector.cxx
+++ b/cui/source/customize/selector.cxx
@@ -567,13 +567,11 @@ Image SvxConfigGroupListBox_Impl::GetImage(
             if ( xDocumentModel.is() )
             {
                 Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xCtx) );
-                Reference<container::XNameAccess> xModuleConfig(
-                    xModuleManager, UNO_QUERY_THROW );
                 // get the long name of the document:
                 OUString appModule( xModuleManager->identify(
                                     xDocumentModel ) );
                 Sequence<beans::PropertyValue> moduleDescr;
-                Any aAny = xModuleConfig->getByName(appModule);
+                Any aAny = xModuleManager->getByName(appModule);
                 if( sal_True != ( aAny >>= moduleDescr ) )
                 {
                     throw RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("SFTreeListBox::Init: failed to get PropertyValue")), Reference< XInterface >());
diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx
index ebd3676..2c7b154 100644
--- a/cui/source/dialogs/scriptdlg.cxx
+++ b/cui/source/dialogs/scriptdlg.cxx
@@ -226,13 +226,11 @@ void SFTreeListBox::Init( const ::rtl::OUString& language  )
             {
                 Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xCtx) );
 
-                Reference<container::XNameAccess> xModuleConfig(
-                    xModuleManager, UNO_QUERY_THROW );
                 // get the long name of the document:
                 Sequence<beans::PropertyValue> moduleDescr;
                 try{
                     ::rtl::OUString appModule = xModuleManager->identify( xDocumentModel );
-                    xModuleConfig->getByName(appModule) >>= moduleDescr;
+                    xModuleManager->getByName(appModule) >>= moduleDescr;
                 } catch(const uno::Exception&)
                     {}
 
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 16bfa7f..c40bfda 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -1955,7 +1955,7 @@ rtl::OUString OfaTreeOptionsDialog::GetModuleIdentifier(
             xCurrentFrame = xDesktop->getCurrentFrame();
     }
 
-    if ( xCurrentFrame.is() && xModuleManager.is() )
+    if ( xCurrentFrame.is() )
     {
         try
         {
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
index e542994..e2c4c03 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -2079,7 +2079,7 @@ Reference< XTitle > ODatabaseDocument::impl_getTitleHelper_throw()
 uno::Reference< frame::XUntitledNumbers > ODatabaseDocument::impl_getUntitledHelper_throw(const uno::Reference< uno::XInterface >& _xComponent)
 {
     if ( !m_xModuleManager.is() )
-        m_xModuleManager.set( ModuleManager::create(m_pImpl->m_aContext.getUNOContext()), UNO_QUERY_THROW );
+        m_xModuleManager.set( ModuleManager::create(m_pImpl->m_aContext.getUNOContext()) );
 
     ::rtl::OUString sModuleId;
     try
diff --git a/dbaccess/source/core/dataaccess/databasedocument.hxx b/dbaccess/source/core/dataaccess/databasedocument.hxx
index 5ffbb18..2ff9ec6 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.hxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.hxx
@@ -34,7 +34,7 @@
 #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
 #include <com/sun/star/util/XCloseable.hpp>
 #include <com/sun/star/view/XPrintable.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
@@ -190,7 +190,7 @@ class ODatabaseDocument :public ModelDependentComponent             // ModelDepe
     ::com::sun::star::uno::WeakReference< ::com::sun::star::script::provider::XScriptProvider > m_xScriptProvider;
 
     /** @short  such module manager is used to classify new opened documents. */
-    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager >                 m_xModuleManager;
+    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >                 m_xModuleManager;
     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle >                         m_xTitleHelper;
     TNumberedController                                                                         m_aNumberedControllers;
 
diff --git a/forms/source/helper/commanddescriptionprovider.cxx b/forms/source/helper/commanddescriptionprovider.cxx
index 2cfe8e7..900e3ce 100644
--- a/forms/source/helper/commanddescriptionprovider.cxx
+++ b/forms/source/helper/commanddescriptionprovider.cxx
@@ -49,7 +49,7 @@ namespace frm
     using ::com::sun::star::frame::XModel;
     using ::com::sun::star::container::XNameAccess;
     using ::com::sun::star::frame::ModuleManager;
-    using ::com::sun::star::frame::XModuleManager;
+    using ::com::sun::star::frame::XModuleManager2;
     using ::com::sun::star::beans::PropertyValue;
     using ::com::sun::star::ui::UICommandDescription;
     /** === end UNO using === **/
@@ -89,7 +89,7 @@ namespace frm
 
         try
         {
-            Reference< XModuleManager > xModuleManager( ModuleManager::create(_rxContext), UNO_QUERY_THROW );
+            Reference< XModuleManager2 > xModuleManager( ModuleManager::create(_rxContext) );
             ::rtl::OUString sModuleID = xModuleManager->identify( _rxDocument );
 
             Reference< XNameAccess > xUICommandDescriptions( UICommandDescription::create(_rxContext) );
diff --git a/forms/source/helper/commandimageprovider.cxx b/forms/source/helper/commandimageprovider.cxx
index 7925985..049b0fc 100644
--- a/forms/source/helper/commandimageprovider.cxx
+++ b/forms/source/helper/commandimageprovider.cxx
@@ -60,7 +60,7 @@ namespace frm
     using ::com::sun::star::ui::XModuleUIConfigurationManagerSupplier;
     using ::com::sun::star::ui::ModuleUIConfigurationManagerSupplier;
     using ::com::sun::star::frame::ModuleManager;
-    using ::com::sun::star::frame::XModuleManager;
+    using ::com::sun::star::frame::XModuleManager2;
     using ::com::sun::star::graphic::XGraphic;
     /** === end UNO using === **/
     namespace ImageType = ::com::sun::star::ui::ImageType;
@@ -112,7 +112,7 @@ namespace frm
         // obtain the image manager or the module
         try
         {
-            Reference< XModuleManager > xModuleManager( ModuleManager::create(_rContext.getUNOContext()), UNO_QUERY_THROW );
+            Reference< XModuleManager2 > xModuleManager( ModuleManager::create(_rContext.getUNOContext()) );
             ::rtl::OUString sModuleID = xModuleManager->identify( _rxDocument );
 
             Reference< XModuleUIConfigurationManagerSupplier > xSuppUIConfig(
diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx
index 708a182..624c25f 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -1142,7 +1142,7 @@ void ViewShellBase::SetViewTabBar (const ::rtl::Reference<ViewTabBar>& rViewTabB
         Reference< XMultiServiceFactory > xServiceManager( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
         Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext(), UNO_QUERY_THROW );
 
-        Reference< XModuleManager > xModuleManager( ModuleManager::create(xContext), UNO_QUERY_THROW );
+        Reference< XModuleManager2 > xModuleManager( ModuleManager::create(xContext) );
         Reference< XInterface > xIfac( xFrame, UNO_QUERY_THROW );
 
         ::rtl::OUString aModuleIdentifier( xModuleManager->identify( xIfac ) );
diff --git a/sfx2/inc/guisaveas.hxx b/sfx2/inc/guisaveas.hxx
index 6491332..689c237 100644
--- a/sfx2/inc/guisaveas.hxx
+++ b/sfx2/inc/guisaveas.hxx
@@ -27,7 +27,7 @@
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/container/XContainerQuery.hpp>
 #include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
 
 #include <comphelper/sequenceashashmap.hxx>
 #include <sfx2/signaturestate.hxx>
@@ -50,15 +50,12 @@ private:
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xFilterCFG;
     ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerQuery > m_xFilterQuery;
-    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > m_xModuleManager;
-    ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xNamedModManager;
+    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager;
 
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > GetServiceFactory();
     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > GetFilterConfiguration();
     ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerQuery > GetFilterQuery();
-    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > GetModuleManager();
-    ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > GetNamedModuleManager();
-
+    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > GetModuleManager();
 
 public:
     SfxStoringHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory );
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index 4d9d216..6135f7b 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -935,7 +935,7 @@ namespace
             Reference < XFramesSupplier > xSupplier( i_rContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW );
             Reference < XIndexAccess > xContainer( xSupplier->getFrames(), UNO_QUERY_THROW );
 
-            Reference< XModuleManager > xCheck( ModuleManager::create(i_rContext.getUNOContext()), UNO_QUERY_THROW );
+            Reference< XModuleManager2 > xCheck( ModuleManager::create(i_rContext.getUNOContext()) );
 
             sal_Int32 nCount = xContainer->getCount();
             for ( sal_Int32 i=0; i<nCount; ++i )
diff --git a/sfx2/source/appl/imagemgr.cxx b/sfx2/source/appl/imagemgr.cxx
index 032e635..b8f9966 100644
--- a/sfx2/source/appl/imagemgr.cxx
+++ b/sfx2/source/appl/imagemgr.cxx
@@ -142,15 +142,13 @@ Image SAL_CALL GetImage(
         }
     }
 
-    static WeakReference< XModuleManager > m_xModuleManager;
+    static WeakReference< XModuleManager2 > m_xModuleManager;
 
-    Reference< XModuleManager > xModuleManager = m_xModuleManager;
+    Reference< XModuleManager2 > xModuleManager = m_xModuleManager;
 
     if ( !xModuleManager.is() )
     {
-        xModuleManager = Reference< XModuleManager >(
-                            ModuleManager::create(::comphelper::getProcessComponentContext()),
-                            UNO_QUERY );
+        xModuleManager = ModuleManager::create(::comphelper::getProcessComponentContext());
         m_xModuleManager = xModuleManager;
     }
 
diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 2175383..f2d86c2 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -34,7 +34,6 @@
 #include <com/sun/star/util/XURLTransformer.hpp>
 #include <com/sun/star/frame/XDispatch.hpp>
 #include <com/sun/star/frame/XDispatchProvider.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/frame/FrameSearchFlag.hpp>
 #include <toolkit/helper/vclunohelper.hxx>
@@ -415,13 +414,13 @@ SfxHelp::~SfxHelp()
 {
     ::rtl::OUString sIdentifier;
     Reference < XFrame > xCurrentFrame;
-    Reference < XModuleManager > xModuleManager( ModuleManager::create(::comphelper::getProcessComponentContext()), UNO_QUERY );
+    Reference < XModuleManager2 > xModuleManager( ModuleManager::create(::comphelper::getProcessComponentContext()) );
     Reference < XDesktop > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
         DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
     if ( xDesktop.is() )
         xCurrentFrame = xDesktop->getCurrentFrame();
 
-    if ( xCurrentFrame.is() && xModuleManager.is() )
+    if ( xCurrentFrame.is() )
     {
         try
         {
@@ -450,12 +449,10 @@ String SfxHelp::GetHelpModuleName_Impl()
     {
         try
         {
-            Reference < XModuleManager > xModuleManager(
-                ModuleManager::create(::comphelper::getProcessComponentContext()), UNO_QUERY );
+            Reference < XModuleManager2 > xModuleManager(
+                ModuleManager::create(::comphelper::getProcessComponentContext()) );
             Sequence< PropertyValue > lProps;
-            Reference< ::com::sun::star::container::XNameAccess > xCont( xModuleManager, UNO_QUERY);
-            if ( xCont.is() )
-                xCont->getByName( aModuleIdentifier ) >>= lProps;
+            xModuleManager->getByName( aModuleIdentifier ) >>= lProps;
             for ( sal_Int32 i = 0; i < lProps.getLength(); ++i )
             {
                 if ( lProps[i].Name == "ooSetupFactoryShortName" )
diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx
index 1bcf986..e10da5d 100644
--- a/sfx2/source/dialog/dockwin.cxx
+++ b/sfx2/source/dialog/dockwin.cxx
@@ -176,14 +176,12 @@ SfxDockingWrapper::SfxDockingWrapper( Window* pParentWnd ,
                           uno::UNO_QUERY );
             }
 
-            static uno::WeakReference< frame::XModuleManager >  m_xModuleManager;
+            static uno::WeakReference< frame::XModuleManager2 >  m_xModuleManager;
 
-            uno::Reference< frame::XModuleManager > xModuleManager( m_xModuleManager );
+            uno::Reference< frame::XModuleManager2 > xModuleManager( m_xModuleManager );
             if ( !xModuleManager.is() )
             {
-                xModuleManager = uno::Reference< frame::XModuleManager >(
-                                    frame::ModuleManager::create(comphelper::ComponentContext(xServiceManager).getUNOContext()),
-                                    uno::UNO_QUERY );
+                xModuleManager = frame::ModuleManager::create(comphelper::ComponentContext(xServiceManager).getUNOContext());
                 m_xModuleManager = xModuleManager;
             }
 
diff --git a/sfx2/source/dialog/mailmodel.cxx b/sfx2/source/dialog/mailmodel.cxx
index 9465fa0..813683b 100644
--- a/sfx2/source/dialog/mailmodel.cxx
+++ b/sfx2/source/dialog/mailmodel.cxx
@@ -307,7 +307,7 @@ SfxMailModel::SaveResult SfxMailModel::SaveDocumentAsFormat(
     if (!xContext.is())
         return eRet;
 
-    css::uno::Reference< css::frame::XModuleManager > xModuleManager( css::frame::ModuleManager::create(xContext), css::uno::UNO_QUERY_THROW );
+    css::uno::Reference< css::frame::XModuleManager2 > xModuleManager( css::frame::ModuleManager::create(xContext) );
 
     rtl::OUString aModule;
     try
@@ -428,18 +428,17 @@ SfxMailModel::SaveResult SfxMailModel::SaveDocumentAsFormat(
                 if ( !bHasLocation ||  aFilterName.isEmpty())
                 {
                     // Retrieve the user defined default filter
-                    css::uno::Reference< css::container::XNameAccess > xNameAccess( xModuleManager, css::uno::UNO_QUERY );
                     try
                     {
-                        ::comphelper::SequenceAsHashMap aFilterPropsHM( xNameAccess->getByName( aModule ) );
+                        ::comphelper::SequenceAsHashMap aFilterPropsHM( xModuleManager->getByName( aModule ) );
                         aFilterName = aFilterPropsHM.getUnpackedValueOrDefault(
                                                     ::rtl::OUString("ooSetupFactoryDefaultFilter"),
                                                     ::rtl::OUString() );
-                        css::uno::Reference< css::container::XNameAccess > xNameAccess2(
+                        css::uno::Reference< css::container::XNameAccess > xNameAccess(
                             xContainerQuery, css::uno::UNO_QUERY );
-                        if ( xNameAccess2.is() )
+                        if ( xNameAccess.is() )
                         {
-                            ::comphelper::SequenceAsHashMap aFilterPropsHM2( xNameAccess2->getByName( aFilterName ) );
+                            ::comphelper::SequenceAsHashMap aFilterPropsHM2( xNameAccess->getByName( aFilterName ) );
                             aTypeName = aFilterPropsHM2.getUnpackedValueOrDefault(
                                                         ::rtl::OUString("Type"),
                                                         ::rtl::OUString() );
diff --git a/sfx2/source/dialog/recfloat.cxx b/sfx2/source/dialog/recfloat.cxx
index fb30ecc..edb28dc 100644
--- a/sfx2/source/dialog/recfloat.cxx
+++ b/sfx2/source/dialog/recfloat.cxx
@@ -47,11 +47,11 @@ static rtl::OUString GetLabelFromCommandURL( const rtl::OUString& rCommandURL, c
     uno::Reference< container::XNameAccess > xUICommandLabels;
     uno::Reference< uno::XComponentContext > xContext;
     uno::Reference< container::XNameAccess > xUICommandDescription;
-    uno::Reference< ::com::sun::star::frame::XModuleManager > xModuleManager;
+    uno::Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager;
 
     static uno::WeakReference< uno::XComponentContext > xTmpContext;
     static uno::WeakReference< container::XNameAccess > xTmpNameAccess;
-    static uno::WeakReference< ::com::sun::star::frame::XModuleManager > xTmpModuleMgr;
+    static uno::WeakReference< ::com::sun::star::frame::XModuleManager2 > xTmpModuleMgr;
 
     xContext = xTmpContext;
     if ( !xContext.is() )
@@ -63,14 +63,14 @@ static rtl::OUString GetLabelFromCommandURL( const rtl::OUString& rCommandURL, c
     xUICommandDescription = xTmpNameAccess;
     if ( !xUICommandDescription.is() )
     {
-        xUICommandDescription = uno::Reference< container::XNameAccess >( ui::UICommandDescription::create(xContext) );
+        xUICommandDescription = ui::UICommandDescription::create(xContext);
         xTmpNameAccess = xUICommandDescription;
     }
 
     xModuleManager = xTmpModuleMgr;
     if ( !xModuleManager.is() )
     {
-        xModuleManager = uno::Reference< frame::XModuleManager >( frame::ModuleManager::create(xContext), uno::UNO_QUERY_THROW );
+        xModuleManager = frame::ModuleManager::create(xContext);
         xTmpModuleMgr = xModuleManager;
     }
 
@@ -85,12 +85,9 @@ static rtl::OUString GetLabelFromCommandURL( const rtl::OUString& rCommandURL, c
         {
         }
 
-        if ( xUICommandDescription.is() )
-        {
-            uno::Any a = xUICommandDescription->getByName( aModuleIdentifier );
-            uno::Reference< container::XNameAccess > xUICommands;
-            a >>= xUICommandLabels;
-        }
+        uno::Any a = xUICommandDescription->getByName( aModuleIdentifier );
+        uno::Reference< container::XNameAccess > xUICommands;
+        a >>= xUICommandLabels;
     }
     catch ( uno::Exception& )
     {
diff --git a/sfx2/source/dialog/taskpane.cxx b/sfx2/source/dialog/taskpane.cxx
index 2f8e904..fa73b75 100644
--- a/sfx2/source/dialog/taskpane.cxx
+++ b/sfx2/source/dialog/taskpane.cxx
@@ -72,13 +72,12 @@ namespace sfx2
     using ::com::sun::star::uno::Sequence;
     using ::com::sun::star::uno::Type;
     using ::com::sun::star::frame::ModuleManager;
-    using ::com::sun::star::frame::XModuleManager;
+    using ::com::sun::star::frame::XModuleManager2;
     using ::com::sun::star::container::XNameAccess;
     using ::com::sun::star::ui::XToolPanel;
     using ::com::sun::star::ui::XUIElementFactory;
     using ::com::sun::star::ui::XUIElement;
     using ::com::sun::star::awt::XWindow;
-    using ::com::sun::star::frame::XModuleManager;
     using ::com::sun::star::frame::XFrame;
     using ::com::sun::star::lang::XComponent;
     using ::com::sun::star::graphic::XGraphicProvider;
@@ -101,7 +100,7 @@ namespace sfx2
             ::rtl::OUStringBuffer aPathComposer;
             try
             {
-                const Reference< XNameAccess > xModuleAccess( ModuleManager::create(aContext.getUNOContext()), UNO_QUERY_THROW );
+                const Reference< XModuleManager2 > xModuleAccess( ModuleManager::create(aContext.getUNOContext()) );
                 const ::comphelper::NamedValueCollection aModuleProps( xModuleAccess->getByName( i_rModuleIdentifier ) );
 
                 const ::rtl::OUString sWindowStateRef( aModuleProps.getOrDefault( "ooSetupFactoryWindowStateConfigRef", ::rtl::OUString() ) );
@@ -129,7 +128,7 @@ namespace sfx2
             try
             {
                 const Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
-                const Reference< XModuleManager > xModuleManager( ModuleManager::create(xContext), UNO_QUERY_THROW );
+                const Reference< XModuleManager2 > xModuleManager( ModuleManager::create(xContext) );
                 sModuleName = xModuleManager->identify( i_rDocumentFrame );
             }
             catch( const Exception& )
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 64a242c..7e994dc 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -745,7 +745,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, Sfx
     pStyleSheetPool         ( NULL ),
     pTreeBox                ( NULL ),
     pCurObjShell            ( NULL ),
-    xModuleManager          ( frame::ModuleManager::create(::comphelper::getProcessComponentContext()), UNO_QUERY ),
+    xModuleManager          ( frame::ModuleManager::create(::comphelper::getProcessComponentContext()) ),
     m_pDeletionWatcher      ( NULL ),
 
     aFmtLb                  ( this, WB_BORDER | WB_TABSTOP | WB_SORT | WB_QUICK_SEARCH ),
@@ -1876,7 +1876,7 @@ void SfxCommonTemplateDialog_Impl::ActionSelect(sal_uInt16 nEntry)
 
 //-------------------------------------------------------------------------
 
-static rtl::OUString getModuleIdentifier( const Reference< XModuleManager >& i_xModMgr, SfxObjectShell* i_pObjSh )
+static rtl::OUString getModuleIdentifier( const Reference< XModuleManager2 >& i_xModMgr, SfxObjectShell* i_pObjSh )
 {
     OSL_ENSURE( i_xModMgr.is(), "getModuleIdentifier(): no XModuleManager" );
     OSL_ENSURE( i_pObjSh, "getModuleIdentifier(): no ObjectShell" );
@@ -1907,14 +1907,10 @@ sal_Int32 SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter( SfxObjectShell*
     sal_Int32 nFilter = -1;
 
     Sequence< PropertyValue > lProps;
-    Reference< ::com::sun::star::container::XNameAccess > xContainer( xModuleManager, UNO_QUERY );
-    if ( xContainer.is() )
-    {
-        ::comphelper::SequenceAsHashMap aFactoryProps(
-            xContainer->getByName( getModuleIdentifier( xModuleManager, i_pObjSh ) ) );
-        sal_Int32 nDefault = -1;
-        nFilter = aFactoryProps.getUnpackedValueOrDefault( DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter"), nDefault );
-    }
+    ::comphelper::SequenceAsHashMap aFactoryProps(
+        xModuleManager->getByName( getModuleIdentifier( xModuleManager, i_pObjSh ) ) );
+    sal_Int32 nDefault = -1;
+    nFilter = aFactoryProps.getUnpackedValueOrDefault( DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter"), nDefault );
 
     return nFilter;
 }
@@ -1924,14 +1920,10 @@ sal_Int32 SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter( SfxObjectShell*
 void SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter( SfxObjectShell* i_pObjSh, sal_Int32 i_nFilter )
 {
     OSL_ENSURE( i_pObjSh, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" );
-    Reference< ::com::sun::star::container::XNameReplace > xContainer( xModuleManager, UNO_QUERY );
-    if ( xContainer.is() )
-    {
-        Sequence< PropertyValue > lProps(1);
-        lProps[0].Name = DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter");
-        lProps[0].Value = makeAny( i_nFilter );;
-        xContainer->replaceByName( getModuleIdentifier( xModuleManager, i_pObjSh ), makeAny( lProps ) );
-    }
+    Sequence< PropertyValue > lProps(1);
+    lProps[0].Name = DEFINE_CONST_UNICODE("ooSetupFactoryStyleFilter");
+    lProps[0].Value = makeAny( i_nFilter );;
+    xModuleManager->replaceByName( getModuleIdentifier( xModuleManager, i_pObjSh ), makeAny( lProps ) );
 }
 
 //-------------------------------------------------------------------------
diff --git a/sfx2/source/doc/docfac.cxx b/sfx2/source/doc/docfac.cxx
index 135ef0b..94eea2b 100644
--- a/sfx2/source/doc/docfac.cxx
+++ b/sfx2/source/doc/docfac.cxx
@@ -386,9 +386,8 @@ String SfxObjectFactory::GetModuleName() const
     {
         css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
 
-        css::uno::Reference< css::container::XNameAccess > xModuleManager(
-            css::frame::ModuleManager::create(xContext),
-            css::uno::UNO_QUERY_THROW);
+        css::uno::Reference< css::frame::XModuleManager2 > xModuleManager(
+            css::frame::ModuleManager::create(xContext));
 
         ::rtl::OUString sDocService(GetDocumentServiceName());
         ::comphelper::SequenceAsHashMap aPropSet( xModuleManager->getByName(sDocService) );
diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index 1ea6af0..1218562 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -1844,9 +1844,8 @@ sal_Bool SfxDocTplService_Impl::storeTemplate( const OUString& rGroupName,
             throw uno::RuntimeException();
 
         // get document service name
-        uno::Reference< frame::XModuleManager > xModuleManager(
-            frame::ModuleManager::create(comphelper::ComponentContext(xFactory).getUNOContext()),
-            uno::UNO_QUERY_THROW );
+        uno::Reference< frame::XModuleManager2 > xModuleManager(
+            frame::ModuleManager::create(comphelper::ComponentContext(xFactory).getUNOContext()) );
         sDocServiceName = xModuleManager->identify( uno::Reference< uno::XInterface >( rStorable, uno::UNO_QUERY ) );
         if ( sDocServiceName.isEmpty() )
             throw uno::RuntimeException();
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 3af0dd3..133cf6c 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -416,7 +416,7 @@ const ::comphelper::SequenceAsHashMap& ModelData_Impl::GetModuleProps()
     if ( !m_pModulePropsHM )
     {
         uno::Sequence< beans::PropertyValue > aModuleProps;
-        m_pOwner->GetNamedModuleManager()->getByName( GetModuleName() ) >>= aModuleProps;
+        m_pOwner->GetModuleManager()->getByName( GetModuleName() ) >>= aModuleProps;
         if ( !aModuleProps.getLength() )
             throw uno::RuntimeException(); // TODO;
         m_pModulePropsHM = new ::comphelper::SequenceAsHashMap( aModuleProps );
@@ -1275,32 +1275,18 @@ uno::Reference< container::XContainerQuery > SfxStoringHelper::GetFilterQuery()
 }
 
 //-------------------------------------------------------------------------
-uno::Reference< ::com::sun::star::frame::XModuleManager > SfxStoringHelper::GetModuleManager()
+uno::Reference< ::com::sun::star::frame::XModuleManager2 > SfxStoringHelper::GetModuleManager()
 {
     if ( !m_xModuleManager.is() )
     {
-        m_xModuleManager = uno::Reference< ::com::sun::star::frame::XModuleManager >(
-            frame::ModuleManager::create(comphelper::ComponentContext(GetServiceFactory()).getUNOContext()),
-            uno::UNO_QUERY_THROW );
+        m_xModuleManager = frame::ModuleManager::create(
+            comphelper::ComponentContext(GetServiceFactory()).getUNOContext());
     }
 
     return m_xModuleManager;
 }
 
 //-------------------------------------------------------------------------
-uno::Reference< container::XNameAccess > SfxStoringHelper::GetNamedModuleManager()
-{
-    if ( !m_xNamedModManager.is() )
-    {
-        m_xNamedModManager = uno::Reference< container::XNameAccess >( GetModuleManager(), uno::UNO_QUERY );
-        if ( !m_xNamedModManager.is() )
-            throw uno::RuntimeException();
-    }
-
-    return m_xNamedModManager;
-}
-
-//-------------------------------------------------------------------------
 sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xModel,
                                             const ::rtl::OUString& aSlotName,
                                             uno::Sequence< beans::PropertyValue >& aArgsSequence,
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index a95c19e..0cc98f3 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -47,7 +47,7 @@ class SfxCommonTemplateDialog_Impl;
 class SfxTemplateDialogWrapper;
 class SfxDockingWindow;
 
-namespace com { namespace sun { namespace star { namespace frame { class XModuleManager; } } } }
+namespace com { namespace sun { namespace star { namespace frame { class XModuleManager2; } } } }
 
 // class DropListBox_Impl ------------------------------------------------
 
@@ -138,7 +138,7 @@ protected:
     SfxStyleSheetBasePool*      pStyleSheetPool;
     SvTreeListBox*              pTreeBox;
     SfxObjectShell*             pCurObjShell;
-    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager >
+    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >
                                 xModuleManager;
     DeletionWatcher*            m_pDeletionWatcher;
 
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 8ea9415..0a4a0de 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -224,11 +224,11 @@ static ::rtl::OUString RetrieveLabelFromCommand(
     const ::rtl::OUString& rCommandURL,
     const css::uno::Reference< css::frame::XFrame >& rFrame )
 {
-    static css::uno::WeakReference< frame::XModuleManager > s_xModuleManager;
+    static css::uno::WeakReference< frame::XModuleManager2 > s_xModuleManager;
     static css::uno::WeakReference< container::XNameAccess > s_xNameAccess;
 
     ::rtl::OUString aLabel;
-    css::uno::Reference< css::frame::XModuleManager > xModuleManager( s_xModuleManager );
+    css::uno::Reference< css::frame::XModuleManager2 > xModuleManager( s_xModuleManager );
     css::uno::Reference< css::container::XNameAccess > xNameAccess( s_xNameAccess );
     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR(
         ::comphelper::getProcessServiceFactory(), css::uno::UNO_QUERY_THROW);
@@ -239,8 +239,7 @@ static ::rtl::OUString RetrieveLabelFromCommand(
     {
         if ( !xModuleManager.is() )
         {
-            xModuleManager = css::uno::Reference< css::frame::XModuleManager >(
-                css::frame::ModuleManager::create(xContext), css::uno::UNO_QUERY_THROW);
+            xModuleManager = css::frame::ModuleManager::create(xContext);
             s_xModuleManager = xModuleManager;
         }
 
@@ -366,7 +365,7 @@ enum ETypeFamily
     {
         css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR         (::comphelper::getProcessServiceFactory()        , css::uno::UNO_QUERY_THROW);
         css::uno::Reference< css::uno::XComponentContext >     xContext      (::comphelper::getProcessComponentContext()        , css::uno::UNO_QUERY_THROW);
-        css::uno::Reference< css::frame::XModuleManager >      xModuleManager(css::frame::ModuleManager::create(xContext), css::uno::UNO_QUERY_THROW);
+        css::uno::Reference< css::frame::XModuleManager2 >      xModuleManager(css::frame::ModuleManager::create(xContext));
 
         ::rtl::OUString sModule = xModuleManager->identify(xFrame);
         ::rtl::OUString sType   ;
@@ -628,7 +627,7 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq )
             css::uno::Reference< css::frame::XFrame >         xFrame( pFrame->GetFrame().GetFrameInterface() );
             css::uno::Reference< css::frame::XModel >         xModel;
 
-            css::uno::Reference< css::frame::XModuleManager > xModuleManager( css::frame::ModuleManager::create(xContext), css::uno::UNO_QUERY_THROW );
+            css::uno::Reference< css::frame::XModuleManager2 > xModuleManager( css::frame::ModuleManager::create(xContext) );
 
             rtl::OUString aModule;
             try
diff --git a/svtools/source/misc/acceleratorexecute.cxx b/svtools/source/misc/acceleratorexecute.cxx
index 881383d..8351bf1 100644
--- a/svtools/source/misc/acceleratorexecute.cxx
+++ b/svtools/source/misc/acceleratorexecute.cxx
@@ -388,9 +388,8 @@ css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::st
 css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::st_openModuleConfig(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
                                                                                                    const css::uno::Reference< css::frame::XFrame >&              xFrame)
 {
-    css::uno::Reference< css::frame::XModuleManager > xModuleDetection(
-        css::frame::ModuleManager::create(comphelper::ComponentContext(xSMGR).getUNOContext()),
-        css::uno::UNO_QUERY_THROW);
+    css::uno::Reference< css::frame::XModuleManager2 > xModuleDetection(
+        css::frame::ModuleManager::create(comphelper::ComponentContext(xSMGR).getUNOContext()));
 
     ::rtl::OUString sModule;
     try
diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
index c0040cd..c3a9483 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
@@ -702,9 +702,8 @@ bool OfficeDocumentsManager::isBasicIDE(
         {
             try
             {
-                m_xModuleMgr = uno::Reference< frame::XModuleManager >(
-                            frame::ModuleManager::create(comphelper::ComponentContext(m_xSMgr).getUNOContext()),
-                            uno::UNO_QUERY );
+                m_xModuleMgr = frame::ModuleManager::create(
+                    comphelper::ComponentContext(m_xSMgr).getUNOContext());
             }
             catch ( uno::Exception const & )
             {
diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.hxx b/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
index 9b40fe3..ff1a07e 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
@@ -39,7 +39,7 @@
 #include "com/sun/star/document/XEventListener.hpp"
 #include "com/sun/star/embed/XStorage.hpp"
 #include "com/sun/star/frame/XModel.hpp"
-#include "com/sun/star/frame/XModuleManager.hpp"
+#include "com/sun/star/frame/XModuleManager2.hpp"
 #include "com/sun/star/util/XCloseListener.hpp"
 
 namespace tdoc_ucp {
@@ -197,7 +197,7 @@ namespace tdoc_ucp {
         com::sun::star::uno::Reference<
             com::sun::star::document::XEventBroadcaster >   m_xDocEvtNotifier;
         com::sun::star::uno::Reference<
-            com::sun::star::frame::XModuleManager >         m_xModuleMgr;
+            com::sun::star::frame::XModuleManager2 >        m_xModuleMgr;
         DocumentList                                        m_aDocs;
         OfficeDocumentsEventListener *                      m_pDocEventListener;
         com::sun::star::uno::Reference<
commit 1c7a54e3a14ad932e68b9281420e6c469e5dd2e5
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Sep 4 14:56:48 2012 +0200

    fdo#46808, Adapt frame::ModuleManager UNO service to new style
    
    Create a merged XModuleManager2 interface for this service to implement.
    Which is backwards-compatible, but does not require creating a new service.
    
    Explicitly document the XNameReplace interface in the IDL, which
    is already implemented by the service, since there is code currently using it.
    
    Change-Id: Ib46349174b1ce495c240031e93c9427fc33d9853

diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
index 4b8b1e4..725b721 100644
--- a/basctl/source/basicide/bastype2.cxx
+++ b/basctl/source/basicide/bastype2.cxx
@@ -37,7 +37,7 @@
 #include <svtools/imagemgr.hxx>
 #include <com/sun/star/script/XLibraryContainer.hpp>
 #include <com/sun/star/script/XLibraryContainerPassword.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/componentcontext.hxx>
 #include <sfx2/dispatch.hxx>
@@ -765,34 +765,31 @@ void TreeListBox::GetRootEntryBitmaps( const ScriptDocument& rDocument, Image& r
     if ( rDocument.isDocument() )
     {
         ::rtl::OUString sFactoryURL;
-        ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
-        Reference< ::com::sun::star::frame::XModuleManager > xModuleManager;
-        if ( aContext.createComponent( "com.sun.star.frame.ModuleManager", xModuleManager ) )
+        Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
+        Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xContext) );
+        try
         {
-            try
+            ::rtl::OUString sModule( xModuleManager->identify( rDocument.getDocument() ) );
+            Reference< container::XNameAccess > xModuleConfig( xModuleManager, UNO_QUERY );
+            if ( xModuleConfig.is() )
             {
-                ::rtl::OUString sModule( xModuleManager->identify( rDocument.getDocument() ) );
-                Reference< container::XNameAccess > xModuleConfig( xModuleManager, UNO_QUERY );
-                if ( xModuleConfig.is() )
+                Sequence< beans::PropertyValue > aModuleDescr;
+                xModuleConfig->getByName( sModule ) >>= aModuleDescr;
+                sal_Int32 nCount = aModuleDescr.getLength();
+                const beans::PropertyValue* pModuleDescr = aModuleDescr.getConstArray();
+                for ( sal_Int32 i = 0; i < nCount; ++i )
                 {
-                    Sequence< beans::PropertyValue > aModuleDescr;
-                    xModuleConfig->getByName( sModule ) >>= aModuleDescr;
-                    sal_Int32 nCount = aModuleDescr.getLength();
-                    const beans::PropertyValue* pModuleDescr = aModuleDescr.getConstArray();
-                    for ( sal_Int32 i = 0; i < nCount; ++i )
+                    if ( pModuleDescr[ i ].Name == "ooSetupFactoryEmptyDocumentURL" )
                     {
-                        if ( pModuleDescr[ i ].Name == "ooSetupFactoryEmptyDocumentURL" )
-                        {
-                            pModuleDescr[ i ].Value >>= sFactoryURL;
-                            break;
-                        }
+                        pModuleDescr[ i ].Value >>= sFactoryURL;
+                        break;
                     }
                 }
             }
-            catch( const Exception& )
-            {
-                DBG_UNHANDLED_EXCEPTION();
-            }
+        }
+        catch( const Exception& )
+        {
+            DBG_UNHANDLED_EXCEPTION();
         }
 
         if ( !sFactoryURL.isEmpty() )
diff --git a/basic/source/basmgr/vbahelper.cxx b/basic/source/basmgr/vbahelper.cxx
index 57796db..6b07178 100644
--- a/basic/source/basmgr/vbahelper.cxx
+++ b/basic/source/basmgr/vbahelper.cxx
@@ -25,7 +25,7 @@
 #include <com/sun/star/container/XEnumeration.hpp>
 #include <com/sun/star/frame/XDesktop.hpp>
 #include <com/sun/star/frame/XModel2.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <comphelper/processfactory.hxx>
 #include <cppuhelper/implbase1.hxx>
@@ -47,8 +47,8 @@ uno::Reference< frame::XModuleManager > lclCreateModuleManager()
     uno::Reference< frame::XModuleManager > xModuleManager;
     try
     {
-        uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
-        xModuleManager.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ) ) ), uno::UNO_QUERY );
+        uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext(), uno::UNO_QUERY_THROW );
+        xModuleManager.set( frame::ModuleManager::create(xContext), uno::UNO_QUERY );
     }
     catch(const uno::Exception& )
     {
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx
index 84e0eea..c12a91a 100644
--- a/cui/source/customize/acccfg.cxx
+++ b/cui/source/customize/acccfg.cxx
@@ -55,7 +55,7 @@
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/form/XReset.hpp>
 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/ui/UICommandDescription.hpp>
 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
@@ -92,7 +92,6 @@ using namespace com::sun::star;
 static ::rtl::OUString SERVICE_STORAGEFACTORY           (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.StorageFactory"                        ));
 static ::rtl::OUString SERVICE_UICONFIGMGR              (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.UIConfigurationManager"              ));
 static ::rtl::OUString SERVICE_DESKTOP                  (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"                               ));
-static ::rtl::OUString SERVICE_MODULEMANAGER            (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.ModuleManager"                  ));
 static ::rtl::OUString SERVICE_GLOBALACCCFG             (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.GlobalAcceleratorConfiguration"      ));
 
 static ::rtl::OUString MODULEPROP_SHORTNAME             (RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryShortName"                                  ));
@@ -865,7 +864,9 @@ void SfxAcceleratorConfigPage::InitAccCfg()
         }
 
         // identify module
-        css::uno::Reference< css::frame::XModuleManager > xModuleManager    (m_xSMGR->createInstance(SERVICE_MODULEMANAGER), css::uno::UNO_QUERY_THROW);
+        css::uno::Reference< css::frame::XModuleManager > xModuleManager(
+                 css::frame::ModuleManager::create(comphelper::ComponentContext(m_xSMGR).getUNOContext()),
+                 css::uno::UNO_QUERY_THROW);
         css::uno::Reference< css::container::XNameAccess > xModuleManagerCont(xModuleManager                                , css::uno::UNO_QUERY_THROW);
         m_sModuleLongName = xModuleManager->identify(m_xFrame);
         ::comphelper::SequenceAsHashMap lModuleProps(xModuleManagerCont->getByName(m_sModuleLongName));
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index e3b896a..4340091 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -69,6 +69,7 @@
 #include <com/sun/star/ui/ItemType.hpp>
 #include <com/sun/star/ui/ItemStyle.hpp>
 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XController.hpp>
 #include <com/sun/star/frame/XDesktop.hpp>
 #include <com/sun/star/ui/UICommandDescription.hpp>
@@ -768,17 +769,17 @@ SfxTabPage *CreateSvxEventConfigPage( Window *pParent, const SfxItemSet& rSet )
 
 sal_Bool impl_showKeyConfigTabPage( const css::uno::Reference< css::frame::XFrame >& xFrame )
 {
-    static ::rtl::OUString SERVICENAME_MODULEMANAGER ("com.sun.star.frame.ModuleManager" );
     static ::rtl::OUString SERVICENAME_DESKTOP       ("com.sun.star.frame.Desktop"            );
     static ::rtl::OUString MODULEID_STARTMODULE      ("com.sun.star.frame.StartModule"        );
 
     try
     {
         css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR   = ::comphelper::getProcessServiceFactory();
+        css::uno::Reference< css::uno::XComponentContext > xContext   = ::comphelper::getProcessComponentContext();
         css::uno::Reference< css::frame::XFramesSupplier >     xDesktop(xSMGR->createInstance(SERVICENAME_DESKTOP), css::uno::UNO_QUERY_THROW);
-        css::uno::Reference< css::frame::XModuleManager >     xMM     (xSMGR->createInstance(SERVICENAME_MODULEMANAGER), css::uno::UNO_QUERY_THROW);
+        css::uno::Reference< css::frame::XModuleManager >      xMM     (css::frame::ModuleManager::create(xContext), css::uno::UNO_QUERY_THROW);
 
-        if (xMM.is() && xFrame.is())
+        if (xFrame.is())
         {
             ::rtl::OUString sModuleId = xMM->identify(xFrame);
             if (
@@ -1664,15 +1665,15 @@ void SvxConfigPage::Reset( const SfxItemSet& )
 
         uno::Reference< lang::XMultiServiceFactory > xServiceManager(
             ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+        uno::Reference< uno::XComponentContext > xContext(
+            ::comphelper::getProcessComponentContext(), uno::UNO_QUERY_THROW );
 
         m_xFrame = GetFrame();
         OUString aModuleId = GetFrameWithDefaultAndIdentify( m_xFrame );
 
         // replace %MODULENAME in the label with the correct module name
         uno::Reference< css::frame::XModuleManager > xModuleManager(
-            xServiceManager->createInstance(
-                OUString( "com.sun.star.frame.ModuleManager"  ) ),
-            uno::UNO_QUERY_THROW );
+            css::frame::ModuleManager::create( xContext ), uno::UNO_QUERY_THROW);
         OUString aModuleName = GetUIModuleName( aModuleId, xModuleManager );
 
         OUString title = aTopLevelSeparator.GetText();
@@ -1687,7 +1688,7 @@ void SvxConfigPage::Reset( const SfxItemSet& )
         }
 
         uno::Reference< css::ui::XModuleUIConfigurationManagerSupplier >
-            xModuleCfgSupplier( css::ui::ModuleUIConfigurationManagerSupplier::create(comphelper::ComponentContext(xServiceManager).getUNOContext()) );
+            xModuleCfgSupplier( css::ui::ModuleUIConfigurationManagerSupplier::create(xContext) );
 
         // Set up data for module specific menus
         SaveInData* pModuleData = NULL;
@@ -1914,10 +1915,8 @@ void SvxConfigPage::Reset( const SfxItemSet& )
             return sModuleID;
         }
 
-        uno::Reference< css::frame::XModuleManager > xModuleManager(
-            xServiceManager->createInstance(
-                OUString( "com.sun.star.frame.ModuleManager"  ) ),
-            uno::UNO_QUERY_THROW );
+        uno::Reference< css::frame::XModuleManager2 > xModuleManager(
+                css::frame::ModuleManager::create( comphelper::ComponentContext(xServiceManager).getUNOContext() ) );
 
         try
         {
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index 86be792..4b12b50 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -38,7 +38,7 @@
 
 #include <com/sun/star/script/browse/XBrowseNodeFactory.hpp>
 #include <com/sun/star/script/browse/BrowseNodeFactoryViewTypes.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XDesktop.hpp>
 #include <com/sun/star/container/XEnumerationAccess.hpp>
 #include <com/sun/star/container/XEnumeration.hpp>
@@ -766,14 +766,7 @@ Image SfxConfigGroupListBox_Impl::GetImage(
             Reference<XInterface> xDocumentModel = getDocumentModel(xCtx, nodeName );
             if ( xDocumentModel.is() )
             {
-                Reference< ::com::sun::star::frame::XModuleManager >
-                    xModuleManager(
-                        xCtx->getServiceManager()
-                            ->createInstanceWithContext(
-                                ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("" // xxx todo
-                                      "com.sun.star.frame.ModuleManager") ),
-                                xCtx ),
-                            UNO_QUERY_THROW );
+                Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xCtx) );
                 Reference<container::XNameAccess> xModuleConfig(
                     xModuleManager, UNO_QUERY_THROW );
                 // get the long name of the document:
diff --git a/cui/source/customize/selector.cxx b/cui/source/customize/selector.cxx
index 1da7e33..67bc1bf 100644
--- a/cui/source/customize/selector.cxx
+++ b/cui/source/customize/selector.cxx
@@ -53,7 +53,7 @@
 #include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
 #include <com/sun/star/script/browse/XBrowseNodeFactory.hpp>
 #include <com/sun/star/script/browse/BrowseNodeFactoryViewTypes.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XDesktop.hpp>
 #include <com/sun/star/container/XEnumerationAccess.hpp>
 #include <com/sun/star/container/XEnumeration.hpp>
@@ -417,12 +417,7 @@ void SvxConfigGroupListBox_Impl::Init()
         Reference< frame::XDispatchInformationProvider > xDIP(
             m_xFrame, UNO_QUERY );
 
-        Reference< ::com::sun::star::frame::XModuleManager >
-            xModuleManager( xMCF->createInstanceWithContext(
-                OUString(RTL_CONSTASCII_USTRINGPARAM(
-                    "com.sun.star.frame.ModuleManager" )),
-                xContext ),
-            UNO_QUERY );
+        Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xContext) );
 
         OUString aModuleId;
         try{
@@ -571,13 +566,7 @@ Image SvxConfigGroupListBox_Impl::GetImage(
             Reference<XInterface> xDocumentModel = getDocumentModel(xCtx, nodeName );
             if ( xDocumentModel.is() )
             {
-                Reference< ::com::sun::star::frame::XModuleManager >
-                    xModuleManager(
-                        xCtx->getServiceManager()
-                            ->createInstanceWithContext(
-                                OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.ModuleManager")),
-                                xCtx ),
-                            UNO_QUERY_THROW );
+                Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xCtx) );
                 Reference<container::XNameAccess> xModuleConfig(
                     xModuleManager, UNO_QUERY_THROW );
                 // get the long name of the document:
diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx
index 3a71808..ebd3676 100644
--- a/cui/source/dialogs/scriptdlg.cxx
+++ b/cui/source/dialogs/scriptdlg.cxx
@@ -49,7 +49,7 @@
 #include <com/sun/star/script/provider/ScriptErrorRaisedException.hpp>
 #include <com/sun/star/script/provider/ScriptExceptionRaisedException.hpp>
 #include <com/sun/star/script/provider/ScriptFrameworkErrorType.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/script/XInvocation.hpp>
 #include <com/sun/star/document/XEmbeddedScripts.hpp>
 
@@ -224,10 +224,7 @@ void SFTreeListBox::Init( const ::rtl::OUString& language  )
 
             if ( xDocumentModel.is() )
             {
-                Reference< ::com::sun::star::frame::XModuleManager >
-                    xModuleManager( xCtx->getServiceManager()->createInstanceWithContext(
-                        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.ModuleManager") ), xCtx ),
-                                    UNO_QUERY_THROW );
+                Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xCtx) );
 
                 Reference<container::XNameAccess> xModuleConfig(
                     xModuleManager, UNO_QUERY_THROW );
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 9100312..16bfa7f 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -64,9 +64,10 @@
 #include <com/sun/star/awt/XControl.hpp>
 #include <com/sun/star/awt/PosSize.hpp>
 #include <com/sun/star/frame/XDesktop.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/loader/CannotActivateFactoryException.hpp>
 #include <com/sun/star/util/XMacroExpander.hpp>
+#include <comphelper/componentcontext.hxx>
 #include <comphelper/processfactory.hxx>
 #include <editeng/optitems.hxx>
 #include <editeng/unolingu.hxx>
@@ -1492,8 +1493,7 @@ rtl::OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame )
 {
     rtl::OUString sIdentifier;
     Reference < XFrame > xCurrentFrame( _xFrame );
-    Reference < XModuleManager > xModuleManager( ::comphelper::getProcessServiceFactory()->createInstance(
-        DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY );
+    Reference < XModuleManager2 > xModuleManager( ModuleManager::create(::comphelper::getProcessComponentContext()) );
     if ( !xCurrentFrame.is() )
     {
         Reference< XDesktop > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
@@ -1502,7 +1502,7 @@ rtl::OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame )
             xCurrentFrame = xDesktop->getCurrentFrame();
     }
 
-    if ( xCurrentFrame.is() && xModuleManager.is() )
+    if ( xCurrentFrame.is() )
     {
         try
         {
@@ -1945,8 +1945,7 @@ rtl::OUString OfaTreeOptionsDialog::GetModuleIdentifier(
 {
     rtl::OUString sModule;
     Reference < XFrame > xCurrentFrame( rFrame );
-    Reference < XModuleManager > xModuleManager( xMFac->createInstance(
-        C2U("com.sun.star.frame.ModuleManager") ), UNO_QUERY );
+    Reference < XModuleManager2 > xModuleManager( ModuleManager::create(comphelper::ComponentContext(xMFac).getUNOContext()) );
 
     if ( !xCurrentFrame.is() )
     {
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
index 305379c..e542994 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -38,6 +38,7 @@
 #include <com/sun/star/embed/XEmbedPersist.hpp>
 #include <com/sun/star/embed/XTransactedObject.hpp>
 #include <com/sun/star/embed/XTransactionBroadcaster.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/io/XActiveDataSource.hpp>
 #include <com/sun/star/io/XSeekable.hpp>
 #include <com/sun/star/io/XOutputStream.hpp>
@@ -2078,7 +2079,7 @@ Reference< XTitle > ODatabaseDocument::impl_getTitleHelper_throw()
 uno::Reference< frame::XUntitledNumbers > ODatabaseDocument::impl_getUntitledHelper_throw(const uno::Reference< uno::XInterface >& _xComponent)
 {
     if ( !m_xModuleManager.is() )
-        m_xModuleManager.set( m_pImpl->m_aContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
+        m_xModuleManager.set( ModuleManager::create(m_pImpl->m_aContext.getUNOContext()), UNO_QUERY_THROW );
 
     ::rtl::OUString sModuleId;
     try
diff --git a/dbaccess/source/core/recovery/subcomponentrecovery.cxx b/dbaccess/source/core/recovery/subcomponentrecovery.cxx
index 0c962b6..d9129d1 100644
--- a/dbaccess/source/core/recovery/subcomponentrecovery.cxx
+++ b/dbaccess/source/core/recovery/subcomponentrecovery.cxx
@@ -26,7 +26,7 @@
 #include "settingsimport.hxx"
 
 #include <com/sun/star/embed/ElementModes.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/document/XStorageBasedDocument.hpp>
 #include <com/sun/star/ucb/XCommandProcessor.hpp>
 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
@@ -61,7 +61,8 @@ namespace dbaccess
     using ::com::sun::star::embed::XStorage;
     using ::com::sun::star::sdb::application::XDatabaseDocumentUI;
     using ::com::sun::star::beans::Pair;
-    using ::com::sun::star::frame::XModuleManager;
+    using ::com::sun::star::frame::ModuleManager;
+    using ::com::sun::star::frame::XModuleManager2;
     using ::com::sun::star::lang::XComponent;
     using ::com::sun::star::frame::XModel;
     using ::com::sun::star::frame::XController;
@@ -480,7 +481,7 @@ namespace dbaccess
         m_aCompDesc.sName = aComponentIdentity.Second;
 
         // what the controller didn't give us is the information whether this is in edit mode or not ...
-        Reference< XModuleManager > xModuleManager( m_rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
+        Reference< XModuleManager2 > xModuleManager( ModuleManager::create(m_rContext.getUNOContext()) );
         const ::rtl::OUString sModuleIdentifier = xModuleManager->identify( m_xComponent );
 
         switch ( m_eType )
diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx
index 337b01b..06ad663 100644
--- a/embeddedobj/source/commonembedding/embedobj.cxx
+++ b/embeddedobj/source/commonembedding/embedobj.cxx
@@ -42,10 +42,11 @@
 #include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/lang/DisposedException.hpp>
 
 #include <com/sun/star/embed/EmbedMisc.hpp>
+#include <comphelper/componentcontext.hxx>
 
 #include <rtl/logfile.hxx>
 
@@ -322,10 +323,7 @@ void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState )
                         uno::Reference< embed::XComponentSupplier > xCompSupl( m_xClientSite, uno::UNO_QUERY_THROW );
                         uno::Reference< uno::XInterface > xContDoc( xCompSupl->getComponent(), uno::UNO_QUERY_THROW );
 
-                        uno::Reference< frame::XModuleManager > xManager(
-                            m_xFactory->createInstance(
-                                    ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ) ) ),
-                            uno::UNO_QUERY_THROW );
+                        uno::Reference< frame::XModuleManager2 > xManager( frame::ModuleManager::create(comphelper::ComponentContext(m_xFactory).getUNOContext()) );
 
                         aModuleName = xManager->identify( xContDoc );
                     }
diff --git a/embeddedobj/source/general/docholder.cxx b/embeddedobj/source/general/docholder.cxx
index 0531439..fd073ed 100644
--- a/embeddedobj/source/general/docholder.cxx
+++ b/embeddedobj/source/general/docholder.cxx
@@ -60,7 +60,7 @@
 #include <com/sun/star/embed/XInplaceClient.hpp>
 #include <com/sun/star/frame/XLayoutManager.hpp>
 #include <com/sun/star/frame/XMenuBarMergingAcceptor.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/ui/XDockingAreaAcceptor.hpp>
 #include <com/sun/star/ui/XUIElementSettings.hpp>
 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
@@ -576,10 +576,7 @@ uno::Reference< container::XIndexAccess > DocumentHolder::RetrieveOwnMenu_Impl()
     if ( !xResult.is() )
     {
         // no internal document configuration, use the one from the module
-        uno::Reference< ::com::sun::star::frame::XModuleManager > xModuleMan(
-                m_xFactory->createInstance(
-                    ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ) ) ),
-                    uno::UNO_QUERY_THROW );
+        uno::Reference< frame::XModuleManager2 > xModuleMan( frame::ModuleManager::create(comphelper::ComponentContext(m_xFactory).getUNOContext()) );
         ::rtl::OUString aModuleIdent =
             xModuleMan->identify( uno::Reference< uno::XInterface >( m_xComponent, uno::UNO_QUERY ) );
 
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index 58e026f..5b493ec 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -64,7 +64,7 @@
 #include "com/sun/star/awt/XDevice.hpp"
 #include "com/sun/star/util/MeasureUnit.hpp"
 #include "com/sun/star/frame/XModel.hpp"
-#include "com/sun/star/frame/XModuleManager.hpp"
+#include "com/sun/star/frame/ModuleManager.hpp"
 #include "com/sun/star/frame/XStorable.hpp"
 #include "com/sun/star/frame/XController.hpp"
 #include "com/sun/star/document/XDocumentProperties.hpp"
@@ -317,10 +317,8 @@ static OUString getMimetypeForDocument( const Reference< XMultiServiceFactory >&
     OUString aDocMimetype;
         // get document service name
     Reference< com::sun::star::frame::XStorable > xStore( xDoc, UNO_QUERY );
-    Reference< frame::XModuleManager > xModuleManager(
-        xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ) ) ),
-                               uno::UNO_QUERY );
-    if( xModuleManager.is() && xStore.is() )
+    Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(comphelper::getComponentContext( xFactory )) );
+    if( xStore.is() )
     {
         OUString aDocServiceName = xModuleManager->identify( Reference< XInterface >( xStore, uno::UNO_QUERY ) );
         if ( !aDocServiceName.isEmpty() )
diff --git a/forms/source/helper/commanddescriptionprovider.cxx b/forms/source/helper/commanddescriptionprovider.cxx
index b0c1b4e..2cfe8e7 100644
--- a/forms/source/helper/commanddescriptionprovider.cxx
+++ b/forms/source/helper/commanddescriptionprovider.cxx
@@ -21,7 +21,7 @@
 #include "commanddescriptionprovider.hxx"
 
 #include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/ui/UICommandDescription.hpp>
 
@@ -45,8 +45,10 @@ namespace frm
     using ::com::sun::star::uno::makeAny;
     using ::com::sun::star::uno::Sequence;
     using ::com::sun::star::uno::Type;
+    using ::com::sun::star::uno::XComponentContext;
     using ::com::sun::star::frame::XModel;
     using ::com::sun::star::container::XNameAccess;
+    using ::com::sun::star::frame::ModuleManager;
     using ::com::sun::star::frame::XModuleManager;
     using ::com::sun::star::beans::PropertyValue;
     using ::com::sun::star::ui::UICommandDescription;
@@ -58,9 +60,9 @@ namespace frm
     class DefaultCommandDescriptionProvider : public ICommandDescriptionProvider
     {
     public:
-        DefaultCommandDescriptionProvider( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
+        DefaultCommandDescriptionProvider( const Reference<XComponentContext>& _rxContext, const Reference< XModel >& _rxDocument )
         {
-            impl_init_nothrow( _rContext, _rxDocument );
+            impl_init_nothrow( _rxContext, _rxDocument );
         }
 
         ~DefaultCommandDescriptionProvider()
@@ -71,7 +73,7 @@ namespace frm
         virtual ::rtl::OUString getCommandDescription( const ::rtl::OUString& _rCommandURL ) const;
 
     private:
-        void    impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument );
+        void    impl_init_nothrow( const Reference<XComponentContext>& _rxContext, const Reference< XModel >& _rxDocument );
 
     private:
         Reference< XNameAccess >    m_xCommandAccess;
@@ -79,7 +81,7 @@ namespace frm
 
 
     //--------------------------------------------------------------------
-    void DefaultCommandDescriptionProvider::impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
+    void DefaultCommandDescriptionProvider::impl_init_nothrow( const Reference<XComponentContext>& _rxContext, const Reference< XModel >& _rxDocument )
     {
         OSL_ENSURE( _rxDocument.is(), "DefaultCommandDescriptionProvider::impl_init_nothrow: no document => no command descriptions!" );
         if ( !_rxDocument.is() )
@@ -87,10 +89,10 @@ namespace frm
 
         try
         {
-            Reference< XModuleManager > xModuleManager( _rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
+            Reference< XModuleManager > xModuleManager( ModuleManager::create(_rxContext), UNO_QUERY_THROW );
             ::rtl::OUString sModuleID = xModuleManager->identify( _rxDocument );
 
-            Reference< XNameAccess > xUICommandDescriptions( UICommandDescription::create(_rContext.getUNOContext()) );
+            Reference< XNameAccess > xUICommandDescriptions( UICommandDescription::create(_rxContext) );
             m_xCommandAccess.set( xUICommandDescriptions->getByName( sModuleID ), UNO_QUERY_THROW );
         }
         catch( const Exception& )
@@ -120,9 +122,9 @@ namespace frm
 
     //--------------------------------------------------------------------
     PCommandDescriptionProvider createDocumentCommandDescriptionProvider(
-        const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
+        const Reference<XComponentContext>& _rxContext, const Reference< XModel >& _rxDocument )
     {
-        PCommandDescriptionProvider pDescriptionProvider( new DefaultCommandDescriptionProvider( _rContext, _rxDocument ) );
+        PCommandDescriptionProvider pDescriptionProvider( new DefaultCommandDescriptionProvider( _rxContext, _rxDocument ) );
         return pDescriptionProvider;
     }
 
diff --git a/forms/source/helper/commandimageprovider.cxx b/forms/source/helper/commandimageprovider.cxx
index 23d2023..7925985 100644
--- a/forms/source/helper/commandimageprovider.cxx
+++ b/forms/source/helper/commandimageprovider.cxx
@@ -31,7 +31,7 @@
 #include <com/sun/star/ui/XImageManager.hpp>
 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/ui/ImageType.hpp>
 
 #include <tools/diagnose_ex.h>
@@ -59,6 +59,7 @@ namespace frm
     using ::com::sun::star::ui::XUIConfigurationManager;
     using ::com::sun::star::ui::XModuleUIConfigurationManagerSupplier;
     using ::com::sun::star::ui::ModuleUIConfigurationManagerSupplier;
+    using ::com::sun::star::frame::ModuleManager;
     using ::com::sun::star::frame::XModuleManager;
     using ::com::sun::star::graphic::XGraphic;
     /** === end UNO using === **/
@@ -111,7 +112,7 @@ namespace frm
         // obtain the image manager or the module
         try
         {
-            Reference< XModuleManager > xModuleManager( _rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
+            Reference< XModuleManager > xModuleManager( ModuleManager::create(_rContext.getUNOContext()), UNO_QUERY_THROW );
             ::rtl::OUString sModuleID = xModuleManager->identify( _rxDocument );
 
             Reference< XModuleUIConfigurationManagerSupplier > xSuppUIConfig(
diff --git a/forms/source/inc/commanddescriptionprovider.hxx b/forms/source/inc/commanddescriptionprovider.hxx
index f319c5e..fa8d014 100644
--- a/forms/source/inc/commanddescriptionprovider.hxx
+++ b/forms/source/inc/commanddescriptionprovider.hxx
@@ -21,8 +21,7 @@
 #define COMMANDDESCRIPTIONPROVIDER_HXX
 
 #include <com/sun/star/frame/XModel.hpp>
-
-#include <comphelper/componentcontext.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
 
 #include <boost/shared_ptr.hpp>
 
@@ -49,7 +48,7 @@ namespace frm
     //=====================================================================
     PCommandDescriptionProvider
         createDocumentCommandDescriptionProvider(
-            const ::comphelper::ComponentContext& _rContext,
+            const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocument
         );
 
diff --git a/forms/source/solar/component/navbarcontrol.cxx b/forms/source/solar/component/navbarcontrol.cxx
index fca8e7b..b2ad7ff 100644
--- a/forms/source/solar/component/navbarcontrol.cxx
+++ b/forms/source/solar/component/navbarcontrol.cxx
@@ -42,6 +42,7 @@
 #include <com/sun/star/awt/XControlModel.hpp>
 #include <com/sun/star/graphic/XGraphic.hpp>
 
+#include <comphelper/componentcontext.hxx>
 #include <tools/debug.hxx>
 #include <tools/diagnose_ex.h>
 #include <vcl/svapp.hxx>
@@ -284,7 +285,7 @@ namespace frm
             _pParentWindow,
             lcl_getWinBits_nothrow( _rxModel ),
             createDocumentCommandImageProvider( _rxORB, xContextDocument ),
-            createDocumentCommandDescriptionProvider( _rxORB, xContextDocument )
+            createDocumentCommandDescriptionProvider( comphelper::ComponentContext(_rxORB).getUNOContext(), xContextDocument )
         );
 
         // some knittings
diff --git a/framework/inc/services/modulemanager.hxx b/framework/inc/services/modulemanager.hxx
index d50b0da..eb1b9f4 100644
--- a/framework/inc/services/modulemanager.hxx
+++ b/framework/inc/services/modulemanager.hxx
@@ -27,10 +27,10 @@
 #include <boost/noncopyable.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
 #include <com/sun/star/container/XNameReplace.hpp>
 #include <com/sun/star/container/XContainerQuery.hpp>
-#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/implbase3.hxx>
 
 namespace com { namespace sun { namespace star { namespace lang {
     class XSingleServiceFactory;
@@ -49,9 +49,10 @@ namespace framework
     implements the service com.sun.star.frame.ModuleManager
  */
 class ModuleManager:
-    public cppu::WeakImplHelper4<
-        css::lang::XServiceInfo, css::frame::XModuleManager,
-        css::container::XNameReplace, css::container::XContainerQuery >,
+    public cppu::WeakImplHelper3<
+        css::lang::XServiceInfo,
+        css::frame::XModuleManager2,
+        css::container::XContainerQuery >,
     private ThreadHelpBase, private boost::noncopyable
 {
     //___________________________________________
diff --git a/framework/source/lomenubar/FrameHelper.cxx b/framework/source/lomenubar/FrameHelper.cxx
index b617404..e8fd68f 100644
--- a/framework/source/lomenubar/FrameHelper.cxx
+++ b/framework/source/lomenubar/FrameHelper.cxx
@@ -49,7 +49,7 @@
 #include <com/sun/star/frame/XDispatchProvider.hpp>
 #include <com/sun/star/frame/XLayoutManager.hpp>
 #include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XPopupMenuController.hpp>
 #include <com/sun/star/frame/FrameAction.hpp>
 #include <com/sun/star/frame/FrameActionEvent.hpp>
@@ -268,7 +268,7 @@ FrameHelper::FrameHelper(const Reference< XMultiServiceFactory >&  rServiceManag
     , m_pDispatchRegistry(new framework::lomenubar::DispatchRegistry(m_xStatusListener))
     , m_xMSF(rServiceManager)
     , m_xTrans(util::URLTransformer::create(comphelper::ComponentContext(m_xMSF).getUNOContext()))
-    , m_xMM(m_xMSF->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.ModuleManager"))),UNO_QUERY)
+    , m_xMM(frame::ModuleManager(comphelper::ComponentContext(m_xMSF).getUNOContext()),UNO_QUERY)
     , m_xPCF(m_xMSF->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.PopupMenuControllerFactory"))), UNO_QUERY)
     , m_xFrame(xFrame)
     , m_xdp(xFrame, UNO_QUERY)
diff --git a/framework/source/services/modulemanager.cxx b/framework/source/services/modulemanager.cxx
index d5d4522..04158c0 100644
--- a/framework/source/services/modulemanager.cxx
+++ b/framework/source/services/modulemanager.cxx
@@ -180,7 +180,7 @@ void SAL_CALL ModuleManager::replaceByName(const ::rtl::OUString& sName ,
     {
         throw css::lang::IllegalArgumentException(
                 ::rtl::OUString("No properties given to replace part of module."),
-                static_cast< css::container::XNameAccess* >(this),
+                static_cast< cppu::OWeakObject * >(this),
                 2);
     }
 
@@ -207,7 +207,7 @@ void SAL_CALL ModuleManager::replaceByName(const ::rtl::OUString& sName ,
     {
         throw css::uno::RuntimeException(
                 ::rtl::OUString("Was not able to get write access to the requested module entry inside configuration."),
-                static_cast< css::container::XNameAccess* >(this));
+                static_cast< cppu::OWeakObject * >(this));
     }
 
     ::comphelper::SequenceAsHashMap::const_iterator pProp;
@@ -239,7 +239,7 @@ css::uno::Any SAL_CALL ModuleManager::getByName(const ::rtl::OUString& sName)
     {
         throw css::uno::RuntimeException(
                 ::rtl::OUString("Was not able to get write access to the requested module entry inside configuration."),
-                static_cast< css::container::XNameAccess* >(this));
+                static_cast< cppu::OWeakObject * >(this));
     }
 
     // convert it to seq< PropertyValue >
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 291699a..8a56c3b 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -134,6 +134,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/frame,\
 	DispatchRecorderSupplier \
 	DocumentTemplates \
 	MediaTypeDetectionHelper \
+	ModuleManager \
 ))
 $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/graphic,\
 	GraphicObject \
@@ -811,7 +812,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/frame,\
 	FramesContainer \
 	GlobalEventBroadcaster \
 	LayoutManager \
-	ModuleManager \
 	PopupMenuController \
 	PopupMenuControllerFactory \
 	ProtocolHandler \
@@ -2538,6 +2538,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/frame,\
 	XModel2 \
 	XModule \
 	XModuleManager \
+	XModuleManager2 \
 	XNotifyingDispatch \
 	XPopupMenuController \
 	XRecordableDispatch \
diff --git a/offapi/com/sun/star/frame/ModuleManager.idl b/offapi/com/sun/star/frame/ModuleManager.idl
index 53ccdc6..b2db408 100644
--- a/offapi/com/sun/star/frame/ModuleManager.idl
+++ b/offapi/com/sun/star/frame/ModuleManager.idl
@@ -29,8 +29,7 @@
 #ifndef __com_sun_star_frame_ModuleManager_idl__
 #define __com_sun_star_frame_ModuleManager_idl__
 
-#include <com/sun/star/frame/XModuleManager.idl>
-#include <com/sun/star/container/XNameAccess.idl>
+#include <com/sun/star/frame/XModuleManager2.idl>
 
 
 module com { module sun { module star { module frame {
@@ -45,25 +44,7 @@ module com { module sun { module star { module frame {
     @since OOo 2.0
  */
 
-service ModuleManager
-{
-    /** provides functions to identify office modules.
-     */
-    interface XModuleManager;
-
-    /** provides read access to the configuration of office modules.
-
-        <p>
-        Every module is referenced by an unique service name
-        (which is used inside configuration as set node name too)
-        and is further represented by a sequence of elements of type
-        <type scope="com::sun::star::beans">PropertyValue</type>.
-        A list of properties can be gotten from the configuration template
-        org.openoffice.Setup/Factory.
-        </p>
-     */
-    interface ::com::sun::star::container::XNameAccess;
-};
+service ModuleManager : XModuleManager2;
 
 }; }; }; };
 
diff --git a/offapi/com/sun/star/frame/XModuleManager2.idl b/offapi/com/sun/star/frame/XModuleManager2.idl
new file mode 100644
index 0000000..277c0e6
--- /dev/null
+++ b/offapi/com/sun/star/frame/XModuleManager2.idl
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef __com_sun_star_frame_XModuleManager2_idl__
+#define __com_sun_star_frame_XModuleManager2_idl__
+
+#include <com/sun/star/frame/XModuleManager.idl>
+#include <com/sun/star/container/XNameReplace.idl>
+
+
+module com {  module sun {  module star {  module frame {
+
+/**
+  This interface provides a merged single interface for the ModuleManager
+  service to implement
+*/
+interface XModuleManager2
+{
+    /** provides functions to identify office modules.
+     */
+    interface XModuleManager;
+
+    /** provides read access to the configuration of office modules.
+
+        <p>
+        Every module is referenced by an unique service name
+        (which is used inside configuration as set node name too)
+        and is further represented by a sequence of elements of type
+        <type scope="com::sun::star::beans">PropertyValue</type>.
+        A list of properties can be gotten from the configuration template
+        org.openoffice.Setup/Factory.
+        </p>
+     */
+    interface ::com::sun::star::container::XNameReplace;
+};
+
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx
index 748d2a6..708a182 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -29,7 +29,7 @@
 #include <comphelper/processfactory.hxx>
 
 #include <com/sun/star/frame/UnknownModuleException.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/ui/UICommandDescription.hpp>
@@ -1142,7 +1142,7 @@ void ViewShellBase::SetViewTabBar (const ::rtl::Reference<ViewTabBar>& rViewTabB
         Reference< XMultiServiceFactory > xServiceManager( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
         Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext(), UNO_QUERY_THROW );
 
-        Reference< XModuleManager > xModuleManager( xServiceManager->createInstance( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
+        Reference< XModuleManager > xModuleManager( ModuleManager::create(xContext), UNO_QUERY_THROW );
         Reference< XInterface > xIfac( xFrame, UNO_QUERY_THROW );
 
         ::rtl::OUString aModuleIdentifier( xModuleManager->identify( xIfac ) );
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index c99fe7a..4d9d216 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -75,7 +75,7 @@
 #include <cppuhelper/exc_hlp.hxx>
 
 #include <com/sun/star/script/provider/XScriptProviderFactory.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 
 #include "frmload.hxx"
@@ -935,7 +935,7 @@ namespace
             Reference < XFramesSupplier > xSupplier( i_rContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW );
             Reference < XIndexAccess > xContainer( xSupplier->getFrames(), UNO_QUERY_THROW );
 
-            Reference< XModuleManager > xCheck( i_rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
+            Reference< XModuleManager > xCheck( ModuleManager::create(i_rContext.getUNOContext()), UNO_QUERY_THROW );
 
             sal_Int32 nCount = xContainer->getCount();
             for ( sal_Int32 i=0; i<nCount; ++i )
diff --git a/sfx2/source/appl/imagemgr.cxx b/sfx2/source/appl/imagemgr.cxx
index 216e81b..032e635 100644
--- a/sfx2/source/appl/imagemgr.cxx
+++ b/sfx2/source/appl/imagemgr.cxx
@@ -20,7 +20,7 @@
 #include "sfx2/imagemgr.hxx"
 #include <com/sun/star/frame/XController.hpp>
 #include <com/sun/star/ui/XImageManager.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/ImageType.hpp>
 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
@@ -149,9 +149,7 @@ Image SAL_CALL GetImage(
     if ( !xModuleManager.is() )
     {
         xModuleManager = Reference< XModuleManager >(
-                            ::comphelper::getProcessServiceFactory()->createInstance(
-                                rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
-                                    "com.sun.star.frame.ModuleManager" ))),
+                            ModuleManager::create(::comphelper::getProcessComponentContext()),
                             UNO_QUERY );
         m_xModuleManager = xModuleManager;
     }
diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 8f728c5..2175383 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -38,7 +38,7 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/frame/FrameSearchFlag.hpp>
 #include <toolkit/helper/vclunohelper.hxx>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/system/SystemShellExecute.hpp>
 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
 #include <unotools/configmgr.hxx>
@@ -415,8 +415,7 @@ SfxHelp::~SfxHelp()
 {
     ::rtl::OUString sIdentifier;
     Reference < XFrame > xCurrentFrame;
-    Reference < XModuleManager > xModuleManager( ::comphelper::getProcessServiceFactory()->createInstance(
-        DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY );
+    Reference < XModuleManager > xModuleManager( ModuleManager::create(::comphelper::getProcessComponentContext()), UNO_QUERY );
     Reference < XDesktop > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
         DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
     if ( xDesktop.is() )
@@ -452,8 +451,7 @@ String SfxHelp::GetHelpModuleName_Impl()
         try
         {
             Reference < XModuleManager > xModuleManager(
-                ::comphelper::getProcessServiceFactory()->createInstance(
-                    DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY );
+                ModuleManager::create(::comphelper::getProcessComponentContext()), UNO_QUERY );
             Sequence< PropertyValue > lProps;
             Reference< ::com::sun::star::container::XNameAccess > xCont( xModuleManager, UNO_QUERY);
             if ( xCont.is() )
diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx
index 6d77417..1bcf986 100644
--- a/sfx2/source/dialog/dockwin.cxx
+++ b/sfx2/source/dialog/dockwin.cxx
@@ -25,6 +25,7 @@
 #include <vcl/timer.hxx>
 #include <rtl/instance.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
+#include <comphelper/componentcontext.hxx>
 #include <comphelper/processfactory.hxx>
 
 #include <sfx2/dockwin.hxx>
@@ -43,7 +44,7 @@
 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
 #include <com/sun/star/awt/XWindow.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 
 #define MAX_TOGGLEAREA_WIDTH        20
@@ -181,8 +182,7 @@ SfxDockingWrapper::SfxDockingWrapper( Window* pParentWnd ,
             if ( !xModuleManager.is() )
             {
                 xModuleManager = uno::Reference< frame::XModuleManager >(
-                                    xServiceManager->createInstance(
-                                        rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ))),
+                                    frame::ModuleManager::create(comphelper::ComponentContext(xServiceManager).getUNOContext()),
                                     uno::UNO_QUERY );
                 m_xModuleManager = xModuleManager;
             }
diff --git a/sfx2/source/dialog/mailmodel.cxx b/sfx2/source/dialog/mailmodel.cxx
index b66cf8f..9465fa0 100644
--- a/sfx2/source/dialog/mailmodel.cxx
+++ b/sfx2/source/dialog/mailmodel.cxx
@@ -33,7 +33,7 @@
 #include <com/sun/star/embed/XTransactedObject.hpp>
 #include <com/sun/star/container/XContainerQuery.hpp>
 #include <com/sun/star/util/XModifiable.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/security/CertificateValidity.hpp>
@@ -303,13 +303,11 @@ SfxMailModel::SaveResult SfxMailModel::SaveDocumentAsFormat(
     bool        bSendAsPDF = (rType.equalsAsciiL( PDF_DOCUMENT_TYPE, PDF_DOCUMENT_TYPE_LEN ));
 
     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR  = ::comphelper::getProcessServiceFactory();
-    if (!xSMGR.is())
+    css::uno::Reference< css::uno::XComponentContext > xContext  = ::comphelper::getProcessComponentContext();
+    if (!xContext.is())
         return eRet;
 
-    const rtl::OUString aModuleManager( "com.sun.star.frame.ModuleManager" );
-    css::uno::Reference< css::frame::XModuleManager > xModuleManager( xSMGR->createInstance( aModuleManager ), css::uno::UNO_QUERY_THROW );
-    if ( !xModuleManager.is() )
-        return eRet;
+    css::uno::Reference< css::frame::XModuleManager > xModuleManager( css::frame::ModuleManager::create(xContext), css::uno::UNO_QUERY_THROW );
 
     rtl::OUString aModule;
     try
diff --git a/sfx2/source/dialog/recfloat.cxx b/sfx2/source/dialog/recfloat.cxx
index a43b9fb..fb30ecc 100644
--- a/sfx2/source/dialog/recfloat.cxx
+++ b/sfx2/source/dialog/recfloat.cxx
@@ -18,7 +18,7 @@
  */
 
 #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/ui/UICommandDescription.hpp>
@@ -26,7 +26,6 @@
 #include <svl/eitem.hxx>
 #include <svtools/generictoolboxcontroller.hxx>
 #include <vcl/msgbox.hxx>
-#include <comphelper/componentcontext.hxx>
 #include <comphelper/processfactory.hxx>
 
 #include "recfloat.hxx"
@@ -46,37 +45,32 @@ static rtl::OUString GetLabelFromCommandURL( const rtl::OUString& rCommandURL, c
     rtl::OUString aLabel;
     rtl::OUString aModuleIdentifier;
     uno::Reference< container::XNameAccess > xUICommandLabels;
-    uno::Reference< lang::XMultiServiceFactory > xServiceManager;
+    uno::Reference< uno::XComponentContext > xContext;
     uno::Reference< container::XNameAccess > xUICommandDescription;
     uno::Reference< ::com::sun::star::frame::XModuleManager > xModuleManager;
 
-    static uno::WeakReference< lang::XMultiServiceFactory > xTmpServiceManager;
-    static uno::WeakReference< container::XNameAccess >     xTmpNameAccess;
+    static uno::WeakReference< uno::XComponentContext > xTmpContext;
+    static uno::WeakReference< container::XNameAccess > xTmpNameAccess;
     static uno::WeakReference< ::com::sun::star::frame::XModuleManager > xTmpModuleMgr;
 
-    xServiceManager = xTmpServiceManager;
-    if ( !xServiceManager.is() )
+    xContext = xTmpContext;
+    if ( !xContext.is() )
     {
-        xServiceManager = ::comphelper::getProcessServiceFactory();
-        xTmpServiceManager = xServiceManager;
+        xContext = ::comphelper::getProcessComponentContext();
+        xTmpContext = xContext;
     }
 
     xUICommandDescription = xTmpNameAccess;
     if ( !xUICommandDescription.is() )
     {
-        xUICommandDescription = uno::Reference< container::XNameAccess >(
-                                    ui::UICommandDescription::create(comphelper::ComponentContext(xServiceManager).getUNOContext()) );
+        xUICommandDescription = uno::Reference< container::XNameAccess >( ui::UICommandDescription::create(xContext) );
         xTmpNameAccess = xUICommandDescription;
     }
 
     xModuleManager = xTmpModuleMgr;
     if ( !xModuleManager.is() )
     {
-        xModuleManager = uno::Reference< ::com::sun::star::frame::XModuleManager >(
-            xServiceManager->createInstance(
-                rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
-                    "com.sun.star.frame.ModuleManager" ))),
-            uno::UNO_QUERY_THROW );
+        xModuleManager = uno::Reference< frame::XModuleManager >( frame::ModuleManager::create(xContext), uno::UNO_QUERY_THROW );
         xTmpModuleMgr = xModuleManager;
     }
 
diff --git a/sfx2/source/dialog/taskpane.cxx b/sfx2/source/dialog/taskpane.cxx
index a33e5a4..2f8e904 100644
--- a/sfx2/source/dialog/taskpane.cxx
+++ b/sfx2/source/dialog/taskpane.cxx
@@ -27,7 +27,7 @@
 #include "sfxlocal.hrc"
 #include "helpid.hrc"
 
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/ui/XToolPanel.hpp>
 #include <com/sun/star/ui/XUIElementFactory.hpp>
@@ -71,6 +71,7 @@ namespace sfx2
     using ::com::sun::star::uno::makeAny;
     using ::com::sun::star::uno::Sequence;
     using ::com::sun::star::uno::Type;
+    using ::com::sun::star::frame::ModuleManager;
     using ::com::sun::star::frame::XModuleManager;
     using ::com::sun::star::container::XNameAccess;
     using ::com::sun::star::ui::XToolPanel;
@@ -100,7 +101,7 @@ namespace sfx2
             ::rtl::OUStringBuffer aPathComposer;
             try
             {
-                const Reference< XNameAccess > xModuleAccess( aContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
+                const Reference< XNameAccess > xModuleAccess( ModuleManager::create(aContext.getUNOContext()), UNO_QUERY_THROW );
                 const ::comphelper::NamedValueCollection aModuleProps( xModuleAccess->getByName( i_rModuleIdentifier ) );
 

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list