poppler/XRef.cc | 26 +++++++++++++------------- poppler/XRef.h | 46 +++++++++++++++++++++++----------------------- 2 files changed, 36 insertions(+), 36 deletions(-)
New commits: commit 729e212f465d015959e5a64662593e5e3f8e4924 Author: Albert Astals Cid <[email protected]> Date: Fri Jul 6 17:29:46 2018 +0200 Add some easy const to XRef diff --git a/poppler/XRef.cc b/poppler/XRef.cc index 95e1a1d4..6eadc0a1 100644 --- a/poppler/XRef.cc +++ b/poppler/XRef.cc @@ -293,7 +293,7 @@ XRef::XRef() { init(); } -XRef::XRef(Object *trailerDictA) { +XRef::XRef(const Object *trailerDictA) { init(); if (trailerDictA->isDict()) @@ -393,7 +393,7 @@ XRef::~XRef() { #endif } -XRef *XRef::copy() { +XRef *XRef::copy() const { XRef *xref = new XRef(); xref->str = str->copy(); xref->strOwner = gTrue; @@ -1028,7 +1028,7 @@ GBool XRef::constructXRef(GBool *wasReconstructed, GBool needCatalogDict) { } void XRef::setEncryption(int permFlagsA, GBool ownerPasswordOkA, - Guchar *fileKeyA, int keyLengthA, + const Guchar *fileKeyA, int keyLengthA, int encVersionA, int encRevisionA, CryptAlgorithm encAlgorithmA) { int i; @@ -1063,14 +1063,14 @@ void XRef::getEncryptionParameters(Guchar **fileKeyA, CryptAlgorithm *encAlgorit } } -GBool XRef::okToPrint(GBool ignoreOwnerPW) { +GBool XRef::okToPrint(GBool ignoreOwnerPW) const { return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permPrint); } // we can print at high res if we are only doing security handler revision // 2 (and we are allowed to print at all), or with security handler rev // 3 and we are allowed to print, and bit 12 is set. -GBool XRef::okToPrintHighRes(GBool ignoreOwnerPW) { +GBool XRef::okToPrintHighRes(GBool ignoreOwnerPW) const { if (encrypted) { if (2 == encRevision) { return (okToPrint(ignoreOwnerPW)); @@ -1085,27 +1085,27 @@ GBool XRef::okToPrintHighRes(GBool ignoreOwnerPW) { } } -GBool XRef::okToChange(GBool ignoreOwnerPW) { +GBool XRef::okToChange(GBool ignoreOwnerPW) const { return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permChange); } -GBool XRef::okToCopy(GBool ignoreOwnerPW) { +GBool XRef::okToCopy(GBool ignoreOwnerPW) const { return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permCopy); } -GBool XRef::okToAddNotes(GBool ignoreOwnerPW) { +GBool XRef::okToAddNotes(GBool ignoreOwnerPW) const { return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permNotes); } -GBool XRef::okToFillForm(GBool ignoreOwnerPW) { +GBool XRef::okToFillForm(GBool ignoreOwnerPW) const { return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permFillForm); } -GBool XRef::okToAccessibility(GBool ignoreOwnerPW) { +GBool XRef::okToAccessibility(GBool ignoreOwnerPW) const { return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permAccessibility); } -GBool XRef::okToAssemble(GBool ignoreOwnerPW) { +GBool XRef::okToAssemble(GBool ignoreOwnerPW) const { return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permAssemble); } @@ -1357,7 +1357,7 @@ void XRef::add(int num, int gen, Goffset offs, GBool used) { } } -void XRef::setModifiedObject (Object* o, Ref r) { +void XRef::setModifiedObject (const Object* o, Ref r) { xrefLocker(); if (r.num < 0 || r.num >= size) { error(errInternal, -1,"XRef::setModifiedObject on unknown ref: {0:d}, {1:d}\n", r.num, r.gen); @@ -1369,7 +1369,7 @@ void XRef::setModifiedObject (Object* o, Ref r) { setModified(); } -Ref XRef::addIndirectObject (Object* o) { +Ref XRef::addIndirectObject (const Object *o) { int entryIndexToUse = -1; for (int i = 1; entryIndexToUse == -1 && i < size; ++i) { XRefEntry *e = getEntry(i, false /* complainIfMissing */); diff --git a/poppler/XRef.h b/poppler/XRef.h index 686b3eb7..bf904d50 100644 --- a/poppler/XRef.h +++ b/poppler/XRef.h @@ -76,7 +76,7 @@ struct XRefEntry { DontRewrite // Entry must not be written back in case of full rewrite }; - inline GBool getFlag(Flag flag) { + inline GBool getFlag(Flag flag) const { const int mask = (1 << (int)flag); return (flags & mask) != 0; } @@ -97,7 +97,7 @@ public: // Constructor, create an empty XRef, used for PDF writing XRef(); // Constructor, create an empty XRef but with info dict, used for PDF writing - XRef(Object *trailerDictA); + XRef(const Object *trailerDictA); // Constructor. Read xref table from stream. XRef(BaseStream *strA, Goffset pos, Goffset mainXRefEntriesOffsetA = 0, GBool *wasReconstructed = NULL, GBool reconstruct = false); @@ -108,20 +108,20 @@ public: XRef& operator=(const XRef &) = delete; // Copy xref but with new base stream! - XRef *copy(); + XRef *copy() const; // Is xref table valid? - GBool isOk() { return ok; } + GBool isOk() const { return ok; } // Is the last XRef section a stream or a table? - GBool isXRefStream() { return xRefStream; } + GBool isXRefStream() const { return xRefStream; } // Get the error code (if isOk() returns false). - int getErrorCode() { return errCode; } + int getErrorCode() const { return errCode; } // Set the encryption parameters. void setEncryption(int permFlagsA, GBool ownerPasswordOkA, - Guchar *fileKeyA, int keyLengthA, + const Guchar *fileKeyA, int keyLengthA, int encVersionA, int encRevisionA, CryptAlgorithm encAlgorithmA); // Mark Encrypt entry as Unencrypted @@ -130,18 +130,18 @@ public: void getEncryptionParameters(Guchar **fileKeyA, CryptAlgorithm *encAlgorithmA, int *keyLengthA); // Is the file encrypted? - GBool isEncrypted() { return encrypted; } + GBool isEncrypted() const { return encrypted; } // Check various permissions. - GBool okToPrint(GBool ignoreOwnerPW = gFalse); - GBool okToPrintHighRes(GBool ignoreOwnerPW = gFalse); - GBool okToChange(GBool ignoreOwnerPW = gFalse); - GBool okToCopy(GBool ignoreOwnerPW = gFalse); - GBool okToAddNotes(GBool ignoreOwnerPW = gFalse); - GBool okToFillForm(GBool ignoreOwnerPW = gFalse); - GBool okToAccessibility(GBool ignoreOwnerPW = gFalse); - GBool okToAssemble(GBool ignoreOwnerPW = gFalse); - int getPermFlags() { return permFlags; } + GBool okToPrint(GBool ignoreOwnerPW = gFalse) const; + GBool okToPrintHighRes(GBool ignoreOwnerPW = gFalse) const; + GBool okToChange(GBool ignoreOwnerPW = gFalse) const; + GBool okToCopy(GBool ignoreOwnerPW = gFalse) const; + GBool okToAddNotes(GBool ignoreOwnerPW = gFalse) const; + GBool okToFillForm(GBool ignoreOwnerPW = gFalse) const; + GBool okToAccessibility(GBool ignoreOwnerPW = gFalse) const; + GBool okToAssemble(GBool ignoreOwnerPW = gFalse) const; + int getPermFlags() const { return permFlags; } // Get catalog object. Object getCatalog(); @@ -161,11 +161,11 @@ public: void removeDocInfo(); // Return the number of objects in the xref table. - int getNumObjects() { return size; } + int getNumObjects() const { return size; } // Return the catalog object reference. - int getRootNum() { return rootNum; } - int getRootGen() { return rootGen; } + int getRootNum() const { return rootNum; } + int getRootGen() const { return rootGen; } // Get end position for a stream in a damaged file. // Returns false if unknown or file is not damaged. @@ -187,13 +187,13 @@ public: Object *getTrailerDict() { return &trailerDict; } // Was the XRef modified? - GBool isModified() { return modified; } + GBool isModified() const { return modified; } // Set the modification flag for XRef to true. void setModified() { modified = gTrue; } // Write access - void setModifiedObject(Object* o, Ref r); - Ref addIndirectObject (Object* o); + void setModifiedObject(const Object* o, Ref r); + Ref addIndirectObject (const Object* o); void removeIndirectObject(Ref r); void add(int num, int gen, Goffset offs, GBool used); _______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
