kspread

kspread_doc.h
1/* This file is part of the KDE project
2 Copyright (C) 2004 Ariya Hidayat <ariya@kde.org>
3 (C) 2002-2003 Norbert Andres <nandres@web.de>
4 (C) 2000-2005 Laurent Montel <montel@kde.org>
5 (C) 2002 John Dailey <dailey@vt.edu>
6 (C) 2002 Phillip Mueller <philipp.mueller@gmx.de>
7 (C) 2000 Werner Trobin <trobin@kde.org>
8 (C) 1999-2000 Simon Hausmann <hausmann@kde.org>
9 (C) 1999 David Faure <faure@kde.org>
10 (C) 1998-2000 Torben Weis <weis@kde.org>
11
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Library General Public
14 License as published by the Free Software Foundation; either
15 version 2 of the License, or (at your option) any later version.
16
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Library General Public License for more details.
21
22 You should have received a copy of the GNU Library General Public License
23 along with this library; see the file COPYING.LIB. If not, write to
24 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 * Boston, MA 02110-1301, USA.
26*/
27
28#ifndef KSPREAD_DOC
29#define KSPREAD_DOC
30
31#include <tqmap.h>
32#include <tqobject.h>
33#include <tqpainter.h>
34#include <tqrect.h>
35#include <tqstring.h>
36#include <tqvaluelist.h>
37
38#include <kcompletion.h>
39
40#include <KoDocument.h>
41#include <KoZoomHandler.h>
42
43#include "kspread_global.h"
44
45class KCommand;
46
47class KoCommandHistory;
48class KoGenStyles;
49class KoOasisSettings;
50class KoPicture;
51class KoPictureCollection;
52class KoPictureKey;
53class KoStore;
54class KoXmlWriter;
55
56class DCOPObject;
57class TQDomDocument;
58class KSpellConfig;
59
60#define MIME_TYPE "application/x-kspread"
61
62namespace KSpread
63{
64class Damage;
65class ValueParser;
66class ValueConverter;
67class ValueFormatter;
68class ValueCalc;
69class Sheet;
70class Doc;
71class View;
72class Map;
73class Region;
74class StyleManager;
75class UndoAction;
76class KSPLoadingInfo;
77class EmbeddedObject;
78
79struct Reference
80{
81 TQString sheet_name;
82 TQString ref_name;
83 TQRect rect;
84};
85
86class Plugin
87{
88 public:
89 Plugin() {}
90 virtual ~Plugin() {}
91 virtual TQDomElement saveXML( TQDomDocument & doc ) const = 0;
92};
93
97class KSPREAD_EXPORT Doc : public KoDocument, public KoZoomHandler
98{
99 TQ_OBJECT
100
101 TQ_PROPERTY( bool getShowRowHeader READ getShowRowHeader )
102 TQ_PROPERTY( bool getShowColHeader READ getShowColHeader )
103 TQ_PROPERTY( double getIndentValue READ getIndentValue WRITE setIndentValue )
104 TQ_PROPERTY( bool getShowMessageError READ getShowMessageError WRITE setShowMessageError)
105 TQ_PROPERTY( bool dontCheckUpperWord READ dontCheckUpperWord WRITE setDontCheckUpperWord)
106 TQ_PROPERTY( bool dontCheckTitleCase READ dontCheckTitleCase WRITE setDontCheckTitleCase)
107
108 TQ_PROPERTY( int syntaxVersion READ syntaxVersion )
109 TQ_PROPERTY( bool showVerticalScrollBar READ showVerticalScrollBar WRITE setShowVerticalScrollBar )
110 TQ_PROPERTY( bool showHorizontalScrollBar READ showHorizontalScrollBar WRITE setShowHorizontalScrollBar )
111 TQ_PROPERTY( bool showColumnHeader READ showColumnHeader WRITE setShowColumnHeader )
112 TQ_PROPERTY( bool showRowHeader READ showRowHeader WRITE setShowRowHeader )
113 TQ_PROPERTY( bool showStatusBar READ showStatusBar WRITE setShowStatusBar )
114 TQ_PROPERTY( bool showFormulaBar READ showFormulaBar WRITE setShowFormulaBar )
115 TQ_PROPERTY( bool showTabBar READ showTabBar WRITE setShowTabBar )
116 TQ_PROPERTY( int undoRedoLimit READ undoRedoLimit WRITE setUndoRedoLimit )
117
118public:
119
123 Doc( TQWidget *parentWidget = 0, const char *widgetName = 0, TQObject* parent = 0,
124 const char* name = 0, bool singleViewMode = false );
125
129 ~Doc();
130
134 enum { STYLE_PAGE = 20,
139 STYLE_CELL_USER,
140 STYLE_CELL_AUTO,
141 STYLE_PAGEMASTER,
142 STYLE_NUMERIC_NUMBER };
143
147 static TQValueList<Doc*> documents();
148
152 virtual TQCString mimeType() const { return MIME_TYPE; }
153
154 TDELocale *locale () const;
155 Map *map () const;
156 StyleManager *styleManager () const;
157 ValueParser *parser () const;
158 ValueFormatter *formatter () const;
159 ValueConverter *converter () const;
160 ValueCalc *calc () const;
161
166 void addCommand( KCommand* command );
167
168 /*
169 * Adds an undo object. This is the same as addCommand, except
170 * that it accepts Undo instance. Once every undo object
171 * is converted to KCommand, this function will be obsoleted.
172 */
173 void addCommand( UndoAction* command );
174
178 void undo();
179
183 void redo();
184
188 void undoLock();
189
193 void undoUnlock();
194
198 bool undoLocked() const;
199
205 KoCommandHistory* commandHistory();
206
212 TQString unitName() const;
213
217 int syntaxVersion( ) const;
218
223 void setShowVerticalScrollBar( bool b );
224
228 bool showVerticalScrollBar() const;
229
233 bool getShowVerticalScrollBar() const { return showVerticalScrollBar(); }
234
239 void setShowHorizontalScrollBar( bool b );
240
244 bool showHorizontalScrollBar() const;
245
249 bool getShowHorizontalScrollBar() const { return showHorizontalScrollBar(); }
250
255 void setShowColumnHeader( bool b );
256
260 bool showColumnHeader() const;
261
265 void setShowColHeader( bool b ){ setShowColumnHeader( b ) ; }
266
270 bool getShowColHeader() const { return showColumnHeader(); }
271
276 void setShowRowHeader( bool b );
277
281 bool showRowHeader() const;
282
286 bool getShowRowHeader() const { return showRowHeader(); }
287
291 void setGridColor( const TQColor& color );
292
296 TQColor gridColor() const;
297
301 void setIndentValue( double val );
302
306 double indentValue() const;
307
311 double getIndentValue() const { return indentValue(); }
312
317 void setShowStatusBar( bool b );
318
322 bool showStatusBar() const;
323
327 bool getShowStatusBar() const { return showStatusBar(); }
328
333 void setShowTabBar( bool b );
334
338 bool showTabBar() const;
339
343 bool getShowTabBar() const { return showTabBar(); }
344
349 void setShowFormulaBar( bool b );
350
354 bool showFormulaBar() const;
355
359 bool getShowFormulaBar() const { return showFormulaBar(); }
360
364 void setShowMessageError( bool b );
365
369 bool showMessageError() const;
370
374 bool getShowMessageError() const{ return showMessageError(); }
375
380 TDEGlobalSettings::Completion completionMode( )const ;
381 void setCompletionMode( TDEGlobalSettings::Completion _complMode);
382
383 KSpread::MoveTo getMoveToValue()const;
384 void setMoveToValue(KSpread::MoveTo _moveTo) ;
385
389 void setTypeOfCalc( MethodOfCalc _calc);
390 MethodOfCalc getTypeOfCalc() const;
391
392
396 void setKSpellConfig(KSpellConfig _tdespell);
397 KSpellConfig * getKSpellConfig();
398
399 bool dontCheckUpperWord() const;
400 void setDontCheckUpperWord(bool _b);
401
402 bool dontCheckTitleCase() const;
403 void setDontCheckTitleCase(bool _b);
404
405 TQColor pageBorderColor() const;
406 void changePageBorderColor( const TQColor & _color);
407
408 virtual bool completeSaving( KoStore* _store );
409
410 virtual TQDomDocument saveXML();
411
412 enum SaveFlag { SaveAll, SaveSelected }; // kpresenter and kword have have SavePage too
413
414 bool savingWholeDocument();
415
429 bool saveOasisHelper( KoStore* store, KoXmlWriter* manifestWriter, SaveFlag saveFlag,
430 TQString* plainText = 0, KoPicture* picture = 0 );
431
432 virtual bool saveOasis( KoStore* store, KoXmlWriter* manifestWriter );
433 void saveOasisDocumentStyles( KoStore* store, KoGenStyles& mainStyles ) const;
434 virtual int supportedSpecialFormats() const;
435
436 virtual bool loadXML( TQIODevice *, const TQDomDocument& doc );
437 virtual bool loadOasis( const TQDomDocument& doc, KoOasisStyles& oasisStyles, const TQDomDocument& settings, KoStore* );
438 virtual bool loadChildren( KoStore* _store );
439 TQDomElement saveAreaName( TQDomDocument& doc ) ;
440 void saveOasisAreaName( KoXmlWriter & xmlWriter );
441
442 void loadAreaName( const TQDomElement& element );
443 void loadOasisAreaName( const TQDomElement& element );
444 void loadOasisCellValidation( const TQDomElement&body );
445
446 virtual void addView( KoView *_view );
447
448 virtual bool initDoc(InitDocFlags flags, TQWidget* parentWidget=0);
449
457 virtual void setZoomAndResolution( int zoom, int dpiX, int dpiY );
458
462 void newZoomAndResolution( bool updateViews, bool forPrint );
463
464 // virtual void printMap( TQPainter & _painter );
465
466 void enableUndo( bool _b );
467 void enableRedo( bool _b );
468
472 bool isLoading() const;
473
478 void doNotPaint(bool status);
479
480 virtual void paintContent( TQPainter & painter, const TQRect & rect, bool transparent = false,
481 double zoomX = 1.0, double zoomY = 1.0 );
482 void paintContent( TQPainter & painter, const TQRect & rect, bool transparent,
483 Sheet * sheet, bool drawCursor = true );
484
485 bool docData( TQString const & xmlTag, TQDomElement & data );
486 void deregisterPlugin( Plugin * plugin );
487 void registerPlugin( Plugin * plugin );
488
510 void paintCellRegions(TQPainter& painter, const TQRect &viewRect,
511 View* view,
512 TQValueList<TQRect> cellRegions,
513 const Sheet* sheet, bool drawCursor);
514
515 virtual DCOPObject* dcopObject();
516
517 void addAreaName(const TQRect &_rect,const TQString & name,const TQString & sheetName);
518 const TQValueList<Reference> & listArea();
519 void removeArea( const TQString &name);
520 TDECompletion & completion();
521 void addStringCompletion(const TQString & stringCompletion);
522
523 void changeAreaSheetName(const TQString & oldName,const TQString &sheetName);
524
525
526 TQRect getRectArea(const TQString & _sheetName);
527
531 void insertObject( EmbeddedObject * obj );
535 TQPtrList<EmbeddedObject>& embeddedObjects();
536 KoPictureCollection *pictureCollection();
537
538 void initConfig();
539 void saveConfig();
540 void refreshLocale();
541
560 void emitBeginOperation(bool waitCursor);
561
565 virtual void emitBeginOperation();
566
572 virtual void emitEndOperation();
573
581 void emitEndOperation( const Region& region );
582
583 bool delayCalculation() const;
584
585
586 void updateBorderButton();
587
588 void insertSheet( Sheet * sheet );
589 void takeSheet( Sheet * sheet );
590
591 // The user-chosen global unit
592
593 static TQString getAttribute(const TQDomElement &element, const char *attributeName, const TQString &defaultValue)
594 {
595 return element.attribute( attributeName, defaultValue );
596 }
597
598 static int getAttribute(const TQDomElement &element, const char *attributeName, int defaultValue)
599 {
600 TQString value;
601 if ( ( value = element.attribute( attributeName ) ) != TQString() )
602 return value.toInt();
603 else
604 return defaultValue;
605 }
606
607 static double getAttribute(const TQDomElement &element, const char *attributeName, double defaultValue)
608 {
609 TQString value;
610 if ( ( value = element.attribute( attributeName ) ) != TQString() )
611 return value.toDouble();
612 else
613 return defaultValue;
614 }
615
616 void addIgnoreWordAll( const TQString & word);
617 void clearIgnoreWordAll( );
618 void addIgnoreWordAllList( const TQStringList & _lst);
619 TQStringList spellListIgnoreAll() const ;
620
621 void setDisplaySheet(Sheet *_Sheet );
622 Sheet * displaySheet() const;
623
627 KSPLoadingInfo* loadingInfo() const;
628
632 void deleteLoadingInfo();
633
634 void increaseNumOperation();
635 void decreaseNumOperation();
636
637 void addDamage( Damage* damage );
638
639/* Function specific when we load config from file */
640 void loadConfigFromFile();
641 bool configLoadFromFile() const;
642
643 // repaint (update) all views
644 void repaint( const TQRect& );
645 void repaint( EmbeddedObject* );
646 void repaint( const KoRect& );
647
648 virtual void addShell( KoMainWindow *shell );
649
650 int undoRedoLimit() const;
651 void setUndoRedoLimit(int _val);
652
653public slots:
654
655 //void newView(); obsloete (Werner)
656
657 void refreshInterface();
658
659 void flushDamages();
660
661signals:
662 // Document signals
675
676 void sig_addAreaName( const TQString & );
677 void sig_removeAreaName( const TQString & );
678
679 void damagesFlushed( const TQValueList<Damage*>& damages );
680
681protected slots:
682 void commandExecuted();
683 void documentRestored();
684
685 virtual void openTemplate( const TQString& file );
686 virtual void initEmpty();
687
688protected:
689 KoView* createViewInstance( TQWidget* parent, const char* name );
690
691 void makeUsedPixmapList();
692 void insertPixmapKey( KoPictureKey key );
693
697 virtual bool completeLoading( KoStore* );
698
702 virtual bool saveChildren( KoStore* _store );
703
704 class SavedDocParts : public TQMap<TQString, TQDomElement> {};
705 SavedDocParts m_savedDocParts;
706
707private:
708 class Private;
709 Private* d;
710
711 // don't allow copy or assignment
712 Doc( const Doc& );
713 Doc& operator=( const Doc& );
714
715 /* helper functions for painting */
716
721 void paintUpdates();
722
723 void PaintRegion(TQPainter& painter, const KoRect &viewRegion,
724 View* view, const TQRect &paintRegion,
725 const Sheet* sheet);
726
727 void loadPaper( TQDomElement const & paper );
728
729 void saveOasisSettings( KoXmlWriter &settingsWriter );
730 void loadOasisSettings( const TQDomDocument&settingsDoc );
731 void loadOasisIgnoreList( const KoOasisSettings& settings );
732 KSPLoadingInfo *m_loadingInfo;
733};
734
735} // namespace KSpread
736
737#endif /* KSPREAD_DOC */
This class holds the data that makes up a spreadsheet.
Definition kspread_doc.h:98
bool getShowFormulaBar() const
bool getShowMessageError() const
void sig_refreshLocale()
Emitted if we update to locale system.
void sig_refreshView()
Emitted if all interfaces have to be updated.
void setShowColHeader(bool b)
@ STYLE_COLUMN_AUTO
auto column styles
@ STYLE_COLUMN_USER
commmon column styles
@ STYLE_ROW_AUTO
auto row styles
@ STYLE_ROW_USER
common row styles
bool getShowStatusBar() const
bool getShowRowHeader() const
void sig_updateView()
Emitted if all views have to be updated.
bool getShowHorizontalScrollBar() const
virtual TQCString mimeType() const
Returns the MIME type of KSpread document.
bool getShowVerticalScrollBar() const
bool getShowTabBar() const
double getIndentValue() const
bool getShowColHeader() const
Temporary information used only during loading.
A map is a simple container for all sheets.
Definition kspread_map.h:59
Abstract base class.
The ValueCalc class is used to perform all sorts of calculations.
Definition valuecalc.h:69
The ValueConverter class can convert Value between various different formats.
The ValueFormatter class generates a textual representation of data stored in a Value,...
The ValueParser parses a text input from the user, generating Value in the desired format.
Definition valueparser.h:40
The View class displays a KSpread document.
The KSpread namespace.
Definition commands.h:39