Commit 1b81192f authored by Albert Astals Cid's avatar Albert Astals Cid

* glib/poppler-page.cc: Make link mapping coordinates follow page

        rotation. Patch by Carlos Garcia Campos <carlosgc@gnome.org>
        * glib/poppler-action.cc: Fix link destination coordinates. Patch by
        Carlos Garcia Campos <carlosgc@gnome.org>
parent 75dcf94f
......@@ -2,6 +2,10 @@
* glib/poppler-document.cc: Plug memory leak in poppler-document.
Patch by Carlos Garcia Campos <carlosgc@gnome.org>
* glib/poppler-page.cc: Make link mapping coordinates follow page
rotation. Patch by Carlos Garcia Campos <carlosgc@gnome.org>
* glib/poppler-action.cc: Fix link destination coordinates. Patch by
Carlos Garcia Campos <carlosgc@gnome.org>
2007-01-21 Albert Astals Cid <aacid@kde.org>
......
......@@ -249,7 +249,20 @@ dest_new_goto (PopplerDocument *document,
dest->change_left = link_dest->getChangeLeft ();
dest->change_top = link_dest->getChangeTop ();
dest->change_zoom = link_dest->getChangeZoom ();
if (dest->page_num > 0) {
PopplerPage *page;
page = poppler_document_get_page (document, dest->page_num - 1);
dest->left -= page->page->getCropBox ()->x1;
dest->bottom -= page->page->getCropBox ()->x1;
dest->right -= page->page->getCropBox ()->y1;
dest->top -= page->page->getCropBox ()->y1;
g_object_unref (page);
}
return dest;
}
......
......@@ -841,7 +841,6 @@ poppler_page_init (PopplerPage *page)
{
}
/**
* poppler_page_get_link_mapping:
* @page: A #PopplerPage
......@@ -855,52 +854,87 @@ poppler_page_init (PopplerPage *page)
GList *
poppler_page_get_link_mapping (PopplerPage *page)
{
GList *map_list = NULL;
gint i;
Links *links;
Object obj;
g_return_val_if_fail (POPPLER_IS_PAGE (page), NULL);
links = new Links (page->page->getAnnots (&obj),
page->document->doc->getCatalog ()->getBaseURI ());
obj.free ();
if (links == NULL)
return NULL;
for (i = 0; i < links->getNumLinks (); i++) {
PopplerLinkMapping *mapping;
LinkAction *link_action;
Link *link;
link = links->getLink (i);
link_action = link->getAction ();
/* Create the mapping */
mapping = g_new (PopplerLinkMapping, 1);
mapping->action = _poppler_action_new (page->document, link_action, NULL);
link->getRect (&(mapping->area.x1), &(mapping->area.y1),
&(mapping->area.x2), &(mapping->area.y2));
mapping->area.x1 -= page->page->getCropBox()->x1;
mapping->area.x2 -= page->page->getCropBox()->x1;
mapping->area.y1 -= page->page->getCropBox()->y1;
mapping->area.y2 -= page->page->getCropBox()->y1;
map_list = g_list_prepend (map_list, mapping);
GList *map_list = NULL;
gint i;
Links *links;
Object obj;
double width, height;
g_return_val_if_fail (POPPLER_IS_PAGE (page), NULL);
links = new Links (page->page->getAnnots (&obj),
page->document->doc->getCatalog ()->getBaseURI ());
obj.free ();
if (links == NULL)
return NULL;
poppler_page_get_size (page, &width, &height);
for (i = 0; i < links->getNumLinks (); i++)
{
PopplerLinkMapping *mapping;
PopplerRectangle rect;
LinkAction *link_action;
Link *link;
link = links->getLink (i);
link_action = link->getAction ();
/* Create the mapping */
mapping = g_new (PopplerLinkMapping, 1);
mapping->action = _poppler_action_new (page->document, link_action, NULL);
link->getRect (&rect.x1, &rect.y1, &rect.x2, &rect.y2);
switch (page->page->getRotate ())
{
case 90:
mapping->area.x1 = rect.y1;
mapping->area.y1 = height - rect.x2;
mapping->area.x2 = mapping->area.x1 + (rect.y2 - rect.y1);
mapping->area.y2 = mapping->area.y1 + (rect.x2 - rect.x1);
break;
case 180:
mapping->area.x1 = width - rect.x2;
mapping->area.y1 = height - rect.y2;
mapping->area.x2 = mapping->area.x1 + (rect.x2 - rect.x1);
mapping->area.y2 = mapping->area.y1 + (rect.y2 - rect.y1);
break;
case 270:
mapping->area.x1 = width - rect.y2;
mapping->area.y1 = rect.x1;
mapping->area.x2 = mapping->area.x1 + (rect.y2 - rect.y1);
mapping->area.y2 = mapping->area.y1 + (rect.x2 - rect.x1);
break;
default:
mapping->area.x1 = rect.x1;
mapping->area.y1 = rect.y1;
mapping->area.x2 = rect.x2;
mapping->area.y2 = rect.y2;
}
delete links;
return map_list;
mapping->area.x1 -= page->page->getCropBox()->x1;
mapping->area.x2 -= page->page->getCropBox()->x1;
mapping->area.y1 -= page->page->getCropBox()->y1;
mapping->area.y2 -= page->page->getCropBox()->y1;
map_list = g_list_prepend (map_list, mapping);
}
delete links;
return map_list;
}
static void
poppler_mapping_free (PopplerLinkMapping *mapping)
{
poppler_action_free (mapping->action);
g_free (mapping);
poppler_action_free (mapping->action);
g_free (mapping);
}
/**
......@@ -915,11 +949,11 @@ poppler_mapping_free (PopplerLinkMapping *mapping)
void
poppler_page_free_link_mapping (GList *list)
{
if (list == NULL)
return;
if (list == NULL)
return;
g_list_foreach (list, (GFunc) (poppler_mapping_free), NULL);
g_list_free (list);
g_list_foreach (list, (GFunc) (poppler_mapping_free), NULL);
g_list_free (list);
}
/* PopplerRectangle type */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment