kpresenter

KPrView.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
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 <kprinter.h>
22#include <tdeaccel.h>
23#include <tdeglobalsettings.h>
24#include <tqpainter.h>
25#include <tqscrollbar.h>
26#include <tqpopupmenu.h>
27#include <tqcursor.h>
28#include <tqfileinfo.h>
29#include <tqtextstream.h>
30#include <assert.h>
31#include <tqtoolbutton.h>
32#include <tqtooltip.h>
33#include <tqdir.h>
34#include <tqclipboard.h>
35#include <tqradiobutton.h>
36#include <tqdragobject.h>
37#include <tqfile.h>
38
39#include "KPrPage.h"
40#include "KPrBackDia.h"
41#include "autoformEdit/AFChoose.h"
42#include "KPrPropertyEditor.h"
43#include "KPrPgConfDia.h"
44#include "KPrEffectDia.h"
45#include "KPrRotationDialogImpl.h"
46#include "KPrShadowDialogImpl.h"
47#include "KPrImageEffectDia.h"
48#include "KPrBackground.h"
49#include "KPrPenStyleWidget.h"
50#include "KPrObjectProperties.h"
51
52#include <KoAutoFormat.h>
53
54#include "KPrSlideTransitionDia.h"
55
56#include "KPrPresDurationDia.h"
57#include "KPrPartObject.h"
58#include "KPrSideBar.h"
59#include "KPrNoteBar.h"
60#include "insertpagedia.h"
61#include "KPrCustomSlideShowDia.h"
62
63#include <KoPictureFilePreview.h>
64#include <KoCreateStyleDia.h>
65
66#include <dcopclient.h>
67#include <tdefiledialog.h>
68#include <tdemessagebox.h>
69#include <kstdaction.h>
70#include <tdeapplication.h>
71#include <tdeio/netaccess.h>
72
73#include "KPrView.h"
74#include "KPrDocument.h"
75#include "KPrWebPresentation.h"
76#include "KPrMSPresentationSetup.h"
77#include "KPrTextObject.h"
78
79#include <tdelocale.h>
80#include <kcolordialog.h>
81#include <tdeconfig.h>
82#include <tdefontdialog.h>
83#include <tdeglobal.h>
84#include <kimageio.h>
85#include <tdeparts/event.h>
86#include <kdebug.h>
87#include <tdetempfile.h>
88#include <kcolorbutton.h>
89#include <kprocess.h>
90
91#include <KoMainWindow.h>
92#include <KoPartSelectDia.h>
93#include <KoQueryTrader.h>
94#include <KoPageLayoutDia.h>
95#include <KoRuler.h>
96#include <KoTemplateCreateDia.h>
97#include <kcoloractions.h>
98#include <tkcoloractions.h>
99#include <tdeaction.h>
100#include <tqspinbox.h>
101#include <tqcombobox.h>
102#include <KoPartSelectAction.h>
103#include <KoTextZoomHandler.h>
104#include <Kolinestyleaction.h>
105#include <Kolinewidthaction.h>
106
107#include <stdlib.h>
108#include <signal.h>
109
110#include <kstandarddirs.h>
111
112#include "KPrViewIface.h"
113#include "KPrConfig.h"
114
115#include <KoTextParag.h>
116#include <KoTextObject.h>
117#include "KPrCommand.h"
118#include <KoFontDia.h>
119#include <KoCharSelectDia.h>
120#include <KoInsertLink.h>
121#include <KoAutoFormatDia.h>
122#include <KoParagCounter.h>
123#include <KoParagDia.h>
124#include <KoVariable.h>
125#include <KoCustomVariablesDia.h>
126#include <KoGuideLineDia.h>
127#include <KoCompletionDia.h>
128
129#include <tdespell.h>
130#include <kstatusbar.h>
131#include "KPrTextDocument.h"
132
133#include <KoChangeCaseDia.h>
134#include <tqregexp.h>
135
136#include <KoSearchDia.h>
137#include "KPrFindReplace.h"
138#include "KPrVariableCollection.h"
139#include "KPrCanvas.h"
140#include <tqpaintdevicemetrics.h>
141#include <KoStyleCollection.h>
142#include "KPrStyleManager.h"
143#include "KPrPixmapObject.h"
144#include <KoCommentDia.h>
145
146#include "KPrDuplicateObjDia.h"
147#include <tdestdaccel.h>
148#include <KoDocumentInfo.h>
149#include <tdeaccelgen.h>
150#include "KPrImportStyleDia.h"
151#include <kurldrag.h>
152#include <config.h>
153#include <KoStore.h>
154#include <KoStoreDrag.h>
155
156#include <tdespell2/broker.h>
157#include <tdespell2/defaultdictionary.h>
158#include <tdespell2/dialog.h>
159#include "KoSpell.h"
160#include "KPrPrinterDlg.h"
161using namespace KSpell2;
162
163#define COPYOASISFORMAT 0
164
165static const char * const pageup_xpm[] = {
166 " 14 14 2 1",
167 ". c #000000",
168 "# c none",
169 "##############",
170 "##############",
171 "######..######",
172 "#####....#####",
173 "####......####",
174 "###........###",
175 "##############",
176 "######..######",
177 "#####....#####",
178 "####......####",
179 "###........###",
180 "##############",
181 "##############",
182 "##############"
183};
184
185static const char * const pagedown_xpm[] = {
186 " 14 14 2 1",
187 ". c #000000",
188 "# c none",
189 "##############",
190 "##############",
191 "##############",
192 "###........###",
193 "####......####",
194 "#####....#####",
195 "######..######",
196 "##############",
197 "###........###",
198 "####......####",
199 "#####....#####",
200 "######..######",
201 "##############",
202 "##############"
203};
204
205#ifdef HAVE_DPMS
206#include <X11/Xlib.h>
207#include <X11/Xutil.h>
208#include <X11/Xmd.h>
209#include <X11/extensions/dpms.h>
210#include <fixx11h.h>
211
212extern "C" {
213#ifndef HAVE_DPMSCAPABLE_PROTO
214Bool DPMSCapable( Display * );
215#endif
216}
217
218#if defined(XIMStringConversionRetrival) || defined (__sun)
219extern "C" {
220#endif
221 Bool DPMSQueryExtension(Display *, int *, int *);
222 Status DPMSEnable(Display *);
223 Status DPMSDisable(Display *);
224 Bool DPMSGetTimeouts(Display *, CARD16 *, CARD16 *, CARD16 *);
225#if defined(XIMStringConversionRetrival) || defined (__sun)
226}
227#endif
228#endif
229
230static void enableDPMS(bool enable)
231{
232#ifdef HAVE_DPMS
233 Display *display = tqt_xdisplay();
234
235 int dummy;
236 bool hasDPMS = DPMSQueryExtension(display, &dummy, &dummy);
237 if (hasDPMS && DPMSCapable(display)) {
238 if (enable) {
239 kdDebug() << "Enabling DPMS" << endl;
240 DPMSEnable(display);
241 } else {
242 kdDebug() << "Disabling DPMS" << endl;
243 DPMSDisable(display);
244 }
245 } else
246 tqWarning("Server has no DPMS extension");
247
248 XFlush(display);
249#else
250 Q_UNUSED(enable); /* keep gcc silent */
251#endif
252}
253
254static bool isDPMSEnabled()
255{
256 bool result = false;
257#ifdef HAVE_DPMS
258 int event_base;
259 int error_base;
260 CARD16 x_standby;
261 CARD16 x_suspend;
262 CARD16 x_off;
263 Display *display = tqt_xdisplay();
264 if (DPMSQueryExtension(display, &event_base, &error_base))
265 if (DPMSCapable(display))
266 result = (DPMSGetTimeouts(display, &x_standby, &x_suspend, &x_off));
267#endif
268 return result;
269}
270
271KPrView::KPrView( KPrDocument* _doc, TQWidget *_parent, const char *_name )
272 : KoView( _doc, _parent, _name )
273{
274
275 setInstance( KPrFactory::global() );
276 if ( !_doc->isReadWrite() )
277 setXMLFile( "kpresenter_readonly.rc" );
278 else
279 setXMLFile( "kpresenter.rc" );
280
281 dcop = 0;
282 dcopObject(); // build it
283
284 m_bDisplayFieldCode=false;
285 // init
286 afChoose = 0;
287 m_propertyEditor = 0;
288 pgConfDia = 0;
289 rotateDia = 0;
290 shadowDia = 0;
291 imageEffectDia = 0;
292 presDurationDia = 0;
293 v_ruler = 0;
294 h_ruler = 0;
295 pen = KoPen( black, 1.0, TQt::SolidLine );
296 brush = TQBrush( white, SolidPattern );
297 lineBegin = L_NORMAL;
298 lineEnd = L_NORMAL;
299 gColor1 = red;
300 gColor2 = green;
301 gType = BCT_GHORZ;
302 gUnbalanced = false;
303 gXFactor = 100;
304 gYFactor = 100;
305 fillType = FT_BRUSH;
306 pieType = PT_PIE;
307 pieLength = 90 * 16;
308 pieAngle = 45 * 16;
309 setMouseTracking( true );
310 m_bShowGUI = true;
311 presStarted = false;
312 m_autoPresRestart = false;
313 m_autoPresStop = false;
314 rndX = 0;
315 rndY = 0;
316 m_editMaster = false;
317 allowWebPres = true;
318 allowMSPres = true;
319 currPg = 0;
320 sidebar = 0;
321 notebar = 0;
322 splitter = 0;
323 pageBase = 0;
324 m_canvas = 0L;
325 m_spell.kospell = 0;
326 m_spell.textIterator = 0L;
327 m_spell.macroCmdSpellCheck = 0L;
328 m_spell.dlg = 0;
329 m_broker = Broker::openBroker( TDESharedConfig::openConfig( "kpresenterrc" ) );
330
331 m_autoPresTimerConnected = false;
332 m_actionList.setAutoDelete( true );
333 checkConcavePolygon = false;
334 cornersValue = 3;
335 sharpnessValue = 0;
336 tbAlign = TQt::AlignLeft;
337 tbFont = font();
338 tbColor = black;
339
340 mirrorType = PM_NORMAL;
341 depth = 0;
342 swapRGB = false;
343 grayscal = false;
344 bright = 0;
345
346 m_currentLineTool = LtLine;
347 m_currentShapeTool = StRectangle;
348 m_currentClosedLineTool = CltFreehand;
349
350 m_searchEntry = 0L;
351 m_replaceEntry = 0L;
352 m_findReplace = 0L;
353 m_switchPage=-1;
354
355 m_fontDlg=0L;
356 m_paragDlg=0L;
357 m_pKPresenterDoc = _doc;
358
359 createGUI();
360
361 setKeyCompression( true );
362 m_specialCharDlg=0L;
363
364 if ( shell() )
365 changeNbOfRecentFiles( m_pKPresenterDoc->maxRecentFiles() );
366
367 connect(this, TQ_SIGNAL(embeddImage(const TQString &)), TQ_SLOT(insertPicture(const TQString &)));
368 connect( m_pKPresenterDoc, TQ_SIGNAL( sig_refreshMenuCustomVariable()),
369 this, TQ_SLOT( refreshCustomMenu()));
370
371 // Cut and copy are directly connected to the selectionChanged signal
372 if ( m_pKPresenterDoc->isReadWrite() )
373 connect( m_canvas, TQ_SIGNAL(selectionChanged(bool)),
374 this, TQ_SLOT(slotChangeCutState(bool )/*setEnabled(bool)*/) );
375 else
376 actionEditCut->setEnabled( false );
377
378 connect( m_canvas, TQ_SIGNAL(selectionChanged(bool)),
379 actionEditCopy, TQ_SLOT(setEnabled(bool)) );
380
381 connect (m_canvas, TQ_SIGNAL(selectionChanged(bool)),
382 actionChangeCase, TQ_SLOT(setEnabled(bool)));
383 //connect (m_canvas, TQ_SIGNAL(selectionChanged(bool)),
384 // actionCreateStyleFromSelection, TQ_SLOT(setEnabled(bool)));
385
386 connect( m_canvas, TQ_SIGNAL( currentObjectEditChanged() ), this, TQ_SLOT( slotObjectEditChanged()));
387
388 connect( h_ruler, TQ_SIGNAL( tabListChanged( const KoTabulatorList & ) ), this,
389 TQ_SLOT( tabListChanged( const KoTabulatorList & ) ) );
390
391 //statusbar stuff
392 connect( m_pKPresenterDoc, TQ_SIGNAL( pageNumChanged() ), this, TQ_SLOT( pageNumChanged()) );
393 connect( this, TQ_SIGNAL( currentPageChanged(int) ), this, TQ_SLOT( pageNumChanged()) );
394 connect( m_canvas, TQ_SIGNAL( objectSizeChanged() ), this, TQ_SLOT( updateObjectStatusBarItem() ));
395 connect( m_canvas, TQ_SIGNAL( objectSelectedChanged() ), this, TQ_SLOT( updateObjectStatusBarItem() ));
396 connect (m_pKPresenterDoc, TQ_SIGNAL(sig_updateRuler()),this, TQ_SLOT( slotUpdateRuler()));
397 connect (m_pKPresenterDoc, TQ_SIGNAL(sig_updateRuler()),this, TQ_SLOT( slotUpdateScrollBarRanges()));
398 connect (m_pKPresenterDoc, TQ_SIGNAL(sig_updateMenuBar()),this, TQ_SLOT(updateSideBarMenu()));
399 connect (m_pKPresenterDoc, TQ_SIGNAL(unitChanged(KoUnit::Unit)),this, TQ_SLOT(slotUnitChanged(KoUnit::Unit)));
400 connect( m_pKPresenterDoc, TQ_SIGNAL( modified( bool ) ), this, TQ_SLOT( documentModified( bool )) );
401 connect( m_pKPresenterDoc, TQ_SIGNAL(completed()), this, TQ_SLOT(loadingFinished()));
402
403 KStatusBar * sb = statusBar();
404 m_sbPageLabel = 0L;
405 m_sbObjectLabel = 0L;
406 m_sbModifiedLabel = 0;
407 m_sbZoomLabel = 0;
408 m_sbUnitLabel = 0;
409
410 if ( sb ) // No statusbar in e.g. konqueror
411 {
412 m_sbPageLabel = new KStatusBarLabel( TQString(), 0, sb );
413 m_sbPageLabel->setAlignment( AlignLeft | AlignVCenter );
414 addStatusBarItem( m_sbPageLabel, 0 );
415
416 m_sbModifiedLabel = new KStatusBarLabel( " ", 0, sb );
417 m_sbModifiedLabel->setAlignment( AlignLeft | AlignVCenter );
418 addStatusBarItem( m_sbModifiedLabel, 0 );
419
420 m_sbObjectLabel = new KStatusBarLabel( TQString(), 0, sb );
421 m_sbObjectLabel->setAlignment( AlignLeft | AlignVCenter );
422 addStatusBarItem( m_sbObjectLabel, 1 );
423
424 m_sbZoomLabel = new KStatusBarLabel( ' ' + TQString::number( m_pKPresenterDoc->zoomHandler()->zoom() ) + "% ", 0, sb );
425 m_sbZoomLabel->setAlignment( AlignHCenter | AlignVCenter );
426 addStatusBarItem( m_sbZoomLabel, 0 );
427
428 m_sbUnitLabel = new KStatusBarLabel( ' ' + KoUnit::unitDescription( m_pKPresenterDoc->unit() ) + ' ', 0, sb );
429 m_sbUnitLabel->setAlignment( AlignHCenter | AlignVCenter );
430 addStatusBarItem( m_sbUnitLabel, 0 );
431 }
432
433 //when kword is embedded into konqueror apply a zoom=100
434 //in konqueror we can't change zoom -- ### TODO ?
435 if(!m_pKPresenterDoc->isReadWrite())
436 {
437 setZoom( 100, true );
438 slotUpdateRuler();
439 initGui();
440 m_pKPresenterDoc->updateZoomRuler();
441 }
442
443
444 setAcceptDrops( true );
445}
446
447DCOPObject* KPrView::dcopObject()
448{
449 if ( !dcop )
450 dcop = new KPrViewIface( this );
451
452 return dcop;
453}
454
455KPrView::~KPrView()
456{
457 delete m_findReplace;
458 m_findReplace = 0L;
459 if(sidebar) {
460 TDEConfig *config=TDEGlobal::config();
461 config->setGroup("Global");
462 config->writeEntry("Sidebar", sidebar->isVisible());
463 }
464 if(notebar) {
465 TDEConfig *config=TDEGlobal::config();
466 config->setGroup("Global");
467 config->writeEntry("Notebar", notebar->isVisible());
468 }
469 clearSpellChecker();
470
471 delete rb_lbegin;
472 delete rb_lend;
473 delete dcop;
474
475 delete m_sbPageLabel;
476 delete m_sbObjectLabel;
477 delete notebar;
478 delete m_searchEntry;
479 m_searchEntry = 0L;
480 delete m_replaceEntry;
481 m_replaceEntry = 0L;
482 delete m_propertyEditor;
483 delete pgConfDia;
484 delete rotateDia;
485 delete shadowDia;
486 delete afChoose;
487 delete m_fontDlg;
488 delete m_paragDlg;
489 delete m_arrangeObjectsPopup;
490
491 if ( m_specialCharDlg )
492 m_specialCharDlg->closeDialog(); // will call slotSpecialCharDlgClosed
493 delete m_specialCharDlg;
494}
495
496void KPrView::setupPrinter( KPrinter &prt )
497{
498 deSelectAllObjects();
499 m_pKPresenterDoc->recalcVariables( VT_TIME );
500 m_pKPresenterDoc->recalcVariables( VT_DATE );
501 prt.setMinMax( 1, m_pKPresenterDoc->getPageNums() );
502 prt.setFromTo( 1, m_pKPresenterDoc->getPageNums() );
503 prt.setOption( "kde-range", m_pKPresenterDoc->selectedForPrinting() );
504 prt.setPageSelection(KPrinter::ApplicationSide);
505 KoPageLayout layout = m_pKPresenterDoc->pageLayout();
506 prt.setOption( "kde-margin-top", TQString::number(layout.ptTop) );
507 prt.setOption( "kde-margin-bottom", TQString::number(layout.ptBottom) );
508 prt.setOption( "kde-margin-left", TQString::number(layout.ptLeft) );
509 prt.setOption( "kde-margin-right", TQString::number(layout.ptRight) );
510 KoFormat pageFormat = layout.format;
511 prt.setPageSize( static_cast<KPrinter::PageSize>( KoPageFormat::printerPageSize( pageFormat ) ) );
512
513 if ( m_pKPresenterDoc->pageLayout().orientation == PG_LANDSCAPE || pageFormat == PG_SCREEN )
514 prt.setOrientation( KPrinter::Landscape );
515 else
516 prt.setOrientation( KPrinter::Portrait );
517 if ( !prt.previewOnly() )
518 prt.addDialogPage( new KPrPrinterDlg( 0, "KPresenter page" ) );
519}
520
521void KPrView::unZoomDocument(int &dpiX,int &dpiY)
522{
523 // ### HACK: disable zooming-when-printing if embedded parts are used.
524 // No koffice app supports zooming in paintContent currently.
525 // Disable in ALL cases now
526 bool doZoom=false;
527 dpiX = doZoom ? 300 : KoGlobal::dpiX();
528 dpiY = doZoom ? 300 : KoGlobal::dpiY();
529 zoomHandler()->setZoomAndResolution( 100, dpiX, dpiY );
530 m_pKPresenterDoc->newZoomAndResolution( false, true /* for printing*/ );
531}
532
533void KPrView::zoomDocument(int zoom)
534{
535 zoomHandler()->setZoomAndResolution( zoom, KoGlobal::dpiX(), KoGlobal::dpiY() );
536 m_pKPresenterDoc->newZoomAndResolution( false, false );
537 updateRuler();
538}
539
540void KPrView::print( KPrinter &prt )
541{
542 float left_margin = 0.0;
543 float top_margin = 0.0;
544 int dpiX=0;
545 int dpiY=0;
546 int oldZoom = zoomHandler()->zoom();
547 bool displayFieldCode = m_pKPresenterDoc->getVariableCollection()->variableSetting()->displayFieldCode();
548 if ( displayFieldCode )
549 {
550 m_pKPresenterDoc->getVariableCollection()->variableSetting()->setDisplayFieldCode(false);
551 m_pKPresenterDoc->recalcVariables( VT_ALL );
552 }
553
554 TQPaintDeviceMetrics metrics( &prt );
555 unZoomDocument(dpiX,dpiY);
556 if ( m_pKPresenterDoc->pageLayout().format == PG_SCREEN )
557 {
558 left_margin = 28.5;
559 top_margin = 15.0;
560 }
561
562 TQPainter painter;
563 painter.begin( &prt );
564 TQRect rect = m_pKPresenterDoc->pageList().at( 0 )->getZoomPageRect();
565 double zoom = TQMIN( double( metrics.width() ) / double( rect.width() ),
566 double( metrics.height() ) / double( rect.height() ) );
567 double newZoom = zoom * m_pKPresenterDoc->zoomHandler()->zoom();
568 kdDebug(33001) << "KPrView::print newZoom = " << newZoom << endl;
569 setZoom( int( newZoom ), false );
570 TQRect paintingRect = m_pKPresenterDoc->pageList().at( 0 )->getZoomPageRect();
571
572 m_canvas->print( &painter, &prt, left_margin, top_margin );
573 painter.end();
574
575 zoomDocument(oldZoom);
576 if ( displayFieldCode )
577 {
578 m_pKPresenterDoc->getVariableCollection()->variableSetting()->setDisplayFieldCode(true);
579 m_pKPresenterDoc->recalcVariables( VT_ALL );
580 }
581
582 m_canvas->repaint();
583 kdDebug(33001) << "KPrView::print zoom&res reset" << endl;
584 m_pKPresenterDoc->getVariableCollection()->variableSetting()->setLastPrintingDate(TQDateTime::currentDateTime());
585 m_pKPresenterDoc->recalcVariables( VT_DATE );
586}
587
588void KPrView::editCut()
589{
590 if ( !m_canvas->currentTextObjectView() ) {
591 m_canvas->setToolEditMode( TEM_MOUSE );
592#if COPYOASISFORMAT
593 m_canvas->copyOasisObjs();
594#else
595 m_canvas->copyObjs();
596#endif
597 m_canvas->deleteObjs();
598 } else {
599 if ( !m_canvas->currentTextObjectView()->kpTextObject()->isProtectContent())
600 m_canvas->currentTextObjectView()->cut();
601 }
602}
603
604void KPrView::editCopy()
605{
606 if ( !m_canvas->currentTextObjectView() ) {
607 m_canvas->setToolEditMode( TEM_MOUSE );
608#if COPYOASISFORMAT
609 m_canvas->copyOasisObjs();
610#else
611 m_canvas->copyObjs();
612#endif
613 }
614 else
615 m_canvas->currentTextObjectView()->copy();
616}
617
618void KPrView::editPaste()
619{
620 if ( !m_canvas->currentTextObjectView() ) {
621 m_canvas->setToolEditMode( TEM_MOUSE );
622 deSelectAllObjects();
623 TQMimeSource *data = TQApplication::clipboard()->data();
624 if ( data->provides( "text/uri-list" ) )
625 {
626 m_pKPresenterDoc->pastePage( data, currPg );
627 setRanges();
628 skipToPage( currPg );
629 updateSideBarMenu();
630 }
631 else if ( data->provides( KoStoreDrag::mimeType("application/x-kpresenter" ) ))
632 {
633 // TODO: it would be nice to have no offset when pasting onto a different page...
634 m_canvas->activePage()->pasteObjs(
635 data->encodedData(KoStoreDrag::mimeType("application/x-kpresenter")),
636 1, 0.0, 0.0, 0.0, 20.0, 20.0);
637
638 m_canvas->setMouseSelectedObject(true);
639 emit objectSelectedChanged();
640 }
641#if COPYOASISFORMAT
642 else if ( data->provides( KoStoreDrag::mimeType("application/vnd.oasis.opendocument.presentation" ) ))
643 {
644 //TODO : fix me !!
645 // TODO: it would be nice to have no offset when pasting onto a different page...
646 //m_canvas->activePage()->pasteObjs(
647 //data->encodedData(KoStoreDrag::mimeType("application/vnd.oasis.opendocument.presentation")),
648 //1, 0.0, 0.0, 0.0, 20.0, 20.0);
649
650 m_canvas->setMouseSelectedObject(true);
651 emit objectSelectedChanged();
652 }
653#endif
654 else if (TQImageDrag::canDecode (data)) {
655 m_canvas->dropImage( data );
656 }
657 } else {
658 if ( !m_canvas->currentTextObjectView()->kpTextObject()->isProtectContent())
659 m_canvas->currentTextObjectView()->paste();
660 }
661}
662
663void KPrView::editDelete()
664{
665 m_canvas->setToolEditMode( TEM_MOUSE );
666 m_canvas->deleteObjs();
667}
668
669void KPrView::editSelectAll()
670{
671 KPrTextView *edit=m_canvas->currentTextObjectView();
672 if ( !edit ) {
673 m_canvas->setToolEditMode( TEM_MOUSE );
674 m_canvas->selectAllObj();
675 }
676 else
677 edit->selectAll();
678}
679
680void KPrView::editDeSelectAll()
681{
682 KPrTextView *edit=m_canvas->currentTextObjectView();
683 if ( !edit ) {
684 m_canvas->setToolEditMode( TEM_MOUSE );
685 deSelectAllObjects();
686 }
687 else
688 edit->selectAll(false);
689}
690
691void KPrView::editCopyPage()
692{
693 m_pKPresenterDoc->copyPageToClipboard( currPg );
694}
695
696void KPrView::editDuplicatePage()
697{
698 m_pKPresenterDoc->copyPage( currPg );
699 setRanges();
700}
701
702void KPrView::updateSideBarMenu()
703{
704 actionEditDelPage->setEnabled( m_pKPresenterDoc->getPageNums() > 1 );
705}
706
707void KPrView::editDelPage()
708{
709 if ( KMessageBox::warningContinueCancel( this,
710 i18n( "Do you want to remove the current slide?"),i18n("Remove Slide"),KGuiItem(i18n("&Delete"),"edit-delete") )
711 != KMessageBox::Continue )
712 return;
713 m_canvas->exitEditMode();
714 m_pKPresenterDoc->deletePage( currPg );
715 setRanges();
716}
717
718void KPrView::insertPage()
719{
720 InsertPageDia dia( this, 0, true );
721#if COPYOASISFORMAT
722 TQString templ = locateLocal( "data", "kpresenter/default.oop" );
723#else
724 TQString templ = locateLocal( "data", "kpresenter/default.kpr" );
725#endif
726 if ( !TQFile::exists( templ ) ) {
727 dia.radioDifferent->setChecked( true );
728 dia.radioDefault->setEnabled( false );
729 }
730 if ( dia.exec() != TQDialog::Accepted )
731 return;
732
733 if (dia.radioCurrentDefault->isChecked())
734 {
735#if COPYOASISFORMAT
736 TQString file = locateLocal( "data", "kpresenter/default.oop" );
737 m_pKPresenterDoc->savePage( file, currPg, true /*ignore stickies*/ );
738#else
739 TQString file = locateLocal( "data", "kpresenter/default.kpr" );
740 m_pKPresenterDoc->savePage( file, currPg, true /*ignore stickies*/ );
741#endif
742 }
743
744 InsertPos pos = (InsertPos)dia.locationCombo->currentItem();
745 m_pKPresenterDoc->insertNewPage( i18n("Insert new slide"), currPg, pos,
746 dia.radioDifferent->isChecked(), TQString() );
747 setRanges();
748}
749
750void KPrView::insertPicture()
751{
752 m_canvas->setToolEditMode( INS_PICTURE );
753 deSelectAllObjects();
754
755 TQStringList mimetypes;
756 mimetypes += KImageIO::mimeTypes( KImageIO::Reading );
757 mimetypes += KoPictureFilePreview::clipartMimeTypes();
758
759 KFileDialog fd( m_pKPresenterDoc->picturePath(), TQString(), this, 0, true );
760 fd.setCaption( i18n( "Insert Picture" ) );
761 fd.setMimeFilter( mimetypes );
762 fd.setPreviewWidget( new KoPictureFilePreview( &fd ) );
763
764 KURL url;
765 if ( fd.exec() == TQDialog::Accepted )
766 url = fd.selectedURL();
767
768 if( url.isEmpty() || !url.isValid() )
769 {
770 m_canvas->setToolEditMode( TEM_MOUSE, false );
771 return;
772 }
773 TQString file;
774 if ( !TDEIO::NetAccess::download( url, file, this ) )
775 {
776 m_canvas->setToolEditMode( TEM_MOUSE, false );
777 return;
778 }
779
780 if ( !file.isEmpty() )
781 m_canvas->activePage()->setInsPictureFile( file );
782}
783
784void KPrView::insertPicture(const TQString &file)
785{
786 m_canvas->setToolEditMode( INS_PICTURE );
787 deSelectAllObjects();
788
789 if ( !file.isEmpty() )
790 m_canvas->activePage()->setInsPictureFile( file );
791}
792
793void KPrView::savePicture()
794{
795 m_canvas->savePicture();
796}
797
798void KPrView::savePicture( const TQString& oldName, KoPicture& picture)
799{
800 TQString oldFile(oldName);
801 KURL url;
802 url.setPath( oldFile );
803 if (!TQDir(url.directory()).exists())
804 oldFile = url.fileName();
805
806 TQString mimetype=picture.getMimeType();
807 kdDebug(33001) << "Picture has mime type: " << mimetype << endl;
808 TQStringList mimetypes;
809 mimetypes << mimetype;
810
811 KFileDialog fd( oldFile, TQString(), this, 0, true );
812 fd.setMimeFilter( mimetypes );
813 fd.setCaption(i18n("Save Picture"));
814 fd.setOperationMode(KFileDialog::Saving);
815 if ( fd.exec() == TQDialog::Accepted )
816 {
817 url = fd.selectedURL();
818 if ( url.isValid() )
819 {
820 if ( url.isLocalFile() )
821 {
822 TQFile file( url.path() );
823 if ( file.open( IO_ReadWrite ) )
824 {
825 picture.save( &file );
826 file.close();
827 }
828 else
829 {
830 KMessageBox::error(this,
831 i18n("Error during saving: could not open '%1' for writing.").arg ( url.path() ),
832 i18n("Save Picture"));
833 }
834 }
835 else
836 {
837 KTempFile tempFile;
838 tempFile.setAutoDelete( true );
839 if ( tempFile.status() == 0 )
840 {
841 TQFile file( tempFile.name() );
842 if ( file.open( IO_ReadWrite ) )
843 {
844 picture.save( &file );
845 file.close();
846 if ( !TDEIO::NetAccess::upload( tempFile.name(), url, this ) )
847 {
848 KMessageBox::sorry( this, i18n(
849 "Unable to save the file to '%1'. %2.").arg( url.prettyURL() ).arg( TDEIO::NetAccess::lastErrorString() ),
850 i18n("Save Failed") );
851 }
852 }
853 else
854 KMessageBox::error(this,
855 i18n("Error during saving: could not open '%1' temporary file for writing.").arg ( file.name() ),
856 i18n("Save Picture"));
857 }
858 else
859 KMessageBox::sorry( this, i18n(
860 "Error during saving: could not create temporary file: %1.").arg( strerror( tempFile.status() ) ),
861 i18n("Save Picture") );
862 }
863 }
864 }
865}
866
867void KPrView::savePicture( KPrPixmapObject* obj )
868{
869 TQString oldFile=obj->getFileName();
870 KoPicture picture(obj->picture());
871 savePicture(oldFile, picture);
872}
873
874void KPrView::toolsMouse()
875{
876 if ( actionToolsMouse->isChecked() )
877 m_canvas->setToolEditMode( TEM_MOUSE, false );
878 else
879 actionToolsMouse->setChecked(true);
880 //deSelectAllObjects();
881}
882
883void KPrView::toolsRotate()
884{
885 if ( actionToolsRotate->isChecked() )
886 m_canvas->setToolEditMode( TEM_ROTATE, false );
887 else
888 actionToolsRotate->setChecked(true);
889}
890
891void KPrView::toolsZoom()
892{
893 if ( actionToolsZoom->isChecked() )
894 m_canvas->setToolEditMode( TEM_ZOOM, false );
895 else
896 actionToolsZoom->setChecked(true);
897}
898
899void KPrView::toolsLinePopup()
900{
901 switch (m_currentLineTool)
902 {
903 case LtLine:
904 actionToolsLine->activate();
905 break;
906 case LtFreehand:
907 actionToolsFreehand->activate();
908 break;
909 case LtPolyline:
910 actionToolsPolyline->activate();
911 break;
912 case LtQuadricBezier:
913 actionToolsQuadricBezierCurve->activate();
914 break;
915 case LtCubicBezier:
916 actionToolsCubicBezierCurve->activate();
917 break;
918 }
919}
920
921void KPrView::toolsLine()
922{
923 if ( actionToolsLine->isChecked() )
924 {
925 m_canvas->setToolEditMode( INS_LINE, false );
926 deSelectAllObjects();
927 m_currentLineTool = LtLine;
928 actionToolsLinePopup->setIcon("line");
929 }
930 else
931 actionToolsLine->setChecked(true);
932}
933
934void KPrView::toolsShapePopup()
935{
936 switch (m_currentShapeTool)
937 {
938 case StRectangle:
939 actionToolsRectangle->activate();
940 break;
941 case StCircle:
942 actionToolsCircleOrEllipse->activate();
943 break;
944 case StPie:
945 actionToolsPie->activate();
946 break;
947 case StPolygon:
948 actionToolsConvexOrConcavePolygon->activate();
949 break;
950 }
951}
952
953void KPrView::toolsRectangle()
954{
955 if ( actionToolsRectangle->isChecked() )
956 {
957 deSelectAllObjects();
958 m_canvas->setToolEditMode( INS_RECT, false );
959 m_currentShapeTool = StRectangle;
960 actionToolsShapePopup->setIcon("rectangle");
961 }
962 else
963 actionToolsRectangle->setChecked(true);
964}
965
966void KPrView::toolsCircleOrEllipse()
967{
968 if ( actionToolsCircleOrEllipse->isChecked() )
969 {
970 deSelectAllObjects();
971 m_canvas->setToolEditMode( INS_ELLIPSE, false );
972 m_currentShapeTool = StCircle;
973 actionToolsShapePopup->setIcon("circle");
974 }
975 else
976 actionToolsCircleOrEllipse->setChecked(true);
977}
978
979void KPrView::toolsPie()
980{
981 if ( actionToolsPie->isChecked() )
982 {
983 deSelectAllObjects();
984 m_canvas->setToolEditMode( INS_PIE, false );
985 m_currentShapeTool = StPie;
986 actionToolsShapePopup->setIcon("pie");
987 }
988 else
989 actionToolsPie->setChecked(true);
990}
991
992void KPrView::toolsDiagramm()
993{
994 if ( actionToolsDiagramm->isChecked() )
995 {
996 deSelectAllObjects();
997 m_canvas->setToolEditMode( INS_DIAGRAMM, false );
998
999 KoDocumentEntry entry = KoDocumentEntry::queryByMimeType( "application/x-kchart" );
1000 if (entry.isEmpty())
1001 {
1002 KMessageBox::sorry( this, i18n( "No chart component registered" ) );
1003 m_canvas->setToolEditMode( TEM_MOUSE );
1004 }
1005 else
1006 m_canvas->setPartEntry( entry );
1007 }
1008 else
1009 actionToolsDiagramm->setChecked(true);
1010}
1011
1012void KPrView::toolsTable()
1013{
1014 if ( actionToolsTable->isChecked() )
1015 {
1016 deSelectAllObjects();
1017 m_canvas->setToolEditMode( INS_TABLE, false );
1018
1019 KoDocumentEntry entry = KoDocumentEntry::queryByMimeType( "application/x-kspread" );
1020 if (entry.isEmpty())
1021 {
1022 KMessageBox::sorry( this, i18n( "No table component registered" ) );
1023 m_canvas->setToolEditMode( TEM_MOUSE );
1024 }
1025 else
1026 m_canvas->setPartEntry( entry );
1027 }
1028 else
1029 actionToolsTable->setChecked(true);
1030}
1031
1032void KPrView::toolsFormula()
1033{
1034 if ( actionToolsFormula->isChecked() )
1035 {
1036 deSelectAllObjects();
1037 m_canvas->setToolEditMode( INS_FORMULA, false );
1038
1039 KoDocumentEntry entry = KoDocumentEntry::queryByMimeType( "application/x-kformula" );
1040 if (entry.isEmpty())
1041 {
1042 KMessageBox::sorry( this, i18n( "No formula component registered" ) );
1043 m_canvas->setToolEditMode( TEM_MOUSE );
1044 }
1045 else
1046 m_canvas->setPartEntry( entry );
1047 }
1048 else
1049 actionToolsFormula->setChecked(true);
1050}
1051
1052void KPrView::toolsText()
1053{
1054 if ( actionToolsText->isChecked() )
1055 {
1056 deSelectAllObjects();
1057 m_canvas->setToolEditMode( INS_TEXT, false );
1058 }
1059 else
1060 actionToolsText->setChecked(true);
1061}
1062
1063void KPrView::toolsAutoform()
1064{
1065 if ( actionToolsAutoform->isChecked() )
1066 {
1067 deSelectAllObjects();
1068 m_canvas->setToolEditMode( TEM_MOUSE, false );
1069 if ( afChoose ) {
1070 delete afChoose;
1071 afChoose = 0;
1072 }
1073 afChoose = new AFChoose( this, i18n( "Autoform-Choose" ) );
1074 afChoose->resize( 400, 300 );
1075 afChoose->setCaption( i18n( "Insert Autoform" ) );
1076
1077 TQObject::connect( afChoose, TQ_SIGNAL( formChosen( const TQString & ) ),
1078 this, TQ_SLOT( afChooseOk( const TQString & ) ) );
1079 TQObject::connect( afChoose, TQ_SIGNAL( afchooseCanceled()),
1080 this, TQ_SLOT(slotAfchooseCanceled()));
1081 afChoose->exec();
1082
1083 TQObject::disconnect( afChoose, TQ_SIGNAL( formChosen( const TQString & ) ),
1084 this, TQ_SLOT( afChooseOk( const TQString & ) ) );
1085 delete afChoose;
1086 afChoose = 0;
1087 }
1088 else
1089 actionToolsAutoform->setChecked(true);
1090}
1091
1092void KPrView::toolsObject()
1093{
1094 KoDocumentEntry pe = actionToolsObject->documentEntry();
1095 if ( pe.isEmpty() ) {
1096 m_canvas->setToolEditMode( TEM_MOUSE );
1097 return;
1098 }
1099
1100 m_canvas->setToolEditMode( INS_OBJECT );
1101 m_canvas->setPartEntry( pe );
1102}
1103
1104void KPrView::toolsFreehand()
1105{
1106 if ( actionToolsFreehand->isChecked() ) {
1107 m_canvas->setToolEditMode( INS_FREEHAND, false );
1108 deSelectAllObjects();
1109 m_currentLineTool = LtFreehand;
1110 actionToolsLinePopup->setIcon("freehand");
1111 }
1112 else
1113 actionToolsFreehand->setChecked(true);
1114}
1115
1116void KPrView::toolsPolyline()
1117{
1118 if ( actionToolsPolyline->isChecked() ) {
1119 m_canvas->setToolEditMode( INS_POLYLINE, false );
1120 deSelectAllObjects();
1121 m_currentLineTool = LtPolyline;
1122 actionToolsLinePopup->setIcon("polyline");
1123 }
1124 else
1125 actionToolsPolyline->setChecked(true);
1126}
1127
1128void KPrView::toolsQuadricBezierCurve()
1129{
1130 if ( actionToolsQuadricBezierCurve->isChecked() ) {
1131 m_canvas->setToolEditMode( INS_QUADRICBEZIERCURVE, false );
1132 deSelectAllObjects();
1133 m_currentLineTool = LtQuadricBezier;
1134 actionToolsLinePopup->setIcon("quadricbeziercurve");
1135 }
1136 else
1137 actionToolsQuadricBezierCurve->setChecked(true);
1138}
1139
1140void KPrView::toolsCubicBezierCurve()
1141{
1142 if ( actionToolsCubicBezierCurve->isChecked() ) {
1143 m_canvas->setToolEditMode( INS_CUBICBEZIERCURVE, false );
1144 deSelectAllObjects();
1145 m_currentLineTool = LtCubicBezier;
1146 actionToolsLinePopup->setIcon("cubicbeziercurve");
1147 }
1148 else
1149 actionToolsCubicBezierCurve->setChecked(true);
1150}
1151
1152void KPrView::toolsConvexOrConcavePolygon()
1153{
1154 if ( actionToolsConvexOrConcavePolygon->isChecked() ) {
1155 m_canvas->setToolEditMode( INS_POLYGON, false );
1156 deSelectAllObjects();
1157 m_currentShapeTool = StPolygon;
1158 actionToolsShapePopup->setIcon("polygon");
1159 }
1160 else
1161 actionToolsConvexOrConcavePolygon->setChecked(true);
1162}
1163
1164void KPrView::toolsClosedLinePopup()
1165{
1166 switch (m_currentClosedLineTool)
1167 {
1168 case CltFreehand:
1169 actionToolsClosedFreehand->activate();
1170 break;
1171 case CltPolyline:
1172 actionToolsClosedPolyline->activate();
1173 break;
1174 case CltQuadricBezier:
1175 actionToolsClosedQuadricBezierCurve->activate();
1176 break;
1177 case CltCubicBezier:
1178 actionToolsClosedCubicBezierCurve->activate();
1179 break;
1180 }
1181}
1182
1183void KPrView::toolsClosedFreehand()
1184{
1185 if ( actionToolsClosedFreehand->isChecked() ) {
1186 m_canvas->setToolEditMode( INS_CLOSED_FREEHAND, false );
1187 deSelectAllObjects();
1188 m_currentClosedLineTool = CltFreehand;
1189 actionToolsClosedLinePopup->setIcon("closed_freehand");
1190 }
1191 else
1192 actionToolsClosedFreehand->setChecked( true );
1193}
1194
1195void KPrView::toolsClosedPolyline()
1196{
1197 if ( actionToolsClosedPolyline->isChecked() ) {
1198 m_canvas->setToolEditMode( INS_CLOSED_POLYLINE, false );
1199 deSelectAllObjects();
1200 m_currentClosedLineTool = CltPolyline;
1201 actionToolsClosedLinePopup->setIcon("closed_polyline");
1202 }
1203 else
1204 actionToolsClosedPolyline->setChecked( true );
1205}
1206
1207void KPrView::toolsClosedQuadricBezierCurve()
1208{
1209 if ( actionToolsClosedQuadricBezierCurve->isChecked() ) {
1210 m_canvas->setToolEditMode( INS_CLOSED_QUADRICBEZIERCURVE, false );
1211 deSelectAllObjects();
1212 m_currentClosedLineTool = CltQuadricBezier;
1213 actionToolsClosedLinePopup->setIcon("closed_quadricbeziercurve");
1214 }
1215 else
1216 actionToolsClosedQuadricBezierCurve->setChecked( true );
1217}
1218
1219void KPrView::toolsClosedCubicBezierCurve()
1220{
1221 if ( actionToolsClosedCubicBezierCurve->isChecked() ) {
1222 m_canvas->setToolEditMode( INS_CLOSED_CUBICBEZIERCURVE, false );
1223 deSelectAllObjects();
1224 m_currentClosedLineTool = CltCubicBezier;
1225 actionToolsClosedLinePopup->setIcon("closed_cubicbeziercurve");
1226 }
1227 else
1228 actionToolsClosedCubicBezierCurve->setChecked( true );
1229}
1230
1231void KPrView::extraProperties()
1232{
1233 m_canvas->setToolEditMode( TEM_MOUSE );
1234
1235 m_propertyEditor = new KPrPropertyEditor( this, "KPrPropertyEditor", m_canvas->activePage(), m_pKPresenterDoc );
1236 m_propertyEditor->setCaption( i18n( "Properties" ) );
1237
1238 connect( m_propertyEditor, TQ_SIGNAL( propertiesOk() ), this, TQ_SLOT( propertiesOk() ) );
1239 m_propertyEditor->exec();
1240 disconnect( m_propertyEditor, TQ_SIGNAL( propertiesOk() ), this, TQ_SLOT( propertiesOk() ) );
1241
1242 delete m_propertyEditor;
1243 m_propertyEditor = 0;
1244}
1245
1246void KPrView::extraRaise()
1247{
1248 m_canvas->setToolEditMode( TEM_MOUSE );
1249 m_canvas->raiseObjs( true );
1250}
1251
1252void KPrView::extraLower()
1253{
1254 m_canvas->setToolEditMode( TEM_MOUSE );
1255 m_canvas->lowerObjs( true );
1256}
1257
1258void KPrView::extraRotate()
1259{
1260 if ( m_canvas->numberOfObjectSelected() > 0 ) {
1261 if ( !rotateDia ) {
1262 rotateDia = new KPrRotationDialogImpl( this );
1263 connect( rotateDia, TQ_SIGNAL( apply() ), this, TQ_SLOT( rotateOk() ) );
1264 }
1265 rotateDia->setAngle( m_canvas->getSelectedObj()->getAngle() );
1266 m_canvas->setToolEditMode( TEM_MOUSE );
1267 rotateDia->exec();
1268 }
1269}
1270
1271void KPrView::extraShadow()
1272{
1273 if ( m_canvas->numberOfObjectSelected() > 0 ) {
1274
1275 if ( !shadowDia ) {
1276 shadowDia = new KPrShadowDialogImpl( this );
1277 shadowDia->resize( shadowDia->minimumSize() );
1278 connect( shadowDia, TQ_SIGNAL( apply() ), this, TQ_SLOT( shadowOk() ) );
1279 }
1280
1281 KPrObject *object=m_canvas->getSelectedObj();
1282 shadowDia->setShadowDirection( object->getShadowDirection() );
1283 if ( object->getShadowDistance() != 0 )
1284 shadowDia->setShadowDistance( object->getShadowDistance() );
1285 else
1286 shadowDia->setShadowDistance( 3 );
1287
1288 shadowDia->setShadowColor( object->getShadowColor() );
1289 m_canvas->setToolEditMode( TEM_MOUSE );
1290 shadowDia->exec();
1291 }
1292}
1293
1294void KPrView::extraBackground()
1295{
1296 KPrPage *page=m_canvas->activePage();
1297 KPrBackDialog* backDia = new KPrBackDialog( this, "InfoDia", page->getBackType( ),
1298 page->getBackColor1( ),
1299 page->getBackColor2( ),
1300 page->getBackColorType( ),
1301 page->getBackPicture( ),
1302 page->getBackView(),
1303 page->getBackUnbalanced(),
1304 page->getBackXFactor(),
1305 page->getBackYFactor( ),
1306 page );
1307 backDia->setCaption( i18n( "Slide Background" ) );
1308 TQObject::connect( backDia, TQ_SIGNAL( backOk( KPrBackDialog*, bool ) ), this, TQ_SLOT( backOk( KPrBackDialog*, bool ) ) ) ;
1309 backDia->exec();
1310
1311 TQObject::disconnect( backDia, TQ_SIGNAL( backOk( KPrBackDialog*, bool ) ), this, TQ_SLOT( backOk( KPrBackDialog*, bool ) ) );
1312 delete backDia;
1313}
1314
1315void KPrView::extraLayout()
1316{
1317 KoPageLayout pgLayout = m_pKPresenterDoc->pageLayout();
1318 KoPageLayout oldLayout = pgLayout;
1319 KoHeadFoot hf;
1320 KoUnit::Unit oldUnit = m_pKPresenterDoc->unit();
1321 KoUnit::Unit unit = oldUnit;
1322
1323 if ( KoPageLayoutDia::pageLayout( pgLayout, hf, FORMAT_AND_BORDERS, unit, this ) ) {
1324 KPrPgLayoutCmd *pgLayoutCmd = new KPrPgLayoutCmd( i18n( "Set Page Layout" ),
1325 pgLayout, oldLayout, oldUnit, unit,kPresenterDoc() );
1326 pgLayoutCmd->execute();
1327 kPresenterDoc()->addCommand( pgLayoutCmd );
1328 updateRuler();
1329 }
1330}
1331
1332void KPrView::extraConfigure()
1333{
1334 KPrConfig configDia( this );
1335 configDia.exec();
1336}
1337
1338void KPrView::extraCreateTemplate()
1339{
1340 int width = 60;
1341 int height = 60;
1342 TQPixmap pix = m_pKPresenterDoc->generatePreview(TQSize(width, height));
1343#if COPYOASISFORMAT
1344 KTempFile tempFile( TQString(), ".otp" );
1345 tempFile.setAutoDelete( true );
1346 m_pKPresenterDoc->savePage( tempFile.name(), getCurrPgNum() - 1);
1347#else
1348 KTempFile tempFile( TQString(), ".kpt" );
1349 tempFile.setAutoDelete( true );
1350 m_pKPresenterDoc->savePage( tempFile.name(), getCurrPgNum() - 1);
1351#endif
1352
1353 KoTemplateCreateDia::createTemplate( "kpresenter_template", KPrFactory::global(),
1354 tempFile.name(), pix, this);
1355 KPrFactory::global()->dirs()->addResourceType("kpresenter_template",
1356 TDEStandardDirs::kde_default( "data" ) +
1357 "kpresenter/templates/");
1358}
1359
1360void KPrView::extraDefaultTemplate()
1361{
1362#if COPYOASISFORMAT
1363 TQString file = locateLocal( "data", "kpresenter/default.oop" );
1364 m_pKPresenterDoc->savePage( file, currPg );
1365#else
1366 TQString file = locateLocal( "data", "kpresenter/default.kpr" );
1367 m_pKPresenterDoc->savePage( file, currPg );
1368#endif
1369}
1370
1371void KPrView::extraWebPres()
1372{
1373 if ( !allowWebPres )
1374 return;
1375
1376 KURL url;
1377 TQString config = TQString();
1378 int ret =KMessageBox::questionYesNoCancel( this,
1379 i18n( "Do you want to load a previously saved configuration"
1380 " which will be used for this HTML Presentation?" ),
1381 i18n( "Create HTML Presentation" ) );
1382 if( ret == KMessageBox::Cancel )
1383 return;
1384 else if ( ret == KMessageBox::Yes )
1385 {
1386 url = KFileDialog::getOpenURL( TQString(), i18n("*.kpweb|KPresenter HTML Presentation (*.kpweb)"), this );
1387
1388 if( url.isEmpty() )
1389 return;
1390
1391 if( !url.isLocalFile() )
1392 {
1393 KMessageBox::sorry( this, i18n( "Only local files are currently supported." ) );
1394 return;
1395 }
1396
1397 config = url.path();
1398 }
1399
1400 KPrWebPresentationWizard::createWebPresentation( config, m_pKPresenterDoc, this );
1401}
1402
1403void KPrView::extraMSPres()
1404{
1405 if ( !allowMSPres )
1406 return;
1407
1408 KPrMSPresentationSetup::createMSPresentation( m_pKPresenterDoc, this );
1409}
1410
1411void KPrView::extraLineBegin()
1412{
1413 m_canvas->setToolEditMode( TEM_MOUSE );
1414 TQPoint pnt( TQCursor::pos() );
1415 rb_lbegin->popup( pnt );
1416}
1417
1418void KPrView::extraLineEnd()
1419{
1420 m_canvas->setToolEditMode( TEM_MOUSE );
1421 TQPoint pnt( TQCursor::pos() );
1422 rb_lend->popup( pnt );
1423}
1424
1425void KPrView::extraGroup()
1426{
1427 m_canvas->setToolEditMode( TEM_MOUSE );
1428 m_canvas->groupObjects();
1429 objectSelectedChanged();
1430}
1431
1432void KPrView::extraUnGroup()
1433{
1434 m_canvas->setToolEditMode( TEM_MOUSE );
1435 m_canvas->ungroupObjects();
1436 objectSelectedChanged();
1437}
1438
1439void KPrView::extraPenStyle( int newStyle )
1440{
1441 m_canvas->setToolEditMode( TEM_MOUSE );
1442 setExtraPenStyle(static_cast<TQt::PenStyle>(newStyle));
1443}
1444
1445void KPrView::extraPenWidth( double newWidth )
1446{
1447 m_canvas->setToolEditMode( TEM_MOUSE );
1448 setExtraPenWidth( newWidth );
1449}
1450
1451void KPrView::screenConfigPages()
1452{
1453 delete pgConfDia;
1454 pgConfDia = new KPrPgConfDia( this, kPresenterDoc() );
1455 pgConfDia->setCaption( i18n( "Configure Slide Show" ) );
1456 TQObject::connect( pgConfDia, TQ_SIGNAL( pgConfDiaOk() ), this, TQ_SLOT( pgConfOk() ) );
1457 pgConfDia->exec();
1458
1459 TQObject::disconnect( pgConfDia, TQ_SIGNAL( pgConfDiaOk() ), this, TQ_SLOT( pgConfOk() ) );
1460 delete pgConfDia;
1461 pgConfDia = 0;
1462}
1463
1464
1465void KPrView::screenTransEffect()
1466{
1467 KPrSlideTransitionDia transitionDia( this, "slideTransitionDialog", this );
1468 transitionDia.exec();
1469}
1470
1471void KPrView::screenAssignEffect()
1472{
1473 m_canvas->setToolEditMode( TEM_MOUSE );
1474
1475 TQPtrList<KPrObject> objs;
1476 if ( m_canvas->canAssignEffect( objs ) ) {
1477 KPrEffectDia *effectDia = new KPrEffectDia( this, "Object Effect", objs, this );
1478 effectDia->setCaption( i18n( "Object Effect" ) );
1479 effectDia->exec(); //the dialog executes the command itself
1480 delete effectDia;
1481 }
1482}
1483
1484void KPrView::screenStart()
1485{
1486 startScreenPres( getCurrPgNum() );
1487}
1488
1489void KPrView::screenStartFromFirst()
1490{
1491 startScreenPres( 1 );
1492}
1493
1494void KPrView::startScreenPres( int pgNum /*1-based*/ )
1495{
1496 // no slide is selected ?
1497 if( !kPresenterDoc()->displaySelectedSlides().count() )
1498 {
1499 KMessageBox::sorry( this, i18n("You didn't select any slide." ),
1500 i18n("No Slide") );
1501 return;
1502 }
1503
1504 m_canvas->setToolEditMode( TEM_MOUSE );
1505
1506 if ( m_canvas && !presStarted ) {
1507 const TQString xdgScreenSaver = TDEStandardDirs::findExe("xdg-screensaver");
1508 if (!xdgScreenSaver.isEmpty()) {
1509 TDEProcess proc;
1510 proc << xdgScreenSaver;
1511 proc << "suspend";
1512 proc << TQString::number( topLevelWidget()->winId() );
1513 kdDebug() << k_funcinfo << proc.args() << endl;
1514 proc.start( TDEProcess::DontCare );
1515 } else {
1516 TQByteArray data;
1517 TQByteArray replyData;
1518 TQCString replyType;
1519 m_screenSaverWasEnabled = false;
1520 // is screensaver enabled?
1521 if (kapp->dcopClient()->call("kdesktop", "KScreensaverIface", "isEnabled()", data, replyType, replyData)
1522 && replyType=="bool")
1523 {
1524 TQDataStream replyArg(replyData, IO_ReadOnly);
1525 replyArg >> m_screenSaverWasEnabled;
1526 kdDebug() << "Screensaver was enabled:" << m_screenSaverWasEnabled << endl;
1527 if ( m_screenSaverWasEnabled )
1528 {
1529 // disable screensaver
1530 TQDataStream arg(data, IO_WriteOnly);
1531 arg << false;
1532 if (!kapp->dcopClient()->send("kdesktop", "KScreensaverIface", "enable(bool)", data))
1533 kdWarning(33001) << "Couldn't disable screensaver (using dcop to kdesktop)!" << endl;
1534 else
1535 kdDebug(33001) << "Screensaver successfully disabled" << endl;
1536 }
1537 } else {
1538 kdWarning(33001) << "Couldn't check screensaver (using dcop to kdesktop)!" << endl;
1539 }
1540 // is DPMS enabled?
1541 m_dpmsWasEnabled = isDPMSEnabled();
1542 kdDebug() << "DPMS was enabled:" << m_dpmsWasEnabled << endl;
1543 if ( m_dpmsWasEnabled ) {
1544 enableDPMS( false );
1545 }
1546 }
1547
1548 deSelectAllObjects();
1549 presStarted = true;
1550 m_autoPresRestart = false;
1551 TQRect desk = TDEGlobalSettings::desktopGeometry(this);
1552 kdDebug(33001) << "KPrView::startScreenPres desk=" << desk << endl;
1553 TQRect pgRect = kPresenterDoc()->pageList().at(0)->getZoomPageRect();
1554 kdDebug(33001) << "KPrView::startScreenPres pgRect=" << pgRect << endl;
1555
1556 double zoomX = static_cast<double>( desk.width() ) / (double)pgRect.width();
1557 double zoomY = static_cast<double>( desk.height() ) / (double)pgRect.height();
1558 kdDebug(33001) << "KPrView::startScreenPres zoomX=" << zoomX << " zoomY=" << zoomY << endl;
1559
1560 xOffsetSaved = canvasXOffset();
1561 yOffsetSaved = canvasYOffset();
1562 setCanvasXOffset( 0 );
1563 setCanvasYOffset( 0 );
1564
1565 m_bDisplayFieldCode = m_pKPresenterDoc->getVariableCollection()->variableSetting()->displayFieldCode();
1566 if ( m_bDisplayFieldCode )
1567 {
1568 m_pKPresenterDoc->getVariableCollection()->variableSetting()->setDisplayFieldCode(false);
1569 m_pKPresenterDoc->recalcVariables( VT_ALL );
1570 }
1571
1572 vert->setEnabled( false );
1573 horz->setEnabled( false );
1574 m_bShowGUI = false;
1575 m_canvas->reparent( ( TQWidget* )0L, 0, TQPoint( 0, 0 ), false );
1576 m_canvas->setPaletteBackgroundColor( TQt::white );
1577 m_canvas->showFullScreen();
1578 m_canvas->setFocusPolicy( TQWidget::StrongFocus );
1579
1580 if ( !kPresenterDoc()->spManualSwitch() )
1581 {
1582 m_autoPresStop = false;
1583 m_pKPresenterDoc->repaint( false );
1584
1585 if ( ! m_autoPresTimerConnected ) {
1586 connect( &m_autoPresTimer, TQ_SIGNAL( timeout() ), TQ_SLOT( doAutomaticScreenPres() ) );
1587 m_autoPresTimerConnected = true;
1588 }
1589 }
1590
1591 m_canvas->startScreenPresentation( zoomX, zoomY, pgNum );
1592
1593 actionScreenStart->setEnabled( false );
1594
1595 if ( kPresenterDoc()->presentationDuration() ) {
1596 m_duration.start();
1597
1598 // ### make m_presentationDurationList a TQMemArray or TQValueVector
1599 for ( unsigned int i = 0; i < kPresenterDoc()->pageList().count(); ++i )
1600 m_presentationDurationList.append( 0 ); // initialization
1601 }
1602 }
1603}
1604
1605void KPrView::screenStop()
1606{
1607 if ( presStarted ) {
1608 m_autoPresStop = true;
1609 m_canvas->stopSound();
1610 m_canvas->showNormal();
1611 m_canvas->hide();
1612 m_canvas->reparent( pageBase, 0, TQPoint( 0, 0 ), true );
1613 m_canvas->lower();
1614 setCanvasXOffset( xOffsetSaved );
1615 setCanvasYOffset( yOffsetSaved );
1616
1617 if ( m_bDisplayFieldCode )
1618 {
1619 m_pKPresenterDoc->getVariableCollection()->variableSetting()->setDisplayFieldCode(true);
1620 m_pKPresenterDoc->recalcVariables( VT_ALL );
1621 }
1622
1623 m_canvas->stopScreenPresentation();
1624 presStarted = false;
1625 vert->setEnabled( true );
1626 horz->setEnabled( true );
1627 m_bShowGUI = true;
1628 m_canvas->setMouseTracking( true );
1629 m_canvas->setBackgroundMode( TQt::NoBackground );
1630
1631 const TQString xdgScreenSaver = TDEStandardDirs::findExe("xdg-screensaver");
1632 if (!xdgScreenSaver.isEmpty()) {
1633 TDEProcess proc;
1634 proc << xdgScreenSaver;
1635 proc << "resume";
1636 proc << TQString::number( topLevelWidget()->winId() );
1637 kdDebug() << k_funcinfo << proc.args() << endl;
1638 proc.start( TDEProcess::DontCare );
1639 } else {
1640 if ( m_screenSaverWasEnabled )
1641 {
1642 // start screensaver again
1643 TQByteArray data;
1644 TQDataStream arg(data, IO_WriteOnly);
1645 arg << true;
1646 if (!kapp->dcopClient()->send("kdesktop", "KScreensaverIface", "enable(bool)", data))
1647 kdWarning(33001) << "Couldn't re-enabled screensaver (using dcop to kdesktop)" << endl;
1648 }
1649 if ( m_dpmsWasEnabled )
1650 {
1651 // re-enable DPMS
1652 kdDebug(33001) << "Re-enabling DPMS" << endl;
1653 enableDPMS( true );
1654 }
1655 }
1656
1657 actionScreenStart->setEnabled( true );
1658 pageBase->resizeEvent( 0 );
1659
1660 if ( kPresenterDoc()->presentationDuration() && !m_presentationDurationList.isEmpty() ) {
1661 openThePresentationDurationDialog();
1662 m_presentationDurationList.clear();
1663 }
1664 }
1665 emit presentationFinished();
1666}
1667
1668void KPrView::screenPause()
1669{
1670}
1671
1672void KPrView::screenFirst()
1673{
1674 m_canvas->deSelectAllObj();
1675
1676 if ( !presStarted )
1677 skipToPage( 0 );
1678 else
1679 gotoPresPage( 1 );
1680}
1681
1682void KPrView::screenPrev( bool gotoPreviousPage )
1683{
1684 if ( m_canvas->currentTextObjectView() )
1685 return;
1686
1687 if ( presStarted ) {
1688 m_canvas->pPrev( gotoPreviousPage );
1689 m_canvas->setFocus();
1690 }
1691 else
1692 prevPage();
1693}
1694
1695void KPrView::screenNext( bool gotoNextPage )
1696{
1697 if ( m_canvas->currentTextObjectView() )
1698 return;
1699 if ( presStarted )
1700 {
1701 m_canvas->pNext( gotoNextPage );
1702 m_canvas->setFocus();
1703 }
1704 else
1705 {
1706 nextPage();
1707 }
1708}
1709
1710void KPrView::screenLast()
1711{
1712 m_canvas->deSelectAllObj();
1713
1714 if ( !presStarted )
1715 skipToPage( m_pKPresenterDoc->getPageNums() - 1 );
1716 else
1717 gotoPresPage( getNumPresPages() );
1718}
1719
1720void KPrView::screenSkip()
1721{
1722}
1723
1724void KPrView::sizeSelected( int size )
1725{
1726 tbFont.setPointSize( size );
1727 m_canvas->setTextPointSize( size );
1728 m_canvas->setFocus();
1729}
1730
1731void KPrView::fontSelected( const TQString &fontFamily )
1732{
1733 tbFont.setFamily( fontFamily );
1734 m_canvas->setTextFamily( fontFamily );
1735 m_canvas->setFocus();
1736}
1737
1738void KPrView::textBold()
1739{
1740 bool b=actionTextBold->isChecked();
1741 tbFont.setBold( b );
1742 m_canvas->setTextBold(b );
1743}
1744
1745
1746void KPrView::textStrikeOut()
1747{
1748 bool b=actionFormatStrikeOut->isChecked();
1749 tbFont.setStrikeOut( b );
1750 m_canvas->setTextStrikeOut( b );
1751}
1752
1753void KPrView::textItalic()
1754{
1755 bool b=actionTextItalic->isChecked();
1756 tbFont.setItalic( b );
1757 m_canvas->setTextItalic( b );
1758}
1759
1760void KPrView::textUnderline()
1761{
1762 bool b=actionTextUnderline->isChecked();
1763 tbFont.setUnderline( b );
1764 m_canvas->setTextUnderline( b );
1765}
1766
1767void KPrView::textColor()
1768{
1769 tbColor = actionTextColor->color();
1770 m_canvas->setTextColor( tbColor );
1771}
1772
1773void KPrView::textAlignLeft()
1774{
1775 if ( actionTextAlignLeft->isChecked() )
1776 {
1777 tbAlign = TQt::AlignLeft;
1778 m_canvas->setTextAlign( tbAlign );
1779 }
1780 else
1781 actionTextAlignLeft->setChecked(true);
1782}
1783
1784void KPrView::textAlignCenter()
1785{
1786 if ( actionTextAlignCenter->isChecked() )
1787 {
1788 tbAlign = TQt::AlignHCenter;
1789 m_canvas->setTextAlign(tbAlign);
1790 }
1791 else
1792 actionTextAlignCenter->setChecked(true);
1793}
1794
1795void KPrView::textAlignRight()
1796{
1797 if ( actionTextAlignRight->isChecked() )
1798 {
1799 tbAlign = TQt::AlignRight;
1800 m_canvas->setTextAlign(tbAlign);
1801 }
1802 else
1803 actionTextAlignRight->setChecked(true);
1804
1805}
1806
1807void KPrView::textAlignBlock()
1808{
1809 if ( actionTextAlignBlock->isChecked() )
1810 {
1811 tbAlign = TQt::AlignJustify;
1812 m_canvas->setTextAlign(tbAlign);
1813 }
1814 else
1815 actionTextAlignBlock->setChecked(true);
1816
1817}
1818
1819void KPrView::textInsertPageNum()
1820{
1821 KPrTextView *edit=m_canvas->currentTextObjectView();
1822 if ( edit )
1823 edit->insertVariable( VT_PGNUM, KoPageVariable::VST_PGNUM_CURRENT );
1824}
1825
1826void KPrView::mtextFont()
1827{
1828 KoTextFormatInterface* textIface = m_canvas->applicableTextInterfaces().first();
1829 TQColor col;
1830 if (textIface)
1831 col = textIface->textBackgroundColor();
1832 col = col.isValid() ? col : TQApplication::palette().color( TQPalette::Active, TQColorGroup::Base );
1833
1834 delete m_fontDlg;
1835
1836 m_fontDlg = new KoFontDia( *textIface->currentFormat()
1837 , m_broker
1838 , this, 0 );
1839
1840 connect( m_fontDlg, TQ_SIGNAL( applyFont() ),
1841 this, TQ_SLOT( slotApplyFont() ) );
1842 m_fontDlg->exec();
1843
1844 delete m_fontDlg;
1845 m_fontDlg=0L;
1846}
1847
1848void KPrView::slotApplyFont()
1849{
1850 int flags = m_fontDlg->changedFlags();
1851 if ( flags )
1852 {
1853 m_canvas->setTextFormat(m_fontDlg->newFormat(), flags);
1854 }
1855}
1856
1857void KPrView::slotCounterStyleSelected()
1858{
1859 TQString actionName = TQString::fromLatin1(sender()->name());
1860 if ( actionName.startsWith( "counterstyle_" ) )
1861 {
1862 TQString styleStr = actionName.mid(13);
1863 //kdDebug(33001) << "KWView::slotCounterStyleSelected styleStr=" << styleStr << endl;
1864 KoParagCounter::Style style = (KoParagCounter::Style)(styleStr.toInt());
1865 KoParagCounter c;
1866 if ( style == KoParagCounter::STYLE_NONE )
1867 c.setNumbering( KoParagCounter::NUM_NONE );
1868 else {
1869 c.setNumbering( KoParagCounter::NUM_LIST );
1870 c.setStyle( style );
1871 if ( c.isBullet() )
1872 c.setSuffix( TQString() );
1873 // else the suffix remains the default, '.'
1874 // TODO save this setting, to use the last one selected in the dialog?
1875 // (same for custom bullet char etc.)
1876
1877 // 68927: restart numbering, by default, if last parag wasn't numbered
1878 // (and if we're not applying this to a selection)
1879 KPrTextView *edit = m_canvas->currentTextObjectView();
1880 if ( edit && !edit->textObject()->hasSelection() ) {
1881 KoTextParag* parag = edit->cursor()->parag();
1882 if ( parag->prev() && !parag->prev()->counter() )
1883 c.setRestartCounter(true);
1884 }
1885 }
1886
1887 TQPtrList<KoTextFormatInterface> lst = m_canvas->applicableTextInterfaces();
1888 TQPtrListIterator<KoTextFormatInterface> it( lst );
1889 KMacroCommand* macroCmd = 0L;
1890 for ( ; it.current() ; ++it )
1891 {
1892 KCommand *cmd = it.current()->setCounterCommand( c );
1893 if ( cmd )
1894 {
1895 if ( !macroCmd )
1896 macroCmd = new KMacroCommand( i18n("Change List Type") );
1897 macroCmd->addCommand( cmd );
1898 }
1899 }
1900 if( macroCmd)
1901 m_pKPresenterDoc->addCommand( macroCmd );
1902 }
1903
1904}
1905
1906void KPrView::textDepthPlus()
1907{
1908 m_canvas->setTextDepthPlus();
1909}
1910
1911void KPrView::textDepthMinus()
1912{
1913 m_canvas->setTextDepthMinus();
1914}
1915
1916void KPrView::textContentsToHeight()
1917{
1918 m_canvas->textContentsToHeight();
1919}
1920
1921void KPrView::textObjectToContents()
1922{
1923 m_canvas->textObjectToContents();
1924}
1925
1926void KPrView::penChosen()
1927{
1928 TQColor c = actionPenColor->color();
1929 if ( !m_canvas->currentTextObjectView() )
1930 {
1931 KCommand * cmd( getPenCmd( i18n( "Change Outline Color" ), KoPen(c),
1932 L_NORMAL, L_NORMAL, KoPenCmd::Color ) );
1933 if( cmd )
1934 m_pKPresenterDoc->addCommand( cmd );
1935 else
1936 pen.setColor( c );
1937 }
1938 else
1939 {
1940 tbColor = c;
1941 m_canvas->setTextColor( tbColor );
1942 }
1943}
1944
1945void KPrView::brushChosen()
1946{
1947 TQColor c = actionBrushColor->color();
1948 KPrTextView *edit = m_canvas->currentTextObjectView();
1949 if ( !edit )
1950 {
1951 //tz TODO remove macro, add parameter for command name in setBrush()
1952 KMacroCommand * macro= NULL;
1953 KCommand * cmd = NULL;
1954 TQBrush newBrush( c );
1955
1956 cmd = m_canvas->activePage()->setBrush( newBrush, FT_BRUSH, TQColor(), TQColor(), BCT_PLAIN, false,
1957 0, 0, KPrBrushCmd::BrushColor | KPrBrushCmd::BrushStyle |
1958 KPrBrushCmd::BrushGradientSelect );
1959 if( cmd )
1960 {
1961 if ( !macro )
1962 macro = new KMacroCommand( i18n( "Change Fill Color" ) );
1963 macro->addCommand( cmd );
1964 }
1965
1966
1967 if( macro )
1968 m_pKPresenterDoc->addCommand( macro );
1969 else
1970 brush.setColor( c );
1971 }
1972 else
1973 {
1974 tbColor = c;
1975 m_canvas->setTextBackgroundColor( c );
1976 }
1977}
1978
1979void KPrView::extraAlignObjLeft()
1980{
1981 m_canvas->alignObjects( AT_LEFT );
1982}
1983
1984void KPrView::extraAlignObjCenterH()
1985{
1986 m_canvas->alignObjects( AT_HCENTER );
1987}
1988
1989void KPrView::extraAlignObjRight()
1990{
1991 m_canvas->alignObjects( AT_RIGHT );
1992}
1993
1994void KPrView::extraAlignObjTop()
1995{
1996 m_canvas->alignObjects( AT_TOP );
1997}
1998
1999void KPrView::extraAlignObjCenterV()
2000{
2001 m_canvas->alignObjects( AT_VCENTER );
2002}
2003
2004void KPrView::extraAlignObjBottom()
2005{
2006 m_canvas->alignObjects( AT_BOTTOM );
2007}
2008
2009void KPrView::extraLineBeginNormal()
2010{
2011 setExtraLineBegin(L_NORMAL);
2012}
2013
2014void KPrView::extraLineBeginArrow()
2015{
2016 setExtraLineBegin(L_ARROW);
2017}
2018
2019void KPrView::extraLineBeginRect()
2020{
2021 setExtraLineBegin(L_SQUARE);
2022}
2023
2024void KPrView::extraLineBeginCircle()
2025{
2026 setExtraLineBegin(L_CIRCLE);
2027}
2028
2029void KPrView::extraLineBeginLineArrow()
2030{
2031 setExtraLineBegin( L_LINE_ARROW );
2032}
2033
2034void KPrView::extraLineBeginDimensionLine()
2035{
2036 setExtraLineBegin( L_DIMENSION_LINE );
2037}
2038
2039void KPrView::extraLineBeginDoubleArrow()
2040{
2041 setExtraLineBegin( L_DOUBLE_ARROW );
2042}
2043
2044void KPrView::extraLineBeginDoubleLineArrow()
2045{
2046 setExtraLineBegin( L_DOUBLE_LINE_ARROW );
2047}
2048
2049void KPrView::setExtraLineBegin(LineEnd lb)
2050{
2051 KCommand * cmd( getPenCmd( i18n("Change Line Begin"), KoPen(),
2052 lb, L_NORMAL, KoPenCmd::BeginLine ) );
2053 if( cmd )
2054 kPresenterDoc()->addCommand( cmd );
2055 else
2056 lineBegin = lb;
2057}
2058
2059void KPrView::extraLineEndNormal()
2060{
2061 setExtraLineEnd(L_NORMAL);
2062}
2063
2064void KPrView::extraLineEndArrow()
2065{
2066 setExtraLineEnd(L_ARROW);
2067}
2068
2069void KPrView::extraLineEndRect()
2070{
2071 setExtraLineEnd(L_SQUARE);
2072}
2073
2074void KPrView::extraLineEndCircle()
2075{
2076 setExtraLineEnd(L_CIRCLE);
2077}
2078
2079void KPrView::extraLineEndLineArrow()
2080{
2081 setExtraLineEnd( L_LINE_ARROW );
2082}
2083
2084void KPrView::extraLineEndDimensionLine()
2085{
2086 setExtraLineEnd( L_DIMENSION_LINE );
2087}
2088
2089void KPrView::extraLineEndDoubleArrow()
2090{
2091 setExtraLineEnd( L_DOUBLE_ARROW );
2092}
2093
2094void KPrView::extraLineEndDoubleLineArrow()
2095{
2096 setExtraLineEnd( L_DOUBLE_LINE_ARROW );
2097}
2098
2099void KPrView::setExtraLineEnd(LineEnd le)
2100{
2101 KCommand * cmd( getPenCmd( i18n("Change Line End"), KoPen(),
2102 L_NORMAL, le, KoPenCmd::EndLine ) );
2103 if( cmd )
2104 kPresenterDoc()->addCommand( cmd );
2105 else
2106 lineEnd = le;
2107}
2108
2109void KPrView::setExtraPenStyle( TQt::PenStyle style )
2110{
2111 KoPen tmpPen;
2112 tmpPen.setStyle( style );
2113
2114 KCommand * cmd( getPenCmd( i18n("Change Outline Style"), tmpPen,
2115 L_NORMAL, L_NORMAL, KoPenCmd::Style ) );
2116 if( cmd )
2117 kPresenterDoc()->addCommand( cmd );
2118 else
2119 pen.setStyle( style );
2120}
2121
2122void KPrView::setExtraPenWidth( double width )
2123{
2124 KoPen tmpPen;
2125 tmpPen.setPointWidth( width );
2126 KCommand * cmd( getPenCmd( i18n("Change Outline Width"), tmpPen,
2127 L_NORMAL, L_NORMAL, KoPenCmd::Width ) );
2128
2129 if( cmd )
2130 kPresenterDoc()->addCommand( cmd );
2131 else
2132 pen.setPointWidth( width );
2133}
2134
2135void KPrView::newPageLayout( const KoPageLayout &_layout )
2136{
2137 KoPageLayout oldLayout = m_pKPresenterDoc->pageLayout();
2138 KoUnit::Unit unit = m_pKPresenterDoc->unit(); // unchanged
2139
2140 KPrPgLayoutCmd *pgLayoutCmd = new KPrPgLayoutCmd( i18n( "Set Page Layout" ), _layout, oldLayout, unit, unit,kPresenterDoc() );
2141 pgLayoutCmd->execute();
2142 kPresenterDoc()->addCommand( pgLayoutCmd );
2143 updateRuler();
2144}
2145
2146void KPrView::updateRuler()
2147{
2148 //update koruler
2149 TQRect r=m_canvas->activePage()->getZoomPageRect();
2150 getHRuler()->setFrameStartEnd( r.left(), r.right()/*+m_canvas->diffx()*/ );
2151 getVRuler()->setFrameStartEnd( r.top(), r.bottom()/*+m_canvas->diffy()*/ );
2152}
2153
2154void KPrView::createGUI()
2155{
2156 splitter = new TQSplitter( this );
2157
2158 if ( !m_pKPresenterDoc->isEmbedded()
2159 && !m_pKPresenterDoc->isSingleViewMode() ) // No sidebar if the document is embedded
2160 {
2161 sidebar = new KPrSideBar( splitter, m_pKPresenterDoc, this );
2162 connect( sidebar, TQ_SIGNAL( movePage( int, int ) ),
2163 m_pKPresenterDoc, TQ_SLOT( movePage( int, int ) ) );
2164 connect( sidebar, TQ_SIGNAL( selectPage( int, bool ) ),
2165 m_pKPresenterDoc, TQ_SLOT( selectPage( int, bool ) ) );
2166 connect( sidebar, TQ_SIGNAL( showPage( int ) ),
2167 this, TQ_SLOT( skipToPage( int ) ) );
2168 // This sucks when resizing the window
2169 //splitter->setResizeMode( sidebar, TQSplitter::FollowSizeHint );
2170 //splitter->setResizeMode( pageBase, TQSplitter::Stretch );
2171 splitter->setResizeMode( sidebar, TQSplitter::KeepSize );
2172 }
2173
2174 TQSplitter *splitterVertical = new TQSplitter( TQt::Vertical, splitter );
2175
2176 // setup page
2177 pageBase = new PageBase( splitterVertical, this );
2178 pageBase->setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Expanding ) );
2179
2180 m_canvas=new KPrCanvas( pageBase, "Canvas", this );
2181
2182 TQObject::connect( m_canvas, TQ_SIGNAL( fontChanged( const TQFont & ) ),
2183 this, TQ_SLOT( fontChanged( const TQFont & ) ) );
2184 TQObject::connect( m_canvas, TQ_SIGNAL( colorChanged( const TQColor & ) ),
2185 this, TQ_SLOT( colorChanged( const TQColor & ) ) );
2186 TQObject::connect( m_canvas, TQ_SIGNAL( alignChanged( int ) ),
2187 this, TQ_SLOT( alignChanged( int ) ) );
2188 TQObject::connect( m_canvas, TQ_SIGNAL( objectSelectedChanged()),
2189 this, TQ_SLOT( objectSelectedChanged()));
2190 TQObject::connect( m_canvas, TQ_SIGNAL( sigMouseWheelEvent( TQWheelEvent* ) ),
2191 this, TQ_SLOT( getPageMouseWheelEvent( TQWheelEvent* ) ) );
2192
2193
2194 // setup notebar.
2195 if ( !m_pKPresenterDoc->isEmbedded()
2196 && !m_pKPresenterDoc->isSingleViewMode() ) // No notebar if the document is embedded
2197 {
2198 notebar = new KPrNoteBar( splitterVertical, this );
2199 }
2200
2201 // setup GUI
2202 setupActions();
2203 setupPopupMenus();
2204 setupScrollbars();
2205 setRanges();
2206 setupRulers();
2207
2208 if ( m_pKPresenterDoc && m_canvas )
2209 {
2210 TQObject::connect( m_canvas, TQ_SIGNAL( stopAutomaticPresentation() ), this, TQ_SLOT( stopAutomaticPresentation() ) );
2211 TQObject::connect( m_canvas, TQ_SIGNAL( restartPresentation() ), this, TQ_SLOT( restartPresentation() ) );
2212
2213 connect( getVRuler(), TQ_SIGNAL( addGuide( const TQPoint &, bool, int ) ),
2214 &( m_canvas->guideLines() ), TQ_SLOT( addGuide( const TQPoint &, bool, int ) ) );
2215 connect( getVRuler(), TQ_SIGNAL( moveGuide( const TQPoint &, bool, int ) ),
2216 &( m_canvas->guideLines() ), TQ_SLOT( moveGuide( const TQPoint &, bool, int ) ) );
2217 connect( getHRuler(), TQ_SIGNAL( addGuide( const TQPoint &, bool, int ) ),
2218 &( m_canvas->guideLines() ), TQ_SLOT( addGuide( const TQPoint &, bool, int ) ) );
2219 connect( getHRuler(), TQ_SIGNAL( moveGuide( const TQPoint &, bool, int ) ),
2220 &( m_canvas->guideLines() ), TQ_SLOT( moveGuide( const TQPoint &, bool, int ) ) );
2221 connect( &( m_canvas->guideLines() ), TQ_SIGNAL( moveGuides( bool ) ),
2222 m_canvas, TQ_SLOT( setPaintGuides( bool ) ) );
2223 connect( &( m_canvas->guideLines() ), TQ_SIGNAL( paintGuides( bool ) ),
2224 m_canvas, TQ_SLOT( setPaintGuides( bool ) ) );
2225 connect( &( m_canvas->guideLines() ), TQ_SIGNAL( guideLinesChanged( KoView * ) ),
2226 m_pKPresenterDoc, TQ_SLOT( slotGuideLinesChanged( KoView * ) ) );
2227 m_canvas->guideLines().setGuideLines( m_pKPresenterDoc->horizontalGuideLines(), m_pKPresenterDoc->verticalGuideLines() );
2228 }
2229
2230 if ( sidebar )
2231 {
2232 sidebar->outline()->setCurrentItem( sidebar->outline()->firstChild() );
2233 sidebar->outline()->setSelected( sidebar->outline()->firstChild(), true );
2234 TDEConfig *config=TDEGlobal::config();
2235 config->setGroup("Global");
2236 if(!config->readBoolEntry("Sidebar", true)) {
2237 sidebar->hide();
2238 actionViewShowSideBar->setChecked(false);
2239 }
2240 else actionViewShowSideBar->setChecked(true);
2241 }
2242
2243 if ( notebar )
2244 {
2245 TDEConfig *config=TDEGlobal::config();
2246 config->setGroup("Global");
2247 if(!config->readBoolEntry("Notebar", true)) {
2248 notebar->hide();
2249 actionViewShowNoteBar->setChecked(false);
2250 }
2251 else actionViewShowNoteBar->setChecked(true);
2252 // HACK This is needed to be able to calculate a good initial size for the notebar
2253 TQTimer::singleShot( 0, this, TQ_SLOT( initialLayoutOfSplitter() ) );
2254 }
2255 KPrPage *initPage=m_pKPresenterDoc->initialActivePage();
2256 if ( !initPage )
2257 m_pKPresenterDoc->pageList().at( 0 ); // first page
2258 skipToPage( m_pKPresenterDoc->pageList().findRef( initPage ) );
2259}
2260
2261void KPrView::initGui()
2262{
2263 tbColor = TQt::black;
2264 actionTextColor->setCurrentColor( TQt::black );
2265 actionBrushColor->setCurrentColor( TQt::white );
2266 actionPenColor->setCurrentColor( TQt::black );
2267 updateSideBarMenu();
2268 objectSelectedChanged();
2269 refreshPageButton();
2270
2271 KStatusBar * sb = statusBar();
2272 if ( sb )
2273 sb->show();
2274 showZoom( zoomHandler()->zoom() );
2275 updateHeaderFooterButton();
2276 updateDisplayObjectMasterPageButton();
2277 updateDisplayBackgroundButton();
2278
2279 actionAllowAutoFormat->setChecked( m_pKPresenterDoc->allowAutoFormat() );
2280 actionViewFormattingChars->setChecked( m_pKPresenterDoc->viewFormattingChars() );
2281
2282 updateGuideLineButton();
2283
2284 updateGridButton();
2285
2286 m_pKPresenterDoc->updateZoomRuler();
2287 updatePageInfo();
2288 actionAllowBgSpellCheck->setChecked( m_pKPresenterDoc->backgroundSpellCheckEnabled());
2289 updateDirectCursorButton();
2290 m_pKPresenterDoc->updatePresentationButton();
2291}
2292
2293void KPrView::updateDisplayObjectMasterPageButton()
2294{
2295 actionDisplayObjectFromMasterPage->setChecked( !m_canvas->activePage()->displayObjectFromMasterPage());
2296}
2297
2298void KPrView::updateDisplayBackgroundButton()
2299{
2300 actionDisplayBackgroundPage->setChecked( !m_canvas->activePage()->displayBackground() );
2301}
2302
2303void KPrView::updateHeaderFooterButton()
2304{
2305 m_actionExtraHeader->setChecked( m_canvas->activePage()->hasHeader() );
2306 m_actionExtraFooter->setChecked( m_canvas->activePage()->hasFooter() );
2307}
2308
2309void KPrView::guiActivateEvent( KParts::GUIActivateEvent *ev )
2310{
2311 if ( ev->activated() )
2312 initGui();
2313
2314 KoView::guiActivateEvent( ev );
2315}
2316
2317void KPrView::setupActions()
2318{
2319 actionEditCut = KStdAction::cut( this, TQ_SLOT( editCut() ), actionCollection(), "edit_cut" );
2320 actionEditCopy = KStdAction::copy( this, TQ_SLOT( editCopy() ), actionCollection(), "edit_copy" );
2321 actionEditPaste = KStdAction::paste( this, TQ_SLOT( editPaste() ), actionCollection(), "edit_paste" );
2322 connect( m_pKPresenterDoc, TQ_SIGNAL( enablePaste( bool ) ),
2323 actionEditPaste, TQ_SLOT( setEnabled( bool ) ) );
2324 m_pKPresenterDoc->clipboardDataChanged(); // set paste's initial state
2325
2326 actionEditDelete = new TDEAction( i18n( "&Delete" ), "edit-delete", CTRL + TQt::Key_Delete,
2327 this, TQ_SLOT( editDelete() ),
2328 actionCollection(), "edit_delete" );
2329 actionEditSelectAll = KStdAction::selectAll( this, TQ_SLOT( editSelectAll() ), actionCollection(), "edit_selectall" );
2330 actionEditDeSelectAll= KStdAction::deselect( this, TQ_SLOT( editDeSelectAll()), actionCollection(), "edit_deselectall");
2331 actionEditCopyPage = new TDEAction( i18n( "Copy Slide" ), "edit-copy",
2332 0, this, TQ_SLOT( editCopyPage() ),
2333 actionCollection(), "edit_copypage" );
2334 actionEditDuplicatePage = new TDEAction( i18n( "Duplicate Slide" ), "newslide",
2335 0, this, TQ_SLOT( editDuplicatePage() ),
2336 actionCollection(), "edit_duplicatepage" );
2337 actionEditDelPage = new TDEAction( i18n( "Delete Slide" ), "delslide", 0,
2338 this, TQ_SLOT( editDelPage() ),
2339 actionCollection(), "edit_delpage" );
2340
2341 actionEditFind=KStdAction::find( this, TQ_SLOT( editFind() ), actionCollection(), "edit_find" );
2342 actionEditFindNext = KStdAction::findNext( this, TQ_SLOT( editFindNext() ), actionCollection(), "edit_findnext" );
2343 actionEditFindPrevious = KStdAction::findPrev( this, TQ_SLOT( editFindPrevious() ), actionCollection(), "edit_findprevious" );
2344 actionEditReplace=KStdAction::replace( this, TQ_SLOT( editReplace() ), actionCollection(), "edit_replace" );
2345
2346 // ---------------- View actions
2347
2348 if ( !m_pKPresenterDoc->isEmbedded() )
2349 {
2350 actionViewShowSideBar = new TDEToggleAction( i18n("Show Sidebar"), 0,
2351 this, TQ_SLOT( viewShowSideBar() ),
2352 actionCollection(), "view_showsidebar" );
2353 actionViewShowSideBar->setCheckedState(i18n("Hide Sidebar"));
2354
2355 actionViewShowNoteBar = new TDEToggleAction( i18n("Show Notebar"), 0,
2356 this, TQ_SLOT( viewShowNoteBar() ),
2357 actionCollection(), "view_shownotebar" );
2358 actionViewShowNoteBar->setCheckedState(i18n("Hide Notebar"));
2359 }
2360
2361 actionViewFormattingChars = new TDEToggleAction( i18n( "&Formatting Characters" ), 0,
2362 this, TQ_SLOT( slotViewFormattingChars() ),
2363 actionCollection(), "view_formattingchars" );
2364 actionViewFormattingChars->setToolTip( i18n( "Toggle the display of non-printing characters." ) );
2365 actionViewFormattingChars->setWhatsThis( i18n( "Toggle the display of non-printing characters.<br><br>When this is enabled, KPresenter shows you tabs, spaces, carriage returns and other non-printing characters." ) );
2366
2367 actionViewSlideMaster = new TDEToggleAction( i18n( "Slide &Master" ), 0,
2368 this, TQ_SLOT( viewSlideMaster() ),
2369 actionCollection(), "view_master" );
2370
2371 actionViewShowGuideLine= new TDEToggleAction( i18n( "Guide Lines" ), 0,
2372 this, TQ_SLOT( viewGuideLines() ),
2373 actionCollection(), "view_guidelines" );
2374
2375 actionViewShowGrid = new TDEToggleAction( i18n( "Show &Grid" ), 0,
2376 this, TQ_SLOT( viewGrid() ),
2377 actionCollection(), "view_grid" );
2378 actionViewShowGrid->setCheckedState(i18n("Hide &Grid"));
2379
2380 actionViewSnapToGrid= new TDEToggleAction( i18n( "Snap to Grid" ), 0,
2381 this, TQ_SLOT(viewSnapToGrid() ),
2382 actionCollection(), "view_snaptogrid" );
2383
2384 // ---------------- insert actions
2385
2386 actionInsertPage = new TDEAction( i18n( "&Slide..." ), "slide", TQt::Key_F2,
2387 this, TQ_SLOT( insertPage() ),
2388 actionCollection(), "insert_page" );
2389
2390 new TDEAction( i18n( "Insert &Slide..." ), "newslide", 0,
2391 this, TQ_SLOT( insertPage() ),
2392 actionCollection(), "insert_page_popup" );
2393
2394 actionInsertPicture = new TDEAction( i18n( "P&icture..." ), "frame_image", TQt::SHIFT+TQt::Key_F5,
2395 this, TQ_SLOT( insertPicture() ),
2396 actionCollection(), "insert_picture" );
2397
2398 // ----------------- tools actions
2399
2400 actionToolsMouse = new TDEToggleAction( i18n( "Select" ), "select", 0,
2401 this, TQ_SLOT( toolsMouse() ),
2402 actionCollection(), "tools_mouse" );
2403 actionToolsMouse->setExclusiveGroup( "tools" );
2404 actionToolsMouse->setChecked( true );
2405
2406 actionToolsRotate = new TDEToggleAction( i18n( "&Rotate" ), "rotate", 0,
2407 this, TQ_SLOT( toolsRotate() ),
2408 actionCollection(), "tools_rotate" );
2409 actionToolsRotate->setExclusiveGroup( "tools" );
2410
2411 actionToolsZoom = new TDEToggleAction( i18n( "&Zoom" ), "viewmag", 0,
2412 this, TQ_SLOT( toolsZoom() ),
2413 actionCollection(), "tools_zoom" );
2414 actionToolsZoom->setExclusiveGroup( "tools" );
2415
2416 actionToolsShapePopup = new TDEActionMenu( i18n( "&Shape" ), "rectangle",
2417 actionCollection(), "tools_shapepopup" );
2418 actionToolsShapePopup->setDelayed(true);
2419 connect(actionToolsShapePopup, TQ_SIGNAL(activated()), this, TQ_SLOT(toolsShapePopup()));
2420
2421 actionToolsRectangle = new TDEToggleAction( i18n( "&Rectangle" ), "rectangle",
2422 0, this, TQ_SLOT( toolsRectangle() ),
2423 actionCollection(), "tools_rectangle" );
2424 actionToolsRectangle->setExclusiveGroup( "tools" );
2425
2426 actionToolsCircleOrEllipse = new TDEToggleAction( i18n( "&Circle/Ellipse" ), "circle",
2427 0, this, TQ_SLOT( toolsCircleOrEllipse() ),
2428 actionCollection(), "tools_circle" );
2429 actionToolsCircleOrEllipse->setExclusiveGroup( "tools" );
2430
2431 actionToolsPie = new TDEToggleAction( i18n( "&Pie/Arc/Chord" ), "pie", 0,
2432 this, TQ_SLOT( toolsPie() ),
2433 actionCollection(), "tools_pie" );
2434 actionToolsPie->setExclusiveGroup( "tools" );
2435
2436 actionToolsText = new TDEToggleAction( i18n( "&Text" ), "frame_text", TQt::Key_F10, // same shortcut as KWord
2437 this, TQ_SLOT( toolsText() ),
2438 actionCollection(), "tools_text" );
2439 actionToolsText->setExclusiveGroup( "tools" );
2440
2441 actionToolsAutoform = new TDEToggleAction( i18n( "&Arrows && Connections" ), "autoform",
2442 0, this, TQ_SLOT( toolsAutoform() ),
2443 actionCollection(), "tools_autoform" );
2444 actionToolsAutoform->setExclusiveGroup( "tools" );
2445
2446 actionToolsDiagramm = new TDEToggleAction( i18n( "&Chart" ), "frame_chart", 0,
2447 this, TQ_SLOT( toolsDiagramm() ),
2448 actionCollection(), "tools_diagramm" );
2449 actionToolsDiagramm->setExclusiveGroup( "tools" );
2450
2451 actionToolsTable = new TDEToggleAction( i18n( "Ta&ble"), "frame_spreadsheet", TQt::Key_F5 /*same as kword*/,
2452 this, TQ_SLOT( toolsTable() ),
2453 actionCollection(), "tools_table" );
2454 actionToolsTable->setExclusiveGroup( "tools" );
2455
2456 actionToolsObject = new KoPartSelectAction( i18n( "&Object" ), "frame_query",
2457 this, TQ_SLOT( toolsObject() ),
2458 actionCollection(), "tools_object" );
2459
2460 actionToolsLinePopup = new TDEActionMenu( i18n( "&Line" ), "line",
2461 actionCollection(), "tools_linepopup" );
2462 actionToolsLinePopup->setDelayed(true);
2463 connect(actionToolsLinePopup, TQ_SIGNAL(activated()), this, TQ_SLOT(toolsLinePopup()));
2464
2465 actionToolsLine = new TDEToggleAction( i18n( "&Line" ), "line", 0,
2466 this, TQ_SLOT( toolsLine() ),
2467 actionCollection(), "tools_line" );
2468 actionToolsLine->setExclusiveGroup( "tools" );
2469
2470 actionToolsFreehand = new TDEToggleAction( i18n( "&Freehand" ), "freehand", 0,
2471 this, TQ_SLOT( toolsFreehand() ),
2472 actionCollection(), "tools_freehand" );
2473 actionToolsFreehand->setExclusiveGroup( "tools" );
2474
2475 actionToolsPolyline = new TDEToggleAction( i18n( "Po&lyline" ), "polyline", 0,
2476 this, TQ_SLOT( toolsPolyline() ),
2477 actionCollection(), "tools_polyline" );
2478 actionToolsPolyline->setExclusiveGroup( "tools" );
2479
2480 actionToolsQuadricBezierCurve = new TDEToggleAction( i18n( "&Quadric Bezier Curve" ), "quadricbeziercurve", 0,
2481 this, TQ_SLOT( toolsQuadricBezierCurve() ),
2482 actionCollection(), "tools_quadricbeziercurve" );
2483 actionToolsQuadricBezierCurve->setExclusiveGroup( "tools" );
2484
2485 actionToolsCubicBezierCurve = new TDEToggleAction( i18n( "C&ubic Bezier Curve" ), "cubicbeziercurve", 0,
2486 this, TQ_SLOT( toolsCubicBezierCurve() ),
2487 actionCollection(), "tools_cubicbeziercurve" );
2488 actionToolsCubicBezierCurve->setExclusiveGroup( "tools" );
2489
2490 actionToolsConvexOrConcavePolygon = new TDEToggleAction( i18n( "Co&nvex/Concave Polygon" ), "polygon", 0,
2491 this, TQ_SLOT( toolsConvexOrConcavePolygon() ),
2492 actionCollection(), "tools_polygon" );
2493 actionToolsConvexOrConcavePolygon->setExclusiveGroup( "tools" );
2494
2495
2496 actionToolsClosedLinePopup = new TDEActionMenu( i18n( "&Closed Line" ), "closed_freehand",
2497 actionCollection(), "tools_closed_linepopup" );
2498 actionToolsClosedLinePopup->setDelayed(true);
2499 connect(actionToolsClosedLinePopup, TQ_SIGNAL(activated()), this, TQ_SLOT(toolsClosedLinePopup()));
2500
2501 actionToolsClosedFreehand = new TDEToggleAction( i18n( "Closed &Freehand" ), "closed_freehand", 0,
2502 this, TQ_SLOT( toolsClosedFreehand() ),
2503 actionCollection(), "tools_closed_freehand" );
2504 actionToolsClosedFreehand->setExclusiveGroup( "tools" );
2505
2506
2507 actionToolsClosedPolyline = new TDEToggleAction( i18n( "Closed Po&lyline" ), "closed_polyline", 0,
2508 this, TQ_SLOT( toolsClosedPolyline() ),
2509 actionCollection(), "tools_closed_polyline" );
2510 actionToolsClosedPolyline->setExclusiveGroup( "tools" );
2511
2512
2513 actionToolsClosedQuadricBezierCurve = new TDEToggleAction( i18n( "Closed &Quadric Bezier Curve" ), "closed_quadricbeziercurve", 0,
2514 this, TQ_SLOT( toolsClosedQuadricBezierCurve() ),
2515 actionCollection(), "tools_closed_quadricbeziercurve" );
2516 actionToolsClosedQuadricBezierCurve->setExclusiveGroup( "tools" );
2517
2518
2519 actionToolsClosedCubicBezierCurve = new TDEToggleAction( i18n( "Closed C&ubic Bezier Curve" ), "closed_cubicbeziercurve", 0,
2520 this, TQ_SLOT( toolsClosedCubicBezierCurve() ),
2521 actionCollection(), "tools_closed_cubicbeziercurve" );
2522 actionToolsClosedCubicBezierCurve->setExclusiveGroup( "tools" );
2523
2524 // ----------------- text actions
2525
2526 actionTextFont = new TDEAction( i18n( "&Font..." ), 0, this, TQ_SLOT( mtextFont() ),
2527 actionCollection(), "text_font" );
2528
2529 actionTextFontSize = new TDEFontSizeAction( i18n( "Font Size" ), 0, actionCollection(), "text_fontsize" );
2530 connect( actionTextFontSize, TQ_SIGNAL( fontSizeChanged( int ) ),
2531 this, TQ_SLOT( sizeSelected( int ) ) );
2532
2533#ifdef KFONTACTION_HAS_CRITERIA_ARG
2534 actionTextFontFamily = new TDEFontAction( TDEFontChooser::SmoothScalableFonts,
2535 i18n( "Font Family" ), 0,
2536 actionCollection(), "text_fontfamily" );
2537#else
2538 actionTextFontFamily = new TDEFontAction( i18n( "Font Family" ), 0,
2539 actionCollection(), "text_fontfamily" );
2540#endif
2541 connect( actionTextFontFamily , TQ_SIGNAL( activated( const TQString & ) ),
2542 this, TQ_SLOT( fontSelected( const TQString & ) ) );
2543
2544 actionTextBold = new TDEToggleAction( i18n( "&Bold" ), "format-text-bold", CTRL + TQt::Key_B,
2545 this, TQ_SLOT( textBold() ),
2546 actionCollection(), "format-text-bold" );
2547
2548 actionTextItalic = new TDEToggleAction( i18n( "&Italic" ), "format-text-italic", CTRL + TQt::Key_I,
2549 this, TQ_SLOT( textItalic() ),
2550 actionCollection(), "format-text-italic" );
2551
2552 actionTextUnderline = new TDEToggleAction( i18n( "&Underline" ), "format-text-underline", CTRL + TQt::Key_U,
2553 this, TQ_SLOT( textUnderline() ),
2554 actionCollection(), "text_underline" );
2555
2556 actionFormatStrikeOut = new TDEToggleAction( i18n( "&Strike Out" ), "format-text-strikethrough", 0 ,
2557 this, TQ_SLOT( textStrikeOut() ),
2558 actionCollection(), "format_strike" );
2559
2560 actionTextColor = new TTDESelectColorAction( i18n( "&Color..." ), TTDESelectColorAction::TextColor,
2561 actionCollection(), "text_color" ,true);
2562 connect( actionTextColor, TQ_SIGNAL( activated() ), TQ_SLOT( textColor() ) );
2563 actionTextColor->setDefaultColor(TQColor());
2564
2565
2566 actionTextAlignLeft = new TDEToggleAction( i18n( "Align &Left" ), "format-text-direction-ltr", ALT + TQt::Key_L,
2567 this, TQ_SLOT( textAlignLeft() ),
2568 actionCollection(), "text_alignleft" );
2569 actionTextAlignLeft->setExclusiveGroup( "align" );
2570 actionTextAlignLeft->setChecked( true );
2571
2572 actionTextAlignCenter = new TDEToggleAction( i18n( "Align &Center" ), "text_center", ALT + TQt::Key_C,
2573 this, TQ_SLOT( textAlignCenter() ),
2574 actionCollection(), "text_aligncenter" );
2575 actionTextAlignCenter->setExclusiveGroup( "align" );
2576
2577 actionTextAlignRight = new TDEToggleAction( i18n( "Align &Right" ), "format-text-direction-rtl", ALT + TQt::Key_R,
2578 this, TQ_SLOT( textAlignRight() ),
2579 actionCollection(), "text_alignright" );
2580 actionTextAlignRight->setExclusiveGroup( "align" );
2581
2582 actionTextAlignBlock = new TDEToggleAction( i18n( "Align &Block" ), "text_block", CTRL + TQt::Key_J,
2583 this, TQ_SLOT( textAlignBlock() ),
2584 actionCollection(), "text_alignblock" );
2585 actionTextAlignBlock->setExclusiveGroup( "align" );
2586
2587
2588 actionFormatNumber = new TDEActionMenu( i18n( "Number" ), "enumList", actionCollection(), "format_number" );
2589 actionFormatNumber->setDelayed( false );
2590 actionFormatBullet = new TDEActionMenu( i18n( "Bullet" ), "unsortedList", actionCollection(), "format_bullet" );
2591 actionFormatBullet->setDelayed( false );
2592 TQPtrList<KoCounterStyleWidget::StyleRepresenter> stylesList;
2593 KoCounterStyleWidget::makeCounterRepresenterList( stylesList );
2594 TQPtrListIterator<KoCounterStyleWidget::StyleRepresenter> styleIt( stylesList );
2595 for ( ; styleIt.current() ; ++styleIt ) {
2596 // Dynamically create toggle-actions for each list style.
2597 // This approach allows to edit toolbars and extract separate actions from this menu
2598 TDEToggleAction* act = new TDEToggleAction( styleIt.current()->name(), /*TODO icon,*/
2599 0, this, TQ_SLOT( slotCounterStyleSelected() ),
2600 actionCollection(), TQString("counterstyle_%1").arg( styleIt.current()->style() ).latin1() );
2601 act->setExclusiveGroup( "counterstyle" );
2602 // Add to the right menu: both for "none", bullet for bullets, numbers otherwise
2603 if ( styleIt.current()->style() == KoParagCounter::STYLE_NONE ) {
2604 actionFormatBullet->insert( act );
2605 actionFormatNumber->insert( act );
2606 } else if ( styleIt.current()->isBullet() )
2607 actionFormatBullet->insert( act );
2608 else
2609 actionFormatNumber->insert( act );
2610 }
2611 actionTextDepthPlus = new TDEAction( i18n( "&Increase Depth" ), TQApplication::reverseLayout() ?"format_decreaseindent" : "format_increaseindent",
2612 CTRL + TQt::Key_Plus, this, TQ_SLOT( textDepthPlus() ),
2613 actionCollection(), "text_depthPlus" );
2614
2615 actionTextDepthMinus = new TDEAction( i18n( "&Decrease Depth" ), TQApplication::reverseLayout() ?"format_increaseindent" : "format_decreaseindent",
2616 CTRL + TQt::Key_Minus, this, TQ_SLOT( textDepthMinus() ),
2617 actionCollection(), "text_depthMinus" );
2618
2619 actionTextExtentCont2Height = new TDEAction( i18n( "Extend Contents to Object &Height" ), 0,
2620 this, TQ_SLOT( textContentsToHeight() ),
2621 actionCollection(), "text_con2hei" );
2622
2623 actionTextExtendObj2Cont = new TDEAction( i18n( "&Extend Object to Fit Contents" ), 0,
2624 this, TQ_SLOT( textObjectToContents() ),
2625 actionCollection(), "text_obj2cont" );
2626
2627 actionTextInsertPageNum = new TDEAction( i18n( "&Insert Slide Number" ), "pgnum", 0,
2628 this, TQ_SLOT( textInsertPageNum() ),
2629 actionCollection(), "text_inspgnum" );
2630
2631 // ----------------- format actions
2632
2633 actionExtraProperties = new TDEAction( i18n( "&Properties" ), "penbrush", 0,
2634 this, TQ_SLOT( extraProperties() ),
2635 actionCollection(), "extra_properties" );
2636
2637 actionExtraArrangePopup = new TDEActionMenu( i18n( "Arra&nge Objects" ), "arrange",
2638 actionCollection(), "extra_arrangepopup" );
2639 actionExtraArrangePopup->setDelayed( false );
2640
2641 actionExtraRaise = new TDEAction( i18n( "Ra&ise Objects" ), "raise",
2642 CTRL+TQt::SHIFT+TQt::Key_R, this, TQ_SLOT( extraRaise() ),
2643 actionCollection(), "extra_raise" );
2644
2645 actionExtraLower = new TDEAction( i18n( "&Lower Objects" ), "lower", CTRL +TQt::SHIFT+ TQt::Key_L,
2646 this, TQ_SLOT( extraLower() ),
2647 actionCollection(), "extra_lower" );
2648
2649 actionExtraBringForward= new TDEAction( i18n( "Bring to Front" ), "bring_forward",
2650 0, this, TQ_SLOT( extraBringForward() ),
2651 actionCollection(), "extra_bring_forward" );
2652
2653 actionExtraSendBackward= new TDEAction( i18n( "Send to Back" ), "send_backward",
2654 0, this, TQ_SLOT( extraSendBackward() ),
2655 actionCollection(), "extra_send_backward" );
2656
2657
2658
2659 actionExtraRotate = new TDEAction( i18n( "R&otate Objects..." ), "object-rotate-right", 0,
2660 this, TQ_SLOT( extraRotate() ),
2661 actionCollection(), "extra_rotate" );
2662
2663 actionExtraShadow = new TDEAction( i18n( "&Shadow Objects..." ), "shadow", 0,
2664 this, TQ_SLOT( extraShadow() ),
2665 actionCollection(), "extra_shadow" );
2666
2667 actionExtraAlignObjLeft = new TDEAction( i18n( "Align &Left" ), "aoleft", 0,
2668 this, TQ_SLOT( extraAlignObjLeft() ),
2669 actionCollection(), "extra_alignleft" );
2670
2671 actionExtraAlignObjCenterH = new TDEAction( i18n( "Align Center (&horizontally)" ),
2672 "aocenterh", 0,
2673 this, TQ_SLOT( extraAlignObjCenterH() ),
2674 actionCollection(), "extra_aligncenterh" );
2675
2676 actionExtraAlignObjRight = new TDEAction( i18n( "Align &Right" ), "aoright", 0,
2677 this, TQ_SLOT( extraAlignObjRight() ),
2678 actionCollection(), "extra_alignright" );
2679
2680 actionExtraAlignObjTop = new TDEAction( i18n( "Align &Top" ), "aotop", 0,
2681 this, TQ_SLOT( extraAlignObjTop() ),
2682 actionCollection(), "extra_aligntop" );
2683
2684 actionExtraAlignObjCenterV = new TDEAction( i18n( "Align Center (&vertically)" ),
2685 "aocenterv", 0,
2686 this, TQ_SLOT( extraAlignObjCenterV() ),
2687 actionCollection(), "extra_aligncenterv" );
2688
2689 actionExtraAlignObjBottom = new TDEAction( i18n( "Align &Bottom" ), "aobottom", 0,
2690 this, TQ_SLOT( extraAlignObjBottom() ),
2691 actionCollection(), "extra_alignbottom" );
2692
2693
2694 actionExtraBackground = new TDEAction( i18n( "Slide Bac&kground..." ), "background", 0,
2695 this, TQ_SLOT( extraBackground() ),
2696 actionCollection(), "extra_background" );
2697
2698 actionExtraLayout = new TDEAction( i18n( "Page &Layout..." ), 0,
2699 this, TQ_SLOT( extraLayout() ),
2700 actionCollection(), "extra_layout" );
2701
2702 m_actionExtraHeader = new TDEToggleAction( i18n( "Enable Document &Header" ), 0,
2703 this, TQ_SLOT( viewHeader() ),
2704 actionCollection(), "extra_header" );
2705 m_actionExtraHeader->setCheckedState( i18n( "Disable Document &Header" ) );
2706 m_actionExtraHeader->setToolTip( i18n( "Shows and hides header display for the current slide." ) );
2707
2708 m_actionExtraFooter = new TDEToggleAction( i18n( "Enable Document Foo&ter" ), 0,
2709 this, TQ_SLOT( viewFooter() ),
2710 actionCollection(), "extra_footer" );
2711 m_actionExtraFooter->setCheckedState( i18n( "Disable Document Foo&ter" ) );
2712 m_actionExtraFooter->setToolTip( i18n( "Shows and hides footer display for the current slide." ) );
2713
2714 actionExtraConfigure = new TDEAction( i18n( "Configure KPresenter..." ),
2715 "configure", 0,
2716 this, TQ_SLOT( extraConfigure() ),
2717 actionCollection(), "extra_configure" );
2718
2719 actionExtraWebPres = new TDEAction( i18n( "Create &HTML Slideshow..." ),
2720 "webpres", 0,
2721 this, TQ_SLOT( extraWebPres() ),
2722 actionCollection(), "extra_webpres" );
2723
2724 actionExtraMSPres = new TDEAction( i18n( "Create Memor&y Stick Slideshow..." ),
2725 0, this, TQ_SLOT( extraMSPres() ),
2726 actionCollection(), "extra_mspres" );
2727
2728 actionExtraCreateTemplate = new TDEAction( i18n( "Template Manager" ), 0,
2729 this, TQ_SLOT( extraCreateTemplate() ),
2730 actionCollection(), "extra_template" );
2731
2732 actionExtraDefaultTemplate = new TDEAction( i18n( "Use Current Slide as Default Template" ), 0,
2733 this, TQ_SLOT( extraDefaultTemplate() ),
2734 actionCollection(), "extra_defaulttemplate" );
2735
2736 actionExtraAlignObjsPopup = new TDEActionMenu( i18n("Align O&bjects"), "alignobjs",
2737 actionCollection(), "extra_alignobjs" );
2738 actionExtraAlignObjsPopup->setDelayed( false );
2739
2740 actionExtraLineBegin = new TDEAction( i18n("Line Begin"), "line_begin", 0,
2741 this, TQ_SLOT( extraLineBegin() ),
2742 actionCollection(), "extra_linebegin" );
2743
2744 actionExtraLineEnd = new TDEAction( i18n("Line End"), "line_end", 0,
2745 this, TQ_SLOT( extraLineEnd() ),
2746 actionCollection(), "extra_lineend" );
2747
2748 actionExtraPenStyle = new KoLineStyleAction( i18n("Outline Style"), "pen_style",
2749 this, TQ_SLOT( extraPenStyle(int) ),
2750 actionCollection(), "extra_penstyle" );
2751 actionExtraPenStyle->setShowCurrentSelection(false);
2752
2753 actionExtraPenWidth = new KoLineWidthAction( i18n("Outline Width"), "pen_width",
2754 this, TQ_SLOT( extraPenWidth(double) ),
2755 actionCollection(), "extra_penwidth" );
2756 actionExtraPenWidth->setUnit( kPresenterDoc()->unit() );
2757 actionExtraPenWidth->setShowCurrentSelection(false);
2758 connect( kPresenterDoc(), TQ_SIGNAL( unitChanged( KoUnit::Unit ) ),
2759 actionExtraPenWidth, TQ_SLOT( setUnit( KoUnit::Unit ) ) );
2760
2761 actionExtraGroup = new TDEAction( i18n( "&Group Objects" ), "group",
2762 TQKeySequence( "Ctrl+G" ),
2763 this, TQ_SLOT( extraGroup() ),
2764 actionCollection(), "extra_group" );
2765
2766 actionExtraUnGroup = new TDEAction( i18n( "&Ungroup Objects" ), "ungroup",
2767 TQKeySequence( "Ctrl+Shift+G" ),
2768 this, TQ_SLOT( extraUnGroup() ),
2769 actionCollection(), "extra_ungroup" );
2770
2771 // ----------------- slideshow actions
2772
2773 actionScreenConfigPages = new TDEAction( i18n( "&Configure Slide Show..." ),
2774 "configure", 0,
2775 this, TQ_SLOT( screenConfigPages() ),
2776 actionCollection(), "screen_configpages" );
2777
2778 actionScreenAssignEffect = new TDEAction( i18n( "Edit &Object Effect..." ),
2779 "effect", 0,
2780 this, TQ_SLOT( screenAssignEffect() ),
2781 actionCollection(), "screen_assigneffect");
2782
2783 actionScreenTransEffect = new TDEAction( i18n( "Edit Slide &Transition..." ),
2784 "slide_effect", 0,
2785 this, TQ_SLOT( screenTransEffect() ),
2786 actionCollection(), "screen_transeffect");
2787
2788
2789 actionScreenStart = new TDEAction( i18n( "&Start" ),
2790 "2rightarrow", TQt::Key_F12,
2791 this, TQ_SLOT( screenStart() ),
2792 actionCollection(), "screen_start" );
2793
2794 actionScreenStartFromFirst = new TDEAction( i18n( "Start From &First Slide" ),
2795 "1rightarrow", 0,
2796 this, TQ_SLOT( screenStartFromFirst() ),
2797 actionCollection(), "screen_startfromfirst" );
2798
2799 actionScreenFirst = new TDEAction( i18n( "&Go to Start" ),
2800 "go-first", 0,
2801 this, TQ_SLOT( screenFirst() ),
2802 actionCollection(), "screen_first" );
2803
2804 actionScreenPrev = new TDEAction( i18n( "&Previous Slide" ),
2805 "back", TQt::Key_Prior,
2806 this, TQ_SLOT( screenPrev() ),
2807 actionCollection(), "screen_prev" );
2808
2809 actionScreenNext = new TDEAction( i18n( "&Next Slide" ),
2810 "forward", TQt::Key_Next,
2811 this, TQ_SLOT( screenNext() ),
2812 actionCollection(), "screen_next" );
2813
2814 actionScreenLast = new TDEAction( i18n( "Go to &End" ),
2815 "go-last", 0,
2816 this, TQ_SLOT( screenLast() ),
2817 actionCollection(), "screen_last" );
2818
2819 actionScreenSkip = new TDEAction( i18n( "Goto &Slide..." ),
2820 "goto", 0,
2821 this, TQ_SLOT( screenSkip() ),
2822 actionCollection(), "screen_skip" );
2823
2824 // ----------------- colorbar(Brush and Pen) action
2825
2826 actionBrushColor = new TTDESelectColorAction( i18n( "Fill Color..." ), TTDESelectColorAction::FillColor,
2827 actionCollection(), "brush_color" ,true);
2828 connect( actionBrushColor, TQ_SIGNAL( activated() ), TQ_SLOT( brushChosen() ) );
2829 actionBrushColor->setDefaultColor(TQColor());
2830
2831 actionPenColor = new TTDESelectColorAction( i18n( "Outline Color..." ), TTDESelectColorAction::LineColor,
2832 actionCollection(), "pen_color" );
2833 connect( actionPenColor, TQ_SIGNAL( activated() ), TQ_SLOT( penChosen() ) );
2834 actionPenColor->setDefaultColor(TQColor());
2835 actionExtendObjectHeight = new TDEAction( i18n( "&Extend Contents to Object Height" ),0, this, TQ_SLOT( textContentsToHeight() ),
2836 actionCollection(), "extendobjectheight" );
2837
2838 actionResizeTextObject = new TDEAction( i18n( "&Resize Object to Fit Contents" ),0, this, TQ_SLOT( textObjectToContents() ),
2839 actionCollection(), "resizetextobject" );
2840
2841 actionRenamePage=new TDEAction(i18n( "&Rename Slide..." ),0,this,
2842 TQ_SLOT( renamePageTitle() ),
2843 actionCollection(), "rename_page" );
2844
2845 actionPicOriginalSize = new TDEAction( i18n( "Sca&le to Original Size" ), 0, this,
2846 TQ_SLOT( picViewOriginalSize() ),
2847 actionCollection(), "pic_original_size" );
2848
2849 actionPic640x480=new TDEAction(i18n( "640x480" ),0,this,
2850 TQ_SLOT( picViewOrig640x480() ),
2851 actionCollection(), "pic_640_480" );
2852
2853 actionPic800x600=new TDEAction(i18n( "800x600" ),0,this,
2854 TQ_SLOT( picViewOrig800x600() ),
2855 actionCollection(), "pic_800_600" );
2856
2857 actionPic1024x768=new TDEAction(i18n( "1024x768" ),0,this,
2858 TQ_SLOT( picViewOrig1024x768() ),
2859 actionCollection(), "pic_1024_768" );
2860
2861 actionPic1280x1024=new TDEAction(i18n( "1280x1024" ),0,this,
2862 TQ_SLOT( picViewOrig1280x1024() ),
2863 actionCollection(), "pic_1280_1024" );
2864
2865 actionPic1600x1200=new TDEAction(i18n( "1600x1200" ),0,this,
2866 TQ_SLOT( picViewOrig1600x1200() ),
2867 actionCollection(), "pic_1600_1200" );
2868
2869 actionChangePic=new TDEAction( i18n( "&Change Picture..." ),"frame_image",0,this,
2870 TQ_SLOT( chPic() ), actionCollection(), "change_picture" );
2871
2872
2873 actionImageEffect = new TDEAction( i18n("Image &Effect..."), 0, this,
2874 TQ_SLOT(imageEffect()), actionCollection(), "image_effect");
2875
2876
2877 actionFormatSuper = new TDEToggleAction( i18n( "Superscript" ), "super", 0,
2878 this, TQ_SLOT( textSuperScript() ),
2879 actionCollection(), "format_super" );
2880 actionFormatSuper->setExclusiveGroup( "valign" );
2881 actionFormatSub = new TDEToggleAction( i18n( "Subscript" ), "sub", 0,
2882 this, TQ_SLOT( textSubScript() ),
2883 actionCollection(), "format_sub" );
2884 actionFormatSub->setExclusiveGroup( "valign" );
2885
2886
2887 actionInsertSpecialChar = new TDEAction( i18n( "Sp&ecial Character..." ), "char",
2888 ALT + TQt::SHIFT + TQt::Key_C,
2889 this, TQ_SLOT( insertSpecialChar() ),
2890 actionCollection(), "insert_specialchar" );
2891
2892 actionInsertLink = new TDEAction( i18n( "Link..." ), 0,
2893 this, TQ_SLOT( insertLink() ),
2894 actionCollection(), "insert_link" );
2895
2896#if 0
2897 //code from page.cpp
2898 //not implemented
2899 picResizeMenu->insertSeparator();
2900 picResizeMenu->insertItem( i18n( "Enter Custom Factor..." ), this, TQ_SLOT( picViewOrigFactor() ) );
2901#endif
2902 (void) new TDEAction( i18n( "Configure &Autocorrection..." ), 0,
2903 this, TQ_SLOT( extraAutoFormat() ),
2904 actionCollection(), "extra_autocorrection" );
2905 actionExtraSpellCheck = KStdAction::spelling( this, TQ_SLOT( slotSpellCheck() ), actionCollection(), "extra_spellcheck" );
2906
2907 actionFormatParag = new TDEAction( i18n( "&Paragraph..." ), ALT + CTRL + TQt::Key_P,
2908 this, TQ_SLOT( formatParagraph() ),
2909 actionCollection(), "format_paragraph" );
2910
2911 actionFormatDefault=new TDEAction( i18n( "Default Format" ), 0,
2912 this, TQ_SLOT( textDefaultFormat() ),
2913 actionCollection(), "text_default" );
2914
2915 actionOpenLink = new TDEAction( i18n( "Open Link" ), 0,
2916 this, TQ_SLOT( openLink() ),
2917 actionCollection(), "open_link" );
2918
2919 actionChangeLink=new TDEAction( i18n("Change Link..."), 0,
2920 this, TQ_SLOT(changeLink()),
2921 actionCollection(), "change_link");
2922
2923 actionCopyLink = new TDEAction( i18n( "Copy Link" ), 0,
2924 this, TQ_SLOT( copyLink() ),
2925 actionCollection(), "copy_link" );
2926
2927 actionRemoveLink = new TDEAction( i18n( "Remove Link" ), 0,
2928 this, TQ_SLOT( removeLink() ),
2929 actionCollection(), "remove_link" );
2930
2931
2932 actionAddLinkToBookmak = new TDEAction( i18n( "Add to Bookmark" ), 0,
2933 this, TQ_SLOT( addToBookmark() ),
2934 actionCollection(), "add_to_bookmark" );
2935
2936 actionEditCustomVarsEdit = new TDEAction( i18n( "&Custom Variables..." ), 0,
2937 this, TQ_SLOT( editCustomVars() ),
2938 actionCollection(), "edit_vars" );
2939
2940 actionEditCustomVars = new TDEAction( i18n( "Edit Variable..." ), 0,
2941 this, TQ_SLOT( editCustomVariable() ),
2942 actionCollection(), "edit_customvars" );
2943
2944
2945 m_variableDefMap.clear();
2946 actionInsertVariable = new TDEActionMenu( i18n( "&Variable" ),
2947 actionCollection(), "insert_variable" );
2948 // The last argument is only needed if a submenu is to be created
2949 addVariableActions( VT_FIELD, KoFieldVariable::actionTexts(), actionInsertVariable, i18n("&Property") );
2950 addVariableActions( VT_DATE, KoDateVariable::actionTexts(), actionInsertVariable, i18n("&Date") );
2951 addVariableActions( VT_TIME, KoTimeVariable::actionTexts(), actionInsertVariable, i18n("&Time") );
2952
2953 actionInsertCustom = new TDEActionMenu( i18n( "&Custom" ),
2954 actionCollection(), "insert_custom" );
2955 actionInsertVariable->insert(actionInsertCustom);
2956 refreshCustomMenu();
2957
2958 addVariableActions( VT_PGNUM, KoPageVariable::actionTexts(), actionInsertVariable, i18n("&Page") );
2959 addVariableActions( VT_STATISTIC, KPrStatisticVariable::actionTexts(), actionInsertVariable, i18n("&Statistic") );
2960
2961 actionInsertVariable->popupMenu()->insertSeparator();
2962 actionRefreshAllVariable = new TDEAction( i18n( "&Refresh All Variables" ), 0,
2963 this, TQ_SLOT( refreshAllVariable() ),
2964 actionCollection(), "refresh_all_variable" );
2965 actionInsertVariable->insert(actionRefreshAllVariable);
2966
2967 actionIncreaseFontSize = new TDEAction( i18n("Increase Font Size"),"fontsizeup", 0,
2968 this, TQ_SLOT( increaseFontSize() ),
2969 actionCollection(), "increaseFontSize" );
2970
2971 actionDecreaseFontSize = new TDEAction( i18n("Decrease Font Size"),"fontsizedown", 0,
2972 this, TQ_SLOT( decreaseFontSize() ),
2973 actionCollection(), "decreaseFontSize" );
2974
2975 actionChangeCase=new TDEAction( i18n( "Change Case..." ), 0,
2976 this, TQ_SLOT( changeCaseOfText() ),
2977 actionCollection(), "change_case" );
2978
2979 actionViewZoom = new TDESelectAction( i18n( "Zoom" ), "viewmag", 0,
2980 actionCollection(), "view_zoom" );
2981 connect( actionViewZoom, TQ_SIGNAL( activated( const TQString & ) ),
2982 this, TQ_SLOT( viewZoom( const TQString & ) ) );
2983 actionViewZoom->setEditable(true);
2984 changeZoomMenu( );
2985
2986 actionFormatStylist = new TDEAction( i18n( "&Style Manager" ), ALT + CTRL + TQt::Key_S,
2987 this, TQ_SLOT( extraStylist() ),
2988 actionCollection(), "format_stylist" );
2989
2990 actionFormatStyleMenu = new TDEActionMenu( i18n( "St&yle" ), 0,
2991 actionCollection(), "format_stylemenu" );
2992
2993
2994 actionFormatStyle = new TDESelectAction( i18n( "St&yle" ), 0,
2995 actionCollection(), "format_style" );
2996 connect( actionFormatStyle, TQ_SIGNAL( activated( int ) ),
2997 this, TQ_SLOT( textStyleSelected( int ) ) );
2998 actionFormatStyle->setMenuAccelsEnabled( true );
2999 updateStyleList();
3000
3001 actionAllowAutoFormat = new TDEToggleAction( i18n( "Enable Autocorrection" ), 0,
3002 this, TQ_SLOT( slotAllowAutoFormat() ),
3003 actionCollection(), "enable_autocorrection" );
3004 actionAllowAutoFormat->setCheckedState(i18n("Disable Autocorrection"));
3005
3006 // ------------------- Actions with a key binding and no GUI item
3007 new TDEAction( i18n( "Insert Non-Breaking Space" ), CTRL+TQt::Key_Space,
3008 this, TQ_SLOT( slotNonbreakingSpace() ), actionCollection(), "nonbreaking_space" );
3009 new TDEAction( i18n( "Insert Non-Breaking Hyphen" ), CTRL+TQt::SHIFT+TQt::Key_Minus,
3010 this, TQ_SLOT( slotNonbreakingHyphen() ), actionCollection(), "nonbreaking_hyphen" );
3011 new TDEAction( i18n( "Insert Soft Hyphen" ), CTRL+TQt::Key_Minus,
3012 this, TQ_SLOT( slotSoftHyphen() ), actionCollection(), "soft_hyphen" );
3013 new TDEAction( i18n( "Line Break" ), TQt::SHIFT+TQt::Key_Return,
3014 this, TQ_SLOT( slotLineBreak() ), actionCollection(), "line_break" );
3015 new TDEAction( i18n( "Completion" ), TDEStdAccel::shortcut(TDEStdAccel::TextCompletion),
3016 this, TQ_SLOT( slotCompletion() ), actionCollection(), "completion" );
3017
3018 new TDEAction( i18n( "Increase Numbering Level" ), ALT+TQt::Key_Right,
3019 this, TQ_SLOT( slotIncreaseNumberingLevel() ), actionCollection(), "increase_numbering_level" );
3020 new TDEAction( i18n( "Decrease Numbering Level" ), ALT+TQt::Key_Left,
3021 this, TQ_SLOT( slotDecreaseNumberingLevel() ), actionCollection(), "decrease_numbering_level" );
3022
3023
3024 actionInsertComment = new TDEAction( i18n( "Comment..." ), 0,
3025 this, TQ_SLOT( insertComment() ),
3026 actionCollection(), "insert_comment" );
3027 actionEditComment = new TDEAction( i18n("Edit Comment..."), 0,
3028 this, TQ_SLOT(editComment()),
3029 actionCollection(), "edit_comment");
3030
3031 actionAddGuideLine = new TDEAction( i18n( "Add Guide Line..."), 0,
3032 this, TQ_SLOT( addGuideLine()),
3033 actionCollection(), "add_guideline");
3034
3035 actionRemoveComment = new TDEAction( i18n("Remove Comment"), 0,
3036 this, TQ_SLOT(removeComment()),
3037 actionCollection(), "remove_comment");
3038
3039 actionCopyTextOfComment = new TDEAction( i18n("Copy Text of Comment..."), 0,
3040 this, TQ_SLOT(copyTextOfComment()),
3041 actionCollection(), "copy_text_comment");
3042
3043 actionConfigureCompletion = new TDEAction( i18n( "&Configure Completion..." ), 0,
3044 this, TQ_SLOT( configureCompletion() ),
3045 actionCollection(), "configure_completion" );
3046
3047 actionZoomMinus = new TDEAction( i18n( "Zoom Out" ), "zoom-out",0,
3048 this, TQ_SLOT( zoomMinus() ),
3049 actionCollection(), "zoom_minus" );
3050 actionZoomPlus = new TDEAction( i18n( "Zoom In" ), "zoom-in",0,
3051 this, TQ_SLOT( zoomPlus() ),
3052 actionCollection(), "zoom_plus" );
3053 actionZoomEntirePage = new TDEAction( i18n( "Zoom Entire Slide" ), 0,
3054 this, TQ_SLOT( zoomEntirePage() ),
3055 actionCollection(), "zoom_entire_page" );
3056
3057 actionZoomMinus = new TDEAction( i18n( "Zoom Slide Width" ), 0,
3058 this, TQ_SLOT( zoomPageWidth() ),
3059 actionCollection(), "zoom_page_width" );
3060 actionZoomSelectedObject= new TDEAction( i18n( "Zoom Selected Objects" ), "zoom-fit-best",0,
3061 this, TQ_SLOT( zoomSelectedObject() ),
3062 actionCollection(), "zoom_selected_object" );
3063 actionZoomPageHeight= new TDEAction( i18n( "Zoom Slide Height" ), 0,
3064 this, TQ_SLOT( zoomPageHeight() ),
3065 actionCollection(), "zoom_page_height" );
3066
3067 actionZoomAllObject= new TDEAction( i18n( "Zoom All Objects" ), 0,
3068 this, TQ_SLOT( zoomAllObject() ),
3069 actionCollection(), "zoom_all_object" );
3070
3071 actionFlipHorizontal= new TDEAction( i18n( "Horizontal Flip" ), 0,
3072 this, TQ_SLOT( flipHorizontal() ),
3073 actionCollection(), "horizontal_flip" );
3074
3075 actionFlipVertical= new TDEAction( i18n( "Vertical Flip" ), 0,
3076 this, TQ_SLOT( flipVertical() ),
3077 actionCollection(), "vertical_flip" );
3078
3079 actionDuplicateObj = new TDEAction( i18n( "Duplicate Object..." ), 0,
3080 this, TQ_SLOT( duplicateObj() ),
3081 actionCollection(), "duplicate_obj" );
3082
3083 actionApplyAutoFormat= new TDEAction( i18n( "Apply Autocorrection" ), 0,
3084 this, TQ_SLOT( applyAutoFormat() ),
3085 actionCollection(), "apply_autoformat" );
3086
3087 actionCreateStyleFromSelection = new TDEAction( i18n( "Create Style From Selection..." ), 0,
3088 this, TQ_SLOT( createStyleFromSelection()),
3089 actionCollection(), "create_style" );
3090
3091 actionCloseObject = new TDEAction( i18n( "Close Object" ), 0,
3092 this, TQ_SLOT( closeObject()),
3093 actionCollection(), "close_object" );
3094
3095
3096 actionAlignVerticalTop = new TDEToggleAction( i18n( "Align Top" ), 0,
3097 this, TQ_SLOT( alignVerticalTop() ),
3098 actionCollection(), "align_top" );
3099 actionAlignVerticalTop->setExclusiveGroup( "vertical_alignment" );
3100 actionAlignVerticalTop->setChecked( true );
3101
3102
3103 actionAlignVerticalBottom = new TDEToggleAction( i18n( "Align Bottom" ), 0,
3104 this, TQ_SLOT( alignVerticalBottom() ),
3105 actionCollection(), "align_bottom" );
3106 actionAlignVerticalBottom->setExclusiveGroup( "vertical_alignment" );
3107
3108 actionAlignVerticalCenter = new TDEToggleAction( i18n( "Align Middle" ), 0,
3109 this, TQ_SLOT( alignVerticalCenter() ),
3110 actionCollection(), "align_center" );
3111 actionAlignVerticalCenter->setExclusiveGroup( "vertical_alignment" );
3112
3113
3114 actionSavePicture= new TDEAction( i18n("Save Picture..."), 0,
3115 this, TQ_SLOT( savePicture() ),
3116 actionCollection(), "save_picture");
3117
3118 actionAllowBgSpellCheck = new TDEToggleAction( i18n( "Autospellcheck" ), 0,
3119 this, TQ_SLOT( autoSpellCheck() ),
3120 actionCollection(), "tool_auto_spellcheck" );
3121
3122 actionInsertFile= new TDEAction( i18n( "File..." ), 0,
3123 this, TQ_SLOT( insertFile() ),
3124 actionCollection(), "insert_file" );
3125 actionImportStyle= new TDEAction( i18n( "Import Styles..." ), 0,
3126 this, TQ_SLOT( importStyle() ),
3127 actionCollection(), "import_style" );
3128
3129 actionSaveBackgroundPicture= new TDEAction( i18n( "Save Background Picture..." ), 0,
3130 this, TQ_SLOT(backgroundPicture() ),
3131 actionCollection(), "save_bgpicture" );
3132#if 0
3133 actionInsertDirectCursor = new TDEToggleAction( i18n( "Type Anywhere Cursor" ), 0,
3134 this, TQ_SLOT( insertDirectCursor() ),
3135 actionCollection(), "direct_cursor" );
3136#endif
3137
3138 actionSpellIgnoreAll = new TDEAction( i18n( "Ignore All" ), 0,
3139 this, TQ_SLOT( slotAddIgnoreAllWord() ),
3140 actionCollection(), "ignore_all" );
3141
3142 actionAddWordToPersonalDictionary=new TDEAction( i18n( "Add Word to Dictionary" ),0,
3143 this, TQ_SLOT( addWordToDictionary() ),
3144 actionCollection(), "add_word_to_dictionary" );
3145 actionCustomSlideShow = new TDEAction( i18n( "Custom Slide Show..." ), 0,
3146 this, TQ_SLOT( customSlideShow() ),
3147 actionCollection(), "custom_slide_show" );
3148
3149 actionDisplayObjectFromMasterPage = new TDEToggleAction( i18n( "Hide Object From Slide Master" ), 0,
3150 this, TQ_SLOT( displayObjectFromMasterPage() ),
3151 actionCollection(), "display_object_from_master_page" );
3152 actionDisplayObjectFromMasterPage->setCheckedState(i18n("Display Object From Slide Master"));
3153
3154
3155 actionDisplayBackgroundPage = new TDEToggleAction( i18n( "Hide Background" ), 0,
3156 this, TQ_SLOT( displayBackground() ),
3157 actionCollection(), "display_background" );
3158 actionDisplayBackgroundPage->setCheckedState(i18n("Display Background"));
3159}
3160
3161void KPrView::displayObjectFromMasterPage()
3162{
3163 bool state=actionDisplayObjectFromMasterPage->isChecked();
3164 m_canvas->activePage()->setDisplayObjectFromMasterPage( !state );
3165 KPrDisplayObjectFromMasterPage * cmd =new KPrDisplayObjectFromMasterPage( state ? i18n("Hide Object From Slide Master") : i18n("Display Object From Slide Master"), m_pKPresenterDoc, m_canvas->activePage(), !state);
3166 m_pKPresenterDoc->addCommand(cmd);
3167 m_pKPresenterDoc->updateSideBarItem( m_pKPresenterDoc->masterPage() );
3168}
3169
3170void KPrView::displayBackground()
3171{
3172 bool state=actionDisplayBackgroundPage->isChecked();
3173 m_canvas->activePage()->setDisplayBackground( !state );
3174 KPrDisplayBackgroundPage * cmd =new KPrDisplayBackgroundPage( state ? i18n("Hide Background") : i18n("Display Background"), m_pKPresenterDoc, m_canvas->activePage(), !state);
3175 m_pKPresenterDoc->addCommand(cmd);
3176 m_pKPresenterDoc->updateSideBarItem( m_pKPresenterDoc->masterPage() );
3177}
3178
3179void KPrView::customSlideShow()
3180{
3181 KPrCustomSlideShowDia *dlg = new KPrCustomSlideShowDia( this, m_pKPresenterDoc, "custom slide show" );
3182 dlg->exec();
3183 delete dlg;
3184 //clear element
3185 m_pKPresenterDoc->clearTestCustomSlideShow();
3186}
3187
3188void KPrView::textSubScript()
3189{
3190 m_canvas->setTextSubScript(actionFormatSub->isChecked());
3191}
3192
3193void KPrView::textSuperScript()
3194{
3195 m_canvas->setTextSuperScript(actionFormatSuper->isChecked());
3196}
3197
3198void KPrView::decreaseFontSize()
3199{
3200 m_canvas->setDecreaseFontSize();
3201}
3202
3203void KPrView::increaseFontSize()
3204{
3205 m_canvas->setIncreaseFontSize();
3206}
3207
3208void KPrView::objectSelectedChanged()
3209{
3210
3211 bool state=m_canvas->isOneObjectSelected();
3212 bool headerfooterselected=false;
3213
3214 if (m_canvas->numberOfObjectSelected()==1)
3215 {
3216 KPrObject *obj=m_canvas->getSelectedObj();
3217 //disable this action when we select a header/footer
3218 if (obj==m_pKPresenterDoc->header() || obj==m_pKPresenterDoc->footer())
3219 headerfooterselected=true;
3220 else
3221 headerfooterselected=false;
3222 }
3223 actionScreenAssignEffect->setEnabled(state && !headerfooterselected);
3224 actionEditDelete->setEnabled(state && !headerfooterselected);
3225 actionEditCut->setEnabled(state && !headerfooterselected);
3226
3227 KPrObjectProperties objectProperties( m_canvas->activePage()->getSelectedObjects() );
3228 int flags = objectProperties.getPropertyFlags();
3229 // only button when object support them or none object is selected
3230 actionBrushColor->setEnabled( !state || ( flags & KPrObjectProperties::PtBrush ) );
3231 actionExtraLineBegin->setEnabled( !state || ( flags & KPrObjectProperties::PtLineEnds ) );
3232 actionExtraLineEnd->setEnabled( !state || ( flags & KPrObjectProperties::PtLineEnds ) );
3233 actionExtraPenWidth->setEnabled( !state || ( flags & KPrObjectProperties::PtPenWidth ) );
3234
3235 actionExtraProperties->setEnabled(state && !headerfooterselected);
3236 actionExtraRotate->setEnabled(state && !headerfooterselected);
3237 actionExtraShadow->setEnabled(state && !m_canvas->haveASelectedPartObj() && !headerfooterselected);
3238
3239 actionExtraAlignObjsPopup->setEnabled(state && !headerfooterselected);
3240 actionExtraGroup->setEnabled(state && m_canvas->numberOfObjectSelected()>1);
3241 actionExtraUnGroup->setEnabled(state && m_canvas->haveASelectedGroupObj());
3242
3243 bool enableAlign = m_canvas->canMoveOneObject() && state && !headerfooterselected;
3244
3245 actionExtraAlignObjLeft->setEnabled(enableAlign);
3246 actionExtraAlignObjCenterH->setEnabled(enableAlign);
3247 actionExtraAlignObjRight->setEnabled(enableAlign);
3248 actionExtraAlignObjTop->setEnabled(enableAlign);
3249 actionExtraAlignObjCenterV->setEnabled(enableAlign);
3250 actionExtraAlignObjBottom->setEnabled(enableAlign);
3251 //actionEditDelete->setEnabled(state);
3252 int nbobj=m_canvas->numberOfObjectSelected();
3253 actionDuplicateObj->setEnabled(state && (nbobj>=1));
3254
3255 state = state && (nbobj==1);
3256 actionExtraArrangePopup->setEnabled(state);
3257
3258 actionExtraRaise->setEnabled( nbobj > 0 );
3259 actionExtraLower->setEnabled( nbobj > 0 );
3260 actionExtraBringForward->setEnabled( nbobj > 0 );
3261 actionExtraSendBackward->setEnabled( nbobj > 0 );
3262
3263 //actionExtraConfigPicture->setEnabled( state && m_canvas->haveASelectedPixmapObj() );
3264 //actionPenColor->setEnabled(state);
3265 //actionExtraPenStyle->setEnabled(state);
3266 //actionExtraPenWidth->setEnabled(state);
3267
3268 actionApplyAutoFormat->setEnabled(m_canvas->oneObjectTextExist());
3269 slotObjectEditChanged();
3270}
3271
3272void KPrView::backOk( KPrBackDialog* backDia, bool takeGlobal )
3273{
3274 KPrPage *page=m_canvas->activePage();
3275 KPrSetBackCmd *setBackCmd = new KPrSetBackCmd( i18n( "Set Background" ),
3276 backDia->getBackGround(),
3277 page->background()->getBackGround(),
3278 backDia->useMasterBackground(),
3279 takeGlobal, m_pKPresenterDoc,page);
3280 setBackCmd->execute();
3281 m_pKPresenterDoc->addCommand( setBackCmd );
3282}
3283
3284void KPrView::afChooseOk( const TQString & c )
3285{
3286 TQFileInfo fileInfo( c );
3287 TQString fileName = locate( "autoforms",
3288 fileInfo.dirPath( false ) + "/" + fileInfo.baseName() + ".atf",
3289 KPrFactory::global() );
3290
3291 deSelectAllObjects();
3292 m_canvas->setToolEditMode( INS_AUTOFORM );
3293 m_canvas->setAutoForm( fileName );
3294}
3295
3296void KPrView::slotAfchooseCanceled()
3297{
3298 setTool( TEM_MOUSE );
3299}
3300
3301void KPrView::propertiesOk()
3302{
3303 KCommand *cmd = m_propertyEditor->getCommand();
3304
3305 if ( cmd )
3306 {
3307 cmd->execute();
3308 kPresenterDoc()->addCommand( cmd );
3309 }
3310}
3311
3312void KPrView::pgConfOk()
3313{
3314 TQValueList<bool> selectedSlides;
3315 for( unsigned i = 0; i < kPresenterDoc()->pageList().count(); i++ ) {
3316 selectedSlides.append( kPresenterDoc()->pageList().at( i )->isSlideSelected() );
3317 }
3318
3319 KPrPgConfCmd *pgConfCmd = new KPrPgConfCmd( i18n( "Configure Slide Show" ),
3320 pgConfDia->getManualSwitch(), pgConfDia->getInfiniteLoop(),
3321 pgConfDia->getShowEndOfPresentationSlide(), pgConfDia->getPresentationDuration(), pgConfDia->getPen(),
3322 pgConfDia->getSelectedSlides(),
3323 pgConfDia->presentationName(),
3324 kPresenterDoc()->spManualSwitch(),
3325 kPresenterDoc()->spInfiniteLoop(),
3326 kPresenterDoc()->spShowEndOfPresentationSlide(),
3327 kPresenterDoc()->presentationDuration(),
3328 kPresenterDoc()->presPen(),
3329 selectedSlides,
3330 kPresenterDoc()->presentationName(),
3331 kPresenterDoc() );
3332 pgConfCmd->execute();
3333 kPresenterDoc()->addCommand( pgConfCmd );
3334
3335 TQPtrListIterator<KPrPage> it( kPresenterDoc()->pageList() );
3336 for ( ; it.current(); ++it )
3337 updateSideBarItem( it.current() );
3338}
3339
3340
3341void KPrView::rotateOk()
3342{
3343 float _newAngle=rotateDia->angle();
3344
3345 KCommand *cmd=m_canvas->activePage()->rotateSelectedObjects(_newAngle);
3346 if( cmd )
3347 kPresenterDoc()->addCommand( cmd );
3348}
3349
3350void KPrView::shadowOk()
3351{
3352 KCommand *cmd=m_canvas->activePage()->shadowObj(shadowDia->shadowDirection(),
3353 shadowDia->shadowDistance(),
3354 shadowDia->shadowColor());
3355 if( cmd)
3356 kPresenterDoc()->addCommand( cmd );
3357}
3358
3359unsigned int KPrView::getCurrPgNum() const
3360{
3361 return currPg + 1;
3362}
3363
3364
3365void KPrView::recalcCurrentPageNum()
3366{
3367 KPrPage *activePage = m_canvas->activePage();
3368
3369 TQPtrList<KPrPage> pageList( m_pKPresenterDoc->pageList() );
3370
3371 int pos = pageList.findRef( activePage );
3372
3373 if ( pos != -1 )
3374 {
3375 currPg = pos;
3376 }
3377 else
3378 {
3379 kdDebug(33001) << "KPrView::recalcCurrentPageNum: activePage not found" << endl;
3380 currPg = 0;
3381 }
3382
3383 if( sidebar )
3384 sidebar->setCurrentPage( currPg );
3385}
3386
3387
3388void KPrView::scrollH( int value )
3389{
3390 if ( !presStarted ) {
3391 m_canvas->scrollX( value );
3392 if ( h_ruler )
3393 h_ruler->setOffset( value, 0 );
3394 }
3395}
3396
3397void KPrView::scrollV( int value )
3398{
3399 if ( !presStarted ) {
3400 m_canvas->scrollY( value );
3401 if ( v_ruler )
3402 v_ruler->setOffset( 0, value );
3403 }
3404}
3405
3406void KPrView::fontChanged( const TQFont &font )
3407{
3408 tbFont.setFamily( font.family() );
3409 tbFont.setBold( font.bold() );
3410 tbFont.setItalic( font.italic() );
3411 tbFont.setUnderline( font.underline() );
3412 tbFont.setPointSize( font.pointSize() );
3413
3414 actionTextFontFamily->setFont( tbFont.family() );
3415 actionTextFontSize->setFontSize( tbFont.pointSize() );
3416 actionTextBold->setChecked( tbFont.bold() );
3417 actionTextItalic->setChecked( tbFont.italic() );
3418 actionTextUnderline->setChecked( tbFont.underline() );
3419}
3420
3421void KPrView::colorChanged( const TQColor &color )
3422{
3423 tbColor = color;
3424 actionTextColor->setEnabled( true );
3425 actionTextColor->setCurrentColor( tbColor );
3426}
3427
3428void KPrView::alignChanged( int align )
3429{
3430 if ( align != tbAlign ) {
3431 tbAlign = align;
3432 if ( ( align & AlignLeft ) == AlignLeft ) {
3433 actionTextAlignLeft->blockSignals( true );
3434 actionTextAlignLeft->setChecked( true );
3435 actionTextAlignLeft->blockSignals( false );
3436 } else if ( ( align & AlignHCenter ) == AlignHCenter ||
3437 ( align & AlignCenter ) == AlignCenter ) {
3438 actionTextAlignCenter->blockSignals( true );
3439 actionTextAlignCenter->setChecked( true );
3440 actionTextAlignCenter->blockSignals( false );
3441 } else if ( ( align & AlignRight ) == AlignRight ) {
3442 actionTextAlignRight->blockSignals( true );
3443 actionTextAlignRight->setChecked( true );
3444 actionTextAlignRight->blockSignals( false );
3445 } else if ( (align & AlignJustify ) == AlignJustify ) {
3446 actionTextAlignBlock->blockSignals( true );
3447 actionTextAlignBlock->setChecked( true );
3448 actionTextAlignBlock->blockSignals( false );
3449 }
3450 }
3451}
3452
3453void KPrView::changePicture( const TQString & filename )
3454{
3455 TQStringList mimetypes;
3456 mimetypes += KImageIO::mimeTypes( KImageIO::Reading );
3457 mimetypes += KoPictureFilePreview::clipartMimeTypes();
3458
3459 KFileDialog fd( filename, TQString(), this, 0, true );
3460 fd.setCaption(i18n("Select New Picture"));
3461 fd.setMimeFilter( mimetypes );
3462 fd.setPreviewWidget( new KoPictureFilePreview( &fd ) );
3463
3464 KURL url;
3465 if ( fd.exec() == TQDialog::Accepted )
3466 url = fd.selectedURL();
3467
3468 if( url.isEmpty() || !url.isValid())
3469 return;
3470
3471 m_canvas->changePicture( url, m_canvas );
3472}
3473
3474void KPrView::resizeEvent( TQResizeEvent *e )
3475{
3476 if ( !presStarted )
3477 TQWidget::resizeEvent( e );
3478
3479 TQSize s = e ? e->size() : size();
3480 splitter->setGeometry( 0, 0, s.width(), s.height() );
3481}
3482
3483void KPrView::reorganize()
3484{
3485 if (m_bShowGUI ) {
3486
3487 horz->show();
3488 vert->show();
3489 pgNext->show();
3490 pgPrev->show();
3491
3492 if(kPresenterDoc()->showRuler())
3493 {
3494 int hSpace = v_ruler->minimumSizeHint().width();
3495 int vSpace = h_ruler->minimumSizeHint().height();
3496
3497 m_canvas->move( hSpace, vSpace );
3498 if ( h_ruler )
3499 {
3500 h_ruler->show();
3501 h_ruler->setGeometry( hSpace, 0, m_canvas->width(), vSpace );
3502 }
3503 if (v_ruler )
3504 {
3505 v_ruler->show();
3506 v_ruler->setGeometry( 0, vSpace, hSpace, m_canvas->height() );
3507 }
3508 if(getTabChooser())
3509 {
3510 getTabChooser()->setGeometry(0, 0, hSpace, vSpace);
3511 getTabChooser()->show();
3512 }
3513 }
3514 else
3515 {
3516 m_canvas->move( 0, 0 );
3517 if ( h_ruler )
3518 h_ruler->hide();
3519 if ( v_ruler )
3520 v_ruler->hide();
3521 getTabChooser()->hide();
3522 }
3523
3524 if( statusBar())
3525 {
3526 if(m_pKPresenterDoc->showStatusBar())
3527 statusBar()->show();
3528 else
3529 statusBar()->hide();
3530 }
3531
3532 setRanges();
3533 }
3534 else
3535 {
3536 horz->hide();
3537 vert->hide();
3538 pgNext->hide();
3539 pgPrev->hide();
3540 h_ruler->hide();
3541 v_ruler->hide();
3542 getTabChooser()->hide();
3543 m_canvas->move( 0, 0 );
3544 }
3545}
3546
3547void PageBase::resizeEvent( TQResizeEvent *e )
3548{
3549 if ( !view->presStarted )
3550 TQWidget::resizeEvent( e );
3551
3552 TQSize s = e ? e->size() : size();
3553
3554 if ( view->m_bShowGUI ) {
3555 int hSpace = view->getVRuler()->minimumSizeHint().width();
3556 int vSpace = view->getVRuler()->minimumSizeHint().height();
3557
3558 view->m_canvas->resize( s.width() - ( hSpace + 16 ), s.height() - ( vSpace + 16 ) );
3559 view->vert->setGeometry( s.width() - 16, 0, 16, s.height() - 32 );
3560 view->pgPrev->setGeometry( s.width() - 15, s.height() - 32, 15, 16 );
3561 view->pgNext->setGeometry( s.width() - 15, s.height() - 16, 15, 16 );
3562 view->horz->setGeometry( 0, s.height() - 16, s.width() - 16, 16 );
3563 }
3564 else
3565 {
3566 view->m_canvas->move( 0, 0 );
3567 view->m_canvas->resize( s.width(), s.height() );
3568 }
3569 view->reorganize();
3570}
3571
3572void KPrView::dragEnterEvent( TQDragEnterEvent *e )
3573{
3574 TQApplication::sendEvent( m_canvas, e );
3575}
3576
3577void KPrView::dragMoveEvent( TQDragMoveEvent *e )
3578{
3579 TQApplication::sendEvent( m_canvas, e );
3580}
3581
3582void KPrView::dragLeaveEvent( TQDragLeaveEvent *e )
3583{
3584 TQApplication::sendEvent( m_canvas, e );
3585}
3586
3587void KPrView::dropEvent( TQDropEvent *e )
3588{
3589 TQApplication::sendEvent( m_canvas, e );
3590}
3591
3592void KPrView::getPageMouseWheelEvent( TQWheelEvent *e )
3593{
3594 TQApplication::sendEvent( vert, e );
3595}
3596
3597void KPrView::keyPressEvent( TQKeyEvent *e )
3598{
3599 if ( e->key() == TQt::Key_Delete && !m_canvas->currentTextObjectView() )
3600 editDelete();
3601 else
3602 TQApplication::sendEvent( m_canvas, e );
3603}
3604
3605void KPrView::doAutomaticScreenPres()
3606{
3607 if ( m_autoPresStop ) // A user pushed Escape key or clicked "Exit presentation" menu.
3608 return;
3609 else if ( m_autoPresRestart && kPresenterDoc()->spInfiniteLoop() ) {
3610 m_autoPresRestart = false;
3611 m_canvas->presGotoFirstPage(); // return to first page.
3612 }
3613 else
3614 screenNext();
3615}
3616
3617void KPrView::updateReadWrite( bool readwrite )
3618{
3619 // First disable or enable everything
3620 TQValueList<TDEAction*> actions = actionCollection()->actions();
3621 // Also grab actions from the document
3622 actions += m_pKPresenterDoc->actionCollection()->actions();
3623 TQValueList<TDEAction*>::ConstIterator aIt = actions.begin();
3624 TQValueList<TDEAction*>::ConstIterator aEnd = actions.end();
3625 for (; aIt != aEnd; ++aIt )
3626 (*aIt)->setEnabled( readwrite );
3627
3628
3629 if ( !readwrite )
3630 {
3631 // Readonly -> re-enable a few harmless actions
3632 refreshPageButton();
3633 actionViewFormattingChars->setEnabled( true );
3634 actionViewZoom->setEnabled( true );
3635 actionEditFind->setEnabled( true );
3636 actionEditFindNext->setEnabled( true );
3637 actionEditFindPrevious->setEnabled( true );
3638 actionEditReplace->setEnabled( true );
3639 actionEditSelectAll->setEnabled( true );
3640 actionEditDeSelectAll->setEnabled( true );
3641 }
3642 else
3643 {
3644 refreshPageButton();
3645 objectSelectedChanged();
3646
3647 refreshCustomMenu();
3648
3649 // Correctly enable or disable undo/redo actions again
3650 m_pKPresenterDoc->commandHistory()->updateActions();
3651 updateSideBarMenu();
3652 }
3653
3654}
3655
3656void KPrView::setupPopupMenus()
3657{
3658 // create right button line begin
3659 rb_lbegin = new TQPopupMenu();
3660 TQ_CHECK_PTR( rb_lbegin );
3661 rb_lbegin->insertItem( KPBarIcon("line_normal_begin" ), this, TQ_SLOT( extraLineBeginNormal() ) );
3662 rb_lbegin->insertSeparator();
3663 rb_lbegin->insertItem( KPBarIcon("line_arrow_begin" ), this, TQ_SLOT( extraLineBeginArrow() ) );
3664 rb_lbegin->insertSeparator();
3665 rb_lbegin->insertItem( KPBarIcon("line_rect_begin" ), this, TQ_SLOT( extraLineBeginRect() ) );
3666 rb_lbegin->insertSeparator();
3667 rb_lbegin->insertItem( KPBarIcon("line_circle_begin" ), this, TQ_SLOT( extraLineBeginCircle() ) );
3668 rb_lbegin->insertSeparator();
3669 rb_lbegin->insertItem( KPBarIcon("line_line_arrow_begin" ), this, TQ_SLOT( extraLineBeginLineArrow() ) );
3670 rb_lbegin->insertSeparator();
3671 rb_lbegin->insertItem( KPBarIcon("line_dimension_line_begin" ), this, TQ_SLOT( extraLineBeginDimensionLine() ) );
3672 rb_lbegin->insertSeparator();
3673 rb_lbegin->insertItem( KPBarIcon("line_double_arrow_begin" ), this, TQ_SLOT( extraLineBeginDoubleArrow() ) );
3674 rb_lbegin->insertSeparator();
3675 rb_lbegin->insertItem( KPBarIcon("line_double_line_arrow_begin" ), this, TQ_SLOT( extraLineBeginDoubleLineArrow() ) );
3676 rb_lbegin->setMouseTracking( true );
3677 rb_lbegin->setCheckable( false );
3678
3679 // create right button line end
3680 rb_lend = new TQPopupMenu();
3681 TQ_CHECK_PTR( rb_lend );
3682 rb_lend->insertItem( KPBarIcon("line_normal_end" ), this, TQ_SLOT( extraLineEndNormal() ) );
3683 rb_lend->insertSeparator();
3684 rb_lend->insertItem( KPBarIcon("line_arrow_end" ), this, TQ_SLOT( extraLineEndArrow() ) );
3685 rb_lend->insertSeparator();
3686 rb_lend->insertItem( KPBarIcon("line_rect_end" ), this, TQ_SLOT( extraLineEndRect() ) );
3687 rb_lend->insertSeparator();
3688 rb_lend->insertItem( KPBarIcon("line_circle_end" ), this, TQ_SLOT( extraLineEndCircle() ) );
3689 rb_lend->insertSeparator();
3690 rb_lend->insertItem( KPBarIcon("line_line_arrow_end" ), this, TQ_SLOT( extraLineEndLineArrow() ) );
3691 rb_lend->insertSeparator();
3692 rb_lend->insertItem( KPBarIcon("line_dimension_line_end" ), this, TQ_SLOT( extraLineEndDimensionLine() ) );
3693 rb_lend->insertSeparator();
3694 rb_lend->insertItem( KPBarIcon("line_double_arrow_end" ), this, TQ_SLOT( extraLineEndDoubleArrow() ) );
3695 rb_lend->insertSeparator();
3696 rb_lend->insertItem( KPBarIcon("line_double_line_arrow_end" ), this, TQ_SLOT( extraLineEndDoubleLineArrow() ) );
3697 rb_lend->setMouseTracking( true );
3698 rb_lend->setCheckable( false );
3699
3700 // create arrange-objects popup
3701 m_arrangeObjectsPopup = new TQPopupMenu();
3702 TQ_CHECK_PTR(m_arrangeObjectsPopup);
3703 m_arrangeObjectsPopup->insertItem(KPBarIcon("lower"), this, TQ_SLOT(extraLower()));
3704 m_arrangeObjectsPopup->insertSeparator();
3705 m_arrangeObjectsPopup->insertItem(KPBarIcon("send_backward"), this, TQ_SLOT(extraSendBackward()));
3706 m_arrangeObjectsPopup->insertSeparator();
3707 m_arrangeObjectsPopup->insertItem(KPBarIcon("bring_forward"), this, TQ_SLOT(extraBringForward()));
3708 m_arrangeObjectsPopup->insertSeparator();
3709 m_arrangeObjectsPopup->insertItem(KPBarIcon("raise"), this, TQ_SLOT(extraRaise()));
3710 m_arrangeObjectsPopup->setMouseTracking(true);
3711 m_arrangeObjectsPopup->setCheckable(false);
3712
3713 // create insert-line popup
3714 actionToolsLinePopup->insert(actionToolsLine);
3715 actionToolsLinePopup->insert(actionToolsFreehand);
3716 actionToolsLinePopup->insert(actionToolsPolyline);
3717 actionToolsLinePopup->insert(actionToolsCubicBezierCurve);
3718 actionToolsLinePopup->insert(actionToolsQuadricBezierCurve);
3719
3720 // create insert-shape popup
3721 actionToolsShapePopup->insert(actionToolsRectangle);
3722 actionToolsShapePopup->insert(actionToolsCircleOrEllipse);
3723 actionToolsShapePopup->insert(actionToolsPie);
3724 actionToolsShapePopup->insert(actionToolsConvexOrConcavePolygon);
3725
3726 // create insert-closed-line popup
3727 actionToolsClosedLinePopup->insert(actionToolsClosedFreehand);
3728 actionToolsClosedLinePopup->insert(actionToolsClosedPolyline);
3729 actionToolsClosedLinePopup->insert(actionToolsClosedQuadricBezierCurve);
3730 actionToolsClosedLinePopup->insert(actionToolsClosedCubicBezierCurve);
3731
3732 actionExtraAlignObjsPopup->insert( actionExtraAlignObjLeft );
3733 actionExtraAlignObjsPopup->insert( actionExtraAlignObjCenterV );
3734 actionExtraAlignObjsPopup->insert( actionExtraAlignObjRight );
3735 actionExtraAlignObjsPopup->insert( actionExtraAlignObjTop );
3736 actionExtraAlignObjsPopup->insert( actionExtraAlignObjCenterH );
3737 actionExtraAlignObjsPopup->insert( actionExtraAlignObjBottom );
3738
3739 actionExtraArrangePopup->insert( actionExtraLower );
3740 actionExtraArrangePopup->insert( actionExtraSendBackward );
3741 actionExtraArrangePopup->insert( actionExtraBringForward );
3742 actionExtraArrangePopup->insert( actionExtraRaise );
3743}
3744
3745void KPrView::setupScrollbars()
3746{
3747 vert = new TQScrollBar( TQt::Vertical, pageBase );
3748 horz = new TQScrollBar( TQt::Horizontal, pageBase );
3749 vert->show();
3750 horz->show();
3751 TQObject::connect( vert, TQ_SIGNAL( valueChanged( int ) ), this, TQ_SLOT( scrollV( int ) ) );
3752 TQObject::connect( horz, TQ_SIGNAL( valueChanged( int ) ), this, TQ_SLOT( scrollH( int ) ) );
3753 vert->setValue(vert->maxValue());
3754 horz->setValue(horz->maxValue());
3755 vert->setValue(vert->minValue());
3756 horz->setValue(horz->minValue());
3757 pgNext = new TQToolButton( pageBase );
3758 pgNext->setPixmap( TQPixmap( pagedown_xpm ) );
3759 pgNext->setAutoRepeat( true );
3760 TQToolTip::add( pgNext, i18n( "Next slide" ) );
3761 connect( pgNext, TQ_SIGNAL( clicked() ), this, TQ_SLOT( nextPage() ) );
3762 pgPrev = new TQToolButton( pageBase );
3763 pgPrev->setPixmap( TQPixmap( pageup_xpm ) );
3764 pgPrev->setAutoRepeat( true );
3765 TQToolTip::add( pgPrev, i18n( "Previous slide" ) );
3766 connect( pgPrev, TQ_SIGNAL( clicked() ), this, TQ_SLOT( prevPage() ) );
3767}
3768
3769void KPrView::setupRulers()
3770{
3771 tabChooser = new KoTabChooser( pageBase, KoTabChooser::TAB_ALL );
3772 tabChooser->setReadWrite(kPresenterDoc()->isReadWrite());
3773 h_ruler = new KoRuler( pageBase, m_canvas, TQt::Horizontal, kPresenterDoc()->pageLayout(),
3774 KoRuler::F_INDENTS | KoRuler::F_TABS, kPresenterDoc()->unit(), tabChooser );
3775 h_ruler->changeFlags(0);
3776
3777 h_ruler->setReadWrite(kPresenterDoc()->isReadWrite());
3778 v_ruler = new KoRuler( pageBase, m_canvas, TQt::Vertical, kPresenterDoc()->pageLayout(), 0, kPresenterDoc()->unit() );
3779 v_ruler->setReadWrite(kPresenterDoc()->isReadWrite());
3780
3781 int hSpace = v_ruler->minimumSizeHint().width();
3782 int vSpace = h_ruler->minimumSizeHint().height();
3783
3784 m_canvas->resize( m_canvas->width() - hSpace, m_canvas->height() - vSpace );
3785 m_canvas->move( hSpace, vSpace );
3786 h_ruler->setGeometry( hSpace, 0, m_canvas->width(), vSpace );
3787 v_ruler->setGeometry( 0, vSpace, hSpace, m_canvas->height() );
3788
3789 TQObject::connect( h_ruler, TQ_SIGNAL( unitChanged( KoUnit::Unit ) ),
3790 this, TQ_SLOT( unitChanged( KoUnit::Unit ) ) );
3791 TQObject::connect( h_ruler, TQ_SIGNAL( newPageLayout( const KoPageLayout & ) ),
3792 this, TQ_SLOT( newPageLayout( const KoPageLayout & ) ) );
3793
3794 connect( h_ruler, TQ_SIGNAL( doubleClicked() ), this,
3795 TQ_SLOT( slotHRulerDoubleClicked() ) );
3796 connect( h_ruler, TQ_SIGNAL( doubleClicked(double) ), this,
3797 TQ_SLOT( slotHRulerDoubleClicked(double) ) );
3798
3799 TQObject::connect( v_ruler, TQ_SIGNAL( unitChanged( KoUnit::Unit ) ),
3800 this, TQ_SLOT( unitChanged( KoUnit::Unit ) ) );
3801 TQObject::connect( v_ruler, TQ_SIGNAL( newPageLayout( const KoPageLayout & ) ),
3802 this, TQ_SLOT( newPageLayout( const KoPageLayout & ) ) );
3803 TQObject::connect( v_ruler, TQ_SIGNAL( doubleClicked() ),
3804 this, TQ_SLOT( openPageLayoutDia() ) );
3805
3806 connect( h_ruler, TQ_SIGNAL( newLeftIndent( double ) ), this, TQ_SLOT( newLeftIndent( double ) ) );
3807 connect( h_ruler, TQ_SIGNAL( newFirstIndent( double ) ), this, TQ_SLOT( newFirstIndent( double ) ) );
3808 connect( h_ruler, TQ_SIGNAL( newRightIndent( double ) ), this, TQ_SLOT( newRightIndent( double ) ) );
3809}
3810
3811void KPrView::unitChanged( KoUnit::Unit u )
3812{
3813 m_pKPresenterDoc->setUnit( u );
3814}
3815
3816void KPrView::setRanges()
3817{
3818 if ( vert && horz && m_canvas && m_pKPresenterDoc ) {
3819 vert->setSteps( 10, m_canvas->height() );
3820 vert->setRange( 0, TQMAX( 0, m_canvas->activePage()->getZoomPageRect().height() - m_canvas->height() ) );
3821 horz->setSteps( 10, m_canvas->width() );
3822 horz->setRange( 0, TQMAX( 0, m_canvas->activePage()->getZoomPageRect().width() + 16 - m_canvas->width() ) );
3823 }
3824}
3825
3826void KPrView::skipToPage( int num )
3827{
3828 setEditMaster( false );
3829 if ( num < 0 || num > static_cast<int>( m_pKPresenterDoc->getPageNums() ) - 1 || !m_canvas )
3830 return;
3831 m_canvas->exitEditMode();
3832 currPg = num;
3833 emit currentPageChanged( currPg );
3834 if( sidebar )
3835 sidebar->setCurrentPage( currPg );
3836 KPrPage* page = m_pKPresenterDoc->pageList().at( currPg );
3837 m_canvas->setActivePage( page );
3838 // don't scroll before new active page is set,
3839 // the page active until then might have been deleted
3840 vert->setValue( 0 );
3841 horz->setValue( 0 );
3842 if ( notebar ) {
3843 TQString text = page->noteText( );
3844 notebar->setCurrentNoteText( text );
3845 }
3846 refreshPageButton();
3847 //(Laurent) deselect object when we change page.
3848 //otherwise you can change object properties on other page
3849 deSelectAllObjects();
3850 m_pKPresenterDoc->repaint( false );
3851
3852 m_pKPresenterDoc->displayActivePage( page );
3853}
3854
3855void KPrView::refreshPageButton()
3856{
3857 bool state = (currPg > 0);
3858 pgPrev->setEnabled( state );
3859 actionScreenFirst->setEnabled(state);
3860 actionScreenPrev->setEnabled(state);
3861 state=(currPg < (int)m_pKPresenterDoc->getPageNums() - 1);
3862 pgNext->setEnabled( state );
3863 actionScreenLast->setEnabled(state);
3864 actionScreenNext->setEnabled(state);
3865 updateHeaderFooterButton();
3866 updateDisplayObjectMasterPageButton();
3867 updateDisplayBackgroundButton();
3868}
3869
3870void KPrView::showObjectRect( const KPrObject * object )
3871{
3872 TQRect r = zoomHandler()->zoomRect( object->getRealRect() );
3873 if ( ! TQRect( getCanvas()->diffx(),
3874 getCanvas()->diffy(),
3875 getCanvas()->width(),
3876 getCanvas()->height() ).contains( r ) )
3877 {
3878 int x = r.left() - 20;
3879 int y = r.top() - 20;
3880 if ( x < 0 )
3881 {
3882 x = 0;
3883 }
3884 if ( y < 0 )
3885 {
3886 y = 0;
3887 }
3888 horz->setValue( x );
3889 vert->setValue( y );
3890 }
3891}
3892
3893void KPrView::setTool( ToolEditMode toolEditMode )
3894{
3895 switch ( toolEditMode ) {
3896 case TEM_MOUSE:
3897 actionToolsMouse->setChecked( true );
3898 break;
3899 case TEM_ROTATE:
3900 actionToolsRotate->setChecked( true );
3901 break;
3902 case TEM_ZOOM:
3903 actionToolsZoom->setChecked( true );
3904 break;
3905 case INS_LINE:
3906 actionToolsLine->setChecked( true );
3907 break;
3908 case INS_RECT:
3909 actionToolsRectangle->setChecked( true );
3910 break;
3911 case INS_ELLIPSE:
3912 actionToolsCircleOrEllipse->setChecked( true );
3913 break;
3914 case INS_PIE:
3915 actionToolsPie->setChecked( true );
3916 break;
3917 case INS_DIAGRAMM:
3918 actionToolsDiagramm->setChecked( true );
3919 break;
3920 case INS_TABLE:
3921 actionToolsTable->setChecked( true );
3922 break;
3923 case INS_FORMULA:
3924 actionToolsFormula->setChecked( true );
3925 break;
3926 case INS_TEXT:
3927 actionToolsText->setChecked( true );
3928 break;
3929 case INS_AUTOFORM:
3930 actionToolsAutoform->setChecked( true );
3931 break;
3932 default: // Shut up gcc -Wall
3933 break; // Shut up gcc 3.x
3934 }
3935}
3936
3937void KPrView::setRulerMouseShow( bool _show )
3938{
3939 v_ruler->showMousePos( _show );
3940 h_ruler->showMousePos( _show );
3941}
3942
3943void KPrView::setRulerMousePos( int mx, int my )
3944{
3945 v_ruler->setMousePos( mx, my );
3946 h_ruler->setMousePos( mx, my );
3947}
3948
3949void KPrView::enableWebPres()
3950{
3951}
3952
3953void KPrView::enableMSPres()
3954{
3955}
3956
3957bool KPrView::doubleClickActivation() const
3958{
3959 return true;
3960}
3961
3962TQWidget* KPrView::canvas() const
3963{
3964 return m_canvas;
3965}
3966
3967int KPrView::canvasXOffset() const
3968{
3969 return m_canvas->diffx();
3970}
3971
3972int KPrView::canvasYOffset() const
3973{
3974 return m_canvas->diffy();
3975}
3976
3977void KPrView::setCanvasXOffset( int _x )
3978{
3979 m_canvas->setDiffX( _x );
3980}
3981
3982void KPrView::setCanvasYOffset( int _y )
3983{
3984 m_canvas->setDiffY( _y );
3985}
3986
3987int KPrView::getCurrentPresPage() const
3988{
3989 if ( !presStarted )
3990 return -1;
3991
3992 return m_canvas->presPage();
3993}
3994
3995int KPrView::getCurrentPresStep() const
3996{
3997 if ( !presStarted )
3998 return -1;
3999
4000 return m_canvas->presStep();
4001}
4002
4003int KPrView::getPresStepsOfPage() const
4004{
4005 if ( !presStarted )
4006 return -1;
4007
4008 return m_canvas->numPresSteps();
4009}
4010
4011int KPrView::getNumPresPages() const
4012{
4013 if ( !presStarted )
4014 return -1;
4015
4016 return m_canvas->numPresPages();
4017}
4018
4019bool KPrView::gotoPresPage( int pg )
4020{
4021 if ( !presStarted )
4022 return false;
4023
4024 m_canvas->gotoPage( pg );
4025 return true;
4026}
4027
4028void KPrView::nextPage()
4029{
4030 // don't move when on master
4031 if ( m_editMaster )
4032 return;
4033
4034 if ( currPg >= (int)m_pKPresenterDoc->getPageNums() - 1 )
4035 return;
4036
4037 //kdDebug(33001)<<"currPg :"<<currPg<<"m_pKPresenterDoc->getPageNums() :"<<m_pKPresenterDoc->getPageNums()<<endl;
4038 skipToPage( currPg+1 );
4039}
4040
4041void KPrView::prevPage()
4042{
4043 // don't move when on master
4044 if ( m_editMaster )
4045 return;
4046
4047 if ( currPg == 0 )
4048 return;
4049 skipToPage( currPg-1 );
4050}
4051
4052void KPrView::updateSideBar()
4053{
4054 if ( sidebar )
4055 {
4056 sidebar->blockSignals( true );
4057 sidebar->thumbBar()->uptodate = false;
4058 sidebar->outline()->rebuildItems();
4059 sidebar->thumbBar()->rebuildItems();
4060 sidebar->blockSignals( false );
4061 }
4062}
4063
4064void KPrView::updateSideBarItem( KPrPage * page )
4065{
4066 if ( sidebar )
4067 sidebar->updateItem( page );
4068 m_pKPresenterDoc->recalcVariables( VT_STATISTIC );
4069}
4070
4071void KPrView::addSideBarItem( int pos )
4072{
4073 if ( sidebar )
4074 {
4075 sidebar->blockSignals( true );
4076 sidebar->addItem( pos );
4077 sidebar->blockSignals( false );
4078 }
4079}
4080
4081void KPrView::moveSideBarItem( int oldPos, int newPos )
4082{
4083 if ( sidebar )
4084 {
4085 sidebar->blockSignals( true );
4086 sidebar->moveItem( oldPos, newPos );
4087 sidebar->blockSignals( false );
4088 }
4089}
4090
4091void KPrView::removeSideBarItem( int pos )
4092{
4093 if ( sidebar )
4094 {
4095 sidebar->blockSignals( true );
4096 sidebar->removeItem( pos );
4097 sidebar->blockSignals( false );
4098 }
4099}
4100
4101void KPrView::updatePageInfo()
4102{
4103 if (m_sbPageLabel)
4104 m_sbPageLabel->setText( TQString(" ") +
4105 i18n("Slide %1/%2").arg(getCurrPgNum()).arg(m_pKPresenterDoc->getPageNums())+
4106 TQString(" ") );
4107}
4108
4109void KPrView::updateObjectStatusBarItem()
4110{
4111 KStatusBar * sb = statusBar();
4112 int nbObjects = m_canvas->objNums();
4113
4114 if ( m_pKPresenterDoc->showStatusBar() && sb && nbObjects > 0 ) {
4115 int nbSelected = m_canvas->numberOfObjectSelected();
4116
4117 if (nbSelected == 1) {
4118 KoUnit::Unit unit = m_pKPresenterDoc->unit();
4119 //TQString unitName = m_pKPresenterDoc->unitName();
4120 KPrObject * obj = m_canvas->getSelectedObj();
4121 KoSize size = obj->getSize();
4122 m_sbObjectLabel->setText( ' ' + i18n( "Statusbar info", "%1: %2, %3 - %4, %5 (width: %6, height: %7)" )
4123 .arg( /*frame->frameSet()->name()*/obj->getObjectName() )
4124 .arg( KoUnit::toUserStringValue( obj->getOrig().x(), unit ) )
4125 .arg( KoUnit::toUserStringValue( obj->getOrig().y() , unit) )
4126 .arg( KoUnit::toUserStringValue( obj->getOrig().x() + size.width(), unit ) )
4127 .arg( KoUnit::toUserStringValue( obj->getOrig().y() + size.height(), unit ) )
4128 .arg( KoUnit::toUserStringValue( size.width(), unit ) )
4129 .arg( KoUnit::toUserStringValue( size.height(), unit ) ) );
4130 }
4131 else
4132 m_sbObjectLabel->setText( i18n("1 object selected", "%n objects selected", nbSelected) );
4133 }
4134 else if ( sb && m_sbObjectLabel )
4135 m_sbObjectLabel->setText( TQString() );
4136}
4137
4138void KPrView::pageNumChanged()
4139{
4140 updatePageInfo();
4141}
4142
4143void KPrView::viewShowSideBar()
4144{
4145 if ( !sidebar )
4146 return;
4147 if ( sidebar->isVisible() )
4148 sidebar->hide();
4149 else
4150 sidebar->show();
4151}
4152
4153void KPrView::viewShowNoteBar()
4154{
4155 if ( !notebar )
4156 return;
4157 if ( notebar->isVisible() )
4158 notebar->hide();
4159 else
4160 notebar->show();
4161}
4162
4163void KPrView::viewSlideMaster()
4164{
4165 bool state = actionViewSlideMaster->isChecked();
4166 setEditMaster( state );
4167 //not activate action when slide master is displaying
4168 state = !state;
4169 m_actionExtraHeader->setEnabled( state );
4170 m_actionExtraFooter->setEnabled( state );
4171 actionDisplayBackgroundPage->setEnabled( state );
4172 actionDisplayObjectFromMasterPage->setEnabled( state );
4173
4174}
4175
4176void KPrView::setEditMaster( bool editMaster )
4177{
4178 if ( m_editMaster != editMaster )
4179 {
4180 m_canvas->exitEditMode();
4181 m_canvas->deSelectAllObj();
4182 m_editMaster = editMaster;
4183 if ( m_editMaster )
4184 {
4185 m_canvas->setActivePage( m_pKPresenterDoc->masterPage() );
4186 pgPrev->setEnabled( false );
4187 actionScreenFirst->setEnabled( false );
4188 actionScreenPrev->setEnabled( false );
4189 pgNext->setEnabled( false );
4190 actionScreenLast->setEnabled( false );
4191 actionScreenNext->setEnabled( false );
4192 actionEditCopyPage->setEnabled( false );
4193 actionEditDuplicatePage->setEnabled( false );
4194 actionEditDelPage->setEnabled( false );
4195 actionViewSlideMaster->setChecked( true );
4196 }
4197 else
4198 {
4199 m_canvas->setActivePage( m_pKPresenterDoc->pageList().at( currPg ) );
4200 actionEditCopyPage->setEnabled( true );
4201 actionEditDuplicatePage->setEnabled( true );
4202 actionEditDelPage->setEnabled( m_pKPresenterDoc->getPageNums() > 1 );
4203 actionViewSlideMaster->setChecked( false );
4204 refreshPageButton();
4205 }
4206 if ( sidebar )
4207 sidebar->setViewMasterPage( m_editMaster );
4208 updateNoteBarText();
4209 m_canvas->repaint( false );
4210 }
4211}
4212
4213void KPrView::updateNoteBarText()
4214{
4215 if ( notebar ) {
4216 if ( m_editMaster )
4217 {
4218 TQString text = m_pKPresenterDoc->masterPage()->noteText();
4219 notebar->setCurrentNoteText( text );
4220 }
4221 else
4222 {
4223 TQString text = m_pKPresenterDoc->pageList().at( currPg )->noteText( );
4224 notebar->setCurrentNoteText( text );
4225 }
4226 }
4227}
4228
4229void KPrView::openPopupMenuMenuPage( const TQPoint & _point )
4230{
4231 if(!koDocument()->isReadWrite() || !factory())
4232 return;
4233 TQPtrList<TDEAction> actionList= TQPtrList<TDEAction>();
4234 TDEActionSeparator *separator=new TDEActionSeparator();
4235 switch( m_canvas->activePage()->getBackType())
4236 {
4237 case BT_COLOR:
4238 case BT_BRUSH:
4239 break;
4240 case BT_PICTURE:
4241 case BT_CLIPART:
4242 actionList.append(separator);
4243 actionList.append(actionSaveBackgroundPicture);
4244 break;
4245 }
4246 if ( actionList.count()>0)
4247 plugActionList( "picture_action", actionList );
4248 m_mousePos = m_canvas->mapFromGlobal( _point );
4249 TQPopupMenu* menu = dynamic_cast<TQPopupMenu*>(factory()->container("menupage_popup",this));
4250 if ( menu )
4251 menu->exec(_point);
4252 m_mousePos = TQPoint( 0, 0 );
4253 unplugActionList( "picture_action" );
4254 delete separator;
4255}
4256
4257void KPrView::openPopupMenuObject( const TQString & name, const TQPoint & _point )
4258{
4259 if(!koDocument()->isReadWrite() || !factory())
4260 return;
4261 dynamic_cast<TQPopupMenu*>(factory()->container(name, this))->popup(_point);
4262}
4263
4264void KPrView::openPopupMenuSideBar(const TQPoint & _point)
4265{
4266 if(!koDocument()->isReadWrite() || !factory())
4267 return;
4268 dynamic_cast<TQPopupMenu*>(factory()->container("sidebarmenu_popup", this))->popup(_point);
4269}
4270
4271void KPrView::renamePageTitle()
4272{
4273 if(sidebar)
4274 sidebar->renamePageTitle();
4275}
4276
4277void KPrView::picViewOriginalSize()
4278{
4279 m_canvas->picViewOriginalSize();
4280}
4281
4282void KPrView::picViewOrig640x480()
4283{
4284 m_canvas->picViewOrig640x480();
4285}
4286
4287void KPrView::picViewOrig800x600()
4288{
4289 m_canvas->picViewOrig800x600();
4290}
4291
4292void KPrView::picViewOrig1024x768()
4293{
4294 m_canvas->picViewOrig1024x768();
4295}
4296
4297void KPrView::picViewOrig1280x1024()
4298{
4299 m_canvas->picViewOrig1280x1024();
4300}
4301
4302void KPrView::picViewOrig1600x1200()
4303{
4304 m_canvas->picViewOrig1600x1200();
4305}
4306
4307void KPrView::chPic()
4308{
4309 m_canvas->chPic();
4310}
4311
4312void KPrView::penColorChanged( const KoPen & _pen )
4313{
4314 //actionPenColor->setEnabled( true );
4315 actionPenColor->setCurrentColor( _pen.color() );
4316}
4317
4318void KPrView::brushColorChanged( const TQBrush & _brush )
4319{
4320 //actionBrushColor->setEnabled( true );
4321 actionBrushColor->setCurrentColor(_brush.style ()==TQt::NoBrush ? TQt::white : _brush.color() );
4322}
4323
4324void KPrView::restartAutoPresTimer()
4325{
4326 m_autoPresTime.start();
4327 m_autoPresElapsedTime = 0;
4328 m_autoPresTimer.start( m_autoPresTimerValue, true );
4329}
4330
4331void KPrView::continueAutoPresTimer()
4332{
4333 m_autoPresTime.restart();
4334 //m_autoPresTimer.changeInterval( m_autoPresTimerValue - m_autoPresElapsedTime );
4335 m_autoPresTimer.start( m_autoPresTimerValue - m_autoPresElapsedTime, true );
4336}
4337
4338void KPrView::stopAutoPresTimer()
4339{
4340 m_autoPresTimer.stop();
4341 m_autoPresElapsedTime += m_autoPresTime.elapsed();
4342}
4343
4344void KPrView::setAutoPresTimer( int sec )
4345{
4346 m_autoPresTimerValue = sec * 1000;
4347 restartAutoPresTimer();
4348}
4349
4350void KPrView::insertSpecialChar()
4351{
4352 KPrTextView *edit=m_canvas->currentTextObjectView();
4353 if ( !edit )
4354 return;
4355 TQString f = edit->textFontFamily();
4356 TQChar c=' ';
4357 if (m_specialCharDlg==0)
4358 {
4359 m_specialCharDlg = new KoCharSelectDia( this, "insert special char", f, c, false );
4360 connect( m_specialCharDlg, TQ_SIGNAL(insertChar(TQChar,const TQString &)),
4361 this, TQ_SLOT(slotSpecialChar(TQChar,const TQString &)));
4362 connect( m_specialCharDlg, TQ_SIGNAL( finished() ),
4363 this, TQ_SLOT( slotSpecialCharDlgClosed() ) );
4364 }
4365 m_specialCharDlg->show();
4366}
4367
4368void KPrView::slotSpecialCharDlgClosed()
4369{
4370 if ( m_specialCharDlg)
4371 {
4372 disconnect( m_specialCharDlg, TQ_SIGNAL(insertChar(TQChar,const TQString &)),
4373 this, TQ_SLOT(slotSpecialChar(TQChar,const TQString &)));
4374 disconnect( m_specialCharDlg, TQ_SIGNAL( finished() ),
4375 this, TQ_SLOT( slotSpecialCharDlgClosed() ) );
4376 m_specialCharDlg->deleteLater();
4377 m_specialCharDlg = 0L;
4378 }
4379}
4380
4381void KPrView::slotSpecialChar(TQChar c, const TQString &_font)
4382{
4383 KPrTextView *edit=m_canvas->currentTextObjectView();
4384 if ( !edit )
4385 return;
4386 edit->insertSpecialChar(c, _font);
4387}
4388
4389void KPrView::insertLink()
4390{
4391 KPrTextView *edit=m_canvas->currentTextObjectView();
4392 if ( !edit )
4393 return;
4394 TQString link;
4395 TQString ref;
4396 if ( edit->textObject()->hasSelection() )
4397 {
4398 TQString selectedText = edit->textObject()->selectedText();
4399 if ( edit->textObject()->selectionHasCustomItems() || selectedText.contains('\n') )
4400 return;
4401 if ( selectedText.startsWith( "mailto:/" ) ||
4402 selectedText.startsWith( "ftp:/" ) ||
4403 selectedText.startsWith( "http:/" ) )
4404 {
4405 link=selectedText;
4406 ref = selectedText;
4407 }
4408 else
4409 {
4410 //Just add text as link name and not url
4411 link = selectedText;
4412 }
4413 }
4414
4415 if(KoInsertLinkDia::createLinkDia(link, ref, TQStringList(), false, this))
4416 {
4417 if(!link.isEmpty() && !ref.isEmpty())
4418 edit->insertLink(link, ref);
4419 }
4420}
4421
4422void KPrView::changeLink()
4423{
4424 KPrTextView * edit = m_canvas->currentTextObjectView();
4425 if ( edit )
4426 {
4427 KoLinkVariable * var=edit->linkVariable();
4428 if(var)
4429 {
4430 TQString oldhref= var->url();
4431 TQString oldLinkName=var->value();
4432 TQString link=oldLinkName;
4433 TQString ref=oldhref;
4434 if(KoInsertLinkDia::createLinkDia(link, ref, TQStringList(), false, this))
4435 {
4436 if(!link.isEmpty() && !ref.isEmpty())
4437 {
4438 if( ref != oldhref || link!=oldLinkName)
4439 {
4440 KPrChangeLinkVariable*cmd=new KPrChangeLinkVariable( i18n("Change Link"),
4441 m_pKPresenterDoc, oldhref,
4442 ref, oldLinkName,link, var);
4443 cmd->execute();
4444 m_pKPresenterDoc->addCommand(cmd);
4445 }
4446 }
4447 }
4448 }
4449 }
4450}
4451
4452void KPrView::showFormat( const KoTextFormat &currentFormat )
4453{
4454 actionTextFontFamily->setFont( currentFormat.font().family() );
4455 actionTextFontSize->setFontSize( currentFormat.pointSize() );
4456 actionTextBold->setChecked( currentFormat.font().bold());
4457 actionTextItalic->setChecked( currentFormat.font().italic() );
4458 actionTextUnderline->setChecked( currentFormat.underline());
4459 actionFormatStrikeOut->setChecked( currentFormat.strikeOut());
4460
4461 actionBrushColor->setEnabled(true);
4462 //actionBrushColor->setText(i18n("Text Background Color..."));
4463
4464 switch(currentFormat.vAlign())
4465 {
4466 case KoTextFormat::AlignSuperScript:
4467 {
4468 actionFormatSub->setChecked( false );
4469 actionFormatSuper->setChecked( true );
4470 break;
4471 }
4472 case KoTextFormat::AlignSubScript:
4473 {
4474 actionFormatSub->setChecked( true );
4475 actionFormatSuper->setChecked( false );
4476 break;
4477 }
4478 case KoTextFormat::AlignNormal:
4479 default:
4480 {
4481 actionFormatSub->setChecked( false );
4482 actionFormatSuper->setChecked( false );
4483 break;
4484 }
4485 }
4486}
4487
4488void KPrView::slotSoftHyphen()
4489{
4490 KPrTextView *edit = m_canvas->currentTextObjectView();
4491 if ( edit )
4492 edit->insertSoftHyphen();
4493}
4494
4495void KPrView::slotNonbreakingSpace()
4496{
4497 KPrTextView *edit=m_canvas->currentTextObjectView();
4498 if ( edit )
4499 edit->insertNonbreakingSpace();
4500}
4501
4502void KPrView::slotNonbreakingHyphen()
4503{
4504 KPrTextView *edit=m_canvas->currentTextObjectView();
4505 if ( edit )
4506 edit->insertNonbreakingHyphen();
4507}
4508
4509void KPrView::slotLineBreak()
4510{
4511 KPrTextView *edit=m_canvas->currentTextObjectView();
4512 if ( edit )
4513 edit->insertLineBreak();
4514}
4515
4516void KPrView::slotIncreaseNumberingLevel()
4517{
4518 KPrTextView *edit=m_canvas->currentTextObjectView();
4519 if ( edit )
4520 {
4521 edit->increaseNumberingLevel( m_pKPresenterDoc->styleCollection() );
4522 }
4523}
4524
4525void KPrView::slotDecreaseNumberingLevel()
4526{
4527 KPrTextView *edit=m_canvas->currentTextObjectView();
4528 if ( edit )
4529 edit->decreaseNumberingLevel( m_pKPresenterDoc->styleCollection() );
4530}
4531
4532void KPrView::extraAutoFormat()
4533{
4534 m_pKPresenterDoc->getAutoFormat()->readConfig();
4535 KoAutoFormatDia dia( this, 0, m_pKPresenterDoc->getAutoFormat() );
4536 dia.exec();
4537 m_pKPresenterDoc->startBackgroundSpellCheck(); // will do so if enabled
4538}
4539
4540void KPrView::slotSpellCheck()
4541{
4542 if (m_spell.kospell) return; // Already in progress
4543 //m_doc->setReadWrite(false); // prevent editing text - not anymore
4544 m_spell.macroCmdSpellCheck = 0L;
4545 m_spell.replaceAll.clear();
4546 TQValueList<KoTextObject *> objects;
4547 KPrTextView *edit=m_canvas->currentTextObjectView();
4548 int options = 0;
4549 if ( edit && edit->textObject()->hasSelection() )
4550 {
4551 objects.append(edit->kpTextObject()->textObject());
4552 options = KFindDialog::SelectedText;
4553 }
4554 else
4555 {
4556 objects = spellAddTextObject();
4557 TQPtrList<KPrObject> lstObj;
4558 }
4559 if ( ! objects.empty() )
4560 {
4561 m_spell.textIterator = new KoTextIterator( objects, edit, options );
4562 startKSpell();
4563 }
4564}
4565
4566TQValueList<KoTextObject *> KPrView::spellAddTextObject() const
4567{
4568 TQValueList<KoTextObject *> lst;
4569 TQPtrList<KPrObject> lstObj;
4570 m_canvas->activePage()->getAllObjectSelectedList(lstObj, true);
4571 TQPtrListIterator<KPrObject> it( lstObj );
4572 for ( ; it.current() ; ++it )
4573 {
4574 if(it.current()->getType()==OT_TEXT)
4575 {
4576 KPrTextObject* tmp = dynamic_cast<KPrTextObject*>(it.current() );
4577 if ( tmp && !tmp->isProtectContent())
4578 lst.append( tmp->textObject() );
4579 }
4580 }
4581 return lst;
4582}
4583
4584
4585
4586void KPrView::startKSpell()
4587{
4588 // m_spellCurrFrameSetNum is supposed to be set by the caller of this method
4589 if ( !m_spell.kospell )
4590 m_spell.kospell = new KoSpell( m_broker, this );
4591 m_spell.kospell->check( m_spell.textIterator, true );
4592
4593 delete m_spell.dlg;
4594 m_spell.dlg = new KSpell2::Dialog( m_spell.kospell, this );
4595 m_spell.dlg->activeAutoCorrect( true );
4596 TQObject::connect( m_spell.dlg, TQ_SIGNAL(misspelling(const TQString&, int)),
4597 this, TQ_SLOT(spellCheckerMisspelling(const TQString&, int)) );
4598 TQObject::connect( m_spell.dlg, TQ_SIGNAL(replace(const TQString&, int, const TQString&)),
4599 this, TQ_SLOT(spellCheckerCorrected(const TQString&, int, const TQString&)) );
4600 TQObject::connect( m_spell.dlg, TQ_SIGNAL(done(const TQString&) ),
4601 this, TQ_SLOT(spellCheckerDone(const TQString&)) );
4602 TQObject::connect( m_spell.dlg, TQ_SIGNAL(cancel() ),
4603 this, TQ_SLOT( spellCheckerCancel() ) );
4604 TQObject::connect( m_spell.dlg, TQ_SIGNAL(autoCorrect(const TQString &, const TQString & ) ),
4605 this, TQ_SLOT( spellAddAutoCorrect (const TQString &, const TQString &) ) );
4606
4607 m_spell.dlg->show();
4608}
4609
4610
4611
4612void KPrView::spellCheckerCancel()
4613{
4614 kdDebug()<<"void KPrView::spellCheckerCancel() \n";
4615 spellCheckerRemoveHighlight();
4616 clearSpellChecker(true);
4617}
4618
4619
4620void KPrView::spellCheckerRemoveHighlight()
4621{
4622 KoTextObject* textobj = m_spell.kospell->currentTextObject();
4623 if ( textobj ) {
4624 KPrTextDocument *textdoc=static_cast<KPrTextDocument *>( textobj->textDocument() );
4625 if ( textdoc )
4626 textdoc->textObject()->removeHighlight();
4627 }
4628 KPrTextView *edit=m_canvas->currentTextObjectView();
4629 if (edit)
4630 edit->drawCursor( true );
4631}
4632
4633
4634void KPrView::clearSpellChecker(bool cancelSpellCheck)
4635{
4636 kdDebug() << "KPrView::clearSpellChecker()" << endl;
4637 delete m_spell.textIterator;
4638 m_spell.textIterator = 0L;
4639
4640
4641 delete m_spell.kospell;
4642 m_spell.kospell = 0;
4643 m_initSwitchPage = -1;
4644 m_switchPage = -1;
4645
4646 if ( m_spell.macroCmdSpellCheck )
4647 {
4648 if ( !cancelSpellCheck )
4649 m_pKPresenterDoc->addCommand(m_spell.macroCmdSpellCheck);
4650 else
4651 {
4652 //reverte all changes
4653 m_spell.macroCmdSpellCheck->unexecute();
4654 delete m_spell.macroCmdSpellCheck;
4655 }
4656 }
4657 m_spell.macroCmdSpellCheck=0L;
4658
4659 m_spell.replaceAll.clear();
4660
4661}
4662
4663void KPrView::spellCheckerMisspelling( const TQString &old, int pos )
4664{
4665 //kdDebug(32001) << "KWView::spellCheckerMisspelling old=" << old << " pos=" << pos << endl;
4666 KoTextObject* textobj = m_spell.kospell->currentTextObject();
4667 KoTextParag* parag = m_spell.kospell->currentParag();
4668 Q_ASSERT( textobj );
4669 Q_ASSERT( parag );
4670 if ( !textobj || !parag ) return;
4671 KPrTextDocument *textdoc=static_cast<KPrTextDocument *>( textobj->textDocument() );
4672 Q_ASSERT( textdoc );
4673 if ( !textdoc ) return;
4674 pos += m_spell.kospell->currentStartIndex();
4675
4676 kdDebug() << "KWView::spellCheckerMisspelling parag=" << parag->paragId() << " pos=" << pos << " length=" << old.length() << endl;
4677
4678 textdoc->textObject()->highlightPortion( parag, pos, old.length(), m_canvas,true/*repaint*/ );
4679}
4680
4681void KPrView::spellCheckerCorrected( const TQString &old, int pos, const TQString &corr )
4682{
4683 //kdDebug(33001) << "KWView::spellCheckerCorrected old=" << old << " corr=" << corr << " pos=" << pos << endl;
4684
4685 //kdDebug(32001) << "KWView::spellCheckerCorrected old=" << old << " corr=" << corr << " pos=" << pos << endl;
4686 KoTextObject* textobj = m_spell.kospell->currentTextObject();
4687 KoTextParag* parag = m_spell.kospell->currentParag();
4688 Q_ASSERT( textobj );
4689 Q_ASSERT( parag );
4690 if ( !textobj || !parag ) return;
4691
4692 KPrTextDocument *textdoc=static_cast<KPrTextDocument *>( textobj->textDocument() );
4693 Q_ASSERT( textdoc );
4694 if ( !textdoc )
4695 return;
4696 pos += m_spell.kospell->currentStartIndex();
4697 textdoc->textObject()->highlightPortion( parag, pos, old.length(), m_canvas,true/*repaint*/ );
4698
4699 KoTextCursor cursor( textdoc );
4700 cursor.setParag( parag );
4701 cursor.setIndex( pos );
4702 if(!m_spell.macroCmdSpellCheck)
4703 m_spell.macroCmdSpellCheck=new KMacroCommand(i18n("Correct Misspelled Word"));
4704 m_spell.macroCmdSpellCheck->addCommand(textobj->replaceSelectionCommand(&cursor, corr, TQString(), KoTextDocument::HighlightSelection));
4705}
4706
4707void KPrView::spellCheckerDone( const TQString & )
4708{
4709 /* See also KWView::spellCheckerDone from KWord */
4710 kdDebug() << "KPrView::spellCheckerDone" << endl;
4711 KPrTextDocument *textdoc=static_cast<KPrTextDocument *>( m_spell.kospell->textDocument() );
4712 Q_ASSERT( textdoc );
4713 if ( textdoc )
4714 textdoc->textObject()->removeHighlight();
4715
4716 clearSpellChecker();
4717}
4718
4719void KPrView::showCounter( KoParagCounter &c )
4720{
4721 TQString styleStr("counterstyle_");
4722 styleStr += TQString::number( c.style() );
4723 //kdDebug(33001) << "KWView::showCounter styleStr=" << styleStr << endl;
4724 TDEToggleAction* act = static_cast<TDEToggleAction *>( actionCollection()->action( styleStr.latin1() ) );
4725 Q_ASSERT( act );
4726 if ( act )
4727 act->setChecked( true );
4728}
4729
4730void KPrView::formatParagraph()
4731{
4732 showParagraphDialog();
4733}
4734
4735void KPrView::showParagraphDialog(int initialPage, double initialTabPos)
4736{
4737 TQPtrList<KoTextFormatInterface> lst = m_canvas->applicableTextInterfaces();
4738 if ( lst.isEmpty() )
4739 return;
4740 TQPtrList<KPrTextObject> lstObjects = m_canvas->applicableTextObjects();
4741 if ( lstObjects.isEmpty() )
4742 return;
4743
4744 delete m_paragDlg;
4745 m_paragDlg = new KoParagDia( this, "",
4746 KoParagDia::PD_SPACING | KoParagDia::PD_ALIGN |
4747 KoParagDia::PD_DECORATION | KoParagDia::PD_NUMBERING |
4748 KoParagDia::PD_TABS,
4749 m_pKPresenterDoc->unit(),
4750 lstObjects.first()->getSize().width(),false );
4751 m_paragDlg->setCaption( i18n( "Paragraph Settings" ) );
4752
4753 // Initialize the dialog from the current paragraph's settings
4754 m_paragDlg->setParagLayout( * lst.first()->currentParagLayoutFormat() );
4755 // Set initial page and initial tabpos if necessary
4756 if ( initialPage != -1 )
4757 {
4758 m_paragDlg->setCurrentPage( initialPage );
4759 if ( initialPage == KoParagDia::PD_TABS )
4760 m_paragDlg->tabulatorsWidget()->setCurrentTab( initialTabPos );
4761 }
4762 connect( m_paragDlg, TQ_SIGNAL( applyParagStyle() ), this, TQ_SLOT( slotApplyParag() ) );
4763
4764 m_paragDlg->exec();
4765 delete m_paragDlg;
4766 m_paragDlg = 0;
4767
4768}
4769
4770void KPrView::slotApplyParag()
4771{
4772 TQPtrList<KoTextFormatInterface> lst = m_canvas->applicableTextInterfaces();
4773 Q_ASSERT( !lst.isEmpty() );
4774 if ( lst.isEmpty() ) return;
4775 TQPtrListIterator<KoTextFormatInterface> it( lst );
4776 KMacroCommand * macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
4777 KoParagLayout newLayout = m_paragDlg->paragLayout();
4778 int flags = m_paragDlg->changedFlags();
4779 kdDebug() << k_funcinfo << "flags=" << flags << endl;
4780 if ( !flags )
4781 return;
4782 for ( ; it.current() ; ++it )
4783 {
4784 KCommand* cmd = it.current()->setParagLayoutFormatCommand( &newLayout, flags );
4785 Q_ASSERT( cmd );
4786 if(cmd)
4787 {
4788 macroCommand->addCommand(cmd);
4789 }
4790 }
4791
4792 if(flags)
4793 m_pKPresenterDoc->addCommand(macroCommand);
4794 else
4795 delete macroCommand;
4796
4797 // Set "oldLayout" in KoParagDia from the current paragraph's settings
4798 // Otherwise "isBlahChanged" will return wrong things when doing A -> B -> A
4799 m_paragDlg->setParagLayout( *lst.first()->currentParagLayoutFormat() );
4800}
4801
4802void KPrView::textDefaultFormat()
4803{
4804 m_canvas->setTextDefaultFormat( );
4805}
4806
4807void KPrView::changeNbOfRecentFiles(int _nb)
4808{
4809 if ( shell() ) // 0 when embedded into konq !
4810 shell()->setMaxRecentItems( _nb );
4811}
4812
4813TQPopupMenu * KPrView::popupMenu( const TQString& name )
4814{
4815 Q_ASSERT(factory());
4816 if ( factory() )
4817 return ((TQPopupMenu*)factory()->container( name, this ));
4818 return 0L;
4819}
4820
4821void KPrView::addVariableActions( int type, const TQStringList & texts,
4822 TDEActionMenu * parentMenu, const TQString & menuText )
4823{
4824 // Single items go directly into parentMenu.
4825 // For multiple items we create a submenu.
4826 if ( texts.count() > 1 && !menuText.isEmpty() )
4827 {
4828 TDEActionMenu * subMenu = new TDEActionMenu( menuText, actionCollection() );
4829 parentMenu->insert( subMenu );
4830 parentMenu = subMenu;
4831 }
4832 TQStringList::ConstIterator it = texts.begin();
4833 for ( int i = 0; it != texts.end() ; ++it, ++i )
4834 {
4835 if ( !(*it).isEmpty() ) // in case of removed subtypes or placeholders
4836 {
4837 VariableDef v;
4838 v.type = type;
4839 v.subtype = i;
4840 TDEAction * act = new TDEAction( (*it), 0, this, TQ_SLOT( insertVariable() ),
4841 actionCollection(), "var-action" );
4842 m_variableDefMap.insert( act, v );
4843 parentMenu->insert( act );
4844 }
4845 }
4846}
4847
4848void KPrView::refreshCustomMenu()
4849{
4850 TDEActionPtrList lst2 = actionCollection()->actions("custom-variable-action");
4851 TQValueList<TDEAction *> actions = lst2;
4852 TQValueList<TDEAction *>::ConstIterator it2 = lst2.begin();
4853 TQValueList<TDEAction *>::ConstIterator end = lst2.end();
4854 TQMap<TQString, TDEShortcut> shortCuts;
4855
4856 for (; it2 != end; ++it2 )
4857 {
4858 shortCuts.insert((*it2)->text(), (*it2)->shortcut());
4859 delete *it2;
4860 }
4861
4862 delete actionInsertCustom;
4863 actionInsertCustom = new TDEActionMenu( i18n( "&Custom" ),
4864 actionCollection(), "insert_custom" );
4865
4866 actionInsertVariable->insert(actionInsertCustom, 0);
4867
4868
4869 actionInsertCustom->popupMenu()->clear();
4870 TQPtrListIterator<KoVariable> it( m_pKPresenterDoc->getVariableCollection()->getVariables() );
4871 TDEAction * act=0;
4872 TQStringList lst;
4873 TQString varName;
4874 int i = 0;
4875 for ( ; it.current() ; ++it )
4876 {
4877 KoVariable *var = it.current();
4878 if ( var->type() == VT_CUSTOM )
4879 {
4880 varName=( (KoCustomVariable*) var )->name();
4881 if ( !lst.contains( varName) )
4882 {
4883 lst.append( varName );
4884 TQCString name = TQString("custom-action_%1").arg(i).latin1();
4885 act = new TDEAction( varName, shortCuts[varName], this,
4886 TQ_SLOT( insertCustomVariable() ), actionCollection(), name );
4887
4888 act->setGroup( "custom-variable-action" );
4889 actionInsertCustom->insert( act );
4890 i++;
4891 }
4892 }
4893 }
4894 bool state=!lst.isEmpty();
4895 if(state)
4896 actionInsertCustom->popupMenu()->insertSeparator();
4897
4898 act = new TDEAction( i18n("New..."), 0, this, TQ_SLOT( insertNewCustomVariable() ), actionCollection(),
4899 TQString("custom-action_%1").arg(i).latin1() );
4900 act->setGroup( "custom-variable-action" );
4901 actionInsertCustom->insert( act );
4902
4903 actionInsertCustom->popupMenu()->insertSeparator();
4904
4905 actionEditCustomVars->setEnabled(state);
4906 actionEditCustomVarsEdit->setEnabled( state );
4907 actionInsertCustom->insert( actionEditCustomVarsEdit );
4908}
4909
4910void KPrView::insertCustomVariable()
4911{
4912 KPrTextView *edit=m_canvas->currentTextObjectView();
4913 if ( edit )
4914 {
4915 TDEAction * act = (TDEAction *)(sender());
4916 edit->insertCustomVariable(act->text());
4917 }
4918}
4919
4920void KPrView::insertNewCustomVariable()
4921{
4922 KPrTextView *edit=m_canvas->currentTextObjectView();
4923 if ( edit )
4924 edit->insertVariable( VT_CUSTOM, 0 );
4925}
4926
4927void KPrView::editCustomVariable()
4928{
4929 KPrTextView *edit=m_canvas->currentTextObjectView();
4930 if ( edit )
4931 {
4932 KoCustomVariable *var = static_cast<KoCustomVariable *>(edit->variable());
4933 if (var)
4934 {
4935 TQString oldvalue = var->value();
4936 KoCustomVarDialog dia( this, var );
4937 if ( dia.exec() )
4938 {
4939 if( var->value() != oldvalue )
4940 {
4941 KPrChangeCustomVariableValue *cmd=new KPrChangeCustomVariableValue(i18n( "Change Custom Variable" ),
4942 m_pKPresenterDoc, oldvalue, var->value(), var );
4943 m_pKPresenterDoc->addCommand(cmd);
4944 }
4945 m_pKPresenterDoc->recalcVariables( VT_CUSTOM );
4946 }
4947 }
4948 }
4949}
4950
4951void KPrView::editCustomVars()
4952{
4953 KoCustomVariablesDia dia( this, m_pKPresenterDoc->getVariableCollection()->getVariables() );
4954 TQStringList listOldCustomValue;
4955 TQPtrListIterator<KoVariable> oldIt( m_pKPresenterDoc->getVariableCollection()->getVariables() );
4956 for ( ; oldIt.current() ; ++oldIt )
4957 {
4958 if(oldIt.current()->type()==VT_CUSTOM)
4959 listOldCustomValue.append(((KoCustomVariable*)oldIt.current())->value());
4960 }
4961 if(dia.exec())
4962 {
4963 m_pKPresenterDoc->recalcVariables( VT_CUSTOM );
4964 TQPtrListIterator<KoVariable> it( m_pKPresenterDoc->getVariableCollection()->getVariables() );
4965 KMacroCommand * macroCommand = 0L;
4966 int i=0;
4967 for ( ; it.current() ; ++it )
4968 {
4969 if(it.current()->type() == VT_CUSTOM )
4970 {
4971 if(((KoCustomVariable*)it.current())->value()!=*(listOldCustomValue.at(i)))
4972 {
4973 if(!macroCommand)
4974 macroCommand = new KMacroCommand( i18n( "Change Custom Variable" ) );
4975 KPrChangeCustomVariableValue *cmd=
4976 new KPrChangeCustomVariableValue(i18n( "Change Custom Variable" ), m_pKPresenterDoc,
4977 *(listOldCustomValue.at(i)),
4978 ((KoCustomVariable*)it.current())->value(),
4979 ((KoCustomVariable*)it.current()));
4980 macroCommand->addCommand(cmd);
4981 }
4982 i++;
4983 }
4984 }
4985 if(macroCommand)
4986 m_pKPresenterDoc->addCommand(macroCommand);
4987 }
4988}
4989
4990void KPrView::insertVariable()
4991{
4992 KPrTextView *edit=m_canvas->currentTextObjectView();
4993 if ( edit )
4994 {
4995 TDEAction * act = (TDEAction *)(sender());
4996 VariableDefMap::ConstIterator it = m_variableDefMap.find( act );
4997 if ( it == m_variableDefMap.end() )
4998 kdWarning(33001) << "Action not found in m_variableDefMap." << endl;
4999 else
5000 {
5001 if ( (*it).type == VT_FIELD )
5002 edit->insertVariable( (*it).type, KoFieldVariable::fieldSubType( (*it).subtype ) );
5003 else
5004 edit->insertVariable( (*it).type, (*it).subtype );
5005 }
5006 }
5007}
5008
5009void KPrView::openLink()
5010{
5011 KPrTextView *edit=m_canvas->currentTextObjectView();
5012 if ( edit )
5013 edit->openLink();
5014}
5015
5016void KPrView::showRulerIndent( double _leftMargin, double _firstLine, double _rightMargin, bool rtl )
5017{
5018 KoRuler * hRuler = getHRuler();
5019 if ( hRuler )
5020 {
5021 hRuler->setFirstIndent( KoUnit::toUserValue( _firstLine, m_pKPresenterDoc->unit() ) );
5022 hRuler->setLeftIndent( KoUnit::toUserValue( _leftMargin, m_pKPresenterDoc->unit() ) );
5023 hRuler->setRightIndent( KoUnit::toUserValue( _rightMargin, m_pKPresenterDoc->unit() ) );
5024 hRuler->setDirection( rtl );
5025 actionTextDepthMinus->setEnabled( _leftMargin>0);
5026 }
5027}
5028
5029void KPrView::tabListChanged( const KoTabulatorList & tabList )
5030{
5031 if(!m_pKPresenterDoc->isReadWrite())
5032 return;
5033
5034 m_canvas->setTabList( tabList );
5035}
5036
5037void KPrView::newFirstIndent( double _firstIndent )
5038{
5039 m_canvas->setNewFirstIndent(_firstIndent);
5040}
5041
5042void KPrView::newLeftIndent( double _leftIndent)
5043{
5044 m_canvas->setNewLeftIndent(_leftIndent);
5045}
5046
5047void KPrView::newRightIndent( double _rightIndent)
5048{
5049 m_canvas->setNewRightIndent(_rightIndent);
5050}
5051
5052void KPrView::slotUpdateRuler()
5053{
5054 // Set the "frame start" in the ruler (tabs are relative to that position)
5055 bool isText=!m_canvas->applicableTextObjects().isEmpty();
5056 if ( isText )
5057 {
5058 KPrTextObject *txtobj= m_canvas->applicableTextObjects().first();
5059 if ( txtobj )
5060 {
5061 TQRect r= zoomHandler()->zoomRect(txtobj->getRealRect());
5062 getHRuler()->setFrameStartEnd( r.left() /*+ m_canvas->diffx()*//*- pc.x()*/, r.right()/*+m_canvas->diffx()*/ /*- pc.x()*/ );
5063 getVRuler()->setFrameStartEnd( r.top()/*+ m_canvas->diffy()*//*- pc.y()*/, r.bottom()/*+m_canvas->diffy()*//*- pc.y()*/ );
5064 if( getHRuler())
5065 {
5066 int flags = txtobj->isProtectContent() ? 0 : (KoRuler::F_INDENTS | KoRuler::F_TABS);
5067 if( getHRuler()->flags()!= flags )
5068 {
5069 getHRuler()->changeFlags(flags);
5070 getHRuler()->repaint();
5071 }
5072 }
5073 if( getVRuler())
5074 {
5075 if( getVRuler()->flags() != 0 )
5076 {
5077 getVRuler()->changeFlags(0);
5078 getVRuler()->repaint();
5079 }
5080 }
5081 }
5082 }
5083 else
5084 {
5085 refreshRuler( kPresenterDoc()->showGuideLines() );
5086 updateRuler();
5087 }
5088}
5089
5090// This handles Tabulators _only_
5091void KPrView::slotHRulerDoubleClicked( double ptpos )
5092{
5093 showParagraphDialog( KoParagDia::PD_TABS, ptpos );
5094}
5095
5096// This handles either:
5097// - Indents
5098// - Page Layout
5099//
5100// This does _not_ handle Tabulators!
5101void KPrView::slotHRulerDoubleClicked()
5102{
5103 KoRuler *ruler = getHRuler();
5104
5105 if ( m_canvas && m_canvas->currentTextObjectView() && (ruler->flags() & KoRuler::F_INDENTS) && ruler->doubleClickedIndent() )
5106 formatParagraph();
5107 else
5108 openPageLayoutDia();
5109}
5110
5111void KPrView::changeCaseOfText()
5112{
5113 TQPtrList<KoTextFormatInterface> lst = m_canvas->applicableTextInterfaces();
5114 if ( lst.isEmpty() ) return;
5115 TQPtrListIterator<KoTextFormatInterface> it( lst );
5116 KoChangeCaseDia *caseDia=new KoChangeCaseDia( this,"change case" );
5117 if(caseDia->exec())
5118 {
5119 KMacroCommand* macroCmd = 0L;
5120 for ( ; it.current() ; ++it )
5121 {
5122 KCommand *cmd = it.current()->setChangeCaseOfTextCommand(caseDia->getTypeOfCase());
5123 if (cmd)
5124 {
5125 if ( !macroCmd )
5126 macroCmd = new KMacroCommand( i18n("Change Case of Text") );
5127 macroCmd->addCommand(cmd);
5128 }
5129 }
5130 if( macroCmd )
5131 m_pKPresenterDoc->addCommand(macroCmd);
5132 }
5133 delete caseDia;
5134}
5135
5136void KPrView::editFind()
5137{
5138 if (!m_searchEntry)
5139 m_searchEntry = new KoSearchContext();
5140 KPrTextView * edit = m_canvas->currentTextObjectView();
5141 bool hasSelection = edit && (edit->kpTextObject())->textObject()->hasSelection();
5142 bool hasCursor = edit != 0;
5143 KoSearchDia dialog( m_canvas, "find", m_searchEntry, hasSelection, hasCursor );
5144
5146 TQValueList<KoTextObject *> list;
5147 TQPtrList<KoTextObject> list2 = m_pKPresenterDoc->allTextObjects();
5148 TQPtrListIterator<KoTextObject> it( list2 );
5149 for ( ; it.current() ; ++it )
5150 list.append(it.current());
5151
5152 if( list.isEmpty() )
5153 return;
5154
5155 if ( dialog.exec() == TQDialog::Accepted )
5156 {
5157 delete m_findReplace;
5158 m_findReplace = new KPrFindReplace( this, m_canvas, &dialog, list, edit );
5159 editFindNext();
5160 }
5161}
5162
5163void KPrView::editReplace()
5164{
5165 if (!m_searchEntry)
5166 m_searchEntry = new KoSearchContext();
5167 if (!m_replaceEntry)
5168 m_replaceEntry = new KoSearchContext();
5169
5170 KPrTextView * edit = m_canvas->currentTextObjectView();
5171 bool hasSelection = edit && (edit->kpTextObject())->textObject()->hasSelection();
5172 bool hasCursor = edit != 0;
5173 KoReplaceDia dialog( m_canvas, "replace", m_searchEntry, m_replaceEntry, hasSelection, hasCursor );
5174
5176 TQValueList<KoTextObject *> list;
5177 TQPtrList<KoTextObject> list2 = m_pKPresenterDoc->allTextObjects();
5178 TQPtrListIterator<KoTextObject> it( list2 );
5179 for ( ; it.current() ; ++it )
5180 list.append(it.current());
5181
5182 if( list.isEmpty() )
5183 return;
5184
5185 if ( dialog.exec() == TQDialog::Accepted )
5186 {
5187 delete m_findReplace;
5188 m_findReplace = new KPrFindReplace( this, m_canvas, &dialog, list, edit );
5189 editFindNext();
5190 }
5191}
5192
5193void KPrView::editFindPrevious()
5194{
5195 if ( !m_findReplace ) // shouldn't be called before find or replace is activated
5196 {
5197 editFind();
5198 return;
5199 }
5200 (void) m_findReplace->findPrevious();
5201}
5202
5203void KPrView::editFindNext()
5204{
5205 if ( !m_findReplace ) // shouldn't be called before find or replace is activated
5206 {
5207 editFind();
5208 return;
5209 }
5210 (void) m_findReplace->findNext();
5211}
5212
5213void KPrView::refreshAllVariable()
5214{
5215 m_pKPresenterDoc->recalcVariables( VT_ALL );
5216}
5217
5218void KPrView::changeZoomMenu( int zoom )
5219{
5220 TQStringList lst;
5221 lst << i18n( "Width" );
5222 lst << i18n( "Whole Slide" );
5223
5224 if(zoom>0)
5225 {
5226 TQValueList<int> list;
5227 bool ok;
5228 const TQStringList itemsList ( actionViewZoom->items() );
5229 TQRegExp regexp("(\\d+)"); // "Captured" non-empty sequence of digits
5230
5231 for (TQStringList::ConstIterator it = itemsList.begin() ; it != itemsList.end() ; ++it)
5232 {
5233 regexp.search(*it);
5234 const int val=regexp.cap(1).toInt(&ok);
5235 //zoom : limit inferior=10
5236 if(ok && val>9 && list.contains(val)==0)
5237 list.append( val );
5238 }
5239 //necessary at the beginning when we read config
5240 //this value is not in combo list
5241 if(list.contains(zoom)==0)
5242 list.append( zoom );
5243
5244 qHeapSort( list );
5245
5246 for (TQValueList<int>::Iterator it = list.begin() ; it != list.end() ; ++it)
5247 lst.append( i18n("%1%").arg(*it) );
5248 }
5249 else
5250 {
5251 lst << i18n("%1%").arg("33");
5252 lst << i18n("%1%").arg("50");
5253 lst << i18n("%1%").arg("75");
5254 lst << i18n("%1%").arg("100");
5255 lst << i18n("%1%").arg("125");
5256 lst << i18n("%1%").arg("150");
5257 lst << i18n("%1%").arg("200");
5258 lst << i18n("%1%").arg("250");
5259 lst << i18n("%1%").arg("350");
5260 lst << i18n("%1%").arg("400");
5261 lst << i18n("%1%").arg("450");
5262 lst << i18n("%1%").arg("500");
5263 }
5264 actionViewZoom->setItems( lst );
5265}
5266
5267void KPrView::showZoom( int zoom )
5268{
5269 TQStringList list = actionViewZoom->items();
5270 TQString zoomStr( i18n("%1%").arg( zoom ) );
5271 int pos = list.findIndex(zoomStr);
5272 if( pos == -1)
5273 {
5274 changeZoomMenu( zoom );
5275 list = actionViewZoom->items();
5276 }
5277 actionViewZoom->setCurrentItem( list.findIndex(zoomStr) );
5278}
5279
5280void KPrView::viewZoom( const TQString &s )
5281{
5282 bool ok=false;
5283 int zoom = 0;
5284 if ( s == i18n("Width") )
5285 {
5286 zoom = tqRound( static_cast<double>(m_canvas->visibleRect().width() * 100 ) /
5287 (zoomHandler()->resolutionX() * m_pKPresenterDoc->pageLayout().ptWidth ) );
5288 ok = true;
5289 }
5290 else if ( s == i18n("Whole Slide") )
5291 {
5292 zoom = getZoomEntirePage();
5293 ok = true;
5294 }
5295 else
5296 {
5297 TQRegExp regexp("(\\d+)"); // "Captured" non-empty sequence of digits
5298 regexp.search(s);
5299 zoom=regexp.cap(1).toInt(&ok);
5300 }
5301 if( !ok || zoom<10 ) //zoom should be valid and >10
5302 zoom = zoomHandler()->zoom();
5303 zoom = TQMIN( zoom, 4000);
5304 //refresh menu
5305 changeZoomMenu( zoom );
5306 //refresh menu item
5307 showZoom(zoom);
5308 //apply zoom if zoom!=m_doc->zoom()
5309 if( zoom != zoomHandler()->zoom() )
5310 {
5311 setZoom( zoom, true );
5312 KPrTextView *edit=m_canvas->currentTextObjectView();
5313 if ( edit )
5314 edit->ensureCursorVisible();
5315 }
5316
5317 m_canvas->setFocus();
5318 m_canvas->repaint();
5319}
5320
5321void KPrView::setZoomRect( const KoRect & rect )
5322{
5323 double height = zoomHandler()->resolutionY() * rect.height();
5324 double width = zoomHandler()->resolutionX() * rect.width();
5325 int zoom = TQMIN( tqRound( static_cast<double>( m_canvas->visibleRect().height() * 100 ) / height ),
5326 tqRound( static_cast<double>( m_canvas->visibleRect().width() * 100 ) / width ) );
5327
5328 m_canvas->setUpdatesEnabled( false );
5329 viewZoom( TQString::number( zoom ) );
5330
5331 m_canvas->setToolEditMode( TEM_MOUSE );
5332 m_canvas->scrollTopLeftPoint( zoomHandler()->zoomPoint( rect.topLeft() ) );
5333 m_canvas->setUpdatesEnabled( true );
5334 m_canvas->repaint();
5335}
5336
5337void KPrView::setZoom( int zoom, bool updateViews )
5338{
5339 zoomHandler()->setZoomAndResolution( zoom, KoGlobal::dpiX(),
5340 KoGlobal::dpiY());
5341 m_pKPresenterDoc->newZoomAndResolution(updateViews,false);
5342 m_pKPresenterDoc->updateZoomRuler();
5343
5344 setRanges();
5345
5346 if ( statusBar() )
5347 m_sbZoomLabel->setText( ' ' + TQString::number( zoom ) + "% " );
5348}
5349
5350void KPrView::slotUpdateScrollBarRanges()
5351{
5352 setRanges();
5353}
5354
5355KoTextZoomHandler *KPrView::zoomHandler() const
5356{
5357 return m_pKPresenterDoc->zoomHandler();
5358}
5359
5360void KPrView::slotViewFormattingChars()
5361{
5362 m_pKPresenterDoc->setViewFormattingChars(actionViewFormattingChars->isChecked());
5363 m_pKPresenterDoc->layout(); // Due to the different formatting when this option is activated
5364 m_pKPresenterDoc->repaint(false);
5365}
5366
5367void KPrView::setPageDuration( int _pgNum )
5368{
5369 if ( kPresenterDoc()->presentationDuration() )
5370 {
5371 // kdDebug(33001) << "KPrView::setPageDuration( " << _pgNum << " )" << endl;
5372 *m_presentationDurationList.at( _pgNum ) += m_duration.elapsed();
5373 m_duration.restart();
5374 }
5375}
5376
5377void KPrView::openThePresentationDurationDialog()
5378{
5379 int totalTime = 0;
5380 TQStringList presentationDurationStringList;
5381 for ( TQValueList<int>::Iterator it = m_presentationDurationList.begin();
5382 it != m_presentationDurationList.end(); ++it ) {
5383 int _time = *it;
5384 TQString presentationDurationString = presentationDurationDataFormatChange( _time );
5385 presentationDurationStringList.append( presentationDurationString );
5386 totalTime += _time;
5387 }
5388
5389 TQString presentationTotalDurationString = presentationDurationDataFormatChange( totalTime );
5390
5391 delete presDurationDia;
5392 presDurationDia = 0;
5393
5394 presDurationDia = new KPrPresDurationDia( this, "presDurationDia", kPresenterDoc(),
5395 presentationDurationStringList, presentationTotalDurationString );
5396 presDurationDia->setCaption( i18n( "Presentation Duration" ) );
5397 TQObject::connect( presDurationDia, TQ_SIGNAL( presDurationDiaClosed() ), this, TQ_SLOT( pddClosed() ) );
5398 presDurationDia->exec();
5399
5400 delete presDurationDia;
5401 presDurationDia = 0;
5402}
5403
5404void KPrView::pddClosed()
5405{
5406 presDurationDia = 0;
5407}
5408
5409// change from milliseconds to hh:mm:ss
5410// in tdelibs 3.2.90, an additional method was added that basically
5411// allows formatting of time as a duration. Before this, you can get
5412// weirdness (such as a duration of 12:00:03 am) depending on how the
5413// time format is set.
5414TQString KPrView::presentationDurationDataFormatChange( int _time )
5415{
5416 TQTime time( 0, 0, 0 );
5417 return TDEGlobal::locale()->formatTime( time.addMSecs( _time ), true, true );
5418}
5419
5420
5421void KPrView::viewFooter()
5422{
5423 bool state = m_actionExtraFooter->isChecked();
5424 m_canvas->activePage()->setFooter( state );
5425 KPrHideShowHeaderFooter * cmd =new KPrHideShowHeaderFooter( state ? i18n("Enable Document Header") : i18n("Disable Document Header"),
5426 m_pKPresenterDoc, m_canvas->activePage(), state, m_pKPresenterDoc->footer());
5427 m_pKPresenterDoc->addCommand(cmd);
5428
5429 m_pKPresenterDoc->updateSideBarItem( m_pKPresenterDoc->masterPage() );
5430}
5431
5432void KPrView::viewHeader()
5433{
5434 bool state = m_actionExtraHeader->isChecked();
5435 m_canvas->activePage()->setHeader( state );
5436 KPrHideShowHeaderFooter * cmd =new KPrHideShowHeaderFooter( state ? i18n("Enable Document Footer") : i18n("Disable Document Footer"),
5437 m_pKPresenterDoc, m_canvas->activePage(), state, m_pKPresenterDoc->header());
5438 m_pKPresenterDoc->addCommand(cmd);
5439
5440 m_pKPresenterDoc->updateSideBarItem( m_pKPresenterDoc->masterPage() );
5441}
5442
5443void KPrView::showStyle( const TQString & styleName )
5444{
5445 KoParagStyle* style = m_pKPresenterDoc->styleCollection()->findStyle( styleName );
5446 if ( style ) {
5447 int pos = m_pKPresenterDoc->styleCollection()->indexOf( style );
5448 // Select style in combo
5449 actionFormatStyle->setCurrentItem( pos );
5450 }
5451}
5452
5453void KPrView::updateStyleList()
5454{
5455 TQString currentStyle = actionFormatStyle->currentText();
5456 // Generate list of styles
5457 const TQStringList lst = m_pKPresenterDoc->styleCollection()->displayNameList();
5458 const int pos = lst.findIndex( currentStyle );
5459 // Fill the combo - using a TDESelectAction
5460 actionFormatStyle->setItems( lst );
5461 if ( pos > -1 )
5462 actionFormatStyle->setCurrentItem( pos );
5463
5464 // Fill the menu - using a TDEActionMenu, so that it's possible to bind keys
5465 // to individual actions
5466 TQStringList lstWithAccels;
5467 // Generate unique accelerators for the menu items
5468 TDEAccelGen::generate( lst, lstWithAccels );
5469 TQMap<TQString, TDEShortcut> shortCuts;
5470
5471 TDEActionPtrList lst2 = actionCollection()->actions("styleList");
5472 TQValueList<TDEAction *> actions = lst2;
5473 TQValueList<TDEAction *>::ConstIterator it = lst2.begin();
5474 TQValueList<TDEAction *>::ConstIterator end = lst2.end();
5475 for (; it != end; ++it )
5476 {
5477 shortCuts.insert( TQString::fromUtf8( (*it)->name() ), (*it)->shortcut() );
5478 actionFormatStyleMenu->remove( *it );
5479 delete *it;
5480 }
5481
5482
5483 uint i = 0;
5484 for ( TQStringList::Iterator it = lstWithAccels.begin(); it != lstWithAccels.end(); ++it, ++i )
5485 {
5486 KoParagStyle *style = m_pKPresenterDoc->styleCollection()->styleAt( i );
5487 if ( style )
5488 {
5489 TQString name = "paragstyle_" + style->name();
5490 TDEToggleAction* act = new TDEToggleAction( (*it),
5491 shortCuts[name], this, TQ_SLOT( slotStyleSelected() ),
5492 actionCollection(), name.utf8() );
5493 act->setGroup( "styleList" );
5494 act->setExclusiveGroup( "styleListAction" );
5495 act->setToolTip( i18n( "Apply a paragraph style" ) );
5496 actionFormatStyleMenu->insert( act );
5497 }
5498 }
5499 bool isText=!m_canvas->applicableTextInterfaces().isEmpty();
5500 actionFormatStyleMenu->setEnabled( isText );
5501 actionFormatStyle->setEnabled(isText);
5502}
5503
5504void KPrView::extraStylist()
5505{
5506 KPrTextView *edit=m_canvas->currentTextObjectView();
5507 TQString activeStyleName = TQString();
5508 if ( edit )
5509 {
5510 edit->hideCursor();
5511 if (edit->cursor() && edit->cursor()->parag() && edit->cursor()->parag()->style())
5512 activeStyleName = edit->cursor()->parag()->style()->displayName();
5513 }
5514 KPrStyleManager * styleManager = new KPrStyleManager( this, m_pKPresenterDoc->unit(), m_pKPresenterDoc,
5515 *m_pKPresenterDoc->styleCollection(), activeStyleName);
5516 styleManager->exec();
5517 delete styleManager;
5518 if ( edit )
5519 edit->showCursor();
5520}
5521
5522// Called when selecting a style in the Format / Style menu
5523void KPrView::slotStyleSelected()
5524{
5525 TQString actionName = TQString::fromUtf8(sender()->name());
5526 kdDebug(33001) << "KPrView::slotStyleSelected " << actionName << endl;
5527 textStyleSelected( m_pKPresenterDoc->styleCollection()->findStyle( actionName ) );
5528}
5529
5530void KPrView::textStyleSelected( int index )
5531{
5532 textStyleSelected( m_pKPresenterDoc->styleCollection()->styleAt( index ) );
5533}
5534
5535void KPrView::textStyleSelected( KoParagStyle *_sty )
5536{
5537 if ( !_sty )
5538 return;
5539
5540 KPrTextView *edit=m_canvas->currentTextObjectView();
5541 if(edit)
5542 {
5543 edit->applyStyle( _sty );
5544 m_canvas->setFocus();
5545 }
5546 else
5547 {
5548 TQPtrList<KPrTextObject> selectedFrames = m_canvas->selectedTextObjs();
5549
5550 if (selectedFrames.count() <= 0)
5551 return; // nope, no frames are selected.
5552 // yes, indeed frames are selected.
5553 TQPtrListIterator<KPrTextObject> it( selectedFrames );
5554 KMacroCommand *globalCmd = 0L;
5555 for ( ; it.current() ; ++it )
5556 {
5557 KoTextObject *textObject = it.current()->textObject();
5558 textObject->textDocument()->selectAll( KoTextDocument::Temp );
5559 KCommand *cmd = textObject->applyStyleCommand( 0L, _sty,
5560 KoTextDocument::Temp, KoParagLayout::All, KoTextFormat::Format,
5561 true, true );
5562 textObject->textDocument()->removeSelection( KoTextDocument::Temp );
5563 if (cmd)
5564 {
5565 if ( !globalCmd)
5566 globalCmd = new KMacroCommand( selectedFrames.count() == 1 ? i18n("Apply Style to Frame") :
5567 i18n("Apply Style to Frames"));
5568 globalCmd->addCommand( cmd );
5569 }
5570 }
5571 if ( globalCmd )
5572 m_pKPresenterDoc->addCommand( globalCmd );
5573 }
5574
5575}
5576
5577void KPrView::slotAllowAutoFormat()
5578{
5579 bool state = actionAllowAutoFormat->isChecked();
5580 m_pKPresenterDoc->setAllowAutoFormat( state );
5581}
5582
5583void KPrView::slotCompletion()
5584{
5585 KPrTextView *edit=m_canvas->currentTextObjectView();
5586 if(edit)
5587 edit->completion();
5588}
5589
5590void KPrView::insertComment()
5591{
5592 KPrTextView *edit=m_canvas->currentTextObjectView();
5593 if ( !edit )
5594 return;
5595 TQString authorName;
5596 KoDocumentInfo * info = m_pKPresenterDoc->documentInfo();
5597 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
5598 if ( !authorPage )
5599 kdWarning() << "Author information not found in documentInfo !" << endl;
5600 else
5601 authorName = authorPage->fullName();
5602
5603 KoCommentDia *commentDia = new KoCommentDia( this, TQString(),authorName );
5604 if( commentDia->exec() )
5605 edit->insertComment(commentDia->commentText());
5606 delete commentDia;
5607}
5608
5609void KPrView::editComment()
5610{
5611 KPrTextView *edit=m_canvas->currentTextObjectView();
5612 if ( edit )
5613 {
5614 KoVariable * tmpVar=edit->variable();
5615 KoNoteVariable * var = dynamic_cast<KoNoteVariable *>(tmpVar);
5616 if(var)
5617 {
5618 TQString authorName;
5619 KoDocumentInfo * info = m_pKPresenterDoc->documentInfo();
5620 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
5621 if ( !authorPage )
5622 kdWarning() << "Author information not found in documentInfo !" << endl;
5623 else
5624 authorName = authorPage->fullName();
5625 TQString oldValue = var->note();
5626 TQString createDate = var->createdNote();
5627 KoCommentDia *commentDia = new KoCommentDia( this, oldValue, authorName, createDate);
5628
5629 if( commentDia->exec() )
5630 {
5631 if ( oldValue != commentDia->commentText())
5632 {
5633 KPrChangeVariableNoteText *cmd = new KPrChangeVariableNoteText( i18n("Change Note Text"), m_pKPresenterDoc, oldValue,commentDia->commentText(), var);
5634 m_pKPresenterDoc->addCommand( cmd );
5635 cmd->execute();
5636 }
5637 }
5638 delete commentDia;
5639 }
5640 }
5641}
5642
5643void KPrView::viewGuideLines()
5644{
5645 bool state=actionViewShowGuideLine->isChecked();
5646 m_pKPresenterDoc->setShowGuideLines( state );
5647 m_pKPresenterDoc->updateGuideLineButton();
5648 deSelectAllObjects();
5649 refreshRuler( state );
5650 m_pKPresenterDoc->repaint(false);
5651}
5652
5653
5654void KPrView::viewGrid()
5655{
5656 m_pKPresenterDoc->setShowGrid( actionViewShowGrid->isChecked() );
5657 m_pKPresenterDoc->setModified( true );
5658 m_pKPresenterDoc->updateGridButton();
5659 m_pKPresenterDoc->repaint(false);
5660}
5661
5662
5663void KPrView::updateGuideLineButton()
5664{
5665 bool state = m_pKPresenterDoc->showGuideLines();
5666 actionViewShowGuideLine->setChecked( state );
5667 refreshRuler( state );
5668}
5669
5670void KPrView::updateGridButton()
5671{
5672 actionViewShowGrid->setChecked( m_pKPresenterDoc->showGrid() );
5673 actionViewSnapToGrid->setChecked ( m_pKPresenterDoc->snapToGrid() );
5674}
5675
5676void KPrView::refreshRuler( bool state )
5677{
5678 if( getHRuler() )
5679 {
5680
5681 if ( !m_pKPresenterDoc->isReadWrite())
5682 {
5683 getHRuler()->changeFlags(KoRuler::F_NORESIZE);
5684 getHRuler()->repaint();
5685 }
5686 else
5687 {
5688 if( state )
5689 {
5690 if( getHRuler()->flags() != KoRuler::F_HELPLINES )
5691 {
5692 getHRuler()->changeFlags(KoRuler::F_HELPLINES);
5693 getHRuler()->repaint();
5694 }
5695 }
5696 else
5697 {
5698 if( getHRuler()->flags() != 0 )
5699 {
5700 getHRuler()->changeFlags( 0 );
5701 getHRuler()->repaint();
5702 }
5703 }
5704 }
5705 }
5706
5707 if( getVRuler())
5708 {
5709 if ( !m_pKPresenterDoc->isReadWrite())
5710 {
5711 getVRuler()->changeFlags(KoRuler::F_NORESIZE);
5712 getVRuler()->repaint();
5713 }
5714 else
5715 {
5716 if( state )
5717 {
5718 if( getVRuler()->flags() != KoRuler::F_HELPLINES )
5719 {
5720 getVRuler()->changeFlags(KoRuler::F_HELPLINES);
5721 getVRuler()->repaint();
5722 }
5723 }
5724 else
5725 {
5726 if( getVRuler()->flags()!= 0)
5727 {
5728 getVRuler()->changeFlags(0);
5729 getVRuler()->repaint();
5730 }
5731 }
5732 }
5733 }
5734
5735}
5736
5737void KPrView::addGuideLine()
5738{
5739 KoRect rect( m_canvas->activePage()->getPageRect() );
5740
5741 KoPoint pos( zoomHandler()->unzoomPoint( m_mousePos + TQPoint( m_canvas->diffx(), m_canvas->diffy() ) ) );
5742 KoGuideLineDia dia( 0, pos, rect, m_pKPresenterDoc->unit() );
5743 if ( dia.exec() == TQDialog::Accepted )
5744 {
5745 m_pKPresenterDoc->addGuideLine( dia.orientation(), dia.pos() );
5746 }
5747}
5748
5749void KPrView::removeComment()
5750{
5751 KPrTextView *edit=m_canvas->currentTextObjectView();
5752 if ( edit )
5753 edit->removeComment();
5754}
5755
5756void KPrView::configureCompletion()
5757{
5758 m_pKPresenterDoc->getAutoFormat()->readConfig();
5759 KoCompletionDia dia( this, 0, m_pKPresenterDoc->getAutoFormat() );
5760 dia.exec();
5761}
5762
5763void KPrView::openPopupMenuZoom( const TQPoint & _point )
5764{
5765 if(!koDocument()->isReadWrite() || !factory())
5766 return;
5767 actionZoomSelectedObject->setEnabled( m_canvas->isOneObjectSelected());
5768 int nbObj = m_canvas->activePage()->objectList().count();
5769 actionZoomAllObject->setEnabled( nbObj > 0);
5770 static_cast<TQPopupMenu*>(factory()->container("zoom_popup",this))->popup(_point);
5771}
5772
5773void KPrView::zoomMinus()
5774{
5775 //unzoom from 25%
5776 int zoom = zoomHandler()->zoom() - (int)(zoomHandler()->zoom()*0.25);
5777 viewZoom( TQString::number(zoom ) );
5778 m_canvas->setToolEditMode( TEM_MOUSE );
5779}
5780
5781void KPrView::zoomPageWidth()
5782{
5783 int zoom = tqRound( static_cast<double>(m_canvas->visibleRect().width() * 100 ) /
5784 (zoomHandler()->resolutionX() * m_pKPresenterDoc->pageLayout().ptWidth ) );
5785 viewZoom( TQString::number(zoom ) );
5786 m_canvas->setToolEditMode( TEM_MOUSE );
5787}
5788
5789void KPrView::zoomEntirePage()
5790{
5791 viewZoom( TQString::number(getZoomEntirePage() ) );
5792 m_canvas->setToolEditMode( TEM_MOUSE );
5793}
5794
5795void KPrView::zoomPlus()
5796{
5797 int zoom = zoomHandler()->zoom() + int( zoomHandler()->zoom() * 0.25 );
5798 viewZoom( TQString::number( zoom ) );
5799 m_canvas->setToolEditMode( TEM_MOUSE );
5800}
5801
5802int KPrView::getZoomEntirePage() const
5803{
5804 double height = zoomHandler()->resolutionY() * m_pKPresenterDoc->pageLayout().ptHeight;
5805 double width = zoomHandler()->resolutionX() * m_pKPresenterDoc->pageLayout().ptWidth;
5806 int zoom = TQMIN( tqRound( static_cast<double>(m_canvas->visibleRect().height() * 100 ) / height ),
5807 tqRound( static_cast<double>(m_canvas->visibleRect().width() * 100 ) / width ) );
5808 return zoom;
5809}
5810
5811void KPrView::zoomSelectedObject()
5812{
5813 if( m_canvas->isOneObjectSelected() )
5814 {
5815 KoRect rect = m_canvas->objectRect( false );
5816 setZoomRect( rect );
5817 }
5818}
5819
5820void KPrView::zoomPageHeight()
5821{
5822 int zoom = tqRound( static_cast<double>(m_canvas->visibleRect().height() * 100 ) /
5823 (zoomHandler()->resolutionX() * m_pKPresenterDoc->pageLayout().ptHeight ) );
5824 viewZoom( TQString::number(zoom ) );
5825 m_canvas->setToolEditMode( TEM_MOUSE );
5826}
5827
5828void KPrView::zoomAllObject()
5829{
5830 KoRect rect = m_canvas->objectRect( true );
5831 double height = zoomHandler()->resolutionY() * rect.height();
5832 double width = zoomHandler()->resolutionX() * rect.width();
5833 int zoom = TQMIN( tqRound( static_cast<double>(m_canvas->visibleRect().height() * 100 ) / height ),
5834 tqRound( static_cast<double>(m_canvas->visibleRect().width() * 100 ) / width ) );
5835 viewZoom( TQString::number(zoom ) );
5836
5837 m_canvas->setToolEditMode( TEM_MOUSE );
5838 m_canvas->scrollTopLeftPoint( zoomHandler()->zoomPoint( rect.topLeft()) );
5839}
5840
5841void KPrView::flipHorizontal()
5842{
5843 m_canvas->flipObject( true );
5844}
5845
5846void KPrView::flipVertical()
5847{
5848 m_canvas->flipObject( false );
5849}
5850
5851void KPrView::slotObjectEditChanged()
5852{
5853 bool state=m_canvas->isOneObjectSelected();
5854 bool rw = koDocument()->isReadWrite();
5855
5856 bool isText=!m_canvas->applicableTextInterfaces().isEmpty();
5857 actionTextFont->setEnabled(isText);
5858 actionTextFontSize->setEnabled(isText);
5859 actionTextFontFamily->setEnabled(isText);
5860 actionTextColor->setEnabled(isText);
5861 actionTextAlignLeft->setEnabled(isText);
5862 actionTextAlignCenter->setEnabled(isText);
5863 actionTextAlignRight->setEnabled(isText);
5864 actionTextAlignBlock->setEnabled(isText);
5865
5866 actionFormatBullet->setEnabled(rw && isText );
5867 actionFormatNumber->setEnabled(rw && isText );
5868
5869 actionTextDepthPlus->setEnabled(isText);
5870 actionFormatDefault->setEnabled(isText);
5871 actionTextDepthMinus->setEnabled(isText);
5872
5873 actionTextExtentCont2Height->setEnabled(isText);
5874 actionTextExtendObj2Cont->setEnabled(isText);
5875 actionTextBold->setEnabled(isText);
5876 actionTextItalic->setEnabled(isText);
5877 actionTextUnderline->setEnabled(isText);
5878 actionFormatStrikeOut->setEnabled(isText);
5879 actionFormatSuper->setEnabled(isText);
5880 actionFormatSub->setEnabled(isText);
5881 actionIncreaseFontSize->setEnabled(isText);
5882 actionDecreaseFontSize->setEnabled(isText);
5883
5884 if ( isText )
5885 {
5886 KoTextFormat format =*(m_canvas->applicableTextInterfaces().first()->currentFormat());
5887 showFormat( format );
5888 const KoParagLayout * paragLayout=m_canvas->applicableTextInterfaces().first()->currentParagLayoutFormat();
5889 KoParagCounter counter;
5890 if(paragLayout->counter)
5891 counter = *(paragLayout->counter);
5892 int align = paragLayout->alignment;
5893 if ( align == TQt::AlignAuto )
5894 align = TQt::AlignLeft; // ## seems hard to detect RTL here
5895 alignChanged( align );
5896 }
5897
5898 KPrTextView *edit=m_canvas->currentTextObjectView();
5899 bool val=(edit!=0) && isText && !edit->kpTextObject()->isProtectContent();
5900 actionInsertSpecialChar->setEnabled(val);
5901 actionInsertComment->setEnabled( val );
5902
5903 actionInsertLink->setEnabled(val);
5904 actionFormatParag->setEnabled(isText);
5905 actionInsertVariable->setEnabled(val);
5906 actionTextInsertPageNum->setEnabled(val);
5907 if ( edit )
5908 actionBrushColor->setEnabled(val);
5909
5910 bool hasSelection = false ;
5911 if(edit)
5912 {
5913 double leftMargin =edit->currentParagLayout().margins[TQStyleSheetItem::MarginLeft];
5914 actionTextDepthMinus->setEnabled(val && leftMargin>0);
5915 hasSelection = edit->textObject()->hasSelection();
5916 actionEditCut->setEnabled(hasSelection);
5917 }
5918 actionCreateStyleFromSelection->setEnabled(edit!=0);
5919
5920 actionChangeCase->setEnabled( (val && rw && hasSelection ) || (rw && !edit && isText) );
5921
5922 if(!edit)
5923 {
5924 actionEditCopy->setEnabled(state);
5925 bool headerfooterselected = false;
5926 if(m_canvas->numberOfObjectSelected()==1)
5927 {
5928 KPrObject *obj=m_canvas->getSelectedObj();
5929 //disable this action when we select a header/footer
5930 if(obj==m_pKPresenterDoc->header() || obj==m_pKPresenterDoc->footer())
5931 headerfooterselected=true;
5932 else
5933 headerfooterselected=false;
5934 }
5935
5936 actionEditCut->setEnabled(state&&!headerfooterselected);
5937 }
5938 actionFormatStyleMenu->setEnabled( isText );
5939 actionFormatStyle->setEnabled(isText);
5940
5941 state=m_canvas->oneObjectTextExist();
5942 actionEditFind->setEnabled(state);
5943 actionEditFindNext->setEnabled( state );
5944 actionEditFindPrevious->setEnabled( state );
5945 actionEditReplace->setEnabled(state);
5946
5947 slotUpdateRuler();
5948}
5949
5950void KPrView::duplicateObj()
5951{
5952 if (m_canvas->currentTextObjectView() && !m_canvas->isOneObjectSelected() )
5953 return;
5954
5955 KPrDuplicatObjDia *dlg= new KPrDuplicatObjDia(this, m_pKPresenterDoc);
5956 if ( dlg->exec() )
5957 {
5958 int nbCopy= dlg->nbCopy();
5959 double angle = dlg->angle();
5960 double increaseX = dlg->increaseX();
5961 double increaseY = dlg->increaseY();
5962 double moveX = dlg->moveX();
5963 double moveY = dlg->moveY();
5964 m_canvas->copyObjs();
5965 m_canvas->setToolEditMode( TEM_MOUSE );
5966 deSelectAllObjects();
5967 TQMimeSource *data = TQApplication::clipboard()->data();
5968 TQCString clip_str = KoStoreDrag::mimeType("application/x-kpresenter");
5969 if ( data->provides( clip_str ) )
5970 {
5971 m_canvas->activePage()->pasteObjs( data->encodedData(clip_str),
5972 nbCopy, angle, increaseX,increaseY, moveX, moveY );
5973 m_canvas->setMouseSelectedObject(true);
5974 emit objectSelectedChanged();
5975 }
5976 }
5977 delete dlg;
5978}
5979
5980void KPrView::extraArrangePopup()
5981{
5982 m_canvas->setToolEditMode( TEM_MOUSE );
5983 TQPoint pnt( TQCursor::pos() );
5984 m_arrangeObjectsPopup->popup( pnt );
5985}
5986
5987void KPrView::extraSendBackward()
5988{
5989 m_canvas->setToolEditMode( TEM_MOUSE );
5990 m_canvas->lowerObjs( false );
5991}
5992
5993void KPrView::extraBringForward()
5994{
5995 m_canvas->setToolEditMode( TEM_MOUSE );
5996 m_canvas->raiseObjs( false );
5997}
5998
5999void KPrView::applyAutoFormat()
6000{
6001 m_pKPresenterDoc->getAutoFormat()->readConfig();
6002 KMacroCommand *macro = 0L;
6003 m_switchPage=m_pKPresenterDoc->pageList().findRef(m_canvas->activePage());
6004 m_initSwitchPage=m_switchPage;
6005 TQPtrList<KoTextObject> list=m_canvas->activePage()->allTextObjects();
6006
6007 KCommand * cmd2 = applyAutoFormatToCurrentPage( list );
6008 if ( cmd2 )
6009 {
6010 if ( !macro )
6011 macro = new KMacroCommand( i18n("Apply Autoformat"));
6012 macro->addCommand( cmd2 );
6013 }
6014
6015 while(switchInOtherPage(i18n( "Do you want to apply autoformat in new slide?")) )
6016 {
6017 KCommand * cmd = applyAutoFormatToCurrentPage(m_canvas->activePage()->allTextObjects());
6018 if ( cmd )
6019 {
6020 if ( !macro )
6021 macro = new KMacroCommand( i18n("Apply Autoformat"));
6022 macro->addCommand( cmd );
6023 }
6024 }
6025 if ( macro )
6026 m_pKPresenterDoc->addCommand(macro);
6027 m_switchPage=-1;
6028 m_initSwitchPage=-1;
6029}
6030
6031bool KPrView::switchInOtherPage( const TQString & text )
6032{
6033 //there is not other page
6034 if(m_pKPresenterDoc->pageList().count()==1)
6035 return false;
6036 m_switchPage++;
6037 if( m_switchPage>=(int)m_pKPresenterDoc->pageList().count())
6038 m_switchPage=0;
6039 if( m_switchPage==m_initSwitchPage)
6040 return false;
6041 if ( KMessageBox::questionYesNo( this, text) != KMessageBox::Yes )
6042 return false;
6043 skipToPage(m_switchPage);
6044 return true;
6045}
6046
6047KCommand * KPrView::applyAutoFormatToCurrentPage( const TQPtrList<KoTextObject> & lst)
6048{
6049 KMacroCommand *macro = 0L;
6050 TQPtrList<KoTextObject> list(lst);
6051 TQPtrListIterator<KoTextObject> fit(list);
6052 for ( ; fit.current() ; ++fit )
6053 {
6054 KCommand *cmd = m_pKPresenterDoc->getAutoFormat()->applyAutoFormat( fit.current() );
6055 if ( cmd )
6056 {
6057 if ( !macro )
6058 macro = new KMacroCommand( i18n("Apply Autoformat"));
6059 macro->addCommand( cmd );
6060 }
6061 }
6062 return macro;
6063}
6064
6065void KPrView::createStyleFromSelection()
6066{
6067 KPrTextView *edit=m_canvas->currentTextObjectView();
6068 if ( edit )
6069 {
6070 KoStyleCollection* coll = m_pKPresenterDoc->styleCollection();
6071 KoCreateStyleDia *dia = new KoCreateStyleDia( TQStringList(), this, 0 );
6072 if ( dia->exec() )
6073 {
6074 TQString name = dia->nameOfNewStyle();
6075 KoParagStyle* style = coll->findStyleByDisplayName( name );
6076 if ( style ) // update existing style
6077 {
6078 // TODO confirmation message box
6079 edit->updateStyleFromSelection( style );
6080 }
6081 else // create new style
6082 {
6083 style = edit->createStyleFromSelection( name );
6084 m_pKPresenterDoc->styleCollection()->addStyle( style );
6085 m_pKPresenterDoc->updateAllStyleLists();
6086 }
6087 showStyle( name );
6088 }
6089 delete dia;
6090 }
6091}
6092
6093void KPrView::closeObject()
6094{
6095 m_canvas->closeObject(true);
6096}
6097
6098void KPrView::viewSnapToGrid()
6099{
6100 m_pKPresenterDoc->setSnapToGrid( actionViewSnapToGrid->isChecked() );
6101 m_pKPresenterDoc->setModified( true );
6102 m_pKPresenterDoc->updateGridButton();
6103}
6104
6105void KPrView::alignVerticalTop()
6106{
6107 if ( actionAlignVerticalTop->isChecked() )
6108 m_canvas->alignVertical(KP_TOP );
6109 else
6110 actionAlignVerticalTop->setChecked(true);
6111}
6112
6113void KPrView::alignVerticalBottom()
6114{
6115 if ( actionAlignVerticalBottom->isChecked() )
6116 m_canvas->alignVertical(KP_BOTTOM );
6117 else
6118 actionAlignVerticalBottom->setChecked(true);
6119}
6120
6121void KPrView::alignVerticalCenter()
6122{
6123 if ( actionAlignVerticalCenter->isChecked() )
6124 m_canvas->alignVertical(KP_CENTER );
6125 else
6126 actionAlignVerticalCenter->setChecked(true);
6127}
6128
6129void KPrView::changeVerticalAlignmentStatus( VerticalAlignmentType _type )
6130{
6131 switch( _type )
6132 {
6133 case KP_CENTER:
6134 actionAlignVerticalCenter->setChecked( true );
6135 break;
6136 case KP_TOP:
6137 actionAlignVerticalTop->setChecked( true );
6138 break;
6139 case KP_BOTTOM:
6140 actionAlignVerticalBottom->setChecked( true );
6141 break;
6142 }
6143}
6144
6145void KPrView::autoSpellCheck()
6146{
6147 m_pKPresenterDoc->changeBgSpellCheckingState( actionAllowBgSpellCheck->isChecked() );
6148}
6149
6150void KPrView::insertFile( )
6151{
6152 KFileDialog fd( TQString(), TQString(), this, 0, true );
6153 TQStringList filter;
6154 filter<<"application/x-kpresenter";
6155 filter<<"application/vnd.oasis.opendocument.presentation";
6156 fd.setMimeFilter( filter );
6157 fd.setCaption(i18n("Insert File"));
6158
6159 KURL url;
6160 if ( fd.exec() == TQDialog::Accepted )
6161 {
6162 url = fd.selectedURL();
6163 if( url.isEmpty() )
6164 {
6165 KMessageBox::sorry( this,
6166 i18n("File name is empty."),
6167 i18n("Insert File"));
6168 return;
6169 }
6170 insertFile(url.path());
6171 }
6172}
6173
6174void KPrView::insertFile(const TQString &path)
6175{
6176 m_pKPresenterDoc->insertFile(path);
6177}
6178
6179void KPrView::importStyle()
6180{
6181 KPrImportStyleDia dia( m_pKPresenterDoc, m_pKPresenterDoc->styleCollection(), this );
6182 if ( dia.exec() && !dia.importedStyles().isEmpty() ) {
6183 m_pKPresenterDoc->styleCollection()->importStyles( dia.importedStyles() );
6184 m_pKPresenterDoc->setModified( true );
6185 m_pKPresenterDoc->updateAllStyleLists();
6186 }
6187}
6188
6189void KPrView::backgroundPicture()
6190{
6191 switch( m_canvas->activePage()->getBackType())
6192 {
6193 case BT_COLOR:
6194 case BT_BRUSH:
6195 break;
6196 case BT_CLIPART:
6197 case BT_PICTURE:
6198 KoPicture picture=m_canvas->activePage()->background()->picture();
6199 savePicture(picture.getKey().filename(), picture);
6200 break;
6201 }
6202}
6203
6204void KPrView::testAndCloseAllTextObjectProtectedContent()
6205{
6206 KPrTextView *edit=m_canvas->currentTextObjectView();
6207 if ( edit && edit->kpTextObject()->isProtectContent())
6208 {
6209 m_canvas->setToolEditMode( TEM_MOUSE );
6210 deSelectAllObjects();
6211 }
6212}
6213
6214void KPrView::updateBgSpellCheckingState()
6215{
6216 actionAllowBgSpellCheck->setChecked( m_pKPresenterDoc->backgroundSpellCheckEnabled() );
6217}
6218
6219void KPrView::updateRulerInProtectContentMode()
6220{
6221 KPrTextView *edit=m_canvas->currentTextObjectView();
6222 if ( edit && getHRuler()) {
6223 if ( !edit->kpTextObject()->isProtectContent() )
6224 getHRuler()->changeFlags(KoRuler::F_INDENTS | KoRuler::F_TABS);
6225 else
6226 getHRuler()->changeFlags(0);
6227 getHRuler()->repaint();
6228 }
6229}
6230
6231void KPrView::slotChangeCutState(bool b)
6232{
6233 KPrTextView *edit=m_canvas->currentTextObjectView();
6234
6235 if ( edit && edit->kpTextObject()->isProtectContent())
6236 actionEditCut->setEnabled( false );
6237 else
6238 actionEditCut->setEnabled( b );
6239}
6240
6241void KPrView::updatePresentationButton(bool b)
6242{
6243 actionScreenStart->setEnabled( b );
6244}
6245
6246void KPrView::refreshGroupButton()
6247{
6248 bool state=m_canvas->isOneObjectSelected();
6249 actionExtraGroup->setEnabled(state && m_canvas->numberOfObjectSelected()>1);
6250 actionExtraUnGroup->setEnabled(state && m_canvas->haveASelectedGroupObj());
6251}
6252
6253void KPrView::closeTextObject()
6254{
6255 KPrTextView *edit=m_canvas->currentTextObjectView();
6256 if ( edit)
6257 {
6258 m_canvas->setToolEditMode( TEM_MOUSE );
6259 deSelectAllObjects();
6260 }
6261}
6262
6263void KPrView::deSelectAllObjects()
6264{
6265 m_canvas->deSelectAllObj();
6266}
6267
6268void KPrView::copyLink()
6269{
6270 KPrTextView *edit=m_canvas->currentTextObjectView();
6271 if ( edit )
6272 edit->copyLink();
6273}
6274
6275void KPrView::addToBookmark()
6276{
6277 KPrTextView *edit=m_canvas->currentTextObjectView();
6278 if ( edit )
6279 {
6280 KoLinkVariable * var=edit->linkVariable();
6281 if(var)
6282 edit->addBookmarks(var->url());
6283 }
6284}
6285
6286void KPrView::removeLink()
6287{
6288 KPrTextView *edit=m_canvas->currentTextObjectView();
6289 if ( edit )
6290 edit->removeLink();
6291}
6292
6293void KPrView::insertDirectCursor()
6294{
6295#if 0
6296 insertDirectCursor( actionInsertDirectCursor->isChecked());
6297#endif
6298}
6299
6300void KPrView::insertDirectCursor(bool b)
6301{
6302 m_pKPresenterDoc->setInsertDirectCursor(b);
6303}
6304
6305void KPrView::updateDirectCursorButton()
6306{
6307#if 0
6308 actionInsertDirectCursor->setChecked(m_pKPresenterDoc->insertDirectCursor());
6309#endif
6310}
6311
6312void KPrView::copyTextOfComment()
6313{
6314 KPrTextView *edit=m_canvas->currentTextObjectView();
6315 if ( edit )
6316 edit->copyTextOfComment();
6317}
6318
6319void KPrView::slotAddIgnoreAllWord()
6320{
6321 KPrTextView *edit=m_canvas->currentTextObjectView();
6322 if ( edit )
6323 m_pKPresenterDoc->addSpellCheckIgnoreWord( edit->currentWordOrSelection() );
6324}
6325
6326void KPrView::addWordToDictionary()
6327{
6328 KPrTextView* edit = m_canvas->currentTextObjectView();
6329 if ( edit )
6330 {
6331 TQString word = edit->wordUnderCursor( *edit->cursor() );
6332 if ( !word.isEmpty() )
6333 m_pKPresenterDoc->addWordToDictionary( word );
6334 }
6335}
6336
6337void KPrView::imageEffect()
6338{
6339 if (m_canvas->numberOfObjectSelected() > 0) {
6340 imageEffectDia = new KPrImageEffectDia(this);
6341
6342 KPrPixmapObject *object=m_canvas->getSelectedImage();
6343
6344 imageEffectDia->setPixmap(object->getOriginalPixmap());
6345 imageEffectDia->setEffect(object->getImageEffect(), object->getIEParam1(), object->getIEParam2(),
6346 object->getIEParam3());
6347
6348 m_canvas->setToolEditMode(TEM_MOUSE);
6349
6350 if (imageEffectDia->exec()==TQDialog::Accepted) {
6351 KCommand *cmd=m_canvas->activePage()->setImageEffect(imageEffectDia->getEffect(), imageEffectDia->getParam1(),
6352 imageEffectDia->getParam2(), imageEffectDia->getParam3());
6353 if ( cmd )
6354 kPresenterDoc()->addCommand( cmd );
6355 }
6356
6357 delete imageEffectDia;
6358 imageEffectDia = 0L;
6359 }
6360}
6361
6362void KPrView::spellAddAutoCorrect (const TQString & originalword, const TQString & newword)
6363{
6364 m_pKPresenterDoc->getAutoFormat()->addAutoFormatEntry( originalword, newword );
6365}
6366
6367TQPtrList<TDEAction> KPrView::listOfResultOfCheckWord( const TQString &word )
6368{
6369 TQPtrList<TDEAction> listAction;
6370 DefaultDictionary *dict = m_broker->defaultDictionary();
6371 TQStringList lst = dict->suggest( word );
6372 if ( !lst.contains( word ))
6373 {
6374 TQStringList::ConstIterator it = lst.begin();
6375 for ( int i = 0; it != lst.end() ; ++it, ++i )
6376 {
6377 if ( !(*it).isEmpty() ) // in case of removed subtypes or placeholders
6378 {
6379 TDEAction * act = new TDEAction( (*it));
6380 connect( act, TQ_SIGNAL(activated()), this, TQ_SLOT(slotCorrectWord()) );
6381 listAction.append( act );
6382 }
6383 }
6384 }
6385
6386 return listAction;
6387}
6388
6389void KPrView::slotCorrectWord()
6390{
6391 TDEAction * act = (TDEAction *)(sender());
6392 KPrTextView* edit = m_canvas->currentTextObjectView();
6393 if ( edit )
6394 {
6395 edit->selectWordUnderCursor( *(edit->cursor()) );
6396 m_pKPresenterDoc->addCommand(edit->textObject()->replaceSelectionCommand(
6397 edit->cursor(), act->text(),
6398 i18n("Replace Word"), KoTextDocument::Standard));
6399 }
6400}
6401
6402KCommand * KPrView::getPenCmd( const TQString &name, KoPen pen, LineEnd lb, LineEnd le, int flags )
6403{
6404 KMacroCommand * macro = NULL;
6405
6406 //tz TODO remove macro, add parameter for command name to setPen()
6407 KCommand * cmd = m_canvas->activePage()->setPen( pen, lb, le, flags );
6408 if( cmd )
6409 {
6410 macro = new KMacroCommand( name );
6411 macro->addCommand( cmd );
6412 }
6413
6414 return macro;
6415}
6416
6417void KPrView::initialLayoutOfSplitter()
6418{
6419 if( !notebar )
6420 {
6421 return;
6422 }
6423
6424 TQSplitter* splitterVertical = static_cast<TQSplitter*>( notebar->parent() );
6425 TQValueList<int> tmpList;
6426 int noteHeight = height() / 25;
6427 tmpList << height() - noteHeight << noteHeight;
6428 splitterVertical->setSizes( tmpList );
6429}
6430
6431void KPrView::slotChildActivated(bool a)
6432{
6433 KoViewChild* ch = child( (KoView*)sender() );
6434 if ( !ch )
6435 return;
6436
6437 if( !a ) {
6438 m_canvas->exitEditMode();
6439 }
6440
6441 KoView::slotChildActivated( a );
6442}
6443
6444Broker *KPrView::broker() const
6445{
6446 return m_broker;
6447}
6448
6449void KPrView::slotUnitChanged( KoUnit::Unit unit )
6450{
6451 h_ruler->setUnit( unit );
6452 v_ruler->setUnit( unit );
6453 if ( statusBar() )
6454 {
6455 m_sbUnitLabel->setText( ' ' + KoUnit::unitDescription( unit ) + ' ' );
6456 updateObjectStatusBarItem();
6457 }
6458}
6459
6460void KPrView::documentModified( bool b )
6461{
6462 if ( !statusBar() )
6463 return;
6464
6465 if ( b )
6466 m_sbModifiedLabel->setPixmap( TDEGlobal::iconLoader()->loadIcon( "action-modified", TDEIcon::Small ) );
6467 else
6468 m_sbModifiedLabel->setText( " " );
6469}
6470
6471void KPrView::loadingFinished()
6472{
6473 h_ruler->setPageLayout(m_pKPresenterDoc->pageLayout());
6474 v_ruler->setPageLayout(m_pKPresenterDoc->pageLayout());
6475 slotUpdateRuler();
6476 m_pKPresenterDoc->updateZoomRuler();
6477 updateSideBar();
6478}
6479
6480#include "KPrView.moc"
KPrTextObject * textObject() const
Return the text object in which this document is.