From 0f2157cb1513371829d7f8c415324cffed28c377 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Tue, 13 Feb 2018 00:23:50 +0200 Subject: 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 Reviewed-by: Tor Lillqvist --- extensions/source/ole/servprov.cxx | 136 ------------------------------------- extensions/source/ole/servprov.hxx | 45 ------------ 2 files changed, 181 deletions(-) diff --git a/extensions/source/ole/servprov.cxx b/extensions/source/ole/servprov.cxx index 78d59292368f..e7fcbb9823ef 100644 --- a/extensions/source/ole/servprov.cxx +++ b/extensions/source/ole/servprov.cxx @@ -43,132 +43,6 @@ using namespace com::sun::star::bridge::ModelDependent; // {82154420-0FBF-11d4-8313-005004526AB4} DEFINE_GUID(OID_ServiceManager, 0x82154420, 0xfbf, 0x11d4, 0x83, 0x13, 0x0, 0x50, 0x4, 0x52, 0x6a, 0xb4); -ProviderOleWrapper::ProviderOleWrapper(const Reference& smgr, - const Reference& xSFact) - : m_xSingleServiceFactory(xSFact), - m_smgr( smgr) -{ - Reference xInt = smgr->createInstance("com.sun.star.bridge.oleautomation.BridgeSupplier"); - - if (xInt.is()) - { - Any a= xInt->queryInterface( cppu::UnoType::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(static_cast(this)); - return NOERROR; - } - else if (IsEqualIID(riid, IID_IClassFactory)) - { - AddRef(); - *ppv = static_cast(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 xInstance; - - if (m_xSingleServiceFactory.is()) - { - xInstance = m_xSingleServiceFactory->createInstance(); - - if (xInstance.is()) - { - Any usrAny(&xInstance, cppu::UnoType::get()); - - sal_uInt8 arId[16]; - rtl_getGlobalProcessId( arId ); - Any oleAny = m_bridgeSupplier->createBridge(usrAny, - Sequence(reinterpret_cast(arId), 16), - UNO, - OLE); - - - if (auto v = o3tl::tryAccess(oleAny)) - { - VARIANT* pVariant = reinterpret_cast(*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& smgr, const Reference& xInst ) : m_refCount(0) @@ -612,16 +486,6 @@ css::uno::Sequence OleServer::getSupportedServiceNames() "com.sun.star.bridge.oleautomation.ApplicationRegistration"}; } -bool OleServer::provideService(const Reference& 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& xInst, GUID const * guid) { IClassFactoryWrapper* pFac = new OneInstanceOleWrapper( m_smgr, xInst ); diff --git a/extensions/source/ole/servprov.hxx b/extensions/source/ole/servprov.hxx index f8b6ad75d2c3..2f4b8446f815 100644 --- a/extensions/source/ole/servprov.hxx +++ b/extensions/source/ole/servprov.hxx @@ -60,49 +60,6 @@ protected: ~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& smgr, - const Reference& 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 m_xSingleServiceFactory; - DWORD m_factoryHandle; - Reference m_bridgeSupplier; - Reference m_smgr; -}; - /***************************************************************************** OneInstanceOleWrapper @@ -239,8 +196,6 @@ public: css::uno::Sequence SAL_CALL getSupportedServiceNames() override; protected: - - bool provideService(const Reference& xMulFact, GUID const * guid); bool provideInstance(const Reference& xInst, GUID const * guid); list< IClassFactoryWrapper* > m_wrapperList; -- cgit