diff options
author | Jacek Fraczek <fraczek.jacek@gmail.com> | 2016-10-05 22:00:51 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-10-10 08:48:30 +0000 |
commit | f004aa99514d385f3ee254bba735f5eaeb7d9ad8 (patch) | |
tree | aacd5792f553b8e9cbf029cc7e0797ed0dd423fe /basic/source/sbx | |
parent | 728c7327bd97602a38723553ed044ea4c01d13b2 (diff) |
tdf#89307: Removed SvRef::operator T*()
Conditional statements are using SvRef::Is() method.
Changed static_cast<T*>(svRef<T>) occurances to svRef.get().
Added operator == and != to SvRef.
SbxObject::Execute is using SbxVariableRef internally.
SbxObject::FindQualified is using SbxVariableRef internally.
Change-Id: I45b553e35d8fca9bf71163e6eefc60802a066395
Reviewed-on: https://gerrit.libreoffice.org/29621
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'basic/source/sbx')
-rw-r--r-- | basic/source/sbx/sbxarray.cxx | 22 | ||||
-rw-r--r-- | basic/source/sbx/sbxexec.cxx | 24 | ||||
-rw-r--r-- | basic/source/sbx/sbxobj.cxx | 61 | ||||
-rw-r--r-- | basic/source/sbx/sbxvar.cxx | 8 |
4 files changed, 59 insertions, 56 deletions
diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx index 8748d2d0f861..e96ac1aa0737 100644 --- a/basic/source/sbx/sbxarray.cxx +++ b/basic/source/sbx/sbxarray.cxx @@ -61,7 +61,7 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray ) for( const auto& rpSrcRef : rArray.mVarEntries ) { SbxVariableRef pSrc_ = rpSrcRef.mpVar; - if( !pSrc_ ) + if( !pSrc_.Is() ) continue; if( eType != SbxVARIANT ) @@ -153,7 +153,7 @@ SbxVariable* SbxArray::Get32( sal_uInt32 nIdx ) if ( !rRef.Is() ) rRef = new SbxVariable( eType ); - return rRef; + return rRef.get(); } SbxVariable* SbxArray::Get( sal_uInt16 nIdx ) @@ -168,7 +168,7 @@ SbxVariable* SbxArray::Get( sal_uInt16 nIdx ) if ( !rRef.Is() ) rRef = new SbxVariable( eType ); - return rRef; + return rRef.get(); } void SbxArray::Put32( SbxVariable* pVar, sal_uInt32 nIdx ) @@ -183,7 +183,7 @@ void SbxArray::Put32( SbxVariable* pVar, sal_uInt32 nIdx ) if( eType != SbxOBJECT || pVar->GetClass() != SbxClassType::Object ) pVar->Convert( eType ); SbxVariableRef& rRef = GetRef32( nIdx ); - if( static_cast<SbxVariable*>(rRef) != pVar ) + if( rRef.get() != pVar ) { rRef = pVar; SetFlag( SbxFlagBits::Modified ); @@ -311,7 +311,7 @@ void SbxArray::Merge( SbxArray* p ) for (auto& rEntry1: p->mVarEntries) { - if (!rEntry1.mpVar) + if (!rEntry1.mpVar.Is()) continue; OUString aName = rEntry1.mpVar->GetName(); @@ -321,7 +321,7 @@ void SbxArray::Merge( SbxArray* p ) // Then overwrite! for (auto& rEntry2: mVarEntries) { - if (!rEntry2.mpVar) + if (!rEntry2.mpVar.Is()) continue; if (rEntry2.mpVar->GetHashCode() == nHash && @@ -334,7 +334,7 @@ void SbxArray::Merge( SbxArray* p ) } } - if (rEntry1.mpVar) + if (rEntry1.mpVar.Is()) { // We don't have element with the same name. Add a new entry. SbxVarEntry aNewEntry; @@ -354,7 +354,7 @@ SbxVariable* SbxArray::FindUserData( sal_uInt32 nData ) SbxVariable* p = nullptr; for (auto& rEntry : mVarEntries) { - if (!rEntry.mpVar) + if (!rEntry.mpVar.Is()) continue; if (rEntry.mpVar->IsVisible() && rEntry.mpVar->GetUserData() == nData) @@ -408,7 +408,7 @@ SbxVariable* SbxArray::Find( const OUString& rName, SbxClassType t ) sal_uInt16 nHash = SbxVariable::MakeHashCode( rName ); for (auto& rEntry : mVarEntries) { - if (!rEntry.mpVar || !rEntry.mpVar->IsVisible()) + if (!rEntry.mpVar.Is() || !rEntry.mpVar->IsVisible()) continue; // The very secure search works as well, if there is no hashcode! @@ -489,14 +489,14 @@ bool SbxArray::StoreData( SvStream& rStrm ) const // Which elements are even defined? for( auto& rEntry: mVarEntries ) { - if (rEntry.mpVar && !(rEntry.mpVar->GetFlags() & SbxFlagBits::DontStore)) + if (rEntry.mpVar.Is() && !(rEntry.mpVar->GetFlags() & SbxFlagBits::DontStore)) nElem++; } rStrm.WriteUInt16( nElem ); for( size_t n = 0; n < mVarEntries.size(); n++ ) { const SbxVarEntry& rEntry = mVarEntries[n]; - if (rEntry.mpVar && !(rEntry.mpVar->GetFlags() & SbxFlagBits::DontStore)) + if (rEntry.mpVar.Is() && !(rEntry.mpVar->GetFlags() & SbxFlagBits::DontStore)) { rStrm.WriteUInt16( n ); if (!rEntry.mpVar->Store(rStrm)) diff --git a/basic/source/sbx/sbxexec.cxx b/basic/source/sbx/sbxexec.cxx index 9507f47f84e3..47775b02a554 100644 --- a/basic/source/sbx/sbxexec.cxx +++ b/basic/source/sbx/sbxexec.cxx @@ -94,7 +94,7 @@ static SbxVariableRef QualifiedName { // It follows still an objectelement. The current element // had to be a SBX-Object or had to deliver such an object! - pObj = dynamic_cast<SbxObject*>( static_cast<SbxVariable*>(refVar) ); + pObj = dynamic_cast<SbxObject*>( refVar.get() ); if( !pObj ) // Then it had to deliver an object pObj = dynamic_cast<SbxObject*>( refVar->GetObject() ); @@ -183,7 +183,7 @@ static SbxVariableRef MulDiv( SbxObject* pObj, SbxObject* pGbl, const sal_Unicod if( refVar2.Is() ) { // temporary variable! - SbxVariable* pVar = refVar; + SbxVariable* pVar = refVar.get(); pVar = new SbxVariable( *pVar ); refVar = pVar; if( cOp == '*' ) @@ -213,7 +213,7 @@ static SbxVariableRef PlusMinus( SbxObject* pObj, SbxObject* pGbl, const sal_Uni if( refVar2.Is() ) { // temporaere Variable! - SbxVariable* pVar = refVar; + SbxVariable* pVar = refVar.get(); pVar = new SbxVariable( *pVar ); refVar = pVar; if( cOp == '+' ) @@ -252,8 +252,8 @@ static SbxVariableRef Assign( SbxObject* pObj, SbxObject* pGbl, const sal_Unicod SbxVariableRef refVar2( PlusMinus( pObj, pGbl, &p ) ); if( refVar2.Is() ) { - SbxVariable* pVar = refVar; - SbxVariable* pVar2 = refVar2; + SbxVariable* pVar = refVar.get(); + SbxVariable* pVar2 = refVar2.get(); *pVar = *pVar2; pVar->SetParameters( nullptr ); } @@ -303,7 +303,7 @@ static SbxVariableRef Element while( *p && *p != ')' && *p != ']' ) { SbxVariableRef refArg = PlusMinus( pGbl, pGbl, &p ); - if( !refArg ) + if( !refArg.Is() ) { // Error during the parsing refVar.Clear(); break; @@ -322,7 +322,7 @@ static SbxVariableRef Element if( *p == ')' ) p++; if( refVar.Is() ) - refVar->SetParameters( refPar ); + refVar->SetParameters( refPar.get() ); } } else @@ -336,7 +336,7 @@ static SbxVariableRef Element SbxVariable* SbxObject::Execute( const OUString& rTxt ) { - SbxVariable* pVar = nullptr; + SbxVariableRef pVar = nullptr; const sal_Unicode* p = rTxt.getStr(); for( ;; ) { @@ -350,7 +350,7 @@ SbxVariable* SbxObject::Execute( const OUString& rTxt ) SetError( ERRCODE_SBX_SYNTAX ); break; } pVar = Assign( this, this, &p ); - if( !pVar ) + if( !pVar.Is() ) { break; } @@ -360,12 +360,12 @@ SbxVariable* SbxObject::Execute( const OUString& rTxt ) SetError( ERRCODE_SBX_SYNTAX ); break; } } - return pVar; + return pVar.get(); } SbxVariable* SbxObject::FindQualified( const OUString& rName, SbxClassType t ) { - SbxVariable* pVar = nullptr; + SbxVariableRef pVar = nullptr; const sal_Unicode* p = rName.getStr(); p = SkipWhitespace( p ); if( !*p ) @@ -378,7 +378,7 @@ SbxVariable* SbxObject::FindQualified( const OUString& rName, SbxClassType t ) { SetError( ERRCODE_SBX_SYNTAX ); } - return pVar; + return pVar.get(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx index 5382b499cc18..e4e7e3827493 100644 --- a/basic/source/sbx/sbxobj.cxx +++ b/basic/source/sbx/sbxobj.cxx @@ -98,9 +98,9 @@ static void CheckParentsOnDelete( SbxObject* pObj, SbxArray* p ) SbxObject::~SbxObject() { - CheckParentsOnDelete( this, pProps ); - CheckParentsOnDelete( this, pMethods ); - CheckParentsOnDelete( this, pObjs ); + CheckParentsOnDelete( this, pProps.get() ); + CheckParentsOnDelete( this, pMethods.get() ); + CheckParentsOnDelete( this, pObjs.get() ); // avoid handling in ~SbxVariable as SbxFlagBits::DimAsNew == SbxFlagBits::GlobalSearch ResetFlag( SbxFlagBits::DimAsNew ); @@ -239,9 +239,9 @@ SbxVariable* SbxObject::Find( const OUString& rName, SbxClassType t ) switch( t ) { case SbxClassType::Variable: - case SbxClassType::Property: pArray = pProps; break; - case SbxClassType::Method: pArray = pMethods; break; - case SbxClassType::Object: pArray = pObjs; break; + case SbxClassType::Property: pArray = pProps.get(); break; + case SbxClassType::Method: pArray = pMethods.get(); break; + case SbxClassType::Object: pArray = pObjs.get(); break; default: SAL_WARN( "basic", "Invalid SBX-Class" ); break; } if( pArray ) @@ -332,13 +332,16 @@ void SbxObject::SetDfltProperty( const OUString& rName ) SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx ) { SbxArray* pArray = nullptr; - if( pVar ) switch( pVar->GetClass() ) + if( pVar ) { - case SbxClassType::Variable: - case SbxClassType::Property: pArray = pProps; break; - case SbxClassType::Method: pArray = pMethods; break; - case SbxClassType::Object: pArray = pObjs; break; - default: SAL_WARN( "basic", "Invalid SBX-Class" ); break; + switch( pVar->GetClass() ) + { + case SbxClassType::Variable: + case SbxClassType::Property: pArray = pProps.get(); break; + case SbxClassType::Method: pArray = pMethods.get(); break; + case SbxClassType::Object: pArray = pObjs.get(); break; + default: SAL_WARN( "basic", "Invalid SBX-Class" ); break; + } } if( pArray ) { @@ -351,7 +354,7 @@ SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx ) for( sal_uInt16 i = 0; i < pArray->Count(); i++ ) { SbxVariableRef& rRef = pArray->GetRef( i ); - if( static_cast<SbxVariable*>(rRef) == pOld ) + if( rRef.get() == pOld ) { nArrayIdx = i; break; } @@ -371,9 +374,9 @@ SbxVariable* SbxObject::Make( const OUString& rName, SbxClassType ct, SbxDataTyp switch( ct ) { case SbxClassType::Variable: - case SbxClassType::Property: pArray = pProps; break; - case SbxClassType::Method: pArray = pMethods; break; - case SbxClassType::Object: pArray = pObjs; break; + case SbxClassType::Property: pArray = pProps.get(); break; + case SbxClassType::Method: pArray = pMethods.get(); break; + case SbxClassType::Object: pArray = pObjs.get(); break; default: SAL_WARN( "basic", "Invalid SBX-Class" ); break; } if( !pArray ) @@ -425,7 +428,7 @@ void SbxObject::Insert( SbxVariable* pVar ) { // Then this element exists already // There are objects of the same name allowed at collections - if( pArray == pObjs && nullptr != dynamic_cast<const SbxCollection*>( this ) ) + if( pArray == pObjs.get() && nullptr != dynamic_cast<const SbxCollection*>( this ) ) { nIdx = pArray->Count(); } @@ -484,9 +487,9 @@ void SbxObject::QuickInsert( SbxVariable* pVar ) switch( pVar->GetClass() ) { case SbxClassType::Variable: - case SbxClassType::Property: pArray = pProps; break; - case SbxClassType::Method: pArray = pMethods; break; - case SbxClassType::Object: pArray = pObjs; break; + case SbxClassType::Property: pArray = pProps.get(); break; + case SbxClassType::Method: pArray = pMethods.get(); break; + case SbxClassType::Object: pArray = pObjs.get(); break; default: SAL_WARN( "basic", "Invalid SBX-Class" ); break; } } @@ -544,7 +547,7 @@ void SbxObject::Remove( SbxVariable* pVar ) { EndListening( pVar_->GetBroadcaster(), true ); } - if( static_cast<SbxVariable*>(pVar_) == pDfltProp ) + if( pVar_.get() == pDfltProp ) { pDfltProp = nullptr; } @@ -568,14 +571,14 @@ static bool LoadArray( SvStream& rStrm, SbxObject* pThis, SbxArray* pArray ) for( sal_uInt16 i = 0; i < p->Count(); i++ ) { SbxVariableRef& r = p->GetRef( i ); - SbxVariable* pVar = r; + SbxVariable* pVar = r.get(); if( pVar ) { pVar->SetParent( pThis ); pThis->StartListening( pVar->GetBroadcaster(), true ); } } - pArray->Merge( p ); + pArray->Merge( p.get() ); return true; } @@ -612,9 +615,9 @@ bool SbxObject::LoadData( SvStream& rStrm, sal_uInt16 nVer ) { rStrm.Seek( nPos ); } - if( !LoadArray( rStrm, this, pMethods ) || - !LoadArray( rStrm, this, pProps ) || - !LoadArray( rStrm, this, pObjs ) ) + if( !LoadArray( rStrm, this, pMethods.get() ) || + !LoadArray( rStrm, this, pProps.get() ) || + !LoadArray( rStrm, this, pObjs.get() ) ) { return false; } @@ -758,7 +761,7 @@ void SbxObject::Dump( SvStream& rStrm, bool bFill ) for( sal_uInt16 i = 0; i < pMethods->Count(); i++ ) { SbxVariableRef& r = pMethods->GetRef( i ); - SbxVariable* pVar = r; + SbxVariable* pVar = r.get(); if( pVar ) { OUString aLine = aIndent + " - " + pVar->GetName( SbxNAME_SHORT_TYPES ); @@ -795,7 +798,7 @@ void SbxObject::Dump( SvStream& rStrm, bool bFill ) for( sal_uInt16 i = 0; i < pProps->Count(); i++ ) { SbxVariableRef& r = pProps->GetRef( i ); - SbxVariable* pVar = r; + SbxVariable* pVar = r.get(); if( pVar ) { OUString aLine = aIndent + " - " + pVar->GetName( SbxNAME_SHORT_TYPES ); @@ -833,7 +836,7 @@ void SbxObject::Dump( SvStream& rStrm, bool bFill ) for( sal_uInt16 i = 0; i < pObjs->Count(); i++ ) { SbxVariableRef& r = pObjs->GetRef( i ); - SbxVariable* pVar = r; + SbxVariable* pVar = r.get(); if ( pVar ) { rStrm.WriteCharPtr( aIndentNameStr.getStr() ).WriteCharPtr( " - Sub" ); diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx index ff8c7e07fccc..27766dfc7fd4 100644 --- a/basic/source/sbx/sbxvar.cxx +++ b/basic/source/sbx/sbxvar.cxx @@ -148,7 +148,7 @@ SfxBroadcaster& SbxVariable::GetBroadcaster() SbxArray* SbxVariable::GetParameters() const { - return mpPar; + return mpPar.get(); } @@ -199,7 +199,7 @@ void SbxVariable::Broadcast( sal_uInt32 nHintId ) SbxInfo* SbxVariable::GetInfo() { - if( !pInfo ) + if( !pInfo.Is() ) { Broadcast( SBX_HINT_INFOWANTED ); if( pInfo.Is() ) @@ -207,7 +207,7 @@ SbxInfo* SbxVariable::GetInfo() SetModified( true ); } } - return pInfo; + return pInfo.get(); } void SbxVariable::SetInfo( SbxInfo* p ) @@ -239,7 +239,7 @@ const OUString& SbxVariable::GetName( SbxNameType t ) const // Request parameter-information (not for objects) const_cast<SbxVariable*>(this)->GetInfo(); // Append nothing, if it is a simple property (no empty brackets) - if (!pInfo || (pInfo->m_Params.empty() && GetClass() == SbxClassType::Property)) + if (!pInfo.Is() || (pInfo->m_Params.empty() && GetClass() == SbxClassType::Property)) { return maName; } |