xref: /trunk/main/sc/source/filter/inc/lotrange.hxx (revision 38d50f7b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_LOTRANGE_HXX
25 #define SC_LOTRANGE_HXX
26 
27 #include <tools/solar.h>
28 #include <compiler.hxx>
29 
30 // --------------------------------------------------------- class LotusRange -
31 
32 class LotusRangeList;
33 
34 typedef sal_uInt16	LR_ID;
35 #define ID_FAIL	0xFFFF
36 
37 class LotusRange
38 {
39 	friend class LotusRangeList;
40 private:
41 	sal_uInt32				nHash;
42 	SCCOL				nColStart;
43 	SCROW				nRowStart;
44 	SCCOL				nColEnd;
45 	SCROW				nRowEnd;
46 	LR_ID				nId;
47 	void				MakeHash( void );
48 	inline void			Copy( const LotusRange& );
49 	inline void			SetId( LR_ID nId );
50 public:
51 						LotusRange( SCCOL nCol, SCROW nRow );
52 						LotusRange( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE );
53 						LotusRange( const LotusRange& );
54 	inline LotusRange	&operator =( const LotusRange& );
55 	inline sal_Bool			operator ==( const LotusRange& ) const;
56 	inline sal_Bool			operator !=( const LotusRange& ) const;
57 	inline sal_Bool			IsSingle( void ) const;
58 };
59 
60 
Copy(const LotusRange & rCpy)61 inline void LotusRange::Copy( const LotusRange& rCpy )
62 {
63 	nColStart = rCpy.nColStart;
64 	nRowStart = rCpy.nRowStart;
65 	nColEnd = rCpy.nColEnd;
66 	nRowEnd = rCpy.nRowEnd;
67 }
68 
69 
SetId(LR_ID nNewId)70 inline void LotusRange::SetId( LR_ID nNewId )
71 {
72 	nId = nNewId;
73 }
74 
75 
operator =(const LotusRange & rCpy)76 inline LotusRange &LotusRange::operator =( const LotusRange& rCpy )
77 {
78 	Copy( rCpy );
79 	return *this;
80 }
81 
82 
operator ==(const LotusRange & rRef) const83 inline sal_Bool LotusRange::operator ==( const LotusRange& rRef ) const
84 {
85 	return ( nHash == rRef.nHash && nColStart == rRef.nColStart &&
86 		nRowStart == rRef.nRowStart && nColEnd == rRef.nColEnd &&
87 		nRowEnd == rRef.nRowEnd );
88 }
89 
90 
operator !=(const LotusRange & rRef) const91 inline sal_Bool LotusRange::operator !=( const LotusRange& rRef ) const
92 {
93 	return ( nHash != rRef.nHash || nColStart != rRef.nColStart ||
94 		nRowStart != rRef.nRowStart || nColEnd != rRef.nColEnd ||
95 		nRowEnd != rRef.nRowEnd );
96 }
97 
98 
IsSingle(void) const99 inline sal_Bool LotusRange::IsSingle( void ) const
100 {
101 	return ( nColStart == nColEnd && nRowStart == nRowEnd );
102 }
103 
104 
105 
106 // ----------------------------------------------------- class LotusRangeList -
107 
108 class LotusRangeList : private List
109 {
110 private:
111 	LR_ID				nIdCnt;
112 	ScComplexRefData		aComplRef;
113 	static SCCOL		nEingCol;
114 	static SCROW		nEingRow;
115 public:
116 						LotusRangeList( void );
117 						~LotusRangeList( void );
118 	inline sal_uInt16		GetIndex( SCCOL nCol, SCROW nRow );
119 	inline sal_uInt16		GetIndex( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE );
120 	sal_uInt16				GetIndex( const LotusRange& );
121 	inline void			Append( SCCOL nCol, SCROW nRow, const String& );
122 	inline void			Append( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE, const String& );
123 	void				Append( LotusRange* pLR, const String& rName );
124 	inline static void	SetEing( const SCCOL nCol, const SCROW nRow );
125 };
126 
127 
GetIndex(SCCOL nCol,SCROW nRow)128 inline LR_ID LotusRangeList::GetIndex( SCCOL nCol, SCROW nRow )
129 {
130 	LotusRange aRef( nCol, nRow );
131 	return GetIndex( aRef );
132 }
133 
134 
GetIndex(SCCOL nColS,SCROW nRowS,SCCOL nColE,SCROW nRowE)135 inline LR_ID LotusRangeList::GetIndex( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE )
136 {
137 	LotusRange aRef( nColS, nRowS, nColE, nRowE );
138 	return GetIndex( aRef );
139 }
140 
141 
Append(SCCOL nCol,SCROW nRow,const String & rName)142 inline void LotusRangeList::Append( SCCOL nCol, SCROW nRow, const String& rName )
143 {
144 	Append( new LotusRange( nCol, nRow ), rName );
145 }
146 
147 
Append(SCCOL nColS,SCROW nRowS,SCCOL nColE,SCROW nRowE,const String & r)148 inline void LotusRangeList::Append( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE, const String& r )
149 {
150 	Append( new LotusRange( nColS, nRowS, nColE, nRowE ), r );
151 }
152 
153 
SetEing(const SCCOL nCol,const SCROW nRow)154 inline void LotusRangeList::SetEing( const SCCOL nCol, const SCROW nRow )
155 {
156 	nEingCol = nCol;
157 	nEingRow = nRow;
158 }
159 
160 #endif
161 
162 
163 
164