Commit 81fc9aa3 authored by Albert Astals Cid's avatar Albert Astals Cid

Use the existing Ref operator==

parent 244c7d69
......@@ -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)
......
......@@ -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;
}
}
......
......@@ -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();
......
......@@ -17,7 +17,7 @@
// Copyright (C) 2005-2007 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org>
// Copyright (C) 2005, 2009, 2012, 2013, 2015, 2017, 2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005, 2009, 2012, 2013, 2015, 2017-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006, 2007, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2007 Koji Otani <sho@bbr.jp>
// Copyright (C) 2008, 2009 Chris Wilson <chris@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);
}
......
......@@ -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 {
......
......@@ -5,7 +5,7 @@
// This file is licensed under the GPLv2 or later
//
// Copyright 2013 Igalia S.L.
// Copyright 2018 Albert Astals Cid <aacid@kde.org>
// Copyright 2018, 2019 Albert Astals Cid <aacid@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;
......
......@@ -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;
}
......
......@@ -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;
}
}
......
......@@ -15,7 +15,7 @@
//
// Copyright (C) 2005 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2006 Stefan Schweizer <genstef@gentoo.org>
// Copyright (C) 2006-2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2006 Scott Turner <scotty1024@mac.com>
// Copyright (C) 2007 Koji Otani <sho@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
......
......@@ -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:
......
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