~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to kivio/kiviopart/kivio_doc.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#ifndef __kivio_doc_h__
20
20
#define __kivio_doc_h__
21
21
 
 
22
#include "kivio_grid_data.h"
 
23
 
 
24
#include <qptrlist.h>
 
25
#include <qobject.h>
 
26
 
 
27
#include <koDocument.h>
 
28
#include <koMainWindow.h>
 
29
#include <koUnit.h>
 
30
 
22
31
class KivioDoc;
23
32
class KivioView;
24
33
class KivioMap;
30
39
class KivioStencilSpawner;
31
40
class KivioStencilSpawnerSet;
32
41
class KivioStackBar;
33
 
class DragBarButton;
34
42
class KivioPainter;
35
43
class KivioStencil;
36
 
class ViewItemList;
 
44
 
 
45
namespace Kivio {
 
46
  class DragBarButton;
 
47
  class ViewItemList;
 
48
}
37
49
 
38
50
class KoStore;
39
 
class View;
40
51
class QDomDocument;
41
 
 
42
 
#include <koDocument.h>
43
 
#include <koMainWindow.h>
44
 
#include "kivio_grid_data.h"
45
 
#include <qlist.h>
46
 
//#include <iostream.h>
47
 
 
48
 
#include <qobject.h>
49
 
#include <koprinter.h>
 
52
class DCOPObject;
 
53
class KCommandHistory;
50
54
 
51
55
class QPainter;
 
56
class KPrinter;
 
57
class KCommand;
 
58
class KoZoomHandler;
 
59
class QFont;
52
60
 
53
61
#define MIME_TYPE "application/x-kivio"
54
62
 
 
63
using namespace Kivio;
 
64
 
55
65
class KivioDoc : public KoDocument
56
 
{ Q_OBJECT
57
 
friend class KivioPage;
58
 
public:
59
 
  KivioDoc( QWidget *parentWidget = 0, const char* widgetName = 0, QObject* parent = 0, const char* name = 0, bool singleViewMode = false );
60
 
  ~KivioDoc();
61
 
 
62
 
  virtual void addShell(KoMainWindow *shell);
63
 
 
64
 
  virtual QDomDocument saveXML();
65
 
 
66
 
  virtual bool loadXML( QIODevice *, const QDomDocument& doc );
67
 
 
68
 
  virtual bool initDoc();
69
 
 
70
 
  KivioOptions* config() { return m_options; }
71
 
 
72
 
  virtual QCString mimeType() const { return MIME_TYPE; }
73
 
 
74
 
  /**
75
 
   * @return a pointer to a new KivioPage. The KivioPage is not added to the map nor added to the GUI.
76
 
   */
77
 
  KivioPage* createPage();
78
 
 
79
 
  /**
80
 
   * Adds a KivioPage to the GUI and makes it active. In addition the KivioPage is
81
 
   * added to the map.
82
 
   *
83
 
   * @see KivioView
84
 
   * @see KivioMap
85
 
   */
86
 
  void addPage( KivioPage* page );
87
 
 
88
 
  /**
89
 
   * Adds a KivioStencilSpawnerSet to the list of spawner sets and make it active.
90
 
   *
91
 
   */
92
 
  KivioStencilSpawnerSet *addSpawnerSet( QString );
93
 
  KivioStencilSpawnerSet *addSpawnerSetDuringLoad( QString );
94
 
  bool removeSpawnerSet( KivioStencilSpawnerSet * );
95
 
 
96
 
  QList<KivioStencilSpawnerSet> *spawnerSets() { return m_pLstSpawnerSets; }
97
 
 
98
 
  KivioStencilSpawner *findStencilSpawner( const QString& setId, const QString& stencilId );
99
 
  KivioStencilSpawner *findInternalStencilSpawner( const QString& title );
100
 
 
101
 
  KivioMap* map() const { return m_pMap; }
102
 
 
103
 
  /**
104
 
   * @return TRUE if the document is currently loading.
105
 
   */
106
 
  bool isLoading() { return m_bLoading; }
107
 
 
108
 
  virtual void paintContent( QPainter& painter, const QRect& rect, bool transparent = false, double zoomX = 1.0, double zoomY = 1.0 );
109
 
  void paintContent( KivioPainter& painter, const QRect& rect, bool transparent, KivioPage* page, QPoint, float, bool );
110
 
 
111
 
  void printContent( KPrinter& prn );
112
 
  bool exportPage( KivioPage *pPage, const QString &fileName, ExportPageDialog * );
113
 
 
114
 
  static QList<KivioDoc>& documents();
115
 
 
116
 
  KivioGroupStencil *clipboard();
117
 
  void setClipboard( KivioGroupStencil * );
118
 
 
119
 
  int units() { return m_units; }
120
 
 
121
 
  KivioGridData grid() { return gridData; }
122
 
  void setGrid(KivioGridData g) { gridData = g; emit sig_updateGrid();}
123
 
 
124
 
  ViewItemList* viewItems() { return viewItemList; }
125
 
 
126
 
  void initConfig();
127
 
  void saveConfig();
128
 
 
129
 
public slots:
130
 
  void updateView(KivioPage*, bool modified=true);
131
 
 
132
 
  void slotDeleteStencilSet( DragBarButton *, QWidget *, KivioStackBar * );
133
 
  void slotSelectionChanged();
134
 
  void setUnits(int);
135
 
 
136
 
  void aboutKivio();
137
 
  void aboutGetStencilSets();
138
 
 
139
 
signals:
140
 
  void sig_selectionChanged();
141
 
  void sig_addPage(KivioPage*);
142
 
  void sig_addSpawnerSet( KivioStencilSpawnerSet * );
143
 
  void sig_updateView(KivioPage*);
144
 
  void sig_pageNameChanged(KivioPage*, const QString&);
145
 
  void sig_deleteStencilSet( DragBarButton*, QWidget *, KivioStackBar * );
146
 
  void sig_updateGrid();
147
 
 
148
 
  void unitsChanged(int);
149
 
 
150
 
protected:
151
 
  bool checkStencilsForSpawner( KivioStencilSpawner * );
152
 
  bool checkGroupForSpawner( KivioStencil *, KivioStencilSpawner *);
153
 
  bool setIsAlreadyLoaded( QString dirName, QString name );
154
 
 
155
 
  KoView* createViewInstance( QWidget* parent, const char* name );
156
 
 
157
 
  /**
158
 
   * List of stencil spawner sets
159
 
   */
160
 
  QList <KivioStencilSpawnerSet> *m_pLstSpawnerSets;
161
 
 
162
 
 
163
 
  /**
164
 
   * Loads a KivioStencilSpawnerSet based on it's id
165
 
   */
166
 
  bool loadStencilSpawnerSet( const QString &id );
167
 
 
168
 
  /**
169
 
   * Overloaded function of @ref KoDocument.
170
 
   */
171
 
  virtual bool completeLoading( KoStore* );
172
 
 
173
 
  /**
174
 
   * Pointer to the map that holds all the pages.
175
 
   */
176
 
  KivioMap *m_pMap;
177
 
 
178
 
  /**
179
 
   * This variable is used to give every KivioPage a unique default name.
180
 
   *
181
 
   * @see #newKivioPage
182
 
   */
183
 
  int m_iPageId;
184
 
 
185
 
  /**
186
 
   * The URL of the this part. This variable is only set if the @ref #load function
187
 
   * had been called with an URL as argument.
188
 
   *
189
 
   * @see #load
190
 
   */
191
 
  QString m_strFileURL;
192
 
 
193
 
  /**
194
 
   * TRUE if loading is in process, otherwise FALSE.
195
 
   * This flag is used to avoid updates etc. during loading.
196
 
   *
197
 
   * @see #isLoading
198
 
   */
199
 
  bool m_bLoading;
200
 
 
201
 
  KivioGroupStencil *m_pClipboard;
202
 
 
203
 
  static QList<KivioDoc>* s_docs;
204
 
  static int s_docId;
205
 
 
206
 
  KivioStencilSpawnerSet* m_pInternalSet;
207
 
 
208
 
  int m_units;
209
 
  KivioGridData gridData;
210
 
 
211
 
  ViewItemList* viewItemList;
212
 
 
213
 
  KivioOptions* m_options;
 
66
{
 
67
  Q_OBJECT
 
68
  friend class KivioPage;
 
69
  public:
 
70
    KivioDoc( QWidget *parentWidget = 0, const char* widgetName = 0, QObject* parent = 0, const char* name = 0, bool singleViewMode = false );
 
71
    ~KivioDoc();
 
72
 
 
73
    virtual DCOPObject* dcopObject();
 
74
 
 
75
    virtual QDomDocument saveXML();
 
76
 
 
77
    virtual bool loadXML( QIODevice *, const QDomDocument& doc );
 
78
 
 
79
    virtual bool initDoc();
 
80
 
 
81
    KivioOptions* config()const { return m_options; }
 
82
 
 
83
    virtual QCString mimeType() const { return MIME_TYPE; }
 
84
 
 
85
    /**
 
86
    * @return a pointer to a new KivioPage. The KivioPage is not added to the map nor added to the GUI.
 
87
    */
 
88
    KivioPage* createPage();
 
89
 
 
90
    /**
 
91
    * Adds a KivioPage to the GUI and makes it active. In addition the KivioPage is
 
92
    * added to the map.
 
93
    *
 
94
    * @see KivioView
 
95
    * @see KivioMap
 
96
    */
 
97
    void addPage( KivioPage* page );
 
98
 
 
99
    /**
 
100
    * Adds a KivioStencilSpawnerSet to the list of spawner sets and make it active.
 
101
    *
 
102
    */
 
103
    KivioStencilSpawnerSet *addSpawnerSet( const QString& );
 
104
    KivioStencilSpawnerSet *addSpawnerSetDuringLoad( const QString& );
 
105
    bool removeSpawnerSet( KivioStencilSpawnerSet * );
 
106
 
 
107
    QPtrList<KivioStencilSpawnerSet> *spawnerSets()const { return m_pLstSpawnerSets; }
 
108
 
 
109
    KivioStencilSpawner *findStencilSpawner( const QString& setId, const QString& stencilId );
 
110
    KivioStencilSpawner *findInternalStencilSpawner( const QString& title );
 
111
 
 
112
    KivioMap* map() const { return m_pMap; }
 
113
 
 
114
    /**
 
115
    * @return TRUE if the document is currently loading.
 
116
    */
 
117
    bool isLoading()const { return m_bLoading; }
 
118
 
 
119
    virtual void paintContent( QPainter& painter, const QRect& rect, bool transparent = false, double zoomX = 1.0, double zoomY = 1.0 );
 
120
    void paintContent( KivioPainter& painter, const QRect& rect, bool transparent, KivioPage* page, QPoint, KoZoomHandler*, bool );
 
121
 
 
122
    void printContent( KPrinter& prn );
 
123
    bool exportPage( KivioPage *pPage, const QString &fileName, ExportPageDialog * );
 
124
 
 
125
    static QPtrList<KivioDoc>& documents();
 
126
 
 
127
    KivioGroupStencil *clipboard();
 
128
    void setClipboard( KivioGroupStencil * );
 
129
 
 
130
    KoUnit::Unit units()const { return m_units; }
 
131
 
 
132
    KivioGridData grid() { return gridData; }
 
133
    void setGrid(KivioGridData g) { gridData = g; emit sig_updateGrid();}
 
134
 
 
135
    ViewItemList* viewItems()const { return viewItemList; }
 
136
 
 
137
    void initConfig();
 
138
    void saveConfig();
 
139
    void updateButton();
 
140
    void addCommand( KCommand * cmd );
 
141
 
 
142
    int undoRedoLimit() const;
 
143
    void setUndoRedoLimit(int val);
 
144
    KCommandHistory * commandHistory()const { return m_commandHistory; }
 
145
 
 
146
    void insertPage( KivioPage * page );
 
147
    void takePage( KivioPage * page );
 
148
    void resetLayerPanel();
 
149
    void updateProtectPanelCheckBox();
 
150
 
 
151
    QFont defaultFont() { return m_font; }
 
152
 
 
153
  public slots:
 
154
    void updateView(KivioPage*);
 
155
 
 
156
    void slotDeleteStencilSet( DragBarButton *, QWidget *, KivioStackBar * );
 
157
    void slotSelectionChanged();
 
158
    void setUnits(KoUnit::Unit);
 
159
 
 
160
    void setDefaultFont(const QFont& f) { m_font = f; }
 
161
 
 
162
  protected slots:
 
163
    void slotDocumentRestored();
 
164
    void slotCommandExecuted();
 
165
 
 
166
  signals:
 
167
    void sig_selectionChanged();
 
168
    void sig_addPage(KivioPage*);
 
169
    void sig_addSpawnerSet( KivioStencilSpawnerSet * );
 
170
    void sig_updateView(KivioPage*);
 
171
    void sig_pageNameChanged(KivioPage*, const QString&);
 
172
    void sig_deleteStencilSet( DragBarButton*, QWidget *, KivioStackBar * );
 
173
    void sig_updateGrid();
 
174
 
 
175
    void unitsChanged(KoUnit::Unit);
 
176
 
 
177
  protected:
 
178
    bool checkStencilsForSpawner( KivioStencilSpawner * );
 
179
    bool checkGroupForSpawner( KivioStencil *, KivioStencilSpawner *);
 
180
    bool setIsAlreadyLoaded( QString dirName, QString name );
 
181
 
 
182
    KoView* createViewInstance( QWidget* parent, const char* name );
 
183
 
 
184
    /**
 
185
    * List of stencil spawner sets
 
186
    */
 
187
    QPtrList <KivioStencilSpawnerSet> *m_pLstSpawnerSets;
 
188
 
 
189
 
 
190
    /**
 
191
    * Loads a KivioStencilSpawnerSet based on it's id
 
192
    */
 
193
    bool loadStencilSpawnerSet( const QString &id );
 
194
 
 
195
    /**
 
196
    * Overloaded function of @ref KoDocument.
 
197
    */
 
198
    virtual bool completeLoading( KoStore* );
 
199
 
 
200
    /**
 
201
    * Pointer to the map that holds all the pages.
 
202
    */
 
203
    KivioMap *m_pMap;
 
204
 
 
205
    /**
 
206
    * This variable is used to give every KivioPage a unique default name.
 
207
    *
 
208
    * @see #newKivioPage
 
209
    */
 
210
    int m_iPageId;
 
211
 
 
212
    /**
 
213
    * The URL of the this part. This variable is only set if the @ref #load function
 
214
    * had been called with an URL as argument.
 
215
    *
 
216
    * @see #load
 
217
    */
 
218
    QString m_strFileURL;
 
219
 
 
220
    /**
 
221
    * TRUE if loading is in process, otherwise FALSE.
 
222
    * This flag is used to avoid updates etc. during loading.
 
223
    *
 
224
    * @see #isLoading
 
225
    */
 
226
    bool m_bLoading;
 
227
 
 
228
    KivioGroupStencil *m_pClipboard;
 
229
 
 
230
    static QPtrList<KivioDoc>* s_docs;
 
231
    static int s_docId;
 
232
 
 
233
    KivioStencilSpawnerSet* m_pInternalSet;
 
234
 
 
235
    KoUnit::Unit m_units;
 
236
    KivioGridData gridData;
 
237
 
 
238
    ViewItemList* viewItemList;
 
239
 
 
240
    KivioOptions* m_options;
 
241
    DCOPObject *dcop;
 
242
    KCommandHistory * m_commandHistory;
 
243
 
 
244
    QFont m_font;
214
245
};
215
246
 
216
247
#endif