00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <kprinter.h>
00022 #include <kaccel.h>
00023 #include <kglobalsettings.h>
00024 #include <qpainter.h>
00025 #include <qscrollbar.h>
00026 #include <qpopupmenu.h>
00027 #include <qcursor.h>
00028 #include <qfileinfo.h>
00029 #include <qtextstream.h>
00030 #include <assert.h>
00031 #include <qtoolbutton.h>
00032 #include <qtooltip.h>
00033 #include <qdir.h>
00034 #include <qclipboard.h>
00035 #include <qradiobutton.h>
00036 #include <qdragobject.h>
00037 #include <qfile.h>
00038
00039 #include "KPrPage.h"
00040 #include "KPrBackDia.h"
00041 #include "autoformEdit/AFChoose.h"
00042 #include "KPrPropertyEditor.h"
00043 #include "KPrPgConfDia.h"
00044 #include "KPrEffectDia.h"
00045 #include "KPrRotationDialogImpl.h"
00046 #include "KPrShadowDialogImpl.h"
00047 #include "KPrImageEffectDia.h"
00048 #include "KPrBackground.h"
00049 #include "KPrPenStyleWidget.h"
00050 #include "KPrObjectProperties.h"
00051
00052 #include <KoAutoFormat.h>
00053
00054 #include "KPrSlideTransitionDia.h"
00055
00056 #include "KPrPresDurationDia.h"
00057 #include "KPrPartObject.h"
00058 #include "KPrSideBar.h"
00059 #include "KPrNoteBar.h"
00060 #include "insertpagedia.h"
00061 #include "KPrCustomSlideShowDia.h"
00062
00063 #include <KoPictureFilePreview.h>
00064 #include <KoCreateStyleDia.h>
00065
00066 #include <dcopclient.h>
00067 #include <kfiledialog.h>
00068 #include <kmessagebox.h>
00069 #include <kstdaction.h>
00070 #include <kapplication.h>
00071 #include <kio/netaccess.h>
00072
00073 #include "KPrView.h"
00074 #include "KPrDocument.h"
00075 #include "KPrWebPresentation.h"
00076 #include "KPrMSPresentationSetup.h"
00077 #include "KPrTextObject.h"
00078
00079 #include <klocale.h>
00080 #include <kcolordialog.h>
00081 #include <kconfig.h>
00082 #include <kfontdialog.h>
00083 #include <kglobal.h>
00084 #include <kimageio.h>
00085 #include <kparts/event.h>
00086 #include <kdebug.h>
00087 #include <ktempfile.h>
00088 #include <kcolorbutton.h>
00089 #include <kprocess.h>
00090
00091 #include <KoMainWindow.h>
00092 #include <KoPartSelectDia.h>
00093 #include <KoQueryTrader.h>
00094 #include <KoPageLayoutDia.h>
00095 #include <KoRuler.h>
00096 #include <KoTemplateCreateDia.h>
00097 #include <kcoloractions.h>
00098 #include <tkcoloractions.h>
00099 #include <kaction.h>
00100 #include <qspinbox.h>
00101 #include <qcombobox.h>
00102 #include <KoPartSelectAction.h>
00103 #include <KoTextZoomHandler.h>
00104 #include <Kolinestyleaction.h>
00105 #include <Kolinewidthaction.h>
00106
00107 #include <stdlib.h>
00108 #include <signal.h>
00109
00110 #include <kstandarddirs.h>
00111
00112 #include "KPrViewIface.h"
00113 #include "KPrConfig.h"
00114
00115 #include <KoTextParag.h>
00116 #include <KoTextObject.h>
00117 #include "KPrCommand.h"
00118 #include <KoFontDia.h>
00119 #include <KoCharSelectDia.h>
00120 #include <KoInsertLink.h>
00121 #include <KoAutoFormatDia.h>
00122 #include <KoParagCounter.h>
00123 #include <KoParagDia.h>
00124 #include <KoVariable.h>
00125 #include <KoCustomVariablesDia.h>
00126 #include <KoGuideLineDia.h>
00127 #include <KoCompletionDia.h>
00128
00129 #include <kspell.h>
00130 #include <kstatusbar.h>
00131 #include "KPrTextDocument.h"
00132
00133 #include <KoChangeCaseDia.h>
00134 #include <qregexp.h>
00135
00136 #include <KoSearchDia.h>
00137 #include "KPrFindReplace.h"
00138 #include "KPrVariableCollection.h"
00139 #include "KPrCanvas.h"
00140 #include <qpaintdevicemetrics.h>
00141 #include <KoStyleCollection.h>
00142 #include "KPrStyleManager.h"
00143 #include "KPrPixmapObject.h"
00144 #include <KoCommentDia.h>
00145
00146 #include "KPrDuplicateObjDia.h"
00147 #include <kstdaccel.h>
00148 #include <KoDocumentInfo.h>
00149 #include <kaccelgen.h>
00150 #include "KPrImportStyleDia.h"
00151 #include <kurldrag.h>
00152 #include <config.h>
00153 #include <KoStore.h>
00154 #include <KoStoreDrag.h>
00155
00156 #include <kspell2/broker.h>
00157 #include <kspell2/defaultdictionary.h>
00158 #include <kspell2/dialog.h>
00159 #include "KoSpell.h"
00160 #include "KPrPrinterDlg.h"
00161 using namespace KSpell2;
00162
00163 #define COPYOASISFORMAT 0
00164
00165 static const char * const pageup_xpm[] = {
00166 " 14 14 2 1",
00167 ". c #000000",
00168 "# c none",
00169 "##############",
00170 "##############",
00171 "######..######",
00172 "#####....#####",
00173 "####......####",
00174 "###........###",
00175 "##############",
00176 "######..######",
00177 "#####....#####",
00178 "####......####",
00179 "###........###",
00180 "##############",
00181 "##############",
00182 "##############"
00183 };
00184
00185 static const char * const pagedown_xpm[] = {
00186 " 14 14 2 1",
00187 ". c #000000",
00188 "# c none",
00189 "##############",
00190 "##############",
00191 "##############",
00192 "###........###",
00193 "####......####",
00194 "#####....#####",
00195 "######..######",
00196 "##############",
00197 "###........###",
00198 "####......####",
00199 "#####....#####",
00200 "######..######",
00201 "##############",
00202 "##############"
00203 };
00204
00205 #ifdef HAVE_DPMS
00206 #include <X11/Xlib.h>
00207 #include <X11/Xutil.h>
00208 #include <X11/Xmd.h>
00209 #include <X11/extensions/dpms.h>
00210 #include <fixx11h.h>
00211
00212 extern "C" {
00213 #ifndef HAVE_DPMSCAPABLE_PROTO
00214 Bool DPMSCapable( Display * );
00215 #endif
00216 }
00217
00218 #if defined(XIMStringConversionRetrival) || defined (__sun) || defined(__hpux)
00219 extern "C" {
00220 #endif
00221 Bool DPMSQueryExtension(Display *, int *, int *);
00222 Status DPMSEnable(Display *);
00223 Status DPMSDisable(Display *);
00224 Bool DPMSGetTimeouts(Display *, CARD16 *, CARD16 *, CARD16 *);
00225 #if defined(XIMStringConversionRetrival) || defined (__sun) || defined(__hpux)
00226 }
00227 #endif
00228 #endif
00229
00230 static void enableDPMS(bool enable)
00231 {
00232 #ifdef HAVE_DPMS
00233 Display *display = qt_xdisplay();
00234
00235 int dummy;
00236 bool hasDPMS = DPMSQueryExtension(display, &dummy, &dummy);
00237 if (hasDPMS && DPMSCapable(display)) {
00238 if (enable) {
00239 kdDebug() << "Enabling DPMS" << endl;
00240 DPMSEnable(display);
00241 } else {
00242 kdDebug() << "Disabling DPMS" << endl;
00243 DPMSDisable(display);
00244 }
00245 } else
00246 qWarning("Server has no DPMS extension");
00247
00248 XFlush(display);
00249 #else
00250 Q_UNUSED(enable);
00251 #endif
00252 }
00253
00254 static bool isDPMSEnabled()
00255 {
00256 bool result = false;
00257 #ifdef HAVE_DPMS
00258 int event_base;
00259 int error_base;
00260 CARD16 x_standby;
00261 CARD16 x_suspend;
00262 CARD16 x_off;
00263 Display *display = qt_xdisplay();
00264 if (DPMSQueryExtension(display, &event_base, &error_base))
00265 if (DPMSCapable(display))
00266 result = (DPMSGetTimeouts(display, &x_standby, &x_suspend, &x_off));
00267 #endif
00268 return result;
00269 }
00270
00271 KPrView::KPrView( KPrDocument* _doc, QWidget *_parent, const char *_name )
00272 : KoView( _doc, _parent, _name )
00273 {
00274
00275 setInstance( KPrFactory::global() );
00276 if ( !_doc->isReadWrite() )
00277 setXMLFile( "kpresenter_readonly.rc" );
00278 else
00279 setXMLFile( "kpresenter.rc" );
00280
00281 dcop = 0;
00282 dcopObject();
00283
00284 m_bDisplayFieldCode=false;
00285
00286 afChoose = 0;
00287 m_propertyEditor = 0;
00288 pgConfDia = 0;
00289 rotateDia = 0;
00290 shadowDia = 0;
00291 imageEffectDia = 0;
00292 presDurationDia = 0;
00293 v_ruler = 0;
00294 h_ruler = 0;
00295 pen = KoPen( black, 1.0, SolidLine );
00296 brush = QBrush( white, SolidPattern );
00297 lineBegin = L_NORMAL;
00298 lineEnd = L_NORMAL;
00299 gColor1 = red;
00300 gColor2 = green;
00301 gType = BCT_GHORZ;
00302 gUnbalanced = false;
00303 gXFactor = 100;
00304 gYFactor = 100;
00305 fillType = FT_BRUSH;
00306 pieType = PT_PIE;
00307 pieLength = 90 * 16;
00308 pieAngle = 45 * 16;
00309 setMouseTracking( true );
00310 m_bShowGUI = true;
00311 presStarted = false;
00312 m_autoPresRestart = false;
00313 m_autoPresStop = false;
00314 rndX = 0;
00315 rndY = 0;
00316 m_editMaster = false;
00317 allowWebPres = true;
00318 allowMSPres = true;
00319 currPg = 0;
00320 sidebar = 0;
00321 notebar = 0;
00322 splitter = 0;
00323 pageBase = 0;
00324 m_canvas = 0L;
00325 m_spell.kospell = 0;
00326 m_spell.textIterator = 0L;
00327 m_spell.macroCmdSpellCheck = 0L;
00328 m_spell.dlg = 0;
00329 m_broker = Broker::openBroker( KSharedConfig::openConfig( "kpresenterrc" ) );
00330
00331 m_autoPresTimerConnected = false;
00332 m_actionList.setAutoDelete( true );
00333 checkConcavePolygon = false;
00334 cornersValue = 3;
00335 sharpnessValue = 0;
00336 tbAlign = Qt::AlignLeft;
00337 tbFont = font();
00338 tbColor = black;
00339
00340 mirrorType = PM_NORMAL;
00341 depth = 0;
00342 swapRGB = false;
00343 grayscal = false;
00344 bright = 0;
00345
00346 m_currentLineTool = LtLine;
00347 m_currentShapeTool = StRectangle;
00348 m_currentClosedLineTool = CltFreehand;
00349
00350 m_searchEntry = 0L;
00351 m_replaceEntry = 0L;
00352 m_findReplace = 0L;
00353 m_switchPage=-1;
00354
00355 m_fontDlg=0L;
00356 m_paragDlg=0L;
00357 m_pKPresenterDoc = _doc;
00358
00359 createGUI();
00360
00361 setKeyCompression( true );
00362 m_specialCharDlg=0L;
00363
00364 if ( shell() )
00365 changeNbOfRecentFiles( m_pKPresenterDoc->maxRecentFiles() );
00366
00367 connect(this, SIGNAL(embeddImage(const QString &)), SLOT(insertPicture(const QString &)));
00368 connect( m_pKPresenterDoc, SIGNAL( sig_refreshMenuCustomVariable()),
00369 this, SLOT( refreshCustomMenu()));
00370
00371
00372 if ( m_pKPresenterDoc->isReadWrite() )
00373 connect( m_canvas, SIGNAL(selectionChanged(bool)),
00374 this, SLOT(slotChangeCutState(bool )) );
00375 else
00376 actionEditCut->setEnabled( false );
00377
00378 connect( m_canvas, SIGNAL(selectionChanged(bool)),
00379 actionEditCopy, SLOT(setEnabled(bool)) );
00380
00381 connect (m_canvas, SIGNAL(selectionChanged(bool)),
00382 actionChangeCase, SLOT(setEnabled(bool)));
00383
00384
00385
00386 connect( m_canvas, SIGNAL( currentObjectEditChanged() ), this, SLOT( slotObjectEditChanged()));
00387
00388 connect( h_ruler, SIGNAL( tabListChanged( const KoTabulatorList & ) ), this,
00389 SLOT( tabListChanged( const KoTabulatorList & ) ) );
00390
00391
00392 connect( m_pKPresenterDoc, SIGNAL( pageNumChanged() ), this, SLOT( pageNumChanged()) );
00393 connect( this, SIGNAL( currentPageChanged(int) ), this, SLOT( pageNumChanged()) );
00394 connect( m_canvas, SIGNAL( objectSizeChanged() ), this, SLOT( updateObjectStatusBarItem() ));
00395 connect( m_canvas, SIGNAL( objectSelectedChanged() ), this, SLOT( updateObjectStatusBarItem() ));
00396 connect (m_pKPresenterDoc, SIGNAL(sig_updateRuler()),this, SLOT( slotUpdateRuler()));
00397 connect (m_pKPresenterDoc, SIGNAL(sig_updateRuler()),this, SLOT( slotUpdateScrollBarRanges()));
00398 connect (m_pKPresenterDoc, SIGNAL(sig_updateMenuBar()),this, SLOT(updateSideBarMenu()));
00399 connect (m_pKPresenterDoc, SIGNAL(unitChanged(KoUnit::Unit)),this, SLOT(slotUnitChanged(KoUnit::Unit)));
00400 connect( m_pKPresenterDoc, SIGNAL( modified( bool ) ), this, SLOT( documentModified( bool )) );
00401 connect( m_pKPresenterDoc, SIGNAL(completed()), this, SLOT(loadingFinished()));
00402
00403 KStatusBar * sb = statusBar();
00404 m_sbPageLabel = 0L;
00405 m_sbObjectLabel = 0L;
00406 m_sbModifiedLabel = 0;
00407 m_sbZoomLabel = 0;
00408 m_sbUnitLabel = 0;
00409
00410 if ( sb )
00411 {
00412 m_sbPageLabel = new KStatusBarLabel( QString::null, 0, sb );
00413 m_sbPageLabel->setAlignment( AlignLeft | AlignVCenter );
00414 addStatusBarItem( m_sbPageLabel, 0 );
00415
00416 m_sbModifiedLabel = new KStatusBarLabel( " ", 0, sb );
00417 m_sbModifiedLabel->setAlignment( AlignLeft | AlignVCenter );
00418 addStatusBarItem( m_sbModifiedLabel, 0 );
00419
00420 m_sbObjectLabel = new KStatusBarLabel( QString::null, 0, sb );
00421 m_sbObjectLabel->setAlignment( AlignLeft | AlignVCenter );
00422 addStatusBarItem( m_sbObjectLabel, 1 );
00423
00424 m_sbZoomLabel = new KStatusBarLabel( ' ' + QString::number( m_pKPresenterDoc->zoomHandler()->zoom() ) + "% ", 0, sb );
00425 m_sbZoomLabel->setAlignment( AlignHCenter | AlignVCenter );
00426 addStatusBarItem( m_sbZoomLabel, 0 );
00427
00428 m_sbUnitLabel = new KStatusBarLabel( ' ' + KoUnit::unitDescription( m_pKPresenterDoc->unit() ) + ' ', 0, sb );
00429 m_sbUnitLabel->setAlignment( AlignHCenter | AlignVCenter );
00430 addStatusBarItem( m_sbUnitLabel, 0 );
00431 }
00432
00433
00434
00435 if(!m_pKPresenterDoc->isReadWrite())
00436 {
00437 setZoom( 100, true );
00438 slotUpdateRuler();
00439 initGui();
00440 m_pKPresenterDoc->updateZoomRuler();
00441 }
00442
00443
00444 setAcceptDrops( TRUE );
00445 }
00446
00447 DCOPObject* KPrView::dcopObject()
00448 {
00449 if ( !dcop )
00450 dcop = new KPrViewIface( this );
00451
00452 return dcop;
00453 }
00454
00455 KPrView::~KPrView()
00456 {
00457 delete m_findReplace;
00458 m_findReplace = 0L;
00459 if(sidebar) {
00460 KConfig *config=KGlobal::config();
00461 config->setGroup("Global");
00462 config->writeEntry("Sidebar", sidebar->isVisible());
00463 }
00464 if(notebar) {
00465 KConfig *config=KGlobal::config();
00466 config->setGroup("Global");
00467 config->writeEntry("Notebar", notebar->isVisible());
00468 }
00469 clearSpellChecker();
00470
00471 delete rb_lbegin;
00472 delete rb_lend;
00473 delete dcop;
00474
00475 delete m_sbPageLabel;
00476 delete m_sbObjectLabel;
00477 delete notebar;
00478 delete m_searchEntry;
00479 m_searchEntry = 0L;
00480 delete m_replaceEntry;
00481 m_replaceEntry = 0L;
00482 delete m_propertyEditor;
00483 delete pgConfDia;
00484 delete rotateDia;
00485 delete shadowDia;
00486 delete afChoose;
00487 delete m_fontDlg;
00488 delete m_paragDlg;
00489 delete m_arrangeObjectsPopup;
00490
00491 if ( m_specialCharDlg )
00492 m_specialCharDlg->closeDialog();
00493 delete m_specialCharDlg;
00494 }
00495
00496 void KPrView::setupPrinter( KPrinter &prt )
00497 {
00498 deSelectAllObjects();
00499 m_pKPresenterDoc->recalcVariables( VT_TIME );
00500 m_pKPresenterDoc->recalcVariables( VT_DATE );
00501 prt.setMinMax( 1, m_pKPresenterDoc->getPageNums() );
00502 prt.setFromTo( 1, m_pKPresenterDoc->getPageNums() );
00503 prt.setOption( "kde-range", m_pKPresenterDoc->selectedForPrinting() );
00504 prt.setPageSelection(KPrinter::ApplicationSide);
00505 KoPageLayout layout = m_pKPresenterDoc->pageLayout();
00506 prt.setOption( "kde-margin-top", QString::number(layout.ptTop) );
00507 prt.setOption( "kde-margin-bottom", QString::number(layout.ptBottom) );
00508 prt.setOption( "kde-margin-left", QString::number(layout.ptLeft) );
00509 prt.setOption( "kde-margin-right", QString::number(layout.ptRight) );
00510 KoFormat pageFormat = layout.format;
00511 prt.setPageSize( static_cast<KPrinter::PageSize>( KoPageFormat::printerPageSize( pageFormat ) ) );
00512
00513 if ( m_pKPresenterDoc->pageLayout().orientation == PG_LANDSCAPE || pageFormat == PG_SCREEN )
00514 prt.setOrientation( KPrinter::Landscape );
00515 else
00516 prt.setOrientation( KPrinter::Portrait );
00517 if ( !prt.previewOnly() )
00518 prt.addDialogPage( new KPrPrinterDlg( 0, "KPresenter page" ) );
00519 }
00520
00521 void KPrView::unZoomDocument(int &dpiX,int &dpiY)
00522 {
00523
00524
00525
00526 bool doZoom=false;
00527 dpiX = doZoom ? 300 : KoGlobal::dpiX();
00528 dpiY = doZoom ? 300 : KoGlobal::dpiY();
00529 zoomHandler()->setZoomAndResolution( 100, dpiX, dpiY );
00530 m_pKPresenterDoc->newZoomAndResolution( false, true );
00531 }
00532
00533 void KPrView::zoomDocument(int zoom)
00534 {
00535 zoomHandler()->setZoomAndResolution( zoom, KoGlobal::dpiX(), KoGlobal::dpiY() );
00536 m_pKPresenterDoc->newZoomAndResolution( false, false );
00537 updateRuler();
00538 }
00539
00540 void KPrView::print( KPrinter &prt )
00541 {
00542 float left_margin = 0.0;
00543 float top_margin = 0.0;
00544 int dpiX=0;
00545 int dpiY=0;
00546 int oldZoom = zoomHandler()->zoom();
00547 bool displayFieldCode = m_pKPresenterDoc->getVariableCollection()->variableSetting()->displayFieldCode();
00548 if ( displayFieldCode )
00549 {
00550 m_pKPresenterDoc->getVariableCollection()->variableSetting()->setDisplayFieldCode(false);
00551 m_pKPresenterDoc->recalcVariables( VT_ALL );
00552 }
00553
00554 QPaintDeviceMetrics metrics( &prt );
00555 unZoomDocument(dpiX,dpiY);
00556 if ( m_pKPresenterDoc->pageLayout().format == PG_SCREEN )
00557 {
00558 left_margin = 28.5;
00559 top_margin = 15.0;
00560 }
00561
00562 QPainter painter;
00563 painter.begin( &prt );
00564 QRect rect = m_pKPresenterDoc->pageList().at( 0 )->getZoomPageRect();
00565 double zoom = QMIN( double( metrics.width() ) / double( rect.width() ),
00566 double( metrics.height() ) / double( rect.height() ) );
00567 double newZoom = zoom * m_pKPresenterDoc->zoomHandler()->zoom();
00568 kdDebug(33001) << "KPrView::print newZoom = " << newZoom << endl;
00569 setZoom( int( newZoom ), false );
00570 QRect paintingRect = m_pKPresenterDoc->pageList().at( 0 )->getZoomPageRect();
00571
00572 m_canvas->print( &painter, &prt, left_margin, top_margin );
00573 painter.end();
00574
00575 zoomDocument(oldZoom);
00576 if ( displayFieldCode )
00577 {
00578 m_pKPresenterDoc->getVariableCollection()->variableSetting()->setDisplayFieldCode(true);
00579 m_pKPresenterDoc->recalcVariables( VT_ALL );
00580 }
00581
00582 m_canvas->repaint();
00583 kdDebug(33001) << "KPrView::print zoom&res reset" << endl;
00584 m_pKPresenterDoc->getVariableCollection()->variableSetting()->setLastPrintingDate(QDateTime::currentDateTime());
00585 m_pKPresenterDoc->recalcVariables( VT_DATE );
00586 }
00587
00588 void KPrView::editCut()
00589 {
00590 if ( !m_canvas->currentTextObjectView() ) {
00591 m_canvas->setToolEditMode( TEM_MOUSE );
00592 #if COPYOASISFORMAT
00593 m_canvas->copyOasisObjs();
00594 #else
00595 m_canvas->copyObjs();
00596 #endif
00597 m_canvas->deleteObjs();
00598 } else {
00599 if ( !m_canvas->currentTextObjectView()->kpTextObject()->isProtectContent())
00600 m_canvas->currentTextObjectView()->cut();
00601 }
00602 }
00603
00604 void KPrView::editCopy()
00605 {
00606 if ( !m_canvas->currentTextObjectView() ) {
00607 m_canvas->setToolEditMode( TEM_MOUSE );
00608 #if COPYOASISFORMAT
00609 m_canvas->copyOasisObjs();
00610 #else
00611 m_canvas->copyObjs();
00612 #endif
00613 }
00614 else
00615 m_canvas->currentTextObjectView()->copy();
00616 }
00617
00618 void KPrView::editPaste()
00619 {
00620 if ( !m_canvas->currentTextObjectView() ) {
00621 m_canvas->setToolEditMode( TEM_MOUSE );
00622 deSelectAllObjects();
00623 QMimeSource *data = QApplication::clipboard()->data();
00624 if ( data->provides( "text/uri-list" ) )
00625 {
00626 m_pKPresenterDoc->pastePage( data, currPg );
00627 setRanges();
00628 skipToPage( currPg );
00629 updateSideBarMenu();
00630 }
00631 else if ( data->provides( KoStoreDrag::mimeType("application/x-kpresenter" ) ))
00632 {
00633
00634 m_canvas->activePage()->pasteObjs(
00635 data->encodedData(KoStoreDrag::mimeType("application/x-kpresenter")),
00636 1, 0.0, 0.0, 0.0, 20.0, 20.0);
00637
00638 m_canvas->setMouseSelectedObject(true);
00639 emit objectSelectedChanged();
00640 }
00641 #if COPYOASISFORMAT
00642 else if ( data->provides( KoStoreDrag::mimeType("application/vnd.oasis.opendocument.presentation" ) ))
00643 {
00644
00645
00646
00647
00648
00649
00650 m_canvas->setMouseSelectedObject(true);
00651 emit objectSelectedChanged();
00652 }
00653 #endif
00654 else if (QImageDrag::canDecode (data)) {
00655 m_canvas->dropImage( data );
00656 }
00657 } else {
00658 if ( !m_canvas->currentTextObjectView()->kpTextObject()->isProtectContent())
00659 m_canvas->currentTextObjectView()->paste();
00660 }
00661 }
00662
00663 void KPrView::editDelete()
00664 {
00665 m_canvas->setToolEditMode( TEM_MOUSE );
00666 m_canvas->deleteObjs();
00667 }
00668
00669 void KPrView::editSelectAll()
00670 {
00671 KPrTextView *edit=m_canvas->currentTextObjectView();
00672 if ( !edit ) {
00673 m_canvas->setToolEditMode( TEM_MOUSE );
00674 m_canvas->selectAllObj();
00675 }
00676 else
00677 edit->selectAll();
00678 }
00679
00680 void KPrView::editDeSelectAll()
00681 {
00682 KPrTextView *edit=m_canvas->currentTextObjectView();
00683 if ( !edit ) {
00684 m_canvas->setToolEditMode( TEM_MOUSE );
00685 deSelectAllObjects();
00686 }
00687 else
00688 edit->selectAll(false);
00689 }
00690
00691 void KPrView::editCopyPage()
00692 {
00693 m_pKPresenterDoc->copyPageToClipboard( currPg );
00694 }
00695
00696 void KPrView::editDuplicatePage()
00697 {
00698 m_pKPresenterDoc->copyPage( currPg );
00699 setRanges();
00700 }
00701
00702 void KPrView::updateSideBarMenu()
00703 {
00704 actionEditDelPage->setEnabled( m_pKPresenterDoc->getPageNums() > 1 );
00705 }
00706
00707 void KPrView::editDelPage()
00708 {
00709 if ( KMessageBox::warningContinueCancel( this,
00710 i18n( "Do you want to remove the current slide?"),i18n("Remove Slide"),KGuiItem(i18n("&Delete"),"editdelete") )
00711 != KMessageBox::Continue )
00712 return;
00713 m_canvas->exitEditMode();
00714 m_pKPresenterDoc->deletePage( currPg );
00715 setRanges();
00716 }
00717
00718 void KPrView::insertPage()
00719 {
00720 InsertPageDia dia( this, 0, TRUE );
00721 #if COPYOASISFORMAT
00722 QString templ = locateLocal( "data", "kpresenter/default.oop" );
00723 #else
00724 QString templ = locateLocal( "data", "kpresenter/default.kpr" );
00725 #endif
00726 if ( !QFile::exists( templ ) ) {
00727 dia.radioDifferent->setChecked( TRUE );
00728 dia.radioDefault->setEnabled( FALSE );
00729 }
00730 if ( dia.exec() != QDialog::Accepted )
00731 return;
00732
00733 if (dia.radioCurrentDefault->isChecked())
00734 {
00735 #if COPYOASISFORMAT
00736 QString file = locateLocal( "data", "kpresenter/default.oop" );
00737 m_pKPresenterDoc->savePage( file, currPg, true );
00738 #else
00739 QString file = locateLocal( "data", "kpresenter/default.kpr" );
00740 m_pKPresenterDoc->savePage( file, currPg, true );
00741 #endif
00742 }
00743
00744 InsertPos pos = (InsertPos)dia.locationCombo->currentItem();
00745 m_pKPresenterDoc->insertNewPage( i18n("Insert new slide"), currPg, pos,
00746 dia.radioDifferent->isChecked(), QString::null );
00747 setRanges();
00748 }
00749
00750 void KPrView::insertPicture()
00751 {
00752 m_canvas->setToolEditMode( INS_PICTURE );
00753 deSelectAllObjects();
00754
00755 QStringList mimetypes;
00756 mimetypes += KImageIO::mimeTypes( KImageIO::Reading );
00757 mimetypes += KoPictureFilePreview::clipartMimeTypes();
00758
00759 KFileDialog fd( m_pKPresenterDoc->picturePath(), QString::null, this, 0, true );
00760 fd.setCaption( i18n( "Insert Picture" ) );
00761 fd.setMimeFilter( mimetypes );
00762 fd.setPreviewWidget( new KoPictureFilePreview( &fd ) );
00763
00764 KURL url;
00765 if ( fd.exec() == QDialog::Accepted )
00766 url = fd.selectedURL();
00767
00768 if( url.isEmpty() || !url.isValid() )
00769 {
00770 m_canvas->setToolEditMode( TEM_MOUSE, false );
00771 return;
00772 }
00773 QString file;
00774 if ( !KIO::NetAccess::download( url, file, this ) )
00775 {
00776 m_canvas->setToolEditMode( TEM_MOUSE, false );
00777 return;
00778 }
00779
00780 if ( !file.isEmpty() )
00781 m_canvas->activePage()->setInsPictureFile( file );
00782 }
00783
00784 void KPrView::insertPicture(const QString &file)
00785 {
00786 m_canvas->setToolEditMode( INS_PICTURE );
00787 deSelectAllObjects();
00788
00789 if ( !file.isEmpty() )
00790 m_canvas->activePage()->setInsPictureFile( file );
00791 }
00792
00793 void KPrView::savePicture()
00794 {
00795 m_canvas->savePicture();
00796 }
00797
00798 void KPrView::savePicture( const QString& oldName, KoPicture& picture)
00799 {
00800 QString oldFile(oldName);
00801 KURL url;
00802 url.setPath( oldFile );
00803 if (!QDir(url.directory()).exists())
00804 oldFile = url.fileName();
00805
00806 QString mimetype=picture.getMimeType();
00807 kdDebug(33001) << "Picture has mime type: " << mimetype << endl;
00808 QStringList mimetypes;
00809 mimetypes << mimetype;
00810
00811 KFileDialog fd( oldFile, QString::null, this, 0, TRUE );
00812 fd.setMimeFilter( mimetypes );
00813 fd.setCaption(i18n("Save Picture"));
00814 fd.setOperationMode(KFileDialog::Saving);
00815 if ( fd.exec() == QDialog::Accepted )
00816 {
00817 url = fd.selectedURL();
00818 if ( url.isValid() )
00819 {
00820 if ( url.isLocalFile() )
00821 {
00822 QFile file( url.path() );
00823 if ( file.open( IO_ReadWrite ) )
00824 {
00825 picture.save( &file );
00826 file.close();
00827 }
00828 else
00829 {
00830 KMessageBox::error(this,
00831 i18n("Error during saving: could not open '%1' for writing.").arg ( url.path() ),
00832 i18n("Save Picture"));
00833 }
00834 }
00835 else
00836 {
00837 KTempFile tempFile;
00838 tempFile.setAutoDelete( true );
00839 if ( tempFile.status() == 0 )
00840 {
00841 QFile file( tempFile.name() );
00842 if ( file.open( IO_ReadWrite ) )
00843 {
00844 picture.save( &file );
00845 file.close();
00846 if ( !KIO::NetAccess::upload( tempFile.name(), url, this ) )
00847 {
00848 KMessageBox::sorry( this, i18n(
00849 "Unable to save the file to '%1'. %2.").arg( url.prettyURL() ).arg( KIO::NetAccess::lastErrorString() ),
00850 i18n("Save Failed") );
00851 }
00852 }
00853 else
00854 KMessageBox::error(this,
00855 i18n("Error during saving: could not open '%1' temporary file for writing.").arg ( file.name() ),
00856 i18n("Save Picture"));
00857 }
00858 else
00859 KMessageBox::sorry( this, i18n(
00860 "Error during saving: could not create temporary file: %1.").arg( strerror( tempFile.status() ) ),
00861 i18n("Save Picture") );
00862 }
00863 }
00864 }
00865 }
00866
00867 void KPrView::savePicture( KPrPixmapObject* obj )
00868 {
00869 QString oldFile=obj->getFileName();
00870 KoPicture picture(obj->picture());
00871 savePicture(oldFile, picture);
00872 }
00873
00874 void KPrView::toolsMouse()
00875 {
00876 if ( actionToolsMouse->isChecked() )
00877 m_canvas->setToolEditMode( TEM_MOUSE, false );
00878 else
00879 actionToolsMouse->setChecked(true);
00880
00881 }
00882
00883 void KPrView::toolsRotate()
00884 {
00885 if ( actionToolsRotate->isChecked() )
00886 m_canvas->setToolEditMode( TEM_ROTATE, false );
00887 else
00888 actionToolsRotate->setChecked(true);
00889 }
00890
00891 void KPrView::toolsZoom()
00892 {
00893 if ( actionToolsZoom->isChecked() )
00894 m_canvas->setToolEditMode( TEM_ZOOM, false );
00895 else
00896 actionToolsZoom->setChecked(true);
00897 }
00898
00899 void KPrView::toolsLinePopup()
00900 {
00901 switch (m_currentLineTool)
00902 {
00903 case LtLine:
00904 actionToolsLine->activate();
00905 break;
00906 case LtFreehand:
00907 actionToolsFreehand->activate();
00908 break;
00909 case LtPolyline:
00910 actionToolsPolyline->activate();
00911 break;
00912 case LtQuadricBezier:
00913 actionToolsQuadricBezierCurve->activate();
00914 break;
00915 case LtCubicBezier:
00916 actionToolsCubicBezierCurve->activate();
00917 break;
00918 }
00919 }
00920
00921 void KPrView::toolsLine()
00922 {
00923 if ( actionToolsLine->isChecked() )
00924 {
00925 m_canvas->setToolEditMode( INS_LINE, false );
00926 deSelectAllObjects();
00927 m_currentLineTool = LtLine;
00928 actionToolsLinePopup->setIcon("line");
00929 }
00930 else
00931 actionToolsLine->setChecked(true);
00932 }
00933
00934 void KPrView::toolsShapePopup()
00935 {
00936 switch (m_currentShapeTool)
00937 {
00938 case StRectangle:
00939 actionToolsRectangle->activate();
00940 break;
00941 case StCircle:
00942 actionToolsCircleOrEllipse->activate();
00943 break;
00944 case StPie:
00945 actionToolsPie->activate();
00946 break;
00947 case StPolygon:
00948 actionToolsConvexOrConcavePolygon->activate();
00949 break;
00950 }
00951 }
00952
00953 void KPrView::toolsRectangle()
00954 {
00955 if ( actionToolsRectangle->isChecked() )
00956 {
00957 deSelectAllObjects();
00958 m_canvas->setToolEditMode( INS_RECT, false );
00959 m_currentShapeTool = StRectangle;
00960 actionToolsShapePopup->setIcon("rectangle");
00961 }
00962 else
00963 actionToolsRectangle->setChecked(true);
00964 }
00965
00966 void KPrView::toolsCircleOrEllipse()
00967 {
00968 if ( actionToolsCircleOrEllipse->isChecked() )
00969 {
00970 deSelectAllObjects();
00971 m_canvas->setToolEditMode( INS_ELLIPSE, false );
00972 m_currentShapeTool = StCircle;
00973 actionToolsShapePopup->setIcon("circle");
00974 }
00975 else
00976 actionToolsCircleOrEllipse->setChecked(true);
00977 }
00978
00979 void KPrView::toolsPie()
00980 {
00981 if ( actionToolsPie->isChecked() )
00982 {
00983 deSelectAllObjects();
00984 m_canvas->setToolEditMode( INS_PIE, false );
00985 m_currentShapeTool = StPie;
00986 actionToolsShapePopup->setIcon("pie");
00987 }
00988 else
00989 actionToolsPie->setChecked(true);
00990 }
00991
00992 void KPrView::toolsDiagramm()
00993 {
00994 if ( actionToolsDiagramm->isChecked() )
00995 {
00996 deSelectAllObjects();
00997 m_canvas->setToolEditMode( INS_DIAGRAMM, false );
00998
00999 KoDocumentEntry entry = KoDocumentEntry::queryByMimeType( "application/x-kchart" );
01000 if (entry.isEmpty())
01001 {
01002 KMessageBox::sorry( this, i18n( "No chart component registered" ) );
01003 m_canvas->setToolEditMode( TEM_MOUSE );
01004 }
01005 else
01006 m_canvas->setPartEntry( entry );
01007 }
01008 else
01009 actionToolsDiagramm->setChecked(true);
01010 }
01011
01012 void KPrView::toolsTable()
01013 {
01014 if ( actionToolsTable->isChecked() )
01015 {
01016 deSelectAllObjects();
01017 m_canvas->setToolEditMode( INS_TABLE, false );
01018
01019 KoDocumentEntry entry = KoDocumentEntry::queryByMimeType( "application/x-kspread" );
01020 if (entry.isEmpty())
01021 {
01022 KMessageBox::sorry( this, i18n( "No table component registered" ) );
01023 m_canvas->setToolEditMode( TEM_MOUSE );
01024 }
01025 else
01026 m_canvas->setPartEntry( entry );
01027 }
01028 else
01029 actionToolsTable->setChecked(true);
01030 }
01031
01032 void KPrView::toolsFormula()
01033 {
01034 if ( actionToolsFormula->isChecked() )
01035 {
01036 deSelectAllObjects();
01037 m_canvas->setToolEditMode( INS_FORMULA, false );
01038
01039 KoDocumentEntry entry = KoDocumentEntry::queryByMimeType( "application/x-kformula" );
01040 if (entry.isEmpty())
01041 {
01042 KMessageBox::sorry( this, i18n( "No formula component registered" ) );
01043 m_canvas->setToolEditMode( TEM_MOUSE );
01044 }
01045 else
01046 m_canvas->setPartEntry( entry );
01047 }
01048 else
01049 actionToolsFormula->setChecked(true);
01050 }
01051
01052 void KPrView::toolsText()
01053 {
01054 if ( actionToolsText->isChecked() )
01055 {
01056 deSelectAllObjects();
01057 m_canvas->setToolEditMode( INS_TEXT, false );
01058 }
01059 else
01060 actionToolsText->setChecked(true);
01061 }
01062
01063 void KPrView::toolsAutoform()
01064 {
01065 if ( actionToolsAutoform->isChecked() )
01066 {
01067 deSelectAllObjects();
01068 m_canvas->setToolEditMode( TEM_MOUSE, false );
01069 if ( afChoose ) {
01070 delete afChoose;
01071 afChoose = 0;
01072 }
01073 afChoose = new AFChoose( this, i18n( "Autoform-Choose" ) );
01074 afChoose->resize( 400, 300 );
01075 afChoose->setCaption( i18n( "Insert Autoform" ) );
01076
01077 QObject::connect( afChoose, SIGNAL( formChosen( const QString & ) ),
01078 this, SLOT( afChooseOk( const QString & ) ) );
01079 QObject::connect( afChoose, SIGNAL( afchooseCanceled()),
01080 this,SLOT(slotAfchooseCanceled()));
01081 afChoose->exec();
01082
01083 QObject::disconnect( afChoose, SIGNAL( formChosen( const QString & ) ),
01084 this, SLOT( afChooseOk( const QString & ) ) );
01085 delete afChoose;
01086 afChoose = 0;
01087 }
01088 else
01089 actionToolsAutoform->setChecked(true);
01090 }
01091
01092 void KPrView::toolsObject()
01093 {
01094 KoDocumentEntry pe = actionToolsObject->documentEntry();
01095 if ( pe.isEmpty() ) {
01096 m_canvas->setToolEditMode( TEM_MOUSE );
01097 return;
01098 }
01099
01100 m_canvas->setToolEditMode( INS_OBJECT );
01101 m_canvas->setPartEntry( pe );
01102 }
01103
01104 void KPrView::toolsFreehand()
01105 {
01106 if ( actionToolsFreehand->isChecked() ) {
01107 m_canvas->setToolEditMode( INS_FREEHAND, false );
01108 deSelectAllObjects();
01109 m_currentLineTool = LtFreehand;
01110 actionToolsLinePopup->setIcon("freehand");
01111 }
01112 else
01113 actionToolsFreehand->setChecked(true);
01114 }
01115
01116 void KPrView::toolsPolyline()
01117 {
01118 if ( actionToolsPolyline->isChecked() ) {
01119 m_canvas->setToolEditMode( INS_POLYLINE, false );
01120 deSelectAllObjects();
01121 m_currentLineTool = LtPolyline;
01122 actionToolsLinePopup->setIcon("polyline");
01123 }
01124 else
01125 actionToolsPolyline->setChecked(true);
01126 }
01127
01128 void KPrView::toolsQuadricBezierCurve()
01129 {
01130 if ( actionToolsQuadricBezierCurve->isChecked() ) {
01131 m_canvas->setToolEditMode( INS_QUADRICBEZIERCURVE, false );
01132 deSelectAllObjects();
01133 m_currentLineTool = LtQuadricBezier;
01134 actionToolsLinePopup->setIcon("quadricbeziercurve");
01135 }
01136 else
01137 actionToolsQuadricBezierCurve->setChecked(true);
01138 }
01139
01140 void KPrView::toolsCubicBezierCurve()
01141 {
01142 if ( actionToolsCubicBezierCurve->isChecked() ) {
01143 m_canvas->setToolEditMode( INS_CUBICBEZIERCURVE, false );
01144 deSelectAllObjects();
01145 m_currentLineTool = LtCubicBezier;
01146 actionToolsLinePopup->setIcon("cubicbeziercurve");
01147 }
01148 else
01149 actionToolsCubicBezierCurve->setChecked(true);
01150 }
01151
01152 void KPrView::toolsConvexOrConcavePolygon()
01153 {
01154 if ( actionToolsConvexOrConcavePolygon->isChecked() ) {
01155 m_canvas->setToolEditMode( INS_POLYGON, false );
01156 deSelectAllObjects();
01157 m_currentShapeTool = StPolygon;
01158 actionToolsShapePopup->setIcon("polygon");
01159 }
01160 else
01161 actionToolsConvexOrConcavePolygon->setChecked(true);
01162 }
01163
01164 void KPrView::toolsClosedLinePopup()
01165 {
01166 switch (m_currentClosedLineTool)
01167 {
01168 case CltFreehand:
01169 actionToolsClosedFreehand->activate();
01170 break;
01171 case CltPolyline:
01172 actionToolsClosedPolyline->activate();
01173 break;
01174 case CltQuadricBezier:
01175 actionToolsClosedQuadricBezierCurve->activate();
01176 break;
01177 case CltCubicBezier:
01178 actionToolsClosedCubicBezierCurve->activate();
01179 break;
01180 }
01181 }
01182
01183 void KPrView::toolsClosedFreehand()
01184 {
01185 if ( actionToolsClosedFreehand->isChecked() ) {
01186 m_canvas->setToolEditMode( INS_CLOSED_FREEHAND, false );
01187 deSelectAllObjects();
01188 m_currentClosedLineTool = CltFreehand;
01189 actionToolsClosedLinePopup->setIcon("closed_freehand");
01190 }
01191 else
01192 actionToolsClosedFreehand->setChecked( true );
01193 }
01194
01195 void KPrView::toolsClosedPolyline()
01196 {
01197 if ( actionToolsClosedPolyline->isChecked() ) {
01198 m_canvas->setToolEditMode( INS_CLOSED_POLYLINE, false );
01199 deSelectAllObjects();
01200 m_currentClosedLineTool = CltPolyline;
01201 actionToolsClosedLinePopup->setIcon("closed_polyline");
01202 }
01203 else
01204 actionToolsClosedPolyline->setChecked( true );
01205 }
01206
01207 void KPrView::toolsClosedQuadricBezierCurve()
01208 {
01209 if ( actionToolsClosedQuadricBezierCurve->isChecked() ) {
01210 m_canvas->setToolEditMode( INS_CLOSED_QUADRICBEZIERCURVE, false );
01211 deSelectAllObjects();
01212 m_currentClosedLineTool = CltQuadricBezier;
01213 actionToolsClosedLinePopup->setIcon("closed_quadricbeziercurve");
01214 }
01215 else
01216 actionToolsClosedQuadricBezierCurve->setChecked( true );
01217 }
01218
01219 void KPrView::toolsClosedCubicBezierCurve()
01220 {
01221 if ( actionToolsClosedCubicBezierCurve->isChecked() ) {
01222 m_canvas->setToolEditMode( INS_CLOSED_CUBICBEZIERCURVE, false );
01223 deSelectAllObjects();
01224 m_currentClosedLineTool = CltCubicBezier;
01225 actionToolsClosedLinePopup->setIcon("closed_cubicbeziercurve");
01226 }
01227 else
01228 actionToolsClosedCubicBezierCurve->setChecked( true );
01229 }
01230
01231 void KPrView::extraProperties()
01232 {
01233 m_canvas->setToolEditMode( TEM_MOUSE );
01234
01235 m_propertyEditor = new KPrPropertyEditor( this, "KPrPropertyEditor", m_canvas->activePage(), m_pKPresenterDoc );
01236 m_propertyEditor->setCaption( i18n( "Properties" ) );
01237
01238 connect( m_propertyEditor, SIGNAL( propertiesOk() ), this, SLOT( propertiesOk() ) );
01239 m_propertyEditor->exec();
01240 disconnect( m_propertyEditor, SIGNAL( propertiesOk() ), this, SLOT( propertiesOk() ) );
01241
01242 delete m_propertyEditor;
01243 m_propertyEditor = 0;
01244 }
01245
01246 void KPrView::extraRaise()
01247 {
01248 m_canvas->setToolEditMode( TEM_MOUSE );
01249 m_canvas->raiseObjs( true );
01250 }
01251
01252 void KPrView::extraLower()
01253 {
01254 m_canvas->setToolEditMode( TEM_MOUSE );
01255 m_canvas->lowerObjs( true );
01256 }
01257
01258 void KPrView::extraRotate()
01259 {
01260 if ( m_canvas->numberOfObjectSelected() > 0 ) {
01261 if ( !rotateDia ) {
01262 rotateDia = new KPrRotationDialogImpl( this );
01263 connect( rotateDia, SIGNAL( apply() ), this, SLOT( rotateOk() ) );
01264 }
01265 rotateDia->setAngle( m_canvas->getSelectedObj()->getAngle() );
01266 m_canvas->setToolEditMode( TEM_MOUSE );
01267 rotateDia->exec();
01268 }
01269 }
01270
01271 void KPrView::extraShadow()
01272 {
01273 if ( m_canvas->numberOfObjectSelected() > 0 ) {
01274
01275 if ( !shadowDia ) {
01276 shadowDia = new KPrShadowDialogImpl( this );
01277 shadowDia->resize( shadowDia->minimumSize() );
01278 connect( shadowDia, SIGNAL( apply() ), this, SLOT( shadowOk() ) );
01279 }
01280
01281 KPrObject *object=m_canvas->getSelectedObj();
01282 shadowDia->setShadowDirection( object->getShadowDirection() );
01283 if ( object->getShadowDistance() != 0 )
01284 shadowDia->setShadowDistance( object->getShadowDistance() );
01285 else
01286 shadowDia->setShadowDistance( 3 );
01287
01288 shadowDia->setShadowColor( object->getShadowColor() );
01289 m_canvas->setToolEditMode( TEM_MOUSE );
01290 shadowDia->exec();
01291 }
01292 }
01293
01294 void KPrView::extraBackground()
01295 {
01296 KPrPage *page=m_canvas->activePage();
01297 KPrBackDialog* backDia = new KPrBackDialog( this, "InfoDia", page->getBackType( ),
01298 page->getBackColor1( ),
01299 page->getBackColor2( ),
01300 page->getBackColorType( ),
01301 page->getBackPicture( ),
01302 page->getBackView(),
01303 page->getBackUnbalanced(),
01304 page->getBackXFactor(),
01305 page->getBackYFactor( ),
01306 page );
01307 backDia->setCaption( i18n( "Slide Background" ) );
01308 QObject::connect( backDia, SIGNAL( backOk( KPrBackDialog*, bool ) ), this, SLOT( backOk( KPrBackDialog*, bool ) ) ) ;
01309 backDia->exec();
01310
01311 QObject::disconnect( backDia, SIGNAL( backOk( KPrBackDialog*, bool ) ), this, SLOT( backOk( KPrBackDialog*, bool ) ) );
01312 delete backDia;
01313 }
01314
01315 void KPrView::extraLayout()
01316 {
01317 KoPageLayout pgLayout = m_pKPresenterDoc->pageLayout();
01318 KoPageLayout oldLayout = pgLayout;
01319 KoHeadFoot hf;
01320 KoUnit::Unit oldUnit = m_pKPresenterDoc->unit();
01321 KoUnit::Unit unit = oldUnit;
01322
01323 if ( KoPageLayoutDia::pageLayout( pgLayout, hf, FORMAT_AND_BORDERS, unit, this ) ) {
01324 KPrPgLayoutCmd *pgLayoutCmd = new KPrPgLayoutCmd( i18n( "Set Page Layout" ),
01325 pgLayout, oldLayout, oldUnit, unit,kPresenterDoc() );
01326 pgLayoutCmd->execute();
01327 kPresenterDoc()->addCommand( pgLayoutCmd );
01328 updateRuler();
01329 }
01330 }
01331
01332 void KPrView::extraConfigure()
01333 {
01334 KPrConfig configDia( this );
01335 configDia.exec();
01336 }
01337
01338 void KPrView::extraCreateTemplate()
01339 {
01340 int width = 60;
01341 int height = 60;
01342 QPixmap pix = m_pKPresenterDoc->generatePreview(QSize(width, height));
01343 #if COPYOASISFORMAT
01344 KTempFile tempFile( QString::null, ".otp" );
01345 tempFile.setAutoDelete( true );
01346 m_pKPresenterDoc->savePage( tempFile.name(), getCurrPgNum() - 1);
01347 #else
01348 KTempFile tempFile( QString::null, ".kpt" );
01349 tempFile.setAutoDelete( true );
01350 m_pKPresenterDoc->savePage( tempFile.name(), getCurrPgNum() - 1);
01351 #endif
01352
01353 KoTemplateCreateDia::createTemplate( "kpresenter_template", KPrFactory::global(),
01354 tempFile.name(), pix, this);
01355 KPrFactory::global()->dirs()->addResourceType("kpresenter_template",
01356 KStandardDirs::kde_default( "data" ) +
01357 "kpresenter/templates/");
01358 }
01359
01360 void KPrView::extraDefaultTemplate()
01361 {
01362 #if COPYOASISFORMAT
01363 QString file = locateLocal( "data", "kpresenter/default.oop" );
01364 m_pKPresenterDoc->savePage( file, currPg );
01365 #else
01366 QString file = locateLocal( "data", "kpresenter/default.kpr" );
01367 m_pKPresenterDoc->savePage( file, currPg );
01368 #endif
01369 }
01370
01371 void KPrView::extraWebPres()
01372 {
01373 if ( !allowWebPres )
01374 return;
01375
01376 KURL url;
01377 QString config = QString::null;
01378 int ret =KMessageBox::questionYesNoCancel( this,
01379 i18n( "Do you want to load a previously saved configuration"
01380 " which will be used for this HTML Presentation?" ),
01381 i18n( "Create HTML Presentation" ) );
01382 if( ret == KMessageBox::Cancel )
01383 return;
01384 else if ( ret == KMessageBox::Yes )
01385 {
01386 url = KFileDialog::getOpenURL( QString::null, i18n("*.kpweb|KPresenter HTML Presentation (*.kpweb)"), this );
01387
01388 if( url.isEmpty() )
01389 return;
01390
01391 if( !url.isLocalFile() )
01392 {
01393 KMessageBox::sorry( this, i18n( "Only local files are currently supported." ) );
01394 return;
01395 }
01396
01397 config = url.path();
01398 }
01399
01400 KPrWebPresentationWizard::createWebPresentation( config, m_pKPresenterDoc, this );
01401 }
01402
01403 void KPrView::extraMSPres()
01404 {
01405 if ( !allowMSPres )
01406 return;
01407
01408 KPrMSPresentationSetup::createMSPresentation( m_pKPresenterDoc, this );
01409 }
01410
01411 void KPrView::extraLineBegin()
01412 {
01413 m_canvas->setToolEditMode( TEM_MOUSE );
01414 QPoint pnt( QCursor::pos() );
01415 rb_lbegin->popup( pnt );
01416 }
01417
01418 void KPrView::extraLineEnd()
01419 {
01420 m_canvas->setToolEditMode( TEM_MOUSE );
01421 QPoint pnt( QCursor::pos() );
01422 rb_lend->popup( pnt );
01423 }
01424
01425 void KPrView::extraGroup()
01426 {
01427 m_canvas->setToolEditMode( TEM_MOUSE );
01428 m_canvas->groupObjects();
01429 objectSelectedChanged();
01430 }
01431
01432 void KPrView::extraUnGroup()
01433 {
01434 m_canvas->setToolEditMode( TEM_MOUSE );
01435 m_canvas->ungroupObjects();
01436 objectSelectedChanged();
01437 }
01438
01439 void KPrView::extraPenStyle( int newStyle )
01440 {
01441 m_canvas->setToolEditMode( TEM_MOUSE );
01442 setExtraPenStyle(static_cast<Qt::PenStyle>(newStyle));
01443 }
01444
01445 void KPrView::extraPenWidth( double newWidth )
01446 {
01447 m_canvas->setToolEditMode( TEM_MOUSE );
01448 setExtraPenWidth( newWidth );
01449 }
01450
01451 void KPrView::screenConfigPages()
01452 {
01453 delete pgConfDia;
01454 pgConfDia = new KPrPgConfDia( this, kPresenterDoc() );
01455 pgConfDia->setCaption( i18n( "Configure Slide Show" ) );
01456 QObject::connect( pgConfDia, SIGNAL( pgConfDiaOk() ), this, SLOT( pgConfOk() ) );
01457 pgConfDia->exec();
01458
01459 QObject::disconnect( pgConfDia, SIGNAL( pgConfDiaOk() ), this, SLOT( pgConfOk() ) );
01460 delete pgConfDia;
01461 pgConfDia = 0;
01462 }
01463
01464
01465 void KPrView::screenTransEffect()
01466 {
01467 KPrSlideTransitionDia transitionDia( this, "slideTransitionDialog", this );
01468 transitionDia.exec();
01469 }
01470
01471 void KPrView::screenAssignEffect()
01472 {
01473 m_canvas->setToolEditMode( TEM_MOUSE );
01474
01475 QPtrList<KPrObject> objs;
01476 if ( m_canvas->canAssignEffect( objs ) ) {
01477 KPrEffectDia *effectDia = new KPrEffectDia( this, "Object Effect", objs, this );
01478 effectDia->setCaption( i18n( "Object Effect" ) );
01479 effectDia->exec();
01480 delete effectDia;
01481 }
01482 }
01483
01484 void KPrView::screenStart()
01485 {
01486 startScreenPres( getCurrPgNum() );
01487 }
01488
01489 void KPrView::screenStartFromFirst()
01490 {
01491 startScreenPres( 1 );
01492 }
01493
01494 void KPrView::startScreenPres( int pgNum )
01495 {
01496
01497 if( !kPresenterDoc()->displaySelectedSlides().count() )
01498 {
01499 KMessageBox::sorry( this, i18n("You didn't select any slide." ),
01500 i18n("No Slide") );
01501 return;
01502 }
01503
01504 m_canvas->setToolEditMode( TEM_MOUSE );
01505
01506 if ( m_canvas && !presStarted ) {
01507 const QString xdgScreenSaver = KStandardDirs::findExe("xdg-screensaver");
01508 if (!xdgScreenSaver.isEmpty()) {
01509 KProcess proc;
01510 proc << xdgScreenSaver;
01511 proc << "suspend";
01512 proc << QString::number( topLevelWidget()->winId() );
01513 kdDebug() << k_funcinfo << proc.args() << endl;
01514 proc.start( KProcess::DontCare );
01515 } else {
01516 QByteArray data;
01517 QByteArray replyData;
01518 QCString replyType;
01519 m_screenSaverWasEnabled = false;
01520
01521 if (kapp->dcopClient()->call("kdesktop", "KScreensaverIface", "isEnabled()", data, replyType, replyData)
01522 && replyType=="bool")
01523 {
01524 QDataStream replyArg(replyData, IO_ReadOnly);
01525 replyArg >> m_screenSaverWasEnabled;
01526 kdDebug() << "Screensaver was enabled:" << m_screenSaverWasEnabled << endl;
01527 if ( m_screenSaverWasEnabled )
01528 {
01529
01530 QDataStream arg(data, IO_WriteOnly);
01531 arg << false;
01532 if (!kapp->dcopClient()->send("kdesktop", "KScreensaverIface", "enable(bool)", data))
01533 kdWarning(33001) << "Couldn't disable screensaver (using dcop to kdesktop)!" << endl;
01534 else
01535 kdDebug(33001) << "Screensaver successfully disabled" << endl;
01536 }
01537 } else {
01538 kdWarning(33001) << "Couldn't check screensaver (using dcop to kdesktop)!" << endl;
01539 }
01540
01541 m_dpmsWasEnabled = isDPMSEnabled();
01542 kdDebug() << "DPMS was enabled:" << m_dpmsWasEnabled << endl;
01543 if ( m_dpmsWasEnabled ) {
01544 enableDPMS( false );
01545 }
01546 }
01547
01548 deSelectAllObjects();
01549 presStarted = true;
01550 m_autoPresRestart = false;
01551 QRect desk = KGlobalSettings::desktopGeometry(this);
01552 kdDebug(33001) << "KPrView::startScreenPres desk=" << desk << endl;
01553 QRect pgRect = kPresenterDoc()->pageList().at(0)->getZoomPageRect();
01554 kdDebug(33001) << "KPrView::startScreenPres pgRect=" << pgRect << endl;
01555
01556 double zoomX = static_cast<double>( desk.width() ) / (double)pgRect.width();
01557 double zoomY = static_cast<double>( desk.height() ) / (double)pgRect.height();
01558 kdDebug(33001) << "KPrView::startScreenPres zoomX=" << zoomX << " zoomY=" << zoomY << endl;
01559
01560 xOffsetSaved = canvasXOffset();
01561 yOffsetSaved = canvasYOffset();
01562 setCanvasXOffset( 0 );
01563 setCanvasYOffset( 0 );
01564
01565 m_bDisplayFieldCode = m_pKPresenterDoc->getVariableCollection()->variableSetting()->displayFieldCode();
01566 if ( m_bDisplayFieldCode )
01567 {
01568 m_pKPresenterDoc->getVariableCollection()->variableSetting()->setDisplayFieldCode(false);
01569 m_pKPresenterDoc->recalcVariables( VT_ALL );
01570 }
01571
01572 vert->setEnabled( false );
01573 horz->setEnabled( false );
01574 m_bShowGUI = false;
01575 m_canvas->reparent( ( QWidget* )0L, 0, QPoint( 0, 0 ), FALSE );
01576 m_canvas->setPaletteBackgroundColor( Qt::white );
01577 m_canvas->showFullScreen();
01578 m_canvas->setFocusPolicy( QWidget::StrongFocus );
01579
01580 if ( !kPresenterDoc()->spManualSwitch() )
01581 {
01582 m_autoPresStop = false;
01583 m_pKPresenterDoc->repaint( false );
01584
01585 if ( ! m_autoPresTimerConnected ) {
01586 connect( &m_autoPresTimer, SIGNAL( timeout() ), SLOT( doAutomaticScreenPres() ) );
01587 m_autoPresTimerConnected = true;
01588 }
01589 }
01590
01591 m_canvas->startScreenPresentation( zoomX, zoomY, pgNum );
01592
01593 actionScreenStart->setEnabled( false );
01594
01595 if ( kPresenterDoc()->presentationDuration() ) {
01596 m_duration.start();
01597
01598
01599 for ( unsigned int i = 0; i < kPresenterDoc()->pageList().count(); ++i )
01600 m_presentationDurationList.append( 0 );
01601 }
01602 }
01603 }
01604
01605 void KPrView::screenStop()
01606 {
01607 if ( presStarted ) {
01608 m_autoPresStop = true;
01609 m_canvas->stopSound();
01610 m_canvas->showNormal();
01611 m_canvas->hide();
01612 m_canvas->reparent( pageBase, 0, QPoint( 0, 0 ), true );
01613 m_canvas->lower();
01614 setCanvasXOffset( xOffsetSaved );
01615 setCanvasYOffset( yOffsetSaved );
01616
01617 if ( m_bDisplayFieldCode )
01618 {
01619 m_pKPresenterDoc->getVariableCollection()->variableSetting()->setDisplayFieldCode(true);
01620 m_pKPresenterDoc->recalcVariables( VT_ALL );
01621 }
01622
01623 m_canvas->stopScreenPresentation();
01624 presStarted = false;
01625 vert->setEnabled( true );
01626 horz->setEnabled( true );
01627 m_bShowGUI = true;
01628 m_canvas->setMouseTracking( true );
01629 m_canvas->setBackgroundMode( Qt::NoBackground );
01630
01631 const QString xdgScreenSaver = KStandardDirs::findExe("xdg-screensaver");
01632 if (!xdgScreenSaver.isEmpty()) {
01633 KProcess proc;
01634 proc << xdgScreenSaver;
01635 proc << "resume";
01636 proc << QString::number( topLevelWidget()->winId() );
01637 kdDebug() << k_funcinfo << proc.args() << endl;
01638 proc.start( KProcess::DontCare );
01639 } else {
01640 if ( m_screenSaverWasEnabled )
01641 {
01642
01643 QByteArray data;
01644 QDataStream arg(data, IO_WriteOnly);
01645 arg << true;
01646 if (!kapp->dcopClient()->send("kdesktop", "KScreensaverIface", "enable(bool)", data))
01647 kdWarning(33001) << "Couldn't re-enabled screensaver (using dcop to kdesktop)" << endl;
01648 }
01649 if ( m_dpmsWasEnabled )
01650 {
01651
01652 kdDebug(33001) << "Re-enabling DPMS" << endl;
01653 enableDPMS( true );
01654 }
01655 }
01656
01657 actionScreenStart->setEnabled( true );
01658 pageBase->resizeEvent( 0 );
01659
01660 if ( kPresenterDoc()->presentationDuration() && !m_presentationDurationList.isEmpty() ) {
01661 openThePresentationDurationDialog();
01662 m_presentationDurationList.clear();
01663 }
01664 }
01665 emit presentationFinished();
01666 }
01667
01668 void KPrView::screenPause()
01669 {
01670 }
01671
01672 void KPrView::screenFirst()
01673 {
01674 m_canvas->deSelectAllObj();
01675
01676 if ( !presStarted )
01677 skipToPage( 0 );
01678 else
01679 gotoPresPage( 1 );
01680 }
01681
01682 void KPrView::screenPrev( bool gotoPreviousPage )
01683 {
01684 if ( m_canvas->currentTextObjectView() )
01685 return;
01686
01687 if ( presStarted ) {
01688 m_canvas->pPrev( gotoPreviousPage );
01689 m_canvas->setFocus();
01690 }
01691 else
01692 prevPage();
01693 }
01694
01695 void KPrView::screenNext( bool gotoNextPage )
01696 {
01697 if ( m_canvas->currentTextObjectView() )
01698 return;
01699 if ( presStarted )
01700 {
01701 m_canvas->pNext( gotoNextPage );
01702 m_canvas->setFocus();
01703 }
01704 else
01705 {
01706 nextPage();
01707 }
01708 }
01709
01710 void KPrView::screenLast()
01711 {
01712 m_canvas->deSelectAllObj();
01713
01714 if ( !presStarted )
01715 skipToPage( m_pKPresenterDoc->getPageNums() - 1 );
01716 else
01717 gotoPresPage( getNumPresPages() );
01718 }
01719
01720 void KPrView::screenSkip()
01721 {
01722 }
01723
01724 void KPrView::sizeSelected( int size )
01725 {
01726 tbFont.setPointSize( size );
01727 m_canvas->setTextPointSize( size );
01728 m_canvas->setFocus();
01729 }
01730
01731 void KPrView::fontSelected( const QString &fontFamily )
01732 {
01733 tbFont.setFamily( fontFamily );
01734 m_canvas->setTextFamily( fontFamily );
01735 m_canvas->setFocus();
01736 }
01737
01738 void KPrView::textBold()
01739 {
01740 bool b=actionTextBold->isChecked();
01741 tbFont.setBold( b );
01742 m_canvas->setTextBold(b );
01743 }
01744
01745
01746 void KPrView::textStrikeOut()
01747 {
01748 bool b=actionFormatStrikeOut->isChecked();
01749 tbFont.setStrikeOut( b );
01750 m_canvas->setTextStrikeOut( b );
01751 }
01752
01753 void KPrView::textItalic()
01754 {
01755 bool b=actionTextItalic->isChecked();
01756 tbFont.setItalic( b );
01757 m_canvas->setTextItalic( b );
01758 }
01759
01760 void KPrView::textUnderline()
01761 {
01762 bool b=actionTextUnderline->isChecked();
01763 tbFont.setUnderline( b );
01764 m_canvas->setTextUnderline( b );
01765 }
01766
01767 void KPrView::textColor()
01768 {
01769 tbColor = actionTextColor->color();
01770 m_canvas->setTextColor( tbColor );
01771 }
01772
01773 void KPrView::textAlignLeft()
01774 {
01775 if ( actionTextAlignLeft->isChecked() )
01776 {
01777 tbAlign = Qt::AlignLeft;
01778 m_canvas->setTextAlign( tbAlign );
01779 }
01780 else
01781 actionTextAlignLeft->setChecked(true);
01782 }
01783
01784 void KPrView::textAlignCenter()
01785 {
01786 if ( actionTextAlignCenter->isChecked() )
01787 {
01788 tbAlign = Qt::AlignHCenter;
01789 m_canvas->setTextAlign(tbAlign);
01790 }
01791 else
01792 actionTextAlignCenter->setChecked(true);
01793 }
01794
01795 void KPrView::textAlignRight()
01796 {
01797 if ( actionTextAlignRight->isChecked() )
01798 {
01799 tbAlign = Qt::AlignRight;
01800 m_canvas->setTextAlign(tbAlign);
01801 }
01802 else
01803 actionTextAlignRight->setChecked(true);
01804
01805 }
01806
01807 void KPrView::textAlignBlock()
01808 {
01809 if ( actionTextAlignBlock->isChecked() )
01810 {
01811 tbAlign = Qt::AlignJustify;
01812 m_canvas->setTextAlign(tbAlign);
01813 }
01814 else
01815 actionTextAlignBlock->setChecked(true);
01816
01817 }
01818
01819 void KPrView::textInsertPageNum()
01820 {
01821 KPrTextView *edit=m_canvas->currentTextObjectView();
01822 if ( edit )
01823 edit->insertVariable( VT_PGNUM, KoPageVariable::VST_PGNUM_CURRENT );
01824 }
01825
01826 void KPrView::mtextFont()
01827 {
01828 KoTextFormatInterface* textIface = m_canvas->applicableTextInterfaces().first();
01829 QColor col;
01830 if (textIface)
01831 col = textIface->textBackgroundColor();
01832 col = col.isValid() ? col : QApplication::palette().color( QPalette::Active, QColorGroup::Base );
01833
01834 delete m_fontDlg;
01835
01836 m_fontDlg = new KoFontDia( *textIface->currentFormat()
01837 , m_broker
01838 , this, 0 );
01839
01840 connect( m_fontDlg, SIGNAL( applyFont() ),
01841 this, SLOT( slotApplyFont() ) );
01842 m_fontDlg->exec();
01843
01844 delete m_fontDlg;
01845 m_fontDlg=0L;
01846 }
01847
01848 void KPrView::slotApplyFont()
01849 {
01850 int flags = m_fontDlg->changedFlags();
01851 if ( flags )
01852 {
01853 m_canvas->setTextFormat(m_fontDlg->newFormat(), flags);
01854 }
01855 }
01856
01857 void KPrView::slotCounterStyleSelected()
01858 {
01859 QString actionName = QString::fromLatin1(sender()->name());
01860 if ( actionName.startsWith( "counterstyle_" ) )
01861 {
01862 QString styleStr = actionName.mid(13);
01863
01864 KoParagCounter::Style style = (KoParagCounter::Style)(styleStr.toInt());
01865 KoParagCounter c;
01866 if ( style == KoParagCounter::STYLE_NONE )
01867 c.setNumbering( KoParagCounter::NUM_NONE );
01868 else {
01869 c.setNumbering( KoParagCounter::NUM_LIST );
01870 c.setStyle( style );
01871 if ( c.isBullet() )
01872 c.setSuffix( QString::null );
01873
01874
01875
01876
01877
01878
01879 KPrTextView *edit = m_canvas->currentTextObjectView();
01880 if ( edit && !edit->textObject()->hasSelection() ) {
01881 KoTextParag* parag = edit->cursor()->parag();
01882 if ( parag->prev() && !parag->prev()->counter() )
01883 c.setRestartCounter(true);
01884 }
01885 }
01886
01887 QPtrList<KoTextFormatInterface> lst = m_canvas->applicableTextInterfaces();
01888 QPtrListIterator<KoTextFormatInterface> it( lst );
01889 KMacroCommand* macroCmd = 0L;
01890 for ( ; it.current() ; ++it )
01891 {
01892 KCommand *cmd = it.current()->setCounterCommand( c );
01893 if ( cmd )
01894 {
01895 if ( !macroCmd )
01896 macroCmd = new KMacroCommand( i18n("Change List Type") );
01897 macroCmd->addCommand( cmd );
01898 }
01899 }
01900 if( macroCmd)
01901 m_pKPresenterDoc->addCommand( macroCmd );
01902 }
01903
01904 }
01905
01906 void KPrView::textDepthPlus()
01907 {
01908 m_canvas->setTextDepthPlus();
01909 }
01910
01911 void KPrView::textDepthMinus()
01912 {
01913 m_canvas->setTextDepthMinus();
01914 }
01915
01916 void KPrView::textContentsToHeight()
01917 {
01918 m_canvas->textContentsToHeight();
01919 }
01920
01921 void KPrView::textObjectToContents()
01922 {
01923 m_canvas->textObjectToContents();
01924 }
01925
01926 void KPrView::penChosen()
01927 {
01928 QColor c = actionPenColor->color();
01929 if ( !m_canvas->currentTextObjectView() )
01930 {
01931 KCommand * cmd( getPenCmd( i18n( "Change Outline Color" ), KoPen(c),
01932 L_NORMAL, L_NORMAL, KoPenCmd::Color ) );
01933 if( cmd )
01934 m_pKPresenterDoc->addCommand( cmd );
01935 else
01936 pen.setColor( c );
01937 }
01938 else
01939 {
01940 tbColor = c;
01941 m_canvas->setTextColor( tbColor );
01942 }
01943 }
01944
01945 void KPrView::brushChosen()
01946 {
01947 QColor c = actionBrushColor->color();
01948 KPrTextView *edit = m_canvas->currentTextObjectView();
01949 if ( !edit )
01950 {
01951
01952 KMacroCommand * macro= NULL;
01953 KCommand * cmd = NULL;
01954 QBrush newBrush( c );
01955
01956 cmd = m_canvas->activePage()->setBrush( newBrush, FT_BRUSH, QColor(), QColor(), BCT_PLAIN, false,
01957 0, 0, KPrBrushCmd::BrushColor | KPrBrushCmd::BrushStyle |
01958 KPrBrushCmd::BrushGradientSelect );
01959 if( cmd )
01960 {
01961 if ( !macro )
01962 macro = new KMacroCommand( i18n( "Change Fill Color" ) );
01963 macro->addCommand( cmd );
01964 }
01965
01966
01967 if( macro )
01968 m_pKPresenterDoc->addCommand( macro );
01969 else
01970 brush.setColor( c );
01971 }
01972 else
01973 {
01974 tbColor = c;
01975 m_canvas->setTextBackgroundColor( c );
01976 }
01977 }
01978
01979 void KPrView::extraAlignObjLeft()
01980 {
01981 m_canvas->alignObjects( AT_LEFT );
01982 }
01983
01984 void KPrView::extraAlignObjCenterH()
01985 {
01986 m_canvas->alignObjects( AT_HCENTER );
01987 }
01988
01989 void KPrView::extraAlignObjRight()
01990 {
01991 m_canvas->alignObjects( AT_RIGHT );
01992 }
01993
01994 void KPrView::extraAlignObjTop()
01995 {
01996 m_canvas->alignObjects( AT_TOP );
01997 }
01998
01999 void KPrView::extraAlignObjCenterV()
02000 {
02001 m_canvas->alignObjects( AT_VCENTER );
02002 }
02003
02004 void KPrView::extraAlignObjBottom()
02005 {
02006 m_canvas->alignObjects( AT_BOTTOM );
02007 }
02008
02009 void KPrView::extraLineBeginNormal()
02010 {
02011 setExtraLineBegin(L_NORMAL);
02012 }
02013
02014 void KPrView::extraLineBeginArrow()
02015 {
02016 setExtraLineBegin(L_ARROW);
02017 }
02018
02019 void KPrView::extraLineBeginRect()
02020 {
02021 setExtraLineBegin(L_SQUARE);
02022 }
02023
02024 void KPrView::extraLineBeginCircle()
02025 {
02026 setExtraLineBegin(L_CIRCLE);
02027 }
02028
02029 void KPrView::extraLineBeginLineArrow()
02030 {
02031 setExtraLineBegin( L_LINE_ARROW );
02032 }
02033
02034 void KPrView::extraLineBeginDimensionLine()
02035 {
02036 setExtraLineBegin( L_DIMENSION_LINE );
02037 }
02038
02039 void KPrView::extraLineBeginDoubleArrow()
02040 {
02041 setExtraLineBegin( L_DOUBLE_ARROW );
02042 }
02043
02044 void KPrView::extraLineBeginDoubleLineArrow()
02045 {
02046 setExtraLineBegin( L_DOUBLE_LINE_ARROW );
02047 }
02048
02049 void KPrView::setExtraLineBegin(LineEnd lb)
02050 {
02051 KCommand * cmd( getPenCmd( i18n("Change Line Begin"), KoPen(),
02052 lb, L_NORMAL, KoPenCmd::LineBegin ) );
02053 if( cmd )
02054 kPresenterDoc()->addCommand( cmd );
02055 else
02056 lineBegin = lb;
02057 }
02058
02059 void KPrView::extraLineEndNormal()
02060 {
02061 setExtraLineEnd(L_NORMAL);
02062 }
02063
02064 void KPrView::extraLineEndArrow()
02065 {
02066 setExtraLineEnd(L_ARROW);
02067 }
02068
02069 void KPrView::extraLineEndRect()
02070 {
02071 setExtraLineEnd(L_SQUARE);
02072 }
02073
02074 void KPrView::extraLineEndCircle()
02075 {
02076 setExtraLineEnd(L_CIRCLE);
02077 }
02078
02079 void KPrView::extraLineEndLineArrow()
02080 {
02081 setExtraLineEnd( L_LINE_ARROW );
02082 }
02083
02084 void KPrView::extraLineEndDimensionLine()
02085 {
02086 setExtraLineEnd( L_DIMENSION_LINE );
02087 }
02088
02089 void KPrView::extraLineEndDoubleArrow()
02090 {
02091 setExtraLineEnd( L_DOUBLE_ARROW );
02092 }
02093
02094 void KPrView::extraLineEndDoubleLineArrow()
02095 {
02096 setExtraLineEnd( L_DOUBLE_LINE_ARROW );
02097 }
02098
02099 void KPrView::setExtraLineEnd(LineEnd le)
02100 {
02101 KCommand * cmd( getPenCmd( i18n("Change Line End"), KoPen(),
02102 L_NORMAL, le, KoPenCmd::LineEnd ) );
02103 if( cmd )
02104 kPresenterDoc()->addCommand( cmd );
02105 else
02106 lineEnd = le;
02107 }
02108
02109 void KPrView::setExtraPenStyle( Qt::PenStyle style )
02110 {
02111 KoPen tmpPen;
02112 tmpPen.setStyle( style );
02113
02114 KCommand * cmd( getPenCmd( i18n("Change Outline Style"), tmpPen,
02115 L_NORMAL, L_NORMAL, KoPenCmd::Style ) );
02116 if( cmd )
02117 kPresenterDoc()->addCommand( cmd );
02118 else
02119 pen.setStyle( style );
02120 }
02121
02122 void KPrView::setExtraPenWidth( double width )
02123 {
02124 KoPen tmpPen;
02125 tmpPen.setPointWidth( width );
02126 KCommand * cmd( getPenCmd( i18n("Change Outline Width"), tmpPen,
02127 L_NORMAL, L_NORMAL, KoPenCmd::Width ) );
02128
02129 if( cmd )
02130 kPresenterDoc()->addCommand( cmd );
02131 else
02132 pen.setPointWidth( width );
02133 }
02134
02135 void KPrView::newPageLayout( const KoPageLayout &_layout )
02136 {
02137 KoPageLayout oldLayout = m_pKPresenterDoc->pageLayout();
02138 KoUnit::Unit unit = m_pKPresenterDoc->unit();
02139
02140 KPrPgLayoutCmd *pgLayoutCmd = new KPrPgLayoutCmd( i18n( "Set Page Layout" ), _layout, oldLayout, unit, unit,kPresenterDoc() );
02141 pgLayoutCmd->execute();
02142 kPresenterDoc()->addCommand( pgLayoutCmd );
02143 updateRuler();
02144 }
02145
02146 void KPrView::updateRuler()
02147 {
02148
02149 QRect r=m_canvas->activePage()->getZoomPageRect();
02150 getHRuler()->setFrameStartEnd( r.left(), r.right() );
02151 getVRuler()->setFrameStartEnd( r.top(), r.bottom() );
02152 }
02153
02154 void KPrView::createGUI()
02155 {
02156 splitter = new QSplitter( this );
02157
02158 if ( !m_pKPresenterDoc->isEmbedded()
02159 && !m_pKPresenterDoc->isSingleViewMode() )
02160 {
02161 sidebar = new KPrSideBar( splitter, m_pKPresenterDoc, this );
02162 connect( sidebar, SIGNAL( movePage( int, int ) ),
02163 m_pKPresenterDoc, SLOT( movePage( int, int ) ) );
02164 connect( sidebar, SIGNAL( selectPage( int, bool ) ),
02165 m_pKPresenterDoc, SLOT( selectPage( int, bool ) ) );
02166 connect( sidebar, SIGNAL( showPage( int ) ),
02167 this, SLOT( skipToPage( int ) ) );
02168
02169
02170
02171 splitter->setResizeMode( sidebar, QSplitter::KeepSize );
02172 }
02173
02174 QSplitter *splitterVertical = new QSplitter( QSplitter::Vertical, splitter );
02175
02176
02177 pageBase = new PageBase( splitterVertical, this );
02178 pageBase->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
02179
02180 m_canvas=new KPrCanvas( pageBase, "Canvas", this );
02181
02182 QObject::connect( m_canvas, SIGNAL( fontChanged( const QFont & ) ),
02183 this, SLOT( fontChanged( const QFont & ) ) );
02184 QObject::connect( m_canvas, SIGNAL( colorChanged( const QColor & ) ),
02185 this, SLOT( colorChanged( const QColor & ) ) );
02186 QObject::connect( m_canvas, SIGNAL( alignChanged( int ) ),
02187 this, SLOT( alignChanged( int ) ) );
02188 QObject::connect( m_canvas, SIGNAL( objectSelectedChanged()),
02189 this, SLOT( objectSelectedChanged()));
02190 QObject::connect( m_canvas, SIGNAL( sigMouseWheelEvent( QWheelEvent* ) ),
02191 this, SLOT( getPageMouseWheelEvent( QWheelEvent* ) ) );
02192
02193
02194
02195 if ( !m_pKPresenterDoc->isEmbedded()
02196 && !m_pKPresenterDoc->isSingleViewMode() )
02197 {
02198 notebar = new KPrNoteBar( splitterVertical, this );
02199 }
02200
02201
02202 setupActions();
02203 setupPopupMenus();
02204 setupScrollbars();
02205 setRanges();
02206 setupRulers();
02207
02208 if ( m_pKPresenterDoc && m_canvas )
02209 {
02210 QObject::connect( m_canvas, SIGNAL( stopAutomaticPresentation() ), this, SLOT( stopAutomaticPresentation() ) );
02211 QObject::connect( m_canvas, SIGNAL( restartPresentation() ), this, SLOT( restartPresentation() ) );
02212
02213 connect( getVRuler(), SIGNAL( addGuide( const QPoint &, bool, int ) ),
02214 &( m_canvas->guideLines() ), SLOT( addGuide( const QPoint &, bool, int ) ) );
02215 connect( getVRuler(), SIGNAL( moveGuide( const QPoint &, bool, int ) ),
02216 &( m_canvas->guideLines() ), SLOT( moveGuide( const QPoint &, bool, int ) ) );
02217 connect( getHRuler(), SIGNAL( addGuide( const QPoint &, bool, int ) ),
02218 &( m_canvas->guideLines() ), SLOT( addGuide( const QPoint &, bool, int ) ) );
02219 connect( getHRuler(), SIGNAL( moveGuide( const QPoint &, bool, int ) ),
02220 &( m_canvas->guideLines() ), SLOT( moveGuide( const QPoint &, bool, int ) ) );
02221 connect( &( m_canvas->guideLines() ), SIGNAL( moveGuides( bool ) ),
02222 m_canvas, SLOT( setPaintGuides( bool ) ) );
02223 connect( &( m_canvas->guideLines() ), SIGNAL( paintGuides( bool ) ),
02224 m_canvas, SLOT( setPaintGuides( bool ) ) );
02225 connect( &( m_canvas->guideLines() ), SIGNAL( guideLinesChanged( KoView * ) ),
02226 m_pKPresenterDoc, SLOT( slotGuideLinesChanged( KoView * ) ) );
02227 m_canvas->guideLines().setGuideLines( m_pKPresenterDoc->horizontalGuideLines(), m_pKPresenterDoc->verticalGuideLines() );
02228 }
02229
02230 if ( sidebar )
02231 {
02232 sidebar->outline()->setCurrentItem( sidebar->outline()->firstChild() );
02233 sidebar->outline()->setSelected( sidebar->outline()->firstChild(), TRUE );
02234 KConfig *config=KGlobal::config();
02235 config->setGroup("Global");
02236 if(!config->readBoolEntry("Sidebar", true)) {
02237 sidebar->hide();
02238 actionViewShowSideBar->setChecked(false);
02239 }
02240 else actionViewShowSideBar->setChecked(true);
02241 }
02242
02243 if ( notebar )
02244 {
02245 KConfig *config=KGlobal::config();
02246 config->setGroup("Global");
02247 if(!config->readBoolEntry("Notebar", true)) {
02248 notebar->hide();
02249 actionViewShowNoteBar->setChecked(false);
02250 }
02251 else actionViewShowNoteBar->setChecked(true);
02252
02253 QTimer::singleShot( 0, this, SLOT( initialLayoutOfSplitter() ) );
02254 }
02255 KPrPage *initPage=m_pKPresenterDoc->initialActivePage();
02256 if ( !initPage )
02257 m_pKPresenterDoc->pageList().at( 0 );
02258 skipToPage( m_pKPresenterDoc->pageList().findRef( initPage ) );
02259 }
02260
02261 void KPrView::initGui()
02262 {
02263 tbColor = Qt::black;
02264 actionTextColor->setCurrentColor( Qt::black );
02265 actionBrushColor->setCurrentColor( Qt::white );
02266 actionPenColor->setCurrentColor( Qt::black );
02267 updateSideBarMenu();
02268 objectSelectedChanged();
02269 refreshPageButton();
02270
02271 KStatusBar * sb = statusBar();
02272 if ( sb )
02273 sb->show();
02274 showZoom( zoomHandler()->zoom() );
02275 updateHeaderFooterButton();
02276 updateDisplayObjectMasterPageButton();
02277 updateDisplayBackgroundButton();
02278
02279 actionAllowAutoFormat->setChecked( m_pKPresenterDoc->allowAutoFormat() );
02280 actionViewFormattingChars->setChecked( m_pKPresenterDoc->viewFormattingChars() );
02281
02282 updateGuideLineButton();
02283
02284 updateGridButton();
02285
02286 m_pKPresenterDoc->updateZoomRuler();
02287 updatePageInfo();
02288 actionAllowBgSpellCheck->setChecked( m_pKPresenterDoc->backgroundSpellCheckEnabled());
02289 updateDirectCursorButton();
02290 m_pKPresenterDoc->updatePresentationButton();
02291 }
02292
02293 void KPrView::updateDisplayObjectMasterPageButton()
02294 {
02295 actionDisplayObjectFromMasterPage->setChecked( !m_canvas->activePage()->displayObjectFromMasterPage());
02296 }
02297
02298 void KPrView::updateDisplayBackgroundButton()
02299 {
02300 actionDisplayBackgroundPage->setChecked( !m_canvas->activePage()->displayBackground() );
02301 }
02302
02303 void KPrView::updateHeaderFooterButton()
02304 {
02305 m_actionExtraHeader->setChecked( m_canvas->activePage()->hasHeader() );
02306 m_actionExtraFooter->setChecked( m_canvas->activePage()->hasFooter() );
02307 }
02308
02309 void KPrView::guiActivateEvent( KParts::GUIActivateEvent *ev )
02310 {
02311 if ( ev->activated() )
02312 initGui();
02313
02314 KoView::guiActivateEvent( ev );
02315 }
02316
02317 void KPrView::setupActions()
02318 {
02319 actionEditCut = KStdAction::cut( this, SLOT( editCut() ), actionCollection(), "edit_cut" );
02320 actionEditCopy = KStdAction::copy( this, SLOT( editCopy() ), actionCollection(), "edit_copy" );
02321 actionEditPaste = KStdAction::paste( this, SLOT( editPaste() ), actionCollection(), "edit_paste" );
02322 connect( m_pKPresenterDoc, SIGNAL( enablePaste( bool ) ),
02323 actionEditPaste, SLOT( setEnabled( bool ) ) );
02324 m_pKPresenterDoc->clipboardDataChanged();
02325
02326 actionEditDelete = new KAction( i18n( "&Delete" ), "editdelete", CTRL + Qt::Key_Delete,
02327 this, SLOT( editDelete() ),
02328 actionCollection(), "edit_delete" );
02329 actionEditSelectAll = KStdAction::selectAll( this, SLOT( editSelectAll() ), actionCollection(), "edit_selectall" );
02330 actionEditDeSelectAll= KStdAction::deselect( this, SLOT( editDeSelectAll()), actionCollection(), "edit_deselectall");
02331 actionEditCopyPage = new KAction( i18n( "Copy Slide" ), "editcopy",
02332 0, this, SLOT( editCopyPage() ),
02333 actionCollection(), "edit_copypage" );
02334 actionEditDuplicatePage = new KAction( i18n( "Duplicate Slide" ), "newslide",
02335 0, this, SLOT( editDuplicatePage() ),
02336 actionCollection(), "edit_duplicatepage" );
02337 actionEditDelPage = new KAction( i18n( "Delete Slide" ), "delslide", 0,
02338 this, SLOT( editDelPage() ),
02339 actionCollection(), "edit_delpage" );
02340
02341 actionEditFind=KStdAction::find( this, SLOT( editFind() ), actionCollection(), "edit_find" );
02342 actionEditFindNext = KStdAction::findNext( this, SLOT( editFindNext() ), actionCollection(), "edit_findnext" );
02343 actionEditFindPrevious = KStdAction::findPrev( this, SLOT( editFindPrevious() ), actionCollection(), "edit_findprevious" );
02344 actionEditReplace=KStdAction::replace( this, SLOT( editReplace() ), actionCollection(), "edit_replace" );
02345
02346
02347
02348 if ( !m_pKPresenterDoc->isEmbedded() )
02349 {
02350 actionViewShowSideBar = new KToggleAction( i18n("Show Sidebar"), 0,
02351 this, SLOT( viewShowSideBar() ),
02352 actionCollection(), "view_showsidebar" );
02353 actionViewShowSideBar->setCheckedState(i18n("Hide Sidebar"));
02354
02355 actionViewShowNoteBar = new KToggleAction( i18n("Show Notebar"), 0,
02356 this, SLOT( viewShowNoteBar() ),
02357 actionCollection(), "view_shownotebar" );
02358 actionViewShowNoteBar->setCheckedState(i18n("Hide Notebar"));
02359 }
02360
02361 actionViewFormattingChars = new KToggleAction( i18n( "&Formatting Characters" ), 0,
02362 this, SLOT( slotViewFormattingChars() ),
02363 actionCollection(), "view_formattingchars" );
02364 actionViewFormattingChars->setToolTip( i18n( "Toggle the display of non-printing characters." ) );
02365 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." ) );
02366
02367 actionViewSlideMaster = new KToggleAction( i18n( "Slide &Master" ), 0,
02368 this, SLOT( viewSlideMaster() ),
02369 actionCollection(), "view_master" );
02370
02371 actionViewShowGuideLine= new KToggleAction( i18n( "Guide Lines" ), 0,
02372 this, SLOT( viewGuideLines() ),
02373 actionCollection(), "view_guidelines" );
02374
02375 actionViewShowGrid = new KToggleAction( i18n( "Show &Grid" ), 0,
02376 this, SLOT( viewGrid() ),
02377 actionCollection(), "view_grid" );
02378 actionViewShowGrid->setCheckedState(i18n("Hide &Grid"));
02379
02380 actionViewSnapToGrid= new KToggleAction( i18n( "Snap to Grid" ), 0,
02381 this, SLOT(viewSnapToGrid() ),
02382 actionCollection(), "view_snaptogrid" );
02383
02384
02385
02386 actionInsertPage = new KAction( i18n( "&Slide..." ), "slide", Qt::Key_F2,
02387 this, SLOT( insertPage() ),
02388 actionCollection(), "insert_page" );
02389
02390 new KAction( i18n( "Insert &Slide..." ), "newslide", 0,
02391 this, SLOT( insertPage() ),
02392 actionCollection(), "insert_page_popup" );
02393
02394 actionInsertPicture = new KAction( i18n( "P&icture..." ), "frame_image", Qt::SHIFT+Qt::Key_F5,
02395 this, SLOT( insertPicture() ),
02396 actionCollection(), "insert_picture" );
02397
02398
02399
02400 actionToolsMouse = new KToggleAction( i18n( "Select" ), "select", 0,
02401 this, SLOT( toolsMouse() ),
02402 actionCollection(), "tools_mouse" );
02403 actionToolsMouse->setExclusiveGroup( "tools" );
02404 actionToolsMouse->setChecked( true );
02405
02406 actionToolsRotate = new KToggleAction( i18n( "&Rotate" ), "rotate", 0,
02407 this, SLOT( toolsRotate() ),
02408 actionCollection(), "tools_rotate" );
02409 actionToolsRotate->setExclusiveGroup( "tools" );
02410
02411 actionToolsZoom = new KToggleAction( i18n( "&Zoom" ), "viewmag", 0,
02412 this, SLOT( toolsZoom() ),
02413 actionCollection(), "tools_zoom" );
02414 actionToolsZoom->setExclusiveGroup( "tools" );
02415
02416 actionToolsShapePopup = new KActionMenu( i18n( "&Shape" ), "rectangle",
02417 actionCollection(), "tools_shapepopup" );
02418 actionToolsShapePopup->setDelayed(true);
02419 connect(actionToolsShapePopup, SIGNAL(activated()), this, SLOT(toolsShapePopup()));
02420
02421 actionToolsRectangle = new KToggleAction( i18n( "&Rectangle" ), "rectangle",
02422 0, this, SLOT( toolsRectangle() ),
02423 actionCollection(), "tools_rectangle" );
02424 actionToolsRectangle->setExclusiveGroup( "tools" );
02425
02426 actionToolsCircleOrEllipse = new KToggleAction( i18n( "&Circle/Ellipse" ), "circle",
02427 0, this, SLOT( toolsCircleOrEllipse() ),
02428 actionCollection(), "tools_circle" );
02429 actionToolsCircleOrEllipse->setExclusiveGroup( "tools" );
02430
02431 actionToolsPie = new KToggleAction( i18n( "&Pie/Arc/Chord" ), "pie", 0,
02432 this, SLOT( toolsPie() ),
02433 actionCollection(), "tools_pie" );
02434 actionToolsPie->setExclusiveGroup( "tools" );
02435
02436 actionToolsText = new KToggleAction( i18n( "&Text" ), "frame_text", Qt::Key_F10,
02437 this, SLOT( toolsText() ),
02438 actionCollection(), "tools_text" );
02439 actionToolsText->setExclusiveGroup( "tools" );
02440
02441 actionToolsAutoform = new KToggleAction( i18n( "&Arrows && Connections" ), "autoform",
02442 0, this, SLOT( toolsAutoform() ),
02443 actionCollection(), "tools_autoform" );
02444 actionToolsAutoform->setExclusiveGroup( "tools" );
02445
02446 actionToolsDiagramm = new KToggleAction( i18n( "&Chart" ), "frame_chart", 0,
02447 this, SLOT( toolsDiagramm() ),
02448 actionCollection(), "tools_diagramm" );
02449 actionToolsDiagramm->setExclusiveGroup( "tools" );
02450
02451 actionToolsTable = new KToggleAction( i18n( "Ta&ble"), "frame_spreadsheet", Qt::Key_F5 ,
02452 this, SLOT( toolsTable() ),
02453 actionCollection(), "tools_table" );
02454 actionToolsTable->setExclusiveGroup( "tools" );
02455
02456 actionToolsObject = new KoPartSelectAction( i18n( "&Object" ), "frame_query",
02457 this, SLOT( toolsObject() ),
02458 actionCollection(), "tools_object" );
02459
02460 actionToolsLinePopup = new KActionMenu( i18n( "&Line" ), "line",
02461 actionCollection(), "tools_linepopup" );
02462 actionToolsLinePopup->setDelayed(true);
02463 connect(actionToolsLinePopup, SIGNAL(activated()), this, SLOT(toolsLinePopup()));
02464
02465 actionToolsLine = new KToggleAction( i18n( "&Line" ), "line", 0,
02466 this, SLOT( toolsLine() ),
02467 actionCollection(), "tools_line" );
02468 actionToolsLine->setExclusiveGroup( "tools" );
02469
02470 actionToolsFreehand = new KToggleAction( i18n( "&Freehand" ), "freehand", 0,
02471 this, SLOT( toolsFreehand() ),
02472 actionCollection(), "tools_freehand" );
02473 actionToolsFreehand->setExclusiveGroup( "tools" );
02474
02475 actionToolsPolyline = new KToggleAction( i18n( "Po&lyline" ), "polyline", 0,
02476 this, SLOT( toolsPolyline() ),
02477 actionCollection(), "tools_polyline" );
02478 actionToolsPolyline->setExclusiveGroup( "tools" );
02479
02480 actionToolsQuadricBezierCurve = new KToggleAction( i18n( "&Quadric Bezier Curve" ), "quadricbeziercurve", 0,
02481 this, SLOT( toolsQuadricBezierCurve() ),
02482 actionCollection(), "tools_quadricbeziercurve" );
02483 actionToolsQuadricBezierCurve->setExclusiveGroup( "tools" );
02484
02485 actionToolsCubicBezierCurve = new KToggleAction( i18n( "C&ubic Bezier Curve" ), "cubicbeziercurve", 0,
02486 this, SLOT( toolsCubicBezierCurve() ),
02487 actionCollection(), "tools_cubicbeziercurve" );
02488 actionToolsCubicBezierCurve->setExclusiveGroup( "tools" );
02489
02490 actionToolsConvexOrConcavePolygon = new KToggleAction( i18n( "Co&nvex/Concave Polygon" ), "polygon", 0,
02491 this, SLOT( toolsConvexOrConcavePolygon() ),
02492 actionCollection(), "tools_polygon" );
02493 actionToolsConvexOrConcavePolygon->setExclusiveGroup( "tools" );
02494
02495
02496 actionToolsClosedLinePopup = new KActionMenu( i18n( "&Closed Line" ), "closed_freehand",
02497 actionCollection(), "tools_closed_linepopup" );
02498 actionToolsClosedLinePopup->setDelayed(true);
02499 connect(actionToolsClosedLinePopup, SIGNAL(activated()), this, SLOT(toolsClosedLinePopup()));
02500
02501 actionToolsClosedFreehand = new KToggleAction( i18n( "Closed &Freehand" ), "closed_freehand", 0,
02502 this, SLOT( toolsClosedFreehand() ),
02503 actionCollection(), "tools_closed_freehand" );
02504 actionToolsClosedFreehand->setExclusiveGroup( "tools" );
02505
02506
02507 actionToolsClosedPolyline = new KToggleAction( i18n( "Closed Po&lyline" ), "closed_polyline", 0,
02508 this, SLOT( toolsClosedPolyline() ),
02509 actionCollection(), "tools_closed_polyline" );
02510 actionToolsClosedPolyline->setExclusiveGroup( "tools" );
02511
02512
02513 actionToolsClosedQuadricBezierCurve = new KToggleAction( i18n( "Closed &Quadric Bezier Curve" ), "closed_quadricbeziercurve", 0,
02514 this, SLOT( toolsClosedQuadricBezierCurve() ),
02515 actionCollection(), "tools_closed_quadricbeziercurve" );
02516 actionToolsClosedQuadricBezierCurve->setExclusiveGroup( "tools" );
02517
02518
02519 actionToolsClosedCubicBezierCurve = new KToggleAction( i18n( "Closed C&ubic Bezier Curve" ), "closed_cubicbeziercurve", 0,
02520 this, SLOT( toolsClosedCubicBezierCurve() ),
02521 actionCollection(), "tools_closed_cubicbeziercurve" );
02522 actionToolsClosedCubicBezierCurve->setExclusiveGroup( "tools" );
02523
02524
02525
02526 actionTextFont = new KAction( i18n( "&Font..." ), 0, this, SLOT( mtextFont() ),
02527 actionCollection(), "text_font" );
02528
02529 actionTextFontSize = new KFontSizeAction( i18n( "Font Size" ), 0, actionCollection(), "text_fontsize" );
02530 connect( actionTextFontSize, SIGNAL( fontSizeChanged( int ) ),
02531 this, SLOT( sizeSelected( int ) ) );
02532
02533 #ifdef KFONTACTION_HAS_CRITERIA_ARG
02534 actionTextFontFamily = new KFontAction( KFontChooser::SmoothScalableFonts,
02535 i18n( "Font Family" ), 0,
02536 actionCollection(), "text_fontfamily" );
02537 #else
02538 actionTextFontFamily = new KFontAction( i18n( "Font Family" ), 0,
02539 actionCollection(), "text_fontfamily" );
02540 #endif
02541 connect( actionTextFontFamily , SIGNAL( activated( const QString & ) ),
02542 this, SLOT( fontSelected( const QString & ) ) );
02543
02544 actionTextBold = new KToggleAction( i18n( "&Bold" ), "text_bold", CTRL + Qt::Key_B,
02545 this, SLOT( textBold() ),
02546 actionCollection(), "text_bold" );
02547
02548 actionTextItalic = new KToggleAction( i18n( "&Italic" ), "text_italic", CTRL + Qt::Key_I,
02549 this, SLOT( textItalic() ),
02550 actionCollection(), "text_italic" );
02551
02552 actionTextUnderline = new KToggleAction( i18n( "&Underline" ), "text_under", CTRL + Qt::Key_U,
02553 this, SLOT( textUnderline() ),
02554 actionCollection(), "text_underline" );
02555
02556 actionFormatStrikeOut = new KToggleAction( i18n( "&Strike Out" ), "text_strike", 0 ,
02557 this, SLOT( textStrikeOut() ),
02558 actionCollection(), "format_strike" );
02559
02560 actionTextColor = new TKSelectColorAction( i18n( "&Color..." ), TKSelectColorAction::TextColor,
02561 actionCollection(), "text_color" ,true);
02562 connect( actionTextColor, SIGNAL( activated() ), SLOT( textColor() ) );
02563 actionTextColor->setDefaultColor(QColor());
02564
02565
02566 actionTextAlignLeft = new KToggleAction( i18n( "Align &Left" ), "text_left", ALT + Qt::Key_L,
02567 this, SLOT( textAlignLeft() ),
02568 actionCollection(), "text_alignleft" );
02569 actionTextAlignLeft->setExclusiveGroup( "align" );
02570 actionTextAlignLeft->setChecked( true );
02571
02572 actionTextAlignCenter = new KToggleAction( i18n( "Align &Center" ), "text_center", ALT + Qt::Key_C,
02573 this, SLOT( textAlignCenter() ),
02574 actionCollection(), "text_aligncenter" );
02575 actionTextAlignCenter->setExclusiveGroup( "align" );
02576
02577 actionTextAlignRight = new KToggleAction( i18n( "Align &Right" ), "text_right", ALT + Qt::Key_R,
02578 this, SLOT( textAlignRight() ),
02579 actionCollection(), "text_alignright" );
02580 actionTextAlignRight->setExclusiveGroup( "align" );
02581
02582 actionTextAlignBlock = new KToggleAction( i18n( "Align &Block" ), "text_block", CTRL + Qt::Key_J,
02583 this, SLOT( textAlignBlock() ),
02584 actionCollection(), "text_alignblock" );
02585 actionTextAlignBlock->setExclusiveGroup( "align" );
02586
02587
02588 actionFormatNumber = new KActionMenu( i18n( "Number" ), "enumList", actionCollection(), "format_number" );
02589 actionFormatNumber->setDelayed( false );
02590 actionFormatBullet = new KActionMenu( i18n( "Bullet" ), "unsortedList", actionCollection(), "format_bullet" );
02591 actionFormatBullet->setDelayed( false );
02592 QPtrList<KoCounterStyleWidget::StyleRepresenter> stylesList;
02593 KoCounterStyleWidget::makeCounterRepresenterList( stylesList );
02594 QPtrListIterator<KoCounterStyleWidget::StyleRepresenter> styleIt( stylesList );
02595 for ( ; styleIt.current() ; ++styleIt ) {
02596
02597
02598 KToggleAction* act = new KToggleAction( styleIt.current()->name(),
02599 0, this, SLOT( slotCounterStyleSelected() ),
02600 actionCollection(), QString("counterstyle_%1").arg( styleIt.current()->style() ).latin1() );
02601 act->setExclusiveGroup( "counterstyle" );
02602
02603 if ( styleIt.current()->style() == KoParagCounter::STYLE_NONE ) {
02604 actionFormatBullet->insert( act );
02605 actionFormatNumber->insert( act );
02606 } else if ( styleIt.current()->isBullet() )
02607 actionFormatBullet->insert( act );
02608 else
02609 actionFormatNumber->insert( act );
02610 }
02611 actionTextDepthPlus = new KAction( i18n( "&Increase Depth" ), QApplication::reverseLayout() ?"format_decreaseindent" : "format_increaseindent",
02612 CTRL + Qt::Key_Plus, this, SLOT( textDepthPlus() ),
02613 actionCollection(), "text_depthPlus" );
02614
02615 actionTextDepthMinus = new KAction( i18n( "&Decrease Depth" ), QApplication::reverseLayout() ?"format_increaseindent" : "format_decreaseindent",
02616 CTRL + Qt::Key_Minus, this, SLOT( textDepthMinus() ),
02617 actionCollection(), "text_depthMinus" );
02618
02619 actionTextExtentCont2Height = new KAction( i18n( "Extend Contents to Object &Height" ), 0,
02620 this, SLOT( textContentsToHeight() ),
02621 actionCollection(), "text_con2hei" );
02622
02623 actionTextExtendObj2Cont = new KAction( i18n( "&Extend Object to Fit Contents" ), 0,
02624 this, SLOT( textObjectToContents() ),
02625 actionCollection(), "text_obj2cont" );
02626
02627 actionTextInsertPageNum = new KAction( i18n( "&Insert Slide Number" ), "pgnum", 0,
02628 this, SLOT( textInsertPageNum() ),
02629 actionCollection(), "text_inspgnum" );
02630
02631
02632
02633 actionExtraProperties = new KAction( i18n( "&Properties" ), "penbrush", 0,
02634 this, SLOT( extraProperties() ),
02635 actionCollection(), "extra_properties" );
02636
02637 actionExtraArrangePopup = new KActionMenu( i18n( "Arra&nge Objects" ), "arrange",
02638 actionCollection(), "extra_arrangepopup" );
02639 actionExtraArrangePopup->setDelayed( false );
02640
02641 actionExtraRaise = new KAction( i18n( "Ra&ise Objects" ), "raise",
02642 CTRL+Qt::SHIFT+Qt::Key_R, this, SLOT( extraRaise() ),
02643 actionCollection(), "extra_raise" );
02644
02645 actionExtraLower = new KAction( i18n( "&Lower Objects" ), "lower", CTRL +Qt::SHIFT+ Qt::Key_L,
02646 this, SLOT( extraLower() ),
02647 actionCollection(), "extra_lower" );
02648
02649 actionExtraBringForward= new KAction( i18n( "Bring to Front" ), "bring_forward",
02650 0, this, SLOT( extraBringForward() ),
02651 actionCollection(), "extra_bring_forward" );
02652
02653 actionExtraSendBackward= new KAction( i18n( "Send to Back" ), "send_backward",
02654 0, this, SLOT( extraSendBackward() ),
02655 actionCollection(), "extra_send_backward" );
02656
02657
02658
02659 actionExtraRotate = new KAction( i18n( "R&otate Objects..." ), "rotate_cw", 0,
02660 this, SLOT( extraRotate() ),
02661 actionCollection(), "extra_rotate" );
02662
02663 actionExtraShadow = new KAction( i18n( "&Shadow Objects..." ), "shadow", 0,
02664 this, SLOT( extraShadow() ),
02665 actionCollection(), "extra_shadow" );
02666
02667 actionExtraAlignObjLeft = new KAction( i18n( "Align &Left" ), "aoleft", 0,
02668 this, SLOT( extraAlignObjLeft() ),
02669 actionCollection(), "extra_alignleft" );
02670
02671 actionExtraAlignObjCenterH = new KAction( i18n( "Align Center (&horizontally)" ),
02672 "aocenterh", 0,
02673 this, SLOT( extraAlignObjCenterH() ),
02674 actionCollection(), "extra_aligncenterh" );
02675
02676 actionExtraAlignObjRight = new KAction( i18n( "Align &Right" ), "aoright", 0,
02677 this, SLOT( extraAlignObjRight() ),
02678 actionCollection(), "extra_alignright" );
02679
02680 actionExtraAlignObjTop = new KAction( i18n( "Align &Top" ), "aotop", 0,
02681 this, SLOT( extraAlignObjTop() ),
02682 actionCollection(), "extra_aligntop" );
02683
02684 actionExtraAlignObjCenterV = new KAction( i18n( "Align Center (&vertically)" ),
02685 "aocenterv", 0,
02686 this, SLOT( extraAlignObjCenterV() ),
02687 actionCollection(), "extra_aligncenterv" );
02688
02689 actionExtraAlignObjBottom = new KAction( i18n( "Align &Bottom" ), "aobottom", 0,
02690 this, SLOT( extraAlignObjBottom() ),
02691 actionCollection(), "extra_alignbottom" );
02692
02693
02694 actionExtraBackground = new KAction( i18n( "Slide Bac&kground..." ), "background", 0,
02695 this, SLOT( extraBackground() ),
02696 actionCollection(), "extra_background" );
02697
02698 actionExtraLayout = new KAction( i18n( "Page &Layout..." ), 0,
02699 this, SLOT( extraLayout() ),
02700 actionCollection(), "extra_layout" );
02701
02702 m_actionExtraHeader = new KToggleAction( i18n( "Enable Document &Header" ), 0,
02703 this, SLOT( viewHeader() ),
02704 actionCollection(), "extra_header" );
02705 m_actionExtraHeader->setCheckedState( i18n( "Disable Document &Header" ) );
02706 m_actionExtraHeader->setToolTip( i18n( "Shows and hides header display for the current slide." ) );
02707
02708 m_actionExtraFooter = new KToggleAction( i18n( "Enable Document Foo&ter" ), 0,
02709 this, SLOT( viewFooter() ),
02710 actionCollection(), "extra_footer" );
02711 m_actionExtraFooter->setCheckedState( i18n( "Disable Document Foo&ter" ) );
02712 m_actionExtraFooter->setToolTip( i18n( "Shows and hides footer display for the current slide." ) );
02713
02714 actionExtraConfigure = new KAction( i18n( "Configure KPresenter..." ),
02715 "configure", 0,
02716 this, SLOT( extraConfigure() ),
02717 actionCollection(), "extra_configure" );
02718
02719 actionExtraWebPres = new KAction( i18n( "Create &HTML Slideshow..." ),
02720 "webpres", 0,
02721 this, SLOT( extraWebPres() ),
02722 actionCollection(), "extra_webpres" );
02723
02724 actionExtraMSPres = new KAction( i18n( "Create Memor&y Stick Slideshow..." ),
02725 0, this, SLOT( extraMSPres() ),
02726 actionCollection(), "extra_mspres" );
02727
02728 actionExtraCreateTemplate = new KAction( i18n( "Template Manager" ), 0,
02729 this, SLOT( extraCreateTemplate() ),
02730 actionCollection(), "extra_template" );
02731
02732 actionExtraDefaultTemplate = new KAction( i18n( "Use Current Slide as Default Template" ), 0,
02733 this, SLOT( extraDefaultTemplate() ),
02734 actionCollection(), "extra_defaulttemplate" );
02735
02736 actionExtraAlignObjsPopup = new KActionMenu( i18n("Align O&bjects"), "alignobjs",
02737 actionCollection(), "extra_alignobjs" );
02738 actionExtraAlignObjsPopup->setDelayed( false );
02739
02740 actionExtraLineBegin = new KAction( i18n("Line Begin"), "line_begin", 0,
02741 this, SLOT( extraLineBegin() ),
02742 actionCollection(), "extra_linebegin" );
02743
02744 actionExtraLineEnd = new KAction( i18n("Line End"), "line_end", 0,
02745 this, SLOT( extraLineEnd() ),
02746 actionCollection(), "extra_lineend" );
02747
02748 actionExtraPenStyle = new KoLineStyleAction( i18n("Outline Style"), "pen_style",
02749 this, SLOT( extraPenStyle(int) ),
02750 actionCollection(), "extra_penstyle" );
02751 actionExtraPenStyle->setShowCurrentSelection(false);
02752
02753 actionExtraPenWidth = new KoLineWidthAction( i18n("Outline Width"), "pen_width",
02754 this, SLOT( extraPenWidth(double) ),
02755 actionCollection(), "extra_penwidth" );
02756 actionExtraPenWidth->setUnit( kPresenterDoc()->unit() );
02757 actionExtraPenWidth->setShowCurrentSelection(false);
02758 connect( kPresenterDoc(), SIGNAL( unitChanged( KoUnit::Unit ) ),
02759 actionExtraPenWidth, SLOT( setUnit( KoUnit::Unit ) ) );
02760
02761 actionExtraGroup = new KAction( i18n( "&Group Objects" ), "group",
02762 QKeySequence( "Ctrl+G" ),
02763 this, SLOT( extraGroup() ),
02764 actionCollection(), "extra_group" );
02765
02766 actionExtraUnGroup = new KAction( i18n( "&Ungroup Objects" ), "ungroup",
02767 QKeySequence( "Ctrl+Shift+G" ),
02768 this, SLOT( extraUnGroup() ),
02769 actionCollection(), "extra_ungroup" );
02770
02771
02772
02773 actionScreenConfigPages = new KAction( i18n( "&Configure Slide Show..." ),
02774 "configure", 0,
02775 this, SLOT( screenConfigPages() ),
02776 actionCollection(), "screen_configpages" );
02777
02778 actionScreenAssignEffect = new KAction( i18n( "Edit &Object Effect..." ),
02779 "effect", 0,
02780 this, SLOT( screenAssignEffect() ),
02781 actionCollection(), "screen_assigneffect");
02782
02783 actionScreenTransEffect = new KAction( i18n( "Edit Slide &Transition..." ),
02784 "slide_effect", 0,
02785 this, SLOT( screenTransEffect() ),
02786 actionCollection(), "screen_transeffect");
02787
02788
02789 actionScreenStart = new KAction( i18n( "&Start" ),
02790 "2rightarrow", Qt::Key_F12,
02791 this, SLOT( screenStart() ),
02792 actionCollection(), "screen_start" );
02793
02794 actionScreenStartFromFirst = new KAction( i18n( "Start From &First Slide" ),
02795 "1rightarrow", 0,
02796 this, SLOT( screenStartFromFirst() ),
02797 actionCollection(), "screen_startfromfirst" );
02798
02799 actionScreenFirst = new KAction( i18n( "&Go to Start" ),
02800 "start", 0,
02801 this, SLOT( screenFirst() ),
02802 actionCollection(), "screen_first" );
02803
02804 actionScreenPrev = new KAction( i18n( "&Previous Slide" ),
02805 "back", Qt::Key_Prior,
02806 this, SLOT( screenPrev() ),
02807 actionCollection(), "screen_prev" );
02808
02809 actionScreenNext = new KAction( i18n( "&Next Slide" ),
02810 "forward", Qt::Key_Next,
02811 this, SLOT( screenNext() ),
02812 actionCollection(), "screen_next" );
02813
02814 actionScreenLast = new KAction( i18n( "Go to &End" ),
02815 "finish", 0,
02816 this, SLOT( screenLast() ),
02817 actionCollection(), "screen_last" );
02818
02819 actionScreenSkip = new KAction( i18n( "Goto &Slide..." ),
02820 "goto", 0,
02821 this, SLOT( screenSkip() ),
02822 actionCollection(), "screen_skip" );
02823
02824
02825
02826 actionBrushColor = new TKSelectColorAction( i18n( "Fill Color..." ), TKSelectColorAction::FillColor,
02827 actionCollection(), "brush_color" ,true);
02828 connect( actionBrushColor, SIGNAL( activated() ), SLOT( brushChosen() ) );
02829 actionBrushColor->setDefaultColor(QColor());
02830
02831 actionPenColor = new TKSelectColorAction( i18n( "Outline Color..." ), TKSelectColorAction::LineColor,
02832 actionCollection(), "pen_color" );
02833 connect( actionPenColor, SIGNAL( activated() ), SLOT( penChosen() ) );
02834 actionPenColor->setDefaultColor(QColor());
02835 actionExtendObjectHeight = new KAction( i18n( "&Extend Contents to Object Height" ),0, this, SLOT( textContentsToHeight() ),
02836 actionCollection(), "extendobjectheight" );
02837
02838 actionResizeTextObject = new KAction( i18n( "&Resize Object to Fit Contents" ),0, this, SLOT( textObjectToContents() ),
02839 actionCollection(), "resizetextobject" );
02840
02841 actionRenamePage=new KAction(i18n( "&Rename Slide..." ),0,this,
02842 SLOT( renamePageTitle() ),
02843 actionCollection(), "rename_page" );
02844
02845 actionPicOriginalSize = new KAction( i18n( "Sca&le to Original Size" ), 0, this,
02846 SLOT( picViewOriginalSize() ),
02847 actionCollection(), "pic_original_size" );
02848
02849 actionPic640x480=new KAction(i18n( "640x480" ),0,this,
02850 SLOT( picViewOrig640x480() ),
02851 actionCollection(), "pic_640_480" );
02852
02853 actionPic800x600=new KAction(i18n( "800x600" ),0,this,
02854 SLOT( picViewOrig800x600() ),
02855 actionCollection(), "pic_800_600" );
02856
02857 actionPic1024x768=new KAction(i18n( "1024x768" ),0,this,
02858 SLOT( picViewOrig1024x768() ),
02859 actionCollection(), "pic_1024_768" );
02860
02861 actionPic1280x1024=new KAction(i18n( "1280x1024" ),0,this,
02862 SLOT( picViewOrig1280x1024() ),
02863 actionCollection(), "pic_1280_1024" );
02864
02865 actionPic1600x1200=new KAction(i18n( "1600x1200" ),0,this,
02866 SLOT( picViewOrig1600x1200() ),
02867 actionCollection(), "pic_1600_1200" );
02868
02869 actionChangePic=new KAction( i18n( "&Change Picture..." ),"frame_image",0,this,
02870 SLOT( chPic() ), actionCollection(), "change_picture" );
02871
02872
02873 actionImageEffect = new KAction( i18n("Image &Effect..."), 0, this,
02874 SLOT(imageEffect()), actionCollection(), "image_effect");
02875
02876
02877 actionFormatSuper = new KToggleAction( i18n( "Superscript" ), "super", 0,
02878 this, SLOT( textSuperScript() ),
02879 actionCollection(), "format_super" );
02880 actionFormatSuper->setExclusiveGroup( "valign" );
02881 actionFormatSub = new KToggleAction( i18n( "Subscript" ), "sub", 0,
02882 this, SLOT( textSubScript() ),
02883 actionCollection(), "format_sub" );
02884 actionFormatSub->setExclusiveGroup( "valign" );
02885
02886
02887 actionInsertSpecialChar = new KAction( i18n( "Sp&ecial Character..." ), "char",
02888 ALT + Qt::SHIFT + Qt::Key_C,
02889 this, SLOT( insertSpecialChar() ),
02890 actionCollection(), "insert_specialchar" );
02891
02892 actionInsertLink = new KAction( i18n( "Link..." ), 0,
02893 this, SLOT( insertLink() ),
02894 actionCollection(), "insert_link" );
02895
02896 #if 0
02897
02898
02899 picResizeMenu->insertSeparator();
02900 picResizeMenu->insertItem( i18n( "Enter Custom Factor..." ), this, SLOT( picViewOrigFactor() ) );
02901 #endif
02902 (void) new KAction( i18n( "Configure &Autocorrection..." ), 0,
02903 this, SLOT( extraAutoFormat() ),
02904 actionCollection(), "extra_autocorrection" );
02905 actionExtraSpellCheck = KStdAction::spelling( this, SLOT( slotSpellCheck() ), actionCollection(), "extra_spellcheck" );
02906
02907 actionFormatParag = new KAction( i18n( "&Paragraph..." ), ALT + CTRL + Qt::Key_P,
02908 this, SLOT( formatParagraph() ),
02909 actionCollection(), "format_paragraph" );
02910
02911 actionFormatDefault=new KAction( i18n( "Default Format" ), 0,
02912 this, SLOT( textDefaultFormat() ),
02913 actionCollection(), "text_default" );
02914
02915 actionOpenLink = new KAction( i18n( "Open Link" ), 0,
02916 this, SLOT( openLink() ),
02917 actionCollection(), "open_link" );
02918
02919 actionChangeLink=new KAction( i18n("Change Link..."), 0,
02920 this,SLOT(changeLink()),
02921 actionCollection(), "change_link");
02922
02923 actionCopyLink = new KAction( i18n( "Copy Link" ), 0,
02924 this, SLOT( copyLink() ),
02925 actionCollection(), "copy_link" );
02926
02927 actionRemoveLink = new KAction( i18n( "Remove Link" ), 0,
02928 this, SLOT( removeLink() ),
02929 actionCollection(), "remove_link" );
02930
02931
02932 actionAddLinkToBookmak = new KAction( i18n( "Add to Bookmark" ), 0,
02933 this, SLOT( addToBookmark() ),
02934 actionCollection(), "add_to_bookmark" );
02935
02936 actionEditCustomVarsEdit = new KAction( i18n( "&Custom Variables..." ), 0,
02937 this, SLOT( editCustomVars() ),
02938 actionCollection(), "edit_vars" );
02939
02940 actionEditCustomVars = new KAction( i18n( "Edit Variable..." ), 0,
02941 this, SLOT( editCustomVariable() ),
02942 actionCollection(), "edit_customvars" );
02943
02944
02945 m_variableDefMap.clear();
02946 actionInsertVariable = new KActionMenu( i18n( "&Variable" ),
02947 actionCollection(), "insert_variable" );
02948
02949 addVariableActions( VT_FIELD, KoFieldVariable::actionTexts(), actionInsertVariable, i18n("&Property") );
02950 addVariableActions( VT_DATE, KoDateVariable::actionTexts(), actionInsertVariable, i18n("&Date") );
02951 addVariableActions( VT_TIME, KoTimeVariable::actionTexts(), actionInsertVariable, i18n("&Time") );
02952
02953 actionInsertCustom = new KActionMenu( i18n( "&Custom" ),
02954 actionCollection(), "insert_custom" );
02955 actionInsertVariable->insert(actionInsertCustom);
02956 refreshCustomMenu();
02957
02958 addVariableActions( VT_PGNUM, KoPageVariable::actionTexts(), actionInsertVariable, i18n("&Page") );
02959 addVariableActions( VT_STATISTIC, KPrStatisticVariable::actionTexts(), actionInsertVariable, i18n("&Statistic") );
02960
02961 actionInsertVariable->popupMenu()->insertSeparator();
02962 actionRefreshAllVariable = new KAction( i18n( "&Refresh All Variables" ), 0,
02963 this, SLOT( refreshAllVariable() ),
02964 actionCollection(), "refresh_all_variable" );
02965 actionInsertVariable->insert(actionRefreshAllVariable);
02966
02967 actionIncreaseFontSize = new KAction( i18n("Increase Font Size"),"fontsizeup", 0,
02968 this, SLOT( increaseFontSize() ),
02969 actionCollection(), "increaseFontSize" );
02970
02971 actionDecreaseFontSize = new KAction( i18n("Decrease Font Size"),"fontsizedown", 0,
02972 this, SLOT( decreaseFontSize() ),
02973 actionCollection(), "decreaseFontSize" );
02974
02975 actionChangeCase=new KAction( i18n( "Change Case..." ), 0,
02976 this, SLOT( changeCaseOfText() ),
02977 actionCollection(), "change_case" );
02978
02979 actionViewZoom = new KSelectAction( i18n( "Zoom" ), "viewmag", 0,
02980 actionCollection(), "view_zoom" );
02981 connect( actionViewZoom, SIGNAL( activated( const QString & ) ),
02982 this, SLOT( viewZoom( const QString & ) ) );
02983 actionViewZoom->setEditable(true);
02984 changeZoomMenu( );
02985
02986 actionFormatStylist = new KAction( i18n( "&Style Manager" ), ALT + CTRL + Qt::Key_S,
02987 this, SLOT( extraStylist() ),
02988 actionCollection(), "format_stylist" );
02989
02990 actionFormatStyleMenu = new KActionMenu( i18n( "St&yle" ), 0,
02991 actionCollection(), "format_stylemenu" );
02992
02993
02994 actionFormatStyle = new KSelectAction( i18n( "St&yle" ), 0,
02995 actionCollection(), "format_style" );
02996 connect( actionFormatStyle, SIGNAL( activated( int ) ),
02997 this, SLOT( textStyleSelected( int ) ) );
02998 actionFormatStyle->setMenuAccelsEnabled( true );
02999 updateStyleList();
03000
03001 actionAllowAutoFormat = new KToggleAction( i18n( "Enable Autocorrection" ), 0,
03002 this, SLOT( slotAllowAutoFormat() ),
03003 actionCollection(), "enable_autocorrection" );
03004 actionAllowAutoFormat->setCheckedState(i18n("Disable Autocorrection"));
03005
03006
03007 new KAction( i18n( "Insert Non-Breaking Space" ), CTRL+Qt::Key_Space,
03008 this, SLOT( slotNonbreakingSpace() ), actionCollection(), "nonbreaking_space" );
03009 new KAction( i18n( "Insert Non-Breaking Hyphen" ), CTRL+Qt::SHIFT+Qt::Key_Minus,
03010 this, SLOT( slotNonbreakingHyphen() ), actionCollection(), "nonbreaking_hyphen" );
03011 new KAction( i18n( "Insert Soft Hyphen" ), CTRL+Qt::Key_Minus,
03012 this, SLOT( slotSoftHyphen() ), actionCollection(), "soft_hyphen" );
03013 new KAction( i18n( "Line Break" ), Qt::SHIFT+Qt::Key_Return,
03014 this, SLOT( slotLineBreak() ), actionCollection(), "line_break" );
03015 new KAction( i18n( "Completion" ), KStdAccel::shortcut(KStdAccel::TextCompletion),
03016 this, SLOT( slotCompletion() ), actionCollection(), "completion" );
03017
03018 new KAction( i18n( "Increase Numbering Level" ), ALT+Qt::Key_Right,
03019 this, SLOT( slotIncreaseNumberingLevel() ), actionCollection(), "increase_numbering_level" );
03020 new KAction( i18n( "Decrease Numbering Level" ), ALT+Qt::Key_Left,
03021 this, SLOT( slotDecreaseNumberingLevel() ), actionCollection(), "decrease_numbering_level" );
03022
03023
03024 actionInsertComment = new KAction( i18n( "Comment..." ), 0,
03025 this, SLOT( insertComment() ),
03026 actionCollection(), "insert_comment" );
03027 actionEditComment = new KAction( i18n("Edit Comment..."), 0,
03028 this,SLOT(editComment()),
03029 actionCollection(), "edit_comment");
03030
03031 actionAddGuideLine = new KAction( i18n( "Add Guide Line..."), 0,
03032 this, SLOT( addGuideLine()),
03033 actionCollection(), "add_guideline");
03034
03035 actionRemoveComment = new KAction( i18n("Remove Comment"), 0,
03036 this,SLOT(removeComment()),
03037 actionCollection(), "remove_comment");
03038
03039 actionCopyTextOfComment = new KAction( i18n("Copy Text of Comment..."), 0,
03040 this,SLOT(copyTextOfComment()),
03041 actionCollection(), "copy_text_comment");
03042
03043 actionConfigureCompletion = new KAction( i18n( "&Configure Completion..." ), 0,
03044 this, SLOT( configureCompletion() ),
03045 actionCollection(), "configure_completion" );
03046
03047 actionZoomMinus = new KAction( i18n( "Zoom Out" ), "viewmag-",0,
03048 this, SLOT( zoomMinus() ),
03049 actionCollection(), "zoom_minus" );
03050 actionZoomPlus = new KAction( i18n( "Zoom In" ), "viewmag+",0,
03051 this, SLOT( zoomPlus() ),
03052 actionCollection(), "zoom_plus" );
03053 actionZoomEntirePage = new KAction( i18n( "Zoom Entire Slide" ), 0,
03054 this, SLOT( zoomEntirePage() ),
03055 actionCollection(), "zoom_entire_page" );
03056
03057 actionZoomMinus = new KAction( i18n( "Zoom Slide Width" ), 0,
03058 this, SLOT( zoomPageWidth() ),
03059 actionCollection(), "zoom_page_width" );
03060 actionZoomSelectedObject= new KAction( i18n( "Zoom Selected Objects" ), "viewmagfit",0,
03061 this, SLOT( zoomSelectedObject() ),
03062 actionCollection(), "zoom_selected_object" );
03063 actionZoomPageHeight= new KAction( i18n( "Zoom Slide Height" ), 0,
03064 this, SLOT( zoomPageHeight() ),
03065 actionCollection(), "zoom_page_height" );
03066
03067 actionZoomAllObject= new KAction( i18n( "Zoom All Objects" ), 0,
03068 this, SLOT( zoomAllObject() ),
03069 actionCollection(), "zoom_all_object" );
03070
03071 actionFlipHorizontal= new KAction( i18n( "Horizontal Flip" ), 0,
03072 this, SLOT( flipHorizontal() ),
03073 actionCollection(), "horizontal_flip" );
03074
03075 actionFlipVertical= new KAction( i18n( "Vertical Flip" ), 0,
03076 this, SLOT( flipVertical() ),
03077 actionCollection(), "vertical_flip" );
03078
03079 actionDuplicateObj = new KAction( i18n( "Duplicate Object..." ), 0,
03080 this, SLOT( duplicateObj() ),
03081 actionCollection(), "duplicate_obj" );
03082
03083 actionApplyAutoFormat= new KAction( i18n( "Apply Autocorrection" ), 0,
03084 this, SLOT( applyAutoFormat() ),
03085 actionCollection(), "apply_autoformat" );
03086
03087 actionCreateStyleFromSelection = new KAction( i18n( "Create Style From Selection..." ), 0,
03088 this, SLOT( createStyleFromSelection()),
03089 actionCollection(), "create_style" );
03090
03091 actionCloseObject = new KAction( i18n( "Close Object" ), 0,
03092 this, SLOT( closeObject()),
03093 actionCollection(), "close_object" );
03094
03095
03096 actionAlignVerticalTop = new KToggleAction( i18n( "Align Top" ), 0,
03097 this, SLOT( alignVerticalTop() ),
03098 actionCollection(), "align_top" );
03099 actionAlignVerticalTop->setExclusiveGroup( "vertical_alignment" );
03100 actionAlignVerticalTop->setChecked( true );
03101
03102
03103 actionAlignVerticalBottom = new KToggleAction( i18n( "Align Bottom" ), 0,
03104 this, SLOT( alignVerticalBottom() ),
03105 actionCollection(), "align_bottom" );
03106 actionAlignVerticalBottom->setExclusiveGroup( "vertical_alignment" );
03107
03108 actionAlignVerticalCenter = new KToggleAction( i18n( "Align Middle" ), 0,
03109 this, SLOT( alignVerticalCenter() ),
03110 actionCollection(), "align_center" );
03111 actionAlignVerticalCenter->setExclusiveGroup( "vertical_alignment" );
03112
03113
03114 actionSavePicture= new KAction( i18n("Save Picture..."), 0,
03115 this, SLOT( savePicture() ),
03116 actionCollection(), "save_picture");
03117
03118 actionAllowBgSpellCheck = new KToggleAction( i18n( "Autospellcheck" ), 0,
03119 this, SLOT( autoSpellCheck() ),
03120 actionCollection(), "tool_auto_spellcheck" );
03121
03122 actionInsertFile= new KAction( i18n( "File..." ), 0,
03123 this, SLOT( insertFile() ),
03124 actionCollection(), "insert_file" );
03125 actionImportStyle= new KAction( i18n( "Import Styles..." ), 0,
03126 this, SLOT( importStyle() ),
03127 actionCollection(), "import_style" );
03128
03129 actionSaveBackgroundPicture= new KAction( i18n( "Save Background Picture..." ), 0,
03130 this, SLOT(backgroundPicture() ),
03131 actionCollection(), "save_bgpicture" );
03132 #if 0
03133 actionInsertDirectCursor = new KToggleAction( i18n( "Type Anywhere Cursor" ), 0,
03134 this, SLOT( insertDirectCursor() ),
03135 actionCollection(), "direct_cursor" );
03136 #endif
03137
03138 actionSpellIgnoreAll = new KAction( i18n( "Ignore All" ), 0,
03139 this, SLOT( slotAddIgnoreAllWord() ),
03140 actionCollection(), "ignore_all" );
03141
03142 actionAddWordToPersonalDictionary=new KAction( i18n( "Add Word to Dictionary" ),0,
03143 this, SLOT( addWordToDictionary() ),
03144 actionCollection(), "add_word_to_dictionary" );
03145 actionCustomSlideShow = new KAction( i18n( "Custom Slide Show..." ), 0,
03146 this, SLOT( customSlideShow() ),
03147 actionCollection(), "custom_slide_show" );
03148
03149 actionDisplayObjectFromMasterPage = new KToggleAction( i18n( "Hide Object From Slide Master" ), 0,
03150 this, SLOT( displayObjectFromMasterPage() ),
03151 actionCollection(), "display_object_from_master_page" );
03152 actionDisplayObjectFromMasterPage->setCheckedState(i18n("Display Object From Slide Master"));
03153
03154
03155 actionDisplayBackgroundPage = new KToggleAction( i18n( "Hide Background" ), 0,
03156 this, SLOT( displayBackground() ),
03157 actionCollection(), "display_background" );
03158 actionDisplayBackgroundPage->setCheckedState(i18n("Display Background"));
03159 }
03160
03161 void KPrView::displayObjectFromMasterPage()
03162 {
03163 bool state=actionDisplayObjectFromMasterPage->isChecked();
03164 m_canvas->activePage()->setDisplayObjectFromMasterPage( !state );
03165 KPrDisplayObjectFromMasterPage * cmd =new KPrDisplayObjectFromMasterPage( state ? i18n("Hide Object From Slide Master") : i18n("Display Object From Slide Master"), m_pKPresenterDoc, m_canvas->activePage(), !state);
03166 m_pKPresenterDoc->addCommand(cmd);
03167 m_pKPresenterDoc->updateSideBarItem( m_pKPresenterDoc->masterPage() );
03168 }
03169
03170 void KPrView::displayBackground()
03171 {
03172 bool state=actionDisplayBackgroundPage->isChecked();
03173 m_canvas->activePage()->setDisplayBackground( !state );
03174 KPrDisplayBackgroundPage * cmd =new KPrDisplayBackgroundPage( state ? i18n("Hide Background") : i18n("Display Background"), m_pKPresenterDoc, m_canvas->activePage(), !state);
03175 m_pKPresenterDoc->addCommand(cmd);
03176 m_pKPresenterDoc->updateSideBarItem( m_pKPresenterDoc->masterPage() );
03177 }
03178
03179 void KPrView::customSlideShow()
03180 {
03181 KPrCustomSlideShowDia *dlg = new KPrCustomSlideShowDia( this, m_pKPresenterDoc, "custom slide show" );
03182 dlg->exec();
03183 delete dlg;
03184
03185 m_pKPresenterDoc->clearTestCustomSlideShow();
03186 }
03187
03188 void KPrView::textSubScript()
03189 {
03190 m_canvas->setTextSubScript(actionFormatSub->isChecked());
03191 }
03192
03193 void KPrView::textSuperScript()
03194 {
03195 m_canvas->setTextSuperScript(actionFormatSuper->isChecked());
03196 }
03197
03198 void KPrView::decreaseFontSize()
03199 {
03200 m_canvas->setDecreaseFontSize();
03201 }
03202
03203 void KPrView::increaseFontSize()
03204 {
03205 m_canvas->setIncreaseFontSize();
03206 }
03207
03208 void KPrView::objectSelectedChanged()
03209 {
03210
03211 bool state=m_canvas->isOneObjectSelected();
03212 bool headerfooterselected=false;
03213
03214 if (m_canvas->numberOfObjectSelected()==1)
03215 {
03216 KPrObject *obj=m_canvas->getSelectedObj();
03217
03218 if (obj==m_pKPresenterDoc->header() || obj==m_pKPresenterDoc->footer())
03219 headerfooterselected=true;
03220 else
03221 headerfooterselected=false;
03222 }
03223 actionScreenAssignEffect->setEnabled(state && !headerfooterselected);
03224 actionEditDelete->setEnabled(state && !headerfooterselected);
03225 actionEditCut->setEnabled(state && !headerfooterselected);
03226
03227 KPrObjectProperties objectProperties( m_canvas->activePage()->getSelectedObjects() );
03228 int flags = objectProperties.getPropertyFlags();
03229
03230 actionBrushColor->setEnabled( !state || ( flags & KPrObjectProperties::PtBrush ) );
03231 actionExtraLineBegin->setEnabled( !state || ( flags & KPrObjectProperties::PtLineEnds ) );
03232 actionExtraLineEnd->setEnabled( !state || ( flags & KPrObjectProperties::PtLineEnds ) );
03233 actionExtraPenWidth->setEnabled( !state || ( flags & KPrObjectProperties::PtPenWidth ) );
03234
03235 actionExtraProperties->setEnabled(state && !headerfooterselected);
03236 actionExtraRotate->setEnabled(state && !headerfooterselected);
03237 actionExtraShadow->setEnabled(state && !m_canvas->haveASelectedPartObj() && !headerfooterselected);
03238
03239 actionExtraAlignObjsPopup->setEnabled(state && !headerfooterselected);
03240 actionExtraGroup->setEnabled(state && m_canvas->numberOfObjectSelected()>1);
03241 actionExtraUnGroup->setEnabled(state && m_canvas->haveASelectedGroupObj());
03242
03243 bool enableAlign = m_canvas->canMoveOneObject() && state && !headerfooterselected;
03244
03245 actionExtraAlignObjLeft->setEnabled(enableAlign);
03246 actionExtraAlignObjCenterH->setEnabled(enableAlign);
03247 actionExtraAlignObjRight->setEnabled(enableAlign);
03248 actionExtraAlignObjTop->setEnabled(enableAlign);
03249 actionExtraAlignObjCenterV->setEnabled(enableAlign);
03250 actionExtraAlignObjBottom->setEnabled(enableAlign);
03251
03252 int nbobj=m_canvas->numberOfObjectSelected();
03253 actionDuplicateObj->setEnabled(state && (nbobj>=1));
03254
03255 state = state && (nbobj==1);
03256 actionExtraArrangePopup->setEnabled(state);
03257
03258 actionExtraRaise->setEnabled( nbobj > 0 );
03259 actionExtraLower->setEnabled( nbobj > 0 );
03260 actionExtraBringForward->setEnabled( nbobj > 0 );
03261 actionExtraSendBackward->setEnabled( nbobj > 0 );
03262
03263
03264
03265
03266
03267
03268 actionApplyAutoFormat->setEnabled(m_canvas->oneObjectTextExist());
03269 slotObjectEditChanged();
03270 }
03271
03272 void KPrView::backOk( KPrBackDialog* backDia, bool takeGlobal )
03273 {
03274 KPrPage *page=m_canvas->activePage();
03275 KPrSetBackCmd *setBackCmd = new KPrSetBackCmd( i18n( "Set Background" ),
03276 backDia->getBackGround(),
03277 page->background()->getBackGround(),
03278 backDia->useMasterBackground(),
03279 takeGlobal, m_pKPresenterDoc,page);
03280 setBackCmd->execute();
03281 m_pKPresenterDoc->addCommand( setBackCmd );
03282 }
03283
03284 void KPrView::afChooseOk( const QString & c )
03285 {
03286 QFileInfo fileInfo( c );
03287 QString fileName = locate( "autoforms",
03288 fileInfo.dirPath( false ) + "/" + fileInfo.baseName() + ".atf",
03289 KPrFactory::global() );
03290
03291 deSelectAllObjects();
03292 m_canvas->setToolEditMode( INS_AUTOFORM );
03293 m_canvas->setAutoForm( fileName );
03294 }
03295
03296 void KPrView::slotAfchooseCanceled()
03297 {
03298 setTool( TEM_MOUSE );
03299 }
03300
03301 void KPrView::propertiesOk()
03302 {
03303 KCommand *cmd = m_propertyEditor->getCommand();
03304
03305 if ( cmd )
03306 {
03307 cmd->execute();
03308 kPresenterDoc()->addCommand( cmd );
03309 }
03310 }
03311
03312 void KPrView::pgConfOk()
03313 {
03314 QValueList<bool> selectedSlides;
03315 for( unsigned i = 0; i < kPresenterDoc()->pageList().count(); i++ ) {
03316 selectedSlides.append( kPresenterDoc()->pageList().at( i )->isSlideSelected() );
03317 }
03318
03319 KPrPgConfCmd *pgConfCmd = new KPrPgConfCmd( i18n( "Configure Slide Show" ),
03320 pgConfDia->getManualSwitch(), pgConfDia->getInfiniteLoop(),
03321 pgConfDia->getShowEndOfPresentationSlide(), pgConfDia->getPresentationDuration(), pgConfDia->getPen(),
03322 pgConfDia->getSelectedSlides(),
03323 pgConfDia->presentationName(),
03324 kPresenterDoc()->spManualSwitch(),
03325 kPresenterDoc()->spInfiniteLoop(),
03326 kPresenterDoc()->spShowEndOfPresentationSlide(),
03327 kPresenterDoc()->presentationDuration(),
03328 kPresenterDoc()->presPen(),
03329 selectedSlides,
03330 kPresenterDoc()->presentationName(),
03331 kPresenterDoc() );
03332 pgConfCmd->execute();
03333 kPresenterDoc()->addCommand( pgConfCmd );
03334
03335 QPtrListIterator<KPrPage> it( kPresenterDoc()->pageList() );
03336 for ( ; it.current(); ++it )
03337 updateSideBarItem( it.current() );
03338 }
03339
03340
03341 void KPrView::rotateOk()
03342 {
03343 float _newAngle=rotateDia->angle();
03344
03345 KCommand *cmd=m_canvas->activePage()->rotateSelectedObjects(_newAngle);
03346 if( cmd )
03347 kPresenterDoc()->addCommand( cmd );
03348 }
03349
03350 void KPrView::shadowOk()
03351 {
03352 KCommand *cmd=m_canvas->activePage()->shadowObj(shadowDia->shadowDirection(),
03353 shadowDia->shadowDistance(),
03354 shadowDia->shadowColor());
03355 if( cmd)
03356 kPresenterDoc()->addCommand( cmd );
03357 }
03358
03359 unsigned int KPrView::getCurrPgNum() const
03360 {
03361 return currPg + 1;
03362 }
03363
03364
03365 void KPrView::recalcCurrentPageNum()
03366 {
03367 KPrPage *activePage = m_canvas->activePage();
03368
03369 QPtrList<KPrPage> pageList( m_pKPresenterDoc->pageList() );
03370
03371 int pos = pageList.findRef( activePage );
03372
03373 if ( pos != -1 )
03374 {
03375 currPg = pos;
03376 }
03377 else
03378 {
03379 kdDebug(33001) << "KPrView::recalcCurrentPageNum: activePage not found" << endl;
03380 currPg = 0;
03381 }
03382
03383 if( sidebar )
03384 sidebar->setCurrentPage( currPg );
03385 }
03386
03387
03388 void KPrView::scrollH( int value )
03389 {
03390 if ( !presStarted ) {
03391 m_canvas->scrollX( value );
03392 if ( h_ruler )
03393 h_ruler->setOffset( value, 0 );
03394 }
03395 }
03396
03397 void KPrView::scrollV( int value )
03398 {
03399 if ( !presStarted ) {
03400 m_canvas->scrollY( value );
03401 if ( v_ruler )
03402 v_ruler->setOffset( 0, value );
03403 }
03404 }
03405
03406 void KPrView::fontChanged( const QFont &font )
03407 {
03408 tbFont.setFamily( font.family() );
03409 tbFont.setBold( font.bold() );
03410 tbFont.setItalic( font.italic() );
03411 tbFont.setUnderline( font.underline() );
03412 tbFont.setPointSize( font.pointSize() );
03413
03414 actionTextFontFamily->setFont( tbFont.family() );
03415 actionTextFontSize->setFontSize( tbFont.pointSize() );
03416 actionTextBold->setChecked( tbFont.bold() );
03417 actionTextItalic->setChecked( tbFont.italic() );
03418 actionTextUnderline->setChecked( tbFont.underline() );
03419 }
03420
03421 void KPrView::colorChanged( const QColor &color )
03422 {
03423 tbColor = color;
03424 actionTextColor->setEnabled( true );
03425 actionTextColor->setCurrentColor( tbColor );
03426 }
03427
03428 void KPrView::alignChanged( int align )
03429 {
03430 if ( align != tbAlign ) {
03431 tbAlign = align;
03432 if ( ( align & AlignLeft ) == AlignLeft ) {
03433 actionTextAlignLeft->blockSignals( true );
03434 actionTextAlignLeft->setChecked( true );
03435 actionTextAlignLeft->blockSignals( false );
03436 } else if ( ( align & AlignHCenter ) == AlignHCenter ||
03437 ( align & AlignCenter ) == AlignCenter ) {
03438 actionTextAlignCenter->blockSignals( true );
03439 actionTextAlignCenter->setChecked( true );
03440 actionTextAlignCenter->blockSignals( false );
03441 } else if ( ( align & AlignRight ) == AlignRight ) {
03442 actionTextAlignRight->blockSignals( true );
03443 actionTextAlignRight->setChecked( true );
03444 actionTextAlignRight->blockSignals( false );
03445 } else if ( (align & AlignJustify ) == AlignJustify ) {
03446 actionTextAlignBlock->blockSignals( true );
03447 actionTextAlignBlock->setChecked( true );
03448 actionTextAlignBlock->blockSignals( false );
03449 }
03450 }
03451 }
03452
03453 void KPrView::changePicture( const QString & filename )
03454 {
03455 QStringList mimetypes;
03456 mimetypes += KImageIO::mimeTypes( KImageIO::Reading );
03457 mimetypes += KoPictureFilePreview::clipartMimeTypes();
03458
03459 KFileDialog fd( filename, QString::null, this, 0, true );
03460 fd.setCaption(i18n("Select New Picture"));
03461 fd.setMimeFilter( mimetypes );
03462 fd.setPreviewWidget( new KoPictureFilePreview( &fd ) );
03463
03464 KURL url;
03465 if ( fd.exec() == QDialog::Accepted )
03466 url = fd.selectedURL();
03467
03468 if( url.isEmpty() || !url.isValid())
03469 return;
03470
03471 m_canvas->changePicture( url, m_canvas );
03472 }
03473
03474 void KPrView::resizeEvent( QResizeEvent *e )
03475 {
03476 if ( !presStarted )
03477 QWidget::resizeEvent( e );
03478
03479 QSize s = e ? e->size() : size();
03480 splitter->setGeometry( 0, 0, s.width(), s.height() );
03481 }
03482
03483 void KPrView::reorganize()
03484 {
03485 if (m_bShowGUI ) {
03486
03487 horz->show();
03488 vert->show();
03489 pgNext->show();
03490 pgPrev->show();
03491
03492 if(kPresenterDoc()->showRuler())
03493 {
03494 int hSpace = v_ruler->minimumSizeHint().width();
03495 int vSpace = h_ruler->minimumSizeHint().height();
03496
03497 m_canvas->move( hSpace, vSpace );
03498 if ( h_ruler )
03499 {
03500 h_ruler->show();
03501 h_ruler->setGeometry( hSpace, 0, m_canvas->width(), vSpace );
03502 }
03503 if (v_ruler )
03504 {
03505 v_ruler->show();
03506 v_ruler->setGeometry( 0, vSpace, hSpace, m_canvas->height() );
03507 }
03508 if(getTabChooser())
03509 {
03510 getTabChooser()->setGeometry(0, 0, hSpace, vSpace);
03511 getTabChooser()->show();
03512 }
03513 }
03514 else
03515 {
03516 m_canvas->move( 0, 0 );
03517 if ( h_ruler )
03518 h_ruler->hide();
03519 if ( v_ruler )
03520 v_ruler->hide();
03521 getTabChooser()->hide();
03522 }
03523
03524 if( statusBar())
03525 {
03526 if(m_pKPresenterDoc->showStatusBar())
03527 statusBar()->show();
03528 else
03529 statusBar()->hide();
03530 }
03531
03532 setRanges();
03533 }
03534 else
03535 {
03536 horz->hide();
03537 vert->hide();
03538 pgNext->hide();
03539 pgPrev->hide();
03540 h_ruler->hide();
03541 v_ruler->hide();
03542 getTabChooser()->hide();
03543 m_canvas->move( 0, 0 );
03544 }
03545 }
03546
03547 void PageBase::resizeEvent( QResizeEvent *e )
03548 {
03549 if ( !view->presStarted )
03550 QWidget::resizeEvent( e );
03551
03552 QSize s = e ? e->size() : size();
03553
03554 if ( view->m_bShowGUI ) {
03555 int hSpace = view->getVRuler()->minimumSizeHint().width();
03556 int vSpace = view->getVRuler()->minimumSizeHint().height();
03557
03558 view->m_canvas->resize( s.width() - ( hSpace + 16 ), s.height() - ( vSpace + 16 ) );
03559 view->vert->setGeometry( s.width() - 16, 0, 16, s.height() - 32 );
03560 view->pgPrev->setGeometry( s.width() - 15, s.height() - 32, 15, 16 );
03561 view->pgNext->setGeometry( s.width() - 15, s.height() - 16, 15, 16 );
03562 view->horz->setGeometry( 0, s.height() - 16, s.width() - 16, 16 );
03563 }
03564 else
03565 {
03566 view->m_canvas->move( 0, 0 );
03567 view->m_canvas->resize( s.width(), s.height() );
03568 }
03569 view->reorganize();
03570 }
03571
03572 void KPrView::dragEnterEvent( QDragEnterEvent *e )
03573 {
03574 QApplication::sendEvent( m_canvas, e );
03575 }
03576
03577 void KPrView::dragMoveEvent( QDragMoveEvent *e )
03578 {
03579 QApplication::sendEvent( m_canvas, e );
03580 }
03581
03582 void KPrView::dragLeaveEvent( QDragLeaveEvent *e )
03583 {
03584 QApplication::sendEvent( m_canvas, e );
03585 }
03586
03587 void KPrView::dropEvent( QDropEvent *e )
03588 {
03589 QApplication::sendEvent( m_canvas, e );
03590 }
03591
03592 void KPrView::getPageMouseWheelEvent( QWheelEvent *e )
03593 {
03594 QApplication::sendEvent( vert, e );
03595 }
03596
03597 void KPrView::keyPressEvent( QKeyEvent *e )
03598 {
03599 if ( e->key() == Qt::Key_Delete && !m_canvas->currentTextObjectView() )
03600 editDelete();
03601 else
03602 QApplication::sendEvent( m_canvas, e );
03603 }
03604
03605 void KPrView::doAutomaticScreenPres()
03606 {
03607 if ( m_autoPresStop )
03608 return;
03609 else if ( m_autoPresRestart && kPresenterDoc()->spInfiniteLoop() ) {
03610 m_autoPresRestart = false;
03611 m_canvas->presGotoFirstPage();
03612 }
03613 else
03614 screenNext();
03615 }
03616
03617 void KPrView::updateReadWrite( bool readwrite )
03618 {
03619
03620 QValueList<KAction*> actions = actionCollection()->actions();
03621
03622 actions += m_pKPresenterDoc->actionCollection()->actions();
03623 QValueList<KAction*>::ConstIterator aIt = actions.begin();
03624 QValueList<KAction*>::ConstIterator aEnd = actions.end();
03625 for (; aIt != aEnd; ++aIt )
03626 (*aIt)->setEnabled( readwrite );
03627
03628
03629 if ( !readwrite )
03630 {
03631
03632 refreshPageButton();
03633 actionViewFormattingChars->setEnabled( true );
03634 actionViewZoom->setEnabled( true );
03635 actionEditFind->setEnabled( true );
03636 actionEditFindNext->setEnabled( true );
03637 actionEditFindPrevious->setEnabled( true );
03638 actionEditReplace->setEnabled( true );
03639 actionEditSelectAll->setEnabled( true );
03640 actionEditDeSelectAll->setEnabled( true );
03641 }
03642 else
03643 {
03644 refreshPageButton();
03645 objectSelectedChanged();
03646
03647 refreshCustomMenu();
03648
03649
03650 m_pKPresenterDoc->commandHistory()->updateActions();
03651 updateSideBarMenu();
03652 }
03653
03654 }
03655
03656 void KPrView::setupPopupMenus()
03657 {
03658
03659 rb_lbegin = new QPopupMenu();
03660 Q_CHECK_PTR( rb_lbegin );
03661 rb_lbegin->insertItem( KPBarIcon("line_normal_begin" ), this, SLOT( extraLineBeginNormal() ) );
03662 rb_lbegin->insertSeparator();
03663 rb_lbegin->insertItem( KPBarIcon("line_arrow_begin" ), this, SLOT( extraLineBeginArrow() ) );
03664 rb_lbegin->insertSeparator();
03665 rb_lbegin->insertItem( KPBarIcon("line_rect_begin" ), this, SLOT( extraLineBeginRect() ) );
03666 rb_lbegin->insertSeparator();
03667 rb_lbegin->insertItem( KPBarIcon("line_circle_begin" ), this, SLOT( extraLineBeginCircle() ) );
03668 rb_lbegin->insertSeparator();
03669 rb_lbegin->insertItem( KPBarIcon("line_line_arrow_begin" ), this, SLOT( extraLineBeginLineArrow() ) );
03670 rb_lbegin->insertSeparator();
03671 rb_lbegin->insertItem( KPBarIcon("line_dimension_line_begin" ), this, SLOT( extraLineBeginDimensionLine() ) );
03672 rb_lbegin->insertSeparator();
03673 rb_lbegin->insertItem( KPBarIcon("line_double_arrow_begin" ), this, SLOT( extraLineBeginDoubleArrow() ) );
03674 rb_lbegin->insertSeparator();
03675 rb_lbegin->insertItem( KPBarIcon("line_double_line_arrow_begin" ), this, SLOT( extraLineBeginDoubleLineArrow() ) );
03676 rb_lbegin->setMouseTracking( true );
03677 rb_lbegin->setCheckable( false );
03678
03679
03680 rb_lend = new QPopupMenu();
03681 Q_CHECK_PTR( rb_lend );
03682 rb_lend->insertItem( KPBarIcon("line_normal_end" ), this, SLOT( extraLineEndNormal() ) );
03683 rb_lend->insertSeparator();
03684 rb_lend->insertItem( KPBarIcon("line_arrow_end" ), this, SLOT( extraLineEndArrow() ) );
03685 rb_lend->insertSeparator();
03686 rb_lend->insertItem( KPBarIcon("line_rect_end" ), this, SLOT( extraLineEndRect() ) );
03687 rb_lend->insertSeparator();
03688 rb_lend->insertItem( KPBarIcon("line_circle_end" ), this, SLOT( extraLineEndCircle() ) );
03689 rb_lend->insertSeparator();
03690 rb_lend->insertItem( KPBarIcon("line_line_arrow_end" ), this, SLOT( extraLineEndLineArrow() ) );
03691 rb_lend->insertSeparator();
03692 rb_lend->insertItem( KPBarIcon("line_dimension_line_end" ), this, SLOT( extraLineEndDimensionLine() ) );
03693 rb_lend->insertSeparator();
03694 rb_lend->insertItem( KPBarIcon("line_double_arrow_end" ), this, SLOT( extraLineEndDoubleArrow() ) );
03695 rb_lend->insertSeparator();
03696 rb_lend->insertItem( KPBarIcon("line_double_line_arrow_end" ), this, SLOT( extraLineEndDoubleLineArrow() ) );
03697 rb_lend->setMouseTracking( true );
03698 rb_lend->setCheckable( false );
03699
03700
03701 m_arrangeObjectsPopup = new QPopupMenu();
03702 Q_CHECK_PTR(m_arrangeObjectsPopup);
03703 m_arrangeObjectsPopup->insertItem(KPBarIcon("lower"), this, SLOT(extraLower()));
03704 m_arrangeObjectsPopup->insertSeparator();
03705 m_arrangeObjectsPopup->insertItem(KPBarIcon("send_backward"), this, SLOT(extraSendBackward()));
03706 m_arrangeObjectsPopup->insertSeparator();
03707 m_arrangeObjectsPopup->insertItem(KPBarIcon("bring_forward"), this, SLOT(extraBringForward()));
03708 m_arrangeObjectsPopup->insertSeparator();
03709 m_arrangeObjectsPopup->insertItem(KPBarIcon("raise"), this, SLOT(extraRaise()));
03710 m_arrangeObjectsPopup->setMouseTracking(true);
03711 m_arrangeObjectsPopup->setCheckable(false);
03712
03713
03714 actionToolsLinePopup->insert(actionToolsLine);
03715 actionToolsLinePopup->insert(actionToolsFreehand);
03716 actionToolsLinePopup->insert(actionToolsPolyline);
03717 actionToolsLinePopup->insert(actionToolsCubicBezierCurve);
03718 actionToolsLinePopup->insert(actionToolsQuadricBezierCurve);
03719
03720
03721 actionToolsShapePopup->insert(actionToolsRectangle);
03722 actionToolsShapePopup->insert(actionToolsCircleOrEllipse);
03723 actionToolsShapePopup->insert(actionToolsPie);
03724 actionToolsShapePopup->insert(actionToolsConvexOrConcavePolygon);
03725
03726
03727 actionToolsClosedLinePopup->insert(actionToolsClosedFreehand);
03728 actionToolsClosedLinePopup->insert(actionToolsClosedPolyline);
03729 actionToolsClosedLinePopup->insert(actionToolsClosedQuadricBezierCurve);
03730 actionToolsClosedLinePopup->insert(actionToolsClosedCubicBezierCurve);
03731
03732 actionExtraAlignObjsPopup->insert( actionExtraAlignObjLeft );
03733 actionExtraAlignObjsPopup->insert( actionExtraAlignObjCenterV );
03734 actionExtraAlignObjsPopup->insert( actionExtraAlignObjRight );
03735 actionExtraAlignObjsPopup->insert( actionExtraAlignObjTop );
03736 actionExtraAlignObjsPopup->insert( actionExtraAlignObjCenterH );
03737 actionExtraAlignObjsPopup->insert( actionExtraAlignObjBottom );
03738
03739 actionExtraArrangePopup->insert( actionExtraLower );
03740 actionExtraArrangePopup->insert( actionExtraSendBackward );
03741 actionExtraArrangePopup->insert( actionExtraBringForward );
03742 actionExtraArrangePopup->insert( actionExtraRaise );
03743 }
03744
03745 void KPrView::setupScrollbars()
03746 {
03747 vert = new QScrollBar( QScrollBar::Vertical, pageBase );
03748 horz = new QScrollBar( QScrollBar::Horizontal, pageBase );
03749 vert->show();
03750 horz->show();
03751 QObject::connect( vert, SIGNAL( valueChanged( int ) ), this, SLOT( scrollV( int ) ) );
03752 QObject::connect( horz, SIGNAL( valueChanged( int ) ), this, SLOT( scrollH( int ) ) );
03753 vert->setValue(vert->maxValue());
03754 horz->setValue(horz->maxValue());
03755 vert->setValue(vert->minValue());
03756 horz->setValue(horz->minValue());
03757 pgNext = new QToolButton( pageBase );
03758 pgNext->setPixmap( QPixmap( pagedown_xpm ) );
03759 pgNext->setAutoRepeat( TRUE );
03760 QToolTip::add( pgNext, i18n( "Next slide" ) );
03761 connect( pgNext, SIGNAL( clicked() ), this, SLOT( nextPage() ) );
03762 pgPrev = new QToolButton( pageBase );
03763 pgPrev->setPixmap( QPixmap( pageup_xpm ) );
03764 pgPrev->setAutoRepeat( TRUE );
03765 QToolTip::add( pgPrev, i18n( "Previous slide" ) );
03766 connect( pgPrev, SIGNAL( clicked() ), this, SLOT( prevPage() ) );
03767 }
03768
03769 void KPrView::setupRulers()
03770 {
03771 tabChooser = new KoTabChooser( pageBase, KoTabChooser::TAB_ALL );
03772 tabChooser->setReadWrite(kPresenterDoc()->isReadWrite());
03773 h_ruler = new KoRuler( pageBase, m_canvas, Qt::Horizontal, kPresenterDoc()->pageLayout(),
03774 KoRuler::F_INDENTS | KoRuler::F_TABS, kPresenterDoc()->unit(), tabChooser );
03775 h_ruler->changeFlags(0);
03776
03777 h_ruler->setReadWrite(kPresenterDoc()->isReadWrite());
03778 v_ruler = new KoRuler( pageBase, m_canvas, Qt::Vertical, kPresenterDoc()->pageLayout(), 0, kPresenterDoc()->unit() );
03779 v_ruler->setReadWrite(kPresenterDoc()->isReadWrite());
03780
03781 int hSpace = v_ruler->minimumSizeHint().width();
03782 int vSpace = h_ruler->minimumSizeHint().height();
03783
03784 m_canvas->resize( m_canvas->width() - hSpace, m_canvas->height() - vSpace );
03785 m_canvas->move( hSpace, vSpace );
03786 h_ruler->setGeometry( hSpace, 0, m_canvas->width(), vSpace );
03787 v_ruler->setGeometry( 0, vSpace, hSpace, m_canvas->height() );
03788
03789 QObject::connect( h_ruler, SIGNAL( unitChanged( KoUnit::Unit ) ),
03790 this, SLOT( unitChanged( KoUnit::Unit ) ) );
03791 QObject::connect( h_ruler, SIGNAL( newPageLayout( const KoPageLayout & ) ),
03792 this, SLOT( newPageLayout( const KoPageLayout & ) ) );
03793
03794 connect( h_ruler, SIGNAL( doubleClicked() ), this,
03795 SLOT( slotHRulerDoubleClicked() ) );
03796 connect( h_ruler, SIGNAL( doubleClicked(double) ), this,
03797 SLOT( slotHRulerDoubleClicked(double) ) );
03798
03799 QObject::connect( v_ruler, SIGNAL( unitChanged( KoUnit::Unit ) ),
03800 this, SLOT( unitChanged( KoUnit::Unit ) ) );
03801 QObject::connect( v_ruler, SIGNAL( newPageLayout( const KoPageLayout & ) ),
03802 this, SLOT( newPageLayout( const KoPageLayout & ) ) );
03803 QObject::connect( v_ruler, SIGNAL( doubleClicked() ),
03804 this, SLOT( openPageLayoutDia() ) );
03805
03806 connect( h_ruler, SIGNAL( newLeftIndent( double ) ), this, SLOT( newLeftIndent( double ) ) );
03807 connect( h_ruler, SIGNAL( newFirstIndent( double ) ), this, SLOT( newFirstIndent( double ) ) );
03808 connect( h_ruler, SIGNAL( newRightIndent( double ) ), this, SLOT( newRightIndent( double ) ) );
03809 }
03810
03811 void KPrView::unitChanged( KoUnit::Unit u )
03812 {
03813 m_pKPresenterDoc->setUnit( u );
03814 }
03815
03816 void KPrView::setRanges()
03817 {
03818 if ( vert && horz && m_canvas && m_pKPresenterDoc ) {
03819 vert->setSteps( 10, m_canvas->height() );
03820 vert->setRange( 0, QMAX( 0, m_canvas->activePage()->getZoomPageRect().height() - m_canvas->height() ) );
03821 horz->setSteps( 10, m_canvas->width() );
03822 horz->setRange( 0, QMAX( 0, m_canvas->activePage()->getZoomPageRect().width() + 16 - m_canvas->width() ) );
03823 }
03824 }
03825
03826 void KPrView::skipToPage( int num )
03827 {
03828 setEditMaster( false );
03829 if ( num < 0 || num > static_cast<int>( m_pKPresenterDoc->getPageNums() ) - 1 || !m_canvas )
03830 return;
03831 m_canvas->exitEditMode();
03832 currPg = num;
03833 emit currentPageChanged( currPg );
03834 if( sidebar )
03835 sidebar->setCurrentPage( currPg );
03836 KPrPage* page = m_pKPresenterDoc->pageList().at( currPg );
03837 m_canvas->setActivePage( page );
03838
03839
03840 vert->setValue( 0 );
03841 horz->setValue( 0 );
03842 if ( notebar ) {
03843 QString text = page->noteText( );
03844 notebar->setCurrentNoteText( text );
03845 }
03846 refreshPageButton();
03847
03848
03849 deSelectAllObjects();
03850 m_pKPresenterDoc->repaint( FALSE );
03851
03852 m_pKPresenterDoc->displayActivePage( page );
03853 }
03854
03855 void KPrView::refreshPageButton()
03856 {
03857 bool state = (currPg > 0);
03858 pgPrev->setEnabled( state );
03859 actionScreenFirst->setEnabled(state);
03860 actionScreenPrev->setEnabled(state);
03861 state=(currPg < (int)m_pKPresenterDoc->getPageNums() - 1);
03862 pgNext->setEnabled( state );
03863 actionScreenLast->setEnabled(state);
03864 actionScreenNext->setEnabled(state);
03865 updateHeaderFooterButton();
03866 updateDisplayObjectMasterPageButton();
03867 updateDisplayBackgroundButton();
03868 }
03869
03870 void KPrView::showObjectRect( const KPrObject * object )
03871 {
03872 QRect r = zoomHandler()->zoomRect( object->getRealRect() );
03873 if ( ! QRect( getCanvas()->diffx(),
03874 getCanvas()->diffy(),
03875 getCanvas()->width(),
03876 getCanvas()->height() ).contains( r ) )
03877 {
03878 int x = r.left() - 20;
03879 int y = r.top() - 20;
03880 if ( x < 0 )
03881 {
03882 x = 0;
03883 }
03884 if ( y < 0 )
03885 {
03886 y = 0;
03887 }
03888 horz->setValue( x );
03889 vert->setValue( y );
03890 }
03891 }
03892
03893 void KPrView::setTool( ToolEditMode toolEditMode )
03894 {
03895 switch ( toolEditMode ) {
03896 case TEM_MOUSE:
03897 actionToolsMouse->setChecked( true );
03898 break;
03899 case TEM_ROTATE:
03900 actionToolsRotate->setChecked( true );
03901 break;
03902 case TEM_ZOOM:
03903 actionToolsZoom->setChecked( true );
03904 break;
03905 case INS_LINE:
03906 actionToolsLine->setChecked( true );
03907 break;
03908 case INS_RECT:
03909 actionToolsRectangle->setChecked( true );
03910 break;
03911 case INS_ELLIPSE:
03912 actionToolsCircleOrEllipse->setChecked( true );
03913 break;
03914 case INS_PIE:
03915 actionToolsPie->setChecked( true );
03916 break;
03917 case INS_DIAGRAMM:
03918 actionToolsDiagramm->setChecked( true );
03919 break;
03920 case INS_TABLE:
03921 actionToolsTable->setChecked( true );
03922 break;
03923 case INS_FORMULA:
03924 actionToolsFormula->setChecked( true );
03925 break;
03926 case INS_TEXT:
03927 actionToolsText->setChecked( true );
03928 break;
03929 case INS_AUTOFORM:
03930 actionToolsAutoform->setChecked( true );
03931 break;
03932 default:
03933 break;
03934 }
03935 }
03936
03937 void KPrView::setRulerMouseShow( bool _show )
03938 {
03939 v_ruler->showMousePos( _show );
03940 h_ruler->showMousePos( _show );
03941 }
03942
03943 void KPrView::setRulerMousePos( int mx, int my )
03944 {
03945 v_ruler->setMousePos( mx, my );
03946 h_ruler->setMousePos( mx, my );
03947 }
03948
03949 void KPrView::enableWebPres()
03950 {
03951 }
03952
03953 void KPrView::enableMSPres()
03954 {
03955 }
03956
03957 bool KPrView::doubleClickActivation() const
03958 {
03959 return true;
03960 }
03961
03962 QWidget* KPrView::canvas() const
03963 {
03964 return m_canvas;
03965 }
03966
03967 int KPrView::canvasXOffset() const
03968 {
03969 return m_canvas->diffx();
03970 }
03971
03972 int KPrView::canvasYOffset() const
03973 {
03974 return m_canvas->diffy();
03975 }
03976
03977 void KPrView::setCanvasXOffset( int _x )
03978 {
03979 m_canvas->setDiffX( _x );
03980 }
03981
03982 void KPrView::setCanvasYOffset( int _y )
03983 {
03984 m_canvas->setDiffY( _y );
03985 }
03986
03987 int KPrView::getCurrentPresPage() const
03988 {
03989 if ( !presStarted )
03990 return -1;
03991
03992 return m_canvas->presPage();
03993 }
03994
03995 int KPrView::getCurrentPresStep() const
03996 {
03997 if ( !presStarted )
03998 return -1;
03999
04000 return m_canvas->presStep();
04001 }
04002
04003 int KPrView::getPresStepsOfPage() const
04004 {
04005 if ( !presStarted )
04006 return -1;
04007
04008 return m_canvas->numPresSteps();
04009 }
04010
04011 int KPrView::getNumPresPages() const
04012 {
04013 if ( !presStarted )
04014 return -1;
04015
04016 return m_canvas->numPresPages();
04017 }
04018
04019 bool KPrView::gotoPresPage( int pg )
04020 {
04021 if ( !presStarted )
04022 return false;
04023
04024 m_canvas->gotoPage( pg );
04025 return true;
04026 }
04027
04028 void KPrView::nextPage()
04029 {
04030
04031 if ( m_editMaster )
04032 return;
04033
04034 if ( currPg >= (int)m_pKPresenterDoc->getPageNums() - 1 )
04035 return;
04036
04037
04038 skipToPage( currPg+1 );
04039 }
04040
04041 void KPrView::prevPage()
04042 {
04043
04044 if ( m_editMaster )
04045 return;
04046
04047 if ( currPg == 0 )
04048 return;
04049 skipToPage( currPg-1 );
04050 }
04051
04052 void KPrView::updateSideBar()
04053 {
04054 if ( sidebar )
04055 {
04056 sidebar->blockSignals( TRUE );
04057 sidebar->thumbBar()->uptodate = false;
04058 sidebar->outline()->rebuildItems();
04059 sidebar->thumbBar()->rebuildItems();
04060 sidebar->blockSignals( FALSE );
04061 }
04062 }
04063
04064 void KPrView::updateSideBarItem( KPrPage * page )
04065 {
04066 if ( sidebar )
04067 sidebar->updateItem( page );
04068 m_pKPresenterDoc->recalcVariables( VT_STATISTIC );
04069 }
04070
04071 void KPrView::addSideBarItem( int pos )
04072 {
04073 if ( sidebar )
04074 {
04075 sidebar->blockSignals( TRUE );
04076 sidebar->addItem( pos );
04077 sidebar->blockSignals( FALSE );
04078 }
04079 }
04080
04081 void KPrView::moveSideBarItem( int oldPos, int newPos )
04082 {
04083 if ( sidebar )
04084 {
04085 sidebar->blockSignals( TRUE );
04086 sidebar->moveItem( oldPos, newPos );
04087 sidebar->blockSignals( FALSE );
04088 }
04089 }
04090
04091 void KPrView::removeSideBarItem( int pos )
04092 {
04093 if ( sidebar )
04094 {
04095 sidebar->blockSignals( TRUE );
04096 sidebar->removeItem( pos );
04097 sidebar->blockSignals( FALSE );
04098 }
04099 }
04100
04101 void KPrView::updatePageInfo()
04102 {
04103 if (m_sbPageLabel)
04104 m_sbPageLabel->setText( QString(" ") +
04105 i18n("Slide %1/%2").arg(getCurrPgNum()).arg(m_pKPresenterDoc->getPageNums())+
04106 QString(" ") );
04107 }
04108
04109 void KPrView::updateObjectStatusBarItem()
04110 {
04111 KStatusBar * sb = statusBar();
04112 int nbObjects = m_canvas->objNums();
04113
04114 if ( m_pKPresenterDoc->showStatusBar() && sb && nbObjects > 0 ) {
04115 int nbSelected = m_canvas->numberOfObjectSelected();
04116
04117 if (nbSelected == 1) {
04118 KoUnit::Unit unit = m_pKPresenterDoc->unit();
04119
04120 KPrObject * obj = m_canvas->getSelectedObj();
04121 KoSize size = obj->getSize();
04122 m_sbObjectLabel->setText( ' ' + i18n( "Statusbar info", "%1: %2, %3 - %4, %5 (width: %6, height: %7)" )
04123 .arg( obj->getObjectName() )
04124 .arg( KoUnit::toUserStringValue( obj->getOrig().x(), unit ) )
04125 .arg( KoUnit::toUserStringValue( obj->getOrig().y() , unit) )
04126 .arg( KoUnit::toUserStringValue( obj->getOrig().x() + size.width(), unit ) )
04127 .arg( KoUnit::toUserStringValue( obj->getOrig().y() + size.height(), unit ) )
04128 .arg( KoUnit::toUserStringValue( size.width(), unit ) )
04129 .arg( KoUnit::toUserStringValue( size.height(), unit ) ) );
04130 }
04131 else
04132 m_sbObjectLabel->setText( i18n("1 object selected", "%n objects selected", nbSelected) );
04133 }
04134 else if ( sb && m_sbObjectLabel )
04135 m_sbObjectLabel->setText( QString::null );
04136 }
04137
04138 void KPrView::pageNumChanged()
04139 {
04140 updatePageInfo();
04141 }
04142
04143 void KPrView::viewShowSideBar()
04144 {
04145 if ( !sidebar )
04146 return;
04147 if ( sidebar->isVisible() )
04148 sidebar->hide();
04149 else
04150 sidebar->show();
04151 }
04152
04153 void KPrView::viewShowNoteBar()
04154 {
04155 if ( !notebar )
04156 return;
04157 if ( notebar->isVisible() )
04158 notebar->hide();
04159 else
04160 notebar->show();
04161 }
04162
04163 void KPrView::viewSlideMaster()
04164 {
04165 bool state = actionViewSlideMaster->isChecked();
04166 setEditMaster( state );
04167
04168 state = !state;
04169 m_actionExtraHeader->setEnabled( state );
04170 m_actionExtraFooter->setEnabled( state );
04171 actionDisplayBackgroundPage->setEnabled( state );
04172 actionDisplayObjectFromMasterPage->setEnabled( state );
04173
04174 }
04175
04176 void KPrView::setEditMaster( bool editMaster )
04177 {
04178 if ( m_editMaster != editMaster )
04179 {
04180 m_canvas->exitEditMode();
04181 m_canvas->deSelectAllObj();
04182 m_editMaster = editMaster;
04183 if ( m_editMaster )
04184 {
04185 m_canvas->setActivePage( m_pKPresenterDoc->masterPage() );
04186 pgPrev->setEnabled( false );
04187 actionScreenFirst->setEnabled( false );
04188 actionScreenPrev->setEnabled( false );
04189 pgNext->setEnabled( false );
04190 actionScreenLast->setEnabled( false );
04191 actionScreenNext->setEnabled( false );
04192 actionEditCopyPage->setEnabled( false );
04193 actionEditDuplicatePage->setEnabled( false );
04194 actionEditDelPage->setEnabled( false );
04195 actionViewSlideMaster->setChecked( true );
04196 }
04197 else
04198 {
04199 m_canvas->setActivePage( m_pKPresenterDoc->pageList().at( currPg ) );
04200 actionEditCopyPage->setEnabled( true );
04201 actionEditDuplicatePage->setEnabled( true );
04202 actionEditDelPage->setEnabled( m_pKPresenterDoc->getPageNums() > 1 );
04203 actionViewSlideMaster->setChecked( false );
04204 refreshPageButton();
04205 }
04206 if ( sidebar )
04207 sidebar->setViewMasterPage( m_editMaster );
04208 updateNoteBarText();
04209 m_canvas->repaint( false );
04210 }
04211 }
04212
04213 void KPrView::updateNoteBarText()
04214 {
04215 if ( notebar ) {
04216 if ( m_editMaster )
04217 {
04218 QString text = m_pKPresenterDoc->masterPage()->noteText();
04219 notebar->setCurrentNoteText( text );
04220 }
04221 else
04222 {
04223 QString text = m_pKPresenterDoc->pageList().at( currPg )->noteText( );
04224 notebar->setCurrentNoteText( text );
04225 }
04226 }
04227 }
04228
04229 void KPrView::openPopupMenuMenuPage( const QPoint & _point )
04230 {
04231 if(!koDocument()->isReadWrite() || !factory())
04232 return;
04233 QPtrList<KAction> actionList= QPtrList<KAction>();
04234 KActionSeparator *separator=new KActionSeparator();
04235 switch( m_canvas->activePage()->getBackType())
04236 {
04237 case BT_COLOR:
04238 case BT_BRUSH:
04239 break;
04240 case BT_PICTURE:
04241 case BT_CLIPART:
04242 actionList.append(separator);
04243 actionList.append(actionSaveBackgroundPicture);
04244 break;
04245 }
04246 if ( actionList.count()>0)
04247 plugActionList( "picture_action", actionList );
04248 m_mousePos = m_canvas->mapFromGlobal( _point );
04249 QPopupMenu* menu = dynamic_cast<QPopupMenu*>(factory()->container("menupage_popup",this));
04250 if ( menu )
04251 menu->exec(_point);
04252 m_mousePos = QPoint( 0, 0 );
04253 unplugActionList( "picture_action" );
04254 delete separator;
04255 }
04256
04257 void KPrView::openPopupMenuObject( const QString & name, const QPoint & _point )
04258 {
04259 if(!koDocument()->isReadWrite() || !factory())
04260 return;
04261 dynamic_cast<QPopupMenu*>(factory()->container(name, this))->popup(_point);
04262 }
04263
04264 void KPrView::openPopupMenuSideBar(const QPoint & _point)
04265 {
04266 if(!koDocument()->isReadWrite() || !factory())
04267 return;
04268 dynamic_cast<QPopupMenu*>(factory()->container("sidebarmenu_popup", this))->popup(_point);
04269 }
04270
04271 void KPrView::renamePageTitle()
04272 {
04273 if(sidebar)
04274 sidebar->renamePageTitle();
04275 }
04276
04277 void KPrView::picViewOriginalSize()
04278 {
04279 m_canvas->picViewOriginalSize();
04280 }
04281
04282 void KPrView::picViewOrig640x480()
04283 {
04284 m_canvas->picViewOrig640x480();
04285 }
04286
04287 void KPrView::picViewOrig800x600()
04288 {
04289 m_canvas->picViewOrig800x600();
04290 }
04291
04292 void KPrView::picViewOrig1024x768()
04293 {
04294 m_canvas->picViewOrig1024x768();
04295 }
04296
04297 void KPrView::picViewOrig1280x1024()
04298 {
04299 m_canvas->picViewOrig1280x1024();
04300 }
04301
04302 void KPrView::picViewOrig1600x1200()
04303 {
04304 m_canvas->picViewOrig1600x1200();
04305 }
04306
04307 void KPrView::chPic()
04308 {
04309 m_canvas->chPic();
04310 }
04311
04312 void KPrView::penColorChanged( const KoPen & _pen )
04313 {
04314
04315 actionPenColor->setCurrentColor( _pen.color() );
04316 }
04317
04318 void KPrView::brushColorChanged( const QBrush & _brush )
04319 {
04320
04321 actionBrushColor->setCurrentColor(_brush.style ()==Qt::NoBrush ? Qt::white : _brush.color() );
04322 }
04323
04324 void KPrView::restartAutoPresTimer()
04325 {
04326 m_autoPresTime.start();
04327 m_autoPresElapsedTime = 0;
04328 m_autoPresTimer.start( m_autoPresTimerValue, true );
04329 }
04330
04331 void KPrView::continueAutoPresTimer()
04332 {
04333 m_autoPresTime.restart();
04334
04335 m_autoPresTimer.start( m_autoPresTimerValue - m_autoPresElapsedTime, true );
04336 }
04337
04338 void KPrView::stopAutoPresTimer()
04339 {
04340 m_autoPresTimer.stop();
04341 m_autoPresElapsedTime += m_autoPresTime.elapsed();
04342 }
04343
04344 void KPrView::setAutoPresTimer( int sec )
04345 {
04346 m_autoPresTimerValue = sec * 1000;
04347 restartAutoPresTimer();
04348 }
04349
04350 void KPrView::insertSpecialChar()
04351 {
04352 KPrTextView *edit=m_canvas->currentTextObjectView();
04353 if ( !edit )
04354 return;
04355 QString f = edit->textFontFamily();
04356 QChar c=' ';
04357 if (m_specialCharDlg==0)
04358 {
04359 m_specialCharDlg = new KoCharSelectDia( this, "insert special char", f, c, false );
04360 connect( m_specialCharDlg, SIGNAL(insertChar(QChar,const QString &)),
04361 this, SLOT(slotSpecialChar(QChar,const QString &)));
04362 connect( m_specialCharDlg, SIGNAL( finished() ),
04363 this, SLOT( slotSpecialCharDlgClosed() ) );
04364 }
04365 m_specialCharDlg->show();
04366 }
04367
04368 void KPrView::slotSpecialCharDlgClosed()
04369 {
04370 if ( m_specialCharDlg)
04371 {
04372 disconnect( m_specialCharDlg, SIGNAL(insertChar(QChar,const QString &)),
04373 this, SLOT(slotSpecialChar(QChar,const QString &)));
04374 disconnect( m_specialCharDlg, SIGNAL( finished() ),
04375 this, SLOT( slotSpecialCharDlgClosed() ) );
04376 m_specialCharDlg->deleteLater();
04377 m_specialCharDlg = 0L;
04378 }
04379 }
04380
04381 void KPrView::slotSpecialChar(QChar c, const QString &_font)
04382 {
04383 KPrTextView *edit=m_canvas->currentTextObjectView();
04384 if ( !edit )
04385 return;
04386 edit->insertSpecialChar(c, _font);
04387 }
04388
04389 void KPrView::insertLink()
04390 {
04391 KPrTextView *edit=m_canvas->currentTextObjectView();
04392 if ( !edit )
04393 return;
04394 QString link;
04395 QString ref;
04396 if ( edit->textObject()->hasSelection() )
04397 {
04398 QString selectedText = edit->textObject()->selectedText();
04399 if ( edit->textObject()->selectionHasCustomItems() || selectedText.contains('\n') )
04400 return;
04401 if ( selectedText.startsWith( "mailto:/" ) ||
04402 selectedText.startsWith( "ftp:/" ) ||
04403 selectedText.startsWith( "http:/" ) )
04404 {
04405 link=selectedText;
04406 ref = selectedText;
04407 }
04408 else
04409 {
04410
04411 link = selectedText;
04412 }
04413 }
04414
04415 if(KoInsertLinkDia::createLinkDia(link, ref, QStringList(), false, this))
04416 {
04417 if(!link.isEmpty() && !ref.isEmpty())
04418 edit->insertLink(link, ref);
04419 }
04420 }
04421
04422 void KPrView::changeLink()
04423 {
04424 KPrTextView * edit = m_canvas->currentTextObjectView();
04425 if ( edit )
04426 {
04427 KoLinkVariable * var=edit->linkVariable();
04428 if(var)
04429 {
04430 QString oldhref= var->url();
04431 QString oldLinkName=var->value();
04432 QString link=oldLinkName;
04433 QString ref=oldhref;
04434 if(KoInsertLinkDia::createLinkDia(link, ref, QStringList(), false, this))
04435 {
04436 if(!link.isEmpty() && !ref.isEmpty())
04437 {
04438 if( ref != oldhref || link!=oldLinkName)
04439 {
04440 KPrChangeLinkVariable*cmd=new KPrChangeLinkVariable( i18n("Change Link"),
04441 m_pKPresenterDoc, oldhref,
04442 ref, oldLinkName,link, var);
04443 cmd->execute();
04444 m_pKPresenterDoc->addCommand(cmd);
04445 }
04446 }
04447 }
04448 }
04449 }
04450 }
04451
04452 void KPrView::showFormat( const KoTextFormat ¤tFormat )
04453 {
04454 actionTextFontFamily->setFont( currentFormat.font().family() );
04455 actionTextFontSize->setFontSize( currentFormat.pointSize() );
04456 actionTextBold->setChecked( currentFormat.font().bold());
04457 actionTextItalic->setChecked( currentFormat.font().italic() );
04458 actionTextUnderline->setChecked( currentFormat.underline());
04459 actionFormatStrikeOut->setChecked( currentFormat.strikeOut());
04460
04461 actionBrushColor->setEnabled(true);
04462
04463
04464 switch(currentFormat.vAlign())
04465 {
04466 case KoTextFormat::AlignSuperScript:
04467 {
04468 actionFormatSub->setChecked( false );
04469 actionFormatSuper->setChecked( true );
04470 break;
04471 }
04472 case KoTextFormat::AlignSubScript:
04473 {
04474 actionFormatSub->setChecked( true );
04475 actionFormatSuper->setChecked( false );
04476 break;
04477 }
04478 case KoTextFormat::AlignNormal:
04479 default:
04480 {
04481 actionFormatSub->setChecked( false );
04482 actionFormatSuper->setChecked( false );
04483 break;
04484 }
04485 }
04486 }
04487
04488 void KPrView::slotSoftHyphen()
04489 {
04490 KPrTextView *edit = m_canvas->currentTextObjectView();
04491 if ( edit )
04492 edit->insertSoftHyphen();
04493 }
04494
04495 void KPrView::slotNonbreakingSpace()
04496 {
04497 KPrTextView *edit=m_canvas->currentTextObjectView();
04498 if ( edit )
04499 edit->insertNonbreakingSpace();
04500 }
04501
04502 void KPrView::slotNonbreakingHyphen()
04503 {
04504 KPrTextView *edit=m_canvas->currentTextObjectView();
04505 if ( edit )
04506 edit->insertNonbreakingHyphen();
04507 }
04508
04509 void KPrView::slotLineBreak()
04510 {
04511 KPrTextView *edit=m_canvas->currentTextObjectView();
04512 if ( edit )
04513 edit->insertLineBreak();
04514 }
04515
04516 void KPrView::slotIncreaseNumberingLevel()
04517 {
04518 KPrTextView *edit=m_canvas->currentTextObjectView();
04519 if ( edit )
04520 {
04521 edit->increaseNumberingLevel( m_pKPresenterDoc->styleCollection() );
04522 }
04523 }
04524
04525 void KPrView::slotDecreaseNumberingLevel()
04526 {
04527 KPrTextView *edit=m_canvas->currentTextObjectView();
04528 if ( edit )
04529 edit->decreaseNumberingLevel( m_pKPresenterDoc->styleCollection() );
04530 }
04531
04532 void KPrView::extraAutoFormat()
04533 {
04534 m_pKPresenterDoc->getAutoFormat()->readConfig();
04535 KoAutoFormatDia dia( this, 0, m_pKPresenterDoc->getAutoFormat() );
04536 dia.exec();
04537 m_pKPresenterDoc->startBackgroundSpellCheck();
04538 }
04539
04540 void KPrView::slotSpellCheck()
04541 {
04542 if (m_spell.kospell) return;
04543
04544 m_spell.macroCmdSpellCheck = 0L;
04545 m_spell.replaceAll.clear();
04546 QValueList<KoTextObject *> objects;
04547 KPrTextView *edit=m_canvas->currentTextObjectView();
04548 int options = 0;
04549 if ( edit && edit->textObject()->hasSelection() )
04550 {
04551 objects.append(edit->kpTextObject()->textObject());
04552 options = KFindDialog::SelectedText;
04553 }
04554 else
04555 {
04556 objects = spellAddTextObject();
04557 QPtrList<KPrObject> lstObj;
04558 }
04559 if ( ! objects.empty() )
04560 {
04561 m_spell.textIterator = new KoTextIterator( objects, edit, options );
04562 startKSpell();
04563 }
04564 }
04565
04566 QValueList<KoTextObject *> KPrView::spellAddTextObject() const
04567 {
04568 QValueList<KoTextObject *> lst;
04569 QPtrList<KPrObject> lstObj;
04570 m_canvas->activePage()->getAllObjectSelectedList(lstObj, true);
04571 QPtrListIterator<KPrObject> it( lstObj );
04572 for ( ; it.current() ; ++it )
04573 {
04574 if(it.current()->getType()==OT_TEXT)
04575 {
04576 KPrTextObject* tmp = dynamic_cast<KPrTextObject*>(it.current() );
04577 if ( tmp && !tmp->isProtectContent())
04578 lst.append( tmp->textObject() );
04579 }
04580 }
04581 return lst;
04582 }
04583
04584
04585
04586 void KPrView::startKSpell()
04587 {
04588
04589 if ( !m_spell.kospell )
04590 m_spell.kospell = new KoSpell( m_broker, this );
04591 m_spell.kospell->check( m_spell.textIterator, true );
04592
04593 delete m_spell.dlg;
04594 m_spell.dlg = new KSpell2::Dialog( m_spell.kospell, this );
04595 m_spell.dlg->activeAutoCorrect( true );
04596 QObject::connect( m_spell.dlg, SIGNAL(misspelling(const QString&, int)),
04597 this, SLOT(spellCheckerMisspelling(const QString&, int)) );
04598 QObject::connect( m_spell.dlg, SIGNAL(replace(const QString&, int, const QString&)),
04599 this, SLOT(spellCheckerCorrected(const QString&, int, const QString&)) );
04600 QObject::connect( m_spell.dlg, SIGNAL(done(const QString&) ),
04601 this, SLOT(spellCheckerDone(const QString&)) );
04602 QObject::connect( m_spell.dlg, SIGNAL(cancel() ),
04603 this, SLOT( spellCheckerCancel() ) );
04604 QObject::connect( m_spell.dlg, SIGNAL(autoCorrect(const QString &, const QString & ) ),
04605 this, SLOT( spellAddAutoCorrect (const QString &, const QString &) ) );
04606
04607 m_spell.dlg->show();
04608 }
04609
04610
04611
04612 void KPrView::spellCheckerCancel()
04613 {
04614 kdDebug()<<"void KPrView::spellCheckerCancel() \n";
04615 spellCheckerRemoveHighlight();
04616 clearSpellChecker(true);
04617 }
04618
04619
04620 void KPrView::spellCheckerRemoveHighlight()
04621 {
04622 KoTextObject* textobj = m_spell.kospell->currentTextObject();
04623 if ( textobj ) {
04624 KPrTextDocument *textdoc=static_cast<KPrTextDocument *>( textobj->textDocument() );
04625 if ( textdoc )
04626 textdoc->textObject()->removeHighlight();
04627 }
04628 KPrTextView *edit=m_canvas->currentTextObjectView();
04629 if (edit)
04630 edit->drawCursor( TRUE );
04631 }
04632
04633
04634 void KPrView::clearSpellChecker(bool cancelSpellCheck)
04635 {
04636 kdDebug() << "KPrView::clearSpellChecker()" << endl;
04637 delete m_spell.textIterator;
04638 m_spell.textIterator = 0L;
04639
04640
04641 delete m_spell.kospell;
04642 m_spell.kospell = 0;
04643 m_initSwitchPage = -1;
04644 m_switchPage = -1;
04645
04646 if ( m_spell.macroCmdSpellCheck )
04647 {
04648 if ( !cancelSpellCheck )
04649 m_pKPresenterDoc->addCommand(m_spell.macroCmdSpellCheck);
04650 else
04651 {
04652
04653 m_spell.macroCmdSpellCheck->unexecute();
04654 delete m_spell.macroCmdSpellCheck;
04655 }
04656 }
04657 m_spell.macroCmdSpellCheck=0L;
04658
04659 m_spell.replaceAll.clear();
04660
04661 }
04662
04663 void KPrView::spellCheckerMisspelling( const QString &old, int pos )
04664 {
04665
04666 KoTextObject* textobj = m_spell.kospell->currentTextObject();
04667 KoTextParag* parag = m_spell.kospell->currentParag();
04668 Q_ASSERT( textobj );
04669 Q_ASSERT( parag );
04670 if ( !textobj || !parag ) return;
04671 KPrTextDocument *textdoc=static_cast<KPrTextDocument *>( textobj->textDocument() );
04672 Q_ASSERT( textdoc );
04673 if ( !textdoc ) return;
04674 pos += m_spell.kospell->currentStartIndex();
04675
04676 kdDebug() << "KWView::spellCheckerMisspelling parag=" << parag->paragId() << " pos=" << pos << " length=" << old.length() << endl;
04677
04678 textdoc->textObject()->highlightPortion( parag, pos, old.length(), m_canvas,true );
04679 }
04680
04681 void KPrView::spellCheckerCorrected( const QString &old, int pos, const QString &corr )
04682 {
04683
04684
04685
04686 KoTextObject* textobj = m_spell.kospell->currentTextObject();
04687 KoTextParag* parag = m_spell.kospell->currentParag();
04688 Q_ASSERT( textobj );
04689 Q_ASSERT( parag );
04690 if ( !textobj || !parag ) return;
04691
04692 KPrTextDocument *textdoc=static_cast<KPrTextDocument *>( textobj->textDocument() );
04693 Q_ASSERT( textdoc );
04694 if ( !textdoc )
04695 return;
04696 pos += m_spell.kospell->currentStartIndex();
04697 textdoc->textObject()->highlightPortion( parag, pos, old.length(), m_canvas,true );
04698
04699 KoTextCursor cursor( textdoc );
04700 cursor.setParag( parag );
04701 cursor.setIndex( pos );
04702 if(!m_spell.macroCmdSpellCheck)
04703 m_spell.macroCmdSpellCheck=new KMacroCommand(i18n("Correct Misspelled Word"));
04704 m_spell.macroCmdSpellCheck->addCommand(textobj->replaceSelectionCommand(&cursor, corr, QString::null, KoTextDocument::HighlightSelection));
04705 }
04706
04707 void KPrView::spellCheckerDone( const QString & )
04708 {
04709
04710 kdDebug() << "KPrView::spellCheckerDone" << endl;
04711 KPrTextDocument *textdoc=static_cast<KPrTextDocument *>( m_spell.kospell->textDocument() );
04712 Q_ASSERT( textdoc );
04713 if ( textdoc )
04714 textdoc->textObject()->removeHighlight();
04715
04716 clearSpellChecker();
04717 }
04718
04719 void KPrView::showCounter( KoParagCounter &c )
04720 {
04721 QString styleStr("counterstyle_");
04722 styleStr += QString::number( c.style() );
04723
04724 KToggleAction* act = static_cast<KToggleAction *>( actionCollection()->action( styleStr.latin1() ) );
04725 Q_ASSERT( act );
04726 if ( act )
04727 act->setChecked( true );
04728 }
04729
04730 void KPrView::formatParagraph()
04731 {
04732 showParagraphDialog();
04733 }
04734
04735 void KPrView::showParagraphDialog(int initialPage, double initialTabPos)
04736 {
04737 QPtrList<KoTextFormatInterface> lst = m_canvas->applicableTextInterfaces();
04738 if ( lst.isEmpty() )
04739 return;
04740 QPtrList<KPrTextObject> lstObjects = m_canvas->applicableTextObjects();
04741 if ( lstObjects.isEmpty() )
04742 return;
04743
04744 delete m_paragDlg;
04745 m_paragDlg = new KoParagDia( this, "",
04746 KoParagDia::PD_SPACING | KoParagDia::PD_ALIGN |
04747 KoParagDia::PD_DECORATION | KoParagDia::PD_NUMBERING |
04748 KoParagDia::PD_TABS,
04749 m_pKPresenterDoc->unit(),
04750 lstObjects.first()->getSize().width(),false );
04751 m_paragDlg->setCaption( i18n( "Paragraph Settings" ) );
04752
04753
04754 m_paragDlg->setParagLayout( * lst.first()->currentParagLayoutFormat() );
04755
04756 if ( initialPage != -1 )
04757 {
04758 m_paragDlg->setCurrentPage( initialPage );
04759 if ( initialPage == KoParagDia::PD_TABS )
04760 m_paragDlg->tabulatorsWidget()->setCurrentTab( initialTabPos );
04761 }
04762 connect( m_paragDlg, SIGNAL( applyParagStyle() ), this, SLOT( slotApplyParag() ) );
04763
04764 m_paragDlg->exec();
04765 delete m_paragDlg;
04766 m_paragDlg = 0;
04767
04768 }
04769
04770 void KPrView::slotApplyParag()
04771 {
04772 QPtrList<KoTextFormatInterface> lst = m_canvas->applicableTextInterfaces();
04773 Q_ASSERT( !lst.isEmpty() );
04774 if ( lst.isEmpty() ) return;
04775 QPtrListIterator<KoTextFormatInterface> it( lst );
04776 KMacroCommand * macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
04777 KoParagLayout newLayout = m_paragDlg->paragLayout();
04778 int flags = m_paragDlg->changedFlags();
04779 kdDebug() << k_funcinfo << "flags=" << flags << endl;
04780 if ( !flags )
04781 return;
04782 for ( ; it.current() ; ++it )
04783 {
04784 KCommand* cmd = it.current()->setParagLayoutFormatCommand( &newLayout, flags );
04785 Q_ASSERT( cmd );
04786 if(cmd)
04787 {
04788 macroCommand->addCommand(cmd);
04789 }
04790 }
04791
04792 if(flags)
04793 m_pKPresenterDoc->addCommand(macroCommand);
04794 else
04795 delete macroCommand;
04796
04797
04798
04799 m_paragDlg->setParagLayout( *lst.first()->currentParagLayoutFormat() );
04800 }
04801
04802 void KPrView::textDefaultFormat()
04803 {
04804 m_canvas->setTextDefaultFormat( );
04805 }
04806
04807 void KPrView::changeNbOfRecentFiles(int _nb)
04808 {
04809 if ( shell() )
04810 shell()->setMaxRecentItems( _nb );
04811 }
04812
04813 QPopupMenu * KPrView::popupMenu( const QString& name )
04814 {
04815 Q_ASSERT(factory());
04816 if ( factory() )
04817 return ((QPopupMenu*)factory()->container( name, this ));
04818 return 0L;
04819 }
04820
04821 void KPrView::addVariableActions( int type, const QStringList & texts,
04822 KActionMenu * parentMenu, const QString & menuText )
04823 {
04824
04825
04826 if ( texts.count() > 1 && !menuText.isEmpty() )
04827 {
04828 KActionMenu * subMenu = new KActionMenu( menuText, actionCollection() );
04829 parentMenu->insert( subMenu );
04830 parentMenu = subMenu;
04831 }
04832 QStringList::ConstIterator it = texts.begin();
04833 for ( int i = 0; it != texts.end() ; ++it, ++i )
04834 {
04835 if ( !(*it).isEmpty() )
04836 {
04837 VariableDef v;
04838 v.type = type;
04839 v.subtype = i;
04840 KAction * act = new KAction( (*it), 0, this, SLOT( insertVariable() ),
04841 actionCollection(), "var-action" );
04842 m_variableDefMap.insert( act, v );
04843 parentMenu->insert( act );
04844 }
04845 }
04846 }
04847
04848 void KPrView::refreshCustomMenu()
04849 {
04850 KActionPtrList lst2 = actionCollection()->actions("custom-variable-action");
04851 QValueList<KAction *> actions = lst2;
04852 QValueList<KAction *>::ConstIterator it2 = lst2.begin();
04853 QValueList<KAction *>::ConstIterator end = lst2.end();
04854 QMap<QString, KShortcut> shortCuts;
04855
04856 for (; it2 != end; ++it2 )
04857 {
04858 shortCuts.insert((*it2)->text(), (*it2)->shortcut());
04859 delete *it2;
04860 }
04861
04862 delete actionInsertCustom;
04863 actionInsertCustom = new KActionMenu( i18n( "&Custom" ),
04864 actionCollection(), "insert_custom" );
04865
04866 actionInsertVariable->insert(actionInsertCustom, 0);
04867
04868
04869 actionInsertCustom->popupMenu()->clear();
04870 QPtrListIterator<KoVariable> it( m_pKPresenterDoc->getVariableCollection()->getVariables() );
04871 KAction * act=0;
04872 QStringList lst;
04873 QString varName;
04874 int i = 0;
04875 for ( ; it.current() ; ++it )
04876 {
04877 KoVariable *var = it.current();
04878 if ( var->type() == VT_CUSTOM )
04879 {
04880 varName=( (KoCustomVariable*) var )->name();
04881 if ( !lst.contains( varName) )
04882 {
04883 lst.append( varName );
04884 QCString name = QString("custom-action_%1").arg(i).latin1();
04885 act = new KAction( varName, shortCuts[varName], this,
04886 SLOT( insertCustomVariable() ), actionCollection(), name );
04887
04888 act->setGroup( "custom-variable-action" );
04889 actionInsertCustom->insert( act );
04890 i++;
04891 }
04892 }
04893 }
04894 bool state=!lst.isEmpty();
04895 if(state)
04896 actionInsertCustom->popupMenu()->insertSeparator();
04897
04898 act = new KAction( i18n("New..."), 0, this, SLOT( insertNewCustomVariable() ), actionCollection(),
04899 QString("custom-action_%1").arg(i).latin1() );
04900 act->setGroup( "custom-variable-action" );
04901 actionInsertCustom->insert( act );
04902
04903 actionInsertCustom->popupMenu()->insertSeparator();
04904
04905 actionEditCustomVars->setEnabled(state);
04906 actionEditCustomVarsEdit->setEnabled( state );
04907 actionInsertCustom->insert( actionEditCustomVarsEdit );
04908 }
04909
04910 void KPrView::insertCustomVariable()
04911 {
04912 KPrTextView *edit=m_canvas->currentTextObjectView();
04913 if ( edit )
04914 {
04915 KAction * act = (KAction *)(sender());
04916 edit->insertCustomVariable(act->text());
04917 }
04918 }
04919
04920 void KPrView::insertNewCustomVariable()
04921 {
04922 KPrTextView *edit=m_canvas->currentTextObjectView();
04923 if ( edit )
04924 edit->insertVariable( VT_CUSTOM, 0 );
04925 }
04926
04927 void KPrView::editCustomVariable()
04928 {
04929 KPrTextView *edit=m_canvas->currentTextObjectView();
04930 if ( edit )
04931 {
04932 KoCustomVariable *var = static_cast<KoCustomVariable *>(edit->variable());
04933 if (var)
04934 {
04935 QString oldvalue = var->value();
04936 KoCustomVarDialog dia( this, var );
04937 if ( dia.exec() )
04938 {
04939 if( var->value() != oldvalue )
04940 {
04941 KPrChangeCustomVariableValue *cmd=new KPrChangeCustomVariableValue(i18n( "Change Custom Variable" ),
04942 m_pKPresenterDoc, oldvalue, var->value(), var );
04943 m_pKPresenterDoc->addCommand(cmd);
04944 }
04945 m_pKPresenterDoc->recalcVariables( VT_CUSTOM );
04946 }
04947 }
04948 }
04949 }
04950
04951 void KPrView::editCustomVars()
04952 {
04953 KoCustomVariablesDia dia( this, m_pKPresenterDoc->getVariableCollection()->getVariables() );
04954 QStringList listOldCustomValue;
04955 QPtrListIterator<KoVariable> oldIt( m_pKPresenterDoc->getVariableCollection()->getVariables() );
04956 for ( ; oldIt.current() ; ++oldIt )
04957 {
04958 if(oldIt.current()->type()==VT_CUSTOM)
04959 listOldCustomValue.append(((KoCustomVariable*)oldIt.current())->value());
04960 }
04961 if(dia.exec())
04962 {
04963 m_pKPresenterDoc->recalcVariables( VT_CUSTOM );
04964 QPtrListIterator<KoVariable> it( m_pKPresenterDoc->getVariableCollection()->getVariables() );
04965 KMacroCommand * macroCommand = 0L;
04966 int i=0;
04967 for ( ; it.current() ; ++it )
04968 {
04969 if(it.current()->type() == VT_CUSTOM )
04970 {
04971 if(((KoCustomVariable*)it.current())->value()!=*(listOldCustomValue.at(i)))
04972 {
04973 if(!macroCommand)
04974 macroCommand = new KMacroCommand( i18n( "Change Custom Variable" ) );
04975 KPrChangeCustomVariableValue *cmd=
04976 new KPrChangeCustomVariableValue(i18n( "Change Custom Variable" ), m_pKPresenterDoc,
04977 *(listOldCustomValue.at(i)),
04978 ((KoCustomVariable*)it.current())->value(),
04979 ((KoCustomVariable*)it.current()));
04980 macroCommand->addCommand(cmd);
04981 }
04982 i++;
04983 }
04984 }
04985 if(macroCommand)
04986 m_pKPresenterDoc->addCommand(macroCommand);
04987 }
04988 }
04989
04990 void KPrView::insertVariable()
04991 {
04992 KPrTextView *edit=m_canvas->currentTextObjectView();
04993 if ( edit )
04994 {
04995 KAction * act = (KAction *)(sender());
04996 VariableDefMap::ConstIterator it = m_variableDefMap.find( act );
04997 if ( it == m_variableDefMap.end() )
04998 kdWarning(33001) << "Action not found in m_variableDefMap." << endl;
04999 else
05000 {
05001 if ( (*it).type == VT_FIELD )
05002 edit->insertVariable( (*it).type, KoFieldVariable::fieldSubType( (*it).subtype ) );
05003 else
05004 edit->insertVariable( (*it).type, (*it).subtype );
05005 }
05006 }
05007 }
05008
05009 void KPrView::openLink()
05010 {
05011 KPrTextView *edit=m_canvas->currentTextObjectView();
05012 if ( edit )
05013 edit->openLink();
05014 }
05015
05016 void KPrView::showRulerIndent( double _leftMargin, double _firstLine, double _rightMargin, bool rtl )
05017 {
05018 KoRuler * hRuler = getHRuler();
05019 if ( hRuler )
05020 {
05021 hRuler->setFirstIndent( KoUnit::toUserValue( _firstLine, m_pKPresenterDoc->unit() ) );
05022 hRuler->setLeftIndent( KoUnit::toUserValue( _leftMargin, m_pKPresenterDoc->unit() ) );
05023 hRuler->setRightIndent( KoUnit::toUserValue( _rightMargin, m_pKPresenterDoc->unit() ) );
05024 hRuler->setDirection( rtl );
05025 actionTextDepthMinus->setEnabled( _leftMargin>0);
05026 }
05027 }
05028
05029 void KPrView::tabListChanged( const KoTabulatorList & tabList )
05030 {
05031 if(!m_pKPresenterDoc->isReadWrite())
05032 return;
05033
05034 m_canvas->setTabList( tabList );
05035 }
05036
05037 void KPrView::newFirstIndent( double _firstIndent )
05038 {
05039 m_canvas->setNewFirstIndent(_firstIndent);
05040 }
05041
05042 void KPrView::newLeftIndent( double _leftIndent)
05043 {
05044 m_canvas->setNewLeftIndent(_leftIndent);
05045 }
05046
05047 void KPrView::newRightIndent( double _rightIndent)
05048 {
05049 m_canvas->setNewRightIndent(_rightIndent);
05050 }
05051
05052 void KPrView::slotUpdateRuler()
05053 {
05054
05055 bool isText=!m_canvas->applicableTextObjects().isEmpty();
05056 if ( isText )
05057 {
05058 KPrTextObject *txtobj= m_canvas->applicableTextObjects().first();
05059 if ( txtobj )
05060 {
05061 QRect r= zoomHandler()->zoomRect(txtobj->getRealRect());
05062 getHRuler()->setFrameStartEnd( r.left() , r.right() );
05063 getVRuler()->setFrameStartEnd( r.top(), r.bottom() );
05064 if( getHRuler())
05065 {
05066 int flags = txtobj->isProtectContent() ? 0 : (KoRuler::F_INDENTS | KoRuler::F_TABS);
05067 if( getHRuler()->flags()!= flags )
05068 {
05069 getHRuler()->changeFlags(flags);
05070 getHRuler()->repaint();
05071 }
05072 }
05073 if( getVRuler())
05074 {
05075 if( getVRuler()->flags() != 0 )
05076 {
05077 getVRuler()->changeFlags(0);
05078 getVRuler()->repaint();
05079 }
05080 }
05081 }
05082 }
05083 else
05084 {
05085 refreshRuler( kPresenterDoc()->showGuideLines() );
05086 updateRuler();
05087 }
05088 }
05089
05090
05091 void KPrView::slotHRulerDoubleClicked( double ptpos )
05092 {
05093 showParagraphDialog( KoParagDia::PD_TABS, ptpos );
05094 }
05095
05096
05097
05098
05099
05100
05101 void KPrView::slotHRulerDoubleClicked()
05102 {
05103 KoRuler *ruler = getHRuler();
05104
05105 if ( m_canvas && m_canvas->currentTextObjectView() && (ruler->flags() & KoRuler::F_INDENTS) && ruler->doubleClickedIndent() )
05106 formatParagraph();
05107 else
05108 openPageLayoutDia();
05109 }
05110
05111 void KPrView::changeCaseOfText()
05112 {
05113 QPtrList<KoTextFormatInterface> lst = m_canvas->applicableTextInterfaces();
05114 if ( lst.isEmpty() ) return;
05115 QPtrListIterator<KoTextFormatInterface> it( lst );
05116 KoChangeCaseDia *caseDia=new KoChangeCaseDia( this,"change case" );
05117 if(caseDia->exec())
05118 {
05119 KMacroCommand* macroCmd = 0L;
05120 for ( ; it.current() ; ++it )
05121 {
05122 KCommand *cmd = it.current()->setChangeCaseOfTextCommand(caseDia->getTypeOfCase());
05123 if (cmd)
05124 {
05125 if ( !macroCmd )
05126 macroCmd = new KMacroCommand( i18n("Change Case of Text") );
05127 macroCmd->addCommand(cmd);
05128 }
05129 }
05130 if( macroCmd )
05131 m_pKPresenterDoc->addCommand(macroCmd);
05132 }
05133 delete caseDia;
05134 }
05135
05136 void KPrView::editFind()
05137 {
05138 if (!m_searchEntry)
05139 m_searchEntry = new KoSearchContext();
05140 KPrTextView * edit = m_canvas->currentTextObjectView();
05141 bool hasSelection = edit && (edit->kpTextObject())->textObject()->hasSelection();
05142 bool hasCursor = edit != 0;
05143 KoSearchDia dialog( m_canvas, "find", m_searchEntry, hasSelection, hasCursor );
05144
05146 QValueList<KoTextObject *> list;
05147 QPtrList<KoTextObject> list2 = m_pKPresenterDoc->allTextObjects();
05148 QPtrListIterator<KoTextObject> it( list2 );
05149 for ( ; it.current() ; ++it )
05150 list.append(it.current());
05151
05152 if( list.isEmpty() )
05153 return;
05154
05155 if ( dialog.exec() == QDialog::Accepted )
05156 {
05157 delete m_findReplace;
05158 m_findReplace = new KPrFindReplace( this, m_canvas, &dialog, list, edit );
05159 editFindNext();
05160 }
05161 }
05162
05163 void KPrView::editReplace()
05164 {
05165 if (!m_searchEntry)
05166 m_searchEntry = new KoSearchContext();
05167 if (!m_replaceEntry)
05168 m_replaceEntry = new KoSearchContext();
05169
05170 KPrTextView * edit = m_canvas->currentTextObjectView();
05171 bool hasSelection = edit && (edit->kpTextObject())->textObject()->hasSelection();
05172 bool hasCursor = edit != 0;
05173 KoReplaceDia dialog( m_canvas, "replace", m_searchEntry, m_replaceEntry, hasSelection, hasCursor );
05174
05176 QValueList<KoTextObject *> list;
05177 QPtrList<KoTextObject> list2 = m_pKPresenterDoc->allTextObjects();
05178 QPtrListIterator<KoTextObject> it( list2 );
05179 for ( ; it.current() ; ++it )
05180 list.append(it.current());
05181
05182 if( list.isEmpty() )
05183 return;
05184
05185 if ( dialog.exec() == QDialog::Accepted )
05186 {
05187 delete m_findReplace;
05188 m_findReplace = new KPrFindReplace( this, m_canvas, &dialog, list, edit );
05189 editFindNext();
05190 }
05191 }
05192
05193 void KPrView::editFindPrevious()
05194 {
05195 if ( !m_findReplace )
05196 {
05197 editFind();
05198 return;
05199 }
05200 (void) m_findReplace->findPrevious();
05201 }
05202
05203 void KPrView::editFindNext()
05204 {
05205 if ( !m_findReplace )
05206 {
05207 editFind();
05208 return;
05209 }
05210 (void) m_findReplace->findNext();
05211 }
05212
05213 void KPrView::refreshAllVariable()
05214 {
05215 m_pKPresenterDoc->recalcVariables( VT_ALL );
05216 }
05217
05218 void KPrView::changeZoomMenu( int zoom )
05219 {
05220 QStringList lst;
05221 lst << i18n( "Width" );
05222 lst << i18n( "Whole Slide" );
05223
05224 if(zoom>0)
05225 {
05226 QValueList<int> list;
05227 bool ok;
05228 const QStringList itemsList ( actionViewZoom->items() );
05229 QRegExp regexp("(\\d+)");
05230
05231 for (QStringList::ConstIterator it = itemsList.begin() ; it != itemsList.end() ; ++it)
05232 {
05233 regexp.search(*it);
05234 const int val=regexp.cap(1).toInt(&ok);
05235
05236 if(ok && val>9 && list.contains(val)==0)
05237 list.append( val );
05238 }
05239
05240
05241 if(list.contains(zoom)==0)
05242 list.append( zoom );
05243
05244 qHeapSort( list );
05245
05246 for (QValueList<int>::Iterator it = list.begin() ; it != list.end() ; ++it)
05247 lst.append( i18n("%1%").arg(*it) );
05248 }
05249 else
05250 {
05251 lst << i18n("%1%").arg("33");
05252 lst << i18n("%1%").arg("50");
05253 lst << i18n("%1%").arg("75");
05254 lst << i18n("%1%").arg("100");
05255 lst << i18n("%1%").arg("125");
05256 lst << i18n("%1%").arg("150");
05257 lst << i18n("%1%").arg("200");
05258 lst << i18n("%1%").arg("250");
05259 lst << i18n("%1%").arg("350");
05260 lst << i18n("%1%").arg("400");
05261 lst << i18n("%1%").arg("450");
05262 lst << i18n("%1%").arg("500");
05263 }
05264 actionViewZoom->setItems( lst );
05265 }
05266
05267 void KPrView::showZoom( int zoom )
05268 {
05269 QStringList list = actionViewZoom->items();
05270 QString zoomStr( i18n("%1%").arg( zoom ) );
05271 int pos = list.findIndex(zoomStr);
05272 if( pos == -1)
05273 {
05274 changeZoomMenu( zoom );
05275 list = actionViewZoom->items();
05276 }
05277 actionViewZoom->setCurrentItem( list.findIndex(zoomStr) );
05278 }
05279
05280 void KPrView::viewZoom( const QString &s )
05281 {
05282 bool ok=false;
05283 int zoom = 0;
05284 if ( s == i18n("Width") )
05285 {
05286 zoom = qRound( static_cast<double>(m_canvas->visibleRect().width() * 100 ) /
05287 (zoomHandler()->resolutionX() * m_pKPresenterDoc->pageLayout().ptWidth ) );
05288 ok = true;
05289 }
05290 else if ( s == i18n("Whole Slide") )
05291 {
05292 zoom = getZoomEntirePage();
05293 ok = true;
05294 }
05295 else
05296 {
05297 QRegExp regexp("(\\d+)");
05298 regexp.search(s);
05299 zoom=regexp.cap(1).toInt(&ok);
05300 }
05301 if( !ok || zoom<10 )
05302 zoom = zoomHandler()->zoom();
05303 zoom = QMIN( zoom, 4000);
05304
05305 changeZoomMenu( zoom );
05306
05307 showZoom(zoom);
05308
05309 if( zoom != zoomHandler()->zoom() )
05310 {
05311 setZoom( zoom, true );
05312 KPrTextView *edit=m_canvas->currentTextObjectView();
05313 if ( edit )
05314 edit->ensureCursorVisible();
05315 }
05316
05317 m_canvas->setFocus();
05318 m_canvas->repaint();
05319 }
05320
05321 void KPrView::setZoomRect( const KoRect & rect )
05322 {
05323 double height = zoomHandler()->resolutionY() * rect.height();
05324 double width = zoomHandler()->resolutionX() * rect.width();
05325 int zoom = QMIN( qRound( static_cast<double>( m_canvas->visibleRect().height() * 100 ) / height ),
05326 qRound( static_cast<double>( m_canvas->visibleRect().width() * 100 ) / width ) );
05327
05328 m_canvas->setUpdatesEnabled( false );
05329 viewZoom( QString::number( zoom ) );
05330
05331 m_canvas->setToolEditMode( TEM_MOUSE );
05332 m_canvas->scrollTopLeftPoint( zoomHandler()->zoomPoint( rect.topLeft() ) );
05333 m_canvas->setUpdatesEnabled( true );
05334 m_canvas->repaint();
05335 }
05336
05337 void KPrView::setZoom( int zoom, bool updateViews )
05338 {
05339 zoomHandler()->setZoomAndResolution( zoom, KoGlobal::dpiX(),
05340 KoGlobal::dpiY());
05341 m_pKPresenterDoc->newZoomAndResolution(updateViews,false);
05342 m_pKPresenterDoc->updateZoomRuler();
05343
05344 setRanges();
05345
05346 if ( statusBar() )
05347 m_sbZoomLabel->setText( ' ' + QString::number( zoom ) + "% " );
05348 }
05349
05350 void KPrView::slotUpdateScrollBarRanges()
05351 {
05352 setRanges();
05353 }
05354
05355 KoTextZoomHandler *KPrView::zoomHandler() const
05356 {
05357 return m_pKPresenterDoc->zoomHandler();
05358 }
05359
05360 void KPrView::slotViewFormattingChars()
05361 {
05362 m_pKPresenterDoc->setViewFormattingChars(actionViewFormattingChars->isChecked());
05363 m_pKPresenterDoc->layout();
05364 m_pKPresenterDoc->repaint(false);
05365 }
05366
05367 void KPrView::setPageDuration( int _pgNum )
05368 {
05369 if ( kPresenterDoc()->presentationDuration() )
05370 {
05371
05372 *m_presentationDurationList.at( _pgNum ) += m_duration.elapsed();
05373 m_duration.restart();
05374 }
05375 }
05376
05377 void KPrView::openThePresentationDurationDialog()
05378 {
05379 int totalTime = 0;
05380 QStringList presentationDurationStringList;
05381 for ( QValueList<int>::Iterator it = m_presentationDurationList.begin();
05382 it != m_presentationDurationList.end(); ++it ) {
05383 int _time = *it;
05384 QString presentationDurationString = presentationDurationDataFormatChange( _time );
05385 presentationDurationStringList.append( presentationDurationString );
05386 totalTime += _time;
05387 }
05388
05389 QString presentationTotalDurationString = presentationDurationDataFormatChange( totalTime );
05390
05391 delete presDurationDia;
05392 presDurationDia = 0;
05393
05394 presDurationDia = new KPrPresDurationDia( this, "presDurationDia", kPresenterDoc(),
05395 presentationDurationStringList, presentationTotalDurationString );
05396 presDurationDia->setCaption( i18n( "Presentation Duration" ) );
05397 QObject::connect( presDurationDia, SIGNAL( presDurationDiaClosed() ), this, SLOT( pddClosed() ) );
05398 presDurationDia->exec();
05399
05400 delete presDurationDia;
05401 presDurationDia = 0;
05402 }
05403
05404 void KPrView::pddClosed()
05405 {
05406 presDurationDia = 0;
05407 }
05408
05409
05410
05411
05412
05413
05414 QString KPrView::presentationDurationDataFormatChange( int _time )
05415 {
05416 QTime time( 0, 0, 0 );
05417 return KGlobal::locale()->formatTime( time.addMSecs( _time ), true, true );
05418 }
05419
05420
05421 void KPrView::viewFooter()
05422 {
05423 bool state = m_actionExtraFooter->isChecked();
05424 m_canvas->activePage()->setFooter( state );
05425 KPrHideShowHeaderFooter * cmd =new KPrHideShowHeaderFooter( state ? i18n("Enable Document Header") : i18n("Disable Document Header"),
05426 m_pKPresenterDoc, m_canvas->activePage(), state, m_pKPresenterDoc->footer());
05427 m_pKPresenterDoc->addCommand(cmd);
05428
05429 m_pKPresenterDoc->updateSideBarItem( m_pKPresenterDoc->masterPage() );
05430 }
05431
05432 void KPrView::viewHeader()
05433 {
05434 bool state = m_actionExtraHeader->isChecked();
05435 m_canvas->activePage()->setHeader( state );
05436 KPrHideShowHeaderFooter * cmd =new KPrHideShowHeaderFooter( state ? i18n("Enable Document Footer") : i18n("Disable Document Footer"),
05437 m_pKPresenterDoc, m_canvas->activePage(), state, m_pKPresenterDoc->header());
05438 m_pKPresenterDoc->addCommand(cmd);
05439
05440 m_pKPresenterDoc->updateSideBarItem( m_pKPresenterDoc->masterPage() );
05441 }
05442
05443 void KPrView::showStyle( const QString & styleName )
05444 {
05445 KoParagStyle* style = m_pKPresenterDoc->styleCollection()->findStyle( styleName );
05446 if ( style ) {
05447 int pos = m_pKPresenterDoc->styleCollection()->indexOf( style );
05448
05449 actionFormatStyle->setCurrentItem( pos );
05450 }
05451 }
05452
05453 void KPrView::updateStyleList()
05454 {
05455 QString currentStyle = actionFormatStyle->currentText();
05456
05457 const QStringList lst = m_pKPresenterDoc->styleCollection()->displayNameList();
05458 const int pos = lst.findIndex( currentStyle );
05459
05460 actionFormatStyle->setItems( lst );
05461 if ( pos > -1 )
05462 actionFormatStyle->setCurrentItem( pos );
05463
05464
05465
05466 QStringList lstWithAccels;
05467
05468 KAccelGen::generate( lst, lstWithAccels );
05469 QMap<QString, KShortcut> shortCuts;
05470
05471 KActionPtrList lst2 = actionCollection()->actions("styleList");
05472 QValueList<KAction *> actions = lst2;
05473 QValueList<KAction *>::ConstIterator it = lst2.begin();
05474 QValueList<KAction *>::ConstIterator end = lst2.end();
05475 for (; it != end; ++it )
05476 {
05477 shortCuts.insert( QString::fromUtf8( (*it)->name() ), (*it)->shortcut() );
05478 actionFormatStyleMenu->remove( *it );
05479 delete *it;
05480 }
05481
05482
05483 uint i = 0;
05484 for ( QStringList::Iterator it = lstWithAccels.begin(); it != lstWithAccels.end(); ++it, ++i )
05485 {
05486 KoParagStyle *style = m_pKPresenterDoc->styleCollection()->styleAt( i );
05487 if ( style )
05488 {
05489 QString name = "paragstyle_" + style->name();
05490 KToggleAction* act = new KToggleAction( (*it),
05491 shortCuts[name], this, SLOT( slotStyleSelected() ),
05492 actionCollection(), name.utf8() );
05493 act->setGroup( "styleList" );
05494 act->setExclusiveGroup( "styleListAction" );
05495 act->setToolTip( i18n( "Apply a paragraph style" ) );
05496 actionFormatStyleMenu->insert( act );
05497 }
05498 }
05499 bool isText=!m_canvas->applicableTextInterfaces().isEmpty();
05500 actionFormatStyleMenu->setEnabled( isText );
05501 actionFormatStyle->setEnabled(isText);
05502 }
05503
05504 void KPrView::extraStylist()
05505 {
05506 KPrTextView *edit=m_canvas->currentTextObjectView();
05507 QString activeStyleName = QString::null;
05508 if ( edit )
05509 {
05510 edit->hideCursor();
05511 if (edit->cursor() && edit->cursor()->parag() && edit->cursor()->parag()->style())
05512 activeStyleName = edit->cursor()->parag()->style()->displayName();
05513 }
05514 KPrStyleManager * styleManager = new KPrStyleManager( this, m_pKPresenterDoc->unit(), m_pKPresenterDoc,
05515 *m_pKPresenterDoc->styleCollection(), activeStyleName);
05516 styleManager->exec();
05517 delete styleManager;
05518 if ( edit )
05519 edit->showCursor();
05520 }
05521
05522
05523 void KPrView::slotStyleSelected()
05524 {
05525 QString actionName = QString::fromUtf8(sender()->name());
05526 kdDebug(33001) << "KPrView::slotStyleSelected " << actionName << endl;
05527 textStyleSelected( m_pKPresenterDoc->styleCollection()->findStyle( actionName ) );
05528 }
05529
05530 void KPrView::textStyleSelected( int index )
05531 {
05532 textStyleSelected( m_pKPresenterDoc->styleCollection()->styleAt( index ) );
05533 }
05534
05535 void KPrView::textStyleSelected( KoParagStyle *_sty )
05536 {
05537 if ( !_sty )
05538 return;
05539
05540 KPrTextView *edit=m_canvas->currentTextObjectView();
05541 if(edit)
05542 {
05543 edit->applyStyle( _sty );
05544 m_canvas->setFocus();
05545 }
05546 else
05547 {
05548 QPtrList<KPrTextObject> selectedFrames = m_canvas->selectedTextObjs();
05549
05550 if (selectedFrames.count() <= 0)
05551 return;
05552
05553 QPtrListIterator<KPrTextObject> it( selectedFrames );
05554 KMacroCommand *globalCmd = 0L;
05555 for ( ; it.current() ; ++it )
05556 {
05557 KoTextObject *textObject = it.current()->textObject();
05558 textObject->textDocument()->selectAll( KoTextDocument::Temp );
05559 KCommand *cmd = textObject->applyStyleCommand( 0L, _sty,
05560 KoTextDocument::Temp, KoParagLayout::All, KoTextFormat::Format,
05561 true, true );
05562 textObject->textDocument()->removeSelection( KoTextDocument::Temp );
05563 if (cmd)
05564 {
05565 if ( !globalCmd)
05566 globalCmd = new KMacroCommand( selectedFrames.count() == 1 ? i18n("Apply Style to Frame") :
05567 i18n("Apply Style to Frames"));
05568 globalCmd->addCommand( cmd );
05569 }
05570 }
05571 if ( globalCmd )
05572 m_pKPresenterDoc->addCommand( globalCmd );
05573 }
05574
05575 }
05576
05577 void KPrView::slotAllowAutoFormat()
05578 {
05579 bool state = actionAllowAutoFormat->isChecked();
05580 m_pKPresenterDoc->setAllowAutoFormat( state );
05581 }
05582
05583 void KPrView::slotCompletion()
05584 {
05585 KPrTextView *edit=m_canvas->currentTextObjectView();
05586 if(edit)
05587 edit->completion();
05588 }
05589
05590 void KPrView::insertComment()
05591 {
05592 KPrTextView *edit=m_canvas->currentTextObjectView();
05593 if ( !edit )
05594 return;
05595 QString authorName;
05596 KoDocumentInfo * info = m_pKPresenterDoc->documentInfo();
05597 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
05598 if ( !authorPage )
05599 kdWarning() << "Author information not found in documentInfo !" << endl;
05600 else
05601 authorName = authorPage->fullName();
05602
05603 KoCommentDia *commentDia = new KoCommentDia( this, QString::null,authorName );
05604 if( commentDia->exec() )
05605 edit->insertComment(commentDia->commentText());
05606 delete commentDia;
05607 }
05608
05609 void KPrView::editComment()
05610 {
05611 KPrTextView *edit=m_canvas->currentTextObjectView();
05612 if ( edit )
05613 {
05614 KoVariable * tmpVar=edit->variable();
05615 KoNoteVariable * var = dynamic_cast<KoNoteVariable *>(tmpVar);
05616 if(var)
05617 {
05618 QString authorName;
05619 KoDocumentInfo * info = m_pKPresenterDoc->documentInfo();
05620 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
05621 if ( !authorPage )
05622 kdWarning() << "Author information not found in documentInfo !" << endl;
05623 else
05624 authorName = authorPage->fullName();
05625 QString oldValue = var->note();
05626 QString createDate = var->createdNote();
05627 KoCommentDia *commentDia = new KoCommentDia( this, oldValue, authorName, createDate);
05628
05629 if( commentDia->exec() )
05630 {
05631 if ( oldValue != commentDia->commentText())
05632 {
05633 KPrChangeVariableNoteText *cmd = new KPrChangeVariableNoteText( i18n("Change Note Text"), m_pKPresenterDoc, oldValue,commentDia->commentText(), var);
05634 m_pKPresenterDoc->addCommand( cmd );
05635 cmd->execute();
05636 }
05637 }
05638 delete commentDia;
05639 }
05640 }
05641 }
05642
05643 void KPrView::viewGuideLines()
05644 {
05645 bool state=actionViewShowGuideLine->isChecked();
05646 m_pKPresenterDoc->setShowGuideLines( state );
05647 m_pKPresenterDoc->updateGuideLineButton();
05648 deSelectAllObjects();
05649 refreshRuler( state );
05650 m_pKPresenterDoc->repaint(false);
05651 }
05652
05653
05654 void KPrView::viewGrid()
05655 {
05656 m_pKPresenterDoc->setShowGrid( actionViewShowGrid->isChecked() );
05657 m_pKPresenterDoc->setModified( true );
05658 m_pKPresenterDoc->updateGridButton();
05659 m_pKPresenterDoc->repaint(false);
05660 }
05661
05662
05663 void KPrView::updateGuideLineButton()
05664 {
05665 bool state = m_pKPresenterDoc->showGuideLines();
05666 actionViewShowGuideLine->setChecked( state );
05667 refreshRuler( state );
05668 }
05669
05670 void KPrView::updateGridButton()
05671 {
05672 actionViewShowGrid->setChecked( m_pKPresenterDoc->showGrid() );
05673 actionViewSnapToGrid->setChecked ( m_pKPresenterDoc->snapToGrid() );
05674 }
05675
05676 void KPrView::refreshRuler( bool state )
05677 {
05678 if( getHRuler() )
05679 {
05680
05681 if ( !m_pKPresenterDoc->isReadWrite())
05682 {
05683 getHRuler()->changeFlags(KoRuler::F_NORESIZE);
05684 getHRuler()->repaint();
05685 }
05686 else
05687 {
05688 if( state )
05689 {
05690 if( getHRuler()->flags() != KoRuler::F_HELPLINES )
05691 {
05692 getHRuler()->changeFlags(KoRuler::F_HELPLINES);
05693 getHRuler()->repaint();
05694 }
05695 }
05696 else
05697 {
05698 if( getHRuler()->flags() != 0 )
05699 {
05700 getHRuler()->changeFlags( 0 );
05701 getHRuler()->repaint();
05702 }
05703 }
05704 }
05705 }
05706
05707 if( getVRuler())
05708 {
05709 if ( !m_pKPresenterDoc->isReadWrite())
05710 {
05711 getVRuler()->changeFlags(KoRuler::F_NORESIZE);
05712 getVRuler()->repaint();
05713 }
05714 else
05715 {
05716 if( state )
05717 {
05718 if( getVRuler()->flags() != KoRuler::F_HELPLINES )
05719 {
05720 getVRuler()->changeFlags(KoRuler::F_HELPLINES);
05721 getVRuler()->repaint();
05722 }
05723 }
05724 else
05725 {
05726 if( getVRuler()->flags()!= 0)
05727 {
05728 getVRuler()->changeFlags(0);
05729 getVRuler()->repaint();
05730 }
05731 }
05732 }
05733 }
05734
05735 }
05736
05737 void KPrView::addGuideLine()
05738 {
05739 KoRect rect( m_canvas->activePage()->getPageRect() );
05740
05741 KoPoint pos( zoomHandler()->unzoomPoint( m_mousePos + QPoint( m_canvas->diffx(), m_canvas->diffy() ) ) );
05742 KoGuideLineDia dia( 0, pos, rect, m_pKPresenterDoc->unit() );
05743 if ( dia.exec() == QDialog::Accepted )
05744 {
05745 m_pKPresenterDoc->addGuideLine( dia.orientation(), dia.pos() );
05746 }
05747 }
05748
05749 void KPrView::removeComment()
05750 {
05751 KPrTextView *edit=m_canvas->currentTextObjectView();
05752 if ( edit )
05753 edit->removeComment();
05754 }
05755
05756 void KPrView::configureCompletion()
05757 {
05758 m_pKPresenterDoc->getAutoFormat()->readConfig();
05759 KoCompletionDia dia( this, 0, m_pKPresenterDoc->getAutoFormat() );
05760 dia.exec();
05761 }
05762
05763 void KPrView::openPopupMenuZoom( const QPoint & _point )
05764 {
05765 if(!koDocument()->isReadWrite() || !factory())
05766 return;
05767 actionZoomSelectedObject->setEnabled( m_canvas->isOneObjectSelected());
05768 int nbObj = m_canvas->activePage()->objectList().count();
05769 actionZoomAllObject->setEnabled( nbObj > 0);
05770 static_cast<QPopupMenu*>(factory()->container("zoom_popup",this))->popup(_point);
05771 }
05772
05773 void KPrView::zoomMinus()
05774 {
05775
05776 int zoom = zoomHandler()->zoom() - (int)(zoomHandler()->zoom()*0.25);
05777 viewZoom( QString::number(zoom ) );
05778 m_canvas->setToolEditMode( TEM_MOUSE );
05779 }
05780
05781 void KPrView::zoomPageWidth()
05782 {
05783 int zoom = qRound( static_cast<double>(m_canvas->visibleRect().width() * 100 ) /
05784 (zoomHandler()->resolutionX() * m_pKPresenterDoc->pageLayout().ptWidth ) );
05785 viewZoom( QString::number(zoom ) );
05786 m_canvas->setToolEditMode( TEM_MOUSE );
05787 }
05788
05789 void KPrView::zoomEntirePage()
05790 {
05791 viewZoom( QString::number(getZoomEntirePage() ) );
05792 m_canvas->setToolEditMode( TEM_MOUSE );
05793 }
05794
05795 void KPrView::zoomPlus()
05796 {
05797 int zoom = zoomHandler()->zoom() + int( zoomHandler()->zoom() * 0.25 );
05798 viewZoom( QString::number( zoom ) );
05799 m_canvas->setToolEditMode( TEM_MOUSE );
05800 }
05801
05802 int KPrView::getZoomEntirePage() const
05803 {
05804 double height = zoomHandler()->resolutionY() * m_pKPresenterDoc->pageLayout().ptHeight;
05805 double width = zoomHandler()->resolutionX() * m_pKPresenterDoc->pageLayout().ptWidth;
05806 int zoom = QMIN( qRound( static_cast<double>(m_canvas->visibleRect().height() * 100 ) / height ),
05807 qRound( static_cast<double>(m_canvas->visibleRect().width() * 100 ) / width ) );
05808 return zoom;
05809 }
05810
05811 void KPrView::zoomSelectedObject()
05812 {
05813 if( m_canvas->isOneObjectSelected() )
05814 {
05815 KoRect rect = m_canvas->objectRect( false );
05816 setZoomRect( rect );
05817 }
05818 }
05819
05820 void KPrView::zoomPageHeight()
05821 {
05822 int zoom = qRound( static_cast<double>(m_canvas->visibleRect().height() * 100 ) /
05823 (zoomHandler()->resolutionX() * m_pKPresenterDoc->pageLayout().ptHeight ) );
05824 viewZoom( QString::number(zoom ) );
05825 m_canvas->setToolEditMode( TEM_MOUSE );
05826 }
05827
05828 void KPrView::zoomAllObject()
05829 {
05830 KoRect rect = m_canvas->objectRect( true );
05831 double height = zoomHandler()->resolutionY() * rect.height();
05832 double width = zoomHandler()->resolutionX() * rect.width();
05833 int zoom = QMIN( qRound( static_cast<double>(m_canvas->visibleRect().height() * 100 ) / height ),
05834 qRound( static_cast<double>(m_canvas->visibleRect().width() * 100 ) / width ) );
05835 viewZoom( QString::number(zoom ) );
05836
05837 m_canvas->setToolEditMode( TEM_MOUSE );
05838 m_canvas->scrollTopLeftPoint( zoomHandler()->zoomPoint( rect.topLeft()) );
05839 }
05840
05841 void KPrView::flipHorizontal()
05842 {
05843 m_canvas->flipObject( true );
05844 }
05845
05846 void KPrView::flipVertical()
05847 {
05848 m_canvas->flipObject( false );
05849 }
05850
05851 void KPrView::slotObjectEditChanged()
05852 {
05853 bool state=m_canvas->isOneObjectSelected();
05854 bool rw = koDocument()->isReadWrite();
05855
05856 bool isText=!m_canvas->applicableTextInterfaces().isEmpty();
05857 actionTextFont->setEnabled(isText);
05858 actionTextFontSize->setEnabled(isText);
05859 actionTextFontFamily->setEnabled(isText);
05860 actionTextColor->setEnabled(isText);
05861 actionTextAlignLeft->setEnabled(isText);
05862 actionTextAlignCenter->setEnabled(isText);
05863 actionTextAlignRight->setEnabled(isText);
05864 actionTextAlignBlock->setEnabled(isText);
05865
05866 actionFormatBullet->setEnabled(rw && isText );
05867 actionFormatNumber->setEnabled(rw && isText );
05868
05869 actionTextDepthPlus->setEnabled(isText);
05870 actionFormatDefault->setEnabled(isText);
05871 actionTextDepthMinus->setEnabled(isText);
05872
05873 actionTextExtentCont2Height->setEnabled(isText);
05874 actionTextExtendObj2Cont->setEnabled(isText);
05875 actionTextBold->setEnabled(isText);
05876 actionTextItalic->setEnabled(isText);
05877 actionTextUnderline->setEnabled(isText);
05878 actionFormatStrikeOut->setEnabled(isText);
05879 actionFormatSuper->setEnabled(isText);
05880 actionFormatSub->setEnabled(isText);
05881 actionIncreaseFontSize->setEnabled(isText);
05882 actionDecreaseFontSize->setEnabled(isText);
05883
05884 if ( isText )
05885 {
05886 KoTextFormat format =*(m_canvas->applicableTextInterfaces().first()->currentFormat());
05887 showFormat( format );
05888 const KoParagLayout * paragLayout=m_canvas->applicableTextInterfaces().first()->currentParagLayoutFormat();
05889 KoParagCounter counter;
05890 if(paragLayout->counter)
05891 counter = *(paragLayout->counter);
05892 int align = paragLayout->alignment;
05893 if ( align == Qt::AlignAuto )
05894 align = Qt::AlignLeft;
05895 alignChanged( align );
05896 }
05897
05898 KPrTextView *edit=m_canvas->currentTextObjectView();
05899 bool val=(edit!=0) && isText && !edit->kpTextObject()->isProtectContent();
05900 actionInsertSpecialChar->setEnabled(val);
05901 actionInsertComment->setEnabled( val );
05902
05903 actionInsertLink->setEnabled(val);
05904 actionFormatParag->setEnabled(isText);
05905 actionInsertVariable->setEnabled(val);
05906 actionTextInsertPageNum->setEnabled(val);
05907 if ( edit )
05908 actionBrushColor->setEnabled(val);
05909
05910 bool hasSelection = false ;
05911 if(edit)
05912 {
05913 double leftMargin =edit->currentParagLayout().margins[QStyleSheetItem::MarginLeft];
05914 actionTextDepthMinus->setEnabled(val && leftMargin>0);
05915 hasSelection = edit->textObject()->hasSelection();
05916 actionEditCut->setEnabled(hasSelection);
05917 }
05918 actionCreateStyleFromSelection->setEnabled(edit!=0);
05919
05920 actionChangeCase->setEnabled( (val && rw && hasSelection ) || (rw && !edit && isText) );
05921
05922 if(!edit)
05923 {
05924 actionEditCopy->setEnabled(state);
05925 bool headerfooterselected = false;
05926 if(m_canvas->numberOfObjectSelected()==1)
05927 {
05928 KPrObject *obj=m_canvas->getSelectedObj();
05929
05930 if(obj==m_pKPresenterDoc->header() || obj==m_pKPresenterDoc->footer())
05931 headerfooterselected=true;
05932 else
05933 headerfooterselected=false;
05934 }
05935
05936 actionEditCut->setEnabled(state&&!headerfooterselected);
05937 }
05938 actionFormatStyleMenu->setEnabled( isText );
05939 actionFormatStyle->setEnabled(isText);
05940
05941 state=m_canvas->oneObjectTextExist();
05942 actionEditFind->setEnabled(state);
05943 actionEditFindNext->setEnabled( state );
05944 actionEditFindPrevious->setEnabled( state );
05945 actionEditReplace->setEnabled(state);
05946
05947 slotUpdateRuler();
05948 }
05949
05950 void KPrView::duplicateObj()
05951 {
05952 if (m_canvas->currentTextObjectView() && !m_canvas->isOneObjectSelected() )
05953 return;
05954
05955 KPrDuplicatObjDia *dlg= new KPrDuplicatObjDia(this, m_pKPresenterDoc);
05956 if ( dlg->exec() )
05957 {
05958 int nbCopy= dlg->nbCopy();
05959 double angle = dlg->angle();
05960 double increaseX = dlg->increaseX();
05961 double increaseY = dlg->increaseY();
05962 double moveX = dlg->moveX();
05963 double moveY = dlg->moveY();
05964 m_canvas->copyObjs();
05965 m_canvas->setToolEditMode( TEM_MOUSE );
05966 deSelectAllObjects();
05967 QMimeSource *data = QApplication::clipboard()->data();
05968 QCString clip_str = KoStoreDrag::mimeType("application/x-kpresenter");
05969 if ( data->provides( clip_str ) )
05970 {
05971 m_canvas->activePage()->pasteObjs( data->encodedData(clip_str),
05972 nbCopy, angle, increaseX,increaseY, moveX, moveY );
05973 m_canvas->setMouseSelectedObject(true);
05974 emit objectSelectedChanged();
05975 }
05976 }
05977 delete dlg;
05978 }
05979
05980 void KPrView::extraArrangePopup()
05981 {
05982 m_canvas->setToolEditMode( TEM_MOUSE );
05983 QPoint pnt( QCursor::pos() );
05984 m_arrangeObjectsPopup->popup( pnt );
05985 }
05986
05987 void KPrView::extraSendBackward()
05988 {
05989 m_canvas->setToolEditMode( TEM_MOUSE );
05990 m_canvas->lowerObjs( false );
05991 }
05992
05993 void KPrView::extraBringForward()
05994 {
05995 m_canvas->setToolEditMode( TEM_MOUSE );
05996 m_canvas->raiseObjs( false );
05997 }
05998
05999 void KPrView::applyAutoFormat()
06000 {
06001 m_pKPresenterDoc->getAutoFormat()->readConfig();
06002 KMacroCommand *macro = 0L;
06003 m_switchPage=m_pKPresenterDoc->pageList().findRef(m_canvas->activePage());
06004 m_initSwitchPage=m_switchPage;
06005 QPtrList<KoTextObject> list=m_canvas->activePage()->allTextObjects();
06006
06007 KCommand * cmd2 = applyAutoFormatToCurrentPage( list );
06008 if ( cmd2 )
06009 {
06010 if ( !macro )
06011 macro = new KMacroCommand( i18n("Apply Autoformat"));
06012 macro->addCommand( cmd2 );
06013 }
06014
06015 while(switchInOtherPage(i18n( "Do you want to apply autoformat in new slide?")) )
06016 {
06017 KCommand * cmd = applyAutoFormatToCurrentPage(m_canvas->activePage()->allTextObjects());
06018 if ( cmd )
06019 {
06020 if ( !macro )
06021 macro = new KMacroCommand( i18n("Apply Autoformat"));
06022 macro->addCommand( cmd );
06023 }
06024 }
06025 if ( macro )
06026 m_pKPresenterDoc->addCommand(macro);
06027 m_switchPage=-1;
06028 m_initSwitchPage=-1;
06029 }
06030
06031 bool KPrView::switchInOtherPage( const QString & text )
06032 {
06033
06034 if(m_pKPresenterDoc->pageList().count()==1)
06035 return false;
06036 m_switchPage++;
06037 if( m_switchPage>=(int)m_pKPresenterDoc->pageList().count())
06038 m_switchPage=0;
06039 if( m_switchPage==m_initSwitchPage)
06040 return false;
06041 if ( KMessageBox::questionYesNo( this, text) != KMessageBox::Yes )
06042 return false;
06043 skipToPage(m_switchPage);
06044 return true;
06045 }
06046
06047 KCommand * KPrView::applyAutoFormatToCurrentPage( const QPtrList<KoTextObject> & lst)
06048 {
06049 KMacroCommand *macro = 0L;
06050 QPtrList<KoTextObject> list(lst);
06051 QPtrListIterator<KoTextObject> fit(list);
06052 for ( ; fit.current() ; ++fit )
06053 {
06054 KCommand *cmd = m_pKPresenterDoc->getAutoFormat()->applyAutoFormat( fit.current() );
06055 if ( cmd )
06056 {
06057 if ( !macro )
06058 macro = new KMacroCommand( i18n("Apply Autoformat"));
06059 macro->addCommand( cmd );
06060 }
06061 }
06062 return macro;
06063 }
06064
06065 void KPrView::createStyleFromSelection()
06066 {
06067 KPrTextView *edit=m_canvas->currentTextObjectView();
06068 if ( edit )
06069 {
06070 KoStyleCollection* coll = m_pKPresenterDoc->styleCollection();
06071 KoCreateStyleDia *dia = new KoCreateStyleDia( QStringList(), this, 0 );
06072 if ( dia->exec() )
06073 {
06074 QString name = dia->nameOfNewStyle();
06075 KoParagStyle* style = coll->findStyleByDisplayName( name );
06076 if ( style )
06077 {
06078
06079 edit->updateStyleFromSelection( style );
06080 }
06081 else
06082 {
06083 style = edit->createStyleFromSelection( name );
06084 m_pKPresenterDoc->styleCollection()->addStyle( style );
06085 m_pKPresenterDoc->updateAllStyleLists();
06086 }
06087 showStyle( name );
06088 }
06089 delete dia;
06090 }
06091 }
06092
06093 void KPrView::closeObject()
06094 {
06095 m_canvas->closeObject(true);
06096 }
06097
06098 void KPrView::viewSnapToGrid()
06099 {
06100 m_pKPresenterDoc->setSnapToGrid( actionViewSnapToGrid->isChecked() );
06101 m_pKPresenterDoc->setModified( true );
06102 m_pKPresenterDoc->updateGridButton();
06103 }
06104
06105 void KPrView::alignVerticalTop()
06106 {
06107 if ( actionAlignVerticalTop->isChecked() )
06108 m_canvas->alignVertical(KP_TOP );
06109 else
06110 actionAlignVerticalTop->setChecked(true);
06111 }
06112
06113 void KPrView::alignVerticalBottom()
06114 {
06115 if ( actionAlignVerticalBottom->isChecked() )
06116 m_canvas->alignVertical(KP_BOTTOM );
06117 else
06118 actionAlignVerticalBottom->setChecked(true);
06119 }
06120
06121 void KPrView::alignVerticalCenter()
06122 {
06123 if ( actionAlignVerticalCenter->isChecked() )
06124 m_canvas->alignVertical(KP_CENTER );
06125 else
06126 actionAlignVerticalCenter->setChecked(true);
06127 }
06128
06129 void KPrView::changeVerticalAlignmentStatus(VerticalAlignmentType _type )
06130 {
06131 switch( _type )
06132 {
06133 case KP_CENTER:
06134 actionAlignVerticalCenter->setChecked( true );
06135 break;
06136 case KP_TOP:
06137 actionAlignVerticalTop->setChecked( true );
06138 break;
06139 case KP_BOTTOM:
06140 actionAlignVerticalBottom->setChecked( true );
06141 break;
06142 }
06143 }
06144
06145 void KPrView::autoSpellCheck()
06146 {
06147 m_pKPresenterDoc->changeBgSpellCheckingState( actionAllowBgSpellCheck->isChecked() );
06148 }
06149
06150 void KPrView::insertFile( )
06151 {
06152 KFileDialog fd( QString::null, QString::null, this, 0, TRUE );
06153 QStringList filter;
06154 filter<<"application/x-kpresenter";
06155 filter<<"application/vnd.oasis.opendocument.presentation";
06156 fd.setMimeFilter( filter );
06157 fd.setCaption(i18n("Insert File"));
06158
06159 KURL url;
06160 if ( fd.exec() == QDialog::Accepted )
06161 {
06162 url = fd.selectedURL();
06163 if( url.isEmpty() )
06164 {
06165 KMessageBox::sorry( this,
06166 i18n("File name is empty."),
06167 i18n("Insert File"));
06168 return;
06169 }
06170 insertFile(url.path());
06171 }
06172 }
06173
06174 void KPrView::insertFile(const QString &path)
06175 {
06176 m_pKPresenterDoc->insertFile(path);
06177 }
06178
06179 void KPrView::importStyle()
06180 {
06181 KPrImportStyleDia dia( m_pKPresenterDoc, m_pKPresenterDoc->styleCollection(), this );
06182 if ( dia.exec() && !dia.importedStyles().isEmpty() ) {
06183 m_pKPresenterDoc->styleCollection()->importStyles( dia.importedStyles() );
06184 m_pKPresenterDoc->setModified( true );
06185 m_pKPresenterDoc->updateAllStyleLists();
06186 }
06187 }
06188
06189 void KPrView::backgroundPicture()
06190 {
06191 switch( m_canvas->activePage()->getBackType())
06192 {
06193 case BT_COLOR:
06194 case BT_BRUSH:
06195 break;
06196 case BT_CLIPART:
06197 case BT_PICTURE:
06198 KoPicture picture=m_canvas->activePage()->background()->picture();
06199 savePicture(picture.getKey().filename(), picture);
06200 break;
06201 }
06202 }
06203
06204 void KPrView::testAndCloseAllTextObjectProtectedContent()
06205 {
06206 KPrTextView *edit=m_canvas->currentTextObjectView();
06207 if ( edit && edit->kpTextObject()->isProtectContent())
06208 {
06209 m_canvas->setToolEditMode( TEM_MOUSE );
06210 deSelectAllObjects();
06211 }
06212 }
06213
06214 void KPrView::updateBgSpellCheckingState()
06215 {
06216 actionAllowBgSpellCheck->setChecked( m_pKPresenterDoc->backgroundSpellCheckEnabled() );
06217 }
06218
06219 void KPrView::updateRulerInProtectContentMode()
06220 {
06221 KPrTextView *edit=m_canvas->currentTextObjectView();
06222 if ( edit && getHRuler()) {
06223 if ( !edit->kpTextObject()->isProtectContent() )
06224 getHRuler()->changeFlags(KoRuler::F_INDENTS | KoRuler::F_TABS);
06225 else
06226 getHRuler()->changeFlags(0);
06227 getHRuler()->repaint();
06228 }
06229 }
06230
06231 void KPrView::slotChangeCutState(bool b)
06232 {
06233 KPrTextView *edit=m_canvas->currentTextObjectView();
06234
06235 if ( edit && edit->kpTextObject()->isProtectContent())
06236 actionEditCut->setEnabled( false );
06237 else
06238 actionEditCut->setEnabled( b );
06239 }
06240
06241 void KPrView::updatePresentationButton(bool b)
06242 {
06243 actionScreenStart->setEnabled( b );
06244 }
06245
06246 void KPrView::refreshGroupButton()
06247 {
06248 bool state=m_canvas->isOneObjectSelected();
06249 actionExtraGroup->setEnabled(state && m_canvas->numberOfObjectSelected()>1);
06250 actionExtraUnGroup->setEnabled(state && m_canvas->haveASelectedGroupObj());
06251 }
06252
06253 void KPrView::closeTextObject()
06254 {
06255 KPrTextView *edit=m_canvas->currentTextObjectView();
06256 if ( edit)
06257 {
06258 m_canvas->setToolEditMode( TEM_MOUSE );
06259 deSelectAllObjects();
06260 }
06261 }
06262
06263 void KPrView::deSelectAllObjects()
06264 {
06265 m_canvas->deSelectAllObj();
06266 }
06267
06268 void KPrView::copyLink()
06269 {
06270 KPrTextView *edit=m_canvas->currentTextObjectView();
06271 if ( edit )
06272 edit->copyLink();
06273 }
06274
06275 void KPrView::addToBookmark()
06276 {
06277 KPrTextView *edit=m_canvas->currentTextObjectView();
06278 if ( edit )
06279 {
06280 KoLinkVariable * var=edit->linkVariable();
06281 if(var)
06282 edit->addBookmarks(var->url());
06283 }
06284 }
06285
06286 void KPrView::removeLink()
06287 {
06288 KPrTextView *edit=m_canvas->currentTextObjectView();
06289 if ( edit )
06290 edit->removeLink();
06291 }
06292
06293 void KPrView::insertDirectCursor()
06294 {
06295 #if 0
06296 insertDirectCursor( actionInsertDirectCursor->isChecked());
06297 #endif
06298 }
06299
06300 void KPrView::insertDirectCursor(bool b)
06301 {
06302 m_pKPresenterDoc->setInsertDirectCursor(b);
06303 }
06304
06305 void KPrView::updateDirectCursorButton()
06306 {
06307 #if 0
06308 actionInsertDirectCursor->setChecked(m_pKPresenterDoc->insertDirectCursor());
06309 #endif
06310 }
06311
06312 void KPrView::copyTextOfComment()
06313 {
06314 KPrTextView *edit=m_canvas->currentTextObjectView();
06315 if ( edit )
06316 edit->copyTextOfComment();
06317 }
06318
06319 void KPrView::slotAddIgnoreAllWord()
06320 {
06321 KPrTextView *edit=m_canvas->currentTextObjectView();
06322 if ( edit )
06323 m_pKPresenterDoc->addSpellCheckIgnoreWord( edit->currentWordOrSelection() );
06324 }
06325
06326 void KPrView::addWordToDictionary()
06327 {
06328 KPrTextView* edit = m_canvas->currentTextObjectView();
06329 if ( edit )
06330 {
06331 QString word = edit->wordUnderCursor( *edit->cursor() );
06332 if ( !word.isEmpty() )
06333 m_pKPresenterDoc->addWordToDictionary( word );
06334 }
06335 }
06336
06337 void KPrView::imageEffect()
06338 {
06339 if (m_canvas->numberOfObjectSelected() > 0) {
06340 imageEffectDia = new KPrImageEffectDia(this);
06341
06342 KPrPixmapObject *object=m_canvas->getSelectedImage();
06343
06344 imageEffectDia->setPixmap(object->getOriginalPixmap());
06345 imageEffectDia->setEffect(object->getImageEffect(), object->getIEParam1(), object->getIEParam2(),
06346 object->getIEParam3());
06347
06348 m_canvas->setToolEditMode(TEM_MOUSE);
06349
06350 if (imageEffectDia->exec()==QDialog::Accepted) {
06351 KCommand *cmd=m_canvas->activePage()->setImageEffect(imageEffectDia->getEffect(), imageEffectDia->getParam1(),
06352 imageEffectDia->getParam2(), imageEffectDia->getParam3());
06353 if ( cmd )
06354 kPresenterDoc()->addCommand( cmd );
06355 }
06356
06357 delete imageEffectDia;
06358 imageEffectDia = 0L;
06359 }
06360 }
06361
06362 void KPrView::spellAddAutoCorrect (const QString & originalword, const QString & newword)
06363 {
06364 m_pKPresenterDoc->getAutoFormat()->addAutoFormatEntry( originalword, newword );
06365 }
06366
06367 QPtrList<KAction> KPrView::listOfResultOfCheckWord( const QString &word )
06368 {
06369 QPtrList<KAction> listAction;
06370 DefaultDictionary *dict = m_broker->defaultDictionary();
06371 QStringList lst = dict->suggest( word );
06372 if ( !lst.contains( word ))
06373 {
06374 QStringList::ConstIterator it = lst.begin();
06375 for ( int i = 0; it != lst.end() ; ++it, ++i )
06376 {
06377 if ( !(*it).isEmpty() )
06378 {
06379 KAction * act = new KAction( (*it));
06380 connect( act, SIGNAL(activated()), this, SLOT(slotCorrectWord()) );
06381 listAction.append( act );
06382 }
06383 }
06384 }
06385
06386 return listAction;
06387 }
06388
06389 void KPrView::slotCorrectWord()
06390 {
06391 KAction * act = (KAction *)(sender());
06392 KPrTextView* edit = m_canvas->currentTextObjectView();
06393 if ( edit )
06394 {
06395 edit->selectWordUnderCursor( *(edit->cursor()) );
06396 m_pKPresenterDoc->addCommand(edit->textObject()->replaceSelectionCommand(
06397 edit->cursor(), act->text(),
06398 i18n("Replace Word"), KoTextDocument::Standard));
06399 }
06400 }
06401
06402 KCommand * KPrView::getPenCmd( const QString &name, KoPen pen, LineEnd lb, LineEnd le, int flags )
06403 {
06404 KMacroCommand * macro = NULL;
06405
06406
06407 KCommand * cmd = m_canvas->activePage()->setPen( pen, lb, le, flags );
06408 if( cmd )
06409 {
06410 macro = new KMacroCommand( name );
06411 macro->addCommand( cmd );
06412 }
06413
06414 return macro;
06415 }
06416
06417 void KPrView::initialLayoutOfSplitter()
06418 {
06419 if( !notebar )
06420 {
06421 return;
06422 }
06423
06424 QSplitter* splitterVertical = static_cast<QSplitter*>( notebar->parent() );
06425 QValueList<int> tmpList;
06426 int noteHeight = height() / 25;
06427 tmpList << height() - noteHeight << noteHeight;
06428 splitterVertical->setSizes( tmpList );
06429 }
06430
06431 void KPrView::slotChildActivated(bool a)
06432 {
06433 KoViewChild* ch = child( (KoView*)sender() );
06434 if ( !ch )
06435 return;
06436
06437 if( !a ) {
06438 m_canvas->exitEditMode();
06439 }
06440
06441 KoView::slotChildActivated( a );
06442 }
06443
06444 Broker *KPrView::broker() const
06445 {
06446 return m_broker;
06447 }
06448
06449 void KPrView::slotUnitChanged( KoUnit::Unit unit )
06450 {
06451 h_ruler->setUnit( unit );
06452 v_ruler->setUnit( unit );
06453 if ( statusBar() )
06454 {
06455 m_sbUnitLabel->setText( ' ' + KoUnit::unitDescription( unit ) + ' ' );
06456 updateObjectStatusBarItem();
06457 }
06458 }
06459
06460 void KPrView::documentModified( bool b )
06461 {
06462 if ( !statusBar() )
06463 return;
06464
06465 if ( b )
06466 m_sbModifiedLabel->setPixmap( KGlobal::iconLoader()->loadIcon( "action-modified", KIcon::Small ) );
06467 else
06468 m_sbModifiedLabel->setText( " " );
06469 }
06470
06471 void KPrView::loadingFinished()
06472 {
06473 h_ruler->setPageLayout(m_pKPresenterDoc->pageLayout());
06474 v_ruler->setPageLayout(m_pKPresenterDoc->pageLayout());
06475 slotUpdateRuler();
06476 m_pKPresenterDoc->updateZoomRuler();
06477 updateSideBar();
06478 }
06479
06480 #include "KPrView.moc"