diff --git a/core/document.cpp b/core/document.cpp index 9d7192782..0d051ed67 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -1165,14 +1165,14 @@ KUrl Document::currentDocument() const return d->m_url; } -bool Document::isAllowed( Permissions flags ) const +bool Document::isAllowed( Permission action ) const { #if !OKULAR_FORCE_DRM if ( KAuthorized::authorize( "skip_drm" ) && !Okular::Settings::obeyDRM() ) return true; #endif - return d->m_generator ? d->m_generator->isAllowed( flags ) : false; + return d->m_generator ? d->m_generator->isAllowed( action ) : false; } bool Document::supportsSearching() const diff --git a/core/document.h b/core/document.h index 26fb0bb2b..60231b501 100644 --- a/core/document.h +++ b/core/document.h @@ -180,11 +180,10 @@ class OKULAR_EXPORT Document : public QObject KUrl currentDocument() const; /** - * Returns whether the given @p actions are allowed - * in the document. - * @see @ref Permissions + * Returns whether the given @p action is allowed in the document. + * @see @ref Permission */ - bool isAllowed( Permissions actions ) const; + bool isAllowed( Permission action ) const; /** * Returns whether the document supports searching. diff --git a/core/generator.cpp b/core/generator.cpp index 242ef2d60..5003a9204 100644 --- a/core/generator.cpp +++ b/core/generator.cpp @@ -223,7 +223,7 @@ Generator::PageSizeMetric Generator::pagesSizeMetric() const return None; } -bool Generator::isAllowed( Permissions ) const +bool Generator::isAllowed( Permission ) const { return true; } diff --git a/core/generator.h b/core/generator.h index e0a01492d..7905ad26b 100644 --- a/core/generator.h +++ b/core/generator.h @@ -286,10 +286,10 @@ class OKULAR_EXPORT Generator : public QObject virtual PageSizeMetric pagesSizeMetric() const; /** - * This method returns whether given action (@ref Permission) is + * This method returns whether given @p action (@ref Permission) is * allowed in this document. */ - virtual bool isAllowed( Permissions action ) const; + virtual bool isAllowed( Permission action ) const; /** * This method is called when the orientation has been changed by the user. diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp index 146e2d38c..33c804ac3 100644 --- a/generators/poppler/generator_pdf.cpp +++ b/generators/poppler/generator_pdf.cpp @@ -591,13 +591,25 @@ const QList *PDFGenerator::embeddedFiles() const return &docEmbeddedFiles; } -bool PDFGenerator::isAllowed( Okular::Permissions permissions ) const +bool PDFGenerator::isAllowed( Okular::Permission permission ) const { bool b = true; - if (permissions & Okular::AllowModify) b = b && pdfdoc->okToChange(); - if (permissions & Okular::AllowCopy) b = b && pdfdoc->okToCopy(); - if (permissions & Okular::AllowPrint) b = b && pdfdoc->okToPrint(); - if (permissions & Okular::AllowNotes) b = b && pdfdoc->okToAddNotes(); + switch ( permission ) + { + case Okular::AllowModify: + b = pdfdoc->okToChange(); + break; + case Okular::AllowCopy: + b = pdfdoc->okToCopy(); + break; + case Okular::AllowPrint: + b = pdfdoc->okToPrint(); + break; + case Okular::AllowNotes: + b = pdfdoc->okToAddNotes(); + break; + default: ; + } return b; } diff --git a/generators/poppler/generator_pdf.h b/generators/poppler/generator_pdf.h index a0ac1f62c..212ac0d42 100644 --- a/generators/poppler/generator_pdf.h +++ b/generators/poppler/generator_pdf.h @@ -63,7 +63,7 @@ class PDFGenerator : public Okular::Generator, public Okular::ConfigInterface PageSizeMetric pagesSizeMetric() const { return Points; } // [INHERITED] document information - bool isAllowed( Okular::Permissions permissions ) const; + bool isAllowed( Okular::Permission permission ) const; // [INHERITED] perform actions on document / pages bool canGeneratePixmap() const;