[gnumeric] Read HTML files with nested tables. [#594789]



commit 2d2e929cf9122d1d6702b52d6cfb578ba450fa1e
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Mon Jun 28 13:38:46 2010 -0600

    Read HTML files with nested tables. [#594789]
    
    2010-06-28  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* html_read.c (GnmHtmlTableCtxt): Add wb_view field.
    	(html_read_content): Add GnmHtmlTableCtxt argument and
    	  change all callers. Recurse into html_read_table as
    	  required.
    	(html_file_open): Initialize wb_view field

 NEWS                     |    1 +
 plugins/html/ChangeLog   |    8 ++++++++
 plugins/html/html_read.c |   28 ++++++++++++++++++++++++----
 3 files changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index 3ec8ad4..3ad37d7 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Andreas:
 	  table to be configured.
 	* Also store any markup if entering text in several cells at once.
 	  [#622530]
+	* Read HTML files with nested tables. [#594789]
 
 Jean:
 	* Fixed autofilter (and other) combo positions. [#621817]
diff --git a/plugins/html/ChangeLog b/plugins/html/ChangeLog
index 4ccf5b0..3e7cc9b 100644
--- a/plugins/html/ChangeLog
+++ b/plugins/html/ChangeLog
@@ -1,3 +1,11 @@
+2010-06-28  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* html_read.c (GnmHtmlTableCtxt): Add wb_view field.
+	(html_read_content): Add GnmHtmlTableCtxt argument and 
+	  change all callers. Recurse into html_read_table as 
+	  required.
+	(html_file_open): Initialize wb_view field
+
 2010-06-16  Morten Welinder <terra gnome org>
 
 	* Release 1.10.6
diff --git a/plugins/html/html_read.c b/plugins/html/html_read.c
index a2a22aa..e46b122 100644
--- a/plugins/html/html_read.c
+++ b/plugins/html/html_read.c
@@ -1,3 +1,4 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * html_read.c
  *
@@ -58,8 +59,14 @@
 typedef struct {
 	Sheet *sheet;
 	int   row;
+	WorkbookView *wb_view;
 } GnmHtmlTableCtxt;
 
+static void html_read_table (htmlNodePtr cur, htmlDocPtr doc, 
+			     WorkbookView *wb_view,
+			     GnmHtmlTableCtxt *tc);
+
+
 static Sheet *
 html_get_sheet (char const *name, Workbook *wb)
 {
@@ -100,7 +107,7 @@ html_append_text (GString *buf, const xmlChar *text)
 static void
 html_read_content (htmlNodePtr cur, GString *buf, GnmStyle *mstyle,
 		   xmlBufferPtr a_buf, GSList **hrefs, gboolean first,
-		   htmlDocPtr doc)
+		   htmlDocPtr doc, GnmHtmlTableCtxt *tc)
 {
 	htmlNodePtr ptr;
 
@@ -139,8 +146,20 @@ html_read_content (htmlNodePtr cur, GString *buf, GnmStyle *mstyle,
 					props = props->next;
 				}
 			}
-			html_read_content (
-				ptr, buf, mstyle, a_buf, hrefs, first, doc);
+			if (xmlStrEqual (ptr->name, CC2XML ("table"))) {
+				Sheet *last_sheet = tc->sheet;
+				int   last_row = tc->row;
+				tc->sheet = NULL;
+				tc->row   = -1;
+				html_read_table (ptr, doc, tc->wb_view, tc);
+				g_string_append_printf (buf, _("[see sheet %s]"), tc->sheet->name_quoted);
+				xmlBufferAdd (a_buf, CC2XML (_("The original html file is\n"
+							       "using nested tables.")), -1);
+				tc->sheet = last_sheet;
+				tc->row = last_row;
+			} else
+				html_read_content 
+					(ptr, buf, mstyle, a_buf, hrefs, first, doc, tc);
 		}
 		first = FALSE;
 	}
@@ -196,7 +215,7 @@ html_read_row (htmlNodePtr cur, htmlDocPtr doc, GnmHtmlTableCtxt *tc)
 				gnm_style_set_font_bold (mstyle, TRUE);
 
 			html_read_content (ptr, buf, mstyle, a_buf,
-					   &hrefs, TRUE, doc);
+					   &hrefs, TRUE, doc, tc);
 
 
 			if (g_slist_length (hrefs) >= 1 &&
@@ -541,6 +560,7 @@ html_file_open (GOFileOpener const *fo, GOIOContext *io_context,
 		xmlNodePtr ptr;
 		tc.sheet = NULL;
 		tc.row   = -1;
+		tc.wb_view = wb_view;
 		for (ptr = doc->children; ptr != NULL ; ptr = ptr->next)
 			html_search_for_tables (ptr, doc, wb_view, &tc);
 		xmlFreeDoc (doc);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]