fs_pdfform.h
Go to the documentation of this file.
1 
15 #ifndef FS_PDFFORM_H_
16 #define FS_PDFFORM_H_
17 
18 #include "common/fs_common.h"
19 #include "fdf/fs_fdfdoc.h"
20 #include "pdf/fs_pdfdoc.h"
21 #include "pdf/fs_pdfpage.h"
24 
30 namespace foxit {
34 namespace pdf {
38 namespace interform {
39 // forward declaration
40 class Control;
41 class Field;
42 
44 FSDK_DEFINE_ARRAY(FieldArray,Field)
45 
46 
47 class ChoiceOption FS_FINAL : public Object {
48  public:
51  : option_value(WString())
52  , option_label(WString())
53  , selected(false)
54  , default_selected(false) {}
55 
66  ChoiceOption(const wchar_t* option_value, const wchar_t* option_label, bool selected, bool default_selected)
67  : option_value(option_value)
68  , option_label(option_label)
69  , selected(selected)
70  , default_selected(default_selected) {}
71 
77  ChoiceOption(const ChoiceOption& option)
78  : option_value(option.option_value)
79  , option_label(option.option_label)
80  , selected(option.selected)
81  , default_selected(option.default_selected) {}
82 
90  ChoiceOption& operator = (const ChoiceOption& option) {
91  option_value = option.option_value;
92  option_label = option.option_label;
93  selected = option.selected;
94  default_selected = option.default_selected;
95  return *this;
96  }
97 
110  void Set(const wchar_t* option_value, const wchar_t* option_label, bool selected, bool default_selected) {
111  this->option_value = option_value;
112  this->option_label = option_label;
113  this->selected = selected;
114  this->default_selected = default_selected;
115  }
118 
121 
123  bool selected;
124 
127 };
128 
130 FSDK_DEFINE_ARRAY(ChoiceOptionArray, ChoiceOption)
131 
132 
145 class Field : public Base {
146  public:
152  typedef enum _Type {
154  e_TypeUnknown = 0,
156  e_TypePushButton = 1,
158  e_TypeCheckBox = 2,
160  e_TypeRadioButton = 3,
162  e_TypeComboBox = 4,
164  e_TypeListBox = 5,
166  e_TypeTextField = 6,
168  e_TypeSignature = 7
169  } Type;
170 
176  typedef enum _Flags {
183  e_FlagReadOnly = 0x01,
185  e_FlagRequired = 0x02,
187  e_FlagNoExport = 0x04,
193  e_FlagButtonNoToggleToOff = 0x100,
199  e_FlagButtonRadiosInUnison = 0x200,
204  e_FlagTextMultiline = 0x100,
213  e_FlagTextPassword = 0x200,
219  e_FlagTextDoNotScroll = 0x400,
226  e_FlagTextComb = 0x800,
231  e_FlagComboEdit = 0x100,
236  e_FlagChoiseMultiSelect = 0x100
237  } Flags;
238 
239 
247  Field(const PDFDoc& document, objects::PDFDictionary* field_dict);
248 
254  Field(const Field& field);
262  Field& operator = (const Field& other);
263 
271  bool operator == (const Field& other) const;
279  bool operator != (const Field& other) const;
280 
282  ~Field();
283 
291  bool IsEmpty() const;
292 
299  Type GetType() const;
300 
309  uint32 GetFlags() const;
310 
321  void SetFlags(uint32 flags);
322 
328  WString GetName() const;
329 
338  WString GetDefaultValue() const;
339 
350  void SetDefualtValue(const wchar_t* value);
351 
361  WString GetValue() const;
362 
388  void SetValue(const wchar_t* value);
389 
402  common::Alignment GetAlignment() const;
403 
420  void SetAlignment(common::Alignment alignment);
421 
432  WString GetAlternateName() const;
433 
447  void SetAlternateName(const wchar_t* alternate_name);
448 
454  DefaultAppearance GetDefaultAppearance() const;
455 
465  void SetDefaultAppearance(const DefaultAppearance& default_ap);
466 
474  WString GetMappingName() const;
475 
486  void SetMappingName(const wchar_t* name);
487 
495  int GetMaxLength() const;
496 
506  void SetMaxLength(int max_length);
507 
516  ChoiceOptionArray GetOptions() const;
517 
528  void SetOptions(const ChoiceOptionArray& option_array);
529 
539  int GetTopVisibleIndex();
540 
552  void SetTopVisibleIndex(int index);
553 
559  int GetControlCount() const;
560 
569  Control GetControl(int index);
570 
578  int GetControlCount(const foxit::pdf::PDFPage& page) const;
579 
590  Control GetControl(const foxit::pdf::PDFPage& page, int index);
591 
597  bool Reset();
598 
604  objects::PDFDictionary* GetDict() const;
613  objects::PDFObject* GetValueObj() const;
614 
623  objects::PDFObject* GetDefaultValueObj() const;
634  objects::PDFObject* GetInheritedAttribute(const char* attribute_name) const;
635 
636  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
637  explicit Field(FS_HANDLE handle = NULL);
638 };
639 
665 class Form FS_FINAL : public Base {
666  public:
675  explicit Form(const pdf::PDFDoc& document);
681  Form(const Form& other);
689  Form& operator = (const Form& other);
690 
698  bool operator == (const Form& other) const;
706  bool operator != (const Form& other) const;
707 
709  ~Form();
710 
718  bool IsEmpty() const;
719 
732 
747  void SetAlignment(common::Alignment alignment);
748 
754  bool NeedConstructAppearances() const;
755 
764  void SetConstructAppearances(bool need_construct);
765 
784  Control GetControlAtDevicePoint(const PDFPage& page, const PointF& point, float tolerance, Field::Type type,
785  const Matrix* matrix = NULL);
786 
801  Control GetControlAtPoint(const PDFPage& page, const PointF& point, float tolerance, Field::Type type);
802 
809 
819  void SetDefaultAppearance(const DefaultAppearance& default_ap);
820 
826  PDFDoc GetDocument() const;
827 
837 
848  void SetFieldsInCalculationOrder(const FieldArray& field_array);
849 
862  bool ValidateFieldName(Field::Type type, const WString& field_name);
863 
872  bool RenameField(Field& field, const wchar_t* new_field_name);
873 
919  Control AddControl(const PDFPage& page, const wchar_t* field_name, Field::Type field_type, const RectF& rect);
920 
933  void RemoveField(Field& field);
934 
946  void RemoveControl(Control& control);
947 
960  int GetFieldCount(const wchar_t* filter = NULL) const;
961 
977  Field GetField(int index, const wchar_t* filter = NULL);
978 
986  int GetControlCount(const PDFPage& page) const;
987 
998  Control GetControl(const PDFPage& page, int index);
999 
1007  Filler GetFormFiller() const;
1008 
1014  bool Reset();
1015 
1024  bool ExportToXML(const char* file_path);
1025 
1034  bool ImportFromXML(const char* file_path);
1035 
1042 
1043  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
1044  explicit Form(FS_HANDLE handle = NULL);
1045 };
1046 
1062 class Control FS_FINAL : public Base {
1063  public:
1069  Control(const Control& other);
1077  Control& operator = (const Control& other);
1078 
1086  bool operator == (const Control& other) const;
1094  bool operator != (const Control& other) const;
1095 
1097  ~Control();
1098 
1106  bool IsEmpty() const;
1107 
1113  Field GetField() const;
1114 
1120  annots::Widget GetWidget() const;
1121 
1127  int GetIndex() const;
1128 
1137  WString GetExportValue() const;
1138 
1149  void SetExportValue(const wchar_t* value);
1150 
1159  bool IsChecked() const;
1160 
1171  void SetChecked(bool checked);
1172 
1182  bool IsDefaultChecked() const;
1183 
1194  void SetDefaultChecked(bool checked);
1195 
1196  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
1197  explicit Control(FS_HANDLE handle = NULL);
1198 
1199 };
1200 } // namespace interform
1201 } // namespace pdf
1202 } // namespace foxit
1203 #endif // FS_PDFFORM_H_
1204 
Control GetControl(const PDFPage &page, int index)
Get a form control by index, in a specified PDF page.
int GetIndex() const
Get the index of current form control among all the controls of related form field.
void Set(const wchar_t *option_value, const wchar_t *option_label, bool selected, bool default_selected)
Set value.
Definition: fs_pdfform.h:110
DefaultAppearance GetDefaultAppearance() const
Get the default appearance data.
bool IsEmpty() const
Check whether current object is empty or not.
Filler GetFormFiller() const
Get the form filler.
CFX_Object Object
Object type.
Definition: fs_basictypes.h:216
Header file for form filler related definitions and classes.
common::Alignment GetAlignment() const
Get the alignment value which is used as document-wide default value.
void SetExportValue(const wchar_t *value)
Set export mapping name when related form field is check box or radio button.
bool IsDefaultChecked() const
Check if the current form control is checked by default when related form field is check box or radio...
Header file for FDF doucument related definitions and classes.
Header file for PDF document related definitions and classes.
bool default_selected
Used to indicate whether the option would be selected by default or not.
Definition: fs_pdfform.h:126
Definition: fs_formfiller.h:156
Control GetControlAtDevicePoint(const PDFPage &page, const PointF &point, float tolerance, Field::Type type, const Matrix *matrix=0)
Get the form control at a specified position, in device coordination system.
bool operator!=(const Control &other) const
Not equal operator.
ChoiceOption(const wchar_t *option_value, const wchar_t *option_label, bool selected, bool default_selected)
Constructor, with parameters.
Definition: fs_pdfform.h:66
bool operator!=(const Form &other) const
Not equal operator.
Definition: fs_annot.h:51
Definition: fs_annot.h:4113
WIDE STRING CLASS.
Definition: fx_string.h:1463
Form & operator=(const Form &other)
Assign operator.
void SetDefaultAppearance(const DefaultAppearance &default_ap)
Set default appearance data.
Definition: fs_pdfdoc.h:338
Definition: fs_pdfform.h:665
Definition: fs_pdfform.h:1062
bool RenameField(Field &field, const wchar_t *new_field_name)
Rename a field with a new name.
void SetDefaultChecked(bool checked)
Set the default check state of current form control when related form field is check box or radio but...
bool operator==(const char *str1, const CFX_ByteString &str2)
Check if two byte strings are equal.
Definition: fs_basictypes.h:125
bool Reset()
Reset data of all fields (except signature fields) to their default value.
Control GetControlAtPoint(const PDFPage &page, const PointF &point, float tolerance, Field::Type type)
Get the form control at a specified position, in PDF coordinate system.
void SetChecked(bool checked)
Set the check state of current form control when related form field is check box or radio button.
void RemoveField(Field &field)
Remove a form field. (Not support signature field)
void SetFieldsInCalculationOrder(const FieldArray &field_array)
Set an array of form fields in calculation order.
Control & operator=(const Control &other)
Assign operator.
WString GetExportValue() const
Get export mapping name when related form field is check box or radio button.
CFX_PointF PointF
Point information, in float.
Definition: fs_basictypes.h:353
bool NeedConstructAppearances() const
Check whether to construct appearance when loading form controls.
WString option_value
The option string value.
Definition: fs_pdfform.h:117
ChoiceOption()
Constructor.
Definition: fs_pdfform.h:50
bool IsChecked() const
Check if the current form control is checked when related form field is check box or radio button.
FieldArray GetFieldsInCalculationOrder()
Get an array of form fields in calculation order.
Field GetField() const
Get the related form field.
Definition: fs_pdfform.h:145
bool operator==(const Form &other) const
Equal operator.
bool ImportFromXML(const char *file_path)
Import the form data from an XML file.
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:195
Definition: fs_pdfpage.h:306
void SetConstructAppearances(bool need_construct)
Set a flag that specifies whether to construct appearances when loading form controls.
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:213
bool selected
Used to indicate whether the option is selected or not.
Definition: fs_pdfform.h:123
Header file for common definitions and classes.
void SetAlignment(common::Alignment alignment)
Set alignment value which is used as document-wide default value.
bool IsEmpty() const
Check whether current object is empty or not.
Alignment
Enumeration for alignment (horizontal).
Definition: fs_common.h:237
Header file for PDF object related definitions and classes.
Control AddControl(const PDFPage &page, const wchar_t *field_name, Field::Type field_type, const RectF &rect)
Add a new form control to a specified form field. If the form field does not exist,...
Definition: fs_basictypes.h:333
annots::Widget GetWidget() const
Get the related widget annotation.
Header file for PDF page related definitions and classes.
Definition: fs_pdfobject.h:762
ChoiceOption(const ChoiceOption &option)
Constructor, with another ChoiceOption object.
Definition: fs_pdfform.h:77
bool ExportToXML(const char *file_path)
Export the form data to an XML file.
Foxit namespace.
Definition: fs_connectedpdf.h:26
Definition: fs_pdfobject.h:55
Type
Enumeration for form field type.
Definition: fs_pdfform.h:152
WString option_label
The displayed string value for the option.
Definition: fs_pdfform.h:120
Definition: fs_pdfform.h:47
Definition: fs_pdfform.h:44
void RemoveControl(Control &control)
Remove a form control. (Not support to remove a form control from a signature field)
Form(const pdf::PDFDoc &document)
Constructor, with PDF document.
objects::PDFDictionary * GetDict() const
Get the dictionary of current object.
#define NULL
The null-pointer value.
Definition: fx_system.h:767
PDFDoc GetDocument() const
Get the PDF document, with which current form object is associated.
bool operator!=(const char *str1, const CFX_ByteString &str2)
Check if two byte strings are not equal.
Definition: fs_basictypes.h:137
int GetFieldCount(const wchar_t *filter=0) const
Get the count of form fields, whose names satisfy the specified name filter.
Definition: fx_coordinates.h:914
bool operator==(const Control &other) const
Equal operator.
Control(const Control &other)
Constructor, with another Control object.
Definition: fs_pdfform.h:130
Field GetField(int index, const wchar_t *filter=0)
Get a form field by index, whose names satisfy the specified name filter.
int GetControlCount(const PDFPage &page) const
Get count of form controls in a specified PDF page.
Definition: fx_coordinates.h:627
bool ValidateFieldName(Field::Type type, const WString &field_name)
Validate whether a field name can be used for a new field in specified field type.

Foxit Software Corporation Logo
@2018 Foxit Software Incorporated. All rights reserved.