X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=pdf%2Fxpdf%2Fpdf-document.cc;h=82838f471624a75916a95dd0766d259f9890067f;hb=662b57ab5fc05d98a0ab3e4258c15cf2a2cc66c1;hp=255c5abd17f1fa6c50cc94c35211c9826c5f71b1;hpb=1cb865554fcb40760784a30c7700b6a751567762;p=evince.git diff --git a/pdf/xpdf/pdf-document.cc b/pdf/xpdf/pdf-document.cc index 255c5abd..82838f47 100644 --- a/pdf/xpdf/pdf-document.cc +++ b/pdf/xpdf/pdf-document.cc @@ -23,9 +23,9 @@ #include "pdf-document.h" #include "ev-ps-exporter.h" #include "ev-document-find.h" +#include "ev-document-misc.h" #include "gpdf-g-switch.h" #include "ev-document-links.h" -#include "ev-document-misc.h" #include "ev-document-security.h" #include "ev-document-thumbnails.h" @@ -90,7 +90,6 @@ struct _PdfDocument UnicodeMap *umap; gchar *password; - gboolean page_valid; PdfDocumentSearch *search; }; @@ -136,29 +135,21 @@ document_init_links (PdfDocument *pdf_document) obj.free (); } -static gboolean -document_validate_page (PdfDocument *pdf_document) +static void +document_display_page (PdfDocument *pdf_document) { - if (!pdf_document->page_valid) { - pdf_document->doc->displayPage (pdf_document->out, pdf_document->page, - 72 * pdf_document->scale, - 72 * pdf_document->scale, - 0, gTrue, gTrue); - - document_init_links (pdf_document); + pdf_document->doc->displayPage (pdf_document->out, pdf_document->page, + 72 * pdf_document->scale, + 72 * pdf_document->scale, + 0, gTrue, gTrue); - pdf_document->page_valid = TRUE; + document_init_links (pdf_document); - ev_document_changed (EV_DOCUMENT (pdf_document)); - - /* Update the search results available to the app since - * we only provide full results on the current page - */ - if (pdf_document->search) - pdf_document_search_page_changed (pdf_document->search); - } - - return pdf_document->page_valid; + /* Update the search results available to the app since + * we only provide full results on the current page + */ + if (pdf_document->search) + pdf_document_search_page_changed (pdf_document->search); } static gboolean @@ -227,8 +218,6 @@ pdf_document_load (EvDocument *document, if (pdf_document->out) pdf_document->out->startDoc(pdf_document->doc->getXRef()); - pdf_document->page_valid = FALSE; - g_object_notify (G_OBJECT (pdf_document), "title"); return TRUE; @@ -274,7 +263,8 @@ pdf_document_set_page (EvDocument *document, if (page != pdf_document->page) { pdf_document->page = page; - pdf_document->page_valid = FALSE; + document_display_page (pdf_document); + ev_document_page_changed (EV_DOCUMENT (pdf_document)); } } @@ -321,7 +311,7 @@ pdf_document_set_target (EvDocument *document, } - pdf_document->page_valid = FALSE; + /* FIXME we need to regenerate pages */ } } @@ -333,7 +323,8 @@ pdf_document_set_scale (EvDocument *document, if (pdf_document->scale != scale) { pdf_document->scale = scale; - pdf_document->page_valid = FALSE; + document_display_page (pdf_document); + ev_document_scale_changed (EV_DOCUMENT (pdf_document)); } } @@ -363,19 +354,13 @@ pdf_document_get_page_size (EvDocument *document, if (height) *height = 1; - - if (page == -1 && document_validate_page (pdf_document)) { - if (width) - *width = pdf_document->out->getBitmapWidth(); - if (height) - *height = pdf_document->out->getBitmapHeight(); - return; - } + if (page == -1) + page = pdf_document->page; the_page = pdf_document->doc->getCatalog ()->getPage (page); if (the_page) { - *width = (int) the_page->getWidth (); - *height = (int) the_page->getHeight (); + *width = (int) ((the_page->getWidth () * pdf_document->scale) + 0.5); + *height = (int) ((the_page->getHeight () * pdf_document->scale) + 0.5); } } @@ -390,7 +375,7 @@ pdf_document_render (EvDocument *document, GdkRectangle page; GdkRectangle draw; - if (!document_validate_page (pdf_document) || !pdf_document->target) + if (!pdf_document->target) return; page.x = pdf_document->page_x_offset; @@ -492,12 +477,6 @@ pdf_document_search_page_changed (PdfDocumentSearch *search) current_page = pdf_document->page; - if (!pdf_document->page_valid) { - /* we can't do anything until displayPage() */ - search->current_page = -1; - return; - } - if (search->current_page == current_page) return; @@ -814,6 +793,14 @@ build_link_from_action (PdfDocument *pdf_document, if (link_action == NULL) { link = ev_link_new_title (title); + } else if (link_action->getKind () == actionGoToR) { + g_warning ("actionGoToR links not implemented"); + } else if (link_action->getKind () == actionLaunch) { + g_warning ("actionLaunch links not implemented"); + } else if (link_action->getKind () == actionNamed) { + g_warning ("actionNamed links not implemented"); + } else if (link_action->getKind () == actionMovie) { + g_warning ("actionMovie links not implemented"); } else if (link_action->getKind () == actionGoTo) { LinkDest *link_dest; LinkGoTo *link_goto; @@ -851,8 +838,13 @@ build_link_from_action (PdfDocument *pdf_document, link_uri = dynamic_cast (link_action); link = ev_link_new_external (title, link_uri->getURI()->getCString()); - } else if (link_action->getKind () == actionNamed) { - /*Skip, for now */ + } else if (link_action->getKind () == actionUnknown) { + LinkUnknown *link_unknown; + + link_unknown = dynamic_cast (link_action); + + g_warning ("Unknown link type %s", + link_unknown->getAction()->getCString()); } return link; @@ -1037,10 +1029,10 @@ pdf_document_get_text (EvDocument *document, GdkRectangle *rect) const char *text; int x1, y1, x2, y2; - x1 = rect->x + pdf_document->page_x_offset; - y1 = rect->y + pdf_document->page_y_offset; - x2 = x1 + rect->width + pdf_document->page_x_offset; - y2 = y1 + rect->height + pdf_document->page_y_offset; + x1 = rect->x - pdf_document->page_x_offset; + y1 = rect->y - pdf_document->page_y_offset; + x2 = x1 + rect->width; + y2 = y1 + rect->height; sel_text = pdf_document->out->getText (x1, y1, x2, y2); text = sel_text->getCString (); @@ -1356,7 +1348,6 @@ pdf_document_init (PdfDocument *pdf_document) pdf_document->page_y_offset = 0; pdf_document->scale = 1.; - pdf_document->page_valid = FALSE; pdf_document->password = NULL; }