Bin dead code
OleServer::provideService() was not called anywhere. That means the ProviderOleWrapper class is unused, too. Which is good, as it seemed to largely be identical to OneInstanceOleWrapper anyway. Change-Id: If8782d56ed1ec1bb173cfc18be585be4c331f335 Reviewed-on: https://gerrit.libreoffice.org/54647 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tor Lillqvist <tml@collabora.com>
This commit is contained in:
@@ -43,132 +43,6 @@ using namespace com::sun::star::bridge::ModelDependent;
|
|||||||
// {82154420-0FBF-11d4-8313-005004526AB4}
|
// {82154420-0FBF-11d4-8313-005004526AB4}
|
||||||
DEFINE_GUID(OID_ServiceManager, 0x82154420, 0xfbf, 0x11d4, 0x83, 0x13, 0x0, 0x50, 0x4, 0x52, 0x6a, 0xb4);
|
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)
|
|
||||||
: m_xSingleServiceFactory(xSFact),
|
|
||||||
m_smgr( smgr)
|
|
||||||
{
|
|
||||||
Reference<XInterface> xInt = smgr->createInstance("com.sun.star.bridge.oleautomation.BridgeSupplier");
|
|
||||||
|
|
||||||
if (xInt.is())
|
|
||||||
{
|
|
||||||
Any a= xInt->queryInterface( cppu::UnoType<XBridgeSupplier2>::get() );
|
|
||||||
a >>= m_bridgeSupplier;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ProviderOleWrapper::~ProviderOleWrapper()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProviderOleWrapper::registerClass(GUID const * pGuid)
|
|
||||||
{
|
|
||||||
HRESULT hresult;
|
|
||||||
|
|
||||||
o2u_attachCurrentThread();
|
|
||||||
|
|
||||||
hresult = CoRegisterClassObject(
|
|
||||||
*pGuid,
|
|
||||||
this,
|
|
||||||
CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
|
|
||||||
REGCLS_MULTIPLEUSE,
|
|
||||||
&m_factoryHandle);
|
|
||||||
|
|
||||||
return (hresult == NOERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProviderOleWrapper::deregisterClass()
|
|
||||||
{
|
|
||||||
HRESULT hresult = CoRevokeClassObject(m_factoryHandle);
|
|
||||||
|
|
||||||
return (hresult == NOERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
STDMETHODIMP ProviderOleWrapper::QueryInterface(REFIID riid, void FAR* FAR* ppv)
|
|
||||||
{
|
|
||||||
if(IsEqualIID(riid, IID_IUnknown))
|
|
||||||
{
|
|
||||||
AddRef();
|
|
||||||
*ppv = static_cast<IUnknown*>(static_cast<IClassFactory*>(this));
|
|
||||||
return NOERROR;
|
|
||||||
}
|
|
||||||
else if (IsEqualIID(riid, IID_IClassFactory))
|
|
||||||
{
|
|
||||||
AddRef();
|
|
||||||
*ppv = static_cast<IClassFactory*>(this);
|
|
||||||
return NOERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ppv = nullptr;
|
|
||||||
return ResultFromScode(E_NOINTERFACE);
|
|
||||||
}
|
|
||||||
|
|
||||||
STDMETHODIMP_(ULONG) ProviderOleWrapper::AddRef()
|
|
||||||
{
|
|
||||||
return osl_atomic_increment( &m_refCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
STDMETHODIMP_(ULONG) ProviderOleWrapper::Release()
|
|
||||||
{
|
|
||||||
MutexGuard aGuard( Mutex::getGlobalMutex());
|
|
||||||
ULONG refCount = --m_refCount;
|
|
||||||
if (m_refCount == 0)
|
|
||||||
{
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
|
|
||||||
return refCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
STDMETHODIMP ProviderOleWrapper::CreateInstance(IUnknown FAR* punkOuter,
|
|
||||||
REFIID riid,
|
|
||||||
void FAR* FAR* ppv)
|
|
||||||
{
|
|
||||||
HRESULT ret = ResultFromScode(E_UNEXPECTED);
|
|
||||||
punkOuter = nullptr;
|
|
||||||
|
|
||||||
Reference<XInterface> xInstance;
|
|
||||||
|
|
||||||
if (m_xSingleServiceFactory.is())
|
|
||||||
{
|
|
||||||
xInstance = m_xSingleServiceFactory->createInstance();
|
|
||||||
|
|
||||||
if (xInstance.is())
|
|
||||||
{
|
|
||||||
Any usrAny(&xInstance, cppu::UnoType<decltype(xInstance)>::get());
|
|
||||||
|
|
||||||
sal_uInt8 arId[16];
|
|
||||||
rtl_getGlobalProcessId( arId );
|
|
||||||
Any oleAny = m_bridgeSupplier->createBridge(usrAny,
|
|
||||||
Sequence<sal_Int8>(reinterpret_cast<sal_Int8*>(arId), 16),
|
|
||||||
UNO,
|
|
||||||
OLE);
|
|
||||||
|
|
||||||
|
|
||||||
if (auto v = o3tl::tryAccess<sal_uIntPtr>(oleAny))
|
|
||||||
{
|
|
||||||
VARIANT* pVariant = reinterpret_cast<VARIANT*>(*v);
|
|
||||||
|
|
||||||
if (pVariant->vt == VT_DISPATCH)
|
|
||||||
{
|
|
||||||
ret = pVariant->pdispVal->QueryInterface(riid, ppv);
|
|
||||||
}
|
|
||||||
|
|
||||||
VariantClear(pVariant);
|
|
||||||
CoTaskMemFree(pVariant);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
STDMETHODIMP ProviderOleWrapper::LockServer(int /*fLock*/)
|
|
||||||
{
|
|
||||||
return NOERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
OneInstanceOleWrapper::OneInstanceOleWrapper( const Reference<XMultiServiceFactory>& smgr,
|
OneInstanceOleWrapper::OneInstanceOleWrapper( const Reference<XMultiServiceFactory>& smgr,
|
||||||
const Reference<XInterface>& xInst )
|
const Reference<XInterface>& xInst )
|
||||||
: m_refCount(0)
|
: m_refCount(0)
|
||||||
@@ -612,16 +486,6 @@ css::uno::Sequence<OUString> OleServer::getSupportedServiceNames()
|
|||||||
"com.sun.star.bridge.oleautomation.ApplicationRegistration"};
|
"com.sun.star.bridge.oleautomation.ApplicationRegistration"};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OleServer::provideService(const Reference<XSingleServiceFactory>& xSFact, GUID const * guid)
|
|
||||||
{
|
|
||||||
IClassFactoryWrapper* pFac = new ProviderOleWrapper( m_smgr, xSFact );
|
|
||||||
|
|
||||||
pFac->AddRef();
|
|
||||||
m_wrapperList.push_back(pFac);
|
|
||||||
|
|
||||||
return pFac->registerClass(guid);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OleServer::provideInstance(const Reference<XInterface>& xInst, GUID const * guid)
|
bool OleServer::provideInstance(const Reference<XInterface>& xInst, GUID const * guid)
|
||||||
{
|
{
|
||||||
IClassFactoryWrapper* pFac = new OneInstanceOleWrapper( m_smgr, xInst );
|
IClassFactoryWrapper* pFac = new OneInstanceOleWrapper( m_smgr, xInst );
|
||||||
|
@@ -60,49 +60,6 @@ protected:
|
|||||||
~IClassFactoryWrapper() {}
|
~IClassFactoryWrapper() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
|
|
||||||
ProviderOleWrapper
|
|
||||||
|
|
||||||
Provides an UNO service provider as OLE class factory. Handle the
|
|
||||||
OLE registration by overriding the abstract methods from
|
|
||||||
IClassFactoryWrapper.
|
|
||||||
|
|
||||||
Acts as a COM class factory. When IClassFactory::CreateInstance is being called
|
|
||||||
then it creates an service by help of the XSingleServiceFactory member and maps
|
|
||||||
maps it to a COM object.
|
|
||||||
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
class ProviderOleWrapper : public IClassFactoryWrapper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
ProviderOleWrapper( const Reference<XMultiServiceFactory>& smgr,
|
|
||||||
const Reference<XSingleServiceFactory>& xSFactory);
|
|
||||||
virtual ~ProviderOleWrapper();
|
|
||||||
|
|
||||||
bool registerClass(GUID const * pGuid) override;
|
|
||||||
bool deregisterClass() override;
|
|
||||||
|
|
||||||
/* IUnknown methods */
|
|
||||||
STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj) override;
|
|
||||||
STDMETHOD_(ULONG, AddRef)() override;
|
|
||||||
STDMETHOD_(ULONG, Release)() override;
|
|
||||||
|
|
||||||
/* IClassFactory methods */
|
|
||||||
STDMETHOD(CreateInstance)(IUnknown FAR* punkOuter, REFIID riid, void FAR* FAR* ppv) override;
|
|
||||||
STDMETHOD(LockServer)(int fLock) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
oslInterlockedCount m_refCount;
|
|
||||||
Reference<XSingleServiceFactory> m_xSingleServiceFactory;
|
|
||||||
DWORD m_factoryHandle;
|
|
||||||
Reference<XBridgeSupplier2> m_bridgeSupplier;
|
|
||||||
Reference<XMultiServiceFactory> m_smgr;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
||||||
OneInstanceOleWrapper
|
OneInstanceOleWrapper
|
||||||
@@ -239,8 +196,6 @@ public:
|
|||||||
css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
|
css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool provideService(const Reference<XSingleServiceFactory>& xMulFact, GUID const * guid);
|
|
||||||
bool provideInstance(const Reference<XInterface>& xInst, GUID const * guid);
|
bool provideInstance(const Reference<XInterface>& xInst, GUID const * guid);
|
||||||
|
|
||||||
list< IClassFactoryWrapper* > m_wrapperList;
|
list< IClassFactoryWrapper* > m_wrapperList;
|
||||||
|
Reference in New Issue
Block a user