it does not make much sense to check for a serie of permissions at the same time, so just check one permission at a time

svn path=/trunk/playground/graphics/okular/; revision=641341
remotes/origin/KDE/4.0
Pino Toscano 19 years ago
parent 9a10418505
commit 1bfc805a3e
  1. 4
      core/document.cpp
  2. 7
      core/document.h
  3. 2
      core/generator.cpp
  4. 4
      core/generator.h
  5. 22
      generators/poppler/generator_pdf.cpp
  6. 2
      generators/poppler/generator_pdf.h

@ -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

@ -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.

@ -223,7 +223,7 @@ Generator::PageSizeMetric Generator::pagesSizeMetric() const
return None;
}
bool Generator::isAllowed( Permissions ) const
bool Generator::isAllowed( Permission ) const
{
return true;
}

@ -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.

@ -591,13 +591,25 @@ const QList<Okular::EmbeddedFile*> *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;
}

@ -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;

Loading…
Cancel
Save