2005-10-19 12:52:47 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-10-19 17:00:58 +00:00
|
|
|
// Name: wx/richtext/richeditxml.h
|
2005-10-19 12:52:47 +00:00
|
|
|
// Purpose: XML and HTML I/O for wxRichTextCtrl
|
|
|
|
// Author: Julian Smart
|
2005-10-19 17:00:58 +00:00
|
|
|
// Modified by:
|
2005-10-19 12:52:47 +00:00
|
|
|
// Created: 2005-09-30
|
2005-10-19 17:00:58 +00:00
|
|
|
// RCS-ID: $Id$
|
2005-10-19 12:52:47 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_RICHTEXTXML_H_
|
|
|
|
#define _WX_RICHTEXTXML_H_
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Includes
|
|
|
|
*/
|
|
|
|
|
2005-10-28 14:24:04 +00:00
|
|
|
#include "wx/richtext/richtextbuffer.h"
|
2006-10-26 06:32:47 +00:00
|
|
|
#include "wx/richtext/richtextstyles.h"
|
2005-10-19 12:52:47 +00:00
|
|
|
|
2005-10-31 14:27:53 +00:00
|
|
|
#if wxUSE_RICHTEXT && wxUSE_XML
|
2005-10-19 12:52:47 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxRichTextXMLHandler
|
|
|
|
*/
|
|
|
|
|
2007-07-09 10:09:52 +00:00
|
|
|
class WXDLLIMPEXP_FWD_XML wxXmlNode;
|
2005-10-19 12:52:47 +00:00
|
|
|
|
2006-06-29 07:16:39 +00:00
|
|
|
class WXDLLIMPEXP_RICHTEXT wxRichTextXMLHandler: public wxRichTextFileHandler
|
2005-10-19 12:52:47 +00: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 06:32:47 +00:00
|
|
|
bool ExportStyleDefinition(wxOutputStream& stream, wxMBConv* convMem, wxMBConv* convFile, wxRichTextStyleDefinition* def, int level);
|
2005-10-19 12:52:47 +00:00
|
|
|
|
|
|
|
/// Recursively import an object
|
|
|
|
bool ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node);
|
2006-10-26 06:32:47 +00:00
|
|
|
bool ImportStyleDefinition(wxRichTextStyleSheet* sheet, wxXmlNode* node);
|
2005-10-19 12:52:47 +00:00
|
|
|
|
|
|
|
/// Create style parameters
|
2007-10-09 11:20:36 +00:00
|
|
|
wxString CreateStyle(const wxTextAttr& attr, bool isPara = false);
|
2005-10-19 12:52:47 +00:00
|
|
|
|
|
|
|
/// Get style parameters
|
2007-10-09 11:20:36 +00:00
|
|
|
bool GetStyle(wxTextAttr& attr, wxXmlNode* node, bool isPara = false);
|
2005-10-19 12:52:47 +00:00
|
|
|
#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 21:47:09 +00:00
|
|
|
#if wxUSE_STREAMS
|
|
|
|
virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
|
|
|
|
virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
|
|
|
|
#endif
|
2005-10-19 12:52:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2005-10-31 14:27:53 +00:00
|
|
|
// wxUSE_RICHTEXT && wxUSE_XML
|
2005-10-19 12:52:47 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_RICHTEXTXML_H_
|