summaryrefslogtreecommitdiff
path: root/basic/source/sbx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-18 14:35:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-19 08:30:49 +0200
commit8b0a69498b025e13d9772689e9e4fa3d6b05e609 (patch)
tree5fce654b3e02cd08d85dc95655c97d7181517687 /basic/source/sbx
parent5dccf84b14ed0e09262411295c5880f787342d59 (diff)
loplugin:flatten in basic
Change-Id: Icb8e3cda312b50c9a9f12f96bec1c746f41c8979 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92483 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic/source/sbx')
-rw-r--r--basic/source/sbx/sbxobj.cxx236
-rw-r--r--basic/source/sbx/sbxvar.cxx56
2 files changed, 146 insertions, 146 deletions
diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx
index 5c7185276ac7..fe42fa1939a1 100644
--- a/basic/source/sbx/sbxobj.cxx
+++ b/basic/source/sbx/sbxobj.cxx
@@ -138,38 +138,38 @@ void SbxObject::Clear()
void SbxObject::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
const SbxHint* p = dynamic_cast<const SbxHint*>(&rHint);
- if( p )
+ if( !p )
+ return;
+
+ const SfxHintId nId = p->GetId();
+ bool bRead = ( nId == SfxHintId::BasicDataWanted );
+ bool bWrite = ( nId == SfxHintId::BasicDataChanged );
+ SbxVariable* pVar = p->GetVar();
+ if( !(bRead || bWrite) )
+ return;
+
+ OUString aVarName( pVar->GetName() );
+ sal_uInt16 nHash_ = MakeHashCode( aVarName );
+ if( nHash_ == nNameHash && aVarName.equalsIgnoreAsciiCase( pNameProp ) )
{
- const SfxHintId nId = p->GetId();
- bool bRead = ( nId == SfxHintId::BasicDataWanted );
- bool bWrite = ( nId == SfxHintId::BasicDataChanged );
- SbxVariable* pVar = p->GetVar();
- if( bRead || bWrite )
+ if( bRead )
{
- OUString aVarName( pVar->GetName() );
- sal_uInt16 nHash_ = MakeHashCode( aVarName );
- if( nHash_ == nNameHash && aVarName.equalsIgnoreAsciiCase( pNameProp ) )
- {
- if( bRead )
- {
- pVar->PutString( GetName() );
- }
- else
- {
- SetName( pVar->GetOUString() );
- }
- }
- else if( nHash_ == nParentHash && aVarName.equalsIgnoreAsciiCase( pParentProp ) )
- {
- SbxObject* p_ = GetParent();
- if( !p_ )
- {
- p_ = this;
- }
- pVar->PutObject( p_ );
- }
+ pVar->PutString( GetName() );
+ }
+ else
+ {
+ SetName( pVar->GetOUString() );
}
}
+ else if( nHash_ == nParentHash && aVarName.equalsIgnoreAsciiCase( pParentProp ) )
+ {
+ SbxObject* p_ = GetParent();
+ if( !p_ )
+ {
+ p_ = this;
+ }
+ pVar->PutObject( p_ );
+ }
}
bool SbxObject::IsClass( const OUString& rName ) const
@@ -392,59 +392,59 @@ void SbxObject::Insert( SbxVariable* pVar )
{
sal_uInt32 nIdx;
SbxArray* pArray = FindVar( pVar, nIdx );
- if( pArray )
+ if( !pArray )
+ return;
+
+ // Into with it. But you should pay attention at the Pointer!
+ if( nIdx < pArray->Count32() )
{
- // Into with it. But you should pay attention at the Pointer!
- if( nIdx < pArray->Count32() )
+ // Then this element exists already
+ // There are objects of the same name allowed at collections
+ if( pArray == pObjs.get() && dynamic_cast<const SbxCollection*>( this ) != nullptr )
{
- // Then this element exists already
- // There are objects of the same name allowed at collections
- if( pArray == pObjs.get() && dynamic_cast<const SbxCollection*>( this ) != nullptr )
+ nIdx = pArray->Count32();
+ }
+ else
+ {
+ SbxVariable* pOld = pArray->Get32( nIdx );
+ // already inside: overwrite
+ if( pOld == pVar )
{
- nIdx = pArray->Count32();
+ return;
}
- else
+ EndListening( pOld->GetBroadcaster(), true );
+ if( pVar->GetClass() == SbxClassType::Property )
{
- SbxVariable* pOld = pArray->Get32( nIdx );
- // already inside: overwrite
- if( pOld == pVar )
+ if( pOld == pDfltProp )
{
- return;
- }
- EndListening( pOld->GetBroadcaster(), true );
- if( pVar->GetClass() == SbxClassType::Property )
- {
- if( pOld == pDfltProp )
- {
- pDfltProp = static_cast<SbxProperty*>(pVar);
- }
+ pDfltProp = static_cast<SbxProperty*>(pVar);
}
}
}
- StartListening(pVar->GetBroadcaster(), DuplicateHandling::Prevent);
- pArray->Put32( pVar, nIdx );
- if( pVar->GetParent() != this )
- {
- pVar->SetParent( this );
- }
- SetModified( true );
+ }
+ StartListening(pVar->GetBroadcaster(), DuplicateHandling::Prevent);
+ pArray->Put32( pVar, nIdx );
+ if( pVar->GetParent() != this )
+ {
+ pVar->SetParent( this );
+ }
+ SetModified( true );
#ifdef DBG_UTIL
- static const char* pCls[] =
- { "DontCare","Array","Value","Variable","Method","Property","Object" };
- OUString aVarName( pVar->GetName() );
- if (const SbxObject *pSbxObj = aVarName.isEmpty() ? dynamic_cast<const SbxObject*>(pVar) : nullptr)
- {
- aVarName = pSbxObj->GetClassName();
- }
- SAL_INFO(
- "basic.sbx",
- "insert "
- << ((pVar->GetClass() >= SbxClassType::DontCare
- && pVar->GetClass() <= SbxClassType::Object)
- ? pCls[static_cast<int>(pVar->GetClass()) - 1] : "Unknown class")
- << " " << aVarName << " in " << SbxVariable::GetName());
-#endif
+ static const char* pCls[] =
+ { "DontCare","Array","Value","Variable","Method","Property","Object" };
+ OUString aVarName( pVar->GetName() );
+ if (const SbxObject *pSbxObj = aVarName.isEmpty() ? dynamic_cast<const SbxObject*>(pVar) : nullptr)
+ {
+ aVarName = pSbxObj->GetClassName();
}
+ SAL_INFO(
+ "basic.sbx",
+ "insert "
+ << ((pVar->GetClass() >= SbxClassType::DontCare
+ && pVar->GetClass() <= SbxClassType::Object)
+ ? pCls[static_cast<int>(pVar->GetClass()) - 1] : "Unknown class")
+ << " " << aVarName << " in " << SbxVariable::GetName());
+#endif
}
// Optimisation, Insertion without checking about
@@ -463,32 +463,32 @@ void SbxObject::QuickInsert( SbxVariable* pVar )
default: SAL_WARN( "basic.sbx", "Invalid SBX-Class" ); break;
}
}
- if( pArray )
+ if( !pArray )
+ return;
+
+ StartListening(pVar->GetBroadcaster(), DuplicateHandling::Prevent);
+ pArray->Put32( pVar, pArray->Count32() );
+ if( pVar->GetParent() != this )
{
- StartListening(pVar->GetBroadcaster(), DuplicateHandling::Prevent);
- pArray->Put32( pVar, pArray->Count32() );
- if( pVar->GetParent() != this )
- {
- pVar->SetParent( this );
- }
- SetModified( true );
+ pVar->SetParent( this );
+ }
+ SetModified( true );
#ifdef DBG_UTIL
- static const char* pCls[] =
- { "DontCare","Array","Value","Variable","Method","Property","Object" };
- OUString aVarName( pVar->GetName() );
- if (const SbxObject *pSbxObj = aVarName.isEmpty() ? dynamic_cast<const SbxObject*>(pVar) : nullptr)
- {
- aVarName = pSbxObj->GetClassName();
- }
- SAL_INFO(
- "basic.sbx",
- "insert "
- << ((pVar->GetClass() >= SbxClassType::DontCare
- && pVar->GetClass() <= SbxClassType::Object)
- ? pCls[static_cast<int>(pVar->GetClass()) - 1] : "Unknown class")
- << " " << aVarName << " in " << SbxVariable::GetName());
-#endif
+ static const char* pCls[] =
+ { "DontCare","Array","Value","Variable","Method","Property","Object" };
+ OUString aVarName( pVar->GetName() );
+ if (const SbxObject *pSbxObj = aVarName.isEmpty() ? dynamic_cast<const SbxObject*>(pVar) : nullptr)
+ {
+ aVarName = pSbxObj->GetClassName();
}
+ SAL_INFO(
+ "basic.sbx",
+ "insert "
+ << ((pVar->GetClass() >= SbxClassType::DontCare
+ && pVar->GetClass() <= SbxClassType::Object)
+ ? pCls[static_cast<int>(pVar->GetClass()) - 1] : "Unknown class")
+ << " " << aVarName << " in " << SbxVariable::GetName());
+#endif
}
void SbxObject::Remove( const OUString& rName, SbxClassType t )
@@ -500,34 +500,34 @@ void SbxObject::Remove( SbxVariable* pVar )
{
sal_uInt32 nIdx;
SbxArray* pArray = FindVar( pVar, nIdx );
- if( pArray && nIdx < pArray->Count32() )
- {
+ if( !(pArray && nIdx < pArray->Count32()) )
+ return;
+
#ifdef DBG_UTIL
- OUString aVarName( pVar->GetName() );
- if (const SbxObject *pSbxObj = aVarName.isEmpty() ? dynamic_cast<const SbxObject*>(pVar) : nullptr)
- {
- aVarName = pSbxObj->GetClassName();
- }
- SAL_INFO(
- "basic.sbx",
- "remove " << aVarName << " in " << SbxVariable::GetName());
+ OUString aVarName( pVar->GetName() );
+ if (const SbxObject *pSbxObj = aVarName.isEmpty() ? dynamic_cast<const SbxObject*>(pVar) : nullptr)
+ {
+ aVarName = pSbxObj->GetClassName();
+ }
+ SAL_INFO(
+ "basic.sbx",
+ "remove " << aVarName << " in " << SbxVariable::GetName());
#endif
- SbxVariableRef pVar_ = pArray->Get32( nIdx );
- if( pVar_->IsBroadcaster() )
- {
- EndListening( pVar_->GetBroadcaster(), true );
- }
- if( pVar_.get() == pDfltProp )
- {
- pDfltProp = nullptr;
- }
- pArray->Remove( nIdx );
- if( pVar_->GetParent() == this )
- {
- pVar_->SetParent( nullptr );
- }
- SetModified( true );
+ SbxVariableRef pVar_ = pArray->Get32( nIdx );
+ if( pVar_->IsBroadcaster() )
+ {
+ EndListening( pVar_->GetBroadcaster(), true );
+ }
+ if( pVar_.get() == pDfltProp )
+ {
+ pDfltProp = nullptr;
}
+ pArray->Remove( nIdx );
+ if( pVar_->GetParent() == this )
+ {
+ pVar_->SetParent( nullptr );
+ }
+ SetModified( true );
}
static bool LoadArray( SvStream& rStrm, SbxObject* pThis, SbxArray* pArray )
diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx
index d8425d59aaa6..5f892417825b 100644
--- a/basic/source/sbx/sbxvar.cxx
+++ b/basic/source/sbx/sbxvar.cxx
@@ -146,42 +146,42 @@ SbxArray* SbxVariable::GetParameters() const
void SbxVariable::Broadcast( SfxHintId nHintId )
{
- if( mpBroadcaster && !IsSet( SbxFlagBits::NoBroadcast ) )
+ if( !(mpBroadcaster && !IsSet( SbxFlagBits::NoBroadcast )) )
+ return;
+
+ // Because the method could be called from outside, check the
+ // rights here again
+ if( nHintId == SfxHintId::BasicDataWanted )
{
- // Because the method could be called from outside, check the
- // rights here again
- if( nHintId == SfxHintId::BasicDataWanted )
+ if( !CanRead() )
{
- if( !CanRead() )
- {
- return;
- }
+ return;
}
- if( nHintId == SfxHintId::BasicDataChanged )
+ }
+ if( nHintId == SfxHintId::BasicDataChanged )
+ {
+ if( !CanWrite() )
{
- if( !CanWrite() )
- {
- return;
- }
+ return;
}
+ }
- //fdo#86843 Add a ref during the following block to guard against
- //getting deleted before completing this method
- SbxVariableRef aBroadcastGuard(this);
+ //fdo#86843 Add a ref during the following block to guard against
+ //getting deleted before completing this method
+ SbxVariableRef aBroadcastGuard(this);
- // Avoid further broadcasting
- std::unique_ptr<SfxBroadcaster> pSave = std::move(mpBroadcaster);
- SbxFlagBits nSaveFlags = GetFlags();
- SetFlag( SbxFlagBits::ReadWrite );
- if( mpPar.is() )
- {
- // Register this as element 0, but don't change over the parent!
- mpPar->GetRef32( 0 ) = this;
- }
- pSave->Broadcast( SbxHint( nHintId, this ) );
- mpBroadcaster = std::move(pSave);
- SetFlags( nSaveFlags );
+ // Avoid further broadcasting
+ std::unique_ptr<SfxBroadcaster> pSave = std::move(mpBroadcaster);
+ SbxFlagBits nSaveFlags = GetFlags();
+ SetFlag( SbxFlagBits::ReadWrite );
+ if( mpPar.is() )
+ {
+ // Register this as element 0, but don't change over the parent!
+ mpPar->GetRef32( 0 ) = this;
}
+ pSave->Broadcast( SbxHint( nHintId, this ) );
+ mpBroadcaster = std::move(pSave);
+ SetFlags( nSaveFlags );
}
SbxInfo* SbxVariable::GetInfo()