diff options
-rw-r--r-- | avmedia/source/win/framegrabber.cxx | 2 | ||||
-rw-r--r-- | avmedia/source/win/player.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AColumn.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AConnection.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx | 8 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AGroup.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/Awrapado.cxx | 6 | ||||
-rw-r--r-- | extensions/source/config/WinUserInfo/WinUserInfoBe.cxx | 4 | ||||
-rw-r--r-- | fpicker/source/win32/VistaFilePickerImpl.cxx | 2 | ||||
-rw-r--r-- | include/systools/win32/comtools.hxx | 26 | ||||
-rw-r--r-- | vcl/win/app/fileregistration.cxx | 7 |
11 files changed, 28 insertions, 35 deletions
diff --git a/avmedia/source/win/framegrabber.cxx b/avmedia/source/win/framegrabber.cxx index 42e30219caf3..a2adc90b7072 100644 --- a/avmedia/source/win/framegrabber.cxx +++ b/avmedia/source/win/framegrabber.cxx @@ -62,7 +62,7 @@ sal::systools::COMReference<IMediaDet> implCreateMediaDet( const OUString& rURL { sal::systools::COMReference<IMediaDet> pDet; - if( SUCCEEDED(pDet.TryCoCreateInstance(CLSID_MediaDet, nullptr, CLSCTX_INPROC_SERVER)) ) + if( SUCCEEDED(pDet.CoCreateInstance(CLSID_MediaDet, nullptr, CLSCTX_INPROC_SERVER)) ) { OUString aLocalStr; diff --git a/avmedia/source/win/player.cxx b/avmedia/source/win/player.cxx index 7f6660ab8462..5c05dcbc32dc 100644 --- a/avmedia/source/win/player.cxx +++ b/avmedia/source/win/player.cxx @@ -95,7 +95,7 @@ bool Player::create( const OUString& rURL ) { bool bRet = false; - if( SUCCEEDED(mpGB.TryCoCreateInstance(CLSID_FilterGraph, nullptr, CLSCTX_INPROC_SERVER)) ) + if( SUCCEEDED(mpGB.CoCreateInstance(CLSID_FilterGraph, nullptr, CLSCTX_INPROC_SERVER)) ) { // Don't use the overlay mixer on Windows Vista // It disables the desktop composition as soon as RenderFile is called diff --git a/connectivity/source/drivers/ado/AColumn.cxx b/connectivity/source/drivers/ado/AColumn.cxx index e136e39f4e2b..a521586b9551 100644 --- a/connectivity/source/drivers/ado/AColumn.cxx +++ b/connectivity/source/drivers/ado/AColumn.cxx @@ -40,7 +40,7 @@ using namespace com::sun::star::sdbc; void WpADOColumn::Create() { - pInterface.TryCoCreateInstance(ADOS::CLSID_ADOCOLUMN_25, nullptr, CLSCTX_INPROC_SERVER); + pInterface.CoCreateInstance(ADOS::CLSID_ADOCOLUMN_25, nullptr, CLSCTX_INPROC_SERVER); } OAdoColumn::OAdoColumn(bool _bCase,OConnection* _pConnection,_ADOColumn* _pColumn) diff --git a/connectivity/source/drivers/ado/AConnection.cxx b/connectivity/source/drivers/ado/AConnection.cxx index 5b44d9e6f4fb..c393d6a4dc3e 100644 --- a/connectivity/source/drivers/ado/AConnection.cxx +++ b/connectivity/source/drivers/ado/AConnection.cxx @@ -59,7 +59,7 @@ OConnection::OConnection(ODriver* _pDriver) osl_atomic_increment( &m_refCount ); sal::systools::COMReference<IClassFactory2> pIUnknown; - if (!FAILED(pIUnknown.TryCoGetClassObject(ADOS::CLSID_ADOCONNECTION_21, CLSCTX_INPROC_SERVER))) + if (!FAILED(pIUnknown.CoGetClassObject(ADOS::CLSID_ADOCONNECTION_21, CLSCTX_INPROC_SERVER))) { HRESULT hr = pIUnknown->CreateInstanceLic(nullptr, nullptr, diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx index 42cf95a827ae..037fdb6fe41d 100644 --- a/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx +++ b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx @@ -385,7 +385,7 @@ RightsEnum OAdoGroup::Map2Right(sal_Int32 _eNum) void WpADOIndex::Create() { - pInterface.TryCoCreateInstance(ADOS::CLSID_ADOINDEX_25, nullptr, CLSCTX_INPROC_SERVER); + pInterface.CoCreateInstance(ADOS::CLSID_ADOINDEX_25, nullptr, CLSCTX_INPROC_SERVER); } void OAdoIndex::fillPropertyValues() @@ -401,7 +401,7 @@ void OAdoIndex::fillPropertyValues() void WpADOKey::Create() { - pInterface.TryCoCreateInstance(ADOS::CLSID_ADOKEY_25, nullptr, CLSCTX_INPROC_SERVER); + pInterface.CoCreateInstance(ADOS::CLSID_ADOKEY_25, nullptr, CLSCTX_INPROC_SERVER); } void OAdoKey::fillPropertyValues() @@ -498,7 +498,7 @@ KeyTypeEnum OAdoKey::Map2KeyRule(sal_Int32 _eNum) void WpADOTable::Create() { - pInterface.TryCoCreateInstance(ADOS::CLSID_ADOTABLE_25, nullptr, CLSCTX_INPROC_SERVER); + pInterface.CoCreateInstance(ADOS::CLSID_ADOTABLE_25, nullptr, CLSCTX_INPROC_SERVER); } OUString WpADOCatalog::GetObjectOwner(std::u16string_view _rName, ObjectTypeEnum _eNum) @@ -533,7 +533,7 @@ void OAdoTable::fillPropertyValues() void WpADOUser::Create() { - pInterface.TryCoCreateInstance(ADOS::CLSID_ADOUSER_25, nullptr, CLSCTX_INPROC_SERVER); + pInterface.CoCreateInstance(ADOS::CLSID_ADOUSER_25, nullptr, CLSCTX_INPROC_SERVER); } diff --git a/connectivity/source/drivers/ado/AGroup.cxx b/connectivity/source/drivers/ado/AGroup.cxx index 932cfc232de3..a347fb96de70 100644 --- a/connectivity/source/drivers/ado/AGroup.cxx +++ b/connectivity/source/drivers/ado/AGroup.cxx @@ -36,7 +36,7 @@ using namespace com::sun::star::sdbcx; void WpADOGroup::Create() { - pInterface.TryCoCreateInstance(ADOS::CLSID_ADOGROUP_25, nullptr, CLSCTX_INPROC_SERVER); + pInterface.CoCreateInstance(ADOS::CLSID_ADOGROUP_25, nullptr, CLSCTX_INPROC_SERVER); } OAdoGroup::OAdoGroup(OCatalog* _pParent,bool _bCase, ADOGroup* _pGroup) : OGroup_ADO(_bCase),m_pCatalog(_pParent) diff --git a/connectivity/source/drivers/ado/Awrapado.cxx b/connectivity/source/drivers/ado/Awrapado.cxx index 2a9f66656956..44a38090b5d3 100644 --- a/connectivity/source/drivers/ado/Awrapado.cxx +++ b/connectivity/source/drivers/ado/Awrapado.cxx @@ -28,7 +28,7 @@ using namespace connectivity::ado; void WpADOCatalog::Create() { - pInterface.TryCoCreateInstance(ADOS::CLSID_ADOCATALOG_25, nullptr, CLSCTX_INPROC_SERVER); + pInterface.CoCreateInstance(ADOS::CLSID_ADOCATALOG_25, nullptr, CLSCTX_INPROC_SERVER); } @@ -256,7 +256,7 @@ void WpADOCommand::put_ActiveConnection(/* [in] */ const OLEVariant& vConn) void WpADOCommand::Create() { sal::systools::COMReference<IClassFactory2> pInterface2; - if (!FAILED(pInterface2.TryCoGetClassObject(ADOS::CLSID_ADOCOMMAND_21, CLSCTX_INPROC_SERVER))) + if (!FAILED(pInterface2.CoGetClassObject(ADOS::CLSID_ADOCOMMAND_21, CLSCTX_INPROC_SERVER))) { sal::systools::COMReference<ADOCommand> pCommand; @@ -649,7 +649,7 @@ bool WpADOProperty::PutAttributes(sal_Int32 _nDefSize) void WpADORecordset::Create() { sal::systools::COMReference<IClassFactory2> pInterface2; - if (!FAILED(pInterface2.TryCoGetClassObject(ADOS::CLSID_ADORECORDSET_21, CLSCTX_INPROC_SERVER))) + if (!FAILED(pInterface2.CoGetClassObject(ADOS::CLSID_ADORECORDSET_21, CLSCTX_INPROC_SERVER))) { sal::systools::COMReference<ADORecordset> pRec; HRESULT hr = pInterface2->CreateInstanceLic(nullptr, diff --git a/extensions/source/config/WinUserInfo/WinUserInfoBe.cxx b/extensions/source/config/WinUserInfo/WinUserInfoBe.cxx index 2e97ab5581ac..9b721d50b36a 100644 --- a/extensions/source/config/WinUserInfo/WinUserInfoBe.cxx +++ b/extensions/source/config/WinUserInfo/WinUserInfoBe.cxx @@ -90,8 +90,8 @@ public: { sal::systools::CoInitializeGuard aCoInitializeGuard(COINIT_APARTMENTTHREADED); - auto pADsys = sal::systools::COMReference<IADsADSystemInfo>().CoCreateInstance( - CLSID_ADSystemInfo, nullptr, CLSCTX_INPROC_SERVER); + sal::systools::COMReference<IADsADSystemInfo> pADsys(CLSID_ADSystemInfo, nullptr, + CLSCTX_INPROC_SERVER); smartBSTR sUserDN; sal::systools::ThrowIfFailed(pADsys->get_UserName(&sUserDN.ptr), "get_UserName failed"); diff --git a/fpicker/source/win32/VistaFilePickerImpl.cxx b/fpicker/source/win32/VistaFilePickerImpl.cxx index dbd0f87983a9..76da82108cde 100644 --- a/fpicker/source/win32/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/VistaFilePickerImpl.cxx @@ -134,7 +134,7 @@ template <class ComPtrDialog, REFCLSID CLSID> class TDialogImpl : public TDialog { public: TDialogImpl() - : TDialogImplBase(ComPtrDialog().CoCreateInstance(CLSID).get()) + : TDialogImplBase(ComPtrDialog(CLSID).get()) { } }; diff --git a/include/systools/win32/comtools.hxx b/include/systools/win32/comtools.hxx index ebaed567fcf3..b141842882aa 100644 --- a/include/systools/win32/comtools.hxx +++ b/include/systools/win32/comtools.hxx @@ -127,6 +127,13 @@ namespace sal::systools { } + // Using CoCreateInstance + COMReference(REFCLSID clsid, IUnknown* pOuter = nullptr, DWORD nCtx = CLSCTX_ALL) + : com_ptr_(nullptr) + { + ThrowIfFailed(CoCreateInstance(clsid, pOuter, nCtx), "CoCreateInstance failed"); + } + COMReference<T>& operator=(const COMReference<T>& other) { return operator=(other.com_ptr_); @@ -170,8 +177,8 @@ namespace sal::systools return operator=(p.template QueryInterface<T>(t)); } - HRESULT TryCoCreateInstance(REFCLSID clsid, IUnknown* pOuter = nullptr, - DWORD nCtx = CLSCTX_ALL) + HRESULT CoCreateInstance(REFCLSID clsid, IUnknown* pOuter = nullptr, + DWORD nCtx = CLSCTX_ALL) { T* ip; HRESULT hr = ::CoCreateInstance(clsid, pOuter, nCtx, IID_PPV_ARGS(&ip)); @@ -180,14 +187,7 @@ namespace sal::systools return hr; } - COMReference<T>& CoCreateInstance(REFCLSID clsid, IUnknown* pOuter = nullptr, - DWORD nCtx = CLSCTX_ALL) - { - ThrowIfFailed(TryCoCreateInstance(clsid, pOuter, nCtx), "CoCreateInstance failed"); - return *this; - } - - HRESULT TryCoGetClassObject(REFCLSID clsid, DWORD nCtx = CLSCTX_ALL) + HRESULT CoGetClassObject(REFCLSID clsid, DWORD nCtx = CLSCTX_ALL) { T* ip; HRESULT hr = ::CoGetClassObject(clsid, nCtx, nullptr, IID_PPV_ARGS(&ip)); @@ -196,12 +196,6 @@ namespace sal::systools return hr; } - COMReference<T>& CoGetClassObject(REFCLSID clsid, DWORD nCtx = CLSCTX_ALL) - { - ThrowIfFailed(TryCoGetClassObject(clsid, nCtx), "CoGetClassObject failed"); - return *this; - } - T* operator->() const { return com_ptr_; } T& operator*() const { return *com_ptr_; } diff --git a/vcl/win/app/fileregistration.cxx b/vcl/win/app/fileregistration.cxx index 75bb0010ba21..bd31c4acd607 100644 --- a/vcl/win/app/fileregistration.cxx +++ b/vcl/win/app/fileregistration.cxx @@ -37,7 +37,7 @@ namespace vcl::fileregistration { static void LaunchModernSettingsDialogDefaultApps() { - auto pIf = sal::systools::COMReference<IApplicationActivationManager>().CoCreateInstance( + sal::systools::COMReference<IApplicationActivationManager> pIf( CLSID_ApplicationActivationManager, nullptr, CLSCTX_INPROC_SERVER); DWORD pid; @@ -121,9 +121,8 @@ void LaunchRegistrationUI() } else { - auto pIf = sal::systools::COMReference<IApplicationAssociationRegistrationUI>() - .CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI, nullptr, - CLSCTX_INPROC_SERVER); + sal::systools::COMReference<IApplicationAssociationRegistrationUI> pIf( + CLSID_ApplicationAssociationRegistrationUI, nullptr, CLSCTX_INPROC_SERVER); // LaunchAdvancedAssociationUI only works for applications registered under // Software\RegisteredApplications. See scp2/source/ooo/registryitem_ooo.scp |