diff options
author | Carlos Garcia Campos <carlosgc@gnome.org> | 2007-02-13 15:32:24 (GMT) |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@src.gnome.org> | 2007-02-13 15:32:24 (GMT) |
commit | 2d1cbc42b4fb22539659e4f621d2d8545d907adb (patch) | |
tree | 33919af82a98a414a3b605e93991b4907b165c90 /backend/ps/ps.c | |
parent | 2f05c3cfce8ff02eb9ddb107102b1e61196ad0f4 (diff) |
Add support for thumbnails in ps backend. Fixes bug #164755.
2007-02-13 Carlos Garcia Campos <carlosgc@gnome.org>
* backend/ps/Makefile.am:
* backend/ps/ps-document.[ch]: (ps_document_init), (ps_document_dispose),
(document_load), (ps_document_load), (save_document),
(save_page_list), (ps_document_get_n_pages),
(ps_document_get_page_size), (ps_document_get_info),
(ps_interpreter_page_rendered), (ps_async_renderer_render_pixbuf),
(ps_interpreter_thumbnail_rendered), (ps_document_render_thumbnail),
(ps_document_thumbnails_get_thumbnail),
(ps_document_thumbnails_get_dimensions),
(ps_document_document_thumbnails_iface_init):
* backend/ps/ps.[ch]: (psgetpagebox):
* backend/ps/ps-interpreter.[ch]:
Add support for thumbnails in ps backend. Fixes bug #164755.
svn path=/trunk/; revision=2323
Diffstat (limited to 'backend/ps/ps.c')
-rw-r--r-- | backend/ps/ps.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/backend/ps/ps.c b/backend/ps/ps.c index 37b7f7e..cccf241 100644 --- a/backend/ps/ps.c +++ b/backend/ps/ps.c @@ -1873,3 +1873,90 @@ static char *readline (fd, lineP, positionP, line_lenP) return(FD_BUF+FD_LINE_BEGIN); } + +#define DEFAULT_PAGE_SIZE 1 + +void +psgetpagebox (const struct document *doc, int page, int *urx, int *ury, int *llx, int *lly) +{ + gint new_llx = 0; + gint new_lly = 0; + gint new_urx = 0; + gint new_ury = 0; + GtkGSPaperSize *papersizes = gtk_gs_defaults_get_paper_sizes (); + int new_pagesize = -1; + + if (new_pagesize == -1) { + new_pagesize = DEFAULT_PAGE_SIZE; + if (doc) { + /* If we have a document: + * We use -- the page size (if specified) + * or the doc. size (if specified) + * or the page bbox (if specified) + * or the bounding box + */ + if ((page >= 0) && (doc->numpages > page) && + (doc->pages) && (doc->pages[page].size)) { + new_pagesize = doc->pages[page].size - doc->size; + } else if (doc->default_page_size != NULL) { + new_pagesize = doc->default_page_size - doc->size; + } else if ((page >= 0) && + (doc->numpages > page) && + (doc->pages) && + (doc->pages[page].boundingbox[URX] > + doc->pages[page].boundingbox[LLX]) && + (doc->pages[page].boundingbox[URY] > + doc->pages[page].boundingbox[LLY])) { + new_pagesize = -1; + } else if ((doc->boundingbox[URX] > doc->boundingbox[LLX]) && + (doc->boundingbox[URY] > doc->boundingbox[LLY])) { + new_pagesize = -1; + } + } + } + + /* Compute bounding box */ + if (doc && (doc->epsf || new_pagesize == -1)) { /* epsf or bbox */ + if ((page >= 0) && + (doc->pages) && + (doc->pages[page].boundingbox[URX] > + doc->pages[page].boundingbox[LLX]) && + (doc->pages[page].boundingbox[URY] > + doc->pages[page].boundingbox[LLY])) { + /* use page bbox */ + new_llx = doc->pages[page].boundingbox[LLX]; + new_lly = doc->pages[page].boundingbox[LLY]; + new_urx = doc->pages[page].boundingbox[URX]; + new_ury = doc->pages[page].boundingbox[URY]; + } else if ((doc->boundingbox[URX] > doc->boundingbox[LLX]) && + (doc->boundingbox[URY] > doc->boundingbox[LLY])) { + /* use doc bbox */ + new_llx = doc->boundingbox[LLX]; + new_lly = doc->boundingbox[LLY]; + new_urx = doc->boundingbox[URX]; + new_ury = doc->boundingbox[URY]; + } + } else { + if (new_pagesize < 0) + new_pagesize = DEFAULT_PAGE_SIZE; + new_llx = new_lly = 0; + if (doc && doc->size && + (new_pagesize < doc->numsizes)) { + new_urx = doc->size[new_pagesize].width; + new_ury = doc->size[new_pagesize].height; + } else { + new_urx = papersizes[new_pagesize].width; + new_ury = papersizes[new_pagesize].height; + } + } + + if (new_urx <= new_llx) + new_urx = papersizes[12].width; + if (new_ury <= new_lly) + new_ury = papersizes[12].height; + + *urx = new_urx; + *ury = new_ury; + *llx = new_llx; + *lly = new_lly; +} |