]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/xpdf/pdf-document.cc
ignore page offset here, to make search results independent of it,
[evince.git] / pdf / xpdf / pdf-document.cc
index 2ec9d5e28ca4b423d519d29d0d11fe5a891a37bb..22e7e4138ad3f5e543d3fce0ecfddcfc62b6180d 100644 (file)
@@ -1023,10 +1023,10 @@ pdf_document_get_text (EvDocument *document, GdkRectangle *rect)
        const char *text;
        int x1, y1, x2, y2;
 
        const char *text;
        int x1, y1, x2, y2;
 
-       x1 = rect->x;
-       y1 = rect->y;
-       x2 = x1 + rect->width;
-       y2 = y1 + rect->height;
+       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;
 
        sel_text = pdf_document->out->getText (x1, y1, x2, y2);
        text = sel_text->getCString ();
 
        sel_text = pdf_document->out->getText (x1, y1, x2, y2);
        text = sel_text->getCString ();
@@ -1039,11 +1039,24 @@ pdf_document_get_link (EvDocument *document, int x, int y)
 {
        PdfDocument *pdf_document = PDF_DOCUMENT (document);
        LinkAction *action;
 {
        PdfDocument *pdf_document = PDF_DOCUMENT (document);
        LinkAction *action;
+       double link_x, link_y;
 
 
-       y = pdf_document->out->getBitmapHeight() - y;
+       if (pdf_document->links == NULL) {
+               return NULL;
+       }
+
+       /* Offset */
+       link_x = x - pdf_document->page_x_offset;
+       link_y = y - pdf_document->page_y_offset;
+
+       /* Inverse y */
+       link_y = pdf_document->out->getBitmapHeight() - link_y;
+
+       /* Zoom */
+       link_x = link_x / pdf_document->scale;
+       link_y = link_y / pdf_document->scale;
 
 
-       action = pdf_document->links->find ((double)x / pdf_document->scale,
-                                           (double)y / pdf_document->scale);
+       action = pdf_document->links->find (link_x, link_y);
        
        if (action) {
                return build_link_from_action (pdf_document, action, "");
        
        if (action) {
                return build_link_from_action (pdf_document, action, "");