X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/44cc96a80c09c8572e1315be66d29f6d610cbf78..43ff861df48f0837dac98005dd397c5f127ca136:/include/wx/richtext/richtextxml.h diff --git a/include/wx/richtext/richtextxml.h b/include/wx/richtext/richtextxml.h index 493511f802..baf52c79a2 100644 --- a/include/wx/richtext/richtextxml.h +++ b/include/wx/richtext/richtextxml.h @@ -26,6 +26,7 @@ */ class WXDLLIMPEXP_FWD_XML wxXmlNode; +class WXDLLIMPEXP_FWD_XML wxXmlDocument; class WXDLLIMPEXP_RICHTEXT wxRichTextXMLHandler: public wxRichTextFileHandler { @@ -33,30 +34,59 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextXMLHandler: public wxRichTextFileHandler public: wxRichTextXMLHandler(const wxString& name = wxT("XML"), const wxString& ext = wxT("xml"), int type = wxRICHTEXT_TYPE_XML) : wxRichTextFileHandler(name, ext, type) - { } + { Init(); } + + void Init(); #if wxUSE_STREAMS + +#if wxRICHTEXT_HAVE_DIRECT_OUTPUT /// Recursively export an object - bool ExportXML(wxOutputStream& stream, wxMBConv* convMem, wxMBConv* convFile, wxRichTextObject& obj, int level); - bool ExportStyleDefinition(wxOutputStream& stream, wxMBConv* convMem, wxMBConv* convFile, wxRichTextStyleDefinition* def, int level); + bool ExportXML(wxOutputStream& stream, wxRichTextObject& obj, int level); + bool ExportStyleDefinition(wxOutputStream& stream, wxRichTextStyleDefinition* def, int level); + wxString AddAttributes(const wxRichTextAttr& attr, bool isPara = false); + bool WriteProperties(wxOutputStream& stream, const wxRichTextProperties& properties, int level); + void OutputString(wxOutputStream& stream, const wxString& str); + void OutputStringEnt(wxOutputStream& stream, const wxString& str); + void OutputIndentation(wxOutputStream& stream, int indent); + static wxString AttributeToXML(const wxString& str); +#endif + +#if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT + bool ExportXML(wxXmlNode* parent, wxRichTextObject& obj); + bool ExportStyleDefinition(wxXmlNode* parent, wxRichTextStyleDefinition* def); + bool AddAttributes(wxXmlNode* node, wxRichTextAttr& attr, bool isPara = false); + bool WriteProperties(wxXmlNode* node, const wxRichTextProperties& properties); +#endif + + /// Make a string from the given property. This can be overridden for custom variants. + virtual wxString MakeStringFromProperty(const wxVariant& var); + + /// Create a proprty from the string read from the XML file. + virtual wxVariant MakePropertyFromString(const wxString& name, const wxString& value, const wxString& type); /// Recursively import an object - bool ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node); + bool ImportXML(wxRichTextBuffer* buffer, wxRichTextObject* obj, wxXmlNode* node); bool ImportStyleDefinition(wxRichTextStyleSheet* sheet, wxXmlNode* node); + bool ImportProperties(wxRichTextObject* obj, wxXmlNode* node); - /// Create style parameters - wxString CreateStyle(const wxTextAttr& attr, bool isPara = false); - - /// Get style parameters - bool GetStyle(wxTextAttr& attr, wxXmlNode* node, bool isPara = false); + /// Import style parameters + bool ImportStyle(wxRichTextAttr& attr, wxXmlNode* node, bool isPara = false); #endif + /// Creates an object given an XML element name + virtual wxRichTextObject* CreateObjectForXMLName(wxRichTextObject* parent, const wxString& name) const; + /// Can we save using this handler? virtual bool CanSave() const { return true; } /// Can we load using this handler? virtual bool CanLoad() const { return true; } + // Used during saving + wxMBConv* GetConvMem() const { return m_convMem; } + wxMBConv* GetConvFile() const { return m_convFile; } + // Implementation bool HasParam(wxXmlNode* node, const wxString& param); @@ -64,12 +94,19 @@ public: wxString GetNodeContent(wxXmlNode *node); wxString GetParamValue(wxXmlNode *node, const wxString& param); wxString GetText(wxXmlNode *node, const wxString& param = wxEmptyString, bool translate = false); + static wxXmlNode* FindNode(wxXmlNode* node, const wxString& name); protected: #if wxUSE_STREAMS virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream); virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream); #endif + +#if wxRICHTEXT_HAVE_DIRECT_OUTPUT + // Used during saving + wxMBConv* m_convMem; + wxMBConv* m_convFile; +#endif }; #endif