1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richtextxml.cpp
3 // Purpose: XML and HTML I/O for wxRichTextCtrl
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
19 #if wxUSE_RICHTEXT && wxUSE_XML
21 #include "wx/richtext/richtextxml.h"
25 #include "wx/module.h"
29 #include "wx/filename.h"
30 #include "wx/clipbrd.h"
31 #include "wx/wfstream.h"
32 #include "wx/sstream.h"
33 #include "wx/txtstrm.h"
34 #include "wx/mstream.h"
35 #include "wx/tokenzr.h"
36 #include "wx/stopwatch.h"
37 #include "wx/xml/xml.h"
39 // Set to 1 for slower wxXmlDocument method, 0 for faster direct method.
40 // If we make wxXmlDocument::Save more efficient, we might switch to this
42 #define wxRICHTEXT_USE_XMLDOCUMENT_OUTPUT 0
44 #if wxRICHTEXT_USE_XMLDOCUMENT_OUTPUT && !wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
45 # error Must define wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT in richtextxml.h to use this method.
48 #if !wxRICHTEXT_USE_XMLDOCUMENT_OUTPUT && !wxRICHTEXT_HAVE_DIRECT_OUTPUT
49 # error Must define wxRICHTEXT_HAVE_DIRECT_OUTPUT in richtextxml.h to use this method.
52 // Set to 1 to time file saving
53 #define wxRICHTEXT_USE_OUTPUT_TIMINGS 0
55 // Convert a colour to a 6-digit hex string
56 static wxString
ColourToHexString(const wxColour
& col
)
60 hex
+= wxDecToHex(col
.Red());
61 hex
+= wxDecToHex(col
.Green());
62 hex
+= wxDecToHex(col
.Blue());
67 // Convert 6-digit hex string to a colour
68 static wxColour
HexStringToColour(const wxString
& hex
)
70 unsigned char r
= (unsigned char)wxHexToDec(hex
.Mid(0, 2));
71 unsigned char g
= (unsigned char)wxHexToDec(hex
.Mid(2, 2));
72 unsigned char b
= (unsigned char)wxHexToDec(hex
.Mid(4, 2));
74 return wxColour(r
, g
, b
);
77 static inline wxString
MakeString(const int& v
) { return wxString::Format(wxT("%d"), v
); }
78 static inline wxString
MakeString(const long& v
) { return wxString::Format(wxT("%ld"), v
); }
79 static inline wxString
MakeString(const double& v
) { return wxString::Format(wxT("%.2f"), (float) v
); }
80 static inline wxString
MakeString(const wxString
& s
) { return s
; }
81 static inline wxString
MakeString(const wxColour
& col
) { return wxT("#") + ColourToHexString(col
); }
83 static inline void AddString(wxString
& str
, const int& v
) { str
<< wxString::Format(wxT("%d"), v
); }
84 static inline void AddString(wxString
& str
, const long& v
) { str
<< wxString::Format(wxT("%ld"), v
); }
85 static inline void AddString(wxString
& str
, const double& v
) { str
<< wxString::Format(wxT("%.2f"), (float) v
); }
86 static inline void AddString(wxString
& str
, const wxChar
* s
) { str
<< s
; }
87 static inline void AddString(wxString
& str
, const wxString
& s
) { str
<< s
; }
88 static inline void AddString(wxString
& str
, const wxColour
& col
) { str
<< wxT("#") << ColourToHexString(col
); }
90 IMPLEMENT_DYNAMIC_CLASS(wxRichTextXMLHandler
, wxRichTextFileHandler
)
92 void wxRichTextXMLHandler::Init()
94 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
102 bool wxRichTextXMLHandler::DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
)
107 buffer
->ResetAndClearCommands();
110 wxXmlDocument
* xmlDoc
= new wxXmlDocument
;
113 // This is the encoding to convert to (memory encoding rather than file encoding)
114 wxString
encoding(wxT("UTF-8"));
116 #if !wxUSE_UNICODE && wxUSE_INTL
117 encoding
= wxLocale::GetSystemEncodingName();
120 if (!xmlDoc
->Load(stream
, encoding
))
122 buffer
->ResetAndClearCommands();
127 if (xmlDoc
->GetRoot() && xmlDoc
->GetRoot()->GetType() == wxXML_ELEMENT_NODE
&& xmlDoc
->GetRoot()->GetName() == wxT("richtext"))
129 wxXmlNode
* child
= xmlDoc
->GetRoot()->GetChildren();
132 if (child
->GetType() == wxXML_ELEMENT_NODE
)
134 wxString name
= child
->GetName();
135 if (name
== wxT("richtext-version"))
139 ImportXML(buffer
, buffer
, child
);
142 child
= child
->GetNext();
153 buffer
->UpdateRanges();
158 /// Creates an object given an XML element name
159 wxRichTextObject
* wxRichTextXMLHandler::CreateObjectForXMLName(wxRichTextObject
* WXUNUSED(parent
), const wxString
& name
) const
161 if (name
== wxT("text") || name
== wxT("symbol"))
162 return new wxRichTextPlainText
;
163 else if (name
== wxT("image"))
164 return new wxRichTextImage
;
165 else if (name
== wxT("paragraph"))
166 return new wxRichTextParagraph
;
167 else if (name
== wxT("paragraphlayout"))
168 return new wxRichTextParagraphLayoutBox
;
169 else if (name
== wxT("textbox"))
170 return new wxRichTextBox
;
171 else if (name
== wxT("cell"))
172 return new wxRichTextCell
;
173 else if (name
== wxT("table"))
174 return new wxRichTextTable
;
179 /// Recursively import an object
180 bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer
* buffer
, wxRichTextObject
* obj
, wxXmlNode
* node
)
182 bool recurse
= false;
183 obj
->ImportFromXML(buffer
, node
, this, & recurse
);
185 // TODO: how to control whether to import children.
187 wxRichTextCompositeObject
* compositeParent
= wxDynamicCast(obj
, wxRichTextCompositeObject
);
188 if (recurse
&& compositeParent
)
190 wxXmlNode
* child
= node
->GetChildren();
193 if (child
->GetName() != wxT("stylesheet"))
195 wxRichTextObject
* childObj
= CreateObjectForXMLName(obj
, child
->GetName());
198 compositeParent
->AppendChild(childObj
);
199 ImportXML(buffer
, childObj
, child
);
202 child
= child
->GetNext();
209 bool wxRichTextXMLHandler::ImportProperties(wxRichTextObject
* obj
, wxXmlNode
* node
)
211 return ImportProperties(obj
->GetProperties(), node
);
214 bool wxRichTextXMLHandler::ImportProperties(wxRichTextProperties
& properties
, wxXmlNode
* node
)
216 wxXmlNode
* child
= node
->GetChildren();
219 if (child
->GetName() == wxT("properties"))
221 wxXmlNode
* propertyChild
= child
->GetChildren();
222 while (propertyChild
)
224 if (propertyChild
->GetName() == wxT("property"))
226 wxString name
= propertyChild
->GetAttribute(wxT("name"), wxEmptyString
);
227 wxString value
= propertyChild
->GetAttribute(wxT("value"), wxEmptyString
);
228 wxString type
= propertyChild
->GetAttribute(wxT("type"), wxEmptyString
);
230 wxVariant var
= MakePropertyFromString(name
, value
, type
);
233 properties
.SetProperty(var
);
236 propertyChild
= propertyChild
->GetNext();
239 child
= child
->GetNext();
244 bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet
* sheet
, wxXmlNode
* node
)
246 wxString styleType
= node
->GetName();
247 wxString styleName
= node
->GetAttribute(wxT("name"), wxEmptyString
);
248 wxString baseStyleName
= node
->GetAttribute(wxT("basestyle"), wxEmptyString
);
250 if (styleName
.empty())
253 if (styleType
== wxT("characterstyle"))
255 wxRichTextCharacterStyleDefinition
* def
= new wxRichTextCharacterStyleDefinition(styleName
);
256 def
->SetBaseStyle(baseStyleName
);
258 wxXmlNode
* child
= node
->GetChildren();
261 if (child
->GetName() == wxT("style"))
264 ImportStyle(attr
, child
, false);
267 child
= child
->GetNext();
270 ImportProperties(def
->GetProperties(), node
);
272 sheet
->AddCharacterStyle(def
);
274 else if (styleType
== wxT("paragraphstyle"))
276 wxRichTextParagraphStyleDefinition
* def
= new wxRichTextParagraphStyleDefinition(styleName
);
278 wxString nextStyleName
= node
->GetAttribute(wxT("nextstyle"), wxEmptyString
);
279 def
->SetNextStyle(nextStyleName
);
280 def
->SetBaseStyle(baseStyleName
);
282 wxXmlNode
* child
= node
->GetChildren();
285 if (child
->GetName() == wxT("style"))
288 ImportStyle(attr
, child
, true);
291 child
= child
->GetNext();
294 ImportProperties(def
->GetProperties(), node
);
296 sheet
->AddParagraphStyle(def
);
298 else if (styleType
== wxT("boxstyle"))
300 wxRichTextBoxStyleDefinition
* def
= new wxRichTextBoxStyleDefinition(styleName
);
302 def
->SetBaseStyle(baseStyleName
);
304 wxXmlNode
* child
= node
->GetChildren();
307 if (child
->GetName() == wxT("style"))
310 ImportStyle(attr
, child
, true);
313 child
= child
->GetNext();
316 ImportProperties(def
->GetProperties(), node
);
318 sheet
->AddBoxStyle(def
);
320 else if (styleType
== wxT("liststyle"))
322 wxRichTextListStyleDefinition
* def
= new wxRichTextListStyleDefinition(styleName
);
324 wxString nextStyleName
= node
->GetAttribute(wxT("nextstyle"), wxEmptyString
);
325 def
->SetNextStyle(nextStyleName
);
326 def
->SetBaseStyle(baseStyleName
);
328 wxXmlNode
* child
= node
->GetChildren();
331 if (child
->GetName() == wxT("style"))
334 ImportStyle(attr
, child
, true);
336 wxString styleLevel
= child
->GetAttribute(wxT("level"), wxEmptyString
);
337 if (styleLevel
.empty())
343 int level
= wxAtoi(styleLevel
);
344 if (level
> 0 && level
<= 10)
346 def
->SetLevelAttributes(level
-1, attr
);
350 child
= child
->GetNext();
353 ImportProperties(def
->GetProperties(), node
);
355 sheet
->AddListStyle(def
);
361 //-----------------------------------------------------------------------------
362 // xml support routines
363 //-----------------------------------------------------------------------------
365 bool wxRichTextXMLHandler::HasParam(wxXmlNode
* node
, const wxString
& param
)
367 return (GetParamNode(node
, param
) != NULL
);
370 wxXmlNode
*wxRichTextXMLHandler::GetParamNode(wxXmlNode
* node
, const wxString
& param
)
372 wxCHECK_MSG(node
, NULL
, wxT("You can't access node data before it was initialized!"));
374 wxXmlNode
*n
= node
->GetChildren();
378 if (n
->GetType() == wxXML_ELEMENT_NODE
&& n
->GetName() == param
)
386 wxString
wxRichTextXMLHandler::GetNodeContent(wxXmlNode
*node
)
389 if (n
== NULL
) return wxEmptyString
;
390 n
= n
->GetChildren();
394 if (n
->GetType() == wxXML_TEXT_NODE
||
395 n
->GetType() == wxXML_CDATA_SECTION_NODE
)
396 return n
->GetContent();
399 return wxEmptyString
;
403 wxString
wxRichTextXMLHandler::GetParamValue(wxXmlNode
*node
, const wxString
& param
)
406 return GetNodeContent(node
);
408 return GetNodeContent(GetParamNode(node
, param
));
411 wxString
wxRichTextXMLHandler::GetText(wxXmlNode
*node
, const wxString
& param
, bool WXUNUSED(translate
))
413 wxXmlNode
*parNode
= GetParamNode(node
, param
);
416 wxString
str1(GetNodeContent(parNode
));
420 wxXmlNode
* wxRichTextXMLHandler::FindNode(wxXmlNode
* node
, const wxString
& name
)
422 if (node
->GetName() == name
&& name
== wxT("stylesheet"))
425 wxXmlNode
* child
= node
->GetChildren();
428 if (child
->GetName() == name
)
430 child
= child
->GetNext();
435 // For use with earlier versions of wxWidgets
436 #ifndef WXUNUSED_IN_UNICODE
438 #define WXUNUSED_IN_UNICODE(x) WXUNUSED(x)
440 #define WXUNUSED_IN_UNICODE(x) x
444 // write string to output
445 inline static void OutputString(wxOutputStream
& stream
, const wxString
& str
,
446 wxMBConv
*WXUNUSED_IN_UNICODE(convMem
), wxMBConv
*convFile
)
448 if (str
.empty()) return;
452 const wxWX2MBbuf
buf(str
.mb_str(*convFile
));
453 stream
.Write((const char*)buf
, strlen((const char*)buf
));
457 const wxWX2MBbuf
buf(str
.mb_str(wxConvUTF8
));
458 stream
.Write((const char*)buf
, strlen((const char*)buf
));
461 if ( convFile
== NULL
)
462 stream
.Write(str
.mb_str(), str
.Len());
465 wxString
str2(str
.wc_str(*convMem
), *convFile
);
466 stream
.Write(str2
.mb_str(), str2
.Len());
471 static void OutputIndentation(wxOutputStream
& stream
, int indent
)
473 wxString str
= wxT("\n");
474 for (int i
= 0; i
< indent
; i
++)
475 str
<< wxT(' ') << wxT(' ');
476 ::OutputString(stream
, str
, NULL
, NULL
);
479 // Same as above, but create entities first.
480 // Translates '<' to "<", '>' to ">" and '&' to "&"
481 static void OutputStringEnt(wxOutputStream
& stream
, const wxString
& str
,
482 wxMBConv
*convMem
= NULL
, wxMBConv
*convFile
= NULL
)
490 for (i
= 0; i
< len
; i
++)
494 // Original code excluded "&" but we _do_ want to convert
495 // the ampersand beginning & because otherwise when read in,
496 // the original "&" becomes "&".
498 if (c
== wxT('<') || c
== wxT('>') || c
== wxT('"') ||
499 (c
== wxT('&') /* && (str.Mid(i+1, 4) != wxT("amp;")) */ ))
501 OutputString(stream
, str
.Mid(last
, i
- last
), convMem
, convFile
);
505 OutputString(stream
, wxT("<"), NULL
, NULL
);
508 OutputString(stream
, wxT(">"), NULL
, NULL
);
511 OutputString(stream
, wxT("&"), NULL
, NULL
);
514 OutputString(stream
, wxT("""), NULL
, NULL
);
520 else if (wxUChar(c
) > 127)
522 OutputString(stream
, str
.Mid(last
, i
- last
), convMem
, convFile
);
524 wxString
s(wxT("&#"));
528 s
<< (int) wxUChar(c
);
531 OutputString(stream
, s
, NULL
, NULL
);
535 OutputString(stream
, str
.Mid(last
, i
- last
), convMem
, convFile
);
538 void wxRichTextXMLHandler::OutputString(wxOutputStream
& stream
, const wxString
& str
)
540 ::OutputString(stream
, str
, m_convMem
, m_convFile
);
543 void wxRichTextXMLHandler::OutputStringEnt(wxOutputStream
& stream
, const wxString
& str
)
545 ::OutputStringEnt(stream
, str
, m_convMem
, m_convFile
);
548 void wxRichTextXMLHandler::OutputIndentation(wxOutputStream
& stream
, int indent
)
550 wxString str
= wxT("\n");
551 for (int i
= 0; i
< indent
; i
++)
552 str
<< wxT(' ') << wxT(' ');
553 ::OutputString(stream
, str
, NULL
, NULL
);
556 wxString
wxRichTextXMLHandler::AttributeToXML(const wxString
& str
)
564 for (i
= 0; i
< len
; i
++)
568 // Original code excluded "&" but we _do_ want to convert
569 // the ampersand beginning & because otherwise when read in,
570 // the original "&" becomes "&".
572 if (c
== wxT('<') || c
== wxT('>') || c
== wxT('"') ||
573 (c
== wxT('&') /* && (str.Mid(i+1, 4) != wxT("amp;")) */ ))
575 str1
+= str
.Mid(last
, i
- last
);
585 str1
+= wxT("&");
588 str1
+= wxT(""");
594 else if (wxUChar(c
) > 127)
596 str1
+= str
.Mid(last
, i
- last
);
598 wxString
s(wxT("&#"));
602 s
<< (int) wxUChar(c
);
609 str1
+= str
.Mid(last
, i
- last
);
613 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
615 static inline void AddAttribute(wxString
& str
, const wxString
& name
, const int& v
)
617 str
<< wxT(" ") << name
<< wxT("=\"") << wxString::Format(wxT("%d"), v
) << wxT("\"");
620 static inline void AddAttribute(wxString
& str
, const wxString
& name
, const long& v
)
622 str
<< wxT(" ") << name
<< wxT("=\"") << wxString::Format(wxT("%ld"), v
) << wxT("\"");
625 static inline void AddAttribute(wxString
& str
, const wxString
& name
, const double& v
)
627 str
<< wxT(" ") << name
<< wxT("=\"") << wxString::Format(wxT("%.2f"), (float) v
) << wxT("\"");
630 static inline void AddAttribute(wxString
& str
, const wxString
& name
, const wxChar
* s
)
632 str
<< wxT(" ") << name
<< wxT("=\"") << s
<< wxT("\"");
635 static inline void AddAttribute(wxString
& str
, const wxString
& name
, const wxString
& s
)
637 str
<< wxT(" ") << name
<< wxT("=\"") << s
<< wxT("\"");
640 static inline void AddAttribute(wxString
& str
, const wxString
& name
, const wxColour
& col
)
642 str
<< wxT(" ") << name
<< wxT("=\"") << wxT("#") << ColourToHexString(col
) << wxT("\"");
645 static inline void AddAttribute(wxString
& str
, const wxString
& name
, const wxTextAttrDimension
& dim
)
649 wxString value
= MakeString(dim
.GetValue()) + wxT(",") + MakeString((int) dim
.GetFlags());
650 str
<< wxT(" ") << name
<< wxT("=\"");
656 static inline void AddAttribute(wxString
& str
, const wxString
& rootName
, const wxTextAttrDimensions
& dims
)
658 if (dims
.GetLeft().IsValid())
659 AddAttribute(str
, rootName
+ wxString(wxT("-left")), dims
.GetLeft());
660 if (dims
.GetRight().IsValid())
661 AddAttribute(str
, rootName
+ wxString(wxT("-right")), dims
.GetRight());
662 if (dims
.GetTop().IsValid())
663 AddAttribute(str
, rootName
+ wxString(wxT("-top")), dims
.GetTop());
664 if (dims
.GetBottom().IsValid())
665 AddAttribute(str
, rootName
+ wxString(wxT("-bottom")), dims
.GetBottom());
668 static inline void AddAttribute(wxString
& str
, const wxString
& rootName
, const wxTextAttrBorder
& border
)
670 if (border
.HasStyle())
671 AddAttribute(str
, rootName
+ wxString(wxT("-style")), border
.GetStyle());
672 if (border
.HasColour())
673 AddAttribute(str
, rootName
+ wxString(wxT("-color")), border
.GetColour());
674 if (border
.HasWidth())
675 AddAttribute(str
, rootName
+ wxString(wxT("-width")), border
.GetWidth());
678 static inline void AddAttribute(wxString
& str
, const wxString
& rootName
, const wxTextAttrBorders
& borders
)
680 AddAttribute(str
, rootName
+ wxString(wxT("-left")), borders
.GetLeft());
681 AddAttribute(str
, rootName
+ wxString(wxT("-right")), borders
.GetRight());
682 AddAttribute(str
, rootName
+ wxString(wxT("-top")), borders
.GetTop());
683 AddAttribute(str
, rootName
+ wxString(wxT("-bottom")), borders
.GetBottom());
687 // wxRICHTEXT_HAVE_DIRECT_OUTPUT
689 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
691 static inline void AddAttribute(wxXmlNode
* node
, const wxString
& name
, const int& v
)
693 node
->AddAttribute(name
, MakeString(v
));
696 static inline void AddAttribute(wxXmlNode
* node
, const wxString
& name
, const long& v
)
698 node
->AddAttribute(name
, MakeString(v
));
701 static inline void AddAttribute(wxXmlNode
* node
, const wxString
& name
, const double& v
)
703 node
->AddAttribute(name
, MakeString(v
));
706 static inline void AddAttribute(wxXmlNode
* node
, const wxString
& name
, const wxString
& s
)
708 node
->AddAttribute(name
, s
);
711 static inline void AddAttribute(wxXmlNode
* node
, const wxString
& name
, const wxColour
& col
)
713 node
->AddAttribute(name
, MakeString(col
));
716 static inline void AddAttribute(wxXmlNode
* node
, const wxString
& name
, const wxTextAttrDimension
& dim
)
720 wxString value
= MakeString(dim
.GetValue()) + wxT(",") + MakeString(dim
.GetFlags());
721 AddAttribute(node
, name
, value
);
725 static inline void AddAttribute(wxXmlNode
* node
, const wxString
& rootName
, const wxTextAttrDimensions
& dims
)
727 if (dims
.GetLeft().IsValid())
728 AddAttribute(node
, rootName
+ wxString(wxT("-left")), dims
.GetLeft());
729 if (dims
.GetRight().IsValid())
730 AddAttribute(node
, rootName
+ wxString(wxT("-right")), dims
.GetRight());
731 if (dims
.GetTop().IsValid())
732 AddAttribute(node
, rootName
+ wxString(wxT("-top")), dims
.GetTop());
733 if (dims
.GetBottom().IsValid())
734 AddAttribute(node
, rootName
+ wxString(wxT("-bottom")), dims
.GetBottom());
737 static inline void AddAttribute(wxXmlNode
* node
, const wxString
& rootName
, const wxTextAttrBorder
& border
)
739 if (border
.HasStyle())
740 AddAttribute(node
, rootName
+ wxString(wxT("-style")), border
.GetStyle());
741 if (border
.HasColour())
742 AddAttribute(node
, rootName
+ wxString(wxT("-color")), border
.GetColour());
743 if (border
.HasWidth())
744 AddAttribute(node
, rootName
+ wxString(wxT("-width")), border
.GetWidth());
747 static inline void AddAttribute(wxXmlNode
* node
, const wxString
& rootName
, const wxTextAttrBorders
& borders
)
749 AddAttribute(node
, rootName
+ wxString(wxT("-left")), borders
.GetLeft());
750 AddAttribute(node
, rootName
+ wxString(wxT("-right")), borders
.GetRight());
751 AddAttribute(node
, rootName
+ wxString(wxT("-top")), borders
.GetTop());
752 AddAttribute(node
, rootName
+ wxString(wxT("-bottom")), borders
.GetBottom());
755 // wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
757 bool wxRichTextXMLHandler::DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
)
762 wxString
version(wxT("1.0") ) ;
764 bool deleteConvFile
= false;
765 wxString fileEncoding
;
766 //wxMBConv* convFile = NULL;
769 fileEncoding
= wxT("UTF-8");
770 m_convFile
= & wxConvUTF8
;
772 fileEncoding
= wxT("ISO-8859-1");
773 m_convFile
= & wxConvISO8859_1
;
776 // If SetEncoding has been called, change the output encoding.
777 if (!m_encoding
.empty() && m_encoding
.Lower() != fileEncoding
.Lower())
779 if (m_encoding
== wxT("<System>"))
782 fileEncoding
= wxLocale::GetSystemEncodingName();
783 // if !wxUSE_INTL, we fall back to UTF-8 or ISO-8859-1 below
788 fileEncoding
= m_encoding
;
791 // GetSystemEncodingName may not have returned a name
792 if (fileEncoding
.empty())
794 fileEncoding
= wxT("UTF-8");
796 fileEncoding
= wxT("ISO-8859-1");
798 m_convFile
= new wxCSConv(fileEncoding
);
799 deleteConvFile
= true;
802 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT && wxRICHTEXT_USE_XMLDOCUMENT_OUTPUT
803 #if wxRICHTEXT_USE_OUTPUT_TIMINGS
804 wxStopWatch stopwatch
;
806 wxXmlDocument
* doc
= new wxXmlDocument
;
807 doc
->SetFileEncoding(fileEncoding
);
809 wxXmlNode
* rootNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, wxT("richtext"));
810 doc
->SetRoot(rootNode
);
811 rootNode
->AddAttribute(wxT("version"), wxT("1.0.0.0"));
812 rootNode
->AddAttribute(wxT("xmlns"), wxT("http://www.wxwidgets.org"));
814 if (buffer
->GetStyleSheet() && (GetFlags() & wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET
))
816 wxXmlNode
* styleSheetNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, wxT("stylesheet"));
817 rootNode
->AddChild(styleSheetNode
);
819 wxString nameAndDescr
;
821 if (!buffer
->GetStyleSheet()->GetName().empty())
822 styleSheetNode
->AddAttribute(wxT("name"), buffer
->GetStyleSheet()->GetName());
824 if (!buffer
->GetStyleSheet()->GetDescription().empty())
825 styleSheetNode
->AddAttribute(wxT("description"), buffer
->GetStyleSheet()->GetDescription());
828 for (i
= 0; i
< (int) buffer
->GetStyleSheet()->GetCharacterStyleCount(); i
++)
830 wxRichTextCharacterStyleDefinition
* def
= buffer
->GetStyleSheet()->GetCharacterStyle(i
);
831 ExportStyleDefinition(styleSheetNode
, def
);
834 for (i
= 0; i
< (int) buffer
->GetStyleSheet()->GetParagraphStyleCount(); i
++)
836 wxRichTextParagraphStyleDefinition
* def
= buffer
->GetStyleSheet()->GetParagraphStyle(i
);
837 ExportStyleDefinition(styleSheetNode
, def
);
840 for (i
= 0; i
< (int) buffer
->GetStyleSheet()->GetListStyleCount(); i
++)
842 wxRichTextListStyleDefinition
* def
= buffer
->GetStyleSheet()->GetListStyle(i
);
843 ExportStyleDefinition(styleSheetNode
, def
);
846 for (i
= 0; i
< (int) buffer
->GetStyleSheet()->GetBoxStyleCount(); i
++)
848 wxRichTextBoxStyleDefinition
* def
= buffer
->GetStyleSheet()->GetBoxStyle(i
);
849 ExportStyleDefinition(styleSheetNode
, def
);
852 WriteProperties(styleSheetNode
, buffer
->GetStyleSheet()->GetProperties());
854 bool success
= ExportXML(rootNode
, *buffer
);
855 #if wxRICHTEXT_USE_OUTPUT_TIMINGS
856 long t
= stopwatch
.Time();
857 wxLogDebug(wxT("Creating the document took %ldms"), t
);
858 wxMessageBox(wxString::Format(wxT("Creating the document took %ldms"), t
));
862 #if wxRICHTEXT_USE_OUTPUT_TIMINGS
865 success
= doc
->Save(stream
);
866 #if wxRICHTEXT_USE_OUTPUT_TIMINGS
868 wxLogDebug(wxT("Save() took %ldms"), t2
);
869 wxMessageBox(wxString::Format(wxT("Save() took %ldms"), t2
));
876 // !(wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT && wxRICHTEXT_USE_XMLDOCUMENT_OUTPUT)
879 m_convMem
= wxConvCurrent
;
885 s
.Printf(wxT("<?xml version=\"%s\" encoding=\"%s\"?>\n"),
886 version
, fileEncoding
);
887 OutputString(stream
, s
);
888 OutputString(stream
, wxT("<richtext version=\"1.0.0.0\" xmlns=\"http://www.wxwidgets.org\">"));
892 if (buffer
->GetStyleSheet() && (GetFlags() & wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET
))
894 OutputIndentation(stream
, level
);
895 wxString nameAndDescr
;
896 if (!buffer
->GetStyleSheet()->GetName().empty())
897 nameAndDescr
<< wxT(" name=\"") << buffer
->GetStyleSheet()->GetName() << wxT("\"");
898 if (!buffer
->GetStyleSheet()->GetDescription().empty())
899 nameAndDescr
<< wxT(" description=\"") << buffer
->GetStyleSheet()->GetDescription() << wxT("\"");
900 OutputString(stream
, wxString(wxT("<stylesheet")) + nameAndDescr
+ wxT(">"));
904 for (i
= 0; i
< (int) buffer
->GetStyleSheet()->GetCharacterStyleCount(); i
++)
906 wxRichTextCharacterStyleDefinition
* def
= buffer
->GetStyleSheet()->GetCharacterStyle(i
);
907 ExportStyleDefinition(stream
, def
, level
+ 1);
910 for (i
= 0; i
< (int) buffer
->GetStyleSheet()->GetParagraphStyleCount(); i
++)
912 wxRichTextParagraphStyleDefinition
* def
= buffer
->GetStyleSheet()->GetParagraphStyle(i
);
913 ExportStyleDefinition(stream
, def
, level
+ 1);
916 for (i
= 0; i
< (int) buffer
->GetStyleSheet()->GetListStyleCount(); i
++)
918 wxRichTextListStyleDefinition
* def
= buffer
->GetStyleSheet()->GetListStyle(i
);
919 ExportStyleDefinition(stream
, def
, level
+ 1);
922 for (i
= 0; i
< (int) buffer
->GetStyleSheet()->GetBoxStyleCount(); i
++)
924 wxRichTextBoxStyleDefinition
* def
= buffer
->GetStyleSheet()->GetBoxStyle(i
);
925 ExportStyleDefinition(stream
, def
, level
+ 1);
928 WriteProperties(stream
, buffer
->GetStyleSheet()->GetProperties(), level
);
930 OutputIndentation(stream
, level
);
931 OutputString(stream
, wxT("</stylesheet>"));
935 bool success
= ExportXML(stream
, *buffer
, level
);
937 OutputString(stream
, wxT("\n</richtext>"));
938 OutputString(stream
, wxT("\n"));
949 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
951 /// Recursively export an object
952 bool wxRichTextXMLHandler::ExportXML(wxOutputStream
& stream
, wxRichTextObject
& obj
, int indent
)
954 obj
.ExportXML(stream
, indent
, this);
959 bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream
& stream
, wxRichTextStyleDefinition
* def
, int level
)
961 wxRichTextCharacterStyleDefinition
* charDef
= wxDynamicCast(def
, wxRichTextCharacterStyleDefinition
);
962 wxRichTextParagraphStyleDefinition
* paraDef
= wxDynamicCast(def
, wxRichTextParagraphStyleDefinition
);
963 wxRichTextListStyleDefinition
* listDef
= wxDynamicCast(def
, wxRichTextListStyleDefinition
);
964 wxRichTextBoxStyleDefinition
* boxDef
= wxDynamicCast(def
, wxRichTextBoxStyleDefinition
);
966 wxString name
= def
->GetName();
969 nameProp
= wxT(" name=\"") + AttributeToXML(name
) + wxT("\"");
971 wxString baseStyle
= def
->GetBaseStyle();
972 wxString baseStyleProp
;
973 if (!baseStyle
.empty())
974 baseStyleProp
= wxT(" basestyle=\"") + AttributeToXML(baseStyle
) + wxT("\"");
976 wxString descr
= def
->GetDescription();
979 descrProp
= wxT(" description=\"") + AttributeToXML(descr
) + wxT("\"");
983 OutputIndentation(stream
, level
);
984 OutputString(stream
, wxT("<characterstyle") + nameProp
+ baseStyleProp
+ descrProp
+ wxT(">"));
988 wxString style
= AddAttributes(def
->GetStyle(), false);
990 OutputIndentation(stream
, level
);
991 OutputString(stream
, wxT("<style ") + style
+ wxT(">"));
993 OutputIndentation(stream
, level
);
994 OutputString(stream
, wxT("</style>"));
998 OutputIndentation(stream
, level
);
999 OutputString(stream
, wxT("</characterstyle>"));
1003 OutputIndentation(stream
, level
);
1005 if (!listDef
->GetNextStyle().empty())
1006 baseStyleProp
<< wxT(" nextstyle=\"") << AttributeToXML(listDef
->GetNextStyle()) << wxT("\"");
1008 OutputString(stream
, wxT("<liststyle") + nameProp
+ baseStyleProp
+ descrProp
+ wxT(">"));
1012 wxString style
= AddAttributes(def
->GetStyle(), true);
1014 OutputIndentation(stream
, level
);
1015 OutputString(stream
, wxT("<style ") + style
+ wxT(">"));
1017 OutputIndentation(stream
, level
);
1018 OutputString(stream
, wxT("</style>"));
1021 for (i
= 0; i
< 10; i
++)
1023 wxRichTextAttr
* levelAttr
= listDef
->GetLevelAttributes(i
);
1026 wxString style
= AddAttributes(def
->GetStyle(), true);
1027 wxString levelStr
= wxString::Format(wxT(" level=\"%d\" "), (i
+1));
1029 OutputIndentation(stream
, level
);
1030 OutputString(stream
, wxT("<style ") + levelStr
+ style
+ wxT(">"));
1032 OutputIndentation(stream
, level
);
1033 OutputString(stream
, wxT("</style>"));
1039 OutputIndentation(stream
, level
);
1040 OutputString(stream
, wxT("</liststyle>"));
1044 OutputIndentation(stream
, level
);
1046 if (!paraDef
->GetNextStyle().empty())
1047 baseStyleProp
<< wxT(" nextstyle=\"") << AttributeToXML(paraDef
->GetNextStyle()) << wxT("\"");
1049 OutputString(stream
, wxT("<paragraphstyle") + nameProp
+ baseStyleProp
+ descrProp
+ wxT(">"));
1053 wxString style
= AddAttributes(def
->GetStyle(), true);
1055 OutputIndentation(stream
, level
);
1056 OutputString(stream
, wxT("<style ") + style
+ wxT(">"));
1058 OutputIndentation(stream
, level
);
1059 OutputString(stream
, wxT("</style>"));
1063 OutputIndentation(stream
, level
);
1064 OutputString(stream
, wxT("</paragraphstyle>"));
1068 OutputIndentation(stream
, level
);
1070 OutputString(stream
, wxT("<boxstyle") + nameProp
+ baseStyleProp
+ descrProp
+ wxT(">"));
1074 wxString style
= AddAttributes(def
->GetStyle(), true);
1076 OutputIndentation(stream
, level
);
1077 OutputString(stream
, wxT("<style ") + style
+ wxT(">"));
1079 OutputIndentation(stream
, level
);
1080 OutputString(stream
, wxT("</style>"));
1084 OutputIndentation(stream
, level
);
1085 OutputString(stream
, wxT("</boxstyle>"));
1092 /// Create a string containing style attributes
1093 wxString
wxRichTextXMLHandler::AddAttributes(const wxRichTextAttr
& attr
, bool isPara
)
1096 if (attr
.HasTextColour() && attr
.GetTextColour().IsOk())
1097 AddAttribute(str
, wxT("textcolor"), attr
.GetTextColour());
1099 if (attr
.HasBackgroundColour() && attr
.GetBackgroundColour().IsOk())
1100 AddAttribute(str
, wxT("bgcolor"), attr
.GetBackgroundColour());
1102 if (attr
.HasFontSize())
1103 AddAttribute(str
, wxT("fontsize"), attr
.GetFontSize());
1105 if (attr
.HasFontFamily())
1106 AddAttribute(str
, wxT("fontfamily"), attr
.GetFontFamily());
1108 if (attr
.HasFontItalic())
1109 AddAttribute(str
, wxT("fontstyle"), attr
.GetFontStyle());
1111 if (attr
.HasFontWeight())
1112 AddAttribute(str
, wxT("fontweight"), attr
.GetFontWeight());
1114 if (attr
.HasFontUnderlined())
1115 AddAttribute(str
, wxT("fontunderlined"), (int) attr
.GetFontUnderlined());
1117 if (attr
.HasFontFaceName())
1118 AddAttribute(str
, wxT("fontface"), AttributeToXML(attr
.GetFontFaceName()));
1120 if (attr
.HasTextEffects())
1122 AddAttribute(str
, wxT("texteffects"), attr
.GetTextEffects());
1123 AddAttribute(str
, wxT("texteffectflags"), attr
.GetTextEffectFlags());
1126 if (!attr
.GetCharacterStyleName().empty())
1127 AddAttribute(str
, wxT("characterstyle"), AttributeToXML(attr
.GetCharacterStyleName()));
1130 AddAttribute(str
, wxT("url"), AttributeToXML(attr
.GetURL()));
1134 if (attr
.HasAlignment())
1135 AddAttribute(str
, wxT("alignment"), (int) attr
.GetAlignment());
1137 if (attr
.HasLeftIndent())
1139 AddAttribute(str
, wxT("leftindent"), (int) attr
.GetLeftIndent());
1140 AddAttribute(str
, wxT("leftsubindent"), (int) attr
.GetLeftSubIndent());
1143 if (attr
.HasRightIndent())
1144 AddAttribute(str
, wxT("rightindent"), (int) attr
.GetRightIndent());
1146 if (attr
.HasParagraphSpacingAfter())
1147 AddAttribute(str
, wxT("parspacingafter"), (int) attr
.GetParagraphSpacingAfter());
1149 if (attr
.HasParagraphSpacingBefore())
1150 AddAttribute(str
, wxT("parspacingbefore"), (int) attr
.GetParagraphSpacingBefore());
1152 if (attr
.HasLineSpacing())
1153 AddAttribute(str
, wxT("linespacing"), (int) attr
.GetLineSpacing());
1155 if (attr
.HasBulletStyle())
1156 AddAttribute(str
, wxT("bulletstyle"), (int) attr
.GetBulletStyle());
1158 if (attr
.HasBulletNumber())
1159 AddAttribute(str
, wxT("bulletnumber"), (int) attr
.GetBulletNumber());
1161 if (attr
.HasBulletText())
1163 // If using a bullet symbol, convert to integer in case it's a non-XML-friendly character.
1164 // Otherwise, assume it's XML-friendly text such as outline numbering, e.g. 1.2.3.1
1165 if (!attr
.GetBulletText().empty() && (attr
.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL
))
1166 AddAttribute(str
, wxT("bulletsymbol"), (int) (attr
.GetBulletText()[0]));
1168 AddAttribute(str
, wxT("bullettext"), AttributeToXML(attr
.GetBulletText()));
1170 AddAttribute(str
, wxT("bulletfont"), attr
.GetBulletFont());
1173 if (attr
.HasBulletName())
1174 AddAttribute(str
, wxT("bulletname"), AttributeToXML(attr
.GetBulletName()));
1176 if (!attr
.GetParagraphStyleName().empty())
1177 AddAttribute(str
, wxT("parstyle"), AttributeToXML(attr
.GetParagraphStyleName()));
1179 if (!attr
.GetListStyleName().empty())
1180 AddAttribute(str
, wxT("liststyle"), AttributeToXML(attr
.GetListStyleName()));
1182 if (!attr
.GetTextBoxAttr().GetBoxStyleName().empty())
1183 AddAttribute(str
, wxT("boxstyle"), AttributeToXML(attr
.GetTextBoxAttr().GetBoxStyleName()));
1189 for (i
= 0; i
< attr
.GetTabs().GetCount(); i
++)
1191 if (i
> 0) strTabs
<< wxT(",");
1192 strTabs
<< attr
.GetTabs()[i
];
1194 AddAttribute(str
, wxT("tabs"), strTabs
);
1197 if (attr
.HasPageBreak())
1199 AddAttribute(str
, wxT("pagebreak"), 1);
1202 if (attr
.HasOutlineLevel())
1203 AddAttribute(str
, wxT("outlinelevel"), (int) attr
.GetOutlineLevel());
1206 AddAttribute(str
, wxT("margin"), attr
.GetTextBoxAttr().GetMargins());
1207 AddAttribute(str
, wxT("padding"), attr
.GetTextBoxAttr().GetPadding());
1208 AddAttribute(str
, wxT("position"), attr
.GetTextBoxAttr().GetPosition());
1209 AddAttribute(str
, wxT("border"), attr
.GetTextBoxAttr().GetBorder());
1210 AddAttribute(str
, wxT("outline"), attr
.GetTextBoxAttr().GetOutline());
1211 AddAttribute(str
, wxT("width"), attr
.GetTextBoxAttr().GetWidth());
1212 AddAttribute(str
, wxT("height"), attr
.GetTextBoxAttr().GetHeight());
1213 AddAttribute(str
, wxT("minwidth"), attr
.GetTextBoxAttr().GetMinSize().GetWidth());
1214 AddAttribute(str
, wxT("minheight"), attr
.GetTextBoxAttr().GetMinSize().GetHeight());
1215 AddAttribute(str
, wxT("maxwidth"), attr
.GetTextBoxAttr().GetMaxSize().GetWidth());
1216 AddAttribute(str
, wxT("maxheight"), attr
.GetTextBoxAttr().GetMaxSize().GetHeight());
1218 if (attr
.GetTextBoxAttr().HasVerticalAlignment())
1221 if (attr
.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_TOP
)
1223 else if (attr
.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_CENTRE
)
1224 value
= wxT("centre");
1225 else if (attr
.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_BOTTOM
)
1226 value
= wxT("bottom");
1228 value
= wxT("none");
1229 AddAttribute(str
, wxT("verticalalignment"), value
);
1232 if (attr
.GetTextBoxAttr().HasFloatMode())
1235 if (attr
.GetTextBoxAttr().GetFloatMode() == wxTEXT_BOX_ATTR_FLOAT_LEFT
)
1236 value
= wxT("left");
1237 else if (attr
.GetTextBoxAttr().GetFloatMode() == wxTEXT_BOX_ATTR_FLOAT_RIGHT
)
1238 value
= wxT("right");
1240 value
= wxT("none");
1241 AddAttribute(str
, wxT("float"), value
);
1244 if (attr
.GetTextBoxAttr().HasClearMode())
1247 if (attr
.GetTextBoxAttr().GetClearMode() == wxTEXT_BOX_ATTR_CLEAR_LEFT
)
1248 value
= wxT("left");
1249 else if (attr
.GetTextBoxAttr().GetClearMode() == wxTEXT_BOX_ATTR_CLEAR_RIGHT
)
1250 value
= wxT("right");
1251 else if (attr
.GetTextBoxAttr().GetClearMode() == wxTEXT_BOX_ATTR_CLEAR_BOTH
)
1252 value
= wxT("both");
1254 value
= wxT("none");
1255 AddAttribute(str
, wxT("clear"), value
);
1258 if (attr
.GetTextBoxAttr().HasCollapseBorders())
1259 AddAttribute(str
, wxT("collapse-borders"), (int) attr
.GetTextBoxAttr().GetCollapseBorders());
1264 // Make a string from the given property. This can be overridden for custom variants.
1265 wxString
wxRichTextXMLHandler::MakeStringFromProperty(const wxVariant
& var
)
1267 return var
.MakeString();
1270 // Create a proprty from the string read from the XML file.
1271 wxVariant
wxRichTextXMLHandler::MakePropertyFromString(const wxString
& name
, const wxString
& value
, const wxString
& WXUNUSED(type
))
1273 wxVariant
var(value
, name
);
1274 // TODO: use type to create using common types
1278 // Write the properties
1279 bool wxRichTextXMLHandler::WriteProperties(wxOutputStream
& stream
, const wxRichTextProperties
& properties
, int level
)
1281 if (properties
.GetCount() > 0)
1285 OutputIndentation(stream
, level
);
1286 OutputString(stream
, wxT("<properties>"));
1291 for (i
= 0; i
< properties
.GetCount(); i
++)
1293 const wxVariant
& var
= properties
[i
];
1296 const wxString
& name
= var
.GetName();
1297 wxString value
= MakeStringFromProperty(var
);
1299 OutputIndentation(stream
, level
);
1300 OutputString(stream
, wxT("<property name=\"") + name
+
1301 wxT("\" type=\"") + var
.GetType() + wxT("\" value=\""));
1302 OutputStringEnt(stream
, value
);
1303 OutputString(stream
, wxT("\"/>"));
1309 OutputIndentation(stream
, level
);
1310 OutputString(stream
, wxT("</properties>"));
1320 // wxRICHTEXT_HAVE_DIRECT_OUTPUT
1322 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
1323 bool wxRichTextXMLHandler::ExportXML(wxXmlNode
* parent
, wxRichTextObject
& obj
)
1325 obj
.ExportXML(parent
, this);
1330 bool wxRichTextXMLHandler::ExportStyleDefinition(wxXmlNode
* parent
, wxRichTextStyleDefinition
* def
)
1332 wxRichTextCharacterStyleDefinition
* charDef
= wxDynamicCast(def
, wxRichTextCharacterStyleDefinition
);
1333 wxRichTextParagraphStyleDefinition
* paraDef
= wxDynamicCast(def
, wxRichTextParagraphStyleDefinition
);
1334 wxRichTextBoxStyleDefinition
* boxDef
= wxDynamicCast(def
, wxRichTextBoxStyleDefinition
);
1335 wxRichTextListStyleDefinition
* listDef
= wxDynamicCast(def
, wxRichTextListStyleDefinition
);
1337 wxString baseStyle
= def
->GetBaseStyle();
1338 wxString descr
= def
->GetDescription();
1340 wxXmlNode
* defNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, wxEmptyString
);
1341 parent
->AddChild(defNode
);
1342 if (!baseStyle
.empty())
1343 defNode
->AddAttribute(wxT("basestyle"), baseStyle
);
1345 defNode
->AddAttribute(wxT("description"), descr
);
1347 wxXmlNode
* styleNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, wxT("style"));
1348 defNode
->AddChild(styleNode
);
1352 defNode
->SetName(wxT("characterstyle"));
1353 AddAttributes(styleNode
, def
->GetStyle(), false);
1357 defNode
->SetName(wxT("liststyle"));
1359 if (!listDef
->GetNextStyle().empty())
1360 defNode
->AddAttribute(wxT("nextstyle"), listDef
->GetNextStyle());
1362 AddAttributes(styleNode
, def
->GetStyle(), true);
1365 for (i
= 0; i
< 10; i
++)
1367 wxRichTextAttr
* levelAttr
= listDef
->GetLevelAttributes(i
);
1370 wxXmlNode
* levelNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, wxT("style"));
1371 defNode
->AddChild(levelNode
);
1372 levelNode
->AddAttribute(wxT("level"), MakeString(i
+1));
1373 AddAttributes(levelNode
, * levelAttr
, true);
1379 defNode
->SetName(wxT("boxstyle"));
1381 AddAttributes(styleNode
, def
->GetStyle(), true);
1385 defNode
->SetName(wxT("paragraphstyle"));
1387 if (!paraDef
->GetNextStyle().empty())
1388 defNode
->AddAttribute(wxT("nextstyle"), paraDef
->GetNextStyle());
1390 AddAttributes(styleNode
, def
->GetStyle(), true);
1393 WriteProperties(defNode
, def
->GetProperties());
1398 bool wxRichTextXMLHandler::AddAttributes(wxXmlNode
* node
, wxRichTextAttr
& attr
, bool isPara
)
1400 if (attr
.HasTextColour() && attr
.GetTextColour().IsOk())
1401 node
->AddAttribute(wxT("textcolor"), MakeString(attr
.GetTextColour()));
1402 if (attr
.HasBackgroundColour() && attr
.GetBackgroundColour().IsOk())
1403 node
->AddAttribute(wxT("bgcolor"), MakeString(attr
.GetBackgroundColour()));
1405 if (attr
.HasFontSize())
1406 node
->AddAttribute(wxT("fontsize"), MakeString(attr
.GetFontSize()));
1407 if (attr
.HasFontFamily())
1408 node
->AddAttribute(wxT("fontfamily"), MakeString(attr
.GetFontFamily()));
1409 if (attr
.HasFontItalic())
1410 node
->AddAttribute(wxT("fontstyle"), MakeString(attr
.GetFontStyle()));
1411 if (attr
.HasFontWeight())
1412 node
->AddAttribute(wxT("fontweight"), MakeString(attr
.GetFontWeight()));
1413 if (attr
.HasFontUnderlined())
1414 node
->AddAttribute(wxT("fontunderlined"), MakeString((int) attr
.GetFontUnderlined()));
1415 if (attr
.HasFontFaceName())
1416 node
->AddAttribute(wxT("fontface"), attr
.GetFontFaceName());
1418 if (attr
.HasTextEffects())
1420 node
->AddAttribute(wxT("texteffects"), MakeString(attr
.GetTextEffects()));
1421 node
->AddAttribute(wxT("texteffectflags"), MakeString(attr
.GetTextEffectFlags()));
1423 if (attr
.HasCharacterStyleName() && !attr
.GetCharacterStyleName().empty())
1424 node
->AddAttribute(wxT("characterstyle"), attr
.GetCharacterStyleName());
1427 node
->AddAttribute(wxT("url"), attr
.GetURL()); // TODO: do we need to wrap this in AttributeToXML?
1431 if (attr
.HasAlignment())
1432 node
->AddAttribute(wxT("alignment"), MakeString((int) attr
.GetAlignment()));
1434 if (attr
.HasLeftIndent())
1436 node
->AddAttribute(wxT("leftindent"), MakeString((int) attr
.GetLeftIndent()));
1437 node
->AddAttribute(wxT("leftsubindent"), MakeString((int) attr
.GetLeftSubIndent()));
1440 if (attr
.HasRightIndent())
1441 node
->AddAttribute(wxT("rightindent"), MakeString((int) attr
.GetRightIndent()));
1443 if (attr
.HasParagraphSpacingAfter())
1444 node
->AddAttribute(wxT("parspacingafter"), MakeString((int) attr
.GetParagraphSpacingAfter()));
1446 if (attr
.HasParagraphSpacingBefore())
1447 node
->AddAttribute(wxT("parspacingbefore"), MakeString((int) attr
.GetParagraphSpacingBefore()));
1449 if (attr
.HasLineSpacing())
1450 node
->AddAttribute(wxT("linespacing"), MakeString((int) attr
.GetLineSpacing()));
1452 if (attr
.HasBulletStyle())
1453 node
->AddAttribute(wxT("bulletstyle"), MakeString((int) attr
.GetBulletStyle()));
1455 if (attr
.HasBulletNumber())
1456 node
->AddAttribute(wxT("bulletnumber"), MakeString((int) attr
.GetBulletNumber()));
1458 if (attr
.HasBulletText())
1460 // If using a bullet symbol, convert to integer in case it's a non-XML-friendly character.
1461 // Otherwise, assume it's XML-friendly text such as outline numbering, e.g. 1.2.3.1
1462 if (!attr
.GetBulletText().empty() && (attr
.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL
))
1463 node
->AddAttribute(wxT("bulletsymbol"), MakeString((int) (attr
.GetBulletText()[0])));
1465 node
->AddAttribute(wxT("bullettext"), attr
.GetBulletText());
1467 if (!attr
.GetBulletFont().empty())
1468 node
->AddAttribute(wxT("bulletfont"), attr
.GetBulletFont());
1471 if (attr
.HasBulletName())
1472 node
->AddAttribute(wxT("bulletname"), attr
.GetBulletName());
1474 if (!attr
.GetParagraphStyleName().empty())
1475 node
->AddAttribute(wxT("parstyle"), attr
.GetParagraphStyleName());
1477 if (!attr
.GetListStyleName().empty())
1478 node
->AddAttribute(wxT("liststyle"), attr
.GetListStyleName());
1480 if (!attr
.GetTextBoxAttr().GetBoxStyleName().empty())
1481 node
->AddAttribute(wxT("boxstyle"), attr
.GetTextBoxAttr().GetBoxStyleName());
1487 for (i
= 0; i
< attr
.GetTabs().GetCount(); i
++)
1491 tabs
<< attr
.GetTabs()[i
];
1493 node
->AddAttribute(wxT("tabs"), tabs
);
1496 if (attr
.HasPageBreak())
1497 node
->AddAttribute(wxT("pagebreak"), wxT("1"));
1499 if (attr
.HasOutlineLevel())
1500 node
->AddAttribute(wxT("outlinelevel"), MakeString((int) attr
.GetOutlineLevel()));
1503 AddAttribute(node
, wxT("margin"), attr
.GetTextBoxAttr().GetMargins());
1504 AddAttribute(node
, wxT("padding"), attr
.GetTextBoxAttr().GetPadding());
1505 AddAttribute(node
, wxT("position"), attr
.GetTextBoxAttr().GetPosition());
1506 AddAttribute(node
, wxT("border"), attr
.GetTextBoxAttr().GetBorder());
1507 AddAttribute(node
, wxT("outline"), attr
.GetTextBoxAttr().GetOutline());
1508 AddAttribute(node
, wxT("width"), attr
.GetTextBoxAttr().GetWidth());
1509 AddAttribute(node
, wxT("height"), attr
.GetTextBoxAttr().GetHeight());
1510 AddAttribute(node
, wxT("minwidth"), attr
.GetTextBoxAttr().GetMinSize().GetWidth());
1511 AddAttribute(node
, wxT("minheight"), attr
.GetTextBoxAttr().GetMinSize().GetHeight());
1512 AddAttribute(node
, wxT("maxwidth"), attr
.GetTextBoxAttr().GetMaxSize().GetWidth());
1513 AddAttribute(node
, wxT("maxheight"), attr
.GetTextBoxAttr().GetMaxSize().GetHeight());
1515 if (attr
.GetTextBoxAttr().HasVerticalAlignment())
1518 if (attr
.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_TOP
)
1520 else if (attr
.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_CENTRE
)
1521 value
= wxT("centre");
1522 else if (attr
.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_BOTTOM
)
1523 value
= wxT("bottom");
1525 value
= wxT("none");
1526 AddAttribute(node
, wxT("verticalalignment"), value
);
1529 if (attr
.GetTextBoxAttr().HasFloatMode())
1532 if (attr
.GetTextBoxAttr().GetFloatMode() == wxTEXT_BOX_ATTR_FLOAT_LEFT
)
1533 value
= wxT("left");
1534 else if (attr
.GetTextBoxAttr().GetFloatMode() == wxTEXT_BOX_ATTR_FLOAT_RIGHT
)
1535 value
= wxT("right");
1537 value
= wxT("none");
1538 AddAttribute(node
, wxT("float"), value
);
1541 if (attr
.GetTextBoxAttr().HasClearMode())
1544 if (attr
.GetTextBoxAttr().GetClearMode() == wxTEXT_BOX_ATTR_CLEAR_LEFT
)
1545 value
= wxT("left");
1546 else if (attr
.GetTextBoxAttr().GetClearMode() == wxTEXT_BOX_ATTR_CLEAR_RIGHT
)
1547 value
= wxT("right");
1548 else if (attr
.GetTextBoxAttr().GetClearMode() == wxTEXT_BOX_ATTR_CLEAR_BOTH
)
1549 value
= wxT("both");
1551 value
= wxT("none");
1552 AddAttribute(node
, wxT("clear"), value
);
1555 if (attr
.GetTextBoxAttr().HasCollapseBorders())
1556 AddAttribute(node
, wxT("collapse-borders"), (int) attr
.GetTextBoxAttr().GetCollapseBorders());
1561 bool wxRichTextXMLHandler::WriteProperties(wxXmlNode
* node
, const wxRichTextProperties
& properties
)
1563 if (properties
.GetCount() > 0)
1565 wxXmlNode
* propertiesNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, wxT("properties"));
1566 node
->AddChild(propertiesNode
);
1568 for (i
= 0; i
< properties
.GetCount(); i
++)
1570 const wxVariant
& var
= properties
[i
];
1573 wxXmlNode
* propertyNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, wxT("property"));
1574 propertiesNode
->AddChild(propertyNode
);
1576 const wxString
& name
= var
.GetName();
1577 wxString value
= MakeStringFromProperty(var
);
1579 AddAttribute(propertyNode
, wxT("name"), name
);
1580 AddAttribute(propertyNode
, wxT("type"), var
.GetType());
1581 AddAttribute(propertyNode
, wxT("value"), value
);
1589 // wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
1591 /// Replace face name with current name for platform.
1592 /// TODO: introduce a virtual function or settable table to
1593 /// do this comprehensively.
1594 bool wxRichTextFixFaceName(wxString
& facename
)
1596 if (facename
.empty())
1600 if (facename
== wxT("Times"))
1602 facename
= wxT("Times New Roman");
1605 else if (facename
== wxT("Helvetica"))
1607 facename
= wxT("Arial");
1610 else if (facename
== wxT("Courier"))
1612 facename
= wxT("Courier New");
1618 if (facename
== wxT("Times New Roman"))
1620 facename
= wxT("Times");
1623 else if (facename
== wxT("Arial"))
1625 facename
= wxT("Helvetica");
1628 else if (facename
== wxT("Courier New"))
1630 facename
= wxT("Courier");
1638 static inline long wxRichTextColourStringToLong(const wxString
& colStr
)
1640 if (!colStr
.IsEmpty())
1642 wxColour
col(colStr
);
1643 return col
.GetRGB();
1649 static inline wxTextAttrDimension
wxRichTextParseDimension(const wxString
& dimStr
)
1651 wxString valuePart
= dimStr
.BeforeFirst(wxT(','));
1653 if (dimStr
.Contains(wxT(",")))
1654 flagsPart
= dimStr
.AfterFirst(wxT(','));
1655 wxTextAttrDimension dim
;
1656 dim
.SetValue(wxAtoi(valuePart
));
1657 dim
.SetFlags(wxAtoi(flagsPart
));
1662 /// Import style parameters
1663 bool wxRichTextXMLHandler::ImportStyle(wxRichTextAttr
& attr
, wxXmlNode
* node
, bool isPara
)
1665 wxXmlAttribute
* xmlAttr
= node
->GetAttributes();
1669 const wxString
& name
= xmlAttr
->GetName();
1670 const wxString
& value
= xmlAttr
->GetValue();
1673 if (name
== wxT("fontface"))
1678 if (GetFlags() & wxRICHTEXT_HANDLER_CONVERT_FACENAMES
)
1679 wxRichTextFixFaceName(v
);
1680 attr
.SetFontFaceName(v
);
1683 else if (name
== wxT("fontfamily"))
1686 attr
.SetFontFamily((wxFontFamily
)wxAtoi(value
));
1688 else if (name
== wxT("fontstyle"))
1691 attr
.SetFontStyle((wxFontStyle
)wxAtoi(value
));
1693 else if (name
== wxT("fontsize"))
1696 attr
.SetFontSize(wxAtoi(value
));
1698 else if (name
== wxT("fontweight"))
1701 attr
.SetFontWeight((wxFontWeight
) wxAtoi(value
));
1703 else if (name
== wxT("fontunderlined"))
1706 attr
.SetFontUnderlined(wxAtoi(value
) != 0);
1708 else if (name
== wxT("textcolor"))
1712 if (value
[0] == wxT('#'))
1713 attr
.SetTextColour(HexStringToColour(value
.Mid(1)));
1715 attr
.SetTextColour(value
);
1718 else if (name
== wxT("bgcolor"))
1722 if (value
[0] == wxT('#'))
1723 attr
.SetBackgroundColour(HexStringToColour(value
.Mid(1)));
1725 attr
.SetBackgroundColour(value
);
1728 else if (name
== wxT("characterstyle"))
1731 attr
.SetCharacterStyleName(value
);
1733 else if (name
== wxT("texteffects"))
1736 attr
.SetTextEffects(wxAtoi(value
));
1738 else if (name
== wxT("texteffectflags"))
1741 attr
.SetTextEffectFlags(wxAtoi(value
));
1743 else if (name
== wxT("url"))
1750 if (name
== wxT("alignment"))
1753 attr
.SetAlignment((wxTextAttrAlignment
) wxAtoi(value
));
1755 else if (name
== wxT("leftindent"))
1758 attr
.SetLeftIndent(wxAtoi(value
), attr
.GetLeftSubIndent());
1760 else if (name
== wxT("leftsubindent"))
1763 attr
.SetLeftIndent(attr
.GetLeftIndent(), wxAtoi(value
));
1765 else if (name
== wxT("rightindent"))
1768 attr
.SetRightIndent(wxAtoi(value
));
1770 else if (name
== wxT("parspacingbefore"))
1773 attr
.SetParagraphSpacingBefore(wxAtoi(value
));
1775 else if (name
== wxT("parspacingafter"))
1778 attr
.SetParagraphSpacingAfter(wxAtoi(value
));
1780 else if (name
== wxT("linespacing"))
1783 attr
.SetLineSpacing(wxAtoi(value
));
1785 else if (name
== wxT("bulletstyle"))
1788 attr
.SetBulletStyle(wxAtoi(value
));
1790 else if (name
== wxT("bulletnumber"))
1793 attr
.SetBulletNumber(wxAtoi(value
));
1795 else if (name
== wxT("bulletsymbol"))
1799 wxChar ch
= wxAtoi(value
);
1802 attr
.SetBulletText(s
);
1805 else if (name
== wxT("bullettext"))
1809 attr
.SetBulletText(value
);
1812 else if (name
== wxT("bulletfont"))
1816 attr
.SetBulletFont(value
);
1819 else if (name
== wxT("bulletname"))
1823 attr
.SetBulletName(value
);
1826 else if (name
== wxT("parstyle"))
1830 attr
.SetParagraphStyleName(value
);
1833 else if (name
== wxT("liststyle"))
1837 attr
.SetListStyleName(value
);
1840 else if (name
== wxT("boxstyle"))
1844 attr
.GetTextBoxAttr().SetBoxStyleName(value
);
1847 else if (name
== wxT("tabs"))
1852 wxStringTokenizer
tkz(value
, wxT(","));
1853 while (tkz
.HasMoreTokens())
1855 wxString token
= tkz
.GetNextToken();
1856 tabs
.Add(wxAtoi(token
));
1861 else if (name
== wxT("pagebreak"))
1865 attr
.SetPageBreak(wxAtoi(value
) != 0);
1868 else if (name
== wxT("outlinelevel"))
1872 attr
.SetOutlineLevel(wxAtoi(value
));
1885 if (name
== wxT("width"))
1887 attr
.GetTextBoxAttr().GetWidth().SetValue(wxRichTextParseDimension(value
));
1889 else if (name
== wxT("height"))
1891 attr
.GetTextBoxAttr().GetHeight().SetValue(wxRichTextParseDimension(value
));
1893 else if (name
== wxT("minwidth"))
1895 attr
.GetTextBoxAttr().GetMinSize().GetWidth().SetValue(wxRichTextParseDimension(value
));
1897 else if (name
== wxT("minheight"))
1899 attr
.GetTextBoxAttr().GetMinSize().GetHeight().SetValue(wxRichTextParseDimension(value
));
1901 else if (name
== wxT("maxwidth"))
1903 attr
.GetTextBoxAttr().GetMaxSize().GetWidth().SetValue(wxRichTextParseDimension(value
));
1905 else if (name
== wxT("maxheight"))
1907 attr
.GetTextBoxAttr().GetMaxSize().GetHeight().SetValue(wxRichTextParseDimension(value
));
1910 else if (name
== wxT("verticalalignment"))
1912 if (value
== wxT("top"))
1913 attr
.GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_TOP
);
1914 else if (value
== wxT("centre"))
1915 attr
.GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_CENTRE
);
1916 else if (value
== wxT("bottom"))
1917 attr
.GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_BOTTOM
);
1918 else if (value
== wxT("none"))
1919 attr
.GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE
);
1921 else if (name
== wxT("float"))
1923 if (value
== wxT("left"))
1924 attr
.GetTextBoxAttr().SetFloatMode(wxTEXT_BOX_ATTR_FLOAT_LEFT
);
1925 else if (value
== wxT("right"))
1926 attr
.GetTextBoxAttr().SetFloatMode(wxTEXT_BOX_ATTR_FLOAT_RIGHT
);
1927 else if (value
== wxT("none"))
1928 attr
.GetTextBoxAttr().SetFloatMode(wxTEXT_BOX_ATTR_FLOAT_NONE
);
1930 else if (name
== wxT("clear"))
1932 if (value
== wxT("left"))
1933 attr
.GetTextBoxAttr().SetClearMode(wxTEXT_BOX_ATTR_CLEAR_LEFT
);
1934 else if (value
== wxT("right"))
1935 attr
.GetTextBoxAttr().SetClearMode(wxTEXT_BOX_ATTR_CLEAR_RIGHT
);
1936 else if (value
== wxT("both"))
1937 attr
.GetTextBoxAttr().SetClearMode(wxTEXT_BOX_ATTR_CLEAR_BOTH
);
1938 else if (value
== wxT("none"))
1939 attr
.GetTextBoxAttr().SetClearMode(wxTEXT_BOX_ATTR_CLEAR_NONE
);
1941 else if (name
== wxT("collapse-borders"))
1942 attr
.GetTextBoxAttr().SetCollapseBorders((wxTextBoxAttrCollapseMode
) wxAtoi(value
));
1944 else if (name
.Contains(wxT("border-")))
1946 if (name
== wxT("border-left-style"))
1947 attr
.GetTextBoxAttr().GetBorder().GetLeft().SetStyle(wxAtoi(value
));
1948 else if (name
== wxT("border-right-style"))
1949 attr
.GetTextBoxAttr().GetBorder().GetRight().SetStyle(wxAtoi(value
));
1950 else if (name
== wxT("border-top-style"))
1951 attr
.GetTextBoxAttr().GetBorder().GetTop().SetStyle(wxAtoi(value
));
1952 else if (name
== wxT("border-bottom-style"))
1953 attr
.GetTextBoxAttr().GetBorder().GetBottom().SetStyle(wxAtoi(value
));
1955 else if (name
== wxT("border-left-colour"))
1956 attr
.GetTextBoxAttr().GetBorder().GetLeft().SetColour(wxRichTextColourStringToLong(value
));
1957 else if (name
== wxT("border-right-colour"))
1958 attr
.GetTextBoxAttr().GetBorder().GetRight().SetColour(wxRichTextColourStringToLong(value
));
1959 else if (name
== wxT("border-top-colour"))
1960 attr
.GetTextBoxAttr().GetBorder().GetTop().SetColour(wxRichTextColourStringToLong(value
));
1961 else if (name
== wxT("border-bottom-colour"))
1962 attr
.GetTextBoxAttr().GetBorder().GetBottom().SetColour(wxRichTextColourStringToLong(value
));
1964 else if (name
== wxT("border-left-width"))
1965 attr
.GetTextBoxAttr().GetBorder().GetLeft().SetWidth(wxRichTextParseDimension(value
));
1966 else if (name
== wxT("border-right-width"))
1967 attr
.GetTextBoxAttr().GetBorder().GetRight().SetWidth(wxRichTextParseDimension(value
));
1968 else if (name
== wxT("border-top-width"))
1969 attr
.GetTextBoxAttr().GetBorder().GetTop().SetWidth(wxRichTextParseDimension(value
));
1970 else if (name
== wxT("border-bottom-width"))
1971 attr
.GetTextBoxAttr().GetBorder().GetBottom().SetWidth(wxRichTextParseDimension(value
));
1973 else if (name
.Contains(wxT("outline-")))
1975 if (name
== wxT("outline-left-style"))
1976 attr
.GetTextBoxAttr().GetOutline().GetLeft().SetStyle(wxAtoi(value
));
1977 else if (name
== wxT("outline-right-style"))
1978 attr
.GetTextBoxAttr().GetOutline().GetRight().SetStyle(wxAtoi(value
));
1979 else if (name
== wxT("outline-top-style"))
1980 attr
.GetTextBoxAttr().GetOutline().GetTop().SetStyle(wxAtoi(value
));
1981 else if (name
== wxT("outline-bottom-style"))
1982 attr
.GetTextBoxAttr().GetOutline().GetBottom().SetStyle(wxAtoi(value
));
1984 else if (name
== wxT("outline-left-colour"))
1985 attr
.GetTextBoxAttr().GetOutline().GetLeft().SetColour(wxRichTextColourStringToLong(value
));
1986 else if (name
== wxT("outline-right-colour"))
1987 attr
.GetTextBoxAttr().GetOutline().GetRight().SetColour(wxRichTextColourStringToLong(value
));
1988 else if (name
== wxT("outline-top-colour"))
1989 attr
.GetTextBoxAttr().GetOutline().GetTop().SetColour(wxRichTextColourStringToLong(value
));
1990 else if (name
== wxT("outline-bottom-colour"))
1991 attr
.GetTextBoxAttr().GetOutline().GetBottom().SetColour(wxRichTextColourStringToLong(value
));
1993 else if (name
== wxT("outline-left-width"))
1994 attr
.GetTextBoxAttr().GetOutline().GetLeft().SetWidth(wxRichTextParseDimension(value
));
1995 else if (name
== wxT("outline-right-width"))
1996 attr
.GetTextBoxAttr().GetOutline().GetRight().SetWidth(wxRichTextParseDimension(value
));
1997 else if (name
== wxT("outline-top-width"))
1998 attr
.GetTextBoxAttr().GetOutline().GetTop().SetWidth(wxRichTextParseDimension(value
));
1999 else if (name
== wxT("outline-bottom-width"))
2000 attr
.GetTextBoxAttr().GetOutline().GetBottom().SetWidth(wxRichTextParseDimension(value
));
2002 else if (name
.Contains(wxT("margin-")))
2004 if (name
== wxT("margin-left"))
2005 attr
.GetTextBoxAttr().GetMargins().GetLeft().SetValue(wxRichTextParseDimension(value
));
2006 else if (name
== wxT("margin-right"))
2007 attr
.GetTextBoxAttr().GetMargins().GetRight().SetValue(wxRichTextParseDimension(value
));
2008 else if (name
== wxT("margin-top"))
2009 attr
.GetTextBoxAttr().GetMargins().GetTop().SetValue(wxRichTextParseDimension(value
));
2010 else if (name
== wxT("margin-bottom"))
2011 attr
.GetTextBoxAttr().GetMargins().GetBottom().SetValue(wxRichTextParseDimension(value
));
2013 else if (name
.Contains(wxT("padding-")))
2015 if (name
== wxT("padding-left"))
2016 attr
.GetTextBoxAttr().GetPadding().GetLeft().SetValue(wxRichTextParseDimension(value
));
2017 else if (name
== wxT("padding-right"))
2018 attr
.GetTextBoxAttr().GetPadding().GetRight().SetValue(wxRichTextParseDimension(value
));
2019 else if (name
== wxT("padding-top"))
2020 attr
.GetTextBoxAttr().GetPadding().GetTop().SetValue(wxRichTextParseDimension(value
));
2021 else if (name
== wxT("padding-bottom"))
2022 attr
.GetTextBoxAttr().GetPadding().GetBottom().SetValue(wxRichTextParseDimension(value
));
2024 else if (name
.Contains(wxT("position-")))
2026 if (name
== wxT("position-left"))
2027 attr
.GetTextBoxAttr().GetPosition().GetLeft().SetValue(wxRichTextParseDimension(value
));
2028 else if (name
== wxT("position-right"))
2029 attr
.GetTextBoxAttr().GetPosition().GetRight().SetValue(wxRichTextParseDimension(value
));
2030 else if (name
== wxT("position-top"))
2031 attr
.GetTextBoxAttr().GetPosition().GetTop().SetValue(wxRichTextParseDimension(value
));
2032 else if (name
== wxT("position-bottom"))
2033 attr
.GetTextBoxAttr().GetPosition().GetBottom().SetValue(wxRichTextParseDimension(value
));
2037 xmlAttr
= xmlAttr
->GetNext();
2046 // Import this object from XML
2047 bool wxRichTextObject::ImportFromXML(wxRichTextBuffer
* WXUNUSED(buffer
), wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
)
2049 handler
->ImportProperties(this, node
);
2050 handler
->ImportStyle(GetAttributes(), node
, UsesParagraphAttributes());
2057 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
2058 // Export this object directly to the given stream.
2059 bool wxRichTextObject::ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
)
2061 ::OutputIndentation(stream
, indent
);
2062 ::OutputString(stream
, wxT("<") + GetXMLNodeName(), handler
->GetConvMem(), handler
->GetConvFile());
2064 wxString style
= handler
->AddAttributes(GetAttributes(), true);
2066 ::OutputString(stream
, style
+ wxT(">"), handler
->GetConvMem(), handler
->GetConvFile());
2068 if (GetProperties().GetCount() > 0)
2070 handler
->WriteProperties(stream
, GetProperties(), indent
);
2073 wxRichTextCompositeObject
* composite
= wxDynamicCast(this, wxRichTextCompositeObject
);
2077 for (i
= 0; i
< composite
->GetChildCount(); i
++)
2079 wxRichTextObject
* child
= composite
->GetChild(i
);
2080 child
->ExportXML(stream
, indent
+1, handler
);
2084 ::OutputIndentation(stream
, indent
);
2085 ::OutputString(stream
, wxT("</") + GetXMLNodeName() + wxT(">"), handler
->GetConvMem(), handler
->GetConvFile());
2090 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
2091 // Export this object to the given parent node, usually creating at least one child node.
2092 bool wxRichTextObject::ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
)
2094 wxXmlNode
* elementNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, GetXMLNodeName());
2095 parent
->AddChild(elementNode
);
2096 handler
->AddAttributes(elementNode
, GetAttributes(), true);
2097 handler
->WriteProperties(elementNode
, GetProperties());
2099 wxRichTextCompositeObject
* composite
= wxDynamicCast(this, wxRichTextCompositeObject
);
2103 for (i
= 0; i
< composite
->GetChildCount(); i
++)
2105 wxRichTextObject
* child
= composite
->GetChild(i
);
2106 child
->ExportXML(elementNode
, handler
);
2114 // Import this object from XML
2115 bool wxRichTextPlainText::ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
)
2117 wxRichTextObject::ImportFromXML(buffer
, node
, handler
, recurse
);
2119 if (node
->GetName() == wxT("text"))
2122 wxXmlNode
* textChild
= node
->GetChildren();
2125 if (textChild
->GetType() == wxXML_TEXT_NODE
||
2126 textChild
->GetType() == wxXML_CDATA_SECTION_NODE
)
2128 wxString text2
= textChild
->GetContent();
2130 // Strip whitespace from end
2131 if (!text2
.empty() && text2
[text2
.length()-1] == wxT('\n'))
2132 text2
= text2
.Mid(0, text2
.length()-1);
2134 if (!text2
.empty() && text2
[0] == wxT('"'))
2135 text2
= text2
.Mid(1);
2136 if (!text2
.empty() && text2
[text2
.length()-1] == wxT('"'))
2137 text2
= text2
.Mid(0, text2
.length() - 1);
2141 textChild
= textChild
->GetNext();
2146 else if (node
->GetName() == wxT("symbol"))
2148 // This is a symbol that XML can't read in the normal way
2150 wxXmlNode
* textChild
= node
->GetChildren();
2153 if (textChild
->GetType() == wxXML_TEXT_NODE
||
2154 textChild
->GetType() == wxXML_CDATA_SECTION_NODE
)
2156 wxString text2
= textChild
->GetContent();
2159 textChild
= textChild
->GetNext();
2162 wxString actualText
;
2163 actualText
<< (wxChar
) wxAtoi(text
);
2164 SetText(actualText
);
2172 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
2173 // Export this object directly to the given stream.
2174 bool wxRichTextPlainText::ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
)
2176 wxString style
= handler
->AddAttributes(GetAttributes(), false);
2180 const wxString
& text
= GetText();
2181 int len
= (int) text
.Length();
2186 ::OutputIndentation(stream
, indent
);
2187 ::OutputString(stream
, wxT("<text"), handler
->GetConvMem(), handler
->GetConvFile());
2188 ::OutputString(stream
, style
+ wxT(">"), handler
->GetConvMem(), handler
->GetConvFile());
2189 if (GetProperties().GetCount() > 0)
2191 handler
->WriteProperties(stream
, GetProperties(), indent
);
2192 ::OutputIndentation(stream
, indent
);
2194 ::OutputString(stream
, wxT("</text>"), handler
->GetConvMem(), handler
->GetConvFile());
2196 else for (i
= 0; i
< len
; i
++)
2199 int c
= (int) text
[i
];
2201 int c
= (int) wxUChar(text
[i
]);
2203 if ((c
< 32 || c
== 34) && /* c != 9 && */ c
!= 10 && c
!= 13)
2207 wxString
fragment(text
.Mid(last
, i
-last
));
2208 if (!fragment
.empty())
2210 ::OutputIndentation(stream
, indent
);
2211 ::OutputString(stream
, wxT("<text"), handler
->GetConvMem(), handler
->GetConvFile());
2213 ::OutputString(stream
, style
+ wxT(">"), handler
->GetConvMem(), handler
->GetConvFile());
2215 if (!fragment
.empty() && (fragment
[0] == wxT(' ') || fragment
[fragment
.length()-1] == wxT(' ')))
2217 ::OutputString(stream
, wxT("\""), handler
->GetConvMem(), handler
->GetConvFile());
2218 ::OutputStringEnt(stream
, fragment
, handler
->GetConvMem(), handler
->GetConvFile());
2219 ::OutputString(stream
, wxT("\""), handler
->GetConvMem(), handler
->GetConvFile());
2222 ::OutputStringEnt(stream
, fragment
, handler
->GetConvMem(), handler
->GetConvFile());
2224 if (GetProperties().GetCount() > 0)
2226 handler
->WriteProperties(stream
, GetProperties(), indent
);
2227 ::OutputIndentation(stream
, indent
);
2229 ::OutputString(stream
, wxT("</text>"), handler
->GetConvMem(), handler
->GetConvFile());
2234 // Output this character as a number in a separate tag, because XML can't cope
2235 // with entities below 32 except for 10 and 13
2237 ::OutputIndentation(stream
, indent
);
2238 ::OutputString(stream
, wxT("<symbol"), handler
->GetConvMem(), handler
->GetConvFile());
2240 ::OutputString(stream
, style
+ wxT(">"), handler
->GetConvMem(), handler
->GetConvFile());
2241 ::OutputString(stream
, wxString::Format(wxT("%d"), c
), handler
->GetConvMem(), handler
->GetConvFile());
2243 if (GetProperties().GetCount() > 0)
2245 handler
->WriteProperties(stream
, GetProperties(), indent
);
2246 ::OutputIndentation(stream
, indent
);
2248 ::OutputString(stream
, wxT("</symbol>"), handler
->GetConvMem(), handler
->GetConvFile());
2256 fragment
= text
.Mid(last
, i
-last
);
2260 ::OutputIndentation(stream
, indent
);
2261 ::OutputString(stream
, wxT("<text"), handler
->GetConvMem(), handler
->GetConvFile());
2263 ::OutputString(stream
, style
+ wxT(">"), handler
->GetConvMem(), handler
->GetConvFile());
2265 if (GetProperties().GetCount() > 0)
2267 handler
->WriteProperties(stream
, GetProperties(), indent
);
2268 ::OutputIndentation(stream
, indent
);
2271 if (!fragment
.empty() && (fragment
[0] == wxT(' ') || fragment
[fragment
.length()-1] == wxT(' ')))
2273 ::OutputString(stream
, wxT("\""), handler
->GetConvMem(), handler
->GetConvFile());
2274 ::OutputStringEnt(stream
, fragment
, handler
->GetConvMem(), handler
->GetConvFile());
2275 ::OutputString(stream
, wxT("\""), handler
->GetConvMem(), handler
->GetConvFile());
2278 ::OutputStringEnt(stream
, fragment
, handler
->GetConvMem(), handler
->GetConvFile());
2280 ::OutputString(stream
, wxT("</text>"), handler
->GetConvMem(), handler
->GetConvFile());
2286 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
2287 // Export this object to the given parent node, usually creating at least one child node.
2288 bool wxRichTextPlainText::ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
)
2292 const wxString
& text
= GetText();
2293 int len
= (int) text
.Length();
2299 wxXmlNode
* elementNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, wxT("text"));
2300 parent
->AddChild(elementNode
);
2302 handler
->AddAttributes(elementNode
, GetAttributes(), false);
2303 handler
->WriteProperties(elementNode
, GetProperties());
2305 else for (i
= 0; i
< len
; i
++)
2308 int c
= (int) text
[i
];
2310 int c
= (int) wxUChar(text
[i
]);
2312 if ((c
< 32 || c
== 34) && c
!= 10 && c
!= 13)
2316 wxString
fragment(text
.Mid(last
, i
-last
));
2317 if (!fragment
.empty())
2319 // TODO: I'm assuming wxXmlDocument will output quotes if necessary
2320 wxXmlNode
* elementNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, wxT("text"));
2321 parent
->AddChild(elementNode
);
2322 handler
->AddAttributes(elementNode
, GetAttributes(), false);
2323 handler
->WriteProperties(elementNode
, GetProperties());
2325 wxXmlNode
* textNode
= new wxXmlNode(wxXML_TEXT_NODE
, wxT("text"));
2326 elementNode
->AddChild(textNode
);
2328 if (fragment
[0] == wxT(' ') || fragment
[fragment
.length()-1] == wxT(' '))
2329 fragment
= wxT("\"") + fragment
+ wxT("\"");
2331 textNode
->SetContent(fragment
);
2336 // Output this character as a number in a separate tag, because XML can't cope
2337 // with entities below 32 except for 10 and 13
2339 wxXmlNode
* elementNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, wxT("symbol"));
2340 parent
->AddChild(elementNode
);
2342 handler
->AddAttributes(elementNode
, GetAttributes(), false);
2343 handler
->WriteProperties(elementNode
, GetProperties());
2345 wxXmlNode
* textNode
= new wxXmlNode(wxXML_TEXT_NODE
, wxT("text"));
2346 elementNode
->AddChild(textNode
);
2347 textNode
->SetContent(wxString::Format(wxT("%d"), c
));
2357 fragment
= text
.Mid(last
, i
-last
);
2361 wxXmlNode
* elementNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, wxT("text"));
2362 parent
->AddChild(elementNode
);
2363 handler
->AddAttributes(elementNode
, GetAttributes(), false);
2365 wxXmlNode
* textNode
= new wxXmlNode(wxXML_TEXT_NODE
, wxT("text"));
2366 elementNode
->AddChild(textNode
);
2368 if (fragment
[0] == wxT(' ') || fragment
[fragment
.length()-1] == wxT(' '))
2369 fragment
= wxT("\"") + fragment
+ wxT("\"");
2371 textNode
->SetContent(fragment
);
2378 // Import this object from XML
2379 bool wxRichTextImage::ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
)
2381 wxRichTextObject::ImportFromXML(buffer
, node
, handler
, recurse
);
2383 wxBitmapType imageType
= wxBITMAP_TYPE_PNG
;
2384 wxString value
= node
->GetAttribute(wxT("imagetype"), wxEmptyString
);
2387 int type
= wxAtoi(value
);
2389 // note: 0 == wxBITMAP_TYPE_INVALID
2390 if (type
<= 0 || type
>= wxBITMAP_TYPE_MAX
)
2392 wxLogWarning("Invalid bitmap type specified for <image> tag: %d", type
);
2396 imageType
= (wxBitmapType
)type
;
2402 wxXmlNode
* imageChild
= node
->GetChildren();
2405 wxString childName
= imageChild
->GetName();
2406 if (childName
== wxT("data"))
2408 wxXmlNode
* dataChild
= imageChild
->GetChildren();
2411 data
= dataChild
->GetContent();
2412 // wxLogDebug(data);
2413 dataChild
= dataChild
->GetNext();
2417 imageChild
= imageChild
->GetNext();
2422 wxStringInputStream
strStream(data
);
2424 GetImageBlock().ReadHex(strStream
, data
.length(), imageType
);
2432 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
2433 // Export this object directly to the given stream.
2434 bool wxRichTextImage::ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
)
2436 wxString style
= handler
->AddAttributes(GetAttributes(), false);
2438 ::OutputIndentation(stream
, indent
);
2439 ::OutputString(stream
, wxT("<image"), handler
->GetConvMem(), handler
->GetConvFile());
2440 if (!GetImageBlock().IsOk())
2443 ::OutputString(stream
, style
+ wxT(">"), handler
->GetConvMem(), handler
->GetConvFile());
2447 ::OutputString(stream
, wxString::Format(wxT(" imagetype=\"%d\""), (int) GetImageBlock().GetImageType()) + style
+ wxT(">"), handler
->GetConvMem(), handler
->GetConvFile());
2449 if (GetProperties().GetCount() > 0)
2451 handler
->WriteProperties(stream
, GetProperties(), indent
);
2452 ::OutputIndentation(stream
, indent
);
2455 ::OutputIndentation(stream
, indent
+1);
2456 ::OutputString(stream
, wxT("<data>"), handler
->GetConvMem(), handler
->GetConvFile());
2458 // wxStopWatch stopwatch;
2460 GetImageBlock().WriteHex(stream
);
2462 // wxLogDebug(wxT("Image conversion to hex took %ldms"), stopwatch.Time());
2464 ::OutputString(stream
, wxT("</data>\n"), handler
->GetConvMem(), handler
->GetConvFile());
2465 ::OutputIndentation(stream
, indent
);
2466 ::OutputString(stream
, wxT("</image>"), handler
->GetConvMem(), handler
->GetConvFile());
2471 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
2472 // Export this object to the given parent node, usually creating at least one child node.
2473 bool wxRichTextImage::ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
)
2475 wxXmlNode
* elementNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, wxT("image"));
2476 parent
->AddChild(elementNode
);
2478 if (GetImageBlock().IsOk())
2479 elementNode
->AddAttribute(wxT("imagetype"), MakeString((int) GetImageBlock().GetImageType()));
2481 handler
->AddAttributes(elementNode
, GetAttributes(), false);
2482 handler
->WriteProperties(elementNode
, GetProperties());
2484 wxXmlNode
* dataNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, wxT("data"));
2485 elementNode
->AddChild(dataNode
);
2486 wxXmlNode
* textNode
= new wxXmlNode(wxXML_TEXT_NODE
, wxT("text"));
2487 dataNode
->AddChild(textNode
);
2492 wxMemoryOutputStream stream
;
2493 if (GetImageBlock().WriteHex(stream
))
2495 if (stream
.GetSize() > 0)
2497 int size
= stream
.GetSize();
2499 int size2
= stream
.GetOutputStreamBuffer()->GetIntPosition();
2500 wxASSERT(size
== size2
);
2502 unsigned char* data
= new unsigned char[size
];
2503 stream
.CopyTo(data
, size
);
2504 strData
= wxString((const char*) data
, wxConvUTF8
, size
);
2508 strData
= wxEmptyString
;
2514 wxStringOutputStream
strStream(& strData
);
2515 GetImageBlock().WriteHex(strStream
);
2519 textNode
->SetContent(strData
);
2520 textNode
->SetNoConversion(true); // optimize speed
2527 // Import this object from XML
2528 bool wxRichTextParagraphLayoutBox::ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
)
2530 wxRichTextObject::ImportFromXML(buffer
, node
, handler
, recurse
);
2534 wxString partial
= node
->GetAttribute(wxT("partialparagraph"), wxEmptyString
);
2535 if (partial
== wxT("true"))
2536 SetPartialParagraph(true);
2538 wxXmlNode
* child
= wxRichTextXMLHandler::FindNode(node
, wxT("stylesheet"));
2539 if (child
&& (handler
->GetFlags() & wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET
))
2541 wxRichTextStyleSheet
* sheet
= new wxRichTextStyleSheet
;
2542 wxString sheetName
= child
->GetAttribute(wxT("name"), wxEmptyString
);
2543 wxString sheetDescription
= child
->GetAttribute(wxT("description"), wxEmptyString
);
2544 sheet
->SetName(sheetName
);
2545 sheet
->SetDescription(sheetDescription
);
2547 wxXmlNode
* child2
= child
->GetChildren();
2550 handler
->ImportStyleDefinition(sheet
, child2
);
2552 child2
= child2
->GetNext();
2554 handler
->ImportProperties(sheet
->GetProperties(), child
);
2556 // Notify that styles have changed. If this is vetoed by the app,
2557 // the new sheet will be deleted. If it is not vetoed, the
2558 // old sheet will be deleted and replaced with the new one.
2559 buffer
->SetStyleSheetAndNotify(sheet
);
2565 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
2566 // Export this object directly to the given stream.
2567 bool wxRichTextParagraphLayoutBox::ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
)
2569 ::OutputIndentation(stream
, indent
);
2570 wxString nodeName
= GetXMLNodeName();
2571 ::OutputString(stream
, wxT("<") + nodeName
, handler
->GetConvMem(), handler
->GetConvFile());
2573 wxString style
= handler
->AddAttributes(GetAttributes(), true);
2575 if (GetPartialParagraph())
2576 style
<< wxT(" partialparagraph=\"true\"");
2578 ::OutputString(stream
, style
+ wxT(">"), handler
->GetConvMem(), handler
->GetConvFile());
2580 if (GetProperties().GetCount() > 0)
2582 handler
->WriteProperties(stream
, GetProperties(), indent
);
2586 for (i
= 0; i
< GetChildCount(); i
++)
2588 wxRichTextObject
* child
= GetChild(i
);
2589 child
->ExportXML(stream
, indent
+1, handler
);
2592 ::OutputIndentation(stream
, indent
);
2593 ::OutputString(stream
, wxT("</") + nodeName
+ wxT(">"), handler
->GetConvMem(), handler
->GetConvFile());
2598 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
2599 // Export this object to the given parent node, usually creating at least one child node.
2600 bool wxRichTextParagraphLayoutBox::ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
)
2602 wxXmlNode
* elementNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, GetXMLNodeName());
2603 parent
->AddChild(elementNode
);
2604 handler
->AddAttributes(elementNode
, GetAttributes(), true);
2605 handler
->WriteProperties(elementNode
, GetProperties());
2607 if (GetPartialParagraph())
2608 elementNode
->AddAttribute(wxT("partialparagraph"), wxT("true"));
2611 for (i
= 0; i
< GetChildCount(); i
++)
2613 wxRichTextObject
* child
= GetChild(i
);
2614 child
->ExportXML(elementNode
, handler
);
2621 // Import this object from XML
2622 bool wxRichTextTable::ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
)
2624 wxRichTextBox::ImportFromXML(buffer
, node
, handler
, recurse
);
2628 m_rowCount
= wxAtoi(node
->GetAttribute(wxT("rows"), wxEmptyString
));
2629 m_colCount
= wxAtoi(node
->GetAttribute(wxT("cols"), wxEmptyString
));
2631 wxXmlNode
* child
= node
->GetChildren();
2634 wxRichTextObject
* childObj
= handler
->CreateObjectForXMLName(this, child
->GetName());
2637 AppendChild(childObj
);
2638 handler
->ImportXML(buffer
, childObj
, child
);
2640 child
= child
->GetNext();
2643 m_cells
.Add(wxRichTextObjectPtrArray(), m_rowCount
);
2645 for (i
= 0; i
< m_rowCount
; i
++)
2647 wxRichTextObjectPtrArray
& colArray
= m_cells
[i
];
2648 for (j
= 0; j
< m_colCount
; j
++)
2650 int idx
= i
* m_colCount
+ j
;
2651 if (idx
< (int) GetChildren().GetCount())
2653 wxRichTextCell
* cell
= wxDynamicCast(GetChildren().Item(idx
)->GetData(), wxRichTextCell
);
2663 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
2664 // Export this object directly to the given stream.
2665 bool wxRichTextTable::ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
)
2667 ::OutputIndentation(stream
, indent
);
2668 wxString nodeName
= GetXMLNodeName();
2669 ::OutputString(stream
, wxT("<") + nodeName
, handler
->GetConvMem(), handler
->GetConvFile());
2671 wxString style
= handler
->AddAttributes(GetAttributes(), true);
2673 style
<< wxT(" rows=\"") << m_rowCount
<< wxT("\"");
2674 style
<< wxT(" cols=\"") << m_colCount
<< wxT("\"");
2676 ::OutputString(stream
, style
+ wxT(">"), handler
->GetConvMem(), handler
->GetConvFile());
2678 if (GetProperties().GetCount() > 0)
2680 handler
->WriteProperties(stream
, GetProperties(), indent
);
2684 for (i
= 0; i
< m_rowCount
; i
++)
2686 for (j
= 0; j
< m_colCount
; j
++)
2688 wxRichTextCell
* cell
= GetCell(i
, j
);
2689 cell
->ExportXML(stream
, indent
+1, handler
);
2693 ::OutputIndentation(stream
, indent
);
2694 ::OutputString(stream
, wxT("</") + nodeName
+ wxT(">"), handler
->GetConvMem(), handler
->GetConvFile());
2700 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
2701 // Export this object to the given parent node, usually creating at least one child node.
2702 bool wxRichTextTable::ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
)
2704 wxXmlNode
* elementNode
= new wxXmlNode(wxXML_ELEMENT_NODE
, GetXMLNodeName());
2705 parent
->AddChild(elementNode
);
2706 handler
->AddAttributes(elementNode
, GetAttributes(), true);
2707 handler
->WriteProperties(elementNode
, GetProperties());
2709 elementNode
->AddAttribute(wxT("rows"), wxString::Format(wxT("%d"), m_rowCount
));
2710 elementNode
->AddAttribute(wxT("cols"), wxString::Format(wxT("%d"), m_colCount
));
2713 for (i
= 0; i
< m_rowCount
; i
++)
2715 for (j
= 0; j
< m_colCount
; j
++)
2717 wxRichTextCell
* cell
= GetCell(i
, j
);
2718 cell
->ExportXML(elementNode
, handler
);
2728 // wxUSE_RICHTEXT && wxUSE_XML