Commit 84f51d91 authored by Jean Bréfort's avatar Jean Bréfort

A better fix for sheet objects printing, but still not perfect.

parent 653c1fbe
2015-08-23 Jean Brefort <jean.brefort@normalesup.org>
* src/print.c (gnm_print_sheet_objects): a better fix for sheet objects
printing, but still not perfect.
* src/sheet-object.c (sheet_object_pts_to_anchor): ditto.
* src/xml-sax-write.c (xml_write_objects): ditto.
2015-08-22 Jean Brefort <jean.brefort@normalesup.org>
* src/print.c (gnm_print_sheet_objects): fix printing of sheet objects
......
......@@ -221,24 +221,37 @@ gnm_print_sheet_objects (cairo_t *cr,
/* move to top left */
if (sheet->text_is_rtl) {
double tr_x, tr_y;
tr_x = (so->anchor.mode != GNM_SO_ANCHOR_ABSOLUTE)?
base_x - 0.5 /* because of leading gridline */
- sheet_col_get_distance_pts (sheet, 0, r->end.col+1)
+ sheet_col_get_distance_pts (sheet, 0,
range->start.col):
base_x - 0.5;
tr_y = base_y + 0.5
+ sheet_row_get_distance_pts (sheet, 0, r->start.row)
- sheet_row_get_distance_pts (sheet, 0,
range->start.row);
switch (so->anchor.mode) {
case GNM_SO_ANCHOR_ABSOLUTE:
tr_x = base_x - 0.5; /* because of leading gridline */
tr_y = base_y + 0.5;
break;
case GNM_SO_ANCHOR_ONE_CELL:
tr_x = base_x - 0.5
- sheet_col_get_distance_pts (sheet, 0, r->start.col+1)
+ sheet_col_get_distance_pts (sheet, 0, range->start.col);
tr_y = base_y + 0.5
+ sheet_row_get_distance_pts (sheet, 0, r->start.row)
- sheet_row_get_distance_pts (sheet, 0, range->start.row);
break;
default:
tr_x = base_x - 0.5
- sheet_col_get_distance_pts (sheet, 0, r->end.col+1)
+ sheet_col_get_distance_pts (sheet, 0, range->start.col);
tr_y = base_y + 0.5
+ sheet_row_get_distance_pts (sheet, 0, r->start.row)
- sheet_row_get_distance_pts (sheet, 0, range->start.row);
break;
}
cairo_translate (cr, tr_x, tr_y);
} else
cairo_translate (cr,
base_x + 0.5
cairo_translate (cr, (so->anchor.mode == GNM_SO_ANCHOR_ABSOLUTE)?
base_x + 0.5: base_x + 0.5
+ sheet_col_get_distance_pts (sheet, 0, r->start.col)
- sheet_col_get_distance_pts (sheet, 0,
range->start.col),
base_y + 0.5
(so->anchor.mode == GNM_SO_ANCHOR_ABSOLUTE)?
base_y + 0.5: base_y + 0.5
+ sheet_row_get_distance_pts (sheet, 0, r->start.row)
- sheet_row_get_distance_pts (sheet, 0,
range->start.row));
......
......@@ -957,7 +957,7 @@ 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) {
/* 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;
......@@ -967,7 +967,7 @@ sheet_object_pts_to_anchor (SheetObjectAnchor *anchor,
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 {
......@@ -985,7 +985,8 @@ sheet_object_pts_to_anchor (SheetObjectAnchor *anchor,
x -= tmp;
}
anchor->cell_bound.start.col = col;
anchor->offset[0] = (res_pts[0] - x) / tmp;
anchor->offset[0] = (anchor->mode == GNM_SO_ANCHOR_ABSOLUTE)?
res_pts[0]: (res_pts[0] - x) / tmp;
/* find start row */
row = y = 0;
do {
......@@ -1003,14 +1004,15 @@ sheet_object_pts_to_anchor (SheetObjectAnchor *anchor,
y -= tmp;
}
anchor->cell_bound.start.row = row;
anchor->offset[1] = (res_pts[1] - y) / tmp;
if (anchor->mode == GNM_SO_ANCHOR_ONE_CELL) {
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 {
......@@ -1028,7 +1030,8 @@ sheet_object_pts_to_anchor (SheetObjectAnchor *anchor,
x -= tmp;
}
anchor->cell_bound.end.col = col;
anchor->offset[2] = (res_pts[2] - x) / tmp;
anchor->offset[2] = (anchor->mode == GNM_SO_ANCHOR_TWO_CELLS)?
(res_pts[2] - x) / tmp: res_pts[2] - res_pts[0];
/* find end row */
do {
ci = sheet_row_get_info (sheet, row);
......@@ -1045,7 +1048,8 @@ sheet_object_pts_to_anchor (SheetObjectAnchor *anchor,
y -= tmp;
}
anchor->cell_bound.end.row = row;
anchor->offset[3] = (res_pts[3] - y) / tmp;
anchor->offset[3] = (anchor->mode == GNM_SO_ANCHOR_TWO_CELLS)?
(res_pts[3] - y) / tmp: res_pts[3] - res_pts[1];
}
void
......
......@@ -1250,19 +1250,6 @@ 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");
......@@ -1277,8 +1264,7 @@ 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);
if (so->anchor.mode != GNM_SO_ANCHOR_ABSOLUTE)
gsf_xml_out_add_cstr (state->output, "ObjectBound", range_as_string (&cell_bound));
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