24 #include "a2dprivate.h"
31 #include "wx/editor/candoc.h"
32 #include "wx/editor/xmlparsdoc.h"
42 m_objectCreate[ wxT(
"a2dLinearGradientFill" ) ] = wxT(
"a2dFill" );
43 m_objectCreate[ wxT(
"a2dRadialGradientFill" ) ] = wxT(
"a2dFill" );
44 m_objectCreate[ wxT(
"a2dOneColourStroke" ) ] = wxT(
"a2dStroke" );
70 if ( memcmp( cheader,
"<?xml ", 6 ) == 0 )
72 wxString buf = XmlDecodeStringToString( cheader, 169 );
76 pos = buf.Find( wxT(
"<cvg" ) );
77 if ( pos == wxNOT_FOUND )
80 pos = buf.Find( wxT(
"classname" ) );
81 if ( pos == wxNOT_FOUND )
84 #if wxUSE_STD_IOSTREAM
124 layers->
Load( NULL, *
this );
137 a2dGeneralGlobals->ReportErrorF(
a2dError_XMLparse, _(
"CVG parsing error: '%s' at line %d column %d" ), error.getMessage().c_str(), error.getLineNumber(), error.getColumnNumber() );
197 parent->
Append( readobject );
198 readobject->
Load( NULL, *
this );
211 a2dGeneralGlobals->ReportErrorF(
a2dError_XMLparse, _(
"CVG parsing error: '%s' at line %d column %d" ), error.getMessage().c_str(), error.getLineNumber(), error.getColumnNumber() );
237 #if wxUSE_STD_IOSTREAM
238 if ( stream.fail() || stream.bad() )
241 if ( !stream.IsOk() )
251 setp.
Start( layers );
256 WriteAttribute( wxT(
"classname" ), GetClassInfo()->GetClassName() );
263 layers->
Save( NULL, *
this, &towritelayer );
278 #if wxUSE_STD_IOSTREAM
279 if ( stream.fail() || stream.bad() )
282 if ( !stream.IsOk() )
305 WriteAttribute( wxT(
"classname" ), GetClassInfo()->GetClassName() );
312 void a2dIOHandlerDocCVGOut::WriteCvgEndDocument()
326 towrite.push_back( start );
328 a2dObjectList::iterator iter = towrite.begin();
329 while ( towrite.size() )
332 obj->
Save( NULL, *
this, &towrite );
333 towrite.erase( iter );
334 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.
void WriteElement(const wxString &name, const wxString &content=wxT(""), bool newLine=true)
Writes start and end tag.
bool SaveLayers(a2dDocumentOutputStream &stream, a2dLayers *layers)
save a layer definition to a CVG file.
void SetDescription(const wxString &desc)
Sets a description of the document.
XMLeventType Next()
Walks to next element and returns event type.
~a2dIOHandlerDocCVGIn()
Destructor.
void WriteStartElementAttributes(const wxString &name, bool newLine=true)
Writes start tag which has attributes.
wxOutputStream a2dDocumentOutputStream
output stream based wxStreams
virtual int GetCurrentLineNumber()
where in the input was line the current tag
~a2dIOHandlerDocCVGOut()
Destructor.
a2dDocumentInputStream * m_streami
file or other string stream containing the format to parse.
const a2dError a2dError_FileCouldNotOpen
bool SaveStartAt(a2dDocumentOutputStream &stream, const a2dCanvasDocument *doc, a2dCanvasObject *start)
saves as CVG starting at object start
a2dCanvasObject is the base class for Canvas Objects.
wxString GetContent()
Returns the current content.
a2dLayers * GetLayerSetup()
Get the layersettings for the canvas.
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
a2dCanvasDocument * m_doc
the document to store/load the data found into
const a2dError a2dError_XMLparse
virtual void InitializeSave()
Inits the IO handler for writing.
virtual bool CanLoad(a2dDocumentInputStream &stream, const wxObject *obj=NULL, wxClassInfo *docClassInfo=NULL)
test header of the file to see if its CVG format
virtual void ResetSave()
Reset the object after saving.
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
wxStringInputStream a2dDocumentStringInputStream
string input stream based wxStreams
a2dIOHandlerDocCVGOut()
Constructor.
virtual void InitializeLoad()
Inits the IO handler for reading.
a2dIOHandlerDocCVGIn()
Constructor.
void UpdateIndexes()
all non defined layers until wxMAXLAYER will be added a new childs.
void WriteEndAttributes(bool close=false)
"Closes" the start tag after writing all attributes (writes the ">" or "/>" bracket).
a2dCanvasDocument * m_doc
the document to store/load the data found into
wxClassInfo * m_docClassInfo
Run-time class information that allows document instances to be constructed dynamically.
void Save(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dObjectList *towrite)
called from a2dIOHandlerXmlSerOut after a SaveObject.
wxInputStream a2dDocumentInputStream
input stream based wxStreams
a2dWalker based algorithms
special a2dCanvasObject to make a multi view hierachy.
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.
Each a2dCanvasView needs to have a a2dCanvasDocument set in order to render data. ...
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.
wxString GetTagName()
Returns name of the current XML tag.
void SetTitle(const wxString &title, bool notifyViews=false)
Sets the title for this document.
bool LoadLayers(a2dDocumentInputStream &stream, a2dLayers *layers)
load a layer definition from a CVG file.
bool Load(a2dDocumentStringInputStream &stream, a2dCanvasDocument *doc, a2dCanvasObject *parent)
reading a CVG document and add the contents as children to a given a2dCanvasObject parent...
virtual void Save(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dObjectList *towrite)
write all needed to an XML type of file called the CVG format
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
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.
general canvas module declarations and classes