summaryrefslogtreecommitdiffstats
path: root/kword/KWCommand.h
blob: 02d58f9af0397ae871d3c24b5ad903efc319195d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
/* This file is part of the KDE project
   Copyright (C) 2001 David Faure <faure@kde.org>

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

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

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

#ifndef KWORD_COMMAND_H
#define KWORD_COMMAND_H
#include <kcommand.h>
#include <kurl.h>
#include <KoCommandHistory.h>
#include <KoPageLayout.h>
#include <KoRect.h>
#include <KoBorder.h>
#include <KoParagLayout.h>
#include <KoParagCounter.h>
#include "KWFrameStyle.h"
#include <KoTextCommand.h>
#include "KWVariable.h"
#include <KoPoint.h>
#include <KoPictureKey.h>

class KWFrameSet;
class KWTableStyle;
class KWTableTemplate;
class KWTableFrameSet;
class RemovedRow;
class RemovedColumn;
class KWPartFrameSet;
class KWDocument;
class KoCustomVariable;
class KoLinkVariable;
class KWFieldVariable;
class KWTimeVariable;
class KWDateVariable;
class KWPgNumVariable;
class KWFootNoteVariable;

// TODO: change most KNamedCommands into KCommands, removing name arguments
// and implementing name() instead (less memory used).

/**
 * Command created when pasting oasis-formatted text
 */
class KWOasisPasteCommand : public KoTextDocCommand
{
public:
    KWOasisPasteCommand( KoTextDocument *d, int parag, int idx,
                             const QByteArray & data );
    KoTextCursor *execute( KoTextCursor *c );
    KoTextCursor *unexecute( KoTextCursor *c );
protected:
    int m_parag;
    int m_idx;
    QByteArray m_data;
    // filled in by execute(), for unexecute()
    int m_lastParag;
    int m_lastIndex;
    KoParagLayout* m_oldParagLayout;
};

struct ParagBookmark {
    QString m_bookName;
    int m_startParagIndex;
    int m_endParagIndex;
};

class KWTextDeleteCommand : public KoTextDeleteCommand
{
public:
    KWTextDeleteCommand( KoTextDocument *d, int i, int idx, const QMemArray<KoTextStringChar> &str,
                         const CustomItemsMap & customItemsMap,
                         const QValueList<KoParagLayout> & oldParagLayouts );
    KoTextCursor *execute( KoTextCursor *c );
    KoTextCursor *unexecute( KoTextCursor *c );
    void createBookmarkList();
private:
    QValueList<ParagBookmark> m_listParagBookmark;
};


////////////////////////// Frame commands ////////////////////////////////

/// Identifies a frame
struct FrameIndex {
    FrameIndex() {}
    FrameIndex( KWFrame *frame );

    KWFrameSet * m_pFrameSet;
    unsigned int m_iFrameIndex;
};


/**
 * Command created when changing frame border
 */
class KWFrameBorderCommand : public KNamedCommand
{
public:
    //enum FrameBorderType { FBLeft=0, FBRight=1, FBTop=2, FBBottom=3};
    struct FrameBorderTypeStruct {
        KoBorder::BorderType m_EFrameType;
        KoBorder m_OldBorder;
    };

    KWFrameBorderCommand( const QString &name, QPtrList<FrameIndex> &_listFrameIndex, QPtrList<FrameBorderTypeStruct> &_frameTypeBorder,const KoBorder & _newBorder ) ;
    ~ KWFrameBorderCommand();

    void execute();
    void unexecute();

protected:
    QPtrList<FrameIndex> m_indexFrame;
    QPtrList<FrameBorderTypeStruct> m_oldBorderFrameType;
    KoBorder m_newBorder;
};

/**
 * Command created when changing background color of one or more frames
 */
class KWFrameBackGroundColorCommand : public KNamedCommand
{
public:
    KWFrameBackGroundColorCommand( const QString &name, QPtrList<FrameIndex> &_listFrameIndex, QPtrList<QBrush> &_oldBrush, const QBrush & _newColor ) ;
    ~KWFrameBackGroundColorCommand();

    void execute();
    void unexecute();

protected:
    QPtrList<FrameIndex> m_indexFrame;
    QPtrList<QBrush> m_oldBackGroundColor;
    QBrush m_newColor;
};

/**
 * Command created when applying a framestyle
 */
class KWFrameStyleCommand : public KNamedCommand
{
public:
    KWFrameStyleCommand( const QString &name, KWFrame *_frame, KWFrameStyle *_fs, bool _repaintViews = true );
    ~ KWFrameStyleCommand() { if (m_oldValues) delete m_oldValues; }

    void execute();
    void unexecute();

protected:
    void applyFrameStyle( KWFrameStyle * _sty );
    KWFrame *m_frame ;
    KWFrameStyle * m_fs;
    KWFrameStyle * m_oldValues;
    bool repaintViews;
};


/**
 * Command created when applying a tablestyle
 */
class KWTableStyleCommand : public KNamedCommand
{
public:
    KWTableStyleCommand( const QString &name, KWFrame *_frame, KWTableStyle *_ts, bool _repaintViews = true );
    ~ KWTableStyleCommand();

    void execute();
    void unexecute();

protected:
    KWFrame *m_frame ;
    KWTableStyle * m_ts;
    KWFrameStyleCommand * m_fsc;
    KCommand * m_sc;
    bool repaintViews;
};

/**
 * Command created when applying a tabletemplate
 */
class KWTableTemplateCommand : public KNamedCommand
{
public:
    KWTableTemplateCommand( const QString &name, KWTableFrameSet *_table, KWTableTemplate *_tt );
    ~ KWTableTemplateCommand();

    void execute();
    void unexecute();

protected:
    KWTableFrameSet *m_table;
    KWTableTemplate * m_tt;
    KMacroCommand * m_tableCommands;
};

struct FrameResizeStruct {
    // Note that the new "minimum frame height" is always s2.height(),
    // since this is called when the user manually resizes a frame (not when
    // some text changes the size of a frame).
    FrameResizeStruct() { } // default constructor;
    FrameResizeStruct( const KoRect& s1, double min1, const KoRect& s2 )
        : oldRect(s1), oldMinHeight(min1),
          newRect( s2), newMinHeight(s2.height()) {
    }
    KoRect oldRect;
    double oldMinHeight;
    KoRect newRect;
    double newMinHeight;
};

/**
 * Command created when a frame is resized
 * (or "moved and resized" as for KWPartFrameSet)
 */
class KWFrameResizeCommand : public KNamedCommand
{
public:
    KWFrameResizeCommand(const QString &name, const QValueList<FrameIndex> &frameIndex, const QValueList<FrameResizeStruct> &frameResize );
    KWFrameResizeCommand(const QString &name, FrameIndex frameIndex, const FrameResizeStruct &frameResize );
    ~KWFrameResizeCommand() {}

    void execute();
    void unexecute();

protected:
    QValueList<FrameIndex> m_indexFrame;
    QValueList<FrameResizeStruct> m_frameResize;
};

/**
 * Command created when we changed a clipart or picture
 */
class KWFrameChangePictureCommand : public KNamedCommand
{
public:
    KWFrameChangePictureCommand( const QString &name, FrameIndex _frameIndex, const KoPictureKey & _oldFile, const KoPictureKey & _newFile) ;
    ~KWFrameChangePictureCommand() {}

    void execute();
    void unexecute();

protected:
    FrameIndex m_indexFrame;
    KoPictureKey m_oldKey;
    KoPictureKey m_newKey;
};

struct FrameMoveStruct {
    FrameMoveStruct() {} // for QValueList
    FrameMoveStruct( const KoPoint& p1, const KoPoint& p2 )
        : oldPos(p1), newPos(p2) {
    }
    KoPoint oldPos;
    KoPoint newPos;
};

/**
 * Command created when one or more frames are moved
 */
class KWFrameMoveCommand : public KNamedCommand
{
public:
    KWFrameMoveCommand( const QString &name,
                        const QValueList<FrameIndex> & _frameIndex,
                        const QValueList<FrameMoveStruct> & _frameMove );
    ~KWFrameMoveCommand() {}

    void execute();
    void unexecute();
    QValueList<FrameMoveStruct> & listFrameMoved() { return m_frameMove; }
protected:
    QValueList<FrameIndex> m_indexFrame;
    QValueList<FrameMoveStruct> m_frameMove;
};

/**
 * Command created when the properties of a frame are changed
 * (e.g. using frame dialog).
 * In the long run, KWFrameBackGroundColorCommand, KWFrameBorderCommand etc.
 * could be removed and KWFramePropertiesCommand could be used instead.
 * #### This solution is memory eating though, since all settings of the frame
 * are copied. TODO: evaluate using graphite's GenericCommand instead.
 */
class KWFramePropertiesCommand : public KNamedCommand
{
public:
    /** A copy of frameAfter is done internally.
     * But make sure frameBefore is already a copy, its ownership is moved to the command.
     */
    KWFramePropertiesCommand( const QString &name, KWFrame *_frameBefore,  KWFrame *_frameAfter );
    ~KWFramePropertiesCommand();
    void execute();
    void unexecute();
protected:
    FrameIndex m_frameIndex;
    KWFrame *m_frameBefore;
    KWFrame *m_frameAfter;
};


/**
 * Command created when one part is moved or resized
 */
class KWFramePartMoveCommand : public KNamedCommand
{
public:
    KWFramePartMoveCommand( const QString &name,FrameIndex _frameIndex,FrameResizeStruct _frameMove ) ;
    ~KWFramePartMoveCommand() {}

    void execute();
    void unexecute();
    FrameResizeStruct & listFrameMoved() { return m_frameMove; }
    bool frameMoved();
protected:
    FrameIndex m_indexFrame;
    FrameResizeStruct m_frameMove;
};

/**
 * Command created when a part with an external document is changed to be stored internal
 */
class KWFramePartInternalCommand : public KNamedCommand
{
public:
    KWFramePartInternalCommand( const QString &name, KWPartFrameSet *part ) ;
    ~KWFramePartInternalCommand() {}

    void execute();
    void unexecute();
protected:
    KWPartFrameSet *m_part;
    KURL m_url;
};

/**
 * Command created when a part with an external document is changed to be stored internal
 */
class KWFramePartExternalCommand : public KNamedCommand
{
public:
    KWFramePartExternalCommand( const QString &name, KWPartFrameSet *part ) ;
    ~KWFramePartExternalCommand() {}

    void execute();
    void unexecute();
protected:
    KWPartFrameSet *m_part;
};

/**
 * This command makes a frameset floating and non-floating
 */
class KWFrameSetInlineCommand : public KNamedCommand
{
public:
    KWFrameSetInlineCommand( const QString &name, KWFrameSet *frameset,
                             bool value );
    ~KWFrameSetInlineCommand() {}

    void execute();
    void unexecute();

protected:
    void setValue( bool value );

    KWFrameSet* m_pFrameSet;
    bool m_value;
    bool m_oldValue;
};

///////////////////////////////layout command///////////////////////////
struct KWPageLayoutStruct {
    KWPageLayoutStruct( const KoPageLayout& pgLayout, const KoColumns& cl, const KoKWHeaderFooter& hf )
        : _pgLayout(pgLayout), _cl(cl), _hf(hf) {
    }
    KoPageLayout _pgLayout;
    KoColumns _cl;
    KoKWHeaderFooter _hf;
};

/**
 * Command created when changing the page layout
 */
class KWPageLayoutCommand : public KNamedCommand
{
public:
    KWPageLayoutCommand( const QString &name, KWDocument *_doc, KWPageLayoutStruct &_oldLayout, KWPageLayoutStruct &_newLayout);
    ~KWPageLayoutCommand() {}

    void execute();
    void unexecute();
protected:
    KWDocument *m_pDoc;
    KWPageLayoutStruct m_oldLayout;
    KWPageLayoutStruct m_newLayout;
};


/**
 * Command created when deleting a frame
 */
class KWDeleteFrameCommand : public KNamedCommand
{
public:
    KWDeleteFrameCommand( const QString &name, KWFrame * frame) ;
    /**
     * Constructor to be used for chaining commands, i.e. inside another command.
     * @param frameIndex a frameIndex object that specifies which frame to delete
     */
    KWDeleteFrameCommand( const FrameIndex &frameIndex) ;
    ~KWDeleteFrameCommand();

    void execute();
    void unexecute();
protected:
    FrameIndex m_frameIndex;
    KWFrame *m_copyFrame;
};

/**
 * Command created when creating a frame
 */
class KWCreateFrameCommand : public KWDeleteFrameCommand
{
public:
    KWCreateFrameCommand( const QString &name, KWFrame * frame);
    ~KWCreateFrameCommand() {}

    void execute() { KWDeleteFrameCommand::unexecute(); }
    void unexecute() { KWDeleteFrameCommand::execute(); }
};

/**
 * Command created when ungrouping a table
 */
class KWUngroupTableCommand : public KNamedCommand
{
public:
    KWUngroupTableCommand( const QString &name, KWTableFrameSet * _table) ;
    ~KWUngroupTableCommand() {}

    void execute();
    void unexecute();
protected:
    KWTableFrameSet *m_pTable;
    QPtrList<KWFrameSet> m_ListFrame;
};

/**
 * Command created when deleting a table
 */
class KWDeleteTableCommand : public KNamedCommand
{
public:
    KWDeleteTableCommand( const QString &name, KWTableFrameSet * _table) ;
    ~KWDeleteTableCommand() {}

    void execute();
    void unexecute();
protected:
    KWTableFrameSet *m_pTable;
};


/**
 * Command created when creating a table
 */
class KWCreateTableCommand : public KWDeleteTableCommand
{
public:
    KWCreateTableCommand( const QString &name, KWTableFrameSet * _table)
        : KWDeleteTableCommand( name, _table ) {}
    ~KWCreateTableCommand() {}

    void execute() { KWDeleteTableCommand::unexecute(); }
    void unexecute() { KWDeleteTableCommand::execute(); }
};

/**
 * Command created when inserting a column
 */
class KWInsertColumnCommand : public KNamedCommand
{
public:
    /* for the last parameter, _maxRight, you should pass the maximum offset that the table can use at its right (normally m_maxRight - m_pTable->boundingRect().left())*/
    KWInsertColumnCommand( const QString &name, KWTableFrameSet * _table, int _pos, double _maxRight);
    ~KWInsertColumnCommand();

    void execute();
    void unexecute();
protected:
    KWTableFrameSet *m_pTable;
    RemovedColumn *m_rc;
    unsigned int m_colPos;
    double m_maxRight; // this is the maximum x of the right part of the table (used so that the table does no go off the page)
    double m_oldWidth; // will be 0 after execute() if the width of the table was not changed by the operation
    bool m_inserted;
};


/**
 * Command created when inserting a row
 */
class KWInsertRowCommand : public KNamedCommand
{
public:
    KWInsertRowCommand( const QString &name, KWTableFrameSet * _table, int _pos);
    ~KWInsertRowCommand();

    void execute();
    void unexecute();
protected:
    KWTableFrameSet *m_pTable;
    RemovedRow *m_rr;
    unsigned int m_rowPos;
    bool m_inserted;
};

/**
 * Command created when removing a row
 */
class KWRemoveRowCommand : public KNamedCommand
{
public:
    KWRemoveRowCommand( const QString &name, KWTableFrameSet * _table, int _pos);
    ~KWRemoveRowCommand();

    void execute();
    void unexecute();
protected:
    KWTableFrameSet *m_pTable;
    RemovedRow *m_rr;
    uint m_rowPos;
};

/**
 * Command created when removing a column
 */
class KWRemoveColumnCommand : public KNamedCommand
{
public:
    KWRemoveColumnCommand( const QString &name, KWTableFrameSet * _table, int _pos);
    ~KWRemoveColumnCommand();

    void execute();
    void unexecute();
protected:
    KWTableFrameSet *m_pTable;
    RemovedColumn *m_rc;
    uint m_colPos;
};

/**
 * Command created when splitting a cell
 */
class KWSplitCellCommand : public KNamedCommand
{
public:
    KWSplitCellCommand( const QString &name, KWTableFrameSet * _table,unsigned int colBegin,unsigned int rowBegin, unsigned int colEnd,unsigned int rowEnd );
    ~KWSplitCellCommand() {}

    void execute();
    void unexecute();
protected:
    KWTableFrameSet *m_pTable;
    unsigned int m_colBegin;
    unsigned int m_rowBegin;
    unsigned int m_colEnd;
    unsigned int m_rowEnd;
    QPtrList<KWFrameSet> m_ListFrameSet;
};

/**
 * Command created when joining cells
 */
class KWJoinCellCommand : public KNamedCommand
{
public:
    KWJoinCellCommand( const QString &name, KWTableFrameSet * _table,unsigned int colBegin,unsigned int rowBegin, unsigned int colEnd,unsigned int rowEnd, QPtrList<KWFrameSet> listFrameSet,QPtrList<KWFrame> listCopyFrame);
    ~KWJoinCellCommand();

    void execute();
    void unexecute();
protected:
    KWTableFrameSet *m_pTable;
    unsigned int m_colBegin;
    unsigned int m_rowBegin;
    unsigned int m_colEnd;
    unsigned int m_rowEnd;
    QPtrList<KWFrameSet> m_ListFrameSet;
    QPtrList<KWFrame> m_copyFrame;
};

/**
 * Command to starting page setting
 */
class KWChangeStartingPageCommand : public KNamedCommand
{
public:
    KWChangeStartingPageCommand( const QString &name, KWDocument *_doc, int _oldStartingPage, int _newStartingPage);
    ~KWChangeStartingPageCommand(){}

    void execute();
    void unexecute();
protected:
    KWDocument *m_doc;
    int oldStartingPage;
    int newStartingPage;
};

/**
 * Command to display link setting
 */
class KWChangeVariableSettingsCommand : public KNamedCommand
{
public:
    enum VariableProperties { VS_DISPLAYLINK, VS_UNDERLINELINK, VS_DISPLAYCOMMENT, VS_DISPLAYFIELDCODE};
    KWChangeVariableSettingsCommand( const QString &name, KWDocument *_doc, bool _oldDisplay, bool _newDisplay, VariableProperties _type);
    ~KWChangeVariableSettingsCommand(){}

    void execute();
    void unexecute();
protected:
    void changeValue( bool b );
    KWDocument *m_doc;
    VariableProperties type;
    bool m_bOldValue;
    bool m_bNewValue;
};

class KWChangeCustomVariableValue : public KNamedCommand
{
 public:
    KWChangeCustomVariableValue( const QString &name, KWDocument *_doc,const QString & _oldValue, const QString & _newValue, KoCustomVariable *var);
    ~KWChangeCustomVariableValue();
    void execute();
    void unexecute();
 protected:
    KWDocument *m_doc;
    QString newValue;
    QString oldValue;
    KoCustomVariable *m_var;
};

class KWChangeVariableNoteText : public KNamedCommand
{
 public:
    KWChangeVariableNoteText( const QString &name, KWDocument *_doc, const QString &_oldValue,const QString &_newValue, KoNoteVariable *var);
    ~KWChangeVariableNoteText();
    void execute();
    void unexecute();
 protected:
    KWDocument *m_doc;
    QString newValue;
    QString oldValue;
     KoNoteVariable *m_var;
};

class KWChangeLinkVariable : public KNamedCommand
{
 public:
    KWChangeLinkVariable( const QString &name, KWDocument *_doc,const QString & _oldHref, const QString & _newHref, const QString & _oldLink,const QString &_newLink, KoLinkVariable *var);
    ~KWChangeLinkVariable(){};
    void execute();
    void unexecute();
 protected:
    KWDocument *m_doc;
    QString oldHref;
    QString newHref;
    QString oldLink;
    QString newLink;
    KoLinkVariable *m_var;
};

class KWHideShowHeader : public KNamedCommand
{
 public:
    KWHideShowHeader( const QString &name, KWDocument *_doc, bool _newValue);
    ~KWHideShowHeader(){};
    void execute();
    void unexecute();
 protected:
    KWDocument *m_doc;
    bool newValue;
};

class KWHideShowFooter : public KNamedCommand
{
 public:
    KWHideShowFooter( const QString &name, KWDocument *_doc, bool _newValue);
    ~KWHideShowFooter(){};
    void execute();
    void unexecute();
 protected:
    KWDocument *m_doc;
    bool newValue;
};


class KWProtectContentCommand : public KNamedCommand
{
public:
    KWProtectContentCommand( const QString &name, KWTextFrameSet*frameset,bool protect );
    ~KWProtectContentCommand() {}

    void execute();
    void unexecute();

protected:
    KWTextFrameSet* m_pFrameSet;
    bool m_bProtect;
};

class KWInsertRemovePageCommand : public KCommand
{
 public:
    enum Command { Insert, Remove };
    KWInsertRemovePageCommand( KWDocument *_doc, Command cmd, int pgNum);
    ~KWInsertRemovePageCommand();
    virtual QString name() const;
    void execute();
    void unexecute();
 protected:
    KWDocument *m_doc;
    Command m_cmd;
    int m_pgNum;
    QValueList<KCommand*> childCommands;

    void doRemove(int pageNumber);
    void doInsert(int pageNumber);

 private:
    static bool compareIndex(const FrameIndex &index1, const FrameIndex &index2);
};

struct FramePaddingStruct {
    FramePaddingStruct() {}
    FramePaddingStruct( KWFrame *frame );
    FramePaddingStruct( double _left, double top, double right, double bottom );
    double topPadding;
    double bottomPadding;
    double leftPadding;
    double rightPadding;
};

class KWFrameChangeFramePaddingCommand :public KNamedCommand
{
public:
    KWFrameChangeFramePaddingCommand( const QString &name, FrameIndex _frameIndex, FramePaddingStruct _framePaddingBegin, FramePaddingStruct _framePaddingEnd );
    ~KWFrameChangeFramePaddingCommand() {}
    void execute();
    void unexecute();
protected:
    FrameIndex m_indexFrame;
    FramePaddingStruct m_framePaddingBegin;
    FramePaddingStruct m_framePaddingEnd;
};


class KWChangeFootEndNoteSettingsCommand : public KNamedCommand
{
public:
    KWChangeFootEndNoteSettingsCommand( const QString &name, KoParagCounter _oldCounter, KoParagCounter _newCounter ,bool _footNote ,KWDocument *_doc );
    ~KWChangeFootEndNoteSettingsCommand() {}

    void execute();
    void unexecute();

protected:
    void changeCounter( KoParagCounter counter);
    KoParagCounter m_oldCounter;
    KoParagCounter m_newCounter;
    bool m_footNote;
    KWDocument *m_doc;
};

class KWChangeTabStopValueCommand : public KNamedCommand
{
public:
    KWChangeTabStopValueCommand( const QString &name,  double _oldValue, double _newValue, KWDocument *_doc);

    ~KWChangeTabStopValueCommand() {}

    virtual void execute();
    virtual void unexecute();
protected:
    KWDocument *m_doc;
    double m_oldValue;
    double m_newValue;
};


struct FootNoteParameter {
    FootNoteParameter() {}
    FootNoteParameter( KWFootNoteVariable *_var );
    FootNoteParameter( NoteType _noteType, KWFootNoteVariable::Numbering _numberingType, const QString &_manualString);
    NoteType noteType;
    KWFootNoteVariable::Numbering numberingType;
    QString manualString;
};

class KWChangeFootNoteParametersCommand : public KNamedCommand
{
public:
    KWChangeFootNoteParametersCommand( const QString &name, KWFootNoteVariable * _var, FootNoteParameter _oldParameter, FootNoteParameter _newParameter, KWDocument *_doc);

    ~KWChangeFootNoteParametersCommand() {}

    virtual void execute();
    virtual void unexecute();
protected:
    void changeVariableParameter( FootNoteParameter _param );
    KWDocument *m_doc;
    KWFootNoteVariable *m_var;
    FootNoteParameter m_oldParameter;
    FootNoteParameter m_newParameter;
};


class KWChangeFootNoteLineSeparatorParametersCommand : public KNamedCommand
{
public:
    KWChangeFootNoteLineSeparatorParametersCommand( const QString &name, SeparatorLinePos _oldValuePos, SeparatorLinePos _newValuePos, int _oldLength, int _newLength, double _oldWidth, double _newWidth,SeparatorLineLineType _oldLineType, SeparatorLineLineType _newLineType, KWDocument *_doc);

    ~KWChangeFootNoteLineSeparatorParametersCommand() {}

    virtual void execute();
    virtual void unexecute();
protected:
    void changeLineSeparatorParameter( SeparatorLinePos _pos, int length, double _width, SeparatorLineLineType _type);
    KWDocument *m_doc;
    SeparatorLinePos m_oldValuePos;
    SeparatorLinePos m_newValuePos;
    int m_oldLength;
    int m_newLength;
    double m_oldWidth;
    double m_newWidth;
    SeparatorLineLineType m_oldLineType;
    SeparatorLineLineType m_newLineType;
};

class KWRenameBookmarkCommand : public KNamedCommand
{
public:
    KWRenameBookmarkCommand( const QString &name, const QString & _oldname, const QString & _newName, KWDocument *_doc);

    ~KWRenameBookmarkCommand() {}

    virtual void execute();
    virtual void unexecute();
protected:
    KWDocument *m_doc;
    QString m_oldName;
    QString m_newName;
};

class KWResizeColumnCommand : public KNamedCommand
{
public:
    KWResizeColumnCommand( KWTableFrameSet *table, int col, double oldSize, double newSize );

    ~KWResizeColumnCommand() {}

    virtual void execute();
    virtual void unexecute();
protected:
    KWTableFrameSet *m_table;
    double m_oldSize;
    double m_newSize;
    int m_col;
};

class KWResizeRowCommand : public KNamedCommand
{
  public:
    KWResizeRowCommand( KWTableFrameSet *table, int row, double oldSize, double newSize );

    ~KWResizeRowCommand() {}

    virtual void execute();
    virtual void unexecute();
  protected:
    KWTableFrameSet *m_table;
    double m_oldSize;
    double m_newSize;
    int m_row;
};

#endif