]> git.saurik.com Git - wxWidgets.git/blame - src/html/winpars.cpp
Upport: Always use GdkPixbuf in wxBitmapButton
[wxWidgets.git] / src / html / winpars.cpp
CommitLineData
5526e819 1/////////////////////////////////////////////////////////////////////////////
93763ad5 2// Name: src/html/winpars.cpp
5526e819
VS
3// Purpose: wxHtmlParser class (generic parser)
4// Author: Vaclav Slavik
69941f05 5// RCS-ID: $Id$
5526e819 6// Copyright: (c) 1999 Vaclav Slavik
65571936 7// Licence: wxWindows licence
5526e819
VS
8/////////////////////////////////////////////////////////////////////////////
9
3096bd2f 10#include "wx/wxprec.h"
5526e819 11
2b5f62a0 12#ifdef __BORLANDC__
93763ad5 13 #pragma hdrstop
5526e819
VS
14#endif
15
93763ad5
WS
16#if wxUSE_HTML && wxUSE_STREAMS
17
b4f4d3dd 18#ifndef WX_PRECOMP
04dbb646
VZ
19 #include "wx/intl.h"
20 #include "wx/dc.h"
e4db172a 21 #include "wx/log.h"
9eddec69 22 #include "wx/settings.h"
5526e819
VS
23#endif
24
69941f05
VS
25#include "wx/html/htmldefs.h"
26#include "wx/html/winpars.h"
27#include "wx/html/htmlwin.h"
b250d384 28#include "wx/fontmap.h"
3ec372c8 29#include "wx/uri.h"
5526e819
VS
30
31
32//-----------------------------------------------------------------------------
33// wxHtmlWinParser
34//-----------------------------------------------------------------------------
35
4f44ea36 36IMPLEMENT_ABSTRACT_CLASS(wxHtmlWinParser, wxHtmlParser)
5526e819
VS
37
38wxList wxHtmlWinParser::m_Modules;
39
bc55e31b 40wxHtmlWinParser::wxHtmlWinParser(wxHtmlWindowInterface *wndIface)
5526e819 41{
211dfedd
VS
42 m_tmpStrBuf = NULL;
43 m_tmpStrBufSize = 0;
bc55e31b 44 m_windowInterface = wndIface;
5526e819
VS
45 m_Container = NULL;
46 m_DC = NULL;
47 m_CharHeight = m_CharWidth = 0;
d1da8872 48 m_UseLink = false;
2b5f62a0 49#if !wxUSE_UNICODE
b250d384 50 m_EncConv = NULL;
2b5f62a0
VZ
51 m_InputEnc = wxFONTENCODING_ISO8859_1;
52 m_OutputEnc = wxFONTENCODING_DEFAULT;
53#endif
b6d93b26 54 m_lastWordCell = NULL;
5526e819
VS
55
56 {
57 int i, j, k, l, m;
58 for (i = 0; i < 2; i++)
59 for (j = 0; j < 2; j++)
60 for (k = 0; k < 2; k++)
61 for (l = 0; l < 2; l++)
3c8c8da2 62 for (m = 0; m < 7; m++)
e3c7fd79 63 {
5526e819 64 m_FontsTable[i][j][k][l][m] = NULL;
f1ad10f3 65 m_FontsFacesTable[i][j][k][l][m] = wxEmptyString;
2b5f62a0 66#if !wxUSE_UNICODE
b250d384 67 m_FontsEncTable[i][j][k][l][m] = wxFONTENCODING_DEFAULT;
2b5f62a0 68#endif
f1ad10f3 69 }
4eecf115
VS
70
71 SetFonts(wxEmptyString, wxEmptyString, NULL);
5526e819
VS
72 }
73
74 // fill in wxHtmlParser's tables:
222ed1d6 75 wxList::compatibility_iterator node = m_Modules.GetFirst();
3c8c8da2 76 while (node)
4f9297b0
VS
77 {
78 wxHtmlTagsModule *mod = (wxHtmlTagsModule*) node->GetData();
79 mod->FillHandlersTable(this);
80 node = node->GetNext();
5526e819
VS
81 }
82}
83
b250d384
VS
84wxHtmlWinParser::~wxHtmlWinParser()
85{
86 int i, j, k, l, m;
87
88 for (i = 0; i < 2; i++)
89 for (j = 0; j < 2; j++)
90 for (k = 0; k < 2; k++)
91 for (l = 0; l < 2; l++)
3c8c8da2 92 for (m = 0; m < 7; m++)
e3c7fd79 93 {
3c8c8da2 94 if (m_FontsTable[i][j][k][l][m] != NULL)
b250d384
VS
95 delete m_FontsTable[i][j][k][l][m];
96 }
2b5f62a0 97#if !wxUSE_UNICODE
211dfedd 98 delete m_EncConv;
2b5f62a0 99#endif
211dfedd 100 delete[] m_tmpStrBuf;
b250d384
VS
101}
102
5526e819
VS
103void wxHtmlWinParser::AddModule(wxHtmlTagsModule *module)
104{
105 m_Modules.Append(module);
106}
107
f6bcfd97
BP
108void wxHtmlWinParser::RemoveModule(wxHtmlTagsModule *module)
109{
110 m_Modules.DeleteObject(module);
111}
112
ba804ab2
VZ
113// build all HTML font sizes (1..7) from the given base size
114static void wxBuildFontSizes(int *sizes, int size)
115{
116 // using a fixed factor (1.2, from CSS2) is a bad idea as explained at
117 // http://www.w3.org/TR/CSS21/fonts.html#font-size-props but this is by far
118 // simplest thing to do so still do it like this for now
1d203ed8 119 sizes[0] = int(size * 0.75); // exception to 1.2 rule, otherwise too small
ba804ab2
VZ
120 sizes[1] = int(size * 0.83);
121 sizes[2] = size;
122 sizes[3] = int(size * 1.2);
123 sizes[4] = int(size * 1.44);
124 sizes[5] = int(size * 1.73);
125 sizes[6] = int(size * 2);
126}
127
1d203ed8
VZ
128static int wxGetDefaultHTMLFontSize()
129{
130 // base the default font size on the size of the default system font but
131 // also ensure that we have a font of reasonable size, otherwise small HTML
132 // fonts are unreadable
133 int size = wxNORMAL_FONT->GetPointSize();
134 if ( size < 10 )
135 size = 10;
136 return size;
137}
138
ba804ab2
VZ
139void wxHtmlWinParser::SetFonts(const wxString& normal_face,
140 const wxString& fixed_face,
4eecf115 141 const int *sizes)
5526e819 142{
ba804ab2
VZ
143 static int default_sizes[7] = { 0 };
144 if ( !sizes )
145 {
146 if ( !default_sizes[0] )
1d203ed8 147 wxBuildFontSizes(default_sizes, wxGetDefaultHTMLFontSize());
ba804ab2
VZ
148
149 sizes = default_sizes;
150 }
4eecf115 151
c9f56e70
VS
152 int i, j, k, l, m;
153
ba804ab2
VZ
154 for (i = 0; i < 7; i++)
155 m_FontsSizes[i] = sizes[i];
156
5526e819
VS
157 m_FontFaceFixed = fixed_face;
158 m_FontFaceNormal = normal_face;
3c8c8da2 159
2b5f62a0 160#if !wxUSE_UNICODE
b250d384 161 SetInputEncoding(m_InputEnc);
2b5f62a0 162#endif
c9f56e70
VS
163
164 for (i = 0; i < 2; i++)
165 for (j = 0; j < 2; j++)
166 for (k = 0; k < 2; k++)
167 for (l = 0; l < 2; l++)
168 for (m = 0; m < 7; m++) {
3c8c8da2 169 if (m_FontsTable[i][j][k][l][m] != NULL)
e3c7fd79 170 {
c9f56e70
VS
171 delete m_FontsTable[i][j][k][l][m];
172 m_FontsTable[i][j][k][l][m] = NULL;
173 }
174 }
5526e819
VS
175}
176
10e5c7ea
VS
177void wxHtmlWinParser::SetStandardFonts(int size,
178 const wxString& normal_face,
179 const wxString& fixed_face)
7acd3625 180{
ba804ab2 181 if (size == -1)
1d203ed8 182 size = wxGetDefaultHTMLFontSize();
d1da8872 183
7acd3625 184 int f_sizes[7];
ba804ab2
VZ
185 wxBuildFontSizes(f_sizes, size);
186
187 wxString normal = normal_face;
188 if ( normal.empty() )
189 normal = wxNORMAL_FONT->GetFaceName();
d1da8872 190
10e5c7ea 191 SetFonts(normal, fixed_face, f_sizes);
7acd3625
RD
192}
193
5526e819
VS
194void wxHtmlWinParser::InitParser(const wxString& source)
195{
196 wxHtmlParser::InitParser(source);
2b5f62a0 197 wxASSERT_MSG(m_DC != NULL, wxT("no DC assigned to wxHtmlWinParser!!"));
5526e819
VS
198
199 m_FontBold = m_FontItalic = m_FontUnderlined = m_FontFixed = FALSE;
f2c2fa4d 200 m_FontSize = 3; //default one
5526e819 201 CreateCurrentFont(); // we're selecting default font into
5620726f
RR
202
203 // we're not using GetCharWidth/Height() because of
204 // differences under X and win
205 wxCoord w,h;
206 m_DC->GetTextExtent( wxT("H"), &w, &h);
207 m_CharWidth = w;
208 m_CharHeight = h;
5526e819 209
d1da8872 210 m_UseLink = false;
9548f380 211 m_Link = wxHtmlLinkInfo( wxEmptyString );
5526e819
VS
212 m_LinkColor.Set(0, 0, 0xFF);
213 m_ActualColor.Set(0, 0, 0);
efba2b89 214 m_Align = wxHTML_ALIGN_LEFT;
3c115835
VS
215 m_ScriptMode = wxHTML_SCRIPT_NORMAL;
216 m_ScriptBaseline = 0;
d1da8872 217 m_tmpLastWasSpace = false;
b6d93b26 218 m_lastWordCell = NULL;
5526e819 219
69328c1a
VS
220 // open the toplevel container that contains everything else and that
221 // is never closed (this makes parser's life easier):
5526e819 222 OpenContainer();
69328c1a
VS
223
224 // then open the first container into which page's content will go:
5526e819 225 OpenContainer();
2b5f62a0 226
fa2f5d3b 227#if !wxUSE_UNICODE
2b5f62a0
VZ
228 wxString charset = ExtractCharsetInformation(source);
229 if (!charset.empty())
230 {
231 wxFontEncoding enc = wxFontMapper::Get()->CharsetToEncoding(charset);
232 if (enc != wxFONTENCODING_SYSTEM)
233 SetInputEncoding(enc);
234 }
235#endif
236
4f9297b0 237 m_Container->InsertCell(new wxHtmlColourCell(m_ActualColor));
44d0c580 238 wxColour windowColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW) ;
bc55e31b
VS
239
240 m_Container->InsertCell
241 (
242 new wxHtmlColourCell
243 (
244 m_windowInterface
245 ? m_windowInterface->GetHTMLBackgroundColour()
246 : windowColour,
247 wxHTML_CLR_BACKGROUND
248 )
249 );
250
4f9297b0 251 m_Container->InsertCell(new wxHtmlFontCell(CreateCurrentFont()));
5526e819
VS
252}
253
5526e819
VS
254void wxHtmlWinParser::DoneParser()
255{
256 m_Container = NULL;
2b5f62a0
VZ
257#if !wxUSE_UNICODE
258 SetInputEncoding(wxFONTENCODING_ISO8859_1); // for next call
259#endif
5526e819
VS
260 wxHtmlParser::DoneParser();
261}
262
bc55e31b
VS
263#if WXWIN_COMPATIBILITY_2_6
264wxHtmlWindow *wxHtmlWinParser::GetWindow()
265{
266 if (!m_windowInterface)
267 return NULL;
268 return wxDynamicCast(m_windowInterface->GetHTMLWindow(), wxHtmlWindow);
269}
270#endif
271
5526e819
VS
272wxObject* wxHtmlWinParser::GetProduct()
273{
274 wxHtmlContainerCell *top;
275
276 CloseContainer();
277 OpenContainer();
67cfebc2 278
5526e819 279 top = m_Container;
4f9297b0 280 while (top->GetParent()) top = top->GetParent();
ace0fab4
VS
281 top->RemoveExtraSpacing(true, true);
282
5526e819
VS
283 return top;
284}
285
0423bdc7 286wxFSFile *wxHtmlWinParser::OpenURL(wxHtmlURLType type,
6cc4e6b8 287 const wxString& url) const
04db5c3f 288{
bc55e31b
VS
289 if ( !m_windowInterface )
290 return wxHtmlParser::OpenURL(type, url);
291
292 wxString myurl(url);
293 wxHtmlOpeningStatus status;
294 for (;;)
6cc4e6b8 295 {
bc55e31b 296 wxString myfullurl(myurl);
4bfa3189 297
bc55e31b
VS
298 // consider url as absolute path first
299 wxURI current(myurl);
300 myfullurl = current.BuildUnescapedURI();
4bfa3189 301
bc55e31b
VS
302 // if not absolute then ...
303 if( current.IsReference() )
304 {
305 wxString basepath = GetFS()->GetPath();
306 wxURI base(basepath);
4bfa3189 307
bc55e31b
VS
308 // ... try to apply base path if valid ...
309 if( !base.IsReference() )
310 {
311 wxURI path(myfullurl);
312 path.Resolve( base );
313 myfullurl = path.BuildUnescapedURI();
314 }
315 else
316 {
317 // ... or force such addition if not included already
318 if( !current.GetPath().Contains(base.GetPath()) )
4bfa3189 319 {
bc55e31b
VS
320 basepath += myurl;
321 wxURI connected( basepath );
322 myfullurl = connected.BuildUnescapedURI();
4bfa3189
WS
323 }
324 }
6cc4e6b8 325 }
0423bdc7 326
bc55e31b
VS
327 wxString redirect;
328 status = m_windowInterface->OnHTMLOpeningURL(type, myfullurl, &redirect);
329 if ( status != wxHTML_REDIRECT )
330 break;
2c892c0b 331
bc55e31b 332 myurl = redirect;
6cc4e6b8 333 }
2c892c0b 334
bc55e31b
VS
335 if ( status == wxHTML_BLOCK )
336 return NULL;
337
5c4035d6
MW
338 int flags = wxFS_READ;
339 if (type == wxHTML_URL_IMAGE)
340 flags |= wxFS_SEEKABLE;
341
342 return GetFS()->OpenFile(myurl, flags);
04db5c3f 343}
5526e819 344
5bce3e6f 345void wxHtmlWinParser::AddText(const wxString& txt)
5526e819 346{
211dfedd 347 register wxChar d;
5526e819 348 int templen = 0;
f23e92e7 349 wxChar nbsp = GetEntitiesParser()->GetCharForCode(160 /* nbsp */);
211dfedd 350
5bce3e6f 351 size_t lng = txt.length();
211dfedd
VS
352 if (lng+1 > m_tmpStrBufSize)
353 {
354 delete[] m_tmpStrBuf;
355 m_tmpStrBuf = new wxChar[lng+1];
356 m_tmpStrBufSize = lng+1;
357 }
358 wxChar *temp = m_tmpStrBuf;
3c8c8da2 359
5bce3e6f
VS
360 wxString::const_iterator i = txt.begin();
361 wxString::const_iterator end = txt.end();
362
3c8c8da2 363 if (m_tmpLastWasSpace)
4f9297b0 364 {
5bce3e6f
VS
365 while ( (i < end) &&
366 (*i == wxT('\n') || *i == wxT('\r') || *i == wxT(' ') ||
367 *i == wxT('\t')) )
368 {
369 ++i;
370 }
5526e819
VS
371 }
372
5bce3e6f 373 while (i < end)
4f9297b0 374 {
5bce3e6f
VS
375 size_t x = 0;
376 d = temp[templen++] = *i;
3c8c8da2 377 if ((d == wxT('\n')) || (d == wxT('\r')) || (d == wxT(' ')) || (d == wxT('\t')))
e3c7fd79 378 {
5bce3e6f
VS
379 ++i, ++x;
380 while ( (i < end) &&
381 (*i == wxT('\n') || *i == wxT('\r') ||
382 *i == wxT(' ')) || *i == wxT('\t') )
383 {
384 ++i;
385 ++x;
386 }
5526e819 387 }
5bce3e6f
VS
388 else
389 ++i;
5526e819 390
3c8c8da2 391 if (x)
e3c7fd79 392 {
211dfedd 393 temp[templen-1] = wxT(' ');
97eac136 394 DoAddText(temp, templen, nbsp);
d1da8872 395 m_tmpLastWasSpace = true;
5526e819
VS
396 }
397 }
af035b26
VS
398
399 if (templen && (templen > 1 || temp[0] != wxT(' ')))
4f9297b0 400 {
97eac136
VS
401 DoAddText(temp, templen, nbsp);
402 m_tmpLastWasSpace = false;
403 }
404}
405
406void wxHtmlWinParser::DoAddText(wxChar *temp, int& templen, wxChar nbsp)
407{
408 temp[templen] = 0;
409 templen = 0;
2b5f62a0 410#if !wxUSE_UNICODE
97eac136
VS
411 if (m_EncConv)
412 m_EncConv->Convert(temp);
2b5f62a0 413#endif
97eac136
VS
414 size_t len = wxStrlen(temp);
415 for (size_t j = 0; j < len; j++)
416 {
417 if (temp[j] == nbsp)
418 temp[j] = wxT(' ');
5526e819 419 }
97eac136
VS
420
421 wxHtmlCell *c = new wxHtmlWordCell(temp, *(GetDC()));
422
3c115835
VS
423 ApplyStateToCell(c);
424
97eac136
VS
425 m_Container->InsertCell(c);
426 ((wxHtmlWordCell*)c)->SetPreviousWord(m_lastWordCell);
427 m_lastWordCell = (wxHtmlWordCell*)c;
5526e819
VS
428}
429
430
431
432wxHtmlContainerCell* wxHtmlWinParser::OpenContainer()
433{
434 m_Container = new wxHtmlContainerCell(m_Container);
4f9297b0 435 m_Container->SetAlignHor(m_Align);
d1da8872 436 m_tmpLastWasSpace = true;
5526e819
VS
437 /* to avoid space being first character in paragraph */
438 return m_Container;
439}
440
441
442
443wxHtmlContainerCell* wxHtmlWinParser::SetContainer(wxHtmlContainerCell *c)
444{
d1da8872 445 m_tmpLastWasSpace = true;
5526e819
VS
446 /* to avoid space being first character in paragraph */
447 return m_Container = c;
448}
449
450
451
452wxHtmlContainerCell* wxHtmlWinParser::CloseContainer()
453{
4f9297b0 454 m_Container = m_Container->GetParent();
5526e819
VS
455 return m_Container;
456}
457
458
f2c2fa4d
VS
459void wxHtmlWinParser::SetFontSize(int s)
460{
461 if (s < 1) s = 1;
462 else if (s > 7) s = 7;
463 m_FontSize = s;
464}
465
466
467
5526e819
VS
468wxFont* wxHtmlWinParser::CreateCurrentFont()
469{
470 int fb = GetFontBold(),
471 fi = GetFontItalic(),
472 fu = GetFontUnderlined(),
473 ff = GetFontFixed(),
f2c2fa4d 474 fs = GetFontSize() - 1 /*remap from <1;7> to <0;6>*/ ;
5526e819 475
f1ad10f3
VS
476 wxString face = ff ? m_FontFaceFixed : m_FontFaceNormal;
477 wxString *faceptr = &(m_FontsFacesTable[fb][fi][fu][ff][fs]);
478 wxFont **fontptr = &(m_FontsTable[fb][fi][fu][ff][fs]);
2b5f62a0 479#if !wxUSE_UNICODE
b250d384 480 wxFontEncoding *encptr = &(m_FontsEncTable[fb][fi][fu][ff][fs]);
2b5f62a0 481#endif
f1ad10f3 482
2b5f62a0
VZ
483 if (*fontptr != NULL && (*faceptr != face
484#if !wxUSE_UNICODE
485 || *encptr != m_OutputEnc
486#endif
487 ))
4f9297b0 488 {
f1ad10f3
VS
489 delete *fontptr;
490 *fontptr = NULL;
491 }
492
3c8c8da2 493 if (*fontptr == NULL)
4f9297b0 494 {
f1ad10f3
VS
495 *faceptr = face;
496 *fontptr = new wxFont(
7a5e6267 497 (int) (m_FontsSizes[fs] * m_PixelScale),
f1ad10f3
VS
498 ff ? wxMODERN : wxSWISS,
499 fi ? wxITALIC : wxNORMAL,
500 fb ? wxBOLD : wxNORMAL,
d1da8872 501 fu ? true : false, face
2b5f62a0
VZ
502#if wxUSE_UNICODE
503 );
504#else
505 , m_OutputEnc);
506 *encptr = m_OutputEnc;
507#endif
5526e819 508 }
4f9297b0 509 m_DC->SetFont(**fontptr);
f1ad10f3 510 return (*fontptr);
5526e819
VS
511}
512
513
514
f2c2fa4d
VS
515void wxHtmlWinParser::SetLink(const wxHtmlLinkInfo& link)
516{
3c8c8da2 517 m_Link = link;
f2c2fa4d
VS
518 m_UseLink = (link.GetHref() != wxEmptyString);
519}
520
3c8c8da2 521void wxHtmlWinParser::SetFontFace(const wxString& face)
b250d384 522{
3c8c8da2 523 if (GetFontFixed()) m_FontFaceFixed = face;
b250d384
VS
524 else m_FontFaceNormal = face;
525
2b5f62a0 526#if !wxUSE_UNICODE
b250d384
VS
527 if (m_InputEnc != wxFONTENCODING_DEFAULT)
528 SetInputEncoding(m_InputEnc);
2b5f62a0 529#endif
b250d384
VS
530}
531
3c115835
VS
532void wxHtmlWinParser::ApplyStateToCell(wxHtmlCell *cell)
533{
534 // set the link:
535 if (m_UseLink)
536 cell->SetLink(GetLink());
537
538 // apply current script mode settings:
539 cell->SetScriptMode(GetScriptMode(), GetScriptBaseline());
540}
b250d384
VS
541
542
2b5f62a0 543#if !wxUSE_UNICODE
b250d384
VS
544void wxHtmlWinParser::SetInputEncoding(wxFontEncoding enc)
545{
546 m_InputEnc = m_OutputEnc = wxFONTENCODING_DEFAULT;
3c8c8da2 547 if (m_EncConv)
daa616fc 548 {
3c8c8da2 549 delete m_EncConv;
daa616fc
VS
550 m_EncConv = NULL;
551 }
b250d384
VS
552
553 if (enc == wxFONTENCODING_DEFAULT) return;
554
555 wxFontEncoding altfix, altnorm;
556 bool availfix, availnorm;
3c8c8da2
VZ
557
558 // exact match?
142b3bc2
VS
559 availnorm = wxFontMapper::Get()->IsEncodingAvailable(enc, m_FontFaceNormal);
560 availfix = wxFontMapper::Get()->IsEncodingAvailable(enc, m_FontFaceFixed);
3c8c8da2 561 if (availnorm && availfix)
b250d384 562 m_OutputEnc = enc;
3c8c8da2 563
b250d384 564 // alternatives?
d1da8872
WS
565 else if (wxFontMapper::Get()->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, false) &&
566 wxFontMapper::Get()->GetAltForEncoding(enc, &altfix, m_FontFaceFixed, false) &&
b250d384
VS
567 altnorm == altfix)
568 m_OutputEnc = altnorm;
3c8c8da2 569
b250d384
VS
570 // at least normal face?
571 else if (availnorm)
572 m_OutputEnc = enc;
d1da8872 573 else if (wxFontMapper::Get()->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, false))
b250d384 574 m_OutputEnc = altnorm;
3c8c8da2 575
b250d384 576 else
c83e1237
SC
577 {
578#ifndef __WXMAC__
6a17b868 579 // okay, let's convert to ISO_8859-1, available always
b250d384 580 m_OutputEnc = wxFONTENCODING_DEFAULT;
90548138 581#else
c83e1237 582 m_OutputEnc = wxLocale::GetSystemEncoding() ;
90548138 583#endif
c83e1237 584 }
3c8c8da2 585
b250d384 586 m_InputEnc = enc;
daa616fc
VS
587 if (m_OutputEnc == wxFONTENCODING_DEFAULT)
588 GetEntitiesParser()->SetEncoding(wxFONTENCODING_SYSTEM);
589 else
590 GetEntitiesParser()->SetEncoding(m_OutputEnc);
3c8c8da2 591
b250d384
VS
592 if (m_InputEnc == m_OutputEnc) return;
593
594 m_EncConv = new wxEncodingConverter();
3c8c8da2 595 if (!m_EncConv->Init(m_InputEnc,
b250d384
VS
596 (m_OutputEnc == wxFONTENCODING_DEFAULT) ?
597 wxFONTENCODING_ISO8859_1 : m_OutputEnc,
3c8c8da2 598 wxCONVERT_SUBSTITUTE))
6a17b868 599 { // total failure :-(
3c8c8da2
VZ
600 wxLogError(_("Failed to display HTML document in %s encoding"),
601 wxFontMapper::GetEncodingName(enc).c_str());
b250d384
VS
602 m_InputEnc = m_OutputEnc = wxFONTENCODING_DEFAULT;
603 delete m_EncConv;
604 m_EncConv = NULL;
605 }
606}
2b5f62a0 607#endif
b250d384
VS
608
609
f2c2fa4d 610
5526e819
VS
611
612//-----------------------------------------------------------------------------
613// wxHtmlWinTagHandler
614//-----------------------------------------------------------------------------
615
616IMPLEMENT_ABSTRACT_CLASS(wxHtmlWinTagHandler, wxHtmlTagHandler)
617
5526e819
VS
618//-----------------------------------------------------------------------------
619// wxHtmlTagsModule
620//-----------------------------------------------------------------------------
621
d6a6d666
VS
622// NB: This is *NOT* winpars.cpp's initialization and shutdown code!!
623// This module is an ancestor for tag handlers modules defined
624// in m_*.cpp files with TAGS_MODULE_BEGIN...TAGS_MODULE_END construct.
625//
626// Do not add any winpars.cpp shutdown or initialization code to it,
627// create a new module instead!
5526e819
VS
628
629IMPLEMENT_DYNAMIC_CLASS(wxHtmlTagsModule, wxModule)
630
5526e819
VS
631bool wxHtmlTagsModule::OnInit()
632{
633 wxHtmlWinParser::AddModule(this);
d1da8872 634 return true;
5526e819
VS
635}
636
5526e819
VS
637void wxHtmlTagsModule::OnExit()
638{
f6bcfd97 639 wxHtmlWinParser::RemoveModule(this);
5526e819 640}
d6a6d666 641
223d09f6 642#endif