Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "ndindex.hxx"
21 :
22 0 : SwNodeRange::SwNodeRange( const SwNodeIndex &rS, const SwNodeIndex &rE )
23 0 : : aStart( rS ), aEnd( rE )
24 0 : {}
25 :
26 0 : SwNodeRange::SwNodeRange( const SwNodeRange &rRange )
27 0 : : aStart( rRange.aStart ), aEnd( rRange.aEnd )
28 0 : {}
29 :
30 0 : SwNodeRange::SwNodeRange( SwNodes& rNds, sal_uLong nSttIdx, sal_uLong nEndIdx )
31 0 : : aStart( rNds, nSttIdx ), aEnd( rNds, nEndIdx )
32 0 : {}
33 :
34 0 : SwNodeRange::SwNodeRange( const SwNodeIndex& rS, long nSttDiff,
35 : const SwNodeIndex& rE, long nEndDiff )
36 0 : : aStart( rS, nSttDiff ), aEnd( rE, nEndDiff )
37 0 : {}
38 :
39 0 : SwNodeRange::SwNodeRange( const SwNode& rS, long nSttDiff,
40 : const SwNode& rE, long nEndDiff )
41 0 : : aStart( rS, nSttDiff ), aEnd( rE, nEndDiff )
42 0 : {}
43 :
44 0 : SwNodeIndex::SwNodeIndex( SwNodes& rNds, sal_uLong nIdx )
45 0 : : pNd( rNds[ nIdx ] ), pNext( 0 ), pPrev( 0 )
46 : {
47 0 : rNds.RegisterIndex( *this );
48 0 : }
49 :
50 0 : SwNodeIndex::SwNodeIndex( const SwNodeIndex& rIdx, long nDiff )
51 0 : : pNext( 0 ), pPrev( 0 )
52 : {
53 0 : if( nDiff )
54 0 : pNd = rIdx.GetNodes()[ rIdx.GetIndex() + nDiff ];
55 : else
56 0 : pNd = rIdx.pNd;
57 :
58 0 : pNd->GetNodes().RegisterIndex( *this );
59 0 : }
60 :
61 0 : SwNodeIndex::SwNodeIndex( const SwNode& rNd, long nDiff )
62 0 : : pNext( 0 ), pPrev( 0 )
63 : {
64 0 : if( nDiff )
65 0 : pNd = rNd.GetNodes()[ rNd.GetIndex() + nDiff ];
66 : else
67 0 : pNd = (SwNode*)&rNd;
68 :
69 0 : pNd->GetNodes().RegisterIndex( *this );
70 0 : }
71 :
72 0 : void SwNodeIndex::Remove()
73 : {
74 0 : pNd->GetNodes().DeRegisterIndex( *this );
75 0 : }
76 :
77 0 : SwNodeIndex& SwNodeIndex::operator=( const SwNodeIndex& rIdx )
78 : {
79 0 : if( &pNd->GetNodes() != &rIdx.pNd->GetNodes() )
80 : {
81 0 : pNd->GetNodes().DeRegisterIndex( *this );
82 0 : pNd = rIdx.pNd;
83 0 : pNd->GetNodes().RegisterIndex( *this );
84 : }
85 : else
86 0 : pNd = rIdx.pNd;
87 0 : return *this;
88 : }
89 :
90 0 : SwNodeIndex& SwNodeIndex::operator=( const SwNode& rNd )
91 : {
92 0 : if( &pNd->GetNodes() != &rNd.GetNodes() )
93 : {
94 0 : pNd->GetNodes().DeRegisterIndex( *this );
95 0 : pNd = (SwNode*)&rNd;
96 0 : pNd->GetNodes().RegisterIndex( *this );
97 : }
98 : else
99 0 : pNd = (SwNode*)&rNd;
100 0 : return *this;
101 : }
102 :
103 0 : SwNodeIndex& SwNodeIndex::Assign( SwNodes& rNds, sal_uLong nIdx )
104 : {
105 0 : if( &pNd->GetNodes() != &rNds )
106 : {
107 0 : pNd->GetNodes().DeRegisterIndex( *this );
108 0 : pNd = rNds[ nIdx ];
109 0 : pNd->GetNodes().RegisterIndex( *this );
110 : }
111 : else
112 0 : pNd = rNds[ nIdx ];
113 0 : return *this;
114 : }
115 :
116 0 : SwNodeIndex& SwNodeIndex::Assign( const SwNode& rNd, long nOffset )
117 : {
118 0 : if( &pNd->GetNodes() != &rNd.GetNodes() )
119 : {
120 0 : pNd->GetNodes().DeRegisterIndex( *this );
121 0 : pNd = (SwNode*)&rNd;
122 0 : pNd->GetNodes().RegisterIndex( *this );
123 : }
124 : else
125 0 : pNd = (SwNode*)&rNd;
126 :
127 0 : if( nOffset )
128 0 : pNd = pNd->GetNodes()[ pNd->GetIndex() + nOffset ];
129 :
130 0 : return *this;
131 : }
132 :
133 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|