]> www.fi.muni.cz Git - evince.git/commitdiff
Fix orientation in the postscript document
authorMarco Pesenti Gritti <mpg@redhat.com>
Wed, 24 Aug 2005 08:46:18 +0000 (08:46 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Wed, 24 Aug 2005 08:46:18 +0000 (08:46 +0000)
2005-08-24  Marco Pesenti Gritti  <mpg@redhat.com>

        * backend/ev-async-renderer.c: (ev_async_renderer_render_pixbuf):
        * backend/ev-async-renderer.h:
        * ps/ps-document.c: (ps_document_init), (setup_pixmap),
        (setup_page), (ps_document_get_page_size),
        (ps_async_renderer_render_pixbuf):
        * ps/ps-document.h:
        * shell/ev-jobs.c: (ev_job_render_run):

        Fix orientation in the postscript document

ChangeLog
backend/ev-async-renderer.c
backend/ev-async-renderer.h
ps/ps-document.c
ps/ps-document.h
shell/ev-jobs.c

index ccb5f5587697d450b221d494f42f6637fa75743f..5c64a32b2055add73559c5a319c07b2af084f346 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-08-24  Marco Pesenti Gritti  <mpg@redhat.com>
+
+       * backend/ev-async-renderer.c: (ev_async_renderer_render_pixbuf):
+       * backend/ev-async-renderer.h:
+       * ps/ps-document.c: (ps_document_init), (setup_pixmap),
+       (setup_page), (ps_document_get_page_size),
+       (ps_async_renderer_render_pixbuf):
+       * ps/ps-document.h:
+       * shell/ev-jobs.c: (ev_job_render_run):
+
+       Fix orientation in the postscript document
+
 2005-08-23  Marco Pesenti Gritti  <mpg@redhat.com>
 
        * pdf/ev-poppler.cc:
index 45ca7e4f8fc299c91044ad1cd0592bc62cffcbe6..022c0b6fe162ef341c6fac9ea9fbe84d48b21bbc 100644 (file)
@@ -73,9 +73,10 @@ ev_async_renderer_class_init (gpointer g_class)
 void
 ev_async_renderer_render_pixbuf (EvAsyncRenderer *async_renderer,
                                 int              page,
-                                double           scale)
+                                double           scale,
+                                int              rotation)
 {
        EvAsyncRendererIface *iface = EV_ASYNC_RENDERER_GET_IFACE (async_renderer);
 
-       iface->render_pixbuf (async_renderer, page, scale);
+       iface->render_pixbuf (async_renderer, page, scale, rotation);
 }
index 044ee6297c35d4f88d37d9c877b2da7b25a27ddb..9aa965730e80766e5023f6d275e8434292065b94 100644 (file)
@@ -46,13 +46,15 @@ struct _EvAsyncRendererIface
 
        void        (* render_pixbuf)   (EvAsyncRenderer *renderer,
                                         int              page,
-                                        double           scale);
+                                        double           scale,
+                                        int              rotation);
 };
 
 GType          ev_async_renderer_get_type       (void);
 void           ev_async_renderer_render_pixbuf  (EvAsyncRenderer *renderer,
                                                  int              page,
-                                                 double           scale);
+                                                 double           scale,
+                                                 int              rotation);
 
 G_END_DECLS
 
index f95dfe0f3a0764a999893f2cc2337db4a23e2563..91acc9ac89e8333281f32fbe9a299b51ac24af14 100644 (file)
@@ -137,8 +137,6 @@ ps_document_init (PSDocument *gs)
 
        gs->ps_export_pagelist = NULL;
        gs->ps_export_filename = NULL;
-
-       gs->orientation = GTK_GS_ORIENTATION_NONE;
 }
 
 static void
@@ -306,7 +304,7 @@ get_ydpi (PSDocument *gs)
 }
 
 static void
-setup_pixmap (PSDocument *gs, int page, double scale)
+setup_pixmap (PSDocument *gs, int page, double scale, int rotation)
 {
        GdkGC *fill;
        GdkColor white = { 0, 0xFFFF, 0xFFFF, 0xFFFF };   /* pixel, r, g, b */
@@ -315,8 +313,14 @@ setup_pixmap (PSDocument *gs, int page, double scale)
        int pixmap_width, pixmap_height;
 
        ev_document_get_page_size (EV_DOCUMENT (gs), page, &width, &height);
-       pixmap_width = width * scale + 0.5;
-       pixmap_height = height * scale + 0.5;
+
+       if (rotation == 90 || rotation == 270) {
+               pixmap_height = width * scale + 0.5;
+               pixmap_width = height * scale + 0.5;
+       } else {
+               pixmap_width = width * scale + 0.5;
+               pixmap_height = height * scale + 0.5;
+       }
 
        if(gs->bpixmap) {
                int w, h;
@@ -433,49 +437,22 @@ get_page_box (PSDocument *gs, int page, int *urx, int *ury, int *llx, int *lly)
        *lly = new_lly;
 }
 
-static int
-get_page_orientation (PSDocument *gs, int page)
-{
-       int orientation;
-
-       orientation = GTK_GS_ORIENTATION_NONE;
-
-       if (gs->structured_doc) {
-               orientation = gs->doc->pages[page].orientation;
-       }
-       if (orientation == GTK_GS_ORIENTATION_NONE) {
-               orientation = gs->doc->default_page_orientation;
-       }
-       if (orientation == GTK_GS_ORIENTATION_NONE) {
-               orientation = gs->doc->orientation;
-       }
-       if (orientation == GTK_GS_ORIENTATION_NONE) {
-               orientation = GTK_GS_ORIENTATION_PORTRAIT;
-       }
-       if (gs->orientation != GTK_GS_ORIENTATION_NONE) {
-               orientation = gs->orientation;
-       }
-
-       return orientation;
-}
-
 static void
-setup_page (PSDocument *gs, int page, double scale)
+setup_page (PSDocument *gs, int page, double scale, int rotation)
 {
        gchar *buf;
-       int urx, ury, llx, lly, orientation;
        char scaled_xdpi[G_ASCII_DTOSTR_BUF_SIZE];      
        char scaled_ydpi[G_ASCII_DTOSTR_BUF_SIZE];
+       int urx, ury, llx, lly;
 
        LOG ("Setup the page");
 
        get_page_box (gs, page, &urx, &ury, &llx, &lly);
-       orientation = get_page_orientation (gs, page);
        g_ascii_dtostr (scaled_xdpi, G_ASCII_DTOSTR_BUF_SIZE, get_xdpi (gs) * scale);
        g_ascii_dtostr (scaled_ydpi, G_ASCII_DTOSTR_BUF_SIZE, get_ydpi (gs) * scale);
 
        buf = g_strdup_printf ("%ld %d %d %d %d %d %s %s %d %d %d %d",
-                              0L, orientation * 90, llx, lly, urx, ury,
+                              0L, rotation, llx, lly, urx, ury,
                               scaled_xdpi, scaled_ydpi,
                               0, 0, 0, 0);
        LOG ("GS property %s", buf);
@@ -1182,35 +1159,16 @@ ps_document_get_page_size (EvDocument   *document,
                           double       *height)
 {
        PSDocument *gs = PS_DOCUMENT (document);
-       int w, h;
-       int urx, ury, llx, lly, orientation;
+       int urx, ury, llx, lly;
 
        get_page_box (PS_DOCUMENT (document), page, &urx, &ury, &llx, &lly);
-       orientation = get_page_orientation (PS_DOCUMENT (document), page);
-
-       switch (orientation) {
-               case GTK_GS_ORIENTATION_PORTRAIT:
-               case GTK_GS_ORIENTATION_UPSIDEDOWN:
-                       w = (urx - llx) / 72.0 * get_xdpi (gs) + 0.5;
-                       h = (ury - lly) / 72.0 * get_ydpi (gs) + 0.5;
-                       break;
-               case GTK_GS_ORIENTATION_LANDSCAPE:
-               case GTK_GS_ORIENTATION_SEASCAPE:
-                       w = (ury - lly) / 72.0 * get_xdpi (gs) + 0.5;
-                       h = (urx - llx) / 72.0 * get_ydpi (gs) + 0.5;
-                       break;
-               default:
-                       w = h = 0;
-                       g_assert_not_reached ();
-                       break;
-       }
 
        if (width) {
-               *width = w;
+               *width = (urx - llx) / 72.0 * get_xdpi (gs) + 0.5;
        }
 
        if (height) {
-               *height = h;
+               *height = (ury - lly) / 72.0 * get_ydpi (gs) + 0.5;
        }
 }
 
@@ -1221,7 +1179,7 @@ ps_document_can_get_text (EvDocument *document)
 }
 
 static void
-ps_async_renderer_render_pixbuf (EvAsyncRenderer *renderer, int page, double scale)
+ps_async_renderer_render_pixbuf (EvAsyncRenderer *renderer, int page, double scale, int rotation)
 {
        PSDocument *gs = PS_DOCUMENT (renderer);
 
@@ -1237,8 +1195,8 @@ ps_async_renderer_render_pixbuf (EvAsyncRenderer *renderer, int page, double sca
                                  gs);
        }
 
-       setup_pixmap (gs, page, scale);
-       setup_page (gs, page, scale);
+       setup_pixmap (gs, page, scale, rotation);
+       setup_page (gs, page, scale, rotation);
 
        render_page (gs, page);
 }
index 7ecad2918bab6351f2f3f1106af0fec8cb7a2973..c8d19db3cb01f359775401de6cef47bf57b3cd81 100644 (file)
@@ -76,8 +76,6 @@ struct _PSDocument {
   int *ps_export_pagelist;
   char *ps_export_filename;
 
-  GtkGSOrientation orientation;
-
   const gchar *gs_status;       /* PSDocument status */
 };
 
index 72ed96142b26f65767321246bc7b9dca26aee970..0f9bf7352498daccac86269c0f69e7c12aa1d381 100644 (file)
@@ -290,7 +290,8 @@ ev_job_render_run (EvJobRender *job)
 
        if (EV_JOB (job)->async) {
                EvAsyncRenderer *renderer = EV_ASYNC_RENDERER (EV_JOB (job)->document);
-               ev_async_renderer_render_pixbuf (renderer, job->rc->page, job->rc->scale);
+               ev_async_renderer_render_pixbuf (renderer, job->rc->page, job->rc->scale,
+                                                job->rc->rotation);
                g_signal_connect (EV_JOB (job)->document, "render_finished",
                                  G_CALLBACK (render_finished_cb), job);
        } else {