+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;
+}