X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b71e9aa4e2187a7f6469f68812467f2ecb6a3836..1ffc8d7a55af1c253ca363bb0fbdda26bb4c9c65:/src/richtext/richtexthtml.cpp diff --git a/src/richtext/richtexthtml.cpp b/src/richtext/richtexthtml.cpp index c1e9c9c584..c1722d2281 100644 --- a/src/richtext/richtexthtml.cpp +++ b/src/richtext/richtexthtml.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: richtext/richtexthtml.cpp +// Name: src/richtext/richtexthtml.cpp // Purpose: HTML I/O for wxRichTextCtrl // Author: Julian Smart // Modified by: @@ -13,7 +13,7 @@ #include "wx/wxprec.h" #ifdef __BORLANDC__ - #pragma hdrstop + #pragma hdrstop #endif #if wxUSE_RICHTEXT @@ -21,15 +21,21 @@ #include "wx/richtext/richtexthtml.h" #ifndef WX_PRECOMP - #include "wx/wx.h" #endif #include "wx/filename.h" #include "wx/wfstream.h" #include "wx/txtstrm.h" +#if wxUSE_FILESYSTEM +#include "wx/filesys.h" +#include "wx/fs_mem.h" +#endif + IMPLEMENT_DYNAMIC_CLASS(wxRichTextHTMLHandler, wxRichTextFileHandler) +int wxRichTextHTMLHandler::sm_fileCounter = 1; + /// Can we handle this filename (if using files)? By default, checks the extension. bool wxRichTextHTMLHandler::CanHandle(const wxString& filename) const { @@ -52,6 +58,8 @@ bool wxRichTextHTMLHandler::DoLoadFile(wxRichTextBuffer *WXUNUSED(buffer), wxInp bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) { + ClearTemporaryImageLocations(); + buffer->Defragment(); wxTextOutputStream str(stream); @@ -61,6 +69,16 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& str << wxT("
\n"); + str << wxT(""); + + str << wxString::Format(wxT(""), + currentParaStyle.GetFont().GetFaceName().c_str(), PtToSize(currentParaStyle.GetFont().GetPointSize()), + currentParaStyle.GetTextColour().GetAsString(wxC2S_HTML_SYNTAX).c_str()); + + m_font = false; + m_indent = 0; + m_list = false; + wxRichTextObjectList::compatibility_iterator node = buffer->GetChildren().GetFirst(); while (node) { @@ -69,7 +87,9 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& if (para) { - OutputParagraphFormatting(currentParaStyle, para->GetAttributes(), stream, true); + wxTextAttrEx paraStyle(para->GetCombinedAttributes()); + + OutputParagraphFormatting(currentParaStyle, paraStyle, stream); wxRichTextObjectList::compatibility_iterator node2 = para->GetChildren().GetFirst(); while (node2) @@ -78,99 +98,580 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& wxRichTextPlainText* textObj = wxDynamicCast(obj, wxRichTextPlainText); if (textObj && !textObj->IsEmpty()) { - OutputCharacterFormatting(currentCharStyle, obj->GetAttributes(), stream, true); + wxTextAttrEx charStyle(para->GetCombinedAttributes(obj->GetAttributes())); + BeginCharacterFormatting(currentCharStyle, charStyle, paraStyle, stream); str << textObj->GetText(); - OutputCharacterFormatting(currentCharStyle, obj->GetAttributes(), stream, false); + EndCharacterFormatting(currentCharStyle, charStyle, paraStyle, stream); } + wxRichTextImage* image = wxDynamicCast(obj, wxRichTextImage); + if( image && !image->IsEmpty()) + WriteImage( image, stream ); + node2 = node2->GetNext(); } + str << wxT("\n"); + } + node = node->GetNext(); + } + + str << wxT(" |
\n"); + // And renavigate to new list's horizontal position + NavigateToListPosition(paraStyle, str); + + // Get the appropriate tag, an ol for numerical values, an ul for dot, square etc. + wxString tag; + TypeOfList(paraStyle, tag); + str << tag << wxT("