summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdfformfill.cpp8
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp217
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_document.cpp14
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_document.h11
4 files changed, 134 insertions, 116 deletions
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index 184f7ca341..8146e1df42 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -253,15 +253,15 @@ FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
// If the CPDFXFA_Document has a SDKDocument already then we've done this
// and can just return the old Env. Otherwise, we'll end up setting a new
// SDKDocument into the XFADocument and, that could get weird.
- if (pDocument->GetSDKDoc())
- return pDocument->GetSDKDoc()->GetEnv();
+ if (pDocument->GetFormFillEnv())
+ return pDocument->GetFormFillEnv();
#endif
CPDFSDK_FormFillEnvironment* pFormFillEnv =
new CPDFSDK_FormFillEnvironment(pDocument, formInfo);
#ifdef PDF_ENABLE_XFA
- pDocument->SetSDKDoc(pFormFillEnv->GetSDKDocument());
+ pDocument->SetFormFillEnv(pFormFillEnv);
CPDFXFA_App::GetInstance()->AddFormFillEnv(pFormFillEnv);
#endif // PDF_ENABLE_XFA
@@ -285,7 +285,7 @@ FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) {
// If the document was closed first, it's possible the XFA document
// is now a nullptr.
if (pFormFillEnv->GetSDKDocument()->GetXFADocument())
- pFormFillEnv->GetSDKDocument()->GetXFADocument()->SetSDKDoc(nullptr);
+ pFormFillEnv->GetSDKDocument()->GetXFADocument()->SetFormFillEnv(nullptr);
#endif // PDF_ENABLE_XFA
delete pFormFillEnv;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index 1d4b36efd7..3d40fb24e2 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -41,21 +41,19 @@ CPDFXFA_DocEnvironment::CPDFXFA_DocEnvironment(CPDFXFA_Document* doc)
}
CPDFXFA_DocEnvironment::~CPDFXFA_DocEnvironment() {
- if (m_pJSContext && m_pDocument->GetSDKDoc() &&
- m_pDocument->GetSDKDoc()->GetEnv())
- m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->ReleaseContext(
- m_pJSContext);
+ if (m_pJSContext && m_pDocument->GetFormFillEnv())
+ m_pDocument->GetFormFillEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext);
}
void CPDFXFA_DocEnvironment::SetChangeMark(CXFA_FFDoc* hDoc) {
- if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetSDKDoc())
- m_pDocument->GetSDKDoc()->SetChangeMark();
+ if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetFormFillEnv())
+ m_pDocument->GetFormFillEnv()->GetSDKDocument()->SetChangeMark();
}
void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView,
const CFX_RectF& rt,
uint32_t dwFlags /* = 0 */) {
- if (!m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
+ if (!m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
return;
if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA)
@@ -65,20 +63,20 @@ void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView,
if (!pPage)
return;
- CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
- if (!pEnv)
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv)
return;
CFX_FloatRect rcPage = CFX_FloatRect::FromCFXRectF(rt);
- pEnv->Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, rcPage.right,
- rcPage.top);
+ pFormFillEnv->Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom,
+ rcPage.right, rcPage.top);
}
void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget,
FX_BOOL bVisible,
const CFX_RectF* pRtAnchor) {
if (!hWidget || !pRtAnchor || !m_pDocument->GetXFADoc() ||
- !m_pDocument->GetSDKDoc() || !m_pDocument->GetXFADocView())
+ !m_pDocument->GetFormFillEnv() || !m_pDocument->GetXFADocView())
return;
if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA)
@@ -97,13 +95,13 @@ void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget,
if (!pPage)
return;
- CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
- if (!pEnv)
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv)
return;
CFX_FloatRect rcCaret = CFX_FloatRect::FromCFXRectF(*pRtAnchor);
- pEnv->DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top,
- rcCaret.right, rcCaret.bottom);
+ pFormFillEnv->DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left,
+ rcCaret.top, rcCaret.right, rcCaret.bottom);
}
FX_BOOL CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget,
@@ -124,12 +122,12 @@ FX_BOOL CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget,
CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc();
int nRotate = pWidgetAcc->GetRotate();
- CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
- if (!pEnv)
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv)
return FALSE;
FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f};
- pEnv->GetPageViewRect(pPage, pageViewRect);
+ pFormFillEnv->GetPageViewRect(pPage, pageViewRect);
int t1;
int t2;
@@ -235,8 +233,8 @@ FX_BOOL CPDFXFA_DocEnvironment::PopupMenu(CXFA_FFWidget* hWidget,
if (!pPage)
return FALSE;
- CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
- if (!pEnv)
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv)
return FALSE;
int menuFlag = 0;
@@ -253,17 +251,13 @@ FX_BOOL CPDFXFA_DocEnvironment::PopupMenu(CXFA_FFWidget* hWidget,
if (hWidget->CanSelectAll())
menuFlag |= FXFA_MENU_SELECTALL;
- return pEnv->PopupMenu(pPage, hWidget, menuFlag, ptPopup);
+ return pFormFillEnv->PopupMenu(pPage, hWidget, menuFlag, ptPopup);
}
void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView,
uint32_t dwFlags) {
- CPDFSDK_Document* pSDKDoc = m_pDocument->GetSDKDoc();
- if (!pSDKDoc)
- return;
-
- CPDFSDK_FormFillEnvironment* pEnv = pSDKDoc->GetEnv();
- if (!pEnv)
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv)
return;
if (m_pDocument->GetLoadStatus() == FXFA_LOADSTATUS_LOADING ||
@@ -285,7 +279,7 @@ void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView,
if (!pPage)
continue;
- m_pDocument->GetSDKDoc()->RemovePageView(pPage);
+ m_pDocument->GetFormFillEnv()->GetSDKDocument()->RemovePageView(pPage);
pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter));
}
@@ -294,7 +288,7 @@ void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView,
: FXFA_PAGEVIEWEVENT_POSTADDED;
int count = FXSYS_abs(nNewCount - m_pDocument->GetOriginalPageCount());
m_pDocument->SetOriginalPageCount(nNewCount);
- pEnv->PageEvent(count, flag);
+ pFormFillEnv->PageEvent(count, flag);
}
void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget,
@@ -310,7 +304,10 @@ void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget,
if (!pXFAPage)
return;
- m_pDocument->GetSDKDoc()->GetPageView(pXFAPage, true)->AddAnnot(hWidget);
+ m_pDocument->GetFormFillEnv()
+ ->GetSDKDocument()
+ ->GetPageView(pXFAPage, true)
+ ->AddAnnot(hWidget);
}
void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget,
@@ -327,58 +324,66 @@ void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget,
return;
CPDFSDK_PageView* pSdkPageView =
- m_pDocument->GetSDKDoc()->GetPageView(pXFAPage, true);
+ m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageView(pXFAPage,
+ true);
if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget))
pSdkPageView->DeleteAnnot(pAnnot);
}
int32_t CPDFXFA_DocEnvironment::CountPages(CXFA_FFDoc* hDoc) {
- if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetSDKDoc())
+ if (hDoc == m_pDocument->GetXFADoc() && m_pDocument->GetFormFillEnv())
return m_pDocument->GetPageCount();
return 0;
}
int32_t CPDFXFA_DocEnvironment::GetCurrentPage(CXFA_FFDoc* hDoc) {
- if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
+ if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
return -1;
if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA)
return -1;
- CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
- if (!pEnv)
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv)
return -1;
- return pEnv->GetCurrentPageIndex(this);
+ return pFormFillEnv->GetCurrentPageIndex(this);
}
void CPDFXFA_DocEnvironment::SetCurrentPage(CXFA_FFDoc* hDoc,
int32_t iCurPage) {
- if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc() ||
+ if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv() ||
m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 ||
- iCurPage >= m_pDocument->GetSDKDoc()->GetPageCount()) {
+ iCurPage >=
+ m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageCount()) {
return;
}
- CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
- if (!pEnv)
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv)
return;
- pEnv->SetCurrentPage(this, iCurPage);
+ pFormFillEnv->SetCurrentPage(this, iCurPage);
}
FX_BOOL CPDFXFA_DocEnvironment::IsCalculationsEnabled(CXFA_FFDoc* hDoc) {
- if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
+ if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
return FALSE;
- if (m_pDocument->GetSDKDoc()->GetInterForm())
- return m_pDocument->GetSDKDoc()->GetInterForm()->IsXfaCalculateEnabled();
+ if (m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm())
+ return m_pDocument->GetFormFillEnv()
+ ->GetSDKDocument()
+ ->GetInterForm()
+ ->IsXfaCalculateEnabled();
return FALSE;
}
void CPDFXFA_DocEnvironment::SetCalculationsEnabled(CXFA_FFDoc* hDoc,
FX_BOOL bEnabled) {
- if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
+ if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
return;
- if (m_pDocument->GetSDKDoc()->GetInterForm())
- m_pDocument->GetSDKDoc()->GetInterForm()->XfaEnableCalculate(bEnabled);
+ if (m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm())
+ m_pDocument->GetFormFillEnv()
+ ->GetSDKDocument()
+ ->GetInterForm()
+ ->XfaEnableCalculate(bEnabled);
}
void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc,
@@ -414,23 +419,24 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc,
m_pDocument->GetDocType() != DOCTYPE_STATIC_XFA)
return;
- CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
- if (!pEnv)
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv)
return;
int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML;
CFX_ByteString bs = wsFilePath.UTF16LE_Encode();
if (wsFilePath.IsEmpty()) {
- if (!pEnv->GetFormFillInfo() || !pEnv->GetFormFillInfo()->m_pJsPlatform)
+ if (!pFormFillEnv->GetFormFillInfo() ||
+ !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform)
return;
- CFX_WideString filepath = pEnv->JS_fieldBrowse();
+ CFX_WideString filepath = pFormFillEnv->JS_fieldBrowse();
bs = filepath.UTF16LE_Encode();
}
int len = bs.GetLength();
FPDF_FILEHANDLER* pFileHandler =
- pEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML,
- (FPDF_WIDESTRING)bs.GetBuffer(len), "wb");
+ pFormFillEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML,
+ (FPDF_WIDESTRING)bs.GetBuffer(len), "wb");
bs.ReleaseBuffer(len);
if (!pFileHandler)
return;
@@ -511,29 +517,34 @@ void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc,
if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA)
return;
- CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
- if (!pEnv)
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv)
return;
CFX_WideStringC str(bsURL.c_str());
- pEnv->GotoURL(this, str);
+ pFormFillEnv->GotoURL(this, str);
}
FX_BOOL CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) {
- if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
+ if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
return FALSE;
- if (m_pDocument->GetSDKDoc()->GetInterForm())
- return m_pDocument->GetSDKDoc()->GetInterForm()->IsXfaValidationsEnabled();
+ if (m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm())
+ return m_pDocument->GetFormFillEnv()
+ ->GetSDKDocument()
+ ->GetInterForm()
+ ->IsXfaValidationsEnabled();
return TRUE;
}
void CPDFXFA_DocEnvironment::SetValidationsEnabled(CXFA_FFDoc* hDoc,
FX_BOOL bEnabled) {
- if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
+ if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
return;
- if (m_pDocument->GetSDKDoc()->GetInterForm())
- m_pDocument->GetSDKDoc()->GetInterForm()->XfaSetValidationsEnabled(
- bEnabled);
+ if (m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm())
+ m_pDocument->GetFormFillEnv()
+ ->GetSDKDocument()
+ ->GetInterForm()
+ ->XfaSetValidationsEnabled(bEnabled);
}
void CPDFXFA_DocEnvironment::SetFocusWidget(CXFA_FFDoc* hDoc,
@@ -543,19 +554,21 @@ void CPDFXFA_DocEnvironment::SetFocusWidget(CXFA_FFDoc* hDoc,
if (!hWidget) {
CPDFSDK_Annot::ObservedPtr pNull;
- m_pDocument->GetSDKDoc()->SetFocusAnnot(&pNull);
+ m_pDocument->GetFormFillEnv()->GetSDKDocument()->SetFocusAnnot(&pNull);
return;
}
- int pageViewCount = m_pDocument->GetSDKDoc()->GetPageViewCount();
+ int pageViewCount =
+ m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageViewCount();
for (int i = 0; i < pageViewCount; i++) {
- CPDFSDK_PageView* pPageView = m_pDocument->GetSDKDoc()->GetPageView(i);
+ CPDFSDK_PageView* pPageView =
+ m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetPageView(i);
if (!pPageView)
continue;
CPDFSDK_Annot::ObservedPtr pAnnot(pPageView->GetAnnotByXFAWidget(hWidget));
if (pAnnot) {
- m_pDocument->GetSDKDoc()->SetFocusAnnot(&pAnnot);
+ m_pDocument->GetFormFillEnv()->GetSDKDocument()->SetFocusAnnot(&pAnnot);
break;
}
}
@@ -568,15 +581,15 @@ void CPDFXFA_DocEnvironment::Print(CXFA_FFDoc* hDoc,
if (hDoc != m_pDocument->GetXFADoc())
return;
- CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
- if (!pEnv || !pEnv->GetFormFillInfo() ||
- !pEnv->GetFormFillInfo()->m_pJsPlatform ||
- !pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) {
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv || !pFormFillEnv->GetFormFillInfo() ||
+ !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform ||
+ !pFormFillEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) {
return;
}
- pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print(
- pEnv->GetFormFillInfo()->m_pJsPlatform,
+ pFormFillEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print(
+ pFormFillEnv->GetFormFillInfo()->m_pJsPlatform,
dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage,
dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage,
dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder,
@@ -584,10 +597,11 @@ void CPDFXFA_DocEnvironment::Print(CXFA_FFDoc* hDoc,
}
FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) {
- if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc())
+ if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetFormFillEnv())
return 0;
- CPDFSDK_InterForm* pInterForm = m_pDocument->GetSDKDoc()->GetInterForm();
+ CPDFSDK_InterForm* pInterForm =
+ m_pDocument->GetFormFillEnv()->GetSDKDocument()->GetInterForm();
if (!pInterForm)
return 0;
@@ -635,16 +649,16 @@ FX_BOOL CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() {
while (pWidgetAcc) {
int fRet = pWidgetAcc->ProcessValidate(-1);
if (fRet == XFA_EVENTERROR_Error) {
- CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
- if (!pEnv)
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv)
return FALSE;
CFX_WideString ws;
ws.FromLocal(IDS_XFA_Validate_Input);
CFX_ByteString bs = ws.UTF16LE_Encode();
int len = bs.GetLength();
- pEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 0,
- 1);
+ pFormFillEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len),
+ (FPDF_WIDESTRING)L"", 0, 1);
bs.ReleaseBuffer(len);
return FALSE;
}
@@ -697,14 +711,14 @@ FX_BOOL CPDFXFA_DocEnvironment::SubmitData(CXFA_FFDoc* hDoc,
IFX_FileRead* CPDFXFA_DocEnvironment::OpenLinkedFile(
CXFA_FFDoc* hDoc,
const CFX_WideString& wsLink) {
- CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
- if (!pEnv)
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv)
return FALSE;
CFX_ByteString bs = wsLink.UTF16LE_Encode();
int len = bs.GetLength();
FPDF_FILEHANDLER* pFileHandler =
- pEnv->OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb");
+ pFormFillEnv->OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb");
bs.ReleaseBuffer(len);
if (!pFileHandler)
@@ -720,8 +734,8 @@ FX_BOOL CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
return FALSE;
CFX_ByteString content;
- CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
- if (!pEnv)
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv)
return FALSE;
CFPDF_FileStream fileStream(pFileHandler);
@@ -891,8 +905,8 @@ FX_BOOL CPDFXFA_DocEnvironment::MailToInfo(CFX_WideString& csURL,
FX_BOOL CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc,
CXFA_Submit submit) {
- CPDFSDK_FormFillEnvironment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
- if (!pEnv)
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
+ if (!pFormFillEnv)
return FALSE;
CFX_WideStringC csURLC;
@@ -903,7 +917,8 @@ FX_BOOL CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc,
ws.FromLocal("Submit cancelled.");
CFX_ByteString bs = ws.UTF16LE_Encode();
int len = bs.GetLength();
- pEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 0, 4);
+ pFormFillEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len),
+ (FPDF_WIDESTRING)L"", 0, 4);
bs.ReleaseBuffer(len);
return FALSE;
}
@@ -927,20 +942,20 @@ FX_BOOL CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc,
flag |= FXFA_PDF;
ToXFAContentFlags(csContent, flag);
- pFileHandler = pEnv->OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb");
+ pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb");
fileFlag = FXFA_SAVEAS_XDP;
ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag);
break;
}
case XFA_ATTRIBUTEENUM_Xml:
- pFileHandler = pEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb");
+ pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb");
fileFlag = FXFA_SAVEAS_XML;
ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL);
break;
case XFA_ATTRIBUTEENUM_Pdf:
break;
case XFA_ATTRIBUTEENUM_Urlencoded:
- pFileHandler = pEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb");
+ pFileHandler = pFormFillEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb");
fileFlag = FXFA_SAVEAS_XML;
ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL);
break;
@@ -971,7 +986,7 @@ FX_BOOL CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc,
FPDF_WIDESTRING pSubject =
(FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength());
FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength());
- pEnv->EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg);
+ pFormFillEnv->EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg);
bsTo.ReleaseBuffer();
bsCC.ReleaseBuffer();
bsBcc.ReleaseBuffer();
@@ -982,7 +997,8 @@ FX_BOOL CPDFXFA_DocEnvironment::SubmitDataInternal(CXFA_FFDoc* hDoc,
CFX_WideString ws;
CFX_ByteString bs = csURL.UTF16LE_Encode();
int len = bs.GetLength();
- pEnv->UploadTo(pFileHandler, fileFlag, (FPDF_WIDESTRING)bs.GetBuffer(len));
+ pFormFillEnv->UploadTo(pFileHandler, fileFlag,
+ (FPDF_WIDESTRING)bs.GetBuffer(len));
bs.ReleaseBuffer(len);
}
return bRet;
@@ -995,10 +1011,11 @@ FX_BOOL CPDFXFA_DocEnvironment::SetGlobalProperty(
if (hDoc != m_pDocument->GetXFADoc())
return FALSE;
- if (m_pDocument->GetSDKDoc() &&
- m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime())
- return m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->SetValueByName(
+ if (m_pDocument->GetFormFillEnv() &&
+ m_pDocument->GetFormFillEnv()->GetJSRuntime()) {
+ return m_pDocument->GetFormFillEnv()->GetJSRuntime()->SetValueByName(
szPropName, pValue);
+ }
return FALSE;
}
@@ -1008,12 +1025,12 @@ FX_BOOL CPDFXFA_DocEnvironment::GetGlobalProperty(
CFXJSE_Value* pValue) {
if (hDoc != m_pDocument->GetXFADoc())
return FALSE;
- if (!m_pDocument->GetSDKDoc() ||
- !m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime())
+ if (!m_pDocument->GetFormFillEnv() ||
+ !m_pDocument->GetFormFillEnv()->GetJSRuntime()) {
return FALSE;
+ }
- CPDFSDK_FormFillEnvironment* pFormFillEnv =
- m_pDocument->GetSDKDoc()->GetEnv();
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pDocument->GetFormFillEnv();
if (!m_pJSContext)
m_pJSContext = pFormFillEnv->GetJSRuntime()->NewContext();
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp
index 90a762ddf3..472779a6d4 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp
@@ -33,7 +33,7 @@ CPDFXFA_Document::CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc,
CPDFXFA_App* pProvider)
: m_iDocType(DOCTYPE_PDF),
m_pPDFDoc(std::move(pPDFDoc)),
- m_pSDKDoc(nullptr),
+ m_pFormFillEnv(nullptr),
m_pXFADocView(nullptr),
m_pApp(pProvider),
m_nLoadStatus(FXFA_LOADSTATUS_PRELOAD),
@@ -43,12 +43,12 @@ CPDFXFA_Document::CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc,
CPDFXFA_Document::~CPDFXFA_Document() {
m_nLoadStatus = FXFA_LOADSTATUS_CLOSING;
- if (m_pSDKDoc) {
- m_pSDKDoc->ClearAllFocusedAnnots();
+ if (m_pFormFillEnv) {
+ m_pFormFillEnv->GetSDKDocument()->ClearAllFocusedAnnots();
// Once we're deleted the SDKDocument will point at a bad underlying
// doc so we need to reset it ...
- m_pSDKDoc->ResetXFADocument();
- m_pSDKDoc = nullptr;
+ m_pFormFillEnv->GetSDKDocument()->ResetXFADocument();
+ m_pFormFillEnv = nullptr;
}
if (m_pXFADoc) {
@@ -201,6 +201,6 @@ void CPDFXFA_Document::RemovePage(CPDFXFA_Page* page) {
}
void CPDFXFA_Document::ClearChangeMark() {
- if (m_pSDKDoc)
- m_pSDKDoc->ClearChangeMark();
+ if (m_pFormFillEnv)
+ m_pFormFillEnv->GetSDKDocument()->ClearChangeMark();
}
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_document.h b/fpdfsdk/fpdfxfa/cpdfxfa_document.h
index 4118a31f6d..de997c16f3 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_document.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_document.h
@@ -12,7 +12,6 @@
#include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h"
#include "xfa/fxfa/xfa_ffdoc.h"
-class CPDFSDK_Document;
class CPDFSDK_FormFillEnvironment;
class CPDFXFA_App;
class CPDFXFA_Page;
@@ -40,8 +39,10 @@ class CPDFXFA_Document {
CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; }
int GetDocType() const { return m_iDocType; }
- CPDFSDK_Document* GetSDKDoc() const { return m_pSDKDoc; }
- void SetSDKDoc(CPDFSDK_Document* pSDKDoc) { m_pSDKDoc = pSDKDoc; }
+ CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv; }
+ void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ m_pFormFillEnv = pFormFillEnv;
+ }
void DeletePage(int page_index);
int GetPageCount() const;
@@ -79,14 +80,14 @@ class CPDFXFA_Document {
std::unique_ptr<CPDF_Document> m_pPDFDoc;
std::unique_ptr<CXFA_FFDoc> m_pXFADoc;
- CPDFSDK_Document* m_pSDKDoc; // not owned.
+ CPDFSDK_FormFillEnvironment* m_pFormFillEnv; // not owned.
CXFA_FFDocView* m_pXFADocView; // not owned.
CPDFXFA_App* const m_pApp;
CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList;
LoadStatus m_nLoadStatus;
int m_nPageCount;
- // Must be destroy before |m_pSDKDoc|.
+ // Must be destroyed before |m_pFormFillEnv|.
CPDFXFA_DocEnvironment m_DocEnv;
};