]> git.saurik.com Git - wxWidgets.git/commitdiff
reduced code duplication in wxHtmlWinParser::AddText (no real change)
authorVáclav Slavík <vslavik@fastmail.fm>
Thu, 17 Nov 2005 23:35:36 +0000 (23:35 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Thu, 17 Nov 2005 23:35:36 +0000 (23:35 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36193 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/html/winpars.h
src/html/winpars.cpp

index 6bd5fa2a6b9bca43db2782e51973de3033305947..2d188ace3aeec6730fcb6291d410c17de5d3688d 100644 (file)
@@ -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;
index 7fc11a1280288ba1988c6baabe45abb2f7aed3d5..52578cc0eee46e34625d9d9995d973157fa89056 100644 (file)
@@ -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;
 }