kpresenter

KPrCommand.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001 Laurent Montel <lmontel@mandrakesoft.com>
3 Copyright (C) 2005-2006 Thorsten Zachmann <zachmann@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include "KPrDocument.h"
22#include "KPrPage.h"
23#include "KPrCommand.h"
24#include "KPrBackground.h"
25#include "KPrGroupObject.h"
26
27
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"
36
37#include "KPrTextObject.h"
38#include "KPrPixmapObject.h"
39
40#include "KPrPartObject.h"
41#include <KoRuler.h>
42#include "KPrPieObject.h"
43#include "KPrRectObject.h"
44#include "KPrView.h"
45#include "KoTextObject.h"
46#include "KPrTextDocument.h"
47#include <kdebug.h>
48#include "KPrVariableCollection.h"
49#include <KoRect.h>
50#include <KoSize.h>
51#include <KoPoint.h>
52#include <KoDom.h>
53#include <KoTextParag.h>
54#include <KoXmlNS.h>
55#include <KoStore.h>
56#include <KoOasisContext.h>
57#include <KoOasisStyles.h>
58#include <KoOasisStore.h>
59
60#include <tqxml.h>
61#include <tqbuffer.h>
62
63
64KPrShadowCmd::KPrShadowCmd( const TQString &_name, TQPtrList<ShadowValues> &_oldShadow, ShadowValues _newShadow,
65 TQPtrList<KPrObject> &_objects, KPrDocument *_doc )
66 : KNamedCommand( _name ), oldShadow( _oldShadow ), objects( _objects )
67{
68 objects.setAutoDelete( false );
69 oldShadow.setAutoDelete( false );
70 doc = _doc;
71 newShadow = _newShadow;
72
73 m_page = doc->findPage( objects );
74
75 TQPtrListIterator<KPrObject> it( objects );
76 for ( ; it.current() ; ++it )
77 it.current()->incCmdRef();
78}
79
80KPrShadowCmd::~KPrShadowCmd()
81{
82 TQPtrListIterator<KPrObject> it( objects );
83 for ( ; it.current() ; ++it )
84 it.current()->decCmdRef();
85 oldShadow.setAutoDelete( true );
86 oldShadow.clear();
87}
88
89void KPrShadowCmd::execute()
90{
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 );
97
98 doc->updateSideBarItem( m_page );
99}
100
101void KPrShadowCmd::unexecute()
102{
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 );
108
109 doc->updateSideBarItem( m_page );
110}
111
112
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 ),
117 diffs( _diffs ),
118 objects( _objects ),
119 txtBackCol( _txtBackCol ),
120 otxtBackCol( _otxtBackCol )
121{
122 gridX = _gridX;
123 gridY = _gridY;
124 oldGridX = _oldGridX;
125 oldGridY = _oldGridY;
126 doc = _doc;
127 TQPtrListIterator<KPrObject> it( objects );
128 for ( ; it.current() ; ++it )
129 it.current()->incCmdRef();
130}
131
132KPrSetOptionsCmd::~KPrSetOptionsCmd()
133{
134 TQPtrListIterator<KPrObject> it( objects );
135 for ( ; it.current() ; ++it )
136 it.current()->decCmdRef();
137}
138
139void KPrSetOptionsCmd::execute()
140{
141 // ## use iterator
142 for ( unsigned int i = 0; i < objects.count(); i++ )
143 objects.at( i )->moveBy( *diffs.at( i ) );
144 doc->setGridValue( gridX, gridY, false );
145 doc->updateRuler();
146 doc->setTxtBackCol( txtBackCol );
147 doc->repaint( false );
148}
149
150void KPrSetOptionsCmd::unexecute()
151{
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 );
155 doc->updateRuler();
156 doc->setTxtBackCol( otxtBackCol );
157 doc->repaint( false );
158}
159
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 )
170, m_doc( doc )
171, m_page( page )
172{
173}
174
175void KPrSetBackCmd::execute()
176{
177 if ( !m_takeGlobal ) {
178 m_page->background()->setBackGround( m_settings );
179 m_page->setUseMasterBackground( m_useMasterBackground );
180 m_doc->restoreBackground( m_page );
181 } else {
182 TQPtrListIterator<KPrPage> it( m_doc->getPageList() );
183 for ( ; it.current() ; ++it )
184 {
185 it.current()->background()->setBackGround( m_settings );
186 it.current()->setUseMasterBackground( m_useMasterBackground );
187 m_doc->restoreBackground(it.current());
188 }
189
190 }
191 m_doc->repaint( false );
192
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() );
197 }
198 }
199 else {
200 m_doc->updateSideBarItem( m_page );
201 }
202}
203
204void KPrSetBackCmd::unexecute()
205{
206 if ( !m_takeGlobal ) {
207 m_page->background()->setBackGround( m_oldSettings );
208 m_page->setUseMasterBackground( m_oldUseMasterBackground );
209 m_doc->restoreBackground( m_page );
210 } else {
211 TQPtrListIterator<KPrPage> it( m_doc->getPageList() );
212 for ( ; it.current() ; ++it )
213 {
214 it.current()->background()->setBackGround( m_oldSettings );
215 it.current()->setUseMasterBackground( m_oldUseMasterBackground );
216 m_doc->restoreBackground(it.current());
217 }
218 }
219 m_doc->repaint( false );
220
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() );
225 }
226 }
227 else {
228 m_doc->updateSideBarItem( m_page );
229 }
230}
231
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 )
235{
236 m_objects.setAutoDelete( false );
237 m_oldAngles.setAutoDelete( false );
238
239 TQPtrListIterator<KPrObject> it( objects );
240 for ( ; it.current() ; ++it )
241 {
242 m_objects.append( it.current() );
243
244 RotateValues *old = new RotateValues;
245 old->angle = it.current()->getAngle();
246 m_oldAngles.append( old );
247
248 it.current()->incCmdRef();
249 }
250
251 m_page = m_doc->findPage( m_objects );
252}
253
254KPrRotateCmd::~KPrRotateCmd()
255{
256 TQPtrListIterator<KPrObject> it( m_objects );
257 for ( ; it.current() ; ++it )
258 it.current()->decCmdRef();
259 m_oldAngles.setAutoDelete( true );
260 m_oldAngles.clear();
261}
262
263void KPrRotateCmd::execute()
264{
265 TQPtrListIterator<KPrObject> it( m_objects );
266 for ( ; it.current() ; ++it )
267 {
268 if ( m_addAngle )
269 it.current()->rotate( it.current()->getAngle() + m_newAngle );
270 else
271 it.current()->rotate( m_newAngle );
272 }
273 m_doc->updateRuler();
274 m_doc->repaint( false );
275
276 m_doc->updateSideBarItem( m_page );
277}
278
279void KPrRotateCmd::unexecute()
280{
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 );
285
286 m_doc->updateSideBarItem( m_page );
287}
288
289
290KPrChgPixCmd::KPrChgPixCmd( const TQString &_name, KPrPixmapObject *_oldObject, KPrPixmapObject *_newObject,
291 KPrDocument *_doc, KPrPage *_page)
292 : KNamedCommand( _name )
293{
294 oldObject = _oldObject;
295 newObject = _newObject;
296 m_page=_page;
297 doc = _doc;
298 oldObject->incCmdRef();
299 newObject->incCmdRef();
300 newObject->setSize( oldObject->getSize() );
301 newObject->setOrig( oldObject->getOrig() );
302}
303
304KPrChgPixCmd::~KPrChgPixCmd()
305{
306 oldObject->decCmdRef();
307 newObject->decCmdRef();
308}
309
310void KPrChgPixCmd::execute()
311{
312 m_page->replaceObject( oldObject, newObject );
313 doc->repaint( newObject );
314
315 doc->updateSideBarItem( m_page );
316}
317
318void KPrChgPixCmd::unexecute()
319{
320 m_page->replaceObject( newObject, oldObject );
321 doc->repaint( oldObject );
322
323 doc->updateSideBarItem( m_page );
324}
325
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 )
331, m_doc( _doc )
332, m_page( _page )
333{
334 TQPtrListIterator<KPrObject> it( m_oldObjectList );
335 for ( ; it.current() ; ++it )
336 it.current()->incCmdRef();
337}
338
339KPrDeleteCmd::~KPrDeleteCmd()
340{
341 TQPtrListIterator<KPrObject> it( m_oldObjectList );
342 for ( ; it.current() ; ++it )
343 it.current()->decCmdRef();
344}
345
346void KPrDeleteCmd::execute()
347{
348 bool textObj=false;
349
350 TQPtrListIterator<KPrObject> it( m_oldObjectList );
351 TQPtrListIterator<KPrObject> itDelete( m_objectsToDelete );
352 TQPtrList<KPrObject> newObjectList;
353 for ( ; it.current(); ++it )
354 {
355 if ( it.current() == itDelete.current() )
356 {
357 it.current()->setSelected( false );
358 it.current()->removeFromObjList();
359
360 if ( !textObj && it.current()->getType() == OT_TEXT )
361 {
362 KPrTextObject * tmp = dynamic_cast<KPrTextObject *>( it.current() );
363 if ( tmp )
364 tmp->setEditingTextObj( false );
365 textObj=true;
366 }
367 ++itDelete;
368 }
369 else
370 {
371 newObjectList.append( it.current() );
372 }
373 }
374
375 m_page->setObjectList( newObjectList );
376
377 for ( itDelete.toFirst(); itDelete.current(); ++itDelete )
378 {
379 TQRect oldRect = m_doc->zoomHandler()->zoomRect( itDelete.current()->getRepaintRect() );
380 m_doc->repaint( oldRect );
381 }
382 if(textObj)
383 m_doc->updateRuler();
384
385 m_doc->updateSideBarItem( m_page );
386}
387
388void KPrDeleteCmd::unexecute()
389{
390 m_page->setObjectList( m_oldObjectList );
391 TQPtrListIterator<KPrObject> it( m_objectsToDelete );
392 for ( ; it.current(); ++it )
393 {
394 it.current()->addToObjList();
395 m_doc->repaint( it.current() );
396 }
397
398 m_doc->updateSideBarItem( m_page );
399}
400
401
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 )
406{
407 TQPtrListIterator<KPrObject> it( objs );
408 for ( ; it.current() ; ++it )
409 it.current()->incCmdRef();
410}
411
412KPrEffectCmd::~KPrEffectCmd()
413{
414 TQPtrListIterator<KPrObject> it( objs );
415 for ( ; it.current() ; ++it )
416 it.current()->decCmdRef();
417}
418
419void KPrEffectCmd::execute()
420{
421 TQPtrListIterator<KPrObject> it( objs );
422 for ( ; it.current() ; ++it )
423 {
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 );
438 }
439}
440
441void KPrEffectCmd::unexecute()
442{
443 KPrObject *object = 0;
444 for ( unsigned int i = 0; i < objs.count(); ++i ) {
445 object = objs.at( i );
446
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 );
461 }
462}
463
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() )
470, m_doc( _doc )
471, m_page( _page )
472{
473 m_groupObject = new KPrGroupObject( m_objectsToGroup );
474 m_groupObject->incCmdRef();
475}
476
477KPrGroupObjCmd::~KPrGroupObjCmd()
478{
479 m_groupObject->decCmdRef();
480}
481
482void KPrGroupObjCmd::execute()
483{
484 KoRect r;
485 int position = 0;
486 TQPtrListIterator<KPrObject> it( m_objectsToGroup );
487 for ( ; it.current() ; ++it )
488 {
489 it.current()->setSelected( false );
490 position = m_page->takeObject(it.current() );
491 r |= it.current()->getRealRect();
492 }
493
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();
502
503 m_doc->repaint( false );
504
505 m_doc->updateSideBarItem( m_page );
506}
507
508void KPrGroupObjCmd::unexecute()
509{
510 m_groupObject->setUpdateObjects( false );
511
512 m_page->setObjectList( m_oldObjectList );
513 m_groupObject->removeFromObjList();
514
515 TQPtrListIterator<KPrObject> it( m_objectsToGroup );
516 for ( ; it.current() ; ++it )
517 {
518 it.current()->addToObjList();
519 it.current()->setSelected( true );
520 }
521
522 m_doc->refreshGroupButton();
523
524 m_doc->repaint( false );
525
526 m_doc->updateSideBarItem( m_page );
527}
528
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_ )
535, m_doc( _doc )
536, m_page( _page )
537{
538 m_groupObject->incCmdRef();
539}
540
541UnGroupObjCmd::~UnGroupObjCmd()
542{
543 m_groupObject->decCmdRef();
544}
545
546void UnGroupObjCmd::execute()
547{
548 m_groupObject->setUpdateObjects( false );
549
550 int position = m_page->takeObject( m_groupObject );
551 m_groupObject->removeFromObjList();
552
553 TQPtrListIterator<KPrObject> it( m_groupedObjects );
554 for ( it.toLast(); it.current() ; --it )
555 {
556 m_page->insertObject( it.current(), position );
557 it.current()->addToObjList();
558 it.current()->setSelected( true );
559 }
560
561 m_doc->refreshGroupButton();
562
563 m_doc->repaint( false );
564
565 m_doc->updateSideBarItem( m_page );
566}
567
568void UnGroupObjCmd::unexecute()
569{
570 KoRect r=KoRect();
571 int position = 0;
572 TQPtrListIterator<KPrObject> it( m_groupedObjects );
573 for ( ; it.current() ; ++it )
574 {
575 it.current()->setSelected( false );
576 position = m_page->takeObject( it.current() );
577 r |= it.current()->getRealRect();
578 }
579
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();
588
589 m_doc->repaint( false );
590
591 m_doc->updateSideBarItem( m_page );
592}
593
594KPrInsertCmd::KPrInsertCmd( const TQString &name, const TQValueList<KPrObject *> objects,
595 KPrDocument *doc, KPrPage *page )
596: KNamedCommand( name )
597, m_objects( objects )
598, m_object( 0 )
599, m_doc( doc )
600, m_page( page )
601{
602 TQValueListConstIterator<KPrObject *> it( m_objects.begin() );
603 for ( ; it != m_objects.end(); ++it )
604 {
605 ( *it )->incCmdRef();
606 }
607}
608
609KPrInsertCmd::KPrInsertCmd( const TQString &name, KPrObject *object,
610 KPrDocument *doc, KPrPage *page )
611: KNamedCommand( name )
612, m_object( object )
613, m_doc( doc )
614, m_page( page )
615{
616 m_object->incCmdRef();
617}
618
619KPrInsertCmd::~KPrInsertCmd()
620{
621 if ( m_object )
622 {
623 m_object->decCmdRef();
624 }
625 else
626 {
627 TQValueListConstIterator<KPrObject *> it( m_objects.begin() );
628 for ( ; it != m_objects.end(); ++it )
629 {
630 ( *it )->decCmdRef();
631 }
632 }
633}
634
635void KPrInsertCmd::execute()
636{
637 if ( m_object )
638 {
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 );
644 }
645 else
646 {
647 m_page->appendObjects( m_objects );
648 TQValueListConstIterator<KPrObject *> it( m_objects.begin() );
649 bool updateRuler = false;
650 for ( ; it != m_objects.end(); ++it )
651 {
652 ( *it )->addToObjList();
653 if ( ( *it )->getType() == OT_TEXT )
654 updateRuler = true;
655 m_doc->repaint( *it );
656 }
657 if ( updateRuler )
658 m_doc->updateRuler();
659 }
660
661 m_doc->updateSideBarItem( m_page );
662}
663
664void KPrInsertCmd::unexecute()
665{
666 if ( m_object )
667 {
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 )
674 {
675 m_doc->terminateEditing( (KPrTextObject*)m_object );
676 ((KPrTextObject*)m_object)->setEditingTextObj( false );
677 m_doc->updateRuler();
678 }
679 }
680 m_doc->repaint( oldRect );
681 }
682 else
683 {
684 TQPtrList<KPrObject> list(m_page->objectList());
685 bool updateRuler = false;
686
687 TQValueListConstIterator<KPrObject *> it( m_objects.begin() );
688 for ( ; it != m_objects.end(); ++it )
689 {
690 if ( list.findRef( *it ) != -1 )
691 {
692 m_page->takeObject( *it );
693 ( *it )->removeFromObjList();
694 if ( ( *it )->getType() == OT_TEXT )
695 {
696 m_doc->terminateEditing( (KPrTextObject*)( *it ) );
697 ( (KPrTextObject*) *it )->setEditingTextObj( false );
698 updateRuler = true;
699 }
700 }
701 }
702 if ( updateRuler )
703 m_doc->updateRuler();
704
705 m_doc->repaint( false );
706 }
707
708 m_doc->updateSideBarItem( m_page );
709}
710
711KPrLowerRaiseCmd::KPrLowerRaiseCmd( const TQString &_name, const TQPtrList<KPrObject>& _oldList,
712 const TQPtrList<KPrObject>& _newList, KPrDocument *_doc,
713 KPrPage *_page )
714 : KNamedCommand( _name )
715{
716 oldList = _oldList;
717 newList = _newList;
718 m_page=_page;
719 oldList.setAutoDelete( false );
720 newList.setAutoDelete( false );
721 doc = _doc;
722
723 TQPtrListIterator<KPrObject> it( oldList );
724 for ( ; it.current() ; ++it )
725 it.current()->incCmdRef();
726}
727
728KPrLowerRaiseCmd::~KPrLowerRaiseCmd()
729{
730 TQPtrListIterator<KPrObject> it( oldList );
731 for ( ; it.current() ; ++it )
732 it.current()->decCmdRef();
733}
734
735void KPrLowerRaiseCmd::execute()
736{
737 m_page->setObjectList( newList );
738 doc->repaint( false );
739
740 doc->updateSideBarItem( m_page );
741}
742
743void KPrLowerRaiseCmd::unexecute()
744{
745 m_page->setObjectList( oldList );
746 doc->repaint( false );
747
748 doc->updateSideBarItem( m_page );
749}
750
751
752KPrMoveByCmd::KPrMoveByCmd( const TQString &_name, const KoPoint &_diff, TQPtrList<KPrObject> &_objects,
753 KPrDocument *_doc,KPrPage *_page )
754 : KNamedCommand( _name ), diff( _diff ), objects( _objects )
755{
756 objects.setAutoDelete( false );
757 doc = _doc;
758 m_page=_page;
759 TQPtrListIterator<KPrObject> it( objects );
760 for ( ; it.current() ; ++it )
761 {
762 it.current()->incCmdRef();
763 }
764}
765
766KPrMoveByCmd::~KPrMoveByCmd()
767{
768 TQPtrListIterator<KPrObject> it( objects );
769 for ( ; it.current() ; ++it )
770 it.current()->decCmdRef();
771}
772
773void KPrMoveByCmd::execute()
774{
775 TQRect oldRect;
776
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 )
781 {
782 if(objects.at(i)->isSelected())
783 doc->updateRuler();
784 }
785 doc->repaint( oldRect );
786 doc->repaint( objects.at( i ) );
787 }
788
789 doc->updateSideBarItem( m_page );
790 doc->updateObjectStatusBarItem();
791}
792
793void KPrMoveByCmd::unexecute()
794{
795 TQRect oldRect;
796
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 )
801 {
802 if(objects.at(i)->isSelected())
803 doc->updateRuler();
804 }
805 doc->repaint( oldRect );
806 doc->repaint( objects.at( i ) );
807 }
808
809 doc->updateSideBarItem( m_page );
810 doc->updateObjectStatusBarItem();
811}
812
813KPrAlignCmd::KPrAlignCmd( const TQString &_name, TQPtrList<KPrObject> &_objects, AlignType _at, KPrDocument *_doc )
814 : KNamedCommand( _name ), doc(_doc)
815{
816 objects.setAutoDelete( false );
817 diffs.setAutoDelete( true );
818 m_page = doc->findPage( _objects );
819
820 TQPtrListIterator<KPrObject> it( _objects );
821 KoRect boundingRect;
822 for ( ; it.current() ; ++it )
823 {
824 boundingRect |= it.current()->getRealRect();
825 }
826
827 if ( _objects.count() == 1 )
828 boundingRect = m_page->getPageRect();
829
830 it.toFirst();
831 for ( ; it.current() ; ++it )
832 {
833 KoPoint * diff = NULL;
834 switch ( _at )
835 {
836 case AT_LEFT:
837 diff = new KoPoint( boundingRect.x() - it.current()->getRealOrig().x(), 0 );
838 break;
839 case AT_TOP:
840 diff = new KoPoint( 0, boundingRect.y() - it.current()->getRealOrig().y() );
841 break;
842 case AT_RIGHT:
843 diff = new KoPoint( boundingRect.x() + boundingRect.width() -
844 it.current()->getRealOrig().x() - it.current()->getRealSize().width(), 0 );
845 break;
846 case AT_BOTTOM:
847 diff = new KoPoint( 0, boundingRect.y() + boundingRect.height() -
848 it.current()->getRealOrig().y() - it.current()->getRealSize().height() );
849 break;
850 case AT_HCENTER:
851 diff = new KoPoint( ( boundingRect.width() - it.current()->getRealSize().width() ) / 2 -
852 it.current()->getRealOrig().x() + boundingRect.x(), 0 );
853 break;
854 case AT_VCENTER:
855 diff = new KoPoint( 0, ( boundingRect.height() - it.current()->getRealSize().height() ) / 2 -
856 it.current()->getRealOrig().y() + boundingRect.y() );
857 break;
858 }
859 if ( diff )
860 {
861 objects.append( it.current() );
862 diffs.append( diff );
863 it.current()->incCmdRef();
864 }
865 }
866}
867
868KPrAlignCmd::~KPrAlignCmd()
869{
870 TQPtrListIterator<KPrObject> it( objects );
871 for ( ; it.current() ; ++it )
872 it.current()->decCmdRef();
873
874 diffs.clear();
875}
876
877void KPrAlignCmd::execute()
878{
879 TQRect oldRect;
880
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 )
885 {
886 if(objects.at(i)->isSelected())
887 doc->updateRuler();
888 }
889
890 doc->repaint( oldRect );
891 doc->repaint( objects.at( i ) );
892 }
893
894 doc->updateSideBarItem( m_page );
895}
896
897void KPrAlignCmd::unexecute()
898{
899 TQRect oldRect;
900
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 )
905 {
906 if(objects.at(i)->isSelected())
907 doc->updateRuler();
908 }
909 doc->repaint( oldRect );
910 doc->repaint( objects.at( i ) );
911 doc->updateRuler();
912 }
913
914 doc->updateSideBarItem( m_page );
915}
916
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)
920{
921 objects.setAutoDelete( false );
922 oldPen.setAutoDelete( false );
923
924 addObjects( _objects );
925}
926
927KoPenCmd::~KoPenCmd()
928{
929 TQPtrListIterator<KPrObject> it( objects );
930 for ( ; it.current() ; ++it )
931 it.current()->decCmdRef();
932
933 oldPen.setAutoDelete( true );
934 oldPen.clear();
935}
936
937void KoPenCmd::execute()
938{
939 for ( int i = 0; i < static_cast<int>( objects.count() ); i++ )
940 {
941 Pen tmpPen = *oldPen.at( i );
942
943 if ( flags & BeginLine )
944 tmpPen.lineBegin = newPen.lineBegin;
945
946 if ( flags & EndLine )
947 tmpPen.lineEnd = newPen.lineEnd;
948
949 if ( flags & Color )
950 tmpPen.pen.setColor( newPen.pen.color() );
951
952 if ( flags & Width )
953 tmpPen.pen.setPointWidth( newPen.pen.pointWidth() );
954
955 if ( flags & Style )
956 tmpPen.pen.setStyle( newPen.pen.style() );
957
958 applyPen( objects.at( i ), &tmpPen );
959 }
960
961 // this has to be called as the outline could have been changed so
962 // that the toolbar is updated correctly
963 doc->updateObjectSelected();
964 doc->updateSideBarItem( m_page );
965}
966
967void KoPenCmd::applyPen( KPrObject *object, Pen *tmpPen )
968{
969 switch (object->getType()) {
970 case OT_LINE:
971 {
972 KPrLineObject* obj=dynamic_cast<KPrLineObject*>( object );
973 if( obj )
974 {
975 //obj->setPen( tmpPen->pen );
976 obj->setLineBegin( tmpPen->lineBegin );
977 obj->setLineEnd( tmpPen->lineEnd );
978 //doc->repaint( obj );
979 }
980 } break;
981 case OT_FREEHAND:
982 case OT_POLYLINE:
983 case OT_QUADRICBEZIERCURVE:
984 case OT_CUBICBEZIERCURVE:
985 {
986 KPrPointObject *obj = dynamic_cast<KPrPointObject*>( object );
987 if ( obj )
988 {
989 //obj->setPen( tmpPen->pen );
990 obj->setLineBegin( tmpPen->lineBegin );
991 obj->setLineEnd( tmpPen->lineEnd );
992 //doc->repaint( obj );
993 }
994 } break;
995 case OT_PIE:
996 {
997 KPrPieObject *obj = dynamic_cast<KPrPieObject*>( object );
998 if ( obj )
999 {
1000 obj->setLineBegin( tmpPen->lineBegin );
1001 obj->setLineEnd( tmpPen->lineEnd );
1002 }
1003 } break;
1004 case OT_AUTOFORM:
1005 {
1006 KPrAutoformObject *obj = dynamic_cast<KPrAutoformObject*>( object );
1007 if ( obj )
1008 {
1009 obj->setLineBegin( tmpPen->lineBegin );
1010 obj->setLineEnd( tmpPen->lineEnd );
1011 }
1012 } break;
1013 default:
1014 break;
1015 }
1016
1017 KPrShadowObject *obj = dynamic_cast<KPrShadowObject*>( object );
1018 if ( obj )
1019 {
1020 obj->setPen( tmpPen->pen );
1021 doc->repaint( obj );
1022 }
1023}
1024
1025void KoPenCmd::unexecute()
1026{
1027 for ( unsigned int i = 0; i < objects.count(); ++i ) {
1028 if( oldPen.count() > i )
1029 applyPen( objects.at( i ), oldPen.at( i ) );
1030 }
1031
1032 // this has to be called as the outline could have been changed so
1033 // that the toolbar is updated correctly
1034 doc->updateObjectSelected();
1035 doc->updateSideBarItem( m_page );
1036}
1037
1038void KoPenCmd::addObjects( const TQPtrList<KPrObject> &_objects )
1039{
1040 TQPtrListIterator<KPrObject> it( _objects );
1041 for ( ; it.current(); ++it )
1042 {
1043 KPrObject * object( it.current() );
1044 if ( object->getType() == OT_GROUP )
1045 {
1046 KPrGroupObject * obj=dynamic_cast<KPrGroupObject*>( object );
1047 if ( obj )
1048 {
1049 addObjects( obj->objectList() );
1050 }
1051 }
1052 else
1053 {
1054 // tz TODO fix name
1055 ::LineEnd lineBegin = L_NORMAL;
1056 ::LineEnd lineEnd = L_NORMAL;
1057 switch ( it.current()->getType() ) {
1058 case OT_LINE:
1059 {
1060 KPrLineObject *obj=dynamic_cast<KPrLineObject*>( object );
1061 if ( obj )
1062 {
1063 lineBegin = obj->getLineBegin();
1064 lineEnd = obj->getLineEnd();
1065 }
1066 } break;
1067 case OT_FREEHAND:
1068 case OT_POLYLINE:
1069 case OT_QUADRICBEZIERCURVE:
1070 case OT_CUBICBEZIERCURVE:
1071 {
1072 KPrPointObject *obj = dynamic_cast<KPrPointObject*>( object );
1073 if ( obj )
1074 {
1075 lineBegin = obj->getLineBegin();
1076 lineEnd = obj->getLineEnd();
1077 }
1078 } break;
1079 case OT_PIE:
1080 {
1081 KPrPieObject *obj = dynamic_cast<KPrPieObject*>( object );
1082 if ( obj )
1083 {
1084 lineBegin = obj->getLineBegin();
1085 lineEnd = obj->getLineEnd();
1086 }
1087 } break;
1088 case OT_AUTOFORM:
1089 {
1090 KPrAutoformObject *obj = dynamic_cast<KPrAutoformObject*>( object );
1091 if ( obj )
1092 {
1093 lineBegin = obj->getLineBegin();
1094 lineEnd = obj->getLineEnd();
1095 }
1096 } break;
1097 default:
1098 break;
1099 }
1100
1101 KPrShadowObject *obj = dynamic_cast<KPrShadowObject*>( object );
1102 if ( obj )
1103 {
1104 objects.append( obj );
1105 obj->incCmdRef();
1106
1107 Pen * pen = new KoPenCmd::Pen( obj->getPen(), lineBegin, lineEnd );
1108
1109 oldPen.append( pen );
1110 }
1111 }
1112 }
1113}
1114
1115
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)
1119{
1120 objects.setAutoDelete( false );
1121 oldBrush.setAutoDelete( false );
1122
1123 addObjects( _objects );
1124}
1125
1126void KPrBrushCmd::addObjects( const TQPtrList<KPrObject> &_objects )
1127{
1128 TQPtrListIterator<KPrObject> it( _objects );
1129 for ( ; it.current(); ++it )
1130 {
1131 if ( it.current()->getType() == OT_GROUP )
1132 {
1133 KPrGroupObject * obj=dynamic_cast<KPrGroupObject*>( it.current() );
1134 if ( obj )
1135 {
1136 addObjects( obj->objectList() );
1137 }
1138 }
1139 else
1140 {
1141 KPr2DObject * obj = dynamic_cast<KPr2DObject *>( it.current() );
1142 if( obj )
1143 {
1144 objects.append( obj );
1145 obj->incCmdRef();
1146
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();
1156
1157 oldBrush.append( brush );
1158 }
1159 }
1160 }
1161}
1162
1163KPrBrushCmd::~KPrBrushCmd()
1164{
1165 TQPtrListIterator<KPr2DObject> it( objects );
1166 for ( ; it.current() ; ++it )
1167 it.current()->decCmdRef();
1168
1169 oldBrush.setAutoDelete( true );
1170 oldBrush.clear();
1171}
1172
1173void KPrBrushCmd::execute()
1174{
1175 for ( int i = 0; i < static_cast<int>( objects.count() ); i++ )
1176 {
1177 Brush tmpBrush = *oldBrush.at( i );
1178
1179 if ( flags & BrushColor )
1180 tmpBrush.brush.setColor( newBrush.brush.color() );
1181
1182 if ( flags & BrushStyle )
1183 tmpBrush.brush.setStyle( newBrush.brush.style() );
1184
1185 if ( flags & BrushGradientSelect )
1186 tmpBrush.fillType = newBrush.fillType;
1187
1188 if ( flags & GradientColor1 )
1189 tmpBrush.gColor1 = newBrush.gColor1;
1190
1191 if ( flags & GradientColor2 )
1192 tmpBrush.gColor2 = newBrush.gColor2;
1193
1194 if ( flags & GradientType )
1195 tmpBrush.gType = newBrush.gType;
1196
1197 if ( flags & GradientBalanced )
1198 tmpBrush.unbalanced = newBrush.unbalanced;
1199
1200 if ( flags & GradientXFactor )
1201 tmpBrush.xfactor = newBrush.xfactor;
1202
1203 if ( flags & GradientYFactor )
1204 tmpBrush.yfactor = newBrush.yfactor;
1205
1206 applyBrush( objects.at( i ), &tmpBrush );
1207 }
1208
1209 doc->updateSideBarItem( m_page );
1210}
1211
1212void KPrBrushCmd::applyBrush( KPr2DObject *object, Brush *tmpBrush )
1213{
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 );
1223}
1224
1225void KPrBrushCmd::unexecute()
1226{
1227 for ( unsigned int i = 0; i < objects.count(); i++ ) {
1228 applyBrush( objects.at( i ), oldBrush.at( i ) );
1229 }
1230
1231 doc->updateSideBarItem( m_page );
1232}
1233
1234
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,
1241 KPrDocument *_doc )
1242 : KNamedCommand( _name )
1243{
1244 manualSwitch = _manualSwitch;
1245 infiniteLoop = _infiniteLoop;
1246 showEndOfPresentationSlide = _showEndOfPresentationSlide;
1247 showPresentationDuration = _showPresentationDuration;
1248 pen = _pen;
1249 selectedSlides = _selectedSlides;
1250 oldManualSwitch = _oldManualSwitch;
1251 oldInfiniteLoop = _oldInfiniteLoop;
1252 oldShowEndOfPresentationSlide = _oldShowEndOfPresentationSlide;
1253 oldShowPresentationDuration = _oldShowPresentationDuration;
1254 oldPen = _oldPen;
1255 oldSelectedSlides = _oldSelectedSlides;
1256 oldPresentationName = _oldPresentationName;
1257 presentationName = _presentationName;
1258 doc = _doc;
1259}
1260
1261void KPrPgConfCmd::execute()
1262{
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 ] );
1274}
1275
1276void KPrPgConfCmd::unexecute()
1277{
1278 doc->setManualSwitch( oldManualSwitch );
1279 doc->setInfiniteLoop( oldInfiniteLoop );
1280 doc->setShowEndOfPresentationSlide( oldShowEndOfPresentationSlide );
1281 doc->setPresentationDuration( oldShowPresentationDuration );
1282 doc->setPresPen( oldPen );
1283 doc->setPresentationName( oldPresentationName );
1284
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 ] );
1290}
1291
1292
1293KPrTransEffectCmd::KPrTransEffectCmd( TQValueVector<PageEffectSettings> oldSettings,
1294 PageEffectSettings newSettings,
1295 KPrPage* page, KPrDocument* doc )
1296{
1297 m_newSettings = newSettings;
1298 m_oldSettings = oldSettings;
1299 Q_ASSERT( !m_oldSettings.isEmpty() );
1300 m_page = page;
1301 m_doc = doc;
1302}
1303
1304void KPrTransEffectCmd::PageEffectSettings::applyTo( KPrPage *page )
1305{
1306 page->setPageEffect( pageEffect );
1307 page->setPageEffectSpeed( effectSpeed );
1308 page->setPageSoundEffect( soundEffect );
1309 page->setPageSoundFileName( soundFileName );
1310 // TODO page->setAutoAdvance( autoAdvance );
1311 page->setPageTimer( slideTime );
1312}
1313
1314void KPrTransEffectCmd::execute()
1315{
1316 if ( m_page )
1317 m_newSettings.applyTo( m_page );
1318 else
1319 for( TQPtrListIterator<KPrPage> it( m_doc->getPageList() ); *it; ++it )
1320 m_newSettings.applyTo( it.current() );
1321}
1322
1323void KPrTransEffectCmd::unexecute()
1324{
1325 if ( m_page )
1326 m_oldSettings[0].applyTo( m_page );
1327 else {
1328 int i = 0;
1329 for( TQPtrListIterator<KPrPage> it( m_doc->getPageList() ); *it; ++it, ++i )
1330 m_oldSettings[i].applyTo( it.current() );
1331 }
1332}
1333
1334TQString KPrTransEffectCmd::name() const
1335{
1336 if ( m_page )
1337 return i18n( "Modify Slide Transition" );
1338 else
1339 return i18n( "Modify Slide Transition For All Pages" );
1340}
1341
1342KPrPgLayoutCmd::KPrPgLayoutCmd( const TQString &_name, KoPageLayout _layout, KoPageLayout _oldLayout,
1343 KoUnit::Unit _oldUnit, KoUnit::Unit _unit,KPrDocument *_doc )
1344 : KNamedCommand( _name )
1345{
1346 m_doc=_doc;
1347 layout = _layout;
1348 oldLayout = _oldLayout;
1349 oldUnit = _oldUnit;
1350 unit = _unit;
1351}
1352
1353void KPrPgLayoutCmd::execute()
1354{
1355 m_doc->setUnit( unit );
1356 m_doc->setPageLayout( layout );
1357 m_doc->updateHeaderFooterPosition();
1358 m_doc->updateRuler();
1359 m_doc->updateRulerPageLayout();
1360}
1361
1362void KPrPgLayoutCmd::unexecute()
1363{
1364 m_doc->setUnit( oldUnit );
1365 m_doc->setPageLayout( oldLayout );
1366 m_doc->updateHeaderFooterPosition();
1367 m_doc->updateRuler();
1368 m_doc->updateRulerPageLayout();
1369}
1370
1371
1372KPrPieValueCmd::KPrPieValueCmd( const TQString &name, PieValues newValues,
1373 TQPtrList<KPrObject> &objects, KPrDocument *doc,
1374 KPrPage *page, int flags )
1375: KNamedCommand( name )
1376, m_doc( doc )
1377, m_page( page )
1378, m_newValues( newValues )
1379, m_flags( flags )
1380{
1381 m_objects.setAutoDelete( false );
1382 m_oldValues.setAutoDelete( false );
1383
1384 addObjects( objects );
1385}
1386
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)
1390{
1391 m_objects.setAutoDelete( false );
1392 m_oldValues.setAutoDelete( false );
1393 m_doc = _doc;
1394 m_page = _page;
1395 m_newValues = _newValues;
1396
1397 TQPtrListIterator<KPrObject> it( m_objects );
1398 for ( ; it.current() ; ++it )
1399 it.current()->incCmdRef();
1400}
1401
1402KPrPieValueCmd::~KPrPieValueCmd()
1403{
1404 TQPtrListIterator<KPrObject> it( m_objects );
1405 for ( ; it.current() ; ++it )
1406 it.current()->decCmdRef();
1407 m_oldValues.setAutoDelete( true );
1408 m_oldValues.clear();
1409}
1410
1411void KPrPieValueCmd::addObjects( const TQPtrList<KPrObject> &objects )
1412{
1413 TQPtrListIterator<KPrObject> it( objects );
1414 for ( ; it.current(); ++it )
1415 {
1416 if ( it.current()->getType() == OT_GROUP )
1417 {
1418 KPrGroupObject * obj = dynamic_cast<KPrGroupObject*>( it.current() );
1419 if ( obj )
1420 {
1421 addObjects( obj->objectList() );
1422 }
1423 }
1424 else
1425 {
1426 KPrPieObject *obj = dynamic_cast<KPrPieObject*>( it.current() );
1427 if( obj )
1428 {
1429 m_objects.append( obj );
1430 obj->incCmdRef();
1431
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 );
1437 }
1438 }
1439 }
1440}
1441
1442void KPrPieValueCmd::execute()
1443{
1444 TQPtrListIterator<KPrObject> it( m_objects );
1445 for ( ; it.current() ; ++it )
1446 {
1447 KPrPieObject* obj=dynamic_cast<KPrPieObject*>( it.current() );
1448 if(obj)
1449 {
1450 if (m_flags & Type)
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 );
1456 }
1457 }
1458 m_doc->repaint( false );
1459
1460 m_doc->updateSideBarItem( m_page );
1461}
1462
1463void KPrPieValueCmd::unexecute()
1464{
1465 for ( unsigned int i = 0; i < m_objects.count(); i++ )
1466 {
1467 KPrPieObject* obj=dynamic_cast<KPrPieObject*>( m_objects.at( i ) );
1468 if(obj)
1469 {
1470 obj->setPieType( m_oldValues.at( i )->pieType );
1471 obj->setPieAngle( m_oldValues.at( i )->pieAngle );
1472 obj->setPieLength( m_oldValues.at( i )->pieLength );
1473 }
1474 }
1475 m_doc->repaint( false );
1476
1477 m_doc->updateSideBarItem( m_page );
1478}
1479
1480
1481KPrPolygonSettingCmd::KPrPolygonSettingCmd( const TQString &name, PolygonSettings newSettings,
1482 TQPtrList<KPrObject> &objects, KPrDocument *doc,
1483 KPrPage *page, int flags )
1484: KNamedCommand( name )
1485, m_doc( doc )
1486, m_page( page )
1487, m_newSettings( newSettings )
1488, m_flags( flags )
1489{
1490 m_objects.setAutoDelete( false );
1491 m_oldSettings.setAutoDelete( false );
1492
1493 addObjects( objects );
1494}
1495
1496
1497KPrPolygonSettingCmd::~KPrPolygonSettingCmd()
1498{
1499 TQPtrListIterator<KPrObject> it( m_objects );
1500 for ( ; it.current() ; ++it )
1501 it.current()->decCmdRef();
1502 m_oldSettings.setAutoDelete( true );
1503 m_oldSettings.clear();
1504}
1505
1506void KPrPolygonSettingCmd::addObjects( const TQPtrList<KPrObject> &objects )
1507{
1508 TQPtrListIterator<KPrObject> it( objects );
1509 for ( ; it.current(); ++it )
1510 {
1511 if ( it.current()->getType() == OT_GROUP )
1512 {
1513 KPrGroupObject * obj = dynamic_cast<KPrGroupObject*>( it.current() );
1514 if ( obj )
1515 {
1516 addObjects( obj->objectList() );
1517 }
1518 }
1519 else
1520 {
1521 KPrPolygonObject *obj = dynamic_cast<KPrPolygonObject*>( it.current() );
1522 if( obj )
1523 {
1524 m_objects.append( obj );
1525 obj->incCmdRef();
1526
1527 PolygonSettings * polygonSettings = new PolygonSettings;
1528
1529 polygonSettings->checkConcavePolygon = obj->getCheckConcavePolygon();
1530 polygonSettings->cornersValue = obj->getCornersValue();
1531 polygonSettings->sharpnessValue = obj->getSharpnessValue();
1532
1533 m_oldSettings.append( polygonSettings );
1534 }
1535 }
1536 }
1537}
1538
1539void KPrPolygonSettingCmd::execute()
1540{
1541 TQPtrListIterator<KPrObject> it( m_objects );
1542 for ( ; it.current() ; ++it )
1543 {
1544 KPrPolygonObject * obj=dynamic_cast<KPrPolygonObject*>( it.current() );
1545 if(obj)
1546 {
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 );
1553 }
1554 }
1555 m_doc->repaint( false );
1556
1557 m_doc->updateSideBarItem( m_page );
1558}
1559
1560void KPrPolygonSettingCmd::unexecute()
1561{
1562 for ( unsigned int i = 0; i < m_objects.count(); ++i )
1563 {
1564 KPrPolygonObject * obj=dynamic_cast<KPrPolygonObject*>( m_objects.at(i) );
1565 if(obj)
1566 {
1567 obj->setCheckConcavePolygon(m_oldSettings.at( i )->checkConcavePolygon);
1568 obj->setCornersValue(m_oldSettings.at( i )->cornersValue);
1569 obj->setSharpnessValue(m_oldSettings.at( i )->sharpnessValue);
1570 }
1571 }
1572 m_doc->repaint( false );
1573
1574 m_doc->updateSideBarItem( m_page );
1575}
1576
1577
1578KPrPictureSettingCmd::KPrPictureSettingCmd( const TQString &name, PictureSettings newSettings,
1579 TQPtrList<KPrObject> &objects, KPrDocument *doc,
1580 KPrPage *page, int flags )
1581: KNamedCommand( name )
1582, m_doc( doc )
1583, m_newSettings( newSettings )
1584, m_page( page )
1585, m_flags( flags )
1586{
1587 m_objects.setAutoDelete( false );
1588 m_oldValues.setAutoDelete( false );
1589
1590 addObjects( objects );
1591}
1592
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 )
1597{
1598 m_objects.setAutoDelete( false );
1599 m_oldValues.setAutoDelete( false );
1600 m_doc = _doc;
1601 m_newSettings = _newSettings;
1602
1603 m_page = m_doc->findPage( m_objects );
1604
1605 TQPtrListIterator<KPrObject> it( m_objects );
1606 for ( ; it.current() ; ++it )
1607 it.current()->incCmdRef();
1608}
1609
1610KPrPictureSettingCmd::~KPrPictureSettingCmd()
1611{
1612 TQPtrListIterator<KPrObject> it( m_objects );
1613 for ( ; it.current() ; ++it )
1614 it.current()->decCmdRef();
1615 m_oldValues.setAutoDelete( true );
1616 m_oldValues.clear();
1617}
1618
1619void KPrPictureSettingCmd::addObjects( const TQPtrList<KPrObject> &objects )
1620{
1621 TQPtrListIterator<KPrObject> it( objects );
1622 for ( ; it.current(); ++it )
1623 {
1624 if ( it.current()->getType() == OT_GROUP )
1625 {
1626 KPrGroupObject * obj = dynamic_cast<KPrGroupObject*>( it.current() );
1627 if ( obj )
1628 {
1629 addObjects( obj->objectList() );
1630 }
1631 }
1632 else
1633 {
1634 KPrPixmapObject *obj = dynamic_cast<KPrPixmapObject*>( it.current() );
1635 if( obj )
1636 {
1637 m_objects.append( obj );
1638 obj->incCmdRef();
1639
1640 PictureSettings * pictureSettings = new PictureSettings;
1641
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();
1647
1648 m_oldValues.append( pictureSettings );
1649 }
1650 }
1651 }
1652}
1653
1654void KPrPictureSettingCmd::execute()
1655{
1656 TQPtrListIterator<KPrObject> it( m_objects );
1657 for ( ; it.current() ; ++it ) {
1658 KPrPixmapObject * obj = dynamic_cast<KPrPixmapObject*>( it.current() );
1659 if ( obj ) {
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 );
1670 }
1671 }
1672 m_doc->repaint( false );
1673
1674 m_doc->updateSideBarItem( m_page );
1675}
1676
1677void KPrPictureSettingCmd::unexecute()
1678{
1679 for ( unsigned int i = 0; i < m_objects.count(); ++i ) {
1680 KPrPixmapObject * obj = dynamic_cast<KPrPixmapObject*>( m_objects.at(i) );
1681 if ( obj ) {
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 );
1688 }
1689 }
1690 m_doc->repaint( false );
1691
1692 m_doc->updateSideBarItem( m_page );
1693}
1694
1695
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)
1699{
1700 m_objects.setAutoDelete( false );
1701 m_oldValues.setAutoDelete( false );
1702 m_doc = _doc;
1703 m_page = _page;
1704 m_newValues = _newValues;
1705
1706 TQPtrListIterator<KPrObject> it( m_objects );
1707 for ( ; it.current() ; ++it )
1708 it.current()->incCmdRef();
1709}
1710
1711
1712KPrRectValueCmd::KPrRectValueCmd( const TQString &name, TQPtrList<KPrObject> &objects, RectValues newValues,
1713 KPrDocument *doc, KPrPage *page, int flags )
1714: KNamedCommand( name )
1715, m_doc( doc )
1716, m_page( page )
1717, m_newValues( newValues )
1718, m_flags( flags )
1719{
1720 m_objects.setAutoDelete( false );
1721 m_oldValues.setAutoDelete( false );
1722
1723 addObjects( objects );
1724}
1725
1726
1727KPrRectValueCmd::~KPrRectValueCmd()
1728{
1729 TQPtrListIterator<KPrObject> it( m_objects );
1730 for ( ; it.current() ; ++it )
1731 it.current()->decCmdRef();
1732
1733 m_oldValues.setAutoDelete( true );
1734 m_oldValues.clear();
1735}
1736
1737
1738void KPrRectValueCmd::addObjects( const TQPtrList<KPrObject> &objects )
1739{
1740 TQPtrListIterator<KPrObject> it( objects );
1741 for ( ; it.current(); ++it )
1742 {
1743 if ( it.current()->getType() == OT_GROUP )
1744 {
1745 KPrGroupObject * obj = dynamic_cast<KPrGroupObject*>( it.current() );
1746 if ( obj )
1747 {
1748 addObjects( obj->objectList() );
1749 }
1750 }
1751 else
1752 {
1753 KPrRectObject *obj = dynamic_cast<KPrRectObject*>( it.current() );
1754 if( obj )
1755 {
1756 m_objects.append( obj );
1757 obj->incCmdRef();
1758
1759 RectValues * rectValue = new RectValues;
1760
1761 int xtmp, ytmp;
1762 obj->getRnds( xtmp, ytmp );
1763 rectValue->xRnd = xtmp;
1764 rectValue->yRnd = ytmp;
1765
1766 m_oldValues.append( rectValue );
1767 }
1768 }
1769 }
1770}
1771
1772
1773void KPrRectValueCmd::execute()
1774{
1775 TQPtrListIterator<KPrObject> it( m_objects );
1776 for ( ; it.current() ; ++it )
1777 {
1778 KPrRectObject *obj = dynamic_cast<KPrRectObject*>( it.current() );
1779 if( obj )
1780 {
1781 int xtmp, ytmp;
1782 obj->getRnds( xtmp, ytmp );
1783
1784 if ( m_flags & XRnd )
1785 {
1786 xtmp = m_newValues.xRnd;
1787 }
1788
1789 if ( m_flags & YRnd )
1790 {
1791 ytmp = m_newValues.yRnd;
1792 }
1793
1794 obj->setRnds( xtmp, ytmp );
1795 }
1796 }
1797 m_doc->repaint( false );
1798
1799 m_doc->updateSideBarItem( m_page );
1800}
1801
1802void KPrRectValueCmd::unexecute()
1803{
1804 for ( unsigned int i = 0; i < m_objects.count(); i++ )
1805 {
1806 KPrRectObject *obj = dynamic_cast<KPrRectObject*>( m_objects.at( i ) );
1807
1808 if( obj )
1809 obj->setRnds( m_oldValues.at( i )->xRnd, m_oldValues.at( i )->yRnd );
1810 }
1811 m_doc->repaint( false );
1812
1813 m_doc->updateSideBarItem( m_page );
1814}
1815
1816
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 )
1820{
1821 object = _object;
1822 doc = _doc;
1823 m_page = doc->findPage( object );
1824
1825 object->incCmdRef();
1826}
1827
1828KPrResizeCmd::~KPrResizeCmd()
1829{
1830 object->decCmdRef();
1831}
1832
1833void KPrResizeCmd::execute()
1834{
1835 TQRect oldRect;
1836
1837 oldRect = doc->zoomHandler()->zoomRect( object->getRepaintRect() );
1838 object->moveBy( m_diff );
1839 object->resizeBy( r_diff );
1840 if ( object->getType() == OT_TEXT )
1841 {
1842 if(object->isSelected())
1843 doc->updateRuler();
1844 doc->layout( object );
1845 }
1846 if ( object->isSelected())
1847 doc->updateObjectStatusBarItem();
1848 doc->repaint( oldRect );
1849 doc->repaint( object );
1850
1851 doc->updateSideBarItem( m_page );
1852}
1853
1854void KPrResizeCmd::unexecute()
1855{
1856 TQRect oldRect;
1857
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 )
1862 {
1863 if(object->isSelected())
1864 doc->updateRuler();
1865 doc->layout( object );
1866 }
1867 if ( object->isSelected())
1868 doc->updateObjectStatusBarItem();
1869
1870 doc->repaint( oldRect );
1871 doc->repaint( object );
1872
1873 doc->updateSideBarItem( m_page );
1874}
1875
1876
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 )
1880{
1881}
1882
1883KoTextCursor * KPrOasisPasteTextCommand::execute( KoTextCursor *c )
1884{
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() );
1888 return 0;
1889 }
1890 //kdDebug() << "KWOasisPasteCommand::execute m_parag=" << m_parag << " m_idx=" << m_idx
1891 // << " firstParag=" << firstParag << " " << firstParag->paragId() << endl;
1892 cursor.setParag( firstParag );
1893 cursor.setIndex( m_idx );
1894 c->setParag( firstParag );
1895 c->setIndex( m_idx );
1896
1897 TQBuffer buffer( m_data );
1898 KoStore * store = KoStore::createStore( &buffer, KoStore::Read );
1899
1900 if ( store->bad() || !store->hasFile( "content.xml" ) )
1901 {
1902 kdError(33001) << "Invalid ZIP store in memory" << endl;
1903 if ( !store->hasFile( "content.xml" ) )
1904 kdError(33001) << "No content.xml file" << endl;
1905 return c;
1906 }
1907 store->disallowNameExpansion();
1908
1909 KoOasisStore oasisStore( store );
1910 TQDomDocument contentDoc;
1911 TQString errorMessage;
1912 bool ok = oasisStore.loadAndParse( "content.xml", contentDoc, errorMessage );
1913 if ( !ok ) {
1914 kdError(33001) << "Error parsing content.xml: " << errorMessage << endl;
1915 return c;
1916 }
1917
1918 KoOasisStyles oasisStyles;
1919 TQDomDocument stylesDoc;
1920 (void)oasisStore.loadAndParse( "styles.xml", stylesDoc, errorMessage );
1921 // Load styles from style.xml
1922 oasisStyles.createStyleMap( stylesDoc, true );
1923 // Also load styles from content.xml
1924 oasisStyles.createStyleMap( contentDoc, false );
1925
1926 TQDomElement content = contentDoc.documentElement();
1927
1928 TQDomElement body ( KoDom::namedItemNS( content, KoXmlNS::office, "body" ) );
1929
1930 // We then want to use whichever element is the child of <office:body>,
1931 // whether that's <office:text> or <office:presentation> or whatever.
1932 TQDomElement iter, realBody;
1933 forEachElement( iter, body ) {
1934 realBody = iter;
1935 }
1936 if ( realBody.isNull() ) {
1937 kdError(33001) << "No element found inside office:body!" << endl;
1938 return c;
1939 }
1940
1941 KPrTextDocument * textdoc = static_cast<KPrTextDocument *>(c->parag()->document());
1942 KPrDocument *doc = textdoc->textObject()->kPresenterDocument();
1943 KoOasisContext context( doc, *doc->getVariableCollection(), oasisStyles, store );
1944
1945 *c = textdoc->textObject()->textObject()->pasteOasisText( realBody, context, cursor, doc->styleCollection() );
1946 textdoc->textObject()->textObject()->setNeedSpellCheck( true );
1947
1948 m_lastParag = c->parag()->paragId();
1949 m_lastIndex = c->index();
1950 return c;
1951}
1952
1953KoTextCursor * KPrOasisPasteTextCommand::unexecute( KoTextCursor *c )
1954{
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() );
1958 return 0;
1959 }
1960 cursor.setParag( firstParag );
1961 cursor.setIndex( m_idx );
1962 doc->setSelectionStart( KoTextDocument::Temp, &cursor );
1963
1964 KoTextParag *lastParag = doc->paragAt( m_lastParag );
1965 if ( !lastParag ) {
1966 tqWarning( "can't locate parag at %d, last parag: %d", m_lastParag, doc->lastParag()->paragId() );
1967 return 0;
1968 }
1969 //Q_ASSERT( lastParag->document() );
1970 // Get hold of the document before deleting the parag
1971 //KoTextDocument* textdoc = lastParag->document();
1972
1973 //kdDebug() << "Undoing paste: deleting from (" << firstParag->paragId() << "," << m_idx << ")"
1974 // << " to (" << lastParag->paragId() << "," << m_lastIndex << ")" << endl;
1975
1976 cursor.setParag( lastParag );
1977 cursor.setIndex( m_lastIndex );
1978 doc->setSelectionEnd( KoTextDocument::Temp, &cursor );
1979 doc->removeSelectedText( KoTextDocument::Temp, c /* sets c to the correct position */ );
1980
1981 if ( m_idx == 0 ) {
1982 Q_ASSERT( m_oldParagLayout );
1983 if ( m_oldParagLayout )
1984 firstParag->setParagLayout( *m_oldParagLayout );
1985 }
1986 return c;
1987}
1988
1989
1990KPrChangeStartingPageCommand::KPrChangeStartingPageCommand( const TQString &name, KPrDocument *_doc,
1991 int _oldStartingPage, int _newStartingPage):
1992 KNamedCommand(name),
1993 m_doc(_doc),
1994 oldStartingPage(_oldStartingPage),
1995 newStartingPage(_newStartingPage)
1996{
1997}
1998
1999void KPrChangeStartingPageCommand::execute()
2000{
2001 m_doc->getVariableCollection()->variableSetting()->setStartingPageNumber(newStartingPage);
2002 m_doc->recalcVariables( VT_PGNUM );
2003}
2004
2005void KPrChangeStartingPageCommand::unexecute()
2006{
2007 m_doc->getVariableCollection()->variableSetting()->setStartingPageNumber(oldStartingPage);
2008 m_doc->recalcVariables( VT_PGNUM );
2009}
2010
2011
2012KPrChangeVariableSettingsCommand::KPrChangeVariableSettingsCommand( const TQString &name, KPrDocument *_doc,
2013 bool _oldValue, bool _newValue,
2014 VariableProperties _type):
2015 KNamedCommand(name),
2016 m_doc(_doc),
2017 type(_type),
2018 m_bOldValue(_oldValue),
2019 m_bNewValue(_newValue)
2020{
2021}
2022
2023void KPrChangeVariableSettingsCommand::changeValue( bool b )
2024{
2025 switch(type)
2026 {
2027 case VS_DISPLAYLINK:
2028 m_doc->getVariableCollection()->variableSetting()->setDisplayLink(b);
2029 m_doc->recalcVariables( VT_LINK );
2030 break;
2031 case VS_UNDERLINELINK:
2032 m_doc->getVariableCollection()->variableSetting()->setUnderlineLink(b);
2033 m_doc->recalcVariables( VT_LINK );
2034 break;
2035 case VS_DISPLAYCOMMENT:
2036 m_doc->getVariableCollection()->variableSetting()->setDisplayComment(b);
2037 m_doc->recalcVariables( VT_NOTE );
2038 break;
2039 case VS_DISPLAYFIELDCODE:
2040 m_doc->getVariableCollection()->variableSetting()->setDisplayFieldCode(b);
2041 m_doc->recalcVariables( VT_ALL );
2042 break;
2043 }
2044}
2045
2046void KPrChangeVariableSettingsCommand::execute()
2047{
2048 changeValue(m_bNewValue);
2049}
2050
2051void KPrChangeVariableSettingsCommand::unexecute()
2052{
2053 changeValue(m_bOldValue);
2054}
2055
2056KPrDeletePageCmd::KPrDeletePageCmd( const TQString &name, int pageNum, KPrDocument *doc )
2057: KNamedCommand( name )
2058, m_doc( doc )
2059, m_pageNum( pageNum )
2060{
2061 m_page = m_doc->pageList().at( m_pageNum );
2062}
2063
2064KPrDeletePageCmd::~KPrDeletePageCmd()
2065{
2066}
2067
2068void KPrDeletePageCmd::execute()
2069{
2070 m_doc->deSelectAllObj();
2071 m_doc->takePage( m_page, TQMAX( m_pageNum - 1, 0 ) );
2072 m_doc->updatePresentationButton();
2073}
2074
2075void KPrDeletePageCmd::unexecute()
2076{
2077 m_doc->deSelectAllObj();
2078 m_doc->insertPage( m_page, TQMAX( m_pageNum - 1, 0 ), m_pageNum );
2079 m_doc->updatePresentationButton();
2080}
2081
2082KPrInsertPageCmd::KPrInsertPageCmd( const TQString &name, int pageNum, InsertPos pos,
2083 KPrPage *page, KPrDocument *doc )
2084: KNamedCommand(name)
2085, m_doc( doc )
2086, m_page( page )
2087, m_currentPageNum( pageNum )
2088, m_insertPageNum( 0 )
2089{
2090 switch( pos )
2091 {
2092 case IP_BEFORE:
2093 m_insertPageNum = m_currentPageNum;
2094 break;
2095 case IP_AFTER:
2096 m_insertPageNum = m_currentPageNum + 1;
2097 break;
2098 }
2099}
2100
2101KPrInsertPageCmd::~KPrInsertPageCmd()
2102{
2103}
2104
2105void KPrInsertPageCmd::execute()
2106{
2107 m_doc->deSelectAllObj();
2108 m_doc->insertPage( m_page, m_currentPageNum, m_insertPageNum );
2109 m_page->completeLoading( false, -1 );
2110 m_doc->updatePresentationButton();
2111}
2112
2113void KPrInsertPageCmd::unexecute()
2114{
2115 m_doc->deSelectAllObj();
2116 m_doc->takePage( m_page, m_currentPageNum );
2117 m_doc->updatePresentationButton();
2118}
2119
2120KPrMovePageCmd::KPrMovePageCmd( const TQString &_name,int from, int to, KPrDocument *_doc ) :
2121 KNamedCommand( _name ),
2122 m_doc( _doc ),
2123 m_oldPosition( from ),
2124 m_newPosition( to )
2125{
2126}
2127
2128KPrMovePageCmd::~KPrMovePageCmd()
2129{
2130}
2131
2132void KPrMovePageCmd::execute()
2133{
2134 m_doc->deSelectAllObj();
2135 m_doc->movePageTo( m_oldPosition, m_newPosition );
2136}
2137
2138void KPrMovePageCmd::unexecute()
2139{
2140 m_doc->deSelectAllObj();
2141 m_doc->movePageTo( m_newPosition, m_oldPosition );
2142}
2143
2144
2145KPrChangeTitlePageNameCommand::KPrChangeTitlePageNameCommand( const TQString &_name,KPrDocument *_doc,
2146 const TQString &_oldPageName,
2147 const TQString &_newPageName, KPrPage *_page ) :
2148 KNamedCommand(_name),
2149 m_doc(_doc),
2150 oldPageName(_oldPageName),
2151 newPageName(_newPageName),
2152 m_page(_page)
2153{
2154}
2155
2156void KPrChangeTitlePageNameCommand::execute()
2157{
2158 m_page->insertManualTitle(newPageName);
2159 m_doc->updateSideBarItem( m_page );
2160 m_doc->recalcVariables( VT_PGNUM );
2161}
2162
2163void KPrChangeTitlePageNameCommand::unexecute()
2164{
2165 m_page->insertManualTitle(oldPageName);
2166 m_doc->updateSideBarItem( m_page );
2167 m_doc->recalcVariables( VT_PGNUM );
2168}
2169
2170KPrChangeCustomVariableValue::KPrChangeCustomVariableValue( const TQString &name, KPrDocument *_doc,
2171 const TQString & _oldValue, const TQString & _newValue,
2172 KoCustomVariable *var):
2173 KNamedCommand(name),
2174 m_doc(_doc),
2175 newValue(_newValue),
2176 oldValue(_oldValue),
2177 m_var(var)
2178{
2179}
2180
2181void KPrChangeCustomVariableValue::execute()
2182{
2183 Q_ASSERT(m_var);
2184 m_var->setValue(newValue);
2185 m_doc->recalcVariables( VT_CUSTOM );
2186}
2187
2188void KPrChangeCustomVariableValue::unexecute()
2189{
2190 Q_ASSERT(m_var);
2191 m_var->setValue(oldValue);
2192 m_doc->recalcVariables( VT_CUSTOM );
2193}
2194
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),
2200 m_doc(_doc),
2201 oldHref(_oldHref),
2202 newHref(_newHref),
2203 oldLink(_oldLink),
2204 newLink(_newLink),
2205 m_var(var)
2206{
2207}
2208
2209
2210void KPrChangeLinkVariable::execute()
2211{
2212 m_var->setLink(newLink,newHref);
2213 m_doc->recalcVariables(VT_LINK);
2214}
2215
2216void KPrChangeLinkVariable::unexecute()
2217{
2218 m_var->setLink(oldLink,oldHref);
2219 m_doc->recalcVariables(VT_LINK);
2220}
2221
2222
2223KPrNameObjectCommand::KPrNameObjectCommand( const TQString &_name, const TQString &_objectName,
2224 KPrObject *_obj, KPrDocument *_doc ):
2225 KNamedCommand( _name ),
2226 newObjectName( _objectName ),
2227 object( _obj ),
2228 doc( _doc )
2229{
2230 oldObjectName = object->getObjectName();
2231
2232 m_page = doc->findPage( object );
2233}
2234
2235KPrNameObjectCommand::~KPrNameObjectCommand()
2236{
2237}
2238
2239void KPrNameObjectCommand::execute()
2240{
2241 object->setObjectName( newObjectName );
2242 m_page->unifyObjectName( object );
2243
2244 doc->updateSideBarItem( m_page );
2245}
2246
2247void KPrNameObjectCommand::unexecute()
2248{
2249 object->setObjectName( oldObjectName );
2250
2251 doc->updateSideBarItem( m_page );
2252}
2253
2254KPrDisplayObjectFromMasterPage::KPrDisplayObjectFromMasterPage(const TQString &name, KPrDocument *_doc, KPrPage *_page, bool _newValue)
2255 :KNamedCommand(name),
2256 m_doc( _doc ),
2257 m_page(_page),
2258 newValue(_newValue)
2259{
2260}
2261
2262void KPrDisplayObjectFromMasterPage::execute()
2263{
2264 m_page->setDisplayObjectFromMasterPage( newValue );
2265 m_doc->updateSideBarItem( m_doc->masterPage() );
2266}
2267
2268void KPrDisplayObjectFromMasterPage::unexecute()
2269{
2270 m_page->setDisplayObjectFromMasterPage( !newValue );
2271 m_doc->updateSideBarItem( m_doc->masterPage() );
2272}
2273
2274
2275KPrDisplayBackgroundPage::KPrDisplayBackgroundPage(const TQString &name, KPrDocument *_doc, KPrPage *_page, bool _newValue)
2276 :KNamedCommand(name),
2277 m_doc( _doc ),
2278 m_page(_page),
2279 newValue(_newValue)
2280{
2281}
2282
2283void KPrDisplayBackgroundPage::execute()
2284{
2285 m_page->setDisplayBackground( newValue );
2286 m_doc->updateSideBarItem( m_doc->masterPage() );
2287}
2288
2289void KPrDisplayBackgroundPage::unexecute()
2290{
2291 m_page->setDisplayBackground( !newValue );
2292 m_doc->updateSideBarItem( m_doc->masterPage() );
2293}
2294
2295
2296KPrHideShowHeaderFooter::KPrHideShowHeaderFooter( const TQString &name, KPrDocument *_doc, KPrPage *_page,
2297 bool _newValue, KPrTextObject *_textObject):
2298 KNamedCommand(name),
2299 m_doc( _doc ),
2300 m_page(_page),
2301 m_textObject(_textObject),
2302 newValue(_newValue)
2303{
2304}
2305
2306
2307void KPrHideShowHeaderFooter::execute()
2308{
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 );
2313 else
2314 kdDebug(33001)<<"Error in void KPrHideShowHeaderFooter::execute()\n";
2315
2316 m_doc->updateSideBarItem( m_doc->masterPage() );
2317}
2318
2319void KPrHideShowHeaderFooter::unexecute()
2320{
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 );
2325 else
2326 kdDebug(33001)<<"Error in void KPrHideShowHeaderFooter::unexecute()\n";
2327
2328 m_doc->updateSideBarItem( m_doc->masterPage() );
2329}
2330
2331KPrFlipObjectCommand::KPrFlipObjectCommand( const TQString &name, KPrDocument *_doc,
2332 bool _horizontal, TQPtrList<KPrObject> &_objects ):
2333 KNamedCommand( name ),
2334 m_doc( _doc ),
2335 objects( _objects ),
2336 horizontal( _horizontal )
2337{
2338 objects.setAutoDelete( false );
2339
2340 m_page = m_doc->findPage( objects );
2341
2342 TQPtrListIterator<KPrObject> it( objects );
2343 for ( ; it.current() ; ++it )
2344 it.current()->incCmdRef();
2345}
2346
2347KPrFlipObjectCommand::~KPrFlipObjectCommand()
2348{
2349 TQPtrListIterator<KPrObject> it( objects );
2350 for ( ; it.current() ; ++it )
2351 it.current()->decCmdRef();
2352}
2353
2354void KPrFlipObjectCommand::execute()
2355{
2356 flipObjects();
2357}
2358
2359void KPrFlipObjectCommand::unexecute()
2360{
2361 flipObjects();
2362}
2363
2364void KPrFlipObjectCommand::flipObjects()
2365{
2366 TQPtrListIterator<KPrObject> it( objects );
2367 for ( ; it.current() ; ++it )
2368 {
2369 it.current()->flip( horizontal );
2370 m_doc->repaint( it.current() );
2371 }
2372
2373 m_doc->updateSideBarItem( m_page );
2374}
2375
2376
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 )
2382, m_type( type )
2383 , m_doc( _doc )
2384{
2385 TQPtrListIterator<KPrObject> it( m_objects );
2386 for ( ; it.current() ; ++it )
2387 {
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() );
2393 }
2394}
2395
2396KPrGeometryPropertiesCommand::KPrGeometryPropertiesCommand( const TQString &name, TQValueList<bool> &lst,
2397 TQPtrList<KPrObject> &objects, bool newValue,
2398 KgpType type, KPrDocument *_doc)
2399: KNamedCommand( name )
2400, m_oldValue( lst )
2401, m_objects( objects )
2402, m_newValue( newValue )
2403, m_type( type )
2404, m_doc ( _doc )
2405{
2406 TQPtrListIterator<KPrObject> it( m_objects );
2407 for ( ; it.current() ; ++it )
2408 it.current()->incCmdRef();
2409}
2410
2411KPrGeometryPropertiesCommand::~KPrGeometryPropertiesCommand()
2412{
2413 TQPtrListIterator<KPrObject> it( m_objects );
2414 for ( ; it.current() ; ++it )
2415 it.current()->decCmdRef();
2416}
2417
2418void KPrGeometryPropertiesCommand::execute()
2419{
2420 TQPtrListIterator<KPrObject> it( m_objects );
2421 for ( ; it.current() ; ++it )
2422 {
2423 if ( m_type == ProtectSize )
2424 {
2425 it.current()->setProtect( m_newValue );
2426 if ( it.current()->isSelected() )
2427 m_doc->repaint( it.current() );
2428 }
2429 else if ( m_type == KeepRatio)
2430 it.current()->setKeepRatio( m_newValue );
2431 }
2432}
2433
2434void KPrGeometryPropertiesCommand::unexecute()
2435{
2436 KPrObject *obj = 0;
2437 for ( unsigned int i = 0; i < m_objects.count(); ++i ) {
2438 obj = m_objects.at( i );
2439 if ( m_type == ProtectSize )
2440 {
2441 obj->setProtect( *m_oldValue.at(i) );
2442 if ( obj->isSelected() )
2443 m_doc->repaint( obj );
2444 }
2445 else if ( m_type == KeepRatio)
2446 obj->setKeepRatio( *m_oldValue.at(i) );
2447 }
2448}
2449
2450KPrProtectContentCommand::KPrProtectContentCommand( const TQString &name, TQPtrList<KPrObject> &objects,
2451 bool protectContent, KPrDocument *doc )
2452: KNamedCommand( name )
2453, m_protectContent( protectContent )
2454, m_doc( doc )
2455{
2456 m_objects.setAutoDelete( false );
2457
2458 addObjects( objects );
2459}
2460
2461KPrProtectContentCommand::KPrProtectContentCommand( const TQString &name, bool protectContent,
2462 KPrTextObject *obj, KPrDocument *doc )
2463: KNamedCommand( name )
2464, m_protectContent( protectContent )
2465, m_doc( doc )
2466{
2467 obj->incCmdRef();
2468 m_objects.append( obj );
2469 m_oldValues.append( obj->isProtectContent() );
2470}
2471
2472KPrProtectContentCommand::~KPrProtectContentCommand()
2473{
2474 TQPtrListIterator<KPrTextObject> it( m_objects );
2475 for ( ; it.current() ; ++it )
2476 it.current()->decCmdRef();
2477}
2478
2479void KPrProtectContentCommand::addObjects( const TQPtrList<KPrObject> &objects )
2480{
2481 TQPtrListIterator<KPrObject> it( objects );
2482 for ( ; it.current(); ++it )
2483 {
2484 if ( it.current()->getType() == OT_GROUP )
2485 {
2486 KPrGroupObject * obj = dynamic_cast<KPrGroupObject*>( it.current() );
2487 if ( obj )
2488 {
2489 addObjects( obj->objectList() );
2490 }
2491 }
2492 else
2493 {
2494 KPrTextObject *obj = dynamic_cast<KPrTextObject*>( it.current() );
2495 if( obj )
2496 {
2497 m_objects.append( obj );
2498 obj->incCmdRef();
2499
2500 m_oldValues.append( obj->isProtectContent() );
2501 }
2502 }
2503 }
2504}
2505
2506void KPrProtectContentCommand::execute()
2507{
2508 TQPtrListIterator<KPrTextObject> it( m_objects );
2509 for ( ; it.current() ; ++it )
2510 {
2511 it.current()->setProtectContent( m_protectContent );
2512 }
2513 m_doc->updateObjectSelected();
2514 m_doc->updateRulerInProtectContentMode();
2515
2516}
2517
2518void KPrProtectContentCommand::unexecute()
2519{
2520 for ( unsigned int i = 0; i < m_objects.count(); i++ )
2521 {
2522 m_objects.at( i )->setProtectContent( m_oldValues[i] );
2523 }
2524 m_doc->updateObjectSelected();
2525 m_doc->updateRulerInProtectContentMode();
2526}
2527
2528KPrCloseObjectCommand::KPrCloseObjectCommand( const TQString &name, TQPtrList<KPrObject> objects, KPrDocument *doc )
2529: KNamedCommand( name )
2530, m_doc( doc )
2531, m_page( doc->findPage( objects.at( 0 ) ) )
2532{
2533 TQPtrListIterator<KPrObject> it( objects );
2534 for ( ; it.current(); ++it )
2535 {
2536 KPrPointObject * pointObject = dynamic_cast<KPrPointObject *>( *it );
2537 if ( pointObject )
2538 {
2539 m_openObjects.append( *it );
2540 ( *it )->incCmdRef();
2541 KPrClosedLineObject * closedObject = new KPrClosedLineObject( *pointObject );
2542 closedObject->incCmdRef();
2543 m_closedObjects.append( closedObject );
2544 }
2545 }
2546}
2547
2548KPrCloseObjectCommand::~KPrCloseObjectCommand()
2549{
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();
2556}
2557
2558void KPrCloseObjectCommand::execute()
2559{
2560 TQPtrListIterator<KPrObject> openIt( m_openObjects );
2561 TQPtrListIterator<KPrObject> closeIt( m_closedObjects );
2562 for ( ; openIt.current() ; ++openIt, ++closeIt )
2563 {
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 );
2571 }
2572 m_doc->updateSideBarItem( m_page );
2573}
2574
2575void KPrCloseObjectCommand::unexecute()
2576{
2577 TQPtrListIterator<KPrObject> openIt( m_openObjects );
2578 TQPtrListIterator<KPrObject> closeIt( m_closedObjects );
2579 for ( ; openIt.current() ; ++openIt, ++closeIt )
2580 {
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 );
2588 }
2589 m_doc->updateSideBarItem( m_page );
2590}
2591
2592MarginsStruct::MarginsStruct( KPrTextObject *obj )
2593{
2594 topMargin = obj->bTop();
2595 bottomMargin= obj->bBottom();
2596 leftMargin = obj->bLeft();
2597 rightMargin= obj->bRight();
2598}
2599
2600MarginsStruct::MarginsStruct( double _left, double _top, double _right, double _bottom ):
2601 topMargin(_top),
2602 bottomMargin(_bottom),
2603 leftMargin(_left),
2604 rightMargin(_right)
2605{
2606}
2607
2608
2609KPrChangeMarginCommand::KPrChangeMarginCommand( const TQString &name, TQPtrList<KPrObject> &objects,
2610 MarginsStruct newMargins, KPrDocument *doc,
2611 KPrPage *page )
2612: KNamedCommand( name )
2613, m_newMargins( newMargins )
2614, m_page( page )
2615, m_doc( doc )
2616{
2617 m_objects.setAutoDelete( false );
2618 m_oldMargins.setAutoDelete( false );
2619
2620 addObjects( objects );
2621}
2622
2623
2624KPrChangeMarginCommand::~KPrChangeMarginCommand()
2625{
2626 TQPtrListIterator<KPrTextObject> it( m_objects );
2627 for ( ; it.current() ; ++it )
2628 it.current()->decCmdRef();
2629 m_oldMargins.setAutoDelete( true );
2630 m_oldMargins.clear();
2631}
2632
2633
2634void KPrChangeMarginCommand::addObjects( const TQPtrList<KPrObject> &objects )
2635{
2636 TQPtrListIterator<KPrObject> it( objects );
2637 for ( ; it.current(); ++it )
2638 {
2639 if ( it.current()->getType() == OT_GROUP )
2640 {
2641 KPrGroupObject * obj = dynamic_cast<KPrGroupObject*>( it.current() );
2642 if ( obj )
2643 {
2644 addObjects( obj->objectList() );
2645 }
2646 }
2647 else
2648 {
2649 KPrTextObject *obj = dynamic_cast<KPrTextObject*>( it.current() );
2650 if( obj )
2651 {
2652 m_objects.append( obj );
2653 obj->incCmdRef();
2654
2655 m_oldMargins.append( new MarginsStruct( obj ) );
2656 }
2657 }
2658 }
2659}
2660
2661
2662void KPrChangeMarginCommand::execute()
2663{
2664 TQPtrListIterator<KPrTextObject> it( m_objects );
2665 for ( ; it.current() ; ++it )
2666 {
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();
2671 }
2672 m_doc->repaint( false );
2673
2674 m_doc->updateSideBarItem( m_page );
2675}
2676
2677void KPrChangeMarginCommand::unexecute()
2678{
2679 for ( unsigned int i = 0; i < m_objects.count(); i++ )
2680 {
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();
2686 object->layout();
2687 }
2688 m_doc->repaint( false );
2689
2690 m_doc->updateSideBarItem( m_page );
2691}
2692
2693
2694KPrChangeVerticalAlignmentCommand::KPrChangeVerticalAlignmentCommand( const TQString &name, KPrTextObject *_obj,
2695 VerticalAlignmentType _oldAlign,
2696 VerticalAlignmentType _newAlign,
2697 KPrDocument *_doc) :
2698 KNamedCommand(name),
2699 m_obj( _obj ),
2700 m_oldAlign(_oldAlign),
2701 m_newAlign(_newAlign),
2702 m_doc( _doc )
2703{
2704 m_page = m_doc->findPage( _obj );
2705}
2706
2707void KPrChangeVerticalAlignmentCommand::execute()
2708{
2709 m_obj->setVerticalAligment( m_newAlign );
2710 m_obj->kPresenterDocument()->layout(m_obj);
2711 m_obj->kPresenterDocument()->repaint(m_obj);
2712
2713 m_doc->updateSideBarItem( m_page );
2714}
2715
2716void KPrChangeVerticalAlignmentCommand::unexecute()
2717{
2718 m_obj->setVerticalAligment( m_oldAlign );
2719 m_obj->kPresenterDocument()->layout(m_obj);
2720 m_obj->kPresenterDocument()->repaint(m_obj);
2721
2722 m_doc->updateSideBarItem( m_page );
2723}
2724
2725
2726KPrChangeTabStopValueCommand::KPrChangeTabStopValueCommand( const TQString &name, double _oldValue, double _newValue,
2727 KPrDocument *_doc):
2728 KNamedCommand(name),
2729 m_doc( _doc ),
2730 m_oldValue(_oldValue),
2731 m_newValue(_newValue)
2732{
2733}
2734
2735void KPrChangeTabStopValueCommand::execute()
2736{
2737 m_doc->setTabStopValue ( m_newValue );
2738}
2739
2740void KPrChangeTabStopValueCommand::unexecute()
2741{
2742 m_doc->setTabStopValue ( m_oldValue );
2743}
2744
2745KPrImageEffectCmd::KPrImageEffectCmd(const TQString &_name, TQPtrList<ImageEffectSettings> &_oldSettings,
2746 ImageEffectSettings _newSettings, TQPtrList<KPrObject> &_objects,
2747 KPrDocument *_doc )
2748 :KNamedCommand( _name ), oldSettings( _oldSettings ), objects( _objects )
2749{
2750 objects.setAutoDelete( false );
2751 oldSettings.setAutoDelete( false );
2752 doc = _doc;
2753 newSettings = _newSettings;
2754
2755 m_page = doc->findPage( objects );
2756
2757 TQPtrListIterator<KPrObject> it( objects );
2758 for ( ; it.current() ; ++it )
2759 it.current()->incCmdRef();
2760}
2761
2762KPrImageEffectCmd::~KPrImageEffectCmd()
2763{
2764 TQPtrListIterator<KPrObject> it( objects );
2765 for ( ; it.current() ; ++it )
2766 it.current()->decCmdRef();
2767 oldSettings.setAutoDelete( true );
2768 oldSettings.clear();
2769}
2770
2771void KPrImageEffectCmd::execute()
2772{
2773 TQPtrListIterator<KPrObject> it( objects );
2774 for ( ; it.current() ; ++it ) {
2775 KPrPixmapObject * obj = dynamic_cast<KPrPixmapObject*>( it.current() );
2776 if ( obj ) {
2777 obj->setImageEffect(newSettings.effect);
2778 obj->setIEParams(newSettings.param1, newSettings.param2, newSettings.param3);
2779 }
2780 }
2781 doc->repaint( false );
2782
2783 doc->updateSideBarItem( m_page );
2784}
2785
2786void KPrImageEffectCmd::unexecute()
2787{
2788 for ( unsigned int i = 0; i < objects.count(); ++i ) {
2789 KPrPixmapObject * obj = dynamic_cast<KPrPixmapObject*>( objects.at(i) );
2790 if ( obj ) {
2791 obj->setImageEffect(oldSettings.at( i )->effect);
2792 obj->setIEParams(oldSettings.at( i )->param1, oldSettings.at( i )->param2,
2793 oldSettings.at( i )->param3);
2794 }
2795 }
2796 doc->repaint( false );
2797
2798 doc->updateSideBarItem( m_page );
2799}
2800
2801KPrChangeVariableNoteText::KPrChangeVariableNoteText( const TQString &name, KPrDocument *_doc,
2802 const TQString &_oldValue,const TQString &_newValue,
2803 KoNoteVariable *var):
2804 KNamedCommand(name),
2805 m_doc(_doc),
2806 newValue(_newValue),
2807 oldValue(_oldValue),
2808 m_var(var)
2809{
2810}
2811
2812KPrChangeVariableNoteText::~KPrChangeVariableNoteText()
2813{
2814}
2815
2816void KPrChangeVariableNoteText::execute()
2817{
2818 Q_ASSERT(m_var);
2819 m_var->setNote(newValue);
2820}
2821
2822void KPrChangeVariableNoteText::unexecute()
2823{
2824 Q_ASSERT(m_var);
2825 m_var->setNote(oldValue);
2826}
KPrTextObject * textObject() const
Return the text object in which this document is.