[gnumeric] A better fix for sheet objects printing, but still not perfect.
- From: Jean Bréfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] A better fix for sheet objects printing, but still not perfect.
- Date: Sun, 23 Aug 2015 07:47:56 +0000 (UTC)
commit 84f51d91425748eac1a1ce9f6d2d4fb2e073ad2d
Author: Jean Brefort <jean brefort normalesup org>
Date: Sun Aug 23 09:47:24 2015 +0200
A better fix for sheet objects printing, but still not perfect.
ChangeLog | 7 +++++++
src/print.c | 39 ++++++++++++++++++++++++++-------------
src/sheet-object.c | 20 ++++++++++++--------
src/xml-sax-write.c | 16 +---------------
4 files changed, 46 insertions(+), 36 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a290f2d..06dc190 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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
diff --git a/src/print.c b/src/print.c
index 9b114aa..a514774 100644
--- a/src/print.c
+++ b/src/print.c
@@ -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));
diff --git a/src/sheet-object.c b/src/sheet-object.c
index 94ad625..2586b16 100644
--- a/src/sheet-object.c
+++ b/src/sheet-object.c
@@ -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
diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c
index 13e9cc5..6962d3a 100644
--- a/src/xml-sax-write.c
+++ b/src/xml-sax-write.c
@@ -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",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]