merge the formfield patch from ooo-build
[ooovba.git] / sw / inc / ndindex.hxx
blobfa4fd28e82e1e786417cc1338de22cd831d355f3
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: ndindex.hxx,v $
10 * $Revision: 1.5 $
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 ************************************************************************/
30 #ifndef _NDINDEX_HXX
31 #define _NDINDEX_HXX
33 #include <limits.h>
34 #include <tools/solar.h>
36 #include "node.hxx"
37 #include "ndarr.hxx"
39 class SwNode;
40 class SwNodes;
42 class SW_DLLPUBLIC SwNodeIndex
44 friend void SwNodes::RegisterIndex( SwNodeIndex& );
45 friend void SwNodes::DeRegisterIndex( SwNodeIndex& );
46 friend void SwNodes::RemoveNode( ULONG, ULONG, BOOL );
48 #ifndef PRODUCT
49 static int nSerial;
50 int MySerial;
51 #endif
53 SwNode* pNd;
54 SwNodeIndex *pNext, *pPrev;
56 void Remove(); // Ausketten
58 // diese sind nicht erlaubt!
59 SwNodeIndex( SwNodes& rNds, USHORT nIdx );
60 SwNodeIndex( SwNodes& rNds, int nIdx );
62 public:
63 SwNodeIndex( SwNodes& rNds, ULONG nIdx = 0 );
64 SwNodeIndex( const SwNodeIndex &, long nDiff = 0 );
65 SwNodeIndex( const SwNode&, long nDiff = 0 );
66 ~SwNodeIndex() { Remove(); }
68 inline ULONG operator++();
69 inline ULONG operator--();
70 #ifndef CFRONT
71 inline ULONG operator++(int);
72 inline ULONG operator--(int);
73 #endif
75 inline ULONG operator+=( ULONG );
76 inline ULONG operator-=( ULONG );
77 inline ULONG operator+=( const SwNodeIndex& );
78 inline ULONG operator-=( const SwNodeIndex& );
80 inline BOOL operator< ( const SwNodeIndex& ) const;
81 inline BOOL operator<=( const SwNodeIndex& ) const;
82 inline BOOL operator> ( const SwNodeIndex& ) const;
83 inline BOOL operator>=( const SwNodeIndex& ) const;
84 inline BOOL operator==( const SwNodeIndex& ) const;
85 inline BOOL operator!=( const SwNodeIndex& ) const;
87 inline BOOL operator< ( ULONG nWert ) const;
88 inline BOOL operator<=( ULONG nWert ) const;
89 inline BOOL operator> ( ULONG nWert ) const;
90 inline BOOL operator>=( ULONG nWert ) const;
91 inline BOOL operator==( ULONG nWert ) const;
92 inline BOOL operator!=( ULONG nWert ) const;
94 inline SwNodeIndex& operator=( ULONG );
95 SwNodeIndex& operator=( const SwNodeIndex& );
96 SwNodeIndex& operator=( const SwNode& );
98 // gebe den Wert vom Index als ULONG zurueck
99 inline ULONG GetIndex() const;
101 // ermoeglicht Zuweisungen ohne Erzeugen eines temporaeren Objektes
102 SwNodeIndex& Assign( SwNodes& rNds, ULONG );
103 SwNodeIndex& Assign( const SwNode& rNd, long nOffset = 0 );
105 // Herausgabe des Pointers auf das NodesArray,
106 inline const SwNodes& GetNodes() const;
107 inline SwNodes& GetNodes();
109 SwNode& GetNode() const { return *pNd; }
113 * SwRange
115 class SW_DLLPUBLIC SwNodeRange
117 public:
118 SwNodeIndex aStart;
119 SwNodeIndex aEnd;
121 SwNodeRange( const SwNodeIndex &rS, const SwNodeIndex &rE );
122 SwNodeRange( const SwNodeRange &rRange );
124 SwNodeRange( SwNodes& rArr, ULONG nSttIdx = 0, ULONG nEndIdx = 0 );
125 SwNodeRange( const SwNodeIndex& rS, long nSttDiff,
126 const SwNodeIndex& rE, long nEndDiff = 0 );
127 SwNodeRange( const SwNode& rS, long nSttDiff,
128 const SwNode& rE, long nEndDiff = 0 );
134 // fuer die inlines wird aber der node.hxx benoetigt. Dieses braucht aber
135 // auch wieder dieses. Also alle Inlines, die auf pNd zugreifen werden
136 // hier implementiert.
138 inline ULONG SwNodeIndex::GetIndex() const
140 return pNd->GetIndex();
142 inline const SwNodes& SwNodeIndex::GetNodes() const
144 return pNd->GetNodes();
146 inline SwNodes& SwNodeIndex::GetNodes()
148 return pNd->GetNodes();
150 inline BOOL SwNodeIndex::operator< ( ULONG nWert ) const
152 return pNd->GetIndex() < nWert;
154 inline BOOL SwNodeIndex::operator<=( ULONG nWert ) const
156 return pNd->GetIndex() <= nWert;
158 inline BOOL SwNodeIndex::operator> ( ULONG nWert ) const
160 return pNd->GetIndex() > nWert;
162 inline BOOL SwNodeIndex::operator>=( ULONG nWert ) const
164 return pNd->GetIndex() >= nWert;
166 inline BOOL SwNodeIndex::operator==( ULONG nWert ) const
168 return pNd->GetIndex() == nWert;
170 inline BOOL SwNodeIndex::operator!=( ULONG nWert ) const
172 return pNd->GetIndex() != nWert;
174 inline BOOL SwNodeIndex::operator<( const SwNodeIndex& rIndex ) const
176 return pNd->GetIndex() < rIndex.GetIndex();
178 inline BOOL SwNodeIndex::operator<=( const SwNodeIndex& rIndex ) const
180 return pNd->GetIndex() <= rIndex.GetIndex();
182 inline BOOL SwNodeIndex::operator>( const SwNodeIndex& rIndex ) const
184 return pNd->GetIndex() > rIndex.GetIndex();
186 inline BOOL SwNodeIndex::operator>=( const SwNodeIndex& rIndex ) const
188 return pNd->GetIndex() >= rIndex.GetIndex();
190 inline BOOL SwNodeIndex::operator==( const SwNodeIndex& rIdx ) const
192 return pNd == rIdx.pNd;
194 inline BOOL SwNodeIndex::operator!=( const SwNodeIndex& rIdx ) const
196 return pNd != rIdx.pNd;
199 inline ULONG SwNodeIndex::operator++()
201 return ( pNd = GetNodes()[ pNd->GetIndex()+1 ] )->GetIndex();
203 inline ULONG SwNodeIndex::operator--()
205 return ( pNd = GetNodes()[ pNd->GetIndex()-1 ] )->GetIndex();
207 #ifndef CFRONT
208 inline ULONG SwNodeIndex::operator++(int)
210 ULONG nOldIndex = pNd->GetIndex();
211 pNd = GetNodes()[ nOldIndex + 1 ];
212 return nOldIndex;
214 inline ULONG SwNodeIndex::operator--(int)
216 ULONG nOldIndex = pNd->GetIndex();
217 pNd = GetNodes()[ nOldIndex - 1 ];
218 return nOldIndex;
220 #endif
222 inline ULONG SwNodeIndex::operator+=( ULONG nWert )
224 return ( pNd = GetNodes()[ pNd->GetIndex() + nWert ] )->GetIndex();
226 inline ULONG SwNodeIndex::operator-=( ULONG nWert )
228 return ( pNd = GetNodes()[ pNd->GetIndex() - nWert ] )->GetIndex();
230 inline ULONG SwNodeIndex::operator+=( const SwNodeIndex& rIndex )
232 return ( pNd = GetNodes()[ pNd->GetIndex() + rIndex.GetIndex() ] )->GetIndex();
234 inline ULONG SwNodeIndex::operator-=( const SwNodeIndex& rIndex )
236 return ( pNd = GetNodes()[ pNd->GetIndex() - rIndex.GetIndex() ] )->GetIndex();
239 inline SwNodeIndex& SwNodeIndex::operator=( ULONG nWert )
241 pNd = GetNodes()[ nWert ];
242 return *this;
247 //JP 29.09.97: impl. steht im ndindex.hxx - sollte moeglichst bald auf die
248 // neue Schnittstelle angepasst werden
249 inline SwNode* SwNodes::operator[]( const SwNodeIndex& rIdx ) const
251 return &rIdx.GetNode();
255 #endif