00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #undef Unsorted
00023
00024 #include "KWView.h"
00025
00026 #include "KWordViewIface.h"
00027 #include "KWConfigFootNoteDia.h"
00028 #include "defs.h"
00029 #include "KWDeleteDia.h"
00030 #include "KWDocStruct.h"
00031 #include "KWFootNoteDia.h"
00032 #include "KWInsertDia.h"
00033 #include "KWAnchor.h"
00034 #include "KoTextBookmark.h"
00035 #include "KWCanvas.h"
00036 #include "KWCommand.h"
00037 #include "KWConfig.h"
00038 #include "KWCreateBookmarkDia.h"
00039 #include "KWDocument.h"
00040 #include "KWEditPersonnalExpression.h"
00041 #include "KWFormulaFrameSet.h"
00042 #include "KWFrame.h"
00043 #include "KWPictureFrameSet.h"
00044 #include "KWFrameStyle.h"
00045 #include "KWFrameStyleManager.h"
00046 #include "KWImportStyleDia.h"
00047 #include "KWInsertPageDia.h"
00048 #include "KWInsertPicDia.h"
00049 #include "KWPartFrameSet.h"
00050 #include "KWStyleManager.h"
00051 #include "KWTableFrameSet.h"
00052 #include "KWTableStyle.h"
00053 #include "KWTableStyleManager.h"
00054 #include "KWTextDocument.h"
00055 #include "KWVariable.h"
00056 #include "KWViewMode.h"
00057 #include "KWMailMergeDataBase.h"
00058 #include "KWMailMergeLabelAction.h"
00059 #include "KWResizeTableDia.h"
00060 #include "KWFindReplace.h"
00061 #include "KWSortDia.h"
00062 #include "KWSplitCellDia.h"
00063 #include "KWTableDia.h"
00064 #include "KWCollectFramesetsVisitor.h"
00065 #include "KWOasisLoader.h"
00066 #include "KWOasisSaver.h"
00067 #include "KWFrameList.h"
00068 #include "KWPageManager.h"
00069 #include "KWPage.h"
00070 #include "KWFrameViewManager.h"
00071 #include "KWFrameView.h"
00072 #include "KWStatisticsDialog.h"
00073
00074 #include <kformuladocument.h>
00075 #include <kformulamimesource.h>
00076
00077 #include <KoRichText.h>
00078 #include <KoAutoFormat.h>
00079 #include <KoAutoFormatDia.h>
00080 #include <KoChangeCaseDia.h>
00081 #include <KoCharSelectDia.h>
00082 #include <KoCommentDia.h>
00083 #include <KoCreateStyleDia.h>
00084 #include <KoDocumentInfo.h>
00085 #include <KoFontDia.h>
00086 #include <KoFrame.h>
00087 #include <KoInsertLink.h>
00088 #include <KoMainWindow.h>
00089 #include <KoParagDia.h>
00090 #include <KoPartSelectAction.h>
00091 #include <KoPictureFilePreview.h>
00092 #include <KoSearchDia.h>
00093 #include <KoStore.h>
00094 #include <KoStoreDrag.h>
00095 #include <KoTemplateCreateDia.h>
00096 #include <KoCompletionDia.h>
00097 #include <KoVariable.h>
00098 #include <KoCustomVariablesDia.h>
00099 #include <KoTextObject.h>
00100 #include <tkcoloractions.h>
00101 #include <KoSpeaker.h>
00102
00103 #include <kparts/partmanager.h>
00104 #include <kaccelgen.h>
00105 #include <kcolordialog.h>
00106 #include <kdebug.h>
00107 #include <kfiledialog.h>
00108 #include <kimageio.h>
00109 #include <kinputdialog.h>
00110 #include <kio/netaccess.h>
00111 #include <kmessagebox.h>
00112 #include <kparts/event.h>
00113 #include <kstandarddirs.h>
00114 #include <kstatusbar.h>
00115 #include <kstdaccel.h>
00116 #include <kstdaction.h>
00117 #include <ktempfile.h>
00118 #include <kurldrag.h>
00119 #include <kdeversion.h>
00120 #include <kiconloader.h>
00121
00122 #include <qclipboard.h>
00123 #include <qapplication.h>
00124 #include <qgroupbox.h>
00125 #include <qlayout.h>
00126 #include <qpaintdevicemetrics.h>
00127 #include <qprogressdialog.h>
00128 #include <qregexp.h>
00129 #include <qtimer.h>
00130 #include <qbuffer.h>
00131
00132 #include <stdlib.h>
00133
00134 #include <kspell2/dialog.h>
00135 #include <kspell2/defaultdictionary.h>
00136 #include "KoSpell.h"
00137
00138 using namespace KSpell2;
00139
00140
00141
00142
00143 class TableInfo {
00144 public:
00145 TableInfo( const QValueList<KWFrameView*>& selectedFrames ) {
00146 m_protectContent = false;
00147
00148 int amountSelected = 0;
00149 m_cell = 0;
00150 QMap<KWTableFrameSet*, QValueList<unsigned int> > tableRows, tableCols;
00151
00152 QValueList<KWFrameView*>::const_iterator framesIterator = selectedFrames.begin();
00153 for(;framesIterator != selectedFrames.end(); ++framesIterator) {
00154 KWFrameView *view = *framesIterator;
00155 if(!view->selected()) continue;
00156 KWFrameSet *fs = view->frame()->frameSet();
00157 Q_ASSERT(fs);
00158 KWTableFrameSet::Cell *cell = dynamic_cast<KWTableFrameSet::Cell*>(fs);
00159 if(cell == 0) continue;
00160 amountSelected++;
00161 if(cell->protectContent())
00162 m_protectContent=true;
00163
00164 if(! tableRows.contains(fs->groupmanager())) {
00165 QValueList<unsigned int> rows;
00166 for(unsigned int i=fs->groupmanager()->getRows(); i != 0; i--)
00167 rows.append(0);
00168 tableRows.insert(fs->groupmanager(), rows);
00169 QValueList<unsigned int> cols;
00170 for(unsigned int i=fs->groupmanager()->getColumns(); i != 0; i--)
00171 cols.append(0);
00172 tableCols.insert(fs->groupmanager(), cols);
00173 }
00174 QValueList<unsigned int> rows = tableRows[fs->groupmanager()];
00175 for(unsigned int r=cell->firstRow(); r <= cell->lastRow(); r++)
00176 rows[r] = rows[r] + 1;
00177 tableRows[fs->groupmanager()] = rows;
00178 QValueList<unsigned int> columns = tableCols[fs->groupmanager()];
00179 for(unsigned int c=cell->firstColumn(); c <= cell->lastColumn(); c++)
00180 columns[c] = columns[c] + 1;
00181 tableCols[fs->groupmanager()] = columns;
00182
00183 if(m_cell == 0 || m_cell->firstRow() > cell->firstRow() ||
00184 m_cell->firstRow() == cell->firstRow() &&
00185 m_cell->firstColumn() > cell->firstColumn())
00186 m_cell = cell;
00187 }
00188
00189 m_selected = amountSelected != 0;
00190 m_oneCellSelected = amountSelected == 1;
00191 if(amountSelected == 0) return;
00192
00193 for(QMapIterator<KWTableFrameSet*, QValueList<unsigned int> > iter = tableRows.begin();
00194 iter != tableRows.end(); ++iter) {
00195 QValueList<unsigned int> rows = iter.data();
00196 QValueListIterator<unsigned int> rowsIter = rows.begin();
00197 for(int x=0;rowsIter != rows.end(); ++rowsIter, x++)
00198 if(*rowsIter == iter.key()->getColumns())
00199 m_rows.append(x);
00200
00201 QValueList<unsigned int> columns = tableCols[iter.key()];
00202 QValueListIterator<unsigned int> colsIter = columns.begin();
00203 for(int x=0;colsIter != columns.end(); ++colsIter, x++)
00204 if(*colsIter == iter.key()->getRows())
00205 m_columns.append(x);
00206 }
00207 }
00208
00209 int tableCellsSelected() { return m_selected; }
00210 int amountRowsSelected() { return m_rows.count(); }
00211 int amountColumnsSelected() { return m_columns.count(); }
00212 bool oneCellSelected() { return m_oneCellSelected; }
00213 bool protectContentEnabled() { return m_protectContent; }
00214 QValueList<uint> selectedRows() { return m_rows; }
00215 QValueList<uint> selectedColumns() { return m_columns; }
00216 KWTableFrameSet::Cell *firstSelectedCell() { return m_cell; }
00217 private:
00218
00219 bool m_oneCellSelected, m_selected, m_protectContent;
00220 QValueList<uint> m_rows, m_columns;
00221 KWTableFrameSet::Cell *m_cell;
00222 };
00223
00224
00225
00226
00227 KWView::KWView( const QString& viewMode, QWidget *parent, const char *name, KWDocument* doc )
00228 : KoView( doc, parent, name )
00229 {
00230 m_doc = doc;
00231 m_gui = 0;
00232
00233 m_dcop = 0;
00234 dcopObject();
00235 m_fsInline=0;
00236 m_spell.kospell = 0;
00237 m_spell.dlg = 0;
00238 m_broker = Broker::openBroker( KSharedConfig::openConfig( "kwordrc" ) );
00239 m_spell.macroCmdSpellCheck=0L;
00240 m_spell.textIterator = 0L;
00241 m_currentPage = m_doc->pageManager()->page(m_doc->startPage());
00242 m_specialCharDlg=0L;
00243 m_searchEntry = 0L;
00244 m_replaceEntry = 0L;
00245 m_findReplace = 0L;
00246 m_fontDlg = 0L;
00247 m_paragDlg = 0L;
00248 m_tableSplit.columns = 1;
00249 m_tableSplit.rows = 1;
00250
00251 m_actionList.setAutoDelete( true );
00252 m_variableActionList.setAutoDelete( true );
00253
00254 m_zoomViewModeNormal.m_zoom = m_doc->zoom();
00255 m_zoomViewModeNormal.m_zoomMode = m_doc->zoomMode();
00256 m_zoomViewModePreview.m_zoom = 33;
00257 m_zoomViewModePreview.m_zoomMode = KoZoomMode::ZOOM_CONSTANT;
00258
00259 m_viewFrameBorders = m_doc->viewFrameBorders();
00260 KoView::setZoom( m_doc->zoomedResolutionY() );
00261
00262
00263 setInstance( KWFactory::instance() );
00264 if ( !m_doc->isReadWrite() )
00265 setXMLFile( "kword_readonly.rc" );
00266 else
00267 setXMLFile( "kword.rc" );
00268
00269
00270 QObject::connect( this, SIGNAL( embeddImage( const QString & ) ),
00271 this, SLOT( slotEmbedImage( const QString & ) ) );
00272
00273 setKeyCompression( TRUE );
00274 setAcceptDrops( TRUE );
00275
00276 setupActions();
00277
00278 m_gui = new KWGUI( viewMode, this, this );
00279 m_gui->setGeometry( 0, 0, width(), height() );
00280 m_gui->show();
00281
00282 m_sbPageLabel = 0;
00283 m_sbModifiedLabel = 0;
00284 m_sbFramesLabel = 0;
00285 m_sbOverwriteLabel = 0;
00286 m_sbZoomLabel = 0;
00287 m_sbUnitLabel = 0;
00288 if ( KStatusBar* sb = statusBar() )
00289 {
00290 m_sbPageLabel = new KStatusBarLabel( QString::null, 0, sb );
00291 m_sbPageLabel->setAlignment( AlignLeft | AlignVCenter );
00292 addStatusBarItem( m_sbPageLabel, 0 );
00293
00294 m_sbModifiedLabel = new KStatusBarLabel( " ", 0, sb );
00295 m_sbModifiedLabel->setAlignment( AlignLeft | AlignVCenter );
00296 addStatusBarItem( m_sbModifiedLabel, 0 );
00297
00298 m_sbFramesLabel = new KStatusBarLabel( QString::null, 0, sb );
00299 m_sbFramesLabel->setAlignment( AlignLeft | AlignVCenter );
00300 addStatusBarItem( m_sbFramesLabel, 1 );
00301
00302 m_sbOverwriteLabel = new KStatusBarLabel( ' ' + i18n( "INSRT" ) + ' ', 0, sb );
00303 m_sbOverwriteLabel->setAlignment( AlignHCenter | AlignVCenter );
00304 addStatusBarItem( m_sbOverwriteLabel, 0 );
00305
00306 m_sbZoomLabel = new KStatusBarLabel( ' ' + QString::number( m_doc->zoom() ) + "% ", 0, sb );
00307 m_sbZoomLabel->setAlignment( AlignHCenter | AlignVCenter );
00308 addStatusBarItem( m_sbZoomLabel, 0 );
00309
00310 m_sbUnitLabel = new KStatusBarLabel( ' ' + KoUnit::unitDescription( m_doc->unit() ) + ' ', 0, sb );
00311 m_sbUnitLabel->setAlignment( AlignHCenter | AlignVCenter );
00312 addStatusBarItem( m_sbUnitLabel, 0 );
00313 }
00314
00315 connect( m_doc, SIGNAL( modified( bool ) ),
00316 this, SLOT( documentModified( bool )) );
00317
00318 connect( m_doc, SIGNAL( numPagesChanged() ),
00319 this, SLOT( numPagesChanged()) );
00320
00321 connect( m_doc, SIGNAL( pageLayoutChanged( const KoPageLayout& ) ),
00322 this, SLOT( slotPageLayoutChanged( const KoPageLayout& )) );
00323
00324 connect( m_doc, SIGNAL( docStructureChanged(int) ),
00325 this, SLOT( docStructChanged(int)) );
00326
00327 connect( m_doc, SIGNAL( unitChanged(KoUnit::Unit) ),
00328 this, SLOT( slotUnitChanged(KoUnit::Unit) ) );
00329
00330 connect( m_doc, SIGNAL( sig_refreshMenuCustomVariable()),
00331 this, SLOT( refreshCustomMenu()));
00332
00333 connect( m_doc, SIGNAL( completed() ),
00334 this, SLOT( slotDocumentLoadingCompleted() ) );
00335
00336 connect( frameViewManager(), SIGNAL(sigFrameSelectionChanged()),
00337 this, SLOT( frameSelectedChanged()));
00338
00339 connect( frameViewManager(), SIGNAL(sigFrameSetRenamed()),
00340 this, SLOT( updateFrameStatusBarItem()));
00341
00342 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
00343 this, SLOT( clipboardDataChanged() ) );
00344
00345 connect( m_gui->canvasWidget(), SIGNAL(currentFrameSetEditChanged()),
00346 this, SLOT(slotFrameSetEditChanged()) );
00347
00348 connect( m_gui->canvasWidget(), SIGNAL( currentMouseModeChanged(int) ),
00349 this, SLOT( showMouseMode(int) ) );
00350
00351 connect( m_gui->canvasWidget(), SIGNAL( overwriteModeChanged( bool ) ),
00352 this, SLOT( changeOverwriteMode( bool ) ) );
00353
00354
00355 if ( m_doc->isReadWrite() )
00356 {
00357 connect( m_gui->canvasWidget(), SIGNAL(selectionChanged(bool)),
00358 this, SLOT(slotChangeCutState(bool )) );
00359 connect (m_gui->canvasWidget(), SIGNAL(selectionChanged(bool)),
00360 this, SLOT(slotChangeCaseState(bool )));
00361 }
00362 else
00363 {
00364 m_actionEditCut->setEnabled( false );
00365 m_actionChangeCase->setEnabled( false );
00366 }
00367
00368 connect( m_gui->canvasWidget(), SIGNAL(selectionChanged(bool)),
00369 m_actionEditCopy, SLOT(setEnabled(bool)) );
00370
00371
00372
00373
00374 connect (m_gui->canvasWidget(), SIGNAL(selectionChanged(bool)),
00375 m_actionConvertToTextBox, SLOT(setEnabled(bool)));
00376 connect (m_gui->canvasWidget(), SIGNAL(selectionChanged(bool)),
00377 m_actionAddPersonalExpression, SLOT(setEnabled(bool )));
00378 connect (m_gui->canvasWidget(), SIGNAL(selectionChanged(bool)),
00379 m_actionSortText, SLOT(setEnabled(bool )));
00380
00381 connect( m_gui->canvasWidget(), SIGNAL(docStructChanged(int)),
00382 this, SLOT(docStructChanged(int)));
00383
00384 connect( m_gui->canvasWidget(), SIGNAL(updateRuler()),
00385 this, SLOT(slotUpdateRuler()));
00386
00387 if ( shell() )
00388 {
00389 connect( shell(), SIGNAL( documentSaved()), m_doc,SLOT(slotDocumentInfoModifed() ) );
00390 changeNbOfRecentFiles( m_doc->maxRecentFiles() );
00391 }
00392
00393 m_gui->canvasWidget()->updateCurrentFormat();
00394 setFocusProxy( m_gui->canvasWidget() );
00395
00396
00397
00398 if(!m_doc->isReadWrite())
00399 {
00400 setZoom( 100, true );
00401 slotUpdateRuler();
00402 initGui();
00403 }
00404
00405
00406
00407
00408 QTimer::singleShot( 0, this, SLOT( slotSetInitialPosition() ) );
00409 QTimer::singleShot( 0, this, SLOT( updateZoom() ) );
00410 }
00411
00412 KWView::~KWView()
00413 {
00414 delete m_tableActionList.first();
00415 clearSpellChecker();
00416
00417 delete m_searchEntry;
00418 m_searchEntry = 0L;
00419 delete m_replaceEntry;
00420 m_replaceEntry = 0L;
00421 if ( m_specialCharDlg )
00422 m_specialCharDlg->closeDialog();
00423
00424
00425 delete m_findReplace;
00426
00427 delete m_gui;
00428 delete m_sbPageLabel;
00429 delete m_sbFramesLabel;
00430 delete m_fsInline;
00431 delete m_dcop;
00432 delete m_fontDlg;
00433 delete m_paragDlg;
00434 }
00435
00436 DCOPObject* KWView::dcopObject()
00437 {
00438 if ( !m_dcop )
00439 m_dcop = new KWordViewIface( this );
00440
00441 return m_dcop;
00442 }
00443
00444 void KWView::slotChangeCutState(bool b)
00445 {
00446 KWTextFrameSetEdit * edit = currentTextEdit();
00447 if ( edit && edit->textFrameSet()->protectContent())
00448 m_actionEditCut->setEnabled( false );
00449 else
00450 m_actionEditCut->setEnabled( b );
00451 }
00452
00453 void KWView::slotChangeCaseState(bool b)
00454 {
00455 KWTextFrameSetEdit * edit = currentTextEdit();
00456 if ( edit && edit->textFrameSet()->protectContent())
00457 m_actionChangeCase->setEnabled( false );
00458 else
00459 m_actionChangeCase->setEnabled( b );
00460 }
00461
00462 void KWView::slotSetInitialPosition()
00463 {
00464 KWTextFrameSetEdit* textedit = dynamic_cast<KWTextFrameSetEdit *>(m_gui->canvasWidget()->currentFrameSetEdit());
00465 if ( textedit )
00466 textedit->ensureCursorVisible();
00467 else
00468 m_gui->canvasWidget()->setContentsPos( 0, 0 );
00469 }
00470
00471 void KWView::changeNbOfRecentFiles(int nb)
00472 {
00473 if ( shell() )
00474 shell()->setMaxRecentItems( nb );
00475 }
00476
00477 KWViewMode* KWView::viewMode() const
00478 {
00479 return m_gui->canvasWidget()->viewMode();
00480 }
00481
00482 void KWView::initGui()
00483 {
00484 clipboardDataChanged();
00485 if ( m_gui )
00486 m_gui->showGUI();
00487 showMouseMode( KWCanvas::MM_EDIT );
00488 initGUIButton();
00489 m_actionFormatDecreaseIndent->setEnabled(false);
00490
00491
00492 m_actionFormatColor->setCurrentColor( Qt::black );
00493
00494 updateGridButton();
00495
00496
00497 updateZoomControls();
00498
00499
00500
00501 m_gui->canvasWidget()->setMouseMode( m_gui->canvasWidget()->mouseMode() );
00502
00503 bool editingFormula = dynamic_cast<KWFormulaFrameSetEdit *>( m_gui->canvasWidget()->currentFrameSetEdit() ) != 0;
00504
00505 if(shell())
00506 shell()->showToolbar( "formula_toolbar", editingFormula );
00507
00508 if ( !editingFormula )
00509 {
00510 kWordDocument()->formulaDocumentWrapper()->setEnabled(false);
00511 kWordDocument()->formulaDocumentWrapper()->enableMatrixActions(false);
00512 kWordDocument()->formulaDocumentWrapper()->getSyntaxHighlightingAction()->setEnabled(false);
00513 }
00514
00515
00516 if ( KStatusBar* sb = statusBar() )
00517 sb->show();
00518
00519 updatePageInfo();
00520 slotFrameSetEditChanged();
00521 frameSelectedChanged();
00522 updateTocActionText(m_doc->tocPresent());
00523
00524 m_actionBackgroundColor->setEnabled(true);
00525 updateBgSpellCheckingState();
00526 updateDirectCursorButton();
00527 m_actionCreateFrameStyle->setEnabled(false);
00528 }
00529
00530
00531 void KWView::updateBgSpellCheckingState()
00532 {
00533 m_actionAllowBgSpellCheck->setChecked( m_doc->backgroundSpellCheckEnabled() );
00534 }
00535
00536
00537 void KWView::initGUIButton()
00538 {
00539 m_actionViewFrameBorders->setChecked( viewFrameBorders() );
00540 m_actionViewFormattingChars->setChecked( m_doc->viewFormattingChars() );
00541 m_actionShowDocStruct->setChecked(m_doc->showdocStruct());
00542 m_actionShowRuler->setChecked(m_doc->showRuler());
00543
00544 updateHeaderFooterButton();
00545 m_actionAllowAutoFormat->setChecked( m_doc->allowAutoFormat() );
00546
00547 if ( !m_doc->isEmbedded() ) {
00548 QString mode = viewMode()->type();
00549 if (mode=="ModePreview")
00550 m_actionViewPreviewMode->setChecked(true);
00551 else if (mode=="ModeText")
00552 m_actionViewTextMode->setChecked(true);
00553 else
00554 m_actionViewPageMode->setChecked(true);
00555 switchModeView();
00556 }
00557 }
00558
00559 void KWView::setupActions()
00560 {
00561
00562
00563
00564
00565 m_actionExtraCreateTemplate = new KAction( i18n( "&Create Template From Document..." ), 0,
00566 this, SLOT( extraCreateTemplate() ),
00567 actionCollection(), "extra_template" );
00568 m_actionExtraCreateTemplate->setToolTip( i18n( "Save this document and use it later as a template" ) );
00569 m_actionExtraCreateTemplate->setWhatsThis( i18n( "You can save this document as a template.<br><br>You can use this new template as a starting point for another document." ) );
00570
00571 m_actionFileStatistics = new KAction( i18n( "Statistics" ), 0, this, SLOT( fileStatistics() ), actionCollection(), "file_statistics" );
00572 m_actionFileStatistics->setToolTip( i18n( "Sentence, word and letter counts for this document" ) );
00573 m_actionFileStatistics->setWhatsThis( i18n( "Information on the number of letters, words, syllables and sentences for this document.<p>Evaluates readability using the Flesch reading score." ) );
00574
00575 m_actionEditCut = KStdAction::cut( this, SLOT( editCut() ), actionCollection(), "edit_cut" );
00576 m_actionEditCopy = KStdAction::copy( this, SLOT( editCopy() ), actionCollection(), "edit_copy" );
00577 m_actionEditPaste = KStdAction::paste( this, SLOT( editPaste() ), actionCollection(), "edit_paste" );
00578 m_actionEditFind = KStdAction::find( this, SLOT( editFind() ), actionCollection(), "edit_find" );
00579 m_actionEditFindNext = KStdAction::findNext( this, SLOT( editFindNext() ), actionCollection(), "edit_findnext" );
00580 m_actionEditFindPrevious = KStdAction::findPrev( this, SLOT( editFindPrevious() ), actionCollection(), "edit_findprevious" );
00581 m_actionEditReplace = KStdAction::replace( this, SLOT( editReplace() ), actionCollection(), "edit_replace" );
00582 m_actionEditSelectAll = KStdAction::selectAll( this, SLOT( editSelectAll() ), actionCollection(), "edit_selectall" );
00583 new KAction( i18n( "Select All Frames" ), 0, this, SLOT( editSelectAllFrames() ), actionCollection(), "edit_selectallframes" );
00584 m_actionEditSelectCurrentFrame = new KAction( i18n( "Select Frame" ), 0,
00585 0, this, SLOT( editSelectCurrentFrame() ),
00586 actionCollection(), "edit_selectcurrentframe" );
00587 m_actionSpellCheck = KStdAction::spelling( this, SLOT( slotSpellCheck() ), actionCollection(), "extra_spellcheck" );
00588 m_actionDeletePage = new KAction( i18n( "Delete Page" ), "delslide", 0,
00589 this, SLOT( deletePage() ),
00590 actionCollection(), "delete_page" );
00591 kdDebug() << m_doc->pageCount() << " " << (m_doc->processingType() == KWDocument::DTP) << endl;
00592
00593 (void) new KAction( i18n( "Configure Mai&l Merge..." ), "configure",0,
00594 this, SLOT( editMailMergeDataBase() ),
00595 actionCollection(), "edit_sldatabase" );
00596
00597
00598 (void) new KWMailMergeLabelAction::KWMailMergeLabelAction( i18n("Drag Mail Merge Variable"), 0,
00599 this, SLOT(editMailMergeDataBase()), actionCollection(), "mailmerge_draglabel" );
00600
00601
00602
00603
00604 m_actionEditDelFrame = new KAction( i18n( "&Delete Frame" ), 0,
00605 this, SLOT( editDeleteFrame() ),
00606 actionCollection(), "edit_delframe" );
00607 m_actionEditDelFrame->setToolTip( i18n( "Delete the currently selected frame(s)." ) );
00608 m_actionEditDelFrame->setWhatsThis( i18n( "Delete the currently selected frame(s)." ) );
00609
00610 m_actionCreateLinkedFrame = new KAction( i18n( "Create Linked Copy" ), 0, this, SLOT( createLinkedFrame() ), actionCollection(), "create_linked_frame" );
00611 m_actionCreateLinkedFrame->setToolTip( i18n( "Create a copy of the current frame, always showing the same contents" ) );
00612 m_actionCreateLinkedFrame->setWhatsThis( i18n("Create a copy of the current frame, that remains linked to it. This means they always show the same contents: modifying the contents in such a frame will update all its linked copies.") );
00613
00614 m_actionRaiseFrame = new KAction( i18n( "Ra&ise Frame" ), "raise",
00615 Qt::CTRL +Qt::SHIFT+ Qt::Key_R, this, SLOT( raiseFrame() ),
00616 actionCollection(), "raiseframe" );
00617 m_actionRaiseFrame->setToolTip( i18n( "Raise the currently selected frame so that it appears above all the other frames" ) );
00618 m_actionRaiseFrame->setWhatsThis( i18n( "Raise the currently selected frame so that it appears above all the other frames. This is only useful if frames overlap each other. If multiple frames are selected they are all raised in turn." ) );
00619
00620 m_actionLowerFrame = new KAction( i18n( "&Lower Frame" ), "lower",
00621 Qt::CTRL +Qt::SHIFT+ Qt::Key_L, this, SLOT( lowerFrame() ),
00622 actionCollection(), "lowerframe" );
00623 m_actionLowerFrame->setToolTip( i18n( "Lower the currently selected frame so that it disappears under any frame that overlaps it" ) );
00624 m_actionLowerFrame->setWhatsThis( i18n( "Lower the currently selected frame so that it disappears under any frame that overlaps it. If multiple frames are selected they are all lowered in turn." ) );
00625
00626 m_actionBringToFront= new KAction( i18n( "Bring to Front" ), "bring_forward",
00627 0, this, SLOT( bringToFront() ),
00628 actionCollection(), "bring_tofront_frame" );
00629
00630 m_actionSendBackward= new KAction( i18n( "Send to Back" ), "send_backward",
00631 0, this, SLOT( sendToBack() ),
00632 actionCollection(), "send_toback_frame" );
00633
00634
00635
00636
00637 if ( !m_doc->isEmbedded() ) {
00638
00639 m_actionViewTextMode = new KToggleAction( i18n( "Text Mode" ), 0,
00640 this, SLOT( viewTextMode() ),
00641 actionCollection(), "view_textmode" );
00642 m_actionViewTextMode->setToolTip( i18n( "Only show the text of the document." ) );
00643 m_actionViewTextMode->setWhatsThis( i18n( "Do not show any pictures, formatting or layout. KWord will display only the text for editing." ) );
00644
00645 m_actionViewTextMode->setExclusiveGroup( "viewmodes" );
00646 m_actionViewPageMode = new KToggleAction( i18n( "&Page Mode" ), 0,
00647 this, SLOT( viewPageMode() ),
00648 actionCollection(), "view_pagemode" );
00649 m_actionViewPageMode->setWhatsThis( i18n( "Switch to page mode.<br><br> Page mode is designed to make editing your text easy.<br><br>This function is most frequently used to return to text editing after switching to preview mode." ) );
00650 m_actionViewPageMode->setToolTip( i18n( "Switch to page editing mode." ) );
00651
00652 m_actionViewPageMode->setExclusiveGroup( "viewmodes" );
00653 m_actionViewPageMode->setChecked( true );
00654 m_actionViewPreviewMode = new KToggleAction( i18n( "Pre&view Mode" ), 0,
00655 this, SLOT( viewPreviewMode() ),
00656 actionCollection(), "view_previewmode" );
00657 m_actionViewPreviewMode->setWhatsThis( i18n( "Zoom out from your document to get a look at several pages of your document.<br><br>The number of pages per line can be customized." ) );
00658 m_actionViewPreviewMode->setToolTip( i18n( "Zoom out to a multiple page view." ) );
00659
00660 m_actionViewPreviewMode->setExclusiveGroup( "viewmodes" );
00661 }
00662 else
00663 {
00664 m_actionViewTextMode = 0;
00665 m_actionViewPageMode = 0;
00666 m_actionViewPreviewMode = 0;
00667 }
00668
00669 m_actionViewFormattingChars = new KToggleAction( i18n( "&Formatting Characters" ), 0,
00670 this, SLOT( slotViewFormattingChars() ),
00671 actionCollection(), "view_formattingchars" );
00672 m_actionViewFormattingChars->setToolTip( i18n( "Toggle the display of non-printing characters." ) );
00673 m_actionViewFormattingChars->setWhatsThis( i18n( "Toggle the display of non-printing characters.<br><br>When this is enabled, KWord shows you tabs, spaces, carriage returns and other non-printing characters." ) );
00674
00675 m_actionViewFrameBorders = new KToggleAction( i18n( "Frame &Borders" ), 0,
00676 this, SLOT( slotViewFrameBorders() ),
00677 actionCollection(), "view_frameborders" );
00678 m_actionViewFrameBorders->setToolTip( i18n( "Turns the border display on and off." ) );
00679 m_actionViewFrameBorders->setWhatsThis( i18n( "Turns the border display on and off.<br><br>The borders are never printed. This option is useful to see how the document will appear on the printed page." ) );
00680
00681 m_actionViewHeader = new KToggleAction( i18n( "Enable Document &Headers" ), 0,
00682 this, SLOT( viewHeader() ),
00683 actionCollection(), "format_header" );
00684 m_actionViewHeader->setCheckedState(i18n("Disable Document &Headers"));
00685 m_actionViewHeader->setToolTip( i18n( "Shows and hides header display." ) );
00686 m_actionViewHeader->setWhatsThis( i18n( "Selecting this option toggles the display of headers in KWord.<br><br>Headers are special frames at the top of each page which can contain page numbers or other information." ) );
00687
00688 m_actionViewFooter = new KToggleAction( i18n( "Enable Document Foo&ters" ), 0,
00689 this, SLOT( viewFooter() ),
00690 actionCollection(), "format_footer" );
00691 m_actionViewFooter->setCheckedState(i18n("Disable Document Foo&ters"));
00692 m_actionViewFooter->setToolTip( i18n( "Shows and hides footer display." ) );
00693 m_actionViewFooter->setWhatsThis( i18n( "Selecting this option toggles the display of footers in KWord. <br><br>Footers are special frames at the bottom of each page which can contain page numbers or other information." ) );
00694
00695 m_actionViewZoom = new KSelectAction( i18n( "Zoom" ), "viewmag", 0,
00696 actionCollection(), "view_zoom" );
00697
00698 connect( m_actionViewZoom, SIGNAL( activated( const QString & ) ),
00699 this, SLOT( viewZoom( const QString & ) ) );
00700 m_actionViewZoom->setEditable(true);
00701 changeZoomMenu( );
00702
00703
00704 m_actionInsertSpecialChar = new KAction( i18n( "Sp&ecial Character..." ), "char",
00705 Qt::ALT + Qt::SHIFT + Qt::Key_C,
00706 this, SLOT( insertSpecialChar() ),
00707 actionCollection(), "insert_specialchar" );
00708 m_actionInsertSpecialChar->setToolTip( i18n( "Insert one or more symbols or letters not found on the keyboard." ) );
00709 m_actionInsertSpecialChar->setWhatsThis( i18n( "Insert one or more symbols or letters not found on the keyboard." ) );
00710
00711 m_actionInsertFrameBreak = new KAction( QString::null, Qt::CTRL + Qt::Key_Return,
00712 this, SLOT( insertFrameBreak() ),
00713 actionCollection(), "insert_framebreak" );
00714 if ( m_doc->processingType() == KWDocument::WP ) {
00715 m_actionInsertFrameBreak->setText( i18n( "Page Break" ) );
00716 m_actionInsertFrameBreak->setToolTip( i18n( "Force the remainder of the text into the next page." ) );
00717 m_actionInsertFrameBreak->setWhatsThis( i18n( "This inserts a non-printing character at the current cursor position. All text after this point will be moved into the next page." ) );
00718 } else {
00719 m_actionInsertFrameBreak->setText( i18n( "&Hard Frame Break" ) );
00720 m_actionInsertFrameBreak->setToolTip( i18n( "Force the remainder of the text into the next frame." ) );
00721 m_actionInsertFrameBreak->setWhatsThis( i18n( "This inserts a non-printing character at the current cursor position. All text after this point will be moved into the next frame in the frameset." ) );
00722 }
00723
00724 new KAction( m_doc->processingType() == KWDocument::WP ? i18n( "Page" ) : i18n( "Page..." ), "page", 0,
00725 this, SLOT( insertPage() ),
00726 actionCollection(), "insert_page" );
00727
00728 m_actionInsertLink = new KAction( i18n( "Link..." ), 0,
00729 this, SLOT( insertLink() ),
00730 actionCollection(), "insert_link" );
00731 m_actionInsertLink->setToolTip( i18n( "Insert a Web address, email address or hyperlink to a file." ) );
00732 m_actionInsertLink->setWhatsThis( i18n( "Insert a Web address, email address or hyperlink to a file." ) );
00733
00734 m_actionInsertComment = new KAction( i18n( "Comment..." ), 0,
00735 this, SLOT( insertComment() ),
00736 actionCollection(), "insert_comment" );
00737 m_actionInsertComment->setToolTip( i18n( "Insert a comment about the selected text." ) );
00738 m_actionInsertComment->setWhatsThis( i18n( "Insert a comment about the selected text. These comments are not designed to appear on the final page." ) );
00739
00740 m_actionEditComment = new KAction( i18n("Edit Comment..."), 0,
00741 this,SLOT(editComment()),
00742 actionCollection(), "edit_comment");
00743 m_actionEditComment->setToolTip( i18n( "Change the content of a comment." ) );
00744 m_actionEditComment->setWhatsThis( i18n( "Change the content of a comment." ) );
00745
00746 m_actionRemoveComment = new KAction( i18n("Remove Comment"), 0,
00747 this,SLOT(removeComment()),
00748 actionCollection(), "remove_comment");
00749 m_actionRemoveComment->setToolTip( i18n( "Remove the selected document comment." ) );
00750 m_actionRemoveComment->setWhatsThis( i18n( "Remove the selected document comment." ) );
00751 m_actionCopyTextOfComment = new KAction( i18n("Copy Text of Comment..."), 0,
00752 this,SLOT(copyTextOfComment()),
00753 actionCollection(), "copy_text_comment");
00754
00755
00756 m_actionInsertFootEndNote = new KAction( i18n( "&Footnote/Endnote..." ), 0,
00757 this, SLOT( insertFootNote() ),
00758 actionCollection(), "insert_footendnote" );
00759 m_actionInsertFootEndNote->setToolTip( i18n( "Insert a footnote referencing the selected text." ) );
00760 m_actionInsertFootEndNote->setWhatsThis( i18n( "Insert a footnote referencing the selected text." ) );
00761
00762 m_actionInsertContents = new KAction( i18n( "Table of &Contents" ), 0,
00763 this, SLOT( insertContents() ),
00764 actionCollection(), "insert_contents" );
00765 m_actionInsertContents->setToolTip( i18n( "Insert table of contents at the current cursor position." ) );
00766 m_actionInsertContents->setWhatsThis( i18n( "Insert table of contents at the current cursor position." ) );
00767
00768 m_variableDefMap.clear();
00769 actionInsertVariable = new KActionMenu( i18n( "&Variable" ),
00770 actionCollection(), "insert_variable" );
00771
00772
00773 addVariableActions( VT_FIELD, KoFieldVariable::actionTexts(), actionInsertVariable, i18n("Document &Information") );
00774 addVariableActions( VT_DATE, KoDateVariable::actionTexts(), actionInsertVariable, i18n("&Date") );
00775 addVariableActions( VT_TIME, KoTimeVariable::actionTexts(), actionInsertVariable, i18n("&Time") );
00776 addVariableActions( VT_PGNUM, KoPageVariable::actionTexts(), actionInsertVariable, i18n("&Page") );
00777 addVariableActions( VT_STATISTIC, KWStatisticVariable::actionTexts(), actionInsertVariable, i18n("&Statistic") );
00778
00779 m_actionInsertCustom = new KActionMenu( i18n( "&Custom" ),
00780 actionCollection(), "insert_custom" );
00781 actionInsertVariable->insert(m_actionInsertCustom);
00782
00783
00784
00785 addVariableActions( VT_MAILMERGE, KoMailMergeVariable::actionTexts(), actionInsertVariable, QString::null );
00786
00787 actionInsertVariable->popupMenu()->insertSeparator();
00788 m_actionRefreshAllVariable = new KAction( i18n( "&Refresh All Variables" ), 0,
00789 this, SLOT( refreshAllVariable() ),
00790 actionCollection(), "refresh_all_variable" );
00791 m_actionRefreshAllVariable->setToolTip( i18n( "Update all variables to current values." ) );
00792 m_actionRefreshAllVariable->setWhatsThis( i18n( "Update all variables in the document to current values.<br><br>This will update page numbers, dates or any other variables that need updating." ) );
00793
00794 actionInsertVariable->insert(m_actionRefreshAllVariable);
00795
00796 m_actionInsertExpression = new KActionMenu( i18n( "&Expression" ),
00797 actionCollection(), "insert_expression" );
00798 loadexpressionActions( m_actionInsertExpression);
00799
00800 m_actionToolsCreateText = new KToggleAction( i18n( "Te&xt Frame" ), "frame_text", Qt::Key_F10 ,
00801 this, SLOT( toolsCreateText() ),
00802 actionCollection(), "tools_createtext" );
00803 m_actionToolsCreateText->setToolTip( i18n( "Create a new text frame." ) );
00804 m_actionToolsCreateText->setWhatsThis( i18n( "Create a new text frame." ) );
00805
00806 m_actionToolsCreateText->setExclusiveGroup( "tools" );
00807 m_actionInsertFormula = new KAction( i18n( "For&mula" ), "frame_formula", Qt::Key_F4,
00808 this, SLOT( insertFormula() ),
00809 actionCollection(), "tools_formula" );
00810 m_actionInsertFormula->setToolTip( i18n( "Insert a formula into a new frame." ) );
00811 m_actionInsertFormula->setWhatsThis( i18n( "Insert a formula into a new frame." ) );
00812
00813 m_actionInsertTable = new KAction( i18n( "&Table..." ), "inline_table",
00814 Qt::Key_F5,
00815 this, SLOT( insertTable() ),
00816 actionCollection(), "insert_table" );
00817 m_actionInsertTable->setToolTip( i18n( "Create a table." ) );
00818 m_actionInsertTable->setWhatsThis( i18n( "Create a table.<br><br>The table can either exist in a frame of its own or inline." ) );
00819
00820 m_actionToolsCreatePix = new KToggleAction( i18n( "P&icture..." ), "frame_image",
00821 Qt::SHIFT + Qt::Key_F5 ,
00822 this, SLOT( insertPicture() ),
00823 actionCollection(), "insert_picture" );
00824 m_actionToolsCreatePix->setToolTip( i18n( "Create a new frame for a picture." ) );
00825 m_actionToolsCreatePix->setWhatsThis( i18n( "Create a new frame for a picture or diagram." ) );
00826 m_actionToolsCreatePix->setExclusiveGroup( "tools" );
00827
00828 m_actionToolsCreatePart = new KoPartSelectAction( i18n( "&Object Frame" ), "frame_query",
00829 this, SLOT( toolsPart() ),
00830 actionCollection(), "tools_part" );
00831 m_actionToolsCreatePart->setToolTip( i18n( "Insert an object into a new frame." ) );
00832 m_actionToolsCreatePart->setWhatsThis( i18n( "Insert an object into a new frame." ) );
00833
00834 m_actionInsertFile = new KAction( i18n( "Fi&le..." ), 0,
00835 this, SLOT( insertFile() ),
00836 actionCollection(), "insert_file" );
00837
00838
00839
00840 m_actionFormatFont = new KAction( i18n( "&Font..." ), Qt::ALT + Qt::CTRL + Qt::Key_F,
00841 this, SLOT( formatFont() ),
00842 actionCollection(), "format_font" );
00843 m_actionFormatFont->setToolTip( i18n( "Change character size, font, boldface, italics etc." ) );
00844 m_actionFormatFont->setWhatsThis( i18n( "Change the attributes of the currently selected characters." ) );
00845
00846 m_actionFormatParag = new KAction( i18n( "&Paragraph..." ), Qt::ALT + Qt::CTRL + Qt::Key_P,
00847 this, SLOT( formatParagraph() ),
00848 actionCollection(), "format_paragraph" );
00849 m_actionFormatParag->setToolTip( i18n( "Change paragraph margins, text flow, borders, bullets, numbering etc." ) );
00850 m_actionFormatParag->setWhatsThis( i18n( "Change paragraph margins, text flow, borders, bullets, numbering etc.<p>Select text in multiple paragraphs to change the formatting of all selected paragraphs.<p>If no text is selected, the paragraph where the cursor is located will be changed." ) );
00851
00852 m_actionFormatFrameSet = new KAction( i18n( "F&rame/Frameset Properties" ), 0,
00853 this, SLOT( formatFrameSet() ),
00854 actionCollection(), "format_frameset" );
00855 m_actionFormatFrameSet->setToolTip( i18n( "Alter frameset properties." ) );
00856 m_actionFormatFrameSet->setWhatsThis( i18n( "Alter frameset properties.<p>Currently you can change the frame background." ) );
00857
00858 m_actionFormatPage = new KAction( i18n( "Page &Layout..." ), 0,
00859 this, SLOT( formatPage() ),
00860 actionCollection(), "format_page" );
00861 m_actionFormatPage->setToolTip( i18n( "Change properties of entire page." ) );
00862 m_actionFormatPage->setWhatsThis( i18n( "Change properties of the entire page.<p>Currently you can change paper size, paper orientation, header and footer sizes, and column settings." ) );
00863
00864
00865 m_actionFormatFrameStylist = new KAction( i18n( "&Frame Style Manager" ), 0 ,
00866 this, SLOT( extraFrameStylist() ),
00867 actionCollection(), "frame_stylist" );
00868 m_actionFormatFrameStylist->setToolTip( i18n( "Change attributes of framestyles." ) );
00869 m_actionFormatFrameStylist->setWhatsThis( i18n( "Change background and borders of framestyles.<p>Multiple framestyles can be changed using the dialog box." ) );
00870
00871
00872 m_actionFormatStylist = new KAction( i18n( "&Style Manager" ), Qt::ALT + Qt::CTRL + Qt::Key_S,
00873 this, SLOT( extraStylist() ),
00874 actionCollection(), "format_stylist" );
00875 m_actionFormatStylist->setToolTip( i18n( "Change attributes of styles." ) );
00876 m_actionFormatStylist->setWhatsThis( i18n( "Change font and paragraph attributes of styles.<p>Multiple styles can be changed using the dialog box." ) );
00877
00878 m_actionFormatFontSize = new KFontSizeAction( i18n( "Font Size" ), 0,
00879 actionCollection(), "format_fontsize" );
00880 connect( m_actionFormatFontSize, SIGNAL( fontSizeChanged( int ) ),
00881 this, SLOT( textSizeSelected( int ) ) );
00882
00883 m_actionFontSizeIncrease = new KAction( i18n("Increase Font Size"), "fontsizeup", Qt::CTRL + Qt::Key_Greater, this, SLOT( increaseFontSize() ), actionCollection(), "increase_fontsize" );
00884 m_actionFontSizeDecrease = new KAction( i18n("Decrease Font Size"), "fontsizedown", Qt::CTRL + Qt::Key_Less, this, SLOT( decreaseFontSize() ), actionCollection(), "decrease_fontsize" );
00885
00886 #ifdef KFONTACTION_HAS_CRITERIA_ARG
00887 m_actionFormatFontFamily = new KFontAction( KFontChooser::SmoothScalableFonts,
00888 i18n( "Font Family" ), 0,
00889 actionCollection(), "format_fontfamily" );
00890 #else
00891 m_actionFormatFontFamily = new KFontAction( i18n( "Font Family" ), 0,
00892 actionCollection(), "format_fontfamily" );
00893 #endif
00894 connect( m_actionFormatFontFamily, SIGNAL( activated( const QString & ) ),
00895 this, SLOT( textFontSelected( const QString & ) ) );
00896
00897 m_actionFormatStyleMenu = new KActionMenu( i18n( "St&yle" ), 0,
00898 actionCollection(), "format_stylemenu" );
00899 m_actionFormatStyle = new KSelectAction( i18n( "St&yle" ), 0,
00900 actionCollection(), "format_style" );
00901
00902
00903 connect( m_actionFormatStyle, SIGNAL( activated( int ) ),
00904 this, SLOT( textStyleSelected( int ) ) );
00905 updateStyleList();
00906
00907 m_actionFormatDefault=new KAction( i18n( "Default Format" ), 0,
00908 this, SLOT( textDefaultFormat() ),
00909 actionCollection(), "text_default" );
00910 m_actionFormatDefault->setToolTip( i18n( "Change font and paragraph attributes to their default values." ) );
00911 m_actionFormatDefault->setWhatsThis( i18n( "Change font and paragraph attributes to their default values." ) );
00912
00913
00914
00915 m_actionFormatBold = new KToggleAction( i18n( "&Bold" ), "text_bold", Qt::CTRL + Qt::Key_B,
00916 this, SLOT( textBold() ),
00917 actionCollection(), "format_bold" );
00918 m_actionFormatItalic = new KToggleAction( i18n( "&Italic" ), "text_italic", Qt::CTRL + Qt::Key_I,
00919 this, SLOT( textItalic() ),
00920 actionCollection(), "format_italic" );
00921 m_actionFormatUnderline = new KToggleAction( i18n( "&Underline" ), "text_under", Qt::CTRL + Qt::Key_U,
00922 this, SLOT( textUnderline() ),
00923 actionCollection(), "format_underline" );
00924 m_actionFormatStrikeOut = new KToggleAction( i18n( "&Strike Out" ), "text_strike", 0 ,
00925 this, SLOT( textStrikeOut() ),
00926 actionCollection(), "format_strike" );
00927
00928 m_actionFormatAlignLeft = new KToggleAction( i18n( "Align &Left" ), "text_left", Qt::CTRL + Qt::Key_L,
00929 this, SLOT( textAlignLeft() ),
00930 actionCollection(), "format_alignleft" );
00931 m_actionFormatAlignLeft->setExclusiveGroup( "align" );
00932 m_actionFormatAlignLeft->setChecked( TRUE );
00933 m_actionFormatAlignCenter = new KToggleAction( i18n( "Align &Center" ), "text_center", Qt::CTRL + Qt::ALT + Qt::Key_C,
00934 this, SLOT( textAlignCenter() ),
00935 actionCollection(), "format_aligncenter" );
00936 m_actionFormatAlignCenter->setExclusiveGroup( "align" );
00937 m_actionFormatAlignRight = new KToggleAction( i18n( "Align &Right" ), "text_right", Qt::CTRL + Qt::ALT + Qt::Key_R,
00938 this, SLOT( textAlignRight() ),
00939 actionCollection(), "format_alignright" );
00940 m_actionFormatAlignRight->setExclusiveGroup( "align" );
00941 m_actionFormatAlignBlock = new KToggleAction( i18n( "Align &Block" ), "text_block", Qt::CTRL + Qt::Key_J,
00942 this, SLOT( textAlignBlock() ),
00943 actionCollection(), "format_alignblock" );
00944 m_actionFormatAlignBlock->setExclusiveGroup( "align" );
00945
00946 m_actionFormatSpacingSingle = new KToggleAction( i18n( "Line Spacing &1" ), "spacesimple", Qt::CTRL + Qt::Key_1,
00947 this, SLOT( textSpacingSingle() ),
00948 actionCollection(), "format_spacingsingle" );
00949 m_actionFormatSpacingSingle->setExclusiveGroup( "spacing" );
00950 m_actionFormatSpacingOneAndHalf = new KToggleAction( i18n( "Line Spacing 1.&5" ), "spacedouble", Qt::CTRL + Qt::Key_5,
00951 this, SLOT( textSpacingOneAndHalf() ),
00952 actionCollection(), "format_spacing15" );
00953 m_actionFormatSpacingOneAndHalf->setExclusiveGroup( "spacing" );
00954 m_actionFormatSpacingDouble = new KToggleAction( i18n( "Line Spacing &2" ), "spacetriple", Qt::CTRL + Qt::Key_2,
00955 this, SLOT( textSpacingDouble() ),
00956 actionCollection(), "format_spacingdouble" );
00957 m_actionFormatSpacingDouble->setExclusiveGroup( "spacing" );
00958
00959 m_actionFormatSuper = new KToggleAction( i18n( "Superscript" ), "super", 0,
00960 this, SLOT( textSuperScript() ),
00961 actionCollection(), "format_super" );
00962
00963 m_actionFormatSub = new KToggleAction( i18n( "Subscript" ), "sub", 0,
00964 this, SLOT( textSubScript() ),
00965 actionCollection(), "format_sub" );
00966
00967
00968 m_actionFormatIncreaseIndent= new KAction( i18n( "Increase Indent" ),
00969 QApplication::reverseLayout() ? "format_decreaseindent" : "format_increaseindent", 0,
00970 this, SLOT( textIncreaseIndent() ),
00971 actionCollection(), "format_increaseindent" );
00972
00973 m_actionFormatDecreaseIndent= new KAction( i18n( "Decrease Indent" ),
00974 QApplication::reverseLayout() ? "format_increaseindent" :"format_decreaseindent", 0,
00975 this, SLOT( textDecreaseIndent() ),
00976 actionCollection(), "format_decreaseindent" );
00977
00978 m_actionFormatColor = new TKSelectColorAction( i18n( "Text Color..." ), TKSelectColorAction::TextColor,
00979 this, SLOT( textColor() ),
00980 actionCollection(), "format_color", true );
00981 m_actionFormatColor->setDefaultColor(QColor());
00982
00983
00984
00985
00986
00987
00988
00989 m_actionFormatNumber = new KActionMenu( i18n( "Number" ),
00990 "enumList", actionCollection(), "format_number" );
00991 m_actionFormatNumber->setDelayed( false );
00992 m_actionFormatBullet = new KActionMenu( i18n( "Bullet" ),
00993 "unsortedList", actionCollection(), "format_bullet" );
00994 m_actionFormatBullet->setDelayed( false );
00995 QPtrList<KoCounterStyleWidget::StyleRepresenter> stylesList;
00996 KoCounterStyleWidget::makeCounterRepresenterList( stylesList );
00997 QPtrListIterator<KoCounterStyleWidget::StyleRepresenter> styleIt( stylesList );
00998 for ( ; styleIt.current() ; ++styleIt ) {
00999
01000
01001 KToggleAction* act = new KToggleAction( styleIt.current()->name(),
01002 0, this, SLOT( slotCounterStyleSelected() ),
01003 actionCollection(), QString("counterstyle_%1").arg( styleIt.current()->style() ).latin1() );
01004 act->setExclusiveGroup( "counterstyle" );
01005
01006 if ( styleIt.current()->style() == KoParagCounter::STYLE_NONE ) {
01007 m_actionFormatBullet->insert( act );
01008 m_actionFormatNumber->insert( act );
01009 } else if ( styleIt.current()->isBullet() )
01010 m_actionFormatBullet->insert( act );
01011 else
01012 m_actionFormatNumber->insert( act );
01013 }
01014
01015
01016
01017 m_actionFrameStyleMenu = new KActionMenu( i18n( "Fra&mestyle" ), 0,
01018 actionCollection(), "frame_stylemenu" );
01019 m_actionFrameStyle = new KSelectAction( i18n( "Framest&yle" ), 0,
01020 actionCollection(), "frame_style" );
01021 connect( m_actionFrameStyle, SIGNAL( activated( int ) ),
01022 this, SLOT( frameStyleSelected( int ) ) );
01023 updateFrameStyleList();
01024 m_actionBorderOutline = new KToggleAction( i18n( "Border Outline" ), "borderoutline",
01025 0, this, SLOT( borderOutline() ), actionCollection(), "border_outline" );
01026 m_actionBorderLeft = new KToggleAction( i18n( "Border Left" ), "borderleft",
01027 0, this, SLOT( borderLeft() ), actionCollection(), "border_left" );
01028 m_actionBorderRight = new KToggleAction( i18n( "Border Right" ), "borderright",
01029 0, this, SLOT( borderRight() ), actionCollection(), "border_right" );
01030 m_actionBorderTop = new KToggleAction( i18n( "Border Top" ), "bordertop",
01031 0, this, SLOT( borderTop() ), actionCollection(), "border_top" );
01032 m_actionBorderBottom = new KToggleAction( i18n( "Border Bottom" ), "borderbottom",
01033 0, this, SLOT( borderBottom() ), actionCollection(), "border_bottom" );
01034 m_actionBorderStyle = new KSelectAction( i18n( "Border Style" ),
01035 0, actionCollection(), "border_style" );
01036
01037 QStringList lst;
01038 lst << KoBorder::getStyle( KoBorder::SOLID );
01039 lst << KoBorder::getStyle( KoBorder::DASH );
01040 lst << KoBorder::getStyle( KoBorder::DOT );
01041 lst << KoBorder::getStyle( KoBorder::DASH_DOT );
01042 lst << KoBorder::getStyle( KoBorder::DASH_DOT_DOT );
01043 lst << KoBorder::getStyle( KoBorder::DOUBLE_LINE );
01044 m_actionBorderStyle->setItems( lst );
01045 m_actionBorderWidth = new KSelectAction( i18n( "Border Width" ), 0,
01046 actionCollection(), "border_width" );
01047 lst.clear();
01048 for ( unsigned int i = 1; i < 10; i++ )
01049 lst << QString::number( i );
01050 m_actionBorderWidth->setItems( lst );
01051 m_actionBorderWidth->setCurrentItem( 0 );
01052
01053 m_actionBorderColor = new TKSelectColorAction( i18n("Border Color"), TKSelectColorAction::LineColor, actionCollection(), "border_color", true );
01054 m_actionBorderColor->setDefaultColor(QColor());
01055
01056
01057 m_actionBackgroundColor = new TKSelectColorAction( i18n( "Text Background Color..." ), TKSelectColorAction::FillColor, actionCollection(),"border_backgroundcolor", true);
01058 m_actionBackgroundColor->setToolTip( i18n( "Change background color for currently selected text." ) );
01059 m_actionBackgroundColor->setWhatsThis( i18n( "Change background color for currently selected text." ) );
01060
01061 connect(m_actionBackgroundColor,SIGNAL(activated()),SLOT(backgroundColor() ));
01062 m_actionBackgroundColor->setDefaultColor(QColor());
01063
01064
01065 m_actionTablePropertiesMenu = new KAction( i18n( "&Properties" ), 0,
01066 this, SLOT( tableProperties() ),
01067 actionCollection(), "table_propertiesmenu" );
01068 m_actionTablePropertiesMenu->setToolTip( i18n( "Adjust properties of the current table." ) );
01069 m_actionTablePropertiesMenu->setWhatsThis( i18n( "Adjust properties of the current table." ) );
01070
01071 m_actionTableInsertRow = new KAction( i18n( "&Insert Row..." ), "insert_table_row", 0,
01072 this, SLOT( tableInsertRow() ),
01073 actionCollection(), "table_insrow" );
01074 m_actionTableInsertRow->setToolTip( i18n( "Insert one or more rows at cursor location." ) );
01075 m_actionTableInsertRow->setWhatsThis( i18n( "Insert one or more rows at current cursor location." ) );
01076
01077 m_actionTableInsertCol = new KAction( i18n( "I&nsert Column..." ), "insert_table_col", 0,
01078 this, SLOT( tableInsertCol() ),
01079 actionCollection(), "table_inscol" );
01080 m_actionTableInsertCol->setToolTip( i18n( "Insert one or more columns into the current table." ) );
01081 m_actionTableInsertCol->setWhatsThis( i18n( "Insert one or more columns into the current table." ) );
01082
01083 m_actionTableDelRow = new KAction( 0, "delete_table_row", 0,
01084 this, SLOT( tableDeleteRow() ),
01085 actionCollection(), "table_delrow" );
01086 m_actionTableDelRow->setToolTip( i18n( "Delete selected rows from the current table." ) );
01087 m_actionTableDelRow->setWhatsThis( i18n( "Delete selected rows from the current table." ) );
01088
01089 m_actionTableDelCol = new KAction( 0, "delete_table_col", 0,
01090 this, SLOT( tableDeleteCol() ),
01091 actionCollection(), "table_delcol" );
01092 m_actionTableDelCol->setToolTip( i18n( "Delete selected columns from the current table." ) );
01093 m_actionTableDelCol->setWhatsThis( i18n( "Delete selected columns from the current table." ) );
01094
01095 m_actionTableResizeCol = new KAction( i18n( "Resize Column..." ), 0,
01096 this, SLOT( tableResizeCol() ),
01097 actionCollection(), "table_resizecol" );
01098 m_actionTableResizeCol->setToolTip( i18n( "Change the width of the currently selected column." ) );
01099 m_actionTableResizeCol->setWhatsThis( i18n( "Change the width of the currently selected column." ) );
01100
01101
01102 m_actionTableJoinCells = new KAction( i18n( "&Join Cells" ), 0,
01103 this, SLOT( tableJoinCells() ),
01104 actionCollection(), "table_joincells" );
01105 m_actionTableJoinCells->setToolTip( i18n( "Join two or more cells into one large cell." ) );
01106 m_actionTableJoinCells->setWhatsThis( i18n( "Join two or more cells into one large cell.<p>This is a good way to create titles and labels within a table." ) );
01107
01108 m_actionTableSplitCells= new KAction( i18n( "&Split Cell..." ), 0,
01109 this, SLOT( tableSplitCells() ),
01110 actionCollection(), "table_splitcells" );
01111 m_actionTableSplitCells->setToolTip( i18n( "Split one cell into two or more cells." ) );
01112 m_actionTableSplitCells->setWhatsThis( i18n( "Split one cell into two or more cells.<p>Cells can be split horizontally, vertically or both directions at once." ) );
01113
01114 m_actionTableProtectCells= new KToggleAction( i18n( "Protect Cells" ), 0, 0, 0,
01115 actionCollection(), "table_protectcells" );
01116 m_actionTableProtectCells->setToolTip( i18n( "Prevent changes to content of selected cells." ) );
01117 connect (m_actionTableProtectCells, SIGNAL( toggled(bool) ), this,
01118 SLOT( tableProtectCells(bool) ));
01119
01120 m_actionTableProtectCells->setWhatsThis( i18n( "Toggles cell protection on and off.<br><br>When cell protection is on, the user can not alter the content or formatting of the text within the cell." ) );
01121
01122 m_actionTableUngroup = new KAction( i18n( "&Ungroup Table" ), 0,
01123 this, SLOT( tableUngroupTable() ),
01124 actionCollection(), "table_ungroup" );
01125 m_actionTableUngroup->setToolTip( i18n( "Break a table into individual frames." ) );
01126 m_actionTableUngroup->setWhatsThis( i18n( "Break a table into individual frames<p>Each frame can be moved independently around the page." ) );
01127
01128 m_actionTableDelete = new KAction( i18n( "Delete &Table" ), 0,
01129 this, SLOT( tableDelete() ),
01130 actionCollection(), "table_delete" );
01131 m_actionTableDelete->setToolTip( i18n( "Delete the entire table." ) );
01132 m_actionTableDelete->setWhatsThis( i18n( "Deletes all cells and the content within the cells of the currently selected table." ) );
01133
01134
01135 m_actionTableStylist = new KAction( i18n( "T&able Style Manager" ), 0,
01136 this, SLOT( tableStylist() ),
01137 actionCollection(), "table_stylist" );
01138 m_actionTableStylist->setToolTip( i18n( "Change attributes of tablestyles." ) );
01139 m_actionTableStylist->setWhatsThis( i18n( "Change textstyle and framestyle of the tablestyles.<p>Multiple tablestyles can be changed using the dialog box." ) );
01140
01141 m_actionTableStyleMenu = new KActionMenu( i18n( "Table&style" ), 0,
01142 actionCollection(), "table_stylemenu" );
01143 m_actionTableStyle = new KSelectAction( i18n( "Table&style" ), 0,
01144 actionCollection(), "table_style" );
01145 connect( m_actionTableStyle, SIGNAL( activated( int ) ),
01146 this, SLOT( tableStyleSelected( int ) ) );
01147 updateTableStyleList();
01148
01149 m_actionConvertTableToText = new KAction( i18n( "Convert Table to Text" ), 0,
01150 this, SLOT( convertTableToText() ),
01151 actionCollection(), "convert_table_to_text" );
01152 m_actionSortText= new KAction( i18n( "Sort Text..." ), 0,
01153 this, SLOT( sortText() ),
01154 actionCollection(), "sort_text" );
01155
01156 m_actionAddPersonalExpression= new KAction( i18n( "Add Expression" ), 0,
01157 this, SLOT( addPersonalExpression() ),
01158 actionCollection(), "add_personal_expression" );
01159
01160
01161
01162
01163
01164 m_actionAllowAutoFormat = new KToggleAction( i18n( "Enable Autocorrection" ), 0,
01165 this, SLOT( slotAllowAutoFormat() ),
01166 actionCollection(), "enable_autocorrection" );
01167 m_actionAllowAutoFormat->setCheckedState(i18n("Disable Autocorrection"));
01168 m_actionAllowAutoFormat->setToolTip( i18n( "Toggle autocorrection on and off." ) );
01169 m_actionAllowAutoFormat->setWhatsThis( i18n( "Toggle autocorrection on and off." ) );
01170
01171 m_actionAutoFormat = new KAction( i18n( "Configure &Autocorrection..." ), 0,
01172 this, SLOT( extraAutoFormat() ),
01173 actionCollection(), "configure_autocorrection" );
01174 m_actionAutoFormat->setToolTip( i18n( "Change autocorrection options." ) );
01175 m_actionAutoFormat->setWhatsThis( i18n( "Change autocorrection options including:<p> <UL><LI><P>exceptions to autocorrection</P> <LI><P>add/remove autocorrection replacement text</P> <LI><P>and basic autocorrection options</P>." ) );
01176
01177 m_actionEditCustomVarsEdit = new KAction( i18n( "Custom &Variables..." ), 0,
01178 this, SLOT( editCustomVars() ),
01179 actionCollection(), "custom_vars" );
01180
01181 m_actionEditPersonnalExpr=new KAction( i18n( "Edit &Personal Expressions..." ), 0,
01182 this, SLOT( editPersonalExpr() ),
01183 actionCollection(), "personal_expr" );
01184 m_actionEditPersonnalExpr->setToolTip( i18n( "Add or change one or more personal expressions." ) );
01185 m_actionEditPersonnalExpr->setWhatsThis( i18n( "Add or change one or more personal expressions.<p>Personal expressions are a way to quickly insert commonly used phrases or text into your document." ) );
01186
01187 m_actionChangeCase=new KAction( i18n( "Change Case..." ), 0,
01188 this, SLOT( changeCaseOfText() ),
01189 actionCollection(), "change_case" );
01190 m_actionChangeCase->setToolTip( i18n( "Alter the capitalization of selected text." ) );
01191 m_actionChangeCase->setWhatsThis( i18n( "Alter the capitalization of selected text to one of five pre-defined patterns.<p>You can also switch all letters from upper case to lower case and from lower case to upper case in one move." ) );
01192
01193
01194 m_actionConfigure = KStdAction::preferences(this, SLOT(configure()), actionCollection(), "configure" );
01195
01196
01197 KAction *actionChangePicture=new KAction( i18n( "Change Picture..." ),"frame_image",0,
01198 this, SLOT( changePicture() ),
01199 actionCollection(), "change_picture" );
01200 actionChangePicture->setToolTip( i18n( "Change the picture in the currently selected frame." ) );
01201 actionChangePicture->setWhatsThis( i18n( "You can specify a different picture in the current frame.<br><br>KWord automatically resizes the new picture to fit within the old frame." ) );
01202
01203 m_actionConfigureHeaderFooter=new KAction( i18n( "Configure Header/Footer..." ), 0,
01204 this, SLOT( configureHeaderFooter() ),
01205 actionCollection(), "configure_headerfooter" );
01206 m_actionConfigureHeaderFooter->setToolTip( i18n( "Configure the currently selected header or footer." ) );
01207 m_actionConfigureHeaderFooter->setWhatsThis( i18n( "Configure the currently selected header or footer." ) );
01208
01209 m_actionInlineFrame = new KToggleAction( i18n( "Inline Frame" ), 0,
01210 this, SLOT( inlineFrame() ),
01211 actionCollection(), "inline_frame" );
01212 m_actionInlineFrame->setToolTip( i18n( "Convert current frame to an inline frame." ) );
01213 m_actionInlineFrame->setWhatsThis( i18n( "Convert the current frame to an inline frame.<br><br>Place the inline frame within the text at the point nearest to the frames current position." ) );
01214
01215 m_actionOpenLink = new KAction( i18n( "Open Link" ), 0,
01216 this, SLOT( openLink() ),
01217 actionCollection(), "open_link" );
01218 m_actionOpenLink->setToolTip( i18n( "Open the link with the appropriate application." ) );
01219 m_actionOpenLink->setWhatsThis( i18n( "Open the link with the appropriate application.<br><br>Web addresses are opened in a browser.<br>Email addresses begin a new message addressed to the link.<br>File links are opened by the appropriate viewer or editor." ) );
01220
01221 m_actionChangeLink=new KAction( i18n("Change Link..."), 0,
01222 this,SLOT(changeLink()),
01223 actionCollection(), "change_link");
01224 m_actionChangeLink->setToolTip( i18n( "Change the content of the currently selected link." ) );
01225 m_actionChangeLink->setWhatsThis( i18n( "Change the details of the currently selected link." ) );
01226
01227 m_actionCopyLink = new KAction( i18n( "Copy Link" ), 0,
01228 this, SLOT( copyLink() ),
01229 actionCollection(), "copy_link" );
01230
01231 m_actionAddLinkToBookmak = new KAction( i18n( "Add to Bookmark" ), 0,
01232 this, SLOT( addToBookmark() ),
01233 actionCollection(), "add_to_bookmark" );
01234
01235 m_actionRemoveLink = new KAction( i18n( "Remove Link" ), 0,
01236 this, SLOT( removeLink() ),
01237 actionCollection(), "remove_link" );
01238
01239 m_actionShowDocStruct = new KToggleAction( i18n( "Show Doc Structure" ), 0,
01240 this, SLOT( showDocStructure() ),
01241 actionCollection(), "show_docstruct" );
01242 m_actionShowDocStruct->setCheckedState(i18n("Hide Doc Structure"));
01243 m_actionShowDocStruct->setToolTip( i18n( "Open document structure sidebar." ) );
01244 m_actionShowDocStruct->setWhatsThis( i18n( "Open document structure sidebar.<p>This sidebar helps you organize your document and quickly find pictures, tables etc." ) );
01245
01246 m_actionShowRuler = new KToggleAction( i18n( "Show Rulers" ), 0,
01247 this, SLOT( showRuler() ),
01248 actionCollection(), "show_ruler" );
01249 m_actionShowRuler->setCheckedState(i18n("Hide Rulers"));
01250 m_actionShowRuler->setToolTip( i18n( "Shows or hides rulers." ) );
01251 m_actionShowRuler->setWhatsThis( i18n("The rulers are the white measuring spaces top and left of the "
01252 "document. The rulers show the position and width of pages and of frames and can "
01253 "be used to position tabulators among others.<p>Uncheck this to disable "
01254 "the rulers from being displayed." ) );
01255
01256 m_actionViewShowGrid = new KToggleAction( i18n( "Show Grid" ), 0,
01257 this, SLOT( viewGrid() ),
01258 actionCollection(), "view_grid" );
01259 m_actionViewShowGrid->setCheckedState(i18n("Hide Grid"));
01260
01261 m_actionViewSnapToGrid= new KToggleAction( i18n( "Snap to Grid" ), 0,
01262 this, SLOT(viewSnapToGrid() ),
01263 actionCollection(), "view_snaptogrid" );
01264
01265 m_actionConfigureCompletion = new KAction( i18n( "Configure C&ompletion..." ), 0,
01266 this, SLOT( configureCompletion() ),
01267 actionCollection(), "configure_completion" );
01268 m_actionConfigureCompletion->setToolTip( i18n( "Change the words and options for autocompletion." ) );
01269 m_actionConfigureCompletion->setWhatsThis( i18n( "Add words or change the options for autocompletion." ) );
01270
01271
01272
01273 new KAction( i18n( "Insert Non-Breaking Space" ), Qt::CTRL+Qt::Key_Space,
01274 this, SLOT( slotNonbreakingSpace() ), actionCollection(), "nonbreaking_space" );
01275 new KAction( i18n( "Insert Non-Breaking Hyphen" ), Qt::CTRL+Qt::SHIFT+Qt::Key_Minus,
01276 this, SLOT( slotNonbreakingHyphen() ), actionCollection(), "nonbreaking_hyphen" );
01277 new KAction( i18n( "Insert Soft Hyphen" ), Qt::CTRL+Qt::Key_Minus,
01278 this, SLOT( slotSoftHyphen() ), actionCollection(), "soft_hyphen" );
01279 new KAction( i18n( "Line Break" ), Qt::SHIFT+Qt::Key_Return,
01280 this, SLOT( slotLineBreak() ), actionCollection(), "line_break" );
01281
01282 new KAction( i18n( "Completion" ), KStdAccel::shortcut(KStdAccel::TextCompletion), this, SLOT( slotCompletion() ), actionCollection(), "completion" );
01283
01284 new KAction( i18n( "Increase Numbering Level" ), Qt::ALT+Qt::Key_Right,
01285 this, SLOT( slotIncreaseNumberingLevel() ), actionCollection(), "increase_numbering_level" );
01286 new KAction( i18n( "Decrease Numbering Level" ), Qt::ALT+Qt::Key_Left,
01287 this, SLOT( slotDecreaseNumberingLevel() ), actionCollection(), "decrease_numbering_level" );
01288
01289
01290
01291 m_actionEditCustomVars = new KAction( i18n( "Edit Variable..." ), 0,
01292 this, SLOT( editCustomVariable() ),
01293 actionCollection(), "edit_customvars" );
01294 m_actionApplyAutoFormat= new KAction( i18n( "Apply Autocorrection" ), 0,
01295 this, SLOT( applyAutoFormat() ),
01296 actionCollection(), "apply_autoformat" );
01297 m_actionApplyAutoFormat->setToolTip( i18n( "Manually force KWord to scan the entire document and apply autocorrection." ) );
01298 m_actionApplyAutoFormat->setWhatsThis( i18n( "Manually force KWord to scan the entire document and apply autocorrection." ) );
01299
01300 m_actionCreateStyleFromSelection = new KAction( i18n( "Create Style From Selection..." ), 0,
01301 this, SLOT( createStyleFromSelection()),
01302 actionCollection(), "create_style" );
01303 m_actionCreateStyleFromSelection->setToolTip( i18n( "Create a new style based on the currently selected text." ) );
01304 m_actionCreateStyleFromSelection->setWhatsThis( i18n( "Create a new style based on the currently selected text." ) );
01305
01306 m_actionConfigureFootEndNote = new KAction( i18n( "&Footnote..." ), 0,
01307 this, SLOT( configureFootEndNote()),
01308 actionCollection(), "format_footendnote" );
01309 m_actionConfigureFootEndNote->setToolTip( i18n( "Change the look of footnotes." ) );
01310 m_actionConfigureFootEndNote->setWhatsThis( i18n( "Change the look of footnotes." ) );
01311
01312 m_actionEditFootEndNote= new KAction( i18n("Edit Footnote"), 0,
01313 this, SLOT( editFootEndNote()),
01314 actionCollection(), "edit_footendnote" );
01315 m_actionEditFootEndNote->setToolTip( i18n( "Change the content of the currently selected footnote." ) );
01316 m_actionEditFootEndNote->setWhatsThis( i18n( "Change the content of the currently selected footnote." ) );
01317
01318
01319 m_actionChangeFootNoteType = new KAction( i18n("Change Footnote/Endnote Parameter"), 0,
01320 this, SLOT( changeFootNoteType() ),
01321 actionCollection(), "change_footendtype");
01322
01323 m_actionSavePicture= new KAction( i18n("Save Picture As..."), 0,
01324 this, SLOT( savePicture() ),
01325 actionCollection(), "save_picture");
01326 m_actionSavePicture->setToolTip( i18n( "Save the picture in a separate file." ) );
01327 m_actionSavePicture->setWhatsThis( i18n( "Save the picture in the currently selected frame in a separate file, outside the KWord document." ) );
01328
01329 m_actionAllowBgSpellCheck = new KToggleAction( i18n( "Autospellcheck" ), 0,
01330 this, SLOT( autoSpellCheck() ),
01331 actionCollection(), "tool_auto_spellcheck" );
01332
01333
01334 m_actionGoToFootEndNote = new KAction( QString::null , 0,
01335 this, SLOT( goToFootEndNote() ),
01336 actionCollection(), "goto_footendnote" );
01337
01338
01339 m_actionDocStructEdit = new KAction( i18n( "Edit Text" ), 0,
01340 this, SLOT( docStructEdit() ),
01341 actionCollection(), "docstruct_edit" );
01342 m_actionDocStructSpeak = new KAction( i18n("Speak Text" ), 0,
01343 this, SLOT( docStructSpeak() ),
01344 actionCollection(), "docstruct_speak" );
01345 m_actionDocStructSelect = new KAction( i18n( "Show" ), 0,
01346 this, SLOT( docStructSelect() ),
01347 actionCollection(), "docstruct_select" );
01348 m_actionDocStructDelete = new KAction( i18n( "Delete Frame" ), 0,
01349 this, SLOT( docStructDelete() ),
01350 actionCollection(), "docstruct_delete" );
01351 m_actionDocStructProperties = new KAction( i18n( "Properties" ), 0,
01352 this, SLOT( docStructProperties() ),
01353 actionCollection(), "docstruct_properties" );
01354
01355 m_actionAddBookmark= new KAction( i18n( "&Bookmark..." ), 0,
01356 this, SLOT( addBookmark() ),
01357 actionCollection(), "add_bookmark" );
01358 m_actionSelectBookmark= new KAction( i18n( "Select &Bookmark..." ), 0,
01359 this, SLOT( selectBookmark() ),
01360 actionCollection(), "select_bookmark" );
01361
01362 m_actionImportStyle= new KAction( i18n( "Import Styles..." ), 0,
01363 this, SLOT( importStyle() ),
01364 actionCollection(), "import_style" );
01365
01366 m_actionCreateFrameStyle = new KAction( i18n( "&Create Framestyle From Frame..." ), 0,
01367 this, SLOT( createFrameStyle()),
01368 actionCollection(), "create_framestyle" );
01369 m_actionCreateFrameStyle->setToolTip( i18n( "Create a new style based on the currently selected frame." ) );
01370 m_actionCreateFrameStyle->setWhatsThis( i18n( "Create a new framestyle based on the currently selected frame." ) );
01371
01372 #if 0 // re-enable after fixing
01373 m_actionInsertDirectCursor = new KToggleAction( i18n( "Type Anywhere Cursor" ), 0,
01374 this, SLOT( insertDirectCursor() ),
01375 actionCollection(), "direct_cursor" );
01376 #endif
01377
01378 m_actionConvertToTextBox = new KAction( i18n( "Convert to Text Box" ), 0,
01379 this, SLOT( convertToTextBox() ),
01380 actionCollection(), "convert_to_text_box" );
01381
01382
01383 m_actionSpellIgnoreAll = new KAction( i18n( "Ignore All" ), 0,
01384 this, SLOT( slotAddIgnoreAllWord() ),
01385 actionCollection(), "ignore_all" );
01386
01387 m_actionAddWordToPersonalDictionary=new KAction( i18n( "Add Word to Dictionary" ),0,
01388 this, SLOT( addWordToDictionary() ),
01389 actionCollection(), "add_word_to_dictionary" );
01390
01391 m_actionEmbeddedStoreInternal=new KToggleAction( i18n( "Store Document Internally" ),0,
01392 this, SLOT( embeddedStoreInternal() ),
01393 actionCollection(), "embedded_store_internal" );
01394
01395 m_actionGoToDocumentStructure=new KAction( i18n( "Go to Document Structure" ), KShortcut("Alt+1"),
01396 this, SLOT( goToDocumentStructure() ),
01397 actionCollection(), "goto_document_structure" );
01398 m_actionGoToDocument=new KAction( i18n( "Go to Document" ), KShortcut("Alt+2"),
01399 this, SLOT( goToDocument() ),
01400 actionCollection(), "goto_document" );
01401
01402
01403
01404
01405 m_tableActionList.append( new KActionSeparator(actionCollection()) );
01406 m_tableActionList.append( m_actionTableInsertRow );
01407 m_tableActionList.append( m_actionTableDelRow );
01408 m_tableActionList.append( m_actionTableInsertCol );
01409 m_tableActionList.append( m_actionTableDelCol );
01410 }
01411
01412 void KWView::refreshMenuExpression()
01413 {
01414 loadexpressionActions( m_actionInsertExpression);
01415 }
01416
01417 void KWView::updateGridButton()
01418 {
01419 m_actionViewShowGrid->setChecked( m_doc->showGrid() );
01420 m_actionViewSnapToGrid->setChecked ( m_doc->snapToGrid() );
01421 }
01422
01423 void KWView::loadexpressionActions( KActionMenu * parentMenu)
01424 {
01425 KActionPtrList lst = actionCollection()->actions("expression-action");
01426 QValueList<KAction *> actions = lst;
01427 QValueList<KAction *>::ConstIterator it = lst.begin();
01428 QValueList<KAction *>::ConstIterator end = lst.end();
01429
01430 QMap<QString, KShortcut> personalShortCuts;
01431 for (; it != end; ++it )
01432 {
01433 personalShortCuts.insert( (*it)->text(), (*it)->shortcut() );
01434 delete *it;
01435 }
01436
01437 parentMenu->popupMenu()->clear();
01438 QStringList path = m_doc->personalExpressionPath();
01439 QStringList files;
01440 for ( QStringList::Iterator it = path.begin(); it != path.end(); ++it )
01441 {
01442 QDir dir( *it );
01443 if ( dir.exists() )
01444 {
01445 QStringList tmp = dir.entryList("*.xml");
01446 for ( QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2 )
01447 files.append( QString( (*it) + (*it2) ));
01448 }
01449 }
01450
01451
01452 int i = 0;
01453 int nbFile = 0;
01454 for( QStringList::Iterator it = files.begin(); it != files.end(); ++it,nbFile++ )
01455 createExpressionActions( parentMenu,*it, i,(nbFile<(int)files.count()-1), personalShortCuts );
01456 }
01457
01458 void KWView::createExpressionActions( KActionMenu * parentMenu,const QString& filename,int &i, bool insertSepar, const QMap<QString, KShortcut>& personalShortCut )
01459 {
01460 QFile file( filename );
01461 if ( !file.exists() || !file.open( IO_ReadOnly ) )
01462 return;
01463
01464 QDomDocument doc;
01465 doc.setContent( &file );
01466 file.close();
01467
01468 bool expressionExist =false;
01469 QDomNode n = doc.documentElement().firstChild();
01470 for( ; !n.isNull(); n = n.nextSibling() )
01471 {
01472 if ( n.isElement() )
01473 {
01474 QDomElement e = n.toElement();
01475 if ( e.tagName() == "Type" )
01476 {
01477 expressionExist =true;
01478 QString group = i18n( e.namedItem( "TypeName" ).toElement().text().utf8() );
01479 KActionMenu * subMenu = new KActionMenu( group, actionCollection() );
01480 parentMenu->insert( subMenu );
01481
01482 QDomNode n2 = e.firstChild();
01483 for( ; !n2.isNull(); n2 = n2.nextSibling() )
01484 {
01485
01486 if ( n2.isElement() )
01487 {
01488 QDomElement e2 = n2.toElement();
01489 if ( e2.tagName() == "Expression" )
01490 {
01491 QString text = i18n( e2.namedItem( "Text" ).toElement().text().utf8() );
01492 KAction * act = new KAction( text, 0, this, SLOT( insertExpression() ),
01493 actionCollection(),
01494 QString("expression-action_%1").arg(i).latin1() );
01495 if ( personalShortCut.contains(text) )
01496 act->setShortcut( personalShortCut[text] );
01497 i++;
01498 act->setGroup("expression-action");
01499 subMenu->insert( act );
01500 }
01501 }
01502 }
01503 }
01504 }
01505 }
01506 if(expressionExist && insertSepar)
01507 parentMenu->popupMenu()->insertSeparator();
01508 }
01509
01510 void KWView::insertExpression()
01511 {
01512 KWTextFrameSetEdit * edit = currentTextEdit();
01513 if ( edit )
01514 {
01515 KAction * act = (KAction *)(sender());
01516 edit->insertExpression(act->text());
01517 }
01518 }
01519
01520
01521 void KWView::addVariableActions( int type, const QStringList & texts,
01522 KActionMenu * parentMenu, const QString & menuText )
01523 {
01524
01525
01526 if ( texts.count() > 1 && !menuText.isEmpty() )
01527 {
01528 KActionMenu * subMenu = new KActionMenu( menuText, actionCollection() );
01529 parentMenu->insert( subMenu );
01530 parentMenu = subMenu;
01531 }
01532 QStringList::ConstIterator it = texts.begin();
01533 for ( int i = 0; it != texts.end() ; ++it, ++i )
01534 {
01535 if ( !(*it).isEmpty() )
01536 {
01537 VariableDef v;
01538 v.type = type;
01539 v.subtype = i;
01540 QCString actionName;
01541 actionName.sprintf( "var-action-%d-%d", type, i );
01542 KAction * act = new KAction( (*it), 0, this, SLOT( insertVariable() ),
01543 actionCollection(), actionName );
01544
01545 act->setToolTip( i18n( "Insert variable \"%1\" into the text" ).arg( *it ) );
01546 m_variableDefMap.insert( act, v );
01547 parentMenu->insert( act );
01548 }
01549 }
01550 }
01551
01552 void KWView::refreshCustomMenu()
01553 {
01554 KActionPtrList lst2 = actionCollection()->actions("custom-variable-action");
01555 QValueList<KAction *> actions = lst2;
01556 QValueList<KAction *>::ConstIterator it2 = lst2.begin();
01557 QValueList<KAction *>::ConstIterator end = lst2.end();
01558 QMap<QString, KShortcut> shortCuts;
01559
01560 for (; it2 != end; ++it2 )
01561 {
01562 shortCuts.insert((*it2)->text(), (*it2)->shortcut());
01563 delete *it2;
01564 }
01565
01566 delete m_actionInsertCustom;
01567 m_actionInsertCustom = new KActionMenu( i18n( "&Custom" ),
01568 actionCollection(), "insert_custom" );
01569 actionInsertVariable->insert(m_actionInsertCustom, 0);
01570
01571 m_actionInsertCustom->popupMenu()->clear();
01572 QPtrListIterator<KoVariable> it( m_doc->variableCollection()->getVariables() );
01573 KAction * act=0;
01574 QStringList lst;
01575 QString varName;
01576 int i = 0;
01577 for ( ; it.current() ; ++it )
01578 {
01579 KoVariable *var = it.current();
01580 if ( var->type() == VT_CUSTOM )
01581 {
01582 varName=( (KoCustomVariable*) var )->name();
01583 if ( !lst.contains( varName) )
01584 {
01585 lst.append( varName );
01586 QCString name = QString("custom-action_%1").arg(i).latin1();
01587 act = new KAction( varName, shortCuts[varName], this, SLOT( insertCustomVariable() ),actionCollection(), name );
01588 act->setGroup( "custom-variable-action" );
01589 m_actionInsertCustom->insert( act );
01590 i++;
01591 }
01592 }
01593 }
01594 bool state=!lst.isEmpty();
01595 if(state)
01596 m_actionInsertCustom->popupMenu()->insertSeparator();
01597
01598 act = new KAction( i18n("New..."), 0, this, SLOT( insertNewCustomVariable() ), actionCollection(),QString("custom-action_%1").arg(i).latin1());
01599 act->setGroup( "custom-variable-action" );
01600
01601
01602 m_actionEditCustomVarsEdit->setEnabled( state );
01603
01604 m_actionInsertCustom->insert( act );
01605
01606 }
01607
01608
01609 void KWView::insertCustomVariable()
01610 {
01611 KWTextFrameSetEdit * edit = currentTextEdit();
01612 if ( edit )
01613 {
01614 KAction * act = (KAction *)(sender());
01615 edit->insertCustomVariable(act->text());
01616 }
01617 }
01618
01619 void KWView::insertNewCustomVariable()
01620 {
01621 KWTextFrameSetEdit * edit = currentTextEdit();
01622 if ( edit )
01623 edit->insertVariable( VT_CUSTOM, 0 );
01624 }
01625
01626 void KWView::showFormulaToolbar( bool show )
01627 {
01628 m_doc->formulaDocument()->setEnabled( show );
01629 m_doc->formulaDocumentWrapper()->enableMatrixActions( show );
01630 m_doc->formulaDocumentWrapper()->getSyntaxHighlightingAction()->setEnabled( true );
01631 if(shell())
01632 shell()->showToolbar( "formula_toolbar", show );
01633 }
01634
01635 void KWView::updatePageInfo()
01636 {
01637 if ( m_sbPageLabel )
01638 {
01639 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
01640 if ( edit && edit->currentFrame() )
01641 m_currentPage = m_doc->pageManager()->page(edit->currentFrame());
01642 else {
01643 KWFrameView *view = frameViewManager()->selectedFrame();
01644 if(view)
01645 m_currentPage = m_doc->pageManager()->page(view->frame());
01646 }
01647
01648
01649
01650
01651
01652
01653 QString oldText = m_sbPageLabel->text();
01654 QString newText;
01655 if ( viewMode()->hasPages() )
01656 newText = ' ' + i18n( "Page %1 of %2" ).arg(m_currentPage->pageNumber())
01657 .arg(m_doc->pageCount()) + ' ';
01658
01659 if ( newText != oldText )
01660 {
01661 m_sbPageLabel->setText( newText );
01662
01663
01664 m_sbPageLabel->repaint();
01665 }
01666 }
01667 slotUpdateRuler();
01668 }
01669
01670 void KWView::numPagesChanged()
01671 {
01672 docStructChanged(TextFrames);
01673 updatePageInfo();
01674 int pages = m_doc->pageCount();
01675 kdDebug() << pages << " " << (m_doc->processingType() == KWDocument::DTP) << endl;
01676 refreshDeletePageAction();
01677 }
01678
01679 void KWView::updateFrameStatusBarItem()
01680 {
01681 KStatusBar * sb = statusBar();
01682 int nbFrame=frameViewManager()->selectedFrames().count();
01683 if ( m_doc->showStatusBar() && sb && nbFrame > 0 )
01684 {
01685 if ( nbFrame == 1 )
01686 {
01687 KoUnit::Unit unit = m_doc->unit();
01688 QString unitName = m_doc->unitName();
01689 KWFrame * frame = frameViewManager()->selectedFrames()[0]->frame();
01690 m_sbFramesLabel->setText( ' ' + i18n( "Statusbar info", "%1: %2, %3 - %4, %5 (width: %6, height: %7)" )
01691 .arg( frame->frameSet()->name() )
01692 .arg( KoUnit::toUserStringValue( frame->left(), unit ) )
01693 .arg( KoUnit::toUserStringValue( frame->top() - m_doc->pageManager()->topOfPage(
01694 m_doc->pageManager()->pageNumber(frame->rect()) ), unit) )
01695 .arg( KoUnit::toUserStringValue( frame->right(), unit ) )
01696 .arg( KoUnit::toUserStringValue( frame->bottom(), unit ) )
01697 .arg( KoUnit::toUserStringValue( frame->width(), unit ) )
01698 .arg( KoUnit::toUserStringValue( frame->height(), unit ) ) );
01699 } else
01700 m_sbFramesLabel->setText( ' ' + i18n( "%1 frames selected" ).arg( nbFrame ) );
01701 }
01702 else if ( sb && m_sbFramesLabel )
01703 m_sbFramesLabel->setText( QString::null );
01704 }
01705
01706 void KWView::setTemporaryStatusBarText(const QString &text)
01707 {
01708 if ( statusBar() && m_sbFramesLabel )
01709 m_sbFramesLabel->setText( text );
01710 }
01711
01712 void KWView::clipboardDataChanged()
01713 {
01714 if ( !m_gui || !m_doc->isReadWrite() )
01715 {
01716 m_actionEditPaste->setEnabled(false);
01717 return;
01718 }
01719 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
01720
01721 if ( edit && !QApplication::clipboard()->text().isEmpty() )
01722 {
01723 m_actionEditPaste->setEnabled(true);
01724 return;
01725 }
01726 QMimeSource *data = QApplication::clipboard()->data();
01727 const int provides = checkClipboard( data );
01728 if ( provides & ( ProvidesImage | ProvidesOasis | ProvidesFormula ) )
01729 m_actionEditPaste->setEnabled( true );
01730 else
01731 {
01732
01733 m_actionEditPaste->setEnabled( edit && ( provides & ProvidesPlainText ) );
01734 }
01735 }
01736
01737 int KWView::checkClipboard( QMimeSource *data )
01738 {
01739 int provides = 0;
01740 QValueList<QCString> formats;
01741 const char* fmt;
01742 for (int i=0; (fmt = data->format(i)); i++)
01743 formats.append( QCString( fmt ) );
01744
01745 if ( QImageDrag::canDecode( data ) )
01746 provides |= ProvidesImage;
01747 if ( formats.findIndex( KFormula::MimeSource::selectionMimeType() ) != -1 )
01748 provides |= ProvidesFormula;
01749 if ( formats.findIndex( "text/plain" ) != -1 )
01750 provides |= ProvidesPlainText;
01751 QCString returnedTypeMime = KoTextObject::providesOasis( data );
01752 if ( !returnedTypeMime.isEmpty() )
01753 provides |= ProvidesOasis;
01754
01755 return provides;
01756 }
01757
01758
01759 void KWView::setupPrinter( KPrinter &prt )
01760 {
01761
01762
01763
01764
01765 m_doc->recalcVariables( VT_TIME );
01766 m_doc->recalcVariables( VT_DATE );
01767 m_doc->recalcVariables( VT_STATISTIC );
01768
01769 prt.setPageSelection( KPrinter::ApplicationSide );
01770 prt.setCurrentPage( currentPage() );
01771 prt.setMinMax( m_doc->startPage(), m_doc->lastPage() );
01772
01773 KoPageLayout pgLayout = m_doc->pageLayout();
01774
01775 prt.setPageSize( static_cast<KPrinter::PageSize>( KoPageFormat::printerPageSize( pgLayout.format ) ) );
01776
01777 if ( pgLayout.orientation == PG_LANDSCAPE || pgLayout.format == PG_SCREEN )
01778 prt.setOrientation( KPrinter::Landscape );
01779 else
01780 prt.setOrientation( KPrinter::Portrait );
01781 }
01782
01783 void KWView::print( KPrinter &prt )
01784 {
01785 bool displayFieldCode = m_doc->variableCollection()->variableSetting()->displayFieldCode();
01786 if ( displayFieldCode )
01787 {
01788 m_doc->variableCollection()->variableSetting()->setDisplayFieldCode(false);
01789 m_doc->recalcVariables( VT_ALL );
01790 }
01791
01792
01793 m_gui->canvasWidget()->setUpdatesEnabled(false);
01794 m_gui->canvasWidget()->viewport()->setCursor( waitCursor );
01795
01796 prt.setFullPage( true );
01797
01798
01799
01800
01801 bool doZoom = false;
01802
01803
01804
01805
01806
01807 int oldZoom = m_doc->zoom();
01808
01809
01810 QPaintDeviceMetrics metrics( &prt );
01811
01812
01813
01814 int dpiX = doZoom ? 300 : KoGlobal::dpiX();
01815 int dpiY = doZoom ? 300 : KoGlobal::dpiY();
01818 m_doc->setZoomAndResolution( 100, dpiX, dpiY );
01819 m_doc->newZoomAndResolution( false, true );
01820
01821
01822
01823 bool serialLetter = FALSE;
01824
01825 QPtrList<KoVariable> vars = m_doc->variableCollection()->getVariables();
01826 KoVariable *v = 0;
01827 for ( v = vars.first(); v; v = vars.next() ) {
01828 if ( v->type() == VT_MAILMERGE ) {
01829 serialLetter = TRUE;
01830 break;
01831 }
01832 }
01833
01834 if ( !m_doc->mailMergeDataBase() ) serialLetter=FALSE;
01835 else
01836 {
01837 m_doc->mailMergeDataBase()->refresh(false);
01838 if (m_doc->mailMergeDataBase()->getNumRecords() == 0 ) serialLetter = FALSE;
01839 }
01840
01841
01842
01843
01844 KoPageLayout pgLayout;
01845 KoColumns cl;
01846 KoKWHeaderFooter hf;
01847 m_doc->getPageLayout( pgLayout, cl, hf );
01848 KoPageLayout oldPGLayout = pgLayout;
01849
01850 if ( pgLayout.format == PG_SCREEN )
01851 {
01852
01853
01854 pgLayout.ptLeft += 25.8;
01855 pgLayout.ptRight += 15.0;
01856 m_doc->setPageLayout( pgLayout, cl, hf, false );
01857 }
01858
01859 QPainter painter;
01860 painter.begin( &prt );
01861
01862 kdDebug(32001) << "KWView::print scaling by " << (double)metrics.logicalDpiX() / (double)dpiX
01863 << "," << (double)metrics.logicalDpiY() / (double)dpiY << endl;
01864 painter.scale( (double)metrics.logicalDpiX() / (double)dpiX,
01865 (double)metrics.logicalDpiY() / (double)dpiY );
01866
01867 bool canceled = false;
01868
01869
01870 #ifdef KW_PASS_PAINTER_TO_QRT
01871 int paragraphs = 0;
01872 fit.toFirst();
01873 for ( ; fit.current() ; ++fit )
01874 if ( fit.current()->isVisible() )
01875 paragraphs += fit.current()->paragraphs();
01876 kdDebug() << "KWView::print total paragraphs: " << paragraphs << endl;
01877
01878
01879 QProgressDialog progress( i18n( "Printing..." ), i18n( "Cancel" ), paragraphs, this );
01880 progress.setProgress( 0 );
01881 int processedParags = 0;
01882 fit.toFirst();
01883 for ( ; fit.current() ; ++fit )
01884 if ( fit.current()->isVisible() )
01885 {
01886 qApp->processEvents();
01887 if ( progress.wasCancelled() ) {
01888 canceled = true;
01889 break;
01890 }
01891
01892 kdDebug() << "KWView::print preparePrinting " << fit.current()->name() << endl;
01893 fit.current()->preparePrinting( &painter, &progress, processedParags );
01894 }
01895 #endif
01896
01897 if ( !canceled )
01898 {
01899 if ( !serialLetter )
01900 m_gui->canvasWidget()->print( &painter, &prt );
01901 else
01902 {
01903 for ( int i = 0; i < m_doc->mailMergeDataBase()->getNumRecords(); ++i ) {
01904 m_doc->setMailMergeRecord( i );
01905 m_doc->variableCollection()->recalcVariables(VT_MAILMERGE);
01906 m_gui->canvasWidget()->print( &painter, &prt );
01907 if ( i < m_doc->mailMergeDataBase()->getNumRecords() - 1 )
01908 prt.newPage();
01909 }
01910 m_doc->setMailMergeRecord( -1 );
01911 }
01912 }
01913
01914 if ( pgLayout.format == PG_SCREEN )
01915 m_doc->setPageLayout( oldPGLayout, cl, hf, false );
01916
01917 #ifdef KW_PASS_PAINTER_TO_QRT
01918 fit.toFirst();
01919 for ( ; fit.current() ; ++fit )
01920 if ( fit.current()->isVisible() )
01921 fit.current()->preparePrinting( 0L, 0L, processedParags );
01922 #endif
01923
01924 m_doc->setZoomAndResolution( oldZoom, KoGlobal::dpiX(), KoGlobal::dpiY() );
01925 m_doc->newZoomAndResolution( false, false );
01926 kdDebug() << "KWView::print zoom&res reset" << endl;
01927
01928 m_gui->canvasWidget()->setUpdatesEnabled(true);
01929 m_gui->canvasWidget()->viewport()->setCursor( ibeamCursor );
01930 m_doc->repaintAllViews();
01931
01932 if ( displayFieldCode )
01933 {
01934 m_doc->variableCollection()->variableSetting()->setDisplayFieldCode(true);
01935 m_doc->recalcVariables( VT_ALL );
01936 }
01937 else
01938 m_doc->variableCollection()->recalcVariables(VT_MAILMERGE);
01939
01940 painter.end();
01941 m_doc->variableCollection()->variableSetting()->setLastPrintingDate(QDateTime::currentDateTime());
01942 m_doc->recalcVariables( VT_DATE );
01943 }
01944
01945 void KWView::showFormat( const KoTextFormat ¤tFormat )
01946 {
01947
01948
01949 if (m_actionFormatFontFamily->font() != currentFormat.font().family())
01950 m_actionFormatFontFamily->setFont( currentFormat.font().family() );
01951 if (m_actionFormatFontSize->fontSize() != currentFormat.pointSize())
01952 m_actionFormatFontSize->setFontSize( currentFormat.pointSize() );
01953 m_actionFormatBold->setChecked( currentFormat.font().bold());
01954 m_actionFormatItalic->setChecked( currentFormat.font().italic() );
01955 m_actionFormatUnderline->setChecked( currentFormat.underline());
01956 m_actionFormatStrikeOut->setChecked( currentFormat.strikeOut());
01957 QColor col=currentFormat.textBackgroundColor();
01958
01959 m_actionBackgroundColor->setCurrentColor( col.isValid() ? col : QApplication::palette().color( QPalette::Active, QColorGroup::Base ));
01960
01961 if ( m_gui && frameViewManager()->selectedFrames().count() > 0)
01962 m_actionBackgroundColor->setText(i18n("Frame Background Color..."));
01963 else
01964 m_actionBackgroundColor->setText(i18n("Text Background Color..."));
01965 switch(currentFormat.vAlign())
01966 {
01967 case KoTextFormat::AlignSuperScript:
01968 {
01969 m_actionFormatSub->setChecked( false );
01970 m_actionFormatSuper->setChecked( true );
01971 break;
01972 }
01973 case KoTextFormat::AlignSubScript:
01974 {
01975 m_actionFormatSub->setChecked( true );
01976 m_actionFormatSuper->setChecked( false );
01977 break;
01978 }
01979 case KoTextFormat::AlignNormal:
01980 default:
01981 {
01982 m_actionFormatSub->setChecked( false );
01983 m_actionFormatSuper->setChecked( false );
01984 break;
01985 }
01986 }
01987
01988 }
01989
01990 void KWView::showRulerIndent( double leftMargin, double firstLine, double rightMargin, bool rtl )
01991 {
01992 KoRuler * hRuler = m_gui ? m_gui->getHorzRuler() : 0;
01993 if ( hRuler )
01994 {
01995 hRuler->setFirstIndent( KoUnit::toUserValue( firstLine, m_doc->unit() ) );
01996 hRuler->setLeftIndent( KoUnit::toUserValue( leftMargin, m_doc->unit() ) );
01997 hRuler->setRightIndent( KoUnit::toUserValue( rightMargin, m_doc->unit() ) );
01998 hRuler->setDirection( rtl );
01999 m_actionFormatDecreaseIndent->setEnabled( leftMargin>0);
02000 }
02001 }
02002
02003 void KWView::showAlign( int align ) {
02004 switch ( align ) {
02005 case Qt::AlignAuto:
02006 kdWarning() << k_funcinfo << "shouldn't be called with AlignAuto" << endl;
02007
02008 case Qt::AlignLeft:
02009 m_actionFormatAlignLeft->setChecked( TRUE );
02010 break;
02011 case Qt::AlignHCenter:
02012 m_actionFormatAlignCenter->setChecked( TRUE );
02013 break;
02014 case Qt::AlignRight:
02015 m_actionFormatAlignRight->setChecked( TRUE );
02016 break;
02017 case Qt::AlignJustify:
02018 m_actionFormatAlignBlock->setChecked( TRUE );
02019 break;
02020 }
02021 }
02022
02023 void KWView::showSpacing( int spacing ) {
02024 switch ( spacing )
02025 {
02026 case KoParagLayout::LS_SINGLE:
02027 m_actionFormatSpacingSingle->setChecked( TRUE );
02028 break;
02029 case KoParagLayout::LS_ONEANDHALF:
02030 m_actionFormatSpacingOneAndHalf->setChecked( TRUE );
02031 break;
02032 case KoParagLayout::LS_DOUBLE:
02033 m_actionFormatSpacingDouble->setChecked( TRUE );
02034 break;
02035 default:
02036 m_actionFormatSpacingSingle->setChecked( FALSE );
02037 m_actionFormatSpacingOneAndHalf->setChecked( FALSE );
02038 m_actionFormatSpacingDouble->setChecked( FALSE );
02039 }
02040 }
02041
02042 void KWView::showCounter( KoParagCounter &c )
02043 {
02044 QString styleStr("counterstyle_");
02045 styleStr += QString::number( c.style() );
02046
02047 KToggleAction* act = static_cast<KToggleAction *>( actionCollection()->action( styleStr.latin1() ) );
02048 Q_ASSERT( act );
02049 if ( act )
02050 act->setChecked( true );
02051 }
02052
02053 void KWView::updateBorderButtons( const KoBorder& left, const KoBorder& right,
02054 const KoBorder& top, const KoBorder& bottom )
02055 {
02056 m_actionBorderLeft->setChecked( left.penWidth() > 0 );
02057 m_actionBorderRight->setChecked( right.penWidth() > 0 );
02058 m_actionBorderTop->setChecked( top.penWidth() > 0 );
02059 m_actionBorderBottom->setChecked( bottom.penWidth() > 0 );
02060 m_actionBorderOutline->setChecked(
02061 m_actionBorderLeft->isChecked() &&
02062 m_actionBorderRight->isChecked() &&
02063 m_actionBorderTop->isChecked() &&
02064 m_actionBorderBottom->isChecked());
02065
02066 KoBorder border = left;
02067 if(left.penWidth() > 0)
02068 border = left;
02069 else if(right.penWidth() > 0)
02070 border = right;
02071 else if(top.penWidth() > 0)
02072 border = top;
02073 else if(bottom.penWidth() > 0)
02074 border = bottom;
02075 else
02076 return;
02077
02078 m_actionBorderWidth->setCurrentItem( (int)border.penWidth() - 1 );
02079 m_actionBorderStyle->setCurrentItem( (int)border.getStyle() );
02080 m_actionBorderColor->setCurrentColor( border.color );
02081 }
02082
02083 void KWView::updateReadWrite( bool readwrite )
02084 {
02085
02086 QValueList<KAction*> actions = actionCollection()->actions();
02087
02088 actions += m_doc->actionCollection()->actions();
02089 QValueList<KAction*>::ConstIterator aIt = actions.begin();
02090 QValueList<KAction*>::ConstIterator aEnd = actions.end();
02091 for (; aIt != aEnd; ++aIt )
02092 (*aIt)->setEnabled( readwrite );
02093
02094 if ( !readwrite )
02095 {
02096
02097 m_actionFileStatistics->setEnabled( true );
02098 m_actionExtraCreateTemplate->setEnabled( true );
02099 m_actionViewPageMode->setEnabled( true );
02100 m_actionViewPreviewMode->setEnabled( true );
02101
02102 m_actionViewTextMode->setEnabled( true );
02103 m_actionShowRuler->setEnabled( true );
02104 m_actionEditFind->setEnabled( true );
02105 m_actionViewFormattingChars->setEnabled( true );
02106 m_actionViewFrameBorders->setEnabled( true );
02107
02108
02109
02110 m_actionViewZoom->setEnabled( true );
02111 m_actionInsertComment->setEnabled( true );
02112 m_actionAllowAutoFormat->setEnabled( true );
02113 m_actionShowDocStruct->setEnabled( true );
02114 m_actionConfigureCompletion->setEnabled( true );
02115 m_actionFormatBullet->setEnabled(true);
02116 m_actionFormatNumber->setEnabled( true);
02117 m_actionSelectBookmark->setEnabled( true );
02118 KAction* act = actionCollection()->action("edit_sldatabase");
02119 if (act)
02120 act->setEnabled( true );
02121
02122
02123
02124
02125
02126
02127 }
02128 else
02129 {
02130 frameSelectedChanged();
02131 slotFrameSetEditChanged();
02132 refreshCustomMenu();
02133 refreshDeletePageAction();
02134
02135 m_doc->commandHistory()->updateActions();
02136 }
02137 }
02138
02139 void KWView::refreshDeletePageAction()
02140 {
02141 m_actionDeletePage->setEnabled( m_doc->pageCount() > 1 && m_doc->processingType() == KWDocument::DTP );
02142 }
02143
02144 void KWView::showMouseMode( int mouseMode )
02145 {
02146 switch ( mouseMode ) {
02147 case KWCanvas::MM_EDIT:
02148 case KWCanvas::MM_CREATE_TABLE:
02149 case KWCanvas::MM_CREATE_FORMULA:
02150 case KWCanvas::MM_CREATE_PART:
02151
02152 m_actionToolsCreateText->setChecked( false );
02153 m_actionToolsCreatePix->setChecked( false );
02154
02155 break;
02156 case KWCanvas::MM_CREATE_TEXT:
02157 m_actionToolsCreateText->setChecked( true );
02158 break;
02159 case KWCanvas::MM_CREATE_PIX:
02160 m_actionToolsCreatePix->setChecked( true );
02161 break;
02162
02163
02164 break;
02165 }
02166
02167 m_actionTableJoinCells->setEnabled( FALSE );
02168 m_actionTableSplitCells->setEnabled( FALSE );
02169 m_actionTableProtectCells->setEnabled( false );
02170 m_actionFormatFrameSet->setEnabled(FALSE);
02171 m_actionTablePropertiesMenu->setEnabled( false );
02172 m_actionConvertTableToText->setEnabled( false );
02173 }
02174
02175 void KWView::showStyle( const QString & styleName )
02176 {
02177 KoParagStyle* style = m_doc->styleCollection()->findStyle( styleName );
02178 if ( style ) {
02179 int pos = m_doc->styleCollection()->indexOf( style );
02180
02181 m_actionFormatStyle->setCurrentItem( pos );
02182
02183 KToggleAction* act = dynamic_cast<KToggleAction *>(actionCollection()->action(style->name().utf8()));
02184 if ( act )
02185 act->setChecked( true );
02186 }
02187 }
02188
02189
02190 static const char* PARAGSTYLE_ACTION_PREFIX = "paragstyle_";
02191 static const char* FRAMESTYLE_ACTION_PREFIX = "framestyle_";
02192 static const char* TABLESTYLE_ACTION_PREFIX = "tablestyle_";
02193
02194 void KWView::updateStyleList()
02195 {
02196 QString currentStyle = m_actionFormatStyle->currentText();
02197
02198 const QStringList lst = m_doc->styleCollection()->displayNameList();
02199 const int pos = lst.findIndex( currentStyle );
02200
02201 m_actionFormatStyle->setItems( lst );
02202 if ( pos > -1 )
02203 m_actionFormatStyle->setCurrentItem( pos );
02204
02205
02206
02207 QStringList lstWithAccels;
02208
02209 KAccelGen::generate( lst, lstWithAccels );
02210 QMap<QString, KShortcut> shortCuts;
02211
02212 KActionPtrList lst2 = actionCollection()->actions("styleList");
02213 QValueList<KAction *> actions = lst2;
02214 QValueList<KAction *>::ConstIterator it = lst2.begin();
02215 const QValueList<KAction *>::ConstIterator end = lst2.end();
02216 for (; it != end; ++it )
02217 {
02218 shortCuts.insert( QString::fromUtf8( (*it)->name() ), (*it)->shortcut() );
02219 m_actionFormatStyleMenu->remove( *it );
02220 delete *it;
02221 }
02222 uint i = 0;
02223 for ( QStringList::Iterator it = lstWithAccels.begin(); it != lstWithAccels.end(); ++it, ++i )
02224 {
02225
02226 KoParagStyle *style = m_doc->styleCollection()->styleAt( i );
02227 if ( style )
02228 {
02229 QString name = PARAGSTYLE_ACTION_PREFIX + style->name();
02230 KToggleAction* act = new KToggleAction( (*it),
02231 shortCuts[name], this, SLOT( slotStyleSelected() ),
02232 actionCollection(), name.utf8() );
02233 act->setGroup( "styleList" );
02234 act->setExclusiveGroup( "styleListAction" );
02235 act->setToolTip( i18n( "Apply a paragraph style" ) );
02236 m_actionFormatStyleMenu->insert( act );
02237 }
02238 else
02239 kdWarning() << "No style found for " << *it << endl;
02240 }
02241 }
02242
02243
02244 void KWView::slotStyleSelected()
02245 {
02246 QString actionName = QString::fromUtf8(sender()->name());
02247 const QString prefix = PARAGSTYLE_ACTION_PREFIX;
02248 if ( actionName.startsWith( prefix ) ) {
02249 actionName = actionName.mid( prefix.length() );
02250 kdDebug(32001) << "KWView::slotStyleSelected " << actionName << endl;
02251 textStyleSelected( m_doc->styleCollection()->findStyle( actionName ) );
02252 }
02253 }
02254
02255 void KWView::updateFrameStyleList()
02256 {
02257
02258
02259 const QString currentStyle = m_actionFrameStyle->currentText();
02260
02261 const QStringList lst = m_doc->frameStyleCollection()->displayNameList();
02262 const int pos = lst.findIndex( currentStyle );
02263
02264 m_actionFrameStyle->setItems( lst );
02265 if ( pos > -1 )
02266 m_actionFrameStyle->setCurrentItem( pos );
02267
02268
02269
02270 QStringList lstWithAccels;
02271
02272 KAccelGen::generate( lst, lstWithAccels );
02273 QMap<QString, KShortcut> shortCuts;
02274
02275
02276 KActionPtrList lst2 = actionCollection()->actions("frameStyleList");
02277 QValueList<KAction *> actions = lst2;
02278 QValueList<KAction *>::ConstIterator it = lst2.begin();
02279 QValueList<KAction *>::ConstIterator end = lst2.end();
02280 for (; it != end; ++it )
02281 {
02282 shortCuts.insert( QString::fromUtf8( (*it)->name() ), (*it)->shortcut() );
02283 m_actionFrameStyleMenu->remove( *it );
02284 delete *it;
02285 }
02286
02287 uint i = 0;
02288 for ( QStringList::Iterator it = lstWithAccels.begin(); it != lstWithAccels.end(); ++it, ++i )
02289 {
02290
02291 KWFrameStyle *style = m_doc->frameStyleCollection()->frameStyleAt( i );
02292 if ( style )
02293 {
02294 QString name = FRAMESTYLE_ACTION_PREFIX + style->name();
02295 KToggleAction* act = new KToggleAction( (*it),
02296 shortCuts[name],
02297 this, SLOT( slotFrameStyleSelected() ),
02298 actionCollection(), name.utf8() );
02299 act->setGroup( "frameStyleList" );
02300 act->setExclusiveGroup( "frameStyleList" );
02301 act->setToolTip( i18n( "Apply a frame style" ) );
02302 m_actionFrameStyleMenu->insert( act );
02303 }
02304 else
02305 kdWarning() << "No frame style found for " << *it << endl;
02306 }
02307 }
02308
02309
02310 void KWView::updateTableStyleList()
02311 {
02312 const QString currentStyle = m_actionTableStyle->currentText();
02313
02314 const QStringList lst = m_doc->tableStyleCollection()->displayNameList();
02315 const int pos = lst.findIndex( currentStyle );
02316
02317 m_actionTableStyle->setItems( lst );
02318 if ( pos > -1 )
02319 m_actionTableStyle->setCurrentItem( pos );
02320
02321
02322
02323 QStringList lstWithAccels;
02324
02325 KAccelGen::generate( lst, lstWithAccels );
02326 QMap<QString, KShortcut> shortCuts;
02327
02328 QValueList<KAction *> actions = actionCollection()->actions("tableStyleList");
02329 QValueList<KAction *>::ConstIterator it = actions.begin();
02330 const QValueList<KAction *>::ConstIterator end = actions.end();
02331 for (; it != end; ++it )
02332 {
02333 shortCuts.insert( QString::fromUtf8( (*it)->name() ), (*it)->shortcut() );
02334 m_actionTableStyleMenu->remove( *it );
02335 delete *it;
02336 }
02337
02338 uint i = 0;
02339 for ( QStringList::Iterator it = lstWithAccels.begin(); it != lstWithAccels.end(); ++it, ++i )
02340 {
02341
02342 KWTableStyle *style = m_doc->tableStyleCollection()->tableStyleAt( i );
02343 if ( style )
02344 {
02345 QString name = TABLESTYLE_ACTION_PREFIX + style->name();
02346 KToggleAction* act = new KToggleAction( (*it),
02347 shortCuts[name], this, SLOT( slotTableStyleSelected() ),
02348 actionCollection(), name.utf8() );
02349 act->setExclusiveGroup( "tableStyleList" );
02350 act->setGroup( "tableStyleList" );
02351 act->setToolTip( i18n( "Apply a table style" ) );
02352 m_actionTableStyleMenu->insert( act );
02353 }
02354 else
02355 kdWarning() << "No table style found for " << *it << endl;
02356 }
02357 }
02358
02359 void KWView::editCut()
02360 {
02361 KWFrameSetEdit * edit = currentTextEdit();
02362 if ( edit )
02363 edit->cut();
02364 else {
02365 QDragObject *drag = m_doc->dragSelected( frameViewManager()->selectedFrames() );
02366 QApplication::clipboard()->setData( drag );
02367 deleteFrame(false);
02368 }
02369 }
02370
02371 void KWView::editCopy()
02372 {
02373 KWTextFrameSetEdit * edit = currentTextEdit();
02374 if ( edit )
02375 edit->copy();
02376 else {
02377 QDragObject *drag = m_doc->dragSelected( frameViewManager()->selectedFrames() );
02378 QApplication::clipboard()->setData( drag );
02379 }
02380 }
02381
02382 void KWView::editPaste()
02383 {
02384 QMimeSource *data = QApplication::clipboard()->data();
02385 pasteData( data, false );
02386 }
02387
02388
02389 void KWView::pasteData( QMimeSource* data, bool drop )
02390 {
02391 int provides = checkClipboard( data );
02392 Q_ASSERT( provides != 0 );
02393
02394
02395 if ( provides & ProvidesFormula ) {
02396 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
02397 if ( edit && edit->frameSet()->type() == FT_FORMULA ) {
02398 edit->pasteData( data, ProvidesFormula, drop );
02399 }
02400 else {
02401 insertFormula( data );
02402 }
02403 }
02404 else
02405 {
02406 deselectAllFrames();
02407
02408 if ( (provides & ProvidesImage) && (provides & ProvidesPlainText) && !( provides & ProvidesOasis ) )
02409 {
02410 QStringList list;
02411 list.append( i18n("Image") );
02412 list.append( i18n("Plain text") );
02413 bool ok;
02414 QString result = KInputDialog::getItem( i18n("Paste"), i18n("Select paste format:"), list, 0, false, &ok );
02415 if (!ok)
02416 return;
02417 if ( result == list.first() )
02418 {
02419 provides = ProvidesImage;
02420 } else {
02421 provides = ProvidesPlainText;
02422 }
02423 if ( !drop )
02424 data = QApplication::clipboard()->data();
02425 }
02426 KWTextFrameSetEdit * edit = currentTextEdit();
02427 if ( edit && ( provides & ProvidesPlainText ) ) {
02428 edit->pasteData( data, provides, drop );
02429 } else if ( provides & ProvidesOasis ) {
02430
02431 QCString returnedTypeMime = KoTextObject::providesOasis( data );
02432 if ( !returnedTypeMime.isEmpty() )
02433 {
02434 const QByteArray arr = data->encodedData( returnedTypeMime );
02435 if( !arr.isEmpty() )
02436 {
02437 QBuffer buffer( arr );
02438 KoStore * store = KoStore::createStore( &buffer, KoStore::Read );
02439 KWOasisLoader oasisLoader( m_doc );
02440 QValueList<KWFrame *> frames = oasisLoader.insertOasisData( store, 0 );
02441 delete store;
02442 QValueList<KWFrame *>::ConstIterator it = frames.begin();
02443 KMacroCommand* macroCmd = 0L;
02444 for ( ; it != frames.end() ; ++it )
02445 {
02446 if ( !macroCmd )
02447 macroCmd = new KMacroCommand( i18n( "Paste" ) );
02448
02449 KWCreateFrameCommand *cmd = new KWCreateFrameCommand( i18n( "Paste" ), *it );
02450 macroCmd->addCommand( cmd );
02451
02452 frameViewManager()->view(*it)->setSelected(true);
02453 (*it)->frameSet()->updateFrames();
02454 }
02455
02456 if ( macroCmd ) {
02457 m_doc->addCommand( macroCmd );
02458 KWFrameList::recalcAllFrames(m_doc);
02459 return;
02460 }
02461 }
02462 }
02463 }
02464 if ( provides & ProvidesImage )
02465 {
02466 KoPoint docPoint( m_currentPage->leftMargin(),
02467 m_currentPage->offsetInDocument() + m_currentPage->topMargin());
02468 m_gui->canvasWidget()->pasteImage( data, docPoint );
02469 }
02470 }
02471 }
02472
02473 void KWView::editSelectAll()
02474 {
02475 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
02476 if ( edit )
02477 edit->selectAll();
02478 }
02479
02480 void KWView::editSelectAllFrames()
02481 {
02482 m_gui->canvasWidget()->selectAllFrames( true );
02483 }
02484
02485 void KWView::editSelectCurrentFrame()
02486 {
02487 if (!m_gui) return;
02488 KWFrameSetEdit* edit = m_gui->canvasWidget()->currentFrameSetEdit();
02489 KWFrame* frame = edit->currentFrame();
02490 if (!frame) return;
02491 KWFrameView *view = frameViewManager()->view(frame);
02492 if (!view) return;
02493 view->setSelected(true);
02494 }
02495
02496 void KWView::editFind()
02497 {
02498 if (!m_searchEntry)
02499 m_searchEntry = new KoSearchContext();
02500 KWTextFrameSetEdit * edit = currentTextEdit();
02501 bool hasSelection = edit && edit->textFrameSet()->hasSelection();
02502 bool hasCursor = edit != 0L;
02503
02504 KoSearchDia dialog( m_gui->canvasWidget(), "find", m_searchEntry, hasSelection, hasCursor );
02505 if ( dialog.exec() == QDialog::Accepted )
02506 {
02507 delete m_findReplace;
02508 m_findReplace = new KWFindReplace( m_gui->canvasWidget(), &dialog, m_gui->canvasWidget()->kWordDocument()->visibleTextObjects(viewMode()), edit);
02509 editFindNext();
02510 }
02511 }
02512
02513 void KWView::editReplace()
02514 {
02515 if (!m_searchEntry)
02516 m_searchEntry = new KoSearchContext();
02517 if (!m_replaceEntry)
02518 m_replaceEntry = new KoSearchContext();
02519
02520 KWTextFrameSetEdit * edit = currentTextEdit();
02521 bool hasSelection = edit && edit->textFrameSet()->hasSelection();
02522 bool hasCursor = edit != 0L;
02523
02524 KoReplaceDia dialog( m_gui->canvasWidget(), "replace", m_searchEntry, m_replaceEntry, hasSelection, hasCursor );
02525 if ( dialog.exec() == QDialog::Accepted )
02526 {
02527 delete m_findReplace;
02528 m_findReplace = new KWFindReplace( m_gui->canvasWidget(), &dialog, m_gui->canvasWidget()->kWordDocument()->visibleTextObjects(viewMode()), edit);
02529 editFindNext();
02530 }
02531 }
02532
02533 void KWView::editFindNext()
02534 {
02535 if ( !m_findReplace )
02536 {
02537 editFind();
02538 return;
02539 }
02540 (void) m_findReplace->findNext();
02541 }
02542
02543 void KWView::editFindPrevious()
02544 {
02545 if ( !m_findReplace )
02546 {
02547 editFind();
02548 return;
02549 }
02550 (void) m_findReplace->findPrevious();
02551 }
02552
02553 void KWView::adjustZOrderOfSelectedFrames(MoveFrameType moveType) {
02554 KMacroCommand* macroCmd = 0L;
02555
02556 QValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
02557 if(selectedFrames.count()==0) return;
02558
02559 KWPage *page = m_doc->pageManager()->page(selectedFrames[0]->frame());
02560 QPtrList<KWFrame> frames;
02561 QValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
02562 while(framesIterator != selectedFrames.end()) {
02563
02564 frames.append((*framesIterator)->frame());
02565 KWFrameSet *table = (*framesIterator)->frame()->frameSet()->groupmanager();
02566 if(table) {
02567 for (QPtrListIterator<KWFrame> cellIt(table->frameIterator() ); cellIt.current() ; ++cellIt ) {
02568 KWFrame *frame = cellIt.current();
02569 if(page->rect().contains(*frame) && !frames.contains(frame))
02570 frames.append(frame);
02571 }
02572 }
02573 ++framesIterator;
02574 }
02575
02576 int lowestZOrder=10000;
02577 QString actionName;
02578 framesIterator = selectedFrames.begin();
02579 while(framesIterator != selectedFrames.end()) {
02580 KWFrame* frame = (*framesIterator)->frame();
02581 int newZOrder=0;
02582 switch(moveType) {
02583 case RaiseFrame:
02584 newZOrder=raiseFrame(frames,frame);
02585 actionName=i18n("Raise Frame");
02586 break;
02587 case LowerFrame:
02588 newZOrder=lowerFrame(frames,frame);
02589 actionName=i18n("Lower Frame");
02590 break;
02591 case BringToFront:
02592 newZOrder=bringToFront(frames,frame);
02593 actionName=i18n("Bring to Front");
02594 break;
02595 case SendToBack:
02596 newZOrder=sendToBack(frames,frame);
02597 actionName=i18n("Send to Back");
02598 break;
02599 }
02600
02601 if ( newZOrder != frame->zOrder() ) {
02602 lowestZOrder=QMIN(lowestZOrder, newZOrder);
02603
02604 KWFrame* frameCopy = frame->getCopy();
02605 frame->setZOrder( newZOrder );
02606 frame->frameStack()->update();
02607
02608 KWFramePropertiesCommand* cmd = new KWFramePropertiesCommand( QString::null, frameCopy, frame);
02609 if(!macroCmd)
02610 macroCmd = new KMacroCommand( actionName );
02611 macroCmd->addCommand(cmd);
02612
02613 frameCopy = frame->getCopy();
02614 frame->setZOrder( newZOrder );
02615
02616 cmd = new KWFramePropertiesCommand( QString::null, frameCopy, frame );
02617 if(!macroCmd)
02618 macroCmd = new KMacroCommand( actionName );
02619 macroCmd->addCommand(cmd);
02620 }
02621 ++framesIterator;
02622 }
02623
02624 if ( macroCmd )
02625 {
02626 m_doc->addCommand(macroCmd);
02627
02628
02629 m_doc->updateAllFrames();
02630 m_doc->layout();
02631 m_doc->repaintAllViews();
02632 }
02633
02634 if(lowestZOrder != 10000 && m_doc->processingType() == KWDocument::WP) {
02635 m_doc->lowerMainFrames( page->pageNumber(), lowestZOrder );
02636 }
02637 }
02638
02639
02640 void KWView::increaseAllZOrdersAbove(int refZOrder, int pageNum, const QPtrList<KWFrame>& frameSelection) {
02641 QPtrList<KWFrame> framesInPage = m_doc->framesInPage( pageNum, false );
02642 for ( QPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
02643 if(frameSelection.contains(frameIt.current()) > 0) continue;
02644 if(frameIt.current()->zOrder() >= refZOrder) {
02645 frameIt.current()->setZOrder( frameIt.current()->zOrder() + 1 );
02646 }
02647 }
02648 }
02649
02650
02651 void KWView::decreaseAllZOrdersUnder(int refZOrder, int pageNum, const QPtrList<KWFrame>& frameSelection) {
02652 QPtrList<KWFrame> framesInPage = m_doc->framesInPage( pageNum, false );
02653 for ( QPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
02654 if(frameSelection.contains(frameIt.current()) > 0) continue;
02655 if(frameIt.current()->zOrder() <= refZOrder) {
02656 frameIt.current()->setZOrder( frameIt.current()->zOrder() - 1 );
02657 }
02658 }
02659 }
02660
02661 int KWView::raiseFrame(const QPtrList<KWFrame>& frameSelection, const KWFrame *frame) {
02662 int newZOrder = 10000;
02663 QValueList<int> zorders;
02664 QPtrList<KWFrame> framesInPage = m_doc->framesInPage( frame->pageNumber(), false );
02665 for ( QPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
02666 if(frameSelection.contains(frameIt.current()) > 0) continue;
02667 if(! frameIt.current()->intersects(*frame)) continue;
02668 int z = frameIt.current()->zOrder();
02669 if(z > frame->zOrder()) {
02670 newZOrder=QMIN(newZOrder, z + 1);
02671 }
02672 zorders.append( z );
02673 }
02674 if(newZOrder==10000) return frame->zOrder();
02675
02676 if ( zorders.find( newZOrder ) != zorders.end() )
02677 increaseAllZOrdersAbove( newZOrder, frame->pageNumber(), frameSelection );
02678 return newZOrder;
02679 }
02680
02681 int KWView::lowerFrame(const QPtrList<KWFrame>& frameSelection, const KWFrame *frame) {
02682 int newZOrder = -10000;
02683 QValueList<int> zorders;
02684 QPtrList<KWFrame> framesInPage = m_doc->framesInPage( frame->pageNumber(), false );
02685 for ( QPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
02686 if(frameSelection.contains(frameIt.current()) > 0) continue;
02687 if(frameIt.current()->frameSet()->isMainFrameset()) continue;
02688 if(! frameIt.current()->intersects(*frame)) continue;
02689 int z = frameIt.current()->zOrder();
02690 if(z < frame->zOrder()) {
02691 newZOrder=QMAX(newZOrder, z -1);
02692 }
02693 zorders.append( z );
02694 }
02695 if(newZOrder==-10000) return frame->zOrder();
02696
02697 if ( zorders.find( newZOrder ) != zorders.end() )
02698 decreaseAllZOrdersUnder( newZOrder, frame->pageNumber(), frameSelection );
02699 return newZOrder;
02700 }
02701
02702 int KWView::bringToFront(const QPtrList<KWFrame>& frameSelection, const KWFrame *frame) {
02703 int newZOrder = frame->zOrder();
02704 QPtrList<KWFrame> framesInPage = m_doc->framesInPage( frame->pageNumber(), false );
02705 for ( QPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
02706 if(frameSelection.contains(frameIt.current()) > 0) continue;
02707 if(! frameIt.current()->intersects(*frame)) continue;
02708 newZOrder=QMAX(newZOrder, frameIt.current()->zOrder()+1);
02709 }
02710 return newZOrder;
02711 }
02712
02713 int KWView::sendToBack(const QPtrList<KWFrame>& frameSelection, const KWFrame *frame) {
02714 int newZOrder = frame->zOrder();
02715 QPtrList<KWFrame> framesInPage = m_doc->framesInPage( frame->pageNumber(), false );
02716 for ( QPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
02717 if(frameSelection.contains(frameIt.current()) > 0) continue;
02718 if(frameIt.current()->frameSet()->isMainFrameset()) continue;
02719 if(! frameIt.current()->intersects(*frame)) continue;
02720 newZOrder=QMIN(newZOrder, frameIt.current()->zOrder()-1);
02721 }
02722 return newZOrder;
02723 }
02724
02725 void KWView::editDeleteFrame()
02726 {
02727 deleteFrame();
02728 }
02729
02730 void KWView::deleteFrame( bool warning )
02731 {
02732 if ( !m_doc->isReadWrite() )
02733 return;
02734
02735 QValueList<KWFrameView*> frames = frameViewManager()->selectedFrames();
02736 if( frames.count() < 1) {
02737 kdWarning() << "KWView::deleteFrame: no frame selected" << endl;
02738 return;
02739 }
02740 if(frames.count()==1)
02741 {
02742 KWFrame *theFrame = frames[0]->frame();
02743 KWFrameSet *fs = theFrame->frameSet();
02744
02745 Q_ASSERT( !fs->isAHeader() );
02746 Q_ASSERT( !fs->isAFooter() );
02747 if ( fs->isMainFrameset() || fs->isAFooter() || fs->isAHeader() || fs->isFootEndNote())
02748 return;
02749
02750
02751 if ( fs->groupmanager() )
02752 {
02753 int result = KMessageBox::warningContinueCancel(
02754 this,
02755 i18n( "You are about to delete a table.\n"
02756 "Doing so will delete all the text in the table.\n"
02757 "Are you sure you want to do that?"),
02758 i18n("Delete Table"), KStdGuiItem::del(),
02759 "DeleteTableConfirmation",
02760 true );
02761 if (result != KMessageBox::Continue)
02762 return;
02763 m_doc->deleteTable( fs->groupmanager() );
02764 return;
02765 }
02766
02767 if ( fs->frameCount() == 1 && fs->type() == FT_TEXT) {
02768 if ( fs->isMainFrameset())
02769 return;
02770
02771 KWTextFrameSet * textfs = dynamic_cast<KWTextFrameSet *>(fs);
02772 Q_ASSERT(textfs);
02773 if ( !textfs )
02774 return;
02775
02776 KoTextDocument * textdoc = textfs->textDocument();
02777 if ( textdoc->length() > 0 )
02778 {
02779 int result = KMessageBox::warningContinueCancel(
02780 this,
02781 i18n( "You are about to delete the last Frame of the "
02782 "Frameset '%1'. "
02783 "The contents of this Frameset will not appear "
02784 "anymore!\n"
02785 "Are you sure you want to do that?").arg(fs->name()),
02786 i18n("Delete Frame"), KStdGuiItem::del());
02787
02788 if (result != KMessageBox::Continue)
02789 return;
02790
02791 m_doc->deleteFrame( theFrame );
02792 return;
02793 }
02794
02795 }
02796
02797 if(warning)
02798 {
02799 int result = KMessageBox::warningContinueCancel(
02800 this,
02801 i18n("Do you want to delete this frame?"),
02802 i18n("Delete Frame"),
02803 KGuiItem(i18n("&Delete"),"editdelete"),
02804 "DeleteLastFrameConfirmation",
02805 true );
02806 if (result != KMessageBox::Continue)
02807 return;
02808 }
02809 m_doc->deleteFrame( theFrame );
02810 }
02811 else
02812 {
02813
02814 if(warning)
02815 {
02816 int result = KMessageBox::warningContinueCancel(
02817 this,
02818 i18n("Do you want to delete this frame?"),
02819 i18n("Delete Frame"),
02820 KGuiItem(i18n("&Delete"),"editdelete"),
02821 "DeleteLastFrameConfirmation",
02822 true );
02823 if (result != KMessageBox::Continue)
02824 return;
02825 }
02826
02827 deleteSelectedFrames();
02828 }
02829 }
02830
02831 void KWView::createLinkedFrame()
02832 {
02833 QValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
02834 if (selectedFrames.count() != 1)
02835 return;
02836 KWFrame* frame = selectedFrames[0]->frame();
02837 KWFrame* newFrame = new KWFrame(0L, frame->x() + m_gui->getVertRuler()->minimumSizeHint().width(), frame->y() + m_gui->getHorzRuler()->minimumSizeHint().height(), frame->width(), frame->height() );
02838 newFrame->setZOrder( m_doc->maxZOrder( newFrame->pageNumber(m_doc) ) + 1 );
02839 newFrame->setCopy(true);
02840 newFrame->setNewFrameBehavior( KWFrame::Copy );
02841 frame->frameSet()->addFrame( newFrame );
02842
02843 frameViewManager()->view(newFrame)->setSelected(true);
02844
02845 KWCreateFrameCommand *cmd = new KWCreateFrameCommand( i18n("Create Linked Copy"), newFrame );
02846 m_doc->addCommand( cmd );
02847
02848 m_doc->frameChanged( newFrame );
02849 }
02850
02851 void KWView::editCustomVariable()
02852 {
02853 KWTextFrameSetEdit * edit = currentTextEdit();
02854 if (edit)
02855 {
02856 KoCustomVariable *var = static_cast<KoCustomVariable *>(edit->variable());
02857 if (var)
02858 {
02859 QString oldvalue = var->value();
02860 KoCustomVarDialog dia( this, var );
02861 if ( dia.exec() )
02862 {
02863 m_doc->recalcVariables( VT_CUSTOM );
02864 if( var->value() != oldvalue )
02865 {
02866 KWChangeCustomVariableValue *cmd=new KWChangeCustomVariableValue(i18n( "Change Custom Variable" ),m_doc, oldvalue, var->value(), var );
02867 m_doc->addCommand(cmd);
02868 }
02869 }
02870 }
02871 }
02872 }
02873
02874 void KWView::editCustomVars()
02875 {
02876 KoCustomVariablesDia dia( this, m_doc->variableCollection()->getVariables() );
02877 QStringList listOldCustomValue;
02878 QPtrListIterator<KoVariable> oldIt( m_doc->variableCollection()->getVariables() );
02879 for ( ; oldIt.current() ; ++oldIt )
02880 {
02881 if(oldIt.current()->type()==VT_CUSTOM)
02882 listOldCustomValue.append(((KoCustomVariable*)oldIt.current())->value());
02883 }
02884 if(dia.exec())
02885 {
02886 m_doc->recalcVariables( VT_CUSTOM );
02887
02888 QPtrListIterator<KoVariable> it( m_doc->variableCollection()->getVariables() );
02889 KMacroCommand * macroCommand = 0L;
02890 int i=0;
02891 for ( ; it.current() ; ++it )
02892 {
02893 if(it.current()->type() == VT_CUSTOM )
02894 {
02895 if(((KoCustomVariable*)it.current())->value()!=*(listOldCustomValue.at(i)))
02896 {
02897 if(!macroCommand)
02898 macroCommand = new KMacroCommand( i18n( "Change Custom Variable" ) );
02899 KWChangeCustomVariableValue *cmd=new KWChangeCustomVariableValue(i18n( "Change Custom Variable" ),m_doc,*(listOldCustomValue.at(i)), ((KoCustomVariable*)it.current())->value() ,((KoCustomVariable*)it.current()));
02900 macroCommand->addCommand(cmd);
02901 }
02902 i++;
02903 }
02904 }
02905 if(macroCommand)
02906 m_doc->addCommand(macroCommand);
02907 }
02908 }
02909
02910 void KWView::editMailMergeDataBase()
02911 {
02912 m_doc->mailMergeDataBase()->showConfigDialog(this);
02913 #if 0
02914 KWMailMergeEditor *dia = new KWMailMergeEditor( this, m_doc->mailMergeDataBase() );
02915 dia->exec();
02916
02917
02918 delete dia;
02919 #endif
02920 }
02921
02922 void KWView::viewTextMode()
02923 {
02924 if ( m_actionViewTextMode->isChecked() )
02925 {
02926 KWTextFrameSet* fs = KWViewModeText::determineTextFrameSet( m_doc );
02927 if ( fs ) {
02928 if ( dynamic_cast<KWViewModePreview *>(viewMode()) )
02929 {
02930 m_zoomViewModePreview.m_zoom = m_doc->zoom();
02931 m_zoomViewModePreview.m_zoomMode = m_doc->zoomMode();
02932 }
02933 else
02934 {
02935 m_zoomViewModeNormal.m_zoom = m_doc->zoom();
02936 m_zoomViewModeNormal.m_zoomMode = m_doc->zoomMode();
02937 }
02938
02939
02940 switch(m_zoomViewModeNormal.m_zoomMode)
02941 {
02942 case KoZoomMode::ZOOM_WIDTH:
02943 m_doc->setZoomMode(KoZoomMode::ZOOM_WIDTH);
02944 QTimer::singleShot( 0, this, SLOT( updateZoom() ) );
02945 break;
02946 case KoZoomMode::ZOOM_PAGE:
02947 m_zoomViewModeNormal.m_zoomMode = KoZoomMode::ZOOM_CONSTANT;
02948 case KoZoomMode::ZOOM_CONSTANT:
02949 m_doc->setZoomMode(KoZoomMode::ZOOM_CONSTANT);
02950 showZoom( m_zoomViewModeNormal.m_zoom );
02951 setZoom( m_zoomViewModeNormal.m_zoom, false );
02952 break;
02953 }
02954 m_doc->switchViewMode( "ModeText" );
02955 } else
02956 initGUIButton();
02957 }
02958 else
02959 m_actionViewTextMode->setChecked( true );
02960 }
02961
02962 void KWView::viewPageMode()
02963 {
02964 if ( m_actionViewPageMode->isChecked() )
02965 {
02966 if ( dynamic_cast<KWViewModePreview *>(viewMode()) )
02967 {
02968 m_zoomViewModePreview.m_zoom = m_doc->zoom();
02969 m_zoomViewModePreview.m_zoomMode = m_doc->zoomMode();
02970 }
02971 else
02972 {
02973 m_zoomViewModeNormal.m_zoom = m_doc->zoom();
02974 m_zoomViewModeNormal.m_zoomMode = m_doc->zoomMode();
02975 }
02976 switch(m_zoomViewModeNormal.m_zoomMode)
02977 {
02978 case KoZoomMode::ZOOM_WIDTH:
02979 m_doc->setZoomMode(KoZoomMode::ZOOM_WIDTH);
02980 QTimer::singleShot( 0, this, SLOT( updateZoom() ) );
02981 break;
02982 case KoZoomMode::ZOOM_PAGE:
02983 m_doc->setZoomMode(KoZoomMode::ZOOM_PAGE);
02984 QTimer::singleShot( 0, this, SLOT( updateZoom() ) );
02985 break;
02986 case KoZoomMode::ZOOM_CONSTANT:
02987 m_doc->setZoomMode(KoZoomMode::ZOOM_CONSTANT);
02988 showZoom( m_zoomViewModeNormal.m_zoom );
02989 setZoom( m_zoomViewModeNormal.m_zoom, false );
02990 break;
02991 }
02992 m_doc->switchViewMode( "ModeNormal" );
02993 }
02994 else
02995 m_actionViewPageMode->setChecked( true );
02996 }
02997
02998 void KWView::viewPreviewMode()
02999 {
03000 if ( m_actionViewPreviewMode->isChecked() )
03001 {
03002 m_zoomViewModeNormal.m_zoom = m_doc->zoom();
03003 m_zoomViewModeNormal.m_zoomMode = m_doc->zoomMode();
03004 switch(m_zoomViewModePreview.m_zoomMode)
03005 {
03006 case KoZoomMode::ZOOM_WIDTH:
03007 m_doc->setZoomMode(KoZoomMode::ZOOM_WIDTH);
03008 QTimer::singleShot( 0, this, SLOT( updateZoom() ) );
03009 break;
03010 case KoZoomMode::ZOOM_PAGE:
03011 m_doc->setZoomMode(KoZoomMode::ZOOM_PAGE);
03012 QTimer::singleShot( 0, this, SLOT( updateZoom() ) );
03013 break;
03014 case KoZoomMode::ZOOM_CONSTANT:
03015 m_doc->setZoomMode(KoZoomMode::ZOOM_CONSTANT);
03016 showZoom( m_zoomViewModePreview.m_zoom );
03017 setZoom( m_zoomViewModePreview.m_zoom, false );
03018 break;
03019 }
03020 m_doc->switchViewMode( "ModePreview" );
03021 }
03022 else
03023 m_actionViewPreviewMode->setChecked( true );
03024 }
03025
03026 void KWView::updateZoomControls()
03027 {
03028 switch(m_doc->zoomMode())
03029 {
03030 case KoZoomMode::ZOOM_WIDTH:
03031 case KoZoomMode::ZOOM_PAGE:
03032 showZoom( KoZoomMode::toString(m_doc->zoomMode()) );
03033 break;
03034 case KoZoomMode::ZOOM_CONSTANT:
03035 changeZoomMenu( m_doc->zoom() );
03036 showZoom( m_doc->zoom() );
03037 break;
03038 }
03039 }
03040
03041 void KWView::changeZoomMenu( int zoom )
03042 {
03043 QString mode;
03044 if ( m_gui && m_gui->canvasWidget() && viewMode())
03045 mode = viewMode()->type();
03046
03047 QStringList lst;
03048 lst << KoZoomMode::toString(KoZoomMode::ZOOM_WIDTH);
03049 if ( mode!="ModeText" )
03050 lst << KoZoomMode::toString(KoZoomMode::ZOOM_PAGE);
03051
03052 if(zoom>0)
03053 {
03054 QValueList<int> list;
03055 bool ok;
03056 const QStringList itemsList ( m_actionViewZoom->items() );
03057 QRegExp regexp("(\\d+)");
03058
03059 for (QStringList::ConstIterator it = itemsList.begin() ; it != itemsList.end() ; ++it)
03060 {
03061 regexp.search(*it);
03062 const int val=regexp.cap(1).toInt(&ok);
03063
03064 if(ok && val>9 && list.contains(val)==0)
03065 list.append( val );
03066 }
03067
03068
03069 if(list.contains(zoom)==0)
03070 list.append( zoom );
03071
03072 qHeapSort( list );
03073
03074 for (QValueList<int>::Iterator it = list.begin() ; it != list.end() ; ++it)
03075 lst.append( i18n("%1%").arg(*it) );
03076 }
03077 else
03078 {
03079 lst << i18n("%1%").arg("33");
03080 lst << i18n("%1%").arg("50");
03081 lst << i18n("%1%").arg("75");
03082 lst << i18n("%1%").arg("100");
03083 lst << i18n("%1%").arg("125");
03084 lst << i18n("%1%").arg("150");
03085 lst << i18n("%1%").arg("200");
03086 lst << i18n("%1%").arg("250");
03087 lst << i18n("%1%").arg("350");
03088 lst << i18n("%1%").arg("400");
03089 lst << i18n("%1%").arg("450");
03090 lst << i18n("%1%").arg("500");
03091 }
03092 m_actionViewZoom->setItems( lst );
03093 }
03094
03095 void KWView::showZoom( int zoom )
03096 {
03097 QStringList list = m_actionViewZoom->items();
03098 QString zoomStr( i18n("%1%").arg( zoom ) );
03099 m_actionViewZoom->setCurrentItem( list.findIndex(zoomStr) );
03100 }
03101
03102 void KWView::showZoom( const QString& zoom )
03103 {
03104 QStringList list = m_actionViewZoom->items();
03105 m_actionViewZoom->setCurrentItem( list.findIndex( zoom ) );
03106 }
03107
03108 void KWView::slotViewFormattingChars()
03109 {
03110 m_doc->setViewFormattingChars(m_actionViewFormattingChars->isChecked());
03111 m_doc->layout();
03112 m_doc->repaintAllViews();
03113 }
03114
03115 void KWView::slotViewFrameBorders()
03116 {
03117 setViewFrameBorders(m_actionViewFrameBorders->isChecked());
03118 m_gui->canvasWidget()->repaintAll();
03119 }
03120
03121 void KWView::viewHeader()
03122 {
03123 bool state = m_actionViewHeader->isChecked();
03124 m_doc->setHeaderVisible( state );
03125 KWHideShowHeader *cmd=new KWHideShowHeader( state ? i18n("Enable Document Headers"):i18n("Disable Document Headers"), m_doc, state);
03126 m_doc->addCommand(cmd);
03127 updateHeader();
03128 }
03129
03130 void KWView::updateHeader()
03131 {
03132 KWTextFrameSetEdit * edit = currentTextEdit();
03133 bool state = m_actionViewHeader->isChecked();
03134 if(!state )
03135 {
03136 KWFrameSet *frameSet=0L;
03137 if(edit)
03138 {
03139 frameSet=edit->frameSet();
03140 if (frameSet->isAHeader())
03141 m_doc->terminateEditing( frameSet );
03142 else
03143 {
03144 KWTableFrameSet *table = frameSet->frame(0)->frameSet()->groupmanager();
03145 if (table)
03146 {
03147 if (table->isFloating() && table->anchorFrameset()->isAHeader())
03148 m_doc->terminateEditing( table );
03149 }
03150 }
03151
03152 }
03153 else
03154 {
03155 KWFormulaFrameSetEdit * editFormula = dynamic_cast<KWFormulaFrameSetEdit *>(m_gui->canvasWidget()->currentFrameSetEdit());
03156 if(editFormula)
03157 {
03158 frameSet= editFormula->frameSet();
03159 if(frameSet->type()==FT_FORMULA && frameSet->isFloating())
03160 m_doc->terminateEditing( frameSet );
03161 }
03162
03163 }
03164 }
03165 }
03166
03167
03168 void KWView::viewFooter()
03169 {
03170 bool state=m_actionViewFooter->isChecked();
03171 m_doc->setFooterVisible( state );
03172 KWHideShowFooter *cmd=new KWHideShowFooter( state ? i18n("Enable Document Footers"):i18n("Disable Document Footers"), m_doc, state);
03173 m_doc->addCommand(cmd);
03174 updateFooter();
03175 }
03176
03177 void KWView::updateFooter()
03178 {
03179 bool state=m_actionViewFooter->isChecked();
03180 KWTextFrameSetEdit * edit = currentTextEdit();
03181 if(!state )
03182 {
03183 KWFrameSet *frameSet=0L;
03184 if(edit)
03185 {
03186 frameSet=edit->frameSet();
03187 if (frameSet->isAFooter())
03188 m_doc->terminateEditing( frameSet );
03189 else
03190 {
03191 KWTableFrameSet *table = frameSet->frame(0)->frameSet()->groupmanager();
03192 if (table)
03193 {
03194 if (table->isFloating() && table->anchorFrameset()->isAFooter())
03195 m_doc->terminateEditing( table );
03196 }
03197 }
03198 }
03199 else
03200 {
03201 KWFormulaFrameSetEdit * editFormula = dynamic_cast<KWFormulaFrameSetEdit *>(m_gui->canvasWidget()->currentFrameSetEdit());
03202 if(editFormula)
03203 {
03204 frameSet= editFormula->frameSet();
03205 if(frameSet->type()==FT_FORMULA && frameSet->isFloating())
03206 m_doc->terminateEditing( frameSet );
03207
03208 }
03209
03210 }
03211 }
03212
03213 }
03214
03215 void KWView::updateZoom( ) {
03216 viewZoom(m_actionViewZoom->currentText());
03217 }
03218
03219 void KWView::viewZoom( const QString &s )
03220 {
03221 bool ok=false;
03222 KWCanvas * canvas = m_gui->canvasWidget();
03223 int zoom = 0;
03224
03225 if ( s == KoZoomMode::toString(KoZoomMode::ZOOM_WIDTH) )
03226 {
03227 m_doc->setZoomMode(KoZoomMode::ZOOM_WIDTH);
03228 zoom = qRound( static_cast<double>(canvas->visibleWidth() * 100 ) / (m_doc->resolutionX() * m_currentPage->width() ) ) - 1;
03229
03230 if(zoom != m_doc->zoom() && !canvas->verticalScrollBar() ||
03231 !canvas->verticalScrollBar()->isVisible()) {
03232
03233 QTimer::singleShot( 0, this, SLOT( updateZoom() ) );
03234 }
03235 ok = true;
03236 }
03237 else if ( s == KoZoomMode::toString(KoZoomMode::ZOOM_PAGE) )
03238 {
03239 m_doc->setZoomMode(KoZoomMode::ZOOM_PAGE);
03240 double height = m_doc->resolutionY() * m_currentPage->height();
03241 double width = m_doc->resolutionX() * m_currentPage->width();
03242 zoom = QMIN( qRound( static_cast<double>(canvas->visibleHeight() * 100 ) / height ),
03243 qRound( static_cast<double>(canvas->visibleWidth() * 100 ) / width ) ) - 1;
03244
03245 ok = true;
03246 }
03247 else
03248 {
03249 m_doc->setZoomMode(KoZoomMode::ZOOM_CONSTANT);
03250 QRegExp regexp("(\\d+)");
03251 regexp.search(s);
03252 zoom=regexp.cap(1).toInt(&ok);
03253 }
03254
03255 if( !ok || zoom<10 )
03256 zoom = m_doc->zoom();
03257 if ( !KoZoomMode::isConstant(s) )
03258 showZoom( s );
03259 else
03260 {
03261 changeZoomMenu( zoom );
03262 showZoom( zoom );
03263 }
03264
03265
03266 if( zoom != m_doc->zoom() )
03267 {
03268 setZoom( zoom, true );
03269
03270 KWTextFrameSetEdit * edit = currentTextEdit();
03271 if ( edit )
03272 edit->ensureCursorVisible();
03273 }
03274
03275 m_gui->canvasWidget()->setFocus();
03276
03277 }
03278
03279 void KWView::setZoom( int zoom, bool updateViews )
03280 {
03281 m_doc->setZoomAndResolution( zoom, KoGlobal::dpiX(), KoGlobal::dpiY());
03282 m_doc->newZoomAndResolution( updateViews, false );
03283 m_doc->updateZoomRuler();
03284
03285 if ( statusBar() )
03286 m_sbZoomLabel->setText( ' ' + QString::number( zoom ) + "% " );
03287
03288
03289 kdDebug() << "KWView::setZoom " << zoom << " setting koview zoom to " << m_doc->zoomedResolutionY() << endl;
03290 KoView::setZoom( m_doc->zoomedResolutionY() );
03291 }
03292
03293 void KWView::insertPicture()
03294 {
03295 if ( m_actionToolsCreatePix->isChecked() )
03296 {
03297 KWInsertPicDia dia( this,m_gui->canvasWidget()->pictureInline(),m_gui->canvasWidget()->pictureKeepRatio(),m_doc );
03298 if ( dia.exec() == QDialog::Accepted && !dia.picture().isNull() )
03299 {
03300 insertPicture( dia.picture(), dia.makeInline(), dia.keepRatio(), 0, 0 );
03301 m_gui->canvasWidget()->setPictureInline( dia.makeInline());
03302 m_gui->canvasWidget()->setPictureKeepRatio( dia.keepRatio() );
03303 }
03304 else
03305 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_EDIT );
03306 }
03307 else
03308 {
03309
03310 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_EDIT );
03311 }
03312 }
03313
03314
03315 void KWView::slotEmbedImage( const QString &filename )
03316 {
03317 KoPicture picture;
03318 KoPictureKey key;
03319 key.setKeyFromFile( filename );
03320 picture.setKey( key );
03321 picture.loadFromFile( filename );
03322 insertPicture( picture, false, true, 0, 0 );
03323 }
03324
03325 void KWView::insertPicture( const KoPicture& picture, const bool makeInline, const bool keepRatio, int suggestedWidth, int suggestedHeight )
03326 {
03327 QSize pixmapSize( picture.getOriginalSize() );
03328 if ( suggestedWidth > 0 && suggestedHeight > 0 )
03329 pixmapSize = QSize( suggestedWidth, suggestedHeight );
03330
03331 if ( makeInline )
03332 {
03333 const double widthLimit = m_currentPage->width() - m_currentPage->leftMargin() -
03334 m_currentPage->rightMargin() - 10;
03335 const double heightLimit = m_currentPage->height() - m_currentPage->topMargin() -
03336 m_currentPage->bottomMargin() - 10;
03337 m_fsInline = 0;
03338 KWPictureFrameSet *frameset = new KWPictureFrameSet( m_doc, QString::null );
03339
03340 frameset->insertPicture( picture );
03341
03342
03343
03344 double width = m_doc->unzoomItX( qRound( (double)pixmapSize.width() * m_doc->zoomedResolutionX() / POINT_TO_INCH( KoGlobal::dpiX() ) ) );
03345 double height = m_doc->unzoomItY( qRound( (double)pixmapSize.height() * m_doc->zoomedResolutionY() / POINT_TO_INCH( KoGlobal::dpiY() ) ) );
03346
03347 frameset->setKeepAspectRatio( keepRatio);
03348
03349
03350 if ( keepRatio && ((width > widthLimit) || (height > heightLimit)) )
03351 {
03352
03353 const double ratioX = width / widthLimit;
03354 const double ratioY = height / heightLimit;
03355 const double ratioPicture = width / height;
03356
03357 if ( ratioPicture == 0 )
03358 {
03359 width = widthLimit;
03360 height = heightLimit;
03361 }
03362 else
03363 if ( ratioX > ratioY )
03364 {
03365 width = widthLimit;
03366 height = widthLimit/ratioPicture;
03367 }
03368 else
03369 {
03370 width = heightLimit*ratioPicture;
03371 height = heightLimit;
03372 }
03373 }
03374 else
03375 {
03376
03377 width = kMin( width, widthLimit );
03378 height = kMin( height, heightLimit );
03379 }
03380
03381 m_fsInline = frameset;
03382 KWFrame *frame = new KWFrame ( m_fsInline, 0, 0, width, height );
03383 m_fsInline->addFrame( frame, false );
03384 m_gui->canvasWidget()->inlinePictureStarted();
03385 showMouseMode( KWCanvas::MM_EDIT );
03386
03387 displayFrameInlineInfo();
03388
03389 #if 0
03390 edit->insertFloatingFrameSet( fs, i18n("Insert Picture Inline") );
03391 fs->finalize();
03392 showMouseMode( KWCanvas::MM_EDIT );
03393 m_doc->refreshDocStructure(Pictures);
03394 #endif
03395 }
03396 else
03397 {
03398 m_gui->canvasWidget()->insertPicture( picture, pixmapSize, keepRatio );
03399 }
03400 }
03401
03402 bool KWView::insertInlinePicture()
03403 {
03404 Q_ASSERT( m_fsInline );
03405 KWTextFrameSetEdit * edit = currentTextEdit();
03406 if(edit)
03407 {
03408 if ( edit->textFrameSet()->textObject()->protectContent() )
03409 return false;
03410
03411 m_doc->addFrameSet( m_fsInline, false );
03412 #if 0
03413 KWFrame *frame = new KWFrame( m_fsInline, 0, 0, m_doc->unzoomItX( width ), m_doc->unzoomItY( height ) );
03414 m_fsInline->addFrame( frame, false );
03415 #endif
03416 edit->insertFloatingFrameSet( m_fsInline, i18n("Insert Picture Inline") );
03417 m_fsInline->finalize();
03418 showMouseMode( KWCanvas::MM_EDIT );
03419 m_doc->refreshDocStructure(Pictures);
03420 m_fsInline=0;
03421 updateFrameStatusBarItem();
03422 }
03423 else
03424 {
03425 delete m_fsInline;
03426 m_fsInline=0;
03427 updateFrameStatusBarItem();
03428 }
03429 return true;
03430 }
03431
03432 void KWView::displayFrameInlineInfo()
03433 {
03434 KMessageBox::information(this,
03435 i18n("Set cursor where you want to insert inline frame."),
03436 i18n("Insert Inline Frame"),
03437 "SetCursorInsertInlineFrame",true);
03438
03439 if ( statusBar() && m_sbFramesLabel )
03440 m_sbFramesLabel->setText( ' ' + i18n("Set cursor where you want to insert inline frame." ) );
03441 }
03442
03443 void KWView::insertSpecialChar()
03444 {
03445 KWTextFrameSetEdit *edit=currentTextEdit();
03446 if ( !edit )
03447 return;
03448 QString f = edit->textFontFamily();
03449 QChar c=' ';
03450 if (m_specialCharDlg==0)
03451 {
03452 m_specialCharDlg = new KoCharSelectDia( this, "insert special char", f, c, false );
03453 connect( m_specialCharDlg, SIGNAL(insertChar(QChar,const QString &)),
03454 this, SLOT(slotSpecialChar(QChar,const QString &)));
03455 connect( m_specialCharDlg, SIGNAL( finished() ),
03456 this, SLOT( slotSpecialCharDlgClosed() ) );
03457 }
03458 m_specialCharDlg->show();
03459 }
03460
03461 void KWView::slotSpecialCharDlgClosed()
03462 {
03463 if ( m_specialCharDlg )
03464 {
03465 disconnect( m_specialCharDlg, SIGNAL(insertChar(QChar,const QString &)),
03466 this, SLOT(slotSpecialChar(QChar,const QString &)));
03467 disconnect( m_specialCharDlg, SIGNAL( finished() ),
03468 this, SLOT( slotSpecialCharDlgClosed() ) );
03469 m_specialCharDlg->deleteLater();
03470 m_specialCharDlg = 0L;
03471 }
03472 }
03473
03474 void KWView::slotSpecialChar(QChar c, const QString &font)
03475 {
03476 KWTextFrameSetEdit *edit=currentTextEdit();
03477 if ( !edit )
03478 return;
03479 edit->insertSpecialChar(c, font);
03480 }
03481
03482 void KWView::insertFrameBreak()
03483 {
03484 KWTextFrameSetEdit *edit=currentTextEdit();
03485 if ( !edit )
03486 return;
03487 edit->insertFrameBreak();
03488 }
03489
03490 void KWView::insertPage()
03491 {
03492 if ( m_doc->processingType() == KWDocument::WP )
03493 {
03494 m_gui->canvasWidget()->editFrameSet( m_doc->frameSet(0) );
03495 KWTextFrameSetEdit *edit = currentTextEdit();
03496 Q_ASSERT(edit);
03497 if ( edit )
03498 edit->insertWPPage();
03499 } else {
03500 KWInsertPageDia dlg( this, "insertpage");
03501 if ( dlg.exec())
03502 {
03503
03504 int page = m_currentPage->pageNumber();
03505 KCommand* cmd = new KWInsertRemovePageCommand( m_doc, KWInsertRemovePageCommand::Insert, dlg.insertPagePos()==KW_INSERTPAGEAFTER ? page : (page -1));
03506 cmd->execute();
03507 m_doc->addCommand( cmd );
03508 }
03509 }
03510 }
03511
03512 void KWView::deletePage()
03513 {
03514 KCommand* cmd = new KWInsertRemovePageCommand( m_doc, KWInsertRemovePageCommand::Remove, m_currentPage->pageNumber() );
03515 cmd->execute();
03516 m_doc->addCommand( cmd );
03517 if(m_doc->lastPage() > m_currentPage->pageNumber())
03518 m_currentPage = m_doc->pageManager()->page( m_doc->lastPage() );
03519 }
03520
03521 void KWView::insertLink()
03522 {
03523 KWTextFrameSetEdit *edit=currentTextEdit();
03524 if ( !edit )
03525 return;
03526 QString link;
03527 QString ref;
03528 if ( edit->textFrameSet()->hasSelection() )
03529 {
03530 QString selectedText = edit->textFrameSet()->textObject()->selectedText();
03531 if ( edit->textFrameSet()->textObject()->selectionHasCustomItems() || selectedText.contains('\n') )
03532 return;
03533 if ( selectedText.startsWith( "mailto:/" ) ||
03534 selectedText.startsWith( "ftp:/" ) ||
03535 selectedText.startsWith( "http:/" ) )
03536 {
03537 link=selectedText;
03538 ref = selectedText;
03539 }
03540 else
03541 {
03542
03543 link = selectedText;
03544 }
03545 }
03546
03547 if(KoInsertLinkDia::createLinkDia(link, ref, m_doc->listOfBookmarkName(0), true, this))
03548 {
03549 if(!link.isEmpty() && !ref.isEmpty())
03550 edit->insertLink(link, ref);
03551 }
03552 }
03553
03554 void KWView::insertComment()
03555 {
03556 KWTextFrameSetEdit *edit=currentTextEdit();
03557 if ( !edit )
03558 return;
03559 QString authorName;
03560 KoDocumentInfo * info = m_doc->documentInfo();
03561 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
03562 if ( !authorPage )
03563 kdWarning() << "Author information not found in documentInfo !" << endl;
03564 else
03565 authorName = authorPage->fullName();
03566
03567 KoCommentDia *commentDia = new KoCommentDia( this, QString::null,authorName );
03568 if( commentDia->exec() )
03569 {
03570 edit->insertComment(commentDia->commentText());
03571 }
03572 delete commentDia;
03573 }
03574
03575
03576 void KWView::insertVariable()
03577 {
03578 KWTextFrameSetEdit * edit = currentTextEdit();
03579 if ( edit )
03580 {
03581 KAction * act = (KAction *)(sender());
03582 VariableDefMap::Iterator it = m_variableDefMap.find( act );
03583 if ( it == m_variableDefMap.end() )
03584 kdWarning() << "Action not found in m_variableDefMap." << endl;
03585 else
03586 {
03587 if ( (*it).type == VT_FIELD )
03588 edit->insertVariable( (*it).type, KoFieldVariable::fieldSubType( (*it).subtype ) );
03589 else
03590 edit->insertVariable( (*it).type, (*it).subtype );
03591 }
03592 }
03593 }
03594
03595 void KWView::insertFootNote()
03596 {
03597 KWTextFrameSetEdit * edit = currentTextEdit();
03598
03599 if ( edit )
03600 {
03601 if ( edit->frameSet() != m_doc->frameSet(0) )
03602 {
03603 KMessageBox::sorry( this,
03604 i18n( "You can only insert footnotes or "
03605 "endnotes into the first frameset."),
03606 i18n("Insert Footnote"));
03607 } else {
03608 KWFootNoteDia dia( m_gui->canvasWidget()->footNoteType(), m_gui->canvasWidget()->numberingFootNoteType(), QString::null, this, m_doc, 0 );
03609 QPtrListIterator<KoTextCustomItem> it( edit->textDocument()->allCustomItems() );
03610 for ( ; it.current() ; ++it )
03611 {
03612 KWFootNoteVariable *fnv = dynamic_cast<KWFootNoteVariable *>( it.current() );
03613 if (fnv && !fnv->isDeleted() && fnv->frameSet() && !fnv->frameSet()->isDeleted() &&
03614 fnv->numberingType()==KWFootNoteVariable::Manual )
03615 dia.appendManualFootNote( fnv->text() );
03616 }
03617 if ( dia.exec() ) {
03618 edit->insertFootNote( dia.noteType(), dia.numberingType(), dia.manualString() );
03619 m_gui->canvasWidget()->setFootNoteType( dia.noteType() );
03620 m_gui->canvasWidget()->setNumberingFootNoteType( dia.numberingType() );
03621 }
03622 }
03623 }
03624 }
03625
03626 void KWView::updateTocActionText(bool hasToc)
03627 {
03628 KActionCollection * coll = actionCollection();
03629 QString name= hasToc ? i18n("Update Table of &Contents"):i18n("Table of &Contents");
03630 coll->action("insert_contents")->setText(name);
03631 }
03632
03633 void KWView::insertContents()
03634 {
03635 KWTextFrameSetEdit *edit = currentTextEdit();
03636 if (edit)
03637 edit->insertTOC();
03638 }
03639
03640 void KWView::formatFont()
03641 {
03642 KoTextFormatInterface* textIface = applicableTextInterfaces().first();
03643
03644 if ( !textIface || !textIface->currentFormat() )
03645 return;
03646
03647 delete m_fontDlg;
03648 m_fontDlg = new KoFontDia( *textIface->currentFormat()
03649 , m_broker
03650 , this, "" );
03651
03652 connect( m_fontDlg, SIGNAL( applyFont() ),
03653 this, SLOT( slotApplyFont() ) );
03654
03655 m_fontDlg->exec();
03656 delete m_fontDlg;
03657 m_fontDlg=0L;
03658
03659
03660 }
03661
03662 void KWView::slotApplyFont()
03663 {
03664 int flags = m_fontDlg->changedFlags();
03665 if ( flags )
03666 {
03667 KMacroCommand *globalCmd = new KMacroCommand(i18n("Change Font"));
03668 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
03669 QPtrListIterator<KoTextFormatInterface> it( lst );
03670 for ( ; it.current() ; ++it )
03671 {
03672 KoTextFormat newFormat = m_fontDlg->newFormat();
03673 KCommand *cmd = it.current()->setFormatCommand( &newFormat, flags, true);
03674 if (cmd)
03675 globalCmd->addCommand(cmd);
03676 }
03677 m_doc->addCommand(globalCmd);
03678 m_gui->canvasWidget()->setFocus();
03679 }
03680
03681 }
03682
03683 void KWView::formatParagraph()
03684 {
03685 showParagraphDialog();
03686 }
03687
03688 void KWView::showParagraphDialog( int initialPage, double initialTabPos )
03689 {
03690 KWTextFrameSetEdit *edit = currentTextEdit();
03691 if (edit)
03692 {
03693 delete m_paragDlg;
03694 bool showFrameEndOptions = !edit->frameSet()->isHeaderOrFooter() &&
03695 !edit->frameSet()->groupmanager();
03696 m_paragDlg = new KoParagDia( this, "",
03697 KoParagDia::PD_SPACING | KoParagDia::PD_ALIGN |
03698 KoParagDia::PD_DECORATION | KoParagDia::PD_NUMBERING |
03699 KoParagDia::PD_TABS,
03700 m_doc->unit(),
03701 edit->textFrameSet()->frame(0)->width(),
03702 showFrameEndOptions,
03703 edit->frameSet()->isFootEndNote());
03704 m_paragDlg->setCaption( i18n( "Paragraph Settings" ) );
03705
03706
03707 m_paragDlg->setParagLayout( edit->cursor()->parag()->paragLayout() );
03708
03709
03710 if ( initialPage != -1 )
03711 {
03712 m_paragDlg->setCurrentPage( initialPage );
03713 if ( initialPage == KoParagDia::PD_TABS )
03714 m_paragDlg->tabulatorsWidget()->setCurrentTab( initialTabPos );
03715 }
03716 connect( m_paragDlg, SIGNAL( applyParagStyle() ), this, SLOT( slotApplyParag()));
03717
03718 m_paragDlg->exec();
03719 delete m_paragDlg;
03720 m_paragDlg=0L;
03721 }
03722
03723 }
03724
03725 void KWView::slotApplyParag()
03726 {
03727 KWTextFrameSetEdit *edit = currentTextEdit();
03728 if( !edit)
03729 return;
03730 KMacroCommand * macroCommand = 0L;
03731 KCommand *cmd=0L;
03732 if(m_paragDlg->isLeftMarginChanged())
03733 {
03734 cmd=edit->setMarginCommand( QStyleSheetItem::MarginLeft, m_paragDlg->leftIndent() );
03735 if(cmd)
03736 {
03737 if ( !macroCommand )
03738 macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
03739 macroCommand->addCommand(cmd);
03740 }
03741 m_gui->getHorzRuler()->setLeftIndent( KoUnit::toUserValue( m_paragDlg->leftIndent(), m_doc->unit() ) );
03742
03743 }
03744
03745 if(m_paragDlg->isRightMarginChanged())
03746 {
03747 cmd=edit->setMarginCommand( QStyleSheetItem::MarginRight, m_paragDlg->rightIndent() );
03748 if(cmd)
03749 {
03750 if ( !macroCommand )
03751 macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
03752 macroCommand->addCommand(cmd);
03753 }
03754 m_gui->getHorzRuler()->setRightIndent( KoUnit::toUserValue( m_paragDlg->rightIndent(), m_doc->unit() ) );
03755 }
03756 if(m_paragDlg->isSpaceBeforeChanged())
03757 {
03758 cmd=edit->setMarginCommand( QStyleSheetItem::MarginTop, m_paragDlg->spaceBeforeParag() );
03759 if(cmd)
03760 {
03761 if ( !macroCommand )
03762 macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
03763 macroCommand->addCommand(cmd);
03764 }
03765 }
03766 if(m_paragDlg->isSpaceAfterChanged())
03767 {
03768 cmd=edit->setMarginCommand( QStyleSheetItem::MarginBottom, m_paragDlg->spaceAfterParag() );
03769 if(cmd)
03770 {
03771 if ( !macroCommand )
03772 macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
03773 macroCommand->addCommand(cmd);
03774 }
03775 }
03776 if(m_paragDlg->isFirstLineChanged())
03777 {
03778 cmd=edit->setMarginCommand( QStyleSheetItem::MarginFirstLine, m_paragDlg->firstLineIndent());
03779 if(cmd)
03780 {
03781 if ( !macroCommand )
03782 macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
03783 macroCommand->addCommand(cmd);
03784 }
03785 m_gui->getHorzRuler()->setFirstIndent(
03786 KoUnit::toUserValue( m_paragDlg->firstLineIndent(), m_doc->unit() ) );
03787 }
03788
03789 if(m_paragDlg->isAlignChanged())
03790 {
03791 cmd=edit->setAlignCommand( m_paragDlg->align() );
03792 if(cmd)
03793 {
03794 if ( !macroCommand )
03795 macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
03796 macroCommand->addCommand(cmd);
03797 }
03798 }
03799 if(m_paragDlg->isCounterChanged())
03800 {
03801 cmd=edit->setCounterCommand( m_paragDlg->counter() );
03802 if(cmd)
03803 {
03804 if ( !macroCommand )
03805 macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
03806 macroCommand->addCommand(cmd);
03807 }
03808 }
03809 if(m_paragDlg->listTabulatorChanged())
03810 {
03811 cmd=edit->setTabListCommand( m_paragDlg->tabListTabulator() );
03812 if(cmd)
03813 {
03814 if ( !macroCommand )
03815 macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
03816 macroCommand->addCommand(cmd);
03817 }
03818 }
03819
03820 if(m_paragDlg->isLineSpacingChanged())
03821 {
03822 cmd=edit->setLineSpacingCommand( m_paragDlg->lineSpacing(),m_paragDlg->lineSpacingType() );
03823 if(cmd)
03824 {
03825 if ( !macroCommand )
03826 macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
03827
03828 macroCommand->addCommand(cmd);
03829 }
03830 }
03831 if(m_paragDlg->isBorderChanged())
03832 {
03833 cmd=edit->setBordersCommand( m_paragDlg->leftBorder(),
03834 m_paragDlg->rightBorder(),
03835 m_paragDlg->topBorder(),
03836 m_paragDlg->bottomBorder() );
03837 if(cmd)
03838 {
03839 if ( !macroCommand )
03840 macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
03841
03842 macroCommand->addCommand(cmd);
03843 }
03844 }
03845 if( m_paragDlg->isJoinBorderChanged() )
03846 {
03847 cmd=edit->setJoinBordersCommand( m_paragDlg->joinBorder() );
03848 if(cmd)
03849 {
03850 if ( !macroCommand )
03851 macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
03852
03853 macroCommand->addCommand(cmd);
03854 }
03855 }
03856 if ( m_paragDlg->isPageBreakingChanged() )
03857 {
03858 cmd=edit->setPageBreakingCommand( m_paragDlg->pageBreaking() );
03859 if(cmd)
03860 {
03861 if ( !macroCommand )
03862 macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
03863
03864 macroCommand->addCommand(cmd);
03865 }
03866 }
03867
03868 if ( m_paragDlg->isBackgroundColorChanged() )
03869 {
03870 cmd=edit->setBackgroundColorCommand( m_paragDlg->backgroundColor() );
03871 if(cmd)
03872 {
03873 if ( !macroCommand )
03874 macroCommand = new KMacroCommand( i18n( "Paragraph Settings" ) );
03875
03876 macroCommand->addCommand(cmd);
03877 }
03878 }
03879
03880 if(macroCommand)
03881 m_doc->addCommand(macroCommand);
03882
03883
03884 m_paragDlg->setParagLayout( edit->cursor()->parag()->paragLayout() );
03885 }
03886
03887
03888 void KWView::slotHRulerDoubleClicked( double ptpos )
03889 {
03890 showParagraphDialog( KoParagDia::PD_TABS, ptpos );
03891 }
03892
03893
03894
03895
03896
03897
03898 void KWView::slotHRulerDoubleClicked()
03899 {
03900 QString mode = viewMode()->type();
03901 bool state = (mode!="ModeText");
03902 if ( !state )
03903 return;
03904
03905 KoRuler *ruler = m_gui->getHorzRuler ();
03906 if ( (ruler->flags() & KoRuler::F_INDENTS) && currentTextEdit() ) {
03907 if ( ruler->doubleClickedIndent () ) {
03908 formatParagraph();
03909 return;
03910 }
03911 }
03912
03913 formatPage();
03914 }
03915
03916 void KWView::formatPage()
03917 {
03918 if( !m_doc->isReadWrite())
03919 return;
03920 QString mode = viewMode()->type();
03921 bool state = (mode!="ModeText");
03922 if ( !state )
03923 return;
03924
03925 KoPageLayout pgLayout;
03926 KoColumns cl;
03927 KoKWHeaderFooter kwhf;
03928 m_doc->getPageLayout( pgLayout, cl, kwhf );
03929
03930 KWPageLayoutStruct oldLayout( pgLayout, cl, kwhf );
03931
03932 KoHeadFoot hf;
03933 int flags = FORMAT_AND_BORDERS | DISABLE_UNIT;
03934 if ( m_doc->processingType() == KWDocument::WP )
03935 flags |= KW_HEADER_AND_FOOTER | COLUMNS;
03936 else
03937 flags |= DISABLE_BORDERS;
03938
03939 KoUnit::Unit unit = m_doc->unit();
03940 KoUnit::Unit oldUnit = unit;
03941
03942 if ( KoPageLayoutDia::pageLayout( pgLayout, hf, cl, kwhf, flags, unit, this ) )
03943 {
03944 if( !(oldLayout._pgLayout==pgLayout) ||
03945 oldLayout._cl != cl ||
03946 oldLayout._hf != kwhf )
03947 {
03948 KWPageLayoutStruct newLayout( pgLayout, cl, kwhf );
03949
03950 KWTextFrameSetEdit *edit = currentTextEdit();
03951 if (edit)
03952 edit->textFrameSet()->clearUndoRedoInfo();
03953 KCommand *cmd =new KWPageLayoutCommand( i18n("Change Layout"),
03954 m_doc, oldLayout, newLayout );
03955 m_doc->addCommand(cmd);
03956
03957 m_doc->setPageLayout( pgLayout, cl, kwhf );
03958 }
03959 if ( unit != oldUnit )
03960 m_doc->setUnit( unit );
03961 }
03962 }
03963
03964 void KWView::formatFrameSet()
03965 {
03966 if ( frameViewManager()->selectedFrame() )
03967 {
03968 m_gui->canvasWidget()->editFrameProperties();
03969 }
03970 else
03971 KMessageBox::sorry( this,
03972 i18n("You must select a frame first."),
03973 i18n("Format Frameset"));
03974 }
03975
03976 void KWView::slotSpellCheck()
03977 {
03978 if (m_spell.kospell) return;
03979
03980 m_spell.macroCmdSpellCheck = 0L;
03981 m_spell.replaceAll.clear();
03982 QValueList<KoTextObject *> objects;
03983 KWTextFrameSetEdit * edit = currentTextEdit();
03984 if (!edit)
03985 return;
03986 int options = 0;
03987 if ( edit && edit->textFrameSet()->hasSelection() )
03988 {
03989 objects.append(edit->textFrameSet()->textObject());
03990 options = KFindDialog::SelectedText;
03991 }
03992 else
03993 {
03994 objects = m_gui->canvasWidget()->kWordDocument()->visibleTextObjects(viewMode());
03995 }
03996 m_spell.textIterator = new KoTextIterator( objects, edit, options );
03997 kdDebug()<<"Created iterator with "<< objects.count() <<endl;
03998 startKSpell();
03999 }
04000
04001 void KWView::extraAutoFormat()
04002 {
04003 m_doc->autoFormat()->readConfig();
04004 KoAutoFormatDia dia( this, 0, m_doc->autoFormat() );
04005 dia.exec();
04006 m_doc->startBackgroundSpellCheck();
04007 }
04008
04009 void KWView::extraFrameStylist()
04010 {
04011 KWTextFrameSetEdit * edit = currentTextEdit();
04012 if ( edit )
04013 edit->hideCursor();
04014 KWFrameStyleManager * frameStyleManager = new KWFrameStyleManager( this, m_doc, QString::null );
04015 frameStyleManager->exec();
04016 delete frameStyleManager;
04017 if ( edit )
04018 edit->showCursor();
04019 }
04020
04021 void KWView::createFrameStyle()
04022 {
04023
04024 QValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
04025 if (selectedFrames.count() != 1)
04026 return;
04027
04028 KWFrame* frame = selectedFrames[0]->frame();
04029
04030 KoCreateStyleDia *dia = new KoCreateStyleDia( m_doc->frameStyleCollection()->displayNameList(), this, 0 );
04031 if ( dia->exec() )
04032 {
04033 KWFrameStyle *style= new KWFrameStyle( dia->nameOfNewStyle(), frame );
04034 m_doc->frameStyleCollection()->addStyle( style );
04035 m_doc->updateAllFrameStyleLists();
04036 }
04037 delete dia;
04038 }
04039
04040 void KWView::extraStylist()
04041 {
04042 KWTextFrameSetEdit * edit = currentTextEdit();
04043 QString activeStyleName = QString::null;
04044 if ( edit )
04045 {
04046 edit->hideCursor();
04047 if (edit->cursor() && edit->cursor()->parag() && edit->cursor()->parag()->style())
04048 activeStyleName = edit->cursor()->parag()->style()->displayName();
04049 }
04050 KWStyleManager * styleManager = new KWStyleManager( this, m_doc->unit(),m_doc, *m_doc->styleCollection(), activeStyleName );
04051 styleManager->exec();
04052 delete styleManager;
04053 if ( edit )
04054 edit->showCursor();
04055 }
04056
04057 void KWView::extraCreateTemplate()
04058 {
04059 int width = 60;
04060 int height = 60;
04061 QPixmap pix = m_doc->generatePreview(QSize(width, height));
04062
04063 KTempFile tempFile( QString::null, ".odt" );
04064 tempFile.setAutoDelete(true);
04065
04066 m_doc->saveNativeFormat( tempFile.name() );
04067
04068 KoTemplateCreateDia::createTemplate( "kword_template", KWFactory::instance(),
04069 tempFile.name(), pix, this );
04070
04071 KWFactory::instance()->dirs()->addResourceType("kword_template",
04072 KStandardDirs::kde_default( "data" ) +
04073 "kword/templates/");
04074 }
04075
04076 void KWView::toolsCreateText()
04077 {
04078 if ( m_actionToolsCreateText->isChecked() )
04079 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_CREATE_TEXT );
04080 else
04081 {
04082
04083 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_EDIT );
04084 }
04085 }
04086
04087 void KWView::insertTable()
04088 {
04089 KWCanvas * canvas = m_gui->canvasWidget();
04090 canvas->setMouseMode( KWCanvas::MM_EDIT );
04091 KWTableDia *tableDia = new KWTableDia( this, 0, KWTableDia::NEW, canvas, m_doc,
04092 canvas->tableRows(),
04093 canvas->tableCols(),
04094 canvas->tableWidthMode(),
04095 canvas->tableHeightMode(),
04096 canvas->tableIsFloating(),
04097 canvas->tableTemplateName(),
04098 canvas->tableFormat());
04099 tableDia->setCaption( i18n( "Insert Table" ) );
04100 if ( tableDia->exec() == QDialog::Rejected )
04101 canvas->setMouseMode( KWCanvas::MM_EDIT );
04102 delete tableDia;
04103 }
04104
04105 void KWView::insertFormula( QMimeSource* source )
04106 {
04107 KWTextFrameSetEdit *edit = currentTextEdit();
04108 if (edit)
04109 {
04110 KWFormulaFrameSet *frameset = new KWFormulaFrameSet( m_doc, QString::null );
04111 m_doc->addFrameSet( frameset, false );
04112 if ( source ) {
04113 QByteArray data = source->encodedData( KFormula::MimeSource::selectionMimeType() );
04114 QDomDocument formula;
04115 formula.setContent( data );
04116 QDomElement formulaElem = formula.namedItem("KFORMULA").toElement();
04117 frameset->paste( formulaElem );
04118 }
04119 KWFrame *frame = new KWFrame(frameset, 0, 0, 10, 10 );
04120 frame->setZOrder( m_doc->maxZOrder( frame->pageNumber(m_doc) ) + 1 );
04121 frameset->addFrame( frame, false );
04122 edit->insertFloatingFrameSet( frameset, i18n("Insert Formula") );
04123 frameset->finalize();
04124 m_doc->refreshDocStructure(FT_FORMULA);
04125
04126 m_gui->canvasWidget()->editFrameSet( frameset );
04127 frameset->setChanged();
04128 m_gui->canvasWidget()->repaintChanged( frameset, true );
04129 }
04130 }
04131
04132 void KWView::toolsPart()
04133 {
04134 m_gui->canvasWidget()->insertPart( m_actionToolsCreatePart->documentEntry() );
04135 }
04136
04137
04138 int KWView::tableSelectCell(const QString &tableName, uint row, uint col)
04139 {
04140 if(!m_doc || !m_gui)
04141 return -1;
04142 KWFrameSet *fs = m_doc->frameSetByName(tableName);
04143 if(!fs)
04144 return -1;
04145 KWTableFrameSet *table = dynamic_cast<KWTableFrameSet*>(fs);
04146 if(!table)
04147 return -1;
04148 if (row >= table->getRows() || col >= table->getColumns())
04149 return -1;
04150
04151 KWTableFrameSet::Cell *cell = table->cell(row, col);
04152
04153 KWCanvas *canvas = m_gui->canvasWidget();
04154 if(!canvas)
04155 return -1;
04156 canvas->tableSelectCell(table, cell);
04157 return 0;
04158 }
04159
04160 int KWView::tableDeleteRow(const QValueList<uint>& rows, KWTableFrameSet *table )
04161 {
04162 if(!table)
04163 table = m_gui->canvasWidget()->getCurrentTable();
04164
04165 if (!m_doc || !table)
04166 return -1;
04167
04168 if(rows.count() >= table->getRows()) {
04169 m_doc->deleteTable(table);
04170 return 0;
04171 }
04172
04173 KMacroCommand *macro = new KMacroCommand(i18n("Remove Rows"));
04174
04175 for (int i = rows.count() - 1; i >= 0 ; i--) {
04176 KWRemoveRowCommand *cmd = new KWRemoveRowCommand( i18n("Remove Row"),
04177 table, rows[i] );
04178 macro->addCommand(cmd);
04179 }
04180
04181 macro->execute();
04182 m_doc->addCommand(macro);
04183 return 0;
04184 }
04185
04186 int KWView::tableDeleteCol(const QValueList<uint>& cols, KWTableFrameSet *table)
04187 {
04188 if(!table)
04189 table = m_gui->canvasWidget()->getCurrentTable();
04190
04191 if (!m_doc || !table)
04192 return -1;
04193
04194 if(cols.count() >= table->getColumns()) {
04195 m_doc->deleteTable(table);
04196 return 0;
04197 }
04198
04199 KMacroCommand *macro = new KMacroCommand(i18n("Remove Columns"));
04200
04201 for (int i = cols.count() - 1; i >= 0; i--) {
04202 KWRemoveColumnCommand *cmd = new KWRemoveColumnCommand( i18n("Remove Column"),
04203 table, cols[i] );
04204 macro->addCommand(cmd);
04205 }
04206
04207 macro->execute();
04208 m_doc->addCommand(macro);
04209 return 0;
04210 }
04211
04212 void KWView::tableProperties()
04213 {
04214 KWCanvas * canvas = m_gui->canvasWidget();
04215 KWTableFrameSet *table = canvas->getCurrentTable();
04216 if (table)
04217 {
04218 canvas->setMouseMode( KWCanvas::MM_EDIT );
04219 KWTableDia *tableDia = new KWTableDia( this, 0, KWTableDia::EDIT, canvas, m_doc,
04220 table->getRows(),
04221 table->getColumns(),
04222 canvas->tableWidthMode(),
04223 canvas->tableHeightMode(),
04224 canvas->tableIsFloating(),
04225 canvas->tableTemplateName(),
04226 canvas->tableFormat());
04227 tableDia->setCaption( i18n( "Adjust Table" ) );
04228 if ( tableDia->exec() == QDialog::Rejected )
04229 canvas->setMouseMode( KWCanvas::MM_EDIT );
04230 delete tableDia;
04231 }
04232 }
04233
04234 void KWView::tableInsertRow()
04235 {
04236 TableInfo ti(frameViewManager()->selectedFrames());
04237 KWTableFrameSet::Cell *cell = ti.firstSelectedCell();
04238 if(! cell) return;
04239
04240 KWInsertDia dia( this, cell->groupmanager(), KWInsertDia::insertRow, cell->firstRow());
04241 dia.exec();
04242 }
04243
04244 void KWView::tableInsertRow(uint row, KWTableFrameSet *table)
04245 {
04246 if(!table)
04247 table = m_gui->canvasWidget()->getCurrentTable();
04248
04249 if (!m_doc || !table)
04250 return;
04251
04252 if(row > table->getRows())
04253 return;
04254
04255 KWInsertRowCommand *cmd = new KWInsertRowCommand( i18n("Insert Row"), table, row);
04256 cmd->execute();
04257 m_doc->addCommand(cmd);
04258 }
04259
04260
04261 void KWView::tableInsertCol()
04262 {
04263 TableInfo ti(frameViewManager()->selectedFrames());
04264 KWTableFrameSet::Cell *cell = ti.firstSelectedCell();
04265 if(! cell) return;
04266
04267 KWInsertDia dia( this, cell->groupmanager(), KWInsertDia::insertColumn, cell->firstColumn());
04268 dia.exec();
04269 }
04270
04271 void KWView::tableInsertCol(uint col, KWTableFrameSet *table )
04272 {
04273 if(!table)
04274 table = m_gui->canvasWidget()->getCurrentTable();
04275
04276 if (!m_doc || !table)
04277 return;
04278
04279 if(col > table->getColumns())
04280 return;
04281
04282
04283
04284
04285 double maxRightOffset;
04286 if (table->isFloating())
04287 maxRightOffset = table->anchorFrameset()->frame(0)->right();
04288 else {
04289 KWPage *page = m_doc->pageManager()->page( table->cell(0,0)->frame(0) );
04290 maxRightOffset = page->width() - page->rightMargin();
04291 }
04292
04293 KWInsertColumnCommand *cmd = new KWInsertColumnCommand( i18n("Insert Column"),
04294 table, col, maxRightOffset);
04295 cmd->execute();
04296 m_doc->addCommand(cmd);
04297 }
04298
04299 void KWView::tableDeleteRow()
04300 {
04301 TableInfo ti( frameViewManager()->selectedFrames() );
04302 if(ti.amountRowsSelected() == 0) return;
04303
04304 KWDeleteDia dia( this, ti.firstSelectedCell()->groupmanager(),
04305 KWDeleteDia::deleteRow, ti.selectedRows() );
04306 dia.exec();
04307 }
04308
04309 void KWView::tableDeleteCol()
04310 {
04311 TableInfo ti( frameViewManager()->selectedFrames() );
04312 if(ti.amountColumnsSelected() == 0) return;
04313
04314 KWDeleteDia dia( this, ti.firstSelectedCell()->groupmanager(),
04315 KWDeleteDia::deleteColumn, ti.selectedColumns() );
04316 dia.exec();
04317 }
04318
04319 void KWView::tableResizeCol()
04320 {
04321 TableInfo ti( frameViewManager()->selectedFrames() );
04322 KWTableFrameSet::Cell *cell = ti.firstSelectedCell();
04323 if(cell == 0)
04324 return;
04325 KWResizeTableDia dia(this, cell->groupmanager(), m_doc, cell->firstColumn());
04326 dia.exec();
04327 }
04328
04329 void KWView::tableJoinCells()
04330 {
04331 KWTableFrameSet *table = 0;
04332 QValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
04333 QValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
04334 unsigned int x1=10000, y1=10000, x2=0, y2=0;
04335 for(;framesIterator != selectedFrames.end(); ++framesIterator) {
04336 KWFrameView *view = *framesIterator;
04337 if(!view->selected()) continue;
04338 KWFrameSet *fs = view->frame()->frameSet();
04339 Q_ASSERT(fs);
04340 KWTableFrameSet::Cell *cell = dynamic_cast<KWTableFrameSet::Cell*>(fs);
04341 if(cell == 0) continue;
04342 if(!table)
04343 table = cell->groupmanager();
04344 else if(table != cell->groupmanager()) {
04345 KMessageBox::sorry( this,
04346 i18n( "More then one table has selected cells, please make sure "
04347 "the selected cells are in one table and are connecting"),
04348 i18n( "Join Cells Failed" ) );
04349 return;
04350 }
04351
04352 if(cell->firstRow() < y1) y1 = cell->firstRow();
04353 if(cell->firstColumn() < x1) x1 = cell->firstColumn();
04354 if(cell->lastRow() > y2) y2 = cell->lastRow();
04355 if(cell->lastColumn() > x2) x2 = cell->lastColumn();
04356 }
04357
04358 Q_ASSERT(table);
04359 if (!table)
04360 return;
04361 KCommand * cmd=table->joinCells(x1, y1, x2, y2);
04362 if ( !cmd )
04363 {
04364 KMessageBox::sorry( this,
04365 i18n( "You have to select some cells which are next to each other "
04366 "and are not already joined." ),
04367 i18n( "Join Cells" ) );
04368 return;
04369 }
04370 m_doc->addCommand(cmd);
04371 m_doc->layout();
04372 }
04373
04374 void KWView::tableSplitCells() {
04375 KWSplitCellDia *splitDia=new KWSplitCellDia( this,"split cell",
04376 m_tableSplit.columns, m_tableSplit.rows );
04377 if(splitDia->exec()) {
04378 m_tableSplit.rows = splitDia->rows();
04379 m_tableSplit.columns = splitDia->columns();
04380 tableSplitCells( m_tableSplit.columns, m_tableSplit.rows );
04381 }
04382 delete splitDia;
04383 }
04384
04385 void KWView::tableSplitCells(int cols, int rows)
04386 {
04387 TableInfo ti( frameViewManager()->selectedFrames() );
04388 if(! ti.oneCellSelected()) {
04389 KMessageBox::sorry( this,
04390 i18n( "You have to put the cursor into a table "
04391 "before splitting cells." ),
04392 i18n( "Split Cells" ) );
04393 return;
04394 }
04395
04396 KWTableFrameSet::Cell *cell = ti.firstSelectedCell();
04397 KCommand *cmd=cell->groupmanager()->splitCell(rows, cols, cell->firstColumn(), cell->firstRow());
04398 if ( !cmd ) {
04399 KMessageBox::sorry( this,
04400 i18n("There is not enough space to split the cell into that many parts, make it bigger first"),
04401 i18n("Split Cells") );
04402 return;
04403 }
04404 m_doc->addCommand(cmd);
04405 m_doc->updateAllFrames();
04406 m_doc->layout();
04407 frameViewManager()->view(cell->frame(0))->setSelected(true);
04408 }
04409
04410 void KWView::tableUngroupTable()
04411 {
04412 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_EDIT );
04413
04414 KWTableFrameSet *table = m_gui->canvasWidget()->getCurrentTable();
04415 Q_ASSERT(table);
04416 if (!table)
04417 return;
04418
04419
04420 KMacroCommand * macroCmd = new KMacroCommand( i18n( "Ungroup Table" ) );
04421
04422 if ( table->isFloating() )
04423 {
04424 KWFrameSetInlineCommand *cmd = new KWFrameSetInlineCommand( QString::null, table, false );
04425 macroCmd->addCommand(cmd);
04426 }
04427
04428 KWUngroupTableCommand *cmd = new KWUngroupTableCommand( QString::null, table );
04429 macroCmd->addCommand( cmd );
04430 m_doc->addCommand( macroCmd );
04431 macroCmd->execute();
04432 }
04433
04434 void KWView::tableDelete()
04435 {
04436 KWTableFrameSet *table = m_gui->canvasWidget()->getCurrentTable();
04437 Q_ASSERT(table);
04438 if (!table)
04439 return;
04440 m_doc->deleteTable( table );
04441 }
04442
04443 void KWView::tableStylist()
04444 {
04445 KWTextFrameSetEdit * edit = currentTextEdit();
04446 if ( edit )
04447 edit->hideCursor();
04448 KWTableStyleManager * tableStyleManager = new KWTableStyleManager( this, m_doc );
04449 tableStyleManager->exec();
04450 delete tableStyleManager;
04451 if ( edit )
04452 edit->showCursor();
04453 }
04454
04455 void KWView::tableProtectCells(bool on)
04456 {
04457 KMacroCommand *macro = 0;
04458 QValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
04459 QValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
04460 for(;framesIterator != selectedFrames.end(); ++framesIterator) {
04461 KWFrameView *view = *framesIterator;
04462 KWFrameSet *fs = view->frame()->frameSet();
04463 Q_ASSERT(fs);
04464 KWTableFrameSet::Cell *cell = dynamic_cast<KWTableFrameSet::Cell*>(fs);
04465 if(cell == 0) continue;
04466 if(cell->protectContent() != on) {
04467 KWProtectContentCommand *cmd = new KWProtectContentCommand( i18n("Protect Content"), cell , on);
04468 if ( !macro )
04469 macro = new KMacroCommand( i18n("Protect Content"));
04470 macro->addCommand( cmd );
04471 }
04472 }
04473 if(macro) {
04474 macro->execute();
04475 m_doc->addCommand( macro );
04476 }
04477 }
04478
04479 void KWView::textStyleSelected( KoParagStyle *sty )
04480 {
04481 if ( !sty )
04482 return;
04483
04484 if ( m_gui->canvasWidget()->currentFrameSetEdit() )
04485 {
04486 KWTextFrameSetEdit * edit = dynamic_cast<KWTextFrameSetEdit *>(m_gui->canvasWidget()->currentFrameSetEdit()->currentTextEdit());
04487 if ( edit )
04488 edit->applyStyle( sty );
04489 }
04490 else
04491 {
04492 QValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
04493 if (selectedFrames.count() <= 0)
04494 return;
04495
04496
04497 QValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
04498 KMacroCommand *globalCmd = 0L;
04499 while(framesIterator != selectedFrames.end()) {
04500 KWFrame *curFrame = (*framesIterator)->frame();
04501 KWFrameSet *curFrameSet = curFrame->frameSet();
04502 if (curFrameSet->type() == FT_TEXT)
04503 {
04504 KoTextObject *textObject = ((KWTextFrameSet*)curFrameSet)->textObject();
04505 textObject->textDocument()->selectAll( KoTextDocument::Temp );
04506 KCommand *cmd = textObject->applyStyleCommand( 0L, sty , KoTextDocument::Temp, KoParagLayout::All, KoTextFormat::Format, true, true );
04507 textObject->textDocument()->removeSelection( KoTextDocument::Temp );
04508 if (cmd)
04509 {
04510 if ( !globalCmd )
04511 globalCmd = new KMacroCommand( selectedFrames.count() == 1 ? i18n("Apply Style to Frame") : i18n("Apply Style to Frames"));
04512 globalCmd->addCommand( cmd );
04513 }
04514 }
04515 ++framesIterator;
04516 }
04517 if ( globalCmd )
04518 m_doc->addCommand( globalCmd );
04519 }
04520 m_gui->canvasWidget()->setFocus();
04521
04522 }
04523
04524
04525 void KWView::textStyleSelected( int index )
04526 {
04527 textStyleSelected( m_doc->styleCollection()->styleAt( index ) );
04528 }
04529
04530
04531 void KWView::slotFrameStyleSelected()
04532 {
04533 QString actionName = QString::fromUtf8(sender()->name());
04534 const QString prefix = FRAMESTYLE_ACTION_PREFIX;
04535 if ( actionName.startsWith( prefix ) ) {
04536 actionName = actionName.mid( prefix.length() );
04537 frameStyleSelected( m_doc->frameStyleCollection()->findStyle( actionName ) );
04538 }
04539 }
04540
04541 void KWView::frameStyleSelected( int index )
04542 {
04543 frameStyleSelected( m_doc->frameStyleCollection()->frameStyleAt( index ) );
04544 }
04545
04546
04547
04548 void KWView::frameStyleSelected( KWFrameStyle *sty )
04549 {
04550 if ( !sty )
04551 return;
04552
04553 if ( m_gui->canvasWidget()->currentFrameSetEdit() )
04554 {
04555 KWFrame * single = m_gui->canvasWidget()->currentFrameSetEdit()->currentFrame();
04556 if ( single ) {
04557
04558 KCommand *cmd = new KWFrameStyleCommand( i18n("Apply Framestyle to Frame"), single, sty );
04559 if (cmd) {
04560 m_doc->addCommand( cmd );
04561 cmd->execute();
04562 }
04563 }
04564 }
04565 else
04566 {
04567 QValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
04568 if (selectedFrames.count() <= 0)
04569 return;
04570
04571
04572 KMacroCommand *globalCmd = new KMacroCommand( selectedFrames.count() == 1 ? i18n("Apply Framestyle to Frame") : i18n("Apply Framestyle to Frames"));
04573
04574 QValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
04575 while(framesIterator != selectedFrames.end()) {
04576 KWFrame *curFrame = (*framesIterator)->frame();
04577 KCommand *cmd = new KWFrameStyleCommand( i18n("Apply Framestyle"), curFrame, sty );
04578 if (cmd)
04579 globalCmd->addCommand( cmd );
04580 ++framesIterator;
04581 }
04582 m_doc->addCommand( globalCmd );
04583 globalCmd->execute();
04584 }
04585
04586 m_gui->canvasWidget()->repaintAll();
04587 m_gui->canvasWidget()->setFocus();
04588
04589
04590 const int pos = m_doc->frameStyleCollection()->indexOf( sty );
04591 Q_ASSERT( pos >= 0 );
04592 m_actionFrameStyle->setCurrentItem( pos );
04593 KToggleAction* act = dynamic_cast<KToggleAction *>(actionCollection()->action( sty->name().utf8() ));
04594 if ( act )
04595 act->setChecked( true );
04596 }
04597
04598
04599
04600 void KWView::slotTableStyleSelected()
04601 {
04602 QString actionName = QString::fromUtf8(sender()->name());
04603 const QString prefix = TABLESTYLE_ACTION_PREFIX;
04604 if ( actionName.startsWith( prefix ) ) {
04605 actionName = actionName.mid( prefix.length() );
04606 tableStyleSelected( m_doc->tableStyleCollection()->findStyle( actionName ) );
04607 }
04608 }
04609
04610 void KWView::tableStyleSelected( int index )
04611 {
04612 tableStyleSelected( m_doc->tableStyleCollection()->tableStyleAt( index ) );
04613 }
04614
04615
04616 void KWView::tableStyleSelected( KWTableStyle *sty )
04617 {
04618 if ( !sty )
04619 return;
04620
04621 if ( m_gui->canvasWidget()->currentFrameSetEdit() )
04622 {
04623 KWFrame * single = m_gui->canvasWidget()->currentFrameSetEdit()->currentFrame();
04624 if ( (single) && ( single->frameSet()->type() == FT_TEXT ) )
04625 {
04626 KCommand *cmd = new KWTableStyleCommand( i18n("Apply Tablestyle to Frame"), single, sty );
04627 if (cmd) {
04628 m_doc->addCommand( cmd );
04629 cmd->execute();
04630 }
04631 }
04632 }
04633 else
04634 {
04635 QValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
04636 if (selectedFrames.count() <= 0)
04637 return;
04638
04639 KMacroCommand *globalCmd = new KMacroCommand( selectedFrames.count() == 1 ? i18n("Apply Tablestyle to Frame") : i18n("Apply Tablestyle to Frames"));
04640
04641 QValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
04642 while(framesIterator != selectedFrames.end() ) {
04643 KWFrame *curFrame = (*framesIterator)->frame();
04644 if(dynamic_cast<KWTextFrameSet*>(curFrame->frameSet())) {
04645 KCommand *cmd = new KWTableStyleCommand( i18n("Apply Tablestyle to Frame"),
04646 curFrame, sty );
04647 if (cmd)
04648 globalCmd->addCommand( cmd );
04649 }
04650 ++framesIterator;
04651 }
04652 m_doc->addCommand( globalCmd );
04653 globalCmd->execute();
04654 }
04655
04656 m_gui->canvasWidget()->repaintAll();
04657 m_gui->canvasWidget()->setFocus();
04658
04659
04660 int pos = m_doc->tableStyleCollection()->indexOf( sty );
04661 m_actionTableStyle->setCurrentItem( pos );
04662 KToggleAction* act = dynamic_cast<KToggleAction *>(actionCollection()->action( sty->name().utf8() ));
04663 if ( act )
04664 act->setChecked( true );
04665 }
04666
04667 void KWView::increaseFontSize()
04668 {
04669 KWTextFrameSetEdit * edit = currentTextEdit();
04670 KoTextFormat *format = edit->currentFormat();
04671 if ( edit )
04672 textSizeSelected( edit->textFrameSet()->textObject()->docFontSize( format ) + 1 );
04673 }
04674
04675 void KWView::decreaseFontSize()
04676 {
04677 KWTextFrameSetEdit * edit = currentTextEdit();
04678 KoTextFormat *format = edit->currentFormat();
04679 if ( edit )
04680 textSizeSelected( edit->textFrameSet()->textObject()->docFontSize( format ) - 1 );
04681 }
04682
04683 void KWView::textSizeSelected( int size )
04684 {
04685 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
04686 QPtrListIterator<KoTextFormatInterface> it( lst );
04687 KMacroCommand *globalCmd = new KMacroCommand(i18n("Change Text Size"));
04688 for ( ; it.current() ; ++it )
04689 {
04690 KCommand *cmd = it.current()->setPointSizeCommand( size );
04691 if (cmd)
04692 globalCmd->addCommand(cmd);
04693 }
04694 m_doc->addCommand(globalCmd);
04695 m_gui->canvasWidget()->setFocus();
04696 }
04697
04698 void KWView::textFontSelected( const QString & font )
04699 {
04700 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
04701 if ( lst.isEmpty() ) return;
04702 QPtrListIterator<KoTextFormatInterface> it( lst );
04703 KMacroCommand* macroCmd = 0L;
04704 for ( ; it.current() ; ++it )
04705 {
04706 KCommand *cmd = it.current()->setFamilyCommand( font );
04707 if (cmd)
04708 {
04709 if ( !macroCmd )
04710 macroCmd = new KMacroCommand( i18n("Change Text Font") );
04711 macroCmd->addCommand( cmd );
04712 }
04713 }
04714 if ( macroCmd )
04715 m_doc->addCommand( macroCmd );
04716 m_gui->canvasWidget()->setFocus();
04717 }
04718
04719 QPtrList<KoTextFormatInterface> KWView::applicableTextInterfaces() const
04720 {
04721 QPtrList<KoTextFormatInterface> lst;
04722 if (currentTextEdit())
04723 {
04724 if ( !currentTextEdit()->textObject()->protectContent())
04725 {
04726
04727 lst.append( currentTextEdit() );
04728
04729 KWCollectFramesetsVisitor visitor;
04730 currentTextEdit()->textDocument()->visitSelection( KoTextDocument::Standard, &visitor );
04731 const QValueList<KWFrameSet *>& frameset = visitor.frameSets();
04732 for ( QValueList<KWFrameSet *>::ConstIterator it = frameset.begin(); it != frameset.end(); ++it )
04733 {
04734 if ( (*it)->type() == FT_TABLE )
04735 {
04736 KWTableFrameSet* kwtableframeset = static_cast<KWTableFrameSet *>( *it );
04737
04738 int const rows = kwtableframeset->getRows();
04739 int const cols = kwtableframeset->getColumns();
04740
04741 for (int r=0; r<rows; ++r)
04742 {
04743 for (int c=0; c<cols; ++c)
04744 {
04745 KWTableFrameSet::Cell *cell = kwtableframeset->cell(r,c);
04746 if (cell)
04747 {
04748 kdDebug() << "adding (" << r << "," << c << ")" << endl;
04749 lst.append(cell);
04750 }
04751 }
04752 }
04753 }
04754 }
04755 }
04756 }
04757 else
04758 {
04759
04760 QValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
04761 QValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
04762 while(framesIterator != selectedFrames.end()) {
04763 KWTextFrameSet* fs = dynamic_cast<KWTextFrameSet *>( (*framesIterator)->frame()->frameSet() );
04764 if ( fs && !lst.contains( fs )&& !fs->protectContent() )
04765 lst.append( fs );
04766 ++framesIterator;
04767 }
04768 }
04769 return lst;
04770 }
04771
04772 void KWView::textBold()
04773 {
04774 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
04775 if ( lst.isEmpty() ) return;
04776 QPtrListIterator<KoTextFormatInterface> it( lst );
04777 KMacroCommand* macroCmd = 0L;
04778 for ( ; it.current() ; ++it )
04779 {
04780 KCommand *cmd = it.current()->setBoldCommand( m_actionFormatBold->isChecked() );
04781 if (cmd)
04782 {
04783 if ( !macroCmd )
04784 macroCmd = new KMacroCommand( i18n("Make Text Bold") );
04785 macroCmd->addCommand(cmd);
04786 }
04787 }
04788 if(macroCmd)
04789 m_doc->addCommand(macroCmd);
04790
04791 }
04792
04793 void KWView::textItalic()
04794 {
04795 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
04796 QPtrListIterator<KoTextFormatInterface> it( lst );
04797 KMacroCommand* macroCmd = 0L;
04798 for ( ; it.current() ; ++it )
04799 {
04800 KCommand *cmd = it.current()->setItalicCommand( m_actionFormatItalic->isChecked() );
04801 if (cmd)
04802 {
04803 if ( !macroCmd )
04804 macroCmd = new KMacroCommand( i18n("Make Text Italic") );
04805 macroCmd->addCommand( cmd );
04806 }
04807 }
04808 if( macroCmd)
04809 m_doc->addCommand( macroCmd );
04810 }
04811
04812 void KWView::textUnderline()
04813 {
04814 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
04815 QPtrListIterator<KoTextFormatInterface> it( lst );
04816 KMacroCommand* macroCmd = 0L;
04817
04818 for ( ; it.current() ; ++it )
04819 {
04820 KCommand *cmd = it.current()->setUnderlineCommand( m_actionFormatUnderline->isChecked() );
04821 if ( cmd )
04822 {
04823 if ( !macroCmd )
04824 macroCmd = new KMacroCommand( i18n("Underline Text") );
04825 macroCmd->addCommand( cmd );
04826 }
04827 }
04828 if(macroCmd)
04829 m_doc->addCommand( macroCmd );
04830 }
04831
04832 void KWView::textStrikeOut()
04833 {
04834 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
04835 QPtrListIterator<KoTextFormatInterface> it( lst );
04836 KMacroCommand* macroCmd = 0L;
04837 for ( ; it.current() ; ++it )
04838 {
04839 KCommand *cmd = it.current()->setStrikeOutCommand( m_actionFormatStrikeOut->isChecked() );
04840 if ( cmd )
04841 {
04842 if ( !macroCmd )
04843 macroCmd = new KMacroCommand( i18n("Strike Out Text") );
04844 macroCmd->addCommand( cmd );
04845 }
04846 }
04847 if( macroCmd)
04848 m_doc->addCommand( macroCmd );
04849 }
04850
04851 void KWView::textColor()
04852 {
04853
04854
04855
04856
04857
04858
04859 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
04860 if ( lst.isEmpty() ) return;
04861 QPtrListIterator<KoTextFormatInterface> it( lst );
04862 KMacroCommand* macroCmd = 0L;
04863 for ( ; it.current() ; ++it )
04864 {
04865 KCommand *cmd = it.current()->setTextColorCommand( m_actionFormatColor->color() );
04866 if ( cmd )
04867 {
04868 if ( !macroCmd )
04869 macroCmd = new KMacroCommand( i18n("Set Text Color") );
04870 macroCmd->addCommand( cmd );
04871 }
04872 }
04873 if( macroCmd)
04874 m_doc->addCommand( macroCmd );
04875 }
04876
04877 void KWView::textAlignLeft()
04878 {
04879 if ( m_actionFormatAlignLeft->isChecked() )
04880 {
04881 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
04882 QPtrListIterator<KoTextFormatInterface> it( lst );
04883 KMacroCommand* macroCmd = 0L;
04884 for ( ; it.current() ; ++it )
04885 {
04886 KCommand *cmd = it.current()->setAlignCommand( Qt::AlignLeft );
04887 if (cmd)
04888 {
04889 if ( !macroCmd)
04890 macroCmd = new KMacroCommand( i18n("Left-Align Text") );
04891 macroCmd->addCommand( cmd );
04892 }
04893 }
04894 if( macroCmd )
04895 m_doc->addCommand( macroCmd );
04896 }
04897 else
04898 m_actionFormatAlignLeft->setChecked( true );
04899 }
04900
04901 void KWView::textAlignCenter()
04902 {
04903 if ( m_actionFormatAlignCenter->isChecked() )
04904 {
04905 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
04906 QPtrListIterator<KoTextFormatInterface> it( lst );
04907 KMacroCommand* macroCmd = 0L;
04908 for ( ; it.current() ; ++it )
04909 {
04910 KCommand *cmd = it.current()->setAlignCommand( Qt::AlignHCenter );
04911 if (cmd)
04912 {
04913 if ( !macroCmd )
04914 macroCmd = new KMacroCommand( i18n("Center Text") );
04915 macroCmd->addCommand( cmd );
04916 }
04917 }
04918 if( macroCmd )
04919 m_doc->addCommand( macroCmd );
04920 }
04921 else
04922 m_actionFormatAlignCenter->setChecked( true );
04923 }
04924
04925 void KWView::textAlignRight()
04926 {
04927 if ( m_actionFormatAlignRight->isChecked() )
04928 {
04929 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
04930 QPtrListIterator<KoTextFormatInterface> it( lst );
04931 KMacroCommand* macroCmd = 0L;
04932 for ( ; it.current() ; ++it )
04933 {
04934 KCommand *cmd = it.current()->setAlignCommand( Qt::AlignRight );
04935 if ( cmd )
04936 {
04937 if (!macroCmd )
04938 macroCmd = new KMacroCommand( i18n("Right-Align Text") );
04939 macroCmd->addCommand( cmd );
04940 }
04941 }
04942 if( macroCmd)
04943 m_doc->addCommand( macroCmd );
04944 }
04945 else
04946 m_actionFormatAlignRight->setChecked( true );
04947 }
04948
04949 void KWView::textAlignBlock()
04950 {
04951 if ( m_actionFormatAlignBlock->isChecked() )
04952 {
04953 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
04954 QPtrListIterator<KoTextFormatInterface> it( lst );
04955 KMacroCommand* macroCmd = 0L;
04956 for ( ; it.current() ; ++it )
04957 {
04958 KCommand *cmd = it.current()->setAlignCommand( Qt::AlignJustify );
04959 if ( cmd )
04960 {
04961 if ( !macroCmd )
04962 macroCmd = new KMacroCommand( i18n("Justify Text") );
04963 macroCmd->addCommand( cmd );
04964 }
04965 }
04966 if( macroCmd)
04967 m_doc->addCommand( macroCmd );
04968 }
04969 else
04970 m_actionFormatAlignBlock->setChecked( true );
04971 }
04972
04973 void KWView::setSpacing( KoParagLayout::SpacingType spacing, const QString& commandName)
04974 {
04975 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
04976 if ( lst.isEmpty() ) return;
04977 QPtrListIterator<KoTextFormatInterface> it( lst );
04978 KMacroCommand* macroCmd = 0L;
04979 for ( ; it.current() ; ++it )
04980 {
04981 KoParagLayout layout( *it.current()->currentParagLayoutFormat() );
04982 layout.lineSpacingType = spacing;
04983
04984 KCommand *cmd = it.current()->setParagLayoutFormatCommand( &layout, KoParagLayout::LineSpacing );
04985 if (cmd)
04986 {
04987 if ( !macroCmd )
04988 macroCmd = new KMacroCommand( commandName );
04989 macroCmd->addCommand(cmd);
04990 }
04991 }
04992 if( macroCmd)
04993 m_doc->addCommand(macroCmd);
04994 }
04995
04996 void KWView::textSpacingSingle()
04997 {
04998 if ( m_actionFormatSpacingSingle->isChecked() )
04999 setSpacing( KoParagLayout::LS_SINGLE, i18n("Set Single Line Spacing") );
05000 else
05001 m_actionFormatSpacingSingle->setChecked( true );
05002 }
05003
05004 void KWView::textSpacingOneAndHalf()
05005 {
05006 if ( m_actionFormatSpacingOneAndHalf->isChecked() )
05007 setSpacing( KoParagLayout::LS_ONEANDHALF, i18n("Set One and a Half Line Spacing") );
05008 else
05009 m_actionFormatSpacingOneAndHalf->setChecked( true );
05010 }
05011
05012 void KWView::textSpacingDouble()
05013 {
05014 if ( m_actionFormatSpacingDouble->isChecked() )
05015 setSpacing( KoParagLayout::LS_DOUBLE, i18n("Set Double Line Spacing") );
05016 else
05017 m_actionFormatSpacingDouble->setChecked( true );
05018 }
05019
05020 void KWView::slotCounterStyleSelected()
05021 {
05022 QString actionName = QString::fromLatin1(sender()->name());
05023 QString styleStr = actionName.mid(13);
05024
05025 KoParagCounter::Style style = (KoParagCounter::Style)(styleStr.toInt());
05026 KoParagCounter c;
05027 if ( style == KoParagCounter::STYLE_NONE )
05028 c.setNumbering( KoParagCounter::NUM_NONE );
05029 else {
05030 c.setNumbering( KoParagCounter::NUM_LIST );
05031 c.setStyle( style );
05032 if ( c.isBullet() )
05033 c.setSuffix( QString::null );
05034 else
05035 c.setSuffix( "." );
05036
05037
05038
05039
05040
05041 if ( currentTextEdit() && !currentTextEdit()->textFrameSet()->hasSelection() ) {
05042 KoTextParag* parag = currentTextEdit()->cursor()->parag();
05043 if ( parag->prev() && !parag->prev()->counter() )
05044 c.setRestartCounter(true);
05045 }
05046 }
05047
05048 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
05049 QPtrListIterator<KoTextFormatInterface> it( lst );
05050 KMacroCommand* macroCmd = 0L;
05051 for ( ; it.current() ; ++it )
05052 {
05053 KCommand *cmd = it.current()->setCounterCommand( c );
05054 if ( cmd )
05055 {
05056 if ( !macroCmd )
05057 macroCmd=new KMacroCommand( i18n("Change List Type") );
05058 macroCmd->addCommand( cmd );
05059 }
05060 }
05061 if( macroCmd)
05062 m_doc->addCommand( macroCmd );
05063 }
05064
05065 void KWView::textSuperScript()
05066 {
05067 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
05068 if ( lst.isEmpty() ) return;
05069 QPtrListIterator<KoTextFormatInterface> it( lst );
05070 KMacroCommand* macroCmd = 0L;
05071 for ( ; it.current() ; ++it )
05072 {
05073 KCommand *cmd = it.current()->setTextSuperScriptCommand(m_actionFormatSuper->isChecked());
05074 if (cmd)
05075 {
05076 if ( !macroCmd )
05077 macroCmd = new KMacroCommand( i18n("Make Text Superscript") );
05078 macroCmd->addCommand(cmd);
05079 }
05080 }
05081 if( macroCmd)
05082 m_doc->addCommand(macroCmd);
05083 if (m_actionFormatSuper->isChecked() )
05084 m_actionFormatSub->setChecked( false );
05085 }
05086
05087 void KWView::textSubScript()
05088 {
05089 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
05090 if ( lst.isEmpty() ) return;
05091 QPtrListIterator<KoTextFormatInterface> it( lst );
05092 KMacroCommand* macroCmd = 0L;
05093 for ( ; it.current() ; ++it )
05094 {
05095 KCommand *cmd = it.current()->setTextSubScriptCommand(m_actionFormatSub->isChecked());
05096 if (cmd)
05097 {
05098 if ( !macroCmd )
05099 macroCmd = new KMacroCommand( i18n("Make Text Subscript") );
05100 macroCmd->addCommand(cmd);
05101 }
05102 }
05103 if( macroCmd )
05104 m_doc->addCommand(macroCmd);
05105 if (m_actionFormatSub->isChecked() )
05106 m_actionFormatSuper->setChecked( false );
05107 }
05108
05109 void KWView::changeCaseOfText()
05110 {
05111 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
05112 if ( lst.isEmpty() ) return;
05113 QPtrListIterator<KoTextFormatInterface> it( lst );
05114 KoChangeCaseDia *caseDia=new KoChangeCaseDia( this,"change case" );
05115 if(caseDia->exec())
05116 {
05117 KMacroCommand* macroCmd = 0L;
05118 for ( ; it.current() ; ++it )
05119 {
05120 KCommand *cmd = it.current()->setChangeCaseOfTextCommand(caseDia->getTypeOfCase());
05121 if (cmd)
05122 {
05123 if ( !macroCmd )
05124 macroCmd = new KMacroCommand( i18n("Change Case of Text") );
05125 macroCmd->addCommand(cmd);
05126 }
05127 }
05128 if( macroCmd )
05129 m_doc->addCommand(macroCmd);
05130 }
05131 delete caseDia;
05132 }
05133
05134 void KWView::editPersonalExpr()
05135 {
05136 KWEditPersonnalExpression *personalDia=new KWEditPersonnalExpression( this );
05137 if(personalDia->exec())
05138 m_doc->refreshMenuExpression();
05139 delete personalDia;
05140 }
05141
05142
05143 void KWView::textIncreaseIndent()
05144 {
05145 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
05146 if ( lst.isEmpty() ) return;
05147 QPtrListIterator<KoTextFormatInterface> it( lst );
05148 double leftMargin=0.0;
05149 if(!lst.isEmpty())
05150 leftMargin=lst.first()->currentParagLayoutFormat()->margins[QStyleSheetItem::MarginLeft];
05151 double indent = m_doc->indentValue();
05152 double newVal = leftMargin + indent;
05153 KMacroCommand* macroCmd = 0L;
05154 for ( ; it.current() ; ++it )
05155 {
05156 KCommand *cmd = it.current()->setMarginCommand( QStyleSheetItem::MarginLeft, newVal );
05157 if (cmd)
05158 {
05159 if ( !macroCmd )
05160 macroCmd = new KMacroCommand( i18n("Increase Paragraph Depth") );
05161 macroCmd->addCommand(cmd);
05162 }
05163 }
05164 if( macroCmd)
05165 m_doc->addCommand(macroCmd);
05166 if(!lst.isEmpty())
05167 {
05168 const KoParagLayout *layout=lst.first()->currentParagLayoutFormat();
05169 showRulerIndent( layout->margins[QStyleSheetItem::MarginLeft], layout->margins[QStyleSheetItem::MarginFirstLine], layout->margins[QStyleSheetItem::MarginRight], lst.first()->rtl());
05170 }
05171 #if 0
05172
05173
05174 KWTextFrameSetEdit * edit = currentTextEdit();
05175 if ( edit )
05176 {
05177 double leftMargin = edit->currentLeftMargin();
05178 double indent = m_doc->indentValue();
05179 double newVal = leftMargin + indent;
05180
05181
05182
05183 {
05184 KCommand *cmd=edit->setMarginCommand( QStyleSheetItem::MarginLeft, newVal );
05185 if(cmd)
05186 m_doc->addCommand(cmd);
05187 }
05188 }
05189 #endif
05190 }
05191
05192 void KWView::textDecreaseIndent()
05193 {
05194 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
05195 if ( lst.isEmpty() ) return;
05196 QPtrListIterator<KoTextFormatInterface> it( lst );
05197 double leftMargin=0.0;
05198 if(!lst.isEmpty())
05199 leftMargin=lst.first()->currentParagLayoutFormat()->margins[QStyleSheetItem::MarginLeft];
05200 double indent = m_doc->indentValue();
05201 double newVal = leftMargin - indent;
05202 KMacroCommand* macroCmd = 0L;
05203 for ( ; it.current() ; ++it )
05204 {
05205 KCommand *cmd = it.current()->setMarginCommand( QStyleSheetItem::MarginLeft, QMAX( newVal, 0 ) );
05206 if (cmd)
05207 {
05208 if ( !macroCmd )
05209 macroCmd = new KMacroCommand( i18n("Decrease Paragraph Depth") );
05210 macroCmd->addCommand(cmd);
05211 }
05212 }
05213 if( macroCmd)
05214 m_doc->addCommand(macroCmd);
05215 if(!lst.isEmpty())
05216 {
05217 const KoParagLayout *layout=lst.first()->currentParagLayoutFormat();
05218 showRulerIndent( layout->margins[QStyleSheetItem::MarginLeft], layout->margins[QStyleSheetItem::MarginFirstLine], layout->margins[QStyleSheetItem::MarginRight], lst.first()->rtl());
05219 }
05220
05221
05222 #if 0
05223 KWTextFrameSetEdit * edit = currentTextEdit();
05224 if ( edit )
05225 {
05226 double leftMargin = edit->currentLeftMargin();
05227 if ( leftMargin > 0 )
05228 {
05229 double indent = m_doc->indentValue();
05230 double newVal = leftMargin - indent;
05231 KCommand *cmd=edit->setMarginCommand( QStyleSheetItem::MarginLeft, QMAX( newVal, 0 ) );
05232 if(cmd)
05233 m_doc->addCommand(cmd);
05234 }
05235 }
05236 #endif
05237 }
05238
05239
05240 void KWView::textDefaultFormat()
05241 {
05242 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
05243 if ( lst.isEmpty() ) return;
05244 QPtrListIterator<KoTextFormatInterface> it( lst );
05245 KMacroCommand* macroCmd = 0L;
05246 for ( ; it.current() ; ++it )
05247 {
05248 KCommand *cmd = it.current()->setDefaultFormatCommand();
05249 if (cmd)
05250 {
05251 if ( !macroCmd )
05252 macroCmd = new KMacroCommand( i18n("Default Format") );
05253 macroCmd->addCommand(cmd);
05254 }
05255 }
05256 if( macroCmd)
05257 m_doc->addCommand(macroCmd);
05258 }
05259
05260
05261 void KWView::borderOutline()
05262 {
05263 bool on = m_actionBorderOutline->isChecked();
05264 if(m_actionBorderLeft->isChecked() != on) {
05265 m_actionBorderLeft->setChecked(on);
05266 borderLeft();
05267 }
05268 if(m_actionBorderRight->isChecked() != on) {
05269 m_actionBorderRight->setChecked(on);
05270 borderRight();
05271 }
05272 if(m_actionBorderTop->isChecked() != on) {
05273 m_actionBorderTop->setChecked(on);
05274 borderTop();
05275 }
05276 if(m_actionBorderBottom->isChecked() != on) {
05277 m_actionBorderBottom->setChecked(on);
05278 borderBottom();
05279 }
05280 }
05281
05282 void KWView::borderLeft() {
05283 borderChanged(KoBorder::LeftBorder);
05284 }
05285
05286 void KWView::borderRight() {
05287 borderChanged(KoBorder::RightBorder);
05288 }
05289
05290 void KWView::borderTop() {
05291 borderChanged(KoBorder::TopBorder);
05292 }
05293
05294 void KWView::borderBottom() {
05295 borderChanged(KoBorder::BottomBorder);
05296 }
05297
05298 void KWView::borderChanged(KoBorder::BorderType type) {
05299 KoBorder border;
05300 border.setPenWidth( m_actionBorderWidth->currentText().toInt() );
05301 border.color = m_actionBorderColor->color();
05302 border.setStyle( KoBorder::getStyle( m_actionBorderStyle->currentText() ) );
05303 bool enabled = false;
05304 QString comment;
05305 switch(type) {
05306 case KoBorder::LeftBorder:
05307 enabled = m_actionBorderLeft->isChecked();
05308 comment = i18n("Change Left Frame Border");
05309 break;
05310 case KoBorder::RightBorder:
05311 enabled = m_actionBorderRight->isChecked();
05312 comment = i18n("Change Right Frame Border");
05313 break;
05314 case KoBorder::TopBorder:
05315 enabled = m_actionBorderTop->isChecked();
05316 comment = i18n("Change Top Frame Border");
05317 break;
05318 case KoBorder::BottomBorder:
05319 default:
05320 enabled = m_actionBorderBottom->isChecked();
05321 comment = i18n("Change Bottom Frame Border");
05322 break;
05323 }
05324 if(!enabled)
05325 border.setPenWidth(0);
05326
05327 KCommand *cmd = 0;
05328 KWTextFrameSetEdit *edit = currentTextEdit();
05329 if ( edit ) {
05330 KoBorder left = edit->border(KoBorder::LeftBorder);
05331 KoBorder right = edit->border(KoBorder::RightBorder);
05332 KoBorder top = edit->border(KoBorder::TopBorder);
05333 KoBorder bottom = edit->border(KoBorder::BottomBorder);
05334 if(type == KoBorder::LeftBorder)
05335 left = border;
05336 else if(type == KoBorder::RightBorder)
05337 right = border;
05338 else if(type == KoBorder::TopBorder)
05339 top = border;
05340 else
05341 bottom = border;
05342 cmd=edit->setBordersCommand( left, right, top, bottom );
05343 }
05344 else {
05345 QPtrList<FrameIndex> indexes;
05346 QPtrList<KWFrameBorderCommand::FrameBorderTypeStruct> borders;
05347 QValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
05348 QValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
05349 for(;framesIterator != selectedFrames.end(); ++framesIterator) {
05350 if( !(*framesIterator)->selected() ) continue;
05351 KWFrame *frame = (*framesIterator)->frame();
05352 indexes.append(new FrameIndex( frame ));
05353 KWFrameBorderCommand::FrameBorderTypeStruct *bts =
05354 new KWFrameBorderCommand::FrameBorderTypeStruct;
05355 bts->m_EFrameType = type;
05356 if(type == KoBorder::LeftBorder)
05357 bts->m_OldBorder=frame->leftBorder();
05358 else if(type == KoBorder::RightBorder)
05359 bts->m_OldBorder=frame->rightBorder();
05360 else if(type == KoBorder::TopBorder)
05361 bts->m_OldBorder=frame->topBorder();
05362 else
05363 bts->m_OldBorder=frame->bottomBorder();
05364 borders.append(bts);
05365 }
05366 if(indexes.count() > 0)
05367 cmd=new KWFrameBorderCommand(comment, indexes, borders, border);
05368 }
05369 if(cmd) {
05370 cmd->execute();
05371 m_doc->addCommand( cmd );
05372 }
05373
05374 m_actionBorderOutline->setChecked(
05375 m_actionBorderLeft->isChecked() && m_actionBorderRight->isChecked() &&
05376 m_actionBorderTop->isChecked() && m_actionBorderBottom->isChecked());
05377 }
05378
05379 void KWView::backgroundColor()
05380 {
05381 QColor backColor = m_actionBackgroundColor->color();
05382
05383 KWTextFrameSetEdit *edit = currentTextEdit();
05384 if ( m_gui)
05385 {
05386 if(edit)
05387 {
05388 KCommand *cmd=edit->setTextBackgroundColorCommand(backColor);
05389 if( cmd)
05390 m_doc->addCommand( cmd );
05391 }
05392 else
05393 m_gui->canvasWidget()->setFrameBackgroundColor( backColor );
05394 }
05395 }
05396
05397 void KWView::resizeEvent( QResizeEvent *e )
05398 {
05399 QWidget::resizeEvent( e );
05400 if ( m_gui )
05401 {
05402 m_gui->resize( width(), height() );
05403 QString s = m_actionViewZoom->currentText();
05404 if ( !KoZoomMode::isConstant(s) )
05405 viewZoom( s );
05406 }
05407 }
05408
05409 void KWView::guiActivateEvent( KParts::GUIActivateEvent *ev )
05410 {
05411 if ( ev->activated() )
05412 {
05413 initGui();
05414 if (m_doc->isEmbedded() ) {
05415
05416 const int zoom = qRound( KoView::zoom() * 100 );
05417 setZoom( zoom, true );
05418 showZoom( zoom );
05419 }
05420 }
05421 KoView::guiActivateEvent( ev );
05422 }
05423
05424 void KWView::tabListChanged( const KoTabulatorList & tabList )
05425 {
05426 if(!m_doc->isReadWrite())
05427 return;
05428 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
05429 if ( lst.isEmpty() ) return;
05430 QPtrListIterator<KoTextFormatInterface> it( lst );
05431 KMacroCommand* macroCmd = 0L;
05432 for ( ; it.current() ; ++it )
05433 {
05434 KCommand *cmd = it.current()->setTabListCommand( tabList );
05435 if (cmd)
05436 {
05437 if ( !macroCmd )
05438 macroCmd = new KMacroCommand(i18n("Change Tabulator") );
05439 macroCmd->addCommand(cmd);
05440 }
05441 }
05442 if(macroCmd)
05443 m_doc->addCommand(macroCmd);
05444 }
05445
05446 void KWView::newPageLayout( const KoPageLayout &layout )
05447 {
05448 QString mode = viewMode()->type();
05449 bool state = (mode!="ModeText");
05450 if ( !state )
05451 return;
05452
05453 KoPageLayout pgLayout;
05454 KoColumns cl;
05455 KoKWHeaderFooter hf;
05456 m_doc->getPageLayout( pgLayout, cl, hf );
05457
05458 if(layout==pgLayout)
05459 return;
05460
05461 KWPageLayoutStruct oldLayout( pgLayout, cl, hf );
05462
05463 m_doc->setPageLayout( layout, cl, hf );
05464
05465 KWPageLayoutStruct newLayout( layout, cl, hf );
05466
05467 KWTextFrameSetEdit *edit = currentTextEdit();
05468 if (edit)
05469 edit->textFrameSet()->clearUndoRedoInfo();
05470 KCommand *cmd = new KWPageLayoutCommand( i18n("Change Layout"), m_doc, oldLayout, newLayout );
05471 m_doc->addCommand(cmd);
05472 }
05473
05474 void KWView::slotPageLayoutChanged( const KoPageLayout& layout )
05475 {
05476
05477
05478
05479 viewMode()->setPageLayout( m_gui->getHorzRuler(), m_gui->getVertRuler(), layout );
05480 m_gui->canvasWidget()->repaintAll();
05481 }
05482
05483 void KWView::newFirstIndent( double firstIndent )
05484 {
05485 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
05486 if ( lst.isEmpty() ) return;
05487 QPtrListIterator<KoTextFormatInterface> it( lst );
05488 KMacroCommand* macroCmd = 0L;
05489 for ( ; it.current() ; ++it )
05490 {
05491 KCommand *cmd = it.current()->setMarginCommand( QStyleSheetItem::MarginFirstLine, firstIndent );
05492 if (cmd)
05493 {
05494 if ( !macroCmd )
05495 macroCmd = new KMacroCommand(i18n("Change First Line Indent"));
05496 macroCmd->addCommand(cmd);
05497 }
05498 }
05499 if(macroCmd)
05500 m_doc->addCommand(macroCmd);
05501 }
05502
05503 void KWView::newLeftIndent( double leftIndent )
05504 {
05505 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
05506 if ( lst.isEmpty() ) return;
05507 QPtrListIterator<KoTextFormatInterface> it( lst );
05508 KMacroCommand* macroCmd = 0L;
05509 for ( ; it.current() ; ++it )
05510 {
05511 KCommand *cmd = it.current()->setMarginCommand( QStyleSheetItem::MarginLeft, leftIndent );
05512 if (cmd)
05513 {
05514 if ( !macroCmd )
05515 macroCmd = new KMacroCommand(i18n("Change Indent") );
05516 macroCmd->addCommand(cmd);
05517 }
05518 }
05519 if(macroCmd)
05520 m_doc->addCommand(macroCmd);
05521
05522 }
05523
05524 void KWView::newRightIndent( double rightIndent)
05525 {
05526
05527 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
05528 if ( lst.isEmpty() ) return;
05529 QPtrListIterator<KoTextFormatInterface> it( lst );
05530 KMacroCommand* macroCmd = 0L;
05531 for ( ; it.current() ; ++it )
05532 {
05533 KCommand *cmd = it.current()->setMarginCommand( QStyleSheetItem::MarginRight, rightIndent );
05534 if (cmd)
05535 {
05536 if ( !macroCmd )
05537 macroCmd = new KMacroCommand(i18n("Change Indent") );
05538 macroCmd->addCommand(cmd);
05539 }
05540 }
05541 if(macroCmd)
05542 m_doc->addCommand(macroCmd);
05543 }
05544
05545 QPopupMenu * KWView::popupMenu( const QString& name )
05546 {
05547
05548
05549
05550 if ( !factory() )
05551 partManager()->setActivePart( m_doc, this );
05552 Q_ASSERT( factory() );
05553 if ( factory() )
05554 return ((QPopupMenu*)factory()->container( name, this ));
05555 return 0;
05556 }
05557
05558 void KWView::startKSpell()
05559 {
05560 if ( !m_spell.kospell )
05561 m_spell.kospell = new KoSpell( m_broker, this );
05562
05563
05564 Q_ASSERT( m_spell.textIterator );
05565
05566 m_spell.kospell->check( m_spell.textIterator, true );
05567 delete m_spell.dlg;
05568 m_spell.dlg = new KSpell2::Dialog( m_spell.kospell, this );
05569 m_spell.dlg->activeAutoCorrect( true );
05570
05571 QObject::connect( m_spell.dlg, SIGNAL(misspelling(const QString&, int)),
05572 this, SLOT(spellCheckerMisspelling(const QString&, int)) );
05573 QObject::connect( m_spell.dlg, SIGNAL(replace(const QString&, int, const QString&)),
05574 this, SLOT(spellCheckerCorrected(const QString&, int, const QString&)) );
05575 QObject::connect( m_spell.dlg, SIGNAL(done(const QString&) ),
05576 this, SLOT(spellCheckerDone(const QString&)) );
05577 QObject::connect( m_spell.dlg, SIGNAL(cancel() ),
05578 this, SLOT( spellCheckerCancel() ) );
05579 QObject::connect( m_spell.dlg, SIGNAL(autoCorrect(const QString &, const QString & ) ),
05580 this, SLOT( spellAddAutoCorrect (const QString &, const QString &) ) );
05581
05582 m_spell.dlg->show();
05583
05584 }
05585
05586 void KWView::spellCheckerMisspelling( const QString &old, int pos )
05587 {
05588
05589 KoTextObject* textobj = m_spell.kospell->currentTextObject();
05590 KoTextParag* parag = m_spell.kospell->currentParag();
05591 Q_ASSERT( textobj );
05592 Q_ASSERT( parag );
05593 if ( !textobj || !parag ) return;
05594 KWTextDocument *textdoc=static_cast<KWTextDocument *>( textobj->textDocument() );
05595 Q_ASSERT( textdoc );
05596 if ( !textdoc ) return;
05597 pos += m_spell.kospell->currentStartIndex();
05598 kdDebug(32001) << "KWView::spellCheckerMisspelling parag=" << parag->paragId() << " pos=" << pos << " length=" << old.length() << endl;
05599 textdoc->textFrameSet()->highlightPortion( parag, pos, old.length(), m_gui->canvasWidget() );
05600 }
05601
05602 void KWView::spellCheckerCorrected( const QString &old, int pos , const QString &corr )
05603 {
05604
05605 KoTextObject* textobj = m_spell.kospell->currentTextObject();
05606 KoTextParag* parag = m_spell.kospell->currentParag();
05607 Q_ASSERT( textobj );
05608 Q_ASSERT( parag );
05609 if ( !textobj || !parag ) return;
05610 KWTextDocument *textdoc=static_cast<KWTextDocument *>( textobj->textDocument() );
05611 Q_ASSERT( textdoc );
05612 if ( !textdoc ) return;
05613 pos += m_spell.kospell->currentStartIndex();
05614 textdoc->textFrameSet()->highlightPortion( parag, pos, old.length(), m_gui->canvasWidget() );
05615
05616 KoTextCursor cursor( textdoc );
05617 cursor.setParag( parag );
05618 cursor.setIndex( pos );
05619 if(!m_spell.macroCmdSpellCheck)
05620 m_spell.macroCmdSpellCheck=new KMacroCommand(i18n("Correct Misspelled Word"));
05621 m_spell.macroCmdSpellCheck->addCommand(textobj->replaceSelectionCommand(
05622 &cursor, corr, QString::null, KoTextDocument::HighlightSelection));
05623 }
05624
05625 void KWView::spellCheckerDone( const QString & )
05626 {
05627
05628 KWTextDocument *textdoc=static_cast<KWTextDocument *>( m_spell.kospell->textDocument() );
05629 Q_ASSERT( textdoc );
05630 if ( textdoc )
05631 textdoc->textFrameSet()->removeHighlight();
05632
05633 clearSpellChecker();
05634 }
05635
05636 void KWView::clearSpellChecker(bool cancelSpellCheck)
05637 {
05638 kdDebug(32001) << "KWView::clearSpellChecker" << endl;
05639
05640 delete m_spell.textIterator;
05641 m_spell.textIterator = 0L;
05642 delete m_spell.kospell;
05643 m_spell.kospell = 0;
05644
05645 if ( m_spell.macroCmdSpellCheck )
05646 {
05647 if ( !cancelSpellCheck )
05648 m_doc->addCommand(m_spell.macroCmdSpellCheck);
05649 else
05650 {
05651
05652 m_spell.macroCmdSpellCheck->unexecute();
05653 delete m_spell.macroCmdSpellCheck;
05654 }
05655 }
05656 m_spell.macroCmdSpellCheck=0L;
05657 m_spell.replaceAll.clear();
05658
05659 }
05660
05661 void KWView::spellCheckerCancel()
05662 {
05663 kdDebug()<<"void KWView::spellCheckerCancel() \n";
05664 spellCheckerRemoveHighlight();
05665
05666 clearSpellChecker(true);
05667 }
05668
05669
05670 void KWView::spellCheckerRemoveHighlight()
05671 {
05672 KoTextObject* textobj = m_spell.kospell->currentTextObject();
05673 if ( textobj ) {
05674 KWTextDocument *textdoc=static_cast<KWTextDocument *>( textobj->textDocument() );
05675 if ( textdoc )
05676 textdoc->textFrameSet()->removeHighlight();
05677 }
05678 KWTextFrameSetEdit * edit = currentTextEdit();
05679 if (edit)
05680 edit->drawCursor( TRUE );
05681 }
05682
05683 void KWView::spellAddAutoCorrect (const QString & originalword, const QString & newword)
05684 {
05685 m_doc->autoFormat()->addAutoFormatEntry( originalword, newword );
05686 }
05687
05688 void KWView::configure()
05689 {
05690 KWConfig configDia( this );
05691 configDia.exec();
05692 }
05693
05694 KWTextFrameSetEdit *KWView::currentTextEdit() const
05695 {
05696 if (!m_gui)
05697 return 0L;
05698 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
05699 if ( edit )
05700 return dynamic_cast<KWTextFrameSetEdit *>(edit->currentTextEdit());
05701 return 0L;
05702 }
05703
05704 void KWView::slotFrameSetEditChanged()
05705 {
05706 KWTextFrameSetEdit * edit = currentTextEdit();
05707 bool rw = koDocument()->isReadWrite();
05708 bool selectedFrames = frameViewManager()->selectedFrames().count() > 0;
05709 bool hasSelection = false;
05710 if ( edit ) {
05711 hasSelection = edit->textFrameSet()->hasSelection();
05712 if ( edit->textFrameSet()->textObject()->protectContent())
05713 rw = false;
05714 }
05715 else {
05716 KWFrameSetEdit * e = m_gui->canvasWidget()->currentFrameSetEdit();
05717 if ( e && e->frameSet()->type() == FT_FORMULA ) {
05718 hasSelection = true;
05719 }
05720 }
05721 m_actionEditCut->setEnabled( hasSelection && rw );
05722
05723 m_actionEditCopy->setEnabled( hasSelection );
05724 m_actionEditReplace->setEnabled( rw );
05725 clipboardDataChanged();
05726
05727 bool state = (edit != 0 | selectedFrames) && rw;
05728 m_actionEditSelectAll->setEnabled(state);
05729 m_actionEditSelectCurrentFrame->setEnabled(state);
05730 m_actionInsertComment->setEnabled( state );
05731 m_actionFormatDefault->setEnabled( state );
05732 m_actionFormatFont->setEnabled( state );
05733 m_actionFormatFontSize->setEnabled( state );
05734 m_actionFormatFontFamily->setEnabled( state );
05735 m_actionAddBookmark->setEnabled(state);
05736 m_actionBackgroundColor->setEnabled( state );
05737 m_actionFormatStyleMenu->setEnabled( state );
05738 m_actionFormatBold->setEnabled( state );
05739 m_actionFormatItalic->setEnabled( state );
05740 m_actionFormatUnderline->setEnabled( state );
05741 m_actionFormatStrikeOut->setEnabled( state );
05742 m_actionFormatColor->setEnabled( state );
05743 m_actionFormatAlignLeft->setEnabled( state );
05744 m_actionFormatAlignCenter->setEnabled( state );
05745 m_actionFormatAlignRight->setEnabled( state );
05746 m_actionFormatAlignBlock->setEnabled( state );
05747
05748 m_actionBorderLeft->setEnabled( state );
05749 m_actionBorderRight->setEnabled( state );
05750 m_actionBorderTop->setEnabled( state );
05751 m_actionBorderBottom->setEnabled( state );
05752 m_actionBorderOutline->setEnabled( state );
05753 m_actionBorderColor->setEnabled( state );
05754 m_actionBorderWidth->setEnabled( state );
05755 m_actionBorderStyle->setEnabled( state );
05756
05757
05758
05759 m_actionInsertLink->setEnabled(state);
05760 m_actionCreateStyleFromSelection->setEnabled( state );
05761 m_actionConvertToTextBox->setEnabled( state && hasSelection);
05762 m_actionAddPersonalExpression->setEnabled( state && hasSelection);
05763 m_actionSortText->setEnabled( state && hasSelection);
05764 bool goodleftMargin=false;
05765 if(state && edit)
05766 goodleftMargin=(edit->currentLeftMargin()>0);
05767
05768 m_actionFormatDecreaseIndent->setEnabled(goodleftMargin);
05769 const bool canChangeCounter = rw && ( !edit || !edit->textFrameSet()->isFootEndNote() );
05770 m_actionFormatBullet->setEnabled(canChangeCounter);
05771 m_actionFormatNumber->setEnabled(canChangeCounter);
05772 m_actionFormatStyle->setEnabled(rw);
05773 m_actionFormatSpacingSingle->setEnabled(rw);
05774 m_actionFormatSpacingOneAndHalf->setEnabled(rw);
05775 m_actionFormatSpacingDouble->setEnabled(rw);
05776 m_actionFormatSuper->setEnabled(rw);
05777 m_actionFormatSub->setEnabled(rw);
05778 m_actionFormatParag->setEnabled(state);
05779 m_actionInsertSpecialChar->setEnabled(state);
05780 m_actionSpellCheck->setEnabled(state);
05781
05782 m_actionChangeCase->setEnabled( (rw && !edit)|| (state && hasSelection) );
05783
05784 if ( edit && edit->textFrameSet()->protectContent())
05785 {
05786 m_actionChangeCase->setEnabled( false );
05787 m_actionEditCut->setEnabled( false );
05788 }
05789 else
05790 m_actionChangeCase->setEnabled( true );
05791
05792 updateTableActions( frameViewManager()->selectedFrames() ) ;
05793
05794 m_actionInsertFormula->setEnabled(state && (viewMode()->type()!="ModeText"));
05795 actionInsertVariable->setEnabled(state);
05796 m_actionInsertExpression->setEnabled(state);
05797
05798 changeFootEndNoteState();
05799
05800 state= state && edit && edit->frameSet() && !edit->frameSet()->isHeaderOrFooter() && !edit->frameSet()->groupmanager() && !edit->frameSet()->isFootEndNote();
05801 m_actionInsertContents->setEnabled(state);
05802 m_actionInsertFrameBreak->setEnabled( state );
05803 updatePageInfo();
05804 }
05805
05806 void KWView::changeFootEndNoteState()
05807 {
05808 bool rw = koDocument()->isReadWrite();
05809 KWTextFrameSetEdit * edit = currentTextEdit();
05810 QString mode = viewMode()->type();
05811
05812 bool isEditableFrameset = edit && edit->frameSet() && edit->frameSet()->isMainFrameset();
05813 bool ok = rw && isEditableFrameset && (mode!="ModeText");
05814 m_actionInsertFootEndNote->setEnabled( ok );
05815 m_actionEditFootEndNote->setEnabled( ok );
05816 }
05817
05818 void KWView::changeFootNoteMenuItem( bool footnote)
05819 {
05820 m_actionEditFootEndNote->setText( footnote? i18n("Edit Footnote"): i18n("Edit Endnote"));
05821 m_actionChangeFootNoteType->setText( footnote? i18n("Change Footnote Parameter"):i18n("Change Endnote Parameter"));
05822 }
05823
05824 void KWView::slotUpdateRuler()
05825 {
05826 KWCanvas* canvas = m_gui->canvasWidget();
05827 QRect r( canvas->viewMode()->rulerFrameRect() );
05828 if ( !r.isNull() )
05829 {
05830 m_gui->getHorzRuler()->setFrameStartEnd( r.left(), r.right() );
05831 m_gui->getVertRuler()->setFrameStartEnd( r.top(), r.bottom() );
05832 }
05833 canvas->updateRulerOffsets();
05834 }
05835
05836 void KWView::frameSelectedChanged()
05837 {
05838 bool rw = koDocument()->isReadWrite();
05839 QValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
05840
05841 m_actionFormatFrameSet->setEnabled( selectedFrames.count() >= 1 );
05842 if ( rw && selectedFrames.count() >= 1 )
05843 {
05844 bool okForDelete = true;
05845 bool okForCopy = true;
05846 bool okForLowerRaise = false;
05847 bool okForChangeParagStyle = true;
05848 bool okForChangeInline = true;
05849 bool containsCellFrame = false;
05850 bool containsMainFrame = false;
05851
05852 QValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
05853 while(framesIterator != selectedFrames.end() && (okForDelete || okForLowerRaise ||
05854 okForChangeParagStyle || okForChangeInline) ) {
05855
05856 bool isFootNote = (*framesIterator)->frame()->frameSet()->isFootEndNote();
05857 bool headerFooterFootNote = isFootNote ||
05858 (*framesIterator)->frame()->frameSet()->isHeaderOrFooter();
05859 bool isMainWPFrame = (*framesIterator)->frame()->frameSet()->isMainFrameset();
05860 okForChangeParagStyle &= !isFootNote;
05861 okForCopy &= !headerFooterFootNote;
05862
05863 okForDelete &= !headerFooterFootNote;
05864 okForDelete &= !isMainWPFrame;
05865
05866
05867
05868
05869 okForLowerRaise |= !(isMainWPFrame || headerFooterFootNote || (*framesIterator)->frame()->frameSet()->isFloating());
05870 okForChangeInline &= !(isMainWPFrame || headerFooterFootNote );
05871
05872 if ( (*framesIterator)->frame()->frameSet()->groupmanager() )
05873 containsCellFrame = true;
05874 if ( isMainWPFrame )
05875 containsMainFrame = true;
05876 ++framesIterator;
05877 }
05878 m_actionEditDelFrame->setEnabled( okForDelete );
05879 m_actionEditCut->setEnabled( okForDelete && !containsCellFrame );
05880 m_actionEditCopy->setEnabled( selectedFrames.count() >= 1 && okForCopy && !containsMainFrame && !containsCellFrame);
05881
05882 m_actionLowerFrame->setEnabled( okForLowerRaise );
05883 m_actionRaiseFrame->setEnabled( okForLowerRaise );
05884 m_actionSendBackward->setEnabled( okForLowerRaise );
05885 m_actionBringToFront->setEnabled( okForLowerRaise );
05886 m_actionFormatBullet->setEnabled( okForChangeParagStyle );
05887 m_actionFormatNumber->setEnabled( okForChangeParagStyle );
05888 m_actionFormatStyle->setEnabled( okForChangeParagStyle);
05889 m_actionInlineFrame->setEnabled( okForChangeInline);
05890
05891 KWFrame *frame = selectedFrames[0]->frame();
05892 updateBorderButtons(frame->leftBorder(), frame->rightBorder(), frame->topBorder(),
05893 frame->bottomBorder());
05894 } else
05895 {
05896 m_actionEditDelFrame->setEnabled( false );
05897 m_actionInlineFrame->setEnabled(false);
05898 m_actionEditCut->setEnabled( false );
05899 m_actionLowerFrame->setEnabled( false );
05900 m_actionRaiseFrame->setEnabled( false );
05901 m_actionSendBackward->setEnabled( false );
05902 m_actionBringToFront->setEnabled( false );
05903
05904 }
05905 bool frameDifferentOfPart=false;
05906 if(selectedFrames.count() >= 1)
05907 {
05908 QValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
05909 while(framesIterator != selectedFrames.end()) {
05910 if ( (*framesIterator)->frame()->frameSet()->type()!=FT_PART &&
05911 (*framesIterator)->frame()->frameSet()->type()!= FT_PICTURE) {
05912 frameDifferentOfPart=true;
05913 break;
05914 }
05915 ++framesIterator;
05916 }
05917 }
05918
05919 m_actionBackgroundColor->setEnabled( (selectedFrames.count() >= 1) && frameDifferentOfPart);
05920 m_actionBackgroundColor->setText(i18n("Frame Background Color..."));
05921
05922 if ( frameDifferentOfPart ) {
05923 KWFrame *frame = selectedFrames[0]->frame();
05924 QColor frameCol=frame->backgroundColor().color();
05925
05926 m_actionBackgroundColor->setCurrentColor( frameCol.isValid()? frame->backgroundColor().color() : QApplication::palette().color( QPalette::Active, QColorGroup::Base ));
05927 }
05928
05929 m_actionCreateFrameStyle->setEnabled( selectedFrames.count()==1 );
05930 m_actionCreateLinkedFrame->setEnabled( selectedFrames.count()==1 );
05931
05932 updateTableActions( selectedFrames );
05933 updatePageInfo();
05934 updateFrameStatusBarItem();
05935
05936 QPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
05937 if ( !lst.isEmpty() )
05938 {
05939 QPtrListIterator<KoTextFormatInterface> it( lst );
05940 KoTextFormat format=*(lst.first()->currentFormat());
05941 showFormat( format );
05942
05943 const KoParagLayout * paragLayout=lst.first()->currentParagLayoutFormat();
05944 KoParagCounter counter;
05945 if(paragLayout->counter)
05946 counter = *(paragLayout->counter);
05947 showCounter( counter );
05948 int align = paragLayout->alignment;
05949 if ( align == Qt::AlignAuto )
05950 align = Qt::AlignLeft;
05951 showAlign( align );
05952 KoParagLayout::SpacingType spacing=paragLayout->lineSpacingType;
05953 showSpacing( spacing );
05954 }
05955
05956 m_gui->canvasWidget()->repaintAll(false);
05957 }
05958
05959
05960 void KWView::updateTableActions( QValueList<KWFrameView*> selectedFrames)
05961 {
05962 TableInfo ti(selectedFrames);
05963 KWTableFrameSet *table = m_gui->canvasWidget()->getCurrentTable();
05964 m_actionTableJoinCells->setEnabled( ti.tableCellsSelected());
05965 m_actionConvertTableToText->setEnabled( table && table->isFloating() );
05966
05967 m_actionTableSplitCells->setEnabled( ti.oneCellSelected() );
05968
05969 m_actionTableInsertRow->setEnabled( ti.amountRowsSelected() );
05970 m_actionTableDelRow->setEnabled( ti.amountRowsSelected() );
05971 m_actionTableInsertCol->setEnabled( ti.amountColumnsSelected() );
05972
05973 if(ti.amountColumnsSelected() == 1)
05974 m_actionTableDelCol->setText(i18n("D&elete Current Column..."));
05975 else
05976 m_actionTableDelCol->setText(i18n("D&elete Selected Columns..."));
05977 m_actionTableDelCol->setEnabled( ti.amountColumnsSelected() > 0 );
05978 if(ti.amountRowsSelected() == 1)
05979 m_actionTableDelRow->setText(i18n("&Delete Current Row..."));
05980 else
05981 m_actionTableDelRow->setText(i18n("&Delete Selected Rows..."));
05982 m_actionTableDelRow->setEnabled( ti.amountRowsSelected() > 0 );
05983
05984 m_actionTableResizeCol->setEnabled( ti.tableCellsSelected() );
05985 m_actionTableDelete->setEnabled( ti.tableCellsSelected() );
05986 m_actionTablePropertiesMenu->setEnabled( ti.tableCellsSelected() );
05987
05988 m_actionTableUngroup->setEnabled( ti.tableCellsSelected() );
05989 m_actionTableProtectCells->setEnabled( ti.tableCellsSelected() );
05990 m_actionTableProtectCells->setChecked( ti.protectContentEnabled() );
05991 }
05992
05993 void KWView::docStructChanged(int type)
05994 {
05995 KWDocStruct *m_pDocStruct=m_gui->getDocStruct();
05996 if(m_pDocStruct)
05997 m_pDocStruct->refreshTree(type);
05998 m_doc->recalcVariables( VT_STATISTIC );
05999 }
06000
06001 void KWView::documentModified( bool b )
06002 {
06003 if ( !statusBar() )
06004 return;
06005
06006 if ( b )
06007 m_sbModifiedLabel->setPixmap( KGlobal::iconLoader()->loadIcon( "action-modified", KIcon::Small ) );
06008 else
06009 m_sbModifiedLabel->setText( " " );
06010 }
06011
06012 void KWView::changeOverwriteMode( bool b )
06013 {
06014 if ( !statusBar() )
06015 return;
06016
06017 if ( b )
06018 m_sbOverwriteLabel->setText( ' ' + i18n( "OVER" ) + ' ' );
06019 else
06020 m_sbOverwriteLabel->setText( ' ' + i18n( "INSRT" ) + ' ' );
06021 }
06022
06023 void KWView::setViewFrameBorders(bool b)
06024 {
06025 m_viewFrameBorders = b;
06026
06027 m_doc->setViewFrameBorders( b );
06028 }
06029
06030 bool KWView::doubleClickActivation() const
06031 {
06032 return TRUE;
06033 }
06034
06035 QWidget* KWView::canvas() const
06036 {
06037
06038
06039
06040 return m_gui->canvasWidget();
06041 }
06042
06043 int KWView::canvasXOffset() const
06044 {
06045 return m_gui->canvasWidget()->contentsX();
06046 }
06047
06048 int KWView::canvasYOffset() const
06049 {
06050 return m_gui->canvasWidget()->contentsY();
06051 }
06052
06053 void KWView::canvasAddChild( KoViewChild * child )
06054 {
06055 connect( m_gui->canvasWidget(), SIGNAL( viewTransformationsChanged() ),
06056 child, SLOT( reposition() ) );
06057
06058
06059 }
06060
06061 void KWView::changePicture()
06062 {
06063 KWFrameView *view = frameViewManager()->selectedFrame();
06064 KWFrame *frame = view == 0 ? 0 : view->frame();
06065 if( !frame )
06066 return;
06067 KWPictureFrameSet *frameset = static_cast<KWPictureFrameSet *>(frame->frameSet());
06068 KoPictureKey oldKey ( frameset->picture().getKey() );
06069 QString oldFile ( oldKey.filename() );
06070 KURL url;
06071 url.setPath( oldFile );
06072 if (!QDir(url.directory()).exists())
06073 oldFile = url.fileName();
06074
06075 KoPicture picture ( KWInsertPicDia::selectPictureDia( oldFile, this ) );
06076 if ( !picture.isNull() )
06077 {
06078 KWFrameChangePictureCommand *cmd= new KWFrameChangePictureCommand( i18n("Change Picture"), FrameIndex(frame), oldKey, picture.getKey() ) ;
06079
06080 frameset->insertPicture( picture );
06081 m_doc->frameChanged( frame );
06082 m_doc->refreshDocStructure( FT_PICTURE );
06083 m_doc->addCommand(cmd);
06084 }
06085 else
06086 kdDebug() << "KWView::changePicture cancelled" << endl;
06087 }
06088
06089 void KWView::savePicture()
06090 {
06091 KWFrameView *view = frameViewManager()->selectedFrame();
06092 KWFrame *frame = view == 0 ? 0 : view->frame();
06093 if ( frame )
06094 {
06095 KWPictureFrameSet *frameset = static_cast<KWPictureFrameSet *>(frame->frameSet());
06096 QString oldFile = frameset->picture().getKey().filename();
06097 KURL url;
06098 url.setPath( oldFile );
06099 if ( !QDir(url.directory()).exists() )
06100 oldFile = url.fileName();
06101
06102 KoPicture picture( frameset->picture() );
06103 QString mimetype = picture.getMimeType();
06104 kdDebug() << "Picture has mime type: " << mimetype << endl;
06105 QStringList mimetypes;
06106 mimetypes << mimetype;
06107 KFileDialog fd( oldFile, QString::null, this, 0, TRUE );
06108 fd.setMimeFilter( mimetypes );
06109 fd.setCaption(i18n("Save Picture"));
06110 fd.setOperationMode(KFileDialog::Saving);
06111 if ( fd.exec() == QDialog::Accepted )
06112 {
06113 url = fd.selectedURL();
06114 if ( url.isValid() )
06115 {
06116 if ( url.isLocalFile() )
06117 {
06118 QFile file( url.path() );
06119 if ( file.open( IO_ReadWrite ) )
06120 {
06121 picture.save( &file );
06122 file.close();
06123 }
06124 else
06125 {
06126 KMessageBox::error(this,
06127 i18n("Error during saving. Could not open '%1' for writing").arg ( url.path() ),
06128 i18n("Save Picture"));
06129 }
06130 }
06131 else
06132 {
06133 KTempFile tempFile;
06134 tempFile.setAutoDelete( true );
06135 if ( tempFile.status() == 0 )
06136 {
06137 QFile file( tempFile.name() );
06138 if ( file.open( IO_ReadWrite ) )
06139 {
06140 picture.save( &file );
06141 file.close();
06142 if ( !KIO::NetAccess::upload( tempFile.name(), url, this ) )
06143 {
06144 KMessageBox::sorry( this, i18n(
06145 "Unable to save the file to '%1'. %2.").arg( url.prettyURL() ).arg( KIO::NetAccess::lastErrorString() ),
06146 i18n("Save Failed") );
06147 }
06148 }
06149 else
06150 KMessageBox::error(this,
06151 i18n("Error during saving. Could not open '%1' temporary file for writing").arg ( file.name() ),
06152 i18n("Save Picture"));
06153 }
06154 else
06155 KMessageBox::sorry( this, i18n(
06156 "Error during saving. Could not create temporary file: %1.").arg( strerror( tempFile.status() ) ),
06157 i18n("Save Picture") );
06158 }
06159 }
06160 else
06161 KMessageBox::sorry( this, i18n("URL %1 is invalid.").arg( url.prettyURL() ), i18n("Save Picture") );
06162 }
06163 }
06164 }
06165
06166 void KWView::configureHeaderFooter()
06167 {
06168 KoPageLayout pgLayout;
06169 KoColumns cl;
06170 KoKWHeaderFooter kwhf;
06171 m_doc->getPageLayout( pgLayout, cl, kwhf );
06172
06173 KWPageLayoutStruct oldLayout( pgLayout, cl, kwhf );
06174
06175 KoHeadFoot hf;
06176 int flags = KW_HEADER_AND_FOOTER;
06177 KoUnit::Unit unit = m_doc->unit();
06178 KoUnit::Unit oldUnit = unit;
06179
06180 if ( KoPageLayoutDia::pageLayout( pgLayout, hf, cl, kwhf, flags, unit ) ) {
06181 if( oldLayout._hf != kwhf )
06182 {
06183 KWPageLayoutStruct newLayout( pgLayout, cl, kwhf );
06184
06185 KCommand *cmd = new KWPageLayoutCommand( i18n("Change Layout"), m_doc,
06186 oldLayout, newLayout );
06187 m_doc->addCommand(cmd);
06188
06189 m_doc->setPageLayout( pgLayout, cl, kwhf );
06190 }
06191 if ( unit != oldUnit )
06192 m_doc->setUnit( unit );
06193 }
06194
06195 }
06196
06197 void KWView::inlineFrame()
06198 {
06199 KWFrameView *view = frameViewManager()->selectedFrame();
06200 KWFrame *frame = view == 0 ? 0 : view->frame();
06201 if( !frame)
06202 return;
06203 KWFrameSet * fs = frame->frameSet();
06204 KWFrameSet * parentFs = fs->groupmanager() ? fs->groupmanager() : fs;
06205
06206 if(m_actionInlineFrame->isChecked())
06207 {
06208
06209 KMacroCommand* macroCmd = new KMacroCommand( i18n("Make Frameset Inline") );
06210 QValueList<FrameIndex> frameindexList;
06211 QValueList<FrameMoveStruct> frameindexMove;
06212
06213 KoPoint initialPos = frame->topLeft();
06214
06215 KWFrameSetInlineCommand *cmd = new KWFrameSetInlineCommand( i18n("Make Frameset Inline"), parentFs, true );
06216 cmd->execute();
06217
06218 frameindexList.append( FrameIndex( frame ) );
06219 frameindexMove.append( FrameMoveStruct( initialPos, frame->topLeft() ) );
06220
06221 KWFrameMoveCommand *cmdMoveFrame = new KWFrameMoveCommand( i18n("Move Frame"), frameindexList, frameindexMove );
06222
06223 macroCmd->addCommand(cmdMoveFrame);
06224 macroCmd->addCommand(cmd);
06225 m_doc->addCommand(macroCmd);
06226 }
06227 else
06228 {
06229 KWFrameSetInlineCommand *cmd = new KWFrameSetInlineCommand( i18n("Make Frameset Non-Inline"), parentFs, false );
06230 m_doc->addCommand(cmd);
06231 cmd->execute();
06232 }
06233 }
06234
06235 void KWView::openLink()
06236 {
06237 KWTextFrameSetEdit * edit = currentTextEdit();
06238 if ( edit )
06239 edit->openLink();
06240 }
06241
06242 void KWView::changeLink()
06243 {
06244 KWTextFrameSetEdit * edit = currentTextEdit();
06245 if ( edit )
06246 {
06247 KoLinkVariable * var=edit->linkVariable();
06248 if(var)
06249 {
06250 QString oldhref= var->url();
06251 QString oldLinkName=var->value();
06252 QString link=oldLinkName;
06253 QString ref=oldhref;
06254 if(KoInsertLinkDia::createLinkDia(link, ref, m_doc->listOfBookmarkName(0), true, this))
06255 {
06256 if(!link.isEmpty() && !ref.isEmpty())
06257 {
06258 if( ref != oldhref || link!=oldLinkName)
06259 {
06260 KWChangeLinkVariable*cmd=new KWChangeLinkVariable( i18n("Change Link"), m_doc,oldhref, ref, oldLinkName,link, var);
06261 cmd->execute();
06262 m_doc->addCommand(cmd);
06263 }
06264 }
06265 }
06266 }
06267 }
06268 }
06269
06270 void KWView::copyLink()
06271 {
06272 KWTextFrameSetEdit * edit = currentTextEdit();
06273 if ( edit )
06274 edit->copyLink();
06275 }
06276
06277 void KWView::removeLink()
06278 {
06279 KWTextFrameSetEdit * edit = currentTextEdit();
06280 if ( edit )
06281 edit->removeLink();
06282 }
06283
06284 void KWView::addToBookmark()
06285 {
06286 KWTextFrameSetEdit * edit = currentTextEdit();
06287 if ( edit )
06288 {
06289 KoLinkVariable * var=edit->linkVariable();
06290 if(var)
06291 {
06292 edit->addBookmarks(var->url());
06293 }
06294 }
06295 }
06296
06297 void KWView::showDocStructure()
06298 {
06299 m_doc->setShowDocStruct(m_actionShowDocStruct->isChecked());
06300 m_doc->reorganizeGUI();
06301 QTimer::singleShot( 0, this, SLOT( updateZoom() ) );
06302 }
06303
06304 void KWView::showRuler()
06305 {
06306 m_doc->setShowRuler( m_actionShowRuler->isChecked());
06307 m_doc->reorganizeGUI();
06308 QTimer::singleShot( 0, this, SLOT( updateZoom() ) );
06309 }
06310
06311 void KWView::viewGrid()
06312 {
06313 m_doc->setShowGrid( m_actionViewShowGrid->isChecked() );
06314 m_doc->setModified( true );
06315 m_doc->updateGridButton();
06316 m_doc->repaintAllViews(false);
06317 }
06318
06319 void KWView::viewSnapToGrid()
06320 {
06321 m_doc->setSnapToGrid( m_actionViewSnapToGrid->isChecked() );
06322 m_doc->setModified( true );
06323 m_doc->updateGridButton();
06324 }
06325
06326 void KWView::slotSoftHyphen()
06327 {
06328 KWTextFrameSetEdit * edit = currentTextEdit();
06329 if ( edit )
06330 edit->insertSoftHyphen();
06331 }
06332
06333 void KWView::slotNonbreakingSpace()
06334 {
06335 KWTextFrameSetEdit * edit = currentTextEdit();
06336 if ( edit )
06337 edit->insertNonbreakingSpace();
06338 }
06339
06340 void KWView::slotNonbreakingHyphen()
06341 {
06342 KWTextFrameSetEdit * edit = currentTextEdit();
06343 if ( edit )
06344 edit->insertNonbreakingHyphen();
06345 }
06346
06347 void KWView::slotLineBreak()
06348 {
06349 KWTextFrameSetEdit * edit = currentTextEdit();
06350 if ( edit )
06351 edit->insertLineBreak();
06352 }
06353
06354 void KWView::slotIncreaseNumberingLevel()
06355 {
06356 KWTextFrameSetEdit * edit = currentTextEdit();
06357 if ( edit )
06358 edit->increaseNumberingLevel( m_doc->styleCollection() );
06359 }
06360
06361 void KWView::slotDecreaseNumberingLevel()
06362 {
06363 KWTextFrameSetEdit * edit = currentTextEdit();
06364 if ( edit )
06365 edit->decreaseNumberingLevel( m_doc->styleCollection() );
06366 }
06367
06368 void KWView::refreshAllVariable()
06369 {
06370 m_doc->recalcVariables( VT_ALL );
06371 }
06372
06373 void KWView::slotAllowAutoFormat()
06374 {
06375 bool state = m_actionAllowAutoFormat->isChecked();
06376 m_doc->setAllowAutoFormat( state );
06377 }
06378
06379 void KWView::slotCompletion()
06380 {
06381 KWTextFrameSetEdit * edit = currentTextEdit();
06382 if ( edit )
06383 edit->completion();
06384 }
06385
06386 void KWView::updateHeaderFooterButton()
06387 {
06388 m_actionViewHeader->setChecked(m_doc->isHeaderVisible());
06389 m_actionViewFooter->setChecked(m_doc->isFooterVisible());
06390 }
06391
06392 void KWView::editComment()
06393 {
06394 KWTextFrameSetEdit * edit = currentTextEdit();
06395 if ( edit )
06396 {
06397 KoVariable * tmpVar=edit->variable();
06398 KoNoteVariable * var = dynamic_cast<KoNoteVariable *>(tmpVar);
06399 if(var)
06400 {
06401 QString authorName;
06402 KoDocumentInfo * info = m_doc->documentInfo();
06403 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
06404 if ( !authorPage )
06405 kdWarning() << "Author information not found in documentInfo !" << endl;
06406 else
06407 authorName = authorPage->fullName();
06408 QString oldValue = var->note();
06409 QString createDate = var->createdNote();
06410 KoCommentDia *commentDia = new KoCommentDia( this, oldValue, authorName, createDate);
06411 if( commentDia->exec() )
06412 {
06413 if ( oldValue != commentDia->commentText())
06414 {
06415 KWChangeVariableNoteText *cmd = new KWChangeVariableNoteText( i18n("Change Note Text"), m_doc, oldValue,commentDia->commentText(), var);
06416 m_doc->addCommand( cmd );
06417 cmd->execute();
06418 }
06419 }
06420 delete commentDia;
06421 }
06422 }
06423 }
06424
06425 void KWView::fileStatistics()
06426 {
06427 KWStatisticsDialog *statisticsDialog = new KWStatisticsDialog( this, m_doc );
06428 if ( !statisticsDialog->wasCanceled() )
06429 statisticsDialog->exec();
06430 delete statisticsDialog;
06431 }
06432
06433 void KWView::removeComment()
06434 {
06435 KWTextFrameSetEdit * edit = currentTextEdit();
06436 if ( edit )
06437 {
06438 edit->removeComment();
06439 }
06440 }
06441
06442 void KWView::copyTextOfComment()
06443 {
06444 KWTextFrameSetEdit * edit = currentTextEdit();
06445 if ( edit )
06446 {
06447 edit->copyTextOfComment();
06448 }
06449 }
06450
06451 void KWView::configureCompletion()
06452 {
06453 m_doc->autoFormat()->readConfig();
06454 KoCompletionDia dia( this, 0, m_doc->autoFormat() );
06455 dia.exec();
06456 }
06457
06458 void KWView::applyAutoFormat()
06459 {
06460 m_doc->autoFormat()->readConfig();
06461 KMacroCommand *macro = 0L;
06462 QValueList<KoTextObject *> list(m_doc->visibleTextObjects(viewMode()));
06463 QValueList<KoTextObject *>::Iterator fit = list.begin();
06464 for ( ; fit != list.end() ; ++fit )
06465 {
06466 KCommand *cmd = m_doc->autoFormat()->applyAutoFormat( *fit );
06467 if ( cmd )
06468 {
06469 if ( !macro )
06470 macro = new KMacroCommand( i18n("Apply Autoformat"));
06471 macro->addCommand( cmd );
06472 }
06473 }
06474 if ( macro )
06475 m_doc->addCommand( macro );
06476 }
06477
06478 void KWView::createStyleFromSelection()
06479 {
06480 KWTextFrameSetEdit * edit = currentTextEdit();
06481 if ( edit )
06482 {
06483 KoStyleCollection* coll = m_doc->styleCollection();
06484 KoCreateStyleDia *dia = new KoCreateStyleDia( QStringList(), this, 0 );
06485 if ( dia->exec() )
06486 {
06487 QString name = dia->nameOfNewStyle();
06488 KoParagStyle* style = coll->findStyleByDisplayName( name );
06489 if ( style )
06490 {
06491
06492 edit->updateStyleFromSelection( style );
06493 }
06494 else
06495 {
06496 style = edit->createStyleFromSelection( name );
06497 m_doc->styleCollection()->addStyle( style );
06498 m_doc->updateAllStyleLists();
06499 }
06500 showStyle( name );
06501 }
06502 delete dia;
06503 }
06504 }
06505
06506
06507 void KWView::switchModeView()
06508 {
06509 KWCanvas* canvas = m_gui->canvasWidget();
06510 slotUpdateRuler();
06511
06512
06513 QString mode = canvas->viewMode()->type();
06514 bool isTextMode = mode == "ModeText";
06515 bool state = !isTextMode;
06516 m_actionToolsCreateText->setEnabled(state);
06517 m_actionToolsCreatePix->setEnabled(state);
06518 m_actionToolsCreatePart->setEnabled(state);
06519 m_actionInsertFormula->setEnabled(state);
06520 m_actionInsertTable->setEnabled(state);
06521 changeFootEndNoteState();
06522 m_actionViewFooter->setEnabled( state && m_doc->processingType() == KWDocument::WP );
06523 m_actionViewHeader->setEnabled( state && m_doc->processingType() == KWDocument::WP );
06524
06525 m_actionShowDocStruct->setEnabled(state);
06526 m_actionFormatPage->setEnabled(state);
06527 m_actionInsertContents->setEnabled( state );
06528 m_actionFrameStyle->setEnabled( state );
06529 m_actionTableStyle->setEnabled ( state );
06530 m_actionViewShowGrid->setEnabled( state );
06531 m_actionViewSnapToGrid->setEnabled( mode == "ModeNormal" || mode == "ModeEmbedded" );
06532 if ( m_gui->getHorzRuler())
06533 {
06534 m_gui->getHorzRuler()->setPageLayoutMenuItemEnabled( state );
06535 if ( !koDocument()->isReadWrite())
06536 m_gui->getHorzRuler()->changeFlags( KoRuler::F_NORESIZE );
06537 else
06538 {
06539 if ( state )
06540 m_gui->getHorzRuler()->changeFlags( m_gui->getHorzRuler()->flags() & ~(KoRuler::F_NORESIZE) );
06541 else
06542 m_gui->getHorzRuler()->changeFlags( m_gui->getHorzRuler()->flags() | KoRuler::F_NORESIZE );
06543 }
06544 }
06545 if ( m_gui->getVertRuler() )
06546 {
06547 m_gui->getVertRuler()->setPageLayoutMenuItemEnabled( state );
06548 if ( !koDocument()->isReadWrite())
06549 m_gui->getVertRuler()->changeFlags( KoRuler::F_NORESIZE );
06550 else
06551 {
06552 if ( state )
06553 m_gui->getVertRuler()->changeFlags( m_gui->getVertRuler()->flags() & ~(KoRuler::F_NORESIZE) );
06554 else
06555 m_gui->getVertRuler()->changeFlags( m_gui->getVertRuler()->flags() | KoRuler::F_NORESIZE );
06556
06557 }
06558 }
06559
06560 if ( isTextMode )
06561 {
06562 if ( m_doc->showdocStruct() )
06563 {
06564 m_doc->setShowDocStruct(false);
06565 m_doc->reorganizeGUI();
06566 }
06567 }
06568 else
06569 {
06570 m_doc->setShowDocStruct(m_actionShowDocStruct->isChecked());
06571 m_doc->reorganizeGUI();
06572 }
06573
06574
06575
06576 m_doc->recalcVariables( VT_PGNUM );
06577 if ( isTextMode )
06578 {
06579
06580 canvas->editFrameSet( static_cast<KWViewModeText* >(canvas->viewMode())->textFrameSet() );
06581
06582 }
06583
06584 updateZoomControls();
06585
06586 updatePageInfo();
06587
06588 canvas->viewMode()->setPageLayout( m_gui->getHorzRuler(), m_gui->getVertRuler(), m_doc->pageLayout() );
06589 }
06590
06591 void KWView::configureFootEndNote()
06592 {
06593 KWConfigFootNoteDia *dia = new KWConfigFootNoteDia( this, "configfootnote", m_doc );
06594 dia->exec();
06595 delete dia;
06596 }
06597
06598 void KWView::editFootEndNote()
06599 {
06600 KWTextFrameSetEdit * edit = currentTextEdit();
06601 if ( edit )
06602 {
06603 KWFootNoteVariable * var = dynamic_cast<KWFootNoteVariable *>( edit->variable() );
06604 if ( var && var->frameSet() )
06605 {
06606 m_gui->canvasWidget()->editFrameSet( var->frameSet() );
06607 KWTextFrameSetEdit* textedit = currentTextEdit();
06608 if ( textedit )
06609 textedit->ensureCursorVisible();
06610 }
06611 }
06612 }
06613
06614 void KWView::changeFootNoteType()
06615 {
06616 KWTextFrameSetEdit * edit = currentTextEdit();
06617 if ( edit )
06618 {
06619 KoVariable * tmpVar=edit->variable();
06620 KWFootNoteVariable * var = dynamic_cast<KWFootNoteVariable *>(tmpVar);
06621 if(var && var->frameSet())
06622 {
06623 KWFootNoteDia dia( var->noteType(), var->numberingType(), (var->numberingType()==KWFootNoteVariable::Auto) ? QString::null : var->manualString(), this, m_doc, 0 );
06624 QPtrListIterator<KoTextCustomItem> it( edit->textDocument()->allCustomItems() );
06625 for ( ; it.current() ; ++it )
06626 {
06627 KWFootNoteVariable *fnv = dynamic_cast<KWFootNoteVariable *>( it.current() );
06628 if (fnv && !fnv->isDeleted() && fnv->frameSet() && !fnv->frameSet()->isDeleted() &&
06629 fnv->numberingType()==KWFootNoteVariable::Manual && fnv != var)
06630 dia.appendManualFootNote( fnv->text() );
06631 }
06632 if ( dia.exec() )
06633 {
06634 FootNoteParameter oldParam( var );
06635 FootNoteParameter newParam(dia.noteType(), dia.numberingType(), dia.manualString() );
06636 KWChangeFootNoteParametersCommand * cmd = new KWChangeFootNoteParametersCommand( i18n("Change Footnote Parameters"), var , oldParam, newParam, m_doc);
06637 cmd->execute();
06638 m_doc->addCommand ( cmd );
06639 }
06640 }
06641 }
06642 }
06643
06644
06645 void KWView::autoSpellCheck()
06646 {
06647 autoSpellCheck( m_actionAllowBgSpellCheck->isChecked() );
06648 }
06649
06650 void KWView::autoSpellCheck(bool b)
06651 {
06652 m_doc->changeBgSpellCheckingState( b );
06653 }
06654
06655 void KWView::goToFootEndNote()
06656 {
06657 KWFrameView *view = frameViewManager()->selectedFrame();
06658 KWFrame *frame = view == 0 ? 0 : view->frame();
06659 if( !frame)
06660 return;
06661 KWFootNoteFrameSet *footNoteFrameSet = dynamic_cast<KWFootNoteFrameSet *>(frame->frameSet());
06662 if ( footNoteFrameSet )
06663 {
06664 KWFootNoteVariable* var=footNoteFrameSet->footNoteVariable();
06665 KoTextParag *parag = var->paragraph();
06666 int index = var->index();
06667 KWTextDocument *textDoc = static_cast<KWTextDocument *>(var->textDocument());
06668 KWTextFrameSet *frameSet =textDoc->textFrameSet();
06669 m_gui->canvasWidget()->editTextFrameSet( frameSet, parag, index );
06670 }
06671 }
06672
06673 void KWView::openDocStructurePopupMenu( const QPoint &p, KWFrameSet *frameset, KWTextParag *parag)
06674 {
06675 bool rw = koDocument()->isReadWrite();
06676 bool kttsdInstalled = KoSpeaker::isKttsdInstalled();
06677 if (!rw && !kttsdInstalled)
06678 return;
06679 bool hasText = (frameset->type()==FT_TEXT || frameset->type()==FT_TABLE || frameset->type()==FT_FORMULA );
06680
06681 m_actionDocStructEdit->setEnabled( rw && hasText );
06682 m_actionDocStructDelete->setEnabled( (rw && !parag && !frameset->isMainFrameset() &&
06683 !frameset->isFootEndNote() && !frameset->isHeaderOrFooter()) );
06684 m_actionDocStructSpeak->setEnabled( hasText && kttsdInstalled );
06685
06686 QPopupMenu* popup = static_cast<QPopupMenu *>(factory()->container("docstruct_popup",this));
06687 if ( popup )
06688 popup->exec(p);
06689 }
06690
06691 void KWView::docStructSelect()
06692 {
06693 if ( m_gui->getDocStruct() )
06694 {
06695 m_gui->getDocStruct()->selectItem();
06696 }
06697 }
06698
06699 void KWView::docStructEdit()
06700 {
06701 if ( m_gui->getDocStruct() )
06702 {
06703 m_gui->getDocStruct()->editItem();
06704
06705 m_gui->canvasWidget()->setFocus();
06706 }
06707 }
06708
06709 void KWView::docStructProperties()
06710 {
06711 if ( m_gui->getDocStruct() )
06712 {
06713 m_gui->getDocStruct()->editProperties();
06714 }
06715 }
06716
06717 void KWView::docStructDelete()
06718 {
06719 if ( m_gui->getDocStruct() )
06720 {
06721 m_gui->getDocStruct()->deleteItem();
06722 }
06723 }
06724
06725 void KWView::docStructSpeak()
06726 {
06727 if ( m_gui->getDocStruct() )
06728 {
06729 m_gui->getDocStruct()->speakItem();
06730 }
06731 }
06732
06733 void KWView::insertFile()
06734 {
06735 KFileDialog fd( QString::null, QString::null, this, 0, TRUE );
06736 fd.setMimeFilter( "application/x-kword" );
06737 fd.setCaption(i18n("Insert File"));
06738 KURL url;
06739 if ( fd.exec() != QDialog::Accepted )
06740 return;
06741 url = fd.selectedURL();
06742 if( url.isEmpty() )
06743 {
06744 KMessageBox::sorry( this,
06745 i18n("File name is empty."),
06746 i18n("Insert File"));
06747 return;
06748 }
06749 insertFile( url );
06750 }
06751
06752 void KWView::insertFile(const KURL& url)
06753 {
06754 KMacroCommand* macroCmd = 0L;
06755 bool hasFixedFramesets = false;
06756 KoStore* store=KoStore::createStore( this, url, KoStore::Read );
06757
06758
06759
06760
06761
06762 QString maindoc = "maindoc.xml";
06763 if ( store )
06764 {
06765
06766
06767 bool b = store->open(maindoc);
06768 if ( !b )
06769 {
06770 KMessageBox::sorry( this,
06771 i18n("This file is not a KWord file!"),
06772 i18n("Insert File"));
06773 delete store;
06774 return;
06775 }
06776
06777 QDomDocument doc;
06778 doc.setContent( store->device() );
06779 QDomElement word = doc.documentElement();
06780
06781 m_doc->loadPictureMap( word );
06782 store->close();
06783 m_doc->loadImagesFromStore( store );
06784 }
06785 if ( store )
06786 {
06787 bool b = store->open(maindoc);
06788 if ( !b )
06789 {
06790 KMessageBox::sorry( this,
06791 i18n("File name is not a KWord file!"),
06792 i18n("Insert File"));
06793 delete store;
06794 return;
06795 }
06796 QDomDocument doc;
06797 doc.setContent( store->device() );
06798 QDomElement word = doc.documentElement();
06799
06800 QDomElement framesets = word.namedItem( "FRAMESETS" ).toElement();
06801 if ( !framesets.isNull() )
06802 {
06803 QDomElement framesetElem = framesets.firstChild().toElement();
06804
06805 while ( !framesetElem.isNull() && framesetElem.tagName() != "FRAMESET" )
06806 framesetElem = framesetElem.nextSibling().toElement();
06807
06808 if ( !framesetElem.isNull() )
06809 {
06810 KWTextFrameSet *textFrameSet = dynamic_cast<KWTextFrameSet *>( m_doc->frameSet(0) );
06811 KoTextCursor insertionCursor( textFrameSet->textDocument() );
06812 KWTextFrameSetEdit* edit = currentTextEdit();
06813 if ( edit && !edit->textFrameSet()->protectContent()) {
06814 textFrameSet = edit->textFrameSet();
06815 insertionCursor = *edit->cursor();
06816 }
06817
06818 QDomDocument domDoc( "PARAGRAPHS" );
06819 QDomElement paragsElem = domDoc.createElement( "PARAGRAPHS" );
06820 domDoc.appendChild( paragsElem );
06821
06822
06823
06824 QValueList<QDomElement> paragList;
06825 QValueList<QString> inlineFsNames;
06826 QDomElement fsElem;
06827
06828 QDomNode n = framesetElem.firstChild().toElement();
06829 while( !n.isNull() )
06830 {
06831 QDomElement e = n.toElement();
06832 if ( !e.isNull() && e.tagName() == "PARAGRAPH" )
06833 {
06834 paragList.append( e );
06835
06836 QDomElement formatsElem = e.namedItem( "FORMATS" ).toElement();
06837 if ( !formatsElem.isNull() )
06838 {
06839
06840 QDomElement formatElem = formatsElem.firstChild().toElement();
06841 for ( ; !formatElem.isNull() ; formatElem = formatElem.nextSibling().toElement() )
06842 {
06843 QDomElement anchorElem = formatElem.namedItem( "ANCHOR" ).toElement();
06844 if ( !anchorElem.isNull() )
06845 {
06846 QString type = anchorElem.attribute( "type" );
06847 if ( type == "grpMgr" || type == "frameset" )
06848 {
06849 QString iName = anchorElem.attribute( "instance" );
06850 inlineFsNames.append( iName );
06851
06852 QString tableName;
06853 QDomElement table;
06854 fsElem = framesetElem.nextSibling().toElement();
06855 for ( ; !fsElem.isNull() ; fsElem = fsElem.nextSibling().toElement() )
06856 {
06857 if ( fsElem.tagName() == "FRAMESET" )
06858 {
06859 QString name = fsElem.attribute( "name" );
06860 QString grpMgr = fsElem.attribute( "grpMgr" );
06861 if ( name == iName )
06862 {
06863 paragList.append( fsElem );
06864
06865 }
06866 else if ( grpMgr == iName )
06867 {
06868 if ( grpMgr != tableName )
06869 {
06870 tableName = grpMgr;
06871 table = domDoc.createElement("FRAMESET");
06872 table.setAttribute("frameType", FT_TABLE);
06873 table.setAttribute("frameInfo", 0);
06874 table.setAttribute("protectSize", fsElem.attribute("protectSize","0"));
06875 table.setAttribute("name", tableName);
06876 table.setAttribute("visible", fsElem.attribute("visible","1"));
06877 paragList.append( table );
06878
06879 }
06880
06881 table.appendChild( fsElem.cloneNode() );
06882
06883 }
06884
06885 }
06886
06887 }
06888
06889 }
06890 }
06891 }
06892 }
06893 }
06894 n = n.nextSibling();
06895 }
06896
06897 QValueList<QDomElement>::Iterator it = paragList.begin();
06898 QValueList<QDomElement>::Iterator end = paragList.end();
06899 for ( ; it!= end ; ++it )
06900 {
06901
06902 paragsElem.appendChild( *it );
06903 }
06904
06905
06906
06907
06908 QDomDocument domDocFrames( "SELECTION" );
06909 QDomElement topElem = domDocFrames.createElement( "SELECTION" );
06910 domDocFrames.appendChild( topElem );
06911 QString tableName;
06912 QDomElement table;
06913 QValueList<QString> fsInHeader;
06914 QValueList<QDomElement> framesetsList;
06915
06916 framesetElem = framesetElem.nextSibling().toElement();
06917 for ( ; !framesetElem.isNull() ; framesetElem = framesetElem.nextSibling().toElement() )
06918 {
06919 if ( framesetElem.tagName() == "FRAMESET" )
06920 {
06921 FrameSetType frameSetType = static_cast<FrameSetType>( KWDocument::getAttribute( framesetElem, "frameType", FT_BASE ) );
06922 KWFrameSet::Info info = static_cast<KWFrameSet::Info>( framesetElem.attribute("frameInfo").toInt() );
06923 if ( frameSetType == FT_TEXT &&
06924 (info == KWFrameSet::FI_FIRST_HEADER ||
06925 info == KWFrameSet::FI_EVEN_HEADER ||
06926 info == KWFrameSet::FI_ODD_HEADER ||
06927 info == KWFrameSet::FI_FIRST_FOOTER ||
06928 info == KWFrameSet::FI_EVEN_FOOTER ||
06929 info == KWFrameSet::FI_ODD_FOOTER)
06930 )
06931 fsInHeader += getInlineFramesets( framesetElem );
06932
06933 QString name = framesetElem.attribute( "name" );
06934 QString grpMgr = framesetElem.attribute( "grpMgr" );
06935 if ( !inlineFsNames.contains(name) && !inlineFsNames.contains(grpMgr) )
06936 {
06937 if ( !grpMgr.isEmpty() )
06938 {
06939 if ( grpMgr != tableName )
06940 {
06941 tableName = grpMgr;
06942 table = domDocFrames.createElement("FRAMESET");
06943 table.setAttribute("frameType", FT_TABLE);
06944 table.setAttribute("frameInfo", 0);
06945 table.setAttribute("protectSize", framesetElem.attribute("protectSize","0"));
06946 table.setAttribute("name", tableName);
06947 table.setAttribute("visible", framesetElem.attribute("visible","1"));
06948 framesetsList.append( table );
06949
06950 }
06951 table.appendChild( framesetElem.cloneNode() );
06952
06953 }
06954 else
06955 {
06956 framesetsList.append( framesetElem );
06957
06958 }
06959 }
06960
06961 }
06962
06963 }
06964 it = framesetsList.begin();
06965 end = framesetsList.end();
06966 for ( ; it != end ; ++it )
06967 {
06968 framesetElem = (*it);
06969 FrameSetType frameSetType = static_cast<FrameSetType>( KWDocument::getAttribute( framesetElem, "frameType", FT_BASE ) );
06970 KWFrameSet::Info info = static_cast<KWFrameSet::Info>( framesetElem.attribute("frameInfo").toInt() );
06971 QString name = framesetElem.attribute("name");
06972 QString grpMgr = framesetElem.attribute( "grpMgr" );
06973
06974 if ( !fsInHeader.contains(name) && !fsInHeader.contains(grpMgr) &&
06975 !( frameSetType == FT_TEXT &&
06976 (info == KWFrameSet::FI_FIRST_HEADER ||
06977 info == KWFrameSet::FI_EVEN_HEADER ||
06978 info == KWFrameSet::FI_ODD_HEADER ||
06979 info == KWFrameSet::FI_FIRST_FOOTER ||
06980 info == KWFrameSet::FI_EVEN_FOOTER ||
06981 info == KWFrameSet::FI_ODD_FOOTER) )
06982 )
06983 {
06984 hasFixedFramesets = true;
06985 topElem.appendChild( framesetElem );
06986 }
06987 }
06988
06989 QDomDocument embeddedDoc( "SELECTION" );
06990 QDomElement selElem = embeddedDoc.createElement( "SELECTION" );
06991 embeddedDoc.appendChild( selElem );
06992
06993 QValueList<QDomElement> embeddedList;
06994 QDomElement embeddedElem = word.namedItem( "EMBEDDED" ).toElement();
06995 for ( ; !embeddedElem.isNull() ; embeddedElem = embeddedElem.nextSibling().toElement() )
06996 {
06997 if ( embeddedElem.tagName() == "EMBEDDED" )
06998 {
06999 embeddedList.append( embeddedElem );
07000 }
07001 }
07002 it = embeddedList.begin();
07003 end = embeddedList.end();
07004 bool hasEmbedded = false;
07005 for ( ; it!= end ; ++it )
07006 {
07007 selElem.appendChild( *it );
07008 hasEmbedded = true;
07009 }
07010 store->close();
07011
07012
07013
07014 if ( !macroCmd )
07015 macroCmd = new KMacroCommand( i18n("Insert File") );
07016
07017 if ( hasFixedFramesets )
07018 {
07019
07020
07021 m_doc->pasteFrames( topElem, macroCmd, false, false, false );
07022 }
07023 if ( hasEmbedded )
07024 {
07025
07026 if ( !macroCmd )
07027 macroCmd = new KMacroCommand( i18n("Insert File") );
07028 m_doc->insertEmbedded( store, selElem, macroCmd, 0 );
07029 }
07030
07031
07032 KCommand *cmd = textFrameSet->pasteOasis( &insertionCursor, domDoc.toCString(), true );
07033
07034 if ( cmd ) {
07035 macroCmd->addCommand( cmd );
07036 }
07037 m_doc->addCommand( macroCmd );
07038
07039 }
07040 }
07041
07042 m_doc->loadImagesFromStore( store );
07043 m_doc->completePasting();
07044
07045 }
07046 delete store;
07047 }
07048
07049 QValueList<QString> KWView::getInlineFramesets( const QDomNode &framesetElem)
07050 {
07051
07052 QValueList<QString> list;
07053 QDomNode n = framesetElem.firstChild().toElement();
07054 for( ; !n.isNull(); n = n.nextSibling() )
07055 {
07056 QDomElement e = n.toElement();
07057 if ( !e.isNull() && e.tagName() == "PARAGRAPH" )
07058 {
07059 QDomElement formatsElem = e.namedItem( "FORMATS" ).toElement();
07060 if ( !formatsElem.isNull() )
07061 {
07062
07063 QDomElement formatElem = formatsElem.firstChild().toElement();
07064 for ( ; !formatElem.isNull() ; formatElem = formatElem.nextSibling().toElement() )
07065 {
07066 QDomElement anchorElem = formatElem.namedItem( "ANCHOR" ).toElement();
07067 if ( !anchorElem.isNull() )
07068 {
07069 QString type = anchorElem.attribute( "type" );
07070 if ( type == "grpMgr" || type == "frameset" )
07071 {
07072 QString iName = anchorElem.attribute( "instance" );
07073 list.append( iName );
07074
07075 }
07076 }
07077 }
07078 }
07079 }
07080 }
07081 return list;
07082 }
07083
07084 void KWView::addBookmark()
07085 {
07086 KWTextFrameSetEdit * edit = currentTextEdit();
07087 if ( edit )
07088 {
07089
07090 KWCreateBookmarkDia dia( m_doc->listOfBookmarkName(0L), this, 0 );
07091 if ( dia.exec() ) {
07092 QString bookName = dia.bookmarkName();
07093 KoTextCursor start, end;
07094 if ( edit->textDocument()->hasSelection( KoTextDocument::Standard ) ) {
07095 start = edit->textDocument()->selectionStartCursor( KoTextDocument::Standard );
07096 end = edit->textDocument()->selectionEndCursor( KoTextDocument::Standard );
07097 } else {
07098 start = *edit->cursor();
07099 end = start;
07100 }
07101 int startSel = start.index();
07102 int endSel = end.index();
07103 m_doc->insertBookmark(bookName, start.parag(),end.parag(), startSel, endSel);
07104 }
07105 }
07106 }
07107
07108 void KWView::selectBookmark()
07109 {
07110 KWSelectBookmarkDia dia( m_doc->listOfBookmarkName(viewMode()), m_doc, this, 0 );
07111 if ( dia.exec() ) {
07112 QString bookName = dia.bookmarkSelected();
07113 const KoTextBookmark * book = m_doc->bookmarkByName( bookName );
07114 Q_ASSERT( book );
07115 if ( book )
07116 {
07117 Q_ASSERT( book->startParag() );
07118 Q_ASSERT( book->endParag() );
07119 if ( !book->startParag() || !book->endParag() )
07120 return;
07121 KWTextFrameSet* textfs = static_cast<KWTextDocument *>( book->textDocument() )->textFrameSet();
07122 m_gui->canvasWidget()->editTextFrameSet( textfs, book->startParag(), book->bookmarkStartIndex() );
07123 KWTextFrameSetEdit * edit = currentTextEdit();
07124 Q_ASSERT( edit );
07125 if ( edit )
07126 {
07127 edit->textDocument()->removeSelection( KoTextDocument::Standard );
07128 edit->textDocument()->setSelectionStart( KoTextDocument::Standard, edit->cursor() );
07129 edit->cursor()->setParag( book->endParag());
07130 edit->cursor()->setIndex(book->bookmarkEndIndex() );
07131 edit->textDocument()->setSelectionEnd( KoTextDocument::Standard, edit->cursor() );
07132 book->startParag()->setChanged( true );
07133 book->endParag()->setChanged( true );
07134 m_doc->slotRepaintChanged( edit->frameSet() );
07135 }
07136 }
07137 }
07138 }
07139
07140 void KWView::importStyle()
07141 {
07142 KWImportStyleDia dia( m_doc, m_doc->styleCollection(), this );
07143 if ( dia.exec() && !dia.importedStyles().isEmpty() ) {
07144 m_doc->styleCollection()->importStyles( dia.importedStyles() );
07145 m_doc->setModified( true );
07146 m_doc->updateAllStyleLists();
07147 }
07148 }
07149
07150 void KWView::testAndCloseAllFrameSetProtectedContent()
07151 {
07152 KWTextFrameSetEdit* edit = currentTextEdit();
07153 if ( edit && edit->textFrameSet()->protectContent()) {
07154 m_doc->terminateEditing( edit->frameSet());
07155 }
07156 }
07157
07158 void KWView::updateRulerInProtectContentMode()
07159 {
07160 KWTextFrameSetEdit* edit = currentTextEdit();
07161 KoRuler * hRuler = m_gui ? m_gui->getHorzRuler() : 0;
07162
07163 if ( edit && hRuler) {
07164 if ( !edit->textFrameSet()->protectContent() )
07165 hRuler->changeFlags(KoRuler::F_INDENTS | KoRuler::F_TABS);
07166 else
07167 hRuler->changeFlags(0);
07168 hRuler->repaint();
07169 }
07170 }
07171
07172 void KWView::deselectAllFrames()
07173 {
07174 m_gui->canvasWidget()->selectAllFrames( false );
07175 }
07176
07177 void KWView::insertDirectCursor()
07178 {
07179 #if 0
07180 insertDirectCursor( m_actionInsertDirectCursor->isChecked());
07181 #endif
07182 }
07183
07184 void KWView::insertDirectCursor(bool b)
07185 {
07186 m_doc->setInsertDirectCursor(b);
07187 }
07188
07189 void KWView::updateDirectCursorButton()
07190 {
07191 #if 0
07192 m_actionInsertDirectCursor->setChecked(m_doc->insertDirectCursor());
07193 #endif
07194 }
07195
07196 void KWView::convertTableToText()
07197 {
07198 KWCanvas * canvas = m_gui->canvasWidget();
07199 KWTableFrameSet *table = canvas->getCurrentTable();
07200 if ( table && table->isFloating() )
07201 {
07202 const QByteArray arr = table->convertTableToText();
07203 KWAnchor * anchor = table->findAnchor( 0 );
07204 if ( anchor && arr.size() )
07205 {
07206 KWTextFrameSet *frameset = table->anchorFrameset();
07207 KoTextParag *parag = anchor->paragraph();
07208 int pos = anchor->index();
07209 KMacroCommand *macro = new KMacroCommand(i18n("Convert Table to Text"));
07210 KCommand *cmd = table->anchorFrameset()->deleteAnchoredFrame( anchor );
07211 if ( cmd )
07212 macro->addCommand( cmd);
07213
07214 m_gui->canvasWidget()->editTextFrameSet( frameset, parag, pos );
07215
07216 KWTextFrameSetEdit* edit = currentTextEdit();
07217 if ( edit && edit->textFrameSet())
07218 {
07219 cmd = edit->textFrameSet()->pasteOasis( edit->cursor(), arr, true );
07220 if ( cmd )
07221 macro->addCommand( cmd );
07222 }
07223 m_doc->addCommand(macro);
07224 }
07225 }
07226 }
07227
07228 void KWView::convertToTextBox()
07229 {
07230 KWTextFrameSetEdit* edit = currentTextEdit();
07231 if ( !edit )
07232 return;
07233
07234 KWTextFrameSet* textfs = edit->textFrameSet();
07235 if( textfs->protectContent() || !textfs->textObject()->hasSelection() )
07236 return;
07237
07238 KWOasisSaver oasisSaver( m_doc );
07239 textfs->textDocument()->copySelection( oasisSaver.bodyWriter(), oasisSaver.savingContext(), KoTextDocument::Standard );
07240 if ( !oasisSaver.finish() )
07241 return;
07242 const QByteArray arr = oasisSaver.data();
07243 if ( !arr.size() )
07244 return;
07245
07246 KCommand *cmd = textfs->textObject()->removeSelectedTextCommand( edit->textView()->cursor(), KoTextDocument::Standard );
07247 Q_ASSERT( cmd );
07248 KMacroCommand* macro = new KMacroCommand( i18n("Convert to Text Box"));
07249 macro->addCommand( cmd );
07250
07251 cmd = m_gui->canvasWidget()->createTextBox( KoRect(30,30,300,300) );
07252 Q_ASSERT( cmd );
07253 if ( cmd )
07254 macro->addCommand( cmd );
07255
07256 edit = currentTextEdit();
07257 Q_ASSERT( edit );
07258 if ( edit )
07259 {
07260 cmd = edit->textFrameSet()->pasteOasis( edit->textView()->cursor(), arr, true );
07261 if ( cmd )
07262 macro->addCommand( cmd );
07263
07264 edit->textFrameSet()->layout();
07265 }
07266 m_doc->addCommand( macro );
07267 }
07268
07269 void KWView::slotAddIgnoreAllWord()
07270 {
07271 KWTextFrameSetEdit* edit = currentTextEdit();
07272 if ( edit )
07273 m_doc->addSpellCheckIgnoreWord( edit->currentWordOrSelection() );
07274 }
07275
07276 void KWView::sortText()
07277 {
07278 KWTextFrameSetEdit* edit = currentTextEdit();
07279 if ( edit && edit->textFrameSet()->hasSelection() )
07280 {
07281 KWSortDia dlg( this, "sort dia" );
07282 if ( dlg.exec() )
07283 {
07284 const QByteArray arr = edit->textFrameSet()->sortText(dlg.getSortType());
07285 if ( arr.size() )
07286 {
07287 KCommand *cmd = edit->textFrameSet()->pasteOasis( edit->cursor(), arr, true );
07288 if ( cmd )
07289 m_doc->addCommand(cmd);
07290 }
07291 }
07292 }
07293 }
07294
07295 void KWView::addPersonalExpression()
07296 {
07297 KWTextFrameSetEdit* edit = currentTextEdit();
07298 if ( !(edit && edit->textFrameSet()->hasSelection()))
07299 return;
07300
07301 QString newExpression = edit->textFrameSet()->textObject()->selectedText();
07302
07303 QString tmp=locateLocal("data","kword/expression/perso.xml");
07304 QFile file( tmp );
07305 if ( !file.open( IO_ReadOnly ) )
07306 return;
07307 QDomDocument doc;
07308 doc.setContent( &file );
07309 file.close();
07310
07311 QString group;
07312 QMap<QString, QStringList>lstOfPersonalExp;
07313 QStringList list;
07314 QDomNode n = doc.documentElement().firstChild();
07315 for( ; !n.isNull(); n = n.nextSibling() )
07316 {
07317 if ( n.isElement() )
07318 {
07319 QDomElement e = n.toElement();
07320 if ( e.tagName() == "Type" )
07321 {
07322 list.clear();
07323 group = i18n( e.namedItem( "TypeName" ).toElement().text().utf8() );
07324
07325 QDomNode n2 = e.firstChild();
07326 for( ; !n2.isNull(); n2 = n2.nextSibling() )
07327 {
07328
07329 if ( n2.isElement() )
07330 {
07331 QDomElement e2 = n2.toElement();
07332 if ( e2.tagName() == "Expression" )
07333 {
07334 QString text = i18n( e2.namedItem( "Text" ).toElement().text().utf8() );
07335 list<<text;
07336 }
07337 }
07338 }
07339 lstOfPersonalExp.insert(group,list);
07340 group = "";
07341 }
07342 }
07343 }
07344
07345 doc = QDomDocument( "KWordExpression" );
07346 QDomElement begin = doc.createElement( "KWordExpression" );
07347 doc.appendChild( begin );
07348 QMapIterator<QString, QStringList> itPersonalExp = lstOfPersonalExp.find(i18n("Normal"));
07349 if ( itPersonalExp != lstOfPersonalExp.end())
07350 {
07351 list = itPersonalExp.data();
07352 list<<newExpression;
07353 lstOfPersonalExp.replace( i18n("Normal"), list);
07354 }
07355 else
07356 {
07357 list.clear();
07358 list<<newExpression;
07359 lstOfPersonalExp.insert( i18n("Normal"), list);
07360 }
07361
07362
07363 itPersonalExp = lstOfPersonalExp.begin();
07364 for ( ; itPersonalExp != lstOfPersonalExp.end(); ++itPersonalExp )
07365 {
07366 QDomElement type = doc.createElement( "Type" );
07367 begin.appendChild( type );
07368 QDomElement typeName = doc.createElement( "TypeName" );
07369 type.appendChild( typeName );
07370 typeName.appendChild( doc.createTextNode(itPersonalExp.key() ) );
07371 list=itPersonalExp.data();
07372 for( uint i=0;i<list.count();i++ )
07373 {
07374 QDomElement expr = doc.createElement( "Expression" );
07375 type.appendChild( expr );
07376 QDomElement text = doc.createElement( "Text" );
07377 expr.appendChild( text );
07378 text.appendChild( doc.createTextNode(list[i] ) );
07379 }
07380 }
07381 QCString s = doc.toCString();
07382
07383 if ( !file.open( IO_WriteOnly ) )
07384 {
07385 kdDebug()<<"Error in addPersonalExpression()\n";
07386 return;
07387 }
07388 file.writeBlock(s,s.length());
07389 file.close();
07390 m_doc->refreshMenuExpression();
07391 }
07392
07393 void KWView::addWordToDictionary()
07394 {
07395 KWTextFrameSetEdit* edit = currentTextEdit();
07396 if ( edit )
07397 {
07398 QString word = edit->wordUnderCursor( *edit->cursor() );
07399 if ( !word.isEmpty() )
07400 m_doc->addWordToDictionary( word );
07401 }
07402 }
07403
07404 void KWView::embeddedStoreInternal()
07405 {
07406 kdDebug(31001)<<k_funcinfo<<endl;
07407 KWFrameView *view = frameViewManager()->selectedFrame();
07408 KWFrame *frame = view == 0 ? 0 : view->frame();
07409 if( !frame)
07410 return;
07411 KWPartFrameSet *part = static_cast<KWPartFrameSet *>(frame->frameSet());
07412 part->storeInternal();
07413 }
07414
07415 void KWView::goToDocumentStructure()
07416 {
07417 KWDocStruct* docStruct = getGUI()->getDocStruct();
07418 if (docStruct) docStruct->setFocusHere();
07419 }
07420
07421 void KWView::goToDocument()
07422 {
07423 KWCanvas* canvas = getGUI()->canvasWidget();
07424 if (!canvas) return;
07425 canvas->setFocus();
07426 }
07427
07428 void KWView::deleteFrameSet( KWFrameSet * frameset)
07429 {
07430 if ( frameset && frameset->frame(0))
07431 {
07432 frameViewManager()->view(frameset->frame(0))->setSelected( true );
07433 deleteFrame();
07434 }
07435 }
07436
07437 QPtrList<KAction> KWView::listOfResultOfCheckWord( const QString &word )
07438 {
07439 QPtrList<KAction> listAction;
07440 DefaultDictionary *dict = m_broker->defaultDictionary();
07441 const QStringList lst = dict->suggest( word );
07442 if ( !lst.contains( word ) )
07443 {
07444 QStringList::ConstIterator it = lst.begin();
07445 const QStringList::ConstIterator end = lst.end();
07446 for ( ; it != end ; ++it )
07447 {
07448 if ( !(*it).isEmpty() )
07449 {
07450 KAction * act = new KAction( *it );
07451 connect( act, SIGNAL(activated()), this, SLOT(slotCorrectWord()) );
07452 listAction.append( act );
07453 }
07454 }
07455 }
07456 return listAction;
07457 }
07458
07459 void KWView::slotCorrectWord()
07460 {
07461 KAction * act = (KAction *)(sender());
07462 KWTextFrameSetEdit* edit = currentTextEdit();
07463 if ( edit )
07464 {
07465 edit->selectWordUnderCursor( *(edit->cursor()) );
07466 m_doc->addCommand( edit->textObject()->replaceSelectionCommand( edit->cursor(), act->text(), i18n("Replace Word") ));
07467 }
07468 }
07469
07470 void KWView::slotChildActivated( bool a )
07471 {
07472
07473 KoViewChild* ch = child( (KoView*)sender() );
07474 if ( !ch )
07475 return;
07476 KWDocumentChild* kwchild = static_cast<KWDocumentChild *>( ch->documentChild() );
07477 KWPartFrameSet* fs = kwchild->partFrameSet();
07478
07479 Q_ASSERT( fs );
07480 if ( fs ) {
07481 if ( a )
07482 fs->startEditing();
07483 else
07484 fs->endEditing();
07485 }
07486 KoView::slotChildActivated( a );
07487 }
07488
07489 Broker *KWView::broker() const
07490 {
07491 return m_broker;
07492 }
07493
07494 void KWView::slotUnitChanged( KoUnit::Unit unit )
07495 {
07496 getGUI()->getHorzRuler()->setUnit( unit );
07497 getGUI()->getVertRuler()->setUnit( unit );
07498 if ( m_sbUnitLabel )
07499 m_sbUnitLabel->setText( ' ' + KoUnit::unitDescription( unit ) + ' ' );
07500 }
07501
07502 KWFrameViewManager* KWView::frameViewManager() const {
07503 return getGUI()->canvasWidget()->frameViewManager();
07504 }
07505
07506 void KWView::deleteSelectedFrames() {
07507 int nbCommand=0;
07508
07509 int docItem=0;
07510
07511 KMacroCommand * macroCmd = new KMacroCommand( i18n("Delete Frames") );
07512 KWFrameViewManager *fvMgr = frameViewManager();
07513 while (KWFrameView *frameView = fvMgr->selectedFrame()) {
07514 KWFrame *frame = frameView->frame();
07515 KWFrameSet *fs = frame->frameSet();
07516 if ( fs->isAFooter() || fs->isAHeader() )
07517 continue;
07518 KWTableFrameSet *table=fs->groupmanager();
07519 if ( table ) {
07520 docItem|=m_doc->typeItemDocStructure(table->type());
07521
07522 if ( table->isFloating() ) {
07523 docItem|=m_doc->typeItemDocStructure(fs->type());
07524
07525 KWAnchor * anchor = table->findAnchor( 0 );
07526 KCommand * cmd=table->anchorFrameset()->deleteAnchoredFrame( anchor );
07527 macroCmd->addCommand(cmd);
07528 nbCommand++;
07529 }
07530 else {
07531 KWDeleteTableCommand *cmd = new KWDeleteTableCommand( i18n("Delete Table"), table );
07532 cmd->execute();
07533 macroCmd->addCommand(cmd);
07534 nbCommand++;
07535 }
07536 }
07537 else {
07538 if ( fs->isMainFrameset() )
07539 continue;
07540
07541 docItem|=m_doc->typeItemDocStructure(fs->type());
07542
07543 if ( fs->isFloating() ) {
07544 KWAnchor * anchor = fs->findAnchor( 0 );
07545 KCommand *cmd=fs->anchorFrameset()->deleteAnchoredFrame( anchor );
07546 macroCmd->addCommand(cmd);
07547 nbCommand++;
07548 }
07549 else {
07550 KWDeleteFrameCommand *cmd = new KWDeleteFrameCommand( i18n("Delete Frame"), frame );
07551 cmd->execute();
07552 macroCmd->addCommand(cmd);
07553 nbCommand++;
07554 }
07555 }
07556 }
07557 if( nbCommand ) {
07558 m_doc->addCommand(macroCmd);
07559 m_doc->refreshDocStructure(docItem);
07560 }
07561 else
07562 delete macroCmd;
07563 }
07564
07565
07566
07567
07568
07569 KWViewWidget::KWViewWidget( QWidget *parent, KWView *view )
07570 : QWidget( parent ),
07571 m_view ( view )
07572 {
07573 }
07574
07575 void KWViewWidget::resizeEvent( QResizeEvent *e )
07576 {
07577
07578 if ( ( e->size().width() != e->oldSize().width() )
07579 && ( m_view->kWordDocument()->zoomMode() == KoZoomMode::ZOOM_WIDTH ) )
07580 {
07581 QTimer::singleShot( 0, m_view, SLOT( updateZoom() ) );
07582 }
07583
07584 QWidget::resizeEvent( e );
07585 }
07586
07587
07588
07589
07590
07591 KWGUI::KWGUI( const QString& viewMode, QWidget *parent, KWView *daView )
07592 : QHBox( parent, "" ),
07593 m_view ( daView )
07594 {
07595
07596 KWDocument * doc = m_view->kWordDocument();
07597
07598 m_horRuler = 0;
07599 m_vertRuler = 0;
07600
07601
07602 m_panner = new QSplitter( Qt::Horizontal, this );
07603
07604
07605 m_docStruct = new KWDocStruct( m_panner, doc, this );
07606 m_docStruct->setMinimumWidth( 0 );
07607
07608
07609 m_right = new KWViewWidget( m_panner, m_view );
07610 QGridLayout *gridLayout = new QGridLayout( m_right, 2, 2 );
07611 m_canvas = new KWCanvas( viewMode, m_right, doc, this );
07612 gridLayout->addWidget( m_canvas, 1, 1 );
07613
07614 QValueList<int> l;
07615 l << 10;
07616 l << 90;
07617 m_panner->setSizes( l );
07618
07619 KoPageLayout layout = doc->pageLayout();
07620
07621 m_tabChooser = new KoTabChooser( m_right, KoTabChooser::TAB_ALL );
07622 m_tabChooser->setReadWrite(doc->isReadWrite());
07623 gridLayout->addWidget( m_tabChooser, 0, 0 );
07624
07625 m_horRuler = new KoRuler( m_right, m_canvas->viewport(), Qt::Horizontal, layout,
07626 KoRuler::F_INDENTS | KoRuler::F_TABS,
07627 doc->unit(), m_tabChooser );
07628 m_horRuler->setReadWrite(doc->isReadWrite());
07629 gridLayout->addWidget( m_horRuler, 0, 1 );
07630
07631 m_vertRuler = new KoRuler( m_right, m_canvas->viewport(), Qt::Vertical, layout,
07632 0, doc->unit() );
07633 m_vertRuler->setReadWrite(doc->isReadWrite());
07634 gridLayout->addWidget( m_vertRuler, 1, 0 );
07635
07636 m_horRuler->setZoom( doc->zoomedResolutionX() );
07637 m_vertRuler->setZoom( doc->zoomedResolutionY() );
07638
07639 m_horRuler->setGridSize(doc->gridX());
07640
07641 connect( m_horRuler, SIGNAL( newPageLayout( const KoPageLayout & ) ), m_view, SLOT( newPageLayout( const KoPageLayout & ) ) );
07642 connect( m_horRuler, SIGNAL( newLeftIndent( double ) ), m_view, SLOT( newLeftIndent( double ) ) );
07643 connect( m_horRuler, SIGNAL( newFirstIndent( double ) ), m_view, SLOT( newFirstIndent( double ) ) );
07644 connect( m_horRuler, SIGNAL( newRightIndent( double ) ), m_view, SLOT( newRightIndent( double ) ) );
07645
07646 connect( m_horRuler, SIGNAL( doubleClicked() ), m_view, SLOT( slotHRulerDoubleClicked() ) );
07647 connect( m_horRuler, SIGNAL( doubleClicked(double) ), m_view, SLOT( slotHRulerDoubleClicked(double) ) );
07648 connect( m_horRuler, SIGNAL( unitChanged( KoUnit::Unit ) ), this, SLOT( unitChanged( KoUnit::Unit ) ) );
07649 connect( m_vertRuler, SIGNAL( newPageLayout( const KoPageLayout & ) ), m_view, SLOT( newPageLayout( const KoPageLayout & ) ) );
07650 connect( m_vertRuler, SIGNAL( doubleClicked() ), m_view, SLOT( formatPage() ) );
07651 connect( m_vertRuler, SIGNAL( unitChanged( KoUnit::Unit ) ), this, SLOT( unitChanged( KoUnit::Unit ) ) );
07652
07653 m_horRuler->hide();
07654 m_vertRuler->hide();
07655
07656 m_canvas->show();
07657
07658 reorganize();
07659
07660 connect( m_horRuler, SIGNAL( tabListChanged( const KoTabulatorList & ) ), m_view,
07661 SLOT( tabListChanged( const KoTabulatorList & ) ) );
07662
07663 setKeyCompression( TRUE );
07664 setAcceptDrops( TRUE );
07665 setFocusPolicy( QWidget::NoFocus );
07666 }
07667
07668 void KWGUI::showGUI()
07669 {
07670 reorganize();
07671 }
07672
07673 void KWGUI::resizeEvent( QResizeEvent *e )
07674 {
07675 QWidget::resizeEvent( e );
07676 reorganize();
07677 }
07678
07679 void KWGUI::reorganize()
07680 {
07681 int hSpace = m_vertRuler->minimumSizeHint().width();
07682 int vSpace = m_horRuler->minimumSizeHint().height();
07683 if(m_view->kWordDocument()->showRuler())
07684 {
07685 m_vertRuler->show();
07686 m_horRuler->show();
07687 m_tabChooser->show();
07688 m_tabChooser->setGeometry( 0, 0, hSpace, vSpace );
07689 }
07690 else
07691 {
07692 m_vertRuler->hide();
07693 m_horRuler->hide();
07694 m_tabChooser->hide();
07695 hSpace = 0;
07696 vSpace = 0;
07697 }
07698
07699 if(m_view->kWordDocument()->showdocStruct()) {
07700 if(m_docStruct->isHidden()) {
07701 m_docStruct->show();
07702 if(m_panner->sizes()[0] < 50) {
07703 QValueList<int> l;
07704 l << 100;
07705 l << width()-100;
07706 m_panner->setSizes( l );
07707 }
07708 }
07709 } else
07710 m_docStruct->hide();
07711
07712 if( m_view->statusBar())
07713 {
07714 if(m_view->kWordDocument()->showStatusBar())
07715 m_view->statusBar()->show();
07716 else
07717 m_view->statusBar()->hide();
07718 }
07719
07720 if ( m_view->kWordDocument()->showScrollBar())
07721 {
07722 m_canvas->setVScrollBarMode(QScrollView::Auto);
07723 m_canvas->setHScrollBarMode(QScrollView::Auto);
07724 }
07725 else
07726 {
07727 m_canvas->setVScrollBarMode(QScrollView::AlwaysOff);
07728 m_canvas->setHScrollBarMode(QScrollView::AlwaysOff);
07729 }
07730 }
07731
07732 void KWGUI::unitChanged( KoUnit::Unit u )
07733 {
07734 m_view->kWordDocument()->setUnit( u );
07735 }
07736
07737 QPoint KWView::applyViewTransformations( const QPoint& p ) const
07738 {
07739 return viewMode()->normalToView( m_doc->zoomPoint( KoPoint( p ) ) );
07740 }
07741
07742 QPoint KWView::reverseViewTransformations( const QPoint& p ) const
07743 {
07744 return m_doc->unzoomPoint( viewMode()->viewToNormal( p ) ).toQPoint();
07745 }
07746
07747 int KWView::currentPage() const {
07748 return m_currentPage->pageNumber();
07749 }
07750
07751 void KWView::slotDocumentLoadingCompleted()
07752 {
07753 updateStyleList();
07754 }
07755
07756 #include "KWView.moc"