In fact it's simpler to not have m_guid fields in these two classes at all

We can just pass the GUID as parameter to the single member function
registerClass() that needs it. This perhaps means the same class can
be used in more cases, also for objects/classes that aren't going to
be registered and don't need any GUID.

Change-Id: I28703190c52b14236c6f613dd4acbe359c075f5c
Reviewed-on: https://gerrit.libreoffice.org/54622
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
This commit is contained in:
Tor Lillqvist
2018-02-13 00:08:41 +02:00
parent e4d95fa557
commit 17ad73232f
2 changed files with 16 additions and 22 deletions

View File

@@ -44,9 +44,8 @@ using namespace com::sun::star::bridge::ModelDependent;
DEFINE_GUID(OID_ServiceManager, 0x82154420, 0xfbf, 0x11d4, 0x83, 0x13, 0x0, 0x50, 0x4, 0x52, 0x6a, 0xb4);
ProviderOleWrapper::ProviderOleWrapper(const Reference<XMultiServiceFactory>& smgr,
const Reference<XSingleServiceFactory>& xSFact, GUID const * pGuid)
const Reference<XSingleServiceFactory>& xSFact)
: m_xSingleServiceFactory(xSFact),
m_guid(*pGuid),
m_smgr( smgr)
{
Reference<XInterface> xInt = smgr->createInstance("com.sun.star.bridge.oleautomation.BridgeSupplier");
@@ -63,14 +62,14 @@ ProviderOleWrapper::~ProviderOleWrapper()
{
}
bool ProviderOleWrapper::registerClass()
bool ProviderOleWrapper::registerClass(GUID const * pGuid)
{
HRESULT hresult;
o2u_attachCurrentThread();
hresult = CoRegisterClassObject(
m_guid,
*pGuid,
this,
CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE,
@@ -171,11 +170,9 @@ STDMETHODIMP ProviderOleWrapper::LockServer(int /*fLock*/)
}
OneInstanceOleWrapper::OneInstanceOleWrapper( const Reference<XMultiServiceFactory>& smgr,
const Reference<XInterface>& xInst,
GUID const * pGuid )
const Reference<XInterface>& xInst )
: m_refCount(0)
, m_xInst(xInst)
, m_guid(*pGuid)
, m_factoryHandle(0)
, m_smgr(smgr)
{
@@ -192,14 +189,14 @@ OneInstanceOleWrapper::~OneInstanceOleWrapper()
{
}
bool OneInstanceOleWrapper::registerClass()
bool OneInstanceOleWrapper::registerClass(GUID const * pGuid)
{
HRESULT hresult;
o2u_attachCurrentThread();
hresult = CoRegisterClassObject(
m_guid,
*pGuid,
this,
CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE,
@@ -617,24 +614,22 @@ css::uno::Sequence<OUString> OleServer::getSupportedServiceNames()
bool OleServer::provideService(const Reference<XSingleServiceFactory>& xSFact, GUID const * guid)
{
IClassFactoryWrapper* pFac = new ProviderOleWrapper( m_smgr, xSFact, guid);
IClassFactoryWrapper* pFac = new ProviderOleWrapper( m_smgr, xSFact );
pFac->AddRef();
m_wrapperList.push_back(pFac);
return pFac->registerClass();
return pFac->registerClass(guid);
}
bool OleServer::provideInstance(const Reference<XInterface>& xInst, GUID const * guid)
{
IClassFactoryWrapper* pFac =
new OneInstanceOleWrapper( m_smgr, xInst, guid );
IClassFactoryWrapper* pFac = new OneInstanceOleWrapper( m_smgr, xInst );
pFac->AddRef();
m_wrapperList.push_back(pFac);
return pFac->registerClass();
return pFac->registerClass(guid);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -53,7 +53,7 @@ class IClassFactoryWrapper : public IClassFactory
{
public:
virtual bool registerClass() = 0;
virtual bool registerClass(GUID const * pGuid) = 0;
virtual bool deregisterClass() = 0;
protected:
@@ -79,10 +79,10 @@ class ProviderOleWrapper : public IClassFactoryWrapper
public:
ProviderOleWrapper( const Reference<XMultiServiceFactory>& smgr,
const Reference<XSingleServiceFactory>& xSFactory, GUID const * pGuid);
const Reference<XSingleServiceFactory>& xSFactory);
virtual ~ProviderOleWrapper();
bool registerClass() override;
bool registerClass(GUID const * pGuid) override;
bool deregisterClass() override;
/* IUnknown methods */
@@ -98,7 +98,6 @@ protected:
oslInterlockedCount m_refCount;
Reference<XSingleServiceFactory> m_xSingleServiceFactory;
const GUID m_guid;
DWORD m_factoryHandle;
Reference<XBridgeSupplier2> m_bridgeSupplier;
Reference<XMultiServiceFactory> m_smgr;
@@ -121,10 +120,11 @@ class OneInstanceOleWrapper : public IClassFactoryWrapper
{
public:
OneInstanceOleWrapper( const Reference<XMultiServiceFactory>& smgr, const Reference<XInterface>& xInst, GUID const * pGuid );
OneInstanceOleWrapper( const Reference<XMultiServiceFactory>& smgr,
const Reference<XInterface>& xInst );
virtual ~OneInstanceOleWrapper();
bool registerClass() override;
bool registerClass(GUID const * pGuid) override;
bool deregisterClass() override;
/* IUnknown methods */
@@ -140,7 +140,6 @@ protected:
oslInterlockedCount m_refCount;
Reference<XInterface> m_xInst;
const GUID m_guid;
DWORD m_factoryHandle;
Reference<XBridgeSupplier2> m_bridgeSupplier;
Reference<XMultiServiceFactory> m_smgr;