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