1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/richtext/richeditxml.h
3 // Purpose: XML and HTML I/O for wxRichTextCtrl
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_RICHTEXTXML_H_
13 #define _WX_RICHTEXTXML_H_
19 #include "wx/richtext/richtextbuffer.h"
21 #if wxUSE_RICHTEXT && wxUSE_XML
24 * wxRichTextXMLHandler
27 class WXDLLIMPEXP_XML wxXmlNode
;
29 class WXDLLIMPEXP_ADV wxRichTextXMLHandler
: public wxRichTextFileHandler
31 DECLARE_CLASS(wxRichTextXMLHandler
)
33 wxRichTextXMLHandler(const wxString
& name
= wxT("XML"), const wxString
& ext
= wxT("xml"), int type
= wxRICHTEXT_TYPE_XML
)
34 : wxRichTextFileHandler(name
, ext
, type
)
38 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
);
39 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
);
41 /// Recursively export an object
42 bool ExportXML(wxOutputStream
& stream
, wxMBConv
* convMem
, wxMBConv
* convFile
, wxRichTextObject
& obj
, int level
);
44 /// Recursively import an object
45 bool ImportXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
);
47 /// Create style parameters
48 wxString
CreateStyle(const wxTextAttrEx
& attr
, bool isPara
= false);
50 /// Get style parameters
51 bool GetStyle(wxTextAttrEx
& attr
, wxXmlNode
* node
, bool isPara
= false);
54 /// Can we save using this handler?
55 virtual bool CanSave() const { return true; }
57 /// Can we load using this handler?
58 virtual bool CanLoad() const { return true; }
62 bool HasParam(wxXmlNode
* node
, const wxString
& param
);
63 wxXmlNode
*GetParamNode(wxXmlNode
* node
, const wxString
& param
);
64 wxString
GetNodeContent(wxXmlNode
*node
);
65 wxString
GetParamValue(wxXmlNode
*node
, const wxString
& param
);
66 wxString
GetText(wxXmlNode
*node
, const wxString
& param
= wxEmptyString
, bool translate
= false);
73 * wxRichTextHTMLHandler
76 class WXDLLIMPEXP_ADV wxRichTextHTMLHandler
: public wxRichTextFileHandler
78 DECLARE_CLASS(wxRichTextHTMLHandler
)
80 wxRichTextHTMLHandler(const wxString
& name
= wxT("HTML"), const wxString
& ext
= wxT("html"), int type
= wxRICHTEXT_TYPE_HTML
)
81 : wxRichTextFileHandler(name
, ext
, type
)
85 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
);
86 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
);
89 /// Can we save using this handler?
90 virtual bool CanSave() const { return true; }
92 /// Can we load using this handler?
93 virtual bool CanLoad() const { return false; }
95 /// Can we handle this filename (if using files)? By default, checks the extension.
96 virtual bool CanHandle(const wxString
& filename
) const;
98 /// Output character formatting
99 virtual void OutputCharacterFormatting(const wxTextAttrEx
& currentStyle
, const wxTextAttrEx
& thisStyle
, wxOutputStream
& stream
, bool start
);
101 /// Output paragraph formatting
102 virtual void OutputParagraphFormatting(const wxTextAttrEx
& currentStyle
, const wxTextAttrEx
& thisStyle
, wxOutputStream
& stream
, bool start
);
109 // wxUSE_RICHTEXT && wxUSE_XML
112 // _WX_RICHTEXTXML_H_