a bit better solution for ©,  etc. (in terms of speed)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4691 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
1999-11-25 17:19:22 +00:00
parent 6919c53fd2
commit c181287ca4

View File

@@ -74,19 +74,25 @@ wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell()
{ {
m_Word = word; m_Word = word;
m_Word.Replace(wxT(" "), wxT(" "), TRUE); if (m_Word.Find(wxT('&')) != -1)
m_Word.Replace(wxT("©"), wxT("(c)"), TRUE); {
m_Word.Replace(wxT("""), wxT("\""), TRUE); static wxChar* substitutions[][3] =
m_Word.Replace(wxT("&lt;"), wxT("<"), TRUE); {
m_Word.Replace(wxT("&gt;"), wxT(">"), TRUE); { wxT("&nbsp;"), wxT("&nbsp "), wxT(" ") },
m_Word.Replace(wxT("&amp;"), wxT("&"), TRUE); { wxT("&copy;"), wxT("&copy "), wxT("(c)") },
{ wxT("&quot;"), wxT("&quot "), wxT("\"") },
{ wxT("&lt;"), wxT("&lt "), wxT("<") },
{ wxT("&gt;"), wxT("&gt "), wxT(">") },
{ wxT("&amp;"), wxT("&amp "), wxT("&") /*this one should be last one*/ },
{ NULL, NULL, NULL }
};
m_Word.Replace(wxT("&nbsp "), wxT(" "), TRUE); for (int i = 0; substitutions[i][0] != NULL; i++)
m_Word.Replace(wxT("&copy "), wxT("(c)"), TRUE); {
m_Word.Replace(wxT("&quot "), wxT("\""), TRUE); m_Word.Replace(substitutions[i][0], substitutions[i][2], TRUE);
m_Word.Replace(wxT("&lt "), wxT("<"), TRUE); m_Word.Replace(substitutions[i][1], substitutions[i][2], TRUE);
m_Word.Replace(wxT("&gt "), wxT(">"), TRUE); }
m_Word.Replace(wxT("&amp "), wxT("&"), TRUE); }
dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent); dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent);
SetCanLiveOnPagebreak(FALSE); SetCanLiveOnPagebreak(FALSE);