wxArt2D
xmlparsdoc.h
1 /*! \file wx/canvas/xmlpars.h
2  \brief a2dIOHandlerCVGIn and a2dIOHandlerCVGOut - XML I/O classes for the CVG format.
3 
4  The main way of serialisation is done with XML and the format is called CVG ( canvas vector graphics ).
5 
6  \author Probably Klaas Holwerda
7 
8  Copyright: 2001-2004 (C) Probably Klaas Holwerda
9 
10  Licence: wxWidgets licence
11 
12  RCS-ID: $Id: xmlpars.h,v 1.16 2009/05/15 16:34:28 titato Exp $
13 */
14 
15 #ifndef _WX_CANVASDOCXMLIO_H_
16 #define _WX_CANVASDOCXMLIO_H_
17 
18 #include "a2dprivate.h"
19 
20 #if wxART2D_USE_XMLPARSE
21 
22 #include <wx/defs.h>
23 #include <wx/string.h>
24 
25 #if wxCHECK_VERSION(2, 5, 3)
26 #include <wx/sstream.h>
27 #endif
28 
29 #include <expat.h>
30 
31 #include "wx/docview/docviewref.h"
32 
33 #include "wx/xmlparse/genxmlpars.h"
34 #include "wx/xmlparse/xmlencode.h"
35 #include "wx/canvas/candefs.h"
36 
37 #if wxART2D_USE_CVGIO
38 
39 
40 //! Input handler for the CVG format.
41 /*!
42  The CVG format is the native file format of wxArt2d.
43  It's a XML format and each a2dCanvasObject is able to load its data from CVG.
44  There's no specification of the CVG, please have a look into the DoLoad methods
45  of the a2dCanvasObject derived classes to see details.
46 
47  In general the following is done.
48  - each a2dObject has a2dObject::Save() and a2dObject::Load() as a start for serialisation.
49  - a2dObject::DoLoad and a2dObject::DoSave() methods are virtual and should be implemented
50  to save also the data of the derived classes.
51  - Saving is a two pass process, in order to first write all XML attributes of an object and next
52  its NON attribute data and nested objects.
53  - one always needs to call derivedFrom::DoLoad in the implementation of a Doload()
54  - one always needs to call derivedFrom::DoSave in the implementation of a DoSave()
55  - multiple referenced objects are written only by refid attribute. When loading the file,
56  those references are resolved.
57 
58  \ingroup fileio cvgfileio
59 */
60 class A2DCANVASDLLEXP a2dIOHandlerDocCVGIn : public a2dIOHandlerCVGIn
61 {
62 public:
63  //! Constructor.
65 
66  //! Destructor.
68 
69  //! test header of the file to see if its CVG format
70  virtual bool CanLoad( a2dDocumentInputStream& stream, const wxObject* obj = NULL, wxClassInfo* docClassInfo = NULL );
71 
72  //! load a layer definition from a CVG file.
73  bool LoadLayers( a2dDocumentInputStream& stream, a2dLayers* layers );
74 
75  //! reading a CVG document and add the contents as children to a given a2dCanvasObject parent.
76  /*!
77  This can be used to include a CVG document in an existing document.
78  Also clipboard action might use this.
79  */
81 
82 protected:
83 
84  //! the document to store/load the data found into
86 
87 };
88 
89 //! output handler for the CVG format.
90 /*!
91  The CVG format is the native file format of wxArt2d.
92  It's a XML format and each a2dCanvasObject is able to save its data as CVG.
93  There's no specification of the CVG, please have a look into the DoSave methods
94  of the a2dCanvasObject derived classes to see details.
95 
96  \ingroup fileio cvgfileio
97 */
98 class A2DCANVASDLLEXP a2dIOHandlerDocCVGOut : public a2dIOHandlerCVGOut
99 {
100 public:
101  //! Constructor.
103 
104  //! Destructor.
106 
107  //! this handler can also save as CVG
108  bool CanSave( const wxObject* obj = NULL ) { return true; }
109 
110  //! saves as CVG starting at object start
111  bool SaveStartAt( a2dDocumentOutputStream& stream, const a2dCanvasDocument* doc, a2dCanvasObject* start );
112 
113  //! save a layer definition to a CVG file.
114  bool SaveLayers( a2dDocumentOutputStream& stream, a2dLayers* layers );
115 
116  void WriteCvgStartDocument( a2dDocumentOutputStream& stream );
117 
118  void WriteCvgEndDocument();
119 
120  void WriteObject( a2dCanvasObject* start );
121 
122 protected:
123 
124  //! the document to store/load the data found into
126 };
127 
128 #endif //wxART2D_USE_CVGIO
129 
130 #endif // wxART2D_USE_XMLPARSE
131 
132 #endif /* _WX_CANVASDOCXMLIO_H_ */
133 
output handler for the CVG format.
Definition: xmlparsdoc.h:98
bool SaveStartAt(a2dDocumentOutputStream &stream, const a2dDrawing *drawing, a2dCanvasObject *start)
saves as CVG starting at object start
Definition: xmlpars.cpp:344
wxOutputStream a2dDocumentOutputStream
output stream based wxStreams
Definition: gen.h:3458
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
output handler for the CVG format.
Definition: xmlpars.h:103
defenitions an no more
XML I/O classes which is Pull parser based for reading XML files.
a2dCanvasDocument * m_doc
the document to store/load the data found into
Definition: xmlparsdoc.h:85
virtual bool CanLoad(a2dDocumentInputStream &stream, const wxObject *obj=NULL, wxClassInfo *docClassInfo=NULL)
test header of the file to see if its CVG format
Definition: xmlpars.cpp:52
Input handler for the CVG format.
Definition: xmlparsdoc.h:60
Docview classes for document view, window and frame.
bool SaveLayers(a2dDocumentOutputStream &stream, a2dLayers *layers)
save a layer definition to a CVG file.
Definition: xmlpars.cpp:304
wxStringInputStream a2dDocumentStringInputStream
string input stream based wxStreams
Definition: gen.h:3452
bool Load(a2dDocumentStringInputStream &stream, a2dDrawing *doc, a2dCanvasObject *parent)
reading a CVG document and add the contents as children to a given a2dCanvasObject parent...
Definition: xmlpars.cpp:146
bool LoadLayers(a2dDocumentInputStream &stream, a2dLayers *layers)
load a layer definition from a CVG file.
Definition: xmlpars.cpp:93
functions for encoding characters in xml
a2dCanvasDocument * m_doc
the document to store/load the data found into
Definition: xmlparsdoc.h:125
wxInputStream a2dDocumentInputStream
input stream based wxStreams
Definition: gen.h:3456
Each a2dCanvasView needs to have a a2dCanvasDocument set in order to render data. ...
Definition: candoc.h:374
bool CanSave(const wxObject *obj=NULL)
this handler can also save as CVG
Definition: xmlparsdoc.h:108
Input handler for the CVG format.
Definition: xmlpars.h:59
xmlparsdoc.h Source File -- Sun Oct 12 2014 17:04:26 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation