Make Catalog::findPage just take a Ref instead of num and gen
All the callers already have a ref so makes no sense to unbox it
diff --git a/cpp/poppler-destination.cpp b/cpp/poppler-destination.cpp
index 74dcc10..eb95581 100644
--- a/cpp/poppler-destination.cpp
+++ b/cpp/poppler-destination.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2019, Masamichi Hosoda <trueroad@trueroad.jp>
+ * Copyright (C) 2019 Albert Astals Cid <aacid@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -196,7 +197,7 @@
if (d->page_number_unresolved) {
d->page_number_unresolved = false;
d->page_number =
- d->pdf_doc->findPage(d->page_ref.num, d->page_ref.gen);
+ d->pdf_doc->findPage(d->page_ref);
}
return d->page_number;
diff --git a/glib/poppler-action.cc b/glib/poppler-action.cc
index 0d7a559..b270f0a 100644
--- a/glib/poppler-action.cc
+++ b/glib/poppler-action.cc
@@ -274,8 +274,8 @@
if (link_dest->isPageRef ()) {
if (document) {
- Ref page_ref = link_dest->getPageRef ();
- dest->page_num = document->doc->findPage (page_ref.num, page_ref.gen);
+ const Ref page_ref = link_dest->getPageRef ();
+ dest->page_num = document->doc->findPage (page_ref);
} else {
/* FIXME: We don't keep areound the page_ref for the
* remote doc, so we can't look this up. Guess that
diff --git a/glib/poppler-structure-element.cc b/glib/poppler-structure-element.cc
index 094ef40..8a1b167 100644
--- a/glib/poppler-structure-element.cc
+++ b/glib/poppler-structure-element.cc
@@ -437,7 +437,7 @@
Ref ref;
if (poppler_structure_element->elem->getPageRef (ref))
{
- return poppler_structure_element->document->doc->findPage(ref.num, ref.gen) - 1;
+ return poppler_structure_element->document->doc->findPage(ref) - 1;
}
return -1;
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 668d0c5..99ea8e2 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1229,9 +1229,9 @@
// Note: This value is overwritten by Annots ctor
const Object &pObj = dict->lookupNF("P");
if (pObj.isRef()) {
- Ref ref = pObj.getRef();
+ const Ref ref = pObj.getRef();
- page = doc->getCatalog()->findPage (ref.num, ref.gen);
+ page = doc->getCatalog()->findPage (ref);
} else {
page = 0;
}
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 4955088..905954e 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -326,12 +326,12 @@
return false;
}
-int Catalog::findPage(int num, int gen) {
+int Catalog::findPage(const Ref pageRef) {
int i;
for (i = 0; i < getNumPages(); ++i) {
Ref *ref = getPageRef(i+1);
- if (ref != nullptr && ref->num == num && ref->gen == gen)
+ if (ref != nullptr && *ref == pageRef)
return i + 1;
}
return 0;
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index f4c3fe6..a3a48f8 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -146,7 +146,7 @@
// Find a page, given its object ID. Returns page number, or 0 if
// not found.
- int findPage(int num, int gen);
+ int findPage(const Ref pageRef);
// Find a named destination. Returns the link destination, or
// NULL if <name> is not a destination.
diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h
index 6f27a5f..3c62903 100644
--- a/poppler/PDFDoc.h
+++ b/poppler/PDFDoc.h
@@ -218,7 +218,7 @@
// Find a page, given its object ID. Returns page number, or 0 if
// not found.
- int findPage(int num, int gen) { return catalog->findPage(num, gen); }
+ int findPage(const Ref ref) { return catalog->findPage(ref); }
// Returns the links for the current page, transferring ownership to
// the caller.
diff --git a/poppler/StructElement.cc b/poppler/StructElement.cc
index e114277..ccfa468 100644
--- a/poppler/StructElement.cc
+++ b/poppler/StructElement.cc
@@ -1002,7 +1002,7 @@
Ref ref;
if (getPageRef(ref)) {
- startPage = endPage = treeRoot->getDoc()->findPage(ref.num, ref.gen);
+ startPage = endPage = treeRoot->getDoc()->findPage(ref);
}
if (!(startPage && endPage)) {
diff --git a/qt5/src/poppler-link.cc b/qt5/src/poppler-link.cc
index 099871d..f2d1655 100644
--- a/qt5/src/poppler-link.cc
+++ b/qt5/src/poppler-link.cc
@@ -256,8 +256,8 @@
if ( !ld->isPageRef() ) d->pageNum = ld->getPageNum();
else
{
- Ref ref = ld->getPageRef();
- d->pageNum = data.doc->doc->findPage( ref.num, ref.gen );
+ const Ref ref = ld->getPageRef();
+ d->pageNum = data.doc->doc->findPage( ref );
}
double left = ld->getLeft();
double bottom = ld->getBottom();
diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc
index e8380a1..114a14b 100644
--- a/utils/HtmlOutputDev.cc
+++ b/utils/HtmlOutputDev.cc
@@ -17,7 +17,7 @@
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
-// Copyright (C) 2005-2013, 2016-2018 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2005-2013, 2016-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2008 Kjartan Maraas <kmaraas@gnome.org>
// Copyright (C) 2008 Boris Toloknov <tlknv@yandex.ru>
// Copyright (C) 2008 Haruyuki Kawabe <Haruyuki.Kawabe@unisys.co.jp>
@@ -1568,8 +1568,8 @@
if (dest){
if (dest->isPageRef()){
- Ref pageref=dest->getPageRef();
- page=catalog->findPage(pageref.num,pageref.gen);
+ const Ref pageref=dest->getPageRef();
+ page=catalog->findPage(pageref);
}
else {
page=dest->getPageNum();
@@ -1875,8 +1875,8 @@
return pagenum;
if (linkdest->isPageRef()) {
- Ref pageref = linkdest->getPageRef();
- pagenum = catalog->findPage(pageref.num, pageref.gen);
+ const Ref pageref = linkdest->getPageRef();
+ pagenum = catalog->findPage(pageref);
} else {
pagenum = linkdest->getPageNum();
}