wxHtmlTag::ScanParam now returns value
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3537 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -140,6 +140,10 @@ wxHtmlTag::wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCac
|
|||||||
while ((i < end_pos) && ((c = source[i++]) != '"')) m_Params += c;
|
while ((i < end_pos) && ((c = source[i++]) != '"')) m_Params += c;
|
||||||
m_Params += c;
|
m_Params += c;
|
||||||
}
|
}
|
||||||
|
else if (c == '\'') {
|
||||||
|
while ((i < end_pos) && ((c = source[i++]) != '\'')) m_Params += c;
|
||||||
|
m_Params += c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_Begin = i;
|
m_Begin = i;
|
||||||
|
|
||||||
@@ -184,6 +188,7 @@ wxString wxHtmlTag::GetParam(const wxString& par, bool with_commas) const
|
|||||||
const char *st = m_Params, *p = par;
|
const char *st = m_Params, *p = par;
|
||||||
const char *st2, *p2;
|
const char *st2, *p2;
|
||||||
bool comma;
|
bool comma;
|
||||||
|
char comma_char;
|
||||||
|
|
||||||
if (*st == 0) return "";
|
if (*st == 0) return "";
|
||||||
if (*p == 0) return "";
|
if (*p == 0) return "";
|
||||||
@@ -192,13 +197,23 @@ wxString wxHtmlTag::GetParam(const wxString& par, bool with_commas) const
|
|||||||
wxString fnd = "";
|
wxString fnd = "";
|
||||||
st2++; // '=' character
|
st2++; // '=' character
|
||||||
comma = FALSE;
|
comma = FALSE;
|
||||||
if (!with_commas && (*(st2) == '"')) {st2++; comma = TRUE;}
|
comma_char = '\0';
|
||||||
|
if (!with_commas && (*(st2) == '"')) {
|
||||||
|
st2++;
|
||||||
|
comma = TRUE;
|
||||||
|
comma_char = '"';
|
||||||
|
}
|
||||||
|
else if (!with_commas && (*(st2) == '\'')) {
|
||||||
|
st2++;
|
||||||
|
comma = TRUE;
|
||||||
|
comma_char = '\'';
|
||||||
|
}
|
||||||
while (*st2 != 0) {
|
while (*st2 != 0) {
|
||||||
if (*st2 == '"') comma = !comma;
|
if (comma && *st2 == comma_char) comma = FALSE;
|
||||||
else if ((*st2 == ' ') && (!comma)) break;
|
else if ((*st2 == ' ') && (!comma)) break;
|
||||||
fnd += (*(st2++));
|
fnd += (*(st2++));
|
||||||
}
|
}
|
||||||
if (!with_commas && (*(st2-1) == '"')) fnd.RemoveLast();
|
if (!with_commas && (*(st2-1) == comma_char)) fnd.RemoveLast();
|
||||||
return fnd;
|
return fnd;
|
||||||
}
|
}
|
||||||
if (*st2 == 0) return "";
|
if (*st2 == 0) return "";
|
||||||
@@ -212,6 +227,10 @@ wxString wxHtmlTag::GetParam(const wxString& par, bool with_commas) const
|
|||||||
st2++;
|
st2++;
|
||||||
while (*st2 != '"') st2++;
|
while (*st2 != '"') st2++;
|
||||||
}
|
}
|
||||||
|
else if (*st2 == '\'') {
|
||||||
|
st2++;
|
||||||
|
while (*st2 != '\'') st2++;
|
||||||
|
}
|
||||||
st2++;
|
st2++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,8 +239,9 @@ wxString wxHtmlTag::GetParam(const wxString& par, bool with_commas) const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void wxHtmlTag::ScanParam(const wxString& par, char *format, ...) const
|
int wxHtmlTag::ScanParam(const wxString& par, char *format, ...) const
|
||||||
{
|
{
|
||||||
|
int retval;
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
wxString parval = GetParam(par);
|
wxString parval = GetParam(par);
|
||||||
|
|
||||||
@@ -229,13 +249,13 @@ void wxHtmlTag::ScanParam(const wxString& par, char *format, ...) const
|
|||||||
|
|
||||||
//#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__VISUALC__)
|
//#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__VISUALC__)
|
||||||
#ifndef HAVE_VSSCANF
|
#ifndef HAVE_VSSCANF
|
||||||
sscanf((const char*)parval, format, va_arg(argptr, void *));
|
retval = sscanf((const char*)parval, format, va_arg(argptr, void *));
|
||||||
#else
|
#else
|
||||||
vsscanf((const char*)parval, format, argptr);
|
retval = vsscanf((const char*)parval, format, argptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
--- vsscanf is not defined under Cygwin or Mingw32 or M$ Visual C++ environment
|
--- vsscanf is not defined under some compilers
|
||||||
if this module doesn't compile with your compiler,
|
if this module doesn't compile with your compiler,
|
||||||
modify the def statement and let me know. Thanks...
|
modify the def statement and let me know. Thanks...
|
||||||
|
|
||||||
@@ -245,6 +265,7 @@ void wxHtmlTag::ScanParam(const wxString& par, char *format, ...) const
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -39,19 +39,19 @@ TAG_HANDLER_BEGIN(FONT, "FONT")
|
|||||||
if (tag.HasParam("COLOR")) {
|
if (tag.HasParam("COLOR")) {
|
||||||
unsigned long tmp = 0;
|
unsigned long tmp = 0;
|
||||||
wxColour clr;
|
wxColour clr;
|
||||||
tag.ScanParam("COLOR", "#%lX", &tmp);
|
if (tag.ScanParam("COLOR", "#%lX", &tmp) == 1) {
|
||||||
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
|
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
|
||||||
m_WParser -> SetActualColor(clr);
|
m_WParser -> SetActualColor(clr);
|
||||||
m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr));
|
m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.HasParam("SIZE")) {
|
if (tag.HasParam("SIZE")) {
|
||||||
// give 'tmp' an initial value. If conversion fails, it will keep this value.
|
|
||||||
long tmp = 0;
|
long tmp = 0;
|
||||||
tag.ScanParam("SIZE", "%li", &tmp);
|
if (tag.ScanParam("SIZE", "%li", &tmp) == 1) {
|
||||||
// We *really* should check the result of (v)sscanf, but ScanParam returns void...
|
m_WParser -> SetFontSize(oldsize+tmp);
|
||||||
m_WParser -> SetFontSize(oldsize+tmp);
|
m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
|
||||||
m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ParseInner(tag);
|
ParseInner(tag);
|
||||||
|
@@ -78,7 +78,7 @@ TAG_HANDLER_BEGIN(HR, "HR")
|
|||||||
c -> SetAlignHor(HTML_ALIGN_CENTER);
|
c -> SetAlignHor(HTML_ALIGN_CENTER);
|
||||||
c -> SetAlign(tag);
|
c -> SetAlign(tag);
|
||||||
c -> SetWidthFloat(tag);
|
c -> SetWidthFloat(tag);
|
||||||
if (tag.HasParam("SIZE")) tag.ScanParam("SIZE", "%i", &sz);
|
if (tag.HasParam("SIZE") && tag.ScanParam("SIZE", "%i", &sz) == 1) {}
|
||||||
else sz = 1;
|
else sz = 1;
|
||||||
c -> InsertCell(new wxHtmlLineCell(sz));
|
c -> InsertCell(new wxHtmlLineCell(sz));
|
||||||
|
|
||||||
|
@@ -291,10 +291,9 @@ wxHtmlImageCell::wxHtmlImageCell(wxFSFile *input, int w, int h, int align, wxStr
|
|||||||
{
|
{
|
||||||
wxImage *img;
|
wxImage *img;
|
||||||
int ww, hh;
|
int ww, hh;
|
||||||
wxString m = input -> GetMimeType();
|
|
||||||
wxInputStream *s = input -> GetStream();
|
wxInputStream *s = input -> GetStream();
|
||||||
|
|
||||||
img = new wxImage(*s, m);
|
img = new wxImage(*s, wxBITMAP_TYPE_ANY);
|
||||||
|
|
||||||
m_Image = NULL;
|
m_Image = NULL;
|
||||||
if (img && (img -> Ok())) {
|
if (img && (img -> Ok())) {
|
||||||
|
@@ -165,24 +165,27 @@ TAG_HANDLER_BEGIN(BODY, "BODY")
|
|||||||
wxColour clr;
|
wxColour clr;
|
||||||
|
|
||||||
if (tag.HasParam("TEXT")) {
|
if (tag.HasParam("TEXT")) {
|
||||||
tag.ScanParam("TEXT", "#%lX", &tmp);
|
if (tag.ScanParam("TEXT", "#%lX", &tmp) == 1) {
|
||||||
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
|
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
|
||||||
m_WParser -> SetActualColor(clr);
|
m_WParser -> SetActualColor(clr);
|
||||||
m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr));
|
m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tag.HasParam("LINK")) {
|
if (tag.HasParam("LINK")) {
|
||||||
tag.ScanParam("LINK", "#%lX", &tmp);
|
if (tag.ScanParam("LINK", "#%lX", &tmp) == 1) {
|
||||||
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
|
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
|
||||||
m_WParser -> SetLinkColor(clr);
|
m_WParser -> SetLinkColor(clr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.HasParam("BGCOLOR")) {
|
if (tag.HasParam("BGCOLOR")) {
|
||||||
tag.ScanParam("BGCOLOR", "#%lX", &tmp);
|
if (tag.ScanParam("BGCOLOR", "#%lX", &tmp) == 1) {
|
||||||
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
|
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
|
||||||
m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr, HTML_CLR_BACKGROUND));
|
m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr, HTML_CLR_BACKGROUND));
|
||||||
if (m_WParser -> GetWindow() != NULL)
|
if (m_WParser -> GetWindow() != NULL)
|
||||||
m_WParser -> GetWindow() -> SetBackgroundColour(clr);
|
m_WParser -> GetWindow() -> SetBackgroundColour(clr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -122,8 +122,8 @@ wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& t
|
|||||||
m_tBkg = m_rBkg = -1;
|
m_tBkg = m_rBkg = -1;
|
||||||
if (tag.HasParam("BGCOLOR")) tag.ScanParam("BGCOLOR", "#%lX", &m_tBkg);
|
if (tag.HasParam("BGCOLOR")) tag.ScanParam("BGCOLOR", "#%lX", &m_tBkg);
|
||||||
if (tag.HasParam("VALIGN")) m_tValign = tag.GetParam("VALIGN"); else m_tValign = wxEmptyString;
|
if (tag.HasParam("VALIGN")) m_tValign = tag.GetParam("VALIGN"); else m_tValign = wxEmptyString;
|
||||||
if (tag.HasParam("CELLSPACING")) tag.ScanParam("CELLSPACING", "%i", &m_Spacing); else m_Spacing = 2;
|
if (tag.HasParam("CELLSPACING") && tag.ScanParam("CELLSPACING", "%i", &m_Spacing) == 1) {} else m_Spacing = 2;
|
||||||
if (tag.HasParam("CELLPADDING")) tag.ScanParam("CELLPADDING", "%i", &m_Padding); else m_Padding = 3;
|
if (tag.HasParam("CELLPADDING") && tag.ScanParam("CELLPADDING", "%i", &m_Padding) == 1) {} else m_Padding = 3;
|
||||||
|
|
||||||
if (m_HasBorders)
|
if (m_HasBorders)
|
||||||
SetBorder(TABLE_BORDER_CLR_1, TABLE_BORDER_CLR_2);
|
SetBorder(TABLE_BORDER_CLR_1, TABLE_BORDER_CLR_2);
|
||||||
|
Reference in New Issue
Block a user