kspread

kspread_undo.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20
21#include "kspread_cell.h"
22#include "kspread_doc.h"
23#include "kspread_global.h"
24#include "kspread_locale.h"
25#include "kspread_map.h"
26#include "kspread_sheet.h"
27#include "kspread_sheetprint.h"
28#include "kspread_style.h"
29#include "kspread_style_manager.h"
30#include "kspread_util.h"
31
32#include "kspread_undo.h"
33
34using namespace KSpread;
35
36bool operator < (const TQPoint& pointA , const TQPoint& pointB)
37{
38 if (pointA.y() == pointB.y())
39 return ( pointA.x() < pointB.x() );
40 else
41 return ( pointA.y() < pointB.y() );
42}
43
44/****************************************************************************
45 *
46 * Undo
47 *
48 ***************************************************************************/
49
50Undo::Undo( Doc *_doc )
51{
52 m_pDoc = _doc;
53
54 m_stckUndo.setAutoDelete( false );
55 m_stckRedo.setAutoDelete( false );
56}
57
58Undo::~Undo()
59{
60 clear();
61}
62
63void Undo::appendUndo( UndoAction *_action )
64{
65 if ( isLocked() )
66 return;
67
68 m_stckRedo.setAutoDelete( true );
69 m_stckRedo.clear();
70 m_stckRedo.setAutoDelete( false );
71
72 m_stckUndo.push( _action );
73
74 if ( m_pDoc )
75 {
76 m_pDoc->enableUndo( hasUndoActions() );
77 m_pDoc->enableRedo( hasRedoActions() );
78 m_pDoc->setModified( true );
79 }
80}
81
82void Undo::clear()
83{
84 if ( isLocked() )
85 return;
86
87 m_stckUndo.setAutoDelete( true );
88 m_stckRedo.setAutoDelete( true );
89
90 m_stckUndo.clear();
91 m_stckRedo.clear();
92
93 m_stckUndo.setAutoDelete( false );
94 m_stckRedo.setAutoDelete( false );
95}
96
97void Undo::undo()
98{
99 if ( m_stckUndo.isEmpty() )
100 return;
101
102 //Don't show error dialogs on undo
103 bool origErrorMessages = true;
104 if ( m_pDoc )
105 {
106 origErrorMessages = m_pDoc->getShowMessageError();
107 m_pDoc->setShowMessageError( false );
108 }
109
110 UndoAction *a = m_stckUndo.pop();
111 a->undo();
112 m_stckRedo.push( a );
113
114 if ( m_pDoc )
115 {
116 m_pDoc->setShowMessageError( origErrorMessages );
117 m_pDoc->enableUndo( hasUndoActions() );
118 m_pDoc->enableRedo( hasRedoActions() );
119 }
120}
121
122void Undo::redo()
123{
124 if ( m_stckRedo.isEmpty() )
125 return;
126 UndoAction *a = m_stckRedo.pop();
127 a->redo();
128 m_stckUndo.push( a );
129
130 if ( m_pDoc )
131 {
132 m_pDoc->enableUndo( hasUndoActions() );
133 m_pDoc->enableRedo( hasRedoActions() );
134 }
135}
136
137void Undo::lock()
138{
139 m_pDoc->undoLock();
140}
141
142void Undo::unlock()
143{
144 m_pDoc->undoUnlock();
145}
146
147bool Undo::isLocked() const
148{
149 return m_pDoc->undoLocked();
150}
151
152TQString Undo::getRedoName()
153{
154 if ( m_stckRedo.isEmpty() )
155 return TQString("");
156 return m_stckRedo.current()->getName();
157
158}
159
160TQString Undo::getUndoName()
161{
162 if ( m_stckUndo.isEmpty() )
163 return TQString("");
164 return m_stckUndo.current()->getName();
165}
166
167/****************************************************************************
168 *
169 * MacroUndoAction
170 *
171 ***************************************************************************/
172MacroUndoAction::MacroUndoAction( Doc *_doc, const TQString& _name ):
173 UndoAction( _doc )
174{
175 name=_name;
176}
177
178MacroUndoAction::~MacroUndoAction()
179{
180 m_commands.setAutoDelete( true );
181}
182
183void MacroUndoAction::addCommand(UndoAction *command)
184{
185 m_commands.append(command);
186}
187
188void MacroUndoAction::undo()
189{
190 TQPtrListIterator<UndoAction> it(m_commands);
191 for ( ; it.current() ; ++it )
192 it.current()->undo();
193}
194
195void MacroUndoAction::redo()
196{
197 TQPtrListIterator<UndoAction> it(m_commands);
198 for ( ; it.current() ; ++it )
199 it.current()->redo();
200}
201
202/****************************************************************************
203 *
204 * UndoInsertRemoveAction
205 *
206 ***************************************************************************/
207
208UndoInsertRemoveAction::UndoInsertRemoveAction( Doc * _doc ) :
209 UndoAction( _doc )
210{
211}
212
213UndoInsertRemoveAction::~UndoInsertRemoveAction()
214{
215
216}
217
218void UndoInsertRemoveAction::saveFormulaReference( Sheet *_sheet,
219 int col, int row, TQString & formula )
220{
221 if ( _sheet == 0 )
222 return;
223 TQString sheetName = _sheet->sheetName();
224
225 m_lstFormulaCells.append( FormulaOfCell( sheetName, col, row, formula ) );
226}
227
228void UndoInsertRemoveAction::undoFormulaReference()
229{
230 TQValueList<FormulaOfCell>::iterator it;
231 for ( it = m_lstFormulaCells.begin(); it != m_lstFormulaCells.end(); ++it )
232 {
233 Sheet* sheet = doc()->map()->findSheet( (*it).sheetName() );
234 if ( sheet )
235 {
236 Cell * cell = sheet->cellAt( (*it).col(), (*it).row() );
237 if ( cell && !cell->isDefault() )
238 {
239 cell->setCellText( (*it).formula() );
240 }
241 }
242 }
243}
244
245/****************************************************************************
246 *
247 * UndoRemoveColumn
248 *
249 ***************************************************************************/
250
251UndoRemoveColumn::UndoRemoveColumn( Doc *_doc, Sheet *_sheet, int _column,int _nbCol ) :
252 UndoInsertRemoveAction( _doc )
253{
254 name=i18n("Remove Columns");
255 m_sheetName = _sheet->sheetName();
256 m_iColumn= _column;
257 m_iNbCol = _nbCol;
258 m_printRange = _sheet->print()->printRange();
259 m_printRepeatColumns = _sheet->print()->printRepeatColumns();
260 TQRect selection;
261 selection.setCoords( _column, 1, _column+m_iNbCol, KS_rowMax );
262 TQDomDocument doc = _sheet->saveCellRegion( selection );
263
264 // Save to buffer
265 TQString buffer;
266 TQTextStream str( &buffer, IO_WriteOnly );
267 str << doc;
268
269 // This is a terrible hack to store unicode
270 // data in a TQCString in a way that
271 // TQCString::length() == TQCString().size().
272 // This allows us to treat the TQCString like a TQByteArray later on.
273 m_data = buffer.utf8();
274 int len = m_data.length();
275 char tmp = m_data[ len - 1 ];
276 m_data.resize( len );
277 *( m_data.data() + len - 1 ) = tmp;
278}
279
280UndoRemoveColumn::~UndoRemoveColumn()
281{
282}
283
284void UndoRemoveColumn::undo()
285{
286 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
287 if ( !sheet )
288 return;
289
290 doc()->undoLock();
291
292 sheet->insertColumn( m_iColumn,m_iNbCol);
293
294 TQPoint pastePoint( m_iColumn, 1 );
295 sheet->paste( m_data, TQRect( pastePoint, pastePoint ) );
296 if(sheet->getAutoCalc()) sheet->recalc();
297
298 sheet->print()->setPrintRange( m_printRange );
299 sheet->print()->setPrintRepeatColumns( m_printRepeatColumns );
300
301 doc()->undoUnlock();
302
303 undoFormulaReference();
304}
305
306void UndoRemoveColumn::redo()
307{
308 doc()->undoLock();
309
310 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
311 if ( !sheet )
312 return;
313
314 sheet->removeColumn( m_iColumn,m_iNbCol );
315
316 doc()->undoUnlock();
317}
318
319/****************************************************************************
320 *
321 * UndoInsertColumn
322 *
323 ***************************************************************************/
324
325UndoInsertColumn::UndoInsertColumn( Doc *_doc, Sheet *_sheet, int _column, int _nbCol ) :
326 UndoInsertRemoveAction( _doc )
327{
328 name=i18n("Insert Columns");
329 m_sheetName = _sheet->sheetName();
330 m_iColumn= _column;
331 m_iNbCol=_nbCol;
332}
333
334UndoInsertColumn::~UndoInsertColumn()
335{
336}
337
338void UndoInsertColumn::undo()
339{
340 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
341 if ( !sheet )
342 return;
343
344 doc()->undoLock();
345 sheet->removeColumn( m_iColumn,m_iNbCol );
346 doc()->undoUnlock();
347
348 undoFormulaReference();
349}
350
351void UndoInsertColumn::redo()
352{
353 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
354 if ( !sheet )
355 return;
356
357 doc()->undoLock();
358 sheet->insertColumn( m_iColumn,m_iNbCol);
359 doc()->undoUnlock();
360}
361
362/****************************************************************************
363 *
364 * UndoRemoveRow
365 *
366 ***************************************************************************/
367
368UndoRemoveRow::UndoRemoveRow( Doc *_doc, Sheet *_sheet, int _row,int _nbRow) :
369 UndoInsertRemoveAction( _doc )
370{
371 name=i18n("Remove Rows");
372
373 m_sheetName = _sheet->sheetName();
374 m_iRow = _row;
375 m_iNbRow= _nbRow;
376 m_printRange=_sheet->print()->printRange();
377 m_printRepeatRows = _sheet->print()->printRepeatRows();
378
379 TQRect selection;
380 selection.setCoords( 1, _row, KS_colMax, _row+m_iNbRow );
381 TQDomDocument doc = _sheet->saveCellRegion( selection );
382
383 // Save to buffer
384 TQString buffer;
385 TQTextStream str( &buffer, IO_WriteOnly );
386 str << doc;
387
388 // This is a terrible hack to store unicode
389 // data in a TQCString in a way that
390 // TQCString::length() == TQCString().size().
391 // This allows us to treat the TQCString like a TQByteArray later on.
392 m_data = buffer.utf8();
393 int len = m_data.length();
394 char tmp = m_data[ len - 1 ];
395 m_data.resize( len );
396 *( m_data.data() + len - 1 ) = tmp;
397
398 // printf("UNDO {{{%s}}}\n", buffer.latin1() );
399 // printf("UNDO2 %i bytes, length %i {{{%s}}}\n", m_data.length(), m_data.size(), (const char*)m_data );
400 // printf("length=%i, size=%i", m_data.length(), m_data.size() );
401 // printf("Last characters are %i %i %i\n", (int)m_data[ m_data.size() - 3 ],
402 // (int)m_data[ m_data.size() - 2 ], (int)m_data[ m_data.size() - 1 ] );
403}
404
405UndoRemoveRow::~UndoRemoveRow()
406{
407}
408
409void UndoRemoveRow::undo()
410{
411 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
412 if ( !sheet )
413 return;
414
415 doc()->undoLock();
416
417 sheet->insertRow( m_iRow,m_iNbRow );
418
419 TQPoint pastePoint( 1, m_iRow );
420 sheet->paste( m_data, TQRect(pastePoint, pastePoint) );
421
422 sheet->print()->setPrintRange( m_printRange );
423 sheet->print()->setPrintRepeatRows( m_printRepeatRows );
424
425 if(sheet->getAutoCalc()) sheet->recalc();
426
427 doc()->undoUnlock();
428
429 undoFormulaReference();
430}
431
432void UndoRemoveRow::redo()
433{
434 doc()->undoLock();
435
436 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
437 if ( !sheet )
438 return;
439
440 sheet->removeRow( m_iRow,m_iNbRow );
441
442 doc()->undoUnlock();
443}
444
445/****************************************************************************
446 *
447 * UndoInsertRow
448 *
449 ***************************************************************************/
450
451UndoInsertRow::UndoInsertRow( Doc *_doc, Sheet *_sheet, int _row,int _nbRow ) :
452 UndoInsertRemoveAction( _doc )
453{
454 name=i18n("Insert Rows");
455 m_sheetName = _sheet->sheetName();
456 m_iRow = _row;
457 m_iNbRow=_nbRow;
458}
459
460UndoInsertRow::~UndoInsertRow()
461{
462}
463
464void UndoInsertRow::undo()
465{
466 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
467 if ( !sheet )
468 return;
469
470 doc()->undoLock();
471 sheet->removeRow( m_iRow,m_iNbRow );
472 doc()->undoUnlock();
473
474 undoFormulaReference();
475}
476
477void UndoInsertRow::redo()
478{
479 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
480 if ( !sheet )
481 return;
482
483 doc()->undoLock();
484 sheet->insertRow( m_iRow,m_iNbRow );
485 doc()->undoUnlock();
486}
487
488
489/****************************************************************************
490 *
491 * UndoHideRow
492 *
493 ***************************************************************************/
494
495/*UndoHideRow::UndoHideRow( Doc *_doc, Sheet *_sheet, int _row, int _nbRow , TQValueList<int>_listRow) :
496 UndoAction( _doc )
497{
498 name=i18n("Hide Rows");
499 m_sheetName = _sheet->sheetName();
500 m_iRow= _row;
501 m_iNbRow=_nbRow;
502 if(m_iNbRow!=-1)
503 createList( listRow ,_sheet );
504 else
505 listRow=TQValueList<int>(_listRow);
506}
507
508UndoHideRow::~UndoHideRow()
509{
510}
511
512void UndoHideRow::createList( TQValueList<int>&list,Sheet *tab )
513{
514RowFormat *rl;
515for(int i=m_iRow;i<=(m_iRow+m_iNbRow);i++)
516 {
517 rl= tab->nonDefaultRowFormat( i );
518 if(!rl->isHide())
519 list.append(rl->row());
520 }
521}
522
523void UndoHideRow::undo()
524{
525 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
526 if ( !sheet )
527 return;
528
529 doc()->undoLock();
530 sheet->showRow( 0,-1,listRow );
531 doc()->undoUnlock();
532}
533
534void UndoHideRow::redo()
535{
536 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
537 if ( !sheet )
538 return;
539
540 doc()->undoLock();
541 sheet->hideRow(0,-1, listRow );
542 doc()->undoUnlock();
543}*/
544
545/****************************************************************************
546 *
547 * UndoHideColumn
548 *
549 ***************************************************************************/
550
551/*UndoHideColumn::UndoHideColumn( Doc *_doc, Sheet *_sheet, int _column, int _nbCol, TQValueList<int>_listCol ) :
552 UndoAction( _doc )
553{
554 name=i18n("Hide Columns");
555
556 m_sheetName = _sheet->sheetName();
557 m_iColumn= _column;
558 m_iNbCol=_nbCol;
559 if(m_iNbCol!=-1)
560 createList( listCol ,_sheet );
561 else
562 listCol=TQValueList<int>(_listCol);
563}
564
565UndoHideColumn::~UndoHideColumn()
566{
567}
568
569void UndoHideColumn::createList( TQValueList<int>&list,Sheet *tab )
570{
571ColumnFormat *cl;
572for(int i=m_iColumn;i<=(m_iColumn+m_iNbCol);i++)
573 {
574 cl= tab->nonDefaultColumnFormat( i );
575 if(!cl->isHide())
576 list.append(cl->column());
577 }
578}
579
580void UndoHideColumn::undo()
581{
582 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
583 if ( !sheet )
584 return;
585
586 doc()->undoLock();
587 sheet->showColumn(0,-1,listCol);
588 doc()->undoUnlock();
589}
590
591void UndoHideColumn::redo()
592{
593 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
594 if ( !sheet )
595 return;
596
597 doc()->undoLock();
598 sheet->hideColumn(0,-1,listCol);
599 doc()->undoUnlock();
600}*/
601
602/****************************************************************************
603 *
604 * UndoShowRow
605 *
606 ***************************************************************************/
607
608/*UndoShowRow::UndoShowRow( Doc *_doc, Sheet *_sheet, int _row, int _nbRow, TQValueList<int>_listRow ) :
609 UndoAction( _doc )
610{
611 name=i18n("Show Rows");
612
613 m_sheetName = _sheet->sheetName();
614 m_iRow= _row;
615 m_iNbRow=_nbRow;
616 if(m_iNbRow!=-1)
617 createList( listRow ,_sheet );
618 else
619 listRow=TQValueList<int>(_listRow);
620}
621
622UndoShowRow::~UndoShowRow()
623{
624}
625
626void UndoShowRow::createList( TQValueList<int>&list,Sheet *tab )
627{
628RowFormat *rl;
629for(int i=m_iRow;i<=(m_iRow+m_iNbRow);i++)
630 {
631 rl= tab->nonDefaultRowFormat( i );
632 if(rl->isHide())
633 list.append(rl->row());
634 }
635}
636
637void UndoShowRow::undo()
638{
639 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
640 if ( !sheet )
641 return;
642
643 doc()->undoLock();
644 sheet->hideRow(0,-1,listRow);
645 doc()->undoUnlock();
646}
647
648void UndoShowRow::redo()
649{
650 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
651 if ( !sheet )
652 return;
653
654 doc()->undoLock();
655 sheet->showRow(0,-1,listRow);
656 doc()->undoUnlock();
657}*/
658
659/****************************************************************************
660 *
661 * UndoShowColumn
662 *
663 ***************************************************************************/
664
665/*UndoShowColumn::UndoShowColumn( Doc *_doc, Sheet *_sheet, int _column, int _nbCol,TQValueList<int>_listCol ) :
666 UndoAction( _doc )
667{
668 name=i18n("Show Columns");
669
670 m_sheetName = _sheet->sheetName();
671 m_iColumn= _column;
672 m_iNbCol=_nbCol;
673 if(m_iNbCol!=-1)
674 createList( listCol ,_sheet );
675 else
676 listCol=TQValueList<int>(_listCol);
677}
678
679UndoShowColumn::~UndoShowColumn()
680{
681}
682
683void UndoShowColumn::createList( TQValueList<int>&list,Sheet *tab )
684{
685ColumnFormat *cl;
686for(int i=m_iColumn;i<=(m_iColumn+m_iNbCol);i++)
687 {
688 cl= tab->nonDefaultColumnFormat( i );
689 if(cl->isHide())
690 list.append(cl->column());
691 }
692
693}
694
695void UndoShowColumn::undo()
696{
697 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
698 if ( !sheet )
699 return;
700
701 doc()->undoLock();
702 sheet->hideColumn( 0,-1,listCol );
703 doc()->undoUnlock();
704}
705
706void UndoShowColumn::redo()
707{
708 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
709 if ( !sheet )
710 return;
711
712 doc()->undoLock();
713 sheet->showColumn(0,-1,listCol);
714 doc()->undoUnlock();
715}*/
716
717
718/****************************************************************************
719 *
720 * UndoPaperLayout
721 *
722 ***************************************************************************/
723
724UndoPaperLayout::UndoPaperLayout( Doc *_doc, Sheet *_sheet )
725 : UndoAction( _doc )
726{
727 name=i18n("Set Page Layout");
728 m_sheetName = _sheet->sheetName();
729
730 m_pl = _sheet->print()->paperLayout();
731 m_hf = _sheet->print()->headFootLine();
732 m_unit = doc()->unit();
733 m_printGrid = _sheet->print()->printGrid();
734 m_printCommentIndicator = _sheet->print()->printCommentIndicator();
735 m_printFormulaIndicator = _sheet->print()->printFormulaIndicator();
736 m_printRange = _sheet->print()->printRange();
737 m_printRepeatColumns = _sheet->print()->printRepeatColumns();
738 m_printRepeatRows = _sheet->print()->printRepeatRows();
739 m_dZoom = _sheet->print()->zoom();
740 m_iPageLimitX = _sheet->print()->pageLimitX();
741 m_iPageLimitY = _sheet->print()->pageLimitY();
742}
743
744UndoPaperLayout::~UndoPaperLayout()
745{
746}
747
748void UndoPaperLayout::undo()
749{
750 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
751 if ( !sheet )
752 return;
753 SheetPrint* print = sheet->print();
754
755 doc()->undoLock();
756
757 m_plRedo = print->paperLayout();
758 print->setPaperLayout( m_pl.ptLeft, m_pl.ptTop,
759 m_pl.ptRight, m_pl.ptBottom,
760 m_pl.format, m_pl.orientation );
761
762 m_hfRedo = print->headFootLine();
763 print->setHeadFootLine( m_hf.headLeft, m_hf.headMid, m_hf.headRight,
764 m_hf.footLeft, m_hf.footMid, m_hf.footRight );
765
766 m_unitRedo = doc()->unit();
767 doc()->setUnit( m_unit );
768
769 m_printGridRedo = print->printGrid();
770 print->setPrintGrid( m_printGrid );
771
772 m_printCommentIndicatorRedo = print->printCommentIndicator();
773 print->setPrintCommentIndicator( m_printCommentIndicator );
774
775 m_printFormulaIndicatorRedo = print->printFormulaIndicator();
776 print->setPrintFormulaIndicator( m_printFormulaIndicator );
777
778 m_printRangeRedo = print->printRange();
779 print->setPrintRange( m_printRange );
780
781 m_printRepeatColumnsRedo = print->printRepeatColumns();
782 print->setPrintRepeatColumns( m_printRepeatColumns );
783
784 m_printRepeatRowsRedo = print->printRepeatRows();
785 print->setPrintRepeatRows( m_printRepeatRows );
786
787 m_dZoomRedo = print->zoom();
788 print->setZoom( m_dZoom );
789
790 m_iPageLimitXRedo = print->pageLimitX();
791 print->setPageLimitX( m_iPageLimitX );
792
793 m_iPageLimitYRedo = print->pageLimitY();
794 print->setPageLimitY( m_iPageLimitY );
795
796 doc()->undoUnlock();
797}
798
799void UndoPaperLayout::redo()
800{
801 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
802 if ( !sheet )
803 return;
804 SheetPrint* print = sheet->print();
805
806 doc()->undoLock();
807 print->setPaperLayout( m_plRedo.ptLeft, m_plRedo.ptTop,
808 m_plRedo.ptRight, m_plRedo.ptBottom,
809 m_plRedo.format, m_plRedo.orientation );
810
811 print->setHeadFootLine( m_hfRedo.headLeft, m_hfRedo.headMid, m_hfRedo.headRight,
812 m_hfRedo.footLeft, m_hfRedo.footMid, m_hfRedo.footRight );
813
814 doc()->setUnit( m_unitRedo );
815
816 print->setPrintGrid( m_printGridRedo );
817 print->setPrintCommentIndicator( m_printCommentIndicatorRedo );
818 print->setPrintFormulaIndicator( m_printFormulaIndicatorRedo );
819
820 print->setPrintRange( m_printRangeRedo );
821 print->setPrintRepeatColumns( m_printRepeatColumnsRedo );
822 print->setPrintRepeatRows( m_printRepeatRowsRedo );
823
824 print->setZoom( m_dZoomRedo );
825
826 print->setPageLimitX( m_iPageLimitX );
827 print->setPageLimitY( m_iPageLimitY );
828
829 doc()->undoUnlock();
830}
831
832
833
834
835/****************************************************************************
836 *
837 * UndoSetText
838 *
839 ***************************************************************************/
840
841UndoSetText::UndoSetText( Doc *_doc, Sheet *_sheet, const TQString& _text, int _column, int _row,FormatType _formatType ) :
842 UndoAction( _doc )
843{
844 name=i18n("Change Text");
845
846 m_strText = _text;
847 m_iColumn= _column;
848 m_iRow = _row;
849 m_sheetName = _sheet->sheetName();
850 m_eFormatType=_formatType;
851}
852
853UndoSetText::~UndoSetText()
854{
855}
856
857void UndoSetText::undo()
858{
859 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
860 if ( !sheet )
861 return;
862
863 doc()->undoLock();
864 doc()->emitBeginOperation();
865 Cell *cell = sheet->nonDefaultCell( m_iColumn, m_iRow );
866 m_strRedoText = cell->text();
867 m_eFormatTypeRedo=cell->format()->getFormatType( m_iColumn, m_iRow );
868 cell->format()->setFormatType(m_eFormatType);
869
870 if ( m_strText.isNull() )
871 cell->setCellText( "" );
872 else
873 cell->setCellText( m_strText );
874 sheet->updateView( TQRect( m_iColumn, m_iRow, 1, 1 ) );
875 doc()->undoUnlock();
876}
877
878void UndoSetText::redo()
879{
880 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
881 if ( !sheet )
882 return;
883
884 doc()->undoLock();
885 doc()->emitBeginOperation();
886 Cell *cell = sheet->nonDefaultCell( m_iColumn, m_iRow );
887 m_strText = cell->text();
888 m_eFormatType=cell->format()->getFormatType( m_iColumn, m_iRow );
889 if ( m_strRedoText.isNull() )
890 cell->setCellText( "" );
891 else
892 cell->setCellText( m_strRedoText );
893 cell->format()->setFormatType(m_eFormatTypeRedo);
894 sheet->updateView( TQRect( m_iColumn, m_iRow, 1, 1 ) );
895 doc()->undoUnlock();
896}
897
898/****************************************************************************
899 *
900 * UndoCellFormat
901 *
902 ***************************************************************************/
903
904UndoCellFormat::UndoCellFormat( Doc * _doc,
905 Sheet * _sheet,
906 const Region & _selection,
907 const TQString & _name ) :
908 UndoAction( _doc )
909{
910 if ( _name.isEmpty())
911 name = i18n("Change Format");
912 else
913 name = _name;
914
915 m_region = _selection;
916 m_sheetName = _sheet->sheetName();
917 copyFormat( m_lstFormats, m_lstColFormats, m_lstRowFormats, _sheet );
918}
919
920void UndoCellFormat::copyFormat(TQValueList<layoutCell> & list,
921 TQValueList<layoutColumn> & listCol,
922 TQValueList<layoutRow> & listRow,
923 Sheet * sheet )
924{
925 TQValueList<layoutCell>::Iterator it2;
926 for ( it2 = list.begin(); it2 != list.end(); ++it2 )
927 {
928 delete (*it2).l;
929 }
930 list.clear();
931
932 Cell * cell;
933 Region::ConstIterator endOfList(m_region.constEnd());
934 for (Region::ConstIterator it = m_region.constBegin(); it != endOfList; ++it)
935 {
936 TQRect range = (*it)->rect().normalize();
937 int bottom = range.bottom();
938 int right = range.right();
939
940 if ( util_isColumnSelected( range ) )
941 {
942 /* Don't need to go through the loop twice...
943 for (int i = range.left(); i <= right; ++i)
944 {
945 layoutColumn tmplayout;
946 tmplayout.col = i;
947 tmplayout.l = new ColumnFormat( sheet, i );
948 tmplayout.l->copy( *(sheet->columnFormat( i )) );
949 listCol.append(tmplayout);
950 }
951 */
952 for ( int c = range.left(); c <= right; ++c )
953 {
954 layoutColumn tmplayout;
955 tmplayout.col = c;
956 tmplayout.l = new ColumnFormat( sheet, c );
957 tmplayout.l->copy( *(sheet->columnFormat( c )) );
958 listCol.append(tmplayout);
959
960 cell = sheet->getFirstCellColumn( c );
961 while ( cell )
962 {
963 if ( cell->isPartOfMerged() )
964 {
965 cell = sheet->getNextCellDown( c, cell->row() );
966 continue;
967 }
968
969 layoutCell tmplayout;
970 tmplayout.col = c;
971 tmplayout.row = cell->row();
972 tmplayout.l = new Format( sheet, 0 );
973 tmplayout.l->copy( *(sheet->cellAt( tmplayout.col, tmplayout.row )->format()) );
974 list.append(tmplayout);
975
976 cell = sheet->getNextCellDown( c, cell->row() );
977 }
978 }
979 /*
980 Cell * c = sheet->firstCell();
981 for( ; c; c = c->nextCell() )
982 {
983 int col = c->column();
984 if ( range.left() <= col && right >= col
985 && !c->isPartOfMerged())
986 {
987 layoutCell tmplayout;
988 tmplayout.col = c->column();
989 tmplayout.row = c->row();
990 tmplayout.l = new Format( sheet, 0 );
991 tmplayout.l->copy( *(sheet->cellAt( tmplayout.col, tmplayout.row )) );
992 list.append(tmplayout);
993 }
994 }
995 */
996 }
997 else if (util_isRowSelected( range ) )
998 {
999 for ( int row = range.top(); row <= bottom; ++row )
1000 {
1001 layoutRow tmplayout;
1002 tmplayout.row = row;
1003 tmplayout.l = new RowFormat( sheet, row );
1004 tmplayout.l->copy( *(sheet->rowFormat( row )) );
1005 listRow.append(tmplayout);
1006
1007 cell = sheet->getFirstCellRow( row );
1008 while ( cell )
1009 {
1010 if ( cell->isPartOfMerged() )
1011 {
1012 cell = sheet->getNextCellRight( cell->column(), row );
1013 continue;
1014 }
1015 layoutCell tmplayout;
1016 tmplayout.col = cell->column();
1017 tmplayout.row = row;
1018 tmplayout.l = new Format( sheet, 0 );
1019 tmplayout.l->copy( *(sheet->cellAt( cell->column(), row )->format()) );
1020 list.append(tmplayout);
1021
1022 cell = sheet->getNextCellRight( cell->column(), row );
1023 }
1024 }
1025 /*
1026 Cell * c = sheet->firstCell();
1027 for( ; c; c = c->nextCell() )
1028 {
1029 int row = c->row();
1030 if ( range.top() <= row && bottom >= row
1031 && !c->isPartOfMerged())
1032 {
1033 layoutCell tmplayout;
1034 tmplayout.col = c->column();
1035 tmplayout.row = c->row();
1036 tmplayout.l = new Format( sheet, 0 );
1037 tmplayout.l->copy( *(sheet->cellAt( tmplayout.col, tmplayout.row )) );
1038 list.append(tmplayout);
1039 }
1040 }
1041 */
1042 }
1043 else
1044 {
1045 for ( int y = range.top(); y <= bottom; ++y )
1046 for ( int x = range.left(); x <= right; ++x )
1047 {
1048 Cell * cell = sheet->nonDefaultCell( x, y );
1049 if ( !cell->isPartOfMerged() )
1050 {
1051 layoutCell tmplayout;
1052 tmplayout.col = x;
1053 tmplayout.row = y;
1054 tmplayout.l = new Format( sheet, 0 );
1055 tmplayout.l->copy( *(sheet->cellAt( x, y )->format()) );
1056 list.append(tmplayout);
1057 }
1058 }
1059 }
1060 }
1061}
1062
1063UndoCellFormat::~UndoCellFormat()
1064{
1065 TQValueList<layoutCell>::Iterator it2;
1066 for ( it2 = m_lstFormats.begin(); it2 != m_lstFormats.end(); ++it2 )
1067 {
1068 delete (*it2).l;
1069 }
1070 m_lstFormats.clear();
1071
1072 for ( it2 = m_lstRedoFormats.begin(); it2 != m_lstRedoFormats.end(); ++it2 )
1073 {
1074 delete (*it2).l;
1075 }
1076 m_lstRedoFormats.clear();
1077
1078 TQValueList<layoutColumn>::Iterator it3;
1079 for ( it3 = m_lstColFormats.begin(); it3 != m_lstColFormats.end(); ++it3 )
1080 {
1081 delete (*it3).l;
1082 }
1083 m_lstColFormats.clear();
1084
1085 for ( it3 = m_lstRedoColFormats.begin(); it3 != m_lstRedoColFormats.end(); ++it3 )
1086 {
1087 delete (*it3).l;
1088 }
1089 m_lstRedoColFormats.clear();
1090
1091 TQValueList<layoutRow>::Iterator it4;
1092 for ( it4 = m_lstRowFormats.begin(); it4 != m_lstRowFormats.end(); ++it4 )
1093 {
1094 delete (*it4).l;
1095 }
1096 m_lstRowFormats.clear();
1097
1098 for ( it4 = m_lstRedoRowFormats.begin(); it4 != m_lstRedoRowFormats.end(); ++it4 )
1099 {
1100 delete (*it4).l;
1101 }
1102 m_lstRedoRowFormats.clear();
1103
1104
1105}
1106
1107void UndoCellFormat::undo()
1108{
1109 Sheet * sheet = doc()->map()->findSheet( m_sheetName );
1110 if ( !sheet )
1111 return;
1112
1113 doc()->undoLock();
1114 doc()->emitBeginOperation();
1115 copyFormat( m_lstRedoFormats, m_lstRedoColFormats, m_lstRedoRowFormats, sheet );
1116 Region::ConstIterator endOfList(m_region.constEnd());
1117 for (Region::ConstIterator it = m_region.constBegin(); it != endOfList; ++it)
1118 {
1119 TQRect range = (*it)->rect().normalize();
1120 if( util_isColumnSelected( range ) )
1121 {
1122 TQValueList<layoutColumn>::Iterator it2;
1123 for ( it2 = m_lstColFormats.begin(); it2 != m_lstColFormats.end(); ++it2 )
1124 {
1125 ColumnFormat * col = sheet->nonDefaultColumnFormat( (*it2).col );
1126 col->copy( *(*it2).l );
1127 }
1128 }
1129 else if( util_isRowSelected( range ) )
1130 {
1131 TQValueList<layoutRow>::Iterator it2;
1132 for ( it2 = m_lstRowFormats.begin(); it2 != m_lstRowFormats.end(); ++it2 )
1133 {
1134 RowFormat * row = sheet->nonDefaultRowFormat( (*it2).row );
1135 row->copy( *(*it2).l );
1136 }
1137 }
1138
1139 TQValueList<layoutCell>::Iterator it2;
1140 for ( it2 = m_lstFormats.begin(); it2 != m_lstFormats.end(); ++it2 )
1141 {
1142 Cell *cell = sheet->nonDefaultCell( (*it2).col,(*it2).row );
1143 cell->format()->copy( *(*it2).l );
1144 cell->setLayoutDirtyFlag();
1145 cell->setDisplayDirtyFlag();
1146 sheet->updateCell( cell, (*it2).col, (*it2).row );
1147 }
1148 }
1149 sheet->setRegionPaintDirty( m_region );
1150 sheet->updateView( &m_region );
1151
1152 doc()->undoUnlock();
1153}
1154
1155void UndoCellFormat::redo()
1156{
1157 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
1158 if ( !sheet )
1159 return;
1160
1161 doc()->undoLock();
1162 doc()->emitBeginOperation();
1163
1164 Region::ConstIterator endOfList(m_region.constEnd());
1165 for (Region::ConstIterator it = m_region.constBegin(); it != endOfList; ++it)
1166 {
1167 TQRect range = (*it)->rect().normalize();
1168 if ( util_isColumnSelected( range ) )
1169 {
1170 TQValueList<layoutColumn>::Iterator it2;
1171 for ( it2 = m_lstRedoColFormats.begin(); it2 != m_lstRedoColFormats.end(); ++it2 )
1172 {
1173 ColumnFormat * col = sheet->nonDefaultColumnFormat( (*it2).col );
1174 col->copy( *(*it2).l );
1175 }
1176 }
1177 else if( util_isRowSelected( range ) )
1178 {
1179 TQValueList<layoutRow>::Iterator it2;
1180 for ( it2 = m_lstRedoRowFormats.begin(); it2 != m_lstRedoRowFormats.end(); ++it2 )
1181 {
1182 RowFormat * row = sheet->nonDefaultRowFormat( (*it2).row );
1183 row->copy( *(*it2).l );
1184 }
1185 }
1186
1187 TQValueList<layoutCell>::Iterator it2;
1188 for ( it2 = m_lstRedoFormats.begin(); it2 != m_lstRedoFormats.end(); ++it2 )
1189 {
1190 Cell * cell = sheet->nonDefaultCell( (*it2).col,(*it2).row );
1191 cell->format()->copy( *(*it2).l );
1192 cell->setLayoutDirtyFlag();
1193 cell->setDisplayDirtyFlag();
1194 sheet->updateCell( cell, (*it2).col, (*it2).row );
1195 }
1196 }
1197
1198 sheet->setRegionPaintDirty( m_region );
1199 sheet->updateView( &m_region );
1200 doc()->undoUnlock();
1201}
1202
1203/****************************************************************************
1204 *
1205 * UndoChangeAngle
1206 *
1207 ***************************************************************************/
1208
1209UndoChangeAngle::UndoChangeAngle( Doc * _doc,
1210 Sheet * _sheet,
1211 const Region & _selection ) :
1212 UndoAction( _doc )
1213{
1214 name = i18n("Change Angle");
1215 m_layoutUndo = new UndoCellFormat( _doc, _sheet, _selection, TQString() );
1216 m_resizeUndo = new UndoResizeColRow( _doc, _sheet, _selection );
1217}
1218
1219UndoChangeAngle::~UndoChangeAngle()
1220{
1221 delete m_resizeUndo;
1222 delete m_layoutUndo;
1223}
1224
1225void UndoChangeAngle::undo()
1226{
1227 m_layoutUndo->undo();
1228 m_resizeUndo->undo();
1229}
1230
1231void UndoChangeAngle::redo()
1232{
1233 m_layoutUndo->redo();
1234 m_resizeUndo->redo();
1235}
1236
1237/****************************************************************************
1238 *
1239 * UndoSort
1240 *
1241 ***************************************************************************/
1242
1243UndoSort::UndoSort( Doc * _doc, Sheet * _sheet, const TQRect & _selection ) :
1244 UndoAction( _doc )
1245{
1246 name = i18n("Sort");
1247
1248 m_rctRect = _selection;
1249 m_sheetName = _sheet->sheetName();
1250 copyAll( m_lstFormats, m_lstColFormats, m_lstRowFormats, _sheet );
1251}
1252
1253void UndoSort::copyAll(TQValueList<layoutTextCell> & list, TQValueList<layoutColumn> & listCol,
1254 TQValueList<layoutRow> & listRow, Sheet * sheet )
1255{
1256 TQValueList<layoutTextCell>::Iterator it2;
1257 for ( it2 = list.begin(); it2 != list.end(); ++it2 )
1258 {
1259 delete (*it2).l;
1260 }
1261 list.clear();
1262
1263 if ( util_isColumnSelected( m_rctRect ) )
1264 {
1265 Cell * c;
1266 for (int col = m_rctRect.left(); col <= m_rctRect.right(); ++col)
1267 {
1268 layoutColumn tmplayout;
1269 tmplayout.col = col;
1270 tmplayout.l = new ColumnFormat( sheet, col );
1271 tmplayout.l->copy( *(sheet->columnFormat( col )) );
1272 listCol.append(tmplayout);
1273
1274 c = sheet->getFirstCellColumn( col );
1275 while ( c )
1276 {
1277 if ( !c->isPartOfMerged() )
1278 {
1279 layoutTextCell tmplayout;
1280 tmplayout.col = col;
1281 tmplayout.row = c->row();
1282 tmplayout.l = new Format( sheet, 0 );
1283 tmplayout.l->copy( *(sheet->cellAt( tmplayout.col, tmplayout.row )->format()) );
1284 tmplayout.text = c->text();
1285 list.append(tmplayout);
1286 }
1287
1288 c = sheet->getNextCellDown( col, c->row() );
1289 }
1290 }
1291 }
1292 else if ( util_isRowSelected( m_rctRect ) )
1293 {
1294 Cell * c;
1295 for ( int row = m_rctRect.top(); row <= m_rctRect.bottom(); ++row)
1296 {
1297 layoutRow tmplayout;
1298 tmplayout.row = row;
1299 tmplayout.l = new RowFormat( sheet, row );
1300 tmplayout.l->copy( *(sheet->rowFormat( row )) );
1301 listRow.append(tmplayout);
1302
1303 c = sheet->getFirstCellRow( row );
1304 while ( c )
1305 {
1306 if ( !c->isPartOfMerged() )
1307 {
1308 layoutTextCell tmplayout;
1309 tmplayout.col = c->column();
1310 tmplayout.row = row;
1311 tmplayout.l = new Format( sheet, 0 );
1312 tmplayout.l->copy( *(sheet->cellAt( tmplayout.col, tmplayout.row )->format()) );
1313 tmplayout.text = c->text();
1314 list.append(tmplayout);
1315 }
1316 c = sheet->getNextCellRight( c->column(), row );
1317 }
1318 }
1319 }
1320 else
1321 {
1322 int bottom = m_rctRect.bottom();
1323 int right = m_rctRect.right();
1324 Cell * cell;
1325 for ( int y = m_rctRect.top(); y <= bottom; ++y )
1326 for ( int x = m_rctRect.left(); x <= right; ++x )
1327 {
1328 cell = sheet->nonDefaultCell( x, y );
1329 if (!cell->isPartOfMerged())
1330 {
1331 layoutTextCell tmplayout;
1332 tmplayout.col = x;
1333 tmplayout.row = y;
1334 tmplayout.l = new Format( sheet, 0 );
1335 tmplayout.l->copy( *(sheet->cellAt( x, y )->format()) );
1336 tmplayout.text = cell->text();
1337 list.append(tmplayout);
1338 }
1339 }
1340 }
1341}
1342
1343UndoSort::~UndoSort()
1344{
1345 TQValueList<layoutTextCell>::Iterator it2;
1346 for ( it2 = m_lstFormats.begin(); it2 != m_lstFormats.end(); ++it2 )
1347 {
1348 delete (*it2).l;
1349 }
1350 m_lstFormats.clear();
1351
1352 for ( it2 = m_lstRedoFormats.begin(); it2 != m_lstRedoFormats.end(); ++it2 )
1353 {
1354 delete (*it2).l;
1355 }
1356 m_lstRedoFormats.clear();
1357
1358 TQValueList<layoutColumn>::Iterator it3;
1359 for ( it3 = m_lstColFormats.begin(); it3 != m_lstColFormats.end(); ++it3 )
1360 {
1361 delete (*it3).l;
1362 }
1363 m_lstColFormats.clear();
1364
1365 for ( it3 = m_lstRedoColFormats.begin(); it3 != m_lstRedoColFormats.end(); ++it3 )
1366 {
1367 delete (*it3).l;
1368 }
1369 m_lstRedoColFormats.clear();
1370
1371 TQValueList<layoutRow>::Iterator it4;
1372 for ( it4 = m_lstRowFormats.begin(); it4 != m_lstRowFormats.end(); ++it4 )
1373 {
1374 delete (*it4).l;
1375 }
1376 m_lstRowFormats.clear();
1377
1378 for ( it4 = m_lstRedoRowFormats.begin(); it4 != m_lstRedoRowFormats.end(); ++it4 )
1379 {
1380 delete (*it4).l;
1381 }
1382 m_lstRedoRowFormats.clear();
1383
1384}
1385
1386void UndoSort::undo()
1387{
1388 Sheet * sheet = doc()->map()->findSheet( m_sheetName );
1389 if ( !sheet )
1390 return;
1391
1392 doc()->undoLock();
1393 doc()->emitBeginOperation();
1394
1395 copyAll( m_lstRedoFormats, m_lstRedoColFormats,
1396 m_lstRedoRowFormats, sheet );
1397
1398 if ( util_isColumnSelected( m_rctRect ) )
1399 {
1400 TQValueList<layoutColumn>::Iterator it2;
1401 for ( it2 = m_lstColFormats.begin(); it2 != m_lstColFormats.end(); ++it2 )
1402 {
1403 ColumnFormat * col = sheet->nonDefaultColumnFormat( (*it2).col );
1404 col->copy( *(*it2).l );
1405 }
1406 }
1407 else if( util_isRowSelected( m_rctRect ) )
1408 {
1409 TQValueList<layoutRow>::Iterator it2;
1410 for ( it2 = m_lstRowFormats.begin(); it2 != m_lstRowFormats.end(); ++it2 )
1411 {
1412 RowFormat *row= sheet->nonDefaultRowFormat( (*it2).row );
1413 row->copy( *(*it2).l );
1414 }
1415 }
1416
1417 TQValueList<layoutTextCell>::Iterator it2;
1418 for ( it2 = m_lstFormats.begin(); it2 != m_lstFormats.end(); ++it2 )
1419 {
1420 Cell *cell = sheet->nonDefaultCell( (*it2).col,(*it2).row );
1421 if ( (*it2).text.isEmpty() )
1422 {
1423 if(!cell->text().isEmpty())
1424 cell->setCellText( "" );
1425 }
1426 else
1427 cell->setCellText( (*it2).text );
1428
1429 cell->format()->copy( *(*it2).l );
1430 cell->setLayoutDirtyFlag();
1431 cell->setDisplayDirtyFlag();
1432 sheet->updateCell( cell, (*it2).col, (*it2).row );
1433 }
1434
1435 sheet->setRegionPaintDirty(m_rctRect);
1436 sheet->updateView( m_rctRect );
1437
1438 doc()->undoUnlock();
1439}
1440
1441void UndoSort::redo()
1442{
1443 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
1444 if ( !sheet )
1445 return;
1446
1447 doc()->undoLock();
1448 doc()->emitBeginOperation();
1449
1450 if( util_isColumnSelected( m_rctRect ) )
1451 {
1452 TQValueList<layoutColumn>::Iterator it2;
1453 for ( it2 = m_lstRedoColFormats.begin(); it2 != m_lstRedoColFormats.end(); ++it2 )
1454 {
1455 ColumnFormat *col= sheet->nonDefaultColumnFormat( (*it2).col );
1456 col->copy( *(*it2).l );
1457 }
1458 }
1459 else if( util_isRowSelected( m_rctRect ) )
1460 {
1461 TQValueList<layoutRow>::Iterator it2;
1462 for ( it2 = m_lstRedoRowFormats.begin(); it2 != m_lstRedoRowFormats.end(); ++it2 )
1463 {
1464 RowFormat *row= sheet->nonDefaultRowFormat( (*it2).row );
1465 row->copy( *(*it2).l );
1466 }
1467 }
1468
1469 TQValueList<layoutTextCell>::Iterator it2;
1470 for ( it2 = m_lstRedoFormats.begin(); it2 != m_lstRedoFormats.end(); ++it2 )
1471 {
1472 Cell *cell = sheet->nonDefaultCell( (*it2).col,(*it2).row );
1473
1474 if ( (*it2).text.isEmpty() )
1475 {
1476 if(!cell->text().isEmpty())
1477 cell->setCellText( "" );
1478 }
1479 else
1480 cell->setCellText( (*it2).text );
1481
1482 cell->format()->copy( *(*it2).l );
1483 cell->setLayoutDirtyFlag();
1484 cell->setDisplayDirtyFlag();
1485 sheet->updateCell( cell, (*it2).col, (*it2).row );
1486 }
1487 sheet->setRegionPaintDirty(m_rctRect);
1488 sheet->updateView( m_rctRect );
1489 doc()->undoUnlock();
1490}
1491
1492/****************************************************************************
1493 *
1494 * UndoDelete
1495 *
1496 ***************************************************************************/
1497
1498UndoDelete::UndoDelete( Doc *_doc, Sheet* sheet, const Region& region)
1499 : UndoAction( _doc )
1500{
1501 name=i18n("Delete");
1502 m_sheetName = sheet->sheetName();
1503 m_region = region;
1504 createListCell(m_data, m_lstColumn, m_lstRow, sheet);
1505}
1506
1507UndoDelete::~UndoDelete()
1508{
1509}
1510
1511void UndoDelete::createListCell( TQCString &listCell,TQValueList<columnSize> &listCol,TQValueList<rowSize> &listRow, Sheet* sheet )
1512{
1513 listRow.clear();
1514 listCol.clear();
1515 Region::ConstIterator endOfList = m_region.constEnd();
1516 for (Region::ConstIterator it = m_region.constBegin(); it != endOfList; ++it)
1517 {
1518 TQRect range = (*it)->rect().normalize();
1519 // copy column(s)
1520 if ((*it)->isColumn())
1521 {
1522 for( int y = range.left() ; y <= range.right() ; ++y )
1523 {
1524 ColumnFormat * cl = sheet->columnFormat( y );
1525 if ( !cl->isDefault() )
1526 {
1527 columnSize tmpSize;
1528 tmpSize.columnNumber=y;
1529 tmpSize.columnWidth=cl->dblWidth();
1530 listCol.append(tmpSize);
1531 }
1532 }
1533 }
1534 // copy row(s)
1535 else if ((*it)->isRow())
1536 {
1537 //save size of row(s)
1538 for( int y = range.top() ; y <= range.bottom() ; ++y )
1539 {
1540 RowFormat *rw=sheet->rowFormat(y);
1541 if(!rw->isDefault())
1542 {
1543 rowSize tmpSize;
1544 tmpSize.rowNumber=y;
1545 tmpSize.rowHeight=rw->dblHeight();
1546 listRow.append(tmpSize);
1547 }
1548 }
1549
1550 }
1551 }
1552
1553 //save all cells in area
1554 TQDomDocument doc = sheet->saveCellRegion( m_region );
1555 // Save to buffer
1556 TQString buffer;
1557 TQTextStream str( &buffer, IO_WriteOnly );
1558 str << doc;
1559
1560 // This is a terrible hack to store unicode
1561 // data in a TQCString in a way that
1562 // TQCString::length() == TQCString().size().
1563 // This allows us to treat the TQCString like a TQByteArray later on.
1564 listCell = buffer.utf8();
1565 int len = listCell.length();
1566 char tmp = listCell[ len - 1 ];
1567 listCell.resize( len );
1568 *( listCell.data() + len - 1 ) = tmp;
1569}
1570
1571
1572void UndoDelete::undo()
1573{
1574 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
1575 if ( !sheet )
1576 return;
1577 createListCell( m_dataRedo, m_lstRedoColumn, m_lstRedoRow, sheet );
1578
1579 doc()->undoLock();
1580 doc()->emitBeginOperation();
1581
1582 {
1583 TQValueList<columnSize>::Iterator it2;
1584 for ( it2 = m_lstColumn.begin(); it2 != m_lstColumn.end(); ++it2 )
1585 {
1586 ColumnFormat *cl=sheet->nonDefaultColumnFormat((*it2).columnNumber);
1587 cl->setDblWidth((*it2).columnWidth);
1588 }
1589 }
1590
1591 {
1592 TQValueList<rowSize>::Iterator it2;
1593 for ( it2 = m_lstRow.begin(); it2 != m_lstRow.end(); ++it2 )
1594 {
1595 RowFormat *rw=sheet->nonDefaultRowFormat((*it2).rowNumber);
1596 rw->setDblHeight((*it2).rowHeight);
1597 }
1598 }
1599
1600 sheet->deleteCells(m_region);
1601 sheet->paste( m_data, m_region.boundingRect() );
1602 sheet->updateView( );
1603
1604 if(sheet->getAutoCalc()) sheet->recalc();
1605
1606 doc()->undoUnlock();
1607}
1608
1609void UndoDelete::redo()
1610{
1611 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
1612 if ( !sheet )
1613 return;
1614
1615 doc()->undoLock();
1616 doc()->emitBeginOperation();
1617
1618 {
1619 TQValueList<columnSize>::Iterator it2;
1620 for ( it2 = m_lstRedoColumn.begin(); it2 != m_lstRedoColumn.end(); ++it2 )
1621 {
1622 ColumnFormat *cl=sheet->nonDefaultColumnFormat((*it2).columnNumber);
1623 cl->setDblWidth((*it2).columnWidth);
1624 }
1625 }
1626
1627 {
1628 TQValueList<rowSize>::Iterator it2;
1629 for ( it2 = m_lstRedoRow.begin(); it2 != m_lstRedoRow.end(); ++it2 )
1630 {
1631 RowFormat *rw=sheet->nonDefaultRowFormat((*it2).rowNumber);
1632 rw->setDblHeight((*it2).rowHeight);
1633 }
1634 }
1635
1636 //move next line to refreshView
1637 //because I must know what is the real rect
1638 //that I must refresh, when there is cell Merged
1639
1640 sheet->paste( m_dataRedo, m_region.boundingRect() );
1641 //sheet->deleteCells( m_selection );
1642 sheet->updateView();
1643 sheet->refreshView( m_region ); // deletes the cells in region!
1644 doc()->undoUnlock();
1645}
1646
1647/****************************************************************************
1648 *
1649 * UndoDragDrop
1650 *
1651 ***************************************************************************/
1652
1653UndoDragDrop::UndoDragDrop( Doc * _doc, Sheet * _sheet,
1654 const Region& _source,
1655 const Region& _target )
1656 : UndoAction( _doc ),
1657 m_selectionSource( _source ),
1658 m_selectionTarget( _target )
1659{
1660 name = i18n( "Drag & Drop" );
1661
1662 m_sheetName = _sheet->sheetName();
1663
1664 saveCellRect( m_dataTarget, _sheet, _target );
1665 saveCellRect( m_dataSource, _sheet, _source );
1666}
1667
1668UndoDragDrop::~UndoDragDrop()
1669{
1670}
1671
1672void UndoDragDrop::saveCellRect( TQCString & cells, Sheet * sheet,
1673 const Region& region )
1674{
1675 TQDomDocument doc = sheet->saveCellRegion(region);
1676 // Save to buffer
1677 TQString buffer;
1678 TQTextStream str( &buffer, IO_WriteOnly );
1679 str << doc;
1680
1681 cells = buffer.utf8();
1682 int len = cells.length();
1683 char tmp = cells[ len - 1 ];
1684 cells.resize( len );
1685 *( cells.data() + len - 1 ) = tmp;
1686}
1687
1688void UndoDragDrop::undo()
1689{
1690 Sheet * sheet = doc()->map()->findSheet( m_sheetName );
1691 if ( !sheet )
1692 return;
1693
1694 saveCellRect( m_dataRedoSource, sheet, m_selectionSource );
1695 saveCellRect( m_dataRedoTarget, sheet, m_selectionTarget );
1696
1697 doc()->undoLock();
1698 doc()->emitBeginOperation();
1699
1700 sheet->deleteCells( m_selectionTarget );
1701 sheet->paste( m_dataTarget, m_selectionTarget.boundingRect() );
1702
1703 sheet->deleteCells( m_selectionSource );
1704 sheet->paste( m_dataSource, m_selectionSource.boundingRect() );
1705
1706 sheet->updateView();
1707
1708 if ( sheet->getAutoCalc() )
1709 sheet->recalc();
1710
1711 doc()->undoUnlock();
1712}
1713
1714void UndoDragDrop::redo()
1715{
1716 Sheet * sheet = doc()->map()->findSheet( m_sheetName );
1717 if ( !sheet )
1718 return;
1719
1720 doc()->undoLock();
1721 doc()->emitBeginOperation();
1722
1723 //move next line to refreshView
1724 //because I must know what is the real rect
1725 //that I must refresh, when there is cell Merged
1726
1727 sheet->deleteCells( m_selectionTarget );
1728 sheet->paste( m_dataRedoTarget, m_selectionTarget.boundingRect() );
1729 sheet->deleteCells( m_selectionSource );
1730 sheet->paste( m_dataRedoSource, m_selectionSource.boundingRect() );
1731
1732 sheet->updateView();
1733 if ( sheet->getAutoCalc() )
1734 sheet->recalc();
1735
1736 doc()->undoUnlock();
1737}
1738
1739
1740/****************************************************************************
1741 *
1742 * UndoResizeColRow
1743 *
1744 ***************************************************************************/
1745
1746
1747UndoResizeColRow::UndoResizeColRow( Doc *_doc, Sheet *_sheet, const Region &_selection ) :
1748 UndoAction( _doc )
1749{
1750 name=i18n("Resize");
1751 m_region = _selection;
1752 m_sheetName = _sheet->sheetName();
1753
1754 createList( m_lstColumn,m_lstRow, _sheet );
1755}
1756
1757void UndoResizeColRow::createList( TQValueList<columnSize> &listCol,TQValueList<rowSize> &listRow, Sheet* sheet )
1758{
1759 listCol.clear();
1760 listRow.clear();
1761 Region::ConstIterator endOfList(m_region.constEnd());
1762 for (Region::ConstIterator it = m_region.constBegin(); it != endOfList; ++it)
1763 {
1764 TQRect m_rctRect = (*it)->rect().normalize();
1765
1766 if( util_isColumnSelected( m_rctRect ) ) // entire column(s)
1767 {
1768 for( int y = m_rctRect.left(); y <= m_rctRect.right(); y++ )
1769 {
1770 ColumnFormat *cl=sheet->columnFormat(y);
1771 if(!cl->isHide())
1772 {
1773 columnSize tmpSize;
1774 tmpSize.columnNumber=y;
1775 tmpSize.columnWidth=cl->dblWidth();
1776 listCol.append(tmpSize);
1777 }
1778 }
1779 }
1780 else if( util_isRowSelected( m_rctRect ) ) // entire row(s)
1781 {
1782 for( int y = m_rctRect.top(); y <= m_rctRect.bottom(); y++ )
1783 {
1784 RowFormat *rw=sheet->rowFormat(y);
1785 if(!rw->isHide())
1786 {
1787 rowSize tmpSize;
1788 tmpSize.rowNumber=y;
1789 tmpSize.rowHeight=rw->dblHeight();
1790 listRow.append(tmpSize);
1791 }
1792 }
1793 }
1794 else //row and column
1795 {
1796 for( int y = m_rctRect.left(); y <= m_rctRect.right(); y++ )
1797 {
1798 ColumnFormat *cl=sheet->columnFormat(y);
1799 if(!cl->isHide())
1800 {
1801 columnSize tmpSize;
1802 tmpSize.columnNumber=y;
1803 tmpSize.columnWidth=cl->dblWidth();
1804 listCol.append(tmpSize);
1805 }
1806 }
1807 for( int y = m_rctRect.top(); y <= m_rctRect.bottom(); y++ )
1808 {
1809 RowFormat *rw=sheet->rowFormat(y);
1810 if(!rw->isHide())
1811 {
1812 rowSize tmpSize;
1813 tmpSize.rowNumber=y;
1814 tmpSize.rowHeight=rw->dblHeight();
1815 listRow.append(tmpSize);
1816 }
1817 }
1818
1819 }
1820 }
1821}
1822
1823UndoResizeColRow::~UndoResizeColRow()
1824{
1825}
1826
1827void UndoResizeColRow::undo()
1828{
1829 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
1830 if ( !sheet )
1831 return;
1832
1833 doc()->undoLock();
1834
1835 createList( m_lstRedoColumn,m_lstRedoRow, sheet );
1836
1837 Region::ConstIterator endOfList(m_region.constEnd());
1838 for (Region::ConstIterator it = m_region.constBegin(); it != endOfList; ++it)
1839 {
1840 TQRect m_rctRect = (*it)->rect().normalize();
1841
1842 if( util_isColumnSelected( m_rctRect ) ) // complete column(s)
1843 {
1844 TQValueList<columnSize>::Iterator it2;
1845 for ( it2 = m_lstColumn.begin(); it2 != m_lstColumn.end(); ++it2 )
1846 {
1847 ColumnFormat *cl=sheet->columnFormat((*it2).columnNumber);
1848 cl->setDblWidth((*it2).columnWidth);
1849 }
1850 }
1851 else if( util_isRowSelected( m_rctRect ) ) // complete row(s)
1852 {
1853 TQValueList<rowSize>::Iterator it2;
1854 for ( it2 = m_lstRow.begin(); it2 != m_lstRow.end(); ++it2 )
1855 {
1856 RowFormat *rw=sheet->rowFormat((*it2).rowNumber);
1857 rw->setDblHeight((*it2).rowHeight);
1858 }
1859 }
1860 else // row and column
1861 {
1862 TQValueList<columnSize>::Iterator it2;
1863 for ( it2 = m_lstColumn.begin(); it2 != m_lstColumn.end(); ++it2 )
1864 {
1865 ColumnFormat *cl=sheet->columnFormat((*it2).columnNumber);
1866 cl->setDblWidth((*it2).columnWidth);
1867 }
1868 TQValueList<rowSize>::Iterator it1;
1869 for ( it1 = m_lstRow.begin(); it1 != m_lstRow.end(); ++it1 )
1870 {
1871 RowFormat *rw=sheet->rowFormat((*it1).rowNumber);
1872 rw->setDblHeight((*it1).rowHeight);
1873 }
1874 }
1875 }
1876
1877 doc()->undoUnlock();
1878}
1879
1880void UndoResizeColRow::redo()
1881{
1882 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
1883 if ( !sheet )
1884 return;
1885
1886 doc()->undoLock();
1887
1888 Region::ConstIterator endOfList(m_region.constEnd());
1889 for (Region::ConstIterator it = m_region.constBegin(); it != endOfList; ++it)
1890 {
1891 TQRect m_rctRect = (*it)->rect().normalize();
1892
1893 if( util_isColumnSelected( m_rctRect ) ) // complete column(s)
1894 {
1895 TQValueList<columnSize>::Iterator it2;
1896 for ( it2 = m_lstRedoColumn.begin(); it2 != m_lstRedoColumn.end(); ++it2 )
1897 {
1898 ColumnFormat *cl=sheet->columnFormat((*it2).columnNumber);
1899 cl->setDblWidth((*it2).columnWidth);
1900 }
1901 }
1902 else if( util_isRowSelected( m_rctRect ) ) // complete row(s)
1903 {
1904 TQValueList<rowSize>::Iterator it2;
1905 for ( it2 = m_lstRedoRow.begin(); it2 != m_lstRedoRow.end(); ++it2 )
1906 {
1907 RowFormat *rw=sheet->rowFormat((*it2).rowNumber);
1908 rw->setDblHeight((*it2).rowHeight);
1909 }
1910 }
1911 else // row and column
1912 {
1913 TQValueList<columnSize>::Iterator it2;
1914 for ( it2 = m_lstRedoColumn.begin(); it2 != m_lstRedoColumn.end(); ++it2 )
1915 {
1916 ColumnFormat *cl=sheet->columnFormat((*it2).columnNumber);
1917 cl->setDblWidth((*it2).columnWidth);
1918 }
1919 TQValueList<rowSize>::Iterator it1;
1920 for ( it1 = m_lstRedoRow.begin(); it1 != m_lstRedoRow.end(); ++it1 )
1921 {
1922 RowFormat *rw=sheet->rowFormat((*it1).rowNumber);
1923 rw->setDblHeight((*it1).rowHeight);
1924 }
1925 }
1926 }
1927
1928 doc()->undoUnlock();
1929}
1930
1931/****************************************************************************
1932 *
1933 * UndoChangeAreaTextCell
1934 *
1935 ***************************************************************************/
1936
1937
1938UndoChangeAreaTextCell::UndoChangeAreaTextCell( Doc *_doc, Sheet *_sheet, const Region &_selection ) :
1939 UndoAction( _doc )
1940{
1941 name=i18n("Change Text");
1942
1943 m_region = _selection;
1944 m_sheetName = _sheet->sheetName();
1945
1946 createList( m_lstTextCell, _sheet );
1947}
1948
1949void UndoChangeAreaTextCell::createList( TQMap<TQPoint,TQString> &map, Sheet* sheet )
1950{
1951 map.clear();
1952
1953 Region::ConstIterator endOfList(m_region.constEnd());
1954 for (Region::ConstIterator it = m_region.constBegin(); it != endOfList; ++it)
1955 {
1956 TQRect m_rctRect = (*it)->rect().normalize();
1957 int bottom = m_rctRect.bottom();
1958 int right = m_rctRect.right();
1959
1960 if( util_isColumnSelected( m_rctRect ) )
1961 {
1962 Cell * c;
1963 for ( int col = m_rctRect.left(); col <= right; ++col )
1964 {
1965 c = sheet->getFirstCellColumn( col );
1966 while ( c )
1967 {
1968 if ( !c->isPartOfMerged() )
1969 {
1970 //textOfCell tmpText;
1971 //tmpText.col = col;
1972 //tmpText.row = c->row();
1973 //tmpText.text = c->text();
1974 map.insert( TQPoint(col,c->row()) , c->text() );
1975 }
1976 c = sheet->getNextCellDown( col, c->row() );
1977 }
1978 }
1979 }
1980 else if ( util_isRowSelected( m_rctRect ) )
1981 {
1982 Cell * c;
1983 for ( int row = m_rctRect.top(); row <= bottom; ++row )
1984 {
1985 c = sheet->getFirstCellRow( row );
1986 while ( c )
1987 {
1988 if ( !c->isPartOfMerged() )
1989 {
1990 //textOfCell tmpText;
1991 //tmpText.col = c->column();
1992 //tmpText.row = row;
1993 //tmpText.text = c->text();
1994 map.insert( TQPoint(c->column(),row) , c->text() );
1995 }
1996 c = sheet->getNextCellRight( c->column(), row );
1997 }
1998 }
1999 }
2000 else
2001 {
2002 Cell * cell;
2003 for ( int x = m_rctRect.left(); x <= right; ++x )
2004 {
2005 cell = sheet->getFirstCellColumn( x );
2006 if ( !cell )
2007 continue;
2008 while ( cell && cell->row() <= bottom )
2009 {
2010 if ( !cell->isObscured() )
2011 {
2012 //textOfCell tmpText;
2013 //tmpText.col = x;
2014 //tmpText.row = cell->row();
2015 //tmpText.text = cell->text();
2016 map.insert( TQPoint(x,cell->row()) , cell->text());
2017 }
2018 cell = sheet->getNextCellDown( x, cell->row() );
2019 }
2020 }
2021 }
2022 }
2023}
2024
2025UndoChangeAreaTextCell::~UndoChangeAreaTextCell()
2026{
2027}
2028
2029void UndoChangeAreaTextCell::undo()
2030{
2031 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2032 if ( !sheet )
2033 return;
2034
2035 doc()->undoLock();
2036 doc()->emitBeginOperation();
2037 sheet->setRegionPaintDirty(m_region);
2038
2039 kdDebug() << "creating redo list..." << endl;
2040 createList( m_lstRedoTextCell, sheet );
2041 kdDebug() << "created redo list..." << endl;
2042
2043 Region::ConstIterator endOfList(m_region.constEnd());
2044 for (Region::ConstIterator it = m_region.constBegin(); it != endOfList; ++it)
2045 {
2046 TQRect m_rctRect = (*it)->rect().normalize();
2047
2048 if ( !util_isRowSelected( m_rctRect )
2049 && !util_isColumnSelected( m_rctRect ) )
2050 {
2051 for ( int x = m_rctRect.left(); x <= m_rctRect.right(); ++x )
2052 for ( int y = m_rctRect.top(); y <= m_rctRect.bottom(); ++y )
2053 {
2054 Cell* cell = sheet->nonDefaultCell( x, y );
2055
2056 const TQPoint location(x,y);
2057
2058 if ( m_lstTextCell.contains(location) )
2059 cell->setCellText( m_lstTextCell[location] );
2060 else
2061 cell->setCellText( "",true );
2062
2063 /*bool found = false;
2064 TQValueList<textOfCell>::Iterator it;
2065 for( it = m_lstTextCell.begin(); it != m_lstTextCell.end(); ++it )
2066 if ( (*it).col == x && (*it).row == y && !found )
2067 {
2068 cell->setCellText( (*it).text );
2069 found = true;
2070 }
2071 if( !found )
2072 cell->setCellText( "", true );*/
2073 }
2074
2075 }
2076 else
2077 {
2078 TQMap<TQPoint,TQString>::Iterator it2;
2079 for ( it2 = m_lstTextCell.begin(); it2 != m_lstTextCell.end(); ++it2 )
2080 {
2081 Cell *cell = sheet->nonDefaultCell( it2.key().x(), it2.key().y() );
2082 if ( it2.data().isEmpty() )
2083 {
2084 if ( !cell->text().isEmpty() )
2085 cell->setCellText( "" );
2086 }
2087 else
2088 cell->setCellText( it2.data() );
2089 }
2090 }
2091 }
2092
2093 //sheet->updateView();
2094 doc()->emitEndOperation();
2095 doc()->undoUnlock();
2096}
2097
2098void UndoChangeAreaTextCell::redo()
2099{
2100 Sheet * sheet = doc()->map()->findSheet( m_sheetName );
2101
2102 if ( !sheet )
2103 return;
2104
2105 doc()->undoLock();
2106 doc()->emitBeginOperation();
2107 sheet->setRegionPaintDirty(m_region);
2108
2109 Region::ConstIterator endOfList(m_region.constEnd());
2110 for (Region::ConstIterator it = m_region.constBegin(); it != endOfList; ++it)
2111 {
2112 TQRect m_rctRect = (*it)->rect().normalize();
2113
2114 if ( !util_isRowSelected( m_rctRect )
2115 && !util_isColumnSelected( m_rctRect ) )
2116 {
2117 for ( int x = m_rctRect.left(); x <= m_rctRect.right(); ++x )
2118 for ( int y = m_rctRect.top(); y <= m_rctRect.bottom(); ++y )
2119 {
2120 Cell* cell = sheet->nonDefaultCell( x, y );
2121
2122 const TQPoint location(x,y);
2123
2124 if (m_lstRedoTextCell.contains(location))
2125 cell->setCellText( m_lstRedoTextCell[location] );
2126 else
2127 cell->setCellText( "" , true );
2128 /*bool found = false;
2129 TQValueList<textOfCell>::Iterator it;
2130 for( it = m_lstRedoTextCell.begin(); it != m_lstRedoTextCell.end(); ++it )
2131 if ( (*it).col == x && (*it).row == y && !found )
2132 {
2133 cell->setCellText( (*it).text );
2134 found = true;
2135 }
2136 if( !found )
2137 cell->setCellText( "", true );*/
2138 }
2139
2140 }
2141 else
2142 {
2143 TQMap<TQPoint,TQString>::Iterator it2;
2144 for ( it2 = m_lstRedoTextCell.begin(); it2 != m_lstRedoTextCell.end(); ++it2 )
2145 {
2146 Cell *cell = sheet->nonDefaultCell( it2.key().x(), it2.key().y() );
2147 if ( it2.data().isEmpty() )
2148 {
2149 if ( !cell->text().isEmpty() )
2150 cell->setCellText( "" );
2151 }
2152 else
2153 cell->setCellText( it2.data() );
2154 }
2155 }
2156 }
2157
2158 //sheet->updateView();
2159 doc()->emitEndOperation();
2160 doc()->undoUnlock();
2161}
2162
2163/****************************************************************************
2164 *
2165 * UndoMergedCell
2166 *
2167 ***************************************************************************/
2168
2169
2170UndoMergedCell::UndoMergedCell( Doc *_doc, Sheet *_sheet, int _column, int _row , int _extraX,int _extraY) :
2171 UndoAction( _doc )
2172{
2173 name=i18n("Merge Cells");
2174
2175 m_sheetName = _sheet->sheetName();
2176 m_iRow=_row;
2177 m_iCol=_column;
2178 m_iExtraX=_extraX;
2179 m_iExtraY=_extraY;
2180
2181}
2182
2183UndoMergedCell::~UndoMergedCell()
2184{
2185}
2186
2187void UndoMergedCell::undo()
2188{
2189 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2190 if ( !sheet )
2191 return;
2192
2193 doc()->undoLock();
2194
2195 Cell *cell = sheet->nonDefaultCell( m_iCol, m_iRow );
2196 m_iExtraRedoX=cell->extraXCells();
2197 m_iExtraRedoY=cell->extraYCells();
2198
2199 sheet->changeMergedCell( m_iCol, m_iRow, m_iExtraX,m_iExtraY);
2200
2201 doc()->undoUnlock();
2202}
2203
2204void UndoMergedCell::redo()
2205{
2206 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2207 if ( !sheet )
2208 return;
2209
2210 doc()->undoLock();
2211
2212 sheet->changeMergedCell( m_iCol, m_iRow, m_iExtraRedoX,m_iExtraRedoY);
2213
2214 doc()->undoUnlock();
2215}
2216
2217/****************************************************************************
2218 *
2219 * UndoAutofill
2220 *
2221 ***************************************************************************/
2222
2223UndoAutofill::UndoAutofill( Doc *_doc, Sheet* sheet, const TQRect & _selection)
2224 : UndoAction( _doc )
2225{
2226 name=i18n("Autofill");
2227
2228 m_sheetName = sheet->sheetName();
2229 m_selection = _selection;
2230 createListCell( m_data, sheet );
2231
2232}
2233
2234UndoAutofill::~UndoAutofill()
2235{
2236}
2237
2238void UndoAutofill::createListCell( TQCString &list, Sheet* sheet )
2239{
2240 TQDomDocument doc = sheet->saveCellRegion( m_selection );
2241 // Save to buffer
2242 TQString buffer;
2243 TQTextStream str( &buffer, IO_WriteOnly );
2244 str << doc;
2245
2246 // This is a terrible hack to store unicode
2247 // data in a TQCString in a way that
2248 // TQCString::length() == TQCString().size().
2249 // This allows us to treat the TQCString like a TQByteArray later on.
2250 list = buffer.utf8();
2251 int len = list.length();
2252 char tmp = list[ len - 1 ];
2253 list.resize( len );
2254 *( list.data() + len - 1 ) = tmp;
2255}
2256
2257void UndoAutofill::undo()
2258{
2259 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2260 if ( !sheet )
2261 return;
2262
2263 createListCell( m_dataRedo, sheet );
2264
2265 doc()->undoLock();
2266 doc()->emitBeginOperation();
2267
2268 sheet->deleteCells( m_selection );
2269 sheet->paste( m_data, m_selection );
2270 //if(sheet->getAutoCalc()) sheet->recalc();
2271
2272 doc()->emitEndOperation();
2273 //sheet->updateView();
2274
2275 doc()->undoUnlock();
2276}
2277
2278void UndoAutofill::redo()
2279{
2280 doc()->undoLock();
2281
2282 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2283 if ( !sheet )
2284 return;
2285
2286 doc()->emitBeginOperation();
2287
2288 sheet->deleteCells( m_selection );
2289 doc()->undoLock();
2290 sheet->paste( m_dataRedo, m_selection );
2291 if ( sheet->getAutoCalc() )
2292 sheet->recalc();
2293 sheet->updateView();
2294 doc()->undoUnlock();
2295}
2296
2297/****************************************************************************
2298 *
2299 * UndoInsertCellRow
2300 *
2301 ***************************************************************************/
2302
2303UndoInsertCellRow::UndoInsertCellRow( Doc *_doc, Sheet *_sheet, const TQRect &_rect ) :
2304 UndoInsertRemoveAction( _doc )
2305{
2306 name=i18n("Insert Cell");
2307
2308 m_sheetName = _sheet->sheetName();
2309 m_rect=_rect;
2310}
2311
2312UndoInsertCellRow::~UndoInsertCellRow()
2313{
2314}
2315
2316void UndoInsertCellRow::undo()
2317{
2318 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2319 if ( !sheet )
2320 return;
2321
2322 doc()->undoLock();
2323 sheet->unshiftRow( m_rect);
2324 doc()->undoUnlock();
2325
2326 undoFormulaReference();
2327}
2328
2329void UndoInsertCellRow::redo()
2330{
2331 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2332 if ( !sheet )
2333 return;
2334
2335 doc()->undoLock();
2336 sheet->shiftRow( m_rect);
2337 doc()->undoUnlock();
2338}
2339
2340/****************************************************************************
2341 *
2342 * UndoInsertCellCol
2343 *
2344 ***************************************************************************/
2345
2346
2347UndoInsertCellCol::UndoInsertCellCol( Doc *_doc, Sheet *_sheet, const TQRect &_rect ) :
2348 UndoInsertRemoveAction( _doc )
2349{
2350 name=i18n("Insert Cell");
2351
2352 m_sheetName = _sheet->sheetName();
2353 m_rect=_rect;
2354}
2355
2356UndoInsertCellCol::~UndoInsertCellCol()
2357{
2358}
2359
2360void UndoInsertCellCol::undo()
2361{
2362 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2363 if ( !sheet )
2364 return;
2365
2366 doc()->undoLock();
2367 sheet->unshiftColumn( m_rect);
2368 doc()->undoUnlock();
2369
2370 undoFormulaReference();
2371}
2372
2373void UndoInsertCellCol::redo()
2374{
2375 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2376 if ( !sheet )
2377 return;
2378
2379 doc()->undoLock();
2380 sheet->shiftColumn( m_rect );
2381 doc()->undoUnlock();
2382}
2383
2384/****************************************************************************
2385 *
2386 * UndoRemoveCellRow
2387 *
2388 ***************************************************************************/
2389
2390UndoRemoveCellRow::UndoRemoveCellRow( Doc *_doc, Sheet *_sheet, const TQRect &rect ) :
2391 UndoInsertRemoveAction( _doc )
2392{
2393 name=i18n("Remove Cell");
2394
2395 m_sheetName = _sheet->sheetName();
2396 m_rect=rect;
2397 TQDomDocument doc = _sheet->saveCellRegion( m_rect );
2398 // Save to buffer
2399 TQString buffer;
2400 TQTextStream str( &buffer, IO_WriteOnly );
2401 str << doc;
2402
2403 // This is a terrible hack to store unicode
2404 // data in a TQCString in a way that
2405 // TQCString::length() == TQCString().size().
2406 // This allows us to treat the TQCString like a TQByteArray later on.
2407 m_data = buffer.utf8();
2408 int len = m_data.length();
2409 char tmp = m_data[ len - 1 ];
2410 m_data.resize( len );
2411 *( m_data.data() + len - 1 ) = tmp;
2412}
2413
2414UndoRemoveCellRow::~UndoRemoveCellRow()
2415{
2416}
2417
2418void UndoRemoveCellRow::undo()
2419{
2420 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2421 if ( !sheet )
2422 return;
2423
2424 doc()->undoLock();
2425 sheet->shiftRow( m_rect );
2426 sheet->paste( m_data, m_rect );
2427 doc()->undoUnlock();
2428
2429 undoFormulaReference();
2430}
2431
2432void UndoRemoveCellRow::redo()
2433{
2434 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2435 if ( !sheet )
2436 return;
2437
2438 doc()->undoLock();
2439 sheet->unshiftRow( m_rect);
2440 doc()->undoUnlock();
2441}
2442
2443/****************************************************************************
2444 *
2445 * UndoRemoveCellCol
2446 *
2447 ***************************************************************************/
2448
2449UndoRemoveCellCol::UndoRemoveCellCol( Doc *_doc, Sheet *_sheet, const TQRect &_rect ) :
2450 UndoInsertRemoveAction( _doc )
2451{
2452 name=i18n("Remove Cell");
2453
2454 m_sheetName = _sheet->sheetName();
2455 m_rect=_rect;
2456 TQDomDocument doc = _sheet->saveCellRegion( m_rect );
2457 // Save to buffer
2458 TQString buffer;
2459 TQTextStream str( &buffer, IO_WriteOnly );
2460 str << doc;
2461
2462 // This is a terrible hack to store unicode
2463 // data in a TQCString in a way that
2464 // TQCString::length() == TQCString().size().
2465 // This allows us to treat the TQCString like a TQByteArray later on.
2466 m_data = buffer.utf8();
2467 int len = m_data.length();
2468 char tmp = m_data[ len - 1 ];
2469 m_data.resize( len );
2470 *( m_data.data() + len - 1 ) = tmp;
2471}
2472
2473UndoRemoveCellCol::~UndoRemoveCellCol()
2474{
2475}
2476
2477void UndoRemoveCellCol::undo()
2478{
2479 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2480 if ( !sheet )
2481 return;
2482
2483 doc()->undoLock();
2484 sheet->shiftColumn( m_rect );
2485 sheet->paste( m_data, m_rect );
2486 doc()->undoUnlock();
2487
2488 undoFormulaReference();
2489}
2490
2491void UndoRemoveCellCol::redo()
2492{
2493 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2494 if ( !sheet )
2495 return;
2496
2497 doc()->undoLock();
2498 sheet->unshiftColumn( m_rect );
2499 doc()->undoUnlock();
2500}
2501
2502/****************************************************************************
2503 *
2504 * UndoConditional
2505 *
2506 ***************************************************************************/
2507
2508UndoConditional::UndoConditional( Doc *_doc, Sheet* sheet, const Region & _selection)
2509 : UndoAction( _doc )
2510{
2511 name=i18n("Conditional Cell Attribute");
2512
2513 m_sheetName = sheet->sheetName();
2514 m_region = _selection;
2515 createListCell( m_data, sheet );
2516
2517}
2518
2519UndoConditional::~UndoConditional()
2520{
2521}
2522
2523void UndoConditional::createListCell( TQCString &list, Sheet* sheet )
2524{
2525 // Save to buffer
2526 TQString buffer;
2527 TQTextStream str( &buffer, IO_WriteOnly );
2528
2529 TQDomDocument doc = sheet->saveCellRegion( m_region );
2530 str << doc;
2531
2532 // This is a terrible hack to store unicode
2533 // data in a TQCString in a way that
2534 // TQCString::length() == TQCString().size().
2535 // This allows us to treat the TQCString like a TQByteArray later on.
2536 list = buffer.utf8();
2537 int len = list.length();
2538 char tmp = list[ len - 1 ];
2539 list.resize( len );
2540 *( list.data() + len - 1 ) = tmp;
2541}
2542
2543void UndoConditional::undo()
2544{
2545 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2546 if ( !sheet )
2547 return;
2548
2549 createListCell( m_dataRedo, sheet );
2550
2551 doc()->undoLock();
2552 sheet->paste(m_data, m_region.boundingRect());
2553 if (sheet->getAutoCalc())
2554 {
2555 sheet->recalc();
2556 }
2557
2558 doc()->undoUnlock();
2559}
2560
2561void UndoConditional::redo()
2562{
2563 doc()->undoLock();
2564
2565 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2566 if ( !sheet )
2567 return;
2568
2569 doc()->undoLock();
2570 sheet->paste(m_dataRedo, m_region.boundingRect());
2571 if (sheet->getAutoCalc())
2572 {
2573 sheet->recalc();
2574 }
2575
2576 doc()->undoUnlock();
2577}
2578
2579
2580/****************************************************************************
2581 *
2582 * UndoCellPaste
2583 *
2584 ***************************************************************************/
2585
2586UndoCellPaste::UndoCellPaste(Doc *_doc, Sheet* sheet,
2587 int _xshift, int _yshift,
2588 const Region& region, bool insert, int _insertTo)
2589 : UndoAction( _doc )
2590{
2591 if(!insert)
2592 name=i18n("Paste");
2593 else
2594 name=i18n("Paste & Insert");
2595
2596 m_sheetName = sheet->sheetName();
2597 m_region = region;
2598 xshift=_xshift;
2599 yshift=_yshift;
2600 b_insert=insert;
2601 m_iInsertTo=_insertTo;
2602 if( !b_insert)
2603 createListCell( m_data, m_lstColumn,m_lstRow,sheet );
2604
2605}
2606
2607UndoCellPaste::~UndoCellPaste()
2608{
2609}
2610
2611void UndoCellPaste::createListCell(TQCString& listCell,
2612 TQValueList<columnSize>& listCol,
2613 TQValueList<rowSize>& listRow,
2614 Sheet* sheet)
2615{
2616 listCol.clear();
2617 listRow.clear();
2618
2619 Region::ConstIterator endOfList = m_region.constEnd();
2620 for (Region::ConstIterator it = m_region.constBegin(); it != endOfList; ++it)
2621 {
2622 int nbCol = 0;
2623 int nbRow = 0;
2624 TQRect range = (*it)->rect().normalize();
2625 if ((*it)->isColumn())
2626 {
2627 nbCol = range.width();
2628 }
2629 else if ((*it)->isRow())
2630 {
2631 nbRow = range.height();
2632 }
2633
2634 // copy column(s)
2635 if (nbCol != 0)
2636 {
2637 //save size of columns
2638 for( int y = 1; y <=nbCol ; ++y )
2639 {
2640 ColumnFormat *cl=sheet->columnFormat(y);
2641 if(!cl->isDefault())
2642 {
2643 columnSize tmpSize;
2644 tmpSize.columnNumber=y;
2645 tmpSize.columnWidth=cl->dblWidth();
2646 listCol.append(tmpSize);
2647 }
2648 }
2649 }
2650 //copy a row(s)
2651 else if (nbRow != 0)
2652 {
2653 //save size of columns
2654 for ( int y = 1; y <=nbRow ; ++y )
2655 {
2656 RowFormat *rw=sheet->rowFormat(y);
2657 if (!rw->isDefault())
2658 {
2659 rowSize tmpSize;
2660 tmpSize.rowNumber=y;
2661 tmpSize.rowHeight=rw->dblHeight();
2662 listRow.append(tmpSize);
2663 }
2664 }
2665 }
2666 }
2667 //save all cells in area
2668 TQDomDocument doc = sheet->saveCellRegion(m_region);
2669 // Save to buffer
2670 TQString buffer;
2671 TQTextStream str( &buffer, IO_WriteOnly );
2672 str << doc;
2673
2674 // This is a terrible hack to store unicode
2675 // data in a TQCString in a way that
2676 // TQCString::length() == TQCString().size().
2677 // This allows us to treat the TQCString like a TQByteArray later on.
2678 listCell = buffer.utf8();
2679 int len = listCell.length();
2680 char tmp = listCell[ len - 1 ];
2681 listCell.resize( len );
2682 *( listCell.data() + len - 1 ) = tmp;
2683}
2684
2685void UndoCellPaste::undo()
2686{
2687 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2688 if ( !sheet )
2689 return;
2690
2691 createListCell( m_dataRedo, m_lstRedoColumn, m_lstRedoRow, sheet );
2692
2693 doc()->undoLock();
2694 doc()->emitBeginOperation();
2695
2696 uint numCols = 0;
2697 uint numRows = 0;
2698
2699 Region::ConstIterator endOfList = m_region.constEnd();
2700 for (Region::ConstIterator it = --m_region.constEnd(); it != endOfList; --it)
2701 {
2702 TQRect range = (*it)->rect().normalize();
2703
2704 if ((*it)->isColumn())
2705 {
2706 if (!b_insert)
2707 {
2708 TQValueList<columnSize>::Iterator it2;
2709 for ( it2 = m_lstColumn.begin(); it2 != m_lstColumn.end(); ++it2 )
2710 {
2711 ColumnFormat *cl=sheet->nonDefaultColumnFormat((*it2).columnNumber);
2712 cl->setDblWidth((*it2).columnWidth);
2713 }
2714 }
2715 else
2716 {
2717 numCols += range.width();
2718 }
2719 }
2720 else if ((*it)->isRow())
2721 {
2722 if (!b_insert)
2723 {
2724 TQValueList<rowSize>::Iterator it2;
2725 for ( it2 = m_lstRow.begin(); it2 != m_lstRow.end(); ++it2 )
2726 {
2727 RowFormat *rw=sheet->nonDefaultRowFormat((*it2).rowNumber);
2728 rw->setDblHeight((*it2).rowHeight);
2729 }
2730 }
2731 else
2732 {
2733 numRows += range.height();
2734 }
2735 }
2736
2737 if (!b_insert)
2738 {
2739 sheet->deleteCells(range);
2740 }
2741 } // for (Region::...
2742
2743 if (b_insert) // with insertion
2744 {
2745 TQRect rect = m_region.boundingRect();
2746 if (m_iInsertTo == -1 && numCols == 0 && numRows == 0)
2747 {
2748 // substract already removed columns
2749 rect.setWidth(rect.width());
2750 sheet->unshiftRow(rect);
2751 }
2752 else if (m_iInsertTo == 1 && numCols == 0 && numRows == 0)
2753 {
2754 // substract already removed rows
2755 rect.setHeight(rect.height());
2756 sheet->unshiftColumn(rect);
2757 }
2758 // delete columns
2759 else if (m_iInsertTo == 0 && numCols == 0 && numRows > 0)
2760 {
2761 sheet->removeRow(rect.top(), rect.height() - 1, false);
2762 }
2763 // delete rows
2764 else if (m_iInsertTo == 0 && numCols > 0 && numRows == 0)
2765 {
2766 sheet->removeColumn(rect.left(), rect.width() - 1, false);
2767 }
2768 }
2769 else // without insertion
2770 {
2771 sheet->paste(m_data, m_region.boundingRect());
2772 }
2773
2774 if (sheet->getAutoCalc())
2775 {
2776 sheet->recalc();
2777 }
2778 sheet->updateView();
2779 doc()->undoUnlock();
2780}
2781
2782void UndoCellPaste::redo()
2783{
2784 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2785 if ( !sheet )
2786 return;
2787
2788 doc()->undoLock();
2789 doc()->emitBeginOperation();
2790
2791 uint numCols = 0;
2792 uint numRows = 0;
2793
2794 Region::ConstIterator endOfList(m_region.constEnd());
2795 for (Region::ConstIterator it = m_region.constBegin(); it != endOfList; ++it)
2796 {
2797 TQRect range = (*it)->rect().normalize();
2798
2799 if ((*it)->isColumn())
2800 {
2801 numCols += range.width();
2802 }
2803 else if ((*it)->isRow())
2804 {
2805 numRows += range.height();
2806 }
2807 else
2808 {
2809 if (!b_insert)
2810 {
2811 sheet->deleteCells( range );
2812 }
2813 }
2814 } // for (Region::...
2815
2816 if (b_insert)
2817 {
2818 TQRect rect = m_region.boundingRect();
2819 if (m_iInsertTo == -1 && numCols == 0 && numRows == 0)
2820 {
2821 rect.setWidth(rect.width());
2822 sheet->shiftRow(rect);
2823 }
2824 else if (m_iInsertTo == 1 && numCols == 0 && numRows == 0)
2825 {
2826 rect.setHeight(rect.height());
2827 sheet->shiftColumn(rect);
2828 }
2829 // insert columns
2830 else if (m_iInsertTo == 0 && numCols == 0 && numRows > 0)
2831 {
2832 sheet->insertRow(rect.top(), rect.height() - 1, false);
2833 }
2834 // insert rows
2835 else if (m_iInsertTo == 0 && numCols > 0 && numRows == 0)
2836 {
2837 sheet->insertColumn(rect.left(), rect.width() - 1, false);
2838 }
2839 }
2840
2841 for (Region::ConstIterator it = m_region.constBegin(); it != endOfList; ++it)
2842 {
2843 if ((*it)->isColumn())
2844 {
2845 TQValueList<columnSize>::Iterator it2;
2846 for ( it2 = m_lstRedoColumn.begin(); it2 != m_lstRedoColumn.end(); ++it2 )
2847 {
2848 ColumnFormat *cl=sheet->nonDefaultColumnFormat((*it2).columnNumber);
2849 cl->setDblWidth((*it2).columnWidth);
2850 }
2851 }
2852 else if ((*it)->isRow())
2853 {
2854 TQValueList<rowSize>::Iterator it2;
2855 for ( it2 = m_lstRedoRow.begin(); it2 != m_lstRedoRow.end(); ++it2 )
2856 {
2857 RowFormat *rw=sheet->nonDefaultRowFormat((*it2).rowNumber);
2858 rw->setDblHeight((*it2).rowHeight);
2859 }
2860 }
2861 } // for (Region::...
2862
2863 sheet->paste( m_dataRedo, m_region.boundingRect() );
2864
2865 if (sheet->getAutoCalc())
2866 {
2867 sheet->recalc();
2868 }
2869
2870 sheet->updateView();
2871 doc()->undoUnlock();
2872}
2873
2874
2875/****************************************************************************
2876 *
2877 * UndoStyleCell
2878 *
2879 ***************************************************************************/
2880
2881UndoStyleCell::UndoStyleCell( Doc *_doc, Sheet* sheet, const TQRect & _selection)
2882 : UndoAction( _doc )
2883{
2884 name=i18n("Style of Cell");
2885
2886 m_sheetName = sheet->sheetName();
2887 m_selection = _selection;
2888 createListCell( m_lstStyleCell, sheet );
2889
2890}
2891
2892UndoStyleCell::~UndoStyleCell()
2893{
2894}
2895
2896void UndoStyleCell::createListCell( TQValueList<styleCell> &listCell, Sheet* sheet )
2897{
2898 int bottom = m_selection.bottom();
2899 int right = m_selection.right();
2900 if ( util_isColumnSelected( m_selection ) )
2901 {
2902 Cell * c;
2903 for ( int col = m_selection.left(); col <= right; ++ col )
2904 {
2905 c = sheet->getFirstCellColumn( col );
2906 while ( c )
2907 {
2908 if ( !c->isPartOfMerged() )
2909 {
2910 styleCell tmpStyleCell;
2911 tmpStyleCell.row = c->row();
2912 tmpStyleCell.col = col;
2913 listCell.append(tmpStyleCell);
2914 }
2915 c = sheet->getNextCellDown( col, c->row() );
2916 }
2917 }
2918 }
2919 else if ( util_isRowSelected( m_selection ) )
2920 {
2921 Cell * c;
2922 for ( int row = m_selection.top(); row <= bottom; ++row )
2923 {
2924 c = sheet->getFirstCellRow( row );
2925 while ( c )
2926 {
2927 if ( !c->isPartOfMerged() )
2928 {
2929 styleCell tmpStyleCell;
2930 tmpStyleCell.row = row;
2931 tmpStyleCell.col = c->column();
2932 listCell.append(tmpStyleCell);
2933 }
2934 c = sheet->getNextCellRight( c->column(), row );
2935 }
2936 }
2937 }
2938 else
2939 {
2940 Cell * cell;
2941 for ( int i = m_selection.top(); i <= bottom; ++i)
2942 for ( int j = m_selection.left(); j <= right; ++j )
2943 {
2944 cell = sheet->nonDefaultCell( j, i);
2945 styleCell tmpStyleCell;
2946 tmpStyleCell.row = i;
2947 tmpStyleCell.col = j;
2948 listCell.append(tmpStyleCell);
2949 }
2950 }
2951}
2952
2953void UndoStyleCell::undo()
2954{
2955 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2956 if ( !sheet )
2957 return;
2958
2959 createListCell( m_lstRedoStyleCell, sheet );
2960
2961 doc()->undoLock();
2962 doc()->emitBeginOperation();
2963
2964
2965 TQValueList<styleCell>::Iterator it2;
2966 for ( it2 = m_lstStyleCell.begin(); it2 != m_lstStyleCell.end(); ++it2 )
2967 {
2968 sheet->nonDefaultCell( (*it2).col, (*it2).row);
2969 }
2970 sheet->setRegionPaintDirty(m_selection);
2971 sheet->updateView( m_selection );
2972 doc()->undoUnlock();
2973}
2974
2975void UndoStyleCell::redo()
2976{
2977 doc()->undoLock();
2978
2979 Sheet* sheet = doc()->map()->findSheet( m_sheetName );
2980 if ( !sheet )
2981 return;
2982
2983 doc()->undoLock();
2984 doc()->emitBeginOperation();
2985
2986 TQValueList<styleCell>::Iterator it2;
2987 for ( it2 = m_lstRedoStyleCell.begin(); it2 != m_lstRedoStyleCell.end(); ++it2 )
2988 {
2989 sheet->nonDefaultCell( (*it2).col, (*it2).row);
2990 }
2991 sheet->setRegionPaintDirty(m_selection);
2992 sheet->updateView();
2993
2994 doc()->undoUnlock();
2995}
2996
2997UndoInsertData::UndoInsertData( Doc * _doc, Sheet * _sheet, TQRect & _selection )
2998 : UndoChangeAreaTextCell( _doc, _sheet, _selection )
2999{
3000 name = i18n("Insert Data From Database");
3001}
For every cell in the spread sheet there is a Cell object.
void setLayoutDirtyFlag(bool format=false)
Causes the format to be recalculated when the cell is drawn next time.
TQString text() const
Return the text the user entered.
int row() const
Returns the cell's row.
bool isObscured() const
int column() const
Returns the cell's column.
int extraXCells() const
int extraYCells() const
void setCellText(const TQString &_text, bool asString=false)
The high-level method for setting text, when the user inputs it.
Format * format() const
Returns the format object of this cell.
bool isDefault() const
Returns true if this is a default cell (with row and column equal to zero).
bool isPartOfMerged() const
If this cell is part of a merged cell, then the marker may never reside on this cell.
This class holds the data that makes up a spreadsheet.
Definition kspread_doc.h:98
The one for all class for points and ranges.
Definition region.h:44
Abstract base class.
@ Format
Format only.
The KSpread namespace.
Definition commands.h:39