]> git.saurik.com Git - wxWidgets.git/commitdiff
added convenience accessors to wxHtmlTag and modified wxHTML code to use them; improv...
authorVáclav Slavík <vslavik@fastmail.fm>
Sun, 1 Jul 2001 18:07:33 +0000 (18:07 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sun, 1 Jul 2001 18:07:33 +0000 (18:07 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10747 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/html/htmltag.h
src/html/helpdata.cpp
src/html/htmltag.cpp
src/html/m_fonts.cpp
src/html/m_hline.cpp
src/html/m_image.cpp
src/html/m_layout.cpp
src/html/m_tables.cpp

index e0370b6b12f7710e83a7b440c742bcd0bdff463a..b438039cd56d02e9213227f9165377ae7c2521fc 100644 (file)
@@ -18,6 +18,8 @@
 #include "wx/defs.h"
 #if wxUSE_HTML
 
+class WXDLLEXPORT wxHtmlEntitiesParser;
+
 //-----------------------------------------------------------------------------
 // wxHtmlTagsCache
 //          - internal wxHTML class, do not use!
@@ -58,7 +60,9 @@ public:
     // constructs wxHtmlTag object based on HTML tag.
     // The tag begins (with '<' character) at position pos in source
     // end_pos is position where parsing ends (usually end of document)
-    wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
+    wxHtmlTag(const wxString& source, int pos, int end_pos, 
+              wxHtmlTagsCache *cache,
+              wxHtmlEntitiesParser *entParser = NULL);
 
     // Returns tag's name in uppercase.
     inline wxString GetName() const {return m_Name;}
@@ -75,7 +79,11 @@ public:
     //                           (or ("WhaT.jpg") if with_commas == TRUE)
     wxString GetParam(const wxString& par, bool with_commas = FALSE) const;
 
-    // Scans param like scanf() functions family do.
+    // Convenience functions:    
+    bool GetParamAsColour(const wxString& par, wxColour *clr) const;
+    bool GetParamAsInt(const wxString& par, int *clr) const;
+
+    // Scans param like scanf() functions family does.
     // Example : ScanParam("COLOR", "\"#%X\"", &clr);
     // This is always with with_commas=FALSE
     // Returns number of scanned values
@@ -85,7 +93,7 @@ public:
     int ScanParam(const wxString& par, wxChar *format, void *param) const;
 
     // Returns string containing all params.
-    inline const wxString& GetAllParams() const {return m_Params;}
+    wxString GetAllParams() const;
 
     // return TRUE if this is ending tag (</something>) or FALSE
     // if it isn't (<something>)
@@ -107,9 +115,10 @@ public:
     inline int GetEndPos2() const {return m_End2;}
 
 private:
-    wxString m_Name, m_Params;
+    wxString m_Name;
     int m_Begin, m_End1, m_End2;
     bool m_Ending;
+    wxArrayString m_ParamNames, m_ParamValues;
 };
 
 
index 3b7b4c4ccd3c5793ce3fbb0edeb4e819dbedd69b..6d5d92ea0adfa1b3061c23ce67ba1272646f1d59 100644 (file)
@@ -162,7 +162,7 @@ bool HP_TagHandler::HandleTag(const wxHtmlTag& tag)
         if (tag.GetParam(wxT("NAME")) == wxT("Local")) 
             m_Page = tag.GetParam(wxT("VALUE"));
         if (tag.GetParam(wxT("NAME")) == wxT("ID")) 
-            tag.ScanParam(wxT("VALUE"), wxT("%i"), &m_ID);
+            tag.GetParamAsInt(wxT("VALUE"), &m_ID);
         return FALSE;
     }
 }
index 9b8049fdba42829d05a317c1f33c2b38881a7b46..8801b152279de43a970bb59962f44314e813fe1c 100644 (file)
@@ -304,6 +304,57 @@ int wxHtmlTag::ScanParam(const wxString& par, wxChar *format, void *param) const
     return wxSscanf(parval, format, param);
 }
 
+bool wxHtmlTag::GetParamAsColour(const wxString& par, wxColour *clr) const
+{
+    wxString str = GetParam(par);
+    
+    if (str.IsEmpty()) return FALSE;
+    if (str.GetChar(0) == wxT('#'))
+    {
+        unsigned long tmp;
+        if (ScanParam(par, wxT("#%lX"), &tmp) != 1)
+            return FALSE;
+        *clr = wxColour((unsigned char)((tmp & 0xFF0000) >> 16),
+                                           (unsigned char)((tmp & 0x00FF00) >> 8),
+                                           (unsigned char)(tmp & 0x0000FF));
+        return TRUE;
+    }
+    else
+    {
+        // Handle colours defined in HTML 4.0:
+        #define HTML_COLOUR(name,r,g,b)                 \
+            if (str.IsSameAs(wxT(name), FALSE))         \
+                { *clr = wxColour(r,g,b); return TRUE; }
+        HTML_COLOUR("black",   0x00,0x00,0x00)
+        HTML_COLOUR("silver",  0xC0,0xC0,0xC0)
+        HTML_COLOUR("gray",    0x80,0x80,0x80)
+        HTML_COLOUR("white",   0xFF,0xFF,0xFF)
+        HTML_COLOUR("maroon",  0x80,0x00,0x00)
+        HTML_COLOUR("red",     0xFF,0x00,0x00)
+        HTML_COLOUR("purple",  0x80,0x00,0x80)
+        HTML_COLOUR("fuchsia", 0xFF,0x00,0xFF)
+        HTML_COLOUR("green",   0x00,0x80,0x00)
+        HTML_COLOUR("lime",    0x00,0xFF,0x00)
+        HTML_COLOUR("olive",   0x80,0x80,0x00)
+        HTML_COLOUR("yellow",  0xFF,0xFF,0x00)
+        HTML_COLOUR("navy",    0x00,0x00,0x80)
+        HTML_COLOUR("blue",    0x00,0x00,0xFF)
+        HTML_COLOUR("teal",    0x00,0x80,0x80)
+        HTML_COLOUR("aqua",    0x00,0xFF,0xFF)
+        #undef HTML_COLOUR
+        return FALSE;
+    }
+}
+
+bool wxHtmlTag::GetParamAsInt(const wxString& par, int *clr) const
+{
+    if (!HasParam(par)) return FALSE;
+    long i;
+    bool succ = GetParam(par).ToLong(&i);
+    *clr = (int)i;
+    return succ;
+}
+
 wxString wxHtmlTag::GetAllParams() const
 {
     // VS: this function is for backward compatiblity only, 
index 67310dea593261a3a13438141d31a05dedaf9b1d..d5391350e6299bb0b7e030be5263dfd068fae5c9 100644 (file)
@@ -45,13 +45,9 @@ TAG_HANDLER_BEGIN(FONT, "FONT")
 
         if (tag.HasParam(wxT("COLOR")))
            {
-            unsigned long tmp = 0;
             wxColour clr;
-            if (tag.ScanParam(wxT("COLOR"), wxT("#%lX"), &tmp) == 1)
+            if (tag.GetParamAsColour(wxT("COLOR"), &clr))
                {
-                clr = wxColour((unsigned char)((tmp & 0xFF0000) >> 16),
-                                                          (unsigned char)((tmp & 0x00FF00) >> 8),
-                                                          (unsigned char)(tmp & 0x0000FF));
                 m_WParser->SetActualColor(clr);
                 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr));
             }
@@ -59,15 +55,16 @@ TAG_HANDLER_BEGIN(FONT, "FONT")
 
         if (tag.HasParam(wxT("SIZE")))
            {
-            long tmp = 0;
-            wxChar c = tag.GetParam(wxT("SIZE"))[(unsigned int) 0];
-            if (tag.ScanParam(wxT("SIZE"), wxT("%li"), &tmp) == 1)
+            int tmp = 0;
+            wxChar c = tag.GetParam(wxT("SIZE")).GetChar(0);
+            if (tag.GetParamAsInt(wxT("SIZE"), &tmp))
                {
-                if (c == '+' || c == '-')
+                if (c == wxT('+') || c == wxT('-'))
                     m_WParser->SetFontSize(oldsize+tmp);
                 else
                     m_WParser->SetFontSize(tmp);
-                m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
+                m_WParser->GetContainer()->InsertCell(
+                    new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
             }
         }
 
@@ -79,7 +76,7 @@ TAG_HANDLER_BEGIN(FONT, "FONT")
                 enu.EnumerateFacenames();
                 m_Faces = *enu.GetFacenames();
             }
-            wxStringTokenizer tk(tag.GetParam(wxT("FACE")), ",");
+            wxStringTokenizer tk(tag.GetParam(wxT("FACE")), wxT(","));
             int index;
 
             while (tk.HasMoreTokens())
@@ -123,12 +120,14 @@ TAG_HANDLER_BEGIN(FACES_U, "U,STRIKE")
         int underlined = m_WParser->GetFontUnderlined();
 
         m_WParser->SetFontUnderlined(TRUE);
-        m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
+        m_WParser->GetContainer()->InsertCell(
+            new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
 
         ParseInner(tag);
 
         m_WParser->SetFontUnderlined(underlined);
-        m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
+        m_WParser->GetContainer()->InsertCell(
+            new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
         return TRUE;
     }
 
@@ -144,12 +143,14 @@ TAG_HANDLER_BEGIN(FACES_B, "B,STRONG")
         int bold = m_WParser->GetFontBold();
 
         m_WParser->SetFontBold(TRUE);
-        m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
+        m_WParser->GetContainer()->InsertCell(
+            new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
 
         ParseInner(tag);
 
         m_WParser->SetFontBold(bold);
-        m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
+        m_WParser->GetContainer()->InsertCell(
+            new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
         return TRUE;
     }
 
@@ -165,12 +166,14 @@ TAG_HANDLER_BEGIN(FACES_I, "I,EM,CITE,ADDRESS")
         int italic = m_WParser->GetFontItalic();
 
         m_WParser->SetFontItalic(TRUE);
-        m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
+        m_WParser->GetContainer()->InsertCell(
+            new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
 
         ParseInner(tag);
 
         m_WParser->SetFontItalic(italic);
-        m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
+        m_WParser->GetContainer()->InsertCell(
+            new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
         return TRUE;
     }
 
@@ -186,12 +189,14 @@ TAG_HANDLER_BEGIN(FACES_TT, "TT,CODE,KBD,SAMP")
         int fixed = m_WParser->GetFontFixed();
 
         m_WParser->SetFontFixed(TRUE);
-        m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
+        m_WParser->GetContainer()->InsertCell(
+            new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
 
         ParseInner(tag);
 
         m_WParser->SetFontFixed(fixed);
-        m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
+        m_WParser->GetContainer()->InsertCell(
+            new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
         return TRUE;
     }
 
@@ -264,7 +269,8 @@ TAG_HANDLER_BEGIN(Hx, "H1,H2,H3,H4,H5,H6")
         m_WParser->SetFontFixed(old_f);
         m_WParser->SetAlign(old_al);
 
-        m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
+        m_WParser->GetContainer()->InsertCell(
+            new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
         m_WParser->CloseContainer();
         m_WParser->OpenContainer();
         c = m_WParser->GetContainer();
@@ -284,12 +290,14 @@ TAG_HANDLER_BEGIN(BIGSMALL, "BIG,SMALL")
         int sz = (tag.GetName() == wxT("BIG")) ? +1 : -1;
 
         m_WParser->SetFontSize(sz);
-        m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
+        m_WParser->GetContainer()->InsertCell(
+            new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
 
         ParseInner(tag);
 
         m_WParser->SetFontSize(oldsize);
-        m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
+        m_WParser->GetContainer()->InsertCell(
+            new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
         return TRUE;
     }
 
index 3eee42e318f5c2cc79125d9146034bbb92938407..77f4abcb64de1a436a25d1ba66b98e5c1be99a3e 100644 (file)
@@ -80,7 +80,7 @@ TAG_HANDLER_BEGIN(HR, "HR")
         c->SetAlign(tag);
         c->SetWidthFloat(tag);
         sz = 1;
-        if (tag.HasParam(wxT("SIZE")) && tag.ScanParam(wxT("SIZE"), wxT("%i"), &sz) == 1) {}
+        tag.GetParamAsInt(wxT("SIZE"), &sz);
         c->InsertCell(new wxHtmlLineCell((int)((double)sz * m_WParser->GetPixelScale())));
 
         m_WParser->CloseContainer();
index 3db4b875eb46634ba794278e0740944387749659..8edf713086b090211f5b992c7e86aacff8241de9 100644 (file)
@@ -404,20 +404,24 @@ TAG_HANDLER_BEGIN(IMG, "IMG,MAP,AREA")
                 wxString mn = wxEmptyString;
 
                 str = m_WParser->GetFS()->OpenFile(tmp);
-                if (tag.HasParam(wxT("WIDTH"))) tag.ScanParam(wxT("WIDTH"), wxT("%i"), &w);
-                if (tag.HasParam(wxT("HEIGHT"))) tag.ScanParam(wxT("HEIGHT"), wxT("%i"), &h);
+                if (tag.HasParam(wxT("WIDTH"))) 
+                    tag.GetParamAsInt(wxT("WIDTH"), &w);
+                if (tag.HasParam(wxT("HEIGHT"))) 
+                    tag.GetParamAsInt(wxT("HEIGHT"), &h);
                 al = wxHTML_ALIGN_BOTTOM;
                 if (tag.HasParam(wxT("ALIGN"))) 
                        {
                     wxString alstr = tag.GetParam(wxT("ALIGN"));
                     alstr.MakeUpper();  // for the case alignment was in ".."
-                    if (alstr == wxT("TEXTTOP")) al = wxHTML_ALIGN_TOP;
-                    else if ((alstr == wxT("CENTER")) || (alstr == wxT("ABSCENTER"))) al = wxHTML_ALIGN_CENTER;
+                    if (alstr == wxT("TEXTTOP")) 
+                        al = wxHTML_ALIGN_TOP;
+                    else if ((alstr == wxT("CENTER")) || (alstr == wxT("ABSCENTER"))) 
+                        al = wxHTML_ALIGN_CENTER;
                 }
                 if (tag.HasParam(wxT("USEMAP"))) 
                        {
                     mn = tag.GetParam( wxT("USEMAP") );
-                    if (mn[ (unsigned int) 0 ] == wxT('#')) 
+                    if (mn.GetChar(0) == wxT('#')) 
                            {
                         mn = mn.Mid( 1 );
                     }
index e3f8ec8c3f6e095cbf22a515cd933bb94934ef03..c8fe7096be433699ecc24715d1c576fc5e5cd81a 100644 (file)
@@ -174,43 +174,23 @@ TAG_HANDLER_BEGIN(BODY, "BODY")
 
     TAG_HANDLER_PROC(tag)
     {
-        unsigned long tmp;
         wxColour clr;
 
-        if (tag.HasParam(wxT("TEXT")))
+        if (tag.GetParamAsColour(wxT("TEXT"), &clr))
            {
-            if (tag.ScanParam(wxT("TEXT"), wxT("#%lX"), &tmp) == 1)
-               {
-                clr = wxColour((unsigned char)((tmp & 0xFF0000) >> 16),
-                                                          (unsigned char)((tmp & 0x00FF00) >> 8),
-                                                          (unsigned char)(tmp & 0x0000FF));
-                m_WParser->SetActualColor(clr);
-                m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr));
-            }
-       }
-
-        if (tag.HasParam(wxT("LINK")))
-           {
-            if (tag.ScanParam(wxT("LINK"), wxT("#%lX"), &tmp) == 1)
-               {
-                clr = wxColour((unsigned char)((tmp & 0xFF0000) >> 16),
-                                                          (unsigned char)((tmp & 0x00FF00) >> 8),
-                                                          (unsigned char)(tmp & 0x0000FF));
-                m_WParser->SetLinkColor(clr);
-           }
+            m_WParser->SetActualColor(clr);
+            m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr));
         }
 
-        if (tag.HasParam(wxT("BGCOLOR")))
+        if (tag.GetParamAsColour(wxT("LINK"), &clr))
+            m_WParser->SetLinkColor(clr);
+
+        if (tag.GetParamAsColour(wxT("BGCOLOR"), &clr))
            {
-            if (tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &tmp) == 1)
-               {
-                clr = wxColour((unsigned char)((tmp & 0xFF0000) >> 16),
-                                                          (unsigned char)((tmp & 0x00FF00) >> 8),
-                                                          (unsigned char)(tmp & 0x0000FF));
-                m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND));
-                if (m_WParser->GetWindow() != NULL)
-                    m_WParser->GetWindow()->SetBackgroundColour(clr);
-           }
+            m_WParser->GetContainer()->InsertCell(
+                new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND));
+            if (m_WParser->GetWindow() != NULL)
+                m_WParser->GetWindow()->SetBackgroundColour(clr);
         }
         return FALSE;
     }
index 01d149d748ea5efb4d23762ec8e21af4a2ac109e..c4a0c6fe31a93879d40e899b1b29ef6175eeaf6b 100644 (file)
@@ -49,8 +49,10 @@ FORCE_LINK_ME(m_tables)
 
 
 typedef struct {
-        int width, units;                      // universal
-        int leftpos, pixwidth, maxrealwidth;   // temporary (depends on width of table)
+        int width, units;                      
+                // universal
+        int leftpos, pixwidth, maxrealwidth;   
+                // temporary (depends on width of table)
     } colStruct;
 
 typedef enum {
@@ -90,7 +92,7 @@ class wxHtmlTableCell : public wxHtmlContainerCell
                 // number of actual column (ranging from 0..m_NumCols)
 
         // default values (for table and row):
-        int m_tBkg, m_rBkg;
+        wxColour m_tBkg, m_rBkg;
         wxString m_tValign, m_rValign;
 
         double m_PixelScale;
@@ -117,18 +119,23 @@ wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& t
  : wxHtmlContainerCell(parent)
 {
     m_PixelScale = pixel_scale;
-    m_HasBorders = (tag.HasParam(wxT("BORDER")) && tag.GetParam(wxT("BORDER")) != wxT("0"));
+    m_HasBorders = (tag.GetParam(wxT("BORDER")) != wxT("0"));
     m_ColsInfo = NULL;
     m_NumCols = m_NumRows = 0;
     m_CellInfo = NULL;
     m_ActualCol = m_ActualRow = -1;
 
     /* scan params: */
-    m_tBkg = m_rBkg = -1;
-    if (tag.HasParam(wxT("BGCOLOR"))) tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &m_tBkg);
-    if (tag.HasParam(wxT("VALIGN"))) m_tValign = tag.GetParam(wxT("VALIGN")); else m_tValign = wxEmptyString;
-    if (tag.HasParam(wxT("CELLSPACING")) && tag.ScanParam(wxT("CELLSPACING"), wxT("%i"), &m_Spacing) == 1) {} else m_Spacing = 2;
-    if (tag.HasParam(wxT("CELLPADDING")) && tag.ScanParam(wxT("CELLPADDING"), wxT("%i"), &m_Padding) == 1) {} else m_Padding = 3;
+    if (tag.HasParam(wxT("BGCOLOR"))) 
+        tag.GetParamAsColour(wxT("BGCOLOR"), &m_tBkg);
+    if (tag.HasParam(wxT("VALIGN"))) 
+        m_tValign = tag.GetParam(wxT("VALIGN")); 
+    else 
+        m_tValign = wxEmptyString;
+    if (!tag.GetParamAsInt(wxT("CELLSPACING"), &m_Spacing))
+        m_Spacing = 2;
+    if (!tag.GetParamAsInt(wxT("CELLPADDING"), &m_Padding))
+        m_Padding = 3;
     m_Spacing = (int)(m_PixelScale * (double)m_Spacing);
     m_Padding = (int)(m_PixelScale * (double)m_Padding);
 
@@ -202,7 +209,7 @@ void wxHtmlTableCell::AddRow(const wxHtmlTag& tag)
     // scan params:
     m_rBkg = m_tBkg;
     if (tag.HasParam(wxT("BGCOLOR"))) 
-        tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &m_rBkg);
+        tag.GetParamAsColour(wxT("BGCOLOR"), &m_rBkg);
     if (tag.HasParam(wxT("VALIGN"))) 
         m_rValign = tag.GetParam(wxT("VALIGN")); 
     else 
@@ -226,7 +233,8 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
     do 
     {
         m_ActualCol++;
-    } while ((m_ActualCol < m_NumCols) && (m_CellInfo[m_ActualRow][m_ActualCol].flag != cellFree));
+    } while ((m_ActualCol < m_NumCols) && 
+             (m_CellInfo[m_ActualRow][m_ActualCol].flag != cellFree));
     
     if (m_ActualCol > m_NumCols - 1)
         ReallocCols(m_ActualCol + 1);
@@ -244,11 +252,11 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
 
     // width:
     {
-        if (tag.HasParam("WIDTH")) 
+        if (tag.HasParam(wxT("WIDTH")))
         {
-            wxString wd = tag.GetParam("WIDTH");
+            wxString wd = tag.GetParam(wxT("WIDTH"));
 
-            if (wd[wd.Length()-1] == '%') 
+            if (wd[wd.Length()-1] == wxT('%'))
             {
                 wxSscanf(wd.c_str(), wxT("%i%%"), &m_ColsInfo[c].width);
                 m_ColsInfo[c].units = wxHTML_UNITS_PERCENT;
@@ -265,14 +273,16 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
 
     // spanning:
     {
-        if (tag.HasParam(wxT("COLSPAN"))) tag.ScanParam(wxT("COLSPAN"), wxT("%i"), &m_CellInfo[r][c].colspan);
-        if (tag.HasParam(wxT("ROWSPAN"))) tag.ScanParam(wxT("ROWSPAN"), wxT("%i"), &m_CellInfo[r][c].rowspan);
+        tag.GetParamAsInt(wxT("COLSPAN"), &m_CellInfo[r][c].colspan);
+        tag.GetParamAsInt(wxT("ROWSPAN"), &m_CellInfo[r][c].rowspan);
         if ((m_CellInfo[r][c].colspan != 1) || (m_CellInfo[r][c].rowspan != 1)) 
         {
             int i, j;
 
-            if (r + m_CellInfo[r][c].rowspan > m_NumRows) ReallocRows(r + m_CellInfo[r][c].rowspan);
-            if (c + m_CellInfo[r][c].colspan > m_NumCols) ReallocCols(c + m_CellInfo[r][c].colspan);
+            if (r + m_CellInfo[r][c].rowspan > m_NumRows) 
+                ReallocRows(r + m_CellInfo[r][c].rowspan);
+            if (c + m_CellInfo[r][c].colspan > m_NumCols) 
+                ReallocCols(c + m_CellInfo[r][c].colspan);
             for (i = r; i < r + m_CellInfo[r][c].rowspan; i++)
                 for (j = c; j < c + m_CellInfo[r][c].colspan; j++)
                     m_CellInfo[i][j].flag = cellSpan;
@@ -282,13 +292,11 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
 
     //background color:
     {
-        int bk = m_rBkg;
-        if (tag.HasParam(wxT("BGCOLOR"))) tag.ScanParam(wxT("BGCOLOR"), wxT("#%lX"), &bk);
-        if (bk != -1) 
-        {
-            wxColour clr = wxColour((bk & 0xFF0000) >> 16 , (bk & 0x00FF00) >> 8, (bk & 0x0000FF));
-            cell->SetBackgroundColour(clr);
-        }
+        wxColour bk = m_rBkg;
+        if (tag.HasParam(wxT("BGCOLOR"))) 
+            tag.GetParamAsColour(wxT("BGCOLOR"), &bk);
+        if (bk.Ok())
+            cell->SetBackgroundColour(bk);
     }
     if (m_HasBorders)
         cell->SetBorder(TABLE_BORDER_CLR_2, TABLE_BORDER_CLR_1);
@@ -296,10 +304,15 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
     // vertical alignment:
     {
         wxString valign;
-        if (tag.HasParam(wxT("VALIGN"))) valign = tag.GetParam(wxT("VALIGN")); else valign = m_tValign;
+        if (tag.HasParam(wxT("VALIGN"))) 
+            valign = tag.GetParam(wxT("VALIGN")); 
+        else 
+            valign = m_tValign;
         valign.MakeUpper();
-        if (valign == wxT("TOP")) m_CellInfo[r][c].valign = wxHTML_ALIGN_TOP;
-        else if (valign == wxT("BOTTOM")) m_CellInfo[r][c].valign = wxHTML_ALIGN_BOTTOM;
+        if (valign == wxT("TOP")) 
+            m_CellInfo[r][c].valign = wxHTML_ALIGN_TOP;
+        else if (valign == wxT("BOTTOM")) 
+            m_CellInfo[r][c].valign = wxHTML_ALIGN_BOTTOM;
         else m_CellInfo[r][c].valign = wxHTML_ALIGN_CENTER;
     }
 
@@ -470,7 +483,8 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH")
             m_Table = new wxHtmlTableCell(c, tag, m_WParser->GetPixelScale());
             m_OldAlign = m_WParser->GetAlign();
             m_tAlign = wxEmptyString;
-            if (tag.HasParam(wxT("ALIGN"))) m_tAlign = tag.GetParam(wxT("ALIGN"));
+            if (tag.HasParam(wxT("ALIGN")))
+                m_tAlign = tag.GetParam(wxT("ALIGN"));
 
             ParseInner(tag);
 
@@ -489,7 +503,8 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH")
             {
                 m_Table->AddRow(tag);
                 m_rAlign = m_tAlign;
-                if (tag.HasParam(wxT("ALIGN"))) m_rAlign = tag.GetParam(wxT("ALIGN"));
+                if (tag.HasParam(wxT("ALIGN"))) 
+                    m_rAlign = tag.GetParam(wxT("ALIGN"));
             }
 
             // new cell
@@ -510,10 +525,13 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH")
                     wxString als;
 
                     als = m_rAlign;
-                    if (tag.HasParam(wxT("ALIGN"))) als = tag.GetParam(wxT("ALIGN"));
+                    if (tag.HasParam(wxT("ALIGN"))) 
+                        als = tag.GetParam(wxT("ALIGN"));
                     als.MakeUpper();
-                    if (als == wxT("RIGHT")) m_WParser->SetAlign(wxHTML_ALIGN_RIGHT);
-                    else if (als == wxT("CENTER")) m_WParser->SetAlign(wxHTML_ALIGN_CENTER);
+                    if (als == wxT("RIGHT")) 
+                        m_WParser->SetAlign(wxHTML_ALIGN_RIGHT);
+                    else if (als == wxT("CENTER")) 
+                        m_WParser->SetAlign(wxHTML_ALIGN_CENTER);
                 }
                 m_WParser->OpenContainer();
             }