Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_LOTRANGE_HXX
30 : : #define SC_LOTRANGE_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <compiler.hxx>
34 : :
35 : : // --------------------------------------------------------- class LotusRange -
36 : :
37 : : class LotusRangeList;
38 : :
39 : : typedef sal_uInt16 LR_ID;
40 : : #define ID_FAIL 0xFFFF
41 : :
42 : : class LotusRange
43 : : {
44 : : friend class LotusRangeList;
45 : : private:
46 : : sal_uInt32 nHash;
47 : : SCCOL nColStart;
48 : : SCROW nRowStart;
49 : : SCCOL nColEnd;
50 : : SCROW nRowEnd;
51 : : LR_ID nId;
52 : : void MakeHash( void );
53 : : inline void Copy( const LotusRange& );
54 : : inline void SetId( LR_ID nId );
55 : : public:
56 : : LotusRange( SCCOL nCol, SCROW nRow );
57 : : LotusRange( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE );
58 : : LotusRange( const LotusRange& );
59 : : inline LotusRange &operator =( const LotusRange& );
60 : : inline sal_Bool operator ==( const LotusRange& ) const;
61 : : inline sal_Bool operator !=( const LotusRange& ) const;
62 : : inline sal_Bool IsSingle( void ) const;
63 : : };
64 : :
65 : :
66 : 0 : inline void LotusRange::Copy( const LotusRange& rCpy )
67 : : {
68 : 0 : nColStart = rCpy.nColStart;
69 : 0 : nRowStart = rCpy.nRowStart;
70 : 0 : nColEnd = rCpy.nColEnd;
71 : 0 : nRowEnd = rCpy.nRowEnd;
72 : 0 : }
73 : :
74 : :
75 : 0 : inline void LotusRange::SetId( LR_ID nNewId )
76 : : {
77 : 0 : nId = nNewId;
78 : 0 : }
79 : :
80 : :
81 : : inline LotusRange &LotusRange::operator =( const LotusRange& rCpy )
82 : : {
83 : : Copy( rCpy );
84 : : return *this;
85 : : }
86 : :
87 : :
88 : 0 : inline sal_Bool LotusRange::operator ==( const LotusRange& rRef ) const
89 : : {
90 : : return ( nHash == rRef.nHash && nColStart == rRef.nColStart &&
91 : : nRowStart == rRef.nRowStart && nColEnd == rRef.nColEnd &&
92 [ # # ][ # # ]: 0 : nRowEnd == rRef.nRowEnd );
[ # # ][ # # ]
[ # # ]
93 : : }
94 : :
95 : :
96 : : inline sal_Bool LotusRange::operator !=( const LotusRange& rRef ) const
97 : : {
98 : : return ( nHash != rRef.nHash || nColStart != rRef.nColStart ||
99 : : nRowStart != rRef.nRowStart || nColEnd != rRef.nColEnd ||
100 : : nRowEnd != rRef.nRowEnd );
101 : : }
102 : :
103 : :
104 : 0 : inline sal_Bool LotusRange::IsSingle( void ) const
105 : : {
106 [ # # ][ # # ]: 0 : return ( nColStart == nColEnd && nRowStart == nRowEnd );
107 : : }
108 : :
109 : :
110 : :
111 : : // ----------------------------------------------------- class LotusRangeList -
112 : :
113 : : class LotusRangeList
114 : : {
115 : : private:
116 : : LR_ID nIdCnt;
117 : : ScComplexRefData aComplRef;
118 : : static SCCOL nEingCol;
119 : : static SCROW nEingRow;
120 : : std::vector<LotusRange*> maRanges;
121 : :
122 : : public:
123 : : LotusRangeList( void );
124 : : ~LotusRangeList( void );
125 : : inline sal_uInt16 GetIndex( SCCOL nCol, SCROW nRow );
126 : : inline sal_uInt16 GetIndex( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE );
127 : : sal_uInt16 GetIndex( const LotusRange& );
128 : : inline void Append( SCCOL nCol, SCROW nRow, const String& );
129 : : inline void Append( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE, const String& );
130 : : void Append( LotusRange* pLR, const String& rName );
131 : : inline static void SetEing( const SCCOL nCol, const SCROW nRow );
132 : : };
133 : :
134 : :
135 : 0 : inline LR_ID LotusRangeList::GetIndex( SCCOL nCol, SCROW nRow )
136 : : {
137 [ # # ]: 0 : LotusRange aRef( nCol, nRow );
138 [ # # ]: 0 : return GetIndex( aRef );
139 : : }
140 : :
141 : :
142 : 0 : inline LR_ID LotusRangeList::GetIndex( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE )
143 : : {
144 [ # # ]: 0 : LotusRange aRef( nColS, nRowS, nColE, nRowE );
145 [ # # ]: 0 : return GetIndex( aRef );
146 : : }
147 : :
148 : :
149 : : inline void LotusRangeList::Append( SCCOL nCol, SCROW nRow, const String& rName )
150 : : {
151 : : Append( new LotusRange( nCol, nRow ), rName );
152 : : }
153 : :
154 : :
155 : : inline void LotusRangeList::Append( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE, const String& r )
156 : : {
157 : : Append( new LotusRange( nColS, nRowS, nColE, nRowE ), r );
158 : : }
159 : :
160 : :
161 : : inline void LotusRangeList::SetEing( const SCCOL nCol, const SCROW nRow )
162 : : {
163 : : nEingCol = nCol;
164 : : nEingRow = nRow;
165 : : }
166 : :
167 : : #endif
168 : :
169 : :
170 : :
171 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|