Commit 2d520dbd authored by Morten Welinder's avatar Morten Welinder
Browse files

Text export: take conditional formats into account

They don't actually matter most of the time, but a conditional number
format can be set and the configurable text export can be convinced
to pay attention to formats.
parent 76914832
2021-02-14 Morten Welinder <terra@gnome.org>
* src/cell.c (gnm_cell_get_effective_style): New function to
resolve conditional styling.
* src/rendered-value.c (gnm_rendered_value_new): Use
gnm_cell_get_effective_style instead of doing it by hand.
2021-01-30 Morten Welinder <terra@gnome.org>
* autogen.sh: check that YELP_HELP_INIT has been expanded.
......
......@@ -28,6 +28,7 @@ Morten:
* Allow plain space as 1000s separator in FR locale.
* Fix graph size problem affecting image output. [#507]
* Check for yelp in autogen. [#558]
* Fix ssconvert problem with conditional styles.
--------------------------------------------------------------------------
Gnumeric 1.12.48
......
......@@ -931,7 +931,7 @@ latex2e_write_multicolumn_cell (GsfOutput *output, GnmCell *cell, int start_col,
GnmStyleBorderType right_border = GNM_STYLE_BORDER_NONE;
/* Print the cell according to its style. */
GnmStyle const *style = gnm_cell_get_style (cell);
GnmStyle const *style = gnm_cell_get_effective_style (cell);
gboolean hidden = gnm_style_get_contents_hidden (style);
g_return_if_fail (style != NULL);
......@@ -1515,7 +1515,7 @@ latex_file_save (GOFileSaver const *fs, G_GNUC_UNUSED GOIOContext *io_context,
static void
latex2e_table_write_cell (GsfOutput *output, GnmCell *cell)
{
GnmStyle const *style = gnm_cell_get_style (cell);
GnmStyle const *style = gnm_cell_get_effective_style (cell);
if (gnm_style_get_contents_hidden (style))
return;
......
......@@ -48,7 +48,7 @@ roff_fprintf (GsfOutput *output, GnmCell *cell)
if (gnm_cell_is_empty (cell))
return 0;
style = gnm_cell_get_style (cell);
style = gnm_cell_get_effective_style (cell);
if (style != NULL && gnm_style_get_contents_hidden (style))
return 0;
......@@ -121,7 +121,7 @@ roff_file_save (GOFileSaver const *fs, GOIOContext *io_context,
if (!cell) {
gsf_output_printf (output, "l");
} else {
GnmStyle const *style = gnm_cell_get_style (cell);
GnmStyle const *style = gnm_cell_get_effective_style (cell);
if (!style)
break;
if (gnm_style_get_align_h (style) & GNM_HALIGN_RIGHT)
......
......@@ -22,6 +22,7 @@
#include <number-match.h>
#include <sheet-style.h>
#include <parse-util.h>
#include <style-conditions.h>
#include <goffice/goffice.h>
......@@ -1001,6 +1002,36 @@ gnm_cell_get_style (GnmCell const *cell)
cell->pos.row);
}
/**
* gnm_cell_get_effective_style:
* @cell: #GnmCell to query
*
* Returns: (transfer none): the fully qualified style for @cell, taking any
* conditional formats into account.
*/
GnmStyle const *
gnm_cell_get_effective_style (GnmCell const *cell)
{
GnmStyleConditions *conds;
GnmStyle const *mstyle;
g_return_val_if_fail (cell != NULL, NULL);
mstyle = gnm_cell_get_style (cell);
conds = gnm_style_get_conditions (mstyle);
if (conds) {
GnmEvalPos ep;
int res;
eval_pos_init_cell (&ep, cell);
res = gnm_style_conditions_eval (conds, &ep);
if (res >= 0)
mstyle = gnm_style_get_cond_style (mstyle, res);
}
return mstyle;
}
/**
* gnm_cell_get_format_given_style: (skip)
* @cell: #GnmCell to query
......@@ -1017,7 +1048,7 @@ gnm_cell_get_format_given_style (GnmCell const *cell, GnmStyle const *style)
g_return_val_if_fail (cell != NULL, go_format_general ());
if (style == NULL)
style = gnm_cell_get_style (cell);
style = gnm_cell_get_effective_style (cell);
fmt = gnm_style_get_format (style);
......@@ -1040,7 +1071,8 @@ gnm_cell_get_format_given_style (GnmCell const *cell, GnmStyle const *style)
GOFormat const *
gnm_cell_get_format (GnmCell const *cell)
{
return gnm_cell_get_format_given_style (cell, NULL);
GnmStyle const *mstyle = gnm_cell_get_effective_style (cell);
return gnm_cell_get_format_given_style (cell, mstyle);
}
static GnmValue *
......
......@@ -82,6 +82,7 @@ void gnm_cell_convert_expr_to_value (GnmCell *cell);
* Manipulate GnmCell attributes
*/
GnmStyle const *gnm_cell_get_style (GnmCell const *cell);
GnmStyle const *gnm_cell_get_effective_style (GnmCell const *cell);
GOFormat const *gnm_cell_get_format (GnmCell const *cell);
GOFormat const *gnm_cell_get_format_given_style (GnmCell const *cell, GnmStyle const *style);
......
......@@ -236,7 +236,7 @@ cell_calc_span (GnmCell const *cell, int *col1, int *col2)
g_return_if_fail (cell != NULL);
sheet = cell->base.sheet;
style = gnm_cell_get_style (cell);
style = gnm_cell_get_effective_style (cell);
h_align = gnm_style_default_halign (style, cell);
/*
......
......@@ -31,7 +31,6 @@
#include <style-color.h>
#include <style-font.h>
#include <style-border.h>
#include <style-conditions.h>
#include <sheet.h>
#include <sheet-merge.h>
#include <gnm-format.h>
......@@ -265,7 +264,6 @@ gnm_rendered_value_new (GnmCell const *cell,
PangoDirection dir;
char const *text;
gboolean debug = debug_rv ();
GnmStyleConditions *conds;
g_return_val_if_fail (cell != NULL, NULL);
......@@ -290,18 +288,7 @@ gnm_rendered_value_new (GnmCell const *cell,
/* Must come after above gnm_cell_eval. */
g_return_val_if_fail (cell->value != NULL, NULL);
mstyle = gnm_cell_get_style (cell);
conds = gnm_style_get_conditions (mstyle);
if (conds) {
GnmEvalPos ep;
int res;
eval_pos_init_cell (&ep, cell);
res = gnm_style_conditions_eval (conds, &ep);
if (res >= 0)
mstyle = gnm_style_get_cond_style (mstyle, res);
}
mstyle = gnm_cell_get_effective_style (cell);
rotation = gnm_style_get_rotation (mstyle);
if (rotation) {
......
......@@ -2644,7 +2644,7 @@ cb_max_cell_height (GnmCellIter const *iter, struct cb_fit *data)
* that they are all the same height, more or less.
*/
Sheet const *sheet = cell->base.sheet;
height = gnm_style_get_pango_height (gnm_cell_get_style (cell),
height = gnm_style_get_pango_height (gnm_cell_get_effective_style (cell),
sheet->rendered_values->context,
sheet->last_zoom_factor_used);
} else {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment