summaryrefslogtreecommitdiffstats
path: root/kspread/kspread_sheet.h
blob: ff6272aced71e583ef2562e7ff2270fac4e02d65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
/* This file is part of the KDE project
   Copyright 1998, 1999 Torben Weis <weis@kde.org>
   Copyright 1999- 2006 The KSpread Team
                        www.koffice.org/kspread

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef KSPREAD_SHEET
#define KSPREAD_SHEET

#include <tqclipboard.h>
#include <tqdragobject.h>
#include <tqintdict.h>
#include <tqmemarray.h>
#include <tqpen.h>
#include <tqptrlist.h>
#include <tqrect.h>
#include <tqwidget.h>

#include <KoDocument.h>
#include <KoDocumentChild.h>
#include <KoOasisSettings.h> // for KoOasisSettings::NamedMap

#include "kspread_autofill.h"
#include "kspread_cell.h"
#include "kspread_format.h"
#include "kspread_global.h"
#include "kspread_object.h"

class TQWidget;
class TQPainter;
class TQDomElement;
class DCOPObject;
class KPrinter;
class KoDocumentEntry;
class KoStyleStack;
class KoGenStyles;
class KoOasisLoadingContext;
class KoOasisSettings;
class KoOasisStyles;
class KCommand;
class KoPicture;
class KoXmlWriter;

namespace KoChart
{
class Part;
}

namespace KSpread
{
class Canvas;
class Cell;
class EmbeddedChart;
class DependencyManager;
class Doc;
class GenValidationStyles;
class Map;
class Point;
class Region;
class Selection;
class Sheet;
class SheetPrint;
class Style;
class UndoInsertRemoveAction;
class View;
class EmbeddedKOfficeObject;
class EmbeddedObject;

/********************************************************************
 *
 * CellBinding
 *
 ********************************************************************/

/**
 * @short This is an abstract base class only.
 */
class CellBinding : public TQObject
{
    Q_OBJECT
  TQ_OBJECT
public:
    CellBinding( Sheet *_sheet, const TQRect& _area );
    virtual ~CellBinding();

    bool contains( int _x, int _y );
    /**
     * Call this function if one of the cells covered by this binding ( @see #rect )
     * has changed. This will in turn force for example a chart to update.
     *
     * @param _obj may by 0L. In this case all cells may have changed.
     */
    virtual void cellChanged( Cell *_obj );

    virtual void setIgnoreChanges( bool _ignore ) { m_bIgnoreChanges = _ignore; }

    virtual TQRect& dataArea() { return m_rctDataArea; }
    virtual void setDataArea( const TQRect _rect ) { m_rctDataArea = _rect; }

    Sheet* sheet()const { return m_pSheet; }

signals:
    void changed( Cell *_obj );

protected:
    TQRect m_rctDataArea;
    Sheet *m_pSheet;
    bool m_bIgnoreChanges;
};

class ChartBinding : public CellBinding
{
    Q_OBJECT
  TQ_OBJECT
public:

    ChartBinding( Sheet *_sheet, const TQRect& _area, EmbeddedChart *_child );
    virtual ~ChartBinding();

    virtual void cellChanged( Cell *_obj );

private:
    EmbeddedChart* m_child;
};

/********************************************************************
 *
 * TextDrag
 *
 ********************************************************************/

/**
 * @short This is a class for handling clipboard data
 */

class TextDrag : public TQTextDrag
{
    Q_OBJECT
  TQ_OBJECT

public:
    TextDrag( TQWidget * dragSource = 0L, const char * name = 0L );
    virtual ~TextDrag();

    void setPlain( TQString const & _plain ) { setText( _plain ); }
    void setKSpread( TQByteArray const & _kspread ) { m_kspread = _kspread; }

    virtual TQByteArray encodedData( const char * mime ) const;
    virtual const char* format( int i ) const;

    static bool canDecode( TQMimeSource * e );

    static const char * selectionMimeType();

protected:
    TQByteArray m_kspread;
};


/********************************************************************
 *
 * Sheet
 *
 ********************************************************************/

/**
 */
class KSPREAD_EXPORT Sheet : public TQObject
{
    friend class Cell;

    Q_OBJECT
  TQ_OBJECT


    TQ_PROPERTY( TQString sheetName READ sheetName )
    TQ_PROPERTY( bool autoCalc READ getAutoCalc WRITE setAutoCalc )
    TQ_PROPERTY( bool showGrid READ getShowGrid WRITE setShowGrid )

public:
    enum Direction { Right, Left, Up, Down };
    enum SortingOrder{ Increase, Decrease };
    enum ChangeRef { ColumnInsert, ColumnRemove, RowInsert, RowRemove };
    enum TestType { Text, Validity, Comment, ConditionalCellAttribute };

    enum LayoutDirection { LeftToRight, RightToLeft };

    Sheet ( Map* map, const TQString &sheetName, const char *_name=0L );
    ~Sheet();

    virtual bool isEmpty( unsigned long int x, unsigned long int y ) const;

    /**
     * Return the name of this sheet.
     */
    TQString sheetName() const;

    /**
     * \deprecated Use sheetName().
     */
    TQString tableName() const { return sheetName(); }

    /**
     * Renames a sheet. This will automatically adapt all formulas
     * in all sheets and all cells to reflect the new name.
     *
     * If the name really changed then @ref #sig_nameChanged is emitted
     * and the GUI will reflect the change.
     *
     * @param init If set to true then no formula will be changed and no signal
     *             will be emitted and no undo action created. Usually you dont
     *             want to do that.
     *
     *
     * @return false if the sheet could not be renamed. Usually the reason is
     *         that this name is already used.
     *
     * @see #changeCellTabName
     * @see TabBar::renameTab
     * @see #sheetName
     */
    bool setSheetName( const TQString& name, bool init = false, bool makeUndo=true );

    Map* workbook() const;
    Doc* doc() const;

    /**
     * Saves the sheet and all it's children in XML format
     */
    virtual TQDomElement saveXML( TQDomDocument& );
    /**
     * Loads the sheet and all it's children in XML format
     */
    virtual bool loadXML( const TQDomElement& );

    virtual bool loadOasis( const TQDomElement& sheet, KoOasisLoadingContext& oasisContext, TQDict<Style>& styleMap );

    virtual bool saveOasis( KoXmlWriter & xmlWriter, KoGenStyles &mainStyles, GenValidationStyles &valStyle, KoStore *store, KoXmlWriter* manifestWriter, int & indexObj, int &partIndexObj );
    void saveOasisHeaderFooter( KoXmlWriter &xmlWriter ) const;

    void loadOasisObjects( const TQDomElement& e, KoOasisLoadingContext& oasisContext );
    void loadOasisSettings( const KoOasisSettings::NamedMap &settings );
    void saveOasisSettings( KoXmlWriter &settingsWriter ) const;
    void saveOasisPrintStyleLayout( KoGenStyle &style ) const;

    /**
     * Saves a children
     */
    virtual bool saveChildren( KoStore* _store, const TQString &_path );
    bool saveOasisObjects( KoStore *store, KoXmlWriter &xmlWriter, KoGenStyles& mainStyles, int & indexObj, int &partIndexObj );
    /**
     * Loads a children
     */
    virtual bool loadChildren( KoStore* _store );

    bool isLoading();


    /**
     * @brief Get a list of all selected objects
     *
     * @return list of selected objets.
     */
    TQPtrList<EmbeddedObject> getSelectedObjects();


    /**
     * @brief get the rect for the objects
     *
     * @param all true if the rect for all objects shoud be returned
     *        false if only the rect for selected objects sould be returned
     *
     * @return rect of the objects
     */
    KoRect getRealRect( bool all );

    //return command when we move object
    KCommand *moveObject(View *_view, double diffx, double diffy);
    KCommand *moveObject(View *m_view,const KoPoint &_move,bool key);

    /**
     * @brief Create a uniq name for an object.
     *
     * Create a uniq name for the object. If no name is set for the object
     * a name according to its type is created. If the name already exists
     * append ' (x)'. // FIXME: not allowed by I18N
     *
     * @param object to work on
     */
    void unifyObjectName( EmbeddedObject *object );

    /**
     * Returns the tqlayout direction of the sheet.
     */
    LayoutDirection layoutDirection() const;

    /**
     * Sets the tqlayout direction of the sheet. For example, for Arabic or Hebrew
     * documents, it is possibly to tqlayout the sheet from right to left.
     */
    void setLayoutDirection( LayoutDirection dir );

    /**
     * \deprecated Use direction().
     */
    bool isRightToLeft() const;

    void password( TQCString & passwd ) const ;
    bool isProtected() const;
    void setProtected( TQCString const & passwd );
    bool checkPassword( TQCString const & passwd ) const;

    void setDefaultHeight( double height );
    void setDefaultWidth( double width );

    const ColumnFormat* columnFormat( int _column ) const;
    ColumnFormat* columnFormat( int _column );
    /**
     * If no special @ref ColumnFormat exists for this column, then a new one is created.
     *
     * @return a non default ColumnFormat for this column.
     */
    ColumnFormat* nonDefaultColumnFormat( int _column, bool force_creation = true );

    const RowFormat* rowFormat( int _row ) const;
    RowFormat* rowFormat( int _row );
    /**
     * If no special @ref RowFormat exists for this row, then a new one is created.
     *
     * @return a non default RowFormat for this row.
     */
    RowFormat* nonDefaultRowFormat( int _row, bool force_creation = true );

    /**
     * @return the first cell of this sheet. Next cells can
     * be retrieved by calling @ref Cell::nextCell.
     */
    Cell* firstCell() const;

    RowFormat* firstRow() const;

    ColumnFormat* firstCol() const;

    Cell* cellAt( int _column, int _row ) const;
    /**
     * @param _scrollbar_update will change the scrollbar if set to true disregarding
     *                          whether _column/_row are bigger than
     *                          m_iMaxRow/m_iMaxColumn. May be overruled by
     *                          @ref #m_bScrollbarUpdates.
     */
    Cell* cellAt( int _column, int _row, bool _scrollbar_update = false );
    /**
     * A convenience function.
     */
    Cell* cellAt( const TQPoint& _point, bool _scrollbar_update = false )
      { return cellAt( _point.x(), _point.y(), _scrollbar_update ); }
    /**
     * @returns the pointer to the cell that is visible at a certain position. That means If the cell
     *          at this position is obscured then the obscuring cell is returned.
     *
     * @param _scrollbar_update will change the scrollbar if set to true disregarding
     *                          whether _column/_row are bigger than
     *                          m_iMaxRow/m_iMaxColumn. May be overruled by
     *                          @ref #m_bScrollbarUpdates.
     */
    Cell* visibleCellAt( int _column, int _row, bool _scrollbar_update = false );
    /**
     * If no special Cell exists for this position then a new one is created.
     *
     * @param _scrollbar_update will change the scrollbar if set to true disregarding
     *                          whether _column/_row are bigger than
     *                          m_iMaxRow/m_iMaxColumn. May be overruled by
     *                          @ref #m_bScrollbarUpdates.
     *
     * @return a non default Cell for the position.
     */
    Cell* nonDefaultCell( int _column, int _row, bool _scrollbar_update = false, Style * _style = 0 );
    Cell* nonDefaultCell( TQPoint const & cellRef, bool scroll = false )
      { return nonDefaultCell( cellRef.x(), cellRef.y(), scroll ); }

    Cell* defaultCell() const;

    Format* defaultFormat();
    const Format* defaultFormat() const;

    /** retrieve a value */
    Value value (int col, int row) const;
    /** retrieve a range of values */
    Value valueRange (int col1, int row1, int col2, int row2) const;

    TQRect visibleRect( Canvas const * const _canvas ) const;
    int topRow( double _ypos, double &_top, const Canvas *_canvas = 0L ) const;
    int bottomRow( double _ypos, const Canvas *_canvas = 0L ) const;
    int leftColumn( double _xpos, double &_left, const Canvas *_canvas = 0L ) const;
    int rightColumn( double _xpos, const Canvas *_canvas = 0L ) const;

    /**
     * @return the left corner of the column as int.
     *
     * @param _canvas If not 0 then the returned position is in screen
     *                coordinates. Otherwise the point (0|0) is in the upper
     *                left corner of the sheet.
     */
    int columnPos( int _col, const Canvas *_canvas = 0L ) const;
    /**
     * @return the left corner of the column as double.
     * Use this method, when you later calculate other positions depending on this one
     * to avoid rounding problems
     *
     * @param _canvas If not 0 then the returned position is in screen
     *                coordinates. Otherwise the point (0|0) is in the upper
     *                left corner of the sheet.
     */
    double dblColumnPos( int _col, const Canvas *_canvas = 0L ) const;
    /**
     * @return the top corner of the row as int.
     *
     * @param _canvas If not 0 then the returned position is in screen
     *                coordinates. Otherwise the point (0|0) is in the upper
     *                top corner of the sheet.
     */
    int rowPos( int _row, const Canvas *_canvas = 0L ) const;
    /**
     * @return the top corner of the row as double.
     * Use this method, when you later calculate other positions depending on this one
     * to avoid rounding problems
     *
     * @param _canvas If not 0 then the returned position is in screen
     *                coordinates. Otherwise the point (0|0) is in the upper
     *                top corner of the sheet.
     */
    double dblRowPos( int _row, const Canvas *_canvas = 0L ) const;

    /**
     * @return the maximum size of the column range
     */
    double sizeMaxX() const ;
    /**
     * @return the maximum size of the row range
     */
    double sizeMaxY() const;

    /**
     * Adjusts the internal reference of the sum of the widths of all columns.
     * Used in resizing of columns.
     */
    void adjustSizeMaxX ( double _x );

    /**
     * Adjusts the internal reference of the sum of the heights of all rows.
     * Used in resizing of rows.
     */
    void adjustSizeMaxY ( double _y );

    /**
     * Sets the @ref Cell::layoutDirtyFlag in all cells.
     */
    void setLayoutDirtyFlag();
    /**
     * Sets the @ref Cell::calcDirtyFlag in all cells.
     * That means that the cells are marked dirty and will recalculate
     * if requested. This function does only MARK, it does NOT actually calculate.
     * Use @ref #recalc to recaculate dirty values.
     */
    void setCalcDirtyFlag();

    /**
     * Calculates all cells in the sheet with the CalcDirtyFlag.
     */
  //why on earth would we want to do this?
//    void calc();

    /**
     * Recalculates the current sheet. If you want to recalculate EVERYTHING, then
     * call @ref Sheet::setCalcDirtyFlag for all sheets in the @ref #m_pMap to make
     * sure that no invalid values in other sheets make you trouble.
     *
     * Recalc will do nothing if automatic calculation is disabled (via @ref Sheet::setAutoCalc ).
     * unless the force flag is set to true.  Automatic recalculation is enabled by default.
     *
     * @param force If false, the sheet will be recalculated if automatic calculation is enabled.
     * If true, the sheet will be recalculated regardless of the automatic calculation setting.
     */
    void recalc( bool force );
    /**
     * Recalculates the current sheet, if automatic recalculation is enabled.
     */
    void recalc();


    /** handles the fact that a cell has been changed - updates
    things that need to be updated */
    void valueChanged (Cell *cell);

    /**
    * Attempts to guess the title (or 'header') of a column, within a given area of the sheet
    * This is used, for example, by the Data Sort dialog, to guess the names of columns
    * within the selected area.  An empty string may be returned if guessColumnTitle does not think
    * that column @p col has a title.
    * @param area The area within the sheet to guess from
    * @param col The column to find the title (or 'header') for.
    */
    TQString guessColumnTitle(TQRect& area, int col);

    /**
    * Attempts to guess the title (or 'header') of a row, within a given area of the sheet
    * This is used, for example, by the Data Sort dialog, to guess the names of rows within the selected area.
    * An empty string may be returned if guessRowTitle does not think that row @p row has a title.
    * @param area The area within the sheet to guess from
    * @param row The row to find the title (or 'header') for.
    */
    TQString guessRowTitle(TQRect& area, int row);

    /**
     * Sets the contents of the cell at row,column to text
     */
    void setText( int row, int column, const TQString& text,
                  bool asString = false );
    void setArrayFormula (Selection *selectionInfo, const TQString &_text);


    void setSelectionFont( Selection* selectionInfo,
                           const char *_font = 0L, int _size = -1,
                           signed char _bold = -1, signed char _italic = -1,
                           signed char _underline = -1,
                           signed char _strike = -1 );

    void setSelectionMoneyFormat( Selection* selectionInfo, bool b );
    void setSelectionAlign( Selection* selectionInfo,
                            Format::Align _align );
    void setSelectionAlignY( Selection* selectionInfo,
                             Format::AlignY _alignY );
    void setSelectionPrecision( Selection* selectionInfo, int _delta );
    void setSelectionPercent( Selection* selectionInfo, bool b );
    void setSelectionMultiRow( Selection* selectionInfo, bool enable );
    void setSelectionStyle( Selection* selectionInfo, Style * style );

    /**
    * setSelectionSize increase or decrease font size
    */
    void setSelectionSize( Selection* selectionInfo, int _size );

    /**
     *change string to upper case if _type equals 1
     * or change string to lower if _type equals -1
     */
    void setSelectionUpperLower( Selection* selectionInfo, int _type );

    void setSelectionfirstLetterUpper( Selection* selectionInfo);

    void setSelectionVerticalText( Selection* selectionInfo, bool _b);

    void setSelectionComment( Selection* selectionInfo,
                              const TQString &_comment);
    void setSelectionRemoveComment(Selection* selectionInfo);

    void setSelectionAngle(Selection* selectionInfo, int _value );

    void setSelectionTextColor( Selection* selectionInfo,
                                const TQColor &tbColor );
    void setSelectionbgColor( Selection* selectionInfo,
                              const TQColor &bg_Color );
    void setSelectionBorderColor( Selection* selectionInfo,
                                  const TQColor &bd_Color );

    /**
     * @param _marker is used if there is no selection currently.
     *                In this case the cell on which the marker is will
     *                be deleted.
     *
     */
    void deleteSelection( Selection* selectionInfo, bool undo = true );

    /**
     * @param _marker is used if there is no selection currently.
     *                In this case the cell on which the marker is will
     *                be copied.
     */
    void copySelection( Selection* selectionInfo );
    /**
     * @param _marker is used if there is no selection currently.
     *                In this case the cell on which the marker is will
     *                be cut.
     */
    void cutSelection( Selection* selectionInfo );
    /**
     * @param _marker is used if there is no selection currently.
     *                In this case the cell on which the marker is will
     *                be cleared.
     */
    void clearTextSelection( Selection* selectionInfo );

    void clearValiditySelection(Selection* selectionInfo );

    void clearConditionalSelection(Selection* selectionInfo );

    void fillSelection( Selection * selectionInfo, int direction );

    void setWordSpelling(Selection* selectionInfo,const TQString _listWord );

    TQString getWordSpelling(Selection* selectionInfo );

    /**
     * A convenience function which retrieves the data to be pasted
     * from the clipboard.
     */
    void paste( const TQRect & pasteArea, bool makeUndo = true,
                Paste::Mode = Paste::Normal, Paste::Operation = Paste::OverWrite,
                bool insert = false, int insertTo = 0, bool pasteFC = false,
                TQClipboard::Mode clipboardMode = TQClipboard::Clipboard );
    void paste( const TQByteArray & data, const TQRect & pasteArea,
                bool makeUndo = false, Paste::Mode= Paste::Normal, Paste::Operation = Paste::OverWrite,
                bool insert = false, int insertTo = 0, bool pasteFC = false );
    void defaultSelection( Selection* selectionInfo );

    /**
     * A function which allows to paste a text plain from the clipboard
     */
    void pasteTextPlain( TQString &_text, TQRect pasteArea);

    void sortByRow( const TQRect &area, int ref_row, SortingOrder );
    void sortByRow( const TQRect &area, int key1, int key2, int key3,
                    SortingOrder order1, SortingOrder order2, SortingOrder order3,
                    TQStringList const * firstKey, bool copyFormat, bool headerRow,
                    Point const & outputPoint, bool respectCase );
    void sortByColumn( const TQRect &area, int ref_column, SortingOrder );
    void sortByColumn( const TQRect &area, int key1, int key2, int key3,
                       SortingOrder order1, SortingOrder order2, SortingOrder order3,
                       TQStringList const * firstKey, bool copyFormat, bool headerCol,
                       Point const & outputPoint, bool respectCase );
    void swapCells( int x1, int y1, int x2, int y2, bool cpFormat );

    /**
     * @param x1, y1: values from source cell,
     * @param x2, y2: values from target cell
     * @param cpFormat: if true: cell format gets copied, too
     */
    void copyCells( int x1, int y1, int x2, int y2, bool cpFormat );
    void setSeries( const TQPoint &_marker, double start, double end, double step, Series mode, Series type );

    /**
     * Moves all cells of the row _marker.y() which are in
     * the column _marker.x() or right hand of that one position
     * to the right.
     *
     * @return true if the shift was possible, or false otherwise.
     *         A reason for returning false is that there was a cell
     *         in the right most position.
     */
    bool shiftRow( const TQRect &_rect, bool makeUndo=true );
    bool shiftColumn( const TQRect& rect, bool makeUndo=true );

    void unshiftColumn( const TQRect& rect, bool makeUndo=true );
    void unshiftRow( const TQRect& rect, bool makeUndo=true );

    /**
     * Moves all columns which are >= @p col one position to the right and
     * inserts a new and empty column. After this the sheet is redrawn.
     * nbCol is the number of column which are installing
     */
    bool insertColumn( int col, int nbCol=0, bool makeUndo=true );
    /**
     * Moves all rows which are >= @p row one position down and
     * inserts a new and empty row. After this the sheet is redrawn.
     */
    bool insertRow( int row, int nbRow=0, bool makeUndo=true );

    /**
     * Deletes the column @p col and redraws the sheet.
     */
    void removeColumn( int col, int nbCol=0, bool makeUndo=true );
    /**
     * Deletes the row @p row and redraws the sheet.
     */
    void removeRow( int row, int nbRow=0, bool makeUndo=true );

    /**
    * hide row
    */
    void hideRow(const Region&);
    void emitHideRow();
    void showRow(const Region&);

    /**
    * hide column
    */
    void hideColumn(const Region&);
    void emitHideColumn();
    void showColumn(const Region&);

    /**
     * Adjust columns and rows of a region
     */
    void adjustArea(const Region&);
    /**
     * Adjust columns of a region
     */
    void adjustColumn(const Region&);
    /**
     * Adjust rows of a region
     */
    void adjustRow(const Region&);

    /**
     * Install borders
     */
    void borderLeft( Selection* selectionInfo, const TQColor &_color );
    void borderTop( Selection* selectionInfo, const TQColor &_color );
    void borderOutline( Selection* selectionInfo, const TQColor &_color );
    void borderAll( Selection* selectionInfo, const TQColor &_color );
    void borderRemove( Selection* selectionInfo );
    void borderBottom( Selection* selectionInfo, const TQColor &_color );
    void borderRight( Selection* selectionInfo, const TQColor &_color );

    void setConditional( Selection* selectionInfo,
       TQValueList<Conditional> const & newConditions );

    void setValidity( Selection* selectionInfo, KSpread::Validity tmp );

    /**
     * Returns, if the grid shall be shown on the screen
     */
    bool getShowGrid() const;

    /**
     * Sets, if the grid shall be shown on the screen
     */
    void setShowGrid( bool _showGrid );

    /**
     * Sets, if formula shall be shown instead of the result
     */
    bool getShowFormula() const;

    void setShowFormula(bool _showFormula);

    /**
     * Sets, if indicator must be shown when the cell holds a formula
     */
    bool getShowFormulaIndicator() const;

    void setShowFormulaIndicator(bool _showFormulaIndicator);

    /**
     * Returns true if comment indicator is visible.
     */
    bool getShowCommentIndicator() const;

    /**
     * If b is true, comment indicator is visible, otherwise
     * it will be hidden.
     */
    void setShowCommentIndicator( bool b );

    bool getLcMode() const;

    void setLcMode(bool _lcMode);

    bool getAutoCalc() const;

    void setAutoCalc(bool _AutoCalc);

    bool getShowColumnNumber() const;

    void setShowColumnNumber(bool _showColumnNumber);

    bool getHideZero() const;

    void setHideZero(bool _hideZero);

    bool getFirstLetterUpper() const;

    void setFirstLetterUpper(bool _firstUpper);

    // TODO Stefan: remove after kspread_undo.cc|h and commands.cc|h are obsolete
    void changeMergedCell( int /*m_iCol*/, int /*m_iRow*/, int /*m_iExtraX*/, int /*m_iExtraY*/) {}

    /**
     * @param region the region to merge
     * @param hor merge horizontally
     * @param ver merge vertically
     */
    void mergeCells( const Region& region, bool hor = false, bool ver = false );
    void dissociateCells( const Region &region );

    void increaseIndent( Selection* selectionInfo );
    void decreaseIndent( Selection* selectionInfo );

    bool areaIsEmpty(const Region& area, TestType _type = Text) ;

    void refreshPreference() ;

    void hideSheet(bool _hide);

    void removeSheet();

    TQRect selectionCellMerged(const TQRect &_sel);
    /**
     * Change name of reference when the user inserts or removes a column,
     * a row or a cell (= insertion of a row [or column] on a single column [or row]).
     * For example the formula =Sheet1!A1 is changed into =Sheet1!B1 if a Column
     * is inserted before A.
     *
     * @param pos the point of insertion (only one coordinate may be used, depending
     * on the other parameters).
     * @param fullRowOrColumn if true, a whole row or column has been inserted/removed.
     *                        if false, we inserted or removed a cell
     * @param ref see ChangeRef
     * @param tabname completes the pos specification by giving the sheet name
     * @param undo is the handler of the undo class in case of lost cell references
     */
    void changeNameCellRef( const TQPoint & pos, bool fullRowOrColumn,
                            ChangeRef ref, TQString tabname, int NbCol = 1,
                            UndoInsertRemoveAction * undo = 0 );


    void refreshRemoveAreaName(const TQString &_areaName);
    void refreshChangeAreaName(const TQString &_areaName);


    /**
     * Update chart when you insert or remove row or column
     *
     * @param pos the point of insertion (only one coordinate may be used, depending
     * on the other parameters).
     * @param fullRowOrColumn if true, a whole row or column has been inserted/removed.
     *                        if false, we inserted or removed a cell
     * @param ref see ChangeRef
     * @param tabname completes the pos specification by giving the sheet name
     */
    void refreshChart(const TQPoint & pos, bool fullRowOrColumn, ChangeRef ref);
    /**
     * Refresh merged cell when you insert or remove row or column
     */
    void refreshMergedCell();

    /**
     * @return true if this sheet is hidden
     */
    bool isHidden()const;
    /**
     * Hides or shows this sheets
     */
    void setHidden( bool hidden );

    /**
     * @return a painter for the hidden widget ( @ref #widget ).
     *
     * This function is useful while making formats where you
     * need some TQPainter related functions.
     */
    TQPainter& painter();
    /**
     * @return a hidden widget.
     *
     * @see #painter
     */
    TQWidget* widget()const;

    /**
     * @return a flag that indicates whether the sheet should paint the page breaks.
     *
     * @see #setShowPageBorders
     * @see #bShowPageBorders
     */
    bool isShowPageBorders() const;

    /**
     * Turns the page break lines on or off.
     *
     * @see #isShowPageBorders
     * @see #bShowPageBorders
     */
    void setShowPageBorders( bool _b );

    void addCellBinding( CellBinding *_bind );
    void removeCellBinding( CellBinding *_bind );
    CellBinding* firstCellBinding();
    CellBinding* nextCellBinding();

    /**
     * Used by the 'chart' to get the sheet on which the chart is build.
     * The cells we are interested in are in the rectangle '_range'.
     * The cells are stored row after row in '_list'.
     */
    bool getCellRectangle( const TQRect &_range, TQPtrList<Cell> &_list );

    /**
     * A convenience function that finds a sheet by its name.
     */
    Sheet *findSheet( const TQString & _name );

    /**
     * Inserts the @p _cell into the sheet.
     * All cells depending on this cell will be actualized.
     * The border range will be actualized, when the cell is out of current range.
     */
    void insertCell( Cell *_cell );
    /**
     * Used by Undo.
     *
     * @see UndoDeleteColumn
     */
    void insertColumnFormat( ColumnFormat *_l );
    /**
     * Used by Undo.
     *
     * @see UndoDeleteRow
     */
    void insertRowFormat( RowFormat *_l );

    /**
     * @see #copy
     *
     * @param era set this to true if you want to encode relative references absolutely (they will
     *            be switched back to relative references during decoding) - used for cut to clipboard
     */
    TQDomDocument saveCellRegion(const Region&, bool copy = false, bool era = false);

    /**
    * insertTo defined if you insert to the bottom or right
    * insert to bottom if insertTo==1
    * insert to right if insertTo ==-1
    * insertTo used just for insert/paste an area
     * @see #paste
     */
    bool loadSelection( const TQDomDocument& doc, const TQRect &pasteArea,
                        int _xshift, int _yshift, bool makeUndo,
                        Paste::Mode = Paste::Normal, Paste::Operation = Paste::OverWrite,
                        bool insert = false, int insertTo = 0, bool paste = false );

    void loadSelectionUndo( const TQDomDocument & doc, const TQRect &loadArea,
                            int _xshift, int _yshift,bool insert,int insertTo);

    /**
    * Used when you insert and paste cell
    * return true if it's a area
    * false if it's a column/row
    * it's used to select if you want to insert at the bottom or right
    * @see #paste
     */
    bool testAreaPasteInsert()const;

    /**
     * Deletes all cells in the given rectangle.
     * The display is NOT updated by this function.
     * This function can be used to clear an area before you paste something from the clipboard
     * in this area.
     *
     * @param region The region that contains the cells that should be deleted
     *
     * @see #loadCells
     */
    void deleteCells(const Region& region);


    /**
     * Return true if there are text value in cell
     * so you can create list selection
     */
    bool testListChoose(Selection* selectionInfo);

    /**
     * returns the text to be copied to the clipboard
     */
    TQString copyAsText(Selection* selection);

    /**
     * Assume that the retangle 'src' was already selected. Then the user clicked on the
     * lower right corner of the marker and resized the area ( left mouse button ).
     * Once he releases the mouse we have to autofill the region 'dest'. Mention that
     * src.left() == dest.left() and src.top() == dest.top().
     *
     * @see #mouseReleaseEvent
     */
    void autofill( TQRect &src, TQRect &dest );


    bool insertChild( const KoRect& _geometry, KoDocumentEntry& );

    bool insertChart( const KoRect& _geometry, KoDocumentEntry&, const TQRect& _data );


    /**
     * Creates a new embedded picture object and inserts it into the sheet next to the currently
     * selected cell.
     *
     * TODO:  Remove this method in future and provide a better way of opening pictures and inserting
     * them into the sheet.
     *
     * @param file The URL of the file to insert.
     * @param point The the top-left point in the sheet where the picture should be inserted.
     */
    bool insertPicture( const KoPoint& point , const KURL& file );

    /**
     * Creates a new embedded picture object and inserts it into the sheet at the specified position.
     *
     * @param point The top-left position for the new picture object in the sheet
     * @param pixmap The source pixmap for the new picture
     */
    bool insertPicture( const KoPoint& point, const TQPixmap& pixmap );

    void changeChildGeometry( EmbeddedKOfficeObject *_child, const KoRect& _geometry );

    const TQColorGroup& colorGroup() { return widget()->colorGroup(); }

    int id() const;

    /**
     * Return the currently maximum defined column of the horizontal scrollbar.
     * It's always 10 times higher than the maximum access column.
     * In an empty sheet it starts with 256.
     */
    int maxColumn() const ;

    /**
     * Checks if the argument _column is out of the current maximum range of the vertical border
     * If this is the case, the current maximum value m_iMaxColumn is adjusted and the vertical border
     * is resized.
     * Use this function with care, as it involves a repaint of the border, when it is out of range.
     */
    void checkRangeHBorder ( int _column );

    /**
     * Return the currently maximum defined row of the vertical scrollbar.
     * It's always 10 times higher than the maximum access row.
     * In an empty sheet it starts with 256.
     */
    int maxRow() const ;

    /**
     * Checks if the argument _row is out of the current maximum range of the horizontal border
     * If this is the case, the current maximum value m_iMaxRow is adjusted and the horizontal border
     * is resized.
     * Use this function with care, as it involves a repaint of the border, when it is out of range.
     */
    void checkRangeVBorder ( int _row );


    void enableScrollBarUpdates( bool _enable );

    virtual DCOPObject* dcopObject();

    static Sheet* find( int _id );

#ifndef NDEBUG
    void printDebug();
#endif

    /**
     * Calculates the cell if necessary, makes its tqlayout if necessary,
     * and force redraw.
     * Then it sets the cell's @ref Cell::m_bDisplayDirtyFlag to false.
     */
    void updateCell( Cell* _cell, int _col, int _row );

    /**
     * Like updateCell except it works on a range of cells.  Use this function
     * rather than calling updateCell(..) on several adjacent cells so there
     * will be one paint event instead of several
     */
    void updateCellArea(const Region& cellArea);

    /**
     * Updates every cell on the sheet
     */
    void update();

    /**
     * repaints all visible cells
     */
    void updateView();

    /**
     * repaints all visible cells in the given rect
     */
    void updateView( TQRect const & rect );

    /**
     * repaints all visible cells in the given rect
     */
    void updateView(Region*);

    /**
     * used to refresh cells when you make redodelete
     */
    void refreshView(const Region& region);

    void emit_updateRow( RowFormat *_format, int _row, bool repaint = true );
    void emit_updateColumn( ColumnFormat *_format, int _column );

    /**
     * Needed for @ref Cell::leftBorderPen and friends, since we can not
     * have a static pen object.
     *
     * The returned pen has pen style NoPen set.
     */
    const TQPen& emptyPen() const ;
    const TQBrush& emptyBrush() const;
    const TQColor& emptyColor() const;

    void updateLocale();


  /**
   * set a region of the spreadsheet to be 'paint dirty' meaning it
   * needs repainted.  This is not a flag on the cell itself since quite
   * often this needs set on a default cell
   */
  void setRegionPaintDirty(TQRect const & range);
  void setRegionPaintDirty(Region const & region);

  /**
   * Remove all records of 'paint dirty' cells
   */
  void clearPaintDirtyData();

  /**
   * Test whether a cell needs repainted
   */
  bool cellIsPaintDirty(TQPoint const & cell) const;

  /**
   * Retrieve the first used cell in a given column.  Can be used in conjunction
   * with getNextCellDown to loop through a column.
   *
   * @param col The column to get the first cell from
   *
   * @return Returns a pointer to the cell, or NULL if there are no used cells
   *         in this column
   */
  Cell* getFirstCellColumn(int col) const;

  /**
   * Retrieve the last used cell in a given column.  Can be used in conjunction
   * with getNextCellUp to loop through a column.
   *
   * @param col The column to get the cell from
   *
   * @return Returns a pointer to the cell, or NULL if there are no used cells
   *         in this column
   */
  Cell* getLastCellColumn(int col) const;

  /**
   * Retrieve the first used cell in a given row.  Can be used in conjunction
   * with getNextCellRight to loop through a row.
   *
   * @param row The row to get the first cell from
   *
   * @return Returns a pointer to the cell, or NULL if there are no used cells
   *         in this row
   */
  Cell* getFirstCellRow(int row) const;

  /**
   * Retrieve the last used cell in a given row.  Can be used in conjunction
   * with getNextCellLeft to loop through a row.
   *
   * @param row The row to get the last cell from
   *
   * @return Returns a pointer to the cell, or NULL if there are no used cells
   *         in this row
   */
  Cell* getLastCellRow(int row) const;

  /**
   * Retrieves the next used cell above the given col/row pair.  The given
   * col/row pair does not need to reference a used cell.
   *
   * @param col column to start looking through
   * @param row the row above which to start looking.
   *
   * @return Returns the next used cell above this one, or NULL if there are none
   */
  Cell* getNextCellUp(int col, int row) const;

  /**
   * Retrieves the next used cell below the given col/row pair.  The given
   * col/row pair does not need to reference a used cell.
   *
   * @param col column to start looking through
   * @param row the row below which to start looking.
   *
   * @return Returns the next used cell below this one, or NULL if there are none
   */
  Cell* getNextCellDown(int col, int row) const;

  /**
   * Retrieves the next used cell to the right of the given col/row pair.
   * The given col/row pair does not need to reference a used cell.
   *
   * @param col the column after which should be searched
   * @param row the row to search through
   *
   * @return Returns the next used cell to the right of this one, or NULL if
   * there are none
   */
  Cell* getNextCellLeft(int col, int row) const;

  /**
   * Retrieves the next used cell to the left of the given col/row pair.
   * The given col/row pair does not need to reference a used cell.
   *
   * @param col the column before which should be searched
   * @param row the row to search through
   *
   * @return Returns the next used cell to the left of this one, or NULL if
   * there are none
   */
  Cell* getNextCellRight(int col, int row) const;

  SheetPrint * print() const;

  /** returns a pointer to the dependency manager */
  KSpread::DependencyManager *dependencies ();

  /**
   * @brief Get the amount of selected objects that belong to this sheet
             *
             * @return the amount of select objects in this sheet
   */
  int numSelected() const;

//return command when we move object
//     KCommand *moveObject(KSpreadView *_view, double diffx, double diffy);
//     KCommand *moveObject(KSpreadView *m_view,const KoPoint &_move,bool key);


signals:
    void sig_refreshView();
    void sig_updateView( Sheet *_sheet );
    void sig_updateView( Sheet *_sheet, const Region& );
    void sig_updateView( EmbeddedObject *obj );
    void sig_updateHBorder( Sheet *_sheet );
    void sig_updateVBorder( Sheet *_sheet );
    void sig_updateChildGeometry( EmbeddedKOfficeObject *_child );
    void sig_maxColumn( int _max_column );
    void sig_maxRow( int _max_row );
    /**
     * @see #setSheetName
     */
    void sig_nameChanged( Sheet* sheet, const TQString& old_name );
    /**
     * Emitted if a certain area of some sheet has to be redrawn.
     * That is for example the case when a new child is inserted.
     */
    void sig_polygonInvalidated( const TQPointArray& );

    void sig_SheetHidden( Sheet* sheet);
    void sig_SheetShown( Sheet* sheet);
    void sig_SheetRemoved( Sheet* sheet);
    void sig_SheetActivated( Sheet* );
    void sig_RefreshView( Sheet* );

protected slots:
  /** react on modification (add/remove) of a named area */
  void slotAreaModified (const TQString &name);

protected:
     /** Updates dependencies for all cells on this sheet */
     void updateAllDependencies();

    /**
     * Change the name of a sheet in all formulas.
     * When you change name sheet Sheet1 -> Price
     * for all cell which refere to Sheet1, this function changes the name.
     */
    void changeCellTabName( TQString const & old_name,TQString const & new_name );

    bool loadRowFormat( const TQDomElement& row, int &rowIndex, KoOasisLoadingContext& oasisContext, TQDict<Style>& styleMap );

    /**
     * Loads the properties of a column from a table:table-column element in an OASIS XML file
     * defaultColumnCellStyles is a map from column indicies to the default cell style for that column
     */
    bool loadColumnFormat(const TQDomElement& row, const KoOasisStyles& oasisStyles, int & indexCol, const TQDict<Style>& styleMap);
    bool loadSheetStyleFormat( TQDomElement *style );
    void loadOasisMasterLayoutPage( KoStyleStack &styleStack );

    TQString saveOasisSheetStyleName( KoGenStyles &mainStyles );
    void saveOasisColRowCell( KoXmlWriter& xmlWriter, KoGenStyles &mainStyles, int maxCols, int maxRows, GenValidationStyles &valStyle );
    void saveOasisCells(  KoXmlWriter& xmlWriter, KoGenStyles &mainStyles, int row, int maxCols, GenValidationStyles &valStyle );
    void convertPart( const TQString & part, KoXmlWriter & writer ) const;
    void addText( const TQString & text, KoXmlWriter & writer ) const;

    void maxRowCols( int & maxCols, int & maxRows );
    bool compareRows( int row1, int row2, int & maxCols ) const;

    TQString getPart( const TQDomNode & part );
    void replaceMacro( TQString & text, const TQString & old, const TQString & newS );

    void insertObject( EmbeddedObject *_obj );

    /**
     * @see #autofill
     */
    void fillSequence( TQPtrList<Cell>& _srcList, TQPtrList<Cell>& _destList, TQPtrList<AutoFillSequence>& _seqList, bool down = true );

    static int s_id;
    static TQIntDict<Sheet>* s_mapSheets;

public:
    // see kspread_sheet.cc for an explanation of this
    // this is for type B and also for type A (better use CellWorkerTypeA for that)
    struct CellWorker
    {
  const bool create_if_default;
  const bool emit_signal;
  const bool type_B;

  CellWorker( bool cid=true, bool es=true, bool tb=true ) : create_if_default( cid ), emit_signal( es ), type_B( tb ) { }
  virtual ~CellWorker() { }

  virtual class UndoAction* createUndoAction( Doc* doc, Sheet* sheet, const Region& region ) =0;

  // these are only needed for type A
  virtual bool testCondition( RowFormat* ) { return false; }
  virtual void doWork( RowFormat* ) { }
  virtual void doWork( ColumnFormat* ) { }
  virtual void prepareCell( Cell* ) { }

  // these are needed in all CellWorkers
  virtual bool testCondition( Cell* cell ) =0;
  virtual void doWork( Cell* cell, bool cellRegion, int x, int y ) =0;
    };

    // this is for type A (surprise :))
    struct CellWorkerTypeA : public CellWorker
    {
  CellWorkerTypeA( ) : CellWorker( true, true, false ) { }
  virtual TQString getUndoTitle( ) =0;
  class UndoAction* createUndoAction( Doc* doc, Sheet* sheet, const Region& region );
    };

protected:
    typedef enum { CompleteRows, CompleteColumns, CellRegion } SelectionType;
    SelectionType workOnCells( Selection* selectionInfo,
                               CellWorker& worker );

private:
    /**
     * Inserts a picture into the sheet and the given position.  The picture should be added to the
     * document's picture collection before calling this method.
     */
    bool insertPicture( const KoPoint& point, KoPicture& picture );

    bool FillSequenceWithInterval (TQPtrList<Cell>& _srcList,
           TQPtrList<Cell>& _destList,
           TQPtrList<AutoFillSequence>& _seqList,
                                   bool down);

    void FillSequenceWithCopy (TQPtrList<Cell>& _srcList,
                               TQPtrList<Cell>& _destList,
                               bool down);

    void convertObscuringBorders();
    void checkCellContent(Cell * cell1, Cell * cell2, int & ret);
    int  adjustColumnHelper(Cell * c, int _col, int _row);
    void checkContentDirection( TQString const & name );
    bool objectNameExists( EmbeddedObject *object, TQPtrList<EmbeddedObject> &list );

    class Private;
    Private* d;

    // don't allow copy or assignment
    Sheet( const Sheet& );
    Sheet& operator=( const Sheet& );
};

} // namespace KSpread

#endif  // KSPREAD_SHEET