diff options
Diffstat (limited to 'basic/source/sbx/sbxobj.cxx')
-rwxr-xr-x[-rw-r--r--] | basic/source/sbx/sbxobj.cxx | 179 |
1 files changed, 91 insertions, 88 deletions
diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx index 45f2d46ed254..a6d089602ba4 100644..100755 --- a/basic/source/sbx/sbxobj.cxx +++ b/basic/source/sbx/sbxobj.cxx @@ -41,7 +41,7 @@ TYPEINIT2(SbxObject,SbxVariable,SfxListener) static const char* pNameProp; // Name-Property static const char* pParentProp; // Parent-Property -static USHORT nNameHash = 0, nParentHash = 0; +static sal_uInt16 nNameHash = 0, nParentHash = 0; ///////////////////////////////////////////////////////////////////////// @@ -86,18 +86,18 @@ SbxObject& SbxObject::operator=( const SbxObject& r ) pDfltProp = r.pDfltProp; SetName( r.GetName() ); SetFlags( r.GetFlags() ); - SetModified( TRUE ); + SetModified( sal_True ); } return *this; } static void CheckParentsOnDelete( SbxObject* pObj, SbxArray* p ) { - for( USHORT i = 0; i < p->Count(); i++ ) + for( sal_uInt16 i = 0; i < p->Count(); i++ ) { SbxVariableRef& rRef = p->GetRef( i ); if( rRef->IsBroadcaster() ) - pObj->EndListening( rRef->GetBroadcaster(), TRUE ); + pObj->EndListening( rRef->GetBroadcaster(), sal_True ); // Did the element have more then one reference and still a Listener? if( rRef->GetRefCount() > 1 ) { @@ -112,6 +112,9 @@ SbxObject::~SbxObject() CheckParentsOnDelete( this, pProps ); CheckParentsOnDelete( this, pMethods ); CheckParentsOnDelete( this, pObjs ); + + // avoid handling in ~SbxVariable as SBX_DIM_AS_NEW == SBX_GBLSEARCH + ResetFlag( SBX_DIM_AS_NEW ); } SbxDataType SbxObject::GetType() const @@ -136,7 +139,7 @@ void SbxObject::Clear() p->ResetFlag( SBX_WRITE ); p->SetFlag( SBX_DONTSTORE ); pDfltProp = NULL; - SetModified( FALSE ); + SetModified( sal_False ); } void SbxObject::SFX_NOTIFY( SfxBroadcaster&, const TypeId&, @@ -145,14 +148,14 @@ void SbxObject::SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SbxHint* p = PTR_CAST(SbxHint,&rHint); if( p ) { - ULONG nId = p->GetId(); - BOOL bRead = BOOL( nId == SBX_HINT_DATAWANTED ); - BOOL bWrite = BOOL( nId == SBX_HINT_DATACHANGED ); + sal_uIntPtr nId = p->GetId(); + sal_Bool bRead = sal_Bool( nId == SBX_HINT_DATAWANTED ); + sal_Bool bWrite = sal_Bool( nId == SBX_HINT_DATACHANGED ); SbxVariable* pVar = p->GetVar(); if( bRead || bWrite ) { XubString aVarName( pVar->GetName() ); - USHORT nHash_ = MakeHashCode( aVarName ); + sal_uInt16 nHash_ = MakeHashCode( aVarName ); if( nHash_ == nNameHash && aVarName.EqualsIgnoreCaseAscii( pNameProp ) ) { @@ -173,12 +176,12 @@ void SbxObject::SFX_NOTIFY( SfxBroadcaster&, const TypeId&, } } -BOOL SbxObject::IsClass( const XubString& rName ) const +sal_Bool SbxObject::IsClass( const XubString& rName ) const { - return BOOL( aClassName.EqualsIgnoreCaseAscii( rName ) ); + return sal_Bool( aClassName.EqualsIgnoreCaseAscii( rName ) ); } -SbxVariable* SbxObject::FindUserData( UINT32 nData ) +SbxVariable* SbxObject::FindUserData( sal_uInt32 nData ) { if( !GetAll( SbxCLASS_DONTCARE ) ) return NULL; @@ -195,10 +198,10 @@ SbxVariable* SbxObject::FindUserData( UINT32 nData ) while( !pRes && pCur->pParent ) { // I myself was already searched through! - USHORT nOwn = pCur->GetFlags(); + sal_uInt16 nOwn = pCur->GetFlags(); pCur->ResetFlag( SBX_EXTSEARCH ); // I search already global! - USHORT nPar = pCur->pParent->GetFlags(); + sal_uInt16 nPar = pCur->pParent->GetFlags(); pCur->pParent->ResetFlag( SBX_GBLSEARCH ); pRes = pCur->pParent->FindUserData( nData ); pCur->SetFlags( nOwn ); @@ -212,7 +215,7 @@ SbxVariable* SbxObject::FindUserData( UINT32 nData ) SbxVariable* SbxObject::Find( const XubString& rName, SbxClassType t ) { #ifdef DBG_UTIL - static USHORT nLvl = 0; + static sal_uInt16 nLvl = 0; static const char* pCls[] = { "DontCare","Array","Value","Variable","Method","Property","Object" }; ByteString aNameStr1( (const UniString&)rName, RTL_TEXTENCODING_ASCII_US ); @@ -262,10 +265,10 @@ SbxVariable* SbxObject::Find( const XubString& rName, SbxClassType t ) while( !pRes && pCur->pParent ) { // I myself was already searched through! - USHORT nOwn = pCur->GetFlags(); + sal_uInt16 nOwn = pCur->GetFlags(); pCur->ResetFlag( SBX_EXTSEARCH ); // I search already global! - USHORT nPar = pCur->pParent->GetFlags(); + sal_uInt16 nPar = pCur->pParent->GetFlags(); pCur->pParent->ResetFlag( SBX_GBLSEARCH ); pRes = pCur->pParent->Find( rName, t ); pCur->SetFlags( nOwn ); @@ -290,7 +293,7 @@ SbxVariable* SbxObject::Find( const XubString& rName, SbxClassType t ) // The whole thing recursive, because Call() might be overloaded // Qualified names are allowed -BOOL SbxObject::Call( const XubString& rName, SbxArray* pParam ) +sal_Bool SbxObject::Call( const XubString& rName, SbxArray* pParam ) { SbxVariable* pMeth = FindQualified( rName, SbxCLASS_DONTCARE); if( pMeth && pMeth->ISA(SbxMethod) ) @@ -300,10 +303,10 @@ BOOL SbxObject::Call( const XubString& rName, SbxArray* pParam ) pMeth->SetParameters( pParam ); pMeth->Broadcast( SBX_HINT_DATAWANTED ); pMeth->SetParameters( NULL ); - return TRUE; + return sal_True; } SetError( SbxERR_NO_METHOD ); - return FALSE; + return sal_False; } SbxProperty* SbxObject::GetDfltProperty() @@ -321,14 +324,14 @@ void SbxObject::SetDfltProperty( const XubString& rName ) if ( rName != aDfltPropName ) pDfltProp = NULL; aDfltPropName = rName; - SetModified( TRUE ); + SetModified( sal_True ); } void SbxObject::SetDfltProperty( SbxProperty* p ) { if( p ) { - USHORT n; + sal_uInt16 n; SbxArray* pArray = FindVar( p, n ); pArray->Put( p, n ); if( p->GetParent() != this ) @@ -336,14 +339,14 @@ void SbxObject::SetDfltProperty( SbxProperty* p ) Broadcast( SBX_HINT_OBJECTCHANGED ); } pDfltProp = p; - SetModified( TRUE ); + SetModified( sal_True ); } // Search of a already available variable. If she was located, // the index will be set, elsewise will be delivered the Count of the Array. // In any case it will be delivered the correct Array. -SbxArray* SbxObject::FindVar( SbxVariable* pVar, USHORT& nArrayIdx ) +SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx ) { SbxArray* pArray = NULL; if( pVar ) switch( pVar->GetClass() ) @@ -362,7 +365,7 @@ SbxArray* SbxObject::FindVar( SbxVariable* pVar, USHORT& nArrayIdx ) pArray->ResetFlag( SBX_EXTSEARCH ); SbxVariable* pOld = pArray->Find( pVar->GetName(), pVar->GetClass() ); if( pOld ) - for( USHORT i = 0; i < pArray->Count(); i++ ) + for( sal_uInt16 i = 0; i < pArray->Count(); i++ ) { SbxVariableRef& rRef = pArray->GetRef( i ); if( (SbxVariable*) rRef == pOld ) @@ -432,9 +435,9 @@ SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataTy } pVar->SetParent( this ); pArray->Put( pVar, pArray->Count() ); - SetModified( TRUE ); + SetModified( sal_True ); // The object listen always - StartListening( pVar->GetBroadcaster(), TRUE ); + StartListening( pVar->GetBroadcaster(), sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); return pVar; } @@ -470,9 +473,9 @@ SbxObject* SbxObject::MakeObject( const XubString& rName, const XubString& rClas pVar->SetName( rName ); pVar->SetParent( this ); pObjs->Put( pVar, pObjs->Count() ); - SetModified( TRUE ); + SetModified( sal_True ); // The object listen always - StartListening( pVar->GetBroadcaster(), TRUE ); + StartListening( pVar->GetBroadcaster(), sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); } return pVar; @@ -480,7 +483,7 @@ SbxObject* SbxObject::MakeObject( const XubString& rName, const XubString& rClas void SbxObject::Insert( SbxVariable* pVar ) { - USHORT nIdx; + sal_uInt16 nIdx; SbxArray* pArray = FindVar( pVar, nIdx ); if( pArray ) { @@ -512,7 +515,7 @@ void SbxObject::Insert( SbxVariable* pVar ) } #endif */ - EndListening( pOld->GetBroadcaster(), TRUE ); + EndListening( pOld->GetBroadcaster(), sal_True ); if( pVar->GetClass() == SbxCLASS_PROPERTY ) { if( pOld == pDfltProp ) @@ -520,11 +523,11 @@ void SbxObject::Insert( SbxVariable* pVar ) } } } - StartListening( pVar->GetBroadcaster(), TRUE ); + StartListening( pVar->GetBroadcaster(), sal_True ); pArray->Put( pVar, nIdx ); if( pVar->GetParent() != this ) pVar->SetParent( this ); - SetModified( TRUE ); + SetModified( sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); #ifdef DBG_UTIL static const char* pCls[] = @@ -561,11 +564,11 @@ void SbxObject::QuickInsert( SbxVariable* pVar ) } if( pArray ) { - StartListening( pVar->GetBroadcaster(), TRUE ); + StartListening( pVar->GetBroadcaster(), sal_True ); pArray->Put( pVar, pArray->Count() ); if( pVar->GetParent() != this ) pVar->SetParent( this ); - SetModified( TRUE ); + SetModified( sal_True ); #ifdef DBG_UTIL static const char* pCls[] = { "DontCare","Array","Value","Variable","Method","Property","Object" }; @@ -600,11 +603,11 @@ void SbxObject::VCPtrInsert( SbxVariable* pVar ) } if( pArray ) { - StartListening( pVar->GetBroadcaster(), TRUE ); + StartListening( pVar->GetBroadcaster(), sal_True ); pArray->Put( pVar, pArray->Count() ); if( pVar->GetParent() != this ) pVar->SetParent( this ); - SetModified( TRUE ); + SetModified( sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); } } @@ -616,7 +619,7 @@ void SbxObject::Remove( const XubString& rName, SbxClassType t ) void SbxObject::Remove( SbxVariable* pVar ) { - USHORT nIdx; + sal_uInt16 nIdx; SbxArray* pArray = FindVar( pVar, nIdx ); if( pArray && nIdx < pArray->Count() ) { @@ -629,13 +632,13 @@ void SbxObject::Remove( SbxVariable* pVar ) #endif SbxVariableRef pVar_ = pArray->Get( nIdx ); if( pVar_->IsBroadcaster() ) - EndListening( pVar_->GetBroadcaster(), TRUE ); + EndListening( pVar_->GetBroadcaster(), sal_True ); if( (SbxVariable*) pVar_ == pDfltProp ) pDfltProp = NULL; pArray->Remove( nIdx ); if( pVar_->GetParent() == this ) pVar_->SetParent( NULL ); - SetModified( TRUE ); + SetModified( sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); } } @@ -643,26 +646,26 @@ void SbxObject::Remove( SbxVariable* pVar ) // From 1997-03-23, cleanup per Pointer for Controls (double names!) void SbxObject::VCPtrRemove( SbxVariable* pVar ) { - USHORT nIdx; + sal_uInt16 nIdx; // New FindVar-Method, otherwise identical with the normal method SbxArray* pArray = VCPtrFindVar( pVar, nIdx ); if( pArray && nIdx < pArray->Count() ) { SbxVariableRef xVar = pArray->Get( nIdx ); if( xVar->IsBroadcaster() ) - EndListening( xVar->GetBroadcaster(), TRUE ); + EndListening( xVar->GetBroadcaster(), sal_True ); if( (SbxVariable*) xVar == pDfltProp ) pDfltProp = NULL; pArray->Remove( nIdx ); if( xVar->GetParent() == this ) xVar->SetParent( NULL ); - SetModified( TRUE ); + SetModified( sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); } } // From 1997-03-23, associated special method, search only by Pointer -SbxArray* SbxObject::VCPtrFindVar( SbxVariable* pVar, USHORT& nArrayIdx ) +SbxArray* SbxObject::VCPtrFindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx ) { SbxArray* pArray = NULL; if( pVar ) switch( pVar->GetClass() ) @@ -677,7 +680,7 @@ SbxArray* SbxObject::VCPtrFindVar( SbxVariable* pVar, USHORT& nArrayIdx ) if( pArray ) { nArrayIdx = pArray->Count(); - for( USHORT i = 0; i < pArray->Count(); i++ ) + for( sal_uInt16 i = 0; i < pArray->Count(); i++ ) { SbxVariableRef& rRef = pArray->GetRef( i ); if( (SbxVariable*) rRef == pVar ) @@ -691,9 +694,9 @@ SbxArray* SbxObject::VCPtrFindVar( SbxVariable* pVar, USHORT& nArrayIdx ) -void SbxObject::SetPos( SbxVariable* pVar, USHORT nPos ) +void SbxObject::SetPos( SbxVariable* pVar, sal_uInt16 nPos ) { - USHORT nIdx; + sal_uInt16 nIdx; SbxArray* pArray = FindVar( pVar, nIdx ); if( pArray ) { @@ -706,41 +709,41 @@ void SbxObject::SetPos( SbxVariable* pVar, USHORT nPos ) pArray->Insert( refVar, nPos ); } } -// SetModified( TRUE ); +// SetModified( sal_True ); // Broadcast( SBX_HINT_OBJECTCHANGED ); } -static BOOL LoadArray( SvStream& rStrm, SbxObject* pThis, SbxArray* pArray ) +static sal_Bool LoadArray( SvStream& rStrm, SbxObject* pThis, SbxArray* pArray ) { SbxArrayRef p = (SbxArray*) SbxBase::Load( rStrm ); if( !p.Is() ) - return FALSE; - for( USHORT i = 0; i < p->Count(); i++ ) + return sal_False; + for( sal_uInt16 i = 0; i < p->Count(); i++ ) { SbxVariableRef& r = p->GetRef( i ); SbxVariable* pVar = r; if( pVar ) { pVar->SetParent( pThis ); - pThis->StartListening( pVar->GetBroadcaster(), TRUE ); + pThis->StartListening( pVar->GetBroadcaster(), sal_True ); } } pArray->Merge( p ); - return TRUE; + return sal_True; } // The load of an object is additive! -BOOL SbxObject::LoadData( SvStream& rStrm, USHORT nVer ) +sal_Bool SbxObject::LoadData( SvStream& rStrm, sal_uInt16 nVer ) { // Help for the read in of old objects: just TRUE back, // LoadPrivateData() had to set the default status up if( !nVer ) - return TRUE; + return sal_True; pDfltProp = NULL; if( !SbxVariable::LoadData( rStrm, nVer ) ) - return FALSE; + return sal_False; // If it contains no alien object, insert ourselves if( aData.eType == SbxOBJECT && !aData.pObj ) aData.pObj = this; @@ -748,11 +751,11 @@ BOOL SbxObject::LoadData( SvStream& rStrm, USHORT nVer ) XubString aDfltProp; rStrm.ReadByteString( aClassName, RTL_TEXTENCODING_ASCII_US ); rStrm.ReadByteString( aDfltProp, RTL_TEXTENCODING_ASCII_US ); - ULONG nPos = rStrm.Tell(); + sal_uIntPtr nPos = rStrm.Tell(); rStrm >> nSize; if( !LoadPrivateData( rStrm, nVer ) ) - return FALSE; - ULONG nNewPos = rStrm.Tell(); + return sal_False; + sal_uIntPtr nNewPos = rStrm.Tell(); nPos += nSize; DBG_ASSERT( nPos >= nNewPos, "SBX: Zu viele Daten eingelesen" ); if( nPos != nNewPos ) @@ -760,39 +763,39 @@ BOOL SbxObject::LoadData( SvStream& rStrm, USHORT nVer ) if( !LoadArray( rStrm, this, pMethods ) || !LoadArray( rStrm, this, pProps ) || !LoadArray( rStrm, this, pObjs ) ) - return FALSE; + return sal_False; // Set properties if( aDfltProp.Len() ) pDfltProp = (SbxProperty*) pProps->Find( aDfltProp, SbxCLASS_PROPERTY ); - SetModified( FALSE ); - return TRUE; + SetModified( sal_False ); + return sal_True; } -BOOL SbxObject::StoreData( SvStream& rStrm ) const +sal_Bool SbxObject::StoreData( SvStream& rStrm ) const { if( !SbxVariable::StoreData( rStrm ) ) - return FALSE; + return sal_False; XubString aDfltProp; if( pDfltProp ) aDfltProp = pDfltProp->GetName(); rStrm.WriteByteString( aClassName, RTL_TEXTENCODING_ASCII_US ); rStrm.WriteByteString( aDfltProp, RTL_TEXTENCODING_ASCII_US ); - ULONG nPos = rStrm.Tell(); - rStrm << (UINT32) 0L; + sal_uIntPtr nPos = rStrm.Tell(); + rStrm << (sal_uInt32) 0L; if( !StorePrivateData( rStrm ) ) - return FALSE; - ULONG nNew = rStrm.Tell(); + return sal_False; + sal_uIntPtr nNew = rStrm.Tell(); rStrm.Seek( nPos ); - rStrm << (UINT32) ( nNew - nPos ); + rStrm << (sal_uInt32) ( nNew - nPos ); rStrm.Seek( nNew ); if( !pMethods->Store( rStrm ) ) - return FALSE; + return sal_False; if( !pProps->Store( rStrm ) ) - return FALSE; + return sal_False; if( !pObjs->Store( rStrm ) ) - return FALSE; - ((SbxObject*) this)->SetModified( FALSE ); - return TRUE; + return sal_False; + ((SbxObject*) this)->SetModified( sal_False ); + return sal_True; } XubString SbxObject::GenerateSource( const XubString &rLinePrefix, @@ -802,7 +805,7 @@ XubString SbxObject::GenerateSource( const XubString &rLinePrefix, XubString aSource; SbxArrayRef xProps( GetProperties() ); bool bLineFeed = false; - for ( USHORT nProp = 0; nProp < xProps->Count(); ++nProp ) + for ( sal_uInt16 nProp = 0; nProp < xProps->Count(); ++nProp ) { SbxPropertyRef xProp = (SbxProperty*) xProps->Get(nProp); XubString aPropName( xProp->GetName() ); @@ -850,7 +853,7 @@ XubString SbxObject::GenerateSource( const XubString &rLinePrefix, return aSource; } -static BOOL CollectAttrs( const SbxBase* p, XubString& rRes ) +static sal_Bool CollectAttrs( const SbxBase* p, XubString& rRes ) { XubString aAttrs; if( p->IsHidden() ) @@ -878,19 +881,19 @@ static BOOL CollectAttrs( const SbxBase* p, XubString& rRes ) rRes.AssignAscii( " (" ); rRes += aAttrs; rRes += ')'; - return TRUE; + return sal_True; } else { rRes.Erase(); - return FALSE; + return sal_False; } } -void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) +void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill ) { // Shifting - static USHORT nLevel = 0; + static sal_uInt16 nLevel = 0; if ( nLevel > 10 ) { rStrm << "<too deep>" << endl; @@ -898,7 +901,7 @@ void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) } ++nLevel; String aIndent; - for ( USHORT n = 1; n < nLevel; ++n ) + for ( sal_uInt16 n = 1; n < nLevel; ++n ) aIndent.AppendAscii( " " ); // if necessary complete the object @@ -909,7 +912,7 @@ void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) ByteString aNameStr( (const UniString&)GetName(), RTL_TEXTENCODING_ASCII_US ); ByteString aClassNameStr( (const UniString&)aClassName, RTL_TEXTENCODING_ASCII_US ); rStrm << "Object( " - << ByteString::CreateFromInt64( (ULONG) this ).GetBuffer() << "=='" + << ByteString::CreateFromInt64( (sal_uIntPtr) this ).GetBuffer() << "=='" << ( aNameStr.Len() ? aNameStr.GetBuffer() : "<unnamed>" ) << "', " << "of class '" << aClassNameStr.GetBuffer() << "', " << "counts " @@ -919,7 +922,7 @@ void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) { ByteString aParentNameStr( (const UniString&)GetName(), RTL_TEXTENCODING_ASCII_US ); rStrm << "in parent " - << ByteString::CreateFromInt64( (ULONG) GetParent() ).GetBuffer() + << ByteString::CreateFromInt64( (sal_uIntPtr) GetParent() ).GetBuffer() << "=='" << ( aParentNameStr.Len() ? aParentNameStr.GetBuffer() : "<unnamed>" ) << "'"; } else @@ -938,7 +941,7 @@ void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) // Methods rStrm << aIndentNameStr.GetBuffer() << "- Methods:" << endl; - for( USHORT i = 0; i < pMethods->Count(); i++ ) + for( sal_uInt16 i = 0; i < pMethods->Count(); i++ ) { SbxVariableRef& r = pMethods->GetRef( i ); SbxVariable* pVar = r; @@ -971,7 +974,7 @@ void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) // Properties rStrm << aIndentNameStr.GetBuffer() << "- Properties:" << endl; { - for( USHORT i = 0; i < pProps->Count(); i++ ) + for( sal_uInt16 i = 0; i < pProps->Count(); i++ ) { SbxVariableRef& r = pProps->GetRef( i ); SbxVariable* pVar = r; @@ -1005,7 +1008,7 @@ void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) // Objects rStrm << aIndentNameStr.GetBuffer() << "- Objects:" << endl; { - for( USHORT i = 0; i < pObjs->Count(); i++ ) + for( sal_uInt16 i = 0; i < pObjs->Count(); i++ ) { SbxVariableRef& r = pObjs->GetRef( i ); SbxVariable* pVar = r; @@ -1029,7 +1032,7 @@ SvDispatch* SbxObject::GetSvDispatch() return NULL; } -BOOL SbxMethod::Run( SbxValues* pValues ) +sal_Bool SbxMethod::Run( SbxValues* pValues ) { SbxValues aRes; if( !pValues ) @@ -1048,7 +1051,7 @@ SbxClassType SbxProperty::GetClass() const return SbxCLASS_PROPERTY; } -void SbxObject::GarbageCollection( ULONG /*nObjects*/ ) +void SbxObject::GarbageCollection( sal_uIntPtr /* nObjects */ ) /* [Description] |