]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/winpars.cpp
Fixed MDI context menu event handling problem (Stefan Kowski)
[wxWidgets.git] / src / html / winpars.cpp
index ff3f4ea0bd1fbf6c09f4f68f8a50beac9c9b0ad3..52578cc0eee46e34625d9d9995d973157fa89056 100644 (file)
@@ -7,11 +7,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "winpars.h"
-#endif
-
 #include "wx/wxprec.h"
 
 #include "wx/defs.h"
 #include "wx/wxprec.h"
 
 #include "wx/defs.h"
@@ -32,7 +27,7 @@
 #include "wx/fontmap.h"
 #include "wx/log.h"
 #include "wx/settings.h"
 #include "wx/fontmap.h"
 #include "wx/log.h"
 #include "wx/settings.h"
-#include "wx/url.h"
+#include "wx/uri.h"
 
 
 //-----------------------------------------------------------------------------
 
 
 //-----------------------------------------------------------------------------
@@ -116,7 +111,7 @@ void wxHtmlWinParser::RemoveModule(wxHtmlTagsModule *module)
     m_Modules.DeleteObject(module);
 }
 
     m_Modules.DeleteObject(module);
 }
 
-void wxHtmlWinParser::SetFonts(wxString normal_face, wxString fixed_face,
+void wxHtmlWinParser::SetFonts(const wxString& normal_face, const wxString& fixed_face,
                                const int *sizes)
 {
     static int default_sizes[7] =
                                const int *sizes)
 {
     static int default_sizes[7] =
@@ -193,7 +188,7 @@ void wxHtmlWinParser::InitParser(const wxString& source)
                  */
 
     m_UseLink = false;
                  */
 
     m_UseLink = false;
-    m_Link = wxHtmlLinkInfo( wxT(""), wxT("") );
+    m_Link = wxHtmlLinkInfo( wxEmptyString );
     m_LinkColor.Set(0, 0, 0xFF);
     m_ActualColor.Set(0, 0, 0);
     m_Align = wxHTML_ALIGN_LEFT;
     m_LinkColor.Set(0, 0, 0xFF);
     m_ActualColor.Set(0, 0, 0);
     m_Align = wxHTML_ALIGN_LEFT;
@@ -257,36 +252,34 @@ wxFSFile *wxHtmlWinParser::OpenURL(wxHtmlURLType type,
         {
             wxString myfullurl(myurl);
 
         {
             wxString myfullurl(myurl);
 
-#if wxUSE_URL
             // consider url as absolute path first
             // consider url as absolute path first
-            wxURL current(wxURL::Unescape(myurl));
-            myfullurl = current.GetURL();
+            wxURI current(myurl);
+            myfullurl = current.BuildUnescapedURI();
 
             // if not absolute then ...
             if( current.IsReference() )
             {
                 wxString basepath = GetFS()->GetPath();
 
             // if not absolute then ...
             if( current.IsReference() )
             {
                 wxString basepath = GetFS()->GetPath();
-                wxURI base(wxURL::Unescape(basepath));
+                wxURI base(basepath);
 
 
-                // try to apply base path if valid ...
+                // ... try to apply base path if valid ...
                 if( !base.IsReference() )
                 {
                     wxURI path(myfullurl);
                     path.Resolve( base );
                 if( !base.IsReference() )
                 {
                     wxURI path(myfullurl);
                     path.Resolve( base );
-                    myfullurl = path.BuildURI();
+                    myfullurl = path.BuildUnescapedURI();
                 }
                 else
                 {
                     // ... or force such addition if not included already
                 }
                 else
                 {
                     // ... or force such addition if not included already
-                    if( !current.GetURL().Contains(basepath) )
+                    if( !current.GetPath().Contains(base.GetPath()) )
                     {
                         basepath += myurl;
                     {
                         basepath += myurl;
-                        wxURL connected( wxURL::Unescape(basepath) );
-                        myfullurl = connected.GetURL();
+                        wxURI connected( basepath );
+                        myfullurl = connected.BuildUnescapedURI();
                     }
                 }
             }
                     }
                 }
             }
-#endif
 
             wxString redirect;
             status = m_Window->OnOpeningURL(type, myfullurl, &redirect);
 
             wxString redirect;
             status = m_Window->OnOpeningURL(type, myfullurl, &redirect);
@@ -307,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,
            x,
            lng = wxStrlen(txt);
     size_t i = 0,
            x,
            lng = wxStrlen(txt);
@@ -345,45 +337,40 @@ void wxHtmlWinParser::AddText(const wxChar* txt)
         if (x)
         {
             temp[templen-1] = wxT(' ');
         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(' ')))
     {
             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 !wxUSE_UNICODE
-        if (m_EncConv)
-            m_EncConv->Convert(temp);
+    if (m_EncConv)
+        m_EncConv->Convert(temp);
 #endif
 #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;
 }
 
 
 }