X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d2d0adc7765dfe904f0f7e97d85a2638c934a7d6..190b93449ef558fd1819c3c3bdc4f2d3cd8208e0:/src/richtext/richtextxml.cpp?ds=sidebyside diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp index 801c5d2fbc..3e03c70559 100644 --- a/src/richtext/richtextxml.cpp +++ b/src/richtext/richtextxml.cpp @@ -41,6 +41,7 @@ bool wxRichTextXMLHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& s if (!stream.IsOk()) return false; + buffer->ResetAndClearCommands(); buffer->Clear(); wxXmlDocument* xmlDoc = new wxXmlDocument; @@ -55,6 +56,7 @@ bool wxRichTextXMLHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& s if (!xmlDoc->Load(stream, encoding)) { + buffer->ResetAndClearCommands(); success = false; } else @@ -215,6 +217,10 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node) if (GetFlags() & wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET) { wxRichTextStyleSheet* sheet = new wxRichTextStyleSheet; + wxString sheetName = node->GetPropVal(wxT("name"), wxEmptyString); + wxString sheetDescription = node->GetPropVal(wxT("description"), wxEmptyString); + sheet->SetName(sheetName); + sheet->SetDescription(sheetDescription); wxXmlNode* child = node->GetChildren(); while (child) @@ -573,7 +579,12 @@ bool wxRichTextXMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& if (buffer->GetStyleSheet() && (GetFlags() & wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET)) { OutputIndentation(stream, level); - OutputString(stream, wxT(""), convMem, convFile); + wxString nameAndDescr; + if (!buffer->GetStyleSheet()->GetName().IsEmpty()) + nameAndDescr << wxT(" name=\"") << buffer->GetStyleSheet()->GetName() << wxT("\""); + if (!buffer->GetStyleSheet()->GetDescription().IsEmpty()) + nameAndDescr << wxT(" description=\"") << buffer->GetStyleSheet()->GetDescription() << wxT("\""); + OutputString(stream, wxString(wxT(""), convMem, convFile); int i; @@ -773,10 +784,15 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxMBCon if (!baseStyle.IsEmpty()) baseStyleProp = wxT(" basestyle=\"") + baseStyle + wxT("\""); + wxString descr = def->GetDescription(); + wxString descrProp; + if (!descr.IsEmpty()) + descrProp = wxT(" description=\"") + descr + wxT("\""); + if (charDef) { OutputIndentation(stream, level); - OutputString(stream, wxT(""), convMem, convFile); + OutputString(stream, wxT(""), convMem, convFile); level ++; @@ -800,7 +816,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxMBCon if (!listDef->GetNextStyle().IsEmpty()) baseStyleProp << wxT(" basestyle=\"") << listDef->GetNextStyle() << wxT("\""); - OutputString(stream, wxT(""), convMem, convFile); + OutputString(stream, wxT(""), convMem, convFile); level ++; @@ -841,7 +857,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxMBCon if (!listDef->GetNextStyle().IsEmpty()) baseStyleProp << wxT(" basestyle=\"") << listDef->GetNextStyle() << wxT("\""); - OutputString(stream, wxT(""), convMem, convFile); + OutputString(stream, wxT(""), convMem, convFile); level ++; @@ -877,25 +893,36 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara if (attr.GetFont().Ok()) { - if (attr.HasSize()) + if (attr.HasFontSize()) str << wxT(" fontsize=\"") << attr.GetFont().GetPointSize() << wxT("\""); - //if (attr.HasFamily()) + //if (attr.HasFontFamily()) // str << wxT(" fontfamily=\"") << attr.GetFont().GetFamily() << wxT("\""); - if (attr.HasItalic()) + if (attr.HasFontItalic()) str << wxT(" fontstyle=\"") << attr.GetFont().GetStyle() << wxT("\""); - if (attr.HasWeight()) + if (attr.HasFontWeight()) str << wxT(" fontweight=\"") << attr.GetFont().GetWeight() << wxT("\""); - if (attr.HasUnderlined()) + if (attr.HasFontUnderlined()) str << wxT(" fontunderlined=\"") << (int) attr.GetFont().GetUnderlined() << wxT("\""); - if (attr.HasFaceName()) + if (attr.HasFontFaceName()) str << wxT(" fontface=\"") << attr.GetFont().GetFaceName() << wxT("\""); } + if (attr.HasTextEffects()) + { + str << wxT(" texteffects=\""); + str << attr.GetTextEffects(); + str << wxT("\""); + + str << wxT(" texteffectflags=\""); + str << attr.GetTextEffectFlags(); + str << wxT("\""); + } + if (!attr.GetCharacterStyleName().empty()) str << wxT(" characterstyle=\"") << wxString(attr.GetCharacterStyleName()) << wxT("\""); @@ -964,6 +991,15 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara } str << wxT("\""); } + + if (attr.HasPageBreak()) + { + str << wxT(" pagebreak=\"1\""); + } + + if (attr.HasOutlineLevel()) + str << wxT(" outlinelevel=\"") << (int) attr.GetOutlineLevel() << wxT("\""); + } return str; @@ -1048,6 +1084,18 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is if (!value.empty()) attr.SetCharacterStyleName(value); + value = node->GetPropVal(wxT("texteffects"), wxEmptyString); + if (!value.IsEmpty()) + { + attr.SetTextEffects(wxAtoi(value)); + } + + value = node->GetPropVal(wxT("texteffectflags"), wxEmptyString); + if (!value.IsEmpty()) + { + attr.SetTextEffectFlags(wxAtoi(value)); + } + // Set paragraph attributes if (isPara) { @@ -1145,6 +1193,18 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is } attr.SetTabs(tabs); } + + value = node->GetPropVal(wxT("pagebreak"), wxEmptyString); + if (!value.IsEmpty()) + { + attr.SetPageBreak(wxAtoi(value) != 0); + } + + value = node->GetPropVal(wxT("outlinelevel"), wxEmptyString); + if (!value.IsEmpty()) + { + attr.SetOutlineLevel(wxAtoi(value) != 0); + } } return true;