Kaydet (Commit) 4bb2bca0 authored tarafından Noel Grandin's avatar Noel Grandin

remove now unnecessary comphelper::OModuleClient stuff

after the great gettext migration of 2017

Change-Id: I704389b1ae1fb34dae0429c98cbfc89c2d3b8e27
Reviewed-on: https://gerrit.libreoffice.org/40322Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 3c077e58
......@@ -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 );
......
......@@ -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);
......
......@@ -74,7 +74,6 @@ namespace pcr
class OBrowserListBox :public Control
,public IButtonClickListener
,public PcrClient
{
protected:
VclPtr<Window> m_aLinesPlayground;
......
......@@ -37,7 +37,6 @@ namespace pcr
class OControlFontDialog
:public OControlFontDialog_DBase
,public OControlFontDialog_PBase
,public PcrClient
{
protected:
// <properties>
......
......@@ -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)
{
......
......@@ -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[] =
{
/*
......
......@@ -36,7 +36,6 @@ namespace pcr
class OPropertyInfoService
:public IPropertyInfoService
,public PcrClient
{
protected:
static sal_uInt16 s_nCount;
......
......@@ -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
......
......@@ -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
......
......@@ -38,7 +38,6 @@ namespace pcr
class OTabOrderDialog
:public OTabOrderDialog_DBase
,public OTabOrderDialog_PBase
,public PcrClient
{
protected:
// <properties>
......
......@@ -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;
......
......@@ -37,7 +37,6 @@ namespace pcr
class OSelectLabelDialog
:public ModalDialog
,public PcrClient
{
VclPtr<FixedText> m_pMainDesc;
VclPtr<SvTreeListBox> m_pControlTree;
......
......@@ -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>
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment