[dia] Bug 594891 - Print pagination relative to extents, not origin



commit 2522b33e8873a7250f2d2d46a0855ebf672ac17f
Author: Hans Breuer <hans breuer org>
Date:   Sun Nov 8 14:57:50 2009 +0100

    Bug 594891 - Print pagination relative to extents, not origin
    
    There was a mismatch between "page guides" and the actual pagination,
    now the page guides give a good estimate of the placement when
    printed (PDF exported).

 plug-ins/cairo/diacairo-print.c |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/plug-ins/cairo/diacairo-print.c b/plug-ins/cairo/diacairo-print.c
index ecaac72..b742024 100644
--- a/plug-ins/cairo/diacairo-print.c
+++ b/plug-ins/cairo/diacairo-print.c
@@ -117,14 +117,28 @@ draw_page (GtkPrintOperation *operation,
     bounds.right = bounds.left + dp_width;
     bounds.bottom = bounds.top + dp_height;
   } else {
+    double dx, dy;
     int nx = ceil((data->extents.right - data->extents.left) / dp_width);
     x = page_nr % nx;
-    y = page_nr / nx; 
+    y = page_nr / nx;
+
+    /* Respect the original pagination as shown by the page guides.
+     * Caclulate the offset between page origin 0,0 and data.extents.topleft. 
+     * For the usual first page this boils down to lefttop=(0,0) but beware
+     * the origin being negative.
+     */
+    dx = fmod(data->extents.left, dp_width);
+    if (dx < 0.0)
+      dx += dp_width;
+    dy = fmod(data->extents.top, dp_height);
+    if (dy < 0.0)
+      dy += dp_height;
+
+    bounds.left = dp_width * x + data->extents.left - dx;
+    bounds.top = dp_height * y + data->extents.top - dy;
+    bounds.right = bounds.left + dp_width;
+    bounds.bottom = bounds.top + dp_height;
   }
-  bounds.left = dp_width * x + data->extents.left;
-  bounds.top = dp_height * y + data->extents.top;
-  bounds.right = bounds.left + dp_width;
-  bounds.bottom = bounds.top + dp_height;
 
 #if 0 /* calls begin/end of the given renderer */
   /* count the number of objects in this region */



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