00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "KPrDocument.h"
00023 #include "KPrPage.h"
00024 #include "KPrCommand.h"
00025 #include "KPrBackground.h"
00026 #include "KPrGroupObject.h"
00027
00028
00029 #include "KPrLineObject.h"
00030 #include "KPrEllipseObject.h"
00031 #include "KPrAutoformObject.h"
00032 #include "KPrFreehandObject.h"
00033 #include "KPrPolylineObject.h"
00034 #include "KPrBezierCurveObject.h"
00035 #include "KPrPolygonObject.h"
00036 #include "KPrClosedLineObject.h"
00037
00038 #include "KPrTextObject.h"
00039 #include "KPrPixmapObject.h"
00040
00041 #include "KPrPartObject.h"
00042 #include <KoRuler.h>
00043 #include "KPrPieObject.h"
00044 #include "KPrRectObject.h"
00045 #include "KPrView.h"
00046 #include "KoTextObject.h"
00047 #include "KPrTextDocument.h"
00048 #include <kdebug.h>
00049 #include "KPrVariableCollection.h"
00050 #include <KoRect.h>
00051 #include <KoSize.h>
00052 #include <KoPoint.h>
00053 #include <KoDom.h>
00054 #include <KoTextParag.h>
00055 #include <KoXmlNS.h>
00056 #include <KoStore.h>
00057 #include <KoOasisContext.h>
00058 #include <KoOasisStyles.h>
00059 #include <KoOasisStore.h>
00060
00061 #include <qxml.h>
00062 #include <qbuffer.h>
00063
00064
00065 KPrShadowCmd::KPrShadowCmd( const QString &_name, QPtrList<ShadowValues> &_oldShadow, ShadowValues _newShadow,
00066 QPtrList<KPrObject> &_objects, KPrDocument *_doc )
00067 : KNamedCommand( _name ), oldShadow( _oldShadow ), objects( _objects )
00068 {
00069 objects.setAutoDelete( false );
00070 oldShadow.setAutoDelete( false );
00071 doc = _doc;
00072 newShadow = _newShadow;
00073
00074 m_page = doc->findPage( objects );
00075
00076 QPtrListIterator<KPrObject> it( objects );
00077 for ( ; it.current() ; ++it )
00078 it.current()->incCmdRef();
00079 }
00080
00081 KPrShadowCmd::~KPrShadowCmd()
00082 {
00083 QPtrListIterator<KPrObject> it( objects );
00084 for ( ; it.current() ; ++it )
00085 it.current()->decCmdRef();
00086 oldShadow.setAutoDelete( true );
00087 oldShadow.clear();
00088 }
00089
00090 void KPrShadowCmd::execute()
00091 {
00092 QPtrListIterator<KPrObject> it( objects );
00093 for ( ; it.current() ; ++it )
00094 it.current()->setShadowParameter(newShadow.shadowDistance,
00095 newShadow.shadowDirection,
00096 newShadow.shadowColor);
00097 doc->repaint( false );
00098
00099 doc->updateSideBarItem( m_page );
00100 }
00101
00102 void KPrShadowCmd::unexecute()
00103 {
00104 for ( unsigned int i = 0; i < objects.count(); i++ )
00105 objects.at( i )->setShadowParameter(oldShadow.at(i)->shadowDistance,
00106 oldShadow.at(i)->shadowDirection,
00107 oldShadow.at(i)->shadowColor);
00108 doc->repaint( false );
00109
00110 doc->updateSideBarItem( m_page );
00111 }
00112
00113
00114 KPrSetOptionsCmd::KPrSetOptionsCmd( const QString &_name, QValueList<KoPoint> &_diffs, QPtrList<KPrObject> &_objects,
00115 double _gridX, double _gridY, double _oldGridX, double _oldGridY,
00116 const QColor &_txtBackCol, const QColor &_otxtBackCol, KPrDocument *_doc )
00117 : KNamedCommand( _name ),
00118 diffs( _diffs ),
00119 objects( _objects ),
00120 txtBackCol( _txtBackCol ),
00121 otxtBackCol( _otxtBackCol )
00122 {
00123 gridX = _gridX;
00124 gridY = _gridY;
00125 oldGridX = _oldGridX;
00126 oldGridY = _oldGridY;
00127 doc = _doc;
00128 QPtrListIterator<KPrObject> it( objects );
00129 for ( ; it.current() ; ++it )
00130 it.current()->incCmdRef();
00131 }
00132
00133 KPrSetOptionsCmd::~KPrSetOptionsCmd()
00134 {
00135 QPtrListIterator<KPrObject> it( objects );
00136 for ( ; it.current() ; ++it )
00137 it.current()->decCmdRef();
00138 }
00139
00140 void KPrSetOptionsCmd::execute()
00141 {
00142
00143 for ( unsigned int i = 0; i < objects.count(); i++ )
00144 objects.at( i )->moveBy( *diffs.at( i ) );
00145 doc->setGridValue( gridX, gridY, false );
00146 doc->updateRuler();
00147 doc->setTxtBackCol( txtBackCol );
00148 doc->repaint( false );
00149 }
00150
00151 void KPrSetOptionsCmd::unexecute()
00152 {
00153 for ( unsigned int i = 0; i < objects.count(); i++ )
00154 objects.at( i )->moveBy( -(*diffs.at( i )).x(), -(*diffs.at( i )).y() );
00155 doc->setGridValue( oldGridX, oldGridY, false );
00156 doc->updateRuler();
00157 doc->setTxtBackCol( otxtBackCol );
00158 doc->repaint( false );
00159 }
00160
00161 KPrSetBackCmd::KPrSetBackCmd( const QString &name, const KPrBackGround::Settings &settings,
00162 const KPrBackGround::Settings &oldSettings,
00163 bool useMasterBackground,
00164 bool takeGlobal, KPrDocument *doc, KPrPage *page )
00165 : KNamedCommand( name )
00166 , m_settings( settings )
00167 , m_oldSettings( oldSettings )
00168 , m_useMasterBackground( useMasterBackground )
00169 , m_oldUseMasterBackground( page->useMasterBackground() )
00170 , m_takeGlobal( takeGlobal )
00171 , m_doc( doc )
00172 , m_page( page )
00173 {
00174 }
00175
00176 void KPrSetBackCmd::execute()
00177 {
00178 if ( !m_takeGlobal ) {
00179 m_page->background()->setBackGround( m_settings );
00180 m_page->setUseMasterBackground( m_useMasterBackground );
00181 m_doc->restoreBackground( m_page );
00182 } else {
00183 QPtrListIterator<KPrPage> it( m_doc->getPageList() );
00184 for ( ; it.current() ; ++it )
00185 {
00186 it.current()->background()->setBackGround( m_settings );
00187 it.current()->setUseMasterBackground( m_useMasterBackground );
00188 m_doc->restoreBackground(it.current());
00189 }
00190
00191 }
00192 m_doc->repaint( false );
00193
00194 if ( m_takeGlobal ) {
00195 QPtrListIterator<KPrPage> it( m_doc->getPageList() );
00196 for ( int pos = 0; it.current(); ++it, ++pos ) {
00197 m_doc->updateSideBarItem( it.current() );
00198 }
00199 }
00200 else {
00201 m_doc->updateSideBarItem( m_page );
00202 }
00203 }
00204
00205 void KPrSetBackCmd::unexecute()
00206 {
00207 if ( !m_takeGlobal ) {
00208 m_page->background()->setBackGround( m_oldSettings );
00209 m_page->setUseMasterBackground( m_oldUseMasterBackground );
00210 m_doc->restoreBackground( m_page );
00211 } else {
00212 QPtrListIterator<KPrPage> it( m_doc->getPageList() );
00213 for ( ; it.current() ; ++it )
00214 {
00215 it.current()->background()->setBackGround( m_oldSettings );
00216 it.current()->setUseMasterBackground( m_oldUseMasterBackground );
00217 m_doc->restoreBackground(it.current());
00218 }
00219 }
00220 m_doc->repaint( false );
00221
00222 if ( m_takeGlobal ) {
00223 QPtrListIterator<KPrPage> it( m_doc->getPageList() );
00224 for ( int pos = 0; it.current(); ++it, ++pos ) {
00225 m_doc->updateSideBarItem( it.current() );
00226 }
00227 }
00228 else {
00229 m_doc->updateSideBarItem( m_page );
00230 }
00231 }
00232
00233 KPrRotateCmd::KPrRotateCmd( const QString &_name, float newAngle, QPtrList<KPrObject> &objects,
00234 KPrDocument *doc, bool addAngle )
00235 : KNamedCommand( _name ), m_doc( doc ), m_newAngle( newAngle ), m_addAngle( addAngle )
00236 {
00237 m_objects.setAutoDelete( false );
00238 m_oldAngles.setAutoDelete( false );
00239
00240 QPtrListIterator<KPrObject> it( objects );
00241 for ( ; it.current() ; ++it )
00242 {
00243 m_objects.append( it.current() );
00244
00245 RotateValues *old = new RotateValues;
00246 old->angle = it.current()->getAngle();
00247 m_oldAngles.append( old );
00248
00249 it.current()->incCmdRef();
00250 }
00251
00252 m_page = m_doc->findPage( m_objects );
00253 }
00254
00255 KPrRotateCmd::~KPrRotateCmd()
00256 {
00257 QPtrListIterator<KPrObject> it( m_objects );
00258 for ( ; it.current() ; ++it )
00259 it.current()->decCmdRef();
00260 m_oldAngles.setAutoDelete( true );
00261 m_oldAngles.clear();
00262 }
00263
00264 void KPrRotateCmd::execute()
00265 {
00266 QPtrListIterator<KPrObject> it( m_objects );
00267 for ( ; it.current() ; ++it )
00268 {
00269 if ( m_addAngle )
00270 it.current()->rotate( it.current()->getAngle() + m_newAngle );
00271 else
00272 it.current()->rotate( m_newAngle );
00273 }
00274 m_doc->updateRuler();
00275 m_doc->repaint( false );
00276
00277 m_doc->updateSideBarItem( m_page );
00278 }
00279
00280 void KPrRotateCmd::unexecute()
00281 {
00282 for ( unsigned int i = 0; i < m_objects.count(); i++ )
00283 m_objects.at(i)->rotate( m_oldAngles.at( i )->angle );
00284 m_doc->updateRuler();
00285 m_doc->repaint( false );
00286
00287 m_doc->updateSideBarItem( m_page );
00288 }
00289
00290
00291 KPrChgPixCmd::KPrChgPixCmd( const QString &_name, KPrPixmapObject *_oldObject, KPrPixmapObject *_newObject,
00292 KPrDocument *_doc, KPrPage *_page)
00293 : KNamedCommand( _name )
00294 {
00295 oldObject = _oldObject;
00296 newObject = _newObject;
00297 m_page=_page;
00298 doc = _doc;
00299 oldObject->incCmdRef();
00300 newObject->incCmdRef();
00301 newObject->setSize( oldObject->getSize() );
00302 newObject->setOrig( oldObject->getOrig() );
00303 }
00304
00305 KPrChgPixCmd::~KPrChgPixCmd()
00306 {
00307 oldObject->decCmdRef();
00308 newObject->decCmdRef();
00309 }
00310
00311 void KPrChgPixCmd::execute()
00312 {
00313 m_page->replaceObject( oldObject, newObject );
00314 doc->repaint( newObject );
00315
00316 doc->updateSideBarItem( m_page );
00317 }
00318
00319 void KPrChgPixCmd::unexecute()
00320 {
00321 m_page->replaceObject( newObject, oldObject );
00322 doc->repaint( oldObject );
00323
00324 doc->updateSideBarItem( m_page );
00325 }
00326
00327 KPrDeleteCmd::KPrDeleteCmd( const QString &_name, QPtrList<KPrObject> &_objects,
00328 KPrDocument *_doc, KPrPage *_page )
00329 : KNamedCommand( _name )
00330 , m_oldObjectList( _page->objectList() )
00331 , m_objectsToDelete( _objects )
00332 , m_doc( _doc )
00333 , m_page( _page )
00334 {
00335 QPtrListIterator<KPrObject> it( m_oldObjectList );
00336 for ( ; it.current() ; ++it )
00337 it.current()->incCmdRef();
00338 }
00339
00340 KPrDeleteCmd::~KPrDeleteCmd()
00341 {
00342 QPtrListIterator<KPrObject> it( m_oldObjectList );
00343 for ( ; it.current() ; ++it )
00344 it.current()->decCmdRef();
00345 }
00346
00347 void KPrDeleteCmd::execute()
00348 {
00349 bool textObj=false;
00350
00351 QPtrListIterator<KPrObject> it( m_oldObjectList );
00352 QPtrListIterator<KPrObject> itDelete( m_objectsToDelete );
00353 QPtrList<KPrObject> newObjectList;
00354 for ( ; it.current(); ++it )
00355 {
00356 if ( it.current() == itDelete.current() )
00357 {
00358 it.current()->setSelected( false );
00359 it.current()->removeFromObjList();
00360
00361 if ( !textObj && it.current()->getType() == OT_TEXT )
00362 {
00363 KPrTextObject * tmp = dynamic_cast<KPrTextObject *>( it.current() );
00364 if ( tmp )
00365 tmp->setEditingTextObj( false );
00366 textObj=true;
00367 }
00368 ++itDelete;
00369 }
00370 else
00371 {
00372 newObjectList.append( it.current() );
00373 }
00374 }
00375
00376 m_page->setObjectList( newObjectList );
00377
00378 for ( itDelete.toFirst(); itDelete.current(); ++itDelete )
00379 {
00380 QRect oldRect = m_doc->zoomHandler()->zoomRect( itDelete.current()->getRepaintRect() );
00381 m_doc->repaint( oldRect );
00382 }
00383 if(textObj)
00384 m_doc->updateRuler();
00385
00386 m_doc->updateSideBarItem( m_page );
00387 }
00388
00389 void KPrDeleteCmd::unexecute()
00390 {
00391 m_page->setObjectList( m_oldObjectList );
00392 QPtrListIterator<KPrObject> it( m_objectsToDelete );
00393 for ( ; it.current(); ++it )
00394 {
00395 it.current()->addToObjList();
00396 m_doc->repaint( it.current() );
00397 }
00398
00399 m_doc->updateSideBarItem( m_page );
00400 }
00401
00402
00403 KPrEffectCmd::KPrEffectCmd( const QString &_name, const QPtrList<KPrObject> &_objs,
00404 const QValueList<EffectStruct> &_oldEffects, EffectStruct _newEffect )
00405 : KNamedCommand( _name ), oldEffects( _oldEffects ),
00406 newEffect( _newEffect ), objs( _objs )
00407 {
00408 QPtrListIterator<KPrObject> it( objs );
00409 for ( ; it.current() ; ++it )
00410 it.current()->incCmdRef();
00411 }
00412
00413 KPrEffectCmd::~KPrEffectCmd()
00414 {
00415 QPtrListIterator<KPrObject> it( objs );
00416 for ( ; it.current() ; ++it )
00417 it.current()->decCmdRef();
00418 }
00419
00420 void KPrEffectCmd::execute()
00421 {
00422 QPtrListIterator<KPrObject> it( objs );
00423 for ( ; it.current() ; ++it )
00424 {
00425 it.current()->setAppearStep( newEffect.appearStep );
00426 it.current()->setEffect( newEffect.effect );
00427 it.current()->setEffect2( newEffect.effect2 );
00428 it.current()->setDisappear( newEffect.disappear );
00429 it.current()->setEffect3( newEffect.effect3 );
00430 it.current()->setDisappearStep( newEffect.disappearStep );
00431 it.current()->setAppearSpeed( newEffect.m_appearSpeed );
00432 it.current()->setDisappearSpeed( newEffect.m_disappearSpeed );
00433 it.current()->setAppearTimer( newEffect.appearTimer );
00434 it.current()->setDisappearTimer( newEffect.disappearTimer );
00435 it.current()->setAppearSoundEffect( newEffect.appearSoundEffect );
00436 it.current()->setDisappearSoundEffect( newEffect.disappearSoundEffect );
00437 it.current()->setAppearSoundEffectFileName( newEffect.a_fileName );
00438 it.current()->setDisappearSoundEffectFileName( newEffect.d_fileName );
00439 }
00440 }
00441
00442 void KPrEffectCmd::unexecute()
00443 {
00444 KPrObject *object = 0;
00445 for ( unsigned int i = 0; i < objs.count(); ++i ) {
00446 object = objs.at( i );
00447
00448 object->setAppearStep( oldEffects[ i ].appearStep );
00449 object->setEffect( oldEffects[ i ].effect );
00450 object->setEffect2( oldEffects[ i ].effect2 );
00451 object->setDisappear( oldEffects[ i ].disappear );
00452 object->setEffect3( oldEffects[ i ].effect3 );
00453 object->setDisappearStep( oldEffects[ i ].disappearStep );
00454 object->setAppearSpeed( oldEffects[ i ].m_appearSpeed );
00455 object->setDisappearSpeed( oldEffects[ i ].m_disappearSpeed );
00456 object->setAppearTimer( oldEffects[ i ].appearTimer );
00457 object->setDisappearTimer( oldEffects[ i ].disappearTimer );
00458 object->setAppearSoundEffect( oldEffects[ i ].appearSoundEffect );
00459 object->setDisappearSoundEffect( oldEffects[ i ].disappearSoundEffect );
00460 object->setAppearSoundEffectFileName( oldEffects[ i ].a_fileName );
00461 object->setDisappearSoundEffectFileName( oldEffects[ i ].d_fileName );
00462 }
00463 }
00464
00465 KPrGroupObjCmd::KPrGroupObjCmd( const QString &_name,
00466 const QPtrList<KPrObject> &_objects,
00467 KPrDocument *_doc, KPrPage *_page )
00468 : KNamedCommand( _name )
00469 , m_objectsToGroup( _objects )
00470 , m_oldObjectList( _page->objectList() )
00471 , m_doc( _doc )
00472 , m_page( _page )
00473 {
00474 m_groupObject = new KPrGroupObject( m_objectsToGroup );
00475 m_groupObject->incCmdRef();
00476 }
00477
00478 KPrGroupObjCmd::~KPrGroupObjCmd()
00479 {
00480 m_groupObject->decCmdRef();
00481 }
00482
00483 void KPrGroupObjCmd::execute()
00484 {
00485 KoRect r;
00486 int position = 0;
00487 QPtrListIterator<KPrObject> it( m_objectsToGroup );
00488 for ( ; it.current() ; ++it )
00489 {
00490 it.current()->setSelected( false );
00491 position = m_page->takeObject(it.current() );
00492 r |= it.current()->getRealRect();
00493 }
00494
00495 m_groupObject->setUpdateObjects( false );
00496 m_groupObject->setOrig( r.x(), r.y() );
00497 m_groupObject->setSize( r.width(), r.height() );
00498 m_page->insertObject( m_groupObject, position );
00499 m_groupObject->addToObjList();
00500 m_groupObject->setUpdateObjects( true );
00501 m_groupObject->setSelected( true );
00502 m_doc->refreshGroupButton();
00503
00504 m_doc->repaint( false );
00505
00506 m_doc->updateSideBarItem( m_page );
00507 }
00508
00509 void KPrGroupObjCmd::unexecute()
00510 {
00511 m_groupObject->setUpdateObjects( false );
00512
00513 m_page->setObjectList( m_oldObjectList );
00514 m_groupObject->removeFromObjList();
00515
00516 QPtrListIterator<KPrObject> it( m_objectsToGroup );
00517 for ( ; it.current() ; ++it )
00518 {
00519 it.current()->addToObjList();
00520 it.current()->setSelected( true );
00521 }
00522
00523 m_doc->refreshGroupButton();
00524
00525 m_doc->repaint( false );
00526
00527 m_doc->updateSideBarItem( m_page );
00528 }
00529
00530 UnGroupObjCmd::UnGroupObjCmd( const QString &_name,
00531 KPrGroupObject *grpObj_,
00532 KPrDocument *_doc, KPrPage *_page )
00533 : KNamedCommand( _name )
00534 , m_groupedObjects( grpObj_->getObjects() )
00535 , m_groupObject( grpObj_ )
00536 , m_doc( _doc )
00537 , m_page( _page )
00538 {
00539 m_groupObject->incCmdRef();
00540 }
00541
00542 UnGroupObjCmd::~UnGroupObjCmd()
00543 {
00544 m_groupObject->decCmdRef();
00545 }
00546
00547 void UnGroupObjCmd::execute()
00548 {
00549 m_groupObject->setUpdateObjects( false );
00550
00551 int position = m_page->takeObject( m_groupObject );
00552 m_groupObject->removeFromObjList();
00553
00554 QPtrListIterator<KPrObject> it( m_groupedObjects );
00555 for ( it.toLast(); it.current() ; --it )
00556 {
00557 m_page->insertObject( it.current(), position );
00558 it.current()->addToObjList();
00559 it.current()->setSelected( true );
00560 }
00561
00562 m_doc->refreshGroupButton();
00563
00564 m_doc->repaint( false );
00565
00566 m_doc->updateSideBarItem( m_page );
00567 }
00568
00569 void UnGroupObjCmd::unexecute()
00570 {
00571 KoRect r=KoRect();
00572 int position = 0;
00573 QPtrListIterator<KPrObject> it( m_groupedObjects );
00574 for ( ; it.current() ; ++it )
00575 {
00576 it.current()->setSelected( false );
00577 position = m_page->takeObject( it.current() );
00578 r |= it.current()->getRealRect();
00579 }
00580
00581 m_groupObject->setUpdateObjects( false );
00582 m_groupObject->setOrig( r.x(), r.y() );
00583 m_groupObject->setSize( r.width(), r.height() );
00584 m_page->insertObject( m_groupObject, position );
00585 m_groupObject->addToObjList();
00586 m_groupObject->setUpdateObjects( true );
00587 m_groupObject->setSelected( true );
00588 m_doc->refreshGroupButton();
00589
00590 m_doc->repaint( false );
00591
00592 m_doc->updateSideBarItem( m_page );
00593 }
00594
00595 KPrInsertCmd::KPrInsertCmd( const QString &name, const QValueList<KPrObject *> objects,
00596 KPrDocument *doc, KPrPage *page )
00597 : KNamedCommand( name )
00598 , m_objects( objects )
00599 , m_object( 0 )
00600 , m_doc( doc )
00601 , m_page( page )
00602 {
00603 QValueListConstIterator<KPrObject *> it( m_objects.begin() );
00604 for ( ; it != m_objects.end(); ++it )
00605 {
00606 ( *it )->incCmdRef();
00607 }
00608 }
00609
00610 KPrInsertCmd::KPrInsertCmd( const QString &name, KPrObject *object,
00611 KPrDocument *doc, KPrPage *page )
00612 : KNamedCommand( name )
00613 , m_object( object )
00614 , m_doc( doc )
00615 , m_page( page )
00616 {
00617 m_object->incCmdRef();
00618 }
00619
00620 KPrInsertCmd::~KPrInsertCmd()
00621 {
00622 if ( m_object )
00623 {
00624 m_object->decCmdRef();
00625 }
00626 else
00627 {
00628 QValueListConstIterator<KPrObject *> it( m_objects.begin() );
00629 for ( ; it != m_objects.end(); ++it )
00630 {
00631 ( *it )->decCmdRef();
00632 }
00633 }
00634 }
00635
00636 void KPrInsertCmd::execute()
00637 {
00638 if ( m_object )
00639 {
00640 m_page->appendObject( m_object );
00641 m_object->addToObjList();
00642 if ( m_object->getType() == OT_TEXT )
00643 m_doc->updateRuler();
00644 m_doc->repaint( m_object );
00645 }
00646 else
00647 {
00648 m_page->appendObjects( m_objects );
00649 QValueListConstIterator<KPrObject *> it( m_objects.begin() );
00650 bool updateRuler = false;
00651 for ( ; it != m_objects.end(); ++it )
00652 {
00653 ( *it )->addToObjList();
00654 if ( ( *it )->getType() == OT_TEXT )
00655 updateRuler = true;
00656 m_doc->repaint( *it );
00657 }
00658 if ( updateRuler )
00659 m_doc->updateRuler();
00660 }
00661
00662 m_doc->updateSideBarItem( m_page );
00663 }
00664
00665 void KPrInsertCmd::unexecute()
00666 {
00667 if ( m_object )
00668 {
00669 QRect oldRect = m_doc->zoomHandler()->zoomRect( m_object->getRepaintRect() );
00670 QPtrList<KPrObject> list(m_page->objectList());
00671 if ( list.findRef( m_object ) != -1 ) {
00672 m_page->takeObject( m_object );
00673 m_object->removeFromObjList();
00674 if ( m_object->getType() == OT_TEXT )
00675 {
00676 m_doc->terminateEditing( (KPrTextObject*)m_object );
00677 ((KPrTextObject*)m_object)->setEditingTextObj( false );
00678 m_doc->updateRuler();
00679 }
00680 }
00681 m_doc->repaint( oldRect );
00682 }
00683 else
00684 {
00685 QPtrList<KPrObject> list(m_page->objectList());
00686 bool updateRuler = false;
00687
00688 QValueListConstIterator<KPrObject *> it( m_objects.begin() );
00689 for ( ; it != m_objects.end(); ++it )
00690 {
00691 if ( list.findRef( *it ) != -1 )
00692 {
00693 m_page->takeObject( *it );
00694 ( *it )->removeFromObjList();
00695 if ( ( *it )->getType() == OT_TEXT )
00696 {
00697 m_doc->terminateEditing( (KPrTextObject*)( *it ) );
00698 ( (KPrTextObject*) *it )->setEditingTextObj( false );
00699 updateRuler = true;
00700 }
00701 }
00702 }
00703 if ( updateRuler )
00704 m_doc->updateRuler();
00705
00706 m_doc->repaint( false );
00707 }
00708
00709 m_doc->updateSideBarItem( m_page );
00710 }
00711
00712 KPrLowerRaiseCmd::KPrLowerRaiseCmd( const QString &_name, const QPtrList<KPrObject>& _oldList,
00713 const QPtrList<KPrObject>& _newList, KPrDocument *_doc,
00714 KPrPage *_page )
00715 : KNamedCommand( _name )
00716 {
00717 oldList = _oldList;
00718 newList = _newList;
00719 m_page=_page;
00720 oldList.setAutoDelete( false );
00721 newList.setAutoDelete( false );
00722 doc = _doc;
00723
00724 QPtrListIterator<KPrObject> it( oldList );
00725 for ( ; it.current() ; ++it )
00726 it.current()->incCmdRef();
00727 }
00728
00729 KPrLowerRaiseCmd::~KPrLowerRaiseCmd()
00730 {
00731 QPtrListIterator<KPrObject> it( oldList );
00732 for ( ; it.current() ; ++it )
00733 it.current()->decCmdRef();
00734 }
00735
00736 void KPrLowerRaiseCmd::execute()
00737 {
00738 m_page->setObjectList( newList );
00739 doc->repaint( false );
00740
00741 doc->updateSideBarItem( m_page );
00742 }
00743
00744 void KPrLowerRaiseCmd::unexecute()
00745 {
00746 m_page->setObjectList( oldList );
00747 doc->repaint( false );
00748
00749 doc->updateSideBarItem( m_page );
00750 }
00751
00752
00753 KPrMoveByCmd::KPrMoveByCmd( const QString &_name, const KoPoint &_diff, QPtrList<KPrObject> &_objects,
00754 KPrDocument *_doc,KPrPage *_page )
00755 : KNamedCommand( _name ), diff( _diff ), objects( _objects )
00756 {
00757 objects.setAutoDelete( false );
00758 doc = _doc;
00759 m_page=_page;
00760 QPtrListIterator<KPrObject> it( objects );
00761 for ( ; it.current() ; ++it )
00762 {
00763 it.current()->incCmdRef();
00764 }
00765 }
00766
00767 KPrMoveByCmd::~KPrMoveByCmd()
00768 {
00769 QPtrListIterator<KPrObject> it( objects );
00770 for ( ; it.current() ; ++it )
00771 it.current()->decCmdRef();
00772 }
00773
00774 void KPrMoveByCmd::execute()
00775 {
00776 QRect oldRect;
00777
00778 for ( unsigned int i = 0; i < objects.count(); i++ ) {
00779 oldRect = doc->zoomHandler()->zoomRect( objects.at( i )->getRepaintRect() );
00780 objects.at( i )->moveBy( diff );
00781 if ( objects.at( i )->getType() == OT_TEXT )
00782 {
00783 if(objects.at(i)->isSelected())
00784 doc->updateRuler();
00785 }
00786 doc->repaint( oldRect );
00787 doc->repaint( objects.at( i ) );
00788 }
00789
00790 doc->updateSideBarItem( m_page );
00791 doc->updateObjectStatusBarItem();
00792 }
00793
00794 void KPrMoveByCmd::unexecute()
00795 {
00796 QRect oldRect;
00797
00798 for ( unsigned int i = 0; i < objects.count(); i++ ) {
00799 oldRect = doc->zoomHandler()->zoomRect( objects.at( i )->getRepaintRect() );
00800 objects.at( i )->moveBy( -diff.x(), -diff.y() );
00801 if ( objects.at( i )->getType() == OT_TEXT )
00802 {
00803 if(objects.at(i)->isSelected())
00804 doc->updateRuler();
00805 }
00806 doc->repaint( oldRect );
00807 doc->repaint( objects.at( i ) );
00808 }
00809
00810 doc->updateSideBarItem( m_page );
00811 doc->updateObjectStatusBarItem();
00812 }
00813
00814 KPrAlignCmd::KPrAlignCmd( const QString &_name, QPtrList<KPrObject> &_objects, AlignType _at, KPrDocument *_doc )
00815 : KNamedCommand( _name ), doc(_doc)
00816 {
00817 objects.setAutoDelete( false );
00818 diffs.setAutoDelete( true );
00819 m_page = doc->findPage( _objects );
00820
00821 QPtrListIterator<KPrObject> it( _objects );
00822 KoRect boundingRect;
00823 for ( ; it.current() ; ++it )
00824 {
00825 boundingRect |= it.current()->getRealRect();
00826 }
00827
00828 if ( _objects.count() == 1 )
00829 boundingRect = m_page->getPageRect();
00830
00831 it.toFirst();
00832 for ( ; it.current() ; ++it )
00833 {
00834 KoPoint * diff = NULL;
00835 switch ( _at )
00836 {
00837 case AT_LEFT:
00838 diff = new KoPoint( boundingRect.x() - it.current()->getRealOrig().x(), 0 );
00839 break;
00840 case AT_TOP:
00841 diff = new KoPoint( 0, boundingRect.y() - it.current()->getRealOrig().y() );
00842 break;
00843 case AT_RIGHT:
00844 diff = new KoPoint( boundingRect.x() + boundingRect.width() -
00845 it.current()->getRealOrig().x() - it.current()->getRealSize().width(), 0 );
00846 break;
00847 case AT_BOTTOM:
00848 diff = new KoPoint( 0, boundingRect.y() + boundingRect.height() -
00849 it.current()->getRealOrig().y() - it.current()->getRealSize().height() );
00850 break;
00851 case AT_HCENTER:
00852 diff = new KoPoint( ( boundingRect.width() - it.current()->getRealSize().width() ) / 2 -
00853 it.current()->getRealOrig().x() + boundingRect.x(), 0 );
00854 break;
00855 case AT_VCENTER:
00856 diff = new KoPoint( 0, ( boundingRect.height() - it.current()->getRealSize().height() ) / 2 -
00857 it.current()->getRealOrig().y() + boundingRect.y() );
00858 break;
00859 }
00860 if ( diff )
00861 {
00862 objects.append( it.current() );
00863 diffs.append( diff );
00864 it.current()->incCmdRef();
00865 }
00866 }
00867 }
00868
00869 KPrAlignCmd::~KPrAlignCmd()
00870 {
00871 QPtrListIterator<KPrObject> it( objects );
00872 for ( ; it.current() ; ++it )
00873 it.current()->decCmdRef();
00874
00875 diffs.clear();
00876 }
00877
00878 void KPrAlignCmd::execute()
00879 {
00880 QRect oldRect;
00881
00882 for ( unsigned int i = 0; i < objects.count(); i++ ) {
00883 oldRect = doc->zoomHandler()->zoomRect( objects.at( i )->getRepaintRect() );
00884 objects.at( i )->moveBy( *diffs.at( i ) );
00885 if ( objects.at( i )->getType() == OT_TEXT )
00886 {
00887 if(objects.at(i)->isSelected())
00888 doc->updateRuler();
00889 }
00890
00891 doc->repaint( oldRect );
00892 doc->repaint( objects.at( i ) );
00893 }
00894
00895 doc->updateSideBarItem( m_page );
00896 }
00897
00898 void KPrAlignCmd::unexecute()
00899 {
00900 QRect oldRect;
00901
00902 for ( unsigned int i = 0; i < objects.count(); i++ ) {
00903 oldRect = doc->zoomHandler()->zoomRect(objects.at( i )->getRepaintRect() );
00904 objects.at( i )->moveBy( -diffs.at( i )->x(), -diffs.at( i )->y() );
00905 if ( objects.at( i )->getType() == OT_TEXT )
00906 {
00907 if(objects.at(i)->isSelected())
00908 doc->updateRuler();
00909 }
00910 doc->repaint( oldRect );
00911 doc->repaint( objects.at( i ) );
00912 doc->updateRuler();
00913 }
00914
00915 doc->updateSideBarItem( m_page );
00916 }
00917
00918 KoPenCmd::KoPenCmd( const QString &_name, QPtrList<KPrObject> &_objects, Pen _newPen,
00919 KPrDocument *_doc, KPrPage *_page, int _flags )
00920 : KNamedCommand(_name), doc(_doc), m_page( _page ), newPen(_newPen), flags(_flags)
00921 {
00922 objects.setAutoDelete( false );
00923 oldPen.setAutoDelete( false );
00924
00925 addObjects( _objects );
00926 }
00927
00928 KoPenCmd::~KoPenCmd()
00929 {
00930 QPtrListIterator<KPrObject> it( objects );
00931 for ( ; it.current() ; ++it )
00932 it.current()->decCmdRef();
00933
00934 oldPen.setAutoDelete( true );
00935 oldPen.clear();
00936 }
00937
00938 void KoPenCmd::execute()
00939 {
00940 for ( int i = 0; i < static_cast<int>( objects.count() ); i++ )
00941 {
00942 Pen tmpPen = *oldPen.at( i );
00943
00944 if ( flags & LineBegin )
00945 tmpPen.lineBegin = newPen.lineBegin;
00946
00947 if ( flags & LineEnd )
00948 tmpPen.lineEnd = newPen.lineEnd;
00949
00950 if ( flags & Color )
00951 tmpPen.pen.setColor( newPen.pen.color() );
00952
00953 if ( flags & Width )
00954 tmpPen.pen.setPointWidth( newPen.pen.pointWidth() );
00955
00956 if ( flags & Style )
00957 tmpPen.pen.setStyle( newPen.pen.style() );
00958
00959 applyPen( objects.at( i ), &tmpPen );
00960 }
00961
00962
00963
00964 doc->updateObjectSelected();
00965 doc->updateSideBarItem( m_page );
00966 }
00967
00968 void KoPenCmd::applyPen( KPrObject *object, Pen *tmpPen )
00969 {
00970 switch (object->getType()) {
00971 case OT_LINE:
00972 {
00973 KPrLineObject* obj=dynamic_cast<KPrLineObject*>( object );
00974 if( obj )
00975 {
00976
00977 obj->setLineBegin( tmpPen->lineBegin );
00978 obj->setLineEnd( tmpPen->lineEnd );
00979
00980 }
00981 } break;
00982 case OT_FREEHAND:
00983 case OT_POLYLINE:
00984 case OT_QUADRICBEZIERCURVE:
00985 case OT_CUBICBEZIERCURVE:
00986 {
00987 KPrPointObject *obj = dynamic_cast<KPrPointObject*>( object );
00988 if ( obj )
00989 {
00990
00991 obj->setLineBegin( tmpPen->lineBegin );
00992 obj->setLineEnd( tmpPen->lineEnd );
00993
00994 }
00995 } break;
00996 case OT_PIE:
00997 {
00998 KPrPieObject *obj = dynamic_cast<KPrPieObject*>( object );
00999 if ( obj )
01000 {
01001 obj->setLineBegin( tmpPen->lineBegin );
01002 obj->setLineEnd( tmpPen->lineEnd );
01003 }
01004 } break;
01005 case OT_AUTOFORM:
01006 {
01007 KPrAutoformObject *obj = dynamic_cast<KPrAutoformObject*>( object );
01008 if ( obj )
01009 {
01010 obj->setLineBegin( tmpPen->lineBegin );
01011 obj->setLineEnd( tmpPen->lineEnd );
01012 }
01013 } break;
01014 default:
01015 break;
01016 }
01017
01018 KPrShadowObject *obj = dynamic_cast<KPrShadowObject*>( object );
01019 if ( obj )
01020 {
01021 obj->setPen( tmpPen->pen );
01022 doc->repaint( obj );
01023 }
01024 }
01025
01026 void KoPenCmd::unexecute()
01027 {
01028 for ( unsigned int i = 0; i < objects.count(); ++i ) {
01029 if( oldPen.count() > i )
01030 applyPen( objects.at( i ), oldPen.at( i ) );
01031 }
01032
01033
01034
01035 doc->updateObjectSelected();
01036 doc->updateSideBarItem( m_page );
01037 }
01038
01039 void KoPenCmd::addObjects( const QPtrList<KPrObject> &_objects )
01040 {
01041 QPtrListIterator<KPrObject> it( _objects );
01042 for ( ; it.current(); ++it )
01043 {
01044 KPrObject * object( it.current() );
01045 if ( object->getType() == OT_GROUP )
01046 {
01047 KPrGroupObject * obj=dynamic_cast<KPrGroupObject*>( object );
01048 if ( obj )
01049 {
01050 addObjects( obj->objectList() );
01051 }
01052 }
01053 else
01054 {
01055
01056 ::LineEnd lineBegin = L_NORMAL;
01057 ::LineEnd lineEnd = L_NORMAL;
01058 switch ( it.current()->getType() ) {
01059 case OT_LINE:
01060 {
01061 KPrLineObject *obj=dynamic_cast<KPrLineObject*>( object );
01062 if ( obj )
01063 {
01064 lineBegin = obj->getLineBegin();
01065 lineEnd = obj->getLineEnd();
01066 }
01067 } break;
01068 case OT_FREEHAND:
01069 case OT_POLYLINE:
01070 case OT_QUADRICBEZIERCURVE:
01071 case OT_CUBICBEZIERCURVE:
01072 {
01073 KPrPointObject *obj = dynamic_cast<KPrPointObject*>( object );
01074 if ( obj )
01075 {
01076 lineBegin = obj->getLineBegin();
01077 lineEnd = obj->getLineEnd();
01078 }
01079 } break;
01080 case OT_PIE:
01081 {
01082 KPrPieObject *obj = dynamic_cast<KPrPieObject*>( object );
01083 if ( obj )
01084 {
01085 lineBegin = obj->getLineBegin();
01086 lineEnd = obj->getLineEnd();
01087 }
01088 } break;
01089 case OT_AUTOFORM:
01090 {
01091 KPrAutoformObject *obj = dynamic_cast<KPrAutoformObject*>( object );
01092 if ( obj )
01093 {
01094 lineBegin = obj->getLineBegin();
01095 lineEnd = obj->getLineEnd();
01096 }
01097 } break;
01098 default:
01099 break;
01100 }
01101
01102 KPrShadowObject *obj = dynamic_cast<KPrShadowObject*>( object );
01103 if ( obj )
01104 {
01105 objects.append( obj );
01106 obj->incCmdRef();
01107
01108 Pen * pen = new KoPenCmd::Pen( obj->getPen(), lineBegin, lineEnd );
01109
01110 oldPen.append( pen );
01111 }
01112 }
01113 }
01114 }
01115
01116
01117 KPrBrushCmd::KPrBrushCmd( const QString &_name, QPtrList<KPrObject> &_objects, Brush _newBrush,
01118 KPrDocument *_doc, KPrPage *_page, int _flags )
01119 : KNamedCommand(_name), doc(_doc), newBrush(_newBrush), m_page(_page), flags(_flags)
01120 {
01121 objects.setAutoDelete( false );
01122 oldBrush.setAutoDelete( false );
01123
01124 addObjects( _objects );
01125 }
01126
01127 void KPrBrushCmd::addObjects( const QPtrList<KPrObject> &_objects )
01128 {
01129 QPtrListIterator<KPrObject> it( _objects );
01130 for ( ; it.current(); ++it )
01131 {
01132 if ( it.current()->getType() == OT_GROUP )
01133 {
01134 KPrGroupObject * obj=dynamic_cast<KPrGroupObject*>( it.current() );
01135 if ( obj )
01136 {
01137 addObjects( obj->objectList() );
01138 }
01139 }
01140 else
01141 {
01142 KPr2DObject * obj = dynamic_cast<KPr2DObject *>( it.current() );
01143 if( obj )
01144 {
01145 objects.append( obj );
01146 obj->incCmdRef();
01147
01148 Brush * brush = new KPrBrushCmd::Brush;
01149 brush->brush = obj->getBrush();
01150 brush->fillType = obj->getFillType();
01151 brush->gColor1 = obj->getGColor1();
01152 brush->gColor2 = obj->getGColor2();
01153 brush->gType = obj->getGType();
01154 brush->unbalanced = obj->getGUnbalanced();
01155 brush->xfactor = obj->getGXFactor();
01156 brush->yfactor = obj->getGYFactor();
01157
01158 oldBrush.append( brush );
01159 }
01160 }
01161 }
01162 }
01163
01164 KPrBrushCmd::~KPrBrushCmd()
01165 {
01166 QPtrListIterator<KPr2DObject> it( objects );
01167 for ( ; it.current() ; ++it )
01168 it.current()->decCmdRef();
01169
01170 oldBrush.setAutoDelete( true );
01171 oldBrush.clear();
01172 }
01173
01174 void KPrBrushCmd::execute()
01175 {
01176 for ( int i = 0; i < static_cast<int>( objects.count() ); i++ )
01177 {
01178 Brush tmpBrush = *oldBrush.at( i );
01179
01180 if ( flags & BrushColor )
01181 tmpBrush.brush.setColor( newBrush.brush.color() );
01182
01183 if ( flags & BrushStyle )
01184 tmpBrush.brush.setStyle( newBrush.brush.style() );
01185
01186 if ( flags & BrushGradientSelect )
01187 tmpBrush.fillType = newBrush.fillType;
01188
01189 if ( flags & GradientColor1 )
01190 tmpBrush.gColor1 = newBrush.gColor1;
01191
01192 if ( flags & GradientColor2 )
01193 tmpBrush.gColor2 = newBrush.gColor2;
01194
01195 if ( flags & GradientType )
01196 tmpBrush.gType = newBrush.gType;
01197
01198 if ( flags & GradientBalanced )
01199 tmpBrush.unbalanced = newBrush.unbalanced;
01200
01201 if ( flags & GradientXFactor )
01202 tmpBrush.xfactor = newBrush.xfactor;
01203
01204 if ( flags & GradientYFactor )
01205 tmpBrush.yfactor = newBrush.yfactor;
01206
01207 applyBrush( objects.at( i ), &tmpBrush );
01208 }
01209
01210 doc->updateSideBarItem( m_page );
01211 }
01212
01213 void KPrBrushCmd::applyBrush( KPr2DObject *object, Brush *tmpBrush )
01214 {
01215 object->setBrush( tmpBrush->brush );
01216 object->setFillType( tmpBrush->fillType );
01217 object->setGColor1( tmpBrush->gColor1 );
01218 object->setGColor2( tmpBrush->gColor2 );
01219 object->setGType( tmpBrush->gType );
01220 object->setGUnbalanced( tmpBrush->unbalanced );
01221 object->setGXFactor( tmpBrush->xfactor );
01222 object->setGYFactor( tmpBrush->yfactor );
01223 doc->repaint( object );
01224 }
01225
01226 void KPrBrushCmd::unexecute()
01227 {
01228 for ( unsigned int i = 0; i < objects.count(); i++ ) {
01229 applyBrush( objects.at( i ), oldBrush.at( i ) );
01230 }
01231
01232 doc->updateSideBarItem( m_page );
01233 }
01234
01235
01236 KPrPgConfCmd::KPrPgConfCmd( const QString &_name, bool _manualSwitch, bool _infiniteLoop,
01237 bool _showPresentationDuration, QPen _pen,
01238 QValueList<bool> _selectedSlides, const QString & _presentationName,
01239 bool _oldManualSwitch, bool _oldInfiniteLoop,
01240 bool _oldShowPresentationDuration, QPen _oldPen,
01241 QValueList<bool> _oldSelectedSlides, const QString & _oldPresentationName,
01242 KPrDocument *_doc )
01243 : KNamedCommand( _name )
01244 {
01245 manualSwitch = _manualSwitch;
01246 infiniteLoop = _infiniteLoop;
01247 showPresentationDuration = _showPresentationDuration;
01248 pen = _pen;
01249 selectedSlides = _selectedSlides;
01250 oldManualSwitch = _oldManualSwitch;
01251 oldInfiniteLoop = _oldInfiniteLoop;
01252 oldShowPresentationDuration = _oldShowPresentationDuration;
01253 oldPen = _oldPen;
01254 oldSelectedSlides = _oldSelectedSlides;
01255 oldPresentationName = _oldPresentationName;
01256 presentationName = _presentationName;
01257 doc = _doc;
01258 }
01259
01260 void KPrPgConfCmd::execute()
01261 {
01262 doc->setManualSwitch( manualSwitch );
01263 doc->setInfiniteLoop( infiniteLoop );
01264 doc->setPresentationDuration( showPresentationDuration );
01265 doc->setPresPen( pen );
01266 doc->setPresentationName( presentationName );
01267 QPtrList<KPrPage> pages = doc->pageList();
01268 unsigned count = selectedSlides.count();
01269 if( count > pages.count() ) count = pages.count();
01270 for( unsigned i = 0; i < selectedSlides.count(); i++ )
01271 pages.at( i )->slideSelected( selectedSlides[ i ] );
01272 }
01273
01274 void KPrPgConfCmd::unexecute()
01275 {
01276 doc->setManualSwitch( oldManualSwitch );
01277 doc->setInfiniteLoop( oldInfiniteLoop );
01278 doc->setPresentationDuration( oldShowPresentationDuration );
01279 doc->setPresPen( oldPen );
01280 doc->setPresentationName( oldPresentationName );
01281
01282 QPtrList<KPrPage> pages = doc->pageList();
01283 unsigned count = oldSelectedSlides.count();
01284 if( count > pages.count() ) count = pages.count();
01285 for( unsigned i = 0; i < oldSelectedSlides.count(); i++ )
01286 pages.at( i )->slideSelected( oldSelectedSlides[ i ] );
01287 }
01288
01289
01290 KPrTransEffectCmd::KPrTransEffectCmd( QValueVector<PageEffectSettings> oldSettings,
01291 PageEffectSettings newSettings,
01292 KPrPage* page, KPrDocument* doc )
01293 {
01294 m_newSettings = newSettings;
01295 m_oldSettings = oldSettings;
01296 Q_ASSERT( !m_oldSettings.isEmpty() );
01297 m_page = page;
01298 m_doc = doc;
01299 }
01300
01301 void KPrTransEffectCmd::PageEffectSettings::applyTo( KPrPage *page )
01302 {
01303 page->setPageEffect( pageEffect );
01304 page->setPageEffectSpeed( effectSpeed );
01305 page->setPageSoundEffect( soundEffect );
01306 page->setPageSoundFileName( soundFileName );
01307
01308 page->setPageTimer( slideTime );
01309 }
01310
01311 void KPrTransEffectCmd::execute()
01312 {
01313 if ( m_page )
01314 m_newSettings.applyTo( m_page );
01315 else
01316 for( QPtrListIterator<KPrPage> it( m_doc->getPageList() ); *it; ++it )
01317 m_newSettings.applyTo( it.current() );
01318 }
01319
01320 void KPrTransEffectCmd::unexecute()
01321 {
01322 if ( m_page )
01323 m_oldSettings[0].applyTo( m_page );
01324 else {
01325 int i = 0;
01326 for( QPtrListIterator<KPrPage> it( m_doc->getPageList() ); *it; ++it, ++i )
01327 m_oldSettings[i].applyTo( it.current() );
01328 }
01329 }
01330
01331 QString KPrTransEffectCmd::name() const
01332 {
01333 if ( m_page )
01334 return i18n( "Modify Slide Transition" );
01335 else
01336 return i18n( "Modify Slide Transition For All Pages" );
01337 }
01338
01339 KPrPgLayoutCmd::KPrPgLayoutCmd( const QString &_name, KoPageLayout _layout, KoPageLayout _oldLayout,
01340 KoUnit::Unit _oldUnit, KoUnit::Unit _unit,KPrDocument *_doc )
01341 : KNamedCommand( _name )
01342 {
01343 m_doc=_doc;
01344 layout = _layout;
01345 oldLayout = _oldLayout;
01346 oldUnit = _oldUnit;
01347 unit = _unit;
01348 }
01349
01350 void KPrPgLayoutCmd::execute()
01351 {
01352 m_doc->setUnit( unit );
01353 m_doc->setPageLayout( layout );
01354 m_doc->updateHeaderFooterPosition();
01355 m_doc->updateRuler();
01356 m_doc->updateRulerPageLayout();
01357 }
01358
01359 void KPrPgLayoutCmd::unexecute()
01360 {
01361 m_doc->setUnit( oldUnit );
01362 m_doc->setPageLayout( oldLayout );
01363 m_doc->updateHeaderFooterPosition();
01364 m_doc->updateRuler();
01365 m_doc->updateRulerPageLayout();
01366 }
01367
01368
01369 KPrPieValueCmd::KPrPieValueCmd( const QString &name, PieValues newValues,
01370 QPtrList<KPrObject> &objects, KPrDocument *doc,
01371 KPrPage *page, int flags )
01372 : KNamedCommand( name )
01373 , m_doc( doc )
01374 , m_page( page )
01375 , m_newValues( newValues )
01376 , m_flags( flags )
01377 {
01378 m_objects.setAutoDelete( false );
01379 m_oldValues.setAutoDelete( false );
01380
01381 addObjects( objects );
01382 }
01383
01384 KPrPieValueCmd::KPrPieValueCmd( const QString &_name, QPtrList<PieValues> &_oldValues, PieValues _newValues,
01385 QPtrList<KPrObject> &_objects, KPrDocument *_doc, KPrPage *_page, int _flags )
01386 : KNamedCommand( _name ), m_oldValues( _oldValues ), m_objects( _objects ), m_flags(_flags)
01387 {
01388 m_objects.setAutoDelete( false );
01389 m_oldValues.setAutoDelete( false );
01390 m_doc = _doc;
01391 m_page = _page;
01392 m_newValues = _newValues;
01393
01394 QPtrListIterator<KPrObject> it( m_objects );
01395 for ( ; it.current() ; ++it )
01396 it.current()->incCmdRef();
01397 }
01398
01399 KPrPieValueCmd::~KPrPieValueCmd()
01400 {
01401 QPtrListIterator<KPrObject> it( m_objects );
01402 for ( ; it.current() ; ++it )
01403 it.current()->decCmdRef();
01404 m_oldValues.setAutoDelete( true );
01405 m_oldValues.clear();
01406 }
01407
01408 void KPrPieValueCmd::addObjects( const QPtrList<KPrObject> &objects )
01409 {
01410 QPtrListIterator<KPrObject> it( objects );
01411 for ( ; it.current(); ++it )
01412 {
01413 if ( it.current()->getType() == OT_GROUP )
01414 {
01415 KPrGroupObject * obj = dynamic_cast<KPrGroupObject*>( it.current() );
01416 if ( obj )
01417 {
01418 addObjects( obj->objectList() );
01419 }
01420 }
01421 else
01422 {
01423 KPrPieObject *obj = dynamic_cast<KPrPieObject*>( it.current() );
01424 if( obj )
01425 {
01426 m_objects.append( obj );
01427 obj->incCmdRef();
01428
01429 PieValues * pieValues = new PieValues;
01430 pieValues->pieType = obj->getPieType();
01431 pieValues->pieAngle = obj->getPieAngle();
01432 pieValues->pieLength = obj->getPieLength();
01433 m_oldValues.append( pieValues );
01434 }
01435 }
01436 }
01437 }
01438
01439 void KPrPieValueCmd::execute()
01440 {
01441 QPtrListIterator<KPrObject> it( m_objects );
01442 for ( ; it.current() ; ++it )
01443 {
01444 KPrPieObject* obj=dynamic_cast<KPrPieObject*>( it.current() );
01445 if(obj)
01446 {
01447 if (m_flags & Type)
01448 obj->setPieType( m_newValues.pieType );
01449 if (m_flags & Angle)
01450 obj->setPieAngle( m_newValues.pieAngle );
01451 if (m_flags & Length)
01452 obj->setPieLength( m_newValues.pieLength );
01453 }
01454 }
01455 m_doc->repaint( false );
01456
01457 m_doc->updateSideBarItem( m_page );
01458 }
01459
01460 void KPrPieValueCmd::unexecute()
01461 {
01462 for ( unsigned int i = 0; i < m_objects.count(); i++ )
01463 {
01464 KPrPieObject* obj=dynamic_cast<KPrPieObject*>( m_objects.at( i ) );
01465 if(obj)
01466 {
01467 obj->setPieType( m_oldValues.at( i )->pieType );
01468 obj->setPieAngle( m_oldValues.at( i )->pieAngle );
01469 obj->setPieLength( m_oldValues.at( i )->pieLength );
01470 }
01471 }
01472 m_doc->repaint( false );
01473
01474 m_doc->updateSideBarItem( m_page );
01475 }
01476
01477
01478 KPrPolygonSettingCmd::KPrPolygonSettingCmd( const QString &name, PolygonSettings newSettings,
01479 QPtrList<KPrObject> &objects, KPrDocument *doc,
01480 KPrPage *page, int flags )
01481 : KNamedCommand( name )
01482 , m_doc( doc )
01483 , m_page( page )
01484 , m_newSettings( newSettings )
01485 , m_flags( flags )
01486 {
01487 m_objects.setAutoDelete( false );
01488 m_oldSettings.setAutoDelete( false );
01489
01490 addObjects( objects );
01491 }
01492
01493
01494 KPrPolygonSettingCmd::~KPrPolygonSettingCmd()
01495 {
01496 QPtrListIterator<KPrObject> it( m_objects );
01497 for ( ; it.current() ; ++it )
01498 it.current()->decCmdRef();
01499 m_oldSettings.setAutoDelete( true );
01500 m_oldSettings.clear();
01501 }
01502
01503 void KPrPolygonSettingCmd::addObjects( const QPtrList<KPrObject> &objects )
01504 {
01505 QPtrListIterator<KPrObject> it( objects );
01506 for ( ; it.current(); ++it )
01507 {
01508 if ( it.current()->getType() == OT_GROUP )
01509 {
01510 KPrGroupObject * obj = dynamic_cast<KPrGroupObject*>( it.current() );
01511 if ( obj )
01512 {
01513 addObjects( obj->objectList() );
01514 }
01515 }
01516 else
01517 {
01518 KPrPolygonObject *obj = dynamic_cast<KPrPolygonObject*>( it.current() );
01519 if( obj )
01520 {
01521 m_objects.append( obj );
01522 obj->incCmdRef();
01523
01524 PolygonSettings * polygonSettings = new PolygonSettings;
01525
01526 polygonSettings->checkConcavePolygon = obj->getCheckConcavePolygon();
01527 polygonSettings->cornersValue = obj->getCornersValue();
01528 polygonSettings->sharpnessValue = obj->getSharpnessValue();
01529
01530 m_oldSettings.append( polygonSettings );
01531 }
01532 }
01533 }
01534 }
01535
01536 void KPrPolygonSettingCmd::execute()
01537 {
01538 QPtrListIterator<KPrObject> it( m_objects );
01539 for ( ; it.current() ; ++it )
01540 {
01541 KPrPolygonObject * obj=dynamic_cast<KPrPolygonObject*>( it.current() );
01542 if(obj)
01543 {
01544 if (m_flags & ConcaveConvex)
01545 obj->setCheckConcavePolygon(m_newSettings.checkConcavePolygon);
01546 if (m_flags & Corners)
01547 obj->setCornersValue(m_newSettings.cornersValue);
01548 if (m_flags & Sharpness)
01549 obj->setSharpnessValue(m_newSettings.sharpnessValue );
01550 }
01551 }
01552 m_doc->repaint( false );
01553
01554 m_doc->updateSideBarItem( m_page );
01555 }
01556
01557 void KPrPolygonSettingCmd::unexecute()
01558 {
01559 for ( unsigned int i = 0; i < m_objects.count(); ++i )
01560 {
01561 KPrPolygonObject * obj=dynamic_cast<KPrPolygonObject*>( m_objects.at(i) );
01562 if(obj)
01563 {
01564 obj->setCheckConcavePolygon(m_oldSettings.at( i )->checkConcavePolygon);
01565 obj->setCornersValue(m_oldSettings.at( i )->cornersValue);
01566 obj->setSharpnessValue(m_oldSettings.at( i )->sharpnessValue);
01567 }
01568 }
01569 m_doc->repaint( false );
01570
01571 m_doc->updateSideBarItem( m_page );
01572 }
01573
01574
01575 KPrPictureSettingCmd::KPrPictureSettingCmd( const QString &name, PictureSettings newSettings,
01576 QPtrList<KPrObject> &objects, KPrDocument *doc,
01577 KPrPage *page, int flags )
01578 : KNamedCommand( name )
01579 , m_doc( doc )
01580 , m_newSettings( newSettings )
01581 , m_page( page )
01582 , m_flags( flags )
01583 {
01584 m_objects.setAutoDelete( false );
01585 m_oldValues.setAutoDelete( false );
01586
01587 addObjects( objects );
01588 }
01589
01590 KPrPictureSettingCmd::KPrPictureSettingCmd( const QString &_name, QPtrList<PictureSettings> &_oldSettings,
01591 PictureSettings _newSettings, QPtrList<KPrObject> &_objects,
01592 KPrDocument *_doc, int flags )
01593 : KNamedCommand( _name ), m_oldValues( _oldSettings ), m_objects( _objects ), m_flags( flags )
01594 {
01595 m_objects.setAutoDelete( false );
01596 m_oldValues.setAutoDelete( false );
01597 m_doc = _doc;
01598 m_newSettings = _newSettings;
01599
01600 m_page = m_doc->findPage( m_objects );
01601
01602 QPtrListIterator<KPrObject> it( m_objects );
01603 for ( ; it.current() ; ++it )
01604 it.current()->incCmdRef();
01605 }
01606
01607 KPrPictureSettingCmd::~KPrPictureSettingCmd()
01608 {
01609 QPtrListIterator<KPrObject> it( m_objects );
01610 for ( ; it.current() ; ++it )
01611 it.current()->decCmdRef();
01612 m_oldValues.setAutoDelete( true );
01613 m_oldValues.clear();
01614 }
01615
01616 void KPrPictureSettingCmd::addObjects( const QPtrList<KPrObject> &objects )
01617 {
01618 QPtrListIterator<KPrObject> it( objects );
01619 for ( ; it.current(); ++it )
01620 {
01621 if ( it.current()->getType() == OT_GROUP )
01622 {
01623 KPrGroupObject * obj = dynamic_cast<KPrGroupObject*>( it.current() );
01624 if ( obj )
01625 {
01626 addObjects( obj->objectList() );
01627 }
01628 }
01629 else
01630 {
01631 KPrPixmapObject *obj = dynamic_cast<KPrPixmapObject*>( it.current() );
01632 if( obj )
01633 {
01634 m_objects.append( obj );
01635 obj->incCmdRef();
01636
01637 PictureSettings * pictureSettings = new PictureSettings;
01638
01639 pictureSettings->mirrorType = obj->getPictureMirrorType();
01640 pictureSettings->depth = obj->getPictureDepth();
01641 pictureSettings->swapRGB = obj->getPictureSwapRGB();
01642 pictureSettings->grayscal = obj->getPictureGrayscal();
01643 pictureSettings->bright = obj->getPictureBright();
01644
01645 m_oldValues.append( pictureSettings );
01646 }
01647 }
01648 }
01649 }
01650
01651 void KPrPictureSettingCmd::execute()
01652 {
01653 QPtrListIterator<KPrObject> it( m_objects );
01654 for ( ; it.current() ; ++it ) {
01655 KPrPixmapObject * obj = dynamic_cast<KPrPixmapObject*>( it.current() );
01656 if ( obj ) {
01657 if ( m_flags & MirrorType )
01658 obj->setPictureMirrorType( m_newSettings.mirrorType );
01659 if ( m_flags & Depth )
01660 obj->setPictureDepth( m_newSettings.depth );
01661 if ( m_flags & SwapRGB )
01662 obj->setPictureSwapRGB( m_newSettings.swapRGB );
01663 if ( m_flags & Grayscal )
01664 obj->setPictureGrayscal( m_newSettings.grayscal );
01665 if ( m_flags & Bright )
01666 obj->setPictureBright( m_newSettings.bright );
01667 }
01668 }
01669 m_doc->repaint( false );
01670
01671 m_doc->updateSideBarItem( m_page );
01672 }
01673
01674 void KPrPictureSettingCmd::unexecute()
01675 {
01676 for ( unsigned int i = 0; i < m_objects.count(); ++i ) {
01677 KPrPixmapObject * obj = dynamic_cast<KPrPixmapObject*>( m_objects.at(i) );
01678 if ( obj ) {
01679 PictureSettings *pictureSettings = m_oldValues.at( i );
01680 obj->setPictureMirrorType( pictureSettings->mirrorType );
01681 obj->setPictureDepth( pictureSettings->depth );
01682 obj->setPictureSwapRGB( pictureSettings->swapRGB );
01683 obj->setPictureGrayscal( pictureSettings->grayscal );
01684 obj->setPictureBright( pictureSettings->bright );
01685 }
01686 }
01687 m_doc->repaint( false );
01688
01689 m_doc->updateSideBarItem( m_page );
01690 }
01691
01692
01693 KPrRectValueCmd::KPrRectValueCmd( const QString &_name, QPtrList<RectValues> &_oldValues, RectValues _newValues,
01694 QPtrList<KPrObject> &_objects, KPrDocument *_doc, KPrPage *_page, int _flags )
01695 : KNamedCommand( _name ), m_oldValues( _oldValues ), m_objects( _objects ), m_flags(_flags)
01696 {
01697 m_objects.setAutoDelete( false );
01698 m_oldValues.setAutoDelete( false );
01699 m_doc = _doc;
01700 m_page = _page;
01701 m_newValues = _newValues;
01702
01703 QPtrListIterator<KPrObject> it( m_objects );
01704 for ( ; it.current() ; ++it )
01705 it.current()->incCmdRef();
01706 }
01707
01708
01709 KPrRectValueCmd::KPrRectValueCmd( const QString &name, QPtrList<KPrObject> &objects, RectValues newValues,
01710 KPrDocument *doc, KPrPage *page, int flags )
01711 : KNamedCommand( name )
01712 , m_doc( doc )
01713 , m_page( page )
01714 , m_newValues( newValues )
01715 , m_flags( flags )
01716 {
01717 m_objects.setAutoDelete( false );
01718 m_oldValues.setAutoDelete( false );
01719
01720 addObjects( objects );
01721 }
01722
01723
01724 KPrRectValueCmd::~KPrRectValueCmd()
01725 {
01726 QPtrListIterator<KPrObject> it( m_objects );
01727 for ( ; it.current() ; ++it )
01728 it.current()->decCmdRef();
01729
01730 m_oldValues.setAutoDelete( true );
01731 m_oldValues.clear();
01732 }
01733
01734
01735 void KPrRectValueCmd::addObjects( const QPtrList<KPrObject> &objects )
01736 {
01737 QPtrListIterator<KPrObject> it( objects );
01738 for ( ; it.current(); ++it )
01739 {
01740 if ( it.current()->getType() == OT_GROUP )
01741 {
01742 KPrGroupObject * obj = dynamic_cast<KPrGroupObject*>( it.current() );
01743 if ( obj )
01744 {
01745 addObjects( obj->objectList() );
01746 }
01747 }
01748 else
01749 {
01750 KPrRectObject *obj = dynamic_cast<KPrRectObject*>( it.current() );
01751 if( obj )
01752 {
01753 m_objects.append( obj );
01754 obj->incCmdRef();
01755
01756 RectValues * rectValue = new RectValues;
01757
01758 int xtmp, ytmp;
01759 obj->getRnds( xtmp, ytmp );
01760 rectValue->xRnd = xtmp;
01761 rectValue->yRnd = ytmp;
01762
01763 m_oldValues.append( rectValue );
01764 }
01765 }
01766 }
01767 }
01768
01769
01770 void KPrRectValueCmd::execute()
01771 {
01772 QPtrListIterator<KPrObject> it( m_objects );
01773 for ( ; it.current() ; ++it )
01774 {
01775 KPrRectObject *obj = dynamic_cast<KPrRectObject*>( it.current() );
01776 if( obj )
01777 {
01778 int xtmp, ytmp;
01779 obj->getRnds( xtmp, ytmp );
01780
01781 if ( m_flags & XRnd )
01782 {
01783 xtmp = m_newValues.xRnd;
01784 }
01785
01786 if ( m_flags & YRnd )
01787 {
01788 ytmp = m_newValues.yRnd;
01789 }
01790
01791 obj->setRnds( xtmp, ytmp );
01792 }
01793 }
01794 m_doc->repaint( false );
01795
01796 m_doc->updateSideBarItem( m_page );
01797 }
01798
01799 void KPrRectValueCmd::unexecute()
01800 {
01801 for ( unsigned int i = 0; i < m_objects.count(); i++ )
01802 {
01803 KPrRectObject *obj = dynamic_cast<KPrRectObject*>( m_objects.at( i ) );
01804
01805 if( obj )
01806 obj->setRnds( m_oldValues.at( i )->xRnd, m_oldValues.at( i )->yRnd );
01807 }
01808 m_doc->repaint( false );
01809
01810 m_doc->updateSideBarItem( m_page );
01811 }
01812
01813
01814 KPrResizeCmd::KPrResizeCmd( const QString &_name, const KoPoint &_m_diff, const KoSize &_r_diff,
01815 KPrObject *_object, KPrDocument *_doc )
01816 : KNamedCommand( _name ), m_diff( _m_diff ), r_diff( _r_diff )
01817 {
01818 object = _object;
01819 doc = _doc;
01820 m_page = doc->findPage( object );
01821
01822 object->incCmdRef();
01823 }
01824
01825 KPrResizeCmd::~KPrResizeCmd()
01826 {
01827 object->decCmdRef();
01828 }
01829
01830 void KPrResizeCmd::execute()
01831 {
01832 QRect oldRect;
01833
01834 oldRect = doc->zoomHandler()->zoomRect( object->getRepaintRect() );
01835 object->moveBy( m_diff );
01836 object->resizeBy( r_diff );
01837 if ( object->getType() == OT_TEXT )
01838 {
01839 if(object->isSelected())
01840 doc->updateRuler();
01841 doc->layout( object );
01842 }
01843 if ( object->isSelected())
01844 doc->updateObjectStatusBarItem();
01845 doc->repaint( oldRect );
01846 doc->repaint( object );
01847
01848 doc->updateSideBarItem( m_page );
01849 }
01850
01851 void KPrResizeCmd::unexecute()
01852 {
01853 QRect oldRect;
01854
01855 oldRect = doc->zoomHandler()->zoomRect( object->getRepaintRect() );
01856 object->moveBy( -m_diff.x(), -m_diff.y() );
01857 object->resizeBy( -r_diff.width(), -r_diff.height() );
01858 if ( object->getType() == OT_TEXT )
01859 {
01860 if(object->isSelected())
01861 doc->updateRuler();
01862 doc->layout( object );
01863 }
01864 if ( object->isSelected())
01865 doc->updateObjectStatusBarItem();
01866
01867 doc->repaint( oldRect );
01868 doc->repaint( object );
01869
01870 doc->updateSideBarItem( m_page );
01871 }
01872
01873
01874 KPrOasisPasteTextCommand::KPrOasisPasteTextCommand( KoTextDocument *d, int parag, int idx,
01875 const QByteArray &data )
01876 : KoTextDocCommand( d ), m_parag( parag ), m_idx( idx ), m_data( data ), m_oldParagLayout( 0 )
01877 {
01878 }
01879
01880 KoTextCursor * KPrOasisPasteTextCommand::execute( KoTextCursor *c )
01881 {
01882 KoTextParag *firstParag = doc->paragAt( m_parag );
01883 if ( !firstParag ) {
01884 qWarning( "can't locate parag at %d, last parag: %d", m_parag, doc->lastParag()->paragId() );
01885 return 0;
01886 }
01887
01888
01889 cursor.setParag( firstParag );
01890 cursor.setIndex( m_idx );
01891 c->setParag( firstParag );
01892 c->setIndex( m_idx );
01893
01894 QBuffer buffer( m_data );
01895 KoStore * store = KoStore::createStore( &buffer, KoStore::Read );
01896
01897 if ( store->bad() || !store->hasFile( "content.xml" ) )
01898 {
01899 kdError(33001) << "Invalid ZIP store in memory" << endl;
01900 if ( !store->hasFile( "content.xml" ) )
01901 kdError(33001) << "No content.xml file" << endl;
01902 return c;
01903 }
01904 store->disallowNameExpansion();
01905
01906 KoOasisStore oasisStore( store );
01907 QDomDocument contentDoc;
01908 QString errorMessage;
01909 bool ok = oasisStore.loadAndParse( "content.xml", contentDoc, errorMessage );
01910 if ( !ok ) {
01911 kdError(33001) << "Error parsing content.xml: " << errorMessage << endl;
01912 return c;
01913 }
01914
01915 KoOasisStyles oasisStyles;
01916 QDomDocument stylesDoc;
01917 (void)oasisStore.loadAndParse( "styles.xml", stylesDoc, errorMessage );
01918
01919 oasisStyles.createStyleMap( stylesDoc, true );
01920
01921 oasisStyles.createStyleMap( contentDoc, false );
01922
01923 QDomElement content = contentDoc.documentElement();
01924
01925 QDomElement body ( KoDom::namedItemNS( content, KoXmlNS::office, "body" ) );
01926
01927
01928
01929 QDomElement iter, realBody;
01930 forEachElement( iter, body ) {
01931 realBody = iter;
01932 }
01933 if ( realBody.isNull() ) {
01934 kdError(33001) << "No element found inside office:body!" << endl;
01935 return c;
01936 }
01937
01938 KPrTextDocument * textdoc = static_cast<KPrTextDocument *>(c->parag()->document());
01939 KPrDocument *doc = textdoc->textObject()->kPresenterDocument();
01940 KoOasisContext context( doc, *doc->getVariableCollection(), oasisStyles, store );
01941
01942 *c = textdoc->textObject()->textObject()->pasteOasisText( realBody, context, cursor, doc->styleCollection() );
01943 textdoc->textObject()->textObject()->setNeedSpellCheck( true );
01944
01945 m_lastParag = c->parag()->paragId();
01946 m_lastIndex = c->index();
01947 return c;
01948 }
01949
01950 KoTextCursor * KPrOasisPasteTextCommand::unexecute( KoTextCursor *c )
01951 {
01952 KoTextParag *firstParag = doc->paragAt( m_parag );
01953 if ( !firstParag ) {
01954 qWarning( "can't locate parag at %d, last parag: %d", m_parag, doc->lastParag()->paragId() );
01955 return 0;
01956 }
01957 cursor.setParag( firstParag );
01958 cursor.setIndex( m_idx );
01959 doc->setSelectionStart( KoTextDocument::Temp, &cursor );
01960
01961 KoTextParag *lastParag = doc->paragAt( m_lastParag );
01962 if ( !lastParag ) {
01963 qWarning( "can't locate parag at %d, last parag: %d", m_lastParag, doc->lastParag()->paragId() );
01964 return 0;
01965 }
01966
01967
01968
01969
01970
01971
01972
01973 cursor.setParag( lastParag );
01974 cursor.setIndex( m_lastIndex );
01975 doc->setSelectionEnd( KoTextDocument::Temp, &cursor );
01976 doc->removeSelectedText( KoTextDocument::Temp, c );
01977
01978 if ( m_idx == 0 ) {
01979 Q_ASSERT( m_oldParagLayout );
01980 if ( m_oldParagLayout )
01981 firstParag->setParagLayout( *m_oldParagLayout );
01982 }
01983 return c;
01984 }
01985
01986
01987 KPrChangeStartingPageCommand::KPrChangeStartingPageCommand( const QString &name, KPrDocument *_doc,
01988 int _oldStartingPage, int _newStartingPage):
01989 KNamedCommand(name),
01990 m_doc(_doc),
01991 oldStartingPage(_oldStartingPage),
01992 newStartingPage(_newStartingPage)
01993 {
01994 }
01995
01996 void KPrChangeStartingPageCommand::execute()
01997 {
01998 m_doc->getVariableCollection()->variableSetting()->setStartingPageNumber(newStartingPage);
01999 m_doc->recalcVariables( VT_PGNUM );
02000 }
02001
02002 void KPrChangeStartingPageCommand::unexecute()
02003 {
02004 m_doc->getVariableCollection()->variableSetting()->setStartingPageNumber(oldStartingPage);
02005 m_doc->recalcVariables( VT_PGNUM );
02006 }
02007
02008
02009 KPrChangeVariableSettingsCommand::KPrChangeVariableSettingsCommand( const QString &name, KPrDocument *_doc,
02010 bool _oldValue, bool _newValue,
02011 VariableProperties _type):
02012 KNamedCommand(name),
02013 m_doc(_doc),
02014 type(_type),
02015 m_bOldValue(_oldValue),
02016 m_bNewValue(_newValue)
02017 {
02018 }
02019
02020 void KPrChangeVariableSettingsCommand::changeValue( bool b )
02021 {
02022 switch(type)
02023 {
02024 case VS_DISPLAYLINK:
02025 m_doc->getVariableCollection()->variableSetting()->setDisplayLink(b);
02026 m_doc->recalcVariables( VT_LINK );
02027 break;
02028 case VS_UNDERLINELINK:
02029 m_doc->getVariableCollection()->variableSetting()->setUnderlineLink(b);
02030 m_doc->recalcVariables( VT_LINK );
02031 break;
02032 case VS_DISPLAYCOMMENT:
02033 m_doc->getVariableCollection()->variableSetting()->setDisplayComment(b);
02034 m_doc->recalcVariables( VT_NOTE );
02035 break;
02036 case VS_DISPLAYFIELDCODE:
02037 m_doc->getVariableCollection()->variableSetting()->setDisplayFieldCode(b);
02038 m_doc->recalcVariables( VT_ALL );
02039 break;
02040 }
02041 }
02042
02043 void KPrChangeVariableSettingsCommand::execute()
02044 {
02045 changeValue(m_bNewValue);
02046 }
02047
02048 void KPrChangeVariableSettingsCommand::unexecute()
02049 {
02050 changeValue(m_bOldValue);
02051 }
02052
02053 KPrDeletePageCmd::KPrDeletePageCmd( const QString &name, int pageNum, KPrDocument *doc )
02054 : KNamedCommand( name )
02055 , m_doc( doc )
02056 , m_pageNum( pageNum )
02057 {
02058 m_page = m_doc->pageList().at( m_pageNum );
02059 }
02060
02061 KPrDeletePageCmd::~KPrDeletePageCmd()
02062 {
02063 }
02064
02065 void KPrDeletePageCmd::execute()
02066 {
02067 m_doc->deSelectAllObj();
02068 m_doc->takePage( m_page, QMAX( m_pageNum - 1, 0 ) );
02069 m_doc->updatePresentationButton();
02070 }
02071
02072 void KPrDeletePageCmd::unexecute()
02073 {
02074 m_doc->deSelectAllObj();
02075 m_doc->insertPage( m_page, QMAX( m_pageNum - 1, 0 ), m_pageNum );
02076 m_doc->updatePresentationButton();
02077 }
02078
02079 KPrInsertPageCmd::KPrInsertPageCmd( const QString &name, int pageNum, InsertPos pos,
02080 KPrPage *page, KPrDocument *doc )
02081 : KNamedCommand(name)
02082 , m_doc( doc )
02083 , m_page( page )
02084 , m_currentPageNum( pageNum )
02085 , m_insertPageNum( 0 )
02086 {
02087 switch( pos )
02088 {
02089 case IP_BEFORE:
02090 m_insertPageNum = m_currentPageNum;
02091 break;
02092 case IP_AFTER:
02093 m_insertPageNum = m_currentPageNum + 1;
02094 break;
02095 }
02096 }
02097
02098 KPrInsertPageCmd::~KPrInsertPageCmd()
02099 {
02100 }
02101
02102 void KPrInsertPageCmd::execute()
02103 {
02104 m_doc->deSelectAllObj();
02105 m_doc->insertPage( m_page, m_currentPageNum, m_insertPageNum );
02106 m_page->completeLoading( false, -1 );
02107 m_doc->updatePresentationButton();
02108 }
02109
02110 void KPrInsertPageCmd::unexecute()
02111 {
02112 m_doc->deSelectAllObj();
02113 m_doc->takePage( m_page, m_currentPageNum );
02114 m_doc->updatePresentationButton();
02115 }
02116
02117 KPrMovePageCmd::KPrMovePageCmd( const QString &_name,int from, int to, KPrDocument *_doc ) :
02118 KNamedCommand( _name ),
02119 m_doc( _doc ),
02120 m_oldPosition( from ),
02121 m_newPosition( to )
02122 {
02123 }
02124
02125 KPrMovePageCmd::~KPrMovePageCmd()
02126 {
02127 }
02128
02129 void KPrMovePageCmd::execute()
02130 {
02131 m_doc->deSelectAllObj();
02132 m_doc->movePageTo( m_oldPosition, m_newPosition );
02133 }
02134
02135 void KPrMovePageCmd::unexecute()
02136 {
02137 m_doc->deSelectAllObj();
02138 m_doc->movePageTo( m_newPosition, m_oldPosition );
02139 }
02140
02141
02142 KPrChangeTitlePageNameCommand::KPrChangeTitlePageNameCommand( const QString &_name,KPrDocument *_doc,
02143 const QString &_oldPageName,
02144 const QString &_newPageName, KPrPage *_page ) :
02145 KNamedCommand(_name),
02146 m_doc(_doc),
02147 oldPageName(_oldPageName),
02148 newPageName(_newPageName),
02149 m_page(_page)
02150 {
02151 }
02152
02153 void KPrChangeTitlePageNameCommand::execute()
02154 {
02155 m_page->insertManualTitle(newPageName);
02156 m_doc->updateSideBarItem( m_page );
02157 m_doc->recalcVariables( VT_PGNUM );
02158 }
02159
02160 void KPrChangeTitlePageNameCommand::unexecute()
02161 {
02162 m_page->insertManualTitle(oldPageName);
02163 m_doc->updateSideBarItem( m_page );
02164 m_doc->recalcVariables( VT_PGNUM );
02165 }
02166
02167 KPrChangeCustomVariableValue::KPrChangeCustomVariableValue( const QString &name, KPrDocument *_doc,
02168 const QString & _oldValue, const QString & _newValue,
02169 KoCustomVariable *var):
02170 KNamedCommand(name),
02171 m_doc(_doc),
02172 newValue(_newValue),
02173 oldValue(_oldValue),
02174 m_var(var)
02175 {
02176 }
02177
02178 void KPrChangeCustomVariableValue::execute()
02179 {
02180 Q_ASSERT(m_var);
02181 m_var->setValue(newValue);
02182 m_doc->recalcVariables( VT_CUSTOM );
02183 }
02184
02185 void KPrChangeCustomVariableValue::unexecute()
02186 {
02187 Q_ASSERT(m_var);
02188 m_var->setValue(oldValue);
02189 m_doc->recalcVariables( VT_CUSTOM );
02190 }
02191
02192 KPrChangeLinkVariable::KPrChangeLinkVariable( const QString &name, KPrDocument *_doc,
02193 const QString & _oldHref, const QString & _newHref,
02194 const QString & _oldLink,const QString &_newLink,
02195 KoLinkVariable *var):
02196 KNamedCommand(name),
02197 m_doc(_doc),
02198 oldHref(_oldHref),
02199 newHref(_newHref),
02200 oldLink(_oldLink),
02201 newLink(_newLink),
02202 m_var(var)
02203 {
02204 }
02205
02206
02207 void KPrChangeLinkVariable::execute()
02208 {
02209 m_var->setLink(newLink,newHref);
02210 m_doc->recalcVariables(VT_LINK);
02211 }
02212
02213 void KPrChangeLinkVariable::unexecute()
02214 {
02215 m_var->setLink(oldLink,oldHref);
02216 m_doc->recalcVariables(VT_LINK);
02217 }
02218
02219
02220 KPrNameObjectCommand::KPrNameObjectCommand( const QString &_name, const QString &_objectName,
02221 KPrObject *_obj, KPrDocument *_doc ):
02222 KNamedCommand( _name ),
02223 newObjectName( _objectName ),
02224 object( _obj ),
02225 doc( _doc )
02226 {
02227 oldObjectName = object->getObjectName();
02228
02229 m_page = doc->findPage( object );
02230 }
02231
02232 KPrNameObjectCommand::~KPrNameObjectCommand()
02233 {
02234 }
02235
02236 void KPrNameObjectCommand::execute()
02237 {
02238 object->setObjectName( newObjectName );
02239 m_page->unifyObjectName( object );
02240
02241 doc->updateSideBarItem( m_page );
02242 }
02243
02244 void KPrNameObjectCommand::unexecute()
02245 {
02246 object->setObjectName( oldObjectName );
02247
02248 doc->updateSideBarItem( m_page );
02249 }
02250
02251 KPrDisplayObjectFromMasterPage::KPrDisplayObjectFromMasterPage(const QString &name, KPrDocument *_doc, KPrPage *_page, bool _newValue)
02252 :KNamedCommand(name),
02253 m_doc( _doc ),
02254 m_page(_page),
02255 newValue(_newValue)
02256 {
02257 }
02258
02259 void KPrDisplayObjectFromMasterPage::execute()
02260 {
02261 m_page->setDisplayObjectFromMasterPage( newValue );
02262 m_doc->updateSideBarItem( m_doc->masterPage() );
02263 }
02264
02265 void KPrDisplayObjectFromMasterPage::unexecute()
02266 {
02267 m_page->setDisplayObjectFromMasterPage( !newValue );
02268 m_doc->updateSideBarItem( m_doc->masterPage() );
02269 }
02270
02271
02272 KPrDisplayBackgroundPage::KPrDisplayBackgroundPage(const QString &name, KPrDocument *_doc, KPrPage *_page, bool _newValue)
02273 :KNamedCommand(name),
02274 m_doc( _doc ),
02275 m_page(_page),
02276 newValue(_newValue)
02277 {
02278 }
02279
02280 void KPrDisplayBackgroundPage::execute()
02281 {
02282 m_page->setDisplayBackground( newValue );
02283 m_doc->updateSideBarItem( m_doc->masterPage() );
02284 }
02285
02286 void KPrDisplayBackgroundPage::unexecute()
02287 {
02288 m_page->setDisplayBackground( !newValue );
02289 m_doc->updateSideBarItem( m_doc->masterPage() );
02290 }
02291
02292
02293 KPrHideShowHeaderFooter::KPrHideShowHeaderFooter( const QString &name, KPrDocument *_doc, KPrPage *_page,
02294 bool _newValue, KPrTextObject *_textObject):
02295 KNamedCommand(name),
02296 m_doc( _doc ),
02297 m_page(_page),
02298 m_textObject(_textObject),
02299 newValue(_newValue)
02300 {
02301 }
02302
02303
02304 void KPrHideShowHeaderFooter::execute()
02305 {
02306 if( m_textObject==m_doc->footer())
02307 m_page->setFooter( newValue );
02308 else if( m_textObject==m_doc->header())
02309 m_page->setHeader( newValue );
02310 else
02311 kdDebug(33001)<<"Error in void KPrHideShowHeaderFooter::execute()\n";
02312
02313 m_doc->updateSideBarItem( m_doc->masterPage() );
02314 }
02315
02316 void KPrHideShowHeaderFooter::unexecute()
02317 {
02318 if( m_textObject==m_doc->footer())
02319 m_page->setFooter( !newValue );
02320 else if( m_textObject==m_doc->header())
02321 m_page->setHeader( !newValue );
02322 else
02323 kdDebug(33001)<<"Error in void KPrHideShowHeaderFooter::unexecute()\n";
02324
02325 m_doc->updateSideBarItem( m_doc->masterPage() );
02326 }
02327
02328 KPrFlipObjectCommand::KPrFlipObjectCommand( const QString &name, KPrDocument *_doc,
02329 bool _horizontal, QPtrList<KPrObject> &_objects ):
02330 KNamedCommand( name ),
02331 m_doc( _doc ),
02332 objects( _objects ),
02333 horizontal( _horizontal )
02334 {
02335 objects.setAutoDelete( false );
02336
02337 m_page = m_doc->findPage( objects );
02338
02339 QPtrListIterator<KPrObject> it( objects );
02340 for ( ; it.current() ; ++it )
02341 it.current()->incCmdRef();
02342 }
02343
02344 KPrFlipObjectCommand::~KPrFlipObjectCommand()
02345 {
02346 QPtrListIterator<KPrObject> it( objects );
02347 for ( ; it.current() ; ++it )
02348 it.current()->decCmdRef();
02349 }
02350
02351 void KPrFlipObjectCommand::execute()
02352 {
02353 flipObjects();
02354 }
02355
02356 void KPrFlipObjectCommand::unexecute()
02357 {
02358 flipObjects();
02359 }
02360
02361 void KPrFlipObjectCommand::flipObjects()
02362 {
02363 QPtrListIterator<KPrObject> it( objects );
02364 for ( ; it.current() ; ++it )
02365 {
02366 it.current()->flip( horizontal );
02367 m_doc->repaint( it.current() );
02368 }
02369
02370 m_doc->updateSideBarItem( m_page );
02371 }
02372
02373
02374 KPrGeometryPropertiesCommand::KPrGeometryPropertiesCommand( const QString &name, QPtrList<KPrObject> &objects,
02375 bool newValue, KgpType type,KPrDocument *_doc )
02376 : KNamedCommand( name )
02377 , m_objects( objects )
02378 , m_newValue( newValue )
02379 , m_type( type )
02380 , m_doc( _doc )
02381 {
02382 QPtrListIterator<KPrObject> it( m_objects );
02383 for ( ; it.current() ; ++it )
02384 {
02385 it.current()->incCmdRef();
02386 if ( m_type == ProtectSize )
02387 m_oldValue.append( it.current()->isProtect() );
02388 else if ( m_type == KeepRatio)
02389 m_oldValue.append( it.current()->isKeepRatio() );
02390 }
02391 }
02392
02393 KPrGeometryPropertiesCommand::KPrGeometryPropertiesCommand( const QString &name, QValueList<bool> &lst,
02394 QPtrList<KPrObject> &objects, bool newValue,
02395 KgpType type, KPrDocument *_doc)
02396 : KNamedCommand( name )
02397 , m_oldValue( lst )
02398 , m_objects( objects )
02399 , m_newValue( newValue )
02400 , m_type( type )
02401 , m_doc ( _doc )
02402 {
02403 QPtrListIterator<KPrObject> it( m_objects );
02404 for ( ; it.current() ; ++it )
02405 it.current()->incCmdRef();
02406 }
02407
02408 KPrGeometryPropertiesCommand::~KPrGeometryPropertiesCommand()
02409 {
02410 QPtrListIterator<KPrObject> it( m_objects );
02411 for ( ; it.current() ; ++it )
02412 it.current()->decCmdRef();
02413 }
02414
02415 void KPrGeometryPropertiesCommand::execute()
02416 {
02417 QPtrListIterator<KPrObject> it( m_objects );
02418 for ( ; it.current() ; ++it )
02419 {
02420 if ( m_type == ProtectSize )
02421 {
02422 it.current()->setProtect( m_newValue );
02423 if ( it.current()->isSelected() )
02424 m_doc->repaint( it.current() );
02425 }
02426 else if ( m_type == KeepRatio)
02427 it.current()->setKeepRatio( m_newValue );
02428 }
02429 }
02430
02431 void KPrGeometryPropertiesCommand::unexecute()
02432 {
02433 KPrObject *obj = 0;
02434 for ( unsigned int i = 0; i < m_objects.count(); ++i ) {
02435 obj = m_objects.at( i );
02436 if ( m_type == ProtectSize )
02437 {
02438 obj->setProtect( *m_oldValue.at(i) );
02439 if ( obj->isSelected() )
02440 m_doc->repaint( obj );
02441 }
02442 else if ( m_type == KeepRatio)
02443 obj->setKeepRatio( *m_oldValue.at(i) );
02444 }
02445 }
02446
02447 KPrProtectContentCommand::KPrProtectContentCommand( const QString &name, QPtrList<KPrObject> &objects,
02448 bool protectContent, KPrDocument *doc )
02449 : KNamedCommand( name )
02450 , m_protectContent( protectContent )
02451 , m_doc( doc )
02452 {
02453 m_objects.setAutoDelete( false );
02454
02455 addObjects( objects );
02456 }
02457
02458 KPrProtectContentCommand::KPrProtectContentCommand( const QString &name, bool protectContent,
02459 KPrTextObject *obj, KPrDocument *doc )
02460 : KNamedCommand( name )
02461 , m_protectContent( protectContent )
02462 , m_doc( doc )
02463 {
02464 obj->incCmdRef();
02465 m_objects.append( obj );
02466 m_oldValues.append( obj->isProtectContent() );
02467 }
02468
02469 KPrProtectContentCommand::~KPrProtectContentCommand()
02470 {
02471 QPtrListIterator<KPrTextObject> it( m_objects );
02472 for ( ; it.current() ; ++it )
02473 it.current()->decCmdRef();
02474 }
02475
02476 void KPrProtectContentCommand::addObjects( const QPtrList<KPrObject> &objects )
02477 {
02478 QPtrListIterator<KPrObject> it( objects );
02479 for ( ; it.current(); ++it )
02480 {
02481 if ( it.current()->getType() == OT_GROUP )
02482 {
02483 KPrGroupObject * obj = dynamic_cast<KPrGroupObject*>( it.current() );
02484 if ( obj )
02485 {
02486 addObjects( obj->objectList() );
02487 }
02488 }
02489 else
02490 {
02491 KPrTextObject *obj = dynamic_cast<KPrTextObject*>( it.current() );
02492 if( obj )
02493 {
02494 m_objects.append( obj );
02495 obj->incCmdRef();
02496
02497 m_oldValues.append( obj->isProtectContent() );
02498 }
02499 }
02500 }
02501 }
02502
02503 void KPrProtectContentCommand::execute()
02504 {
02505 QPtrListIterator<KPrTextObject> it( m_objects );
02506 for ( ; it.current() ; ++it )
02507 {
02508 it.current()->setProtectContent( m_protectContent );
02509 }
02510 m_doc->updateObjectSelected();
02511 m_doc->updateRulerInProtectContentMode();
02512
02513 }
02514
02515 void KPrProtectContentCommand::unexecute()
02516 {
02517 for ( unsigned int i = 0; i < m_objects.count(); i++ )
02518 {
02519 m_objects.at( i )->setProtectContent( m_oldValues[i] );
02520 }
02521 m_doc->updateObjectSelected();
02522 m_doc->updateRulerInProtectContentMode();
02523 }
02524
02525 KPrCloseObjectCommand::KPrCloseObjectCommand( const QString &name, QPtrList<KPrObject> objects, KPrDocument *doc )
02526 : KNamedCommand( name )
02527 , m_doc( doc )
02528 , m_page( doc->findPage( objects.at( 0 ) ) )
02529 {
02530 QPtrListIterator<KPrObject> it( objects );
02531 for ( ; it.current(); ++it )
02532 {
02533 KPrPointObject * pointObject = dynamic_cast<KPrPointObject *>( *it );
02534 if ( pointObject )
02535 {
02536 m_openObjects.append( *it );
02537 ( *it )->incCmdRef();
02538 KPrClosedLineObject * closedObject = new KPrClosedLineObject( *pointObject );
02539 closedObject->incCmdRef();
02540 m_closedObjects.append( closedObject );
02541 }
02542 }
02543 }
02544
02545 KPrCloseObjectCommand::~KPrCloseObjectCommand()
02546 {
02547 QPtrListIterator<KPrObject> it( m_openObjects );
02548 for ( ; it.current() ; ++it )
02549 it.current()->decCmdRef();
02550 QPtrListIterator<KPrObject> it2( m_closedObjects );
02551 for ( ; it2.current() ; ++it2 )
02552 it2.current()->decCmdRef();
02553 }
02554
02555 void KPrCloseObjectCommand::execute()
02556 {
02557 QPtrListIterator<KPrObject> openIt( m_openObjects );
02558 QPtrListIterator<KPrObject> closeIt( m_closedObjects );
02559 for ( ; openIt.current() ; ++openIt, ++closeIt )
02560 {
02561 m_page->replaceObject( *openIt, *closeIt );
02562 bool selected = ( *openIt )->isSelected();
02563 ( *openIt )->removeFromObjList();
02564 ( *closeIt )->addToObjList();
02565 ( *openIt )->setSelected( false );
02566 ( *closeIt )->setSelected( selected );
02567 m_doc->repaint( *closeIt );
02568 }
02569 m_doc->updateSideBarItem( m_page );
02570 }
02571
02572 void KPrCloseObjectCommand::unexecute()
02573 {
02574 QPtrListIterator<KPrObject> openIt( m_openObjects );
02575 QPtrListIterator<KPrObject> closeIt( m_closedObjects );
02576 for ( ; openIt.current() ; ++openIt, ++closeIt )
02577 {
02578 m_page->replaceObject( *closeIt, *openIt );
02579 bool selected = ( *closeIt )->isSelected();
02580 ( *closeIt )->removeFromObjList();
02581 ( *openIt )->addToObjList();
02582 ( *closeIt )->setSelected( false );
02583 ( *openIt )->setSelected( selected );
02584 m_doc->repaint( *openIt );
02585 }
02586 m_doc->updateSideBarItem( m_page );
02587 }
02588
02589 MarginsStruct::MarginsStruct( KPrTextObject *obj )
02590 {
02591 topMargin = obj->bTop();
02592 bottomMargin= obj->bBottom();
02593 leftMargin = obj->bLeft();
02594 rightMargin= obj->bRight();
02595 }
02596
02597 MarginsStruct::MarginsStruct( double _left, double _top, double _right, double _bottom ):
02598 topMargin(_top),
02599 bottomMargin(_bottom),
02600 leftMargin(_left),
02601 rightMargin(_right)
02602 {
02603 }
02604
02605
02606 KPrChangeMarginCommand::KPrChangeMarginCommand( const QString &name, QPtrList<KPrObject> &objects,
02607 MarginsStruct newMargins, KPrDocument *doc,
02608 KPrPage *page )
02609 : KNamedCommand( name )
02610 , m_newMargins( newMargins )
02611 , m_page( page )
02612 , m_doc( doc )
02613 {
02614 m_objects.setAutoDelete( false );
02615 m_oldMargins.setAutoDelete( false );
02616
02617 addObjects( objects );
02618 }
02619
02620
02621 KPrChangeMarginCommand::~KPrChangeMarginCommand()
02622 {
02623 QPtrListIterator<KPrTextObject> it( m_objects );
02624 for ( ; it.current() ; ++it )
02625 it.current()->decCmdRef();
02626 m_oldMargins.setAutoDelete( true );
02627 m_oldMargins.clear();
02628 }
02629
02630
02631 void KPrChangeMarginCommand::addObjects( const QPtrList<KPrObject> &objects )
02632 {
02633 QPtrListIterator<KPrObject> it( objects );
02634 for ( ; it.current(); ++it )
02635 {
02636 if ( it.current()->getType() == OT_GROUP )
02637 {
02638 KPrGroupObject * obj = dynamic_cast<KPrGroupObject*>( it.current() );
02639 if ( obj )
02640 {
02641 addObjects( obj->objectList() );
02642 }
02643 }
02644 else
02645 {
02646 KPrTextObject *obj = dynamic_cast<KPrTextObject*>( it.current() );
02647 if( obj )
02648 {
02649 m_objects.append( obj );
02650 obj->incCmdRef();
02651
02652 m_oldMargins.append( new MarginsStruct( obj ) );
02653 }
02654 }
02655 }
02656 }
02657
02658
02659 void KPrChangeMarginCommand::execute()
02660 {
02661 QPtrListIterator<KPrTextObject> it( m_objects );
02662 for ( ; it.current() ; ++it )
02663 {
02664 it.current()->setTextMargins( m_newMargins.leftMargin, m_newMargins.topMargin,
02665 m_newMargins.rightMargin, m_newMargins.bottomMargin);
02666 it.current()->resizeTextDocument();
02667 it.current()->layout();
02668 }
02669 m_doc->repaint( false );
02670
02671 m_doc->updateSideBarItem( m_page );
02672 }
02673
02674 void KPrChangeMarginCommand::unexecute()
02675 {
02676 for ( unsigned int i = 0; i < m_objects.count(); i++ )
02677 {
02678 KPrTextObject *object = m_objects.at( i );
02679 MarginsStruct *marginsStruct = m_oldMargins.at( i );
02680 object->setTextMargins( marginsStruct->leftMargin, marginsStruct->topMargin,
02681 marginsStruct->rightMargin, marginsStruct->bottomMargin);
02682 object->resizeTextDocument();
02683 object->layout();
02684 }
02685 m_doc->repaint( false );
02686
02687 m_doc->updateSideBarItem( m_page );
02688 }
02689
02690
02691 KPrChangeVerticalAlignmentCommand::KPrChangeVerticalAlignmentCommand( const QString &name, KPrTextObject *_obj,
02692 VerticalAlignmentType _oldAlign,
02693 VerticalAlignmentType _newAlign,
02694 KPrDocument *_doc) :
02695 KNamedCommand(name),
02696 m_obj( _obj ),
02697 m_oldAlign(_oldAlign),
02698 m_newAlign(_newAlign),
02699 m_doc( _doc )
02700 {
02701 m_page = m_doc->findPage( _obj );
02702 }
02703
02704 void KPrChangeVerticalAlignmentCommand::execute()
02705 {
02706 m_obj->setVerticalAligment( m_newAlign );
02707 m_obj->kPresenterDocument()->layout(m_obj);
02708 m_obj->kPresenterDocument()->repaint(m_obj);
02709
02710 m_doc->updateSideBarItem( m_page );
02711 }
02712
02713 void KPrChangeVerticalAlignmentCommand::unexecute()
02714 {
02715 m_obj->setVerticalAligment( m_oldAlign );
02716 m_obj->kPresenterDocument()->layout(m_obj);
02717 m_obj->kPresenterDocument()->repaint(m_obj);
02718
02719 m_doc->updateSideBarItem( m_page );
02720 }
02721
02722
02723 KPrChangeTabStopValueCommand::KPrChangeTabStopValueCommand( const QString &name, double _oldValue, double _newValue,
02724 KPrDocument *_doc):
02725 KNamedCommand(name),
02726 m_doc( _doc ),
02727 m_oldValue(_oldValue),
02728 m_newValue(_newValue)
02729 {
02730 }
02731
02732 void KPrChangeTabStopValueCommand::execute()
02733 {
02734 m_doc->setTabStopValue ( m_newValue );
02735 }
02736
02737 void KPrChangeTabStopValueCommand::unexecute()
02738 {
02739 m_doc->setTabStopValue ( m_oldValue );
02740 }
02741
02742 KPrImageEffectCmd::KPrImageEffectCmd(const QString &_name, QPtrList<ImageEffectSettings> &_oldSettings,
02743 ImageEffectSettings _newSettings, QPtrList<KPrObject> &_objects,
02744 KPrDocument *_doc )
02745 :KNamedCommand( _name ), oldSettings( _oldSettings ), objects( _objects )
02746 {
02747 objects.setAutoDelete( false );
02748 oldSettings.setAutoDelete( false );
02749 doc = _doc;
02750 newSettings = _newSettings;
02751
02752 m_page = doc->findPage( objects );
02753
02754 QPtrListIterator<KPrObject> it( objects );
02755 for ( ; it.current() ; ++it )
02756 it.current()->incCmdRef();
02757 }
02758
02759 KPrImageEffectCmd::~KPrImageEffectCmd()
02760 {
02761 QPtrListIterator<KPrObject> it( objects );
02762 for ( ; it.current() ; ++it )
02763 it.current()->decCmdRef();
02764 oldSettings.setAutoDelete( true );
02765 oldSettings.clear();
02766 }
02767
02768 void KPrImageEffectCmd::execute()
02769 {
02770 QPtrListIterator<KPrObject> it( objects );
02771 for ( ; it.current() ; ++it ) {
02772 KPrPixmapObject * obj = dynamic_cast<KPrPixmapObject*>( it.current() );
02773 if ( obj ) {
02774 obj->setImageEffect(newSettings.effect);
02775 obj->setIEParams(newSettings.param1, newSettings.param2, newSettings.param3);
02776 }
02777 }
02778 doc->repaint( false );
02779
02780 doc->updateSideBarItem( m_page );
02781 }
02782
02783 void KPrImageEffectCmd::unexecute()
02784 {
02785 for ( unsigned int i = 0; i < objects.count(); ++i ) {
02786 KPrPixmapObject * obj = dynamic_cast<KPrPixmapObject*>( objects.at(i) );
02787 if ( obj ) {
02788 obj->setImageEffect(oldSettings.at( i )->effect);
02789 obj->setIEParams(oldSettings.at( i )->param1, oldSettings.at( i )->param2,
02790 oldSettings.at( i )->param3);
02791 }
02792 }
02793 doc->repaint( false );
02794
02795 doc->updateSideBarItem( m_page );
02796 }
02797
02798 KPrChangeVariableNoteText::KPrChangeVariableNoteText( const QString &name, KPrDocument *_doc,
02799 const QString &_oldValue,const QString &_newValue,
02800 KoNoteVariable *var):
02801 KNamedCommand(name),
02802 m_doc(_doc),
02803 newValue(_newValue),
02804 oldValue(_oldValue),
02805 m_var(var)
02806 {
02807 }
02808
02809 KPrChangeVariableNoteText::~KPrChangeVariableNoteText()
02810 {
02811 }
02812
02813 void KPrChangeVariableNoteText::execute()
02814 {
02815 Q_ASSERT(m_var);
02816 m_var->setNote(newValue);
02817 }
02818
02819 void KPrChangeVariableNoteText::unexecute()
02820 {
02821 Q_ASSERT(m_var);
02822 m_var->setNote(oldValue);
02823 }