kspread

kspread_view.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2006 Raphael Langerhorst <raphael.langerhorst@kdemail.net>
00003              (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
00004              (C) 1999-2003 Laurent Montel <montel@kde.org>
00005              (C) 2002-2003 Norbert Andres <nandres@web.de>
00006              (C) 2002-2003 Philipp Mueller <philipp.mueller@gmx.de>
00007              (C) 2002-2003 John Dailey <dailey@vt.edu>
00008              (C) 1999-2003 David Faure <faure@kde.org>
00009              (C) 1999-2001 Simon Hausmann <hausmann@kde.org>
00010              (C) 1998-2000 Torben Weis <weis@kde.org>
00011 
00012    This library is free software; you can redistribute it and/or
00013    modify it under the terms of the GNU Library General Public
00014    License as published by the Free Software Foundation; either
00015    version 2 of the License, or (at your option) any later version.
00016 
00017    This library is distributed in the hope that it will be useful,
00018    but WITHOUT ANY WARRANTY; without even the implied warranty of
00019    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020    Library General Public License for more details.
00021 
00022    You should have received a copy of the GNU Library General Public License
00023    along with this library; see the file COPYING.LIB.  If not, write to
00024    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00025  * Boston, MA 02110-1301, USA.
00026 */
00027 
00028 #ifndef KSPREAD_VIEW
00029 #define KSPREAD_VIEW
00030 
00031 #include <qpoint.h>
00032 #include <qptrlist.h>
00033 #include <qstringlist.h>
00034 #include <qvaluelist.h>
00035 
00036 #include <kprinter.h>
00037 #include <kdeprint/kprintdialogpage.h>
00038 
00039 #include <KoPoint.h>
00040 #include <KoView.h>
00041 
00042 
00043 class QScrollBar;
00044 
00045 class KoDocumentEntry;
00046 class KoTabBar;
00047 
00048 class SheetSelectWidget;
00049 
00050 namespace KSpread
00051 {
00052 class Cell;
00053 class Damage;
00054 class Sheet;
00055 class Canvas;
00056 class Child;
00057 class Doc;
00058 class EditWidget;
00059 class HBorder;
00060 class LocationEditWidget;
00061 class Region;
00062 class Selection;
00063 class VBorder;
00064 class View;
00065 class ComboboxLocationEditWidget;
00066 class EmbeddedKOfficeObject;
00067 class EmbeddedObject;
00068 
00069 
00080 class KPSheetSelectPage : public KPrintDialogPage
00081 {
00082   Q_OBJECT
00083   public:
00084     KPSheetSelectPage( QWidget *parent = 0 );
00085 //     ~KPSheetSelectPage();
00086 
00087 //     //reimplement virtual functions
00091     void getOptions( QMap<QString,QString>& opts, bool incldef = false );
00092 
00096     void setOptions( const QMap<QString,QString>& opts );
00097 
00101     bool isValid( QString& msg );
00102 
00106     QStringList selectedSheets();
00107 
00111     void clearSelection();
00112 
00124     static QString printOptionForIndex(unsigned int index);
00125 
00130     static QStringList selectedSheets(KPrinter &prt);
00131 
00132   public slots:
00133 
00137     void prependAvailableSheet(const QString& sheetname);
00138 
00142     void prependSelectedSheet(const QString& sheetname);
00143 
00144   protected slots:
00145 
00146     // The following slots just implement the code for the buttons
00147 
00148     void selectAll();
00149     void select();
00150     void remove();
00151     void removeAll();
00152 
00153     void moveTop();
00154     void moveUp();
00155     void moveDown();
00156     void moveBottom();
00157 
00158   private:
00159 
00164     SheetSelectWidget* gui;
00165 };
00166 
00167 
00186 class KSPREAD_EXPORT View : public KoView
00187 {
00188     friend class Canvas;
00189 
00190     Q_OBJECT
00191 public:
00192 
00194     View( QWidget *_parent, const char *_name,
00195         Doc *doc );
00196 
00198     ~View();
00199 
00200     Doc* doc() const;
00201 
00203     Canvas* canvasWidget() const;
00204 
00206     HBorder* hBorderWidget() const;
00207 
00209     VBorder* vBorderWidget() const;
00210 
00212     QScrollBar* horzScrollBar() const;
00213 
00215     QScrollBar* vertScrollBar() const;
00216 
00218     KSpread::EditWidget* editWidget() const;
00219 
00221     ComboboxLocationEditWidget* posWidget() const;
00222 
00224     KoTabBar* tabBar() const;
00225 
00226     void setZoom( int zoom, bool updateViews ); // change the zoom value
00227 
00228     void addSheet( Sheet *_t );
00229     //void removesheet( Sheet *_t );
00230     void removeAllSheets();
00231     void setActiveSheet( Sheet *_t,bool updatesheet=true );
00232 
00233     const Sheet* activeSheet() const;
00234     Sheet* activeSheet();
00235 
00236     void openPopupMenu( const QPoint &_global );
00237     void popupRowMenu(const QPoint & _point ) ;
00238     void popupColumnMenu( const QPoint & _point);
00239 
00240     // void showFormulaToolBar( bool show );
00241 
00245     void setText( const QString& _text, bool array = false );
00246 
00247     void enableUndo( bool _b );
00248     void enableRedo( bool _b );
00249     void enableInsertColumn( bool _b );
00250     void enableInsertRow( bool _b );
00251 
00259     void insertChart( const QRect& _geometry, KoDocumentEntry& _entry );
00267     void insertChild( const QRect& _geometry, KoDocumentEntry& _entry );
00268 
00269    // void insertPicture( const QRect& _geometry, KURL& _file );
00270 
00271     virtual void print( KPrinter &printer );
00272     virtual void setupPrinter( KPrinter &printer );
00273 
00279     void updateEditWidget();
00283     void updateEditWidgetOnPress();
00284 
00285 
00289     void deleteEditor( bool saveChanges = true );
00290     void closeEditor();
00291     virtual DCOPObject* dcopObject();
00292 
00293     virtual QWidget *canvas() const;
00294     virtual int canvasXOffset() const;
00295     virtual int canvasYOffset() const;
00296 
00300     KoDocument *hitTest( const QPoint &pos );
00301 
00302 
00303     void initConfig();
00304 
00305 
00306     void initCalcMenu();
00307 
00308     void changeNbOfRecentFiles(int _nb);
00309 
00310     void updateBorderButton();
00311 
00312     void removeSheet( Sheet *_t );
00313     void insertSheet( Sheet* sheet );
00314     QColor borderColor() const;
00315 
00316     Selection* selectionInfo() const;
00317     Selection* choice() const;
00318 
00319     void updateShowSheetMenu();
00320 
00325     void markSelectionAsDirty();
00326 
00330     void paintUpdates();
00331 
00335     void resetInsertHandle();
00336 
00337     bool isInsertingObject();
00338 
00339     bool showSheet(const QString& sheetName);
00340 
00344     QPoint markerFromSheet( Sheet* sheet ) const;
00345 
00349     KoPoint offsetFromSheet( Sheet* sheet ) const;
00350 
00355     void saveCurrentSheetSelection();
00356 
00357     void deleteSelectedObjects();
00358 
00362     static QColor highlightColor();
00363 
00364 public slots:
00368     void refreshView();
00369     void initialPosition();
00373     void createTemplate();
00374     void transformPart();
00375     void copySelection();
00376     void cutSelection();
00377     void deleteSelection();
00378     void clearTextSelection();
00379     void clearCommentSelection();
00380     void clearValiditySelection();
00381     void clearConditionalSelection();
00382     void fillRight();
00383     void fillLeft();
00384     void fillUp();
00385     void fillDown();
00386     void recalcWorkBook();
00387     void recalcWorkSheet();
00388     void paste();
00389     void specialPaste();
00390     void editCell();
00391     void setAreaName();
00392     void showAreaName();
00393     void adjust();
00394     void defaultSelection();
00395     void paperLayoutDlg();
00396     void styleDialog();
00397     void definePrintRange();
00398     void resetPrintRange();
00399     void insertObject();
00400     void insertFromDatabase();
00401     void insertFromTextfile();
00402     void insertFromClipboard();
00403     void insertSpecialChar();
00404     void togglePageBorders( bool );
00405     void toggleProtectSheet( bool );
00406     void toggleProtectDoc( bool );
00407     void viewZoom( const QString & );
00408     void find();
00409     void findNext();
00410     void findPrevious();
00411     void replace();
00412     void conditional();
00413     void validity();
00414     void insertSeries();
00415     void sort();
00416     void insertHyperlink();
00417     void removeHyperlink();
00418     void goalSeek();
00419     void multipleOperations();
00420     void subtotals();
00421     void textToColumns();
00422     void consolidate();
00423     void insertSheet();
00424     void removeSheet();
00425     void hideSheet();
00426     void showSheet();
00427     void helpUsing();
00428     void insertChart();
00429     void insertPicture();
00430     void moneyFormat(bool b);
00431     void alignLeft( bool b );
00432     void alignRight( bool b );
00433     void alignCenter( bool b );
00434     void alignTop( bool b );
00435     void alignMiddle( bool b );
00436     void alignBottom( bool b );
00437     void wrapText( bool b );
00438     void precisionMinus();
00439     void precisionPlus();
00440     void createStyleFromCell();
00441     void styleSelected( const QString & );
00442     void setSelectionPrecision(int delta);
00443     void percent(bool b);
00444     void fontSelected( const QString &_font );
00445     void fontSizeSelected( int size );
00446     void bold( bool b );
00447     void italic( bool b );
00448     void underline( bool b );
00449     void strikeOut( bool b );
00450     void deleteColumn();
00451     void insertColumn();
00452     void deleteRow();
00453     void insertRow();
00454     void hideRow();
00455     void showRow();
00456     void showSelRows();
00457     void hideColumn();
00458     void showColumn();
00459     void showSelColumns();
00460     void insertMathExpr();
00461     void formulaSelection( const QString &_math );
00462     void changeTextColor();
00463     void changeBackgroundColor();
00464     void sortInc();
00465     void sortDec();
00466     void layoutDlg();
00467     void extraProperties();
00468     void borderBottom();
00469     void borderRight();
00470     void borderLeft();
00471     void borderTop();
00472     void borderOutline();
00473     void borderAll();
00474     void borderRemove();
00475     void changeBorderColor();
00476     void sheetFormat();
00477     void autoSum();
00478     void resizeRow();
00479     void resizeColumn();
00480     void increaseFontSize();
00481     void decreaseFontSize();
00482     void setSelectionFontSize(int size);
00483 
00484     void setSelectionTextColor(const QColor &txtColor);
00485     void setSelectionBackgroundColor(const QColor &bgColor);
00486     void setSelectionBorderColor(const QColor &bdColor);
00487 
00488     void setSelectionLeftBorderColor(const QColor &color);
00489     void setSelectionRightBorderColor(const QColor &color);
00490     void setSelectionTopBorderColor(const QColor &color);
00491     void setSelectionBottomBorderColor(const QColor &color);
00492     void setSelectionAllBorderColor(const QColor &color);
00493     void setSelectionOutlineBorderColor(const QColor &color);
00494 
00495     void upper();
00496     void lower();
00497     void equalizeColumn();
00498     void equalizeRow();
00499     void preference();
00500     void firstLetterUpper();
00501     void verticalText(bool );
00502     void addModifyComment();
00503     void setSelectionComment(QString comment);
00504     void removeComment();
00505     void changeAngle();
00506     void setSelectionAngle(int angle);
00507 
00514     void mergeCell();
00515     void mergeCellHorizontal();
00516     void mergeCellVertical();
00517 
00518 
00524     void dissociateCell();
00525 
00526     void gotoCell();
00527     void increaseIndent();
00528     void decreaseIndent();
00529     void copyAsText();
00530 
00531     void moveSheet( unsigned sheet, unsigned target );
00532 
00536     void sheetProperties();
00537 
00542     void changeSheet( const QString& _name );
00543 
00548     void nextSheet();
00549 
00554     void previousSheet();
00555 
00560     void firstSheet();
00561 
00566     void lastSheet();
00567 
00568     void sortList();
00569 
00570     void statusBarClicked(int _id);
00571     void menuCalc(bool);
00572 
00576     void showStatusBar( bool b );
00577 
00581     void showTabBar( bool b );
00582 
00586     void showFormulaBar( bool b );
00587 
00591     void popupTabBarMenu( const QPoint& );
00592 
00593     void handleDamages( const QValueList<Damage*>& damages );
00594 
00595     void runInternalTests();
00596     void runInspector();
00597 
00598     void initialiseMarkerFromSheet( Sheet *_sheet, const QPoint &point );
00599 
00603     void calcStatusBarOp();
00604 
00605 protected slots:
00609     void slotActivateTool( int _id );
00610     void slotInsert();
00611     void slotInsertCellCopy();
00612     void slotRemove();
00613     void slotRename();
00614 
00618     void popupChildMenu( KoChild*, const QPoint& global_pos );
00619 
00624     void slotPopupDeleteChild();
00625 
00629     void slotPopupAdjustColumn();
00630     void slotPopupAdjustRow();
00631 
00635     void slotItemSelected( int );
00636     void slotListChoosePopupMenu( );
00637 
00641     void slotHighlight( const QString &text, int matchingIndex, int matchedLength );
00645     void slotReplace( const QString &newText, int, int, int );
00646 
00647     void slotSpecialChar( QChar c, const QString & _font );
00648     void slotSpecialCharDlgClosed();
00649 
00650     void propertiesOk();
00651 
00652     void objectSelectedChanged();
00653 
00654 protected slots:
00655     void slotChildSelected( KoDocumentChild* ch );
00656     void slotChildUnselected( KoDocumentChild* );
00657 
00658 public slots:
00659     // Document signals
00660     void slotRefreshView();
00661     void slotUpdateView( Sheet *_sheet );
00662     void slotUpdateView( Sheet *_sheet, const Region& );
00663     void slotUpdateView( EmbeddedObject* obj );
00664     void slotUpdateHBorder( Sheet *_sheet );
00665     void slotUpdateVBorder( Sheet *_sheet );
00666     void slotChangeSelection(const Region&);
00667     void slotChangeChoice(const Region&);
00668     void slotScrollChoice(const Region&);
00669     void slotAddSheet( Sheet *_sheet );
00670     void slotUpdateChildGeometry( EmbeddedKOfficeObject *_child );
00671     void slotSheetRenamed( Sheet* sheet, const QString& old_name );
00672     void slotSheetHidden( Sheet*_sheet );
00673     void slotSheetShown( Sheet*_sheet );
00674     void slotSheetRemoved( Sheet*_sheet );
00675     void refreshLocale();
00676     void extraSpelling();
00677 
00678     void spellCheckerReady();
00679     void spellCheckerMisspelling( const QString &, const QStringList &, unsigned int);
00680     void spellCheckerCorrected( const QString &, const QString &, unsigned int);
00681     void spellCheckerDone( const QString & );
00682     void spellCheckerFinished( );
00683     void spellCheckerIgnoreAll( const QString & word);
00684     void spellCheckerReplaceAll( const QString &,  const QString &);
00685     void startKSpell();
00686 
00691     void commandExecuted();
00692 
00693     virtual int leftBorder() const;
00694     virtual int rightBorder() const;
00695     virtual int topBorder() const;
00696     virtual int bottomBorder() const;
00697 
00698 protected:
00699 
00700     virtual void keyPressEvent ( QKeyEvent * _ev );
00701     virtual void resizeEvent( QResizeEvent *_ev );
00702 
00703     virtual QWMatrix matrix() const;
00704 
00711     KoPoint markerDocumentPosition();
00712 
00718     void activateFormulaEditor();
00719 
00720     virtual void updateReadWrite( bool readwrite );
00721 
00722     virtual void guiActivateEvent( KParts::GUIActivateEvent *ev );
00723 
00724     void initFindReplace();
00725     Cell* findNextCell();
00726 
00727 private:
00728     class Private;
00729     Private* d;
00730 
00731     // don't allow copy or assignment
00732     View( const View& );
00733     View& operator=( const View& );
00734 
00735     void initView();
00736 
00737     bool spellSwitchToOtherSheet();
00738     void spellCleanup();
00739 
00744     bool isLoading() const;
00745 
00746     Cell* nextFindValidCell( int col, int row );
00747 
00748     friend class Private;
00749 };
00750 
00751 } // namespace KSpread
00752 
00753 #endif // KSPREAD_VIEW
KDE Home | KDE Accessibility Home | Description of Access Keys