[poppler] glib/poppler-action.cc poppler/Annot.cc poppler/Annot.h poppler/CairoFontEngine.cc poppler/Form.cc poppler/MarkedContentOutputDev.cc poppler/Page.cc poppler/PSOutputDev.cc poppler/SplashOutputDev.cc test/pdf-fullrewrite.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Mar 29 13:25:38 UTC 2019


 glib/poppler-action.cc            |    4 ++--
 poppler/Annot.cc                  |    8 ++++----
 poppler/Annot.h                   |    4 ++--
 poppler/CairoFontEngine.cc        |    6 +++---
 poppler/Form.cc                   |    3 +--
 poppler/MarkedContentOutputDev.cc |    5 ++---
 poppler/PSOutputDev.cc            |   25 +++++++++----------------
 poppler/Page.cc                   |    4 ++--
 poppler/SplashOutputDev.cc        |    7 +++----
 test/pdf-fullrewrite.cc           |    6 +++---
 10 files changed, 31 insertions(+), 41 deletions(-)

New commits:
commit 81fc9aa333f81be496d8255cd2ad4d0b9e23bba6
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri Mar 29 12:39:58 2019 +0100

    Use the existing Ref operator==

diff --git a/glib/poppler-action.cc b/glib/poppler-action.cc
index b270f0a2..3efa8994 100644
--- a/glib/poppler-action.cc
+++ b/glib/poppler-action.cc
@@ -554,9 +554,9 @@ get_layer_for_ref (PopplerDocument *document,
 		Layer *layer = (Layer *)l->data;
 
 		if (layer->oc) {
-			Ref ocgRef = layer->oc->getRef();
+			const Ref ocgRef = layer->oc->getRef();
 
-			if (ref->num == ocgRef.num && ref->gen == ocgRef.gen) {
+			if (*ref == ocgRef) {
 				GList *rb_group = nullptr;
 
 				if (preserve_rb)
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 99ea8e24..3bc776ec 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -934,8 +934,8 @@ int AnnotAppearance::getNumStates() {
 // Test if stateObj (a Ref or a Dict) points to the specified stream
 bool AnnotAppearance::referencesStream(const Object *stateObj, Ref refToStream) {
   if (stateObj->isRef()) {
-    Ref r = stateObj->getRef();
-    if (r.num == refToStream.num && r.gen == refToStream.gen) {
+    const Ref r = stateObj->getRef();
+    if (r == refToStream) {
       return true;
     }
   } else if (stateObj->isDict()) { // Test each value
@@ -943,8 +943,8 @@ bool AnnotAppearance::referencesStream(const Object *stateObj, Ref refToStream)
     for (int i = 0; i < size; ++i) {
       const Object &obj1 = stateObj->dictGetValNF(i);
       if (obj1.isRef()) {
-        Ref r = obj1.getRef();
-        if (r.num == refToStream.num && r.gen == refToStream.gen) {
+        const Ref r = obj1.getRef();
+        if (r == refToStream) {
           return true;
         }
       }
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 7bcb6b2d..9f6c9fb1 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -669,8 +669,8 @@ public:
   // Get the resource dict of the appearance stream
   virtual Object getAppearanceResDict();
 
-  bool match(Ref *refA)
-    { return ref.num == refA->num && ref.gen == refA->gen; }
+  bool match(const Ref *refA) const
+    { return ref == *refA; }
 
   double getXMin();
   double getYMin();
diff --git a/poppler/CairoFontEngine.cc b/poppler/CairoFontEngine.cc
index e29898a9..bf6bd88d 100644
--- a/poppler/CairoFontEngine.cc
+++ b/poppler/CairoFontEngine.cc
@@ -17,7 +17,7 @@
 // Copyright (C) 2005-2007 Jeff Muizelaar <jeff at infidigm.net>
 // Copyright (C) 2005, 2006 Kristian Høgsberg <krh at redhat.com>
 // Copyright (C) 2005 Martin Kretzschmar <martink at gnome.org>
-// Copyright (C) 2005, 2009, 2012, 2013, 2015, 2017, 2018 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2005, 2009, 2012, 2013, 2015, 2017-2019 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2006, 2007, 2010, 2011 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2007 Koji Otani <sho at bbr.jp>
 // Copyright (C) 2008, 2009 Chris Wilson <chris at chris-wilson.co.uk>
@@ -81,7 +81,7 @@ CairoFont::~CairoFont() {
 
 bool
 CairoFont::matches(Ref &other, bool printingA) {
-  return (other.num == ref.num && other.gen == ref.gen);
+  return (other == ref);
 }
 
 cairo_font_face_t *
@@ -784,7 +784,7 @@ CairoType3Font::~CairoType3Font() { }
 
 bool
 CairoType3Font::matches(Ref &other, bool printingA) {
-  return (other.num == ref.num && other.gen == ref.gen && printing == printingA);
+  return (other == ref && printing == printingA);
 }
 
 
diff --git a/poppler/Form.cc b/poppler/Form.cc
index 3673d657..92775cdc 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -828,8 +828,7 @@ FormWidget* FormField::findWidgetByRef (Ref aref)
 {
   if (terminal) {
     for(int i=0; i<numChildren; i++) {
-      if (widgets[i]->getRef().num == aref.num 
-          && widgets[i]->getRef().gen == aref.gen)
+      if (widgets[i]->getRef() == aref)
         return widgets[i];
     }
   } else {
diff --git a/poppler/MarkedContentOutputDev.cc b/poppler/MarkedContentOutputDev.cc
index 98f1e4b1..bf00d40d 100644
--- a/poppler/MarkedContentOutputDev.cc
+++ b/poppler/MarkedContentOutputDev.cc
@@ -5,7 +5,7 @@
 // This file is licensed under the GPLv2 or later
 //
 // Copyright 2013 Igalia S.L.
-// Copyright 2018 Albert Astals Cid <aacid at kde.org>
+// Copyright 2018, 2019 Albert Astals Cid <aacid at kde.org>
 //
 //========================================================================
 
@@ -109,8 +109,7 @@ bool MarkedContentOutputDev::needFontChange(const GfxFont* font) const
     return true;
 
   // Two non-null valid fonts are the same if they point to the same Ref
-  if (currentFont->getID()->num == font->getID()->num &&
-      currentFont->getID()->gen == font->getID()->gen)
+  if (*currentFont->getID() == *font->getID())
     return false;
 
   return true;
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 944de682..0d201835 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -1891,8 +1891,7 @@ void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) {
 
   // check if font is already set up
   for (i = 0; i < fontIDLen; ++i) {
-    if (fontIDs[i].num == font->getID()->num &&
-	fontIDs[i].gen == font->getID()->gen) {
+    if (fontIDs[i] == *font->getID()) {
       return;
     }
   }
@@ -2368,8 +2367,7 @@ void PSOutputDev::setupEmbeddedType1CFont(GfxFont *font, Ref *id,
 
   // check if font is already embedded
   for (i = 0; i < t1FontNameLen; ++i) {
-    if (t1FontNames[i].fontFileID.num == id->num &&
-	t1FontNames[i].fontFileID.gen == id->gen) {
+    if (t1FontNames[i].fontFileID == *id) {
       psName->clear();
       psName->insert(0, t1FontNames[i].psName);
       return;
@@ -2413,8 +2411,7 @@ void PSOutputDev::setupEmbeddedOpenTypeT1CFont(GfxFont *font, Ref *id,
 
   // check if font is already embedded
   for (i = 0; i < t1FontNameLen; ++i) {
-    if (t1FontNames[i].fontFileID.num == id->num &&
-	t1FontNames[i].fontFileID.gen == id->gen) {
+    if (t1FontNames[i].fontFileID == *id) {
       psName->clear();
       psName->insert(0, t1FontNames[i].psName);
       return;
@@ -2614,8 +2611,7 @@ void PSOutputDev::setupEmbeddedCIDType0Font(GfxFont *font, Ref *id,
 
   // check if font is already embedded
   for (i = 0; i < t1FontNameLen; ++i) {
-    if (t1FontNames[i].fontFileID.num == id->num &&
-	t1FontNames[i].fontFileID.gen == id->gen) {
+    if (t1FontNames[i].fontFileID == *id) {
       psName->clear();
       psName->insert(0, t1FontNames[i].psName);
       return;
@@ -2709,8 +2705,7 @@ void PSOutputDev::setupEmbeddedOpenTypeCFFFont(GfxFont *font, Ref *id,
 
   // check if font is already embedded
   for (i = 0; i < t1FontNameLen; ++i) {
-    if (t1FontNames[i].fontFileID.num == id->num &&
-	t1FontNames[i].fontFileID.gen == id->gen) {
+    if (t1FontNames[i].fontFileID == *id) {
       psName->clear();
       psName->insert(0, t1FontNames[i].psName);
       return;
@@ -2905,7 +2900,7 @@ void PSOutputDev::setupImages(Dict *resDict) {
 	    imgID = xObjRef.getRef();
 	    int j;
 	    for (j = 0; j < imgIDLen; ++j) {
-	      if (imgIDs[j].num == imgID.num && imgIDs[j].gen == imgID.gen) {
+	      if (imgIDs[j] == imgID) {
 		break;
 	      }
 	    }
@@ -3138,7 +3133,7 @@ void PSOutputDev::setupForm(Ref id, Object *strObj) {
 
   // check if form is already defined
   for (int i = 0; i < formIDLen; ++i) {
-    if (formIDs[i].num == id.num && formIDs[i].gen == id.gen) {
+    if (formIDs[i] == id) {
       return;
     }
   }
@@ -5086,8 +5081,7 @@ void PSOutputDev::drawString(GfxState *state, const GooString *s) {
   codeToGID = nullptr;
   if (font->isCIDFont()) {
     for (i = 0; i < font16EncLen; ++i) {
-      if (font->getID()->num == font16Enc[i].fontID.num &&
-	  font->getID()->gen == font16Enc[i].fontID.gen) {
+      if (*font->getID() == font16Enc[i].fontID) {
 	if (!font16Enc[i].enc) {
 	  // font substitution failed, so don't output any text
 	  return;
@@ -5100,8 +5094,7 @@ void PSOutputDev::drawString(GfxState *state, const GooString *s) {
   // check for a code-to-GID map
   } else {
     for (i = 0; i < font8InfoLen; ++i) {
-      if (font->getID()->num == font8Info[i].fontID.num &&
-	  font->getID()->gen == font8Info[i].fontID.gen) {
+      if (*font->getID() == font8Info[i].fontID) {
 	codeToGID = font8Info[i].codeToGID;
 	break;
       }
diff --git a/poppler/Page.cc b/poppler/Page.cc
index 447a94d2..d137ec4b 100644
--- a/poppler/Page.cc
+++ b/poppler/Page.cc
@@ -425,8 +425,8 @@ void Page::removeAnnot(Annot *annot) {
     for (int i = 0; idx == -1 && i < annArray.arrayGetLength(); ++i) {
       const Object &tmp = annArray.arrayGetNF(i);
       if (tmp.isRef()) {
-        Ref currAnnot = tmp.getRef();
-        if (currAnnot.num == annotRef.num && currAnnot.gen == annotRef.gen) {
+        const Ref currAnnot = tmp.getRef();
+        if (currAnnot == annotRef) {
           idx = i;
         }
       }
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index fd89511b..51d2191d 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -15,7 +15,7 @@
 //
 // Copyright (C) 2005 Takashi Iwai <tiwai at suse.de>
 // Copyright (C) 2006 Stefan Schweizer <genstef at gentoo.org>
-// Copyright (C) 2006-2018 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006-2019 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk at gmail.com>
 // Copyright (C) 2006 Scott Turner <scotty1024 at mac.com>
 // Copyright (C) 2007 Koji Otani <sho at bbr.jp>
@@ -1204,8 +1204,7 @@ public:
   ~SplashOutFontFileID() {}
 
   bool matches(SplashFontFileID *id) override {
-    return ((SplashOutFontFileID *)id)->r.num == r.num &&
-           ((SplashOutFontFileID *)id)->r.gen == r.gen;
+    return ((SplashOutFontFileID *)id)->r == r;
   }
 
 private:
@@ -1234,7 +1233,7 @@ public:
   T3FontCache& operator=(const T3FontCache &) = delete;
   bool matches(const Ref *idA, double m11A, double m12A,
 		double m21A, double m22A)
-    { return fontID.num == idA->num && fontID.gen == idA->gen &&
+    { return fontID == *idA &&
 	     m11 == m11A && m12 == m12A && m21 == m21A && m22 == m22A; }
 
   Ref fontID;			// PDF font ID
diff --git a/test/pdf-fullrewrite.cc b/test/pdf-fullrewrite.cc
index 22b76a3f..a9e3e8ef 100644
--- a/test/pdf-fullrewrite.cc
+++ b/test/pdf-fullrewrite.cc
@@ -247,9 +247,9 @@ static bool compareObjects(const Object *objA, const Object *objB)
       if (objB->getType() != objRef) {
         return false;
       } else {
-        Ref refA = objA->getRef();
-        Ref refB = objB->getRef();
-        return (refA.num == refB.num) && (refA.gen == refB.gen);
+        const Ref refA = objA->getRef();
+        const Ref refB = objB->getRef();
+        return refA == refB;
       }
     }
     default:


More information about the poppler mailing list