[Libreoffice-commits] core.git: comphelper/source extensions/source include/comphelper include/unotools

Noel Grandin noel.grandin at collabora.co.uk
Sun Jul 23 19:12:22 UTC 2017


 comphelper/source/misc/componentmodule.cxx             |   21 ----
 extensions/source/propctrlr/MasterDetailLinkDialog.hxx |    1 
 extensions/source/propctrlr/browserlistbox.hxx         |    1 
 extensions/source/propctrlr/controlfontdialog.hxx      |    1 
 extensions/source/propctrlr/formbrowsertools.cxx       |    3 
 extensions/source/propctrlr/formmetadata.cxx           |    3 
 extensions/source/propctrlr/formmetadata.hxx           |    1 
 extensions/source/propctrlr/modulepcr.cxx              |   28 ++++++
 extensions/source/propctrlr/modulepcr.hxx              |   23 +++++
 extensions/source/propctrlr/pcrunodialogs.hxx          |    1 
 extensions/source/propctrlr/propertyhandler.hxx        |    3 
 extensions/source/propctrlr/selectlabeldialog.hxx      |    1 
 include/comphelper/componentmodule.hxx                 |   31 -------
 include/unotools/componentresmodule.hxx                |   73 -----------------
 14 files changed, 49 insertions(+), 142 deletions(-)

New commits:
commit 4bb2bca091ffa0cc8a5f4a850eef146bb66feaa0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Sun Jul 23 13:44:27 2017 +0200

    remove now unnecessary comphelper::OModuleClient stuff
    
    after the great gettext migration of 2017
    
    Change-Id: I704389b1ae1fb34dae0429c98cbfc89c2d3b8e27
    Reviewed-on: https://gerrit.libreoffice.org/40322
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/comphelper/source/misc/componentmodule.cxx b/comphelper/source/misc/componentmodule.cxx
index dc780d55ae78..e1e95aee11a1 100644
--- a/comphelper/source/misc/componentmodule.cxx
+++ b/comphelper/source/misc/componentmodule.cxx
@@ -49,8 +49,7 @@ namespace comphelper
     }
 
     OModule::OModule()
-        : m_nClients(0)
-        , m_pImpl(new OModuleImpl)
+        : m_pImpl(new OModuleImpl)
     {
     }
 
@@ -58,24 +57,6 @@ namespace comphelper
     {
     }
 
-    void OModule::registerClient( OModule::ClientAccess )
-    {
-        osl_atomic_increment( &m_nClients );
-    }
-
-    void OModule::revokeClient( OModule::ClientAccess )
-    {
-        if ( 0 == osl_atomic_decrement( &m_nClients ) )
-        {
-            ::osl::MutexGuard aGuard(m_aMutex);
-            onLastClient();
-        }
-    }
-
-    void OModule::onLastClient()
-    {
-    }
-
     void OModule::registerImplementation( const ComponentDescription& _rComp )
     {
         ::osl::MutexGuard aGuard( m_aMutex );
diff --git a/extensions/source/propctrlr/MasterDetailLinkDialog.hxx b/extensions/source/propctrlr/MasterDetailLinkDialog.hxx
index 62422e21e873..88f1ab689957 100644
--- a/extensions/source/propctrlr/MasterDetailLinkDialog.hxx
+++ b/extensions/source/propctrlr/MasterDetailLinkDialog.hxx
@@ -31,7 +31,6 @@ namespace pcr
 
     class MasterDetailLinkDialog :   public MasterDetailLinkDialog_DBase
                                     ,public MasterDetailLinkDialog_PBase
-                                    ,public PcrClient
     {
     public:
         explicit MasterDetailLinkDialog(const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
diff --git a/extensions/source/propctrlr/browserlistbox.hxx b/extensions/source/propctrlr/browserlistbox.hxx
index edd715033523..dfdbefaa4e90 100644
--- a/extensions/source/propctrlr/browserlistbox.hxx
+++ b/extensions/source/propctrlr/browserlistbox.hxx
@@ -74,7 +74,6 @@ namespace pcr
 
     class OBrowserListBox   :public Control
                             ,public IButtonClickListener
-                            ,public PcrClient
     {
     protected:
         VclPtr<Window>              m_aLinesPlayground;
diff --git a/extensions/source/propctrlr/controlfontdialog.hxx b/extensions/source/propctrlr/controlfontdialog.hxx
index bbf1ffcc1818..2b94c58d8c8c 100644
--- a/extensions/source/propctrlr/controlfontdialog.hxx
+++ b/extensions/source/propctrlr/controlfontdialog.hxx
@@ -37,7 +37,6 @@ namespace pcr
     class OControlFontDialog
                 :public OControlFontDialog_DBase
                 ,public OControlFontDialog_PBase
-                ,public PcrClient
     {
     protected:
         // <properties>
diff --git a/extensions/source/propctrlr/formbrowsertools.cxx b/extensions/source/propctrlr/formbrowsertools.cxx
index c7801df339ff..fe64952d7df6 100644
--- a/extensions/source/propctrlr/formbrowsertools.cxx
+++ b/extensions/source/propctrlr/formbrowsertools.cxx
@@ -39,9 +39,6 @@ namespace pcr
 
     OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj)
     {
-        PcrClient aResourceAccess;
-            // this ensures that we have our resource file loaded
-
         OUString sClassName;
         switch (nClassId)
         {
diff --git a/extensions/source/propctrlr/formmetadata.cxx b/extensions/source/propctrlr/formmetadata.cxx
index 334c4cbc8292..11e91e716a7c 100644
--- a/extensions/source/propctrlr/formmetadata.cxx
+++ b/extensions/source/propctrlr/formmetadata.cxx
@@ -103,9 +103,6 @@ namespace pcr
         if ( s_pPropertyInfos )
             return s_pPropertyInfos;
 
-        PcrClient aResourceAccess;
-        // this ensures that we have our resource file loaded
-
         static OPropertyInfoImpl aPropertyInfos[] =
         {
         /*
diff --git a/extensions/source/propctrlr/formmetadata.hxx b/extensions/source/propctrlr/formmetadata.hxx
index 27e289692efe..7e5e750ba027 100644
--- a/extensions/source/propctrlr/formmetadata.hxx
+++ b/extensions/source/propctrlr/formmetadata.hxx
@@ -36,7 +36,6 @@ namespace pcr
 
     class OPropertyInfoService
                 :public IPropertyInfoService
-                ,public PcrClient
     {
     protected:
         static sal_uInt16               s_nCount;
diff --git a/extensions/source/propctrlr/modulepcr.cxx b/extensions/source/propctrlr/modulepcr.cxx
index 87ec308dbe36..56931b21bc14 100644
--- a/extensions/source/propctrlr/modulepcr.cxx
+++ b/extensions/source/propctrlr/modulepcr.cxx
@@ -27,12 +27,36 @@
 
 namespace pcr
 {
-    IMPLEMENT_MODULE( PcrModule, "pcr" )
+    struct CreateModuleClass
+    {
+        PcrModule* operator()()
+        {
+            static PcrModule* pModule = new PcrModule;
+            return pModule;
+            /*  yes, in theory, this is a resource leak, since the PcrModule
+                will never be cleaned up. However, using a non-heap instance of PcrModule
+                would not work: It would be cleaned up when the module is unloaded.
+                This might happen (and is likely to happen) *after* the tools-library
+                has been unloaded. However, the module's dtor is where we would delete
+                our resource manager (in case not all our clients de-registered) - which
+                would call into the already-unloaded tools-library. */
+        }
+    };
+
+    PcrModule::PcrModule()
+        :BaseClass( OString( "pcr" ), Application::GetSettings().GetUILanguageTag() )
+    {
+    }
+
+    PcrModule& PcrModule::getInstance()
+    {
+        return *rtl_Instance< PcrModule, CreateModuleClass, ::osl::MutexGuard, ::osl::GetGlobalMutex >::
+            create( CreateModuleClass(), ::osl::GetGlobalMutex() );
+    }
 
     OUString PcrRes(const char* pId)
     {
         return Translate::get(pId, PcrModule::getInstance().getResLocale());
-
     }
 
 } // namespace pcr
diff --git a/extensions/source/propctrlr/modulepcr.hxx b/extensions/source/propctrlr/modulepcr.hxx
index 69665e075887..652ff0b93f8a 100644
--- a/extensions/source/propctrlr/modulepcr.hxx
+++ b/extensions/source/propctrlr/modulepcr.hxx
@@ -24,7 +24,28 @@
 
 namespace pcr
 {
-    DEFINE_MODULE(PcrModule, PcrClient)
+    /* -------------------------------------------------------------------- */
+    class PcrModule : public ::utl::OComponentResourceModule
+    {
+        friend struct CreateModuleClass;
+        typedef ::utl::OComponentResourceModule BaseClass;
+    public:
+        static PcrModule& getInstance();
+    private:
+        PcrModule();
+    };
+
+    /* -------------------------------------------------------------------- */
+    template < class TYPE >
+    class OAutoRegistration : public ::comphelper::OAutoRegistration< TYPE >
+    {
+    private:
+        typedef ::comphelper::OAutoRegistration< TYPE >    BaseClass;
+    public:
+        OAutoRegistration() : BaseClass( PcrModule::getInstance() )
+        {
+        }
+    };
 
     OUString PcrRes(const char* pId);
 } // namespace pcr
diff --git a/extensions/source/propctrlr/pcrunodialogs.hxx b/extensions/source/propctrlr/pcrunodialogs.hxx
index 98c6a1342b5c..fc3b1189bb3f 100644
--- a/extensions/source/propctrlr/pcrunodialogs.hxx
+++ b/extensions/source/propctrlr/pcrunodialogs.hxx
@@ -38,7 +38,6 @@ namespace pcr
     class OTabOrderDialog
                 :public OTabOrderDialog_DBase
                 ,public OTabOrderDialog_PBase
-                ,public PcrClient
     {
     protected:
         // <properties>
diff --git a/extensions/source/propctrlr/propertyhandler.hxx b/extensions/source/propctrlr/propertyhandler.hxx
index 88c1caecce8d..7711e6055af0 100644
--- a/extensions/source/propctrlr/propertyhandler.hxx
+++ b/extensions/source/propctrlr/propertyhandler.hxx
@@ -76,9 +76,6 @@ namespace pcr
                                     m_aSupportedProperties;
         mutable bool                m_bSupportedPropertiesAreKnown;
 
-        /// helper which ensures that we can access resources as long as the instance lives
-        PcrClient       m_aEnsureResAccess;
-
     private:
         /// the property listener which has been registered
         PropertyChangeListeners                               m_aPropertyListeners;
diff --git a/extensions/source/propctrlr/selectlabeldialog.hxx b/extensions/source/propctrlr/selectlabeldialog.hxx
index 626a40ce816f..e31f86a88e60 100644
--- a/extensions/source/propctrlr/selectlabeldialog.hxx
+++ b/extensions/source/propctrlr/selectlabeldialog.hxx
@@ -37,7 +37,6 @@ namespace pcr
 
     class OSelectLabelDialog
             :public ModalDialog
-            ,public PcrClient
     {
         VclPtr<FixedText>       m_pMainDesc;
         VclPtr<SvTreeListBox>   m_pControlTree;
diff --git a/include/comphelper/componentmodule.hxx b/include/comphelper/componentmodule.hxx
index 05626ebaecee..9cb07461ce7d 100644
--- a/include/comphelper/componentmodule.hxx
+++ b/include/comphelper/componentmodule.hxx
@@ -82,7 +82,6 @@ namespace comphelper
     class COMPHELPER_DLLPUBLIC OModule
     {
     private:
-        oslInterlockedCount     m_nClients;     /// number of registered clients
         std::unique_ptr<OModuleImpl>            m_pImpl;        /// impl class. lives as long as at least one client for the module is registered
 
     protected:
@@ -126,42 +125,12 @@ namespace comphelper
         */
         void* getComponentFactory( const sal_Char* _pImplementationName );
 
-    public:
-        class ClientAccess { friend class OModuleClient; private: ClientAccess() { } };
-        /// register a client for the module
-        void registerClient( ClientAccess );
-        /// revoke a client for the module
-        void revokeClient( ClientAccess );
-
-    protected:
-
-        /** called when the last client has been revoked
-            @precond
-                <member>m_aMutex</member> is locked
-        */
-        virtual void onLastClient();
-
     private:
         OModule( const OModule& ) = delete;
         OModule& operator=( const OModule& ) = delete;
     };
 
 
-    //= OModuleClient
-
-    /** base class for objects which uses any global module-specific resources
-    */
-    class COMPHELPER_DLLPUBLIC OModuleClient
-    {
-    protected:
-        OModule&    m_rModule;
-
-    public:
-        OModuleClient( OModule& _rModule ) :m_rModule( _rModule )   { m_rModule.registerClient( OModule::ClientAccess() ); }
-        ~OModuleClient()                                            { m_rModule.revokeClient( OModule::ClientAccess() ); }
-    };
-
-
     //= OAutoRegistration
 
     template <class TYPE>
diff --git a/include/unotools/componentresmodule.hxx b/include/unotools/componentresmodule.hxx
index 127954d7dfb9..ee19e99f53b0 100644
--- a/include/unotools/componentresmodule.hxx
+++ b/include/unotools/componentresmodule.hxx
@@ -31,8 +31,6 @@ namespace utl
 
     class OComponentResModuleImpl;
 
-    //= OComponentResourceModule
-
     /** extends the comphelper::OModule implementation with
         simply resource access
     */
@@ -52,77 +50,6 @@ namespace utl
         const std::locale& getResLocale();
     };
 
-    //= defining a concrete module
-
-#define DEFINE_MODULE( ModuleClass, ClientClass ) \
-    /* -------------------------------------------------------------------- */ \
-    class ModuleClass : public ::utl::OComponentResourceModule \
-    { \
-        friend struct CreateModuleClass; \
-        typedef ::utl::OComponentResourceModule BaseClass; \
-    \
-    public: \
-        static ModuleClass& getInstance(); \
-    \
-    private: \
-        ModuleClass(); \
-    }; \
-    \
-    /* -------------------------------------------------------------------- */ \
-    class ClientClass : public ::comphelper::OModuleClient \
-    { \
-    private: \
-        typedef ::comphelper::OModuleClient BaseClass; \
-    \
-    public: \
-        ClientClass() : BaseClass( ModuleClass::getInstance() ) \
-        { \
-        } \
-    }; \
-    \
-    /* -------------------------------------------------------------------- */ \
-    template < class TYPE > \
-    class OAutoRegistration : public ::comphelper::OAutoRegistration< TYPE > \
-    { \
-    private: \
-        typedef ::comphelper::OAutoRegistration< TYPE >    BaseClass; \
-    \
-    public: \
-        OAutoRegistration() : BaseClass( ModuleClass::getInstance() ) \
-        { \
-        } \
-    };
-
-    //= implementing a concrete module
-
-#define IMPLEMENT_MODULE( ModuleClass, resprefix ) \
-    struct CreateModuleClass \
-    { \
-        ModuleClass* operator()() \
-        { \
-            static ModuleClass* pModule = new ModuleClass; \
-            return pModule; \
-            /*  yes, in theory, this is a resource leak, since the ModuleClass \
-                will never be cleaned up. However, using a non-heap instance of ModuleClass \
-                would not work: It would be cleaned up when the module is unloaded. \
-                This might happen (and is likely to happen) *after* the tools-library \
-                has been unloaded. However, the module's dtor is where we would delete \
-                our resource manager (in case not all our clients de-registered) - which \
-                would call into the already-unloaded tools-library. */ \
-        } \
-    }; \
-    \
-    ModuleClass::ModuleClass() \
-        :BaseClass( OString( resprefix ), Application::GetSettings().GetUILanguageTag() ) \
-    { \
-    } \
-    \
-    ModuleClass& ModuleClass::getInstance() \
-    { \
-        return *rtl_Instance< ModuleClass, CreateModuleClass, ::osl::MutexGuard, ::osl::GetGlobalMutex >:: \
-            create( CreateModuleClass(), ::osl::GetGlobalMutex() ); \
-    } \
-
 } // namespace utl
 
 #endif // INCLUDED_UNOTOOLS_COMPONENTRESMODULE_HXX


More information about the Libreoffice-commits mailing list