Revision: 7362
http://mahogany.svn.sourceforge.net/mahogany/?rev=7362&view=rev
Author: vadz
Date: 2007-09-07 12:42:38 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
rewrite HTML parsing code in InsertRawContents() using new wx 2.9 iterator
methods to avoid deprecation warnings due to use of wxHtmlTag::GetBegin/EndPos()
Modified Paths:
--------------
trunk/M/src/modules/HtmlViewer.cpp
Modified: trunk/M/src/modules/HtmlViewer.cpp
===================================================================
--- trunk/M/src/modules/HtmlViewer.cpp 2007-09-07 17:45:42 UTC (rev 7361)
+++ trunk/M/src/modules/HtmlViewer.cpp 2007-09-07 19:42:38 UTC (rev 7362)
@@ -1074,31 +1074,55 @@
encChanger(wxHtmlParser::ExtractCharsetInformation(data), m_htmlText);
// tag handler used to extract the <body> tag contents
+ //
+ // note that we have to use string indices with wx 2.8 but string iterators
+ // with 2.9 to avoid deprecation warnings (as index versions are much less
+ // efficient with wx 2.9)
class BodyTagHandler : public wxHtmlTagHandler
{
public:
- BodyTagHandler()
+ BodyTagHandler(const String& text)
{
// by default, take all
+#if wxCHECK_VERSION(2, 9, 0)
+ m_begin = text.begin();
+ m_end = text.end();
+#else // wx <= 2.8
m_begin = 0;
m_end = String::npos;
+
+ wxUnusedVar(text);
+#endif // wx 2.9+/2.8-
}
virtual wxString GetSupportedTags() { return "BODY"; }
virtual bool HandleTag(const wxHtmlTag& tag)
{
+ // "end 1" is the position just before the closing tag while "end 2"
+ // is after the tag, as we don't need the tag itself, use the former
+#if wxCHECK_VERSION(2, 9, 0)
+ m_begin = tag.GetBeginIter();
+ m_end = tag.GetEndIter1();
+#else // wx <= 2.8
m_begin = tag.GetBeginPos();
- m_end = tag.GetEndPos1(); // position just before the closing tag
+ m_end = tag.GetEndPos1();
+#endif // wx 2.9+/2.8-
return false;
}
- size_t GetBegin() const { return m_begin; }
- size_t GetEnd() const { return m_end; }
+#if wxCHECK_VERSION(2, 9, 0)
+ typedef wxString::const_iterator IndexType;
+#else // wx <= 2.8
+ typedef size_t IndexType;
+#endif // wx 2.9+/2.8-
+ IndexType GetBegin() const { return m_begin; }
+ IndexType GetEnd() const { return m_end; }
+
private:
- size_t m_begin,
- m_end;
+ IndexType m_begin,
+ m_end;
};
class BodyParser : public wxHtmlParser
@@ -1111,12 +1135,16 @@
virtual void AddText(const wxString& WXUNUSED(txt)) { }
};
- BodyTagHandler *handler = new BodyTagHandler;
+ BodyTagHandler *handler = new BodyTagHandler(data);
BodyParser parser;
parser.AddTagHandler(handler);
parser.Parse(data);
+#if wxCHECK_VERSION(2, 9, 0)
+ m_htmlText += wxString(handler->GetBegin(), handler->GetEnd());
+#else // wx <= 2.8
m_htmlText += data.substr(handler->GetBegin(), handler->GetEnd());
+#endif // wx 2.9+/2.8-
// set the flag for EndBody
m_hasHtmlContents = true;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates