[gnumeric] Add latex fragment exporter of visible rows only. [#739512]



commit 5f1a8962b629489fceff50a9e8e402375189304b
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Sun Nov 2 10:45:21 2014 -0700

    Add latex fragment exporter of visible rows only. [#739512]
    
    2014-11-02  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * latex.c (latex_table_file_save_impl): new
        (latex_table_file_save): use latex_table_file_save_impl
        (latex_table_visible_file_save): new
        * plugin.xml.in: add latex_table_visible_file_save
        * latex.h (latex_table_visible_file_save): new

 NEWS                       |    3 +
 plugins/html/ChangeLog     |    8 ++++
 plugins/html/latex.c       |   91 +++++++++++++++++++++++++++++++------------
 plugins/html/latex.h       |    5 ++
 plugins/html/plugin.xml.in |    5 ++
 5 files changed, 86 insertions(+), 26 deletions(-)
---
diff --git a/NEWS b/NEWS
index f52c5bc..a7b80bc 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 Gnumeric 1.12.19
 
+Andreas:
+       * Add latex fragment exporter of visible rows only. [#739512]
+
 Jean:
        * Fix ants problems.
 
diff --git a/plugins/html/ChangeLog b/plugins/html/ChangeLog
index f71d630..541f32f 100644
--- a/plugins/html/ChangeLog
+++ b/plugins/html/ChangeLog
@@ -1,3 +1,11 @@
+2014-11-02  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * latex.c (latex_table_file_save_impl): new
+       (latex_table_file_save): use latex_table_file_save_impl
+       (latex_table_visible_file_save): new
+       * plugin.xml.in: add latex_table_visible_file_save
+       * latex.h (latex_table_visible_file_save): new
+
 2014-09-25  Morten Welinder <terra gnome org>
 
        * Release 1.12.18
diff --git a/plugins/html/latex.c b/plugins/html/latex.c
index 6743108..0dd22da 100644
--- a/plugins/html/latex.c
+++ b/plugins/html/latex.c
@@ -8,8 +8,8 @@
  * Copyright (C) 2001 Adrian Custer, Berkeley
  * email: acuster nature berkeley edu
  *
- * Copyright (C) 2001-2006 Andreas J. Guelzow, Edmonton
- * email: aguelzow taliesin ca
+ * Copyright (C) 2001-2014 Andreas J. Guelzow, Edmonton
+ * email: aguelzow pyrshep ca
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -31,8 +31,10 @@
  * This file contains the LaTeX2e plugin functions.
  *
  *
- * The LaTeX2e function is named:
+ * The LaTeX2e functions are named:
  *             latex_file_save()
+ *              latex_table_visible_file_save()
+ *              latex_table_file_save
  *
  */
 
@@ -1554,18 +1556,15 @@ latex2e_table_write_file_header(GsfOutput *output)
 /**
  * latex_table_file_save :  The LaTeX2e exporter plugin function.
  *
- * @FileSaver:        New structure for file plugins. I don't understand.
- * @IOcontext:        currently not used but reserved for the future.
  * @WorkbookView:     this provides the way to access the sheet being exported.
- * @filename:         where we'll write.
+ * @outpu:            where we'll write.
+ * @all:              Whether to write all rows or just the visible ones.
  *
  * This writes the top 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,
-                      G_GNUC_UNUSED GOIOContext *io_context,
-                      WorkbookView const *wb_view, GsfOutput *output)
+static void
+latex_table_file_save_impl (WorkbookView const *wb_view, GsfOutput *output, gboolean all)
 {
        GnmCell *cell;
        Sheet *current_sheet;
@@ -1583,22 +1582,62 @@ latex_table_file_save (G_GNUC_UNUSED GOFileSaver const *fs,
        for (row = total_range.start.row; row <= total_range.end.row; row++) {
                ColRowInfo const * ri;
                ri = sheet_row_get_info (current_sheet, row);
-               if (ri->needs_respan)
-                       row_calc_spans ((ColRowInfo *) ri, row, current_sheet);
-
-               for (col = total_range.start.col; col <= total_range.end.col; col++) {
-                       /* Get the cell. */
-                       cell = sheet_cell_get (current_sheet, col, row);
-
-                       /* Check if we are not the first cell in the row.*/
-                       if (col != total_range.start.col)
-                               gsf_output_printf (output, "\t&");
-
-                       if (gnm_cell_is_empty (cell))
-                               continue;
-
-                       latex2e_table_write_cell(output, cell);
+               if (all || ri->visible) {
+                       if (ri->needs_respan)
+                               row_calc_spans ((ColRowInfo *) ri, row, current_sheet);
+                       
+                       for (col = total_range.start.col; col <= total_range.end.col; col++) {
+                               /* Get the cell. */
+                               cell = sheet_cell_get (current_sheet, col, row);
+                               
+                               /* Check if we are not the first cell in the row.*/
+                               if (col != total_range.start.col)
+                                       gsf_output_printf (output, "\t&");
+                               
+                               if (gnm_cell_is_empty (cell))
+                                       continue;
+                               
+                               latex2e_table_write_cell(output, cell);
+                       }
+                       gsf_output_printf (output, "\\\\\n");
                }
-               gsf_output_printf (output, "\\\\\n");
        }
 }
+
+/**
+ * latex_table_file_save :  The LaTeX2e exporter plugin function.
+ *
+ * @FileSaver:        New structure for file plugins. I don't understand.
+ * @IOcontext:        currently not used but reserved for the future.
+ * @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.
+ */
+void
+latex_table_file_save (G_GNUC_UNUSED GOFileSaver const *fs,
+                      G_GNUC_UNUSED GOIOContext *io_context,
+                      WorkbookView const *wb_view, GsfOutput *output)
+{
+       latex_table_file_save_impl (wb_view, output, TRUE);
+}
+
+/**
+ * latex_table_visible_file_save :  The LaTeX2e exporter plugin function.
+ *
+ * @FileSaver:        New structure for file plugins. I don't understand.
+ * @IOcontext:        currently not used but reserved for the future.
+ * @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.
+ */
+void
+latex_table_visible_file_save (G_GNUC_UNUSED GOFileSaver const *fs,
+                      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/latex.h b/plugins/html/latex.h
index 8186e3a..a72269b 100644
--- a/plugins/html/latex.h
+++ b/plugins/html/latex.h
@@ -31,4 +31,9 @@ void latex_file_save (GOFileSaver const *fs, GOIOContext *io_context,
 void latex_table_file_save (GOFileSaver const *fs, GOIOContext *io_context,
                            WorkbookView const *wb_view, GsfOutput *output);
 
+void latex_table_visible_file_save (GOFileSaver const *fs,
+                                   GOIOContext *io_context,
+                                   WorkbookView const *wb_view,
+                                   GsfOutput *output);
+
 #endif
diff --git a/plugins/html/plugin.xml.in b/plugins/html/plugin.xml.in
index f302dcf..9d49ff3 100644
--- a/plugins/html/plugin.xml.in
+++ b/plugins/html/plugin.xml.in
@@ -54,6 +54,11 @@
                                <_description>LaTeX 2e (*.tex) table fragment</_description>
                        </information>
                </service>
+               <service type="file_saver" id="latex_table_visible" file_extension="tex" 
format_level="write_only">
+                       <information>
+                               <_description>LaTeX 2e (*.tex) table fragment of visible rows</_description>
+                       </information>
+               </service>
                <service type="file_saver" id="roff" file_extension="me" format_level="write_only">
                        <information>
                                <_description>TROFF (*.me)</_description>


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