m_CharHeight = m_CharWidth = 0;
m_UseLink = false;
#if !wxUSE_UNICODE
+ m_nbsp = 0;
m_EncConv = NULL;
m_InputEnc = wxFONTENCODING_ISO8859_1;
m_OutputEnc = wxFONTENCODING_DEFAULT;
{
register wxChar d;
int templen = 0;
- wxChar nbsp = GetEntitiesParser()->GetCharForCode(160 /* nbsp */);
size_t lng = txt.length();
if (lng+1 > m_tmpStrBufSize)
++i, ++x;
while ( (i < end) &&
(*i == wxT('\n') || *i == wxT('\r') ||
- *i == wxT(' ')) || *i == wxT('\t') )
+ *i == wxT(' ') || *i == wxT('\t')) )
{
++i;
++x;
if (x)
{
temp[templen-1] = wxT(' ');
- DoAddText(temp, templen, nbsp);
+ DoAddText(temp, templen);
m_tmpLastWasSpace = true;
}
}
if (templen && (templen > 1 || temp[0] != wxT(' ')))
{
- DoAddText(temp, templen, nbsp);
+ DoAddText(temp, templen);
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;
templen = 0;
#if !wxUSE_UNICODE
size_t len = wxStrlen(temp);
for (size_t j = 0; j < len; j++)
{
- if (temp[j] == nbsp)
+ if (temp[j] == CUR_NBSP_VALUE)
temp[j] = wxT(' ');
}
- wxHtmlCell *c = new wxHtmlWordCell(temp, *(GetDC()));
+ wxHtmlWordCell *c = new wxHtmlWordCell(temp, *(GetDC()));
ApplyStateToCell(c);
m_Container->InsertCell(c);
- ((wxHtmlWordCell*)c)->SetPreviousWord(m_lastWordCell);
- m_lastWordCell = (wxHtmlWordCell*)c;
+ c->SetPreviousWord(m_lastWordCell);
+ m_lastWordCell = c;
}
void wxHtmlWinParser::SetFontSize(int s)
{
- if (s < 1) s = 1;
- else if (s > 7) s = 7;
+ if (s < 1)
+ s = 1;
+ else if (s > 7)
+ s = 7;
m_FontSize = s;
}
void wxHtmlWinParser::SetFontFace(const wxString& face)
{
- if (GetFontFixed()) m_FontFaceFixed = face;
- else m_FontFaceNormal = face;
+ if (GetFontFixed())
+ m_FontFaceFixed = face;
+ else
+ m_FontFaceNormal = face;
#if !wxUSE_UNICODE
if (m_InputEnc != wxFONTENCODING_DEFAULT)
#if !wxUSE_UNICODE
void wxHtmlWinParser::SetInputEncoding(wxFontEncoding enc)
{
+ // the character used for non-breakable space may change:
+ m_nbsp = 0;
+
m_InputEnc = m_OutputEnc = wxFONTENCODING_DEFAULT;
if (m_EncConv)
{
m_EncConv = NULL;
}
- if (enc == wxFONTENCODING_DEFAULT) return;
+ if (enc == wxFONTENCODING_DEFAULT)
+ return;
wxFontEncoding altfix, altnorm;
bool availfix, availnorm;
- // exact match?
availnorm = wxFontMapper::Get()->IsEncodingAvailable(enc, m_FontFaceNormal);
availfix = wxFontMapper::Get()->IsEncodingAvailable(enc, m_FontFaceFixed);
+
if (availnorm && availfix)
+ {
+ // exact match?
m_OutputEnc = enc;
+ }
- // alternatives?
else if (wxFontMapper::Get()->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, false) &&
wxFontMapper::Get()->GetAltForEncoding(enc, &altfix, m_FontFaceFixed, false) &&
altnorm == altfix)
+ {
+ // alternatives?
m_OutputEnc = altnorm;
-
- // at least normal face?
+ }
else if (availnorm)
+ {
+ // at least normal face?
m_OutputEnc = enc;
+ }
else if (wxFontMapper::Get()->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, false))
+ {
m_OutputEnc = altnorm;
-
+ }
else
{
#ifndef __WXMAC__
m_InputEnc = enc;
if (m_OutputEnc == wxFONTENCODING_DEFAULT)
+ {
GetEntitiesParser()->SetEncoding(wxFONTENCODING_SYSTEM);
+ }
else
+ {
GetEntitiesParser()->SetEncoding(m_OutputEnc);
+ }
- if (m_InputEnc == m_OutputEnc) return;
+ if (m_InputEnc == m_OutputEnc)
+ return;
m_EncConv = new wxEncodingConverter();
if (!m_EncConv->Init(m_InputEnc,