*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <config.h>
#include "djvu-links.h"
#include "djvu-document-private.h"
#include "ev-document-links.h"
-#include "ev-mapping.h"
+#include "ev-mapping-list.h"
static gboolean number_from_miniexp(miniexp_t sexp, int *number)
{
}
}
-static EvLinkDest *
-get_djvu_link_dest (const DjvuDocument *djvu_document, const gchar *link_name, int base_page)
+static guint64
+get_djvu_link_page (const DjvuDocument *djvu_document, const gchar *link_name, int base_page)
{
guint64 page_num = 0;
if (g_str_has_prefix (link_name, "#")) {
if (base_page > 0 && g_str_has_prefix (link_name+1, "+")) {
if (number_from_string_10 (link_name + 2, &page_num)) {
- return ev_link_dest_new_page (base_page + page_num);
+ return base_page + page_num;
}
} else if (base_page > 0 && g_str_has_prefix (link_name+1, "-")) {
if (number_from_string_10 (link_name + 2, &page_num)) {
- return ev_link_dest_new_page (base_page - page_num);
+ return base_page - page_num;
}
} else {
if (number_from_string_10 (link_name + 1, &page_num)) {
- return ev_link_dest_new_page (page_num - 1);
+ return page_num - 1;
}
}
} else {
/* FIXME: component file identifiers */
}
- return NULL;
+ return page_num;
+}
+
+static EvLinkDest *
+get_djvu_link_dest (const DjvuDocument *djvu_document, const gchar *link_name, int base_page)
+{
+ return ev_link_dest_new_page (get_djvu_link_page (djvu_document, link_name, base_page));
}
static EvLinkAction *
return FALSE;
}
-GList *
+EvMappingList *
djvu_links_get_links (EvDocumentLinks *document_links,
gint page,
double scale_factor)
ddjvu_miniexp_release (djvu_document->d_document, page_annotations);
}
- return retval;
+ return ev_mapping_list_new (page, retval, (GDestroyNotify)g_object_unref);
}
EvLinkDest *
return ev_dest;
}
+gint
+djvu_links_find_link_page (EvDocumentLinks *document_links,
+ const gchar *link_name)
+{
+ DjvuDocument *djvu_document = DJVU_DOCUMENT (document_links);
+ gint page;
+
+ page = get_djvu_link_page (djvu_document, link_name, -1);
+
+ if (page == -1) {
+ g_warning ("DjvuLibre error: unknown link destination %s", link_name);
+ }
+
+ return page;
+}
+
GtkTreeModel *
djvu_links_get_links_model (EvDocumentLinks *document_links)
{