#include "fpdfsdk/cpdfsdk_interactiveform.h"
#include <stdint.h>
#include <algorithm>
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
#include "constants/annotation_flags.h"
#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/parser/cfdf_document.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfdoc/cpdf_action.h"
#include "core/fpdfdoc/cpdf_formcontrol.h"
#include "core/fpdfdoc/cpdf_interactiveform.h"
#include "core/fxcrt/autorestorer.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/fx_string_wrappers.h"
#include "core/fxcrt/stl_util.h"
#include "core/fxge/cfx_graphstatedata.h"
#include "core/fxge/cfx_path.h"
#include "fpdfsdk/cpdfsdk_annot.h"
#include "fpdfsdk/cpdfsdk_annotiterator.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_pageview.h"
#include "fpdfsdk/cpdfsdk_widget.h"
#include "fpdfsdk/formfiller/cffl_formfield.h"
#include "fxjs/ijs_event_context.h"
#include "fxjs/ijs_runtime.h"
namespace {
constexpr uint32_t kWhiteBGR = …;
bool IsFormFieldTypeComboOrText(FormFieldType fieldType) { … }
#ifdef PDF_ENABLE_XFA
bool IsFormFieldTypeXFA(FormFieldType fieldType) { … }
#endif
ByteString FDFToURLEncodedData(ByteString buffer) { … }
}
CPDFSDK_InteractiveForm::CPDFSDK_InteractiveForm(
CPDFSDK_FormFillEnvironment* pFormFillEnv)
: … { … }
CPDFSDK_InteractiveForm::~CPDFSDK_InteractiveForm() = default;
CPDFSDK_Widget* CPDFSDK_InteractiveForm::GetWidget(
CPDF_FormControl* pControl) const { … }
void CPDFSDK_InteractiveForm::GetWidgets(
const WideString& sFieldName,
std::vector<ObservedPtr<CPDFSDK_Widget>>* widgets) const { … }
void CPDFSDK_InteractiveForm::GetWidgets(
CPDF_FormField* pField,
std::vector<ObservedPtr<CPDFSDK_Widget>>* widgets) const { … }
int CPDFSDK_InteractiveForm::GetPageIndexByAnnotDict(
CPDF_Document* pDocument,
const CPDF_Dictionary* pAnnotDict) const { … }
void CPDFSDK_InteractiveForm::AddMap(CPDF_FormControl* pControl,
CPDFSDK_Widget* pWidget) { … }
void CPDFSDK_InteractiveForm::RemoveMap(CPDF_FormControl* pControl) { … }
void CPDFSDK_InteractiveForm::EnableCalculate(bool bEnabled) { … }
bool CPDFSDK_InteractiveForm::IsCalculateEnabled() const { … }
#ifdef PDF_ENABLE_XFA
void CPDFSDK_InteractiveForm::XfaEnableCalculate(bool bEnabled) { … }
bool CPDFSDK_InteractiveForm::IsXfaCalculateEnabled() const { … }
bool CPDFSDK_InteractiveForm::IsXfaValidationsEnabled() { … }
void CPDFSDK_InteractiveForm::XfaSetValidationsEnabled(bool bEnabled) { … }
void CPDFSDK_InteractiveForm::SynchronizeField(CPDF_FormField* pFormField) { … }
#endif
void CPDFSDK_InteractiveForm::OnCalculate(CPDF_FormField* pFormField) { … }
std::optional<WideString> CPDFSDK_InteractiveForm::OnFormat(
CPDF_FormField* pFormField) { … }
void CPDFSDK_InteractiveForm::ResetFieldAppearance(
CPDF_FormField* pFormField,
std::optional<WideString> sValue) { … }
void CPDFSDK_InteractiveForm::UpdateField(CPDF_FormField* pFormField) { … }
bool CPDFSDK_InteractiveForm::OnKeyStrokeCommit(CPDF_FormField* pFormField,
const WideString& csValue) { … }
bool CPDFSDK_InteractiveForm::OnValidate(CPDF_FormField* pFormField,
const WideString& csValue) { … }
bool CPDFSDK_InteractiveForm::DoAction_Hide(const CPDF_Action& action) { … }
bool CPDFSDK_InteractiveForm::DoAction_SubmitForm(const CPDF_Action& action) { … }
bool CPDFSDK_InteractiveForm::SubmitFields(
const WideString& csDestination,
const std::vector<CPDF_FormField*>& fields,
bool bIncludeOrExclude,
bool bUrlEncoded) { … }
ByteString CPDFSDK_InteractiveForm::ExportFieldsToFDFTextBuf(
const std::vector<CPDF_FormField*>& fields,
bool bIncludeOrExclude) { … }
bool CPDFSDK_InteractiveForm::SubmitForm(const WideString& sDestination) { … }
ByteString CPDFSDK_InteractiveForm::ExportFormToFDFTextBuf() { … }
void CPDFSDK_InteractiveForm::DoAction_ResetForm(const CPDF_Action& action) { … }
std::vector<CPDF_FormField*> CPDFSDK_InteractiveForm::GetFieldFromObjects(
const std::vector<RetainPtr<const CPDF_Object>>& objects) const { … }
bool CPDFSDK_InteractiveForm::BeforeValueChange(CPDF_FormField* pField,
const WideString& csValue) { … }
void CPDFSDK_InteractiveForm::AfterValueChange(CPDF_FormField* pField) { … }
bool CPDFSDK_InteractiveForm::BeforeSelectionChange(CPDF_FormField* pField,
const WideString& csValue) { … }
void CPDFSDK_InteractiveForm::AfterSelectionChange(CPDF_FormField* pField) { … }
void CPDFSDK_InteractiveForm::AfterCheckedStatusChange(CPDF_FormField* pField) { … }
void CPDFSDK_InteractiveForm::AfterFormReset(CPDF_InteractiveForm* pForm) { … }
bool CPDFSDK_InteractiveForm::IsNeedHighLight(FormFieldType fieldType) const { … }
void CPDFSDK_InteractiveForm::RemoveAllHighLights() { … }
void CPDFSDK_InteractiveForm::SetHighlightColor(FX_COLORREF clr,
FormFieldType fieldType) { … }
void CPDFSDK_InteractiveForm::SetAllHighlightColors(FX_COLORREF clr) { … }
FX_COLORREF CPDFSDK_InteractiveForm::GetHighlightColor(
FormFieldType fieldType) { … }