[poppler] poppler/Annot.cc poppler/GfxFont.cc poppler/GfxFont.h poppler/Link.cc poppler/Link.h poppler/StructElement.h poppler/StructTreeRoot.h qt5/src

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Mar 28 10:58:16 UTC 2019


 poppler/Annot.cc         |   10 ++++------
 poppler/GfxFont.cc       |   14 +++++++-------
 poppler/GfxFont.h        |    4 ++--
 poppler/Link.cc          |    6 +++---
 poppler/Link.h           |    2 +-
 poppler/StructElement.h  |    2 +-
 poppler/StructTreeRoot.h |    4 ++--
 qt5/src/poppler-link.cc  |    6 +++---
 qt5/src/poppler-page.cc  |    8 +++-----
 9 files changed, 26 insertions(+), 30 deletions(-)

New commits:
commit 926ea4645fa36d29d4bf89009719716668103366
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Mar 28 00:09:28 2019 +0100

    Use the newly introduced Ref::INVALID()

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index fd2ea0fa..668d0c5a 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -3773,7 +3773,7 @@ void AnnotWidget::initialize(PDFDoc *docA, Dict *dict) {
     border = std::make_unique<AnnotBorderBS>(obj1.getDict());
   }
 
-  updatedAppearanceStream.num = updatedAppearanceStream.gen = -1;
+  updatedAppearanceStream = Ref::INVALID();
 }
 
 LinkAction* AnnotWidget::getAdditionalAction(AdditionalActionsType type)
@@ -4100,9 +4100,7 @@ bool AnnotAppearanceBuilder::drawText(const GooString *text, const GooString *da
         if (forceZapfDingbats) {
           // We are forcing ZaDb but the font does not exist
           // so create a fake one
-          Ref r; // dummy Ref, it's not used at all in this codepath
-          r.num = -1;
-          r.gen = -1;
+          Ref r = Ref::INVALID(); // dummy Ref, it's not used at all in this codepath
           Dict *d = new Dict(xref);
           fontToFree = new Gfx8BitFont(xref, "ZaDb", r, new GooString("ZapfDingbats"), fontType1, r, d);
           delete d;
@@ -4908,7 +4906,7 @@ void AnnotWidget::updateAppearanceStream()
 {
   // If this the first time updateAppearanceStream() is called on this widget,
   // destroy the AP dictionary because we are going to create a new one.
-  if (updatedAppearanceStream.num == -1) {
+  if (updatedAppearanceStream == Ref::INVALID()) {
     invalidateAppearance(); // Delete AP dictionary and all referenced streams
   }
 
@@ -4928,7 +4926,7 @@ void AnnotWidget::updateAppearanceStream()
   // If this the first time updateAppearanceStream() is called on this widget,
   // create a new AP dictionary containing the new appearance stream.
   // Otherwise, just update the stream we had created previously.
-  if (updatedAppearanceStream.num == -1) {
+  if (updatedAppearanceStream == Ref::INVALID()) {
     // Write the appearance stream
     updatedAppearanceStream = xref->addIndirectObject(&obj1);
 
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 44282d94..db6f0b8d 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -601,7 +601,7 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps) {
   }
 
   //----- embedded font
-  if (embFontID.num >= 0) {
+  if (embFontID != Ref::INVALID()) {
     embed = true;
     Object refObj(embFontID);
     Object embFontObj = refObj.fetch(xref);
@@ -823,7 +823,7 @@ char *GfxFont::readEmbFontFile(XRef *xref, int *len) {
   Object obj2 = obj1.fetch(xref);
   if (!obj2.isStream()) {
     error(errSyntaxError, -1, "Embedded font file is not a stream");
-    embFontID.num = -1;
+    embFontID = Ref::INVALID();
     *len = 0;
     return nullptr;
   }
@@ -1027,7 +1027,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
 
   // for non-embedded fonts, don't trust the ascent/descent/bbox
   // values from the font descriptor
-  if (builtinFont && embFontID.num < 0) {
+  if (builtinFont && embFontID == Ref::INVALID()) {
     ascent = 0.001 * builtinFont->ascent;
     descent = 0.001 * builtinFont->descent;
     fontBBox[0] = 0.001 * builtinFont->bbox[0];
@@ -1123,7 +1123,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
   ffT1 = nullptr;
   ffT1C = nullptr;
   buf = nullptr;
-  if (type == fontType1 && embFontID.num >= 0) {
+  if (type == fontType1 && embFontID != Ref::INVALID()) {
     if ((buf = readEmbFontFile(xref, &len))) {
       if ((ffT1 = FoFiType1::make(buf, len))) {
 	if (ffT1->getName()) {
@@ -1139,7 +1139,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
       }
       gfree(buf);
     }
-  } else if (type == fontType1C && embFontID.num >= 0) {
+  } else if (type == fontType1C && embFontID != Ref::INVALID()) {
     if ((buf = readEmbFontFile(xref, &len))) {
       if ((ffT1C = FoFiType1C::make(buf, len))) {
 	if (ffT1C->getName()) {
@@ -1159,7 +1159,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
 
   // get default base encoding
   if (!baseEnc) {
-    if (builtinFont && embFontID.num < 0) {
+    if (builtinFont && embFontID == Ref::INVALID()) {
       baseEnc = builtinFont->defaultBaseEnc;
       hasEncoding = true;
     } else if (type == fontTrueType) {
@@ -1197,7 +1197,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
   // T1C->T1 conversion (since the 'seac' operator depends on having
   // the accents in the encoding), so we fill in any gaps from
   // StandardEncoding
-  if (type == fontType1C && embFontID.num >= 0 && baseEncFromFontFile) {
+  if (type == fontType1C && embFontID != Ref::INVALID() && baseEncFromFontFile) {
     for (i = 0; i < 256; ++i) {
       if (!enc[i] && standardEncoding[i]) {
 	enc[i] = (char *)standardEncoding[i];
diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index 0b1b03e3..740a29c2 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -218,8 +218,8 @@ public:
   // Invalidate an embedded font
   // Returns false if there is no embedded font.
   bool invalidateEmbeddedFont() {
-    if (embFontID.num >= 0) {
-      embFontID.num = -1;
+    if (embFontID != Ref::INVALID()) {
+      embFontID = Ref::INVALID();
       return true;
     }
     return false;
diff --git a/poppler/Link.cc b/poppler/Link.cc
index bd9e6a6c..33b842f1 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -638,7 +638,7 @@ LinkNamed::~LinkNamed() {
 //------------------------------------------------------------------------
 
 LinkMovie::LinkMovie(const Object *obj) {
-  annotRef.num = -1;
+  annotRef = Ref::INVALID();
   annotTitle = nullptr;
 
   const Object &annotationObj = obj->dictLookupNF("Annotation");
@@ -651,7 +651,7 @@ LinkMovie::LinkMovie(const Object *obj) {
     annotTitle = tmp.getString()->copy();
   }
 
-  if ((annotTitle == nullptr) && (annotRef.num == -1)) {
+  if ((annotTitle == nullptr) && (annotRef == Ref::INVALID())) {
     error(errSyntaxError, -1,
 	  "Movie action is missing both the Annot and T keys");
   }
@@ -733,7 +733,7 @@ LinkRendition::LinkRendition(const Object *obj) {
   js = nullptr;
   int operationCode = -1;
 
-  screenRef.num = -1;
+  screenRef = Ref::INVALID();
 
   if (obj->isDict()) {
     Object tmp = obj->dictLookup("JS");
diff --git a/poppler/Link.h b/poppler/Link.h
index 801b75cc..08949ea8 100644
--- a/poppler/Link.h
+++ b/poppler/Link.h
@@ -360,7 +360,7 @@ public:
   bool hasRenditionObject() const { return renditionObj.isDict(); }
   const Object* getRenditionObject() const { return &renditionObj; }
 
-  bool hasScreenAnnot() const { return screenRef.num != -1; }
+  bool hasScreenAnnot() const { return screenRef != Ref::INVALID(); }
   Ref getScreenAnnot() const { return screenRef; }
 
   RenditionOperation getOperation() const { return operation; }
diff --git a/poppler/StructElement.h b/poppler/StructElement.h
index 9030fb3d..4cc052a0 100644
--- a/poppler/StructElement.h
+++ b/poppler/StructElement.h
@@ -155,7 +155,7 @@ public:
   bool isGrouping() const;
 
   inline bool isContent() const { return (type == MCID) || isObjectRef(); }
-  inline bool isObjectRef() const { return (type == OBJR && c->ref.num != -1 && c->ref.gen != -1); }
+  inline bool isObjectRef() const { return (type == OBJR && c->ref != Ref::INVALID()); }
 
   int getMCID() const { return c->mcid; }
   Ref getObjectRef() const { return c->ref; }
diff --git a/poppler/StructTreeRoot.h b/poppler/StructTreeRoot.h
index 41b1cd85..58b129c8 100644
--- a/poppler/StructTreeRoot.h
+++ b/poppler/StructTreeRoot.h
@@ -5,7 +5,7 @@
 // This file is licensed under the GPLv2 or later
 //
 // Copyright 2013, 2014 Igalia S.L.
-// Copyright 2018 Albert Astals Cid <aacid at kde.org>
+// Copyright 2018, 2019 Albert Astals Cid <aacid at kde.org>
 // Copyright 2018 Adrian Johnson <ajohnson at redneon.com>
 // Copyright 2018 Adam Reichold <adam.reichold at t-online.de>
 //
@@ -64,7 +64,7 @@ private:
     Ref            ref;
     StructElement *element;
 
-    Parent(): element(nullptr) { ref.num = ref.gen = -1; }
+    Parent(): element(nullptr) { ref = Ref::INVALID(); }
     Parent(const Parent &p) = default;
     Parent& operator=(const Parent &) = default;
     ~Parent() {}
diff --git a/qt5/src/poppler-link.cc b/qt5/src/poppler-link.cc
index da3d5d8b..099871d8 100644
--- a/qt5/src/poppler-link.cc
+++ b/qt5/src/poppler-link.cc
@@ -1,5 +1,5 @@
 /* poppler-link.cc: qt interface to poppler
- * Copyright (C) 2006-2007, 2013, 2016-2018, Albert Astals Cid
+ * Copyright (C) 2006-2007, 2013, 2016-2019, Albert Astals Cid
  * Copyright (C) 2007-2008, Pino Toscano <pino at kde.org>
  * Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
  * Copyright (C) 2012, Tobias Koenig <tokoe at kdab.com>
@@ -626,7 +626,7 @@ class LinkMoviePrivate : public LinkPrivate
 	bool LinkRendition::isReferencedAnnotation( const ScreenAnnotation *annotation ) const
 	{
 		Q_D( const LinkRendition );
-		if ( d->annotationReference.num != -1 && d->annotationReference == annotation->d_ptr->pdfObjectReference() )
+		if ( d->annotationReference != Ref::INVALID() && d->annotationReference == annotation->d_ptr->pdfObjectReference() )
 		{
 			return true;
 		}
@@ -681,7 +681,7 @@ class LinkMoviePrivate : public LinkPrivate
 	bool LinkMovie::isReferencedAnnotation( const MovieAnnotation *annotation ) const
 	{
 		Q_D( const LinkMovie );
-		if ( d->annotationReference.num != -1 && d->annotationReference == annotation->d_ptr->pdfObjectReference() )
+		if ( d->annotationReference != Ref::INVALID() && d->annotationReference == annotation->d_ptr->pdfObjectReference() )
 		{
 			return true;
 		}
diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc
index c6e3d526..3e750620 100644
--- a/qt5/src/poppler-page.cc
+++ b/qt5/src/poppler-page.cc
@@ -1,7 +1,7 @@
 /* poppler-page.cc: qt interface to poppler
  * Copyright (C) 2005, Net Integration Technologies, Inc.
  * Copyright (C) 2005, Brad Hards <bradh at frogmouth.net>
- * Copyright (C) 2005-2018, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2005-2019, Albert Astals Cid <aacid at kde.org>
  * Copyright (C) 2005, Stefan Kebekus <stefan.kebekus at math.uni-koeln.de>
  * Copyright (C) 2006-2011, Pino Toscano <pino at kde.org>
  * Copyright (C) 2008 Carlos Garcia Campos <carlosgc at gnome.org>
@@ -299,8 +299,7 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo
 
       const QString title = ( lm->hasAnnotTitle() ? UnicodeParsedString( lm->getAnnotTitle() ) : QString() );
 
-      Ref reference;
-      reference.num = reference.gen = -1;
+      Ref reference = Ref::INVALID();
       if ( lm->hasAnnotRef() )
         reference = *lm->getAnnotRef();
 
@@ -329,8 +328,7 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo
     {
       ::LinkRendition *lrn = (::LinkRendition *)a;
 
-      Ref reference;
-      reference.num = reference.gen = -1;
+      Ref reference = Ref::INVALID();
       if ( lrn->hasScreenAnnot() )
         reference = lrn->getScreenAnnot();
 


More information about the poppler mailing list