1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ndindex.hxx,v $
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 ************************************************************************/
35 #include <tools/solar.h>
47 friend void SwNodes::RegisterIndex( SwNodeIndex
& );
48 friend void SwNodes::DeRegisterIndex( SwNodeIndex
& );
49 friend void SwNodes::RemoveNode( ULONG
, ULONG
, FASTBOOL
);
57 SwNodeIndex
*pNext
, *pPrev
;
59 void Remove(); // Ausketten
61 // diese sind nicht erlaubt!
62 SwNodeIndex( SwNodes
& rNds
, USHORT nIdx
);
63 SwNodeIndex( SwNodes
& rNds
, int nIdx
);
66 SwNodeIndex( SwNodes
& rNds
, ULONG nIdx
= 0 );
67 SwNodeIndex( const SwNodeIndex
&, long nDiff
= 0 );
68 SwNodeIndex( const SwNode
&, long nDiff
= 0 );
69 ~SwNodeIndex() { Remove(); }
71 inline ULONG
operator++();
72 inline ULONG
operator--();
74 inline ULONG
operator++(int);
75 inline ULONG
operator--(int);
78 inline ULONG
operator+=( ULONG
);
79 inline ULONG
operator-=( ULONG
);
80 inline ULONG
operator+=( const SwNodeIndex
& );
81 inline ULONG
operator-=( const SwNodeIndex
& );
83 inline BOOL
operator< ( const SwNodeIndex
& ) const;
84 inline BOOL
operator<=( const SwNodeIndex
& ) const;
85 inline BOOL
operator> ( const SwNodeIndex
& ) const;
86 inline BOOL
operator>=( const SwNodeIndex
& ) const;
87 inline BOOL
operator==( const SwNodeIndex
& ) const;
88 inline BOOL
operator!=( const SwNodeIndex
& ) const;
90 inline BOOL
operator< ( ULONG nWert
) const;
91 inline BOOL
operator<=( ULONG nWert
) const;
92 inline BOOL
operator> ( ULONG nWert
) const;
93 inline BOOL
operator>=( ULONG nWert
) const;
94 inline BOOL
operator==( ULONG nWert
) const;
95 inline BOOL
operator!=( ULONG nWert
) const;
97 inline SwNodeIndex
& operator=( ULONG
);
98 SwNodeIndex
& operator=( const SwNodeIndex
& );
99 SwNodeIndex
& operator=( const SwNode
& );
101 // gebe den Wert vom Index als ULONG zurueck
102 inline ULONG
GetIndex() const;
104 // ermoeglicht Zuweisungen ohne Erzeugen eines temporaeren Objektes
105 SwNodeIndex
& Assign( const SwNode
& rNd
, long nOffset
= 0 );
107 // Herausgabe des Pointers auf das NodesArray,
108 inline const SwNodes
& GetNodes() const;
109 inline SwNodes
& GetNodes();
111 SwNode
& GetNode() const { return *pNd
; }
123 SwNodeRange( const SwNodeIndex
&rS
, const SwNodeIndex
&rE
);
124 SwNodeRange( const SwNodeRange
&rRange
);
126 SwNodeRange( const SwNodeIndex
& rS
, long nSttDiff
,
127 const SwNodeIndex
& rE
, long nEndDiff
= 0 );
128 SwNodeRange( const SwNode
& rS
, long nSttDiff
,
129 const SwNode
& rE
, long nEndDiff
= 0 );
135 // fuer die inlines wird aber der node.hxx benoetigt. Dieses braucht aber
136 // auch wieder dieses. Also alle Inlines, die auf pNd zugreifen werden
137 // hier implementiert.
139 inline ULONG
SwNodeIndex::GetIndex() const
141 return pNd
->GetIndex();
143 inline const SwNodes
& SwNodeIndex::GetNodes() const
145 return pNd
->GetNodes();
147 inline SwNodes
& SwNodeIndex::GetNodes()
149 return pNd
->GetNodes();
151 inline BOOL
SwNodeIndex::operator< ( ULONG nWert
) const
153 return pNd
->GetIndex() < nWert
;
155 inline BOOL
SwNodeIndex::operator<=( ULONG nWert
) const
157 return pNd
->GetIndex() <= nWert
;
159 inline BOOL
SwNodeIndex::operator> ( ULONG nWert
) const
161 return pNd
->GetIndex() > nWert
;
163 inline BOOL
SwNodeIndex::operator>=( ULONG nWert
) const
165 return pNd
->GetIndex() >= nWert
;
167 inline BOOL
SwNodeIndex::operator==( ULONG nWert
) const
169 return pNd
->GetIndex() == nWert
;
171 inline BOOL
SwNodeIndex::operator!=( ULONG nWert
) const
173 return pNd
->GetIndex() != nWert
;
175 inline BOOL
SwNodeIndex::operator<( const SwNodeIndex
& rIndex
) const
177 return pNd
->GetIndex() < rIndex
.GetIndex();
179 inline BOOL
SwNodeIndex::operator<=( const SwNodeIndex
& rIndex
) const
181 return pNd
->GetIndex() <= rIndex
.GetIndex();
183 inline BOOL
SwNodeIndex::operator>( const SwNodeIndex
& rIndex
) const
185 return pNd
->GetIndex() > rIndex
.GetIndex();
187 inline BOOL
SwNodeIndex::operator>=( const SwNodeIndex
& rIndex
) const
189 return pNd
->GetIndex() >= rIndex
.GetIndex();
191 inline BOOL
SwNodeIndex::operator==( const SwNodeIndex
& rIdx
) const
193 return pNd
== rIdx
.pNd
;
195 inline BOOL
SwNodeIndex::operator!=( const SwNodeIndex
& rIdx
) const
197 return pNd
!= rIdx
.pNd
;
200 inline ULONG
SwNodeIndex::operator++()
202 return ( pNd
= GetNodes()[ pNd
->GetIndex()+1 ] )->GetIndex();
204 inline ULONG
SwNodeIndex::operator--()
206 return ( pNd
= GetNodes()[ pNd
->GetIndex()-1 ] )->GetIndex();
209 inline ULONG
SwNodeIndex::operator++(int)
211 ULONG nOldIndex
= pNd
->GetIndex();
212 pNd
= GetNodes()[ nOldIndex
+ 1 ];
215 inline ULONG
SwNodeIndex::operator--(int)
217 ULONG nOldIndex
= pNd
->GetIndex();
218 pNd
= GetNodes()[ nOldIndex
- 1 ];
223 inline ULONG
SwNodeIndex::operator+=( ULONG nWert
)
225 return ( pNd
= GetNodes()[ pNd
->GetIndex() + nWert
] )->GetIndex();
227 inline ULONG
SwNodeIndex::operator-=( ULONG nWert
)
229 return ( pNd
= GetNodes()[ pNd
->GetIndex() - nWert
] )->GetIndex();
231 inline ULONG
SwNodeIndex::operator+=( const SwNodeIndex
& rIndex
)
233 return ( pNd
= GetNodes()[ pNd
->GetIndex() + rIndex
.GetIndex() ] )->GetIndex();
235 inline ULONG
SwNodeIndex::operator-=( const SwNodeIndex
& rIndex
)
237 return ( pNd
= GetNodes()[ pNd
->GetIndex() - rIndex
.GetIndex() ] )->GetIndex();
240 inline SwNodeIndex
& SwNodeIndex::operator=( ULONG nWert
)
242 pNd
= GetNodes()[ nWert
];
248 //JP 29.09.97: impl. steht im ndindex.hxx - sollte moeglichst bald auf die
249 // neue Schnittstelle angepasst werden
250 inline SwNode
* SwNodes::operator[]( const SwNodeIndex
& rIdx
) const
252 return &rIdx
.GetNode();
256 } //namespace binfilter