[gnumeric] Fix border handling for merged cells in LaTeX export.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Fix border handling for merged cells in LaTeX export.
- Date: Sun, 28 Apr 2013 22:17:18 +0000 (UTC)
commit 03074d492680bf788c0f4b91acff9b283c6485a1
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sun Apr 28 16:15:59 2013 -0600
Fix border handling for merged cells in LaTeX export.
2013-04-28 Andreas J. Guelzow <aguelzow pyrshep ca>
* latex.c (latex2e_find_this_vline): renamed from latex2e_find_vline
(latex2e_find_vline): new, taking care of merges
(latex2e_find_hhlines): handle merges
NEWS | 3 ++
plugins/html/ChangeLog | 6 ++++
plugins/html/latex.c | 64 +++++++++++++++++++++++++++++++----------------
3 files changed, 51 insertions(+), 22 deletions(-)
---
diff --git a/NEWS b/NEWS
index e5fa289..3c2c151 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
Gnumeric 1.12.3
+Andreas:
+ * Fix border handling for merged cells in LaTeX export.
+
--------------------------------------------------------------------------
Gnumeric 1.12.2
diff --git a/plugins/html/ChangeLog b/plugins/html/ChangeLog
index f7b42eb..1a89d9f 100644
--- a/plugins/html/ChangeLog
+++ b/plugins/html/ChangeLog
@@ -1,3 +1,9 @@
+2013-04-28 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * latex.c (latex2e_find_this_vline): renamed from latex2e_find_vline
+ (latex2e_find_vline): new, taking care of merges
+ (latex2e_find_hhlines): handle merges
+
2013-04-26 Morten Welinder <terra gnome org>
* Release 1.12.2
diff --git a/plugins/html/latex.c b/plugins/html/latex.c
index 64ee72e..f269724 100644
--- a/plugins/html/latex.c
+++ b/plugins/html/latex.c
@@ -700,7 +700,7 @@ latex2e_write_table_header(GsfOutput *output, int num_cols)
*
*/
static GnmStyleBorderType
-latex2e_find_vline (int col, int row, Sheet *sheet, GnmStyleElement which_border)
+latex2e_find_this_vline (int col, int row, Sheet *sheet, GnmStyleElement which_border)
{
GnmBorder const *border;
GnmStyle const *style;
@@ -711,8 +711,7 @@ latex2e_find_vline (int col, int row, Sheet *sheet, GnmStyleElement which_border
style = sheet_style_get (sheet, col, row);
border = gnm_style_get_border (style, which_border);
- if (!(gnm_style_border_is_blank (border) ||
- border->line_type == GNM_STYLE_BORDER_NONE))
+ if (!gnm_style_border_is_blank (border))
return border->line_type;
if (which_border == MSTYLE_BORDER_LEFT) {
@@ -720,20 +719,43 @@ latex2e_find_vline (int col, int row, Sheet *sheet, GnmStyleElement which_border
return GNM_STYLE_BORDER_NONE;
style = sheet_style_get (sheet, col - 1, row);
border = gnm_style_get_border (style, MSTYLE_BORDER_RIGHT);
- return ((gnm_style_border_is_blank (border)) ? GNM_STYLE_BORDER_NONE :
- border->line_type);
+ return ((border == NULL) ? GNM_STYLE_BORDER_NONE : border->line_type);
} else {
if ((col+1) >= colrow_max (TRUE, sheet))
return GNM_STYLE_BORDER_NONE;
style = sheet_style_get (sheet, col + 1, row);
border = gnm_style_get_border (style, MSTYLE_BORDER_LEFT);
- return ((gnm_style_border_is_blank (border)) ? GNM_STYLE_BORDER_NONE :
- border->line_type);
+ return ((border == NULL) ? GNM_STYLE_BORDER_NONE : border->line_type);
}
return GNM_STYLE_BORDER_NONE;
}
+static GnmStyleBorderType
+latex2e_find_vline (int col, int row, Sheet *sheet, GnmStyleElement which_border)
+{
+ /* We are checking for NONE boreders first since there should only be a few merged ranges */
+ GnmStyleBorderType result = latex2e_find_this_vline (col, row, sheet, which_border);
+ GnmCellPos pos;
+ GnmRange const * range;
+
+ if (result == GNM_STYLE_BORDER_NONE)
+ return GNM_STYLE_BORDER_NONE;
+
+ pos.col = col;
+ pos.row = row;
+ range = gnm_sheet_merge_contains_pos (sheet, &pos);
+
+ if (range) {
+ if ((which_border == MSTYLE_BORDER_LEFT && col == range->start.col)
+ || (which_border == MSTYLE_BORDER_RIGHT&& col == range->end.col))
+ return result;
+ else
+ return GNM_STYLE_BORDER_NONE;
+ }
+ return result;
+}
+
/**
* latex2e_print_vert_border:
*
@@ -1136,8 +1158,8 @@ latex2e_find_hhlines (GnmStyleBorderType *clines, G_GNUC_UNUSED int length, int
{
GnmStyle const *style;
GnmBorder const *border;
- /* GnmRange const *merge_range; */
- /* GnmCellPos pos; */
+ GnmRange const *range;
+ GnmCellPos pos;
style = sheet_style_get (sheet, col, row);
border = gnm_style_get_border (style, type);
@@ -1145,19 +1167,17 @@ latex2e_find_hhlines (GnmStyleBorderType *clines, G_GNUC_UNUSED int length, int
return FALSE;
clines[0] = border->line_type;
- /* The following code completes the border above a merged cell. As long as we allow partial */
- /* borders above & below merged cells in Gnumeric we should not enable this. */
- /* pos.col = col; */
- /* pos.row = row; */
- /* merge_range = gnm_sheet_merge_is_corner (sheet, &pos); */
- /* if (merge_range != NULL) { */
- /* int i; */
-
- /* for (i = 1; i < MIN (merge_range->end.col - merge_range->start.col + 1, */
- /* length); i++) */
- /* clines[i] = border->line_type; */
- /* } */
-
+ pos.col = col;
+ pos.row = row;
+ range = gnm_sheet_merge_contains_pos (sheet, &pos);
+ if (range) {
+ if ((type == MSTYLE_BORDER_TOP && row > range->start.row)
+ || (type == MSTYLE_BORDER_BOTTOM&& row < range->end.row)) {
+ clines[0] = GNM_STYLE_BORDER_NONE;
+ return FALSE;
+ }
+ }
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]