kspread

kspread_cluster.h
1/* This file is part of the KDE project
2 Copyright (C) 2000 Torben Weis <weis@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef kspread_cluster_h
21#define kspread_cluster_h
22
23#include "kspread_value.h"
24
25#define KSPREAD_CLUSTER_LEVEL1 128
26#define KSPREAD_CLUSTER_LEVEL2 256
27#define KSPREAD_CLUSTER_MAX (128*256)
28
29class TQPoint;
30
31namespace KSpread
32{
33class Cell;
34class ColumnFormat;
35class RowFormat;
36
73{
74public:
75 Cluster();
76 ~Cluster();
77
78 Cell* lookup( int x, int y ) const;
79
84 void clear();
85
90 void insert( Cell* cell, int x, int y );
94 void remove( int x, int y );
95
96 void setAutoDelete( bool );
97 bool autoDelete() const;
98
99 Cell* firstCell() const;
100
101 bool shiftRow( const TQPoint& marker );
109 bool shiftColumn( const TQPoint& marker );
110
115 void unshiftColumn( const TQPoint& marker );
116 void unshiftRow( const TQPoint& marker );
117
125 bool insertColumn( int col );
126 bool insertRow( int row );
127
135 void removeColumn( int col );
136 void removeRow( int row );
137
142 void clearColumn( int col );
143 void clearRow( int row );
144
149 Value valueRange (int col1, int row1, int col2, int row2) const;
150
160 Cell* getFirstCellColumn(int col) const;
161
171 Cell* getLastCellColumn(int col) const;
172
182 Cell* getFirstCellRow(int row) const;
183
193 Cell* getLastCellRow(int row) const;
194
204 Cell* getNextCellUp(int col, int row) const;
205
215 Cell* getNextCellDown(int col, int row) const;
216
227 Cell* getNextCellRight(int col, int row) const;
228
239 Cell* getNextCellLeft(int col, int row) const;
240
241private:
246 bool shiftRow( const TQPoint& marker, bool& work );
247 bool shiftColumn( const TQPoint& marker, bool& work );
248
249 void unshiftColumn( const TQPoint& marker, bool& work );
250 void unshiftRow( const TQPoint& marker, bool& work );
251
253 Value makeArray (int col1, int row1, int col2, int row2) const;
254
255 Cell*** m_cluster;
256 Cell* m_first;
257 bool m_autoDelete;
258 int m_biggestX, m_biggestY;
259};
260
261class ColumnCluster
262{
263public:
264 ColumnCluster();
265 ~ColumnCluster();
266
267 const ColumnFormat* lookup( int col ) const;
268 ColumnFormat* lookup( int col );
269
270 void clear();
271
272 void insertElement( ColumnFormat*, int col );
273 void removeElement( int col );
274
275 bool insertColumn( int col );
276 bool removeColumn( int col );
277
278 void setAutoDelete( bool );
279 bool autoDelete() const;
280
281 ColumnFormat* first() const { return m_first; }
282 ColumnFormat* next( int col ) const;
283
284private:
285 ColumnFormat*** m_cluster;
286 ColumnFormat* m_first;
287 bool m_autoDelete;
288};
289
290class RowCluster
291{
292public:
293 RowCluster();
294 ~RowCluster();
295
296 const RowFormat* lookup( int col ) const;
297 RowFormat* lookup( int col );
298
299 void clear();
300
301 void insertElement( RowFormat*, int row );
302 void removeElement( int row );
303
304 bool insertRow( int row );
305 bool removeRow( int row );
306
307 void setAutoDelete( bool );
308 bool autoDelete() const;
309
310 RowFormat* first()const { return m_first; }
311
312private:
313 RowFormat*** m_cluster;
314 RowFormat* m_first;
315 bool m_autoDelete;
316};
317
318} // namespace KSpread;
319
320#endif
For every cell in the spread sheet there is a Cell object.
Philipp This class defines a pointer map to all cells, which makes access to them more performant and...
Cell * getNextCellDown(int col, int row) const
Retrieves the next used cell below the given col/row pair.
Cell * getNextCellRight(int col, int row) const
Retrieves the next used cell to the right of the given col/row pair.
Cell * getNextCellLeft(int col, int row) const
Retrieves the next used cell to the left of the given col/row pair.
Cell * getLastCellRow(int row) const
Retrieve the last used cell in a given row.
Cell * getFirstCellRow(int row) const
Retrieve the first used cell in a given row.
void remove(int x, int y)
Removes the cell at the given position, if there is any.
void clear()
Removes all cells from the sheet and frees memory that was used for the clusters.
void clearColumn(int col)
Removes all elements from the column.
bool shiftColumn(const TQPoint &marker)
Moves all cells in the column marker.x() beginning with the one at marker.y() one position downwards.
Cell * getNextCellUp(int col, int row) const
Retrieves the next used cell above the given col/row pair.
void unshiftColumn(const TQPoint &marker)
Moves all cells in the column marker.x() beginning with the one at marker.y() + 1 one position upward...
Cell * getLastCellColumn(int col) const
Retrieve the last used cell in a given column.
Cell * getFirstCellColumn(int col) const
Retrieve the first used cell in a given column.
bool insertColumn(int col)
Moves all columns beginning with col one position to the right.
Value valueRange(int col1, int row1, int col2, int row2) const
Retrieve a range of values stored in a Value.
void removeColumn(int col)
Removes all elements from the column and move all columns right of col one position to the left.
void insert(Cell *cell, int x, int y)
Inserts a cell at the requested position.
Provides a wrapper for cell value.
The KSpread namespace.
Definition commands.h:39