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 <tdeversion.h>
120#include <kiconloader.h>
122#include <tqclipboard.h>
123#include <tqapplication.h>
124#include <tqgroupbox.h>
126#include <tqpaintdevicemetrics.h>
127#include <tqprogressdialog.h>
134#include <tdespell2/dialog.h>
135#include <tdespell2/defaultdictionary.h>
138using namespace KSpell2;
145 TableInfo(
const TQValueList<KWFrameView*>& selectedFrames ) {
146 m_protectContent =
false;
148 int amountSelected = 0;
150 TQMap<KWTableFrameSet*, TQValueList<unsigned int> > tableRows, tableCols;
152 TQValueList<KWFrameView*>::const_iterator framesIterator = selectedFrames.begin();
153 for(;framesIterator != selectedFrames.end(); ++framesIterator) {
159 if(cell == 0)
continue;
161 if(cell->protectContent())
162 m_protectContent=
true;
165 TQValueList<unsigned int> rows;
169 TQValueList<unsigned int> cols;
174 TQValueList<unsigned int> rows = tableRows[fs->
groupmanager()];
175 for(
unsigned int r=cell->firstRow(); r <= cell->lastRow(); r++)
176 rows[r] = rows[r] + 1;
178 TQValueList<unsigned int> columns = tableCols[fs->
groupmanager()];
179 for(
unsigned int c=cell->firstColumn(); c <= cell->lastColumn(); c++)
180 columns[c] = columns[c] + 1;
183 if(m_cell == 0 || m_cell->firstRow() > cell->firstRow() ||
184 m_cell->firstRow() == cell->firstRow() &&
185 m_cell->firstColumn() > cell->firstColumn())
189 m_selected = amountSelected != 0;
190 m_oneCellSelected = amountSelected == 1;
191 if(amountSelected == 0)
return;
193 for(TQMapIterator<
KWTableFrameSet*, TQValueList<unsigned int> > iter = tableRows.begin();
194 iter != tableRows.end(); ++iter) {
195 TQValueList<unsigned int> rows = iter.data();
196 TQValueListIterator<unsigned int> rowsIter = rows.begin();
197 for(
int x=0;rowsIter != rows.end(); ++rowsIter, x++)
198 if(*rowsIter == iter.key()->getColumns())
201 TQValueList<unsigned int> columns = tableCols[iter.key()];
202 TQValueListIterator<unsigned int> colsIter = columns.begin();
203 for(
int x=0;colsIter != columns.end(); ++colsIter, x++)
204 if(*colsIter == iter.key()->getRows())
209 int tableCellsSelected() {
return m_selected; }
210 int amountRowsSelected() {
return m_rows.count(); }
211 int amountColumnsSelected() {
return m_columns.count(); }
212 bool oneCellSelected() {
return m_oneCellSelected; }
213 bool protectContentEnabled() {
return m_protectContent; }
214 TQValueList<uint> selectedRows() {
return m_rows; }
215 TQValueList<uint> selectedColumns() {
return m_columns; }
219 bool m_oneCellSelected, m_selected, m_protectContent;
220 TQValueList<uint> m_rows, m_columns;
227KWView::KWView(
const TQString& viewMode, TQWidget *parent,
const char *name, KWDocument* doc )
228 : KoView( doc, parent, name )
238 m_broker = Broker::openBroker( TDESharedConfig::openConfig(
"kwordrc" ) );
239 m_spell.macroCmdSpellCheck=0L;
240 m_spell.textIterator = 0L;
241 m_currentPage = m_doc->pageManager()->page(m_doc->startPage());
248 m_tableSplit.columns = 1;
249 m_tableSplit.rows = 1;
251 m_actionList.setAutoDelete(
true );
252 m_variableActionList.setAutoDelete(
true );
254 m_zoomViewModeNormal.m_zoom = m_doc->zoom();
255 m_zoomViewModeNormal.m_zoomMode = m_doc->zoomMode();
256 m_zoomViewModePreview.m_zoom = 33;
257 m_zoomViewModePreview.m_zoomMode = KoZoomMode::ZOOM_CONSTANT;
259 m_viewFrameBorders = m_doc->viewFrameBorders();
260 KoView::setZoom( m_doc->zoomedResolutionY() );
263 setInstance( KWFactory::instance() );
264 if ( !m_doc->isReadWrite() )
265 setXMLFile(
"kword_readonly.rc" );
267 setXMLFile(
"kword.rc" );
270 TQObject::connect(
this, TQ_SIGNAL( embeddImage(
const TQString & ) ),
271 this, TQ_SLOT( slotEmbedImage(
const TQString & ) ) );
273 setKeyCompression(
true );
274 setAcceptDrops(
true );
278 m_gui =
new KWGUI( viewMode,
this,
this );
279 m_gui->setGeometry( 0, 0, width(), height() );
283 m_sbModifiedLabel = 0;
285 m_sbOverwriteLabel = 0;
288 if ( KStatusBar* sb = statusBar() )
290 m_sbPageLabel =
new KStatusBarLabel( TQString(), 0, sb );
291 m_sbPageLabel->setAlignment( AlignLeft | AlignVCenter );
292 addStatusBarItem( m_sbPageLabel, 0 );
294 m_sbModifiedLabel =
new KStatusBarLabel(
" ", 0, sb );
295 m_sbModifiedLabel->setAlignment( AlignLeft | AlignVCenter );
296 addStatusBarItem( m_sbModifiedLabel, 0 );
298 m_sbFramesLabel =
new KStatusBarLabel( TQString(), 0, sb );
299 m_sbFramesLabel->setAlignment( AlignLeft | AlignVCenter );
300 addStatusBarItem( m_sbFramesLabel, 1 );
302 m_sbOverwriteLabel =
new KStatusBarLabel(
' ' + i18n(
"INSRT" ) +
' ', 0, sb );
303 m_sbOverwriteLabel->setAlignment( AlignHCenter | AlignVCenter );
304 addStatusBarItem( m_sbOverwriteLabel, 0 );
306 m_sbZoomLabel =
new KStatusBarLabel(
' ' + TQString::number( m_doc->zoom() ) +
"% ", 0, sb );
307 m_sbZoomLabel->setAlignment( AlignHCenter | AlignVCenter );
308 addStatusBarItem( m_sbZoomLabel, 0 );
310 m_sbUnitLabel =
new KStatusBarLabel(
' ' + KoUnit::unitDescription( m_doc->unit() ) +
' ', 0, sb );
311 m_sbUnitLabel->setAlignment( AlignHCenter | AlignVCenter );
312 addStatusBarItem( m_sbUnitLabel, 0 );
315 connect( m_doc, TQ_SIGNAL( modified(
bool ) ),
316 this, TQ_SLOT( documentModified(
bool )) );
318 connect( m_doc, TQ_SIGNAL( numPagesChanged() ),
319 this, TQ_SLOT( numPagesChanged()) );
321 connect( m_doc, TQ_SIGNAL( pageLayoutChanged(
const KoPageLayout& ) ),
322 this, TQ_SLOT( slotPageLayoutChanged(
const KoPageLayout& )) );
324 connect( m_doc, TQ_SIGNAL( docStructureChanged(
int) ),
325 this, TQ_SLOT( docStructChanged(
int)) );
327 connect( m_doc, TQ_SIGNAL( unitChanged(KoUnit::Unit) ),
328 this, TQ_SLOT( slotUnitChanged(KoUnit::Unit) ) );
330 connect( m_doc, TQ_SIGNAL( sig_refreshMenuCustomVariable()),
331 this, TQ_SLOT( refreshCustomMenu()));
333 connect( m_doc, TQ_SIGNAL( completed() ),
334 this, TQ_SLOT( slotDocumentLoadingCompleted() ) );
336 connect( frameViewManager(), TQ_SIGNAL(sigFrameSelectionChanged()),
337 this, TQ_SLOT( frameSelectedChanged()));
339 connect( frameViewManager(), TQ_SIGNAL(sigFrameSetRenamed()),
340 this, TQ_SLOT( updateFrameStatusBarItem()));
342 connect( TQApplication::clipboard(), TQ_SIGNAL( dataChanged() ),
343 this, TQ_SLOT( clipboardDataChanged() ) );
345 connect( m_gui->canvasWidget(), TQ_SIGNAL(currentFrameSetEditChanged()),
346 this, TQ_SLOT(slotFrameSetEditChanged()) );
348 connect( m_gui->canvasWidget(), TQ_SIGNAL( currentMouseModeChanged(
int) ),
349 this, TQ_SLOT( showMouseMode(
int) ) );
351 connect( m_gui->canvasWidget(), TQ_SIGNAL( overwriteModeChanged(
bool ) ),
352 this, TQ_SLOT( changeOverwriteMode(
bool ) ) );
355 if ( m_doc->isReadWrite() )
357 connect( m_gui->canvasWidget(), TQ_SIGNAL(selectionChanged(
bool)),
358 this, TQ_SLOT(slotChangeCutState(
bool )) );
359 connect (m_gui->canvasWidget(), TQ_SIGNAL(selectionChanged(
bool)),
360 this, TQ_SLOT(slotChangeCaseState(
bool )));
364 m_actionEditCut->setEnabled(
false );
365 m_actionChangeCase->setEnabled(
false );
368 connect( m_gui->canvasWidget(), TQ_SIGNAL(selectionChanged(
bool)),
369 m_actionEditCopy, TQ_SLOT(setEnabled(
bool)) );
374 connect (m_gui->canvasWidget(), TQ_SIGNAL(selectionChanged(
bool)),
375 m_actionConvertToTextBox, TQ_SLOT(setEnabled(
bool)));
376 connect (m_gui->canvasWidget(), TQ_SIGNAL(selectionChanged(
bool)),
377 m_actionAddPersonalExpression, TQ_SLOT(setEnabled(
bool )));
378 connect (m_gui->canvasWidget(), TQ_SIGNAL(selectionChanged(
bool)),
379 m_actionSortText, TQ_SLOT(setEnabled(
bool )));
381 connect( m_gui->canvasWidget(), TQ_SIGNAL(docStructChanged(
int)),
382 this, TQ_SLOT(docStructChanged(
int)));
384 connect( m_gui->canvasWidget(), TQ_SIGNAL(updateRuler()),
385 this, TQ_SLOT(slotUpdateRuler()));
389 connect( shell(), TQ_SIGNAL( documentSaved()), m_doc,TQ_SLOT(slotDocumentInfoModifed() ) );
390 changeNbOfRecentFiles( m_doc->maxRecentFiles() );
393 m_gui->canvasWidget()->updateCurrentFormat();
394 setFocusProxy( m_gui->canvasWidget() );
398 if(!m_doc->isReadWrite())
400 setZoom( 100,
true );
408 TQTimer::singleShot( 0,
this, TQ_SLOT( slotSetInitialPosition() ) );
409 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
414 delete m_tableActionList.first();
417 delete m_searchEntry;
419 delete m_replaceEntry;
421 if ( m_specialCharDlg )
422 m_specialCharDlg->closeDialog();
425 delete m_findReplace;
428 delete m_sbPageLabel;
429 delete m_sbFramesLabel;
436DCOPObject* KWView::dcopObject()
439 m_dcop =
new KWordViewIface(
this );
444void KWView::slotChangeCutState(
bool b)
447 if ( edit && edit->textFrameSet()->protectContent())
448 m_actionEditCut->setEnabled(
false );
450 m_actionEditCut->setEnabled( b );
453void KWView::slotChangeCaseState(
bool b)
456 if ( edit && edit->textFrameSet()->protectContent())
457 m_actionChangeCase->setEnabled(
false );
459 m_actionChangeCase->setEnabled( b );
462void KWView::slotSetInitialPosition()
466 textedit->ensureCursorVisible();
468 m_gui->canvasWidget()->setContentsPos( 0, 0 );
471void KWView::changeNbOfRecentFiles(
int nb)
474 shell()->setMaxRecentItems( nb );
479 return m_gui->canvasWidget()->viewMode();
482void KWView::initGui()
484 clipboardDataChanged();
487 showMouseMode( KWCanvas::MM_EDIT );
489 m_actionFormatDecreaseIndent->setEnabled(
false);
492 m_actionFormatColor->setCurrentColor( TQt::black );
497 updateZoomControls();
501 m_gui->canvasWidget()->setMouseMode( m_gui->canvasWidget()->mouseMode() );
503 bool editingFormula =
dynamic_cast<KWFormulaFrameSetEdit *
>( m_gui->canvasWidget()->currentFrameSetEdit() ) != 0;
506 shell()->showToolbar(
"formula_toolbar", editingFormula );
508 if ( !editingFormula )
510 kWordDocument()->formulaDocumentWrapper()->setEnabled(
false);
511 kWordDocument()->formulaDocumentWrapper()->enableMatrixActions(
false);
512 kWordDocument()->formulaDocumentWrapper()->getSyntaxHighlightingAction()->setEnabled(
false);
516 if ( KStatusBar* sb = statusBar() )
520 slotFrameSetEditChanged();
521 frameSelectedChanged();
522 updateTocActionText(m_doc->tocPresent());
524 m_actionBackgroundColor->setEnabled(
true);
525 updateBgSpellCheckingState();
526 updateDirectCursorButton();
527 m_actionCreateFrameStyle->setEnabled(
false);
531void KWView::updateBgSpellCheckingState()
533 m_actionAllowBgSpellCheck->setChecked( m_doc->backgroundSpellCheckEnabled() );
537void KWView::initGUIButton()
539 m_actionViewFrameBorders->setChecked( viewFrameBorders() );
540 m_actionViewFormattingChars->setChecked( m_doc->viewFormattingChars() );
541 m_actionShowDocStruct->setChecked(m_doc->showdocStruct());
542 m_actionShowRuler->setChecked(m_doc->showRuler());
544 updateHeaderFooterButton();
545 m_actionAllowAutoFormat->setChecked( m_doc->allowAutoFormat() );
547 if ( !m_doc->isEmbedded() ) {
548 TQString mode = viewMode()->type();
549 if (mode==
"ModePreview")
550 m_actionViewPreviewMode->setChecked(
true);
551 else if (mode==
"ModeText")
552 m_actionViewTextMode->setChecked(
true);
554 m_actionViewPageMode->setChecked(
true);
559void KWView::setupActions()
565 m_actionExtraCreateTemplate =
new TDEAction( i18n(
"&Create Template From Document..." ), 0,
566 this, TQ_SLOT( extraCreateTemplate() ),
567 actionCollection(),
"extra_template" );
568 m_actionExtraCreateTemplate->setToolTip( i18n(
"Save this document and use it later as a template" ) );
569 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." ) );
571 m_actionFileStatistics =
new TDEAction( i18n(
"Statistics" ), 0,
this, TQ_SLOT( fileStatistics() ), actionCollection(),
"file_statistics" );
572 m_actionFileStatistics->setToolTip( i18n(
"Sentence, word and letter counts for this document" ) );
573 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." ) );
575 m_actionEditCut = KStdAction::cut(
this, TQ_SLOT( editCut() ), actionCollection(),
"edit_cut" );
576 m_actionEditCopy = KStdAction::copy(
this, TQ_SLOT( editCopy() ), actionCollection(),
"edit_copy" );
577 m_actionEditPaste = KStdAction::paste(
this, TQ_SLOT( editPaste() ), actionCollection(),
"edit_paste" );
578 m_actionEditFind = KStdAction::find(
this, TQ_SLOT( editFind() ), actionCollection(),
"edit_find" );
579 m_actionEditFindNext = KStdAction::findNext(
this, TQ_SLOT( editFindNext() ), actionCollection(),
"edit_findnext" );
580 m_actionEditFindPrevious = KStdAction::findPrev(
this, TQ_SLOT( editFindPrevious() ), actionCollection(),
"edit_findprevious" );
581 m_actionEditReplace = KStdAction::replace(
this, TQ_SLOT( editReplace() ), actionCollection(),
"edit_replace" );
582 m_actionEditSelectAll = KStdAction::selectAll(
this, TQ_SLOT( editSelectAll() ), actionCollection(),
"edit_selectall" );
583 new TDEAction( i18n(
"Select All Frames" ), 0,
this, TQ_SLOT( editSelectAllFrames() ), actionCollection(),
"edit_selectallframes" );
584 m_actionEditSelectCurrentFrame =
new TDEAction( i18n(
"Select Frame" ), 0,
585 0,
this, TQ_SLOT( editSelectCurrentFrame() ),
586 actionCollection(),
"edit_selectcurrentframe" );
587 m_actionSpellCheck = KStdAction::spelling(
this, TQ_SLOT( slotSpellCheck() ), actionCollection(),
"extra_spellcheck" );
588 m_actionDeletePage =
new TDEAction( i18n(
"Delete Page" ),
"delslide", 0,
589 this, TQ_SLOT( deletePage() ),
590 actionCollection(),
"delete_page" );
591 kdDebug() << m_doc->pageCount() <<
" " << (m_doc->processingType() == KWDocument::DTP) << endl;
593 (void)
new TDEAction( i18n(
"Configure Mai&l Merge..." ),
"configure",0,
594 this, TQ_SLOT( editMailMergeDataBase() ),
595 actionCollection(),
"edit_sldatabase" );
598 (void)
new KWMailMergeLabelAction( i18n(
"Drag Mail Merge Variable"), 0,
599 this, TQ_SLOT(editMailMergeDataBase()), actionCollection(),
"mailmerge_draglabel" );
604 m_actionEditDelFrame =
new TDEAction( i18n(
"&Delete Frame" ), 0,
605 this, TQ_SLOT( editDeleteFrame() ),
606 actionCollection(),
"edit_delframe" );
607 m_actionEditDelFrame->setToolTip( i18n(
"Delete the currently selected frame(s)." ) );
608 m_actionEditDelFrame->setWhatsThis( i18n(
"Delete the currently selected frame(s)." ) );
610 m_actionCreateLinkedFrame =
new TDEAction( i18n(
"Create Linked Copy" ), 0,
this, TQ_SLOT( createLinkedFrame() ), actionCollection(),
"create_linked_frame" );
611 m_actionCreateLinkedFrame->setToolTip( i18n(
"Create a copy of the current frame, always showing the same contents" ) );
612 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.") );
614 m_actionRaiseFrame =
new TDEAction( i18n(
"Ra&ise Frame" ),
"raise",
615 TQt::CTRL +TQt::SHIFT+ TQt::Key_R,
this, TQ_SLOT( raiseFrame() ),
616 actionCollection(),
"raiseframe" );
617 m_actionRaiseFrame->setToolTip( i18n(
"Raise the currently selected frame so that it appears above all the other frames" ) );
618 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." ) );
620 m_actionLowerFrame =
new TDEAction( i18n(
"&Lower Frame" ),
"lower",
621 TQt::CTRL +TQt::SHIFT+ TQt::Key_L,
this, TQ_SLOT( lowerFrame() ),
622 actionCollection(),
"lowerframe" );
623 m_actionLowerFrame->setToolTip( i18n(
"Lower the currently selected frame so that it disappears under any frame that overlaps it" ) );
624 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." ) );
626 m_actionBringToFront=
new TDEAction( i18n(
"Bring to Front" ),
"bring_forward",
627 0,
this, TQ_SLOT( bringToFront() ),
628 actionCollection(),
"bring_tofront_frame" );
630 m_actionSendBackward=
new TDEAction( i18n(
"Send to Back" ),
"send_backward",
631 0,
this, TQ_SLOT( sendToBack() ),
632 actionCollection(),
"send_toback_frame" );
637 if ( !m_doc->isEmbedded() ) {
639 m_actionViewTextMode =
new TDEToggleAction( i18n(
"Text Mode" ), 0,
640 this, TQ_SLOT( viewTextMode() ),
641 actionCollection(),
"view_textmode" );
642 m_actionViewTextMode->setToolTip( i18n(
"Only show the text of the document." ) );
643 m_actionViewTextMode->setWhatsThis( i18n(
"Do not show any pictures, formatting or layout. KWord will display only the text for editing." ) );
645 m_actionViewTextMode->setExclusiveGroup(
"viewmodes" );
646 m_actionViewPageMode =
new TDEToggleAction( i18n(
"&Page Mode" ), 0,
647 this, TQ_SLOT( viewPageMode() ),
648 actionCollection(),
"view_pagemode" );
649 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." ) );
650 m_actionViewPageMode->setToolTip( i18n(
"Switch to page editing mode." ) );
652 m_actionViewPageMode->setExclusiveGroup(
"viewmodes" );
653 m_actionViewPageMode->setChecked(
true );
654 m_actionViewPreviewMode =
new TDEToggleAction( i18n(
"Pre&view Mode" ), 0,
655 this, TQ_SLOT( viewPreviewMode() ),
656 actionCollection(),
"view_previewmode" );
657 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." ) );
658 m_actionViewPreviewMode->setToolTip( i18n(
"Zoom out to a multiple page view." ) );
660 m_actionViewPreviewMode->setExclusiveGroup(
"viewmodes" );
664 m_actionViewTextMode = 0;
665 m_actionViewPageMode = 0;
666 m_actionViewPreviewMode = 0;
669 m_actionViewFormattingChars =
new TDEToggleAction( i18n(
"&Formatting Characters" ), 0,
670 this, TQ_SLOT( slotViewFormattingChars() ),
671 actionCollection(),
"view_formattingchars" );
672 m_actionViewFormattingChars->setToolTip( i18n(
"Toggle the display of non-printing characters." ) );
673 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." ) );
675 m_actionViewFrameBorders =
new TDEToggleAction( i18n(
"Frame &Borders" ), 0,
676 this, TQ_SLOT( slotViewFrameBorders() ),
677 actionCollection(),
"view_frameborders" );
678 m_actionViewFrameBorders->setToolTip( i18n(
"Turns the border display on and off." ) );
679 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." ) );
681 m_actionViewHeader =
new TDEToggleAction( i18n(
"Enable Document &Headers" ), 0,
682 this, TQ_SLOT( viewHeader() ),
683 actionCollection(),
"format_header" );
684 m_actionViewHeader->setCheckedState(i18n(
"Disable Document &Headers"));
685 m_actionViewHeader->setToolTip( i18n(
"Shows and hides header display." ) );
686 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." ) );
688 m_actionViewFooter =
new TDEToggleAction( i18n(
"Enable Document Foo&ters" ), 0,
689 this, TQ_SLOT( viewFooter() ),
690 actionCollection(),
"format_footer" );
691 m_actionViewFooter->setCheckedState(i18n(
"Disable Document Foo&ters"));
692 m_actionViewFooter->setToolTip( i18n(
"Shows and hides footer display." ) );
693 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." ) );
695 m_actionViewZoom =
new TDESelectAction( i18n(
"Zoom" ),
"viewmag", 0,
696 actionCollection(),
"view_zoom" );
698 connect( m_actionViewZoom, TQ_SIGNAL( activated(
const TQString & ) ),
699 this, TQ_SLOT( viewZoom(
const TQString & ) ) );
700 m_actionViewZoom->setEditable(
true);
704 m_actionInsertSpecialChar =
new TDEAction( i18n(
"Sp&ecial Character..." ),
"char",
705 TQt::ALT + TQt::SHIFT + TQt::Key_C,
706 this, TQ_SLOT( insertSpecialChar() ),
707 actionCollection(),
"insert_specialchar" );
708 m_actionInsertSpecialChar->setToolTip( i18n(
"Insert one or more symbols or letters not found on the keyboard." ) );
709 m_actionInsertSpecialChar->setWhatsThis( i18n(
"Insert one or more symbols or letters not found on the keyboard." ) );
711 m_actionInsertFrameBreak =
new TDEAction( TQString(), TQt::CTRL + TQt::Key_Return,
712 this, TQ_SLOT( insertFrameBreak() ),
713 actionCollection(),
"insert_framebreak" );
714 if ( m_doc->processingType() == KWDocument::WP ) {
715 m_actionInsertFrameBreak->setText( i18n(
"Page Break" ) );
716 m_actionInsertFrameBreak->setToolTip( i18n(
"Force the remainder of the text into the next page." ) );
717 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." ) );
719 m_actionInsertFrameBreak->setText( i18n(
"&Hard Frame Break" ) );
720 m_actionInsertFrameBreak->setToolTip( i18n(
"Force the remainder of the text into the next frame." ) );
721 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." ) );
724 new TDEAction( m_doc->processingType() == KWDocument::WP ? i18n(
"Page" ) : i18n(
"Page..." ),
"page", 0,
725 this, TQ_SLOT( insertPage() ),
726 actionCollection(),
"insert_page" );
728 m_actionInsertLink =
new TDEAction( i18n(
"Link..." ), 0,
729 this, TQ_SLOT( insertLink() ),
730 actionCollection(),
"insert_link" );
731 m_actionInsertLink->setToolTip( i18n(
"Insert a Web address, email address or hyperlink to a file." ) );
732 m_actionInsertLink->setWhatsThis( i18n(
"Insert a Web address, email address or hyperlink to a file." ) );
734 m_actionInsertComment =
new TDEAction( i18n(
"Comment..." ), 0,
735 this, TQ_SLOT( insertComment() ),
736 actionCollection(),
"insert_comment" );
737 m_actionInsertComment->setToolTip( i18n(
"Insert a comment about the selected text." ) );
738 m_actionInsertComment->setWhatsThis( i18n(
"Insert a comment about the selected text. These comments are not designed to appear on the final page." ) );
740 m_actionEditComment =
new TDEAction( i18n(
"Edit Comment..."), 0,
741 this, TQ_SLOT(editComment()),
742 actionCollection(),
"edit_comment");
743 m_actionEditComment->setToolTip( i18n(
"Change the content of a comment." ) );
744 m_actionEditComment->setWhatsThis( i18n(
"Change the content of a comment." ) );
746 m_actionRemoveComment =
new TDEAction( i18n(
"Remove Comment"), 0,
747 this, TQ_SLOT(removeComment()),
748 actionCollection(),
"remove_comment");
749 m_actionRemoveComment->setToolTip( i18n(
"Remove the selected document comment." ) );
750 m_actionRemoveComment->setWhatsThis( i18n(
"Remove the selected document comment." ) );
751 m_actionCopyTextOfComment =
new TDEAction( i18n(
"Copy Text of Comment..."), 0,
752 this, TQ_SLOT(copyTextOfComment()),
753 actionCollection(),
"copy_text_comment");
756 m_actionInsertFootEndNote =
new TDEAction( i18n(
"&Footnote/Endnote..." ), 0,
757 this, TQ_SLOT( insertFootNote() ),
758 actionCollection(),
"insert_footendnote" );
759 m_actionInsertFootEndNote->setToolTip( i18n(
"Insert a footnote referencing the selected text." ) );
760 m_actionInsertFootEndNote->setWhatsThis( i18n(
"Insert a footnote referencing the selected text." ) );
762 m_actionInsertContents =
new TDEAction( i18n(
"Table of &Contents" ), 0,
763 this, TQ_SLOT( insertContents() ),
764 actionCollection(),
"insert_contents" );
765 m_actionInsertContents->setToolTip( i18n(
"Insert table of contents at the current cursor position." ) );
766 m_actionInsertContents->setWhatsThis( i18n(
"Insert table of contents at the current cursor position." ) );
768 m_variableDefMap.clear();
769 actionInsertVariable =
new TDEActionMenu( i18n(
"&Variable" ),
770 actionCollection(),
"insert_variable" );
773 addVariableActions( VT_FIELD, KoFieldVariable::actionTexts(), actionInsertVariable, i18n(
"Document &Information") );
774 addVariableActions( VT_DATE, KoDateVariable::actionTexts(), actionInsertVariable, i18n(
"&Date") );
775 addVariableActions( VT_TIME, KoTimeVariable::actionTexts(), actionInsertVariable, i18n(
"&Time") );
776 addVariableActions( VT_PGNUM, KoPageVariable::actionTexts(), actionInsertVariable, i18n(
"&Page") );
777 addVariableActions( VT_STATISTIC, KWStatisticVariable::actionTexts(), actionInsertVariable, i18n(
"&Statistic") );
779 m_actionInsertCustom =
new TDEActionMenu( i18n(
"&Custom" ),
780 actionCollection(),
"insert_custom" );
781 actionInsertVariable->insert(m_actionInsertCustom);
785 addVariableActions( VT_MAILMERGE, KoMailMergeVariable::actionTexts(), actionInsertVariable, TQString() );
787 actionInsertVariable->popupMenu()->insertSeparator();
788 m_actionRefreshAllVariable =
new TDEAction( i18n(
"&Refresh All Variables" ), 0,
789 this, TQ_SLOT( refreshAllVariable() ),
790 actionCollection(),
"refresh_all_variable" );
791 m_actionRefreshAllVariable->setToolTip( i18n(
"Update all variables to current values." ) );
792 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." ) );
794 actionInsertVariable->insert(m_actionRefreshAllVariable);
796 m_actionInsertExpression =
new TDEActionMenu( i18n(
"&Expression" ),
797 actionCollection(),
"insert_expression" );
798 loadexpressionActions( m_actionInsertExpression);
800 m_actionToolsCreateText =
new TDEToggleAction( i18n(
"Te&xt Frame" ),
"frame_text", TQt::Key_F10 ,
801 this, TQ_SLOT( toolsCreateText() ),
802 actionCollection(),
"tools_createtext" );
803 m_actionToolsCreateText->setToolTip( i18n(
"Create a new text frame." ) );
804 m_actionToolsCreateText->setWhatsThis( i18n(
"Create a new text frame." ) );
806 m_actionToolsCreateText->setExclusiveGroup(
"tools" );
807 m_actionInsertFormula =
new TDEAction( i18n(
"For&mula" ),
"frame_formula", TQt::Key_F4,
808 this, TQ_SLOT( insertFormula() ),
809 actionCollection(),
"tools_formula" );
810 m_actionInsertFormula->setToolTip( i18n(
"Insert a formula into a new frame." ) );
811 m_actionInsertFormula->setWhatsThis( i18n(
"Insert a formula into a new frame." ) );
813 m_actionInsertTable =
new TDEAction( i18n(
"&Table..." ),
"inline_table",
815 this, TQ_SLOT( insertTable() ),
816 actionCollection(),
"insert_table" );
817 m_actionInsertTable->setToolTip( i18n(
"Create a table." ) );
818 m_actionInsertTable->setWhatsThis( i18n(
"Create a table.<br><br>The table can either exist in a frame of its own or inline." ) );
820 m_actionToolsCreatePix =
new TDEToggleAction( i18n(
"P&icture..." ),
"frame_image",
821 TQt::SHIFT + TQt::Key_F5 ,
822 this, TQ_SLOT( insertPicture() ),
823 actionCollection(),
"insert_picture" );
824 m_actionToolsCreatePix->setToolTip( i18n(
"Create a new frame for a picture." ) );
825 m_actionToolsCreatePix->setWhatsThis( i18n(
"Create a new frame for a picture or diagram." ) );
826 m_actionToolsCreatePix->setExclusiveGroup(
"tools" );
828 m_actionToolsCreatePart =
new KoPartSelectAction( i18n(
"&Object Frame" ),
"frame_query",
829 this, TQ_SLOT( toolsPart() ),
830 actionCollection(),
"tools_part" );
831 m_actionToolsCreatePart->setToolTip( i18n(
"Insert an object into a new frame." ) );
832 m_actionToolsCreatePart->setWhatsThis( i18n(
"Insert an object into a new frame." ) );
834 m_actionInsertFile =
new TDEAction( i18n(
"Fi&le..." ), 0,
835 this, TQ_SLOT( insertFile() ),
836 actionCollection(),
"insert_file" );
840 m_actionFormatFont =
new TDEAction( i18n(
"&Font..." ), TQt::ALT + TQt::CTRL + TQt::Key_F,
841 this, TQ_SLOT( formatFont() ),
842 actionCollection(),
"format_font" );
843 m_actionFormatFont->setToolTip( i18n(
"Change character size, font, boldface, italics etc." ) );
844 m_actionFormatFont->setWhatsThis( i18n(
"Change the attributes of the currently selected characters." ) );
846 m_actionFormatParag =
new TDEAction( i18n(
"&Paragraph..." ), TQt::ALT + TQt::CTRL + TQt::Key_P,
847 this, TQ_SLOT( formatParagraph() ),
848 actionCollection(),
"format_paragraph" );
849 m_actionFormatParag->setToolTip( i18n(
"Change paragraph margins, text flow, borders, bullets, numbering etc." ) );
850 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." ) );
852 m_actionFormatFrameSet =
new TDEAction( i18n(
"F&rame/Frameset Properties" ), 0,
853 this, TQ_SLOT( formatFrameSet() ),
854 actionCollection(),
"format_frameset" );
855 m_actionFormatFrameSet->setToolTip( i18n(
"Alter frameset properties." ) );
856 m_actionFormatFrameSet->setWhatsThis( i18n(
"Alter frameset properties.<p>Currently you can change the frame background." ) );
858 m_actionFormatPage =
new TDEAction( i18n(
"Page &Layout..." ), 0,
859 this, TQ_SLOT( formatPage() ),
860 actionCollection(),
"format_page" );
861 m_actionFormatPage->setToolTip( i18n(
"Change properties of entire page." ) );
862 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." ) );
865 m_actionFormatFrameStylist =
new TDEAction( i18n(
"&Frame Style Manager" ), 0 ,
866 this, TQ_SLOT( extraFrameStylist() ),
867 actionCollection(),
"frame_stylist" );
868 m_actionFormatFrameStylist->setToolTip( i18n(
"Change attributes of framestyles." ) );
869 m_actionFormatFrameStylist->setWhatsThis( i18n(
"Change background and borders of framestyles.<p>Multiple framestyles can be changed using the dialog box." ) );
872 m_actionFormatStylist =
new TDEAction( i18n(
"&Style Manager" ), TQt::ALT + TQt::CTRL + TQt::Key_S,
873 this, TQ_SLOT( extraStylist() ),
874 actionCollection(),
"format_stylist" );
875 m_actionFormatStylist->setToolTip( i18n(
"Change attributes of styles." ) );
876 m_actionFormatStylist->setWhatsThis( i18n(
"Change font and paragraph attributes of styles.<p>Multiple styles can be changed using the dialog box." ) );
878 m_actionFormatFontSize =
new TDEFontSizeAction( i18n(
"Font Size" ), 0,
879 actionCollection(),
"format_fontsize" );
880 connect( m_actionFormatFontSize, TQ_SIGNAL( fontSizeChanged(
int ) ),
881 this, TQ_SLOT( textSizeSelected(
int ) ) );
883 m_actionFontSizeIncrease =
new TDEAction( i18n(
"Increase Font Size"),
"fontsizeup", TQt::CTRL + TQt::Key_Greater,
this, TQ_SLOT( increaseFontSize() ), actionCollection(),
"increase_fontsize" );
884 m_actionFontSizeDecrease =
new TDEAction( i18n(
"Decrease Font Size"),
"fontsizedown", TQt::CTRL + TQt::Key_Less,
this, TQ_SLOT( decreaseFontSize() ), actionCollection(),
"decrease_fontsize" );
886#ifdef KFONTACTION_HAS_CRITERIA_ARG
887 m_actionFormatFontFamily =
new TDEFontAction( TDEFontChooser::SmoothScalableFonts,
888 i18n(
"Font Family" ), 0,
889 actionCollection(),
"format_fontfamily" );
891 m_actionFormatFontFamily =
new TDEFontAction( i18n(
"Font Family" ), 0,
892 actionCollection(),
"format_fontfamily" );
894 connect( m_actionFormatFontFamily, TQ_SIGNAL( activated(
const TQString & ) ),
895 this, TQ_SLOT( textFontSelected(
const TQString & ) ) );
897 m_actionFormatStyleMenu =
new TDEActionMenu( i18n(
"St&yle" ), 0,
898 actionCollection(),
"format_stylemenu" );
899 m_actionFormatStyle =
new TDESelectAction( i18n(
"St&yle" ), 0,
900 actionCollection(),
"format_style" );
903 connect( m_actionFormatStyle, TQ_SIGNAL( activated(
int ) ),
904 this, TQ_SLOT( textStyleSelected(
int ) ) );
907 m_actionFormatDefault=
new TDEAction( i18n(
"Default Format" ), 0,
908 this, TQ_SLOT( textDefaultFormat() ),
909 actionCollection(),
"text_default" );
910 m_actionFormatDefault->setToolTip( i18n(
"Change font and paragraph attributes to their default values." ) );
911 m_actionFormatDefault->setWhatsThis( i18n(
"Change font and paragraph attributes to their default values." ) );
915 m_actionFormatBold =
new TDEToggleAction( i18n(
"&Bold" ),
"format-text-bold", TQt::CTRL + TQt::Key_B,
916 this, TQ_SLOT( textBold() ),
917 actionCollection(),
"format_bold" );
918 m_actionFormatItalic =
new TDEToggleAction( i18n(
"&Italic" ),
"format-text-italic", TQt::CTRL + TQt::Key_I,
919 this, TQ_SLOT( textItalic() ),
920 actionCollection(),
"format_italic" );
921 m_actionFormatUnderline =
new TDEToggleAction( i18n(
"&Underline" ),
"format-text-underline", TQt::CTRL + TQt::Key_U,
922 this, TQ_SLOT( textUnderline() ),
923 actionCollection(),
"format_underline" );
924 m_actionFormatStrikeOut =
new TDEToggleAction( i18n(
"&Strike Out" ),
"format-text-strikethrough", 0 ,
925 this, TQ_SLOT( textStrikeOut() ),
926 actionCollection(),
"format_strike" );
928 m_actionFormatAlignLeft =
new TDEToggleAction( i18n(
"Align &Left" ),
"format-text-direction-ltr", TQt::CTRL + TQt::Key_L,
929 this, TQ_SLOT( textAlignLeft() ),
930 actionCollection(),
"format_alignleft" );
931 m_actionFormatAlignLeft->setExclusiveGroup(
"align" );
932 m_actionFormatAlignLeft->setChecked(
true );
933 m_actionFormatAlignCenter =
new TDEToggleAction( i18n(
"Align &Center" ),
"text_center", TQt::CTRL + TQt::ALT + TQt::Key_C,
934 this, TQ_SLOT( textAlignCenter() ),
935 actionCollection(),
"format_aligncenter" );
936 m_actionFormatAlignCenter->setExclusiveGroup(
"align" );
937 m_actionFormatAlignRight =
new TDEToggleAction( i18n(
"Align &Right" ),
"format-text-direction-rtl", TQt::CTRL + TQt::ALT + TQt::Key_R,
938 this, TQ_SLOT( textAlignRight() ),
939 actionCollection(),
"format_alignright" );
940 m_actionFormatAlignRight->setExclusiveGroup(
"align" );
941 m_actionFormatAlignBlock =
new TDEToggleAction( i18n(
"Align &Block" ),
"text_block", TQt::CTRL + TQt::Key_J,
942 this, TQ_SLOT( textAlignBlock() ),
943 actionCollection(),
"format_alignblock" );
944 m_actionFormatAlignBlock->setExclusiveGroup(
"align" );
946 m_actionFormatSpacingSingle =
new TDEToggleAction( i18n(
"Line Spacing &1" ),
"spacesimple", TQt::CTRL + TQt::Key_1,
947 this, TQ_SLOT( textSpacingSingle() ),
948 actionCollection(),
"format_spacingsingle" );
949 m_actionFormatSpacingSingle->setExclusiveGroup(
"spacing" );
950 m_actionFormatSpacingOneAndHalf =
new TDEToggleAction( i18n(
"Line Spacing 1.&5" ),
"spacedouble", TQt::CTRL + TQt::Key_5,
951 this, TQ_SLOT( textSpacingOneAndHalf() ),
952 actionCollection(),
"format_spacing15" );
953 m_actionFormatSpacingOneAndHalf->setExclusiveGroup(
"spacing" );
954 m_actionFormatSpacingDouble =
new TDEToggleAction( i18n(
"Line Spacing &2" ),
"spacetriple", TQt::CTRL + TQt::Key_2,
955 this, TQ_SLOT( textSpacingDouble() ),
956 actionCollection(),
"format_spacingdouble" );
957 m_actionFormatSpacingDouble->setExclusiveGroup(
"spacing" );
959 m_actionFormatSuper =
new TDEToggleAction( i18n(
"Superscript" ),
"super", 0,
960 this, TQ_SLOT( textSuperScript() ),
961 actionCollection(),
"format_super" );
963 m_actionFormatSub =
new TDEToggleAction( i18n(
"Subscript" ),
"sub", 0,
964 this, TQ_SLOT( textSubScript() ),
965 actionCollection(),
"format_sub" );
968 m_actionFormatIncreaseIndent=
new TDEAction( i18n(
"Increase Indent" ),
969 TQApplication::reverseLayout() ?
"format_decreaseindent" :
"format_increaseindent", 0,
970 this, TQ_SLOT( textIncreaseIndent() ),
971 actionCollection(),
"format_increaseindent" );
973 m_actionFormatDecreaseIndent=
new TDEAction( i18n(
"Decrease Indent" ),
974 TQApplication::reverseLayout() ?
"format_increaseindent" :
"format_decreaseindent", 0,
975 this, TQ_SLOT( textDecreaseIndent() ),
976 actionCollection(),
"format_decreaseindent" );
978 m_actionFormatColor =
new TTDESelectColorAction( i18n(
"Text Color..." ), TTDESelectColorAction::TextColor,
979 this, TQ_SLOT( textColor() ),
980 actionCollection(),
"format_color",
true );
981 m_actionFormatColor->setDefaultColor(TQColor());
989 m_actionFormatNumber =
new TDEActionMenu( i18n(
"Number" ),
990 "enumList", actionCollection(),
"format_number" );
991 m_actionFormatNumber->setDelayed(
false );
992 m_actionFormatBullet =
new TDEActionMenu( i18n(
"Bullet" ),
993 "unsortedList", actionCollection(),
"format_bullet" );
994 m_actionFormatBullet->setDelayed(
false );
995 TQPtrList<KoCounterStyleWidget::StyleRepresenter> stylesList;
996 KoCounterStyleWidget::makeCounterRepresenterList( stylesList );
997 TQPtrListIterator<KoCounterStyleWidget::StyleRepresenter> styleIt( stylesList );
998 for ( ; styleIt.current() ; ++styleIt ) {
1001 TDEToggleAction* act =
new TDEToggleAction( styleIt.current()->name(),
1002 0,
this, TQ_SLOT( slotCounterStyleSelected() ),
1003 actionCollection(), TQString(
"counterstyle_%1").arg( styleIt.current()->style() ).latin1() );
1004 act->setExclusiveGroup(
"counterstyle" );
1006 if ( styleIt.current()->style() == KoParagCounter::STYLE_NONE ) {
1007 m_actionFormatBullet->insert( act );
1008 m_actionFormatNumber->insert( act );
1009 }
else if ( styleIt.current()->isBullet() )
1010 m_actionFormatBullet->insert( act );
1012 m_actionFormatNumber->insert( act );
1017 m_actionFrameStyleMenu =
new TDEActionMenu( i18n(
"Fra&mestyle" ), 0,
1018 actionCollection(),
"frame_stylemenu" );
1019 m_actionFrameStyle =
new TDESelectAction( i18n(
"Framest&yle" ), 0,
1020 actionCollection(),
"frame_style" );
1021 connect( m_actionFrameStyle, TQ_SIGNAL( activated(
int ) ),
1022 this, TQ_SLOT( frameStyleSelected(
int ) ) );
1023 updateFrameStyleList();
1024 m_actionBorderOutline =
new TDEToggleAction( i18n(
"Border Outline" ),
"borderoutline",
1025 0,
this, TQ_SLOT( borderOutline() ), actionCollection(),
"border_outline" );
1026 m_actionBorderLeft =
new TDEToggleAction( i18n(
"Border Left" ),
"borderleft",
1027 0,
this, TQ_SLOT( borderLeft() ), actionCollection(),
"border_left" );
1028 m_actionBorderRight =
new TDEToggleAction( i18n(
"Border Right" ),
"borderright",
1029 0,
this, TQ_SLOT( borderRight() ), actionCollection(),
"border_right" );
1030 m_actionBorderTop =
new TDEToggleAction( i18n(
"Border Top" ),
"bordertop",
1031 0,
this, TQ_SLOT( borderTop() ), actionCollection(),
"border_top" );
1032 m_actionBorderBottom =
new TDEToggleAction( i18n(
"Border Bottom" ),
"borderbottom",
1033 0,
this, TQ_SLOT( borderBottom() ), actionCollection(),
"border_bottom" );
1034 m_actionBorderStyle =
new TDESelectAction( i18n(
"Border Style" ),
1035 0, actionCollection(),
"border_style" );
1038 lst << KoBorder::getStyle( KoBorder::SOLID );
1039 lst << KoBorder::getStyle( KoBorder::DASH );
1040 lst << KoBorder::getStyle( KoBorder::DOT );
1041 lst << KoBorder::getStyle( KoBorder::DASH_DOT );
1042 lst << KoBorder::getStyle( KoBorder::DASH_DOT_DOT );
1043 lst << KoBorder::getStyle( KoBorder::DOUBLE_LINE );
1044 m_actionBorderStyle->setItems( lst );
1045 m_actionBorderWidth =
new TDESelectAction( i18n(
"Border Width" ), 0,
1046 actionCollection(),
"border_width" );
1048 for (
unsigned int i = 1; i < 10; i++ )
1049 lst << TQString::number( i );
1050 m_actionBorderWidth->setItems( lst );
1051 m_actionBorderWidth->setCurrentItem( 0 );
1053 m_actionBorderColor =
new TTDESelectColorAction( i18n(
"Border Color"), TTDESelectColorAction::LineColor, actionCollection(),
"border_color",
true );
1054 m_actionBorderColor->setDefaultColor(TQColor());
1057 m_actionBackgroundColor =
new TTDESelectColorAction( i18n(
"Text Background Color..." ), TTDESelectColorAction::FillColor, actionCollection(),
"border_backgroundcolor",
true);
1058 m_actionBackgroundColor->setToolTip( i18n(
"Change background color for currently selected text." ) );
1059 m_actionBackgroundColor->setWhatsThis( i18n(
"Change background color for currently selected text." ) );
1061 connect(m_actionBackgroundColor,TQ_SIGNAL(activated()),TQ_SLOT(backgroundColor() ));
1062 m_actionBackgroundColor->setDefaultColor(TQColor());
1065 m_actionTablePropertiesMenu =
new TDEAction( i18n(
"&Properties" ), 0,
1066 this, TQ_SLOT( tableProperties() ),
1067 actionCollection(),
"table_propertiesmenu" );
1068 m_actionTablePropertiesMenu->setToolTip( i18n(
"Adjust properties of the current table." ) );
1069 m_actionTablePropertiesMenu->setWhatsThis( i18n(
"Adjust properties of the current table." ) );
1071 m_actionTableInsertRow =
new TDEAction( i18n(
"&Insert Row..." ),
"insert_table_row", 0,
1072 this, TQ_SLOT( tableInsertRow() ),
1073 actionCollection(),
"table_insrow" );
1074 m_actionTableInsertRow->setToolTip( i18n(
"Insert one or more rows at cursor location." ) );
1075 m_actionTableInsertRow->setWhatsThis( i18n(
"Insert one or more rows at current cursor location." ) );
1077 m_actionTableInsertCol =
new TDEAction( i18n(
"I&nsert Column..." ),
"insert_table_col", 0,
1078 this, TQ_SLOT( tableInsertCol() ),
1079 actionCollection(),
"table_inscol" );
1080 m_actionTableInsertCol->setToolTip( i18n(
"Insert one or more columns into the current table." ) );
1081 m_actionTableInsertCol->setWhatsThis( i18n(
"Insert one or more columns into the current table." ) );
1083 m_actionTableDelRow =
new TDEAction( 0,
"delete_table_row", 0,
1084 this, TQ_SLOT( tableDeleteRow() ),
1085 actionCollection(),
"table_delrow" );
1086 m_actionTableDelRow->setToolTip( i18n(
"Delete selected rows from the current table." ) );
1087 m_actionTableDelRow->setWhatsThis( i18n(
"Delete selected rows from the current table." ) );
1089 m_actionTableDelCol =
new TDEAction( 0,
"delete_table_col", 0,
1090 this, TQ_SLOT( tableDeleteCol() ),
1091 actionCollection(),
"table_delcol" );
1092 m_actionTableDelCol->setToolTip( i18n(
"Delete selected columns from the current table." ) );
1093 m_actionTableDelCol->setWhatsThis( i18n(
"Delete selected columns from the current table." ) );
1095 m_actionTableResizeCol =
new TDEAction( i18n(
"Resize Column..." ), 0,
1096 this, TQ_SLOT( tableResizeCol() ),
1097 actionCollection(),
"table_resizecol" );
1098 m_actionTableResizeCol->setToolTip( i18n(
"Change the width of the currently selected column." ) );
1099 m_actionTableResizeCol->setWhatsThis( i18n(
"Change the width of the currently selected column." ) );
1102 m_actionTableJoinCells =
new TDEAction( i18n(
"&Join Cells" ), 0,
1103 this, TQ_SLOT( tableJoinCells() ),
1104 actionCollection(),
"table_joincells" );
1105 m_actionTableJoinCells->setToolTip( i18n(
"Join two or more cells into one large cell." ) );
1106 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." ) );
1108 m_actionTableSplitCells=
new TDEAction( i18n(
"&Split Cell..." ), 0,
1109 this, TQ_SLOT( tableSplitCells() ),
1110 actionCollection(),
"table_splitcells" );
1111 m_actionTableSplitCells->setToolTip( i18n(
"Split one cell into two or more cells." ) );
1112 m_actionTableSplitCells->setWhatsThis( i18n(
"Split one cell into two or more cells.<p>Cells can be split horizontally, vertically or both directions at once." ) );
1114 m_actionTableProtectCells=
new TDEToggleAction( i18n(
"Protect Cells" ), 0, 0, 0,
1115 actionCollection(),
"table_protectcells" );
1116 m_actionTableProtectCells->setToolTip( i18n(
"Prevent changes to content of selected cells." ) );
1117 connect (m_actionTableProtectCells, TQ_SIGNAL( toggled(
bool) ),
this,
1118 TQ_SLOT( tableProtectCells(
bool) ));
1120 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." ) );
1122 m_actionTableUngroup =
new TDEAction( i18n(
"&Ungroup Table" ), 0,
1123 this, TQ_SLOT( tableUngroupTable() ),
1124 actionCollection(),
"table_ungroup" );
1125 m_actionTableUngroup->setToolTip( i18n(
"Break a table into individual frames." ) );
1126 m_actionTableUngroup->setWhatsThis( i18n(
"Break a table into individual frames<p>Each frame can be moved independently around the page." ) );
1128 m_actionTableDelete =
new TDEAction( i18n(
"Delete &Table" ), 0,
1129 this, TQ_SLOT( tableDelete() ),
1130 actionCollection(),
"table_delete" );
1131 m_actionTableDelete->setToolTip( i18n(
"Delete the entire table." ) );
1132 m_actionTableDelete->setWhatsThis( i18n(
"Deletes all cells and the content within the cells of the currently selected table." ) );
1135 m_actionTableStylist =
new TDEAction( i18n(
"T&able Style Manager" ), 0,
1136 this, TQ_SLOT( tableStylist() ),
1137 actionCollection(),
"table_stylist" );
1138 m_actionTableStylist->setToolTip( i18n(
"Change attributes of tablestyles." ) );
1139 m_actionTableStylist->setWhatsThis( i18n(
"Change textstyle and framestyle of the tablestyles.<p>Multiple tablestyles can be changed using the dialog box." ) );
1141 m_actionTableStyleMenu =
new TDEActionMenu( i18n(
"Table&style" ), 0,
1142 actionCollection(),
"table_stylemenu" );
1143 m_actionTableStyle =
new TDESelectAction( i18n(
"Table&style" ), 0,
1144 actionCollection(),
"table_style" );
1145 connect( m_actionTableStyle, TQ_SIGNAL( activated(
int ) ),
1146 this, TQ_SLOT( tableStyleSelected(
int ) ) );
1147 updateTableStyleList();
1149 m_actionConvertTableToText =
new TDEAction( i18n(
"Convert Table to Text" ), 0,
1150 this, TQ_SLOT( convertTableToText() ),
1151 actionCollection(),
"convert_table_to_text" );
1152 m_actionSortText=
new TDEAction( i18n(
"Sort Text..." ), 0,
1153 this, TQ_SLOT( sortText() ),
1154 actionCollection(),
"sort_text" );
1156 m_actionAddPersonalExpression=
new TDEAction( i18n(
"Add Expression" ), 0,
1157 this, TQ_SLOT( addPersonalExpression() ),
1158 actionCollection(),
"add_personal_expression" );
1164 m_actionAllowAutoFormat =
new TDEToggleAction( i18n(
"Enable Autocorrection" ), 0,
1165 this, TQ_SLOT( slotAllowAutoFormat() ),
1166 actionCollection(),
"enable_autocorrection" );
1167 m_actionAllowAutoFormat->setCheckedState(i18n(
"Disable Autocorrection"));
1168 m_actionAllowAutoFormat->setToolTip( i18n(
"Toggle autocorrection on and off." ) );
1169 m_actionAllowAutoFormat->setWhatsThis( i18n(
"Toggle autocorrection on and off." ) );
1171 m_actionAutoFormat =
new TDEAction( i18n(
"Configure &Autocorrection..." ), 0,
1172 this, TQ_SLOT( extraAutoFormat() ),
1173 actionCollection(),
"configure_autocorrection" );
1174 m_actionAutoFormat->setToolTip( i18n(
"Change autocorrection options." ) );
1175 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>." ) );
1177 m_actionEditCustomVarsEdit =
new TDEAction( i18n(
"Custom &Variables..." ), 0,
1178 this, TQ_SLOT( editCustomVars() ),
1179 actionCollection(),
"custom_vars" );
1181 m_actionEditPersonnalExpr=
new TDEAction( i18n(
"Edit &Personal Expressions..." ), 0,
1182 this, TQ_SLOT( editPersonalExpr() ),
1183 actionCollection(),
"personal_expr" );
1184 m_actionEditPersonnalExpr->setToolTip( i18n(
"Add or change one or more personal expressions." ) );
1185 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." ) );
1187 m_actionChangeCase=
new TDEAction( i18n(
"Change Case..." ), 0,
1188 this, TQ_SLOT( changeCaseOfText() ),
1189 actionCollection(),
"change_case" );
1190 m_actionChangeCase->setToolTip( i18n(
"Alter the capitalization of selected text." ) );
1191 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." ) );
1194 m_actionConfigure = KStdAction::preferences(
this, TQ_SLOT(configure()), actionCollection(),
"configure" );
1197 TDEAction *actionChangePicture=
new TDEAction( i18n(
"Change Picture..." ),
"frame_image",0,
1198 this, TQ_SLOT( changePicture() ),
1199 actionCollection(),
"change_picture" );
1200 actionChangePicture->setToolTip( i18n(
"Change the picture in the currently selected frame." ) );
1201 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." ) );
1203 m_actionConfigureHeaderFooter=
new TDEAction( i18n(
"Configure Header/Footer..." ), 0,
1204 this, TQ_SLOT( configureHeaderFooter() ),
1205 actionCollection(),
"configure_headerfooter" );
1206 m_actionConfigureHeaderFooter->setToolTip( i18n(
"Configure the currently selected header or footer." ) );
1207 m_actionConfigureHeaderFooter->setWhatsThis( i18n(
"Configure the currently selected header or footer." ) );
1209 m_actionInlineFrame =
new TDEToggleAction( i18n(
"Inline Frame" ), 0,
1210 this, TQ_SLOT( inlineFrame() ),
1211 actionCollection(),
"inline_frame" );
1212 m_actionInlineFrame->setToolTip( i18n(
"Convert current frame to an inline frame." ) );
1213 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." ) );
1215 m_actionOpenLink =
new TDEAction( i18n(
"Open Link" ), 0,
1216 this, TQ_SLOT( openLink() ),
1217 actionCollection(),
"open_link" );
1218 m_actionOpenLink->setToolTip( i18n(
"Open the link with the appropriate application." ) );
1219 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." ) );
1221 m_actionChangeLink=
new TDEAction( i18n(
"Change Link..."), 0,
1222 this, TQ_SLOT(changeLink()),
1223 actionCollection(),
"change_link");
1224 m_actionChangeLink->setToolTip( i18n(
"Change the content of the currently selected link." ) );
1225 m_actionChangeLink->setWhatsThis( i18n(
"Change the details of the currently selected link." ) );
1227 m_actionCopyLink =
new TDEAction( i18n(
"Copy Link" ), 0,
1228 this, TQ_SLOT( copyLink() ),
1229 actionCollection(),
"copy_link" );
1231 m_actionAddLinkToBookmak =
new TDEAction( i18n(
"Add to Bookmark" ), 0,
1232 this, TQ_SLOT( addToBookmark() ),
1233 actionCollection(),
"add_to_bookmark" );
1235 m_actionRemoveLink =
new TDEAction( i18n(
"Remove Link" ), 0,
1236 this, TQ_SLOT( removeLink() ),
1237 actionCollection(),
"remove_link" );
1239 m_actionShowDocStruct =
new TDEToggleAction( i18n(
"Show Doc Structure" ), 0,
1240 this, TQ_SLOT( showDocStructure() ),
1241 actionCollection(),
"show_docstruct" );
1242 m_actionShowDocStruct->setCheckedState(i18n(
"Hide Doc Structure"));
1243 m_actionShowDocStruct->setToolTip( i18n(
"Open document structure sidebar." ) );
1244 m_actionShowDocStruct->setWhatsThis( i18n(
"Open document structure sidebar.<p>This sidebar helps you organize your document and quickly find pictures, tables etc." ) );
1246 m_actionShowRuler =
new TDEToggleAction( i18n(
"Show Rulers" ), 0,
1247 this, TQ_SLOT( showRuler() ),
1248 actionCollection(),
"show_ruler" );
1249 m_actionShowRuler->setCheckedState(i18n(
"Hide Rulers"));
1250 m_actionShowRuler->setToolTip( i18n(
"Shows or hides rulers." ) );
1251 m_actionShowRuler->setWhatsThis( i18n(
"The rulers are the white measuring spaces top and left of the "
1252 "document. The rulers show the position and width of pages and of frames and can "
1253 "be used to position tabulators among others.<p>Uncheck this to disable "
1254 "the rulers from being displayed." ) );
1256 m_actionViewShowGrid =
new TDEToggleAction( i18n(
"Show Grid" ), 0,
1257 this, TQ_SLOT( viewGrid() ),
1258 actionCollection(),
"view_grid" );
1259 m_actionViewShowGrid->setCheckedState(i18n(
"Hide Grid"));
1261 m_actionViewSnapToGrid=
new TDEToggleAction( i18n(
"Snap to Grid" ), 0,
1262 this, TQ_SLOT(viewSnapToGrid() ),
1263 actionCollection(),
"view_snaptogrid" );
1265 m_actionConfigureCompletion =
new TDEAction( i18n(
"Configure C&ompletion..." ), 0,
1266 this, TQ_SLOT( configureCompletion() ),
1267 actionCollection(),
"configure_completion" );
1268 m_actionConfigureCompletion->setToolTip( i18n(
"Change the words and options for autocompletion." ) );
1269 m_actionConfigureCompletion->setWhatsThis( i18n(
"Add words or change the options for autocompletion." ) );
1273 new TDEAction( i18n(
"Insert Non-Breaking Space" ), TQt::CTRL+TQt::Key_Space,
1274 this, TQ_SLOT( slotNonbreakingSpace() ), actionCollection(),
"nonbreaking_space" );
1275 new TDEAction( i18n(
"Insert Non-Breaking Hyphen" ), TQt::CTRL+TQt::SHIFT+TQt::Key_Minus,
1276 this, TQ_SLOT( slotNonbreakingHyphen() ), actionCollection(),
"nonbreaking_hyphen" );
1277 new TDEAction( i18n(
"Insert Soft Hyphen" ), TQt::CTRL+TQt::Key_Minus,
1278 this, TQ_SLOT( slotSoftHyphen() ), actionCollection(),
"soft_hyphen" );
1279 new TDEAction( i18n(
"Line Break" ), TQt::SHIFT+TQt::Key_Return,
1280 this, TQ_SLOT( slotLineBreak() ), actionCollection(),
"line_break" );
1282 new TDEAction( i18n(
"Completion" ), TDEStdAccel::shortcut(TDEStdAccel::TextCompletion),
this, TQ_SLOT( slotCompletion() ), actionCollection(),
"completion" );
1284 new TDEAction( i18n(
"Increase Numbering Level" ), TQt::ALT+TQt::Key_Right,
1285 this, TQ_SLOT( slotIncreaseNumberingLevel() ), actionCollection(),
"increase_numbering_level" );
1286 new TDEAction( i18n(
"Decrease Numbering Level" ), TQt::ALT+TQt::Key_Left,
1287 this, TQ_SLOT( slotDecreaseNumberingLevel() ), actionCollection(),
"decrease_numbering_level" );
1291 m_actionEditCustomVars =
new TDEAction( i18n(
"Edit Variable..." ), 0,
1292 this, TQ_SLOT( editCustomVariable() ),
1293 actionCollection(),
"edit_customvars" );
1294 m_actionApplyAutoFormat=
new TDEAction( i18n(
"Apply Autocorrection" ), 0,
1295 this, TQ_SLOT( applyAutoFormat() ),
1296 actionCollection(),
"apply_autoformat" );
1297 m_actionApplyAutoFormat->setToolTip( i18n(
"Manually force KWord to scan the entire document and apply autocorrection." ) );
1298 m_actionApplyAutoFormat->setWhatsThis( i18n(
"Manually force KWord to scan the entire document and apply autocorrection." ) );
1300 m_actionCreateStyleFromSelection =
new TDEAction( i18n(
"Create Style From Selection..." ), 0,
1301 this, TQ_SLOT( createStyleFromSelection()),
1302 actionCollection(),
"create_style" );
1303 m_actionCreateStyleFromSelection->setToolTip( i18n(
"Create a new style based on the currently selected text." ) );
1304 m_actionCreateStyleFromSelection->setWhatsThis( i18n(
"Create a new style based on the currently selected text." ) );
1306 m_actionConfigureFootEndNote =
new TDEAction( i18n(
"&Footnote..." ), 0,
1307 this, TQ_SLOT( configureFootEndNote()),
1308 actionCollection(),
"format_footendnote" );
1309 m_actionConfigureFootEndNote->setToolTip( i18n(
"Change the look of footnotes." ) );
1310 m_actionConfigureFootEndNote->setWhatsThis( i18n(
"Change the look of footnotes." ) );
1312 m_actionEditFootEndNote=
new TDEAction( i18n(
"Edit Footnote"), 0,
1313 this, TQ_SLOT( editFootEndNote()),
1314 actionCollection(),
"edit_footendnote" );
1315 m_actionEditFootEndNote->setToolTip( i18n(
"Change the content of the currently selected footnote." ) );
1316 m_actionEditFootEndNote->setWhatsThis( i18n(
"Change the content of the currently selected footnote." ) );
1319 m_actionChangeFootNoteType =
new TDEAction( i18n(
"Change Footnote/Endnote Parameter"), 0,
1320 this, TQ_SLOT( changeFootNoteType() ),
1321 actionCollection(),
"change_footendtype");
1323 m_actionSavePicture=
new TDEAction( i18n(
"Save Picture As..."), 0,
1324 this, TQ_SLOT( savePicture() ),
1325 actionCollection(),
"save_picture");
1326 m_actionSavePicture->setToolTip( i18n(
"Save the picture in a separate file." ) );
1327 m_actionSavePicture->setWhatsThis( i18n(
"Save the picture in the currently selected frame in a separate file, outside the KWord document." ) );
1329 m_actionAllowBgSpellCheck =
new TDEToggleAction( i18n(
"Autospellcheck" ), 0,
1330 this, TQ_SLOT( autoSpellCheck() ),
1331 actionCollection(),
"tool_auto_spellcheck" );
1334 m_actionGoToFootEndNote =
new TDEAction( TQString() , 0,
1335 this, TQ_SLOT( goToFootEndNote() ),
1336 actionCollection(),
"goto_footendnote" );
1339 m_actionDocStructEdit =
new TDEAction( i18n(
"Edit Text" ), 0,
1340 this, TQ_SLOT( docStructEdit() ),
1341 actionCollection(),
"docstruct_edit" );
1342 m_actionDocStructSpeak =
new TDEAction( i18n(
"Speak Text" ), 0,
1343 this, TQ_SLOT( docStructSpeak() ),
1344 actionCollection(),
"docstruct_speak" );
1345 m_actionDocStructSelect =
new TDEAction( i18n(
"Show" ), 0,
1346 this, TQ_SLOT( docStructSelect() ),
1347 actionCollection(),
"docstruct_select" );
1348 m_actionDocStructDelete =
new TDEAction( i18n(
"Delete Frame" ), 0,
1349 this, TQ_SLOT( docStructDelete() ),
1350 actionCollection(),
"docstruct_delete" );
1351 m_actionDocStructProperties =
new TDEAction( i18n(
"Properties" ), 0,
1352 this, TQ_SLOT( docStructProperties() ),
1353 actionCollection(),
"docstruct_properties" );
1355 m_actionAddBookmark=
new TDEAction( i18n(
"&Bookmark..." ), 0,
1356 this, TQ_SLOT( addBookmark() ),
1357 actionCollection(),
"add_bookmark" );
1358 m_actionSelectBookmark=
new TDEAction( i18n(
"Select &Bookmark..." ), 0,
1359 this, TQ_SLOT( selectBookmark() ),
1360 actionCollection(),
"select_bookmark" );
1362 m_actionImportStyle=
new TDEAction( i18n(
"Import Styles..." ), 0,
1363 this, TQ_SLOT( importStyle() ),
1364 actionCollection(),
"import_style" );
1366 m_actionCreateFrameStyle =
new TDEAction( i18n(
"&Create Framestyle From Frame..." ), 0,
1367 this, TQ_SLOT( createFrameStyle()),
1368 actionCollection(),
"create_framestyle" );
1369 m_actionCreateFrameStyle->setToolTip( i18n(
"Create a new style based on the currently selected frame." ) );
1370 m_actionCreateFrameStyle->setWhatsThis( i18n(
"Create a new framestyle based on the currently selected frame." ) );
1373 m_actionInsertDirectCursor =
new TDEToggleAction( i18n(
"Type Anywhere Cursor" ), 0,
1374 this, TQ_SLOT( insertDirectCursor() ),
1375 actionCollection(),
"direct_cursor" );
1378 m_actionConvertToTextBox =
new TDEAction( i18n(
"Convert to Text Box" ), 0,
1379 this, TQ_SLOT( convertToTextBox() ),
1380 actionCollection(),
"convert_to_text_box" );
1383 m_actionSpellIgnoreAll =
new TDEAction( i18n(
"Ignore All" ), 0,
1384 this, TQ_SLOT( slotAddIgnoreAllWord() ),
1385 actionCollection(),
"ignore_all" );
1387 m_actionAddWordToPersonalDictionary=
new TDEAction( i18n(
"Add Word to Dictionary" ),0,
1388 this, TQ_SLOT( addWordToDictionary() ),
1389 actionCollection(),
"add_word_to_dictionary" );
1391 m_actionEmbeddedStoreInternal=
new TDEToggleAction( i18n(
"Store Document Internally" ),0,
1392 this, TQ_SLOT( embeddedStoreInternal() ),
1393 actionCollection(),
"embedded_store_internal" );
1395 m_actionGoToDocumentStructure=
new TDEAction( i18n(
"Go to Document Structure" ), TDEShortcut(
"Alt+1"),
1396 this, TQ_SLOT( goToDocumentStructure() ),
1397 actionCollection(),
"goto_document_structure" );
1398 m_actionGoToDocument=
new TDEAction( i18n(
"Go to Document" ), TDEShortcut(
"Alt+2"),
1399 this, TQ_SLOT( goToDocument() ),
1400 actionCollection(),
"goto_document" );
1405 m_tableActionList.append(
new TDEActionSeparator(actionCollection()) );
1406 m_tableActionList.append( m_actionTableInsertRow );
1407 m_tableActionList.append( m_actionTableDelRow );
1408 m_tableActionList.append( m_actionTableInsertCol );
1409 m_tableActionList.append( m_actionTableDelCol );
1412void KWView::refreshMenuExpression()
1414 loadexpressionActions( m_actionInsertExpression);
1417void KWView::updateGridButton()
1419 m_actionViewShowGrid->setChecked( m_doc->showGrid() );
1420 m_actionViewSnapToGrid->setChecked ( m_doc->snapToGrid() );
1423void KWView::loadexpressionActions( TDEActionMenu * parentMenu)
1425 TDEActionPtrList lst = actionCollection()->actions(
"expression-action");
1426 TQValueList<TDEAction *> actions = lst;
1427 TQValueList<TDEAction *>::ConstIterator it = lst.begin();
1428 TQValueList<TDEAction *>::ConstIterator end = lst.end();
1430 TQMap<TQString, TDEShortcut> personalShortCuts;
1431 for (; it != end; ++it )
1433 personalShortCuts.insert( (*it)->text(), (*it)->shortcut() );
1437 parentMenu->popupMenu()->clear();
1438 TQStringList path = m_doc->personalExpressionPath();
1440 for ( TQStringList::Iterator it = path.begin(); it != path.end(); ++it )
1445 TQStringList tmp = dir.entryList(
"*.xml");
1446 for ( TQStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2 )
1447 files.append( TQString( (*it) + (*it2) ));
1454 for( TQStringList::Iterator it = files.begin(); it != files.end(); ++it,nbFile++ )
1455 createExpressionActions( parentMenu,*it, i,(nbFile<(
int)files.count()-1), personalShortCuts );
1458void KWView::createExpressionActions( TDEActionMenu * parentMenu,
const TQString& filename,
int &i,
bool insertSepar,
const TQMap<TQString, TDEShortcut>& personalShortCut )
1460 TQFile file( filename );
1461 if ( !file.exists() || !file.open( IO_ReadOnly ) )
1465 doc.setContent( &file );
1468 bool expressionExist =
false;
1469 TQDomNode n = doc.documentElement().firstChild();
1470 for( ; !n.isNull(); n = n.nextSibling() )
1472 if ( n.isElement() )
1474 TQDomElement e = n.toElement();
1475 if ( e.tagName() ==
"Type" )
1477 expressionExist =
true;
1478 TQString group = i18n( e.namedItem(
"TypeName" ).toElement().text().utf8() );
1479 TDEActionMenu * subMenu =
new TDEActionMenu( group, actionCollection() );
1480 parentMenu->insert( subMenu );
1482 TQDomNode n2 = e.firstChild();
1483 for( ; !n2.isNull(); n2 = n2.nextSibling() )
1486 if ( n2.isElement() )
1488 TQDomElement e2 = n2.toElement();
1489 if ( e2.tagName() ==
"Expression" )
1491 TQString text = i18n( e2.namedItem(
"Text" ).toElement().text().utf8() );
1492 TDEAction * act =
new TDEAction( text, 0,
this, TQ_SLOT( insertExpression() ),
1494 TQString(
"expression-action_%1").arg(i).latin1() );
1495 if ( personalShortCut.contains(text) )
1496 act->setShortcut( personalShortCut[text] );
1498 act->setGroup(
"expression-action");
1499 subMenu->insert( act );
1506 if(expressionExist && insertSepar)
1507 parentMenu->popupMenu()->insertSeparator();
1510void KWView::insertExpression()
1515 TDEAction * act = (TDEAction *)(sender());
1516 edit->insertExpression(act->text());
1521void KWView::addVariableActions(
int type,
const TQStringList & texts,
1522 TDEActionMenu * parentMenu,
const TQString & menuText )
1526 if ( texts.count() > 1 && !menuText.isEmpty() )
1528 TDEActionMenu * subMenu =
new TDEActionMenu( menuText, actionCollection() );
1529 parentMenu->insert( subMenu );
1530 parentMenu = subMenu;
1532 TQStringList::ConstIterator it = texts.begin();
1533 for (
int i = 0; it != texts.end() ; ++it, ++i )
1535 if ( !(*it).isEmpty() )
1540 TQCString actionName;
1541 actionName.sprintf(
"var-action-%d-%d", type, i );
1542 TDEAction * act =
new TDEAction( (*it), 0,
this, TQ_SLOT( insertVariable() ),
1543 actionCollection(), actionName );
1545 act->setToolTip( i18n(
"Insert variable \"%1\" into the text" ).arg( *it ) );
1546 m_variableDefMap.insert( act, v );
1547 parentMenu->insert( act );
1552void KWView::refreshCustomMenu()
1554 TDEActionPtrList lst2 = actionCollection()->actions(
"custom-variable-action");
1555 TQValueList<TDEAction *> actions = lst2;
1556 TQValueList<TDEAction *>::ConstIterator it2 = lst2.begin();
1557 TQValueList<TDEAction *>::ConstIterator end = lst2.end();
1558 TQMap<TQString, TDEShortcut> shortCuts;
1560 for (; it2 != end; ++it2 )
1562 shortCuts.insert((*it2)->text(), (*it2)->shortcut());
1566 delete m_actionInsertCustom;
1567 m_actionInsertCustom =
new TDEActionMenu( i18n(
"&Custom" ),
1568 actionCollection(),
"insert_custom" );
1569 actionInsertVariable->insert(m_actionInsertCustom, 0);
1571 m_actionInsertCustom->popupMenu()->clear();
1572 TQPtrListIterator<KoVariable> it( m_doc->variableCollection()->getVariables() );
1577 for ( ; it.current() ; ++it )
1579 KoVariable *var = it.current();
1580 if ( var->type() == VT_CUSTOM )
1582 varName=( (KoCustomVariable*) var )->name();
1583 if ( !lst.contains( varName) )
1585 lst.append( varName );
1586 TQCString name = TQString(
"custom-action_%1").arg(i).latin1();
1587 act =
new TDEAction( varName, shortCuts[varName],
this, TQ_SLOT( insertCustomVariable() ),actionCollection(), name );
1588 act->setGroup(
"custom-variable-action" );
1589 m_actionInsertCustom->insert( act );
1594 bool state=!lst.isEmpty();
1596 m_actionInsertCustom->popupMenu()->insertSeparator();
1598 act =
new TDEAction( i18n(
"New..."), 0,
this, TQ_SLOT( insertNewCustomVariable() ), actionCollection(),TQString(
"custom-action_%1").arg(i).latin1());
1599 act->setGroup(
"custom-variable-action" );
1602 m_actionEditCustomVarsEdit->setEnabled( state );
1604 m_actionInsertCustom->insert( act );
1609void KWView::insertCustomVariable()
1614 TDEAction * act = (TDEAction *)(sender());
1615 edit->insertCustomVariable(act->text());
1619void KWView::insertNewCustomVariable()
1623 edit->insertVariable( VT_CUSTOM, 0 );
1626void KWView::showFormulaToolbar(
bool show )
1628 m_doc->formulaDocument()->setEnabled( show );
1629 m_doc->formulaDocumentWrapper()->enableMatrixActions( show );
1630 m_doc->formulaDocumentWrapper()->getSyntaxHighlightingAction()->setEnabled(
true );
1632 shell()->showToolbar(
"formula_toolbar", show );
1635void KWView::updatePageInfo()
1637 if ( m_sbPageLabel )
1639 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
1640 if ( edit && edit->currentFrame() )
1641 m_currentPage = m_doc->pageManager()->page(edit->currentFrame());
1643 KWFrameView *view = frameViewManager()->selectedFrame();
1645 m_currentPage = m_doc->pageManager()->page(view->
frame());
1653 TQString oldText = m_sbPageLabel->text();
1655 if ( viewMode()->hasPages() )
1656 newText =
' ' + i18n(
"Page %1 of %2" ).arg(m_currentPage->pageNumber())
1657 .arg(m_doc->pageCount()) +
' ';
1659 if ( newText != oldText )
1661 m_sbPageLabel->setText( newText );
1664 m_sbPageLabel->repaint();
1670void KWView::numPagesChanged()
1672 docStructChanged(TextFrames);
1674 int pages = m_doc->pageCount();
1675 kdDebug() << pages <<
" " << (m_doc->processingType() == KWDocument::DTP) << endl;
1676 refreshDeletePageAction();
1679void KWView::updateFrameStatusBarItem()
1681 KStatusBar * sb = statusBar();
1682 int nbFrame=frameViewManager()->selectedFrames().count();
1683 if ( m_doc->showStatusBar() && sb && nbFrame > 0 )
1687 KoUnit::Unit unit = m_doc->unit();
1688 TQString unitName = m_doc->unitName();
1689 KWFrame * frame = frameViewManager()->selectedFrames()[0]->frame();
1690 m_sbFramesLabel->setText(
' ' + i18n(
"Statusbar info",
"%1: %2, %3 - %4, %5 (width: %6, height: %7)" )
1692 .arg( KoUnit::toUserStringValue( frame->left(), unit ) )
1693 .arg( KoUnit::toUserStringValue( frame->top() - m_doc->pageManager()->topOfPage(
1694 m_doc->pageManager()->pageNumber(frame->
rect()) ), unit) )
1695 .arg( KoUnit::toUserStringValue( frame->right(), unit ) )
1696 .arg( KoUnit::toUserStringValue( frame->bottom(), unit ) )
1697 .arg( KoUnit::toUserStringValue( frame->width(), unit ) )
1698 .arg( KoUnit::toUserStringValue( frame->height(), unit ) ) );
1700 m_sbFramesLabel->setText(
' ' + i18n(
"%1 frames selected" ).arg( nbFrame ) );
1702 else if ( sb && m_sbFramesLabel )
1703 m_sbFramesLabel->setText( TQString() );
1706void KWView::setTemporaryStatusBarText(
const TQString &text)
1708 if ( statusBar() && m_sbFramesLabel )
1709 m_sbFramesLabel->setText( text );
1712void KWView::clipboardDataChanged()
1714 if ( !m_gui || !m_doc->isReadWrite() )
1716 m_actionEditPaste->setEnabled(
false);
1719 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
1721 if ( edit && !TQApplication::clipboard()->text().isEmpty() )
1723 m_actionEditPaste->setEnabled(
true);
1726 TQMimeSource *data = TQApplication::clipboard()->data();
1727 const int provides = checkClipboard( data );
1728 if ( provides & ( ProvidesImage | ProvidesOasis | ProvidesFormula ) )
1729 m_actionEditPaste->setEnabled(
true );
1733 m_actionEditPaste->setEnabled( edit && ( provides & ProvidesPlainText ) );
1737int KWView::checkClipboard( TQMimeSource *data )
1740 TQValueList<TQCString> formats;
1742 for (
int i=0; (fmt = data->format(i)); i++)
1743 formats.append( TQCString( fmt ) );
1745 if ( TQImageDrag::canDecode( data ) )
1746 provides |= ProvidesImage;
1747 if ( formats.findIndex( KFormula::MimeSource::selectionMimeType() ) != -1 )
1748 provides |= ProvidesFormula;
1749 if ( formats.findIndex(
"text/plain" ) != -1 )
1750 provides |= ProvidesPlainText;
1751 TQCString returnedTypeMime = KoTextObject::providesOasis( data );
1752 if ( !returnedTypeMime.isEmpty() )
1753 provides |= ProvidesOasis;
1759void KWView::setupPrinter( KPrinter &prt )
1765 m_doc->recalcVariables( VT_TIME );
1766 m_doc->recalcVariables( VT_DATE );
1767 m_doc->recalcVariables( VT_STATISTIC );
1769 prt.setPageSelection( KPrinter::ApplicationSide );
1770 prt.setCurrentPage( currentPage() );
1771 prt.setMinMax( m_doc->startPage(), m_doc->lastPage() );
1773 KoPageLayout pgLayout = m_doc->pageLayout();
1775 prt.setPageSize(
static_cast<KPrinter::PageSize
>( KoPageFormat::printerPageSize( pgLayout.format ) ) );
1777 if ( pgLayout.orientation == PG_LANDSCAPE || pgLayout.format == PG_SCREEN )
1778 prt.setOrientation( KPrinter::Landscape );
1780 prt.setOrientation( KPrinter::Portrait );
1783void KWView::print( KPrinter &prt )
1785 bool displayFieldCode = m_doc->variableCollection()->variableSetting()->displayFieldCode();
1786 if ( displayFieldCode )
1788 m_doc->variableCollection()->variableSetting()->setDisplayFieldCode(
false);
1789 m_doc->recalcVariables( VT_ALL );
1793 m_gui->canvasWidget()->setUpdatesEnabled(
false);
1794 m_gui->canvasWidget()->viewport()->setCursor( waitCursor );
1796 prt.setFullPage(
true );
1801 bool doZoom =
false;
1807 int oldZoom = m_doc->zoom();
1810 TQPaintDeviceMetrics metrics( &prt );
1814 int dpiX = doZoom ? 300 : KoGlobal::dpiX();
1815 int dpiY = doZoom ? 300 : KoGlobal::dpiY();
1818 m_doc->setZoomAndResolution( 100, dpiX, dpiY );
1819 m_doc->newZoomAndResolution(
false,
true );
1823 bool serialLetter =
false;
1825 TQPtrList<KoVariable> vars = m_doc->variableCollection()->getVariables();
1827 for ( v = vars.first(); v; v = vars.next() ) {
1828 if ( v->type() == VT_MAILMERGE ) {
1829 serialLetter =
true;
1834 if ( !m_doc->mailMergeDataBase() ) serialLetter=
false;
1837 m_doc->mailMergeDataBase()->refresh(
false);
1838 if (m_doc->mailMergeDataBase()->getNumRecords() == 0 ) serialLetter =
false;
1844 KoPageLayout pgLayout;
1846 KoKWHeaderFooter hf;
1847 m_doc->getPageLayout( pgLayout, cl, hf );
1848 KoPageLayout oldPGLayout = pgLayout;
1850 if ( pgLayout.format == PG_SCREEN )
1854 pgLayout.ptLeft += 25.8;
1855 pgLayout.ptRight += 15.0;
1856 m_doc->setPageLayout( pgLayout, cl, hf,
false );
1860 painter.begin( &prt );
1862 kdDebug(32001) <<
"KWView::print scaling by " << (double)metrics.logicalDpiX() / (double)dpiX
1863 <<
"," << (
double)metrics.logicalDpiY() / (double)dpiY << endl;
1864 painter.scale( (
double)metrics.logicalDpiX() / (double)dpiX,
1865 (
double)metrics.logicalDpiY() / (double)dpiY );
1867 bool canceled =
false;
1870#ifdef KW_PASS_PAINTER_TO_TQRT
1873 for ( ; fit.current() ; ++fit )
1874 if ( fit.current()->isVisible() )
1875 paragraphs += fit.current()->paragraphs();
1876 kdDebug() <<
"KWView::print total paragraphs: " << paragraphs << endl;
1879 TQProgressDialog progress( i18n(
"Printing..." ), i18n(
"Cancel" ), paragraphs,
this );
1880 progress.setProgress( 0 );
1881 int processedParags = 0;
1883 for ( ; fit.current() ; ++fit )
1884 if ( fit.current()->isVisible() )
1886 tqApp->processEvents();
1887 if ( progress.wasCancelled() ) {
1892 kdDebug() <<
"KWView::print preparePrinting " << fit.current()->name() << endl;
1893 fit.current()->preparePrinting( &painter, &progress, processedParags );
1899 if ( !serialLetter )
1900 m_gui->canvasWidget()->print( &painter, &prt );
1903 for (
int i = 0; i < m_doc->mailMergeDataBase()->getNumRecords(); ++i ) {
1904 m_doc->setMailMergeRecord( i );
1905 m_doc->variableCollection()->recalcVariables(VT_MAILMERGE);
1906 m_gui->canvasWidget()->print( &painter, &prt );
1907 if ( i < m_doc->mailMergeDataBase()->getNumRecords() - 1 )
1910 m_doc->setMailMergeRecord( -1 );
1914 if ( pgLayout.format == PG_SCREEN )
1915 m_doc->setPageLayout( oldPGLayout, cl, hf,
false );
1917#ifdef KW_PASS_PAINTER_TO_TQRT
1919 for ( ; fit.current() ; ++fit )
1920 if ( fit.current()->isVisible() )
1921 fit.current()->preparePrinting( 0L, 0L, processedParags );
1924 m_doc->setZoomAndResolution( oldZoom, KoGlobal::dpiX(), KoGlobal::dpiY() );
1925 m_doc->newZoomAndResolution(
false,
false );
1926 kdDebug() <<
"KWView::print zoom&res reset" << endl;
1928 m_gui->canvasWidget()->setUpdatesEnabled(
true);
1929 m_gui->canvasWidget()->viewport()->setCursor( ibeamCursor );
1930 m_doc->repaintAllViews();
1932 if ( displayFieldCode )
1934 m_doc->variableCollection()->variableSetting()->setDisplayFieldCode(
true);
1935 m_doc->recalcVariables( VT_ALL );
1938 m_doc->variableCollection()->recalcVariables(VT_MAILMERGE);
1941 m_doc->variableCollection()->variableSetting()->setLastPrintingDate(TQDateTime::currentDateTime());
1942 m_doc->recalcVariables( VT_DATE );
1945void KWView::showFormat(
const KoTextFormat ¤tFormat )
1949 if (m_actionFormatFontFamily->font() != currentFormat.font().family())
1950 m_actionFormatFontFamily->setFont( currentFormat.font().family() );
1951 if (m_actionFormatFontSize->fontSize() != currentFormat.pointSize())
1952 m_actionFormatFontSize->setFontSize( currentFormat.pointSize() );
1953 m_actionFormatBold->setChecked( currentFormat.font().bold());
1954 m_actionFormatItalic->setChecked( currentFormat.font().italic() );
1955 m_actionFormatUnderline->setChecked( currentFormat.underline());
1956 m_actionFormatStrikeOut->setChecked( currentFormat.strikeOut());
1957 TQColor col=currentFormat.textBackgroundColor();
1959 m_actionBackgroundColor->setCurrentColor( col.isValid() ? col : TQApplication::palette().color( TQPalette::Active, TQColorGroup::Base ));
1961 if ( m_gui && frameViewManager()->selectedFrames().count() > 0)
1962 m_actionBackgroundColor->setText(i18n(
"Frame Background Color..."));
1964 m_actionBackgroundColor->setText(i18n(
"Text Background Color..."));
1965 switch(currentFormat.vAlign())
1967 case KoTextFormat::AlignSuperScript:
1969 m_actionFormatSub->setChecked(
false );
1970 m_actionFormatSuper->setChecked(
true );
1973 case KoTextFormat::AlignSubScript:
1975 m_actionFormatSub->setChecked(
true );
1976 m_actionFormatSuper->setChecked(
false );
1979 case KoTextFormat::AlignNormal:
1982 m_actionFormatSub->setChecked(
false );
1983 m_actionFormatSuper->setChecked(
false );
1990void KWView::showRulerIndent(
double leftMargin,
double firstLine,
double rightMargin,
bool rtl )
1992 KoRuler * hRuler = m_gui ? m_gui->getHorzRuler() : 0;
1995 hRuler->setFirstIndent( KoUnit::toUserValue( firstLine, m_doc->unit() ) );
1996 hRuler->setLeftIndent( KoUnit::toUserValue( leftMargin, m_doc->unit() ) );
1997 hRuler->setRightIndent( KoUnit::toUserValue( rightMargin, m_doc->unit() ) );
1998 hRuler->setDirection( rtl );
1999 m_actionFormatDecreaseIndent->setEnabled( leftMargin>0);
2003void KWView::showAlign(
int align ) {
2005 case TQt::AlignAuto:
2006 kdWarning() << k_funcinfo <<
"shouldn't be called with AlignAuto" << endl;
2008 case TQt::AlignLeft:
2009 m_actionFormatAlignLeft->setChecked(
true );
2011 case TQt::AlignHCenter:
2012 m_actionFormatAlignCenter->setChecked(
true );
2014 case TQt::AlignRight:
2015 m_actionFormatAlignRight->setChecked(
true );
2017 case TQt::AlignJustify:
2018 m_actionFormatAlignBlock->setChecked(
true );
2023void KWView::showSpacing(
int spacing ) {
2026 case KoParagLayout::LS_SINGLE:
2027 m_actionFormatSpacingSingle->setChecked(
true );
2029 case KoParagLayout::LS_ONEANDHALF:
2030 m_actionFormatSpacingOneAndHalf->setChecked(
true );
2032 case KoParagLayout::LS_DOUBLE:
2033 m_actionFormatSpacingDouble->setChecked(
true );
2036 m_actionFormatSpacingSingle->setChecked(
false );
2037 m_actionFormatSpacingOneAndHalf->setChecked(
false );
2038 m_actionFormatSpacingDouble->setChecked(
false );
2042void KWView::showCounter( KoParagCounter &c )
2044 TQString styleStr(
"counterstyle_");
2045 styleStr += TQString::number( c.style() );
2047 TDEToggleAction* act =
static_cast<TDEToggleAction *
>( actionCollection()->action( styleStr.latin1() ) );
2050 act->setChecked(
true );
2053void KWView::updateBorderButtons(
const KoBorder& left,
const KoBorder& right,
2054 const KoBorder& top,
const KoBorder& bottom )
2056 m_actionBorderLeft->setChecked( left.penWidth() > 0 );
2057 m_actionBorderRight->setChecked( right.penWidth() > 0 );
2058 m_actionBorderTop->setChecked( top.penWidth() > 0 );
2059 m_actionBorderBottom->setChecked( bottom.penWidth() > 0 );
2060 m_actionBorderOutline->setChecked(
2061 m_actionBorderLeft->isChecked() &&
2062 m_actionBorderRight->isChecked() &&
2063 m_actionBorderTop->isChecked() &&
2064 m_actionBorderBottom->isChecked());
2066 KoBorder border = left;
2067 if(left.penWidth() > 0)
2069 else if(right.penWidth() > 0)
2071 else if(top.penWidth() > 0)
2073 else if(bottom.penWidth() > 0)
2078 m_actionBorderWidth->setCurrentItem( (
int)border.penWidth() - 1 );
2079 m_actionBorderStyle->setCurrentItem( (
int)border.getStyle() );
2080 m_actionBorderColor->setCurrentColor( border.color );
2083void KWView::updateReadWrite(
bool readwrite )
2086 TQValueList<TDEAction*> actions = actionCollection()->actions();
2088 actions += m_doc->actionCollection()->actions();
2089 TQValueList<TDEAction*>::ConstIterator aIt = actions.begin();
2090 TQValueList<TDEAction*>::ConstIterator aEnd = actions.end();
2091 for (; aIt != aEnd; ++aIt )
2092 (*aIt)->setEnabled( readwrite );
2097 m_actionFileStatistics->setEnabled(
true );
2098 m_actionExtraCreateTemplate->setEnabled(
true );
2099 m_actionViewPageMode->setEnabled(
true );
2100 m_actionViewPreviewMode->setEnabled(
true );
2102 m_actionViewTextMode->setEnabled(
true );
2103 m_actionShowRuler->setEnabled(
true );
2104 m_actionEditFind->setEnabled(
true );
2105 m_actionViewFormattingChars->setEnabled(
true );
2106 m_actionViewFrameBorders->setEnabled(
true );
2110 m_actionViewZoom->setEnabled(
true );
2111 m_actionInsertComment->setEnabled(
true );
2112 m_actionAllowAutoFormat->setEnabled(
true );
2113 m_actionShowDocStruct->setEnabled(
true );
2114 m_actionConfigureCompletion->setEnabled(
true );
2115 m_actionFormatBullet->setEnabled(
true);
2116 m_actionFormatNumber->setEnabled(
true);
2117 m_actionSelectBookmark->setEnabled(
true );
2118 TDEAction* act = actionCollection()->action(
"edit_sldatabase");
2120 act->setEnabled(
true );
2130 frameSelectedChanged();
2131 slotFrameSetEditChanged();
2132 refreshCustomMenu();
2133 refreshDeletePageAction();
2135 m_doc->commandHistory()->updateActions();
2139void KWView::refreshDeletePageAction()
2141 m_actionDeletePage->setEnabled( m_doc->pageCount() > 1 && m_doc->processingType() == KWDocument::DTP );
2144void KWView::showMouseMode(
int mouseMode )
2146 switch ( mouseMode ) {
2147 case KWCanvas::MM_EDIT:
2148 case KWCanvas::MM_CREATE_TABLE:
2149 case KWCanvas::MM_CREATE_FORMULA:
2150 case KWCanvas::MM_CREATE_PART:
2152 m_actionToolsCreateText->setChecked(
false );
2153 m_actionToolsCreatePix->setChecked(
false );
2156 case KWCanvas::MM_CREATE_TEXT:
2157 m_actionToolsCreateText->setChecked(
true );
2159 case KWCanvas::MM_CREATE_PIX:
2160 m_actionToolsCreatePix->setChecked(
true );
2167 m_actionTableJoinCells->setEnabled(
false );
2168 m_actionTableSplitCells->setEnabled(
false );
2169 m_actionTableProtectCells->setEnabled(
false );
2170 m_actionFormatFrameSet->setEnabled(
false);
2171 m_actionTablePropertiesMenu->setEnabled(
false );
2172 m_actionConvertTableToText->setEnabled(
false );
2175void KWView::showStyle(
const TQString & styleName )
2177 KoParagStyle* style = m_doc->styleCollection()->findStyle( styleName );
2179 int pos = m_doc->styleCollection()->indexOf( style );
2181 m_actionFormatStyle->setCurrentItem( pos );
2183 TDEToggleAction* act =
dynamic_cast<TDEToggleAction *
>(actionCollection()->action(style->name().utf8().data()));
2185 act->setChecked(
true );
2190static const char* PARAGSTYLE_ACTION_PREFIX =
"paragstyle_";
2191static const char* FRAMESTYLE_ACTION_PREFIX =
"framestyle_";
2192static const char* TABLESTYLE_ACTION_PREFIX =
"tablestyle_";
2194void KWView::updateStyleList()
2196 TQString currentStyle = m_actionFormatStyle->currentText();
2198 const TQStringList lst = m_doc->styleCollection()->displayNameList();
2199 const int pos = lst.findIndex( currentStyle );
2201 m_actionFormatStyle->setItems( lst );
2203 m_actionFormatStyle->setCurrentItem( pos );
2207 TQStringList lstWithAccels;
2209 TDEAccelGen::generate( lst, lstWithAccels );
2210 TQMap<TQString, TDEShortcut> shortCuts;
2212 TDEActionPtrList lst2 = actionCollection()->actions(
"styleList");
2213 TQValueList<TDEAction *> actions = lst2;
2214 TQValueList<TDEAction *>::ConstIterator it = lst2.begin();
2215 const TQValueList<TDEAction *>::ConstIterator end = lst2.end();
2216 for (; it != end; ++it )
2218 shortCuts.insert( TQString::fromUtf8( (*it)->name() ), (*it)->shortcut() );
2219 m_actionFormatStyleMenu->remove( *it );
2223 for ( TQStringList::Iterator it = lstWithAccels.begin(); it != lstWithAccels.end(); ++it, ++i )
2226 KoParagStyle *style = m_doc->styleCollection()->styleAt( i );
2229 TQString name = PARAGSTYLE_ACTION_PREFIX + style->name();
2230 TDEToggleAction* act =
new TDEToggleAction( (*it),
2231 shortCuts[name],
this, TQ_SLOT( slotStyleSelected() ),
2232 actionCollection(), name.utf8() );
2233 act->setGroup(
"styleList" );
2234 act->setExclusiveGroup(
"styleListAction" );
2235 act->setToolTip( i18n(
"Apply a paragraph style" ) );
2236 m_actionFormatStyleMenu->insert( act );
2239 kdWarning() <<
"No style found for " << *it << endl;
2244void KWView::slotStyleSelected()
2246 TQString actionName = TQString::fromUtf8(sender()->name());
2247 const TQString prefix = PARAGSTYLE_ACTION_PREFIX;
2248 if ( actionName.startsWith( prefix ) ) {
2249 actionName = actionName.mid( prefix.length() );
2250 kdDebug(32001) <<
"KWView::slotStyleSelected " << actionName << endl;
2251 textStyleSelected( m_doc->styleCollection()->findStyle( actionName ) );
2255void KWView::updateFrameStyleList()
2259 const TQString currentStyle = m_actionFrameStyle->currentText();
2261 const TQStringList lst = m_doc->frameStyleCollection()->displayNameList();
2262 const int pos = lst.findIndex( currentStyle );
2264 m_actionFrameStyle->setItems( lst );
2266 m_actionFrameStyle->setCurrentItem( pos );
2270 TQStringList lstWithAccels;
2272 TDEAccelGen::generate( lst, lstWithAccels );
2273 TQMap<TQString, TDEShortcut> shortCuts;
2276 TDEActionPtrList lst2 = actionCollection()->actions(
"frameStyleList");
2277 TQValueList<TDEAction *> actions = lst2;
2278 TQValueList<TDEAction *>::ConstIterator it = lst2.begin();
2279 TQValueList<TDEAction *>::ConstIterator end = lst2.end();
2280 for (; it != end; ++it )
2282 shortCuts.insert( TQString::fromUtf8( (*it)->name() ), (*it)->shortcut() );
2283 m_actionFrameStyleMenu->remove( *it );
2288 for ( TQStringList::Iterator it = lstWithAccels.begin(); it != lstWithAccels.end(); ++it, ++i )
2291 KWFrameStyle *style = m_doc->frameStyleCollection()->frameStyleAt( i );
2294 TQString name = FRAMESTYLE_ACTION_PREFIX + style->name();
2295 TDEToggleAction* act =
new TDEToggleAction( (*it),
2297 this, TQ_SLOT( slotFrameStyleSelected() ),
2298 actionCollection(), name.utf8() );
2299 act->setGroup(
"frameStyleList" );
2300 act->setExclusiveGroup(
"frameStyleList" );
2301 act->setToolTip( i18n(
"Apply a frame style" ) );
2302 m_actionFrameStyleMenu->insert( act );
2305 kdWarning() <<
"No frame style found for " << *it << endl;
2310void KWView::updateTableStyleList()
2312 const TQString currentStyle = m_actionTableStyle->currentText();
2314 const TQStringList lst = m_doc->tableStyleCollection()->displayNameList();
2315 const int pos = lst.findIndex( currentStyle );
2317 m_actionTableStyle->setItems( lst );
2319 m_actionTableStyle->setCurrentItem( pos );
2323 TQStringList lstWithAccels;
2325 TDEAccelGen::generate( lst, lstWithAccels );
2326 TQMap<TQString, TDEShortcut> shortCuts;
2328 TQValueList<TDEAction *> actions = actionCollection()->actions(
"tableStyleList");
2329 TQValueList<TDEAction *>::ConstIterator it = actions.begin();
2330 const TQValueList<TDEAction *>::ConstIterator end = actions.end();
2331 for (; it != end; ++it )
2333 shortCuts.insert( TQString::fromUtf8( (*it)->name() ), (*it)->shortcut() );
2334 m_actionTableStyleMenu->remove( *it );
2339 for ( TQStringList::Iterator it = lstWithAccels.begin(); it != lstWithAccels.end(); ++it, ++i )
2342 KWTableStyle *style = m_doc->tableStyleCollection()->tableStyleAt( i );
2345 TQString name = TABLESTYLE_ACTION_PREFIX + style->name();
2346 TDEToggleAction* act =
new TDEToggleAction( (*it),
2347 shortCuts[name],
this, TQ_SLOT( slotTableStyleSelected() ),
2348 actionCollection(), name.utf8() );
2349 act->setExclusiveGroup(
"tableStyleList" );
2350 act->setGroup(
"tableStyleList" );
2351 act->setToolTip( i18n(
"Apply a table style" ) );
2352 m_actionTableStyleMenu->insert( act );
2355 kdWarning() <<
"No table style found for " << *it << endl;
2359void KWView::editCut()
2365 TQDragObject *drag = m_doc->dragSelected( frameViewManager()->selectedFrames() );
2366 TQApplication::clipboard()->setData( drag );
2371void KWView::editCopy()
2377 TQDragObject *drag = m_doc->dragSelected( frameViewManager()->selectedFrames() );
2378 TQApplication::clipboard()->setData( drag );
2382void KWView::editPaste()
2384 TQMimeSource *data = TQApplication::clipboard()->data();
2385 pasteData( data,
false );
2389void KWView::pasteData( TQMimeSource* data,
bool drop )
2391 int provides = checkClipboard( data );
2392 Q_ASSERT( provides != 0 );
2395 if ( provides & ProvidesFormula ) {
2396 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
2397 if ( edit && edit->frameSet()->
type() == FT_FORMULA ) {
2398 edit->pasteData( data, ProvidesFormula, drop );
2401 insertFormula( data );
2406 deselectAllFrames();
2408 if ( (provides & ProvidesImage) && (provides & ProvidesPlainText) && !( provides & ProvidesOasis ) )
2411 list.append( i18n(
"Image") );
2412 list.append( i18n(
"Plain text") );
2414 TQString result = KInputDialog::getItem( i18n(
"Paste"), i18n(
"Select paste format:"), list, 0,
false, &ok );
2417 if ( result == list.first() )
2419 provides = ProvidesImage;
2421 provides = ProvidesPlainText;
2424 data = TQApplication::clipboard()->data();
2427 if ( edit && ( provides & ProvidesPlainText ) ) {
2428 edit->pasteData( data, provides, drop );
2429 }
else if ( provides & ProvidesOasis ) {
2431 TQCString returnedTypeMime = KoTextObject::providesOasis( data );
2432 if ( !returnedTypeMime.isEmpty() )
2434 const TQByteArray arr = data->encodedData( returnedTypeMime );
2435 if( !arr.isEmpty() )
2437 TQBuffer buffer( arr );
2438 KoStore * store = KoStore::createStore( &buffer, KoStore::Read );
2439 KWOasisLoader oasisLoader( m_doc );
2440 TQValueList<KWFrame *> frames = oasisLoader.insertOasisData( store, 0 );
2442 TQValueList<KWFrame *>::ConstIterator it = frames.begin();
2443 KMacroCommand* macroCmd = 0L;
2444 for ( ; it != frames.end() ; ++it )
2447 macroCmd =
new KMacroCommand( i18n(
"Paste" ) );
2450 macroCmd->addCommand( cmd );
2452 frameViewManager()->view(*it)->setSelected(
true);
2453 (*it)->frameSet()->updateFrames();
2457 m_doc->addCommand( macroCmd );
2464 if ( provides & ProvidesImage )
2466 KoPoint docPoint( m_currentPage->leftMargin(),
2467 m_currentPage->offsetInDocument() + m_currentPage->topMargin());
2468 m_gui->canvasWidget()->pasteImage( data, docPoint );
2473void KWView::editSelectAll()
2475 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
2480void KWView::editSelectAllFrames()
2482 m_gui->canvasWidget()->selectAllFrames(
true );
2485void KWView::editSelectCurrentFrame()
2488 KWFrameSetEdit* edit = m_gui->canvasWidget()->currentFrameSetEdit();
2489 KWFrame* frame = edit->currentFrame();
2491 KWFrameView *view = frameViewManager()->view(frame);
2496void KWView::editFind()
2499 m_searchEntry =
new KoSearchContext();
2501 bool hasSelection = edit && edit->textFrameSet()->
hasSelection();
2502 bool hasCursor = edit != 0L;
2504 KoSearchDia dialog( m_gui->canvasWidget(),
"find", m_searchEntry, hasSelection, hasCursor );
2505 if ( dialog.exec() == TQDialog::Accepted )
2507 delete m_findReplace;
2508 m_findReplace =
new KWFindReplace( m_gui->canvasWidget(), &dialog, m_gui->canvasWidget()->kWordDocument()->visibleTextObjects(viewMode()), edit);
2513void KWView::editReplace()
2516 m_searchEntry =
new KoSearchContext();
2517 if (!m_replaceEntry)
2518 m_replaceEntry =
new KoSearchContext();
2521 bool hasSelection = edit && edit->textFrameSet()->
hasSelection();
2522 bool hasCursor = edit != 0L;
2524 KoReplaceDia dialog( m_gui->canvasWidget(),
"replace", m_searchEntry, m_replaceEntry, hasSelection, hasCursor );
2525 if ( dialog.exec() == TQDialog::Accepted )
2527 delete m_findReplace;
2528 m_findReplace =
new KWFindReplace( m_gui->canvasWidget(), &dialog, m_gui->canvasWidget()->kWordDocument()->visibleTextObjects(viewMode()), edit);
2533void KWView::editFindNext()
2535 if ( !m_findReplace )
2540 (void) m_findReplace->findNext();
2543void KWView::editFindPrevious()
2545 if ( !m_findReplace )
2550 (void) m_findReplace->findPrevious();
2553void KWView::adjustZOrderOfSelectedFrames(MoveFrameType moveType) {
2554 KMacroCommand* macroCmd = 0L;
2556 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
2557 if(selectedFrames.count()==0)
return;
2559 KWPage *page = m_doc->pageManager()->page(selectedFrames[0]->frame());
2560 TQPtrList<KWFrame> frames;
2561 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
2562 while(framesIterator != selectedFrames.end()) {
2564 frames.append((*framesIterator)->frame());
2567 for (TQPtrListIterator<KWFrame> cellIt(table->
frameIterator() ); cellIt.current() ; ++cellIt ) {
2568 KWFrame *frame = cellIt.current();
2569 if(page->
rect().contains(*frame) && !frames.contains(frame))
2570 frames.append(frame);
2576 int lowestZOrder=10000;
2577 TQString actionName;
2578 framesIterator = selectedFrames.begin();
2579 while(framesIterator != selectedFrames.end()) {
2580 KWFrame* frame = (*framesIterator)->frame();
2584 newZOrder=raiseFrame(frames,frame);
2585 actionName=i18n(
"Raise Frame");
2588 newZOrder=lowerFrame(frames,frame);
2589 actionName=i18n(
"Lower Frame");
2592 newZOrder=bringToFront(frames,frame);
2593 actionName=i18n(
"Bring to Front");
2596 newZOrder=sendToBack(frames,frame);
2597 actionName=i18n(
"Send to Back");
2601 if ( newZOrder != frame->zOrder() ) {
2602 lowestZOrder=TQMIN(lowestZOrder, newZOrder);
2606 frame->frameStack()->
update();
2610 macroCmd =
new KMacroCommand( actionName );
2611 macroCmd->addCommand(cmd);
2618 macroCmd =
new KMacroCommand( actionName );
2619 macroCmd->addCommand(cmd);
2626 m_doc->addCommand(macroCmd);
2629 m_doc->updateAllFrames();
2631 m_doc->repaintAllViews();
2634 if(lowestZOrder != 10000 && m_doc->processingType() == KWDocument::WP) {
2635 m_doc->lowerMainFrames( page->
pageNumber(), lowestZOrder );
2640void KWView::increaseAllZOrdersAbove(
int refZOrder,
int pageNum,
const TQPtrList<KWFrame>& frameSelection) {
2641 TQPtrList<KWFrame> framesInPage = m_doc->framesInPage( pageNum,
false );
2642 for ( TQPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
2643 if(frameSelection.contains(frameIt.current()) > 0)
continue;
2644 if(frameIt.current()->zOrder() >= refZOrder) {
2645 frameIt.current()->setZOrder( frameIt.current()->zOrder() + 1 );
2651void KWView::decreaseAllZOrdersUnder(
int refZOrder,
int pageNum,
const TQPtrList<KWFrame>& frameSelection) {
2652 TQPtrList<KWFrame> framesInPage = m_doc->framesInPage( pageNum,
false );
2653 for ( TQPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
2654 if(frameSelection.contains(frameIt.current()) > 0)
continue;
2655 if(frameIt.current()->zOrder() <= refZOrder) {
2656 frameIt.current()->setZOrder( frameIt.current()->zOrder() - 1 );
2661int KWView::raiseFrame(
const TQPtrList<KWFrame>& frameSelection,
const KWFrame *frame) {
2662 int newZOrder = 10000;
2663 TQValueList<int> zorders;
2664 TQPtrList<KWFrame> framesInPage = m_doc->framesInPage( frame->
pageNumber(),
false );
2665 for ( TQPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
2666 if(frameSelection.contains(frameIt.current()) > 0)
continue;
2667 if(! frameIt.current()->intersects(*frame))
continue;
2668 int z = frameIt.current()->zOrder();
2669 if(z > frame->zOrder()) {
2670 newZOrder=TQMIN(newZOrder, z + 1);
2672 zorders.append( z );
2674 if(newZOrder==10000)
return frame->zOrder();
2676 if ( zorders.find( newZOrder ) != zorders.end() )
2677 increaseAllZOrdersAbove( newZOrder, frame->
pageNumber(), frameSelection );
2681int KWView::lowerFrame(
const TQPtrList<KWFrame>& frameSelection,
const KWFrame *frame) {
2682 int newZOrder = -10000;
2683 TQValueList<int> zorders;
2684 TQPtrList<KWFrame> framesInPage = m_doc->framesInPage( frame->
pageNumber(),
false );
2685 for ( TQPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
2686 if(frameSelection.contains(frameIt.current()) > 0)
continue;
2687 if(frameIt.current()->frameSet()->isMainFrameset())
continue;
2688 if(! frameIt.current()->intersects(*frame))
continue;
2689 int z = frameIt.current()->zOrder();
2690 if(z < frame->zOrder()) {
2691 newZOrder=TQMAX(newZOrder, z -1);
2693 zorders.append( z );
2695 if(newZOrder==-10000)
return frame->zOrder();
2697 if ( zorders.find( newZOrder ) != zorders.end() )
2698 decreaseAllZOrdersUnder( newZOrder, frame->
pageNumber(), frameSelection );
2702int KWView::bringToFront(
const TQPtrList<KWFrame>& frameSelection,
const KWFrame *frame) {
2703 int newZOrder = frame->zOrder();
2704 TQPtrList<KWFrame> framesInPage = m_doc->framesInPage( frame->
pageNumber(),
false );
2705 for ( TQPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
2706 if(frameSelection.contains(frameIt.current()) > 0)
continue;
2707 if(! frameIt.current()->intersects(*frame))
continue;
2708 newZOrder=TQMAX(newZOrder, frameIt.current()->zOrder()+1);
2713int KWView::sendToBack(
const TQPtrList<KWFrame>& frameSelection,
const KWFrame *frame) {
2714 int newZOrder = frame->zOrder();
2715 TQPtrList<KWFrame> framesInPage = m_doc->framesInPage( frame->
pageNumber(),
false );
2716 for ( TQPtrListIterator<KWFrame> frameIt( framesInPage ); frameIt.current(); ++frameIt ) {
2717 if(frameSelection.contains(frameIt.current()) > 0)
continue;
2718 if(frameIt.current()->frameSet()->isMainFrameset())
continue;
2719 if(! frameIt.current()->intersects(*frame))
continue;
2720 newZOrder=TQMIN(newZOrder, frameIt.current()->zOrder()-1);
2725void KWView::editDeleteFrame()
2730void KWView::deleteFrame(
bool warning )
2732 if ( !m_doc->isReadWrite() )
2735 TQValueList<KWFrameView*> frames = frameViewManager()->selectedFrames();
2736 if( frames.count() < 1) {
2737 kdWarning() <<
"KWView::deleteFrame: no frame selected" << endl;
2740 if(frames.count()==1)
2742 KWFrame *theFrame = frames[0]->frame();
2745 Q_ASSERT( !fs->isAHeader() );
2746 Q_ASSERT( !fs->isAFooter() );
2747 if ( fs->isMainFrameset() || fs->isAFooter() || fs->isAHeader() || fs->isFootEndNote())
2753 int result = KMessageBox::warningContinueCancel(
2755 i18n(
"You are about to delete a table.\n"
2756 "Doing so will delete all the text in the table.\n"
2757 "Are you sure you want to do that?"),
2758 i18n(
"Delete Table"), KStdGuiItem::del(),
2759 "DeleteTableConfirmation",
2761 if (result != KMessageBox::Continue)
2768 if ( fs->isMainFrameset())
2776 KoTextDocument * textdoc = textfs->textDocument();
2777 if ( textdoc->length() > 0 )
2779 int result = KMessageBox::warningContinueCancel(
2781 i18n(
"You are about to delete the last Frame of the "
2783 "The contents of this Frameset will not appear "
2785 "Are you sure you want to do that?").arg(fs->
name()),
2786 i18n(
"Delete Frame"), KStdGuiItem::del());
2788 if (result != KMessageBox::Continue)
2791 m_doc->deleteFrame( theFrame );
2799 int result = KMessageBox::warningContinueCancel(
2801 i18n(
"Do you want to delete this frame?"),
2802 i18n(
"Delete Frame"),
2803 KGuiItem(i18n(
"&Delete"),
"edit-delete"),
2804 "DeleteLastFrameConfirmation",
2806 if (result != KMessageBox::Continue)
2809 m_doc->deleteFrame( theFrame );
2816 int result = KMessageBox::warningContinueCancel(
2818 i18n(
"Do you want to delete this frame?"),
2819 i18n(
"Delete Frame"),
2820 KGuiItem(i18n(
"&Delete"),
"edit-delete"),
2821 "DeleteLastFrameConfirmation",
2823 if (result != KMessageBox::Continue)
2827 deleteSelectedFrames();
2831void KWView::createLinkedFrame()
2833 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
2834 if (selectedFrames.count() != 1)
2836 KWFrame* frame = selectedFrames[0]->frame();
2837 KWFrame* newFrame =
new KWFrame(0L, frame->x() + m_gui->getVertRuler()->minimumSizeHint().width(), frame->y() + m_gui->getHorzRuler()->minimumSizeHint().height(), frame->width(), frame->height() );
2839 newFrame->setCopy(
true);
2840 newFrame->setNewFrameBehavior( KWFrame::Copy );
2841 frame->
frameSet()->addFrame( newFrame );
2843 frameViewManager()->view(newFrame)->setSelected(
true);
2846 m_doc->addCommand( cmd );
2848 m_doc->frameChanged( newFrame );
2851void KWView::editCustomVariable()
2856 KoCustomVariable *var =
static_cast<KoCustomVariable *
>(edit->variable());
2859 TQString oldvalue = var->value();
2860 KoCustomVarDialog dia(
this, var );
2863 m_doc->recalcVariables( VT_CUSTOM );
2864 if( var->value() != oldvalue )
2866 KWChangeCustomVariableValue *cmd=
new KWChangeCustomVariableValue(i18n(
"Change Custom Variable" ),m_doc, oldvalue, var->value(), var );
2867 m_doc->addCommand(cmd);
2874void KWView::editCustomVars()
2876 KoCustomVariablesDia dia(
this, m_doc->variableCollection()->getVariables() );
2877 TQStringList listOldCustomValue;
2878 TQPtrListIterator<KoVariable> oldIt( m_doc->variableCollection()->getVariables() );
2879 for ( ; oldIt.current() ; ++oldIt )
2881 if(oldIt.current()->type()==VT_CUSTOM)
2882 listOldCustomValue.append(((KoCustomVariable*)oldIt.current())->value());
2886 m_doc->recalcVariables( VT_CUSTOM );
2888 TQPtrListIterator<KoVariable> it( m_doc->variableCollection()->getVariables() );
2889 KMacroCommand * macroCommand = 0L;
2891 for ( ; it.current() ; ++it )
2893 if(it.current()->type() == VT_CUSTOM )
2895 if(((KoCustomVariable*)it.current())->value()!=*(listOldCustomValue.at(i)))
2898 macroCommand =
new KMacroCommand( i18n(
"Change Custom Variable" ) );
2899 KWChangeCustomVariableValue *cmd=
new KWChangeCustomVariableValue(i18n(
"Change Custom Variable" ),m_doc,*(listOldCustomValue.at(i)), ((KoCustomVariable*)it.current())->value() ,((KoCustomVariable*)it.current()));
2900 macroCommand->addCommand(cmd);
2906 m_doc->addCommand(macroCommand);
2910void KWView::editMailMergeDataBase()
2912 m_doc->mailMergeDataBase()->showConfigDialog(
this);
2914 KWMailMergeEditor *dia =
new KWMailMergeEditor(
this, m_doc->mailMergeDataBase() );
2922void KWView::viewTextMode()
2924 if ( m_actionViewTextMode->isChecked() )
2930 m_zoomViewModePreview.m_zoom = m_doc->zoom();
2931 m_zoomViewModePreview.m_zoomMode = m_doc->zoomMode();
2935 m_zoomViewModeNormal.m_zoom = m_doc->zoom();
2936 m_zoomViewModeNormal.m_zoomMode = m_doc->zoomMode();
2940 switch(m_zoomViewModeNormal.m_zoomMode)
2942 case KoZoomMode::ZOOM_WIDTH:
2943 m_doc->setZoomMode(KoZoomMode::ZOOM_WIDTH);
2944 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
2946 case KoZoomMode::ZOOM_PAGE:
2947 m_zoomViewModeNormal.m_zoomMode = KoZoomMode::ZOOM_CONSTANT;
2948 case KoZoomMode::ZOOM_CONSTANT:
2949 m_doc->setZoomMode(KoZoomMode::ZOOM_CONSTANT);
2950 showZoom( m_zoomViewModeNormal.m_zoom );
2951 setZoom( m_zoomViewModeNormal.m_zoom,
false );
2954 m_doc->switchViewMode(
"ModeText" );
2959 m_actionViewTextMode->setChecked(
true );
2962void KWView::viewPageMode()
2964 if ( m_actionViewPageMode->isChecked() )
2968 m_zoomViewModePreview.m_zoom = m_doc->zoom();
2969 m_zoomViewModePreview.m_zoomMode = m_doc->zoomMode();
2973 m_zoomViewModeNormal.m_zoom = m_doc->zoom();
2974 m_zoomViewModeNormal.m_zoomMode = m_doc->zoomMode();
2976 switch(m_zoomViewModeNormal.m_zoomMode)
2978 case KoZoomMode::ZOOM_WIDTH:
2979 m_doc->setZoomMode(KoZoomMode::ZOOM_WIDTH);
2980 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
2982 case KoZoomMode::ZOOM_PAGE:
2983 m_doc->setZoomMode(KoZoomMode::ZOOM_PAGE);
2984 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
2986 case KoZoomMode::ZOOM_CONSTANT:
2987 m_doc->setZoomMode(KoZoomMode::ZOOM_CONSTANT);
2988 showZoom( m_zoomViewModeNormal.m_zoom );
2989 setZoom( m_zoomViewModeNormal.m_zoom,
false );
2992 m_doc->switchViewMode(
"ModeNormal" );
2995 m_actionViewPageMode->setChecked(
true );
2998void KWView::viewPreviewMode()
3000 if ( m_actionViewPreviewMode->isChecked() )
3002 m_zoomViewModeNormal.m_zoom = m_doc->zoom();
3003 m_zoomViewModeNormal.m_zoomMode = m_doc->zoomMode();
3004 switch(m_zoomViewModePreview.m_zoomMode)
3006 case KoZoomMode::ZOOM_WIDTH:
3007 m_doc->setZoomMode(KoZoomMode::ZOOM_WIDTH);
3008 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
3010 case KoZoomMode::ZOOM_PAGE:
3011 m_doc->setZoomMode(KoZoomMode::ZOOM_PAGE);
3012 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
3014 case KoZoomMode::ZOOM_CONSTANT:
3015 m_doc->setZoomMode(KoZoomMode::ZOOM_CONSTANT);
3016 showZoom( m_zoomViewModePreview.m_zoom );
3017 setZoom( m_zoomViewModePreview.m_zoom,
false );
3020 m_doc->switchViewMode(
"ModePreview" );
3023 m_actionViewPreviewMode->setChecked(
true );
3026void KWView::updateZoomControls()
3028 switch(m_doc->zoomMode())
3030 case KoZoomMode::ZOOM_WIDTH:
3031 case KoZoomMode::ZOOM_PAGE:
3032 showZoom( KoZoomMode::toString(m_doc->zoomMode()) );
3034 case KoZoomMode::ZOOM_CONSTANT:
3035 changeZoomMenu( m_doc->zoom() );
3036 showZoom( m_doc->zoom() );
3041void KWView::changeZoomMenu(
int zoom )
3044 if ( m_gui && m_gui->canvasWidget() && viewMode())
3045 mode = viewMode()->type();
3048 lst << KoZoomMode::toString(KoZoomMode::ZOOM_WIDTH);
3049 if ( mode!=
"ModeText" )
3050 lst << KoZoomMode::toString(KoZoomMode::ZOOM_PAGE);
3054 TQValueList<int> list;
3056 const TQStringList itemsList ( m_actionViewZoom->items() );
3057 TQRegExp regexp(
"(\\d+)");
3059 for (TQStringList::ConstIterator it = itemsList.begin() ; it != itemsList.end() ; ++it)
3062 const int val=regexp.cap(1).toInt(&ok);
3064 if(ok && val>9 && list.contains(val)==0)
3069 if(list.contains(zoom)==0)
3070 list.append( zoom );
3074 for (TQValueList<int>::Iterator it = list.begin() ; it != list.end() ; ++it)
3075 lst.append( i18n(
"%1%").arg(*it) );
3079 lst << i18n(
"%1%").arg(
"33");
3080 lst << i18n(
"%1%").arg(
"50");
3081 lst << i18n(
"%1%").arg(
"75");
3082 lst << i18n(
"%1%").arg(
"100");
3083 lst << i18n(
"%1%").arg(
"125");
3084 lst << i18n(
"%1%").arg(
"150");
3085 lst << i18n(
"%1%").arg(
"200");
3086 lst << i18n(
"%1%").arg(
"250");
3087 lst << i18n(
"%1%").arg(
"350");
3088 lst << i18n(
"%1%").arg(
"400");
3089 lst << i18n(
"%1%").arg(
"450");
3090 lst << i18n(
"%1%").arg(
"500");
3092 m_actionViewZoom->setItems( lst );
3095void KWView::showZoom(
int zoom )
3097 TQStringList list = m_actionViewZoom->items();
3098 TQString zoomStr( i18n(
"%1%").arg( zoom ) );
3099 m_actionViewZoom->setCurrentItem( list.findIndex(zoomStr) );
3102void KWView::showZoom(
const TQString& zoom )
3104 TQStringList list = m_actionViewZoom->items();
3105 m_actionViewZoom->setCurrentItem( list.findIndex( zoom ) );
3108void KWView::slotViewFormattingChars()
3110 m_doc->setViewFormattingChars(m_actionViewFormattingChars->isChecked());
3112 m_doc->repaintAllViews();
3115void KWView::slotViewFrameBorders()
3117 setViewFrameBorders(m_actionViewFrameBorders->isChecked());
3118 m_gui->canvasWidget()->repaintAll();
3121void KWView::viewHeader()
3123 bool state = m_actionViewHeader->isChecked();
3124 m_doc->setHeaderVisible( state );
3125 KWHideShowHeader *cmd=
new KWHideShowHeader( state ? i18n(
"Enable Document Headers"):i18n(
"Disable Document Headers"), m_doc, state);
3126 m_doc->addCommand(cmd);
3130void KWView::updateHeader()
3133 bool state = m_actionViewHeader->isChecked();
3139 frameSet=edit->frameSet();
3140 if (frameSet->isAHeader())
3141 m_doc->terminateEditing( frameSet );
3148 m_doc->terminateEditing( table );
3155 KWFormulaFrameSetEdit * editFormula =
dynamic_cast<KWFormulaFrameSetEdit *
>(m_gui->canvasWidget()->currentFrameSetEdit());
3158 frameSet= editFormula->frameSet();
3160 m_doc->terminateEditing( frameSet );
3168void KWView::viewFooter()
3170 bool state=m_actionViewFooter->isChecked();
3171 m_doc->setFooterVisible( state );
3172 KWHideShowFooter *cmd=
new KWHideShowFooter( state ? i18n(
"Enable Document Footers"):i18n(
"Disable Document Footers"), m_doc, state);
3173 m_doc->addCommand(cmd);
3177void KWView::updateFooter()
3179 bool state=m_actionViewFooter->isChecked();
3186 frameSet=edit->frameSet();
3187 if (frameSet->isAFooter())
3188 m_doc->terminateEditing( frameSet );
3195 m_doc->terminateEditing( table );
3201 KWFormulaFrameSetEdit * editFormula =
dynamic_cast<KWFormulaFrameSetEdit *
>(m_gui->canvasWidget()->currentFrameSetEdit());
3204 frameSet= editFormula->frameSet();
3206 m_doc->terminateEditing( frameSet );
3215void KWView::updateZoom( ) {
3216 viewZoom(m_actionViewZoom->currentText());
3219void KWView::viewZoom(
const TQString &s )
3222 KWCanvas * canvas = m_gui->canvasWidget();
3225 if ( s == KoZoomMode::toString(KoZoomMode::ZOOM_WIDTH) )
3227 m_doc->setZoomMode(KoZoomMode::ZOOM_WIDTH);
3228 zoom = tqRound(
static_cast<double>(canvas->visibleWidth() * 100 ) / (m_doc->resolutionX() * m_currentPage->width() ) ) - 1;
3230 if(zoom != m_doc->zoom() && !canvas->verticalScrollBar() ||
3231 !canvas->verticalScrollBar()->isVisible()) {
3233 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
3237 else if ( s == KoZoomMode::toString(KoZoomMode::ZOOM_PAGE) )
3239 m_doc->setZoomMode(KoZoomMode::ZOOM_PAGE);
3240 double height = m_doc->resolutionY() * m_currentPage->height();
3241 double width = m_doc->resolutionX() * m_currentPage->width();
3242 zoom = TQMIN( tqRound(
static_cast<double>(canvas->visibleHeight() * 100 ) / height ),
3243 tqRound(
static_cast<double>(canvas->visibleWidth() * 100 ) / width ) ) - 1;
3249 m_doc->setZoomMode(KoZoomMode::ZOOM_CONSTANT);
3250 TQRegExp regexp(
"(\\d+)");
3252 zoom=regexp.cap(1).toInt(&ok);
3255 if( !ok || zoom<10 )
3256 zoom = m_doc->zoom();
3257 if ( !KoZoomMode::isConstant(s) )
3261 changeZoomMenu( zoom );
3266 if( zoom != m_doc->zoom() )
3268 setZoom( zoom,
true );
3272 edit->ensureCursorVisible();
3275 m_gui->canvasWidget()->setFocus();
3279void KWView::setZoom(
int zoom,
bool updateViews )
3281 m_doc->setZoomAndResolution( zoom, KoGlobal::dpiX(), KoGlobal::dpiY());
3282 m_doc->newZoomAndResolution( updateViews,
false );
3283 m_doc->updateZoomRuler();
3286 m_sbZoomLabel->setText(
' ' + TQString::number( zoom ) +
"% " );
3289 kdDebug() <<
"KWView::setZoom " << zoom <<
" setting koview zoom to " << m_doc->zoomedResolutionY() << endl;
3290 KoView::setZoom( m_doc->zoomedResolutionY() );
3293void KWView::insertPicture()
3295 if ( m_actionToolsCreatePix->isChecked() )
3297 KWInsertPicDia dia(
this,m_gui->canvasWidget()->pictureInline(),m_gui->canvasWidget()->pictureKeepRatio(),m_doc );
3298 if ( dia.exec() == TQDialog::Accepted && !dia.picture().isNull() )
3300 insertPicture( dia.picture(), dia.makeInline(), dia.keepRatio(), 0, 0 );
3301 m_gui->canvasWidget()->setPictureInline( dia.makeInline());
3302 m_gui->canvasWidget()->setPictureKeepRatio( dia.keepRatio() );
3305 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_EDIT );
3310 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_EDIT );
3315void KWView::slotEmbedImage(
const TQString &filename )
3319 key.setKeyFromFile( filename );
3320 picture.setKey( key );
3321 picture.loadFromFile( filename );
3322 insertPicture( picture,
false,
true, 0, 0 );
3325void KWView::insertPicture(
const KoPicture& picture,
const bool makeInline,
const bool keepRatio,
int suggestedWidth,
int suggestedHeight )
3327 TQSize pixmapSize( picture.getOriginalSize() );
3328 if ( suggestedWidth > 0 && suggestedHeight > 0 )
3329 pixmapSize = TQSize( suggestedWidth, suggestedHeight );
3333 const double widthLimit = m_currentPage->width() - m_currentPage->leftMargin() -
3334 m_currentPage->rightMargin() - 10;
3335 const double heightLimit = m_currentPage->height() - m_currentPage->topMargin() -
3336 m_currentPage->bottomMargin() - 10;
3338 KWPictureFrameSet *frameset =
new KWPictureFrameSet( m_doc, TQString() );
3340 frameset->insertPicture( picture );
3344 double width = m_doc->unzoomItX( tqRound( (
double)pixmapSize.width() * m_doc->zoomedResolutionX() / POINT_TO_INCH( KoGlobal::dpiX() ) ) );
3345 double height = m_doc->unzoomItY( tqRound( (
double)pixmapSize.height() * m_doc->zoomedResolutionY() / POINT_TO_INCH( KoGlobal::dpiY() ) ) );
3347 frameset->setKeepAspectRatio( keepRatio);
3350 if ( keepRatio && ((width > widthLimit) || (height > heightLimit)) )
3353 const double ratioX = width / widthLimit;
3354 const double ratioY = height / heightLimit;
3355 const double ratioPicture = width / height;
3357 if ( ratioPicture == 0 )
3360 height = heightLimit;
3363 if ( ratioX > ratioY )
3366 height = widthLimit/ratioPicture;
3370 width = heightLimit*ratioPicture;
3371 height = heightLimit;
3377 width = kMin( width, widthLimit );
3378 height = kMin( height, heightLimit );
3381 m_fsInline = frameset;
3382 KWFrame *frame =
new KWFrame ( m_fsInline, 0, 0, width, height );
3383 m_fsInline->addFrame( frame,
false );
3384 m_gui->canvasWidget()->inlinePictureStarted();
3385 showMouseMode( KWCanvas::MM_EDIT );
3387 displayFrameInlineInfo();
3390 edit->insertFloatingFrameSet( fs, i18n(
"Insert Picture Inline") );
3392 showMouseMode( KWCanvas::MM_EDIT );
3393 m_doc->refreshDocStructure(Pictures);
3398 m_gui->canvasWidget()->insertPicture( picture, pixmapSize, keepRatio );
3402bool KWView::insertInlinePicture()
3404 Q_ASSERT( m_fsInline );
3408 if ( edit->textFrameSet()->
textObject()->protectContent() )
3411 m_doc->addFrameSet( m_fsInline,
false );
3413 KWFrame *frame =
new KWFrame( m_fsInline, 0, 0, m_doc->unzoomItX( width ), m_doc->unzoomItY( height ) );
3414 m_fsInline->addFrame( frame,
false );
3416 edit->insertFloatingFrameSet( m_fsInline, i18n(
"Insert Picture Inline") );
3417 m_fsInline->finalize();
3418 showMouseMode( KWCanvas::MM_EDIT );
3419 m_doc->refreshDocStructure(Pictures);
3421 updateFrameStatusBarItem();
3427 updateFrameStatusBarItem();
3432void KWView::displayFrameInlineInfo()
3434 KMessageBox::information(
this,
3435 i18n(
"Set cursor where you want to insert inline frame."),
3436 i18n(
"Insert Inline Frame"),
3437 "SetCursorInsertInlineFrame",
true);
3439 if ( statusBar() && m_sbFramesLabel )
3440 m_sbFramesLabel->setText(
' ' + i18n(
"Set cursor where you want to insert inline frame." ) );
3443void KWView::insertSpecialChar()
3448 TQString f = edit->textFontFamily();
3450 if (m_specialCharDlg==0)
3452 m_specialCharDlg =
new KoCharSelectDia(
this,
"insert special char", f, c,
false );
3453 connect( m_specialCharDlg, TQ_SIGNAL(insertChar(TQChar,
const TQString &)),
3454 this, TQ_SLOT(slotSpecialChar(TQChar,
const TQString &)));
3455 connect( m_specialCharDlg, TQ_SIGNAL( finished() ),
3456 this, TQ_SLOT( slotSpecialCharDlgClosed() ) );
3458 m_specialCharDlg->show();
3461void KWView::slotSpecialCharDlgClosed()
3463 if ( m_specialCharDlg )
3465 disconnect( m_specialCharDlg, TQ_SIGNAL(insertChar(TQChar,
const TQString &)),
3466 this, TQ_SLOT(slotSpecialChar(TQChar,
const TQString &)));
3467 disconnect( m_specialCharDlg, TQ_SIGNAL( finished() ),
3468 this, TQ_SLOT( slotSpecialCharDlgClosed() ) );
3469 m_specialCharDlg->deleteLater();
3470 m_specialCharDlg = 0L;
3474void KWView::slotSpecialChar(TQChar c,
const TQString &font)
3479 edit->insertSpecialChar(c, font);
3482void KWView::insertFrameBreak()
3487 edit->insertFrameBreak();
3490void KWView::insertPage()
3492 if ( m_doc->processingType() == KWDocument::WP )
3494 m_gui->canvasWidget()->editFrameSet( m_doc->frameSet(0) );
3498 edit->insertWPPage();
3500 KWInsertPageDia dlg(
this,
"insertpage");
3505 KCommand* cmd =
new KWInsertRemovePageCommand( m_doc, KWInsertRemovePageCommand::Insert, dlg.insertPagePos()==KW_INSERTPAGEAFTER ? page : (page -1));
3507 m_doc->addCommand( cmd );
3512void KWView::deletePage()
3514 KCommand* cmd =
new KWInsertRemovePageCommand( m_doc, KWInsertRemovePageCommand::Remove, m_currentPage->pageNumber() );
3516 m_doc->addCommand( cmd );
3517 if(m_doc->lastPage() > m_currentPage->pageNumber())
3518 m_currentPage = m_doc->pageManager()->page( m_doc->lastPage() );
3521void KWView::insertLink()
3530 TQString selectedText = edit->textFrameSet()->
textObject()->selectedText();
3531 if ( edit->textFrameSet()->
textObject()->selectionHasCustomItems() || selectedText.contains(
'\n') )
3533 if ( selectedText.startsWith(
"mailto:/" ) ||
3534 selectedText.startsWith(
"ftp:/" ) ||
3535 selectedText.startsWith(
"http:/" ) )
3543 link = selectedText;
3547 if(KoInsertLinkDia::createLinkDia(link, ref, m_doc->listOfBookmarkName(0),
true,
this))
3549 if(!link.isEmpty() && !ref.isEmpty())
3550 edit->insertLink(link, ref);
3554void KWView::insertComment()
3559 TQString authorName;
3560 KoDocumentInfo * info = m_doc->documentInfo();
3561 KoDocumentInfoAuthor * authorPage =
static_cast<KoDocumentInfoAuthor *
>(info->page(
"author" ));
3563 kdWarning() <<
"Author information not found in documentInfo !" << endl;
3565 authorName = authorPage->fullName();
3567 KoCommentDia *commentDia =
new KoCommentDia(
this, TQString(),authorName );
3568 if( commentDia->exec() )
3570 edit->insertComment(commentDia->commentText());
3576void KWView::insertVariable()
3581 TDEAction * act = (TDEAction *)(sender());
3582 VariableDefMap::Iterator it = m_variableDefMap.find( act );
3583 if ( it == m_variableDefMap.end() )
3584 kdWarning() <<
"Action not found in m_variableDefMap." << endl;
3587 if ( (*it).type == VT_FIELD )
3588 edit->insertVariable( (*it).type, KoFieldVariable::fieldSubType( (*it).subtype ) );
3590 edit->insertVariable( (*it).type, (*it).subtype );
3595void KWView::insertFootNote()
3601 if ( edit->frameSet() != m_doc->frameSet(0) )
3603 KMessageBox::sorry(
this,
3604 i18n(
"You can only insert footnotes or "
3605 "endnotes into the first frameset."),
3606 i18n(
"Insert Footnote"));
3608 KWFootNoteDia dia( m_gui->canvasWidget()->footNoteType(), m_gui->canvasWidget()->numberingFootNoteType(), TQString(),
this, m_doc, 0 );
3609 TQPtrListIterator<KoTextCustomItem> it( edit->textDocument()->allCustomItems() );
3610 for ( ; it.current() ; ++it )
3613 if (fnv && !fnv->isDeleted() && fnv->
frameSet() && !fnv->
frameSet()->isDeleted() &&
3614 fnv->numberingType()==KWFootNoteVariable::Manual )
3615 dia.appendManualFootNote( fnv->text() );
3618 edit->insertFootNote( dia.noteType(), dia.numberingType(), dia.manualString() );
3619 m_gui->canvasWidget()->setFootNoteType( dia.noteType() );
3620 m_gui->canvasWidget()->setNumberingFootNoteType( dia.numberingType() );
3626void KWView::updateTocActionText(
bool hasToc)
3628 TDEActionCollection * coll = actionCollection();
3629 TQString name= hasToc ? i18n(
"Update Table of &Contents"):i18n(
"Table of &Contents");
3630 coll->action(
"insert_contents")->setText(name);
3633void KWView::insertContents()
3640void KWView::formatFont()
3642 KoTextFormatInterface* textIface = applicableTextInterfaces().first();
3644 if ( !textIface || !textIface->currentFormat() )
3648 m_fontDlg =
new KoFontDia( *textIface->currentFormat()
3652 connect( m_fontDlg, TQ_SIGNAL( applyFont() ),
3653 this, TQ_SLOT( slotApplyFont() ) );
3662void KWView::slotApplyFont()
3664 int flags = m_fontDlg->changedFlags();
3667 KMacroCommand *globalCmd =
new KMacroCommand(i18n(
"Change Font"));
3668 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
3669 TQPtrListIterator<KoTextFormatInterface> it( lst );
3670 for ( ; it.current() ; ++it )
3672 KoTextFormat newFormat = m_fontDlg->newFormat();
3673 KCommand *cmd = it.current()->setFormatCommand( &newFormat, flags,
true);
3675 globalCmd->addCommand(cmd);
3677 m_doc->addCommand(globalCmd);
3678 m_gui->canvasWidget()->setFocus();
3683void KWView::formatParagraph()
3685 showParagraphDialog();
3688void KWView::showParagraphDialog(
int initialPage,
double initialTabPos )
3694 bool showFrameEndOptions = !edit->frameSet()->isHeaderOrFooter() &&
3696 m_paragDlg =
new KoParagDia(
this,
"",
3697 KoParagDia::PD_SPACING | KoParagDia::PD_ALIGN |
3698 KoParagDia::PD_DECORATION | KoParagDia::PD_NUMBERING |
3699 KoParagDia::PD_TABS,
3701 edit->textFrameSet()->
frame(0)->width(),
3702 showFrameEndOptions,
3703 edit->frameSet()->isFootEndNote());
3704 m_paragDlg->setCaption( i18n(
"Paragraph Settings" ) );
3707 m_paragDlg->setParagLayout( edit->cursor()->parag()->paragLayout() );
3710 if ( initialPage != -1 )
3712 m_paragDlg->setCurrentPage( initialPage );
3713 if ( initialPage == KoParagDia::PD_TABS )
3714 m_paragDlg->tabulatorsWidget()->setCurrentTab( initialTabPos );
3716 connect( m_paragDlg, TQ_SIGNAL( applyParagStyle() ),
this, TQ_SLOT( slotApplyParag()));
3725void KWView::slotApplyParag()
3730 KMacroCommand * macroCommand = 0L;
3732 if(m_paragDlg->isLeftMarginChanged())
3734 cmd=edit->setMarginCommand( TQStyleSheetItem::MarginLeft, m_paragDlg->leftIndent() );
3737 if ( !macroCommand )
3738 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3739 macroCommand->addCommand(cmd);
3741 m_gui->getHorzRuler()->setLeftIndent( KoUnit::toUserValue( m_paragDlg->leftIndent(), m_doc->unit() ) );
3745 if(m_paragDlg->isRightMarginChanged())
3747 cmd=edit->setMarginCommand( TQStyleSheetItem::MarginRight, m_paragDlg->rightIndent() );
3750 if ( !macroCommand )
3751 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3752 macroCommand->addCommand(cmd);
3754 m_gui->getHorzRuler()->setRightIndent( KoUnit::toUserValue( m_paragDlg->rightIndent(), m_doc->unit() ) );
3756 if(m_paragDlg->isSpaceBeforeChanged())
3758 cmd=edit->setMarginCommand( TQStyleSheetItem::MarginTop, m_paragDlg->spaceBeforeParag() );
3761 if ( !macroCommand )
3762 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3763 macroCommand->addCommand(cmd);
3766 if(m_paragDlg->isSpaceAfterChanged())
3768 cmd=edit->setMarginCommand( TQStyleSheetItem::MarginBottom, m_paragDlg->spaceAfterParag() );
3771 if ( !macroCommand )
3772 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3773 macroCommand->addCommand(cmd);
3776 if(m_paragDlg->isFirstLineChanged())
3778 cmd=edit->setMarginCommand( TQStyleSheetItem::MarginFirstLine, m_paragDlg->firstLineIndent());
3781 if ( !macroCommand )
3782 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3783 macroCommand->addCommand(cmd);
3785 m_gui->getHorzRuler()->setFirstIndent(
3786 KoUnit::toUserValue( m_paragDlg->firstLineIndent(), m_doc->unit() ) );
3789 if(m_paragDlg->isAlignChanged())
3791 cmd=edit->setAlignCommand( m_paragDlg->align() );
3794 if ( !macroCommand )
3795 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3796 macroCommand->addCommand(cmd);
3799 if(m_paragDlg->isCounterChanged())
3801 cmd=edit->setCounterCommand( m_paragDlg->counter() );
3804 if ( !macroCommand )
3805 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3806 macroCommand->addCommand(cmd);
3809 if(m_paragDlg->listTabulatorChanged())
3811 cmd=edit->setTabListCommand( m_paragDlg->tabListTabulator() );
3814 if ( !macroCommand )
3815 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3816 macroCommand->addCommand(cmd);
3820 if(m_paragDlg->isLineSpacingChanged())
3822 cmd=edit->setLineSpacingCommand( m_paragDlg->lineSpacing(),m_paragDlg->lineSpacingType() );
3825 if ( !macroCommand )
3826 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3828 macroCommand->addCommand(cmd);
3831 if(m_paragDlg->isBorderChanged())
3833 cmd=edit->setBordersCommand( m_paragDlg->leftBorder(),
3834 m_paragDlg->rightBorder(),
3835 m_paragDlg->topBorder(),
3836 m_paragDlg->bottomBorder() );
3839 if ( !macroCommand )
3840 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3842 macroCommand->addCommand(cmd);
3845 if( m_paragDlg->isJoinBorderChanged() )
3847 cmd=edit->setJoinBordersCommand( m_paragDlg->joinBorder() );
3850 if ( !macroCommand )
3851 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3853 macroCommand->addCommand(cmd);
3856 if ( m_paragDlg->isPageBreakingChanged() )
3858 cmd=edit->setPageBreakingCommand( m_paragDlg->pageBreaking() );
3861 if ( !macroCommand )
3862 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3864 macroCommand->addCommand(cmd);
3868 if ( m_paragDlg->isBackgroundColorChanged() )
3870 cmd=edit->setBackgroundColorCommand( m_paragDlg->backgroundColor() );
3873 if ( !macroCommand )
3874 macroCommand =
new KMacroCommand( i18n(
"Paragraph Settings" ) );
3876 macroCommand->addCommand(cmd);
3881 m_doc->addCommand(macroCommand);
3884 m_paragDlg->setParagLayout( edit->cursor()->parag()->paragLayout() );
3888void KWView::slotHRulerDoubleClicked(
double ptpos )
3890 showParagraphDialog( KoParagDia::PD_TABS, ptpos );
3898void KWView::slotHRulerDoubleClicked()
3900 TQString mode = viewMode()->type();
3901 bool state = (mode!=
"ModeText");
3905 KoRuler *ruler = m_gui->getHorzRuler ();
3906 if ( (ruler->flags() & KoRuler::F_INDENTS) && currentTextEdit() ) {
3907 if ( ruler->doubleClickedIndent () ) {
3916void KWView::formatPage()
3918 if( !m_doc->isReadWrite())
3920 TQString mode = viewMode()->type();
3921 bool state = (mode!=
"ModeText");
3925 KoPageLayout pgLayout;
3927 KoKWHeaderFooter kwhf;
3928 m_doc->getPageLayout( pgLayout, cl, kwhf );
3930 KWPageLayoutStruct oldLayout( pgLayout, cl, kwhf );
3933 int flags = FORMAT_AND_BORDERS | DISABLE_UNIT;
3934 if ( m_doc->processingType() == KWDocument::WP )
3935 flags |= KW_HEADER_AND_FOOTER | COLUMNS;
3937 flags |= DISABLE_BORDERS;
3939 KoUnit::Unit unit = m_doc->unit();
3940 KoUnit::Unit oldUnit = unit;
3942 if ( KoPageLayoutDia::pageLayout( pgLayout, hf, cl, kwhf, flags, unit,
this ) )
3944 if( !(oldLayout._pgLayout==pgLayout) ||
3945 oldLayout._cl != cl ||
3946 oldLayout._hf != kwhf )
3948 KWPageLayoutStruct newLayout( pgLayout, cl, kwhf );
3952 edit->textFrameSet()->clearUndoRedoInfo();
3954 m_doc, oldLayout, newLayout );
3955 m_doc->addCommand(cmd);
3957 m_doc->setPageLayout( pgLayout, cl, kwhf );
3959 if ( unit != oldUnit )
3960 m_doc->setUnit( unit );
3964void KWView::formatFrameSet()
3966 if ( frameViewManager()->selectedFrame() )
3968 m_gui->canvasWidget()->editFrameProperties();
3971 KMessageBox::sorry(
this,
3972 i18n(
"You must select a frame first."),
3973 i18n(
"Format Frameset"));
3976void KWView::slotSpellCheck()
3978 if (m_spell.kospell)
return;
3980 m_spell.macroCmdSpellCheck = 0L;
3981 m_spell.replaceAll.clear();
3982 TQValueList<KoTextObject *> objects;
3989 objects.append(edit->textFrameSet()->
textObject());
3990 options = KFindDialog::SelectedText;
3994 objects = m_gui->canvasWidget()->kWordDocument()->visibleTextObjects(viewMode());
3996 m_spell.textIterator =
new KoTextIterator( objects, edit, options );
3997 kdDebug()<<
"Created iterator with "<< objects.count() <<endl;
4001void KWView::extraAutoFormat()
4003 m_doc->autoFormat()->readConfig();
4004 KoAutoFormatDia dia(
this, 0, m_doc->autoFormat() );
4006 m_doc->startBackgroundSpellCheck();
4009void KWView::extraFrameStylist()
4014 KWFrameStyleManager * frameStyleManager =
new KWFrameStyleManager(
this, m_doc, TQString() );
4015 frameStyleManager->exec();
4016 delete frameStyleManager;
4021void KWView::createFrameStyle()
4024 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4025 if (selectedFrames.count() != 1)
4028 KWFrame* frame = selectedFrames[0]->frame();
4030 KoCreateStyleDia *dia =
new KoCreateStyleDia( m_doc->frameStyleCollection()->displayNameList(),
this, 0 );
4034 m_doc->frameStyleCollection()->addStyle( style );
4035 m_doc->updateAllFrameStyleLists();
4040void KWView::extraStylist()
4043 TQString activeStyleName = TQString();
4047 if (edit->cursor() && edit->cursor()->parag() && edit->cursor()->parag()->style())
4048 activeStyleName = edit->cursor()->parag()->style()->displayName();
4050 KWStyleManager * styleManager =
new KWStyleManager(
this, m_doc->unit(),m_doc, *m_doc->styleCollection(), activeStyleName );
4051 styleManager->exec();
4052 delete styleManager;
4057void KWView::extraCreateTemplate()
4061 TQPixmap pix = m_doc->generatePreview(TQSize(width, height));
4063 KTempFile tempFile( TQString(),
".odt" );
4064 tempFile.setAutoDelete(
true);
4066 m_doc->saveNativeFormat( tempFile.name() );
4068 KoTemplateCreateDia::createTemplate(
"kword_template", KWFactory::instance(),
4069 tempFile.name(), pix,
this );
4071 KWFactory::instance()->dirs()->addResourceType(
"kword_template",
4072 TDEStandardDirs::kde_default(
"data" ) +
4073 "kword/templates/");
4076void KWView::toolsCreateText()
4078 if ( m_actionToolsCreateText->isChecked() )
4079 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_CREATE_TEXT );
4083 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_EDIT );
4087void KWView::insertTable()
4089 KWCanvas * canvas = m_gui->canvasWidget();
4090 canvas->setMouseMode( KWCanvas::MM_EDIT );
4091 KWTableDia *tableDia =
new KWTableDia(
this, 0, KWTableDia::NEW, canvas, m_doc,
4092 canvas->tableRows(),
4093 canvas->tableCols(),
4094 canvas->tableWidthMode(),
4095 canvas->tableHeightMode(),
4096 canvas->tableIsFloating(),
4097 canvas->tableTemplateName(),
4098 canvas->tableFormat());
4099 tableDia->setCaption( i18n(
"Insert Table" ) );
4100 if ( tableDia->exec() == TQDialog::Rejected )
4101 canvas->setMouseMode( KWCanvas::MM_EDIT );
4105void KWView::insertFormula( TQMimeSource* source )
4110 KWFormulaFrameSet *frameset =
new KWFormulaFrameSet( m_doc, TQString() );
4111 m_doc->addFrameSet( frameset,
false );
4113 TQByteArray data = source->encodedData( KFormula::MimeSource::selectionMimeType() );
4114 TQDomDocument formula;
4115 formula.setContent( data );
4116 TQDomElement formulaElem = formula.namedItem(
"math").toElement();
4117 frameset->paste( formulaElem );
4121 frameset->addFrame( frame,
false );
4122 edit->insertFloatingFrameSet( frameset, i18n(
"Insert Formula") );
4123 frameset->finalize();
4124 m_doc->refreshDocStructure(FT_FORMULA);
4126 m_gui->canvasWidget()->editFrameSet( frameset );
4127 frameset->setChanged();
4128 m_gui->canvasWidget()->repaintChanged( frameset,
true );
4132void KWView::toolsPart()
4134 m_gui->canvasWidget()->insertPart( m_actionToolsCreatePart->documentEntry() );
4138int KWView::tableSelectCell(
const TQString &tableName, uint row, uint col)
4140 if(!m_doc || !m_gui)
4142 KWFrameSet *fs = m_doc->frameSetByName(tableName);
4153 KWCanvas *canvas = m_gui->canvasWidget();
4156 canvas->tableSelectCell(table, cell);
4160int KWView::tableDeleteRow(
const TQValueList<uint>& rows,
KWTableFrameSet *table )
4163 table = m_gui->canvasWidget()->getCurrentTable();
4165 if (!m_doc || !table)
4168 if(rows.count() >= table->
getRows()) {
4169 m_doc->deleteTable(table);
4173 KMacroCommand *macro =
new KMacroCommand(i18n(
"Remove Rows"));
4175 for (
int i = rows.count() - 1; i >= 0 ; i--) {
4178 macro->addCommand(cmd);
4182 m_doc->addCommand(macro);
4186int KWView::tableDeleteCol(
const TQValueList<uint>& cols,
KWTableFrameSet *table)
4189 table = m_gui->canvasWidget()->getCurrentTable();
4191 if (!m_doc || !table)
4195 m_doc->deleteTable(table);
4199 KMacroCommand *macro =
new KMacroCommand(i18n(
"Remove Columns"));
4201 for (
int i = cols.count() - 1; i >= 0; i--) {
4204 macro->addCommand(cmd);
4208 m_doc->addCommand(macro);
4212void KWView::tableProperties()
4214 KWCanvas * canvas = m_gui->canvasWidget();
4218 canvas->setMouseMode( KWCanvas::MM_EDIT );
4219 KWTableDia *tableDia =
new KWTableDia(
this, 0, KWTableDia::EDIT, canvas, m_doc,
4222 canvas->tableWidthMode(),
4223 canvas->tableHeightMode(),
4224 canvas->tableIsFloating(),
4225 canvas->tableTemplateName(),
4226 canvas->tableFormat());
4227 tableDia->setCaption( i18n(
"Adjust Table" ) );
4228 if ( tableDia->exec() == TQDialog::Rejected )
4229 canvas->setMouseMode( KWCanvas::MM_EDIT );
4234void KWView::tableInsertRow()
4236 TableInfo ti(frameViewManager()->selectedFrames());
4240 KWInsertDia dia(
this, cell->
groupmanager(), KWInsertDia::insertRow, cell->firstRow());
4247 table = m_gui->canvasWidget()->getCurrentTable();
4249 if (!m_doc || !table)
4257 m_doc->addCommand(cmd);
4261void KWView::tableInsertCol()
4263 TableInfo ti(frameViewManager()->selectedFrames());
4267 KWInsertDia dia(
this, cell->
groupmanager(), KWInsertDia::insertColumn, cell->firstColumn());
4274 table = m_gui->canvasWidget()->getCurrentTable();
4276 if (!m_doc || !table)
4285 double maxRightOffset;
4289 KWPage *page = m_doc->pageManager()->page( table->cell(0,0)->
frame(0) );
4294 table, col, maxRightOffset);
4296 m_doc->addCommand(cmd);
4299void KWView::tableDeleteRow()
4301 TableInfo ti( frameViewManager()->selectedFrames() );
4302 if(ti.amountRowsSelected() == 0)
return;
4304 KWDeleteDia dia(
this, ti.firstSelectedCell()->groupmanager(),
4305 KWDeleteDia::deleteRow, ti.selectedRows() );
4309void KWView::tableDeleteCol()
4311 TableInfo ti( frameViewManager()->selectedFrames() );
4312 if(ti.amountColumnsSelected() == 0)
return;
4314 KWDeleteDia dia(
this, ti.firstSelectedCell()->groupmanager(),
4315 KWDeleteDia::deleteColumn, ti.selectedColumns() );
4319void KWView::tableResizeCol()
4321 TableInfo ti( frameViewManager()->selectedFrames() );
4329void KWView::tableJoinCells()
4332 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4333 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
4334 unsigned int x1=10000, y1=10000, x2=0, y2=0;
4335 for(;framesIterator != selectedFrames.end(); ++framesIterator) {
4341 if(cell == 0)
continue;
4345 KMessageBox::sorry(
this,
4346 i18n(
"More then one table has selected cells, please make sure "
4347 "the selected cells are in one table and are connecting"),
4348 i18n(
"Join Cells Failed" ) );
4352 if(cell->firstRow() < y1) y1 = cell->firstRow();
4353 if(cell->firstColumn() < x1) x1 = cell->firstColumn();
4354 if(cell->lastRow() > y2) y2 = cell->lastRow();
4355 if(cell->lastColumn() > x2) x2 = cell->lastColumn();
4361 KCommand * cmd=table->
joinCells(x1, y1, x2, y2);
4364 KMessageBox::sorry(
this,
4365 i18n(
"You have to select some cells which are next to each other "
4366 "and are not already joined." ),
4367 i18n(
"Join Cells" ) );
4370 m_doc->addCommand(cmd);
4374void KWView::tableSplitCells() {
4375 KWSplitCellDia *splitDia=
new KWSplitCellDia(
this,
"split cell",
4376 m_tableSplit.columns, m_tableSplit.rows );
4377 if(splitDia->exec()) {
4378 m_tableSplit.rows = splitDia->rows();
4379 m_tableSplit.columns = splitDia->columns();
4380 tableSplitCells( m_tableSplit.columns, m_tableSplit.rows );
4385void KWView::tableSplitCells(
int cols,
int rows)
4387 TableInfo ti( frameViewManager()->selectedFrames() );
4388 if(! ti.oneCellSelected()) {
4389 KMessageBox::sorry(
this,
4390 i18n(
"You have to put the cursor into a table "
4391 "before splitting cells." ),
4392 i18n(
"Split Cells" ) );
4399 KMessageBox::sorry(
this,
4400 i18n(
"There is not enough space to split the cell into that many parts, make it bigger first"),
4401 i18n(
"Split Cells") );
4404 m_doc->addCommand(cmd);
4405 m_doc->updateAllFrames();
4407 frameViewManager()->view(cell->
frame(0))->setSelected(
true);
4410void KWView::tableUngroupTable()
4412 m_gui->canvasWidget()->setMouseMode( KWCanvas::MM_EDIT );
4420 KMacroCommand * macroCmd =
new KMacroCommand( i18n(
"Ungroup Table" ) );
4425 macroCmd->addCommand(cmd);
4429 macroCmd->addCommand( cmd );
4430 m_doc->addCommand( macroCmd );
4431 macroCmd->execute();
4434void KWView::tableDelete()
4440 m_doc->deleteTable( table );
4443void KWView::tableStylist()
4448 KWTableStyleManager * tableStyleManager =
new KWTableStyleManager(
this, m_doc );
4449 tableStyleManager->exec();
4450 delete tableStyleManager;
4455void KWView::tableProtectCells(
bool on)
4457 KMacroCommand *macro = 0;
4458 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4459 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
4460 for(;framesIterator != selectedFrames.end(); ++framesIterator) {
4465 if(cell == 0)
continue;
4466 if(cell->protectContent() != on) {
4467 KWProtectContentCommand *cmd =
new KWProtectContentCommand( i18n(
"Protect Content"), cell , on);
4469 macro =
new KMacroCommand( i18n(
"Protect Content"));
4470 macro->addCommand( cmd );
4475 m_doc->addCommand( macro );
4479void KWView::textStyleSelected( KoParagStyle *sty )
4484 if ( m_gui->canvasWidget()->currentFrameSetEdit() )
4488 edit->applyStyle( sty );
4492 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4493 if (selectedFrames.count() <= 0)
4497 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
4498 KMacroCommand *globalCmd = 0L;
4499 while(framesIterator != selectedFrames.end()) {
4500 KWFrame *curFrame = (*framesIterator)->frame();
4502 if (curFrameSet->
type() == FT_TEXT)
4504 KoTextObject *textObject = ((
KWTextFrameSet*)curFrameSet)->textObject();
4505 textObject->textDocument()->selectAll( KoTextDocument::Temp );
4506 KCommand *cmd = textObject->applyStyleCommand( 0L, sty , KoTextDocument::Temp, KoParagLayout::All, KoTextFormat::Format,
true,
true );
4507 textObject->textDocument()->removeSelection( KoTextDocument::Temp );
4511 globalCmd =
new KMacroCommand( selectedFrames.count() == 1 ? i18n(
"Apply Style to Frame") : i18n(
"Apply Style to Frames"));
4512 globalCmd->addCommand( cmd );
4518 m_doc->addCommand( globalCmd );
4520 m_gui->canvasWidget()->setFocus();
4525void KWView::textStyleSelected(
int index )
4527 textStyleSelected( m_doc->styleCollection()->styleAt( index ) );
4531void KWView::slotFrameStyleSelected()
4533 TQString actionName = TQString::fromUtf8(sender()->name());
4534 const TQString prefix = FRAMESTYLE_ACTION_PREFIX;
4535 if ( actionName.startsWith( prefix ) ) {
4536 actionName = actionName.mid( prefix.length() );
4537 frameStyleSelected( m_doc->frameStyleCollection()->findStyle( actionName ) );
4541void KWView::frameStyleSelected(
int index )
4543 frameStyleSelected( m_doc->frameStyleCollection()->frameStyleAt( index ) );
4553 if ( m_gui->canvasWidget()->currentFrameSetEdit() )
4555 KWFrame * single = m_gui->canvasWidget()->currentFrameSetEdit()->currentFrame();
4558 KCommand *cmd =
new KWFrameStyleCommand( i18n(
"Apply Framestyle to Frame"), single, sty );
4560 m_doc->addCommand( cmd );
4567 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4568 if (selectedFrames.count() <= 0)
4572 KMacroCommand *globalCmd =
new KMacroCommand( selectedFrames.count() == 1 ? i18n(
"Apply Framestyle to Frame") : i18n(
"Apply Framestyle to Frames"));
4574 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
4575 while(framesIterator != selectedFrames.end()) {
4576 KWFrame *curFrame = (*framesIterator)->frame();
4579 globalCmd->addCommand( cmd );
4582 m_doc->addCommand( globalCmd );
4583 globalCmd->execute();
4586 m_gui->canvasWidget()->repaintAll();
4587 m_gui->canvasWidget()->setFocus();
4590 const int pos = m_doc->frameStyleCollection()->indexOf( sty );
4591 Q_ASSERT( pos >= 0 );
4592 m_actionFrameStyle->setCurrentItem( pos );
4593 TDEToggleAction* act =
dynamic_cast<TDEToggleAction *
>(actionCollection()->action( sty->name().utf8().data() ));
4595 act->setChecked(
true );
4600void KWView::slotTableStyleSelected()
4602 TQString actionName = TQString::fromUtf8(sender()->name());
4603 const TQString prefix = TABLESTYLE_ACTION_PREFIX;
4604 if ( actionName.startsWith( prefix ) ) {
4605 actionName = actionName.mid( prefix.length() );
4606 tableStyleSelected( m_doc->tableStyleCollection()->findStyle( actionName ) );
4610void KWView::tableStyleSelected(
int index )
4612 tableStyleSelected( m_doc->tableStyleCollection()->tableStyleAt( index ) );
4621 if ( m_gui->canvasWidget()->currentFrameSetEdit() )
4623 KWFrame * single = m_gui->canvasWidget()->currentFrameSetEdit()->currentFrame();
4624 if ( (single) && ( single->
frameSet()->
type() == FT_TEXT ) )
4626 KCommand *cmd =
new KWTableStyleCommand( i18n(
"Apply Tablestyle to Frame"), single, sty );
4628 m_doc->addCommand( cmd );
4635 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4636 if (selectedFrames.count() <= 0)
4639 KMacroCommand *globalCmd =
new KMacroCommand( selectedFrames.count() == 1 ? i18n(
"Apply Tablestyle to Frame") : i18n(
"Apply Tablestyle to Frames"));
4641 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
4642 while(framesIterator != selectedFrames.end() ) {
4643 KWFrame *curFrame = (*framesIterator)->frame();
4648 globalCmd->addCommand( cmd );
4652 m_doc->addCommand( globalCmd );
4653 globalCmd->execute();
4656 m_gui->canvasWidget()->repaintAll();
4657 m_gui->canvasWidget()->setFocus();
4660 int pos = m_doc->tableStyleCollection()->indexOf( sty );
4661 m_actionTableStyle->setCurrentItem( pos );
4662 TDEToggleAction* act =
dynamic_cast<TDEToggleAction *
>(actionCollection()->action( sty->name().utf8().data() ));
4664 act->setChecked(
true );
4667void KWView::increaseFontSize()
4670 KoTextFormat *format = edit->currentFormat();
4672 textSizeSelected( edit->textFrameSet()->
textObject()->docFontSize( format ) + 1 );
4675void KWView::decreaseFontSize()
4678 KoTextFormat *format = edit->currentFormat();
4680 textSizeSelected( edit->textFrameSet()->
textObject()->docFontSize( format ) - 1 );
4683void KWView::textSizeSelected(
int size )
4685 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4686 TQPtrListIterator<KoTextFormatInterface> it( lst );
4687 KMacroCommand *globalCmd =
new KMacroCommand(i18n(
"Change Text Size"));
4688 for ( ; it.current() ; ++it )
4690 KCommand *cmd = it.current()->setPointSizeCommand( size );
4692 globalCmd->addCommand(cmd);
4694 m_doc->addCommand(globalCmd);
4695 m_gui->canvasWidget()->setFocus();
4698void KWView::textFontSelected(
const TQString & font )
4700 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4701 if ( lst.isEmpty() )
return;
4702 TQPtrListIterator<KoTextFormatInterface> it( lst );
4703 KMacroCommand* macroCmd = 0L;
4704 for ( ; it.current() ; ++it )
4706 KCommand *cmd = it.current()->setFamilyCommand( font );
4710 macroCmd =
new KMacroCommand( i18n(
"Change Text Font") );
4711 macroCmd->addCommand( cmd );
4715 m_doc->addCommand( macroCmd );
4716 m_gui->canvasWidget()->setFocus();
4719TQPtrList<KoTextFormatInterface> KWView::applicableTextInterfaces()
const
4721 TQPtrList<KoTextFormatInterface> lst;
4722 if (currentTextEdit())
4724 if ( !currentTextEdit()->textObject()->protectContent())
4727 lst.append( currentTextEdit() );
4729 KWCollectFramesetsVisitor visitor;
4730 currentTextEdit()->textDocument()->visitSelection( KoTextDocument::Standard, &visitor );
4731 const TQValueList<KWFrameSet *>& frameset = visitor.frameSets();
4732 for ( TQValueList<KWFrameSet *>::ConstIterator it = frameset.begin(); it != frameset.end(); ++it )
4734 if ( (*it)->type() == FT_TABLE )
4738 int const rows = kwtableframeset->
getRows();
4739 int const cols = kwtableframeset->
getColumns();
4741 for (
int r=0; r<rows; ++r)
4743 for (
int c=0; c<cols; ++c)
4748 kdDebug() <<
"adding (" << r <<
"," << c <<
")" << endl;
4760 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
4761 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
4762 while(framesIterator != selectedFrames.end()) {
4764 if ( fs && !lst.contains( fs )&& !fs->protectContent() )
4772void KWView::textBold()
4774 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4775 if ( lst.isEmpty() )
return;
4776 TQPtrListIterator<KoTextFormatInterface> it( lst );
4777 KMacroCommand* macroCmd = 0L;
4778 for ( ; it.current() ; ++it )
4780 KCommand *cmd = it.current()->setBoldCommand( m_actionFormatBold->isChecked() );
4784 macroCmd =
new KMacroCommand( i18n(
"Make Text Bold") );
4785 macroCmd->addCommand(cmd);
4789 m_doc->addCommand(macroCmd);
4793void KWView::textItalic()
4795 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4796 TQPtrListIterator<KoTextFormatInterface> it( lst );
4797 KMacroCommand* macroCmd = 0L;
4798 for ( ; it.current() ; ++it )
4800 KCommand *cmd = it.current()->setItalicCommand( m_actionFormatItalic->isChecked() );
4804 macroCmd =
new KMacroCommand( i18n(
"Make Text Italic") );
4805 macroCmd->addCommand( cmd );
4809 m_doc->addCommand( macroCmd );
4812void KWView::textUnderline()
4814 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4815 TQPtrListIterator<KoTextFormatInterface> it( lst );
4816 KMacroCommand* macroCmd = 0L;
4818 for ( ; it.current() ; ++it )
4820 KCommand *cmd = it.current()->setUnderlineCommand( m_actionFormatUnderline->isChecked() );
4824 macroCmd =
new KMacroCommand( i18n(
"Underline Text") );
4825 macroCmd->addCommand( cmd );
4829 m_doc->addCommand( macroCmd );
4832void KWView::textStrikeOut()
4834 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4835 TQPtrListIterator<KoTextFormatInterface> it( lst );
4836 KMacroCommand* macroCmd = 0L;
4837 for ( ; it.current() ; ++it )
4839 KCommand *cmd = it.current()->setStrikeOutCommand( m_actionFormatStrikeOut->isChecked() );
4843 macroCmd =
new KMacroCommand( i18n(
"Strike Out Text") );
4844 macroCmd->addCommand( cmd );
4848 m_doc->addCommand( macroCmd );
4851void KWView::textColor()
4859 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4860 if ( lst.isEmpty() )
return;
4861 TQPtrListIterator<KoTextFormatInterface> it( lst );
4862 KMacroCommand* macroCmd = 0L;
4863 for ( ; it.current() ; ++it )
4865 KCommand *cmd = it.current()->setTextColorCommand( m_actionFormatColor->color() );
4869 macroCmd =
new KMacroCommand( i18n(
"Set Text Color") );
4870 macroCmd->addCommand( cmd );
4874 m_doc->addCommand( macroCmd );
4877void KWView::textAlignLeft()
4879 if ( m_actionFormatAlignLeft->isChecked() )
4881 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4882 TQPtrListIterator<KoTextFormatInterface> it( lst );
4883 KMacroCommand* macroCmd = 0L;
4884 for ( ; it.current() ; ++it )
4886 KCommand *cmd = it.current()->setAlignCommand( TQt::AlignLeft );
4890 macroCmd =
new KMacroCommand( i18n(
"Left-Align Text") );
4891 macroCmd->addCommand( cmd );
4895 m_doc->addCommand( macroCmd );
4898 m_actionFormatAlignLeft->setChecked(
true );
4901void KWView::textAlignCenter()
4903 if ( m_actionFormatAlignCenter->isChecked() )
4905 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4906 TQPtrListIterator<KoTextFormatInterface> it( lst );
4907 KMacroCommand* macroCmd = 0L;
4908 for ( ; it.current() ; ++it )
4910 KCommand *cmd = it.current()->setAlignCommand( TQt::AlignHCenter );
4914 macroCmd =
new KMacroCommand( i18n(
"Center Text") );
4915 macroCmd->addCommand( cmd );
4919 m_doc->addCommand( macroCmd );
4922 m_actionFormatAlignCenter->setChecked(
true );
4925void KWView::textAlignRight()
4927 if ( m_actionFormatAlignRight->isChecked() )
4929 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4930 TQPtrListIterator<KoTextFormatInterface> it( lst );
4931 KMacroCommand* macroCmd = 0L;
4932 for ( ; it.current() ; ++it )
4934 KCommand *cmd = it.current()->setAlignCommand( TQt::AlignRight );
4938 macroCmd =
new KMacroCommand( i18n(
"Right-Align Text") );
4939 macroCmd->addCommand( cmd );
4943 m_doc->addCommand( macroCmd );
4946 m_actionFormatAlignRight->setChecked(
true );
4949void KWView::textAlignBlock()
4951 if ( m_actionFormatAlignBlock->isChecked() )
4953 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4954 TQPtrListIterator<KoTextFormatInterface> it( lst );
4955 KMacroCommand* macroCmd = 0L;
4956 for ( ; it.current() ; ++it )
4958 KCommand *cmd = it.current()->setAlignCommand( TQt::AlignJustify );
4962 macroCmd =
new KMacroCommand( i18n(
"Justify Text") );
4963 macroCmd->addCommand( cmd );
4967 m_doc->addCommand( macroCmd );
4970 m_actionFormatAlignBlock->setChecked(
true );
4973void KWView::setSpacing( KoParagLayout::SpacingType spacing,
const TQString& commandName)
4975 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
4976 if ( lst.isEmpty() )
return;
4977 TQPtrListIterator<KoTextFormatInterface> it( lst );
4978 KMacroCommand* macroCmd = 0L;
4979 for ( ; it.current() ; ++it )
4981 KoParagLayout layout( *it.current()->currentParagLayoutFormat() );
4982 layout.lineSpacingType = spacing;
4984 KCommand *cmd = it.current()->setParagLayoutFormatCommand( &layout, KoParagLayout::LineSpacing );
4988 macroCmd =
new KMacroCommand( commandName );
4989 macroCmd->addCommand(cmd);
4993 m_doc->addCommand(macroCmd);
4996void KWView::textSpacingSingle()
4998 if ( m_actionFormatSpacingSingle->isChecked() )
4999 setSpacing( KoParagLayout::LS_SINGLE, i18n(
"Set Single Line Spacing") );
5001 m_actionFormatSpacingSingle->setChecked(
true );
5004void KWView::textSpacingOneAndHalf()
5006 if ( m_actionFormatSpacingOneAndHalf->isChecked() )
5007 setSpacing( KoParagLayout::LS_ONEANDHALF, i18n(
"Set One and a Half Line Spacing") );
5009 m_actionFormatSpacingOneAndHalf->setChecked(
true );
5012void KWView::textSpacingDouble()
5014 if ( m_actionFormatSpacingDouble->isChecked() )
5015 setSpacing( KoParagLayout::LS_DOUBLE, i18n(
"Set Double Line Spacing") );
5017 m_actionFormatSpacingDouble->setChecked(
true );
5020void KWView::slotCounterStyleSelected()
5022 TQString actionName = TQString::fromLatin1(sender()->name());
5023 TQString styleStr = actionName.mid(13);
5025 KoParagCounter::Style style = (KoParagCounter::Style)(styleStr.toInt());
5027 if ( style == KoParagCounter::STYLE_NONE )
5028 c.setNumbering( KoParagCounter::NUM_NONE );
5030 c.setNumbering( KoParagCounter::NUM_LIST );
5031 c.setStyle( style );
5033 c.setSuffix( TQString() );
5041 if ( currentTextEdit() && !currentTextEdit()->textFrameSet()->hasSelection() ) {
5042 KoTextParag* parag = currentTextEdit()->cursor()->parag();
5043 if ( parag->prev() && !parag->prev()->counter() )
5044 c.setRestartCounter(
true);
5048 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5049 TQPtrListIterator<KoTextFormatInterface> it( lst );
5050 KMacroCommand* macroCmd = 0L;
5051 for ( ; it.current() ; ++it )
5053 KCommand *cmd = it.current()->setCounterCommand( c );
5057 macroCmd=
new KMacroCommand( i18n(
"Change List Type") );
5058 macroCmd->addCommand( cmd );
5062 m_doc->addCommand( macroCmd );
5065void KWView::textSuperScript()
5067 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5068 if ( lst.isEmpty() )
return;
5069 TQPtrListIterator<KoTextFormatInterface> it( lst );
5070 KMacroCommand* macroCmd = 0L;
5071 for ( ; it.current() ; ++it )
5073 KCommand *cmd = it.current()->setTextSuperScriptCommand(m_actionFormatSuper->isChecked());
5077 macroCmd =
new KMacroCommand( i18n(
"Make Text Superscript") );
5078 macroCmd->addCommand(cmd);
5082 m_doc->addCommand(macroCmd);
5083 if (m_actionFormatSuper->isChecked() )
5084 m_actionFormatSub->setChecked(
false );
5087void KWView::textSubScript()
5089 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5090 if ( lst.isEmpty() )
return;
5091 TQPtrListIterator<KoTextFormatInterface> it( lst );
5092 KMacroCommand* macroCmd = 0L;
5093 for ( ; it.current() ; ++it )
5095 KCommand *cmd = it.current()->setTextSubScriptCommand(m_actionFormatSub->isChecked());
5099 macroCmd =
new KMacroCommand( i18n(
"Make Text Subscript") );
5100 macroCmd->addCommand(cmd);
5104 m_doc->addCommand(macroCmd);
5105 if (m_actionFormatSub->isChecked() )
5106 m_actionFormatSuper->setChecked(
false );
5109void KWView::changeCaseOfText()
5111 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5112 if ( lst.isEmpty() )
return;
5113 TQPtrListIterator<KoTextFormatInterface> it( lst );
5114 KoChangeCaseDia *caseDia=
new KoChangeCaseDia(
this,
"change case" );
5117 KMacroCommand* macroCmd = 0L;
5118 for ( ; it.current() ; ++it )
5120 KCommand *cmd = it.current()->setChangeCaseOfTextCommand(caseDia->getTypeOfCase());
5124 macroCmd =
new KMacroCommand( i18n(
"Change Case of Text") );
5125 macroCmd->addCommand(cmd);
5129 m_doc->addCommand(macroCmd);
5134void KWView::editPersonalExpr()
5136 KWEditPersonnalExpression *personalDia=
new KWEditPersonnalExpression(
this );
5137 if(personalDia->exec())
5138 m_doc->refreshMenuExpression();
5143void KWView::textIncreaseIndent()
5145 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5146 if ( lst.isEmpty() )
return;
5147 TQPtrListIterator<KoTextFormatInterface> it( lst );
5148 double leftMargin=0.0;
5150 leftMargin=lst.first()->currentParagLayoutFormat()->margins[TQStyleSheetItem::MarginLeft];
5151 double indent = m_doc->indentValue();
5152 double newVal = leftMargin + indent;
5153 KMacroCommand* macroCmd = 0L;
5154 for ( ; it.current() ; ++it )
5156 KCommand *cmd = it.current()->setMarginCommand( TQStyleSheetItem::MarginLeft, newVal );
5160 macroCmd =
new KMacroCommand( i18n(
"Increase Paragraph Depth") );
5161 macroCmd->addCommand(cmd);
5165 m_doc->addCommand(macroCmd);
5168 const KoParagLayout *layout=lst.first()->currentParagLayoutFormat();
5169 showRulerIndent( layout->margins[TQStyleSheetItem::MarginLeft], layout->margins[TQStyleSheetItem::MarginFirstLine], layout->margins[TQStyleSheetItem::MarginRight], lst.first()->rtl());
5177 double leftMargin = edit->currentLeftMargin();
5178 double indent = m_doc->indentValue();
5179 double newVal = leftMargin + indent;
5184 KCommand *cmd=edit->setMarginCommand( TQStyleSheetItem::MarginLeft, newVal );
5186 m_doc->addCommand(cmd);
5192void KWView::textDecreaseIndent()
5194 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5195 if ( lst.isEmpty() )
return;
5196 TQPtrListIterator<KoTextFormatInterface> it( lst );
5197 double leftMargin=0.0;
5199 leftMargin=lst.first()->currentParagLayoutFormat()->margins[TQStyleSheetItem::MarginLeft];
5200 double indent = m_doc->indentValue();
5201 double newVal = leftMargin - indent;
5202 KMacroCommand* macroCmd = 0L;
5203 for ( ; it.current() ; ++it )
5205 KCommand *cmd = it.current()->setMarginCommand( TQStyleSheetItem::MarginLeft, TQMAX( newVal, 0 ) );
5209 macroCmd =
new KMacroCommand( i18n(
"Decrease Paragraph Depth") );
5210 macroCmd->addCommand(cmd);
5214 m_doc->addCommand(macroCmd);
5217 const KoParagLayout *layout=lst.first()->currentParagLayoutFormat();
5218 showRulerIndent( layout->margins[TQStyleSheetItem::MarginLeft], layout->margins[TQStyleSheetItem::MarginFirstLine], layout->margins[TQStyleSheetItem::MarginRight], lst.first()->rtl());
5226 double leftMargin = edit->currentLeftMargin();
5227 if ( leftMargin > 0 )
5229 double indent = m_doc->indentValue();
5230 double newVal = leftMargin - indent;
5231 KCommand *cmd=edit->setMarginCommand( TQStyleSheetItem::MarginLeft, TQMAX( newVal, 0 ) );
5233 m_doc->addCommand(cmd);
5240void KWView::textDefaultFormat()
5242 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5243 if ( lst.isEmpty() )
return;
5244 TQPtrListIterator<KoTextFormatInterface> it( lst );
5245 KMacroCommand* macroCmd = 0L;
5246 for ( ; it.current() ; ++it )
5248 KCommand *cmd = it.current()->setDefaultFormatCommand();
5252 macroCmd =
new KMacroCommand( i18n(
"Default Format") );
5253 macroCmd->addCommand(cmd);
5257 m_doc->addCommand(macroCmd);
5261void KWView::borderOutline()
5263 bool on = m_actionBorderOutline->isChecked();
5264 if(m_actionBorderLeft->isChecked() != on) {
5265 m_actionBorderLeft->setChecked(on);
5268 if(m_actionBorderRight->isChecked() != on) {
5269 m_actionBorderRight->setChecked(on);
5272 if(m_actionBorderTop->isChecked() != on) {
5273 m_actionBorderTop->setChecked(on);
5276 if(m_actionBorderBottom->isChecked() != on) {
5277 m_actionBorderBottom->setChecked(on);
5282void KWView::borderLeft() {
5283 borderChanged(KoBorder::LeftBorder);
5286void KWView::borderRight() {
5287 borderChanged(KoBorder::RightBorder);
5290void KWView::borderTop() {
5291 borderChanged(KoBorder::TopBorder);
5294void KWView::borderBottom() {
5295 borderChanged(KoBorder::BottomBorder);
5298void KWView::borderChanged(KoBorder::BorderType type) {
5300 border.setPenWidth( m_actionBorderWidth->currentText().toInt() );
5301 border.color = m_actionBorderColor->color();
5302 border.setStyle( KoBorder::getStyle( m_actionBorderStyle->currentText() ) );
5303 bool enabled =
false;
5306 case KoBorder::LeftBorder:
5307 enabled = m_actionBorderLeft->isChecked();
5308 comment = i18n(
"Change Left Frame Border");
5310 case KoBorder::RightBorder:
5311 enabled = m_actionBorderRight->isChecked();
5312 comment = i18n(
"Change Right Frame Border");
5314 case KoBorder::TopBorder:
5315 enabled = m_actionBorderTop->isChecked();
5316 comment = i18n(
"Change Top Frame Border");
5318 case KoBorder::BottomBorder:
5320 enabled = m_actionBorderBottom->isChecked();
5321 comment = i18n(
"Change Bottom Frame Border");
5325 border.setPenWidth(0);
5330 KoBorder left = edit->
border(KoBorder::LeftBorder);
5331 KoBorder right = edit->
border(KoBorder::RightBorder);
5332 KoBorder top = edit->
border(KoBorder::TopBorder);
5333 KoBorder bottom = edit->
border(KoBorder::BottomBorder);
5334 if(type == KoBorder::LeftBorder)
5336 else if(type == KoBorder::RightBorder)
5338 else if(type == KoBorder::TopBorder)
5342 cmd=edit->setBordersCommand( left, right, top, bottom );
5345 TQPtrList<FrameIndex> indexes;
5346 TQPtrList<KWFrameBorderCommand::FrameBorderTypeStruct> borders;
5347 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
5348 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
5349 for(;framesIterator != selectedFrames.end(); ++framesIterator) {
5350 if( !(*framesIterator)->selected() )
continue;
5351 KWFrame *frame = (*framesIterator)->frame();
5353 KWFrameBorderCommand::FrameBorderTypeStruct *bts =
5354 new KWFrameBorderCommand::FrameBorderTypeStruct;
5355 bts->m_EFrameType = type;
5356 if(type == KoBorder::LeftBorder)
5358 else if(type == KoBorder::RightBorder)
5359 bts->m_OldBorder=frame->rightBorder();
5360 else if(type == KoBorder::TopBorder)
5361 bts->m_OldBorder=frame->topBorder();
5363 bts->m_OldBorder=frame->bottomBorder();
5364 borders.append(bts);
5366 if(indexes.count() > 0)
5371 m_doc->addCommand( cmd );
5374 m_actionBorderOutline->setChecked(
5375 m_actionBorderLeft->isChecked() && m_actionBorderRight->isChecked() &&
5376 m_actionBorderTop->isChecked() && m_actionBorderBottom->isChecked());
5379void KWView::backgroundColor()
5381 TQColor backColor = m_actionBackgroundColor->color();
5388 KCommand *cmd=edit->setTextBackgroundColorCommand(backColor);
5390 m_doc->addCommand( cmd );
5393 m_gui->canvasWidget()->setFrameBackgroundColor( backColor );
5397void KWView::resizeEvent( TQResizeEvent *e )
5399 TQWidget::resizeEvent( e );
5402 m_gui->resize( width(), height() );
5403 TQString s = m_actionViewZoom->currentText();
5404 if ( !KoZoomMode::isConstant(s) )
5409void KWView::guiActivateEvent( KParts::GUIActivateEvent *ev )
5411 if ( ev->activated() )
5414 if (m_doc->isEmbedded() ) {
5416 const int zoom = tqRound( KoView::zoom() * 100 );
5417 setZoom( zoom,
true );
5421 KoView::guiActivateEvent( ev );
5424void KWView::tabListChanged(
const KoTabulatorList & tabList )
5426 if(!m_doc->isReadWrite())
5428 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5429 if ( lst.isEmpty() )
return;
5430 TQPtrListIterator<KoTextFormatInterface> it( lst );
5431 KMacroCommand* macroCmd = 0L;
5432 for ( ; it.current() ; ++it )
5434 KCommand *cmd = it.current()->setTabListCommand( tabList );
5438 macroCmd =
new KMacroCommand(i18n(
"Change Tabulator") );
5439 macroCmd->addCommand(cmd);
5443 m_doc->addCommand(macroCmd);
5446void KWView::newPageLayout(
const KoPageLayout &layout )
5448 TQString mode = viewMode()->type();
5449 bool state = (mode!=
"ModeText");
5453 KoPageLayout pgLayout;
5455 KoKWHeaderFooter hf;
5456 m_doc->getPageLayout( pgLayout, cl, hf );
5458 if(layout==pgLayout)
5461 KWPageLayoutStruct oldLayout( pgLayout, cl, hf );
5463 m_doc->setPageLayout( layout, cl, hf );
5465 KWPageLayoutStruct newLayout( layout, cl, hf );
5469 edit->textFrameSet()->clearUndoRedoInfo();
5470 KCommand *cmd =
new KWPageLayoutCommand( i18n(
"Change Layout"), m_doc, oldLayout, newLayout );
5471 m_doc->addCommand(cmd);
5474void KWView::slotPageLayoutChanged(
const KoPageLayout& layout )
5479 viewMode()->setPageLayout( m_gui->getHorzRuler(), m_gui->getVertRuler(), layout );
5480 m_gui->canvasWidget()->repaintAll();
5483void KWView::newFirstIndent(
double firstIndent )
5485 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5486 if ( lst.isEmpty() )
return;
5487 TQPtrListIterator<KoTextFormatInterface> it( lst );
5488 KMacroCommand* macroCmd = 0L;
5489 for ( ; it.current() ; ++it )
5491 KCommand *cmd = it.current()->setMarginCommand( TQStyleSheetItem::MarginFirstLine, firstIndent );
5495 macroCmd =
new KMacroCommand(i18n(
"Change First Line Indent"));
5496 macroCmd->addCommand(cmd);
5500 m_doc->addCommand(macroCmd);
5503void KWView::newLeftIndent(
double leftIndent )
5505 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5506 if ( lst.isEmpty() )
return;
5507 TQPtrListIterator<KoTextFormatInterface> it( lst );
5508 KMacroCommand* macroCmd = 0L;
5509 for ( ; it.current() ; ++it )
5511 KCommand *cmd = it.current()->setMarginCommand( TQStyleSheetItem::MarginLeft, leftIndent );
5515 macroCmd =
new KMacroCommand(i18n(
"Change Indent") );
5516 macroCmd->addCommand(cmd);
5520 m_doc->addCommand(macroCmd);
5524void KWView::newRightIndent(
double rightIndent)
5527 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5528 if ( lst.isEmpty() )
return;
5529 TQPtrListIterator<KoTextFormatInterface> it( lst );
5530 KMacroCommand* macroCmd = 0L;
5531 for ( ; it.current() ; ++it )
5533 KCommand *cmd = it.current()->setMarginCommand( TQStyleSheetItem::MarginRight, rightIndent );
5537 macroCmd =
new KMacroCommand(i18n(
"Change Indent") );
5538 macroCmd->addCommand(cmd);
5542 m_doc->addCommand(macroCmd);
5545TQPopupMenu * KWView::popupMenu(
const TQString& name )
5551 partManager()->setActivePart( m_doc,
this );
5552 Q_ASSERT( factory() );
5554 return ((TQPopupMenu*)factory()->container( name,
this ));
5558void KWView::startKSpell()
5560 if ( !m_spell.kospell )
5561 m_spell.kospell =
new KoSpell( m_broker,
this );
5564 Q_ASSERT( m_spell.textIterator );
5566 m_spell.kospell->check( m_spell.textIterator,
true );
5568 m_spell.dlg =
new KSpell2::Dialog( m_spell.kospell,
this );
5569 m_spell.dlg->activeAutoCorrect(
true );
5571 TQObject::connect( m_spell.dlg, TQ_SIGNAL(misspelling(
const TQString&,
int)),
5572 this, TQ_SLOT(spellCheckerMisspelling(
const TQString&,
int)) );
5573 TQObject::connect( m_spell.dlg, TQ_SIGNAL(replace(
const TQString&,
int,
const TQString&)),
5574 this, TQ_SLOT(spellCheckerCorrected(
const TQString&,
int,
const TQString&)) );
5575 TQObject::connect( m_spell.dlg, TQ_SIGNAL(done(
const TQString&) ),
5576 this, TQ_SLOT(spellCheckerDone(
const TQString&)) );
5577 TQObject::connect( m_spell.dlg, TQ_SIGNAL(cancel() ),
5578 this, TQ_SLOT( spellCheckerCancel() ) );
5579 TQObject::connect( m_spell.dlg, TQ_SIGNAL(autoCorrect(
const TQString &,
const TQString & ) ),
5580 this, TQ_SLOT( spellAddAutoCorrect (
const TQString &,
const TQString &) ) );
5582 m_spell.dlg->show();
5586void KWView::spellCheckerMisspelling(
const TQString &old,
int pos )
5589 KoTextObject* textobj = m_spell.kospell->currentTextObject();
5590 KoTextParag* parag = m_spell.kospell->currentParag();
5591 Q_ASSERT( textobj );
5593 if ( !textobj || !parag )
return;
5595 Q_ASSERT( textdoc );
5596 if ( !textdoc )
return;
5597 pos += m_spell.kospell->currentStartIndex();
5598 kdDebug(32001) <<
"KWView::spellCheckerMisspelling parag=" << parag->paragId() <<
" pos=" << pos <<
" length=" << old.length() << endl;
5602void KWView::spellCheckerCorrected(
const TQString &old,
int pos ,
const TQString &corr )
5605 KoTextObject* textobj = m_spell.kospell->currentTextObject();
5606 KoTextParag* parag = m_spell.kospell->currentParag();
5607 Q_ASSERT( textobj );
5609 if ( !textobj || !parag )
return;
5611 Q_ASSERT( textdoc );
5612 if ( !textdoc )
return;
5613 pos += m_spell.kospell->currentStartIndex();
5616 KoTextCursor cursor( textdoc );
5617 cursor.setParag( parag );
5618 cursor.setIndex( pos );
5619 if(!m_spell.macroCmdSpellCheck)
5620 m_spell.macroCmdSpellCheck=
new KMacroCommand(i18n(
"Correct Misspelled Word"));
5621 m_spell.macroCmdSpellCheck->addCommand(textobj->replaceSelectionCommand(
5622 &cursor, corr, TQString(), KoTextDocument::HighlightSelection));
5625void KWView::spellCheckerDone(
const TQString & )
5629 Q_ASSERT( textdoc );
5633 clearSpellChecker();
5636void KWView::clearSpellChecker(
bool cancelSpellCheck)
5638 kdDebug(32001) <<
"KWView::clearSpellChecker" << endl;
5640 delete m_spell.textIterator;
5641 m_spell.textIterator = 0L;
5642 delete m_spell.kospell;
5643 m_spell.kospell = 0;
5645 if ( m_spell.macroCmdSpellCheck )
5647 if ( !cancelSpellCheck )
5648 m_doc->addCommand(m_spell.macroCmdSpellCheck);
5652 m_spell.macroCmdSpellCheck->unexecute();
5653 delete m_spell.macroCmdSpellCheck;
5656 m_spell.macroCmdSpellCheck=0L;
5657 m_spell.replaceAll.clear();
5661void KWView::spellCheckerCancel()
5663 kdDebug()<<
"void KWView::spellCheckerCancel() \n";
5664 spellCheckerRemoveHighlight();
5666 clearSpellChecker(
true);
5670void KWView::spellCheckerRemoveHighlight()
5672 KoTextObject* textobj = m_spell.kospell->currentTextObject();
5680 edit->drawCursor(
true );
5683void KWView::spellAddAutoCorrect (
const TQString & originalword,
const TQString & newword)
5685 m_doc->autoFormat()->addAutoFormatEntry( originalword, newword );
5688void KWView::configure()
5690 KWConfig configDia(
this );
5698 KWFrameSetEdit * edit = m_gui->canvasWidget()->currentFrameSetEdit();
5704void KWView::slotFrameSetEditChanged()
5707 bool rw = koDocument()->isReadWrite();
5708 bool selectedFrames = frameViewManager()->selectedFrames().count() > 0;
5709 bool hasSelection =
false;
5712 if ( edit->textFrameSet()->
textObject()->protectContent())
5716 KWFrameSetEdit * e = m_gui->canvasWidget()->currentFrameSetEdit();
5717 if ( e && e->frameSet()->
type() == FT_FORMULA ) {
5718 hasSelection =
true;
5721 m_actionEditCut->setEnabled( hasSelection && rw );
5723 m_actionEditCopy->setEnabled( hasSelection );
5724 m_actionEditReplace->setEnabled( rw );
5725 clipboardDataChanged();
5727 bool state = (edit != 0 | selectedFrames) && rw;
5728 m_actionEditSelectAll->setEnabled(state);
5729 m_actionEditSelectCurrentFrame->setEnabled(state);
5730 m_actionInsertComment->setEnabled( state );
5731 m_actionFormatDefault->setEnabled( state );
5732 m_actionFormatFont->setEnabled( state );
5733 m_actionFormatFontSize->setEnabled( state );
5734 m_actionFormatFontFamily->setEnabled( state );
5735 m_actionAddBookmark->setEnabled(state);
5736 m_actionBackgroundColor->setEnabled( state );
5737 m_actionFormatStyleMenu->setEnabled( state );
5738 m_actionFormatBold->setEnabled( state );
5739 m_actionFormatItalic->setEnabled( state );
5740 m_actionFormatUnderline->setEnabled( state );
5741 m_actionFormatStrikeOut->setEnabled( state );
5742 m_actionFormatColor->setEnabled( state );
5743 m_actionFormatAlignLeft->setEnabled( state );
5744 m_actionFormatAlignCenter->setEnabled( state );
5745 m_actionFormatAlignRight->setEnabled( state );
5746 m_actionFormatAlignBlock->setEnabled( state );
5748 m_actionBorderLeft->setEnabled( state );
5749 m_actionBorderRight->setEnabled( state );
5750 m_actionBorderTop->setEnabled( state );
5751 m_actionBorderBottom->setEnabled( state );
5752 m_actionBorderOutline->setEnabled( state );
5753 m_actionBorderColor->setEnabled( state );
5754 m_actionBorderWidth->setEnabled( state );
5755 m_actionBorderStyle->setEnabled( state );
5759 m_actionInsertLink->setEnabled(state);
5760 m_actionCreateStyleFromSelection->setEnabled( state );
5761 m_actionConvertToTextBox->setEnabled( state && hasSelection);
5762 m_actionAddPersonalExpression->setEnabled( state && hasSelection);
5763 m_actionSortText->setEnabled( state && hasSelection);
5764 bool goodleftMargin=
false;
5766 goodleftMargin=(edit->currentLeftMargin()>0);
5768 m_actionFormatDecreaseIndent->setEnabled(goodleftMargin);
5769 const bool canChangeCounter = rw && ( !edit || !edit->textFrameSet()->isFootEndNote() );
5770 m_actionFormatBullet->setEnabled(canChangeCounter);
5771 m_actionFormatNumber->setEnabled(canChangeCounter);
5772 m_actionFormatStyle->setEnabled(rw);
5773 m_actionFormatSpacingSingle->setEnabled(rw);
5774 m_actionFormatSpacingOneAndHalf->setEnabled(rw);
5775 m_actionFormatSpacingDouble->setEnabled(rw);
5776 m_actionFormatSuper->setEnabled(rw);
5777 m_actionFormatSub->setEnabled(rw);
5778 m_actionFormatParag->setEnabled(state);
5779 m_actionInsertSpecialChar->setEnabled(state);
5780 m_actionSpellCheck->setEnabled(state);
5782 m_actionChangeCase->setEnabled( (rw && !edit)|| (state && hasSelection) );
5784 if ( edit && edit->textFrameSet()->protectContent())
5786 m_actionChangeCase->setEnabled(
false );
5787 m_actionEditCut->setEnabled(
false );
5790 m_actionChangeCase->setEnabled(
true );
5792 updateTableActions( frameViewManager()->selectedFrames() ) ;
5794 m_actionInsertFormula->setEnabled(state && (viewMode()->type()!=
"ModeText"));
5795 actionInsertVariable->setEnabled(state);
5796 m_actionInsertExpression->setEnabled(state);
5798 changeFootEndNoteState();
5800 state= state && edit && edit->frameSet() && !edit->frameSet()->isHeaderOrFooter() && !edit->frameSet()->
groupmanager() && !edit->frameSet()->isFootEndNote();
5801 m_actionInsertContents->setEnabled(state);
5802 m_actionInsertFrameBreak->setEnabled( state );
5806void KWView::changeFootEndNoteState()
5808 bool rw = koDocument()->isReadWrite();
5810 TQString mode = viewMode()->type();
5812 bool isEditableFrameset = edit && edit->frameSet() && edit->frameSet()->isMainFrameset();
5813 bool ok = rw && isEditableFrameset && (mode!=
"ModeText");
5814 m_actionInsertFootEndNote->setEnabled( ok );
5815 m_actionEditFootEndNote->setEnabled( ok );
5818void KWView::changeFootNoteMenuItem(
bool footnote)
5820 m_actionEditFootEndNote->setText( footnote? i18n(
"Edit Footnote"): i18n(
"Edit Endnote"));
5821 m_actionChangeFootNoteType->setText( footnote? i18n(
"Change Footnote Parameter"):i18n(
"Change Endnote Parameter"));
5824void KWView::slotUpdateRuler()
5826 KWCanvas* canvas = m_gui->canvasWidget();
5830 m_gui->getHorzRuler()->setFrameStartEnd( r.left(), r.right() );
5831 m_gui->getVertRuler()->setFrameStartEnd( r.top(), r.bottom() );
5833 canvas->updateRulerOffsets();
5836void KWView::frameSelectedChanged()
5838 bool rw = koDocument()->isReadWrite();
5839 TQValueList<KWFrameView*> selectedFrames = frameViewManager()->selectedFrames();
5841 m_actionFormatFrameSet->setEnabled( selectedFrames.count() >= 1 );
5842 if ( rw && selectedFrames.count() >= 1 )
5844 bool okForDelete =
true;
5845 bool okForCopy =
true;
5846 bool okForLowerRaise =
false;
5847 bool okForChangeParagStyle =
true;
5848 bool okForChangeInline =
true;
5849 bool containsCellFrame =
false;
5850 bool containsMainFrame =
false;
5852 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
5853 while(framesIterator != selectedFrames.end() && (okForDelete || okForLowerRaise ||
5854 okForChangeParagStyle || okForChangeInline) ) {
5856 bool isFootNote = (*framesIterator)->frame()->frameSet()->isFootEndNote();
5857 bool headerFooterFootNote = isFootNote ||
5858 (*framesIterator)->frame()->frameSet()->isHeaderOrFooter();
5859 bool isMainWPFrame = (*framesIterator)->frame()->frameSet()->isMainFrameset();
5860 okForChangeParagStyle &= !isFootNote;
5861 okForCopy &= !headerFooterFootNote;
5863 okForDelete &= !headerFooterFootNote;
5864 okForDelete &= !isMainWPFrame;
5869 okForLowerRaise |= !(isMainWPFrame || headerFooterFootNote || (*framesIterator)->frame()->frameSet()->isFloating());
5870 okForChangeInline &= !(isMainWPFrame || headerFooterFootNote );
5872 if ( (*framesIterator)->frame()->frameSet()->groupmanager() )
5873 containsCellFrame =
true;
5874 if ( isMainWPFrame )
5875 containsMainFrame =
true;
5878 m_actionEditDelFrame->setEnabled( okForDelete );
5879 m_actionEditCut->setEnabled( okForDelete && !containsCellFrame );
5880 m_actionEditCopy->setEnabled( selectedFrames.count() >= 1 && okForCopy && !containsMainFrame && !containsCellFrame);
5882 m_actionLowerFrame->setEnabled( okForLowerRaise );
5883 m_actionRaiseFrame->setEnabled( okForLowerRaise );
5884 m_actionSendBackward->setEnabled( okForLowerRaise );
5885 m_actionBringToFront->setEnabled( okForLowerRaise );
5886 m_actionFormatBullet->setEnabled( okForChangeParagStyle );
5887 m_actionFormatNumber->setEnabled( okForChangeParagStyle );
5888 m_actionFormatStyle->setEnabled( okForChangeParagStyle);
5889 m_actionInlineFrame->setEnabled( okForChangeInline);
5891 KWFrame *frame = selectedFrames[0]->frame();
5892 updateBorderButtons(frame->
leftBorder(), frame->rightBorder(), frame->topBorder(),
5893 frame->bottomBorder());
5896 m_actionEditDelFrame->setEnabled(
false );
5897 m_actionInlineFrame->setEnabled(
false);
5898 m_actionEditCut->setEnabled(
false );
5899 m_actionLowerFrame->setEnabled(
false );
5900 m_actionRaiseFrame->setEnabled(
false );
5901 m_actionSendBackward->setEnabled(
false );
5902 m_actionBringToFront->setEnabled(
false );
5905 bool frameDifferentOfPart=
false;
5906 if(selectedFrames.count() >= 1)
5908 TQValueListIterator<KWFrameView*> framesIterator = selectedFrames.begin();
5909 while(framesIterator != selectedFrames.end()) {
5910 if ( (*framesIterator)->frame()->frameSet()->type()!=FT_PART &&
5911 (*framesIterator)->frame()->frameSet()->type()!= FT_PICTURE) {
5912 frameDifferentOfPart=
true;
5919 m_actionBackgroundColor->setEnabled( (selectedFrames.count() >= 1) && frameDifferentOfPart);
5920 m_actionBackgroundColor->setText(i18n(
"Frame Background Color..."));
5922 if ( frameDifferentOfPart ) {
5923 KWFrame *frame = selectedFrames[0]->frame();
5924 TQColor frameCol=frame->backgroundColor().color();
5926 m_actionBackgroundColor->setCurrentColor( frameCol.isValid()? frame->backgroundColor().color() : TQApplication::palette().color( TQPalette::Active, TQColorGroup::Base ));
5929 m_actionCreateFrameStyle->setEnabled( selectedFrames.count()==1 );
5930 m_actionCreateLinkedFrame->setEnabled( selectedFrames.count()==1 );
5932 updateTableActions( selectedFrames );
5934 updateFrameStatusBarItem();
5936 TQPtrList<KoTextFormatInterface> lst = applicableTextInterfaces();
5937 if ( !lst.isEmpty() )
5939 TQPtrListIterator<KoTextFormatInterface> it( lst );
5940 KoTextFormat format=*(lst.first()->currentFormat());
5941 showFormat( format );
5943 const KoParagLayout * paragLayout=lst.first()->currentParagLayoutFormat();
5944 KoParagCounter counter;
5945 if(paragLayout->counter)
5946 counter = *(paragLayout->counter);
5947 showCounter( counter );
5948 int align = paragLayout->alignment;
5949 if ( align == TQt::AlignAuto )
5950 align = TQt::AlignLeft;
5952 KoParagLayout::SpacingType spacing=paragLayout->lineSpacingType;
5953 showSpacing( spacing );
5956 m_gui->canvasWidget()->repaintAll(
false);
5960void KWView::updateTableActions( TQValueList<KWFrameView*> selectedFrames)
5962 TableInfo ti(selectedFrames);
5964 m_actionTableJoinCells->setEnabled( ti.tableCellsSelected());
5965 m_actionConvertTableToText->setEnabled( table && table->
isFloating() );
5967 m_actionTableSplitCells->setEnabled( ti.oneCellSelected() );
5969 m_actionTableInsertRow->setEnabled( ti.amountRowsSelected() );
5970 m_actionTableDelRow->setEnabled( ti.amountRowsSelected() );
5971 m_actionTableInsertCol->setEnabled( ti.amountColumnsSelected() );
5973 if(ti.amountColumnsSelected() == 1)
5974 m_actionTableDelCol->setText(i18n(
"D&elete Current Column..."));
5976 m_actionTableDelCol->setText(i18n(
"D&elete Selected Columns..."));
5977 m_actionTableDelCol->setEnabled( ti.amountColumnsSelected() > 0 );
5978 if(ti.amountRowsSelected() == 1)
5979 m_actionTableDelRow->setText(i18n(
"&Delete Current Row..."));
5981 m_actionTableDelRow->setText(i18n(
"&Delete Selected Rows..."));
5982 m_actionTableDelRow->setEnabled( ti.amountRowsSelected() > 0 );
5984 m_actionTableResizeCol->setEnabled( ti.tableCellsSelected() );
5985 m_actionTableDelete->setEnabled( ti.tableCellsSelected() );
5986 m_actionTablePropertiesMenu->setEnabled( ti.tableCellsSelected() );
5988 m_actionTableUngroup->setEnabled( ti.tableCellsSelected() );
5989 m_actionTableProtectCells->setEnabled( ti.tableCellsSelected() );
5990 m_actionTableProtectCells->setChecked( ti.protectContentEnabled() );
5993void KWView::docStructChanged(
int type)
5995 KWDocStruct *m_pDocStruct=m_gui->getDocStruct();
5997 m_pDocStruct->refreshTree(type);
5998 m_doc->recalcVariables( VT_STATISTIC );
6001void KWView::documentModified(
bool b )
6007 m_sbModifiedLabel->setPixmap( TDEGlobal::iconLoader()->loadIcon(
"action-modified", TDEIcon::Small ) );
6009 m_sbModifiedLabel->setText(
" " );
6012void KWView::changeOverwriteMode(
bool b )
6018 m_sbOverwriteLabel->setText(
' ' + i18n(
"OVER" ) +
' ' );
6020 m_sbOverwriteLabel->setText(
' ' + i18n(
"INSRT" ) +
' ' );
6023void KWView::setViewFrameBorders(
bool b)
6025 m_viewFrameBorders = b;
6027 m_doc->setViewFrameBorders( b );
6030bool KWView::doubleClickActivation()
const
6035TQWidget* KWView::canvas()
const
6040 return m_gui->canvasWidget();
6043int KWView::canvasXOffset()
const
6045 return m_gui->canvasWidget()->contentsX();
6048int KWView::canvasYOffset()
const
6050 return m_gui->canvasWidget()->contentsY();
6053void KWView::canvasAddChild( KoViewChild * child )
6055 connect( m_gui->canvasWidget(), TQ_SIGNAL( viewTransformationsChanged() ),
6056 child, TQ_SLOT( reposition() ) );
6061void KWView::changePicture()
6063 KWFrameView *view = frameViewManager()->selectedFrame();
6067 KWPictureFrameSet *frameset =
static_cast<KWPictureFrameSet *
>(frame->
frameSet());
6068 KoPictureKey oldKey ( frameset->picture().getKey() );
6069 TQString oldFile ( oldKey.filename() );
6071 url.setPath( oldFile );
6072 if (!TQDir(url.directory()).exists())
6073 oldFile = url.fileName();
6075 KoPicture picture ( KWInsertPicDia::selectPictureDia( oldFile,
this ) );
6076 if ( !picture.isNull() )
6080 frameset->insertPicture( picture );
6081 m_doc->frameChanged( frame );
6082 m_doc->refreshDocStructure( FT_PICTURE );
6083 m_doc->addCommand(cmd);
6086 kdDebug() <<
"KWView::changePicture cancelled" << endl;
6089void KWView::savePicture()
6091 KWFrameView *view = frameViewManager()->selectedFrame();
6095 KWPictureFrameSet *frameset =
static_cast<KWPictureFrameSet *
>(frame->
frameSet());
6096 TQString oldFile = frameset->picture().getKey().filename();
6098 url.setPath( oldFile );
6099 if ( !TQDir(url.directory()).exists() )
6100 oldFile = url.fileName();
6102 KoPicture picture( frameset->picture() );
6103 TQString mimetype = picture.getMimeType();
6104 kdDebug() <<
"Picture has mime type: " << mimetype << endl;
6105 TQStringList mimetypes;
6106 mimetypes << mimetype;
6107 KFileDialog fd( oldFile, TQString(),
this, 0,
true );
6108 fd.setMimeFilter( mimetypes );
6109 fd.setCaption(i18n(
"Save Picture"));
6110 fd.setOperationMode(KFileDialog::Saving);
6111 if ( fd.exec() == TQDialog::Accepted )
6113 url = fd.selectedURL();
6114 if ( url.isValid() )
6116 if ( url.isLocalFile() )
6118 TQFile file( url.path() );
6119 if ( file.open( IO_ReadWrite ) )
6121 picture.save( &file );
6126 KMessageBox::error(
this,
6127 i18n(
"Error during saving. Could not open '%1' for writing").arg ( url.path() ),
6128 i18n(
"Save Picture"));
6134 tempFile.setAutoDelete(
true );
6135 if ( tempFile.status() == 0 )
6137 TQFile file( tempFile.name() );
6138 if ( file.open( IO_ReadWrite ) )
6140 picture.save( &file );
6142 if ( !TDEIO::NetAccess::upload( tempFile.name(), url,
this ) )
6144 KMessageBox::sorry(
this, i18n(
6145 "Unable to save the file to '%1'. %2.").arg( url.prettyURL() ).arg( TDEIO::NetAccess::lastErrorString() ),
6146 i18n(
"Save Failed") );
6150 KMessageBox::error(
this,
6151 i18n(
"Error during saving. Could not open '%1' temporary file for writing").arg ( file.name() ),
6152 i18n(
"Save Picture"));
6155 KMessageBox::sorry(
this, i18n(
6156 "Error during saving. Could not create temporary file: %1.").arg( strerror( tempFile.status() ) ),
6157 i18n(
"Save Picture") );
6161 KMessageBox::sorry(
this, i18n(
"URL %1 is invalid.").arg( url.prettyURL() ), i18n(
"Save Picture") );
6166void KWView::configureHeaderFooter()
6168 KoPageLayout pgLayout;
6170 KoKWHeaderFooter kwhf;
6171 m_doc->getPageLayout( pgLayout, cl, kwhf );
6173 KWPageLayoutStruct oldLayout( pgLayout, cl, kwhf );
6176 int flags = KW_HEADER_AND_FOOTER;
6177 KoUnit::Unit unit = m_doc->unit();
6178 KoUnit::Unit oldUnit = unit;
6180 if ( KoPageLayoutDia::pageLayout( pgLayout, hf, cl, kwhf, flags, unit ) ) {
6181 if( oldLayout._hf != kwhf )
6183 KWPageLayoutStruct newLayout( pgLayout, cl, kwhf );
6186 oldLayout, newLayout );
6187 m_doc->addCommand(cmd);
6189 m_doc->setPageLayout( pgLayout, cl, kwhf );
6191 if ( unit != oldUnit )
6192 m_doc->setUnit( unit );
6197void KWView::inlineFrame()
6199 KWFrameView *view = frameViewManager()->selectedFrame();
6206 if(m_actionInlineFrame->isChecked())
6209 KMacroCommand* macroCmd =
new KMacroCommand( i18n(
"Make Frameset Inline") );
6210 TQValueList<FrameIndex> frameindexList;
6211 TQValueList<FrameMoveStruct> frameindexMove;
6213 KoPoint initialPos = frame->topLeft();
6218 frameindexList.append(
FrameIndex( frame ) );
6219 frameindexMove.append( FrameMoveStruct( initialPos, frame->topLeft() ) );
6223 macroCmd->addCommand(cmdMoveFrame);
6224 macroCmd->addCommand(cmd);
6225 m_doc->addCommand(macroCmd);
6230 m_doc->addCommand(cmd);
6235void KWView::openLink()
6242void KWView::changeLink()
6247 KoLinkVariable * var=edit->linkVariable();
6250 TQString oldhref= var->url();
6251 TQString oldLinkName=var->value();
6252 TQString link=oldLinkName;
6253 TQString ref=oldhref;
6254 if(KoInsertLinkDia::createLinkDia(link, ref, m_doc->listOfBookmarkName(0),
true,
this))
6256 if(!link.isEmpty() && !ref.isEmpty())
6258 if( ref != oldhref || link!=oldLinkName)
6260 KWChangeLinkVariable*cmd=
new KWChangeLinkVariable( i18n(
"Change Link"), m_doc,oldhref, ref, oldLinkName,link, var);
6262 m_doc->addCommand(cmd);
6270void KWView::copyLink()
6277void KWView::removeLink()
6284void KWView::addToBookmark()
6289 KoLinkVariable * var=edit->linkVariable();
6292 edit->addBookmarks(var->url());
6297void KWView::showDocStructure()
6299 m_doc->setShowDocStruct(m_actionShowDocStruct->isChecked());
6300 m_doc->reorganizeGUI();
6301 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
6304void KWView::showRuler()
6306 m_doc->setShowRuler( m_actionShowRuler->isChecked());
6307 m_doc->reorganizeGUI();
6308 TQTimer::singleShot( 0,
this, TQ_SLOT( updateZoom() ) );
6311void KWView::viewGrid()
6313 m_doc->setShowGrid( m_actionViewShowGrid->isChecked() );
6314 m_doc->setModified(
true );
6315 m_doc->updateGridButton();
6316 m_doc->repaintAllViews(
false);
6319void KWView::viewSnapToGrid()
6321 m_doc->setSnapToGrid( m_actionViewSnapToGrid->isChecked() );
6322 m_doc->setModified(
true );
6323 m_doc->updateGridButton();
6326void KWView::slotSoftHyphen()
6330 edit->insertSoftHyphen();
6333void KWView::slotNonbreakingSpace()
6337 edit->insertNonbreakingSpace();
6340void KWView::slotNonbreakingHyphen()
6344 edit->insertNonbreakingHyphen();
6347void KWView::slotLineBreak()
6351 edit->insertLineBreak();
6354void KWView::slotIncreaseNumberingLevel()
6358 edit->increaseNumberingLevel( m_doc->styleCollection() );
6361void KWView::slotDecreaseNumberingLevel()
6365 edit->decreaseNumberingLevel( m_doc->styleCollection() );
6368void KWView::refreshAllVariable()
6370 m_doc->recalcVariables( VT_ALL );
6373void KWView::slotAllowAutoFormat()
6375 bool state = m_actionAllowAutoFormat->isChecked();
6376 m_doc->setAllowAutoFormat( state );
6379void KWView::slotCompletion()
6386void KWView::updateHeaderFooterButton()
6388 m_actionViewHeader->setChecked(m_doc->isHeaderVisible());
6389 m_actionViewFooter->setChecked(m_doc->isFooterVisible());
6392void KWView::editComment()
6397 KoVariable * tmpVar=edit->variable();
6398 KoNoteVariable * var =
dynamic_cast<KoNoteVariable *
>(tmpVar);
6401 TQString authorName;
6402 KoDocumentInfo * info = m_doc->documentInfo();
6403 KoDocumentInfoAuthor * authorPage =
static_cast<KoDocumentInfoAuthor *
>(info->page(
"author" ));
6405 kdWarning() <<
"Author information not found in documentInfo !" << endl;
6407 authorName = authorPage->fullName();
6408 TQString oldValue = var->note();
6409 TQString createDate = var->createdNote();
6410 KoCommentDia *commentDia =
new KoCommentDia(
this, oldValue, authorName, createDate);
6411 if( commentDia->exec() )
6413 if ( oldValue != commentDia->commentText())
6415 KWChangeVariableNoteText *cmd =
new KWChangeVariableNoteText( i18n(
"Change Note Text"), m_doc, oldValue,commentDia->commentText(), var);
6416 m_doc->addCommand( cmd );
6425void KWView::fileStatistics()
6428 if ( !statisticsDialog->wasCanceled() )
6429 statisticsDialog->exec();
6430 delete statisticsDialog;
6433void KWView::removeComment()
6438 edit->removeComment();
6442void KWView::copyTextOfComment()
6447 edit->copyTextOfComment();
6451void KWView::configureCompletion()
6453 m_doc->autoFormat()->readConfig();
6454 KoCompletionDia dia(
this, 0, m_doc->autoFormat() );
6458void KWView::applyAutoFormat()
6460 m_doc->autoFormat()->readConfig();
6461 KMacroCommand *macro = 0L;
6462 TQValueList<KoTextObject *> list(m_doc->visibleTextObjects(viewMode()));
6463 TQValueList<KoTextObject *>::Iterator fit = list.begin();
6464 for ( ; fit != list.end() ; ++fit )
6466 KCommand *cmd = m_doc->autoFormat()->applyAutoFormat( *fit );
6470 macro =
new KMacroCommand( i18n(
"Apply Autoformat"));
6471 macro->addCommand( cmd );
6475 m_doc->addCommand( macro );
6478void KWView::createStyleFromSelection()
6483 KoStyleCollection* coll = m_doc->styleCollection();
6484 KoCreateStyleDia *dia =
new KoCreateStyleDia( TQStringList(),
this, 0 );
6487 TQString name = dia->nameOfNewStyle();
6488 KoParagStyle* style = coll->findStyleByDisplayName( name );
6492 edit->updateStyleFromSelection( style );
6496 style = edit->createStyleFromSelection( name );
6497 m_doc->styleCollection()->addStyle( style );
6498 m_doc->updateAllStyleLists();
6507void KWView::switchModeView()
6509 KWCanvas* canvas = m_gui->canvasWidget();
6513 TQString mode = canvas->viewMode()->
type();
6514 bool isTextMode = mode ==
"ModeText";
6515 bool state = !isTextMode;
6516 m_actionToolsCreateText->setEnabled(state);
6517 m_actionToolsCreatePix->setEnabled(state);
6518 m_actionToolsCreatePart->setEnabled(state);
6519 m_actionInsertFormula->setEnabled(state);
6520 m_actionInsertTable->setEnabled(state);
6521 changeFootEndNoteState();
6522 m_actionViewFooter->setEnabled( state && m_doc->processingType() == KWDocument::WP );
6523 m_actionViewHeader->setEnabled( state && m_doc->processingType() == KWDocument::WP );
6525 m_actionShowDocStruct->setEnabled(state);
6526 m_actionFormatPage->setEnabled(state);
6527 m_actionInsertContents->setEnabled( state );
6528 m_actionFrameStyle->setEnabled( state );
6529 m_actionTableStyle->setEnabled ( state );
6530 m_actionViewShowGrid->setEnabled( state );
6531 m_actionViewSnapToGrid->setEnabled( mode ==
"ModeNormal" || mode ==
"ModeEmbedded" );
6532 if ( m_gui->getHorzRuler())
6534 m_gui->getHorzRuler()->setPageLayoutMenuItemEnabled( state );
6535 if ( !koDocument()->isReadWrite())
6536 m_gui->getHorzRuler()->changeFlags( KoRuler::F_NORESIZE );
6540 m_gui->getHorzRuler()->changeFlags( m_gui->getHorzRuler()->flags() & ~(KoRuler::F_NORESIZE) );
6542 m_gui->getHorzRuler()->changeFlags( m_gui->getHorzRuler()->flags() | KoRuler::F_NORESIZE );
6545 if ( m_gui->getVertRuler() )
6547 m_gui->getVertRuler()->setPageLayoutMenuItemEnabled( state );
6548 if ( !koDocument()->isReadWrite())
6549 m_gui->getVertRuler()->changeFlags( KoRuler::F_NORESIZE );
6553 m_gui->getVertRuler()->changeFlags( m_gui->getVertRuler()->flags() & ~(KoRuler::F_NORESIZE) );
6555 m_gui->getVertRuler()->changeFlags( m_gui->getVertRuler()->flags() | KoRuler::F_NORESIZE );
6562 if ( m_doc->showdocStruct() )
6564 m_doc->setShowDocStruct(
false);
6565 m_doc->reorganizeGUI();
6570 m_doc->setShowDocStruct(m_actionShowDocStruct->isChecked());
6571 m_doc->reorganizeGUI();
6576 m_doc->recalcVariables( VT_PGNUM );
6580 canvas->editFrameSet(
static_cast<KWViewModeText*
>(canvas->viewMode())->textFrameSet() );
6584 updateZoomControls();
6588 canvas->viewMode()->
setPageLayout( m_gui->getHorzRuler(), m_gui->getVertRuler(), m_doc->pageLayout() );
6591void KWView::configureFootEndNote()
6593 KWConfigFootNoteDia *dia =
new KWConfigFootNoteDia(
this,
"configfootnote", m_doc );
6598void KWView::editFootEndNote()
6606 m_gui->canvasWidget()->editFrameSet( var->
frameSet() );
6609 textedit->ensureCursorVisible();
6614void KWView::changeFootNoteType()
6619 KoVariable * tmpVar=edit->variable();
6623 KWFootNoteDia dia( var->noteType(), var->numberingType(), (var->numberingType()==KWFootNoteVariable::Auto) ? TQString() : var->manualString(), this, m_doc, 0 );
6624 TQPtrListIterator<KoTextCustomItem> it( edit->textDocument()->allCustomItems() );
6625 for ( ; it.current() ; ++it )
6628 if (fnv && !fnv->isDeleted() && fnv->
frameSet() && !fnv->
frameSet()->isDeleted() &&
6629 fnv->numberingType()==KWFootNoteVariable::Manual && fnv != var)
6630 dia.appendManualFootNote( fnv->text() );
6634 FootNoteParameter oldParam( var );
6635 FootNoteParameter newParam(dia.noteType(), dia.numberingType(), dia.manualString() );
6636 KWChangeFootNoteParametersCommand * cmd =
new KWChangeFootNoteParametersCommand( i18n(
"Change Footnote Parameters"), var , oldParam, newParam, m_doc);
6638 m_doc->addCommand ( cmd );
6645void KWView::autoSpellCheck()
6647 autoSpellCheck( m_actionAllowBgSpellCheck->isChecked() );
6650void KWView::autoSpellCheck(
bool b)
6652 m_doc->changeBgSpellCheckingState( b );
6655void KWView::goToFootEndNote()
6657 KWFrameView *view = frameViewManager()->selectedFrame();
6661 KWFootNoteFrameSet *footNoteFrameSet =
dynamic_cast<KWFootNoteFrameSet *
>(frame->
frameSet());
6662 if ( footNoteFrameSet )
6665 KoTextParag *parag = var->paragraph();
6666 int index = var->index();
6669 m_gui->canvasWidget()->editTextFrameSet( frameSet, parag, index );
6675 bool rw = koDocument()->isReadWrite();
6676 bool kttsdInstalled = KoSpeaker::isKttsdInstalled();
6677 if (!rw && !kttsdInstalled)
6679 bool hasText = (frameset->
type()==FT_TEXT || frameset->
type()==FT_TABLE || frameset->
type()==FT_FORMULA );
6681 m_actionDocStructEdit->setEnabled( rw && hasText );
6682 m_actionDocStructDelete->setEnabled( (rw && !parag && !frameset->isMainFrameset() &&
6683 !frameset->isFootEndNote() && !frameset->isHeaderOrFooter()) );
6684 m_actionDocStructSpeak->setEnabled( hasText && kttsdInstalled );
6686 TQPopupMenu* popup =
static_cast<TQPopupMenu *
>(factory()->container(
"docstruct_popup",
this));
6691void KWView::docStructSelect()
6693 if ( m_gui->getDocStruct() )
6695 m_gui->getDocStruct()->selectItem();
6699void KWView::docStructEdit()
6701 if ( m_gui->getDocStruct() )
6703 m_gui->getDocStruct()->editItem();
6705 m_gui->canvasWidget()->setFocus();
6709void KWView::docStructProperties()
6711 if ( m_gui->getDocStruct() )
6713 m_gui->getDocStruct()->editProperties();
6717void KWView::docStructDelete()
6719 if ( m_gui->getDocStruct() )
6721 m_gui->getDocStruct()->deleteItem();
6725void KWView::docStructSpeak()
6727 if ( m_gui->getDocStruct() )
6729 m_gui->getDocStruct()->speakItem();
6733void KWView::insertFile()
6735 KFileDialog fd( TQString(), TQString(),
this, 0,
true );
6736 fd.setMimeFilter(
"application/x-kword" );
6737 fd.setCaption(i18n(
"Insert File"));
6739 if ( fd.exec() != TQDialog::Accepted )
6741 url = fd.selectedURL();
6744 KMessageBox::sorry(
this,
6745 i18n(
"File name is empty."),
6746 i18n(
"Insert File"));
6752void KWView::insertFile(
const KURL& url)
6754 KMacroCommand* macroCmd = 0L;
6755 bool hasFixedFramesets =
false;
6756 KoStore* store=KoStore::createStore(
this, url, KoStore::Read );
6762 TQString maindoc =
"maindoc.xml";
6767 bool b = store->open(maindoc);
6770 KMessageBox::sorry(
this,
6771 i18n(
"This file is not a KWord file!"),
6772 i18n(
"Insert File"));
6778 doc.setContent( store->device() );
6779 TQDomElement word = doc.documentElement();
6781 m_doc->loadPictureMap( word );
6783 m_doc->loadImagesFromStore( store );
6787 bool b = store->open(maindoc);
6790 KMessageBox::sorry(
this,
6791 i18n(
"File name is not a KWord file!"),
6792 i18n(
"Insert File"));
6797 doc.setContent( store->device() );
6798 TQDomElement word = doc.documentElement();
6800 TQDomElement framesets = word.namedItem(
"FRAMESETS" ).toElement();
6801 if ( !framesets.isNull() )
6803 TQDomElement framesetElem = framesets.firstChild().toElement();
6805 while ( !framesetElem.isNull() && framesetElem.tagName() !=
"FRAMESET" )
6806 framesetElem = framesetElem.nextSibling().toElement();
6808 if ( !framesetElem.isNull() )
6811 KoTextCursor insertionCursor( textFrameSet->textDocument() );
6813 if ( edit && !edit->textFrameSet()->protectContent()) {
6814 textFrameSet = edit->textFrameSet();
6815 insertionCursor = *edit->cursor();
6818 TQDomDocument domDoc(
"PARAGRAPHS" );
6819 TQDomElement paragsElem = domDoc.createElement(
"PARAGRAPHS" );
6820 domDoc.appendChild( paragsElem );
6824 TQValueList<TQDomElement> paragList;
6825 TQValueList<TQString> inlineFsNames;
6826 TQDomElement fsElem;
6828 TQDomNode n = framesetElem.firstChild().toElement();
6829 while( !n.isNull() )
6831 TQDomElement e = n.toElement();
6832 if ( !e.isNull() && e.tagName() ==
"PARAGRAPH" )
6834 paragList.append( e );
6836 TQDomElement formatsElem = e.namedItem(
"FORMATS" ).toElement();
6837 if ( !formatsElem.isNull() )
6840 TQDomElement formatElem = formatsElem.firstChild().toElement();
6841 for ( ; !formatElem.isNull() ; formatElem = formatElem.nextSibling().toElement() )
6843 TQDomElement anchorElem = formatElem.namedItem(
"ANCHOR" ).toElement();
6844 if ( !anchorElem.isNull() )
6846 TQString type = anchorElem.attribute(
"type" );
6847 if ( type ==
"grpMgr" || type ==
"frameset" )
6849 TQString iName = anchorElem.attribute(
"instance" );
6850 inlineFsNames.append( iName );
6854 fsElem = framesetElem.nextSibling().toElement();
6855 for ( ; !fsElem.isNull() ; fsElem = fsElem.nextSibling().toElement() )
6857 if ( fsElem.tagName() ==
"FRAMESET" )
6859 TQString name = fsElem.attribute(
"name" );
6860 TQString grpMgr = fsElem.attribute(
"grpMgr" );
6861 if ( name == iName )
6863 paragList.append( fsElem );
6866 else if ( grpMgr == iName )
6868 if ( grpMgr != tableName )
6871 table = domDoc.createElement(
"FRAMESET");
6872 table.setAttribute(
"frameType", FT_TABLE);
6873 table.setAttribute(
"frameInfo", 0);
6874 table.setAttribute(
"protectSize", fsElem.attribute(
"protectSize",
"0"));
6875 table.setAttribute(
"name", tableName);
6876 table.setAttribute(
"visible", fsElem.attribute(
"visible",
"1"));
6877 paragList.append( table );
6881 table.appendChild( fsElem.cloneNode() );
6894 n = n.nextSibling();
6897 TQValueList<TQDomElement>::Iterator it = paragList.begin();
6898 TQValueList<TQDomElement>::Iterator end = paragList.end();
6899 for ( ; it!= end ; ++it )
6902 paragsElem.appendChild( *it );
6908 TQDomDocument domDocFrames(
"SELECTION" );
6909 TQDomElement topElem = domDocFrames.createElement(
"SELECTION" );
6910 domDocFrames.appendChild( topElem );
6913 TQValueList<TQString> fsInHeader;
6914 TQValueList<TQDomElement> framesetsList;
6916 framesetElem = framesetElem.nextSibling().toElement();
6917 for ( ; !framesetElem.isNull() ; framesetElem = framesetElem.nextSibling().toElement() )
6919 if ( framesetElem.tagName() ==
"FRAMESET" )
6921 FrameSetType frameSetType =
static_cast<FrameSetType
>( KWDocument::getAttribute( framesetElem,
"frameType", FT_BASE ) );
6923 if ( frameSetType == FT_TEXT &&
6924 (info == KWFrameSet::FI_FIRST_HEADER ||
6925 info == KWFrameSet::FI_EVEN_HEADER ||
6926 info == KWFrameSet::FI_ODD_HEADER ||
6927 info == KWFrameSet::FI_FIRST_FOOTER ||
6928 info == KWFrameSet::FI_EVEN_FOOTER ||
6929 info == KWFrameSet::FI_ODD_FOOTER)
6931 fsInHeader += getInlineFramesets( framesetElem );
6933 TQString name = framesetElem.attribute(
"name" );
6934 TQString grpMgr = framesetElem.attribute(
"grpMgr" );
6935 if ( !inlineFsNames.contains(name) && !inlineFsNames.contains(grpMgr) )
6937 if ( !grpMgr.isEmpty() )
6939 if ( grpMgr != tableName )
6942 table = domDocFrames.createElement(
"FRAMESET");
6943 table.setAttribute(
"frameType", FT_TABLE);
6944 table.setAttribute(
"frameInfo", 0);
6945 table.setAttribute(
"protectSize", framesetElem.attribute(
"protectSize",
"0"));
6946 table.setAttribute(
"name", tableName);
6947 table.setAttribute(
"visible", framesetElem.attribute(
"visible",
"1"));
6948 framesetsList.append( table );
6951 table.appendChild( framesetElem.cloneNode() );
6956 framesetsList.append( framesetElem );
6964 it = framesetsList.begin();
6965 end = framesetsList.end();
6966 for ( ; it != end ; ++it )
6968 framesetElem = (*it);
6969 FrameSetType frameSetType =
static_cast<FrameSetType
>( KWDocument::getAttribute( framesetElem,
"frameType", FT_BASE ) );
6971 TQString name = framesetElem.attribute(
"name");
6972 TQString grpMgr = framesetElem.attribute(
"grpMgr" );
6974 if ( !fsInHeader.contains(name) && !fsInHeader.contains(grpMgr) &&
6975 !( frameSetType == FT_TEXT &&
6976 (info == KWFrameSet::FI_FIRST_HEADER ||
6977 info == KWFrameSet::FI_EVEN_HEADER ||
6978 info == KWFrameSet::FI_ODD_HEADER ||
6979 info == KWFrameSet::FI_FIRST_FOOTER ||
6980 info == KWFrameSet::FI_EVEN_FOOTER ||
6981 info == KWFrameSet::FI_ODD_FOOTER) )
6984 hasFixedFramesets =
true;
6985 topElem.appendChild( framesetElem );
6989 TQDomDocument embeddedDoc(
"SELECTION" );
6990 TQDomElement selElem = embeddedDoc.createElement(
"SELECTION" );
6991 embeddedDoc.appendChild( selElem );
6993 TQValueList<TQDomElement> embeddedList;
6994 TQDomElement embeddedElem = word.namedItem(
"EMBEDDED" ).toElement();
6995 for ( ; !embeddedElem.isNull() ; embeddedElem = embeddedElem.nextSibling().toElement() )
6997 if ( embeddedElem.tagName() ==
"EMBEDDED" )
6999 embeddedList.append( embeddedElem );
7002 it = embeddedList.begin();
7003 end = embeddedList.end();
7004 bool hasEmbedded =
false;
7005 for ( ; it!= end ; ++it )
7007 selElem.appendChild( *it );
7015 macroCmd =
new KMacroCommand( i18n(
"Insert File") );
7017 if ( hasFixedFramesets )
7021 m_doc->pasteFrames( topElem, macroCmd,
false,
false,
false );
7027 macroCmd =
new KMacroCommand( i18n(
"Insert File") );
7028 m_doc->insertEmbedded( store, selElem, macroCmd, 0 );
7032 KCommand *cmd = textFrameSet->pasteOasis( &insertionCursor, domDoc.toCString(),
true );
7035 macroCmd->addCommand( cmd );
7037 m_doc->addCommand( macroCmd );
7042 m_doc->loadImagesFromStore( store );
7043 m_doc->completePasting();
7049TQValueList<TQString> KWView::getInlineFramesets(
const TQDomNode &framesetElem)
7052 TQValueList<TQString> list;
7053 TQDomNode n = framesetElem.firstChild().toElement();
7054 for( ; !n.isNull(); n = n.nextSibling() )
7056 TQDomElement e = n.toElement();
7057 if ( !e.isNull() && e.tagName() ==
"PARAGRAPH" )
7059 TQDomElement formatsElem = e.namedItem(
"FORMATS" ).toElement();
7060 if ( !formatsElem.isNull() )
7063 TQDomElement formatElem = formatsElem.firstChild().toElement();
7064 for ( ; !formatElem.isNull() ; formatElem = formatElem.nextSibling().toElement() )
7066 TQDomElement anchorElem = formatElem.namedItem(
"ANCHOR" ).toElement();
7067 if ( !anchorElem.isNull() )
7069 TQString type = anchorElem.attribute(
"type" );
7070 if ( type ==
"grpMgr" || type ==
"frameset" )
7072 TQString iName = anchorElem.attribute(
"instance" );
7073 list.append( iName );
7084void KWView::addBookmark()
7090 KWCreateBookmarkDia dia( m_doc->listOfBookmarkName(0L),
this, 0 );
7092 TQString bookName = dia.bookmarkName();
7093 KoTextCursor start, end;
7094 if ( edit->textDocument()->hasSelection( KoTextDocument::Standard ) ) {
7095 start = edit->textDocument()->selectionStartCursor( KoTextDocument::Standard );
7096 end = edit->textDocument()->selectionEndCursor( KoTextDocument::Standard );
7098 start = *edit->cursor();
7101 int startSel = start.index();
7102 int endSel = end.index();
7103 m_doc->insertBookmark(bookName, start.parag(),end.parag(), startSel, endSel);
7108void KWView::selectBookmark()
7110 KWSelectBookmarkDia dia( m_doc->listOfBookmarkName(viewMode()), m_doc,
this, 0 );
7112 TQString bookName = dia.bookmarkSelected();
7113 const KoTextBookmark * book = m_doc->bookmarkByName( bookName );
7117 Q_ASSERT( book->startParag() );
7118 Q_ASSERT( book->endParag() );
7119 if ( !book->startParag() || !book->endParag() )
7122 m_gui->canvasWidget()->editTextFrameSet( textfs, book->startParag(), book->bookmarkStartIndex() );
7127 edit->textDocument()->removeSelection( KoTextDocument::Standard );
7128 edit->textDocument()->setSelectionStart( KoTextDocument::Standard, edit->cursor() );
7129 edit->cursor()->setParag( book->endParag());
7130 edit->cursor()->setIndex(book->bookmarkEndIndex() );
7131 edit->textDocument()->setSelectionEnd( KoTextDocument::Standard, edit->cursor() );
7132 book->startParag()->setChanged(
true );
7133 book->endParag()->setChanged(
true );
7134 m_doc->slotRepaintChanged( edit->frameSet() );
7140void KWView::importStyle()
7142 KWImportStyleDia dia( m_doc, m_doc->styleCollection(),
this );
7143 if ( dia.exec() && !dia.importedStyles().isEmpty() ) {
7144 m_doc->styleCollection()->importStyles( dia.importedStyles() );
7145 m_doc->setModified(
true );
7146 m_doc->updateAllStyleLists();
7150void KWView::testAndCloseAllFrameSetProtectedContent()
7153 if ( edit && edit->textFrameSet()->protectContent()) {
7154 m_doc->terminateEditing( edit->frameSet());
7158void KWView::updateRulerInProtectContentMode()
7161 KoRuler * hRuler = m_gui ? m_gui->getHorzRuler() : 0;
7163 if ( edit && hRuler) {
7164 if ( !edit->textFrameSet()->protectContent() )
7165 hRuler->changeFlags(KoRuler::F_INDENTS | KoRuler::F_TABS);
7167 hRuler->changeFlags(0);
7172void KWView::deselectAllFrames()
7174 m_gui->canvasWidget()->selectAllFrames(
false );
7177void KWView::insertDirectCursor()
7180 insertDirectCursor( m_actionInsertDirectCursor->isChecked());
7184void KWView::insertDirectCursor(
bool b)
7186 m_doc->setInsertDirectCursor(b);
7189void KWView::updateDirectCursorButton()
7192 m_actionInsertDirectCursor->setChecked(m_doc->insertDirectCursor());
7196void KWView::convertTableToText()
7198 KWCanvas * canvas = m_gui->canvasWidget();
7202 const TQByteArray arr = table->convertTableToText();
7204 if ( anchor && arr.size() )
7207 KoTextParag *parag = anchor->paragraph();
7208 int pos = anchor->index();
7209 KMacroCommand *macro =
new KMacroCommand(i18n(
"Convert Table to Text"));
7210 KCommand *cmd = table->
anchorFrameset()->deleteAnchoredFrame( anchor );
7212 macro->addCommand( cmd);
7214 m_gui->canvasWidget()->editTextFrameSet( frameset, parag, pos );
7217 if ( edit && edit->textFrameSet())
7219 cmd = edit->textFrameSet()->pasteOasis( edit->cursor(), arr,
true );
7221 macro->addCommand( cmd );
7223 m_doc->addCommand(macro);
7228void KWView::convertToTextBox()
7235 if( textfs->protectContent() || !textfs->
textObject()->hasSelection() )
7239 textfs->textDocument()->copySelection( oasisSaver.bodyWriter(), oasisSaver.savingContext(), KoTextDocument::Standard );
7240 if ( !oasisSaver.finish() )
7242 const TQByteArray arr = oasisSaver.data();
7246 KCommand *cmd = textfs->
textObject()->removeSelectedTextCommand( edit->textView()->cursor(), KoTextDocument::Standard );
7248 KMacroCommand* macro =
new KMacroCommand( i18n(
"Convert to Text Box"));
7249 macro->addCommand( cmd );
7251 cmd = m_gui->canvasWidget()->createTextBox( KoRect(30,30,300,300) );
7254 macro->addCommand( cmd );
7256 edit = currentTextEdit();
7260 cmd = edit->textFrameSet()->pasteOasis( edit->textView()->cursor(), arr,
true );
7262 macro->addCommand( cmd );
7264 edit->textFrameSet()->
layout();
7266 m_doc->addCommand( macro );
7269void KWView::slotAddIgnoreAllWord()
7273 m_doc->addSpellCheckIgnoreWord( edit->currentWordOrSelection() );
7276void KWView::sortText()
7281 KWSortDia dlg(
this,
"sort dia" );
7284 const TQByteArray arr = edit->textFrameSet()->
sortText(dlg.getSortType());
7287 KCommand *cmd = edit->textFrameSet()->pasteOasis( edit->cursor(), arr,
true );
7289 m_doc->addCommand(cmd);
7295void KWView::addPersonalExpression()
7301 TQString newExpression = edit->textFrameSet()->
textObject()->selectedText();
7303 TQString tmp=locateLocal(
"data",
"kword/expression/perso.xml");
7305 if ( !file.open( IO_ReadOnly ) )
7308 doc.setContent( &file );
7312 TQMap<TQString, TQStringList>lstOfPersonalExp;
7314 TQDomNode n = doc.documentElement().firstChild();
7315 for( ; !n.isNull(); n = n.nextSibling() )
7317 if ( n.isElement() )
7319 TQDomElement e = n.toElement();
7320 if ( e.tagName() ==
"Type" )
7323 group = i18n( e.namedItem(
"TypeName" ).toElement().text().utf8() );
7325 TQDomNode n2 = e.firstChild();
7326 for( ; !n2.isNull(); n2 = n2.nextSibling() )
7329 if ( n2.isElement() )
7331 TQDomElement e2 = n2.toElement();
7332 if ( e2.tagName() ==
"Expression" )
7334 TQString text = i18n( e2.namedItem(
"Text" ).toElement().text().utf8() );
7339 lstOfPersonalExp.insert(group,list);
7345 doc = TQDomDocument(
"KWordExpression" );
7346 TQDomElement begin = doc.createElement(
"KWordExpression" );
7347 doc.appendChild( begin );
7348 TQMapIterator<TQString, TQStringList> itPersonalExp = lstOfPersonalExp.find(i18n(
"Normal"));
7349 if ( itPersonalExp != lstOfPersonalExp.end())
7351 list = itPersonalExp.data();
7352 list<<newExpression;
7353 lstOfPersonalExp.replace( i18n(
"Normal"), list);
7358 list<<newExpression;
7359 lstOfPersonalExp.insert( i18n(
"Normal"), list);
7363 itPersonalExp = lstOfPersonalExp.begin();
7364 for ( ; itPersonalExp != lstOfPersonalExp.end(); ++itPersonalExp )
7366 TQDomElement type = doc.createElement(
"Type" );
7367 begin.appendChild( type );
7368 TQDomElement typeName = doc.createElement(
"TypeName" );
7369 type.appendChild( typeName );
7370 typeName.appendChild( doc.createTextNode(itPersonalExp.key() ) );
7371 list=itPersonalExp.data();
7372 for( uint i=0;i<list.count();i++ )
7374 TQDomElement expr = doc.createElement(
"Expression" );
7375 type.appendChild( expr );
7376 TQDomElement text = doc.createElement(
"Text" );
7377 expr.appendChild( text );
7378 text.appendChild( doc.createTextNode(list[i] ) );
7381 TQCString s = doc.toCString();
7383 if ( !file.open( IO_WriteOnly ) )
7385 kdDebug()<<
"Error in addPersonalExpression()\n";
7388 file.writeBlock(s,s.length());
7390 m_doc->refreshMenuExpression();
7393void KWView::addWordToDictionary()
7398 TQString word = edit->wordUnderCursor( *edit->cursor() );
7399 if ( !word.isEmpty() )
7400 m_doc->addWordToDictionary( word );
7404void KWView::embeddedStoreInternal()
7406 kdDebug(31001)<<k_funcinfo<<endl;
7407 KWFrameView *view = frameViewManager()->selectedFrame();
7412 part->storeInternal();
7415void KWView::goToDocumentStructure()
7417 KWDocStruct* docStruct = getGUI()->getDocStruct();
7418 if (docStruct) docStruct->setFocusHere();
7421void KWView::goToDocument()
7423 KWCanvas* canvas = getGUI()->canvasWidget();
7424 if (!canvas)
return;
7428void KWView::deleteFrameSet(
KWFrameSet * frameset)
7430 if ( frameset && frameset->
frame(0))
7432 frameViewManager()->view(frameset->
frame(0))->setSelected(
true );
7437TQPtrList<TDEAction> KWView::listOfResultOfCheckWord(
const TQString &word )
7439 TQPtrList<TDEAction> listAction;
7440 DefaultDictionary *dict = m_broker->defaultDictionary();
7441 const TQStringList lst = dict->suggest( word );
7442 if ( !lst.contains( word ) )
7444 TQStringList::ConstIterator it = lst.begin();
7445 const TQStringList::ConstIterator end = lst.end();
7446 for ( ; it != end ; ++it )
7448 if ( !(*it).isEmpty() )
7450 TDEAction * act =
new TDEAction( *it );
7451 connect( act, TQ_SIGNAL(activated()),
this, TQ_SLOT(slotCorrectWord()) );
7452 listAction.append( act );
7459void KWView::slotCorrectWord()
7461 TDEAction * act = (TDEAction *)(sender());
7465 edit->selectWordUnderCursor( *(edit->cursor()) );
7466 m_doc->addCommand( edit->textObject()->replaceSelectionCommand( edit->cursor(), act->text(), i18n(
"Replace Word") ));
7470void KWView::slotChildActivated(
bool a )
7473 KoViewChild* ch = child( (KoView*)sender() );
7476 KWDocumentChild* kwchild =
static_cast<KWDocumentChild *
>( ch->documentChild() );
7486 KoView::slotChildActivated( a );
7489Broker *KWView::broker()
const
7494void KWView::slotUnitChanged( KoUnit::Unit unit )
7496 getGUI()->getHorzRuler()->setUnit( unit );
7497 getGUI()->getVertRuler()->setUnit( unit );
7498 if ( m_sbUnitLabel )
7499 m_sbUnitLabel->setText(
' ' + KoUnit::unitDescription( unit ) +
' ' );
7503 return getGUI()->canvasWidget()->frameViewManager();
7506void KWView::deleteSelectedFrames() {
7511 KMacroCommand * macroCmd =
new KMacroCommand( i18n(
"Delete Frames") );
7514 KWFrame *frame = frameView->frame();
7516 if ( fs->isAFooter() || fs->isAHeader() )
7520 docItem|=m_doc->typeItemDocStructure(table->
type());
7523 docItem|=m_doc->typeItemDocStructure(fs->
type());
7526 KCommand * cmd=table->
anchorFrameset()->deleteAnchoredFrame( anchor );
7527 macroCmd->addCommand(cmd);
7533 macroCmd->addCommand(cmd);
7538 if ( fs->isMainFrameset() )
7541 docItem|=m_doc->typeItemDocStructure(fs->
type());
7545 KCommand *cmd=fs->
anchorFrameset()->deleteAnchoredFrame( anchor );
7546 macroCmd->addCommand(cmd);
7552 macroCmd->addCommand(cmd);
7558 m_doc->addCommand(macroCmd);
7559 m_doc->refreshDocStructure(docItem);
7569KWViewWidget::KWViewWidget( TQWidget *parent, KWView *view )
7570 : TQWidget( parent ),
7575void KWViewWidget::resizeEvent( TQResizeEvent *e )
7578 if ( ( e->size().width() != e->oldSize().width() )
7579 && ( m_view->kWordDocument()->zoomMode() == KoZoomMode::ZOOM_WIDTH ) )
7581 TQTimer::singleShot( 0, m_view, TQ_SLOT( updateZoom() ) );
7584 TQWidget::resizeEvent( e );
7591KWGUI::KWGUI(
const TQString& viewMode, TQWidget *parent, KWView *daView )
7592 : TQHBox( parent,
"" ),
7596 KWDocument * doc = m_view->kWordDocument();
7602 m_panner =
new TQSplitter( TQt::Horizontal,
this );
7605 m_docStruct =
new KWDocStruct( m_panner, doc,
this );
7606 m_docStruct->setMinimumWidth( 0 );
7609 m_right =
new KWViewWidget( m_panner, m_view );
7610 TQGridLayout *gridLayout =
new TQGridLayout( m_right, 2, 2 );
7611 m_canvas =
new KWCanvas( viewMode, m_right, doc,
this );
7612 gridLayout->addWidget( m_canvas, 1, 1 );
7617 m_panner->setSizes( l );
7619 KoPageLayout layout = doc->pageLayout();
7621 m_tabChooser =
new KoTabChooser( m_right, KoTabChooser::TAB_ALL );
7622 m_tabChooser->setReadWrite(doc->isReadWrite());
7623 gridLayout->addWidget( m_tabChooser, 0, 0 );
7625 m_horRuler =
new KoRuler( m_right, m_canvas->viewport(), TQt::Horizontal, layout,
7626 KoRuler::F_INDENTS | KoRuler::F_TABS,
7627 doc->unit(), m_tabChooser );
7628 m_horRuler->setReadWrite(doc->isReadWrite());
7629 gridLayout->addWidget( m_horRuler, 0, 1 );
7631 m_vertRuler =
new KoRuler( m_right, m_canvas->viewport(), TQt::Vertical, layout,
7633 m_vertRuler->setReadWrite(doc->isReadWrite());
7634 gridLayout->addWidget( m_vertRuler, 1, 0 );
7636 m_horRuler->setZoom( doc->zoomedResolutionX() );
7637 m_vertRuler->setZoom( doc->zoomedResolutionY() );
7639 m_horRuler->setGridSize(doc->gridX());
7641 connect( m_horRuler, TQ_SIGNAL( newPageLayout(
const KoPageLayout & ) ), m_view, TQ_SLOT( newPageLayout(
const KoPageLayout & ) ) );
7642 connect( m_horRuler, TQ_SIGNAL( newLeftIndent(
double ) ), m_view, TQ_SLOT( newLeftIndent(
double ) ) );
7643 connect( m_horRuler, TQ_SIGNAL( newFirstIndent(
double ) ), m_view, TQ_SLOT( newFirstIndent(
double ) ) );
7644 connect( m_horRuler, TQ_SIGNAL( newRightIndent(
double ) ), m_view, TQ_SLOT( newRightIndent(
double ) ) );
7646 connect( m_horRuler, TQ_SIGNAL( doubleClicked() ), m_view, TQ_SLOT( slotHRulerDoubleClicked() ) );
7647 connect( m_horRuler, TQ_SIGNAL( doubleClicked(
double) ), m_view, TQ_SLOT( slotHRulerDoubleClicked(
double) ) );
7648 connect( m_horRuler, TQ_SIGNAL( unitChanged( KoUnit::Unit ) ),
this, TQ_SLOT( unitChanged( KoUnit::Unit ) ) );
7649 connect( m_vertRuler, TQ_SIGNAL( newPageLayout(
const KoPageLayout & ) ), m_view, TQ_SLOT( newPageLayout(
const KoPageLayout & ) ) );
7650 connect( m_vertRuler, TQ_SIGNAL( doubleClicked() ), m_view, TQ_SLOT( formatPage() ) );
7651 connect( m_vertRuler, TQ_SIGNAL( unitChanged( KoUnit::Unit ) ),
this, TQ_SLOT( unitChanged( KoUnit::Unit ) ) );
7654 m_vertRuler->hide();
7660 connect( m_horRuler, TQ_SIGNAL( tabListChanged(
const KoTabulatorList & ) ), m_view,
7661 TQ_SLOT( tabListChanged(
const KoTabulatorList & ) ) );
7663 setKeyCompression(
true );
7664 setAcceptDrops(
true );
7665 setFocusPolicy( TQWidget::NoFocus );
7668void KWGUI::showGUI()
7673void KWGUI::resizeEvent( TQResizeEvent *e )
7675 TQWidget::resizeEvent( e );
7679void KWGUI::reorganize()
7681 int hSpace = m_vertRuler->minimumSizeHint().width();
7682 int vSpace = m_horRuler->minimumSizeHint().height();
7683 if(m_view->kWordDocument()->showRuler())
7685 m_vertRuler->show();
7687 m_tabChooser->show();
7688 m_tabChooser->setGeometry( 0, 0, hSpace, vSpace );
7692 m_vertRuler->hide();
7694 m_tabChooser->hide();
7699 if(m_view->kWordDocument()->showdocStruct()) {
7700 if(m_docStruct->isHidden()) {
7701 m_docStruct->show();
7702 if(m_panner->sizes()[0] < 50) {
7706 m_panner->setSizes( l );
7710 m_docStruct->hide();
7712 if( m_view->statusBar())
7714 if(m_view->kWordDocument()->showStatusBar())
7715 m_view->statusBar()->show();
7717 m_view->statusBar()->hide();
7720 if ( m_view->kWordDocument()->showScrollBar())
7722 m_canvas->setVScrollBarMode(TQScrollView::Auto);
7723 m_canvas->setHScrollBarMode(TQScrollView::Auto);
7727 m_canvas->setVScrollBarMode(TQScrollView::AlwaysOff);
7728 m_canvas->setHScrollBarMode(TQScrollView::AlwaysOff);
7732void KWGUI::unitChanged( KoUnit::Unit u )
7734 m_view->kWordDocument()->setUnit( u );
7737TQPoint KWView::applyViewTransformations(
const TQPoint& p )
const
7739 return viewMode()->normalToView( m_doc->zoomPoint( KoPoint( p ) ) );
7742TQPoint KWView::reverseViewTransformations(
const TQPoint& p )
const
7744 return m_doc->unzoomPoint( viewMode()->viewToNormal( p ) ).toTQPoint();
7747int KWView::currentPage()
const {
7748 return m_currentPage->pageNumber();
7751void KWView::slotDocumentLoadingCompleted()
7756#include "KWView.moc"
An anchor is a special character, or 'custom item'.
Class: KWCanvas This class is responsible for the rendering of the frames to the screen as well as th...
KWTableFrameSet * getCurrentTable() const
The current table (either because one or more cells are selected, or because the cursor is in a table...
Command created when creating a frame.
Command created when deleting a frame.
Command created when deleting a table.
This class implements the 'find' functionality ( the "search next, prompt" loop ) and the 'replace' f...
Command created when changing frame border.
Command created when we changed a clipart or picture.
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.
Command created when one or more frames are moved.
Command created when the properties of a frame are changed (e.g.
This object is created to edit a particular frameset in a particular view The view's canvas creates i...
virtual KWFrameSetEdit * currentTextEdit()
Return the current most-low-level text edit object.
This command makes a frameset floating and non-floating.
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.
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
Command created when applying a framestyle.
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.
an instance of a KWFrameView represents the view in the MVC model of a frame; there can be multiple K...
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
Command created when inserting a column.
Command created when inserting a row.
This is used to save a bunch of paragraphs into a oasis store in memory, as some features do (e....
Command created when changing the page layout.
This class represents a printed page of the document.
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.
A frameset that contains an embedded object (a KWDocumentChild)
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).
Command created when removing a column.
Command created when removing a row.
A dialog that can be used to resize columns of a table using numeric input.
A class that calculates and show the statistics for a certain KWDocument.
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
Command created when applying a tablestyle.
Table style (can created/modified/deleted by the user) A table style is simply a paragraph style and ...
This is our KoTextDocument reimplementation, to create KWTextParag instead of KoTextParags,...
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.
Class: KWTextFrameSet Contains text (KoTextObject) and frames to display that text.
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.
Command created when ungrouping a table.
A mode for previewing the overall document Pages are organized in a grid (mostly useful when zooming ...
The 'edit only one text frameset' view mode.
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.
virtual void setPageLayout(KoRuler *hRuler, KoRuler *vRuler, const KoPageLayout &layout)
Called when the page layout is set, or changes.
virtual TQRect rulerFrameRect()
The result of this is passed to setFrameStartEnd for both rulers (after adjustement with pageCorner()...
virtual const TQString type() const =0
Return the name of the viewmode, used for loading/saving.