From c181287ca4b816a392987b1b3aedf02cf9f1f8b9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Thu, 25 Nov 1999 17:19:22 +0000 Subject: [PATCH] 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 --- src/html/htmlcell.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index eab1485438..71633156ea 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -73,20 +73,26 @@ bool wxHtmlCell::AdjustPagebreak(int *pagebreak) wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell() { m_Word = word; - - m_Word.Replace(wxT(" "), wxT(" "), TRUE); - m_Word.Replace(wxT("©"), wxT("(c)"), TRUE); - m_Word.Replace(wxT("""), wxT("\""), TRUE); - m_Word.Replace(wxT("<"), wxT("<"), TRUE); - m_Word.Replace(wxT(">"), wxT(">"), TRUE); - m_Word.Replace(wxT("&"), wxT("&"), TRUE); - - m_Word.Replace(wxT("  "), wxT(" "), TRUE); - m_Word.Replace(wxT("© "), wxT("(c)"), TRUE); - m_Word.Replace(wxT("" "), wxT("\""), TRUE); - m_Word.Replace(wxT("< "), wxT("<"), TRUE); - m_Word.Replace(wxT("> "), wxT(">"), TRUE); - m_Word.Replace(wxT("& "), wxT("&"), TRUE); + + if (m_Word.Find(wxT('&')) != -1) + { + static wxChar* substitutions[][3] = + { + { wxT(" "), wxT("  "), wxT(" ") }, + { wxT("©"), wxT("© "), wxT("(c)") }, + { wxT("""), wxT("" "), wxT("\"") }, + { wxT("<"), wxT("< "), wxT("<") }, + { wxT(">"), wxT("> "), wxT(">") }, + { wxT("&"), wxT("& "), wxT("&") /*this one should be last one*/ }, + { NULL, NULL, NULL } + }; + + for (int i = 0; substitutions[i][0] != NULL; i++) + { + m_Word.Replace(substitutions[i][0], substitutions[i][2], TRUE); + m_Word.Replace(substitutions[i][1], substitutions[i][2], TRUE); + } + } dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent); SetCanLiveOnPagebreak(FALSE); -- 2.45.2