Commit e10f6990 authored by Brad Hards's avatar Brad Hards
Browse files

Add some more user permissions properties - high resolution

printing, document assembly, extraction for accessibility
and form completion.
parent 3a8e1ba0
2005-07-05 Brad Hards <bradh@frogmouth.net>
* poppler/XRef.h:
* poppler/Xref.cc:
* poppler/PDFDoc.h: Add some more user permissions properties -
high resolution printing, document assembly, extraction for
accessibility and form completion.
2005-07-04 Brad Hards <bradh@frogmouth.net>
* qt4/src/poppler-page.cc: fix typo bug that
......
......@@ -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();
......
......@@ -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;
......
......@@ -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); }
......
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