From 51e5e4970bda753faf7403cbf3c68ded3ed7a71f Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 11 Oct 2016 15:39:25 +0200 Subject: Replace OLEString operators with proper functions, for clarity Change-Id: I1fa309d034e1ec94f38d07ede07e691f1484a4f5 Reviewed-on: https://gerrit.libreoffice.org/29697 Reviewed-by: Stephan Bergmann Tested-by: Stephan Bergmann --- connectivity/source/drivers/ado/AConnection.cxx | 2 +- .../source/drivers/ado/ADatabaseMetaDataImpl.cxx | 4 +- connectivity/source/drivers/ado/AUsers.cxx | 2 +- connectivity/source/drivers/ado/AView.cxx | 4 +- connectivity/source/drivers/ado/AViews.cxx | 2 +- connectivity/source/drivers/ado/Aolevariant.cxx | 8 +- connectivity/source/drivers/ado/Awrapado.cxx | 126 ++++++++++----------- connectivity/source/inc/ado/Aolevariant.hxx | 6 +- 8 files changed, 77 insertions(+), 77 deletions(-) (limited to 'connectivity') diff --git a/connectivity/source/drivers/ado/AConnection.cxx b/connectivity/source/drivers/ado/AConnection.cxx index cc94d9527b07..6894db134678 100644 --- a/connectivity/source/drivers/ado/AConnection.cxx +++ b/connectivity/source/drivers/ado/AConnection.cxx @@ -71,7 +71,7 @@ OConnection::OConnection(ODriver* _pDriver) throw(SQLException, RuntimeExcepti hr = pIUnknown->CreateInstanceLic( pOuter, NULL, ADOS::IID_ADOCONNECTION_21, - ADOS::GetKeyStr(), + ADOS::GetKeyStr().asBSTR(), (void**) &pCon); if( !FAILED( hr ) ) diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx index db6e5d63c45b..e2214a96ff38 100644 --- a/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx +++ b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx @@ -549,8 +549,8 @@ OUString WpADOCatalog::GetObjectOwner(const OUString& _rName, ObjectTypeEnum _eN _rVar.setNoArg(); OLEString aBSTR; OLEString sStr1(_rName); - pInterface->GetObjectOwner(sStr1,_eNum,_rVar,&aBSTR); - return aBSTR; + pInterface->GetObjectOwner(sStr1.asBSTR(),_eNum,_rVar,aBSTR.getAddress()); + return aBSTR.asOUString(); } void OAdoTable::fillPropertyValues() diff --git a/connectivity/source/drivers/ado/AUsers.cxx b/connectivity/source/drivers/ado/AUsers.cxx index b9b0a1f55868..b6876dced8dc 100644 --- a/connectivity/source/drivers/ado/AUsers.cxx +++ b/connectivity/source/drivers/ado/AUsers.cxx @@ -60,7 +60,7 @@ sdbcx::ObjectType OUsers::appendObject( const OUString& _rForName, const Referen m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_USER_DESCRIPTOR_ERROR,static_cast(this) ); ADOUsers* pUsers = (ADOUsers*)m_aCollection; - pUsers->Append(OLEVariant(pUser->getImpl()),OLEString(pUser->getPassword())); + pUsers->Append(OLEVariant(pUser->getImpl()),OLEString(pUser->getPassword()).asBSTR()); return createObject( _rForName ); } diff --git a/connectivity/source/drivers/ado/AView.cxx b/connectivity/source/drivers/ado/AView.cxx index 0c72bbd38f7b..9d276c952062 100644 --- a/connectivity/source/drivers/ado/AView.cxx +++ b/connectivity/source/drivers/ado/AView.cxx @@ -88,8 +88,8 @@ void OAdoView::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const { ADOCommand* pCom = (ADOCommand*)aVar.getIDispatch(); OLEString aBSTR; - pCom->get_CommandText(&aBSTR); - rValue <<= aBSTR.operator OUString(); + pCom->get_CommandText(aBSTR.getAddress()); + rValue <<= aBSTR.asOUString(); } } break; diff --git a/connectivity/source/drivers/ado/AViews.cxx b/connectivity/source/drivers/ado/AViews.cxx index 9702d79a79c2..7264bad9bf9e 100644 --- a/connectivity/source/drivers/ado/AViews.cxx +++ b/connectivity/source/drivers/ado/AViews.cxx @@ -72,7 +72,7 @@ sdbcx::ObjectType OViews::appendObject( const OUString& _rForName, const Referen aCommand.put_Name(sName); aCommand.put_CommandText(getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND)))); ADOViews* pViews = (ADOViews*)m_aCollection; - if(FAILED(pViews->Append(OLEString(sName),aCommand))) + if(FAILED(pViews->Append(OLEString(sName).asBSTR(),aCommand))) ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast(this)); OTables* pTables = static_cast(static_cast(m_rParent).getPrivateTables()); diff --git a/connectivity/source/drivers/ado/Aolevariant.cxx b/connectivity/source/drivers/ado/Aolevariant.cxx index b351e9edb138..6556fc607e92 100644 --- a/connectivity/source/drivers/ado/Aolevariant.cxx +++ b/connectivity/source/drivers/ado/Aolevariant.cxx @@ -77,15 +77,15 @@ OLEString& OLEString::operator=(const BSTR& _rSrc) m_sStr = _rSrc; return *this; } -OLEString::operator OUString() const +OUString OLEString::asOUString() const { return (m_sStr != NULL) ? OUString(reinterpret_cast(LPCOLESTR(m_sStr)),::SysStringLen(m_sStr)) : OUString(); } -OLEString::operator BSTR() const +BSTR OLEString::asBSTR() const { return m_sStr; } -BSTR* OLEString::operator &() +BSTR* OLEString::getAddress() { return &m_sStr; } @@ -427,7 +427,7 @@ OLEVariant::operator css::uno::Sequence< sal_Int8 >() const if(V_VT(this) == VT_BSTR) { OLEString sStr(V_BSTR(this)); - aRet = css::uno::Sequence(reinterpret_cast((const wchar_t*)sStr),sizeof(sal_Unicode)*sStr.length()); + aRet = css::uno::Sequence(reinterpret_cast(sStr.asBSTR()),sizeof(sal_Unicode)*sStr.length()); } else if(!isNull()) { diff --git a/connectivity/source/drivers/ado/Awrapado.cxx b/connectivity/source/drivers/ado/Awrapado.cxx index 9e9fc3b73c25..22a2a3826581 100644 --- a/connectivity/source/drivers/ado/Awrapado.cxx +++ b/connectivity/source/drivers/ado/Awrapado.cxx @@ -61,15 +61,15 @@ OUString WpADOConnection::GetConnectionString() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_ConnectionString(&aBSTR); - return aBSTR; + pInterface->get_ConnectionString(aBSTR.getAddress()); + return aBSTR.asOUString(); } sal_Bool WpADOConnection::PutConnectionString(const OUString &aCon) const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString bstr(aCon); - sal_Bool bErg = SUCCEEDED(pInterface->put_ConnectionString(bstr)); + sal_Bool bErg = SUCCEEDED(pInterface->put_ConnectionString(bstr.asBSTR())); return bErg; } @@ -112,7 +112,7 @@ sal_Bool WpADOConnection::Execute(const OUString& _CommandText,OLEVariant& Recor { OSL_ENSURE(pInterface,"Interface is null!"); OLEString sStr1(_CommandText); - sal_Bool bErg = SUCCEEDED(pInterface->Execute(sStr1,&RecordsAffected,Options,(_ADORecordset**)ppiRset)); + sal_Bool bErg = SUCCEEDED(pInterface->Execute(sStr1.asBSTR(),&RecordsAffected,Options,(_ADORecordset**)ppiRset)); return bErg; } @@ -141,7 +141,7 @@ sal_Bool WpADOConnection::Open(const OUString& ConnectionString, const OUString& OLEString sStr1(ConnectionString); OLEString sStr2(UserID); OLEString sStr3(Password); - sal_Bool bErg = SUCCEEDED(pInterface->Open(sStr1,sStr2,sStr3,Options)); + sal_Bool bErg = SUCCEEDED(pInterface->Open(sStr1.asBSTR(),sStr2.asBSTR(),sStr3.asBSTR(),Options)); return bErg; } @@ -154,15 +154,15 @@ sal_Bool WpADOConnection::GetErrors(ADOErrors** pErrors) OUString WpADOConnection::GetDefaultDatabase() const { OSL_ENSURE(pInterface,"Interface is null!"); - OLEString aBSTR; pInterface->get_DefaultDatabase(&aBSTR); - return aBSTR; + OLEString aBSTR; pInterface->get_DefaultDatabase(aBSTR.getAddress()); + return aBSTR.asOUString(); } sal_Bool WpADOConnection::PutDefaultDatabase(const OUString& _bstr) { OSL_ENSURE(pInterface,"Interface is null!"); OLEString bstr(_bstr); - sal_Bool bErg = SUCCEEDED(pInterface->put_DefaultDatabase(bstr)); + sal_Bool bErg = SUCCEEDED(pInterface->put_DefaultDatabase(bstr.asBSTR())); return bErg; } @@ -226,15 +226,15 @@ sal_Bool WpADOConnection::put_Mode(const ConnectModeEnum &eNum) OUString WpADOConnection::get_Provider() const { OSL_ENSURE(pInterface,"Interface is null!"); - OLEString aBSTR; pInterface->get_Provider(&aBSTR); - return aBSTR; + OLEString aBSTR; pInterface->get_Provider(aBSTR.getAddress()); + return aBSTR.asOUString(); } sal_Bool WpADOConnection::put_Provider(const OUString& _bstr) { OSL_ENSURE(pInterface,"Interface is null!"); OLEString bstr(_bstr); - return SUCCEEDED(pInterface->put_Provider(bstr)); + return SUCCEEDED(pInterface->put_Provider(bstr.asBSTR())); } sal_Int32 WpADOConnection::get_State() const @@ -255,8 +255,8 @@ OUString WpADOConnection::get_Version() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_Version(&aBSTR); - return aBSTR; + pInterface->get_Version(aBSTR.getAddress()); + return aBSTR.asOUString(); } sal_Bool WpADOCommand::putref_ActiveConnection( WpADOConnection *pCon) @@ -291,7 +291,7 @@ void WpADOCommand::Create() hr = pInterface2->CreateInstanceLic( pOuter, NULL, ADOS::IID_ADOCOMMAND_21, - ADOS::GetKeyStr(), + ADOS::GetKeyStr().asBSTR(), (void**) &pCommand); if( !FAILED( hr ) ) @@ -316,15 +316,15 @@ OUString WpADOCommand::get_CommandText() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_CommandText(&aBSTR); - return aBSTR; + pInterface->get_CommandText(aBSTR.getAddress()); + return aBSTR.asOUString(); } sal_Bool WpADOCommand::put_CommandText(const OUString &aCon) { OSL_ENSURE(pInterface,"Interface is null!"); OLEString bstr(aCon); - sal_Bool bErg = SUCCEEDED(pInterface->put_CommandText(bstr)); + sal_Bool bErg = SUCCEEDED(pInterface->put_CommandText(bstr.asBSTR())); return bErg; } @@ -368,7 +368,7 @@ ADOParameter* WpADOCommand::CreateParameter(const OUString &_bstr,DataTypeEnum T OSL_ENSURE(pInterface,"Interface is null!"); ADOParameter* pPara = NULL; OLEString bstr(_bstr); - sal_Bool bErg = SUCCEEDED(pInterface->CreateParameter(bstr,Type,Direction,nSize,Value,&pPara)); + sal_Bool bErg = SUCCEEDED(pInterface->CreateParameter(bstr.asBSTR(),Type,Direction,nSize,Value,&pPara)); return bErg ? pPara : NULL; } @@ -400,15 +400,15 @@ OUString WpADOCommand::GetName() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_Name(&aBSTR); - return aBSTR; + pInterface->get_Name(aBSTR.getAddress()); + return aBSTR.asOUString(); } sal_Bool WpADOCommand::put_Name(const OUString& _Name) { OSL_ENSURE(pInterface,"Interface is null!"); OLEString bstr(_Name); - sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr.asBSTR())); return bErg; } @@ -422,16 +422,16 @@ OUString WpADOError::GetDescription() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_Description(&aBSTR); - return aBSTR; + pInterface->get_Description(aBSTR.getAddress()); + return aBSTR.asOUString(); } OUString WpADOError::GetSource() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_Source(&aBSTR); - return aBSTR; + pInterface->get_Source(aBSTR.getAddress()); + return aBSTR.asOUString(); } sal_Int32 WpADOError::GetNumber() const @@ -446,8 +446,8 @@ OUString WpADOError::GetDescription() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_SQLState(&aBSTR); - return aBSTR; + pInterface->get_SQLState(aBSTR.getAddress()); + return aBSTR.asOUString(); } sal_Int32 WpADOError::GetNativeError() const @@ -505,8 +505,8 @@ OUString WpADOField::GetName() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_Name(&aBSTR); - return aBSTR; + pInterface->get_Name(aBSTR.getAddress()); + return aBSTR.asOUString(); } DataTypeEnum WpADOField::GetADOType() const @@ -658,8 +658,8 @@ sal_Bool WpADOProperty::PutValue(const OLEVariant &aValVar) { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_Name(&aBSTR); - return aBSTR; + pInterface->get_Name(aBSTR.getAddress()); + return aBSTR.asOUString(); } DataTypeEnum WpADOProperty::GetADOType() const @@ -699,7 +699,7 @@ sal_Bool WpADOProperty::PutValue(const OLEVariant &aValVar) hr = pInterface2->CreateInstanceLic( pOuter, NULL, ADOS::IID_ADORECORDSET_21, - ADOS::GetKeyStr(), + ADOS::GetKeyStr().asBSTR(), (void**) &pRec); if( !FAILED( hr ) ) @@ -947,8 +947,8 @@ WpADOProperties WpADORecordset::get_Properties() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_Name(&aBSTR); - return aBSTR; + pInterface->get_Name(aBSTR.getAddress()); + return aBSTR.asOUString(); } DataTypeEnum WpADOParameter::GetADOType() const @@ -1031,30 +1031,30 @@ OUString WpADOColumn::get_Name() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_Name(&aBSTR); - return aBSTR; + pInterface->get_Name(aBSTR.getAddress()); + return aBSTR.asOUString(); } OUString WpADOColumn::get_RelatedColumn() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_RelatedColumn(&aBSTR); - return aBSTR; + pInterface->get_RelatedColumn(aBSTR.getAddress()); + return aBSTR.asOUString(); } void WpADOColumn::put_Name(const OUString& _rName) { OSL_ENSURE(pInterface,"Interface is null!"); OLEString bstr(_rName); - sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr.asBSTR())); (void)bErg; } void WpADOColumn::put_RelatedColumn(const OUString& _rName) { OSL_ENSURE(pInterface,"Interface is null!"); OLEString bstr(_rName); - sal_Bool bErg = SUCCEEDED(pInterface->put_RelatedColumn(bstr)); + sal_Bool bErg = SUCCEEDED(pInterface->put_RelatedColumn(bstr.asBSTR())); (void)bErg; } @@ -1150,15 +1150,15 @@ OUString WpADOKey::get_Name() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_Name(&aBSTR); - return aBSTR; + pInterface->get_Name(aBSTR.getAddress()); + return aBSTR.asOUString(); } void WpADOKey::put_Name(const OUString& _rName) { OSL_ENSURE(pInterface,"Interface is null!"); OLEString bstr(_rName); - sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr.asBSTR())); (void)bErg; } @@ -1180,15 +1180,15 @@ OUString WpADOKey::get_RelatedTable() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_RelatedTable(&aBSTR); - return aBSTR; + pInterface->get_RelatedTable(aBSTR.getAddress()); + return aBSTR.asOUString(); } void WpADOKey::put_RelatedTable(const OUString& _rName) { OSL_ENSURE(pInterface,"Interface is null!"); OLEString bstr(_rName); - sal_Bool bErg = SUCCEEDED(pInterface->put_RelatedTable(bstr)); + sal_Bool bErg = SUCCEEDED(pInterface->put_RelatedTable(bstr.asBSTR())); (void)bErg; } @@ -1234,15 +1234,15 @@ OUString WpADOIndex::get_Name() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_Name(&aBSTR); - return aBSTR; + pInterface->get_Name(aBSTR.getAddress()); + return aBSTR.asOUString(); } void WpADOIndex::put_Name(const OUString& _rName) { OSL_ENSURE(pInterface,"Interface is null!"); OLEString bstr(_rName); - sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr.asBSTR())); (void)bErg; } @@ -1356,15 +1356,15 @@ OUString WpADOTable::get_Name() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_Name(&aBSTR); - return aBSTR; + pInterface->get_Name(aBSTR.getAddress()); + return aBSTR.asOUString(); } void WpADOTable::put_Name(const OUString& _rName) { OSL_ENSURE(pInterface,"Interface is null!"); OLEString bstr(_rName); - sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr.asBSTR())); (void)bErg; } @@ -1372,8 +1372,8 @@ OUString WpADOTable::get_Type() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_Type(&aBSTR); - return aBSTR; + pInterface->get_Type(aBSTR.getAddress()); + return aBSTR.asOUString(); } WpADOColumns WpADOTable::get_Columns() const @@ -1430,8 +1430,8 @@ OUString WpADOView::get_Name() const { OSL_ENSURE(pInterface,"Interface is null!"); OLEString aBSTR; - pInterface->get_Name(&aBSTR); - return aBSTR; + pInterface->get_Name(aBSTR.getAddress()); + return aBSTR.asOUString(); } void WpADOView::get_Command(OLEVariant& _rVar) const @@ -1448,14 +1448,14 @@ void WpADOView::put_Command(OLEVariant& _rVar) OUString WpADOGroup::get_Name() const { OLEString aBSTR; - pInterface->get_Name(&aBSTR); - return aBSTR; + pInterface->get_Name(aBSTR.getAddress()); + return aBSTR.asOUString(); } void WpADOGroup::put_Name(const OUString& _rName) { OLEString bstr(_rName); - sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr.asBSTR())); (void)bErg; } @@ -1493,14 +1493,14 @@ WpADOUsers WpADOGroup::get_Users( ) OUString WpADOUser::get_Name() const { OLEString aBSTR; - pInterface->get_Name(&aBSTR); - return aBSTR; + pInterface->get_Name(aBSTR.getAddress()); + return aBSTR.asOUString(); } void WpADOUser::put_Name(const OUString& _rName) { OLEString bstr(_rName); - sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr.asBSTR())); (void)bErg; } @@ -1508,7 +1508,7 @@ sal_Bool WpADOUser::ChangePassword(const OUString& _rPwd,const OUString& _rNewPw { OLEString sStr1(_rPwd); OLEString sStr2(_rNewPwd); - sal_Bool bErg = SUCCEEDED(pInterface->ChangePassword(sStr1,sStr2)); + sal_Bool bErg = SUCCEEDED(pInterface->ChangePassword(sStr1.asBSTR(),sStr2.asBSTR())); return bErg; } diff --git a/connectivity/source/inc/ado/Aolevariant.hxx b/connectivity/source/inc/ado/Aolevariant.hxx index 0ef9dda81bc1..e300128a8567 100644 --- a/connectivity/source/inc/ado/Aolevariant.hxx +++ b/connectivity/source/inc/ado/Aolevariant.hxx @@ -64,9 +64,9 @@ namespace connectivity OLEString& operator=(const OUString& _rSrc); OLEString& operator=(const BSTR& _rSrc); OLEString& operator=(const OLEString& _rSrc); - operator OUString() const; - operator BSTR() const; - BSTR* operator &(); + OUString asOUString() const; + BSTR asBSTR() const; + BSTR* getAddress(); sal_Int32 length() const; }; -- cgit