]> www.fi.muni.cz Git - evince.git/commitdiff
Handle PostScript page orientation. Fixes bug #318568.
authorCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 13 Feb 2007 18:21:24 +0000 (18:21 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Tue, 13 Feb 2007 18:21:24 +0000 (18:21 +0000)
2007-02-13  Carlos Garcia Campos  <carlosgc@gnome.org>
* backend/ps/gstypes.h:
* backend/ps/ps-document.c: (ps_document_get_page_rotation),
(ps_document_get_page_size), (ps_async_renderer_render_pixbuf),
(ps_document_thumbnails_get_thumbnail):
Handle PostScript page orientation. Fixes bug #318568.

svn path=/trunk/; revision=2324

ChangeLog
backend/ps/gstypes.h
backend/ps/ps-document.c

index ae157aadf2d05a35a28e6a2b944f8a4fca13b4c1..1b7a182c1e84536d8934fbe4a830cbc86de0a310 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-02-13  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * backend/ps/gstypes.h:
+       * backend/ps/ps-document.c: (ps_document_get_page_rotation),
+       (ps_document_get_page_size), (ps_async_renderer_render_pixbuf),
+       (ps_document_thumbnails_get_thumbnail):
+
+       Handle PostScript page orientation. Fixes bug #318568.
+
 2007-02-13  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * backend/ps/Makefile.am:
index f1f5cb267cd3e25b98eb14c6e8e62c96e8c61832..5202caafd8c8c6ba062d7f9f2c70a685f4f19704 100644 (file)
@@ -33,9 +33,9 @@ typedef struct _GtkGSPaperSize GtkGSPaperSize;
 typedef enum {
   GTK_GS_ORIENTATION_NONE = -1,
   GTK_GS_ORIENTATION_PORTRAIT = 0,
-  GTK_GS_ORIENTATION_SEASCAPE = 3,
-  GTK_GS_ORIENTATION_UPSIDEDOWN = 2,
-  GTK_GS_ORIENTATION_LANDSCAPE = 1
+  GTK_GS_ORIENTATION_SEASCAPE = 270,
+  GTK_GS_ORIENTATION_UPSIDEDOWN = 180,
+  GTK_GS_ORIENTATION_LANDSCAPE = 90
 } GtkGSOrientation;
 
 struct _GtkGSPaperSize {
index 086f082125762db12612b7c11f1b694b4ae97700..d1b456d28478e74da4d077b6b92bc6300a5e398f 100644 (file)
@@ -356,6 +356,29 @@ ps_document_get_n_pages (EvDocument *document)
        return ps->structured_doc ? ps->doc->numpages : 1;
 }
 
+static gint
+ps_document_get_page_rotation (PSDocument *ps_document,
+                              int         page)
+{
+       gint rotation = GTK_GS_ORIENTATION_NONE;
+
+       g_assert (ps_document->doc != NULL);
+       
+       if (ps_document->structured_doc) {
+               if (ps_document->doc->pages[page].orientation != GTK_GS_ORIENTATION_NONE)
+                       rotation = ps_document->doc->pages[page].orientation;
+               else
+                       rotation = ps_document->doc->default_page_orientation;
+       }
+
+       if (rotation == GTK_GS_ORIENTATION_NONE)
+               rotation = ps_document->doc->orientation;
+
+       if (rotation == GTK_GS_ORIENTATION_NONE)
+               rotation = GTK_GS_ORIENTATION_PORTRAIT;
+
+       return rotation;
+}
 
 static void
 ps_document_get_page_size (EvDocument *document,
@@ -365,15 +388,30 @@ ps_document_get_page_size (EvDocument *document,
 {
        PSDocument *ps_document = PS_DOCUMENT (document);
        int urx, ury, llx, lly;
+       gdouble pwidth, pheight;
+       gdouble page_width, page_height;
+       gint rotate;
 
        psgetpagebox (ps_document->doc, page, &urx, &ury, &llx, &lly);
 
+       pwidth = (urx - llx) + 0.5;
+       pheight = (ury - lly) + 0.5;
+
+       rotate = ps_document_get_page_rotation (ps_document, page);
+       if (rotate == 90 || rotate == 270) {
+               page_height = pwidth;
+               page_width = pheight;
+       } else {
+               page_width = pwidth;
+               page_height = pheight;
+       }
+       
        if (width) {
-               *width = (urx - llx) + 0.5;
+               *width = page_width;
        }
 
        if (height) {
-               *height = (ury - lly) + 0.5;
+               *height = page_height;
        }
 }
 
@@ -441,6 +479,8 @@ ps_async_renderer_render_pixbuf (EvAsyncRenderer *renderer,
 
        g_return_if_fail (PS_IS_INTERPRETER (ps_document->gs));
 
+       rotation = (rotation + ps_document_get_page_rotation (ps_document, page)) % 360;
+
        ps_interpreter_render_page (ps_document->gs, page, scale, rotation);
 }
 
@@ -506,6 +546,8 @@ ps_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
        ps_document_get_page_size (EV_DOCUMENT (ps_document), page,
                                   &page_width, &page_height);
        scale = size / page_width;
+
+       rotation = (rotation + ps_document_get_page_rotation (ps_document, page)) % 360;
        
        if (!ps_document->thumbs_rc) {
                ps_document->thumbs_rc = ev_render_context_new (rotation, page, scale);