diff options
Diffstat (limited to 'fpdfsdk/fpdfxfa')
-rw-r--r-- | fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp | 135 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h | 69 |
2 files changed, 54 insertions, 150 deletions
diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp index 63f4bb9faf..be83d3416e 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp @@ -41,6 +41,7 @@ #define FXFA_XFDF 0x00100000 #define FXFA_FORM 0x01000000 #define FXFA_PDF 0x10000000 +#define FXFA_XFA_ALL 0x01111111 #ifndef _WIN32 extern void SetLastError(int err); @@ -517,13 +518,6 @@ void CPDFXFA_Document::WidgetPreRemove(CXFA_FFWidget* hWidget, pSdkPageView->DeleteAnnot(pAnnot); } -FX_BOOL CPDFXFA_Document::RenderCustomWidget(CXFA_FFWidget* hWidget, - CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - const CFX_RectF& rtUI) { - return FALSE; -} - int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) { if (hDoc == m_pXFADoc.get() && m_pSDKDoc) return GetPageCount(); @@ -554,6 +548,7 @@ void CPDFXFA_Document::SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) { return; pEnv->FFI_SetCurrentPage(this, iCurPage); } + FX_BOOL CPDFXFA_Document::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) return FALSE; @@ -562,6 +557,7 @@ FX_BOOL CPDFXFA_Document::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { return FALSE; } + void CPDFXFA_Document::SetCalculationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) { if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) @@ -682,8 +678,6 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, // Ignoring flush error. } } -void CPDFXFA_Document::ImportData(CXFA_FFDoc* hDoc, - const CFX_WideString& wsFilePath) {} void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc, const CFX_WideString& bsURL, @@ -711,6 +705,7 @@ FX_BOOL CPDFXFA_Document::IsValidationsEnabled(CXFA_FFDoc* hDoc) { return TRUE; } + void CPDFXFA_Document::SetValidationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) { if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) @@ -718,6 +713,7 @@ void CPDFXFA_Document::SetValidationsEnabled(CXFA_FFDoc* hDoc, if (m_pSDKDoc->GetInterForm()) m_pSDKDoc->GetInterForm()->XfaSetValidationsEnabled(bEnabled); } + void CPDFXFA_Document::SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) { if (hDoc != m_pXFADoc.get()) @@ -740,6 +736,7 @@ void CPDFXFA_Document::SetFocusWidget(CXFA_FFDoc* hDoc, } } } + void CPDFXFA_Document::Print(CXFA_FFDoc* hDoc, int32_t nStartPage, int32_t nEndPage, @@ -762,49 +759,6 @@ void CPDFXFA_Document::Print(CXFA_FFDoc* hDoc, dwOptions & XFA_PRINTOPT_PrintAnnot); } -int32_t CPDFXFA_Document::AbsPageCountInBatch(CXFA_FFDoc* hDoc) { - return 0; -} - -int32_t CPDFXFA_Document::AbsPageInBatch(CXFA_FFDoc* hDoc, - CXFA_FFWidget* hWidget) { - return 0; -} - -int32_t CPDFXFA_Document::SheetCountInBatch(CXFA_FFDoc* hDoc) { - return 0; -} - -int32_t CPDFXFA_Document::SheetInBatch(CXFA_FFDoc* hDoc, - CXFA_FFWidget* hWidget) { - return 0; -} - -int32_t CPDFXFA_Document::Verify(CXFA_FFDoc* hDoc, - CXFA_Node* pSigNode, - FX_BOOL bUsed) { - return 0; -} - -FX_BOOL CPDFXFA_Document::Sign(CXFA_FFDoc* hDoc, - CXFA_NodeList* pNodeList, - const CFX_WideStringC& wsExpression, - const CFX_WideStringC& wsXMLIdent, - const CFX_WideStringC& wsValue, - FX_BOOL bUsed) { - return 0; -} - -CXFA_NodeList* CPDFXFA_Document::Enumerate(CXFA_FFDoc* hDoc) { - return 0; -} - -FX_BOOL CPDFXFA_Document::Clear(CXFA_FFDoc* hDoc, - CXFA_Node* pSigNode, - FX_BOOL bCleared) { - return 0; -} - void CPDFXFA_Document::GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) { if (hDoc != m_pXFADoc.get()) return; @@ -830,15 +784,15 @@ FX_ARGB CPDFXFA_Document::GetHighlightColor(CXFA_FFDoc* hDoc) { return 0; } -FX_BOOL CPDFXFA_Document::_NotifySubmit(FX_BOOL bPrevOrPost) { +FX_BOOL CPDFXFA_Document::NotifySubmit(FX_BOOL bPrevOrPost) { if (bPrevOrPost) - return _OnBeforeNotifySumbit(); + return OnBeforeNotifySubmit(); - _OnAfterNotifySumbit(); + OnAfterNotifySubmit(); return TRUE; } -FX_BOOL CPDFXFA_Document::_OnBeforeNotifySumbit() { +FX_BOOL CPDFXFA_Document::OnBeforeNotifySubmit() { if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) return TRUE; @@ -885,7 +839,7 @@ FX_BOOL CPDFXFA_Document::_OnBeforeNotifySumbit() { return TRUE; } -void CPDFXFA_Document::_OnAfterNotifySumbit() { +void CPDFXFA_Document::OnAfterNotifySubmit() { if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) return; @@ -912,27 +866,15 @@ void CPDFXFA_Document::_OnAfterNotifySumbit() { } FX_BOOL CPDFXFA_Document::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { - if (!_NotifySubmit(TRUE) || !m_pXFADocView) + if (!NotifySubmit(TRUE) || !m_pXFADocView) return FALSE; m_pXFADocView->UpdateDocView(); - FX_BOOL ret = _SubmitData(hDoc, submit); - _NotifySubmit(FALSE); + FX_BOOL ret = SubmitDataInternal(hDoc, submit); + NotifySubmit(FALSE); return ret; } -FX_BOOL CPDFXFA_Document::CheckWord(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& sWord) { - return FALSE; -} - -FX_BOOL CPDFXFA_Document::GetSuggestWords( - CXFA_FFDoc* hDoc, - const CFX_ByteStringC& sWord, - std::vector<CFX_ByteString>& sSuggest) { - return FALSE; -} - IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(CXFA_FFDoc* hDoc, const CFX_WideString& wsLink) { CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); @@ -948,10 +890,11 @@ IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(CXFA_FFDoc* hDoc, return nullptr; return new CFPDF_FileStream(pFileHandler); } -FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, - int fileType, - FPDF_DWORD encodeType, - FPDF_DWORD flag) { + +FX_BOOL CPDFXFA_Document::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, + int fileType, + FPDF_DWORD encodeType, + FPDF_DWORD flag) { if (!m_pXFADocView) return FALSE; @@ -1032,13 +975,13 @@ FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, return TRUE; } -void CPDFXFA_Document::_ClearChangeMark() { +void CPDFXFA_Document::ClearChangeMark() { if (m_pSDKDoc) m_pSDKDoc->ClearChangeMark(); } -void CPDFXFA_Document::_ToXFAContentFlags(CFX_WideString csSrcContent, - FPDF_DWORD& flag) { +void CPDFXFA_Document::ToXFAContentFlags(CFX_WideString csSrcContent, + FPDF_DWORD& flag) { if (csSrcContent.Find(L" config ", 0) != -1) flag |= FXFA_CONFIG; if (csSrcContent.Find(L" template ", 0) != -1) @@ -1057,12 +1000,13 @@ void CPDFXFA_Document::_ToXFAContentFlags(CFX_WideString csSrcContent, flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; } -FX_BOOL CPDFXFA_Document::_MailToInfo(CFX_WideString& csURL, - CFX_WideString& csToAddress, - CFX_WideString& csCCAddress, - CFX_WideString& csBCCAddress, - CFX_WideString& csSubject, - CFX_WideString& csMsg) { + +FX_BOOL CPDFXFA_Document::MailToInfo(CFX_WideString& csURL, + CFX_WideString& csToAddress, + CFX_WideString& csCCAddress, + CFX_WideString& csBCCAddress, + CFX_WideString& csSubject, + CFX_WideString& csMsg) { CFX_WideString srcURL = csURL; srcURL.TrimLeft(); if (0 != srcURL.Left(7).CompareNoCase(L"mailto:")) @@ -1130,7 +1074,8 @@ FX_BOOL CPDFXFA_Document::_MailToInfo(CFX_WideString& csURL, return TRUE; } -FX_BOOL CPDFXFA_Document::_SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { +FX_BOOL CPDFXFA_Document::SubmitDataInternal(CXFA_FFDoc* hDoc, + CXFA_Submit submit) { CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); if (!pEnv) return FALSE; @@ -1164,23 +1109,23 @@ FX_BOOL CPDFXFA_Document::_SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { FPDF_DWORD flag = 0; if (submit.IsSubmitEmbedPDF()) flag |= FXFA_PDF; - _ToXFAContentFlags(csContent, flag); + ToXFAContentFlags(csContent, flag); pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb"); fileFlag = FXFA_SAVEAS_XDP; - _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag); + ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag); break; } case XFA_ATTRIBUTEENUM_Xml: pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); fileFlag = FXFA_SAVEAS_XML; - _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0); + ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); break; case XFA_ATTRIBUTEENUM_Pdf: break; case XFA_ATTRIBUTEENUM_Urlencoded: pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); fileFlag = FXFA_SAVEAS_XML; - _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0); + ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); break; default: return false; @@ -1193,8 +1138,8 @@ FX_BOOL CPDFXFA_Document::_SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { CFX_WideString csBCCAddress; CFX_WideString csSubject; CFX_WideString csMsg; - bRet = _MailToInfo(csURL, csToAddress, csCCAddress, csBCCAddress, csSubject, - csMsg); + bRet = MailToInfo(csURL, csToAddress, csCCAddress, csBCCAddress, csSubject, + csMsg); if (!bRet) return FALSE; CFX_ByteString bsTo = CFX_WideString(csToAddress).UTF16LE_Encode(); @@ -1270,9 +1215,3 @@ FX_BOOL CPDFXFA_Document::GetGlobalProperty(CXFA_FFDoc* hDoc, return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName, pValue); } - -CPDF_Document* CPDFXFA_Document::OpenPDF(CXFA_FFDoc* hDoc, - IFX_FileRead* pFile, - FX_BOOL bTakeOverFile) { - return nullptr; -} diff --git a/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h b/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h index c83c770f97..c3abeb2247 100644 --- a/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h +++ b/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h @@ -76,12 +76,6 @@ class CPDFXFA_Document : public IXFA_DocProvider { void WidgetPreRemove(CXFA_FFWidget* hWidget, CXFA_WidgetAcc* pWidgetData) override; - // return true if render it. - FX_BOOL RenderCustomWidget(CXFA_FFWidget* hWidget, - CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - const CFX_RectF& rtUI) override; - // Host method int32_t CountPages(CXFA_FFDoc* hDoc) override; int32_t GetCurrentPage(CXFA_FFDoc* hDoc) override; @@ -93,7 +87,6 @@ class CPDFXFA_Document : public IXFA_DocProvider { void ExportData(CXFA_FFDoc* hDoc, const CFX_WideString& wsFilePath, FX_BOOL bXDP = TRUE) override; - void ImportData(CXFA_FFDoc* hDoc, const CFX_WideString& wsFilePath) override; void GotoURL(CXFA_FFDoc* hDoc, const CFX_WideString& bsURL, FX_BOOL bAppend = TRUE) override; @@ -104,27 +97,6 @@ class CPDFXFA_Document : public IXFA_DocProvider { int32_t nStartPage, int32_t nEndPage, uint32_t dwOptions) override; - - // LayoutPseudo method - int32_t AbsPageCountInBatch(CXFA_FFDoc* hDoc) override; - int32_t AbsPageInBatch(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override; - int32_t SheetCountInBatch(CXFA_FFDoc* hDoc) override; - int32_t SheetInBatch(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override; - - int32_t Verify(CXFA_FFDoc* hDoc, - CXFA_Node* pSigNode, - FX_BOOL bUsed = TRUE) override; - FX_BOOL Sign(CXFA_FFDoc* hDoc, - CXFA_NodeList* pNodeList, - const CFX_WideStringC& wsExpression, - const CFX_WideStringC& wsXMLIdent, - const CFX_WideStringC& wsValue = FX_WSTRC(L"open"), - FX_BOOL bUsed = TRUE) override; - CXFA_NodeList* Enumerate(CXFA_FFDoc* hDoc) override; - FX_BOOL Clear(CXFA_FFDoc* hDoc, - CXFA_Node* pSigNode, - FX_BOOL bCleared = TRUE) override; - // Get document path void GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) override; FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) override; @@ -143,11 +115,6 @@ class CPDFXFA_Document : public IXFA_DocProvider { */ FX_BOOL SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) override; - FX_BOOL CheckWord(CXFA_FFDoc* hDoc, const CFX_ByteStringC& sWord) override; - FX_BOOL GetSuggestWords(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& sWord, - std::vector<CFX_ByteString>& sSuggest) override; - // Get PDF javascript object, set the object to pValue. FX_BOOL GetPDFScriptObject(CXFA_FFDoc* hDoc, const CFX_ByteStringC& utf8Name, @@ -159,29 +126,11 @@ class CPDFXFA_Document : public IXFA_DocProvider { FX_BOOL SetGlobalProperty(CXFA_FFDoc* hDoc, const CFX_ByteStringC& szPropName, CFXJSE_Value* pValue) override; - CPDF_Document* OpenPDF(CXFA_FFDoc* hDoc, - IFX_FileRead* pFile, - FX_BOOL bTakeOverFile) override; IFX_FileRead* OpenLinkedFile(CXFA_FFDoc* hDoc, const CFX_WideString& wsLink) override; - FX_BOOL _OnBeforeNotifySumbit(); - void _OnAfterNotifySumbit(); - FX_BOOL _NotifySubmit(FX_BOOL bPrevOrPost); - FX_BOOL _SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit); - FX_BOOL _MailToInfo(CFX_WideString& csURL, - CFX_WideString& csToAddress, - CFX_WideString& csCCAddress, - CFX_WideString& csBCCAddress, - CFX_WideString& csSubject, - CFX_WideString& csMsg); - FX_BOOL _ExportSubmitFile(FPDF_FILEHANDLER* ppFileHandler, - int fileType, - FPDF_DWORD encodeType, - FPDF_DWORD flag = 0x01111111); - void _ToXFAContentFlags(CFX_WideString csSrcContent, FPDF_DWORD& flag); - void _ClearChangeMark(); + void ClearChangeMark(); private: enum LoadStatus { @@ -200,6 +149,22 @@ class CPDFXFA_Document : public IXFA_DocProvider { } } + FX_BOOL OnBeforeNotifySubmit(); + void OnAfterNotifySubmit(); + FX_BOOL NotifySubmit(FX_BOOL bPrevOrPost); + FX_BOOL SubmitDataInternal(CXFA_FFDoc* hDoc, CXFA_Submit submit); + FX_BOOL MailToInfo(CFX_WideString& csURL, + CFX_WideString& csToAddress, + CFX_WideString& csCCAddress, + CFX_WideString& csBCCAddress, + CFX_WideString& csSubject, + CFX_WideString& csMsg); + FX_BOOL ExportSubmitFile(FPDF_FILEHANDLER* ppFileHandler, + int fileType, + FPDF_DWORD encodeType, + FPDF_DWORD flag); + void ToXFAContentFlags(CFX_WideString csSrcContent, FPDF_DWORD& flag); + int m_iDocType; // |m_pSDKDoc| has to be released before |m_pPDFDoc| since it needs to access |