kspread

kspread_sheet.h
1/* This file is part of the KDE project
2 Copyright 1998, 1999 Torben Weis <weis@kde.org>
3 Copyright 1999- 2006 The KSpread Team
4 www.koffice.org/kspread
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20*/
21
22#ifndef KSPREAD_SHEET
23#define KSPREAD_SHEET
24
25#include <tqclipboard.h>
26#include <tqdragobject.h>
27#include <tqintdict.h>
28#include <tqmemarray.h>
29#include <tqpen.h>
30#include <tqptrlist.h>
31#include <tqrect.h>
32#include <tqwidget.h>
33
34#include <KoDocument.h>
35#include <KoDocumentChild.h>
36#include <KoOasisSettings.h> // for KoOasisSettings::NamedMap
37
38#include "kspread_autofill.h"
39#include "kspread_cell.h"
40#include "kspread_format.h"
41#include "kspread_global.h"
42#include "kspread_object.h"
43
44class TQWidget;
45class TQPainter;
46class TQDomElement;
47class DCOPObject;
48class KPrinter;
49class KoDocumentEntry;
50class KoStyleStack;
51class KoGenStyles;
52class KoOasisLoadingContext;
53class KoOasisSettings;
54class KoOasisStyles;
55class KCommand;
56class KoPicture;
57class KoXmlWriter;
58
59namespace KoChart
60{
61class Part;
62}
63
64namespace KSpread
65{
66class Canvas;
67class Cell;
68class EmbeddedChart;
70class Doc;
71class GenValidationStyles;
72class Map;
73class Point;
74class Region;
75class Selection;
76class Sheet;
77class SheetPrint;
78class Style;
79class UndoInsertRemoveAction;
80class View;
82class EmbeddedObject;
83
84/********************************************************************
85 *
86 * CellBinding
87 *
88 ********************************************************************/
89
93class CellBinding : public TQObject
94{
95 TQ_OBJECT
96
97public:
98 CellBinding( Sheet *_sheet, const TQRect& _area );
99 virtual ~CellBinding();
100
101 bool contains( int _x, int _y );
108 virtual void cellChanged( Cell *_obj );
109
110 virtual void setIgnoreChanges( bool _ignore ) { m_bIgnoreChanges = _ignore; }
111
112 virtual TQRect& dataArea() { return m_rctDataArea; }
113 virtual void setDataArea( const TQRect _rect ) { m_rctDataArea = _rect; }
114
115 Sheet* sheet()const { return m_pSheet; }
116
117signals:
118 void changed( Cell *_obj );
119
120protected:
121 TQRect m_rctDataArea;
122 Sheet *m_pSheet;
123 bool m_bIgnoreChanges;
124};
125
126class ChartBinding : public CellBinding
127{
128 TQ_OBJECT
129
130public:
131
132 ChartBinding( Sheet *_sheet, const TQRect& _area, EmbeddedChart *_child );
133 virtual ~ChartBinding();
134
135 virtual void cellChanged( Cell *_obj );
136
137private:
138 EmbeddedChart* m_child;
139};
140
141/********************************************************************
142 *
143 * TextDrag
144 *
145 ********************************************************************/
146
150
151class TextDrag : public TQTextDrag
152{
153 TQ_OBJECT
154
155
156public:
157 TextDrag( TQWidget * dragSource = 0L, const char * name = 0L );
158 virtual ~TextDrag();
159
160 void setPlain( TQString const & _plain ) { setText( _plain ); }
161 void setKSpread( TQByteArray const & _kspread ) { m_kspread = _kspread; }
162
163 virtual TQByteArray encodedData( const char * mime ) const;
164 virtual const char* format( int i ) const;
165
166 static bool canDecode( TQMimeSource * e );
167
168 static const char * selectionMimeType();
169
170protected:
171 TQByteArray m_kspread;
172};
173
174
175/********************************************************************
176 *
177 * Sheet
178 *
179 ********************************************************************/
180
183class KSPREAD_EXPORT Sheet : public TQObject
184{
185 friend class Cell;
186
187 TQ_OBJECT
188
189
190
191 TQ_PROPERTY( TQString sheetName READ sheetName )
192 TQ_PROPERTY( bool autoCalc READ getAutoCalc WRITE setAutoCalc )
193 TQ_PROPERTY( bool showGrid READ getShowGrid WRITE setShowGrid )
194
195public:
196 enum Direction { Right, Left, Up, Down };
197 enum SortingOrder{ Increase, Decrease };
198 enum ChangeRef { ColumnInsert, ColumnRemove, RowInsert, RowRemove };
199 enum TestType { Text, Validity, Comment, ConditionalCellAttribute };
200
201 enum LayoutDirection { LeftToRight, RightToLeft };
202
203 Sheet ( Map* map, const TQString &sheetName, const char *_name=0L );
204 ~Sheet();
205
206 virtual bool isEmpty( unsigned long int x, unsigned long int y ) const;
207
211 TQString sheetName() const;
212
216 TQString tableName() const { return sheetName(); }
217
237 bool setSheetName( const TQString& name, bool init = false, bool makeUndo=true );
238
239 Map* workbook() const;
240 Doc* doc() const;
241
245 virtual TQDomElement saveXML( TQDomDocument& );
249 virtual bool loadXML( const TQDomElement& );
250
251 virtual bool loadOasis( const TQDomElement& sheet, KoOasisLoadingContext& oasisContext, TQDict<Style>& styleMap );
252
253 virtual bool saveOasis( KoXmlWriter & xmlWriter, KoGenStyles &mainStyles, GenValidationStyles &valStyle, KoStore *store, KoXmlWriter* manifestWriter, int & indexObj, int &partIndexObj );
254 void saveOasisHeaderFooter( KoXmlWriter &xmlWriter ) const;
255
256 void loadOasisObjects( const TQDomElement& e, KoOasisLoadingContext& oasisContext );
257 void loadOasisSettings( const KoOasisSettings::NamedMap &settings );
258 void saveOasisSettings( KoXmlWriter &settingsWriter ) const;
259 void saveOasisPrintStyleLayout( KoGenStyle &style ) const;
260
264 virtual bool saveChildren( KoStore* _store, const TQString &_path );
265 bool saveOasisObjects( KoStore *store, KoXmlWriter &xmlWriter, KoGenStyles& mainStyles, int & indexObj, int &partIndexObj );
269 virtual bool loadChildren( KoStore* _store );
270
271 bool isLoading();
272
273
279 TQPtrList<EmbeddedObject> getSelectedObjects();
280
281
290 KoRect getRealRect( bool all );
291
292 //return command when we move object
293 KCommand *moveObject(View *_view, double diffx, double diffy);
294 KCommand *moveObject(View *m_view,const KoPoint &_move,bool key);
295
305 void unifyObjectName( EmbeddedObject *object );
306
310 LayoutDirection layoutDirection() const;
311
316 void setLayoutDirection( LayoutDirection dir );
317
321 bool isRightToLeft() const;
322
323 void password( TQCString & passwd ) const ;
324 bool isProtected() const;
325 void setProtected( TQCString const & passwd );
326 bool checkPassword( TQCString const & passwd ) const;
327
328 void setDefaultHeight( double height );
329 void setDefaultWidth( double width );
330
331 const ColumnFormat* columnFormat( int _column ) const;
332 ColumnFormat* columnFormat( int _column );
338 ColumnFormat* nonDefaultColumnFormat( int _column, bool force_creation = true );
339
340 const RowFormat* rowFormat( int _row ) const;
341 RowFormat* rowFormat( int _row );
347 RowFormat* nonDefaultRowFormat( int _row, bool force_creation = true );
348
353 Cell* firstCell() const;
354
355 RowFormat* firstRow() const;
356
357 ColumnFormat* firstCol() const;
358
359 Cell* cellAt( int _column, int _row ) const;
366 Cell* cellAt( int _column, int _row, bool _scrollbar_update = false );
370 Cell* cellAt( const TQPoint& _point, bool _scrollbar_update = false )
371 { return cellAt( _point.x(), _point.y(), _scrollbar_update ); }
381 Cell* visibleCellAt( int _column, int _row, bool _scrollbar_update = false );
392 Cell* nonDefaultCell( int _column, int _row, bool _scrollbar_update = false, Style * _style = 0 );
393 Cell* nonDefaultCell( TQPoint const & cellRef, bool scroll = false )
394 { return nonDefaultCell( cellRef.x(), cellRef.y(), scroll ); }
395
396 Cell* defaultCell() const;
397
398 Format* defaultFormat();
399 const Format* defaultFormat() const;
400
402 Value value (int col, int row) const;
404 Value valueRange (int col1, int row1, int col2, int row2) const;
405
406 TQRect visibleRect( Canvas const * const _canvas ) const;
407 int topRow( double _ypos, double &_top, const Canvas *_canvas = 0L ) const;
408 int bottomRow( double _ypos, const Canvas *_canvas = 0L ) const;
409 int leftColumn( double _xpos, double &_left, const Canvas *_canvas = 0L ) const;
410 int rightColumn( double _xpos, const Canvas *_canvas = 0L ) const;
411
419 int columnPos( int _col, const Canvas *_canvas = 0L ) const;
429 double dblColumnPos( int _col, const Canvas *_canvas = 0L ) const;
437 int rowPos( int _row, const Canvas *_canvas = 0L ) const;
447 double dblRowPos( int _row, const Canvas *_canvas = 0L ) const;
448
452 double sizeMaxX() const ;
456 double sizeMaxY() const;
457
462 void adjustSizeMaxX ( double _x );
463
468 void adjustSizeMaxY ( double _y );
469
473 void setLayoutDirtyFlag();
480 void setCalcDirtyFlag();
481
485 //why on earth would we want to do this?
486// void calc();
487
499 void recalc( bool force );
503 void recalc();
504
505
508 void valueChanged (Cell *cell);
509
518 TQString guessColumnTitle(TQRect& area, int col);
519
527 TQString guessRowTitle(TQRect& area, int row);
528
532 void setText( int row, int column, const TQString& text,
533 bool asString = false );
534 void setArrayFormula (Selection *selectionInfo, const TQString &_text);
535
536
537 void setSelectionFont( Selection* selectionInfo,
538 const char *_font = 0L, int _size = -1,
539 signed char _bold = -1, signed char _italic = -1,
540 signed char _underline = -1,
541 signed char _strike = -1 );
542
543 void setSelectionMoneyFormat( Selection* selectionInfo, bool b );
544 void setSelectionAlign( Selection* selectionInfo,
545 Format::Align _align );
546 void setSelectionAlignY( Selection* selectionInfo,
547 Format::AlignY _alignY );
548 void setSelectionPrecision( Selection* selectionInfo, int _delta );
549 void setSelectionPercent( Selection* selectionInfo, bool b );
550 void setSelectionMultiRow( Selection* selectionInfo, bool enable );
551 void setSelectionStyle( Selection* selectionInfo, Style * style );
552
556 void setSelectionSize( Selection* selectionInfo, int _size );
557
562 void setSelectionUpperLower( Selection* selectionInfo, int _type );
563
564 void setSelectionfirstLetterUpper( Selection* selectionInfo);
565
566 void setSelectionVerticalText( Selection* selectionInfo, bool _b);
567
568 void setSelectionComment( Selection* selectionInfo,
569 const TQString &_comment);
570 void setSelectionRemoveComment(Selection* selectionInfo);
571
572 void setSelectionAngle(Selection* selectionInfo, int _value );
573
574 void setSelectionTextColor( Selection* selectionInfo,
575 const TQColor &tbColor );
576 void setSelectionbgColor( Selection* selectionInfo,
577 const TQColor &bg_Color );
578 void setSelectionBorderColor( Selection* selectionInfo,
579 const TQColor &bd_Color );
580
587 void deleteSelection( Selection* selectionInfo, bool undo = true );
588
594 void copySelection( Selection* selectionInfo );
600 void cutSelection( Selection* selectionInfo );
606 void clearTextSelection( Selection* selectionInfo );
607
608 void clearValiditySelection(Selection* selectionInfo );
609
610 void clearConditionalSelection(Selection* selectionInfo );
611
612 void fillSelection( Selection * selectionInfo, int direction );
613
614 void setWordSpelling(Selection* selectionInfo,const TQString _listWord );
615
616 TQString getWordSpelling(Selection* selectionInfo );
617
622 void paste( const TQRect & pasteArea, bool makeUndo = true,
623 Paste::Mode = Paste::Normal, Paste::Operation = Paste::OverWrite,
624 bool insert = false, int insertTo = 0, bool pasteFC = false,
625 TQClipboard::Mode clipboardMode = TQClipboard::Clipboard );
626 void paste( const TQByteArray & data, const TQRect & pasteArea,
627 bool makeUndo = false, Paste::Mode= Paste::Normal, Paste::Operation = Paste::OverWrite,
628 bool insert = false, int insertTo = 0, bool pasteFC = false );
629 void defaultSelection( Selection* selectionInfo );
630
634 void pasteTextPlain( TQString &_text, TQRect pasteArea);
635
636 void sortByRow( const TQRect &area, int ref_row, SortingOrder );
637 void sortByRow( const TQRect &area, int key1, int key2, int key3,
638 SortingOrder order1, SortingOrder order2, SortingOrder order3,
639 TQStringList const * firstKey, bool copyFormat, bool headerRow,
640 Point const & outputPoint, bool respectCase );
641 void sortByColumn( const TQRect &area, int ref_column, SortingOrder );
642 void sortByColumn( const TQRect &area, int key1, int key2, int key3,
643 SortingOrder order1, SortingOrder order2, SortingOrder order3,
644 TQStringList const * firstKey, bool copyFormat, bool headerCol,
645 Point const & outputPoint, bool respectCase );
646 void swapCells( int x1, int y1, int x2, int y2, bool cpFormat );
647
653 void copyCells( int x1, int y1, int x2, int y2, bool cpFormat );
654 void setSeries( const TQPoint &_marker, double start, double end, double step, Series mode, Series type );
655
665 bool shiftRow( const TQRect &_rect, bool makeUndo=true );
666 bool shiftColumn( const TQRect& rect, bool makeUndo=true );
667
668 void unshiftColumn( const TQRect& rect, bool makeUndo=true );
669 void unshiftRow( const TQRect& rect, bool makeUndo=true );
670
676 bool insertColumn( int col, int nbCol=0, bool makeUndo=true );
681 bool insertRow( int row, int nbRow=0, bool makeUndo=true );
682
686 void removeColumn( int col, int nbCol=0, bool makeUndo=true );
690 void removeRow( int row, int nbRow=0, bool makeUndo=true );
691
695 void hideRow(const Region&);
696 void emitHideRow();
697 void showRow(const Region&);
698
702 void hideColumn(const Region&);
703 void emitHideColumn();
704 void showColumn(const Region&);
705
709 void adjustArea(const Region&);
713 void adjustColumn(const Region&);
717 void adjustRow(const Region&);
718
722 void borderLeft( Selection* selectionInfo, const TQColor &_color );
723 void borderTop( Selection* selectionInfo, const TQColor &_color );
724 void borderOutline( Selection* selectionInfo, const TQColor &_color );
725 void borderAll( Selection* selectionInfo, const TQColor &_color );
726 void borderRemove( Selection* selectionInfo );
727 void borderBottom( Selection* selectionInfo, const TQColor &_color );
728 void borderRight( Selection* selectionInfo, const TQColor &_color );
729
730 void setConditional( Selection* selectionInfo,
731 TQValueList<Conditional> const & newConditions );
732
733 void setValidity( Selection* selectionInfo, KSpread::Validity tmp );
734
738 bool getShowGrid() const;
739
743 void setShowGrid( bool _showGrid );
744
748 bool getShowFormula() const;
749
750 void setShowFormula(bool _showFormula);
751
755 bool getShowFormulaIndicator() const;
756
757 void setShowFormulaIndicator(bool _showFormulaIndicator);
758
762 bool getShowCommentIndicator() const;
763
768 void setShowCommentIndicator( bool b );
769
770 bool getLcMode() const;
771
772 void setLcMode(bool _lcMode);
773
774 bool getAutoCalc() const;
775
776 void setAutoCalc(bool _AutoCalc);
777
778 bool getShowColumnNumber() const;
779
780 void setShowColumnNumber(bool _showColumnNumber);
781
782 bool getHideZero() const;
783
784 void setHideZero(bool _hideZero);
785
786 bool getFirstLetterUpper() const;
787
788 void setFirstLetterUpper(bool _firstUpper);
789
790 // TODO Stefan: remove after kspread_undo.cpp|h and commands.cpp|h are obsolete
791 void changeMergedCell( int /*m_iCol*/, int /*m_iRow*/, int /*m_iExtraX*/, int /*m_iExtraY*/) {}
792
798 void mergeCells( const Region& region, bool hor = false, bool ver = false );
799 void dissociateCells( const Region &region );
800
801 void increaseIndent( Selection* selectionInfo );
802 void decreaseIndent( Selection* selectionInfo );
803
804 bool areaIsEmpty(const Region& area, TestType _type = Text) ;
805
806 void refreshPreference() ;
807
808 void hideSheet(bool _hide);
809
810 void removeSheet();
811
812 TQRect selectionCellMerged(const TQRect &_sel);
827 void changeNameCellRef( const TQPoint & pos, bool fullRowOrColumn,
828 ChangeRef ref, TQString tabname, int NbCol = 1,
829 UndoInsertRemoveAction * undo = 0 );
830
831
832 void refreshRemoveAreaName(const TQString &_areaName);
833 void refreshChangeAreaName(const TQString &_areaName);
834
835
846 void refreshChart(const TQPoint & pos, bool fullRowOrColumn, ChangeRef ref);
850 void refreshMergedCell();
851
855 bool isHidden()const;
859 void setHidden( bool hidden );
860
867 TQPainter& painter();
873 TQWidget* widget()const;
874
881 bool isShowPageBorders() const;
882
889 void setShowPageBorders( bool _b );
890
891 void addCellBinding( CellBinding *_bind );
892 void removeCellBinding( CellBinding *_bind );
893 CellBinding* firstCellBinding();
894 CellBinding* nextCellBinding();
895
901 bool getCellRectangle( const TQRect &_range, TQPtrList<Cell> &_list );
902
906 Sheet *findSheet( const TQString & _name );
907
913 void insertCell( Cell *_cell );
919 void insertColumnFormat( ColumnFormat *_l );
925 void insertRowFormat( RowFormat *_l );
926
933 TQDomDocument saveCellRegion(const Region&, bool copy = false, bool era = false);
934
942 bool loadSelection( const TQDomDocument& doc, const TQRect &pasteArea,
943 int _xshift, int _yshift, bool makeUndo,
944 Paste::Mode = Paste::Normal, Paste::Operation = Paste::OverWrite,
945 bool insert = false, int insertTo = 0, bool paste = false );
946
947 void loadSelectionUndo( const TQDomDocument & doc, const TQRect &loadArea,
948 int _xshift, int _yshift,bool insert,int insertTo);
949
957 bool testAreaPasteInsert()const;
958
969 void deleteCells(const Region& region);
970
971
976 bool testListChoose(Selection* selectionInfo);
977
981 TQString copyAsText(Selection* selection);
982
991 void autofill( TQRect &src, TQRect &dest );
992
993
994 bool insertChild( const KoRect& _geometry, KoDocumentEntry& );
995
996 bool insertChart( const KoRect& _geometry, KoDocumentEntry&, const TQRect& _data );
997
998
1009 bool insertPicture( const KoPoint& point , const KURL& file );
1010
1017 bool insertPicture( const KoPoint& point, const TQPixmap& pixmap );
1018
1019 void changeChildGeometry( EmbeddedKOfficeObject *_child, const KoRect& _geometry );
1020
1021 const TQColorGroup& colorGroup() { return widget()->colorGroup(); }
1022
1023 int id() const;
1024
1030 int maxColumn() const ;
1031
1038 void checkRangeHBorder ( int _column );
1039
1045 int maxRow() const ;
1046
1053 void checkRangeVBorder ( int _row );
1054
1055
1056 void enableScrollBarUpdates( bool _enable );
1057
1058 virtual DCOPObject* dcopObject();
1059
1060 static Sheet* find( int _id );
1061
1062#ifndef NDEBUG
1063 void printDebug();
1064#endif
1065
1071 void updateCell( Cell* _cell, int _col, int _row );
1072
1078 void updateCellArea(const Region& cellArea);
1079
1083 void update();
1084
1088 void updateView();
1089
1093 void updateView( TQRect const & rect );
1094
1098 void updateView(Region*);
1099
1103 void refreshView(const Region& region);
1104
1105 void emit_updateRow( RowFormat *_format, int _row, bool repaint = true );
1106 void emit_updateColumn( ColumnFormat *_format, int _column );
1107
1114 const TQPen& emptyPen() const ;
1115 const TQBrush& emptyBrush() const;
1116 const TQColor& emptyColor() const;
1117
1118 void updateLocale();
1119
1120
1126 void setRegionPaintDirty(TQRect const & range);
1127 void setRegionPaintDirty(Region const & region);
1128
1132 void clearPaintDirtyData();
1133
1137 bool cellIsPaintDirty(TQPoint const & cell) const;
1138
1148 Cell* getFirstCellColumn(int col) const;
1149
1159 Cell* getLastCellColumn(int col) const;
1160
1170 Cell* getFirstCellRow(int row) const;
1171
1181 Cell* getLastCellRow(int row) const;
1182
1192 Cell* getNextCellUp(int col, int row) const;
1193
1203 Cell* getNextCellDown(int col, int row) const;
1204
1215 Cell* getNextCellLeft(int col, int row) const;
1216
1227 Cell* getNextCellRight(int col, int row) const;
1228
1229 SheetPrint * print() const;
1230
1232 KSpread::DependencyManager *dependencies ();
1233
1239 int numSelected() const;
1240
1241//return command when we move object
1242// KCommand *moveObject(KSpreadView *_view, double diffx, double diffy);
1243// KCommand *moveObject(KSpreadView *m_view,const KoPoint &_move,bool key);
1244
1245
1246signals:
1247 void sig_refreshView();
1248 void sig_updateView( Sheet *_sheet );
1249 void sig_updateView( Sheet *_sheet, const Region& );
1250 void sig_updateView( EmbeddedObject *obj );
1251 void sig_updateHBorder( Sheet *_sheet );
1252 void sig_updateVBorder( Sheet *_sheet );
1253 void sig_updateChildGeometry( EmbeddedKOfficeObject *_child );
1254 void sig_maxColumn( int _max_column );
1255 void sig_maxRow( int _max_row );
1259 void sig_nameChanged( Sheet* sheet, const TQString& old_name );
1264 void sig_polygonInvalidated( const TQPointArray& );
1265
1266 void sig_SheetHidden( Sheet* sheet);
1267 void sig_SheetShown( Sheet* sheet);
1268 void sig_SheetRemoved( Sheet* sheet);
1269 void sig_SheetActivated( Sheet* );
1270 void sig_RefreshView( Sheet* );
1271
1272protected slots:
1274 void slotAreaModified (const TQString &name);
1275
1276protected:
1278 void updateAllDependencies();
1279
1285 void changeCellTabName( TQString const & old_name,TQString const & new_name );
1286
1287 bool loadRowFormat( const TQDomElement& row, int &rowIndex, KoOasisLoadingContext& oasisContext, TQDict<Style>& styleMap );
1288
1293 bool loadColumnFormat(const TQDomElement& row, const KoOasisStyles& oasisStyles, int & indexCol, const TQDict<Style>& styleMap);
1294 bool loadSheetStyleFormat( TQDomElement *style );
1295 void loadOasisMasterLayoutPage( KoStyleStack &styleStack );
1296
1297 TQString saveOasisSheetStyleName( KoGenStyles &mainStyles );
1298 void saveOasisColRowCell( KoXmlWriter& xmlWriter, KoGenStyles &mainStyles, int maxCols, int maxRows, GenValidationStyles &valStyle );
1299 void saveOasisCells( KoXmlWriter& xmlWriter, KoGenStyles &mainStyles, int row, int maxCols, GenValidationStyles &valStyle );
1300 void convertPart( const TQString & part, KoXmlWriter & writer ) const;
1301 void addText( const TQString & text, KoXmlWriter & writer ) const;
1302
1303 void maxRowCols( int & maxCols, int & maxRows );
1304 bool compareRows( int row1, int row2, int & maxCols ) const;
1305
1306 TQString getPart( const TQDomNode & part );
1307 void replaceMacro( TQString & text, const TQString & old, const TQString & newS );
1308
1309 void insertObject( EmbeddedObject *_obj );
1310
1314 void fillSequence( TQPtrList<Cell>& _srcList, TQPtrList<Cell>& _destList, TQPtrList<AutoFillSequence>& _seqList, bool down = true );
1315
1316 static int s_id;
1317 static TQIntDict<Sheet>* s_mapSheets;
1318
1319public:
1320 // see kspread_sheet.cpp for an explanation of this
1321 // this is for type B and also for type A (better use CellWorkerTypeA for that)
1322 struct CellWorker
1323 {
1324 const bool create_if_default;
1325 const bool emit_signal;
1326 const bool type_B;
1327
1328 CellWorker( bool cid=true, bool es=true, bool tb=true ) : create_if_default( cid ), emit_signal( es ), type_B( tb ) { }
1329 virtual ~CellWorker() { }
1330
1331 virtual class UndoAction* createUndoAction( Doc* doc, Sheet* sheet, const Region& region ) =0;
1332
1333 // these are only needed for type A
1334 virtual bool testCondition( RowFormat* ) { return false; }
1335 virtual void doWork( RowFormat* ) { }
1336 virtual void doWork( ColumnFormat* ) { }
1337 virtual void prepareCell( Cell* ) { }
1338
1339 // these are needed in all CellWorkers
1340 virtual bool testCondition( Cell* cell ) =0;
1341 virtual void doWork( Cell* cell, bool cellRegion, int x, int y ) =0;
1342 };
1343
1344 // this is for type A (surprise :))
1345 struct CellWorkerTypeA : public CellWorker
1346 {
1347 CellWorkerTypeA( ) : CellWorker( true, true, false ) { }
1348 virtual TQString getUndoTitle( ) =0;
1349 class UndoAction* createUndoAction( Doc* doc, Sheet* sheet, const Region& region );
1350 };
1351
1352protected:
1353 typedef enum { CompleteRows, CompleteColumns, CellRegion } SelectionType;
1354 SelectionType workOnCells( Selection* selectionInfo,
1355 CellWorker& worker );
1356
1357private:
1362 bool insertPicture( const KoPoint& point, KoPicture& picture );
1363
1364 bool FillSequenceWithInterval (TQPtrList<Cell>& _srcList,
1365 TQPtrList<Cell>& _destList,
1366 TQPtrList<AutoFillSequence>& _seqList,
1367 bool down);
1368
1369 void FillSequenceWithCopy (TQPtrList<Cell>& _srcList,
1370 TQPtrList<Cell>& _destList,
1371 bool down);
1372
1373 void convertObscuringBorders();
1374 void checkCellContent(Cell * cell1, Cell * cell2, int & ret);
1375 int adjustColumnHelper(Cell * c, int _col, int _row);
1376 void checkContentDirection( TQString const & name );
1377 bool objectNameExists( EmbeddedObject *object, TQPtrList<EmbeddedObject> &list );
1378
1379 class Private;
1380 Private* d;
1381
1382 // don't allow copy or assignment
1383 Sheet( const Sheet& );
1384 Sheet& operator=( const Sheet& );
1385};
1386
1387} // namespace KSpread
1388
1389#endif // KSPREAD_SHEET
The canvas builds a part of the GUI of KSpread.
This is an abstract base class only.
virtual void cellChanged(Cell *_obj)
Call this function if one of the cells covered by this binding (.
For every cell in the spread sheet there is a Cell object.
This class manages dependencies.
This class holds the data that makes up a spreadsheet.
Definition kspread_doc.h:98
Holds an embedded chart object.
Holds an embedded koffice object.
Contains basic information for every object.
A map is a simple container for all sheets.
Definition kspread_map.h:59
Represents the position of a single cell in a workbook.
The one for all class for points and ranges.
Definition region.h:44
The Style class represents a cell style.
The View class displays a KSpread document.
@ Format
Format only.
@ Comment
Comment only.
@ Text
Text only.
The KSpread namespace.
Definition commands.h:39