From 97eac136f38a16dcd181b7e6c062c079d43a7702 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Thu, 17 Nov 2005 23:35:36 +0000 Subject: [PATCH] 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 --- include/wx/html/winpars.h | 2 ++ src/html/winpars.cpp | 56 +++++++++++++++++---------------------- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/include/wx/html/winpars.h b/include/wx/html/winpars.h index 6bd5fa2a6b..2d188ace3a 100644 --- a/include/wx/html/winpars.h +++ b/include/wx/html/winpars.h @@ -133,6 +133,8 @@ protected: virtual void AddText(const wxChar* txt); private: + void DoAddText(wxChar *temp, int& templen, wxChar nbsp); + bool m_tmpLastWasSpace; wxChar *m_tmpStrBuf; size_t m_tmpStrBufSize; diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp index 7fc11a1280..52578cc0ee 100644 --- a/src/html/winpars.cpp +++ b/src/html/winpars.cpp @@ -300,7 +300,6 @@ wxFSFile *wxHtmlWinParser::OpenURL(wxHtmlURLType type, void wxHtmlWinParser::AddText(const wxChar* txt) { - wxHtmlCell *c; size_t i = 0, x, lng = wxStrlen(txt); @@ -338,45 +337,40 @@ void wxHtmlWinParser::AddText(const wxChar* txt) if (x) { temp[templen-1] = wxT(' '); - temp[templen] = 0; - 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) - c->SetLink(m_Link); - m_Container->InsertCell(c); - ((wxHtmlWordCell*)c)->SetPreviousWord(m_lastWordCell); - m_lastWordCell = (wxHtmlWordCell*)c; + DoAddText(temp, templen, nbsp); m_tmpLastWasSpace = true; } } if (templen && (templen > 1 || temp[0] != wxT(' '))) { - temp[templen] = 0; + DoAddText(temp, templen, nbsp); + m_tmpLastWasSpace = false; + } +} + +void wxHtmlWinParser::DoAddText(wxChar *temp, int& templen, wxChar nbsp) +{ + temp[templen] = 0; + templen = 0; #if !wxUSE_UNICODE - if (m_EncConv) - m_EncConv->Convert(temp); + 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) - c->SetLink(m_Link); - m_Container->InsertCell(c); - ((wxHtmlWordCell*)c)->SetPreviousWord(m_lastWordCell); - m_lastWordCell = (wxHtmlWordCell*)c; - m_tmpLastWasSpace = false; + size_t len = wxStrlen(temp); + for (size_t j = 0; j < len; j++) + { + if (temp[j] == nbsp) + temp[j] = wxT(' '); } + + wxHtmlCell *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; } -- 2.45.2