kspread

kspread_sheet.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
00003              (C) 1999-2005 The KSpread Team
00004                            www.koffice.org/kspread
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KSPREAD_SHEET
00023 #define KSPREAD_SHEET
00024 
00025 #include <qclipboard.h>
00026 #include <qdragobject.h>
00027 #include <qintdict.h>
00028 #include <qmemarray.h>
00029 #include <qpen.h>
00030 #include <qptrlist.h>
00031 #include <qrect.h>
00032 #include <qwidget.h>
00033 
00034 #include <KoDocument.h>
00035 #include <KoDocumentChild.h>
00036 #include <KoOasisSettings.h> // for KoOasisSettings::NamedMap
00037 
00038 #include "kspread_autofill.h"
00039 #include "kspread_cell.h"
00040 #include "kspread_format.h"
00041 #include "kspread_global.h"
00042 #include "kspread_object.h"
00043 
00044 class QWidget;
00045 class QPainter;
00046 class QDomElement;
00047 class DCOPObject;
00048 class KPrinter;
00049 class KoDocumentEntry;
00050 class KoStyleStack;
00051 class KoGenStyles;
00052 class KoOasisLoadingContext;
00053 class KoOasisSettings;
00054 class KoOasisStyles;
00055 class KCommand;
00056 class KoPicture;
00057 class KoXmlWriter;
00058 
00059 namespace KoChart
00060 {
00061 class Part;
00062 }
00063 
00064 namespace KSpread
00065 {
00066 class Canvas;
00067 class Cell;
00068 class EmbeddedChart;
00069 class DependencyManager;
00070 class Doc;
00071 class GenValidationStyles;
00072 class Map;
00073 class Point;
00074 class Region;
00075 class Selection;
00076 class Sheet;
00077 class SheetPrint;
00078 class Style;
00079 class UndoInsertRemoveAction;
00080 class View;
00081 class EmbeddedKOfficeObject;
00082 class EmbeddedObject;
00083 
00084 /********************************************************************
00085  *
00086  * CellBinding
00087  *
00088  ********************************************************************/
00089 
00093 class CellBinding : public QObject
00094 {
00095     Q_OBJECT
00096 public:
00097     CellBinding( Sheet *_sheet, const QRect& _area );
00098     virtual ~CellBinding();
00099 
00100     bool contains( int _x, int _y );
00107     virtual void cellChanged( Cell *_obj );
00108 
00109     virtual void setIgnoreChanges( bool _ignore ) { m_bIgnoreChanges = _ignore; }
00110 
00111     virtual QRect& dataArea() { return m_rctDataArea; }
00112     virtual void setDataArea( const QRect _rect ) { m_rctDataArea = _rect; }
00113 
00114     Sheet* sheet()const { return m_pSheet; }
00115 
00116 signals:
00117     void changed( Cell *_obj );
00118 
00119 protected:
00120     QRect m_rctDataArea;
00121     Sheet *m_pSheet;
00122     bool m_bIgnoreChanges;
00123 };
00124 
00125 class ChartBinding : public CellBinding
00126 {
00127     Q_OBJECT
00128 public:
00129 
00130     ChartBinding( Sheet *_sheet, const QRect& _area, EmbeddedChart *_child );
00131     virtual ~ChartBinding();
00132 
00133     virtual void cellChanged( Cell *_obj );
00134 
00135 private:
00136     EmbeddedChart* m_child;
00137 };
00138 
00139 /********************************************************************
00140  *
00141  * TextDrag
00142  *
00143  ********************************************************************/
00144 
00149 class TextDrag : public QTextDrag
00150 {
00151     Q_OBJECT
00152 
00153 public:
00154     TextDrag( QWidget * dragSource = 0L, const char * name = 0L );
00155     virtual ~TextDrag();
00156 
00157     void setPlain( QString const & _plain ) { setText( _plain ); }
00158     void setKSpread( QByteArray const & _kspread ) { m_kspread = _kspread; }
00159 
00160     virtual QByteArray encodedData( const char * mime ) const;
00161     virtual const char* format( int i ) const;
00162 
00163     static bool canDecode( QMimeSource * e );
00164 
00165     static const char * selectionMimeType();
00166 
00167 protected:
00168     QByteArray m_kspread;
00169 };
00170 
00171 
00172 /********************************************************************
00173  *
00174  * Sheet
00175  *
00176  ********************************************************************/
00177 
00180 class KSPREAD_EXPORT Sheet : public QObject
00181 {
00182     friend class Cell;
00183 
00184     Q_OBJECT
00185 
00186 
00187     Q_PROPERTY( QString sheetName READ sheetName )
00188     Q_PROPERTY( bool autoCalc READ getAutoCalc WRITE setAutoCalc )
00189     Q_PROPERTY( bool showGrid READ getShowGrid WRITE setShowGrid )
00190 
00191 public:
00192     enum Direction { Right, Left, Up, Down };
00193     enum SortingOrder{ Increase, Decrease };
00194     enum ChangeRef { ColumnInsert, ColumnRemove, RowInsert, RowRemove };
00195     enum TestType { Text, Validity, Comment, ConditionalCellAttribute };
00196 
00197     enum LayoutDirection { LeftToRight, RightToLeft };
00198 
00199     Sheet ( Map* map, const QString &sheetName, const char *_name=0L );
00200     ~Sheet();
00201 
00202     virtual bool isEmpty( unsigned long int x, unsigned long int y ) const;
00203 
00207     QString sheetName() const;
00208 
00212     QString tableName() const { return sheetName(); }
00213 
00233     bool setSheetName( const QString& name, bool init = false, bool makeUndo=true );
00234 
00235     Map* workbook() const;
00236     Doc* doc() const;
00237 
00241     virtual QDomElement saveXML( QDomDocument& );
00245     virtual bool loadXML( const QDomElement& );
00246 
00247     virtual bool loadOasis( const QDomElement& sheet, KoOasisLoadingContext& oasisContext, QDict<Style>& styleMap );
00248 
00249     virtual bool saveOasis( KoXmlWriter & xmlWriter, KoGenStyles &mainStyles, GenValidationStyles &valStyle, KoStore *store, KoXmlWriter* manifestWriter, int & indexObj, int &partIndexObj );
00250     void saveOasisHeaderFooter( KoXmlWriter &xmlWriter ) const;
00251 
00252     void loadOasisObjects( const QDomElement& e, KoOasisLoadingContext& oasisContext );
00253     void loadOasisSettings( const KoOasisSettings::NamedMap &settings );
00254     void saveOasisSettings( KoXmlWriter &settingsWriter ) const;
00255     void saveOasisPrintStyleLayout( KoGenStyle &style ) const;
00256 
00260     virtual bool saveChildren( KoStore* _store, const QString &_path );
00261     bool saveOasisObjects( KoStore *store, KoXmlWriter &xmlWriter, KoGenStyles& mainStyles, int & indexObj, int &partIndexObj );
00265     virtual bool loadChildren( KoStore* _store );
00266 
00267     bool isLoading();
00268 
00269 
00275     QPtrList<EmbeddedObject> getSelectedObjects();
00276 
00277 
00286     KoRect getRealRect( bool all );
00287 
00288     //return command when we move object
00289     KCommand *moveObject(View *_view, double diffx, double diffy);
00290     KCommand *moveObject(View *m_view,const KoPoint &_move,bool key);
00291 
00301     void unifyObjectName( EmbeddedObject *object );
00302 
00306     LayoutDirection layoutDirection() const;
00307 
00312     void setLayoutDirection( LayoutDirection dir );
00313 
00317     bool isRightToLeft() const;
00318 
00319     void password( QCString & passwd ) const ;
00320     bool isProtected() const;
00321     void setProtected( QCString const & passwd );
00322     bool checkPassword( QCString const & passwd ) const;
00323 
00324     void setDefaultHeight( double height );
00325     void setDefaultWidth( double width );
00326 
00327     const ColumnFormat* columnFormat( int _column ) const;
00328     ColumnFormat* columnFormat( int _column );
00334     ColumnFormat* nonDefaultColumnFormat( int _column, bool force_creation = true );
00335 
00336     const RowFormat* rowFormat( int _row ) const;
00337     RowFormat* rowFormat( int _row );
00343     RowFormat* nonDefaultRowFormat( int _row, bool force_creation = true );
00344 
00349     Cell* firstCell() const;
00350 
00351     RowFormat* firstRow() const;
00352 
00353     ColumnFormat* firstCol() const;
00354 
00355     Cell* cellAt( int _column, int _row ) const;
00362     Cell* cellAt( int _column, int _row, bool _scrollbar_update = false );
00366     Cell* cellAt( const QPoint& _point, bool _scrollbar_update = false )
00367       { return cellAt( _point.x(), _point.y(), _scrollbar_update ); }
00377     Cell* visibleCellAt( int _column, int _row, bool _scrollbar_update = false );
00388     Cell* nonDefaultCell( int _column, int _row, bool _scrollbar_update = false, Style * _style = 0 );
00389     Cell* nonDefaultCell( QPoint const & cellRef, bool scroll = false )
00390       { return nonDefaultCell( cellRef.x(), cellRef.y(), scroll ); }
00391 
00392     Cell* defaultCell() const;
00393 
00394     Format* defaultFormat();
00395     const Format* defaultFormat() const;
00396 
00398     Value value (int col, int row) const;
00400     Value valueRange (int col1, int row1, int col2, int row2) const;
00401 
00402     QRect visibleRect( Canvas const * const _canvas ) const;
00403     int topRow( double _ypos, double &_top, const Canvas *_canvas = 0L ) const;
00404     int bottomRow( double _ypos, const Canvas *_canvas = 0L ) const;
00405     int leftColumn( double _xpos, double &_left, const Canvas *_canvas = 0L ) const;
00406     int rightColumn( double _xpos, const Canvas *_canvas = 0L ) const;
00407 
00415     int columnPos( int _col, const Canvas *_canvas = 0L ) const;
00425     double dblColumnPos( int _col, const Canvas *_canvas = 0L ) const;
00433     int rowPos( int _row, const Canvas *_canvas = 0L ) const;
00443     double dblRowPos( int _row, const Canvas *_canvas = 0L ) const;
00444 
00448     double sizeMaxX() const ;
00452     double sizeMaxY() const;
00453 
00458     void adjustSizeMaxX ( double _x );
00459 
00464     void adjustSizeMaxY ( double _y );
00465 
00469     void setLayoutDirtyFlag();
00476     void setCalcDirtyFlag();
00477 
00481   //why on earth would we want to do this?
00482 //    void calc();
00483 
00495     void recalc( bool force );
00499     void recalc();
00500 
00501 
00504     void valueChanged (Cell *cell);
00505 
00514     QString guessColumnTitle(QRect& area, int col);
00515 
00523     QString guessRowTitle(QRect& area, int row);
00524 
00528     void setText( int row, int column, const QString& text,
00529                   bool asString = false );
00530     void setArrayFormula (Selection *selectionInfo, const QString &_text);
00531 
00532 
00533     void setSelectionFont( Selection* selectionInfo,
00534                            const char *_font = 0L, int _size = -1,
00535                            signed char _bold = -1, signed char _italic = -1,
00536                            signed char _underline = -1,
00537                            signed char _strike = -1 );
00538 
00539     void setSelectionMoneyFormat( Selection* selectionInfo, bool b );
00540     void setSelectionAlign( Selection* selectionInfo,
00541                             Format::Align _align );
00542     void setSelectionAlignY( Selection* selectionInfo,
00543                              Format::AlignY _alignY );
00544     void setSelectionPrecision( Selection* selectionInfo, int _delta );
00545     void setSelectionPercent( Selection* selectionInfo, bool b );
00546     void setSelectionMultiRow( Selection* selectionInfo, bool enable );
00547     void setSelectionStyle( Selection* selectionInfo, Style * style );
00548 
00552     void setSelectionSize( Selection* selectionInfo, int _size );
00553 
00558     void setSelectionUpperLower( Selection* selectionInfo, int _type );
00559 
00560     void setSelectionfirstLetterUpper( Selection* selectionInfo);
00561 
00562     void setSelectionVerticalText( Selection* selectionInfo, bool _b);
00563 
00564     void setSelectionComment( Selection* selectionInfo,
00565                               const QString &_comment);
00566     void setSelectionRemoveComment(Selection* selectionInfo);
00567 
00568     void setSelectionAngle(Selection* selectionInfo, int _value );
00569 
00570     void setSelectionTextColor( Selection* selectionInfo,
00571                                 const QColor &tbColor );
00572     void setSelectionbgColor( Selection* selectionInfo,
00573                               const QColor &bg_Color );
00574     void setSelectionBorderColor( Selection* selectionInfo,
00575                                   const QColor &bd_Color );
00576 
00583     void deleteSelection( Selection* selectionInfo, bool undo = true );
00584 
00590     void copySelection( Selection* selectionInfo );
00596     void cutSelection( Selection* selectionInfo );
00602     void clearTextSelection( Selection* selectionInfo );
00603 
00604     void clearValiditySelection(Selection* selectionInfo );
00605 
00606     void clearConditionalSelection(Selection* selectionInfo );
00607 
00608     void fillSelection( Selection * selectionInfo, int direction );
00609 
00610     void setWordSpelling(Selection* selectionInfo,const QString _listWord );
00611 
00612     QString getWordSpelling(Selection* selectionInfo );
00613 
00618     void paste( const QRect & pasteArea, bool makeUndo = true,
00619                 Paste::Mode = Paste::Normal, Paste::Operation = Paste::OverWrite,
00620                 bool insert = false, int insertTo = 0, bool pasteFC = false,
00621                 QClipboard::Mode clipboardMode = QClipboard::Clipboard );
00622     void paste( const QByteArray & data, const QRect & pasteArea,
00623                 bool makeUndo = false, Paste::Mode= Paste::Normal, Paste::Operation = Paste::OverWrite,
00624                 bool insert = false, int insertTo = 0, bool pasteFC = false );
00625     void defaultSelection( Selection* selectionInfo );
00626 
00630     void pasteTextPlain( QString &_text, QRect pasteArea);
00631 
00632     void sortByRow( const QRect &area, int ref_row, SortingOrder );
00633     void sortByRow( const QRect &area, int key1, int key2, int key3,
00634                     SortingOrder order1, SortingOrder order2, SortingOrder order3,
00635                     QStringList const * firstKey, bool copyFormat, bool headerRow,
00636                     Point const & outputPoint, bool respectCase );
00637     void sortByColumn( const QRect &area, int ref_column, SortingOrder );
00638     void sortByColumn( const QRect &area, int key1, int key2, int key3,
00639                        SortingOrder order1, SortingOrder order2, SortingOrder order3,
00640                        QStringList const * firstKey, bool copyFormat, bool headerCol,
00641                        Point const & outputPoint, bool respectCase );
00642     void swapCells( int x1, int y1, int x2, int y2, bool cpFormat );
00643 
00649     void copyCells( int x1, int y1, int x2, int y2, bool cpFormat );
00650     void setSeries( const QPoint &_marker, double start, double end, double step, Series mode, Series type );
00651 
00661     bool shiftRow( const QRect &_rect, bool makeUndo=true );
00662     bool shiftColumn( const QRect& rect, bool makeUndo=true );
00663 
00664     void unshiftColumn( const QRect& rect, bool makeUndo=true );
00665     void unshiftRow( const QRect& rect, bool makeUndo=true );
00666 
00672     bool insertColumn( int col, int nbCol=0, bool makeUndo=true );
00677     bool insertRow( int row, int nbRow=0, bool makeUndo=true );
00678 
00682     void removeColumn( int col, int nbCol=0, bool makeUndo=true );
00686     void removeRow( int row, int nbRow=0, bool makeUndo=true );
00687 
00691     void hideRow(const Region&);
00692     void emitHideRow();
00693     void showRow(const Region&);
00694 
00698     void hideColumn(const Region&);
00699     void emitHideColumn();
00700     void showColumn(const Region&);
00701 
00705     void adjustArea(const Region&);
00709     void adjustColumn(const Region&);
00713     void adjustRow(const Region&);
00714 
00718     void borderLeft( Selection* selectionInfo, const QColor &_color );
00719     void borderTop( Selection* selectionInfo, const QColor &_color );
00720     void borderOutline( Selection* selectionInfo, const QColor &_color );
00721     void borderAll( Selection* selectionInfo, const QColor &_color );
00722     void borderRemove( Selection* selectionInfo );
00723     void borderBottom( Selection* selectionInfo, const QColor &_color );
00724     void borderRight( Selection* selectionInfo, const QColor &_color );
00725 
00726     void setConditional( Selection* selectionInfo,
00727        QValueList<Conditional> const & newConditions );
00728 
00729     void setValidity( Selection* selectionInfo, KSpread::Validity tmp );
00730 
00734     bool getShowGrid() const;
00735 
00739     void setShowGrid( bool _showGrid );
00740 
00744     bool getShowFormula() const;
00745 
00746     void setShowFormula(bool _showFormula);
00747 
00751     bool getShowFormulaIndicator() const;
00752 
00753     void setShowFormulaIndicator(bool _showFormulaIndicator);
00754 
00758     bool getShowCommentIndicator() const;
00759 
00764     void setShowCommentIndicator( bool b );
00765 
00766     bool getLcMode() const;
00767 
00768     void setLcMode(bool _lcMode);
00769 
00770     bool getAutoCalc() const;
00771 
00772     void setAutoCalc(bool _AutoCalc);
00773 
00774     bool getShowColumnNumber() const;
00775 
00776     void setShowColumnNumber(bool _showColumnNumber);
00777 
00778     bool getHideZero() const;
00779 
00780     void setHideZero(bool _hideZero);
00781 
00782     bool getFirstLetterUpper() const;
00783 
00784     void setFirstLetterUpper(bool _firstUpper);
00785 
00786     // TODO Stefan: remove after kspread_undo.cc|h and commands.cc|h are obsolete
00787     void changeMergedCell( int /*m_iCol*/, int /*m_iRow*/, int /*m_iExtraX*/, int /*m_iExtraY*/) {}
00788 
00794     void mergeCells( const Region& region, bool hor = false, bool ver = false );
00795     void dissociateCells( const Region &region );
00796 
00797     void increaseIndent( Selection* selectionInfo );
00798     void decreaseIndent( Selection* selectionInfo );
00799 
00800     bool areaIsEmpty(const Region& area, TestType _type = Text) ;
00801 
00802     void refreshPreference() ;
00803 
00804     void hideSheet(bool _hide);
00805 
00806     void removeSheet();
00807 
00808     QRect selectionCellMerged(const QRect &_sel);
00823     void changeNameCellRef( const QPoint & pos, bool fullRowOrColumn,
00824                             ChangeRef ref, QString tabname, int NbCol = 1,
00825                             UndoInsertRemoveAction * undo = 0 );
00826 
00827 
00828     void refreshRemoveAreaName(const QString &_areaName);
00829     void refreshChangeAreaName(const QString &_areaName);
00830 
00831 
00842     void refreshChart(const QPoint & pos, bool fullRowOrColumn, ChangeRef ref);
00846     void refreshMergedCell();
00847 
00851     bool isHidden()const;
00855     void setHidden( bool hidden );
00856 
00863     QPainter& painter();
00869     QWidget* widget()const;
00870 
00877     bool isShowPageBorders() const;
00878 
00885     void setShowPageBorders( bool _b );
00886 
00887     void addCellBinding( CellBinding *_bind );
00888     void removeCellBinding( CellBinding *_bind );
00889     CellBinding* firstCellBinding();
00890     CellBinding* nextCellBinding();
00891 
00897     bool getCellRectangle( const QRect &_range, QPtrList<Cell> &_list );
00898 
00902     Sheet *findSheet( const QString & _name );
00903 
00909     void insertCell( Cell *_cell );
00915     void insertColumnFormat( ColumnFormat *_l );
00921     void insertRowFormat( RowFormat *_l );
00922 
00929     QDomDocument saveCellRegion(const Region&, bool copy = false, bool era = false);
00930 
00938     bool loadSelection( const QDomDocument& doc, const QRect &pasteArea,
00939                         int _xshift, int _yshift, bool makeUndo,
00940                         Paste::Mode = Paste::Normal, Paste::Operation = Paste::OverWrite,
00941                         bool insert = false, int insertTo = 0, bool paste = false );
00942 
00943     void loadSelectionUndo( const QDomDocument & doc, const QRect &loadArea,
00944                             int _xshift, int _yshift,bool insert,int insertTo);
00945 
00953     bool testAreaPasteInsert()const;
00954 
00965     void deleteCells(const Region& region);
00966 
00967 
00972     bool testListChoose(Selection* selectionInfo);
00973 
00977     QString copyAsText(Selection* selection);
00978 
00987     void autofill( QRect &src, QRect &dest );
00988 
00989 
00990     bool insertChild( const KoRect& _geometry, KoDocumentEntry& );
00991 
00992     bool insertChart( const KoRect& _geometry, KoDocumentEntry&, const QRect& _data );
00993 
00994 
01005     bool insertPicture( const KoPoint& point , const KURL& file );
01006 
01013     bool insertPicture( const KoPoint& point, const QPixmap& pixmap );
01014 
01015     void changeChildGeometry( EmbeddedKOfficeObject *_child, const KoRect& _geometry );
01016 
01017     const QColorGroup& colorGroup() { return widget()->colorGroup(); }
01018 
01019     int id() const;
01020 
01026     int maxColumn() const ;
01027 
01034     void checkRangeHBorder ( int _column );
01035 
01041     int maxRow() const ;
01042 
01049     void checkRangeVBorder ( int _row );
01050 
01051 
01052     void enableScrollBarUpdates( bool _enable );
01053 
01054     virtual DCOPObject* dcopObject();
01055 
01056     static Sheet* find( int _id );
01057 
01058 #ifndef NDEBUG
01059     void printDebug();
01060 #endif
01061 
01067     void updateCell( Cell* _cell, int _col, int _row );
01068 
01074     void updateCellArea(const Region& cellArea);
01075 
01079     void update();
01080 
01084     void updateView();
01085 
01089     void updateView( QRect const & rect );
01090 
01094     void updateView(Region*);
01095 
01099     void refreshView(const Region& region);
01100 
01101     void emit_updateRow( RowFormat *_format, int _row, bool repaint = true );
01102     void emit_updateColumn( ColumnFormat *_format, int _column );
01103 
01110     const QPen& emptyPen() const ;
01111     const QBrush& emptyBrush() const;
01112     const QColor& emptyColor() const;
01113 
01114     void updateLocale();
01115 
01116 
01122   void setRegionPaintDirty(QRect const & range);
01123   void setRegionPaintDirty(Region const & region);
01124 
01128   void clearPaintDirtyData();
01129 
01133   bool cellIsPaintDirty(QPoint const & cell) const;
01134 
01144   Cell* getFirstCellColumn(int col) const;
01145 
01155   Cell* getLastCellColumn(int col) const;
01156 
01166   Cell* getFirstCellRow(int row) const;
01167 
01177   Cell* getLastCellRow(int row) const;
01178 
01188   Cell* getNextCellUp(int col, int row) const;
01189 
01199   Cell* getNextCellDown(int col, int row) const;
01200 
01211   Cell* getNextCellLeft(int col, int row) const;
01212 
01223   Cell* getNextCellRight(int col, int row) const;
01224 
01225   SheetPrint * print() const;
01226 
01228   KSpread::DependencyManager *dependencies ();
01229 
01235   int numSelected() const;
01236 
01237 //return command when we move object
01238 //     KCommand *moveObject(KSpreadView *_view, double diffx, double diffy);
01239 //     KCommand *moveObject(KSpreadView *m_view,const KoPoint &_move,bool key);
01240 
01241 
01242 signals:
01243     void sig_refreshView();
01244     void sig_updateView( Sheet *_sheet );
01245     void sig_updateView( Sheet *_sheet, const Region& );
01246     void sig_updateView( EmbeddedObject *obj );
01247     void sig_updateHBorder( Sheet *_sheet );
01248     void sig_updateVBorder( Sheet *_sheet );
01249     void sig_updateChildGeometry( EmbeddedKOfficeObject *_child );
01250     void sig_maxColumn( int _max_column );
01251     void sig_maxRow( int _max_row );
01255     void sig_nameChanged( Sheet* sheet, const QString& old_name );
01260     void sig_polygonInvalidated( const QPointArray& );
01261 
01262     void sig_SheetHidden( Sheet* sheet);
01263     void sig_SheetShown( Sheet* sheet);
01264     void sig_SheetRemoved( Sheet* sheet);
01265     void sig_SheetActivated( Sheet* );
01266     void sig_RefreshView( Sheet* );
01267 
01268 protected slots:
01270   void slotAreaModified (const QString &name);
01271 
01272 protected:
01274      void updateAllDependencies();
01275 
01281     void changeCellTabName( QString const & old_name,QString const & new_name );
01282 
01283     bool loadRowFormat( const QDomElement& row, int &rowIndex, KoOasisLoadingContext& oasisContext, QDict<Style>& styleMap );
01284 
01289     bool loadColumnFormat(const QDomElement& row, const KoOasisStyles& oasisStyles, int & indexCol, const QDict<Style>& styleMap);
01290     bool loadSheetStyleFormat( QDomElement *style );
01291     void loadOasisMasterLayoutPage( KoStyleStack &styleStack );
01292 
01293     QString saveOasisSheetStyleName( KoGenStyles &mainStyles );
01294     void saveOasisColRowCell( KoXmlWriter& xmlWriter, KoGenStyles &mainStyles, int maxCols, int maxRows, GenValidationStyles &valStyle );
01295     void saveOasisCells(  KoXmlWriter& xmlWriter, KoGenStyles &mainStyles, int row, int maxCols, GenValidationStyles &valStyle );
01296     void convertPart( const QString & part, KoXmlWriter & writer ) const;
01297     void addText( const QString & text, KoXmlWriter & writer ) const;
01298 
01299     void maxRowCols( int & maxCols, int & maxRows );
01300 
01301     bool rowAsCell( int row, int maxCols );
01302 
01303     QString getPart( const QDomNode & part );
01304     void replaceMacro( QString & text, const QString & old, const QString & newS );
01305 
01306     void insertObject( EmbeddedObject *_obj );
01307 
01311     void fillSequence( QPtrList<Cell>& _srcList, QPtrList<Cell>& _destList, QPtrList<AutoFillSequence>& _seqList, bool down = true );
01312 
01313     static int s_id;
01314     static QIntDict<Sheet>* s_mapSheets;
01315 
01316 public:
01317     // see kspread_sheet.cc for an explanation of this
01318     // this is for type B and also for type A (better use CellWorkerTypeA for that)
01319     struct CellWorker
01320     {
01321   const bool create_if_default;
01322   const bool emit_signal;
01323   const bool type_B;
01324 
01325   CellWorker( bool cid=true, bool es=true, bool tb=true ) : create_if_default( cid ), emit_signal( es ), type_B( tb ) { }
01326   virtual ~CellWorker() { }
01327 
01328   virtual class UndoAction* createUndoAction( Doc* doc, Sheet* sheet, const Region& region ) =0;
01329 
01330   // these are only needed for type A
01331   virtual bool testCondition( RowFormat* ) { return false; }
01332   virtual void doWork( RowFormat* ) { }
01333   virtual void doWork( ColumnFormat* ) { }
01334   virtual void prepareCell( Cell* ) { }
01335 
01336   // these are needed in all CellWorkers
01337   virtual bool testCondition( Cell* cell ) =0;
01338   virtual void doWork( Cell* cell, bool cellRegion, int x, int y ) =0;
01339     };
01340 
01341     // this is for type A (surprise :))
01342     struct CellWorkerTypeA : public CellWorker
01343     {
01344   CellWorkerTypeA( ) : CellWorker( true, true, false ) { }
01345   virtual QString getUndoTitle( ) =0;
01346   class UndoAction* createUndoAction( Doc* doc, Sheet* sheet, const Region& region );
01347     };
01348 
01349 protected:
01350     typedef enum { CompleteRows, CompleteColumns, CellRegion } SelectionType;
01351     SelectionType workOnCells( Selection* selectionInfo,
01352                                CellWorker& worker );
01353 
01354 private:
01359     bool insertPicture( const KoPoint& point, KoPicture& picture );
01360 
01361     bool FillSequenceWithInterval (QPtrList<Cell>& _srcList,
01362            QPtrList<Cell>& _destList,
01363            QPtrList<AutoFillSequence>& _seqList,
01364                                    bool down);
01365 
01366     void FillSequenceWithCopy (QPtrList<Cell>& _srcList,
01367                                QPtrList<Cell>& _destList,
01368                                bool down);
01369 
01370     void convertObscuringBorders();
01371     void checkCellContent(Cell * cell1, Cell * cell2, int & ret);
01372     int  adjustColumnHelper(Cell * c, int _col, int _row);
01373     void checkContentDirection( QString const & name );
01374     bool objectNameExists( EmbeddedObject *object, QPtrList<EmbeddedObject> &list );
01375 
01376     class Private;
01377     Private* d;
01378 
01379     // don't allow copy or assignment
01380     Sheet( const Sheet& );
01381     Sheet& operator=( const Sheet& );
01382 };
01383 
01384 } // namespace KSpread
01385 
01386 #endif  // KSPREAD_SHEET
KDE Home | KDE Accessibility Home | Description of Access Keys