-static void
-compute_dimensions (PSDocument *gs, int page)
-{
- GtkGSPaperSize *paper_sizes = gtk_gs_defaults_get_paper_sizes ();
- int urx, ury, llx, lly;
- int width, height;
- int orientation;
-
- g_return_if_fail (PS_IS_DOCUMENT (gs));
- g_return_if_fail (gs->doc != NULL);
- g_return_if_fail (page >= 0);
- g_return_if_fail (gs->doc->numpages > page);
-
- orientation = GTK_GS_ORIENTATION_NONE;
- if (gs->structured_doc) {
- orientation = gs->doc->pages[gs->current_page].orientation;
- }
- if (orientation == GTK_GS_ORIENTATION_NONE) {
- orientation = GTK_GS_ORIENTATION_PORTRAIT;
- }
-
- if (gs->doc->pages && gs->doc->pages[page].size) {
- int page_size;
-
- page_size = gs->doc->pages[page].size - gs->doc->size;
- llx = lly = 0;
- urx = gs->doc->size[page_size].width;
- ury = gs->doc->size[page_size].height;
- } else if (gs->doc->pages &&
- (gs->doc->pages[page].boundingbox[URX] >
- gs->doc->pages[page].boundingbox[LLX]) &&
- (gs->doc->pages[page].boundingbox[URY] >
- gs->doc->pages[page].boundingbox[LLY])) {
- llx = gs->doc->pages[page].boundingbox[LLX];
- lly = gs->doc->pages[page].boundingbox[LLY];
- urx = gs->doc->pages[page].boundingbox[URX];
- ury = gs->doc->pages[page].boundingbox[URY];
- } else if ((gs->doc->boundingbox[URX] > gs->doc->boundingbox[LLX]) &&
- (gs->doc->boundingbox[URY] > gs->doc->boundingbox[LLY])) {
- llx = gs->doc->boundingbox[LLX];
- lly = gs->doc->boundingbox[LLY];
- urx = gs->doc->boundingbox[URX];
- ury = gs->doc->boundingbox[URY];
- } else {
- /* Fallback to A4 */
- llx = lly = 0;
- urx = paper_sizes[12].width;
- ury = paper_sizes[12].height;
- }
-
- switch (orientation) {
- case GTK_GS_ORIENTATION_PORTRAIT:
- case GTK_GS_ORIENTATION_UPSIDEDOWN:
- width = (urx - llx) / 72.0 * get_xdpi (gs) + 0.5;
- height = (ury - lly) / 72.0 * get_ydpi (gs) + 0.5;
- break;
- case GTK_GS_ORIENTATION_LANDSCAPE:
- case GTK_GS_ORIENTATION_SEASCAPE:
- width = (ury - lly) / 72.0 * get_xdpi (gs) + 0.5;
- height = (urx - llx) / 72.0 * get_ydpi (gs) + 0.5;
- break;
- default:
- width = height = 0;
- g_assert_not_reached ();
- break;
- }
-
- width = width * gs->zoom_factor;
- height = height * gs->zoom_factor;
-
- if (llx != gs->llx || lly != gs->lly ||
- urx != gs->urx || ury != gs->ury ||
- gs->width != width || gs->height != height ||
- orientation != gs->orientation) {
- gs->llx = llx;
- gs->lly = lly;
- gs->urx = urx;
- gs->ury = ury;
- gs->width = width;
- gs->height = height;
- gs->orientation = orientation;
- gs->changed = TRUE;
- }
-}
-