+ return 0;
+}
+
+wxString wxRichTextHTMLHandler::GetAlignment( const wxTextAttr& thisStyle )
+{
+ switch( thisStyle.GetAlignment() )
+ {
+ case wxTEXT_ALIGNMENT_LEFT:
+ return wxT("left");
+ case wxTEXT_ALIGNMENT_RIGHT:
+ return wxT("right");
+ case wxTEXT_ALIGNMENT_CENTER:
+ return wxT("center");
+ case wxTEXT_ALIGNMENT_JUSTIFIED:
+ return wxT("justify");
+ default:
+ return wxT("left");
+ }
+}
+
+void wxRichTextHTMLHandler::WriteImage(wxRichTextImage* image, wxOutputStream& stream)
+{
+ wxTextOutputStream str(stream);
+
+ str << wxT("<img src=\"");
+
+#if wxUSE_FILESYSTEM
+ if (GetFlags() & wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY)
+ {
+ if (!image->GetImage().Ok() && image->GetImageBlock().GetData())
+ image->LoadFromBlock();
+ if (image->GetImage().Ok() && !image->GetImageBlock().GetData())
+ image->MakeBlock();
+
+ if (image->GetImage().Ok())
+ {
+ wxString ext(image->GetImageBlock().GetExtension());
+ wxString tempFilename(wxString::Format(wxT("image%d.%s"), sm_fileCounter, ext));
+ wxMemoryFSHandler::AddFile(tempFilename, image->GetImage(), image->GetImageBlock().GetImageType());
+
+ m_imageLocations.Add(tempFilename);
+
+ str << wxT("memory:") << tempFilename;
+ }
+ else
+ str << wxT("memory:?");
+
+ sm_fileCounter ++;
+ }
+ else if (GetFlags() & wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES)
+ {
+ if (!image->GetImage().Ok() && image->GetImageBlock().GetData())
+ image->LoadFromBlock();
+ if (image->GetImage().Ok() && !image->GetImageBlock().GetData())
+ image->MakeBlock();
+
+ if (image->GetImage().Ok())
+ {
+ wxString tempDir(GetTempDir());
+ if (tempDir.IsEmpty())
+ tempDir = wxFileName::GetTempDir();
+
+ wxString ext(image->GetImageBlock().GetExtension());
+ wxString tempFilename(wxString::Format(wxT("%s/image%d.%s"), tempDir, sm_fileCounter, ext));
+ image->GetImageBlock().Write(tempFilename);
+
+ m_imageLocations.Add(tempFilename);
+
+ str << wxFileSystem::FileNameToURL(tempFilename);
+ }
+ else
+ str << wxT("file:?");
+
+ sm_fileCounter ++;
+ }
+ else // if (GetFlags() & wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64) // this is implied
+#endif
+ {
+ str << wxT("data:");
+ str << GetMimeType(image->GetImageBlock().GetImageType());
+ str << wxT(";base64,");
+
+ if (image->GetImage().Ok() && !image->GetImageBlock().GetData())
+ image->MakeBlock();
+
+ wxChar* data = b64enc( image->GetImageBlock().GetData(), image->GetImageBlock().GetDataSize() );
+ str << data;
+
+ delete[] data;
+ }
+
+ str << wxT("\" />");
+}
+
+long wxRichTextHTMLHandler::PtToSize(long size)
+{
+ int i;
+ int len = m_fontSizeMapping.GetCount();
+ for (i = 0; i < len; i++)
+ if (size <= m_fontSizeMapping[i])
+ return i+1;
+ return 7;
+}
+
+wxString wxRichTextHTMLHandler::SymbolicIndent(long indent)
+{
+ wxString in;
+ for(;indent > 0; indent -= 20)
+ in.Append( wxT(" ") );
+ return in;
+}
+
+const wxChar* wxRichTextHTMLHandler::GetMimeType(int imageType)
+{
+ switch(imageType)