]> www.fi.muni.cz Git - evince.git/commitdiff
Ignore link coordinates if they are outside page bounds
authorMarco Pesenti Gritti <mpg@redhat.com>
Mon, 26 Sep 2005 11:09:47 +0000 (11:09 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Mon, 26 Sep 2005 11:09:47 +0000 (11:09 +0000)
2005-09-26  Marco Pesenti Gritti  <mpg@redhat.com>

        * shell/ev-view.c: (doc_point_to_view_point), (goto_fitr_link),
        (goto_fitv_link), (goto_fith_link), (goto_xyz_link):

        Ignore link coordinates if they are outside page bounds

ChangeLog
shell/ev-view.c

index c5faf62283175abaef15a73d5667caf6f2d68366..0180dd65f05390bdc3f8c25c1c80b2da04763caf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-09-26  Marco Pesenti Gritti  <mpg@redhat.com>
+
+       * shell/ev-view.c: (doc_point_to_view_point), (goto_fitr_link),
+       (goto_fitv_link), (goto_fith_link), (goto_xyz_link):
+
+       Ignore link coordinates if they are outside page bounds
+
 2005-09-26  Marco Pesenti Gritti  <mpg@redhat.com>
 
        * backend/ev-link.c: (ev_link_type_get_type),
index 15bd41244edcf10215eae5d720374955b0372632..4b684190963623e21f591b93d92082466cb37f4e 100644 (file)
@@ -934,7 +934,7 @@ view_rect_to_doc_rect (EvView *view,
        doc_rect->y2 = doc_rect->y1 + (double) view_rect->height / view->scale;
 }
 
-static void
+static gboolean
 doc_point_to_view_point (EvView       *view,
                          int           page,
                         EvPoint      *doc_point,
@@ -942,7 +942,7 @@ doc_point_to_view_point (EvView       *view,
 {
        GdkRectangle page_area;
        GtkBorder border;
-       double x, y;
+       double x, y, view_x, view_y;
        int width, height;
 
        ev_page_cache_get_size (view->page_cache, page,
@@ -968,8 +968,13 @@ doc_point_to_view_point (EvView       *view,
 
        get_page_extents (view, page, &page_area, &border);
 
-       view_point->x = x * view->scale + page_area.x;
-       view_point->y = y * view->scale + page_area.y;
+       view_x = x * view->scale;
+       view_y = y * view->scale;
+       view_point->x = view_x + page_area.x;
+       view_point->y = view_y + page_area.y;
+
+       return (view_x > 0 && view_x <= page_area.width &&
+               view_y > 0 && view_y <= page_area.height);
 }
 
 static void
@@ -1128,7 +1133,6 @@ goto_fitr_link (EvView *view, EvLink *link)
 
        doc_point.x = ev_link_get_left (link);
        doc_point.y = ev_link_get_top (link);
-       doc_point_to_view_point (view, page, &doc_point, &view_point);
 
        zoom = zoom_for_size_best_fit (ev_link_get_right (link) - ev_link_get_left (link),
                                       ev_link_get_top (link) - ev_link_get_bottom (link),
@@ -1138,7 +1142,11 @@ goto_fitr_link (EvView *view, EvLink *link)
        ev_view_set_sizing_mode (view, EV_SIZING_FREE);
        ev_view_set_zoom (view, zoom, FALSE);
        ev_page_cache_set_current_page (view->page_cache, page);
-       gtk_adjustment_set_value (view->hadjustment, view_point.x);
+
+       if (doc_point_to_view_point (view, page, &doc_point, &view_point)) {
+               gtk_adjustment_set_value (view->hadjustment, view_point.x);
+               gtk_adjustment_set_value (view->vadjustment, view_point.y);
+       }
 }
 
 static void
@@ -1154,7 +1162,6 @@ goto_fitv_link (EvView *view, EvLink *link)
 
        doc_point.x = ev_link_get_left (link);
        doc_point.y = 0;
-       doc_point_to_view_point (view, page, &doc_point, &view_point);
 
        zoom = zoom_for_size_fit_height (doc_width - doc_point.x , doc_height,
                                         ev_view_get_width (view),
@@ -1163,7 +1170,10 @@ goto_fitv_link (EvView *view, EvLink *link)
        ev_view_set_sizing_mode (view, EV_SIZING_FREE);
        ev_view_set_zoom (view, zoom, FALSE);
        ev_page_cache_set_current_page (view->page_cache, page);
-       gtk_adjustment_set_value (view->hadjustment, view_point.x);
+
+       if (doc_point_to_view_point (view, page, &doc_point, &view_point)) {
+               gtk_adjustment_set_value (view->hadjustment, view_point.x);
+       }
 }
 
 static void
@@ -1179,7 +1189,6 @@ goto_fith_link (EvView *view, EvLink *link)
 
        doc_point.x = 0;
        doc_point.y = doc_height - ev_link_get_top (link);
-       doc_point_to_view_point (view, page, &doc_point, &view_point);
 
        zoom = zoom_for_size_fit_width (doc_width, ev_link_get_top (link),
                                        ev_view_get_width (view),
@@ -1187,7 +1196,12 @@ goto_fith_link (EvView *view, EvLink *link)
 
        ev_view_set_sizing_mode (view, EV_SIZING_FREE);
        ev_view_set_zoom (view, zoom, FALSE);
-       gtk_adjustment_set_value (view->vadjustment, view_point.y);
+
+       if (doc_point_to_view_point (view, page, &doc_point, &view_point)) {
+               gtk_adjustment_set_value (view->vadjustment, view_point.y);
+       } else {
+               ev_page_cache_set_current_page (view->page_cache, page);
+       }
 }
 
 static void
@@ -1227,10 +1241,13 @@ goto_xyz_link (EvView *view, EvLink *link)
 
        doc_point.x = ev_link_get_left (link);
        doc_point.y = height - ev_link_get_top (link);
-       doc_point_to_view_point (view, page, &doc_point, &view_point);
 
-       gtk_adjustment_set_value (view->hadjustment, view_point.x);
-       gtk_adjustment_set_value (view->vadjustment, view_point.y);
+       if (doc_point_to_view_point (view, page, &doc_point, &view_point)) {
+               gtk_adjustment_set_value (view->hadjustment, view_point.x);
+               gtk_adjustment_set_value (view->vadjustment, view_point.y);
+       } else {
+               ev_page_cache_set_current_page (view->page_cache, page);
+       }
 }
 
 void