]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/richtext/richtextxml.h
Remove hard TABs from 3rd party files in src directory.
[wxWidgets.git] / interface / wx / richtext / richtextxml.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: richtext/richtextxml.h
21b447dc 3// Purpose: interface of wxRichTextXMLHandler
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxRichTextXMLHandler
7c913512 11
23324ae1 12 A handler for loading and saving content in an XML format specific
9e7ad1ca
FM
13 to wxRichTextBuffer.
14
15 You can either add the handler to the buffer and load and save through
16 the buffer or control API, or you can create an instance of the handler
17 on the stack and call its functions directly.
18
19
20 @section richtextxmlhandler_flags Handler flags
21
22 The following flags can be used with this handler, via the handler's SetFlags()
23 function or the buffer or control's SetHandlerFlags() function:
24
25 - wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET
26 Include the style sheet in loading and saving operations.
27
7c913512 28
23324ae1 29 @library{wxrichtext}
21b447dc 30 @category{richtext}
23324ae1
FM
31*/
32class wxRichTextXMLHandler : public wxRichTextFileHandler
33{
34public:
35 /**
23324ae1
FM
36 Constructor.
37 */
f8ebb70d
FM
38 wxRichTextXMLHandler(const wxString& name = "XML",
39 const wxString& ext = "xml",
0004982c 40 int type = wxRICHTEXT_TYPE_XML);
23324ae1
FM
41
42 /**
43 Returns @true.
44 */
adaaa686 45 virtual bool CanLoad() const;
23324ae1
FM
46
47 /**
48 Returns @true.
49 */
adaaa686 50 virtual bool CanSave() const;
23324ae1
FM
51
52 /**
53 Creates XML code for a given character or paragraph style.
54 */
4cc4bfaf 55 wxString CreateStyle(const wxTextAttr& attr, bool isPara = false);
23324ae1 56
23324ae1
FM
57 /**
58 Recursively exports an object to the stream.
59 */
60 bool ExportXML(wxOutputStream& stream, wxMBConv* convMem,
61 wxMBConv* convFile,
62 wxRichTextObject& obj,
63 int level);
64
65 /**
66 Helper function: gets node context.
67 */
68 wxString GetNodeContent(wxXmlNode* node);
69
70 /**
71 Helper function: gets a named parameter from the XML node.
72 */
73 wxXmlNode* GetParamNode(wxXmlNode* node, const wxString& param);
74
75 /**
76 Helper function: gets a named parameter from the XML node.
77 */
78 wxString GetParamValue(wxXmlNode* node, const wxString& param);
79
80 /**
81 Helper function: gets style parameters from the given XML node.
82 */
83 bool GetStyle(wxTextAttr& attr, wxXmlNode* node,
4cc4bfaf 84 bool isPara = false);
23324ae1
FM
85
86 /**
87 Helper function: gets text from the node.
88 */
89 wxString GetText(wxXmlNode* node,
90 const wxString& param = wxEmptyString,
4cc4bfaf 91 bool translate = false);
23324ae1
FM
92
93 /**
94 Helper function: returns @true if the node has the given parameter.
95 */
96 bool HasParam(wxXmlNode* node, const wxString& param);
97
98 /**
99 Recursively imports an object.
100 */
101 bool ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node);
5e6e278d
FM
102
103protected:
104
105 /**
106 Loads buffer context from the given stream.
107 */
108 virtual bool DoLoadFile(wxRichTextBuffer* buffer, wxInputStream& stream);
109
110 /**
111 Saves buffer context to the given stream.
112 */
113 virtual bool DoSaveFile(wxRichTextBuffer* buffer, wxOutputStream& stream);
23324ae1 114};
e54c96f1 115