karbon

vdocument.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001, The Karbon Developers
00003    Copyright (C) 2002, The Karbon Developers
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef VDOCUMENT_H
00022 #define VDOCUMENT_H
00023 
00024 #include <KoUnit.h>
00025 
00026 #include <qstring.h>
00027 #include <qptrlist.h>
00028 #include <qptrdict.h>
00029 
00030 #include "vobject.h"
00031 
00032 #include "karbon_grid_data.h"
00033 #include <koffice_export.h>
00034 
00035 class QDomDocument;
00036 class QDomElement;
00037 class VSelection;
00038 class VLayer;
00039 class KoPageLayout;
00040 
00041 typedef QPtrList<VLayer> VLayerList;
00042 typedef QPtrListIterator<VLayer> VLayerListIterator;
00043 
00044 
00052 class KARBONBASE_EXPORT VDocument : public VObject
00053 {
00054 public:
00056     enum VSelectionMode {
00057         ActiveLayer,    
00058         VisibleLayers,  
00059         SelectedLayers, 
00060         AllLayers       
00061     };
00062 
00066     VDocument();
00067 
00073     VDocument( const VDocument& document );
00074 
00078     virtual ~VDocument();
00079 
00080     virtual void draw( VPainter* painter, const KoRect* rect ) const;
00081     
00090     void drawPage( VPainter *painter, const KoPageLayout &pl, bool drawPageMargins ) const;
00091 
00097     double width() const { return m_width; }
00098 
00104     double height() const { return m_height; }
00105 
00111     void setWidth( double width ) { m_width = width; m_boundingBox.setWidth( width ); }
00112 
00118     void setHeight( double height ) { m_height = height; m_boundingBox.setHeight( height ); }
00119 
00125     KoUnit::Unit unit() const
00126         { return m_unit; }
00127 
00133     void setUnit( KoUnit::Unit unit )
00134         { m_unit = unit; }
00135 
00145     bool canRaiseLayer( VLayer* layer );
00146 
00156     bool canLowerLayer( VLayer* layer );
00157 
00163     void raiseLayer( VLayer* layer );
00164 
00170     void lowerLayer( VLayer* layer );
00171 
00178     int layerPos( VLayer* layer );
00179 
00187     void insertLayer( VLayer* layer );
00188 
00196     void removeLayer( VLayer* layer );
00197 
00205     void setActiveLayer( VLayer* layer );
00206 
00212     VLayer* activeLayer() const { return m_activeLayer; }
00213 
00217     const VLayerList& layers() const { return m_layers; }
00218 
00219     QDomDocument saveXML() const;
00220     virtual void saveOasis( KoStore *store, KoXmlWriter *docWriter, KoGenStyles &mainStyles ) const;
00221     enum { STYLE_GRAPHICAUTO = 20, STYLE_LINEAR_GRADIENT, STYLE_RADIAL_GRADIENT, STYLE_STROKE };
00222     bool loadXML( const QDomElement& doc );
00223     virtual bool loadOasis( const QDomElement &element, KoOasisLoadingContext &context );
00224     virtual void save( QDomElement& element ) const;
00225     virtual void load( const QDomElement& element );
00226     void loadDocumentContent( const QDomElement& doc );
00227 
00228     virtual VDocument* clone() const;
00229 
00230     virtual void accept( VVisitor& visitor );
00231 
00232 
00238     VSelection* selection() const
00239         { return m_selection; }
00240 
00246     VSelectionMode selectionMode() { return m_selectionMode; }
00247 
00253     void setSelectionMode( VSelectionMode mode ) { m_selectionMode = mode; }
00254 
00260     void append( VObject* object );
00261 
00268     QString objectName( const VObject *obj ) const;
00269 
00279     void setObjectName( const VObject *obj, const QString name ) { m_objectNames.insert( obj, name ); }
00280 
00281     bool saveAsPath() const { return m_saveAsPath; }
00282     void saveAsPath( bool b ) { m_saveAsPath = b; }
00283 
00289     KarbonGridData &grid() { return m_gridData; }
00290 
00291 private:
00295     double m_width;
00296 
00300     double m_height;
00301 
00302 
00304     VLayerList m_layers;
00306     VLayer* m_activeLayer;
00307 
00309     VSelection* m_selection;
00311     VSelectionMode m_selectionMode;
00312 
00316     KoUnit::Unit m_unit;
00317 
00318     QMap<const VObject *, QString>  m_objectNames;
00319 
00320     // TODO this flag is used nowhere, can we remove it?
00321     bool m_saveAsPath;
00322 
00323     KarbonGridData m_gridData;
00324 };
00325 
00326 #endif
00327 
KDE Home | KDE Accessibility Home | Description of Access Keys