X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/12f5e1e78fe906050ff2fee9529476db332633f0..d3fa4bc22e84e3ca4d88cc1772f2d414140a1017:/interface/wx/richtext/richtextxml.h?ds=inline diff --git a/interface/wx/richtext/richtextxml.h b/interface/wx/richtext/richtextxml.h index 1a0f881e04..b5a838c6ea 100644 --- a/interface/wx/richtext/richtextxml.h +++ b/interface/wx/richtext/richtextxml.h @@ -3,17 +3,28 @@ // Purpose: interface of wxRichTextXMLHandler // Author: wxWidgets team // RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /** @class wxRichTextXMLHandler A handler for loading and saving content in an XML format specific - to wxRichTextBuffer. You can either add the handler to the buffer - and load and save through the buffer or control API, or you can - create an instance of the handler on the stack and call its - functions directly. + to wxRichTextBuffer. + + You can either add the handler to the buffer and load and save through + the buffer or control API, or you can create an instance of the handler + on the stack and call its functions directly. + + + @section richtextxmlhandler_flags Handler flags + + The following flags can be used with this handler, via the handler's SetFlags() + function or the buffer or control's SetHandlerFlags() function: + + - wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET + Include the style sheet in loading and saving operations. + @library{wxrichtext} @category{richtext} @@ -22,43 +33,26 @@ class wxRichTextXMLHandler : public wxRichTextFileHandler { public: /** - , wxString&@e ext = wxT("xml"), @b int@e type = wxRICHTEXT_TYPE_XML) Constructor. */ - wxRichTextXMLHandler() const; + wxRichTextXMLHandler(const wxString& name = "XML", + const wxString& ext = "xml", + int type = wxRICHTEXT_TYPE_XML); /** Returns @true. */ - bool CanLoad() const; + virtual bool CanLoad() const; /** Returns @true. */ - bool CanSave() const; - - /** - Creates XML code for a given character or paragraph style. - */ - wxString CreateStyle(const wxTextAttr& attr, bool isPara = false); - - /** - Loads buffer context from the given stream. - */ - bool DoLoadFile(wxRichTextBuffer* buffer, wxInputStream& stream); - - /** - Saves buffer context to the given stream. - */ - bool DoSaveFile(wxRichTextBuffer* buffer, wxOutputStream& stream); + virtual bool CanSave() const; /** Recursively exports an object to the stream. */ - bool ExportXML(wxOutputStream& stream, wxMBConv* convMem, - wxMBConv* convFile, - wxRichTextObject& obj, - int level); + bool ExportXML(wxOutputStream& stream, wxRichTextObject& obj, int level); /** Helper function: gets node context. @@ -75,12 +69,6 @@ public: */ wxString GetParamValue(wxXmlNode* node, const wxString& param); - /** - Helper function: gets style parameters from the given XML node. - */ - bool GetStyle(wxTextAttr& attr, wxXmlNode* node, - bool isPara = false); - /** Helper function: gets text from the node. */ @@ -96,6 +84,29 @@ public: /** Recursively imports an object. */ - bool ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node); + bool ImportXML(wxRichTextBuffer* buffer, wxRichTextObject* obj, wxXmlNode* node); + + /** + Call with XML node name, C++ class name so that wxRTC can read in the node. + If you add a custom object, call this. + */ + static void RegisterNodeName(const wxString& nodeName, const wxString& className) { sm_nodeNameToClassMap[nodeName] = className; } + + /** + Cleans up the mapping between node name and C++ class. + */ + static void ClearNodeToClassMap() { sm_nodeNameToClassMap.clear(); } + +protected: + + /** + Loads buffer context from the given stream. + */ + virtual bool DoLoadFile(wxRichTextBuffer* buffer, wxInputStream& stream); + + /** + Saves buffer context to the given stream. + */ + virtual bool DoSaveFile(wxRichTextBuffer* buffer, wxOutputStream& stream); };