1*e1f63238SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*e1f63238SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*e1f63238SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*e1f63238SAndrew Rist * distributed with this work for additional information 6*e1f63238SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*e1f63238SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*e1f63238SAndrew Rist * "License"); you may not use this file except in compliance 9*e1f63238SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*e1f63238SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*e1f63238SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*e1f63238SAndrew Rist * software distributed under the License is distributed on an 15*e1f63238SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*e1f63238SAndrew Rist * KIND, either express or implied. See the License for the 17*e1f63238SAndrew Rist * specific language governing permissions and limitations 18*e1f63238SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*e1f63238SAndrew Rist *************************************************************/ 21*e1f63238SAndrew Rist 22*e1f63238SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_basic.hxx" 26cdf0e10cSrcweir #include <tools/stream.hxx> 27cdf0e10cSrcweir #include <basic/sbx.hxx> 28cdf0e10cSrcweir #include "runtime.hxx" 29cdf0e10cSrcweir #include <vector> 30cdf0e10cSrcweir using namespace std; 31cdf0e10cSrcweir 32cdf0e10cSrcweir struct SbxDim { // eine Array-Dimension: 33cdf0e10cSrcweir SbxDim* pNext; // Link 34cdf0e10cSrcweir sal_Int32 nLbound, nUbound; // Begrenzungen 35cdf0e10cSrcweir sal_Int32 nSize; // Anzahl Elemente 36cdf0e10cSrcweir }; 37cdf0e10cSrcweir 38cdf0e10cSrcweir class SbxVarEntry : public SbxVariableRef { 39cdf0e10cSrcweir public: 40cdf0e10cSrcweir XubString* pAlias; 41cdf0e10cSrcweir SbxVarEntry() : SbxVariableRef(), pAlias( NULL ) {} 42cdf0e10cSrcweir ~SbxVarEntry() { delete pAlias; } 43cdf0e10cSrcweir }; 44cdf0e10cSrcweir 45cdf0e10cSrcweir typedef SbxVarEntry* SbxVarEntryPtr; 46cdf0e10cSrcweir typedef vector< SbxVarEntryPtr > SbxVarEntryPtrVector; 47cdf0e10cSrcweir class SbxVarRefs : public SbxVarEntryPtrVector 48cdf0e10cSrcweir { 49cdf0e10cSrcweir public: 50cdf0e10cSrcweir SbxVarRefs( void ) {} 51cdf0e10cSrcweir }; 52cdf0e10cSrcweir 53cdf0e10cSrcweir 54cdf0e10cSrcweir TYPEINIT1(SbxArray,SbxBase) 55cdf0e10cSrcweir TYPEINIT1(SbxDimArray,SbxArray) 56cdf0e10cSrcweir 57cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////// 58cdf0e10cSrcweir // 59cdf0e10cSrcweir // SbxArray 60cdf0e10cSrcweir // 61cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////// 62cdf0e10cSrcweir 63cdf0e10cSrcweir SbxArray::SbxArray( SbxDataType t ) : SbxBase() 64cdf0e10cSrcweir { 65cdf0e10cSrcweir pData = new SbxVarRefs; 66cdf0e10cSrcweir eType = t; 67cdf0e10cSrcweir if( t != SbxVARIANT ) 68cdf0e10cSrcweir SetFlag( SBX_FIXED ); 69cdf0e10cSrcweir } 70cdf0e10cSrcweir 71cdf0e10cSrcweir SbxArray::SbxArray( const SbxArray& rArray ) : 72cdf0e10cSrcweir SvRefBase( rArray ), SbxBase() 73cdf0e10cSrcweir { 74cdf0e10cSrcweir pData = new SbxVarRefs; 75cdf0e10cSrcweir if( rArray.eType != SbxVARIANT ) 76cdf0e10cSrcweir SetFlag( SBX_FIXED ); 77cdf0e10cSrcweir *this = rArray; 78cdf0e10cSrcweir } 79cdf0e10cSrcweir 80cdf0e10cSrcweir SbxArray& SbxArray::operator=( const SbxArray& rArray ) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir if( &rArray != this ) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir eType = rArray.eType; 85cdf0e10cSrcweir Clear(); 86cdf0e10cSrcweir SbxVarRefs* pSrc = rArray.pData; 87cdf0e10cSrcweir for( sal_uInt32 i = 0; i < pSrc->size(); i++ ) 88cdf0e10cSrcweir { 89cdf0e10cSrcweir SbxVarEntryPtr pSrcRef = (*pSrc)[i]; 90cdf0e10cSrcweir const SbxVariable* pSrc_ = *pSrcRef; 91cdf0e10cSrcweir if( !pSrc_ ) 92cdf0e10cSrcweir continue; 93cdf0e10cSrcweir SbxVarEntryPtr pDstRef = new SbxVarEntry; 94cdf0e10cSrcweir *((SbxVariableRef*) pDstRef) = *((SbxVariableRef*) pSrcRef); 95cdf0e10cSrcweir if( pSrcRef->pAlias ) 96cdf0e10cSrcweir pDstRef->pAlias = new XubString( *pSrcRef->pAlias ); 97cdf0e10cSrcweir if( eType != SbxVARIANT ) 98cdf0e10cSrcweir // Keine Objekte konvertieren 99cdf0e10cSrcweir if( eType != SbxOBJECT || pSrc_->GetClass() != SbxCLASS_OBJECT ) 100cdf0e10cSrcweir ((SbxVariable*) pSrc_)->Convert( eType ); 101cdf0e10cSrcweir pData->push_back( pDstRef ); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir } 104cdf0e10cSrcweir return *this; 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir SbxArray::~SbxArray() 108cdf0e10cSrcweir { 109cdf0e10cSrcweir Clear(); 110cdf0e10cSrcweir delete pData; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir SbxDataType SbxArray::GetType() const 114cdf0e10cSrcweir { 115cdf0e10cSrcweir return (SbxDataType) ( eType | SbxARRAY ); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir SbxClassType SbxArray::GetClass() const 119cdf0e10cSrcweir { 120cdf0e10cSrcweir return SbxCLASS_ARRAY; 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir void SbxArray::Clear() 124cdf0e10cSrcweir { 125cdf0e10cSrcweir sal_uInt32 nSize = pData->size(); 126cdf0e10cSrcweir for( sal_uInt32 i = 0 ; i < nSize ; i++ ) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir SbxVarEntry* pEntry = (*pData)[i]; 129cdf0e10cSrcweir delete pEntry; 130cdf0e10cSrcweir } 131cdf0e10cSrcweir pData->clear(); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir sal_uInt32 SbxArray::Count32() const 135cdf0e10cSrcweir { 136cdf0e10cSrcweir return pData->size(); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir sal_uInt16 SbxArray::Count() const 140cdf0e10cSrcweir { 141cdf0e10cSrcweir sal_uInt32 nCount = pData->size(); 142cdf0e10cSrcweir DBG_ASSERT( nCount <= SBX_MAXINDEX, "SBX: Array-Index > SBX_MAXINDEX" ); 143cdf0e10cSrcweir return (sal_uInt16)nCount; 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 146cdf0e10cSrcweir SbxVariableRef& SbxArray::GetRef32( sal_uInt32 nIdx ) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir // Array ggf. vergroessern 149cdf0e10cSrcweir DBG_ASSERT( nIdx <= SBX_MAXINDEX32, "SBX: Array-Index > SBX_MAXINDEX32" ); 150cdf0e10cSrcweir // Very Hot Fix 151cdf0e10cSrcweir if( nIdx > SBX_MAXINDEX32 ) 152cdf0e10cSrcweir { 153cdf0e10cSrcweir SetError( SbxERR_BOUNDS ); 154cdf0e10cSrcweir nIdx = 0; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir while( pData->size() <= nIdx ) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir const SbxVarEntryPtr p = new SbxVarEntry; 159cdf0e10cSrcweir pData->push_back( p ); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir return *((*pData)[nIdx]); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir SbxVariableRef& SbxArray::GetRef( sal_uInt16 nIdx ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir // Array ggf. vergroessern 167cdf0e10cSrcweir DBG_ASSERT( nIdx <= SBX_MAXINDEX, "SBX: Array-Index > SBX_MAXINDEX" ); 168cdf0e10cSrcweir // Very Hot Fix 169cdf0e10cSrcweir if( nIdx > SBX_MAXINDEX ) 170cdf0e10cSrcweir { 171cdf0e10cSrcweir SetError( SbxERR_BOUNDS ); 172cdf0e10cSrcweir nIdx = 0; 173cdf0e10cSrcweir } 174cdf0e10cSrcweir while( pData->size() <= nIdx ) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir const SbxVarEntryPtr p = new SbxVarEntry; 177cdf0e10cSrcweir pData->push_back( p ); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir return *((*pData)[nIdx]); 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir SbxVariable* SbxArray::Get32( sal_uInt32 nIdx ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir if( !CanRead() ) 185cdf0e10cSrcweir { 186cdf0e10cSrcweir SetError( SbxERR_PROP_WRITEONLY ); 187cdf0e10cSrcweir return NULL; 188cdf0e10cSrcweir } 189cdf0e10cSrcweir SbxVariableRef& rRef = GetRef32( nIdx ); 190cdf0e10cSrcweir 191cdf0e10cSrcweir if ( !rRef.Is() ) 192cdf0e10cSrcweir rRef = new SbxVariable( eType ); 193cdf0e10cSrcweir #ifdef DBG_UTIL 194cdf0e10cSrcweir else 195cdf0e10cSrcweir DBG_CHKOBJ( rRef, SbxBase, 0 ); 196cdf0e10cSrcweir #endif 197cdf0e10cSrcweir 198cdf0e10cSrcweir return rRef; 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201cdf0e10cSrcweir SbxVariable* SbxArray::Get( sal_uInt16 nIdx ) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir if( !CanRead() ) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir SetError( SbxERR_PROP_WRITEONLY ); 206cdf0e10cSrcweir return NULL; 207cdf0e10cSrcweir } 208cdf0e10cSrcweir SbxVariableRef& rRef = GetRef( nIdx ); 209cdf0e10cSrcweir 210cdf0e10cSrcweir if ( !rRef.Is() ) 211cdf0e10cSrcweir rRef = new SbxVariable( eType ); 212cdf0e10cSrcweir #ifdef DBG_UTIL 213cdf0e10cSrcweir else 214cdf0e10cSrcweir DBG_CHKOBJ( rRef, SbxBase, 0 ); 215cdf0e10cSrcweir #endif 216cdf0e10cSrcweir 217cdf0e10cSrcweir return rRef; 218cdf0e10cSrcweir } 219cdf0e10cSrcweir 220cdf0e10cSrcweir void SbxArray::Put32( SbxVariable* pVar, sal_uInt32 nIdx ) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir if( !CanWrite() ) 223cdf0e10cSrcweir SetError( SbxERR_PROP_READONLY ); 224cdf0e10cSrcweir else 225cdf0e10cSrcweir { 226cdf0e10cSrcweir if( pVar ) 227cdf0e10cSrcweir if( eType != SbxVARIANT ) 228cdf0e10cSrcweir // Keine Objekte konvertieren 229cdf0e10cSrcweir if( eType != SbxOBJECT || pVar->GetClass() != SbxCLASS_OBJECT ) 230cdf0e10cSrcweir pVar->Convert( eType ); 231cdf0e10cSrcweir SbxVariableRef& rRef = GetRef32( nIdx ); 232cdf0e10cSrcweir if( (SbxVariable*) rRef != pVar ) 233cdf0e10cSrcweir { 234cdf0e10cSrcweir rRef = pVar; 235cdf0e10cSrcweir SetFlag( SBX_MODIFIED ); 236cdf0e10cSrcweir } 237cdf0e10cSrcweir } 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir void SbxArray::Put( SbxVariable* pVar, sal_uInt16 nIdx ) 241cdf0e10cSrcweir { 242cdf0e10cSrcweir if( !CanWrite() ) 243cdf0e10cSrcweir SetError( SbxERR_PROP_READONLY ); 244cdf0e10cSrcweir else 245cdf0e10cSrcweir { 246cdf0e10cSrcweir if( pVar ) 247cdf0e10cSrcweir if( eType != SbxVARIANT ) 248cdf0e10cSrcweir // Keine Objekte konvertieren 249cdf0e10cSrcweir if( eType != SbxOBJECT || pVar->GetClass() != SbxCLASS_OBJECT ) 250cdf0e10cSrcweir pVar->Convert( eType ); 251cdf0e10cSrcweir SbxVariableRef& rRef = GetRef( nIdx ); 252cdf0e10cSrcweir if( (SbxVariable*) rRef != pVar ) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir rRef = pVar; 255cdf0e10cSrcweir SetFlag( SBX_MODIFIED ); 256cdf0e10cSrcweir } 257cdf0e10cSrcweir } 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir const XubString& SbxArray::GetAlias( sal_uInt16 nIdx ) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir if( !CanRead() ) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir SetError( SbxERR_PROP_WRITEONLY ); 265cdf0e10cSrcweir return String::EmptyString(); 266cdf0e10cSrcweir } 267cdf0e10cSrcweir SbxVarEntry& rRef = (SbxVarEntry&) GetRef( nIdx ); 268cdf0e10cSrcweir 269cdf0e10cSrcweir if ( !rRef.pAlias ) 270cdf0e10cSrcweir return String::EmptyString(); 271cdf0e10cSrcweir #ifdef DBG_UTIL 272cdf0e10cSrcweir else 273cdf0e10cSrcweir DBG_CHKOBJ( rRef, SbxBase, 0 ); 274cdf0e10cSrcweir #endif 275cdf0e10cSrcweir 276cdf0e10cSrcweir return *rRef.pAlias; 277cdf0e10cSrcweir } 278cdf0e10cSrcweir 279cdf0e10cSrcweir void SbxArray::PutAlias( const XubString& rAlias, sal_uInt16 nIdx ) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir if( !CanWrite() ) 282cdf0e10cSrcweir SetError( SbxERR_PROP_READONLY ); 283cdf0e10cSrcweir else 284cdf0e10cSrcweir { 285cdf0e10cSrcweir SbxVarEntry& rRef = (SbxVarEntry&) GetRef( nIdx ); 286cdf0e10cSrcweir if( !rRef.pAlias ) 287cdf0e10cSrcweir rRef.pAlias = new XubString( rAlias ); 288cdf0e10cSrcweir else 289cdf0e10cSrcweir *rRef.pAlias = rAlias; 290cdf0e10cSrcweir } 291cdf0e10cSrcweir } 292cdf0e10cSrcweir 293cdf0e10cSrcweir void SbxArray::Insert32( SbxVariable* pVar, sal_uInt32 nIdx ) 294cdf0e10cSrcweir { 295cdf0e10cSrcweir DBG_ASSERT( pData->size() <= SBX_MAXINDEX32, "SBX: Array wird zu gross" ); 296cdf0e10cSrcweir if( pData->size() > SBX_MAXINDEX32 ) 297cdf0e10cSrcweir return; 298cdf0e10cSrcweir SbxVarEntryPtr p = new SbxVarEntry; 299cdf0e10cSrcweir *((SbxVariableRef*) p) = pVar; 300cdf0e10cSrcweir SbxVarEntryPtrVector::size_type nSize = pData->size(); 301cdf0e10cSrcweir if( nIdx > nSize ) 302cdf0e10cSrcweir nIdx = nSize; 303cdf0e10cSrcweir if( eType != SbxVARIANT && pVar ) 304cdf0e10cSrcweir (*p)->Convert( eType ); 305cdf0e10cSrcweir if( nIdx == nSize ) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir pData->push_back( p ); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir else 310cdf0e10cSrcweir { 311cdf0e10cSrcweir pData->insert( pData->begin() + nIdx, p ); 312cdf0e10cSrcweir } 313cdf0e10cSrcweir SetFlag( SBX_MODIFIED ); 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir void SbxArray::Insert( SbxVariable* pVar, sal_uInt16 nIdx ) 317cdf0e10cSrcweir { 318cdf0e10cSrcweir DBG_ASSERT( pData->size() <= 0x3FF0, "SBX: Array wird zu gross" ); 319cdf0e10cSrcweir if( pData->size() > 0x3FF0 ) 320cdf0e10cSrcweir return; 321cdf0e10cSrcweir Insert32( pVar, nIdx ); 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir void SbxArray::Remove32( sal_uInt32 nIdx ) 325cdf0e10cSrcweir { 326cdf0e10cSrcweir if( nIdx < pData->size() ) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir SbxVariableRef* pRef = (*pData)[nIdx]; 329cdf0e10cSrcweir pData->erase( pData->begin() + nIdx ); 330cdf0e10cSrcweir delete pRef; 331cdf0e10cSrcweir SetFlag( SBX_MODIFIED ); 332cdf0e10cSrcweir } 333cdf0e10cSrcweir } 334cdf0e10cSrcweir 335cdf0e10cSrcweir void SbxArray::Remove( sal_uInt16 nIdx ) 336cdf0e10cSrcweir { 337cdf0e10cSrcweir if( nIdx < pData->size() ) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir SbxVariableRef* pRef = (*pData)[nIdx]; 340cdf0e10cSrcweir pData->erase( pData->begin() + nIdx ); 341cdf0e10cSrcweir delete pRef; 342cdf0e10cSrcweir SetFlag( SBX_MODIFIED ); 343cdf0e10cSrcweir } 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir void SbxArray::Remove( SbxVariable* pVar ) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir if( pVar ) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir for( sal_uInt32 i = 0; i < pData->size(); i++ ) 351cdf0e10cSrcweir { 352cdf0e10cSrcweir SbxVariableRef* pRef = (*pData)[i]; 353cdf0e10cSrcweir // SbxVariableRef* pRef = pData->GetObject( i ); 354cdf0e10cSrcweir if( *pRef == pVar ) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir Remove32( i ); break; 357cdf0e10cSrcweir } 358cdf0e10cSrcweir } 359cdf0e10cSrcweir } 360cdf0e10cSrcweir } 361cdf0e10cSrcweir 362cdf0e10cSrcweir // Uebernahme der Daten aus dem uebergebenen Array, wobei 363cdf0e10cSrcweir // gleichnamige Variable ueberschrieben werden. 364cdf0e10cSrcweir 365cdf0e10cSrcweir void SbxArray::Merge( SbxArray* p ) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir if( p ) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir sal_uInt32 nSize = p->Count(); 370cdf0e10cSrcweir for( sal_uInt32 i = 0; i < nSize; i++ ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir SbxVarEntryPtr pRef1 = (*(p->pData))[i]; 373cdf0e10cSrcweir // Ist das Element by name schon drin? 374cdf0e10cSrcweir // Dann ueberschreiben! 375cdf0e10cSrcweir SbxVariable* pVar = *pRef1; 376cdf0e10cSrcweir if( pVar ) 377cdf0e10cSrcweir { 378cdf0e10cSrcweir XubString aName = pVar->GetName(); 379cdf0e10cSrcweir sal_uInt16 nHash = pVar->GetHashCode(); 380cdf0e10cSrcweir for( sal_uInt32 j = 0; j < pData->size(); j++ ) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir SbxVariableRef* pRef2 = (*pData)[j]; 383cdf0e10cSrcweir if( (*pRef2)->GetHashCode() == nHash 384cdf0e10cSrcweir && (*pRef2)->GetName().EqualsIgnoreCaseAscii( aName ) ) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir *pRef2 = pVar; pRef1 = NULL; 387cdf0e10cSrcweir break; 388cdf0e10cSrcweir } 389cdf0e10cSrcweir } 390cdf0e10cSrcweir if( pRef1 ) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir SbxVarEntryPtr pRef = new SbxVarEntry; 393cdf0e10cSrcweir const SbxVarEntryPtr pTemp = pRef; 394cdf0e10cSrcweir pData->push_back( pTemp ); 395cdf0e10cSrcweir *((SbxVariableRef*) pRef) = *((SbxVariableRef*) pRef1); 396cdf0e10cSrcweir if( pRef1->pAlias ) 397cdf0e10cSrcweir pRef->pAlias = new XubString( *pRef1->pAlias ); 398cdf0e10cSrcweir } 399cdf0e10cSrcweir } 400cdf0e10cSrcweir } 401cdf0e10cSrcweir } 402cdf0e10cSrcweir } 403cdf0e10cSrcweir 404cdf0e10cSrcweir // Suchen eines Elements ueber die Userdaten. Falls ein Element 405cdf0e10cSrcweir // ein Objekt ist, wird dieses ebenfalls durchsucht. 406cdf0e10cSrcweir 407cdf0e10cSrcweir SbxVariable* SbxArray::FindUserData( sal_uInt32 nData ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir SbxVariable* p = NULL; 410cdf0e10cSrcweir for( sal_uInt32 i = 0; i < pData->size(); i++ ) 411cdf0e10cSrcweir { 412cdf0e10cSrcweir SbxVariableRef* pRef = (*pData)[i]; 413cdf0e10cSrcweir SbxVariable* pVar = *pRef; 414cdf0e10cSrcweir if( pVar ) 415cdf0e10cSrcweir { 416cdf0e10cSrcweir if( pVar->IsVisible() && pVar->GetUserData() == nData ) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir p = pVar; 419cdf0e10cSrcweir p->ResetFlag( SBX_EXTFOUND ); 420cdf0e10cSrcweir break; // JSM 06.10.95 421cdf0e10cSrcweir } 422cdf0e10cSrcweir // Haben wir ein Array/Objekt mit Extended Search? 423cdf0e10cSrcweir else if( pVar->IsSet( SBX_EXTSEARCH ) ) 424cdf0e10cSrcweir { 425cdf0e10cSrcweir switch( pVar->GetClass() ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir case SbxCLASS_OBJECT: 428cdf0e10cSrcweir { 429cdf0e10cSrcweir // Objekte duerfen ihren Parent nicht durchsuchen 430cdf0e10cSrcweir sal_uInt16 nOld = pVar->GetFlags(); 431cdf0e10cSrcweir pVar->ResetFlag( SBX_GBLSEARCH ); 432cdf0e10cSrcweir p = ((SbxObject*) pVar)->FindUserData( nData ); 433cdf0e10cSrcweir pVar->SetFlags( nOld ); 434cdf0e10cSrcweir break; 435cdf0e10cSrcweir } 436cdf0e10cSrcweir case SbxCLASS_ARRAY: 437cdf0e10cSrcweir p = ((SbxArray*) pVar)->FindUserData( nData ); 438cdf0e10cSrcweir break; 439cdf0e10cSrcweir default: break; 440cdf0e10cSrcweir } 441cdf0e10cSrcweir if( p ) 442cdf0e10cSrcweir { 443cdf0e10cSrcweir p->SetFlag( SBX_EXTFOUND ); 444cdf0e10cSrcweir break; 445cdf0e10cSrcweir } 446cdf0e10cSrcweir } 447cdf0e10cSrcweir } 448cdf0e10cSrcweir } 449cdf0e10cSrcweir return p; 450cdf0e10cSrcweir } 451cdf0e10cSrcweir 452cdf0e10cSrcweir // Suchen eines Elements ueber den Namen und den Typ. Falls ein Element 453cdf0e10cSrcweir // ein Objekt ist, wird dieses ebenfalls durchsucht. 454cdf0e10cSrcweir 455cdf0e10cSrcweir SbxVariable* SbxArray::Find( const XubString& rName, SbxClassType t ) 456cdf0e10cSrcweir { 457cdf0e10cSrcweir SbxVariable* p = NULL; 458cdf0e10cSrcweir sal_uInt32 nCount = pData->size(); 459cdf0e10cSrcweir if( !nCount ) 460cdf0e10cSrcweir return NULL; 461cdf0e10cSrcweir sal_Bool bExtSearch = IsSet( SBX_EXTSEARCH ); 462cdf0e10cSrcweir sal_uInt16 nHash = SbxVariable::MakeHashCode( rName ); 463cdf0e10cSrcweir for( sal_uInt32 i = 0; i < nCount; i++ ) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir SbxVariableRef* pRef = (*pData)[i]; 466cdf0e10cSrcweir SbxVariable* pVar = *pRef; 467cdf0e10cSrcweir if( pVar && pVar->IsVisible() ) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir // Die ganz sichere Suche klappt auch, wenn es 470cdf0e10cSrcweir // keinen Hascode gibt! 471cdf0e10cSrcweir sal_uInt16 nVarHash = pVar->GetHashCode(); 472cdf0e10cSrcweir if( ( !nVarHash || nVarHash == nHash ) 473cdf0e10cSrcweir && ( t == SbxCLASS_DONTCARE || pVar->GetClass() == t ) 474cdf0e10cSrcweir && ( pVar->GetName().EqualsIgnoreCaseAscii( rName ) ) ) 475cdf0e10cSrcweir { 476cdf0e10cSrcweir p = pVar; 477cdf0e10cSrcweir p->ResetFlag( SBX_EXTFOUND ); 478cdf0e10cSrcweir break; 479cdf0e10cSrcweir } 480cdf0e10cSrcweir // Haben wir ein Array/Objekt mit Extended Search? 481cdf0e10cSrcweir else if( bExtSearch && pVar->IsSet( SBX_EXTSEARCH ) ) 482cdf0e10cSrcweir { 483cdf0e10cSrcweir switch( pVar->GetClass() ) 484cdf0e10cSrcweir { 485cdf0e10cSrcweir case SbxCLASS_OBJECT: 486cdf0e10cSrcweir { 487cdf0e10cSrcweir // Objekte duerfen ihren Parent nicht durchsuchen 488cdf0e10cSrcweir sal_uInt16 nOld = pVar->GetFlags(); 489cdf0e10cSrcweir pVar->ResetFlag( SBX_GBLSEARCH ); 490cdf0e10cSrcweir p = ((SbxObject*) pVar)->Find( rName, t ); 491cdf0e10cSrcweir pVar->SetFlags( nOld ); 492cdf0e10cSrcweir break; 493cdf0e10cSrcweir } 494cdf0e10cSrcweir case SbxCLASS_ARRAY: 495cdf0e10cSrcweir p = ((SbxArray*) pVar)->Find( rName, t ); 496cdf0e10cSrcweir break; 497cdf0e10cSrcweir default: break; 498cdf0e10cSrcweir } 499cdf0e10cSrcweir if( p ) 500cdf0e10cSrcweir { 501cdf0e10cSrcweir p->SetFlag( SBX_EXTFOUND ); 502cdf0e10cSrcweir break; 503cdf0e10cSrcweir } 504cdf0e10cSrcweir } 505cdf0e10cSrcweir } 506cdf0e10cSrcweir } 507cdf0e10cSrcweir return p; 508cdf0e10cSrcweir } 509cdf0e10cSrcweir 510cdf0e10cSrcweir sal_Bool SbxArray::LoadData( SvStream& rStrm, sal_uInt16 nVer ) 511cdf0e10cSrcweir { 512cdf0e10cSrcweir sal_uInt16 nElem; 513cdf0e10cSrcweir Clear(); 514cdf0e10cSrcweir sal_Bool bRes = sal_True; 515cdf0e10cSrcweir sal_uInt16 f = nFlags; 516cdf0e10cSrcweir nFlags |= SBX_WRITE; 517cdf0e10cSrcweir rStrm >> nElem; 518cdf0e10cSrcweir nElem &= 0x7FFF; 519cdf0e10cSrcweir for( sal_uInt32 n = 0; n < nElem; n++ ) 520cdf0e10cSrcweir { 521cdf0e10cSrcweir sal_uInt16 nIdx; 522cdf0e10cSrcweir rStrm >> nIdx; 523cdf0e10cSrcweir SbxVariable* pVar = (SbxVariable*) Load( rStrm ); 524cdf0e10cSrcweir if( pVar ) 525cdf0e10cSrcweir { 526cdf0e10cSrcweir SbxVariableRef& rRef = GetRef( nIdx ); 527cdf0e10cSrcweir rRef = pVar; 528cdf0e10cSrcweir } 529cdf0e10cSrcweir else 530cdf0e10cSrcweir { 531cdf0e10cSrcweir bRes = sal_False; break; 532cdf0e10cSrcweir } 533cdf0e10cSrcweir } 534cdf0e10cSrcweir if( bRes ) 535cdf0e10cSrcweir bRes = LoadPrivateData( rStrm, nVer ); 536cdf0e10cSrcweir nFlags = f; 537cdf0e10cSrcweir return bRes; 538cdf0e10cSrcweir } 539cdf0e10cSrcweir 540cdf0e10cSrcweir sal_Bool SbxArray::StoreData( SvStream& rStrm ) const 541cdf0e10cSrcweir { 542cdf0e10cSrcweir sal_uInt32 nElem = 0; 543cdf0e10cSrcweir sal_uInt32 n; 544cdf0e10cSrcweir // Welche Elemente sind ueberhaupt definiert? 545cdf0e10cSrcweir for( n = 0; n < pData->size(); n++ ) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir SbxVariableRef* pRef = (*pData)[n]; 548cdf0e10cSrcweir SbxVariable* p = *pRef; 549cdf0e10cSrcweir if( p && !( p->GetFlags() & SBX_DONTSTORE ) ) 550cdf0e10cSrcweir nElem++; 551cdf0e10cSrcweir } 552cdf0e10cSrcweir rStrm << (sal_uInt16) nElem; 553cdf0e10cSrcweir for( n = 0; n < pData->size(); n++ ) 554cdf0e10cSrcweir { 555cdf0e10cSrcweir SbxVariableRef* pRef = (*pData)[n]; 556cdf0e10cSrcweir SbxVariable* p = *pRef; 557cdf0e10cSrcweir if( p && !( p->GetFlags() & SBX_DONTSTORE ) ) 558cdf0e10cSrcweir { 559cdf0e10cSrcweir rStrm << (sal_uInt16) n; 560cdf0e10cSrcweir if( !p->Store( rStrm ) ) 561cdf0e10cSrcweir return sal_False; 562cdf0e10cSrcweir } 563cdf0e10cSrcweir } 564cdf0e10cSrcweir return StorePrivateData( rStrm ); 565cdf0e10cSrcweir } 566cdf0e10cSrcweir 567cdf0e10cSrcweir // #100883 Method to set method directly to parameter array 568cdf0e10cSrcweir void SbxArray::PutDirect( SbxVariable* pVar, sal_uInt32 nIdx ) 569cdf0e10cSrcweir { 570cdf0e10cSrcweir SbxVariableRef& rRef = GetRef32( nIdx ); 571cdf0e10cSrcweir rRef = pVar; 572cdf0e10cSrcweir } 573cdf0e10cSrcweir 574cdf0e10cSrcweir 575cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////// 576cdf0e10cSrcweir // 577cdf0e10cSrcweir // SbxArray 578cdf0e10cSrcweir // 579cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////// 580cdf0e10cSrcweir 581cdf0e10cSrcweir SbxDimArray::SbxDimArray( SbxDataType t ) : SbxArray( t ), mbHasFixedSize( false ) 582cdf0e10cSrcweir { 583cdf0e10cSrcweir pFirst = pLast = NULL; 584cdf0e10cSrcweir nDim = 0; 585cdf0e10cSrcweir } 586cdf0e10cSrcweir 587cdf0e10cSrcweir SbxDimArray::SbxDimArray( const SbxDimArray& rArray ) 588cdf0e10cSrcweir : SvRefBase( rArray ), SbxArray( rArray.eType ) 589cdf0e10cSrcweir { 590cdf0e10cSrcweir pFirst = pLast = NULL; 591cdf0e10cSrcweir nDim = 0; 592cdf0e10cSrcweir *this = rArray; 593cdf0e10cSrcweir } 594cdf0e10cSrcweir 595cdf0e10cSrcweir SbxDimArray& SbxDimArray::operator=( const SbxDimArray& rArray ) 596cdf0e10cSrcweir { 597cdf0e10cSrcweir if( &rArray != this ) 598cdf0e10cSrcweir { 599cdf0e10cSrcweir SbxArray::operator=( (const SbxArray&) rArray ); 600cdf0e10cSrcweir SbxDim* p = rArray.pFirst; 601cdf0e10cSrcweir while( p ) 602cdf0e10cSrcweir { 603cdf0e10cSrcweir AddDim32( p->nLbound, p->nUbound ); 604cdf0e10cSrcweir p = p->pNext; 605cdf0e10cSrcweir } 606cdf0e10cSrcweir this->mbHasFixedSize = rArray.mbHasFixedSize; 607cdf0e10cSrcweir } 608cdf0e10cSrcweir return *this; 609cdf0e10cSrcweir } 610cdf0e10cSrcweir 611cdf0e10cSrcweir SbxDimArray::~SbxDimArray() 612cdf0e10cSrcweir { 613cdf0e10cSrcweir Clear(); 614cdf0e10cSrcweir } 615cdf0e10cSrcweir 616cdf0e10cSrcweir void SbxDimArray::Clear() 617cdf0e10cSrcweir { 618cdf0e10cSrcweir SbxDim* p = pFirst; 619cdf0e10cSrcweir while( p ) 620cdf0e10cSrcweir { 621cdf0e10cSrcweir SbxDim* q = p->pNext; 622cdf0e10cSrcweir delete p; 623cdf0e10cSrcweir p = q; 624cdf0e10cSrcweir } 625cdf0e10cSrcweir pFirst = pLast = NULL; 626cdf0e10cSrcweir nDim = 0; 627cdf0e10cSrcweir } 628cdf0e10cSrcweir 629cdf0e10cSrcweir // Dimension hinzufuegen 630cdf0e10cSrcweir 631cdf0e10cSrcweir void SbxDimArray::AddDimImpl32( sal_Int32 lb, sal_Int32 ub, sal_Bool bAllowSize0 ) 632cdf0e10cSrcweir { 633cdf0e10cSrcweir SbxError eRes = SbxERR_OK; 634cdf0e10cSrcweir if( ub < lb && !bAllowSize0 ) 635cdf0e10cSrcweir { 636cdf0e10cSrcweir eRes = SbxERR_BOUNDS; 637cdf0e10cSrcweir ub = lb; 638cdf0e10cSrcweir } 639cdf0e10cSrcweir SbxDim* p = new SbxDim; 640cdf0e10cSrcweir p->nLbound = lb; 641cdf0e10cSrcweir p->nUbound = ub; 642cdf0e10cSrcweir p->nSize = ub - lb + 1; 643cdf0e10cSrcweir p->pNext = NULL; 644cdf0e10cSrcweir if( !pFirst ) 645cdf0e10cSrcweir pFirst = pLast = p; 646cdf0e10cSrcweir else 647cdf0e10cSrcweir pLast->pNext = p, pLast = p; 648cdf0e10cSrcweir nDim++; 649cdf0e10cSrcweir if( eRes ) 650cdf0e10cSrcweir SetError( eRes ); 651cdf0e10cSrcweir } 652cdf0e10cSrcweir 653cdf0e10cSrcweir void SbxDimArray::AddDim( short lb, short ub ) 654cdf0e10cSrcweir { 655cdf0e10cSrcweir AddDimImpl32( lb, ub, sal_False ); 656cdf0e10cSrcweir } 657cdf0e10cSrcweir 658cdf0e10cSrcweir void SbxDimArray::unoAddDim( short lb, short ub ) 659cdf0e10cSrcweir { 660cdf0e10cSrcweir AddDimImpl32( lb, ub, sal_True ); 661cdf0e10cSrcweir } 662cdf0e10cSrcweir 663cdf0e10cSrcweir void SbxDimArray::AddDim32( sal_Int32 lb, sal_Int32 ub ) 664cdf0e10cSrcweir { 665cdf0e10cSrcweir AddDimImpl32( lb, ub, sal_False ); 666cdf0e10cSrcweir } 667cdf0e10cSrcweir 668cdf0e10cSrcweir void SbxDimArray::unoAddDim32( sal_Int32 lb, sal_Int32 ub ) 669cdf0e10cSrcweir { 670cdf0e10cSrcweir AddDimImpl32( lb, ub, sal_True ); 671cdf0e10cSrcweir } 672cdf0e10cSrcweir 673cdf0e10cSrcweir 674cdf0e10cSrcweir // Dimensionsdaten auslesen 675cdf0e10cSrcweir 676cdf0e10cSrcweir sal_Bool SbxDimArray::GetDim32( sal_Int32 n, sal_Int32& rlb, sal_Int32& rub ) const 677cdf0e10cSrcweir { 678cdf0e10cSrcweir if( n < 1 || n > nDim ) 679cdf0e10cSrcweir { 680cdf0e10cSrcweir SetError( SbxERR_BOUNDS ); rub = rlb = 0; return sal_False; 681cdf0e10cSrcweir } 682cdf0e10cSrcweir SbxDim* p = pFirst; 683cdf0e10cSrcweir while( --n ) 684cdf0e10cSrcweir p = p->pNext; 685cdf0e10cSrcweir rub = p->nUbound; 686cdf0e10cSrcweir rlb = p->nLbound; 687cdf0e10cSrcweir return sal_True; 688cdf0e10cSrcweir } 689cdf0e10cSrcweir 690cdf0e10cSrcweir sal_Bool SbxDimArray::GetDim( short n, short& rlb, short& rub ) const 691cdf0e10cSrcweir { 692cdf0e10cSrcweir sal_Int32 rlb32, rub32; 693cdf0e10cSrcweir sal_Bool bRet = GetDim32( n, rlb32, rub32 ); 694cdf0e10cSrcweir if( bRet ) 695cdf0e10cSrcweir { 696cdf0e10cSrcweir if( rlb32 < -SBX_MAXINDEX || rub32 > SBX_MAXINDEX ) 697cdf0e10cSrcweir { 698cdf0e10cSrcweir SetError( SbxERR_BOUNDS ); 699cdf0e10cSrcweir return sal_False; 700cdf0e10cSrcweir } 701cdf0e10cSrcweir rub = (short)rub32; 702cdf0e10cSrcweir rlb = (short)rlb32; 703cdf0e10cSrcweir } 704cdf0e10cSrcweir return bRet; 705cdf0e10cSrcweir } 706cdf0e10cSrcweir 707cdf0e10cSrcweir // Element-Ptr anhand einer Index-Liste 708cdf0e10cSrcweir 709cdf0e10cSrcweir sal_uInt32 SbxDimArray::Offset32( const sal_Int32* pIdx ) 710cdf0e10cSrcweir { 711cdf0e10cSrcweir sal_uInt32 nPos = 0; 712cdf0e10cSrcweir for( SbxDim* p = pFirst; p; p = p->pNext ) 713cdf0e10cSrcweir { 714cdf0e10cSrcweir sal_Int32 nIdx = *pIdx++; 715cdf0e10cSrcweir if( nIdx < p->nLbound || nIdx > p->nUbound ) 716cdf0e10cSrcweir { 717cdf0e10cSrcweir nPos = (sal_uInt32)SBX_MAXINDEX32 + 1; break; 718cdf0e10cSrcweir } 719cdf0e10cSrcweir nPos = nPos * p->nSize + nIdx - p->nLbound; 720cdf0e10cSrcweir } 721cdf0e10cSrcweir if( nDim == 0 || nPos > SBX_MAXINDEX32 ) 722cdf0e10cSrcweir { 723cdf0e10cSrcweir SetError( SbxERR_BOUNDS ); nPos = 0; 724cdf0e10cSrcweir } 725cdf0e10cSrcweir return nPos; 726cdf0e10cSrcweir } 727cdf0e10cSrcweir 728cdf0e10cSrcweir sal_uInt16 SbxDimArray::Offset( const short* pIdx ) 729cdf0e10cSrcweir { 730cdf0e10cSrcweir long nPos = 0; 731cdf0e10cSrcweir for( SbxDim* p = pFirst; p; p = p->pNext ) 732cdf0e10cSrcweir { 733cdf0e10cSrcweir short nIdx = *pIdx++; 734cdf0e10cSrcweir if( nIdx < p->nLbound || nIdx > p->nUbound ) 735cdf0e10cSrcweir { 736cdf0e10cSrcweir nPos = SBX_MAXINDEX + 1; break; 737cdf0e10cSrcweir } 738cdf0e10cSrcweir nPos = nPos * p->nSize + nIdx - p->nLbound; 739cdf0e10cSrcweir } 740cdf0e10cSrcweir if( nDim == 0 || nPos > SBX_MAXINDEX ) 741cdf0e10cSrcweir { 742cdf0e10cSrcweir SetError( SbxERR_BOUNDS ); nPos = 0; 743cdf0e10cSrcweir } 744cdf0e10cSrcweir return (sal_uInt16) nPos; 745cdf0e10cSrcweir } 746cdf0e10cSrcweir 747cdf0e10cSrcweir SbxVariableRef& SbxDimArray::GetRef( const short* pIdx ) 748cdf0e10cSrcweir { 749cdf0e10cSrcweir return SbxArray::GetRef( Offset( pIdx ) ); 750cdf0e10cSrcweir } 751cdf0e10cSrcweir 752cdf0e10cSrcweir SbxVariable* SbxDimArray::Get( const short* pIdx ) 753cdf0e10cSrcweir { 754cdf0e10cSrcweir return SbxArray::Get( Offset( pIdx ) ); 755cdf0e10cSrcweir } 756cdf0e10cSrcweir 757cdf0e10cSrcweir void SbxDimArray::Put( SbxVariable* p, const short* pIdx ) 758cdf0e10cSrcweir { 759cdf0e10cSrcweir SbxArray::Put( p, Offset( pIdx ) ); 760cdf0e10cSrcweir } 761cdf0e10cSrcweir 762cdf0e10cSrcweir SbxVariableRef& SbxDimArray::GetRef32( const sal_Int32* pIdx ) 763cdf0e10cSrcweir { 764cdf0e10cSrcweir return SbxArray::GetRef32( Offset32( pIdx ) ); 765cdf0e10cSrcweir } 766cdf0e10cSrcweir 767cdf0e10cSrcweir SbxVariable* SbxDimArray::Get32( const sal_Int32* pIdx ) 768cdf0e10cSrcweir { 769cdf0e10cSrcweir return SbxArray::Get32( Offset32( pIdx ) ); 770cdf0e10cSrcweir } 771cdf0e10cSrcweir 772cdf0e10cSrcweir void SbxDimArray::Put32( SbxVariable* p, const sal_Int32* pIdx ) 773cdf0e10cSrcweir { 774cdf0e10cSrcweir SbxArray::Put32( p, Offset32( pIdx ) ); 775cdf0e10cSrcweir } 776cdf0e10cSrcweir 777cdf0e10cSrcweir 778cdf0e10cSrcweir // Element-Nr anhand eines Parameter-Arrays 779cdf0e10cSrcweir 780cdf0e10cSrcweir sal_uInt32 SbxDimArray::Offset32( SbxArray* pPar ) 781cdf0e10cSrcweir { 782cdf0e10cSrcweir if( nDim == 0 || !pPar || ( ( nDim != ( pPar->Count() - 1 ) ) && SbiRuntime::isVBAEnabled() ) ) 783cdf0e10cSrcweir { 784cdf0e10cSrcweir SetError( SbxERR_BOUNDS ); return 0; 785cdf0e10cSrcweir } 786cdf0e10cSrcweir sal_uInt32 nPos = 0; 787cdf0e10cSrcweir sal_uInt16 nOff = 1; // Nicht Element 0! 788cdf0e10cSrcweir for( SbxDim* p = pFirst; p && !IsError(); p = p->pNext ) 789cdf0e10cSrcweir { 790cdf0e10cSrcweir sal_Int32 nIdx = pPar->Get( nOff++ )->GetLong(); 791cdf0e10cSrcweir if( nIdx < p->nLbound || nIdx > p->nUbound ) 792cdf0e10cSrcweir { 793cdf0e10cSrcweir nPos = (sal_uInt32) SBX_MAXINDEX32+1; break; 794cdf0e10cSrcweir } 795cdf0e10cSrcweir nPos = nPos * p->nSize + nIdx - p->nLbound; 796cdf0e10cSrcweir } 797cdf0e10cSrcweir if( nPos > (sal_uInt32) SBX_MAXINDEX32 ) 798cdf0e10cSrcweir { 799cdf0e10cSrcweir SetError( SbxERR_BOUNDS ); nPos = 0; 800cdf0e10cSrcweir } 801cdf0e10cSrcweir return nPos; 802cdf0e10cSrcweir } 803cdf0e10cSrcweir 804cdf0e10cSrcweir sal_uInt16 SbxDimArray::Offset( SbxArray* pPar ) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir sal_uInt32 nPos = Offset32( pPar ); 807cdf0e10cSrcweir if( nPos > (long) SBX_MAXINDEX ) 808cdf0e10cSrcweir { 809cdf0e10cSrcweir SetError( SbxERR_BOUNDS ); nPos = 0; 810cdf0e10cSrcweir } 811cdf0e10cSrcweir return (sal_uInt16) nPos; 812cdf0e10cSrcweir } 813cdf0e10cSrcweir 814cdf0e10cSrcweir SbxVariableRef& SbxDimArray::GetRef( SbxArray* pPar ) 815cdf0e10cSrcweir { 816cdf0e10cSrcweir return SbxArray::GetRef32( Offset32( pPar ) ); 817cdf0e10cSrcweir } 818cdf0e10cSrcweir 819cdf0e10cSrcweir SbxVariable* SbxDimArray::Get( SbxArray* pPar ) 820cdf0e10cSrcweir { 821cdf0e10cSrcweir return SbxArray::Get32( Offset32( pPar ) ); 822cdf0e10cSrcweir } 823cdf0e10cSrcweir 824cdf0e10cSrcweir void SbxDimArray::Put( SbxVariable* p, SbxArray* pPar ) 825cdf0e10cSrcweir { 826cdf0e10cSrcweir SbxArray::Put32( p, Offset32( pPar ) ); 827cdf0e10cSrcweir } 828cdf0e10cSrcweir 829cdf0e10cSrcweir sal_Bool SbxDimArray::LoadData( SvStream& rStrm, sal_uInt16 nVer ) 830cdf0e10cSrcweir { 831cdf0e10cSrcweir short nDimension; 832cdf0e10cSrcweir rStrm >> nDimension; 833cdf0e10cSrcweir for( short i = 0; i < nDimension && rStrm.GetError() == SVSTREAM_OK; i++ ) 834cdf0e10cSrcweir { 835cdf0e10cSrcweir sal_Int16 lb, ub; 836cdf0e10cSrcweir rStrm >> lb >> ub; 837cdf0e10cSrcweir AddDim( lb, ub ); 838cdf0e10cSrcweir } 839cdf0e10cSrcweir return SbxArray::LoadData( rStrm, nVer ); 840cdf0e10cSrcweir } 841cdf0e10cSrcweir 842cdf0e10cSrcweir sal_Bool SbxDimArray::StoreData( SvStream& rStrm ) const 843cdf0e10cSrcweir { 844cdf0e10cSrcweir rStrm << (sal_Int16) nDim; 845cdf0e10cSrcweir for( short i = 0; i < nDim; i++ ) 846cdf0e10cSrcweir { 847cdf0e10cSrcweir short lb, ub; 848cdf0e10cSrcweir GetDim( i, lb, ub ); 849cdf0e10cSrcweir rStrm << (sal_Int16) lb << (sal_Int16) ub; 850cdf0e10cSrcweir } 851cdf0e10cSrcweir return SbxArray::StoreData( rStrm ); 852cdf0e10cSrcweir } 853cdf0e10cSrcweir 854