+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)
+ {
+ case wxBITMAP_TYPE_BMP:
+ return wxT("image/bmp");
+ case wxBITMAP_TYPE_TIF:
+ return wxT("image/tiff");
+ case wxBITMAP_TYPE_GIF:
+ return wxT("image/gif");
+ case wxBITMAP_TYPE_PNG:
+ return wxT("image/png");
+ case wxBITMAP_TYPE_JPEG:
+ return wxT("image/jpeg");
+ default:
+ return wxT("image/unknown");
+ }
+}
+
+// exim-style base64 encoder
+wxChar* wxRichTextHTMLHandler::b64enc( unsigned char* input, size_t in_len )
+{
+ // elements of enc64 array must be 8 bit values
+ // otherwise encoder will fail
+ // hmmm.. Does wxT macro define a char as 16 bit value
+ // when compiling with UNICODE option?
+ static const wxChar enc64[] = wxT("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
+ wxChar* output = new wxChar[4*((in_len+2)/3)+1];
+ wxChar* p = output;
+
+ while( in_len-- > 0 )
+ {
+ register wxChar a, b;
+
+ a = *input++;
+
+ *p++ = enc64[ (a >> 2) & 0x3f ];
+
+ if( in_len-- == 0 )
+ {
+ *p++ = enc64[ (a << 4 ) & 0x30 ];
+ *p++ = '=';
+ *p++ = '=';
+ break;
+ }
+
+ b = *input++;
+
+ *p++ = enc64[(( a << 4 ) | ((b >> 4) &0xf )) & 0x3f];
+
+ if( in_len-- == 0 )
+ {
+ *p++ = enc64[ (b << 2) & 0x3f ];
+ *p++ = '=';
+ break;
+ }
+
+ a = *input++;
+
+ *p++ = enc64[ ((( b << 2 ) & 0x3f ) | ((a >> 6)& 0x3)) & 0x3f ];
+
+ *p++ = enc64[ a & 0x3f ];
+ }
+ *p = 0;
+
+ return output;
+}