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 :
21 : #include "ndindex.hxx"
22 :
23 :
24 791 : SwNodeRange::SwNodeRange( const SwNodeIndex &rS, const SwNodeIndex &rE )
25 791 : : aStart( rS ), aEnd( rE )
26 791 : {}
27 :
28 1239 : SwNodeRange::SwNodeRange( const SwNodeRange &rRange )
29 1239 : : aStart( rRange.aStart ), aEnd( rRange.aEnd )
30 1239 : {}
31 :
32 0 : SwNodeRange::SwNodeRange( SwNodes& rNds, sal_uLong nSttIdx, sal_uLong nEndIdx )
33 0 : : aStart( rNds, nSttIdx ), aEnd( rNds, nEndIdx )
34 0 : {}
35 :
36 :
37 521 : SwNodeRange::SwNodeRange( const SwNodeIndex& rS, long nSttDiff,
38 : const SwNodeIndex& rE, long nEndDiff )
39 521 : : aStart( rS, nSttDiff ), aEnd( rE, nEndDiff )
40 521 : {}
41 :
42 413 : SwNodeRange::SwNodeRange( const SwNode& rS, long nSttDiff,
43 : const SwNode& rE, long nEndDiff )
44 413 : : aStart( rS, nSttDiff ), aEnd( rE, nEndDiff )
45 413 : {}
46 :
47 :
48 125099 : SwNodeIndex::SwNodeIndex( SwNodes& rNds, sal_uLong nIdx )
49 125099 : : pNd( rNds[ nIdx ] ), pNext( 0 ), pPrev( 0 )
50 : {
51 125099 : rNds.RegisterIndex( *this );
52 125099 : }
53 :
54 :
55 357316 : SwNodeIndex::SwNodeIndex( const SwNodeIndex& rIdx, long nDiff )
56 357316 : : pNext( 0 ), pPrev( 0 )
57 : {
58 357316 : if( nDiff )
59 101275 : pNd = rIdx.GetNodes()[ rIdx.GetIndex() + nDiff ];
60 : else
61 256041 : pNd = rIdx.pNd;
62 :
63 357316 : pNd->GetNodes().RegisterIndex( *this );
64 357316 : }
65 :
66 :
67 57981 : SwNodeIndex::SwNodeIndex( const SwNode& rNd, long nDiff )
68 57981 : : pNext( 0 ), pPrev( 0 )
69 : {
70 57981 : if( nDiff )
71 2514 : pNd = rNd.GetNodes()[ rNd.GetIndex() + nDiff ];
72 : else
73 55467 : pNd = (SwNode*)&rNd;
74 :
75 57981 : pNd->GetNodes().RegisterIndex( *this );
76 57981 : }
77 :
78 :
79 537218 : void SwNodeIndex::Remove()
80 : {
81 537218 : pNd->GetNodes().DeRegisterIndex( *this );
82 537218 : }
83 :
84 79776 : SwNodeIndex& SwNodeIndex::operator=( const SwNodeIndex& rIdx )
85 : {
86 79776 : if( &pNd->GetNodes() != &rIdx.pNd->GetNodes() )
87 : {
88 0 : pNd->GetNodes().DeRegisterIndex( *this );
89 0 : pNd = rIdx.pNd;
90 0 : pNd->GetNodes().RegisterIndex( *this );
91 : }
92 : else
93 79776 : pNd = rIdx.pNd;
94 79776 : return *this;
95 : }
96 :
97 8003 : SwNodeIndex& SwNodeIndex::operator=( const SwNode& rNd )
98 : {
99 8003 : if( &pNd->GetNodes() != &rNd.GetNodes() )
100 : {
101 0 : pNd->GetNodes().DeRegisterIndex( *this );
102 0 : pNd = (SwNode*)&rNd;
103 0 : pNd->GetNodes().RegisterIndex( *this );
104 : }
105 : else
106 8003 : pNd = (SwNode*)&rNd;
107 8003 : return *this;
108 : }
109 :
110 0 : SwNodeIndex& SwNodeIndex::Assign( SwNodes& rNds, sal_uLong nIdx )
111 : {
112 0 : if( &pNd->GetNodes() != &rNds )
113 : {
114 0 : pNd->GetNodes().DeRegisterIndex( *this );
115 0 : pNd = rNds[ nIdx ];
116 0 : pNd->GetNodes().RegisterIndex( *this );
117 : }
118 : else
119 0 : pNd = rNds[ nIdx ];
120 0 : return *this;
121 : }
122 :
123 4892 : SwNodeIndex& SwNodeIndex::Assign( const SwNode& rNd, long nOffset )
124 : {
125 4892 : if( &pNd->GetNodes() != &rNd.GetNodes() )
126 : {
127 0 : pNd->GetNodes().DeRegisterIndex( *this );
128 0 : pNd = (SwNode*)&rNd;
129 0 : pNd->GetNodes().RegisterIndex( *this );
130 : }
131 : else
132 4892 : pNd = (SwNode*)&rNd;
133 :
134 4892 : if( nOffset )
135 4892 : pNd = pNd->GetNodes()[ pNd->GetIndex() + nOffset ];
136 :
137 4892 : return *this;
138 : }
139 :
140 :
141 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|