26#include "KWordViewIface.h"
27#include "KWConfigFootNoteDia.h"
29#include "KWDeleteDia.h"
30#include "KWDocStruct.h"
31#include "KWFootNoteDia.h"
32#include "KWInsertDia.h"
34#include "KoTextBookmark.h"
38#include "KWCreateBookmarkDia.h"
39#include "KWDocument.h"
40#include "KWEditPersonnalExpression.h"
41#include "KWFormulaFrameSet.h"
43#include "KWPictureFrameSet.h"
44#include "KWFrameStyle.h"
45#include "KWFrameStyleManager.h"
46#include "KWImportStyleDia.h"
47#include "KWInsertPageDia.h"
48#include "KWInsertPicDia.h"
49#include "KWPartFrameSet.h"
50#include "KWStyleManager.h"
51#include "KWTableFrameSet.h"
52#include "KWTableStyle.h"
53#include "KWTableStyleManager.h"
54#include "KWTextDocument.h"
55#include "KWVariable.h"
56#include "KWViewMode.h"
57#include "KWMailMergeDataBase.h"
58#include "KWMailMergeLabelAction.h"
59#include "KWResizeTableDia.h"
60#include "KWFindReplace.h"
62#include "KWSplitCellDia.h"
63#include "KWTableDia.h"
64#include "KWCollectFramesetsVisitor.h"
65#include "KWOasisLoader.h"
66#include "KWOasisSaver.h"
67#include "KWFrameList.h"
68#include "KWPageManager.h"
70#include "KWFrameViewManager.h"
71#include "KWFrameView.h"
72#include "KWStatisticsDialog.h"
74#include <kformuladocument.h>
75#include <kformulamimesource.h>
77#include <KoRichText.h>
78#include <KoAutoFormat.h>
79#include <KoAutoFormatDia.h>
80#include <KoChangeCaseDia.h>
81#include <KoCharSelectDia.h>
82#include <KoCommentDia.h>
83#include <KoCreateStyleDia.h>
84#include <KoDocumentInfo.h>
87#include <KoInsertLink.h>
88#include <KoMainWindow.h>
89#include <KoParagDia.h>
90#include <KoPartSelectAction.h>
91#include <KoPictureFilePreview.h>
92#include <KoSearchDia.h>
94#include <KoStoreDrag.h>
95#include <KoTemplateCreateDia.h>
96#include <KoCompletionDia.h>
97#include <KoVariable.h>
98#include <KoCustomVariablesDia.h>
99#include <KoTextObject.h>
100#include <tkcoloractions.h>
101#include <KoSpeaker.h>
103#include <tdeparts/partmanager.h>
104#include <tdeaccelgen.h>
105#include <kcolordialog.h>
107#include <tdefiledialog.h>
109#include <kinputdialog.h>
110#include <tdeio/netaccess.h>
111#include <tdemessagebox.h>
112#include <tdeparts/event.h>
113#include <kstandarddirs.h>
114#include <kstatusbar.h>
115#include <tdestdaccel.h>
116#include <kstdaction.h>
117#include <tdetempfile.h>
119#include <kiconloader.h>
121#include <tqclipboard.h>
122#include <tqapplication.h>
123#include <tqgroupbox.h>
125#include <tqpaintdevicemetrics.h>
126#include <tqprogressdialog.h>
133#include <tdespell2/dialog.h>
134#include <tdespell2/defaultdictionary.h>
137using namespace KSpell2;
144 TableInfo(
const TQValueList<KWFrameView*>& selectedFrames ) {
145 m_protectContent =
false;
147 int amountSelected = 0;
149 TQMap<KWTableFrameSet*, TQValueList<unsigned int> > tableRows, tableCols;
151 TQValueList<KWFrameView*>::const_iterator framesIterator = selectedFrames.begin();
152 for(;framesIterator != selectedFrames.end(); ++framesIterator) {
153 KWFrameView *view = *framesIterator;
157 KWTableFrameSet::Cell *cell =
dynamic_cast<KWTableFrameSet::Cell*
>(fs);
158 if(cell == 0)
continue;
160 if(cell->protectContent())
161 m_protectContent=
true;
164 TQValueList<unsigned int> rows;
168 TQValueList<unsigned int> cols;
173 TQValueList<unsigned int> rows = tableRows[fs->
groupmanager()];
174 for(
unsigned int r=cell->firstRow(); r <= cell->lastRow(); r++)
175 rows[r] = rows[r] + 1;
177 TQValueList<unsigned int> columns = tableCols[fs->
groupmanager()];
178 for(
unsigned int c=cell->firstColumn(); c <= cell->lastColumn(); c++)
179 columns[c] = columns[c] + 1;
182 if(m_cell == 0 || m_cell->firstRow() > cell->firstRow() ||
183 m_cell->firstRow() == cell->firstRow() &&
184 m_cell->firstColumn() > cell->firstColumn())
188 m_selected = amountSelected != 0;
189 m_oneCellSelected = amountSelected == 1;
190 if(amountSelected == 0)
return;
192 for(TQMapIterator<KWTableFrameSet*, TQValueList<unsigned int> > iter = tableRows.begin();
193 iter != tableRows.end(); ++iter) {
194 TQValueList<unsigned int> rows = iter.data();
195 TQValueListIterator<unsigned int> rowsIter = rows.begin();
196 for(
int x=0;rowsIter != rows.end(); ++rowsIter, x++)
197 if(*rowsIter == iter.key()->getColumns())
200 TQValueList<unsigned int> columns = tableCols[iter.key()];
201 TQValueListIterator<unsigned int> colsIter = columns.begin();
202 for(
int x=0;colsIter != columns.end(); ++colsIter, x++)
203 if(*colsIter == iter.key()->getRows())
208 int tableCellsSelected() {
return m_selected; }
209 int amountRowsSelected() {
return m_rows.count(); }
210 int amountColumnsSelected() {
return m_columns.count(); }
211 bool oneCellSelected() {
return m_oneCellSelected; }
212 bool protectContentEnabled() {
return m_protectContent; }
213 TQValueList<uint> selectedRows() {
return m_rows; }
214 TQValueList<uint> selectedColumns() {
return m_columns; }
215 KWTableFrameSet::Cell *firstSelectedCell() {
return m_cell; }
218 bool m_oneCellSelected, m_selected, m_protectContent;
219 TQValueList<uint> m_rows, m_columns;
220 KWTableFrameSet::Cell *m_cell;
226KWView::KWView(
const TQString& viewMode, TQWidget *parent,
const char *name, KWDocument* doc )
227 : KoView( doc, parent, name )
237 m_broker = Broker::openBroker( TDESharedConfig::openConfig(
"kwordrc" ) );
238 m_spell.macroCmdSpellCheck=0L;
239 m_spell.textIterator = 0L;
240 m_currentPage = m_doc->pageManager()->page(m_doc->startPage());
247 m_tableSplit.columns = 1;
248 m_tableSplit.rows = 1;
250 m_actionList.setAutoDelete(
true );
251 m_variableActionList.setAutoDelete(
true );
253 m_zoomViewModeNormal.m_zoom = m_doc->zoom();
254 m_zoomViewModeNormal.m_zoomMode = m_doc->zoomMode();
255 m_zoomViewModePreview.m_zoom = 33;
256 m_zoomViewModePreview.m_zoomMode = KoZoomMode::ZOOM_CONSTANT;
258 m_viewFrameBorders = m_doc->viewFrameBorders();
259 KoView::setZoom( m_doc->zoomedResolutionY() );
262 setInstance( KWFactory::instance() );
263 if ( !m_doc->isReadWrite() )
264 setXMLFile(
"kword_readonly.rc" );
266 setXMLFile(
"kword.rc" );
269 TQObject::connect(
this, TQ_SIGNAL( embeddImage(
const TQString & ) ),
270 this, TQ_SLOT( slotEmbedImage(
const TQString & ) ) );
272 setKeyCompression(
true );
273 setAcceptDrops(
true );
277 m_gui =
new KWGUI( viewMode,
this,
this );
278 m_gui->setGeometry( 0, 0, width(), height() );
282 m_sbModifiedLabel = 0;
284 m_sbOverwriteLabel = 0;
287 if ( KStatusBar* sb = statusBar() )
289 m_sbPageLabel =
new KStatusBarLabel( TQString(), 0, sb );
290 m_sbPageLabel->setAlignment( AlignLeft | AlignVCenter );
291 addStatusBarItem( m_sbPageLabel, 0 );
293 m_sbModifiedLabel =
new KStatusBarLabel(
" ", 0, sb );
294 m_sbModifiedLabel->setAlignment( AlignLeft | AlignVCenter );
295 addStatusBarItem( m_sbModifiedLabel, 0 );
297 m_sbFramesLabel =
new KStatusBarLabel( TQString(), 0, sb );
298 m_sbFramesLabel->setAlignment( AlignLeft | AlignVCenter );
299 addStatusBarItem( m_sbFramesLabel, 1 );
301 m_sbOverwriteLabel =
new KStatusBarLabel(
' ' + i18n(
"INSRT" ) +
' ', 0, sb );
302 m_sbOverwriteLabel->setAlignment( AlignHCenter | AlignVCenter );
303 addStatusBarItem( m_sbOverwriteLabel, 0 );
305 m_sbZoomLabel =
new KStatusBarLabel(
' ' + TQString::number( m_doc->zoom() ) +
"% ", 0, sb );
306 m_sbZoomLabel->setAlignment( AlignHCenter | AlignVCenter );
307 addStatusBarItem( m_sbZoomLabel, 0 );
309 m_sbUnitLabel =
new KStatusBarLabel(
' ' + KoUnit::unitDescription( m_doc->unit() ) +
' ', 0, sb );
310 m_sbUnitLabel->setAlignment( AlignHCenter | AlignVCenter );
311 addStatusBarItem( m_sbUnitLabel, 0 );
314 connect( m_doc, TQ_SIGNAL( modified(
bool ) ),
315 this, TQ_SLOT( documentModified(
bool )) );
317 connect( m_doc, TQ_SIGNAL( numPagesChanged() ),
318 this, TQ_SLOT( numPagesChanged()) );
320 connect( m_doc, TQ_SIGNAL( pageLayoutChanged(
const KoPageLayout& ) ),
321 this, TQ_SLOT( slotPageLayoutChanged(
const KoPageLayout& )) );
323 connect( m_doc, TQ_SIGNAL( docStructureChanged(
int) ),
324 this, TQ_SLOT( docStructChanged(
int)) );
326 connect( m_doc, TQ_SIGNAL( unitChanged(KoUnit::Unit) ),
327 this, TQ_SLOT( slotUnitChanged(KoUnit::Unit) ) );
329 connect( m_doc, TQ_SIGNAL( sig_refreshMenuCustomVariable()),
330 this, TQ_SLOT( refreshCustomMenu()));
332 connect( m_doc, TQ_SIGNAL( completed() ),
333 this, TQ_SLOT( slotDocumentLoadingCompleted() ) );
335 connect( frameViewManager(), TQ_SIGNAL(sigFrameSelectionChanged()),
336 this, TQ_SLOT( frameSelectedChanged()));
338 connect( frameViewManager(), TQ_SIGNAL(sigFrameSetRenamed()),
339 this, TQ_SLOT( updateFrameStatusBarItem()));
341 connect( TQApplication::clipboard(), TQ_SIGNAL( dataChanged() ),
342 this, TQ_SLOT( clipboardDataChanged() ) );
344 connect( m_gui->canvasWidget(), TQ_SIGNAL(currentFrameSetEditChanged()),
345 this, TQ_SLOT(slotFrameSetEditChanged()) );
347 connect( m_gui->canvasWidget(), TQ_SIGNAL( currentMouseModeChanged(
int) ),
348 this, TQ_SLOT( showMouseMode(
int) ) );
350 connect( m_gui->canvasWidget(), TQ_SIGNAL( overwriteModeChanged(
bool ) ),
351 this, TQ_SLOT( changeOverwriteMode(
bool ) ) );
354 if ( m_doc->isReadWrite() )
356 connect( m_gui->canvasWidget(), TQ_SIGNAL(selectionChanged(
bool)),
357 this, TQ_SLOT(slotChangeCutState(
bool )) );
358 connect (m_gui->canvasWidget(), TQ_SIGNAL(selectionChanged(
bool)),
359 this, TQ_SLOT(slotChangeCaseState(
bool )));
363 m_actionEditCut->setEnabled(
false );
364 m_actionChangeCase->setEnabled(
false );
367 connect( m_gui->canvasWidget(), TQ_SIGNAL(selectionChanged(
bool)),
368 m_actionEditCopy, TQ_SLOT(setEnabled(
bool)) );
373 connect (m_gui->canvasWidget(), TQ_SIGNAL(selectionChanged(
bool)),
374 m_actionConvertToTextBox, TQ_SLOT(setEnabled(
bool)));
375 connect (m_gui->canvasWidget(), TQ_SIGNAL(selectionChanged(
bool)),
376 m_actionAddPersonalExpression, TQ_SLOT(setEnabled(
bool )));
377 connect (m_gui->canvasWidget(), TQ_SIGNAL(selectionChanged(
bool)),
378 m_actionSortText, TQ_SLOT(setEnabled(
bool )));
380 connect( m_gui->canvasWidget(), TQ_SIGNAL(docStructChanged(
int)),
381 this, TQ_SLOT(docStructChanged(
int)));
383 connect( m_gui->canvasWidget(), TQ_SIGNAL(updateRuler()),
384 this, TQ_SLOT(slotUpdateRuler()));
388 connect( shell(), TQ_SIGNAL( documentSaved()), m_doc,TQ_SLOT(slotDocumentInfoModifed() ) );
389 changeNbOfRecentFiles( m_doc->maxRecentFiles() );
392 m_gui->canvasWidget()->updateCurrentFormat();
393 setFocusProxy( m_gui->canvasWidget() );
397 if(!m_doc->isReadWrite())
399 setZoom( 100,
true );
407 TQTimer::singleShot( 0,
this, TQ_SLOT( slotSetInitialPosition() ) );
408 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
413 delete m_tableActionList.first();
416 delete m_searchEntry;
418 delete m_replaceEntry;
420 if ( m_specialCharDlg )
421 m_specialCharDlg->closeDialog();
424 delete m_findReplace;
427 delete m_sbPageLabel;
428 delete m_sbFramesLabel;
435DCOPObject* KWView::dcopObject()
438 m_dcop =
new KWordViewIface(
this );
443void KWView::slotChangeCutState(
bool b)
445 KWTextFrameSetEdit * edit = currentTextEdit();
446 if ( edit && edit->textFrameSet()->protectContent())
447 m_actionEditCut->setEnabled(
false );
449 m_actionEditCut->setEnabled( b );
452void KWView::slotChangeCaseState(
bool b)
454 KWTextFrameSetEdit * edit = currentTextEdit();
455 if ( edit && edit->textFrameSet()->protectContent())
456 m_actionChangeCase->setEnabled(
false );
458 m_actionChangeCase->setEnabled( b );
461void KWView::slotSetInitialPosition()
463 KWTextFrameSetEdit* textedit =
dynamic_cast<KWTextFrameSetEdit *
>(m_gui->canvasWidget()->currentFrameSetEdit());
465 textedit->ensureCursorVisible();
467 m_gui->canvasWidget()->setContentsPos( 0, 0 );
470void KWView::changeNbOfRecentFiles(
int nb)
473 shell()->setMaxRecentItems( nb );
478 return m_gui->canvasWidget()->viewMode();
481void KWView::initGui()
483 clipboardDataChanged();
486 showMouseMode( KWCanvas::MM_EDIT );
488 m_actionFormatDecreaseIndent->setEnabled(
false);
491 m_actionFormatColor->setCurrentColor( TQt::black );
496 updateZoomControls();
500 m_gui->canvasWidget()->setMouseMode( m_gui->canvasWidget()->mouseMode() );
502 bool editingFormula =
dynamic_cast<KWFormulaFrameSetEdit *
>( m_gui->canvasWidget()->currentFrameSetEdit() ) != 0;
505 shell()->showToolbar(
"formula_toolbar", editingFormula );
507 if ( !editingFormula )
509 kWordDocument()->formulaDocumentWrapper()->setEnabled(
false);
510 kWordDocument()->formulaDocumentWrapper()->enableMatrixActions(
false);
511 kWordDocument()->formulaDocumentWrapper()->getSyntaxHighlightingAction()->setEnabled(
false);
515 if ( KStatusBar* sb = statusBar() )
519 slotFrameSetEditChanged();
520 frameSelectedChanged();
521 updateTocActionText(m_doc->tocPresent());
523 m_actionBackgroundColor->setEnabled(
true);
524 updateBgSpellCheckingState();
525 updateDirectCursorButton();
526 m_actionCreateFrameStyle->setEnabled(
false);
530void KWView::updateBgSpellCheckingState()
532 m_actionAllowBgSpellCheck->setChecked( m_doc->backgroundSpellCheckEnabled() );
536void KWView::initGUIButton()
538 m_actionViewFrameBorders->setChecked( viewFrameBorders() );
539 m_actionViewFormattingChars->setChecked( m_doc->viewFormattingChars() );
540 m_actionShowDocStruct->setChecked(m_doc->showdocStruct());
541 m_actionShowRuler->setChecked(m_doc->showRuler());
543 updateHeaderFooterButton();
544 m_actionAllowAutoFormat->setChecked( m_doc->allowAutoFormat() );
546 if ( !m_doc->isEmbedded() ) {
547 TQString mode = viewMode()->type();
548 if (mode==
"ModePreview")
549 m_actionViewPreviewMode->setChecked(
true);
550 else if (mode==
"ModeText")
551 m_actionViewTextMode->setChecked(
true);
553 m_actionViewPageMode->setChecked(
true);
558void KWView::setupActions()
564 m_actionExtraCreateTemplate =
new TDEAction( i18n(
"&Create Template From Document..." ), 0,
565 this, TQ_SLOT( extraCreateTemplate() ),
566 actionCollection(),
"extra_template" );
567 m_actionExtraCreateTemplate->setToolTip( i18n(
"Save this document and use it later as a template" ) );
568 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." ) );
570 m_actionFileStatistics =
new TDEAction( i18n(
"Statistics" ), 0,
this, TQ_SLOT( fileStatistics() ), actionCollection(),
"file_statistics" );
571 m_actionFileStatistics->setToolTip( i18n(
"Sentence, word and letter counts for this document" ) );
572 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." ) );
574 m_actionEditCut = KStdAction::cut(
this, TQ_SLOT( editCut() ), actionCollection(),
"edit_cut" );
575 m_actionEditCopy = KStdAction::copy(
this, TQ_SLOT( editCopy() ), actionCollection(),
"edit_copy" );
576 m_actionEditPaste = KStdAction::paste(
this, TQ_SLOT( editPaste() ), actionCollection(),
"edit_paste" );
577 m_actionEditFind = KStdAction::find(
this, TQ_SLOT( editFind() ), actionCollection(),
"edit_find" );
578 m_actionEditFindNext = KStdAction::findNext(
this, TQ_SLOT( editFindNext() ), actionCollection(),
"edit_findnext" );
579 m_actionEditFindPrevious = KStdAction::findPrev(
this, TQ_SLOT( editFindPrevious() ), actionCollection(),
"edit_findprevious" );
580 m_actionEditReplace = KStdAction::replace(
this, TQ_SLOT( editReplace() ), actionCollection(),
"edit_replace" );
581 m_actionEditSelectAll = KStdAction::selectAll(
this, TQ_SLOT( editSelectAll() ), actionCollection(),
"edit_selectall" );
582 new TDEAction( i18n(
"Select All Frames" ), 0,
this, TQ_SLOT( editSelectAllFrames() ), actionCollection(),
"edit_selectallframes" );
583 m_actionEditSelectCurrentFrame =
new TDEAction( i18n(
"Select Frame" ), 0,
584 0,
this, TQ_SLOT( editSelectCurrentFrame() ),
585 actionCollection(),
"edit_selectcurrentframe" );
586 m_actionSpellCheck = KStdAction::spelling(
this, TQ_SLOT( slotSpellCheck() ), actionCollection(),
"extra_spellcheck" );
587 m_actionDeletePage =
new TDEAction( i18n(
"Delete Page" ),
"delslide", 0,
588 this, TQ_SLOT( deletePage() ),
589 actionCollection(),
"delete_page" );
590 kdDebug() << m_doc->pageCount() <<
" " << (m_doc->processingType() == KWDocument::DTP) << endl;
592 (void)
new TDEAction( i18n(
"Configure Mai&l Merge..." ),
"configure",0,
593 this, TQ_SLOT( editMailMergeDataBase() ),
594 actionCollection(),
"edit_sldatabase" );
597 (void)
new KWMailMergeLabelAction( i18n(
"Drag Mail Merge Variable"), 0,
598 this, TQ_SLOT(editMailMergeDataBase()), actionCollection(),
"mailmerge_draglabel" );
603 m_actionEditDelFrame =
new TDEAction( i18n(
"&Delete Frame" ), 0,
604 this, TQ_SLOT( editDeleteFrame() ),
605 actionCollection(),
"edit_delframe" );
606 m_actionEditDelFrame->setToolTip( i18n(
"Delete the currently selected frame(s)." ) );
607 m_actionEditDelFrame->setWhatsThis( i18n(
"Delete the currently selected frame(s)." ) );
609 m_actionCreateLinkedFrame =
new TDEAction( i18n(
"Create Linked Copy" ), 0,
this, TQ_SLOT( createLinkedFrame() ), actionCollection(),
"create_linked_frame" );
610 m_actionCreateLinkedFrame->setToolTip( i18n(
"Create a copy of the current frame, always showing the same contents" ) );
611 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.") );
613 m_actionRaiseFrame =
new TDEAction( i18n(
"Ra&ise Frame" ),
"raise",
614 TQt::CTRL +TQt::SHIFT+ TQt::Key_R,
this, TQ_SLOT( raiseFrame() ),
615 actionCollection(),
"raiseframe" );
616 m_actionRaiseFrame->setToolTip( i18n(
"Raise the currently selected frame so that it appears above all the other frames" ) );
617 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." ) );
619 m_actionLowerFrame =
new TDEAction( i18n(
"&Lower Frame" ),
"lower",
620 TQt::CTRL +TQt::SHIFT+ TQt::Key_L,
this, TQ_SLOT( lowerFrame() ),
621 actionCollection(),
"lowerframe" );
622 m_actionLowerFrame->setToolTip( i18n(
"Lower the currently selected frame so that it disappears under any frame that overlaps it" ) );
623 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." ) );
625 m_actionBringToFront=
new TDEAction( i18n(
"Bring to Front" ),
"bring_forward",
626 0,
this, TQ_SLOT( bringToFront() ),
627 actionCollection(),
"bring_tofront_frame" );
629 m_actionSendBackward=
new TDEAction( i18n(
"Send to Back" ),
"send_backward",
630 0,
this, TQ_SLOT( sendToBack() ),
631 actionCollection(),
"send_toback_frame" );
636 if ( !m_doc->isEmbedded() ) {
638 m_actionViewTextMode =
new TDEToggleAction( i18n(
"Text Mode" ), 0,
639 this, TQ_SLOT( viewTextMode() ),
640 actionCollection(),
"view_textmode" );
641 m_actionViewTextMode->setToolTip( i18n(
"Only show the text of the document." ) );
642 m_actionViewTextMode->setWhatsThis( i18n(
"Do not show any pictures, formatting or layout. KWord will display only the text for editing." ) );
644 m_actionViewTextMode->setExclusiveGroup(
"viewmodes" );
645 m_actionViewPageMode =
new TDEToggleAction( i18n(
"&Page Mode" ), 0,
646 this, TQ_SLOT( viewPageMode() ),
647 actionCollection(),
"view_pagemode" );
648 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." ) );
649 m_actionViewPageMode->setToolTip( i18n(
"Switch to page editing mode." ) );
651 m_actionViewPageMode->setExclusiveGroup(
"viewmodes" );
652 m_actionViewPageMode->setChecked(
true );
653 m_actionViewPreviewMode =
new TDEToggleAction( i18n(
"Pre&view Mode" ), 0,
654 this, TQ_SLOT( viewPreviewMode() ),
655 actionCollection(),
"view_previewmode" );
656 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." ) );
657 m_actionViewPreviewMode->setToolTip( i18n(
"Zoom out to a multiple page view." ) );
659 m_actionViewPreviewMode->setExclusiveGroup(
"viewmodes" );
663 m_actionViewTextMode = 0;
664 m_actionViewPageMode = 0;
665 m_actionViewPreviewMode = 0;
668 m_actionViewFormattingChars =
new TDEToggleAction( i18n(
"&Formatting Characters" ), 0,
669 this, TQ_SLOT( slotViewFormattingChars() ),
670 actionCollection(),
"view_formattingchars" );
671 m_actionViewFormattingChars->setToolTip( i18n(
"Toggle the display of non-printing characters." ) );
672 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." ) );
674 m_actionViewFrameBorders =
new TDEToggleAction( i18n(
"Frame &Borders" ), 0,
675 this, TQ_SLOT( slotViewFrameBorders() ),
676 actionCollection(),
"view_frameborders" );
677 m_actionViewFrameBorders->setToolTip( i18n(
"Turns the border display on and off." ) );
678 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." ) );
680 m_actionViewHeader =
new TDEToggleAction( i18n(
"Enable Document &Headers" ), 0,
681 this, TQ_SLOT( viewHeader() ),
682 actionCollection(),
"format_header" );
683 m_actionViewHeader->setCheckedState(i18n(
"Disable Document &Headers"));
684 m_actionViewHeader->setToolTip( i18n(
"Shows and hides header display." ) );
685 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." ) );
687 m_actionViewFooter =
new TDEToggleAction( i18n(
"Enable Document Foo&ters" ), 0,
688 this, TQ_SLOT( viewFooter() ),
689 actionCollection(),
"format_footer" );
690 m_actionViewFooter->setCheckedState(i18n(
"Disable Document Foo&ters"));
691 m_actionViewFooter->setToolTip( i18n(
"Shows and hides footer display." ) );
692 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." ) );
694 m_actionViewZoom =
new TDESelectAction( i18n(
"Zoom" ),
"viewmag", 0,
695 actionCollection(),
"view_zoom" );
697 connect( m_actionViewZoom, TQ_SIGNAL( activated(
const TQString & ) ),
698 this, TQ_SLOT( viewZoom(
const TQString & ) ) );
699 m_actionViewZoom->setEditable(
true);
703 m_actionInsertSpecialChar =
new TDEAction( i18n(
"Sp&ecial Character..." ),
"char",
704 TQt::ALT + TQt::SHIFT + TQt::Key_C,
705 this, TQ_SLOT( insertSpecialChar() ),
706 actionCollection(),
"insert_specialchar" );
707 m_actionInsertSpecialChar->setToolTip( i18n(
"Insert one or more symbols or letters not found on the keyboard." ) );
708 m_actionInsertSpecialChar->setWhatsThis( i18n(
"Insert one or more symbols or letters not found on the keyboard." ) );
710 m_actionInsertFrameBreak =
new TDEAction( TQString(), TQt::CTRL + TQt::Key_Return,
711 this, TQ_SLOT( insertFrameBreak() ),
712 actionCollection(),
"insert_framebreak" );
713 if ( m_doc->processingType() == KWDocument::WP ) {
714 m_actionInsertFrameBreak->setText( i18n(
"Page Break" ) );
715 m_actionInsertFrameBreak->setToolTip( i18n(
"Force the remainder of the text into the next page." ) );
716 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." ) );
718 m_actionInsertFrameBreak->setText( i18n(
"&Hard Frame Break" ) );
719 m_actionInsertFrameBreak->setToolTip( i18n(
"Force the remainder of the text into the next frame." ) );
720 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." ) );
723 new TDEAction( m_doc->processingType() == KWDocument::WP ? i18n(
"Page" ) : i18n(
"Page..." ),
"page", 0,
724 this, TQ_SLOT( insertPage() ),
725 actionCollection(),
"insert_page" );
727 m_actionInsertLink =
new TDEAction( i18n(
"Link..." ), 0,
728 this, TQ_SLOT( insertLink() ),
729 actionCollection(),
"insert_link" );
730 m_actionInsertLink->setToolTip( i18n(
"Insert a Web address, email address or hyperlink to a file." ) );
731 m_actionInsertLink->setWhatsThis( i18n(
"Insert a Web address, email address or hyperlink to a file." ) );
733 m_actionInsertComment =
new TDEAction( i18n(
"Comment..." ), 0,
734 this, TQ_SLOT( insertComment() ),
735 actionCollection(),
"insert_comment" );
736 m_actionInsertComment->setToolTip( i18n(
"Insert a comment about the selected text." ) );
737 m_actionInsertComment->setWhatsThis( i18n(
"Insert a comment about the selected text. These comments are not designed to appear on the final page." ) );
739 m_actionEditComment =
new TDEAction( i18n(
"Edit Comment..."), 0,
740 this, TQ_SLOT(editComment()),
741 actionCollection(),
"edit_comment");
742 m_actionEditComment->setToolTip( i18n(
"Change the content of a comment." ) );
743 m_actionEditComment->setWhatsThis( i18n(
"Change the content of a comment." ) );
745 m_actionRemoveComment =
new TDEAction( i18n(
"Remove Comment"), 0,
746 this, TQ_SLOT(removeComment()),
747 actionCollection(),
"remove_comment");
748 m_actionRemoveComment->setToolTip( i18n(
"Remove the selected document comment." ) );
749 m_actionRemoveComment->setWhatsThis( i18n(
"Remove the selected document comment." ) );
750 m_actionCopyTextOfComment =
new TDEAction( i18n(
"Copy Text of Comment..."), 0,
751 this, TQ_SLOT(copyTextOfComment()),
752 actionCollection(),
"copy_text_comment");
755 m_actionInsertFootEndNote =
new TDEAction( i18n(
"&Footnote/Endnote..." ), 0,
756 this, TQ_SLOT( insertFootNote() ),
757 actionCollection(),
"insert_footendnote" );
758 m_actionInsertFootEndNote->setToolTip( i18n(
"Insert a footnote referencing the selected text." ) );
759 m_actionInsertFootEndNote->setWhatsThis( i18n(
"Insert a footnote referencing the selected text." ) );
761 m_actionInsertContents =
new TDEAction( i18n(
"Table of &Contents" ), 0,
762 this, TQ_SLOT( insertContents() ),
763 actionCollection(),
"insert_contents" );
764 m_actionInsertContents->setToolTip( i18n(
"Insert table of contents at the current cursor position." ) );
765 m_actionInsertContents->setWhatsThis( i18n(
"Insert table of contents at the current cursor position." ) );
767 m_variableDefMap.clear();
768 actionInsertVariable =
new TDEActionMenu( i18n(
"&Variable" ),
769 actionCollection(),
"insert_variable" );
772 addVariableActions( VT_FIELD, KoFieldVariable::actionTexts(), actionInsertVariable, i18n(
"Document &Information") );
773 addVariableActions( VT_DATE, KoDateVariable::actionTexts(), actionInsertVariable, i18n(
"&Date") );
774 addVariableActions( VT_TIME, KoTimeVariable::actionTexts(), actionInsertVariable, i18n(
"&Time") );
775 addVariableActions( VT_PGNUM, KoPageVariable::actionTexts(), actionInsertVariable, i18n(
"&Page") );
776 addVariableActions( VT_STATISTIC, KWStatisticVariable::actionTexts(), actionInsertVariable, i18n(
"&Statistic") );
778 m_actionInsertCustom =
new TDEActionMenu( i18n(
"&Custom" ),
779 actionCollection(),
"insert_custom" );
780 actionInsertVariable->insert(m_actionInsertCustom);
784 addVariableActions( VT_MAILMERGE, KoMailMergeVariable::actionTexts(), actionInsertVariable, TQString() );
786 actionInsertVariable->popupMenu()->insertSeparator();
787 m_actionRefreshAllVariable =
new TDEAction( i18n(
"&Refresh All Variables" ), 0,
788 this, TQ_SLOT( refreshAllVariable() ),
789 actionCollection(),
"refresh_all_variable" );
790 m_actionRefreshAllVariable->setToolTip( i18n(
"Update all variables to current values." ) );
791 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." ) );
793 actionInsertVariable->insert(m_actionRefreshAllVariable);
795 m_actionInsertExpression =
new TDEActionMenu( i18n(
"&Expression" ),
796 actionCollection(),
"insert_expression" );
797 loadexpressionActions( m_actionInsertExpression);
799 m_actionToolsCreateText =
new TDEToggleAction( i18n(
"Te&xt Frame" ),
"frame_text", TQt::Key_F10 ,
800 this, TQ_SLOT( toolsCreateText() ),
801 actionCollection(),
"tools_createtext" );
802 m_actionToolsCreateText->setToolTip( i18n(
"Create a new text frame." ) );
803 m_actionToolsCreateText->setWhatsThis( i18n(
"Create a new text frame." ) );
805 m_actionToolsCreateText->setExclusiveGroup(
"tools" );
806 m_actionInsertFormula =
new TDEAction( i18n(
"For&mula" ),
"frame_formula", TQt::Key_F4,
807 this, TQ_SLOT( insertFormula() ),
808 actionCollection(),
"tools_formula" );
809 m_actionInsertFormula->setToolTip( i18n(
"Insert a formula into a new frame." ) );
810 m_actionInsertFormula->setWhatsThis( i18n(
"Insert a formula into a new frame." ) );
812 m_actionInsertTable =
new TDEAction( i18n(
"&Table..." ),
"inline_table",
814 this, TQ_SLOT( insertTable() ),
815 actionCollection(),
"insert_table" );
816 m_actionInsertTable->setToolTip( i18n(
"Create a table." ) );
817 m_actionInsertTable->setWhatsThis( i18n(
"Create a table.<br><br>The table can either exist in a frame of its own or inline." ) );
819 m_actionToolsCreatePix =
new TDEToggleAction( i18n(
"P&icture..." ),
"frame_image",
820 TQt::SHIFT + TQt::Key_F5 ,
821 this, TQ_SLOT( insertPicture() ),
822 actionCollection(),
"insert_picture" );
823 m_actionToolsCreatePix->setToolTip( i18n(
"Create a new frame for a picture." ) );
824 m_actionToolsCreatePix->setWhatsThis( i18n(
"Create a new frame for a picture or diagram." ) );
825 m_actionToolsCreatePix->setExclusiveGroup(
"tools" );
827 m_actionToolsCreatePart =
new KoPartSelectAction( i18n(
"&Object Frame" ),
"frame_query",
828 this, TQ_SLOT( toolsPart() ),
829 actionCollection(),
"tools_part" );
830 m_actionToolsCreatePart->setToolTip( i18n(
"Insert an object into a new frame." ) );
831 m_actionToolsCreatePart->setWhatsThis( i18n(
"Insert an object into a new frame." ) );
833 m_actionInsertFile =
new TDEAction( i18n(
"Fi&le..." ), 0,
834 this, TQ_SLOT( insertFile() ),
835 actionCollection(),
"insert_file" );
839 m_actionFormatFont =
new TDEAction( i18n(
"&Font..." ), TQt::ALT + TQt::CTRL + TQt::Key_F,
840 this, TQ_SLOT( formatFont() ),
841 actionCollection(),
"format_font" );
842 m_actionFormatFont->setToolTip( i18n(
"Change character size, font, boldface, italics etc." ) );
843 m_actionFormatFont->setWhatsThis( i18n(
"Change the attributes of the currently selected characters." ) );
845 m_actionFormatParag =
new TDEAction( i18n(
"&Paragraph..." ), TQt::ALT + TQt::CTRL + TQt::Key_P,
846 this, TQ_SLOT( formatParagraph() ),
847 actionCollection(),
"format_paragraph" );
848 m_actionFormatParag->setToolTip( i18n(
"Change paragraph margins, text flow, borders, bullets, numbering etc." ) );
849 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." ) );
851 m_actionFormatFrameSet =
new TDEAction( i18n(
"F&rame/Frameset Properties" ), 0,
852 this, TQ_SLOT( formatFrameSet() ),
853 actionCollection(),
"format_frameset" );
854 m_actionFormatFrameSet->setToolTip( i18n(
"Alter frameset properties." ) );
855 m_actionFormatFrameSet->setWhatsThis( i18n(
"Alter frameset properties.<p>Currently you can change the frame background." ) );
857 m_actionFormatPage =
new TDEAction( i18n(
"Page &Layout..." ), 0,
858 this, TQ_SLOT( formatPage() ),
859 actionCollection(),
"format_page" );
860 m_actionFormatPage->setToolTip( i18n(
"Change properties of entire page." ) );
861 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." ) );
864 m_actionFormatFrameStylist =
new TDEAction( i18n(
"&Frame Style Manager" ), 0 ,
865 this, TQ_SLOT( extraFrameStylist() ),
866 actionCollection(),
"frame_stylist" );
867 m_actionFormatFrameStylist->setToolTip( i18n(
"Change attributes of framestyles." ) );
868 m_actionFormatFrameStylist->setWhatsThis( i18n(
"Change background and borders of framestyles.<p>Multiple framestyles can be changed using the dialog box." ) );
871 m_actionFormatStylist =
new TDEAction( i18n(
"&Style Manager" ), TQt::ALT + TQt::CTRL + TQt::Key_S,
872 this, TQ_SLOT( extraStylist() ),
873 actionCollection(),
"format_stylist" );
874 m_actionFormatStylist->setToolTip( i18n(
"Change attributes of styles." ) );
875 m_actionFormatStylist->setWhatsThis( i18n(
"Change font and paragraph attributes of styles.<p>Multiple styles can be changed using the dialog box." ) );
877 m_actionFormatFontSize =
new TDEFontSizeAction( i18n(
"Font Size" ), 0,
878 actionCollection(),
"format_fontsize" );
879 connect( m_actionFormatFontSize, TQ_SIGNAL( fontSizeChanged(
int ) ),
880 this, TQ_SLOT( textSizeSelected(
int ) ) );
882 m_actionFontSizeIncrease =
new TDEAction( i18n(
"Increase Font Size"),
"fontsizeup", TQt::CTRL + TQt::Key_Greater,
this, TQ_SLOT( increaseFontSize() ), actionCollection(),
"increase_fontsize" );
883 m_actionFontSizeDecrease =
new TDEAction( i18n(
"Decrease Font Size"),
"fontsizedown", TQt::CTRL + TQt::Key_Less,
this, TQ_SLOT( decreaseFontSize() ), actionCollection(),
"decrease_fontsize" );
885#ifdef KFONTACTION_HAS_CRITERIA_ARG
886 m_actionFormatFontFamily =
new TDEFontAction( TDEFontChooser::SmoothScalableFonts,
887 i18n(
"Font Family" ), 0,
888 actionCollection(),
"format_fontfamily" );
890 m_actionFormatFontFamily =
new TDEFontAction( i18n(
"Font Family" ), 0,
891 actionCollection(),
"format_fontfamily" );
893 connect( m_actionFormatFontFamily, TQ_SIGNAL( activated(
const TQString & ) ),
894 this, TQ_SLOT( textFontSelected(
const TQString & ) ) );
896 m_actionFormatStyleMenu =
new TDEActionMenu( i18n(
"St&yle" ), 0,
897 actionCollection(),
"format_stylemenu" );
898 m_actionFormatStyle =
new TDESelectAction( i18n(
"St&yle" ), 0,
899 actionCollection(),
"format_style" );
902 connect( m_actionFormatStyle, TQ_SIGNAL( activated(
int ) ),
903 this, TQ_SLOT( textStyleSelected(
int ) ) );
906 m_actionFormatDefault=
new TDEAction( i18n(
"Default Format" ), 0,
907 this, TQ_SLOT( textDefaultFormat() ),
908 actionCollection(),
"text_default" );
909 m_actionFormatDefault->setToolTip( i18n(
"Change font and paragraph attributes to their default values." ) );
910 m_actionFormatDefault->setWhatsThis( i18n(
"Change font and paragraph attributes to their default values." ) );
914 m_actionFormatBold =
new TDEToggleAction( i18n(
"&Bold" ),
"format-text-bold", TQt::CTRL + TQt::Key_B,
915 this, TQ_SLOT( textBold() ),
916 actionCollection(),
"format_bold" );
917 m_actionFormatItalic =
new TDEToggleAction( i18n(
"&Italic" ),
"format-text-italic", TQt::CTRL + TQt::Key_I,
918 this, TQ_SLOT( textItalic() ),
919 actionCollection(),
"format_italic" );
920 m_actionFormatUnderline =
new TDEToggleAction( i18n(
"&Underline" ),
"format-text-underline", TQt::CTRL + TQt::Key_U,
921 this, TQ_SLOT( textUnderline() ),
922 actionCollection(),
"format_underline" );
923 m_actionFormatStrikeOut =
new TDEToggleAction( i18n(
"&Strike Out" ),
"format-text-strikethrough", 0 ,
924 this, TQ_SLOT( textStrikeOut() ),
925 actionCollection(),
"format_strike" );
927 m_actionFormatAlignLeft =
new TDEToggleAction( i18n(
"Align &Left" ),
"format-text-direction-ltr", TQt::CTRL + TQt::Key_L,
928 this, TQ_SLOT( textAlignLeft() ),
929 actionCollection(),
"format_alignleft" );
930 m_actionFormatAlignLeft->setExclusiveGroup(
"align" );
931 m_actionFormatAlignLeft->setChecked(
true );
932 m_actionFormatAlignCenter =
new TDEToggleAction( i18n(
"Align &Center" ),
"text_center", TQt::CTRL + TQt::ALT + TQt::Key_C,
933 this, TQ_SLOT( textAlignCenter() ),
934 actionCollection(),
"format_aligncenter" );
935 m_actionFormatAlignCenter->setExclusiveGroup(
"align" );
936 m_actionFormatAlignRight =
new TDEToggleAction( i18n(
"Align &Right" ),
"format-text-direction-rtl", TQt::CTRL + TQt::ALT + TQt::Key_R,
937 this, TQ_SLOT( textAlignRight() ),
938 actionCollection(),
"format_alignright" );
939 m_actionFormatAlignRight->setExclusiveGroup(
"align" );
940 m_actionFormatAlignBlock =
new TDEToggleAction( i18n(
"Align &Block" ),
"text_block", TQt::CTRL + TQt::Key_J,
941 this, TQ_SLOT( textAlignBlock() ),
942 actionCollection(),
"format_alignblock" );
943 m_actionFormatAlignBlock->setExclusiveGroup(
"align" );
945 m_actionFormatSpacingSingle =
new TDEToggleAction( i18n(
"Line Spacing &1" ),
"spacesimple", TQt::CTRL + TQt::Key_1,
946 this, TQ_SLOT( textSpacingSingle() ),
947 actionCollection(),
"format_spacingsingle" );
948 m_actionFormatSpacingSingle->setExclusiveGroup(
"spacing" );
949 m_actionFormatSpacingOneAndHalf =
new TDEToggleAction( i18n(
"Line Spacing 1.&5" ),
"spacedouble", TQt::CTRL + TQt::Key_5,
950 this, TQ_SLOT( textSpacingOneAndHalf() ),
951 actionCollection(),
"format_spacing15" );
952 m_actionFormatSpacingOneAndHalf->setExclusiveGroup(
"spacing" );
953 m_actionFormatSpacingDouble =
new TDEToggleAction( i18n(
"Line Spacing &2" ),
"spacetriple", TQt::CTRL + TQt::Key_2,
954 this, TQ_SLOT( textSpacingDouble() ),
955 actionCollection(),
"format_spacingdouble" );
956 m_actionFormatSpacingDouble->setExclusiveGroup(
"spacing" );
958 m_actionFormatSuper =
new TDEToggleAction( i18n(
"Superscript" ),
"super", 0,
959 this, TQ_SLOT( textSuperScript() ),
960 actionCollection(),
"format_super" );
962 m_actionFormatSub =
new TDEToggleAction( i18n(
"Subscript" ),
"sub", 0,
963 this, TQ_SLOT( textSubScript() ),
964 actionCollection(),
"format_sub" );
967 m_actionFormatIncreaseIndent=
new TDEAction( i18n(
"Increase Indent" ),
968 TQApplication::reverseLayout() ?
"format_decreaseindent" :
"format_increaseindent", 0,
969 this, TQ_SLOT( textIncreaseIndent() ),
970 actionCollection(),
"format_increaseindent" );
972 m_actionFormatDecreaseIndent=
new TDEAction( i18n(
"Decrease Indent" ),
973 TQApplication::reverseLayout() ?
"format_increaseindent" :
"format_decreaseindent", 0,
974 this, TQ_SLOT( textDecreaseIndent() ),
975 actionCollection(),
"format_decreaseindent" );
977 m_actionFormatColor =
new TTDESelectColorAction( i18n(
"Text Color..." ), TTDESelectColorAction::TextColor,
978 this, TQ_SLOT( textColor() ),
979 actionCollection(),
"format_color",
true );
980 m_actionFormatColor->setDefaultColor(TQColor());
988 m_actionFormatNumber =
new TDEActionMenu( i18n(
"Number" ),
989 "enumList", actionCollection(),
"format_number" );
990 m_actionFormatNumber->setDelayed(
false );
991 m_actionFormatBullet =
new TDEActionMenu( i18n(
"Bullet" ),
992 "unsortedList", actionCollection(),
"format_bullet" );
993 m_actionFormatBullet->setDelayed(
false );
994 TQPtrList<KoCounterStyleWidget::StyleRepresenter> stylesList;
995 KoCounterStyleWidget::makeCounterRepresenterList( stylesList );
996 TQPtrListIterator<KoCounterStyleWidget::StyleRepresenter> styleIt( stylesList );
997 for ( ; styleIt.current() ; ++styleIt ) {
1000 TDEToggleAction* act =
new TDEToggleAction( styleIt.current()->name(),
1001 0,
this, TQ_SLOT( slotCounterStyleSelected() ),
1002 actionCollection(), TQString(
"counterstyle_%1").arg( styleIt.current()->style() ).latin1() );
1003 act->setExclusiveGroup(
"counterstyle" );
1005 if ( styleIt.current()->style() == KoParagCounter::STYLE_NONE ) {
1006 m_actionFormatBullet->insert( act );
1007 m_actionFormatNumber->insert( act );
1008 }
else if ( styleIt.current()->isBullet() )
1009 m_actionFormatBullet->insert( act );
1011 m_actionFormatNumber->insert( act );
1016 m_actionFrameStyleMenu =
new TDEActionMenu( i18n(
"Fra&mestyle" ), 0,
1017 actionCollection(),
"frame_stylemenu" );
1018 m_actionFrameStyle =
new TDESelectAction( i18n(
"Framest&yle" ), 0,
1019 actionCollection(),
"frame_style" );
1020 connect( m_actionFrameStyle, TQ_SIGNAL( activated(
int ) ),
1021 this, TQ_SLOT( frameStyleSelected(
int ) ) );
1022 updateFrameStyleList();
1023 m_actionBorderOutline =
new TDEToggleAction( i18n(
"Border Outline" ),
"borderoutline",
1024 0,
this, TQ_SLOT( borderOutline() ), actionCollection(),
"border_outline" );
1025 m_actionBorderLeft =
new TDEToggleAction( i18n(
"Border Left" ),
"borderleft",
1026 0,
this, TQ_SLOT( borderLeft() ), actionCollection(),
"border_left" );
1027 m_actionBorderRight =
new TDEToggleAction( i18n(
"Border Right" ),
"borderright",
1028 0,
this, TQ_SLOT( borderRight() ), actionCollection(),
"border_right" );
1029 m_actionBorderTop =
new TDEToggleAction( i18n(
"Border Top" ),
"bordertop",
1030 0,
this, TQ_SLOT( borderTop() ), actionCollection(),
"border_top" );
1031 m_actionBorderBottom =
new TDEToggleAction( i18n(
"Border Bottom" ),
"borderbottom",
1032 0,
this, TQ_SLOT( borderBottom() ), actionCollection(),
"border_bottom" );
1033 m_actionBorderStyle =
new TDESelectAction( i18n(
"Border Style" ),
1034 0, actionCollection(),
"border_style" );
1037 lst << KoBorder::getStyle( KoBorder::SOLID );
1038 lst << KoBorder::getStyle( KoBorder::DASH );
1039 lst << KoBorder::getStyle( KoBorder::DOT );
1040 lst << KoBorder::getStyle( KoBorder::DASH_DOT );
1041 lst << KoBorder::getStyle( KoBorder::DASH_DOT_DOT );
1042 lst << KoBorder::getStyle( KoBorder::DOUBLE_LINE );
1043 m_actionBorderStyle->setItems( lst );
1044 m_actionBorderWidth =
new TDESelectAction( i18n(
"Border Width" ), 0,
1045 actionCollection(),
"border_width" );
1047 for (
unsigned int i = 1; i < 10; i++ )
1048 lst << TQString::number( i );
1049 m_actionBorderWidth->setItems( lst );
1050 m_actionBorderWidth->setCurrentItem( 0 );
1052 m_actionBorderColor =
new TTDESelectColorAction( i18n(
"Border Color"), TTDESelectColorAction::LineColor, actionCollection(),
"border_color",
true );
1053 m_actionBorderColor->setDefaultColor(TQColor());
1056 m_actionBackgroundColor =
new TTDESelectColorAction( i18n(
"Text Background Color..." ), TTDESelectColorAction::FillColor, actionCollection(),
"border_backgroundcolor",
true);
1057 m_actionBackgroundColor->setToolTip( i18n(
"Change background color for currently selected text." ) );
1058 m_actionBackgroundColor->setWhatsThis( i18n(
"Change background color for currently selected text." ) );
1060 connect(m_actionBackgroundColor,TQ_SIGNAL(activated()),TQ_SLOT(backgroundColor() ));
1061 m_actionBackgroundColor->setDefaultColor(TQColor());
1064 m_actionTablePropertiesMenu =
new TDEAction( i18n(
"&Properties" ), 0,
1065 this, TQ_SLOT( tableProperties() ),
1066 actionCollection(),
"table_propertiesmenu" );
1067 m_actionTablePropertiesMenu->setToolTip( i18n(
"Adjust properties of the current table." ) );
1068 m_actionTablePropertiesMenu->setWhatsThis( i18n(
"Adjust properties of the current table." ) );
1070 m_actionTableInsertRow =
new TDEAction( i18n(
"&Insert Row..." ),
"insert_table_row", 0,
1071 this, TQ_SLOT( tableInsertRow() ),
1072 actionCollection(),
"table_insrow" );
1073 m_actionTableInsertRow->setToolTip( i18n(
"Insert one or more rows at cursor location." ) );
1074 m_actionTableInsertRow->setWhatsThis( i18n(
"Insert one or more rows at current cursor location." ) );
1076 m_actionTableInsertCol =
new TDEAction( i18n(
"I&nsert Column..." ),
"insert_table_col", 0,
1077 this, TQ_SLOT( tableInsertCol() ),
1078 actionCollection(),
"table_inscol" );
1079 m_actionTableInsertCol->setToolTip( i18n(
"Insert one or more columns into the current table." ) );
1080 m_actionTableInsertCol->setWhatsThis( i18n(
"Insert one or more columns into the current table." ) );
1082 m_actionTableDelRow =
new TDEAction( 0,
"delete_table_row", 0,
1083 this, TQ_SLOT( tableDeleteRow() ),
1084 actionCollection(),
"table_delrow" );
1085 m_actionTableDelRow->setToolTip( i18n(
"Delete selected rows from the current table." ) );
1086 m_actionTableDelRow->setWhatsThis( i18n(
"Delete selected rows from the current table." ) );
1088 m_actionTableDelCol =
new TDEAction( 0,
"delete_table_col", 0,
1089 this, TQ_SLOT( tableDeleteCol() ),
1090 actionCollection(),
"table_delcol" );
1091 m_actionTableDelCol->setToolTip( i18n(
"Delete selected columns from the current table." ) );
1092 m_actionTableDelCol->setWhatsThis( i18n(
"Delete selected columns from the current table." ) );
1094 m_actionTableResizeCol =
new TDEAction( i18n(
"Resize Column..." ), 0,
1095 this, TQ_SLOT( tableResizeCol() ),
1096 actionCollection(),
"table_resizecol" );
1097 m_actionTableResizeCol->setToolTip( i18n(
"Change the width of the currently selected column." ) );
1098 m_actionTableResizeCol->setWhatsThis( i18n(
"Change the width of the currently selected column." ) );
1101 m_actionTableJoinCells =
new TDEAction( i18n(
"&Join Cells" ), 0,
1102 this, TQ_SLOT( tableJoinCells() ),
1103 actionCollection(),
"table_joincells" );
1104 m_actionTableJoinCells->setToolTip( i18n(
"Join two or more cells into one large cell." ) );
1105 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." ) );
1107 m_actionTableSplitCells=
new TDEAction( i18n(
"&Split Cell..." ), 0,
1108 this, TQ_SLOT( tableSplitCells() ),
1109 actionCollection(),
"table_splitcells" );
1110 m_actionTableSplitCells->setToolTip( i18n(
"Split one cell into two or more cells." ) );
1111 m_actionTableSplitCells->setWhatsThis( i18n(
"Split one cell into two or more cells.<p>Cells can be split horizontally, vertically or both directions at once." ) );
1113 m_actionTableProtectCells=
new TDEToggleAction( i18n(
"Protect Cells" ), 0, 0, 0,
1114 actionCollection(),
"table_protectcells" );
1115 m_actionTableProtectCells->setToolTip( i18n(
"Prevent changes to content of selected cells." ) );
1116 connect (m_actionTableProtectCells, TQ_SIGNAL( toggled(
bool) ),
this,
1117 TQ_SLOT( tableProtectCells(
bool) ));
1119 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." ) );
1121 m_actionTableUngroup =
new TDEAction( i18n(
"&Ungroup Table" ), 0,
1122 this, TQ_SLOT( tableUngroupTable() ),
1123 actionCollection(),
"table_ungroup" );
1124 m_actionTableUngroup->setToolTip( i18n(
"Break a table into individual frames." ) );
1125 m_actionTableUngroup->setWhatsThis( i18n(
"Break a table into individual frames<p>Each frame can be moved independently around the page." ) );
1127 m_actionTableDelete =
new TDEAction( i18n(
"Delete &Table" ), 0,
1128 this, TQ_SLOT( tableDelete() ),
1129 actionCollection(),
"table_delete" );
1130 m_actionTableDelete->setToolTip( i18n(
"Delete the entire table." ) );
1131 m_actionTableDelete->setWhatsThis( i18n(
"Deletes all cells and the content within the cells of the currently selected table." ) );
1134 m_actionTableStylist =
new TDEAction( i18n(
"T&able Style Manager" ), 0,
1135 this, TQ_SLOT( tableStylist() ),
1136 actionCollection(),
"table_stylist" );
1137 m_actionTableStylist->setToolTip( i18n(
"Change attributes of tablestyles." ) );
1138 m_actionTableStylist->setWhatsThis( i18n(
"Change textstyle and framestyle of the tablestyles.<p>Multiple tablestyles can be changed using the dialog box." ) );
1140 m_actionTableStyleMenu =
new TDEActionMenu( i18n(
"Table&style" ), 0,
1141 actionCollection(),
"table_stylemenu" );
1142 m_actionTableStyle =
new TDESelectAction( i18n(
"Table&style" ), 0,
1143 actionCollection(),
"table_style" );
1144 connect( m_actionTableStyle, TQ_SIGNAL( activated(
int ) ),
1145 this, TQ_SLOT( tableStyleSelected(
int ) ) );
1146 updateTableStyleList();
1148 m_actionConvertTableToText =
new TDEAction( i18n(
"Convert Table to Text" ), 0,
1149 this, TQ_SLOT( convertTableToText() ),
1150 actionCollection(),
"convert_table_to_text" );
1151 m_actionSortText=
new TDEAction( i18n(
"Sort Text..." ), 0,
1152 this, TQ_SLOT( sortText() ),
1153 actionCollection(),
"sort_text" );
1155 m_actionAddPersonalExpression=
new TDEAction( i18n(
"Add Expression" ), 0,
1156 this, TQ_SLOT( addPersonalExpression() ),
1157 actionCollection(),
"add_personal_expression" );
1163 m_actionAllowAutoFormat =
new TDEToggleAction( i18n(
"Enable Autocorrection" ), 0,
1164 this, TQ_SLOT( slotAllowAutoFormat() ),
1165 actionCollection(),
"enable_autocorrection" );
1166 m_actionAllowAutoFormat->setCheckedState(i18n(
"Disable Autocorrection"));
1167 m_actionAllowAutoFormat->setToolTip( i18n(
"Toggle autocorrection on and off." ) );
1168 m_actionAllowAutoFormat->setWhatsThis( i18n(
"Toggle autocorrection on and off." ) );
1170 m_actionAutoFormat =
new TDEAction( i18n(
"Configure &Autocorrection..." ), 0,
1171 this, TQ_SLOT( extraAutoFormat() ),
1172 actionCollection(),
"configure_autocorrection" );
1173 m_actionAutoFormat->setToolTip( i18n(
"Change autocorrection options." ) );
1174 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>." ) );
1176 m_actionEditCustomVarsEdit =
new TDEAction( i18n(
"Custom &Variables..." ), 0,
1177 this, TQ_SLOT( editCustomVars() ),
1178 actionCollection(),
"custom_vars" );
1180 m_actionEditPersonnalExpr=
new TDEAction( i18n(
"Edit &Personal Expressions..." ), 0,
1181 this, TQ_SLOT( editPersonalExpr() ),
1182 actionCollection(),
"personal_expr" );
1183 m_actionEditPersonnalExpr->setToolTip( i18n(
"Add or change one or more personal expressions." ) );
1184 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." ) );
1186 m_actionChangeCase=
new TDEAction( i18n(
"Change Case..." ), 0,
1187 this, TQ_SLOT( changeCaseOfText() ),
1188 actionCollection(),
"change_case" );
1189 m_actionChangeCase->setToolTip( i18n(
"Alter the capitalization of selected text." ) );
1190 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." ) );
1193 m_actionConfigure = KStdAction::preferences(
this, TQ_SLOT(configure()), actionCollection(),
"configure" );
1196 TDEAction *actionChangePicture=
new TDEAction( i18n(
"Change Picture..." ),
"frame_image",0,
1197 this, TQ_SLOT( changePicture() ),
1198 actionCollection(),
"change_picture" );
1199 actionChangePicture->setToolTip( i18n(
"Change the picture in the currently selected frame." ) );
1200 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." ) );
1202 m_actionConfigureHeaderFooter=
new TDEAction( i18n(
"Configure Header/Footer..." ), 0,
1203 this, TQ_SLOT( configureHeaderFooter() ),
1204 actionCollection(),
"configure_headerfooter" );
1205 m_actionConfigureHeaderFooter->setToolTip( i18n(
"Configure the currently selected header or footer." ) );
1206 m_actionConfigureHeaderFooter->setWhatsThis( i18n(
"Configure the currently selected header or footer." ) );
1208 m_actionInlineFrame =
new TDEToggleAction( i18n(
"Inline Frame" ), 0,
1209 this, TQ_SLOT( inlineFrame() ),
1210 actionCollection(),
"inline_frame" );
1211 m_actionInlineFrame->setToolTip( i18n(
"Convert current frame to an inline frame." ) );
1212 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." ) );
1214 m_actionOpenLink =
new TDEAction( i18n(
"Open Link" ), 0,
1215 this, TQ_SLOT( openLink() ),
1216 actionCollection(),
"open_link" );
1217 m_actionOpenLink->setToolTip( i18n(
"Open the link with the appropriate application." ) );
1218 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." ) );
1220 m_actionChangeLink=
new TDEAction( i18n(
"Change Link..."), 0,
1221 this, TQ_SLOT(changeLink()),
1222 actionCollection(),
"change_link");
1223 m_actionChangeLink->setToolTip( i18n(
"Change the content of the currently selected link." ) );
1224 m_actionChangeLink->setWhatsThis( i18n(
"Change the details of the currently selected link." ) );
1226 m_actionCopyLink =
new TDEAction( i18n(
"Copy Link" ), 0,
1227 this, TQ_SLOT( copyLink() ),
1228 actionCollection(),
"copy_link" );
1230 m_actionAddLinkToBookmak =
new TDEAction( i18n(
"Add to Bookmark" ), 0,
1231 this, TQ_SLOT( addToBookmark() ),
1232 actionCollection(),
"add_to_bookmark" );
1234 m_actionRemoveLink =
new TDEAction( i18n(
"Remove Link" ), 0,
1235 this, TQ_SLOT( removeLink() ),
1236 actionCollection(),
"remove_link" );
1238 m_actionShowDocStruct =
new TDEToggleAction( i18n(
"Show Doc Structure" ), 0,
1239 this, TQ_SLOT( showDocStructure() ),
1240 actionCollection(),
"show_docstruct" );
1241 m_actionShowDocStruct->setCheckedState(i18n(
"Hide Doc Structure"));
1242 m_actionShowDocStruct->setToolTip( i18n(
"Open document structure sidebar." ) );
1243 m_actionShowDocStruct->setWhatsThis( i18n(
"Open document structure sidebar.<p>This sidebar helps you organize your document and quickly find pictures, tables etc." ) );
1245 m_actionShowRuler =
new TDEToggleAction( i18n(
"Show Rulers" ), 0,
1246 this, TQ_SLOT( showRuler() ),
1247 actionCollection(),
"show_ruler" );
1248 m_actionShowRuler->setCheckedState(i18n(
"Hide Rulers"));
1249 m_actionShowRuler->setToolTip( i18n(
"Shows or hides rulers." ) );
1250 m_actionShowRuler->setWhatsThis( i18n(
"The rulers are the white measuring spaces top and left of the "
1251 "document. The rulers show the position and width of pages and of frames and can "
1252 "be used to position tabulators among others.<p>Uncheck this to disable "
1253 "the rulers from being displayed." ) );
1255 m_actionViewShowGrid =
new TDEToggleAction( i18n(
"Show Grid" ), 0,
1256 this, TQ_SLOT( viewGrid() ),
1257 actionCollection(),
"view_grid" );
1258 m_actionViewShowGrid->setCheckedState(i18n(
"Hide Grid"));
1260 m_actionViewSnapToGrid=
new TDEToggleAction( i18n(
"Snap to Grid" ), 0,
1261 this, TQ_SLOT(viewSnapToGrid() ),
1262 actionCollection(),
"view_snaptogrid" );
1264 m_actionConfigureCompletion =
new TDEAction( i18n(
"Configure C&ompletion..." ), 0,
1265 this, TQ_SLOT( configureCompletion() ),
1266 actionCollection(),
"configure_completion" );
1267 m_actionConfigureCompletion->setToolTip( i18n(
"Change the words and options for autocompletion." ) );
1268 m_actionConfigureCompletion->setWhatsThis( i18n(
"Add words or change the options for autocompletion." ) );
1272 new TDEAction( i18n(
"Insert Non-Breaking Space" ), TQt::CTRL+TQt::Key_Space,
1273 this, TQ_SLOT( slotNonbreakingSpace() ), actionCollection(),
"nonbreaking_space" );
1274 new TDEAction( i18n(
"Insert Non-Breaking Hyphen" ), TQt::CTRL+TQt::SHIFT+TQt::Key_Minus,
1275 this, TQ_SLOT( slotNonbreakingHyphen() ), actionCollection(),
"nonbreaking_hyphen" );
1276 new TDEAction( i18n(
"Insert Soft Hyphen" ), TQt::CTRL+TQt::Key_Minus,
1277 this, TQ_SLOT( slotSoftHyphen() ), actionCollection(),
"soft_hyphen" );
1278 new TDEAction( i18n(
"Line Break" ), TQt::SHIFT+TQt::Key_Return,
1279 this, TQ_SLOT( slotLineBreak() ), actionCollection(),
"line_break" );
1281 new TDEAction( i18n(
"Completion" ), TDEStdAccel::shortcut(TDEStdAccel::TextCompletion),
this, TQ_SLOT( slotCompletion() ), actionCollection(),
"completion" );
1283 new TDEAction( i18n(
"Increase Numbering Level" ), TQt::ALT+TQt::Key_Right,
1284 this, TQ_SLOT( slotIncreaseNumberingLevel() ), actionCollection(),
"increase_numbering_level" );
1285 new TDEAction( i18n(
"Decrease Numbering Level" ), TQt::ALT+TQt::Key_Left,
1286 this, TQ_SLOT( slotDecreaseNumberingLevel() ), actionCollection(),
"decrease_numbering_level" );
1290 m_actionEditCustomVars =
new TDEAction( i18n(
"Edit Variable..." ), 0,
1291 this, TQ_SLOT( editCustomVariable() ),
1292 actionCollection(),
"edit_customvars" );
1293 m_actionApplyAutoFormat=
new TDEAction( i18n(
"Apply Autocorrection" ), 0,
1294 this, TQ_SLOT( applyAutoFormat() ),
1295 actionCollection(),
"apply_autoformat" );
1296 m_actionApplyAutoFormat->setToolTip( i18n(
"Manually force KWord to scan the entire document and apply autocorrection." ) );
1297 m_actionApplyAutoFormat->setWhatsThis( i18n(
"Manually force KWord to scan the entire document and apply autocorrection." ) );
1299 m_actionCreateStyleFromSelection =
new TDEAction( i18n(
"Create Style From Selection..." ), 0,
1300 this, TQ_SLOT( createStyleFromSelection()),
1301 actionCollection(),
"create_style" );
1302 m_actionCreateStyleFromSelection->setToolTip( i18n(
"Create a new style based on the currently selected text." ) );
1303 m_actionCreateStyleFromSelection->setWhatsThis( i18n(
"Create a new style based on the currently selected text." ) );
1305 m_actionConfigureFootEndNote =
new TDEAction( i18n(
"&Footnote..." ), 0,
1306 this, TQ_SLOT( configureFootEndNote()),
1307 actionCollection(),
"format_footendnote" );
1308 m_actionConfigureFootEndNote->setToolTip( i18n(
"Change the look of footnotes." ) );
1309 m_actionConfigureFootEndNote->setWhatsThis( i18n(
"Change the look of footnotes." ) );
1311 m_actionEditFootEndNote=
new TDEAction( i18n(
"Edit Footnote"), 0,
1312 this, TQ_SLOT( editFootEndNote()),
1313 actionCollection(),
"edit_footendnote" );
1314 m_actionEditFootEndNote->setToolTip( i18n(
"Change the content of the currently selected footnote." ) );
1315 m_actionEditFootEndNote->setWhatsThis( i18n(
"Change the content of the currently selected footnote." ) );
1318 m_actionChangeFootNoteType =
new TDEAction( i18n(
"Change Footnote/Endnote Parameter"), 0,
1319 this, TQ_SLOT( changeFootNoteType() ),
1320 actionCollection(),
"change_footendtype");
1322 m_actionSavePicture=
new TDEAction( i18n(
"Save Picture As..."), 0,
1323 this, TQ_SLOT( savePicture() ),
1324 actionCollection(),
"save_picture");
1325 m_actionSavePicture->setToolTip( i18n(
"Save the picture in a separate file." ) );
1326 m_actionSavePicture->setWhatsThis( i18n(
"Save the picture in the currently selected frame in a separate file, outside the KWord document." ) );
1328 m_actionAllowBgSpellCheck =
new TDEToggleAction( i18n(
"Autospellcheck" ), 0,
1329 this, TQ_SLOT( autoSpellCheck() ),
1330 actionCollection(),
"tool_auto_spellcheck" );
1333 m_actionGoToFootEndNote =
new TDEAction( TQString() , 0,
1334 this, TQ_SLOT( goToFootEndNote() ),
1335 actionCollection(),
"goto_footendnote" );
1338 m_actionDocStructEdit =
new TDEAction( i18n(
"Edit Text" ), 0,
1339 this, TQ_SLOT( docStructEdit() ),
1340 actionCollection(),
"docstruct_edit" );
1341 m_actionDocStructSpeak =
new TDEAction( i18n(
"Speak Text" ), 0,
1342 this, TQ_SLOT( docStructSpeak() ),
1343 actionCollection(),
"docstruct_speak" );
1344 m_actionDocStructSelect =
new TDEAction( i18n(
"Show" ), 0,
1345 this, TQ_SLOT( docStructSelect() ),
1346 actionCollection(),
"docstruct_select" );
1347 m_actionDocStructDelete =
new TDEAction( i18n(
"Delete Frame" ), 0,
1348 this, TQ_SLOT( docStructDelete() ),
1349 actionCollection(),
"docstruct_delete" );
1350 m_actionDocStructProperties =
new TDEAction( i18n(
"Properties" ), 0,
1351 this, TQ_SLOT( docStructProperties() ),
1352 actionCollection(),
"docstruct_properties" );
1354 m_actionAddBookmark=
new TDEAction( i18n(
"&Bookmark..." ), 0,
1355 this, TQ_SLOT( addBookmark() ),
1356 actionCollection(),
"add_bookmark" );
1357 m_actionSelectBookmark=
new TDEAction( i18n(
"Select &Bookmark..." ), 0,
1358 this, TQ_SLOT( selectBookmark() ),
1359 actionCollection(),
"select_bookmark" );
1361 m_actionImportStyle=
new TDEAction( i18n(
"Import Styles..." ), 0,
1362 this, TQ_SLOT( importStyle() ),
1363 actionCollection(),
"import_style" );
1365 m_actionCreateFrameStyle =
new TDEAction( i18n(
"&Create Framestyle From Frame..." ), 0,
1366 this, TQ_SLOT( createFrameStyle()),
1367 actionCollection(),
"create_framestyle" );
1368 m_actionCreateFrameStyle->setToolTip( i18n(
"Create a new style based on the currently selected frame." ) );
1369 m_actionCreateFrameStyle->setWhatsThis( i18n(
"Create a new framestyle based on the currently selected frame." ) );
1372 m_actionInsertDirectCursor =
new TDEToggleAction( i18n(
"Type Anywhere Cursor" ), 0,
1373 this, TQ_SLOT( insertDirectCursor() ),
1374 actionCollection(),
"direct_cursor" );
1377 m_actionConvertToTextBox =
new TDEAction( i18n(
"Convert to Text Box" ), 0,
1378 this, TQ_SLOT( convertToTextBox() ),
1379 actionCollection(),
"convert_to_text_box" );
1382 m_actionSpellIgnoreAll =
new TDEAction( i18n(
"Ignore All" ), 0,
1383 this, TQ_SLOT( slotAddIgnoreAllWord() ),
1384 actionCollection(),
"ignore_all" );
1386 m_actionAddWordToPersonalDictionary=
new TDEAction( i18n(
"Add Word to Dictionary" ),0,
1387 this, TQ_SLOT( addWordToDictionary() ),
1388 actionCollection(),
"add_word_to_dictionary" );
1390 m_actionEmbeddedStoreInternal=
new TDEToggleAction( i18n(
"Store Document Internally" ),0,
1391 this, TQ_SLOT( embeddedStoreInternal() ),
1392 actionCollection(),
"embedded_store_internal" );
1394 m_actionGoToDocumentStructure=
new TDEAction( i18n(
"Go to Document Structure" ), TDEShortcut(
"Alt+1"),
1395 this, TQ_SLOT( goToDocumentStructure() ),
1396 actionCollection(),
"goto_document_structure" );
1397 m_actionGoToDocument=
new TDEAction( i18n(
"Go to Document" ), TDEShortcut(
"Alt+2"),
1398 this, TQ_SLOT( goToDocument() ),
1399 actionCollection(),
"goto_document" );
1404 m_tableActionList.append(
new TDEActionSeparator(actionCollection()) );
1405 m_tableActionList.append( m_actionTableInsertRow );
1406 m_tableActionList.append( m_actionTableDelRow );
1407 m_tableActionList.append( m_actionTableInsertCol );
1408 m_tableActionList.append( m_actionTableDelCol );
1411void KWView::refreshMenuExpression()
1413 loadexpressionActions( m_actionInsertExpression);
1416void KWView::updateGridButton()
1418 m_actionViewShowGrid->setChecked( m_doc->showGrid() );
1419 m_actionViewSnapToGrid->setChecked ( m_doc->snapToGrid() );
1422void KWView::loadexpressionActions( TDEActionMenu * parentMenu)
1424 TDEActionPtrList lst = actionCollection()->actions(
"expression-action");
1425 TQValueList<TDEAction *> actions = lst;
1426 TQValueList<TDEAction *>::ConstIterator it = lst.begin();
1427 TQValueList<TDEAction *>::ConstIterator end = lst.end();
1429 TQMap<TQString, TDEShortcut> personalShortCuts;
1430 for (; it != end; ++it )
1432 personalShortCuts.insert( (*it)->text(), (*it)->shortcut() );
1436 parentMenu->popupMenu()->clear();
1437 TQStringList path = m_doc->personalExpressionPath();
1439 for ( TQStringList::Iterator it = path.begin(); it != path.end(); ++it )
1444 TQStringList tmp = dir.entryList(
"*.xml");
1445 for ( TQStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2 )
1446 files.append( TQString( (*it) + (*it2) ));
1453 for( TQStringList::Iterator it = files.begin(); it != files.end(); ++it,nbFile++ )
1454 createExpressionActions( parentMenu,*it, i,(nbFile<(
int)files.count()-1), personalShortCuts );
1457void KWView::createExpressionActions( TDEActionMenu * parentMenu,
const TQString& filename,
int &i,
bool insertSepar,
const TQMap<TQString, TDEShortcut>& personalShortCut )
1459 TQFile file( filename );
1460 if ( !file.exists() || !file.open( IO_ReadOnly ) )
1464 doc.setContent( &file );
1467 bool expressionExist =
false;
1468 TQDomNode n = doc.documentElement().firstChild();
1469 for( ; !n.isNull(); n = n.nextSibling() )
1471 if ( n.isElement() )
1473 TQDomElement e = n.toElement();
1474 if ( e.tagName() ==
"Type" )
1476 expressionExist =
true;
1477 TQString group = i18n( e.namedItem(
"TypeName" ).toElement().text().utf8() );
1478 TDEActionMenu * subMenu =
new TDEActionMenu( group, actionCollection() );
1479 parentMenu->insert( subMenu );
1481 TQDomNode n2 = e.firstChild();
1482 for( ; !n2.isNull(); n2 = n2.nextSibling() )
1485 if ( n2.isElement() )
1487 TQDomElement e2 = n2.toElement();
1488 if ( e2.tagName() ==
"Expression" )
1490 TQString text = i18n( e2.namedItem(
"Text" ).toElement().text().utf8() );
1491 TDEAction * act =
new TDEAction( text, 0,
this, TQ_SLOT( insertExpression() ),
1493 TQString(
"expression-action_%1").arg(i).latin1() );
1494 if ( personalShortCut.contains(text) )
1495 act->setShortcut( personalShortCut[text] );
1497 act->setGroup(
"expression-action");
1498 subMenu->insert( act );
1505 if(expressionExist && insertSepar)
1506 parentMenu->popupMenu()->insertSeparator();
1509void KWView::insertExpression()
1511 KWTextFrameSetEdit * edit = currentTextEdit();
1514 TDEAction * act = (TDEAction *)(sender());
1515 edit->insertExpression(act->text());
1520void KWView::addVariableActions(
int type,
const TQStringList & texts,
1521 TDEActionMenu * parentMenu,
const TQString & menuText )
1525 if ( texts.count() > 1 && !menuText.isEmpty() )
1527 TDEActionMenu * subMenu =
new TDEActionMenu( menuText, actionCollection() );
1528 parentMenu->insert( subMenu );
1529 parentMenu = subMenu;
1531 TQStringList::ConstIterator it = texts.begin();
1532 for (
int i = 0; it != texts.end() ; ++it, ++i )
1534 if ( !(*it).isEmpty() )
1539 TQCString actionName;
1540 actionName.sprintf(
"var-action-%d-%d", type, i );
1541 TDEAction * act =
new TDEAction( (*it), 0,
this, TQ_SLOT( insertVariable() ),
1542 actionCollection(), actionName );
1544 act->setToolTip( i18n(
"Insert variable \"%1\" into the text" ).arg( *it ) );
1545 m_variableDefMap.insert( act, v );
1546 parentMenu->insert( act );
1551void KWView::refreshCustomMenu()
1553 TDEActionPtrList lst2 = actionCollection()->actions(
"custom-variable-action");
1554 TQValueList<TDEAction *> actions = lst2;
1555 TQValueList<TDEAction *>::ConstIterator it2 = lst2.begin();
1556 TQValueList<TDEAction *>::ConstIterator end = lst2.end();
1557 TQMap<TQString, TDEShortcut> shortCuts;
1559 for (; it2 != end; ++it2 )
1561 shortCuts.insert((*it2)->text(), (*it2)->shortcut());
1565 delete m_actionInsertCustom;
1566 m_actionInsertCustom =
new TDEActionMenu( i18n(
"&Custom" ),
1567 actionCollection(),
"insert_custom" );
1568 actionInsertVariable->insert(m_actionInsertCustom, 0);
1570 m_actionInsertCustom->popupMenu()->clear();
1571 TQPtrListIterator<KoVariable> it( m_doc->variableCollection()->getVariables() );
1576 for ( ; it.current() ; ++it )
1578 KoVariable *var = it.current();
1579 if ( var->type() == VT_CUSTOM )
1581 varName=( (KoCustomVariable*) var )->name();
1582 if ( !lst.contains( varName) )
1584 lst.append( varName );
1585 TQCString name = TQString(
"custom-action_%1").arg(i).latin1();
1586 act =
new TDEAction( varName, shortCuts[varName],
this, TQ_SLOT( insertCustomVariable() ),actionCollection(), name );
1587 act->setGroup(
"custom-variable-action" );
1588 m_actionInsertCustom->insert( act );
1593 bool state=!lst.isEmpty();
1595 m_actionInsertCustom->popupMenu()->insertSeparator();
1597 act =
new TDEAction( i18n(
"New..."), 0,
this, TQ_SLOT( insertNewCustomVariable() ), actionCollection(),TQString(
"custom-action_%1").arg(i).latin1());
1598 act->setGroup(
"custom-variable-action" );
1601 m_actionEditCustomVarsEdit->setEnabled( state );
1603 m_actionInsertCustom->insert( act );
1608void KWView::insertCustomVariable()
1610 KWTextFrameSetEdit * edit = currentTextEdit();
1613 TDEAction * act = (TDEAction *)(sender());
1614 edit->insertCustomVariable(act->text());
1618void KWView::insertNewCustomVariable()
1620 KWTextFrameSetEdit * edit = currentTextEdit();
1622 edit->insertVariable( VT_CUSTOM, 0 );
1625void KWView::showFormulaToolbar(
bool show )
1627 m_doc->formulaDocument()->setEnabled( show );
1628 m_doc->formulaDocumentWrapper()->enableMatrixActions( show );
1629 m_doc->formulaDocumentWrapper()->getSyntaxHighlightingAction()->setEnabled(
true );
1631 shell()->showToolbar(
"formula_toolbar", show );
1634void KWView::updatePageInfo()
1636 if ( m_sbPageLabel )
1638 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
1639 if ( edit && edit->currentFrame() )
1640 m_currentPage = m_doc->pageManager()->page(edit->currentFrame());
1642 KWFrameView *view = frameViewManager()->selectedFrame();
1644 m_currentPage = m_doc->pageManager()->page(view->
frame());
1652 TQString oldText = m_sbPageLabel->text();
1654 if ( viewMode()->hasPages() )
1655 newText =
' ' + i18n(
"Page %1 of %2" ).arg(m_currentPage->pageNumber())
1656 .arg(m_doc->pageCount()) +
' ';
1658 if ( newText != oldText )
1660 m_sbPageLabel->setText( newText );
1663 m_sbPageLabel->repaint();
1669void KWView::numPagesChanged()
1671 docStructChanged(TextFrames);
1673 int pages = m_doc->pageCount();
1674 kdDebug() << pages <<
" " << (m_doc->processingType() == KWDocument::DTP) << endl;
1675 refreshDeletePageAction();
1678void KWView::updateFrameStatusBarItem()
1680 KStatusBar * sb = statusBar();
1681 int nbFrame=frameViewManager()->selectedFrames().count();
1682 if ( m_doc->showStatusBar() && sb && nbFrame > 0 )
1686 KoUnit::Unit unit = m_doc->unit();
1687 TQString unitName = m_doc->unitName();
1688 KWFrame * frame = frameViewManager()->selectedFrames()[0]->frame();
1689 m_sbFramesLabel->setText(
' ' + i18n(
"Statusbar info",
"%1: %2, %3 - %4, %5 (width: %6, height: %7)" )
1691 .arg( KoUnit::toUserStringValue( frame->left(), unit ) )
1692 .arg( KoUnit::toUserStringValue( frame->top() - m_doc->pageManager()->topOfPage(
1693 m_doc->pageManager()->pageNumber(frame->
rect()) ), unit) )
1694 .arg( KoUnit::toUserStringValue( frame->right(), unit ) )
1695 .arg( KoUnit::toUserStringValue( frame->bottom(), unit ) )
1696 .arg( KoUnit::toUserStringValue( frame->width(), unit ) )
1697 .arg( KoUnit::toUserStringValue( frame->height(), unit ) ) );
1699 m_sbFramesLabel->setText(
' ' + i18n(
"%1 frames selected" ).arg( nbFrame ) );
1701 else if ( sb && m_sbFramesLabel )
1702 m_sbFramesLabel->setText( TQString() );
1705void KWView::setTemporaryStatusBarText(
const TQString &text)
1707 if ( statusBar() && m_sbFramesLabel )
1708 m_sbFramesLabel->setText( text );
1711void KWView::clipboardDataChanged()
1713 if ( !m_gui || !m_doc->isReadWrite() )
1715 m_actionEditPaste->setEnabled(
false);
1718 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
1720 if ( edit && !TQApplication::clipboard()->text().isEmpty() )
1722 m_actionEditPaste->setEnabled(
true);
1725 TQMimeSource *data = TQApplication::clipboard()->data();
1726 const int provides = checkClipboard( data );
1727 if ( provides & ( ProvidesImage | ProvidesOasis | ProvidesFormula ) )
1728 m_actionEditPaste->setEnabled(
true );
1732 m_actionEditPaste->setEnabled( edit && ( provides & ProvidesPlainText ) );
1736int KWView::checkClipboard( TQMimeSource *data )
1739 TQValueList<TQCString> formats;
1741 for (
int i=0; (fmt = data->format(i)); i++)
1742 formats.append( TQCString( fmt ) );
1744 if ( TQImageDrag::canDecode( data ) )
1745 provides |= ProvidesImage;
1746 if ( formats.findIndex( KFormula::MimeSource::selectionMimeType() ) != -1 )
1747 provides |= ProvidesFormula;
1748 if ( formats.findIndex(
"text/plain" ) != -1 )
1749 provides |= ProvidesPlainText;
1750 TQCString returnedTypeMime = KoTextObject::providesOasis( data );
1751 if ( !returnedTypeMime.isEmpty() )
1752 provides |= ProvidesOasis;
1758void KWView::setupPrinter( KPrinter &prt )
1764 m_doc->recalcVariables( VT_TIME );
1765 m_doc->recalcVariables( VT_DATE );
1766 m_doc->recalcVariables( VT_STATISTIC );
1768 prt.setPageSelection( KPrinter::ApplicationSide );
1769 prt.setCurrentPage( currentPage() );
1770 prt.setMinMax( m_doc->startPage(), m_doc->lastPage() );
1772 KoPageLayout pgLayout = m_doc->pageLayout();
1774 prt.setPageSize(
static_cast<KPrinter::PageSize
>( KoPageFormat::printerPageSize( pgLayout.format ) ) );
1776 if ( pgLayout.orientation == PG_LANDSCAPE || pgLayout.format == PG_SCREEN )
1777 prt.setOrientation( KPrinter::Landscape );
1779 prt.setOrientation( KPrinter::Portrait );
1782void KWView::print( KPrinter &prt )
1784 bool displayFieldCode = m_doc->variableCollection()->variableSetting()->displayFieldCode();
1785 if ( displayFieldCode )
1787 m_doc->variableCollection()->variableSetting()->setDisplayFieldCode(
false);
1788 m_doc->recalcVariables( VT_ALL );
1792 m_gui->canvasWidget()->setUpdatesEnabled(
false);
1793 m_gui->canvasWidget()->viewport()->setCursor( waitCursor );
1795 prt.setFullPage(
true );
1800 bool doZoom =
false;
1806 int oldZoom = m_doc->zoom();
1809 TQPaintDeviceMetrics metrics( &prt );
1813 int dpiX = doZoom ? 300 : KoGlobal::dpiX();
1814 int dpiY = doZoom ? 300 : KoGlobal::dpiY();
1817 m_doc->setZoomAndResolution( 100, dpiX, dpiY );
1818 m_doc->newZoomAndResolution(
false,
true );
1822 bool serialLetter =
false;
1824 TQPtrList<KoVariable> vars = m_doc->variableCollection()->getVariables();
1826 for ( v = vars.first(); v; v = vars.next() ) {
1827 if ( v->type() == VT_MAILMERGE ) {
1828 serialLetter =
true;
1833 if ( !m_doc->mailMergeDataBase() ) serialLetter=
false;
1836 m_doc->mailMergeDataBase()->refresh(
false);
1837 if (m_doc->mailMergeDataBase()->getNumRecords() == 0 ) serialLetter =
false;
1843 KoPageLayout pgLayout;
1845 KoKWHeaderFooter hf;
1846 m_doc->getPageLayout( pgLayout, cl, hf );
1847 KoPageLayout oldPGLayout = pgLayout;
1849 if ( pgLayout.format == PG_SCREEN )
1853 pgLayout.ptLeft += 25.8;
1854 pgLayout.ptRight += 15.0;
1855 m_doc->setPageLayout( pgLayout, cl, hf,
false );
1859 painter.begin( &prt );
1861 kdDebug(32001) <<
"KWView::print scaling by " << (double)metrics.logicalDpiX() / (double)dpiX
1862 <<
"," << (
double)metrics.logicalDpiY() / (double)dpiY << endl;
1863 painter.scale( (
double)metrics.logicalDpiX() / (
double)dpiX,
1864 (
double)metrics.logicalDpiY() / (
double)dpiY );
1866 bool canceled =
false;
1869#ifdef KW_PASS_PAINTER_TO_TQRT
1872 for ( ; fit.current() ; ++fit )
1873 if ( fit.current()->isVisible() )
1874 paragraphs += fit.current()->paragraphs();
1875 kdDebug() <<
"KWView::print total paragraphs: " << paragraphs << endl;
1878 TQProgressDialog progress( i18n(
"Printing..." ), i18n(
"Cancel" ), paragraphs,
this );
1879 progress.setProgress( 0 );
1880 int processedParags = 0;
1882 for ( ; fit.current() ; ++fit )
1883 if ( fit.current()->isVisible() )
1885 tqApp->processEvents();
1886 if ( progress.wasCancelled() ) {
1891 kdDebug() <<
"KWView::print preparePrinting " << fit.current()->name() << endl;
1892 fit.current()->preparePrinting( &painter, &progress, processedParags );
1898 if ( !serialLetter )
1899 m_gui->canvasWidget()->print( &painter, &prt );
1902 for (
int i = 0; i < m_doc->mailMergeDataBase()->getNumRecords(); ++i ) {
1903 m_doc->setMailMergeRecord( i );
1904 m_doc->variableCollection()->recalcVariables(VT_MAILMERGE);
1905 m_gui->canvasWidget()->print( &painter, &prt );
1906 if ( i < m_doc->mailMergeDataBase()->getNumRecords() - 1 )
1909 m_doc->setMailMergeRecord( -1 );
1913 if ( pgLayout.format == PG_SCREEN )
1914 m_doc->setPageLayout( oldPGLayout, cl, hf,
false );
1916#ifdef KW_PASS_PAINTER_TO_TQRT
1918 for ( ; fit.current() ; ++fit )
1919 if ( fit.current()->isVisible() )
1920 fit.current()->preparePrinting( 0L, 0L, processedParags );
1923 m_doc->setZoomAndResolution( oldZoom, KoGlobal::dpiX(), KoGlobal::dpiY() );
1924 m_doc->newZoomAndResolution(
false,
false );
1925 kdDebug() <<
"KWView::print zoom&res reset" << endl;
1927 m_gui->canvasWidget()->setUpdatesEnabled(
true);
1928 m_gui->canvasWidget()->viewport()->setCursor( ibeamCursor );
1929 m_doc->repaintAllViews();
1931 if ( displayFieldCode )
1933 m_doc->variableCollection()->variableSetting()->setDisplayFieldCode(
true);
1934 m_doc->recalcVariables( VT_ALL );
1937 m_doc->variableCollection()->recalcVariables(VT_MAILMERGE);
1940 m_doc->variableCollection()->variableSetting()->setLastPrintingDate(TQDateTime::currentDateTime());
1941 m_doc->recalcVariables( VT_DATE );
1944void KWView::showFormat(
const KoTextFormat ¤tFormat )
1948 if (m_actionFormatFontFamily->font() != currentFormat.font().family())
1949 m_actionFormatFontFamily->setFont( currentFormat.font().family() );
1950 if (m_actionFormatFontSize->fontSize() != currentFormat.pointSize())
1951 m_actionFormatFontSize->setFontSize( currentFormat.pointSize() );
1952 m_actionFormatBold->setChecked( currentFormat.font().bold());
1953 m_actionFormatItalic->setChecked( currentFormat.font().italic() );
1954 m_actionFormatUnderline->setChecked( currentFormat.underline());
1955 m_actionFormatStrikeOut->setChecked( currentFormat.strikeOut());
1956 TQColor col=currentFormat.textBackgroundColor();
1958 m_actionBackgroundColor->setCurrentColor( col.isValid() ? col : TQApplication::palette().color( TQPalette::Active, TQColorGroup::Base ));
1960 if ( m_gui && frameViewManager()->selectedFrames().count() > 0)
1961 m_actionBackgroundColor->setText(i18n(
"Frame Background Color..."));
1963 m_actionBackgroundColor->setText(i18n(
"Text Background Color..."));
1964 switch(currentFormat.vAlign())
1966 case KoTextFormat::AlignSuperScript:
1968 m_actionFormatSub->setChecked(
false );
1969 m_actionFormatSuper->setChecked(
true );
1972 case KoTextFormat::AlignSubScript:
1974 m_actionFormatSub->setChecked(
true );
1975 m_actionFormatSuper->setChecked(
false );
1978 case KoTextFormat::AlignNormal:
1981 m_actionFormatSub->setChecked(
false );
1982 m_actionFormatSuper->setChecked(
false );
1989void KWView::showRulerIndent(
double leftMargin,
double firstLine,
double rightMargin,
bool rtl )
1991 KoRuler * hRuler = m_gui ? m_gui->getHorzRuler() : 0;
1994 hRuler->setFirstIndent( KoUnit::toUserValue( firstLine, m_doc->unit() ) );
1995 hRuler->setLeftIndent( KoUnit::toUserValue( leftMargin, m_doc->unit() ) );
1996 hRuler->setRightIndent( KoUnit::toUserValue( rightMargin, m_doc->unit() ) );
1997 hRuler->setDirection( rtl );
1998 m_actionFormatDecreaseIndent->setEnabled( leftMargin>0);
2002void KWView::showAlign(
int align ) {
2004 case TQt::AlignAuto:
2005 kdWarning() << k_funcinfo <<
"shouldn't be called with AlignAuto" << endl;
2007 case TQt::AlignLeft:
2008 m_actionFormatAlignLeft->setChecked(
true );
2010 case TQt::AlignHCenter:
2011 m_actionFormatAlignCenter->setChecked(
true );
2013 case TQt::AlignRight:
2014 m_actionFormatAlignRight->setChecked(
true );
2016 case TQt::AlignJustify:
2017 m_actionFormatAlignBlock->setChecked(
true );
2022void KWView::showSpacing(
int spacing ) {
2025 case KoParagLayout::LS_SINGLE:
2026 m_actionFormatSpacingSingle->setChecked(
true );
2028 case KoParagLayout::LS_ONEANDHALF:
2029 m_actionFormatSpacingOneAndHalf->setChecked(
true );
2031 case KoParagLayout::LS_DOUBLE:
2032 m_actionFormatSpacingDouble->setChecked(
true );
2035 m_actionFormatSpacingSingle->setChecked(
false );
2036 m_actionFormatSpacingOneAndHalf->setChecked(
false );
2037 m_actionFormatSpacingDouble->setChecked(
false );
2041void KWView::showCounter( KoParagCounter &c )
2043 TQString styleStr(
"counterstyle_");
2044 styleStr += TQString::number( c.style() );
2046 TDEToggleAction* act =
static_cast<TDEToggleAction *
>( actionCollection()->action( styleStr.latin1() ) );
2049 act->setChecked(
true );
2052void KWView::updateBorderButtons(
const KoBorder& left,
const KoBorder& right,
2053 const KoBorder& top,
const KoBorder& bottom )
2055 m_actionBorderLeft->setChecked( left.penWidth() > 0 );
2056 m_actionBorderRight->setChecked( right.penWidth() > 0 );
2057 m_actionBorderTop->setChecked( top.penWidth() > 0 );
2058 m_actionBorderBottom->setChecked( bottom.penWidth() > 0 );
2059 m_actionBorderOutline->setChecked(
2060 m_actionBorderLeft->isChecked() &&
2061 m_actionBorderRight->isChecked() &&
2062 m_actionBorderTop->isChecked() &&
2063 m_actionBorderBottom->isChecked());
2065 KoBorder border = left;
2066 if(left.penWidth() > 0)
2068 else if(right.penWidth() > 0)
2070 else if(top.penWidth() > 0)
2072 else if(bottom.penWidth() > 0)
2077 m_actionBorderWidth->setCurrentItem( (
int)border.penWidth() - 1 );
2078 m_actionBorderStyle->setCurrentItem( (
int)border.getStyle() );
2079 m_actionBorderColor->setCurrentColor( border.color );
2082void KWView::updateReadWrite(
bool readwrite )
2085 TQValueList<TDEAction*> actions = actionCollection()->actions();
2087 actions += m_doc->actionCollection()->actions();
2088 TQValueList<TDEAction*>::ConstIterator aIt = actions.begin();
2089 TQValueList<TDEAction*>::ConstIterator aEnd = actions.end();
2090 for (; aIt != aEnd; ++aIt )
2091 (*aIt)->setEnabled( readwrite );
2096 m_actionFileStatistics->setEnabled(
true );
2097 m_actionExtraCreateTemplate->setEnabled(
true );
2098 m_actionViewPageMode->setEnabled(
true );
2099 m_actionViewPreviewMode->setEnabled(
true );
2101 m_actionViewTextMode->setEnabled(
true );
2102 m_actionShowRuler->setEnabled(
true );
2103 m_actionEditFind->setEnabled(
true );
2104 m_actionViewFormattingChars->setEnabled(
true );
2105 m_actionViewFrameBorders->setEnabled(
true );
2109 m_actionViewZoom->setEnabled(
true );
2110 m_actionInsertComment->setEnabled(
true );
2111 m_actionAllowAutoFormat->setEnabled(
true );
2112 m_actionShowDocStruct->setEnabled(
true );
2113 m_actionConfigureCompletion->setEnabled(
true );
2114 m_actionFormatBullet->setEnabled(
true);
2115 m_actionFormatNumber->setEnabled(
true);
2116 m_actionSelectBookmark->setEnabled(
true );
2117 TDEAction* act = actionCollection()->action(
"edit_sldatabase");
2119 act->setEnabled(
true );
2129 frameSelectedChanged();
2130 slotFrameSetEditChanged();
2131 refreshCustomMenu();
2132 refreshDeletePageAction();
2134 m_doc->commandHistory()->updateActions();
2138void KWView::refreshDeletePageAction()
2140 m_actionDeletePage->setEnabled( m_doc->pageCount() > 1 && m_doc->processingType() == KWDocument::DTP );
2143void KWView::showMouseMode(
int mouseMode )
2145 switch ( mouseMode ) {
2146 case KWCanvas::MM_EDIT:
2147 case KWCanvas::MM_CREATE_TABLE:
2148 case KWCanvas::MM_CREATE_FORMULA:
2149 case KWCanvas::MM_CREATE_PART:
2151 m_actionToolsCreateText->setChecked(
false );
2152 m_actionToolsCreatePix->setChecked(
false );
2155 case KWCanvas::MM_CREATE_TEXT:
2156 m_actionToolsCreateText->setChecked(
true );
2158 case KWCanvas::MM_CREATE_PIX:
2159 m_actionToolsCreatePix->setChecked(
true );
2166 m_actionTableJoinCells->setEnabled(
false );
2167 m_actionTableSplitCells->setEnabled(
false );
2168 m_actionTableProtectCells->setEnabled(
false );
2169 m_actionFormatFrameSet->setEnabled(
false);
2170 m_actionTablePropertiesMenu->setEnabled(
false );
2171 m_actionConvertTableToText->setEnabled(
false );
2174void KWView::showStyle(
const TQString & styleName )
2176 KoParagStyle* style = m_doc->styleCollection()->findStyle( styleName );
2178 int pos = m_doc->styleCollection()->indexOf( style );
2180 m_actionFormatStyle->setCurrentItem( pos );
2182 TDEToggleAction* act =
dynamic_cast<TDEToggleAction *
>(actionCollection()->action(style->name().utf8().data()));
2184 act->setChecked(
true );
2189static const char* PARAGSTYLE_ACTION_PREFIX =
"paragstyle_";
2190static const char* FRAMESTYLE_ACTION_PREFIX =
"framestyle_";
2191static const char* TABLESTYLE_ACTION_PREFIX =
"tablestyle_";
2193void KWView::updateStyleList()
2195 TQString currentStyle = m_actionFormatStyle->currentText();
2197 const TQStringList lst = m_doc->styleCollection()->displayNameList();
2198 const int pos = lst.findIndex( currentStyle );
2200 m_actionFormatStyle->setItems( lst );
2202 m_actionFormatStyle->setCurrentItem( pos );
2206 TQStringList lstWithAccels;
2208 TDEAccelGen::generate( lst, lstWithAccels );
2209 TQMap<TQString, TDEShortcut> shortCuts;
2211 TDEActionPtrList lst2 = actionCollection()->actions(
"styleList");
2212 TQValueList<TDEAction *> actions = lst2;
2213 TQValueList<TDEAction *>::ConstIterator it = lst2.begin();
2214 const TQValueList<TDEAction *>::ConstIterator end = lst2.end();
2215 for (; it != end; ++it )
2217 shortCuts.insert( TQString::fromUtf8( (*it)->name() ), (*it)->shortcut() );
2218 m_actionFormatStyleMenu->remove( *it );
2222 for ( TQStringList::Iterator it = lstWithAccels.begin(); it != lstWithAccels.end(); ++it, ++i )
2225 KoParagStyle *style = m_doc->styleCollection()->styleAt( i );
2228 TQString name = PARAGSTYLE_ACTION_PREFIX + style->name();
2229 TDEToggleAction* act =
new TDEToggleAction( (*it),
2230 shortCuts[name],
this, TQ_SLOT( slotStyleSelected() ),
2231 actionCollection(), name.utf8() );
2232 act->setGroup(
"styleList" );
2233 act->setExclusiveGroup(
"styleListAction" );
2234 act->setToolTip( i18n(
"Apply a paragraph style" ) );
2235 m_actionFormatStyleMenu->insert( act );
2238 kdWarning() <<
"No style found for " << *it << endl;
2243void KWView::slotStyleSelected()
2245 TQString actionName = TQString::fromUtf8(sender()->name());
2246 const TQString prefix = PARAGSTYLE_ACTION_PREFIX;
2247 if ( actionName.startsWith( prefix ) ) {
2248 actionName = actionName.mid( prefix.length() );
2249 kdDebug(32001) <<
"KWView::slotStyleSelected " << actionName << endl;
2250 textStyleSelected( m_doc->styleCollection()->findStyle( actionName ) );
2254void KWView::updateFrameStyleList()
2258 const TQString currentStyle = m_actionFrameStyle->currentText();
2260 const TQStringList lst = m_doc->frameStyleCollection()->displayNameList();
2261 const int pos = lst.findIndex( currentStyle );
2263 m_actionFrameStyle->setItems( lst );
2265 m_actionFrameStyle->setCurrentItem( pos );
2269 TQStringList lstWithAccels;
2271 TDEAccelGen::generate( lst, lstWithAccels );
2272 TQMap<TQString, TDEShortcut> shortCuts;
2275 TDEActionPtrList lst2 = actionCollection()->actions(
"frameStyleList");
2276 TQValueList<TDEAction *> actions = lst2;
2277 TQValueList<TDEAction *>::ConstIterator it = lst2.begin();
2278 TQValueList<TDEAction *>::ConstIterator end = lst2.end();
2279 for (; it != end; ++it )
2281 shortCuts.insert( TQString::fromUtf8( (*it)->name() ), (*it)->shortcut() );
2282 m_actionFrameStyleMenu->remove( *it );
2287 for ( TQStringList::Iterator it = lstWithAccels.begin(); it != lstWithAccels.end(); ++it, ++i )
2290 KWFrameStyle *style = m_doc->frameStyleCollection()->frameStyleAt( i );
2293 TQString name = FRAMESTYLE_ACTION_PREFIX + style->name();
2294 TDEToggleAction* act =
new TDEToggleAction( (*it),
2296 this, TQ_SLOT( slotFrameStyleSelected() ),
2297 actionCollection(), name.utf8() );
2298 act->setGroup(
"frameStyleList" );
2299 act->setExclusiveGroup(
"frameStyleList" );
2300 act->setToolTip( i18n(
"Apply a frame style" ) );
2301 m_actionFrameStyleMenu->insert( act );
2304 kdWarning() <<
"No frame style found for " << *it << endl;
2309void KWView::updateTableStyleList()
2311 const TQString currentStyle = m_actionTableStyle->currentText();
2313 const TQStringList lst = m_doc->tableStyleCollection()->displayNameList();
2314 const int pos = lst.findIndex( currentStyle );
2316 m_actionTableStyle->setItems( lst );
2318 m_actionTableStyle->setCurrentItem( pos );
2322 TQStringList lstWithAccels;
2324 TDEAccelGen::generate( lst, lstWithAccels );
2325 TQMap<TQString, TDEShortcut> shortCuts;
2327 TQValueList<TDEAction *> actions = actionCollection()->actions(
"tableStyleList");
2328 TQValueList<TDEAction *>::ConstIterator it = actions.begin();
2329 const TQValueList<TDEAction *>::ConstIterator end = actions.end();
2330 for (; it != end; ++it )
2332 shortCuts.insert( TQString::fromUtf8( (*it)->name() ), (*it)->shortcut() );
2333 m_actionTableStyleMenu->remove( *it );
2338 for ( TQStringList::Iterator it = lstWithAccels.begin(); it != lstWithAccels.end(); ++it, ++i )
2341 KWTableStyle *style = m_doc->tableStyleCollection()->tableStyleAt( i );
2344 TQString name = TABLESTYLE_ACTION_PREFIX + style->name();
2345 TDEToggleAction* act =
new TDEToggleAction( (*it),
2346 shortCuts[name],
this, TQ_SLOT( slotTableStyleSelected() ),
2347 actionCollection(), name.utf8() );
2348 act->setExclusiveGroup(
"tableStyleList" );
2349 act->setGroup(
"tableStyleList" );
2350 act->setToolTip( i18n(
"Apply a table style" ) );
2351 m_actionTableStyleMenu->insert( act );
2354 kdWarning() <<
"No table style found for " << *it << endl;
2358void KWView::editCut()
2360 KWFrameSetEdit * edit = currentTextEdit();
2364 TQDragObject *drag = m_doc->dragSelected( frameViewManager()->selectedFrames() );
2365 TQApplication::clipboard()->setData( drag );
2370void KWView::editCopy()
2372 KWTextFrameSetEdit * edit = currentTextEdit();
2376 TQDragObject *drag = m_doc->dragSelected( frameViewManager()->selectedFrames() );
2377 TQApplication::clipboard()->setData( drag );
2381void KWView::editPaste()
2383 TQMimeSource *data = TQApplication::clipboard()->data();
2384 pasteData( data,
false );
2388void KWView::pasteData( TQMimeSource* data,
bool drop )
2390 int provides = checkClipboard( data );
2391 Q_ASSERT( provides != 0 );
2394 if ( provides & ProvidesFormula ) {
2395 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
2396 if ( edit && edit->frameSet()->
type() == FT_FORMULA ) {
2397 edit->pasteData( data, ProvidesFormula, drop );
2400 insertFormula( data );
2405 deselectAllFrames();
2407 if ( (provides & ProvidesImage) && (provides & ProvidesPlainText) && !( provides & ProvidesOasis ) )
2410 list.append( i18n(
"Image") );
2411 list.append( i18n(
"Plain text") );
2413 TQString result = KInputDialog::getItem( i18n(
"Paste"), i18n(
"Select paste format:"), list, 0,
false, &ok );
2416 if ( result == list.first() )
2418 provides = ProvidesImage;
2420 provides = ProvidesPlainText;
2423 data = TQApplication::clipboard()->data();
2425 KWTextFrameSetEdit * edit = currentTextEdit();
2426 if ( edit && ( provides & ProvidesPlainText ) ) {
2427 edit->pasteData( data, provides, drop );
2428 }
else if ( provides & ProvidesOasis ) {
2430 TQCString returnedTypeMime = KoTextObject::providesOasis( data );
2431 if ( !returnedTypeMime.isEmpty() )
2433 const TQByteArray arr = data->encodedData( returnedTypeMime );
2434 if( !arr.isEmpty() )
2436 TQBuffer buffer( arr );
2437 KoStore * store = KoStore::createStore( &buffer, KoStore::Read );
2438 KWOasisLoader oasisLoader( m_doc );
2439 TQValueList<KWFrame *> frames = oasisLoader.insertOasisData( store, 0 );
2441 TQValueList<KWFrame *>::ConstIterator it = frames.begin();
2442 KMacroCommand* macroCmd = 0L;
2443 for ( ; it != frames.end() ; ++it )
2446 macroCmd =
new KMacroCommand( i18n(
"Paste" ) );
2448 KWCreateFrameCommand *cmd =
new KWCreateFrameCommand( i18n(
"Paste" ), *it );
2449 macroCmd->addCommand( cmd );
2451 frameViewManager()->view(*it)->setSelected(
true);
2452 (*it)->frameSet()->updateFrames();
2456 m_doc->addCommand( macroCmd );
2463 if ( provides & ProvidesImage )
2465 KoPoint docPoint( m_currentPage->leftMargin(),
2466 m_currentPage->offsetInDocument() + m_currentPage->topMargin());
2467 m_gui->canvasWidget()->pasteImage( data, docPoint );
2472void KWView::editSelectAll()
2474 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
2479void KWView::editSelectAllFrames()
2481 m_gui->canvasWidget()->selectAllFrames(
true );
2484void KWView::editSelectCurrentFrame()
2487 KWFrameSetEdit* edit = m_gui->canvasWidget()->currentFrameSetEdit();
2488 KWFrame* frame = edit->currentFrame();
2490 KWFrameView *view = frameViewManager()->view(frame);
2495void KWView::editFind()
2498 m_searchEntry =
new KoSearchContext();
2499 KWTextFrameSetEdit * edit = currentTextEdit();
2500 bool hasSelection = edit && edit->textFrameSet()->
hasSelection();
2501 bool hasCursor = edit != 0L;
2503 KoSearchDia dialog( m_gui->canvasWidget(),
"find", m_searchEntry, hasSelection, hasCursor );
2504 if ( dialog.exec() == TQDialog::Accepted )
2506 delete m_findReplace;
2507 m_findReplace =
new KWFindReplace( m_gui->canvasWidget(), &dialog, m_gui->canvasWidget()->kWordDocument()->visibleTextObjects(viewMode()), edit);
2512void KWView::editReplace()
2515 m_searchEntry =
new KoSearchContext();
2516 if (!m_replaceEntry)
2517 m_replaceEntry =
new KoSearchContext();
2519 KWTextFrameSetEdit * edit = currentTextEdit();
2520 bool hasSelection = edit && edit->textFrameSet()->
hasSelection();
2521 bool hasCursor = edit != 0L;
2523 KoReplaceDia dialog( m_gui->canvasWidget(),
"replace", m_searchEntry, m_replaceEntry, hasSelection, hasCursor );
2524 if ( dialog.exec() == TQDialog::Accepted )
2526 delete m_findReplace;
2527 m_findReplace =
new KWFindReplace( m_gui->canvasWidget(), &dialog, m_gui->canvasWidget()->kWordDocument()->visibleTextObjects(viewMode()), edit);
2532void KWView::editFindNext()
2534 if ( !m_findReplace )
2539 (void) m_findReplace->findNext();
2542void KWView::editFindPrevious()
2544 if ( !m_findReplace )
2549 (void) m_findReplace->findPrevious();
2552void KWView::adjustZOrderOfSelectedFrames(MoveFrameType moveType) {
2553 KMacroCommand* macroCmd = 0L;
2555 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
2556 if(selectedFrames.count()==0)
return;
2558 KWPage *page = m_doc->pageManager()->page(selectedFrames[0]->frame());
2559 TQPtrList<KWFrame> frames;
2560 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
2561 while(framesIterator != selectedFrames.end()) {
2563 frames.append((*framesIterator)->frame());
2564 KWFrameSet *table = (*framesIterator)->frame()->frameSet()->groupmanager();
2566 for (TQPtrListIterator<KWFrame> cellIt(table->
frameIterator() ); cellIt.current() ; ++cellIt ) {
2567 KWFrame *frame = cellIt.current();
2568 if(page->
rect().contains(*frame) && !frames.contains(frame))
2569 frames.append(frame);
2575 int lowestZOrder=10000;
2576 TQString actionName;
2577 framesIterator = selectedFrames.begin();
2578 while(framesIterator != selectedFrames.end()) {
2579 KWFrame* frame = (*framesIterator)->frame();
2583 newZOrder=raiseFrame(frames,frame);
2584 actionName=i18n(
"Raise Frame");
2587 newZOrder=lowerFrame(frames,frame);
2588 actionName=i18n(
"Lower Frame");
2591 newZOrder=bringToFront(frames,frame);
2592 actionName=i18n(
"Bring to Front");
2595 newZOrder=sendToBack(frames,frame);
2596 actionName=i18n(
"Send to Back");
2600 if ( newZOrder != frame->zOrder() ) {
2601 lowestZOrder=TQMIN(lowestZOrder, newZOrder);
2603 KWFrame* frameCopy = frame->
getCopy();
2605 frame->frameStack()->
update();
2607 KWFramePropertiesCommand* cmd =
new KWFramePropertiesCommand( TQString(), frameCopy, frame);
2609 macroCmd =
new KMacroCommand( actionName );
2610 macroCmd->addCommand(cmd);
2615 cmd =
new KWFramePropertiesCommand( TQString(), frameCopy, frame );
2617 macroCmd =
new KMacroCommand( actionName );
2618 macroCmd->addCommand(cmd);
2625 m_doc->addCommand(macroCmd);
2628 m_doc->updateAllFrames();
2630 m_doc->repaintAllViews();
2633 if(lowestZOrder != 10000 && m_doc->processingType() == KWDocument::WP) {
2634 m_doc->lowerMainFrames( page->
pageNumber(), lowestZOrder );
2639void KWView::increaseAllZOrdersAbove(
int refZOrder,
int pageNum,
const TQPtrList<KWFrame>& frameSelection) {
2640 TQPtrList<KWFrame> framesInPage = m_doc->framesInPage( pageNum,
false );
2641 for ( TQPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
2642 if(frameSelection.contains(frameIt.current()) > 0)
continue;
2643 if(frameIt.current()->zOrder() >= refZOrder) {
2644 frameIt.current()->setZOrder( frameIt.current()->zOrder() + 1 );
2650void KWView::decreaseAllZOrdersUnder(
int refZOrder,
int pageNum,
const TQPtrList<KWFrame>& frameSelection) {
2651 TQPtrList<KWFrame> framesInPage = m_doc->framesInPage( pageNum,
false );
2652 for ( TQPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
2653 if(frameSelection.contains(frameIt.current()) > 0)
continue;
2654 if(frameIt.current()->zOrder() <= refZOrder) {
2655 frameIt.current()->setZOrder( frameIt.current()->zOrder() - 1 );
2660int KWView::raiseFrame(
const TQPtrList<KWFrame>& frameSelection,
const KWFrame *frame) {
2661 int newZOrder = 10000;
2662 TQValueList<int> zorders;
2663 TQPtrList<KWFrame> framesInPage = m_doc->framesInPage( frame->
pageNumber(),
false );
2664 for ( TQPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
2665 if(frameSelection.contains(frameIt.current()) > 0)
continue;
2666 if(! frameIt.current()->intersects(*frame))
continue;
2667 int z = frameIt.current()->zOrder();
2668 if(z > frame->zOrder()) {
2669 newZOrder=TQMIN(newZOrder, z + 1);
2671 zorders.append( z );
2673 if(newZOrder==10000)
return frame->zOrder();
2675 if ( zorders.find( newZOrder ) != zorders.end() )
2676 increaseAllZOrdersAbove( newZOrder, frame->
pageNumber(), frameSelection );
2680int KWView::lowerFrame(
const TQPtrList<KWFrame>& frameSelection,
const KWFrame *frame) {
2681 int newZOrder = -10000;
2682 TQValueList<int> zorders;
2683 TQPtrList<KWFrame> framesInPage = m_doc->framesInPage( frame->
pageNumber(),
false );
2684 for ( TQPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
2685 if(frameSelection.contains(frameIt.current()) > 0)
continue;
2686 if(frameIt.current()->frameSet()->isMainFrameset())
continue;
2687 if(! frameIt.current()->intersects(*frame))
continue;
2688 int z = frameIt.current()->zOrder();
2689 if(z < frame->zOrder()) {
2690 newZOrder=TQMAX(newZOrder, z -1);
2692 zorders.append( z );
2694 if(newZOrder==-10000)
return frame->zOrder();
2696 if ( zorders.find( newZOrder ) != zorders.end() )
2697 decreaseAllZOrdersUnder( newZOrder, frame->
pageNumber(), frameSelection );
2701int KWView::bringToFront(
const TQPtrList<KWFrame>& frameSelection,
const KWFrame *frame) {
2702 int newZOrder = frame->zOrder();
2703 TQPtrList<KWFrame> framesInPage = m_doc->framesInPage( frame->
pageNumber(),
false );
2704 for ( TQPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
2705 if(frameSelection.contains(frameIt.current()) > 0)
continue;
2706 if(! frameIt.current()->intersects(*frame))
continue;
2707 newZOrder=TQMAX(newZOrder, frameIt.current()->zOrder()+1);
2712int KWView::sendToBack(
const TQPtrList<KWFrame>& frameSelection,
const KWFrame *frame) {
2713 int newZOrder = frame->zOrder();
2714 TQPtrList<KWFrame> framesInPage = m_doc->framesInPage( frame->
pageNumber(),
false );
2715 for ( TQPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
2716 if(frameSelection.contains(frameIt.current()) > 0)
continue;
2717 if(frameIt.current()->frameSet()->isMainFrameset())
continue;
2718 if(! frameIt.current()->intersects(*frame))
continue;
2719 newZOrder=TQMIN(newZOrder, frameIt.current()->zOrder()-1);
2724void KWView::editDeleteFrame()
2729void KWView::deleteFrame(
bool warning )
2731 if ( !m_doc->isReadWrite() )
2734 TQValueList<KWFrameView*> frames = frameViewManager()->selectedFrames();
2735 if( frames.count() < 1) {
2736 kdWarning() <<
"KWView::deleteFrame: no frame selected" << endl;
2739 if(frames.count()==1)
2741 KWFrame *theFrame = frames[0]->frame();
2742 KWFrameSet *fs = theFrame->
frameSet();
2744 Q_ASSERT( !fs->isAHeader() );
2745 Q_ASSERT( !fs->isAFooter() );
2746 if ( fs->isMainFrameset() || fs->isAFooter() || fs->isAHeader() || fs->isFootEndNote())
2752 int result = KMessageBox::warningContinueCancel(
2754 i18n(
"You are about to delete a table.\n"
2755 "Doing so will delete all the text in the table.\n"
2756 "Are you sure you want to do that?"),
2757 i18n(
"Delete Table"), KStdGuiItem::del(),
2758 "DeleteTableConfirmation",
2760 if (result != KMessageBox::Continue)
2767 if ( fs->isMainFrameset())
2770 KWTextFrameSet * textfs =
dynamic_cast<KWTextFrameSet *
>(fs);
2775 KoTextDocument * textdoc = textfs->textDocument();
2776 if ( textdoc->length() > 0 )
2778 int result = KMessageBox::warningContinueCancel(
2780 i18n(
"You are about to delete the last Frame of the "
2782 "The contents of this Frameset will not appear "
2784 "Are you sure you want to do that?").arg(fs->
name()),
2785 i18n(
"Delete Frame"), KStdGuiItem::del());
2787 if (result != KMessageBox::Continue)
2790 m_doc->deleteFrame( theFrame );
2798 int result = KMessageBox::warningContinueCancel(
2800 i18n(
"Do you want to delete this frame?"),
2801 i18n(
"Delete Frame"),
2802 KGuiItem(i18n(
"&Delete"),
"edit-delete"),
2803 "DeleteLastFrameConfirmation",
2805 if (result != KMessageBox::Continue)
2808 m_doc->deleteFrame( theFrame );
2815 int result = KMessageBox::warningContinueCancel(
2817 i18n(
"Do you want to delete this frame?"),
2818 i18n(
"Delete Frame"),
2819 KGuiItem(i18n(
"&Delete"),
"edit-delete"),
2820 "DeleteLastFrameConfirmation",
2822 if (result != KMessageBox::Continue)
2826 deleteSelectedFrames();
2830void KWView::createLinkedFrame()
2832 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
2833 if (selectedFrames.count() != 1)
2835 KWFrame* frame = selectedFrames[0]->frame();
2836 KWFrame* newFrame =
new KWFrame(0L, frame->x() + m_gui->getVertRuler()->minimumSizeHint().width(), frame->y() + m_gui->getHorzRuler()->minimumSizeHint().height(), frame->width(), frame->height() );
2838 newFrame->setCopy(
true);
2839 newFrame->setNewFrameBehavior( KWFrame::Copy );
2840 frame->
frameSet()->addFrame( newFrame );
2842 frameViewManager()->view(newFrame)->setSelected(
true);
2844 KWCreateFrameCommand *cmd =
new KWCreateFrameCommand( i18n(
"Create Linked Copy"), newFrame );
2845 m_doc->addCommand( cmd );
2847 m_doc->frameChanged( newFrame );
2850void KWView::editCustomVariable()
2852 KWTextFrameSetEdit * edit = currentTextEdit();
2855 KoCustomVariable *var =
static_cast<KoCustomVariable *
>(edit->variable());
2858 TQString oldvalue = var->value();
2859 KoCustomVarDialog dia(
this, var );
2862 m_doc->recalcVariables( VT_CUSTOM );
2863 if( var->value() != oldvalue )
2865 KWChangeCustomVariableValue *cmd=
new KWChangeCustomVariableValue(i18n(
"Change Custom Variable" ),m_doc, oldvalue, var->value(), var );
2866 m_doc->addCommand(cmd);
2873void KWView::editCustomVars()
2875 KoCustomVariablesDia dia(
this, m_doc->variableCollection()->getVariables() );
2876 TQStringList listOldCustomValue;
2877 TQPtrListIterator<KoVariable> oldIt( m_doc->variableCollection()->getVariables() );
2878 for ( ; oldIt.current() ; ++oldIt )
2880 if(oldIt.current()->type()==VT_CUSTOM)
2881 listOldCustomValue.append(((KoCustomVariable*)oldIt.current())->value());
2885 m_doc->recalcVariables( VT_CUSTOM );
2887 TQPtrListIterator<KoVariable> it( m_doc->variableCollection()->getVariables() );
2888 KMacroCommand * macroCommand = 0L;
2890 for ( ; it.current() ; ++it )
2892 if(it.current()->type() == VT_CUSTOM )
2894 if(((KoCustomVariable*)it.current())->value()!=*(listOldCustomValue.at(i)))
2897 macroCommand =
new KMacroCommand( i18n(
"Change Custom Variable" ) );
2898 KWChangeCustomVariableValue *cmd=
new KWChangeCustomVariableValue(i18n(
"Change Custom Variable" ),m_doc,*(listOldCustomValue.at(i)), ((KoCustomVariable*)it.current())->value() ,((KoCustomVariable*)it.current()));
2899 macroCommand->addCommand(cmd);
2905 m_doc->addCommand(macroCommand);
2909void KWView::editMailMergeDataBase()
2911 m_doc->mailMergeDataBase()->showConfigDialog(
this);
2913 KWMailMergeEditor *dia =
new KWMailMergeEditor(
this, m_doc->mailMergeDataBase() );
2921void KWView::viewTextMode()
2923 if ( m_actionViewTextMode->isChecked() )
2927 if (
dynamic_cast<KWViewModePreview *
>(viewMode()) )
2929 m_zoomViewModePreview.m_zoom = m_doc->zoom();
2930 m_zoomViewModePreview.m_zoomMode = m_doc->zoomMode();
2934 m_zoomViewModeNormal.m_zoom = m_doc->zoom();
2935 m_zoomViewModeNormal.m_zoomMode = m_doc->zoomMode();
2939 switch(m_zoomViewModeNormal.m_zoomMode)
2941 case KoZoomMode::ZOOM_WIDTH:
2942 m_doc->setZoomMode(KoZoomMode::ZOOM_WIDTH);
2943 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
2945 case KoZoomMode::ZOOM_PAGE:
2946 m_zoomViewModeNormal.m_zoomMode = KoZoomMode::ZOOM_CONSTANT;
2947 case KoZoomMode::ZOOM_CONSTANT:
2948 m_doc->setZoomMode(KoZoomMode::ZOOM_CONSTANT);
2949 showZoom( m_zoomViewModeNormal.m_zoom );
2950 setZoom( m_zoomViewModeNormal.m_zoom,
false );
2953 m_doc->switchViewMode(
"ModeText" );
2958 m_actionViewTextMode->setChecked(
true );
2961void KWView::viewPageMode()
2963 if ( m_actionViewPageMode->isChecked() )
2965 if (
dynamic_cast<KWViewModePreview *
>(viewMode()) )
2967 m_zoomViewModePreview.m_zoom = m_doc->zoom();
2968 m_zoomViewModePreview.m_zoomMode = m_doc->zoomMode();
2972 m_zoomViewModeNormal.m_zoom = m_doc->zoom();
2973 m_zoomViewModeNormal.m_zoomMode = m_doc->zoomMode();
2975 switch(m_zoomViewModeNormal.m_zoomMode)
2977 case KoZoomMode::ZOOM_WIDTH:
2978 m_doc->setZoomMode(KoZoomMode::ZOOM_WIDTH);
2979 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
2981 case KoZoomMode::ZOOM_PAGE:
2982 m_doc->setZoomMode(KoZoomMode::ZOOM_PAGE);
2983 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
2985 case KoZoomMode::ZOOM_CONSTANT:
2986 m_doc->setZoomMode(KoZoomMode::ZOOM_CONSTANT);
2987 showZoom( m_zoomViewModeNormal.m_zoom );
2988 setZoom( m_zoomViewModeNormal.m_zoom,
false );
2991 m_doc->switchViewMode(
"ModeNormal" );
2994 m_actionViewPageMode->setChecked(
true );
2997void KWView::viewPreviewMode()
2999 if ( m_actionViewPreviewMode->isChecked() )
3001 m_zoomViewModeNormal.m_zoom = m_doc->zoom();
3002 m_zoomViewModeNormal.m_zoomMode = m_doc->zoomMode();
3003 switch(m_zoomViewModePreview.m_zoomMode)
3005 case KoZoomMode::ZOOM_WIDTH:
3006 m_doc->setZoomMode(KoZoomMode::ZOOM_WIDTH);
3007 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
3009 case KoZoomMode::ZOOM_PAGE:
3010 m_doc->setZoomMode(KoZoomMode::ZOOM_PAGE);
3011 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
3013 case KoZoomMode::ZOOM_CONSTANT:
3014 m_doc->setZoomMode(KoZoomMode::ZOOM_CONSTANT);
3015 showZoom( m_zoomViewModePreview.m_zoom );
3016 setZoom( m_zoomViewModePreview.m_zoom,
false );
3019 m_doc->switchViewMode(
"ModePreview" );
3022 m_actionViewPreviewMode->setChecked(
true );
3025void KWView::updateZoomControls()
3027 switch(m_doc->zoomMode())
3029 case KoZoomMode::ZOOM_WIDTH:
3030 case KoZoomMode::ZOOM_PAGE:
3031 showZoom( KoZoomMode::toString(m_doc->zoomMode()) );
3033 case KoZoomMode::ZOOM_CONSTANT:
3034 changeZoomMenu( m_doc->zoom() );
3035 showZoom( m_doc->zoom() );
3040void KWView::changeZoomMenu(
int zoom )
3043 if ( m_gui && m_gui->canvasWidget() && viewMode())
3044 mode = viewMode()->type();
3047 lst << KoZoomMode::toString(KoZoomMode::ZOOM_WIDTH);
3048 if ( mode!=
"ModeText" )
3049 lst << KoZoomMode::toString(KoZoomMode::ZOOM_PAGE);
3053 TQValueList<int> list;
3055 const TQStringList itemsList ( m_actionViewZoom->items() );
3056 TQRegExp regexp(
"(\\d+)");
3058 for (TQStringList::ConstIterator it = itemsList.begin() ; it != itemsList.end() ; ++it)
3061 const int val=regexp.cap(1).toInt(&ok);
3063 if(ok && val>9 && list.contains(val)==0)
3068 if(list.contains(zoom)==0)
3069 list.append( zoom );
3073 for (TQValueList<int>::Iterator it = list.begin() ; it != list.end() ; ++it)
3074 lst.append( i18n(
"%1%").arg(*it) );
3078 lst << i18n(
"%1%").arg(
"33");
3079 lst << i18n(
"%1%").arg(
"50");
3080 lst << i18n(
"%1%").arg(
"75");
3081 lst << i18n(
"%1%").arg(
"100");
3082 lst << i18n(
"%1%").arg(
"125");
3083 lst << i18n(
"%1%").arg(
"150");
3084 lst << i18n(
"%1%").arg(
"200");
3085 lst << i18n(
"%1%").arg(
"250");
3086 lst << i18n(
"%1%").arg(
"350");
3087 lst << i18n(
"%1%").arg(
"400");
3088 lst << i18n(
"%1%").arg(
"450");
3089 lst << i18n(
"%1%").arg(
"500");
3091 m_actionViewZoom->setItems( lst );
3094void KWView::showZoom(
int zoom )
3096 TQStringList list = m_actionViewZoom->items();
3097 TQString zoomStr( i18n(
"%1%").arg( zoom ) );
3098 m_actionViewZoom->setCurrentItem( list.findIndex(zoomStr) );
3101void KWView::showZoom(
const TQString& zoom )
3103 TQStringList list = m_actionViewZoom->items();
3104 m_actionViewZoom->setCurrentItem( list.findIndex( zoom ) );
3107void KWView::slotViewFormattingChars()
3109 m_doc->setViewFormattingChars(m_actionViewFormattingChars->isChecked());
3111 m_doc->repaintAllViews();
3114void KWView::slotViewFrameBorders()
3116 setViewFrameBorders(m_actionViewFrameBorders->isChecked());
3117 m_gui->canvasWidget()->repaintAll();
3120void KWView::viewHeader()
3122 bool state = m_actionViewHeader->isChecked();
3123 m_doc->setHeaderVisible( state );
3124 KWHideShowHeader *cmd=
new KWHideShowHeader( state ? i18n(
"Enable Document Headers"):i18n(
"Disable Document Headers"), m_doc, state);
3125 m_doc->addCommand(cmd);
3129void KWView::updateHeader()
3131 KWTextFrameSetEdit * edit = currentTextEdit();
3132 bool state = m_actionViewHeader->isChecked();
3135 KWFrameSet *frameSet=0L;
3138 frameSet=edit->frameSet();
3139 if (frameSet->isAHeader())
3140 m_doc->terminateEditing( frameSet );
3147 m_doc->terminateEditing( table );
3154 KWFormulaFrameSetEdit * editFormula =
dynamic_cast<KWFormulaFrameSetEdit *
>(m_gui->canvasWidget()->currentFrameSetEdit());
3157 frameSet= editFormula->frameSet();
3159 m_doc->terminateEditing( frameSet );
3167void KWView::viewFooter()
3169 bool state=m_actionViewFooter->isChecked();
3170 m_doc->setFooterVisible( state );
3171 KWHideShowFooter *cmd=
new KWHideShowFooter( state ? i18n(
"Enable Document Footers"):i18n(
"Disable Document Footers"), m_doc, state);
3172 m_doc->addCommand(cmd);
3176void KWView::updateFooter()
3178 bool state=m_actionViewFooter->isChecked();
3179 KWTextFrameSetEdit * edit = currentTextEdit();
3182 KWFrameSet *frameSet=0L;
3185 frameSet=edit->frameSet();
3186 if (frameSet->isAFooter())
3187 m_doc->terminateEditing( frameSet );
3194 m_doc->terminateEditing( table );
3200 KWFormulaFrameSetEdit * editFormula =
dynamic_cast<KWFormulaFrameSetEdit *
>(m_gui->canvasWidget()->currentFrameSetEdit());
3203 frameSet= editFormula->frameSet();
3205 m_doc->terminateEditing( frameSet );
3214void KWView::updateZoom( ) {
3215 viewZoom(m_actionViewZoom->currentText());
3218void KWView::viewZoom(
const TQString &s )
3221 KWCanvas * canvas = m_gui->canvasWidget();
3224 if ( s == KoZoomMode::toString(KoZoomMode::ZOOM_WIDTH) )
3226 m_doc->setZoomMode(KoZoomMode::ZOOM_WIDTH);
3227 zoom = tqRound(
static_cast<double>(canvas->visibleWidth() * 100 ) / (m_doc->resolutionX() * m_currentPage->width() ) ) - 1;
3229 if(zoom != m_doc->zoom() && !canvas->verticalScrollBar() ||
3230 !canvas->verticalScrollBar()->isVisible()) {
3232 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
3236 else if ( s == KoZoomMode::toString(KoZoomMode::ZOOM_PAGE) )
3238 m_doc->setZoomMode(KoZoomMode::ZOOM_PAGE);
3239 double height = m_doc->resolutionY() * m_currentPage->height();
3240 double width = m_doc->resolutionX() * m_currentPage->width();
3241 zoom = TQMIN( tqRound(
static_cast<double>(canvas->visibleHeight() * 100 ) / height ),
3242 tqRound(
static_cast<double>(canvas->visibleWidth() * 100 ) / width ) ) - 1;
3248 m_doc->setZoomMode(KoZoomMode::ZOOM_CONSTANT);
3249 TQRegExp regexp(
"(\\d+)");
3251 zoom=regexp.cap(1).toInt(&ok);
3254 if( !ok || zoom<10 )
3255 zoom = m_doc->zoom();
3256 if ( !KoZoomMode::isConstant(s) )
3260 changeZoomMenu( zoom );
3265 if( zoom != m_doc->zoom() )
3267 setZoom( zoom,
true );
3269 KWTextFrameSetEdit * edit = currentTextEdit();
3271 edit->ensureCursorVisible();
3274 m_gui->canvasWidget()->setFocus();
3278void KWView::setZoom(
int zoom,
bool updateViews )
3280 m_doc->setZoomAndResolution( zoom, KoGlobal::dpiX(), KoGlobal::dpiY());
3281 m_doc->newZoomAndResolution( updateViews,
false );
3282 m_doc->updateZoomRuler();
3285 m_sbZoomLabel->setText(
' ' + TQString::number( zoom ) +
"% " );
3288 kdDebug() <<
"KWView::setZoom " << zoom <<
" setting koview zoom to " << m_doc->zoomedResolutionY() << endl;
3289 KoView::setZoom( m_doc->zoomedResolutionY() );
3292void KWView::insertPicture()
3294 if ( m_actionToolsCreatePix->isChecked() )
3296 KWInsertPicDia dia(
this,m_gui->canvasWidget()->pictureInline(),m_gui->canvasWidget()->pictureKeepRatio(),m_doc );
3297 if ( dia.exec() == TQDialog::Accepted && !dia.picture().isNull() )
3299 insertPicture( dia.picture(), dia.makeInline(), dia.keepRatio(), 0, 0 );
3300 m_gui->canvasWidget()->setPictureInline( dia.makeInline());
3301 m_gui->canvasWidget()->setPictureKeepRatio( dia.keepRatio() );
3304 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_EDIT );
3309 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_EDIT );
3314void KWView::slotEmbedImage(
const TQString &filename )
3318 key.setKeyFromFile( filename );
3319 picture.setKey( key );
3320 picture.loadFromFile( filename );
3321 insertPicture( picture,
false,
true, 0, 0 );
3324void KWView::insertPicture(
const KoPicture& picture,
const bool makeInline,
const bool keepRatio,
int suggestedWidth,
int suggestedHeight )
3326 TQSize pixmapSize( picture.getOriginalSize() );
3327 if ( suggestedWidth > 0 && suggestedHeight > 0 )
3328 pixmapSize = TQSize( suggestedWidth, suggestedHeight );
3332 const double widthLimit = m_currentPage->width() - m_currentPage->leftMargin() -
3333 m_currentPage->rightMargin() - 10;
3334 const double heightLimit = m_currentPage->height() - m_currentPage->topMargin() -
3335 m_currentPage->bottomMargin() - 10;
3337 KWPictureFrameSet *frameset =
new KWPictureFrameSet( m_doc, TQString() );
3339 frameset->insertPicture( picture );
3343 double width = m_doc->unzoomItX( tqRound( (
double)pixmapSize.width() * m_doc->zoomedResolutionX() / POINT_TO_INCH( KoGlobal::dpiX() ) ) );
3344 double height = m_doc->unzoomItY( tqRound( (
double)pixmapSize.height() * m_doc->zoomedResolutionY() / POINT_TO_INCH( KoGlobal::dpiY() ) ) );
3346 frameset->setKeepAspectRatio( keepRatio);
3349 if ( keepRatio && ((width > widthLimit) || (height > heightLimit)) )
3352 const double ratioX = width / widthLimit;
3353 const double ratioY = height / heightLimit;
3354 const double ratioPicture = width / height;
3356 if ( ratioPicture == 0 )
3359 height = heightLimit;
3362 if ( ratioX > ratioY )
3365 height = widthLimit/ratioPicture;
3369 width = heightLimit*ratioPicture;
3370 height = heightLimit;
3376 width = kMin( width, widthLimit );
3377 height = kMin( height, heightLimit );
3380 m_fsInline = frameset;
3381 KWFrame *frame =
new KWFrame ( m_fsInline, 0, 0, width, height );
3382 m_fsInline->addFrame( frame,
false );
3383 m_gui->canvasWidget()->inlinePictureStarted();
3384 showMouseMode( KWCanvas::MM_EDIT );
3386 displayFrameInlineInfo();
3389 edit->insertFloatingFrameSet( fs, i18n(
"Insert Picture Inline") );
3391 showMouseMode( KWCanvas::MM_EDIT );
3392 m_doc->refreshDocStructure(Pictures);
3397 m_gui->canvasWidget()->insertPicture( picture, pixmapSize, keepRatio );
3401bool KWView::insertInlinePicture()
3403 Q_ASSERT( m_fsInline );
3404 KWTextFrameSetEdit * edit = currentTextEdit();
3407 if ( edit->textFrameSet()->
textObject()->protectContent() )
3410 m_doc->addFrameSet( m_fsInline,
false );
3412 KWFrame *frame =
new KWFrame( m_fsInline, 0, 0, m_doc->unzoomItX( width ), m_doc->unzoomItY( height ) );
3413 m_fsInline->addFrame( frame,
false );
3415 edit->insertFloatingFrameSet( m_fsInline, i18n(
"Insert Picture Inline") );
3416 m_fsInline->finalize();
3417 showMouseMode( KWCanvas::MM_EDIT );
3418 m_doc->refreshDocStructure(Pictures);
3420 updateFrameStatusBarItem();
3426 updateFrameStatusBarItem();
3431void KWView::displayFrameInlineInfo()
3433 KMessageBox::information(
this,
3434 i18n(
"Set cursor where you want to insert inline frame."),
3435 i18n(
"Insert Inline Frame"),
3436 "SetCursorInsertInlineFrame",
true);
3438 if ( statusBar() && m_sbFramesLabel )
3439 m_sbFramesLabel->setText(
' ' + i18n(
"Set cursor where you want to insert inline frame." ) );
3442void KWView::insertSpecialChar()
3444 KWTextFrameSetEdit *edit=currentTextEdit();
3447 TQString f = edit->textFontFamily();
3449 if (m_specialCharDlg==0)
3451 m_specialCharDlg =
new KoCharSelectDia(
this,
"insert special char", f, c,
false );
3452 connect( m_specialCharDlg, TQ_SIGNAL(insertChar(TQChar,
const TQString &)),
3453 this, TQ_SLOT(slotSpecialChar(TQChar,
const TQString &)));
3454 connect( m_specialCharDlg, TQ_SIGNAL( finished() ),
3455 this, TQ_SLOT( slotSpecialCharDlgClosed() ) );
3457 m_specialCharDlg->show();
3460void KWView::slotSpecialCharDlgClosed()
3462 if ( m_specialCharDlg )
3464 disconnect( m_specialCharDlg, TQ_SIGNAL(insertChar(TQChar,
const TQString &)),
3465 this, TQ_SLOT(slotSpecialChar(TQChar,
const TQString &)));
3466 disconnect( m_specialCharDlg, TQ_SIGNAL( finished() ),
3467 this, TQ_SLOT( slotSpecialCharDlgClosed() ) );
3468 m_specialCharDlg->deleteLater();
3469 m_specialCharDlg = 0L;
3473void KWView::slotSpecialChar(TQChar c,
const TQString &font)
3475 KWTextFrameSetEdit *edit=currentTextEdit();
3478 edit->insertSpecialChar(c, font);
3481void KWView::insertFrameBreak()
3483 KWTextFrameSetEdit *edit=currentTextEdit();
3486 edit->insertFrameBreak();
3489void KWView::insertPage()
3491 if ( m_doc->processingType() == KWDocument::WP )
3493 m_gui->canvasWidget()->editFrameSet( m_doc->frameSet(0) );
3494 KWTextFrameSetEdit *edit = currentTextEdit();
3497 edit->insertWPPage();
3499 KWInsertPageDia dlg(
this,
"insertpage");
3504 KCommand* cmd =
new KWInsertRemovePageCommand( m_doc, KWInsertRemovePageCommand::Insert, dlg.insertPagePos()==KW_INSERTPAGEAFTER ? page : (page -1));
3506 m_doc->addCommand( cmd );
3511void KWView::deletePage()
3513 KCommand* cmd =
new KWInsertRemovePageCommand( m_doc, KWInsertRemovePageCommand::Remove, m_currentPage->pageNumber() );
3515 m_doc->addCommand( cmd );
3516 if(m_doc->lastPage() > m_currentPage->pageNumber())
3517 m_currentPage = m_doc->pageManager()->page( m_doc->lastPage() );
3520void KWView::insertLink()
3522 KWTextFrameSetEdit *edit=currentTextEdit();
3529 TQString selectedText = edit->textFrameSet()->
textObject()->selectedText();
3530 if ( edit->textFrameSet()->
textObject()->selectionHasCustomItems() || selectedText.contains(
'\n') )
3532 if ( selectedText.startsWith(
"mailto:/" ) ||
3533 selectedText.startsWith(
"ftp:/" ) ||
3534 selectedText.startsWith(
"http:/" ) )
3542 link = selectedText;
3546 if(KoInsertLinkDia::createLinkDia(link, ref, m_doc->listOfBookmarkName(0),
true,
this))
3548 if(!link.isEmpty() && !ref.isEmpty())
3549 edit->insertLink(link, ref);
3553void KWView::insertComment()
3555 KWTextFrameSetEdit *edit=currentTextEdit();
3558 TQString authorName;
3559 KoDocumentInfo * info = m_doc->documentInfo();
3560 KoDocumentInfoAuthor * authorPage =
static_cast<KoDocumentInfoAuthor *
>(info->page(
"author" ));
3562 kdWarning() <<
"Author information not found in documentInfo !" << endl;
3564 authorName = authorPage->fullName();
3566 KoCommentDia *commentDia =
new KoCommentDia(
this, TQString(),authorName );
3567 if( commentDia->exec() )
3569 edit->insertComment(commentDia->commentText());
3575void KWView::insertVariable()
3577 KWTextFrameSetEdit * edit = currentTextEdit();
3580 TDEAction * act = (TDEAction *)(sender());
3581 VariableDefMap::Iterator it = m_variableDefMap.find( act );
3582 if ( it == m_variableDefMap.end() )
3583 kdWarning() <<
"Action not found in m_variableDefMap." << endl;
3586 if ( (*it).type == VT_FIELD )
3587 edit->insertVariable( (*it).type, KoFieldVariable::fieldSubType( (*it).subtype ) );
3589 edit->insertVariable( (*it).type, (*it).subtype );
3594void KWView::insertFootNote()
3596 KWTextFrameSetEdit * edit = currentTextEdit();
3600 if ( edit->frameSet() != m_doc->frameSet(0) )
3602 KMessageBox::sorry(
this,
3603 i18n(
"You can only insert footnotes or "
3604 "endnotes into the first frameset."),
3605 i18n(
"Insert Footnote"));
3607 KWFootNoteDia dia( m_gui->canvasWidget()->footNoteType(), m_gui->canvasWidget()->numberingFootNoteType(), TQString(),
this, m_doc, 0 );
3608 TQPtrListIterator<KoTextCustomItem> it( edit->textDocument()->allCustomItems() );
3609 for ( ; it.current() ; ++it )
3611 KWFootNoteVariable *fnv =
dynamic_cast<KWFootNoteVariable *
>( it.current() );
3613 fnv->numberingType()==KWFootNoteVariable::Manual )
3614 dia.appendManualFootNote( fnv->text() );
3617 edit->insertFootNote( dia.noteType(), dia.numberingType(), dia.manualString() );
3618 m_gui->canvasWidget()->setFootNoteType( dia.noteType() );
3619 m_gui->canvasWidget()->setNumberingFootNoteType( dia.numberingType() );
3625void KWView::updateTocActionText(
bool hasToc)
3627 TDEActionCollection * coll = actionCollection();
3628 TQString name= hasToc ? i18n(
"Update Table of &Contents"):i18n(
"Table of &Contents");
3629 coll->action(
"insert_contents")->setText(name);
3632void KWView::insertContents()
3634 KWTextFrameSetEdit *edit = currentTextEdit();
3639void KWView::formatFont()
3641 KoTextFormatInterface* textIface = applicableTextInterfaces().first();
3643 if ( !textIface || !textIface->currentFormat() )
3647 m_fontDlg =
new KoFontDia( *textIface->currentFormat()
3651 connect( m_fontDlg, TQ_SIGNAL( applyFont() ),
3652 this, TQ_SLOT( slotApplyFont() ) );
3661void KWView::slotApplyFont()
3663 int flags = m_fontDlg->changedFlags();
3666 KMacroCommand *globalCmd =
new KMacroCommand(i18n(
"Change Font"));
3667 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
3668 TQPtrListIterator<KoTextFormatInterface> it( lst );
3669 for ( ; it.current() ; ++it )
3671 KoTextFormat newFormat = m_fontDlg->newFormat();
3672 KCommand *cmd = it.current()->setFormatCommand( &newFormat, flags,
true);
3674 globalCmd->addCommand(cmd);
3676 m_doc->addCommand(globalCmd);
3677 m_gui->canvasWidget()->setFocus();
3682void KWView::formatParagraph()
3684 showParagraphDialog();
3687void KWView::showParagraphDialog(
int initialPage,
double initialTabPos )
3689 KWTextFrameSetEdit *edit = currentTextEdit();
3693 bool showFrameEndOptions = !edit->frameSet()->isHeaderOrFooter() &&
3695 m_paragDlg =
new KoParagDia(
this,
"",
3696 KoParagDia::PD_SPACING | KoParagDia::PD_ALIGN |
3697 KoParagDia::PD_DECORATION | KoParagDia::PD_NUMBERING |
3698 KoParagDia::PD_TABS,
3700 edit->textFrameSet()->
frame(0)->width(),
3701 showFrameEndOptions,
3702 edit->frameSet()->isFootEndNote());
3703 m_paragDlg->setCaption( i18n(
"Paragraph Settings" ) );
3706 m_paragDlg->setParagLayout( edit->cursor()->parag()->paragLayout() );
3709 if ( initialPage != -1 )
3711 m_paragDlg->setCurrentPage( initialPage );
3712 if ( initialPage == KoParagDia::PD_TABS )
3713 m_paragDlg->tabulatorsWidget()->setCurrentTab( initialTabPos );
3715 connect( m_paragDlg, TQ_SIGNAL( applyParagStyle() ),
this, TQ_SLOT( slotApplyParag()));
3724void KWView::slotApplyParag()
3726 KWTextFrameSetEdit *edit = currentTextEdit();
3729 KMacroCommand * macroCommand = 0L;
3731 if(m_paragDlg->isLeftMarginChanged())
3733 cmd=edit->setMarginCommand( TQStyleSheetItem::MarginLeft, m_paragDlg->leftIndent() );
3736 if ( !macroCommand )
3737 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3738 macroCommand->addCommand(cmd);
3740 m_gui->getHorzRuler()->setLeftIndent( KoUnit::toUserValue( m_paragDlg->leftIndent(), m_doc->unit() ) );
3744 if(m_paragDlg->isRightMarginChanged())
3746 cmd=edit->setMarginCommand( TQStyleSheetItem::MarginRight, m_paragDlg->rightIndent() );
3749 if ( !macroCommand )
3750 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3751 macroCommand->addCommand(cmd);
3753 m_gui->getHorzRuler()->setRightIndent( KoUnit::toUserValue( m_paragDlg->rightIndent(), m_doc->unit() ) );
3755 if(m_paragDlg->isSpaceBeforeChanged())
3757 cmd=edit->setMarginCommand( TQStyleSheetItem::MarginTop, m_paragDlg->spaceBeforeParag() );
3760 if ( !macroCommand )
3761 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3762 macroCommand->addCommand(cmd);
3765 if(m_paragDlg->isSpaceAfterChanged())
3767 cmd=edit->setMarginCommand( TQStyleSheetItem::MarginBottom, m_paragDlg->spaceAfterParag() );
3770 if ( !macroCommand )
3771 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3772 macroCommand->addCommand(cmd);
3775 if(m_paragDlg->isFirstLineChanged())
3777 cmd=edit->setMarginCommand( TQStyleSheetItem::MarginFirstLine, m_paragDlg->firstLineIndent());
3780 if ( !macroCommand )
3781 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3782 macroCommand->addCommand(cmd);
3784 m_gui->getHorzRuler()->setFirstIndent(
3785 KoUnit::toUserValue( m_paragDlg->firstLineIndent(), m_doc->unit() ) );
3788 if(m_paragDlg->isAlignChanged())
3790 cmd=edit->setAlignCommand( m_paragDlg->align() );
3793 if ( !macroCommand )
3794 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3795 macroCommand->addCommand(cmd);
3798 if(m_paragDlg->isCounterChanged())
3800 cmd=edit->setCounterCommand( m_paragDlg->counter() );
3803 if ( !macroCommand )
3804 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3805 macroCommand->addCommand(cmd);
3808 if(m_paragDlg->listTabulatorChanged())
3810 cmd=edit->setTabListCommand( m_paragDlg->tabListTabulator() );
3813 if ( !macroCommand )
3814 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3815 macroCommand->addCommand(cmd);
3819 if(m_paragDlg->isLineSpacingChanged())
3821 cmd=edit->setLineSpacingCommand( m_paragDlg->lineSpacing(),m_paragDlg->lineSpacingType() );
3824 if ( !macroCommand )
3825 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3827 macroCommand->addCommand(cmd);
3830 if(m_paragDlg->isBorderChanged())
3832 cmd=edit->setBordersCommand( m_paragDlg->leftBorder(),
3833 m_paragDlg->rightBorder(),
3834 m_paragDlg->topBorder(),
3835 m_paragDlg->bottomBorder() );
3838 if ( !macroCommand )
3839 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3841 macroCommand->addCommand(cmd);
3844 if( m_paragDlg->isJoinBorderChanged() )
3846 cmd=edit->setJoinBordersCommand( m_paragDlg->joinBorder() );
3849 if ( !macroCommand )
3850 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3852 macroCommand->addCommand(cmd);
3855 if ( m_paragDlg->isPageBreakingChanged() )
3857 cmd=edit->setPageBreakingCommand( m_paragDlg->pageBreaking() );
3860 if ( !macroCommand )
3861 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3863 macroCommand->addCommand(cmd);
3867 if ( m_paragDlg->isBackgroundColorChanged() )
3869 cmd=edit->setBackgroundColorCommand( m_paragDlg->backgroundColor() );
3872 if ( !macroCommand )
3873 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3875 macroCommand->addCommand(cmd);
3880 m_doc->addCommand(macroCommand);
3883 m_paragDlg->setParagLayout( edit->cursor()->parag()->paragLayout() );
3887void KWView::slotHRulerDoubleClicked(
double ptpos )
3889 showParagraphDialog( KoParagDia::PD_TABS, ptpos );
3897void KWView::slotHRulerDoubleClicked()
3899 TQString mode = viewMode()->type();
3900 bool state = (mode!=
"ModeText");
3904 KoRuler *ruler = m_gui->getHorzRuler ();
3905 if ( (ruler->flags() & KoRuler::F_INDENTS) && currentTextEdit() ) {
3906 if ( ruler->doubleClickedIndent () ) {
3915void KWView::formatPage()
3917 if( !m_doc->isReadWrite())
3919 TQString mode = viewMode()->type();
3920 bool state = (mode!=
"ModeText");
3924 KoPageLayout pgLayout;
3926 KoKWHeaderFooter kwhf;
3927 m_doc->getPageLayout( pgLayout, cl, kwhf );
3929 KWPageLayoutStruct oldLayout( pgLayout, cl, kwhf );
3932 int flags = FORMAT_AND_BORDERS | DISABLE_UNIT;
3933 if ( m_doc->processingType() == KWDocument::WP )
3934 flags |= KW_HEADER_AND_FOOTER | COLUMNS;
3936 flags |= DISABLE_BORDERS;
3938 KoUnit::Unit unit = m_doc->unit();
3939 KoUnit::Unit oldUnit = unit;
3941 if ( KoPageLayoutDia::pageLayout( pgLayout, hf, cl, kwhf, flags, unit,
this ) )
3943 if( !(oldLayout._pgLayout==pgLayout) ||
3944 oldLayout._cl != cl ||
3945 oldLayout._hf != kwhf )
3947 KWPageLayoutStruct newLayout( pgLayout, cl, kwhf );
3949 KWTextFrameSetEdit *edit = currentTextEdit();
3951 edit->textFrameSet()->clearUndoRedoInfo();
3952 KCommand *cmd =
new KWPageLayoutCommand( i18n(
"Change Layout"),
3953 m_doc, oldLayout, newLayout );
3954 m_doc->addCommand(cmd);
3956 m_doc->setPageLayout( pgLayout, cl, kwhf );
3958 if ( unit != oldUnit )
3959 m_doc->setUnit( unit );
3963void KWView::formatFrameSet()
3965 if ( frameViewManager()->selectedFrame() )
3967 m_gui->canvasWidget()->editFrameProperties();
3970 KMessageBox::sorry(
this,
3971 i18n(
"You must select a frame first."),
3972 i18n(
"Format Frameset"));
3975void KWView::slotSpellCheck()
3977 if (m_spell.kospell)
return;
3979 m_spell.macroCmdSpellCheck = 0L;
3980 m_spell.replaceAll.clear();
3981 TQValueList<KoTextObject *> objects;
3982 KWTextFrameSetEdit * edit = currentTextEdit();
3988 objects.append(edit->textFrameSet()->
textObject());
3989 options = KFindDialog::SelectedText;
3993 objects = m_gui->canvasWidget()->kWordDocument()->visibleTextObjects(viewMode());
3995 m_spell.textIterator =
new KoTextIterator( objects, edit, options );
3996 kdDebug()<<
"Created iterator with "<< objects.count() <<endl;
4000void KWView::extraAutoFormat()
4002 m_doc->autoFormat()->readConfig();
4003 KoAutoFormatDia dia(
this, 0, m_doc->autoFormat() );
4005 m_doc->startBackgroundSpellCheck();
4008void KWView::extraFrameStylist()
4010 KWTextFrameSetEdit * edit = currentTextEdit();
4013 KWFrameStyleManager * frameStyleManager =
new KWFrameStyleManager(
this, m_doc, TQString() );
4014 frameStyleManager->exec();
4015 delete frameStyleManager;
4020void KWView::createFrameStyle()
4023 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4024 if (selectedFrames.count() != 1)
4027 KWFrame* frame = selectedFrames[0]->frame();
4029 KoCreateStyleDia *dia =
new KoCreateStyleDia( m_doc->frameStyleCollection()->displayNameList(),
this, 0 );
4032 KWFrameStyle *style=
new KWFrameStyle( dia->nameOfNewStyle(), frame );
4033 m_doc->frameStyleCollection()->addStyle( style );
4034 m_doc->updateAllFrameStyleLists();
4039void KWView::extraStylist()
4041 KWTextFrameSetEdit * edit = currentTextEdit();
4042 TQString activeStyleName = TQString();
4046 if (edit->cursor() && edit->cursor()->parag() && edit->cursor()->parag()->style())
4047 activeStyleName = edit->cursor()->parag()->style()->displayName();
4049 KWStyleManager * styleManager =
new KWStyleManager(
this, m_doc->unit(),m_doc, *m_doc->styleCollection(), activeStyleName );
4050 styleManager->exec();
4051 delete styleManager;
4056void KWView::extraCreateTemplate()
4060 TQPixmap pix = m_doc->generatePreview(TQSize(width, height));
4062 KTempFile tempFile( TQString(),
".odt" );
4063 tempFile.setAutoDelete(
true);
4065 m_doc->saveNativeFormat( tempFile.name() );
4067 KoTemplateCreateDia::createTemplate(
"kword_template", KWFactory::instance(),
4068 tempFile.name(), pix,
this );
4070 KWFactory::instance()->dirs()->addResourceType(
"kword_template",
4071 TDEStandardDirs::kde_default(
"data" ) +
4072 "kword/templates/");
4075void KWView::toolsCreateText()
4077 if ( m_actionToolsCreateText->isChecked() )
4078 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_CREATE_TEXT );
4082 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_EDIT );
4086void KWView::insertTable()
4088 KWCanvas * canvas = m_gui->canvasWidget();
4089 canvas->setMouseMode( KWCanvas::MM_EDIT );
4090 KWTableDia *tableDia =
new KWTableDia(
this, 0, KWTableDia::NEW, canvas, m_doc,
4091 canvas->tableRows(),
4092 canvas->tableCols(),
4093 canvas->tableWidthMode(),
4094 canvas->tableHeightMode(),
4095 canvas->tableIsFloating(),
4096 canvas->tableTemplateName(),
4097 canvas->tableFormat());
4098 tableDia->setCaption( i18n(
"Insert Table" ) );
4099 if ( tableDia->exec() == TQDialog::Rejected )
4100 canvas->setMouseMode( KWCanvas::MM_EDIT );
4104void KWView::insertFormula( TQMimeSource* source )
4106 KWTextFrameSetEdit *edit = currentTextEdit();
4109 KWFormulaFrameSet *frameset =
new KWFormulaFrameSet( m_doc, TQString() );
4110 m_doc->addFrameSet( frameset,
false );
4112 TQByteArray data = source->encodedData( KFormula::MimeSource::selectionMimeType() );
4113 TQDomDocument formula;
4114 formula.setContent( data );
4115 TQDomElement formulaElem = formula.namedItem(
"math").toElement();
4116 frameset->paste( formulaElem );
4118 KWFrame *frame =
new KWFrame(frameset, 0, 0, 10, 10 );
4120 frameset->addFrame( frame,
false );
4121 edit->insertFloatingFrameSet( frameset, i18n(
"Insert Formula") );
4123 m_doc->refreshDocStructure(FT_FORMULA);
4125 m_gui->canvasWidget()->editFrameSet( frameset );
4126 frameset->setChanged();
4127 m_gui->canvasWidget()->repaintChanged( frameset,
true );
4131void KWView::toolsPart()
4133 m_gui->canvasWidget()->insertPart( m_actionToolsCreatePart->documentEntry() );
4137int KWView::tableSelectCell(
const TQString &tableName, uint row, uint col)
4139 if(!m_doc || !m_gui)
4141 KWFrameSet *fs = m_doc->frameSetByName(tableName);
4144 KWTableFrameSet *table =
dynamic_cast<KWTableFrameSet*
>(fs);
4150 KWTableFrameSet::Cell *cell = table->cell(row, col);
4152 KWCanvas *canvas = m_gui->canvasWidget();
4155 canvas->tableSelectCell(table, cell);
4159int KWView::tableDeleteRow(
const TQValueList<uint>& rows,
KWTableFrameSet *table )
4162 table = m_gui->canvasWidget()->getCurrentTable();
4164 if (!m_doc || !table)
4167 if(rows.count() >= table->
getRows()) {
4168 m_doc->deleteTable(table);
4172 KMacroCommand *macro =
new KMacroCommand(i18n(
"Remove Rows"));
4174 for (
int i = rows.count() - 1; i >= 0 ; i--) {
4175 KWRemoveRowCommand *cmd =
new KWRemoveRowCommand( i18n(
"Remove Row"),
4177 macro->addCommand(cmd);
4181 m_doc->addCommand(macro);
4185int KWView::tableDeleteCol(
const TQValueList<uint>& cols,
KWTableFrameSet *table)
4188 table = m_gui->canvasWidget()->getCurrentTable();
4190 if (!m_doc || !table)
4194 m_doc->deleteTable(table);
4198 KMacroCommand *macro =
new KMacroCommand(i18n(
"Remove Columns"));
4200 for (
int i = cols.count() - 1; i >= 0; i--) {
4201 KWRemoveColumnCommand *cmd =
new KWRemoveColumnCommand( i18n(
"Remove Column"),
4203 macro->addCommand(cmd);
4207 m_doc->addCommand(macro);
4211void KWView::tableProperties()
4213 KWCanvas * canvas = m_gui->canvasWidget();
4214 KWTableFrameSet *table = canvas->getCurrentTable();
4217 canvas->setMouseMode( KWCanvas::MM_EDIT );
4218 KWTableDia *tableDia =
new KWTableDia(
this, 0, KWTableDia::EDIT, canvas, m_doc,
4221 canvas->tableWidthMode(),
4222 canvas->tableHeightMode(),
4223 canvas->tableIsFloating(),
4224 canvas->tableTemplateName(),
4225 canvas->tableFormat());
4226 tableDia->setCaption( i18n(
"Adjust Table" ) );
4227 if ( tableDia->exec() == TQDialog::Rejected )
4228 canvas->setMouseMode( KWCanvas::MM_EDIT );
4233void KWView::tableInsertRow()
4235 TableInfo ti(frameViewManager()->selectedFrames());
4236 KWTableFrameSet::Cell *cell = ti.firstSelectedCell();
4239 KWInsertDia dia(
this, cell->
groupmanager(), KWInsertDia::insertRow, cell->firstRow());
4246 table = m_gui->canvasWidget()->getCurrentTable();
4248 if (!m_doc || !table)
4254 KWInsertRowCommand *cmd =
new KWInsertRowCommand( i18n(
"Insert Row"), table, row);
4256 m_doc->addCommand(cmd);
4260void KWView::tableInsertCol()
4262 TableInfo ti(frameViewManager()->selectedFrames());
4263 KWTableFrameSet::Cell *cell = ti.firstSelectedCell();
4266 KWInsertDia dia(
this, cell->
groupmanager(), KWInsertDia::insertColumn, cell->firstColumn());
4273 table = m_gui->canvasWidget()->getCurrentTable();
4275 if (!m_doc || !table)
4284 double maxRightOffset;
4288 KWPage *page = m_doc->pageManager()->page( table->cell(0,0)->
frame(0) );
4292 KWInsertColumnCommand *cmd =
new KWInsertColumnCommand( i18n(
"Insert Column"),
4293 table, col, maxRightOffset);
4295 m_doc->addCommand(cmd);
4298void KWView::tableDeleteRow()
4300 TableInfo ti( frameViewManager()->selectedFrames() );
4301 if(ti.amountRowsSelected() == 0)
return;
4303 KWDeleteDia dia(
this, ti.firstSelectedCell()->groupmanager(),
4304 KWDeleteDia::deleteRow, ti.selectedRows() );
4308void KWView::tableDeleteCol()
4310 TableInfo ti( frameViewManager()->selectedFrames() );
4311 if(ti.amountColumnsSelected() == 0)
return;
4313 KWDeleteDia dia(
this, ti.firstSelectedCell()->groupmanager(),
4314 KWDeleteDia::deleteColumn, ti.selectedColumns() );
4318void KWView::tableResizeCol()
4320 TableInfo ti( frameViewManager()->selectedFrames() );
4321 KWTableFrameSet::Cell *cell = ti.firstSelectedCell();
4324 KWResizeTableDia dia(
this, cell->
groupmanager(), m_doc, cell->firstColumn());
4328void KWView::tableJoinCells()
4330 KWTableFrameSet *table = 0;
4331 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4332 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
4333 unsigned int x1=10000, y1=10000, x2=0, y2=0;
4334 for(;framesIterator != selectedFrames.end(); ++framesIterator) {
4335 KWFrameView *view = *framesIterator;
4339 KWTableFrameSet::Cell *cell =
dynamic_cast<KWTableFrameSet::Cell*
>(fs);
4340 if(cell == 0)
continue;
4344 KMessageBox::sorry(
this,
4345 i18n(
"More then one table has selected cells, please make sure "
4346 "the selected cells are in one table and are connecting"),
4347 i18n(
"Join Cells Failed" ) );
4351 if(cell->firstRow() < y1) y1 = cell->firstRow();
4352 if(cell->firstColumn() < x1) x1 = cell->firstColumn();
4353 if(cell->lastRow() > y2) y2 = cell->lastRow();
4354 if(cell->lastColumn() > x2) x2 = cell->lastColumn();
4360 KCommand * cmd=table->
joinCells(x1, y1, x2, y2);
4363 KMessageBox::sorry(
this,
4364 i18n(
"You have to select some cells which are next to each other "
4365 "and are not already joined." ),
4366 i18n(
"Join Cells" ) );
4369 m_doc->addCommand(cmd);
4373void KWView::tableSplitCells() {
4374 KWSplitCellDia *splitDia=
new KWSplitCellDia(
this,
"split cell",
4375 m_tableSplit.columns, m_tableSplit.rows );
4376 if(splitDia->exec()) {
4377 m_tableSplit.rows = splitDia->rows();
4378 m_tableSplit.columns = splitDia->columns();
4379 tableSplitCells( m_tableSplit.columns, m_tableSplit.rows );
4384void KWView::tableSplitCells(
int cols,
int rows)
4386 TableInfo ti( frameViewManager()->selectedFrames() );
4387 if(! ti.oneCellSelected()) {
4388 KMessageBox::sorry(
this,
4389 i18n(
"You have to put the cursor into a table "
4390 "before splitting cells." ),
4391 i18n(
"Split Cells" ) );
4395 KWTableFrameSet::Cell *cell = ti.firstSelectedCell();
4398 KMessageBox::sorry(
this,
4399 i18n(
"There is not enough space to split the cell into that many parts, make it bigger first"),
4400 i18n(
"Split Cells") );
4403 m_doc->addCommand(cmd);
4404 m_doc->updateAllFrames();
4406 frameViewManager()->view(cell->
frame(0))->setSelected(
true);
4409void KWView::tableUngroupTable()
4411 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_EDIT );
4413 KWTableFrameSet *table = m_gui->canvasWidget()->getCurrentTable();
4419 KMacroCommand * macroCmd =
new KMacroCommand( i18n(
"Ungroup Table" ) );
4423 KWFrameSetInlineCommand *cmd =
new KWFrameSetInlineCommand( TQString(), table,
false );
4424 macroCmd->addCommand(cmd);
4427 KWUngroupTableCommand *cmd =
new KWUngroupTableCommand( TQString(), table );
4428 macroCmd->addCommand( cmd );
4429 m_doc->addCommand( macroCmd );
4430 macroCmd->execute();
4433void KWView::tableDelete()
4435 KWTableFrameSet *table = m_gui->canvasWidget()->getCurrentTable();
4439 m_doc->deleteTable( table );
4442void KWView::tableStylist()
4444 KWTextFrameSetEdit * edit = currentTextEdit();
4447 KWTableStyleManager * tableStyleManager =
new KWTableStyleManager(
this, m_doc );
4448 tableStyleManager->exec();
4449 delete tableStyleManager;
4454void KWView::tableProtectCells(
bool on)
4456 KMacroCommand *macro = 0;
4457 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4458 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
4459 for(;framesIterator != selectedFrames.end(); ++framesIterator) {
4460 KWFrameView *view = *framesIterator;
4463 KWTableFrameSet::Cell *cell =
dynamic_cast<KWTableFrameSet::Cell*
>(fs);
4464 if(cell == 0)
continue;
4465 if(cell->protectContent() != on) {
4466 KWProtectContentCommand *cmd =
new KWProtectContentCommand( i18n(
"Protect Content"), cell , on);
4468 macro =
new KMacroCommand( i18n(
"Protect Content"));
4469 macro->addCommand( cmd );
4474 m_doc->addCommand( macro );
4478void KWView::textStyleSelected( KoParagStyle *sty )
4483 if ( m_gui->canvasWidget()->currentFrameSetEdit() )
4485 KWTextFrameSetEdit * edit =
dynamic_cast<KWTextFrameSetEdit *
>(m_gui->canvasWidget()->currentFrameSetEdit()->currentTextEdit());
4487 edit->applyStyle( sty );
4491 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4492 if (selectedFrames.count() <= 0)
4496 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
4497 KMacroCommand *globalCmd = 0L;
4498 while(framesIterator != selectedFrames.end()) {
4499 KWFrame *curFrame = (*framesIterator)->frame();
4500 KWFrameSet *curFrameSet = curFrame->
frameSet();
4501 if (curFrameSet->
type() == FT_TEXT)
4503 KoTextObject *textObject = ((KWTextFrameSet*)curFrameSet)->textObject();
4504 textObject->textDocument()->selectAll( KoTextDocument::Temp );
4505 KCommand *cmd = textObject->applyStyleCommand( 0L, sty , KoTextDocument::Temp, KoParagLayout::All, KoTextFormat::Format,
true,
true );
4506 textObject->textDocument()->removeSelection( KoTextDocument::Temp );
4510 globalCmd =
new KMacroCommand( selectedFrames.count() == 1 ? i18n(
"Apply Style to Frame") : i18n(
"Apply Style to Frames"));
4511 globalCmd->addCommand( cmd );
4517 m_doc->addCommand( globalCmd );
4519 m_gui->canvasWidget()->setFocus();
4524void KWView::textStyleSelected(
int index )
4526 textStyleSelected( m_doc->styleCollection()->styleAt( index ) );
4530void KWView::slotFrameStyleSelected()
4532 TQString actionName = TQString::fromUtf8(sender()->name());
4533 const TQString prefix = FRAMESTYLE_ACTION_PREFIX;
4534 if ( actionName.startsWith( prefix ) ) {
4535 actionName = actionName.mid( prefix.length() );
4536 frameStyleSelected( m_doc->frameStyleCollection()->findStyle( actionName ) );
4540void KWView::frameStyleSelected(
int index )
4542 frameStyleSelected( m_doc->frameStyleCollection()->frameStyleAt( index ) );
4552 if ( m_gui->canvasWidget()->currentFrameSetEdit() )
4554 KWFrame * single = m_gui->canvasWidget()->currentFrameSetEdit()->currentFrame();
4557 KCommand *cmd =
new KWFrameStyleCommand( i18n(
"Apply Framestyle to Frame"), single, sty );
4559 m_doc->addCommand( cmd );
4566 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4567 if (selectedFrames.count() <= 0)
4571 KMacroCommand *globalCmd =
new KMacroCommand( selectedFrames.count() == 1 ? i18n(
"Apply Framestyle to Frame") : i18n(
"Apply Framestyle to Frames"));
4573 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
4574 while(framesIterator != selectedFrames.end()) {
4575 KWFrame *curFrame = (*framesIterator)->frame();
4576 KCommand *cmd =
new KWFrameStyleCommand( i18n(
"Apply Framestyle"), curFrame, sty );
4578 globalCmd->addCommand( cmd );
4581 m_doc->addCommand( globalCmd );
4582 globalCmd->execute();
4585 m_gui->canvasWidget()->repaintAll();
4586 m_gui->canvasWidget()->setFocus();
4589 const int pos = m_doc->frameStyleCollection()->indexOf( sty );
4590 Q_ASSERT( pos >= 0 );
4591 m_actionFrameStyle->setCurrentItem( pos );
4592 TDEToggleAction* act =
dynamic_cast<TDEToggleAction *
>(actionCollection()->action( sty->name().utf8().data() ));
4594 act->setChecked(
true );
4599void KWView::slotTableStyleSelected()
4601 TQString actionName = TQString::fromUtf8(sender()->name());
4602 const TQString prefix = TABLESTYLE_ACTION_PREFIX;
4603 if ( actionName.startsWith( prefix ) ) {
4604 actionName = actionName.mid( prefix.length() );
4605 tableStyleSelected( m_doc->tableStyleCollection()->findStyle( actionName ) );
4609void KWView::tableStyleSelected(
int index )
4611 tableStyleSelected( m_doc->tableStyleCollection()->tableStyleAt( index ) );
4620 if ( m_gui->canvasWidget()->currentFrameSetEdit() )
4622 KWFrame * single = m_gui->canvasWidget()->currentFrameSetEdit()->currentFrame();
4623 if ( (single) && ( single->
frameSet()->
type() == FT_TEXT ) )
4625 KCommand *cmd =
new KWTableStyleCommand( i18n(
"Apply Tablestyle to Frame"), single, sty );
4627 m_doc->addCommand( cmd );
4634 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4635 if (selectedFrames.count() <= 0)
4638 KMacroCommand *globalCmd =
new KMacroCommand( selectedFrames.count() == 1 ? i18n(
"Apply Tablestyle to Frame") : i18n(
"Apply Tablestyle to Frames"));
4640 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
4641 while(framesIterator != selectedFrames.end() ) {
4642 KWFrame *curFrame = (*framesIterator)->frame();
4643 if(
dynamic_cast<KWTextFrameSet*
>(curFrame->
frameSet())) {
4644 KCommand *cmd =
new KWTableStyleCommand( i18n(
"Apply Tablestyle to Frame"),
4647 globalCmd->addCommand( cmd );
4651 m_doc->addCommand( globalCmd );
4652 globalCmd->execute();
4655 m_gui->canvasWidget()->repaintAll();
4656 m_gui->canvasWidget()->setFocus();
4659 int pos = m_doc->tableStyleCollection()->indexOf( sty );
4660 m_actionTableStyle->setCurrentItem( pos );
4661 TDEToggleAction* act =
dynamic_cast<TDEToggleAction *
>(actionCollection()->action( sty->name().utf8().data() ));
4663 act->setChecked(
true );
4666void KWView::increaseFontSize()
4668 KWTextFrameSetEdit * edit = currentTextEdit();
4669 KoTextFormat *format = edit->currentFormat();
4671 textSizeSelected( edit->textFrameSet()->
textObject()->docFontSize( format ) + 1 );
4674void KWView::decreaseFontSize()
4676 KWTextFrameSetEdit * edit = currentTextEdit();
4677 KoTextFormat *format = edit->currentFormat();
4679 textSizeSelected( edit->textFrameSet()->
textObject()->docFontSize( format ) - 1 );
4682void KWView::textSizeSelected(
int size )
4684 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4685 TQPtrListIterator<KoTextFormatInterface> it( lst );
4686 KMacroCommand *globalCmd =
new KMacroCommand(i18n(
"Change Text Size"));
4687 for ( ; it.current() ; ++it )
4689 KCommand *cmd = it.current()->setPointSizeCommand( size );
4691 globalCmd->addCommand(cmd);
4693 m_doc->addCommand(globalCmd);
4694 m_gui->canvasWidget()->setFocus();
4697void KWView::textFontSelected(
const TQString & font )
4699 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4700 if ( lst.isEmpty() )
return;
4701 TQPtrListIterator<KoTextFormatInterface> it( lst );
4702 KMacroCommand* macroCmd = 0L;
4703 for ( ; it.current() ; ++it )
4705 KCommand *cmd = it.current()->setFamilyCommand( font );
4709 macroCmd =
new KMacroCommand( i18n(
"Change Text Font") );
4710 macroCmd->addCommand( cmd );
4714 m_doc->addCommand( macroCmd );
4715 m_gui->canvasWidget()->setFocus();
4718TQPtrList<KoTextFormatInterface> KWView::applicableTextInterfaces()
const
4720 TQPtrList<KoTextFormatInterface> lst;
4721 if (currentTextEdit())
4723 if ( !currentTextEdit()->textObject()->protectContent())
4726 lst.append( currentTextEdit() );
4728 KWCollectFramesetsVisitor visitor;
4729 currentTextEdit()->textDocument()->visitSelection( KoTextDocument::Standard, &visitor );
4730 const TQValueList<KWFrameSet *>& frameset = visitor.frameSets();
4731 for ( TQValueList<KWFrameSet *>::ConstIterator it = frameset.begin(); it != frameset.end(); ++it )
4733 if ( (*it)->type() == FT_TABLE )
4735 KWTableFrameSet* kwtableframeset =
static_cast<KWTableFrameSet *
>( *it );
4737 int const rows = kwtableframeset->
getRows();
4738 int const cols = kwtableframeset->
getColumns();
4740 for (
int r=0; r<rows; ++r)
4742 for (
int c=0; c<cols; ++c)
4744 KWTableFrameSet::Cell *cell = kwtableframeset->cell(r,c);
4747 kdDebug() <<
"adding (" << r <<
"," << c <<
")" << endl;
4759 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4760 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
4761 while(framesIterator != selectedFrames.end()) {
4762 KWTextFrameSet* fs =
dynamic_cast<KWTextFrameSet *
>( (*framesIterator)->frame()->frameSet() );
4763 if ( fs && !lst.contains( fs )&& !fs->protectContent() )
4771void KWView::textBold()
4773 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4774 if ( lst.isEmpty() )
return;
4775 TQPtrListIterator<KoTextFormatInterface> it( lst );
4776 KMacroCommand* macroCmd = 0L;
4777 for ( ; it.current() ; ++it )
4779 KCommand *cmd = it.current()->setBoldCommand( m_actionFormatBold->isChecked() );
4783 macroCmd =
new KMacroCommand( i18n(
"Make Text Bold") );
4784 macroCmd->addCommand(cmd);
4788 m_doc->addCommand(macroCmd);
4792void KWView::textItalic()
4794 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4795 TQPtrListIterator<KoTextFormatInterface> it( lst );
4796 KMacroCommand* macroCmd = 0L;
4797 for ( ; it.current() ; ++it )
4799 KCommand *cmd = it.current()->setItalicCommand( m_actionFormatItalic->isChecked() );
4803 macroCmd =
new KMacroCommand( i18n(
"Make Text Italic") );
4804 macroCmd->addCommand( cmd );
4808 m_doc->addCommand( macroCmd );
4811void KWView::textUnderline()
4813 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4814 TQPtrListIterator<KoTextFormatInterface> it( lst );
4815 KMacroCommand* macroCmd = 0L;
4817 for ( ; it.current() ; ++it )
4819 KCommand *cmd = it.current()->setUnderlineCommand( m_actionFormatUnderline->isChecked() );
4823 macroCmd =
new KMacroCommand( i18n(
"Underline Text") );
4824 macroCmd->addCommand( cmd );
4828 m_doc->addCommand( macroCmd );
4831void KWView::textStrikeOut()
4833 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4834 TQPtrListIterator<KoTextFormatInterface> it( lst );
4835 KMacroCommand* macroCmd = 0L;
4836 for ( ; it.current() ; ++it )
4838 KCommand *cmd = it.current()->setStrikeOutCommand( m_actionFormatStrikeOut->isChecked() );
4842 macroCmd =
new KMacroCommand( i18n(
"Strike Out Text") );
4843 macroCmd->addCommand( cmd );
4847 m_doc->addCommand( macroCmd );
4850void KWView::textColor()
4858 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4859 if ( lst.isEmpty() )
return;
4860 TQPtrListIterator<KoTextFormatInterface> it( lst );
4861 KMacroCommand* macroCmd = 0L;
4862 for ( ; it.current() ; ++it )
4864 KCommand *cmd = it.current()->setTextColorCommand( m_actionFormatColor->color() );
4868 macroCmd =
new KMacroCommand( i18n(
"Set Text Color") );
4869 macroCmd->addCommand( cmd );
4873 m_doc->addCommand( macroCmd );
4876void KWView::textAlignLeft()
4878 if ( m_actionFormatAlignLeft->isChecked() )
4880 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4881 TQPtrListIterator<KoTextFormatInterface> it( lst );
4882 KMacroCommand* macroCmd = 0L;
4883 for ( ; it.current() ; ++it )
4885 KCommand *cmd = it.current()->setAlignCommand( TQt::AlignLeft );
4889 macroCmd =
new KMacroCommand( i18n(
"Left-Align Text") );
4890 macroCmd->addCommand( cmd );
4894 m_doc->addCommand( macroCmd );
4897 m_actionFormatAlignLeft->setChecked(
true );
4900void KWView::textAlignCenter()
4902 if ( m_actionFormatAlignCenter->isChecked() )
4904 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4905 TQPtrListIterator<KoTextFormatInterface> it( lst );
4906 KMacroCommand* macroCmd = 0L;
4907 for ( ; it.current() ; ++it )
4909 KCommand *cmd = it.current()->setAlignCommand( TQt::AlignHCenter );
4913 macroCmd =
new KMacroCommand( i18n(
"Center Text") );
4914 macroCmd->addCommand( cmd );
4918 m_doc->addCommand( macroCmd );
4921 m_actionFormatAlignCenter->setChecked(
true );
4924void KWView::textAlignRight()
4926 if ( m_actionFormatAlignRight->isChecked() )
4928 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4929 TQPtrListIterator<KoTextFormatInterface> it( lst );
4930 KMacroCommand* macroCmd = 0L;
4931 for ( ; it.current() ; ++it )
4933 KCommand *cmd = it.current()->setAlignCommand( TQt::AlignRight );
4937 macroCmd =
new KMacroCommand( i18n(
"Right-Align Text") );
4938 macroCmd->addCommand( cmd );
4942 m_doc->addCommand( macroCmd );
4945 m_actionFormatAlignRight->setChecked(
true );
4948void KWView::textAlignBlock()
4950 if ( m_actionFormatAlignBlock->isChecked() )
4952 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4953 TQPtrListIterator<KoTextFormatInterface> it( lst );
4954 KMacroCommand* macroCmd = 0L;
4955 for ( ; it.current() ; ++it )
4957 KCommand *cmd = it.current()->setAlignCommand( TQt::AlignJustify );
4961 macroCmd =
new KMacroCommand( i18n(
"Justify Text") );
4962 macroCmd->addCommand( cmd );
4966 m_doc->addCommand( macroCmd );
4969 m_actionFormatAlignBlock->setChecked(
true );
4972void KWView::setSpacing( KoParagLayout::SpacingType spacing,
const TQString& commandName)
4974 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4975 if ( lst.isEmpty() )
return;
4976 TQPtrListIterator<KoTextFormatInterface> it( lst );
4977 KMacroCommand* macroCmd = 0L;
4978 for ( ; it.current() ; ++it )
4980 KoParagLayout layout( *it.current()->currentParagLayoutFormat() );
4981 layout.lineSpacingType = spacing;
4983 KCommand *cmd = it.current()->setParagLayoutFormatCommand( &layout, KoParagLayout::LineSpacing );
4987 macroCmd =
new KMacroCommand( commandName );
4988 macroCmd->addCommand(cmd);
4992 m_doc->addCommand(macroCmd);
4995void KWView::textSpacingSingle()
4997 if ( m_actionFormatSpacingSingle->isChecked() )
4998 setSpacing( KoParagLayout::LS_SINGLE, i18n(
"Set Single Line Spacing") );
5000 m_actionFormatSpacingSingle->setChecked(
true );
5003void KWView::textSpacingOneAndHalf()
5005 if ( m_actionFormatSpacingOneAndHalf->isChecked() )
5006 setSpacing( KoParagLayout::LS_ONEANDHALF, i18n(
"Set One and a Half Line Spacing") );
5008 m_actionFormatSpacingOneAndHalf->setChecked(
true );
5011void KWView::textSpacingDouble()
5013 if ( m_actionFormatSpacingDouble->isChecked() )
5014 setSpacing( KoParagLayout::LS_DOUBLE, i18n(
"Set Double Line Spacing") );
5016 m_actionFormatSpacingDouble->setChecked(
true );
5019void KWView::slotCounterStyleSelected()
5021 TQString actionName = TQString::fromLatin1(sender()->name());
5022 TQString styleStr = actionName.mid(13);
5024 KoParagCounter::Style style = (KoParagCounter::Style)(styleStr.toInt());
5026 if ( style == KoParagCounter::STYLE_NONE )
5027 c.setNumbering( KoParagCounter::NUM_NONE );
5029 c.setNumbering( KoParagCounter::NUM_LIST );
5030 c.setStyle( style );
5032 c.setSuffix( TQString() );
5040 if ( currentTextEdit() && !currentTextEdit()->textFrameSet()->hasSelection() ) {
5041 KoTextParag* parag = currentTextEdit()->cursor()->parag();
5042 if ( parag->prev() && !parag->prev()->counter() )
5043 c.setRestartCounter(
true);
5047 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5048 TQPtrListIterator<KoTextFormatInterface> it( lst );
5049 KMacroCommand* macroCmd = 0L;
5050 for ( ; it.current() ; ++it )
5052 KCommand *cmd = it.current()->setCounterCommand( c );
5056 macroCmd=
new KMacroCommand( i18n(
"Change List Type") );
5057 macroCmd->addCommand( cmd );
5061 m_doc->addCommand( macroCmd );
5064void KWView::textSuperScript()
5066 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5067 if ( lst.isEmpty() )
return;
5068 TQPtrListIterator<KoTextFormatInterface> it( lst );
5069 KMacroCommand* macroCmd = 0L;
5070 for ( ; it.current() ; ++it )
5072 KCommand *cmd = it.current()->setTextSuperScriptCommand(m_actionFormatSuper->isChecked());
5076 macroCmd =
new KMacroCommand( i18n(
"Make Text Superscript") );
5077 macroCmd->addCommand(cmd);
5081 m_doc->addCommand(macroCmd);
5082 if (m_actionFormatSuper->isChecked() )
5083 m_actionFormatSub->setChecked(
false );
5086void KWView::textSubScript()
5088 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5089 if ( lst.isEmpty() )
return;
5090 TQPtrListIterator<KoTextFormatInterface> it( lst );
5091 KMacroCommand* macroCmd = 0L;
5092 for ( ; it.current() ; ++it )
5094 KCommand *cmd = it.current()->setTextSubScriptCommand(m_actionFormatSub->isChecked());
5098 macroCmd =
new KMacroCommand( i18n(
"Make Text Subscript") );
5099 macroCmd->addCommand(cmd);
5103 m_doc->addCommand(macroCmd);
5104 if (m_actionFormatSub->isChecked() )
5105 m_actionFormatSuper->setChecked(
false );
5108void KWView::changeCaseOfText()
5110 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5111 if ( lst.isEmpty() )
return;
5112 TQPtrListIterator<KoTextFormatInterface> it( lst );
5113 KoChangeCaseDia *caseDia=
new KoChangeCaseDia(
this,
"change case" );
5116 KMacroCommand* macroCmd = 0L;
5117 for ( ; it.current() ; ++it )
5119 KCommand *cmd = it.current()->setChangeCaseOfTextCommand(caseDia->getTypeOfCase());
5123 macroCmd =
new KMacroCommand( i18n(
"Change Case of Text") );
5124 macroCmd->addCommand(cmd);
5128 m_doc->addCommand(macroCmd);
5133void KWView::editPersonalExpr()
5135 KWEditPersonnalExpression *personalDia=
new KWEditPersonnalExpression(
this );
5136 if(personalDia->exec())
5137 m_doc->refreshMenuExpression();
5142void KWView::textIncreaseIndent()
5144 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5145 if ( lst.isEmpty() )
return;
5146 TQPtrListIterator<KoTextFormatInterface> it( lst );
5147 double leftMargin=0.0;
5149 leftMargin=lst.first()->currentParagLayoutFormat()->margins[TQStyleSheetItem::MarginLeft];
5150 double indent = m_doc->indentValue();
5151 double newVal = leftMargin + indent;
5152 KMacroCommand* macroCmd = 0L;
5153 for ( ; it.current() ; ++it )
5155 KCommand *cmd = it.current()->setMarginCommand( TQStyleSheetItem::MarginLeft, newVal );
5159 macroCmd =
new KMacroCommand( i18n(
"Increase Paragraph Depth") );
5160 macroCmd->addCommand(cmd);
5164 m_doc->addCommand(macroCmd);
5167 const KoParagLayout *layout=lst.first()->currentParagLayoutFormat();
5168 showRulerIndent( layout->margins[TQStyleSheetItem::MarginLeft], layout->margins[TQStyleSheetItem::MarginFirstLine], layout->margins[TQStyleSheetItem::MarginRight], lst.first()->rtl());
5173 KWTextFrameSetEdit * edit = currentTextEdit();
5176 double leftMargin = edit->currentLeftMargin();
5177 double indent = m_doc->indentValue();
5178 double newVal = leftMargin + indent;
5183 KCommand *cmd=edit->setMarginCommand( TQStyleSheetItem::MarginLeft, newVal );
5185 m_doc->addCommand(cmd);
5191void KWView::textDecreaseIndent()
5193 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5194 if ( lst.isEmpty() )
return;
5195 TQPtrListIterator<KoTextFormatInterface> it( lst );
5196 double leftMargin=0.0;
5198 leftMargin=lst.first()->currentParagLayoutFormat()->margins[TQStyleSheetItem::MarginLeft];
5199 double indent = m_doc->indentValue();
5200 double newVal = leftMargin - indent;
5201 KMacroCommand* macroCmd = 0L;
5202 for ( ; it.current() ; ++it )
5204 KCommand *cmd = it.current()->setMarginCommand( TQStyleSheetItem::MarginLeft, TQMAX( newVal, 0 ) );
5208 macroCmd =
new KMacroCommand( i18n(
"Decrease Paragraph Depth") );
5209 macroCmd->addCommand(cmd);
5213 m_doc->addCommand(macroCmd);
5216 const KoParagLayout *layout=lst.first()->currentParagLayoutFormat();
5217 showRulerIndent( layout->margins[TQStyleSheetItem::MarginLeft], layout->margins[TQStyleSheetItem::MarginFirstLine], layout->margins[TQStyleSheetItem::MarginRight], lst.first()->rtl());
5222 KWTextFrameSetEdit * edit = currentTextEdit();
5225 double leftMargin = edit->currentLeftMargin();
5226 if ( leftMargin > 0 )
5228 double indent = m_doc->indentValue();
5229 double newVal = leftMargin - indent;
5230 KCommand *cmd=edit->setMarginCommand( TQStyleSheetItem::MarginLeft, TQMAX( newVal, 0 ) );
5232 m_doc->addCommand(cmd);
5239void KWView::textDefaultFormat()
5241 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5242 if ( lst.isEmpty() )
return;
5243 TQPtrListIterator<KoTextFormatInterface> it( lst );
5244 KMacroCommand* macroCmd = 0L;
5245 for ( ; it.current() ; ++it )
5247 KCommand *cmd = it.current()->setDefaultFormatCommand();
5251 macroCmd =
new KMacroCommand( i18n(
"Default Format") );
5252 macroCmd->addCommand(cmd);
5256 m_doc->addCommand(macroCmd);
5260void KWView::borderOutline()
5262 bool on = m_actionBorderOutline->isChecked();
5263 if(m_actionBorderLeft->isChecked() != on) {
5264 m_actionBorderLeft->setChecked(on);
5267 if(m_actionBorderRight->isChecked() != on) {
5268 m_actionBorderRight->setChecked(on);
5271 if(m_actionBorderTop->isChecked() != on) {
5272 m_actionBorderTop->setChecked(on);
5275 if(m_actionBorderBottom->isChecked() != on) {
5276 m_actionBorderBottom->setChecked(on);
5281void KWView::borderLeft() {
5282 borderChanged(KoBorder::LeftBorder);
5285void KWView::borderRight() {
5286 borderChanged(KoBorder::RightBorder);
5289void KWView::borderTop() {
5290 borderChanged(KoBorder::TopBorder);
5293void KWView::borderBottom() {
5294 borderChanged(KoBorder::BottomBorder);
5297void KWView::borderChanged(KoBorder::BorderType type) {
5299 border.setPenWidth( m_actionBorderWidth->currentText().toInt() );
5300 border.color = m_actionBorderColor->color();
5301 border.setStyle( KoBorder::getStyle( m_actionBorderStyle->currentText() ) );
5302 bool enabled =
false;
5305 case KoBorder::LeftBorder:
5306 enabled = m_actionBorderLeft->isChecked();
5307 comment = i18n(
"Change Left Frame Border");
5309 case KoBorder::RightBorder:
5310 enabled = m_actionBorderRight->isChecked();
5311 comment = i18n(
"Change Right Frame Border");
5313 case KoBorder::TopBorder:
5314 enabled = m_actionBorderTop->isChecked();
5315 comment = i18n(
"Change Top Frame Border");
5317 case KoBorder::BottomBorder:
5319 enabled = m_actionBorderBottom->isChecked();
5320 comment = i18n(
"Change Bottom Frame Border");
5324 border.setPenWidth(0);
5327 KWTextFrameSetEdit *edit = currentTextEdit();
5329 KoBorder left = edit->
border(KoBorder::LeftBorder);
5330 KoBorder right = edit->
border(KoBorder::RightBorder);
5331 KoBorder top = edit->
border(KoBorder::TopBorder);
5332 KoBorder bottom = edit->
border(KoBorder::BottomBorder);
5333 if(type == KoBorder::LeftBorder)
5335 else if(type == KoBorder::RightBorder)
5337 else if(type == KoBorder::TopBorder)
5341 cmd=edit->setBordersCommand( left, right, top, bottom );
5344 TQPtrList<FrameIndex> indexes;
5345 TQPtrList<KWFrameBorderCommand::FrameBorderTypeStruct> borders;
5346 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
5347 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
5348 for(;framesIterator != selectedFrames.end(); ++framesIterator) {
5349 if( !(*framesIterator)->selected() )
continue;
5350 KWFrame *frame = (*framesIterator)->frame();
5351 indexes.append(
new FrameIndex( frame ));
5352 KWFrameBorderCommand::FrameBorderTypeStruct *bts =
5353 new KWFrameBorderCommand::FrameBorderTypeStruct;
5354 bts->m_EFrameType = type;
5355 if(type == KoBorder::LeftBorder)
5357 else if(type == KoBorder::RightBorder)
5358 bts->m_OldBorder=frame->rightBorder();
5359 else if(type == KoBorder::TopBorder)
5360 bts->m_OldBorder=frame->topBorder();
5362 bts->m_OldBorder=frame->bottomBorder();
5363 borders.append(bts);
5365 if(indexes.count() > 0)
5366 cmd=
new KWFrameBorderCommand(comment, indexes, borders, border);
5370 m_doc->addCommand( cmd );
5373 m_actionBorderOutline->setChecked(
5374 m_actionBorderLeft->isChecked() && m_actionBorderRight->isChecked() &&
5375 m_actionBorderTop->isChecked() && m_actionBorderBottom->isChecked());
5378void KWView::backgroundColor()
5380 TQColor backColor = m_actionBackgroundColor->color();
5382 KWTextFrameSetEdit *edit = currentTextEdit();
5387 KCommand *cmd=edit->setTextBackgroundColorCommand(backColor);
5389 m_doc->addCommand( cmd );
5392 m_gui->canvasWidget()->setFrameBackgroundColor( backColor );
5396void KWView::resizeEvent( TQResizeEvent *e )
5398 TQWidget::resizeEvent( e );
5401 m_gui->resize( width(), height() );
5402 TQString s = m_actionViewZoom->currentText();
5403 if ( !KoZoomMode::isConstant(s) )
5408void KWView::guiActivateEvent( KParts::GUIActivateEvent *ev )
5410 if ( ev->activated() )
5413 if (m_doc->isEmbedded() ) {
5415 const int zoom = tqRound( KoView::zoom() * 100 );
5416 setZoom( zoom,
true );
5420 KoView::guiActivateEvent( ev );
5423void KWView::tabListChanged(
const KoTabulatorList & tabList )
5425 if(!m_doc->isReadWrite())
5427 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5428 if ( lst.isEmpty() )
return;
5429 TQPtrListIterator<KoTextFormatInterface> it( lst );
5430 KMacroCommand* macroCmd = 0L;
5431 for ( ; it.current() ; ++it )
5433 KCommand *cmd = it.current()->setTabListCommand( tabList );
5437 macroCmd =
new KMacroCommand(i18n(
"Change Tabulator") );
5438 macroCmd->addCommand(cmd);
5442 m_doc->addCommand(macroCmd);
5445void KWView::newPageLayout(
const KoPageLayout &layout )
5447 TQString mode = viewMode()->type();
5448 bool state = (mode!=
"ModeText");
5452 KoPageLayout pgLayout;
5454 KoKWHeaderFooter hf;
5455 m_doc->getPageLayout( pgLayout, cl, hf );
5457 if(layout==pgLayout)
5460 KWPageLayoutStruct oldLayout( pgLayout, cl, hf );
5462 m_doc->setPageLayout( layout, cl, hf );
5464 KWPageLayoutStruct newLayout( layout, cl, hf );
5466 KWTextFrameSetEdit *edit = currentTextEdit();
5468 edit->textFrameSet()->clearUndoRedoInfo();
5469 KCommand *cmd =
new KWPageLayoutCommand( i18n(
"Change Layout"), m_doc, oldLayout, newLayout );
5470 m_doc->addCommand(cmd);
5473void KWView::slotPageLayoutChanged(
const KoPageLayout& layout )
5478 viewMode()->setPageLayout( m_gui->getHorzRuler(), m_gui->getVertRuler(), layout );
5479 m_gui->canvasWidget()->repaintAll();
5482void KWView::newFirstIndent(
double firstIndent )
5484 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5485 if ( lst.isEmpty() )
return;
5486 TQPtrListIterator<KoTextFormatInterface> it( lst );
5487 KMacroCommand* macroCmd = 0L;
5488 for ( ; it.current() ; ++it )
5490 KCommand *cmd = it.current()->setMarginCommand( TQStyleSheetItem::MarginFirstLine, firstIndent );
5494 macroCmd =
new KMacroCommand(i18n(
"Change First Line Indent"));
5495 macroCmd->addCommand(cmd);
5499 m_doc->addCommand(macroCmd);
5502void KWView::newLeftIndent(
double leftIndent )
5504 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5505 if ( lst.isEmpty() )
return;
5506 TQPtrListIterator<KoTextFormatInterface> it( lst );
5507 KMacroCommand* macroCmd = 0L;
5508 for ( ; it.current() ; ++it )
5510 KCommand *cmd = it.current()->setMarginCommand( TQStyleSheetItem::MarginLeft, leftIndent );
5514 macroCmd =
new KMacroCommand(i18n(
"Change Indent") );
5515 macroCmd->addCommand(cmd);
5519 m_doc->addCommand(macroCmd);
5523void KWView::newRightIndent(
double rightIndent)
5526 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5527 if ( lst.isEmpty() )
return;
5528 TQPtrListIterator<KoTextFormatInterface> it( lst );
5529 KMacroCommand* macroCmd = 0L;
5530 for ( ; it.current() ; ++it )
5532 KCommand *cmd = it.current()->setMarginCommand( TQStyleSheetItem::MarginRight, rightIndent );
5536 macroCmd =
new KMacroCommand(i18n(
"Change Indent") );
5537 macroCmd->addCommand(cmd);
5541 m_doc->addCommand(macroCmd);
5544TQPopupMenu * KWView::popupMenu(
const TQString& name )
5550 partManager()->setActivePart( m_doc,
this );
5551 Q_ASSERT( factory() );
5553 return ((TQPopupMenu*)factory()->container( name,
this ));
5557void KWView::startKSpell()
5559 if ( !m_spell.kospell )
5560 m_spell.kospell =
new KoSpell( m_broker,
this );
5563 Q_ASSERT( m_spell.textIterator );
5565 m_spell.kospell->check( m_spell.textIterator,
true );
5567 m_spell.dlg =
new KSpell2::Dialog( m_spell.kospell,
this );
5568 m_spell.dlg->activeAutoCorrect(
true );
5570 TQObject::connect( m_spell.dlg, TQ_SIGNAL(misspelling(
const TQString&,
int)),
5571 this, TQ_SLOT(spellCheckerMisspelling(
const TQString&,
int)) );
5572 TQObject::connect( m_spell.dlg, TQ_SIGNAL(replace(
const TQString&,
int,
const TQString&)),
5573 this, TQ_SLOT(spellCheckerCorrected(
const TQString&,
int,
const TQString&)) );
5574 TQObject::connect( m_spell.dlg, TQ_SIGNAL(done(
const TQString&) ),
5575 this, TQ_SLOT(spellCheckerDone(
const TQString&)) );
5576 TQObject::connect( m_spell.dlg, TQ_SIGNAL(cancel() ),
5577 this, TQ_SLOT( spellCheckerCancel() ) );
5578 TQObject::connect( m_spell.dlg, TQ_SIGNAL(autoCorrect(
const TQString &,
const TQString & ) ),
5579 this, TQ_SLOT( spellAddAutoCorrect (
const TQString &,
const TQString &) ) );
5581 m_spell.dlg->show();
5585void KWView::spellCheckerMisspelling(
const TQString &old,
int pos )
5588 KoTextObject* textobj = m_spell.kospell->currentTextObject();
5589 KoTextParag* parag = m_spell.kospell->currentParag();
5590 Q_ASSERT( textobj );
5592 if ( !textobj || !parag )
return;
5593 KWTextDocument *textdoc=
static_cast<KWTextDocument *
>( textobj->textDocument() );
5594 Q_ASSERT( textdoc );
5595 if ( !textdoc )
return;
5596 pos += m_spell.kospell->currentStartIndex();
5597 kdDebug(32001) <<
"KWView::spellCheckerMisspelling parag=" << parag->paragId() <<
" pos=" << pos <<
" length=" << old.length() << endl;
5601void KWView::spellCheckerCorrected(
const TQString &old,
int pos ,
const TQString &corr )
5604 KoTextObject* textobj = m_spell.kospell->currentTextObject();
5605 KoTextParag* parag = m_spell.kospell->currentParag();
5606 Q_ASSERT( textobj );
5608 if ( !textobj || !parag )
return;
5609 KWTextDocument *textdoc=
static_cast<KWTextDocument *
>( textobj->textDocument() );
5610 Q_ASSERT( textdoc );
5611 if ( !textdoc )
return;
5612 pos += m_spell.kospell->currentStartIndex();
5615 KoTextCursor cursor( textdoc );
5616 cursor.setParag( parag );
5617 cursor.setIndex( pos );
5618 if(!m_spell.macroCmdSpellCheck)
5619 m_spell.macroCmdSpellCheck=
new KMacroCommand(i18n(
"Correct Misspelled Word"));
5620 m_spell.macroCmdSpellCheck->addCommand(textobj->replaceSelectionCommand(
5621 &cursor, corr, TQString(), KoTextDocument::HighlightSelection));
5624void KWView::spellCheckerDone(
const TQString & )
5627 KWTextDocument *textdoc=
static_cast<KWTextDocument *
>( m_spell.kospell->textDocument() );
5628 Q_ASSERT( textdoc );
5632 clearSpellChecker();
5635void KWView::clearSpellChecker(
bool cancelSpellCheck)
5637 kdDebug(32001) <<
"KWView::clearSpellChecker" << endl;
5639 delete m_spell.textIterator;
5640 m_spell.textIterator = 0L;
5641 delete m_spell.kospell;
5642 m_spell.kospell = 0;
5644 if ( m_spell.macroCmdSpellCheck )
5646 if ( !cancelSpellCheck )
5647 m_doc->addCommand(m_spell.macroCmdSpellCheck);
5651 m_spell.macroCmdSpellCheck->unexecute();
5652 delete m_spell.macroCmdSpellCheck;
5655 m_spell.macroCmdSpellCheck=0L;
5656 m_spell.replaceAll.clear();
5660void KWView::spellCheckerCancel()
5662 kdDebug()<<
"void KWView::spellCheckerCancel() \n";
5663 spellCheckerRemoveHighlight();
5665 clearSpellChecker(
true);
5669void KWView::spellCheckerRemoveHighlight()
5671 KoTextObject* textobj = m_spell.kospell->currentTextObject();
5673 KWTextDocument *textdoc=
static_cast<KWTextDocument *
>( textobj->textDocument() );
5677 KWTextFrameSetEdit * edit = currentTextEdit();
5679 edit->drawCursor(
true );
5682void KWView::spellAddAutoCorrect (
const TQString & originalword,
const TQString & newword)
5684 m_doc->autoFormat()->addAutoFormatEntry( originalword, newword );
5687void KWView::configure()
5689 KWConfig configDia(
this );
5697 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
5703void KWView::slotFrameSetEditChanged()
5705 KWTextFrameSetEdit * edit = currentTextEdit();
5706 bool rw = koDocument()->isReadWrite();
5707 bool selectedFrames = frameViewManager()->selectedFrames().count() > 0;
5708 bool hasSelection =
false;
5711 if ( edit->textFrameSet()->
textObject()->protectContent())
5715 KWFrameSetEdit * e = m_gui->canvasWidget()->currentFrameSetEdit();
5716 if ( e && e->frameSet()->
type() == FT_FORMULA ) {
5717 hasSelection =
true;
5720 m_actionEditCut->setEnabled( hasSelection && rw );
5722 m_actionEditCopy->setEnabled( hasSelection );
5723 m_actionEditReplace->setEnabled( rw );
5724 clipboardDataChanged();
5726 bool state = (edit != 0 | selectedFrames) && rw;
5727 m_actionEditSelectAll->setEnabled(state);
5728 m_actionEditSelectCurrentFrame->setEnabled(state);
5729 m_actionInsertComment->setEnabled( state );
5730 m_actionFormatDefault->setEnabled( state );
5731 m_actionFormatFont->setEnabled( state );
5732 m_actionFormatFontSize->setEnabled( state );
5733 m_actionFormatFontFamily->setEnabled( state );
5734 m_actionAddBookmark->setEnabled(state);
5735 m_actionBackgroundColor->setEnabled( state );
5736 m_actionFormatStyleMenu->setEnabled( state );
5737 m_actionFormatBold->setEnabled( state );
5738 m_actionFormatItalic->setEnabled( state );
5739 m_actionFormatUnderline->setEnabled( state );
5740 m_actionFormatStrikeOut->setEnabled( state );
5741 m_actionFormatColor->setEnabled( state );
5742 m_actionFormatAlignLeft->setEnabled( state );
5743 m_actionFormatAlignCenter->setEnabled( state );
5744 m_actionFormatAlignRight->setEnabled( state );
5745 m_actionFormatAlignBlock->setEnabled( state );
5747 m_actionBorderLeft->setEnabled( state );
5748 m_actionBorderRight->setEnabled( state );
5749 m_actionBorderTop->setEnabled( state );
5750 m_actionBorderBottom->setEnabled( state );
5751 m_actionBorderOutline->setEnabled( state );
5752 m_actionBorderColor->setEnabled( state );
5753 m_actionBorderWidth->setEnabled( state );
5754 m_actionBorderStyle->setEnabled( state );
5758 m_actionInsertLink->setEnabled(state);
5759 m_actionCreateStyleFromSelection->setEnabled( state );
5760 m_actionConvertToTextBox->setEnabled( state && hasSelection);
5761 m_actionAddPersonalExpression->setEnabled( state && hasSelection);
5762 m_actionSortText->setEnabled( state && hasSelection);
5763 bool goodleftMargin=
false;
5765 goodleftMargin=(edit->currentLeftMargin()>0);
5767 m_actionFormatDecreaseIndent->setEnabled(goodleftMargin);
5768 const bool canChangeCounter = rw && ( !edit || !edit->textFrameSet()->isFootEndNote() );
5769 m_actionFormatBullet->setEnabled(canChangeCounter);
5770 m_actionFormatNumber->setEnabled(canChangeCounter);
5771 m_actionFormatStyle->setEnabled(rw);
5772 m_actionFormatSpacingSingle->setEnabled(rw);
5773 m_actionFormatSpacingOneAndHalf->setEnabled(rw);
5774 m_actionFormatSpacingDouble->setEnabled(rw);
5775 m_actionFormatSuper->setEnabled(rw);
5776 m_actionFormatSub->setEnabled(rw);
5777 m_actionFormatParag->setEnabled(state);
5778 m_actionInsertSpecialChar->setEnabled(state);
5779 m_actionSpellCheck->setEnabled(state);
5781 m_actionChangeCase->setEnabled( (rw && !edit)|| (state && hasSelection) );
5783 if ( edit && edit->textFrameSet()->protectContent())
5785 m_actionChangeCase->setEnabled(
false );
5786 m_actionEditCut->setEnabled(
false );
5789 m_actionChangeCase->setEnabled(
true );
5791 updateTableActions( frameViewManager()->selectedFrames() ) ;
5793 m_actionInsertFormula->setEnabled(state && (viewMode()->type()!=
"ModeText"));
5794 actionInsertVariable->setEnabled(state);
5795 m_actionInsertExpression->setEnabled(state);
5797 changeFootEndNoteState();
5799 state= state && edit && edit->frameSet() && !edit->frameSet()->isHeaderOrFooter() && !edit->frameSet()->
groupmanager() && !edit->frameSet()->isFootEndNote();
5800 m_actionInsertContents->setEnabled(state);
5801 m_actionInsertFrameBreak->setEnabled( state );
5805void KWView::changeFootEndNoteState()
5807 bool rw = koDocument()->isReadWrite();
5808 KWTextFrameSetEdit * edit = currentTextEdit();
5809 TQString mode = viewMode()->type();
5811 bool isEditableFrameset = edit && edit->frameSet() && edit->frameSet()->isMainFrameset();
5812 bool ok = rw && isEditableFrameset && (mode!=
"ModeText");
5813 m_actionInsertFootEndNote->setEnabled( ok );
5814 m_actionEditFootEndNote->setEnabled( ok );
5817void KWView::changeFootNoteMenuItem(
bool footnote)
5819 m_actionEditFootEndNote->setText( footnote? i18n(
"Edit Footnote"): i18n(
"Edit Endnote"));
5820 m_actionChangeFootNoteType->setText( footnote? i18n(
"Change Footnote Parameter"):i18n(
"Change Endnote Parameter"));
5823void KWView::slotUpdateRuler()
5825 KWCanvas* canvas = m_gui->canvasWidget();
5826 TQRect r( canvas->viewMode()->rulerFrameRect() );
5829 m_gui->getHorzRuler()->setFrameStartEnd( r.left(), r.right() );
5830 m_gui->getVertRuler()->setFrameStartEnd( r.top(), r.bottom() );
5832 canvas->updateRulerOffsets();
5835void KWView::frameSelectedChanged()
5837 bool rw = koDocument()->isReadWrite();
5838 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
5840 m_actionFormatFrameSet->setEnabled( selectedFrames.count() >= 1 );
5841 if ( rw && selectedFrames.count() >= 1 )
5843 bool okForDelete =
true;
5844 bool okForCopy =
true;
5845 bool okForLowerRaise =
false;
5846 bool okForChangeParagStyle =
true;
5847 bool okForChangeInline =
true;
5848 bool containsCellFrame =
false;
5849 bool containsMainFrame =
false;
5851 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
5852 while(framesIterator != selectedFrames.end() && (okForDelete || okForLowerRaise ||
5853 okForChangeParagStyle || okForChangeInline) ) {
5855 bool isFootNote = (*framesIterator)->frame()->frameSet()->isFootEndNote();
5856 bool headerFooterFootNote = isFootNote ||
5857 (*framesIterator)->frame()->frameSet()->isHeaderOrFooter();
5858 bool isMainWPFrame = (*framesIterator)->frame()->frameSet()->isMainFrameset();
5859 okForChangeParagStyle &= !isFootNote;
5860 okForCopy &= !headerFooterFootNote;
5862 okForDelete &= !headerFooterFootNote;
5863 okForDelete &= !isMainWPFrame;
5868 okForLowerRaise |= !(isMainWPFrame || headerFooterFootNote || (*framesIterator)->frame()->frameSet()->isFloating());
5869 okForChangeInline &= !(isMainWPFrame || headerFooterFootNote );
5871 if ( (*framesIterator)->frame()->frameSet()->groupmanager() )
5872 containsCellFrame =
true;
5873 if ( isMainWPFrame )
5874 containsMainFrame =
true;
5877 m_actionEditDelFrame->setEnabled( okForDelete );
5878 m_actionEditCut->setEnabled( okForDelete && !containsCellFrame );
5879 m_actionEditCopy->setEnabled( selectedFrames.count() >= 1 && okForCopy && !containsMainFrame && !containsCellFrame);
5881 m_actionLowerFrame->setEnabled( okForLowerRaise );
5882 m_actionRaiseFrame->setEnabled( okForLowerRaise );
5883 m_actionSendBackward->setEnabled( okForLowerRaise );
5884 m_actionBringToFront->setEnabled( okForLowerRaise );
5885 m_actionFormatBullet->setEnabled( okForChangeParagStyle );
5886 m_actionFormatNumber->setEnabled( okForChangeParagStyle );
5887 m_actionFormatStyle->setEnabled( okForChangeParagStyle);
5888 m_actionInlineFrame->setEnabled( okForChangeInline);
5890 KWFrame *frame = selectedFrames[0]->frame();
5891 updateBorderButtons(frame->
leftBorder(), frame->rightBorder(), frame->topBorder(),
5892 frame->bottomBorder());
5895 m_actionEditDelFrame->setEnabled(
false );
5896 m_actionInlineFrame->setEnabled(
false);
5897 m_actionEditCut->setEnabled(
false );
5898 m_actionLowerFrame->setEnabled(
false );
5899 m_actionRaiseFrame->setEnabled(
false );
5900 m_actionSendBackward->setEnabled(
false );
5901 m_actionBringToFront->setEnabled(
false );
5904 bool frameDifferentOfPart=
false;
5905 if(selectedFrames.count() >= 1)
5907 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
5908 while(framesIterator != selectedFrames.end()) {
5909 if ( (*framesIterator)->frame()->frameSet()->type()!=FT_PART &&
5910 (*framesIterator)->frame()->frameSet()->type()!= FT_PICTURE) {
5911 frameDifferentOfPart=
true;
5918 m_actionBackgroundColor->setEnabled( (selectedFrames.count() >= 1) && frameDifferentOfPart);
5919 m_actionBackgroundColor->setText(i18n(
"Frame Background Color..."));
5921 if ( frameDifferentOfPart ) {
5922 KWFrame *frame = selectedFrames[0]->frame();
5923 TQColor frameCol=frame->backgroundColor().color();
5925 m_actionBackgroundColor->setCurrentColor( frameCol.isValid()? frame->backgroundColor().color() : TQApplication::palette().color( TQPalette::Active, TQColorGroup::Base ));
5928 m_actionCreateFrameStyle->setEnabled( selectedFrames.count()==1 );
5929 m_actionCreateLinkedFrame->setEnabled( selectedFrames.count()==1 );
5931 updateTableActions( selectedFrames );
5933 updateFrameStatusBarItem();
5935 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5936 if ( !lst.isEmpty() )
5938 TQPtrListIterator<KoTextFormatInterface> it( lst );
5939 KoTextFormat format=*(lst.first()->currentFormat());
5940 showFormat( format );
5942 const KoParagLayout * paragLayout=lst.first()->currentParagLayoutFormat();
5943 KoParagCounter counter;
5944 if(paragLayout->counter)
5945 counter = *(paragLayout->counter);
5946 showCounter( counter );
5947 int align = paragLayout->alignment;
5948 if ( align == TQt::AlignAuto )
5949 align = TQt::AlignLeft;
5951 KoParagLayout::SpacingType spacing=paragLayout->lineSpacingType;
5952 showSpacing( spacing );
5955 m_gui->canvasWidget()->repaintAll(
false);
5959void KWView::updateTableActions( TQValueList<KWFrameView*> selectedFrames)
5961 TableInfo ti(selectedFrames);
5962 KWTableFrameSet *table = m_gui->canvasWidget()->getCurrentTable();
5963 m_actionTableJoinCells->setEnabled( ti.tableCellsSelected());
5964 m_actionConvertTableToText->setEnabled( table && table->
isFloating() );
5966 m_actionTableSplitCells->setEnabled( ti.oneCellSelected() );
5968 m_actionTableInsertRow->setEnabled( ti.amountRowsSelected() );
5969 m_actionTableDelRow->setEnabled( ti.amountRowsSelected() );
5970 m_actionTableInsertCol->setEnabled( ti.amountColumnsSelected() );
5972 if(ti.amountColumnsSelected() == 1)
5973 m_actionTableDelCol->setText(i18n(
"D&elete Current Column..."));
5975 m_actionTableDelCol->setText(i18n(
"D&elete Selected Columns..."));
5976 m_actionTableDelCol->setEnabled( ti.amountColumnsSelected() > 0 );
5977 if(ti.amountRowsSelected() == 1)
5978 m_actionTableDelRow->setText(i18n(
"&Delete Current Row..."));
5980 m_actionTableDelRow->setText(i18n(
"&Delete Selected Rows..."));
5981 m_actionTableDelRow->setEnabled( ti.amountRowsSelected() > 0 );
5983 m_actionTableResizeCol->setEnabled( ti.tableCellsSelected() );
5984 m_actionTableDelete->setEnabled( ti.tableCellsSelected() );
5985 m_actionTablePropertiesMenu->setEnabled( ti.tableCellsSelected() );
5987 m_actionTableUngroup->setEnabled( ti.tableCellsSelected() );
5988 m_actionTableProtectCells->setEnabled( ti.tableCellsSelected() );
5989 m_actionTableProtectCells->setChecked( ti.protectContentEnabled() );
5992void KWView::docStructChanged(
int type)
5994 KWDocStruct *m_pDocStruct=m_gui->getDocStruct();
5996 m_pDocStruct->refreshTree(type);
5997 m_doc->recalcVariables( VT_STATISTIC );
6000void KWView::documentModified(
bool b )
6006 m_sbModifiedLabel->setPixmap( TDEGlobal::iconLoader()->loadIcon(
"action-modified", TDEIcon::Small ) );
6008 m_sbModifiedLabel->setText(
" " );
6011void KWView::changeOverwriteMode(
bool b )
6017 m_sbOverwriteLabel->setText(
' ' + i18n(
"OVER" ) +
' ' );
6019 m_sbOverwriteLabel->setText(
' ' + i18n(
"INSRT" ) +
' ' );
6022void KWView::setViewFrameBorders(
bool b)
6024 m_viewFrameBorders = b;
6026 m_doc->setViewFrameBorders( b );
6029bool KWView::doubleClickActivation()
const
6034TQWidget* KWView::canvas()
const
6039 return m_gui->canvasWidget();
6042int KWView::canvasXOffset()
const
6044 return m_gui->canvasWidget()->contentsX();
6047int KWView::canvasYOffset()
const
6049 return m_gui->canvasWidget()->contentsY();
6052void KWView::canvasAddChild( KoViewChild * child )
6054 connect( m_gui->canvasWidget(), TQ_SIGNAL( viewTransformationsChanged() ),
6055 child, TQ_SLOT( reposition() ) );
6060void KWView::changePicture()
6062 KWFrameView *view = frameViewManager()->selectedFrame();
6063 KWFrame *frame = view == 0 ? 0 : view->
frame();
6066 KWPictureFrameSet *frameset =
static_cast<KWPictureFrameSet *
>(frame->
frameSet());
6067 KoPictureKey oldKey ( frameset->picture().getKey() );
6068 TQString oldFile ( oldKey.filename() );
6070 url.setPath( oldFile );
6071 if (!TQDir(url.directory()).exists())
6072 oldFile = url.fileName();
6074 KoPicture picture ( KWInsertPicDia::selectPictureDia( oldFile,
this ) );
6075 if ( !picture.isNull() )
6077 KWFrameChangePictureCommand *cmd=
new KWFrameChangePictureCommand( i18n(
"Change Picture"), FrameIndex(frame), oldKey, picture.getKey() ) ;
6079 frameset->insertPicture( picture );
6080 m_doc->frameChanged( frame );
6081 m_doc->refreshDocStructure( FT_PICTURE );
6082 m_doc->addCommand(cmd);
6085 kdDebug() <<
"KWView::changePicture cancelled" << endl;
6088void KWView::savePicture()
6090 KWFrameView *view = frameViewManager()->selectedFrame();
6091 KWFrame *frame = view == 0 ? 0 : view->
frame();
6094 KWPictureFrameSet *frameset =
static_cast<KWPictureFrameSet *
>(frame->
frameSet());
6095 TQString oldFile = frameset->picture().getKey().filename();
6097 url.setPath( oldFile );
6098 if ( !TQDir(url.directory()).exists() )
6099 oldFile = url.fileName();
6101 KoPicture picture( frameset->picture() );
6102 TQString mimetype = picture.getMimeType();
6103 kdDebug() <<
"Picture has mime type: " << mimetype << endl;
6104 TQStringList mimetypes;
6105 mimetypes << mimetype;
6106 KFileDialog fd( oldFile, TQString(),
this, 0,
true );
6107 fd.setMimeFilter( mimetypes );
6108 fd.setCaption(i18n(
"Save Picture"));
6109 fd.setOperationMode(KFileDialog::Saving);
6110 if ( fd.exec() == TQDialog::Accepted )
6112 url = fd.selectedURL();
6113 if ( url.isValid() )
6115 if ( url.isLocalFile() )
6117 TQFile file( url.path() );
6118 if ( file.open( IO_ReadWrite ) )
6120 picture.save( &file );
6125 KMessageBox::error(
this,
6126 i18n(
"Error during saving. Could not open '%1' for writing").arg ( url.path() ),
6127 i18n(
"Save Picture"));
6133 tempFile.setAutoDelete(
true );
6134 if ( tempFile.status() == 0 )
6136 TQFile file( tempFile.name() );
6137 if ( file.open( IO_ReadWrite ) )
6139 picture.save( &file );
6141 if ( !TDEIO::NetAccess::upload( tempFile.name(), url,
this ) )
6143 KMessageBox::sorry(
this, i18n(
6144 "Unable to save the file to '%1'. %2.").arg( url.prettyURL() ).arg( TDEIO::NetAccess::lastErrorString() ),
6145 i18n(
"Save Failed") );
6149 KMessageBox::error(
this,
6150 i18n(
"Error during saving. Could not open '%1' temporary file for writing").arg ( file.name() ),
6151 i18n(
"Save Picture"));
6154 KMessageBox::sorry(
this, i18n(
6155 "Error during saving. Could not create temporary file: %1.").arg( strerror( tempFile.status() ) ),
6156 i18n(
"Save Picture") );
6160 KMessageBox::sorry(
this, i18n(
"URL %1 is invalid.").arg( url.prettyURL() ), i18n(
"Save Picture") );
6165void KWView::configureHeaderFooter()
6167 KoPageLayout pgLayout;
6169 KoKWHeaderFooter kwhf;
6170 m_doc->getPageLayout( pgLayout, cl, kwhf );
6172 KWPageLayoutStruct oldLayout( pgLayout, cl, kwhf );
6175 int flags = KW_HEADER_AND_FOOTER;
6176 KoUnit::Unit unit = m_doc->unit();
6177 KoUnit::Unit oldUnit = unit;
6179 if ( KoPageLayoutDia::pageLayout( pgLayout, hf, cl, kwhf, flags, unit ) ) {
6180 if( oldLayout._hf != kwhf )
6182 KWPageLayoutStruct newLayout( pgLayout, cl, kwhf );
6184 KCommand *cmd =
new KWPageLayoutCommand( i18n(
"Change Layout"), m_doc,
6185 oldLayout, newLayout );
6186 m_doc->addCommand(cmd);
6188 m_doc->setPageLayout( pgLayout, cl, kwhf );
6190 if ( unit != oldUnit )
6191 m_doc->setUnit( unit );
6196void KWView::inlineFrame()
6198 KWFrameView *view = frameViewManager()->selectedFrame();
6199 KWFrame *frame = view == 0 ? 0 : view->
frame();
6202 KWFrameSet * fs = frame->
frameSet();
6205 if(m_actionInlineFrame->isChecked())
6208 KMacroCommand* macroCmd =
new KMacroCommand( i18n(
"Make Frameset Inline") );
6209 TQValueList<FrameIndex> frameindexList;
6210 TQValueList<FrameMoveStruct> frameindexMove;
6212 KoPoint initialPos = frame->topLeft();
6214 KWFrameSetInlineCommand *cmd =
new KWFrameSetInlineCommand( i18n(
"Make Frameset Inline"), parentFs,
true );
6217 frameindexList.append( FrameIndex( frame ) );
6218 frameindexMove.append( FrameMoveStruct( initialPos, frame->topLeft() ) );
6220 KWFrameMoveCommand *cmdMoveFrame =
new KWFrameMoveCommand( i18n(
"Move Frame"), frameindexList, frameindexMove );
6222 macroCmd->addCommand(cmdMoveFrame);
6223 macroCmd->addCommand(cmd);
6224 m_doc->addCommand(macroCmd);
6228 KWFrameSetInlineCommand *cmd =
new KWFrameSetInlineCommand( i18n(
"Make Frameset Non-Inline"), parentFs,
false );
6229 m_doc->addCommand(cmd);
6234void KWView::openLink()
6236 KWTextFrameSetEdit * edit = currentTextEdit();
6241void KWView::changeLink()
6243 KWTextFrameSetEdit * edit = currentTextEdit();
6246 KoLinkVariable * var=edit->linkVariable();
6249 TQString oldhref= var->url();
6250 TQString oldLinkName=var->value();
6251 TQString link=oldLinkName;
6252 TQString ref=oldhref;
6253 if(KoInsertLinkDia::createLinkDia(link, ref, m_doc->listOfBookmarkName(0),
true,
this))
6255 if(!link.isEmpty() && !ref.isEmpty())
6257 if( ref != oldhref || link!=oldLinkName)
6259 KWChangeLinkVariable*cmd=
new KWChangeLinkVariable( i18n(
"Change Link"), m_doc,oldhref, ref, oldLinkName,link, var);
6261 m_doc->addCommand(cmd);
6269void KWView::copyLink()
6271 KWTextFrameSetEdit * edit = currentTextEdit();
6276void KWView::removeLink()
6278 KWTextFrameSetEdit * edit = currentTextEdit();
6283void KWView::addToBookmark()
6285 KWTextFrameSetEdit * edit = currentTextEdit();
6288 KoLinkVariable * var=edit->linkVariable();
6291 edit->addBookmarks(var->url());
6296void KWView::showDocStructure()
6298 m_doc->setShowDocStruct(m_actionShowDocStruct->isChecked());
6299 m_doc->reorganizeGUI();
6300 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
6303void KWView::showRuler()
6305 m_doc->setShowRuler( m_actionShowRuler->isChecked());
6306 m_doc->reorganizeGUI();
6307 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
6310void KWView::viewGrid()
6312 m_doc->setShowGrid( m_actionViewShowGrid->isChecked() );
6313 m_doc->setModified(
true );
6314 m_doc->updateGridButton();
6315 m_doc->repaintAllViews(
false);
6318void KWView::viewSnapToGrid()
6320 m_doc->setSnapToGrid( m_actionViewSnapToGrid->isChecked() );
6321 m_doc->setModified(
true );
6322 m_doc->updateGridButton();
6325void KWView::slotSoftHyphen()
6327 KWTextFrameSetEdit * edit = currentTextEdit();
6329 edit->insertSoftHyphen();
6332void KWView::slotNonbreakingSpace()
6334 KWTextFrameSetEdit * edit = currentTextEdit();
6336 edit->insertNonbreakingSpace();
6339void KWView::slotNonbreakingHyphen()
6341 KWTextFrameSetEdit * edit = currentTextEdit();
6343 edit->insertNonbreakingHyphen();
6346void KWView::slotLineBreak()
6348 KWTextFrameSetEdit * edit = currentTextEdit();
6350 edit->insertLineBreak();
6353void KWView::slotIncreaseNumberingLevel()
6355 KWTextFrameSetEdit * edit = currentTextEdit();
6357 edit->increaseNumberingLevel( m_doc->styleCollection() );
6360void KWView::slotDecreaseNumberingLevel()
6362 KWTextFrameSetEdit * edit = currentTextEdit();
6364 edit->decreaseNumberingLevel( m_doc->styleCollection() );
6367void KWView::refreshAllVariable()
6369 m_doc->recalcVariables( VT_ALL );
6372void KWView::slotAllowAutoFormat()
6374 bool state = m_actionAllowAutoFormat->isChecked();
6375 m_doc->setAllowAutoFormat( state );
6378void KWView::slotCompletion()
6380 KWTextFrameSetEdit * edit = currentTextEdit();
6385void KWView::updateHeaderFooterButton()
6387 m_actionViewHeader->setChecked(m_doc->isHeaderVisible());
6388 m_actionViewFooter->setChecked(m_doc->isFooterVisible());
6391void KWView::editComment()
6393 KWTextFrameSetEdit * edit = currentTextEdit();
6396 KoVariable * tmpVar=edit->variable();
6397 KoNoteVariable * var =
dynamic_cast<KoNoteVariable *
>(tmpVar);
6400 TQString authorName;
6401 KoDocumentInfo * info = m_doc->documentInfo();
6402 KoDocumentInfoAuthor * authorPage =
static_cast<KoDocumentInfoAuthor *
>(info->page(
"author" ));
6404 kdWarning() <<
"Author information not found in documentInfo !" << endl;
6406 authorName = authorPage->fullName();
6407 TQString oldValue = var->note();
6408 TQString createDate = var->createdNote();
6409 KoCommentDia *commentDia =
new KoCommentDia(
this, oldValue, authorName, createDate);
6410 if( commentDia->exec() )
6412 if ( oldValue != commentDia->commentText())
6414 KWChangeVariableNoteText *cmd =
new KWChangeVariableNoteText( i18n(
"Change Note Text"), m_doc, oldValue,commentDia->commentText(), var);
6415 m_doc->addCommand( cmd );
6424void KWView::fileStatistics()
6426 KWStatisticsDialog *statisticsDialog =
new KWStatisticsDialog(
this, m_doc );
6427 if ( !statisticsDialog->wasCanceled() )
6428 statisticsDialog->exec();
6429 delete statisticsDialog;
6432void KWView::removeComment()
6434 KWTextFrameSetEdit * edit = currentTextEdit();
6437 edit->removeComment();
6441void KWView::copyTextOfComment()
6443 KWTextFrameSetEdit * edit = currentTextEdit();
6446 edit->copyTextOfComment();
6450void KWView::configureCompletion()
6452 m_doc->autoFormat()->readConfig();
6453 KoCompletionDia dia(
this, 0, m_doc->autoFormat() );
6457void KWView::applyAutoFormat()
6459 m_doc->autoFormat()->readConfig();
6460 KMacroCommand *macro = 0L;
6461 TQValueList<KoTextObject *> list(m_doc->visibleTextObjects(viewMode()));
6462 TQValueList<KoTextObject *>::Iterator fit = list.begin();
6463 for ( ; fit != list.end() ; ++fit )
6465 KCommand *cmd = m_doc->autoFormat()->applyAutoFormat( *fit );
6469 macro =
new KMacroCommand( i18n(
"Apply Autoformat"));
6470 macro->addCommand( cmd );
6474 m_doc->addCommand( macro );
6477void KWView::createStyleFromSelection()
6479 KWTextFrameSetEdit * edit = currentTextEdit();
6482 KoStyleCollection* coll = m_doc->styleCollection();
6483 KoCreateStyleDia *dia =
new KoCreateStyleDia( TQStringList(),
this, 0 );
6486 TQString name = dia->nameOfNewStyle();
6487 KoParagStyle* style = coll->findStyleByDisplayName( name );
6491 edit->updateStyleFromSelection( style );
6495 style = edit->createStyleFromSelection( name );
6496 m_doc->styleCollection()->addStyle( style );
6497 m_doc->updateAllStyleLists();
6506void KWView::switchModeView()
6508 KWCanvas* canvas = m_gui->canvasWidget();
6512 TQString mode = canvas->viewMode()->type();
6513 bool isTextMode = mode ==
"ModeText";
6514 bool state = !isTextMode;
6515 m_actionToolsCreateText->setEnabled(state);
6516 m_actionToolsCreatePix->setEnabled(state);
6517 m_actionToolsCreatePart->setEnabled(state);
6518 m_actionInsertFormula->setEnabled(state);
6519 m_actionInsertTable->setEnabled(state);
6520 changeFootEndNoteState();
6521 m_actionViewFooter->setEnabled( state && m_doc->processingType() == KWDocument::WP );
6522 m_actionViewHeader->setEnabled( state && m_doc->processingType() == KWDocument::WP );
6524 m_actionShowDocStruct->setEnabled(state);
6525 m_actionFormatPage->setEnabled(state);
6526 m_actionInsertContents->setEnabled( state );
6527 m_actionFrameStyle->setEnabled( state );
6528 m_actionTableStyle->setEnabled ( state );
6529 m_actionViewShowGrid->setEnabled( state );
6530 m_actionViewSnapToGrid->setEnabled( mode ==
"ModeNormal" || mode ==
"ModeEmbedded" );
6531 if ( m_gui->getHorzRuler())
6533 m_gui->getHorzRuler()->setPageLayoutMenuItemEnabled( state );
6534 if ( !koDocument()->isReadWrite())
6535 m_gui->getHorzRuler()->changeFlags( KoRuler::F_NORESIZE );
6539 m_gui->getHorzRuler()->changeFlags( m_gui->getHorzRuler()->flags() & ~(KoRuler::F_NORESIZE) );
6541 m_gui->getHorzRuler()->changeFlags( m_gui->getHorzRuler()->flags() | KoRuler::F_NORESIZE );
6544 if ( m_gui->getVertRuler() )
6546 m_gui->getVertRuler()->setPageLayoutMenuItemEnabled( state );
6547 if ( !koDocument()->isReadWrite())
6548 m_gui->getVertRuler()->changeFlags( KoRuler::F_NORESIZE );
6552 m_gui->getVertRuler()->changeFlags( m_gui->getVertRuler()->flags() & ~(KoRuler::F_NORESIZE) );
6554 m_gui->getVertRuler()->changeFlags( m_gui->getVertRuler()->flags() | KoRuler::F_NORESIZE );
6561 if ( m_doc->showdocStruct() )
6563 m_doc->setShowDocStruct(
false);
6564 m_doc->reorganizeGUI();
6569 m_doc->setShowDocStruct(m_actionShowDocStruct->isChecked());
6570 m_doc->reorganizeGUI();
6575 m_doc->recalcVariables( VT_PGNUM );
6579 canvas->editFrameSet(
static_cast<KWViewModeText*
>(canvas->viewMode())->textFrameSet() );
6583 updateZoomControls();
6587 canvas->viewMode()->setPageLayout( m_gui->getHorzRuler(), m_gui->getVertRuler(), m_doc->pageLayout() );
6590void KWView::configureFootEndNote()
6592 KWConfigFootNoteDia *dia =
new KWConfigFootNoteDia(
this,
"configfootnote", m_doc );
6597void KWView::editFootEndNote()
6599 KWTextFrameSetEdit * edit = currentTextEdit();
6602 KWFootNoteVariable * var =
dynamic_cast<KWFootNoteVariable *
>( edit->variable() );
6605 m_gui->canvasWidget()->editFrameSet( var->
frameSet() );
6606 KWTextFrameSetEdit* textedit = currentTextEdit();
6608 textedit->ensureCursorVisible();
6613void KWView::changeFootNoteType()
6615 KWTextFrameSetEdit * edit = currentTextEdit();
6618 KoVariable * tmpVar=edit->variable();
6619 KWFootNoteVariable * var =
dynamic_cast<KWFootNoteVariable *
>(tmpVar);
6622 KWFootNoteDia dia( var->noteType(), var->numberingType(), (var->numberingType()==KWFootNoteVariable::Auto) ? TQString() : var->manualString(),
this, m_doc, 0 );
6623 TQPtrListIterator<KoTextCustomItem> it( edit->textDocument()->allCustomItems() );
6624 for ( ; it.current() ; ++it )
6626 KWFootNoteVariable *fnv =
dynamic_cast<KWFootNoteVariable *
>( it.current() );
6628 fnv->numberingType()==KWFootNoteVariable::Manual && fnv != var)
6629 dia.appendManualFootNote( fnv->text() );
6633 FootNoteParameter oldParam( var );
6634 FootNoteParameter newParam(dia.noteType(), dia.numberingType(), dia.manualString() );
6635 KWChangeFootNoteParametersCommand * cmd =
new KWChangeFootNoteParametersCommand( i18n(
"Change Footnote Parameters"), var , oldParam, newParam, m_doc);
6637 m_doc->addCommand ( cmd );
6644void KWView::autoSpellCheck()
6646 autoSpellCheck( m_actionAllowBgSpellCheck->isChecked() );
6649void KWView::autoSpellCheck(
bool b)
6651 m_doc->changeBgSpellCheckingState( b );
6654void KWView::goToFootEndNote()
6656 KWFrameView *view = frameViewManager()->selectedFrame();
6657 KWFrame *frame = view == 0 ? 0 : view->
frame();
6660 KWFootNoteFrameSet *footNoteFrameSet =
dynamic_cast<KWFootNoteFrameSet *
>(frame->
frameSet());
6661 if ( footNoteFrameSet )
6663 KWFootNoteVariable* var=footNoteFrameSet->footNoteVariable();
6664 KoTextParag *parag = var->paragraph();
6665 int index = var->index();
6666 KWTextDocument *textDoc =
static_cast<KWTextDocument *
>(var->textDocument());
6668 m_gui->canvasWidget()->editTextFrameSet( frameSet, parag, index );
6674 bool rw = koDocument()->isReadWrite();
6675 bool kttsdInstalled = KoSpeaker::isKttsdInstalled();
6676 if (!rw && !kttsdInstalled)
6678 bool hasText = (frameset->
type()==FT_TEXT || frameset->
type()==FT_TABLE || frameset->
type()==FT_FORMULA );
6680 m_actionDocStructEdit->setEnabled( rw && hasText );
6681 m_actionDocStructDelete->setEnabled( (rw && !parag && !frameset->isMainFrameset() &&
6682 !frameset->isFootEndNote() && !frameset->isHeaderOrFooter()) );
6683 m_actionDocStructSpeak->setEnabled( hasText && kttsdInstalled );
6685 TQPopupMenu* popup =
static_cast<TQPopupMenu *
>(factory()->container(
"docstruct_popup",
this));
6690void KWView::docStructSelect()
6692 if ( m_gui->getDocStruct() )
6694 m_gui->getDocStruct()->selectItem();
6698void KWView::docStructEdit()
6700 if ( m_gui->getDocStruct() )
6702 m_gui->getDocStruct()->editItem();
6704 m_gui->canvasWidget()->setFocus();
6708void KWView::docStructProperties()
6710 if ( m_gui->getDocStruct() )
6712 m_gui->getDocStruct()->editProperties();
6716void KWView::docStructDelete()
6718 if ( m_gui->getDocStruct() )
6720 m_gui->getDocStruct()->deleteItem();
6724void KWView::docStructSpeak()
6726 if ( m_gui->getDocStruct() )
6728 m_gui->getDocStruct()->speakItem();
6732void KWView::insertFile()
6734 KFileDialog fd( TQString(), TQString(),
this, 0,
true );
6735 fd.setMimeFilter(
"application/x-kword" );
6736 fd.setCaption(i18n(
"Insert File"));
6738 if ( fd.exec() != TQDialog::Accepted )
6740 url = fd.selectedURL();
6743 KMessageBox::sorry(
this,
6744 i18n(
"File name is empty."),
6745 i18n(
"Insert File"));
6751void KWView::insertFile(
const KURL& url)
6753 KMacroCommand* macroCmd = 0L;
6754 bool hasFixedFramesets =
false;
6755 KoStore* store=KoStore::createStore(
this, url, KoStore::Read );
6761 TQString maindoc =
"maindoc.xml";
6766 bool b = store->open(maindoc);
6769 KMessageBox::sorry(
this,
6770 i18n(
"This file is not a KWord file!"),
6771 i18n(
"Insert File"));
6777 doc.setContent( store->device() );
6778 TQDomElement word = doc.documentElement();
6780 m_doc->loadPictureMap( word );
6782 m_doc->loadImagesFromStore( store );
6786 bool b = store->open(maindoc);
6789 KMessageBox::sorry(
this,
6790 i18n(
"File name is not a KWord file!"),
6791 i18n(
"Insert File"));
6796 doc.setContent( store->device() );
6797 TQDomElement word = doc.documentElement();
6799 TQDomElement framesets = word.namedItem(
"FRAMESETS" ).toElement();
6800 if ( !framesets.isNull() )
6802 TQDomElement framesetElem = framesets.firstChild().toElement();
6804 while ( !framesetElem.isNull() && framesetElem.tagName() !=
"FRAMESET" )
6805 framesetElem = framesetElem.nextSibling().toElement();
6807 if ( !framesetElem.isNull() )
6809 KWTextFrameSet *textFrameSet =
dynamic_cast<KWTextFrameSet *
>( m_doc->frameSet(0) );
6810 KoTextCursor insertionCursor( textFrameSet->textDocument() );
6811 KWTextFrameSetEdit* edit = currentTextEdit();
6812 if ( edit && !edit->textFrameSet()->protectContent()) {
6813 textFrameSet = edit->textFrameSet();
6814 insertionCursor = *edit->cursor();
6817 TQDomDocument domDoc(
"PARAGRAPHS" );
6818 TQDomElement paragsElem = domDoc.createElement(
"PARAGRAPHS" );
6819 domDoc.appendChild( paragsElem );
6823 TQValueList<TQDomElement> paragList;
6824 TQValueList<TQString> inlineFsNames;
6825 TQDomElement fsElem;
6827 TQDomNode n = framesetElem.firstChild().toElement();
6828 while( !n.isNull() )
6830 TQDomElement e = n.toElement();
6831 if ( !e.isNull() && e.tagName() ==
"PARAGRAPH" )
6833 paragList.append( e );
6835 TQDomElement formatsElem = e.namedItem(
"FORMATS" ).toElement();
6836 if ( !formatsElem.isNull() )
6839 TQDomElement formatElem = formatsElem.firstChild().toElement();
6840 for ( ; !formatElem.isNull() ; formatElem = formatElem.nextSibling().toElement() )
6842 TQDomElement anchorElem = formatElem.namedItem(
"ANCHOR" ).toElement();
6843 if ( !anchorElem.isNull() )
6845 TQString type = anchorElem.attribute(
"type" );
6846 if ( type ==
"grpMgr" || type ==
"frameset" )
6848 TQString iName = anchorElem.attribute(
"instance" );
6849 inlineFsNames.append( iName );
6853 fsElem = framesetElem.nextSibling().toElement();
6854 for ( ; !fsElem.isNull() ; fsElem = fsElem.nextSibling().toElement() )
6856 if ( fsElem.tagName() ==
"FRAMESET" )
6858 TQString name = fsElem.attribute(
"name" );
6859 TQString grpMgr = fsElem.attribute(
"grpMgr" );
6860 if ( name == iName )
6862 paragList.append( fsElem );
6865 else if ( grpMgr == iName )
6867 if ( grpMgr != tableName )
6870 table = domDoc.createElement(
"FRAMESET");
6871 table.setAttribute(
"frameType", FT_TABLE);
6872 table.setAttribute(
"frameInfo", 0);
6873 table.setAttribute(
"protectSize", fsElem.attribute(
"protectSize",
"0"));
6874 table.setAttribute(
"name", tableName);
6875 table.setAttribute(
"visible", fsElem.attribute(
"visible",
"1"));
6876 paragList.append( table );
6880 table.appendChild( fsElem.cloneNode() );
6893 n = n.nextSibling();
6896 TQValueList<TQDomElement>::Iterator it = paragList.begin();
6897 TQValueList<TQDomElement>::Iterator end = paragList.end();
6898 for ( ; it!= end ; ++it )
6901 paragsElem.appendChild( *it );
6907 TQDomDocument domDocFrames(
"SELECTION" );
6908 TQDomElement topElem = domDocFrames.createElement(
"SELECTION" );
6909 domDocFrames.appendChild( topElem );
6912 TQValueList<TQString> fsInHeader;
6913 TQValueList<TQDomElement> framesetsList;
6915 framesetElem = framesetElem.nextSibling().toElement();
6916 for ( ; !framesetElem.isNull() ; framesetElem = framesetElem.nextSibling().toElement() )
6918 if ( framesetElem.tagName() ==
"FRAMESET" )
6920 FrameSetType frameSetType =
static_cast<FrameSetType
>( KWDocument::getAttribute( framesetElem,
"frameType", FT_BASE ) );
6922 if ( frameSetType == FT_TEXT &&
6923 (info == KWFrameSet::FI_FIRST_HEADER ||
6924 info == KWFrameSet::FI_EVEN_HEADER ||
6925 info == KWFrameSet::FI_ODD_HEADER ||
6926 info == KWFrameSet::FI_FIRST_FOOTER ||
6927 info == KWFrameSet::FI_EVEN_FOOTER ||
6928 info == KWFrameSet::FI_ODD_FOOTER)
6930 fsInHeader += getInlineFramesets( framesetElem );
6932 TQString name = framesetElem.attribute(
"name" );
6933 TQString grpMgr = framesetElem.attribute(
"grpMgr" );
6934 if ( !inlineFsNames.contains(name) && !inlineFsNames.contains(grpMgr) )
6936 if ( !grpMgr.isEmpty() )
6938 if ( grpMgr != tableName )
6941 table = domDocFrames.createElement(
"FRAMESET");
6942 table.setAttribute(
"frameType", FT_TABLE);
6943 table.setAttribute(
"frameInfo", 0);
6944 table.setAttribute(
"protectSize", framesetElem.attribute(
"protectSize",
"0"));
6945 table.setAttribute(
"name", tableName);
6946 table.setAttribute(
"visible", framesetElem.attribute(
"visible",
"1"));
6947 framesetsList.append( table );
6950 table.appendChild( framesetElem.cloneNode() );
6955 framesetsList.append( framesetElem );
6963 it = framesetsList.begin();
6964 end = framesetsList.end();
6965 for ( ; it != end ; ++it )
6967 framesetElem = (*it);
6968 FrameSetType frameSetType =
static_cast<FrameSetType
>( KWDocument::getAttribute( framesetElem,
"frameType", FT_BASE ) );
6970 TQString name = framesetElem.attribute(
"name");
6971 TQString grpMgr = framesetElem.attribute(
"grpMgr" );
6973 if ( !fsInHeader.contains(name) && !fsInHeader.contains(grpMgr) &&
6974 !( frameSetType == FT_TEXT &&
6975 (info == KWFrameSet::FI_FIRST_HEADER ||
6976 info == KWFrameSet::FI_EVEN_HEADER ||
6977 info == KWFrameSet::FI_ODD_HEADER ||
6978 info == KWFrameSet::FI_FIRST_FOOTER ||
6979 info == KWFrameSet::FI_EVEN_FOOTER ||
6980 info == KWFrameSet::FI_ODD_FOOTER) )
6983 hasFixedFramesets =
true;
6984 topElem.appendChild( framesetElem );
6988 TQDomDocument embeddedDoc(
"SELECTION" );
6989 TQDomElement selElem = embeddedDoc.createElement(
"SELECTION" );
6990 embeddedDoc.appendChild( selElem );
6992 TQValueList<TQDomElement> embeddedList;
6993 TQDomElement embeddedElem = word.namedItem(
"EMBEDDED" ).toElement();
6994 for ( ; !embeddedElem.isNull() ; embeddedElem = embeddedElem.nextSibling().toElement() )
6996 if ( embeddedElem.tagName() ==
"EMBEDDED" )
6998 embeddedList.append( embeddedElem );
7001 it = embeddedList.begin();
7002 end = embeddedList.end();
7003 bool hasEmbedded =
false;
7004 for ( ; it!= end ; ++it )
7006 selElem.appendChild( *it );
7014 macroCmd =
new KMacroCommand( i18n(
"Insert File") );
7016 if ( hasFixedFramesets )
7020 m_doc->pasteFrames( topElem, macroCmd,
false,
false,
false );
7026 macroCmd =
new KMacroCommand( i18n(
"Insert File") );
7027 m_doc->insertEmbedded( store, selElem, macroCmd, 0 );
7031 KCommand *cmd = textFrameSet->pasteOasis( &insertionCursor, domDoc.toCString(),
true );
7034 macroCmd->addCommand( cmd );
7036 m_doc->addCommand( macroCmd );
7041 m_doc->loadImagesFromStore( store );
7042 m_doc->completePasting();
7048TQValueList<TQString> KWView::getInlineFramesets(
const TQDomNode &framesetElem)
7051 TQValueList<TQString> list;
7052 TQDomNode n = framesetElem.firstChild().toElement();
7053 for( ; !n.isNull(); n = n.nextSibling() )
7055 TQDomElement e = n.toElement();
7056 if ( !e.isNull() && e.tagName() ==
"PARAGRAPH" )
7058 TQDomElement formatsElem = e.namedItem(
"FORMATS" ).toElement();
7059 if ( !formatsElem.isNull() )
7062 TQDomElement formatElem = formatsElem.firstChild().toElement();
7063 for ( ; !formatElem.isNull() ; formatElem = formatElem.nextSibling().toElement() )
7065 TQDomElement anchorElem = formatElem.namedItem(
"ANCHOR" ).toElement();
7066 if ( !anchorElem.isNull() )
7068 TQString type = anchorElem.attribute(
"type" );
7069 if ( type ==
"grpMgr" || type ==
"frameset" )
7071 TQString iName = anchorElem.attribute(
"instance" );
7072 list.append( iName );
7083void KWView::addBookmark()
7085 KWTextFrameSetEdit * edit = currentTextEdit();
7089 KWCreateBookmarkDia dia( m_doc->listOfBookmarkName(0L),
this, 0 );
7091 TQString bookName = dia.bookmarkName();
7092 KoTextCursor start, end;
7093 if ( edit->textDocument()->hasSelection( KoTextDocument::Standard ) ) {
7094 start = edit->textDocument()->selectionStartCursor( KoTextDocument::Standard );
7095 end = edit->textDocument()->selectionEndCursor( KoTextDocument::Standard );
7097 start = *edit->cursor();
7100 int startSel = start.index();
7101 int endSel = end.index();
7102 m_doc->insertBookmark(bookName, start.parag(),end.parag(), startSel, endSel);
7107void KWView::selectBookmark()
7109 KWSelectBookmarkDia dia( m_doc->listOfBookmarkName(viewMode()), m_doc,
this, 0 );
7111 TQString bookName = dia.bookmarkSelected();
7112 const KoTextBookmark * book = m_doc->bookmarkByName( bookName );
7116 Q_ASSERT( book->startParag() );
7117 Q_ASSERT( book->endParag() );
7118 if ( !book->startParag() || !book->endParag() )
7120 KWTextFrameSet* textfs =
static_cast<KWTextDocument *
>( book->textDocument() )->textFrameSet();
7121 m_gui->canvasWidget()->editTextFrameSet( textfs, book->startParag(), book->bookmarkStartIndex() );
7122 KWTextFrameSetEdit * edit = currentTextEdit();
7126 edit->textDocument()->removeSelection( KoTextDocument::Standard );
7127 edit->textDocument()->setSelectionStart( KoTextDocument::Standard, edit->cursor() );
7128 edit->cursor()->setParag( book->endParag());
7129 edit->cursor()->setIndex(book->bookmarkEndIndex() );
7130 edit->textDocument()->setSelectionEnd( KoTextDocument::Standard, edit->cursor() );
7131 book->startParag()->setChanged(
true );
7132 book->endParag()->setChanged(
true );
7133 m_doc->slotRepaintChanged( edit->frameSet() );
7139void KWView::importStyle()
7141 KWImportStyleDia dia( m_doc, m_doc->styleCollection(),
this );
7142 if ( dia.exec() && !dia.importedStyles().isEmpty() ) {
7143 m_doc->styleCollection()->importStyles( dia.importedStyles() );
7144 m_doc->setModified(
true );
7145 m_doc->updateAllStyleLists();
7149void KWView::testAndCloseAllFrameSetProtectedContent()
7151 KWTextFrameSetEdit* edit = currentTextEdit();
7152 if ( edit && edit->textFrameSet()->protectContent()) {
7153 m_doc->terminateEditing( edit->frameSet());
7157void KWView::updateRulerInProtectContentMode()
7159 KWTextFrameSetEdit* edit = currentTextEdit();
7160 KoRuler * hRuler = m_gui ? m_gui->getHorzRuler() : 0;
7162 if ( edit && hRuler) {
7163 if ( !edit->textFrameSet()->protectContent() )
7164 hRuler->changeFlags(KoRuler::F_INDENTS | KoRuler::F_TABS);
7166 hRuler->changeFlags(0);
7171void KWView::deselectAllFrames()
7173 m_gui->canvasWidget()->selectAllFrames(
false );
7176void KWView::insertDirectCursor()
7179 insertDirectCursor( m_actionInsertDirectCursor->isChecked());
7183void KWView::insertDirectCursor(
bool b)
7185 m_doc->setInsertDirectCursor(b);
7188void KWView::updateDirectCursorButton()
7191 m_actionInsertDirectCursor->setChecked(m_doc->insertDirectCursor());
7195void KWView::convertTableToText()
7197 KWCanvas * canvas = m_gui->canvasWidget();
7198 KWTableFrameSet *table = canvas->getCurrentTable();
7201 const TQByteArray arr = table->convertTableToText();
7203 if ( anchor && arr.size() )
7206 KoTextParag *parag = anchor->paragraph();
7207 int pos = anchor->index();
7208 KMacroCommand *macro =
new KMacroCommand(i18n(
"Convert Table to Text"));
7209 KCommand *cmd = table->
anchorFrameset()->deleteAnchoredFrame( anchor );
7211 macro->addCommand( cmd);
7213 m_gui->canvasWidget()->editTextFrameSet( frameset, parag, pos );
7215 KWTextFrameSetEdit* edit = currentTextEdit();
7216 if ( edit && edit->textFrameSet())
7218 cmd = edit->textFrameSet()->pasteOasis( edit->cursor(), arr,
true );
7220 macro->addCommand( cmd );
7222 m_doc->addCommand(macro);
7227void KWView::convertToTextBox()
7229 KWTextFrameSetEdit* edit = currentTextEdit();
7233 KWTextFrameSet* textfs = edit->textFrameSet();
7234 if( textfs->protectContent() || !textfs->
textObject()->hasSelection() )
7237 KWOasisSaver oasisSaver( m_doc );
7238 textfs->textDocument()->copySelection( oasisSaver.bodyWriter(), oasisSaver.savingContext(), KoTextDocument::Standard );
7239 if ( !oasisSaver.finish() )
7241 const TQByteArray arr = oasisSaver.data();
7245 KCommand *cmd = textfs->
textObject()->removeSelectedTextCommand( edit->textView()->cursor(), KoTextDocument::Standard );
7247 KMacroCommand* macro =
new KMacroCommand( i18n(
"Convert to Text Box"));
7248 macro->addCommand( cmd );
7250 cmd = m_gui->canvasWidget()->createTextBox( KoRect(30,30,300,300) );
7253 macro->addCommand( cmd );
7255 edit = currentTextEdit();
7259 cmd = edit->textFrameSet()->pasteOasis( edit->textView()->cursor(), arr,
true );
7261 macro->addCommand( cmd );
7263 edit->textFrameSet()->
layout();
7265 m_doc->addCommand( macro );
7268void KWView::slotAddIgnoreAllWord()
7270 KWTextFrameSetEdit* edit = currentTextEdit();
7272 m_doc->addSpellCheckIgnoreWord( edit->currentWordOrSelection() );
7275void KWView::sortText()
7277 KWTextFrameSetEdit* edit = currentTextEdit();
7280 KWSortDia dlg(
this,
"sort dia" );
7283 const TQByteArray arr = edit->textFrameSet()->
sortText(dlg.getSortType());
7286 KCommand *cmd = edit->textFrameSet()->pasteOasis( edit->cursor(), arr,
true );
7288 m_doc->addCommand(cmd);
7294void KWView::addPersonalExpression()
7296 KWTextFrameSetEdit* edit = currentTextEdit();
7300 TQString newExpression = edit->textFrameSet()->
textObject()->selectedText();
7302 TQString tmp=locateLocal(
"data",
"kword/expression/perso.xml");
7304 if ( !file.open( IO_ReadOnly ) )
7307 doc.setContent( &file );
7311 TQMap<TQString, TQStringList>lstOfPersonalExp;
7313 TQDomNode n = doc.documentElement().firstChild();
7314 for( ; !n.isNull(); n = n.nextSibling() )
7316 if ( n.isElement() )
7318 TQDomElement e = n.toElement();
7319 if ( e.tagName() ==
"Type" )
7322 group = i18n( e.namedItem(
"TypeName" ).toElement().text().utf8() );
7324 TQDomNode n2 = e.firstChild();
7325 for( ; !n2.isNull(); n2 = n2.nextSibling() )
7328 if ( n2.isElement() )
7330 TQDomElement e2 = n2.toElement();
7331 if ( e2.tagName() ==
"Expression" )
7333 TQString text = i18n( e2.namedItem(
"Text" ).toElement().text().utf8() );
7338 lstOfPersonalExp.insert(group,list);
7344 doc = TQDomDocument(
"KWordExpression" );
7345 TQDomElement begin = doc.createElement(
"KWordExpression" );
7346 doc.appendChild( begin );
7347 TQMapIterator<TQString, TQStringList> itPersonalExp = lstOfPersonalExp.find(i18n(
"Normal"));
7348 if ( itPersonalExp != lstOfPersonalExp.end())
7350 list = itPersonalExp.data();
7351 list<<newExpression;
7352 lstOfPersonalExp.replace( i18n(
"Normal"), list);
7357 list<<newExpression;
7358 lstOfPersonalExp.insert( i18n(
"Normal"), list);
7362 itPersonalExp = lstOfPersonalExp.begin();
7363 for ( ; itPersonalExp != lstOfPersonalExp.end(); ++itPersonalExp )
7365 TQDomElement type = doc.createElement(
"Type" );
7366 begin.appendChild( type );
7367 TQDomElement typeName = doc.createElement(
"TypeName" );
7368 type.appendChild( typeName );
7369 typeName.appendChild( doc.createTextNode(itPersonalExp.key() ) );
7370 list=itPersonalExp.data();
7371 for( uint i=0;i<list.count();i++ )
7373 TQDomElement expr = doc.createElement(
"Expression" );
7374 type.appendChild( expr );
7375 TQDomElement text = doc.createElement(
"Text" );
7376 expr.appendChild( text );
7377 text.appendChild( doc.createTextNode(list[i] ) );
7380 TQCString s = doc.toCString();
7382 if ( !file.open( IO_WriteOnly ) )
7384 kdDebug()<<
"Error in addPersonalExpression()\n";
7387 file.writeBlock(s,s.length());
7389 m_doc->refreshMenuExpression();
7392void KWView::addWordToDictionary()
7394 KWTextFrameSetEdit* edit = currentTextEdit();
7397 TQString word = edit->wordUnderCursor( *edit->cursor() );
7398 if ( !word.isEmpty() )
7399 m_doc->addWordToDictionary( word );
7403void KWView::embeddedStoreInternal()
7405 kdDebug(31001)<<k_funcinfo<<endl;
7406 KWFrameView *view = frameViewManager()->selectedFrame();
7407 KWFrame *frame = view == 0 ? 0 : view->
frame();
7410 KWPartFrameSet *part =
static_cast<KWPartFrameSet *
>(frame->
frameSet());
7411 part->storeInternal();
7414void KWView::goToDocumentStructure()
7416 KWDocStruct* docStruct = getGUI()->getDocStruct();
7417 if (docStruct) docStruct->setFocusHere();
7420void KWView::goToDocument()
7422 KWCanvas* canvas = getGUI()->canvasWidget();
7423 if (!canvas)
return;
7427void KWView::deleteFrameSet(
KWFrameSet * frameset)
7429 if ( frameset && frameset->
frame(0))
7431 frameViewManager()->view(frameset->
frame(0))->setSelected(
true );
7436TQPtrList<TDEAction> KWView::listOfResultOfCheckWord(
const TQString &word )
7438 TQPtrList<TDEAction> listAction;
7439 DefaultDictionary *dict = m_broker->defaultDictionary();
7440 const TQStringList lst = dict->suggest( word );
7441 if ( !lst.contains( word ) )
7443 TQStringList::ConstIterator it = lst.begin();
7444 const TQStringList::ConstIterator end = lst.end();
7445 for ( ; it != end ; ++it )
7447 if ( !(*it).isEmpty() )
7449 TDEAction * act =
new TDEAction( *it );
7450 connect( act, TQ_SIGNAL(activated()),
this, TQ_SLOT(slotCorrectWord()) );
7451 listAction.append( act );
7458void KWView::slotCorrectWord()
7460 TDEAction * act = (TDEAction *)(sender());
7461 KWTextFrameSetEdit* edit = currentTextEdit();
7464 edit->selectWordUnderCursor( *(edit->cursor()) );
7465 m_doc->addCommand( edit->textObject()->replaceSelectionCommand( edit->cursor(), act->text(), i18n(
"Replace Word") ));
7469void KWView::slotChildActivated(
bool a )
7472 KoViewChild* ch = child( (KoView*)sender() );
7475 KWDocumentChild* kwchild =
static_cast<KWDocumentChild *
>( ch->documentChild() );
7476 KWPartFrameSet* fs = kwchild->partFrameSet();
7485 KoView::slotChildActivated( a );
7488Broker *KWView::broker()
const
7493void KWView::slotUnitChanged( KoUnit::Unit unit )
7495 getGUI()->getHorzRuler()->setUnit( unit );
7496 getGUI()->getVertRuler()->setUnit( unit );
7497 if ( m_sbUnitLabel )
7498 m_sbUnitLabel->setText(
' ' + KoUnit::unitDescription( unit ) +
' ' );
7502 return getGUI()->canvasWidget()->frameViewManager();
7505void KWView::deleteSelectedFrames() {
7510 KMacroCommand * macroCmd =
new KMacroCommand( i18n(
"Delete Frames") );
7511 KWFrameViewManager *fvMgr = frameViewManager();
7513 KWFrame *frame = frameView->frame();
7514 KWFrameSet *fs = frame->
frameSet();
7515 if ( fs->isAFooter() || fs->isAHeader() )
7519 docItem|=m_doc->typeItemDocStructure(table->
type());
7522 docItem|=m_doc->typeItemDocStructure(fs->
type());
7525 KCommand * cmd=table->
anchorFrameset()->deleteAnchoredFrame( anchor );
7526 macroCmd->addCommand(cmd);
7530 KWDeleteTableCommand *cmd =
new KWDeleteTableCommand( i18n(
"Delete Table"), table );
7532 macroCmd->addCommand(cmd);
7537 if ( fs->isMainFrameset() )
7540 docItem|=m_doc->typeItemDocStructure(fs->
type());
7544 KCommand *cmd=fs->
anchorFrameset()->deleteAnchoredFrame( anchor );
7545 macroCmd->addCommand(cmd);
7549 KWDeleteFrameCommand *cmd =
new KWDeleteFrameCommand( i18n(
"Delete Frame"), frame );
7551 macroCmd->addCommand(cmd);
7557 m_doc->addCommand(macroCmd);
7558 m_doc->refreshDocStructure(docItem);
7568KWViewWidget::KWViewWidget( TQWidget *parent, KWView *view )
7569 : TQWidget( parent ),
7574void KWViewWidget::resizeEvent( TQResizeEvent *e )
7577 if ( ( e->size().width() != e->oldSize().width() )
7578 && ( m_view->kWordDocument()->zoomMode() == KoZoomMode::ZOOM_WIDTH ) )
7580 TQTimer::singleShot( 0, m_view, TQ_SLOT( updateZoom() ) );
7583 TQWidget::resizeEvent( e );
7590KWGUI::KWGUI(
const TQString& viewMode, TQWidget *parent, KWView *daView )
7591 : TQHBox( parent,
"" ),
7595 KWDocument * doc = m_view->kWordDocument();
7601 m_panner =
new TQSplitter( TQt::Horizontal,
this );
7604 m_docStruct =
new KWDocStruct( m_panner, doc,
this );
7605 m_docStruct->setMinimumWidth( 0 );
7608 m_right =
new KWViewWidget( m_panner, m_view );
7609 TQGridLayout *gridLayout =
new TQGridLayout( m_right, 2, 2 );
7610 m_canvas =
new KWCanvas( viewMode, m_right, doc,
this );
7611 gridLayout->addWidget( m_canvas, 1, 1 );
7616 m_panner->setSizes( l );
7618 KoPageLayout layout = doc->pageLayout();
7620 m_tabChooser =
new KoTabChooser( m_right, KoTabChooser::TAB_ALL );
7621 m_tabChooser->setReadWrite(doc->isReadWrite());
7622 gridLayout->addWidget( m_tabChooser, 0, 0 );
7624 m_horRuler =
new KoRuler( m_right, m_canvas->viewport(), TQt::Horizontal, layout,
7625 KoRuler::F_INDENTS | KoRuler::F_TABS,
7626 doc->unit(), m_tabChooser );
7627 m_horRuler->setReadWrite(doc->isReadWrite());
7628 gridLayout->addWidget( m_horRuler, 0, 1 );
7630 m_vertRuler =
new KoRuler( m_right, m_canvas->viewport(), TQt::Vertical, layout,
7632 m_vertRuler->setReadWrite(doc->isReadWrite());
7633 gridLayout->addWidget( m_vertRuler, 1, 0 );
7635 m_horRuler->setZoom( doc->zoomedResolutionX() );
7636 m_vertRuler->setZoom( doc->zoomedResolutionY() );
7638 m_horRuler->setGridSize(doc->gridX());
7640 connect( m_horRuler, TQ_SIGNAL( newPageLayout(
const KoPageLayout & ) ), m_view, TQ_SLOT( newPageLayout(
const KoPageLayout & ) ) );
7641 connect( m_horRuler, TQ_SIGNAL( newLeftIndent(
double ) ), m_view, TQ_SLOT( newLeftIndent(
double ) ) );
7642 connect( m_horRuler, TQ_SIGNAL( newFirstIndent(
double ) ), m_view, TQ_SLOT( newFirstIndent(
double ) ) );
7643 connect( m_horRuler, TQ_SIGNAL( newRightIndent(
double ) ), m_view, TQ_SLOT( newRightIndent(
double ) ) );
7645 connect( m_horRuler, TQ_SIGNAL( doubleClicked() ), m_view, TQ_SLOT( slotHRulerDoubleClicked() ) );
7646 connect( m_horRuler, TQ_SIGNAL( doubleClicked(
double) ), m_view, TQ_SLOT( slotHRulerDoubleClicked(
double) ) );
7647 connect( m_horRuler, TQ_SIGNAL( unitChanged( KoUnit::Unit ) ),
this, TQ_SLOT( unitChanged( KoUnit::Unit ) ) );
7648 connect( m_vertRuler, TQ_SIGNAL( newPageLayout(
const KoPageLayout & ) ), m_view, TQ_SLOT( newPageLayout(
const KoPageLayout & ) ) );
7649 connect( m_vertRuler, TQ_SIGNAL( doubleClicked() ), m_view, TQ_SLOT( formatPage() ) );
7650 connect( m_vertRuler, TQ_SIGNAL( unitChanged( KoUnit::Unit ) ),
this, TQ_SLOT( unitChanged( KoUnit::Unit ) ) );
7653 m_vertRuler->hide();
7659 connect( m_horRuler, TQ_SIGNAL( tabListChanged(
const KoTabulatorList & ) ), m_view,
7660 TQ_SLOT( tabListChanged(
const KoTabulatorList & ) ) );
7662 setKeyCompression(
true );
7663 setAcceptDrops(
true );
7664 setFocusPolicy( TQWidget::NoFocus );
7667void KWGUI::showGUI()
7672void KWGUI::resizeEvent( TQResizeEvent *e )
7674 TQWidget::resizeEvent( e );
7678void KWGUI::reorganize()
7680 int hSpace = m_vertRuler->minimumSizeHint().width();
7681 int vSpace = m_horRuler->minimumSizeHint().height();
7682 if(m_view->kWordDocument()->showRuler())
7684 m_vertRuler->show();
7686 m_tabChooser->show();
7687 m_tabChooser->setGeometry( 0, 0, hSpace, vSpace );
7691 m_vertRuler->hide();
7693 m_tabChooser->hide();
7698 if(m_view->kWordDocument()->showdocStruct()) {
7699 if(m_docStruct->isHidden()) {
7700 m_docStruct->show();
7701 if(m_panner->sizes()[0] < 50) {
7705 m_panner->setSizes( l );
7709 m_docStruct->hide();
7711 if( m_view->statusBar())
7713 if(m_view->kWordDocument()->showStatusBar())
7714 m_view->statusBar()->show();
7716 m_view->statusBar()->hide();
7719 if ( m_view->kWordDocument()->showScrollBar())
7721 m_canvas->setVScrollBarMode(TQScrollView::Auto);
7722 m_canvas->setHScrollBarMode(TQScrollView::Auto);
7726 m_canvas->setVScrollBarMode(TQScrollView::AlwaysOff);
7727 m_canvas->setHScrollBarMode(TQScrollView::AlwaysOff);
7731void KWGUI::unitChanged( KoUnit::Unit u )
7733 m_view->kWordDocument()->setUnit( u );
7736TQPoint KWView::applyViewTransformations(
const TQPoint& p )
const
7738 return viewMode()->normalToView( m_doc->zoomPoint( KoPoint( p ) ) );
7741TQPoint KWView::reverseViewTransformations(
const TQPoint& p )
const
7743 return m_doc->unzoomPoint( viewMode()->viewToNormal( p ) ).toTQPoint();
7746int KWView::currentPage()
const {
7747 return m_currentPage->pageNumber();
7750void KWView::slotDocumentLoadingCompleted()
7755#include "KWView.moc"
Class: KWCanvas This class is responsible for the rendering of the frames to the screen as well as th...
static void recalcAllFrames(KWDocument *doc)
Update the z-ordering for all frames of the whole document.
void update()
Update the z-ordering around the frame we host the framelist for.
virtual KWFrameSetEdit * currentTextEdit()
Return the current most-low-level text edit object.
Class: KWFrameSet Base type, a frameset holds content as well as frames to show that content.
KWAnchor * findAnchor(int frameNum)
Return the anchor object for this frame number.
virtual FrameSetType type() const
The type of frameset.
Info
The different types of textFramesets (that TEXT is important here!) FI_BODY = normal text frames.
const TQPtrList< KWFrame > & frameIterator() const
Iterator over the child frames.
virtual void finalize()
Called once the frameset has been completely loaded or constructed.
bool isDeleted() const
True if the frameset was deleted (but not destroyed, since it's in the undo/redo).
unsigned int frameCount() const
Get number of child frames.
bool isFloating() const
Return true if this frameset is floating (inline), false if it's fixed.
KWTableFrameSet * groupmanager() const
returns the groupManager this frameset belongs to.
KWTextFrameSet * anchorFrameset() const
Return the frameset in which our anchor is - assuming isFloating().
KWFrame * frame(unsigned int _num) const
get a frame by number
TQString name() const
get/set frameset name. For tables in particular, this must be unique
The user-visible style for frames (borders and background).
Class that knows about all the (visible) frames in the document and will act as a manager between the...
KWFrameView * selectedFrame() const
Returns the first selected frame.
void setSelected(bool selected, MouseMeaning selectPolicy=MEANING_MOUSE_SELECT)
Set the selected state of this frameView.
KWFrame * frame() const
returns the frame this frameView represents
bool selected() const
returns if this frameView is selected. A selected frame is shown differently on screen.
This class represents a single frame.
KWFrameSet * frameSet() const
Data stucture methods.
void setZOrder(int z)
The z-order of the frame, relative to the other frames on the same page.
int pageNumber() const
The page on which this frame is.
const KoBorder & leftBorder() const
All borders can be custom drawn with their own colors etc.
const KoRect & rect() const
Return the rectangle for this frame.
KWFrame * getCopy()
returns a copy of self
int pageNumber() const
returns the number of this page as it will be shown to the user.
double width() const
return the width of this page (in pt)
double rightMargin() const
return the width of the margin at left (in pt);
const KoRect rect() const
return a KoRect with the (pt) sizes of this page. Margins are ignored for this function.
void startEditing()
Called by KWView when the object is being edited (activated).
void endEditing()
Called by KWView when the object is not being edited anymore (deactivated).
This class implements tables by acting as the manager for the frame(set)s which make up the table cel...
virtual FrameSetType type() const
The type of frameset.
KCommand * splitCell(unsigned int intoRows, unsigned int intoColumns, unsigned int column, unsigned int row, TQPtrList< KWFrameSet > listFrameSet=TQPtrList< KWFrameSet >(), TQPtrList< KWFrame >listFrame=TQPtrList< KWFrame >())
split one cell into a number of cells and return a command for undo purposes.
unsigned int getColumns() const
returns the number of columns
KCommand * joinCells(unsigned int firstColumn, unsigned int firstRow, unsigned int endColumn, unsigned int endRow)
merge cells to one cell.
unsigned int getRows() const
returns the number of rows
Table style (can created/modified/deleted by the user) A table style is simply a paragraph style and ...
KWTextFrameSet * textFrameSet() const
Return the text frameset in which this document is.
Object that is created to edit a Text frame set (KWTextFrameSet).
KoBorder border(KoBorder::BorderType type)
Return the requested border of the paragraph that the cursor currently is in.
bool openLink(KoLinkVariable *variable)
Called by KoTextView when clicking on a link.
bool hasSelection() const
return true if some text is selected
TQByteArray sortText(SortType type) const
Sort selected paragraphs Return a complete OASIS store, ready for "pasting".
KoTextObject * textObject() const
Return the contained text object.
virtual void layout()
Invalidate all paragraphs and start re-formatting.
virtual void finalize()
Called once the frameset has been completely loaded or constructed.
void highlightPortion(KoTextParag *parag, int index, int length, KWCanvas *canvas, bool repaint=true, KDialogBase *dialog=0)
Highlighting support (for search/replace, spellchecking etc.).
This class extends KoTextParag for KWord-specific formatting stuff, custom items, loading and saving.
static KWTextFrameSet * determineTextFrameSet(KWDocument *doc)
Return a text frameset that the user has either selected or is currently editing, returning the main ...
Abstract base class for KWCanvas's view modes.