summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/cpdfsdk_annotiterator_embeddertest.cpp2
-rw-r--r--fpdfsdk/cpdfsdk_helpers.h10
-rw-r--r--fpdfsdk/fpdf_formfill.cpp37
-rw-r--r--fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp3
-rw-r--r--fpdfsdk/pwl/cpwl_edit_embeddertest.cpp3
5 files changed, 33 insertions, 22 deletions
diff --git a/fpdfsdk/cpdfsdk_annotiterator_embeddertest.cpp b/fpdfsdk/cpdfsdk_annotiterator_embeddertest.cpp
index 879a365ae8..161ae95178 100644
--- a/fpdfsdk/cpdfsdk_annotiterator_embeddertest.cpp
+++ b/fpdfsdk/cpdfsdk_annotiterator_embeddertest.cpp
@@ -40,7 +40,7 @@ TEST_F(CPDFSDK_AnnotIteratorTest, CPDFSDK_AnnotIterator) {
CFX_FloatRect RightTop(401, 401, 421, 421);
CPDFSDK_FormFillEnvironment* pFormFillEnv =
- static_cast<CPDFSDK_FormFillEnvironment*>(form_handle());
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(form_handle());
{
// Page 0 specifies "row order".
diff --git a/fpdfsdk/cpdfsdk_helpers.h b/fpdfsdk/cpdfsdk_helpers.h
index 4fd85cfc72..5de947afdf 100644
--- a/fpdfsdk/cpdfsdk_helpers.h
+++ b/fpdfsdk/cpdfsdk_helpers.h
@@ -38,6 +38,7 @@ class CPDF_StructElement;
class CPDF_StructTree;
class CPDF_TextPage;
class CPDF_TextPageFind;
+class CPDFSDK_FormFillEnvironment;
class IPDFSDK_PauseAdapter;
class FX_PATHPOINT;
@@ -197,6 +198,15 @@ inline CPDF_TextPageFind* CPDFTextPageFindFromFPDFSchHandle(
return reinterpret_cast<CPDF_TextPageFind*>(handle);
}
+inline FPDF_FORMHANDLE FPDFFormHandleFromCPDFSDKFormFillEnvironment(
+ CPDFSDK_FormFillEnvironment* handle) {
+ return reinterpret_cast<FPDF_FORMHANDLE>(handle);
+}
+inline CPDFSDK_FormFillEnvironment*
+CPDFSDKFormFillEnvironmentFromFPDFFormHandle(FPDF_FORMHANDLE handle) {
+ return reinterpret_cast<CPDFSDK_FormFillEnvironment*>(handle);
+}
+
ByteString CFXByteStringFromFPDFWideString(FPDF_WIDESTRING wide_string);
#ifdef PDF_ENABLE_XFA
diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp
index d529a5be69..3a74bc3908 100644
--- a/fpdfsdk/fpdf_formfill.cpp
+++ b/fpdfsdk/fpdf_formfill.cpp
@@ -143,14 +143,9 @@ static_assert(kFormFieldTypeCount == FPDF_FORMFIELD_COUNT,
namespace {
-CPDFSDK_FormFillEnvironment* HandleToCPDFSDKEnvironment(
- FPDF_FORMHANDLE handle) {
- return static_cast<CPDFSDK_FormFillEnvironment*>(handle);
-}
-
CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) {
CPDFSDK_FormFillEnvironment* pFormFillEnv =
- HandleToCPDFSDKEnvironment(hHandle);
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(hHandle);
return pFormFillEnv ? pFormFillEnv->GetInterForm() : nullptr;
}
@@ -161,7 +156,7 @@ CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle,
return nullptr;
CPDFSDK_FormFillEnvironment* pFormFillEnv =
- HandleToCPDFSDKEnvironment(hHandle);
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(hHandle);
return pFormFillEnv ? pFormFillEnv->GetPageView(pPage, true) : nullptr;
}
@@ -326,8 +321,10 @@ FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
// this and can just return the old Env. Otherwise, we'll end up setting a new
// environment into the XFADocument and, that could get weird.
auto* pContext = static_cast<CPDFXFA_Context*>(pDocument->GetExtension());
- if (pContext && pContext->GetFormFillEnv())
- return pContext->GetFormFillEnv();
+ if (pContext && pContext->GetFormFillEnv()) {
+ return FPDFFormHandleFromCPDFSDKFormFillEnvironment(
+ pContext->GetFormFillEnv());
+ }
#endif
auto pFormFillEnv = pdfium::MakeUnique<CPDFSDK_FormFillEnvironment>(
@@ -338,13 +335,14 @@ FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
pContext->SetFormFillEnv(pFormFillEnv.get());
#endif // PDF_ENABLE_XFA
- return pFormFillEnv.release(); // Caller takes ownership.
+ return FPDFFormHandleFromCPDFSDKFormFillEnvironment(
+ pFormFillEnv.release()); // Caller takes ownership.
}
FPDF_EXPORT void FPDF_CALLCONV
FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) {
CPDFSDK_FormFillEnvironment* pFormFillEnv =
- HandleToCPDFSDKEnvironment(hHandle);
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(hHandle);
if (!pFormFillEnv)
return;
@@ -363,7 +361,7 @@ FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) {
FPDF_EXPORT void FPDF_CALLCONV FORM_SetSaveCallback(FPDF_FORMHANDLE hHandle,
FORM_SAVECALLED callback) {
CPDFSDK_FormFillEnvironment* pFormFillEnv =
- HandleToCPDFSDKEnvironment(hHandle);
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(hHandle);
if (!pFormFillEnv)
return;
@@ -558,7 +556,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_Redo(FPDF_FORMHANDLE hHandle,
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) {
CPDFSDK_FormFillEnvironment* pFormFillEnv =
- HandleToCPDFSDKEnvironment(hHandle);
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(hHandle);
if (!pFormFillEnv)
return false;
return pFormFillEnv->KillFocusAnnot(0);
@@ -632,7 +630,7 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_OnAfterLoadPage(FPDF_PAGE page,
FPDF_EXPORT void FPDF_CALLCONV FORM_OnBeforeClosePage(FPDF_PAGE page,
FPDF_FORMHANDLE hHandle) {
CPDFSDK_FormFillEnvironment* pFormFillEnv =
- HandleToCPDFSDKEnvironment(hHandle);
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(hHandle);
if (!pFormFillEnv)
return;
@@ -651,7 +649,7 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_OnBeforeClosePage(FPDF_PAGE page,
FPDF_EXPORT void FPDF_CALLCONV
FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) {
CPDFSDK_FormFillEnvironment* pFormFillEnv =
- HandleToCPDFSDKEnvironment(hHandle);
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(hHandle);
if (pFormFillEnv && pFormFillEnv->IsJSPlatformPresent())
pFormFillEnv->ProcJavascriptFun();
}
@@ -659,7 +657,7 @@ FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) {
FPDF_EXPORT void FPDF_CALLCONV
FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) {
CPDFSDK_FormFillEnvironment* pFormFillEnv =
- HandleToCPDFSDKEnvironment(hHandle);
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(hHandle);
if (pFormFillEnv && pFormFillEnv->IsJSPlatformPresent())
pFormFillEnv->ProcOpenAction();
}
@@ -667,7 +665,7 @@ FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) {
FPDF_EXPORT void FPDF_CALLCONV FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
int aaType) {
CPDFSDK_FormFillEnvironment* pFormFillEnv =
- HandleToCPDFSDKEnvironment(hHandle);
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(hHandle);
if (!pFormFillEnv)
return;
@@ -681,7 +679,8 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
if (aa.ActionExist(type)) {
CPDF_Action action = aa.GetAction(type);
CPDFSDK_ActionHandler* pActionHandler =
- HandleToCPDFSDKEnvironment(hHandle)->GetActionHandler();
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(hHandle)
+ ->GetActionHandler();
pActionHandler->DoAction_Document(action, type, pFormFillEnv);
}
}
@@ -690,7 +689,7 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_DoPageAAction(FPDF_PAGE page,
FPDF_FORMHANDLE hHandle,
int aaType) {
CPDFSDK_FormFillEnvironment* pFormFillEnv =
- HandleToCPDFSDKEnvironment(hHandle);
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(hHandle);
if (!pFormFillEnv)
return;
diff --git a/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp b/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
index e4b329e61e..62d42f9344 100644
--- a/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
@@ -29,7 +29,8 @@ class CPWLComboBoxEditEmbeddertest : public EmbedderTest {
m_page = LoadPage(0);
ASSERT_TRUE(m_page);
- m_pFormFillEnv = static_cast<CPDFSDK_FormFillEnvironment*>(form_handle());
+ m_pFormFillEnv =
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(form_handle());
CPDFSDK_AnnotIterator iter(m_pFormFillEnv->GetPageView(0),
CPDF_Annot::Subtype::WIDGET);
diff --git a/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp b/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp
index 43d06d3d2a..3edbf7580a 100644
--- a/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp
@@ -28,7 +28,8 @@ class CPWLEditEmbeddertest : public EmbedderTest {
m_page = LoadPage(0);
ASSERT_TRUE(m_page);
- m_pFormFillEnv = static_cast<CPDFSDK_FormFillEnvironment*>(form_handle());
+ m_pFormFillEnv =
+ CPDFSDKFormFillEnvironmentFromFPDFFormHandle(form_handle());
CPDFSDK_AnnotIterator iter(m_pFormFillEnv->GetPageView(0),
CPDF_Annot::Subtype::WIDGET);
// Normal text field.