[poppler] cpp/poppler-destination.cpp glib/poppler-action.cc glib/poppler-structure-element.cc poppler/Annot.cc poppler/Catalog.cc poppler/Catalog.h poppler/PDFDoc.h poppler/StructElement.cc qt5/src utils/HtmlOutputDev.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Mar 29 12:19:09 UTC 2019


 cpp/poppler-destination.cpp       |    3 ++-
 glib/poppler-action.cc            |    4 ++--
 glib/poppler-structure-element.cc |    2 +-
 poppler/Annot.cc                  |    4 ++--
 poppler/Catalog.cc                |    4 ++--
 poppler/Catalog.h                 |    2 +-
 poppler/PDFDoc.h                  |    2 +-
 poppler/StructElement.cc          |    2 +-
 qt5/src/poppler-link.cc           |    4 ++--
 utils/HtmlOutputDev.cc            |   10 +++++-----
 10 files changed, 19 insertions(+), 18 deletions(-)

New commits:
commit 244c7d6926463b079b1f96e34d9e4451d352942e
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri Mar 29 12:59:16 2019 +0100

    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 74dcc106..eb955815 100644
--- a/cpp/poppler-destination.cpp
+++ b/cpp/poppler-destination.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2019, Masamichi Hosoda <trueroad at trueroad.jp>
+ * Copyright (C) 2019 Albert Astals Cid <aacid at 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 @@ int destination::page_number() const
     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 0d7a559b..b270f0a2 100644
--- a/glib/poppler-action.cc
+++ b/glib/poppler-action.cc
@@ -274,8 +274,8 @@ dest_new_goto (PopplerDocument *document,
 
 	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 094ef408..8a1b167e 100644
--- a/glib/poppler-structure-element.cc
+++ b/glib/poppler-structure-element.cc
@@ -437,7 +437,7 @@ poppler_structure_element_get_page (PopplerStructureElement *poppler_structure_e
   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 668d0c5a..99ea8e24 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1229,9 +1229,9 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) {
   // 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 4955088a..905954e3 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -326,12 +326,12 @@ bool Catalog::cachePageTree(int page)
   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 f4c3fe6c..a3a48f87 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -146,7 +146,7 @@ public:
 
   // 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 6f27a5f1..3c62903a 100644
--- a/poppler/PDFDoc.h
+++ b/poppler/PDFDoc.h
@@ -218,7 +218,7 @@ public:
 
   // 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 e1142772..ccfa4686 100644
--- a/poppler/StructElement.cc
+++ b/poppler/StructElement.cc
@@ -1002,7 +1002,7 @@ const TextSpanArray& StructElement::getTextSpansInternal(MarkedContentOutputDev&
 
   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 099871d8..f2d1655f 100644
--- a/qt5/src/poppler-link.cc
+++ b/qt5/src/poppler-link.cc
@@ -256,8 +256,8 @@ class LinkMoviePrivate : public LinkPrivate
 		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 e8380a14..114a14bd 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 at kde.org>
+// Copyright (C) 2005-2013, 2016-2019 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2008 Kjartan Maraas <kmaraas at gnome.org>
 // Copyright (C) 2008 Boris Toloknov <tlknv at yandex.ru>
 // Copyright (C) 2008 Haruyuki Kawabe <Haruyuki.Kawabe at unisys.co.jp>
@@ -1568,8 +1568,8 @@ GooString* HtmlOutputDev::getLinkDest(AnnotLink *link){
 	      
 	  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 @@ int HtmlOutputDev::getOutlinePageNum(OutlineItem *item)
         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();
     }


More information about the poppler mailing list