Poppler Qt5  0.74.0
poppler-form.h
1 /* poppler-form.h: qt interface to poppler
2  * Copyright (C) 2007-2008, Pino Toscano <pino@kde.org>
3  * Copyright (C) 2008, 2011, 2016, 2017, 2019, Albert Astals Cid <aacid@kde.org>
4  * Copyright (C) 2012, Adam Reichold <adamreichold@myopera.com>
5  * Copyright (C) 2016, Hanno Meyer-Thurow <h.mth@web.de>
6  * Copyright (C) 2017, Hans-Ulrich Jüttner <huj@froreich-bioscientia.de>
7  * Copyright (C) 2017, Tobias C. Berner <tcberner@freebsd.org>
8  * Copyright (C) 2018, Andre Heinecke <aheinecke@intevation.de>
9  * Copyright (C) 2018, Chinmoy Ranjan Pradhan <chinmoyrp65@protonmail.com>
10  * Copyright (C) 2018, Oliver Sander <oliver.sander@tu-dresden.de>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
25  */
26 
27 #ifndef _POPPLER_QT5_FORM_H_
28 #define _POPPLER_QT5_FORM_H_
29 
30 #include <time.h>
31 #include <QtCore/QDateTime>
32 #include <QtCore/QList>
33 #include <QtCore/QRectF>
34 #include <QtCore/QStringList>
35 #include <QtCore/QSharedPointer>
36 #include "poppler-export.h"
37 #include "poppler-annotation.h"
38 
39 class Page;
40 class FormWidget;
41 class FormWidgetButton;
42 class FormWidgetText;
43 class FormWidgetChoice;
44 class FormWidgetSignature;
45 
46 namespace Poppler {
47 
48  class DocumentData;
49  class Link;
50 
51  class FormFieldData;
57  class POPPLER_QT5_EXPORT FormField {
58  public:
59 
63  enum FormType {
67  FormSignature
68  };
69 
70  virtual ~FormField();
71 
75  virtual FormType type() const = 0;
76 
81  QRectF rect() const;
82 
86  int id() const;
87 
91  QString name() const;
92 
97  void setName(const QString &name) const;
98 
103  QString fullyQualifiedName() const;
104 
109  QString uiName() const;
110 
114  bool isReadOnly() const;
115 
120  void setReadOnly(bool value);
121 
125  bool isVisible() const;
126 
131  void setVisible(bool value);
132 
138  Link* activationAction() const;
139 
146  {
151  };
157  Link* additionalAction(AdditionalActionType type) const;
158 
164  Link* additionalAction(Annotation::AdditionalActionType type) const;
165 
166  protected:
168  FormField(FormFieldData &dd);
169 
170  FormFieldData *m_formData;
172 
173  private:
174  Q_DISABLE_COPY(FormField)
175  };
176 
182  class POPPLER_QT5_EXPORT FormFieldButton : public FormField {
183  public:
184 
189  {
192  Radio
193  };
194 
196  FormFieldButton(DocumentData *doc, ::Page *p, ::FormWidgetButton *w);
198  ~FormFieldButton();
199 
200  FormType type() const override;
201 
205  ButtonType buttonType() const;
206 
210  QString caption() const;
211 
215  bool state() const;
216 
220  void setState( bool state );
221 
228  QList<int> siblings() const;
229 
230  private:
231  Q_DISABLE_COPY(FormFieldButton)
232  };
233 
239  class POPPLER_QT5_EXPORT FormFieldText : public FormField {
240  public:
241 
245  enum TextType {
248  FileSelect
249  };
250 
252  FormFieldText(DocumentData *doc, ::Page *p, ::FormWidgetText *w);
254  ~FormFieldText();
255 
256  FormType type() const override;
257 
261  TextType textType() const;
262 
266  QString text() const;
267 
272  void setText( const QString& text );
273 
280  bool isPassword() const;
281 
285  bool isRichText() const;
286 
290  int maximumLength() const;
291 
295  Qt::Alignment textAlignment() const;
296 
301  bool canBeSpellChecked() const;
302 
306  double getFontSize() const;
307 
311  void setFontSize(int fontSize);
312 
313  private:
314  Q_DISABLE_COPY(FormFieldText)
315  };
316 
322  class POPPLER_QT5_EXPORT FormFieldChoice : public FormField {
323  public:
324 
328  enum ChoiceType {
330  ListBox
331  };
332 
334  FormFieldChoice(DocumentData *doc, ::Page *p, ::FormWidgetChoice *w);
336  ~FormFieldChoice();
337 
338  FormType type() const override;
339 
343  ChoiceType choiceType() const;
344 
348  QStringList choices() const;
349 
356  bool isEditable() const;
357 
364  bool multiSelect() const;
365 
369  QList<int> currentChoices() const;
370 
374  void setCurrentChoices( const QList<int> &choice );
375 
381  QString editChoice() const;
382 
388  void setEditChoice(const QString& text);
389 
393  Qt::Alignment textAlignment() const;
394 
401  bool canBeSpellChecked() const;
402 
403  private:
404  Q_DISABLE_COPY(FormFieldChoice)
405  };
406 
412  class CertificateInfoPrivate;
413  class POPPLER_QT5_EXPORT CertificateInfo {
414  public:
415 
420  {
421  RsaKey,
422  DsaKey,
423  EcKey,
424  OtherKey
425  };
426 
431  {
432  KuDigitalSignature = 0x80,
433  KuNonRepudiation = 0x40,
434  KuKeyEncipherment = 0x20,
435  KuDataEncipherment = 0x10,
436  KuKeyAgreement = 0x08,
437  KuKeyCertSign = 0x04,
438  KuClrSign = 0x02,
439  KuEncipherOnly = 0x01,
440  KuNone = 0x00
441  };
442  Q_DECLARE_FLAGS(KeyUsageExtensions, KeyUsageExtension)
443 
444 
448  {
449  CommonName,
450  DistinguishedName,
451  EmailAddress,
452  Organization,
453  };
454 
455  CertificateInfo(CertificateInfoPrivate *priv);
456  ~CertificateInfo();
457 
461  bool isNull() const;
462 
466  int version() const;
467 
471  QByteArray serialNumber() const;
472 
476  QString issuerInfo(EntityInfoKey key) const;
477 
481  QString subjectInfo(EntityInfoKey key) const;
482 
486  QDateTime validityStart() const;
487 
491  QDateTime validityEnd() const;
492 
496  KeyUsageExtensions keyUsageExtensions() const;
497 
501  QByteArray publicKey() const;
502 
506  PublicKeyType publicKeyType() const;
507 
511  int publicKeyStrength() const;
512 
516  bool isSelfSigned() const;
517 
521  QByteArray certificateData() const;
522 
523  CertificateInfo(const CertificateInfo &other);
524  CertificateInfo &operator=(const CertificateInfo &other);
525 
526  private:
527  Q_DECLARE_PRIVATE(CertificateInfo)
528 
529  QSharedPointer<CertificateInfoPrivate> d_ptr;
530  };
531  Q_DECLARE_OPERATORS_FOR_FLAGS(CertificateInfo::KeyUsageExtensions)
532 
533 
538  class SignatureValidationInfoPrivate;
539  class POPPLER_QT5_EXPORT SignatureValidationInfo {
540  public:
541 
552  SignatureNotVerified
553  };
554 
565  CertificateNotVerified
566  };
567 
573  {
574  HashAlgorithmUnknown,
575  HashAlgorithmMd2,
576  HashAlgorithmMd5,
577  HashAlgorithmSha1,
578  HashAlgorithmSha256,
579  HashAlgorithmSha384,
580  HashAlgorithmSha512,
581  HashAlgorithmSha224
582  };
583 
585  SignatureValidationInfo(SignatureValidationInfoPrivate *priv);
588 
592  SignatureStatus signatureStatus() const;
593 
597  CertificateStatus certificateStatus() const;
598 
602  QString signerName() const;
603 
608  QString signerSubjectDN() const;
609 
614  QString location() const;
615 
620  QString reason() const;
621 
626  HashAlgorithm hashAlgorithm() const;
627 
631  time_t signingTime() const;
632 
637  QByteArray signature() const;
638 
643  QList<qint64> signedRangeBounds() const;
644 
650  bool signsTotalDocument() const;
651 
656  CertificateInfo certificateInfo() const;
657 
659  SignatureValidationInfo &operator=(const SignatureValidationInfo &other);
660 
661  private:
662  Q_DECLARE_PRIVATE(SignatureValidationInfo)
663 
664  QSharedPointer<SignatureValidationInfoPrivate> d_ptr;
665  };
666 
672  class POPPLER_QT5_EXPORT FormFieldSignature : public FormField {
673  public:
674 
680  AdbePkcs7sha1,
681  AdbePkcs7detached,
682  EtsiCAdESdetached
683  };
684 
689  ValidateVerifyCertificate = 1,
690  ValidateForceRevalidation = 2,
691  };
692 
694  FormFieldSignature(DocumentData *doc, ::Page *p, ::FormWidgetSignature *w);
697 
698  FormType type() const override;
699 
704  SignatureType signatureType() const;
705 
711  SignatureValidationInfo validate(ValidateOptions opt) const;
712 
720  SignatureValidationInfo validate(int opt, const QDateTime& validationTime) const;
721 
722  private:
723  Q_DISABLE_COPY(FormFieldSignature)
724  };
725 
726 }
727 
728 #endif
TextType
The particular type of this text field.
Definition: poppler-form.h:245
A form field that represents a choice field.
Definition: poppler-form.h:322
A simple push button.
Definition: poppler-form.h:190
A JavaScript action to be performed before the field is formatted to display its value.
Definition: poppler-form.h:148
The certificate could not be verified.
Definition: poppler-form.h:564
A simple singleline text field.
Definition: poppler-form.h:246
A JavaScript action to be performed when the user modifies the field.
Definition: poppler-form.h:147
A JavaScript action to be performed when the field needs to be recalculated.
Definition: poppler-form.h:150
The signature is cryptographically invalid.
Definition: poppler-form.h:547
EntityInfoKey
Predefined keys for elements in an entity's distinguished name.
Definition: poppler-form.h:447
The document content was changed after the signature was applied.
Definition: poppler-form.h:548
The base class representing a form field.
Definition: poppler-form.h:57
A check box.
Definition: poppler-form.h:191
CertificateStatus
The verification result of the certificate.
Definition: poppler-form.h:558
A text field. See TextType.
Definition: poppler-form.h:65
A page in a document.
Definition: poppler-qt5.h:409
A button field. See ButtonType.
Definition: poppler-form.h:64
The certificate trust chain has not finished in a trusted root certificate.
Definition: poppler-form.h:561
A simple singleline text field.
Definition: poppler-form.h:329
AdditionalActionType
Describes the flags from the form 'AA' dictionary.
Definition: poppler-form.h:145
ButtonType
The types of button field.
Definition: poppler-form.h:188
KeyUsageExtension
Certificate key usage extensions.
Definition: poppler-form.h:430
A form field that represents a signature.
Definition: poppler-form.h:672
A JavaScript action to be performed when the field value changes.
Definition: poppler-form.h:149
SignatureStatus
The verification result of the signature.
Definition: poppler-form.h:545
AdditionalActionType
Describes the flags from an annotations 'AA' dictionary.
Definition: poppler-annotation.h:412
A form field that represents a text input.
Definition: poppler-form.h:239
A multiline text field.
Definition: poppler-form.h:247
Definition: poppler-form.h:539
The signature could not be verified.
Definition: poppler-form.h:550
The signature is cryptographically valid.
Definition: poppler-form.h:546
The requested signature is not present in the document.
Definition: poppler-form.h:551
PublicKeyType
The algorithm of public key.
Definition: poppler-form.h:419
The certificate was revoked by the issuing certificate authority.
Definition: poppler-form.h:562
A single choice field. See ChoiceType.
Definition: poppler-form.h:66
The Poppler Qt5 binding.
Definition: poppler-annotation.h:45
FormType
The different types of form field.
Definition: poppler-form.h:63
A form field that represents a "button".
Definition: poppler-form.h:182
The issuer of this certificate has been marked as untrusted by the user.
Definition: poppler-form.h:560
HashAlgorithm
The hash algorithm of the signature.
Definition: poppler-form.h:572
The signature CMS/PKCS7 structure is malformed.
Definition: poppler-form.h:549
ChoiceType
The particular type of this choice field.
Definition: poppler-form.h:328
ValidateOptions
The validation options of this signature.
Definition: poppler-form.h:688
SignatureType
The types of signature fields.
Definition: poppler-form.h:679
The signing time is outside the validity bounds of this certificate.
Definition: poppler-form.h:563
Definition: poppler-form.h:413
The certificate is considered trusted.
Definition: poppler-form.h:559