X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7c9fdebe5fd18292fc8d08d5707e8340a0e2ee23..12bb29f5432174ecbd65549bda832d70d34a98ae:/src/richtext/richtextxml.cpp diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp index 2d8acafb82..4157ec5505 100644 --- a/src/richtext/richtextxml.cpp +++ b/src/richtext/richtextxml.cpp @@ -89,6 +89,8 @@ static inline void AddString(wxString& str, const wxColour& col) { str << wxT("# IMPLEMENT_DYNAMIC_CLASS(wxRichTextXMLHandler, wxRichTextFileHandler) +wxStringToStringHashMap wxRichTextXMLHandler::sm_nodeNameToClassMap; + void wxRichTextXMLHandler::Init() { #if wxRICHTEXT_HAVE_DIRECT_OUTPUT @@ -158,24 +160,12 @@ bool wxRichTextXMLHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& s /// Creates an object given an XML element name wxRichTextObject* wxRichTextXMLHandler::CreateObjectForXMLName(wxRichTextObject* WXUNUSED(parent), const wxString& name) const { - if (name == wxT("text") || name == wxT("symbol")) - return new wxRichTextPlainText; - else if (name == wxT("image")) - return new wxRichTextImage; - else if (name == wxT("paragraph")) - return new wxRichTextParagraph; - else if (name == wxT("paragraphlayout")) - return new wxRichTextParagraphLayoutBox; - else if (name == wxT("textbox")) - return new wxRichTextBox; - else if (name == wxT("cell")) - return new wxRichTextCell; - else if (name == wxT("table")) - return new wxRichTextTable; - else if (name == wxT("field")) - return new wxRichTextField; - else + // The standard node to class mappings are added in wxRichTextModule::OnInit in richtextbuffer.cpp + wxStringToStringHashMap::const_iterator it = sm_nodeNameToClassMap.find(name); + if (it == sm_nodeNameToClassMap.end()) return NULL; + else + return wxDynamicCast(wxCreateDynamicObject(it->second), wxRichTextObject); } /// Recursively import an object @@ -1102,8 +1092,10 @@ wxString wxRichTextXMLHandler::AddAttributes(const wxRichTextAttr& attr, bool is if (attr.HasBackgroundColour() && attr.GetBackgroundColour().IsOk()) AddAttribute(str, wxT("bgcolor"), attr.GetBackgroundColour()); - if (attr.HasFontSize()) - AddAttribute(str, wxT("fontsize"), attr.GetFontSize()); + if (attr.HasFontPointSize()) + AddAttribute(str, wxT("fontpointsize"), attr.GetFontSize()); + else if (attr.HasFontPixelSize()) + AddAttribute(str, wxT("fontpixelsize"), attr.GetFontSize()); if (attr.HasFontFamily()) AddAttribute(str, wxT("fontfamily"), attr.GetFontFamily()); @@ -1405,8 +1397,10 @@ bool wxRichTextXMLHandler::AddAttributes(wxXmlNode* node, wxRichTextAttr& attr, 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.HasFontPointSize()) + node->AddAttribute(wxT("fontpointsize"), MakeString(attr.GetFontSize())); + else if (attr.HasFontPixelSize()) + node->AddAttribute(wxT("fontpixelsize"), MakeString(attr.GetFontSize())); if (attr.HasFontFamily()) node->AddAttribute(wxT("fontfamily"), MakeString(attr.GetFontFamily())); if (attr.HasFontItalic()) @@ -1693,10 +1687,15 @@ bool wxRichTextXMLHandler::ImportStyle(wxRichTextAttr& attr, wxXmlNode* node, bo if (!value.empty()) attr.SetFontStyle((wxFontStyle)wxAtoi(value)); } - else if (name == wxT("fontsize")) + else if (name == wxT("fontsize") || name == wxT("fontpointsize")) + { + if (!value.empty()) + attr.SetFontPointSize(wxAtoi(value)); + } + else if (name == wxT("fontpixelsize")) { if (!value.empty()) - attr.SetFontSize(wxAtoi(value)); + attr.SetFontPixelSize(wxAtoi(value)); } else if (name == wxT("fontweight")) {