Kaydet (Commit) 3c0abdd8 authored tarafından Rüdiger Timm's avatar Rüdiger Timm

INTEGRATION: CWS npower5 (1.29.42); FILE MERGED

2007/01/23 19:21:05 npower 1.29.42.4: #i70951# cater for optional key and before params
2007/01/23 09:38:15 npower 1.29.42.3: #i70951 named params, used static definition for param info
2007/01/19 16:50:50 npower 1.29.42.2: Issue number:  71492
2007/01/19 16:46:03 npower 1.29.42.1:  #i70951#, #i70952# add named params and fix indexing error for collection class
Issue number:
Submitted by:
Reviewed by:
üst 46f0245e
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: sb.cxx,v $ * $RCSfile: sb.cxx,v $
* *
* $Revision: 1.29 $ * $Revision: 1.30 $
* *
* last change: $Author: obo $ $Date: 2006-09-17 10:00:06 $ * last change: $Author: rt $ $Date: 2007-01-29 15:04:54 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -846,8 +846,16 @@ void StarBASIC::InitAllModules( StarBASIC* pBasicNotToInit ) ...@@ -846,8 +846,16 @@ void StarBASIC::InitAllModules( StarBASIC* pBasicNotToInit )
SbModule* pModule = (SbModule*)pModules->Get( nMod ); SbModule* pModule = (SbModule*)pModules->Get( nMod );
if( !pModule->IsCompiled() ) if( !pModule->IsCompiled() )
pModule->Compile(); pModule->Compile();
}
// compile modules first then RunInit ( otherwise there is
// can be order dependency, e.g. classmodule A has a member
// of of type classmodule B and classmodule B hasn't been compiled yet )
for ( USHORT nMod = 0; nMod < pModules->Count(); nMod++ )
{
SbModule* pModule = (SbModule*)pModules->Get( nMod );
pModule->RunInit(); pModule->RunInit();
} }
// Alle Objekte ueberpruefen, ob es sich um ein Basic handelt // Alle Objekte ueberpruefen, ob es sich um ein Basic handelt
// Wenn ja, auch dort initialisieren // Wenn ja, auch dort initialisieren
for ( USHORT nObj = 0; nObj < pObjs->Count(); nObj++ ) for ( USHORT nObj = 0; nObj < pObjs->Count(); nObj++ )
...@@ -1494,6 +1502,9 @@ static const char pItemStr[] = "Item"; ...@@ -1494,6 +1502,9 @@ static const char pItemStr[] = "Item";
static const char pRemoveStr[] = "Remove"; static const char pRemoveStr[] = "Remove";
static USHORT nCountHash = 0, nAddHash, nItemHash, nRemoveHash; static USHORT nCountHash = 0, nAddHash, nItemHash, nRemoveHash;
SbxInfoRef BasicCollection::xAddInfo = NULL;
SbxInfoRef BasicCollection::xItemInfo = NULL;
BasicCollection::BasicCollection( const XubString& rClass ) BasicCollection::BasicCollection( const XubString& rClass )
: SbxObject( rClass ) : SbxObject( rClass )
{ {
...@@ -1505,6 +1516,7 @@ BasicCollection::BasicCollection( const XubString& rClass ) ...@@ -1505,6 +1516,7 @@ BasicCollection::BasicCollection( const XubString& rClass )
nRemoveHash = MakeHashCode( String::CreateFromAscii( pRemoveStr ) ); nRemoveHash = MakeHashCode( String::CreateFromAscii( pRemoveStr ) );
} }
Initialize(); Initialize();
} }
BasicCollection::~BasicCollection() BasicCollection::~BasicCollection()
...@@ -1532,6 +1544,19 @@ void BasicCollection::Initialize() ...@@ -1532,6 +1544,19 @@ void BasicCollection::Initialize()
p->SetFlag( SBX_DONTSTORE ); p->SetFlag( SBX_DONTSTORE );
p = Make( String::CreateFromAscii( pRemoveStr ), SbxCLASS_METHOD, SbxEMPTY ); p = Make( String::CreateFromAscii( pRemoveStr ), SbxCLASS_METHOD, SbxEMPTY );
p->SetFlag( SBX_DONTSTORE ); p->SetFlag( SBX_DONTSTORE );
if ( !xAddInfo.Is() )
{
xAddInfo = new SbxInfo;
xAddInfo->AddParam( String( RTL_CONSTASCII_USTRINGPARAM("Item") ), SbxVARIANT, SBX_READ );
xAddInfo->AddParam( String( RTL_CONSTASCII_USTRINGPARAM("Key") ), SbxVARIANT, SBX_READ | SBX_OPTIONAL );
xAddInfo->AddParam( String( RTL_CONSTASCII_USTRINGPARAM("Before") ), SbxVARIANT, SBX_READ | SBX_OPTIONAL );
xAddInfo->AddParam( String( RTL_CONSTASCII_USTRINGPARAM("After") ), SbxVARIANT, SBX_READ | SBX_OPTIONAL );
}
if ( !xItemInfo.Is() )
{
xItemInfo = new SbxInfo;
xItemInfo->AddParam( String( RTL_CONSTASCII_USTRINGPARAM("Index") ), SbxVARIANT, SBX_READ | SBX_OPTIONAL);
}
} }
SbxVariable* BasicCollection::Find( const XubString& rName, SbxClassType t ) SbxVariable* BasicCollection::Find( const XubString& rName, SbxClassType t )
...@@ -1549,11 +1574,12 @@ void BasicCollection::SFX_NOTIFY( SfxBroadcaster& rCst, const TypeId& rId1, ...@@ -1549,11 +1574,12 @@ void BasicCollection::SFX_NOTIFY( SfxBroadcaster& rCst, const TypeId& rId1,
ULONG nId = p->GetId(); ULONG nId = p->GetId();
BOOL bRead = BOOL( nId == SBX_HINT_DATAWANTED ); BOOL bRead = BOOL( nId == SBX_HINT_DATAWANTED );
BOOL bWrite = BOOL( nId == SBX_HINT_DATACHANGED ); BOOL bWrite = BOOL( nId == SBX_HINT_DATACHANGED );
BOOL bRequestInfo = BOOL( nId == SBX_HINT_INFOWANTED );
SbxVariable* pVar = p->GetVar(); SbxVariable* pVar = p->GetVar();
SbxArray* pArg = pVar->GetParameters(); SbxArray* pArg = pVar->GetParameters();
XubString aVarName( pVar->GetName() );
if( bRead || bWrite ) if( bRead || bWrite )
{ {
XubString aVarName( pVar->GetName() );
if( pVar->GetHashCode() == nCountHash if( pVar->GetHashCode() == nCountHash
&& aVarName.EqualsIgnoreCaseAscii( pCountStr ) ) && aVarName.EqualsIgnoreCaseAscii( pCountStr ) )
pVar->PutLong( xItemArray->Count32() ); pVar->PutLong( xItemArray->Count32() );
...@@ -1570,6 +1596,15 @@ void BasicCollection::SFX_NOTIFY( SfxBroadcaster& rCst, const TypeId& rId1, ...@@ -1570,6 +1596,15 @@ void BasicCollection::SFX_NOTIFY( SfxBroadcaster& rCst, const TypeId& rId1,
SbxObject::SFX_NOTIFY( rCst, rId1, rHint, rId2 ); SbxObject::SFX_NOTIFY( rCst, rId1, rHint, rId2 );
return; return;
} }
else if ( bRequestInfo )
{
if( pVar->GetHashCode() == nAddHash
&& aVarName.EqualsIgnoreCaseAscii( pAddStr ) )
pVar->SetInfo( xAddInfo );
else if( pVar->GetHashCode() == nItemHash
&& aVarName.EqualsIgnoreCaseAscii( pItemStr ) )
pVar->SetInfo( xItemInfo );
}
} }
SbxObject::SFX_NOTIFY( rCst, rId1, rHint, rId2 ); SbxObject::SFX_NOTIFY( rCst, rId1, rHint, rId2 );
} }
...@@ -1624,7 +1659,7 @@ void BasicCollection::CollAdd( SbxArray* pPar_ ) ...@@ -1624,7 +1659,7 @@ void BasicCollection::CollAdd( SbxArray* pPar_ )
SbxVariable* pBefore = pPar_->Get(3); SbxVariable* pBefore = pPar_->Get(3);
if( nCount == 5 ) if( nCount == 5 )
{ {
if( !pBefore->IsErr() ) if( !( pBefore->IsErr() || ( pBefore->GetType() == SbxEMPTY ) ) )
{ {
SetError( SbERR_BAD_ARGUMENT ); SetError( SbERR_BAD_ARGUMENT );
return; return;
...@@ -1654,7 +1689,7 @@ void BasicCollection::CollAdd( SbxArray* pPar_ ) ...@@ -1654,7 +1689,7 @@ void BasicCollection::CollAdd( SbxArray* pPar_ )
if( nCount >= 3 ) if( nCount >= 3 )
{ {
SbxVariable* pKey = pPar_->Get(2); SbxVariable* pKey = pPar_->Get(2);
if( !pKey->IsErr() ) if( !( pKey->IsErr() || ( pKey->GetType() == SbxEMPTY ) ) )
{ {
if( pKey->GetType() != SbxSTRING ) if( pKey->GetType() != SbxSTRING )
{ {
...@@ -1694,7 +1729,8 @@ void BasicCollection::CollItem( SbxArray* pPar_ ) ...@@ -1694,7 +1729,8 @@ void BasicCollection::CollItem( SbxArray* pPar_ )
pRes = xItemArray->Get32( nIndex ); pRes = xItemArray->Get32( nIndex );
if( !pRes ) if( !pRes )
SetError( SbxERR_BAD_INDEX ); SetError( SbxERR_BAD_INDEX );
*(pPar_->Get(0)) = *pRes; else
*(pPar_->Get(0)) = *pRes;
} }
void BasicCollection::CollRemove( SbxArray* pPar_ ) void BasicCollection::CollRemove( SbxArray* pPar_ )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment