SbxObject& SbxObject::operator=( const SbxObject& r )
{ if( &r != this )
{
SbxVariable::operator=( r );
aClassName = r.aClassName;
pMethods = new SbxArray;
pProps = new SbxArray;
pObjs = new SbxArray( SbxOBJECT ); // The arrays were copied, the content taken over
*pMethods = *r.pMethods;
*pProps = *r.pProps;
*pObjs = *r.pObjs; // Because the variables were taken over, this is OK
pDfltProp = r.pDfltProp;
SetName( r.GetName() );
SetFlags( r.GetFlags() );
SetModified( true );
} return *this;
}
staticvoid CheckParentsOnDelete( SbxObject* pObj, SbxArray* p )
{ for (sal_uInt32 i = 0; i < p->Count(); i++)
{
SbxVariableRef& rRef = p->GetRef(i); if( rRef->IsBroadcaster() )
{
pObj->EndListening( rRef->GetBroadcaster(), true );
} // does the element have more than one reference and still a Listener? if( rRef->GetRefCount() > 1 )
{
rRef->SetParent( nullptr );
SAL_INFO_IF(rRef->IsBroadcaster() && rRef->GetBroadcaster().GetListenerCount(), "basic.sbx", "Object element with dangling parent");
}
}
}
SbxVariable* pRes = nullptr;
pObjs->SetFlag( SbxFlagBits::ExtSearch ); if( t == SbxClassType::DontCare )
{
pRes = pMethods->Find( rName, SbxClassType::Method ); if( !pRes )
{
pRes = pProps->Find( rName, SbxClassType::Property );
} if( !pRes )
{
pRes = pObjs->Find( rName, t );
}
} else
{
SbxArray* pArray = nullptr; switch( t )
{ 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.sbx", "Invalid SBX-Class" ); break;
} if( pArray )
{
pRes = pArray->Find( rName, t );
}
} // Extended Search in the Object-Array? // For objects and DontCare the array of objects has already been searched if( !pRes && ( t == SbxClassType::Method || t == SbxClassType::Property ) )
pRes = pObjs->Find( rName, t ); // Search in the parents? if( !pRes && IsSet( SbxFlagBits::GlobalSearch ) )
{
SbxObject* pCur = this; while( !pRes && pCur->pParent )
{ // I myself was already searched!
SbxFlagBits nOwn = pCur->GetFlags();
pCur->ResetFlag( SbxFlagBits::ExtSearch ); // I search already global!
SbxFlagBits nPar = pCur->pParent->GetFlags();
pCur->pParent->ResetFlag( SbxFlagBits::GlobalSearch );
pRes = pCur->pParent->Find( rName, t );
pCur->SetFlags( nOwn );
pCur->pParent->SetFlags( nPar );
pCur = pCur->pParent;
}
} #ifdef DBG_UTIL
--nLvl;
SAL_INFO_IF(
pRes, "basic.sbx", "found" << std::setw(nLvl) << " " << rName << " in "
<< SbxVariable::GetName()); #endif return pRes;
}
// Abbreviated version: The parent-string will be searched // The whole thing recursive, because Call() might be overridden // Qualified names are allowed
bool SbxObject::Call( const OUString& rName, SbxArray* pParam )
{
SbxVariable* pMeth = FindQualified( rName, SbxClassType::DontCare); if( dynamic_cast<const SbxMethod*>( pMeth) )
{ // tdf#149622 - clear return value of the method before calling it
pMeth->Clear();
// Search of an already available variable. If it was located, // the index will be set, otherwise the Count of the Array will be returned. // In any case the correct Array will be returned.
SbxArray* SbxObject::FindVar( SbxVariable const * pVar, sal_uInt32& nArrayIdx )
{
SbxArray* pArray = nullptr; if( pVar )
{ 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.sbx", "Invalid SBX-Class" ); break;
}
} if( pArray )
{
nArrayIdx = pArray->Count(); // Is the variable per name available?
pArray->ResetFlag( SbxFlagBits::ExtSearch );
SbxVariable* pOld = pArray->Find( pVar->GetName(), pVar->GetClass() ); if( pOld )
{ for (sal_uInt32 i = 0; i < pArray->Count(); i++)
{
SbxVariableRef& rRef = pArray->GetRef(i); if( rRef.get() == pOld )
{
nArrayIdx = i; break;
}
}
}
} return pArray;
}
// If a new object will be established, this object will be indexed, // if an object of this name exists already.
SbxVariable* SbxObject::Make( const OUString& rName, SbxClassType ct, SbxDataType dt, bool bIsRuntimeFunction )
{ // Is the object already available?
SbxArray* pArray = nullptr; switch( ct )
{ 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.sbx", "Invalid SBX-Class" ); break;
} if( !pArray )
{ return nullptr;
} // Collections may contain objects of the same name if( ct != SbxClassType::Object || dynamic_cast<const SbxCollection*>( this ) == nullptr )
{
SbxVariable* pRes = pArray->Find( rName, ct ); if( pRes )
{ return pRes;
}
}
SbxVariableRef pVar; switch( ct )
{ case SbxClassType::Variable: case SbxClassType::Property:
pVar = new SbxProperty( rName, dt ); break; case SbxClassType::Method:
pVar = new SbxMethod( rName, dt, bIsRuntimeFunction ); break; case SbxClassType::Object:
pVar = CreateObject( rName ).get(); break; default: break;
}
pVar->SetParent( this );
pArray->Put(pVar.get(), pArray->Count());
SetModified( true ); // The object listen always
StartListening(pVar->GetBroadcaster(), DuplicateHandling::Prevent); return pVar.get();
}
void SbxMethod::Clear()
{ // Release referenced data, and reset data type to the function return type // Implementation similar to SbxValue::SetType // tdf#143582: Don't take "read-only" flag into account, allow clearing method return value switch (aData.eType)
{ case SbxSTRING: delete aData.pOUString; break; case SbxOBJECT: if (aData.pObj)
{ if (aData.pObj != this)
{ bool bParentProp = (GetUserData() & 0xFFFF) == 5345; // See sbxvalue.cxx if (!bParentProp)
aData.pObj->ReleaseRef();
}
} break; case SbxDECIMAL:
releaseDecimalPtr(aData.pDecimal); break; default: break;
}
aData.clear(IsFixed() ? aData.eType : SbxEMPTY);
}
SbxProperty::SbxProperty( const OUString& r, SbxDataType t )
: SbxVariable( t )
{
SetName( r );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.