+ level --;
+ }
+
+ return true;
+}
+
+
+#endif
+ // wxRICHTEXT_HAVE_DIRECT_OUTPUT
+
+#if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
+bool wxRichTextXMLHandler::ExportXML(wxXmlNode* parent, wxRichTextObject& obj)
+{
+ obj.ExportXML(parent, this);
+
+ return true;
+}
+
+bool wxRichTextXMLHandler::ExportStyleDefinition(wxXmlNode* parent, wxRichTextStyleDefinition* def)
+{
+ wxRichTextCharacterStyleDefinition* charDef = wxDynamicCast(def, wxRichTextCharacterStyleDefinition);
+ wxRichTextParagraphStyleDefinition* paraDef = wxDynamicCast(def, wxRichTextParagraphStyleDefinition);
+ wxRichTextBoxStyleDefinition* boxDef = wxDynamicCast(def, wxRichTextBoxStyleDefinition);
+ wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition);
+
+ wxString baseStyle = def->GetBaseStyle();
+ wxString descr = def->GetDescription();
+
+ wxXmlNode* defNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxEmptyString);
+ parent->AddChild(defNode);
+ if (!baseStyle.empty())
+ defNode->AddAttribute(wxT("basestyle"), baseStyle);
+ if (!descr.empty())
+ defNode->AddAttribute(wxT("description"), descr);
+
+ wxXmlNode* styleNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("style"));
+ defNode->AddChild(styleNode);
+
+ if (charDef)
+ {
+ defNode->SetName(wxT("characterstyle"));
+ AddAttributes(styleNode, def->GetStyle(), false);
+ }
+ else if (listDef)
+ {
+ defNode->SetName(wxT("liststyle"));
+
+ if (!listDef->GetNextStyle().empty())
+ defNode->AddAttribute(wxT("nextstyle"), listDef->GetNextStyle());
+
+ AddAttributes(styleNode, def->GetStyle(), true);
+
+ int i;
+ for (i = 0; i < 10; i ++)
+ {
+ wxRichTextAttr* levelAttr = listDef->GetLevelAttributes(i);
+ if (levelAttr)
+ {
+ wxXmlNode* levelNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("style"));
+ defNode->AddChild(levelNode);
+ levelNode->AddAttribute(wxT("level"), MakeString(i+1));
+ AddAttributes(levelNode, * levelAttr, true);
+ }
+ }
+ }
+ else if (boxDef)
+ {
+ defNode->SetName(wxT("boxstyle"));
+
+ AddAttributes(styleNode, def->GetStyle(), true);
+ }
+ else if (paraDef)
+ {
+ defNode->SetName(wxT("paragraphstyle"));
+
+ if (!paraDef->GetNextStyle().empty())
+ defNode->AddAttribute(wxT("nextstyle"), paraDef->GetNextStyle());
+
+ AddAttributes(styleNode, def->GetStyle(), true);
+ }
+
+ WriteProperties(defNode, def->GetProperties());
+
+ return true;
+}
+
+bool wxRichTextXMLHandler::AddAttributes(wxXmlNode* node, wxRichTextAttr& attr, bool isPara)
+{
+ if (attr.HasTextColour() && attr.GetTextColour().IsOk())
+ node->AddAttribute(wxT("textcolor"), MakeString(attr.GetTextColour()));
+ if (attr.HasBackgroundColour() && attr.GetBackgroundColour().IsOk())
+ node->AddAttribute(wxT("bgcolor"), MakeString(attr.GetBackgroundColour()));
+
+ if (attr.HasFontSize())
+ node->AddAttribute(wxT("fontsize"), MakeString(attr.GetFontSize()));
+ if (attr.HasFontFamily())
+ node->AddAttribute(wxT("fontfamily"), MakeString(attr.GetFontFamily()));
+ if (attr.HasFontItalic())
+ node->AddAttribute(wxT("fontstyle"), MakeString(attr.GetFontStyle()));
+ if (attr.HasFontWeight())
+ node->AddAttribute(wxT("fontweight"), MakeString(attr.GetFontWeight()));
+ if (attr.HasFontUnderlined())
+ node->AddAttribute(wxT("fontunderlined"), MakeString((int) attr.GetFontUnderlined()));
+ if (attr.HasFontFaceName())
+ node->AddAttribute(wxT("fontface"), attr.GetFontFaceName());
+
+ if (attr.HasTextEffects())
+ {
+ node->AddAttribute(wxT("texteffects"), MakeString(attr.GetTextEffects()));
+ node->AddAttribute(wxT("texteffectflags"), MakeString(attr.GetTextEffectFlags()));
+ }
+ if (attr.HasCharacterStyleName() && !attr.GetCharacterStyleName().empty())
+ node->AddAttribute(wxT("characterstyle"), attr.GetCharacterStyleName());
+
+ if (attr.HasURL())
+ node->AddAttribute(wxT("url"), attr.GetURL()); // TODO: do we need to wrap this in AttributeToXML?
+
+ if (isPara)
+ {
+ if (attr.HasAlignment())
+ node->AddAttribute(wxT("alignment"), MakeString((int) attr.GetAlignment()));
+
+ if (attr.HasLeftIndent())
+ {
+ node->AddAttribute(wxT("leftindent"), MakeString((int) attr.GetLeftIndent()));
+ node->AddAttribute(wxT("leftsubindent"), MakeString((int) attr.GetLeftSubIndent()));
+ }
+
+ if (attr.HasRightIndent())
+ node->AddAttribute(wxT("rightindent"), MakeString((int) attr.GetRightIndent()));
+
+ if (attr.HasParagraphSpacingAfter())
+ node->AddAttribute(wxT("parspacingafter"), MakeString((int) attr.GetParagraphSpacingAfter()));
+
+ if (attr.HasParagraphSpacingBefore())
+ node->AddAttribute(wxT("parspacingbefore"), MakeString((int) attr.GetParagraphSpacingBefore()));
+
+ if (attr.HasLineSpacing())
+ node->AddAttribute(wxT("linespacing"), MakeString((int) attr.GetLineSpacing()));
+
+ if (attr.HasBulletStyle())
+ node->AddAttribute(wxT("bulletstyle"), MakeString((int) attr.GetBulletStyle()));
+
+ if (attr.HasBulletNumber())
+ node->AddAttribute(wxT("bulletnumber"), MakeString((int) attr.GetBulletNumber()));
+
+ if (attr.HasBulletText())
+ {
+ // If using a bullet symbol, convert to integer in case it's a non-XML-friendly character.
+ // Otherwise, assume it's XML-friendly text such as outline numbering, e.g. 1.2.3.1
+ if (!attr.GetBulletText().empty() && (attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL))
+ node->AddAttribute(wxT("bulletsymbol"), MakeString((int) (attr.GetBulletText()[0])));
+ else
+ node->AddAttribute(wxT("bullettext"), attr.GetBulletText());
+
+ if (!attr.GetBulletFont().empty())
+ node->AddAttribute(wxT("bulletfont"), attr.GetBulletFont());
+ }
+
+ if (attr.HasBulletName())
+ node->AddAttribute(wxT("bulletname"), attr.GetBulletName());
+
+ if (!attr.GetParagraphStyleName().empty())
+ node->AddAttribute(wxT("parstyle"), attr.GetParagraphStyleName());
+
+ if (!attr.GetListStyleName().empty())
+ node->AddAttribute(wxT("liststyle"), attr.GetListStyleName());
+
+ if (!attr.GetTextBoxAttr().GetBoxStyleName().empty())
+ node->AddAttribute(wxT("boxstyle"), attr.GetTextBoxAttr().GetBoxStyleName());
+
+ if (attr.HasTabs())
+ {
+ wxString tabs;
+ size_t i;
+ for (i = 0; i < attr.GetTabs().GetCount(); i++)
+ {
+ if (i > 0)
+ tabs << wxT(",");
+ tabs << attr.GetTabs()[i];
+ }
+ node->AddAttribute(wxT("tabs"), tabs);
+ }
+
+ if (attr.HasPageBreak())
+ node->AddAttribute(wxT("pagebreak"), wxT("1"));
+
+ if (attr.HasOutlineLevel())
+ node->AddAttribute(wxT("outlinelevel"), MakeString((int) attr.GetOutlineLevel()));
+ }
+
+ AddAttribute(node, wxT("margin"), attr.GetTextBoxAttr().GetMargins());
+ AddAttribute(node, wxT("padding"), attr.GetTextBoxAttr().GetPadding());
+ AddAttribute(node, wxT("position"), attr.GetTextBoxAttr().GetPosition());
+ AddAttribute(node, wxT("border"), attr.GetTextBoxAttr().GetBorder());
+ AddAttribute(node, wxT("outline"), attr.GetTextBoxAttr().GetOutline());
+ AddAttribute(node, wxT("width"), attr.GetTextBoxAttr().GetWidth());
+ AddAttribute(node, wxT("height"), attr.GetTextBoxAttr().GetHeight());
+ AddAttribute(node, wxT("minwidth"), attr.GetTextBoxAttr().GetMinSize().GetWidth());
+ AddAttribute(node, wxT("minheight"), attr.GetTextBoxAttr().GetMinSize().GetHeight());
+ AddAttribute(node, wxT("maxwidth"), attr.GetTextBoxAttr().GetMaxSize().GetWidth());
+ AddAttribute(node, wxT("maxheight"), attr.GetTextBoxAttr().GetMaxSize().GetHeight());
+
+ if (attr.GetTextBoxAttr().HasVerticalAlignment())
+ {
+ wxString value;
+ if (attr.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_TOP)
+ value = wxT("top");
+ else if (attr.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_CENTRE)
+ value = wxT("centre");
+ else if (attr.GetTextBoxAttr().GetVerticalAlignment() == wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_BOTTOM)
+ value = wxT("bottom");
+ else
+ value = wxT("none");
+ AddAttribute(node, wxT("verticalalignment"), value);
+ }
+
+ if (attr.GetTextBoxAttr().HasFloatMode())
+ {
+ wxString value;
+ if (attr.GetTextBoxAttr().GetFloatMode() == wxTEXT_BOX_ATTR_FLOAT_LEFT)
+ value = wxT("left");
+ else if (attr.GetTextBoxAttr().GetFloatMode() == wxTEXT_BOX_ATTR_FLOAT_RIGHT)
+ value = wxT("right");
+ else
+ value = wxT("none");
+ AddAttribute(node, wxT("float"), value);
+ }
+
+ if (attr.GetTextBoxAttr().HasClearMode())
+ {
+ wxString value;
+ if (attr.GetTextBoxAttr().GetClearMode() == wxTEXT_BOX_ATTR_CLEAR_LEFT)
+ value = wxT("left");
+ else if (attr.GetTextBoxAttr().GetClearMode() == wxTEXT_BOX_ATTR_CLEAR_RIGHT)
+ value = wxT("right");
+ else if (attr.GetTextBoxAttr().GetClearMode() == wxTEXT_BOX_ATTR_CLEAR_BOTH)
+ value = wxT("both");
+ else
+ value = wxT("none");
+ AddAttribute(node, wxT("clear"), value);
+ }
+
+ if (attr.GetTextBoxAttr().HasCollapseBorders())
+ AddAttribute(node, wxT("collapse-borders"), (int) attr.GetTextBoxAttr().GetCollapseBorders());
+
+ return true;
+}
+
+bool wxRichTextXMLHandler::WriteProperties(wxXmlNode* node, const wxRichTextProperties& properties)
+{
+ if (properties.GetCount() > 0)
+ {
+ wxXmlNode* propertiesNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("properties"));
+ node->AddChild(propertiesNode);
+ size_t i;
+ for (i = 0; i < properties.GetCount(); i++)
+ {
+ const wxVariant& var = properties[i];
+ if (!var.IsNull())
+ {
+ wxXmlNode* propertyNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("property"));
+ propertiesNode->AddChild(propertyNode);
+
+ const wxString& name = var.GetName();
+ wxString value = MakeStringFromProperty(var);
+
+ AddAttribute(propertyNode, wxT("name"), name);
+ AddAttribute(propertyNode, wxT("type"), var.GetType());
+ AddAttribute(propertyNode, wxT("value"), value);
+ }
+ }
+ }
+ return true;
+}
+
+#endif
+ // wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
+
+/// Replace face name with current name for platform.
+/// TODO: introduce a virtual function or settable table to
+/// do this comprehensively.
+bool wxRichTextFixFaceName(wxString& facename)
+{
+ if (facename.empty())
+ return false;
+
+#ifdef __WXMSW__
+ if (facename == wxT("Times"))
+ {
+ facename = wxT("Times New Roman");
+ return true;
+ }
+ else if (facename == wxT("Helvetica"))
+ {
+ facename = wxT("Arial");
+ return true;
+ }
+ else if (facename == wxT("Courier"))
+ {
+ facename = wxT("Courier New");
+ return true;
+ }
+ else
+ return false;
+#else
+ if (facename == wxT("Times New Roman"))
+ {
+ facename = wxT("Times");
+ return true;
+ }
+ else if (facename == wxT("Arial"))
+ {
+ facename = wxT("Helvetica");
+ return true;
+ }
+ else if (facename == wxT("Courier New"))
+ {
+ facename = wxT("Courier");
+ return true;
+ }
+ else
+ return false;
+#endif
+}
+
+static inline long wxRichTextColourStringToLong(const wxString& colStr)
+{
+ if (!colStr.IsEmpty())
+ {
+ wxColour col(colStr);
+ return col.GetRGB();
+ }
+ else
+ return 0;
+}
+
+static inline wxTextAttrDimension wxRichTextParseDimension(const wxString& dimStr)
+{
+ wxString valuePart = dimStr.BeforeFirst(wxT(','));
+ wxString flagsPart;
+ if (dimStr.Contains(wxT(",")))
+ flagsPart = dimStr.AfterFirst(wxT(','));
+ wxTextAttrDimension dim;
+ dim.SetValue(wxAtoi(valuePart));
+ dim.SetFlags(wxAtoi(flagsPart));
+
+ return dim;
+}
+
+/// Import style parameters
+bool wxRichTextXMLHandler::ImportStyle(wxRichTextAttr& attr, wxXmlNode* node, bool isPara)
+{
+ wxXmlAttribute* xmlAttr = node->GetAttributes();
+ bool found;
+ while (xmlAttr)
+ {
+ const wxString& name = xmlAttr->GetName();
+ const wxString& value = xmlAttr->GetValue();
+ found = true;
+
+ if (name == wxT("fontface"))
+ {
+ if (!value.empty())
+ {
+ wxString v = value;
+ if (GetFlags() & wxRICHTEXT_HANDLER_CONVERT_FACENAMES)
+ wxRichTextFixFaceName(v);
+ attr.SetFontFaceName(v);
+ }
+ }
+ else if (name == wxT("fontfamily"))
+ {
+ if (!value.empty())
+ attr.SetFontFamily((wxFontFamily)wxAtoi(value));
+ }
+ else if (name == wxT("fontstyle"))
+ {
+ if (!value.empty())
+ attr.SetFontStyle((wxFontStyle)wxAtoi(value));
+ }
+ else if (name == wxT("fontsize"))
+ {
+ if (!value.empty())
+ attr.SetFontSize(wxAtoi(value));
+ }
+ else if (name == wxT("fontweight"))
+ {
+ if (!value.empty())
+ attr.SetFontWeight((wxFontWeight) wxAtoi(value));
+ }
+ else if (name == wxT("fontunderlined"))
+ {
+ if (!value.empty())
+ attr.SetFontUnderlined(wxAtoi(value) != 0);
+ }
+ else if (name == wxT("textcolor"))
+ {
+ if (!value.empty())
+ {
+ if (value[0] == wxT('#'))
+ attr.SetTextColour(HexStringToColour(value.Mid(1)));
+ else
+ attr.SetTextColour(value);
+ }
+ }
+ else if (name == wxT("bgcolor"))
+ {
+ if (!value.empty())
+ {
+ if (value[0] == wxT('#'))
+ attr.SetBackgroundColour(HexStringToColour(value.Mid(1)));
+ else
+ attr.SetBackgroundColour(value);
+ }
+ }
+ else if (name == wxT("characterstyle"))
+ {
+ if (!value.empty())
+ attr.SetCharacterStyleName(value);
+ }
+ else if (name == wxT("texteffects"))
+ {
+ if (!value.empty())
+ attr.SetTextEffects(wxAtoi(value));
+ }
+ else if (name == wxT("texteffectflags"))
+ {
+ if (!value.empty())
+ attr.SetTextEffectFlags(wxAtoi(value));
+ }
+ else if (name == wxT("url"))
+ {
+ if (!value.empty())
+ attr.SetURL(value);
+ }
+ else if (isPara)
+ {
+ if (name == wxT("alignment"))
+ {
+ if (!value.empty())
+ attr.SetAlignment((wxTextAttrAlignment) wxAtoi(value));
+ }
+ else if (name == wxT("leftindent"))
+ {
+ if (!value.empty())
+ attr.SetLeftIndent(wxAtoi(value), attr.GetLeftSubIndent());
+ }
+ else if (name == wxT("leftsubindent"))
+ {
+ if (!value.empty())
+ attr.SetLeftIndent(attr.GetLeftIndent(), wxAtoi(value));
+ }
+ else if (name == wxT("rightindent"))
+ {
+ if (!value.empty())
+ attr.SetRightIndent(wxAtoi(value));
+ }
+ else if (name == wxT("parspacingbefore"))
+ {
+ if (!value.empty())
+ attr.SetParagraphSpacingBefore(wxAtoi(value));
+ }
+ else if (name == wxT("parspacingafter"))
+ {
+ if (!value.empty())
+ attr.SetParagraphSpacingAfter(wxAtoi(value));
+ }
+ else if (name == wxT("linespacing"))
+ {
+ if (!value.empty())
+ attr.SetLineSpacing(wxAtoi(value));
+ }
+ else if (name == wxT("bulletstyle"))
+ {
+ if (!value.empty())
+ attr.SetBulletStyle(wxAtoi(value));
+ }
+ else if (name == wxT("bulletnumber"))
+ {
+ if (!value.empty())
+ attr.SetBulletNumber(wxAtoi(value));
+ }
+ else if (name == wxT("bulletsymbol"))
+ {
+ if (!value.empty())
+ {
+ wxChar ch = wxAtoi(value);
+ wxString s;
+ s << ch;
+ attr.SetBulletText(s);
+ }
+ }
+ else if (name == wxT("bullettext"))
+ {
+ if (!value.empty())
+ {
+ attr.SetBulletText(value);
+ }
+ }
+ else if (name == wxT("bulletfont"))
+ {
+ if (!value.empty())
+ {
+ attr.SetBulletFont(value);
+ }
+ }
+ else if (name == wxT("bulletname"))
+ {
+ if (!value.empty())
+ {
+ attr.SetBulletName(value);
+ }
+ }
+ else if (name == wxT("parstyle"))
+ {
+ if (!value.empty())
+ {
+ attr.SetParagraphStyleName(value);
+ }
+ }
+ else if (name == wxT("liststyle"))
+ {
+ if (!value.empty())
+ {
+ attr.SetListStyleName(value);
+ }
+ }
+ else if (name == wxT("boxstyle"))
+ {
+ if (!value.empty())
+ {
+ attr.GetTextBoxAttr().SetBoxStyleName(value);
+ }
+ }
+ else if (name == wxT("tabs"))
+ {
+ if (!value.empty())
+ {
+ wxArrayInt tabs;
+ wxStringTokenizer tkz(value, wxT(","));
+ while (tkz.HasMoreTokens())
+ {
+ wxString token = tkz.GetNextToken();
+ tabs.Add(wxAtoi(token));
+ }
+ attr.SetTabs(tabs);
+ }
+ }
+ else if (name == wxT("pagebreak"))
+ {
+ if (!value.empty())
+ {
+ attr.SetPageBreak(wxAtoi(value) != 0);
+ }
+ }
+ else if (name == wxT("outlinelevel"))
+ {
+ if (!value.empty())
+ {
+ attr.SetOutlineLevel(wxAtoi(value));
+ }
+ }
+ else
+ found = false;
+ }
+ else
+ found = false;
+
+ if (!found)
+ {
+ // Box attributes
+
+ if (name == wxT("width"))
+ {
+ attr.GetTextBoxAttr().GetWidth().SetValue(wxRichTextParseDimension(value));
+ }
+ else if (name == wxT("height"))
+ {
+ attr.GetTextBoxAttr().GetHeight().SetValue(wxRichTextParseDimension(value));
+ }
+ else if (name == wxT("minwidth"))
+ {
+ attr.GetTextBoxAttr().GetMinSize().GetWidth().SetValue(wxRichTextParseDimension(value));
+ }
+ else if (name == wxT("minheight"))
+ {
+ attr.GetTextBoxAttr().GetMinSize().GetHeight().SetValue(wxRichTextParseDimension(value));
+ }
+ else if (name == wxT("maxwidth"))
+ {
+ attr.GetTextBoxAttr().GetMaxSize().GetWidth().SetValue(wxRichTextParseDimension(value));
+ }
+ else if (name == wxT("maxheight"))
+ {
+ attr.GetTextBoxAttr().GetMaxSize().GetHeight().SetValue(wxRichTextParseDimension(value));
+ }
+
+ else if (name == wxT("verticalalignment"))
+ {
+ if (value == wxT("top"))
+ attr.GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_TOP);
+ else if (value == wxT("centre"))
+ attr.GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_CENTRE);
+ else if (value == wxT("bottom"))
+ attr.GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_BOTTOM);
+ else if (value == wxT("none"))
+ attr.GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE);
+ }
+ else if (name == wxT("float"))
+ {
+ if (value == wxT("left"))
+ attr.GetTextBoxAttr().SetFloatMode(wxTEXT_BOX_ATTR_FLOAT_LEFT);
+ else if (value == wxT("right"))
+ attr.GetTextBoxAttr().SetFloatMode(wxTEXT_BOX_ATTR_FLOAT_RIGHT);
+ else if (value == wxT("none"))
+ attr.GetTextBoxAttr().SetFloatMode(wxTEXT_BOX_ATTR_FLOAT_NONE);
+ }
+ else if (name == wxT("clear"))
+ {
+ if (value == wxT("left"))
+ attr.GetTextBoxAttr().SetClearMode(wxTEXT_BOX_ATTR_CLEAR_LEFT);
+ else if (value == wxT("right"))
+ attr.GetTextBoxAttr().SetClearMode(wxTEXT_BOX_ATTR_CLEAR_RIGHT);
+ else if (value == wxT("both"))
+ attr.GetTextBoxAttr().SetClearMode(wxTEXT_BOX_ATTR_CLEAR_BOTH);
+ else if (value == wxT("none"))
+ attr.GetTextBoxAttr().SetClearMode(wxTEXT_BOX_ATTR_CLEAR_NONE);
+ }
+ else if (name == wxT("collapse-borders"))
+ attr.GetTextBoxAttr().SetCollapseBorders((wxTextBoxAttrCollapseMode) wxAtoi(value));
+
+ else if (name.Contains(wxT("border-")))
+ {
+ if (name == wxT("border-left-style"))
+ attr.GetTextBoxAttr().GetBorder().GetLeft().SetStyle(wxAtoi(value));
+ else if (name == wxT("border-right-style"))
+ attr.GetTextBoxAttr().GetBorder().GetRight().SetStyle(wxAtoi(value));
+ else if (name == wxT("border-top-style"))
+ attr.GetTextBoxAttr().GetBorder().GetTop().SetStyle(wxAtoi(value));
+ else if (name == wxT("border-bottom-style"))
+ attr.GetTextBoxAttr().GetBorder().GetBottom().SetStyle(wxAtoi(value));
+
+ else if (name == wxT("border-left-colour"))
+ attr.GetTextBoxAttr().GetBorder().GetLeft().SetColour(wxRichTextColourStringToLong(value));
+ else if (name == wxT("border-right-colour"))
+ attr.GetTextBoxAttr().GetBorder().GetRight().SetColour(wxRichTextColourStringToLong(value));
+ else if (name == wxT("border-top-colour"))
+ attr.GetTextBoxAttr().GetBorder().GetTop().SetColour(wxRichTextColourStringToLong(value));
+ else if (name == wxT("border-bottom-colour"))
+ attr.GetTextBoxAttr().GetBorder().GetBottom().SetColour(wxRichTextColourStringToLong(value));
+
+ else if (name == wxT("border-left-width"))
+ attr.GetTextBoxAttr().GetBorder().GetLeft().SetWidth(wxRichTextParseDimension(value));
+ else if (name == wxT("border-right-width"))
+ attr.GetTextBoxAttr().GetBorder().GetRight().SetWidth(wxRichTextParseDimension(value));
+ else if (name == wxT("border-top-width"))
+ attr.GetTextBoxAttr().GetBorder().GetTop().SetWidth(wxRichTextParseDimension(value));
+ else if (name == wxT("border-bottom-width"))
+ attr.GetTextBoxAttr().GetBorder().GetBottom().SetWidth(wxRichTextParseDimension(value));
+ }
+ else if (name.Contains(wxT("outline-")))
+ {
+ if (name == wxT("outline-left-style"))
+ attr.GetTextBoxAttr().GetOutline().GetLeft().SetStyle(wxAtoi(value));
+ else if (name == wxT("outline-right-style"))
+ attr.GetTextBoxAttr().GetOutline().GetRight().SetStyle(wxAtoi(value));
+ else if (name == wxT("outline-top-style"))
+ attr.GetTextBoxAttr().GetOutline().GetTop().SetStyle(wxAtoi(value));
+ else if (name == wxT("outline-bottom-style"))
+ attr.GetTextBoxAttr().GetOutline().GetBottom().SetStyle(wxAtoi(value));
+
+ else if (name == wxT("outline-left-colour"))
+ attr.GetTextBoxAttr().GetOutline().GetLeft().SetColour(wxRichTextColourStringToLong(value));
+ else if (name == wxT("outline-right-colour"))
+ attr.GetTextBoxAttr().GetOutline().GetRight().SetColour(wxRichTextColourStringToLong(value));
+ else if (name == wxT("outline-top-colour"))
+ attr.GetTextBoxAttr().GetOutline().GetTop().SetColour(wxRichTextColourStringToLong(value));
+ else if (name == wxT("outline-bottom-colour"))
+ attr.GetTextBoxAttr().GetOutline().GetBottom().SetColour(wxRichTextColourStringToLong(value));
+
+ else if (name == wxT("outline-left-width"))
+ attr.GetTextBoxAttr().GetOutline().GetLeft().SetWidth(wxRichTextParseDimension(value));
+ else if (name == wxT("outline-right-width"))
+ attr.GetTextBoxAttr().GetOutline().GetRight().SetWidth(wxRichTextParseDimension(value));
+ else if (name == wxT("outline-top-width"))
+ attr.GetTextBoxAttr().GetOutline().GetTop().SetWidth(wxRichTextParseDimension(value));
+ else if (name == wxT("outline-bottom-width"))
+ attr.GetTextBoxAttr().GetOutline().GetBottom().SetWidth(wxRichTextParseDimension(value));
+ }
+ else if (name.Contains(wxT("margin-")))
+ {
+ if (name == wxT("margin-left"))
+ attr.GetTextBoxAttr().GetMargins().GetLeft().SetValue(wxRichTextParseDimension(value));
+ else if (name == wxT("margin-right"))
+ attr.GetTextBoxAttr().GetMargins().GetRight().SetValue(wxRichTextParseDimension(value));
+ else if (name == wxT("margin-top"))
+ attr.GetTextBoxAttr().GetMargins().GetTop().SetValue(wxRichTextParseDimension(value));
+ else if (name == wxT("margin-bottom"))
+ attr.GetTextBoxAttr().GetMargins().GetBottom().SetValue(wxRichTextParseDimension(value));
+ }
+ else if (name.Contains(wxT("padding-")))
+ {
+ if (name == wxT("padding-left"))
+ attr.GetTextBoxAttr().GetPadding().GetLeft().SetValue(wxRichTextParseDimension(value));
+ else if (name == wxT("padding-right"))
+ attr.GetTextBoxAttr().GetPadding().GetRight().SetValue(wxRichTextParseDimension(value));
+ else if (name == wxT("padding-top"))
+ attr.GetTextBoxAttr().GetPadding().GetTop().SetValue(wxRichTextParseDimension(value));
+ else if (name == wxT("padding-bottom"))
+ attr.GetTextBoxAttr().GetPadding().GetBottom().SetValue(wxRichTextParseDimension(value));
+ }
+ else if (name.Contains(wxT("position-")))
+ {
+ if (name == wxT("position-left"))
+ attr.GetTextBoxAttr().GetPosition().GetLeft().SetValue(wxRichTextParseDimension(value));
+ else if (name == wxT("position-right"))
+ attr.GetTextBoxAttr().GetPosition().GetRight().SetValue(wxRichTextParseDimension(value));
+ else if (name == wxT("position-top"))
+ attr.GetTextBoxAttr().GetPosition().GetTop().SetValue(wxRichTextParseDimension(value));
+ else if (name == wxT("position-bottom"))
+ attr.GetTextBoxAttr().GetPosition().GetBottom().SetValue(wxRichTextParseDimension(value));
+ }
+ }
+
+ xmlAttr = xmlAttr->GetNext();
+ }
+
+ return true;
+}
+
+#endif
+ // wxUSE_STREAMS
+
+// Import this object from XML
+bool wxRichTextObject::ImportFromXML(wxRichTextBuffer* WXUNUSED(buffer), wxXmlNode* node, wxRichTextXMLHandler* handler, bool* recurse)
+{
+ handler->ImportProperties(this, node);
+ handler->ImportStyle(GetAttributes(), node, UsesParagraphAttributes());
+
+ *recurse = true;
+
+ return true;
+}
+
+#if wxRICHTEXT_HAVE_DIRECT_OUTPUT
+// Export this object directly to the given stream.
+bool wxRichTextObject::ExportXML(wxOutputStream& stream, int indent, wxRichTextXMLHandler* handler)
+{
+ ::OutputIndentation(stream, indent);
+ ::OutputString(stream, wxT("<") + GetXMLNodeName(), handler->GetConvMem(), handler->GetConvFile());
+
+ wxString style = handler->AddAttributes(GetAttributes(), true);
+
+ ::OutputString(stream, style + wxT(">"), handler->GetConvMem(), handler->GetConvFile());
+
+ if (GetProperties().GetCount() > 0)
+ {
+ handler->WriteProperties(stream, GetProperties(), indent);
+ }
+
+ wxRichTextCompositeObject* composite = wxDynamicCast(this, wxRichTextCompositeObject);
+ if (composite)
+ {
+ size_t i;
+ for (i = 0; i < composite->GetChildCount(); i++)
+ {
+ wxRichTextObject* child = composite->GetChild(i);
+ child->ExportXML(stream, indent+1, handler);
+ }
+ }
+
+ ::OutputIndentation(stream, indent);
+ ::OutputString(stream, wxT("</") + GetXMLNodeName() + wxT(">"), handler->GetConvMem(), handler->GetConvFile());
+ return true;
+}
+#endif
+
+#if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
+// Export this object to the given parent node, usually creating at least one child node.
+bool wxRichTextObject::ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* handler)
+{
+ wxXmlNode* elementNode = new wxXmlNode(wxXML_ELEMENT_NODE, GetXMLNodeName());
+ parent->AddChild(elementNode);
+ handler->AddAttributes(elementNode, GetAttributes(), true);
+ handler->WriteProperties(elementNode, GetProperties());
+
+ wxRichTextCompositeObject* composite = wxDynamicCast(this, wxRichTextCompositeObject);
+ if (composite)
+ {
+ size_t i;
+ for (i = 0; i < composite->GetChildCount(); i++)
+ {
+ wxRichTextObject* child = composite->GetChild(i);
+ child->ExportXML(elementNode, handler);
+ }
+ }
+ return true;
+}
+#endif