don't recompute nonbreakable space character every time a text fragment is added in ANSI build
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48229 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
96d665d249
commit
c782096417
@ -149,7 +149,7 @@ protected:
|
|||||||
virtual void AddText(const wxString& txt);
|
virtual void AddText(const wxString& txt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DoAddText(wxChar *temp, int& templen, wxChar nbsp);
|
void DoAddText(wxChar *temp, int& templen);
|
||||||
|
|
||||||
bool m_tmpLastWasSpace;
|
bool m_tmpLastWasSpace;
|
||||||
wxChar *m_tmpStrBuf;
|
wxChar *m_tmpStrBuf;
|
||||||
@ -201,6 +201,7 @@ private:
|
|||||||
// html font sizes and faces of fixed and proportional fonts
|
// html font sizes and faces of fixed and proportional fonts
|
||||||
|
|
||||||
#if !wxUSE_UNICODE
|
#if !wxUSE_UNICODE
|
||||||
|
wxChar m_nbsp;
|
||||||
wxFontEncoding m_InputEnc, m_OutputEnc;
|
wxFontEncoding m_InputEnc, m_OutputEnc;
|
||||||
// I/O font encodings
|
// I/O font encodings
|
||||||
wxEncodingConverter *m_EncConv;
|
wxEncodingConverter *m_EncConv;
|
||||||
|
@ -47,6 +47,7 @@ wxHtmlWinParser::wxHtmlWinParser(wxHtmlWindowInterface *wndIface)
|
|||||||
m_CharHeight = m_CharWidth = 0;
|
m_CharHeight = m_CharWidth = 0;
|
||||||
m_UseLink = false;
|
m_UseLink = false;
|
||||||
#if !wxUSE_UNICODE
|
#if !wxUSE_UNICODE
|
||||||
|
m_nbsp = 0;
|
||||||
m_EncConv = NULL;
|
m_EncConv = NULL;
|
||||||
m_InputEnc = wxFONTENCODING_ISO8859_1;
|
m_InputEnc = wxFONTENCODING_ISO8859_1;
|
||||||
m_OutputEnc = wxFONTENCODING_DEFAULT;
|
m_OutputEnc = wxFONTENCODING_DEFAULT;
|
||||||
@ -346,7 +347,6 @@ void wxHtmlWinParser::AddText(const wxString& txt)
|
|||||||
{
|
{
|
||||||
register wxChar d;
|
register wxChar d;
|
||||||
int templen = 0;
|
int templen = 0;
|
||||||
wxChar nbsp = GetEntitiesParser()->GetCharForCode(160 /* nbsp */);
|
|
||||||
|
|
||||||
size_t lng = txt.length();
|
size_t lng = txt.length();
|
||||||
if (lng+1 > m_tmpStrBufSize)
|
if (lng+1 > m_tmpStrBufSize)
|
||||||
@ -391,20 +391,29 @@ void wxHtmlWinParser::AddText(const wxString& txt)
|
|||||||
if (x)
|
if (x)
|
||||||
{
|
{
|
||||||
temp[templen-1] = wxT(' ');
|
temp[templen-1] = wxT(' ');
|
||||||
DoAddText(temp, templen, nbsp);
|
DoAddText(temp, templen);
|
||||||
m_tmpLastWasSpace = true;
|
m_tmpLastWasSpace = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (templen && (templen > 1 || temp[0] != wxT(' ')))
|
if (templen && (templen > 1 || temp[0] != wxT(' ')))
|
||||||
{
|
{
|
||||||
DoAddText(temp, templen, nbsp);
|
DoAddText(temp, templen);
|
||||||
m_tmpLastWasSpace = false;
|
m_tmpLastWasSpace = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxHtmlWinParser::DoAddText(wxChar *temp, int& templen, wxChar nbsp)
|
void wxHtmlWinParser::DoAddText(wxChar *temp, int& templen)
|
||||||
{
|
{
|
||||||
|
#define NBSP_UNICODE_VALUE 160
|
||||||
|
#if !wxUSE_UNICODE
|
||||||
|
if ( m_nbsp == 0 )
|
||||||
|
m_nbsp = GetEntitiesParser()->GetCharForCode(NBSP_UNICODE_VALUE);
|
||||||
|
#define CUR_NBSP_VALUE m_nbsp
|
||||||
|
#else
|
||||||
|
#define CUR_NBSP_VALUE NBSP_UNICODE_VALUE
|
||||||
|
#endif
|
||||||
|
|
||||||
temp[templen] = 0;
|
temp[templen] = 0;
|
||||||
templen = 0;
|
templen = 0;
|
||||||
#if !wxUSE_UNICODE
|
#if !wxUSE_UNICODE
|
||||||
@ -414,7 +423,7 @@ void wxHtmlWinParser::DoAddText(wxChar *temp, int& templen, wxChar nbsp)
|
|||||||
size_t len = wxStrlen(temp);
|
size_t len = wxStrlen(temp);
|
||||||
for (size_t j = 0; j < len; j++)
|
for (size_t j = 0; j < len; j++)
|
||||||
{
|
{
|
||||||
if (temp[j] == nbsp)
|
if (temp[j] == CUR_NBSP_VALUE)
|
||||||
temp[j] = wxT(' ');
|
temp[j] = wxT(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,6 +552,9 @@ void wxHtmlWinParser::ApplyStateToCell(wxHtmlCell *cell)
|
|||||||
#if !wxUSE_UNICODE
|
#if !wxUSE_UNICODE
|
||||||
void wxHtmlWinParser::SetInputEncoding(wxFontEncoding enc)
|
void wxHtmlWinParser::SetInputEncoding(wxFontEncoding enc)
|
||||||
{
|
{
|
||||||
|
// the character used for non-breakable space may change:
|
||||||
|
m_nbsp = 0;
|
||||||
|
|
||||||
m_InputEnc = m_OutputEnc = wxFONTENCODING_DEFAULT;
|
m_InputEnc = m_OutputEnc = wxFONTENCODING_DEFAULT;
|
||||||
if (m_EncConv)
|
if (m_EncConv)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user