+ else if (name == wxT("outline-left-colour"))
+ attr.GetTextBoxAttr().GetOutline().GetLeft().SetColour(ColourStringToLong(value));
+ else if (name == wxT("outline-right-colour"))
+ attr.GetTextBoxAttr().GetOutline().GetRight().SetColour(ColourStringToLong(value));
+ else if (name == wxT("outline-top-colour"))
+ attr.GetTextBoxAttr().GetOutline().GetTop().SetColour(ColourStringToLong(value));
+ else if (name == wxT("outline-bottom-colour"))
+ attr.GetTextBoxAttr().GetOutline().GetBottom().SetColour(ColourStringToLong(value));
+
+ else if (name == wxT("outline-left-width"))
+ attr.GetTextBoxAttr().GetOutline().GetLeft().SetWidth(ParseDimension(value));
+ else if (name == wxT("outline-right-width"))
+ attr.GetTextBoxAttr().GetOutline().GetRight().SetWidth(ParseDimension(value));
+ else if (name == wxT("outline-top-width"))
+ attr.GetTextBoxAttr().GetOutline().GetTop().SetWidth(ParseDimension(value));
+ else if (name == wxT("outline-bottom-width"))
+ attr.GetTextBoxAttr().GetOutline().GetBottom().SetWidth(ParseDimension(value));
+ }
+ else if (name.Contains(wxT("margin-")))
+ {
+ if (name == wxT("margin-left"))
+ attr.GetTextBoxAttr().GetMargins().GetLeft().SetValue(ParseDimension(value));
+ else if (name == wxT("margin-right"))
+ attr.GetTextBoxAttr().GetMargins().GetRight().SetValue(ParseDimension(value));
+ else if (name == wxT("margin-top"))
+ attr.GetTextBoxAttr().GetMargins().GetTop().SetValue(ParseDimension(value));
+ else if (name == wxT("margin-bottom"))
+ attr.GetTextBoxAttr().GetMargins().GetBottom().SetValue(ParseDimension(value));
+ }
+ else if (name.Contains(wxT("padding-")))
+ {
+ if (name == wxT("padding-left"))
+ attr.GetTextBoxAttr().GetPadding().GetLeft().SetValue(ParseDimension(value));
+ else if (name == wxT("padding-right"))
+ attr.GetTextBoxAttr().GetPadding().GetRight().SetValue(ParseDimension(value));
+ else if (name == wxT("padding-top"))
+ attr.GetTextBoxAttr().GetPadding().GetTop().SetValue(ParseDimension(value));
+ else if (name == wxT("padding-bottom"))
+ attr.GetTextBoxAttr().GetPadding().GetBottom().SetValue(ParseDimension(value));
+ }
+ else if (name.Contains(wxT("position-")))
+ {
+ if (name == wxT("position-left"))
+ attr.GetTextBoxAttr().GetPosition().GetLeft().SetValue(ParseDimension(value));
+ else if (name == wxT("position-right"))
+ attr.GetTextBoxAttr().GetPosition().GetRight().SetValue(ParseDimension(value));
+ else if (name == wxT("position-top"))
+ attr.GetTextBoxAttr().GetPosition().GetTop().SetValue(ParseDimension(value));
+ else if (name == wxT("position-bottom"))
+ attr.GetTextBoxAttr().GetPosition().GetBottom().SetValue(ParseDimension(value));
+ }
+ }
+
+ xmlAttr = xmlAttr->GetNext();
+ }
+
+ return true;
+}
+
+bool wxRichTextXMLHelper::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wxXmlNode* node)
+{
+ wxString styleType = node->GetName();
+ wxString styleName = node->GetAttribute(wxT("name"), wxEmptyString);
+ wxString baseStyleName = node->GetAttribute(wxT("basestyle"), wxEmptyString);
+
+ if (styleName.empty())
+ return false;
+
+ if (styleType == wxT("characterstyle"))
+ {
+ wxRichTextCharacterStyleDefinition* def = new wxRichTextCharacterStyleDefinition(styleName);
+ def->SetBaseStyle(baseStyleName);
+
+ wxXmlNode* child = node->GetChildren();
+ while (child)
+ {
+ if (child->GetName() == wxT("style"))
+ {
+ wxRichTextAttr attr;
+ ImportStyle(attr, child, false);
+ def->SetStyle(attr);
+ }
+ child = child->GetNext();
+ }
+
+ ImportProperties(def->GetProperties(), node);
+
+ sheet->AddCharacterStyle(def);
+ }
+ else if (styleType == wxT("paragraphstyle"))
+ {
+ wxRichTextParagraphStyleDefinition* def = new wxRichTextParagraphStyleDefinition(styleName);
+
+ wxString nextStyleName = node->GetAttribute(wxT("nextstyle"), wxEmptyString);
+ def->SetNextStyle(nextStyleName);
+ def->SetBaseStyle(baseStyleName);
+
+ wxXmlNode* child = node->GetChildren();
+ while (child)
+ {
+ if (child->GetName() == wxT("style"))
+ {
+ wxRichTextAttr attr;
+ ImportStyle(attr, child, true);
+ def->SetStyle(attr);
+ }
+ child = child->GetNext();
+ }
+
+ ImportProperties(def->GetProperties(), node);
+
+ sheet->AddParagraphStyle(def);
+ }
+ else if (styleType == wxT("boxstyle"))
+ {
+ wxRichTextBoxStyleDefinition* def = new wxRichTextBoxStyleDefinition(styleName);
+
+ def->SetBaseStyle(baseStyleName);
+
+ wxXmlNode* child = node->GetChildren();
+ while (child)
+ {
+ if (child->GetName() == wxT("style"))
+ {
+ wxRichTextAttr attr;
+ ImportStyle(attr, child, true);
+ def->SetStyle(attr);
+ }
+ child = child->GetNext();
+ }
+
+ ImportProperties(def->GetProperties(), node);
+
+ sheet->AddBoxStyle(def);
+ }
+ else if (styleType == wxT("liststyle"))
+ {
+ wxRichTextListStyleDefinition* def = new wxRichTextListStyleDefinition(styleName);
+
+ wxString nextStyleName = node->GetAttribute(wxT("nextstyle"), wxEmptyString);
+ def->SetNextStyle(nextStyleName);
+ def->SetBaseStyle(baseStyleName);
+
+ wxXmlNode* child = node->GetChildren();
+ while (child)
+ {
+ if (child->GetName() == wxT("style"))
+ {
+ wxRichTextAttr attr;
+ ImportStyle(attr, child, true);
+
+ wxString styleLevel = child->GetAttribute(wxT("level"), wxEmptyString);
+ if (styleLevel.empty())
+ {
+ def->SetStyle(attr);
+ }
+ else
+ {
+ int level = wxAtoi(styleLevel);
+ if (level > 0 && level <= 10)
+ {
+ def->SetLevelAttributes(level-1, attr);
+ }
+ }
+ }
+ child = child->GetNext();
+ }
+
+ ImportProperties(def->GetProperties(), node);
+
+ sheet->AddListStyle(def);
+ }
+
+ return true;
+}
+
+bool wxRichTextXMLHelper::ImportProperties(wxRichTextProperties& properties, wxXmlNode* node)
+{
+ wxXmlNode* child = node->GetChildren();
+ while (child)
+ {
+ if (child->GetName() == wxT("properties"))
+ {
+ wxXmlNode* propertyChild = child->GetChildren();
+ while (propertyChild)
+ {
+ if (propertyChild->GetName() == wxT("property"))
+ {
+ wxString name = propertyChild->GetAttribute(wxT("name"), wxEmptyString);
+ wxString value = propertyChild->GetAttribute(wxT("value"), wxEmptyString);
+ wxString type = propertyChild->GetAttribute(wxT("type"), wxEmptyString);
+
+ wxVariant var = MakePropertyFromString(name, value, type);
+ if (!var.IsNull())
+ {
+ properties.SetProperty(var);
+ }
+ }
+ propertyChild = propertyChild->GetNext();
+ }
+ }
+ child = child->GetNext();
+ }
+ return true;
+}
+
+#if wxRICHTEXT_HAVE_DIRECT_OUTPUT
+// write string to output
+void wxRichTextXMLHelper::OutputString(wxOutputStream& stream, const wxString& str,
+ wxMBConv *WXUNUSED_IN_UNICODE(convMem), wxMBConv *convFile)
+{
+ if (str.empty()) return;
+#if wxUSE_UNICODE
+ if (convFile)
+ {
+ const wxWX2MBbuf buf(str.mb_str(*convFile));
+ stream.Write((const char*)buf, strlen((const char*)buf));
+ }
+ else
+ {
+ const wxWX2MBbuf buf(str.mb_str(wxConvUTF8));
+ stream.Write((const char*)buf, strlen((const char*)buf));
+ }
+#else
+ if ( convFile == NULL )
+ stream.Write(str.mb_str(), str.Len());
+ else
+ {
+ wxString str2(str.wc_str(*convMem), *convFile);
+ stream.Write(str2.mb_str(), str2.Len());
+ }
+#endif
+}
+
+void wxRichTextXMLHelper::OutputIndentation(wxOutputStream& stream, int indent)
+{
+ wxString str = wxT("\n");
+ for (int i = 0; i < indent; i++)
+ str << wxT(' ') << wxT(' ');
+ OutputString(stream, str, NULL, NULL);
+}
+
+// Same as above, but create entities first.
+// Translates '<' to "<", '>' to ">" and '&' to "&"
+void wxRichTextXMLHelper::OutputStringEnt(wxOutputStream& stream, const wxString& str,
+ wxMBConv *convMem, wxMBConv *convFile)
+{
+ wxString buf;
+ size_t i, last, len;
+ wxChar c;
+
+ len = str.Len();
+ last = 0;
+ for (i = 0; i < len; i++)
+ {
+ c = str.GetChar(i);
+
+ // Original code excluded "&" but we _do_ want to convert
+ // the ampersand beginning & because otherwise when read in,
+ // the original "&" becomes "&".