[gnumeric] Fix printing of sheet objects with one cell or absolute anchors. [#753961]
- From: Jean Bréfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Fix printing of sheet objects with one cell or absolute anchors. [#753961]
- Date: Sat, 22 Aug 2015 13:37:29 +0000 (UTC)
commit 653c1fbe47d2a9023f29f338ab37f29b27f9b751
Author: Jean Brefort <jean brefort normalesup org>
Date: Sat Aug 22 15:37:13 2015 +0200
Fix printing of sheet objects with one cell or absolute anchors. [#753961]
ChangeLog | 6 ++++
NEWS | 3 ++
src/print.c | 10 ++++--
src/sheet-object.c | 82 +++++++++++++++++++++++++++++++++-------------------
4 files changed, 67 insertions(+), 34 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1a13c31..a290f2d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-08-22 Jean Brefort <jean brefort normalesup org>
+
+ * src/print.c (gnm_print_sheet_objects): fix printing of sheet objects
+ with one cell or absolute anchors. [#753961]
+ * src/sheet-object.c (sheet_object_draw_cairo):
+
2015-07-28 Morten Welinder <terra gnome org>
* configure.ac: Post-release bump.
diff --git a/NEWS b/NEWS
index ae4352e..2585838 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
Gnumeric 1.12.24
+Jean:
+ * Fix printing of sheet objects with one cell or absolute anchors. [#753961]
+
--------------------------------------------------------------------------
Gnumeric 1.12.23
diff --git a/src/print.c b/src/print.c
index e6cd990..9b114aa 100644
--- a/src/print.c
+++ b/src/print.c
@@ -221,10 +221,12 @@ gnm_print_sheet_objects (cairo_t *cr,
/* move to top left */
if (sheet->text_is_rtl) {
double tr_x, tr_y;
- tr_x = 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);
+ 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,
diff --git a/src/sheet-object.c b/src/sheet-object.c
index 9642ed8..94ad625 100644
--- a/src/sheet-object.c
+++ b/src/sheet-object.c
@@ -757,38 +757,60 @@ sheet_object_draw_cairo (SheetObject const *so, cairo_t *cr, gboolean rtl)
SheetObjectAnchor const *anchor;
double x = 0., y = 0., width, height, cell_width, cell_height;
anchor = sheet_object_get_anchor (so);
- cell_width = sheet_col_get_distance_pts (so->sheet,
- anchor->cell_bound.start.col,
- anchor->cell_bound.start.col + 1);
- cell_height = sheet_row_get_distance_pts (so->sheet,
- anchor->cell_bound.start.row,
- anchor->cell_bound.start.row + 1);
- x = cell_width * anchor->offset[0];
-
- y = cell_height * anchor->offset[1];
- cell_width = sheet_col_get_distance_pts (so->sheet,
- anchor->cell_bound.end.col,
- anchor->cell_bound.end.col + 1);
- cell_height = sheet_row_get_distance_pts (so->sheet,
- anchor->cell_bound.end.row,
- anchor->cell_bound.end.row + 1);
-
- if (rtl) {
- x = cell_width * (1 - anchor->offset[2]);
- }
- if (sheet_object_can_resize (so)) {
- width = sheet_col_get_distance_pts (so->sheet,
+ if (anchor->mode == GNM_SO_ANCHOR_ABSOLUTE) {
+ x = anchor->offset[0];
+ y = anchor->offset[1];
+ if (sheet_object_can_resize (so)) {
+ width = anchor->offset[2];
+ height = anchor->offset[3];
+ } else
+ sheet_object_default_size ((SheetObject *) so, &width, &height);
+ if (rtl)
+ x = -x - width;
+ } else {
+ cell_width = sheet_col_get_distance_pts (so->sheet,
anchor->cell_bound.start.col,
- anchor->cell_bound.end.col + 1);
- height = sheet_row_get_distance_pts (so->sheet,
+ anchor->cell_bound.start.col + 1);
+ cell_height = sheet_row_get_distance_pts (so->sheet,
anchor->cell_bound.start.row,
- anchor->cell_bound.end.row + 1);
- width -= x;
- height -= y;
- width -= cell_width * (1. - anchor->offset[2]);
- height -= cell_height * (1 - anchor->offset[3]);
- } else
- sheet_object_default_size ((SheetObject *) so, &width, &height);
+ anchor->cell_bound.start.row + 1);
+ x = cell_width * anchor->offset[0];
+
+ y = cell_height * anchor->offset[1];
+ if (anchor->mode == GNM_SO_ANCHOR_TWO_CELLS) {
+ cell_width = sheet_col_get_distance_pts (so->sheet,
+ anchor->cell_bound.end.col,
+ anchor->cell_bound.end.col + 1);
+ cell_height = sheet_row_get_distance_pts (so->sheet,
+ anchor->cell_bound.end.row,
+ anchor->cell_bound.end.row + 1);
+
+ if (rtl)
+ x = cell_width * (1 - anchor->offset[2]);
+
+ if (sheet_object_can_resize (so)) {
+ width = sheet_col_get_distance_pts (so->sheet,
+ anchor->cell_bound.start.col,
+ anchor->cell_bound.end.col + 1);
+ height = sheet_row_get_distance_pts (so->sheet,
+ anchor->cell_bound.start.row,
+ anchor->cell_bound.end.row + 1);
+ width -= x;
+ height -= y;
+ width -= cell_width * (1. - ((rtl)? anchor->offset[0]:
anchor->offset[2]));
+ height -= cell_height * (1 - anchor->offset[3]);
+ } else
+ sheet_object_default_size ((SheetObject *) so, &width, &height);
+ } else {
+ if (sheet_object_can_resize (so)) {
+ width = anchor->offset[2];
+ height = anchor->offset[3];
+ } else
+ sheet_object_default_size ((SheetObject *) so, &width, &height);
+ if (rtl)
+ x = cell_width * (1 - anchor->offset[0]) - width;
+ }
+ }
/* we don't need to save/restore cairo, the caller must do it */
cairo_translate (cr, x, y);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]