Commit 926ea464 authored by Albert Astals Cid's avatar Albert Astals Cid Committed by Albert Astals Cid

Use the newly introduced Ref::INVALID()

parent 8122f6d6
......@@ -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);
......
......@@ -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];
......
......@@ -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;
......
......@@ -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");
......
......@@ -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; }
......
......@@ -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; }
......
......@@ -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@kde.org>
// Copyright 2018, 2019 Albert Astals Cid <aacid@kde.org>
// Copyright 2018 Adrian Johnson <ajohnson@redneon.com>
// Copyright 2018 Adam Reichold <adam.reichold@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() {}
......
/* 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@kde.org>
* Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
* Copyright (C) 2012, Tobias Koenig <tokoe@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;
}
......
/* poppler-page.cc: qt interface to poppler
* Copyright (C) 2005, Net Integration Technologies, Inc.
* Copyright (C) 2005, Brad Hards <bradh@frogmouth.net>
* Copyright (C) 2005-2018, Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2005-2019, Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2005, Stefan Kebekus <stefan.kebekus@math.uni-koeln.de>
* Copyright (C) 2006-2011, Pino Toscano <pino@kde.org>
* Copyright (C) 2008 Carlos Garcia Campos <carlosgc@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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment