diff --git a/include/wx/richtext/richtexthtml.h b/include/wx/richtext/richtexthtml.h
index 7f93c00a91..8bca5ff644 100644
--- a/include/wx/richtext/richtexthtml.h
+++ b/include/wx/richtext/richtexthtml.h
@@ -39,17 +39,65 @@ public:
/// Can we handle this filename (if using files)? By default, checks the extension.
virtual bool CanHandle(const wxString& filename) const;
- /// Output character formatting
- virtual void OutputCharacterFormatting(const wxTextAttrEx& currentStyle, const wxTextAttrEx& thisStyle, wxOutputStream& stream, bool start);
-
- /// Output paragraph formatting
- virtual void OutputParagraphFormatting(const wxTextAttrEx& currentStyle, const wxTextAttrEx& thisStyle, wxOutputStream& stream, bool start);
-
protected:
+
#if wxUSE_STREAMS
virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
#endif
+
+ /// Output character formatting
+ virtual void BeginCharacterFormatting(const wxTextAttrEx& currentStyle, const wxTextAttrEx& thisStyle, wxOutputStream& stream );
+ virtual void EndCharacterFormatting(const wxTextAttrEx& WXUNUSED(currentStyle), const wxTextAttrEx& thisStyle, wxOutputStream& stream );
+
+ /// Output paragraph formatting
+ virtual void OutputParagraphFormatting(const wxTextAttrEx& WXUNUSED(currentStyle), const wxTextAttrEx& thisStyle, wxOutputStream& stream/*, bool start*/);
+
+ /// Converts an image to its base64 equivalent
+ void Image_to_Base64(wxRichTextImage* image, wxOutputStream& stream);
+
+ /// Builds required indentation
+ void Indent( const wxTextAttrEx& thisStyle, wxTextOutputStream& str );
+
+ /// Left indent
+ void LIndent( const wxTextAttrEx& thisStyle, wxTextOutputStream& str );
+
+ /// Converts from pt to size property compatible height
+ long Pt_To_Size(long size);
+
+ /// Typical base64 encoder
+ wxChar* b64enc( unsigned char* input, size_t in_len );
+
+ /// Gets the mime type of the given wxBITMAP_TYPE
+ wxChar* GetMimeType(int imageType);
+
+ /// Gets the html equivalent of the specified value
+ wxString GetAlignment( const wxTextAttrEx& thisStyle );
+
+ /// Generates array for indentations
+ wxString SymbolicIndent(long indent);
+
+ /// Finds the html equivalent of the specified bullet
+ void TypeOfList( const wxTextAttrEx& thisStyle, wxString& tag );
+
+ /// Closes existings or Opens new tables for navigation to an item's horizontal position.
+ void NavigateToListPosition( const wxTextAttrEx& thisStyle, wxTextOutputStream& str );
+
+ /// Indentation values of the table tags
+ wxArrayInt m_indents;
+
+ /// Horizontal position of the current table
+ long m_indent;
+
+ /// Is there any opened font tag
+ bool m_font;
+
+ /// Is there any opened ul/ol tag
+ bool m_list;
+
+ /// type of list, ul or ol?
+ bool m_is_ul;
+
};
#endif
diff --git a/src/richtext/richtexthtml.cpp b/src/richtext/richtexthtml.cpp
index c1e9c9c584..49552e64d3 100644
--- a/src/richtext/richtexthtml.cpp
+++ b/src/richtext/richtexthtml.cpp
@@ -53,24 +53,55 @@ bool wxRichTextHTMLHandler::DoLoadFile(wxRichTextBuffer *WXUNUSED(buffer), wxInp
bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream)
{
buffer->Defragment();
-
+
wxTextOutputStream str(stream);
-
+
wxTextAttrEx currentParaStyle = buffer->GetAttributes();
wxTextAttrEx currentCharStyle = buffer->GetAttributes();
-
+
str << wxT("
\n");
-
+
+ /*
+ wxRichText may be support paper formats like a1/a2/a3/a4
+ when this widget grown enough, i should turn back and support its new features
+ but not yet
+
+ str << wxT("");
+
+ wxString left_indent = SymbolicIndent(currentParaStyle.GetLeftIndent());
+ wxString right_indent = SymbolicIndent(currentParaStyle.GetRightIndent());
+
+ str << wxString::Format(wxT("%s | | %s |
"),
+ left_indent.c_str(), //Document-Wide Left Indent
+ right_indent.c_str()); //Document-Wide Right Indent
+
+ str << wxT(" | ");
+ */
+
+ str << wxT("");
+
+ str << wxString::Format(wxT(""),
+ currentParaStyle.GetFont().GetFaceName(), Pt_To_Size( currentParaStyle.GetFont().GetPointSize() ),
+ currentParaStyle.GetTextColour().Red(), currentParaStyle.GetTextColour().Green(),
+ currentParaStyle.GetTextColour().Blue());
+
+ //wxString align = GetAlignment( currentParaStyle.GetAlignment() );
+ //str << wxString::Format(wxT(" "), align );
+
+ m_font = false;
+ m_indent = 0;
+ m_list = false;
+
wxRichTextObjectList::compatibility_iterator node = buffer->GetChildren().GetFirst();
while (node)
{
wxRichTextParagraph* para = wxDynamicCast(node->GetData(), wxRichTextParagraph);
wxASSERT (para != NULL);
-
+
if (para)
{
- OutputParagraphFormatting(currentParaStyle, para->GetAttributes(), stream, true);
-
+ OutputParagraphFormatting(currentParaStyle, para->GetAttributes(), stream);
+
wxRichTextObjectList::compatibility_iterator node2 = para->GetChildren().GetFirst();
while (node2)
{
@@ -78,99 +109,480 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
wxRichTextPlainText* textObj = wxDynamicCast(obj, wxRichTextPlainText);
if (textObj && !textObj->IsEmpty())
{
- OutputCharacterFormatting(currentCharStyle, obj->GetAttributes(), stream, true);
-
+ BeginCharacterFormatting(currentCharStyle, obj->GetAttributes(), stream);
+
str << textObj->GetText();
-
- OutputCharacterFormatting(currentCharStyle, obj->GetAttributes(), stream, false);
+
+ EndCharacterFormatting(currentCharStyle, obj->GetAttributes(), stream);
}
-
+
+ wxRichTextImage* image = wxDynamicCast(obj, wxRichTextImage);
+ if( image && !image->IsEmpty())
+ Image_to_Base64( image, stream );
+
node2 = node2->GetNext();
}
-
- OutputParagraphFormatting(currentParaStyle, para->GetAttributes(), stream, false);
-
- str << wxT(" \n");
+ //OutputParagraphFormatting(currentParaStyle, para->GetAttributes(), stream, false);
}
-
node = node->GetNext();
}
-
- str << wxT("\n");
-
+
+ str << wxT(" |
|