Commit 8057cc86 authored by Jean Bréfort's avatar Jean Bréfort

Make sure that the objects bounds are always updated

parent 84f51d91
2015-08-24 Jean Brefort <jean.brefort@normalesup.org>
* src/sheet-object.c (sheet_object_update_bounds),
(sheet_object_set_sheet), (sheet_object_pts_to_anchor): make sure that
the objects bounds are always updated. Really fix printing.
* src/xml-sax-write.c (xml_write_objects): revert previous change.
2015-08-23 Jean Brefort <jean.brefort@normalesup.org>
* src/print.c (gnm_print_sheet_objects): a better fix for sheet objects
......
......@@ -492,6 +492,12 @@ sheet_object_update_bounds (SheetObject *so, GnmCellPos const *pos)
so->anchor.cell_bound.end.row < pos->row)
return;
if (so->anchor.mode != GNM_SO_ANCHOR_TWO_CELLS) {
double x[4];
sheet_object_anchor_to_pts (&so->anchor, so->sheet, x);
sheet_object_pts_to_anchor (&so->anchor, so->sheet, x);
}
switch (so->anchor.mode) {
default:
case GNM_SO_ANCHOR_TWO_CELLS:
......@@ -581,6 +587,12 @@ sheet_object_set_sheet (SheetObject *so, Sheet *sheet)
g_object_ref (so);
sheet->sheet_objects = g_slist_prepend (sheet->sheet_objects, so);
/* Update object bounds for absolute and one cell anchored objects */
if (so->anchor.mode != GNM_SO_ANCHOR_TWO_CELLS) {
double x[4];
sheet_object_anchor_to_pts (&so->anchor, sheet, x);
sheet_object_pts_to_anchor (&so->anchor, sheet, x);
}
/* FIXME : add a flag to sheet to have sheet_update do this */
sheet_objects_max_extent (sheet);
......@@ -957,17 +969,6 @@ sheet_object_pts_to_anchor (SheetObjectAnchor *anchor,
int col, row;
double x, y, tmp = 0;
ColRowInfo const *ci;
/* if (anchor->mode == GNM_SO_ANCHOR_ABSOLUTE) {
anchor->cell_bound.start.col = 0;
anchor->cell_bound.start.row = 0;
anchor->cell_bound.end.col = 0;
anchor->cell_bound.end.row = 0;
anchor->offset[0] = res_pts[0];
anchor->offset[1] = res_pts[1];
anchor->offset[2] = res_pts[2] - res_pts[0];
anchor->offset[3] = res_pts[3] - res_pts[1];
return;
}*/
/* find end column */
col = x = 0;
do {
......@@ -1006,13 +1007,6 @@ sheet_object_pts_to_anchor (SheetObjectAnchor *anchor,
anchor->cell_bound.start.row = row;
anchor->offset[1] = (anchor->mode == GNM_SO_ANCHOR_ABSOLUTE)?
res_pts[1]: (res_pts[1] - y) / tmp;
/* if (anchor->mode == GNM_SO_ANCHOR_ONE_CELL) {
anchor->cell_bound.end.col = col;
anchor->cell_bound.end.row = row;
anchor->offset[2] = res_pts[2] - res_pts[0];
anchor->offset[3] = res_pts[3] - res_pts[1];
return;
}*/
/* find end column */
do {
......
......@@ -1250,6 +1250,19 @@ xml_write_objects (GnmOutputXML *state, GSList *objects)
SheetObjectClass *klass = GNM_SO_CLASS (G_OBJECT_GET_CLASS (so));
GnmRange cell_bound = so->anchor.cell_bound;
switch (so->anchor.mode) {
case GNM_SO_ANCHOR_TWO_CELLS:
break;
case GNM_SO_ANCHOR_ONE_CELL:
cell_bound.end = cell_bound.start;
break;
case GNM_SO_ANCHOR_ABSOLUTE:
range_init (&cell_bound, 0, 0, 0, 0);
break;
default:
g_assert_not_reached ();
}
if (needs_container) {
needs_container = FALSE;
gsf_xml_out_start_element (state->output, GNM "Objects");
......@@ -1264,7 +1277,8 @@ xml_write_objects (GnmOutputXML *state, GSList *objects)
gsf_xml_out_start_element (state->output, tmp);
if (so->name)
gsf_xml_out_add_cstr (state->output, "Name", so->name);
gsf_xml_out_add_cstr (state->output, "ObjectBound", range_as_string (&cell_bound));
if (so->anchor.mode != GNM_SO_ANCHOR_ABSOLUTE)
gsf_xml_out_add_cstr (state->output, "ObjectBound", range_as_string (&cell_bound));
if (so->anchor.mode != GNM_SO_ANCHOR_TWO_CELLS)
gsf_xml_out_add_enum (state->output,
"AnchorMode",
......
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