[Libreoffice-commits] .: 3 commits - dbaccess/source framework/inc framework/source reportdesign/source sfx2/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Oct 23 08:44:57 PDT 2012


 dbaccess/source/core/dataaccess/databasedocument.cxx              |    2 
 dbaccess/source/ui/browser/genericcontroller.cxx                  |    2 
 framework/inc/framework/statusbarconfiguration.hxx                |    2 
 framework/inc/framework/titlehelper.hxx                           |    5 -
 framework/inc/framework/toolboxconfiguration.hxx                  |    2 
 framework/inc/helper/persistentwindowstate.hxx                    |    4 
 framework/inc/jobs/helponstartup.hxx                              |    4 
 framework/inc/jobs/jobexecutor.hxx                                |    4 
 framework/inc/services.h                                          |    2 
 framework/inc/services/layoutmanager.hxx                          |    4 
 framework/inc/uiconfiguration/moduleuicfgsupplier.hxx             |    4 
 framework/inc/uiconfiguration/windowstateconfiguration.hxx        |    4 
 framework/inc/uielement/uicommanddescription.hxx                  |    4 
 framework/inc/uifactory/addonstoolboxfactory.hxx                  |    4 
 framework/inc/uifactory/menubarfactory.hxx                        |    6 -
 framework/inc/uifactory/uielementfactorymanager.hxx               |    4 
 framework/inc/uifactory/windowcontentfactorymanager.hxx           |    4 
 framework/inc/xml/imagesconfiguration.hxx                         |    2 
 framework/source/accelerators/acceleratorconfiguration.cxx        |   17 ++-
 framework/source/fwe/classes/framelistanalyzer.cxx                |   12 +-
 framework/source/fwe/helper/titlehelper.cxx                       |   21 +---
 framework/source/fwe/xml/menuconfiguration.cxx                    |   13 +-
 framework/source/fwe/xml/statusbarconfiguration.cxx               |   27 +-----
 framework/source/fwe/xml/toolboxconfiguration.cxx                 |   28 +-----
 framework/source/fwi/helper/mischelper.cxx                        |    4 
 framework/source/helper/persistentwindowstate.cxx                 |   12 +-
 framework/source/helper/titlebarupdate.cxx                        |   25 +----
 framework/source/jobs/helponstartup.cxx                           |   10 --
 framework/source/jobs/jobdispatch.cxx                             |    8 -
 framework/source/jobs/jobexecutor.cxx                             |    6 -
 framework/source/layoutmanager/layoutmanager.cxx                  |    3 
 framework/source/services/autorecovery.cxx                        |    8 -
 framework/source/services/frame.cxx                               |    2 
 framework/source/services/modulemanager.cxx                       |    2 
 framework/source/uiconfiguration/imagemanagerimpl.cxx             |    2 
 framework/source/uiconfiguration/moduleuicfgsupplier.cxx          |    3 
 framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx |    4 
 framework/source/uiconfiguration/uiconfigurationmanager.cxx       |    4 
 framework/source/uiconfiguration/windowstateconfiguration.cxx     |    9 --
 framework/source/uielement/addonstoolbarmanager.cxx               |    4 
 framework/source/uielement/menubarmanager.cxx                     |   12 +-
 framework/source/uielement/menubarwrapper.cxx                     |    7 -
 framework/source/uielement/newmenucontroller.cxx                  |   45 ++++------
 framework/source/uielement/toolbarmanager.cxx                     |   10 --
 framework/source/uielement/toolbarsmenucontroller.cxx             |    7 -
 framework/source/uielement/uicommanddescription.cxx               |    8 -
 framework/source/uifactory/addonstoolboxfactory.cxx               |    3 
 framework/source/uifactory/menubarfactory.cxx                     |    9 +-
 framework/source/uifactory/statusbarfactory.cxx                   |    2 
 framework/source/uifactory/toolboxfactory.cxx                     |    2 
 framework/source/uifactory/uielementfactorymanager.cxx            |    5 -
 framework/source/uifactory/windowcontentfactorymanager.cxx        |    5 -
 framework/source/xml/imagesconfiguration.cxx                      |   28 +-----
 reportdesign/source/core/api/ReportDefinition.cxx                 |    2 
 sfx2/source/doc/sfxbasemodel.cxx                                  |    5 -
 sfx2/source/view/sfxbasecontroller.cxx                            |    2 
 56 files changed, 183 insertions(+), 256 deletions(-)

New commits:
commit 5e9a7f1919663d22cb568b1afdc018ef6be0cc91
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 23 17:43:57 2012 +0200

    Related fdo#46808: Improve previous commit slightly
    
    Change-Id: Ib4f44f745f7e3e2e1403d905cc16bee4c487b0b4

diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index 6fdb5f3..519c5cd 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -1183,12 +1183,11 @@ void AutoRecovery::implts_specifyAppModuleAndFactory(AutoRecovery::TDocumentInfo
     // <- SAFE ----------------------------------
 
     css::uno::Reference< css::frame::XModuleManager2 > xManager = ModuleManager::create( comphelper::getComponentContext(xSMGR) );
-    css::uno::Reference< css::container::XNameAccess > xModuleConfig(xManager, css::uno::UNO_QUERY_THROW);
 
     if (rInfo.AppModule.isEmpty())
         rInfo.AppModule = xManager->identify(rInfo.Document);
 
-    ::comphelper::SequenceAsHashMap lModuleDescription(xModuleConfig->getByName(rInfo.AppModule));
+    ::comphelper::SequenceAsHashMap lModuleDescription(xManager->getByName(rInfo.AppModule));
     lModuleDescription[rtl::OUString(CFG_ENTRY_PROP_EMPTYDOCUMENTURL)] >>= rInfo.FactoryURL;
     lModuleDescription[rtl::OUString(CFG_ENTRY_PROP_FACTORYSERVICE)] >>= rInfo.FactoryService;
 }
diff --git a/framework/source/services/modulemanager.cxx b/framework/source/services/modulemanager.cxx
index d376766..df2a40f 100644
--- a/framework/source/services/modulemanager.cxx
+++ b/framework/source/services/modulemanager.cxx
@@ -67,7 +67,7 @@ ModuleManager::impl_createFactory(
 css::uno::Sequence< rtl::OUString >
 ModuleManager::impl_getSupportedServiceNames() {
     css::uno::Sequence< rtl::OUString > s(1);
-    s[0] = DECLARE_ASCII("com.sun.star.frame.ModuleManager");
+    s[0] = "com.sun.star.frame.ModuleManager";
     return s;
 }
 
diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx
index 4bb8269..bf8dbbf 100644
--- a/framework/source/uielement/newmenucontroller.cxx
+++ b/framework/source/uielement/newmenucontroller.cxx
@@ -42,7 +42,6 @@
 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
 
 #include <vcl/svapp.hxx>
 #include <vcl/i18nhelp.hxx>
@@ -493,12 +492,11 @@ void NewMenuController::impl_setPopupMenu()
         m_aModuleIdentifier = xModuleManager->identify( m_xFrame );
         m_bModuleIdentified = sal_True;
 
-        Reference< XNameAccess > xNameAccess( xModuleManager, UNO_QUERY );
-        if ( !m_aModuleIdentifier.isEmpty() && xNameAccess.is() )
+        if ( !m_aModuleIdentifier.isEmpty() )
         {
             Sequence< PropertyValue > aSeq;
 
-            if ( xNameAccess->getByName( m_aModuleIdentifier ) >>= aSeq )
+            if ( xModuleManager->getByName( m_aModuleIdentifier ) >>= aSeq )
             {
                 for ( sal_Int32 y = 0; y < aSeq.getLength(); y++ )
                 {
diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx
index 102f921..232a1ce 100644
--- a/framework/source/uielement/uicommanddescription.cxx
+++ b/framework/source/uielement/uicommanddescription.cxx
@@ -664,15 +664,14 @@ UICommandDescription::~UICommandDescription()
 void UICommandDescription::impl_fillElements(const sal_Char* _pName)
 {
     m_xModuleManager.set( ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) ) );
-    Reference< XNameAccess > xNameAccess( m_xModuleManager, UNO_QUERY_THROW );
-    Sequence< rtl::OUString > aElementNames = xNameAccess->getElementNames();
+    Sequence< rtl::OUString > aElementNames = m_xModuleManager->getElementNames();
     Sequence< PropertyValue > aSeq;
     ::rtl::OUString                  aModuleIdentifier;
 
     for ( sal_Int32 i = 0; i < aElementNames.getLength(); i++ )
     {
         aModuleIdentifier = aElementNames[i];
-        if ( xNameAccess->getByName( aModuleIdentifier ) >>= aSeq )
+        if ( m_xModuleManager->getByName( aModuleIdentifier ) >>= aSeq )
         {
             ::rtl::OUString aCommandStr;
             for ( sal_Int32 y = 0; y < aSeq.getLength(); y++ )
commit 432c0f491712870b82dcf5dee7b98fa5440bfa1a
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Oct 16 11:10:43 2012 +0200

    fdo#46808, use service constructor for frame::ModuleManager
    
    Change-Id: Iae2bd22a22213274d4a7697345b879f6573a30f0

diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
index 29a0a2f..8f5c6ae 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -2067,7 +2067,7 @@ Reference< XTitle > ODatabaseDocument::impl_getTitleHelper_throw()
             UNO_QUERY_THROW );
         uno::Reference< frame::XModel > xThis   (getThis(), uno::UNO_QUERY_THROW);
 
-        ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(m_pImpl->m_aContext.getLegacyServiceFactory());
+        ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(m_pImpl->m_aContext.getUNOContext());
         m_xTitleHelper.set(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW);
         pHelper->setOwner                   (xThis   );
         pHelper->connectWithUntitledNumbers (xDesktop);
diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx
index 3131ad1..58345e6 100644
--- a/dbaccess/source/ui/browser/genericcontroller.cxx
+++ b/dbaccess/source/ui/browser/genericcontroller.cxx
@@ -1383,7 +1383,7 @@ Reference< XTitle > OGenericUnoController::impl_getTitleHelper_throw()
         Reference< XUntitledNumbers > xUntitledProvider(getPrivateModel(), UNO_QUERY      );
         Reference< XController >      xThis(static_cast< XController* >(this), UNO_QUERY_THROW);
 
-        ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(m_xServiceFactory);
+        ::framework::TitleHelper* pHelper = new ::framework::TitleHelper( comphelper::getComponentContext(m_xServiceFactory) );
         m_xTitleHelper.set( static_cast< ::cppu::OWeakObject* >(pHelper), UNO_QUERY_THROW);
 
         pHelper->setOwner                   (xThis            );
diff --git a/framework/inc/framework/titlehelper.hxx b/framework/inc/framework/titlehelper.hxx
index 959810b..79e7807 100644
--- a/framework/inc/framework/titlehelper.hxx
+++ b/framework/inc/framework/titlehelper.hxx
@@ -31,6 +31,7 @@
 
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
 #include <com/sun/star/frame/XUntitledNumbers.hpp>
 #include <com/sun/star/frame/XTitle.hpp>
@@ -75,7 +76,7 @@ class FWE_DLLPUBLIC TitleHelper : private ::cppu::BaseMutex
         //---------------------------------------
         /** @short  lightweight constructor.
          */
-        TitleHelper(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
+        TitleHelper(const css::uno::Reference< css::uno::XComponentContext >& rxContext);
 
         //---------------------------------------
         /** @short  free all internaly used resources.
@@ -182,7 +183,7 @@ class FWE_DLLPUBLIC TitleHelper : private ::cppu::BaseMutex
     private:
 
         /** points to the global uno service manager. */
-        css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
+        css::uno::Reference< css::uno::XComponentContext> m_xContext;
 
         /** reference to the outside UNO class using this helper. */
         css::uno::WeakReference< css::uno::XInterface > m_xOwner;
diff --git a/framework/inc/helper/persistentwindowstate.hxx b/framework/inc/helper/persistentwindowstate.hxx
index 86f63ab..76adf8f 100644
--- a/framework/inc/helper/persistentwindowstate.hxx
+++ b/framework/inc/helper/persistentwindowstate.hxx
@@ -117,7 +117,7 @@ class PersistentWindowState :   // interfaces
         /** @short  identify the application module, which  is used behind the component
                     of our frame.
 
-            @param  xSMGR
+            @param  rxContext
                     needed to create needed uno resources.
 
             @param  xFrame
@@ -126,7 +126,7 @@ class PersistentWindowState :   // interfaces
             @return [string]
                     a module identifier for the current frame component.
          */
-        static ::rtl::OUString implst_identifyModule(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
+        static ::rtl::OUString implst_identifyModule(const css::uno::Reference< css::uno::XComponentContext >& rxContext,
                                                      const css::uno::Reference< css::frame::XFrame >&              xFrame);
 
         //____________________________
diff --git a/framework/inc/jobs/helponstartup.hxx b/framework/inc/jobs/helponstartup.hxx
index 8696720..4111c98 100644
--- a/framework/inc/jobs/helponstartup.hxx
+++ b/framework/inc/jobs/helponstartup.hxx
@@ -31,7 +31,7 @@
 #include <com/sun/star/task/XJob.hpp>
 #include <com/sun/star/lang/XEventListener.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
 
 
 namespace framework{
@@ -57,7 +57,7 @@ class HelpOnStartup : private ThreadHelpBase
 
         //.......................................
         /** @short  such module manager is used to classify new opened documents. */
-        css::uno::Reference< css::frame::XModuleManager > m_xModuleManager;
+        css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;
 
         //.......................................
         /** @short  is needed to locate a might open help frame. */
diff --git a/framework/inc/jobs/jobexecutor.hxx b/framework/inc/jobs/jobexecutor.hxx
index a0ab8f3..4b0f70f 100644
--- a/framework/inc/jobs/jobexecutor.hxx
+++ b/framework/inc/jobs/jobexecutor.hxx
@@ -44,7 +44,7 @@
 #include <com/sun/star/container/XContainerListener.hpp>
 #include <com/sun/star/lang/XEventListener.hpp>
 #include <com/sun/star/document/XEventListener.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
 
 #include <cppuhelper/weak.hxx>
 #include <rtl/ustring.hxx>
@@ -77,7 +77,7 @@ class JobExecutor : public  css::lang::XTypeProvider
         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
 
         /** reference to the module info service */
-        css::uno::Reference< css::frame::XModuleManager > m_xModuleManager;
+        css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;
 
         /** cached list of all registered event names of cfg for call optimization. */
         OUStringList m_lEvents;
diff --git a/framework/inc/services.h b/framework/inc/services.h
index 0b79215..9933309 100644
--- a/framework/inc/services.h
+++ b/framework/inc/services.h
@@ -69,7 +69,6 @@ namespace framework{
 #define SERVICENAME_POPUPMENUCONTROLLER                         DECLARE_ASCII("com.sun.star.frame.PopupMenuController"       )
 #define SERVICENAME_UICOMMANDDESCRIPTION                        DECLARE_ASCII("com.sun.star.frame.UICommandDescription"      )
 #define SERVICENAME_UIELEMENTFACTORYMANAGER                     DECLARE_ASCII("com.sun.star.ui.UIElementFactoryManager"      )
-#define SERVICENAME_MODULEMANAGER                               DECLARE_ASCII("com.sun.star.frame.ModuleManager"             )
 #define SERVICENAME_UICONFIGURATIONMANAGER                      DECLARE_ASCII("com.sun.star.ui.UIConfigurationManager"       )
 #define SERVICENAME_MODULEUICONFIGURATIONMANAGERSUPPLIER        DECLARE_ASCII("com.sun.star.ui.ModuleUIConfigurationManagerSupplier" )
 #define SERVICENAME_MODULEUICONFIGURATIONMANAGER                DECLARE_ASCII("com.sun.star.ui.ModuleUIConfigurationManager" )
diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx
index a757f26..3ff6ea1 100644
--- a/framework/inc/services/layoutmanager.hxx
+++ b/framework/inc/services/layoutmanager.hxx
@@ -56,7 +56,7 @@
 #include <com/sun/star/frame/XLayoutManager.hpp>
 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
 #include <com/sun/star/ui/XUIConfiguration.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
 #include <com/sun/star/frame/XFrameActionListener.hpp>
 #include <com/sun/star/awt/XWindowListener.hpp>
 #include <com/sun/star/util/XURLTransformer.hpp>
@@ -325,7 +325,7 @@ namespace framework
             UIElement                                                                   m_aStatusBarElement;
             UIElement                                                                   m_aProgressBarElement;
             com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement >          m_xProgressBarBackup;
-            css::uno::Reference< ::com::sun::star::frame::XModuleManager >              m_xModuleManager;
+            css::uno::Reference< ::com::sun::star::frame::XModuleManager2 >             m_xModuleManager;
             css::uno::Reference< ::com::sun::star::ui::XUIElementFactory >              m_xUIElementFactoryManager;
             css::uno::Reference< ::com::sun::star::container::XNameAccess >             m_xPersistentWindowState;
             css::uno::Reference< ::com::sun::star::container::XNameAccess >             m_xPersistentWindowStateSupplier;
diff --git a/framework/inc/uiconfiguration/moduleuicfgsupplier.hxx b/framework/inc/uiconfiguration/moduleuicfgsupplier.hxx
index 208c630..4961ca8 100644
--- a/framework/inc/uiconfiguration/moduleuicfgsupplier.hxx
+++ b/framework/inc/uiconfiguration/moduleuicfgsupplier.hxx
@@ -49,7 +49,7 @@
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
 #include <com/sun/star/embed/XStorage.hpp>
 #include <com/sun/star/embed/XTransactedObject.hpp>
 
@@ -102,7 +102,7 @@ namespace framework
             com::sun::star::uno::Reference< com::sun::star::embed::XStorage >                   m_xDefaultCfgRootStorage;
             com::sun::star::uno::Reference< com::sun::star::embed::XStorage >                   m_xUserCfgRootStorage;
             com::sun::star::uno::Reference< com::sun::star::embed::XTransactedObject >          m_xUserRootCommit;
-            com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager >   m_xModuleMgr;
+            com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >          m_xModuleMgr;
             com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >        m_xServiceManager;
             ::cppu::OMultiTypeInterfaceContainerHelper                                          m_aListenerContainer;   /// container for ALL Listener
    };
diff --git a/framework/inc/uiconfiguration/windowstateconfiguration.hxx b/framework/inc/uiconfiguration/windowstateconfiguration.hxx
index fbf1b20..61cc1c3 100644
--- a/framework/inc/uiconfiguration/windowstateconfiguration.hxx
+++ b/framework/inc/uiconfiguration/windowstateconfiguration.hxx
@@ -46,7 +46,7 @@
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/lang/XTypeProvider.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
 
 #include <cppuhelper/implbase2.hxx>
 #include <rtl/ustring.hxx>
@@ -113,7 +113,7 @@ class WindowStateConfiguration :  private ThreadHelpBase
         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >    m_xServiceManager;
         ModuleToWindowStateFileMap                                                          m_aModuleToFileHashMap;
         ModuleToWindowStateConfigHashMap                                                    m_aModuleToWindowStateHashMap;
-        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > m_xModuleManager;
+        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >        m_xModuleManager;
 };
 
 } // namespace framework
diff --git a/framework/inc/uielement/uicommanddescription.hxx b/framework/inc/uielement/uicommanddescription.hxx
index 8c5984e..601b1c3 100644
--- a/framework/inc/uielement/uicommanddescription.hxx
+++ b/framework/inc/uielement/uicommanddescription.hxx
@@ -46,7 +46,7 @@
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/lang/XTypeProvider.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
 
 #include <cppuhelper/implbase2.hxx>
 #include <rtl/ustring.hxx>
@@ -101,7 +101,7 @@ public:
         ModuleToCommandFileMap                                                              m_aModuleToCommandFileMap;
         UICommandsHashMap                                                                   m_aUICommandsHashMap;
         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >        m_xGenericUICommands;
-        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager >         m_xModuleManager;
+        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >        m_xModuleManager;
 };
 
 } // namespace framework
diff --git a/framework/inc/uifactory/addonstoolboxfactory.hxx b/framework/inc/uifactory/addonstoolboxfactory.hxx
index 43097aa..d05f11c 100644
--- a/framework/inc/uifactory/addonstoolboxfactory.hxx
+++ b/framework/inc/uifactory/addonstoolboxfactory.hxx
@@ -33,7 +33,7 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/ui/XUIElementFactory.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 
@@ -62,7 +62,7 @@ class AddonsToolBoxFactory :  protected ThreadHelpBase
 
     private:
         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
-        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > m_xModuleManager;
+        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >     m_xModuleManager;
 };
 
 }
diff --git a/framework/inc/uifactory/menubarfactory.hxx b/framework/inc/uifactory/menubarfactory.hxx
index 135e6ba..d34025e 100644
--- a/framework/inc/uifactory/menubarfactory.hxx
+++ b/framework/inc/uifactory/menubarfactory.hxx
@@ -32,7 +32,7 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/ui/XUIElementFactory.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
 
 #include <toolkit/awt/vclxmenu.hxx>
 #include <cppuhelper/implbase2.hxx>
@@ -59,14 +59,14 @@ namespace framework
                         ,const char* _pExtraMode
                         ,const char* _pAsciiName
                         ,const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement >& _xMenuBar
-                        ,const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager >& _xModuleManager
+                        ,const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >& _xModuleManager
                         ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceManager);
 
         protected:
             MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager,bool );
 
             ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
-            ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > m_xModuleManager;
+            ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >     m_xModuleManager;
     };
 }
 
diff --git a/framework/inc/uifactory/uielementfactorymanager.hxx b/framework/inc/uifactory/uielementfactorymanager.hxx
index 99dc12f..1667253 100644
--- a/framework/inc/uifactory/uielementfactorymanager.hxx
+++ b/framework/inc/uifactory/uielementfactorymanager.hxx
@@ -47,7 +47,7 @@
 #include <com/sun/star/ui/XUIElementFactoryRegistration.hpp>
 #include <com/sun/star/container/XContainerListener.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
-#include "com/sun/star/frame/XModuleManager.hpp"
+#include "com/sun/star/frame/XModuleManager2.hpp"
 
 #include <cppuhelper/implbase1.hxx>
 #include <cppuhelper/implbase3.hxx>
@@ -134,7 +134,7 @@ class UIElementFactoryManager :  private ThreadHelpBase
 
         sal_Bool                                                                            m_bConfigRead;
         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >    m_xServiceManager;
-        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > m_xModuleManager;
+        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >        m_xModuleManager;
         ConfigurationAccess_FactoryManager*                                        m_pConfigAccess;
 };
 
diff --git a/framework/inc/uifactory/windowcontentfactorymanager.hxx b/framework/inc/uifactory/windowcontentfactorymanager.hxx
index 4711c1f..5facbbd 100644
--- a/framework/inc/uifactory/windowcontentfactorymanager.hxx
+++ b/framework/inc/uifactory/windowcontentfactorymanager.hxx
@@ -35,7 +35,7 @@
 
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
-#include "com/sun/star/frame/XModuleManager.hpp"
+#include "com/sun/star/frame/XModuleManager2.hpp"
 
 #include <cppuhelper/implbase2.hxx>
 #include <rtl/ustring.hxx>
@@ -64,7 +64,7 @@ class WindowContentFactoryManager : private ThreadHelpBase
 
         sal_Bool                                                                         m_bConfigRead;
         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
-        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager >      m_xModuleManager;
+        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >     m_xModuleManager;
         ConfigurationAccess_FactoryManager*                                 m_pConfigAccess;
 };
 
diff --git a/framework/source/fwe/classes/framelistanalyzer.cxx b/framework/source/fwe/classes/framelistanalyzer.cxx
index 5aee045..e22af21 100644
--- a/framework/source/fwe/classes/framelistanalyzer.cxx
+++ b/framework/source/fwe/classes/framelistanalyzer.cxx
@@ -36,7 +36,7 @@
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 
 #include <comphelper/processfactory.hxx>
 #include <vcl/svapp.hxx>
@@ -132,10 +132,10 @@ void FrameListAnalyzer::impl_analyze()
     {
         try
         {
-            css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
-            css::uno::Reference< css::frame::XModuleManager > xModuleMgr(xSMGR->createInstance(SERVICENAME_MODULEMANAGER), css::uno::UNO_QUERY_THROW);
+            css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+            css::uno::Reference< css::frame::XModuleManager2 > xModuleMgr = css::frame::ModuleManager::create(xContext);
             ::rtl::OUString sModule = xModuleMgr->identify(m_xReferenceFrame);
-            m_bReferenceIsBacking = (sModule.equals(SERVICENAME_STARTMODULE));
+            m_bReferenceIsBacking = sModule.equals(SERVICENAME_STARTMODULE);
         }
         catch(const css::frame::UnknownModuleException&)
         {
@@ -207,8 +207,8 @@ void FrameListAnalyzer::impl_analyze()
             {
                 try
                 {
-                    css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
-                    css::uno::Reference< css::frame::XModuleManager > xModuleMgr(xSMGR->createInstance(SERVICENAME_MODULEMANAGER), css::uno::UNO_QUERY);
+                    css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+                    css::uno::Reference< css::frame::XModuleManager2 > xModuleMgr = css::frame::ModuleManager::create(xContext);
                     ::rtl::OUString sModule = xModuleMgr->identify(xFrame);
                     if (sModule.equals(SERVICENAME_STARTMODULE))
                     {
diff --git a/framework/source/fwe/helper/titlehelper.cxx b/framework/source/fwe/helper/titlehelper.cxx
index 1782d34..03aedbd 100644
--- a/framework/source/fwe/helper/titlehelper.cxx
+++ b/framework/source/fwe/helper/titlehelper.cxx
@@ -32,7 +32,7 @@
 
 #include <com/sun/star/frame/UntitledNumbersConst.hpp>
 #include <com/sun/star/frame/XStorable.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/document/XEventBroadcaster.hpp>
 #include <com/sun/star/beans/XMaterialHolder.hpp>
@@ -50,9 +50,9 @@ namespace framework{
 namespace css = ::com::sun::star;
 
 //-----------------------------------------------
-TitleHelper::TitleHelper(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
+TitleHelper::TitleHelper(const css::uno::Reference< css::uno::XComponentContext >& rxContext)
     : ::cppu::BaseMutex ()
-    , m_xSMGR           (xSMGR)
+    , m_xContext        (rxContext)
     , m_xOwner          ()
     , m_xUntitledNumbers()
     , m_xSubTitle       ()
@@ -558,24 +558,19 @@ void TitleHelper::impl_appendModuleName (::rtl::OUStringBuffer& sTitle)
     // SYNCHRONIZED ->
     ::osl::ResettableMutexGuard aLock(m_aMutex);
 
-        css::uno::Reference< css::uno::XInterface >            xOwner = m_xOwner.get();
-        css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR  = m_xSMGR;
+        css::uno::Reference< css::uno::XInterface >        xOwner   = m_xOwner.get();
+        css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext;
 
     aLock.clear ();
     // <- SYNCHRONIZED
 
     try
     {
-        css::uno::Reference< css::frame::XModuleManager > xModuleManager(
-            xSMGR->createInstance(SERVICENAME_MODULEMANAGER),
-            css::uno::UNO_QUERY_THROW);
-
-        css::uno::Reference< css::container::XNameAccess > xConfig(
-            xModuleManager,
-            css::uno::UNO_QUERY_THROW);
+        css::uno::Reference< css::frame::XModuleManager2 > xModuleManager =
+            css::frame::ModuleManager::create(xContext);
 
         const ::rtl::OUString                 sID     = xModuleManager->identify(xOwner);
-              ::comphelper::SequenceAsHashMap lProps  = xConfig->getByName (sID);
+              ::comphelper::SequenceAsHashMap lProps  = xModuleManager->getByName (sID);
         const ::rtl::OUString                 sUIName = lProps.getUnpackedValueOrDefault (OFFICEFACTORY_PROPNAME_UINAME, ::rtl::OUString());
 
         // An UIname property is an optional value !
diff --git a/framework/source/fwi/helper/mischelper.cxx b/framework/source/fwi/helper/mischelper.cxx
index 3964826..1706bd1 100644
--- a/framework/source/fwi/helper/mischelper.cxx
+++ b/framework/source/fwi/helper/mischelper.cxx
@@ -29,7 +29,7 @@
 
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/document/XDocumentLanguages.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 
 #include <tools/debug.hxx>
@@ -94,7 +94,7 @@ uno::Reference< linguistic2::XLanguageGuessing > LanguageGuessingHelper::GetGues
             if ( !_rIni )
             {
                 _rIni = sal_True;
-                Reference< XModuleManager > xModuleManager( _xServiceFactory->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW );
+                Reference< XModuleManager2 > xModuleManager = ModuleManager::create( comphelper::getComponentContext(_xServiceFactory) );
 
                 try
                 {
diff --git a/framework/source/helper/persistentwindowstate.cxx b/framework/source/helper/persistentwindowstate.cxx
index 206deaa..1733b92 100644
--- a/framework/source/helper/persistentwindowstate.cxx
+++ b/framework/source/helper/persistentwindowstate.cxx
@@ -37,8 +37,9 @@
 
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 
+#include <comphelper/processfactory.hxx>
 #include <comphelper/configurationhelper.hxx>
 #include <vcl/window.hxx>
 #include <vcl/syswin.hxx>
@@ -134,7 +135,7 @@ void SAL_CALL PersistentWindowState::frameAction(const css::frame::FrameActionEv
         return;
 
     // unknown module -> no configuration available!
-    ::rtl::OUString sModuleName = PersistentWindowState::implst_identifyModule(xSMGR, xFrame);
+    ::rtl::OUString sModuleName = PersistentWindowState::implst_identifyModule(comphelper::getComponentContext(xSMGR), xFrame);
     if (sModuleName.isEmpty())
         return;
 
@@ -181,14 +182,13 @@ void SAL_CALL PersistentWindowState::disposing(const css::lang::EventObject&)
 }
 
 //*****************************************************************************************************************
-::rtl::OUString PersistentWindowState::implst_identifyModule(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
+::rtl::OUString PersistentWindowState::implst_identifyModule(const css::uno::Reference< css::uno::XComponentContext >& rxContext,
                                                              const css::uno::Reference< css::frame::XFrame >&              xFrame)
 {
     ::rtl::OUString sModuleName;
 
-    css::uno::Reference< css::frame::XModuleManager > xModuleManager(
-        xSMGR->createInstance(SERVICENAME_MODULEMANAGER),
-        css::uno::UNO_QUERY_THROW);
+    css::uno::Reference< css::frame::XModuleManager2 > xModuleManager =
+        css::frame::ModuleManager::create( rxContext );
 
     try
     {
diff --git a/framework/source/helper/titlebarupdate.cxx b/framework/source/helper/titlebarupdate.cxx
index 2264a82..9e702b0 100644
--- a/framework/source/helper/titlebarupdate.cxx
+++ b/framework/source/helper/titlebarupdate.cxx
@@ -38,13 +38,14 @@
 #include <com/sun/star/awt/XWindow.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/lang/IllegalArgumentException.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/XPropertySet.hpp>
 #include <com/sun/star/beans/XMaterialHolder.hpp>
 #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
 #include <com/sun/star/beans/NamedValue.hpp>
 
+#include <comphelper/processfactory.hxx>
 #include <comphelper/sequenceashashmap.hxx>
 #include <unotools/configmgr.hxx>
 #include <unotools/bootstrap.hxx>
@@ -175,13 +176,8 @@ void TitleBarUpdate::impl_updateApplicationID(const css::uno::Reference< css::fr
         aReadLock.unlock();
         // <- SYNCHRONIZED
 
-        css::uno::Reference< css::frame::XModuleManager > xModuleManager(
-            xSMGR->createInstance(SERVICENAME_MODULEMANAGER),
-            css::uno::UNO_QUERY_THROW);
-
-        css::uno::Reference< css::container::XNameAccess > xConfig(
-            xModuleManager,
-            css::uno::UNO_QUERY_THROW);
+        css::uno::Reference< css::frame::XModuleManager2 > xModuleManager =
+            css::frame::ModuleManager::create( comphelper::getComponentContext(xSMGR) );
 
         rtl::OUString aModuleId = xModuleManager->identify(xFrame);
         rtl::OUString sDesktopName;
@@ -248,16 +244,11 @@ void TitleBarUpdate::impl_updateApplicationID(const css::uno::Reference< css::fr
 
     try
     {
-        css::uno::Reference< css::frame::XModuleManager > xModuleManager(
-            xSMGR->createInstance(SERVICENAME_MODULEMANAGER),
-            css::uno::UNO_QUERY_THROW);
-
-        css::uno::Reference< css::container::XNameAccess > xConfig(
-            xModuleManager,
-            css::uno::UNO_QUERY_THROW);
+        css::uno::Reference< css::frame::XModuleManager2 > xModuleManager =
+            css::frame::ModuleManager::create( comphelper::getComponentContext(xSMGR) );
 
-                                        rInfo.sID = xModuleManager->identify(xFrame);
-        ::comphelper::SequenceAsHashMap lProps    = xConfig->getByName (rInfo.sID);
+        rInfo.sID = xModuleManager->identify(xFrame);
+        ::comphelper::SequenceAsHashMap lProps    = xModuleManager->getByName (rInfo.sID);
 
         rInfo.sUIName = lProps.getUnpackedValueOrDefault (OFFICEFACTORY_PROPNAME_UINAME, ::rtl::OUString());
         rInfo.nIcon   = lProps.getUnpackedValueOrDefault (OFFICEFACTORY_PROPNAME_ICON  , INVALID_ICON_ID  );
diff --git a/framework/source/jobs/helponstartup.cxx b/framework/source/jobs/helponstartup.cxx
index 017cc4a..8c7201d 100644
--- a/framework/source/jobs/helponstartup.cxx
+++ b/framework/source/jobs/helponstartup.cxx
@@ -46,6 +46,7 @@
 //_______________________________________________
 // include interfaces
 #include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XFramesSupplier.hpp>
 #include <com/sun/star/frame/XDesktop.hpp>
 
@@ -90,9 +91,7 @@ DEFINE_INIT_SERVICE(HelpOnStartup,
                             see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
                         */
                         // create some needed uno services and cache it
-                        m_xModuleManager = css::uno::Reference< css::frame::XModuleManager >(
-                            m_xSMGR->createInstance(SERVICENAME_MODULEMANAGER),
-                            css::uno::UNO_QUERY_THROW);
+                        m_xModuleManager = css::frame::ModuleManager::create( comphelper::getComponentContext(m_xSMGR) );
 
                         m_xDesktop = css::uno::Reference< css::frame::XFrame >(
                             m_xSMGR->createInstance(SERVICENAME_DESKTOP),
@@ -252,13 +251,10 @@ void SAL_CALL HelpOnStartup::disposing(const css::lang::EventObject& aEvent)
     // Classify it.
     // SAFE ->
     ResetableGuard aLock(m_aLock);
-    css::uno::Reference< css::frame::XModuleManager > xModuleManager = m_xModuleManager;
+    css::uno::Reference< css::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
     aLock.unlock();
     // <- SAFE
 
-    if (!xModuleManager.is())
-        return ::rtl::OUString();
-
     ::rtl::OUString sModuleId;
     try
     {
diff --git a/framework/source/jobs/jobdispatch.cxx b/framework/source/jobs/jobdispatch.cxx
index fd0b5ee..8672062 100644
--- a/framework/source/jobs/jobdispatch.cxx
+++ b/framework/source/jobs/jobdispatch.cxx
@@ -38,7 +38,7 @@
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/frame/DispatchResultState.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 
 #include <rtl/ustrbuf.hxx>
 #include <vcl/svapp.hxx>
@@ -129,10 +129,8 @@ void SAL_CALL JobDispatch::initialize( const css::uno::Sequence< css::uno::Any >
         {
             lArguments[a] >>= m_xFrame;
 
-            css::uno::Reference< css::frame::XModuleManager > xModuleManager(
-                m_xSMGR->createInstance(
-                    SERVICENAME_MODULEMANAGER ),
-                css::uno::UNO_QUERY_THROW );
+            css::uno::Reference< css::frame::XModuleManager2 > xModuleManager =
+                css::frame::ModuleManager::create(comphelper::getComponentContext(m_xSMGR));
             try
             {
                 m_sModuleIdentifier = xModuleManager->identify( m_xFrame );
diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx
index 0963d58..84fbb27 100644
--- a/framework/source/jobs/jobexecutor.cxx
+++ b/framework/source/jobs/jobexecutor.cxx
@@ -42,6 +42,7 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 
 #include <unotools/configpaths.hxx>
 #include <rtl/ustrbuf.hxx>
@@ -78,10 +79,7 @@ DEFINE_XSERVICEINFO_ONEINSTANCESERVICE( JobExecutor                   ,
 
 DEFINE_INIT_SERVICE( JobExecutor,
                      {
-                         m_xModuleManager = css::uno::Reference< css::frame::XModuleManager >(
-                             m_xSMGR->createInstance(
-                                 SERVICENAME_MODULEMANAGER ),
-                             css::uno::UNO_QUERY_THROW );
+                         m_xModuleManager = css::frame::ModuleManager::create( comphelper::getComponentContext(m_xSMGR) );
 
                          /*Attention
                              I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index 10094d9..9bb9692 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -44,6 +44,7 @@
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/frame/FrameAction.hpp>
 #include <com/sun/star/frame/XUIControllerRegistration.hpp>
@@ -137,7 +138,7 @@ LayoutManager::LayoutManager( const Reference< XMultiServiceFactory >& xServiceM
         , m_bPreserveContentSize( false )
         , m_bMenuBarCloser( false )
         , m_pInplaceMenuBar( NULL )
-        , m_xModuleManager( Reference< XModuleManager >( xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY ))
+        , m_xModuleManager( ModuleManager::create( comphelper::getComponentContext(xServiceManager) ))
         , m_xUIElementFactoryManager( Reference< ui::XUIElementFactory >(
                 xServiceManager->createInstance( SERVICENAME_UIELEMENTFACTORYMANAGER ), UNO_QUERY ))
         , m_xPersistentWindowStateSupplier( Reference< XNameAccess >(
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index a5efae1..6fdb5f3 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -47,7 +47,7 @@
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/frame/XLoadable.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/frame/XTitle.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/frame/XDispatchProvider.hpp>
@@ -111,6 +111,7 @@ using ::com::sun::star::uno::Any;
 using ::com::sun::star::beans::PropertyValue;
 using ::com::sun::star::container::XEnumeration;
 using ::com::sun::star::document::XDocumentRecovery;
+using ::com::sun::star::frame::ModuleManager;
 using ::com::sun::star::frame::XModel2;
 using ::com::sun::star::frame::XModel;
 using ::com::sun::star::frame::XFrame;
@@ -1181,8 +1182,8 @@ void AutoRecovery::implts_specifyAppModuleAndFactory(AutoRecovery::TDocumentInfo
     aReadLock.unlock();
     // <- SAFE ----------------------------------
 
-    css::uno::Reference< css::frame::XModuleManager > xManager     (xSMGR->createInstance(SERVICENAME_MODULEMANAGER), css::uno::UNO_QUERY_THROW);
-    css::uno::Reference< css::container::XNameAccess > xModuleConfig(xManager                                        , css::uno::UNO_QUERY_THROW);
+    css::uno::Reference< css::frame::XModuleManager2 > xManager = ModuleManager::create( comphelper::getComponentContext(xSMGR) );
+    css::uno::Reference< css::container::XNameAccess > xModuleConfig(xManager, css::uno::UNO_QUERY_THROW);
 
     if (rInfo.AppModule.isEmpty())
         rInfo.AppModule = xManager->identify(rInfo.Document);
diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx
index e3bf76b..b56b561 100644
--- a/framework/source/services/frame.cxx
+++ b/framework/source/services/frame.cxx
@@ -599,7 +599,7 @@ void SAL_CALL Frame::initialize( const css::uno::Reference< css::awt::XWindow >&
     m_pWindowCommandDispatch = new WindowCommandDispatch(xSMGR, this);
 
     // Initialize title functionality
-    TitleHelper* pTitleHelper = new TitleHelper(xSMGR);
+    TitleHelper* pTitleHelper = new TitleHelper( comphelper::getComponentContext(xSMGR) );
     m_xTitleHelper = css::uno::Reference< css::frame::XTitle >(static_cast< ::cppu::OWeakObject* >(pTitleHelper), css::uno::UNO_QUERY_THROW);
     pTitleHelper->setOwner(xThis);
 }
diff --git a/framework/source/services/modulemanager.cxx b/framework/source/services/modulemanager.cxx
index 8860f0d..d376766 100644
--- a/framework/source/services/modulemanager.cxx
+++ b/framework/source/services/modulemanager.cxx
@@ -67,7 +67,7 @@ ModuleManager::impl_createFactory(
 css::uno::Sequence< rtl::OUString >
 ModuleManager::impl_getSupportedServiceNames() {
     css::uno::Sequence< rtl::OUString > s(1);
-    s[0] = SERVICENAME_MODULEMANAGER;
+    s[0] = DECLARE_ASCII("com.sun.star.frame.ModuleManager");
     return s;
 }
 
diff --git a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
index 0753e9d..088271f 100644
--- a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
+++ b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
@@ -34,6 +34,7 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/io/XOutputStream.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/io/XSeekable.hpp>
@@ -109,7 +110,7 @@ ModuleUIConfigurationManagerSupplier::ModuleUIConfigurationManagerSupplier( cons
     ThreadHelpBase( &Application::GetSolarMutex() )
     , m_bDisposed( false )
 //TODO_AS    , m_bInit( false )
-    , m_xModuleMgr( Reference< XModuleManager >( xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY ))
+    , m_xModuleMgr( ModuleManager::create( comphelper::getComponentContext(xServiceManager) ) )
     , m_xServiceManager( xServiceManager )
     , m_aListenerContainer( m_aLock.getShareableOslMutex() )
 {
diff --git a/framework/source/uiconfiguration/windowstateconfiguration.cxx b/framework/source/uiconfiguration/windowstateconfiguration.cxx
index 8a38346..0c831f3 100644
--- a/framework/source/uiconfiguration/windowstateconfiguration.cxx
+++ b/framework/source/uiconfiguration/windowstateconfiguration.cxx
@@ -37,6 +37,7 @@
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/awt/Point.hpp>
 #include <com/sun/star/awt/Size.hpp>
 #include <com/sun/star/ui/DockingArea.hpp>
@@ -1363,14 +1364,12 @@ WindowStateConfiguration::WindowStateConfiguration( const Reference< XMultiServi
     ThreadHelpBase(),
     m_xServiceManager( xServiceManager )
 {
-    m_xModuleManager = Reference< XModuleManager >( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ),
-                                                    UNO_QUERY );
+    m_xModuleManager = ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) );
     Reference< XNameAccess > xEmptyNameAccess;
-    Reference< XNameAccess > xNameAccess( m_xModuleManager, UNO_QUERY_THROW );
     Sequence< rtl::OUString > aElementNames;
     try
     {
-        aElementNames = xNameAccess->getElementNames();
+        aElementNames = m_xModuleManager->getElementNames();
     }
     catch (const ::com::sun::star::uno::RuntimeException &)
     {
@@ -1381,7 +1380,7 @@ WindowStateConfiguration::WindowStateConfiguration( const Reference< XMultiServi
     for ( sal_Int32 i = 0; i < aElementNames.getLength(); i++ )
     {
         aModuleIdentifier = aElementNames[i];
-        if ( xNameAccess->getByName( aModuleIdentifier ) >>= aSeq )
+        if ( m_xModuleManager->getByName( aModuleIdentifier ) >>= aSeq )
         {
             ::rtl::OUString aWindowStateFileStr;
             for ( sal_Int32 y = 0; y < aSeq.getLength(); y++ )
diff --git a/framework/source/uielement/addonstoolbarmanager.cxx b/framework/source/uielement/addonstoolbarmanager.cxx
index 1bc24dd..5f6c847 100644
--- a/framework/source/uielement/addonstoolbarmanager.cxx
+++ b/framework/source/uielement/addonstoolbarmanager.cxx
@@ -48,6 +48,7 @@
 #include <uielement/toolbarmerger.hxx>
 
 #include <com/sun/star/ui/ItemType.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XToolbarController.hpp>
 #include <com/sun/star/frame/XDispatchProvider.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
@@ -225,8 +226,7 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue
     ::rtl::OUString aModuleIdentifier;
     try
     {
-        Reference< XModuleManager > xModuleManager(
-            m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW );
+        Reference< XModuleManager2 > xModuleManager = ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) );
         aModuleIdentifier = xModuleManager->identify( m_xFrame );
     }
     catch ( const Exception& )
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index b79f179..2f1f22e 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -56,7 +56,7 @@
 #include <com/sun/star/ui/ItemType.hpp>
 #include <com/sun/star/ui/ImageType.hpp>
 #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/ui/XModuleUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/ItemStyle.hpp>
@@ -1537,8 +1537,7 @@ void MenuBarManager::RetrieveShortcuts( std::vector< MenuItemHandler* >& aMenuSh
     if ( !m_bModuleIdentified )
     {
         m_bModuleIdentified = sal_True;
-        Reference< XModuleManager > xModuleManager;
-        xModuleManager = Reference< XModuleManager >( getServiceFactory()->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW );
+        Reference< XModuleManager2 > xModuleManager = ModuleManager::create( comphelper::getComponentContext( getServiceFactory() ) );
 
         try
         {
@@ -1657,9 +1656,9 @@ void MenuBarManager::RetrieveImageManagers()
         }
     }
 
-    Reference< XModuleManager > xModuleManager;
+    Reference< XModuleManager2 > xModuleManager;
     if ( m_aModuleIdentifier.isEmpty() )
-        xModuleManager.set( getServiceFactory()->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW );
+        xModuleManager.set( ModuleManager::create( comphelper::getComponentContext( getServiceFactory() ) ) );
 
     try
     {
@@ -1895,8 +1894,7 @@ void MenuBarManager::SetItemContainer( const Reference< XIndexAccess >& rItemCon
     if ( !m_bModuleIdentified )
     {
         m_bModuleIdentified = sal_True;
-        Reference< XModuleManager > xModuleManager;
-        xModuleManager = Reference< XModuleManager >( getServiceFactory()->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW );
+        Reference< XModuleManager2 > xModuleManager = ModuleManager::create( comphelper::getComponentContext(getServiceFactory()) );
 
         try
         {
diff --git a/framework/source/uielement/menubarwrapper.cxx b/framework/source/uielement/menubarwrapper.cxx
index 48b93d5..cc7032a 100644
--- a/framework/source/uielement/menubarwrapper.cxx
+++ b/framework/source/uielement/menubarwrapper.cxx
@@ -38,7 +38,7 @@
 #include <com/sun/star/container/XIndexContainer.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/ui/UIElementType.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/util/URLTransformer.hpp>
 
 #include <comphelper/processfactory.hxx>
@@ -147,10 +147,7 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th
                 pVCLMenuBar = new MenuBar();
             }
 
-            Reference< XModuleManager > xModuleManager;
-            xModuleManager = Reference< XModuleManager >(
-                m_xServiceFactory->createInstance(
-                    SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW );
+            Reference< XModuleManager2 > xModuleManager = ModuleManager::create( comphelper::getComponentContext(m_xServiceFactory) );
 
             try
             {
diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx
index 3859562..4bb8269 100644
--- a/framework/source/uielement/newmenucontroller.cxx
+++ b/framework/source/uielement/newmenucontroller.cxx
@@ -41,7 +41,7 @@
 #include <com/sun/star/awt/MenuItemStyle.hpp>
 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 
 #include <vcl/svapp.hxx>
@@ -487,39 +487,36 @@ void NewMenuController::impl_setPopupMenu()
         fillPopupMenu( m_xPopupMenu );
 
     // Identify module that we are attach to. It's our context that we need to know.
-    Reference< XModuleManager > xModuleManager( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ),UNO_QUERY );
-    if ( xModuleManager.is() )
+    Reference< XModuleManager2 > xModuleManager = ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) );
+    try
     {
-        try
+        m_aModuleIdentifier = xModuleManager->identify( m_xFrame );
+        m_bModuleIdentified = sal_True;
+
+        Reference< XNameAccess > xNameAccess( xModuleManager, UNO_QUERY );
+        if ( !m_aModuleIdentifier.isEmpty() && xNameAccess.is() )
         {
-            m_aModuleIdentifier = xModuleManager->identify( m_xFrame );
-            m_bModuleIdentified = sal_True;
+            Sequence< PropertyValue > aSeq;
 
-            Reference< XNameAccess > xNameAccess( xModuleManager, UNO_QUERY );
-            if ( !m_aModuleIdentifier.isEmpty() && xNameAccess.is() )
+            if ( xNameAccess->getByName( m_aModuleIdentifier ) >>= aSeq )
             {
-                Sequence< PropertyValue > aSeq;
-
-                if ( xNameAccess->getByName( m_aModuleIdentifier ) >>= aSeq )
+                for ( sal_Int32 y = 0; y < aSeq.getLength(); y++ )
                 {
-                    for ( sal_Int32 y = 0; y < aSeq.getLength(); y++ )
+                    if ( aSeq[y].Name == "ooSetupFactoryEmptyDocumentURL" )
                     {
-                        if ( aSeq[y].Name == "ooSetupFactoryEmptyDocumentURL" )
-                        {
-                            aSeq[y].Value >>= m_aEmptyDocURL;
-                            break;
-                        }
+                        aSeq[y].Value >>= m_aEmptyDocURL;
+                        break;
                     }
                 }
             }
         }
-        catch ( const RuntimeException& )
-        {
-            throw;
-        }
-        catch ( const Exception& )
-        {
-        }
+    }
+    catch ( const RuntimeException& )
+    {
+        throw;
+    }
+    catch ( const Exception& )
+    {
     }
 }
 
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 208fe1d..21d23bd 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -49,7 +49,7 @@
 #include <com/sun/star/ui/DockingArea.hpp>
 #include <com/sun/star/graphic/XGraphic.hpp>
 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/ui/XUIElementSettings.hpp>
 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
@@ -829,7 +829,7 @@ uno::Sequence< beans::PropertyValue > ToolBarManager::GetPropsForCommand( const
     {
         if ( !m_bModuleIdentified )
         {
-            Reference< XModuleManager > xModuleManager( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW );
+            Reference< XModuleManager2 > xModuleManager = ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) );
             Reference< XInterface > xIfac( m_xFrame, UNO_QUERY );
 
             m_bModuleIdentified = sal_True;
@@ -1200,8 +1200,7 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
 
     sal_uInt16    nId( 1 );
 
-    Reference< XModuleManager > xModuleManager( Reference< XModuleManager >(
-                                                    m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY ));
+    Reference< XModuleManager2 > xModuleManager = ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) );
     if ( !m_xDocImageManager.is() )
     {
         Reference< XModel > xModel( GetModelFromFrame() );
@@ -1221,8 +1220,7 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
 
     try
     {
-        if ( xModuleManager.is() )
-            m_aModuleIdentifier = xModuleManager->identify( Reference< XInterface >( m_xFrame, UNO_QUERY ) );
+        m_aModuleIdentifier = xModuleManager->identify( Reference< XInterface >( m_xFrame, UNO_QUERY ) );
     }
     catch (const Exception&)
     {
diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx
index 5d479a5..37bf5ec 100644
--- a/framework/source/uielement/toolbarsmenucontroller.cxx
+++ b/framework/source/uielement/toolbarsmenucontroller.cxx
@@ -41,6 +41,7 @@
 #include <com/sun/star/awt/XDevice.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/awt/MenuItemStyle.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XDispatchProvider.hpp>
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
@@ -229,7 +230,7 @@ rtl::OUString ToolbarsMenuController::getUINameFromCommand( const rtl::OUString&
     {
         try
         {
-            Reference< XModuleManager > xModuleManager( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW );
+            Reference< XModuleManager2 > xModuleManager = ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) );
             m_aModuleIdentifier = xModuleManager->identify( m_xFrame );
             Reference< XNameAccess > xNameAccess( m_xServiceManager->createInstance(
                                                                     SERVICENAME_UICOMMANDDESCRIPTION ),
@@ -831,9 +832,7 @@ void SAL_CALL ToolbarsMenuController::initialize( const Sequence< Any >& aArgume
 
         if ( m_bInitialized )
         {
-            Reference< XModuleManager > xModuleManager( m_xServiceManager->createInstance(
-                                                            SERVICENAME_MODULEMANAGER ),
-                                                        UNO_QUERY );
+            Reference< XModuleManager2 > xModuleManager = ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) );
             Reference< XNameAccess > xPersistentWindowStateSupplier( m_xServiceManager->createInstance(
                                                                         SERVICENAME_WINDOWSTATECONFIGURATION ),
                                                                      UNO_QUERY );
diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx
index 4715e1c..102f921 100644
--- a/framework/source/uielement/uicommanddescription.cxx
+++ b/framework/source/uielement/uicommanddescription.cxx
@@ -36,6 +36,7 @@
 
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/container/XContainer.hpp>
@@ -662,7 +663,7 @@ UICommandDescription::~UICommandDescription()
 }
 void UICommandDescription::impl_fillElements(const sal_Char* _pName)
 {
-    m_xModuleManager.set( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ),UNO_QUERY );
+    m_xModuleManager.set( ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) ) );
     Reference< XNameAccess > xNameAccess( m_xModuleManager, UNO_QUERY_THROW );
     Sequence< rtl::OUString > aElementNames = xNameAccess->getElementNames();
     Sequence< PropertyValue > aSeq;
diff --git a/framework/source/uifactory/addonstoolboxfactory.cxx b/framework/source/uifactory/addonstoolboxfactory.cxx
index 21ca8c1..54b84d1 100644
--- a/framework/source/uifactory/addonstoolboxfactory.cxx
+++ b/framework/source/uifactory/addonstoolboxfactory.cxx
@@ -32,6 +32,7 @@
 #include <threadhelp/resetableguard.hxx>
 
 #include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
@@ -71,7 +72,7 @@ AddonsToolBoxFactory::AddonsToolBoxFactory(
     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) :
     ThreadHelpBase( &Application::GetSolarMutex() )
     , m_xServiceManager( xServiceManager )
-    , m_xModuleManager( xServiceManager->createInstance(SERVICENAME_MODULEMANAGER),UNO_QUERY )
+    , m_xModuleManager( ModuleManager::create( comphelper::getComponentContext(xServiceManager) ) )
 {
 }
 
diff --git a/framework/source/uifactory/menubarfactory.cxx b/framework/source/uifactory/menubarfactory.cxx
index e221e9a..fcb17cc 100644
--- a/framework/source/uifactory/menubarfactory.cxx
+++ b/framework/source/uifactory/menubarfactory.cxx
@@ -33,6 +33,7 @@
 #include <uielement/menubarwrapper.hxx>
 
 #include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
@@ -73,13 +74,13 @@ DEFINE_INIT_SERVICE                     (   MenuBarFactory, {} )
 MenuBarFactory::MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) :
     ThreadHelpBase()
     , m_xServiceManager( xServiceManager )
-    , m_xModuleManager( xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY )
+    , m_xModuleManager( ModuleManager::create( comphelper::getComponentContext(xServiceManager) ) )
 {
 }
 MenuBarFactory::MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager,bool ) :
     ThreadHelpBase(&Application::GetSolarMutex())
     , m_xServiceManager( xServiceManager )
-    , m_xModuleManager( xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY )
+    , m_xModuleManager( ModuleManager::create( comphelper::getComponentContext(xServiceManager) ) )
 {
 }
 
@@ -97,7 +98,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::l
     ResetableGuard aLock( m_aLock );
     MenuBarWrapper* pMenuBarWrapper = new MenuBarWrapper( m_xServiceManager );
     Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pMenuBarWrapper, UNO_QUERY );
-    Reference< ::com::sun::star::frame::XModuleManager > xModuleManager = m_xModuleManager;
+    Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
     aLock.unlock();
     CreateUIElement(ResourceURL,Args,"MenuOnly","private:resource/menubar/",xMenuBar,xModuleManager,m_xServiceManager);
     return xMenuBar;
@@ -107,7 +108,7 @@ void MenuBarFactory::CreateUIElement(const ::rtl::OUString& ResourceURL
                                      ,const char* _pExtraMode
                                      ,const char* _pAsciiName
                                      ,const Reference< ::com::sun::star::ui::XUIElement >& _xMenuBar
-                                     ,const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager >& _xModuleManager
+                                     ,const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >& _xModuleManager
                                      ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceManager)
 {
     Reference< XUIConfigurationManager > xCfgMgr;
diff --git a/framework/source/uifactory/statusbarfactory.cxx b/framework/source/uifactory/statusbarfactory.cxx
index 7f2fce4..df64bc1 100644
--- a/framework/source/uifactory/statusbarfactory.cxx
+++ b/framework/source/uifactory/statusbarfactory.cxx
@@ -76,7 +76,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::l
     ResetableGuard aLock( m_aLock );
     StatusBarWrapper* pWrapper = new StatusBarWrapper( m_xServiceManager );
     Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY );
-    Reference< ::com::sun::star::frame::XModuleManager > xModuleManager = m_xModuleManager;
+    Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
     aLock.unlock();
     MenuBarFactory::CreateUIElement(ResourceURL,Args,NULL,"private:resource/statusbar/",xMenuBar,xModuleManager,m_xServiceManager);
     return xMenuBar;
diff --git a/framework/source/uifactory/toolboxfactory.cxx b/framework/source/uifactory/toolboxfactory.cxx
index a30a1c3..69a037c 100644
--- a/framework/source/uifactory/toolboxfactory.cxx
+++ b/framework/source/uifactory/toolboxfactory.cxx
@@ -72,7 +72,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::l
     ResetableGuard aLock( m_aLock );
     ToolBarWrapper* pWrapper = new ToolBarWrapper( m_xServiceManager );
     Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY );
-    Reference< ::com::sun::star::frame::XModuleManager > xModuleManager = m_xModuleManager;
+    Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = m_xModuleManager;
     aLock.unlock();
     CreateUIElement(ResourceURL,Args,"PopupMode","private:resource/toolbar/",xMenuBar,xModuleManager,m_xServiceManager);
     return xMenuBar;
diff --git a/framework/source/uifactory/uielementfactorymanager.cxx b/framework/source/uifactory/uielementfactorymanager.cxx
index 11ff2a1..9e0deba 100644
--- a/framework/source/uifactory/uielementfactorymanager.cxx
+++ b/framework/source/uifactory/uielementfactorymanager.cxx
@@ -38,6 +38,7 @@
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
 
 #include <rtl/ustrbuf.hxx>
@@ -394,7 +395,7 @@ UIElementFactoryManager::UIElementFactoryManager( const Reference< XMultiService
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen at sun.com", "UIElementFactoryManager::UIElementFactoryManager" );
     m_pConfigAccess = new ConfigurationAccess_FactoryManager( m_xServiceManager,rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.Factories/Registered/UIElementFactories" )) );
     m_pConfigAccess->acquire();
-    m_xModuleManager = Reference< XModuleManager >( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY );
+    m_xModuleManager = ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) );
 }
 
 UIElementFactoryManager::~UIElementFactoryManager()
@@ -436,7 +437,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::l
             Args[i].Value >>= xFrame;
     }
 
-    Reference< XModuleManager > xManager( m_xModuleManager );
+    Reference< XModuleManager2 > xManager( m_xModuleManager );
     aLock.unlock();
 
     // Determine the module identifier
diff --git a/framework/source/uifactory/windowcontentfactorymanager.cxx b/framework/source/uifactory/windowcontentfactorymanager.cxx
index b9691a5..23c7c97 100644
--- a/framework/source/uifactory/windowcontentfactorymanager.cxx
+++ b/framework/source/uifactory/windowcontentfactorymanager.cxx
@@ -36,6 +36,7 @@
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/awt/XToolkit.hpp>
 #include <com/sun/star/awt/XControlModel.hpp>
@@ -78,7 +79,7 @@ WindowContentFactoryManager::WindowContentFactoryManager( const uno::Reference<
 {
     m_pConfigAccess = new ConfigurationAccess_FactoryManager( m_xServiceManager,rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.WindowContentFactories/Registered/ContentFactories" )) );
     m_pConfigAccess->acquire();
-    m_xModuleManager = uno::Reference< frame::XModuleManager >( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), uno::UNO_QUERY );
+    m_xModuleManager = frame::ModuleManager::create( comphelper::getComponentContext(m_xServiceManager) );
 }
 
 WindowContentFactoryManager::~WindowContentFactoryManager()
@@ -147,7 +148,7 @@ throw (uno::Exception, uno::RuntimeException)
         }
     }
 
-    uno::Reference< frame::XModuleManager > xModuleManager;
+    uno::Reference< frame::XModuleManager2 > xModuleManager;
     // SAFE
     {
         ResetableGuard aLock( m_aLock );
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx
index e5840cc..6374ef3 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -2691,7 +2691,7 @@ uno::Reference< frame::XTitle > OReportDefinition::impl_getTitleHelper_throw()
                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop")) ,m_aProps->m_xContext),uno::UNO_QUERY_THROW);
         uno::Reference< frame::XModel >              xThis   (static_cast< frame::XModel* >(this), uno::UNO_QUERY_THROW);
 
-        ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(uno::Reference< lang::XMultiServiceFactory >(m_aProps->m_xContext->getServiceManager(),uno::UNO_QUERY));
+        ::framework::TitleHelper* pHelper = new ::framework::TitleHelper( m_aProps->m_xContext );
         m_pImpl->m_xTitleHelper = uno::Reference< frame::XTitle >(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW);
         pHelper->setOwner                   (xThis   );
         pHelper->connectWithUntitledNumbers (xDesktop);
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 872bdbc..37180ab 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -3833,12 +3833,13 @@ css::uno::Reference< css::frame::XTitle > SfxBaseModel::impl_getTitleHelper ()
 
     if ( ! m_pData->m_xTitleHelper.is ())
     {
-        css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR   = ::comphelper::getProcessServiceFactory ();
+        css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR    = ::comphelper::getProcessServiceFactory();
+        css::uno::Reference< css::uno::XComponentContext >     xContext = ::comphelper::getProcessComponentContext();
         const ::rtl::OUString SERVICENAME_DESKTOP("com.sun.star.frame.Desktop");
         css::uno::Reference< css::frame::XUntitledNumbers >    xDesktop(xSMGR->createInstance(SERVICENAME_DESKTOP), css::uno::UNO_QUERY_THROW);
         css::uno::Reference< css::frame::XModel >              xThis   (static_cast< css::frame::XModel* >(this), css::uno::UNO_QUERY_THROW);
 
-        ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(xSMGR);
+        ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(xContext);
         m_pData->m_xTitleHelper = css::uno::Reference< css::frame::XTitle >(static_cast< ::cppu::OWeakObject* >(pHelper), css::uno::UNO_QUERY_THROW);
         pHelper->setOwner                   (xThis   );
         pHelper->connectWithUntitledNumbers (xDesktop);
diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx
index 7b315a6..658d887 100644
--- a/sfx2/source/view/sfxbasecontroller.cxx
+++ b/sfx2/source/view/sfxbasecontroller.cxx
@@ -1503,7 +1503,7 @@ css::uno::Reference< css::frame::XTitle > SfxBaseController::impl_getTitleHelper
         css::uno::Reference< css::frame::XUntitledNumbers > xUntitledProvider(xModel                                       , css::uno::UNO_QUERY      );
         css::uno::Reference< css::frame::XController >      xThis            (static_cast< css::frame::XController* >(this), css::uno::UNO_QUERY_THROW);
 
-        ::framework::TitleHelper* pHelper                 = new ::framework::TitleHelper(::comphelper::getProcessServiceFactory());
+        ::framework::TitleHelper* pHelper                 = new ::framework::TitleHelper(::comphelper::getProcessComponentContext());
                                   m_pData->m_xTitleHelper = css::uno::Reference< css::frame::XTitle >(static_cast< ::cppu::OWeakObject* >(pHelper), css::uno::UNO_QUERY_THROW);
 
         pHelper->setOwner                   (xThis            );
commit b493b5a284d5a629d16e733197c7840fb33b469c
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Oct 16 09:45:07 2012 +0200

    fdo#46808, use service constructor for xml::sax::Writer
    
    Change-Id: I2b216a0e3a9694568642e9de2f4f43ecd682555f

diff --git a/framework/inc/framework/statusbarconfiguration.hxx b/framework/inc/framework/statusbarconfiguration.hxx
index 2c405c7..5204e67 100644
--- a/framework/inc/framework/statusbarconfiguration.hxx
+++ b/framework/inc/framework/statusbarconfiguration.hxx
@@ -50,7 +50,7 @@ class FWE_DLLPUBLIC StatusBarConfiguration
             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& rStatusbarConfiguration );
 
         static sal_Bool StoreStatusBar(
-            const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
+            const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream,
             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rStatusbarConfiguration );
 };
diff --git a/framework/inc/framework/toolboxconfiguration.hxx b/framework/inc/framework/toolboxconfiguration.hxx
index 1e31bbb..b8282bc 100644
--- a/framework/inc/framework/toolboxconfiguration.hxx
+++ b/framework/inc/framework/toolboxconfiguration.hxx
@@ -42,7 +42,7 @@ class FWE_DLLPUBLIC ToolBoxConfiguration
             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& rToolbarConfiguration );
 
         static sal_Bool StoreToolBox(
-            const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
+            const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream,
             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rToolbarConfiguration );
 };
diff --git a/framework/inc/services.h b/framework/inc/services.h
index 70956ec..0b79215 100644
--- a/framework/inc/services.h
+++ b/framework/inc/services.h
@@ -80,7 +80,6 @@ namespace framework{
 #define SERVICENAME_GLOBALACCELERATORCONFIGURATION              DECLARE_ASCII("com.sun.star.ui.GlobalAcceleratorConfiguration")
 #define SERVICENAME_MODULEACCELERATORCONFIGURATION              DECLARE_ASCII("com.sun.star.ui.ModuleAcceleratorConfiguration")
 #define SERVICENAME_DOCUMENTACCELERATORCONFIGURATION            DECLARE_ASCII("com.sun.star.ui.DocumentAcceleratorConfiguration")
-#define SERVICENAME_SAXWRITER                                   DECLARE_ASCII("com.sun.star.xml.sax.Writer"                         )
 #define SERVICENAME_STORAGEFACTORY                              DECLARE_ASCII("com.sun.star.embed.StorageFactory"                   )
 #define SERVICENAME_FILESYSTEMSTORAGEFACTORY                    DECLARE_ASCII("com.sun.star.embed.FileSystemStorageFactory"         )
 #define SERVICENAME_TEMPFILE                                    DECLARE_ASCII("com.sun.star.io.TempFile"                            )
diff --git a/framework/inc/xml/imagesconfiguration.hxx b/framework/inc/xml/imagesconfiguration.hxx
index eda31f4..d08c3b1 100644
--- a/framework/inc/xml/imagesconfiguration.hxx
+++ b/framework/inc/xml/imagesconfiguration.hxx
@@ -106,7 +106,7 @@ class ImagesConfiguration
             ImageListsDescriptor& rItems );
 
         static sal_Bool StoreImages(
-            const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
+            const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream,
             const ImageListsDescriptor& rItems );
 };
diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx
index fa010e7..8becd7d 100644
--- a/framework/source/accelerators/acceleratorconfiguration.cxx
+++ b/framework/source/accelerators/acceleratorconfiguration.cxx
@@ -43,6 +43,7 @@
 
 #include <com/sun/star/xml/sax/Parser.hpp>
 #include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/xml/sax/Writer.hpp>
 #include <com/sun/star/io/XActiveDataSource.hpp>
 #include <com/sun/star/embed/ElementModes.hpp>
 #include <com/sun/star/io/XSeekable.hpp>
@@ -562,12 +563,12 @@ void XMLBasedAcceleratorConfiguration::impl_ts_save(const css::uno::Reference< c
         xSeek->seek(0);
 
     // combine writer/cache/stream etcpp.
-    css::uno::Reference< css::xml::sax::XDocumentHandler > xWriter    (xSMGR->createInstance(SERVICENAME_SAXWRITER), css::uno::UNO_QUERY_THROW);
-    css::uno::Reference< css::io::XActiveDataSource>       xDataSource(xWriter                                     , css::uno::UNO_QUERY_THROW);
-    xDataSource->setOutputStream(xStream);
+    css::uno::Reference< css::xml::sax::XWriter > xWriter = css::xml::sax::Writer::create(comphelper::getComponentContext(xSMGR));
+    xWriter->setOutputStream(xStream);
 
     // write into the stream
-    AcceleratorConfigurationWriter aWriter(aCache, xWriter);
+    css::uno::Reference< css::xml::sax::XDocumentHandler > xHandler(xWriter, css::uno::UNO_QUERY_THROW);
+    AcceleratorConfigurationWriter aWriter(aCache, xHandler);
     aWriter.flush();
 
     // take over all changes into the original container
@@ -1111,12 +1112,12 @@ void SAL_CALL XCUBasedAcceleratorConfiguration::storeToStorage(const css::uno::R
     if (xSeek.is())
         xSeek->seek(0);
 
-    css::uno::Reference< css::xml::sax::XDocumentHandler > xWriter    (m_xSMGR->createInstance(SERVICENAME_SAXWRITER), css::uno::UNO_QUERY_THROW);
-    css::uno::Reference< css::io::XActiveDataSource>       xDataSource(xWriter                                     , css::uno::UNO_QUERY_THROW);
-    xDataSource->setOutputStream(xOut);
+    css::uno::Reference< css::xml::sax::XWriter > xWriter = css::xml::sax::Writer::create(comphelper::getComponentContext(m_xSMGR));
+    xWriter->setOutputStream(xOut);
 
     // write into the stream
-    AcceleratorConfigurationWriter aWriter(aCache, xWriter);
+    css::uno::Reference< css::xml::sax::XDocumentHandler > xHandler(xWriter, css::uno::UNO_QUERY_THROW);
+    AcceleratorConfigurationWriter aWriter(aCache, xHandler);
     aWriter.flush();
 }
 
diff --git a/framework/source/fwe/xml/menuconfiguration.cxx b/framework/source/fwe/xml/menuconfiguration.cxx
index c47e52d..e5a5922 100644
--- a/framework/source/fwe/xml/menuconfiguration.cxx
+++ b/framework/source/fwe/xml/menuconfiguration.cxx
@@ -37,6 +37,7 @@
 #include <uielement/rootitemcontainer.hxx>
 
 #include <com/sun/star/xml/sax/Parser.hpp>
+#include <com/sun/star/xml/sax/Writer.hpp>
 #include <com/sun/star/io/XActiveDataSource.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
 #include <comphelper/processfactory.hxx>
@@ -129,17 +130,13 @@ void MenuConfiguration::StoreMenuBarConfigurationToXML(
     Reference< XOutputStream >& rOutputStream )
 throw ( WrappedTargetException )
 {
-    Reference< XDocumentHandler > xWriter;
-
-    xWriter = Reference< XDocumentHandler >( m_rxServiceManager->createInstance(
-            SERVICENAME_SAXWRITER), UNO_QUERY) ;
-
-    Reference< XActiveDataSource> xDataSource( xWriter , UNO_QUERY );
-    xDataSource->setOutputStream( rOutputStream );
+    Reference< XWriter > xWriter = Writer::create(comphelper::getComponentContext(m_rxServiceManager));
+    xWriter->setOutputStream( rOutputStream );
 
     try
     {
-        OWriteMenuDocumentHandler aWriteMenuDocumentHandler( rMenuBarConfiguration, xWriter );
+        Reference< XDocumentHandler > xHandler(xWriter, UNO_QUERY_THROW);
+        OWriteMenuDocumentHandler aWriteMenuDocumentHandler( rMenuBarConfiguration, xHandler );
         aWriteMenuDocumentHandler.WriteMenuDocument();
     }
     catch ( const RuntimeException& e )
diff --git a/framework/source/fwe/xml/statusbarconfiguration.cxx b/framework/source/fwe/xml/statusbarconfiguration.cxx
index 2b24554..521ad09 100644
--- a/framework/source/fwe/xml/statusbarconfiguration.cxx
+++ b/framework/source/fwe/xml/statusbarconfiguration.cxx
@@ -33,6 +33,7 @@
 #include <services.h>
 
 #include <com/sun/star/xml/sax/Parser.hpp>
+#include <com/sun/star/xml/sax/Writer.hpp>
 #include <com/sun/star/io/XActiveDataSource.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -50,26 +51,12 @@ using namespace ::com::sun::star::container;
 namespace framework
 {
 
-static Reference< XParser > GetSaxParser(
-    const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext
-    )
-{
-    return Parser::create( xContext );
-}
-
-static Reference< XDocumentHandler > GetSaxWriter(
-    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory
-    )
-{
-    return Reference< XDocumentHandler >( xServiceFactory->createInstance( SERVICENAME_SAXWRITER), UNO_QUERY) ;
-}
-
 sal_Bool StatusBarConfiguration::LoadStatusBar(
     const Reference< XComponentContext >& rxContext,
     const Reference< XInputStream >& xInputStream,
     const Reference< XIndexContainer >& rStatusbarConfiguration )
 {
-    Reference< XParser > xParser( GetSaxParser( rxContext ) );
+    Reference< XParser > xParser = Parser::create(rxContext);
 
     // connect stream to input stream to the parser
     InputSource aInputSource;
@@ -102,17 +89,17 @@ sal_Bool StatusBarConfiguration::LoadStatusBar(
 }
 
 sal_Bool StatusBarConfiguration::StoreStatusBar(
-    const Reference< XMultiServiceFactory >& xServiceFactory,
+    const Reference< XComponentContext >& rxContext,
     const Reference< XOutputStream >& xOutputStream,
     const Reference< XIndexAccess >& rStatusbarConfiguration )
 {
-    Reference< XDocumentHandler > xWriter( GetSaxWriter( xServiceFactory ) );
-    Reference< ::com::sun::star::io::XActiveDataSource> xDataSource( xWriter , UNO_QUERY );
-    xDataSource->setOutputStream( xOutputStream );
+    Reference< XWriter > xWriter = Writer::create( rxContext );
+    xWriter->setOutputStream( xOutputStream );
 
     try
     {
-        OWriteStatusBarDocumentHandler aWriteStatusBarDocumentHandler( rStatusbarConfiguration, xWriter );
+        Reference< XDocumentHandler > xHandler(xWriter, UNO_QUERY_THROW);
+        OWriteStatusBarDocumentHandler aWriteStatusBarDocumentHandler( rStatusbarConfiguration, xHandler );
         aWriteStatusBarDocumentHandler.WriteStatusBarDocument();
         return sal_True;
     }
diff --git a/framework/source/fwe/xml/toolboxconfiguration.cxx b/framework/source/fwe/xml/toolboxconfiguration.cxx
index dcc7d48..1fe48cb 100644
--- a/framework/source/fwe/xml/toolboxconfiguration.cxx
+++ b/framework/source/fwe/xml/toolboxconfiguration.cxx
@@ -33,6 +33,7 @@
 #include <services.h>
 
 #include <com/sun/star/xml/sax/Parser.hpp>
+#include <com/sun/star/xml/sax/Writer.hpp>
 #include <com/sun/star/io/XActiveDataSource.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -50,26 +51,12 @@ using namespace ::com::sun::star::container;
 namespace framework
 {
 
-static Reference< XParser > GetSaxParser(
-    const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext
-    )
-{
-    return Parser::create(rxContext);
-}
-
-static Reference< XDocumentHandler > GetSaxWriter(
-    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory
-    )
-{
-    return Reference< XDocumentHandler >( xServiceFactory->createInstance( SERVICENAME_SAXWRITER), UNO_QUERY) ;
-}
-
 sal_Bool ToolBoxConfiguration::LoadToolBox(
     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
     const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rInputStream,
     const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& rToolbarConfiguration )
 {
-    Reference< XParser > xParser( GetSaxParser( rxContext ) );
+    Reference< XParser > xParser = Parser::create(rxContext);
 
     // connect stream to input stream to the parser
     InputSource aInputSource;
@@ -104,18 +91,17 @@ sal_Bool ToolBoxConfiguration::LoadToolBox(
 
 
 sal_Bool ToolBoxConfiguration::StoreToolBox(
-    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
+    const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
     const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream,
     const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rToolbarConfiguration )
 {
-    Reference< XDocumentHandler > xWriter( GetSaxWriter( xServiceFactory ) );
-
-    Reference< ::com::sun::star::io::XActiveDataSource> xDataSource( xWriter , UNO_QUERY );
-    xDataSource->setOutputStream( rOutputStream );
+    Reference< XWriter > xWriter = Writer::create(rxContext);
+    xWriter->setOutputStream( rOutputStream );
 
     try
     {
-        OWriteToolBoxDocumentHandler aWriteToolBoxDocumentHandler( rToolbarConfiguration, xWriter );
+        Reference< XDocumentHandler > xHandler( xWriter, UNO_QUERY_THROW );
+        OWriteToolBoxDocumentHandler aWriteToolBoxDocumentHandler( rToolbarConfiguration, xHandler );
         aWriteToolBoxDocumentHandler.WriteToolBoxDocument();
         return sal_True;
     }
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx
index 3e3b503..c6f3389 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.cxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx
@@ -614,7 +614,7 @@ sal_Bool ImageManagerImpl::implts_storeUserImages(
 
                 xOutputStream = xStream->getOutputStream();
                 if ( xOutputStream.is() )
-                    ImagesConfiguration::StoreImages( m_xServiceManager, xOutputStream, aUserImageListInfo );
+                    ImagesConfiguration::StoreImages( comphelper::getComponentContext(m_xServiceManager), xOutputStream, aUserImageListInfo );
 
                 // Commit user image storage
                 xTransaction = uno::Reference< XTransactedObject >( xUserImageStorage, UNO_QUERY );
diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
index 2a6b451..85a4428 100644
--- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
@@ -468,7 +468,7 @@ void ModuleUIConfigurationManager::impl_storeElementTypeData( Reference< XStorag
                         {
                             try
                             {
-                                ToolBoxConfiguration::StoreToolBox( m_xServiceManager, xOutputStream, rElement.xSettings );
+                                ToolBoxConfiguration::StoreToolBox( comphelper::getComponentContext(m_xServiceManager), xOutputStream, rElement.xSettings );
                             }
                             catch ( const ::com::sun::star::lang::WrappedTargetException& )
                             {
@@ -480,7 +480,7 @@ void ModuleUIConfigurationManager::impl_storeElementTypeData( Reference< XStorag
                         {
                             try
                             {
-                                StatusBarConfiguration::StoreStatusBar( m_xServiceManager, xOutputStream, rElement.xSettings );
+                                StatusBarConfiguration::StoreStatusBar( comphelper::getComponentContext(m_xServiceManager), xOutputStream, rElement.xSettings );
                             }
                             catch ( const ::com::sun::star::lang::WrappedTargetException& )
                             {
diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
index f19853f..6ca9126 100644
--- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
@@ -397,7 +397,7 @@ void UIConfigurationManager::impl_storeElementTypeData( Reference< XStorage >& x
                         {
                             try
                             {
-                                ToolBoxConfiguration::StoreToolBox( m_xServiceManager, xOutputStream, rElement.xSettings );
+                                ToolBoxConfiguration::StoreToolBox( comphelper::getComponentContext(m_xServiceManager), xOutputStream, rElement.xSettings );
                             }
                             catch ( const ::com::sun::star::lang::WrappedTargetException& )
                             {
@@ -409,7 +409,7 @@ void UIConfigurationManager::impl_storeElementTypeData( Reference< XStorage >& x
                         {
                             try
                             {
-                                StatusBarConfiguration::StoreStatusBar( m_xServiceManager, xOutputStream, rElement.xSettings );
+                                StatusBarConfiguration::StoreStatusBar( comphelper::getComponentContext(m_xServiceManager), xOutputStream, rElement.xSettings );
                             }
                             catch ( const ::com::sun::star::lang::WrappedTargetException& )
                             {
diff --git a/framework/source/xml/imagesconfiguration.cxx b/framework/source/xml/imagesconfiguration.cxx
index 622b45f..c65c46c 100644
--- a/framework/source/xml/imagesconfiguration.cxx
+++ b/framework/source/xml/imagesconfiguration.cxx
@@ -34,6 +34,7 @@
 #include <xml/saxnamespacefilter.hxx>
 
 #include <com/sun/star/xml/sax/Parser.hpp>
+#include <com/sun/star/xml/sax/Writer.hpp>
 #include <com/sun/star/io/XActiveDataSource.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -50,26 +51,12 @@ using namespace ::com::sun::star::io;
 namespace framework
 {
 
-static Reference< XParser > GetSaxParser(
-    const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext
-    )
-{
-    return Parser::create(rxContext);
-}
-
-static Reference< XDocumentHandler > GetSaxWriter(
-    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory
-    )
-{
-    return Reference< XDocumentHandler >( xServiceFactory->createInstance( SERVICENAME_SAXWRITER), UNO_QUERY) ;
-}
-
 sal_Bool ImagesConfiguration::LoadImages(
     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
     const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rInputStream,
     ImageListsDescriptor& rItems )
 {
-    Reference< XParser > xParser( GetSaxParser( rxContext ) );
+    Reference< XParser > xParser = Parser::create( rxContext );
 
     // connect stream to input stream to the parser
     InputSource aInputSource;
@@ -103,18 +90,17 @@ sal_Bool ImagesConfiguration::LoadImages(
 }
 
 sal_Bool ImagesConfiguration::StoreImages(
-    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
+    const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
     const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream,
     const ImageListsDescriptor& rItems )
 {
-    Reference< XDocumentHandler > xWriter( GetSaxWriter( xServiceFactory ) );
-
-    Reference< ::com::sun::star::io::XActiveDataSource> xDataSource( xWriter , UNO_QUERY );
-    xDataSource->setOutputStream( rOutputStream );
+    Reference< XWriter > xWriter = Writer::create(rxContext);
+    xWriter->setOutputStream( rOutputStream );
 
     try
     {
-        OWriteImagesDocumentHandler aWriteImagesDocumentHandler( rItems, xWriter );
+        Reference< XDocumentHandler > xHandler( xWriter, UNO_QUERY_THROW );
+        OWriteImagesDocumentHandler aWriteImagesDocumentHandler( rItems, xHandler );
         aWriteImagesDocumentHandler.WriteImagesDocument();
         return sal_True;
     }


More information about the Libreoffice-commits mailing list