[gnumeric] ssconvert: enable --export-file-per-sheet for html and latex.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ssconvert: enable --export-file-per-sheet for html and latex.
- Date: Fri, 11 May 2018 00:03:18 +0000 (UTC)
commit 3b6c52bfe5aae236b3226eecca5e645a1fcb58cd
Author: Morten Welinder <terra gnome org>
Date: Thu May 10 20:02:13 2018 -0400
ssconvert: enable --export-file-per-sheet for html and latex.
Also fix scope of latex savers -- one sheet only.
NEWS | 1 +
plugins/html/html.c | 18 +++++++++++++-----
plugins/html/latex.c | 34 +++++++++++++++++++++++-----------
plugins/html/plugin.xml.in | 21 ++++++++++++++-------
4 files changed, 51 insertions(+), 23 deletions(-)
---
diff --git a/NEWS b/NEWS
index 0e9e87a..a6717d2 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Morten:
* Introspection fixes.
* Work around gtk+ breakage re. link colors.
* Fix problems with ssconvert --export-file-per-sheet. [#694408]
+ * Enable --export-file-per-sheet for html and latex.
--------------------------------------------------------------------------
Gnumeric 1.12.41
diff --git a/plugins/html/html.c b/plugins/html/html.c
index 364487c..f400c7a 100644
--- a/plugins/html/html.c
+++ b/plugins/html/html.c
@@ -48,6 +48,8 @@
#include <gsf/gsf-output.h>
#include <string.h>
+#define SHEET_SELECTION_KEY "sheet-selection"
+
/*
* html_version_t:
*
@@ -694,9 +696,10 @@ static void
html_file_save (GOFileSaver const *fs, GOIOContext *io_context,
WorkbookView const *wb_view, GsfOutput *output, html_version_t version)
{
- GSList *sheets, *ptr;
Workbook *wb = wb_view_get_workbook (wb_view);
GOFileSaveScope save_scope;
+ GPtrArray *sel;
+ unsigned ui, count;
g_return_if_fail (fs != NULL);
g_return_if_fail (wb != NULL);
@@ -775,12 +778,17 @@ html_file_save (GOFileSaver const *fs, GOIOContext *io_context,
break;
}
- sheets = workbook_sheets (wb);
save_scope = go_file_saver_get_save_scope (fs);
- for (ptr = sheets ; ptr != NULL ; ptr = ptr->next) {
- write_sheet (output, (Sheet *) ptr->data, version, save_scope);
+
+ sel = g_object_get_data (G_OBJECT (wb), SHEET_SELECTION_KEY);
+ count = sel ? sel->len : workbook_sheet_count (wb);
+ for (ui = 0; ui < count; ui++) {
+ Sheet *sheet = sel
+ ? g_ptr_array_index (sel, ui)
+ : workbook_sheet_by_index (wb, ui);
+ write_sheet (output, sheet, version, save_scope);
}
- g_slist_free (sheets);
+
if (version == HTML32 || version == HTML40 || version == XHTML)
gsf_output_puts (output, "</body>\n</html>\n");
}
diff --git a/plugins/html/latex.c b/plugins/html/latex.c
index 0afc47b..722b331 100644
--- a/plugins/html/latex.c
+++ b/plugins/html/latex.c
@@ -63,6 +63,8 @@
#include <gsf/gsf-output.h>
#include <string.h>
+#define SHEET_SELECTION_KEY "sheet-selection"
+
typedef enum {
LATEX_NO_BORDER = 0,
LATEX_SINGLE_BORDER = 1,
@@ -1290,6 +1292,7 @@ void
latex_file_save (G_GNUC_UNUSED GOFileSaver const *fs, G_GNUC_UNUSED GOIOContext *io_context,
WorkbookView const *wb_view, GsfOutput *output)
{
+ Workbook *wb = wb_view_get_workbook (wb_view);
GnmCell *cell;
Sheet *current_sheet;
GnmRange total_range;
@@ -1299,9 +1302,13 @@ latex_file_save (G_GNUC_UNUSED GOFileSaver const *fs, G_GNUC_UNUSED GOIOContext
GnmStyleBorderType *clines, *this_clines;
GnmStyleBorderType *prev_vert = NULL, *next_vert = NULL, *this_vert;
gboolean needs_hline;
+ GPtrArray *sel;
- /* Get the topmost sheet and its range from the plugin function argument. */
- current_sheet = wb_view_cur_sheet(wb_view);
+ /* Get the sheet and its range from the plugin function argument. */
+ sel = g_object_get_data (G_OBJECT (wb), SHEET_SELECTION_KEY);
+ current_sheet = sel && sel->len
+ ? g_ptr_array_index (sel, 0)
+ : wb_view_cur_sheet(wb_view);
total_range = file_saver_sheet_get_extent (current_sheet);
/* This is the preamble of the LaTeX2e file. */
@@ -1551,7 +1558,7 @@ latex2e_table_write_file_header(GsfOutput *output)
}
/**
- * latex_table_file_save : The LaTeX2e exporter plugin function.
+ * latex_table_file_save_impl : The LaTeX2e exporter plugin function.
*
* @WorkbookView: this provides the way to access the sheet being exported.
* @outpu: where we'll write.
@@ -1563,16 +1570,21 @@ latex2e_table_write_file_header(GsfOutput *output)
static void
latex_table_file_save_impl (WorkbookView const *wb_view, GsfOutput *output, gboolean all)
{
+ Workbook *wb = wb_view_get_workbook (wb_view);
GnmCell *cell;
Sheet *current_sheet;
GnmRange total_range;
int row, col;
+ GPtrArray *sel;
/* This is the preamble of the LaTeX2e file. */
latex2e_table_write_file_header(output);
- /* Get the topmost sheet and its range from the plugin function argument. */
- current_sheet = wb_view_cur_sheet(wb_view);
+ /* Get the sheet and its range from the plugin function argument. */
+ sel = g_object_get_data (G_OBJECT (wb), SHEET_SELECTION_KEY);
+ current_sheet = sel && sel->len
+ ? g_ptr_array_index (sel, 0)
+ : wb_view_cur_sheet(wb_view);
total_range = file_saver_sheet_get_extent (current_sheet);
/* Step through the sheet, writing cells as appropriate. */
@@ -1609,8 +1621,8 @@ latex_table_file_save_impl (WorkbookView const *wb_view, GsfOutput *output, gboo
* @WorkbookView: this provides the way to access the sheet being exported.
* @output: where we'll write.
*
- * This writes the top sheet of a Gnumeric workbook as the content of a latex table environment.
- * We try to avoid all formatting.
+ * This writes the selected sheet of a Gnumeric workbook as the content of a
+ * latex table environment. We try to avoid all formatting.
*/
void
latex_table_file_save (G_GNUC_UNUSED GOFileSaver const *fs,
@@ -1628,13 +1640,13 @@ latex_table_file_save (G_GNUC_UNUSED GOFileSaver const *fs,
* @WorkbookView: this provides the way to access the sheet being exported.
* @output: where we'll write.
*
- * This writes the top sheet of a Gnumeric workbook as the content of a latex table environment.
- * We try to avoid all formatting.
+ * This writes the selected sheet of a Gnumeric workbook as the content of a
+ * latex table environment. We try to avoid all formatting.
*/
void
latex_table_visible_file_save (G_GNUC_UNUSED GOFileSaver const *fs,
- G_GNUC_UNUSED GOIOContext *io_context,
- WorkbookView const *wb_view, GsfOutput *output)
+ G_GNUC_UNUSED GOIOContext *io_context,
+ WorkbookView const *wb_view, GsfOutput *output)
{
latex_table_file_save_impl (wb_view, output, FALSE);
}
diff --git a/plugins/html/plugin.xml.in b/plugins/html/plugin.xml.in
index 9d49ff3..7016237 100644
--- a/plugins/html/plugin.xml.in
+++ b/plugins/html/plugin.xml.in
@@ -17,22 +17,26 @@
<suffix>htm</suffix>
</suffixes>
</service>
- <service type="file_saver" id="html32" file_extension="html" format_level="write_only">
+ <service type="file_saver" id="html32" file_extension="html"
+ format_level="write_only" sheet_selection="true">
<information>
<_description>HTML 3.2 (*.html)</_description>
</information>
</service>
- <service type="file_saver" id="html40" file_extension="html" format_level="write_only">
+ <service type="file_saver" id="html40" file_extension="html"
+ format_level="write_only" sheet_selection="true">
<information>
<_description>HTML 4.0 (*.html)</_description>
</information>
</service>
- <service type="file_saver" id="html40frag" file_extension="html" format_level="write_only">
+ <service type="file_saver" id="html40frag" file_extension="html"
+ format_level="write_only" sheet_selection="true">
<information>
<_description>HTML (*.html) fragment</_description>
</information>
</service>
- <service type="file_saver" id="xhtml" file_extension="html" format_level="write_only">
+ <service type="file_saver" id="xhtml" file_extension="html"
+ format_level="write_only" sheet_selection="true">
<information>
<_description>XHTML (*.html)</_description>
</information>
@@ -44,17 +48,20 @@
<_description>XHTML range - for export to clipboard</_description>
</information>
</service>
- <service type="file_saver" id="latex" file_extension="tex" format_level="write_only">
+ <service type="file_saver" id="latex" file_extension="tex"
+ save_scope="sheet" format_level="write_only" sheet_selection="true">
<information>
<_description>LaTeX 2e (*.tex)</_description>
</information>
</service>
- <service type="file_saver" id="latex_table" file_extension="tex" format_level="write_only">
+ <service type="file_saver" id="latex_table" file_extension="tex"
+ save_scope="sheet" format_level="write_only" sheet_selection="true">
<information>
<_description>LaTeX 2e (*.tex) table fragment</_description>
</information>
</service>
- <service type="file_saver" id="latex_table_visible" file_extension="tex"
format_level="write_only">
+ <service type="file_saver" id="latex_table_visible" file_extension="tex"
+ save_scope="sheet" format_level="write_only" sheet_selection="true">
<information>
<_description>LaTeX 2e (*.tex) table fragment of visible rows</_description>
</information>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]