00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef KSPREAD_DOC
00029 #define KSPREAD_DOC
00030
00031 #include <qmap.h>
00032 #include <qobject.h>
00033 #include <qpainter.h>
00034 #include <qrect.h>
00035 #include <qstring.h>
00036 #include <qvaluelist.h>
00037
00038 #include <kcompletion.h>
00039
00040 #include <KoDocument.h>
00041 #include <KoZoomHandler.h>
00042
00043 #include "kspread_global.h"
00044
00045 class KCommand;
00046
00047 class KoCommandHistory;
00048 class KoGenStyles;
00049 class KoOasisSettings;
00050 class KoPicture;
00051 class KoPictureCollection;
00052 class KoPictureKey;
00053 class KoStore;
00054 class KoXmlWriter;
00055
00056 class DCOPObject;
00057 class QDomDocument;
00058 class KSpellConfig;
00059
00060 #define MIME_TYPE "application/x-kspread"
00061
00062 namespace KSpread
00063 {
00064 class Damage;
00065 class ValueParser;
00066 class ValueConverter;
00067 class ValueFormatter;
00068 class ValueCalc;
00069 class Sheet;
00070 class Doc;
00071 class View;
00072 class Map;
00073 class Region;
00074 class StyleManager;
00075 class UndoAction;
00076 class KSPLoadingInfo;
00077 class EmbeddedObject;
00078
00079 struct Reference
00080 {
00081 QString sheet_name;
00082 QString ref_name;
00083 QRect rect;
00084 };
00085
00086 class Plugin
00087 {
00088 public:
00089 Plugin() {}
00090 virtual ~Plugin() {}
00091 virtual QDomElement saveXML( QDomDocument & doc ) const = 0;
00092 };
00093
00097 class KSPREAD_EXPORT Doc : public KoDocument, public KoZoomHandler
00098 {
00099 Q_OBJECT
00100 Q_PROPERTY( bool getShowRowHeader READ getShowRowHeader )
00101 Q_PROPERTY( bool getShowColHeader READ getShowColHeader )
00102 Q_PROPERTY( double getIndentValue READ getIndentValue WRITE setIndentValue )
00103 Q_PROPERTY( bool getShowMessageError READ getShowMessageError WRITE setShowMessageError)
00104 Q_PROPERTY( bool dontCheckUpperWord READ dontCheckUpperWord WRITE setDontCheckUpperWord)
00105 Q_PROPERTY( bool dontCheckTitleCase READ dontCheckTitleCase WRITE setDontCheckTitleCase)
00106
00107 Q_PROPERTY( int syntaxVersion READ syntaxVersion )
00108 Q_PROPERTY( bool showVerticalScrollBar READ showVerticalScrollBar WRITE setShowVerticalScrollBar )
00109 Q_PROPERTY( bool showHorizontalScrollBar READ showHorizontalScrollBar WRITE setShowHorizontalScrollBar )
00110 Q_PROPERTY( bool showColumnHeader READ showColumnHeader WRITE setShowColumnHeader )
00111 Q_PROPERTY( bool showRowHeader READ showRowHeader WRITE setShowRowHeader )
00112 Q_PROPERTY( bool showStatusBar READ showStatusBar WRITE setShowStatusBar )
00113 Q_PROPERTY( bool showFormulaBar READ showFormulaBar WRITE setShowFormulaBar )
00114 Q_PROPERTY( bool showTabBar READ showTabBar WRITE setShowTabBar )
00115 Q_PROPERTY( int undoRedoLimit READ undoRedoLimit WRITE setUndoRedoLimit )
00116
00117 public:
00118
00122 Doc( QWidget *parentWidget = 0, const char *widgetName = 0, QObject* parent = 0,
00123 const char* name = 0, bool singleViewMode = false );
00124
00128 ~Doc();
00129
00133 enum { STYLE_PAGE = 20,
00134 STYLE_COLUMN_USER,
00135 STYLE_COLUMN_AUTO,
00136 STYLE_ROW_USER,
00137 STYLE_ROW_AUTO,
00138 STYLE_CELL_USER,
00139 STYLE_CELL_AUTO,
00140 STYLE_PAGEMASTER,
00141 STYLE_NUMERIC_NUMBER };
00142
00146 static QValueList<Doc*> documents();
00147
00151 virtual QCString mimeType() const { return MIME_TYPE; }
00152
00153 KLocale *locale () const;
00154 Map *map () const;
00155 StyleManager *styleManager () const;
00156 ValueParser *parser () const;
00157 ValueFormatter *formatter () const;
00158 ValueConverter *converter () const;
00159 ValueCalc *calc () const;
00160
00165 void addCommand( KCommand* command );
00166
00167
00168
00169
00170
00171
00172 void addCommand( UndoAction* command );
00173
00177 void undo();
00178
00182 void redo();
00183
00187 void undoLock();
00188
00192 void undoUnlock();
00193
00197 bool undoLocked() const;
00198
00204 KoCommandHistory* commandHistory();
00205
00211 QString unitName() const;
00212
00216 int syntaxVersion( ) const;
00217
00222 void setShowVerticalScrollBar( bool b );
00223
00227 bool showVerticalScrollBar() const;
00228
00232 bool getShowVerticalScrollBar() const { return showVerticalScrollBar(); }
00233
00238 void setShowHorizontalScrollBar( bool b );
00239
00243 bool showHorizontalScrollBar() const;
00244
00248 bool getShowHorizontalScrollBar() const { return showHorizontalScrollBar(); }
00249
00254 void setShowColumnHeader( bool b );
00255
00259 bool showColumnHeader() const;
00260
00264 void setShowColHeader( bool b ){ setShowColumnHeader( b ) ; }
00265
00269 bool getShowColHeader() const { return showColumnHeader(); }
00270
00275 void setShowRowHeader( bool b );
00276
00280 bool showRowHeader() const;
00281
00285 bool getShowRowHeader() const { return showRowHeader(); }
00286
00290 void setGridColor( const QColor& color );
00291
00295 QColor gridColor() const;
00296
00300 void setIndentValue( double val );
00301
00305 double indentValue() const;
00306
00310 double getIndentValue() const { return indentValue(); }
00311
00316 void setShowStatusBar( bool b );
00317
00321 bool showStatusBar() const;
00322
00326 bool getShowStatusBar() const { return showStatusBar(); }
00327
00332 void setShowTabBar( bool b );
00333
00337 bool showTabBar() const;
00338
00342 bool getShowTabBar() const { return showTabBar(); }
00343
00348 void setShowFormulaBar( bool b );
00349
00353 bool showFormulaBar() const;
00354
00358 bool getShowFormulaBar() const { return showFormulaBar(); }
00359
00363 void setShowMessageError( bool b );
00364
00368 bool showMessageError() const;
00369
00373 bool getShowMessageError() const{ return showMessageError(); }
00374
00379 KGlobalSettings::Completion completionMode( )const ;
00380 void setCompletionMode( KGlobalSettings::Completion _complMode);
00381
00382 KSpread::MoveTo getMoveToValue()const;
00383 void setMoveToValue(KSpread::MoveTo _moveTo) ;
00384
00388 void setTypeOfCalc( MethodOfCalc _calc);
00389 MethodOfCalc getTypeOfCalc() const;
00390
00391
00395 void setKSpellConfig(KSpellConfig _kspell);
00396 KSpellConfig * getKSpellConfig();
00397
00398 bool dontCheckUpperWord() const;
00399 void setDontCheckUpperWord(bool _b);
00400
00401 bool dontCheckTitleCase() const;
00402 void setDontCheckTitleCase(bool _b);
00403
00404 QColor pageBorderColor() const;
00405 void changePageBorderColor( const QColor & _color);
00406
00407 virtual bool completeSaving( KoStore* _store );
00408
00409 virtual QDomDocument saveXML();
00410
00411 enum SaveFlag { SaveAll, SaveSelected };
00412
00413 bool savingWholeDocument();
00414
00428 bool saveOasisHelper( KoStore* store, KoXmlWriter* manifestWriter, SaveFlag saveFlag,
00429 QString* plainText = 0, KoPicture* picture = 0 );
00430
00431 virtual bool saveOasis( KoStore* store, KoXmlWriter* manifestWriter );
00432 void saveOasisDocumentStyles( KoStore* store, KoGenStyles& mainStyles ) const;
00433 virtual int supportedSpecialFormats() const;
00434
00435 virtual bool loadXML( QIODevice *, const QDomDocument& doc );
00436 virtual bool loadOasis( const QDomDocument& doc, KoOasisStyles& oasisStyles, const QDomDocument& settings, KoStore* );
00437 virtual bool loadChildren( KoStore* _store );
00438 QDomElement saveAreaName( QDomDocument& doc ) ;
00439 void saveOasisAreaName( KoXmlWriter & xmlWriter );
00440
00441 void loadAreaName( const QDomElement& element );
00442 void loadOasisAreaName( const QDomElement& element );
00443 void loadOasisCellValidation( const QDomElement&body );
00444
00445 virtual void addView( KoView *_view );
00446
00447 virtual bool initDoc(InitDocFlags flags, QWidget* parentWidget=0);
00448
00456 virtual void setZoomAndResolution( int zoom, int dpiX, int dpiY );
00457
00461 void newZoomAndResolution( bool updateViews, bool forPrint );
00462
00463
00464
00465 void enableUndo( bool _b );
00466 void enableRedo( bool _b );
00467
00471 bool isLoading() const;
00472
00477 void doNotPaint(bool status);
00478
00479 virtual void paintContent( QPainter & painter, const QRect & rect, bool transparent = false,
00480 double zoomX = 1.0, double zoomY = 1.0 );
00481 void paintContent( QPainter & painter, const QRect & rect, bool transparent,
00482 Sheet * sheet, bool drawCursor = true );
00483
00484 bool docData( QString const & xmlTag, QDomElement & data );
00485 void deregisterPlugin( Plugin * plugin );
00486 void registerPlugin( Plugin * plugin );
00487
00509 void paintCellRegions(QPainter& painter, const QRect &viewRect,
00510 View* view,
00511 QValueList<QRect> cellRegions,
00512 const Sheet* sheet, bool drawCursor);
00513
00514 virtual DCOPObject* dcopObject();
00515
00516 void addAreaName(const QRect &_rect,const QString & name,const QString & sheetName);
00517 const QValueList<Reference> & listArea();
00518 void removeArea( const QString &name);
00519 KCompletion & completion();
00520 void addStringCompletion(const QString & stringCompletion);
00521
00522 void changeAreaSheetName(const QString & oldName,const QString &sheetName);
00523
00524
00525 QRect getRectArea(const QString & _sheetName);
00526
00530 void insertObject( EmbeddedObject * obj );
00534 QPtrList<EmbeddedObject>& embeddedObjects();
00535 KoPictureCollection *pictureCollection();
00536
00537 void initConfig();
00538 void saveConfig();
00539 void refreshLocale();
00540
00559 void emitBeginOperation(bool waitCursor);
00560
00564 virtual void emitBeginOperation();
00565
00571 virtual void emitEndOperation();
00572
00580 void emitEndOperation( const Region& region );
00581
00582 bool delayCalculation() const;
00583
00584
00585 void updateBorderButton();
00586
00587 void insertSheet( Sheet * sheet );
00588 void takeSheet( Sheet * sheet );
00589
00590
00591
00592 static QString getAttribute(const QDomElement &element, const char *attributeName, const QString &defaultValue)
00593 {
00594 return element.attribute( attributeName, defaultValue );
00595 }
00596
00597 static int getAttribute(const QDomElement &element, const char *attributeName, int defaultValue)
00598 {
00599 QString value;
00600 if ( ( value = element.attribute( attributeName ) ) != QString::null )
00601 return value.toInt();
00602 else
00603 return defaultValue;
00604 }
00605
00606 static double getAttribute(const QDomElement &element, const char *attributeName, double defaultValue)
00607 {
00608 QString value;
00609 if ( ( value = element.attribute( attributeName ) ) != QString::null )
00610 return value.toDouble();
00611 else
00612 return defaultValue;
00613 }
00614
00615 void addIgnoreWordAll( const QString & word);
00616 void clearIgnoreWordAll( );
00617 void addIgnoreWordAllList( const QStringList & _lst);
00618 QStringList spellListIgnoreAll() const ;
00619
00620 void setDisplaySheet(Sheet *_Sheet );
00621 Sheet * displaySheet() const;
00622
00626 KSPLoadingInfo* loadingInfo() const;
00627
00631 void deleteLoadingInfo();
00632
00633 void increaseNumOperation();
00634 void decreaseNumOperation();
00635
00636 void addDamage( Damage* damage );
00637
00638
00639 void loadConfigFromFile();
00640 bool configLoadFromFile() const;
00641
00642
00643 void repaint( const QRect& );
00644 void repaint( EmbeddedObject* );
00645 void repaint( const KoRect& );
00646
00647 virtual void addShell( KoMainWindow *shell );
00648
00649 int undoRedoLimit() const;
00650 void setUndoRedoLimit(int _val);
00651
00652 public slots:
00653
00654
00655
00656 void refreshInterface();
00657
00658 void flushDamages();
00659
00660 signals:
00661
00665 void sig_updateView();
00669 void sig_refreshView();
00673 void sig_refreshLocale();
00674
00675 void sig_addAreaName( const QString & );
00676 void sig_removeAreaName( const QString & );
00677
00678 void damagesFlushed( const QValueList<Damage*>& damages );
00679
00680 protected slots:
00681 void commandExecuted();
00682 void documentRestored();
00683
00684 virtual void openTemplate( const QString& file );
00685 virtual void initEmpty();
00686
00687 protected:
00688 KoView* createViewInstance( QWidget* parent, const char* name );
00689
00690 void makeUsedPixmapList();
00691 void insertPixmapKey( KoPictureKey key );
00692
00696 virtual bool completeLoading( KoStore* );
00697
00701 virtual bool saveChildren( KoStore* _store );
00702
00703 class SavedDocParts : public QMap<QString, QDomElement> {};
00704 SavedDocParts m_savedDocParts;
00705
00706 private:
00707 class Private;
00708 Private* d;
00709
00710
00711 Doc( const Doc& );
00712 Doc& operator=( const Doc& );
00713
00714
00715
00720 void paintUpdates();
00721
00722 void PaintRegion(QPainter& painter, const KoRect &viewRegion,
00723 View* view, const QRect &paintRegion,
00724 const Sheet* sheet);
00725
00726 void loadPaper( QDomElement const & paper );
00727
00728 void saveOasisSettings( KoXmlWriter &settingsWriter );
00729 void loadOasisSettings( const QDomDocument&settingsDoc );
00730 void loadOasisIgnoreList( const KoOasisSettings& settings );
00731 KSPLoadingInfo *m_loadingInfo;
00732 };
00733
00734 }
00735
00736 #endif