#endif
#include "wx/html/htmlpars.h"
+#include "wx/html/styleparams.h"
+
#include "wx/vector.h"
#include <stdio.h> // for vsscanf
#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()
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('#'))
{
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) )