+ if (width)
+ *width = document->priv->max_width;
+ if (height)
+ *height = document->priv->max_height;
+}
+
+void
+ev_document_get_min_page_size (EvDocument *document,
+ gdouble *width,
+ gdouble *height)
+{
+ g_return_if_fail (EV_IS_DOCUMENT (document));
+
+ if (width)
+ *width = document->priv->min_width;
+ if (height)
+ *height = document->priv->min_height;
+}
+
+gboolean
+ev_document_check_dimensions (EvDocument *document)
+{
+ g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
+
+ return (document->priv->max_width > 0 && document->priv->max_height > 0);
+}
+
+gint
+ev_document_get_max_label_len (EvDocument *document)
+{
+ g_return_val_if_fail (EV_IS_DOCUMENT (document), -1);
+
+ return document->priv->max_label;
+}
+
+gboolean
+ev_document_has_text_page_labels (EvDocument *document)
+{
+ g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
+
+ return document->priv->page_labels != NULL;
+}
+
+gboolean
+ev_document_find_page_by_label (EvDocument *document,
+ const gchar *page_label,
+ gint *page_index)
+{
+ gint i, page;
+ glong value;
+ gchar *endptr = NULL;
+ EvDocumentPrivate *priv = document->priv;
+
+ g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
+ g_return_val_if_fail (page_label != NULL, FALSE);
+ g_return_val_if_fail (page_index != NULL, FALSE);
+
+ /* First, look for a literal label match */
+ for (i = 0; priv->page_labels && i < priv->n_pages; i ++) {
+ if (priv->page_labels[i] != NULL &&
+ ! strcmp (page_label, priv->page_labels[i])) {
+ *page_index = i;
+ return TRUE;
+ }
+ }
+
+ /* Second, look for a match with case insensitively */
+ for (i = 0; priv->page_labels && i < priv->n_pages; i++) {
+ if (priv->page_labels[i] != NULL &&
+ ! strcasecmp (page_label, priv->page_labels[i])) {
+ *page_index = i;
+ return TRUE;
+ }
+ }
+
+ /* Next, parse the label, and see if the number fits */
+ value = strtol (page_label, &endptr, 10);
+ if (endptr[0] == '\0') {
+ /* Page number is an integer */
+ page = MIN (G_MAXINT, value);
+
+ /* convert from a page label to a page offset */
+ page --;
+ if (page >= 0 && page < priv->n_pages) {
+ *page_index = page;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+/* EvDocumentInfo */
+EV_DEFINE_BOXED_TYPE (EvDocumentInfo, ev_document_info, ev_document_info_copy, ev_document_info_free)
+
+EvDocumentInfo *
+ev_document_info_copy (EvDocumentInfo *info)
+{
+ EvDocumentInfo *copy;
+
+ g_return_val_if_fail (info != NULL, NULL);
+
+ copy = g_new0 (EvDocumentInfo, 1);
+ copy->title = g_strdup (info->title);
+ copy->format = g_strdup (info->format);
+ copy->author = g_strdup (info->author);
+ copy->subject = g_strdup (info->subject);
+ copy->keywords = g_strdup (info->keywords);
+ copy->security = g_strdup (info->security);
+ copy->creator = g_strdup (info->creator);
+ copy->producer = g_strdup (info->producer);
+ copy->linearized = g_strdup (info->linearized);
+
+ copy->creation_date = info->creation_date;
+ copy->modified_date = info->modified_date;
+ copy->layout = info->layout;
+ copy->mode = info->mode;
+ copy->ui_hints = info->ui_hints;
+ copy->permissions = info->permissions;
+ copy->n_pages = info->n_pages;
+ copy->license = ev_document_license_copy (info->license);
+
+ copy->fields_mask = info->fields_mask;
+
+ return copy;