Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_interactiveform.h
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef CORE_FPDFDOC_CPDF_INTERACTIVEFORM_H_
8#define CORE_FPDFDOC_CPDF_INTERACTIVEFORM_H_
9
10#include <stddef.h>
11#include <stdint.h>
12
13#include <functional>
14#include <map>
15#include <memory>
16#include <vector>
17
18#include "core/fpdfapi/parser/cpdf_dictionary.h"
19#include "core/fpdfapi/parser/fpdf_parser_decode.h"
20#include "core/fpdfdoc/cpdf_defaultappearance.h"
21#include "core/fpdfdoc/cpdf_formfield.h"
22#include "core/fxcrt/fx_coordinates.h"
23#include "core/fxcrt/fx_string.h"
24#include "core/fxcrt/retain_ptr.h"
25#include "core/fxcrt/unowned_ptr.h"
26#include "third_party/base/containers/span.h"
27
28class CFieldTree;
29class CFDF_Document;
30class CPDF_Document;
31class CPDF_Font;
33class CPDF_Page;
34
36 public:
38 public:
39 virtual ~NotifierIface() = default;
40
41 virtual bool BeforeValueChange(CPDF_FormField* pField,
42 const WideString& csValue) = 0;
43 virtual void AfterValueChange(CPDF_FormField* pField) = 0;
45 const WideString& csValue) = 0;
46 virtual void AfterSelectionChange(CPDF_FormField* pField) = 0;
47 virtual void AfterCheckedStatusChange(CPDF_FormField* pField) = 0;
48 virtual void AfterFormReset(CPDF_InteractiveForm* pForm) = 0;
49 };
50
51 explicit CPDF_InteractiveForm(CPDF_Document* pDocument);
53
54 static bool IsUpdateAPEnabled();
55 static void SetUpdateAP(bool bUpdateAP);
57 CPDF_Document* pDocument,
58 ByteString* csNameTag);
59
60 size_t CountFields(const WideString& csFieldName) const;
61 CPDF_FormField* GetField(size_t index, const WideString& csFieldName) const;
62 CPDF_FormField* GetFieldByDict(const CPDF_Dictionary* pFieldDict) const;
63
64 const CPDF_FormControl* GetControlAtPoint(const CPDF_Page* pPage,
65 const CFX_PointF& point,
66 int* z_order) const;
67 CPDF_FormControl* GetControlByDict(const CPDF_Dictionary* pWidgetDict) const;
68
69 bool NeedConstructAP() const;
73
74 RetainPtr<CPDF_Font> GetFormFont(ByteString csNameTag) const;
76 RetainPtr<CPDF_Dictionary> pElement) const;
78 int GetFormAlignment() const;
79 bool CheckRequiredFields(const std::vector<CPDF_FormField*>* fields,
80 bool bIncludeOrExclude) const;
81
82 std::unique_ptr<CFDF_Document> ExportToFDF(const WideString& pdf_path) const;
84 const WideString& pdf_path,
85 const std::vector<CPDF_FormField*>& fields,
86 bool bIncludeOrExclude) const;
87
88 void ResetForm();
89 void ResetForm(pdfium::span<CPDF_FormField*> fields, bool bIncludeOrExclude);
90
91 void SetNotifierIface(NotifierIface* pNotify);
92 void FixPageFields(CPDF_Page* pPage);
93
94 // Wrap callbacks thru NotifierIface.
96 const WideString& csValue);
99 const WideString& csValue);
102
104 const CPDF_FormField* pField);
105
106 private:
107 void LoadField(RetainPtr<CPDF_Dictionary> pFieldDict, int nLevel);
108 void AddTerminalField(RetainPtr<CPDF_Dictionary> pFieldDict);
109 CPDF_FormControl* AddControl(CPDF_FormField* pField,
110 RetainPtr<CPDF_Dictionary> pWidgetDict);
111
112 static bool s_bUpdateAP;
113
114 ByteString m_bsEncoding;
115 UnownedPtr<CPDF_Document> const m_pDocument;
116 RetainPtr<CPDF_Dictionary> m_pFormDict;
117 std::unique_ptr<CFieldTree> m_pFieldTree;
120 std::less<>>
122 // Points into |m_ControlMap|.
125 std::less<>>
127 UnownedPtr<NotifierIface> m_pFormNotify;
128};
129
130#endif // CORE_FPDFDOC_CPDF_INTERACTIVEFORM_H_
constexpr CFX_FloatRect(float l, float b, float r, float t)
float Width() const
float Height() const
void Translate(float e, float f)
CPDF_Annot * GetAt(size_t index) const
size_t Count() const
bool Contains(const CPDF_Annot *pAnnot) const
void DisplayAnnots(CPDF_Page *pPage, CFX_RenderDevice *pDevice, CPDF_RenderContext *pContext, bool bPrinting, const CFX_Matrix &mtUser2Device, bool bShowWidget)
~CPDF_AnnotList() override
CPDF_AnnotList(CPDF_Page *pPage)
Subtype GetSubtype() const
const CPDF_Dictionary * GetAnnotDict() const
Definition cpdf_annot.h:83
void SetPopupAnnot(CPDF_Annot *pAnnot)
Definition cpdf_annot.h:103
bool KeyExist(const ByteString &key) const
ByteString GetByteStringFor(const ByteString &key) const
CFX_FloatRect GetRectFor(const ByteString &key) const
RetainPtr< const CPDF_Object > GetFieldAttr(const ByteString &name) const
int GetSelectedIndex(int index) const
bool IsSelectedIndex(int iOptIndex) const
bool UseSelectedIndicesObject() const
static WideString GetFullNameForDict(const CPDF_Dictionary *pFieldDict)
int CountOptions() const
int GetDefaultSelectedItem() const
bool IsSelectedOption(const WideString &wsOptValue) const
void SelectOption(int iOptIndex)
WideString GetMappingName() const
WideString GetValue() const
WideString GetFullName() const
static RetainPtr< const CPDF_Object > GetFieldAttrForDict(const CPDF_Dictionary *pFieldDict, const ByteString &name)
int CountControls() const
int FindOption(const WideString &csOptValue) const
uint32_t GetFieldFlags() const
bool IsRequired() const
WideString GetAlternateName() const
bool ClearSelection(NotificationOption notify)
int GetControlIndex(const CPDF_FormControl *pControl) const
int GetSelectedOptionIndex(int index) const
bool SetItemSelection(int index, NotificationOption notify)
int GetMaxLen() const
bool IsItemSelected(int index) const
static RetainPtr< CPDF_Object > GetMutableFieldAttrForDict(CPDF_Dictionary *pFieldDict, const ByteString &name)
WideString GetOptionLabel(int index) const
static absl::optional< FormFieldType > IntToFormFieldType(int value)
bool IsNoExport() const
int CountSelectedOptions() const
int CountSelectedItems() const
WideString GetCheckValue(bool bDefault) const
CPDF_FormControl * GetControl(int index) const
int GetTopVisibleIndex() const
Type GetType() const
FormFieldType GetFieldType() const
WideString GetOptionValue(int index) const
CPDF_AAction GetAdditionalAction() const
RetainPtr< const CPDF_Dictionary > GetFieldDict() const
WideString GetDefaultValue() const
CPDF_FormField(CPDF_InteractiveForm *pForm, RetainPtr< CPDF_Dictionary > pDict)
bool CheckControl(int iControlIndex, bool bChecked, NotificationOption notify)
void SetFieldFlags(uint32_t dwFlags)
bool SetValue(const WideString &value, NotificationOption notify)
static void GenerateFormAP(CPDF_Document *pDoc, CPDF_Dictionary *pAnnotDict, FormType type)
virtual bool BeforeSelectionChange(CPDF_FormField *pField, const WideString &csValue)=0
virtual void AfterCheckedStatusChange(CPDF_FormField *pField)=0
virtual bool BeforeValueChange(CPDF_FormField *pField, const WideString &csValue)=0
virtual void AfterValueChange(CPDF_FormField *pField)=0
virtual void AfterFormReset(CPDF_InteractiveForm *pForm)=0
virtual void AfterSelectionChange(CPDF_FormField *pField)=0
RetainPtr< CPDF_Font > GetFontForElement(RetainPtr< CPDF_Dictionary > pElement) const
CPDF_FormField * GetFieldInCalculationOrder(int index)
bool NotifyBeforeSelectionChange(CPDF_FormField *pField, const WideString &csValue)
bool NotifyBeforeValueChange(CPDF_FormField *pField, const WideString &csValue)
void SetNotifierIface(NotifierIface *pNotify)
static void SetUpdateAP(bool bUpdateAP)
bool CheckRequiredFields(const std::vector< CPDF_FormField * > *fields, bool bIncludeOrExclude) const
size_t CountFields(const WideString &csFieldName) const
std::unique_ptr< CFDF_Document > ExportToFDF(const WideString &pdf_path) const
const CPDF_FormControl * GetControlAtPoint(const CPDF_Page *pPage, const CFX_PointF &point, int *z_order) const
std::unique_ptr< CFDF_Document > ExportToFDF(const WideString &pdf_path, const std::vector< CPDF_FormField * > &fields, bool bIncludeOrExclude) const
void NotifyAfterSelectionChange(CPDF_FormField *pField)
CPDF_InteractiveForm(CPDF_Document *pDocument)
void NotifyAfterValueChange(CPDF_FormField *pField)
int FindFieldInCalculationOrder(const CPDF_FormField *pField)
CPDF_FormControl * GetControlByDict(const CPDF_Dictionary *pWidgetDict) const
void FixPageFields(CPDF_Page *pPage)
static RetainPtr< CPDF_Font > AddNativeInteractiveFormFont(CPDF_Document *pDocument, ByteString *csNameTag)
CPDF_FormField * GetField(size_t index, const WideString &csFieldName) const
const std::vector< UnownedPtr< CPDF_FormControl > > & GetControlsForField(const CPDF_FormField *pField)
CPDF_DefaultAppearance GetDefaultAppearance() const
CPDF_FormField * GetFieldByDict(const CPDF_Dictionary *pFieldDict) const
void ResetForm(pdfium::span< CPDF_FormField * > fields, bool bIncludeOrExclude)
RetainPtr< CPDF_Font > GetFormFont(ByteString csNameTag) const
void NotifyAfterCheckedStatusChange(CPDF_FormField *pField)
float GetPageWidth() const override
Definition cpdf_page.cpp:55
bool operator==(const char *ptr) const
bool operator!=(const char *ptr) const
Definition bytestring.h:130
NotificationOption
FormFieldType
constexpr size_t kFormFieldTypeCount
constexpr uint32_t kChoiceDoNotSpellCheck
Definition form_flags.h:40
constexpr uint32_t kReadOnly
Definition form_flags.h:13
constexpr uint32_t kChoiceEdit
Definition form_flags.h:37
constexpr uint32_t kButtonPushbutton
Definition form_flags.h:21
constexpr uint32_t kTextFileSelect
Definition form_flags.h:28
constexpr uint32_t kButtonRadiosInUnison
Definition form_flags.h:22
constexpr uint32_t kChoiceSort
Definition form_flags.h:38
constexpr uint32_t kChoiceCombo
Definition form_flags.h:36
constexpr uint32_t kTextPassword
Definition form_flags.h:27
constexpr uint32_t kTextDoNotSpellCheck
Definition form_flags.h:29
constexpr uint32_t kRequired
Definition form_flags.h:14
constexpr uint32_t kButtonNoToggleToOff
Definition form_flags.h:19
constexpr uint32_t kChoiceCommitOnSelChange
Definition form_flags.h:41
constexpr uint32_t kButtonRadio
Definition form_flags.h:20
constexpr uint32_t kChoiceMultiSelect
Definition form_flags.h:39
constexpr uint32_t kNoExport
Definition form_flags.h:15
constexpr uint32_t kTextDoNotScroll
Definition form_flags.h:30
constexpr uint32_t kTextRichText
Definition form_flags.h:32
constexpr uint32_t kTextComb
Definition form_flags.h:31
constexpr uint32_t kTextMultiline
Definition form_flags.h:26