X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c9554803fa46f1749a45585f96e80bc459a5cd88..f68e16c5fcf53c411742c8338a290addc5fb4b62:/src/html/htmltag.cpp diff --git a/src/html/htmltag.cpp b/src/html/htmltag.cpp index 4cd0412e95..3f88bf3edc 100644 --- a/src/html/htmltag.cpp +++ b/src/html/htmltag.cpp @@ -23,6 +23,8 @@ #endif #include "wx/html/htmlpars.h" +#include "wx/html/styleparams.h" + #include "wx/vector.h" #include // for vsscanf @@ -430,6 +432,32 @@ wxHtmlTag::wxHtmlTag(wxHtmlTag *parent, #if WXWIN_COMPATIBILITY_2_8 m_sourceStart = source->begin(); #endif + + // Try to parse any style parameters that can be handled simply by + // converting them to the equivalent HTML 3 attributes: this is a far cry + // from perfect but better than nothing. + static const struct EquivAttr + { + const char *style; + const char *attr; + } equivAttrs[] = + { + { "text-align", "ALIGN" }, + { "width", "WIDTH" }, + { "vertical-align", "VALIGN" }, + { "background", "BGCOLOR" }, + }; + + wxHtmlStyleParams styleParams(*this); + for ( unsigned n = 0; n < WXSIZEOF(equivAttrs); n++ ) + { + const EquivAttr& ea = equivAttrs[n]; + if ( styleParams.HasParam(ea.style) && !HasParam(ea.attr) ) + { + m_ParamNames.Add(ea.attr); + m_ParamValues.Add(styleParams.GetParam(ea.style)); + } + } } wxHtmlTag::~wxHtmlTag() @@ -481,12 +509,11 @@ int wxHtmlTag::ScanParam(const wxString& par, return wxSscanf(parval, format, param); } -bool wxHtmlTag::GetParamAsColour(const wxString& par, wxColour *clr) const +/* static */ +bool wxHtmlTag::ParseAsColour(const wxString& str, wxColour *clr) { wxCHECK_MSG( clr, false, wxT("invalid colour argument") ); - wxString str = GetParam(par); - // handle colours defined in HTML 4.0 first: if (str.length() > 1 && str[0] != wxT('#')) { @@ -522,6 +549,12 @@ bool wxHtmlTag::GetParamAsColour(const wxString& par, wxColour *clr) const return false; } +bool wxHtmlTag::GetParamAsColour(const wxString& par, wxColour *clr) const +{ + const wxString str = GetParam(par); + return !str.empty() && ParseAsColour(str, clr); +} + bool wxHtmlTag::GetParamAsInt(const wxString& par, int *clr) const { if ( !HasParam(par) )