/* This file is part of the KDE project Copyright 1998, 1999 Torben Weis Copyright 1999- 2006 The KSpread Team www.koffice.org/kspread This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KSPREAD_SHEET #define KSPREAD_SHEET #include #include #include #include #include #include #include #include #include #include #include // for KoOasisSettings::NamedMap #include "kspread_autofill.h" #include "kspread_cell.h" #include "kspread_format.h" #include "kspread_global.h" #include "kspread_object.h" class TQWidget; class TQPainter; class TQDomElement; class DCOPObject; class KPrinter; class KoDocumentEntry; class KoStyleStack; class KoGenStyles; class KoOasisLoadingContext; class KoOasisSettings; class KoOasisStyles; class KCommand; class KoPicture; class KoXmlWriter; namespace KoChart { class Part; } namespace KSpread { class Canvas; class Cell; class EmbeddedChart; class DependencyManager; class Doc; class GenValidationStyles; class Map; class Point; class Region; class Selection; class Sheet; class SheetPrint; class Style; class UndoInsertRemoveAction; class View; class EmbeddedKOfficeObject; class EmbeddedObject; /******************************************************************** * * CellBinding * ********************************************************************/ /** * @short This is an abstract base class only. */ class CellBinding : public TQObject { Q_OBJECT TQ_OBJECT public: CellBinding( Sheet *_sheet, const TQRect& _area ); virtual ~CellBinding(); bool tqcontains( int _x, int _y ); /** * Call this function if one of the cells covered by this binding ( @see #rect ) * has changed. This will in turn force for example a chart to update. * * @param _obj may by 0L. In this case all cells may have changed. */ virtual void cellChanged( Cell *_obj ); virtual void setIgnoreChanges( bool _ignore ) { m_bIgnoreChanges = _ignore; } virtual TQRect& dataArea() { return m_rctDataArea; } virtual void setDataArea( const TQRect _rect ) { m_rctDataArea = _rect; } Sheet* sheet()const { return m_pSheet; } signals: void changed( Cell *_obj ); protected: TQRect m_rctDataArea; Sheet *m_pSheet; bool m_bIgnoreChanges; }; class ChartBinding : public CellBinding { Q_OBJECT TQ_OBJECT public: ChartBinding( Sheet *_sheet, const TQRect& _area, EmbeddedChart *_child ); virtual ~ChartBinding(); virtual void cellChanged( Cell *_obj ); private: EmbeddedChart* m_child; }; /******************************************************************** * * TextDrag * ********************************************************************/ /** * @short This is a class for handling clipboard data */ class TextDrag : public TQTextDrag { Q_OBJECT TQ_OBJECT public: TextDrag( TQWidget * dragSource = 0L, const char * name = 0L ); virtual ~TextDrag(); void setPlain( TQString const & _plain ) { setText( _plain ); } void setKSpread( TQByteArray const & _kspread ) { m_kspread = _kspread; } virtual TQByteArray tqencodedData( const char * mime ) const; virtual const char* format( int i ) const; static bool canDecode( TQMimeSource * e ); static const char * selectionMimeType(); protected: TQByteArray m_kspread; }; /******************************************************************** * * Sheet * ********************************************************************/ /** */ class KSPREAD_EXPORT Sheet : public TQObject { friend class Cell; Q_OBJECT TQ_OBJECT TQ_PROPERTY( TQString sheetName READ sheetName ) TQ_PROPERTY( bool autoCalc READ getAutoCalc WRITE setAutoCalc ) TQ_PROPERTY( bool showGrid READ getShowGrid WRITE setShowGrid ) public: enum Direction { Right, Left, Up, Down }; enum SortingOrder{ Increase, Decrease }; enum ChangeRef { ColumnInsert, ColumnRemove, RowInsert, RowRemove }; enum TestType { Text, Validity, Comment, ConditionalCellAttribute }; enum LayoutDirection { LeftToRight, RightToLeft }; Sheet ( Map* map, const TQString &sheetName, const char *_name=0L ); ~Sheet(); virtual bool isEmpty( unsigned long int x, unsigned long int y ) const; /** * Return the name of this sheet. */ TQString sheetName() const; /** * \deprecated Use sheetName(). */ TQString tableName() const { return sheetName(); } /** * Renames a sheet. This will automatically adapt all formulas * in all sheets and all cells to reflect the new name. * * If the name really changed then @ref #sig_nameChanged is emitted * and the GUI will reflect the change. * * @param init If set to true then no formula will be changed and no signal * will be emitted and no undo action created. Usually you dont * want to do that. * * * @return false if the sheet could not be renamed. Usually the reason is * that this name is already used. * * @see #changeCellTabName * @see TabBar::renameTab * @see #sheetName */ bool setSheetName( const TQString& name, bool init = false, bool makeUndo=true ); Map* workbook() const; Doc* doc() const; /** * Saves the sheet and all it's tqchildren in XML format */ virtual TQDomElement saveXML( TQDomDocument& ); /** * Loads the sheet and all it's tqchildren in XML format */ virtual bool loadXML( const TQDomElement& ); virtual bool loadOasis( const TQDomElement& sheet, KoOasisLoadingContext& oasisContext, TQDict