X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/07854e5edda33cdb2c4ff50f545f7a3eb94badc3..1ae30333bc929731802800694f85e6275986cd0a:/src/richtext/richtexthtml.cpp diff --git a/src/richtext/richtexthtml.cpp b/src/richtext/richtexthtml.cpp index 4326e33e15..95ed0c1d4c 100644 --- a/src/richtext/richtexthtml.cpp +++ b/src/richtext/richtexthtml.cpp @@ -27,8 +27,15 @@ #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 { @@ -51,6 +58,8 @@ bool wxRichTextHTMLHandler::DoLoadFile(wxRichTextBuffer *WXUNUSED(buffer), wxInp bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) { + ClearTemporaryImageLocations(); + buffer->Defragment(); wxTextOutputStream str(stream); @@ -58,34 +67,15 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& 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 | ||
");
- */
-
- str << wxT("
|
after every paragraph - if(!m_list) + // If there is no opened list currently, insert a
after every paragraph + if (!m_list) { wxTextOutputStream str(stream); - wxString align = GetAlignment( thisStyle ); + wxString align = GetAlignment(thisStyle); str << wxString::Format(wxT("
"), align.c_str()); } + + if (thisStyle.HasPageBreak()) + { + wxTextOutputStream str(stream); + str << wxT("
\n"); + } } void wxRichTextHTMLHandler::NavigateToListPosition(const wxTextAttrEx& thisStyle, wxTextOutputStream& str) { - //indenting an item using an ul/ol tag is equal to inserting 5 x on its left side. - //so we should start from 100 point left + // indenting an item using an ul/ol tag is equal to inserting 5 x on its left side. + // so we should start from 100 point left - //Is the second td's left wall of the current indentaion table at the 100+ point-left-side - //of the item, horizontally? - if( m_indent + 100 < thisStyle.GetLeftIndent() ) + // Is the second td's left wall of the current indentaion table at the 100+ point-left-side + // of the item, horizontally? + if (m_indent + 100 < thisStyle.GetLeftIndent()) { - //yes it is + // yes it is LIndent(thisStyle, str); m_indent = thisStyle.GetLeftIndent() - 100; m_indents.Add( m_indent ); return; } - //No it isn't + // No it isn't int i = m_indents.size() - 1; - for(; i > -1; i--) + for (; i > -1; i--) { //Is the second td's left wall of the current indentaion table at the 100+ point-left-side //of the item ? - if( m_indent + 100 < thisStyle.GetLeftIndent() ) + if (m_indent + 100 < thisStyle.GetLeftIndent()) { - //Yes it is + // Yes it is LIndent(thisStyle, str); m_indent = thisStyle.GetLeftIndent() - 100; m_indents.Add( m_indent ); break; } - else if( m_indent + 100 == thisStyle.GetLeftIndent() ) - break;//exact match + else if (m_indent + 100 == thisStyle.GetLeftIndent()) + break; //exact match else { - //No it is not, the second td's left wall of the current indentaion table is at the + // No it is not, the second td's left wall of the current indentaion table is at the //right side of the current item horizontally, so close it. str << wxT(""); m_indents.RemoveAt(i); - if( i < 1 ){m_indent=0; break;} + if (i < 1) + { + m_indent=0; break; + } m_indent = m_indents[i-1]; } } } void wxRichTextHTMLHandler::Indent( const wxTextAttrEx& thisStyle, wxTextOutputStream& str ) { - //As a five year experienced web developer i assure you there is no way to indent an item - //in html way, but we can use tables. - + //There is no way to indent an item in HTML, but we can use tables. + // Item -> "Hello world" + // Its Left Indentation -> 100 + // Its Left Sub-Indentation ->40 + // A typical indentation-table for the item will be construct as the following - //Item -> "Hello world" - //Its Left Indentation -> 100 - //Its Left Sub-Indentation ->40 - //A typical indentation-table for the item will be construct as the following - - //3 x nbsp = 60 - //2 x nbsp = 40 - //LSI = Left Sub Indent - //LI = Left Indent - LSI + // 3 x nbsp = 60 + // 2 x nbsp = 40 + // LSI = Left Sub Indent + // LI = Left Indent - LSI // - //------------------------------------------- - //| nbsp;|nbsp;nbsp;Hello World | - //| | | | | - //| V | V | - //| --LI-- | --LSI-- | - //------------------------------------------- + // ------------------------------------------- + // | nbsp;|nbsp;nbsp;Hello World | + // | | | | | + // | V | V | + // | --LI-- | --LSI-- | + // ------------------------------------------- str << wxT("%s | "), symbolic_indent.c_str() ); str << wxT("");
- if( thisStyle.GetLeftSubIndent() < 0 )
+ if (thisStyle.GetLeftSubIndent() < 0)
{
str << SymbolicIndent(~thisStyle.GetLeftSubIndent());
}
@@ -407,28 +423,28 @@ void wxRichTextHTMLHandler::Indent( const wxTextAttrEx& thisStyle, wxTextOutputS
void wxRichTextHTMLHandler::LIndent( const wxTextAttrEx& thisStyle, wxTextOutputStream& str )
{
- //Code:
- //r.BeginNumberedBullet(1, 200, 60);
- //r.Newline();
- //r.WriteText(wxT("first item"));
- //r.EndNumberedBullet();
- //r.BeginNumberedBullet(2, 200, 60);
- //r.Newline();
- //r.WriteText(wxT("second item."));
- //r.EndNumberedBullet();
+ // Code:
+ // r.BeginNumberedBullet(1, 200, 60);
+ // r.Newline();
+ // r.WriteText(wxT("first item"));
+ // r.EndNumberedBullet();
+ // r.BeginNumberedBullet(2, 200, 60);
+ // r.Newline();
+ // r.WriteText(wxT("second item."));
+ // r.EndNumberedBullet();
//
- //A typical indentation-table for the item will be construct as the following
+ // A typical indentation-table for the item will be construct as the following
- //1 x nbsp = 20 point
- //ULI -> 100pt (UL/OL tag indents its sub element by 100 point)
- //<--------- 100 pt ---------->|
- //------------------------------------------------------
- //| nbsp; nbsp;|
|