2005-10-19 08:52:47 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-10-19 13:00:58 -04:00
|
|
|
// Name: wx/richtext/richeditxml.h
|
2005-10-19 08:52:47 -04:00
|
|
|
// Purpose: XML and HTML I/O for wxRichTextCtrl
|
|
|
|
// Author: Julian Smart
|
2005-10-19 13:00:58 -04:00
|
|
|
// Modified by:
|
2005-10-19 08:52:47 -04:00
|
|
|
// Created: 2005-09-30
|
2005-10-19 13:00:58 -04:00
|
|
|
// RCS-ID: $Id$
|
2005-10-19 08:52:47 -04:00
|
|
|
// Copyright: (c) Julian Smart
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_RICHTEXTXML_H_
|
|
|
|
#define _WX_RICHTEXTXML_H_
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Includes
|
|
|
|
*/
|
|
|
|
|
2005-10-28 10:24:04 -04:00
|
|
|
#include "wx/richtext/richtextbuffer.h"
|
2006-10-26 02:32:47 -04:00
|
|
|
#include "wx/richtext/richtextstyles.h"
|
2005-10-19 08:52:47 -04:00
|
|
|
|
2005-10-31 09:27:53 -05:00
|
|
|
#if wxUSE_RICHTEXT && wxUSE_XML
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxRichTextXMLHandler
|
|
|
|
*/
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_XML wxXmlNode;
|
|
|
|
|
2006-06-29 03:16:39 -04:00
|
|
|
class WXDLLIMPEXP_RICHTEXT wxRichTextXMLHandler: public wxRichTextFileHandler
|
2005-10-19 08:52:47 -04:00
|
|
|
{
|
|
|
|
DECLARE_CLASS(wxRichTextXMLHandler)
|
|
|
|
public:
|
|
|
|
wxRichTextXMLHandler(const wxString& name = wxT("XML"), const wxString& ext = wxT("xml"), int type = wxRICHTEXT_TYPE_XML)
|
|
|
|
: wxRichTextFileHandler(name, ext, type)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
#if wxUSE_STREAMS
|
|
|
|
/// Recursively export an object
|
|
|
|
bool ExportXML(wxOutputStream& stream, wxMBConv* convMem, wxMBConv* convFile, wxRichTextObject& obj, int level);
|
2006-10-26 02:32:47 -04:00
|
|
|
bool ExportStyleDefinition(wxOutputStream& stream, wxMBConv* convMem, wxMBConv* convFile, wxRichTextStyleDefinition* def, int level);
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Recursively import an object
|
|
|
|
bool ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node);
|
2006-10-26 02:32:47 -04:00
|
|
|
bool ImportStyleDefinition(wxRichTextStyleSheet* sheet, wxXmlNode* node);
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Create style parameters
|
|
|
|
wxString CreateStyle(const wxTextAttrEx& attr, bool isPara = false);
|
|
|
|
|
|
|
|
/// Get style parameters
|
|
|
|
bool GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool isPara = false);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/// Can we save using this handler?
|
|
|
|
virtual bool CanSave() const { return true; }
|
|
|
|
|
|
|
|
/// Can we load using this handler?
|
|
|
|
virtual bool CanLoad() const { return true; }
|
|
|
|
|
|
|
|
// Implementation
|
|
|
|
|
|
|
|
bool HasParam(wxXmlNode* node, const wxString& param);
|
|
|
|
wxXmlNode *GetParamNode(wxXmlNode* node, const wxString& param);
|
|
|
|
wxString GetNodeContent(wxXmlNode *node);
|
|
|
|
wxString GetParamValue(wxXmlNode *node, const wxString& param);
|
|
|
|
wxString GetText(wxXmlNode *node, const wxString& param = wxEmptyString, bool translate = false);
|
|
|
|
|
|
|
|
protected:
|
2006-02-08 16:47:09 -05:00
|
|
|
#if wxUSE_STREAMS
|
|
|
|
virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
|
|
|
|
virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
|
|
|
|
#endif
|
2005-10-19 08:52:47 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2005-10-31 09:27:53 -05:00
|
|
|
// wxUSE_RICHTEXT && wxUSE_XML
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_RICHTEXTXML_H_
|