X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=pdf%2Fev-poppler.cc;h=0f9a3562c2dde199d2ff3a763ba2ade5916be8ff;hb=274f17472f798aa469fe6089291efa5379de157c;hp=9989d827674d6d9e17fb55f7ef34cb8930653d79;hpb=79986dda7231d1ef1c530909bde8e18a507a2a2a;p=evince.git diff --git a/pdf/ev-poppler.cc b/pdf/ev-poppler.cc index 9989d827..0f9a3562 100644 --- a/pdf/ev-poppler.cc +++ b/pdf/ev-poppler.cc @@ -128,6 +128,7 @@ static void pdf_document_init (PdfDocument *pdf_document) { pdf_document->password = NULL; + pdf_document->orientation = POPPLER_ORIENTATION_PORTRAIT; } static void @@ -175,6 +176,24 @@ pdf_document_save (EvDocument *document, return retval; } +static PopplerOrientation +get_document_orientation (PdfDocument *pdf_document) +{ +#ifdef POPPLER_ORIENTATION + PopplerPage *page; + + /* Should prolly be smarter here and check more than first page */ + page = poppler_document_get_page (pdf_document->document, 0); + if (page) { + return poppler_page_get_orientation (page); + } else { + return POPPLER_ORIENTATION_PORTRAIT; + } +#else + return POPPLER_ORIENTATION_PORTRAIT; +#endif +} + static gboolean pdf_document_load (EvDocument *document, const char *uri, @@ -191,6 +210,8 @@ pdf_document_load (EvDocument *document, return FALSE; } + pdf_document->orientation = get_document_orientation (pdf_document); + return TRUE; } @@ -488,6 +509,30 @@ pdf_document_get_text (EvDocument *document, int page, EvRectangle *rect) return poppler_page_get_text (poppler_page, &r); } +static EvOrientation +pdf_document_get_orientation (EvDocument *document) +{ + EvOrientation result; + PdfDocument *pdf_document = PDF_DOCUMENT (document); + + switch (pdf_document->orientation) { + case POPPLER_ORIENTATION_PORTRAIT: + result = EV_ORIENTATION_PORTRAIT; + break; + case POPPLER_ORIENTATION_LANDSCAPE: + result = EV_ORIENTATION_LANDSCAPE; + break; + case POPPLER_ORIENTATION_UPSIDEDOWN: + result = EV_ORIENTATION_UPSIDEDOWN; + break; + case POPPLER_ORIENTATION_SEASCAPE: + result = EV_ORIENTATION_SEASCAPE; + break; + } + + return result; +} + static void pdf_document_set_orientation (EvDocument *document, EvOrientation orientation) { @@ -495,9 +540,6 @@ pdf_document_set_orientation (EvDocument *document, EvOrientation orientation) PopplerOrientation poppler_orientation; switch (orientation) { - case EV_ORIENTATION_DOCUMENT: - poppler_orientation = POPPLER_ORIENTATION_DOCUMENT; - break; case EV_ORIENTATION_PORTRAIT: poppler_orientation = POPPLER_ORIENTATION_PORTRAIT; break; @@ -529,6 +571,7 @@ pdf_document_document_iface_init (EvDocumentIface *iface) iface->can_get_text = pdf_document_can_get_text; iface->get_info = pdf_document_get_info; iface->set_orientation = pdf_document_set_orientation; + iface->get_orientation = pdf_document_get_orientation; }; static void @@ -658,8 +701,10 @@ build_tree (PdfDocument *pdf_document, PopplerIndexIter *child; PopplerAction *action; EvLink *link; + gboolean expand; action = poppler_index_iter_get_action (iter); + expand = poppler_index_iter_is_open (iter); if (action) { gtk_tree_store_append (GTK_TREE_STORE (model), &tree_iter, parent); link = ev_link_from_action (action); @@ -668,6 +713,7 @@ build_tree (PdfDocument *pdf_document, gtk_tree_store_set (GTK_TREE_STORE (model), &tree_iter, EV_DOCUMENT_LINKS_COLUMN_MARKUP, ev_link_get_title (link), EV_DOCUMENT_LINKS_COLUMN_LINK, link, + EV_DOCUMENT_LINKS_COLUMN_EXPAND, expand, -1); child = poppler_index_iter_get_child (iter); if (child) @@ -688,16 +734,16 @@ pdf_document_links_get_links_model (EvDocumentLinks *document_links) g_return_val_if_fail (PDF_IS_DOCUMENT (document_links), NULL); iter = poppler_index_iter_new (pdf_document->document); - /* Create the model iff we have items*/ + /* Create the model if we have items*/ if (iter != NULL) { model = (GtkTreeModel *) gtk_tree_store_new (EV_DOCUMENT_LINKS_COLUMN_NUM_COLUMNS, G_TYPE_STRING, - G_TYPE_POINTER); + G_TYPE_POINTER, + G_TYPE_BOOLEAN); build_tree (pdf_document, model, NULL, iter); poppler_index_iter_free (iter); } - return model; }