Commit 9352ac52 authored by Albert Astals Cid's avatar Albert Astals Cid

Implement isAllowed for the pdf generator, Enrico is implementing the use of it in pageview etc.

IMHO this is not a feaute but a bug-fix as if this is not implemented we let the user copy text and print from PDF that are protected against and wether we may like it or not is what the spec says and we could get in problems if someone copies text from a protected PDF using our tool.

svn path=/trunk/kdegraphics/kpdf/; revision=390866
parent e4a14234
......@@ -52,7 +52,7 @@ class Generator : public QObject
// DRM handling
enum Permissions { Modify = 1, Copy = 2, Print = 4, AddNotes = 8 };
virtual bool isAllowed( int /*permisisons*/ ) { return true; }
virtual bool isAllowed( int /*permissions*/ ) { return true; }
// page contents generation
virtual bool canGeneratePixmap() = 0;
......
......@@ -209,6 +209,16 @@ const DocumentSynopsis * PDFGenerator::generateDocumentSynopsis()
return &docSyn;
}
bool PDFGenerator::isAllowed( int permissions )
{
bool b = true;
if (permissions & Modify) b = b && pdfdoc->okToChange();
if (permissions & Copy) b = b && pdfdoc->okToCopy();
if (permissions & Print) b = b && pdfdoc->okToPrint();
if (permissions & AddNotes) b = b && pdfdoc->okToAddNotes();
return b;
}
bool PDFGenerator::canGeneratePixmap()
{
return ready;
......
......@@ -54,6 +54,9 @@ class PDFGenerator : public Generator
const DocumentInfo * generateDocumentInfo();
const DocumentSynopsis * generateDocumentSynopsis();
// [INHERITED] document informations
bool isAllowed( int permissions );
// [INHERITED] perform actions on document / pages
bool canGeneratePixmap();
void generatePixmap( PixmapRequest * request );
......
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