diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-30 15:21:11 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-30 17:34:39 +0200 |
commit | 0c1b49048f1127d352b43847353392f0512f19e3 (patch) | |
tree | 81bbe680c12a5a1fa5e4c98f73881ca14e4fc1e2 /extensions | |
parent | 64cf52d47968d512afd383ce9a7321a4bd72b2ca (diff) |
loplugin:unusedmethods
and tweak the plugin a little to speed it up
Change-Id: Ia59456232602184c4f1b5d1d75ad94a9a2e2d0be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99799
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/abpilot/abspage.hxx | 1 | ||||
-rw-r--r-- | extensions/source/abpilot/datasourcehandling.cxx | 1 | ||||
-rw-r--r-- | extensions/source/dbpilots/controlwizard.hxx | 1 | ||||
-rw-r--r-- | extensions/source/inc/componentmodule.cxx | 115 | ||||
-rw-r--r-- | extensions/source/inc/componentmodule.hxx | 114 | ||||
-rw-r--r-- | extensions/source/propctrlr/modulepcr.cxx | 17 | ||||
-rw-r--r-- | extensions/source/propctrlr/modulepcr.hxx | 13 | ||||
-rw-r--r-- | extensions/source/propctrlr/objectinspectormodel.cxx | 1 |
8 files changed, 6 insertions, 257 deletions
diff --git a/extensions/source/abpilot/abspage.hxx b/extensions/source/abpilot/abspage.hxx index b10ee599c144..7c55bf3fae20 100644 --- a/extensions/source/abpilot/abspage.hxx +++ b/extensions/source/abpilot/abspage.hxx @@ -22,6 +22,7 @@ #include <vcl/wizardmachine.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <strings.hrc> #include <componentmodule.hxx> diff --git a/extensions/source/abpilot/datasourcehandling.cxx b/extensions/source/abpilot/datasourcehandling.cxx index 3ee8f4d368ab..1d7da2e1719b 100644 --- a/extensions/source/abpilot/datasourcehandling.cxx +++ b/extensions/source/abpilot/datasourcehandling.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/SQLContext.hpp> #include <com/sun/star/sdb/XCompletedConnection.hpp> diff --git a/extensions/source/dbpilots/controlwizard.hxx b/extensions/source/dbpilots/controlwizard.hxx index f918a5a94ab8..12835c1a6ce2 100644 --- a/extensions/source/dbpilots/controlwizard.hxx +++ b/extensions/source/dbpilots/controlwizard.hxx @@ -24,6 +24,7 @@ #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <vcl/weld.hxx> #include <vcl/wizardmachine.hxx> #include "dbptypes.hxx" diff --git a/extensions/source/inc/componentmodule.cxx b/extensions/source/inc/componentmodule.cxx index fa55250df2d5..69d2234adbdb 100644 --- a/extensions/source/inc/componentmodule.cxx +++ b/extensions/source/inc/componentmodule.cxx @@ -19,130 +19,15 @@ #include "componentmodule.hxx" #include <unotools/resmgr.hxx> -#include <osl/diagnose.h> namespace compmodule { - using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; - using namespace ::com::sun::star::registry; - using namespace ::cppu; OUString ModuleRes(const char* pId) { return Translate::get(pId, Translate::Create("pcr")); } - //- registration helper - - std::vector< OUString >* OModule::s_pImplementationNames = nullptr; - std::vector< Sequence< OUString > >* OModule::s_pSupportedServices = nullptr; - std::vector< ComponentInstantiation >* OModule::s_pCreationFunctionPointers = nullptr; - std::vector< FactoryInstantiation >* OModule::s_pFactoryFunctionPointers = nullptr; - - - void OModule::registerComponent( - const OUString& _rImplementationName, - const Sequence< OUString >& _rServiceNames, - ComponentInstantiation _pCreateFunction, - FactoryInstantiation _pFactoryFunction) - { - if (!s_pImplementationNames) - { - OSL_ENSURE(!s_pSupportedServices && !s_pCreationFunctionPointers && !s_pFactoryFunctionPointers, - "OModule::registerComponent : inconsistent state (the pointers (1)) !"); - s_pImplementationNames = new std::vector< OUString >; - s_pSupportedServices = new std::vector< Sequence< OUString > >; - s_pCreationFunctionPointers = new std::vector< ComponentInstantiation >; - s_pFactoryFunctionPointers = new std::vector< FactoryInstantiation >; - } - OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers, - "OModule::registerComponent : inconsistent state (the pointers (2)) !"); - - OSL_ENSURE( (s_pImplementationNames->size() == s_pSupportedServices->size()) - && (s_pImplementationNames->size() == s_pCreationFunctionPointers->size()) - && (s_pImplementationNames->size() == s_pFactoryFunctionPointers->size()), - "OModule::registerComponent : inconsistent state !"); - - s_pImplementationNames->push_back(_rImplementationName); - s_pSupportedServices->push_back(_rServiceNames); - s_pCreationFunctionPointers->push_back(_pCreateFunction); - s_pFactoryFunctionPointers->push_back(_pFactoryFunction); - } - - - void OModule::revokeComponent(const OUString& _rImplementationName) - { - if (!s_pImplementationNames) - { - OSL_FAIL("OModule::revokeComponent : have no class infos ! Are you sure called this method at the right time ?"); - return; - } - OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers, - "OModule::revokeComponent : inconsistent state (the pointers) !"); - OSL_ENSURE( (s_pImplementationNames->size() == s_pSupportedServices->size()) - && (s_pImplementationNames->size() == s_pCreationFunctionPointers->size()) - && (s_pImplementationNames->size() == s_pFactoryFunctionPointers->size()), - "OModule::revokeComponent : inconsistent state !"); - - auto it = std::find(s_pImplementationNames->begin(), s_pImplementationNames->end(), _rImplementationName); - if (it != s_pImplementationNames->end()) - { - sal_Int32 i = static_cast<sal_Int32>(std::distance(s_pImplementationNames->begin(), it)); - s_pImplementationNames->erase(it); - s_pSupportedServices->erase(s_pSupportedServices->begin() + i); - s_pCreationFunctionPointers->erase(s_pCreationFunctionPointers->begin() + i); - s_pFactoryFunctionPointers->erase(s_pFactoryFunctionPointers->begin() + i); - } - - if (s_pImplementationNames->empty()) - { - delete s_pImplementationNames; s_pImplementationNames = nullptr; - delete s_pSupportedServices; s_pSupportedServices = nullptr; - delete s_pCreationFunctionPointers; s_pCreationFunctionPointers = nullptr; - delete s_pFactoryFunctionPointers; s_pFactoryFunctionPointers = nullptr; - } - } - - - Reference< XInterface > OModule::getComponentFactory( - const OUString& _rImplementationName, - const Reference< XMultiServiceFactory >& _rxServiceManager) - { - OSL_ENSURE(_rxServiceManager.is(), "OModule::getComponentFactory : invalid argument (service manager) !"); - OSL_ENSURE(!_rImplementationName.isEmpty(), "OModule::getComponentFactory : invalid argument (implementation name) !"); - - if (!s_pImplementationNames) - { - OSL_FAIL("OModule::getComponentFactory : have no class infos ! Are you sure called this method at the right time ?"); - return nullptr; - } - OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers, - "OModule::getComponentFactory : inconsistent state (the pointers) !"); - OSL_ENSURE( (s_pImplementationNames->size() == s_pSupportedServices->size()) - && (s_pImplementationNames->size() == s_pCreationFunctionPointers->size()) - && (s_pImplementationNames->size() == s_pFactoryFunctionPointers->size()), - "OModule::getComponentFactory : inconsistent state !"); - - - sal_Int32 nLen = s_pImplementationNames->size(); - - for (sal_Int32 i=0; i<nLen; ++i) - { - if ((*s_pImplementationNames)[i] == _rImplementationName) - { - const FactoryInstantiation FactoryInstantiationFunction = (*s_pFactoryFunctionPointers)[i]; - - Reference< XInterface > xReturn = FactoryInstantiationFunction( _rxServiceManager, _rImplementationName, - (*s_pCreationFunctionPointers)[i], - (*s_pSupportedServices)[i], nullptr); - return xReturn; - } - } - - return nullptr; - } - } // namespace compmodule diff --git a/extensions/source/inc/componentmodule.hxx b/extensions/source/inc/componentmodule.hxx index d697ab86644e..3b5d402578cd 100644 --- a/extensions/source/inc/componentmodule.hxx +++ b/extensions/source/inc/componentmodule.hxx @@ -20,126 +20,14 @@ #ifndef INCLUDED_EXTENSIONS_SOURCE_INC_COMPONENTMODULE_HXX #define INCLUDED_EXTENSIONS_SOURCE_INC_COMPONENTMODULE_HXX -/** you may find this file helpful if you implement a component (in its own library) which can't use - the usual infrastructure.<br/> - More precise, you find helper classes to ease the use of resources and the registration of services. -*/ - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/uno/Sequence.hxx> -#include <cppuhelper/factory.hxx> -#include <vector> +#include <rtl/ustring.hxx> namespace compmodule { -typedef css::uno::Reference< css::lang::XSingleServiceFactory > (*FactoryInstantiation) - ( - const css::uno::Reference< css::lang::XMultiServiceFactory >& _rServiceManager, - const OUString & _rComponentName, - ::cppu::ComponentInstantiation _pCreateFunction, - const css::uno::Sequence< OUString > & _rServiceNames, - rtl_ModuleCount* - ); - - class OModule - { - private: - OModule() = delete; //TODO: get rid of this class - - protected: - // auto registration administration - static std::vector< OUString >* - s_pImplementationNames; - static std::vector< css::uno::Sequence< OUString > >* - s_pSupportedServices; - static std::vector< cppu::ComponentInstantiation >* - s_pCreationFunctionPointers; - static std::vector< FactoryInstantiation >* - s_pFactoryFunctionPointers; - - public: - /** register a component implementing a service with the given data. - @param _rImplementationName - the implementation name of the component - @param _rServiceNames - the services the component supports - @param _pCreateFunction - a function for creating an instance of the component - @param _pFactoryFunction - a function for creating a factory for that component - @see revokeComponent - */ - static void registerComponent( - const OUString& _rImplementationName, - const css::uno::Sequence< OUString >& _rServiceNames, - ::cppu::ComponentInstantiation _pCreateFunction, - FactoryInstantiation _pFactoryFunction); - - /** revoke the registration for the specified component - @param _rImplementationName - the implementation name of the component - */ - static void revokeComponent( - const OUString& _rImplementationName); - - /** creates a Factory for the component with the given implementation name. - <p>Usually used from within component_getFactory.<p/> - @param _rxServiceManager - a pointer to an XMultiServiceFactory interface as got in component_getFactory - @param _pImplementationName - the implementation name of the component - @return - the XInterface access to a factory for the component - */ - static css::uno::Reference< css::uno::XInterface > getComponentFactory( - const OUString& _rImplementationName, - const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxServiceManager - ); - }; - // specialized ResId, using the resource locale provided by the global module OUString ModuleRes(const char* pId); - template <class TYPE> - class OMultiInstanceAutoRegistration - { - public: - /** automatically registers a multi instance component - <p>Assumed that the template argument has the three methods - <ul> - <li><code>static OUString getImplementationName_Static()</code><li/> - <li><code>static css::uno::Sequence< OUString > getSupportedServiceNames_Static()</code><li/> - <li><code>static css::uno::Reference< css::uno::XInterface > - Create(const css::uno::Reference< css::lang::XMultiServiceFactory >&)</code> - </li> - <ul/> - the instantiation of this object will automatically register the class via <method>OModule::registerComponent</method>. - <p/> - The factory creation function used is <code>::cppu::createSingleFactory</code>. - */ - OMultiInstanceAutoRegistration(); - ~OMultiInstanceAutoRegistration(); - }; - - template <class TYPE> - OMultiInstanceAutoRegistration<TYPE>::OMultiInstanceAutoRegistration() - { - OModule::registerComponent( - TYPE::getImplementationName_Static(), - TYPE::getSupportedServiceNames_Static(), - TYPE::Create, - ::cppu::createSingleFactory - ); - } - - template <class TYPE> - OMultiInstanceAutoRegistration<TYPE>::~OMultiInstanceAutoRegistration() - { - OModule::revokeComponent(TYPE::getImplementationName_Static()); - } - } // namespace compmodule diff --git a/extensions/source/propctrlr/modulepcr.cxx b/extensions/source/propctrlr/modulepcr.cxx index 37d119e8e824..fdaf3b2a6348 100644 --- a/extensions/source/propctrlr/modulepcr.cxx +++ b/extensions/source/propctrlr/modulepcr.cxx @@ -23,23 +23,6 @@ namespace pcr { - PcrModule::PcrModule() - { - } - - PcrModule& PcrModule::getInstance() - { - 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. */ - } - OUString PcrRes(const char* pId) { return Translate::get(pId, Translate::Create("pcr")); diff --git a/extensions/source/propctrlr/modulepcr.hxx b/extensions/source/propctrlr/modulepcr.hxx index d29c2fd2c969..ee44cc6bbad3 100644 --- a/extensions/source/propctrlr/modulepcr.hxx +++ b/extensions/source/propctrlr/modulepcr.hxx @@ -20,21 +20,10 @@ #ifndef INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_MODULEPCR_HXX #define INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_MODULEPCR_HXX -#include <comphelper/componentmodule.hxx> +#include <rtl/ustring.hxx> namespace pcr { - /* -------------------------------------------------------------------- */ - class PcrModule : public ::comphelper::OModule - { - friend struct CreateModuleClass; - typedef ::comphelper::OModule BaseClass; - public: - static PcrModule& getInstance(); - private: - PcrModule(); - }; - OUString PcrRes(const char* pId); } // namespace pcr diff --git a/extensions/source/propctrlr/objectinspectormodel.cxx b/extensions/source/propctrlr/objectinspectormodel.cxx index 49e876b0a232..99447d5c8a3f 100644 --- a/extensions/source/propctrlr/objectinspectormodel.cxx +++ b/extensions/source/propctrlr/objectinspectormodel.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/ucb/AlreadyInitializedException.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> namespace pcr |