22#include "KWDocument.h"
23#include "KWTextFrameSet.h"
24#include "KWTableStyle.h"
25#include "KWTableTemplate.h"
26#include "KWTableFrameSet.h"
27#include "KWPartFrameSet.h"
28#include "KWTextDocument.h"
29#include "KWTextParag.h"
31#include "KWVariable.h"
32#include "KWOasisLoader.h"
33#include "KWFrameList.h"
34#include "KWFrameSet.h"
35#include "KWPictureFrameSet.h"
36#include "KWPageManager.h"
39#include <KoTextObject.h>
40#include <KoOasisStyles.h>
41#include <KoOasisContext.h>
45#include <KoOasisStore.h>
57class KWDeleteCustomItemVisitor :
public KoParagVisitor
60 KWDeleteCustomItemVisitor() : KoParagVisitor() { }
61 virtual bool visit( KoTextParag *parag,
int start,
int end )
63 kdDebug(32001) <<
"KWPasteTextCommand::execute " << parag->paragId() <<
" " << start <<
" " << end << endl;
64 for (
int i = start ; i < end ; ++i )
66 KoTextStringChar * ch = parag->at( i );
67 if ( ch->isCustom() ) {
68 KoTextCustomItem* item = ch->customItem();
69 item->setDeleted(
true );
70 parag->removeCustomItem(i);
71 KCommand* itemCmd = item->deleteCommand();
81KWPasteTextCommand::KWPasteTextCommand( KoTextDocument *d,
int parag,
int idx,
82 const TQCString & data )
83 : KoTextDocCommand( d ), m_parag( parag ), m_idx( idx ), m_data( data ), m_oldParagLayout( 0 )
87KoTextCursor * KWPasteTextCommand::execute( KoTextCursor *c )
89 KoTextParag *firstParag = doc->paragAt( m_parag );
91 tqWarning(
"can't locate parag at %d, last parag: %d", m_parag, doc->lastParag()->paragId() );
96 cursor.setParag( firstParag );
97 cursor.setIndex( m_idx );
98 c->setParag( firstParag );
100 TQDomDocument domDoc;
101 domDoc.setContent( m_data );
102 TQDomElement elem = domDoc.documentElement();
110 TQValueList<TQDomElement> listParagraphs;
111 TQDomElement paragraph = elem.firstChild().toElement();
112 for ( ; !paragraph.isNull() ; paragraph = paragraph.nextSibling().toElement() )
114 if ( paragraph.tagName() ==
"PARAGRAPH" )
116 TQString s = paragraph.namedItem(
"TEXT" ).toElement().text();
118 c->insert( s,
false );
120 if ( !paragraph.nextSibling().isNull() )
124 c->splitAndInsertEmptyParag(
false,
true );
128 listParagraphs.append( paragraph );
134 firstParag = doc->paragAt( m_parag );
137 uint count = listParagraphs.count();
138 TQValueList<TQDomElement>::Iterator it = listParagraphs.begin();
139 TQValueList<TQDomElement>::Iterator end = listParagraphs.end();
140 for ( uint item = 0 ; it != end ; ++it, ++item )
144 kdWarning() <<
"KWPasteTextCommand: parag==0L ! KWord bug, please report." << endl;
147 TQDomElement paragElem = *it;
149 if ( item == 0 && m_idx > 0 )
152 TQDomElement layout = paragElem.namedItem(
"LAYOUT" ).toElement();
153 if ( !layout.isNull() )
155 TQDomElement formatElem = layout.namedItem(
"FORMAT" ).toElement();
156 if ( !formatElem.isNull() )
158 KoTextFormat f = parag->
loadFormat( formatElem, 0L, TQFont(), TDEGlobal::locale()->language(),
false );
159 KoTextFormat * defaultFormat = doc->formatCollection()->format( &f );
161 int endIndex = (item == count-1) ? c->index() : parag->string()->length() - 1;
162 parag->setFormat( m_idx, endIndex - m_idx, defaultFormat,
true );
166 parag->
loadFormatting( paragElem, m_idx, (textFs->isMainFrameset()));
172 delete m_oldParagLayout;
173 m_oldParagLayout =
new KoParagLayout( parag->paragLayout() );
177 int len = (item == count-1) ? c->index() : parag->string()->length();
179 parag->setFormat( 0, len, parag->paragFormat(), true );
180 parag->
loadFormatting( paragElem, 0, (textFs->isMainFrameset()) );
182 parag->invalidate(0);
183 parag->setChanged(
true );
187 textFs->
textObject()->setNeedSpellCheck(
true );
189 KWDocument * doc = textFs->kWordDocument();
190 doc->processPictureRequests();
194 doc->pasteFrames( elem, 0,
196 (textFs->isMainFrameset()) ,
198 doc->completePasting();
200 m_lastParag = c->parag()->paragId();
201 m_lastIndex = c->index();
205KoTextCursor * KWPasteTextCommand::unexecute( KoTextCursor *c )
207 KoTextParag *firstParag = doc->paragAt( m_parag );
209 tqWarning(
"can't locate parag at %d, last parag: %d", m_parag, doc->lastParag()->paragId() );
212 cursor.setParag( firstParag );
213 cursor.setIndex( m_idx );
214 doc->setSelectionStart( KoTextDocument::Temp, &cursor );
216 KoTextParag *lastParag = doc->paragAt( m_lastParag );
218 tqWarning(
"can't locate parag at %d, last parag: %d", m_lastParag, doc->lastParag()->paragId() );
221 Q_ASSERT( lastParag->document() );
227 cursor.setParag( lastParag );
228 cursor.setIndex( m_lastIndex );
229 doc->setSelectionEnd( KoTextDocument::Temp, &cursor );
231 KWDeleteCustomItemVisitor visitor;
232 doc->visitSelection( KoTextDocument::Temp, &visitor );
234 doc->removeSelectedText( KoTextDocument::Temp, c );
240 Q_ASSERT( m_oldParagLayout );
241 if ( m_oldParagLayout )
242 firstParag->setParagLayout( *m_oldParagLayout );
248KWOasisPasteCommand::KWOasisPasteCommand( KoTextDocument *d,
int parag,
int idx,
249 const TQByteArray& data )
250 : KoTextDocCommand( d ), m_parag( parag ), m_idx( idx ), m_data( data ), m_oldParagLayout( 0 )
254KoTextCursor * KWOasisPasteCommand::execute( KoTextCursor *c )
256 KoTextParag *firstParag = doc->paragAt( m_parag );
258 tqWarning(
"can't locate parag at %d, last parag: %d", m_parag, doc->lastParag()->paragId() );
263 cursor.setParag( firstParag );
264 cursor.setIndex( m_idx );
265 c->setParag( firstParag );
266 c->setIndex( m_idx );
270 TQBuffer buffer( m_data );
272 KoStore * store = KoStore::createStore( &buffer, KoStore::Read );
273 KWDocument* kwdoc = textdoc->
textFrameSet()->kWordDocument();
274 KWOasisLoader loader( kwdoc );
275 loader.insertOasisData( store, c );
279 m_lastParag = c->parag()->paragId();
280 m_lastIndex = c->index();
284KoTextCursor * KWOasisPasteCommand::unexecute( KoTextCursor *c )
286 KoTextParag *firstParag = doc->paragAt( m_parag );
288 tqWarning(
"can't locate parag at %d, last parag: %d", m_parag, doc->lastParag()->paragId() );
291 cursor.setParag( firstParag );
292 cursor.setIndex( m_idx );
293 doc->setSelectionStart( KoTextDocument::Temp, &cursor );
295 KoTextParag *lastParag = doc->paragAt( m_lastParag );
297 tqWarning(
"can't locate parag at %d, last parag: %d", m_lastParag, doc->lastParag()->paragId() );
300 Q_ASSERT( lastParag->document() );
307 cursor.setParag( lastParag );
308 cursor.setIndex( m_lastIndex );
309 doc->setSelectionEnd( KoTextDocument::Temp, &cursor );
311 KWDeleteCustomItemVisitor visitor;
312 doc->visitSelection( KoTextDocument::Temp, &visitor );
314 doc->removeSelectedText( KoTextDocument::Temp, c );
321 Q_ASSERT( m_oldParagLayout );
322 if ( m_oldParagLayout )
323 firstParag->setParagLayout( *m_oldParagLayout );
330KWTextDeleteCommand::KWTextDeleteCommand( KoTextDocument *d,
int i,
int idx,
const TQMemArray<KoTextStringChar> &str,
331 const CustomItemsMap & customItemsMap,
332 const TQValueList<KoParagLayout> & oldParagLayouts )
333 :KoTextDeleteCommand(d, i, idx, str, customItemsMap, oldParagLayouts)
338void KWTextDeleteCommand::createBookmarkList()
341 KoTextParag *s = doc ? doc->paragAt(
id ) : parag;
343 tqWarning(
"can't locate parag at %d, last parag: %d",
id, doc->lastParag()->paragId() );
348 TQValueList<KoParagLayout>::Iterator lit = m_oldParagLayouts.begin();
349 kdDebug(32500) <<
"KWTextDeleteCommand::createBookmarkList " << m_oldParagLayouts.count() <<
" parag layouts. First parag=" << s->paragId() << endl;
350 Q_ASSERT(
id == s->paragId() );
353 if ( lit != m_oldParagLayouts.end() )
355 kdDebug(32500) <<
"KWTextDeleteCommand::unexecute find bookmark in parag " << p->paragId() << endl;
366KoTextCursor *KWTextDeleteCommand::execute( KoTextCursor *c )
368 return KoTextDeleteCommand::execute( c );
371KoTextCursor *KWTextDeleteCommand::unexecute( KoTextCursor *c )
373 return KoTextDeleteCommand::unexecute( c );
378FrameIndex::FrameIndex(
KWFrame *frame )
384KWFrameBorderCommand::KWFrameBorderCommand(
const TQString &name, TQPtrList<FrameIndex> &_listFrameIndex, TQPtrList<FrameBorderTypeStruct> &_frameTypeBorder,
const KoBorder & _newBorder):
386 m_indexFrame(_listFrameIndex),
387 m_oldBorderFrameType(_frameTypeBorder),
388 m_newBorder( _newBorder)
392KWFrameBorderCommand::~KWFrameBorderCommand()
394 m_indexFrame.setAutoDelete(
true);
395 m_oldBorderFrameType.setAutoDelete(
true);
398void KWFrameBorderCommand::execute()
401 KWDocument *doc = 0L;
402 for ( tmp=m_indexFrame.first(); tmp != 0; tmp=m_indexFrame.next() )
405 doc = frameSet->kWordDocument();
408 FrameBorderTypeStruct *tmpFrameStruct=m_oldBorderFrameType.at(m_indexFrame.find(tmp));
410 switch( tmpFrameStruct->m_EFrameType)
412 case KoBorder::LeftBorder:
414 cell->setLeftBorder(m_newBorder);
416 frame->setLeftBorder(m_newBorder);
418 case KoBorder::RightBorder:
420 cell->setRightBorder(m_newBorder);
422 frame->setRightBorder(m_newBorder);
424 case KoBorder::TopBorder:
426 cell->setTopBorder(m_newBorder);
428 frame->setTopBorder(m_newBorder);
430 case KoBorder::BottomBorder:
432 cell->setBottomBorder(m_newBorder);
434 frame->setBottomBorder(m_newBorder);
449 doc->repaintAllViews();
453void KWFrameBorderCommand::unexecute()
456 KWDocument *doc = 0L;
457 for ( tmp=m_indexFrame.first(); tmp != 0; tmp=m_indexFrame.next() )
460 doc = frameSet->kWordDocument();
463 FrameBorderTypeStruct *tmpFrameStruct=m_oldBorderFrameType.at(m_indexFrame.find(tmp));
464 switch(tmpFrameStruct->m_EFrameType)
466 case KoBorder::LeftBorder:
468 cell->setLeftBorder(tmpFrameStruct->m_OldBorder);
470 frame->setLeftBorder(tmpFrameStruct->m_OldBorder);
472 case KoBorder::RightBorder:
474 cell->setRightBorder(tmpFrameStruct->m_OldBorder);
476 frame->setRightBorder(tmpFrameStruct->m_OldBorder);
478 case KoBorder::TopBorder:
480 cell->setTopBorder(tmpFrameStruct->m_OldBorder);
482 frame->setTopBorder(tmpFrameStruct->m_OldBorder);
484 case KoBorder::BottomBorder:
486 cell->setBottomBorder(tmpFrameStruct->m_OldBorder);
488 frame->setBottomBorder(tmpFrameStruct->m_OldBorder);
504 doc->repaintAllViews();
508KWFrameBackGroundColorCommand::KWFrameBackGroundColorCommand(
const TQString &name, TQPtrList<FrameIndex> &_listFrameIndex, TQPtrList<TQBrush> &_oldBrush,
const TQBrush & _newColor ):
510 m_indexFrame(_listFrameIndex),
511 m_oldBackGroundColor(_oldBrush),
512 m_newColor( _newColor)
516KWFrameBackGroundColorCommand::~KWFrameBackGroundColorCommand()
518 m_indexFrame.setAutoDelete(
true);
519 m_oldBackGroundColor.setAutoDelete(
true);
523void KWFrameBackGroundColorCommand::execute()
526 KWDocument * doc = 0L;
527 for ( tmp=m_indexFrame.first(); tmp != 0; tmp=m_indexFrame.next() )
530 if ( frameSet && (frameSet->
type() != FT_PICTURE) && (frameSet->
type() != FT_PART))
532 doc = frameSet->kWordDocument();
534 frame->setBackgroundColor(m_newColor);
539 doc->repaintAllViews();
542void KWFrameBackGroundColorCommand::unexecute()
545 KWDocument * doc = 0L;
546 for ( tmp=m_indexFrame.first(); tmp != 0; tmp=m_indexFrame.next() )
549 if ( frameSet && (frameSet->
type() != FT_PICTURE) && (frameSet->
type() != FT_PART) )
551 doc = frameSet->kWordDocument();
553 TQBrush *tmpFrameStruct=m_oldBackGroundColor.at(m_indexFrame.find(tmp));
554 frame->setBackgroundColor(*tmpFrameStruct);
560 doc->repaintAllViews();
563KWFrameStyleCommand::KWFrameStyleCommand(
const TQString &name,
KWFrame *_frame,
KWFrameStyle *_fs,
bool _repaintViews ) :
564 KNamedCommand( name )
568 repaintViews = _repaintViews;
573void KWFrameStyleCommand::execute()
575 applyFrameStyle( m_fs);
578void KWFrameStyleCommand::unexecute()
580 applyFrameStyle( m_oldValues);
583void KWFrameStyleCommand::applyFrameStyle(
KWFrameStyle * _sty )
586 m_frame->setBackgroundColor( _sty->backgroundColor() );
587 m_frame->setLeftBorder( _sty->leftBorder() );
588 m_frame->setRightBorder( _sty->rightBorder() );
589 m_frame->setTopBorder( _sty->topBorder() );
590 m_frame->setBottomBorder( _sty->bottomBorder() );
594 m_frame->
frameSet()->kWordDocument()->repaintAllViews();
598KWTableStyleCommand::KWTableStyleCommand(
const TQString &name,
KWFrame *_frame,
KWTableStyle *_ts,
bool _repaintViews ) :
599 KNamedCommand( name )
603 repaintViews = _repaintViews;
606 m_fsc =
new KWFrameStyleCommand(
"Apply Framestyle to Frame", m_frame, m_ts->frameStyle(), repaintViews );
610KWTableStyleCommand::~KWTableStyleCommand()
616void KWTableStyleCommand::execute()
621 if ( (m_ts) && ( m_frame->
frameSet()->
type() == FT_TEXT ) && ( m_ts->paragraphStyle() ) )
624 textObject->textDocument()->selectAll( KoTextDocument::Temp );
625 m_sc = textObject->applyStyleCommand( 0L, m_ts->paragraphStyle(), KoTextDocument::Temp, KoParagLayout::All, KoTextFormat::Format,
true, false );
626 textObject->textDocument()->removeSelection( KoTextDocument::Temp );
631 m_frame->
frameSet()->kWordDocument()->repaintAllViews();
635void KWTableStyleCommand::unexecute()
644 m_frame->
frameSet()->kWordDocument()->repaintAllViews();
647KWTableTemplateCommand::KWTableTemplateCommand(
const TQString &name,
KWTableFrameSet *_table, KWTableTemplate *_tt ) :
648 KNamedCommand( name )
654 m_tableCommands =
new KMacroCommand(
"Apply Tablestyles to Table" );
658 unsigned int rows = m_table->getRows();
659 unsigned int cols = m_table->getColumns();
661 for (
unsigned int i = 0; i < rows; i++ )
663 for (
unsigned int j = 0; j < cols; j++ )
665 if ( (i==0) && (j==0) )
666 cell = m_tt->pTopLeftCorner();
668 if ( (i==0) && ( j==(cols-1) ) )
669 cell = m_tt->pTopRightCorner();
671 if ( ( i==(rows-1) ) && (j==0) )
672 cell = m_tt->pBottomLeftCorner();
674 if ( ( i==(rows-1) ) && ( j==(cols-1) ) )
675 cell = m_tt->pBottomRightCorner();
677 if ( ( i==0 ) && ( j>0 ) && ( j<(cols-1) ) )
678 cell = m_tt->pFirstRow();
680 if ( ( j==0 ) && ( i>0 ) && ( i<(rows-1) ) )
681 cell = m_tt->pFirstCol();
683 if ( ( i==(rows-1) ) && ( j>0 ) && ( j<(cols-1) ) )
684 cell = m_tt->pLastRow();
686 if ( ( j==(cols-1) ) && ( i>0 ) && ( i<(rows-1) ) )
687 cell = m_tt->pLastCol();
689 if ( (i>0) && (j>0) && (i<(rows-1)) && (j<(cols-1)) )
690 cell = m_tt->pBodyCell();
692 m_tableCommands->addCommand(
new KWTableStyleCommand(
"Apply tablestyle to cell", m_table->cell(i,j)->frame(0),cell,
false ) );
697KWTableTemplateCommand::~KWTableTemplateCommand()
699 delete m_tableCommands;
702void KWTableTemplateCommand::execute()
704 m_tableCommands->execute();
705 m_table->kWordDocument()->repaintAllViews();
708void KWTableTemplateCommand::unexecute()
710 m_tableCommands->unexecute();
711 m_table->kWordDocument()->repaintAllViews();
715KWFrameResizeCommand::KWFrameResizeCommand(
const TQString &name,
const TQValueList<FrameIndex> &frameIndex,
const TQValueList<FrameResizeStruct> &frameResize )
716 : KNamedCommand(name), m_indexFrame(frameIndex), m_frameResize(frameResize) {
717 Q_ASSERT(m_indexFrame.count() == m_frameResize.count());
719KWFrameResizeCommand::KWFrameResizeCommand(
const TQString &name,
FrameIndex frameIndex,
const FrameResizeStruct &frameResize )
720 : KNamedCommand(name) {
721 m_indexFrame.append(frameIndex);
722 m_frameResize.append(frameResize);
725void KWFrameResizeCommand::execute()
727 TQValueList<FrameResizeStruct>::Iterator resizeIter = m_frameResize.begin();
728 TQValueList<FrameIndex>::Iterator iter = m_indexFrame.begin();
729 for(; iter != m_indexFrame.end() && resizeIter != m_frameResize.end(); ++resizeIter, ++iter ) {
731 FrameResizeStruct frs = *resizeIter;
734 Q_ASSERT( frameSet );
737 frame->setCoords(frs.newRect.left(),frs.newRect.top(),frs.newRect.right(),frs.newRect.bottom());
743 table->
recalcCols(cell->firstColumn(), cell->firstRow());
744 table->recalcRows(cell->firstColumn(), cell->firstRow());
748 table->recalcRows(0, 0);
752 KWDocument * doc = frameSet->kWordDocument();
757 doc->frameChanged( frame );
761void KWFrameResizeCommand::unexecute()
763 TQValueList<FrameResizeStruct>::Iterator resizeIter = m_frameResize.begin();
764 TQValueList<FrameIndex>::Iterator iter = m_indexFrame.begin();
765 for(; iter != m_indexFrame.end() && resizeIter != m_frameResize.end(); ++resizeIter, ++iter ) {
767 FrameResizeStruct frs = *resizeIter;
769 Q_ASSERT( frameSet );
772 frame->setCoords(frs.oldRect.left(),frs.oldRect.top(),frs.oldRect.right(),frs.oldRect.bottom());
778 table->
recalcCols(cell->firstColumn(), cell->firstRow());
779 table->recalcRows(cell->firstColumn(), cell->firstRow());
783 table->recalcRows(0, 0);
786 KWDocument * doc = frameSet->kWordDocument();
790 frame->updateRulerHandles();
793 doc->frameChanged( frame );
797KWFrameChangePictureCommand::KWFrameChangePictureCommand(
const TQString &name,
FrameIndex _frameIndex,
const KoPictureKey & _oldKey,
const KoPictureKey & _newKey ) :
799 m_indexFrame(_frameIndex),
805void KWFrameChangePictureCommand::execute()
807 KWFrameSet *frameSet = m_indexFrame.m_pFrameSet;
808 Q_ASSERT( frameSet );
809 KWFrame *frame = frameSet->
frame(m_indexFrame.m_iFrameIndex);
811 KWDocument * doc = frameSet->kWordDocument();
812 KWPictureFrameSet *frameset =
static_cast<KWPictureFrameSet *
>(frame->
frameSet());
813 frameset->reloadPicture( m_newKey );
814 frameSet->kWordDocument()->refreshDocStructure( frameSet->
type() );
815 doc->frameChanged( frame );
818void KWFrameChangePictureCommand::unexecute()
820 KWFrameSet *frameSet =m_indexFrame.m_pFrameSet;
821 KWFrame *frame=frameSet->
frame(m_indexFrame.m_iFrameIndex);
822 KWDocument * doc = frameSet->kWordDocument();
823 KWPictureFrameSet *frameset =
static_cast<KWPictureFrameSet *
>(frame->
frameSet());
824 frameset->reloadPicture( m_oldKey );
825 frameSet->kWordDocument()->refreshDocStructure( frameSet->
type() );
826 doc->frameChanged( frame );
830KWFramePartMoveCommand::KWFramePartMoveCommand(
const TQString &name,
FrameIndex _frameIndex, FrameResizeStruct _frameMove ) :
832 m_indexFrame(_frameIndex),
833 m_frameMove(_frameMove)
837void KWFramePartMoveCommand::execute()
839 KWFrameSet *frameSet = m_indexFrame.m_pFrameSet;
840 Q_ASSERT( frameSet );
841 KWFrame *frame = frameSet->
frame(m_indexFrame.m_iFrameIndex);
843 frame->setCoords(m_frameMove.newRect.left(),m_frameMove.newRect.top(),m_frameMove.newRect.right(),m_frameMove.newRect.bottom());
845 KWDocument * doc = frameSet->kWordDocument();
847 frame->updateRulerHandles();
848 doc->frameChanged( frame );
851void KWFramePartMoveCommand::unexecute()
853 KWFrameSet *frameSet =m_indexFrame.m_pFrameSet;
854 KWFrame *frame=frameSet->
frame(m_indexFrame.m_iFrameIndex);
855 frame->setCoords(m_frameMove.oldRect.left(),m_frameMove.oldRect.top(),m_frameMove.oldRect.right(),m_frameMove.oldRect.bottom());
857 KWDocument * doc = frameSet->kWordDocument();
858 frame->updateRulerHandles();
861 doc->frameChanged( frame );
864bool KWFramePartMoveCommand::frameMoved()
866 return (m_frameMove.oldRect!=m_frameMove.newRect);
869KWFramePartInternalCommand::KWFramePartInternalCommand(
const TQString &name,
KWPartFrameSet *part ) :
873 m_url = m_part->getChild()->document()->url();
876void KWFramePartInternalCommand::execute()
878 m_part->getChild()->document()->setStoreInternal(
true);
881void KWFramePartInternalCommand::unexecute()
883 m_part->getChild()->document()->setStoreInternal(
false);
884 m_part->getChild()->document()->setURL( m_url );
888KWFramePartExternalCommand::KWFramePartExternalCommand(
const TQString &name,
KWPartFrameSet *part ) :
894void KWFramePartExternalCommand::execute()
896 m_part->getChild()->document()->setStoreInternal(
false);
899void KWFramePartExternalCommand::unexecute()
901 m_part->getChild()->document()->setStoreInternal(
true);
905KWFrameMoveCommand::KWFrameMoveCommand(
const TQString &name,
906 const TQValueList<FrameIndex> & _frameIndex,
907 const TQValueList<FrameMoveStruct> & _frameMove ) :
909 m_indexFrame(_frameIndex),
910 m_frameMove(_frameMove)
914void KWFrameMoveCommand::execute()
916 bool needRelayout =
false;
917 KWDocument * doc = 0L;
918 TQValueList<FrameMoveStruct>::Iterator moveIt = m_frameMove.begin();
919 TQValueList<FrameIndex>::Iterator tmp = m_indexFrame.begin();
920 for( ; tmp != m_indexFrame.end() && moveIt != m_frameMove.end(); ++tmp, ++moveIt )
923 doc = frameSet->kWordDocument();
925 frame->moveTopLeft( (*moveIt).newPos );
927 frame->updateRulerHandles();
928 needRelayout = needRelayout || ( frame->runAround() != KWFrame::RA_NO );
932 doc->updateAllFrames();
936 doc->updateRulerFrameStartEnd();
937 doc->repaintAllViews();
941void KWFrameMoveCommand::unexecute()
943 bool needRelayout =
false;
944 KWDocument * doc = 0L;
945 TQValueList<FrameMoveStruct>::Iterator moveIt = m_frameMove.begin();
946 TQValueList<FrameIndex>::Iterator tmp = m_indexFrame.begin();
947 for( ; tmp != m_indexFrame.end() && moveIt != m_frameMove.end(); ++tmp, ++moveIt )
950 doc = frameSet->kWordDocument();
952 frame->moveTopLeft( (*moveIt).oldPos );
954 frame->updateRulerHandles();
955 needRelayout = needRelayout || ( frame->runAround() != KWFrame::RA_NO );
960 doc->updateAllFrames();
963 doc->updateRulerFrameStartEnd();
964 doc->repaintAllViews();
970 m_frameIndex( _frameAfter ),
971 m_frameBefore(_frameBefore),
972 m_frameAfter(_frameAfter->getCopy())
976KWFramePropertiesCommand::~KWFramePropertiesCommand()
978 delete m_frameBefore;
982void KWFramePropertiesCommand::execute()
984 kdDebug(32001) <<
"KWFrameChangeParamCommand::execute" << endl;
985 KWFrameSet *frameSet = m_frameIndex.m_pFrameSet;
986 Q_ASSERT( frameSet );
988 KWFrame *frame = frameSet->
frame( m_frameIndex.m_iFrameIndex );
990 frame->copySettings(m_frameAfter);
991 frame->frameStack()->
update();
993 KWDocument * doc = frameSet->kWordDocument();
996 doc->frameChanged( frame );
997 doc->updateAllFrames();
999 doc->repaintAllViews();
1000 doc->updateRulerFrameStartEnd();
1004void KWFramePropertiesCommand::unexecute()
1006 kdDebug(32001) <<
"KWFrameChangeParamCommand::unexecute" << endl;
1007 KWFrameSet *frameSet = m_frameIndex.m_pFrameSet;
1008 Q_ASSERT( frameSet );
1010 KWFrame *frame = frameSet->
frame( m_frameIndex.m_iFrameIndex );
1012 frame->copySettings(m_frameBefore);
1013 frame->frameStack()->
update();
1014 KWDocument * doc = frameSet->kWordDocument();
1017 doc->frameChanged( frame );
1018 doc->updateAllFrames();
1020 doc->repaintAllViews();
1021 doc->updateRulerFrameStartEnd();
1026KWFrameSetInlineCommand::KWFrameSetInlineCommand(
const TQString &name,
KWFrameSet *frameset,
bool value ) :
1027 KNamedCommand(name),
1028 m_pFrameSet( frameset ),
1031 m_oldValue = m_pFrameSet->isFloating();
1034void KWFrameSetInlineCommand::setValue(
bool value )
1036 kdDebug(32001) <<
"KWFrameSetInlineCommand::execute" << endl;
1050 m_pFrameSet->kWordDocument()->updateAllFrames();
1053void KWFrameSetInlineCommand::execute()
1055 setValue( m_value );
1058void KWFrameSetInlineCommand::unexecute()
1060 setValue( m_oldValue );
1063KWPageLayoutCommand::KWPageLayoutCommand(
const TQString &name,KWDocument *_doc,KWPageLayoutStruct &_oldLayout, KWPageLayoutStruct &_newLayout ) :
1064 KNamedCommand(name),
1066 m_oldLayout(_oldLayout),
1067 m_newLayout(_newLayout)
1071void KWPageLayoutCommand::execute()
1073 m_pDoc->setPageLayout( m_newLayout._pgLayout, m_newLayout._cl, m_newLayout._hf );
1076void KWPageLayoutCommand::unexecute()
1078 m_pDoc->setPageLayout( m_oldLayout._pgLayout, m_oldLayout._cl, m_oldLayout._hf);
1082KWDeleteFrameCommand::KWDeleteFrameCommand(
const TQString &name,
KWFrame * frame ):
1083 KNamedCommand(name),
1084 m_frameIndex( frame ),
1085 m_copyFrame( frame->getCopy() )
1089KWDeleteFrameCommand::KWDeleteFrameCommand(
const FrameIndex &frameIndex) :
1092 m_frameIndex = frameIndex;
1093 m_copyFrame = m_frameIndex.m_pFrameSet->
frame(m_frameIndex.m_iFrameIndex)->
getCopy();
1096KWDeleteFrameCommand::~KWDeleteFrameCommand()
1102void KWDeleteFrameCommand::execute()
1104 KWFrameSet *frameSet = m_frameIndex.m_pFrameSet;
1105 Q_ASSERT( frameSet );
1107 KWFrame *frame = frameSet->
frame( m_frameIndex.m_iFrameIndex );
1110kdDebug() <<
"delete frame " << m_frameIndex.m_iFrameIndex <<
" of " << frameSet->
name() << endl;
1111 KWDocument* doc = frameSet->kWordDocument();
1112 doc->terminateEditing( frameSet );
1113 doc->frameChanged( frame );
1114 frameSet->
deleteFrame( m_frameIndex.m_iFrameIndex );
1122 doc->refreshDocStructure( frameSet->
type() );
1123 doc->updateTextFrameSetEdit();
1126void KWDeleteFrameCommand::unexecute()
1128 KWFrameSet *frameSet = m_frameIndex.m_pFrameSet;
1130 frame->setFrameSet( frameSet );
1131 frameSet->addFrame( frame );
1135 partfs->setDeleted(
false );
1140 KWDocument* doc = frameSet->kWordDocument();
1141 doc->frameChanged( frame );
1144 doc->refreshDocStructure(frameSet->
type());
1145 doc->updateRulerFrameStartEnd();
1148KWCreateFrameCommand::KWCreateFrameCommand(
const TQString &name,
KWFrame * frame ) :
1153KWUngroupTableCommand::KWUngroupTableCommand(
const TQString &name,
KWTableFrameSet * _table ):
1154 KNamedCommand(name),
1157 m_ListFrame.clear();
1158 for ( KWTableFrameSet::TableIter i(m_pTable); i ; ++i ) {
1159 m_ListFrame.append( i.current() );
1163void KWUngroupTableCommand::execute()
1165 KWDocument * doc = m_pTable->kWordDocument();
1166 for ( KWTableFrameSet::TableIter i(m_pTable) ; i ; ++i ) {
1167 i->setGroupManager( 0L );
1168 doc->addFrameSet( i.current() );
1171 doc->removeFrameSet(m_pTable);
1179 refresh |=TextFrames;
1180 doc->refreshDocStructure(refresh);
1182 doc->updateAllFrames();
1183 doc->repaintAllViews();
1186void KWUngroupTableCommand::unexecute()
1190 KWDocument * doc = m_pTable->kWordDocument();
1192 for ( tmp=m_ListFrame.first(); tmp != 0; tmp=m_ListFrame.next() )
1195 doc->removeFrameSet(tmp);
1200 doc->addFrameSet(m_pTable);
1204 refresh |=TextFrames;
1205 doc->refreshDocStructure(refresh);
1208 doc->updateAllFrames();
1209 doc->repaintAllViews();
1213KWDeleteTableCommand::KWDeleteTableCommand(
const TQString &name,
KWTableFrameSet * _table ):
1214 KNamedCommand(name),
1220void KWDeleteTableCommand::execute()
1222 kdDebug(32001) <<
"KWDeleteTableCommand::execute" << endl;
1223 KWDocument * doc = m_pTable->kWordDocument();
1224 doc->removeFrameSet(m_pTable);
1226 doc->refreshDocStructure((
int)Tables);
1227 doc->updateAllFrames();
1230 doc->repaintAllViews();
1231 doc->updateRulerFrameStartEnd();
1235void KWDeleteTableCommand::unexecute()
1237 kdDebug(32001) <<
"KWDeleteTableCommand::unexecute" << endl;
1238 KWDocument * doc = m_pTable->kWordDocument();
1240 doc->addFrameSet(m_pTable);
1241 doc->refreshDocStructure((
int)Tables);
1242 doc->updateAllFrames();
1244 doc->repaintAllViews();
1245 doc->updateRulerFrameStartEnd();
1249KWInsertColumnCommand::KWInsertColumnCommand(
const TQString &name,
KWTableFrameSet * _table,
int _col,
double _maxRight ):
1250 KNamedCommand(name),
1252 m_rc(new RemovedColumn()),
1254 m_maxRight(_maxRight),
1260KWInsertColumnCommand::~KWInsertColumnCommand()
1265void KWInsertColumnCommand::execute()
1267 kdDebug(32001) <<
"KWInsertColumnCommand::execute" << endl;
1268 KWDocument * doc = m_pTable->kWordDocument();
1270 if (m_pTable->
boundingRect().right() + KWTableFrameSet::m_sDefaultColWidth >=
static_cast<int>(m_maxRight))
1275 double newTableWidth =m_maxRight - m_pTable->
boundingRect().left();
1276 double newColSize = newTableWidth / (m_pTable->
getColumns()+1);
1277 double resizeTableWidth = m_maxRight - m_pTable->
boundingRect().left();
1278 m_pTable->
resizeWidth(resizeTableWidth - newColSize);
1285 Q_ASSERT(m_pTable->
boundingRect().right() <= m_maxRight);
1286 doc->updateAllFrames();
1288 doc->repaintAllViews();
1291void KWInsertColumnCommand::unexecute()
1293 kdDebug(32001) <<
"KWInsertColumnCommand::unexecute" << endl;
1294 KWDocument * doc = m_pTable->kWordDocument();
1295 doc->terminateEditing(m_pTable);
1302 doc->updateAllFrames();
1304 doc->repaintAllViews();
1309KWInsertRowCommand::KWInsertRowCommand(
const TQString &name,
KWTableFrameSet * _table,
int _row ):
1310 KNamedCommand(name),
1319KWInsertRowCommand::~KWInsertRowCommand()
1324void KWInsertRowCommand::execute()
1326 kdDebug(32001) <<
"KWInsertRowCommand::execute" << endl;
1327 KWDocument * doc = m_pTable->kWordDocument();
1334 doc->updateAllFrames();
1336 doc->repaintAllViews();
1339void KWInsertRowCommand::unexecute()
1341 kdDebug(32001) <<
"KWInsertRowCommand::unexecute" << endl;
1342 KWDocument * doc = m_pTable->kWordDocument();
1344 doc->terminateEditing(m_pTable);
1347 doc->updateAllFrames();
1352KWRemoveRowCommand::KWRemoveRowCommand(
const TQString &name,
KWTableFrameSet * _table,
int _row ):
1353 KNamedCommand(name),
1361KWRemoveRowCommand::~KWRemoveRowCommand()
1366void KWRemoveRowCommand::execute()
1368 kdDebug(32001) <<
"KWRemoveRowCommand::execute" << endl;
1369 KWDocument * doc = m_pTable->kWordDocument();
1370 doc->terminateEditing(m_pTable);
1374 doc->updateAllFrames();
1378void KWRemoveRowCommand::unexecute()
1380 kdDebug(32001) <<
"KWRemoveRowCommand::unexecute" << endl;
1381 KWDocument * doc = m_pTable->kWordDocument();
1383 doc->updateAllFrames();
1385 doc->repaintAllViews();
1388KWRemoveColumnCommand::KWRemoveColumnCommand(
const TQString &name,
KWTableFrameSet * _table,
int _col ):
1389 KNamedCommand(name),
1391 m_rc(new RemovedColumn()),
1397KWRemoveColumnCommand::~KWRemoveColumnCommand()
1402void KWRemoveColumnCommand::execute()
1404 kdDebug(32001) <<
"KWRemoveColumnCommand::execute" << endl;
1405 KWDocument * doc = m_pTable->kWordDocument();
1406 doc->terminateEditing(m_pTable);
1409 doc->updateAllFrames();
1413void KWRemoveColumnCommand::unexecute()
1415 kdDebug(32001) <<
"KWRemoveColumnCommand::unexecute" << endl;
1416 KWDocument * doc = m_pTable->kWordDocument();
1418 doc->updateAllFrames();
1420 doc->repaintAllViews();
1425KWSplitCellCommand::KWSplitCellCommand(
const TQString &name,
KWTableFrameSet * _table,
unsigned int colBegin,
unsigned int rowBegin,
unsigned int colEnd,
unsigned int rowEnd ):
1426 KNamedCommand(name),
1428 m_colBegin(colBegin),
1429 m_rowBegin(rowBegin),
1436void KWSplitCellCommand::execute()
1438 kdDebug(32001) <<
"KWSplitCellCommand::execute" << endl;
1439 KWDocument * doc = m_pTable->kWordDocument();
1440 doc->terminateEditing(m_pTable);
1442 m_pTable->
splitCell(m_rowEnd, m_colEnd,m_colBegin,m_rowBegin,m_ListFrameSet);
1443 doc->updateAllFrames();
1447void KWSplitCellCommand::unexecute()
1449 kdDebug(32001) <<
"KWSplitCellCommand::unexecute" << endl;
1450 KWDocument * doc = m_pTable->kWordDocument();
1451 doc->terminateEditing(m_pTable);
1455 if(m_ListFrameSet.isEmpty())
1457 for (
unsigned int i = 0; i < m_pTable->
getColumns(); i++ )
1459 for (
unsigned int j = 0; j < m_pTable->
getRows(); j++ )
1461 if(j>=m_rowBegin && j<=(m_rowBegin+m_rowEnd-1)
1462 && i>=m_colBegin && i<=(m_colEnd+m_colBegin-1))
1465 if( !(j==m_rowBegin && i==m_colBegin))
1467 kdDebug(32001)<<
"store cell row :"<<j<<
" col :"<<i<<endl;
1469 m_ListFrameSet.append(cell);
1477 m_pTable->
joinCells(m_colBegin, m_rowBegin, m_colEnd+m_colBegin-1+cell->columnSpan()-1,
1478 m_rowBegin+m_rowEnd-1+cell->rowSpan()-1);
1480 doc->updateAllFrames();
1486KWJoinCellCommand::KWJoinCellCommand(
const TQString &name,
KWTableFrameSet * _table,
unsigned int colBegin,
unsigned int rowBegin,
unsigned int colEnd,
unsigned int rowEnd, TQPtrList<KWFrameSet> listFrameSet,TQPtrList<KWFrame> listCopyFrame):
1487 KNamedCommand(name),
1489 m_colBegin(colBegin),
1490 m_rowBegin(rowBegin),
1493 m_ListFrameSet(listFrameSet),
1494 m_copyFrame(listCopyFrame)
1498KWJoinCellCommand::~KWJoinCellCommand()
1500 m_copyFrame.setAutoDelete(
true );
1503void KWJoinCellCommand::execute()
1505 kdDebug(32001) <<
"KWJoinCellCommand::execute" << endl;
1506 KWDocument * doc = m_pTable->kWordDocument();
1507 doc->terminateEditing(m_pTable);
1508 m_pTable->
joinCells(m_colBegin,m_rowBegin,m_colEnd,m_rowEnd);
1509 doc->updateAllFrames();
1513void KWJoinCellCommand::unexecute()
1515 kdDebug(32001) <<
"KWJoinCellCommand::unexecute" << endl;
1516 KWDocument * doc = m_pTable->kWordDocument();
1517 doc->terminateEditing(m_pTable);
1518 m_pTable->
splitCell(m_rowEnd-m_rowBegin+1, m_colEnd-m_colBegin+1,m_colBegin,m_rowBegin,m_ListFrameSet,m_copyFrame);
1519 doc->updateAllFrames();
1524KWChangeStartingPageCommand::KWChangeStartingPageCommand(
const TQString &name, KWDocument *_doc,
int _oldStartingPage,
int _newStartingPage):
1525 KNamedCommand(name),
1527 oldStartingPage(_oldStartingPage),
1528 newStartingPage(_newStartingPage)
1532void KWChangeStartingPageCommand::execute()
1534 m_doc->variableCollection()->variableSetting()->setStartingPageNumber(newStartingPage);
1535 m_doc->recalcVariables( VT_PGNUM );
1538void KWChangeStartingPageCommand::unexecute()
1540 m_doc->variableCollection()->variableSetting()->setStartingPageNumber(oldStartingPage);
1541 m_doc->recalcVariables( VT_PGNUM );
1544KWChangeVariableSettingsCommand::KWChangeVariableSettingsCommand(
const TQString &name, KWDocument *_doc,
bool _oldValue,
bool _newValue, VariableProperties _type):
1545 KNamedCommand(name),
1548 m_bOldValue(_oldValue),
1549 m_bNewValue(_newValue)
1553void KWChangeVariableSettingsCommand::changeValue(
bool b )
1557 case VS_DISPLAYLINK:
1558 m_doc->variableCollection()->variableSetting()->setDisplayLink(b);
1559 m_doc->recalcVariables( VT_LINK );
1561 case VS_UNDERLINELINK:
1562 m_doc->variableCollection()->variableSetting()->setUnderlineLink(b);
1563 m_doc->recalcVariables( VT_LINK );
1565 case VS_DISPLAYCOMMENT:
1566 m_doc->variableCollection()->variableSetting()->setDisplayComment(b);
1567 m_doc->recalcVariables( VT_NOTE );
1569 case VS_DISPLAYFIELDCODE:
1570 m_doc->variableCollection()->variableSetting()->setDisplayFieldCode(b);
1573 m_doc->displayFootNoteFieldCode();
1574 m_doc->recalcVariables( VT_ALL );
1579void KWChangeVariableSettingsCommand::execute()
1581 changeValue(m_bNewValue);
1584void KWChangeVariableSettingsCommand::unexecute()
1586 changeValue(m_bOldValue);
1589KWChangeCustomVariableValue::KWChangeCustomVariableValue(
const TQString &name, KWDocument *_doc,
const TQString & _oldValue,
const TQString & _newValue,KoCustomVariable *var):
1590 KNamedCommand(name),
1592 newValue(_newValue),
1593 oldValue(_oldValue),
1598KWChangeCustomVariableValue::~KWChangeCustomVariableValue()
1602void KWChangeCustomVariableValue::execute()
1605 m_var->setValue(newValue);
1606 m_doc->recalcVariables( VT_CUSTOM );
1609void KWChangeCustomVariableValue::unexecute()
1612 m_var->setValue(oldValue);
1613 m_doc->recalcVariables( VT_CUSTOM );
1616KWChangeVariableNoteText::KWChangeVariableNoteText(
const TQString &name, KWDocument *_doc,
1617 const TQString &_oldValue,
const TQString &_newValue,
1618 KoNoteVariable *var):
1619 KNamedCommand(name),
1621 newValue(_newValue),
1622 oldValue(_oldValue),
1627KWChangeVariableNoteText::~KWChangeVariableNoteText()
1631void KWChangeVariableNoteText::execute()
1634 m_var->setNote(newValue);
1637void KWChangeVariableNoteText::unexecute()
1640 m_var->setNote(oldValue);
1644KWChangeLinkVariable::KWChangeLinkVariable(
const TQString &name, KWDocument *_doc,
const TQString & _oldHref,
const TQString & _newHref,
const TQString & _oldLink,
const TQString &_newLink, KoLinkVariable *var):
1645 KNamedCommand(name),
1656void KWChangeLinkVariable::execute()
1658 m_var->setLink(newLink,newHref);
1659 m_doc->recalcVariables(VT_LINK);
1662void KWChangeLinkVariable::unexecute()
1664 m_var->setLink(oldLink,oldHref);
1665 m_doc->recalcVariables(VT_LINK);
1668KWHideShowHeader::KWHideShowHeader(
const TQString &name, KWDocument *_doc,
bool _newValue):
1669 KNamedCommand(name),
1676void KWHideShowHeader::execute()
1678 m_doc->setHeaderVisible(newValue );
1679 m_doc->updateHeaderButton();
1683void KWHideShowHeader::unexecute()
1685 m_doc->setHeaderVisible(!newValue );
1686 m_doc->updateHeaderButton();
1689KWHideShowFooter::KWHideShowFooter(
const TQString &name, KWDocument *_doc,
bool _newValue):
1690 KNamedCommand(name),
1697void KWHideShowFooter::execute()
1699 m_doc->setFooterVisible( newValue );
1700 m_doc->updateFooterButton();
1703void KWHideShowFooter::unexecute()
1705 m_doc->setFooterVisible( !newValue );
1706 m_doc->updateFooterButton();
1710KWProtectContentCommand::KWProtectContentCommand(
const TQString &name,
KWTextFrameSet*frameset,
bool _protect):
1711 KNamedCommand(name),
1712 m_pFrameSet(frameset),
1713 m_bProtect(_protect)
1718void KWProtectContentCommand::execute()
1720 m_pFrameSet->setProtectContent(m_bProtect);
1721 m_pFrameSet->kWordDocument()->updateTextFrameSetEdit();
1722 m_pFrameSet->kWordDocument()->testAndCloseAllFrameSetProtectedContent();
1723 m_pFrameSet->kWordDocument()->updateRulerInProtectContentMode();
1727void KWProtectContentCommand::unexecute()
1729 m_pFrameSet->setProtectContent(!m_bProtect);
1730 m_pFrameSet->kWordDocument()->updateTextFrameSetEdit();
1731 m_pFrameSet->kWordDocument()->testAndCloseAllFrameSetProtectedContent();
1732 m_pFrameSet->kWordDocument()->updateRulerInProtectContentMode();
1736KWInsertRemovePageCommand::KWInsertRemovePageCommand( KWDocument *_doc, Command cmd,
int pgNum)
1737 : KCommand(), m_doc(_doc), m_cmd(cmd), m_pgNum(pgNum)
1740KWInsertRemovePageCommand::~KWInsertRemovePageCommand() {
1741 TQValueListIterator<KCommand*> cmdIter = childCommands.begin();
1742 for(;cmdIter != childCommands.end(); ++ cmdIter)
1746TQString KWInsertRemovePageCommand::name()
const
1748 return m_cmd == Insert ? i18n(
"Insert Page")
1749 : i18n(
"Delete Page %1").arg(m_pgNum);
1752void KWInsertRemovePageCommand::execute() {
1753 if ( m_cmd == Insert )
1759void KWInsertRemovePageCommand::unexecute() {
1760 if ( m_cmd == Insert )
1762 doRemove(m_pgNum+1);
1765 doInsert(m_pgNum-1);
1768void KWInsertRemovePageCommand::doRemove(
int pageNumber) {
1769 bool firstRun = childCommands.count() == 0;
1771 TQValueVector<FrameIndex> indexes;
1772 TQPtrList<KWFrame> frames = m_doc->framesInPage(pageNumber,
false);
1773 TQPtrListIterator<KWFrame> framesIter(frames);
1774 for(; framesIter.current(); ++framesIter)
1779 std::sort(indexes.begin(), indexes.end(), compareIndex);
1781 TQValueVector<FrameIndex>::iterator iter = indexes.begin();
1782 for(; iter != indexes.end(); ++iter)
1785 TQValueListIterator<KCommand*> cmdIter = childCommands.begin();
1786 for(;cmdIter != childCommands.end(); ++ cmdIter)
1787 (*cmdIter)->execute();
1790 KWPage* page = m_doc->pageManager()->page(pageNumber);
1793 const double pageHeight = page->
height();
1794 const double topOfPage = m_doc->pageManager()->topOfPage(pageNumber);
1795 m_doc->pageManager()->removePage( pageNumber );
1797 if(firstRun && m_doc->lastPage() >= pageNumber) {
1799 TQValueList<FrameIndex> indexes;
1800 TQValueList<FrameMoveStruct> moveStructs;
1801 TQPtrListIterator<KWFrameSet> fss = m_doc->framesetsIterator();
1802 for(;fss.current(); ++fss) {
1804 if(fs->isMainFrameset())
continue;
1805 if(fs->isHeaderOrFooter())
continue;
1806 if(fs->isFootEndNote())
continue;
1809 TQPtrListIterator<KWFrame> framesIter(frames);
1810 for(; framesIter.current(); ++framesIter) {
1812 if(frame->top() > topOfPage) {
1814 KoPoint before = frame->topLeft();
1815 frame->moveBy(0, -pageHeight);
1816 moveStructs.append(FrameMoveStruct(before, frame->topLeft()));
1821 childCommands.append(cmd);
1823 m_doc->afterRemovePages();
1826bool KWInsertRemovePageCommand::compareIndex(
const FrameIndex &index1,
const FrameIndex &index2) {
1827 if(index1.m_pFrameSet == index2.m_pFrameSet)
1828 return index1.m_iFrameIndex >= index2.m_iFrameIndex;
1829 return index1.m_pFrameSet >= index2.m_pFrameSet;
1833void KWInsertRemovePageCommand::doInsert(
int pageNumber) {
1834 m_doc->pageManager()->
insertPage( pageNumber );
1835 for(
int i=childCommands.count()-1; i > 0; i--)
1836 childCommands[i]->unexecute();
1837 m_doc->afterInsertPage( pageNumber );
1840FramePaddingStruct::FramePaddingStruct(
KWFrame *frame )
1848FramePaddingStruct::FramePaddingStruct(
double _left,
double _top,
double _right,
double _bottom ):
1850 bottomPadding(_bottom),
1852 rightPadding(_right)
1857KWFrameChangeFramePaddingCommand::KWFrameChangeFramePaddingCommand(
const TQString &name,
FrameIndex _frameIndex, FramePaddingStruct _framePaddingBegin, FramePaddingStruct _framePaddingEnd ) :
1858 KNamedCommand(name),
1859 m_indexFrame(_frameIndex),
1860 m_framePaddingBegin(_framePaddingBegin),
1861 m_framePaddingEnd(_framePaddingEnd)
1865void KWFrameChangeFramePaddingCommand::execute()
1867 KWFrameSet *frameSet = m_indexFrame.m_pFrameSet;
1868 Q_ASSERT( frameSet );
1869 KWFrame *frame = frameSet->
frame(m_indexFrame.m_iFrameIndex);
1871 frame->setFramePadding( m_framePaddingEnd.leftPadding,m_framePaddingEnd.topPadding , m_framePaddingEnd.rightPadding, m_framePaddingEnd.bottomPadding);
1872 frameSet->kWordDocument()->frameChanged( frame );
1875void KWFrameChangeFramePaddingCommand::unexecute()
1877 KWFrameSet *frameSet = m_indexFrame.m_pFrameSet;
1878 Q_ASSERT( frameSet );
1879 KWFrame *frame = frameSet->
frame(m_indexFrame.m_iFrameIndex);
1881 frame->setFramePadding( m_framePaddingBegin.leftPadding,m_framePaddingBegin.topPadding , m_framePaddingBegin.rightPadding, m_framePaddingBegin.bottomPadding);
1882 frameSet->kWordDocument()->frameChanged( frame );
1885KWChangeFootEndNoteSettingsCommand::KWChangeFootEndNoteSettingsCommand(
const TQString &name, KoParagCounter _oldCounter, KoParagCounter _newCounter ,
bool _footNote ,KWDocument *_doc):
1886 KNamedCommand(name),
1887 m_oldCounter(_oldCounter),
1888 m_newCounter(_newCounter),
1889 m_footNote( _footNote ),
1894void KWChangeFootEndNoteSettingsCommand::execute()
1896 changeCounter( m_newCounter);
1899void KWChangeFootEndNoteSettingsCommand::unexecute()
1901 changeCounter( m_oldCounter);
1904void KWChangeFootEndNoteSettingsCommand::changeCounter( KoParagCounter counter)
1908 static_cast<KWVariableSettings*
>(m_doc->variableCollection()->variableSetting())->changeFootNoteCounter(counter );
1912 static_cast<KWVariableSettings*
>(m_doc->variableCollection()->variableSetting())->changeEndNoteCounter(counter );
1914 m_doc->changeFootNoteConfig();
1918KWChangeTabStopValueCommand::KWChangeTabStopValueCommand(
const TQString &name,
double _oldValue,
double _newValue, KWDocument *_doc):
1919 KNamedCommand(name),
1921 m_oldValue(_oldValue),
1922 m_newValue(_newValue)
1926void KWChangeTabStopValueCommand::execute()
1928 m_doc->setTabStopValue ( m_newValue );
1931void KWChangeTabStopValueCommand::unexecute()
1933 m_doc->setTabStopValue ( m_oldValue );
1940 noteType = _var->noteType();
1941 numberingType = _var->numberingType();
1942 manualString = _var->manualString();
1945FootNoteParameter::FootNoteParameter( NoteType _noteType, KWFootNoteVariable::Numbering _numberingType,
const TQString &_manualString)
1947 noteType= _noteType;
1948 numberingType = _numberingType;
1949 manualString = _manualString;
1952KWChangeFootNoteParametersCommand::KWChangeFootNoteParametersCommand(
const TQString &name,
KWFootNoteVariable * _var, FootNoteParameter _oldParameter, FootNoteParameter _newParameter, KWDocument *_doc):
1953 KNamedCommand(name),
1956 m_oldParameter( _oldParameter ),
1957 m_newParameter( _newParameter)
1961void KWChangeFootNoteParametersCommand::execute()
1963 changeVariableParameter( m_newParameter );
1966void KWChangeFootNoteParametersCommand::unexecute()
1968 changeVariableParameter( m_oldParameter );
1971void KWChangeFootNoteParametersCommand::changeVariableParameter( FootNoteParameter _param )
1973 m_var->setNoteType( _param.noteType );
1974 m_var->setNumberingType( _param.numberingType );
1975 m_var->setManualString( _param.manualString );
1976 m_var->setNumDisplay( -1 );
1977 if ( m_var->numberingType()== KWFootNoteVariable::Manual)
1980 m_var->paragraph()->invalidate(0);
1981 m_var->paragraph()->setChanged(
true );
1985 Q_ASSERT( frameset );
1992 m_doc->recalcFrames( framePage, -1 );
1995 m_doc->delayedRepaintAllViews();
1999KWChangeFootNoteLineSeparatorParametersCommand::KWChangeFootNoteLineSeparatorParametersCommand(
const TQString &name, SeparatorLinePos _oldValuePos, SeparatorLinePos _newValuePos,
int _oldLength,
int _newLength,
double _oldWidth,
double _newWidth, SeparatorLineLineType _oldLineType, SeparatorLineLineType _newLineType, KWDocument *_doc):
2000 KNamedCommand(name),
2002 m_oldValuePos(_oldValuePos),
2003 m_newValuePos(_newValuePos),
2004 m_oldLength(_oldLength),
2005 m_newLength(_newLength),
2006 m_oldWidth(_oldWidth),
2007 m_newWidth(_newWidth),
2008 m_oldLineType(_oldLineType),
2009 m_newLineType(_newLineType)
2014void KWChangeFootNoteLineSeparatorParametersCommand::execute()
2016 changeLineSeparatorParameter( m_newValuePos, m_newLength, m_newWidth,m_newLineType );
2019void KWChangeFootNoteLineSeparatorParametersCommand::unexecute()
2021 changeLineSeparatorParameter( m_oldValuePos, m_oldLength, m_oldWidth, m_oldLineType);
2024void KWChangeFootNoteLineSeparatorParametersCommand::changeLineSeparatorParameter( SeparatorLinePos _pos,
int _length,
double _width, SeparatorLineLineType _type)
2026 m_doc->setFootNoteSeparatorLinePosition( _pos );
2027 m_doc->setFootNoteSeparatorLineLength( _length);
2028 m_doc->setFootNoteSeparatorLineWidth(_width );
2029 m_doc->setFootNoteSeparatorLineType( _type );
2030 m_doc->repaintAllViews();
2034KWRenameBookmarkCommand::KWRenameBookmarkCommand(
const TQString &name,
const TQString & _oldname,
const TQString & _newName, KWDocument *_doc):
2035 KNamedCommand(name),
2037 m_oldName( _oldname),
2038 m_newName( _newName)
2042void KWRenameBookmarkCommand::execute()
2044 m_doc->renameBookmark( m_oldName, m_newName);
2047void KWRenameBookmarkCommand::unexecute()
2049 m_doc->renameBookmark( m_newName, m_oldName);
2052KWResizeColumnCommand::KWResizeColumnCommand(
KWTableFrameSet *table,
int col,
double oldSize,
double newSize ):
2053 KNamedCommand( i18n(
"Resize Column") ),
2055 m_oldSize( oldSize ),
2056 m_newSize( newSize ),
2061void KWResizeColumnCommand::execute()
2063 m_table->resizeColumn(m_col, m_newSize);
2064 m_table->kWordDocument()->layout();
2065 m_table->kWordDocument()->repaintAllViews();
2068void KWResizeColumnCommand::unexecute()
2070 m_table->resizeColumn(m_col, m_oldSize);
2071 m_table->kWordDocument()->layout();
2072 m_table->kWordDocument()->repaintAllViews();
2075KWResizeRowCommand::KWResizeRowCommand(
KWTableFrameSet *table,
int row,
double oldSize,
double newSize ):
2076 KNamedCommand( i18n(
"Resize Row") ),
2078 m_oldSize( oldSize ),
2079 m_newSize( newSize ),
2084void KWResizeRowCommand::execute()
2086 m_table->resizeRow( m_row, m_newSize );
2087 m_table->kWordDocument()->repaintAllViews();
2090void KWResizeRowCommand::unexecute()
2092 m_table->resizeRow( m_row, m_oldSize );
2093 m_table->kWordDocument()->repaintAllViews();
Command created when deleting a frame.
void update()
Update the z-ordering around the frame we host the framelist for.
Command created when one or more frames are moved.
KWFramePropertiesCommand(const TQString &name, KWFrame *_frameBefore, KWFrame *_frameAfter)
A copy of frameAfter is done internally.
Class: KWFrameSet Base type, a frameset holds content as well as frames to show that content.
virtual void deleteFrame(unsigned int num, bool remove=true, bool recalc=true)
Delete a frame from the set of frames this frameSet has.
virtual FrameSetType type() const
The type of frameset.
const TQPtrList< KWFrame > & frameIterator() const
Iterator over the child frames.
int frameFromPtr(KWFrame *frame)
Get frame number.
KWTableFrameSet * groupmanager() const
returns the groupManager this frameset belongs to.
void setFixed()
Make this frameset fixed, i.e. not anchored.
KWFrame * frame(unsigned int _num) const
get a frame by number
void setFloating()
Make this frameset floating (anchored), as close to its current position as possible.
TQString name() const
get/set frameset name. For tables in particular, this must be unique
Info frameSetInfo() const
Returns the type of TextFrameSet this is.
bool isVisible(KWViewMode *viewMode=0L) const
Returns true if the frameset is visible.
void setGroupManager(KWTableFrameSet *gm)
make this frameset part of a groupmanager
Command created when applying a framestyle.
The user-visible style for frames (borders and background)
This class represents a single frame.
KWFrameSet * frameSet() const
Data stucture methods.
double paddingTop() const
get top padding
double paddingBottom() const
get bottom padding
void setMinimumFrameHeight(double h)
The property minimum frame height is used to make the automatic frame shrinking code stop.
double paddingLeft() const
get left padding
double paddingRight() const
get right padding
int pageNumber() const
The page on which this frame is.
KWFrame * getCopy()
returns a copy of self
void frameBordersChanged()
Marks a frame to have changed position/borders.
KWPage * insertPage(int pageNumber)
Inserts a new page at the specified position in the document.
This class represents a printed page of the document.
double height() const
return the height of this page (in pt)
A frameset that contains an embedded object (a KWDocumentChild)
This class implements tables by acting as the manager for the frame(set)s which make up the table cel...
void resizeWidth(double width)
change the width of the table, keeping the proportions of the cells (if one is wider than the others,...
void insertNewColumn(uint _idx, double width=KWTableFrameSet::m_sDefaultColWidth)
insert a column of new cells use the getRows() call to decide how many cells are created
void reInsertRow(RemovedRow &row)
replace a row that was removed with deleteRow()
void ungroup()
release the constrains of the table and allow all frames to be edited apart from each other.
virtual void updateFrames(int flags=0xff)
Called when our frames change, or when another frameset's frames change.
KoRect boundingRect()
Calculate the absolute size of the complete table.
void deleteColumn(uint _idx, RemovedColumn &rc)
remove all the cells in a certain column
void insertNewRow(uint _idx, bool _recalc=true, bool _removeable=false)
insert a row of new cells, use the getCols() call to decide how many cells are created
KCommand * splitCell(unsigned int intoRows, unsigned int intoColumns, unsigned int column, unsigned int row, TQPtrList< KWFrameSet > listFrameSet=TQPtrList< KWFrameSet >(), TQPtrList< KWFrame >listFrame=TQPtrList< KWFrame >())
split one cell into a number of cells and return a command for undo purposes.
virtual void setVisible(bool v)
set the visibility of the frameset.
void reInsertColumn(RemovedColumn &col)
replace a column that was removed with deleteColumn()
void recalcCols(uint column, uint row)
resize and position all cells
unsigned int getColumns() const
returns the number of columns
void addCell(Cell *cell)
Add a cell to this table, the cell should already have info like row, col and should already have a f...
void deleteRow(uint _idx, RemovedRow &rr, bool _recalc=true)
Remove all the cells in a certain row.
KCommand * joinCells(unsigned int firstColumn, unsigned int firstRow, unsigned int endColumn, unsigned int endRow)
merge cells to one cell.
unsigned int getRows() const
returns the number of rows
Command created when applying a tablestyle.
Table style (can created/modified/deleted by the user) A table style is simply a paragraph style and ...
This is our KoTextDocument reimplementation, to create KWTextParag instead of KoTextParags,...
KWTextFrameSet * textFrameSet() const
Return the text frameset in which this document is.
Class: KWTextFrameSet Contains text (KoTextObject) and frames to display that text.
KoTextObject * textObject() const
Return the contained text object.
void renumberFootNotes(bool repaint=true)
(Assuming this==main frameset), recalc the foot note numbers
This class extends KoTextParag for KWord-specific formatting stuff, custom items, loading and saving.
static KoTextFormat loadFormat(TQDomElement &formatElem, KoTextFormat *refFormat, const TQFont &defaultFont, const TQString &defaultLanguage, bool hyphanation)
Public for loading a style (KWord-1.3 XML)
void loadLayout(TQDomElement &attributes)
Load (from KWord-1.3 XML) and apply paragraph layout.
void loadFormatting(TQDomElement &attributes, int offset=0, bool loadFootNote=true)
Load (from KWord-1.3 XML) and apply <FORMAT> tags (used by KWTextParag::load and by KWPasteCommand)
RemovedRow and RemovedColumn implement the Memento design pattern.