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 class KoOasisSettings;
00032 class KCommand;
00033
00034 class KSpreadDoc;
00035 class KSpreadInterpreter;
00036 class KSpreadView;
00037 class KSpreadMap;
00038 class KSpreadSheet;
00039 class KSpreadStyleManager;
00040 class KSpreadUndoAction;
00041 class KSPLoadingInfo;
00042
00043 class KoStore;
00044 class KoCommandHistory;
00045 class KoXmlWriter;
00046
00047 class View;
00048
00049 class DCOPObject;
00050
00051 class QDomDocument;
00052
00053 class KSpellConfig;
00054
00055 #include <koDocument.h>
00056 #include <kozoomhandler.h>
00057 #include <koGenStyles.h>
00058 #include <koUnit.h>
00059
00060 #include <kcompletion.h>
00061 #include <qmap.h>
00062 #include <qobject.h>
00063 #include <qpainter.h>
00064 #include <qrect.h>
00065 #include <qstring.h>
00066 #include <qvaluelist.h>
00067
00068 #include <kspread_global.h>
00069
00070 #include <koscript_context.h>
00071
00072 #define MIME_TYPE "application/x-kspread"
00073
00074 struct Reference
00075 {
00076 QString sheet_name;
00077 QString ref_name;
00078 QRect rect;
00079 };
00080
00081 class KSpreadPlugin
00082 {
00083 public:
00084 KSpreadPlugin() {}
00085 virtual ~KSpreadPlugin() {}
00086 virtual QDomElement saveXML( QDomDocument & doc ) const = 0;
00087 };
00088
00089 namespace KSpread
00090 {
00091 class Damage;
00092 class ValueParser;
00093 class ValueConverter;
00094 class ValueFormatter;
00095 class ValueCalc;
00096 }
00097
00098
00099 class DocPrivate;
00100
00104 class KSPREAD_EXPORT KSpreadDoc : public KoDocument, public KoZoomHandler
00105 {
00106 Q_OBJECT
00107 Q_PROPERTY( bool getShowRowHeader READ getShowRowHeader )
00108 Q_PROPERTY( bool getShowColHeader READ getShowColHeader )
00109 Q_PROPERTY( double getIndentValue READ getIndentValue WRITE setIndentValue )
00110 Q_PROPERTY( bool getShowMessageError READ getShowMessageError WRITE setShowMessageError)
00111 Q_PROPERTY( bool dontCheckUpperWord READ dontCheckUpperWord WRITE setDontCheckUpperWord)
00112 Q_PROPERTY( bool dontCheckTitleCase READ dontCheckTitleCase WRITE setDontCheckTitleCase)
00113
00114 Q_PROPERTY( int syntaxVersion READ syntaxVersion )
00115 Q_PROPERTY( bool showVerticalScrollBar READ showVerticalScrollBar WRITE setShowVerticalScrollBar )
00116 Q_PROPERTY( bool showHorizontalScrollBar READ showHorizontalScrollBar WRITE setShowHorizontalScrollBar )
00117 Q_PROPERTY( bool showColumnHeader READ showColumnHeader WRITE setShowColumnHeader )
00118 Q_PROPERTY( bool showRowHeader READ showRowHeader WRITE setShowRowHeader )
00119 Q_PROPERTY( bool showStatusBar READ showStatusBar WRITE setShowStatusBar )
00120 Q_PROPERTY( bool showFormulaBar READ showFormulaBar WRITE setShowFormulaBar )
00121 Q_PROPERTY( bool showTabBar READ showTabBar WRITE setShowTabBar )
00122
00123 public:
00124
00128 KSpreadDoc( QWidget *parentWidget = 0, const char *widgetName = 0, QObject* parent = 0,
00129 const char* name = 0, bool singleViewMode = false );
00130
00134 ~KSpreadDoc();
00135
00136 enum { STYLE_PAGE = 20, STYLE_COLUMN, STYLE_ROW, STYLE_CELL, STYLE_PAGEMASTER, STYLE_USERSTYLE, STYLE_DEFAULTSTYLE, STYLE_NUMERIC_NUMBER};
00137
00138
00142 static QValueList<KSpreadDoc*> documents();
00143
00147 virtual QCString mimeType() const { return MIME_TYPE; }
00148
00149 KLocale *locale () const;
00150 KSpreadMap *map () const;
00151 KSpreadStyleManager *styleManager () const;
00152 KSpread::ValueParser *parser () const;
00153 KSpread::ValueFormatter *formatter () const;
00154 KSpread::ValueConverter *converter () const;
00155 KSpread::ValueCalc *calc () const;
00156
00161 void addCommand( KCommand* command );
00162
00163
00164
00165
00166
00167
00168 void addCommand( KSpreadUndoAction* command );
00169
00173 void undo();
00174
00178 void redo();
00179
00183 void undoLock();
00184
00188 void undoUnlock();
00189
00193 bool undoLocked() const;
00194
00200 KoCommandHistory* commandHistory();
00201
00205 KoUnit::Unit unit() const;
00206
00210 KoUnit::Unit getUnit() const { return unit(); }
00211
00215 void setUnit( KoUnit::Unit u );
00216
00222 QString unitName() const;
00223
00227 QString getUnitName() const { return unitName(); }
00228
00232 int syntaxVersion( ) const;
00233
00238 void setShowVerticalScrollBar( bool b );
00239
00243 bool showVerticalScrollBar() const;
00244
00248 bool getShowVerticalScrollBar() const { return showVerticalScrollBar(); }
00249
00254 void setShowHorizontalScrollBar( bool b );
00255
00259 bool showHorizontalScrollBar() const;
00260
00264 bool getShowHorizontalScrollBar() const { return showHorizontalScrollBar(); }
00265
00270 void setShowColumnHeader( bool b );
00271
00275 bool showColumnHeader() const;
00276
00280 void setShowColHeader( bool b ){ setShowColumnHeader( b ) ; }
00281
00285 bool getShowColHeader() const { return showColumnHeader(); }
00286
00291 void setShowRowHeader( bool b );
00292
00296 bool showRowHeader() const;
00297
00301 bool getShowRowHeader() const { return showRowHeader(); }
00302
00306 void setGridColor( const QColor& color );
00307
00311 QColor gridColor() const;
00312
00316 void setIndentValue( double val );
00317
00321 double indentValue() const;
00322
00326 double getIndentValue() const { return indentValue(); }
00327
00332 void setShowStatusBar( bool b );
00333
00337 bool showStatusBar() const;
00338
00342 bool getShowStatusBar() const { return showStatusBar(); }
00343
00348 void setShowTabBar( bool b );
00349
00353 bool showTabBar() const;
00354
00358 bool getShowTabBar() const { return showTabBar(); }
00359
00364 void setShowFormulaBar( bool b );
00365
00369 bool showFormulaBar() const;
00370
00374 bool getShowFormulaBar() const { return showFormulaBar(); }
00375
00380 void setShowCommentIndicator( bool b );
00381
00385 bool showCommentIndicator() const;
00386
00390 bool getShowCommentIndicator() const { return showCommentIndicator(); }
00391
00395 void setShowMessageError( bool b );
00396
00400 bool showMessageError() const;
00401
00405 bool getShowMessageError() const{ return showMessageError(); }
00406
00411 KGlobalSettings::Completion completionMode( )const ;
00412 void setCompletionMode( KGlobalSettings::Completion _complMode);
00413
00414 KSpread::MoveTo getMoveToValue()const;
00415 void setMoveToValue(KSpread::MoveTo _moveTo) ;
00416
00420 void setTypeOfCalc( MethodOfCalc _calc);
00421 MethodOfCalc getTypeOfCalc() const;
00422
00423
00427 void setKSpellConfig(KSpellConfig _kspell);
00428 KSpellConfig * getKSpellConfig() const;
00429
00430 bool dontCheckUpperWord() const;
00431 void setDontCheckUpperWord(bool _b);
00432
00433 bool dontCheckTitleCase() const;
00434 void setDontCheckTitleCase(bool _b);
00435
00436 QColor pageBorderColor() const;
00437 void changePageBorderColor( const QColor & _color);
00438
00439
00440 virtual QDomDocument saveXML();
00441
00442 virtual bool saveOasis( KoStore* store, KoXmlWriter* manifestWriter );
00443 void saveOasisDocumentStyles( KoStore* store, KoGenStyles& mainStyles ) const;
00444 virtual int supportedSpecialFormats() const;
00445
00446 virtual bool loadXML( QIODevice *, const QDomDocument& doc );
00447 virtual bool loadOasis( const QDomDocument& doc, KoOasisStyles& oasisStyles, const QDomDocument& settings, KoStore* );
00448 virtual bool loadChildren( KoStore* _store );
00449 QDomElement saveAreaName( QDomDocument& doc ) ;
00450 void saveOasisAreaName( KoXmlWriter & xmlWriter );
00451
00452 void loadAreaName( const QDomElement& element );
00453 void loadOasisAreaName( const QDomElement& element );
00454 void loadOasisCellValidation( const QDomElement&body );
00455
00456 virtual void addView( KoView *_view );
00457
00458 virtual bool initDoc(InitDocFlags flags, QWidget* parentWidget=0);
00459
00467 virtual void setZoomAndResolution( int zoom, int dpiX, int dpiY );
00468
00472 void newZoomAndResolution( bool updateViews, bool forPrint );
00473
00477 KSpreadInterpreter* interpreter()const;
00478
00484 void resetInterpreter();
00485
00490 KSContext & context();
00491
00492
00493
00494 void enableUndo( bool _b );
00495 void enableRedo( bool _b );
00496
00500 bool isLoading() const;
00501
00502 virtual void paintContent( QPainter & painter, const QRect & rect, bool transparent = false,
00503 double zoomX = 1.0, double zoomY = 1.0 );
00504 void paintContent( QPainter & painter, const QRect & rect, bool transparent,
00505 KSpreadSheet * sheet, bool drawCursor = true );
00506
00507 bool docData( QString const & xmlTag, QDomElement & data );
00508 void deregisterPlugin( KSpreadPlugin * plugin );
00509 void registerPlugin( KSpreadPlugin * plugin );
00510
00532 void paintCellRegions(QPainter& painter, const QRect &viewRect,
00533 KSpreadView* view,
00534 QValueList<QRect> cellRegions,
00535 const KSpreadSheet* sheet, bool drawCursor);
00536
00537 virtual DCOPObject* dcopObject();
00538
00539 void addAreaName(const QRect &_rect,const QString & name,const QString & sheetName);
00540 const QValueList<Reference> & listArea();
00541 void removeArea( const QString &name);
00542 KCompletion & completion();
00543 void addStringCompletion(const QString & stringCompletion);
00544
00545 void changeAreaSheetName(const QString & oldName,const QString &sheetName);
00546
00547
00548 QRect getRectArea(const QString & _sheetName);
00549
00550 void insertChild( KoDocumentChild * child ) { KoDocument::insertChild( child ); }
00551
00552 void initConfig();
00553 void saveConfig();
00554 void refreshLocale();
00555
00574 void emitBeginOperation(bool waitCursor);
00575
00579 virtual void emitBeginOperation();
00580
00585 virtual void emitEndOperation();
00586
00591 void emitEndOperation( QRect const & rect );
00592
00593 bool delayCalculation() const;
00594
00595
00596 void updateBorderButton();
00597
00598 void insertSheet( KSpreadSheet * sheet );
00599 void takeSheet( KSpreadSheet * sheet );
00600
00601
00602
00603 static QString getAttribute(const QDomElement &element, const char *attributeName, const QString &defaultValue)
00604 {
00605 return element.attribute( attributeName, defaultValue );
00606 }
00607
00608 static int getAttribute(const QDomElement &element, const char *attributeName, int defaultValue)
00609 {
00610 QString value;
00611 if ( ( value = element.attribute( attributeName ) ) != QString::null )
00612 return value.toInt();
00613 else
00614 return defaultValue;
00615 }
00616
00617 static double getAttribute(const QDomElement &element, const char *attributeName, double defaultValue)
00618 {
00619 QString value;
00620 if ( ( value = element.attribute( attributeName ) ) != QString::null )
00621 return value.toDouble();
00622 else
00623 return defaultValue;
00624 }
00625
00626 void addIgnoreWordAll( const QString & word);
00627 void clearIgnoreWordAll( );
00628 void addIgnoreWordAllList( const QStringList & _lst);
00629 QStringList spellListIgnoreAll() const ;
00630
00631 void setDisplaySheet(KSpreadSheet *_Sheet );
00632 KSpreadSheet * displaySheet() const;
00633 KSPLoadingInfo * loadingInfo() const;
00634 void increaseNumOperation();
00635 void decreaseNumOperation();
00636
00637 void addDamage( KSpread::Damage* damage );
00638
00639
00640 void loadConfigFromFile();
00641 bool configLoadFromFile() const;
00642
00643 public slots:
00644
00645
00646
00647 void refreshInterface();
00648
00649 void flushDamages();
00650
00651 signals:
00652
00656 void sig_updateView();
00660 void sig_refreshView();
00664 void sig_refreshLocale();
00665
00666 void sig_addAreaName( const QString & );
00667 void sig_removeAreaName( const QString & );
00668
00669 void damagesFlushed( const QValueList<KSpread::Damage*>& damages );
00670
00671 protected slots:
00672 void commandExecuted();
00673 void documentRestored();
00674
00675 protected:
00676 KoView* createViewInstance( QWidget* parent, const char* name );
00677
00681 virtual bool completeLoading( KoStore* );
00682
00686 virtual bool saveChildren( KoStore* _store );
00687
00691 void initInterpreter();
00695 void destroyInterpreter();
00696
00697 class SavedDocParts : public QMap<QString, QDomElement> {};
00698 SavedDocParts m_savedDocParts;
00699
00700 private:
00701
00702 DocPrivate* d;
00703
00704
00705 KSpreadDoc( const KSpreadDoc& );
00706 KSpreadDoc& operator=( const KSpreadDoc& );
00707
00708
00709
00714 void paintUpdates();
00715
00716 void PaintRegion(QPainter& painter, const KoRect &viewRegion,
00717 KSpreadView* view, const QRect &paintRegion,
00718 const KSpreadSheet* sheet);
00719 void PaintChooseRect(QPainter& painter, const KoRect &viewRect,
00720 KSpreadView* view, const KSpreadSheet* sheet,
00721 const QRect &chooseRect);
00722 void PaintNormalMarker(QPainter& painter, const KoRect &viewRect,
00723 KSpreadView* view, const KSpreadSheet* sheet,
00724 const QRect &selection);
00725
00741 void retrieveMarkerInfo( const QRect &marker, const KSpreadSheet* sheet,
00742 KSpreadView* view, const KoRect &viewRect,
00743 double positions[], bool paintSides[] );
00744 void loadPaper( QDomElement const & paper );
00745
00746 void saveOasisSettings( KoXmlWriter &settingsWriter );
00747 void loadOasisSettings( const QDomDocument&settingsDoc );
00748 void loadOasisIgnoreList( const KoOasisSettings& settings );
00749 KSPLoadingInfo *m_loadingInfo;
00750 };
00751
00752 #endif