38#include <tqclipboard.h>
41#include <tqpaintdevicemetrics.h>
44#include <tqtoolbutton.h>
45#include <tqsqldatabase.h>
46#include <tqlistview.h>
47#include <tqsizepolicy.h>
50#include <dcopclient.h>
52#include <tdeapplication.h>
56#include <kfinddialog.h>
57#include <tdefontdialog.h>
58#include <kinputdialog.h>
59#include <tdemessagebox.h>
60#include <knotifyclient.h>
63#include <kreplacedialog.h>
65#include <tdespelldlg.h>
66#include <kstatusbar.h>
67#include <kstdaction.h>
68#include <kstandarddirs.h>
69#include <tdetempfile.h>
70#include <tdeparts/partmanager.h>
71#include <tdelistview.h>
72#include <kpushbutton.h>
75#include <tkcoloractions.h>
77#include <KoCharSelectDia.h>
78#include <KoCommandHistory.h>
79#include <KoMainWindow.h>
80#include <KoOasisLoadingContext.h>
81#include <KoOasisStore.h>
82#include <KoOasisStyles.h>
83#include <KoPartSelectAction.h>
84#include <KoStoreDrag.h>
86#include <kspread_toolbox.h>
87#include <KoTemplateCreateDia.h>
88#include <KoZoomAction.h>
95#include "ksploadinginfo.h"
96#include "kspread_canvas.h"
97#include "kspread_editors.h"
98#include "kspread_events.h"
99#include "kspread_global.h"
100#include "kspread_handler.h"
101#include "kspread_locale.h"
102#include "kspread_map.h"
103#include "selection.h"
104#include "kspread_sheetprint.h"
105#include "kspread_style.h"
106#include "kspread_style_manager.h"
107#include "kspread_undo.h"
108#include "testrunner.h"
109#include "valuecalc.h"
110#include "valueconverter.h"
113#include "dialogs/kspread_dlg_angle.h"
114#include "dialogs/kspread_dlg_area.h"
115#include "dialogs/kspread_dlg_comment.h"
116#include "dialogs/kspread_dlg_conditional.h"
117#include "dialogs/kspread_dlg_cons.h"
118#include "dialogs/kspread_dlg_csv.h"
119#include "dialogs/kspread_dlg_database.h"
120#include "dialogs/kspread_dlg_format.h"
121#include "dialogs/kspread_dlg_formula.h"
122#include "dialogs/kspread_dlg_goalseek.h"
123#include "dialogs/kspread_dlg_goto.h"
124#include "dialogs/kspread_dlg_insert.h"
125#include "dialogs/kspread_dlg_layout.h"
126#include "dialogs/kspread_dlg_list.h"
128#include "dialogs/kspread_dlg_paperlayout.h"
129#include "dialogs/kspread_dlg_pasteinsert.h"
130#include "dialogs/kspread_dlg_preference.h"
131#include "dialogs/kspread_dlg_reference.h"
132#include "dialogs/kspread_dlg_resize2.h"
133#include "dialogs/kspread_dlg_series.h"
134#include "dialogs/kspread_dlg_show.h"
135#include "dialogs/kspread_dlg_showColRow.h"
136#include "dialogs/kspread_dlg_sort.h"
137#include "dialogs/kspread_dlg_special.h"
138#include "dialogs/kspread_dlg_styles.h"
139#include "dialogs/kspread_dlg_subtotal.h"
140#include "dialogs/kspread_dlg_validity.h"
141#include "dialogs/link.h"
142#include "dialogs/sheet_properties.h"
143#include "dialogs/kspread_dlg_find.h"
144#include "dialogs/SheetSelectWidget.h"
145#include "kspread_propertyEditor.h"
146#include "kspread_generalProperty.h"
149#include "KSpreadViewIface.h"
151#include "kspread_view.h"
172 VBorder *vBorderWidget;
173 HBorder *hBorderWidget;
174 TQScrollBar *horzScrollBar;
175 TQScrollBar *vertScrollBar;
177 KStatusBarLabel* calcLabel;
180 TQHBoxLayout* formulaBarLayout;
181 ComboboxLocationEditWidget *posWidget;
182 TQButton* formulaButton;
184 TQButton *cancelButton;
186 TQGridLayout* viewLayout;
187 TQHBoxLayout* tabScrollBarLayout;
190 ViewActions* actions;
202 Selection* selection;
204 TQMap<Sheet*, TQPoint> savedAnchors;
205 TQMap<Sheet*, TQPoint> savedMarkers;
206 TQMap<Sheet*, KoPoint> savedOffsets;
211 TQStringList findStrings;
212 TQStringList replaceStrings;
213 FindOption::searchTypeValue typeValue;
214 FindOption::searchDirectionValue directionValue;
223 InsertHandler* insertHandler;
226 KoCharSelectDia* specialCharDlg;
229 TQGuardedPtr<KoTransformToolBox> transformToolBox;
234 TQPopupMenu *popupMenu;
235 int popupMenuFirstToolId;
237 TQPopupMenu *popupRow;
238 TQPopupMenu *popupColumn;
239 TQPopupMenu* popupChild;
240 TQPopupMenu* popupListChoose;
243 Child* popupChildObject;
249 Sheet * firstSpellSheet;
250 Sheet * currentSpellSheet;
252 MacroUndoAction *macroCmdSpellCheck;
253 unsigned int spellCurrCellX;
254 unsigned int spellCurrCellY;
255 unsigned int spellStartCellX;
256 unsigned int spellStartCellY;
257 unsigned int spellEndCellX;
258 unsigned int spellEndCellY;
259 bool spellCheckSelection;
260 TQStringList replaceAll;
265 Sheet * currentSheet;
275 TQPtrList<ToolEntry> toolList;
278 void adjustActions(
bool mode );
279 void adjustActions( Sheet* sheet, Cell* cell );
280 void adjustWorkbookActions(
bool mode );
281 void updateButton( Cell *cell,
int column,
int row);
282 TQButton* newIconButton(
const char *_file,
bool _kbutton =
false, TQWidget *_parent = 0L );
284 PropertyEditor *m_propertyEditor;
288 TQTimer statusBarOpTimer;
296 TDEAction* cellLayout;
297 TDEAction *actionExtraProperties;
298 TDEAction* defaultFormat;
299 TDEToggleAction* bold;
300 TDEToggleAction* italic;
301 TDEToggleAction* underline;
302 TDEToggleAction* strikeOut;
303 TDEFontAction* selectFont;
304 TDEFontSizeAction* selectFontSize;
305 TDEAction* fontSizeUp;
306 TDEAction* fontSizeDown;
307 TTDESelectColorAction* textColor;
308 TDEToggleAction* alignLeft;
309 TDEToggleAction* alignCenter;
310 TDEToggleAction* alignRight;
311 TDEToggleAction* alignTop;
312 TDEToggleAction* alignMiddle;
313 TDEToggleAction* alignBottom;
314 TDEToggleAction* wrapText;
315 TDEToggleAction* verticalText;
316 TDEAction* increaseIndent;
317 TDEAction* decreaseIndent;
318 TDEAction* changeAngle;
319 TDEToggleAction* percent;
321 TDEAction* precminus;
322 TDEToggleAction* money;
325 TDEAction* firstLetterUpper;
326 TTDESelectColorAction* bgColor;
327 TDEAction* borderLeft;
328 TDEAction* borderRight;
329 TDEAction* borderTop;
330 TDEAction* borderBottom;
331 TDEAction* borderAll;
332 TDEAction* borderOutline;
333 TDEAction* borderRemove;
334 TTDESelectColorAction* borderColor;
335 TDESelectAction* selectStyle;
336 TDEAction* createStyle;
340 TDEAction* insertCell;
341 TDEAction* removeCell;
342 TDEAction* deleteCell;
343 TDEToolBarPopupAction* mergeCell;
344 TDEAction* mergeCellHorizontal;
345 TDEAction* mergeCellVertical;
346 TDEAction* dissociateCell;
347 TDEAction* clearText;
348 TDEAction* conditional;
349 TDEAction* clearConditional;
351 TDEAction* clearValidity;
352 TDEAction* addModifyComment;
353 TDEAction* removeComment;
354 TDEAction* clearComment;
357 TDEAction* resizeColumn;
358 TDEAction* insertColumn;
359 TDEAction* deleteColumn;
360 TDEAction* hideColumn;
361 TDEAction* showColumn;
362 TDEAction* equalizeColumn;
363 TDEAction* showSelColumns;
364 TDEAction* resizeRow;
365 TDEAction* insertRow;
366 TDEAction* deleteRow;
369 TDEAction* equalizeRow;
370 TDEAction* showSelRows;
374 TDEAction* sheetProperties;
375 TDEAction* insertSheet;
376 TDEAction* menuInsertSheet;
377 TDEAction* removeSheet;
378 TDEAction* renameSheet;
379 TDEAction* hideSheet;
380 TDEAction* showSheet;
381 TDEAction* autoFormat;
384 TDEAction* insertSeries;
385 TDEAction* insertFunction;
386 TDEAction* insertSpecialChar;
387 TDEAction* insertFromDatabase;
388 TDEAction* insertFromTextfile;
389 TDEAction* insertFromClipboard;
390 TDEAction* transform;
394 TDEAction* fillRight;
398 TDEAction* paperLayout;
399 TDEAction* definePrintRange;
400 TDEAction* resetPrintRange;
401 TDEToggleAction* showPageBorders;
402 TDEAction* recalcWorksheet;
403 TDEAction* recalcWorkbook;
404 TDEToggleAction* protectSheet;
405 TDEToggleAction* protectDoc;
411 TDEAction* specialPaste;
412 TDEAction* insertCellCopy;
418 TDEAction* nextSheet;
419 TDEAction* prevSheet;
420 TDEAction* firstSheet;
421 TDEAction* lastSheet;
424 TDEAction* styleDialog;
426 TDESelectAction* formulaSelection;
427 TDEAction* insertLink;
428 TDEAction* removeLink;
429 TDEAction* consolidate;
431 TDEAction* subTotals;
432 TDEAction* textToColumns;
433 TDEAction* multipleOperations;
434 TDEAction* createTemplate;
435 KoPartSelectAction *insertPart;
436 TDEToggleAction* insertChartFrame;
437 TDEAction* insertPicture;
438 TDEAction* customList;
439 TDEAction* spellChecking;
440 TDEAction* internalTests;
441 TDEAction* inspector;
444 KoZoomAction* viewZoom;
445 TDEToggleAction* showStatusBar;
446 TDEToggleAction* showTabBar;
447 TDEToggleAction* showFormulaBar;
448 TDEAction* preference;
451 TDEToggleAction* calcNone;
452 TDEToggleAction* calcMin;
453 TDEToggleAction* calcMax;
454 TDEToggleAction* calcAverage;
455 TDEToggleAction* calcCount;
456 TDEToggleAction* calcSum;
457 TDEToggleAction* calcCountA;
461void View::Private::initActions()
463 actions =
new ViewActions;
465 TDEActionCollection* ac = view->actionCollection();
469 actions->cellLayout =
new TDEAction( i18n(
"Cell Format..."),
"cell_layout",
470 TQt::CTRL+ TQt::ALT+ TQt::Key_F, view, TQ_SLOT( layoutDlg() ), ac,
"cellLayout" );
471 actions->cellLayout->setToolTip( i18n(
"Set the cell formatting.") );
473 actions->actionExtraProperties =
new TDEAction( i18n(
"&Properties" ),
"penbrush", 0,
474 view, TQ_SLOT( extraProperties() ), ac,
"extra_properties" );
476 actions->defaultFormat =
new TDEAction( i18n(
"Default"),
477 0, view, TQ_SLOT( defaultSelection() ), ac,
"default" );
478 actions->defaultFormat->setToolTip( i18n(
"Resets to the default format.") );
480 actions->bold =
new TDEToggleAction( i18n(
"Bold"),
"format-text-bold",
481 TQt::CTRL+TQt::Key_B, ac,
"bold");
482 TQObject::connect( actions->bold, TQ_SIGNAL( toggled(
bool) ),
483 view, TQ_SLOT( bold(
bool ) ) );
485 actions->italic =
new TDEToggleAction( i18n(
"Italic"),
"format-text-italic",
486 TQt::CTRL+TQt::Key_I, ac,
"italic");
487 TQObject::connect( actions->italic, TQ_SIGNAL( toggled(
bool) ),
488 view, TQ_SLOT( italic(
bool ) ) );
490 actions->underline =
new TDEToggleAction( i18n(
"Underline"),
"format-text-underline",
491 TQt::CTRL+TQt::Key_U, ac,
"underline");
492 TQObject::connect( actions->underline, TQ_SIGNAL( toggled(
bool) ),
493 view, TQ_SLOT( underline(
bool ) ) );
495 actions->strikeOut =
new TDEToggleAction( i18n(
"Strike Out"),
"format-text-strikethrough",
497 TQObject::connect( actions->strikeOut, TQ_SIGNAL( toggled(
bool) ),
498 view, TQ_SLOT( strikeOut(
bool ) ) );
500 actions->selectFont =
new TDEFontAction( i18n(
"Select Font..."),
501 0, ac,
"selectFont" );
502 TQObject::connect( actions->selectFont, TQ_SIGNAL( activated(
const TQString& ) ),
503 view, TQ_SLOT( fontSelected(
const TQString& ) ) );
505 actions->selectFontSize =
new TDEFontSizeAction( i18n(
"Select Font Size"),
506 0, ac,
"selectFontSize" );
507 TQObject::connect( actions->selectFontSize, TQ_SIGNAL( fontSizeChanged(
int ) ),
508 view, TQ_SLOT( fontSizeSelected(
int ) ) );
510 actions->fontSizeUp =
new TDEAction( i18n(
"Increase Font Size"),
"fontsizeup",
511 0, view, TQ_SLOT( increaseFontSize() ), ac,
"increaseFontSize" );
513 actions->fontSizeDown =
new TDEAction( i18n(
"Decrease Font Size"),
"fontsizedown",
514 0, view, TQ_SLOT( decreaseFontSize() ), ac,
"decreaseFontSize" );
516 actions->textColor =
new TTDESelectColorAction( i18n(
"Text Color"),
517 TTDESelectColorAction::TextColor, view, TQ_SLOT( changeTextColor() ),
518 ac,
"textColor",
true );
519 actions->textColor->setDefaultColor(TQColor());
521 actions->alignLeft =
new TDEToggleAction( i18n(
"Align Left"),
"format-text-direction-ltr",
523 TQObject::connect( actions->alignLeft, TQ_SIGNAL( toggled(
bool ) ),
524 view, TQ_SLOT( alignLeft(
bool ) ) );
525 actions->alignLeft->setExclusiveGroup(
"Align" );
526 actions->alignLeft->setToolTip(i18n(
"Left justify the cell contents."));
528 actions->alignCenter =
new TDEToggleAction( i18n(
"Align Center"),
"text_center",
530 TQObject::connect( actions->alignCenter, TQ_SIGNAL( toggled(
bool ) ),
531 view, TQ_SLOT( alignCenter(
bool ) ) );
532 actions->alignCenter->setExclusiveGroup(
"Align" );
533 actions->alignCenter->setToolTip(i18n(
"Center the cell contents."));
535 actions->alignRight =
new TDEToggleAction( i18n(
"Align Right"),
"format-text-direction-rtl",
537 TQObject::connect( actions->alignRight, TQ_SIGNAL( toggled(
bool ) ),
538 view, TQ_SLOT( alignRight(
bool ) ) );
539 actions->alignRight->setExclusiveGroup(
"Align" );
540 actions->alignRight->setToolTip(i18n(
"Right justify the cell contents."));
542 actions->alignTop =
new TDEToggleAction( i18n(
"Align Top"),
"text_top",
544 TQObject::connect( actions->alignTop, TQ_SIGNAL( toggled(
bool ) ),
545 view, TQ_SLOT( alignTop(
bool ) ) );
546 actions->alignTop->setExclusiveGroup(
"Pos" );
547 actions->alignTop->setToolTip(i18n(
"Align cell contents along the top of the cell."));
549 actions->alignMiddle =
new TDEToggleAction( i18n(
"Align Middle"),
"middle",
551 TQObject::connect( actions->alignMiddle, TQ_SIGNAL( toggled(
bool ) ),
552 view, TQ_SLOT( alignMiddle(
bool ) ) );
553 actions->alignMiddle->setExclusiveGroup(
"Pos" );
554 actions->alignMiddle->setToolTip(i18n(
"Align cell contents centered in the cell."));
556 actions->alignBottom =
new TDEToggleAction( i18n(
"Align Bottom"),
"text_bottom",
558 TQObject::connect( actions->alignBottom, TQ_SIGNAL( toggled(
bool ) ),
559 view, TQ_SLOT( alignBottom(
bool ) ) );
560 actions->alignBottom->setExclusiveGroup(
"Pos" );
561 actions->alignBottom->setToolTip(i18n(
"Align cell contents along the bottom of the cell."));
563 actions->wrapText =
new TDEToggleAction( i18n(
"Wrap Text"),
"multirow",
565 TQObject::connect( actions->wrapText, TQ_SIGNAL( toggled(
bool ) ),
566 view, TQ_SLOT( wrapText(
bool ) ) );
567 actions->wrapText->setToolTip(i18n(
"Make the cell text wrap onto multiple lines."));
569 actions->verticalText =
new TDEToggleAction( i18n(
"Vertical Text"),
"vertical_text" ,
570 0 ,ac,
"verticaltext" );
571 TQObject::connect( actions->verticalText, TQ_SIGNAL( toggled(
bool ) ),
572 view, TQ_SLOT( verticalText(
bool ) ) );
573 actions->verticalText->setToolTip(i18n(
"Print cell contents vertically."));
575 actions->increaseIndent =
new TDEAction( i18n(
"Increase Indent"),
576 TQApplication::reverseLayout() ?
"format_decreaseindent":
"format_increaseindent",
577 0, view, TQ_SLOT( increaseIndent() ), ac,
"increaseindent" );
578 actions->increaseIndent->setToolTip(i18n(
"Increase the indentation."));
580 actions->decreaseIndent =
new TDEAction( i18n(
"Decrease Indent"),
581 TQApplication::reverseLayout() ?
"format_increaseindent" :
"format_decreaseindent",
582 0, view, TQ_SLOT( decreaseIndent() ), ac,
"decreaseindent");
583 actions->decreaseIndent->setToolTip(i18n(
"Decrease the indentation."));
585 actions->changeAngle =
new TDEAction( i18n(
"Change Angle..."),
586 0, view, TQ_SLOT( changeAngle() ), ac,
"changeangle" );
587 actions->changeAngle->setToolTip(i18n(
"Change the angle that cell contents are printed."));
589 actions->percent =
new TDEToggleAction( i18n(
"Percent Format"),
"percent",
591 TQObject::connect( actions->percent, TQ_SIGNAL( toggled(
bool ) ),
592 view, TQ_SLOT( percent(
bool ) ) );
593 actions->percent->setToolTip(i18n(
"Set the cell formatting to look like a percentage."));
595 actions->precplus =
new TDEAction( i18n(
"Increase Precision"),
"prec_plus",
596 0, view, TQ_SLOT( precisionPlus() ), ac,
"precplus");
597 actions->precplus->setToolTip(i18n(
"Increase the decimal precision shown onscreen."));
599 actions->precminus =
new TDEAction( i18n(
"Decrease Precision"),
"prec_minus",
600 0, view, TQ_SLOT( precisionMinus() ), ac,
"precminus");
601 actions->precminus->setToolTip(i18n(
"Decrease the decimal precision shown onscreen."));
603 actions->money =
new TDEToggleAction( i18n(
"Money Format"),
"money",
605 TQObject::connect( actions->money, TQ_SIGNAL( toggled(
bool ) ),
606 view, TQ_SLOT( moneyFormat(
bool ) ) );
607 actions->money->setToolTip(i18n(
"Set the cell formatting to look like your local currency."));
609 actions->upper =
new TDEAction( i18n(
"Upper Case"),
"fontsizeup",
610 0, view, TQ_SLOT( upper() ), ac,
"upper" );
611 actions->upper->setToolTip(i18n(
"Convert all letters to upper case."));
613 actions->lower =
new TDEAction( i18n(
"Lower Case"),
"fontsizedown",
614 0, view, TQ_SLOT( lower() ), ac,
"lower" );
615 actions->lower->setToolTip(i18n(
"Convert all letters to lower case."));
617 actions->firstLetterUpper =
new TDEAction( i18n(
"Convert First Letter to Upper Case"),
"first_letter_upper",
618 0, view, TQ_SLOT( firstLetterUpper() ),ac,
"firstletterupper" );
619 actions->firstLetterUpper->setToolTip(i18n(
"Capitalize the first letter."));
621 actions->bgColor =
new TTDESelectColorAction( i18n(
"Background Color"),
622 TTDESelectColorAction::FillColor, ac,
"backgroundColor",
true );
623 TQObject::connect(actions->bgColor, TQ_SIGNAL( activated() ),
624 view, TQ_SLOT( changeBackgroundColor() ) );
625 actions->bgColor->setDefaultColor(TQColor());
626 actions->bgColor->setToolTip(i18n(
"Set the background color."));
628 actions->borderLeft =
new TDEAction( i18n(
"Border Left"),
"border_left",
629 0, view, TQ_SLOT( borderLeft() ), ac,
"borderLeft" );
630 actions->borderLeft->setToolTip(i18n(
"Set a left border to the selected area."));
632 actions->borderRight =
new TDEAction( i18n(
"Border Right"),
"border_right",
633 0, view, TQ_SLOT( borderRight() ), ac,
"borderRight" );
634 actions->borderRight->setToolTip(i18n(
"Set a right border to the selected area."));
636 actions->borderTop =
new TDEAction( i18n(
"Border Top"),
"border_top",
637 0, view, TQ_SLOT( borderTop() ), ac,
"borderTop" );
638 actions->borderTop->setToolTip(i18n(
"Set a top border to the selected area."));
640 actions->borderBottom =
new TDEAction( i18n(
"Border Bottom"),
"border_bottom",
641 0, view, TQ_SLOT( borderBottom() ), ac,
"borderBottom" );
642 actions->borderBottom->setToolTip(i18n(
"Set a bottom border to the selected area."));
644 actions->borderAll =
new TDEAction( i18n(
"All Borders"),
"border_all",
645 0, view, TQ_SLOT( borderAll() ), ac,
"borderAll" );
646 actions->borderAll->setToolTip(i18n(
"Set a border around all cells in the selected area."));
648 actions->borderRemove =
new TDEAction( i18n(
"Remove Borders"),
"border_remove",
649 0, view, TQ_SLOT( borderRemove() ), ac,
"borderRemove" );
650 actions->borderRemove->setToolTip(i18n(
"Remove all borders in the selected area."));
652 actions->borderOutline =
new TDEAction( i18n(
"Border Outline"), (
"border_outline"),
653 0, view, TQ_SLOT( borderOutline() ), ac,
"borderOutline" );
654 actions->borderOutline->setToolTip(i18n(
"Set a border to the outline of the selected area."));
656 actions->borderColor =
new TTDESelectColorAction( i18n(
"Border Color"),
657 TTDESelectColorAction::LineColor, ac,
"borderColor" );
658 TQObject::connect( actions->borderColor, TQ_SIGNAL( activated() ),
659 view, TQ_SLOT( changeBorderColor() ) );
660 actions->borderColor->setToolTip( i18n(
"Select a new border color." ) );
662 actions->selectStyle =
new TDESelectAction( i18n(
"St&yle" ),
663 0, ac,
"stylemenu" );
664 actions->selectStyle->setToolTip( i18n(
"Apply a predefined style to the selected cells." ) );
665 TQObject::connect( actions->selectStyle, TQ_SIGNAL( activated(
const TQString & ) ),
666 view, TQ_SLOT( styleSelected(
const TQString & ) ) );
668 actions->createStyle =
new TDEAction( i18n(
"Create Style From Cell..." ),
669 0, view, TQ_SLOT( createStyleFromCell()), ac,
"createStyle" );
670 actions->createStyle->setToolTip( i18n(
"Create a new style based on the currently selected cell." ) );
674 actions->editCell =
new TDEAction( i18n(
"Modify Cell"),
"cell_edit",
675 TQt::CTRL+TQt::Key_M, view, TQ_SLOT( editCell() ), ac,
"editCell" );
676 actions->editCell->setToolTip(i18n(
"Edit the highlighted cell."));
678 actions->insertCell =
new TDEAction( i18n(
"Insert Cells..."),
"insertcell",
679 0, view, TQ_SLOT( slotInsert() ), ac,
"insertCell" );
680 actions->insertCell->setToolTip(i18n(
"Insert a blank cell into the spreadsheet."));
682 actions->removeCell =
new TDEAction( i18n(
"Remove Cells..."),
"removecell",
683 0, view, TQ_SLOT( slotRemove() ), ac,
"removeCell" );
684 actions->removeCell->setToolTip(i18n(
"Removes the current cell from the spreadsheet."));
686 actions->deleteCell =
new TDEAction( i18n(
"Delete"),
"deletecell",
687 0, view, TQ_SLOT( deleteSelection() ), ac,
"delete" );
688 actions->deleteCell->setToolTip(i18n(
"Delete all contents and formatting of the current cell."));
690 actions->mergeCell =
new TDEToolBarPopupAction( i18n(
"Merge Cells"),
"mergecell",
691 0, view, TQ_SLOT( mergeCell() ), ac,
"mergecell" );
692 actions->mergeCell->setToolTip(i18n(
"Merge the selected region."));
693 actions->mergeCell->plug( actions->mergeCell->popupMenu() );
695 actions->mergeCellHorizontal =
new TDEAction( i18n(
"Merge Cells Horizontally"),
"mergecell-horizontal",
696 0, view, TQ_SLOT( mergeCellHorizontal() ), ac,
"mergecellHorizontal" );
697 actions->mergeCellHorizontal->setToolTip(i18n(
"Merge the selected region horizontally."));
698 actions->mergeCellHorizontal->plug( actions->mergeCell->popupMenu() );
700 actions->mergeCellVertical =
new TDEAction( i18n(
"Merge Cells Vertically"),
"mergecell-vertical",
701 0, view, TQ_SLOT( mergeCellVertical() ), ac,
"mergecellVertical" );
702 actions->mergeCellVertical->setToolTip(i18n(
"Merge the selected region vertically."));
703 actions->mergeCellVertical->plug( actions->mergeCell->popupMenu() );
705 actions->dissociateCell =
new TDEAction( i18n(
"Dissociate Cells"),
"dissociatecell",
706 0, view, TQ_SLOT( dissociateCell() ), ac,
"dissociatecell" );
707 actions->dissociateCell->setToolTip(i18n(
"Unmerge the selected region."));
709 actions->clearText =
new TDEAction( i18n(
"Text"),
710 0, view, TQ_SLOT( clearTextSelection() ), ac,
"cleartext" );
711 actions->clearText->setToolTip(i18n(
"Remove the contents of the current cell."));
713 actions->conditional =
new TDEAction( i18n(
"Conditional Cell Attributes..."),
714 0, view, TQ_SLOT( conditional() ), ac,
"conditional" );
715 actions->conditional->setToolTip(i18n(
"Set cell format based on certain conditions."));
718 actions->clearConditional =
new TDEAction( i18n(
"Conditional Cell Attributes"),
719 0, view, TQ_SLOT( clearConditionalSelection() ), ac,
"clearconditional" );
720 actions->clearConditional->setToolTip(i18n(
"Remove the conditional cell formatting."));
722 actions->validity =
new TDEAction( i18n(
"Validity..."),
723 0, view, TQ_SLOT( validity() ), ac,
"validity" );
724 actions->validity->setToolTip(i18n(
"Set tests to confirm cell data is valid."));
726 actions->clearValidity =
new TDEAction( i18n(
"Validity"),
727 0, view, TQ_SLOT( clearValiditySelection() ), ac,
"clearvalidity" );
728 actions->clearValidity->setToolTip(i18n(
"Remove the validity tests on this cell."));
730 actions->addModifyComment =
new TDEAction( i18n(
"&Add/Modify Comment..."),
"comment",
731 0, view, TQ_SLOT( addModifyComment() ), ac,
"addmodifycomment" );
732 actions->addModifyComment->setToolTip(i18n(
"Edit a comment for this cell."));
734 actions->removeComment =
new TDEAction( i18n(
"&Remove Comment"),
"removecomment",
735 0, view, TQ_SLOT( removeComment() ), ac,
"removecomment" );
736 actions->removeComment->setToolTip(i18n(
"Remove this cell's comment."));
738 actions->clearComment =
new TDEAction( i18n(
"Comment"),
739 0, view, TQ_SLOT( clearCommentSelection() ), ac,
"clearcomment" );
740 actions->clearComment->setToolTip(i18n(
"Remove this cell's comment."));
744 actions->resizeColumn =
new TDEAction( i18n(
"Resize Column..."),
"resizecol",
745 0, view, TQ_SLOT( resizeColumn() ), ac,
"resizeCol" );
746 actions->resizeColumn->setToolTip(i18n(
"Change the width of a column."));
748 actions->insertColumn =
new TDEAction( i18n(
"Insert Columns"),
"insert_table_col",
749 0, view, TQ_SLOT( insertColumn() ), ac,
"insertColumn" );
750 actions->insertColumn->setToolTip(i18n(
"Inserts a new column into the spreadsheet."));
752 actions->deleteColumn =
new TDEAction( i18n(
"Delete Columns"),
"delete_table_col",
753 0, view, TQ_SLOT( deleteColumn() ), ac,
"deleteColumn" );
754 actions->deleteColumn->setToolTip(i18n(
"Removes a column from the spreadsheet."));
756 actions->hideColumn =
new TDEAction( i18n(
"Hide Columns"),
"hide_table_column",
757 0, view, TQ_SLOT( hideColumn() ), ac,
"hideColumn" );
758 actions->hideColumn->setToolTip(i18n(
"Hide the column from view."));
760 actions->showColumn =
new TDEAction( i18n(
"Show Columns..."),
"show_table_column",
761 0, view, TQ_SLOT( showColumn() ), ac,
"showColumn" );
762 actions->showColumn->setToolTip(i18n(
"Show hidden columns."));
764 actions->equalizeColumn =
new TDEAction( i18n(
"Equalize Column"),
"adjustcol",
765 0, view, TQ_SLOT( equalizeColumn() ), ac,
"equalizeCol" );
766 actions->equalizeColumn->setToolTip(i18n(
"Resizes selected columns to be the same size."));
768 actions->showSelColumns =
new TDEAction( i18n(
"Show Columns"),
"show_sheet_column",
769 0, view, TQ_SLOT( showSelColumns() ), ac,
"showSelColumns" );
770 actions->showSelColumns->setToolTip(i18n(
"Show hidden columns in the selection."));
771 actions->showSelColumns->setEnabled(
false);
773 actions->resizeRow =
new TDEAction( i18n(
"Resize Row..."),
"resizerow",
774 0, view, TQ_SLOT( resizeRow() ), ac,
"resizeRow" );
775 actions->resizeRow->setToolTip(i18n(
"Change the height of a row."));
777 actions->insertRow =
new TDEAction( i18n(
"Insert Rows"),
"insert_table_row",
778 0, view, TQ_SLOT( insertRow() ), ac,
"insertRow" );
779 actions->insertRow->setToolTip(i18n(
"Inserts a new row into the spreadsheet."));
781 actions->deleteRow =
new TDEAction( i18n(
"Delete Rows"),
"delete_table_row",
782 0, view, TQ_SLOT( deleteRow() ), ac,
"deleteRow" );
783 actions->deleteRow->setToolTip(i18n(
"Removes a row from the spreadsheet."));
785 actions->hideRow =
new TDEAction( i18n(
"Hide Rows"),
"hide_table_row",
786 0, view, TQ_SLOT( hideRow() ), ac,
"hideRow" );
787 actions->hideRow->setToolTip(i18n(
"Hide a row from view."));
789 actions->showRow =
new TDEAction( i18n(
"Show Rows..."),
"show_table_row",
790 0, view, TQ_SLOT( showRow() ), ac,
"showRow" );
791 actions->showRow->setToolTip(i18n(
"Show hidden rows."));
793 actions->equalizeRow =
new TDEAction( i18n(
"Equalize Row"),
"adjustrow",
794 0, view, TQ_SLOT( equalizeRow() ), ac,
"equalizeRow" );
795 actions->equalizeRow->setToolTip(i18n(
"Resizes selected rows to be the same size."));
797 actions->showSelRows =
new TDEAction( i18n(
"Show Rows"),
"show_table_row",
798 0, view, TQ_SLOT( showSelRows() ), ac,
"showSelRows" );
799 actions->showSelRows->setEnabled(
false);
800 actions->showSelRows->setToolTip(i18n(
"Show hidden rows in the selection."));
802 actions->adjust =
new TDEAction( i18n(
"Adjust Row && Column"),
803 0, view, TQ_SLOT( adjust() ), ac,
"adjust" );
804 actions->adjust->setToolTip(i18n(
"Adjusts row/column size so that the contents will fit."));
807 actions->sheetProperties =
new TDEAction( i18n(
"Sheet Properties"),
808 0, view, TQ_SLOT( sheetProperties() ), ac,
"sheetProperties" );
809 actions->sheetProperties->setToolTip(i18n(
"Modify current sheet's properties."));
811 actions->insertSheet =
new TDEAction( i18n(
"Insert Sheet"),
"inserttable",
812 0, view, TQ_SLOT( insertSheet() ), ac,
"insertSheet" );
813 actions->insertSheet->setToolTip(i18n(
"Insert a new sheet."));
816 actions->menuInsertSheet =
new TDEAction( i18n(
"&Sheet"),
"inserttable",
817 0, view, TQ_SLOT( insertSheet() ), ac,
"menuInsertSheet" );
818 actions->menuInsertSheet->setToolTip(i18n(
"Insert a new sheet."));
820 actions->removeSheet =
new TDEAction( i18n(
"Remove Sheet"),
"delete_table",
821 0, view, TQ_SLOT( removeSheet() ), ac,
"removeSheet" );
822 actions->removeSheet->setToolTip(i18n(
"Remove the active sheet."));
824 actions->renameSheet=
new TDEAction( i18n(
"Rename Sheet..."),
825 0, view, TQ_SLOT( slotRename() ), ac,
"renameSheet" );
826 actions->renameSheet->setToolTip(i18n(
"Rename the active sheet."));
828 actions->showSheet =
new TDEAction(i18n(
"Show Sheet..."),
829 0, view, TQ_SLOT( showSheet()), ac,
"showSheet" );
830 actions->showSheet->setToolTip(i18n(
"Show a hidden sheet."));
832 actions->hideSheet =
new TDEAction(i18n(
"Hide Sheet"),
833 0, view, TQ_SLOT( hideSheet() ), ac,
"hideSheet" );
834 actions->hideSheet->setToolTip(i18n(
"Hide the active sheet."));
836 actions->autoFormat =
new TDEAction( i18n(
"AutoFormat..."),
837 0, view, TQ_SLOT( sheetFormat() ), ac,
"sheetFormat" );
838 actions->autoFormat->setToolTip(i18n(
"Set the worksheet formatting."));
840 actions->areaName =
new TDEAction( i18n(
"Area Name..."),
841 0, view, TQ_SLOT( setAreaName() ), ac,
"areaname" );
842 actions->areaName->setToolTip(i18n(
"Set a name for a region of the spreadsheet."));
844 actions->showArea =
new TDEAction( i18n(
"Show Area..."),
845 0, view, TQ_SLOT( showAreaName() ), ac,
"showArea" );
846 actions->showArea->setToolTip(i18n(
"Display a named area."));
848 actions->insertFunction =
new TDEAction( i18n(
"&Function..."),
"funct",
849 0, view, TQ_SLOT( insertMathExpr() ), ac,
"insertMathExpr" );
850 actions->insertFunction->setToolTip(i18n(
"Insert math expression."));
852 actions->insertSeries =
new TDEAction( i18n(
"&Series..."),
"series",
853 0, view, TQ_SLOT( insertSeries() ), ac,
"series");
854 actions->insertSeries ->setToolTip(i18n(
"Insert a series."));
856 actions->insertLink =
new TDEAction( i18n(
"&Link..."),
"insert_link",
857 0, view, TQ_SLOT( insertHyperlink() ), ac,
"insertHyperlink" );
858 actions->insertLink->setToolTip(i18n(
"Insert an Internet hyperlink."));
860 actions->removeLink =
new TDEAction( i18n(
"&Remove Link"),
861 0, view, TQ_SLOT( removeHyperlink() ), ac,
"removeHyperlink" );
862 actions->removeLink->setToolTip(i18n(
"Remove a link."));
864 actions->insertSpecialChar =
new TDEAction( i18n(
"S&pecial Character..." ),
"char",
865 view, TQ_SLOT( insertSpecialChar() ), ac,
"insertSpecialChar" );
866 actions->insertSpecialChar->setToolTip( i18n(
"Insert one or more symbols or letters not found on the keyboard." ) );
868 actions->insertPart =
new KoPartSelectAction( i18n(
"&Object"),
"frame_query",
869 view, TQ_SLOT( insertObject() ), ac,
"insertPart");
870 actions->insertPart->setToolTip(i18n(
"Insert an object from another program."));
872 actions->insertChartFrame =
new TDEToggleAction( i18n(
"&Chart"),
"insert_chart",
873 0, view, TQ_SLOT( insertChart() ), ac,
"insertChart" );
874 actions->insertChartFrame->setToolTip(i18n(
"Insert a chart."));
876 actions->insertPicture =
new TDEAction( i18n(
"&Picture"),
877 0, view, TQ_SLOT( insertPicture() ), ac,
"insertPicture" );
878 actions->insertPicture->setToolTip(i18n(
"Insert a picture."));
881 actions->insertFromDatabase =
new TDEAction( i18n(
"From &Database..."),
882 0, view, TQ_SLOT( insertFromDatabase() ), ac,
"insertFromDatabase");
883 actions->insertFromDatabase->setToolTip(i18n(
"Insert data from a SQL database."));
886 actions->insertFromTextfile =
new TDEAction( i18n(
"From &Text File..."),
887 0, view, TQ_SLOT( insertFromTextfile() ), ac,
"insertFromTextfile");
888 actions->insertFromTextfile->setToolTip(i18n(
"Insert data from a text file to the current cursor position/selection."));
890 actions->insertFromClipboard =
new TDEAction( i18n(
"From &Clipboard..."),
891 0, view, TQ_SLOT( insertFromClipboard() ), ac,
"insertFromClipboard");
892 actions->insertFromClipboard->setToolTip(i18n(
"Insert CSV data from the clipboard to the current cursor position/selection."));
899 actions->sort =
new TDEAction( i18n(
"&Sort..."),
900 0, view, TQ_SLOT( sort() ), ac,
"sort" );
901 actions->sort->setToolTip(i18n(
"Sort a group of cells."));
903 actions->sortDec =
new TDEAction( i18n(
"Sort &Decreasing"),
"sort_decrease",
904 0, view, TQ_SLOT( sortDec() ), ac,
"sortDec" );
905 actions->sortDec->setToolTip(i18n(
"Sort a group of cells in decreasing (last to first) order."));
907 actions->sortInc =
new TDEAction( i18n(
"Sort &Increasing"),
"sort_incr",
908 0, view, TQ_SLOT( sortInc() ), ac,
"sortInc" );
909 actions->sortInc->setToolTip(i18n(
"Sort a group of cells in ascending (first to last) order."));
911 actions->paperLayout =
new TDEAction( i18n(
"Page Layout..."),
912 0, view, TQ_SLOT( paperLayoutDlg() ), ac,
"paperLayout" );
913 actions->paperLayout->setToolTip(i18n(
"Specify the layout of the spreadsheet for a printout."));
915 actions->definePrintRange =
new TDEAction( i18n(
"Define Print Range"),
916 0, view, TQ_SLOT( definePrintRange() ), ac,
"definePrintRange" );
917 actions->definePrintRange->setToolTip(i18n(
"Define the print range in the current sheet."));
919 actions->resetPrintRange =
new TDEAction( i18n(
"Reset Print Range"),
920 0, view, TQ_SLOT( resetPrintRange() ), ac,
"resetPrintRange" );
921 actions->definePrintRange->setToolTip(i18n(
"Define the print range in the current sheet."));
923 actions->showPageBorders =
new TDEToggleAction( i18n(
"Show Page Borders"),
924 0, ac,
"showPageBorders");
925 actions->showPageBorders->setCheckedState(i18n(
"Hide Page Borders"));
926 TQObject::connect( actions->showPageBorders, TQ_SIGNAL( toggled(
bool ) ),
927 view, TQ_SLOT( togglePageBorders(
bool ) ) );
928 actions->showPageBorders->setToolTip( i18n(
"Show on the spreadsheet where the page borders will be." ) );
930 actions->recalcWorksheet =
new TDEAction( i18n(
"Recalculate Sheet"),
931 TQt::SHIFT + TQt::Key_F9, view, TQ_SLOT( recalcWorkSheet() ), ac,
"RecalcWorkSheet" );
932 actions->recalcWorksheet->setToolTip(i18n(
"Recalculate the value of every cell in the current worksheet."));
934 actions->recalcWorkbook =
new TDEAction( i18n(
"Recalculate Document"),
935 TQt::Key_F9, view, TQ_SLOT( recalcWorkBook() ), ac,
"RecalcWorkBook" );
936 actions->recalcWorkbook->setToolTip(i18n(
"Recalculate the value of every cell in all worksheets."));
938 actions->protectSheet =
new TDEToggleAction( i18n(
"Protect &Sheet..." ),
939 0, ac,
"protectSheet" );
940 actions->protectSheet->setToolTip( i18n(
"Protect the sheet from being modified." ) );
941 TQObject::connect( actions->protectSheet, TQ_SIGNAL( toggled(
bool ) ),
942 view, TQ_SLOT( toggleProtectSheet(
bool ) ) );
944 actions->protectDoc =
new TDEToggleAction( i18n(
"Protect &Document..." ),
945 0, ac,
"protectDoc" );
946 actions->protectDoc->setToolTip( i18n(
"Protect the document from being modified." ) );
947 TQObject::connect( actions->protectDoc, TQ_SIGNAL( toggled(
bool ) ),
948 view, TQ_SLOT( toggleProtectDoc(
bool ) ) );
952 actions->copy = KStdAction::copy( view, TQ_SLOT( copySelection() ), ac,
"copy" );
953 actions->copy->setToolTip(i18n(
"Copy the cell object to the clipboard."));
955 actions->paste = KStdAction::paste( view, TQ_SLOT( paste() ), ac,
"paste" );
956 actions->paste->setToolTip(i18n(
"Paste the contents of the clipboard at the cursor."));
958 actions->cut = KStdAction::cut( view, TQ_SLOT( cutSelection() ), ac,
"cut" );
959 actions->cut->setToolTip(i18n(
"Move the cell object to the clipboard."));
961 actions->specialPaste =
new TDEAction( i18n(
"Special Paste..."),
"special_paste",
962 0, view, TQ_SLOT( specialPaste() ), ac,
"specialPaste" );
963 actions->specialPaste->setToolTip(i18n(
"Paste the contents of the clipboard with special options."));
965 actions->insertCellCopy =
new TDEAction( i18n(
"Paste with Insertion"),
"insertcellcopy",
966 0, view, TQ_SLOT( slotInsertCellCopy() ), ac,
"insertCellCopy" );
967 actions->insertCellCopy->setToolTip(i18n(
"Inserts a cell from the clipboard into the spreadsheet."));
969 actions->find = KStdAction::find( view, TQ_SLOT(find()), ac );
970 KStdAction::findNext( view, TQ_SLOT( findNext() ), ac );
971 KStdAction::findPrev( view, TQ_SLOT( findPrevious() ), ac );
973 actions->replace = KStdAction::replace( view, TQ_SLOT(replace()), ac );
975 actions->fillRight =
new TDEAction( i18n(
"&Right" ), 0,
976 0, view, TQ_SLOT( fillRight() ), ac,
"fillRight" );
978 actions->fillLeft =
new TDEAction( i18n(
"&Left" ), 0,
979 0, view, TQ_SLOT( fillLeft() ), ac,
"fillLeft" );
981 actions->fillDown =
new TDEAction( i18n(
"&Down" ), 0,
982 0, view, TQ_SLOT( fillDown() ), ac,
"fillDown" );
984 actions->fillUp =
new TDEAction( i18n(
"&Up" ), 0,
985 0, view, TQ_SLOT( fillUp() ), ac,
"fillUp" );
989 actions->styleDialog =
new TDEAction( i18n(
"Style Manager" ),
990 0, view, TQ_SLOT( styleDialog() ), ac,
"styles" );
991 actions->styleDialog->setToolTip( i18n(
"Edit and organize cell styles." ) );
993 actions->autoSum =
new TDEAction( i18n(
"Autosum"),
"black_sum",
994 0, view, TQ_SLOT( autoSum() ), ac,
"autoSum" );
995 actions->autoSum->setToolTip(i18n(
"Insert the 'sum' function"));
997 actions->spellChecking = KStdAction::spelling( view, TQ_SLOT( extraSpelling() ),
999 actions->spellChecking->setToolTip(i18n(
"Check the spelling."));
1001 actions->formulaSelection =
new TDESelectAction(i18n(
"Formula Selection"),
1002 0, ac,
"formulaSelection");
1003 actions->formulaSelection->setToolTip(i18n(
"Insert a function."));
1006 lst.append(
"AVERAGE");
1008 lst.append(
"COUNT");
1011 lst.append( i18n(
"Others...") );
1012 ((TDESelectAction*) actions->formulaSelection)->setItems( lst );
1013 actions->formulaSelection->setComboWidth( 80 );
1014 actions->formulaSelection->setCurrentItem(0);
1015 TQObject::connect( actions->formulaSelection, TQ_SIGNAL( activated(
const TQString& ) ),
1016 view, TQ_SLOT( formulaSelection(
const TQString& ) ) );
1018 actions->viewZoom =
new KoZoomAction( i18n(
"Zoom" ),
"viewmag", 0, ac,
"view_zoom" );
1019 TQObject::connect( actions->viewZoom, TQ_SIGNAL( zoomChanged(
const TQString & ) ),
1020 view, TQ_SLOT( viewZoom(
const TQString & ) ) );
1022 actions->consolidate =
new TDEAction( i18n(
"&Consolidate..."),
1023 0, view, TQ_SLOT( consolidate() ), ac,
"consolidate" );
1024 actions->consolidate->setToolTip(i18n(
"Create a region of summary data from a group of similar regions."));
1026 actions->goalSeek =
new TDEAction( i18n(
"&Goal Seek..."),
1027 0, view, TQ_SLOT( goalSeek() ), ac,
"goalSeek" );
1028 actions->goalSeek->setToolTip( i18n(
"Repeating calculation to find a specific value.") );
1030 actions->subTotals =
new TDEAction( i18n(
"&Subtotals..."),
1031 0, view, TQ_SLOT( subtotals() ), ac,
"subtotals" );
1032 actions->subTotals->setToolTip( i18n(
"Create different kind of subtotals to a list or database.") );
1034 actions->textToColumns =
new TDEAction( i18n(
"&Text to Columns..."),
1035 0, view, TQ_SLOT( textToColumns() ), ac,
"textToColumns" );
1036 actions->textToColumns->setToolTip( i18n(
"Expand the content of cells to multiple columns.") );
1038 actions->multipleOperations =
new TDEAction( i18n(
"&Multiple Operations..."),
1039 0, view, TQ_SLOT( multipleOperations() ), ac,
"multipleOperations" );
1040 actions->multipleOperations->setToolTip( i18n(
"Apply the same formula to various cells using different values for the parameter.") );
1042 actions->createTemplate =
new TDEAction( i18n(
"&Create Template From Document..." ),
1043 0, view, TQ_SLOT( createTemplate() ), ac,
"createTemplate" );
1045 actions->customList =
new TDEAction( i18n(
"Custom Lists..."),
1046 0, view, TQ_SLOT( sortList() ), ac,
"sortlist" );
1047 actions->customList->setToolTip(i18n(
"Create custom lists for sorting or autofill."));
1051 actions->gotoCell =
new TDEAction( i18n(
"Goto Cell..."),
"goto",
1052 0, view, TQ_SLOT( gotoCell() ), ac,
"gotoCell" );
1053 actions->gotoCell->setToolTip(i18n(
"Move to a particular cell."));
1055 actions->nextSheet =
new TDEAction( i18n(
"Next Sheet"),
"forward",
1056 TQt::CTRL+TQt::Key_PageDown, view, TQ_SLOT( nextSheet() ), ac,
"nextSheet");
1057 actions->nextSheet->setToolTip(i18n(
"Move to the next sheet."));
1059 actions->prevSheet =
new TDEAction( i18n(
"Previous Sheet"),
"back",
1060 TQt::CTRL+TQt::Key_PageUp, view, TQ_SLOT( previousSheet() ), ac,
"previousSheet");
1061 actions->prevSheet->setToolTip(i18n(
"Move to the previous sheet."));
1063 actions->firstSheet =
new TDEAction( i18n(
"First Sheet"),
"go-first",
1064 0, view, TQ_SLOT( firstSheet() ), ac,
"firstSheet");
1065 actions->firstSheet->setToolTip(i18n(
"Move to the first sheet."));
1067 actions->lastSheet =
new TDEAction( i18n(
"Last Sheet"),
"go-last",
1068 0, view, TQ_SLOT( lastSheet() ), ac,
"lastSheet");
1069 actions->lastSheet->setToolTip(i18n(
"Move to the last sheet."));
1073 actions->showStatusBar =
new TDEToggleAction( i18n(
"Show Status Bar"),
1074 0, ac,
"showStatusBar" );
1075 actions->showStatusBar->setCheckedState(i18n(
"Hide Status Bar"));
1076 TQObject::connect( actions->showStatusBar, TQ_SIGNAL( toggled(
bool ) ),
1077 view, TQ_SLOT( showStatusBar(
bool ) ) );
1078 actions->showStatusBar->setToolTip(i18n(
"Show the status bar."));
1080 actions->showTabBar =
new TDEToggleAction( i18n(
"Show Tab Bar"),
1081 0, ac,
"showTabBar" );
1082 actions->showTabBar->setCheckedState(i18n(
"Hide Tab Bar"));
1083 TQObject::connect( actions->showTabBar, TQ_SIGNAL( toggled(
bool ) ),
1084 view, TQ_SLOT( showTabBar(
bool ) ) );
1085 actions->showTabBar->setToolTip(i18n(
"Show the tab bar."));
1087 actions->showFormulaBar =
new TDEToggleAction( i18n(
"Show Formula Bar"),
1088 0, ac,
"showFormulaBar" );
1089 actions->showFormulaBar->setCheckedState(i18n(
"Hide Formula Bar"));
1090 TQObject::connect( actions->showFormulaBar, TQ_SIGNAL( toggled(
bool ) ),
1091 view, TQ_SLOT( showFormulaBar(
bool ) ) );
1092 actions->showFormulaBar->setToolTip(i18n(
"Show the formula bar."));
1094 actions->preference =
new TDEAction( i18n(
"Configure KSpread..."),
"configure",
1095 0, view, TQ_SLOT( preference() ), ac,
"preference" );
1096 actions->preference->setToolTip(i18n(
"Set various KSpread options."));
1100 actions->calcNone =
new TDEToggleAction( i18n(
"None"), 0, ac,
"menu_none");
1101 TQObject::connect( actions->calcNone, TQ_SIGNAL( toggled(
bool ) ),
1102 view, TQ_SLOT( menuCalc(
bool ) ) );
1103 actions->calcNone->setExclusiveGroup(
"Calc" );
1104 actions->calcNone->setToolTip(i18n(
"No calculation"));
1106 actions->calcSum =
new TDEToggleAction( i18n(
"Sum"), 0, ac,
"menu_sum");
1107 TQObject::connect( actions->calcSum, TQ_SIGNAL( toggled(
bool ) ),
1108 view, TQ_SLOT( menuCalc(
bool ) ) );
1109 actions->calcSum->setExclusiveGroup(
"Calc" );
1110 actions->calcSum->setToolTip(i18n(
"Calculate using sum."));
1112 actions->calcMin =
new TDEToggleAction( i18n(
"Min"), 0, ac,
"menu_min");
1113 TQObject::connect( actions->calcMin, TQ_SIGNAL( toggled(
bool ) ),
1114 view, TQ_SLOT( menuCalc(
bool ) ) );
1115 actions->calcMin->setExclusiveGroup(
"Calc" );
1116 actions->calcMin->setToolTip(i18n(
"Calculate using minimum."));
1118 actions->calcMax =
new TDEToggleAction( i18n(
"Max"), 0, ac,
"menu_max");
1119 TQObject::connect( actions->calcMax, TQ_SIGNAL( toggled(
bool ) ),
1120 view, TQ_SLOT( menuCalc(
bool ) ) );
1121 actions->calcMax->setExclusiveGroup(
"Calc" );
1122 actions->calcMax->setToolTip(i18n(
"Calculate using maximum."));
1124 actions->calcAverage =
new TDEToggleAction( i18n(
"Average"), 0, ac,
"menu_average");
1125 TQObject::connect( actions->calcAverage, TQ_SIGNAL( toggled(
bool ) ),
1126 view, TQ_SLOT( menuCalc(
bool ) ) );
1127 actions->calcAverage->setExclusiveGroup(
"Calc" );
1128 actions->calcAverage->setToolTip(i18n(
"Calculate using average."));
1130 actions->calcCount =
new TDEToggleAction( i18n(
"Count"), 0, ac,
"menu_count");
1131 TQObject::connect( actions->calcCount, TQ_SIGNAL( toggled(
bool ) ),
1132 view, TQ_SLOT( menuCalc(
bool ) ) );
1133 actions->calcCount->setExclusiveGroup(
"Calc" );
1134 actions->calcCount->setToolTip(i18n(
"Calculate using the count."));
1136 actions->calcCountA =
new TDEToggleAction( i18n(
"CountA"), 0, ac,
"menu_counta");
1137 TQObject::connect( actions->calcCountA, TQ_SIGNAL( toggled(
bool ) ),
1138 view, TQ_SLOT( menuCalc(
bool ) ) );
1139 actions->calcCountA->setExclusiveGroup(
"Calc" );
1140 actions->calcCountA->setToolTip(i18n(
"Calculate using the countA."));
1144 actions->internalTests =
new TDEAction( i18n(
"Run Internal Tests..."),
"internalTests",
1145 TQt::CTRL+ TQt::SHIFT + TQt::Key_T, view, TQ_SLOT( runInternalTests() ), ac,
"internalTests" );
1146 actions->inspector =
new TDEAction( i18n(
"Run Inspector..."),
"inspector",
1147 TQt::CTRL+ TQt::SHIFT + TQt::Key_I, view, TQ_SLOT( runInspector() ), ac,
"inspector" );
1149 m_propertyEditor = 0;
1152void View::Private::adjustActions(
bool mode )
1154 actions->replace->setEnabled( mode );
1155 actions->insertSeries->setEnabled( mode );
1156 actions->insertLink->setEnabled( mode );
1157 actions->insertSpecialChar->setEnabled( mode );
1158 actions->insertFunction->setEnabled( mode );
1159 actions->removeComment->setEnabled( mode );
1160 actions->decreaseIndent->setEnabled( mode );
1161 actions->bold->setEnabled( mode );
1162 actions->italic->setEnabled( mode );
1163 actions->underline->setEnabled( mode );
1164 actions->strikeOut->setEnabled( mode );
1165 actions->percent->setEnabled( mode );
1166 actions->precplus->setEnabled( mode );
1167 actions->precminus->setEnabled( mode );
1168 actions->money->setEnabled( mode );
1169 actions->alignLeft->setEnabled( mode );
1170 actions->alignCenter->setEnabled( mode );
1171 actions->alignRight->setEnabled( mode );
1172 actions->alignTop->setEnabled( mode );
1173 actions->alignMiddle->setEnabled( mode );
1174 actions->alignBottom->setEnabled( mode );
1175 actions->paste->setEnabled( mode );
1176 actions->cut->setEnabled( mode );
1177 actions->specialPaste->setEnabled( mode );
1178 actions->deleteCell->setEnabled( mode );
1179 actions->clearText->setEnabled( mode );
1180 actions->clearComment->setEnabled( mode );
1181 actions->clearValidity->setEnabled( mode );
1182 actions->clearConditional->setEnabled( mode );
1183 actions->recalcWorkbook->setEnabled( mode );
1184 actions->recalcWorksheet->setEnabled( mode );
1185 actions->adjust->setEnabled( mode );
1186 actions->editCell->setEnabled( mode );
1187 actions->paperLayout->setEnabled( mode );
1188 actions->styleDialog->setEnabled( mode );
1189 actions->definePrintRange->setEnabled( mode );
1190 actions->resetPrintRange->setEnabled( mode );
1191 actions->insertFromDatabase->setEnabled( mode );
1192 actions->insertFromTextfile->setEnabled( mode );
1193 actions->insertFromClipboard->setEnabled( mode );
1194 actions->conditional->setEnabled( mode );
1195 actions->validity->setEnabled( mode );
1196 actions->goalSeek->setEnabled( mode );
1197 actions->subTotals->setEnabled( mode );
1198 actions->multipleOperations->setEnabled( mode );
1199 actions->textToColumns->setEnabled( mode );
1200 actions->consolidate->setEnabled( mode );
1201 actions->insertCellCopy->setEnabled( mode );
1202 actions->wrapText->setEnabled( mode );
1203 actions->selectFont->setEnabled( mode );
1204 actions->selectFontSize->setEnabled( mode );
1205 actions->deleteColumn->setEnabled( mode );
1206 actions->hideColumn->setEnabled( mode );
1207 actions->showColumn->setEnabled( mode );
1208 actions->showSelColumns->setEnabled( mode );
1209 actions->insertColumn->setEnabled( mode );
1210 actions->deleteRow->setEnabled( mode );
1211 actions->insertRow->setEnabled( mode );
1212 actions->hideRow->setEnabled( mode );
1213 actions->showRow->setEnabled( mode );
1214 actions->showSelRows->setEnabled( mode );
1215 actions->formulaSelection->setEnabled( mode );
1216 actions->textColor->setEnabled( mode );
1217 actions->bgColor->setEnabled( mode );
1218 actions->cellLayout->setEnabled( mode );
1219 actions->borderLeft->setEnabled( mode );
1220 actions->borderRight->setEnabled( mode );
1221 actions->borderTop->setEnabled( mode );
1222 actions->borderBottom->setEnabled( mode );
1223 actions->borderAll->setEnabled( mode );
1224 actions->borderOutline->setEnabled( mode );
1225 actions->borderRemove->setEnabled( mode );
1226 actions->borderColor->setEnabled( mode );
1227 actions->removeSheet->setEnabled( mode );
1228 actions->autoSum->setEnabled( mode );
1229 actions->defaultFormat->setEnabled( mode );
1230 actions->areaName->setEnabled( mode );
1231 actions->resizeRow->setEnabled( mode );
1232 actions->resizeColumn->setEnabled( mode );
1233 actions->fontSizeUp->setEnabled( mode );
1234 actions->fontSizeDown->setEnabled( mode );
1235 actions->upper->setEnabled( mode );
1236 actions->lower->setEnabled( mode );
1237 actions->equalizeRow->setEnabled( mode );
1238 actions->equalizeColumn->setEnabled( mode );
1239 actions->verticalText->setEnabled( mode );
1240 actions->addModifyComment->setEnabled( mode );
1241 actions->removeComment->setEnabled( mode );
1242 actions->insertCell->setEnabled( mode );
1243 actions->removeCell->setEnabled( mode );
1244 actions->changeAngle->setEnabled( mode );
1245 actions->dissociateCell->setEnabled( mode );
1246 actions->increaseIndent->setEnabled( mode );
1247 actions->decreaseIndent->setEnabled( mode );
1248 actions->spellChecking->setEnabled( mode );
1249 actions->calcMin->setEnabled( mode );
1250 actions->calcMax->setEnabled( mode );
1251 actions->calcAverage->setEnabled( mode );
1252 actions->calcCount->setEnabled( mode );
1253 actions->calcCountA->setEnabled( mode );
1254 actions->calcSum->setEnabled( mode );
1255 actions->calcNone->setEnabled( mode );
1256 actions->insertPart->setEnabled( mode );
1257 actions->createStyle->setEnabled( mode );
1258 actions->selectStyle->setEnabled( mode );
1259 actions->insertChartFrame->setEnabled( mode );
1261 actions->autoFormat->setEnabled(
false );
1262 actions->sort->setEnabled(
false );
1263 actions->mergeCell->setEnabled(
false );
1264 actions->mergeCellHorizontal->setEnabled(
false );
1265 actions->mergeCellVertical->setEnabled(
false );
1266 actions->sortDec->setEnabled(
false );
1267 actions->sortInc->setEnabled(
false );
1270 actions->fillRight->setEnabled(
false );
1271 actions->fillLeft->setEnabled(
false );
1272 actions->fillUp->setEnabled(
false );
1273 actions->fillDown->setEnabled(
false );
1275 if ( mode && !view->doc()->map()->isProtected() )
1276 actions->renameSheet->setEnabled(
true );
1278 actions->renameSheet->setEnabled(
false );
1280 actions->showStatusBar->setChecked( view->doc()->showStatusBar() );
1281 actions->showTabBar->setChecked( view->doc()->showTabBar() );
1282 actions->showFormulaBar->setChecked( view->doc()->showFormulaBar() );
1284 formulaButton->setEnabled( mode );
1288 selection->update();
1289 view->objectSelectedChanged();
1293void View::Private::adjustActions( Sheet* sheet, Cell* cell )
1297 if ( selection->isSingular() )
1299 if ( !actions->bold->isEnabled() )
1300 adjustActions(
true );
1304 if ( actions->bold->isEnabled() )
1305 adjustActions(
false );
1308 else if ( sheet->isProtected() )
1310 if ( actions->bold->isEnabled() )
1311 adjustActions(
false );
1315void View::Private::adjustWorkbookActions(
bool mode )
1317 tabBar->setReadOnly( !view->doc()->isReadWrite() || view->doc()->map()->isProtected() );
1319 actions->hideSheet->setEnabled( mode );
1320 actions->showSheet->setEnabled( mode );
1321 actions->insertSheet->setEnabled( mode );
1322 actions->menuInsertSheet->setEnabled( mode );
1323 actions->removeSheet->setEnabled( mode );
1327 if ( activeSheet && !activeSheet->isProtected() )
1329 bool state = ( view->doc()->map()->visibleSheets().count() > 1 );
1330 actions->removeSheet->setEnabled( state );
1331 actions->hideSheet->setEnabled( state );
1333 actions->showSheet->setEnabled( view->doc()->map()->hiddenSheets().count() > 0 );
1334 actions->renameSheet->setEnabled( activeSheet && !activeSheet->isProtected() );
1339void View::Private::updateButton( Cell *cell,
int column,
int row)
1346 TQStringList fontList;
1347 TDEFontChooser::getFontList( fontList, 0 );
1348 TQString fontFamily = cell->
format()->textFontFamily( column,row );
1349 for ( TQStringList::Iterator it = fontList.begin(); it != fontList.end(); ++it )
1350 if ((*it).lower() == fontFamily.lower())
1352 actions->selectFont->setFont( fontFamily );
1356 actions->selectFontSize->setFontSize( cell->
format()->textFontSize( column, row ) );
1357 actions->bold->setChecked( cell->
format()->textFontBold( column, row ) );
1358 actions->italic->setChecked( cell->
format()->textFontItalic( column, row) );
1359 actions->underline->setChecked( cell->
format()->textFontUnderline( column, row ) );
1360 actions->strikeOut->setChecked( cell->
format()->textFontStrike( column, row ) );
1362 actions->alignLeft->setChecked( cell->
format()->align( column, row ) == Format::Left );
1363 actions->alignCenter->setChecked( cell->
format()->align( column, row ) == Format::Center );
1364 actions->alignRight->setChecked( cell->
format()->align( column, row ) == Format::Right );
1366 actions->alignTop->setChecked( cell->
format()->alignY( column, row ) == Format::Top );
1367 actions->alignMiddle->setChecked( cell->
format()->alignY( column, row ) == Format::Middle );
1368 actions->alignBottom->setChecked( cell->
format()->alignY( column, row ) == Format::Bottom );
1370 actions->verticalText->setChecked( cell->
format()->verticalText( column,row ) );
1372 actions->wrapText->setChecked( cell->
format()->multiRow( column,row ) );
1375 actions->percent->setChecked( ft == Percentage_format );
1376 actions->money->setChecked( ft == Money_format );
1378 if ( activeSheet && !activeSheet->isProtected() )
1379 actions->removeComment->setEnabled( !cell->
format()->comment(column,row).isEmpty() );
1381 if ( activeSheet && !activeSheet->isProtected() )
1382 actions->decreaseIndent->setEnabled( cell->
format()->getIndent( column, row ) > 0.0 );
1384 toolbarLock =
false;
1386 adjustActions( activeSheet, cell );
1389TQButton* View::Private::newIconButton(
const char *_file,
bool _kbutton, TQWidget *_parent )
1391 if ( _parent == 0L )
1395 TQPushButton* pb =
new TQPushButton( _parent );
1396 pb->setIconSet( SmallIconSet(_file) );
1399 TQToolButton* pb =
new TQToolButton( _parent );
1400 pb->setIconSet( SmallIconSet(_file) );
1405KPSheetSelectPage::KPSheetSelectPage( TQWidget *parent )
1406: KPrintDialogPage(parent),
1407 gui(new SheetSelectWidget(this))
1409 setTitle(gui->caption());
1412 gui->ListViewAvailable->setSorting(-1);
1413 gui->ListViewSelected->setSorting(-1);
1416 connect(gui->ButtonSelectAll,TQ_SIGNAL(clicked()),
this,TQ_SLOT(selectAll()));
1417 connect(gui->ButtonSelect,TQ_SIGNAL(clicked()),
this,TQ_SLOT(select()));
1418 connect(gui->ButtonRemove,TQ_SIGNAL(clicked()),
this,TQ_SLOT(remove()));
1419 connect(gui->ButtonRemoveAll,TQ_SIGNAL(clicked()),
this,TQ_SLOT(removeAll()));
1421 connect(gui->ButtonMoveTop,TQ_SIGNAL(clicked()),
this,TQ_SLOT(moveTop()));
1422 connect(gui->ButtonMoveUp,TQ_SIGNAL(clicked()),
this,TQ_SLOT(moveUp()));
1423 connect(gui->ButtonMoveDown,TQ_SIGNAL(clicked()),
this,TQ_SLOT(moveDown()));
1424 connect(gui->ButtonMoveBottom,TQ_SIGNAL(clicked()),
this,TQ_SLOT(moveBottom()));
1431void KPSheetSelectPage::getOptions( TQMap<TQString,TQString>& opts,
bool )
1433 TQStringList sheetlist = this->selectedSheets();
1434 TQStringList::iterator it;
1436 for (it = sheetlist.begin(); it != sheetlist.end(); ++it, i++)
1438 opts.insert(printOptionForIndex(i),*it);
1442void KPSheetSelectPage::setOptions(
const TQMap<TQString,TQString>& opts )
1445 TQStringList sheetlist;
1446 while (opts.contains(printOptionForIndex(i)))
1448 sheetlist.prepend(opts[printOptionForIndex(i++)]);
1451 TQStringList::iterator it;
1452 for (it = sheetlist.begin(); it != sheetlist.end(); ++it)
1454 kdDebug() <<
" adding sheet to list of printed sheets: " << *it << endl;
1455 this->prependSelectedSheet(*it);
1459bool KPSheetSelectPage::isValid(TQString& )
1473TQString KPSheetSelectPage::printOptionForIndex(
unsigned int index)
1475 return TQString(
"sheetprintorder%1").arg(index);
1478void KPSheetSelectPage::prependAvailableSheet(
const TQString& sheetname)
1481 new TQListViewItem(gui->ListViewAvailable,sheetname);
1484void KPSheetSelectPage::prependSelectedSheet(
const TQString& sheetname)
1487 new TQListViewItem(gui->ListViewSelected,sheetname);
1490TQStringList KPSheetSelectPage::selectedSheets()
1494 TQListViewItem* item = gui->ListViewSelected->firstChild();
1497 list.append(item->text(0));
1498 item = item->nextSibling();
1503TQStringList KPSheetSelectPage::selectedSheets(KPrinter &prt)
1507 const TQMap<TQString,TQString>& options = prt.options();
1508 for (index = 0; options.contains(KPSheetSelectPage::printOptionForIndex(index)); index++)
1510 list.append(options[KPSheetSelectPage::printOptionForIndex(index)]);
1515void KPSheetSelectPage::clearSelection()
1517 gui->ListViewSelected->clear();
1520void KPSheetSelectPage::selectAll()
1525 TQListViewItem* item = gui->ListViewAvailable->firstChild();
1528 list.prepend(item->text(0));
1529 item = item->nextSibling();
1531 TQStringList::iterator it;
1532 for (it = list.begin(); it != list.end(); ++it)
1534 this->prependSelectedSheet(*it);
1538void KPSheetSelectPage::select()
1543 TQListViewItem* item = gui->ListViewAvailable->firstChild();
1546 if (item->isSelected())
1547 list.prepend(item->text(0));
1548 item = item->nextSibling();
1550 TQStringList::iterator it;
1551 for (it = list.begin(); it != list.end(); ++it)
1553 this->prependSelectedSheet(*it);
1557void KPSheetSelectPage::remove()
1559 TQListViewItem* item = gui->ListViewSelected->firstChild();
1560 TQListViewItem* nextitem = NULL;
1563 nextitem = item->nextSibling();
1564 if (item->isSelected())
1570void KPSheetSelectPage::removeAll()
1572 gui->ListViewSelected->clear();
1576void KPSheetSelectPage::moveTop()
1581 TQValueList<TQListViewItem*> newlist;
1582 TQListViewItem* item = gui->ListViewSelected->firstChild();
1583 TQListViewItem* nextitem = NULL;
1587 nextitem = item->nextSibling();
1588 if (item->isSelected())
1590 newlist.prepend(item);
1591 gui->ListViewSelected->takeItem(item);
1596 item = gui->ListViewSelected->firstChild();
1600 nextitem = item->nextSibling();
1601 if (!item->isSelected())
1603 newlist.prepend(item);
1604 gui->ListViewSelected->takeItem(item);
1611 TQValueList<TQListViewItem*>::iterator it;
1612 for (it = newlist.begin(); it != newlist.end(); ++it)
1615 gui->ListViewSelected->insertItem(*it);
1619void KPSheetSelectPage::moveUp()
1624 TQValueList<TQListViewItem*> newlist;
1625 TQListViewItem* item = gui->ListViewSelected->firstChild();
1626 TQListViewItem* nextitem = NULL;
1629 nextitem = item->nextSibling();
1630 if (!item->isSelected())
1632 while (nextitem && nextitem->isSelected())
1634 TQListViewItem* nextnextitem = nextitem->nextSibling();
1635 newlist.prepend(nextitem);
1636 gui->ListViewSelected->takeItem(nextitem);
1637 nextitem = nextnextitem;
1641 newlist.prepend(item);
1642 gui->ListViewSelected->takeItem(item);
1648 TQValueList<TQListViewItem*>::iterator it;
1649 for (it = newlist.begin(); it != newlist.end(); ++it)
1652 gui->ListViewSelected->insertItem(*it);
1656void KPSheetSelectPage::moveDown()
1658 TQListViewItem* item = gui->ListViewSelected->lastItem();
1671 while (item && !item->isSelected() && item->itemAbove() && item->itemAbove()->isSelected())
1673 TQListViewItem* tempitem = item->itemAbove();
1674 tempitem->moveItem(item);
1677 item = item->itemAbove();
1681void KPSheetSelectPage::moveBottom()
1686 TQValueList<TQListViewItem*> newlist;
1687 TQListViewItem* item = gui->ListViewSelected->firstChild();
1688 TQListViewItem* nextitem = NULL;
1693 nextitem = item->nextSibling();
1694 if (!item->isSelected())
1696 newlist.prepend(item);
1697 gui->ListViewSelected->takeItem(item);
1702 item = gui->ListViewSelected->firstChild();
1705 nextitem = item->nextSibling();
1706 if (item->isSelected())
1708 newlist.prepend(item);
1709 gui->ListViewSelected->takeItem(item);
1716 TQValueList<TQListViewItem*>::iterator it;
1717 for (it = newlist.begin(); it != newlist.end(); ++it)
1720 gui->ListViewSelected->insertItem(*it);
1731View::View( TQWidget *_parent,
const char *_name,
1733 : KoView( _doc, _parent, _name )
1735 ElapsedTime et(
"View constructor" );
1736 kdDebug(36001) <<
"sizeof(Cell)=" <<
sizeof(
Cell) <<endl;
1746 d->toolbarLock =
false;
1749 d->selection =
new Selection(
this );
1750 d->choice =
new Selection(
this );
1751 d->choice->setMultipleSelection(
true);
1752 connect(d->selection, TQ_SIGNAL(changed(
const Region&)),
this, TQ_SLOT(slotChangeSelection(
const Region&)));
1753 connect(d->choice, TQ_SIGNAL(changed(
const Region&)),
this, TQ_SLOT(slotChangeChoice(
const Region&)));
1754 connect(d->choice, TQ_SIGNAL(changed(
const Region&)),
this, TQ_SLOT(slotScrollChoice(
const Region&)));
1757 d->findLeftColumn = 0;
1758 d->findRightColumn = 0;
1759 d->typeValue = FindOption::Value;
1760 d->directionValue = FindOption::Row;
1764 d->popupMenuFirstToolId = 0;
1769 d->popupListChoose = 0;
1770 d->popupChildObject = 0;
1772 d->searchInSheets.currentSheet = 0;
1773 d->searchInSheets.firstSheet = 0;
1776 d->spell.tdespell = 0;
1777 d->spell.macroCmdSpellCheck = 0;
1778 d->spell.firstSpellSheet = 0;
1779 d->spell.currentSpellSheet = 0;
1780 d->spell.currentCell = 0;
1781 d->spell.spellStartCellX = 0;
1782 d->spell.spellStartCellY = 0;
1783 d->spell.spellEndCellX = 0;
1784 d->spell.spellEndCellY = 0;
1785 d->spell.spellCheckSelection =
false;
1787 d->insertHandler = 0L;
1788 d->specialCharDlg = 0;
1790 setInstance( Factory::global() );
1791 if ( doc()->isReadWrite() )
1792 setXMLFile(
"kspread.rc" );
1794 setXMLFile(
"kspread_readonly.rc" );
1809 KoContainerHandler* h =
new KoContainerHandler(
this, d->canvas );
1810 connect( h, TQ_SIGNAL( popupMenu( KoChild*,
const TQPoint& ) ),
this, TQ_SLOT(
popupChildMenu( KoChild*,
const TQPoint& ) ) );
1813 connect(
this, TQ_SIGNAL( childSelected( KoDocumentChild* ) ),
1814 this, TQ_SLOT( slotChildSelected( KoDocumentChild* ) ) );
1815 connect(
this, TQ_SIGNAL( childUnselected( KoDocumentChild* ) ),
1816 this, TQ_SLOT( slotChildUnselected( KoDocumentChild* ) ) );
1819 connect(
this, TQ_SIGNAL( childActivated( KoDocumentChild* ) ),
1820 this, TQ_SLOT( slotChildUnselected( KoDocumentChild* ) ) );
1822 connect( d->canvas, TQ_SIGNAL( objectSelectedChanged() ),
1823 this, TQ_SLOT( objectSelectedChanged() ) );
1825 TQObject::connect( doc()->map(), TQ_SIGNAL( sig_addSheet( Sheet* ) ), TQ_SLOT( slotAddSheet( Sheet* ) ) );
1827 TQObject::connect( doc(), TQ_SIGNAL( sig_refreshView( ) ),
this, TQ_SLOT( slotRefreshView() ) );
1829 TQObject::connect( doc(), TQ_SIGNAL( sig_refreshLocale() ),
this, TQ_SLOT( refreshLocale()));
1831 TQObject::connect( doc(), TQ_SIGNAL( sig_addAreaName(
const TQString & ) ), d->posWidget, TQ_SLOT( slotAddAreaName(
const TQString & ) ) );
1833 TQObject::connect( doc(), TQ_SIGNAL( sig_removeAreaName(
const TQString & ) ), d->posWidget, TQ_SLOT( slotRemoveAreaName(
const TQString & ) ) );
1835 TQObject::connect( doc(), TQ_SIGNAL( damagesFlushed(
const TQValueList<Damage*>& ) ),
1836 this, TQ_SLOT( handleDamages(
const TQValueList<Damage*>& ) ) );
1841 if (!doc()->isReadWrite())
1843 setZoom( 100,
true );
1846 viewZoom( TQString::number( doc()->zoom() ) );
1849 d->actions->selectStyle->setItems( d->doc->styleManager()->styleNames() );
1856 if ( !doc()->map()->sheetList().isEmpty() )
1857 TQTimer::singleShot(50,
this, TQ_SLOT(initialPosition()));
1859 connect (&d->statusBarOpTimer, TQ_SIGNAL(timeout()),
this, TQ_SLOT(
calcStatusBarOp()));
1865 if ( doc()->isReadWrite() )
1867 if ( !d->transformToolBox.isNull() )
1868 delete (&*d->transformToolBox);
1875 delete d->spell.tdespell;
1877 d->canvas->endChoose();
1884 delete d->selection;
1887 delete d->popupColumn;
1889 delete d->popupMenu;
1890 delete d->popupChild;
1891 delete d->popupListChoose;
1892 delete d->calcLabel;
1895 delete d->insertHandler;
1896 d->insertHandler = 0L;
1906Doc* View::doc()
const
1921void View::initView()
1923 d->viewLayout =
new TQGridLayout(
this, 3, 4 );
1927 d->vertScrollBar =
new TQScrollBar(
this,
"ScrollBar_2" );
1928 d->vertScrollBar->setRange( 0, 4096 );
1929 d->vertScrollBar->setOrientation( TQt::Vertical );
1930 d->vertScrollBar->setLineStep(60);
1931 d->vertScrollBar->setPageStep(60);
1934 d->toolWidget =
new TQFrame(
this );
1936 d->formulaBarLayout =
new TQHBoxLayout( d->toolWidget );
1937 d->formulaBarLayout->setMargin( 4 );
1938 d->formulaBarLayout->addSpacing( 2 );
1940 d->posWidget =
new ComboboxLocationEditWidget( d->toolWidget,
this );
1941 d->posWidget->setMinimumWidth( 100 );
1942 d->formulaBarLayout->addWidget( d->posWidget );
1943 d->formulaBarLayout->addSpacing( 6 );
1945 d->formulaButton = d->newIconButton(
"funct",
true, d->toolWidget );
1946 d->formulaBarLayout->addWidget( d->formulaButton );
1947 d->formulaBarLayout->addSpacing( 2 );
1948 connect( d->formulaButton, TQ_SIGNAL( clicked() ), TQ_SLOT( insertMathExpr() ) );
1950 d->cancelButton = d->newIconButton(
"cancel",
true, d->toolWidget );
1951 d->formulaBarLayout->addWidget( d->cancelButton );
1952 d->okButton = d->newIconButton(
"ok",
true, d->toolWidget );
1953 d->formulaBarLayout->addWidget( d->okButton );
1954 d->formulaBarLayout->addSpacing( 6 );
1957 d->canvas =
new Canvas(
this );
1961 d->editWidget =
new EditWidget( d->toolWidget, d->canvas, d->cancelButton, d->okButton );
1962 d->editWidget->setFocusPolicy( TQWidget::StrongFocus );
1963 d->formulaBarLayout->addWidget( d->editWidget, 2 );
1964 d->formulaBarLayout->addSpacing( 2 );
1966 d->canvas->setEditWidget( d->editWidget );
1968 d->hBorderWidget =
new HBorder(
this, d->canvas,
this );
1969 d->vBorderWidget =
new VBorder(
this, d->canvas ,
this );
1970 d->hBorderWidget->setSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Minimum );
1971 d->vBorderWidget->setSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Expanding );
1973 d->canvas->setFocusPolicy( TQWidget::StrongFocus );
1974 TQWidget::setFocusPolicy( TQWidget::StrongFocus );
1975 setFocusProxy( d->canvas );
1977 connect(
this, TQ_SIGNAL( invalidated() ), d->canvas, TQ_SLOT( update() ) );
1979 TQWidget* bottomPart =
new TQWidget(
this );
1980 d->tabScrollBarLayout =
new TQHBoxLayout( bottomPart );
1981 d->tabScrollBarLayout->setAutoAdd(
true );
1982 d->tabBar =
new KoTabBar( bottomPart );
1983 d->horzScrollBar =
new TQScrollBar( bottomPart,
"ScrollBar_1" );
1985 d->horzScrollBar->setRange( 0, 4096 );
1986 d->horzScrollBar->setOrientation( TQt::Horizontal );
1988 d->horzScrollBar->setLineStep(60);
1989 d->horzScrollBar->setPageStep(60);
1991 TQObject::connect( d->tabBar, TQ_SIGNAL( tabChanged(
const TQString& ) ),
this, TQ_SLOT(
changeSheet(
const TQString& ) ) );
1992 TQObject::connect( d->tabBar, TQ_SIGNAL( tabMoved(
unsigned,
unsigned ) ),
1993 this, TQ_SLOT( moveSheet(
unsigned,
unsigned ) ) );
1994 TQObject::connect( d->tabBar, TQ_SIGNAL( contextMenu(
const TQPoint& ) ),
1996 TQObject::connect( d->tabBar, TQ_SIGNAL( doubleClicked() ),
1997 this, TQ_SLOT( slotRename() ) );
1999 d->viewLayout->setColStretch( 1, 10 );
2000 d->viewLayout->setRowStretch( 2, 10 );
2001 d->viewLayout->addMultiCellWidget( d->toolWidget, 0, 0, 0, 2 );
2002 d->viewLayout->addMultiCellWidget( d->hBorderWidget, 1, 1, 1, 2 );
2003 d->viewLayout->addWidget( d->vBorderWidget, 2, 0 );
2004 d->viewLayout->addWidget( d->canvas, 2, 1 );
2005 d->viewLayout->addWidget( d->vertScrollBar, 2, 2 );
2006 d->viewLayout->addMultiCellWidget( bottomPart, 3, 3, 0, 2 );
2008 KStatusBar * sb = statusBar();
2010 d->calcLabel = sb ?
new KStatusBarLabel( TQString(), 0, sb ) : 0;
2011 addStatusBarItem( d->calcLabel, 0 );
2013 connect(d->calcLabel ,TQ_SIGNAL(itemPressed(
int )),
this,TQ_SLOT(statusBarClicked(
int)));
2016 TQObject::connect( d->vertScrollBar, TQ_SIGNAL( valueChanged(
int) ), d->canvas, TQ_SLOT( slotScrollVert(
int) ) );
2017 TQObject::connect( d->horzScrollBar, TQ_SIGNAL( valueChanged(
int) ), d->canvas, TQ_SLOT( slotScrollHorz(
int) ) );
2028 return d->hBorderWidget;
2033 return d->vBorderWidget;
2038 return d->horzScrollBar;
2043 return d->vertScrollBar;
2048 return d->editWidget;
2053 return d->posWidget;
2061bool View::isLoading()
const
2066Selection* View::selectionInfo()
const
2068 return d->selection;
2071Selection* View::choice()
const
2078 d->actions->insertChartFrame->setChecked(
false );
2081 d->insertHandler = 0;
2084bool View::isInsertingObject()
2086 return d->insertHandler;
2089const Sheet* View::activeSheet()
const
2091 return d->activeSheet;
2094Sheet* View::activeSheet()
2096 return d->activeSheet;
2099void View::initConfig()
2101 TDEConfig *config = Factory::global()->config();
2102 if ( config->hasGroup(
"Parameters" ))
2104 config->setGroup(
"Parameters" );
2105 if ( !doc()->configLoadFromFile() )
2107 if ( !doc()->configLoadFromFile() )
2111 if ( !doc()->configLoadFromFile() )
2112 doc()->setCompletionMode((TDEGlobalSettings::Completion)config->readNumEntry(
"Completion Mode",(
int)(TDEGlobalSettings::CompletionAuto)));
2113 doc()->setMoveToValue((KSpread::MoveTo)config->readNumEntry(
"Move",(
int)(Bottom)));
2114 doc()->
setIndentValue( config->readDoubleNumEntry(
"Indent", 10.0 ) );
2115 doc()->
setTypeOfCalc((MethodOfCalc)config->readNumEntry(
"Method of Calc",(
int)(SumOfNumber)));
2116 if ( !doc()->configLoadFromFile() )
2124 changeNbOfRecentFiles(config->readNumEntry(
"NbRecentFile",10));
2127 doc()->setAutoSave(config->readNumEntry(
"AutoSave",KoDocument::defaultAutoSave()/60)*60);
2128 doc()->setBackupFile( config->readBoolEntry(
"BackupFile",
true));
2131 if ( config->hasGroup(
"KSpread Color" ) )
2133 config->setGroup(
"KSpread Color" );
2134 TQColor _col(TQt::lightGray);
2135 _col = config->readColorEntry(
"GridColor", &_col);
2138 TQColor _pbCol(TQt::red);
2139 _pbCol = config->readColorEntry(
"PageBorderColor", &_pbCol);
2140 doc()->changePageBorderColor(_pbCol);
2162void View::changeNbOfRecentFiles(
int _nb)
2165 shell()->setMaxRecentItems( _nb );
2168void View::initCalcMenu()
2170 switch( doc()->getTypeOfCalc())
2173 d->actions->calcSum->setChecked(
true);
2176 d->actions->calcMin->setChecked(
true);
2179 d->actions->calcMax->setChecked(
true);
2182 d->actions->calcAverage->setChecked(
true);
2185 d->actions->calcCount->setChecked(
true);
2188 d->actions->calcCountA->setChecked(
true);
2191 d->actions->calcNone->setChecked(
true);
2194 d->actions->calcSum->setChecked(
true);
2201void View::recalcWorkBook()
2210 tbl = doc()->map()->nextSheet() )
2221void View::refreshLocale()
2227 tbl = doc()->map()->nextSheet() )
2229 tbl->updateLocale();
2234void View::recalcWorkSheet()
2236 if ( d->activeSheet != 0 )
2241 d->activeSheet->recalc(
true);
2248void View::extraSpelling()
2250 if ( d->spell.tdespell )
2253 if (d->activeSheet == 0L)
2256 d->spell.macroCmdSpellCheck = 0L;
2257 d->spell.firstSpellSheet = d->activeSheet;
2258 d->spell.currentSpellSheet = d->spell.firstSpellSheet;
2260 TQRect selection = d->selection->selection();
2263 if (d->selection->isSingular())
2265 d->spell.spellStartCellX = 0;
2266 d->spell.spellStartCellY = 0;
2267 d->spell.spellEndCellX = 0;
2268 d->spell.spellEndCellY = 0;
2269 d->spell.spellCheckSelection =
false;
2270 d->spell.currentCell = d->activeSheet->firstCell();
2274 d->spell.spellStartCellX = selection.left();
2275 d->spell.spellStartCellY = selection.top();
2276 d->spell.spellEndCellX = selection.right();
2277 d->spell.spellEndCellY = selection.bottom();
2278 d->spell.spellCheckSelection =
true;
2279 d->spell.currentCell = 0L;
2282 d->spell.spellCurrCellX = d->spell.spellStartCellX - 1;
2283 d->spell.spellCurrCellY = d->spell.spellStartCellY;
2290void View::startKSpell()
2292 if ( doc()->getKSpellConfig() )
2294 doc()->getKSpellConfig()->setIgnoreList( doc()->spellListIgnoreAll() );
2295 doc()->getKSpellConfig()->setReplaceAllList( d->spell.replaceAll );
2298 d->spell.tdespell =
new KSpell(
this, i18n(
"Spell Checking" ),
this,
2299 TQ_SLOT( spellCheckerReady() ),
2300 doc()->getKSpellConfig() );
2302 d->spell.tdespell->setIgnoreUpperWords( doc()->dontCheckUpperWord() );
2303 d->spell.tdespell->setIgnoreTitleCase( doc()->dontCheckTitleCase() );
2305 TQObject::connect( d->spell.tdespell, TQ_SIGNAL( death() ),
2306 this, TQ_SLOT( spellCheckerFinished() ) );
2307 TQObject::connect( d->spell.tdespell, TQ_SIGNAL( misspelling(
const TQString &,
2308 const TQStringList &,
2310 this, TQ_SLOT( spellCheckerMisspelling(
const TQString &,
2311 const TQStringList &,
2313 TQObject::connect( d->spell.tdespell, TQ_SIGNAL( corrected(
const TQString &,
2316 this, TQ_SLOT( spellCheckerCorrected(
const TQString &,
2319 TQObject::connect( d->spell.tdespell, TQ_SIGNAL( done(
const TQString & ) ),
2320 this, TQ_SLOT( spellCheckerDone(
const TQString & ) ) );
2321 TQObject::connect( d->spell.tdespell, TQ_SIGNAL( ignoreall (
const TQString & ) ),
2322 this, TQ_SLOT( spellCheckerIgnoreAll(
const TQString & ) ) );
2324 TQObject::connect( d->spell.tdespell, TQ_SIGNAL( replaceall(
const TQString & ,
const TQString & )),
this, TQ_SLOT( spellCheckerReplaceAll(
const TQString & ,
const TQString & )));
2328void View::spellCheckerReplaceAll(
const TQString &orig,
const TQString & replacement)
2330 d->spell.replaceAll.append( orig);
2331 d->spell.replaceAll.append( replacement);
2335void View::spellCheckerIgnoreAll(
const TQString & word)
2337 doc()->addIgnoreWordAll( word );
2341void View::spellCheckerReady()
2344 d->canvas->setCursor( WaitCursor );
2347 if (!d->spell.spellCheckSelection)
2351 while ( d->spell.currentCell )
2354 if ( d->spell.currentCell->value().isString() )
2356 d->spell.tdespell->check( d->spell.currentCell->text(),
true );
2361 d->spell.currentCell = d->spell.currentCell->nextCell();
2362 if ( d->spell.currentCell && d->spell.currentCell->isDefault() )
2363 kdDebug() <<
"checking default cell!!" << endl << endl;
2366 if (spellSwitchToOtherSheet())
2367 spellCheckerReady();
2376 ++d->spell.spellCurrCellX;
2377 if (d->spell.spellCurrCellX > d->spell.spellEndCellX)
2379 d->spell.spellCurrCellX = d->spell.spellStartCellX;
2380 ++d->spell.spellCurrCellY;
2386 for ( y = d->spell.spellCurrCellY; y <= d->spell.spellEndCellY; ++y )
2388 for ( x = d->spell.spellCurrCellX; x <= d->spell.spellEndCellX; ++x )
2390 Cell * cell = d->spell.currentSpellSheet->cellAt( x, y );
2393 if (cell->isDefault() || !cell->value().isString())
2396 d->spell.spellCurrCellX = x;
2397 d->spell.spellCurrCellY = y;
2399 d->spell.tdespell->check( cell->text(), true );
2403 d->spell.spellCurrCellX = d->spell.spellStartCellX;
2408 if (d->spell.spellCheckSelection)
2415 if (spellSwitchToOtherSheet())
2416 spellCheckerReady();
2423void View::spellCleanup()
2426 d->canvas->setCursor( ArrowCursor );
2428 d->spell.tdespell->cleanUp();
2429 delete d->spell.tdespell;
2430 d->spell.tdespell = 0L;
2431 d->spell.firstSpellSheet = 0L;
2432 d->spell.currentSpellSheet = 0L;
2433 d->spell.currentCell = 0L;
2434 d->spell.replaceAll.clear();
2437 KMessageBox::information(
this, i18n(
"Spell checking is complete." ) );
2439 if ( d->spell.macroCmdSpellCheck )
2440 doc()->
addCommand( d->spell.macroCmdSpellCheck );
2441 d->spell.macroCmdSpellCheck=0L;
2445bool View::spellSwitchToOtherSheet()
2448 if ( doc()->map()->count() == 1 )
2452 TQPtrList<Sheet> sheetList = doc()->map()->sheetList();
2454 unsigned int curIndex = sheetList.findRef(d->spell.currentSpellSheet);
2458 if ( curIndex >= sheetList.count() )
2459 d->spell.currentSpellSheet = sheetList.first();
2461 d->spell.currentSpellSheet = sheetList.at(curIndex);
2464 if ( d->spell.currentSpellSheet == d->spell.firstSpellSheet )
2466 setActiveSheet( d->spell.firstSpellSheet );
2470 if (d->spell.spellCheckSelection)
2472 d->spell.spellEndCellX = d->spell.currentSpellSheet->maxColumn();
2473 d->spell.spellEndCellY = d->spell.currentSpellSheet->maxRow();
2475 d->spell.spellCurrCellX = d->spell.spellStartCellX - 1;
2476 d->spell.spellCurrCellY = d->spell.spellStartCellY;
2480 d->spell.currentCell = d->spell.currentSpellSheet->firstCell();
2483 if ( KMessageBox::questionYesNo(
this,
2484 i18n(
"Do you want to check the spelling in the next sheet?") )
2485 != KMessageBox::Yes )
2488 setActiveSheet( d->spell.currentSpellSheet );
2494void View::spellCheckerMisspelling(
const TQString &,
2495 const TQStringList &,
2499 if ( !d->spell.spellCheckSelection )
2501 d->spell.spellCurrCellX = d->spell.currentCell->column();
2502 d->spell.spellCurrCellY = d->spell.currentCell->row();
2505 d->selection->initialize(TQPoint(d->spell.spellCurrCellX, d->spell.spellCurrCellY));
2509void View::spellCheckerCorrected(
const TQString & old,
const TQString & corr,
2514 if (d->spell.spellCheckSelection)
2516 cell = d->spell.currentSpellSheet->cellAt( d->spell.spellCurrCellX,
2517 d->spell.spellCurrCellY );
2521 cell = d->spell.currentCell;
2522 d->spell.spellCurrCellX = cell->column();
2523 d->spell.spellCurrCellY = cell->row();
2531 TQString content( cell->text() );
2533 UndoSetText* undo =
new UndoSetText( doc(), d->activeSheet,
2535 d->spell.spellCurrCellX,
2536 d->spell.spellCurrCellY,
2537 cell->formatType());
2538 content.replace( pos, old.length(), corr );
2539 cell->setCellText( content );
2540 d->editWidget->setText( content );
2542 if ( !d->spell.macroCmdSpellCheck )
2543 d->spell.macroCmdSpellCheck =
new MacroUndoAction( doc(), i18n(
"Correct Misspelled Word") );
2544 d->spell.macroCmdSpellCheck->addCommand( undo );
2548void View::spellCheckerDone(
const TQString & )
2550 int result = d->spell.tdespell->dlgResult();
2552 d->spell.tdespell->cleanUp();
2553 delete d->spell.tdespell;
2554 d->spell.tdespell = 0L;
2556 if ( result != KS_CANCEL && result != KS_STOP )
2558 if (d->spell.spellCheckSelection)
2560 if ( (d->spell.spellCurrCellY <= d->spell.spellEndCellY)
2561 && (d->spell.spellCurrCellX <= d->spell.spellEndCellX) )
2569 if ( d->spell.currentCell )
2571 d->spell.currentCell = d->spell.currentCell->nextCell();
2579 d->spell.replaceAll.clear();
2581 if ( d->spell.macroCmdSpellCheck )
2583 doc()->
addCommand( d->spell.macroCmdSpellCheck );
2585 d->spell.macroCmdSpellCheck=0L;
2588void View::spellCheckerFinished()
2591 d->canvas->setCursor( ArrowCursor );
2593 KSpell::spellStatus status = d->spell.tdespell->status();
2594 d->spell.tdespell->cleanUp();
2595 delete d->spell.tdespell;
2596 d->spell.tdespell = 0L;
2597 d->spell.replaceAll.clear();
2599 bool tdespellNotConfigured=
false;
2601 if (status == KSpell::Error)
2603 KMessageBox::sorry(
this, i18n(
"ISpell could not be started.\n"
2604 "Please make sure you have ISpell properly configured and in your PATH."));
2605 tdespellNotConfigured=
true;
2607 else if (status == KSpell::Crashed)
2609 KMessageBox::sorry(
this, i18n(
"ISpell seems to have crashed."));
2612 if (d->spell.macroCmdSpellCheck)
2614 doc()->
addCommand( d->spell.macroCmdSpellCheck );
2616 d->spell.macroCmdSpellCheck=0L;
2619 if (tdespellNotConfigured)
2621 PreferenceDialog configDlg(
this, 0 );
2622 configDlg.openPage( PreferenceDialog::KS_SPELLING);
2627void View::initialPosition()
2630 TQPtrListIterator<Sheet> it( doc()->map()->sheetList() );
2631 for( ; it.current(); ++it )
2632 addSheet( it.current() );
2635 if ( KSPLoadingInfo* loadingInfo = doc()->loadingInfo() )
2637 d->savedAnchors = loadingInfo->cursorPositions();
2638 d->savedMarkers = loadingInfo->cursorPositions();
2639 d->savedOffsets = loadingInfo->scrollingOffsets();
2643 if ( doc()->isEmbedded() )
2645 tbl = doc()->displaySheet();
2649 tbl = doc()->map()->initialActiveSheet();
2651 setActiveSheet( tbl );
2655 tbl = doc()->map()->
findSheet( doc()->map()->visibleSheets().first());
2661 tbl->setHidden(
false );
2662 TQString tabName = tbl->sheetName();
2663 d->tabBar->addTab( tabName );
2666 setActiveSheet( tbl );
2672 if ( !doc()->loadingInfo() )
2674 double offsetX = doc()->map()->initialXOffset();
2675 double offsetY = doc()->map()->initialYOffset();
2678 int col = doc()->map()->initialMarkerColumn();
2681 int row = doc()->map()->initialMarkerRow();
2684 d->canvas->setXOffset( offsetX );
2685 d->canvas->setYOffset( offsetY );
2686 d->horzScrollBar->setValue( (
int)offsetX );
2687 d->vertScrollBar->setValue( (
int)offsetY );
2688 d->selection->initialize( TQPoint(col, row) );
2691 updateBorderButton();
2692 updateShowSheetMenu();
2694 d->actions->autoFormat->setEnabled(
false);
2695 d->actions->sort->setEnabled(
false);
2696 d->actions->mergeCell->setEnabled(
false);
2697 d->actions->mergeCellHorizontal->setEnabled(
false);
2698 d->actions->mergeCellVertical->setEnabled(
false);
2699 d->actions->createStyle->setEnabled(
false);
2701 d->actions->fillUp->setEnabled(
false );
2702 d->actions->fillRight->setEnabled(
false );
2703 d->actions->fillDown->setEnabled(
false );
2704 d->actions->fillLeft->setEnabled(
false );
2707 doc()->decreaseNumOperation();
2709 TQRect vr( activeSheet()->visibleRect( d->canvas ) );
2712 activeSheet()->setRegionPaintDirty( vr );
2715 if ( koDocument()->isReadWrite() )
2718 d->adjustActions( !d->activeSheet->isProtected() );
2719 d->adjustWorkbookActions( !doc()->map()->isProtected() );
2729 if (!d->activeSheet)
2732 int column = d->canvas->markerColumn();
2733 int row = d->canvas->markerRow();
2735 Cell* cell = d->activeSheet->cellAt( column, row );
2738 d->editWidget->setText(
"" );
2741 if ( d->activeSheet->isProtected() && cell->format()->isHideFormula( column, row ) )
2742 d->editWidget->setText( cell->strOutText() );
2743 else if ( d->activeSheet->isProtected() && cell->format()->isHideAll( column, row ) )
2744 d->editWidget->setText(
"" );
2746 d->editWidget->setText( cell->text() );
2748 d->updateButton(cell, column, row);
2749 d->adjustActions( d->activeSheet, cell );
2754 if (!d->activeSheet)
2757 int column = d->canvas->markerColumn();
2758 int row = d->canvas->markerRow();
2760 Cell * cell = d->activeSheet->cellAt( column, row );
2761 bool active = activeSheet()->getShowFormula()
2762 && !( d->activeSheet->isProtected() && cell && cell->format()->isHideFormula( column, row ) );
2764 if ( d->activeSheet && !d->activeSheet->isProtected() )
2766 d->actions->alignLeft->setEnabled(!active);
2767 d->actions->alignCenter->setEnabled(!active);
2768 d->actions->alignRight->setEnabled(!active);
2773 d->editWidget->setText(
"" );
2774 if ( d->activeSheet->isProtected() )
2775 d->editWidget->setEnabled(
false );
2777 d->editWidget->setEnabled(
true );
2781 if ( d->activeSheet->isProtected() && cell->format()->isHideFormula( column, row ) )
2782 d->editWidget->setText( cell->strOutText() );
2783 else if ( d->activeSheet->isProtected() && cell->format()->isHideAll( column, row ) )
2784 d->editWidget->setText(
"" );
2786 d->editWidget->setText( cell->text() );
2788 if ( d->activeSheet->isProtected() && !cell->format()->notProtected( column, row ) )
2789 d->editWidget->setEnabled(
false );
2791 d->editWidget->setEnabled(
true );
2793 if ( d->canvas->editor() )
2795 d->canvas->editor()->setEditorFont(cell->format()->textFont(column, row),
true);
2796 d->canvas->editor()->setFocus();
2798 d->updateButton(cell, column, row);
2799 d->adjustActions( d->activeSheet, cell );
2806void View::objectSelectedChanged()
2808 if ( d->canvas->isObjectSelected() )
2809 d->actions->actionExtraProperties->setEnabled(
true );
2811 d->actions->actionExtraProperties->setEnabled(
false );
2814void View::updateReadWrite(
bool readwrite )
2818 d->editWidget->setEnabled( readwrite );
2820 TQValueList<TDEAction*> actions = actionCollection()->actions();
2821 TQValueList<TDEAction*>::ConstIterator aIt = actions.begin();
2822 TQValueList<TDEAction*>::ConstIterator aEnd = actions.end();
2823 for (; aIt != aEnd; ++aIt )
2824 (*aIt)->setEnabled( readwrite );
2827 if ( !doc() || !doc()->map() || doc()->map()->isProtected() )
2829 d->actions->showSheet->setEnabled(
false );
2830 d->actions->hideSheet->setEnabled(
false );
2834 d->actions->showSheet->setEnabled(
true );
2835 d->actions->hideSheet->setEnabled(
true );
2837 d->actions->gotoCell->setEnabled(
true );
2838 d->actions->viewZoom->setEnabled(
true );
2839 d->actions->showPageBorders->setEnabled(
true );
2840 d->actions->find->setEnabled(
true);
2841 d->actions->replace->setEnabled( readwrite );
2842 if ( !doc()->isReadWrite())
2843 d->actions->copy->setEnabled(
true );
2852 TQPixmap pix = doc()->generatePreview(TQSize(width, height));
2854 KTempFile tempFile( TQString(),
".kst" );
2856 if (tempFile.status() != 0)
2858 tqWarning(
"Creation of temprary file to store template failed.");
2862 tempFile.setAutoDelete(
true);
2864 doc()->saveNativeFormat( tempFile.name() );
2866 KoTemplateCreateDia::createTemplate(
"kspread_template", Factory::global(),
2867 tempFile.name(), pix,
this );
2869 Factory::global()->dirs()->addResourceType(
"kspread_template",
2870 TDEStandardDirs::kde_default(
"data" ) +
2871 "kspread/templates/");
2874void View::sheetFormat()
2887 if ( d->canvas->editor() )
2895 TQRect sel = d->selection->selection(
false);
2897 if (sel.height() > 1)
2899 if (d->selection->marker().y()==sel.top())
2900 sel.setTop(sel.top()+1);
2901 if (d->selection->marker().y()==sel.bottom())
2902 sel.setBottom(sel.bottom()-1);
2906 if (sel.width() > 1)
2908 if (d->selection->marker().x()==sel.left())
2909 sel.setLeft(sel.left()+1);
2911 if (d->selection->marker().x()==sel.right())
2912 sel.setRight(sel.right()-1);
2921 int start = -1, end = -1;
2923 if ( (d->selection->marker().y() > 1) && activeSheet()->cellAt(d->selection->marker().x(), d->selection->marker().y()-1)->value().isNumber() )
2926 start = end = d->selection->marker().y()-1;
2927 for (start--; (start > 0) && activeSheet()->cellAt(d->selection->marker().x(), start)->value().isNumber(); start--) ;
2929 Point startPoint, endPoint;
2930 startPoint.setRow(start+1);
2931 startPoint.setColumn(d->selection->marker().x());
2932 endPoint.setRow(end);
2933 endPoint.setColumn(d->selection->marker().x());
2935 TQString str = Range(startPoint, endPoint).toString();
2937 d->canvas->createEditor( Canvas::CellEditor ,
true ,
true );
2938 d->canvas->editor()->setText(
"=SUM(" + str +
")");
2939 d->canvas->editor()->setCursorPosition(5 + str.length());
2942 else if ( (d->selection->marker().x() > 1) && activeSheet()->cellAt(d->selection->marker().x()-1, d->selection->marker().y())->value().isNumber() )
2945 start = end = d->selection->marker().x()-1;
2946 for (start--; (start > 0) && activeSheet()->cellAt(start, d->selection->marker().y())->value().isNumber(); start--) ;
2948 Point startPoint, endPoint;
2949 startPoint.setColumn(start+1);
2950 startPoint.setRow(d->selection->marker().y());
2951 endPoint.setColumn(end);
2952 endPoint.setRow(d->selection->marker().y());
2954 TQString str = Range(startPoint, endPoint).toString();
2956 d->canvas->createEditor( Canvas::CellEditor ,
true ,
true );
2957 d->canvas->editor()->setText(
"=SUM(" + str +
")");
2958 d->canvas->editor()->setCursorPosition(5 + str.length());
2964 if ( (sel.width() > 1) && (sel.height() > 1) )
2969 d->canvas->createEditor( Canvas::CellEditor ,
true ,
true );
2972 if ( (rg.range().isValid() ) && (!rg.range().isEmpty()) )
2974 d->canvas->editor()->setText(
"=SUM("+rg.toString()+
")" );
2975 d->canvas->deleteEditor(
true);
2979 d->canvas->startChoose();
2980 d->canvas->editor()->setText(
"=SUM()" );
2981 d->canvas->editor()->setCursorPosition( 5 );
2993void View::changeTextColor()
2995 if ( d->activeSheet != 0L )
2998 d->activeSheet->setSelectionTextColor( selectionInfo(), d->actions->textColor->color() );
3003void View::setSelectionTextColor(
const TQColor &txtColor)
3005 if (d->activeSheet != 0L)
3008 d->activeSheet->setSelectionTextColor( selectionInfo(), txtColor );
3015void View::changeBackgroundColor()
3017 if ( d->activeSheet != 0L )
3020 d->activeSheet->setSelectionbgColor( selectionInfo(), d->actions->bgColor->color() );
3025void View::setSelectionBackgroundColor(
const TQColor &bgColor)
3027 if (d->activeSheet != 0L)
3030 d->activeSheet->setSelectionbgColor( selectionInfo(), bgColor );
3035void View::changeBorderColor()
3037 if ( d->activeSheet != 0L )
3040 d->activeSheet->setSelectionBorderColor( selectionInfo(), d->actions->borderColor->color() );
3045void View::setSelectionBorderColor(
const TQColor &bdColor)
3047 if (d->activeSheet != 0L)
3050 d->activeSheet->setSelectionBorderColor( selectionInfo(), bdColor );
3055void View::helpUsing()
3057 kapp->invokeHelp( );
3060void View::enableUndo(
bool _b )
3062 TDEAction* action = actionCollection()->action(
"office_undo" );
3063 if( action ) action->setEnabled( _b );
3066void View::enableRedo(
bool _b )
3068 TDEAction* action = actionCollection()->action(
"office_redo" );
3069 if( action ) action->setEnabled( _b );
3072void View::enableInsertColumn(
bool _b )
3074 if ( d->activeSheet && !d->activeSheet->isProtected() )
3075 d->actions->insertColumn->setEnabled( _b );
3078void View::enableInsertRow(
bool _b )
3080 if ( d->activeSheet && !d->activeSheet->isProtected() )
3081 d->actions->insertRow->setEnabled( _b );
3084void View::deleteColumn()
3086 if ( !d->activeSheet )
3091 TQRect r( d->selection->selection() );
3093 d->activeSheet->removeColumn( r.left(), ( r.right()-r.left() ) );
3097 d->selection->update();
3099 TQRect vr( d->activeSheet->visibleRect( d->canvas ) );
3100 vr.setLeft( r.left() );
3105void View::deleteRow()
3107 if ( !d->activeSheet )
3111 TQRect r( d->selection->selection() );
3112 d->activeSheet->removeRow( r.top(),(r.bottom()-r.top()) );
3116 d->selection->update();
3118 TQRect vr( d->activeSheet->visibleRect( d->canvas ) );
3119 vr.setTop( r.top() );
3124void View::insertColumn()
3126 if ( !d->activeSheet )
3130 TQRect r( d->selection->selection() );
3131 d->activeSheet->insertColumn( r.left(), ( r.right()-r.left() ) );
3135 TQRect vr( d->activeSheet->visibleRect( d->canvas ) );
3136 vr.setLeft( r.left() - 1 );
3141void View::hideColumn()
3143 if ( !d->activeSheet )
3146 if ( d->selection->isRowSelected() )
3148 KMessageBox::error(
this, i18n(
"Area is too large." ) );
3152 d->activeSheet->hideColumn(*selectionInfo());
3155void View::showColumn()
3157 if ( !d->activeSheet )
3160 ShowColRow dlg(
this,
"showCol", ShowColRow::Column );
3164void View::showSelColumns()
3166 if ( !d->activeSheet )
3169 d->activeSheet->showColumn(*selectionInfo());
3172void View::insertRow()
3174 if ( !d->activeSheet )
3177 TQRect r( d->selection->selection() );
3178 d->activeSheet->insertRow( r.top(), ( r.bottom() - r.top() ) );
3181 TQRect vr( d->activeSheet->visibleRect( d->canvas ) );
3182 vr.setTop( r.top() - 1 );
3189 if ( !d->activeSheet )
3192 if ( d->selection->isColumnSelected() )
3194 KMessageBox::error(
this, i18n(
"Area is too large." ) );
3198 d->activeSheet->hideRow(*selectionInfo());
3203 if ( !d->activeSheet )
3206 ShowColRow dlg(
this,
"showRow", ShowColRow::Row );
3210void View::showSelRows()
3212 if ( !d->activeSheet )
3215 d->activeSheet->showRow(*selectionInfo());
3218void View::fontSelected(
const TQString & _font )
3220 if ( d->toolbarLock )
3224 if ( d->activeSheet != 0L )
3225 d->activeSheet->setSelectionFont( d->selection, _font.latin1() );
3228 if ( d->canvas->editor() )
3230 Cell * cell = d->activeSheet->cellAt( d->selection->marker() );
3231 d->canvas->editor()->setEditorFont( cell->format()->textFont( cell->column(), cell->row() ),
true );
3232 d->canvas->editor()->setFocus();
3235 d->canvas->setFocus();
3241void View::decreaseFontSize()
3243 setSelectionFontSize( -1 );
3246void View::increaseFontSize()
3248 setSelectionFontSize( 1 );
3251void View::setSelectionFontSize(
int size )
3253 if ( d->activeSheet != NULL )
3255 d->activeSheet->setSelectionSize( selectionInfo(), size );
3261 if ( !d->activeSheet )
3266 d->activeSheet->setSelectionUpperLower( selectionInfo(), -1 );
3275 if ( !d->activeSheet )
3280 d->activeSheet->setSelectionUpperLower( selectionInfo(), 1 );
3287void View::firstLetterUpper()
3289 if ( !d->activeSheet )
3292 d->activeSheet->setSelectionfirstLetterUpper( selectionInfo() );
3299void View::verticalText(
bool b)
3301 if ( !d->activeSheet )
3305 d->activeSheet->setSelectionVerticalText( selectionInfo(), b );
3306 d->activeSheet->adjustArea(*selectionInfo());
3313void View::insertSpecialChar()
3315 TQString f( d->actions->selectFont->font() );
3318 if ( d->specialCharDlg == 0 )
3320 d->specialCharDlg =
new KoCharSelectDia(
this,
"insert special char", f, c,
false );
3321 connect( d->specialCharDlg, TQ_SIGNAL( insertChar( TQChar,
const TQString & ) ),
3322 this, TQ_SLOT( slotSpecialChar( TQChar,
const TQString & ) ) );
3323 connect( d->specialCharDlg, TQ_SIGNAL( finished() ),
3324 this, TQ_SLOT( slotSpecialCharDlgClosed() ) );
3326 d->specialCharDlg->show();
3329void View::slotSpecialCharDlgClosed()
3331 if ( d->specialCharDlg )
3333 disconnect( d->specialCharDlg, TQ_SIGNAL(insertChar(TQChar,
const TQString &)),
3334 this, TQ_SLOT(slotSpecialChar(TQChar,
const TQString &)));
3335 disconnect( d->specialCharDlg, TQ_SIGNAL( finished() ),
3336 this, TQ_SLOT( slotSpecialCharDlgClosed() ) );
3337 d->specialCharDlg->deleteLater();
3338 d->specialCharDlg = 0L;
3342void View::slotSpecialChar( TQChar c,
const TQString & _font )
3344 if ( d->activeSheet )
3346 TQPoint marker( d->selection->marker() );
3347 Cell * cell = d->activeSheet->nonDefaultCell( marker );
3348 if ( cell->format()->textFont( marker.x(), marker.y() ).family() != _font )
3350 cell->format()->setTextFontFamily( _font );
3352 EditWidget * edit = d->editWidget;
3353 TQKeyEvent ev( TQEvent::KeyPress, 0, 0, 0, TQString( c ) );
3354 TQApplication::sendEvent( edit, &ev );
3358void View::insertMathExpr()
3360 if ( d->activeSheet == 0L )
3363 FormulaDialog * dlg =
new FormulaDialog(
this,
"Function" );
3371void View::formulaSelection(
const TQString &_math )
3373 if ( d->activeSheet == 0 )
3376 if ( _math == i18n(
"Others...") )
3382 FormulaDialog *dlg =
new FormulaDialog(
this,
"Formula Editor", _math );
3386void View::fontSizeSelected(
int _size )
3388 if ( d->toolbarLock )
3393 if ( d->activeSheet != 0L )
3394 d->activeSheet->setSelectionFont( selectionInfo(), 0L, _size );
3397 if ( d->canvas->editor() )
3399 Cell * cell = d->activeSheet->cellAt( d->selection->marker() );
3400 d->canvas->editor()->setEditorFont( cell->format()->textFont( d->canvas->markerColumn(),
3401 d->canvas->markerRow() ),
true );
3402 d->canvas->editor()->setFocus();
3405 d->canvas->setFocus();
3411void View::bold(
bool b )
3413 if ( d->toolbarLock )
3415 if ( d->activeSheet == 0 )
3420 int col = d->canvas->markerColumn();
3421 int row = d->canvas->markerRow();
3422 d->activeSheet->setSelectionFont( selectionInfo(), 0L, -1, b );
3424 if ( d->canvas->editor() )
3426 Cell * cell = d->activeSheet->cellAt( col, row );
3427 d->canvas->editor()->setEditorFont( cell->format()->textFont( col, row ),
true );
3434void View::underline(
bool b )
3436 if ( d->toolbarLock )
3438 if ( d->activeSheet == 0 )
3443 int col = d->canvas->markerColumn();
3444 int row = d->canvas->markerRow();
3446 d->activeSheet->setSelectionFont( selectionInfo(), 0L, -1, -1, -1 ,b );
3447 if ( d->canvas->editor() )
3449 Cell * cell = d->activeSheet->cellAt( col, row );
3450 d->canvas->editor()->setEditorFont( cell->format()->textFont( col, row ),
true );
3457void View::strikeOut(
bool b )
3459 if ( d->toolbarLock )
3461 if ( d->activeSheet == 0 )
3466 int col = d->canvas->markerColumn();
3467 int row = d->canvas->markerRow();
3469 d->activeSheet->setSelectionFont( selectionInfo(), 0L, -1, -1, -1 ,-1, b );
3470 if ( d->canvas->editor() )
3472 Cell * cell = d->activeSheet->cellAt( col, row );
3473 d->canvas->editor()->setEditorFont( cell->format()->textFont( col, row ),
true );
3481void View::italic(
bool b )
3483 if ( d->toolbarLock )
3485 if ( d->activeSheet == 0 )
3490 int col = d->canvas->markerColumn();
3491 int row = d->canvas->markerRow();
3493 d->activeSheet->setSelectionFont( selectionInfo(), 0L, -1, -1, b );
3494 if ( d->canvas->editor() )
3496 Cell * cell = d->activeSheet->cellAt( col, row );
3497 d->canvas->editor()->setEditorFont( cell->format()->textFont( col, row ),
true );
3509 TQRect range = d->selection->selection();
3510 if ( d->selection->isSingular() )
3512 KMessageBox::error(
this, i18n(
"You must select multiple cells." ) );
3519 if ( d->selection->isRowSelected() || range.top() == range.bottom() )
3520 activeSheet()->sortByRow( range, range.top(), Sheet::Increase );
3522 activeSheet()->sortByColumn( range, range.left(), Sheet::Increase );
3531 TQRect range = d->selection->selection();
3532 if ( d->selection->isSingular() )
3534 KMessageBox::error(
this, i18n(
"You must select multiple cells." ) );
3541 if ( d->selection->isRowSelected() || range.top() == range.bottom() )
3542 activeSheet()->sortByRow( range, range.top(), Sheet::Decrease );
3544 activeSheet()->sortByColumn( range, range.left(), Sheet::Decrease );
3552void View::borderBottom()
3554 if ( d->activeSheet != 0L )
3558 d->activeSheet->borderBottom( d->selection, d->actions->borderColor->color() );
3565void View::setSelectionBottomBorderColor(
const TQColor & color )
3567 if ( d->activeSheet != 0L )
3570 d->activeSheet->borderBottom( selectionInfo(), color );
3577void View::borderRight()
3579 if ( d->activeSheet != 0L )
3582 if ( d->activeSheet->layoutDirection()==Sheet::RightToLeft )
3583 d->activeSheet->borderLeft( d->selection, d->actions->borderColor->color() );
3585 d->activeSheet->borderRight( d->selection, d->actions->borderColor->color() );
3592void View::setSelectionRightBorderColor(
const TQColor & color )
3594 if ( d->activeSheet != 0L )
3597 if ( d->activeSheet->layoutDirection()==Sheet::RightToLeft )
3598 d->activeSheet->borderLeft( selectionInfo(), color );
3600 d->activeSheet->borderRight( selectionInfo(), color );
3607void View::borderLeft()
3609 if ( d->activeSheet != 0L )
3612 if ( d->activeSheet->layoutDirection()==Sheet::RightToLeft )
3613 d->activeSheet->borderRight( d->selection, d->actions->borderColor->color() );
3615 d->activeSheet->borderLeft( d->selection, d->actions->borderColor->color() );
3622void View::setSelectionLeftBorderColor(
const TQColor & color )
3624 if ( d->activeSheet != 0L )
3627 if ( d->activeSheet->layoutDirection()==Sheet::RightToLeft )
3628 d->activeSheet->borderRight( selectionInfo(), color );
3630 d->activeSheet->borderLeft( selectionInfo(), color );
3637void View::borderTop()
3639 if ( d->activeSheet != 0L )
3642 d->activeSheet->borderTop( d->selection, d->actions->borderColor->color() );
3649void View::setSelectionTopBorderColor(
const TQColor & color )
3651 if ( d->activeSheet != 0L )
3654 d->activeSheet->borderTop( selectionInfo(), color );
3661void View::borderOutline()
3663 if ( d->activeSheet != 0L )
3666 d->activeSheet->borderOutline( d->selection, d->actions->borderColor->color() );
3673void View::setSelectionOutlineBorderColor(
const TQColor & color )
3675 if ( d->activeSheet != 0L )
3678 d->activeSheet->borderOutline( selectionInfo(), color );
3685void View::borderAll()
3687 if ( d->activeSheet != 0L )
3690 d->activeSheet->borderAll( d->selection, d->actions->borderColor->color() );
3697void View::setSelectionAllBorderColor(
const TQColor & color )
3699 if ( d->activeSheet != 0L )
3702 d->activeSheet->borderAll( selectionInfo(), color );
3709void View::borderRemove()
3711 if ( d->activeSheet != 0L )
3714 d->activeSheet->borderRemove( d->selection );
3721void View::addSheet( Sheet * _t )
3728 TQObject::connect( _t, TQ_SIGNAL( sig_refreshView() ), TQ_SLOT( slotRefreshView() ) );
3729 TQObject::connect( _t, TQ_SIGNAL( sig_updateView( Sheet* ) ), TQ_SLOT( slotUpdateView( Sheet* ) ) );
3730 TQObject::connect( _t->print(), TQ_SIGNAL( sig_updateView( Sheet* ) ), TQ_SLOT( slotUpdateView( Sheet* ) ) );
3731 TQObject::connect( _t, TQ_SIGNAL( sig_updateView( Sheet *,
const Region& ) ),
3732 TQ_SLOT( slotUpdateView( Sheet*,
const Region& ) ) );
3733 TQObject::connect( _t, TQ_SIGNAL( sig_updateView( EmbeddedObject* )), TQ_SLOT( slotUpdateView( EmbeddedObject* ) ) );
3735 TQObject::connect( _t, TQ_SIGNAL( sig_updateHBorder( Sheet * ) ),
3736 TQ_SLOT( slotUpdateHBorder( Sheet * ) ) );
3737 TQObject::connect( _t, TQ_SIGNAL( sig_updateVBorder( Sheet * ) ),
3738 TQ_SLOT( slotUpdateVBorder( Sheet * ) ) );
3739 TQObject::connect( _t, TQ_SIGNAL( sig_nameChanged( Sheet*,
const TQString& ) ),
3740 this, TQ_SLOT( slotSheetRenamed( Sheet*,
const TQString& ) ) );
3741 TQObject::connect( _t, TQ_SIGNAL( sig_SheetHidden( Sheet* ) ),
3742 this, TQ_SLOT( slotSheetHidden( Sheet* ) ) );
3743 TQObject::connect( _t, TQ_SIGNAL( sig_SheetShown( Sheet* ) ),
3744 this, TQ_SLOT( slotSheetShown( Sheet* ) ) );
3745 TQObject::connect( _t, TQ_SIGNAL( sig_SheetRemoved( Sheet* ) ),
3746 this, TQ_SLOT( slotSheetRemoved( Sheet* ) ) );
3749 TQObject::connect( _t, TQ_SIGNAL( sig_updateChildGeometry( EmbeddedKOfficeObject* ) ),
3750 TQ_SLOT( slotUpdateChildGeometry( EmbeddedKOfficeObject* ) ) );
3751 TQObject::connect( _t, TQ_SIGNAL( sig_maxColumn(
int ) ), d->canvas, TQ_SLOT( slotMaxColumn(
int ) ) );
3752 TQObject::connect( _t, TQ_SIGNAL( sig_maxRow(
int ) ), d->canvas, TQ_SLOT( slotMaxRow(
int ) ) );
3755 updateBorderButton();
3757 if ( !d->activeSheet )
3765void View::slotSheetRemoved( Sheet *_t )
3769 TQString m_sheetName=_t->sheetName();
3770 d->tabBar->removeTab( _t->sheetName() );
3771 if (doc()->map()->findSheet( doc()->map()->visibleSheets().first()))
3772 setActiveSheet( doc()->map()->findSheet( doc()->map()->visibleSheets().first() ));
3774 d->activeSheet = 0L;
3776 TQValueList<Reference>::Iterator it;
3777 TQValueList<Reference> area=doc()->listArea();
3778 for ( it = area.begin(); it != area.end(); ++it )
3781 if ( (*it).sheet_name == m_sheetName )
3783 doc()->removeArea( (*it).ref_name );
3788 for ( tbl = doc()->map()->
firstSheet(); tbl != 0L; tbl = doc()->map()->nextSheet() )
3790 tbl->refreshRemoveAreaName((*it).ref_name);
3798void View::removeAllSheets()
3803 setActiveSheet( 0L );
3808void View::setActiveSheet( Sheet * _t,
bool updateSheet )
3810 if ( _t == d->activeSheet )
3817 Sheet * oldSheet = d->activeSheet;
3819 d->activeSheet = _t;
3821 if ( d->activeSheet == 0L )
3827 if ( oldSheet && oldSheet->layoutDirection()==Sheet::RightToLeft != d->activeSheet->layoutDirection()==Sheet::RightToLeft )
3830 doc()->setDisplaySheet( d->activeSheet );
3833 d->tabBar->setActiveTab( _t->sheetName() );
3834 d->vBorderWidget->repaint();
3835 d->hBorderWidget->repaint();
3836 d->activeSheet->setRegionPaintDirty(TQRect(TQPoint(0,0), TQPoint(KS_colMax, KS_rowMax)));
3837 d->canvas->slotMaxColumn( d->activeSheet->maxColumn() );
3838 d->canvas->slotMaxRow( d->activeSheet->maxRow() );
3841 d->actions->showPageBorders->setChecked( d->activeSheet->isShowPageBorders() );
3842 d->actions->protectSheet->setChecked( d->activeSheet->isProtected() );
3843 d->actions->protectDoc->setChecked( doc()->map()->isProtected() );
3844 d->adjustActions( !d->activeSheet->isProtected() );
3845 d->adjustWorkbookActions( !doc()->map()->isProtected() );
3848 TQMapIterator<Sheet*, TQPoint> it = d->savedAnchors.find(d->activeSheet);
3849 TQMapIterator<Sheet*, TQPoint> it2 = d->savedMarkers.find(d->activeSheet);
3850 TQMapIterator<Sheet*, KoPoint> it3 = d->savedOffsets.find(d->activeSheet);
3853 TQPoint newAnchor = (it == d->savedAnchors.end()) ? TQPoint(1,1) : *it;
3854 TQPoint newMarker = (it2 == d->savedMarkers.end()) ? TQPoint(1,1) : *it2;
3856 d->selection->clear();
3857 d->selection->setSheet( d->activeSheet );
3858 d->selection->initialize(TQRect(newMarker, newAnchor));
3860 d->canvas->scrollToCell(newMarker);
3861 if (it3 != d->savedOffsets.end())
3863 d->canvas->setXOffset((*it3).x());
3864 d->canvas->setYOffset((*it3).y());
3865 d->horzScrollBar->setValue((
int)(*it3).x());
3866 d->vertScrollBar->setValue((
int)(*it3).y());
3873void View::slotSheetRenamed( Sheet* sheet,
const TQString& old_name )
3876 d->tabBar->renameTab( old_name, sheet->sheetName() );
3880void View::slotSheetHidden( Sheet* )
3883 updateShowSheetMenu();
3887void View::slotSheetShown( Sheet* )
3890 d->tabBar->setTabs( doc()->map()->visibleSheets() );
3891 updateShowSheetMenu();
3897 if ( activeSheet()->sheetName() == _name )
3900 Sheet *t = doc()->map()->
findSheet( _name );
3903 kdDebug(36001) <<
"Unknown sheet " << _name << endl;
3907 d->canvas->closeEditor();
3908 setActiveSheet( t,
false );
3910 d->canvas->updateEditor();
3913 updateBorderButton();
3916 d->vBorderWidget->repaint();
3917 d->hBorderWidget->repaint();
3918 d->canvas->slotMaxColumn( d->activeSheet->maxColumn() );
3919 d->canvas->slotMaxRow( d->activeSheet->maxRow() );
3920 t->setRegionPaintDirty( t->visibleRect( d->canvas ) );
3924void View::moveSheet(
unsigned sheet,
unsigned target )
3926 if( doc()->map()->isProtected() )
return;
3928 TQStringList vs = doc()->map()->visibleSheets();
3930 if( target >= vs.count() )
3931 doc()->map()->
moveSheet( vs[ sheet ], vs[ vs.count()-1 ],
false );
3933 doc()->map()->
moveSheet( vs[ sheet ], vs[ target ],
true );
3935 d->tabBar->moveTab( sheet, target );
3941 if( doc()->map()->isProtected() )
return;
3942 if( d->activeSheet->isProtected() )
return;
3944 bool directionChanged =
false;
3946 SheetPropertiesDialog* dlg =
new SheetPropertiesDialog(
this );
3947 dlg->setLayoutDirection( d->activeSheet->layoutDirection() );
3948 dlg->setAutoCalc( d->activeSheet->getAutoCalc() );
3949 dlg->setShowGrid( d->activeSheet->getShowGrid() );
3950 dlg->setShowPageBorders( d->activeSheet->isShowPageBorders() );
3951 dlg->setShowFormula( d->activeSheet->getShowFormula() );
3952 dlg->setHideZero( d->activeSheet->getHideZero() );
3953 dlg->setShowFormulaIndicator( d->activeSheet->getShowFormulaIndicator() );
3954 dlg->setShowCommentIndicator( d->activeSheet->getShowCommentIndicator() );
3955 dlg->setColumnAsNumber( d->activeSheet->getShowColumnNumber() );
3956 dlg->setLcMode( d->activeSheet->getLcMode() );
3957 dlg->setCapitalizeFirstLetter( d->activeSheet->getFirstLetterUpper() );
3963 if ( d->activeSheet->layoutDirection() != dlg->layoutDirection() )
3964 directionChanged =
true;
3966 command->setLayoutDirection( dlg->layoutDirection() );
3967 command->setAutoCalc( dlg->autoCalc() );
3968 command->setShowGrid( dlg->showGrid() );
3969 command->setShowPageBorders( dlg->showPageBorders() );
3970 command->setShowFormula( dlg->showFormula() );
3971 command->setHideZero( dlg->hideZero() );
3972 command->setShowFormulaIndicator( dlg->showFormulaIndicator() );
3973 command->setShowCommentIndicator( dlg->showCommentIndicator() );
3974 command->setColumnAsNumber( dlg->columnAsNumber() );
3975 command->setLcMode( dlg->lcMode() );
3976 command->setCapitalizeFirstLetter( dlg->capitalizeFirstLetter() );
3983 if ( directionChanged )
3986 d->horzScrollBar->setValue( d->horzScrollBar->maxValue() -
3987 d->horzScrollBar->value() );
3988 d->hBorderWidget->update();
3992void View::insertSheet()
3994 if ( doc()->map()->isProtected() )
3996 KMessageBox::error( 0, i18n (
"You cannot change a protected sheet." ) );
4001 d->canvas->closeEditor();
4003 KCommand* command =
new AddSheetCommand( t );
4006 setActiveSheet( t );
4008 if ( doc()->map()->visibleSheets().count() > 1 )
4010 d->actions->removeSheet->setEnabled(
true );
4011 d->actions->hideSheet->setEnabled(
true );
4017void View::hideSheet()
4019 if ( !d->activeSheet )
4022 if ( doc()->map()->visibleSheets().count() == 1)
4024 KMessageBox::error(
this, i18n(
"You cannot hide the last visible sheet.") );
4028 TQStringList vs = doc()->map()->visibleSheets();
4029 int i = vs.findIndex( d->activeSheet->tableName() ) - 1;
4031 TQString sn = vs[i];
4035 KCommand* command =
new HideSheetCommand( activeSheet() );
4041 d->tabBar->removeTab( d->activeSheet->sheetName() );
4042 d->tabBar->setActiveTab( sn );
4045void View::showSheet()
4047 if ( !d->activeSheet )
4050 ShowDialog dlg(
this,
"Sheet show");
4054void View::copySelection()
4056 if ( !d->activeSheet )
4064 if ( !d->canvas->editor() )
4066 d->activeSheet->copySelection( selectionInfo() );
4071 d->canvas->editor()->copy();
4074void View::copyAsText()
4076 if ( !d->activeSheet )
4078 d->activeSheet->copyAsText( selectionInfo() );
4082void View::cutSelection()
4084 if ( !d->activeSheet )
4095 KMacroCommand * macroCommand = 0L;
4096 TQPtrListIterator<EmbeddedObject> it( doc()->embeddedObjects() );
4097 for ( ; it.current() ; ++it )
4099 if ( it.current()->sheet() ==
canvasWidget()->activeSheet() && it.current()->isSelected() )
4102 macroCommand =
new KMacroCommand( i18n(
"Cut Objects" ) );
4103 RemoveObjectCommand *cmd =
new RemoveObjectCommand( it.current(),
true );
4104 macroCommand->addCommand( cmd );
4111 macroCommand->execute();
4116 if ( !d->canvas->editor())
4118 d->activeSheet->cutSelection( selectionInfo() );
4123 d->canvas->editor()->cut();
4131 if ( !d->activeSheet )
4134 if (!koDocument()->isReadWrite())
4137 TQMimeSource *data = TQApplication::clipboard()->data( TQClipboard::Clipboard );
4138 for (
int i=0; data->format(i) != 0; i++ )
4139 kdDebug() <<
"format:" << data->format(i) << endl;
4141 if ( data->provides( KoStoreDrag::mimeType(
"application/vnd.oasis.opendocument.spreadsheet" ) ))
4144 TQCString returnedTypeMime =
"application/vnd.oasis.opendocument.spreadsheet";
4145 const TQByteArray arr = data->encodedData( returnedTypeMime );
4148 TQBuffer buffer( arr );
4149 KoStore * store = KoStore::createStore( &buffer, KoStore::Read );
4151 KoOasisStore oasisStore( store );
4153 TQString errorMessage;
4154 bool ok = oasisStore.loadAndParse(
"content.xml", doc, errorMessage );
4156 kdError(32001) <<
"Error parsing content.xml: " << errorMessage << endl;
4160 KoOasisStyles oasisStyles;
4161 TQDomDocument stylesDoc;
4162 (void)oasisStore.loadAndParse(
"styles.xml", stylesDoc, errorMessage );
4164 oasisStyles.createStyleMap( stylesDoc,
true );
4166 oasisStyles.createStyleMap( doc,
false );
4169 TQDomElement content = doc.documentElement();
4170 TQDomElement realBody ( KoDom::namedItemNS( content, KoXmlNS::office,
"body" ) );
4171 if ( realBody.isNull() )
4173 kdDebug() <<
"Invalid OASIS OpenDocument file. No office:body tag found." << endl;
4176 TQDomElement body = KoDom::namedItemNS( realBody, KoXmlNS::office,
"spreadsheet" );
4178 if ( body.isNull() )
4180 kdError(32001) <<
"No office:spreadsheet found!" << endl;
4181 TQDomElement childElem;
4183 forEachElement( childElem, realBody ) {
4184 localName = childElem.localName();
4189 KoOasisLoadingContext context( d->doc, oasisStyles, store );
4190 Q_ASSERT( !oasisStyles.officeStyle().isNull() );
4193 d->doc->styleManager()->loadOasisStyleTemplate( oasisStyles );
4196 d->doc->loadOasisAreaName( body );
4197 d->doc->loadOasisCellValidation( body );
4200 bool result = d->doc->map()->loadOasis( body, context );
4208 TQPixmap clipboardPixmap = TQApplication::clipboard()->pixmap( TQClipboard::Clipboard );
4209 if (!clipboardPixmap.isNull())
4215 doc()->emitBeginOperation(
false );
4216 if ( !d->canvas->editor() )
4219 d->activeSheet->paste( d->selection->lastRange(),
true,
4227 d->canvas->editor()->paste();
4229 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
4232void View::specialPaste()
4234 if ( !d->activeSheet )
4237 SpecialDialog dlg(
this,
"Special Paste" );
4240 if ( d->activeSheet->getAutoCalc() )
4242 doc()->emitBeginOperation(
false );
4243 d->activeSheet->recalc();
4244 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
4251void View::removeComment()
4253 if ( !d->activeSheet )
4256 doc()->emitBeginOperation(
false);
4257 d->activeSheet->setSelectionRemoveComment( selectionInfo() );
4261 doc()->emitEndOperation();
4265void View::changeAngle()
4267 if ( !d->activeSheet )
4270 AngleDialog dlg(
this,
"Angle" ,
4271 TQPoint( d->canvas->markerColumn(), d->canvas->markerRow() ));
4275 d->activeSheet->adjustArea(*selectionInfo());
4279void View::setSelectionAngle(
int angle )
4281 doc()->emitBeginOperation(
false );
4283 if ( d->activeSheet != NULL )
4285 d->activeSheet->setSelectionAngle( selectionInfo(), angle );
4286 d->activeSheet->adjustArea(*selectionInfo());
4290 doc()->emitEndOperation();
4296 if( !d->activeSheet )
4298 d->activeSheet->mergeCells(*selectionInfo());
4301void View::mergeCellHorizontal()
4304 if( !d->activeSheet )
4306 d->activeSheet->mergeCells(*selectionInfo(),
true);
4309void View::mergeCellVertical()
4312 if( !d->activeSheet )
4314 d->activeSheet->mergeCells(*selectionInfo(),
false,
true);
4320 if( !d->activeSheet )
4322 d->activeSheet->dissociateCells(*selectionInfo());
4326void View::increaseIndent()
4328 if ( !d->activeSheet )
4331 doc()->emitBeginOperation(
false );
4332 d->activeSheet->increaseIndent( d->selection );
4336 doc()->emitEndOperation();
4339void View::decreaseIndent()
4341 if ( !d->activeSheet )
4344 doc()->emitBeginOperation(
false );
4345 int column = d->canvas->markerColumn();
4346 int row = d->canvas->markerRow();
4348 d->activeSheet->decreaseIndent( d->selection );
4349 Cell * cell = d->activeSheet->cellAt( column, row );
4351 if ( !d->activeSheet->isProtected() )
4352 d->actions->decreaseIndent->setEnabled( cell->format()->getIndent( column, row ) > 0.0 );
4355 doc()->emitEndOperation();
4358void View::goalSeek()
4360 if ( d->canvas->editor() )
4362 d->canvas->deleteEditor(
true );
4365 GoalSeekDialog * dlg
4366 =
new GoalSeekDialog(
this, TQPoint( d->canvas->markerColumn(),
4367 d->canvas->markerRow() ),
4373void View::subtotals()
4378 TQRect selection( d->selection->selection() );
4379 if ( ( selection.width() < 2 ) || ( selection.height() < 2 ) )
4381 KMessageBox::error(
this, i18n(
"You must select multiple cells.") );
4385 SubtotalDialog dlg(
this, selection,
"SubtotalDialog" );
4388 doc()->emitBeginOperation(
false );
4390 d->selection->initialize( TQRect(dlg.selection().topLeft(), dlg.selection().bottomRight()));
4391 doc()->emitEndOperation( selection );
4395void View::multipleOperations()
4397 if ( d->canvas->editor() )
4399 d->canvas->deleteEditor(
true );
4405void View::textToColumns()
4410 d->canvas->closeEditor();
4412 TQRect area=d->selection->selection();
4415 area.setRight(area.left());
4425 CSVDialog dialog(
this,
"CSVDialog", area, CSVDialog::Column );
4426 if( !dialog.cancelled() )
4430void View::consolidate()
4432 d->canvas->closeEditor();
4433 ConsolidateDialog * dlg =
new ConsolidateDialog(
this,
"ConsolidateDialog" );
4438void View::sortList()
4440 if (!activeSheet())
return;
4442 ListDialog dlg(
this,
"List selection" );
4446void View::gotoCell()
4448 if (!activeSheet())
return;
4450 GotoDialog dlg(
this,
"GotoCell" );
4456 if (!activeSheet())
return;
4458 FindDlg dlg(
this,
"Find", d->findOptions, d->findStrings );
4459 dlg.setHasSelection( !d->selection->isSingular() );
4460 dlg.setHasCursor(
true );
4461 if ( KFindDialog::Accepted != dlg.exec() )
4465 d->findOptions = dlg.options();
4466 d->findStrings = dlg.findHistory();
4467 d->typeValue = dlg.searchType();
4468 d->directionValue = dlg.searchDirection();
4473 d->find =
new KFind( dlg.pattern(), dlg.options(),
this );
4476 d->searchInSheets.currentSheet = activeSheet();
4477 d->searchInSheets.firstSheet = d->searchInSheets.currentSheet;
4485void View::initFindReplace()
4487 KFind* findObj = d->find ? d->find : d->replace;
4488 Q_ASSERT( findObj );
4489 connect(findObj, TQ_SIGNAL( highlight(
const TQString &,
int,
int ) ),
4490 this, TQ_SLOT(
slotHighlight(
const TQString &,
int,
int ) ) );
4491 connect(findObj, TQ_SIGNAL( findNext() ),
4492 this, TQ_SLOT( findNext() ) );
4494 bool bck = d->findOptions & KFindDialog::FindBackwards;
4495 Sheet* currentSheet = d->searchInSheets.currentSheet;
4497 TQRect region = ( d->findOptions & KFindDialog::SelectedText )
4498 ? d->selection->selection()
4499 : TQRect( 1, 1, currentSheet->maxColumn(), currentSheet->maxRow() );
4501 int colStart = !bck ? region.left() : region.right();
4502 int colEnd = !bck ? region.right() : region.left();
4503 int rowStart = !bck ? region.top() :region.bottom();
4504 int rowEnd = !bck ? region.bottom() : region.top();
4505 if ( d->findOptions & KFindDialog::FromCursor ) {
4506 TQPoint marker( d->selection->marker() );
4507 colStart = marker.x();
4508 rowStart = marker.y();
4510 d->findLeftColumn = region.left();
4511 d->findRightColumn = region.right();
4512 d->findPos = TQPoint( colStart, rowStart );
4513 d->findEnd = TQPoint( colEnd, rowEnd );
4518void View::findNext()
4520 KFind* findObj = d->find ? d->find : d->replace;
4525 KFind::Result res = KFind::NoMatch;
4526 Cell* cell = findNextCell();
4527 bool forw = ! ( d->findOptions & KFindDialog::FindBackwards );
4528 while ( res == KFind::NoMatch && cell )
4530 if ( findObj->needData() )
4532 if ( d->typeValue == FindOption::Note )
4533 findObj->setData( cell->format()->comment( cell->column(), cell->row() ) );
4535 findObj->setData( cell->text() );
4536 d->findPos = TQPoint( cell->column(), cell->row() );
4542 res = d->find->find();
4544 res = d->replace->replace();
4546 if ( res == KFind::NoMatch ) {
4548 if ( d->directionValue == FindOption::Row )
4562 cell = findNextCell();
4566 if ( res == KFind::NoMatch )
4570 if ( findObj->shouldRestart() ) {
4571 d->findOptions &= ~KFindDialog::FromCursor;
4572 findObj->resetCounts();
4577 d->find->closeFindNextDialog();
4579 d->replace->closeReplaceNextDialog();
4584Cell* View::nextFindValidCell(
int col,
int row )
4586 Cell *cell = d->searchInSheets.currentSheet->cellAt( col, row );
4587 if ( cell->isDefault() || cell->isObscured() || cell->isFormula() )
4589 if ( d->typeValue == FindOption::Note && cell && cell->format()->comment(col, row).isEmpty())
4594Cell* View::findNextCell()
4599 Sheet* sheet = d->searchInSheets.currentSheet;
4601 bool forw = ! ( d->findOptions & KFindDialog::FindBackwards );
4602 int col = d->findPos.x();
4603 int row = d->findPos.y();
4604 int maxRow = sheet->maxRow();
4607 if ( d->directionValue == FindOption::Row )
4609 while ( !cell && row != d->findEnd.y() && (forw ? row < maxRow : row >= 0) )
4611 while ( !cell && (forw ? col <= d->findRightColumn : col >= d->findLeftColumn) )
4613 cell = nextFindValidCell( col, row );
4621 col = d->findLeftColumn;
4624 col = d->findRightColumn;
4632 while ( !cell && (forw ? col <= d->findRightColumn : col >= d->findLeftColumn) )
4634 while ( !cell && row != d->findEnd.y() && (forw ? row < maxRow : row >= 0) )
4636 cell = nextFindValidCell( col, row );
4660void View::findPrevious()
4662 KFind* findObj = d->find ? d->find : d->replace;
4668 int opt = d->findOptions;
4669 bool forw = ! ( opt & KFindDialog::FindBackwards );
4671 d->findOptions = ( opt | KFindDialog::FindBackwards );
4673 d->findOptions = ( opt & ~KFindDialog::FindBackwards );
4677 d->findOptions = opt;
4682 if (!d->activeSheet)
4685 SearchDlg dlg(
this,
"Replace", d->findOptions, d->findStrings, d->replaceStrings );
4686 dlg.setHasSelection( !d->selection->isSingular() );
4687 dlg.setHasCursor(
true );
4688 if ( KReplaceDialog::Accepted != dlg.exec() )
4691 d->findOptions = dlg.options();
4692 d->findStrings = dlg.findHistory();
4693 d->replaceStrings = dlg.replacementHistory();
4694 d->typeValue = dlg.searchType();
4703 if (dlg.pattern() ==
"^" && dlg.replacement().isEmpty())
4705 d->replace =
new KReplace( dlg.pattern(), dlg.replacement(), dlg.options() );
4707 d->searchInSheets.currentSheet = activeSheet();
4708 d->searchInSheets.firstSheet = d->searchInSheets.currentSheet;
4710 connect( d->replace, TQ_SIGNAL( replace(
const TQString &,
int,
int,
int ) ),
4711 this, TQ_SLOT(
slotReplace(
const TQString &,
int,
int,
int ) ) );
4713 if ( !doc()->undoLocked() )
4715 TQRect region( d->findPos, d->findEnd );
4717 UndoChangeAreaTextCell *undo =
new UndoChangeAreaTextCell( doc(), d->searchInSheets.currentSheet, region );
4718 doc()->addCommand( undo );
4726 Cell *cell = activeSheet()->cellAt(
canvasWidget()->markerColumn(),
4728 if ( cell->text() != 0L )
4729 d->editWidget->setText( cell->text() );
4731 d->editWidget->setText(
"" );
4737 d->selection->initialize( d->findPos );
4738 KDialogBase *baseDialog=0L;
4740 baseDialog = d->find->findNextDialog();
4742 baseDialog = d->replace->replaceNextDialog();
4743 kdDebug()<<
" baseDialog :"<<baseDialog<<endl;
4744 TQRect globalRect( d->findPos, d->findEnd );
4745 globalRect.moveTopLeft(
canvasWidget()->mapToGlobal( globalRect.topLeft() ) );
4746 KDialog::avoidArea( baseDialog, TQRect( d->findPos, d->findEnd ));
4752 Cell *cell = d->searchInSheets.currentSheet->cellAt( d->findPos );
4755 cell->setDisplayDirtyFlag();
4756 if ( d->typeValue == FindOption::Value )
4757 cell->setCellText( newText );
4758 else if ( d->typeValue == FindOption::Note )
4759 cell->format()->setComment( newText );
4760 cell->clearDisplayDirtyFlag();
4763void View::conditional()
4765 TQRect rect( d->selection->selection() );
4767 if ( util_isRowOrColumnSelected(rect))
4769 KMessageBox::error(
this, i18n(
"Area is too large.") );
4773 ConditionalDialog dlg(
this,
"ConditionalDialog", rect);
4778void View::validity()
4780 TQRect rect( d->selection->selection() );
4782 if (d->selection->isColumnOrRowSelected())
4784 KMessageBox::error(
this, i18n(
"Area is too large."));
4788 DlgValidity dlg(
this,
"validity",rect);
4794void View::insertSeries()
4796 d->canvas->closeEditor();
4797 SeriesDlg dlg(
this,
"Series", TQPoint( d->canvas->markerColumn(), d->canvas->markerRow() ) );
4803 if ( d->selection->isSingular() )
4805 KMessageBox::error(
this, i18n(
"You must select multiple cells.") );
4809 SortDialog dlg(
this,
"Sort" );
4813void View::removeHyperlink()
4815 TQPoint marker( d->selection->marker() );
4816 Cell * cell = d->activeSheet->cellAt( marker );
4818 if( cell->link().isEmpty() )
return;
4820 LinkCommand* command =
new LinkCommand( cell, TQString(), TQString() );
4821 doc()->addCommand( command );
4825 d->editWidget->setText( cell->text() );
4828void View::insertHyperlink()
4833 d->canvas->closeEditor();
4835 TQPoint marker( d->selection->marker() );
4836 Cell* cell = d->activeSheet->cellAt( marker );
4838 LinkDialog* dlg =
new LinkDialog(
this );
4839 dlg->setCaption( i18n(
"Insert Link" ) );
4842 dlg->setText( cell->text() );
4843 if( !cell->link().isEmpty() )
4845 dlg->setCaption( i18n(
"Edit Link" ) );
4846 dlg->setLink( cell->link() );
4850 if( dlg->exec() == KDialog::Accepted )
4852 cell = d->activeSheet->nonDefaultCell( marker );
4854 LinkCommand* command =
new LinkCommand( cell, dlg->text(), dlg->link() );
4855 doc()->addCommand( command );
4860 d->editWidget->setText( cell->text() );
4865void View::insertFromDatabase()
4868 d->canvas->closeEditor();
4870 TQRect rect = d->selection->selection();
4872 TQStringList str = TQSqlDatabase::drivers();
4873 if ( str.isEmpty() )
4875 KMessageBox::error(
this, i18n(
"No database drivers available. To use this feature you need "
4876 "to install the necessary TQt 3 database drivers.") );
4881 doc()->doNotPaint(
true );
4882 DatabaseDialog dlg(
this, rect,
"DatabaseDialog");
4884 doc()->doNotPaint(
false );
4888void View::insertFromTextfile()
4890 d->canvas->closeEditor();
4892 doc()->doNotPaint(
true );
4893 CSVDialog dialog(
this,
"CSVDialog", d->selection->selection(), CSVDialog::File );
4894 if( !dialog.cancelled() )
4896 doc()->doNotPaint(
false );
4899void View::insertFromClipboard()
4901 d->canvas->closeEditor();
4902 doc()->doNotPaint(
true );
4903 CSVDialog dialog(
this,
"CSVDialog", d->selection->selection(), CSVDialog::Clipboard );
4904 if( !dialog.cancelled() )
4906 doc()->doNotPaint(
false );
4909void View::setupPrinter( KPrinter &prt )
4914 SheetPrint* print = d->activeSheet->print();
4917 KoFormat pageFormat = print->paperFormat();
4919 prt.setPageSize(
static_cast<KPrinter::PageSize
>( KoPageFormat::printerPageSize( pageFormat ) ) );
4921 if ( print->orientation() == PG_LANDSCAPE || pageFormat == PG_SCREEN )
4922 prt.setOrientation( KPrinter::Landscape );
4924 prt.setOrientation( KPrinter::Portrait );
4926 prt.setFullPage(
true );
4930 KPSheetSelectPage* sheetpage =
new KPSheetSelectPage();
4931 prt.addDialogPage(sheetpage);
4934 TQPtrList<Sheet> sheetlist = doc()->map()->sheetList();
4935 Sheet* sheet = sheetlist.last();
4938 kdDebug() <<
"Adding " << sheet->sheetName() << endl;
4939 sheetpage->prependAvailableSheet(sheet->sheetName());
4940 sheet = sheetlist.prev();
4944void View::print( KPrinter &prt )
4950 Sheet* selectedsheet = this->activeSheet();
4955 if (sheetlist.empty())
4957 kdDebug() <<
"No sheet for printing selected, printing active sheet" << endl;
4958 sheetlist.append(d->activeSheet->sheetName());
4962 painter.begin( &prt );
4964 bool firstpage =
true;
4966 TQStringList::iterator sheetlistiterator;
4967 for (sheetlistiterator = sheetlist.begin(); sheetlistiterator != sheetlist.end(); ++sheetlistiterator)
4969 kdDebug() <<
" printing sheet " << *sheetlistiterator << endl;
4970 Sheet* sheet = doc()->map()->findSheet(*sheetlistiterator);
4973 kdWarning() << i18n(
"Sheet %1 could not be found for printing").arg(*sheetlistiterator) << endl;
4977 setActiveSheet(sheet,
false);
4979 SheetPrint* print = d->activeSheet->print();
4985 kdDebug() <<
" inserting new page" << endl;
4989 if ( d->canvas->editor() )
4991 d->canvas->deleteEditor(
true );
4994 int oldZoom = doc()->zoom();
5001 TQPaintDeviceMetrics metrics( &prt );
5003 int dpiX = metrics.logicalDpiX();
5004 int dpiY = metrics.logicalDpiY();
5006 doc()->setZoomAndResolution(
int( print->zoom() * 100 ), dpiX, dpiY );
5009 KoOrientation _orient = print->orientation();
5012 if ( prt.orientation() == KPrinter::Landscape )
5014 print->setPaperOrientation( PG_LANDSCAPE );
5018 print->setPaperOrientation( PG_PORTRAIT );
5021 bool result = print->print( painter, &prt );
5024 print->setPaperOrientation( _orient );
5026 doc()->setZoomAndResolution( oldZoom, KoGlobal::dpiX(), KoGlobal::dpiY() );
5027 doc()->newZoomAndResolution(
true,
false );
5030 doc()->emitBeginOperation(
false );
5031 setZoom( oldZoom,
false );
5032 doc()->emitEndOperation();
5037 if( !prt.previewOnly() )
5039 KMessageBox::information( 0,
5040 i18n(
"Nothing to print for sheet %1.").arg(
5041 d->activeSheet->sheetName()) );
5050 this->setActiveSheet(selectedsheet);
5053void View::insertChart(
const TQRect& _geometry, KoDocumentEntry& _e )
5055 if ( !d->activeSheet )
5059 KoRect unzoomedRect = doc()->unzoomRect( _geometry );
5060 unzoomedRect.moveBy( d->canvas->xOffset(), d->canvas->yOffset() );
5062 InsertObjectCommand *cmd = 0;
5063 if ( d->selection->isColumnOrRowSelected() )
5065 KMessageBox::error(
this, i18n(
"Area is too large."));
5069 cmd =
new InsertObjectCommand( unzoomedRect, _e, d->selection->selection(), d->canvas );
5071 doc()->addCommand( cmd );
5077 if ( !d->activeSheet )
5081 KoRect unzoomedRect = doc()->unzoomRect( _geometry );
5082 unzoomedRect.moveBy( d->canvas->xOffset(), d->canvas->yOffset() );
5084 InsertObjectCommand *cmd =
new InsertObjectCommand( unzoomedRect, _e, d->canvas );
5085 doc()->addCommand( cmd );
5091 TQPoint marker=selectionInfo()->marker();
5093 return KoPoint( d->activeSheet->dblColumnPos(marker.x()),
5094 d->activeSheet->dblRowPos(marker.y()) );
5097void View::insertPicture()
5106 KURL file = KFileDialog::getImageOpenURL( TQString(), d->canvas );
5111 if ( !d->activeSheet )
5114 InsertObjectCommand *cmd =
new InsertObjectCommand( KoRect(
markerDocumentPosition(),KoSize(0,0)) , file, d->canvas );
5115 doc()->addCommand( cmd );
5119void View::slotUpdateChildGeometry( EmbeddedKOfficeObject * )
5145void View::toggleProtectDoc(
bool mode )
5147 if ( !doc() || !doc()->map() )
5153 int result = KPasswordDialog::getNewPassword( password, i18n(
"Protect Document" ) );
5154 if ( result != KPasswordDialog::Accepted )
5156 d->actions->protectDoc->setChecked(
false );
5160 TQCString hash(
"" );
5161 if ( password.length() > 0 )
5162 SHA1::getHash( password, hash );
5163 doc()->map()->setProtected( hash );
5167 int result = KPasswordDialog::getPassword( password, i18n(
"Unprotect Document" ) );
5168 if ( result != KPasswordDialog::Accepted )
5170 d->actions->protectDoc->setChecked(
true );
5174 TQCString hash(
"" );
5175 if ( password.length() > 0 )
5176 SHA1::getHash( password, hash );
5177 if ( !doc()->map()->checkPassword( hash ) )
5179 KMessageBox::error( 0, i18n(
"Password is incorrect." ) );
5180 d->actions->protectDoc->setChecked(
true );
5184 doc()->map()->setProtected( TQCString() );
5187 doc()->setModified(
true );
5188 d->adjustWorkbookActions( !mode );
5191void View::toggleProtectSheet(
bool mode )
5193 if ( !d->activeSheet )
5199 int result = KPasswordDialog::getNewPassword( password, i18n(
"Protect Sheet" ) );
5200 if ( result != KPasswordDialog::Accepted )
5202 d->actions->protectSheet->setChecked(
false );
5206 TQCString hash(
"" );
5207 if ( password.length() > 0 )
5208 SHA1::getHash( password, hash );
5210 d->activeSheet->setProtected( hash );
5214 int result = KPasswordDialog::getPassword( password, i18n(
"Unprotect Sheet" ) );
5215 if ( result != KPasswordDialog::Accepted )
5217 d->actions->protectSheet->setChecked(
true );
5221 TQCString hash(
"" );
5222 if ( password.length() > 0 )
5223 SHA1::getHash( password, hash );
5225 if ( !d->activeSheet->checkPassword( hash ) )
5227 KMessageBox::error( 0, i18n(
"Password is incorrect." ) );
5228 d->actions->protectSheet->setChecked(
true );
5232 d->activeSheet->setProtected( TQCString() );
5234 doc()->setModified(
true );
5235 d->adjustActions( !mode );
5236 doc()->emitBeginOperation();
5240 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
5243void View::togglePageBorders(
bool mode )
5245 if ( !d->activeSheet )
5248 doc()->emitBeginOperation(
false );
5249 d->activeSheet->setShowPageBorders( mode );
5250 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
5253void View::viewZoom(
const TQString & s )
5256 int oldZoom = doc()->zoom();
5259 TQRegExp regexp(
"(\\d+)");
5261 int newZoom=regexp.cap(1).toInt(&ok);
5262 if ( !ok || newZoom < 10 )
5264 if ( newZoom != oldZoom )
5266 d->actions->viewZoom->setZoom( newZoom );
5268 doc()->emitBeginOperation(
false );
5270 d->canvas->closeEditor();
5271 setZoom( newZoom,
true );
5275 TQRect r( d->activeSheet->visibleRect( d->canvas ) );
5276 r.setWidth( r.width() + 2 );
5277 doc()->emitEndOperation( r );
5282void View::setZoom(
int zoom,
bool )
5284 kdDebug() <<
"---------SetZoom: " << zoom << endl;
5287 doc()->emitBeginOperation(
false );
5289 doc()->setZoomAndResolution( zoom, KoGlobal::dpiX(), KoGlobal::dpiY());
5292 Q_ASSERT(d->activeSheet);
5295 d->activeSheet->setRegionPaintDirty(TQRect(TQPoint(0,0), TQPoint(KS_colMax, KS_rowMax)));
5297 doc()->refreshInterface();
5298 doc()->emitEndOperation();
5303 doc()->setShowStatusBar( b );
5309 doc()->setShowTabBar( b );
5315 doc()->setShowFormulaBar( b );
5319void View::preference()
5321 if ( !d->activeSheet )
5324 PreferenceDialog dlg(
this,
"Preference" );
5327 doc()->emitBeginOperation(
false );
5328 d->activeSheet->refreshPreference();
5329 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
5333void View::addModifyComment()
5335 if ( !d->activeSheet )
5338 CommentDialog dlg(
this,
"comment",
5339 TQPoint( d->canvas->markerColumn(),
5340 d->canvas->markerRow() ) );
5345void View::setSelectionComment( TQString comment )
5347 if ( d->activeSheet != NULL )
5349 doc()->emitBeginOperation(
false );
5351 d->activeSheet->setSelectionComment( selectionInfo(), comment.stripWhiteSpace() );
5355 doc()->emitEndOperation();
5359void View::editCell()
5361 if ( d->canvas->editor() )
5364 d->canvas->createEditor(
true);
5367bool View::showSheet(
const TQString& sheetName) {
5368 Sheet *t=doc()->map()->findSheet(sheetName);
5371 kdDebug(36001) <<
"Unknown sheet " <<sheetName<< endl;
5374 d->canvas->closeEditor();
5375 setActiveSheet( t );
5382 Sheet * t = doc()->map()->nextSheet( activeSheet() );
5385 kdDebug(36001) <<
"Unknown sheet " << endl;
5388 d->canvas->closeEditor();
5389 setActiveSheet( t );
5390 d->tabBar->setActiveTab( t->sheetName() );
5391 d->tabBar->ensureVisible( t->sheetName() );
5396 Sheet * t = doc()->map()->previousSheet( activeSheet() );
5399 kdDebug(36001) <<
"Unknown sheet " << endl;
5402 d->canvas->closeEditor();
5403 setActiveSheet( t );
5404 d->tabBar->setActiveTab( t->sheetName() );
5405 d->tabBar->ensureVisible( t->sheetName() );
5410 Sheet *t = doc()->map()->firstSheet();
5413 kdDebug(36001) <<
"Unknown sheet " << endl;
5416 d->canvas->closeEditor();
5417 setActiveSheet( t );
5418 d->tabBar->setActiveTab( t->sheetName() );
5419 d->tabBar->ensureVisible( t->sheetName() );
5424 Sheet *t = doc()->map()->lastSheet( );
5427 kdDebug(36001) <<
"Unknown sheet " << endl;
5430 d->canvas->closeEditor();
5431 setActiveSheet( t );
5432 d->tabBar->setActiveTab( t->sheetName() );
5433 d->tabBar->ensureVisible( t->sheetName() );
5436void View::keyPressEvent ( TQKeyEvent* _ev )
5439 if ( _ev->state() & ( TQt::AltButton | TQt::ControlButton ) )
5441 if ( _ev->state() & ( TQt::ControlButton ) )
5443 switch( _ev->key() )
5447 if ( _ev->state() & TQt::ShiftButton )
5448 d->activeSheet->printDebug();
5451 TQWidget::keyPressEvent( _ev );
5455 TQWidget::keyPressEvent( _ev );
5458 TQApplication::sendEvent( d->canvas, _ev );
5511int View::leftBorder()
const
5513 return int( d->canvas->doc()->zoomItX( YBORDER_WIDTH ) );
5516int View::rightBorder()
const
5518 return d->vertScrollBar->width();
5521int View::topBorder()
const
5523 return d->toolWidget->height() + int( d->canvas->doc()->zoomItX( Format::globalRowHeight() + 2 ) );
5526int View::bottomBorder()
const
5528 return d->horzScrollBar->height();
5533 kdDebug() <<
"refreshing view" << endl;
5535 Sheet * sheet = activeSheet();
5539 d->adjustActions( !sheet->isProtected() );
5540 d->actions->viewZoom->setZoom( doc()->zoom() );
5542 bool active = sheet->getShowFormula();
5543 if ( sheet && !sheet->isProtected() )
5545 d->actions->alignLeft->setEnabled( !active );
5546 d->actions->alignCenter->setEnabled( !active );
5547 d->actions->alignRight->setEnabled( !active );
5550 d->tabBar->setReadOnly( !doc()->isReadWrite() || doc()->map()->isProtected() );
5554 d->hBorderWidget->setShown( doc()->showColumnHeader() );
5555 d->vBorderWidget->setShown( doc()->showRowHeader() );
5556 d->vertScrollBar->setShown( doc()->showVerticalScrollBar() );
5557 d->horzScrollBar->setShown( doc()->showHorizontalScrollBar() );
5559 if ( statusBar() ) statusBar()->setShown( doc()->
showStatusBar() );
5561 d->canvas->updatePosWidget();
5563 d->hBorderWidget->setMinimumHeight( doc()->zoomItY( KoGlobal::defaultFont().pointSizeFloat() + 5 ) );
5564 d->vBorderWidget->setMinimumWidth( doc()->zoomItX( YBORDER_WIDTH ) );
5566 Sheet::LayoutDirection sheetDir = sheet->layoutDirection();
5567 bool interfaceIsRTL = TQApplication::reverseLayout();
5569 kdDebug()<<
" sheetDir == Sheet::LeftToRight :"<<( sheetDir == Sheet::LeftToRight )<<endl;
5570 if ((sheetDir == Sheet::LeftToRight && !interfaceIsRTL) ||
5571 (sheetDir == Sheet::RightToLeft && interfaceIsRTL))
5573 d->formulaBarLayout->setDirection( TQBoxLayout::LeftToRight );
5574 d->viewLayout->setOrigin( TQGridLayout::TopLeft );
5575 d->tabScrollBarLayout->setDirection( TQBoxLayout::LeftToRight );
5576 d->tabBar->setReverseLayout( interfaceIsRTL );
5580 d->formulaBarLayout->setDirection( TQBoxLayout::RightToLeft );
5581 d->viewLayout->setOrigin( TQGridLayout::TopRight );
5582 d->tabScrollBarLayout->setDirection( TQBoxLayout::RightToLeft );
5583 d->tabBar->setReverseLayout( !interfaceIsRTL );
5587void View::resizeEvent( TQResizeEvent * )
5596 delete d->popupChild;
5628void View::popupColumnMenu(
const TQPoint & _point )
5630 assert( d->activeSheet );
5632 if ( !koDocument()->isReadWrite() )
5635 delete d->popupColumn ;
5637 d->popupColumn =
new TQPopupMenu(
this );
5639 bool isProtected = d->activeSheet->isProtected();
5643 d->actions->cellLayout->plug( d->popupColumn );
5644 d->popupColumn->insertSeparator();
5645 d->actions->cut->plug( d->popupColumn );
5647 d->actions->copy->plug( d->popupColumn );
5650 d->actions->paste->plug( d->popupColumn );
5651 d->actions->specialPaste->plug( d->popupColumn );
5652 d->actions->insertCellCopy->plug( d->popupColumn );
5653 d->popupColumn->insertSeparator();
5654 d->actions->defaultFormat->plug( d->popupColumn );
5656 if (!d->selection->isColumnOrRowSelected())
5658 d->actions->areaName->plug( d->popupColumn );
5661 d->actions->resizeColumn->plug( d->popupColumn );
5663 d->popupColumn->insertSeparator();
5664 d->actions->insertColumn->plug( d->popupColumn );
5665 d->actions->deleteColumn->plug( d->popupColumn );
5666 d->actions->hideColumn->plug( d->popupColumn );
5668 d->actions->showSelColumns->setEnabled(
false);
5670 ColumnFormat* format;
5672 Region::ConstIterator endOfList = d->selection->constEnd();
5673 for (Region::ConstIterator it = d->selection->constBegin(); it != endOfList; ++it)
5675 TQRect range = (*it)->rect().normalize();
5677 for (col = range.left(); col < range.right(); ++col)
5679 format = activeSheet()->columnFormat(col);
5681 if ( format->isHide() )
5683 d->actions->showSelColumns->setEnabled(
true );
5684 d->actions->showSelColumns->plug( d->popupColumn );
5688 if (range.left() > 1 && col == range.right())
5690 bool allHidden =
true;
5691 for (col = 1; col < range.left(); ++col)
5693 format = activeSheet()->columnFormat(col);
5695 allHidden &= format->isHide();
5699 d->actions->showSelColumns->setEnabled(
true );
5700 d->actions->showSelColumns->plug( d->popupColumn );
5711 TQObject::connect( d->popupColumn, TQ_SIGNAL(activated(
int ) ),
this, TQ_SLOT(
slotActivateTool(
int ) ) );
5713 d->popupColumn->popup( _point );
5718 if ( !d->activeSheet )
5721 d->activeSheet->adjustColumn(*selectionInfo());
5724void View::popupRowMenu(
const TQPoint & _point )
5726 assert( d->activeSheet );
5728 if ( !koDocument()->isReadWrite() )
5731 delete d->popupRow ;
5733 d->popupRow=
new TQPopupMenu();
5735 bool isProtected = d->activeSheet->isProtected();
5739 d->actions->cellLayout->plug( d->popupRow );
5740 d->popupRow->insertSeparator();
5741 d->actions->cut->plug( d->popupRow );
5743 d->actions->copy->plug( d->popupRow );
5746 d->actions->paste->plug( d->popupRow );
5747 d->actions->specialPaste->plug( d->popupRow );
5748 d->actions->insertCellCopy->plug( d->popupRow );
5749 d->popupRow->insertSeparator();
5750 d->actions->defaultFormat->plug( d->popupRow );
5752 if (!d->selection->isColumnOrRowSelected())
5754 d->actions->areaName->plug(d->popupRow);
5757 d->actions->resizeRow->plug( d->popupRow );
5758 d->popupRow->insertItem( i18n(
"Adjust Row"),
this, TQ_SLOT( slotPopupAdjustRow() ) );
5759 d->popupRow->insertSeparator();
5760 d->actions->insertRow->plug( d->popupRow );
5761 d->actions->deleteRow->plug( d->popupRow );
5762 d->actions->hideRow->plug( d->popupRow );
5764 d->actions->showSelColumns->setEnabled(
false);
5767 Region::ConstIterator endOfList = d->selection->constEnd();
5768 for (Region::ConstIterator it = d->selection->constBegin(); it != endOfList; ++it)
5770 TQRect range = (*it)->rect().normalize();
5772 for (row = range.top(); row < range.bottom(); ++row)
5774 format = activeSheet()->rowFormat(row);
5776 if ( format->isHide() )
5778 d->actions->showSelRows->setEnabled(
true );
5779 d->actions->showSelRows->plug( d->popupRow );
5783 if (range.top() > 1 && row == range.bottom())
5785 bool allHidden =
true;
5786 for (row = 1; row < range.top(); ++row)
5788 format = activeSheet()->rowFormat(row);
5790 allHidden &= format->isHide();
5794 d->actions->showSelRows->setEnabled(
true );
5795 d->actions->showSelRows->plug( d->popupRow );
5806 TQObject::connect( d->popupRow, TQ_SIGNAL( activated(
int ) ),
this, TQ_SLOT(
slotActivateTool(
int ) ) );
5807 d->popupRow->popup( _point );
5810void View::slotPopupAdjustRow()
5812 if ( !d->activeSheet )
5815 d->activeSheet->adjustRow(*selectionInfo());
5819void View::slotListChoosePopupMenu( )
5821 if ( !koDocument()->isReadWrite() )
5824 assert( d->activeSheet );
5825 delete d->popupListChoose;
5827 d->popupListChoose =
new TQPopupMenu();
5829 TQRect selection( d->selection->selection() );
5830 Cell * cell = d->activeSheet->cellAt( d->canvas->markerColumn(), d->canvas->markerRow() );
5831 TQString tmp = cell->text();
5832 TQStringList itemList;
5834 for (
int col = selection.left(); col <= selection.right(); ++col )
5836 Cell * c = d->activeSheet->getFirstCellColumn( col );
5839 if ( !c->isPartOfMerged()
5840 && !( col == d->canvas->markerColumn()
5841 && c->row() == d->canvas->markerRow()) )
5843 if ( c->value().isString() && c->text() != tmp && !c->text().isEmpty() )
5845 if ( itemList.findIndex( c->text() ) == -1 )
5846 itemList.append(c->text());
5850 c = d->activeSheet->getNextCellDown( col, c->row() );
5871 for ( TQStringList::Iterator it = itemList.begin(); it != itemList.end();++it )
5872 d->popupListChoose->insertItem( (*it),
id++ );
5876 RowFormat * rl = d->activeSheet->rowFormat( d->canvas->markerRow());
5877 double tx = d->activeSheet->dblColumnPos( d->canvas->markerColumn(), d->canvas );
5878 double ty = d->activeSheet->dblRowPos(d->canvas->markerRow(), d->canvas );
5879 double h = rl->dblHeight( d->canvas );
5880 if ( cell->extraYCells() )
5881 h = cell->extraHeight();
5884 if ( d->activeSheet->layoutDirection()==Sheet::RightToLeft )
5889 TQPoint p( (
int)tx, (
int)ty );
5890 TQPoint p2 = d->canvas->mapToGlobal( p );
5892 if ( d->activeSheet->layoutDirection()==Sheet::RightToLeft )
5894 p2.setX( p2.x() - d->popupListChoose->sizeHint().width() + 1 );
5897 d->popupListChoose->popup( p2 );
5898 TQObject::connect( d->popupListChoose, TQ_SIGNAL( activated(
int ) ),
5905 TQString tmp = d->popupListChoose->text(
id );
5906 int x = d->canvas->markerColumn();
5907 int y = d->canvas->markerRow();
5908 Cell * cell = d->activeSheet->nonDefaultCell( x, y );
5910 if ( tmp == cell->text() )
5913 doc()->emitBeginOperation(
false );
5915 if ( !doc()->undoLocked() )
5917 UndoSetText* undo =
new UndoSetText( doc(), d->activeSheet, cell->text(),
5918 x, y, cell->formatType() );
5919 doc()->addCommand( undo );
5922 cell->setCellText( tmp );
5923 d->editWidget->setText( tmp );
5925 doc()->emitEndOperation( TQRect( x, y, 1, 1 ) );
5928void View::openPopupMenu(
const TQPoint & _point )
5930 assert( d->activeSheet );
5931 delete d->popupMenu;
5933 if ( !koDocument()->isReadWrite() )
5936 d->popupMenu =
new TQPopupMenu();
5939 if ( d->canvas->isObjectSelected() && ( obj = d->canvas->getObject( d->canvas->mapFromGlobal( _point ), d->activeSheet ) ) && obj->isSelected() )
5941 d->actions->deleteCell->plug( d->popupMenu );
5942 d->popupMenu->insertSeparator();
5943 d->actions->cut->plug( d->popupMenu );
5944 d->actions->copy->plug( d->popupMenu );
5945 d->actions->paste->plug( d->popupMenu );
5946 d->popupMenu->popup( _point );
5947 d->popupMenu->insertSeparator();
5948 d->actions->actionExtraProperties->plug( d->popupMenu );
5952 Cell * cell = d->activeSheet->cellAt( d->canvas->markerColumn(), d->canvas->markerRow() );
5954 bool isProtected = d->activeSheet->isProtected();
5955 if ( !cell->isDefault() && cell->format()->notProtected( d->canvas->markerColumn(), d->canvas->markerRow() )
5956 && d->selection->isSingular() )
5957 isProtected =
false;
5961 d->actions->cellLayout->plug( d->popupMenu );
5962 d->popupMenu->insertSeparator();
5963 d->actions->cut->plug( d->popupMenu );
5965 d->actions->copy->plug( d->popupMenu );
5967 d->actions->paste->plug( d->popupMenu );
5971 d->actions->specialPaste->plug( d->popupMenu );
5972 d->actions->insertCellCopy->plug( d->popupMenu );
5973 d->popupMenu->insertSeparator();
5974 d->actions->deleteCell->plug( d->popupMenu );
5975 d->actions->adjust->plug( d->popupMenu );
5976 d->actions->defaultFormat->plug( d->popupMenu );
5979 if (!d->selection->isColumnOrRowSelected())
5981 d->actions->areaName->plug( d->popupMenu );
5982 d->popupMenu->insertSeparator();
5983 d->actions->insertCell->plug( d->popupMenu );
5984 d->actions->removeCell->plug( d->popupMenu );
5987 d->popupMenu->insertSeparator();
5988 d->actions->addModifyComment->plug( d->popupMenu );
5989 if ( !cell->format()->comment(d->canvas->markerColumn(), d->canvas->markerRow()).isEmpty() )
5991 d->actions->removeComment->plug( d->popupMenu );
5994 if (activeSheet()->testListChoose(selectionInfo()))
5996 d->popupMenu->insertSeparator();
5997 d->popupMenu->insertItem( i18n(
"Selection List..."),
this, TQ_SLOT( slotListChoosePopupMenu() ) );
6002 d->toolList.clear();
6003 d->toolList.setAutoDelete(
true );
6005 if ( !isProtected && !activeSheet()->getWordSpelling( selectionInfo() ).isEmpty() )
6007 d->popupMenuFirstToolId = 10;
6009 TQValueList<KDataToolInfo> tools = KDataToolInfo::query(
"TQString",
"text/plain", doc()->instance() );
6010 if ( tools.count() > 0 )
6012 d->popupMenu->insertSeparator();
6013 TQValueList<KDataToolInfo>::Iterator entry = tools.begin();
6014 for( ; entry != tools.end(); ++entry )
6016 TQStringList lst = (*entry).userCommands();
6017 TQStringList::ConstIterator it = lst.begin();
6020 for (; it != lst.end(); ++it )
6021 d->popupMenu->insertItem( *it, d->popupMenuFirstToolId + i++ );
6023 lst = (*entry).commands();
6025 for (; it != lst.end(); ++it )
6027 Private::ToolEntry *t =
new Private::ToolEntry;
6030 d->toolList.append( t );
6034 TQObject::connect( d->popupMenu, TQ_SIGNAL( activated(
int ) ),
this, TQ_SLOT(
slotActivateTool(
int ) ) );
6038 d->popupMenu->popup( _point );
6043 if (!activeSheet())
return;
6046 if ( _id < d->popupMenuFirstToolId )
6049 Private::ToolEntry* entry = d->toolList.at( _id - d->popupMenuFirstToolId );
6051 KDataTool* tool = entry->info.createTool();
6054 kdDebug(36001) <<
"Could not create Tool" << endl;
6058 TQString text = activeSheet()->getWordSpelling( selectionInfo() );
6060 if ( tool->run( entry->command, &text,
"TQString",
"text/plain") )
6062 doc()->emitBeginOperation(
false);
6064 activeSheet()->setWordSpelling( selectionInfo(), text);
6066 Cell *cell = d->activeSheet->cellAt( d->canvas->markerColumn(), d->canvas->markerRow() );
6067 d->editWidget->setText( cell->text() );
6069 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
6073void View::deleteSelection()
6075 if (!activeSheet())
return;
6079 deleteSelectedObjects();
6083 doc()->emitBeginOperation(
false );
6084 d->activeSheet->deleteSelection( selectionInfo() );
6089 doc()->emitEndOperation();
6092void View::deleteSelectedObjects()
6094 KMacroCommand * macroCommand = 0L;
6095 TQPtrListIterator<EmbeddedObject> it( doc()->embeddedObjects() );
6096 for ( ; it.current() ; ++it )
6098 if ( it.current()->sheet() ==
canvasWidget()->activeSheet() && it.current()->isSelected() )
6102 macroCommand =
new KMacroCommand( i18n(
"Remove Object" ) );
6103 RemoveObjectCommand *cmd =
new RemoveObjectCommand( it.current() );
6104 macroCommand->addCommand( cmd );
6109 doc()->addCommand( macroCommand );
6111 macroCommand->execute();
6117 if ( !d->activeSheet )
6120 d->activeSheet->adjustArea(*selectionInfo());
6123void View::clearTextSelection()
6128 doc()->emitBeginOperation(
false );
6129 d->activeSheet->clearTextSelection( selectionInfo() );
6134 doc()->emitEndOperation();
6137void View::clearCommentSelection()
6142 doc()->emitBeginOperation(
false );
6143 d->activeSheet->setSelectionRemoveComment( selectionInfo() );
6148 doc()->emitEndOperation();
6151void View::clearValiditySelection()
6156 doc()->emitBeginOperation(
false );
6157 d->activeSheet->clearValiditySelection( selectionInfo() );
6162 doc()->emitEndOperation();
6165void View::clearConditionalSelection()
6170 doc()->emitBeginOperation(
false );
6171 d->activeSheet->clearConditionalSelection( selectionInfo() );
6176 doc()->emitEndOperation();
6179void View::fillRight()
6184 doc()->emitBeginOperation(
false );
6185 d->activeSheet->fillSelection( selectionInfo(), Sheet::Right );
6188 doc()->emitEndOperation();
6191void View::fillLeft()
6196 doc()->emitBeginOperation(
false );
6197 d->activeSheet->fillSelection( selectionInfo(), Sheet::Left );
6200 doc()->emitEndOperation();
6208 doc()->emitBeginOperation(
false );
6209 d->activeSheet->fillSelection( selectionInfo(), Sheet::Up );
6212 doc()->emitEndOperation();
6215void View::fillDown()
6220 doc()->emitBeginOperation(
false );
6221 d->activeSheet->fillSelection( selectionInfo(), Sheet::Down );
6224 doc()->emitEndOperation();
6227void View::defaultSelection()
6232 doc()->emitBeginOperation(
false );
6233 d->activeSheet->defaultSelection( selectionInfo() );
6238 doc()->emitEndOperation();
6241void View::slotInsert()
6243 TQRect r( d->selection->selection() );
6244 InsertDialog dlg(
this,
"InsertDialog", r, InsertDialog::Insert );
6248void View::slotRemove()
6250 TQRect r( d->selection->selection() );
6251 InsertDialog dlg(
this,
"Remove", r, InsertDialog::Remove );
6255void View::slotInsertCellCopy()
6257 if ( !d->activeSheet )
6260 if ( !d->activeSheet->testAreaPasteInsert() )
6262 doc()->emitBeginOperation(
false );
6263 d->activeSheet->paste( d->selection->lastRange(),
true,
6265 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
6269 PasteInsertDialog dlg(
this,
"Remove", d->selection->selection() );
6273 if ( d->activeSheet->getAutoCalc() )
6275 doc()->emitBeginOperation(
false );
6276 d->activeSheet->recalc();
6277 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
6282void View::setAreaName()
6284 AreaDialog dlg(
this,
"Area Name",TQPoint(d->canvas->markerColumn(), d->canvas->markerRow()) );
6288void View::showAreaName()
6290 reference dlg(
this,
"Show Area" );
6294void View::resizeRow()
6296 if (!activeSheet())
return;
6298 if ( d->selection->isColumnSelected() )
6299 KMessageBox::error(
this, i18n(
"Area is too large."));
6302 ResizeRow dlg(
this );
6307void View::resizeColumn()
6309 if (!activeSheet())
return;
6312 if ( d->selection->isRowSelected() )
6313 KMessageBox::error(
this, i18n(
"Area is too large." ) );
6316 ResizeColumn dlg(
this );
6321void View::equalizeRow()
6323 if (!activeSheet())
return;
6325 if ( d->selection->isColumnSelected() )
6326 KMessageBox::error(
this, i18n(
"Area is too large." ) );
6329 doc()->emitBeginOperation(
false );
6331 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
6335void View::equalizeColumn()
6340 if ( d->selection->isRowSelected() )
6341 KMessageBox::error(
this, i18n(
"Area is too large." ) );
6344 doc()->emitBeginOperation(
false );
6346 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
6351void View::layoutDlg()
6356 CellFormatDialog dlg(
this, d->activeSheet );
6359void View::extraProperties()
6365 d->m_propertyEditor =
new PropertyEditor(
this,
"KPrPropertyEditor", d->activeSheet, doc() );
6366 d->m_propertyEditor->setCaption( i18n(
"Properties" ) );
6368 connect( d->m_propertyEditor, TQ_SIGNAL( propertiesOk() ),
this, TQ_SLOT( propertiesOk() ) );
6369 d->m_propertyEditor->exec();
6370 disconnect( d->m_propertyEditor, TQ_SIGNAL( propertiesOk() ),
this, TQ_SLOT( propertiesOk() ) );
6372 delete d->m_propertyEditor;
6373 d->m_propertyEditor = 0;
6376void View::propertiesOk()
6378 KCommand *cmd = d->m_propertyEditor->getCommand();
6383 doc()->addCommand( cmd );
6387void View::styleDialog()
6389 StyleDlg dlg(
this, doc()->styleManager() );
6392 d->actions->selectStyle->setItems( doc()->styleManager()->styleNames() );
6393 if ( d->activeSheet )
6395 d->activeSheet->setLayoutDirtyFlag();
6396 d->activeSheet->setRegionPaintDirty( d->activeSheet->visibleRect( d->canvas ) );
6399 d->canvas->repaint();
6402void View::paperLayoutDlg()
6404 if ( d->canvas->editor() )
6406 d->canvas->deleteEditor(
true );
6408 SheetPrint* print = d->activeSheet->print();
6411 pl.format = print->paperFormat();
6412 pl.orientation = print->orientation();
6414 pl.ptWidth = MM_TO_POINT( print->paperWidth() );
6415 pl.ptHeight = MM_TO_POINT( print->paperHeight() );
6416 pl.ptLeft = MM_TO_POINT( print->leftBorder() );
6417 pl.ptRight = MM_TO_POINT( print->rightBorder() );
6418 pl.ptTop = MM_TO_POINT( print->topBorder() );
6419 pl.ptBottom = MM_TO_POINT( print->bottomBorder() );
6422 hf.headLeft = print->localizeHeadFootLine( print->headLeft() );
6423 hf.headRight = print->localizeHeadFootLine( print->headRight() );
6424 hf.headMid = print->localizeHeadFootLine( print->headMid() );
6425 hf.footLeft = print->localizeHeadFootLine( print->footLeft() );
6426 hf.footRight = print->localizeHeadFootLine( print->footRight() );
6427 hf.footMid = print->localizeHeadFootLine( print->footMid() );
6429 KoUnit::Unit unit = doc()->unit();
6432 =
new PaperLayout(
this,
"PageLayout", pl, hf,
6433 FORMAT_AND_BORDERS | HEADER_AND_FOOTER,
6434 unit, d->activeSheet,
this );
6439void View::definePrintRange()
6441 d->activeSheet->print()->definePrintRange( selectionInfo() );
6444void View::resetPrintRange()
6446 d->activeSheet->print()->resetPrintRange();
6449void View::wrapText(
bool b )
6451 if ( d->toolbarLock )
6454 if ( d->activeSheet != 0L )
6456 doc()->emitBeginOperation(
false );
6457 d->activeSheet->setSelectionMultiRow( selectionInfo(), b );
6458 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
6462void View::alignLeft(
bool b )
6464 if ( d->toolbarLock )
6467 if ( d->activeSheet != 0L )
6469 doc()->emitBeginOperation(
false );
6471 d->activeSheet->setSelectionAlign( selectionInfo(),
6472 Format::Undefined );
6474 d->activeSheet->setSelectionAlign( selectionInfo(),
6478 doc()->emitEndOperation();
6482void View::alignRight(
bool b )
6484 if ( d->toolbarLock )
6487 if ( d->activeSheet != 0L )
6489 doc()->emitBeginOperation(
false );
6491 d->activeSheet->setSelectionAlign( selectionInfo(), Format::Undefined );
6493 d->activeSheet->setSelectionAlign( selectionInfo(), Format::Right );
6496 doc()->emitEndOperation();
6500void View::alignCenter(
bool b )
6502 if ( d->toolbarLock )
6505 if ( d->activeSheet != 0L )
6507 doc()->emitBeginOperation(
false );
6509 d->activeSheet->setSelectionAlign( selectionInfo(), Format::Undefined );
6511 d->activeSheet->setSelectionAlign( selectionInfo(), Format::Center );
6514 doc()->emitEndOperation();
6518void View::alignTop(
bool b )
6520 if ( d->toolbarLock )
6523 if ( d->activeSheet != 0L )
6525 doc()->emitBeginOperation(
false );
6527 d->activeSheet->setSelectionAlignY( selectionInfo(), Format::UndefinedY );
6529 d->activeSheet->setSelectionAlignY( selectionInfo(), Format::Top );
6532 doc()->emitEndOperation();
6536void View::alignBottom(
bool b )
6538 if ( d->toolbarLock )
6541 if ( d->activeSheet != 0L )
6543 doc()->emitBeginOperation(
false );
6545 d->activeSheet->setSelectionAlignY( selectionInfo(), Format::UndefinedY );
6547 d->activeSheet->setSelectionAlignY( selectionInfo(), Format::Bottom );
6550 doc()->emitEndOperation();
6554void View::alignMiddle(
bool b )
6556 if ( d->toolbarLock )
6559 if ( d->activeSheet != 0L )
6561 doc()->emitBeginOperation(
false );
6563 d->activeSheet->setSelectionAlignY( selectionInfo(), Format::UndefinedY );
6565 d->activeSheet->setSelectionAlignY( selectionInfo(), Format::Middle );
6568 doc()->emitEndOperation();
6572void View::moneyFormat(
bool b)
6574 if ( d->toolbarLock )
6577 doc()->emitBeginOperation(
false );
6578 if ( d->activeSheet != 0L )
6579 d->activeSheet->setSelectionMoneyFormat( selectionInfo(), b );
6583 doc()->emitEndOperation();
6586void View::createStyleFromCell()
6588 if ( !d->activeSheet )
6591 TQPoint p( d->selection->selection().topLeft() );
6592 Cell * cell = d->activeSheet->nonDefaultCell( p.x(), p.y() );
6595 TQString styleName(
"" );
6599 styleName = KInputDialog::getText( i18n(
"Create Style From Cell" ),
6600 i18n(
"Enter name:" ), styleName, &ok,
this );
6605 styleName = styleName.stripWhiteSpace();
6607 if ( styleName.length() < 1 )
6609 KNotifyClient::beep();
6610 KMessageBox::sorry(
this, i18n(
"The style name cannot be empty." ) );
6614 if ( doc()->styleManager()->style( styleName ) != 0 )
6616 KNotifyClient::beep();
6617 KMessageBox::sorry(
this, i18n(
"A style with this name already exists." ) );
6623 CustomStyle * style =
new CustomStyle( cell->format()->style(), styleName );
6625 doc()->styleManager()->m_styles[ styleName ] = style;
6626 cell->format()->setStyle( style );
6627 TQStringList lst( d->actions->selectStyle->items() );
6628 lst.push_back( styleName );
6629 d->actions->selectStyle->setItems( lst );
6632void View::styleSelected(
const TQString & style )
6634 if (d->activeSheet )
6636 Style * s = doc()->styleManager()->style( style );
6640 doc()->emitBeginOperation(
false);
6641 d->activeSheet->setSelectionStyle( selectionInfo(), s );
6644 doc()->emitEndOperation();
6649void View::precisionPlus()
6651 setSelectionPrecision( 1 );
6654void View::precisionMinus()
6656 setSelectionPrecision( -1 );
6659void View::setSelectionPrecision(
int delta )
6661 if ( d->activeSheet != NULL )
6663 doc()->emitBeginOperation(
false );
6664 d->activeSheet->setSelectionPrecision( selectionInfo(), delta );
6667 doc()->emitEndOperation();
6671void View::percent(
bool b )
6673 if ( d->toolbarLock )
6676 doc()->emitBeginOperation(
false );
6677 if ( d->activeSheet != 0L )
6678 d->activeSheet->setSelectionPercent( selectionInfo() ,b );
6682 doc()->emitEndOperation();
6686void View::insertObject()
6691 doc()->emitBeginOperation(
false );
6692 KoDocumentEntry e = d->actions->insertPart->documentEntry();
6695 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
6700 delete d->insertHandler;
6702 d->insertHandler =
new InsertPartHandler(
this, d->canvas, e );
6703 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
6706void View::insertChart()
6711 if ( d->selection->isColumnOrRowSelected() )
6713 KMessageBox::error(
this, i18n(
"Area too large."));
6716 TQValueList<KoDocumentEntry> vec = KoDocumentEntry::query(
true,
"'KOfficeChart' in ServiceTypes" );
6717 if ( vec.isEmpty() )
6719 KMessageBox::error(
this, i18n(
"No charting component registered.") );
6724 delete d->insertHandler;
6726 doc()->emitBeginOperation(
false );
6728 d->insertHandler =
new InsertChartHandler(
this, d->canvas, vec[0] );
6729 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
6767void View::removeSheet()
6769 if ( doc()->map()->count() <= 1 || ( doc()->map()->visibleSheets().count() <= 1 ) )
6771 KNotifyClient::beep();
6772 KMessageBox::sorry(
this, i18n(
"You cannot delete the only sheet."), i18n(
"Remove Sheet") );
6775 KNotifyClient::beep();
6776 int ret = KMessageBox::warningContinueCancel(
this, i18n(
"You are about to remove the active sheet.\nDo you want to continue?" ),
6777 i18n(
"Remove Sheet" ),KGuiItem(i18n(
"&Delete"),
"edit-delete") );
6779 if ( ret == KMessageBox::Continue )
6781 doc()->emitBeginOperation(
false );
6782 if ( d->canvas->editor() )
6784 d->canvas->deleteEditor(
false );
6786 doc()->setModified(
true );
6787 Sheet * tbl = activeSheet();
6788 KCommand* command =
new RemoveSheetCommand( tbl );
6789 doc()->addCommand( command );
6794 UndoRemoveSheet * undo =
new UndoRemoveSheet( doc(), tbl );
6795 doc()->addCommand( undo );
6796 tbl->doc()->map()->takeSheet( tbl );
6797 doc()->takeSheet( tbl );
6799 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
6804void View::slotRename()
6807 Sheet * sheet = activeSheet();
6809 if( sheet->isProtected() )
6811 KMessageBox::error( 0, i18n (
"You cannot change a protected sheet." ) );
6816 TQString activeName = sheet->sheetName();
6817 TQString newName = KInputDialog::getText( i18n(
"Rename Sheet"),i18n(
"Enter name:"), activeName, &ok,
this );
6821 while (!util_validateSheetName(newName))
6823 KNotifyClient::beep();
6824 KMessageBox::information(
this, i18n(
"Sheet name contains illegal characters. Only numbers and letters are allowed."),
6825 i18n(
"Change Sheet Name") );
6827 newName = newName.simplifyWhiteSpace();
6828 int n = newName.find(
'-');
6829 if ( n > -1 ) newName[n] =
'_';
6830 n = newName.find(
'!');
6831 if ( n > -1 ) newName[n] =
'_';
6832 n = newName.find(
'$');
6833 if ( n > -1 ) newName[n] =
'_';
6835 newName = KInputDialog::getText( i18n(
"Rename Sheet"),i18n(
"Enter name:"), newName, &ok,
this );
6840 if ( (newName.stripWhiteSpace()).isEmpty() )
6842 KNotifyClient::beep();
6843 KMessageBox::information(
this, i18n(
"Sheet name cannot be empty."), i18n(
"Change Sheet Name") );
6847 else if ( newName != activeName )
6850 if ( doc()->map()->findSheet( newName ) )
6852 KNotifyClient::beep();
6853 KMessageBox::information(
this, i18n(
"This name is already used."), i18n(
"Change Sheet Name") );
6859 KCommand* command =
new RenameSheetCommand( sheet, newName );
6860 doc()->addCommand( command );
6865 doc()->emitBeginOperation(
false);
6867 doc()->setModified(
true );
6868 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
6874 if ( d->activeSheet == 0L )
6879 d->activeSheet->setArrayFormula (d->selection, _text);
6884 int x = d->canvas->markerColumn();
6885 int y = d->canvas->markerRow();
6887 d->activeSheet->setText( y, x, _text );
6889 Cell * cell = d->activeSheet->cellAt( x, y );
6890 if ( cell->value().isString() && !_text.isEmpty() && !_text.at(0).isDigit() && !cell->isFormula() )
6891 doc()->addStringCompletion( _text );
6901void View::slotAddSheet( Sheet *_sheet )
6906void View::slotRefreshView()
6909 d->canvas->repaint();
6910 d->vBorderWidget->repaint();
6911 d->hBorderWidget->repaint();
6914void View::slotUpdateView( Sheet *_sheet )
6917 if ( ( !activeSheet() ) || ( _sheet != d->activeSheet ) )
6920 d->activeSheet->setRegionPaintDirty( d->activeSheet->visibleRect( d->canvas ) );
6921 doc()->emitEndOperation();
6924void View::slotUpdateView( Sheet * _sheet,
const Region& region )
6929 if ( _sheet != d->activeSheet )
6933 d->activeSheet->setRegionPaintDirty( region );
6934 doc()->emitEndOperation( region );
6937void View::slotUpdateView( EmbeddedObject *obj )
6939 d->canvas->repaintObject( obj );
6942void View::slotUpdateHBorder( Sheet * _sheet )
6947 if ( _sheet != d->activeSheet )
6950 doc()->emitBeginOperation(
false);
6951 d->hBorderWidget->update();
6952 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
6955void View::slotUpdateVBorder( Sheet *_sheet )
6960 if ( _sheet != d->activeSheet )
6963 doc()->emitBeginOperation(
false );
6964 d->vBorderWidget->update();
6965 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
6977 doc()->emitBeginOperation(
false );
6979 bool colSelected = d->selection->isColumnSelected();
6980 bool rowSelected = d->selection->isRowSelected();
6981 if (d->activeSheet && !d->activeSheet->isProtected())
6984 d->actions->insertRow->setEnabled( !colSelected );
6985 d->actions->deleteRow->setEnabled( !colSelected );
6986 d->actions->resizeRow->setEnabled( !colSelected );
6987 d->actions->equalizeRow->setEnabled( !colSelected );
6988 d->actions->hideRow->setEnabled( !colSelected );
6989 d->actions->validity->setEnabled( !colSelected && !rowSelected);
6990 d->actions->conditional->setEnabled( !colSelected && !rowSelected);
6991 d->actions->insertColumn->setEnabled( !rowSelected );
6992 d->actions->deleteColumn->setEnabled( !rowSelected );
6993 d->actions->resizeColumn->setEnabled( !rowSelected );
6994 d->actions->equalizeColumn->setEnabled( !rowSelected );
6995 d->actions->hideColumn->setEnabled( !rowSelected );
6996 d->actions->textToColumns->setEnabled( !rowSelected );
6998 bool simpleSelection = d->selection->isSingular() || colSelected || rowSelected;
6999 d->actions->autoFormat->setEnabled( !simpleSelection );
7000 d->actions->sort->setEnabled( !simpleSelection );
7001 d->actions->mergeCell->setEnabled( !simpleSelection );
7002 d->actions->mergeCellHorizontal->setEnabled( !simpleSelection );
7003 d->actions->mergeCellVertical->setEnabled( !simpleSelection );
7004 d->actions->fillRight->setEnabled( !simpleSelection );
7005 d->actions->fillUp->setEnabled( !simpleSelection );
7006 d->actions->fillDown->setEnabled( !simpleSelection );
7007 d->actions->fillLeft->setEnabled( !simpleSelection );
7008 d->actions->sortDec->setEnabled( !simpleSelection );
7009 d->actions->sortInc->setEnabled( !simpleSelection);
7010 d->actions->createStyle->setEnabled( simpleSelection );
7012 bool contiguousSelection = d->selection->isContiguous();
7013 d->actions->subTotals->setEnabled(contiguousSelection);
7015 d->actions->selectStyle->setCurrentItem( -1 );
7017 d->statusBarOpTimer.start(250,
true);
7023 d->canvas->setSelectionChangePaintDirty( d->activeSheet, changedRegion );
7024 d->vBorderWidget->update();
7025 d->hBorderWidget->update();
7027 if (colSelected || rowSelected)
7029 doc()->emitEndOperation();
7033 d->canvas->validateSelection();
7040 d->canvas->scrollToCell(selectionInfo()->marker());
7044 if ( !d->canvas->editor() && !d->canvas->chooseMode() )
7048 d->canvas->updatePosWidget();
7050 doc()->emitEndOperation();
7059 doc()->emitBeginOperation(
false );
7060 d->canvas->updateEditor();
7061 d->canvas->setSelectionChangePaintDirty( d->activeSheet, changedRegion );
7062 doc()->emitEndOperation( *choice() );
7063 kdDebug() <<
"Choice: " << *choice() << endl;
7068 if ( !changedRegion.
isValid() )
7070 d->canvas->scrollToCell( choice()->marker() );
7075 Sheet * sheet = activeSheet();
7078 TQRect tmpRect(d->selection->selection());
7079 MethodOfCalc tmpMethod = doc()->getTypeOfCalc();
7080 if ( tmpMethod != NoneCalc )
7083 Value range = sheet->valueRange (tmpRect.left(), tmpRect.top(),
7084 tmpRect.right(), tmpRect.bottom());
7088 val = calc->
sum (range);
7091 val = calc->avg (range);
7094 val = calc->min (range);
7097 val = calc->max (range);
7100 val =
Value (calc->count (range));
7103 val =
Value (calc->count (range,
false));
7112 TQString res = d->doc->converter()->asString (val).asString ();
7117 tmp = i18n(
"Sum: ") + res;
7120 tmp = i18n(
"Average: ") + res;
7123 tmp = i18n(
"Min: ") + res;
7126 tmp = i18n(
"Max: ") + res;
7129 tmp = i18n(
"Count: ") + res;
7132 tmp = i18n(
"CountA: ") + res;
7141 d->calcLabel->setText(TQString(
" ") + tmp +
' ');
7145void View::statusBarClicked(
int _id)
7147 if ( !koDocument()->isReadWrite() || !factory() )
7151 TQPoint mousepos = TQCursor::pos();
7152 ((TQPopupMenu*)factory()->container(
"calc_popup" ,
this ) )->popup( mousepos );
7156void View::menuCalc(
bool )
7158 doc()->emitBeginOperation(
false);
7159 if ( d->actions->calcMin->isChecked() )
7161 doc()->setTypeOfCalc( Min );
7163 else if ( d->actions->calcMax->isChecked() )
7165 doc()->setTypeOfCalc( Max );
7167 else if ( d->actions->calcCount->isChecked() )
7169 doc()->setTypeOfCalc( Count );
7171 else if ( d->actions->calcAverage->isChecked() )
7173 doc()->setTypeOfCalc( Average );
7175 else if ( d->actions->calcSum->isChecked() )
7177 doc()->setTypeOfCalc( SumOfNumber );
7179 else if ( d->actions->calcCountA->isChecked() )
7181 doc()->setTypeOfCalc( CountA );
7183 else if ( d->actions->calcNone->isChecked() )
7184 doc()->setTypeOfCalc( NoneCalc );
7188 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
7192TQWMatrix View::matrix()
const
7195 m.scale( d->doc->zoomedResolutionX(),
7196 d->doc->zoomedResolutionY() );
7197 m.translate( - d->canvas->xOffset(), - d->canvas->yOffset() );
7201void View::transformPart()
7203 Q_ASSERT( selectedChild() );
7205 if ( d->transformToolBox.isNull() )
7207 d->transformToolBox =
new KoTransformToolBox( selectedChild(), topLevelWidget() );
7208 d->transformToolBox->show();
7210 d->transformToolBox->setDocumentChild( selectedChild() );
7214 d->transformToolBox->show();
7215 d->transformToolBox->raise();
7219void View::slotChildSelected( KoDocumentChild* )
7233 doc()->emitBeginOperation(
false );
7234 d->activeSheet->setRegionPaintDirty(TQRect(TQPoint(0,0), TQPoint(KS_colMax, KS_rowMax)));
7236 doc()->emitEndOperation();
7240void View::slotChildUnselected( KoDocumentChild* )
7254 doc()->emitBeginOperation(
false );
7255 d->activeSheet->setRegionPaintDirty(TQRect(TQPoint(0,0), TQPoint(KS_colMax, KS_rowMax)));
7256 doc()->emitEndOperation();
7263 doc()->emitBeginOperation(
false );
7264 d->canvas->deleteEditor( saveChanges );
7267 doc()->emitEndOperation();
7270DCOPObject * View::dcopObject()
7273 d->dcop =
new ViewIface(
this );
7278TQWidget * View::canvas()
const
7283int View::canvasXOffset()
const
7285 if (!d->activeSheet)
7288 double zoomedResX = d->activeSheet->doc()->zoomedResolutionX();
7292int View::canvasYOffset()
const
7294 if (!d->activeSheet)
7297 double zoomedResY = d->activeSheet->doc()->zoomedResolutionY();
7302void View::guiActivateEvent( KParts::GUIActivateEvent *ev )
7304 if ( d->activeSheet )
7306 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
7308 if ( ev->activated() )
7322 KoView::guiActivateEvent( ev );
7327 if ( !koDocument()->isReadWrite() || !factory() )
7331 bool state = ( doc()->map()->visibleSheets().count() > 1 );
7332 if ( d->activeSheet && d->activeSheet->isProtected() )
7334 d->actions->removeSheet->setEnabled(
false );
7335 d->actions->hideSheet->setEnabled(
false );
7336 d->actions->showSheet->setEnabled(
false );
7340 d->actions->removeSheet->setEnabled( state);
7341 d->actions->hideSheet->setEnabled( state );
7342 d->actions->showSheet->setEnabled( doc()->map()->hiddenSheets().count()>0 );
7344 if ( !doc() || !doc()->map() || doc()->map()->isProtected() )
7346 d->actions->insertSheet->setEnabled(
false );
7347 d->actions->renameSheet->setEnabled(
false );
7348 d->actions->showSheet->setEnabled(
false );
7349 d->actions->hideSheet->setEnabled(
false );
7350 d->actions->removeSheet->setEnabled(
false );
7352 static_cast<TQPopupMenu*
>(factory()->container(
"menupage_popup",
this))->popup(_point);
7356void View::updateBorderButton()
7359 if ( d->activeSheet )
7360 d->actions->showPageBorders->setChecked( d->activeSheet->isShowPageBorders() );
7364void View::removeSheet( Sheet *_t )
7366 doc()->emitBeginOperation(
false);
7367 TQString m_tablName=_t->sheetName();
7368 d->tabBar->removeTab( m_tablName );
7369 setActiveSheet( doc()->map()->findSheet( doc()->map()->visibleSheets().first() ));
7371 bool state = doc()->map()->visibleSheets().count() > 1;
7372 d->actions->removeSheet->setEnabled( state );
7373 d->actions->hideSheet->setEnabled( state );
7374 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
7377void View::insertSheet( Sheet* sheet )
7379 doc()->emitBeginOperation(
false );
7380 TQString tabName = sheet->sheetName();
7381 if ( !sheet->isHidden() )
7383 d->tabBar->addTab( tabName );
7386 bool state = ( doc()->map()->visibleSheets().count() > 1 );
7387 d->actions->removeSheet->setEnabled( state );
7388 d->actions->hideSheet->setEnabled( state );
7389 doc()->emitEndOperation( sheet->visibleRect( d->canvas ) );
7392TQColor View::borderColor()
const
7394 return d->actions->borderColor->color();
7397void View::updateShowSheetMenu()
7399 doc()->emitBeginOperation(
false );
7400 if ( d->activeSheet->isProtected() )
7401 d->actions->showSheet->setEnabled(
false );
7403 d->actions->showSheet->setEnabled( doc()->map()->hiddenSheets().count() > 0 );
7404 doc()->emitEndOperation( d->activeSheet->visibleRect( d->canvas ) );
7407void View::closeEditor()
7409 if ( d->activeSheet ) {
7410 doc()->emitBeginOperation(
false );
7411 d->canvas->closeEditor();
7414 doc()->emitEndOperation();
7420 if (!d->activeSheet)
7423 d->activeSheet->setRegionPaintDirty( *selectionInfo() );
7431 d->canvas->paintUpdates();
7440void View::initialiseMarkerFromSheet( Sheet *_sheet,
const TQPoint &point )
7442 d->savedMarkers.replace( _sheet, point);
7447 TQMapIterator<Sheet*, TQPoint> it = d->savedMarkers.find(sheet);
7448 TQPoint newMarker = (it == d->savedMarkers.end()) ? TQPoint(1,1) : *it;
7454 TQMapIterator<Sheet*, KoPoint> it = d->savedOffsets.find(sheet);
7455 KoPoint offset = (it == d->savedOffsets.end()) ? KoPoint() : *it;
7462 if (d->activeSheet != NULL)
7464 d->savedAnchors.replace(d->activeSheet, d->selection->anchor());
7465 kdDebug() <<
" Current scrollbar vert value: " << d->canvas->vertScrollBar()->value() << endl;
7466 kdDebug() <<
"Saving marker pos: " << d->selection->marker() << endl;
7467 d->savedMarkers.replace(d->activeSheet, d->selection->marker());
7468 d->savedOffsets.replace(d->activeSheet, KoPoint(d->canvas->xOffset(),
7469 d->canvas->yOffset()));
7473void View::handleDamages(
const TQValueList<Damage*>& damages )
7475 TQValueList<Damage*>::ConstIterator it;
7476 for( it = damages.begin(); it != damages.end(); ++it )
7478 Damage* damage = *it;
7479 if( !damage )
continue;
7481 if( damage->type() == Damage::Cell )
7483 CellDamage* cd =
static_cast<CellDamage*
>( damage );
7484 Cell* damagedCell = cd->cell();
7485 Sheet* damagedSheet = damagedCell->
sheet();
7486 TQRect drect( damagedCell->
column(), damagedCell->
row(), 1, 1 );
7487 damagedSheet->setRegionPaintDirty( drect );
7491 if( damage->type() == Damage::Sheet )
7493 SheetDamage* sd =
static_cast<SheetDamage*
>( damage );
7494 Sheet* damagedSheet = sd->sheet();
7496 if( sd->action() == SheetDamage::PropertiesChanged )
7498 CellBinding * b = 0;
7499 for ( b = damagedSheet->firstCellBinding(); b != 0;
7500 b = damagedSheet->nextCellBinding() )
7501 b->cellChanged( 0 );
7503 d->activeSheet->setRegionPaintDirty( TQRect(TQPoint(0,0),
7504 TQPoint(KS_colMax, KS_rowMax)));
7515void View::runInternalTests()
7518 KSpread::TestRunner* runner =
new KSpread::TestRunner();
7523void View::runInspector()
7526 if(!d->activeSheet)
return;
7527 Cell * cell = d->activeSheet->cellAt( d->selection->marker() );
7528 KSpread::Inspector* ins =
new KSpread::Inspector( cell );
7535 return TQApplication::palette().active().highlight().light( 175 );
7540#include "kspread_view.moc"
The canvas builds a part of the GUI of KSpread.
void copyOasisObjects()
This is intended to copy the selected objects to the clipboard so that they can be pasted into other ...
For every cell in the spread sheet there is a Cell object.
FormatType formatType() const
Return the format of this cell.
int row() const
Returns the cell's row.
Sheet * sheet() const
Returns the worksheet which owns this cell.
int column() const
Returns the cell's column.
Format * format() const
Returns the format object of this cell.
bool isDefault() const
Returns true if this is a default cell (with row and column equal to zero).
This class holds the data that makes up a spreadsheet.
void setShowTabBar(bool b)
If b is true, tab bar is visible, otherwise it will be hidden.
void setShowVerticalScrollBar(bool b)
If b is true, vertical scrollbar is visible, otherwise it will be hidden.
void setShowStatusBar(bool b)
If b is true, status bar is visible, otherwise it will be hidden.
void setIndentValue(double val)
Sets the indentation value.
void setTypeOfCalc(MethodOfCalc _calc)
Method of calc.
void emitBeginOperation(bool waitCursor)
Functions to begin a kspread 'operation'.
void setShowColHeader(bool b)
void setGridColor(const TQColor &color)
Sets the color of the grid.
void setShowMessageError(bool b)
If b is true, an error message will pop up whenever error occurs.
void setShowHorizontalScrollBar(bool b)
If b is true, horizontal scrollbar is visible, otherwise it will be hidden.
void addCommand(KCommand *command)
Adds a command to the command history.
void setShowFormulaBar(bool b)
If b is true, formula bar is visible, otherwise it will be hidden.
void deleteLoadingInfo()
deletes the loading info after loading is complete
virtual void emitEndOperation()
Mark the end of an operation and triggers a repaint of any cells or regions of cells which have been ...
void setShowRowHeader(bool b)
If b is true, row header is visible, otherwise it will be hidden.
Contains basic information for every object.
TQStringList selectedSheets()
Sheet * findSheet(const TQString &_name)
searches for a sheet named _name
Sheet * firstSheet()
Use the #nextSheet function to get all the other sheets.
void moveSheet(const TQString &_from, const TQString &_to, bool _before=true)
The sheet named _from is being moved to the sheet _to.
The one for all class for points and ranges.
Class SheetPropertiesCommand implements a command for changing sheet properties.
The ValueCalc class is used to perform all sorts of calculations.
Value sum(const Value &range, bool full=true)
basic range functions
Provides a wrapper for cell value.
void slotActivateTool(int _id)
Popup menu.
void refreshView()
refresh view when you hide/show vertical scrollbar
void deleteEditor(bool saveChanges=true)
Called before saving, to finish the current edition (if any)
ComboboxLocationEditWidget * posWidget() const
Returns the location widget.
void sheetProperties()
Shows the sheet properties dialog.
KoPoint offsetFromSheet(Sheet *sheet) const
void mergeCell()
Merges selected cells into one cell.
static TQColor highlightColor()
Returns the default color for highlighting cells and column / row headers.
void dissociateCell()
Breaks merged cell.
void showTabBar(bool b)
Shows the tab bar if b is true, otherwise the tab bar will be hidden.
KoTabBar * tabBar() const
Returns the tab bar.
Canvas * canvasWidget() const
Returns the canvas of the view.
void slotItemSelected(int)
list from list choose
void previousSheet()
Switch the active sheet to the previous visible sheet.
void popupTabBarMenu(const TQPoint &)
Shows context menu when tabbar is double-clicked.
void createTemplate()
Actions.
void slotPopupAdjustColumn()
Border popup menu.
void slotPopupDeleteChild()
Invoked when the "Delete Embedded Document" option from an embedded document's popup menu is selected...
TQScrollBar * vertScrollBar() const
Returns the vertical scrollbar.
void resetInsertHandle()
Resets the internal handle pointer, called from InsertHandler destructor.
void commandExecuted()
Updates the view and the action.
void changeSheet(const TQString &_name)
Switch the active sheet to the name.
TQScrollBar * horzScrollBar() const
Returns the horizontal scrollbar.
void markSelectionAsDirty()
Mark all selected cells / regions of cells as 'dirty' (ie.
void setText(const TQString &_text, bool array=false)
Used by EditWidget.
void slotHighlight(const TQString &text, int matchingIndex, int matchedLength)
Called by find/replace (findNext) when it found a match.
void paintUpdates()
Repaint any cell with the paintDirty flag that is visible in this view.
void calcStatusBarOp()
write in statusBar result of calc (Min, or Max, average, sum, count)
TQPoint markerFromSheet(Sheet *sheet) const
void slotReplace(const TQString &newText, int, int, int)
Called when replacing text in a cell.
void firstSheet()
Switch the active sheet to the first visible sheet in the workbook.
void popupChildMenu(KoChild *, const TQPoint &global_pos)
Invoked if the popup menu for an embedded document should be opened.
VBorder * vBorderWidget() const
Returns the row header.
KoDocument * hitTest(const TQPoint &pos)
~View()
Destroys the view.
void activateFormulaEditor()
Activates the formula editor for the current cell.
void nextSheet()
Switch the active sheet to the next visible sheet.
void lastSheet()
Switch the active sheet to the last visible sheet in the workbook.
HBorder * hBorderWidget() const
Returns the column header.
void updateEditWidget()
Fills the EditWidget with the current cells content.
KoPoint markerDocumentPosition()
Returns the position of the top-left point of the currently selected cell in document coordinates.
void insertChild(const TQRect &_geometry, KoDocumentEntry &_entry)
void showStatusBar(bool b)
Shows the status bar if b is true, otherwise the status bar will be hidden.
void saveCurrentSheetSelection()
Save current sheet selection.
void showFormulaBar(bool b)
Shows the formula bar if b is true, otherwise the formula bar will be hidden.
KSpread::EditWidget * editWidget() const
Returns the editor widget.
void updateEditWidgetOnPress()
Same as updateEditEidget() but no update of menus and toolbars.