update dev300-m58
[ooovba.git] / tools / inc / impcont.hxx
blobe92c5b9c19b9226fb85eae835f281d0ecd2a949b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: impcont.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _IMPCONT_HXX
32 #define _IMPCONT_HXX
34 #include <tools/tools.h>
35 #include <tools/contnr.hxx>
37 typedef void* PVOID;
39 // ----------
40 // - CBlock -
41 // ----------
43 class CBlock
45 private:
46 CBlock* pPrev; // Vorheriger Block
47 CBlock* pNext; // Naechster Block
48 USHORT nSize; // Groesse des Blocks
49 USHORT nCount; // Anzahl Pointer
50 void** pNodes; // Pointer auf die Daten
52 #if defined DBG_UTIL
53 static char const * DbgCheckCBlock(void const *);
54 #endif
56 public:
57 // Fuer List-Container
58 CBlock( USHORT nSize, CBlock* pPrev, CBlock* pNext );
59 // Fuer Array-Container
60 CBlock( USHORT nSize, CBlock* pPrev );
61 // Copy-Ctor
62 CBlock( const CBlock& r, CBlock* pPrev );
63 ~CBlock();
65 void Insert( void* p, USHORT nIndex, USHORT nReSize );
66 CBlock* Split( void* p, USHORT nIndex, USHORT nReSize );
67 void* Remove( USHORT nIndex, USHORT nReSize );
68 void* Replace( void* pNew, USHORT nIndex );
70 void** GetNodes() const { return pNodes; }
71 void** GetObjectPtr( USHORT nIndex );
72 void* GetObject( USHORT nIndex ) const;
74 void SetSize( USHORT nNewSize );
76 USHORT GetSize() const { return nCount; }
77 USHORT Count() const { return nCount; }
78 void SetPrevBlock( CBlock* p ) { pPrev = p; }
79 void SetNextBlock( CBlock* p ) { pNext = p; }
80 CBlock* GetPrevBlock() const { return pPrev; }
81 CBlock* GetNextBlock() const { return pNext; }
82 void Reset() { nCount = 0; }
84 private:
85 CBlock( const CBlock& r );
87 friend class Container;
90 /*************************************************************************
92 |* CBlock::GetObject()
94 |* Beschreibung Gibt einen Pointer aus dem Block zurueck
95 |* Ersterstellung TH 17.09.91
96 |* Letzte Aenderung TH 17.09.91
98 *************************************************************************/
100 inline void* CBlock::GetObject( USHORT nIndex ) const
102 return pNodes[nIndex];
105 /*************************************************************************
107 |* Container::ImpGetObject()
109 |* Beschreibung Wir gehen davon aus, das Pointer in der Regel
110 |* sich im ersten Block befindet und schalten
111 |* deshalb eine Inline-Methode davor
112 |* Ersterstellung TH 02.07.93
113 |* Letzte Aenderung TH 02.07.93
115 *************************************************************************/
117 inline void* Container::ImpGetObject( ULONG nIndex ) const
119 if ( pFirstBlock && (nIndex < pFirstBlock->Count()) )
120 // Item innerhalb des gefundenen Blocks zurueckgeben
121 return pFirstBlock->GetObject( (USHORT)nIndex );
122 else
123 return GetObject( nIndex );
126 /*************************************************************************
128 |* Container::ImpGetOnlyNodes()
130 |* Beschreibung Wenn es nur einen Block gibt, wird davon
131 |* das Daten-Array zurueckgegeben
132 |* Ersterstellung TH 24.01.96
133 |* Letzte Aenderung TH 24.01.96
135 *************************************************************************/
137 // #i70651#: Prevent warnings on Mac OS X
138 #ifdef MACOSX
139 #pragma GCC system_header
140 #endif
142 inline void** Container::ImpGetOnlyNodes() const
144 if ( (pFirstBlock == pLastBlock) && pFirstBlock )
145 return pFirstBlock->GetNodes();
146 else
147 return NULL;
150 #endif // _IMPCONT_HXX