[Libreoffice-commits] core.git: 4 commits - desktop/source framework/inc framework/source framework/util offapi/com offapi/UnoApi_offapi.mk sfx2/inc sfx2/source

Matúš Kukan matus.kukan at collabora.com
Wed Jan 29 02:46:53 PST 2014


 desktop/source/app/app.cxx                                    |    9 
 framework/inc/pch/precompiled_fwk.hxx                         |    8 
 framework/inc/uifactory/configurationaccessfactorymanager.hxx |   86 +++
 framework/inc/uifactory/uicontrollerfactory.hxx               |  101 ---
 framework/inc/uifactory/uielementfactorymanager.hxx           |  133 ----
 framework/source/layoutmanager/layoutmanager.cxx              |    4 
 framework/source/register/registerservices.cxx                |    6 
 framework/source/uielement/menubarmanager.cxx                 |    6 
 framework/source/uielement/popuptoolbarcontroller.cxx         |    4 
 framework/source/uielement/statusbarmanager.cxx               |    4 
 framework/source/uielement/toolbarmanager.cxx                 |    4 
 framework/source/uifactory/uicontrollerfactory.cxx            |  279 ++++++++--
 framework/source/uifactory/uielementfactorymanager.cxx        |  201 ++++---
 framework/source/uifactory/windowcontentfactorymanager.cxx    |    8 
 framework/util/fwk.component                                  |   16 
 offapi/UnoApi_offapi.mk                                       |    4 
 offapi/com/sun/star/frame/PopupMenuControllerFactory.idl      |    9 
 offapi/com/sun/star/frame/StatusbarControllerFactory.idl      |   12 
 offapi/com/sun/star/frame/ToolbarControllerFactory.idl        |    7 
 offapi/com/sun/star/frame/thePopupMenuControllerFactory.idl   |   46 +
 offapi/com/sun/star/frame/theStatusbarControllerFactory.idl   |   47 +
 offapi/com/sun/star/frame/theToolbarControllerFactory.idl     |   41 +
 offapi/com/sun/star/ui/UIElementFactoryManager.idl            |    8 
 offapi/com/sun/star/ui/theUIElementFactoryManager.idl         |   44 +
 sfx2/inc/pch/precompiled_sfx.hxx                              |    4 
 sfx2/source/dialog/taskpane.cxx                               |    6 
 sfx2/source/sidebar/ControllerFactory.cxx                     |    4 
 sfx2/source/sidebar/SidebarController.cxx                     |    4 
 sfx2/source/toolbox/tbxitem.cxx                               |    4 
 29 files changed, 683 insertions(+), 426 deletions(-)

New commits:
commit a64c6c448dcc47c58cb839cc97b7bfc941b784fc
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Thu Jan 9 17:10:15 2014 +0100

    fwk: Constructor feature for single-instance UIElementFactoryManager.
    
    Change-Id: Iaa6b6bf8f132e2f8efb9ae71e9302e6be19347c9

diff --git a/framework/inc/uifactory/uielementfactorymanager.hxx b/framework/inc/uifactory/configurationaccessfactorymanager.hxx
similarity index 54%
rename from framework/inc/uifactory/uielementfactorymanager.hxx
rename to framework/inc/uifactory/configurationaccessfactorymanager.hxx
index 5e5f563..36aae57 100644
--- a/framework/inc/uifactory/uielementfactorymanager.hxx
+++ b/framework/inc/uifactory/configurationaccessfactorymanager.hxx
@@ -20,37 +20,18 @@
 #ifndef INCLUDED_FRAMEWORK_INC_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX
 #define INCLUDED_FRAMEWORK_INC_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX
 
-/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble
-               with solaris headers ...
-*/
-#include <vector>
-#include <list>
-
-#include <threadhelp/threadhelpbase.hxx>
-#include <macros/generic.hxx>
-#include <macros/xinterface.hxx>
-#include <macros/xtypeprovider.hxx>
-#include <macros/xserviceinfo.hxx>
-#include <stdtypes.h>
-
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/ui/XUIElementFactoryManager.hpp>
+#include <sal/config.h>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/container/XContainerListener.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
-#include "com/sun/star/frame/XModuleManager2.hpp"
 
 #include <cppuhelper/implbase1.hxx>
-#include <cppuhelper/implbase2.hxx>
 #include <rtl/ustring.hxx>
 
-namespace framework
-{
+namespace framework {
 
-    class ConfigurationAccess_FactoryManager : // interfaces
-                                                    // baseclasses
-                                                    // Order is necessary for right initialization!
-                                                    private ThreadHelpBase                           ,
-                                                    public  ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener>
+    class ConfigurationAccess_FactoryManager : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener>
 {
     public:
                       ConfigurationAccess_FactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& rxContext, const OUString& _sRoot );
@@ -85,6 +66,7 @@ namespace framework
 
         sal_Bool impl_getElementProps( const ::com::sun::star::uno::Any& rElement, OUString& rType, OUString& rName, OUString& rModule, OUString& rServiceSpecifier ) const;
 
+        mutable osl::Mutex m_aMutex;
         OUString                     m_aPropType;
         OUString                     m_aPropName;
         OUString                     m_aPropModule;
@@ -97,35 +79,6 @@ namespace framework
         sal_Bool                          m_bConfigAccessInitialized;
 };
 
-
-class UIElementFactoryManager :  private ThreadHelpBase                                             ,   // Struct for right initalization of mutex member! Must be first of baseclasses.
-                                 public ::cppu::WeakImplHelper2< ::com::sun::star::lang::XServiceInfo,
-                                                                 ::com::sun::star::ui::XUIElementFactoryManager>
-{
-    public:
-        UIElementFactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
-        virtual ~UIElementFactoryManager();
-
-        //  XInterface, XTypeProvider, XServiceInfo
-        DECLARE_XSERVICEINFO
-
-        // XUIElementFactory
-        virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Args ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
-
-        // XUIElementFactoryRegistration
-        virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getRegisteredFactories(  ) throw (::com::sun::star::uno::RuntimeException);
-        virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElementFactory > SAL_CALL getFactory( const OUString& ResourceURL, const OUString& ModuleIdentifier ) throw (::com::sun::star::uno::RuntimeException);
-        virtual void SAL_CALL registerFactory( const OUString& aType, const OUString& aName, const OUString& aModuleIdentifier, const OUString& aFactoryImplementationName ) throw (::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
-        virtual void SAL_CALL deregisterFactory( const OUString& aType, const OUString& aName, const OUString& aModuleIdentifier ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
-
-    private:
-
-        sal_Bool                                                                            m_bConfigRead;
-        ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >        m_xContext;
-        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >        m_xModuleManager;
-        ConfigurationAccess_FactoryManager*                                        m_pConfigAccess;
-};
-
 } // namespace framework
 
 #endif // INCLUDED_FRAMEWORK_INC_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX
diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx
index a1c0018..14dc4ce 100644
--- a/framework/source/register/registerservices.cxx
+++ b/framework/source/register/registerservices.cxx
@@ -34,7 +34,6 @@
                              )
 =================================================================================================================*/
 #include <services/desktop.hxx>
-#include <uifactory/uielementfactorymanager.hxx>
 #include <uiconfiguration/moduleuicfgsupplier.hxx>
 #include <uifactory/menubarfactory.hxx>
 #include <uifactory/toolboxfactory.hxx>
@@ -49,7 +48,6 @@
 
 COMPONENTGETFACTORY ( fwk,
                         IFFACTORY( ::framework::Desktop                                 )   else
-                        IFFACTORY( ::framework::UIElementFactoryManager                 )   else
                         IFFACTORY( ::framework::ModuleUIConfigurationManagerSupplier    )   else
                         IFFACTORY( ::framework::MenuBarFactory                          )   else
                         IFFACTORY( ::framework::ToolBoxFactory                          )   else
diff --git a/framework/source/uifactory/uielementfactorymanager.cxx b/framework/source/uifactory/uielementfactorymanager.cxx
index d1dd274..28ef238 100644
--- a/framework/source/uifactory/uielementfactorymanager.cxx
+++ b/framework/source/uifactory/uielementfactorymanager.cxx
@@ -17,30 +17,28 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <uifactory/uielementfactorymanager.hxx>
-#include <uifactory/windowcontentfactorymanager.hxx>
-#include <threadhelp/resetableguard.hxx>
-#include "services.h"
+#include <sal/config.h>
 
-#include "helper/mischelper.hxx"
+#include <uifactory/windowcontentfactorymanager.hxx>
+#include <uifactory/configurationaccessfactorymanager.hxx>
+#include <helper/mischelper.hxx>
 
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/configuration/theDefaultProvider.hpp>
-#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/container/XContainerListener.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
+#include <com/sun/star/ui/XUIElementFactoryManager.hpp>
 
 #include <rtl/ustrbuf.hxx>
-#include <cppuhelper/weak.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/supportsservice.hxx>
 #include <vcl/svapp.hxx>
 
-//_________________________________________________________________________________________________________________
-//  Defines
-//_________________________________________________________________________________________________________________
-
 using namespace com::sun::star::uno;
 using namespace com::sun::star::lang;
 using namespace com::sun::star::beans;
@@ -49,16 +47,13 @@ using namespace com::sun::star::configuration;
 using namespace com::sun::star::container;
 using namespace ::com::sun::star::ui;
 using namespace ::com::sun::star::frame;
-
-//_________________________________________________________________________________________________________________
-//  Namespace
-//_________________________________________________________________________________________________________________
+using namespace framework;
 
 namespace framework
 {
 
 // global function needed by both implementations
-OUString getHashKeyFromStrings( const OUString& aType, const OUString& aName, const OUString& aModuleName )
+static OUString getHashKeyFromStrings( const OUString& aType, const OUString& aName, const OUString& aModuleName )
 {
     OUStringBuffer aKey( aType );
     aKey.appendAscii( "^" );
@@ -69,13 +64,7 @@ OUString getHashKeyFromStrings( const OUString& aType, const OUString& aName, co
 }
 
 
-//*****************************************************************************************************************
-//  Configuration access class for UIElementFactoryManager implementation
-//*****************************************************************************************************************
-
-
 ConfigurationAccess_FactoryManager::ConfigurationAccess_FactoryManager( const Reference< XComponentContext >& rxContext, const OUString& _sRoot ) :
-    ThreadHelpBase(),
     m_aPropType( "Type" ),
     m_aPropName( "Name" ),
     m_aPropModule( "Module" ),
@@ -89,7 +78,7 @@ ConfigurationAccess_FactoryManager::ConfigurationAccess_FactoryManager( const Re
 ConfigurationAccess_FactoryManager::~ConfigurationAccess_FactoryManager()
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
 
     Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
     if ( xContainer.is() )
@@ -99,7 +88,7 @@ ConfigurationAccess_FactoryManager::~ConfigurationAccess_FactoryManager()
 OUString ConfigurationAccess_FactoryManager::getFactorySpecifierFromTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule ) const
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
 
     FactoryManagerMap::const_iterator pIter =
         m_aFactoryManagerMap.find( getHashKeyFromStrings( rType, rName, rModule ));
@@ -134,7 +123,7 @@ OUString ConfigurationAccess_FactoryManager::getFactorySpecifierFromTypeNameModu
 void ConfigurationAccess_FactoryManager::addFactorySpecifierToTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule, const OUString& rServiceSpecifier )
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
 
     OUString aHashKey = getHashKeyFromStrings( rType, rName, rModule );
 
@@ -150,7 +139,7 @@ void ConfigurationAccess_FactoryManager::addFactorySpecifierToTypeNameModule( co
 void ConfigurationAccess_FactoryManager::removeFactorySpecifierFromTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule )
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
 
     OUString aHashKey = getHashKeyFromStrings( rType, rName, rModule );
 
@@ -165,7 +154,7 @@ void ConfigurationAccess_FactoryManager::removeFactorySpecifierFromTypeNameModul
 Sequence< Sequence< PropertyValue > > ConfigurationAccess_FactoryManager::getFactoriesDescription() const
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
 
     Sequence< Sequence< PropertyValue > > aSeqSeq;
 
@@ -213,7 +202,7 @@ void SAL_CALL ConfigurationAccess_FactoryManager::elementInserted( const Contain
     OUString   aService;
 
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
 
     if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
     {
@@ -232,7 +221,7 @@ void SAL_CALL ConfigurationAccess_FactoryManager::elementRemoved ( const Contain
     OUString   aService;
 
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
 
     if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
     {
@@ -251,7 +240,7 @@ void SAL_CALL ConfigurationAccess_FactoryManager::elementReplaced( const Contain
     OUString   aService;
 
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
 
     if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
     {
@@ -268,14 +257,14 @@ void SAL_CALL ConfigurationAccess_FactoryManager::disposing( const EventObject&
 {
     // SAFE
     // remove our reference to the config access
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
     m_xConfigAccess.clear();
 }
 
 void ConfigurationAccess_FactoryManager::readConfigurationData()
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
 
     if ( !m_bConfigAccessInitialized )
     {
@@ -288,7 +277,8 @@ void ConfigurationAccess_FactoryManager::readConfigurationData()
 
         try
         {
-            m_xConfigAccess.set( m_xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,aArgs ), UNO_QUERY );
+            m_xConfigAccess.set( m_xConfigProvider->createInstanceWithArguments(
+                        "com.sun.star.configuration.ConfigurationAccess", aArgs ), UNO_QUERY );
         }
         catch ( const WrappedTargetException& )
         {
@@ -319,8 +309,6 @@ void ConfigurationAccess_FactoryManager::readConfigurationData()
         }
 
         Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
-        aLock.unlock();
-        // UNSAFE
         if ( xContainer.is() )
         {
             m_xConfigListener = new WeakContainerListener(this);
@@ -356,33 +344,81 @@ sal_Bool ConfigurationAccess_FactoryManager::impl_getElementProps( const Any& aE
     return sal_True;
 }
 
-//*****************************************************************************************************************
-//  XInterface, XTypeProvider, XServiceInfo
-//*****************************************************************************************************************
-DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2  (   UIElementFactoryManager                         ,
-                                            ::cppu::OWeakObject                             ,
-                                            "com.sun.star.ui.UIElementFactoryManager",
-                                            IMPLEMENTATIONNAME_UIELEMENTFACTORYMANAGER
-                                        )
+} // framework
+
+namespace {
+
+typedef ::cppu::WeakComponentImplHelper2<
+    css::lang::XServiceInfo,
+    css::ui::XUIElementFactoryManager> UIElementFactoryManager_BASE;
+
+class UIElementFactoryManager : private osl::Mutex,
+                                public UIElementFactoryManager_BASE
+{
+    virtual void SAL_CALL disposing() SAL_OVERRIDE;
+public:
+    UIElementFactoryManager( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
+    virtual ~UIElementFactoryManager();
+
+    virtual OUString SAL_CALL getImplementationName()
+        throw (css::uno::RuntimeException)
+    {
+        return OUString("com.sun.star.comp.framework.UIElementFactoryManager");
+    }
+
+    virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
+        throw (css::uno::RuntimeException)
+    {
+        return cppu::supportsService(this, ServiceName);
+    }
+
+    virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
+        throw (css::uno::RuntimeException)
+    {
+        css::uno::Sequence< OUString > aSeq(1);
+        aSeq[0] = OUString("com.sun.star.ui.UIElementFactoryManager");
+        return aSeq;
+    }
+
+    // XUIElementFactory
+    virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const css::uno::Sequence< css::beans::PropertyValue >& Args ) throw (css::container::NoSuchElementException, css::lang::IllegalArgumentException, css::uno::RuntimeException);
 
-DEFINE_INIT_SERVICE                     (   UIElementFactoryManager, {} )
+    // XUIElementFactoryRegistration
+    virtual css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > SAL_CALL getRegisteredFactories(  ) throw (css::uno::RuntimeException);
+    virtual css::uno::Reference< css::ui::XUIElementFactory > SAL_CALL getFactory( const OUString& ResourceURL, const OUString& ModuleIdentifier ) throw (css::uno::RuntimeException);
+    virtual void SAL_CALL registerFactory( const OUString& aType, const OUString& aName, const OUString& aModuleIdentifier, const OUString& aFactoryImplementationName ) throw (css::container::ElementExistException, css::uno::RuntimeException);
+    virtual void SAL_CALL deregisterFactory( const OUString& aType, const OUString& aName, const OUString& aModuleIdentifier ) throw (css::container::NoSuchElementException, css::uno::RuntimeException);
+
+private:
+    sal_Bool                                                  m_bConfigRead;
+    css::uno::Reference< css::uno::XComponentContext >        m_xContext;
+    ConfigurationAccess_FactoryManager*                       m_pConfigAccess;
+};
 
 UIElementFactoryManager::UIElementFactoryManager( const Reference< XComponentContext >& rxContext ) :
-    ThreadHelpBase( &Application::GetSolarMutex() ),
+    UIElementFactoryManager_BASE(*static_cast<osl::Mutex *>(this)),
     m_bConfigRead( sal_False ),
     m_xContext(rxContext)
 {
-    m_pConfigAccess = new ConfigurationAccess_FactoryManager( rxContext, OUString( "/org.openoffice.Office.UI.Factories/Registered/UIElementFactories" ) );
+    m_pConfigAccess = new ConfigurationAccess_FactoryManager(rxContext,
+            "/org.openoffice.Office.UI.Factories/Registered/UIElementFactories");
     m_pConfigAccess->acquire();
-    m_xModuleManager = ModuleManager::create( rxContext );
 }
 
 UIElementFactoryManager::~UIElementFactoryManager()
 {
-    ResetableGuard aLock( m_aLock );
+    disposing();
+}
 
-    // reduce reference count
-    m_pConfigAccess->release();
+void SAL_CALL UIElementFactoryManager::disposing()
+{
+    osl::MutexGuard g(rBHelper.rMutex);
+    if (m_pConfigAccess)
+    {
+        // reduce reference count
+        m_pConfigAccess->release();
+        m_pConfigAccess = 0;
+    }
 }
 
 // XUIElementFactory
@@ -391,8 +427,9 @@ Reference< XUIElement > SAL_CALL UIElementFactoryManager::createUIElement(
     const Sequence< PropertyValue >& Args )
 throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
 {
-    // SAFE
-    ResetableGuard aLock( m_aLock );
+    Reference< XFrame > xFrame;
+    { // SAFE
+    osl::MutexGuard g(rBHelper.rMutex);
 
     if ( !m_bConfigRead )
     {
@@ -400,27 +437,22 @@ throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::l
         m_pConfigAccess->readConfigurationData();
     }
 
-    const OUString aPropFrame( "Frame" );
-
-    OUString   aModuleId;
-    PropertyValue   aPropValue;
-    Reference< XFrame > xFrame;
-
     // Retrieve the frame instance from the arguments to determine the module identifier. This must be provided
     // to the search function. An empty module identifier is provided if the frame is missing or the module id cannot
     // retrieve from it.
     for ( int i = 0; i < Args.getLength(); i++ )
     {
-        if ( Args[i].Name.equals( aPropFrame ))
+        if ( Args[i].Name == "Frame")
             Args[i].Value >>= xFrame;
     }
+    } // SAFE
 
-    Reference< XModuleManager2 > xManager( m_xModuleManager );
-    aLock.unlock();
+    Reference< XModuleManager2 > xManager = ModuleManager::create( m_xContext );
 
     // Determine the module identifier
     try
     {
+        OUString aModuleId;
         if ( xFrame.is() && xManager.is() )
             aModuleId = xManager->identify( xFrame );
 
@@ -440,7 +472,7 @@ Sequence< Sequence< PropertyValue > > SAL_CALL UIElementFactoryManager::getRegis
 throw ( RuntimeException )
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(rBHelper.rMutex);
 
     if ( !m_bConfigRead )
     {
@@ -454,7 +486,9 @@ throw ( RuntimeException )
 Reference< XUIElementFactory > SAL_CALL UIElementFactoryManager::getFactory( const OUString& aResourceURL, const OUString& aModuleId )
 throw ( RuntimeException )
 {
-    ResetableGuard aLock( m_aLock );
+    OUString aServiceSpecifier;
+    { // SAFE
+    osl::MutexGuard g(rBHelper.rMutex);
 
     if ( !m_bConfigRead )
     {
@@ -467,13 +501,11 @@ throw ( RuntimeException )
 
     WindowContentFactoryManager::RetrieveTypeNameFromResourceURL( aResourceURL, aType, aName );
 
-    Reference< XComponentContext > xContext( m_xContext );
+    aServiceSpecifier = m_pConfigAccess->getFactorySpecifierFromTypeNameModule( aType, aName, aModuleId );
+    } // SAFE
 
-    OUString aServiceSpecifier = m_pConfigAccess->getFactorySpecifierFromTypeNameModule( aType, aName, aModuleId );
-
-    aLock.unlock();
     if ( !aServiceSpecifier.isEmpty() )
-        return Reference< XUIElementFactory >( xContext->getServiceManager()->createInstanceWithContext(aServiceSpecifier, xContext), UNO_QUERY );
+        return Reference< XUIElementFactory >( m_xContext->getServiceManager()->createInstanceWithContext(aServiceSpecifier, m_xContext), UNO_QUERY );
     else
         return Reference< XUIElementFactory >();
 }
@@ -482,7 +514,7 @@ void SAL_CALL UIElementFactoryManager::registerFactory( const OUString& aType, c
 throw ( ElementExistException, RuntimeException )
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(rBHelper.rMutex);
 
     if ( !m_bConfigRead )
     {
@@ -498,7 +530,7 @@ void SAL_CALL UIElementFactoryManager::deregisterFactory( const OUString& aType,
 throw ( NoSuchElementException, RuntimeException )
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(rBHelper.rMutex);
 
     if ( !m_bConfigRead )
     {
@@ -510,6 +542,31 @@ throw ( NoSuchElementException, RuntimeException )
     // SAFE
 }
 
-} // namespace framework
+struct Instance {
+    explicit Instance(
+        css::uno::Reference<css::uno::XComponentContext> const & context):
+        instance(static_cast<cppu::OWeakObject *>(
+                    new UIElementFactoryManager(context)))
+    {
+    }
+
+    css::uno::Reference<css::uno::XInterface> instance;
+};
+
+struct Singleton:
+    public rtl::StaticWithArg<
+        Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
+{};
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_framework_UIElementFactoryManager_get_implementation(
+    css::uno::XComponentContext *context,
+    css::uno::Sequence<css::uno::Any> const &)
+{
+    return cppu::acquire(static_cast<cppu::OWeakObject *>(
+            Singleton::get(context).instance.get()));
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uifactory/windowcontentfactorymanager.cxx b/framework/source/uifactory/windowcontentfactorymanager.cxx
index b66c473..7f3b638 100644
--- a/framework/source/uifactory/windowcontentfactorymanager.cxx
+++ b/framework/source/uifactory/windowcontentfactorymanager.cxx
@@ -18,7 +18,8 @@
  */
 
 #include <uifactory/windowcontentfactorymanager.hxx>
-#include <uifactory/uielementfactorymanager.hxx>
+
+#include <uifactory/configurationaccessfactorymanager.hxx>
 #include <threadhelp/resetableguard.hxx>
 #include "services.h"
 
@@ -29,8 +30,9 @@
 #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/XControlModel.hpp>
-#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
 
 #include <rtl/ustrbuf.hxx>
 #include <cppuhelper/weak.hxx>
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index ea55f64..f81a53c 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -145,7 +145,8 @@
       constructor="com_sun_star_comp_framework_UIConfigurationManager_get_implementation">
     <service name="com.sun.star.ui.UIConfigurationManager"/>
   </implementation>
-  <implementation name="com.sun.star.comp.framework.UIElementFactoryManager">
+  <implementation name="com.sun.star.comp.framework.UIElementFactoryManager"
+      constructor="com_sun_star_comp_framework_UIElementFactoryManager_get_implementation">
     <service name="com.sun.star.ui.UIElementFactoryManager"/>
     <singleton name="com.sun.star.ui.theUIElementFactoryManager"/>
   </implementation>
commit e9a23fd78c7506cc28cdd4619cdb623813e36c61
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Wed Jan 29 10:51:46 2014 +0100

    Introduce com.sun.star.ui.theUIElementFactoryManager singleton.
    
    To replace single-instance com.sun.star.ui.UIElementFactoryManager
    service.
    
    Change-Id: I4262909c4396e3907d271a56696a06903168a58d

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 82c03b4..7c754cf 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -69,7 +69,7 @@
 #include <com/sun/star/task/XRestartManager.hpp>
 #include <com/sun/star/document/XEventListener.hpp>
 #include <com/sun/star/frame/theUICommandDescription.hpp>
-#include <com/sun/star/ui/UIElementFactoryManager.hpp>
+#include <com/sun/star/ui/theUIElementFactoryManager.hpp>
 #include <com/sun/star/ui/WindowStateConfiguration.hpp>
 #include <com/sun/star/frame/XUIControllerRegistration.hpp>
 #include <com/sun/star/frame/thePopupMenuControllerFactory.hpp>
@@ -2185,7 +2185,7 @@ void Desktop::PreloadConfigurationData()
 
     // preload user interface element factories
     Sequence< Sequence< css::beans::PropertyValue > > aSeqSeqPropValue;
-    Reference< XUIElementFactoryManager > xUIElementFactory = UIElementFactoryManager::create( xContext );
+    Reference< XUIElementFactoryManager > xUIElementFactory = theUIElementFactoryManager::get( xContext );
     try
     {
         aSeqSeqPropValue = xUIElementFactory->getRegisteredFactories();
diff --git a/framework/inc/pch/precompiled_fwk.hxx b/framework/inc/pch/precompiled_fwk.hxx
index db2efda..c88be55 100644
--- a/framework/inc/pch/precompiled_fwk.hxx
+++ b/framework/inc/pch/precompiled_fwk.hxx
@@ -205,7 +205,7 @@
 #include <com/sun/star/ui/ModuleAcceleratorConfiguration.hpp>
 #include <com/sun/star/ui/ModuleUIConfigurationManager.hpp>
 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
-#include <com/sun/star/ui/UIElementFactoryManager.hpp>
+#include <com/sun/star/ui/theUIElementFactoryManager.hpp>
 #include <com/sun/star/ui/UIElementType.hpp>
 #include <com/sun/star/ui/WindowStateConfiguration.hpp>
 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index 7dc9bb3..e0d8746 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -49,7 +49,7 @@
 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/UIElementType.hpp>
 #include <com/sun/star/ui/WindowStateConfiguration.hpp>
-#include <com/sun/star/ui/UIElementFactoryManager.hpp>
+#include <com/sun/star/ui/theUIElementFactoryManager.hpp>
 #include <com/sun/star/container/XNameReplace.hpp>
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/frame/LayoutManagerEvents.hpp>
@@ -123,7 +123,7 @@ LayoutManager::LayoutManager( const Reference< XComponentContext >& xContext ) :
         , m_bMenuBarCloser( false )
         , m_pInplaceMenuBar( NULL )
         , m_xModuleManager( ModuleManager::create( xContext ))
-        , m_xUIElementFactoryManager( ui::UIElementFactoryManager::create(xContext) )
+        , m_xUIElementFactoryManager( ui::theUIElementFactoryManager::get(xContext) )
         , m_xPersistentWindowStateSupplier( ui::WindowStateConfiguration::create( xContext ) )
         , m_pGlobalSettings( 0 )
         , m_aListenerContainer( m_aLock.getShareableOslMutex() )
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index 3a1cd49..ea55f64 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -147,6 +147,7 @@
   </implementation>
   <implementation name="com.sun.star.comp.framework.UIElementFactoryManager">
     <service name="com.sun.star.ui.UIElementFactoryManager"/>
+    <singleton name="com.sun.star.ui.theUIElementFactoryManager"/>
   </implementation>
   <implementation name="com.sun.star.comp.framework.URLTransformer"
       constructor="com_sun_star_comp_framework_URLTransformer_get_implementation">
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 78c2e7d..0314edb 100755
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -426,6 +426,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/ui,\
     WindowContentFactoryManager \
 	WindowStateConfiguration \
 	theUICategoryDescription \
+    theUIElementFactoryManager \
 ))
 $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/ui/dialogs,\
 	AddressBookSourcePilot \
diff --git a/offapi/com/sun/star/ui/UIElementFactoryManager.idl b/offapi/com/sun/star/ui/UIElementFactoryManager.idl
index d7ab858..8a16451 100644
--- a/offapi/com/sun/star/ui/UIElementFactoryManager.idl
+++ b/offapi/com/sun/star/ui/UIElementFactoryManager.idl
@@ -26,12 +26,10 @@
 module com { module sun { module star { module ui {
 
 
-/** specifies a user interface factory manager that controls all registered user
-    interface element factories.
+/**
+    A legacy (single-instance) service-variant of theUIElementFactoryManager singleton.
 
-    <p>An implementation is usually obtained from a
-    com::sun::star::lang::ServiceManager.
-    </p>
+    @deprecated Use theUIElementFactoryManager singleton instead.
 
     @since OOo 2.0
 */
diff --git a/offapi/com/sun/star/ui/theUIElementFactoryManager.idl b/offapi/com/sun/star/ui/theUIElementFactoryManager.idl
new file mode 100644
index 0000000..d612577
--- /dev/null
+++ b/offapi/com/sun/star/ui/theUIElementFactoryManager.idl
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef __com_sun_star_ui_theUIElementFactoryManager_idl__
+#define __com_sun_star_ui_theUIElementFactoryManager_idl__
+
+#include <com/sun/star/ui/XUIElementFactoryManager.idl>
+
+
+module com { module sun { module star { module ui {
+
+
+/** specifies a user interface factory manager that controls all registered user
+    interface element factories.
+
+    Prior to LibreOffice 4.3, this singleton was only available as a
+    (single-instance) UIElementFactoryManager service.
+
+    @since LibreOffice 4.3
+*/
+
+singleton theUIElementFactoryManager : XUIElementFactoryManager;
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/inc/pch/precompiled_sfx.hxx b/sfx2/inc/pch/precompiled_sfx.hxx
index 208f750..9d715a6 100644
--- a/sfx2/inc/pch/precompiled_sfx.hxx
+++ b/sfx2/inc/pch/precompiled_sfx.hxx
@@ -443,7 +443,7 @@
 #include <com/sun/star/ui/ImageType.hpp>
 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/UIConfigurationManager.hpp>
-#include <com/sun/star/ui/UIElementFactoryManager.hpp>
+#include <com/sun/star/ui/theUIElementFactoryManager.hpp>
 #include <com/sun/star/ui/UIElementType.hpp>
 #include <com/sun/star/ui/WindowContentFactoryManager.hpp>
 #include <com/sun/star/ui/WindowStateConfiguration.hpp>
diff --git a/sfx2/source/dialog/taskpane.cxx b/sfx2/source/dialog/taskpane.cxx
index 0892b06..b7307f8 100644
--- a/sfx2/source/dialog/taskpane.cxx
+++ b/sfx2/source/dialog/taskpane.cxx
@@ -37,7 +37,7 @@
 #include <com/sun/star/graphic/XGraphicProvider.hpp>
 #include <com/sun/star/accessibility/XAccessible.hpp>
 #include <com/sun/star/awt/XControl.hpp>
-#include <com/sun/star/ui/UIElementFactoryManager.hpp>
+#include <com/sun/star/ui/theUIElementFactoryManager.hpp>
 
 #include <comphelper/namedvaluecollection.hxx>
 #include <comphelper/types.hxx>
@@ -77,7 +77,7 @@ namespace sfx2
     using ::com::sun::star::ui::XToolPanel;
     using ::com::sun::star::ui::XUIElementFactory;
     using ::com::sun::star::ui::XUIElementFactoryManager;
-    using ::com::sun::star::ui::UIElementFactoryManager;
+    using ::com::sun::star::ui::theUIElementFactoryManager;
     using ::com::sun::star::ui::XUIElement;
     using ::com::sun::star::awt::XWindow;
     using ::com::sun::star::frame::XFrame;
@@ -358,7 +358,7 @@ namespace sfx2
         m_bAttemptedCreation = true;
         try
         {
-            const Reference< XUIElementFactoryManager > xFactory = UIElementFactoryManager::create( ::comphelper::getProcessComponentContext() );
+            const Reference< XUIElementFactoryManager > xFactory = theUIElementFactoryManager::get( ::comphelper::getProcessComponentContext() );
 
             ::comphelper::NamedValueCollection aCreationArgs;
             aCreationArgs.put( "Frame", makeAny( m_xFrame ) );
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 357c545..8d86e65 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -47,7 +47,7 @@
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
 #include <com/sun/star/ui/ContextChangeEventObject.hpp>
-#include <com/sun/star/ui/UIElementFactoryManager.hpp>
+#include <com/sun/star/ui/theUIElementFactoryManager.hpp>
 #include <com/sun/star/util/XURLTransformer.hpp>
 #include <com/sun/star/util/URL.hpp>
 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
@@ -761,7 +761,7 @@ Reference<ui::XUIElement> SidebarController::CreateUIElement (
     {
         const Reference<XComponentContext> xComponentContext (::comphelper::getProcessComponentContext() );
         const Reference<ui::XUIElementFactory> xUIElementFactory =
-               ui::UIElementFactoryManager::create( xComponentContext );
+               ui::theUIElementFactoryManager::get( xComponentContext );
 
        // Create the XUIElement.
         ::comphelper::NamedValueCollection aCreationArguments;
diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx
index 3ff970a..99dc1f0 100644
--- a/sfx2/source/toolbox/tbxitem.cxx
+++ b/sfx2/source/toolbox/tbxitem.cxx
@@ -47,7 +47,7 @@
 #include <com/sun/star/frame/XModuleManager.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/ui/XUIFunctionListener.hpp>
-#include <com/sun/star/ui/UIElementFactoryManager.hpp>
+#include <com/sun/star/ui/theUIElementFactoryManager.hpp>
 #include <com/sun/star/frame/status/Visibility.hpp>
 #include <svl/eitem.hxx>
 #include <svl/stritem.hxx>
@@ -797,7 +797,7 @@ void SfxToolBoxControl::createAndPositionSubToolBar( const OUString& rSubToolBar
         xUIElementFactory = xWeakUIElementFactory;
         if ( !xUIElementFactory.is() )
         {
-            xUIElementFactory = UIElementFactoryManager::create( m_xContext );
+            xUIElementFactory = theUIElementFactoryManager::get( m_xContext );
             xWeakUIElementFactory = xUIElementFactory;
         }
 
commit 43b84c96629e78e17e6a1e51e4c482887197036f
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Thu Jan 9 13:46:42 2014 +0100

    fwk: Constructor feature for single-instance UIControllerFactories.
    
    Change-Id: I0867404f7e4aa7b9caafe4f0568bd2c20190867f

diff --git a/framework/inc/uifactory/uicontrollerfactory.hxx b/framework/inc/uifactory/uicontrollerfactory.hxx
deleted file mode 100644
index 08af3f4..0000000
--- a/framework/inc/uifactory/uicontrollerfactory.hxx
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_FRAMEWORK_INC_UIFACTORY_UICONTROLLERFACTORY_HXX
-#define INCLUDED_FRAMEWORK_INC_UIFACTORY_UICONTROLLERFACTORY_HXX
-
-#include <threadhelp/threadhelpbase.hxx>
-#include <macros/generic.hxx>
-#include <macros/xinterface.hxx>
-#include <macros/xtypeprovider.hxx>
-#include <macros/xserviceinfo.hxx>
-#include <stdtypes.h>
-
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XTypeProvider.hpp>
-#include <com/sun/star/frame/XUIControllerFactory.hpp>
-
-#include <cppuhelper/implbase2.hxx>
-
-namespace framework
-{
-
-class ConfigurationAccess_ControllerFactory;
-class UIControllerFactory :  protected ThreadHelpBase, // Struct for right initalization of mutex member! Must be first of baseclasses.
-                             public ::cppu::WeakImplHelper2<
-                                 com::sun::star::lang::XServiceInfo,
-                                 com::sun::star::frame::XUIControllerFactory >
-{
-    public:
-        virtual ~UIControllerFactory();
-
-        // XServiceInfo
-        virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
-        virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException) = 0;
-        virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
-
-        // XMultiComponentFactory
-        virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithContext( const OUString& aServiceSpecifier, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
-        virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArgumentsAndContext( const OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
-        virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() throw (::com::sun::star::uno::RuntimeException);
-
-        // XUIControllerRegistration
-        virtual sal_Bool SAL_CALL hasController( const OUString& aCommandURL, const OUString& aModuleName ) throw (::com::sun::star::uno::RuntimeException);
-        virtual void SAL_CALL registerController( const OUString& aCommandURL, const OUString& aModuleName, const OUString& aControllerImplementationName ) throw (::com::sun::star::uno::RuntimeException);
-        virtual void SAL_CALL deregisterController( const OUString& aCommandURL, const OUString& aModuleName ) throw (::com::sun::star::uno::RuntimeException);
-
-    protected:
-        UIControllerFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext, const rtl::OUString &rUINode  );
-        sal_Bool                                                                         m_bConfigRead;
-        ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >     m_xContext;
-        ConfigurationAccess_ControllerFactory*                                           m_pConfigAccess;
-};
-
-class PopupMenuControllerFactory :  public UIControllerFactory
-{
-    public:
-        PopupMenuControllerFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
-
-        //  XInterface, XTypeProvider, XServiceInfo
-        DECLARE_XSERVICEINFO
-};
-
-class ToolbarControllerFactory :  public UIControllerFactory
-{
-    public:
-        ToolbarControllerFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
-
-        //  XInterface, XTypeProvider, XServiceInfo
-        DECLARE_XSERVICEINFO
-};
-
-class StatusbarControllerFactory :  public UIControllerFactory
-{
-    public:
-        StatusbarControllerFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
-
-        //  XInterface, XTypeProvider, XServiceInfo
-        DECLARE_XSERVICEINFO
-};
-
-}
-
-#endif // INCLUDED_FRAMEWORK_INC_UIFACTORY_UICONTROLLERFACTORY_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx
index fc55475..a1c0018 100644
--- a/framework/source/register/registerservices.cxx
+++ b/framework/source/register/registerservices.cxx
@@ -35,7 +35,6 @@
 =================================================================================================================*/
 #include <services/desktop.hxx>
 #include <uifactory/uielementfactorymanager.hxx>
-#include <uifactory/uicontrollerfactory.hxx>
 #include <uiconfiguration/moduleuicfgsupplier.hxx>
 #include <uifactory/menubarfactory.hxx>
 #include <uifactory/toolboxfactory.hxx>
@@ -51,15 +50,12 @@
 COMPONENTGETFACTORY ( fwk,
                         IFFACTORY( ::framework::Desktop                                 )   else
                         IFFACTORY( ::framework::UIElementFactoryManager                 )   else
-                        IFFACTORY( ::framework::PopupMenuControllerFactory              )   else
                         IFFACTORY( ::framework::ModuleUIConfigurationManagerSupplier    )   else
                         IFFACTORY( ::framework::MenuBarFactory                          )   else
                         IFFACTORY( ::framework::ToolBoxFactory                          )   else
                         IFFACTORY( ::framework::WindowStateConfiguration                )   else
-                        IFFACTORY( ::framework::ToolbarControllerFactory                )   else
                         IFFACTORY( ::framework::StatusBarFactory                        )   else
                         IFFACTORY( ::framework::SessionListener                         )   else
-                        IFFACTORY( ::framework::StatusbarControllerFactory              )   else
                         IFFACTORY( ::framework::SessionListener                         )   else
                         IFFACTORY( ::framework::TaskCreatorService                      )   else
                         IFFACTORY( ::framework::WindowContentFactoryManager             )   else
diff --git a/framework/source/uifactory/uicontrollerfactory.cxx b/framework/source/uifactory/uicontrollerfactory.cxx
index e14eba7..7ffce35 100644
--- a/framework/source/uifactory/uicontrollerfactory.cxx
+++ b/framework/source/uifactory/uicontrollerfactory.cxx
@@ -17,50 +17,88 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <uifactory/uicontrollerfactory.hxx>
 #include <uifactory/factoryconfiguration.hxx>
-#include <threadhelp/resetableguard.hxx>
-#include "services.h"
 
 #include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#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/lang/XServiceInfo.hpp>
+#include <com/sun/star/frame/XUIControllerFactory.hpp>
 
 #include <rtl/ustrbuf.hxx>
-#include <cppuhelper/weak.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/supportsservice.hxx>
 
-using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::container;
-using namespace ::com::sun::star::frame;
+using namespace css::uno;
+using namespace css::lang;
+using namespace css::beans;
+using namespace css::container;
+using namespace css::frame;
+using namespace framework;
 
-namespace framework
+namespace {
+
+typedef ::cppu::WeakComponentImplHelper2<
+    css::lang::XServiceInfo,
+    css::frame::XUIControllerFactory > UIControllerFactory_BASE;
+
+class UIControllerFactory : private osl::Mutex,
+                            public UIControllerFactory_BASE
 {
+public:
+    virtual ~UIControllerFactory();
+
+    // XServiceInfo
+    virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (css::uno::RuntimeException) = 0;
+    virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (css::uno::RuntimeException) = 0;
+    virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (css::uno::RuntimeException) = 0;
+
+    // XMultiComponentFactory
+    virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithContext( const OUString& aServiceSpecifier, const css::uno::Reference< css::uno::XComponentContext >& Context ) throw (css::uno::Exception, css::uno::RuntimeException);
+    virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArgumentsAndContext( const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments, const css::uno::Reference< css::uno::XComponentContext >& Context ) throw (css::uno::Exception, css::uno::RuntimeException);
+    virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() throw (css::uno::RuntimeException);
+
+    // XUIControllerRegistration
+    virtual sal_Bool SAL_CALL hasController( const OUString& aCommandURL, const OUString& aModuleName ) throw (css::uno::RuntimeException);
+    virtual void SAL_CALL registerController( const OUString& aCommandURL, const OUString& aModuleName, const OUString& aControllerImplementationName ) throw (css::uno::RuntimeException);
+    virtual void SAL_CALL deregisterController( const OUString& aCommandURL, const OUString& aModuleName ) throw (css::uno::RuntimeException);
+
+protected:
+    UIControllerFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString &rUINode  );
+    sal_Bool                                                                         m_bConfigRead;
+    css::uno::Reference< css::uno::XComponentContext >     m_xContext;
+    ConfigurationAccess_ControllerFactory*                                           m_pConfigAccess;
+
+private:
+    virtual void SAL_CALL disposing() SAL_OVERRIDE;
+};
 
 UIControllerFactory::UIControllerFactory(
     const Reference< XComponentContext >& xContext,
     const rtl::OUString &rConfigurationNode )
-    : ThreadHelpBase()
+    : UIControllerFactory_BASE(*static_cast<osl::Mutex *>(this))
     , m_bConfigRead( sal_False )
     , m_xContext( xContext )
     , m_pConfigAccess()
 {
-    rtl::OUStringBuffer aBuffer;
-    aBuffer.append( "/org.openoffice.Office.UI.Controller/Registered/" );
-    aBuffer.append( rConfigurationNode );
-    m_pConfigAccess = new ConfigurationAccess_ControllerFactory( m_xContext, aBuffer.makeStringAndClear() );
+    m_pConfigAccess = new ConfigurationAccess_ControllerFactory(m_xContext,
+            "/org.openoffice.Office.UI.Controller/Registered/" + rConfigurationNode);
     m_pConfigAccess->acquire();
 }
 
 UIControllerFactory::~UIControllerFactory()
 {
-    ResetableGuard aLock( m_aLock );
+    disposing();
+}
 
-    // reduce reference count
-    m_pConfigAccess->release();
+void SAL_CALL UIControllerFactory::disposing()
+{
+    osl::MutexGuard g(rBHelper.rMutex);
+    if (m_pConfigAccess)
+    {
+        // reduce reference count
+        m_pConfigAccess->release();
+        m_pConfigAccess = 0;
+    }
 }
 
 // XMultiComponentFactory
@@ -70,7 +108,7 @@ Reference< XInterface > SAL_CALL UIControllerFactory::createInstanceWithContext(
 throw (Exception, RuntimeException)
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(rBHelper.rMutex);
 
     if ( !m_bConfigRead )
     {
@@ -133,8 +171,9 @@ throw (Exception, RuntimeException)
     }
 
     {
-        // SAFE
-        ResetableGuard aLock( m_aLock );
+        OUString aServiceName;
+        { // SAFE
+        osl::MutexGuard g(rBHelper.rMutex);
 
         if ( !m_bConfigRead )
         {
@@ -142,14 +181,11 @@ throw (Exception, RuntimeException)
             m_pConfigAccess->readConfigurationData();
         }
 
-        OUString aServiceName = m_pConfigAccess->getServiceFromCommandModule( ServiceSpecifier, aPropName );
-        Reference< XComponentContext > xContext( m_xContext );
-
-        aLock.unlock();
-        // SAFE
+        aServiceName = m_pConfigAccess->getServiceFromCommandModule( ServiceSpecifier, aPropName );
+        } // SAFE
 
         if ( !aServiceName.isEmpty() )
-            return xContext->getServiceManager()->createInstanceWithArgumentsAndContext( aServiceName, aNewArgs, xContext );
+            return m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( aServiceName, aNewArgs, m_xContext );
         else
             return Reference< XInterface >();
     }
@@ -165,9 +201,9 @@ throw (RuntimeException)
 sal_Bool SAL_CALL UIControllerFactory::hasController(
     const OUString& aCommandURL,
     const OUString& aModuleName )
-throw (::com::sun::star::uno::RuntimeException)
+throw (css::uno::RuntimeException)
 {
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(rBHelper.rMutex);
 
     if ( !m_bConfigRead )
     {
@@ -185,7 +221,7 @@ void SAL_CALL UIControllerFactory::registerController(
 throw (RuntimeException)
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(rBHelper.rMutex);
 
     if ( !m_bConfigRead )
     {
@@ -203,7 +239,7 @@ void SAL_CALL UIControllerFactory::deregisterController(
 throw (RuntimeException)
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(rBHelper.rMutex);
 
     if ( !m_bConfigRead )
     {
@@ -215,14 +251,32 @@ throw (RuntimeException)
     // SAFE
 }
 
+class PopupMenuControllerFactory :  public UIControllerFactory
+{
+public:
+    PopupMenuControllerFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext );
+
+    virtual OUString SAL_CALL getImplementationName()
+        throw (css::uno::RuntimeException)
+    {
+        return OUString("com.sun.star.comp.framework.PopupMenuControllerFactory");
+    }
+
+    virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
+        throw (css::uno::RuntimeException)
+    {
+        return cppu::supportsService(this, ServiceName);
+    }
 
-DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2(   PopupMenuControllerFactory                      ,
-                                            ::cppu::OWeakObject                             ,
-                                            SERVICENAME_POPUPMENUCONTROLLERFACTORY          ,
-                                            IMPLEMENTATIONNAME_POPUPMENUCONTROLLERFACTORY
-                                        )
+    virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
+        throw (css::uno::RuntimeException)
+    {
+        css::uno::Sequence< OUString > aSeq(1);
+        aSeq[0] = OUString("com.sun.star.frame.PopupMenuControllerFactory");
+        return aSeq;
+    }
 
-DEFINE_INIT_SERVICE                     (   PopupMenuControllerFactory, {} )
+};
 
 PopupMenuControllerFactory::PopupMenuControllerFactory( const Reference< XComponentContext >& xContext ) :
     UIControllerFactory(
@@ -231,13 +285,50 @@ PopupMenuControllerFactory::PopupMenuControllerFactory( const Reference< XCompon
 {
 }
 
-DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2(   ToolbarControllerFactory                     ,
-                                            ::cppu::OWeakObject                             ,
-                                            SERVICENAME_TOOLBARCONTROLLERFACTORY            ,
-                                            IMPLEMENTATIONNAME_TOOLBARCONTROLLERFACTORY
-                                        )
+struct PopupMenuControllerFactoryInstance {
+    explicit PopupMenuControllerFactoryInstance(
+        css::uno::Reference<css::uno::XComponentContext> const & context):
+        instance(static_cast<cppu::OWeakObject *>(
+                    new PopupMenuControllerFactory(context)))
+    {
+    }
+
+    css::uno::Reference<css::uno::XInterface> instance;
+};
+
+struct PopupMenuControllerFactorySingleton:
+    public rtl::StaticWithArg<
+        PopupMenuControllerFactoryInstance,
+        css::uno::Reference<css::uno::XComponentContext>,
+        PopupMenuControllerFactorySingleton>
+{};
+
+class ToolbarControllerFactory :  public UIControllerFactory
+{
+public:
+    ToolbarControllerFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext );
+
+    virtual OUString SAL_CALL getImplementationName()
+        throw (css::uno::RuntimeException)
+    {
+        return OUString("com.sun.star.comp.framework.ToolBarControllerFactory");
+    }
+
+    virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
+        throw (css::uno::RuntimeException)
+    {
+        return cppu::supportsService(this, ServiceName);
+    }
+
+    virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
+        throw (css::uno::RuntimeException)
+    {
+        css::uno::Sequence< OUString > aSeq(1);
+        aSeq[0] = OUString("com.sun.star.frame.ToolbarControllerFactory");
+        return aSeq;
+    }
 
-DEFINE_INIT_SERVICE                     (   ToolbarControllerFactory, {} )
+};
 
 ToolbarControllerFactory::ToolbarControllerFactory( const Reference< XComponentContext >& xContext ) :
     UIControllerFactory(
@@ -246,13 +337,50 @@ ToolbarControllerFactory::ToolbarControllerFactory( const Reference< XComponentC
 {
 }
 
-DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2(   StatusbarControllerFactory                      ,
-                                            ::cppu::OWeakObject                             ,
-                                            SERVICENAME_STATUSBARCONTROLLERFACTORY          ,
-                                            IMPLEMENTATIONNAME_STATUSBARCONTROLLERFACTORY
-                                        )
+struct ToolbarControllerFactoryInstance {
+    explicit ToolbarControllerFactoryInstance(
+        css::uno::Reference<css::uno::XComponentContext> const & context):
+        instance(static_cast<cppu::OWeakObject *>(
+                    new ToolbarControllerFactory(context)))
+    {
+    }
+
+    css::uno::Reference<css::uno::XInterface> instance;
+};
+
+struct ToolbarControllerFactorySingleton:
+    public rtl::StaticWithArg<
+        ToolbarControllerFactoryInstance,
+        css::uno::Reference<css::uno::XComponentContext>,
+        ToolbarControllerFactorySingleton>
+{};
+
+class StatusbarControllerFactory :  public UIControllerFactory
+{
+public:
+    StatusbarControllerFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext );
+
+    virtual OUString SAL_CALL getImplementationName()
+        throw (css::uno::RuntimeException)
+    {
+        return OUString("com.sun.star.comp.framework.StatusBarControllerFactory");
+    }
+
+    virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
+        throw (css::uno::RuntimeException)
+    {
+        return cppu::supportsService(this, ServiceName);
+    }
+
+    virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
+        throw (css::uno::RuntimeException)
+    {
+        css::uno::Sequence< OUString > aSeq(1);
+        aSeq[0] = OUString("com.sun.star.frame.StatusbarControllerFactory");
+        return aSeq;
+    }
 
-DEFINE_INIT_SERVICE                     (   StatusbarControllerFactory, {} )
+};
 
 StatusbarControllerFactory::StatusbarControllerFactory( const Reference< XComponentContext >& xContext ) :
     UIControllerFactory(
@@ -261,6 +389,51 @@ StatusbarControllerFactory::StatusbarControllerFactory( const Reference< XCompon
 {
 }
 
-} // namespace framework
+struct StatusbarControllerFactoryInstance {
+    explicit StatusbarControllerFactoryInstance(
+        css::uno::Reference<css::uno::XComponentContext> const & context):
+        instance(static_cast<cppu::OWeakObject *>(
+                    new StatusbarControllerFactory(context)))
+    {
+    }
+
+    css::uno::Reference<css::uno::XInterface> instance;
+};
+
+struct StatusbarControllerFactorySingleton:
+    public rtl::StaticWithArg<
+        StatusbarControllerFactoryInstance,
+        css::uno::Reference<css::uno::XComponentContext>,
+        StatusbarControllerFactorySingleton>
+{};
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_framework_PopupMenuControllerFactory_get_implementation(
+    css::uno::XComponentContext *context,
+    css::uno::Sequence<css::uno::Any> const &)
+{
+    return cppu::acquire(static_cast<cppu::OWeakObject *>(
+            PopupMenuControllerFactorySingleton::get(context).instance.get()));
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_framework_ToolBarControllerFactory_get_implementation(
+    css::uno::XComponentContext *context,
+    css::uno::Sequence<css::uno::Any> const &)
+{
+    return cppu::acquire(static_cast<cppu::OWeakObject *>(
+            ToolbarControllerFactorySingleton::get(context).instance.get()));
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_framework_StatusBarControllerFactory_get_implementation(
+    css::uno::XComponentContext *context,
+    css::uno::Sequence<css::uno::Any> const &)
+{
+    return cppu::acquire(static_cast<cppu::OWeakObject *>(
+            StatusbarControllerFactorySingleton::get(context).instance.get()));
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index d6d5d1b..3a1cd49 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -99,7 +99,8 @@
   <implementation name="com.sun.star.comp.framework.PathSubstitution">
     <service name="com.sun.star.util.PathSubstitution"/>
   </implementation>
-  <implementation name="com.sun.star.comp.framework.PopupMenuControllerFactory">
+  <implementation name="com.sun.star.comp.framework.PopupMenuControllerFactory"
+      constructor="com_sun_star_comp_framework_PopupMenuControllerFactory_get_implementation">
     <service name="com.sun.star.frame.PopupMenuControllerFactory"/>
     <singleton name="com.sun.star.frame.thePopupMenuControllerFactory"/>
   </implementation>
@@ -107,7 +108,8 @@
       constructor="com_sun_star_comp_framework_RecentFilesMenuController_get_implementation">
     <service name="com.sun.star.frame.PopupMenuController"/>
   </implementation>
-  <implementation name="com.sun.star.comp.framework.StatusBarControllerFactory">
+  <implementation name="com.sun.star.comp.framework.StatusBarControllerFactory"
+      constructor="com_sun_star_comp_framework_StatusBarControllerFactory_get_implementation">
     <service name="com.sun.star.frame.StatusbarControllerFactory"/>
     <singleton name="com.sun.star.frame.theStatusbarControllerFactory"/>
   </implementation>
@@ -121,7 +123,8 @@
   <implementation name="com.sun.star.comp.framework.TaskCreator">
     <service name="com.sun.star.frame.TaskCreator"/>
   </implementation>
-  <implementation name="com.sun.star.comp.framework.ToolBarControllerFactory">
+  <implementation name="com.sun.star.comp.framework.ToolBarControllerFactory"
+      constructor="com_sun_star_comp_framework_ToolBarControllerFactory_get_implementation">
     <service name="com.sun.star.frame.ToolbarControllerFactory"/>
     <singleton name="com.sun.star.frame.theToolbarControllerFactory"/>
   </implementation>
commit af1c0ef8d397b652a4b58b29fbd7cab1a0ab5840
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Wed Jan 29 10:35:38 2014 +0100

    Introduce com.sun.star.frame.ControllerFactory singletons:
    
    com.sun.star.frame.thePopupMenuControllerFactory
    com.sun.star.frame.theStatusbarControllerFactory
    com.sun.star.frame.theToolbarControllerFactory
    
    To replace their single-instance service variants.
    
    Change-Id: I00586d0d61e63f9482cb659071e88aa9cf02d5b5

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 88c7fbf..82c03b4 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -72,8 +72,7 @@
 #include <com/sun/star/ui/UIElementFactoryManager.hpp>
 #include <com/sun/star/ui/WindowStateConfiguration.hpp>
 #include <com/sun/star/frame/XUIControllerRegistration.hpp>
-#include <com/sun/star/frame/ToolbarControllerFactory.hpp>
-#include <com/sun/star/frame/PopupMenuControllerFactory.hpp>
+#include <com/sun/star/frame/thePopupMenuControllerFactory.hpp>
 #include <com/sun/star/office/Quickstart.hpp>
 
 #include <toolkit/helper/vclunohelper.hxx>
@@ -2199,7 +2198,7 @@ void Desktop::PreloadConfigurationData()
     // configuration file they also get preloaded!
 
     Reference< css::frame::XUIControllerRegistration > xPopupMenuControllerFactory =
-    css::frame::PopupMenuControllerFactory::create( xContext );
+    css::frame::thePopupMenuControllerFactory::get( xContext );
     try
     {
         xPopupMenuControllerFactory->hasController(
diff --git a/framework/inc/pch/precompiled_fwk.hxx b/framework/inc/pch/precompiled_fwk.hxx
index c9b8c09..db2efda 100644
--- a/framework/inc/pch/precompiled_fwk.hxx
+++ b/framework/inc/pch/precompiled_fwk.hxx
@@ -121,11 +121,11 @@
 #include <com/sun/star/frame/LayoutManagerEvents.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/OfficeFrameLoader.hpp>
-#include <com/sun/star/frame/PopupMenuControllerFactory.hpp>
+#include <com/sun/star/frame/thePopupMenuControllerFactory.hpp>
 #include <com/sun/star/frame/StartModule.hpp>
-#include <com/sun/star/frame/StatusbarControllerFactory.hpp>
+#include <com/sun/star/frame/theStatusbarControllerFactory.hpp>
 #include <com/sun/star/frame/TaskCreator.hpp>
-#include <com/sun/star/frame/ToolbarControllerFactory.hpp>
+#include <com/sun/star/frame/theToolbarControllerFactory.hpp>
 #include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/frame/XControlNotificationListener.hpp>
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index 866ea13..b3fb3bf 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -43,7 +43,7 @@
 #include <com/sun/star/uno/XCurrentContext.hpp>
 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
 #include <com/sun/star/frame/XPopupMenuController.hpp>
-#include <com/sun/star/frame/PopupMenuControllerFactory.hpp>
+#include <com/sun/star/frame/thePopupMenuControllerFactory.hpp>
 #include <com/sun/star/lang/SystemDependent.hpp>
 #include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
 #include <com/sun/star/ui/ItemType.hpp>
@@ -179,7 +179,7 @@ MenuBarManager::MenuBarManager(
     , m_xURLTransformer(_xURLTransformer)
     , m_nSymbolsStyle( SvtMiscOptions().GetCurrentSymbolsStyle() )
 {
-    m_xPopupMenuControllerFactory = frame::PopupMenuControllerFactory::create(m_xContext);
+    m_xPopupMenuControllerFactory = frame::thePopupMenuControllerFactory::get(m_xContext);
     FillMenuManager( pMenu, rFrame, rDispatchProvider, rModuleIdentifier, bDelete, bDeleteChildren );
 }
 
@@ -1963,7 +1963,7 @@ void MenuBarManager::Init(const Reference< XFrame >& rFrame,AddonMenu* pAddonMen
     m_bIsBookmarkMenu   = sal_True;
 
     OUString aModuleIdentifier;
-    m_xPopupMenuControllerFactory = frame::PopupMenuControllerFactory::create(
+    m_xPopupMenuControllerFactory = frame::thePopupMenuControllerFactory::get(
         ::comphelper::getProcessComponentContext());
 
     Reference< XStatusListener > xStatusListener;
diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx b/framework/source/uielement/popuptoolbarcontroller.cxx
index c94edc5..6f513fd 100644
--- a/framework/source/uielement/popuptoolbarcontroller.cxx
+++ b/framework/source/uielement/popuptoolbarcontroller.cxx
@@ -32,7 +32,7 @@
 
 #include <com/sun/star/awt/PopupMenuDirection.hpp>
 #include <com/sun/star/awt/XPopupMenu.hpp>
-#include <com/sun/star/frame/PopupMenuControllerFactory.hpp>
+#include <com/sun/star/frame/thePopupMenuControllerFactory.hpp>
 #include <com/sun/star/frame/XDispatchProvider.hpp>
 #include <com/sun/star/frame/XPopupMenuController.hpp>
 #include <com/sun/star/frame/XUIControllerFactory.hpp>
@@ -129,7 +129,7 @@ throw ( css::uno::Exception, css::uno::RuntimeException )
     try
     {
         m_xPopupMenuFactory.set(
-            css::frame::PopupMenuControllerFactory::create( m_xContext ) );
+            css::frame::thePopupMenuControllerFactory::get( m_xContext ) );
         m_bHasController = m_xPopupMenuFactory->hasController(
             m_aPopupCommand, getModuleName() );
     }
diff --git a/framework/source/uielement/statusbarmanager.cxx b/framework/source/uielement/statusbarmanager.cxx
index bb5cfd2..399a89e 100644
--- a/framework/source/uielement/statusbarmanager.cxx
+++ b/framework/source/uielement/statusbarmanager.cxx
@@ -36,7 +36,7 @@
 #include <helper/mischelper.hxx>
 
 #include <com/sun/star/frame/XFrame.hpp>
-#include <com/sun/star/frame/StatusbarControllerFactory.hpp>
+#include <com/sun/star/frame/theStatusbarControllerFactory.hpp>
 #include <com/sun/star/ui/ItemStyle.hpp>
 #include <com/sun/star/ui/ItemType.hpp>
 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
@@ -145,7 +145,7 @@ StatusBarManager::StatusBarManager(
     m_xContext( rxContext )
 {
 
-    m_xStatusbarControllerFactory = frame::StatusbarControllerFactory::create(
+    m_xStatusbarControllerFactory = frame::theStatusbarControllerFactory::get(
         ::comphelper::getProcessComponentContext());
 
     m_pStatusBar->SetClickHdl( LINK( this, StatusBarManager, Click ) );
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index dd2b7b8..51bb67c 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -42,7 +42,7 @@
 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/ToolbarControllerFactory.hpp>
+#include <com/sun/star/frame/theToolbarControllerFactory.hpp>
 #include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
 #include <com/sun/star/ui/XUIElementSettings.hpp>
 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
@@ -211,7 +211,7 @@ ToolBarManager::ToolBarManager( const Reference< XComponentContext >& rxContext,
     if ( pWindow )
         ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( m_pToolBar );
 
-    m_xToolbarControllerFactory = frame::ToolbarControllerFactory::create( m_xContext );
+    m_xToolbarControllerFactory = frame::theToolbarControllerFactory::get( m_xContext );
     m_xURLTransformer = URLTransformer::create( m_xContext );
 
     m_pToolBar->SetSelectHdl( LINK( this, ToolBarManager, Select) );
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index 2a211ce..d6d5d1b 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -101,6 +101,7 @@
   </implementation>
   <implementation name="com.sun.star.comp.framework.PopupMenuControllerFactory">
     <service name="com.sun.star.frame.PopupMenuControllerFactory"/>
+    <singleton name="com.sun.star.frame.thePopupMenuControllerFactory"/>
   </implementation>
   <implementation name="com.sun.star.comp.framework.RecentFilesMenuController"
       constructor="com_sun_star_comp_framework_RecentFilesMenuController_get_implementation">
@@ -108,6 +109,7 @@
   </implementation>
   <implementation name="com.sun.star.comp.framework.StatusBarControllerFactory">
     <service name="com.sun.star.frame.StatusbarControllerFactory"/>
+    <singleton name="com.sun.star.frame.theStatusbarControllerFactory"/>
   </implementation>
   <implementation name="com.sun.star.comp.framework.StatusBarFactory">
     <service name="com.sun.star.ui.StatusBarFactory"/>
@@ -121,6 +123,7 @@
   </implementation>
   <implementation name="com.sun.star.comp.framework.ToolBarControllerFactory">
     <service name="com.sun.star.frame.ToolbarControllerFactory"/>
+    <singleton name="com.sun.star.frame.theToolbarControllerFactory"/>
   </implementation>
   <implementation name="com.sun.star.comp.framework.ToolBarFactory">
     <service name="com.sun.star.ui.ToolBarFactory"/>
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index f2664e9..78c2e7d 100755
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -951,6 +951,9 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,com/sun/star/frame,\
 	ToolbarController \
 	ToolbarControllerFactory \
 	TransientDocumentsDocumentContentFactory \
+	thePopupMenuControllerFactory \
+	theStatusbarControllerFactory \
+	theToolbarControllerFactory \
 ))
 $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,com/sun/star/gallery,\
 	GalleryItem \
diff --git a/offapi/com/sun/star/frame/PopupMenuControllerFactory.idl b/offapi/com/sun/star/frame/PopupMenuControllerFactory.idl
index f6c55b0..009bb66 100644
--- a/offapi/com/sun/star/frame/PopupMenuControllerFactory.idl
+++ b/offapi/com/sun/star/frame/PopupMenuControllerFactory.idl
@@ -24,13 +24,10 @@
 
 module com { module sun { module star { module frame {
 
-/** specifies a factory that creates instances of registered popup menu controller.
+/**
+    A legacy (single-instance) service-variant of thePopupMenuControllerFactory singleton.
 
-    <p>
-    A pop-up menu controller can be registered for a command URL and a model service name.
-    A menu bar or context menu will automatically create a pop-up menu controller if
-    it contains a registered command URL.
-    </p>
+    @deprecated Use thePopupMenuControllerFactory singleton instead.
 
     @since OOo 2.0
 */
diff --git a/offapi/com/sun/star/frame/StatusbarControllerFactory.idl b/offapi/com/sun/star/frame/StatusbarControllerFactory.idl
index ffffabf..4f74f6d 100644
--- a/offapi/com/sun/star/frame/StatusbarControllerFactory.idl
+++ b/offapi/com/sun/star/frame/StatusbarControllerFactory.idl
@@ -24,14 +24,10 @@
 
 module com { module sun { module star { module frame {
 
-/** specifies a factory that creates instances of registered status bar
-    controller.
-
-    <p>
-    A status bar controller can be registered for a command URL and a model
-    service name. A status bar will automatically create a status bar controller
-    if it contains a registered command URL.
-    </p>
+/**
+    A legacy (single-instance) service-variant of theStatusbarControllerFactory singleton.
+
+    @deprecated Use theStatusbarControllerFactory singleton instead.
 
     @since OOo 2.0
 */
diff --git a/offapi/com/sun/star/frame/ToolbarControllerFactory.idl b/offapi/com/sun/star/frame/ToolbarControllerFactory.idl
index 69b1314..56e8e3f 100644
--- a/offapi/com/sun/star/frame/ToolbarControllerFactory.idl
+++ b/offapi/com/sun/star/frame/ToolbarControllerFactory.idl
@@ -22,11 +22,10 @@
 
 module com { module sun { module star { module frame {
 
-/** specifies a factory that creates instances of registered toolbar controller.
+/**
+    A legacy (single-instance) service-variant of theToolbarControllerFactory singleton.
 
-    <p>
-    A toolbar controller can be registered for a command URL and a model service name.
-    </p>
+    @deprecated Use theToolbarControllerFactory singleton instead.
 
     @since OOo 2.0
 */
diff --git a/offapi/com/sun/star/frame/thePopupMenuControllerFactory.idl b/offapi/com/sun/star/frame/thePopupMenuControllerFactory.idl
new file mode 100644
index 0000000..48511b7
--- /dev/null
+++ b/offapi/com/sun/star/frame/thePopupMenuControllerFactory.idl
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef __com_sun_star_frame_thePopupMenuControllerFactory_idl__
+#define __com_sun_star_frame_thePopupMenuControllerFactory_idl__
+
+#include <com/sun/star/frame/XUIControllerFactory.idl>
+
+module com { module sun { module star { module frame {
+
+/** specifies a factory that creates instances of registered popup menu controller.
+
+    <p>
+    A pop-up menu controller can be registered for a command URL and a model service name.
+    A menu bar or context menu will automatically create a pop-up menu controller if
+    it contains a registered command URL.
+    </p>
+
+    Prior to LibreOffice 4.3, this singleton was only available as a
+    (single-instance) PopupMenuControllerFactory service.
+
+    @since LibreOffice 4.3
+*/
+singleton thePopupMenuControllerFactory : XUIControllerFactory;
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/frame/theStatusbarControllerFactory.idl b/offapi/com/sun/star/frame/theStatusbarControllerFactory.idl
new file mode 100644
index 0000000..3fdfb11
--- /dev/null
+++ b/offapi/com/sun/star/frame/theStatusbarControllerFactory.idl
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef __com_sun_star_frame_theStatusbarControllerFactory_idl__
+#define __com_sun_star_frame_theStatusbarControllerFactory_idl__
+
+#include <com/sun/star/frame/XUIControllerFactory.idl>
+
+module com { module sun { module star { module frame {
+
+/** specifies a factory that creates instances of registered status bar
+    controller.
+
+    <p>
+    A status bar controller can be registered for a command URL and a model
+    service name. A status bar will automatically create a status bar controller
+    if it contains a registered command URL.
+    </p>
+
+    Prior to LibreOffice 4.3, this singleton was only available as a
+    (single-instance) StatusbarControllerFactory service.
+
+    @since LibreOffice 4.3
+*/
+singleton theStatusbarControllerFactory : XUIControllerFactory;
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/frame/theToolbarControllerFactory.idl b/offapi/com/sun/star/frame/theToolbarControllerFactory.idl
new file mode 100644
index 0000000..b0222af
--- /dev/null
+++ b/offapi/com/sun/star/frame/theToolbarControllerFactory.idl
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef __com_sun_star_frame_theToolbarControllerFactory_idl__
+#define __com_sun_star_frame_theToolbarControllerFactory_idl__
+
+#include <com/sun/star/frame/XUIControllerFactory.idl>
+
+module com { module sun { module star { module frame {
+
+/** specifies a factory that creates instances of registered toolbar controller.
+
+    <p>
+    A toolbar controller can be registered for a command URL and a model service name.
+    </p>
+
+    Prior to LibreOffice 4.3, this singleton was only available as a
+    (single-instance) ToolbarControllerFactory service.
+
+    @since LibreOffice 4.3
+*/
+
+singleton theToolbarControllerFactory : XUIControllerFactory;
+
+}; }; }; };
+
+#endif
diff --git a/sfx2/inc/pch/precompiled_sfx.hxx b/sfx2/inc/pch/precompiled_sfx.hxx
index f2e8713..208f750 100644
--- a/sfx2/inc/pch/precompiled_sfx.hxx
+++ b/sfx2/inc/pch/precompiled_sfx.hxx
@@ -253,7 +253,7 @@
 #include <com/sun/star/frame/IllegalArgumentIOException.hpp>
 #include <com/sun/star/frame/LayoutManagerEvents.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/ToolbarControllerFactory.hpp>
+#include <com/sun/star/frame/theToolbarControllerFactory.hpp>
 #include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/frame/UntitledNumbersConst.hpp>
 #include <com/sun/star/frame/XBorderResizeListener.hpp>
diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx
index 90e202c..3a6e294 100644
--- a/sfx2/source/sidebar/ControllerFactory.cxx
+++ b/sfx2/source/sidebar/ControllerFactory.cxx
@@ -23,7 +23,7 @@
 
 #include <com/sun/star/frame/XToolbarController.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
-#include <com/sun/star/frame/ToolbarControllerFactory.hpp>
+#include <com/sun/star/frame/theToolbarControllerFactory.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 
 #include <framework/sfxhelperfunctions.hxx>
@@ -147,7 +147,7 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBarController(
     try
     {
         Reference<XComponentContext> xContext = comphelper::getProcessComponentContext();
-        Reference<frame::XUIControllerFactory> xFactory = frame::ToolbarControllerFactory::create( xContext );
+        Reference<frame::XUIControllerFactory> xFactory = frame::theToolbarControllerFactory::get( xContext );
         OUString sModuleName (Tools::GetModuleName(rxFrame));
 
         if (xFactory.is() && xFactory->hasController(rsCommandName,  sModuleName))


More information about the Libreoffice-commits mailing list