return (EvDocumentBookmarksIter *) iter;
}
-static gboolean
-pdf_document_bookmarks_get_values (EvDocumentBookmarks *document_bookmarks,
- EvDocumentBookmarksIter *bookmarks_iter,
- char **title,
- EvDocumentBookmarksType *type,
- gint *page)
+static EvBookmark *
+pdf_document_bookmarks_get_bookmark (EvDocumentBookmarks *document_bookmarks,
+ EvDocumentBookmarksIter *bookmarks_iter)
{
PdfDocument *pdf_document = PDF_DOCUMENT (document_bookmarks);
+ EvBookmark *bookmark = NULL;
BookmarksIter *iter = (BookmarksIter *)bookmarks_iter;
OutlineItem *anItem;
LinkAction *link_action;
- LinkDest *link_dest = NULL;
- LinkURI *link_uri = NULL;
- LinkGoTo *link_goto = NULL;
- GString *named_dest;
Unicode *link_title;
- Ref page_ref;
- gint page_num = -1;
+ const char *title;
g_return_val_if_fail (PDF_IS_DOCUMENT (document_bookmarks), FALSE);
g_return_val_if_fail (iter != NULL, FALSE);
- g_return_val_if_fail (title != NULL, FALSE);
- g_return_val_if_fail (type != NULL, FALSE);
- g_return_val_if_fail (page != NULL, FALSE);
anItem = (OutlineItem *)iter->items->get(iter->index);
link_action = anItem->getAction ();
link_title = anItem->getTitle ();
-
- if (link_action) {
- switch (link_action->getKind ()) {
-
- case actionGoTo:
- link_goto = dynamic_cast <LinkGoTo *> (link_action);
- link_dest = link_goto->getDest ();
- named_dest = link_goto->getNamedDest ();
-
- /* Wow! This seems excessively slow on large
- * documents. I need to investigate more... -jrb */
- if (link_dest != NULL) {
- link_dest = link_dest->copy ();
- } else if (named_dest != NULL) {
- named_dest = named_dest->copy ();
- link_dest = pdf_document->doc->findDest (named_dest);
- delete named_dest;
- }
- if (link_dest != NULL) {
- if (link_dest->isPageRef ()) {
- page_ref = link_dest->getPageRef ();
- page_num = pdf_document->doc->findPage (page_ref.num, page_ref.gen);
- } else {
- page_num = link_dest->getPageNum ();
- }
-
- delete link_dest;
+ title = unicode_to_char (anItem, pdf_document->umap);
+
+ if (link_action == NULL) {
+ bookmark = ev_bookmark_new_title (title);
+ } else if (link_action->getKind () == actionGoTo) {
+ LinkDest *link_dest;
+ LinkGoTo *link_goto;
+ Ref page_ref;
+ gint page_num = 0;
+ GString *named_dest;
+
+ link_goto = dynamic_cast <LinkGoTo *> (link_action);
+ link_dest = link_goto->getDest ();
+ named_dest = link_goto->getNamedDest ();
+
+ /* Wow! This seems excessively slow on large
+ * documents. I need to investigate more... -jrb */
+ if (link_dest != NULL) {
+ link_dest = link_dest->copy ();
+ } else if (named_dest != NULL) {
+ named_dest = named_dest->copy ();
+ link_dest = pdf_document->doc->findDest (named_dest);
+ delete named_dest;
+ }
+ if (link_dest != NULL) {
+ if (link_dest->isPageRef ()) {
+ page_ref = link_dest->getPageRef ();
+ page_num = pdf_document->doc->findPage (page_ref.num, page_ref.gen);
+ } else {
+ page_num = link_dest->getPageNum ();
}
+ delete link_dest;
+ }
- break;
- case actionURI:
- link_uri = dynamic_cast <LinkURI *> (link_action);
- break;
+ bookmark = ev_bookmark_new_link (title, page_num);
+ } else if (link_action->getKind () == actionURI) {
+ LinkURI *link_uri;
- case actionNamed:
+ link_uri = dynamic_cast <LinkURI *> (link_action);
+ bookmark = ev_bookmark_new_external
+ (title, link_uri->getURI()->getCString());
+ } else if (link_action->getKind () == actionNamed) {
/*Skip, for now */
- default:
- g_warning ("Unknown link action type: %d", link_action->getKind ());
- }
-
- *title = g_strdup (unicode_to_char (anItem, pdf_document->umap));
- } else if (link_title) {
- *title = g_strdup (unicode_to_char (anItem, pdf_document->umap));
}
- *type = EV_DOCUMENT_BOOKMARKS_TYPE_LINK;
- *page = page_num;
-
- return TRUE;
+ return bookmark;
}
static EvDocumentBookmarksIter *
{
iface->has_document_bookmarks = pdf_document_bookmarks_has_document_bookmarks;
iface->begin_read = pdf_document_bookmarks_begin_read;
- iface->get_values = pdf_document_bookmarks_get_values;
+ iface->get_bookmark = pdf_document_bookmarks_get_bookmark;
iface->get_child = pdf_document_bookmarks_get_child;
iface->next = pdf_document_bookmarks_next;
iface->free_iter = pdf_document_bookmarks_free_iter;
return pixbuf;
}
+static void
+pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails,
+ gint page,
+ gint suggested_width,
+ gint *width,
+ gint *height)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document_thumbnails);
+ Page *the_page;
+ Object the_thumb;
+ Thumb *thumb = NULL;
+ gdouble page_ratio;
+
+ /* getPage seems to want page + 1 for some reason; */
+ the_page = pdf_document->doc->getCatalog ()->getPage (page + 1);
+ the_page->getThumb (&the_thumb);
+
+
+
+ if (!(the_thumb.isNull () || the_thumb.isNone())) {
+ /* Build the thumbnail object */
+ thumb = new Thumb(pdf_document->doc->getXRef (),
+ &the_thumb);
+
+ *width = thumb->getWidth ();
+ *height = thumb->getHeight ();
+ } else {
+ page_ratio = the_page->getHeight () / the_page->getWidth ();
+ *width = suggested_width;
+ *height = (gint) (suggested_width * page_ratio);
+ }
+}
+
static GdkPixbuf *
pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
gint page,
pdf_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface)
{
iface->get_thumbnail = pdf_document_thumbnails_get_thumbnail;
+ iface->get_dimensions = pdf_document_thumbnails_get_dimensions;
}