|
Lines 1-69
Link Here
|
| 1 |
From 8b0348b3d5f33494d7e637411633fbea511a78d7 Mon Sep 17 00:00:00 2001 |
|
|
| 2 |
From: Jakub Wilk <jwilk@jwilk.net> |
| 3 |
Date: Mon, 1 Apr 2019 08:49:02 +0200 |
| 4 |
Subject: [PATCH] Use Catalog::findPage(Ref) as alternative to |
| 5 |
Catalog::findPage(int, int). |
| 6 |
MIME-Version: 1.0 |
| 7 |
Content-Type: text/plain; charset=UTF-8 |
| 8 |
Content-Transfer-Encoding: 8bit |
| 9 |
|
| 10 |
Fixes: |
| 11 |
|
| 12 |
pdf2djvu.cc: In function ‘int get_page_for_goto_link(pdf::link::GoTo*, pdf::Catalog*)’: |
| 13 |
pdf2djvu.cc:90:56: error: no matching function for call to ‘Catalog::findPage(int&, int&)’ |
| 14 |
--- |
| 15 |
pdf-backend.cc | 15 +++++++++++++++ |
| 16 |
pdf-backend.hh | 2 ++ |
| 17 |
pdf2djvu.cc | 2 +- |
| 18 |
3 files changed, 18 insertions(+), 1 deletion(-) |
| 19 |
|
| 20 |
diff --git a/pdf-backend.cc b/pdf-backend.cc |
| 21 |
index f1d7662..a1b9b63 100644 |
| 22 |
--- pdf-backend.cc |
| 23 |
+++ pdf-backend.cc |
| 24 |
@@ -631,4 +631,19 @@ const char * pdf::get_c_string(const pdf::String *str) |
| 25 |
} |
| 26 |
#endif |
| 27 |
|
| 28 |
+template <typename C> static auto find_page_impl(C *catalog, pdf::Ref pgref) -> decltype(catalog->findPage(0, 0)) |
| 29 |
+{ |
| 30 |
+ return catalog->findPage(pgref.num, pgref.gen); |
| 31 |
+} |
| 32 |
+ |
| 33 |
+template <typename C> static auto find_page_impl(C *catalog, pdf::Ref pgref) -> decltype(catalog->findPage(pgref)) |
| 34 |
+{ |
| 35 |
+ return catalog->findPage(pgref); |
| 36 |
+} |
| 37 |
+ |
| 38 |
+int pdf::find_page(pdf::Catalog *catalog, pdf::Ref pgref) |
| 39 |
+{ |
| 40 |
+ return find_page_impl<pdf::Catalog>(catalog, pgref); |
| 41 |
+} |
| 42 |
+ |
| 43 |
// vim:ts=2 sts=2 sw=2 et |
| 44 |
diff --git a/pdf-backend.hh b/pdf-backend.hh |
| 45 |
index d7872c3..d88c956 100644 |
| 46 |
--- pdf-backend.hh |
| 47 |
+++ pdf-backend.hh |
| 48 |
@@ -436,6 +436,8 @@ namespace pdf |
| 49 |
|
| 50 |
const char * get_c_string(const pdf::String *str); |
| 51 |
|
| 52 |
+ int find_page(pdf::Catalog *catalog, pdf::Ref pgref); |
| 53 |
+ |
| 54 |
} |
| 55 |
|
| 56 |
#endif |
| 57 |
diff --git a/pdf2djvu.cc b/pdf2djvu.cc |
| 58 |
index d9e1532..21f2d50 100644 |
| 59 |
--- pdf2djvu.cc |
| 60 |
+++ pdf2djvu.cc |
| 61 |
@@ -87,7 +87,7 @@ static int get_page_for_goto_link(pdf::link::GoTo *goto_link, pdf::Catalog *cata |
| 62 |
if (dest->isPageRef()) |
| 63 |
{ |
| 64 |
pdf::Ref pageref = dest->getPageRef(); |
| 65 |
- page = catalog->findPage(pageref.num, pageref.gen); |
| 66 |
+ page = pdf::find_page(catalog, pageref); |
| 67 |
} |
| 68 |
else |
| 69 |
page = dest->getPageNum(); |