diff options
author | Brad Hards <bradh@frogmouth.net> | 2005-07-05 12:15:04 +0000 |
---|---|---|
committer | Brad Hards <bradh@frogmouth.net> | 2005-07-05 12:15:04 +0000 |
commit | e10f6990d3339e3a7adeaa50b1754cf7ecf82f87 (patch) | |
tree | bad3ecbeb5026d05f1e1440de913041910776449 /poppler | |
parent | 3a8e1ba03cdec6412dd0b79f0cc59a4cd97dd4e7 (diff) |
Add some more user permissions properties - high resolution
printing, document assembly, extraction for accessibility
and form completion.
Diffstat (limited to 'poppler')
-rw-r--r-- | poppler/PDFDoc.h | 9 | ||||
-rw-r--r-- | poppler/XRef.cc | 55 | ||||
-rw-r--r-- | poppler/XRef.h | 4 |
3 files changed, 64 insertions, 4 deletions
diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h index 160ac839..93818470 100644 --- a/poppler/PDFDoc.h +++ b/poppler/PDFDoc.h @@ -132,12 +132,21 @@ public: // Check various permissions. GBool okToPrint(GBool ignoreOwnerPW = gFalse) { return xref->okToPrint(ignoreOwnerPW); } + GBool okToPrintHighRes(GBool ignoreOwnerPW = gFalse) + { return xref->okToPrintHighRes(ignoreOwnerPW); } GBool okToChange(GBool ignoreOwnerPW = gFalse) { return xref->okToChange(ignoreOwnerPW); } GBool okToCopy(GBool ignoreOwnerPW = gFalse) { return xref->okToCopy(ignoreOwnerPW); } GBool okToAddNotes(GBool ignoreOwnerPW = gFalse) { return xref->okToAddNotes(ignoreOwnerPW); } + GBool okToFillForm(GBool ignoreOwnerPW = gFalse) + { return xref->okToFillForm(ignoreOwnerPW); } + GBool okToAccessibility(GBool ignoreOwnerPW = gFalse) + { return xref->okToAccessibility(ignoreOwnerPW); } + GBool okToAssemble(GBool ignoreOwnerPW = gFalse) + { return xref->okToAssemble(ignoreOwnerPW); } + // Is this document linearized? GBool isLinearized(); diff --git a/poppler/XRef.cc b/poppler/XRef.cc index ebb8062d..b7c4ccac 100644 --- a/poppler/XRef.cc +++ b/poppler/XRef.cc @@ -37,12 +37,17 @@ #ifndef NO_DECRYPTION //------------------------------------------------------------------------ // Permission bits +// Note that the PDF spec uses 1 base (eg bit 3 is 1<<2) //------------------------------------------------------------------------ -#define permPrint (1<<2) -#define permChange (1<<3) -#define permCopy (1<<4) -#define permNotes (1<<5) +#define permPrint (1<<2) // bit 3 +#define permChange (1<<3) // bit 4 +#define permCopy (1<<4) // bit 5 +#define permNotes (1<<5) // bit 6 +#define permFillForm (1<<8) // bit 9 +#define permAccessibility (1<<9) // bit 10 +#define permAssemble (1<<10) // bit 11 +#define permHighResPrint (1<<11) // bit 12 #define defPermFlags 0xfffc #endif @@ -899,6 +904,24 @@ GBool XRef::okToPrint(GBool ignoreOwnerPW) { #endif } +// 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) { +#ifndef NO_DECRYPTION + if (2 == encRevision) { + return (okToPrint(ignoreOwnerPW)); + } else if (encRevision >= 3) { + return (okToPrint(ignoreOwnerPW) && (permFlags & permHighResPrint)); + } else { + // something weird - unknown security handler version + return gFalse; + } +#else + return gTrue; +#endif +} + GBool XRef::okToChange(GBool ignoreOwnerPW) { #ifndef NO_DECRYPTION return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permChange); @@ -923,6 +946,30 @@ GBool XRef::okToAddNotes(GBool ignoreOwnerPW) { #endif } +GBool XRef::okToFillForm(GBool ignoreOwnerPW) { +#ifndef NO_DECRYPTION + return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permFillForm); +#else + return gTrue; +#endif +} + +GBool XRef::okToAccessibility(GBool ignoreOwnerPW) { +#ifndef NO_DECRYPTION + return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permAccessibility); +#else + return gTrue; +#endif +} + +GBool XRef::okToAssemble(GBool ignoreOwnerPW) { +#ifndef NO_DECRYPTION + return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permAssemble); +#else + return gTrue; +#endif +} + Object *XRef::fetch(int num, int gen, Object *obj) { XRefEntry *e; Parser *parser; diff --git a/poppler/XRef.h b/poppler/XRef.h index 14b15a14..b742a7f8 100644 --- a/poppler/XRef.h +++ b/poppler/XRef.h @@ -61,9 +61,13 @@ public: // 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); // Get catalog object. Object *getCatalog(Object *obj) { return fetch(rootNum, rootGen, obj); } |