X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/288b6107e1060b57ec50048d06cfc3f22bc11e0c..409521e45d44fc57df39efcb965701d378edcb20:/src/richtext/richtextxml.cpp?ds=sidebyside diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp index c5759c78cc..a9833b3e74 100644 --- a/src/richtext/richtextxml.cpp +++ b/src/richtext/richtextxml.cpp @@ -270,7 +270,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx { if (child->GetName() == wxT("style")) { - wxTextAttrEx attr; + wxTextAttr attr; GetStyle(attr, child, false); def->SetStyle(attr); } @@ -292,7 +292,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx { if (child->GetName() == wxT("style")) { - wxTextAttrEx attr; + wxTextAttr attr; GetStyle(attr, child, false); def->SetStyle(attr); } @@ -314,7 +314,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx { if (child->GetName() == wxT("style")) { - wxTextAttrEx attr; + wxTextAttr attr; GetStyle(attr, child, false); wxString styleLevel = child->GetAttribute(wxT("level"), wxEmptyString); @@ -834,7 +834,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxMBCon int i; for (i = 0; i < 10; i ++) { - wxRichTextAttr* levelAttr = listDef->GetLevelAttributes(i); + wxTextAttr* levelAttr = listDef->GetLevelAttributes(i); if (levelAttr) { wxString style = CreateStyle(def->GetStyle(), false); @@ -882,7 +882,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxMBCon } /// Create style parameters -wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara) +wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttr& attr, bool isPara) { wxString str; if (attr.HasTextColour() && attr.GetTextColour().Ok()) @@ -894,26 +894,23 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara str << wxT(" bgcolor=\"#") << ColourToHexString(attr.GetBackgroundColour()) << wxT("\""); } - if (attr.GetFont().Ok()) - { - if (attr.HasFontSize()) - str << wxT(" fontsize=\"") << attr.GetFont().GetPointSize() << wxT("\""); + if (attr.HasFontSize()) + str << wxT(" fontsize=\"") << attr.GetFontSize() << wxT("\""); - //if (attr.HasFontFamily()) - // str << wxT(" fontfamily=\"") << attr.GetFont().GetFamily() << wxT("\""); + //if (attr.HasFontFamily()) + // str << wxT(" fontfamily=\"") << attr.GetFont().GetFamily() << wxT("\""); - if (attr.HasFontItalic()) - str << wxT(" fontstyle=\"") << attr.GetFont().GetStyle() << wxT("\""); + if (attr.HasFontItalic()) + str << wxT(" fontstyle=\"") << attr.GetFontStyle() << wxT("\""); - if (attr.HasFontWeight()) - str << wxT(" fontweight=\"") << attr.GetFont().GetWeight() << wxT("\""); + if (attr.HasFontWeight()) + str << wxT(" fontweight=\"") << attr.GetFontWeight() << wxT("\""); - if (attr.HasFontUnderlined()) - str << wxT(" fontunderlined=\"") << (int) attr.GetFont().GetUnderlined() << wxT("\""); + if (attr.HasFontUnderlined()) + str << wxT(" fontunderlined=\"") << (int) attr.GetFontUnderlined() << wxT("\""); - if (attr.HasFontFaceName()) - str << wxT(" fontface=\"") << attr.GetFont().GetFaceName() << wxT("\""); - } + if (attr.HasFontFaceName()) + str << wxT(" fontface=\"") << attr.GetFontFaceName() << wxT("\""); if (attr.HasTextEffects()) { @@ -929,6 +926,9 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara if (!attr.GetCharacterStyleName().empty()) str << wxT(" characterstyle=\"") << wxString(attr.GetCharacterStyleName()) << wxT("\""); + if (attr.HasURL()) + str << wxT(" url=\"") << attr.GetURL() << wxT("\""); + if (isPara) { if (attr.HasAlignment()) @@ -973,9 +973,6 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara if (attr.HasBulletName()) str << wxT(" bulletname=\"") << attr.GetBulletName() << wxT("\""); - if (attr.HasURL()) - str << wxT(" url=\"") << attr.GetURL() << wxT("\""); - if (!attr.GetParagraphStyleName().empty()) str << wxT(" parstyle=\"") << wxString(attr.GetParagraphStyleName()) << wxT("\""); @@ -1009,20 +1006,20 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara } /// Get style parameters -bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool isPara) +bool wxRichTextXMLHandler::GetStyle(wxTextAttr& attr, wxXmlNode* node, bool isPara) { wxString fontFacename; int fontSize = 12; - int fontFamily = wxDEFAULT; + // int fontFamily = wxDEFAULT; int fontWeight = wxNORMAL; int fontStyle = wxNORMAL; bool fontUnderlined = false; - int fontFlags = 0; + // int fontFlags = 0; fontFacename = node->GetAttribute(wxT("fontface"), wxEmptyString); if (!fontFacename.IsEmpty()) - fontFlags |= wxTEXT_ATTR_FONT_FACE; + attr.SetFontFaceName(fontFacename); wxString value; //value = node->GetAttribute(wxT("fontfamily"), wxEmptyString); @@ -1033,38 +1030,30 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is if (!value.empty()) { fontStyle = wxAtoi(value); - fontFlags |= wxTEXT_ATTR_FONT_ITALIC; + attr.SetFontStyle(fontStyle); } value = node->GetAttribute(wxT("fontsize"), wxEmptyString); if (!value.empty()) { fontSize = wxAtoi(value); - fontFlags |= wxTEXT_ATTR_FONT_SIZE; + attr.SetFontSize(fontSize); } value = node->GetAttribute(wxT("fontweight"), wxEmptyString); if (!value.empty()) { fontWeight = wxAtoi(value); - fontFlags |= wxTEXT_ATTR_FONT_WEIGHT; + attr.SetFontWeight(fontWeight); } value = node->GetAttribute(wxT("fontunderlined"), wxEmptyString); if (!value.empty()) { fontUnderlined = wxAtoi(value) != 0; - fontFlags |= wxTEXT_ATTR_FONT_UNDERLINE; + attr.SetFontUnderlined(fontUnderlined); } - 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->GetAttribute(wxT("textcolor"), wxEmptyString); if (!value.empty()) { @@ -1099,6 +1088,10 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is attr.SetTextEffectFlags(wxAtoi(value)); } + value = node->GetAttribute(wxT("url"), wxEmptyString); + if (!value.empty()) + attr.SetURL(value); + // Set paragraph attributes if (isPara) { @@ -1172,10 +1165,6 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is if (!value.empty()) attr.SetBulletName(value); - value = node->GetAttribute(wxT("url"), wxEmptyString); - if (!value.empty()) - attr.SetURL(value); - value = node->GetAttribute(wxT("parstyle"), wxEmptyString); if (!value.empty()) attr.SetParagraphStyleName(value); @@ -1206,7 +1195,7 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is value = node->GetAttribute(wxT("outlinelevel"), wxEmptyString); if (!value.IsEmpty()) { - attr.SetOutlineLevel(wxAtoi(value) != 0); + attr.SetOutlineLevel(wxAtoi(value)); } }