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_
23 #include "wx/richtext/richtextbuffer.h"
26 * wxRichTextXMLHandler
29 class WXDLLIMPEXP_XML wxXmlNode
;
31 class WXDLLIMPEXP_ADV wxRichTextXMLHandler
: public wxRichTextFileHandler
33 DECLARE_CLASS(wxRichTextXMLHandler
)
35 wxRichTextXMLHandler(const wxString
& name
= wxT("XML"), const wxString
& ext
= wxT("xml"), int type
= wxRICHTEXT_TYPE_XML
)
36 : wxRichTextFileHandler(name
, ext
, type
)
40 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
);
41 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
);
43 /// Recursively export an object
44 bool ExportXML(wxOutputStream
& stream
, wxMBConv
* convMem
, wxMBConv
* convFile
, wxRichTextObject
& obj
, int level
);
46 /// Recursively import an object
47 bool ImportXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
);
49 /// Create style parameters
50 wxString
CreateStyle(const wxTextAttrEx
& attr
, bool isPara
= false);
52 /// Get style parameters
53 bool GetStyle(wxTextAttrEx
& attr
, wxXmlNode
* node
, bool isPara
= false);
56 /// Can we save using this handler?
57 virtual bool CanSave() const { return true; }
59 /// Can we load using this handler?
60 virtual bool CanLoad() const { return true; }
64 bool HasParam(wxXmlNode
* node
, const wxString
& param
);
65 wxXmlNode
*GetParamNode(wxXmlNode
* node
, const wxString
& param
);
66 wxString
GetNodeContent(wxXmlNode
*node
);
67 wxString
GetParamValue(wxXmlNode
*node
, const wxString
& param
);
68 wxString
GetText(wxXmlNode
*node
, const wxString
& param
= wxEmptyString
, bool translate
= false);
75 * wxRichTextHTMLHandler
78 class WXDLLIMPEXP_ADV wxRichTextHTMLHandler
: public wxRichTextFileHandler
80 DECLARE_CLASS(wxRichTextHTMLHandler
)
82 wxRichTextHTMLHandler(const wxString
& name
= wxT("HTML"), const wxString
& ext
= wxT("html"), int type
= wxRICHTEXT_TYPE_HTML
)
83 : wxRichTextFileHandler(name
, ext
, type
)
87 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
);
88 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
);
91 /// Can we save using this handler?
92 virtual bool CanSave() const { return true; }
94 /// Can we load using this handler?
95 virtual bool CanLoad() const { return false; }
97 /// Can we handle this filename (if using files)? By default, checks the extension.
98 virtual bool CanHandle(const wxString
& filename
) const;
100 /// Output character formatting
101 virtual void OutputCharacterFormatting(const wxTextAttrEx
& currentStyle
, const wxTextAttrEx
& thisStyle
, wxOutputStream
& stream
, bool start
);
103 /// Output paragraph formatting
104 virtual void OutputParagraphFormatting(const wxTextAttrEx
& currentStyle
, const wxTextAttrEx
& thisStyle
, wxOutputStream
& stream
, bool start
);
114 // _WX_RICHTEXTXML_H_