]> git.saurik.com Git - wxWidgets.git/blame - include/wx/richtext/richtextxml.h
No real changes, just use ProgID term instead of incorrect CLSID.
[wxWidgets.git] / include / wx / richtext / richtextxml.h
CommitLineData
5d7836c4 1/////////////////////////////////////////////////////////////////////////////
7fe8059f 2// Name: wx/richtext/richeditxml.h
5d7836c4
JS
3// Purpose: XML and HTML I/O for wxRichTextCtrl
4// Author: Julian Smart
7fe8059f 5// Modified by:
5d7836c4 6// Created: 2005-09-30
7fe8059f 7// RCS-ID: $Id$
5d7836c4
JS
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_RICHTEXTXML_H_
13#define _WX_RICHTEXTXML_H_
14
15/*!
16 * Includes
17 */
18
b01ca8b6 19#include "wx/richtext/richtextbuffer.h"
d2d0adc7 20#include "wx/richtext/richtextstyles.h"
5d7836c4 21
fcdbeefa 22#if wxUSE_RICHTEXT && wxUSE_XML
5d7836c4 23
5d7836c4
JS
24/*!
25 * wxRichTextXMLHandler
26 */
27
b5dbe15d 28class WXDLLIMPEXP_FWD_XML wxXmlNode;
bec80f4f 29class WXDLLIMPEXP_FWD_XML wxXmlDocument;
5d7836c4 30
3b2cb431 31class WXDLLIMPEXP_RICHTEXT wxRichTextXMLHandler: public wxRichTextFileHandler
5d7836c4
JS
32{
33 DECLARE_CLASS(wxRichTextXMLHandler)
34public:
35 wxRichTextXMLHandler(const wxString& name = wxT("XML"), const wxString& ext = wxT("xml"), int type = wxRICHTEXT_TYPE_XML)
36 : wxRichTextFileHandler(name, ext, type)
bec80f4f
JS
37 { Init(); }
38
39 void Init();
5d7836c4
JS
40
41#if wxUSE_STREAMS
bec80f4f
JS
42
43#if wxRICHTEXT_HAVE_DIRECT_OUTPUT
5d7836c4 44 /// Recursively export an object
bec80f4f
JS
45 bool ExportXML(wxOutputStream& stream, wxRichTextObject& obj, int level);
46 bool ExportStyleDefinition(wxOutputStream& stream, wxRichTextStyleDefinition* def, int level);
47 wxString AddAttributes(const wxRichTextAttr& attr, bool isPara = false);
48 bool WriteProperties(wxOutputStream& stream, const wxRichTextProperties& properties, int level);
49 void OutputString(wxOutputStream& stream, const wxString& str);
50 void OutputStringEnt(wxOutputStream& stream, const wxString& str);
51 void OutputIndentation(wxOutputStream& stream, int indent);
52 static wxString AttributeToXML(const wxString& str);
53#endif
54
55#if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
56 bool ExportXML(wxXmlNode* parent, wxRichTextObject& obj);
57 bool ExportStyleDefinition(wxXmlNode* parent, wxRichTextStyleDefinition* def);
58 bool AddAttributes(wxXmlNode* node, wxRichTextAttr& attr, bool isPara = false);
59 bool WriteProperties(wxXmlNode* node, const wxRichTextProperties& properties);
60#endif
61
62 /// Make a string from the given property. This can be overridden for custom variants.
63 virtual wxString MakeStringFromProperty(const wxVariant& var);
64
65 /// Create a proprty from the string read from the XML file.
66 virtual wxVariant MakePropertyFromString(const wxString& name, const wxString& value, const wxString& type);
5d7836c4
JS
67
68 /// Recursively import an object
bec80f4f 69 bool ImportXML(wxRichTextBuffer* buffer, wxRichTextObject* obj, wxXmlNode* node);
d2d0adc7 70 bool ImportStyleDefinition(wxRichTextStyleSheet* sheet, wxXmlNode* node);
bec80f4f 71 bool ImportProperties(wxRichTextObject* obj, wxXmlNode* node);
5d7836c4 72
bec80f4f
JS
73 /// Import style parameters
74 bool ImportStyle(wxRichTextAttr& attr, wxXmlNode* node, bool isPara = false);
5d7836c4
JS
75#endif
76
bec80f4f
JS
77 /// Creates an object given an XML element name
78 virtual wxRichTextObject* CreateObjectForXMLName(wxRichTextObject* parent, const wxString& name) const;
79
5d7836c4
JS
80 /// Can we save using this handler?
81 virtual bool CanSave() const { return true; }
82
83 /// Can we load using this handler?
84 virtual bool CanLoad() const { return true; }
85
bec80f4f
JS
86 // Used during saving
87 wxMBConv* GetConvMem() const { return m_convMem; }
88 wxMBConv* GetConvFile() const { return m_convFile; }
89
5d7836c4
JS
90// Implementation
91
92 bool HasParam(wxXmlNode* node, const wxString& param);
93 wxXmlNode *GetParamNode(wxXmlNode* node, const wxString& param);
94 wxString GetNodeContent(wxXmlNode *node);
95 wxString GetParamValue(wxXmlNode *node, const wxString& param);
96 wxString GetText(wxXmlNode *node, const wxString& param = wxEmptyString, bool translate = false);
97
98protected:
6f02a879
VZ
99#if wxUSE_STREAMS
100 virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
101 virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
102#endif
bec80f4f
JS
103
104#if wxRICHTEXT_HAVE_DIRECT_OUTPUT
105 // Used during saving
106 wxMBConv* m_convMem;
107 wxMBConv* m_convFile;
108#endif
5d7836c4
JS
109};
110
5d7836c4 111#endif
fcdbeefa 112 // wxUSE_RICHTEXT && wxUSE_XML
5d7836c4
JS
113
114#endif
115 // _WX_RICHTEXTXML_H_