From: Carlos Garcia Campos Date: Fri, 14 Dec 2007 11:12:20 +0000 (+0000) Subject: Do not change left, top and zoom values when they are null in PDF X-Git-Tag: EVINCE_2_21_90~100 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=a73a364ed185d1d933bd032debd1e37d31a1426b;p=evince.git Do not change left, top and zoom values when they are null in PDF 2007-12-14 Carlos Garcia Campos * backend/pdf/ev-poppler.cc: (ev_link_dest_from_dest): * libdocument/ev-link-dest.[ch]: (ev_link_dest_get_top), (ev_link_dest_get_left), (ev_link_dest_get_zoom), (ev_link_dest_get_property), (ev_link_dest_set_property), (ev_link_dest_class_init), (ev_link_dest_new_xyz), (ev_link_dest_new_fith), (ev_link_dest_new_fitv), (ev_link_dest_new_fitr): * shell/ev-view.c: (goto_fitr_dest), (goto_fitv_dest), (goto_fith_dest), (goto_xyz_dest): Do not change left, top and zoom values when they are null in PDF destinations. Fixes bug #460658. svn path=/trunk/; revision=2769 --- diff --git a/ChangeLog b/ChangeLog index a7c0b674..4b96411e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2007-12-14 Carlos Garcia Campos + + * backend/pdf/ev-poppler.cc: (ev_link_dest_from_dest): + * libdocument/ev-link-dest.[ch]: (ev_link_dest_get_top), + (ev_link_dest_get_left), (ev_link_dest_get_zoom), + (ev_link_dest_get_property), (ev_link_dest_set_property), + (ev_link_dest_class_init), (ev_link_dest_new_xyz), + (ev_link_dest_new_fith), (ev_link_dest_new_fitv), + (ev_link_dest_new_fitr): + * shell/ev-view.c: (goto_fitr_dest), (goto_fitv_dest), + (goto_fith_dest), (goto_xyz_dest): + + Do not change left, top and zoom values when they are null in PDF + destinations. Fixes bug #460658. + 2007-12-10 Christian Persch * shell/ev-view-accessible.c: (ev_view_accessible_finalize), diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc index c4baa99f..690c9081 100644 --- a/backend/pdf/ev-poppler.cc +++ b/backend/pdf/ev-poppler.cc @@ -859,7 +859,10 @@ ev_link_dest_from_dest (PdfDocument *pdf_document, ev_dest = ev_link_dest_new_xyz (dest->page_num - 1, dest->left, height - dest->top, - dest->zoom); + dest->zoom, + dest->change_left, + dest->change_top, + dest->change_zoom); g_object_unref (poppler_page); } break; @@ -874,13 +877,15 @@ ev_link_dest_from_dest (PdfDocument *pdf_document, MAX (0, dest->page_num - 1)); poppler_page_get_size (poppler_page, NULL, &height); ev_dest = ev_link_dest_new_fith (dest->page_num - 1, - height - dest->top); + height - dest->top, + dest->change_top); g_object_unref (poppler_page); } break; case POPPLER_DEST_FITV: ev_dest = ev_link_dest_new_fitv (dest->page_num - 1, - dest->left); + dest->left, + dest->change_left); break; case POPPLER_DEST_FITR: { PopplerPage *poppler_page; diff --git a/libdocument/ev-link-dest.c b/libdocument/ev-link-dest.c index 09f840af..7d04649d 100644 --- a/libdocument/ev-link-dest.c +++ b/libdocument/ev-link-dest.c @@ -29,10 +29,17 @@ enum { PROP_BOTTOM, PROP_RIGHT, PROP_ZOOM, + PROP_CHANGE, PROP_NAMED, PROP_PAGE_LABEL }; +typedef enum { + EV_DEST_CHANGE_TOP = 1 << 0, + EV_DEST_CHANGE_LEFT = 1 << 1, + EV_DEST_CHANGE_ZOOM = 1 << 2 +} EvDestChange; + struct _EvLinkDest { GObject base_instance; @@ -51,6 +58,7 @@ struct _EvLinkDestPrivate { double bottom; double right; double zoom; + EvDestChange change; gchar *named; gchar *page_label; }; @@ -102,18 +110,26 @@ ev_link_dest_get_page (EvLinkDest *self) } gdouble -ev_link_dest_get_top (EvLinkDest *self) +ev_link_dest_get_top (EvLinkDest *self, + gboolean *change_top) { g_return_val_if_fail (EV_IS_LINK_DEST (self), 0); + if (change_top) + *change_top = (self->priv->change & EV_DEST_CHANGE_TOP); + return self->priv->top; } gdouble -ev_link_dest_get_left (EvLinkDest *self) +ev_link_dest_get_left (EvLinkDest *self, + gboolean *change_left) { g_return_val_if_fail (EV_IS_LINK_DEST (self), 0); + if (change_left) + *change_left = (self->priv->change & EV_DEST_CHANGE_LEFT); + return self->priv->left; } @@ -134,10 +150,14 @@ ev_link_dest_get_right (EvLinkDest *self) } gdouble -ev_link_dest_get_zoom (EvLinkDest *self) +ev_link_dest_get_zoom (EvLinkDest *self, + gboolean *change_zoom) { g_return_val_if_fail (EV_IS_LINK_DEST (self), 0); + if (change_zoom) + *change_zoom = (self->priv->change & EV_DEST_CHANGE_ZOOM); + return self->priv->zoom; } @@ -189,6 +209,9 @@ ev_link_dest_get_property (GObject *object, case PROP_ZOOM: g_value_set_double (value, self->priv->zoom); break; + case PROP_CHANGE: + g_value_set_uint (value, self->priv->change); + break; case PROP_NAMED: g_value_set_string (value, self->priv->named); break; @@ -233,6 +256,9 @@ ev_link_dest_set_property (GObject *object, case PROP_ZOOM: self->priv->zoom = g_value_get_double (value); break; + case PROP_CHANGE: + self->priv->change = g_value_get_uint (value); + break; case PROP_NAMED: self->priv->named = g_value_dup_string (value); break; @@ -358,6 +384,16 @@ ev_link_dest_class_init (EvLinkDestClass *ev_link_dest_class) 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property (g_object_class, + PROP_CHANGE, + g_param_spec_uint ("change", + "Change", + "Wether top, left, and zoom should be changed", + 0, + G_MAXUINT, + 0, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (g_object_class, PROP_NAMED, g_param_spec_string ("named", @@ -386,17 +422,30 @@ ev_link_dest_new_page (gint page) } EvLinkDest * -ev_link_dest_new_xyz (gint page, - gdouble left, - gdouble top, - gdouble zoom) +ev_link_dest_new_xyz (gint page, + gdouble left, + gdouble top, + gdouble zoom, + gboolean change_left, + gboolean change_top, + gboolean change_zoom) { + EvDestChange change = 0; + + if (change_left) + change |= EV_DEST_CHANGE_LEFT; + if (change_top) + change |= EV_DEST_CHANGE_TOP; + if (change_zoom) + change |= EV_DEST_CHANGE_ZOOM; + return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST, "page", page, "type", EV_LINK_DEST_TYPE_XYZ, "left", left, "top", top, "zoom", zoom, + "change", change, NULL)); } @@ -410,24 +459,38 @@ ev_link_dest_new_fit (gint page) } EvLinkDest * -ev_link_dest_new_fith (gint page, - gdouble top) +ev_link_dest_new_fith (gint page, + gdouble top, + gboolean change_top) { + EvDestChange change = 0; + + if (change_top) + change |= EV_DEST_CHANGE_TOP; + return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST, "page", page, "type", EV_LINK_DEST_TYPE_FITH, "top", top, + "change", change, NULL)); } EvLinkDest * -ev_link_dest_new_fitv (gint page, - gdouble left) +ev_link_dest_new_fitv (gint page, + gdouble left, + gboolean change_left) { + EvDestChange change = 0; + + if (change_left) + change |= EV_DEST_CHANGE_LEFT; + return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST, "page", page, "type", EV_LINK_DEST_TYPE_FITV, "left", left, + "change", change, NULL)); } @@ -438,6 +501,8 @@ ev_link_dest_new_fitr (gint page, gdouble right, gdouble top) { + EvDestChange change = EV_DEST_CHANGE_TOP | EV_DEST_CHANGE_LEFT; + return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST, "page", page, "type", EV_LINK_DEST_TYPE_FITR, @@ -445,6 +510,7 @@ ev_link_dest_new_fitr (gint page, "bottom", bottom, "right", right, "top", top, + "change", change, NULL)); } diff --git a/libdocument/ev-link-dest.h b/libdocument/ev-link-dest.h index a0c96f58..a7ee0595 100644 --- a/libdocument/ev-link-dest.h +++ b/libdocument/ev-link-dest.h @@ -55,11 +55,14 @@ GType ev_link_dest_get_type (void) G_GNUC_CONST; EvLinkDestType ev_link_dest_get_dest_type (EvLinkDest *self); gint ev_link_dest_get_page (EvLinkDest *self); -gdouble ev_link_dest_get_top (EvLinkDest *self); -gdouble ev_link_dest_get_left (EvLinkDest *self); +gdouble ev_link_dest_get_top (EvLinkDest *self, + gboolean *change_top); +gdouble ev_link_dest_get_left (EvLinkDest *self, + gboolean *change_left); gdouble ev_link_dest_get_bottom (EvLinkDest *self); gdouble ev_link_dest_get_right (EvLinkDest *self); -gdouble ev_link_dest_get_zoom (EvLinkDest *self); +gdouble ev_link_dest_get_zoom (EvLinkDest *self, + gboolean *change_zoom); const gchar *ev_link_dest_get_named_dest (EvLinkDest *self); const gchar *ev_link_dest_get_page_label (EvLinkDest *self); @@ -67,12 +70,17 @@ EvLinkDest *ev_link_dest_new_page (gint page); EvLinkDest *ev_link_dest_new_xyz (gint page, gdouble left, gdouble top, - gdouble zoom); + gdouble zoom, + gboolean change_left, + gboolean change_top, + gboolean change_zoom); EvLinkDest *ev_link_dest_new_fit (gint page); EvLinkDest *ev_link_dest_new_fith (gint page, - gdouble top); + gdouble top, + gboolean change_top); EvLinkDest *ev_link_dest_new_fitv (gint page, - gdouble left); + gdouble left, + gboolean change_left); EvLinkDest *ev_link_dest_new_fitr (gint page, gdouble left, gdouble bottom, diff --git a/shell/ev-view.c b/shell/ev-view.c index b1ec0569..a6007c91 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -1154,21 +1154,26 @@ static void goto_fitr_dest (EvView *view, EvLinkDest *dest) { EvPoint doc_point; - double zoom; + gdouble zoom, left, top; + gboolean change_left, change_top; + + left = ev_link_dest_get_left (dest, &change_left); + top = ev_link_dest_get_top (dest, &change_top); - zoom = zoom_for_size_best_fit (ev_link_dest_get_right (dest) - ev_link_dest_get_left (dest), - ev_link_dest_get_bottom (dest) - ev_link_dest_get_top (dest), + zoom = zoom_for_size_best_fit (ev_link_dest_get_right (dest) - left, + ev_link_dest_get_bottom (dest) - top, ev_view_get_width (view), ev_view_get_height (view), 0, 0); ev_view_set_sizing_mode (view, EV_SIZING_FREE); ev_view_set_zoom (view, zoom, FALSE); - doc_point.x = ev_link_dest_get_left (dest); - doc_point.y = ev_link_dest_get_top (dest); + doc_point.x = change_left ? left : 0; + doc_point.y = change_top ? top : 0; view->current_page = ev_link_dest_get_page (dest); - view->pending_point = doc_point; + if (change_left || change_top) + view->pending_point = doc_point; view->pending_scroll = SCROLL_TO_PAGE_POSITION; gtk_widget_queue_resize (GTK_WIDGET (view)); @@ -1179,12 +1184,14 @@ goto_fitv_dest (EvView *view, EvLinkDest *dest) { EvPoint doc_point; int doc_width, doc_height, page; - double zoom; + double zoom, left; + gboolean change_left; page = ev_link_dest_get_page (dest); ev_page_cache_get_size (view->page_cache, page, 0, 1.0, &doc_width, &doc_height); - doc_point.x = ev_link_dest_get_left (dest); + left = ev_link_dest_get_left (dest, &change_left); + doc_point.x = change_left ? left : 0; doc_point.y = 0; zoom = zoom_for_size_fit_height (doc_width - doc_point.x , doc_height, @@ -1195,7 +1202,8 @@ goto_fitv_dest (EvView *view, EvLinkDest *dest) ev_view_set_zoom (view, zoom, FALSE); view->current_page = page; - view->pending_point = doc_point; + if (change_left) + view->pending_point = doc_point; view->pending_scroll = SCROLL_TO_PAGE_POSITION; gtk_widget_queue_resize (GTK_WIDGET (view)); @@ -1206,15 +1214,18 @@ goto_fith_dest (EvView *view, EvLinkDest *dest) { EvPoint doc_point; int doc_width, doc_height, page; - double zoom; + gdouble zoom, top; + gboolean change_top; page = ev_link_dest_get_page (dest); ev_page_cache_get_size (view->page_cache, page, 0, 1.0, &doc_width, &doc_height); + top = ev_link_dest_get_top (dest, &change_top); + doc_point.x = 0; - doc_point.y = ev_link_dest_get_top (dest); + doc_point.y = change_top ? top : 0; - zoom = zoom_for_size_fit_width (doc_width, ev_link_dest_get_top (dest), + zoom = zoom_for_size_fit_width (doc_width, top, ev_view_get_width (view), ev_view_get_height (view), 0); @@ -1222,7 +1233,8 @@ goto_fith_dest (EvView *view, EvLinkDest *dest) ev_view_set_zoom (view, zoom, FALSE); view->current_page = page; - view->pending_point = doc_point; + if (change_top) + view->pending_point = doc_point; view->pending_scroll = SCROLL_TO_PAGE_POSITION; gtk_widget_queue_resize (GTK_WIDGET (view)); @@ -1255,21 +1267,26 @@ goto_xyz_dest (EvView *view, EvLinkDest *dest) { EvPoint doc_point; gint page; - double zoom; + gdouble zoom, left, top; + gboolean change_zoom, change_left, change_top; - zoom = ev_link_dest_get_zoom (dest); + zoom = ev_link_dest_get_zoom (dest, &change_zoom); page = ev_link_dest_get_page (dest); - if (zoom > 1) { + if (change_zoom && zoom > 1) { ev_view_set_sizing_mode (view, EV_SIZING_FREE); ev_view_set_zoom (view, zoom, FALSE); } - doc_point.x = ev_link_dest_get_left (dest); - doc_point.y = ev_link_dest_get_top (dest); + left = ev_link_dest_get_left (dest, &change_left); + top = ev_link_dest_get_top (dest, &change_top); + + doc_point.x = change_left ? left : 0; + doc_point.y = change_top ? top : 0; view->current_page = page; - view->pending_point = doc_point; + if (change_left || change_top) + view->pending_point = doc_point; view->pending_scroll = SCROLL_TO_PAGE_POSITION; gtk_widget_queue_resize (GTK_WIDGET (view));