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