#endif
#ifndef WXPRECOMP
-#include "wx/wx.h"
+ #include "wx/log.h"
+ #include "wx/intl.h"
#endif
#include "wx/tokenzr.h"
IMPLEMENT_ABSTRACT_CLASS(wxHtmlParser,wxObject)
-wxHtmlParser::wxHtmlParser()
- : wxObject(), m_Cache(NULL), m_HandlersHash(wxKEY_STRING),
+wxHtmlParser::wxHtmlParser()
+ : wxObject(), m_Cache(NULL), m_HandlersHash(wxKEY_STRING),
m_FS(NULL), m_HandlersStack(NULL)
{
m_entitiesParser = new wxHtmlEntitiesParser;
templen = 0;
i = begin_pos;
- while (i < end_pos)
+ while (i < end_pos)
{
c = m_Source[(unsigned int) i];
// continue building word:
- if (c != '<')
+ if (c != '<')
{
temp[templen++] = c;
i++;
}
- else if (c == '<')
+ else if (c == '<')
{
- wxHtmlTag tag(m_Source, i, end_pos, m_Cache);
+ wxHtmlTag tag(m_Source, i, end_pos, m_Cache, m_entitiesParser);
- if (templen)
+ if (templen)
{
temp[templen] = 0;
AddText(temp);
}
}
- if (templen)
+ if (templen)
{ // last word of block :-(
temp[templen] = 0;
AddText(temp);
h = (wxHtmlTagHandler*) m_HandlersHash.Get(tag.GetName());
if (h)
inner = h->HandleTag(tag);
- if (!inner)
+ if (!inner)
{
if (tag.HasEnding())
DoParsing(tag.GetBeginPos(), tag.GetEndPos1());
wxStringTokenizer tokenizer(tags, ", ");
wxString key;
- if (m_HandlersStack == NULL)
+ if (m_HandlersStack == NULL)
{
m_HandlersStack = new wxList;
m_HandlersStack->DeleteContents(TRUE);
m_HandlersStack->Insert(new wxHashTable(m_HandlersHash));
- while (tokenizer.HasMoreTokens())
+ while (tokenizer.HasMoreTokens())
{
key = tokenizer.NextToken();
m_HandlersHash.Delete(key);
void wxHtmlParser::PopTagHandler()
{
wxNode *first;
-
- if (m_HandlersStack == NULL ||
- (first = m_HandlersStack->GetFirst()) == NULL)
+
+ if (m_HandlersStack == NULL ||
+ (first = m_HandlersStack->GetFirst()) == NULL)
{
wxLogWarning(_("Warning: attempt to remove HTML tag handler from empty stack."));
return;
wxHtmlEntitiesParser::~wxHtmlEntitiesParser()
{
+#if wxUSE_WCHAR_T && !wxUSE_UNICODE
delete m_conv;
+#endif
}
void wxHtmlEntitiesParser::SetEncoding(wxFontEncoding encoding)
const wxChar *c, *last;
const wxChar *in_str = input.c_str();
wxString output;
-
+
for (c = in_str, last = in_str; *c != wxT('\0'); c++)
{
if (*c == wxT('&'))
unsigned code;
};
-static int compar_entity(const void *key, const void *item)
+static int LINKAGEMODE compar_entity(const void *key, const void *item)
{
return wxStrcmp((wxChar*)key, ((wxHtmlEntityInfo*)item)->name);
}
wxChar wxHtmlEntitiesParser::GetEntityChar(const wxString& entity)
{
unsigned code = 0;
-
+
if (entity[0] == wxT('#'))
{
const wxChar *ent_s = entity.c_str();
const wxChar *format;
-
+
if (ent_s[1] == wxT('x') || ent_s[1] == wxT('X'))
{
format = wxT("%x");
{ wxT("zwnj"),8204 },
{NULL, 0}};
static size_t substitutions_cnt = 0;
-
+
if (substitutions_cnt == 0)
while (substitutions[substitutions_cnt].code != 0)
substitutions_cnt++;
wxHtmlEntityInfo *info;
- info = (wxHtmlEntityInfo*) bsearch(entity.c_str(), substitutions,
+ info = (wxHtmlEntityInfo*) bsearch(entity.c_str(), substitutions,
substitutions_cnt,
sizeof(wxHtmlEntityInfo),
compar_entity);
if (info)
code = info->code;
}
-
+
if (code == 0)
return wxT('?');
else