kspread

kspread_cluster.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2000 Torben Weis <weis@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef kspread_cluster_h
00021 #define kspread_cluster_h
00022 
00023 #include "kspread_value.h"
00024 
00025 #define KSPREAD_CLUSTER_LEVEL1 128
00026 #define KSPREAD_CLUSTER_LEVEL2 256
00027 #define KSPREAD_CLUSTER_MAX (128*256)
00028 
00029 class QPoint;
00030 
00031 namespace KSpread
00032 {
00033 class Cell;
00034 class ColumnFormat;
00035 class RowFormat;
00036 
00072 class Cluster
00073 {
00074 public:
00075     Cluster();
00076     ~Cluster();
00077 
00078     Cell* lookup( int x, int y ) const;
00079 
00084     void clear();
00085 
00090     void insert( Cell* cell, int x, int y );
00094     void remove( int x, int y );
00095 
00096     void setAutoDelete( bool );
00097     bool autoDelete() const;
00098 
00099     Cell* firstCell() const;
00100 
00101     bool shiftRow( const QPoint& marker );
00109     bool shiftColumn( const QPoint& marker );
00110 
00115     void unshiftColumn( const QPoint& marker );
00116     void unshiftRow( const QPoint& marker );
00117 
00125     bool insertColumn( int col );
00126     bool insertRow( int row );
00127 
00135     void removeColumn( int col );
00136     void removeRow( int row );
00137 
00142     void clearColumn( int col );
00143     void clearRow( int row );
00144 
00149   Value valueRange (int col1, int row1, int col2, int row2) const;
00150 
00160   Cell* getFirstCellColumn(int col) const;
00161 
00171   Cell* getLastCellColumn(int col) const;
00172 
00182   Cell* getFirstCellRow(int row) const;
00183 
00193   Cell* getLastCellRow(int row) const;
00194 
00204   Cell* getNextCellUp(int col, int row) const;
00205 
00215   Cell* getNextCellDown(int col, int row) const;
00216 
00227   Cell* getNextCellRight(int col, int row) const;
00228 
00239   Cell* getNextCellLeft(int col, int row) const;
00240 
00241 private:
00246     bool shiftRow( const QPoint& marker, bool& work );
00247     bool shiftColumn( const QPoint& marker, bool& work );
00248 
00249     void unshiftColumn( const QPoint& marker, bool& work );
00250     void unshiftRow( const QPoint& marker, bool& work );
00251 
00253     Value makeArray (int col1, int row1, int col2, int row2) const;
00254 
00255     Cell*** m_cluster;
00256     Cell* m_first;
00257     bool m_autoDelete;
00258     int m_biggestX, m_biggestY;
00259 };
00260 
00261 class ColumnCluster
00262 {
00263 public:
00264     ColumnCluster();
00265     ~ColumnCluster();
00266 
00267     const ColumnFormat* lookup( int col ) const;
00268     ColumnFormat* lookup( int col );
00269 
00270     void clear();
00271 
00272     void insertElement( ColumnFormat*, int col );
00273     void removeElement( int col );
00274 
00275     bool insertColumn( int col );
00276     bool removeColumn( int col );
00277 
00278     void setAutoDelete( bool );
00279     bool autoDelete() const;
00280 
00281     ColumnFormat* first() const { return m_first; }
00282     ColumnFormat* next( int col ) const;
00283 
00284 private:
00285     ColumnFormat*** m_cluster;
00286     ColumnFormat* m_first;
00287     bool m_autoDelete;
00288 };
00289 
00290 class RowCluster
00291 {
00292 public:
00293     RowCluster();
00294     ~RowCluster();
00295 
00296     const RowFormat* lookup( int col ) const;
00297     RowFormat* lookup( int col );
00298 
00299     void clear();
00300 
00301     void insertElement( RowFormat*, int row );
00302     void removeElement( int row );
00303 
00304     bool insertRow( int row );
00305     bool removeRow( int row );
00306 
00307     void setAutoDelete( bool );
00308     bool autoDelete() const;
00309 
00310     RowFormat* first() const { return m_first; }
00311     RowFormat* next( int row ) const;
00312 
00313 private:
00314     RowFormat*** m_cluster;
00315     RowFormat* m_first;
00316     bool m_autoDelete;
00317 };
00318 
00319 } // namespace KSpread;
00320 
00321 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys