kspread

kspread_view.h
1/* This file is part of the KDE project
2 Copyright (C) 2006 Raphael Langerhorst <raphael.langerhorst@kdemail.net>
3 (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
4 (C) 1999-2003 Laurent Montel <montel@kde.org>
5 (C) 2002-2003 Norbert Andres <nandres@web.de>
6 (C) 2002-2003 Philipp Mueller <philipp.mueller@gmx.de>
7 (C) 2002-2003 John Dailey <dailey@vt.edu>
8 (C) 1999-2003 David Faure <faure@kde.org>
9 (C) 1999-2001 Simon Hausmann <hausmann@kde.org>
10 (C) 1998-2000 Torben Weis <weis@kde.org>
11
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Library General Public
14 License as published by the Free Software Foundation; either
15 version 2 of the License, or (at your option) any later version.
16
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Library General Public License for more details.
21
22 You should have received a copy of the GNU Library General Public License
23 along with this library; see the file COPYING.LIB. If not, write to
24 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 * Boston, MA 02110-1301, USA.
26*/
27
28#ifndef KSPREAD_VIEW
29#define KSPREAD_VIEW
30
31#include <tqpoint.h>
32#include <tqptrlist.h>
33#include <tqstringlist.h>
34#include <tqvaluelist.h>
35
36#include <kprinter.h>
37#include <tdeprint/kprintdialogpage.h>
38
39#include <KoPoint.h>
40#include <KoView.h>
41
42
43class TQScrollBar;
44
45class KoDocumentEntry;
46class KoTabBar;
47
48class SheetSelectWidget;
49
50namespace KSpread
51{
52class Cell;
53class Damage;
54class Sheet;
55class Canvas;
56class Child;
57class Doc;
58class EditWidget;
59class HBorder;
61class Region;
62class Selection;
63class VBorder;
64class View;
67class EmbeddedObject;
68
69
80class KPSheetSelectPage : public KPrintDialogPage
81{
82 TQ_OBJECT
83
84 public:
85 KPSheetSelectPage( TQWidget *parent = 0 );
86// ~KPSheetSelectPage();
87
88// //reimplement virtual functions
92 void getOptions( TQMap<TQString,TQString>& opts, bool incldef = false );
93
97 void setOptions( const TQMap<TQString,TQString>& opts );
98
102 bool isValid( TQString& msg );
103
107 TQStringList selectedSheets();
108
112 void clearSelection();
113
125 static TQString printOptionForIndex(unsigned int index);
126
131 static TQStringList selectedSheets(KPrinter &prt);
132
133 public slots:
134
138 void prependAvailableSheet(const TQString& sheetname);
139
143 void prependSelectedSheet(const TQString& sheetname);
144
145 protected slots:
146
147 // The following slots just implement the code for the buttons
148
149 void selectAll();
150 void select();
151 void remove();
152 void removeAll();
153
154 void moveTop();
155 void moveUp();
156 void moveDown();
157 void moveBottom();
158
159 private:
160
165 SheetSelectWidget* gui;
166};
167
168
187class KSPREAD_EXPORT View : public KoView
188{
189 friend class Canvas;
190
191 TQ_OBJECT
192
193public:
194
196 View( TQWidget *_parent, const char *_name,
197 Doc *doc );
198
200 ~View();
201
202 Doc* doc() const;
203
205 Canvas* canvasWidget() const;
206
208 HBorder* hBorderWidget() const;
209
211 VBorder* vBorderWidget() const;
212
214 TQScrollBar* horzScrollBar() const;
215
217 TQScrollBar* vertScrollBar() const;
218
221
224
226 KoTabBar* tabBar() const;
227
228 void setZoom( int zoom, bool updateViews ); // change the zoom value
229
230 void addSheet( Sheet *_t );
231 //void removesheet( Sheet *_t );
232 void removeAllSheets();
233 void setActiveSheet( Sheet *_t,bool updatesheet=true );
234
235 const Sheet* activeSheet() const;
236 Sheet* activeSheet();
237
238 void openPopupMenu( const TQPoint &_global );
239 void popupRowMenu(const TQPoint & _point ) ;
240 void popupColumnMenu( const TQPoint & _point);
241
242 // void showFormulaToolBar( bool show );
243
247 void setText( const TQString& _text, bool array = false );
248
249 void enableUndo( bool _b );
250 void enableRedo( bool _b );
251 void enableInsertColumn( bool _b );
252 void enableInsertRow( bool _b );
253
261 void insertChart( const TQRect& _geometry, KoDocumentEntry& _entry );
269 void insertChild( const TQRect& _geometry, KoDocumentEntry& _entry );
270
271 // void insertPicture( const TQRect& _geometry, KURL& _file );
272
273 virtual void print( KPrinter &printer );
274 virtual void setupPrinter( KPrinter &printer );
275
281 void updateEditWidget();
286
287
291 void deleteEditor( bool saveChanges = true );
292 void closeEditor();
293 virtual DCOPObject* dcopObject();
294
295 virtual TQWidget *canvas() const;
296 virtual int canvasXOffset() const;
297 virtual int canvasYOffset() const;
298
302 KoDocument *hitTest( const TQPoint &pos );
303
304
305 void initConfig();
306
307
308 void initCalcMenu();
309
310 void changeNbOfRecentFiles(int _nb);
311
312 void updateBorderButton();
313
314 void removeSheet( Sheet *_t );
315 void insertSheet( Sheet* sheet );
316 TQColor borderColor() const;
317
318 Selection* selectionInfo() const;
319 Selection* choice() const;
320
321 void updateShowSheetMenu();
322
328
332 void paintUpdates();
333
337 void resetInsertHandle();
338
339 bool isInsertingObject();
340
341 bool showSheet(const TQString& sheetName);
342
346 TQPoint markerFromSheet( Sheet* sheet ) const;
347
351 KoPoint offsetFromSheet( Sheet* sheet ) const;
352
358
359 void deleteSelectedObjects();
360
364 static TQColor highlightColor();
365
366public slots:
370 void refreshView();
371 void initialPosition();
375 void createTemplate();
376 void transformPart();
377 void copySelection();
378 void cutSelection();
379 void deleteSelection();
380 void clearTextSelection();
381 void clearCommentSelection();
382 void clearValiditySelection();
383 void clearConditionalSelection();
384 void fillRight();
385 void fillLeft();
386 void fillUp();
387 void fillDown();
388 void recalcWorkBook();
389 void recalcWorkSheet();
390 void paste();
391 void specialPaste();
392 void editCell();
393 void setAreaName();
394 void showAreaName();
395 void adjust();
396 void defaultSelection();
397 void paperLayoutDlg();
398 void styleDialog();
399 void definePrintRange();
400 void resetPrintRange();
401 void insertObject();
402 void insertFromDatabase();
403 void insertFromTextfile();
404 void insertFromClipboard();
405 void insertSpecialChar();
406 void togglePageBorders( bool );
407 void toggleProtectSheet( bool );
408 void toggleProtectDoc( bool );
409 void viewZoom( const TQString & );
410 void find();
411 void findNext();
412 void findPrevious();
413 void replace();
414 void conditional();
415 void validity();
416 void insertSeries();
417 void sort();
418 void insertHyperlink();
419 void removeHyperlink();
420 void goalSeek();
421 void multipleOperations();
422 void subtotals();
423 void textToColumns();
424 void consolidate();
425 void insertSheet();
426 void removeSheet();
427 void hideSheet();
428 void showSheet();
429 void helpUsing();
430 void insertChart();
431 void insertPicture();
432 void moneyFormat(bool b);
433 void alignLeft( bool b );
434 void alignRight( bool b );
435 void alignCenter( bool b );
436 void alignTop( bool b );
437 void alignMiddle( bool b );
438 void alignBottom( bool b );
439 void wrapText( bool b );
440 void precisionMinus();
441 void precisionPlus();
442 void createStyleFromCell();
443 void styleSelected( const TQString & );
444 void setSelectionPrecision(int delta);
445 void percent(bool b);
446 void fontSelected( const TQString &_font );
447 void fontSizeSelected( int size );
448 void bold( bool b );
449 void italic( bool b );
450 void underline( bool b );
451 void strikeOut( bool b );
452 void deleteColumn();
453 void insertColumn();
454 void deleteRow();
455 void insertRow();
456 void hideRow();
457 void showRow();
458 void showSelRows();
459 void hideColumn();
460 void showColumn();
461 void showSelColumns();
462 void insertMathExpr();
463 void formulaSelection( const TQString &_math );
464 void changeTextColor();
465 void changeBackgroundColor();
466 void sortInc();
467 void sortDec();
468 void layoutDlg();
469 void extraProperties();
470 void borderBottom();
471 void borderRight();
472 void borderLeft();
473 void borderTop();
474 void borderOutline();
475 void borderAll();
476 void borderRemove();
477 void changeBorderColor();
478 void sheetFormat();
479 void autoSum();
480 void resizeRow();
481 void resizeColumn();
482 void increaseFontSize();
483 void decreaseFontSize();
484 void setSelectionFontSize(int size);
485
486 void setSelectionTextColor(const TQColor &txtColor);
487 void setSelectionBackgroundColor(const TQColor &bgColor);
488 void setSelectionBorderColor(const TQColor &bdColor);
489
490 void setSelectionLeftBorderColor(const TQColor &color);
491 void setSelectionRightBorderColor(const TQColor &color);
492 void setSelectionTopBorderColor(const TQColor &color);
493 void setSelectionBottomBorderColor(const TQColor &color);
494 void setSelectionAllBorderColor(const TQColor &color);
495 void setSelectionOutlineBorderColor(const TQColor &color);
496
497 void upper();
498 void lower();
499 void equalizeColumn();
500 void equalizeRow();
501 void preference();
502 void firstLetterUpper();
503 void verticalText(bool );
504 void addModifyComment();
505 void setSelectionComment(TQString comment);
506 void removeComment();
507 void changeAngle();
508 void setSelectionAngle(int angle);
509
516 void mergeCell();
517 void mergeCellHorizontal();
518 void mergeCellVertical();
519
520
526 void dissociateCell();
527
528 void gotoCell();
529 void increaseIndent();
530 void decreaseIndent();
531 void copyAsText();
532
533 void moveSheet( unsigned sheet, unsigned target );
534
538 void sheetProperties();
539
544 void changeSheet( const TQString& _name );
545
550 void nextSheet();
551
556 void previousSheet();
557
562 void firstSheet();
563
568 void lastSheet();
569
570 void sortList();
571
572 void statusBarClicked(int _id);
573 void menuCalc(bool);
574
578 void showStatusBar( bool b );
579
583 void showTabBar( bool b );
584
588 void showFormulaBar( bool b );
589
593 void popupTabBarMenu( const TQPoint& );
594
595 void handleDamages( const TQValueList<Damage*>& damages );
596
597 void runInternalTests();
598 void runInspector();
599
600 void initialiseMarkerFromSheet( Sheet *_sheet, const TQPoint &point );
601
605 void calcStatusBarOp();
606
607protected slots:
611 void slotActivateTool( int _id );
612 void slotInsert();
613 void slotInsertCellCopy();
614 void slotRemove();
615 void slotRename();
616
620 void popupChildMenu( KoChild*, const TQPoint& global_pos );
621
627
632 void slotPopupAdjustRow();
633
637 void slotItemSelected( int );
638 void slotListChoosePopupMenu( );
639
643 void slotHighlight( const TQString &text, int matchingIndex, int matchedLength );
647 void slotReplace( const TQString &newText, int, int, int );
648
649 void slotSpecialChar( TQChar c, const TQString & _font );
650 void slotSpecialCharDlgClosed();
651
652 void propertiesOk();
653
654 void objectSelectedChanged();
655
656protected slots:
657 void slotChildSelected( KoDocumentChild* ch );
658 void slotChildUnselected( KoDocumentChild* );
659
660public slots:
661 // Document signals
662 void slotRefreshView();
663 void slotUpdateView( Sheet *_sheet );
664 void slotUpdateView( Sheet *_sheet, const Region& );
665 void slotUpdateView( EmbeddedObject* obj );
666 void slotUpdateHBorder( Sheet *_sheet );
667 void slotUpdateVBorder( Sheet *_sheet );
668 void slotChangeSelection(const Region&);
669 void slotChangeChoice(const Region&);
670 void slotScrollChoice(const Region&);
671 void slotAddSheet( Sheet *_sheet );
672 void slotUpdateChildGeometry( EmbeddedKOfficeObject *_child );
673 void slotSheetRenamed( Sheet* sheet, const TQString& old_name );
674 void slotSheetHidden( Sheet*_sheet );
675 void slotSheetShown( Sheet*_sheet );
676 void slotSheetRemoved( Sheet*_sheet );
677 void refreshLocale();
678 void extraSpelling();
679
680 void spellCheckerReady();
681 void spellCheckerMisspelling( const TQString &, const TQStringList &, unsigned int);
682 void spellCheckerCorrected( const TQString &, const TQString &, unsigned int);
683 void spellCheckerDone( const TQString & );
684 void spellCheckerFinished( );
685 void spellCheckerIgnoreAll( const TQString & word);
686 void spellCheckerReplaceAll( const TQString &, const TQString &);
687 void startKSpell();
688
693 void commandExecuted();
694
695 virtual int leftBorder() const;
696 virtual int rightBorder() const;
697 virtual int topBorder() const;
698 virtual int bottomBorder() const;
699
700protected:
701
702 virtual void keyPressEvent ( TQKeyEvent * _ev );
703 virtual void resizeEvent( TQResizeEvent *_ev );
704
705 virtual TQWMatrix matrix() const;
706
713 KoPoint markerDocumentPosition();
714
721
722 virtual void updateReadWrite( bool readwrite );
723
724 virtual void guiActivateEvent( KParts::GUIActivateEvent *ev );
725
726 void initFindReplace();
727 Cell* findNextCell();
728
729private:
730 class Private;
731 Private* d;
732
733 // don't allow copy or assignment
734 View( const View& );
735 View& operator=( const View& );
736
737 void initView();
738
739 bool spellSwitchToOtherSheet();
740 void spellCleanup();
741
746 bool isLoading() const;
747
748 Cell* nextFindValidCell( int col, int row );
749
750 friend class Private;
751};
752
753} // namespace KSpread
754
755#endif // KSPREAD_VIEW
The canvas builds a part of the GUI of KSpread.
For every cell in the spread sheet there is a Cell object.
ComboboxLocationEditWidget.
This class holds the data that makes up a spreadsheet.
Definition kspread_doc.h:98
The widget that appears above the sheet and allows to edit the cells content.
Holds an embedded koffice object.
Contains basic information for every object.
void prependSelectedSheet(const TQString &sheetname)
Inserts given sheet to the list of sheets for printing at the top.
void prependAvailableSheet(const TQString &sheetname)
Inserts given sheet to the list of available sheets.
void getOptions(TQMap< TQString, TQString > &opts, bool incldef=false)
void clearSelection()
Removes all sheets from the list of selected sheets.
bool isValid(TQString &msg)
static TQString printOptionForIndex(unsigned int index)
The print order of the sheets is stored in the option map, using a prefix plus the index of the sheet...
void setOptions(const TQMap< TQString, TQString > &opts)
A widget that allows the user to enter an arbitrary cell location to goto or cell selection to highli...
The one for all class for points and ranges.
Definition region.h:44
The View class displays a KSpread document.
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)
void insertChart(const TQRect &_geometry, KoDocumentEntry &_entry)
void activateFormulaEditor()
Activates the formula editor for the current cell.
View(TQWidget *_parent, const char *_name, Doc *doc)
Creates a new view.
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.
The KSpread namespace.
Definition commands.h:39