21
#include "kwtextframeset.h"
22
22
#include "kwcommand.h"
23
#include "kwtextframeset.h"
23
#include "kwtablestyle.h"
24
#include "kwtabletemplate.h"
24
25
#include "kwtableframeset.h"
26
#include "kwpartframeset.h"
27
#include "kwtextparag.h"
25
28
#include "kwanchor.h"
27
#include <qrichtext_p.h>
29
#include "kwvariable.h"
30
#include "kovariable.h"
31
#include <kotextobject.h>
28
33
#include <kdebug.h>
30
// This is automatically called by KCommandHistory's redo action when redo is activated
31
void KWTextCommand::execute()
36
// This is automatically called by KCommandHistory's undo action when undo is activated
37
void KWTextCommand::unexecute()
42
KWTextDeleteCommand::KWTextDeleteCommand(
43
QTextDocument *d, int i, int idx, const QArray<QTextStringChar> &str,
44
const CustomItemsMap & customItemsMap,
45
const QValueList<KWParagLayout> &oldParagLayouts )
46
: QTextDeleteCommand( d, i, idx, str,
47
QValueList< QVector<QStyleSheetItem> >(),
48
QValueList<QStyleSheetItem::ListStyle>(),
50
m_oldParagLayouts( oldParagLayouts ),
51
m_customItemsMap( customItemsMap )
53
// Note that we don't pass aligns and liststyles to QTextDeleteCommand.
54
// We'll handle them here, as part of the rest, since they are in the paraglayouts
57
QTextCursor * KWTextDeleteCommand::execute( QTextCursor *c )
59
QTextParag *s = doc ? doc->paragAt( id ) : parag;
61
qWarning( "can't locate parag at %d, last parag: %d", id, doc->lastParag()->paragId() );
65
cursor.setIndex( index );
66
int len = text.size();
67
// Detach from custom items. They are already in the map, and we don't
68
// want them to be deleted
69
for ( int i = 0; i < len; ++i )
71
QTextStringChar * ch = cursor.parag()->at( cursor.index() );
74
static_cast<KWTextCustomItem *>( ch->customItem() )->setDeleted( true );
75
static_cast<KWTextParag*>(cursor.parag())->removeCustomItem(cursor.index());
80
return QTextDeleteCommand::execute(c);
83
QTextCursor * KWTextDeleteCommand::unexecute( QTextCursor *c )
85
// Let QRichText re-create the text and formatting
86
QTextCursor * cr = QTextDeleteCommand::unexecute(c);
88
QTextParag *s = doc ? doc->paragAt( id ) : parag;
90
qWarning( "can't locate parag at %d, last parag: %d", id, doc->lastParag()->paragId() );
94
cursor.setIndex( index );
95
// Set any custom item that we had
96
m_customItemsMap.insertItems( cursor, text.size() );
98
// Now restore the parag layouts (i.e. KWord specific stuff)
99
QValueList<KWParagLayout>::Iterator lit = m_oldParagLayouts.begin();
100
kdDebug() << "KWTextDeleteCommand::unexecute " << m_oldParagLayouts.count() << " parag layouts. First parag=" << s->paragId() << endl;
101
ASSERT( id == s->paragId() );
104
if ( lit != m_oldParagLayouts.end() )
106
kdDebug() << "KWTextDeleteCommand::unexecute applying paraglayout to parag " << p->paragId() << endl;
107
static_cast<KWTextParag*>(p)->setParagLayout( *lit );
111
//if ( s == cr->parag() )
119
KWTextParagCommand::KWTextParagCommand( QTextDocument *d, int fParag, int lParag,
120
const QValueList<KWParagLayout> &oldParagLayouts,
121
KWParagLayout newParagLayout,
123
QStyleSheetItem::Margin margin )
124
: QTextCommand( d ), firstParag( fParag ), lastParag( lParag ), m_oldParagLayouts( oldParagLayouts ),
125
m_newParagLayout( newParagLayout ), m_flags( flags ), m_margin( margin )
129
QTextCursor * KWTextParagCommand::execute( QTextCursor *c )
131
//kdDebug() << "KWTextParagCommand::execute" << endl;
132
KWTextParag *p = static_cast<KWTextParag *>(doc->paragAt( firstParag ));
135
kdWarning() << "KWTextParagCommand::execute paragraph " << firstParag << "not found" << endl;
139
if ( ( m_flags & KWParagLayout::Margins ) && m_margin != (QStyleSheetItem::Margin)-1 ) // all
140
p->setMargin( static_cast<QStyleSheetItem::Margin>(m_margin), m_newParagLayout.margins[m_margin] );
143
p->setParagLayout( m_newParagLayout, m_flags );
145
if ( p->paragId() == lastParag )
147
p = static_cast<KWTextParag *>(p->next());
149
//kdDebug() << "KWTextParagCommand::execute done" << endl;
150
// Set cursor to end of selection. Like in QTextFormatCommand::[un]execute...
152
c->setIndex( p->length()-1 );
156
QTextCursor * KWTextParagCommand::unexecute( QTextCursor *c )
158
KWTextParag *p = static_cast<KWTextParag *>(doc->paragAt( firstParag ));
161
kdDebug() << "KWTextParagCommand::unexecute paragraph " << firstParag << "not found" << endl;
164
QValueList<KWParagLayout>::Iterator lit = m_oldParagLayouts.begin();
166
if ( lit == m_oldParagLayouts.end() )
168
kdDebug() << "KWTextParagCommand::unexecute m_oldParagLayouts not big enough!" << endl;
171
if ( m_flags & KWParagLayout::Margins && m_margin != (QStyleSheetItem::Margin)-1 ) // just one
172
p->setMargin( static_cast<QStyleSheetItem::Margin>(m_margin), (*lit).margins[m_margin] );
175
p->setParagLayout( *lit, m_flags );
177
if ( p->paragId() == lastParag )
179
p = static_cast<KWTextParag *>(p->next());
182
// Set cursor to end of selection. Like in QTextFormatCommand::[un]execute...
184
c->setIndex( p->length()-1 );
190
KWParagFormatCommand::KWParagFormatCommand( QTextDocument *d, int fParag, int lParag,
191
const QValueList<QTextFormat *> &oldFormats,
192
QTextFormat * newFormat )
193
: QTextCommand( d ), firstParag( fParag ), lastParag( lParag ), m_oldFormats( oldFormats ),
194
m_newFormat( newFormat )
196
QValueList<QTextFormat *>::Iterator lit = m_oldFormats.begin();
197
for ( ; lit != m_oldFormats.end() ; ++lit )
201
KWParagFormatCommand::~KWParagFormatCommand()
203
QValueList<QTextFormat *>::Iterator lit = m_oldFormats.begin();
204
for ( ; lit != m_oldFormats.end() ; ++lit )
208
QTextCursor * KWParagFormatCommand::execute( QTextCursor *c )
210
KWTextParag *p = static_cast<KWTextParag *>(doc->paragAt( firstParag ));
213
kdDebug() << "KWTextParagCommand::execute paragraph " << firstParag << "not found" << endl;
217
p->setFormat( m_newFormat );
219
if ( p->paragId() == lastParag )
221
p = static_cast<KWTextParag *>(p->next());
226
QTextCursor * KWParagFormatCommand::unexecute( QTextCursor *c )
228
QTextParag *p = doc->paragAt( firstParag );
231
kdDebug() << "KWParagFormatCommand::unexecute paragraph " << firstParag << "not found" << endl;
234
QValueList<QTextFormat *>::Iterator lit = m_oldFormats.begin();
236
if ( lit == m_oldFormats.end() )
238
kdDebug() << "KWParagFormatCommand::unexecute m_oldFormats not big enough!" << endl;
241
p->setFormat( (*lit) );
242
if ( p->paragId() == lastParag )
250
KWPasteTextCommand::KWPasteTextCommand( QTextDocument *d, int parag, int idx,
36
KWPasteTextCommand::KWPasteTextCommand( KoTextDocument *d, int parag, int idx,
251
37
const QCString & data )
252
: QTextCommand( d ), m_parag( parag ), m_idx( idx ), m_data( data )
38
: KoTextDocCommand( d ), m_parag( parag ), m_idx( idx ), m_data( data ), m_oldParagLayout( 0 )
256
QTextCursor * KWPasteTextCommand::execute( QTextCursor *c )
42
KoTextCursor * KWPasteTextCommand::execute( KoTextCursor *c )
258
QTextParag *firstParag = doc->paragAt( m_parag );
44
KoTextParag *firstParag = doc->paragAt( m_parag );
259
45
if ( !firstParag ) {
260
46
qWarning( "can't locate parag at %d, last parag: %d", m_parag, doc->lastParag()->paragId() );
327
110
QDomElement formatElem = layout.namedItem( "FORMAT" ).toElement();
328
111
if ( !formatElem.isNull() )
330
QTextFormat f = parag->loadFormat( formatElem, 0L, QFont() );
331
QTextFormat * defaultFormat = doc->formatCollection()->format( &f );
113
KoTextFormat f = parag->loadFormat( formatElem, 0L, QFont(), KGlobal::locale()->language(),false );
114
KoTextFormat * defaultFormat = doc->formatCollection()->format( &f );
332
115
// Last paragraph (i.e. only one in all) : some of the text might be from before the paste
333
116
int endIndex = (item == count-1) ? c->index() : parag->string()->length() - 1;
334
117
parag->setFormat( m_idx, endIndex - m_idx, defaultFormat, TRUE );
338
parag->loadFormatting( paragElem, m_idx );
121
parag->loadFormatting( paragElem, m_idx, (textFs->isMainFrameset()));
342
125
if ( item == 0 ) // This paragraph existed, store its parag layout
343
m_oldParagLayout = parag->paragLayout();
127
delete m_oldParagLayout;
128
m_oldParagLayout = new KoParagLayout( parag->paragLayout() );
344
130
parag->loadLayout( paragElem );
345
131
// Last paragraph: some of the text might be from before the paste
346
132
int len = (item == count-1) ? c->index() : parag->string()->length();
347
133
// Apply default format
348
134
parag->setFormat( 0, len, parag->paragFormat(), TRUE );
349
parag->loadFormatting( paragElem );
135
parag->loadFormatting( paragElem, 0, (textFs->isMainFrameset()) );
137
parag->invalidate(0); // the formatting will be done by caller (either KWTextFrameSet::pasteKWord or KoTextObject::undo/redo)
352
138
parag->setChanged( TRUE );
353
139
parag = static_cast<KWTextParag *>(parag->next());
354
140
//kdDebug() << "KWPasteTextCommand::execute going to next parag: " << parag << endl;
142
textFs->textObject()->setNeedSpellCheck( true );
356
143
textFs->zoom( false );
358
144
// In case loadFormatting queued any image request
359
145
KWDocument * doc = textFs->kWordDocument();
360
doc->processImageRequests();
146
doc->processPictureRequests();
148
//kdDebug() << "KWPasteTextCommand::execute calling doc->pasteFrames" << endl;
362
149
// In case of any inline frameset
363
doc->pasteFrames( elem, 0 );
150
doc->pasteFrames( elem, 0,
151
true /*don't change footnote attribute*/ ,
152
(textFs->isMainFrameset()) /*load footnotes if mainframeset*/,
153
false /*don't select frames*/ );
154
doc->completePasting();
365
156
m_lastParag = c->parag()->paragId();
366
157
m_lastIndex = c->index();
395
QTextCursor * KWPasteTextCommand::unexecute( QTextCursor *c )
187
KoTextCursor * KWPasteTextCommand::unexecute( KoTextCursor *c )
397
QTextParag *firstParag = doc->paragAt( m_parag );
189
KoTextParag *firstParag = doc->paragAt( m_parag );
398
190
if ( !firstParag ) {
399
191
qWarning( "can't locate parag at %d, last parag: %d", m_parag, doc->lastParag()->paragId() );
402
194
cursor.setParag( firstParag );
403
195
cursor.setIndex( m_idx );
404
doc->setSelectionStart( QTextDocument::Temp, &cursor );
196
doc->setSelectionStart( KoTextDocument::Temp, &cursor );
406
QTextParag *lastParag = doc->paragAt( m_lastParag );
198
KoTextParag *lastParag = doc->paragAt( m_lastParag );
407
199
if ( !lastParag ) {
408
200
qWarning( "can't locate parag at %d, last parag: %d", m_lastParag, doc->lastParag()->paragId() );
203
Q_ASSERT( lastParag->document() );
204
// Get hold of the document before deleting the parag
205
KoTextDocument* textdoc = lastParag->document();
207
//kdDebug() << "Undoing paste: deleting from (" << firstParag->paragId() << "," << m_idx << ")"
208
// << " to (" << lastParag->paragId() << "," << m_lastIndex << ")" << endl;
411
210
cursor.setParag( lastParag );
412
211
cursor.setIndex( m_lastIndex );
413
doc->setSelectionEnd( QTextDocument::Temp, &cursor );
212
doc->setSelectionEnd( KoTextDocument::Temp, &cursor );
414
213
// Delete all custom items
415
214
KWDeleteCustomItemVisitor visitor;
416
static_cast<KoTextDocument *>(doc)->visitSelection( QTextDocument::Temp, &visitor );
418
doc->removeSelectedText( QTextDocument::Temp, c /* sets c to the correct position */ );
421
static_cast<KWTextParag *>( firstParag )->setParagLayout( m_oldParagLayout );
215
doc->visitSelection( KoTextDocument::Temp, &visitor );
217
doc->removeSelectedText( KoTextDocument::Temp, c /* sets c to the correct position */ );
219
KWTextFrameSet * textFs = static_cast<KWTextDocument *>(textdoc)->textFrameSet();
221
textFs->renumberFootNotes();
223
Q_ASSERT( m_oldParagLayout );
224
if ( m_oldParagLayout )
225
firstParag->setParagLayout( *m_oldParagLayout );
425
KWTextFormatCommand::KWTextFormatCommand(QTextDocument *d, int sid, int sidx, int eid, int eidx, const QMemArray<QTextStringChar> &old, QTextFormat *f, int fl )
426
: QTextFormatCommand(d, sid, sidx, eid, eidx, old, f, fl)
431
KWTextFormatCommand::~KWTextFormatCommand()
435
void KWTextFormatCommand::resizeCustomItem()
437
QTextParag *sp = doc->paragAt( startId );
438
QTextParag *ep = doc->paragAt( endId );
231
KWTextDeleteCommand::KWTextDeleteCommand( KoTextDocument *d, int i, int idx, const QMemArray<KoTextStringChar> &str,
232
const CustomItemsMap & customItemsMap,
233
const QValueList<KoParagLayout> & oldParagLayouts )
234
:KoTextDeleteCommand(d, i, idx, str, customItemsMap, oldParagLayouts)
236
//createBookmarkList();
239
void KWTextDeleteCommand::createBookmarkList()
242
KoTextParag *s = doc ? doc->paragAt( id ) : parag;
244
qWarning( "can't locate parag at %d, last parag: %d", id, doc->lastParag()->paragId() );
442
QTextCursor start( doc );
443
start.setParag( sp );
444
start.setIndex( startIndex );
445
QTextCursor end( doc );
447
end.setIndex( endIndex );
449
doc->setSelectionStart( QTextDocument::Temp, &start );
450
doc->setSelectionEnd( QTextDocument::Temp, &end );
453
if ( start.parag() == end.parag() )
455
QString text = start.parag()->string()->toString().mid( start.index(), end.index() - start.index() );
456
for ( int i = start.index(); i < end.index(); ++i )
458
if( start.parag()->at(i)->isCustom())
460
static_cast<KWTextCustomItem *>( start.parag()->at(i)->customItem() )->resize();
467
QString text = start.parag()->string()->toString().mid( start.index(), start.parag()->length() - 1 - start.index() );
468
for ( i = start.index(); i < start.parag()->length(); ++i )
469
if( start.parag()->at(i)->isCustom())
471
static_cast<KWTextCustomItem *>( start.parag()->at(i)->customItem() )->resize();
474
QTextParag *p = start.parag()->next();
475
while ( p && p != end.parag() )
477
text = p->string()->toString().left( p->length() - 1 );
478
for ( i = 0; i < p->length(); ++i )
480
if( p->at(i)->isCustom())
482
static_cast<KWTextCustomItem *>(p->at(i)->customItem() )->resize();
487
text = end.parag()->string()->toString().left( end.index() );
488
for ( i = 0; i < end.index(); ++i )
490
if( end.parag()->at(i)->isCustom())
492
static_cast<KWTextCustomItem *>( end.parag()->at(i)->customItem() )->resize();
498
QTextCursor *KWTextFormatCommand::execute( QTextCursor *c )
500
QTextCursor *tmp=QTextFormatCommand::execute( c );
501
QTextParag *sp = doc->paragAt( startId );
502
QTextParag *ep = doc->paragAt( endId );
511
QTextCursor *KWTextFormatCommand::unexecute( QTextCursor *c )
513
QTextCursor*tmp= QTextFormatCommand::unexecute( c );
515
QTextParag *sp = doc->paragAt( startId );
516
QTextParag *ep = doc->paragAt( endId );
248
// Now restore the parag layouts (i.e. libkotext specific stuff)
249
QValueList<KoParagLayout>::Iterator lit = m_oldParagLayouts.begin();
250
kdDebug(32500) << "KWTextDeleteCommand::createBookmarkList " << m_oldParagLayouts.count() << " parag layouts. First parag=" << s->paragId() << endl;
251
Q_ASSERT( id == s->paragId() );
254
if ( lit != m_oldParagLayouts.end() )
256
kdDebug(32500) << "KWTextDeleteCommand::unexecute find bookmark in parag " << p->paragId() << endl;
257
//p->setParagLayout( *lit );
267
KoTextCursor *KWTextDeleteCommand::execute( KoTextCursor *c )
269
return KoTextDeleteCommand::execute( c );
272
KoTextCursor *KWTextDeleteCommand::unexecute( KoTextCursor *c )
274
return KoTextDeleteCommand::unexecute( c );
526
277
////////////////////////// Frame commands ////////////////////////////////
528
279
FrameIndex::FrameIndex( KWFrame *frame )
530
m_pFrameSet=frame->getFrameSet();
531
m_iFrameIndex=m_pFrameSet->getFrameFromPtr(frame);
281
m_pFrameSet=frame->frameSet();
282
m_iFrameIndex=m_pFrameSet->frameFromPtr(frame);
534
KWFrameBorderCommand::KWFrameBorderCommand( const QString &name, QList<FrameIndex> &_listFrameIndex, QList<FrameBorderTypeStruct> &_frameTypeBorder,const Border & _newBorder):
285
KWFrameBorderCommand::KWFrameBorderCommand( const QString &name, QPtrList<FrameIndex> &_listFrameIndex, QPtrList<FrameBorderTypeStruct> &_frameTypeBorder,const KoBorder & _newBorder):
536
287
m_indexFrame(_listFrameIndex),
537
288
m_oldBorderFrameType(_frameTypeBorder),
538
289
m_newBorder( _newBorder)
293
KWFrameBorderCommand::~KWFrameBorderCommand()
295
m_indexFrame.setAutoDelete( true);
296
m_oldBorderFrameType.setAutoDelete( true);
542
299
void KWFrameBorderCommand::execute()
652
472
doc->repaintAllViews();
656
KWFrameResizeCommand::KWFrameResizeCommand( const QString &name, FrameIndex _frameIndex, FrameResizeStruct _frameResize ) :
475
KWFrameStyleCommand::KWFrameStyleCommand( const QString &name, KWFrame *_frame, KWFrameStyle *_fs, bool _repaintViews ) :
476
KNamedCommand( name )
480
repaintViews = _repaintViews;
482
m_oldValues = new KWFrameStyle( "Old", m_frame );
485
void KWFrameStyleCommand::execute()
487
applyFrameStyle( m_fs);
490
void KWFrameStyleCommand::unexecute()
492
applyFrameStyle( m_oldValues);
495
void KWFrameStyleCommand::applyFrameStyle( KWFrameStyle * _sty )
497
if ( m_frame->frameSet() && (m_frame->frameSet()->type() != FT_PICTURE)&& (m_frame->frameSet()->type() != FT_PART))
498
m_frame->setBackgroundColor( _sty->backgroundColor() );
499
m_frame->setLeftBorder( _sty->leftBorder() );
500
m_frame->setRightBorder( _sty->rightBorder() );
501
m_frame->setTopBorder( _sty->topBorder() );
502
m_frame->setBottomBorder( _sty->bottomBorder() );
504
m_frame->frameBordersChanged();
505
if (m_frame->isSelected())
506
m_frame->updateResizeHandles();
509
m_frame->frameSet()->kWordDocument()->repaintAllViews();
510
m_frame->frameSet()->kWordDocument()->refreshFrameBorderButton();
514
KWTableStyleCommand::KWTableStyleCommand( const QString &name, KWFrame *_frame, KWTableStyle *_ts, bool _repaintViews ) :
515
KNamedCommand( name )
519
repaintViews = _repaintViews;
521
// No need for i18n because it will never be displayed.
522
m_fsc = new KWFrameStyleCommand( "Apply Framestyle to Frame", m_frame, m_ts->pFrameStyle(), repaintViews );
526
KWTableStyleCommand::~KWTableStyleCommand()
532
void KWTableStyleCommand::execute()
537
if ( (m_ts) && ( m_frame->frameSet()->type() == FT_TEXT ) && ( m_ts->pStyle() ) )
539
KoTextObject *textObject = ((KWTextFrameSet*)m_frame->frameSet())->textObject();
540
textObject->textDocument()->selectAll( KoTextDocument::Temp );
541
m_sc = textObject->applyStyleCommand( 0L, m_ts->pStyle(), KoTextDocument::Temp, KoParagLayout::All, KoTextFormat::Format, true, false );
542
textObject->textDocument()->removeSelection( KoTextDocument::Temp );
545
m_frame->frameBordersChanged();
546
if (m_frame->isSelected())
547
m_frame->updateResizeHandles();
550
m_frame->frameSet()->kWordDocument()->repaintAllViews();
551
m_frame->frameSet()->kWordDocument()->refreshFrameBorderButton();
555
void KWTableStyleCommand::unexecute()
562
m_frame->frameBordersChanged();
563
if (m_frame->isSelected())
564
m_frame->updateResizeHandles();
567
m_frame->frameSet()->kWordDocument()->repaintAllViews();
568
m_frame->frameSet()->kWordDocument()->refreshFrameBorderButton();
571
KWTableTemplateCommand::KWTableTemplateCommand( const QString &name, KWTableFrameSet *_table, KWTableTemplate *_tt ) :
572
KNamedCommand( name )
577
// No need for i18n because it will never be displayed.
578
m_tableCommands = new KMacroCommand( "Apply Tablestyles to Table" );
581
KWTableStyle *cell = 0L;
582
unsigned int rows = m_table->getRows();
583
unsigned int cols = m_table->getCols();
585
for ( unsigned int i = 0; i < rows; i++ )
587
for ( unsigned int j = 0; j < cols; j++ )
589
if ( (i==0) && (j==0) ) // TOP LEFT CORNER
590
cell = m_tt->pTopLeftCorner();
592
if ( (i==0) && ( j==(cols-1) ) ) // TOP RIGHT CORNER
593
cell = m_tt->pTopRightCorner();
595
if ( ( i==(rows-1) ) && (j==0) ) // BOTTOM LEFT CORNER
596
cell = m_tt->pBottomLeftCorner();
598
if ( ( i==(rows-1) ) && ( j==(cols-1) ) ) // BOTTOM RIGHT CORNER
599
cell = m_tt->pBottomRightCorner();
601
if ( ( i==0 ) && ( j>0 ) && ( j<(cols-1) ) ) // FIRST ROW
602
cell = m_tt->pFirstRow();
604
if ( ( j==0 ) && ( i>0 ) && ( i<(rows-1) ) ) // FIRST COL
605
cell = m_tt->pFirstCol();
607
if ( ( i==(rows-1) ) && ( j>0 ) && ( j<(cols-1) ) ) // LAST ROW
608
cell = m_tt->pLastRow();
610
if ( ( j==(cols-1) ) && ( i>0 ) && ( i<(rows-1) ) ) // LAST COL
611
cell = m_tt->pLastCol();
613
if ( (i>0) && (j>0) && (i<(rows-1)) && (j<(cols-1)) ) // BODY
614
cell = m_tt->pBodyCell();
616
m_tableCommands->addCommand( new KWTableStyleCommand( "Apply tablestyle to cell", m_table->getCell(i,j)->frame(0),cell, false ) );
621
KWTableTemplateCommand::~KWTableTemplateCommand()
623
delete m_tableCommands;
626
void KWTableTemplateCommand::execute()
628
m_tableCommands->execute();
629
m_table->kWordDocument()->repaintAllViews();
632
void KWTableTemplateCommand::unexecute()
634
m_tableCommands->unexecute();
635
m_table->kWordDocument()->repaintAllViews();
639
KWFrameResizeCommand::KWFrameResizeCommand( const QString &name, FrameIndex _frameIndex, const FrameResizeStruct& _frameResize ) :
658
641
m_indexFrame(_frameIndex),
659
642
m_FrameResize(_frameResize)
644
//kdDebug() << "Resize command: oldRect=" << m_FrameResize.oldRect
645
// << " oldMinHeight=" << m_FrameResize.oldMinHeight
646
// << " newRect=" << m_FrameResize.newRect
647
// << " newMinHeight=" << m_FrameResize.newMinHeight << endl;
663
650
void KWFrameResizeCommand::execute()
665
652
KWFrameSet *frameSet = m_indexFrame.m_pFrameSet;
667
KWFrame *frame = frameSet->getFrame(m_indexFrame.m_iFrameIndex);
669
frame->setCoords(m_FrameResize.sizeOfEnd.left(),m_FrameResize.sizeOfEnd.top(),m_FrameResize.sizeOfEnd.right(),m_FrameResize.sizeOfEnd.bottom());
653
Q_ASSERT( frameSet );
654
KWFrame *frame = frameSet->frame(m_indexFrame.m_iFrameIndex);
656
frame->setCoords(m_FrameResize.newRect.left(),m_FrameResize.newRect.top(),m_FrameResize.newRect.right(),m_FrameResize.newRect.bottom());
657
frame->setMinFrameHeight(m_FrameResize.newMinHeight);
671
KWTableFrameSet *table = frame->getFrameSet()->getGroupManager();
659
KWTableFrameSet *table = frame->frameSet()->getGroupManager();
673
KWTableFrameSet::Cell *cell=dynamic_cast<KWTableFrameSet::Cell *>(frame->getFrameSet());
661
KWTableFrameSet::Cell *cell=dynamic_cast<KWTableFrameSet::Cell *>(frame->frameSet());
676
table->recalcCols(cell->m_col,cell->m_row);
677
table->recalcRows(cell->m_col,cell->m_row);
664
table->recalcCols(cell->firstCol(), cell->firstRow());
665
table->recalcRows(cell->firstCol(), cell->firstRow());
681
669
table->recalcCols();
682
670
table->recalcRows();
684
table->updateTempHeaders();
685
672
table->refreshSelectedCell();
686
673
//repaintTableHeaders( table );
688
675
KWDocument * doc = frameSet->kWordDocument();
690
if(frameSet->isAHeader() || frameSet->isAFooter())
676
if ( frameSet->frameSetInfo() != KWFrameSet::FI_BODY ) // header/footer/footnote
691
677
doc->recalcFrames();
692
679
frame->updateRulerHandles();
694
682
doc->frameChanged( frame );
697
685
void KWFrameResizeCommand::unexecute()
699
687
KWFrameSet *frameSet =m_indexFrame.m_pFrameSet;
700
KWFrame *frame=frameSet->getFrame(m_indexFrame.m_iFrameIndex);
701
frame->setCoords(m_FrameResize.sizeOfBegin.left(),m_FrameResize.sizeOfBegin.top(),m_FrameResize.sizeOfBegin.right(),m_FrameResize.sizeOfBegin.bottom());
702
KWTableFrameSet *table = frame->getFrameSet()->getGroupManager();
688
KWFrame *frame=frameSet->frame(m_indexFrame.m_iFrameIndex);
689
frame->setCoords(m_FrameResize.oldRect.left(),m_FrameResize.oldRect.top(),m_FrameResize.oldRect.right(),m_FrameResize.oldRect.bottom());
690
frame->setMinFrameHeight(m_FrameResize.oldMinHeight);
691
KWTableFrameSet *table = frame->frameSet()->getGroupManager();
704
KWTableFrameSet::Cell *cell=dynamic_cast<KWTableFrameSet::Cell *>(frame->getFrameSet());
693
KWTableFrameSet::Cell *cell=dynamic_cast<KWTableFrameSet::Cell *>(frame->frameSet());
707
table->recalcCols(cell->m_col,cell->m_row);
708
table->recalcRows(cell->m_col,cell->m_row);
696
table->recalcCols(cell->firstCol(), cell->firstRow());
697
table->recalcRows(cell->firstCol(), cell->firstRow());
712
701
table->recalcCols();
713
702
table->recalcRows();
715
table->updateTempHeaders();
716
704
table->refreshSelectedCell();
717
705
//repaintTableHeaders( table );
719
707
KWDocument * doc = frameSet->kWordDocument();
720
if(frameSet->isAHeader() || frameSet->isAFooter())
708
if ( frameSet->frameSetInfo() != KWFrameSet::FI_BODY ) // header/footer/footnote
721
709
doc->recalcFrames();
723
711
frame->updateRulerHandles();
903
KWFrameSetFloatingCommand::KWFrameSetFloatingCommand( const QString &name, KWFrameSet *frameset, bool floating ) :
960
KWFrameSetPropertyCommand::KWFrameSetPropertyCommand( const QString &name, KWFrameSet *frameset, Property prop, const QString& value ) :
905
962
m_pFrameSet( frameset ),
906
m_bFloating( floating )
910
void KWFrameSetFloatingCommand::execute()
912
kdDebug() << "KWFrameSetFloatingCommand::execute" << endl;
915
// Make frame(set) floating
916
m_pFrameSet->setFloating();
917
// ## We might want to store a list of anchors in the command, and reuse them
918
// in execute/unexecute. Currently setFixed forgets the anchors and setFloating recreates new ones...
922
// Make frame(set) non-floating
923
m_pFrameSet->setFixed();
925
m_pFrameSet->kWordDocument()->updateAllFrames();
926
m_pFrameSet->kWordDocument()->repaintAllViews();
927
m_pFrameSet->kWordDocument()->updateRulerFrameStartEnd();
928
m_pFrameSet->kWordDocument()->updateResizeHandles();
931
void KWFrameSetFloatingCommand::unexecute()
933
kdDebug() << "KWFrameSetFloatingCommand::unexecute" << endl;
936
// Make frame(set) floating again
937
m_pFrameSet->setFloating();
941
// Make frame(set) non-floating again
942
m_pFrameSet->setFixed();
944
m_pFrameSet->kWordDocument()->updateAllFrames();
945
m_pFrameSet->kWordDocument()->repaintAllViews();
946
m_pFrameSet->kWordDocument()->updateRulerFrameStartEnd();
947
m_pFrameSet->kWordDocument()->updateResizeHandles();
950
KWPageLayoutCommand::KWPageLayoutCommand( const QString &name,KWDocument *_doc,pageLayout &_oldLayout, pageLayout &_newLayout ) :
966
switch ( m_property ) {
968
m_oldValue = m_pFrameSet->getName();
971
m_oldValue = m_pFrameSet->isFloating() ? "true" : "false";
973
case FSP_KEEPASPECTRATION:
974
m_oldValue = static_cast<KWPictureFrameSet*>(m_pFrameSet)->keepAspectRatio() ? "keepRatio" : "dontKeepRatio";
976
case FSP_PROTECTSIZE:
977
m_oldValue = m_pFrameSet->isProtectSize() ? "true" : "false";
982
void KWFrameSetPropertyCommand::setValue( const QString &value )
984
kdDebug() << "KWFrameSetPropertyCommand::execute" << endl;
985
switch ( m_property ) {
987
m_pFrameSet->setName( value );
990
if ( value == "true" )
992
// Make frame(set) floating
993
m_pFrameSet->setFloating();
994
// ## We might want to store a list of anchors in the command, and reuse them
995
// in execute/unexecute. Currently setFixed forgets the anchors and setFloating recreates new ones...
997
else if(value == "false")
999
// Make frame(set) non-floating
1000
m_pFrameSet->setFixed();
1002
case FSP_KEEPASPECTRATION:
1003
if( value == "keepRatio")
1005
KWPictureFrameSet * frameSet=dynamic_cast<KWPictureFrameSet*>(m_pFrameSet);
1007
frameSet->setKeepAspectRatio( true );
1009
else if( value=="dontKeepRatio")
1011
KWPictureFrameSet * frameSet=dynamic_cast<KWPictureFrameSet*>(m_pFrameSet);
1013
frameSet->setKeepAspectRatio( false );
1016
case FSP_PROTECTSIZE:
1017
if( value == "true")
1018
m_pFrameSet->setProtectSize( true );
1020
m_pFrameSet->setProtectSize( false );
1021
m_pFrameSet->kWordDocument()->repaintResizeHandles();
1022
m_pFrameSet->kWordDocument()->updateCursorType();
1026
m_pFrameSet->kWordDocument()->updateResizeHandles();
1028
m_pFrameSet->kWordDocument()->updateAllFrames();
1029
m_pFrameSet->kWordDocument()->repaintAllViews();
1030
m_pFrameSet->kWordDocument()->updateRulerFrameStartEnd();
1033
void KWFrameSetPropertyCommand::execute()
1035
setValue( m_value );
1038
void KWFrameSetPropertyCommand::unexecute()
1040
setValue( m_oldValue );
1043
KWPageLayoutCommand::KWPageLayoutCommand( const QString &name,KWDocument *_doc,KWPageLayoutStruct &_oldLayout, KWPageLayoutStruct &_newLayout ) :
1044
KNamedCommand(name),
953
m_OldLayout(_oldLayout),
954
m_NewLayout(_newLayout)
1046
m_oldLayout(_oldLayout),
1047
m_newLayout(_newLayout)
958
1051
void KWPageLayoutCommand::execute()
960
m_pDoc->setPageLayout( m_NewLayout._pgLayout,m_NewLayout._cl, m_NewLayout._hf );
961
m_pDoc->updateRuler();
962
m_pDoc->updateResizeHandles();
963
m_pDoc->updateContentsSize();
964
m_pDoc->repaintAllViews();
1053
m_pDoc->setPageLayout( m_newLayout._pgLayout, m_newLayout._cl, m_newLayout._hf );
967
1056
void KWPageLayoutCommand::unexecute()
969
m_pDoc->setPageLayout( m_OldLayout._pgLayout,m_OldLayout._cl, m_OldLayout._hf);
970
m_pDoc->updateRuler();
971
m_pDoc->updateResizeHandles();
972
m_pDoc->updateContentsSize();
973
m_pDoc->repaintAllViews();
1058
m_pDoc->setPageLayout( m_oldLayout._pgLayout, m_oldLayout._cl, m_oldLayout._hf);
977
1062
KWDeleteFrameCommand::KWDeleteFrameCommand( const QString &name, KWFrame * frame ):
1063
KNamedCommand(name),
979
1064
m_frameIndex( frame ),
980
1065
m_copyFrame( frame->getCopy() )
1094
1190
kdDebug() << "KWDeleteTableCommand::execute" << endl;
1095
1191
KWDocument * doc = m_pTable->kWordDocument();
1096
1192
doc->removeFrameSet(m_pTable);
1193
m_pTable->setVisible( false );
1097
1194
doc->refreshDocStructure((int)Tables);
1098
1195
doc->updateAllFrames();
1196
m_pTable->updateFrames(); // not in the doc list anymore, so the above call didn't do it!
1100
1198
doc->repaintAllViews();
1199
doc->updateRulerFrameStartEnd();
1103
1203
void KWDeleteTableCommand::unexecute()
1105
1205
kdDebug() << "KWDeleteTableCommand::unexecute" << endl;
1106
1206
KWDocument * doc = m_pTable->kWordDocument();
1207
m_pTable->setVisible( true );
1107
1208
doc->addFrameSet(m_pTable);
1108
1209
doc->refreshDocStructure((int)Tables);
1109
1210
doc->updateAllFrames();
1111
1212
doc->repaintAllViews();
1213
doc->updateRulerFrameStartEnd();
1115
KWInsertColumnCommand::KWInsertColumnCommand( const QString &name, KWTableFrameSet * _table, int _col ):
1217
KWInsertColumnCommand::KWInsertColumnCommand( const QString &name, KWTableFrameSet * _table, int _col, double _maxRight ):
1218
KNamedCommand(name),
1117
1219
m_pTable(_table),
1121
m_ListFrameSet.clear();
1220
m_rc(new RemovedColumn()),
1222
m_maxRight(_maxRight),
1228
KWInsertColumnCommand::~KWInsertColumnCommand()
1124
1233
void KWInsertColumnCommand::execute()
1126
1235
kdDebug() << "KWInsertColumnCommand::execute" << endl;
1127
1236
KWDocument * doc = m_pTable->kWordDocument();
1128
m_pTable->insertCol( m_colPos,m_ListFrameSet);
1237
// a insert column = KWTableFrameSet::m_sDefaultColWidth, see kwtableframeset.cc
1238
if (m_pTable->boundingRect().right() + KWTableFrameSet::m_sDefaultColWidth >= static_cast<int>(m_maxRight))
1239
{ // must create space (resize the table)
1240
m_oldWidth = m_pTable->boundingRect().width();
1241
// here we calculate the new table size for a table that would take the
1242
// entire width of the page, which what the user wants 99% of the time.
1243
double newTableWidth =m_maxRight - m_pTable->boundingRect().left();
1244
double newColSize = newTableWidth / (m_pTable->getCols()+1);
1245
double resizeTableWidth = m_maxRight - m_pTable->boundingRect().left();
1246
m_pTable->resizeWidth(resizeTableWidth - newColSize);
1247
m_pTable->insertNewCol(m_colPos, newColSize);
1250
{ // simply insert the column without asking for a specific size :
1251
m_pTable->insertNewCol(m_colPos);
1253
Q_ASSERT(m_pTable->boundingRect().right() <= m_maxRight);
1129
1254
doc->updateAllFrames();
1131
1256
doc->updateResizeHandles( );
1393
1511
doc->repaintAllViews();
1515
KWChangeStartingPageCommand::KWChangeStartingPageCommand( const QString &name, KWDocument *_doc, int _oldStartingPage, int _newStartingPage):
1516
KNamedCommand(name),
1518
oldStartingPage(_oldStartingPage),
1519
newStartingPage(_newStartingPage)
1523
void KWChangeStartingPageCommand::execute()
1525
m_doc->getVariableCollection()->variableSetting()->setStartingPage(newStartingPage);
1526
m_doc->recalcVariables( VT_PGNUM );
1529
void KWChangeStartingPageCommand::unexecute()
1531
m_doc->getVariableCollection()->variableSetting()->setStartingPage(oldStartingPage);
1532
m_doc->recalcVariables( VT_PGNUM );
1535
KWChangeVariableSettingsCommand::KWChangeVariableSettingsCommand( const QString &name, KWDocument *_doc, bool _oldValue, bool _newValue, VariableProperties _type):
1536
KNamedCommand(name),
1539
m_bOldValue(_oldValue),
1540
m_bNewValue(_newValue)
1544
void KWChangeVariableSettingsCommand::changeValue( bool b )
1548
case VS_DISPLAYLINK:
1549
m_doc->getVariableCollection()->variableSetting()->setDisplayLink(b);
1550
m_doc->recalcVariables( VT_LINK );
1552
case VS_UNDERLINELINK:
1553
m_doc->getVariableCollection()->variableSetting()->setUnderlineLink(b);
1554
m_doc->recalcVariables( VT_LINK );
1556
case VS_DISPLAYCOMMENT:
1557
m_doc->getVariableCollection()->variableSetting()->setDisplayComment(b);
1558
m_doc->recalcVariables( VT_NOTE );
1560
case VS_DISPLAYFIELDCODE:
1561
m_doc->getVariableCollection()->variableSetting()->setDisplayFieldCode(b);
1562
//hack necessary otherwise footnote frameset is not refreshing
1563
//and footnote is not resize.
1564
m_doc->displayFootNoteFieldCode();
1565
m_doc->recalcVariables( VT_ALL );
1570
void KWChangeVariableSettingsCommand::execute()
1572
changeValue(m_bNewValue);
1575
void KWChangeVariableSettingsCommand::unexecute()
1577
changeValue(m_bOldValue);
1580
KWChangeCustomVariableValue::KWChangeCustomVariableValue( const QString &name, KWDocument *_doc,const QString & _oldValue, const QString & _newValue,KoCustomVariable *var):
1581
KNamedCommand(name),
1583
newValue(_newValue),
1584
oldValue(_oldValue),
1589
KWChangeCustomVariableValue::~KWChangeCustomVariableValue()
1593
void KWChangeCustomVariableValue::execute()
1596
m_var->setValue(newValue);
1597
m_doc->recalcVariables( VT_CUSTOM );
1600
void KWChangeCustomVariableValue::unexecute()
1603
m_var->setValue(oldValue);
1604
m_doc->recalcVariables( VT_CUSTOM );
1607
KWChangeVariableNoteText::KWChangeVariableNoteText( const QString &name, KWDocument *_doc,
1608
const QString &_oldValue,const QString &_newValue,
1609
KoNoteVariable *var):
1610
KNamedCommand(name),
1612
newValue(_newValue),
1613
oldValue(_oldValue),
1618
KWChangeVariableNoteText::~KWChangeVariableNoteText()
1622
void KWChangeVariableNoteText::execute()
1625
m_var->setNote(newValue);
1628
void KWChangeVariableNoteText::unexecute()
1631
m_var->setNote(oldValue);
1634
// TODO: move to libkotext to remove code duplication with kpresenter
1635
KWChangeLinkVariable::KWChangeLinkVariable( const QString &name, KWDocument *_doc,const QString & _oldHref, const QString & _newHref, const QString & _oldLink,const QString &_newLink, KoLinkVariable *var):
1636
KNamedCommand(name),
1647
void KWChangeLinkVariable::execute()
1649
m_var->setLink(newLink,newHref);
1650
m_doc->recalcVariables(VT_LINK);
1653
void KWChangeLinkVariable::unexecute()
1655
m_var->setLink(oldLink,oldHref);
1656
m_doc->recalcVariables(VT_LINK);
1659
KWHideShowHeader::KWHideShowHeader( const QString &name, KWDocument *_doc, bool _newValue):
1660
KNamedCommand(name),
1667
void KWHideShowHeader::execute()
1669
m_doc->setHeaderVisible(newValue );
1670
m_doc->updateHeaderButton();
1674
void KWHideShowHeader::unexecute()
1676
m_doc->setHeaderVisible(!newValue );
1677
m_doc->updateHeaderButton();
1680
KWHideShowFooter::KWHideShowFooter( const QString &name, KWDocument *_doc, bool _newValue):
1681
KNamedCommand(name),
1688
void KWHideShowFooter::execute()
1690
m_doc->setFooterVisible( newValue );
1691
m_doc->updateFooterButton();
1694
void KWHideShowFooter::unexecute()
1696
m_doc->setFooterVisible( !newValue );
1697
m_doc->updateFooterButton();
1701
KWProtectContentCommand::KWProtectContentCommand( const QString &name, KWTextFrameSet*frameset, bool _protect):
1702
KNamedCommand(name),
1703
m_pFrameSet(frameset),
1704
m_bProtect(_protect)
1709
void KWProtectContentCommand::execute()
1711
m_pFrameSet->textObject()->setProtectContent(m_bProtect);
1712
m_pFrameSet->kWordDocument()->updateTextFrameSetEdit();
1713
m_pFrameSet->kWordDocument()->testAndCloseAllFrameSetProtectedContent();
1714
m_pFrameSet->kWordDocument()->updateRulerInProtectContentMode();
1718
void KWProtectContentCommand::unexecute()
1720
m_pFrameSet->textObject()->setProtectContent(!m_bProtect);
1721
m_pFrameSet->kWordDocument()->updateTextFrameSetEdit();
1722
m_pFrameSet->kWordDocument()->testAndCloseAllFrameSetProtectedContent();
1723
m_pFrameSet->kWordDocument()->updateRulerInProtectContentMode();
1727
KWInsertRemovePageCommand::KWInsertRemovePageCommand( KWDocument *_doc, Command cmd, int pgNum)
1728
: KCommand(), m_doc(_doc), m_cmd(cmd), m_pgNum(pgNum)
1731
QString KWInsertRemovePageCommand::name() const
1733
return m_cmd == Insert ? i18n("Insert Page") // problem with after/before page
1734
: i18n("Delete Page %1").arg(m_pgNum);
1737
void KWInsertRemovePageCommand::execute()
1739
if ( m_cmd == Insert ) {
1740
m_doc->insertPage( m_pgNum );
1741
m_doc->afterAppendPage( m_pgNum ); // TODO rename to afterInsertPage
1743
m_doc->removePage( m_pgNum );
1744
m_doc->afterRemovePages();
1748
void KWInsertRemovePageCommand::unexecute()
1750
if ( m_cmd == Insert ) { // remove the page that was inserted
1751
m_doc->removePage( m_pgNum+1 );
1752
m_doc->afterRemovePages();
1753
} else { // Re-insert the page that was deleted
1754
m_doc->insertPage( m_pgNum-1 );
1755
m_doc->afterAppendPage( m_pgNum-1 ); // TODO rename to afterInsertPage
1759
FrameMarginsStruct::FrameMarginsStruct( KWFrame *frame )
1761
topMargin = frame->bTop();
1762
bottomMargin= frame->bBottom();
1763
leftMargin = frame->bLeft();
1764
rightMargin= frame->bRight();
1767
FrameMarginsStruct::FrameMarginsStruct( double _left, double _top, double _right, double _bottom ):
1769
bottomMargin(_bottom),
1776
KWFrameChangeFrameMarginCommand::KWFrameChangeFrameMarginCommand( const QString &name, FrameIndex _frameIndex, FrameMarginsStruct _frameMarginsBegin, FrameMarginsStruct _frameMarginsEnd ) :
1777
KNamedCommand(name),
1778
m_indexFrame(_frameIndex),
1779
m_frameMarginsBegin(_frameMarginsBegin),
1780
m_frameMarginsEnd(_frameMarginsEnd)
1784
void KWFrameChangeFrameMarginCommand::execute()
1786
KWFrameSet *frameSet = m_indexFrame.m_pFrameSet;
1787
Q_ASSERT( frameSet );
1788
KWFrame *frame = frameSet->frame(m_indexFrame.m_iFrameIndex);
1790
frame->setFrameMargins( m_frameMarginsEnd.leftMargin,m_frameMarginsEnd.topMargin , m_frameMarginsEnd.rightMargin, m_frameMarginsEnd.bottomMargin);
1791
frameSet->kWordDocument()->frameChanged( frame );
1794
void KWFrameChangeFrameMarginCommand::unexecute()
1796
KWFrameSet *frameSet = m_indexFrame.m_pFrameSet;
1797
Q_ASSERT( frameSet );
1798
KWFrame *frame = frameSet->frame(m_indexFrame.m_iFrameIndex);
1800
frame->setFrameMargins( m_frameMarginsBegin.leftMargin,m_frameMarginsBegin.topMargin , m_frameMarginsBegin.rightMargin, m_frameMarginsBegin.bottomMargin);
1801
frameSet->kWordDocument()->frameChanged( frame );
1804
KWChangeFootEndNoteSettingsCommand::KWChangeFootEndNoteSettingsCommand( const QString &name, KoParagCounter _oldCounter, KoParagCounter _newCounter ,bool _footNote ,KWDocument *_doc):
1805
KNamedCommand(name),
1806
m_oldCounter(_oldCounter),
1807
m_newCounter(_newCounter),
1808
m_footNote( _footNote ),
1813
void KWChangeFootEndNoteSettingsCommand::execute()
1815
changeCounter( m_newCounter);
1818
void KWChangeFootEndNoteSettingsCommand::unexecute()
1820
changeCounter( m_oldCounter);
1823
void KWChangeFootEndNoteSettingsCommand::changeCounter( KoParagCounter counter)
1827
static_cast<KWVariableSettings*>(m_doc->getVariableCollection()->variableSetting())->changeFootNoteCounter(counter );
1831
static_cast<KWVariableSettings*>(m_doc->getVariableCollection()->variableSetting())->changeEndNoteCounter(counter );
1833
m_doc->changeFootNoteConfig();
1837
KWChangeTabStopValueCommand::KWChangeTabStopValueCommand( const QString &name, double _oldValue, double _newValue, KWDocument *_doc):
1838
KNamedCommand(name),
1840
m_oldValue(_oldValue),
1841
m_newValue(_newValue)
1845
void KWChangeTabStopValueCommand::execute()
1847
m_doc->setTabStopValue ( m_newValue );
1850
void KWChangeTabStopValueCommand::unexecute()
1852
m_doc->setTabStopValue ( m_oldValue );
1857
FootNoteParameter::FootNoteParameter( KWFootNoteVariable *_var )
1859
noteType = _var->noteType();
1860
numberingType = _var->numberingType();
1861
manualString = _var->manualString();
1864
FootNoteParameter::FootNoteParameter( NoteType _noteType, KWFootNoteVariable::Numbering _numberingType, const QString &_manualString)
1866
noteType= _noteType;
1867
numberingType = _numberingType;
1868
manualString = _manualString;
1871
KWChangeFootNoteParametersCommand::KWChangeFootNoteParametersCommand( const QString &name, KWFootNoteVariable * _var, FootNoteParameter _oldParameter, FootNoteParameter _newParameter, KWDocument *_doc):
1872
KNamedCommand(name),
1875
m_oldParameter( _oldParameter ),
1876
m_newParameter( _newParameter)
1880
void KWChangeFootNoteParametersCommand::execute()
1882
changeVariableParameter( m_newParameter );
1885
void KWChangeFootNoteParametersCommand::unexecute()
1887
changeVariableParameter( m_oldParameter );
1890
void KWChangeFootNoteParametersCommand::changeVariableParameter( FootNoteParameter _param )
1892
m_var->setNoteType( _param.noteType );
1893
m_var->setNumberingType( _param.numberingType );
1894
m_var->setManualString( _param.manualString );
1895
m_var->setNumDisplay( -1 ); // force renumberFootNotes to recalc
1896
if ( m_var->numberingType()== KWFootNoteVariable::Manual)
1899
m_var->paragraph()->invalidate(0);
1900
m_var->paragraph()->setChanged( true );
1903
KWTextFrameSet * frameset = dynamic_cast<KWTextFrameSet *>( m_doc->frameSet( 0 ));
1904
Q_ASSERT( frameset );
1906
frameset->renumberFootNotes();
1908
// Re-layout the footnote/endnote frame
1909
KWFrame* footNoteFrame = m_var->frameSet()->frame( 0 );
1910
int framePage = footNoteFrame->pageNum();
1911
m_doc->recalcFrames( framePage, -1 );
1914
m_doc->delayedRepaintAllViews();
1918
KWChangeFootNoteLineSeparatorParametersCommand::KWChangeFootNoteLineSeparatorParametersCommand( const QString &name, SeparatorLinePos _oldValuePos, SeparatorLinePos _newValuePos, int _oldLength, int _newLength, double _oldWidth, double _newWidth, SeparatorLineLineType _oldLineType, SeparatorLineLineType _newLineType, KWDocument *_doc):
1919
KNamedCommand(name),
1921
m_oldValuePos(_oldValuePos),
1922
m_newValuePos(_newValuePos),
1923
m_oldLength(_oldLength),
1924
m_newLength(_newLength),
1925
m_oldWidth(_oldWidth),
1926
m_newWidth(_newWidth),
1927
m_oldLineType(_oldLineType),
1928
m_newLineType(_newLineType)
1933
void KWChangeFootNoteLineSeparatorParametersCommand::execute()
1935
changeLineSeparatorParameter( m_newValuePos, m_newLength, m_newWidth,m_newLineType );
1938
void KWChangeFootNoteLineSeparatorParametersCommand::unexecute()
1940
changeLineSeparatorParameter( m_oldValuePos, m_oldLength, m_oldWidth, m_oldLineType);
1943
void KWChangeFootNoteLineSeparatorParametersCommand::changeLineSeparatorParameter( SeparatorLinePos _pos, int _length, double _width, SeparatorLineLineType _type)
1945
m_doc->setFootNoteSeparatorLinePosition( _pos );
1946
m_doc->setFootNoteSeparatorLineLength( _length);
1947
m_doc->setFootNoteSeparatorLineWidth(_width );
1948
m_doc->setFootNoteSeparatorLineType( _type );
1949
m_doc->repaintAllViews();
1953
KWRenameBookmarkCommand::KWRenameBookmarkCommand( const QString &name, const QString & _oldname, const QString & _newName, KWDocument *_doc):
1954
KNamedCommand(name),
1956
m_oldName( _oldname),
1957
m_newName( _newName)
1961
void KWRenameBookmarkCommand::execute()
1963
m_doc->renameBookMark( m_oldName, m_newName);
1966
void KWRenameBookmarkCommand::unexecute()
1968
m_doc->renameBookMark( m_newName, m_oldName);