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.cxx,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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #include "errhdl.hxx" // fuers ASSERT
37 #include "error.h" // fuers ASSERT
38 #include "ndindex.hxx"
41 int SwNodeIndex::nSerial
= 0;
45 SwNodeRange::SwNodeRange( const SwNodeIndex
&rS
, const SwNodeIndex
&rE
)
46 : aStart( rS
), aEnd( rE
)
49 SwNodeRange::SwNodeRange( const SwNodeRange
&rRange
)
50 : aStart( rRange
.aStart
), aEnd( rRange
.aEnd
)
53 SwNodeRange::SwNodeRange( SwNodes
& rNds
, ULONG nSttIdx
, ULONG nEndIdx
)
54 : aStart( rNds
, nSttIdx
), aEnd( rNds
, nEndIdx
)
58 SwNodeRange::SwNodeRange( const SwNodeIndex
& rS
, long nSttDiff
,
59 const SwNodeIndex
& rE
, long nEndDiff
)
60 : aStart( rS
, nSttDiff
), aEnd( rE
, nEndDiff
)
63 SwNodeRange::SwNodeRange( const SwNode
& rS
, long nSttDiff
,
64 const SwNode
& rE
, long nEndDiff
)
65 : aStart( rS
, nSttDiff
), aEnd( rE
, nEndDiff
)
69 SwNodeIndex::SwNodeIndex( SwNodes
& rNds
, ULONG nIdx
)
70 : pNd( rNds
[ nIdx
] ), pNext( 0 ), pPrev( 0 )
72 rNds
.RegisterIndex( *this );
75 MySerial
= ++nSerial
; // nur in der nicht PRODUCT-Version
80 SwNodeIndex::SwNodeIndex( const SwNodeIndex
& rIdx
, long nDiff
)
81 : pNext( 0 ), pPrev( 0 )
84 pNd
= rIdx
.GetNodes()[ rIdx
.GetIndex() + nDiff
];
88 pNd
->GetNodes().RegisterIndex( *this );
90 MySerial
= ++nSerial
; // nur in der nicht PRODUCT-Version
95 SwNodeIndex::SwNodeIndex( const SwNode
& rNd
, long nDiff
)
96 : pNext( 0 ), pPrev( 0 )
99 pNd
= rNd
.GetNodes()[ rNd
.GetIndex() + nDiff
];
103 pNd
->GetNodes().RegisterIndex( *this );
105 MySerial
= ++nSerial
; // nur in der nicht PRODUCT-Version
110 void SwNodeIndex::Remove()
112 pNd
->GetNodes().DeRegisterIndex( *this );
115 SwNodeIndex
& SwNodeIndex::operator=( const SwNodeIndex
& rIdx
)
117 if( &pNd
->GetNodes() != &rIdx
.pNd
->GetNodes() )
119 pNd
->GetNodes().DeRegisterIndex( *this );
121 pNd
->GetNodes().RegisterIndex( *this );
128 SwNodeIndex
& SwNodeIndex::operator=( const SwNode
& rNd
)
130 if( &pNd
->GetNodes() != &rNd
.GetNodes() )
132 pNd
->GetNodes().DeRegisterIndex( *this );
134 pNd
->GetNodes().RegisterIndex( *this );
141 SwNodeIndex
& SwNodeIndex::Assign( SwNodes
& rNds
, ULONG nIdx
)
143 if( &pNd
->GetNodes() != &rNds
)
145 pNd
->GetNodes().DeRegisterIndex( *this );
147 pNd
->GetNodes().RegisterIndex( *this );
154 SwNodeIndex
& SwNodeIndex::Assign( const SwNode
& rNd
, long nOffset
)
156 if( &pNd
->GetNodes() != &rNd
.GetNodes() )
158 pNd
->GetNodes().DeRegisterIndex( *this );
160 pNd
->GetNodes().RegisterIndex( *this );
166 pNd
= pNd
->GetNodes()[ pNd
->GetIndex() + nOffset
];