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,
{
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;
}
}
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);
}
static GdkPixbuf *
ps_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
- gint page,
- gint rotation,
- gint size,
+ EvRenderContext *rc,
gboolean border)
{
PSDocument *ps_document;
GdkPixbuf *pixbuf = NULL;
- gdouble page_width, page_height;
- gdouble scale;
ps_document = PS_DOCUMENT (document_thumbnails);
ps_document->thumbs_mutex = g_mutex_new ();
ps_document->thumbs_cond = g_cond_new ();
- ps_document_get_page_size (EV_DOCUMENT (ps_document), page,
- &page_width, &page_height);
- scale = size / page_width;
-
- if (!ps_document->thumbs_rc) {
- ps_document->thumbs_rc = ev_render_context_new (rotation, page, scale);
- } else {
- ev_render_context_set_page (ps_document->thumbs_rc, page);
- ev_render_context_set_scale (ps_document->thumbs_rc, scale);
- ev_render_context_set_rotation (ps_document->thumbs_rc, rotation);
- }
+ if (ps_document->thumbs_rc)
+ g_object_unref (ps_document->thumbs_rc);
+ ps_document->thumbs_rc = g_object_ref (rc);
ev_document_doc_mutex_unlock ();
g_mutex_lock (ps_document->thumbs_mutex);
if (border) {
GdkPixbuf *border_pixbuf;
- border_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, rotation, pixbuf);
+ border_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, pixbuf);
g_object_unref (pixbuf);
pixbuf = border_pixbuf;
}
static void
ps_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails,
- gint page,
- gint size,
+ EvRenderContext *rc,
gint *width,
gint *height)
{
ps_document = PS_DOCUMENT (document_thumbnails);
ps_document_get_page_size (EV_DOCUMENT (ps_document),
- page,
+ rc->page,
&page_width, &page_height);
- *width = size;
- *height = (int) (size * page_height / page_width);
+
+ if (rc->rotation == 90 || rc->rotation == 270) {
+ *width = (gint) (page_height * rc->scale);
+ *height = (gint) (page_width * rc->scale);
+ } else {
+ *width = (gint) (page_width * rc->scale);
+ *height = (gint) (page_height * rc->scale);
+ }
}
static void