[Libreoffice-commits] core.git: 6 commits - codemaker/source cui/inc cui/source dbaccess/inc dbaccess/source desktop/source forms/source framework/inc framework/qa framework/source framework/util include/osl offapi/com offapi/UnoApi_offapi.mk sd/inc sd/source sfx2/inc sfx2/source svtools/inc svtools/source svx/inc svx/source sw/inc sw/source vcl/inc vcl/source

Matúš Kukan matus.kukan at collabora.com
Tue Jan 28 09:53:43 PST 2014


 codemaker/source/cppumaker/cpputype.cxx                    |   34 
 cui/inc/pch/precompiled_cui.hxx                            |    4 
 cui/source/customize/acccfg.cxx                            |    4 
 cui/source/customize/cfg.cxx                               |    4 
 cui/source/customize/cfgutil.cxx                           |    8 
 cui/source/customize/selector.cxx                          |    8 
 dbaccess/inc/pch/precompiled_dbu.hxx                       |    2 
 dbaccess/source/ui/control/opendoccontrols.cxx             |    6 
 desktop/source/app/app.cxx                                 |    8 
 desktop/source/migration/migration.cxx                     |    4 
 forms/source/helper/commanddescriptionprovider.cxx         |    6 
 framework/inc/pch/precompiled_fwk.hxx                      |    4 
 framework/inc/uiconfiguration/uicategorydescription.hxx    |   58 -
 framework/inc/uielement/uicommanddescription.hxx           |   46 
 framework/qa/complex/framework/autosave/AutoSave.java      |    3 
 framework/source/fwi/helper/mischelper.cxx                 |    4 
 framework/source/register/registerservices.cxx             |    4 
 framework/source/services/autorecovery.cxx                 |  615 +++++--------
 framework/source/services/sessionlistener.cxx              |    8 
 framework/source/uiconfiguration/imagemanagerimpl.cxx      |    4 
 framework/source/uiconfiguration/uicategorydescription.cxx |  101 +-
 framework/source/uielement/toolbarmanager.cxx              |    4 
 framework/source/uielement/toolbarsmenucontroller.cxx      |    4 
 framework/source/uielement/uicommanddescription.cxx        |   77 -
 framework/util/fwk.component                               |    9 
 include/osl/detail/component-defines.h                     |    2 
 offapi/UnoApi_offapi.mk                                    |    3 
 offapi/com/sun/star/frame/AutoRecovery.idl                 |    3 
 offapi/com/sun/star/frame/UICommandDescription.idl         |   20 
 offapi/com/sun/star/frame/theAutoRecovery.idl              |   28 
 offapi/com/sun/star/frame/theUICommandDescription.idl      |   60 +
 offapi/com/sun/star/ui/UICategoryDescription.idl           |   30 
 offapi/com/sun/star/ui/theUICategoryDescription.idl        |   64 +
 sd/inc/pch/precompiled_sd.hxx                              |    4 
 sd/source/ui/dlg/dlgass.cxx                                |    4 
 sd/source/ui/slideshow/slideshowimpl.cxx                   |    4 
 sd/source/ui/view/ViewShellBase.cxx                        |    4 
 sfx2/inc/pch/precompiled_sfx.hxx                           |    2 
 sfx2/source/dialog/recfloat.cxx                            |    4 
 sfx2/source/dialog/templdlg.cxx                            |    4 
 sfx2/source/sidebar/CommandInfoProvider.cxx                |    4 
 sfx2/source/view/viewsh.cxx                                |    4 
 svtools/inc/pch/precompiled_svt.hxx                        |    2 
 svtools/source/uno/contextmenuhelper.cxx                   |    4 
 svx/inc/pch/precompiled_svx.hxx                            |    2 
 svx/source/dialog/docrecovery.cxx                          |    4 
 sw/inc/pch/precompiled_sw.hxx                              |    2 
 sw/source/ui/lingu/olmenu.cxx                              |    4 
 vcl/inc/pch/precompiled_vcl.hxx                            |    2 
 vcl/source/window/toolbox2.cxx                             |    4 
 50 files changed, 691 insertions(+), 606 deletions(-)

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

    fwk: Constructor feature for one instance UICommandDescription.
    
    Change-Id: I3b772ce36492e89451597b3c7dadc5e5b5b22de7

diff --git a/framework/inc/uielement/uicommanddescription.hxx b/framework/inc/uielement/uicommanddescription.hxx
index 08a2518..c3f113e 100644
--- a/framework/inc/uielement/uicommanddescription.hxx
+++ b/framework/inc/uielement/uicommanddescription.hxx
@@ -20,41 +20,51 @@
 #ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_UICOMMANDDESCRIPTION_HXX
 #define INCLUDED_FRAMEWORK_INC_UIELEMENT_UICOMMANDDESCRIPTION_HXX
 
-/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble
-               with solaris headers ...
-*/
-#include <vector>
-#include <list>
 #include <boost/unordered_map.hpp>
 
-#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/configuration/theDefaultProvider.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/frame/XModuleManager2.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
 
-#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/supportsservice.hxx>
 #include <rtl/ustring.hxx>
 
 namespace framework
 {
-class UICommandDescription :  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::container::XNameAccess >
+typedef ::cppu::WeakComponentImplHelper2< com::sun::star::lang::XServiceInfo,
+        com::sun::star::container::XNameAccess > UICommandDescription_BASE;
+
+class UICommandDescription : private osl::Mutex,
+                             public UICommandDescription_BASE
 {
     public:
         UICommandDescription( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
         virtual ~UICommandDescription();
 
-        //  XInterface, XTypeProvider, XServiceInfo
-        DECLARE_XSERVICEINFO
+        virtual OUString SAL_CALL getImplementationName()
+            throw (css::uno::RuntimeException)
+        {
+            return OUString("com.sun.star.comp.framework.UICommandDescription");
+        }
+
+        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.UICommandDescription");
+            return aSeq;
+        }
+
 private:
         // XNameAccess
         virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx
index 3fe6481..fc55475 100644
--- a/framework/source/register/registerservices.cxx
+++ b/framework/source/register/registerservices.cxx
@@ -36,7 +36,6 @@
 #include <services/desktop.hxx>
 #include <uifactory/uielementfactorymanager.hxx>
 #include <uifactory/uicontrollerfactory.hxx>
-#include <uielement/uicommanddescription.hxx>
 #include <uiconfiguration/moduleuicfgsupplier.hxx>
 #include <uifactory/menubarfactory.hxx>
 #include <uifactory/toolboxfactory.hxx>
@@ -53,7 +52,6 @@ COMPONENTGETFACTORY ( fwk,
                         IFFACTORY( ::framework::Desktop                                 )   else
                         IFFACTORY( ::framework::UIElementFactoryManager                 )   else
                         IFFACTORY( ::framework::PopupMenuControllerFactory              )   else
-                        IFFACTORY( ::framework::UICommandDescription                    )   else
                         IFFACTORY( ::framework::ModuleUIConfigurationManagerSupplier    )   else
                         IFFACTORY( ::framework::MenuBarFactory                          )   else
                         IFFACTORY( ::framework::ToolBoxFactory                          )   else
diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx
index 9480d46..84a4563 100644
--- a/framework/source/uielement/uicommanddescription.cxx
+++ b/framework/source/uielement/uicommanddescription.cxx
@@ -18,8 +18,6 @@
  */
 
 #include "uielement/uicommanddescription.hxx"
-#include <threadhelp/resetableguard.hxx>
-#include "services.h"
 
 #include "properties.h"
 
@@ -41,10 +39,6 @@
 #include <comphelper/sequence.hxx>
 #include <comphelper/string.hxx>
 
-//_________________________________________________________________________________________________________________
-//  Defines
-//_________________________________________________________________________________________________________________
-
 using namespace com::sun::star::uno;
 using namespace com::sun::star::lang;
 using namespace com::sun::star::beans;
@@ -89,9 +83,9 @@ namespace framework
 //*****************************************************************************************************************
 
 class ConfigurationAccess_UICommand : // Order is necessary for right initialization!
-                                        private ThreadHelpBase                           ,
                                         public  ::cppu::WeakImplHelper2<XNameAccess,XContainerListener>
 {
+    osl::Mutex m_aMutex;
     public:
                                   ConfigurationAccess_UICommand( const OUString& aModuleName, const Reference< XNameAccess >& xGenericUICommands, const Reference< XComponentContext >& rxContext );
         virtual                   ~ConfigurationAccess_UICommand();
@@ -189,7 +183,6 @@ class ConfigurationAccess_UICommand : // Order is necessary for right initializa
 //  XInterface, XTypeProvider
 //*****************************************************************************************************************
 ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const OUString& aModuleName, const Reference< XNameAccess >& rGenericUICommands, const Reference< XComponentContext>& rxContext ) :
-    ThreadHelpBase(),
     m_aConfigCmdAccess( CONFIGURATION_ROOT_ACCESS ),
     m_aConfigPopupAccess( CONFIGURATION_ROOT_ACCESS ),
     m_aPropUILabel( CONFIGURATION_PROPERTY_LABEL ),
@@ -217,7 +210,7 @@ ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( const OUString& aM
 ConfigurationAccess_UICommand::~ConfigurationAccess_UICommand()
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
     Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
     if ( xContainer.is() )
         xContainer->removeContainerListener(m_xConfigListener);
@@ -232,7 +225,7 @@ Any SAL_CALL ConfigurationAccess_UICommand::getByNameImpl( const OUString& rComm
 {
     static sal_Int32 nRequests  = 0;
 
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
     if ( !m_bConfigAccessInitialized )
     {
         initializeConfigAccess();
@@ -473,7 +466,7 @@ Any ConfigurationAccess_UICommand::getInfoFromCommand( const OUString& rCommandU
 Sequence< OUString > ConfigurationAccess_UICommand::getAllCommands()
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
 
     if ( !m_bConfigAccessInitialized )
     {
@@ -528,7 +521,8 @@ sal_Bool ConfigurationAccess_UICommand::initializeConfigAccess()
         aPropValue.Value <<= m_aConfigCmdAccess;
         aArgs[0] <<= aPropValue;
 
-        m_xConfigAccess = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,aArgs ),UNO_QUERY );
+        m_xConfigAccess = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments(
+                    "com.sun.star.configuration.ConfigurationAccess", aArgs ),UNO_QUERY );
         if ( m_xConfigAccess.is() )
         {
             // Add as container listener
@@ -542,7 +536,8 @@ sal_Bool ConfigurationAccess_UICommand::initializeConfigAccess()
 
         aPropValue.Value <<= m_aConfigPopupAccess;
         aArgs[0] <<= aPropValue;
-        m_xConfigAccessPopups = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,aArgs ),UNO_QUERY );
+        m_xConfigAccessPopups = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments(
+                    "com.sun.star.configuration.ConfigurationAccess", aArgs ),UNO_QUERY );
         if ( m_xConfigAccessPopups.is() )
         {
             // Add as container listener
@@ -569,21 +564,21 @@ sal_Bool ConfigurationAccess_UICommand::initializeConfigAccess()
 // container.XContainerListener
 void SAL_CALL ConfigurationAccess_UICommand::elementInserted( const ContainerEvent& ) throw(RuntimeException)
 {
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
     m_bCacheFilled = sal_False;
     fillCache();
 }
 
 void SAL_CALL ConfigurationAccess_UICommand::elementRemoved( const ContainerEvent& ) throw(RuntimeException)
 {
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
     m_bCacheFilled = sal_False;
     fillCache();
 }
 
 void SAL_CALL ConfigurationAccess_UICommand::elementReplaced( const ContainerEvent& ) throw(RuntimeException)
 {
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
     m_bCacheFilled = sal_False;
     fillCache();
 }
@@ -593,7 +588,7 @@ void SAL_CALL ConfigurationAccess_UICommand::disposing( const EventObject& aEven
 {
     // SAFE
     // remove our reference to the config access
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(m_aMutex);
 
     Reference< XInterface > xIfac1( aEvent.Source, UNO_QUERY );
     Reference< XInterface > xIfac2( m_xConfigAccess, UNO_QUERY );
@@ -607,19 +602,8 @@ void SAL_CALL ConfigurationAccess_UICommand::disposing( const EventObject& aEven
     }
 }
 
-//*****************************************************************************************************************
-//  XInterface, XTypeProvider, XServiceInfo
-//*****************************************************************************************************************
-DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2  (   UICommandDescription                    ,
-                                            ::cppu::OWeakObject                     ,
-                                            "com.sun.star.frame.UICommandDescription",
-                                            IMPLEMENTATIONNAME_UICOMMANDDESCRIPTION
-                                        )
-
-DEFINE_INIT_SERVICE                     (   UICommandDescription, {} )
-
 UICommandDescription::UICommandDescription( const Reference< XComponentContext >& rxContext ) :
-    ThreadHelpBase(),
+    UICommandDescription_BASE(*static_cast<osl::Mutex *>(this)),
     m_aPrivateResourceURL( PRIVATE_RESOURCE_URL ),
     m_xContext( rxContext )
 {
@@ -635,13 +619,13 @@ UICommandDescription::UICommandDescription( const Reference< XComponentContext >
         pIter->second = m_xGenericUICommands;
 }
 UICommandDescription::UICommandDescription( const Reference< XComponentContext >& rxContext, bool ) :
-    ThreadHelpBase(),
+    UICommandDescription_BASE(*static_cast<osl::Mutex *>(this)),
     m_xContext( rxContext )
 {
 }
 UICommandDescription::~UICommandDescription()
 {
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(rBHelper.rMutex);
     m_aModuleToCommandFileMap.clear();
     m_aUICommandsHashMap.clear();
     m_xGenericUICommands.clear();
@@ -688,7 +672,7 @@ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::la
 {
     Any a;
 
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(rBHelper.rMutex);
 
     ModuleToCommandFileMap::const_iterator pM2CIter = m_aModuleToCommandFileMap.find( aName );
     if ( pM2CIter != m_aModuleToCommandFileMap.end() )
@@ -727,7 +711,7 @@ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::la
 Sequence< OUString > SAL_CALL UICommandDescription::getElementNames()
 throw (::com::sun::star::uno::RuntimeException)
 {
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(rBHelper.rMutex);
 
     Sequence< OUString > aSeq( m_aModuleToCommandFileMap.size() );
 
@@ -745,7 +729,7 @@ throw (::com::sun::star::uno::RuntimeException)
 sal_Bool SAL_CALL UICommandDescription::hasByName( const OUString& aName )
 throw (::com::sun::star::uno::RuntimeException)
 {
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(rBHelper.rMutex);
 
     ModuleToCommandFileMap::const_iterator pIter = m_aModuleToCommandFileMap.find( aName );
     return ( pIter != m_aModuleToCommandFileMap.end() );
@@ -765,6 +749,31 @@ throw (::com::sun::star::uno::RuntimeException)
     return sal_True;
 }
 
+struct Instance {
+    explicit Instance(
+        css::uno::Reference<css::uno::XComponentContext> const & context):
+        instance(static_cast<cppu::OWeakObject *>(
+                    new UICommandDescription(context)))
+    {
+    }
+
+    css::uno::Reference<css::uno::XInterface> instance;
+};
+
+struct Singleton:
+    public rtl::StaticWithArg<
+        Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
+{};
+
 } // namespace framework
 
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_framework_UICommandDescription_get_implementation(
+    css::uno::XComponentContext *context,
+    css::uno::Sequence<css::uno::Any> const &)
+{
+    return cppu::acquire(static_cast<cppu::OWeakObject *>(
+                framework::Singleton::get(context).instance.get()));
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index c63d108..2a211ce 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -130,7 +130,8 @@
     <service name="com.sun.star.ui.UICategoryDescription"/>
     <singleton name="com.sun.star.ui.theUICategoryDescription"/>
   </implementation>
-  <implementation name="com.sun.star.comp.framework.UICommandDescription">
+  <implementation name="com.sun.star.comp.framework.UICommandDescription"
+      constructor="com_sun_star_comp_framework_UICommandDescription_get_implementation">
     <service name="com.sun.star.frame.UICommandDescription"/>
     <singleton name="com.sun.star.frame.theUICommandDescription"/>
   </implementation>
commit ba8413d2629352b1e5defaf154498856580e4651
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue Jan 28 15:27:32 2014 +0100

    Introduce com.sun.star.frame.theUICommandDescription singleton.
    
    Change-Id: Ic88cca3722d555ba48d7da8c176556fa1ff90650

diff --git a/cui/inc/pch/precompiled_cui.hxx b/cui/inc/pch/precompiled_cui.hxx
index 264817d..5108a64 100644
--- a/cui/inc/pch/precompiled_cui.hxx
+++ b/cui/inc/pch/precompiled_cui.hxx
@@ -113,7 +113,7 @@
 #include <com/sun/star/frame/FrameSearchFlag.hpp>
 #include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/frame/XController.hpp>
 #include <com/sun/star/frame/XDesktop.hpp>
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx
index 419eead..489aace 100644
--- a/cui/source/customize/acccfg.cxx
+++ b/cui/source/customize/acccfg.cxx
@@ -52,7 +52,7 @@
 #include <com/sun/star/frame/XController.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/UIConfigurationManager.hpp>
@@ -830,7 +830,7 @@ void SfxAcceleratorConfigPage::InitAccCfg()
         // no - initialize this instance
         m_xContext = ::comphelper::getProcessComponentContext();
 
-        m_xUICmdDescription = css::frame::UICommandDescription::create(m_xContext);
+        m_xUICmdDescription = css::frame::theUICommandDescription::get(m_xContext);
 
         // get the current active frame, which should be our "parent"
         // for this session
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 58f7b32..3f89c70 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -71,7 +71,7 @@
 #include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/XController.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/graphic/GraphicProvider.hpp>
 #include <com/sun/star/ui/ItemType.hpp>
 #include <com/sun/star/ui/ItemStyle.hpp>
@@ -869,7 +869,7 @@ SaveInData::SaveInData(
     uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
 
     uno::Reference< container::XNameAccess > xNameAccess(
-        css::frame::UICommandDescription::create(xContext) );
+        css::frame::theUICommandDescription::get(xContext) );
 
     xNameAccess->getByName( aModuleId ) >>= m_xCommandToLabelMap;
 
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index f817ea7..4a93a6f 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -25,7 +25,7 @@
 #include <com/sun/star/document/XScriptInvocationContext.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/frame/XDispatchInformationProvider.hpp>
 #include <com/sun/star/script/browse/XBrowseNode.hpp>
 #include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
@@ -597,7 +597,7 @@ void SfxConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent
 
         m_xGlobalCategoryInfo = css::ui::theUICategoryDescription::get( m_xContext );
         m_xModuleCategoryInfo = css::uno::Reference< css::container::XNameAccess >(m_xGlobalCategoryInfo->getByName(m_sModuleLongName), css::uno::UNO_QUERY_THROW);
-        m_xUICmdDescription   = css::frame::UICommandDescription::create( m_xContext );
+        m_xUICmdDescription   = css::frame::theUICommandDescription::get( m_xContext );
 
         InitModule();
         InitBasic();
diff --git a/cui/source/customize/selector.cxx b/cui/source/customize/selector.cxx
index a33623a..4db4c27 100644
--- a/cui/source/customize/selector.cxx
+++ b/cui/source/customize/selector.cxx
@@ -46,7 +46,7 @@
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/frame/XDispatchInformationProvider.hpp>
 #include <com/sun/star/frame/DispatchInformation.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
 #include <com/sun/star/script/provider/XScriptProvider.hpp>
 #include <com/sun/star/script/browse/theBrowseNodeFactory.hpp>
@@ -425,7 +425,7 @@ void SvxConfigGroupListBox::Init(bool bShowSlots, const Reference< frame::XFrame
             { aModuleId = OUString(); }
 
         Reference< container::XNameAccess > const xNameAccess(
-                frame::UICommandDescription::create(xContext) );
+                frame::theUICommandDescription::get(xContext) );
         xNameAccess->getByName( aModuleId ) >>= m_xModuleCommands;
 
         Reference< container::XNameAccess > xAllCategories =
diff --git a/dbaccess/inc/pch/precompiled_dbu.hxx b/dbaccess/inc/pch/precompiled_dbu.hxx
index c3ef98d..14c809c 100644
--- a/dbaccess/inc/pch/precompiled_dbu.hxx
+++ b/dbaccess/inc/pch/precompiled_dbu.hxx
@@ -112,7 +112,7 @@
 #include <com/sun/star/frame/Frame.hpp>
 #include <com/sun/star/frame/FrameSearchFlag.hpp>
 #include <com/sun/star/frame/TaskCreator.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/frame/XController2.hpp>
 #include <com/sun/star/frame/XDispatchProvider.hpp>
diff --git a/dbaccess/source/ui/control/opendoccontrols.cxx b/dbaccess/source/ui/control/opendoccontrols.cxx
index e3372b9..008f367 100644
--- a/dbaccess/source/ui/control/opendoccontrols.cxx
+++ b/dbaccess/source/ui/control/opendoccontrols.cxx
@@ -24,7 +24,7 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
 #include <com/sun/star/graphic/XGraphic.hpp>
 #include <com/sun/star/ui/XImageManager.hpp>
@@ -56,7 +56,7 @@ namespace dbaui
         using ::com::sun::star::ui::XModuleUIConfigurationManagerSupplier;
         using ::com::sun::star::ui::XUIConfigurationManager;
         using ::com::sun::star::ui::XImageManager;
-        using ::com::sun::star::frame::UICommandDescription;
+        using ::com::sun::star::frame::theUICommandDescription;
         using ::com::sun::star::graphic::XGraphic;
 
         OUString GetCommandText( const sal_Char* _pCommandURL, const OUString& _rModuleName )
@@ -77,7 +77,7 @@ namespace dbaui
                     if ( !xContext.is() )
                         break;
 
-                    Reference< XNameAccess> xNameAccess( UICommandDescription::create(xContext) );
+                    Reference< XNameAccess> xNameAccess( theUICommandDescription::get(xContext) );
 
                     xNameAccess->getByName( _rModuleName ) >>= xUICommandLabels;
                     if ( !xUICommandLabels.is() )
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index c48f9f8..3715e72 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -68,7 +68,7 @@
 #include <com/sun/star/task/OfficeRestartManager.hpp>
 #include <com/sun/star/task/XRestartManager.hpp>
 #include <com/sun/star/document/XEventListener.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/ui/UIElementFactoryManager.hpp>
 #include <com/sun/star/ui/WindowStateConfiguration.hpp>
 #include <com/sun/star/frame/XUIControllerRegistration.hpp>
@@ -2092,7 +2092,7 @@ void Desktop::PreloadModuleData( const CommandLineArgs& rArgs )
 void Desktop::PreloadConfigurationData()
 {
     Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
-    Reference< XNameAccess > xNameAccess = css::frame::UICommandDescription::create(xContext);
+    Reference< XNameAccess > xNameAccess = css::frame::theUICommandDescription::get(xContext);
 
     OUString aWriterDoc( "com.sun.star.text.TextDocument" );
     OUString aCalcDoc( "com.sun.star.sheet.SpreadsheetDocument" );
diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx
index ff51660..c6e0466 100644
--- a/desktop/source/migration/migration.cxx
+++ b/desktop/source/migration/migration.cxx
@@ -54,7 +54,7 @@
 #include <com/sun/star/embed/FileSystemStorageFactory.hpp>
 #include <com/sun/star/embed/XStorage.hpp>
 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/ui/UIConfigurationManager.hpp>
 #include <com/sun/star/ui/XUIConfiguration.hpp>
 #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
@@ -83,7 +83,7 @@ OUString retrieveLabelFromCommand(const OUString& sCommand, const OUString& sMod
 
     uno::Reference< container::XNameAccess > xUICommands;
     uno::Reference< container::XNameAccess > const xNameAccess(
-            frame::UICommandDescription::create(
+            frame::theUICommandDescription::get(
                 ::comphelper::getProcessComponentContext()) );
     xNameAccess->getByName( sModuleIdentifier ) >>= xUICommands;
     if (xUICommands.is())
diff --git a/forms/source/helper/commanddescriptionprovider.cxx b/forms/source/helper/commanddescriptionprovider.cxx
index b1edc2a..045fe58 100644
--- a/forms/source/helper/commanddescriptionprovider.cxx
+++ b/forms/source/helper/commanddescriptionprovider.cxx
@@ -23,7 +23,7 @@
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 
 #include <comphelper/namedvaluecollection.hxx>
 #include <tools/diagnose_ex.h>
@@ -50,7 +50,7 @@ namespace frm
     using ::com::sun::star::frame::ModuleManager;
     using ::com::sun::star::frame::XModuleManager2;
     using ::com::sun::star::beans::PropertyValue;
-    using ::com::sun::star::frame::UICommandDescription;
+    using ::com::sun::star::frame::theUICommandDescription;
 
     //====================================================================
     //= DefaultCommandDescriptionProvider
@@ -90,7 +90,7 @@ namespace frm
             Reference< XModuleManager2 > xModuleManager( ModuleManager::create(_rxContext) );
             OUString sModuleID = xModuleManager->identify( _rxDocument );
 
-            Reference< XNameAccess > xUICommandDescriptions( UICommandDescription::create(_rxContext) );
+            Reference< XNameAccess > xUICommandDescriptions( theUICommandDescription::get(_rxContext) );
             m_xCommandAccess.set( xUICommandDescriptions->getByName( sModuleID ), UNO_QUERY_THROW );
         }
         catch( const Exception& )
diff --git a/framework/inc/pch/precompiled_fwk.hxx b/framework/inc/pch/precompiled_fwk.hxx
index 2fb34f6..c9b8c09 100644
--- a/framework/inc/pch/precompiled_fwk.hxx
+++ b/framework/inc/pch/precompiled_fwk.hxx
@@ -126,7 +126,7 @@
 #include <com/sun/star/frame/StatusbarControllerFactory.hpp>
 #include <com/sun/star/frame/TaskCreator.hpp>
 #include <com/sun/star/frame/ToolbarControllerFactory.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/frame/XControlNotificationListener.hpp>
 #include <com/sun/star/frame/XController.hpp>
diff --git a/framework/source/fwi/helper/mischelper.cxx b/framework/source/fwi/helper/mischelper.cxx
index a9a0684..9970c52 100644
--- a/framework/source/fwi/helper/mischelper.cxx
+++ b/framework/source/fwi/helper/mischelper.cxx
@@ -21,7 +21,7 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/document/XDocumentLanguages.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/linguistic2/LanguageGuessing.hpp>
 
@@ -94,7 +94,7 @@ OUString RetrieveLabelFromCommand(
                 }
             }
 
-            Reference< XNameAccess > xNameAccess = frame::UICommandDescription::create( _xContext );
+            Reference< XNameAccess > xNameAccess = frame::theUICommandDescription::get( _xContext );
             xNameAccess->getByName( _rModuleIdentifier ) >>= _xUICommandLabels;
         }
         catch ( const Exception& )
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx
index e039276..5a36fef 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.cxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx
@@ -26,7 +26,7 @@
 
 #include "properties.h"
 
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/ui/UIElementType.hpp>
 #include <com/sun/star/ui/ConfigurationEvent.hpp>
 #include <com/sun/star/lang/DisposedException.hpp>
@@ -173,7 +173,7 @@ void CmdImageList::impl_fillCommandToImageNameMap()
     {
         const OUString aCommandImageList( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDIMAGELIST );
         Sequence< OUString > aCmdImageSeq;
-        uno::Reference< XNameAccess > xCmdDesc = frame::UICommandDescription::create( m_xContext );
+        uno::Reference< XNameAccess > xCmdDesc = frame::theUICommandDescription::get( m_xContext );
 
         if ( !m_aModuleIdentifier.isEmpty() )
         {
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 3a2617b..71d8a84 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -33,7 +33,7 @@
 
 #include <com/sun/star/ui/ItemType.hpp>
 #include <com/sun/star/frame/XDispatchProvider.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/awt/XDockableWindow.hpp>
 #include <com/sun/star/frame/XLayoutManager.hpp>
@@ -795,7 +795,7 @@ uno::Sequence< beans::PropertyValue > ToolBarManager::GetPropsForCommand( const
 
             if ( !m_aModuleIdentifier.isEmpty() )
             {
-                Reference< XNameAccess > xNameAccess = frame::UICommandDescription::create( m_xContext );
+                Reference< XNameAccess > xNameAccess = frame::theUICommandDescription::get( m_xContext );
                 xNameAccess->getByName( m_aModuleIdentifier ) >>= m_xUICommandLabels;
             }
         }
diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx
index 1f3917c..f758c6b 100644
--- a/framework/source/uielement/toolbarsmenucontroller.cxx
+++ b/framework/source/uielement/toolbarsmenucontroller.cxx
@@ -34,7 +34,7 @@
 #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/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/frame/XLayoutManager.hpp>
@@ -222,7 +222,7 @@ OUString ToolbarsMenuController::getUINameFromCommand( const OUString& rCommandU
         {
             Reference< XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext );
             m_aModuleIdentifier = xModuleManager->identify( m_xFrame );
-            Reference< XNameAccess > xNameAccess = frame::UICommandDescription::create( m_xContext );
+            Reference< XNameAccess > xNameAccess = frame::theUICommandDescription::get( m_xContext );
             xNameAccess->getByName( m_aModuleIdentifier ) >>= m_xUICommandDescription;
         }
         catch ( const Exception& )
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index 98f36f8..c63d108 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -132,6 +132,7 @@
   </implementation>
   <implementation name="com.sun.star.comp.framework.UICommandDescription">
     <service name="com.sun.star.frame.UICommandDescription"/>
+    <singleton name="com.sun.star.frame.theUICommandDescription"/>
   </implementation>
   <implementation name="com.sun.star.comp.framework.UIConfigurationManager"
       constructor="com_sun_star_comp_framework_UIConfigurationManager_get_implementation">
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 519c145..cd7434f 100755
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -202,6 +202,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/frame,\
 	UICommandDescription \
 	theAutoRecovery \
 	theGlobalEventBroadcaster \
+	theUICommandDescription \
 ))
 $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/graphic,\
 	GraphicObject \
diff --git a/offapi/com/sun/star/frame/UICommandDescription.idl b/offapi/com/sun/star/frame/UICommandDescription.idl
index 5d3a814..76e6db9 100644
--- a/offapi/com/sun/star/frame/UICommandDescription.idl
+++ b/offapi/com/sun/star/frame/UICommandDescription.idl
@@ -26,26 +26,12 @@
 module com { module sun { module star { module frame {
 
 
-/** a service which provides information about user interface commands of modules.
+/**
+    A legacy (single-instance) service-variant of theUICommandDescription singleton.
 
-    <p>
-    OpenOffice.org has an amount of commands that can be used by user interface
-    elements. This service provides access to the user interface commands that
-    are part of OpenOffice.org modules, like Writer or Calc.
-    </p>
+    @deprecated Use theUICommandDescription singleton instead.
 
     @since OOo 2.0
-
-    Provides access to user interface commands of the installed modules.
-
-    <p>
-    To access the user interface command description of a module, a unique module specifier
-    must be provided to com::sun::star::container::XNameAccess::getByName() function.
-    The module specifier can be retrieved from the com::sun::star::frame::ModuleManager
-    service. The interface provides references to com::sun:star::ui::ModuleUICommandDescription.
-    </p>
-
-    @see com::sun::star::frame::ModuleManager
 */
 service UICommandDescription : com::sun::star::container::XNameAccess;
 
diff --git a/offapi/com/sun/star/frame/theUICommandDescription.idl b/offapi/com/sun/star/frame/theUICommandDescription.idl
new file mode 100644
index 0000000..7765df7
--- /dev/null
+++ b/offapi/com/sun/star/frame/theUICommandDescription.idl
@@ -0,0 +1,60 @@
+/* -*- 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_theUICommandDescription_idl__
+#define __com_sun_star_frame_theUICommandDescription_idl__
+
+#include <com/sun/star/container/XNameAccess.idl>
+
+
+module com { module sun { module star { module frame {
+
+
+/** a singleton which provides information about user interface commands of modules.
+
+    <p>
+    OpenOffice.org has an amount of commands that can be used by user interface
+    elements. This singleton provides access to the user interface commands that
+    are part of OpenOffice.org modules, like Writer or Calc.
+    </p>
+
+    Provides access to user interface commands of the installed modules.
+
+    <p>
+    To access the user interface command description of a module, a unique module specifier
+    must be provided to com::sun::star::container::XNameAccess::getByName() function.
+    The module specifier can be retrieved from the com::sun::star::frame::ModuleManager
+    service. The interface provides references to com::sun:star::ui::ModuleUICommandDescription.
+    </p>
+
+    @see com::sun::star::frame::ModuleManager
+
+    Prior to LibreOffice 4.3, this singleton was only available as a
+    (single-instance) UICommandDescription service.
+
+    @since LibreOffice 4.3
+
+*/
+singleton theUICommandDescription : com::sun::star::container::XNameAccess;
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/inc/pch/precompiled_sd.hxx b/sd/inc/pch/precompiled_sd.hxx
index 8867391..f9365d7 100644
--- a/sd/inc/pch/precompiled_sd.hxx
+++ b/sd/inc/pch/precompiled_sd.hxx
@@ -210,7 +210,7 @@
 #include <com/sun/star/frame/FrameAction.hpp>
 #include <com/sun/star/frame/FrameActionEvent.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/frame/UnknownModuleException.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/frame/XController.hpp>
diff --git a/sd/source/ui/dlg/dlgass.cxx b/sd/source/ui/dlg/dlgass.cxx
index 58e5d25..207be88 100644
--- a/sd/source/ui/dlg/dlgass.cxx
+++ b/sd/source/ui/dlg/dlgass.cxx
@@ -50,7 +50,7 @@
 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/XImageManager.hpp>
 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <unotools/historyoptions.hxx>
 #include <osl/file.hxx>
 #include <sfx2/filedlghelper.hxx>
@@ -1734,7 +1734,7 @@ OUString AssistentDlgImpl::GetUiTextForCommand (const OUString& sCommandURL)
                 break;
 
             Reference<container::XNameAccess> const xNameAccess(
-                    frame::UICommandDescription::create(xContext) );
+                    frame::theUICommandDescription::get(xContext) );
             Any a = xNameAccess->getByName(
                 "com.sun.star.presentation.PresentationDocument");
             a >>= xUICommandLabels;
diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx
index c30cda2..6895ef7 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -23,7 +23,7 @@
 #include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 
 #include "ViewShellBase.hxx"
 #include <algorithm>
@@ -1111,7 +1111,7 @@ OUString ImplRetrieveLabelFromCommand( const Reference< XFrame >& xFrame, const
         if( !aModuleIdentifier.isEmpty() )
         {
             Reference< XNameAccess > const xNameAccess(
-                    frame::UICommandDescription::create(xContext) );
+                    frame::theUICommandDescription::get(xContext) );
             Reference< ::com::sun::star::container::XNameAccess > m_xUICommandLabels( xNameAccess->getByName( aModuleIdentifier ), UNO_QUERY_THROW );
             Sequence< PropertyValue > aPropSeq;
             if( m_xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq )
diff --git a/sfx2/inc/pch/precompiled_sfx.hxx b/sfx2/inc/pch/precompiled_sfx.hxx
index 1c8c73b..f2e8713 100644
--- a/sfx2/inc/pch/precompiled_sfx.hxx
+++ b/sfx2/inc/pch/precompiled_sfx.hxx
@@ -254,7 +254,7 @@
 #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/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/frame/UntitledNumbersConst.hpp>
 #include <com/sun/star/frame/XBorderResizeListener.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
diff --git a/sfx2/source/dialog/recfloat.cxx b/sfx2/source/dialog/recfloat.cxx
index df34bb0..d943ddc 100644
--- a/sfx2/source/dialog/recfloat.cxx
+++ b/sfx2/source/dialog/recfloat.cxx
@@ -21,7 +21,7 @@
 #include <com/sun/star/frame/ModuleManager.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 
 #include <svl/eitem.hxx>
 #include <svtools/generictoolboxcontroller.hxx>
@@ -63,7 +63,7 @@ static OUString GetLabelFromCommandURL( const OUString& rCommandURL, const uno::
     xUICommandDescription = xTmpNameAccess;
     if ( !xUICommandDescription.is() )
     {
-        xUICommandDescription = frame::UICommandDescription::create(xContext);
+        xUICommandDescription = frame::theUICommandDescription::get(xContext);
         xTmpNameAccess = xUICommandDescription;
     }
 
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 46f3238..5af6681 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -31,7 +31,7 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 
 #include <sfx2/sfxhelp.hxx>
 #include <sfx2/app.hxx>
@@ -2781,7 +2781,7 @@ IMPL_LINK( SfxTemplateDialog_Impl, ToolBoxRClick, ToolBox *, pBox )
         //create a popup menu in Writer
         boost::scoped_ptr<PopupMenu> pMenu(new PopupMenu);
         uno::Reference< container::XNameAccess > xNameAccess(
-                frame::UICommandDescription::create(
+                frame::theUICommandDescription::get(
                     ::comphelper::getProcessComponentContext()) );
         uno::Reference< container::XNameAccess > xUICommands;
         OUString sTextDoc("com.sun.star.text.TextDocument");
diff --git a/sfx2/source/sidebar/CommandInfoProvider.cxx b/sfx2/source/sidebar/CommandInfoProvider.cxx
index 6753692..61d1b62 100644
--- a/sfx2/source/sidebar/CommandInfoProvider.cxx
+++ b/sfx2/source/sidebar/CommandInfoProvider.cxx
@@ -25,7 +25,7 @@
 #include <cppuhelper/basemutex.hxx>
 
 #include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
@@ -305,7 +305,7 @@ Sequence<beans::PropertyValue> CommandInfoProvider::GetCommandProperties (const
         const OUString sModuleIdentifier (GetModuleIdentifier());
         if (sModuleIdentifier.getLength() > 0)
         {
-            Reference<container::XNameAccess> xNameAccess  = frame::UICommandDescription::create(mxContext);
+            Reference<container::XNameAccess> xNameAccess  = frame::theUICommandDescription::get(mxContext);
             Reference<container::XNameAccess> xUICommandLabels;
             if (xNameAccess->getByName(sModuleIdentifier) >>= xUICommandLabels)
                 xUICommandLabels->getByName(rsCommandName) >>= aProperties;
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 3d5199d..cdababa 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -33,7 +33,7 @@
 #include <com/sun/star/container/XContainerQuery.hpp>
 #include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <cppuhelper/implbase1.hxx>
 
 #include <osl/file.hxx>
@@ -242,7 +242,7 @@ static OUString RetrieveLabelFromCommand(
         if ( !xNameAccess.is() )
         {
             xNameAccess = css::uno::Reference< css::container::XNameAccess >(
-                css::frame::UICommandDescription::create(xContext),
+                css::frame::theUICommandDescription::get(xContext),
                     css::uno::UNO_QUERY_THROW );
             s_xNameAccess = xNameAccess;
         }
diff --git a/svtools/inc/pch/precompiled_svt.hxx b/svtools/inc/pch/precompiled_svt.hxx
index fd97b7b..cb98da3 100644
--- a/svtools/inc/pch/precompiled_svt.hxx
+++ b/svtools/inc/pch/precompiled_svt.hxx
@@ -142,7 +142,7 @@
 #include <com/sun/star/frame/DocumentTemplates.hpp>
 #include <com/sun/star/frame/Frame.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/frame/XController.hpp>
 #include <com/sun/star/frame/XDispatch.hpp>
diff --git a/svtools/source/uno/contextmenuhelper.cxx b/svtools/source/uno/contextmenuhelper.cxx
index 7c8abc6..6132665 100644
--- a/svtools/source/uno/contextmenuhelper.cxx
+++ b/svtools/source/uno/contextmenuhelper.cxx
@@ -31,7 +31,7 @@
 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
 #include <com/sun/star/ui/ImageType.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/util/URLTransformer.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 
@@ -428,7 +428,7 @@ ContextMenuHelper::associateUIConfigurationManagers()
             }
 
             uno::Reference< container::XNameAccess > xNameAccess(
-                frame::UICommandDescription::create(
+                frame::theUICommandDescription::get(
                         ::comphelper::getProcessComponentContext()),
                     uno::UNO_QUERY_THROW );
             try
diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx
index 7b1315d..a90133e 100644
--- a/sw/inc/pch/precompiled_sw.hxx
+++ b/sw/inc/pch/precompiled_sw.hxx
@@ -185,7 +185,7 @@
 #include <com/sun/star/frame/DispatchHelper.hpp>
 #include <com/sun/star/frame/DispatchResultState.hpp>
 #include <com/sun/star/frame/FrameSearchFlag.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/frame/XController.hpp>
 #include <com/sun/star/frame/XDispatch.hpp>
diff --git a/sw/source/ui/lingu/olmenu.cxx b/sw/source/ui/lingu/olmenu.cxx
index b3114f0..af9a344 100644
--- a/sw/source/ui/lingu/olmenu.cxx
+++ b/sw/source/ui/lingu/olmenu.cxx
@@ -91,7 +91,7 @@
 #include <com/sun/star/uno/Any.hxx>
 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
 #include <com/sun/star/system/SystemShellExecute.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 
 
 using namespace ::com::sun::star;
@@ -236,7 +236,7 @@ OUString RetrieveLabelFromCommand( const OUString& aCmdURL )
         try
         {
             uno::Reference< container::XNameAccess > const xNameAccess(
-                    frame::UICommandDescription::create(
+                    frame::theUICommandDescription::get(
                         ::comphelper::getProcessComponentContext() ),
                     uno::UNO_QUERY_THROW );
             uno::Reference< container::XNameAccess > xUICommandLabels;
diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx
index 0c33fb5..b859ff2 100644
--- a/vcl/inc/pch/precompiled_vcl.hxx
+++ b/vcl/inc/pch/precompiled_vcl.hxx
@@ -192,7 +192,7 @@
 #include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
 #include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/frame/XController.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/frame/XModuleManager2.hpp>
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 0294e3d..a9b8151 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -39,7 +39,7 @@
 #include <unotools/confignode.hxx>
 
 #include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/UICommandDescription.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
 #include <com/sun/star/frame/XController.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/frame/XModuleManager2.hpp>
@@ -701,7 +701,7 @@ static OUString getCommandLabel(const OUString& rCommand, const uno::Reference<u
     try
     {
         uno::Reference<container::XNameAccess> xUICommandLabels;
-        uno::Reference<container::XNameAccess> xUICommandDescription(frame::UICommandDescription::create(rContext));
+        uno::Reference<container::XNameAccess> xUICommandDescription(frame::theUICommandDescription::get(rContext));
 
         if ((xUICommandDescription->getByName(rModuleId) >>= xUICommandLabels) && xUICommandLabels.is())
         {
commit b2c89e7236d71d92a96430db0a7eca14b41c227a
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Thu Jan 9 17:18:57 2014 +0100

    fwk: Constructor feature for one instance UICategoryDescription.
    
    Change-Id: I56c906c9eeafb625dee65eec9fe39ea3aee66251

diff --git a/framework/inc/uiconfiguration/uicategorydescription.hxx b/framework/inc/uiconfiguration/uicategorydescription.hxx
deleted file mode 100644
index e3b9d6a..0000000
--- a/framework/inc/uiconfiguration/uicategorydescription.hxx
+++ /dev/null
@@ -1,58 +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_UICONFIGURATION_UICATEGORYDESCRIPTION_HXX
-#define INCLUDED_FRAMEWORK_INC_UICONFIGURATION_UICATEGORYDESCRIPTION_HXX
-
-/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble
-               with solaris headers ...
-*/
-#include <vector>
-#include <list>
-#include <boost/unordered_map.hpp>
-
-#include <threadhelp/threadhelpbase.hxx>
-#include <macros/generic.hxx>
-#include <macros/xserviceinfo.hxx>
-#include <uielement/uicommanddescription.hxx>
-#include <stdtypes.h>
-
-#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>
-
-namespace framework
-{
-class UICategoryDescription :  public UICommandDescription
-{
-    public:
-        UICategoryDescription( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
-        virtual ~UICategoryDescription();
-
-        DECLARE_XSERVICEINFO
-    private:
-        virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > impl_createConfigAccess(const OUString& _sName);
-};
-
-} // namespace framework
-
-#endif // __FRAMEWORK_SERVICES_UICOMMANDCATEGORY_HXX_
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx
index a6e0fee..3fe6481 100644
--- a/framework/source/register/registerservices.cxx
+++ b/framework/source/register/registerservices.cxx
@@ -42,7 +42,6 @@
 #include <uifactory/toolboxfactory.hxx>
 #include "uiconfiguration/windowstateconfiguration.hxx"
 #include <uifactory/statusbarfactory.hxx>
-#include <uiconfiguration/uicategorydescription.hxx>
 #include <services/sessionlistener.hxx>
 #include <services/taskcreatorsrv.hxx>
 
@@ -61,7 +60,6 @@ COMPONENTGETFACTORY ( fwk,
                         IFFACTORY( ::framework::WindowStateConfiguration                )   else
                         IFFACTORY( ::framework::ToolbarControllerFactory                )   else
                         IFFACTORY( ::framework::StatusBarFactory                        )   else
-                        IFFACTORY( ::framework::UICategoryDescription                   )   else
                         IFFACTORY( ::framework::SessionListener                         )   else
                         IFFACTORY( ::framework::StatusbarControllerFactory              )   else
                         IFFACTORY( ::framework::SessionListener                         )   else
diff --git a/framework/source/uiconfiguration/uicategorydescription.cxx b/framework/source/uiconfiguration/uicategorydescription.cxx
index d93cfe2..43ee09b 100644
--- a/framework/source/uiconfiguration/uicategorydescription.cxx
+++ b/framework/source/uiconfiguration/uicategorydescription.cxx
@@ -17,9 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "uiconfiguration/uicategorydescription.hxx"
-#include <threadhelp/resetableguard.hxx>
-#include "services.h"
+#include <uielement/uicommanddescription.hxx>
 
 #include "properties.h"
 
@@ -31,17 +29,17 @@
 #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 <rtl/ustrbuf.hxx>
 #include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/supportsservice.hxx>
 #include <unotools/configmgr.hxx>
 
 #include <vcl/mnemonic.hxx>
 #include <comphelper/sequence.hxx>
 
-//_________________________________________________________________________________________________________________
-//  Defines
-//_________________________________________________________________________________________________________________
+#include <boost/unordered_map.hpp>
 
 using namespace com::sun::star::uno;
 using namespace com::sun::star::lang;
@@ -49,10 +47,9 @@ using namespace com::sun::star::beans;
 using namespace com::sun::star::configuration;
 using namespace com::sun::star::container;
 using namespace ::com::sun::star::frame;
+using namespace framework;
 
-//_________________________________________________________________________________________________________________
-//  Namespace
-//_________________________________________________________________________________________________________________
+namespace {
 
 struct ModuleToCategory
 {
@@ -65,17 +62,9 @@ static const char CONFIGURATION_ROOT_ACCESS[]               = "/org.openoffice.O
 static const char CONFIGURATION_CATEGORY_ELEMENT_ACCESS[]   = "/Commands/Categories";
 static const char CONFIGURATION_PROPERTY_NAME[]             = "Name";
 
-namespace framework
-{
-
-//*****************************************************************************************************************
-//  Configuration access class for PopupMenuControllerFactory implementation
-//*****************************************************************************************************************
-
-class ConfigurationAccess_UICategory : // Order is necessary for right initialization!
-                                        private ThreadHelpBase                           ,
-                                        public  ::cppu::WeakImplHelper2<XNameAccess,XContainerListener>
+class ConfigurationAccess_UICategory : public ::cppu::WeakImplHelper2<XNameAccess,XContainerListener>
 {
+    osl::Mutex aMutex;
     public:
                                   ConfigurationAccess_UICategory( const OUString& aModuleName, const Reference< XNameAccess >& xGenericUICommands, const Reference< XComponentContext >& rxContext );
         virtual                   ~ConfigurationAccess_UICategory();
@@ -135,7 +124,6 @@ class ConfigurationAccess_UICategory : // Order is necessary for right initializ
 //*****************************************************************************************************************
 
 ConfigurationAccess_UICategory::ConfigurationAccess_UICategory( const OUString& aModuleName, const Reference< XNameAccess >& rGenericUICategories, const Reference< XComponentContext >& rxContext ) :
-    ThreadHelpBase(),
     m_aConfigCategoryAccess( CONFIGURATION_ROOT_ACCESS ),
     m_aPropUIName( CONFIGURATION_PROPERTY_NAME ),
     m_xGenericUICategories( rGenericUICategories ),
@@ -152,7 +140,7 @@ ConfigurationAccess_UICategory::ConfigurationAccess_UICategory( const OUString&
 ConfigurationAccess_UICategory::~ConfigurationAccess_UICategory()
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(aMutex);
     Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
     if ( xContainer.is() )
         xContainer->removeContainerListener(m_xConfigListener);
@@ -162,7 +150,7 @@ ConfigurationAccess_UICategory::~ConfigurationAccess_UICategory()
 Any SAL_CALL ConfigurationAccess_UICategory::getByName( const OUString& rId )
 throw ( NoSuchElementException, WrappedTargetException, RuntimeException)
 {
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(aMutex);
     if ( !m_bConfigAccessInitialized )
     {
         initializeConfigAccess();
@@ -290,7 +278,7 @@ Any ConfigurationAccess_UICategory::getUINameFromCache( const OUString& rId )
 Sequence< OUString > ConfigurationAccess_UICategory::getAllIds()
 {
     // SAFE
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(aMutex);
 
     if ( !m_bConfigAccessInitialized )
     {
@@ -345,7 +333,8 @@ sal_Bool ConfigurationAccess_UICategory::initializeConfigAccess()
         aPropValue.Value <<= m_aConfigCategoryAccess;
         aArgs[0] <<= aPropValue;
 
-        m_xConfigAccess = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,aArgs ),UNO_QUERY );
+        m_xConfigAccess = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments(
+                    "com.sun.star.configuration.ConfigurationAccess", aArgs ),UNO_QUERY );
         if ( m_xConfigAccess.is() )
         {
             // Add as container listener
@@ -387,7 +376,7 @@ void SAL_CALL ConfigurationAccess_UICategory::disposing( const EventObject& aEve
 {
     // SAFE
     // remove our reference to the config access
-    ResetableGuard aLock( m_aLock );
+    osl::MutexGuard g(aMutex);
 
     Reference< XInterface > xIfac1( aEvent.Source, UNO_QUERY );
     Reference< XInterface > xIfac2( m_xConfigAccess, UNO_QUERY );
@@ -395,17 +384,35 @@ void SAL_CALL ConfigurationAccess_UICategory::disposing( const EventObject& aEve
         m_xConfigAccess.clear();
 }
 
-//*****************************************************************************************************************
-//  XInterface, XTypeProvider, XServiceInfo
-//*****************************************************************************************************************
+class UICategoryDescription :  public UICommandDescription
+{
+public:
+    UICategoryDescription( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
+    virtual ~UICategoryDescription();
 
-DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2  ( UICategoryDescription                  ,
-                                            ::cppu::OWeakObject                    ,
-                                            "com.sun.star.ui.UICategoryDescription",
-                                            OUString("com.sun.star.comp.framework.UICategoryDescription")
-                                        )
+    virtual OUString SAL_CALL getImplementationName()
+        throw (css::uno::RuntimeException)
+    {
+        return OUString("com.sun.star.comp.framework.UICategoryDescription");
+    }
 
-DEFINE_INIT_SERVICE                     (   UICategoryDescription, {} )
+    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.UICategoryDescription");
+        return aSeq;
+    }
+
+private:
+    virtual css::uno::Reference< css::container::XNameAccess > impl_createConfigAccess(const OUString& _sName);
+};
 
 UICategoryDescription::UICategoryDescription( const Reference< XComponentContext >& rxContext ) :
     UICommandDescription(rxContext,true)
@@ -433,6 +440,30 @@ Reference< XNameAccess > UICategoryDescription::impl_createConfigAccess(const OU
     return new ConfigurationAccess_UICategory( _sName, m_xGenericUICommands, m_xContext );
 }
 
-} // namespace framework
+struct Instance {
+    explicit Instance(
+        css::uno::Reference<css::uno::XComponentContext> const & context):
+        instance(static_cast<cppu::OWeakObject *>(
+                    new UICategoryDescription(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_UICategoryDescription_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/util/fwk.component b/framework/util/fwk.component
index 0692040..98f36f8 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -125,7 +125,8 @@
   <implementation name="com.sun.star.comp.framework.ToolBarFactory">
     <service name="com.sun.star.ui.ToolBarFactory"/>
   </implementation>
-  <implementation name="com.sun.star.comp.framework.UICategoryDescription">
+  <implementation name="com.sun.star.comp.framework.UICategoryDescription"
+      constructor="com_sun_star_comp_framework_UICategoryDescription_get_implementation">
     <service name="com.sun.star.ui.UICategoryDescription"/>
     <singleton name="com.sun.star.ui.theUICategoryDescription"/>
   </implementation>
commit 54f606c666c6d9e642090074d9d2aa4b6a3bec22
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue Jan 28 15:06:35 2014 +0100

    Introduce com.sun.star.ui.theUICategoryDescription singleton.
    
    Change-Id: I79a78f208b2aa5eaacbd2e349b2b5066afa1ad23

diff --git a/cui/inc/pch/precompiled_cui.hxx b/cui/inc/pch/precompiled_cui.hxx
index 8489a4b..264817d 100644
--- a/cui/inc/pch/precompiled_cui.hxx
+++ b/cui/inc/pch/precompiled_cui.hxx
@@ -211,7 +211,7 @@
 #include <com/sun/star/ui/ItemStyle.hpp>
 #include <com/sun/star/ui/ItemType.hpp>
 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
-#include <com/sun/star/ui/UICategoryDescription.hpp>
+#include <com/sun/star/ui/theUICategoryDescription.hpp>
 #include <com/sun/star/ui/UIConfigurationManager.hpp>
 #include <com/sun/star/ui/UIElementType.hpp>
 #include <com/sun/star/ui/WindowStateConfiguration.hpp>
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index a221b8a..f817ea7 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -35,7 +35,7 @@
 #include <com/sun/star/script/provider/XScriptProvider.hpp>
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/uno/RuntimeException.hpp>
-#include <com/sun/star/ui/UICategoryDescription.hpp>
+#include <com/sun/star/ui/theUICategoryDescription.hpp>
 
 #include "acccfg.hrc"
 #include "helpid.hrc"
@@ -595,7 +595,7 @@ void SfxConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent
         m_xContext        = xContext;
         m_sModuleLongName = sModuleLongName;
 
-        m_xGlobalCategoryInfo = css::ui::UICategoryDescription::create( m_xContext );
+        m_xGlobalCategoryInfo = css::ui::theUICategoryDescription::get( m_xContext );
         m_xModuleCategoryInfo = css::uno::Reference< css::container::XNameAccess >(m_xGlobalCategoryInfo->getByName(m_sModuleLongName), css::uno::UNO_QUERY_THROW);
         m_xUICmdDescription   = css::frame::UICommandDescription::create( m_xContext );
 
diff --git a/cui/source/customize/selector.cxx b/cui/source/customize/selector.cxx
index 82df036..a33623a 100644
--- a/cui/source/customize/selector.cxx
+++ b/cui/source/customize/selector.cxx
@@ -54,7 +54,7 @@
 #include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
 #include <com/sun/star/script/browse/XBrowseNodeFactory.hpp>
 #include <com/sun/star/script/browse/BrowseNodeFactoryViewTypes.hpp>
-#include <com/sun/star/ui/UICategoryDescription.hpp>
+#include <com/sun/star/ui/theUICategoryDescription.hpp>
 
 
 using namespace ::com::sun::star;
@@ -429,7 +429,7 @@ void SvxConfigGroupListBox::Init(bool bShowSlots, const Reference< frame::XFrame
         xNameAccess->getByName( aModuleId ) >>= m_xModuleCommands;
 
         Reference< container::XNameAccess > xAllCategories =
-            ui::UICategoryDescription::create( xContext );
+            ui::theUICategoryDescription::get( xContext );
 
         Reference< container::XNameAccess > xModuleCategories;
         if ( !aModuleId.isEmpty() )
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index 9c541e1..0692040 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -127,6 +127,7 @@
   </implementation>
   <implementation name="com.sun.star.comp.framework.UICategoryDescription">
     <service name="com.sun.star.ui.UICategoryDescription"/>
+    <singleton name="com.sun.star.ui.theUICategoryDescription"/>
   </implementation>
   <implementation name="com.sun.star.comp.framework.UICommandDescription">
     <service name="com.sun.star.frame.UICommandDescription"/>
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 7702d13..519c145 100755
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -424,6 +424,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/ui,\
 	WindowContentFactory \
     WindowContentFactoryManager \
 	WindowStateConfiguration \
+	theUICategoryDescription \
 ))
 $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/ui/dialogs,\
 	AddressBookSourcePilot \
diff --git a/offapi/com/sun/star/ui/UICategoryDescription.idl b/offapi/com/sun/star/ui/UICategoryDescription.idl
index 6e59799..96415ed 100644
--- a/offapi/com/sun/star/ui/UICategoryDescription.idl
+++ b/offapi/com/sun/star/ui/UICategoryDescription.idl
@@ -24,31 +24,11 @@
 module com {  module sun {  module star {  module ui {
 
 
-/** a service which provides information about user interface command
-    categories.
-
-    <p>
-    OpenOffice.org has an amount of commands that can be used by user
-    interface elements. Every command is member of a single category.
-    Categories makes it easier to handle to huge amount of commands
-    provided by OpenOffice.org. This service is normally used by UI
-    implementations which provides all commands to a user.
-    </p>
-
-    Provides access to user interface command categories of the installed
-    modules.
-
-    <p>
-    To access the user interface command categories of a module, a unique
-    module specifier must be provided to
-    com::sun::star::container::XNameAccess::getByName()
-    function. The module specifier can be retrieved from the
-    com::sun::star::frame::ModuleManager
-    service. The interface provides references to
-    com::sun:star::ui::ModuleUICommandDescription.
-    </p>
-
-    @see com::sun::star::frame::ModuleManager
+/**
+    A legacy (single-instance) service-variant of theUICategoryDescription singleton.
+
+    @deprecated Use theUICategoryDescription singleton instead.
+
     @since OOo 2.0
 */
 service UICategoryDescription : com::sun::star::container::XNameAccess;
diff --git a/offapi/com/sun/star/ui/theUICategoryDescription.idl b/offapi/com/sun/star/ui/theUICategoryDescription.idl
new file mode 100644
index 0000000..466e3d9
--- /dev/null
+++ b/offapi/com/sun/star/ui/theUICategoryDescription.idl
@@ -0,0 +1,64 @@
+/* -*- 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_theUICategoryDescription_idl__
+#define __com_sun_star_ui_theUICategoryDescription_idl__
+
+#include <com/sun/star/container/XNameAccess.idl>
+
+module com {  module sun {  module star {  module ui {
+
+
+/** a singleton which provides information about user interface command
+    categories.
+
+    <p>
+    OpenOffice.org has an amount of commands that can be used by user
+    interface elements. Every command is member of a single category.
+    Categories makes it easier to handle to huge amount of commands
+    provided by OpenOffice.org. This singleton is normally used by UI
+    implementations which provides all commands to a user.
+    </p>
+
+    Provides access to user interface command categories of the installed
+    modules.
+
+    <p>
+    To access the user interface command categories of a module, a unique
+    module specifier must be provided to
+    com::sun::star::container::XNameAccess::getByName()
+    function. The module specifier can be retrieved from the
+    com::sun::star::frame::ModuleManager
+    service. The interface provides references to
+    com::sun:star::ui::ModuleUICommandDescription.
+    </p>
+
+    @see com::sun::star::frame::ModuleManager
+
+    Prior to LibreOffice 4.3, this singleton was only available as a
+    (single-instance) UICategoryDescription service.
+
+    @since LibreOffice 4.3
+*/
+singleton theUICategoryDescription : com::sun::star::container::XNameAccess;
+
+}; }; }; }; // com.sun.star.ui
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit dd1c991bd993c3e0edb8108474f88d94ba6bd2bc
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Wed Jan 22 12:14:20 2014 +0100

    Introduce com.sun.star.frame.theAutoRecovery singleton.
    
    To replace com.sun.star.frame.AutoRecovery single-instance service,
    incorrectly converted in 279859fdbc40f68d8f1649fa5b928d9de49e8d9e
    
    Unfortunately needs a lot of changes in autorecovery.cxx.
    
    Change-Id: Iba5188dffea3e03803236f23e0b3f343746ace90

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 43b99e1..c48f9f8 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -39,7 +39,7 @@
 #include <svl/languageoptions.hxx>
 #include <svtools/javacontext.hxx>
 #include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/frame/AutoRecovery.hpp>
+#include <com/sun/star/frame/theAutoRecovery.hpp>
 #include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
 #include <com/sun/star/frame/SessionListener.hpp>
 #include <com/sun/star/frame/XSessionManagerListener.hpp>
@@ -2344,7 +2344,7 @@ void Desktop::OpenClients()
     {
         try
         {
-            Reference< XDispatch > xRecovery = css::frame::AutoRecovery::create( ::comphelper::getProcessComponentContext() );
+            Reference< XDispatch > xRecovery = css::frame::theAutoRecovery::get( ::comphelper::getProcessComponentContext() );
             Reference< css::util::XURLTransformer > xParser = css::util::URLTransformer::create( ::comphelper::getProcessComponentContext() );
 
             css::util::URL aCmd;
diff --git a/framework/inc/pch/precompiled_fwk.hxx b/framework/inc/pch/precompiled_fwk.hxx
index 4d1790c..2fb34f6 100644
--- a/framework/inc/pch/precompiled_fwk.hxx
+++ b/framework/inc/pch/precompiled_fwk.hxx
@@ -106,7 +106,7 @@
 #include <com/sun/star/embed/XPackageStructureCreator.hpp>
 #include <com/sun/star/embed/XTransactedObject.hpp>
 #include <com/sun/star/frame/AppDispatchProvider.hpp>
-#include <com/sun/star/frame/AutoRecovery.hpp>
+#include <com/sun/star/frame/theAutoRecovery.hpp>
 #include <com/sun/star/frame/CommandGroup.hpp>
 #include <com/sun/star/frame/ContentHandlerFactory.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
diff --git a/framework/qa/complex/framework/autosave/AutoSave.java b/framework/qa/complex/framework/autosave/AutoSave.java
index 92d95f8..4d02849 100644
--- a/framework/qa/complex/framework/autosave/AutoSave.java
+++ b/framework/qa/complex/framework/autosave/AutoSave.java
@@ -26,6 +26,7 @@ import com.sun.star.frame.XDispatch;
 import com.sun.star.frame.XDispatchProvider;
 import com.sun.star.frame.XModel;
 import com.sun.star.frame.XStatusListener;
+import com.sun.star.frame.theAutoRecovery;
 import com.sun.star.lang.XMultiServiceFactory;
 import com.sun.star.sheet.FillDirection;
 import com.sun.star.sheet.XCellSeries;
@@ -204,7 +205,7 @@ public class AutoSave
             m_aSOF = SOfficeFactory.getFactory(m_xSMGR);
 
             // create AutoSave instance
-            m_xAutoSave = UnoRuntime.queryInterface(XDispatch.class, m_xSMGR.createInstance("com.sun.star.comp.framework.AutoRecovery"));
+            m_xAutoSave = theAutoRecovery.get(connection.getComponentContext());
 
             // prepare AutoSave
             // make sure it will be started every 1 min
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index c83cdfb..127492e 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -23,14 +23,11 @@
 
 #include <loadenv/targethelper.hxx>
 #include <pattern/frame.hxx>
-#include <threadhelp/readguard.hxx>
-#include <threadhelp/writeguard.hxx>
 
 #include <classes/resource.hrc>
 #include <classes/fwkresid.hxx>
 #include <protocols.h>
 #include <properties.h>
-#include <services.h>
 
 #include "helper/mischelper.hxx"
 
@@ -67,6 +64,7 @@
 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
 #include <com/sun/star/lang/XTypeProvider.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
 #include <com/sun/star/frame/XDispatch.hpp>
 #include <com/sun/star/document/XEventListener.hpp>
 #include <com/sun/star/document/XEventBroadcaster.hpp>
@@ -76,12 +74,12 @@
 
 #include <comphelper/configurationhelper.hxx>
 #include <cppuhelper/exc_hlp.hxx>
-#include <cppuhelper/implbase5.hxx>
+#include <cppuhelper/compbase5.hxx>
 #include <cppuhelper/propshlp.hxx>
 #include <cppuhelper/supportsservice.hxx>
 #include <unotools/mediadescriptor.hxx>
 #include <comphelper/namedvaluecollection.hxx>
-#include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
 #include <vcl/evntpost.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/timer.hxx>
@@ -98,10 +96,6 @@
 #include <svl/documentlockfile.hxx>
 #include <tools/urlobj.hxx>
 
-#include <threadhelp/threadhelpbase.hxx>
-#include <macros/xinterface.hxx>
-#include <macros/xtypeprovider.hxx>
-#include <macros/xserviceinfo.hxx>
 #include <general.h>
 #include <stdtypes.h>
 
@@ -188,7 +182,7 @@ public:
     of documents - including features of an EmergencySave in
     case a GPF occurs.
  */
-typedef ::cppu::WeakImplHelper5<
+typedef ::cppu::WeakComponentImplHelper5<
             css::lang::XServiceInfo,
             css::frame::XDispatch,
             css::document::XEventListener,    // => css.lang.XEventListener
@@ -196,12 +190,11 @@ typedef ::cppu::WeakImplHelper5<
             css::util::XModifyListener >      // => css.lang.XEventListener
          AutoRecovery_BASE;
 
-class AutoRecovery  : // attention! Must be the first base class to guarentee right initialize lock ...
-                      private ThreadHelpBase
-                    , public  ::cppu::OBroadcastHelper
-                    , public  ::cppu::OPropertySetHelper            // => XPropertySet, XFastPropertySet, XMultiPropertySet
+class AutoRecovery  : private osl::Mutex
                     , public  AutoRecovery_BASE
+                    , public  ::cppu::OPropertySetHelper            // => XPropertySet, XFastPropertySet, XMultiPropertySet
 {
+    using cppu::WeakComponentImplHelperBase::rBHelper;
 public:
 
     /** These values are used as flags and represent the current state of a document.
@@ -586,13 +579,9 @@ public:
 
     //---------------------------------------
     // css.lang.XEventListener
-    using cppu::OPropertySetHelper::disposing;
     virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
         throw(css::uno::RuntimeException);
 
-//___________________________________________
-// helper
-
 protected:
 
     //---------------------------------------
@@ -615,10 +604,9 @@ protected:
 
     virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
         throw(css::uno::RuntimeException);
-//___________________________________________
-// helper
 
 private:
+    virtual void SAL_CALL disposing() SAL_OVERRIDE;
 
     //---------------------------------------
     /** @short  open the underlying configuration.
@@ -1245,7 +1233,7 @@ class CacheLockGuard
         css::uno::Reference< css::uno::XInterface > m_xOwner;
 
         // mutex shared with outside calli !
-        LockHelper& m_rSharedMutex;
+        osl::Mutex& m_rSharedMutex;
 
         // this variable knows the state of the "cache lock"
         sal_Int32& m_rCacheLock;
@@ -1257,7 +1245,7 @@ class CacheLockGuard
     public:
 
         CacheLockGuard(AutoRecovery* pOwner                      ,
-                       LockHelper&   rMutex                      ,
+                       osl::Mutex&   rMutex                      ,
                        sal_Int32&    rCacheLock                  ,
                        sal_Bool      bLockForAddRemoveVectorItems);
         ~CacheLockGuard();
@@ -1268,7 +1256,7 @@ class CacheLockGuard
 
 //-----------------------------------------------
 CacheLockGuard::CacheLockGuard(AutoRecovery* pOwner                      ,
-                               LockHelper&   rMutex                      ,
+                               osl::Mutex&   rMutex                      ,
                                sal_Int32&    rCacheLock                  ,
                                sal_Bool      bLockForAddRemoveVectorItems)
     : m_xOwner            (static_cast< css::frame::XDispatch* >(pOwner))
@@ -1289,8 +1277,8 @@ CacheLockGuard::~CacheLockGuard()
 //-----------------------------------------------
 void CacheLockGuard::lock(sal_Bool bLockForAddRemoveVectorItems)
 {
-    // SAFE -> ----------------------------------
-    WriteGuard aWriteLock(m_rSharedMutex);
+    /* SAFE */ {
+    osl::MutexGuard g(m_rSharedMutex);
 
     if (m_bLockedByThisGuard)
         return;
@@ -1318,16 +1306,14 @@ void CacheLockGuard::lock(sal_Bool bLockForAddRemoveVectorItems)
 
     ++m_rCacheLock;
     m_bLockedByThisGuard = sal_True;
-
-    aWriteLock.unlock();
-    // <- SAFE ----------------------------------
+    } /* SAFE */
 }
 
 //-----------------------------------------------
 void CacheLockGuard::unlock()
 {
-    // SAFE -> ----------------------------------
-    WriteGuard aWriteLock(m_rSharedMutex);
+    /* SAFE */ {
+    osl::MutexGuard g(m_rSharedMutex);
 
     if ( ! m_bLockedByThisGuard)
         return;
@@ -1342,8 +1328,7 @@ void CacheLockGuard::unlock()
                 OUString("Wrong using of member m_nDocCacheLock detected. A ref counted value shouldn't reach values <0 .-)"),
                 m_xOwner);
     }
-    aWriteLock.unlock();
-    // <- SAFE ----------------------------------
+    } /* SAFE */
 }
 
 //-----------------------------------------------
@@ -1396,9 +1381,8 @@ void DispatchParams::forget()
 
 //-----------------------------------------------
 AutoRecovery::AutoRecovery(const css::uno::Reference< css::uno::XComponentContext >& xContext)
-    : ThreadHelpBase            (&Application::GetSolarMutex()                      )
-    , ::cppu::OBroadcastHelper  ( m_aLock.getShareableOslMutex()                    )
-    , ::cppu::OPropertySetHelper( *(static_cast< ::cppu::OBroadcastHelper* >(this)) )
+    : AutoRecovery_BASE         (*static_cast<Mutex *>(this))
+    , ::cppu::OPropertySetHelper(rBHelper)
     , m_xContext                (xContext                                           )
     , m_bListenForDocEvents     (sal_False                                          )
     , m_bListenForConfigChanges (sal_False                                          )
@@ -1407,7 +1391,7 @@ AutoRecovery::AutoRecovery(const css::uno::Reference< css::uno::XComponentContex
     , m_aAsyncDispatcher        ( LINK( this, AutoRecovery, implts_asyncDispatch )  )
     , m_eTimerType              (E_DONT_START_TIMER                                 )
     , m_nIdPool                 (0                                                  )
-    , m_lListener               (m_aLock.getShareableOslMutex()                     )
+    , m_lListener               (rBHelper.rMutex)
     , m_nDocCacheLock           (0                                                  )
     , m_nMinSpaceDocSave        (MIN_DISCSPACE_DOCSAVE                              )
     , m_nMinSpaceConfigSave     (MIN_DISCSPACE_CONFIGSAVE                           )
@@ -1433,6 +1417,11 @@ void AutoRecovery::initListeners()
 //-----------------------------------------------
 AutoRecovery::~AutoRecovery()
 {
+    disposing();
+}
+
+void AutoRecovery::disposing()
+{
     implts_stopTimer();
 }
 
@@ -1464,8 +1453,10 @@ void SAL_CALL AutoRecovery::dispatch(const css::util::URL&
     if (eNewJob == AutoRecovery::E_NO_JOB)
         return;
 
-    // SAFE -> ----------------------------------
-    WriteGuard aWriteLock(m_aLock);
+    sal_Bool bAsync;
+    DispatchParams aParams;
+    /* SAFE */ {
+    osl::MutexGuard g(rBHelper.rMutex);
 
     // still running operation ... ignoring AUTO_SAVE.
     // All other requests has higher prio!
@@ -1517,15 +1508,14 @@ void SAL_CALL AutoRecovery::dispatch(const css::util::URL&
 
     m_eJob |= eNewJob;
 
-    sal_Bool       bAsync  = lArgs.getUnpackedValueOrDefault(PROP_DISPATCH_ASYNCHRON, (sal_Bool)sal_False);
-    DispatchParams aParams (lArgs, static_cast< css::frame::XDispatch* >(this));
+    bAsync = lArgs.getUnpackedValueOrDefault(PROP_DISPATCH_ASYNCHRON, sal_False);
+    aParams = DispatchParams(lArgs, static_cast< css::frame::XDispatch* >(this));
 
     // Hold this instance alive till the asynchronous operation will be finished.
     if (bAsync)
         m_aDispatchParams = aParams;
 
-    aWriteLock.unlock();
-    // <- SAFE ----------------------------------
+    } /* SAFE */
 
     if (bAsync)
         m_aAsyncDispatcher.Post(0);
@@ -1551,11 +1541,11 @@ void AutoRecovery::ListenerInformer::stop()
 //-----------------------------------------------
 void AutoRecovery::implts_dispatch(const DispatchParams& aParams)
 {
-    // SAFE -> ----------------------------------
-    WriteGuard aWriteLock(m_aLock);
-    sal_Int32 eJob = m_eJob;
-    aWriteLock.unlock();
-    // <- SAFE ----------------------------------
+    sal_Int32 eJob;
+    /* SAFE */ {
+    osl::MutexGuard g(rBHelper.rMutex);
+    eJob = m_eJob;
+    } /* SAFE */
 
     // in case a new dispatch overwrites a may ba active AutoSave session
     // we must restore this session later. see below ...
@@ -1661,8 +1651,8 @@ void AutoRecovery::implts_dispatch(const DispatchParams& aParams)
 
     aListenerInformer.stop();
 
-    // SAFE -> ----------------------------------
-    aWriteLock.lock();
+    /* SAFE */ {
+    osl::MutexGuard g(rBHelper.rMutex);
     m_eJob = E_NO_JOB;
     if (
         (bAllowAutoSaveReactivation) &&
@@ -1677,8 +1667,7 @@ void AutoRecovery::implts_dispatch(const DispatchParams& aParams)
         }
     }
 
-    aWriteLock.unlock();
-    // <- SAFE ----------------------------------
+    } /* SAFE */
 
     // depends on bAllowAutoSaveReactivation implicitly by looking on m_eJob=E_AUTO_SAVE! see before ...
     implts_updateTimer();
@@ -1698,10 +1687,10 @@ void SAL_CALL AutoRecovery::addStatusListener(const css::uno::Reference< css::fr
     m_lListener.addInterface(aURL.Complete, xListener);
 
     // REENTRANT !? -> --------------------------------
-    CacheLockGuard aCacheLock(this, m_aLock, m_nDocCacheLock, LOCK_FOR_CACHE_USE);
+    CacheLockGuard aCacheLock(this, rBHelper.rMutex, m_nDocCacheLock, LOCK_FOR_CACHE_USE);
 
-    // THREAD SAFE -> ----------------------------------
-    ReadGuard aReadLock(m_aLock);
+    /* SAFE */ {
+    osl::ResettableMutexGuard g(rBHelper.rMutex);
 
     AutoRecovery::TDocumentList::iterator pIt;
     for(  pIt  = m_lDocCache.begin();
@@ -1711,15 +1700,14 @@ void SAL_CALL AutoRecovery::addStatusListener(const css::uno::Reference< css::fr
         AutoRecovery::TDocumentInfo&  rInfo = *pIt;
         css::frame::FeatureStateEvent aEvent = AutoRecovery::implst_createFeatureStateEvent(m_eJob, OPERATION_UPDATE, &rInfo);
 
-        // <- SAFE ------------------------------
-        aReadLock.unlock();
+        // } /* SAFE */
+        g.clear();
         xListener->statusChanged(aEvent);
-        aReadLock.lock();
-        // SAFE -> ------------------------------
+        g.reset();
+        // /* SAFE */ {
     }
 
-    aReadLock.unlock();
-    // <- SAFE ----------------------------------
+    } /* SAFE */
 }
 
 //-----------------------------------------------
@@ -1812,8 +1800,8 @@ void SAL_CALL AutoRecovery::changesOccurred(const css::util::ChangesEvent& aEven
     sal_Int32 c = lChanges.getLength();
     sal_Int32 i = 0;
 
-    // SAFE -> ----------------------------------
-    WriteGuard aWriteLock(m_aLock);
+    /* SAFE */ {
+    osl::ResettableMutexGuard g(rBHelper.rMutex);
 
     // Changes of the configuration must be ignored if AutoSave/Recovery was disabled for this
     // office session. That can happen if e.g. the command line arguments "--norestore" or "--headless"
@@ -1848,8 +1836,7 @@ void SAL_CALL AutoRecovery::changesOccurred(const css::util::ChangesEvent& aEven
             pChanges[i].Element >>= m_nAutoSaveTimeIntervall;
     }
 
-    aWriteLock.unlock();
-    // <- SAFE ----------------------------------
+    } /* SAFE */
 
     // Note: This call stops the timer and starts it again.
     // But it checks the different timer states internaly and
@@ -1872,8 +1859,8 @@ void SAL_CALL AutoRecovery::modified(const css::lang::EventObject& aEvent)
 void SAL_CALL AutoRecovery::disposing(const css::lang::EventObject& aEvent)
     throw(css::uno::RuntimeException)
 {
-    // SAFE -> ----------------------------------
-    WriteGuard aWriteLock(m_aLock);
+    /* SAFE */ {
+    osl::MutexGuard g(rBHelper.rMutex);
 
     if (aEvent.Source == m_xNewDocBroadcaster)
     {
@@ -1897,26 +1884,24 @@ void SAL_CALL AutoRecovery::disposing(const css::lang::EventObject& aEvent)
         return;
     }
 
-    // <- SAFE ----------------------------------
+    } /* SAFE */
 }
 
 //-----------------------------------------------
 css::uno::Reference< css::container::XNameAccess > AutoRecovery::implts_openConfig()
 {
-    // SAFE -> ----------------------------------
-    WriteGuard aWriteLock(m_aLock);
+    /* SAFE */ {
+    osl::MutexGuard g(rBHelper.rMutex);
 
     if (m_xRecoveryCFG.is())
         return m_xRecoveryCFG;
-    css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext;
 
-    aWriteLock.unlock();
-    // <- SAFE ----------------------------------
+    } /* SAFE */
 
     OUString sCFG_PACKAGE_RECOVERY(CFG_PACKAGE_RECOVERY);
     // throws a RuntimeException if an error occurs!
     css::uno::Reference< css::container::XNameAccess > xCFG(
-        ::comphelper::ConfigurationHelper::openConfig(xContext, sCFG_PACKAGE_RECOVERY, ::comphelper::ConfigurationHelper::E_STANDARD),
+        ::comphelper::ConfigurationHelper::openConfig(m_xContext, sCFG_PACKAGE_RECOVERY, ::comphelper::ConfigurationHelper::E_STANDARD),
         css::uno::UNO_QUERY);
 
     sal_Int32 nMinSpaceDocSave    = MIN_DISCSPACE_DOCSAVE;
@@ -1925,13 +1910,13 @@ css::uno::Reference< css::container::XNameAccess > AutoRecovery::implts_openConf
     try
     {
         OUString sCFG_PATH_AUTOSAVE(CFG_PATH_AUTOSAVE);
-        ::comphelper::ConfigurationHelper::readDirectKey(xContext,
+        ::comphelper::ConfigurationHelper::readDirectKey(m_xContext,
                                                          sCFG_PACKAGE_RECOVERY,
                                                          sCFG_PATH_AUTOSAVE,
                                                          OUString(CFG_ENTRY_MINSPACE_DOCSAVE),
                                                          ::comphelper::ConfigurationHelper::E_STANDARD) >>= nMinSpaceDocSave;
 
-        ::comphelper::ConfigurationHelper::readDirectKey(xContext,
+        ::comphelper::ConfigurationHelper::readDirectKey(m_xContext,
                                                          sCFG_PACKAGE_RECOVERY,
                                                          sCFG_PATH_AUTOSAVE,
                                                          OUString(CFG_ENTRY_MINSPACE_CONFIGSAVE),
@@ -1945,13 +1930,12 @@ css::uno::Reference< css::container::XNameAccess > AutoRecovery::implts_openConf
         nMinSpaceConfigSave = MIN_DISCSPACE_CONFIGSAVE;
     }
 
-    // SAFE -> ----------------------------------
-    aWriteLock.lock();
+    /* SAFE */ {
+    osl::MutexGuard g(rBHelper.rMutex);
     m_xRecoveryCFG        = xCFG;
     m_nMinSpaceDocSave    = nMinSpaceDocSave;
     m_nMinSpaceConfigSave = nMinSpaceConfigSave;
-    aWriteLock.unlock();
-    // <- SAFE ----------------------------------
+    } /* SAFE */
 
     return xCFG;
 }
@@ -1969,8 +1953,8 @@ void AutoRecovery::implts_readAutoSaveConfig()
     sal_Bool bUserEnabled = sal_False;
     xCommonRegistry->getByHierarchicalName(OUString(CFG_ENTRY_USERAUTOSAVE_ENABLED)) >>= bUserEnabled;
 
-    // SAFE -> ------------------------------
-    WriteGuard aWriteLock(m_aLock);
+    /* SAFE */ {
+    osl::MutexGuard g(rBHelper.rMutex);
     if (bEnabled)
     {
         m_eJob       |= AutoRecovery::E_AUTO_SAVE;
@@ -1990,18 +1974,16 @@ void AutoRecovery::implts_readAutoSaveConfig()
         m_eJob       &= ~AutoRecovery::E_AUTO_SAVE;
         m_eTimerType  = AutoRecovery::E_DONT_START_TIMER;
     }
-    aWriteLock.unlock();
-    // <- SAFE ------------------------------
+    } /* SAFE */
 
     // AutoSaveTimeIntervall [int] in min
     sal_Int32 nTimeIntervall = 15;
     xCommonRegistry->getByHierarchicalName(OUString(CFG_ENTRY_AUTOSAVE_TIMEINTERVALL)) >>= nTimeIntervall;
 
-    // SAFE -> ----------------------------------
-    aWriteLock.lock();
+    /* SAFE */ {
+    osl::MutexGuard g(rBHelper.rMutex);
     m_nAutoSaveTimeIntervall = nTimeIntervall;
-    aWriteLock.unlock();
-    // <- SAFE ----------------------------------
+    } /* SAFE */
 }
 
 //-----------------------------------------------
@@ -2012,15 +1994,14 @@ void AutoRecovery::implts_readConfig()
     css::uno::Reference< css::container::XHierarchicalNameAccess > xCommonRegistry(implts_openConfig(), css::uno::UNO_QUERY);
 
     // REENTRANT -> --------------------------------
-    CacheLockGuard aCacheLock(this, m_aLock, m_nDocCacheLock, LOCK_FOR_CACHE_ADD_REMOVE);
+    CacheLockGuard aCacheLock(this, rBHelper.rMutex, m_nDocCacheLock, LOCK_FOR_CACHE_ADD_REMOVE);
 
-    // THREADSAFE -> -------------------------------
-    WriteGuard aWriteLock(m_aLock);
+    /* SAFE */ {
+    osl::MutexGuard g(rBHelper.rMutex);
     // reset current cache load cache
     m_lDocCache.clear();
     m_nIdPool = 0;
-    aWriteLock.unlock();
-    // <- THREADSAFE -------------------------------
+    } /* SAFE */
 
     aCacheLock.unlock();
     // <- REENTRANT --------------------------------
@@ -2067,24 +2048,22 @@ void AutoRecovery::implts_readConfig()
             {
                 OUString sID = pItems[i].copy(sRECOVERY_ITEM_BASE_IDENTIFIER.getLength());
                 aInfo.ID = sID.toInt32();
-                // SAFE -> ----------------------
-                aWriteLock.lock();
+                /* SAFE */ {
+                osl::MutexGuard g(rBHelper.rMutex);
                 if (aInfo.ID > m_nIdPool)
                 {
                     m_nIdPool = aInfo.ID+1;
                     SAL_WARN_IF(m_nIdPool<0, "fwk", "AutoRecovery::implts_readConfig(): Overflow of IDPool detected!");
                 }
-                aWriteLock.unlock();
-                // <- SAFE ----------------------
+                } /* SAFE */
             }
             else
                 SAL_INFO("fwk", "AutoRecovery::implts_readConfig(): Who changed numbering of recovery items? Cache will be inconsistent then! I do not know, what will happen next time .-)");
 
-            // THREADSAFE -> --------------------------
-            aWriteLock.lock();
+            /* SAFE */ {
+            osl::MutexGuard g(rBHelper.rMutex);
             m_lDocCache.push_back(aInfo);
-            aWriteLock.unlock();
-            // <- THREADSAFE --------------------------
+            } /* SAFE */
         }
 
         aCacheLock.unlock();
@@ -2104,12 +2083,11 @@ void AutoRecovery::implts_specifyDefaultFilterAndExtension(AutoRecovery::TDocume
                 static_cast< css::frame::XDispatch* >(this));
     }
 
-    // SAFE -> ----------------------------------
-    ReadGuard aReadLock(m_aLock);
-    css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext;
-    css::uno::Reference< css::container::XNameAccess>      xCFG  = m_xModuleCFG;
-    aReadLock.unlock();
-    // <- SAFE ----------------------------------
+    css::uno::Reference< css::container::XNameAccess> xCFG;
+    /* SAFE */ {
+    osl::MutexGuard g(rBHelper.rMutex);
+    xCFG = m_xModuleCFG;
+    } /* SAFE */
 
     try
     {
@@ -2117,15 +2095,14 @@ void AutoRecovery::implts_specifyDefaultFilterAndExtension(AutoRecovery::TDocume
         {
             // open module config on demand and cache the update access
             xCFG = css::uno::Reference< css::container::XNameAccess >(
-                ::comphelper::ConfigurationHelper::openConfig(xContext, OUString(CFG_PACKAGE_MODULES),
+                ::comphelper::ConfigurationHelper::openConfig(m_xContext, OUString(CFG_PACKAGE_MODULES),
                 ::comphelper::ConfigurationHelper::E_STANDARD),
                 css::uno::UNO_QUERY_THROW);
 
-            // SAFE -> ----------------------------------
-            WriteGuard aWriteLock(m_aLock);
+            /* SAFE */ {
+            osl::MutexGuard g2(rBHelper.rMutex);
             m_xModuleCFG = xCFG;
-            aWriteLock.unlock();
-            // <- SAFE ----------------------------------
+            } /* SAFE */
         }
 
         css::uno::Reference< css::container::XNameAccess > xModuleProps(
@@ -2134,8 +2111,12 @@ void AutoRecovery::implts_specifyDefaultFilterAndExtension(AutoRecovery::TDocume
 
         xModuleProps->getByName(OUString(CFG_ENTRY_REALDEFAULTFILTER)) >>= rInfo.DefaultFilter;
 
-        css::uno::Reference< css::container::XNameAccess > xFilterCFG(xContext->getServiceManager()->createInstanceWithContext(SERVICENAME_FILTERFACTORY, xContext), css::uno::UNO_QUERY_THROW);
-        css::uno::Reference< css::container::XNameAccess > xTypeCFG  (xContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.TypeDetection", xContext), css::uno::UNO_QUERY_THROW);
+        css::uno::Reference< css::container::XNameAccess > xFilterCFG(
+                m_xContext->getServiceManager()->createInstanceWithContext(
+                    "com.sun.star.document.FilterFactory", m_xContext), css::uno::UNO_QUERY_THROW);
+        css::uno::Reference< css::container::XNameAccess > xTypeCFG(
+                m_xContext->getServiceManager()->createInstanceWithContext(
+                    "com.sun.star.document.TypeDetection", m_xContext), css::uno::UNO_QUERY_THROW);
 
         ::comphelper::SequenceAsHashMap       lFilterProps        (xFilterCFG->getByName(rInfo.DefaultFilter));
         OUString                       sTypeRegistration   = lFilterProps.getUnpackedValueOrDefault(OUString(FILTER_PROP_TYPE), OUString());
@@ -2163,13 +2144,7 @@ void AutoRecovery::implts_specifyAppModuleAndFactory(AutoRecovery::TDocumentInfo
         "Cant find out the application module nor its factory URL, if no application module (or a suitable) document is known!",
         *this );
 
-    // SAFE -> ----------------------------------
-    ReadGuard aReadLock(m_aLock);
-    css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext;
-    aReadLock.unlock();
-    // <- SAFE ----------------------------------
-
-    css::uno::Reference< css::frame::XModuleManager2 > xManager = ModuleManager::create( xContext );
+    css::uno::Reference< css::frame::XModuleManager2 > xManager = ModuleManager::create(m_xContext);
 
     if (rInfo.AppModule.isEmpty())
         rInfo.AppModule = xManager->identify(rInfo.Document);
@@ -2223,8 +2198,7 @@ void AutoRecovery::implts_collectActiveViewNames( AutoRecovery::TDocumentInfo& i
 //-----------------------------------------------
 void AutoRecovery::implts_persistAllActiveViewNames()
 {
-    // SAFE -> ----------------------------------
-    WriteGuard aWriteLock(m_aLock);
+    osl::MutexGuard g(rBHelper.rMutex);
 
     // This list will be filled with every document
     AutoRecovery::TDocumentList::iterator pIt;
@@ -2324,11 +2298,11 @@ void AutoRecovery::implts_flushConfigItem(const AutoRecovery::TDocumentInfo& rIn
             // b) unknown problem (may be locking problem)                              => reset RETRY value to more useful value(!) (e.g. retry=3)
             // c) unknown problem (may be locking problem) + 1..2 repeating operations  => throw the original exception to force generation of a stacktrace !
 
-            // SAFE ->
-            ReadGuard aReadLock(m_aLock);
-            sal_Int32 nMinSpaceConfigSave = m_nMinSpaceConfigSave;
-            aReadLock.unlock();
-            // <- SAFE
+            sal_Int32 nMinSpaceConfigSave;
+            /* SAFE */ {
+            osl::MutexGuard g(rBHelper.rMutex);
+            nMinSpaceConfigSave = m_nMinSpaceConfigSave;
+            } /* SAFE */
 

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list