karbon

vdocument.h
1/* This file is part of the KDE project
2 Copyright (C) 2001, The Karbon Developers
3 Copyright (C) 2002, The Karbon Developers
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef VDOCUMENT_H
22#define VDOCUMENT_H
23
24#include <KoUnit.h>
25
26#include <tqstring.h>
27#include <tqptrlist.h>
28#include <tqptrdict.h>
29
30#include "vobject.h"
31
32#include "karbon_grid_data.h"
33#include <koffice_export.h>
34
35class TQDomDocument;
36class TQDomElement;
37class VSelection;
38class VLayer;
39class KoPageLayout;
40
41typedef TQPtrList<VLayer> VLayerList;
42typedef TQPtrListIterator<VLayer> VLayerListIterator;
43
44
52class KARBONBASE_EXPORT VDocument : public VObject
53{
54public:
62
66 VDocument();
67
73 VDocument( const VDocument& document );
74
78 virtual ~VDocument();
79
80 virtual void draw( VPainter* painter, const KoRect* rect ) const;
81
90 void drawPage( VPainter *painter, const KoPageLayout &pl, bool drawPageMargins ) const;
91
97 double width() const { return m_width; }
98
104 double height() const { return m_height; }
105
111 void setWidth( double width ) { m_width = width; m_boundingBox.setWidth( width ); }
112
118 void setHeight( double height ) { m_height = height; m_boundingBox.setHeight( height ); }
119
125 KoUnit::Unit unit() const
126 { return m_unit; }
127
133 void setUnit( KoUnit::Unit unit )
134 { m_unit = unit; }
135
145 bool canRaiseLayer( VLayer* layer );
146
156 bool canLowerLayer( VLayer* layer );
157
163 void raiseLayer( VLayer* layer );
164
170 void lowerLayer( VLayer* layer );
171
178 int layerPos( VLayer* layer );
179
187 void insertLayer( VLayer* layer );
188
196 void removeLayer( VLayer* layer );
197
205 void setActiveLayer( VLayer* layer );
206
212 VLayer* activeLayer() const { return m_activeLayer; }
213
217 const VLayerList& layers() const { return m_layers; }
218
219 TQDomDocument saveXML() const;
220 virtual void saveOasis( KoStore *store, KoXmlWriter *docWriter, KoGenStyles &mainStyles ) const;
221 enum { STYLE_GRAPHICAUTO = 20, STYLE_LINEAR_GRADIENT, STYLE_RADIAL_GRADIENT, STYLE_STROKE };
222 bool loadXML( const TQDomElement& doc );
223 virtual bool loadOasis( const TQDomElement &element, KoOasisLoadingContext &context );
224 virtual void save( TQDomElement& element ) const;
225 virtual void load( const TQDomElement& element );
226 void loadDocumentContent( const TQDomElement& doc );
227
228 virtual VDocument* clone() const;
229
230 virtual void accept( VVisitor& visitor );
231
232
239 { return m_selection; }
240
246 VSelectionMode selectionMode() { return m_selectionMode; }
247
253 void setSelectionMode( VSelectionMode mode ) { m_selectionMode = mode; }
254
260 void append( VObject* object );
261
268 TQString objectName( const VObject *obj ) const;
269
279 void setObjectName( const VObject *obj, const TQString name ) { m_objectNames.insert( obj, name ); }
280
281 bool saveAsPath() const { return m_saveAsPath; }
282 void saveAsPath( bool b ) { m_saveAsPath = b; }
283
289 KarbonGridData &grid() { return m_gridData; }
290
291private:
295 double m_width;
296
300 double m_height;
301
302
304 VLayerList m_layers;
306 VLayer* m_activeLayer;
307
309 VSelection* m_selection;
311 VSelectionMode m_selectionMode;
312
316 KoUnit::Unit m_unit;
317
318 TQMap<const VObject *, TQString> m_objectNames;
319
320 // TODO this flag is used nowhere, can we remove it?
321 bool m_saveAsPath;
322
323 KarbonGridData m_gridData;
324};
325
326#endif
327
All non-visual, static doc info is in here.
Definition vdocument.h:53
void setObjectName(const VObject *obj, const TQString name)
Sets custom name of specified object.
Definition vdocument.h:279
void setHeight(double height)
Sets document height.
Definition vdocument.h:118
double width() const
Returns document width.
Definition vdocument.h:97
KarbonGridData & grid()
Returns the document's grid.
Definition vdocument.h:289
void setSelectionMode(VSelectionMode mode)
Sets the selection mode.
Definition vdocument.h:253
VLayer * activeLayer() const
Returns a pointer to the active layer.
Definition vdocument.h:212
void setWidth(double width)
Sets document width.
Definition vdocument.h:111
VSelection * selection() const
Returns a pointer to the selection.
Definition vdocument.h:238
KoUnit::Unit unit() const
Returns document unit.
Definition vdocument.h:125
VSelectionMode
The different selection modes.
Definition vdocument.h:56
@ ActiveLayer
selection within the active layer
Definition vdocument.h:57
@ VisibleLayers
selection within all visible layers
Definition vdocument.h:58
@ SelectedLayers
selection within all selected layers
Definition vdocument.h:59
const VLayerList & layers() const
Returns the list of layers.
Definition vdocument.h:217
void setUnit(KoUnit::Unit unit)
Sets document unit.
Definition vdocument.h:133
double height() const
Returns document height.
Definition vdocument.h:104
VSelectionMode selectionMode()
Returns the selection mode.
Definition vdocument.h:246
VLayer manages a set of vobjects.
Definition vlayer.h:37
The base class for all karbon objects.
Definition vobject.h:50
virtual VObject * clone() const =0
Create an exact copy of this object.
virtual void accept(VVisitor &)
Accept a VVisitor.
Definition vobject.h:236
virtual void saveOasis(KoStore *store, KoXmlWriter *docWriter, KoGenStyles &mainStyles, int &index) const
Save this object's state to OpenDocument.
Definition vobject.cpp:116
virtual void load(const TQDomElement &element)
Load this object's state from xml and initialize this object accordingly.
Definition vobject.cpp:157
virtual void save(TQDomElement &element) const
Save this object's state to xml.
Definition vobject.cpp:102
virtual bool loadOasis(const TQDomElement &element, KoOasisLoadingContext &context)
Load this object's state from OpenDocument and initialize this object accordingly.
Definition vobject.cpp:181
virtual void draw(VPainter *painter, const KoRect *rect=0L) const
Draw the object to a painting device.
Definition vobject.h:100
VSelection manages a set of selected vobjects.
Definition vselection.h:62
The abstract visitor class.
Definition vvisitor.h:51