From 4bfa3189651bd06b6866eb220075bbd134b690c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Thu, 16 Dec 2004 20:32:43 +0000 Subject: [PATCH] Send full url to wxHtmlWindow::OnOpeningURL validation (and therefore use wxURL to not duplicate code). Present it in statusbar of samples/html/test application. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31033 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/samples/gizmos/dynsash/dynsash.bkl | 1 + contrib/samples/ogl/studio/studio.bkl | 1 + contrib/utils/wxrcedit/wxrcedit.bkl | 1 + demos/dbbrowse/dbbrowse.bkl | 1 + demos/forty/forty.bkl | 1 + demos/poem/poem.bkl | 1 + samples/help/help.bkl | 1 + samples/htlbox/htlbox.bkl | 1 + samples/html/about/about.bkl | 1 + samples/html/help/help.bkl | 1 + samples/html/helpview/helpview.bkl | 1 + samples/html/printing/printing.bkl | 1 + samples/html/test/test.cpp | 28 ++++++++++++++-- samples/html/virtual/virtual.bkl | 1 + samples/html/widget/widget.bkl | 1 + samples/html/zip/zip.bkl | 1 + samples/xrc/xrcdemo.bkl | 1 + src/html/winpars.cpp | 38 ++++++++++++++++++++-- utils/configtool/src/configtool.bkl | 1 + utils/hhp2cached/hhp2cached.bkl | 1 + utils/tex2rtf/src/tex2rtf.bkl | 1 + 21 files changed, 79 insertions(+), 6 deletions(-) diff --git a/contrib/samples/gizmos/dynsash/dynsash.bkl b/contrib/samples/gizmos/dynsash/dynsash.bkl index 640ba00078..ab6cddf118 100644 --- a/contrib/samples/gizmos/dynsash/dynsash.bkl +++ b/contrib/samples/gizmos/dynsash/dynsash.bkl @@ -11,6 +11,7 @@ gizmos html core + net base diff --git a/contrib/samples/ogl/studio/studio.bkl b/contrib/samples/ogl/studio/studio.bkl index 7f8acf13a5..48a1737a63 100644 --- a/contrib/samples/ogl/studio/studio.bkl +++ b/contrib/samples/ogl/studio/studio.bkl @@ -23,6 +23,7 @@ adv html core + net base studio.rc diff --git a/contrib/utils/wxrcedit/wxrcedit.bkl b/contrib/utils/wxrcedit/wxrcedit.bkl index 804ac66a57..cd1d2f0572 100644 --- a/contrib/utils/wxrcedit/wxrcedit.bkl +++ b/contrib/utils/wxrcedit/wxrcedit.bkl @@ -23,6 +23,7 @@ html core xml + net base wxrcedit.rc $(EXTRALIBS_XML) diff --git a/demos/dbbrowse/dbbrowse.bkl b/demos/dbbrowse/dbbrowse.bkl index e00c06a951..53ea35bf66 100644 --- a/demos/dbbrowse/dbbrowse.bkl +++ b/demos/dbbrowse/dbbrowse.bkl @@ -19,6 +19,7 @@ odbc html core + net base dbbrowse.rc diff --git a/demos/forty/forty.bkl b/demos/forty/forty.bkl index 3296588c40..cc5ac9a99a 100644 --- a/demos/forty/forty.bkl +++ b/demos/forty/forty.bkl @@ -17,6 +17,7 @@ html adv core + net base forty.rc diff --git a/demos/poem/poem.bkl b/demos/poem/poem.bkl index 546b1165e1..8143cf0b69 100644 --- a/demos/poem/poem.bkl +++ b/demos/poem/poem.bkl @@ -7,6 +7,7 @@ wxpoem.cpp html core + net base wxpoem.rc diff --git a/samples/help/help.bkl b/samples/help/help.bkl index fa12112403..edb5d35d4d 100644 --- a/samples/help/help.bkl +++ b/samples/help/help.bkl @@ -7,6 +7,7 @@ demo.cpp html core + net base demo.rc diff --git a/samples/htlbox/htlbox.bkl b/samples/htlbox/htlbox.bkl index 3105bc4d6b..5c417b995c 100644 --- a/samples/htlbox/htlbox.bkl +++ b/samples/htlbox/htlbox.bkl @@ -7,6 +7,7 @@ htlbox.cpp html core + net base htlbox.rc diff --git a/samples/html/about/about.bkl b/samples/html/about/about.bkl index 473530efee..11b5b7fff9 100644 --- a/samples/html/about/about.bkl +++ b/samples/html/about/about.bkl @@ -9,6 +9,7 @@ about.cpp html core + net base about.rc diff --git a/samples/html/help/help.bkl b/samples/html/help/help.bkl index 6bc0a74eb0..771ea1978a 100644 --- a/samples/html/help/help.bkl +++ b/samples/html/help/help.bkl @@ -9,6 +9,7 @@ help.cpp html core + net base help.rc diff --git a/samples/html/helpview/helpview.bkl b/samples/html/helpview/helpview.bkl index a04699656e..5edc6d4d36 100644 --- a/samples/html/helpview/helpview.bkl +++ b/samples/html/helpview/helpview.bkl @@ -9,6 +9,7 @@ helpview.cpp html core + net base helpview.rc diff --git a/samples/html/printing/printing.bkl b/samples/html/printing/printing.bkl index 37e7f0ad19..5115f0f724 100644 --- a/samples/html/printing/printing.bkl +++ b/samples/html/printing/printing.bkl @@ -9,6 +9,7 @@ printing.cpp html core + net base adv printing.rc diff --git a/samples/html/test/test.cpp b/samples/html/test/test.cpp index 50e10402e4..d3efde3d9e 100644 --- a/samples/html/test/test.cpp +++ b/samples/html/test/test.cpp @@ -44,6 +44,20 @@ public: virtual bool OnInit(); }; +// Define a new html window type: this is a wrapper for handling wxHtmlWindow events +class MyHtmlWindow : public wxHtmlWindow +{ +public: + MyHtmlWindow(wxWindow *parent) : wxHtmlWindow( parent ) { } + + virtual wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType WXUNUSED(type), + const wxString& WXUNUSED(url), + wxString *WXUNUSED(redirect)) const; + +private: + DECLARE_NO_COPY_CLASS(MyHtmlWindow) +}; + // Define a new frame type: this is going to be our main frame class MyFrame : public wxFrame { @@ -59,7 +73,7 @@ public: void OnProcessor(wxCommandEvent& event); private: - wxHtmlWindow *m_Html; + MyHtmlWindow *m_Html; wxHtmlProcessor *m_Processor; // Any class wishing to process wxWidgets events must use this macro @@ -185,12 +199,12 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) #endif // wxUSE_ACCEL #if wxUSE_STATUSBAR - CreateStatusBar(1); + CreateStatusBar(2); #endif // wxUSE_STATUSBAR m_Processor = new BoldProcessor; m_Processor->Enable(false); - m_Html = new wxHtmlWindow(this); + m_Html = new MyHtmlWindow(this); m_Html->SetRelatedFrame(this, _("HTML : %s")); #if wxUSE_STATUSBAR m_Html->SetRelatedStatusBar(0); @@ -242,3 +256,11 @@ void MyFrame::OnProcessor(wxCommandEvent& WXUNUSED(event)) m_Processor->Enable(!m_Processor->IsEnabled()); m_Html->LoadPage(m_Html->GetOpenedPage()); } + +wxHtmlOpeningStatus MyHtmlWindow::OnOpeningURL(wxHtmlURLType WXUNUSED(type), + const wxString& url, + wxString *WXUNUSED(redirect)) const +{ + GetRelatedFrame()->SetStatusText(url + _T(" lately opened"),1); + return wxHTML_OPEN; +} diff --git a/samples/html/virtual/virtual.bkl b/samples/html/virtual/virtual.bkl index 10c045e6a6..fc8ea5eca0 100644 --- a/samples/html/virtual/virtual.bkl +++ b/samples/html/virtual/virtual.bkl @@ -9,6 +9,7 @@ virtual.cpp html core + net base virtual.rc diff --git a/samples/html/widget/widget.bkl b/samples/html/widget/widget.bkl index 82e8e709ca..bba4e6319d 100644 --- a/samples/html/widget/widget.bkl +++ b/samples/html/widget/widget.bkl @@ -9,6 +9,7 @@ widget.cpp html core + net base widget.rc diff --git a/samples/html/zip/zip.bkl b/samples/html/zip/zip.bkl index dbf4125afd..c5d40d2756 100644 --- a/samples/html/zip/zip.bkl +++ b/samples/html/zip/zip.bkl @@ -9,6 +9,7 @@ zip.cpp html core + net base zip.rc diff --git a/samples/xrc/xrcdemo.bkl b/samples/xrc/xrcdemo.bkl index 0d008d4951..a2497944d4 100644 --- a/samples/xrc/xrcdemo.bkl +++ b/samples/xrc/xrcdemo.bkl @@ -15,6 +15,7 @@ adv core xml + net base xrcdemo.rc diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp index 344ade10a0..ff3f4ea0bd 100644 --- a/src/html/winpars.cpp +++ b/src/html/winpars.cpp @@ -32,6 +32,7 @@ #include "wx/fontmap.h" #include "wx/log.h" #include "wx/settings.h" +#include "wx/url.h" //----------------------------------------------------------------------------- @@ -248,16 +249,47 @@ wxObject* wxHtmlWinParser::GetProduct() wxFSFile *wxHtmlWinParser::OpenURL(wxHtmlURLType type, const wxString& url) const { - // FIXME - normalize the URL to full path before passing to - // OnOpeningURL!! if ( m_Window ) { wxString myurl(url); wxHtmlOpeningStatus status; for (;;) { + wxString myfullurl(myurl); + +#if wxUSE_URL + // consider url as absolute path first + wxURL current(wxURL::Unescape(myurl)); + myfullurl = current.GetURL(); + + // if not absolute then ... + if( current.IsReference() ) + { + wxString basepath = GetFS()->GetPath(); + wxURI base(wxURL::Unescape(basepath)); + + // try to apply base path if valid ... + if( !base.IsReference() ) + { + wxURI path(myfullurl); + path.Resolve( base ); + myfullurl = path.BuildURI(); + } + else + { + // ... or force such addition if not included already + if( !current.GetURL().Contains(basepath) ) + { + basepath += myurl; + wxURL connected( wxURL::Unescape(basepath) ); + myfullurl = connected.GetURL(); + } + } + } +#endif + wxString redirect; - status = m_Window->OnOpeningURL(type, myurl, &redirect); + status = m_Window->OnOpeningURL(type, myfullurl, &redirect); if ( status != wxHTML_REDIRECT ) break; diff --git a/utils/configtool/src/configtool.bkl b/utils/configtool/src/configtool.bkl index efc0c5b039..fcc06aaa78 100644 --- a/utils/configtool/src/configtool.bkl +++ b/utils/configtool/src/configtool.bkl @@ -27,6 +27,7 @@ html core xml + net base diff --git a/utils/hhp2cached/hhp2cached.bkl b/utils/hhp2cached/hhp2cached.bkl index 388ecbd517..5535d6a251 100644 --- a/utils/hhp2cached/hhp2cached.bkl +++ b/utils/hhp2cached/hhp2cached.bkl @@ -12,6 +12,7 @@ hhp2cached.rc html core + net base $(BINDIR) diff --git a/utils/tex2rtf/src/tex2rtf.bkl b/utils/tex2rtf/src/tex2rtf.bkl index 50c86a4392..e433ca26c2 100644 --- a/utils/tex2rtf/src/tex2rtf.bkl +++ b/utils/tex2rtf/src/tex2rtf.bkl @@ -30,6 +30,7 @@ $(TEX2RTF_SRC) html core + net base $(BINDIR) -- 2.45.2