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 
00309     bool isLoading() const;
00310 
00311 
00312     void initCalcMenu();
00313 
00314     void changeNbOfRecentFiles(int _nb);
00315 
00316     void updateBorderButton();
00317 
00318     void removeSheet( Sheet *_t );
00319     void insertSheet( Sheet* sheet );
00320     QColor borderColor() const;
00321 
00322     Selection* selectionInfo() const;
00323     Selection* choice() const;
00324 
00325     void updateShowSheetMenu();
00326 
00331     void markSelectionAsDirty();
00332      
00336     void paintUpdates();
00337 
00341     void resetInsertHandle();
00342 
00343     bool isInsertingObject();
00344 
00345     bool showSheet(const QString& sheetName);
00346 
00347     QPoint markerFromSheet( Sheet *_sheet ) const;
00348     /*
00349      * Save current sheet selection. Call when we change sheet, or save in oasis format
00350      */
00351     void saveCurrentSheetSelection();
00352 
00353     void deleteSelectedObjects();
00354     
00358     static QColor highlightColor();
00359 
00360 public slots:
00364     void refreshView();
00365     void initialPosition();
00369     void createTemplate();
00370     void transformPart();
00371     void copySelection();
00372     void cutSelection();
00373     void deleteSelection();
00374     void clearTextSelection();
00375     void clearCommentSelection();
00376     void clearValiditySelection();
00377     void clearConditionalSelection();
00378     void fillRight();
00379     void fillLeft();
00380     void fillUp();
00381     void fillDown();
00382     void recalcWorkBook();
00383     void recalcWorkSheet();
00384     void paste();
00385     void specialPaste();
00386     void editCell();
00387     void setAreaName();
00388     void showAreaName();
00389     void adjust();
00390     void defaultSelection();
00391     void paperLayoutDlg();
00392     void styleDialog();
00393     void definePrintRange();
00394     void resetPrintRange();
00395     void insertObject();
00396     void insertFromDatabase();
00397     void insertFromTextfile();
00398     void insertFromClipboard();
00399     void insertSpecialChar();
00400     void togglePageBorders( bool );
00401     void toggleProtectSheet( bool );
00402     void toggleProtectDoc( bool );
00403     void viewZoom( const QString & );
00404     void find();
00405     void findNext();
00406     void findPrevious();
00407     void replace();
00408     void conditional();
00409     void validity();
00410     void insertSeries();
00411     void sort();
00412     void insertHyperlink();
00413     void removeHyperlink();
00414     void goalSeek();
00415     void multipleOperations();
00416     void subtotals();
00417     void textToColumns();
00418     void consolidate();
00419     void insertSheet();
00420     void removeSheet();
00421     void hideSheet();
00422     void showSheet();
00423     void helpUsing();
00424     void insertChart();
00425     void insertPicture();
00426     void moneyFormat(bool b);
00427     void alignLeft( bool b );
00428     void alignRight( bool b );
00429     void alignCenter( bool b );
00430     void alignTop( bool b );
00431     void alignMiddle( bool b );
00432     void alignBottom( bool b );
00433     void wrapText( bool b );
00434     void precisionMinus();
00435     void precisionPlus();
00436     void createStyleFromCell();
00437     void styleSelected( const QString & );
00438     void setSelectionPrecision(int delta);
00439     void percent(bool b);
00440     void fontSelected( const QString &_font );
00441     void fontSizeSelected( int size );
00442     void bold( bool b );
00443     void italic( bool b );
00444     void underline( bool b );
00445     void strikeOut( bool b );
00446     void deleteColumn();
00447     void insertColumn();
00448     void deleteRow();
00449     void insertRow();
00450     void hideRow();
00451     void showRow();
00452     void showSelRows();
00453     void hideColumn();
00454     void showColumn();
00455     void showSelColumns();
00456     void insertMathExpr();
00457     void formulaSelection( const QString &_math );
00458     void changeTextColor();
00459     void changeBackgroundColor();
00460     void sortInc();
00461     void sortDec();
00462     void layoutDlg();
00463     void extraProperties();
00464     void borderBottom();
00465     void borderRight();
00466     void borderLeft();
00467     void borderTop();
00468     void borderOutline();
00469     void borderAll();
00470     void borderRemove();
00471     void changeBorderColor();
00472     void sheetFormat();
00473     void autoSum();
00474     void resizeRow();
00475     void resizeColumn();
00476     void increaseFontSize();
00477     void decreaseFontSize();
00478     void setSelectionFontSize(int size);
00479 
00480     void setSelectionTextColor(const QColor &txtColor);
00481     void setSelectionBackgroundColor(const QColor &bgColor);
00482     void setSelectionBorderColor(const QColor &bdColor);
00483 
00484     void setSelectionLeftBorderColor(const QColor &color);
00485     void setSelectionRightBorderColor(const QColor &color);
00486     void setSelectionTopBorderColor(const QColor &color);
00487     void setSelectionBottomBorderColor(const QColor &color);
00488     void setSelectionAllBorderColor(const QColor &color);
00489     void setSelectionOutlineBorderColor(const QColor &color);
00490 
00491     void upper();
00492     void lower();
00493     void equalizeColumn();
00494     void equalizeRow();
00495     void preference();
00496     void firstLetterUpper();
00497     void verticalText(bool );
00498     void addModifyComment();
00499     void setSelectionComment(QString comment);
00500     void removeComment();
00501     void changeAngle();
00502     void setSelectionAngle(int angle);
00503 
00510     void mergeCell();
00511     void mergeCellHorizontal();
00512     void mergeCellVertical();
00513     
00514 
00520     void dissociateCell();
00521 
00522     void gotoCell();
00523     void increaseIndent();
00524     void decreaseIndent();
00525     void copyAsText();
00526 
00527     void moveSheet( unsigned sheet, unsigned target );
00528 
00532     void sheetProperties();
00533 
00538     void changeSheet( const QString& _name );
00539 
00544     void nextSheet();
00545 
00550     void previousSheet();
00551 
00556     void firstSheet();
00557 
00562     void lastSheet();
00563 
00564     void sortList();
00565 
00566     void statusBarClicked(int _id);
00567     void menuCalc(bool);
00568 
00572     void showStatusBar( bool b );
00573 
00577     void showTabBar( bool b );
00578 
00582     void showFormulaBar( bool b );
00583 
00587     void popupTabBarMenu( const QPoint& );
00588 
00589     void handleDamages( const QValueList<Damage*>& damages );
00590 
00591     void runInternalTests();
00592     void runInspector();
00593 
00594     void initialiseMarkerFromSheet( Sheet *_sheet, const QPoint &point );
00595 
00599     void calcStatusBarOp();
00600 
00601 protected slots:
00605     void slotActivateTool( int _id );
00606     void slotInsert();
00607     void slotInsertCellCopy();
00608     void slotRemove();
00609     void slotRename();
00610 
00614     void popupChildMenu( KoChild*, const QPoint& global_pos );
00615 
00620     void slotPopupDeleteChild();
00621 
00625     void slotPopupAdjustColumn();
00626     void slotPopupAdjustRow();
00627 
00631     void slotItemSelected( int );
00632     void slotListChoosePopupMenu( );
00633 
00637     void slotHighlight( const QString &text, int matchingIndex, int matchedLength );
00641     void slotReplace( const QString &newText, int, int, int );
00642 
00643     void slotSpecialChar( QChar c, const QString & _font );
00644     void slotSpecialCharDlgClosed();
00645 
00646     void propertiesOk();
00647 
00648     void objectSelectedChanged();
00649 
00650 protected slots:
00651     void slotChildSelected( KoDocumentChild* ch );
00652     void slotChildUnselected( KoDocumentChild* );
00653 
00654 public slots:
00655     // Document signals
00656     void slotRefreshView();
00657     void slotUpdateView( Sheet *_sheet );
00658     void slotUpdateView( Sheet *_sheet, const Region& );
00659     void slotUpdateView( EmbeddedObject* obj );
00660     void slotUpdateHBorder( Sheet *_sheet );
00661     void slotUpdateVBorder( Sheet *_sheet );
00662     void slotChangeSelection(const Region&);
00663     void slotChangeChoice(const Region&);
00664     void slotAddSheet( Sheet *_sheet );
00665     void slotUpdateChildGeometry( EmbeddedKOfficeObject *_child );
00666     void slotSheetRenamed( Sheet* sheet, const QString& old_name );
00667     void slotSheetHidden( Sheet*_sheet );
00668     void slotSheetShown( Sheet*_sheet );
00669     void slotSheetRemoved( Sheet*_sheet );
00670     void refreshLocale();
00671     void extraSpelling();
00672 
00673     void spellCheckerReady();
00674     void spellCheckerMisspelling( const QString &, const QStringList &, unsigned int);
00675     void spellCheckerCorrected( const QString &, const QString &, unsigned int);
00676     void spellCheckerDone( const QString & );
00677     void spellCheckerFinished( );
00678     void spellCheckerIgnoreAll( const QString & word);
00679     void spellCheckerReplaceAll( const QString &,  const QString &);
00680     void startKSpell();
00681 
00686     void commandExecuted();
00687 
00688     virtual int leftBorder() const;
00689     virtual int rightBorder() const;
00690     virtual int topBorder() const;
00691     virtual int bottomBorder() const;
00692 
00693 protected:
00694 
00695     virtual void keyPressEvent ( QKeyEvent * _ev );
00696     virtual void resizeEvent( QResizeEvent *_ev );
00697 
00698     virtual QWMatrix matrix() const;
00699 
00706     KoPoint markerDocumentPosition();
00707     
00713     void activateFormulaEditor();
00714 
00715     virtual void updateReadWrite( bool readwrite );
00716 
00717     virtual void guiActivateEvent( KParts::GUIActivateEvent *ev );
00718 
00719     void initFindReplace();
00720     Cell* findNextCell();
00721 
00722 private:
00723     class Private;
00724     Private* d;
00725 
00726     // don't allow copy or assignment
00727     View( const View& );
00728     View& operator=( const View& );
00729 
00730     void initView();
00731 
00732     bool spellSwitchToOtherSheet();
00733     void spellCleanup();
00734 
00735     Cell* nextFindValidCell( int col, int row );
00736     
00737     friend class Private;
00738 };
00739 
00740 } // namespace KSpread
00741 
00742 #endif // KSPREAD_VIEW
KDE Home | KDE Accessibility Home | Description of Access Keys