24 #include "a2dprivate.h"
41 m_objectCreate[ wxT(
"a2dLinearGradientFill" ) ] = wxT(
"a2dFill" );
42 m_objectCreate[ wxT(
"a2dRadialGradientFill" ) ] = wxT(
"a2dFill" );
43 m_objectCreate[ wxT(
"a2dOneColourStroke" ) ] = wxT(
"a2dStroke" );
69 if ( memcmp( cheader,
"<?xml ", 6 ) == 0 )
71 wxString buf = XmlDecodeStringToString( cheader, 169 );
75 pos = buf.Find( wxT(
"<cvg" ) );
76 if ( pos == wxNOT_FOUND )
79 pos = buf.Find( wxT(
"classname" ) );
80 if ( pos == wxNOT_FOUND )
83 #if wxUSE_STD_IOSTREAM
123 layers->
Load( NULL, *
this );
136 a2dGeneralGlobals->ReportErrorF(
a2dError_XMLparse, _(
"CVG parsing error: '%s' at line %d column %d" ), error.getMessage().c_str(), error.getLineNumber(), error.getColumnNumber() );
157 wxString version = wxT(
"");
160 drawing->
Load( NULL, *
this );
216 a2dGeneralGlobals->ReportErrorF(
a2dError_XMLparse, _(
"CVG parsing error: '%s' at line %d column %d" ), error.getMessage().c_str(), error.getLineNumber(), error.getColumnNumber() );
269 canvasobject->
Load( NULL, *
this );
282 a2dGeneralGlobals->ReportErrorF(
a2dError_XMLparse, _(
"CVG parsing error: '%s' at line %d column %d" ), error.getMessage().c_str(), error.getLineNumber(), error.getColumnNumber() );
308 #if wxUSE_STD_IOSTREAM
309 if ( stream.fail() || stream.bad() )
312 if ( !stream.IsOk() )
322 setp.
Start( layers );
327 WriteAttribute( wxT(
"classname" ), GetClassInfo()->GetClassName() );
334 layers->
Save( NULL, *
this, &towritelayer );
348 #if wxUSE_STD_IOSTREAM
349 if ( stream.fail() || stream.bad() )
352 if ( !stream.IsOk() )
361 const_cast<a2dDrawing*
>( drawing )->
Save( NULL, *
this, &towrite, start );
376 WriteAttribute( wxT(
"classname" ), GetClassInfo()->GetClassName() );
383 void a2dIOHandlerCVGOut::WriteCvgEndDocument()
397 towrite.push_back( start );
399 a2dObjectList::iterator iter = towrite.begin();
400 while ( towrite.size() )
403 obj->
Save( NULL, *
this, &towrite );
404 towrite.erase( iter );
405 iter = towrite.begin();
set check on a2dObject flag false or true
For exceptions thrown while parsing XML files.
a2dHashMapCreateObject m_objectCreate
This is used to find a classname using a symbolic name.
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
bool SaveStartAt(a2dDocumentOutputStream &stream, const a2dDrawing *drawing, a2dCanvasObject *start)
saves as CVG starting at object start
void WriteElement(const wxString &name, const wxString &content=wxT(""), bool newLine=true)
Writes start and end tag.
XMLeventType Next()
Walks to next element and returns event type.
void WriteStartElementAttributes(const wxString &name, bool newLine=true)
Writes start tag which has attributes.
a2dIOHandlerCVGIn and a2dIOHandlerCVGOut - XML I/O classes for the CVG format.
wxOutputStream a2dDocumentOutputStream
output stream based wxStreams
virtual int GetCurrentLineNumber()
where in the input was line the current tag
a2dDocumentInputStream * m_streami
file or other string stream containing the format to parse.
const a2dError a2dError_FileCouldNotOpen
a2dCanvasObject is the base class for Canvas Objects.
virtual wxObject * CreateObject(const wxString &symbolicName)
Creates an specific object by name.
void WriteEndElement(bool newLine=true)
Writes correspondending end tag for the current start tag.
virtual void ResetLoad()
Reset the object after loading.
void WriteStartDocument(const wxString &version, const wxString &encoding, bool standalone)
Writes the XML header declaration.
a2dIOHandlerStrIn & SeekI(wxFileOffset pos)
set stream at a position
virtual bool CanLoad(a2dDocumentInputStream &stream, const wxObject *obj=NULL, wxClassInfo *docClassInfo=NULL)
test header of the file to see if its CVG format
a2dIOHandlerCVGIn()
Constructor.
~a2dIOHandlerCVGOut()
Destructor.
const a2dError a2dError_XMLparse
virtual void InitializeSave()
Inits the IO handler for writing.
virtual void ResetSave()
Reset the object after saving.
bool SaveLayers(a2dDocumentOutputStream &stream, a2dLayers *layers)
save a layer definition to a CVG file.
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
wxStringInputStream a2dDocumentStringInputStream
string input stream based wxStreams
bool Load(a2dDocumentStringInputStream &stream, a2dDrawing *doc, a2dCanvasObject *parent)
reading a CVG document and add the contents as children to a given a2dCanvasObject parent...
virtual void InitializeLoad()
Inits the IO handler for reading.
void UpdateIndexes()
all non defined layers until wxMAXLAYER will be added a new childs.
bool LoadLayers(a2dDocumentInputStream &stream, a2dLayers *layers)
load a layer definition from a CVG file.
Contains a2dDrawing Class to hold a drawing.
void WriteEndAttributes(bool close=false)
"Closes" the start tag after writing all attributes (writes the ">" or "/>" bracket).
wxClassInfo * m_docClassInfo
Run-time class information that allows document instances to be constructed dynamically.
a2dIOHandlerCVGOut()
Constructor.
wxInputStream a2dDocumentInputStream
input stream based wxStreams
a2dWalker based algorithms
virtual void Load(wxObject *parent, a2dIOHandlerXmlSerIn &parser)
load object from CVG file
wxString GetAttributeValue(const wxString &attrib, const wxString &defaultv=wxT(""))
Returns the value of an attribute.
virtual void Load(wxObject *parent, a2dIOHandlerXmlSerIn &parser)
load object from CVG file
void WriteEndDocument()
Checks if all open tags are closed.
XMLeventType GetEventType()
Returns the type of current event.
void Require(const XMLeventType &type, wxString name)
Forces a special tag.
virtual bool Save(a2dDocumentOutputStream &stream, const wxObject *doc)
save a2dCanvasDocument as CVG
wxString GetTagName()
Returns name of the current XML tag.
virtual void Save(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dObjectList *towrite)
write all needed to an XML type of file called the CVG format
~a2dIOHandlerCVGIn()
Destructor.
virtual bool LinkReferences(bool ignoreNonResolved=false)
link references to their destination
a2dDocumentOutputStream * m_streamo
file or other string stream containing the format to output to.
bool Start(a2dObject *object)
start removing properties from the object given, and down.
void SetFormatVersion(wxString formatVersion)
set version of library or document being parsed for
Contain one drawing as hierarchical tree of a2dCanvasObject's.
general canvas module declarations and classes