1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_tools.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #ifndef _LIMITS_H 32*cdf0e10cSrcweir #include <limits.h> 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #ifndef _STRING_H 36*cdf0e10cSrcweir #include <string.h> 37*cdf0e10cSrcweir #endif 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #ifndef _STDIO_H 40*cdf0e10cSrcweir #include <stdio.h> 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir #include <tools/solar.h> 43*cdf0e10cSrcweir #include <impcont.hxx> 44*cdf0e10cSrcweir #include <tools/contnr.hxx> 45*cdf0e10cSrcweir #include <tools/debug.hxx> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir // ----------------------------------------------------------------------- 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir DBG_NAME( CBlock ) 50*cdf0e10cSrcweir DBG_NAME( Container ) 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir /************************************************************************* 53*cdf0e10cSrcweir |* 54*cdf0e10cSrcweir |* DbgCheckCBlock() 55*cdf0e10cSrcweir |* 56*cdf0e10cSrcweir |* Beschreibung Pruefung eines CBlock fuer Debug-Utilities 57*cdf0e10cSrcweir |* Ersterstellung MI 30.01.92 58*cdf0e10cSrcweir |* Letzte Aenderung TH 24.01.96 59*cdf0e10cSrcweir |* 60*cdf0e10cSrcweir *************************************************************************/ 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir #ifdef DBG_UTIL 63*cdf0e10cSrcweir const char* CBlock::DbgCheckCBlock( const void* pBlock ) 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir CBlock* p = (CBlock*)pBlock; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir if ( p->nCount > p->nSize ) 68*cdf0e10cSrcweir return "nCount > nSize"; 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir if ( p->nSize && !p->pNodes ) 71*cdf0e10cSrcweir return "nSize > 0 && pNodes == NULL"; 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir return NULL; 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir #endif 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir /************************************************************************* 78*cdf0e10cSrcweir |* 79*cdf0e10cSrcweir |* CBlock::CBlock() 80*cdf0e10cSrcweir |* 81*cdf0e10cSrcweir |* Beschreibung Construktor des Verwaltungsblocks 82*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 83*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 84*cdf0e10cSrcweir |* 85*cdf0e10cSrcweir *************************************************************************/ 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir CBlock::CBlock( sal_uInt16 nInitSize, CBlock* _pPrev, CBlock* _pNext ) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir DBG_CTOR( CBlock, DbgCheckCBlock ); 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir pPrev = _pPrev; 92*cdf0e10cSrcweir pNext = _pNext; 93*cdf0e10cSrcweir nSize = nInitSize; 94*cdf0e10cSrcweir nCount = 0; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir // Datenpuffer anlegen 97*cdf0e10cSrcweir pNodes = new PVOID[nSize]; 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir /************************************************************************* 101*cdf0e10cSrcweir |* 102*cdf0e10cSrcweir |* CBlock::CBlock() 103*cdf0e10cSrcweir |* 104*cdf0e10cSrcweir |* Beschreibung Construktor des Verwaltungsblocks 105*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 106*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 107*cdf0e10cSrcweir |* 108*cdf0e10cSrcweir *************************************************************************/ 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir CBlock::CBlock( sal_uInt16 _nSize, CBlock* _pPrev ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir DBG_CTOR( CBlock, DbgCheckCBlock ); 113*cdf0e10cSrcweir DBG_ASSERT( _nSize, "CBlock::CBlock(): nSize == 0" ); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir pPrev = _pPrev; 116*cdf0e10cSrcweir pNext = NULL; 117*cdf0e10cSrcweir nSize = _nSize; 118*cdf0e10cSrcweir nCount = _nSize; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir // Datenpuffer anlegen und initialisieren 121*cdf0e10cSrcweir pNodes = new PVOID[nSize]; 122*cdf0e10cSrcweir memset( pNodes, 0, nSize*sizeof(PVOID) ); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir /************************************************************************* 126*cdf0e10cSrcweir |* 127*cdf0e10cSrcweir |* CBlock::CBlock() 128*cdf0e10cSrcweir |* 129*cdf0e10cSrcweir |* Beschreibung Copy-Construktor des Verwaltungsblocks 130*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 131*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 132*cdf0e10cSrcweir |* 133*cdf0e10cSrcweir *************************************************************************/ 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir CBlock::CBlock( const CBlock& r, CBlock* _pPrev ) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir DBG_CTOR( CBlock, DbgCheckCBlock ); 138*cdf0e10cSrcweir DBG_CHKOBJ( &r, CBlock, DbgCheckCBlock ); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir pPrev = _pPrev; 141*cdf0e10cSrcweir pNext = NULL; 142*cdf0e10cSrcweir nSize = r.nSize; 143*cdf0e10cSrcweir nCount = r.nCount; 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir // Datenpuffer anlegen und Daten kopieren 146*cdf0e10cSrcweir pNodes = new PVOID[nSize]; 147*cdf0e10cSrcweir memcpy( pNodes, r.pNodes, nCount*sizeof(PVOID) ); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir /************************************************************************* 151*cdf0e10cSrcweir |* 152*cdf0e10cSrcweir |* CBlock::~CBlock() 153*cdf0e10cSrcweir |* 154*cdf0e10cSrcweir |* Beschreibung Destruktor des Verwaltungsblocks 155*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 156*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 157*cdf0e10cSrcweir |* 158*cdf0e10cSrcweir *************************************************************************/ 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir inline CBlock::~CBlock() 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir DBG_DTOR( CBlock, DbgCheckCBlock ); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir // Daten loeschen 165*cdf0e10cSrcweir delete[] pNodes; 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir /************************************************************************* 169*cdf0e10cSrcweir |* 170*cdf0e10cSrcweir |* CBlock::Insert() 171*cdf0e10cSrcweir |* 172*cdf0e10cSrcweir |* Beschreibung Fuegt einen Pointer ein 173*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 174*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 175*cdf0e10cSrcweir |* 176*cdf0e10cSrcweir *************************************************************************/ 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir void CBlock::Insert( void* p, sal_uInt16 nIndex, sal_uInt16 nReSize ) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir DBG_CHKTHIS( CBlock, DbgCheckCBlock ); 181*cdf0e10cSrcweir DBG_ASSERT( nIndex <= nCount, "CBlock::Insert(): Index > nCount" ); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir // Muss Block realokiert werden 184*cdf0e10cSrcweir if ( nCount == nSize ) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir // Neue Daten anlegen 187*cdf0e10cSrcweir nSize = nSize + nReSize; // MSVC warns here if += is used 188*cdf0e10cSrcweir void** pNewNodes = new PVOID[nSize]; 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir // Wird angehaengt 191*cdf0e10cSrcweir if ( nCount == nIndex ) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir // Daten kopieren 194*cdf0e10cSrcweir memcpy( pNewNodes, pNodes, nCount*sizeof(PVOID) ); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir else 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir // Daten kopieren 199*cdf0e10cSrcweir memcpy( pNewNodes, pNodes, nIndex*sizeof(PVOID) ); 200*cdf0e10cSrcweir memcpy( pNewNodes + nIndex + 1, 201*cdf0e10cSrcweir pNodes + nIndex, 202*cdf0e10cSrcweir (nCount-nIndex)*sizeof(PVOID) ); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir // Alte Daten loeschen und neue setzen 206*cdf0e10cSrcweir delete[] pNodes; 207*cdf0e10cSrcweir pNodes = pNewNodes; 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir else 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir if ( nIndex < nCount ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir memmove( pNodes + nIndex + 1, 214*cdf0e10cSrcweir pNodes + nIndex, 215*cdf0e10cSrcweir (nCount-nIndex)*sizeof(PVOID) ); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir // Neuen Pointer setzen und Elementgroesse erhoehen 220*cdf0e10cSrcweir pNodes[nIndex] = p; 221*cdf0e10cSrcweir nCount++; 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir /************************************************************************* 225*cdf0e10cSrcweir |* 226*cdf0e10cSrcweir |* CBlock::Split() 227*cdf0e10cSrcweir |* 228*cdf0e10cSrcweir |* Beschreibung Fuegt einen Pointer ein und splittet den Block 229*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 230*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 231*cdf0e10cSrcweir |* 232*cdf0e10cSrcweir *************************************************************************/ 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir CBlock* CBlock::Split( void* p, sal_uInt16 nIndex, sal_uInt16 nReSize ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir DBG_CHKTHIS( CBlock, DbgCheckCBlock ); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir sal_uInt16 nNewSize; 239*cdf0e10cSrcweir sal_uInt16 nMiddle; 240*cdf0e10cSrcweir CBlock* pNewBlock; 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir nMiddle = nCount/2; 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir if ( ( nIndex == nCount ) || ( nIndex == 0 ) ) 245*cdf0e10cSrcweir nNewSize = nReSize; 246*cdf0e10cSrcweir else 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir // Der aktuelle Block wird in der Mitte geteilt 249*cdf0e10cSrcweir nNewSize = (nCount+1) / 2; 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir if ( nNewSize < nReSize ) 252*cdf0e10cSrcweir nNewSize = nReSize; 253*cdf0e10cSrcweir else 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir // Neue Groesse muss ein vielfaches von Resize sein 256*cdf0e10cSrcweir if ( nNewSize % nReSize ) 257*cdf0e10cSrcweir nNewSize += nReSize - (nNewSize % nReSize); 258*cdf0e10cSrcweir else 259*cdf0e10cSrcweir nNewSize = nNewSize + nReSize; // MSVC warns here if += is used 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir // Vor oder hinter dem aktuellem Block einfuegen? 264*cdf0e10cSrcweir if ( nIndex > nMiddle ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir // Neuen Split-Block anlegen und hinter dem aktuellem Block einfuegen 267*cdf0e10cSrcweir pNewBlock = new CBlock( nNewSize, this, pNext ); 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir if ( pNext ) 270*cdf0e10cSrcweir pNext->pPrev = pNewBlock; 271*cdf0e10cSrcweir pNext = pNewBlock; 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir if ( nIndex == nCount ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir // Neuen Pointer einfuegen 276*cdf0e10cSrcweir pNewBlock->pNodes[0] = p; 277*cdf0e10cSrcweir pNewBlock->nCount = 1; 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir else 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir nIndex = nIndex - nMiddle; // MSVC warns here if += is used 282*cdf0e10cSrcweir // Alles von Mitte bis Index kopieren 283*cdf0e10cSrcweir if ( nIndex ) 284*cdf0e10cSrcweir memcpy( pNewBlock->pNodes, pNodes+nMiddle, nIndex*sizeof(PVOID) ); 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir // Neuen Pointer einfuegen 287*cdf0e10cSrcweir pNewBlock->pNodes[nIndex] = p; 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir // Alles von Mitte bis Ende hinter Index kopieren 290*cdf0e10cSrcweir memcpy( pNewBlock->pNodes+nIndex+1, 291*cdf0e10cSrcweir pNodes+nMiddle+nIndex, 292*cdf0e10cSrcweir (nCount-nMiddle-nIndex) * sizeof(PVOID) ); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir pNewBlock->nCount = (nCount-nMiddle+1); 295*cdf0e10cSrcweir nCount = nMiddle; 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir // Den aktuellen Datenbereich auch halbieren 298*cdf0e10cSrcweir if ( nSize != nNewSize ) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir void** pNewNodes = new PVOID[nNewSize]; 301*cdf0e10cSrcweir memcpy( pNewNodes, pNodes, nCount*sizeof(PVOID) ); 302*cdf0e10cSrcweir delete[] pNodes; 303*cdf0e10cSrcweir pNodes = pNewNodes; 304*cdf0e10cSrcweir nSize = nNewSize; 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir else 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir // Neuen Split-Block anlegen und vor dem aktuellem Block einfuegen 311*cdf0e10cSrcweir pNewBlock = new CBlock( nNewSize, pPrev, this ); 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir if ( pPrev ) 314*cdf0e10cSrcweir pPrev->pNext = pNewBlock; 315*cdf0e10cSrcweir pPrev = pNewBlock; 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir if ( nIndex == 0 ) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir // Neuen Pointer einfuegen 320*cdf0e10cSrcweir pNewBlock->pNodes[0] = p; 321*cdf0e10cSrcweir pNewBlock->nCount = 1; 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir else 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir // Alles von Anfang bis Index kopieren 326*cdf0e10cSrcweir memcpy( pNewBlock->pNodes, pNodes, nIndex*sizeof(PVOID) ); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir // Neuen Pointer einfuegen 329*cdf0e10cSrcweir pNewBlock->pNodes[nIndex] = p; 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir // Alles von Index bis Mitte hinter Index kopieren 332*cdf0e10cSrcweir if ( nIndex != nMiddle ) 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir memcpy( pNewBlock->pNodes+nIndex+1, 335*cdf0e10cSrcweir pNodes+nIndex, 336*cdf0e10cSrcweir (nMiddle-nIndex) * sizeof(PVOID) ); 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir pNewBlock->nCount = nMiddle+1; 340*cdf0e10cSrcweir nCount = nCount - nMiddle; // MSVC warns here if += is used 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir // Die zweite Haelfte in einen neuen Block kopieren 343*cdf0e10cSrcweir if ( nSize != nNewSize ) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir void** pNewNodes = new PVOID[nNewSize]; 346*cdf0e10cSrcweir memcpy( pNewNodes, pNodes+nMiddle, nCount*sizeof(PVOID) ); 347*cdf0e10cSrcweir delete[] pNodes; 348*cdf0e10cSrcweir pNodes = pNewNodes; 349*cdf0e10cSrcweir nSize = nNewSize; 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir else 352*cdf0e10cSrcweir memmove( pNodes, pNodes+nMiddle, nCount*sizeof(PVOID) ); 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir // Neu angelegten Block zurueckgeben, da gegebenfalls die Blockpointer 357*cdf0e10cSrcweir // im Container angepast werden koennen 358*cdf0e10cSrcweir return pNewBlock; 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir /************************************************************************* 362*cdf0e10cSrcweir |* 363*cdf0e10cSrcweir |* CBlock::Remove() 364*cdf0e10cSrcweir |* 365*cdf0e10cSrcweir |* Beschreibung Entfernt einen Pointer 366*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 367*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 368*cdf0e10cSrcweir |* 369*cdf0e10cSrcweir *************************************************************************/ 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir void* CBlock::Remove( sal_uInt16 nIndex, sal_uInt16 nReSize ) 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir DBG_CHKTHIS( CBlock, DbgCheckCBlock ); 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir // Alten Pointer sichern 376*cdf0e10cSrcweir void* pOld = pNodes[nIndex]; 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir // 1 Element weniger 379*cdf0e10cSrcweir nCount--; 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir // Block verkleinern (wenn Reallokationsgroesse um 4 unterschritten wird) 382*cdf0e10cSrcweir if ( nCount == (nSize-nReSize-4) ) 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir // Neue Daten anlegen 385*cdf0e10cSrcweir nSize = nSize - nReSize; // MSVC warns here if += is used 386*cdf0e10cSrcweir void** pNewNodes = new PVOID[nSize]; 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir // Wird letzter Eintrag geloescht 389*cdf0e10cSrcweir if ( nIndex == nCount ) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir // Daten kopieren 392*cdf0e10cSrcweir memcpy( pNewNodes, pNodes, nCount*sizeof(PVOID) ); 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir else 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir // Daten kopieren 397*cdf0e10cSrcweir memcpy( pNewNodes, pNodes, nIndex*sizeof(PVOID) ); 398*cdf0e10cSrcweir memcpy( pNewNodes + nIndex, pNodes + nIndex+1, 399*cdf0e10cSrcweir (nCount-nIndex)*sizeof(PVOID) ); 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir // Alte Daten loeschen und neue setzen 403*cdf0e10cSrcweir delete[] pNodes; 404*cdf0e10cSrcweir pNodes = pNewNodes; 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir else 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir // Wenn nicht das letzte Element, dann zusammenschieben 409*cdf0e10cSrcweir if ( nIndex < nCount ) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir memmove( pNodes + nIndex, pNodes + nIndex + 1, 412*cdf0e10cSrcweir (nCount-nIndex)*sizeof(PVOID) ); 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir // Alten Pointer zurueckgeben 417*cdf0e10cSrcweir return pOld; 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir /************************************************************************* 421*cdf0e10cSrcweir |* 422*cdf0e10cSrcweir |* CBlock::Replace() 423*cdf0e10cSrcweir |* 424*cdf0e10cSrcweir |* Beschreibung Ersetzt einen Pointer 425*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 426*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 427*cdf0e10cSrcweir |* 428*cdf0e10cSrcweir *************************************************************************/ 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir inline void* CBlock::Replace( void* p, sal_uInt16 nIndex ) 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir DBG_CHKTHIS( CBlock, DbgCheckCBlock ); 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir // Alten Pointer sichern, neuen setzen und alten zurueckgeben 435*cdf0e10cSrcweir void* pOld = pNodes[nIndex]; 436*cdf0e10cSrcweir pNodes[nIndex] = p; 437*cdf0e10cSrcweir return pOld; 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir /************************************************************************* 441*cdf0e10cSrcweir |* 442*cdf0e10cSrcweir |* CBlock::GetObjectPtr() 443*cdf0e10cSrcweir |* 444*cdf0e10cSrcweir |* Beschreibung Gibt einen Pointer auf den Pointer aus dem Block 445*cdf0e10cSrcweir |* zurueck 446*cdf0e10cSrcweir |* Ersterstellung TH 26.01.93 447*cdf0e10cSrcweir |* Letzte Aenderung TH 26.01.93 448*cdf0e10cSrcweir |* 449*cdf0e10cSrcweir *************************************************************************/ 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir inline void** CBlock::GetObjectPtr( sal_uInt16 nIndex ) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir DBG_CHKTHIS( CBlock, DbgCheckCBlock ); 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir return &(pNodes[nIndex]); 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir /************************************************************************* 459*cdf0e10cSrcweir |* 460*cdf0e10cSrcweir |* CBlock::SetSize() 461*cdf0e10cSrcweir |* 462*cdf0e10cSrcweir |* Beschreibung Aendert die Groesse des Blocks 463*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 464*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 465*cdf0e10cSrcweir |* 466*cdf0e10cSrcweir *************************************************************************/ 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir void CBlock::SetSize( sal_uInt16 nNewSize ) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir DBG_CHKTHIS( CBlock, DbgCheckCBlock ); 471*cdf0e10cSrcweir DBG_ASSERT( nNewSize, "CBlock::SetSize(): nNewSize == 0" ); 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir // Unterscheidet sich die Groesse 474*cdf0e10cSrcweir if ( nNewSize != nCount ) 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir // Array erweitern 477*cdf0e10cSrcweir void** pNewNodes = new PVOID[nNewSize]; 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir // Alte Tabelle in die Neue kopieren 480*cdf0e10cSrcweir if ( nNewSize < nCount ) 481*cdf0e10cSrcweir memcpy( pNewNodes, pNodes, nNewSize*sizeof(PVOID) ); 482*cdf0e10cSrcweir else 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir memcpy( pNewNodes, pNodes, nCount*sizeof(PVOID) ); 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir // Array mit 0 initialisieren 487*cdf0e10cSrcweir memset( pNewNodes+nCount, 0, (nNewSize-nCount)*sizeof(PVOID) ); 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir // Altes Array loeschen und neue Werte setzen 491*cdf0e10cSrcweir nSize = nNewSize; 492*cdf0e10cSrcweir nCount = nSize; 493*cdf0e10cSrcweir delete[] pNodes; 494*cdf0e10cSrcweir pNodes = pNewNodes; 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir //------------------------------------------------------------------------ 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir /************************************************************************* 501*cdf0e10cSrcweir |* 502*cdf0e10cSrcweir |* DbgCheckContainer() 503*cdf0e10cSrcweir |* 504*cdf0e10cSrcweir |* Beschreibung Pruefung eines Container fuer Debug-Utilities 505*cdf0e10cSrcweir |* Ersterstellung MI 30.01.92 506*cdf0e10cSrcweir |* Letzte Aenderung TH 24.01.96 507*cdf0e10cSrcweir |* 508*cdf0e10cSrcweir *************************************************************************/ 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir #ifdef DBG_UTIL 511*cdf0e10cSrcweir const char* Container::DbgCheckContainer( const void* pCont ) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir Container* p = (Container*)pCont; 514*cdf0e10cSrcweir 515*cdf0e10cSrcweir if ( p->nCount && (!p->pFirstBlock || !p->pLastBlock || !p->pCurBlock) ) 516*cdf0e10cSrcweir return "nCount > 0 but no CBlocks"; 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir return NULL; 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir #endif 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir /************************************************************************* 523*cdf0e10cSrcweir |* 524*cdf0e10cSrcweir |* ImpCopyContainer() 525*cdf0e10cSrcweir |* 526*cdf0e10cSrcweir |* Beschreibung Kopiert alle Daten des Containers 527*cdf0e10cSrcweir |* Ersterstellung TH 24.01.96 528*cdf0e10cSrcweir |* Letzte Aenderung TH 24.01.96 529*cdf0e10cSrcweir |* 530*cdf0e10cSrcweir *************************************************************************/ 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir void Container::ImpCopyContainer( const Container* pCont2 ) 533*cdf0e10cSrcweir { 534*cdf0e10cSrcweir // Werte vom uebergebenen Container uebernehmen 535*cdf0e10cSrcweir nCount = pCont2->nCount; 536*cdf0e10cSrcweir nCurIndex = pCont2->nCurIndex; 537*cdf0e10cSrcweir nInitSize = pCont2->nInitSize; 538*cdf0e10cSrcweir nReSize = pCont2->nReSize; 539*cdf0e10cSrcweir nBlockSize = pCont2->nBlockSize; 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir // Alle Bloecke kopieren 542*cdf0e10cSrcweir if ( pCont2->nCount ) 543*cdf0e10cSrcweir { 544*cdf0e10cSrcweir CBlock* pBlock1; 545*cdf0e10cSrcweir CBlock* pBlock2; 546*cdf0e10cSrcweir CBlock* pTempBlock; 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir // Erstmal ersten Block kopieren 549*cdf0e10cSrcweir pBlock2 = pCont2->pFirstBlock; 550*cdf0e10cSrcweir pFirstBlock = new CBlock( *pBlock2, NULL ); 551*cdf0e10cSrcweir // Ist erster Block der Current-Block, dann Current-Block setzen 552*cdf0e10cSrcweir if ( pBlock2 == pCont2->pCurBlock ) 553*cdf0e10cSrcweir pCurBlock = pFirstBlock; 554*cdf0e10cSrcweir pBlock1 = pFirstBlock; 555*cdf0e10cSrcweir pBlock2 = pBlock2->GetNextBlock(); 556*cdf0e10cSrcweir while ( pBlock2 ) 557*cdf0e10cSrcweir { 558*cdf0e10cSrcweir // Neuen Block anlegen und aus der uebergebenen Liste kopieren 559*cdf0e10cSrcweir pTempBlock = new CBlock( *pBlock2, pBlock1 ); 560*cdf0e10cSrcweir pBlock1->SetNextBlock( pTempBlock ); 561*cdf0e10cSrcweir pBlock1 = pTempBlock; 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir // Current-Block beruecksichtigen 564*cdf0e10cSrcweir if ( pBlock2 == pCont2->pCurBlock ) 565*cdf0e10cSrcweir pCurBlock = pBlock1; 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir // Auf naechsten Block weitersetzen 568*cdf0e10cSrcweir pBlock2 = pBlock2->GetNextBlock(); 569*cdf0e10cSrcweir } 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir // Letzten Block setzen 572*cdf0e10cSrcweir pLastBlock = pBlock1; 573*cdf0e10cSrcweir } 574*cdf0e10cSrcweir else 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir pFirstBlock = NULL; 577*cdf0e10cSrcweir pLastBlock = NULL; 578*cdf0e10cSrcweir pCurBlock = NULL; 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir /************************************************************************* 583*cdf0e10cSrcweir |* 584*cdf0e10cSrcweir |* Container::Container() 585*cdf0e10cSrcweir |* 586*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 587*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 588*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 589*cdf0e10cSrcweir |* 590*cdf0e10cSrcweir *************************************************************************/ 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir Container::Container( sal_uInt16 _nBlockSize, sal_uInt16 _nInitSize, sal_uInt16 _nReSize ) 593*cdf0e10cSrcweir { 594*cdf0e10cSrcweir DBG_CTOR( Container, DbgCheckContainer ); 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir // BlockSize muss mindestens 4 sein und kleiner als 64 KB 597*cdf0e10cSrcweir if ( _nBlockSize < 4 ) 598*cdf0e10cSrcweir nBlockSize = 4; 599*cdf0e10cSrcweir else 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir if ( _nBlockSize < CONTAINER_MAXBLOCKSIZE ) 602*cdf0e10cSrcweir nBlockSize = _nBlockSize; 603*cdf0e10cSrcweir else 604*cdf0e10cSrcweir nBlockSize = CONTAINER_MAXBLOCKSIZE; 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir // ReSize muss mindestens 2 sein und kleiner als BlockSize 608*cdf0e10cSrcweir if ( _nReSize >= nBlockSize ) 609*cdf0e10cSrcweir nReSize = nBlockSize; 610*cdf0e10cSrcweir else 611*cdf0e10cSrcweir { 612*cdf0e10cSrcweir if ( _nReSize < 2 ) 613*cdf0e10cSrcweir nReSize = 2; 614*cdf0e10cSrcweir else 615*cdf0e10cSrcweir nReSize = _nReSize; 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir // BlockSize muss ein vielfaches der Resizegroesse sein 618*cdf0e10cSrcweir if ( nBlockSize % nReSize ) 619*cdf0e10cSrcweir nBlockSize -= nReSize - (nBlockSize % nReSize); 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir // InitSize muss groesser gleich ReSize sein und kleiner als BlockSize 623*cdf0e10cSrcweir if ( _nInitSize <= nReSize ) 624*cdf0e10cSrcweir nInitSize = nReSize; 625*cdf0e10cSrcweir else 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir if ( _nInitSize >= nBlockSize ) 628*cdf0e10cSrcweir nInitSize = nBlockSize; 629*cdf0e10cSrcweir else 630*cdf0e10cSrcweir { 631*cdf0e10cSrcweir nInitSize = _nInitSize; 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir // InitSize muss ein vielfaches der Resizegroesse sein 634*cdf0e10cSrcweir if ( nInitSize % nReSize ) 635*cdf0e10cSrcweir nInitSize -= nReSize - (nInitSize % nReSize); 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir // Werte initialisieren 640*cdf0e10cSrcweir pFirstBlock = NULL; 641*cdf0e10cSrcweir pLastBlock = NULL; 642*cdf0e10cSrcweir pCurBlock = NULL; 643*cdf0e10cSrcweir nCount = 0; 644*cdf0e10cSrcweir nCurIndex = 0; 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir /************************************************************************* 648*cdf0e10cSrcweir |* 649*cdf0e10cSrcweir |* Container::Container() 650*cdf0e10cSrcweir |* 651*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 652*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 653*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 654*cdf0e10cSrcweir |* 655*cdf0e10cSrcweir *************************************************************************/ 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir Container::Container( sal_uIntPtr nSize ) 658*cdf0e10cSrcweir { 659*cdf0e10cSrcweir DBG_CTOR( Container, DbgCheckContainer ); 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir nCount = nSize; 662*cdf0e10cSrcweir nCurIndex = 0; 663*cdf0e10cSrcweir nBlockSize = CONTAINER_MAXBLOCKSIZE; 664*cdf0e10cSrcweir nInitSize = 1; 665*cdf0e10cSrcweir nReSize = 1; 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir if ( !nSize ) 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir pFirstBlock = NULL; 670*cdf0e10cSrcweir pLastBlock = NULL; 671*cdf0e10cSrcweir pCurBlock = NULL; 672*cdf0e10cSrcweir } 673*cdf0e10cSrcweir else 674*cdf0e10cSrcweir { 675*cdf0e10cSrcweir // Muss mehr als ein Block angelegt werden 676*cdf0e10cSrcweir if ( nSize <= nBlockSize ) 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir pFirstBlock = new CBlock( (sal_uInt16)nSize, NULL ); 679*cdf0e10cSrcweir pLastBlock = pFirstBlock; 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir else 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir CBlock* pBlock1; 684*cdf0e10cSrcweir CBlock* pBlock2; 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir pFirstBlock = new CBlock( nBlockSize, NULL ); 687*cdf0e10cSrcweir pBlock1 = pFirstBlock; 688*cdf0e10cSrcweir nSize -= nBlockSize; 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir // Solange die Blockgroesse ueberschritten wird, neue Bloecke anlegen 691*cdf0e10cSrcweir while ( nSize > nBlockSize ) 692*cdf0e10cSrcweir { 693*cdf0e10cSrcweir pBlock2 = new CBlock( nBlockSize, pBlock1 ); 694*cdf0e10cSrcweir pBlock1->SetNextBlock( pBlock2 ); 695*cdf0e10cSrcweir pBlock1 = pBlock2; 696*cdf0e10cSrcweir nSize -= nBlockSize; 697*cdf0e10cSrcweir } 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir pLastBlock = new CBlock( (sal_uInt16)nSize, pBlock1 ); 700*cdf0e10cSrcweir pBlock1->SetNextBlock( pLastBlock ); 701*cdf0e10cSrcweir } 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir pCurBlock = pFirstBlock; 704*cdf0e10cSrcweir } 705*cdf0e10cSrcweir } 706*cdf0e10cSrcweir 707*cdf0e10cSrcweir /************************************************************************* 708*cdf0e10cSrcweir |* 709*cdf0e10cSrcweir |* Container::Container() 710*cdf0e10cSrcweir |* 711*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 712*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 713*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 714*cdf0e10cSrcweir |* 715*cdf0e10cSrcweir *************************************************************************/ 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir Container::Container( const Container& r ) 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir DBG_CTOR( Container, DbgCheckContainer ); 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir // Daten kopieren 722*cdf0e10cSrcweir ImpCopyContainer( &r ); 723*cdf0e10cSrcweir } 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir /************************************************************************* 726*cdf0e10cSrcweir |* 727*cdf0e10cSrcweir |* Container::~Container() 728*cdf0e10cSrcweir |* 729*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 730*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 731*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 732*cdf0e10cSrcweir |* 733*cdf0e10cSrcweir *************************************************************************/ 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir Container::~Container() 736*cdf0e10cSrcweir { 737*cdf0e10cSrcweir DBG_DTOR( Container, DbgCheckContainer ); 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir // Alle Bloecke loeschen 740*cdf0e10cSrcweir CBlock* pBlock = pFirstBlock; 741*cdf0e10cSrcweir while ( pBlock ) 742*cdf0e10cSrcweir { 743*cdf0e10cSrcweir CBlock* pTemp = pBlock->GetNextBlock(); 744*cdf0e10cSrcweir delete pBlock; 745*cdf0e10cSrcweir pBlock = pTemp; 746*cdf0e10cSrcweir } 747*cdf0e10cSrcweir } 748*cdf0e10cSrcweir 749*cdf0e10cSrcweir /************************************************************************* 750*cdf0e10cSrcweir |* 751*cdf0e10cSrcweir |* Container::ImpInsert() 752*cdf0e10cSrcweir |* 753*cdf0e10cSrcweir |* Beschreibung Interne Methode zum Einfuegen eines Pointers 754*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 755*cdf0e10cSrcweir |* Letzte Aenderung DV 01.07.97 756*cdf0e10cSrcweir |* 757*cdf0e10cSrcweir *************************************************************************/ 758*cdf0e10cSrcweir 759*cdf0e10cSrcweir void Container::ImpInsert( void* p, CBlock* pBlock, sal_uInt16 nIndex ) 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir if ( !nCount ) 764*cdf0e10cSrcweir { 765*cdf0e10cSrcweir if ( !pBlock ) 766*cdf0e10cSrcweir { 767*cdf0e10cSrcweir pFirstBlock = new CBlock( nInitSize, NULL, NULL ); 768*cdf0e10cSrcweir pLastBlock = pFirstBlock; 769*cdf0e10cSrcweir pCurBlock = pFirstBlock; 770*cdf0e10cSrcweir } 771*cdf0e10cSrcweir pFirstBlock->Insert( p, nIndex, nReSize ); 772*cdf0e10cSrcweir } 773*cdf0e10cSrcweir else 774*cdf0e10cSrcweir { 775*cdf0e10cSrcweir // Ist im Block die maximale Blockgroesse erreicht, 776*cdf0e10cSrcweir // dann neuen Block anlegen 777*cdf0e10cSrcweir if ( pBlock->Count() == nBlockSize ) 778*cdf0e10cSrcweir { 779*cdf0e10cSrcweir // Block auftrennen 780*cdf0e10cSrcweir CBlock* pNewBlock = pBlock->Split( p, nIndex, nReSize ); 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir // Wurde Block dahinter angehaegnt 783*cdf0e10cSrcweir if ( pBlock->pNext == pNewBlock ) 784*cdf0e10cSrcweir { 785*cdf0e10cSrcweir // Gegebenenfalls LastBlock anpassen 786*cdf0e10cSrcweir if ( pBlock == pLastBlock ) 787*cdf0e10cSrcweir pLastBlock = pNewBlock; 788*cdf0e10cSrcweir 789*cdf0e10cSrcweir // Current-Position nachfuehren 790*cdf0e10cSrcweir if ( pBlock == pCurBlock ) 791*cdf0e10cSrcweir { 792*cdf0e10cSrcweir if ( pBlock->nCount <= nCurIndex ) 793*cdf0e10cSrcweir { 794*cdf0e10cSrcweir if ( nIndex <= nCurIndex ) 795*cdf0e10cSrcweir nCurIndex++; 796*cdf0e10cSrcweir pCurBlock = pNewBlock; 797*cdf0e10cSrcweir nCurIndex = nCurIndex - pBlock->nCount; // MSVC warns here if += is used 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir } 800*cdf0e10cSrcweir } 801*cdf0e10cSrcweir else 802*cdf0e10cSrcweir { 803*cdf0e10cSrcweir // Gegebenenfalls FirstBlock anpassen 804*cdf0e10cSrcweir if ( pBlock == pFirstBlock ) 805*cdf0e10cSrcweir pFirstBlock = pNewBlock; 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir // Current-Position nachfuehren 808*cdf0e10cSrcweir if ( pBlock == pCurBlock ) 809*cdf0e10cSrcweir { 810*cdf0e10cSrcweir if ( nIndex <= nCurIndex ) 811*cdf0e10cSrcweir nCurIndex++; 812*cdf0e10cSrcweir if ( pNewBlock->nCount <= nCurIndex ) 813*cdf0e10cSrcweir nCurIndex = nCurIndex - pNewBlock->nCount; // MSVC warns here if += is used 814*cdf0e10cSrcweir else 815*cdf0e10cSrcweir pCurBlock = pNewBlock; 816*cdf0e10cSrcweir } 817*cdf0e10cSrcweir } 818*cdf0e10cSrcweir } 819*cdf0e10cSrcweir else 820*cdf0e10cSrcweir { 821*cdf0e10cSrcweir // Sonst reicht normales einfuegen in den Block 822*cdf0e10cSrcweir pBlock->Insert( p, nIndex, nReSize ); 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir // Current-Position nachfuehren 825*cdf0e10cSrcweir if ( (pBlock == pCurBlock) && (nIndex <= nCurIndex) ) 826*cdf0e10cSrcweir nCurIndex++; 827*cdf0e10cSrcweir } 828*cdf0e10cSrcweir } 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir // Ein neues Item im Container 831*cdf0e10cSrcweir nCount++; 832*cdf0e10cSrcweir } 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir /************************************************************************* 835*cdf0e10cSrcweir |* 836*cdf0e10cSrcweir |* Container::Insert() 837*cdf0e10cSrcweir |* 838*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 839*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 840*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 841*cdf0e10cSrcweir |* 842*cdf0e10cSrcweir *************************************************************************/ 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir void Container::Insert( void* p ) 845*cdf0e10cSrcweir { 846*cdf0e10cSrcweir ImpInsert( p, pCurBlock, nCurIndex ); 847*cdf0e10cSrcweir } 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir /************************************************************************* 850*cdf0e10cSrcweir |* 851*cdf0e10cSrcweir |* Container::Insert() 852*cdf0e10cSrcweir |* 853*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 854*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 855*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 856*cdf0e10cSrcweir |* 857*cdf0e10cSrcweir *************************************************************************/ 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir void Container::Insert( void* p, sal_uIntPtr nIndex ) 860*cdf0e10cSrcweir { 861*cdf0e10cSrcweir if ( nCount <= nIndex ) 862*cdf0e10cSrcweir { 863*cdf0e10cSrcweir if ( pLastBlock ) 864*cdf0e10cSrcweir ImpInsert( p, pLastBlock, pLastBlock->Count() ); 865*cdf0e10cSrcweir else 866*cdf0e10cSrcweir ImpInsert( p, NULL, 0 ); 867*cdf0e10cSrcweir } 868*cdf0e10cSrcweir else 869*cdf0e10cSrcweir { 870*cdf0e10cSrcweir // Block suchen 871*cdf0e10cSrcweir CBlock* pTemp = pFirstBlock; 872*cdf0e10cSrcweir while ( pTemp->Count() < nIndex ) 873*cdf0e10cSrcweir { 874*cdf0e10cSrcweir nIndex -= pTemp->Count(); 875*cdf0e10cSrcweir pTemp = pTemp->GetNextBlock(); 876*cdf0e10cSrcweir } 877*cdf0e10cSrcweir 878*cdf0e10cSrcweir ImpInsert( p, pTemp, (sal_uInt16)nIndex ); 879*cdf0e10cSrcweir } 880*cdf0e10cSrcweir } 881*cdf0e10cSrcweir 882*cdf0e10cSrcweir /************************************************************************* 883*cdf0e10cSrcweir |* 884*cdf0e10cSrcweir |* Container::Insert() 885*cdf0e10cSrcweir |* 886*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 887*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 888*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 889*cdf0e10cSrcweir |* 890*cdf0e10cSrcweir *************************************************************************/ 891*cdf0e10cSrcweir 892*cdf0e10cSrcweir void Container::Insert( void* pNew, void* pOld ) 893*cdf0e10cSrcweir { 894*cdf0e10cSrcweir sal_uIntPtr nIndex = GetPos( pOld ); 895*cdf0e10cSrcweir if ( nIndex != CONTAINER_ENTRY_NOTFOUND ) 896*cdf0e10cSrcweir Insert( pNew, nIndex ); 897*cdf0e10cSrcweir } 898*cdf0e10cSrcweir 899*cdf0e10cSrcweir /************************************************************************* 900*cdf0e10cSrcweir |* 901*cdf0e10cSrcweir |* Container::ImpRemove() 902*cdf0e10cSrcweir |* 903*cdf0e10cSrcweir |* Beschreibung Interne Methode zum Entfernen eines Pointers 904*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 905*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 906*cdf0e10cSrcweir |* 907*cdf0e10cSrcweir *************************************************************************/ 908*cdf0e10cSrcweir 909*cdf0e10cSrcweir void* Container::ImpRemove( CBlock* pBlock, sal_uInt16 nIndex ) 910*cdf0e10cSrcweir { 911*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 912*cdf0e10cSrcweir 913*cdf0e10cSrcweir void* pOld; 914*cdf0e10cSrcweir 915*cdf0e10cSrcweir // Ist Liste danach leer 916*cdf0e10cSrcweir if ( nCount == 1 ) 917*cdf0e10cSrcweir { 918*cdf0e10cSrcweir // Block und CurIndex zuruecksetzen 919*cdf0e10cSrcweir pOld = pBlock->GetObject( nIndex ); 920*cdf0e10cSrcweir pBlock->Reset(); 921*cdf0e10cSrcweir nCurIndex = 0; 922*cdf0e10cSrcweir } 923*cdf0e10cSrcweir else 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir // Ist Block nach Remove leer 926*cdf0e10cSrcweir if ( pBlock->Count() == 1 ) 927*cdf0e10cSrcweir { 928*cdf0e10cSrcweir // dann Block entfernen und Block-Pointer umsetzen 929*cdf0e10cSrcweir if ( pBlock->GetPrevBlock() ) 930*cdf0e10cSrcweir (pBlock->GetPrevBlock())->SetNextBlock( pBlock->GetNextBlock() ); 931*cdf0e10cSrcweir else 932*cdf0e10cSrcweir pFirstBlock = pBlock->GetNextBlock(); 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir if ( pBlock->GetNextBlock() ) 935*cdf0e10cSrcweir (pBlock->GetNextBlock())->SetPrevBlock( pBlock->GetPrevBlock() ); 936*cdf0e10cSrcweir else 937*cdf0e10cSrcweir pLastBlock = pBlock->GetPrevBlock(); 938*cdf0e10cSrcweir 939*cdf0e10cSrcweir // Current-Position nachfuehren 940*cdf0e10cSrcweir if ( pBlock == pCurBlock ) 941*cdf0e10cSrcweir { 942*cdf0e10cSrcweir if ( pBlock->GetNextBlock() ) 943*cdf0e10cSrcweir { 944*cdf0e10cSrcweir pCurBlock = pBlock->GetNextBlock(); 945*cdf0e10cSrcweir nCurIndex = 0; 946*cdf0e10cSrcweir } 947*cdf0e10cSrcweir else 948*cdf0e10cSrcweir { 949*cdf0e10cSrcweir pCurBlock = pBlock->GetPrevBlock(); 950*cdf0e10cSrcweir nCurIndex = pCurBlock->Count()-1; 951*cdf0e10cSrcweir } 952*cdf0e10cSrcweir } 953*cdf0e10cSrcweir 954*cdf0e10cSrcweir pOld = pBlock->GetObject( nIndex ); 955*cdf0e10cSrcweir delete pBlock; 956*cdf0e10cSrcweir } 957*cdf0e10cSrcweir else 958*cdf0e10cSrcweir { 959*cdf0e10cSrcweir // Sonst Item aus dem Block entfernen 960*cdf0e10cSrcweir pOld = pBlock->Remove( nIndex, nReSize ); 961*cdf0e10cSrcweir 962*cdf0e10cSrcweir // Current-Position nachfuehren 963*cdf0e10cSrcweir if ( (pBlock == pCurBlock) && 964*cdf0e10cSrcweir ((nIndex < nCurIndex) || ((nCurIndex == pBlock->Count()) && nCurIndex)) ) 965*cdf0e10cSrcweir nCurIndex--; 966*cdf0e10cSrcweir } 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir // Jetzt gibt es ein Item weniger 970*cdf0e10cSrcweir nCount--; 971*cdf0e10cSrcweir 972*cdf0e10cSrcweir // Und den Pointer zurueckgeben, der entfernt wurde 973*cdf0e10cSrcweir return pOld; 974*cdf0e10cSrcweir } 975*cdf0e10cSrcweir 976*cdf0e10cSrcweir /************************************************************************* 977*cdf0e10cSrcweir |* 978*cdf0e10cSrcweir |* Container::Remove() 979*cdf0e10cSrcweir |* 980*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 981*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 982*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 983*cdf0e10cSrcweir |* 984*cdf0e10cSrcweir *************************************************************************/ 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir void* Container::Remove() 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir // Wenn kein Item vorhanden ist, NULL zurueckgeben 989*cdf0e10cSrcweir if ( !nCount ) 990*cdf0e10cSrcweir return NULL; 991*cdf0e10cSrcweir else 992*cdf0e10cSrcweir return ImpRemove( pCurBlock, nCurIndex ); 993*cdf0e10cSrcweir } 994*cdf0e10cSrcweir 995*cdf0e10cSrcweir /************************************************************************* 996*cdf0e10cSrcweir |* 997*cdf0e10cSrcweir |* Container::Remove() 998*cdf0e10cSrcweir |* 999*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1000*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1001*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1002*cdf0e10cSrcweir |* 1003*cdf0e10cSrcweir *************************************************************************/ 1004*cdf0e10cSrcweir 1005*cdf0e10cSrcweir void* Container::Remove( sal_uIntPtr nIndex ) 1006*cdf0e10cSrcweir { 1007*cdf0e10cSrcweir // Ist Index nicht innerhalb des Containers, dann NULL zurueckgeben 1008*cdf0e10cSrcweir if ( nCount <= nIndex ) 1009*cdf0e10cSrcweir return NULL; 1010*cdf0e10cSrcweir else 1011*cdf0e10cSrcweir { 1012*cdf0e10cSrcweir // Block suchen 1013*cdf0e10cSrcweir CBlock* pTemp = pFirstBlock; 1014*cdf0e10cSrcweir while ( pTemp->Count() <= nIndex ) 1015*cdf0e10cSrcweir { 1016*cdf0e10cSrcweir nIndex -= pTemp->Count(); 1017*cdf0e10cSrcweir pTemp = pTemp->GetNextBlock(); 1018*cdf0e10cSrcweir } 1019*cdf0e10cSrcweir 1020*cdf0e10cSrcweir return ImpRemove( pTemp, (sal_uInt16)nIndex ); 1021*cdf0e10cSrcweir } 1022*cdf0e10cSrcweir } 1023*cdf0e10cSrcweir 1024*cdf0e10cSrcweir /************************************************************************* 1025*cdf0e10cSrcweir |* 1026*cdf0e10cSrcweir |* Container::Replace() 1027*cdf0e10cSrcweir |* 1028*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1029*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1030*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1031*cdf0e10cSrcweir |* 1032*cdf0e10cSrcweir *************************************************************************/ 1033*cdf0e10cSrcweir 1034*cdf0e10cSrcweir void* Container::Replace( void* p ) 1035*cdf0e10cSrcweir { 1036*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1037*cdf0e10cSrcweir 1038*cdf0e10cSrcweir if ( !nCount ) 1039*cdf0e10cSrcweir return NULL; 1040*cdf0e10cSrcweir else 1041*cdf0e10cSrcweir return pCurBlock->Replace( p, nCurIndex ); 1042*cdf0e10cSrcweir } 1043*cdf0e10cSrcweir 1044*cdf0e10cSrcweir /************************************************************************* 1045*cdf0e10cSrcweir |* 1046*cdf0e10cSrcweir |* Container::Replace() 1047*cdf0e10cSrcweir |* 1048*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1049*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1050*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1051*cdf0e10cSrcweir |* 1052*cdf0e10cSrcweir *************************************************************************/ 1053*cdf0e10cSrcweir 1054*cdf0e10cSrcweir void* Container::Replace( void* p, sal_uIntPtr nIndex ) 1055*cdf0e10cSrcweir { 1056*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1057*cdf0e10cSrcweir 1058*cdf0e10cSrcweir // Ist Index nicht innerhalb des Containers, dann NULL zurueckgeben 1059*cdf0e10cSrcweir if ( nCount <= nIndex ) 1060*cdf0e10cSrcweir return NULL; 1061*cdf0e10cSrcweir else 1062*cdf0e10cSrcweir { 1063*cdf0e10cSrcweir // Block suchen 1064*cdf0e10cSrcweir CBlock* pTemp = pFirstBlock; 1065*cdf0e10cSrcweir while ( pTemp->Count() <= nIndex ) 1066*cdf0e10cSrcweir { 1067*cdf0e10cSrcweir nIndex -= pTemp->Count(); 1068*cdf0e10cSrcweir pTemp = pTemp->GetNextBlock(); 1069*cdf0e10cSrcweir } 1070*cdf0e10cSrcweir 1071*cdf0e10cSrcweir return pTemp->Replace( p, (sal_uInt16)nIndex ); 1072*cdf0e10cSrcweir } 1073*cdf0e10cSrcweir } 1074*cdf0e10cSrcweir 1075*cdf0e10cSrcweir /************************************************************************* 1076*cdf0e10cSrcweir |* 1077*cdf0e10cSrcweir |* Container::SetSize() 1078*cdf0e10cSrcweir |* 1079*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1080*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1081*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1082*cdf0e10cSrcweir |* 1083*cdf0e10cSrcweir *************************************************************************/ 1084*cdf0e10cSrcweir 1085*cdf0e10cSrcweir void Container::SetSize( sal_uIntPtr nNewSize ) 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1088*cdf0e10cSrcweir 1089*cdf0e10cSrcweir if ( nNewSize ) 1090*cdf0e10cSrcweir { 1091*cdf0e10cSrcweir // Unterscheiden sich die Groessen 1092*cdf0e10cSrcweir if ( nNewSize != nCount ) 1093*cdf0e10cSrcweir { 1094*cdf0e10cSrcweir CBlock* pTemp; 1095*cdf0e10cSrcweir sal_uIntPtr nTemp; 1096*cdf0e10cSrcweir 1097*cdf0e10cSrcweir // Wird verkleinert 1098*cdf0e10cSrcweir if ( nNewSize < nCount ) 1099*cdf0e10cSrcweir { 1100*cdf0e10cSrcweir pTemp = pFirstBlock; 1101*cdf0e10cSrcweir nTemp = 0; 1102*cdf0e10cSrcweir while ( (nTemp+pTemp->Count()) < nNewSize ) 1103*cdf0e10cSrcweir { 1104*cdf0e10cSrcweir nTemp += pTemp->Count(); 1105*cdf0e10cSrcweir pTemp = pTemp->GetNextBlock(); 1106*cdf0e10cSrcweir } 1107*cdf0e10cSrcweir 1108*cdf0e10cSrcweir // Alle folgenden Bloecke loeschen 1109*cdf0e10cSrcweir sal_Bool bLast = sal_False; 1110*cdf0e10cSrcweir CBlock* pDelNext; 1111*cdf0e10cSrcweir CBlock* pDelBlock = pTemp->GetNextBlock(); 1112*cdf0e10cSrcweir while ( pDelBlock ) 1113*cdf0e10cSrcweir { 1114*cdf0e10cSrcweir // Muss CurrentBlock umgesetzt werden 1115*cdf0e10cSrcweir if ( pDelBlock == pCurBlock ) 1116*cdf0e10cSrcweir bLast = sal_True; 1117*cdf0e10cSrcweir pDelNext = pDelBlock->GetNextBlock(); 1118*cdf0e10cSrcweir delete pDelBlock; 1119*cdf0e10cSrcweir pDelBlock = pDelNext; 1120*cdf0e10cSrcweir } 1121*cdf0e10cSrcweir 1122*cdf0e10cSrcweir // Block in der Groesse anpassen, oder bei Groesse 0 loeschen 1123*cdf0e10cSrcweir if ( nNewSize > nTemp ) 1124*cdf0e10cSrcweir { 1125*cdf0e10cSrcweir pLastBlock = pTemp; 1126*cdf0e10cSrcweir pTemp->SetNextBlock( NULL ); 1127*cdf0e10cSrcweir pTemp->SetSize( (sal_uInt16)(nNewSize-nTemp) ); 1128*cdf0e10cSrcweir } 1129*cdf0e10cSrcweir else 1130*cdf0e10cSrcweir { 1131*cdf0e10cSrcweir pLastBlock = pTemp->GetPrevBlock(); 1132*cdf0e10cSrcweir pLastBlock->SetNextBlock( NULL ); 1133*cdf0e10cSrcweir delete pTemp; 1134*cdf0e10cSrcweir } 1135*cdf0e10cSrcweir 1136*cdf0e10cSrcweir nCount = nNewSize; 1137*cdf0e10cSrcweir if ( bLast ) 1138*cdf0e10cSrcweir { 1139*cdf0e10cSrcweir pCurBlock = pLastBlock; 1140*cdf0e10cSrcweir nCurIndex = pCurBlock->Count()-1; 1141*cdf0e10cSrcweir } 1142*cdf0e10cSrcweir } 1143*cdf0e10cSrcweir else 1144*cdf0e10cSrcweir { 1145*cdf0e10cSrcweir // Auf den letzen Puffer setzen 1146*cdf0e10cSrcweir pTemp = pLastBlock; 1147*cdf0e10cSrcweir nTemp = nNewSize - nCount; 1148*cdf0e10cSrcweir 1149*cdf0e10cSrcweir if ( !pTemp ) 1150*cdf0e10cSrcweir { 1151*cdf0e10cSrcweir // Muss mehr als ein Block angelegt werden 1152*cdf0e10cSrcweir if ( nNewSize <= nBlockSize ) 1153*cdf0e10cSrcweir { 1154*cdf0e10cSrcweir pFirstBlock = new CBlock( (sal_uInt16)nNewSize, NULL ); 1155*cdf0e10cSrcweir pLastBlock = pFirstBlock; 1156*cdf0e10cSrcweir } 1157*cdf0e10cSrcweir else 1158*cdf0e10cSrcweir { 1159*cdf0e10cSrcweir CBlock* pBlock1; 1160*cdf0e10cSrcweir CBlock* pBlock2; 1161*cdf0e10cSrcweir 1162*cdf0e10cSrcweir pFirstBlock = new CBlock( nBlockSize, NULL ); 1163*cdf0e10cSrcweir pBlock1 = pFirstBlock; 1164*cdf0e10cSrcweir nNewSize -= nBlockSize; 1165*cdf0e10cSrcweir 1166*cdf0e10cSrcweir // Solange die Blockgroesse ueberschritten wird, neue Bloecke anlegen 1167*cdf0e10cSrcweir while ( nNewSize > nBlockSize ) 1168*cdf0e10cSrcweir { 1169*cdf0e10cSrcweir pBlock2 = new CBlock( nBlockSize, pBlock1 ); 1170*cdf0e10cSrcweir pBlock1->SetNextBlock( pBlock2 ); 1171*cdf0e10cSrcweir pBlock1 = pBlock2; 1172*cdf0e10cSrcweir nNewSize -= nBlockSize; 1173*cdf0e10cSrcweir } 1174*cdf0e10cSrcweir 1175*cdf0e10cSrcweir pLastBlock = new CBlock( (sal_uInt16)nNewSize, pBlock1 ); 1176*cdf0e10cSrcweir pBlock1->SetNextBlock( pLastBlock ); 1177*cdf0e10cSrcweir } 1178*cdf0e10cSrcweir 1179*cdf0e10cSrcweir pCurBlock = pFirstBlock; 1180*cdf0e10cSrcweir } 1181*cdf0e10cSrcweir // Reicht es, den letzen Puffer in der Groesse anzupassen 1182*cdf0e10cSrcweir else if ( (nTemp+pTemp->Count()) <= nBlockSize ) 1183*cdf0e10cSrcweir pTemp->SetSize( (sal_uInt16)(nTemp+pTemp->Count()) ); 1184*cdf0e10cSrcweir else 1185*cdf0e10cSrcweir { 1186*cdf0e10cSrcweir // Puffer auf max. Blockgroesse setzen 1187*cdf0e10cSrcweir nTemp -= nBlockSize - pTemp->GetSize(); 1188*cdf0e10cSrcweir pTemp->SetSize( nBlockSize ); 1189*cdf0e10cSrcweir 1190*cdf0e10cSrcweir CBlock* pTemp2; 1191*cdf0e10cSrcweir // Solange die Blockgroesse ueberschritten wird, 1192*cdf0e10cSrcweir // neue Bloecke anlegen 1193*cdf0e10cSrcweir while ( nTemp > nBlockSize ) 1194*cdf0e10cSrcweir { 1195*cdf0e10cSrcweir pTemp2 = new CBlock( nBlockSize, pTemp ); 1196*cdf0e10cSrcweir pTemp->SetNextBlock( pTemp2 ); 1197*cdf0e10cSrcweir pTemp = pTemp2; 1198*cdf0e10cSrcweir nTemp -= nBlockSize; 1199*cdf0e10cSrcweir } 1200*cdf0e10cSrcweir 1201*cdf0e10cSrcweir // Den letzten Block anlegen 1202*cdf0e10cSrcweir if ( nTemp ) 1203*cdf0e10cSrcweir { 1204*cdf0e10cSrcweir pLastBlock = new CBlock( (sal_uInt16)nTemp, pTemp ); 1205*cdf0e10cSrcweir pTemp->SetNextBlock( pLastBlock ); 1206*cdf0e10cSrcweir } 1207*cdf0e10cSrcweir else 1208*cdf0e10cSrcweir pLastBlock = pTemp; 1209*cdf0e10cSrcweir } 1210*cdf0e10cSrcweir 1211*cdf0e10cSrcweir nCount = nNewSize; 1212*cdf0e10cSrcweir } 1213*cdf0e10cSrcweir } 1214*cdf0e10cSrcweir } 1215*cdf0e10cSrcweir else 1216*cdf0e10cSrcweir Clear(); 1217*cdf0e10cSrcweir } 1218*cdf0e10cSrcweir 1219*cdf0e10cSrcweir /************************************************************************* 1220*cdf0e10cSrcweir |* 1221*cdf0e10cSrcweir |* Container::Clear() 1222*cdf0e10cSrcweir |* 1223*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1224*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1225*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1226*cdf0e10cSrcweir |* 1227*cdf0e10cSrcweir *************************************************************************/ 1228*cdf0e10cSrcweir 1229*cdf0e10cSrcweir void Container::Clear() 1230*cdf0e10cSrcweir { 1231*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1232*cdf0e10cSrcweir 1233*cdf0e10cSrcweir // Erst alle Bloecke loeschen 1234*cdf0e10cSrcweir CBlock* pBlock = pFirstBlock; 1235*cdf0e10cSrcweir while ( pBlock ) 1236*cdf0e10cSrcweir { 1237*cdf0e10cSrcweir CBlock* pTemp = pBlock->GetNextBlock(); 1238*cdf0e10cSrcweir delete pBlock; 1239*cdf0e10cSrcweir pBlock = pTemp; 1240*cdf0e10cSrcweir } 1241*cdf0e10cSrcweir 1242*cdf0e10cSrcweir // Werte zuruecksetzen 1243*cdf0e10cSrcweir pFirstBlock = NULL; 1244*cdf0e10cSrcweir pLastBlock = NULL; 1245*cdf0e10cSrcweir pCurBlock = NULL; 1246*cdf0e10cSrcweir nCount = 0; 1247*cdf0e10cSrcweir nCurIndex = 0; 1248*cdf0e10cSrcweir } 1249*cdf0e10cSrcweir 1250*cdf0e10cSrcweir /************************************************************************* 1251*cdf0e10cSrcweir |* 1252*cdf0e10cSrcweir |* Container::GetCurObject() 1253*cdf0e10cSrcweir |* 1254*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1255*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1256*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1257*cdf0e10cSrcweir |* 1258*cdf0e10cSrcweir *************************************************************************/ 1259*cdf0e10cSrcweir 1260*cdf0e10cSrcweir void* Container::GetCurObject() const 1261*cdf0e10cSrcweir { 1262*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1263*cdf0e10cSrcweir 1264*cdf0e10cSrcweir // NULL, wenn Container leer 1265*cdf0e10cSrcweir if ( !nCount ) 1266*cdf0e10cSrcweir return NULL; 1267*cdf0e10cSrcweir else 1268*cdf0e10cSrcweir return pCurBlock->GetObject( nCurIndex ); 1269*cdf0e10cSrcweir } 1270*cdf0e10cSrcweir 1271*cdf0e10cSrcweir /************************************************************************* 1272*cdf0e10cSrcweir |* 1273*cdf0e10cSrcweir |* Container::GetCurPos() 1274*cdf0e10cSrcweir |* 1275*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1276*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1277*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1278*cdf0e10cSrcweir |* 1279*cdf0e10cSrcweir *************************************************************************/ 1280*cdf0e10cSrcweir 1281*cdf0e10cSrcweir sal_uIntPtr Container::GetCurPos() const 1282*cdf0e10cSrcweir { 1283*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1284*cdf0e10cSrcweir 1285*cdf0e10cSrcweir // CONTAINER_ENTRY_NOTFOUND, wenn Container leer 1286*cdf0e10cSrcweir if ( !nCount ) 1287*cdf0e10cSrcweir return CONTAINER_ENTRY_NOTFOUND; 1288*cdf0e10cSrcweir else 1289*cdf0e10cSrcweir { 1290*cdf0e10cSrcweir // Block suchen 1291*cdf0e10cSrcweir CBlock* pTemp = pFirstBlock; 1292*cdf0e10cSrcweir sal_uIntPtr nTemp = 0; 1293*cdf0e10cSrcweir while ( pTemp != pCurBlock ) 1294*cdf0e10cSrcweir { 1295*cdf0e10cSrcweir nTemp += pTemp->Count(); 1296*cdf0e10cSrcweir pTemp = pTemp->GetNextBlock(); 1297*cdf0e10cSrcweir } 1298*cdf0e10cSrcweir 1299*cdf0e10cSrcweir return nTemp+nCurIndex; 1300*cdf0e10cSrcweir } 1301*cdf0e10cSrcweir } 1302*cdf0e10cSrcweir 1303*cdf0e10cSrcweir /************************************************************************* 1304*cdf0e10cSrcweir |* 1305*cdf0e10cSrcweir |* Container::GetObjectPtr() 1306*cdf0e10cSrcweir |* 1307*cdf0e10cSrcweir |* Beschreibung Interne Methode fuer Referenz-Container 1308*cdf0e10cSrcweir |* Ersterstellung TH 26.01.93 1309*cdf0e10cSrcweir |* Letzte Aenderung TH 26.01.93 1310*cdf0e10cSrcweir |* 1311*cdf0e10cSrcweir *************************************************************************/ 1312*cdf0e10cSrcweir 1313*cdf0e10cSrcweir void** Container::GetObjectPtr( sal_uIntPtr nIndex ) 1314*cdf0e10cSrcweir { 1315*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1316*cdf0e10cSrcweir 1317*cdf0e10cSrcweir // Ist Index nicht innerhalb des Containers, dann NULL zurueckgeben 1318*cdf0e10cSrcweir if ( nCount <= nIndex ) 1319*cdf0e10cSrcweir return NULL; 1320*cdf0e10cSrcweir else 1321*cdf0e10cSrcweir { 1322*cdf0e10cSrcweir // Block suchen 1323*cdf0e10cSrcweir CBlock* pTemp = pFirstBlock; 1324*cdf0e10cSrcweir while ( pTemp->Count() <= nIndex ) 1325*cdf0e10cSrcweir { 1326*cdf0e10cSrcweir nIndex -= pTemp->Count(); 1327*cdf0e10cSrcweir pTemp = pTemp->GetNextBlock(); 1328*cdf0e10cSrcweir } 1329*cdf0e10cSrcweir 1330*cdf0e10cSrcweir // Item innerhalb des gefundenen Blocks zurueckgeben 1331*cdf0e10cSrcweir return pTemp->GetObjectPtr( (sal_uInt16)nIndex ); 1332*cdf0e10cSrcweir } 1333*cdf0e10cSrcweir } 1334*cdf0e10cSrcweir 1335*cdf0e10cSrcweir /************************************************************************* 1336*cdf0e10cSrcweir |* 1337*cdf0e10cSrcweir |* Container::GetObject() 1338*cdf0e10cSrcweir |* 1339*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1340*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1341*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1342*cdf0e10cSrcweir |* 1343*cdf0e10cSrcweir *************************************************************************/ 1344*cdf0e10cSrcweir 1345*cdf0e10cSrcweir void* Container::GetObject( sal_uIntPtr nIndex ) const 1346*cdf0e10cSrcweir { 1347*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1348*cdf0e10cSrcweir 1349*cdf0e10cSrcweir // Ist Index nicht innerhalb des Containers, dann NULL zurueckgeben 1350*cdf0e10cSrcweir if ( nCount <= nIndex ) 1351*cdf0e10cSrcweir return NULL; 1352*cdf0e10cSrcweir else 1353*cdf0e10cSrcweir { 1354*cdf0e10cSrcweir // Block suchen 1355*cdf0e10cSrcweir CBlock* pTemp = pFirstBlock; 1356*cdf0e10cSrcweir while ( pTemp->Count() <= nIndex ) 1357*cdf0e10cSrcweir { 1358*cdf0e10cSrcweir nIndex -= pTemp->Count(); 1359*cdf0e10cSrcweir pTemp = pTemp->GetNextBlock(); 1360*cdf0e10cSrcweir } 1361*cdf0e10cSrcweir 1362*cdf0e10cSrcweir // Item innerhalb des gefundenen Blocks zurueckgeben 1363*cdf0e10cSrcweir return pTemp->GetObject( (sal_uInt16)nIndex ); 1364*cdf0e10cSrcweir } 1365*cdf0e10cSrcweir } 1366*cdf0e10cSrcweir 1367*cdf0e10cSrcweir /************************************************************************* 1368*cdf0e10cSrcweir |* 1369*cdf0e10cSrcweir |* Container::GetPos() 1370*cdf0e10cSrcweir |* 1371*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1372*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1373*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1374*cdf0e10cSrcweir |* 1375*cdf0e10cSrcweir *************************************************************************/ 1376*cdf0e10cSrcweir 1377*cdf0e10cSrcweir sal_uIntPtr Container::GetPos( const void* p ) const 1378*cdf0e10cSrcweir { 1379*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1380*cdf0e10cSrcweir 1381*cdf0e10cSrcweir void** pNodes; 1382*cdf0e10cSrcweir CBlock* pTemp; 1383*cdf0e10cSrcweir sal_uIntPtr nTemp; 1384*cdf0e10cSrcweir sal_uInt16 nBlockCount; 1385*cdf0e10cSrcweir sal_uInt16 i; 1386*cdf0e10cSrcweir 1387*cdf0e10cSrcweir // Block suchen 1388*cdf0e10cSrcweir pTemp = pFirstBlock; 1389*cdf0e10cSrcweir nTemp = 0; 1390*cdf0e10cSrcweir while ( pTemp ) 1391*cdf0e10cSrcweir { 1392*cdf0e10cSrcweir pNodes = pTemp->GetNodes(); 1393*cdf0e10cSrcweir i = 0; 1394*cdf0e10cSrcweir nBlockCount = pTemp->Count(); 1395*cdf0e10cSrcweir while ( i < nBlockCount ) 1396*cdf0e10cSrcweir { 1397*cdf0e10cSrcweir if ( p == *pNodes ) 1398*cdf0e10cSrcweir return nTemp+i; 1399*cdf0e10cSrcweir pNodes++; 1400*cdf0e10cSrcweir i++; 1401*cdf0e10cSrcweir } 1402*cdf0e10cSrcweir nTemp += nBlockCount; 1403*cdf0e10cSrcweir pTemp = pTemp->GetNextBlock(); 1404*cdf0e10cSrcweir } 1405*cdf0e10cSrcweir 1406*cdf0e10cSrcweir return CONTAINER_ENTRY_NOTFOUND; 1407*cdf0e10cSrcweir } 1408*cdf0e10cSrcweir 1409*cdf0e10cSrcweir /************************************************************************* 1410*cdf0e10cSrcweir |* 1411*cdf0e10cSrcweir |* Container::GetPos() 1412*cdf0e10cSrcweir |* 1413*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1414*cdf0e10cSrcweir |* Ersterstellung TH 14.09.94 1415*cdf0e10cSrcweir |* Letzte Aenderung TH 14.09.94 1416*cdf0e10cSrcweir |* 1417*cdf0e10cSrcweir *************************************************************************/ 1418*cdf0e10cSrcweir 1419*cdf0e10cSrcweir sal_uIntPtr Container::GetPos( const void* p, sal_uIntPtr nStartIndex, 1420*cdf0e10cSrcweir sal_Bool bForward ) const 1421*cdf0e10cSrcweir { 1422*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1423*cdf0e10cSrcweir 1424*cdf0e10cSrcweir // Ist Index nicht innerhalb des Containers, dann NOTFOUND zurueckgeben 1425*cdf0e10cSrcweir if ( nCount <= nStartIndex ) 1426*cdf0e10cSrcweir return CONTAINER_ENTRY_NOTFOUND; 1427*cdf0e10cSrcweir else 1428*cdf0e10cSrcweir { 1429*cdf0e10cSrcweir void** pNodes; 1430*cdf0e10cSrcweir sal_uInt16 nBlockCount; 1431*cdf0e10cSrcweir sal_uInt16 i; 1432*cdf0e10cSrcweir 1433*cdf0e10cSrcweir // Block suchen 1434*cdf0e10cSrcweir CBlock* pTemp = pFirstBlock; 1435*cdf0e10cSrcweir sal_uIntPtr nTemp = 0; 1436*cdf0e10cSrcweir while ( nTemp+pTemp->Count() <= nStartIndex ) 1437*cdf0e10cSrcweir { 1438*cdf0e10cSrcweir nTemp += pTemp->Count(); 1439*cdf0e10cSrcweir pTemp = pTemp->GetNextBlock(); 1440*cdf0e10cSrcweir } 1441*cdf0e10cSrcweir 1442*cdf0e10cSrcweir // Jetzt den Pointer suchen 1443*cdf0e10cSrcweir if ( bForward ) 1444*cdf0e10cSrcweir { 1445*cdf0e10cSrcweir // Alle Bloecke durchrsuchen 1446*cdf0e10cSrcweir i = (sal_uInt16)(nStartIndex - nTemp); 1447*cdf0e10cSrcweir pNodes = pTemp->GetObjectPtr( i ); 1448*cdf0e10cSrcweir do 1449*cdf0e10cSrcweir { 1450*cdf0e10cSrcweir nBlockCount = pTemp->Count(); 1451*cdf0e10cSrcweir while ( i < nBlockCount ) 1452*cdf0e10cSrcweir { 1453*cdf0e10cSrcweir if ( p == *pNodes ) 1454*cdf0e10cSrcweir return nTemp+i; 1455*cdf0e10cSrcweir pNodes++; 1456*cdf0e10cSrcweir i++; 1457*cdf0e10cSrcweir } 1458*cdf0e10cSrcweir nTemp += nBlockCount; 1459*cdf0e10cSrcweir pTemp = pTemp->GetNextBlock(); 1460*cdf0e10cSrcweir if ( pTemp ) 1461*cdf0e10cSrcweir { 1462*cdf0e10cSrcweir i = 0; 1463*cdf0e10cSrcweir pNodes = pTemp->GetNodes(); 1464*cdf0e10cSrcweir } 1465*cdf0e10cSrcweir else 1466*cdf0e10cSrcweir break; 1467*cdf0e10cSrcweir } 1468*cdf0e10cSrcweir while ( sal_True ); 1469*cdf0e10cSrcweir } 1470*cdf0e10cSrcweir else 1471*cdf0e10cSrcweir { 1472*cdf0e10cSrcweir // Alle Bloecke durchrsuchen 1473*cdf0e10cSrcweir i = (sal_uInt16)(nStartIndex-nTemp)+1; 1474*cdf0e10cSrcweir pNodes = pTemp->GetObjectPtr( i-1 ); 1475*cdf0e10cSrcweir do 1476*cdf0e10cSrcweir { 1477*cdf0e10cSrcweir do 1478*cdf0e10cSrcweir { 1479*cdf0e10cSrcweir if ( p == *pNodes ) 1480*cdf0e10cSrcweir return nTemp+i-1; 1481*cdf0e10cSrcweir pNodes--; 1482*cdf0e10cSrcweir i--; 1483*cdf0e10cSrcweir } 1484*cdf0e10cSrcweir while ( i ); 1485*cdf0e10cSrcweir nTemp -= pTemp->Count(); 1486*cdf0e10cSrcweir pTemp = pTemp->GetPrevBlock(); 1487*cdf0e10cSrcweir if ( pTemp ) 1488*cdf0e10cSrcweir { 1489*cdf0e10cSrcweir i = pTemp->Count(); 1490*cdf0e10cSrcweir // Leere Bloecke in der Kette darf es nicht geben. Nur 1491*cdf0e10cSrcweir // wenn ein Block existiert, darf dieser leer sein 1492*cdf0e10cSrcweir pNodes = pTemp->GetObjectPtr( i-1 ); 1493*cdf0e10cSrcweir } 1494*cdf0e10cSrcweir else 1495*cdf0e10cSrcweir break; 1496*cdf0e10cSrcweir } 1497*cdf0e10cSrcweir while ( sal_True ); 1498*cdf0e10cSrcweir } 1499*cdf0e10cSrcweir } 1500*cdf0e10cSrcweir 1501*cdf0e10cSrcweir return CONTAINER_ENTRY_NOTFOUND; 1502*cdf0e10cSrcweir } 1503*cdf0e10cSrcweir 1504*cdf0e10cSrcweir /************************************************************************* 1505*cdf0e10cSrcweir |* 1506*cdf0e10cSrcweir |* Container::Seek() 1507*cdf0e10cSrcweir |* 1508*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1509*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1510*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1511*cdf0e10cSrcweir |* 1512*cdf0e10cSrcweir *************************************************************************/ 1513*cdf0e10cSrcweir 1514*cdf0e10cSrcweir void* Container::Seek( sal_uIntPtr nIndex ) 1515*cdf0e10cSrcweir { 1516*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1517*cdf0e10cSrcweir 1518*cdf0e10cSrcweir // Ist der Container leer, dann NULL zurueckgeben 1519*cdf0e10cSrcweir if ( nCount <= nIndex ) 1520*cdf0e10cSrcweir return NULL; 1521*cdf0e10cSrcweir else 1522*cdf0e10cSrcweir { 1523*cdf0e10cSrcweir // Block suchen 1524*cdf0e10cSrcweir CBlock* pTemp = pFirstBlock; 1525*cdf0e10cSrcweir while ( pTemp->Count() <= nIndex ) 1526*cdf0e10cSrcweir { 1527*cdf0e10cSrcweir nIndex -= pTemp->Count(); 1528*cdf0e10cSrcweir pTemp = pTemp->GetNextBlock(); 1529*cdf0e10cSrcweir } 1530*cdf0e10cSrcweir 1531*cdf0e10cSrcweir // Item innerhalb des gefundenen Blocks zurueckgeben 1532*cdf0e10cSrcweir pCurBlock = pTemp; 1533*cdf0e10cSrcweir nCurIndex = (sal_uInt16)nIndex; 1534*cdf0e10cSrcweir return pCurBlock->GetObject( nCurIndex ); 1535*cdf0e10cSrcweir } 1536*cdf0e10cSrcweir } 1537*cdf0e10cSrcweir 1538*cdf0e10cSrcweir /************************************************************************* 1539*cdf0e10cSrcweir |* 1540*cdf0e10cSrcweir |* Container::First() 1541*cdf0e10cSrcweir |* 1542*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1543*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1544*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1545*cdf0e10cSrcweir |* 1546*cdf0e10cSrcweir *************************************************************************/ 1547*cdf0e10cSrcweir 1548*cdf0e10cSrcweir void* Container::First() 1549*cdf0e10cSrcweir { 1550*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1551*cdf0e10cSrcweir 1552*cdf0e10cSrcweir // Ist Container leer, dann NULL zurueckgeben 1553*cdf0e10cSrcweir if ( !nCount ) 1554*cdf0e10cSrcweir return NULL; 1555*cdf0e10cSrcweir else 1556*cdf0e10cSrcweir { 1557*cdf0e10cSrcweir // Block und Index setzen und ersten Pointer zurueckgeben 1558*cdf0e10cSrcweir pCurBlock = pFirstBlock; 1559*cdf0e10cSrcweir nCurIndex = 0; 1560*cdf0e10cSrcweir return pCurBlock->GetObject( nCurIndex ); 1561*cdf0e10cSrcweir } 1562*cdf0e10cSrcweir } 1563*cdf0e10cSrcweir 1564*cdf0e10cSrcweir /************************************************************************* 1565*cdf0e10cSrcweir |* 1566*cdf0e10cSrcweir |* Container::Last() 1567*cdf0e10cSrcweir |* 1568*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1569*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1570*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1571*cdf0e10cSrcweir |* 1572*cdf0e10cSrcweir *************************************************************************/ 1573*cdf0e10cSrcweir 1574*cdf0e10cSrcweir void* Container::Last() 1575*cdf0e10cSrcweir { 1576*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1577*cdf0e10cSrcweir 1578*cdf0e10cSrcweir // Ist Container leer, dann NULL zurueckgeben 1579*cdf0e10cSrcweir if ( !nCount ) 1580*cdf0e10cSrcweir return NULL; 1581*cdf0e10cSrcweir else 1582*cdf0e10cSrcweir { 1583*cdf0e10cSrcweir // Block und Index setzen und ersten Pointer zurueckgeben 1584*cdf0e10cSrcweir pCurBlock = pLastBlock; 1585*cdf0e10cSrcweir nCurIndex = pCurBlock->Count()-1; 1586*cdf0e10cSrcweir return pCurBlock->GetObject( nCurIndex ); 1587*cdf0e10cSrcweir } 1588*cdf0e10cSrcweir } 1589*cdf0e10cSrcweir 1590*cdf0e10cSrcweir /************************************************************************* 1591*cdf0e10cSrcweir |* 1592*cdf0e10cSrcweir |* Container::Next() 1593*cdf0e10cSrcweir |* 1594*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1595*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1596*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1597*cdf0e10cSrcweir |* 1598*cdf0e10cSrcweir *************************************************************************/ 1599*cdf0e10cSrcweir 1600*cdf0e10cSrcweir void* Container::Next() 1601*cdf0e10cSrcweir { 1602*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1603*cdf0e10cSrcweir 1604*cdf0e10cSrcweir // Ist Container leer, dann NULL zurueckgeben, ansonsten preufen ob 1605*cdf0e10cSrcweir // naechste Position noch im aktuellen Block ist. Falls nicht, dann 1606*cdf0e10cSrcweir // einen Block weiterschalten (geht ohne Gefahr, da leere Bloecke 1607*cdf0e10cSrcweir // nicht vorkommen duerfen, es sein denn, es ist der einzige). 1608*cdf0e10cSrcweir if ( !nCount ) 1609*cdf0e10cSrcweir return NULL; 1610*cdf0e10cSrcweir else if ( (nCurIndex+1) < pCurBlock->Count() ) 1611*cdf0e10cSrcweir return pCurBlock->GetObject( ++nCurIndex ); 1612*cdf0e10cSrcweir else if ( pCurBlock->GetNextBlock() ) 1613*cdf0e10cSrcweir { 1614*cdf0e10cSrcweir pCurBlock = pCurBlock->GetNextBlock(); 1615*cdf0e10cSrcweir nCurIndex = 0; 1616*cdf0e10cSrcweir return pCurBlock->GetObject( nCurIndex ); 1617*cdf0e10cSrcweir } 1618*cdf0e10cSrcweir else 1619*cdf0e10cSrcweir return NULL; 1620*cdf0e10cSrcweir } 1621*cdf0e10cSrcweir 1622*cdf0e10cSrcweir /************************************************************************* 1623*cdf0e10cSrcweir |* 1624*cdf0e10cSrcweir |* Container::Prev() 1625*cdf0e10cSrcweir |* 1626*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1627*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1628*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1629*cdf0e10cSrcweir |* 1630*cdf0e10cSrcweir *************************************************************************/ 1631*cdf0e10cSrcweir 1632*cdf0e10cSrcweir void* Container::Prev() 1633*cdf0e10cSrcweir { 1634*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1635*cdf0e10cSrcweir 1636*cdf0e10cSrcweir // Ist Container leer, dann NULL zurueckgeben, ansonsten preufen ob 1637*cdf0e10cSrcweir // vorherige Position noch im aktuellen Block ist. Falls nicht, dann 1638*cdf0e10cSrcweir // einen Block zurueckschalten (geht ohne Gefahr, da leere Bloecke 1639*cdf0e10cSrcweir // nicht vorkommen duerfen, es sein denn, es ist der einzige). 1640*cdf0e10cSrcweir if ( !nCount ) 1641*cdf0e10cSrcweir return NULL; 1642*cdf0e10cSrcweir else if ( nCurIndex ) 1643*cdf0e10cSrcweir return pCurBlock->GetObject( --nCurIndex ); 1644*cdf0e10cSrcweir else if ( pCurBlock->GetPrevBlock() ) 1645*cdf0e10cSrcweir { 1646*cdf0e10cSrcweir pCurBlock = pCurBlock->GetPrevBlock(); 1647*cdf0e10cSrcweir nCurIndex = pCurBlock->Count() - 1; 1648*cdf0e10cSrcweir return pCurBlock->GetObject( nCurIndex ); 1649*cdf0e10cSrcweir } 1650*cdf0e10cSrcweir else 1651*cdf0e10cSrcweir return NULL; 1652*cdf0e10cSrcweir } 1653*cdf0e10cSrcweir 1654*cdf0e10cSrcweir /************************************************************************* 1655*cdf0e10cSrcweir |* 1656*cdf0e10cSrcweir |* Container::operator =() 1657*cdf0e10cSrcweir |* 1658*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1659*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1660*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1661*cdf0e10cSrcweir |* 1662*cdf0e10cSrcweir *************************************************************************/ 1663*cdf0e10cSrcweir 1664*cdf0e10cSrcweir Container& Container::operator =( const Container& r ) 1665*cdf0e10cSrcweir { 1666*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1667*cdf0e10cSrcweir 1668*cdf0e10cSrcweir // Erst alle Bloecke loeschen 1669*cdf0e10cSrcweir CBlock* pBlock = pFirstBlock; 1670*cdf0e10cSrcweir while ( pBlock ) 1671*cdf0e10cSrcweir { 1672*cdf0e10cSrcweir CBlock* pTemp = pBlock->GetNextBlock(); 1673*cdf0e10cSrcweir delete pBlock; 1674*cdf0e10cSrcweir pBlock = pTemp; 1675*cdf0e10cSrcweir } 1676*cdf0e10cSrcweir 1677*cdf0e10cSrcweir // Daten kopieren 1678*cdf0e10cSrcweir ImpCopyContainer( &r ); 1679*cdf0e10cSrcweir return *this; 1680*cdf0e10cSrcweir } 1681*cdf0e10cSrcweir 1682*cdf0e10cSrcweir /************************************************************************* 1683*cdf0e10cSrcweir |* 1684*cdf0e10cSrcweir |* Container::operator ==() 1685*cdf0e10cSrcweir |* 1686*cdf0e10cSrcweir |* Beschreibung CONTNR.SDW 1687*cdf0e10cSrcweir |* Ersterstellung TH 17.09.91 1688*cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91 1689*cdf0e10cSrcweir |* 1690*cdf0e10cSrcweir *************************************************************************/ 1691*cdf0e10cSrcweir 1692*cdf0e10cSrcweir sal_Bool Container::operator ==( const Container& r ) const 1693*cdf0e10cSrcweir { 1694*cdf0e10cSrcweir DBG_CHKTHIS( Container, DbgCheckContainer ); 1695*cdf0e10cSrcweir 1696*cdf0e10cSrcweir if ( nCount != r.nCount ) 1697*cdf0e10cSrcweir return sal_False; 1698*cdf0e10cSrcweir 1699*cdf0e10cSrcweir sal_uIntPtr i = 0; 1700*cdf0e10cSrcweir while ( i < nCount ) 1701*cdf0e10cSrcweir { 1702*cdf0e10cSrcweir if ( GetObject( i ) != r.GetObject( i ) ) 1703*cdf0e10cSrcweir return sal_False; 1704*cdf0e10cSrcweir i++; 1705*cdf0e10cSrcweir } 1706*cdf0e10cSrcweir 1707*cdf0e10cSrcweir return sal_True; 1708*cdf0e10cSrcweir } 1709