diff options
Diffstat (limited to 'src/table.cc')
-rw-r--r-- | src/table.cc | 85 |
1 files changed, 68 insertions, 17 deletions
diff --git a/src/table.cc b/src/table.cc index 622868ca..d66b32b0 100644 --- a/src/table.cc +++ b/src/table.cc @@ -30,14 +30,15 @@ using namespace dw::core::style; static void Html_tag_open_table_cell(DilloHtml *html, const char *tag, int tagsize, - dw::core::style::TextAlignType text_align); + dw::core::style::TextAlignType text_align); +static void Html_tag_content_table_cell(DilloHtml *html, + const char *tag, int tagsize); /* * <TABLE> */ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize) { - dw::core::Widget *table; const char *attrbuf; int32_t border = -1, cellspacing = -1, cellpadding = -1, bgcolor = -1; CssLength cssLength; @@ -99,7 +100,7 @@ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize) CSS_TYPE_COLOR, bgcolor); } - HT2TB(html)->addParbreak (0, html->styleEngine->wordStyle ()); + html->styleEngine->style (); // evaluate now, so we can build non-css hints for the cells /* The style for the cells */ html->styleEngine->clearNonCssHints (); @@ -135,13 +136,21 @@ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize) CSS_TYPE_LENGTH_PERCENTAGE, cssLength); } +} +void Html_tag_content_table(DilloHtml *html, const char *tag, int tagsize) +{ + dw::core::Widget *table; + + HT2TB(html)->addParbreak (0, html->styleEngine->wordStyle ()); table = new dw::Table(prefs.limit_text_width); HT2TB(html)->addWidget (table, html->styleEngine->style ()); + HT2TB(html)->addParbreak (0, html->styleEngine->wordStyle ()); S_TOP(html)->table_mode = DILLO_HTML_TABLE_MODE_TOP; S_TOP(html)->table_border_mode = DILLO_HTML_TABLE_BORDER_SEPARATE; S_TOP(html)->cell_text_align_set = FALSE; S_TOP(html)->table = table; + } /* @@ -177,8 +186,6 @@ void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize) html->styleEngine->inheritBackgroundColor (); - ((dw::Table*)S_TOP(html)->table)->addRow (html->styleEngine->style ()); - if (bgcolor != -1) { html->styleEngine->setNonCssHint(CSS_PROPERTY_BACKGROUND_COLOR, CSS_TYPE_COLOR, bgcolor); @@ -188,6 +195,20 @@ void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize) default: break; } +} + +void Html_tag_content_tr(DilloHtml *html, const char *tag, int tagsize) +{ + switch (S_TOP(html)->table_mode) { + case DILLO_HTML_TABLE_MODE_NONE: + return; + case DILLO_HTML_TABLE_MODE_TOP: + case DILLO_HTML_TABLE_MODE_TR: + case DILLO_HTML_TABLE_MODE_TD: + ((dw::Table*)S_TOP(html)->table)->addRow (html->styleEngine->style ()); + default: + break; + } S_TOP(html)->table_mode = DILLO_HTML_TABLE_MODE_TR; } @@ -201,6 +222,11 @@ void Html_tag_open_td(DilloHtml *html, const char *tag, int tagsize) dw::core::style::TEXT_ALIGN_LEFT); } +void Html_tag_content_td(DilloHtml *html, const char *tag, int tagsize) +{ + Html_tag_content_table_cell (html, tag, tagsize); +} + /* * <TH> */ @@ -210,6 +236,11 @@ void Html_tag_open_th(DilloHtml *html, const char *tag, int tagsize) dw::core::style::TEXT_ALIGN_CENTER); } +void Html_tag_content_th(DilloHtml *html, const char *tag, int tagsize) +{ + Html_tag_content_table_cell (html, tag, tagsize); +} + /* * Utilities */ @@ -311,8 +342,6 @@ static void Html_tag_open_table_cell(DilloHtml *html, const char *tag, int tagsize, dw::core::style::TextAlignType text_align) { - Widget *col_tb; - int colspan = 1, rowspan = 1; const char *attrbuf; int32_t bgcolor; @@ -329,16 +358,6 @@ static void Html_tag_open_table_cell(DilloHtml *html, /* continues */ case DILLO_HTML_TABLE_MODE_TR: case DILLO_HTML_TABLE_MODE_TD: - if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "colspan"))) { - char *invalid; - colspan = strtol(attrbuf, &invalid, 10); - if ((colspan < 0) || (attrbuf == invalid)) - colspan = 1; - } - /* TODO: check errors? */ - if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "rowspan"))) - rowspan = MAX(1, strtol (attrbuf, NULL, 10)); - /* text style */ if (!S_TOP(html)->cell_text_align_set) { html->styleEngine->setNonCssHint (CSS_PROPERTY_TEXT_ALIGN, @@ -365,6 +384,38 @@ static void Html_tag_open_table_cell(DilloHtml *html, CSS_TYPE_COLOR, bgcolor); } + default: + /* compiler happiness */ + break; + } +} + +static void Html_tag_content_table_cell(DilloHtml *html, + const char *tag, int tagsize) +{ + int colspan = 1, rowspan = 1; + const char *attrbuf; + Widget *col_tb; + + switch (S_TOP(html)->table_mode) { + case DILLO_HTML_TABLE_MODE_NONE: + return; + + case DILLO_HTML_TABLE_MODE_TOP: + BUG_MSG("<td> or <th> outside <tr>\n"); + /* a_Dw_table_add_cell takes care that dillo does not crash. */ + /* continues */ + case DILLO_HTML_TABLE_MODE_TR: + case DILLO_HTML_TABLE_MODE_TD: + if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "colspan"))) { + char *invalid; + colspan = strtol(attrbuf, &invalid, 10); + if ((colspan < 0) || (attrbuf == invalid)) + colspan = 1; + } + /* TODO: check errors? */ + if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "rowspan"))) + rowspan = MAX(1, strtol (attrbuf, NULL, 10)); if (html->styleEngine->style ()->textAlign == TEXT_ALIGN_STRING) col_tb = new dw::TableCell ( |