para->AppendChild(textObject);
}
+ else if (childName == wxT("symbol"))
+ {
+ // This is a symbol that XML can't read in the normal way
+ wxString text;
+ wxXmlNode* textChild = child->GetChildren();
+ while (textChild)
+ {
+ if (textChild->GetType() == wxXML_TEXT_NODE ||
+ textChild->GetType() == wxXML_CDATA_SECTION_NODE)
+ {
+ wxString text2 = textChild->GetContent();
+ text += text2;
+ }
+ textChild = textChild->GetNext();
+ }
+
+ wxString actualText;
+ actualText << (wxChar) wxAtoi(text);
+
+ wxRichTextPlainText* textObject = new wxRichTextPlainText(actualText, para);
+ GetStyle(textObject->GetAttributes(), child, false);
+
+ para->AppendChild(textObject);
+ }
else if (childName == wxT("image"))
{
int imageType = wxBITMAP_TYPE_PNG;
}
last = i + 1;
}
+ else if (wxUChar(c) > 127)
+ {
+ OutputString(stream, str.Mid(last, i - last), convMem, convFile);
+
+ wxString s(wxT("&#"));
+ s << (int) c;
+ s << wxT(";");
+ OutputString(stream, s, NULL, NULL);
+ last = i + 1;
+ }
}
OutputString(stream, str.Mid(last, i - last), convMem, convFile);
}
objectName = wxT("image");
else
objectName = wxT("object");
+
+ bool terminateTag = true;
if (obj.IsKindOf(CLASSINFO(wxRichTextPlainText)))
{
- wxRichTextPlainText& text = (wxRichTextPlainText&) obj;
+ wxRichTextPlainText& textObj = (wxRichTextPlainText&) obj;
+
+ wxString style = CreateStyle(obj.GetAttributes(), false);
+
+ int i;
+ int last = 0;
+ const wxString& text = textObj.GetText();
+ int len = (int) text.Length();
+ for (i = 0; i < len; i++)
+ {
+ int c = (int) text[i];
+ if (c < 32 && c != 9 && c != 10 && c != 13)
+ {
+ if (i > 0)
+ {
+ OutputIndentation(stream, indent);
+ OutputString(stream, wxT("<") + objectName, convMem, convFile);
- OutputIndentation(stream, indent);
- OutputString(stream, wxT("<") + objectName, convMem, convFile);
+ OutputString(stream, style + wxT(">"), convMem, convFile);
- wxString style = CreateStyle(obj.GetAttributes(), false);
+ wxString fragment(text.Mid(last, i-last));
+ if (!fragment.empty() && (fragment[0] == wxT(' ') || fragment[fragment.length()-1] == wxT(' ')))
+ {
+ OutputString(stream, wxT("\""), convMem, convFile);
+ OutputStringEnt(stream, fragment, convMem, convFile);
+ OutputString(stream, wxT("\""), convMem, convFile);
+ }
+ else
+ OutputStringEnt(stream, fragment, convMem, convFile);
- OutputString(stream, style + wxT(">"), convMem, convFile);
+ OutputString(stream, wxT("</text>"), convMem, convFile);
+ }
+
+
+ // Output this character as a number in a separate tag, because XML can't cope
+ // with entities below 32 except for 9, 10 and 13
+ last = i + 1;
+ OutputIndentation(stream, indent);
+ OutputString(stream, wxT("<symbol"), convMem, convFile);
- wxString str = text.GetText();
- if (!str.empty() && (str[0] == wxT(' ') || str[str.length()-1] == wxT(' ')))
+ OutputString(stream, style + wxT(">"), convMem, convFile);
+ OutputString(stream, wxString::Format(wxT("%d"), c), convMem, convFile);
+
+ OutputString(stream, wxT("</symbol>"), convMem, convFile);
+ }
+ }
+
+ wxString fragment;
+ if (last == 0)
+ fragment = text;
+ else
+ fragment = text.Mid(last, i-last);
+
+ if (last < len)
{
- OutputString(stream, wxT("\""), convMem, convFile);
- OutputStringEnt(stream, str, convMem, convFile);
- OutputString(stream, wxT("\""), convMem, convFile);
+ OutputIndentation(stream, indent);
+ OutputString(stream, wxT("<") + objectName, convMem, convFile);
+
+ OutputString(stream, style + wxT(">"), convMem, convFile);
+
+ if (!fragment.empty() && (fragment[0] == wxT(' ') || fragment[fragment.length()-1] == wxT(' ')))
+ {
+ OutputString(stream, wxT("\""), convMem, convFile);
+ OutputStringEnt(stream, fragment, convMem, convFile);
+ OutputString(stream, wxT("\""), convMem, convFile);
+ }
+ else
+ OutputStringEnt(stream, fragment, convMem, convFile);
}
else
- OutputStringEnt(stream, str, convMem, convFile);
+ terminateTag = false;
}
else if (obj.IsKindOf(CLASSINFO(wxRichTextImage)))
{
isPara = true;
wxString style = CreateStyle(obj.GetAttributes(), isPara);
-
+
if (objectName == wxT("paragraphlayout") && ((wxRichTextParagraphLayoutBox&) obj).GetPartialParagraph())
style << wxT(" partialparagraph=\"true\"");
if (objectName != wxT("text"))
OutputIndentation(stream, indent);
- OutputString(stream, wxT("</") + objectName + wxT(">"), convMem, convFile);
+ if (terminateTag)
+ OutputString(stream, wxT("</") + objectName + wxT(">"), convMem, convFile);
return true;
}
{
if (attr.HasSize())
str << wxT(" fontsize=\"") << attr.GetFont().GetPointSize() << wxT("\"");
-
+
//if (attr.HasFamily())
// str << wxT(" fontfamily=\"") << attr.GetFont().GetFamily() << wxT("\"");
str << wxT(" bulletnumber=\"") << (int) attr.GetBulletNumber() << wxT("\"");
if (attr.HasBulletSymbol())
- str << wxT(" bulletsymbol=\"") << wxString(attr.GetBulletSymbol()) << wxT("\"");
+ {
+ str << wxT(" bulletsymbol=\"") << (int) (attr.GetBulletSymbol()) << wxT("\"");
+ str << wxT(" bulletfont=\"") << attr.GetBulletFont() << wxT("\"");
+ }
if (!attr.GetParagraphStyleName().empty())
str << wxT(" parstyle=\"") << wxString(attr.GetParagraphStyleName()) << wxT("\"");
-
+
if (attr.HasTabs())
{
str << wxT(" tabs=\"");
str << wxT(",");
str << attr.GetTabs()[i];
}
- str << wxT("\"");
+ str << wxT("\"");
}
}
int fontWeight = wxNORMAL;
int fontStyle = wxNORMAL;
bool fontUnderlined = false;
-
+
int fontFlags = 0;
fontFacename = node->GetPropVal(wxT("fontface"), wxEmptyString);
fontUnderlined = wxAtoi(value) != 0;
fontFlags |= wxTEXT_ATTR_FONT_UNDERLINE;
}
-
+
attr.SetFlags(fontFlags);
-
+
if (attr.HasFlag(wxTEXT_ATTR_FONT))
attr.SetFont(* wxTheFontList->FindOrCreateFont(fontSize, fontFamily, fontStyle, fontWeight, fontUnderlined, fontFacename));
// Restore correct font flags
attr.SetFlags(fontFlags);
-
+
value = node->GetPropVal(wxT("textcolor"), wxEmptyString);
if (!value.empty())
{
int leftSubIndent = 0;
int leftIndent = 0;
bool hasLeftIndent = false;
-
+
value = node->GetPropVal(wxT("leftindent"), wxEmptyString);
if (!value.empty())
{
value = node->GetPropVal(wxT("bulletsymbol"), wxEmptyString);
if (!value.empty())
- attr.SetBulletSymbol(value[0]);
+ attr.SetBulletSymbol(wxAtoi(value));
+
+ value = node->GetPropVal(wxT("bulletfont"), wxEmptyString);
+ if (!value.empty())
+ attr.SetBulletFont(value);
value = node->GetPropVal(wxT("parstyle"), wxEmptyString);
if (!value.empty())
attr.SetParagraphStyleName(value);
-
+
value = node->GetPropVal(wxT("tabs"), wxEmptyString);
if (!value.empty())
{
#endif
// wxUSE_RICHTEXT && wxUSE_XML
+