summaryrefslogtreecommitdiff
path: root/fpdfsdk/include/fpdfxfa
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-10-28 23:03:33 -0700
committerBo Xu <bo_xu@foxitsoftware.com>2014-11-03 11:10:11 -0800
commitfdc00a7042d912aafaabddae4d9c84199921ef23 (patch)
tree32ab8ac91cc68d2cd15b9168782a71b3f3f5e7b9 /fpdfsdk/include/fpdfxfa
parente9b38fa38de2c95d8260be31c57d9272c4d127ed (diff)
downloadpdfium-fdc00a7042d912aafaabddae4d9c84199921ef23.tar.xz
Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
Diffstat (limited to 'fpdfsdk/include/fpdfxfa')
-rw-r--r--fpdfsdk/include/fpdfxfa/fpdfxfa_app.h140
-rw-r--r--fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h148
-rw-r--r--fpdfsdk/include/fpdfxfa/fpdfxfa_page.h50
-rw-r--r--fpdfsdk/include/fpdfxfa/fpdfxfa_util.h50
4 files changed, 388 insertions, 0 deletions
diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h
new file mode 100644
index 0000000000..c77aae3b12
--- /dev/null
+++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h
@@ -0,0 +1,140 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _FPDFXFA_APP_H_
+#define _FPDFXFA_APP_H_
+
+class CPDFXFA_App;
+class IFXJS_Runtime;
+class CJS_RuntimeFactory;
+
+class CPDFXFA_App : public IXFA_AppProvider, public CFX_Object
+{
+public:
+ CPDFXFA_App();
+ ~CPDFXFA_App();
+
+ FX_BOOL Initialize();
+
+ IXFA_App* GetXFAApp() { return m_pXFAApp; }
+
+
+ /*CPDFDoc_Environment*GetFormFillEnv(){ return m_pEnv; }*/
+ FX_BOOL AddFormFillEnv(CPDFDoc_Environment* pEnv);
+ FX_BOOL RemoveFormFillEnv(CPDFDoc_Environment* pEnv);
+
+ FXJSE_HRUNTIME GetJSERuntime() { return m_hJSERuntime; }
+
+ void ReleaseRuntime();
+
+ FX_BOOL InitRuntime(FX_BOOL bReset = FALSE) {
+ if (bReset) {
+ m_bInitRuntime = FALSE;
+ return TRUE;
+ }
+ if (m_bInitRuntime)
+ return TRUE;
+ m_bInitRuntime = TRUE;
+ return FALSE;
+ }
+
+ //IFXJS_Runtime* GetJSRuntime();
+
+ CJS_RuntimeFactory* GetRuntimeFactory() {return m_pJSRuntimeFactory;}
+
+public:
+ /**
+ *Specifies the name of the client application in which a form currently exists. Such as Exchange-Pro.
+ */
+ virtual void GetAppType(CFX_WideString &wsAppType);
+ virtual void SetAppType(FX_WSTR wsAppType) ;
+ virtual void SetFoxitAppType(FX_WSTR wsFoxitAppType) { return; }
+ virtual void GetFoxitAppType(CFX_WideString &wsFoxitAppType) { return; }
+ virtual void GetFoxitAppName(CFX_WideString& wsFoxitName) {wsFoxitName = L"Foxit";}
+ virtual void GetFoxitVersion(CFX_WideString &wsFoxitVersion) {wsFoxitVersion = L"7.0";}
+ /**
+ *Returns the language of the running host application. Such as zh_CN
+ */
+ virtual void GetLanguage(CFX_WideString &wsLanguage);
+ /**
+ *Returns the platform of the machine running the script. Such as WIN
+ */
+ virtual void GetPlatform(CFX_WideString &wsPlatform);
+ /**
+ * Indicates the packaging of the application that is running the script. Such as Full
+ */
+ virtual void GetVariation(CFX_WideString &wsVariation);
+ /**
+ * Indicates the version number of the current application. Such as 9
+ */
+ virtual void GetVersion(CFX_WideString &wsVersion);
+ //Get application name, such as Phantom
+ virtual void GetAppName(CFX_WideString& wsName);
+ /**
+ *Causes the system to play a sound.
+ * @param[in] dwType The system code for the appropriate sound.0 (Error)1 (Warning)2 (Question)3 (Status)4 (Default)
+ */
+ virtual void Beep(FX_DWORD dwType);
+ /**
+ * Displays a message box.
+ * @param[in] dwIconType Icon type, refer to XFA_MBICON.
+ * @param[in] dwButtonType Button type, refer to XFA_MESSAGEBUTTON.
+ * @return A valid integer representing the value of the button pressed by the user, refer to XFA_ID.
+ */
+ virtual FX_INT32 MsgBox(FX_WSTR wsMessage, FX_WSTR wsTitle = FX_WSTRC(L""), FX_DWORD dwIconType = 0, FX_DWORD dwButtonType = 0);
+ //bMark True (default) Masks the user¡¯s answer with * (asterisks). False Does not mask the user¡¯s answer.
+ virtual void Response(CFX_WideString &wsAnswer, FX_WSTR wsQuestion, FX_WSTR wsTitle = FX_WSTRC(L""), FX_WSTR wsDefaultAnswer = FX_WSTRC(L""), FX_BOOL bMark = TRUE);
+ virtual FX_INT32 GetDocumentCountInBatch();
+ virtual FX_INT32 GetCurDocumentInBatch();
+ //wsURL http, ftp, such as "http://www.w3.org/TR/REC-xml-names/".
+ virtual IFX_FileRead* DownloadURL(FX_WSTR wsURL);
+ /*
+ * Post data to the given url.
+ * @param[in] wsURL the URL being uploaded.
+ * @param[in] wsData the data being uploaded.
+ * @param[in] wsContentType the content type of data including text/html, text/xml, text/plain, multipart/form-data,
+ * application/x-www-form-urlencoded, application/octet-stream, any valid MIME type.
+ * @param[in] wsEncode the encode of data including UTF-8, UTF-16, ISO8859-1, any recognized [IANA]character encoding
+ * @param[in] wsHeader any additional HTTP headers to be included in the post.
+ * @param[out] wsResponse decoded response from server.
+ * @return TRUE Server permitted the post request, FALSE otherwise.
+ */
+ virtual FX_BOOL PostRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_WSTR wsContentType,
+ FX_WSTR wsEncode, FX_WSTR wsHeader, CFX_WideString &wsResponse);
+
+ /*
+ * Put data to the given url.
+ * @param[in] wsURL the URL being uploaded.
+ * @param[in] wsData the data being uploaded.
+ * @param[in] wsEncode the encode of data including UTF-8, UTF-16, ISO8859-1, any recognized [IANA]character encoding
+ * @return TRUE Server permitted the post request, FALSE otherwise.
+ */
+ virtual FX_BOOL PutRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_WSTR wsEncode);
+
+ virtual void LoadString(FX_INT32 iStringID, CFX_WideString &wsString);
+ virtual FX_BOOL ShowFileDialog(FX_WSTR wsTitle, FX_WSTR wsFilter, CFX_WideStringArray &wsPathArr, FX_BOOL bOpen = TRUE);
+ virtual IFWL_AdapterTimerMgr* GetTimerMgr();
+
+ CFX_ArrayTemplate<CPDFDoc_Environment*> m_pEnvList;
+
+public:
+ static CPDFXFA_App* m_pApp;
+
+private:
+ IXFA_App* m_pXFAApp;
+ IXFA_FontMgr* m_pFontMgr;
+ FXJSE_HRUNTIME m_hJSERuntime;
+ IFXJS_Runtime* m_pJSRuntime;
+ CJS_RuntimeFactory* m_pJSRuntimeFactory;
+
+ CFX_WideString m_csAppType;
+ FX_BOOL m_bInitRuntime;
+};
+
+CPDFXFA_App* FPDFXFA_GetApp();
+void FPDFXFA_ReleaseApp();
+
+#endif
diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h
new file mode 100644
index 0000000000..fadded858f
--- /dev/null
+++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h
@@ -0,0 +1,148 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _FPDFXFA_DOC_H_
+#define _FPDFXFA_DOC_H_
+
+class CPDFXFA_App;
+class CPDFXFA_Document;
+class CPDFXFA_Page;
+class CPDFSDK_Document;
+class CPDFDoc_Environment;
+class IFXJS_Runtime;
+class IFXJS_Context;
+
+class CPDFXFA_Document : public IXFA_DocProvider, public CFX_Object
+{
+public:
+ CPDFXFA_Document(CPDF_Document* pPDFDoc, CPDFXFA_App* pProvider);
+ ~CPDFXFA_Document();
+
+ FX_BOOL LoadXFADoc();
+ void CloseXFADoc();
+ CPDFXFA_App* GetApp() {return m_pApp;}
+ CPDF_Document* GetPDFDoc() { return m_pPDFDoc; }
+ XFA_HDOC GetXFADoc() { return m_pXFADoc; }
+ IXFA_DocView* GetXFADocView() { return m_pXFADocView; }
+
+ int GetPageCount();
+ CPDFXFA_Page* GetPage(int page_index);
+ CPDFXFA_Page* GetPage(IXFA_PageView* pPage);
+ void RemovePage(CPDFXFA_Page* page);
+ int GetDocType(){ return m_iDocType; }
+
+ CPDFSDK_Document* GetSDKDocument(CPDFDoc_Environment* pFormFillEnv);
+ void ReleaseSDKDoc();
+
+ void FXRect2PDFRect(const CFX_RectF& fxRectF, CPDF_Rect& pdfRect);
+
+public:
+ virtual void SetChangeMark(XFA_HDOC hDoc);
+ virtual FX_BOOL GetChangeMark(XFA_HDOC hDoc);
+ //used in dynamic xfa, dwFlags refer to XFA_INVALIDATE_XXX macros.
+ virtual void InvalidateRect(IXFA_PageView* pPageView, const CFX_RectF& rt, FX_DWORD dwFlags = 0);
+ //used in static xfa, dwFlags refer to XFA_INVALIDATE_XXX macros.
+ virtual void InvalidateRect(XFA_HWIDGET hWidget, FX_DWORD dwFlags = 0);
+ //show or hide caret
+ virtual void DisplayCaret(XFA_HWIDGET hWidget, FX_BOOL bVisible, const CFX_RectF* pRtAnchor);
+ //dwPos: (0:bottom 1:top)
+ virtual FX_BOOL GetPopupPos(XFA_HWIDGET hWidget, FX_FLOAT fMinPopup, FX_FLOAT fMaxPopup,
+ const CFX_RectF &rtAnchor, CFX_RectF &rtPopup);
+ virtual FX_BOOL PopupMenu(XFA_HWIDGET hWidget, CFX_PointF ptPopup, const CFX_RectF* pRectExclude = NULL);
+
+ //dwFlags XFA_PAGEVIEWEVENT_Added, XFA_PAGEVIEWEVENT_Removing
+ virtual void PageViewEvent(IXFA_PageView* pPageView, FX_DWORD dwFlags);
+ //dwEvent refer to XFA_WIDGETEVENT_XXX
+ virtual void WidgetEvent(XFA_HWIDGET hWidget, CXFA_WidgetAcc* pWidgetData, FX_DWORD dwEvent, FX_LPVOID pParam = NULL, FX_LPVOID pAdditional = NULL);
+
+ //return true if render it.
+ virtual FX_BOOL RenderCustomWidget(XFA_HWIDGET hWidget, CFX_Graphics* pGS, CFX_Matrix* pMatrix, const CFX_RectF& rtUI){return FALSE;}
+
+ //host method
+ virtual FX_INT32 CountPages(XFA_HDOC hDoc);
+ virtual FX_INT32 GetCurrentPage(XFA_HDOC hDoc);
+ virtual void SetCurrentPage(XFA_HDOC hDoc, FX_INT32 iCurPage);
+ virtual FX_BOOL IsCalculationsEnabled(XFA_HDOC hDoc);
+ virtual void SetCalculationsEnabled(XFA_HDOC hDoc, FX_BOOL bEnabled);
+ virtual void GetTitle(XFA_HDOC hDoc, CFX_WideString &wsTitle);
+ virtual void SetTitle(XFA_HDOC hDoc, FX_WSTR wsTitle);
+ virtual void ExportData(XFA_HDOC hDoc, FX_WSTR wsFilePath, FX_BOOL bXDP = TRUE);
+ virtual void ImportData(XFA_HDOC hDoc, FX_WSTR wsFilePath);
+ virtual void GotoURL(XFA_HDOC hDoc, FX_WSTR bsURL, FX_BOOL bAppend = TRUE);
+ virtual FX_BOOL IsValidationsEnabled(XFA_HDOC hDoc);
+ virtual void SetValidationsEnabled(XFA_HDOC hDoc, FX_BOOL bEnabled);
+ virtual void SetFocusWidget(XFA_HDOC hDoc, XFA_HWIDGET hWidget);
+ virtual void Print(XFA_HDOC hDoc, FX_INT32 nStartPage, FX_INT32 nEndPage, FX_DWORD dwOptions);
+
+ //LayoutPseudo method
+ virtual FX_INT32 AbsPageCountInBatch(XFA_HDOC hDoc){return 0;}
+ virtual FX_INT32 AbsPageInBatch(XFA_HDOC hDoc, XFA_HWIDGET hWidget){return 0;}
+ virtual FX_INT32 SheetCountInBatch(XFA_HDOC hDoc){return 0;}
+ virtual FX_INT32 SheetInBatch(XFA_HDOC hDoc, XFA_HWIDGET hWidget){return 0;}
+
+ //SignaturePseudoModel method
+ //TODO:
+ virtual FX_INT32 Verify(XFA_HDOC hDoc, CXFA_Node* pSigNode, FX_BOOL bUsed = TRUE/*, SecurityHandler* pHandler, SignatureInfo &info*/) {return 0;}
+ virtual FX_BOOL Sign(XFA_HDOC hDoc, CXFA_NodeList* pNodeList, FX_WSTR wsExpression, FX_WSTR wsXMLIdent, FX_WSTR wsValue = FX_WSTRC(L"open"), FX_BOOL bUsed = TRUE/*, SecurityHandler* pHandler = NULL, SignatureInfo &info*/) {return 0;}
+ virtual CXFA_NodeList* Enumerate(XFA_HDOC hDoc) {return 0;}
+ virtual FX_BOOL Clear(XFA_HDOC hDoc, CXFA_Node* pSigNode, FX_BOOL bCleared = TRUE) {return 0;}
+
+ //Get document path
+ virtual void GetURL(XFA_HDOC hDoc, CFX_WideString &wsDocURL);
+ virtual FX_ARGB GetHighlightColor(XFA_HDOC hDoc);
+ virtual void AddDoRecord(XFA_HWIDGET hWidget);
+ /**
+ *Submit data to email, http, ftp.
+ * @param[in] hDoc The document handler.
+ * @param[in] eFormat Determines the format in which the data will be submitted. XFA_ATTRIBUTEENUM_Xdp, XFA_ATTRIBUTEENUM_Xml...
+ * @param[in] wsTarget The URL to which the data will be submitted.
+ * @param[in] eEncoding The encoding of text content.
+ * @param[in] pXDPContent Controls what subset of the data is submitted, used only when the format property is xdp.
+ * @param[in] bEmbedPDF, specifies whether PDF is embedded in the submitted content or not.
+ */
+ virtual FX_BOOL SubmitData(XFA_HDOC hDoc, CXFA_Submit submit);
+
+ virtual FX_BOOL CheckWord(XFA_HDOC hDoc, FX_BSTR sWord){return FALSE;}
+ virtual FX_BOOL GetSuggestWords(XFA_HDOC hDoc, FX_BSTR sWord, CFX_ByteStringArray& sSuggest){return FALSE;}
+
+ //Get PDF javascript object, set the object to hValue.
+ virtual FX_BOOL GetPDFScriptObject(XFA_HDOC hDoc, FX_BSTR utf8Name, FXJSE_HVALUE hValue);
+
+ virtual FX_BOOL GetGlobalProperty(XFA_HDOC hDoc, FX_BSTR szPropName, FXJSE_HVALUE hValue);
+ virtual FX_BOOL SetGlobalProperty(XFA_HDOC hDoc, FX_BSTR szPropName, FXJSE_HVALUE hValue);
+ virtual CPDF_Document* OpenPDF(XFA_HDOC hDoc, IFX_FileRead* pFile, FX_BOOL bTakeOverFile){return NULL;}
+
+ virtual IFX_FileRead* OpenLinkedFile(XFA_HDOC hDoc, const CFX_WideString& wsLink);
+
+ FX_BOOL _GetHValueByName(FX_BSTR utf8Name, FXJSE_HVALUE hValue, IFXJS_Runtime* runTime);
+ FX_BOOL _OnBeforeNotifySumbit();
+ void _OnAfterNotifySumbit();
+ FX_BOOL _NotifySubmit(FX_BOOL bPrevOrPost);
+ FX_BOOL _SubmitData(XFA_HDOC 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();
+
+private:
+ CPDF_Document* m_pPDFDoc;
+ XFA_HDOC m_pXFADoc;
+ IXFA_DocView* m_pXFADocView;
+ CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList;
+
+ CPDFSDK_Document* m_pSDKDoc;
+ CPDFXFA_App* m_pApp;
+
+ CFX_MapByteStringToPtr m_XfaGlobalProperty;
+
+ CFX_MapByteStringToPtr m_ValueMap;
+
+ IFXJS_Context* m_pJSContext;
+
+ int m_iDocType;
+};
+
+#endif
diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_page.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_page.h
new file mode 100644
index 0000000000..1d60c33e43
--- /dev/null
+++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_page.h
@@ -0,0 +1,50 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _FPDFXFA_PAGEVIEW_H_
+#define _FPDFXFA_PAGEVIEW_H_
+
+class CPDFXFA_Page;
+
+class CPDFXFA_Page : public CFX_Object
+{
+public:
+ CPDFXFA_Page(CPDFXFA_Document* pDoc, int page_index);
+ ~CPDFXFA_Page();
+
+ void Release();
+ void AddRef(){ m_iRef ++; }
+ FX_BOOL LoadPage();
+ FX_BOOL LoadPDFPage(CPDF_Dictionary* pageDict);
+ CPDFXFA_Document* GetDocument() { return m_pDocument; }
+ int GetPageIndex() { return m_iPageIndex; }
+ CPDF_Page* GetPDFPage() { return m_pPDFPage; }
+ IXFA_PageView* GetXFAPageView() { return m_pXFAPageView; }
+
+ FX_FLOAT GetPageWidth();
+ FX_FLOAT GetPageHeight();
+
+ void DeviceToPage(int start_x, int start_y, int size_x, int size_y,
+ int rotate, int device_x, int device_y, double* page_x, double* page_y);
+ void PageToDevice(int start_x, int start_y, int size_x, int size_y,
+ int rotate, double page_x, double page_y, int* device_x, int* device_y);
+
+ void GetDisplayMatrix(CFX_AffineMatrix& matrix, int xPos, int yPos,
+ int xSize, int ySize, int iRotate) const;
+
+protected:
+ FX_BOOL LoadPDFPage();
+ FX_BOOL LoadXFAPageView();
+
+private:
+ CPDF_Page* m_pPDFPage;
+ IXFA_PageView* m_pXFAPageView;
+ int m_iPageIndex;
+ CPDFXFA_Document* m_pDocument;
+ int m_iRef;
+};
+
+#endif
diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h
new file mode 100644
index 0000000000..07ea65f2b1
--- /dev/null
+++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h
@@ -0,0 +1,50 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _FPDFXFA_UTIL_H_
+#define _FPDFXFA_UTIL_H_
+
+#define DOCTYPE_PDF 0
+#define DOCTYPE_DYNIMIC_XFA 1 //Dynimic xfa Document Type
+#define DOCTYPE_STATIC_XFA 2 //Static xfa Document Type
+
+#define JS_STR_VIEWERTYPE_STANDARD L"Exchange"
+#define JS_STR_LANGUANGE L"ENU"
+#define JS_STR_VIEWERVARIATION L"Full"
+#define JS_STR_VIEWERVERSION_XFA L"11"
+
+FX_BOOL FPDF_HasXFAField(CPDF_Document* pPDFDoc, int& docType);
+
+class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr, public CFX_Object
+{
+public:
+ CXFA_FWLAdapterTimerMgr(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv)
+ {
+
+ }
+ virtual FWL_ERR Start(IFWL_Timer *pTimer, FX_DWORD dwElapse, FWL_HTIMER &hTimer, FX_BOOL bImmediately = TRUE);
+ virtual FWL_ERR Stop(FWL_HTIMER hTimer);
+
+protected:
+ static void TimerProc(FX_INT32 idEvent);
+
+ static CFX_PtrArray ms_timerArray;
+ CPDFDoc_Environment* m_pEnv;
+};
+
+class CFWL_TimerInfo : public CFX_Object
+{
+public:
+ CFWL_TimerInfo()
+ : pTimer(NULL)
+ {
+
+ }
+ FX_UINT32 uIDEvent;
+ IFWL_Timer *pTimer;
+};
+
+#endif