20#ifndef __kspread_undo_h__
21#define __kspread_undo_h__
23#include <tqptrstack.h>
27#include <tqvaluelist.h>
31#include <KoPageLayout.h>
33#include "kspread_doc.h"
45class UndoResizeColRow;
63struct layoutTextCell {
95 FormulaOfCell(): m_sheetName(0) {}
96 FormulaOfCell( TQString & sheetName,
int col,
int row, TQString & formula )
97 : m_sheetName( sheetName ), m_col( col ), m_row( row ), m_formula( formula )
100 TQString sheetName()
const {
return m_sheetName; }
101 TQString formula()
const {
return m_formula; }
102 int col()
const {
return m_col; }
103 int row()
const {
return m_row; }
106 TQString m_sheetName;
119 UndoAction(
Doc *_doc ) { m_pDoc = _doc; m_pDoc->setModified(
true); }
120 virtual ~UndoAction() { }
122 virtual void undo() = 0;
123 virtual void redo() = 0;
125 Doc* doc()
const {
return m_pDoc; }
127 TQString getName()
const {
return name ;}
137 MacroUndoAction(
Doc * _doc,
const TQString & _name );
138 virtual ~MacroUndoAction();
146 TQPtrList<UndoAction> m_commands;
149class UndoInsertRemoveAction :
public UndoAction
152 UndoInsertRemoveAction( Doc *_doc );
153 virtual ~UndoInsertRemoveAction();
155 void saveFormulaReference( Sheet *_sheet,
int col,
int row, TQString & formula );
158 void undoFormulaReference();
159 TQValueList<FormulaOfCell> m_lstFormulaCells;
162class UndoRemoveColumn :
public UndoInsertRemoveAction
165 UndoRemoveColumn( Doc *_doc, Sheet *_sheet,
int _column,
int _nbCol=0 );
166 virtual ~UndoRemoveColumn();
172 TQString m_sheetName;
177 TQPair<int, int> m_printRepeatColumns;
180class UndoInsertColumn :
public UndoInsertRemoveAction
183 UndoInsertColumn( Doc *_doc, Sheet *_sheet,
int _column,
int _nbCol=0 );
184 virtual ~UndoInsertColumn();
190 TQString m_sheetName;
195class UndoRemoveRow :
public UndoInsertRemoveAction
198 UndoRemoveRow( Doc *_doc, Sheet *_sheet,
int _row,
int _nbRow=0 );
199 virtual ~UndoRemoveRow();
205 TQString m_sheetName;
210 TQPair<int, int> m_printRepeatRows;
213class UndoInsertRow :
public UndoInsertRemoveAction
216 UndoInsertRow( Doc *_doc, Sheet *_sheet,
int _row,
int _nbRow=0 );
217 virtual ~UndoInsertRow();
223 TQString m_sheetName;
232 UndoHideColumn( Doc *_doc, Sheet *_sheet,
int _column,
int _nbCol=0, TQValueList<int>listCol=TQValueList<int>() );
233 virtual ~UndoHideColumn();
237 void createList( TQValueList<int>&list,Sheet *_tab );
240 TQString m_sheetName;
243 TQValueList<int> listCol;
249 UndoHideRow( Doc *_doc, Sheet *_sheet,
int _column,
int _nbCol=0, TQValueList<int>_listRow=TQValueList<int>() );
250 virtual ~UndoHideRow();
255 void createList( TQValueList<int>&list,Sheet *_tab );
257 TQString m_sheetName;
260 TQValueList<int> listRow;
266 UndoShowColumn( Doc *_doc, Sheet *_sheet,
int _column,
int _nbCol=0, TQValueList<int>_list=TQValueList<int>() );
267 virtual ~UndoShowColumn();
272 void createList( TQValueList<int>&list,Sheet *_tab );
274 TQString m_sheetName;
277 TQValueList<int> listCol;
283 UndoShowRow( Doc *_doc, Sheet *_sheet,
int _column,
int _nbCol=0, TQValueList<int>list=TQValueList<int>() );
284 virtual ~UndoShowRow();
290 void createList( TQValueList<int>&list,Sheet *_tab );
291 TQString m_sheetName;
294 TQValueList<int> listRow;
301 UndoPaperLayout( Doc *_doc, Sheet *_sheet );
302 virtual ~UndoPaperLayout();
308 TQString m_sheetName;
310 KoPageLayout m_plRedo;
314 KoUnit::Unit m_unitRedo;
316 bool m_printGridRedo;
317 bool m_printCommentIndicator;
318 bool m_printCommentIndicatorRedo;
319 bool m_printFormulaIndicator;
320 bool m_printFormulaIndicatorRedo;
322 TQRect m_printRangeRedo;
323 TQPair<int, int> m_printRepeatColumns;
324 TQPair<int, int> m_printRepeatColumnsRedo;
325 TQPair<int, int> m_printRepeatRows;
326 TQPair<int, int> m_printRepeatRowsRedo;
330 int m_iPageLimitXRedo;
332 int m_iPageLimitYRedo;
339 UndoSetText( Doc *_doc, Sheet *_sheet,
const TQString& _text,
int _column,
int _row, FormatType _formatType );
340 virtual ~UndoSetText();
346 TQString m_sheetName;
350 TQString m_strRedoText;
351 FormatType m_eFormatType;
352 FormatType m_eFormatTypeRedo;
358 UndoCellFormat( Doc *_doc, Sheet *_sheet,
const Region &_selection,
const TQString &_title );
359 virtual ~UndoCellFormat();
365 void copyFormat( TQValueList<layoutCell> &list,TQValueList<layoutColumn> &listCol,TQValueList<layoutRow> &listRow, Sheet* sheet );
368 TQValueList<layoutCell> m_lstFormats;
369 TQValueList<layoutCell> m_lstRedoFormats;
370 TQValueList<layoutColumn> m_lstColFormats;
371 TQValueList<layoutColumn> m_lstRedoColFormats;
372 TQValueList<layoutRow> m_lstRowFormats;
373 TQValueList<layoutRow> m_lstRedoRowFormats;
375 TQString m_sheetName;
381 UndoChangeAngle( Doc *_doc, Sheet *_sheet,
const Region &_selection );
382 virtual ~UndoChangeAngle();
389 UndoCellFormat* m_layoutUndo;
390 UndoResizeColRow* m_resizeUndo;
397 UndoDelete(Doc *_doc, Sheet *_sheet,
const Region& region);
398 virtual ~UndoDelete();
404 void createListCell( TQCString &listCell,TQValueList<columnSize> &listCol,TQValueList<rowSize> &listRow, Sheet* sheet );
408 TQCString m_dataRedo;
409 TQValueList<columnSize> m_lstColumn;
410 TQValueList<columnSize> m_lstRedoColumn;
411 TQValueList<rowSize> m_lstRow;
412 TQValueList<rowSize> m_lstRedoRow;
413 TQString m_sheetName;
419 UndoDragDrop( Doc * _doc, Sheet * _sheet,
const Region& _source,
const Region& _target );
420 virtual ~UndoDragDrop();
426 Region m_selectionSource;
427 Region m_selectionTarget;
428 TQCString m_dataSource;
429 TQCString m_dataTarget;
430 TQCString m_dataRedoSource;
431 TQCString m_dataRedoTarget;
432 TQString m_sheetName;
434 void saveCellRect( TQCString & cells, Sheet * sheet,
435 const Region& region );
441 UndoResizeColRow( Doc *_doc, Sheet *_sheet,
const Region &_selection );
442 virtual ~UndoResizeColRow();
448 void createList( TQValueList<columnSize> &listCol,TQValueList<rowSize> &listRow, Sheet* sheet );
451 TQValueList<columnSize> m_lstColumn;
452 TQValueList<columnSize> m_lstRedoColumn;
453 TQValueList<rowSize> m_lstRow;
454 TQValueList<rowSize> m_lstRedoRow;
455 TQString m_sheetName;
458class UndoChangeAreaTextCell :
public UndoAction
461 UndoChangeAreaTextCell( Doc *_doc, Sheet *_sheet,
const Region &_selection );
462 virtual ~UndoChangeAreaTextCell();
468 void createList( TQMap<TQPoint,TQString> &list, Sheet* sheet );
471 TQMap<TQPoint,TQString> m_lstTextCell;
472 TQMap<TQPoint,TQString> m_lstRedoTextCell;
473 TQString m_sheetName;
479 UndoSort( Doc *_doc, Sheet *_sheet,
const TQRect &_selection);
486 void copyAll( TQValueList<layoutTextCell> & list, TQValueList<layoutColumn> & listCol,
487 TQValueList<layoutRow> & listRow, Sheet * sheet );
490 TQValueList<layoutTextCell> m_lstFormats;
491 TQValueList<layoutTextCell> m_lstRedoFormats;
492 TQValueList<layoutColumn> m_lstColFormats;
493 TQValueList<layoutColumn> m_lstRedoColFormats;
494 TQValueList<layoutRow> m_lstRowFormats;
495 TQValueList<layoutRow> m_lstRedoRowFormats;
497 TQString m_sheetName;
503 UndoMergedCell( Doc *_doc, Sheet *_sheet,
int _column,
int _row,
int _extraX,
int _extraY);
504 virtual ~UndoMergedCell();
516 TQString m_sheetName;
523 UndoAutofill( Doc *_doc, Sheet *_sheet,
const TQRect &_rect );
524 virtual ~UndoAutofill();
529 void createListCell( TQCString &list, Sheet* sheet );
532 TQCString m_dataRedo;
533 TQString m_sheetName;
536class UndoInsertCellCol :
public UndoInsertRemoveAction
539 UndoInsertCellCol( Doc *_doc, Sheet *_sheet,
const TQRect &_rect );
540 virtual ~UndoInsertCellCol();
546 TQString m_sheetName;
550class UndoInsertCellRow :
public UndoInsertRemoveAction
553 UndoInsertCellRow( Doc *_doc, Sheet *_sheet,
const TQRect &_rect );
554 virtual ~UndoInsertCellRow();
560 TQString m_sheetName;
564class UndoRemoveCellCol :
public UndoInsertRemoveAction
567 UndoRemoveCellCol( Doc *_doc, Sheet *_sheet,
const TQRect &_rect );
568 virtual ~UndoRemoveCellCol();
574 TQString m_sheetName;
579class UndoRemoveCellRow :
public UndoInsertRemoveAction
582 UndoRemoveCellRow( Doc *_doc, Sheet *_sheet,
const TQRect &_rect );
583 virtual ~UndoRemoveCellRow();
589 TQString m_sheetName;
597 UndoConditional( Doc *_doc, Sheet *_sheet,
const Region & _selection );
598 virtual ~UndoConditional();
603 void createListCell( TQCString &list, Sheet* sheet );
606 TQCString m_dataRedo;
607 TQString m_sheetName;
613 UndoCellPaste(Doc *_doc, Sheet *_sheet,
614 int _xshift,
int _yshift,
615 const Region& _selection,
bool insert,
int insertTo = 0);
616 virtual ~UndoCellPaste();
622 void createListCell( TQCString &listCell,TQValueList<columnSize> &listCol,TQValueList<rowSize> &listRow, Sheet* sheet );
626 TQCString m_dataRedo;
627 TQValueList<columnSize> m_lstColumn;
628 TQValueList<columnSize> m_lstRedoColumn;
629 TQValueList<rowSize> m_lstRow;
630 TQValueList<rowSize> m_lstRedoRow;
635 TQString m_sheetName;
642 UndoStyleCell( Doc *_doc, Sheet *_sheet,
const TQRect &_rect );
643 virtual ~UndoStyleCell();
649 void createListCell( TQValueList<styleCell> &listCell, Sheet* sheet );
651 TQValueList<styleCell> m_lstStyleCell;
652 TQValueList<styleCell> m_lstRedoStyleCell;
653 TQString m_sheetName;
656class UndoInsertData :
public UndoChangeAreaTextCell
659 UndoInsertData( Doc * _doc, Sheet * _sheet, TQRect & _selection );
675 bool isLocked()
const ;
677 bool hasUndoActions()
const {
return !m_stckUndo.isEmpty(); }
678 bool hasRedoActions()
const {
return !m_stckRedo.isEmpty(); }
680 void appendUndo( UndoAction *_action );
682 TQString getUndoName();
683 TQString getRedoName();
686 TQPtrStack<UndoAction> m_stckUndo;
687 TQPtrStack<UndoAction> m_stckRedo;
This class holds the data that makes up a spreadsheet.
The one for all class for points and ranges.