[gnumeric] Make sure that the objects bounds are always updated



commit 8057cc867f404cbd46c78840b42aa62744facb35
Author: Jean Brefort <jean brefort normalesup org>
Date:   Mon Aug 24 09:17:42 2015 +0200

    Make sure that the objects bounds are always updated

 ChangeLog           |    7 +++++++
 src/sheet-object.c  |   30 ++++++++++++------------------
 src/xml-sax-write.c |   16 +++++++++++++++-
 3 files changed, 34 insertions(+), 19 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 06dc190..f47a2e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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
diff --git a/src/sheet-object.c b/src/sheet-object.c
index 2586b16..eae7dd8 100644
--- a/src/sheet-object.c
+++ b/src/sheet-object.c
@@ -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 {
diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c
index 6962d3a..13e9cc5 100644
--- a/src/xml-sax-write.c
+++ b/src/xml-sax-write.c
@@ -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",


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