21#include "KPrDocument.h"
23#include "KPrCommand.h"
24#include "KPrBackground.h"
25#include "KPrGroupObject.h"
28#include "KPrLineObject.h"
29#include "KPrEllipseObject.h"
30#include "KPrAutoformObject.h"
31#include "KPrFreehandObject.h"
32#include "KPrPolylineObject.h"
33#include "KPrBezierCurveObject.h"
34#include "KPrPolygonObject.h"
35#include "KPrClosedLineObject.h"
37#include "KPrTextObject.h"
38#include "KPrPixmapObject.h"
40#include "KPrPartObject.h"
42#include "KPrPieObject.h"
43#include "KPrRectObject.h"
45#include "KoTextObject.h"
46#include "KPrTextDocument.h"
48#include "KPrVariableCollection.h"
53#include <KoTextParag.h>
56#include <KoOasisContext.h>
57#include <KoOasisStyles.h>
58#include <KoOasisStore.h>
64KPrShadowCmd::KPrShadowCmd(
const TQString &_name, TQPtrList<ShadowValues> &_oldShadow, ShadowValues _newShadow,
65 TQPtrList<KPrObject> &_objects, KPrDocument *_doc )
66 : KNamedCommand( _name ), oldShadow( _oldShadow ), objects( _objects )
68 objects.setAutoDelete(
false );
69 oldShadow.setAutoDelete(
false );
71 newShadow = _newShadow;
73 m_page = doc->findPage( objects );
75 TQPtrListIterator<KPrObject> it( objects );
76 for ( ; it.current() ; ++it )
77 it.current()->incCmdRef();
80KPrShadowCmd::~KPrShadowCmd()
82 TQPtrListIterator<KPrObject> it( objects );
83 for ( ; it.current() ; ++it )
84 it.current()->decCmdRef();
85 oldShadow.setAutoDelete(
true );
89void KPrShadowCmd::execute()
91 TQPtrListIterator<KPrObject> it( objects );
92 for ( ; it.current() ; ++it )
93 it.current()->setShadowParameter(newShadow.shadowDistance,
94 newShadow.shadowDirection,
95 newShadow.shadowColor);
96 doc->repaint(
false );
98 doc->updateSideBarItem( m_page );
101void KPrShadowCmd::unexecute()
103 for (
unsigned int i = 0; i < objects.count(); i++ )
104 objects.at( i )->setShadowParameter(oldShadow.at(i)->shadowDistance,
105 oldShadow.at(i)->shadowDirection,
106 oldShadow.at(i)->shadowColor);
107 doc->repaint(
false );
109 doc->updateSideBarItem( m_page );
113KPrSetOptionsCmd::KPrSetOptionsCmd(
const TQString &_name, TQValueList<KoPoint> &_diffs, TQPtrList<KPrObject> &_objects,
114 double _gridX,
double _gridY,
double _oldGridX,
double _oldGridY,
115 const TQColor &_txtBackCol,
const TQColor &_otxtBackCol, KPrDocument *_doc )
116 : KNamedCommand( _name ),
119 txtBackCol( _txtBackCol ),
120 otxtBackCol( _otxtBackCol )
124 oldGridX = _oldGridX;
125 oldGridY = _oldGridY;
127 TQPtrListIterator<KPrObject> it( objects );
128 for ( ; it.current() ; ++it )
129 it.current()->incCmdRef();
132KPrSetOptionsCmd::~KPrSetOptionsCmd()
134 TQPtrListIterator<KPrObject> it( objects );
135 for ( ; it.current() ; ++it )
136 it.current()->decCmdRef();
139void KPrSetOptionsCmd::execute()
142 for (
unsigned int i = 0; i < objects.count(); i++ )
143 objects.at( i )->moveBy( *diffs.at( i ) );
144 doc->setGridValue( gridX, gridY,
false );
146 doc->setTxtBackCol( txtBackCol );
147 doc->repaint(
false );
150void KPrSetOptionsCmd::unexecute()
152 for (
unsigned int i = 0; i < objects.count(); i++ )
153 objects.at( i )->moveBy( -(*diffs.at( i )).x(), -(*diffs.at( i )).y() );
154 doc->setGridValue( oldGridX, oldGridY,
false );
156 doc->setTxtBackCol( otxtBackCol );
157 doc->repaint(
false );
160KPrSetBackCmd::KPrSetBackCmd(
const TQString &name,
const KPrBackGround::Settings &settings,
161 const KPrBackGround::Settings &oldSettings,
162 bool useMasterBackground,
163 bool takeGlobal, KPrDocument *doc, KPrPage *page )
164: KNamedCommand( name )
165, m_settings( settings )
166, m_oldSettings( oldSettings )
167, m_useMasterBackground( useMasterBackground )
168, m_oldUseMasterBackground( page->useMasterBackground() )
169, m_takeGlobal( takeGlobal )
175void KPrSetBackCmd::execute()
177 if ( !m_takeGlobal ) {
178 m_page->background()->setBackGround( m_settings );
179 m_page->setUseMasterBackground( m_useMasterBackground );
180 m_doc->restoreBackground( m_page );
182 TQPtrListIterator<KPrPage> it( m_doc->getPageList() );
183 for ( ; it.current() ; ++it )
185 it.current()->background()->setBackGround( m_settings );
186 it.current()->setUseMasterBackground( m_useMasterBackground );
187 m_doc->restoreBackground(it.current());
191 m_doc->repaint(
false );
193 if ( m_takeGlobal ) {
194 TQPtrListIterator<KPrPage> it( m_doc->getPageList() );
195 for (
int pos = 0; it.current(); ++it, ++pos ) {
196 m_doc->updateSideBarItem( it.current() );
200 m_doc->updateSideBarItem( m_page );
204void KPrSetBackCmd::unexecute()
206 if ( !m_takeGlobal ) {
207 m_page->background()->setBackGround( m_oldSettings );
208 m_page->setUseMasterBackground( m_oldUseMasterBackground );
209 m_doc->restoreBackground( m_page );
211 TQPtrListIterator<KPrPage> it( m_doc->getPageList() );
212 for ( ; it.current() ; ++it )
214 it.current()->background()->setBackGround( m_oldSettings );
215 it.current()->setUseMasterBackground( m_oldUseMasterBackground );
216 m_doc->restoreBackground(it.current());
219 m_doc->repaint(
false );
221 if ( m_takeGlobal ) {
222 TQPtrListIterator<KPrPage> it( m_doc->getPageList() );
223 for (
int pos = 0; it.current(); ++it, ++pos ) {
224 m_doc->updateSideBarItem( it.current() );
228 m_doc->updateSideBarItem( m_page );
232KPrRotateCmd::KPrRotateCmd(
const TQString &_name,
float newAngle, TQPtrList<KPrObject> &objects,
233 KPrDocument *doc,
bool addAngle )
234 : KNamedCommand( _name ), m_doc( doc ), m_newAngle( newAngle ), m_addAngle( addAngle )
236 m_objects.setAutoDelete(
false );
237 m_oldAngles.setAutoDelete(
false );
239 TQPtrListIterator<KPrObject> it( objects );
240 for ( ; it.current() ; ++it )
242 m_objects.append( it.current() );
244 RotateValues *old =
new RotateValues;
245 old->angle = it.current()->getAngle();
246 m_oldAngles.append( old );
248 it.current()->incCmdRef();
251 m_page = m_doc->findPage( m_objects );
254KPrRotateCmd::~KPrRotateCmd()
256 TQPtrListIterator<KPrObject> it( m_objects );
257 for ( ; it.current() ; ++it )
258 it.current()->decCmdRef();
259 m_oldAngles.setAutoDelete(
true );
263void KPrRotateCmd::execute()
265 TQPtrListIterator<KPrObject> it( m_objects );
266 for ( ; it.current() ; ++it )
269 it.current()->rotate( it.current()->getAngle() + m_newAngle );
271 it.current()->rotate( m_newAngle );
273 m_doc->updateRuler();
274 m_doc->repaint(
false );
276 m_doc->updateSideBarItem( m_page );
279void KPrRotateCmd::unexecute()
281 for (
unsigned int i = 0; i < m_objects.count(); i++ )
282 m_objects.at(i)->rotate( m_oldAngles.at( i )->angle );
283 m_doc->updateRuler();
284 m_doc->repaint(
false );
286 m_doc->updateSideBarItem( m_page );
290KPrChgPixCmd::KPrChgPixCmd(
const TQString &_name, KPrPixmapObject *_oldObject, KPrPixmapObject *_newObject,
291 KPrDocument *_doc, KPrPage *_page)
292 : KNamedCommand( _name )
294 oldObject = _oldObject;
295 newObject = _newObject;
298 oldObject->incCmdRef();
299 newObject->incCmdRef();
300 newObject->setSize( oldObject->getSize() );
301 newObject->setOrig( oldObject->getOrig() );
304KPrChgPixCmd::~KPrChgPixCmd()
306 oldObject->decCmdRef();
307 newObject->decCmdRef();
310void KPrChgPixCmd::execute()
312 m_page->replaceObject( oldObject, newObject );
313 doc->repaint( newObject );
315 doc->updateSideBarItem( m_page );
318void KPrChgPixCmd::unexecute()
320 m_page->replaceObject( newObject, oldObject );
321 doc->repaint( oldObject );
323 doc->updateSideBarItem( m_page );
326KPrDeleteCmd::KPrDeleteCmd(
const TQString &_name, TQPtrList<KPrObject> &_objects,
327 KPrDocument *_doc, KPrPage *_page )
328: KNamedCommand( _name )
329, m_oldObjectList( _page->objectList() )
330, m_objectsToDelete( _objects )
334 TQPtrListIterator<KPrObject> it( m_oldObjectList );
335 for ( ; it.current() ; ++it )
336 it.current()->incCmdRef();
339KPrDeleteCmd::~KPrDeleteCmd()
341 TQPtrListIterator<KPrObject> it( m_oldObjectList );
342 for ( ; it.current() ; ++it )
343 it.current()->decCmdRef();
346void KPrDeleteCmd::execute()
350 TQPtrListIterator<KPrObject> it( m_oldObjectList );
351 TQPtrListIterator<KPrObject> itDelete( m_objectsToDelete );
352 TQPtrList<KPrObject> newObjectList;
353 for ( ; it.current(); ++it )
355 if ( it.current() == itDelete.current() )
357 it.current()->setSelected(
false );
358 it.current()->removeFromObjList();
360 if ( !textObj && it.current()->getType() == OT_TEXT )
362 KPrTextObject * tmp =
dynamic_cast<KPrTextObject *
>( it.current() );
364 tmp->setEditingTextObj(
false );
371 newObjectList.append( it.current() );
375 m_page->setObjectList( newObjectList );
377 for ( itDelete.toFirst(); itDelete.current(); ++itDelete )
379 TQRect oldRect = m_doc->zoomHandler()->zoomRect( itDelete.current()->getRepaintRect() );
380 m_doc->repaint( oldRect );
383 m_doc->updateRuler();
385 m_doc->updateSideBarItem( m_page );
388void KPrDeleteCmd::unexecute()
390 m_page->setObjectList( m_oldObjectList );
391 TQPtrListIterator<KPrObject> it( m_objectsToDelete );
392 for ( ; it.current(); ++it )
394 it.current()->addToObjList();
395 m_doc->repaint( it.current() );
398 m_doc->updateSideBarItem( m_page );
402KPrEffectCmd::KPrEffectCmd(
const TQString &_name,
const TQPtrList<KPrObject> &_objs,
403 const TQValueList<EffectStruct> &_oldEffects, EffectStruct _newEffect )
404 : KNamedCommand( _name ), oldEffects( _oldEffects ),
405 newEffect( _newEffect ), objs( _objs )
407 TQPtrListIterator<KPrObject> it( objs );
408 for ( ; it.current() ; ++it )
409 it.current()->incCmdRef();
412KPrEffectCmd::~KPrEffectCmd()
414 TQPtrListIterator<KPrObject> it( objs );
415 for ( ; it.current() ; ++it )
416 it.current()->decCmdRef();
419void KPrEffectCmd::execute()
421 TQPtrListIterator<KPrObject> it( objs );
422 for ( ; it.current() ; ++it )
424 it.current()->setAppearStep( newEffect.appearStep );
425 it.current()->setEffect( newEffect.effect );
426 it.current()->setEffect2( newEffect.effect2 );
427 it.current()->setDisappear( newEffect.disappear );
428 it.current()->setEffect3( newEffect.effect3 );
429 it.current()->setDisappearStep( newEffect.disappearStep );
430 it.current()->setAppearSpeed( newEffect.m_appearSpeed );
431 it.current()->setDisappearSpeed( newEffect.m_disappearSpeed );
432 it.current()->setAppearTimer( newEffect.appearTimer );
433 it.current()->setDisappearTimer( newEffect.disappearTimer );
434 it.current()->setAppearSoundEffect( newEffect.appearSoundEffect );
435 it.current()->setDisappearSoundEffect( newEffect.disappearSoundEffect );
436 it.current()->setAppearSoundEffectFileName( newEffect.a_fileName );
437 it.current()->setDisappearSoundEffectFileName( newEffect.d_fileName );
441void KPrEffectCmd::unexecute()
443 KPrObject *
object = 0;
444 for (
unsigned int i = 0; i < objs.count(); ++i ) {
445 object = objs.at( i );
447 object->setAppearStep( oldEffects[ i ].appearStep );
448 object->setEffect( oldEffects[ i ].effect );
449 object->setEffect2( oldEffects[ i ].effect2 );
450 object->setDisappear( oldEffects[ i ].disappear );
451 object->setEffect3( oldEffects[ i ].effect3 );
452 object->setDisappearStep( oldEffects[ i ].disappearStep );
453 object->setAppearSpeed( oldEffects[ i ].m_appearSpeed );
454 object->setDisappearSpeed( oldEffects[ i ].m_disappearSpeed );
455 object->setAppearTimer( oldEffects[ i ].appearTimer );
456 object->setDisappearTimer( oldEffects[ i ].disappearTimer );
457 object->setAppearSoundEffect( oldEffects[ i ].appearSoundEffect );
458 object->setDisappearSoundEffect( oldEffects[ i ].disappearSoundEffect );
459 object->setAppearSoundEffectFileName( oldEffects[ i ].a_fileName );
460 object->setDisappearSoundEffectFileName( oldEffects[ i ].d_fileName );
464KPrGroupObjCmd::KPrGroupObjCmd(
const TQString &_name,
465 const TQPtrList<KPrObject> &_objects,
466 KPrDocument *_doc, KPrPage *_page )
467: KNamedCommand( _name )
468, m_objectsToGroup( _objects )
469, m_oldObjectList( _page->objectList() )
473 m_groupObject =
new KPrGroupObject( m_objectsToGroup );
474 m_groupObject->incCmdRef();
477KPrGroupObjCmd::~KPrGroupObjCmd()
479 m_groupObject->decCmdRef();
482void KPrGroupObjCmd::execute()
486 TQPtrListIterator<KPrObject> it( m_objectsToGroup );
487 for ( ; it.current() ; ++it )
489 it.current()->setSelected(
false );
490 position = m_page->takeObject(it.current() );
491 r |= it.current()->getRealRect();
494 m_groupObject->setUpdateObjects(
false );
495 m_groupObject->setOrig( r.x(), r.y() );
496 m_groupObject->setSize( r.width(), r.height() );
497 m_page->insertObject( m_groupObject, position );
498 m_groupObject->addToObjList();
499 m_groupObject->setUpdateObjects(
true );
500 m_groupObject->setSelected(
true );
501 m_doc->refreshGroupButton();
503 m_doc->repaint(
false );
505 m_doc->updateSideBarItem( m_page );
508void KPrGroupObjCmd::unexecute()
510 m_groupObject->setUpdateObjects(
false );
512 m_page->setObjectList( m_oldObjectList );
513 m_groupObject->removeFromObjList();
515 TQPtrListIterator<KPrObject> it( m_objectsToGroup );
516 for ( ; it.current() ; ++it )
518 it.current()->addToObjList();
519 it.current()->setSelected(
true );
522 m_doc->refreshGroupButton();
524 m_doc->repaint(
false );
526 m_doc->updateSideBarItem( m_page );
529UnGroupObjCmd::UnGroupObjCmd(
const TQString &_name,
530 KPrGroupObject *grpObj_,
531 KPrDocument *_doc, KPrPage *_page )
532: KNamedCommand( _name )
533, m_groupedObjects( grpObj_->getObjects() )
534, m_groupObject( grpObj_ )
538 m_groupObject->incCmdRef();
541UnGroupObjCmd::~UnGroupObjCmd()
543 m_groupObject->decCmdRef();
546void UnGroupObjCmd::execute()
548 m_groupObject->setUpdateObjects(
false );
550 int position = m_page->takeObject( m_groupObject );
551 m_groupObject->removeFromObjList();
553 TQPtrListIterator<KPrObject> it( m_groupedObjects );
554 for ( it.toLast(); it.current() ; --it )
556 m_page->insertObject( it.current(), position );
557 it.current()->addToObjList();
558 it.current()->setSelected(
true );
561 m_doc->refreshGroupButton();
563 m_doc->repaint(
false );
565 m_doc->updateSideBarItem( m_page );
568void UnGroupObjCmd::unexecute()
572 TQPtrListIterator<KPrObject> it( m_groupedObjects );
573 for ( ; it.current() ; ++it )
575 it.current()->setSelected(
false );
576 position = m_page->takeObject( it.current() );
577 r |= it.current()->getRealRect();
580 m_groupObject->setUpdateObjects(
false );
581 m_groupObject->setOrig( r.x(), r.y() );
582 m_groupObject->setSize( r.width(), r.height() );
583 m_page->insertObject( m_groupObject, position );
584 m_groupObject->addToObjList();
585 m_groupObject->setUpdateObjects(
true );
586 m_groupObject->setSelected(
true );
587 m_doc->refreshGroupButton();
589 m_doc->repaint(
false );
591 m_doc->updateSideBarItem( m_page );
594KPrInsertCmd::KPrInsertCmd(
const TQString &name,
const TQValueList<KPrObject *> objects,
595 KPrDocument *doc, KPrPage *page )
596: KNamedCommand( name )
597, m_objects( objects )
602 TQValueListConstIterator<KPrObject *> it( m_objects.begin() );
603 for ( ; it != m_objects.end(); ++it )
605 ( *it )->incCmdRef();
609KPrInsertCmd::KPrInsertCmd(
const TQString &name, KPrObject *
object,
610 KPrDocument *doc, KPrPage *page )
611: KNamedCommand( name )
616 m_object->incCmdRef();
619KPrInsertCmd::~KPrInsertCmd()
623 m_object->decCmdRef();
627 TQValueListConstIterator<KPrObject *> it( m_objects.begin() );
628 for ( ; it != m_objects.end(); ++it )
630 ( *it )->decCmdRef();
635void KPrInsertCmd::execute()
639 m_page->appendObject( m_object );
640 m_object->addToObjList();
641 if ( m_object->getType() == OT_TEXT )
642 m_doc->updateRuler();
643 m_doc->repaint( m_object );
647 m_page->appendObjects( m_objects );
648 TQValueListConstIterator<KPrObject *> it( m_objects.begin() );
649 bool updateRuler =
false;
650 for ( ; it != m_objects.end(); ++it )
652 ( *it )->addToObjList();
653 if ( ( *it )->getType() == OT_TEXT )
655 m_doc->repaint( *it );
658 m_doc->updateRuler();
661 m_doc->updateSideBarItem( m_page );
664void KPrInsertCmd::unexecute()
668 TQRect oldRect = m_doc->zoomHandler()->zoomRect( m_object->getRepaintRect() );
669 TQPtrList<KPrObject> list(m_page->objectList());
670 if ( list.findRef( m_object ) != -1 ) {
671 m_page->takeObject( m_object );
672 m_object->removeFromObjList();
673 if ( m_object->getType() == OT_TEXT )
675 m_doc->terminateEditing( (KPrTextObject*)m_object );
676 ((KPrTextObject*)m_object)->setEditingTextObj(
false );
677 m_doc->updateRuler();
680 m_doc->repaint( oldRect );
684 TQPtrList<KPrObject> list(m_page->objectList());
685 bool updateRuler =
false;
687 TQValueListConstIterator<KPrObject *> it( m_objects.begin() );
688 for ( ; it != m_objects.end(); ++it )
690 if ( list.findRef( *it ) != -1 )
692 m_page->takeObject( *it );
693 ( *it )->removeFromObjList();
694 if ( ( *it )->getType() == OT_TEXT )
696 m_doc->terminateEditing( (KPrTextObject*)( *it ) );
697 ( (KPrTextObject*) *it )->setEditingTextObj(
false );
703 m_doc->updateRuler();
705 m_doc->repaint(
false );
708 m_doc->updateSideBarItem( m_page );
711KPrLowerRaiseCmd::KPrLowerRaiseCmd(
const TQString &_name,
const TQPtrList<KPrObject>& _oldList,
712 const TQPtrList<KPrObject>& _newList, KPrDocument *_doc,
714 : KNamedCommand( _name )
719 oldList.setAutoDelete(
false );
720 newList.setAutoDelete(
false );
723 TQPtrListIterator<KPrObject> it( oldList );
724 for ( ; it.current() ; ++it )
725 it.current()->incCmdRef();
728KPrLowerRaiseCmd::~KPrLowerRaiseCmd()
730 TQPtrListIterator<KPrObject> it( oldList );
731 for ( ; it.current() ; ++it )
732 it.current()->decCmdRef();
735void KPrLowerRaiseCmd::execute()
737 m_page->setObjectList( newList );
738 doc->repaint(
false );
740 doc->updateSideBarItem( m_page );
743void KPrLowerRaiseCmd::unexecute()
745 m_page->setObjectList( oldList );
746 doc->repaint(
false );
748 doc->updateSideBarItem( m_page );
752KPrMoveByCmd::KPrMoveByCmd(
const TQString &_name,
const KoPoint &_diff, TQPtrList<KPrObject> &_objects,
753 KPrDocument *_doc,KPrPage *_page )
754 : KNamedCommand( _name ), diff( _diff ), objects( _objects )
756 objects.setAutoDelete(
false );
759 TQPtrListIterator<KPrObject> it( objects );
760 for ( ; it.current() ; ++it )
762 it.current()->incCmdRef();
766KPrMoveByCmd::~KPrMoveByCmd()
768 TQPtrListIterator<KPrObject> it( objects );
769 for ( ; it.current() ; ++it )
770 it.current()->decCmdRef();
773void KPrMoveByCmd::execute()
777 for (
unsigned int i = 0; i < objects.count(); i++ ) {
778 oldRect = doc->zoomHandler()->zoomRect( objects.at( i )->getRepaintRect() );
779 objects.at( i )->moveBy( diff );
780 if ( objects.at( i )->getType() == OT_TEXT )
782 if(objects.at(i)->isSelected())
785 doc->repaint( oldRect );
786 doc->repaint( objects.at( i ) );
789 doc->updateSideBarItem( m_page );
790 doc->updateObjectStatusBarItem();
793void KPrMoveByCmd::unexecute()
797 for (
unsigned int i = 0; i < objects.count(); i++ ) {
798 oldRect = doc->zoomHandler()->zoomRect( objects.at( i )->getRepaintRect() );
799 objects.at( i )->moveBy( -diff.x(), -diff.y() );
800 if ( objects.at( i )->getType() == OT_TEXT )
802 if(objects.at(i)->isSelected())
805 doc->repaint( oldRect );
806 doc->repaint( objects.at( i ) );
809 doc->updateSideBarItem( m_page );
810 doc->updateObjectStatusBarItem();
813KPrAlignCmd::KPrAlignCmd(
const TQString &_name, TQPtrList<KPrObject> &_objects, AlignType _at, KPrDocument *_doc )
814 : KNamedCommand( _name ), doc(_doc)
816 objects.setAutoDelete(
false );
817 diffs.setAutoDelete(
true );
818 m_page = doc->findPage( _objects );
820 TQPtrListIterator<KPrObject> it( _objects );
822 for ( ; it.current() ; ++it )
824 boundingRect |= it.current()->getRealRect();
827 if ( _objects.count() == 1 )
828 boundingRect = m_page->getPageRect();
831 for ( ; it.current() ; ++it )
833 KoPoint * diff = NULL;
837 diff =
new KoPoint( boundingRect.x() - it.current()->getRealOrig().x(), 0 );
840 diff =
new KoPoint( 0, boundingRect.y() - it.current()->getRealOrig().y() );
843 diff =
new KoPoint( boundingRect.x() + boundingRect.width() -
844 it.current()->getRealOrig().x() - it.current()->getRealSize().width(), 0 );
847 diff =
new KoPoint( 0, boundingRect.y() + boundingRect.height() -
848 it.current()->getRealOrig().y() - it.current()->getRealSize().height() );
851 diff =
new KoPoint( ( boundingRect.width() - it.current()->getRealSize().width() ) / 2 -
852 it.current()->getRealOrig().x() + boundingRect.x(), 0 );
855 diff =
new KoPoint( 0, ( boundingRect.height() - it.current()->getRealSize().height() ) / 2 -
856 it.current()->getRealOrig().y() + boundingRect.y() );
861 objects.append( it.current() );
862 diffs.append( diff );
863 it.current()->incCmdRef();
868KPrAlignCmd::~KPrAlignCmd()
870 TQPtrListIterator<KPrObject> it( objects );
871 for ( ; it.current() ; ++it )
872 it.current()->decCmdRef();
877void KPrAlignCmd::execute()
881 for (
unsigned int i = 0; i < objects.count(); i++ ) {
882 oldRect = doc->zoomHandler()->zoomRect( objects.at( i )->getRepaintRect() );
883 objects.at( i )->moveBy( *diffs.at( i ) );
884 if ( objects.at( i )->getType() == OT_TEXT )
886 if(objects.at(i)->isSelected())
890 doc->repaint( oldRect );
891 doc->repaint( objects.at( i ) );
894 doc->updateSideBarItem( m_page );
897void KPrAlignCmd::unexecute()
901 for (
unsigned int i = 0; i < objects.count(); i++ ) {
902 oldRect = doc->zoomHandler()->zoomRect(objects.at( i )->getRepaintRect() );
903 objects.at( i )->moveBy( -diffs.at( i )->x(), -diffs.at( i )->y() );
904 if ( objects.at( i )->getType() == OT_TEXT )
906 if(objects.at(i)->isSelected())
909 doc->repaint( oldRect );
910 doc->repaint( objects.at( i ) );
914 doc->updateSideBarItem( m_page );
917KoPenCmd::KoPenCmd(
const TQString &_name, TQPtrList<KPrObject> &_objects, Pen _newPen,
918 KPrDocument *_doc, KPrPage *_page,
int _flags )
919: KNamedCommand(_name), doc(_doc), m_page( _page ), newPen(_newPen), flags(_flags)
921 objects.setAutoDelete(
false );
922 oldPen.setAutoDelete(
false );
924 addObjects( _objects );
929 TQPtrListIterator<KPrObject> it( objects );
930 for ( ; it.current() ; ++it )
931 it.current()->decCmdRef();
933 oldPen.setAutoDelete(
true );
937void KoPenCmd::execute()
939 for (
int i = 0; i < static_cast<int>( objects.count() ); i++ )
941 Pen tmpPen = *oldPen.at( i );
943 if ( flags & BeginLine )
944 tmpPen.lineBegin = newPen.lineBegin;
946 if ( flags & EndLine )
947 tmpPen.lineEnd = newPen.lineEnd;
950 tmpPen.pen.setColor( newPen.pen.color() );
953 tmpPen.pen.setPointWidth( newPen.pen.pointWidth() );
956 tmpPen.pen.setStyle( newPen.pen.style() );
958 applyPen( objects.at( i ), &tmpPen );
963 doc->updateObjectSelected();
964 doc->updateSideBarItem( m_page );
967void KoPenCmd::applyPen( KPrObject *
object, Pen *tmpPen )
969 switch (object->getType()) {
972 KPrLineObject* obj=
dynamic_cast<KPrLineObject*
>( object );
976 obj->setLineBegin( tmpPen->lineBegin );
977 obj->setLineEnd( tmpPen->lineEnd );
983 case OT_QUADRICBEZIERCURVE:
984 case OT_CUBICBEZIERCURVE:
986 KPrPointObject *obj =
dynamic_cast<KPrPointObject*
>( object );
990 obj->setLineBegin( tmpPen->lineBegin );
991 obj->setLineEnd( tmpPen->lineEnd );
997 KPrPieObject *obj =
dynamic_cast<KPrPieObject*
>( object );
1000 obj->setLineBegin( tmpPen->lineBegin );
1001 obj->setLineEnd( tmpPen->lineEnd );
1006 KPrAutoformObject *obj =
dynamic_cast<KPrAutoformObject*
>( object );
1009 obj->setLineBegin( tmpPen->lineBegin );
1010 obj->setLineEnd( tmpPen->lineEnd );
1017 KPrShadowObject *obj =
dynamic_cast<KPrShadowObject*
>( object );
1020 obj->setPen( tmpPen->pen );
1021 doc->repaint( obj );
1025void KoPenCmd::unexecute()
1027 for (
unsigned int i = 0; i < objects.count(); ++i ) {
1028 if( oldPen.count() > i )
1029 applyPen( objects.at( i ), oldPen.at( i ) );
1034 doc->updateObjectSelected();
1035 doc->updateSideBarItem( m_page );
1038void KoPenCmd::addObjects(
const TQPtrList<KPrObject> &_objects )
1040 TQPtrListIterator<KPrObject> it( _objects );
1041 for ( ; it.current(); ++it )
1043 KPrObject * object( it.current() );
1044 if ( object->getType() == OT_GROUP )
1046 KPrGroupObject * obj=
dynamic_cast<KPrGroupObject*
>( object );
1049 addObjects( obj->objectList() );
1055 ::LineEnd lineBegin = L_NORMAL;
1056 ::LineEnd lineEnd = L_NORMAL;
1057 switch ( it.current()->getType() ) {
1060 KPrLineObject *obj=
dynamic_cast<KPrLineObject*
>( object );
1063 lineBegin = obj->getLineBegin();
1064 lineEnd = obj->getLineEnd();
1069 case OT_QUADRICBEZIERCURVE:
1070 case OT_CUBICBEZIERCURVE:
1072 KPrPointObject *obj =
dynamic_cast<KPrPointObject*
>( object );
1075 lineBegin = obj->getLineBegin();
1076 lineEnd = obj->getLineEnd();
1081 KPrPieObject *obj =
dynamic_cast<KPrPieObject*
>( object );
1084 lineBegin = obj->getLineBegin();
1085 lineEnd = obj->getLineEnd();
1090 KPrAutoformObject *obj =
dynamic_cast<KPrAutoformObject*
>( object );
1093 lineBegin = obj->getLineBegin();
1094 lineEnd = obj->getLineEnd();
1101 KPrShadowObject *obj =
dynamic_cast<KPrShadowObject*
>( object );
1104 objects.append( obj );
1107 Pen * pen =
new KoPenCmd::Pen( obj->getPen(), lineBegin, lineEnd );
1109 oldPen.append( pen );
1116KPrBrushCmd::KPrBrushCmd(
const TQString &_name, TQPtrList<KPrObject> &_objects, Brush _newBrush,
1117 KPrDocument *_doc, KPrPage *_page,
int _flags )
1118: KNamedCommand(_name), doc(_doc), newBrush(_newBrush), m_page(_page), flags(_flags)
1120 objects.setAutoDelete(
false );
1121 oldBrush.setAutoDelete(
false );
1123 addObjects( _objects );
1126void KPrBrushCmd::addObjects(
const TQPtrList<KPrObject> &_objects )
1128 TQPtrListIterator<KPrObject> it( _objects );
1129 for ( ; it.current(); ++it )
1131 if ( it.current()->getType() == OT_GROUP )
1133 KPrGroupObject * obj=
dynamic_cast<KPrGroupObject*
>( it.current() );
1136 addObjects( obj->objectList() );
1141 KPr2DObject * obj =
dynamic_cast<KPr2DObject *
>( it.current() );
1144 objects.append( obj );
1147 Brush * brush =
new KPrBrushCmd::Brush;
1148 brush->brush = obj->getBrush();
1149 brush->fillType = obj->getFillType();
1150 brush->gColor1 = obj->getGColor1();
1151 brush->gColor2 = obj->getGColor2();
1152 brush->gType = obj->getGType();
1153 brush->unbalanced = obj->getGUnbalanced();
1154 brush->xfactor = obj->getGXFactor();
1155 brush->yfactor = obj->getGYFactor();
1157 oldBrush.append( brush );
1163KPrBrushCmd::~KPrBrushCmd()
1165 TQPtrListIterator<KPr2DObject> it( objects );
1166 for ( ; it.current() ; ++it )
1167 it.current()->decCmdRef();
1169 oldBrush.setAutoDelete(
true );
1173void KPrBrushCmd::execute()
1175 for (
int i = 0; i < static_cast<int>( objects.count() ); i++ )
1177 Brush tmpBrush = *oldBrush.at( i );
1179 if ( flags & BrushColor )
1180 tmpBrush.brush.setColor( newBrush.brush.color() );
1182 if ( flags & BrushStyle )
1183 tmpBrush.brush.setStyle( newBrush.brush.style() );
1185 if ( flags & BrushGradientSelect )
1186 tmpBrush.fillType = newBrush.fillType;
1188 if ( flags & GradientColor1 )
1189 tmpBrush.gColor1 = newBrush.gColor1;
1191 if ( flags & GradientColor2 )
1192 tmpBrush.gColor2 = newBrush.gColor2;
1194 if ( flags & GradientType )
1195 tmpBrush.gType = newBrush.gType;
1197 if ( flags & GradientBalanced )
1198 tmpBrush.unbalanced = newBrush.unbalanced;
1200 if ( flags & GradientXFactor )
1201 tmpBrush.xfactor = newBrush.xfactor;
1203 if ( flags & GradientYFactor )
1204 tmpBrush.yfactor = newBrush.yfactor;
1206 applyBrush( objects.at( i ), &tmpBrush );
1209 doc->updateSideBarItem( m_page );
1212void KPrBrushCmd::applyBrush( KPr2DObject *
object, Brush *tmpBrush )
1214 object->setBrush( tmpBrush->brush );
1215 object->setFillType( tmpBrush->fillType );
1216 object->setGColor1( tmpBrush->gColor1 );
1217 object->setGColor2( tmpBrush->gColor2 );
1218 object->setGType( tmpBrush->gType );
1219 object->setGUnbalanced( tmpBrush->unbalanced );
1220 object->setGXFactor( tmpBrush->xfactor );
1221 object->setGYFactor( tmpBrush->yfactor );
1222 doc->repaint(
object );
1225void KPrBrushCmd::unexecute()
1227 for (
unsigned int i = 0; i < objects.count(); i++ ) {
1228 applyBrush( objects.at( i ), oldBrush.at( i ) );
1231 doc->updateSideBarItem( m_page );
1235KPrPgConfCmd::KPrPgConfCmd(
const TQString &_name,
bool _manualSwitch,
bool _infiniteLoop,
1236 bool _showEndOfPresentationSlide,
bool _showPresentationDuration, TQPen _pen,
1237 TQValueList<bool> _selectedSlides,
const TQString & _presentationName,
1238 bool _oldManualSwitch,
bool _oldInfiniteLoop,
1239 bool _oldShowEndOfPresentationSlide,
bool _oldShowPresentationDuration, TQPen _oldPen,
1240 TQValueList<bool> _oldSelectedSlides,
const TQString & _oldPresentationName,
1242 : KNamedCommand( _name )
1244 manualSwitch = _manualSwitch;
1245 infiniteLoop = _infiniteLoop;
1246 showEndOfPresentationSlide = _showEndOfPresentationSlide;
1247 showPresentationDuration = _showPresentationDuration;
1249 selectedSlides = _selectedSlides;
1250 oldManualSwitch = _oldManualSwitch;
1251 oldInfiniteLoop = _oldInfiniteLoop;
1252 oldShowEndOfPresentationSlide = _oldShowEndOfPresentationSlide;
1253 oldShowPresentationDuration = _oldShowPresentationDuration;
1255 oldSelectedSlides = _oldSelectedSlides;
1256 oldPresentationName = _oldPresentationName;
1257 presentationName = _presentationName;
1261void KPrPgConfCmd::execute()
1263 doc->setManualSwitch( manualSwitch );
1264 doc->setInfiniteLoop( infiniteLoop );
1265 doc->setShowEndOfPresentationSlide ( showEndOfPresentationSlide );
1266 doc->setPresentationDuration( showPresentationDuration );
1267 doc->setPresPen( pen );
1268 doc->setPresentationName( presentationName );
1269 TQPtrList<KPrPage> pages = doc->pageList();
1270 unsigned count = selectedSlides.count();
1271 if( count > pages.count() ) count = pages.count();
1272 for(
unsigned i = 0; i < selectedSlides.count(); i++ )
1273 pages.at( i )->slideSelected( selectedSlides[ i ] );
1276void KPrPgConfCmd::unexecute()
1278 doc->setManualSwitch( oldManualSwitch );
1279 doc->setInfiniteLoop( oldInfiniteLoop );
1280 doc->setShowEndOfPresentationSlide( oldShowEndOfPresentationSlide );
1281 doc->setPresentationDuration( oldShowPresentationDuration );
1282 doc->setPresPen( oldPen );
1283 doc->setPresentationName( oldPresentationName );
1285 TQPtrList<KPrPage> pages = doc->pageList();
1286 unsigned count = oldSelectedSlides.count();
1287 if( count > pages.count() ) count = pages.count();
1288 for(
unsigned i = 0; i < oldSelectedSlides.count(); i++ )
1289 pages.at( i )->slideSelected( oldSelectedSlides[ i ] );
1293KPrTransEffectCmd::KPrTransEffectCmd( TQValueVector<PageEffectSettings> oldSettings,
1294 PageEffectSettings newSettings,
1295 KPrPage* page, KPrDocument* doc )
1297 m_newSettings = newSettings;
1298 m_oldSettings = oldSettings;
1299 Q_ASSERT( !m_oldSettings.isEmpty() );
1304void KPrTransEffectCmd::PageEffectSettings::applyTo( KPrPage *page )
1306 page->setPageEffect( pageEffect );
1307 page->setPageEffectSpeed( effectSpeed );
1308 page->setPageSoundEffect( soundEffect );
1309 page->setPageSoundFileName( soundFileName );
1311 page->setPageTimer( slideTime );
1314void KPrTransEffectCmd::execute()
1317 m_newSettings.applyTo( m_page );
1319 for( TQPtrListIterator<KPrPage> it( m_doc->getPageList() ); *it; ++it )
1320 m_newSettings.applyTo( it.current() );
1323void KPrTransEffectCmd::unexecute()
1326 m_oldSettings[0].applyTo( m_page );
1329 for( TQPtrListIterator<KPrPage> it( m_doc->getPageList() ); *it; ++it, ++i )
1330 m_oldSettings[i].applyTo( it.current() );
1334TQString KPrTransEffectCmd::name()
const
1337 return i18n(
"Modify Slide Transition" );
1339 return i18n(
"Modify Slide Transition For All Pages" );
1342KPrPgLayoutCmd::KPrPgLayoutCmd(
const TQString &_name, KoPageLayout _layout, KoPageLayout _oldLayout,
1343 KoUnit::Unit _oldUnit, KoUnit::Unit _unit,KPrDocument *_doc )
1344 : KNamedCommand( _name )
1348 oldLayout = _oldLayout;
1353void KPrPgLayoutCmd::execute()
1355 m_doc->setUnit( unit );
1356 m_doc->setPageLayout( layout );
1357 m_doc->updateHeaderFooterPosition();
1358 m_doc->updateRuler();
1359 m_doc->updateRulerPageLayout();
1362void KPrPgLayoutCmd::unexecute()
1364 m_doc->setUnit( oldUnit );
1365 m_doc->setPageLayout( oldLayout );
1366 m_doc->updateHeaderFooterPosition();
1367 m_doc->updateRuler();
1368 m_doc->updateRulerPageLayout();
1372KPrPieValueCmd::KPrPieValueCmd(
const TQString &name, PieValues newValues,
1373 TQPtrList<KPrObject> &objects, KPrDocument *doc,
1374 KPrPage *page,
int flags )
1375: KNamedCommand( name )
1378, m_newValues( newValues )
1381 m_objects.setAutoDelete(
false );
1382 m_oldValues.setAutoDelete(
false );
1384 addObjects( objects );
1387KPrPieValueCmd::KPrPieValueCmd(
const TQString &_name, TQPtrList<PieValues> &_oldValues, PieValues _newValues,
1388 TQPtrList<KPrObject> &_objects, KPrDocument *_doc, KPrPage *_page,
int _flags )
1389 : KNamedCommand( _name ), m_oldValues( _oldValues ), m_objects( _objects ), m_flags(_flags)
1391 m_objects.setAutoDelete(
false );
1392 m_oldValues.setAutoDelete(
false );
1395 m_newValues = _newValues;
1397 TQPtrListIterator<KPrObject> it( m_objects );
1398 for ( ; it.current() ; ++it )
1399 it.current()->incCmdRef();
1402KPrPieValueCmd::~KPrPieValueCmd()
1404 TQPtrListIterator<KPrObject> it( m_objects );
1405 for ( ; it.current() ; ++it )
1406 it.current()->decCmdRef();
1407 m_oldValues.setAutoDelete(
true );
1408 m_oldValues.clear();
1411void KPrPieValueCmd::addObjects(
const TQPtrList<KPrObject> &objects )
1413 TQPtrListIterator<KPrObject> it( objects );
1414 for ( ; it.current(); ++it )
1416 if ( it.current()->getType() == OT_GROUP )
1418 KPrGroupObject * obj =
dynamic_cast<KPrGroupObject*
>( it.current() );
1421 addObjects( obj->objectList() );
1426 KPrPieObject *obj =
dynamic_cast<KPrPieObject*
>( it.current() );
1429 m_objects.append( obj );
1432 PieValues * pieValues =
new PieValues;
1433 pieValues->pieType = obj->getPieType();
1434 pieValues->pieAngle = obj->getPieAngle();
1435 pieValues->pieLength = obj->getPieLength();
1436 m_oldValues.append( pieValues );
1442void KPrPieValueCmd::execute()
1444 TQPtrListIterator<KPrObject> it( m_objects );
1445 for ( ; it.current() ; ++it )
1447 KPrPieObject* obj=
dynamic_cast<KPrPieObject*
>( it.current() );
1451 obj->setPieType( m_newValues.pieType );
1452 if (m_flags & Angle)
1453 obj->setPieAngle( m_newValues.pieAngle );
1454 if (m_flags & Length)
1455 obj->setPieLength( m_newValues.pieLength );
1458 m_doc->repaint(
false );
1460 m_doc->updateSideBarItem( m_page );
1463void KPrPieValueCmd::unexecute()
1465 for (
unsigned int i = 0; i < m_objects.count(); i++ )
1467 KPrPieObject* obj=
dynamic_cast<KPrPieObject*
>( m_objects.at( i ) );
1470 obj->setPieType( m_oldValues.at( i )->pieType );
1471 obj->setPieAngle( m_oldValues.at( i )->pieAngle );
1472 obj->setPieLength( m_oldValues.at( i )->pieLength );
1475 m_doc->repaint(
false );
1477 m_doc->updateSideBarItem( m_page );
1481KPrPolygonSettingCmd::KPrPolygonSettingCmd(
const TQString &name, PolygonSettings newSettings,
1482 TQPtrList<KPrObject> &objects, KPrDocument *doc,
1483 KPrPage *page,
int flags )
1484: KNamedCommand( name )
1487, m_newSettings( newSettings )
1490 m_objects.setAutoDelete(
false );
1491 m_oldSettings.setAutoDelete(
false );
1493 addObjects( objects );
1497KPrPolygonSettingCmd::~KPrPolygonSettingCmd()
1499 TQPtrListIterator<KPrObject> it( m_objects );
1500 for ( ; it.current() ; ++it )
1501 it.current()->decCmdRef();
1502 m_oldSettings.setAutoDelete(
true );
1503 m_oldSettings.clear();
1506void KPrPolygonSettingCmd::addObjects(
const TQPtrList<KPrObject> &objects )
1508 TQPtrListIterator<KPrObject> it( objects );
1509 for ( ; it.current(); ++it )
1511 if ( it.current()->getType() == OT_GROUP )
1513 KPrGroupObject * obj =
dynamic_cast<KPrGroupObject*
>( it.current() );
1516 addObjects( obj->objectList() );
1521 KPrPolygonObject *obj =
dynamic_cast<KPrPolygonObject*
>( it.current() );
1524 m_objects.append( obj );
1527 PolygonSettings * polygonSettings =
new PolygonSettings;
1529 polygonSettings->checkConcavePolygon = obj->getCheckConcavePolygon();
1530 polygonSettings->cornersValue = obj->getCornersValue();
1531 polygonSettings->sharpnessValue = obj->getSharpnessValue();
1533 m_oldSettings.append( polygonSettings );
1539void KPrPolygonSettingCmd::execute()
1541 TQPtrListIterator<KPrObject> it( m_objects );
1542 for ( ; it.current() ; ++it )
1544 KPrPolygonObject * obj=
dynamic_cast<KPrPolygonObject*
>( it.current() );
1547 if (m_flags & ConcaveConvex)
1548 obj->setCheckConcavePolygon(m_newSettings.checkConcavePolygon);
1549 if (m_flags & Corners)
1550 obj->setCornersValue(m_newSettings.cornersValue);
1551 if (m_flags & Sharpness)
1552 obj->setSharpnessValue(m_newSettings.sharpnessValue );
1555 m_doc->repaint(
false );
1557 m_doc->updateSideBarItem( m_page );
1560void KPrPolygonSettingCmd::unexecute()
1562 for (
unsigned int i = 0; i < m_objects.count(); ++i )
1564 KPrPolygonObject * obj=
dynamic_cast<KPrPolygonObject*
>( m_objects.at(i) );
1567 obj->setCheckConcavePolygon(m_oldSettings.at( i )->checkConcavePolygon);
1568 obj->setCornersValue(m_oldSettings.at( i )->cornersValue);
1569 obj->setSharpnessValue(m_oldSettings.at( i )->sharpnessValue);
1572 m_doc->repaint(
false );
1574 m_doc->updateSideBarItem( m_page );
1578KPrPictureSettingCmd::KPrPictureSettingCmd(
const TQString &name, PictureSettings newSettings,
1579 TQPtrList<KPrObject> &objects, KPrDocument *doc,
1580 KPrPage *page,
int flags )
1581: KNamedCommand( name )
1583, m_newSettings( newSettings )
1587 m_objects.setAutoDelete(
false );
1588 m_oldValues.setAutoDelete(
false );
1590 addObjects( objects );
1593KPrPictureSettingCmd::KPrPictureSettingCmd(
const TQString &_name, TQPtrList<PictureSettings> &_oldSettings,
1594 PictureSettings _newSettings, TQPtrList<KPrObject> &_objects,
1595 KPrDocument *_doc,
int flags )
1596 : KNamedCommand( _name ), m_oldValues( _oldSettings ), m_objects( _objects ), m_flags( flags )
1598 m_objects.setAutoDelete(
false );
1599 m_oldValues.setAutoDelete(
false );
1601 m_newSettings = _newSettings;
1603 m_page = m_doc->findPage( m_objects );
1605 TQPtrListIterator<KPrObject> it( m_objects );
1606 for ( ; it.current() ; ++it )
1607 it.current()->incCmdRef();
1610KPrPictureSettingCmd::~KPrPictureSettingCmd()
1612 TQPtrListIterator<KPrObject> it( m_objects );
1613 for ( ; it.current() ; ++it )
1614 it.current()->decCmdRef();
1615 m_oldValues.setAutoDelete(
true );
1616 m_oldValues.clear();
1619void KPrPictureSettingCmd::addObjects(
const TQPtrList<KPrObject> &objects )
1621 TQPtrListIterator<KPrObject> it( objects );
1622 for ( ; it.current(); ++it )
1624 if ( it.current()->getType() == OT_GROUP )
1626 KPrGroupObject * obj =
dynamic_cast<KPrGroupObject*
>( it.current() );
1629 addObjects( obj->objectList() );
1634 KPrPixmapObject *obj =
dynamic_cast<KPrPixmapObject*
>( it.current() );
1637 m_objects.append( obj );
1640 PictureSettings * pictureSettings =
new PictureSettings;
1642 pictureSettings->mirrorType = obj->getPictureMirrorType();
1643 pictureSettings->depth = obj->getPictureDepth();
1644 pictureSettings->swapRGB = obj->getPictureSwapRGB();
1645 pictureSettings->grayscal = obj->getPictureGrayscal();
1646 pictureSettings->bright = obj->getPictureBright();
1648 m_oldValues.append( pictureSettings );
1654void KPrPictureSettingCmd::execute()
1656 TQPtrListIterator<KPrObject> it( m_objects );
1657 for ( ; it.current() ; ++it ) {
1658 KPrPixmapObject * obj =
dynamic_cast<KPrPixmapObject*
>( it.current() );
1660 if ( m_flags & MirrorType )
1661 obj->setPictureMirrorType( m_newSettings.mirrorType );
1662 if ( m_flags & Depth )
1663 obj->setPictureDepth( m_newSettings.depth );
1664 if ( m_flags & SwapRGB )
1665 obj->setPictureSwapRGB( m_newSettings.swapRGB );
1666 if ( m_flags & Grayscal )
1667 obj->setPictureGrayscal( m_newSettings.grayscal );
1668 if ( m_flags & Bright )
1669 obj->setPictureBright( m_newSettings.bright );
1672 m_doc->repaint(
false );
1674 m_doc->updateSideBarItem( m_page );
1677void KPrPictureSettingCmd::unexecute()
1679 for (
unsigned int i = 0; i < m_objects.count(); ++i ) {
1680 KPrPixmapObject * obj =
dynamic_cast<KPrPixmapObject*
>( m_objects.at(i) );
1682 PictureSettings *pictureSettings = m_oldValues.at( i );
1683 obj->setPictureMirrorType( pictureSettings->mirrorType );
1684 obj->setPictureDepth( pictureSettings->depth );
1685 obj->setPictureSwapRGB( pictureSettings->swapRGB );
1686 obj->setPictureGrayscal( pictureSettings->grayscal );
1687 obj->setPictureBright( pictureSettings->bright );
1690 m_doc->repaint(
false );
1692 m_doc->updateSideBarItem( m_page );
1696KPrRectValueCmd::KPrRectValueCmd(
const TQString &_name, TQPtrList<RectValues> &_oldValues, RectValues _newValues,
1697 TQPtrList<KPrObject> &_objects, KPrDocument *_doc, KPrPage *_page,
int _flags )
1698 : KNamedCommand( _name ), m_oldValues( _oldValues ), m_objects( _objects ), m_flags(_flags)
1700 m_objects.setAutoDelete(
false );
1701 m_oldValues.setAutoDelete(
false );
1704 m_newValues = _newValues;
1706 TQPtrListIterator<KPrObject> it( m_objects );
1707 for ( ; it.current() ; ++it )
1708 it.current()->incCmdRef();
1712KPrRectValueCmd::KPrRectValueCmd(
const TQString &name, TQPtrList<KPrObject> &objects, RectValues newValues,
1713 KPrDocument *doc, KPrPage *page,
int flags )
1714: KNamedCommand( name )
1717, m_newValues( newValues )
1720 m_objects.setAutoDelete(
false );
1721 m_oldValues.setAutoDelete(
false );
1723 addObjects( objects );
1727KPrRectValueCmd::~KPrRectValueCmd()
1729 TQPtrListIterator<KPrObject> it( m_objects );
1730 for ( ; it.current() ; ++it )
1731 it.current()->decCmdRef();
1733 m_oldValues.setAutoDelete(
true );
1734 m_oldValues.clear();
1738void KPrRectValueCmd::addObjects(
const TQPtrList<KPrObject> &objects )
1740 TQPtrListIterator<KPrObject> it( objects );
1741 for ( ; it.current(); ++it )
1743 if ( it.current()->getType() == OT_GROUP )
1745 KPrGroupObject * obj =
dynamic_cast<KPrGroupObject*
>( it.current() );
1748 addObjects( obj->objectList() );
1753 KPrRectObject *obj =
dynamic_cast<KPrRectObject*
>( it.current() );
1756 m_objects.append( obj );
1759 RectValues * rectValue =
new RectValues;
1762 obj->getRnds( xtmp, ytmp );
1763 rectValue->xRnd = xtmp;
1764 rectValue->yRnd = ytmp;
1766 m_oldValues.append( rectValue );
1773void KPrRectValueCmd::execute()
1775 TQPtrListIterator<KPrObject> it( m_objects );
1776 for ( ; it.current() ; ++it )
1778 KPrRectObject *obj =
dynamic_cast<KPrRectObject*
>( it.current() );
1782 obj->getRnds( xtmp, ytmp );
1784 if ( m_flags & XRnd )
1786 xtmp = m_newValues.xRnd;
1789 if ( m_flags & YRnd )
1791 ytmp = m_newValues.yRnd;
1794 obj->setRnds( xtmp, ytmp );
1797 m_doc->repaint(
false );
1799 m_doc->updateSideBarItem( m_page );
1802void KPrRectValueCmd::unexecute()
1804 for (
unsigned int i = 0; i < m_objects.count(); i++ )
1806 KPrRectObject *obj =
dynamic_cast<KPrRectObject*
>( m_objects.at( i ) );
1809 obj->setRnds( m_oldValues.at( i )->xRnd, m_oldValues.at( i )->yRnd );
1811 m_doc->repaint(
false );
1813 m_doc->updateSideBarItem( m_page );
1817KPrResizeCmd::KPrResizeCmd(
const TQString &_name,
const KoPoint &_m_diff,
const KoSize &_r_diff,
1818 KPrObject *_object, KPrDocument *_doc )
1819 : KNamedCommand( _name ), m_diff( _m_diff ), r_diff( _r_diff )
1823 m_page = doc->findPage(
object );
1825 object->incCmdRef();
1828KPrResizeCmd::~KPrResizeCmd()
1830 object->decCmdRef();
1833void KPrResizeCmd::execute()
1837 oldRect = doc->zoomHandler()->zoomRect( object->getRepaintRect() );
1838 object->moveBy( m_diff );
1839 object->resizeBy( r_diff );
1840 if ( object->getType() == OT_TEXT )
1842 if(object->isSelected())
1844 doc->layout(
object );
1846 if ( object->isSelected())
1847 doc->updateObjectStatusBarItem();
1848 doc->repaint( oldRect );
1849 doc->repaint(
object );
1851 doc->updateSideBarItem( m_page );
1854void KPrResizeCmd::unexecute()
1858 oldRect = doc->zoomHandler()->zoomRect( object->getRepaintRect() );
1859 object->moveBy( -m_diff.x(), -m_diff.y() );
1860 object->resizeBy( -r_diff.width(), -r_diff.height() );
1861 if ( object->getType() == OT_TEXT )
1863 if(object->isSelected())
1865 doc->layout(
object );
1867 if ( object->isSelected())
1868 doc->updateObjectStatusBarItem();
1870 doc->repaint( oldRect );
1871 doc->repaint(
object );
1873 doc->updateSideBarItem( m_page );
1877KPrOasisPasteTextCommand::KPrOasisPasteTextCommand( KoTextDocument *d,
int parag,
int idx,
1878 const TQByteArray &data )
1879 : KoTextDocCommand( d ), m_parag( parag ), m_idx( idx ), m_data( data ), m_oldParagLayout( 0 )
1883KoTextCursor * KPrOasisPasteTextCommand::execute( KoTextCursor *c )
1885 KoTextParag *firstParag = doc->paragAt( m_parag );
1886 if ( !firstParag ) {
1887 tqWarning(
"can't locate parag at %d, last parag: %d", m_parag, doc->lastParag()->paragId() );
1892 cursor.setParag( firstParag );
1893 cursor.setIndex( m_idx );
1894 c->setParag( firstParag );
1895 c->setIndex( m_idx );
1897 TQBuffer buffer( m_data );
1898 KoStore * store = KoStore::createStore( &buffer, KoStore::Read );
1900 if ( store->bad() || !store->hasFile(
"content.xml" ) )
1902 kdError(33001) <<
"Invalid ZIP store in memory" << endl;
1903 if ( !store->hasFile(
"content.xml" ) )
1904 kdError(33001) <<
"No content.xml file" << endl;
1907 store->disallowNameExpansion();
1909 KoOasisStore oasisStore( store );
1910 TQDomDocument contentDoc;
1911 TQString errorMessage;
1912 bool ok = oasisStore.loadAndParse(
"content.xml", contentDoc, errorMessage );
1914 kdError(33001) <<
"Error parsing content.xml: " << errorMessage << endl;
1918 KoOasisStyles oasisStyles;
1919 TQDomDocument stylesDoc;
1920 (void)oasisStore.loadAndParse(
"styles.xml", stylesDoc, errorMessage );
1922 oasisStyles.createStyleMap( stylesDoc,
true );
1924 oasisStyles.createStyleMap( contentDoc,
false );
1926 TQDomElement content = contentDoc.documentElement();
1928 TQDomElement body ( KoDom::namedItemNS( content, KoXmlNS::office,
"body" ) );
1932 TQDomElement iter, realBody;
1933 forEachElement( iter, body ) {
1936 if ( realBody.isNull() ) {
1937 kdError(33001) <<
"No element found inside office:body!" << endl;
1941 KPrTextDocument * textdoc =
static_cast<KPrTextDocument *
>(c->parag()->document());
1942 KPrDocument *doc = textdoc->
textObject()->kPresenterDocument();
1943 KoOasisContext context( doc, *doc->getVariableCollection(), oasisStyles, store );
1945 *c = textdoc->
textObject()->textObject()->pasteOasisText( realBody, context, cursor, doc->styleCollection() );
1946 textdoc->
textObject()->textObject()->setNeedSpellCheck(
true );
1948 m_lastParag = c->parag()->paragId();
1949 m_lastIndex = c->index();
1953KoTextCursor * KPrOasisPasteTextCommand::unexecute( KoTextCursor *c )
1955 KoTextParag *firstParag = doc->paragAt( m_parag );
1956 if ( !firstParag ) {
1957 tqWarning(
"can't locate parag at %d, last parag: %d", m_parag, doc->lastParag()->paragId() );
1960 cursor.setParag( firstParag );
1961 cursor.setIndex( m_idx );
1962 doc->setSelectionStart( KoTextDocument::Temp, &cursor );
1964 KoTextParag *lastParag = doc->paragAt( m_lastParag );
1966 tqWarning(
"can't locate parag at %d, last parag: %d", m_lastParag, doc->lastParag()->paragId() );
1976 cursor.setParag( lastParag );
1977 cursor.setIndex( m_lastIndex );
1978 doc->setSelectionEnd( KoTextDocument::Temp, &cursor );
1979 doc->removeSelectedText( KoTextDocument::Temp, c );
1982 Q_ASSERT( m_oldParagLayout );
1983 if ( m_oldParagLayout )
1984 firstParag->setParagLayout( *m_oldParagLayout );
1990KPrChangeStartingPageCommand::KPrChangeStartingPageCommand(
const TQString &name, KPrDocument *_doc,
1991 int _oldStartingPage,
int _newStartingPage):
1992 KNamedCommand(name),
1994 oldStartingPage(_oldStartingPage),
1995 newStartingPage(_newStartingPage)
1999void KPrChangeStartingPageCommand::execute()
2001 m_doc->getVariableCollection()->variableSetting()->setStartingPageNumber(newStartingPage);
2002 m_doc->recalcVariables( VT_PGNUM );
2005void KPrChangeStartingPageCommand::unexecute()
2007 m_doc->getVariableCollection()->variableSetting()->setStartingPageNumber(oldStartingPage);
2008 m_doc->recalcVariables( VT_PGNUM );
2012KPrChangeVariableSettingsCommand::KPrChangeVariableSettingsCommand(
const TQString &name, KPrDocument *_doc,
2013 bool _oldValue,
bool _newValue,
2014 VariableProperties _type):
2015 KNamedCommand(name),
2018 m_bOldValue(_oldValue),
2019 m_bNewValue(_newValue)
2023void KPrChangeVariableSettingsCommand::changeValue(
bool b )
2027 case VS_DISPLAYLINK:
2028 m_doc->getVariableCollection()->variableSetting()->setDisplayLink(b);
2029 m_doc->recalcVariables( VT_LINK );
2031 case VS_UNDERLINELINK:
2032 m_doc->getVariableCollection()->variableSetting()->setUnderlineLink(b);
2033 m_doc->recalcVariables( VT_LINK );
2035 case VS_DISPLAYCOMMENT:
2036 m_doc->getVariableCollection()->variableSetting()->setDisplayComment(b);
2037 m_doc->recalcVariables( VT_NOTE );
2039 case VS_DISPLAYFIELDCODE:
2040 m_doc->getVariableCollection()->variableSetting()->setDisplayFieldCode(b);
2041 m_doc->recalcVariables( VT_ALL );
2046void KPrChangeVariableSettingsCommand::execute()
2048 changeValue(m_bNewValue);
2051void KPrChangeVariableSettingsCommand::unexecute()
2053 changeValue(m_bOldValue);
2056KPrDeletePageCmd::KPrDeletePageCmd(
const TQString &name,
int pageNum, KPrDocument *doc )
2057: KNamedCommand( name )
2059, m_pageNum( pageNum )
2061 m_page = m_doc->pageList().at( m_pageNum );
2064KPrDeletePageCmd::~KPrDeletePageCmd()
2068void KPrDeletePageCmd::execute()
2070 m_doc->deSelectAllObj();
2071 m_doc->takePage( m_page, TQMAX( m_pageNum - 1, 0 ) );
2072 m_doc->updatePresentationButton();
2075void KPrDeletePageCmd::unexecute()
2077 m_doc->deSelectAllObj();
2078 m_doc->insertPage( m_page, TQMAX( m_pageNum - 1, 0 ), m_pageNum );
2079 m_doc->updatePresentationButton();
2082KPrInsertPageCmd::KPrInsertPageCmd(
const TQString &name,
int pageNum, InsertPos pos,
2083 KPrPage *page, KPrDocument *doc )
2084: KNamedCommand(name)
2087, m_currentPageNum( pageNum )
2088, m_insertPageNum( 0 )
2093 m_insertPageNum = m_currentPageNum;
2096 m_insertPageNum = m_currentPageNum + 1;
2101KPrInsertPageCmd::~KPrInsertPageCmd()
2105void KPrInsertPageCmd::execute()
2107 m_doc->deSelectAllObj();
2108 m_doc->insertPage( m_page, m_currentPageNum, m_insertPageNum );
2109 m_page->completeLoading(
false, -1 );
2110 m_doc->updatePresentationButton();
2113void KPrInsertPageCmd::unexecute()
2115 m_doc->deSelectAllObj();
2116 m_doc->takePage( m_page, m_currentPageNum );
2117 m_doc->updatePresentationButton();
2120KPrMovePageCmd::KPrMovePageCmd(
const TQString &_name,
int from,
int to, KPrDocument *_doc ) :
2121 KNamedCommand( _name ),
2123 m_oldPosition( from ),
2128KPrMovePageCmd::~KPrMovePageCmd()
2132void KPrMovePageCmd::execute()
2134 m_doc->deSelectAllObj();
2135 m_doc->movePageTo( m_oldPosition, m_newPosition );
2138void KPrMovePageCmd::unexecute()
2140 m_doc->deSelectAllObj();
2141 m_doc->movePageTo( m_newPosition, m_oldPosition );
2145KPrChangeTitlePageNameCommand::KPrChangeTitlePageNameCommand(
const TQString &_name,KPrDocument *_doc,
2146 const TQString &_oldPageName,
2147 const TQString &_newPageName, KPrPage *_page ) :
2148 KNamedCommand(_name),
2150 oldPageName(_oldPageName),
2151 newPageName(_newPageName),
2156void KPrChangeTitlePageNameCommand::execute()
2158 m_page->insertManualTitle(newPageName);
2159 m_doc->updateSideBarItem( m_page );
2160 m_doc->recalcVariables( VT_PGNUM );
2163void KPrChangeTitlePageNameCommand::unexecute()
2165 m_page->insertManualTitle(oldPageName);
2166 m_doc->updateSideBarItem( m_page );
2167 m_doc->recalcVariables( VT_PGNUM );
2170KPrChangeCustomVariableValue::KPrChangeCustomVariableValue(
const TQString &name, KPrDocument *_doc,
2171 const TQString & _oldValue,
const TQString & _newValue,
2172 KoCustomVariable *var):
2173 KNamedCommand(name),
2175 newValue(_newValue),
2176 oldValue(_oldValue),
2181void KPrChangeCustomVariableValue::execute()
2184 m_var->setValue(newValue);
2185 m_doc->recalcVariables( VT_CUSTOM );
2188void KPrChangeCustomVariableValue::unexecute()
2191 m_var->setValue(oldValue);
2192 m_doc->recalcVariables( VT_CUSTOM );
2195KPrChangeLinkVariable::KPrChangeLinkVariable(
const TQString &name, KPrDocument *_doc,
2196 const TQString & _oldHref,
const TQString & _newHref,
2197 const TQString & _oldLink,
const TQString &_newLink,
2198 KoLinkVariable *var):
2199 KNamedCommand(name),
2210void KPrChangeLinkVariable::execute()
2212 m_var->setLink(newLink,newHref);
2213 m_doc->recalcVariables(VT_LINK);
2216void KPrChangeLinkVariable::unexecute()
2218 m_var->setLink(oldLink,oldHref);
2219 m_doc->recalcVariables(VT_LINK);
2223KPrNameObjectCommand::KPrNameObjectCommand(
const TQString &_name,
const TQString &_objectName,
2224 KPrObject *_obj, KPrDocument *_doc ):
2225 KNamedCommand( _name ),
2226 newObjectName( _objectName ),
2230 oldObjectName =
object->getObjectName();
2232 m_page = doc->findPage(
object );
2235KPrNameObjectCommand::~KPrNameObjectCommand()
2239void KPrNameObjectCommand::execute()
2241 object->setObjectName( newObjectName );
2242 m_page->unifyObjectName(
object );
2244 doc->updateSideBarItem( m_page );
2247void KPrNameObjectCommand::unexecute()
2249 object->setObjectName( oldObjectName );
2251 doc->updateSideBarItem( m_page );
2254KPrDisplayObjectFromMasterPage::KPrDisplayObjectFromMasterPage(
const TQString &name, KPrDocument *_doc, KPrPage *_page,
bool _newValue)
2255 :KNamedCommand(name),
2262void KPrDisplayObjectFromMasterPage::execute()
2264 m_page->setDisplayObjectFromMasterPage( newValue );
2265 m_doc->updateSideBarItem( m_doc->masterPage() );
2268void KPrDisplayObjectFromMasterPage::unexecute()
2270 m_page->setDisplayObjectFromMasterPage( !newValue );
2271 m_doc->updateSideBarItem( m_doc->masterPage() );
2275KPrDisplayBackgroundPage::KPrDisplayBackgroundPage(
const TQString &name, KPrDocument *_doc, KPrPage *_page,
bool _newValue)
2276 :KNamedCommand(name),
2283void KPrDisplayBackgroundPage::execute()
2285 m_page->setDisplayBackground( newValue );
2286 m_doc->updateSideBarItem( m_doc->masterPage() );
2289void KPrDisplayBackgroundPage::unexecute()
2291 m_page->setDisplayBackground( !newValue );
2292 m_doc->updateSideBarItem( m_doc->masterPage() );
2296KPrHideShowHeaderFooter::KPrHideShowHeaderFooter(
const TQString &name, KPrDocument *_doc, KPrPage *_page,
2297 bool _newValue, KPrTextObject *_textObject):
2298 KNamedCommand(name),
2301 m_textObject(_textObject),
2307void KPrHideShowHeaderFooter::execute()
2309 if( m_textObject==m_doc->footer())
2310 m_page->setFooter( newValue );
2311 else if( m_textObject==m_doc->header())
2312 m_page->setHeader( newValue );
2314 kdDebug(33001)<<
"Error in void KPrHideShowHeaderFooter::execute()\n";
2316 m_doc->updateSideBarItem( m_doc->masterPage() );
2319void KPrHideShowHeaderFooter::unexecute()
2321 if( m_textObject==m_doc->footer())
2322 m_page->setFooter( !newValue );
2323 else if( m_textObject==m_doc->header())
2324 m_page->setHeader( !newValue );
2326 kdDebug(33001)<<
"Error in void KPrHideShowHeaderFooter::unexecute()\n";
2328 m_doc->updateSideBarItem( m_doc->masterPage() );
2331KPrFlipObjectCommand::KPrFlipObjectCommand(
const TQString &name, KPrDocument *_doc,
2332 bool _horizontal, TQPtrList<KPrObject> &_objects ):
2333 KNamedCommand( name ),
2335 objects( _objects ),
2336 horizontal( _horizontal )
2338 objects.setAutoDelete(
false );
2340 m_page = m_doc->findPage( objects );
2342 TQPtrListIterator<KPrObject> it( objects );
2343 for ( ; it.current() ; ++it )
2344 it.current()->incCmdRef();
2347KPrFlipObjectCommand::~KPrFlipObjectCommand()
2349 TQPtrListIterator<KPrObject> it( objects );
2350 for ( ; it.current() ; ++it )
2351 it.current()->decCmdRef();
2354void KPrFlipObjectCommand::execute()
2359void KPrFlipObjectCommand::unexecute()
2364void KPrFlipObjectCommand::flipObjects()
2366 TQPtrListIterator<KPrObject> it( objects );
2367 for ( ; it.current() ; ++it )
2369 it.current()->flip( horizontal );
2370 m_doc->repaint( it.current() );
2373 m_doc->updateSideBarItem( m_page );
2377KPrGeometryPropertiesCommand::KPrGeometryPropertiesCommand(
const TQString &name, TQPtrList<KPrObject> &objects,
2378 bool newValue, KgpType type,KPrDocument *_doc )
2379: KNamedCommand( name )
2380, m_objects( objects )
2381, m_newValue( newValue )
2385 TQPtrListIterator<KPrObject> it( m_objects );
2386 for ( ; it.current() ; ++it )
2388 it.current()->incCmdRef();
2389 if ( m_type == ProtectSize )
2390 m_oldValue.append( it.current()->isProtect() );
2391 else if ( m_type == KeepRatio)
2392 m_oldValue.append( it.current()->isKeepRatio() );
2396KPrGeometryPropertiesCommand::KPrGeometryPropertiesCommand(
const TQString &name, TQValueList<bool> &lst,
2397 TQPtrList<KPrObject> &objects,
bool newValue,
2398 KgpType type, KPrDocument *_doc)
2399: KNamedCommand( name )
2401, m_objects( objects )
2402, m_newValue( newValue )
2406 TQPtrListIterator<KPrObject> it( m_objects );
2407 for ( ; it.current() ; ++it )
2408 it.current()->incCmdRef();
2411KPrGeometryPropertiesCommand::~KPrGeometryPropertiesCommand()
2413 TQPtrListIterator<KPrObject> it( m_objects );
2414 for ( ; it.current() ; ++it )
2415 it.current()->decCmdRef();
2418void KPrGeometryPropertiesCommand::execute()
2420 TQPtrListIterator<KPrObject> it( m_objects );
2421 for ( ; it.current() ; ++it )
2423 if ( m_type == ProtectSize )
2425 it.current()->setProtect( m_newValue );
2426 if ( it.current()->isSelected() )
2427 m_doc->repaint( it.current() );
2429 else if ( m_type == KeepRatio)
2430 it.current()->setKeepRatio( m_newValue );
2434void KPrGeometryPropertiesCommand::unexecute()
2437 for (
unsigned int i = 0; i < m_objects.count(); ++i ) {
2438 obj = m_objects.at( i );
2439 if ( m_type == ProtectSize )
2441 obj->setProtect( *m_oldValue.at(i) );
2442 if ( obj->isSelected() )
2443 m_doc->repaint( obj );
2445 else if ( m_type == KeepRatio)
2446 obj->setKeepRatio( *m_oldValue.at(i) );
2450KPrProtectContentCommand::KPrProtectContentCommand(
const TQString &name, TQPtrList<KPrObject> &objects,
2451 bool protectContent, KPrDocument *doc )
2452: KNamedCommand( name )
2453, m_protectContent( protectContent )
2456 m_objects.setAutoDelete(
false );
2458 addObjects( objects );
2461KPrProtectContentCommand::KPrProtectContentCommand(
const TQString &name,
bool protectContent,
2462 KPrTextObject *obj, KPrDocument *doc )
2463: KNamedCommand( name )
2464, m_protectContent( protectContent )
2468 m_objects.append( obj );
2469 m_oldValues.append( obj->isProtectContent() );
2472KPrProtectContentCommand::~KPrProtectContentCommand()
2474 TQPtrListIterator<KPrTextObject> it( m_objects );
2475 for ( ; it.current() ; ++it )
2476 it.current()->decCmdRef();
2479void KPrProtectContentCommand::addObjects(
const TQPtrList<KPrObject> &objects )
2481 TQPtrListIterator<KPrObject> it( objects );
2482 for ( ; it.current(); ++it )
2484 if ( it.current()->getType() == OT_GROUP )
2486 KPrGroupObject * obj =
dynamic_cast<KPrGroupObject*
>( it.current() );
2489 addObjects( obj->objectList() );
2494 KPrTextObject *obj =
dynamic_cast<KPrTextObject*
>( it.current() );
2497 m_objects.append( obj );
2500 m_oldValues.append( obj->isProtectContent() );
2506void KPrProtectContentCommand::execute()
2508 TQPtrListIterator<KPrTextObject> it( m_objects );
2509 for ( ; it.current() ; ++it )
2511 it.current()->setProtectContent( m_protectContent );
2513 m_doc->updateObjectSelected();
2514 m_doc->updateRulerInProtectContentMode();
2518void KPrProtectContentCommand::unexecute()
2520 for (
unsigned int i = 0; i < m_objects.count(); i++ )
2522 m_objects.at( i )->setProtectContent( m_oldValues[i] );
2524 m_doc->updateObjectSelected();
2525 m_doc->updateRulerInProtectContentMode();
2528KPrCloseObjectCommand::KPrCloseObjectCommand(
const TQString &name, TQPtrList<KPrObject> objects, KPrDocument *doc )
2529: KNamedCommand( name )
2531, m_page( doc->findPage( objects.at( 0 ) ) )
2533 TQPtrListIterator<KPrObject> it( objects );
2534 for ( ; it.current(); ++it )
2536 KPrPointObject * pointObject =
dynamic_cast<KPrPointObject *
>( *it );
2539 m_openObjects.append( *it );
2540 ( *it )->incCmdRef();
2541 KPrClosedLineObject * closedObject =
new KPrClosedLineObject( *pointObject );
2542 closedObject->incCmdRef();
2543 m_closedObjects.append( closedObject );
2548KPrCloseObjectCommand::~KPrCloseObjectCommand()
2550 TQPtrListIterator<KPrObject> it( m_openObjects );
2551 for ( ; it.current() ; ++it )
2552 it.current()->decCmdRef();
2553 TQPtrListIterator<KPrObject> it2( m_closedObjects );
2554 for ( ; it2.current() ; ++it2 )
2555 it2.current()->decCmdRef();
2558void KPrCloseObjectCommand::execute()
2560 TQPtrListIterator<KPrObject> openIt( m_openObjects );
2561 TQPtrListIterator<KPrObject> closeIt( m_closedObjects );
2562 for ( ; openIt.current() ; ++openIt, ++closeIt )
2564 m_page->replaceObject( *openIt, *closeIt );
2565 bool selected = ( *openIt )->isSelected();
2566 ( *openIt )->removeFromObjList();
2567 ( *closeIt )->addToObjList();
2568 ( *openIt )->setSelected(
false );
2569 ( *closeIt )->setSelected( selected );
2570 m_doc->repaint( *closeIt );
2572 m_doc->updateSideBarItem( m_page );
2575void KPrCloseObjectCommand::unexecute()
2577 TQPtrListIterator<KPrObject> openIt( m_openObjects );
2578 TQPtrListIterator<KPrObject> closeIt( m_closedObjects );
2579 for ( ; openIt.current() ; ++openIt, ++closeIt )
2581 m_page->replaceObject( *closeIt, *openIt );
2582 bool selected = ( *closeIt )->isSelected();
2583 ( *closeIt )->removeFromObjList();
2584 ( *openIt )->addToObjList();
2585 ( *closeIt )->setSelected(
false );
2586 ( *openIt )->setSelected( selected );
2587 m_doc->repaint( *openIt );
2589 m_doc->updateSideBarItem( m_page );
2592MarginsStruct::MarginsStruct( KPrTextObject *obj )
2594 topMargin = obj->bTop();
2595 bottomMargin= obj->bBottom();
2596 leftMargin = obj->bLeft();
2597 rightMargin= obj->bRight();
2600MarginsStruct::MarginsStruct(
double _left,
double _top,
double _right,
double _bottom ):
2602 bottomMargin(_bottom),
2609KPrChangeMarginCommand::KPrChangeMarginCommand(
const TQString &name, TQPtrList<KPrObject> &objects,
2610 MarginsStruct newMargins, KPrDocument *doc,
2612: KNamedCommand( name )
2613, m_newMargins( newMargins )
2617 m_objects.setAutoDelete(
false );
2618 m_oldMargins.setAutoDelete(
false );
2620 addObjects( objects );
2624KPrChangeMarginCommand::~KPrChangeMarginCommand()
2626 TQPtrListIterator<KPrTextObject> it( m_objects );
2627 for ( ; it.current() ; ++it )
2628 it.current()->decCmdRef();
2629 m_oldMargins.setAutoDelete(
true );
2630 m_oldMargins.clear();
2634void KPrChangeMarginCommand::addObjects(
const TQPtrList<KPrObject> &objects )
2636 TQPtrListIterator<KPrObject> it( objects );
2637 for ( ; it.current(); ++it )
2639 if ( it.current()->getType() == OT_GROUP )
2641 KPrGroupObject * obj =
dynamic_cast<KPrGroupObject*
>( it.current() );
2644 addObjects( obj->objectList() );
2649 KPrTextObject *obj =
dynamic_cast<KPrTextObject*
>( it.current() );
2652 m_objects.append( obj );
2655 m_oldMargins.append(
new MarginsStruct( obj ) );
2662void KPrChangeMarginCommand::execute()
2664 TQPtrListIterator<KPrTextObject> it( m_objects );
2665 for ( ; it.current() ; ++it )
2667 it.current()->setTextMargins( m_newMargins.leftMargin, m_newMargins.topMargin,
2668 m_newMargins.rightMargin, m_newMargins.bottomMargin);
2669 it.current()->resizeTextDocument();
2670 it.current()->layout();
2672 m_doc->repaint(
false );
2674 m_doc->updateSideBarItem( m_page );
2677void KPrChangeMarginCommand::unexecute()
2679 for (
unsigned int i = 0; i < m_objects.count(); i++ )
2681 KPrTextObject *
object = m_objects.at( i );
2682 MarginsStruct *marginsStruct = m_oldMargins.at( i );
2683 object->setTextMargins( marginsStruct->leftMargin, marginsStruct->topMargin,
2684 marginsStruct->rightMargin, marginsStruct->bottomMargin);
2685 object->resizeTextDocument();
2688 m_doc->repaint(
false );
2690 m_doc->updateSideBarItem( m_page );
2694KPrChangeVerticalAlignmentCommand::KPrChangeVerticalAlignmentCommand(
const TQString &name, KPrTextObject *_obj,
2695 VerticalAlignmentType _oldAlign,
2696 VerticalAlignmentType _newAlign,
2697 KPrDocument *_doc) :
2698 KNamedCommand(name),
2700 m_oldAlign(_oldAlign),
2701 m_newAlign(_newAlign),
2704 m_page = m_doc->findPage( _obj );
2707void KPrChangeVerticalAlignmentCommand::execute()
2709 m_obj->setVerticalAligment( m_newAlign );
2710 m_obj->kPresenterDocument()->layout(m_obj);
2711 m_obj->kPresenterDocument()->repaint(m_obj);
2713 m_doc->updateSideBarItem( m_page );
2716void KPrChangeVerticalAlignmentCommand::unexecute()
2718 m_obj->setVerticalAligment( m_oldAlign );
2719 m_obj->kPresenterDocument()->layout(m_obj);
2720 m_obj->kPresenterDocument()->repaint(m_obj);
2722 m_doc->updateSideBarItem( m_page );
2726KPrChangeTabStopValueCommand::KPrChangeTabStopValueCommand(
const TQString &name,
double _oldValue,
double _newValue,
2728 KNamedCommand(name),
2730 m_oldValue(_oldValue),
2731 m_newValue(_newValue)
2735void KPrChangeTabStopValueCommand::execute()
2737 m_doc->setTabStopValue ( m_newValue );
2740void KPrChangeTabStopValueCommand::unexecute()
2742 m_doc->setTabStopValue ( m_oldValue );
2745KPrImageEffectCmd::KPrImageEffectCmd(
const TQString &_name, TQPtrList<ImageEffectSettings> &_oldSettings,
2746 ImageEffectSettings _newSettings, TQPtrList<KPrObject> &_objects,
2748 :KNamedCommand( _name ), oldSettings( _oldSettings ), objects( _objects )
2750 objects.setAutoDelete(
false );
2751 oldSettings.setAutoDelete(
false );
2753 newSettings = _newSettings;
2755 m_page = doc->findPage( objects );
2757 TQPtrListIterator<KPrObject> it( objects );
2758 for ( ; it.current() ; ++it )
2759 it.current()->incCmdRef();
2762KPrImageEffectCmd::~KPrImageEffectCmd()
2764 TQPtrListIterator<KPrObject> it( objects );
2765 for ( ; it.current() ; ++it )
2766 it.current()->decCmdRef();
2767 oldSettings.setAutoDelete(
true );
2768 oldSettings.clear();
2771void KPrImageEffectCmd::execute()
2773 TQPtrListIterator<KPrObject> it( objects );
2774 for ( ; it.current() ; ++it ) {
2775 KPrPixmapObject * obj =
dynamic_cast<KPrPixmapObject*
>( it.current() );
2777 obj->setImageEffect(newSettings.effect);
2778 obj->setIEParams(newSettings.param1, newSettings.param2, newSettings.param3);
2781 doc->repaint(
false );
2783 doc->updateSideBarItem( m_page );
2786void KPrImageEffectCmd::unexecute()
2788 for (
unsigned int i = 0; i < objects.count(); ++i ) {
2789 KPrPixmapObject * obj =
dynamic_cast<KPrPixmapObject*
>( objects.at(i) );
2791 obj->setImageEffect(oldSettings.at( i )->effect);
2792 obj->setIEParams(oldSettings.at( i )->param1, oldSettings.at( i )->param2,
2793 oldSettings.at( i )->param3);
2796 doc->repaint(
false );
2798 doc->updateSideBarItem( m_page );
2801KPrChangeVariableNoteText::KPrChangeVariableNoteText(
const TQString &name, KPrDocument *_doc,
2802 const TQString &_oldValue,
const TQString &_newValue,
2803 KoNoteVariable *var):
2804 KNamedCommand(name),
2806 newValue(_newValue),
2807 oldValue(_oldValue),
2812KPrChangeVariableNoteText::~KPrChangeVariableNoteText()
2816void KPrChangeVariableNoteText::execute()
2819 m_var->setNote(newValue);
2822void KPrChangeVariableNoteText::unexecute()
2825 m_var->setNote(oldValue);
KPrTextObject * textObject() const
Return the text object in which this document is.