Commit 2a420f79 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg
Browse files

bug 16490. We were attempting to display the entered text rather than the

bug 16490.
We were attempting to display the entered text rather than the formated text
and falling over when the copied cell had no sheet.  This is not lovely, but it
is as clean as we'll get for now.

2000-07-06  Jody Goldberg <jgoldberg@home.com>

	* src/sheet-style.c (sheet_style_compute_from_list) : Make public.
	  and rename from sheet_mstyle_compute_from_list.  Changed all
	  callers.

	* src/rendered-value.c (rendered_value_new) : Optionaly take a style
	  list.  Use it if offered.

	* src/cell.c (cell_render_value) : New signature for rendered_value_new.

	* src/render-ascii.c (cell_region_render_ascii) : Temporarily reverse
	  the style list so that it goes in the correct direction.   Use
	  rendered_value not entered_text.

	* src/clipboard.c (clipboard_prepend_cell) : Init the Cell::pos with
	  the offsets.  This is useful in when looking up formats.
parent 67f3bc5e
2000-07-06 Jody Goldberg <jgoldberg@home.com>
* src/sheet-style.c (sheet_style_compute_from_list) : Make public.
and rename from sheet_mstyle_compute_from_list. Changed all
callers.
* src/rendered-value.c (rendered_value_new) : Optionaly take a style
list. Use it if offered.
* src/cell.c (cell_render_value) : New signature for rendered_value_new.
* src/render-ascii.c (cell_region_render_ascii) : Temporarily reverse
the style list so that it goes in the correct direction. Use
rendered_value not entered_text.
* src/clipboard.c (clipboard_prepend_cell) : Init the Cell::pos with
the offsets. This is useful in when looking up formats.
2000-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-financial.c: Implemented COUPNCD().
......
2000-07-06 Jody Goldberg <jgoldberg@home.com>
* src/sheet-style.c (sheet_style_compute_from_list) : Make public.
and rename from sheet_mstyle_compute_from_list. Changed all
callers.
* src/rendered-value.c (rendered_value_new) : Optionaly take a style
list. Use it if offered.
* src/cell.c (cell_render_value) : New signature for rendered_value_new.
* src/render-ascii.c (cell_region_render_ascii) : Temporarily reverse
the style list so that it goes in the correct direction. Use
rendered_value not entered_text.
* src/clipboard.c (clipboard_prepend_cell) : Init the Cell::pos with
the offsets. This is useful in when looking up formats.
2000-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-financial.c: Implemented COUPNCD().
......
2000-07-06 Jody Goldberg <jgoldberg@home.com>
* src/sheet-style.c (sheet_style_compute_from_list) : Make public.
and rename from sheet_mstyle_compute_from_list. Changed all
callers.
* src/rendered-value.c (rendered_value_new) : Optionaly take a style
list. Use it if offered.
* src/cell.c (cell_render_value) : New signature for rendered_value_new.
* src/render-ascii.c (cell_region_render_ascii) : Temporarily reverse
the style list so that it goes in the correct direction. Use
rendered_value not entered_text.
* src/clipboard.c (clipboard_prepend_cell) : Init the Cell::pos with
the offsets. This is useful in when looking up formats.
2000-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-financial.c: Implemented COUPNCD().
......
2000-07-06 Jody Goldberg <jgoldberg@home.com>
* src/sheet-style.c (sheet_style_compute_from_list) : Make public.
and rename from sheet_mstyle_compute_from_list. Changed all
callers.
* src/rendered-value.c (rendered_value_new) : Optionaly take a style
list. Use it if offered.
* src/cell.c (cell_render_value) : New signature for rendered_value_new.
* src/render-ascii.c (cell_region_render_ascii) : Temporarily reverse
the style list so that it goes in the correct direction. Use
rendered_value not entered_text.
* src/clipboard.c (clipboard_prepend_cell) : Init the Cell::pos with
the offsets. This is useful in when looking up formats.
2000-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-financial.c: Implemented COUPNCD().
......
2000-07-06 Jody Goldberg <jgoldberg@home.com>
* src/sheet-style.c (sheet_style_compute_from_list) : Make public.
and rename from sheet_mstyle_compute_from_list. Changed all
callers.
* src/rendered-value.c (rendered_value_new) : Optionaly take a style
list. Use it if offered.
* src/cell.c (cell_render_value) : New signature for rendered_value_new.
* src/render-ascii.c (cell_region_render_ascii) : Temporarily reverse
the style list so that it goes in the correct direction. Use
rendered_value not entered_text.
* src/clipboard.c (clipboard_prepend_cell) : Init the Cell::pos with
the offsets. This is useful in when looking up formats.
2000-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-financial.c: Implemented COUPNCD().
......
2000-07-06 Jody Goldberg <jgoldberg@home.com>
* src/sheet-style.c (sheet_style_compute_from_list) : Make public.
and rename from sheet_mstyle_compute_from_list. Changed all
callers.
* src/rendered-value.c (rendered_value_new) : Optionaly take a style
list. Use it if offered.
* src/cell.c (cell_render_value) : New signature for rendered_value_new.
* src/render-ascii.c (cell_region_render_ascii) : Temporarily reverse
the style list so that it goes in the correct direction. Use
rendered_value not entered_text.
* src/clipboard.c (clipboard_prepend_cell) : Init the Cell::pos with
the offsets. This is useful in when looking up formats.
2000-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-financial.c: Implemented COUPNCD().
......
2000-07-06 Jody Goldberg <jgoldberg@home.com>
* src/sheet-style.c (sheet_style_compute_from_list) : Make public.
and rename from sheet_mstyle_compute_from_list. Changed all
callers.
* src/rendered-value.c (rendered_value_new) : Optionaly take a style
list. Use it if offered.
* src/cell.c (cell_render_value) : New signature for rendered_value_new.
* src/render-ascii.c (cell_region_render_ascii) : Temporarily reverse
the style list so that it goes in the correct direction. Use
rendered_value not entered_text.
* src/clipboard.c (clipboard_prepend_cell) : Init the Cell::pos with
the offsets. This is useful in when looking up formats.
2000-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-financial.c: Implemented COUPNCD().
......
......@@ -672,7 +672,7 @@ cell_render_value (Cell *cell)
RenderedValue *rv;
g_return_if_fail (cell != NULL);
rv = rendered_value_new (cell);
rv = rendered_value_new (cell, NULL);
if (cell->rendered_value)
rendered_value_destroy (cell->rendered_value);
cell->rendered_value = rv;
......
......@@ -256,8 +256,8 @@ clipboard_prepend_cell (Sheet *sheet, int col, int row, Cell *cell, void *user_d
copy = g_new (CellCopy, 1);
copy->type = CELL_COPY_TYPE_CELL;
copy->u.cell = cell_copy (cell);
copy->col_offset = col - c->base_col;
copy->row_offset = row - c->base_row;
copy->u.cell->pos.col = copy->col_offset = col - c->base_col;
copy->u.cell->pos.row = copy->row_offset = row - c->base_row;
c->list = g_list_prepend (c->list, copy);
......
......@@ -22,7 +22,7 @@ char *
cell_region_render_ascii (CellRegion *cr)
{
GString *all, *line;
GList *l;
GList *l, *styles;
char ***data, *return_val;
int col, row;
......@@ -33,19 +33,28 @@ cell_region_render_ascii (CellRegion *cr)
for (row = 0; row < cr->rows; row++)
data [row] = g_new0 (char *, cr->cols);
/* temporarily reverse the style list to be in forwards order
* so that we can look things up
*/
styles = g_list_reverse (cr->styles);
for (l = cr->list; l; l = l->next){
CellCopy *c_copy = l->data;
char *v;
if (c_copy->type == CELL_COPY_TYPE_TEXT)
if (c_copy->type != CELL_COPY_TYPE_TEXT) {
RenderedValue *rv = rendered_value_new (c_copy->u.cell, styles);
v = rendered_value_get_text (rv);
rendered_value_destroy (rv);
} else
v = g_strdup (c_copy->u.text);
else
/* FIXME: We need to use the style's format information here */
v = cell_get_entered_text (c_copy->u.cell);
data [c_copy->row_offset][c_copy->col_offset] = v;
}
/* Restore the style list to reverse order in case some one pastes again */
cr->styles = g_list_reverse (styles);
all = g_string_new (NULL);
line = g_string_new (NULL);
for (row = 0; row < cr->rows; row++){
......
......@@ -40,7 +40,7 @@
* formula instead of its value.
*/
RenderedValue *
rendered_value_new (Cell * cell)
rendered_value_new (Cell *cell, GList *styles)
{
RenderedValue *res;
StyleColor *color;
......@@ -49,7 +49,8 @@ rendered_value_new (Cell * cell)
g_return_val_if_fail (cell != NULL, NULL);
g_return_val_if_fail (cell->value != NULL, NULL);
if (cell_has_expr (cell) && cell->sheet->display_formulas) {
if (cell_has_expr (cell) &&
cell->sheet != NULL && cell->sheet->display_formulas) {
ParsePos pp;
char *tmpstr = expr_tree_as_string (cell->u.expression,
parse_pos_init_cell (&pp, cell));
......@@ -57,7 +58,10 @@ rendered_value_new (Cell * cell)
g_free (tmpstr);
color = NULL;
} else {
MStyle *mstyle = cell_get_mstyle (cell);
MStyle *mstyle = (styles != NULL)
? sheet_style_compute_from_list (styles, cell->pos.col, cell->pos.row)
: cell_get_mstyle (cell);
if (mstyle_is_element_set (mstyle, MSTYLE_FORMAT)) {
/* entered text CAN be null if called by
* set_value
......@@ -89,7 +93,7 @@ rendered_value_new (Cell * cell)
}
void
rendered_value_destroy (RenderedValue * rv)
rendered_value_destroy (RenderedValue *rv)
{
if (rv->rendered_text) {
string_unref (rv->rendered_text);
......@@ -120,7 +124,7 @@ rendered_value_destroy (RenderedValue * rv)
void
rendered_value_calc_size (Cell const *cell)
{
RenderedValue * rv = cell->rendered_value;
RenderedValue *rv = cell->rendered_value;
MStyle *mstyle = cell_get_mstyle (cell);
StyleFont * const style_font =
sheet_view_get_style_font (cell->sheet, mstyle);
......@@ -209,7 +213,7 @@ rendered_value_calc_size (Cell const *cell)
* Caller is responsible for freeing the result
*/
char *
rendered_value_get_text (RenderedValue const * rv)
rendered_value_get_text (RenderedValue const *rv)
{
g_return_val_if_fail (rv->rendered_text != NULL,
g_strdup ("ERROR"));
......@@ -227,7 +231,7 @@ rendered_value_get_text (RenderedValue const * rv)
* a string representation of the value.
*/
char *
cell_get_rendered_text (Cell const * cell)
cell_get_rendered_text (Cell const *cell)
{
g_return_val_if_fail (cell != NULL,
g_strdup("ERROR"));
......@@ -279,7 +283,7 @@ cell_get_entered_text (Cell const *cell)
}
int
cell_rendered_width (Cell const * cell)
cell_rendered_width (Cell const *cell)
{
if (!cell || !cell->rendered_value)
return 0;
......@@ -287,7 +291,7 @@ cell_rendered_width (Cell const * cell)
return cell->rendered_value->width_pixel;
}
int
cell_rendered_height (Cell const * cell)
cell_rendered_height (Cell const *cell)
{
if (!cell || !cell->rendered_value)
return 0;
......
......@@ -27,7 +27,7 @@ struct _RenderedValue {
int width_pixel, height_pixel;
};
RenderedValue * rendered_value_new (Cell *cell);
RenderedValue * rendered_value_new (Cell *cell, GList *styles);
void rendered_value_destroy (RenderedValue *rv);
void rendered_value_calc_size (Cell const *cell);
......
......@@ -596,8 +596,8 @@ sheet_style_attach (Sheet *sheet, Range range,
sheet_style_cache_flush (sd, STYLE_CACHE_FLUSH_ALL);
}
static MStyle *
sheet_mstyle_compute_from_list (GList *list, int col, int row)
MStyle *
sheet_style_compute_from_list (GList *list, int col, int row)
{
GList *l;
GList *style_list;
......@@ -744,8 +744,7 @@ sheet_style_compute (const Sheet *sheet, int col, int row)
style_cache_misses++;
}
mstyle = sheet_mstyle_compute_from_list (sd->cached_list,
col, row);
mstyle = sheet_style_compute_from_list (sd->cached_list, col, row);
sheet_style_cache_add (sd, col, row, mstyle);
......@@ -1176,6 +1175,12 @@ sheet_style_relocate (const ExprRelocateInfo *rinfo)
sheet_style_cache_flush (rinfo->origin_sheet->style_data, STYLE_CACHE_FLUSH_ALL);
}
/*
* sheet_get_styles_in_range :
*
* Returns the list of styles that intersect the supplied range @r.
* NOTE : The list is in REVERSE ORDER.
*/
GList *
sheet_get_styles_in_range (Sheet *sheet, const Range *r)
{
......@@ -1566,14 +1571,14 @@ border_check (UniqueClosure *cl, GList *edge_list,
continue; /* an outer corner */
/* Calculate the respective styles */
inner_style = sheet_mstyle_compute_from_list (edge_list,
inner.col,
inner.row);
inner_style = sheet_style_compute_from_list (edge_list,
inner.col,
inner.row);
if (do_outer)
outer_style = sheet_mstyle_compute_from_list (edge_list,
outer.col,
outer.row);
outer_style = sheet_style_compute_from_list (edge_list,
outer.col,
outer.row);
/* Build up the border maps + do internal borders */
switch (location) {
......@@ -1713,9 +1718,9 @@ sheet_unique_cb (Sheet *sheet, Range const *range,
frags = range_fragment_list_clip (middle_list, &middle);
for (l = frags; l; l = g_list_next (l)) {
Range *r = l->data;
MStyle *tmp = sheet_mstyle_compute_from_list (middle_list,
r->start.col,
r->start.row);
MStyle *tmp = sheet_style_compute_from_list (middle_list,
r->start.col,
r->start.row);
mstyle_compare (cl->mstyle, tmp);
mstyle_unref (tmp);
}
......
......@@ -249,6 +249,8 @@ int sheet_row_size_fit_pixels (Sheet *sheet, int row);
/* sheet-style.c */
MStyle *sheet_style_compute (const Sheet *sheet,
int col, int row);
MStyle *sheet_style_compute_from_list (GList *list,
int col, int row);
void sheet_style_attach (Sheet *sheet, Range range,
MStyle *mstyle);
void sheet_style_attach_single (Sheet *sheet, int col, int row,
......
Markdown is supported
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