reduced code duplication in wxHtmlWinParser::AddText (no real change)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36193 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2005-11-17 23:35:36 +00:00
parent 46cbb21ecb
commit 97eac136f3
2 changed files with 28 additions and 32 deletions

View File

@@ -133,6 +133,8 @@ protected:
virtual void AddText(const wxChar* txt); virtual void AddText(const wxChar* txt);
private: private:
void DoAddText(wxChar *temp, int& templen, wxChar nbsp);
bool m_tmpLastWasSpace; bool m_tmpLastWasSpace;
wxChar *m_tmpStrBuf; wxChar *m_tmpStrBuf;
size_t m_tmpStrBufSize; size_t m_tmpStrBufSize;

View File

@@ -300,7 +300,6 @@ wxFSFile *wxHtmlWinParser::OpenURL(wxHtmlURLType type,
void wxHtmlWinParser::AddText(const wxChar* txt) void wxHtmlWinParser::AddText(const wxChar* txt)
{ {
wxHtmlCell *c;
size_t i = 0, size_t i = 0,
x, x,
lng = wxStrlen(txt); lng = wxStrlen(txt);
@@ -338,6 +337,20 @@ void wxHtmlWinParser::AddText(const wxChar* txt)
if (x) if (x)
{ {
temp[templen-1] = wxT(' '); temp[templen-1] = wxT(' ');
DoAddText(temp, templen, nbsp);
m_tmpLastWasSpace = true;
}
}
if (templen && (templen > 1 || temp[0] != wxT(' ')))
{
DoAddText(temp, templen, nbsp);
m_tmpLastWasSpace = false;
}
}
void wxHtmlWinParser::DoAddText(wxChar *temp, int& templen, wxChar nbsp)
{
temp[templen] = 0; temp[templen] = 0;
templen = 0; templen = 0;
#if !wxUSE_UNICODE #if !wxUSE_UNICODE
@@ -346,37 +359,18 @@ void wxHtmlWinParser::AddText(const wxChar* txt)
#endif #endif
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] == nbsp)
temp[j] = wxT(' '); temp[j] = wxT(' ');
c = new wxHtmlWordCell(temp, *(GetDC()));
if (m_UseLink)
c->SetLink(m_Link);
m_Container->InsertCell(c);
((wxHtmlWordCell*)c)->SetPreviousWord(m_lastWordCell);
m_lastWordCell = (wxHtmlWordCell*)c;
m_tmpLastWasSpace = true;
}
} }
if (templen && (templen > 1 || temp[0] != wxT(' '))) wxHtmlCell *c = new wxHtmlWordCell(temp, *(GetDC()));
{
temp[templen] = 0;
#if !wxUSE_UNICODE
if (m_EncConv)
m_EncConv->Convert(temp);
#endif
size_t len = wxStrlen(temp);
for (size_t j = 0; j < len; j++)
if (temp[j] == nbsp)
temp[j] = wxT(' ');
c = new wxHtmlWordCell(temp, *(GetDC()));
if (m_UseLink) if (m_UseLink)
c->SetLink(m_Link); c->SetLink(m_Link);
m_Container->InsertCell(c); m_Container->InsertCell(c);
((wxHtmlWordCell*)c)->SetPreviousWord(m_lastWordCell); ((wxHtmlWordCell*)c)->SetPreviousWord(m_lastWordCell);
m_lastWordCell = (wxHtmlWordCell*)c; m_lastWordCell = (wxHtmlWordCell*)c;
m_tmpLastWasSpace = false;
}
} }