25#include <tqclipboard.h>
26#include <tqdragobject.h>
28#include <tqmemarray.h>
34#include <KoDocument.h>
35#include <KoDocumentChild.h>
36#include <KoOasisSettings.h>
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"
52class KoOasisLoadingContext;
69class DependencyManager;
71class GenValidationStyles;
79class UndoInsertRemoveAction;
81class EmbeddedKOfficeObject;
101 bool contains(
int _x,
int _y );
110 virtual void setIgnoreChanges(
bool _ignore ) { m_bIgnoreChanges = _ignore; }
112 virtual TQRect& dataArea() {
return m_rctDataArea; }
113 virtual void setDataArea(
const TQRect _rect ) { m_rctDataArea = _rect; }
115 Sheet* sheet()
const {
return m_pSheet; }
118 void changed(
Cell *_obj );
121 TQRect m_rctDataArea;
123 bool m_bIgnoreChanges;
132 ChartBinding( Sheet *_sheet,
const TQRect& _area,
EmbeddedChart *_child );
133 virtual ~ChartBinding();
135 virtual void cellChanged(
Cell *_obj );
157 TextDrag( TQWidget * dragSource = 0L,
const char * name = 0L );
160 void setPlain( TQString
const & _plain ) { setText( _plain ); }
161 void setKSpread( TQByteArray
const & _kspread ) { m_kspread = _kspread; }
163 virtual TQByteArray encodedData(
const char * mime )
const;
164 virtual const char* format(
int i )
const;
166 static bool canDecode( TQMimeSource * e );
168 static const char * selectionMimeType();
171 TQByteArray m_kspread;
183class KSPREAD_EXPORT Sheet :
public TQObject
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 )
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 };
201 enum LayoutDirection { LeftToRight, RightToLeft };
203 Sheet ( Map* map,
const TQString &sheetName,
const char *_name=0L );
206 virtual bool isEmpty(
unsigned long int x,
unsigned long int y )
const;
211 TQString sheetName()
const;
216 TQString tableName()
const {
return sheetName(); }
237 bool setSheetName(
const TQString& name,
bool init =
false,
bool makeUndo=
true );
239 Map* workbook()
const;
245 virtual TQDomElement saveXML( TQDomDocument& );
249 virtual bool loadXML(
const TQDomElement& );
251 virtual bool loadOasis(
const TQDomElement& sheet, KoOasisLoadingContext& oasisContext, TQDict<Style>& styleMap );
253 virtual bool saveOasis( KoXmlWriter & xmlWriter, KoGenStyles &mainStyles, GenValidationStyles &valStyle, KoStore *store, KoXmlWriter* manifestWriter,
int & indexObj,
int &partIndexObj );
254 void saveOasisHeaderFooter( KoXmlWriter &xmlWriter )
const;
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;
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 );
279 TQPtrList<EmbeddedObject> getSelectedObjects();
290 KoRect getRealRect(
bool all );
293 KCommand *moveObject(View *_view,
double diffx,
double diffy);
294 KCommand *moveObject(View *m_view,
const KoPoint &_move,
bool key);
305 void unifyObjectName( EmbeddedObject *
object );
310 LayoutDirection layoutDirection()
const;
316 void setLayoutDirection( LayoutDirection dir );
321 bool isRightToLeft()
const;
323 void password( TQCString & passwd )
const ;
324 bool isProtected()
const;
325 void setProtected( TQCString
const & passwd );
326 bool checkPassword( TQCString
const & passwd )
const;
328 void setDefaultHeight(
double height );
329 void setDefaultWidth(
double width );
331 const ColumnFormat* columnFormat(
int _column )
const;
332 ColumnFormat* columnFormat(
int _column );
338 ColumnFormat* nonDefaultColumnFormat(
int _column,
bool force_creation =
true );
340 const RowFormat* rowFormat(
int _row )
const;
341 RowFormat* rowFormat(
int _row );
347 RowFormat* nonDefaultRowFormat(
int _row,
bool force_creation =
true );
353 Cell* firstCell()
const;
355 RowFormat* firstRow()
const;
357 ColumnFormat* firstCol()
const;
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 ); }
396 Cell* defaultCell()
const;
399 const Format* defaultFormat()
const;
402 Value value (
int col,
int row)
const;
404 Value valueRange (
int col1,
int row1,
int col2,
int row2)
const;
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;
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;
452 double sizeMaxX()
const ;
456 double sizeMaxY()
const;
462 void adjustSizeMaxX (
double _x );
468 void adjustSizeMaxY (
double _y );
473 void setLayoutDirtyFlag();
480 void setCalcDirtyFlag();
499 void recalc(
bool force );
508 void valueChanged (Cell *cell);
518 TQString guessColumnTitle(TQRect& area,
int col);
527 TQString guessRowTitle(TQRect& area,
int row);
532 void setText(
int row,
int column,
const TQString& text,
533 bool asString =
false );
534 void setArrayFormula (Selection *selectionInfo,
const TQString &_text);
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 );
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 );
556 void setSelectionSize( Selection* selectionInfo,
int _size );
562 void setSelectionUpperLower( Selection* selectionInfo,
int _type );
564 void setSelectionfirstLetterUpper( Selection* selectionInfo);
566 void setSelectionVerticalText( Selection* selectionInfo,
bool _b);
568 void setSelectionComment( Selection* selectionInfo,
569 const TQString &_comment);
570 void setSelectionRemoveComment(Selection* selectionInfo);
572 void setSelectionAngle(Selection* selectionInfo,
int _value );
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 );
587 void deleteSelection( Selection* selectionInfo,
bool undo =
true );
594 void copySelection( Selection* selectionInfo );
600 void cutSelection( Selection* selectionInfo );
606 void clearTextSelection( Selection* selectionInfo );
608 void clearValiditySelection(Selection* selectionInfo );
610 void clearConditionalSelection(Selection* selectionInfo );
612 void fillSelection( Selection * selectionInfo,
int direction );
614 void setWordSpelling(Selection* selectionInfo,
const TQString _listWord );
616 TQString getWordSpelling(Selection* selectionInfo );
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 );
634 void pasteTextPlain( TQString &_text, TQRect pasteArea);
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 );
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 );
665 bool shiftRow(
const TQRect &_rect,
bool makeUndo=
true );
666 bool shiftColumn(
const TQRect& rect,
bool makeUndo=
true );
668 void unshiftColumn(
const TQRect& rect,
bool makeUndo=
true );
669 void unshiftRow(
const TQRect& rect,
bool makeUndo=
true );
676 bool insertColumn(
int col,
int nbCol=0,
bool makeUndo=
true );
681 bool insertRow(
int row,
int nbRow=0,
bool makeUndo=
true );
686 void removeColumn(
int col,
int nbCol=0,
bool makeUndo=
true );
690 void removeRow(
int row,
int nbRow=0,
bool makeUndo=
true );
695 void hideRow(
const Region&);
697 void showRow(
const Region&);
702 void hideColumn(
const Region&);
703 void emitHideColumn();
704 void showColumn(
const Region&);
709 void adjustArea(
const Region&);
713 void adjustColumn(
const Region&);
717 void adjustRow(
const Region&);
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 );
730 void setConditional( Selection* selectionInfo,
731 TQValueList<Conditional>
const & newConditions );
733 void setValidity( Selection* selectionInfo, KSpread::Validity tmp );
738 bool getShowGrid()
const;
743 void setShowGrid(
bool _showGrid );
748 bool getShowFormula()
const;
750 void setShowFormula(
bool _showFormula);
755 bool getShowFormulaIndicator()
const;
757 void setShowFormulaIndicator(
bool _showFormulaIndicator);
762 bool getShowCommentIndicator()
const;
768 void setShowCommentIndicator(
bool b );
770 bool getLcMode()
const;
772 void setLcMode(
bool _lcMode);
774 bool getAutoCalc()
const;
776 void setAutoCalc(
bool _AutoCalc);
778 bool getShowColumnNumber()
const;
780 void setShowColumnNumber(
bool _showColumnNumber);
782 bool getHideZero()
const;
784 void setHideZero(
bool _hideZero);
786 bool getFirstLetterUpper()
const;
788 void setFirstLetterUpper(
bool _firstUpper);
791 void changeMergedCell(
int ,
int ,
int ,
int ) {}
798 void mergeCells(
const Region& region,
bool hor =
false,
bool ver =
false );
799 void dissociateCells(
const Region ®ion );
801 void increaseIndent( Selection* selectionInfo );
802 void decreaseIndent( Selection* selectionInfo );
804 bool areaIsEmpty(
const Region& area, TestType _type = Text) ;
806 void refreshPreference() ;
808 void hideSheet(
bool _hide);
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 );
832 void refreshRemoveAreaName(
const TQString &_areaName);
833 void refreshChangeAreaName(
const TQString &_areaName);
846 void refreshChart(
const TQPoint & pos,
bool fullRowOrColumn, ChangeRef ref);
850 void refreshMergedCell();
855 bool isHidden()
const;
859 void setHidden(
bool hidden );
867 TQPainter& painter();
873 TQWidget* widget()
const;
881 bool isShowPageBorders()
const;
889 void setShowPageBorders(
bool _b );
891 void addCellBinding( CellBinding *_bind );
892 void removeCellBinding( CellBinding *_bind );
893 CellBinding* firstCellBinding();
894 CellBinding* nextCellBinding();
901 bool getCellRectangle(
const TQRect &_range, TQPtrList<Cell> &_list );
906 Sheet *findSheet(
const TQString & _name );
913 void insertCell( Cell *_cell );
919 void insertColumnFormat( ColumnFormat *_l );
925 void insertRowFormat( RowFormat *_l );
933 TQDomDocument saveCellRegion(
const Region&,
bool copy =
false,
bool era =
false);
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 );
947 void loadSelectionUndo(
const TQDomDocument & doc,
const TQRect &loadArea,
948 int _xshift,
int _yshift,
bool insert,
int insertTo);
957 bool testAreaPasteInsert()
const;
969 void deleteCells(
const Region& region);
976 bool testListChoose(Selection* selectionInfo);
981 TQString copyAsText(Selection* selection);
991 void autofill( TQRect &src, TQRect &dest );
994 bool insertChild(
const KoRect& _geometry, KoDocumentEntry& );
996 bool insertChart(
const KoRect& _geometry, KoDocumentEntry&,
const TQRect& _data );
1009 bool insertPicture(
const KoPoint& point ,
const KURL& file );
1017 bool insertPicture(
const KoPoint& point,
const TQPixmap& pixmap );
1019 void changeChildGeometry( EmbeddedKOfficeObject *_child,
const KoRect& _geometry );
1021 const TQColorGroup& colorGroup() {
return widget()->colorGroup(); }
1030 int maxColumn()
const ;
1038 void checkRangeHBorder (
int _column );
1045 int maxRow()
const ;
1053 void checkRangeVBorder (
int _row );
1056 void enableScrollBarUpdates(
bool _enable );
1058 virtual DCOPObject* dcopObject();
1060 static Sheet* find(
int _id );
1071 void updateCell( Cell* _cell,
int _col,
int _row );
1078 void updateCellArea(
const Region& cellArea);
1093 void updateView( TQRect
const & rect );
1098 void updateView(Region*);
1103 void refreshView(
const Region& region);
1105 void emit_updateRow( RowFormat *_format,
int _row,
bool repaint =
true );
1106 void emit_updateColumn( ColumnFormat *_format,
int _column );
1114 const TQPen& emptyPen()
const ;
1115 const TQBrush& emptyBrush()
const;
1116 const TQColor& emptyColor()
const;
1118 void updateLocale();
1126 void setRegionPaintDirty(TQRect
const & range);
1127 void setRegionPaintDirty(Region
const & region);
1132 void clearPaintDirtyData();
1137 bool cellIsPaintDirty(TQPoint
const & cell)
const;
1148 Cell* getFirstCellColumn(
int col)
const;
1159 Cell* getLastCellColumn(
int col)
const;
1170 Cell* getFirstCellRow(
int row)
const;
1181 Cell* getLastCellRow(
int row)
const;
1192 Cell* getNextCellUp(
int col,
int row)
const;
1203 Cell* getNextCellDown(
int col,
int row)
const;
1215 Cell* getNextCellLeft(
int col,
int row)
const;
1227 Cell* getNextCellRight(
int col,
int row)
const;
1229 SheetPrint * print()
const;
1239 int numSelected()
const;
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& );
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* );
1274 void slotAreaModified (
const TQString &name);
1278 void updateAllDependencies();
1285 void changeCellTabName( TQString
const & old_name,TQString
const & new_name );
1287 bool loadRowFormat(
const TQDomElement& row,
int &rowIndex, KoOasisLoadingContext& oasisContext, TQDict<Style>& styleMap );
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 );
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;
1303 void maxRowCols(
int & maxCols,
int & maxRows );
1304 bool compareRows(
int row1,
int row2,
int & maxCols )
const;
1306 TQString getPart(
const TQDomNode & part );
1307 void replaceMacro( TQString & text,
const TQString & old,
const TQString & newS );
1309 void insertObject( EmbeddedObject *_obj );
1314 void fillSequence( TQPtrList<Cell>& _srcList, TQPtrList<Cell>& _destList, TQPtrList<AutoFillSequence>& _seqList,
bool down =
true );
1317 static TQIntDict<Sheet>* s_mapSheets;
1324 const bool create_if_default;
1325 const bool emit_signal;
1328 CellWorker(
bool cid=
true,
bool es=
true,
bool tb=
true ) : create_if_default( cid ), emit_signal( es ), type_B( tb ) { }
1329 virtual ~CellWorker() { }
1331 virtual class UndoAction* createUndoAction( Doc* doc, Sheet* sheet,
const Region& region ) =0;
1334 virtual bool testCondition( RowFormat* ) {
return false; }
1335 virtual void doWork( RowFormat* ) { }
1336 virtual void doWork( ColumnFormat* ) { }
1337 virtual void prepareCell( Cell* ) { }
1340 virtual bool testCondition( Cell* cell ) =0;
1341 virtual void doWork( Cell* cell,
bool cellRegion,
int x,
int y ) =0;
1345 struct CellWorkerTypeA :
public CellWorker
1347 CellWorkerTypeA( ) : CellWorker( true, true, false ) { }
1348 virtual TQString getUndoTitle( ) =0;
1349 class UndoAction* createUndoAction( Doc* doc, Sheet* sheet,
const Region& region );
1353 typedef enum { CompleteRows, CompleteColumns, CellRegion } SelectionType;
1354 SelectionType workOnCells( Selection* selectionInfo,
1355 CellWorker& worker );
1362 bool insertPicture(
const KoPoint& point, KoPicture& picture );
1364 bool FillSequenceWithInterval (TQPtrList<Cell>& _srcList,
1365 TQPtrList<Cell>& _destList,
1366 TQPtrList<AutoFillSequence>& _seqList,
1369 void FillSequenceWithCopy (TQPtrList<Cell>& _srcList,
1370 TQPtrList<Cell>& _destList,
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 );
1383 Sheet(
const Sheet& );
1384 Sheet& operator=(
const Sheet& );
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.
Holds an embedded chart object.
This is a class for handling clipboard data.