summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/include/formfiller/FFL_ComboBox.h2
-rw-r--r--fpdfsdk/include/formfiller/FFL_FormFiller.h1
-rw-r--r--fpdfsdk/include/formfiller/FFL_IFormFiller.h6
-rw-r--r--fpdfsdk/include/formfiller/FFL_Notify.h1
-rw-r--r--fpdfsdk/include/formfiller/FFL_TextField.h2
-rw-r--r--fpdfsdk/include/fpdf_dataavail.h2
-rw-r--r--fpdfsdk/include/fpdf_flatten.h5
-rw-r--r--fpdfsdk/include/fpdf_progressive.h8
-rw-r--r--fpdfsdk/include/fpdf_transformpage.h7
-rw-r--r--fpdfsdk/include/fpdfdoc.h4
-rw-r--r--fpdfsdk/include/fpdfedit.h34
-rw-r--r--fpdfsdk/include/fpdfformfill.h412
-rw-r--r--fpdfsdk/include/fpdfppo.h3
-rw-r--r--fpdfsdk/include/fpdftext.h2
-rw-r--r--fpdfsdk/include/fpdfview.h127
-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
-rw-r--r--fpdfsdk/include/fsdk_annothandler.h89
-rw-r--r--fpdfsdk/include/fsdk_baseannot.h69
-rw-r--r--fpdfsdk/include/fsdk_baseform.h85
-rw-r--r--fpdfsdk/include/fsdk_define.h38
-rw-r--r--fpdfsdk/include/fsdk_mgr.h412
-rw-r--r--fpdfsdk/include/javascript/IJavaScript.h2
-rw-r--r--fpdfsdk/include/javascript/JS_Context.h2
-rw-r--r--fpdfsdk/include/javascript/JS_Define.h56
-rw-r--r--fpdfsdk/include/javascript/JS_GlobalData.h1
-rw-r--r--fpdfsdk/include/javascript/JS_Object.h15
-rw-r--r--fpdfsdk/include/javascript/JS_Runtime.h16
-rw-r--r--fpdfsdk/include/javascript/JavaScript.h1
-rw-r--r--fpdfsdk/include/pdfwindow/PWL_Edit.h3
-rw-r--r--fpdfsdk/src/formfiller/FFL_ComboBox.cpp13
-rw-r--r--fpdfsdk/src/formfiller/FFL_FormFiller.cpp11
-rw-r--r--fpdfsdk/src/formfiller/FFL_IFormFiller.cpp202
-rw-r--r--fpdfsdk/src/formfiller/FFL_TextField.cpp12
-rw-r--r--fpdfsdk/src/fpdf_dataavail.cpp13
-rw-r--r--fpdfsdk/src/fpdf_ext.cpp3
-rw-r--r--fpdfsdk/src/fpdf_flatten.cpp7
-rw-r--r--fpdfsdk/src/fpdf_progressive.cpp13
-rw-r--r--fpdfsdk/src/fpdf_transformpage.cpp22
-rw-r--r--fpdfsdk/src/fpdfdoc.cpp22
-rw-r--r--fpdfsdk/src/fpdfeditimg.cpp15
-rw-r--r--fpdfsdk/src/fpdfeditpage.cpp44
-rw-r--r--fpdfsdk/src/fpdfformfill.cpp459
-rw-r--r--fpdfsdk/src/fpdfppo.cpp25
-rw-r--r--fpdfsdk/src/fpdfsave.cpp275
-rw-r--r--fpdfsdk/src/fpdftext.cpp10
-rw-r--r--fpdfsdk/src/fpdfview.cpp360
-rw-r--r--fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp640
-rw-r--r--fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp1476
-rw-r--r--fpdfsdk/src/fpdfxfa/fpdfxfa_page.cpp276
-rw-r--r--fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp96
-rw-r--r--fpdfsdk/src/fsdk_actionhandler.cpp5
-rw-r--r--fpdfsdk/src/fsdk_annothandler.cpp494
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp130
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp843
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp337
-rw-r--r--fpdfsdk/src/javascript/Document.cpp26
-rw-r--r--fpdfsdk/src/javascript/Field.cpp2
-rw-r--r--fpdfsdk/src/javascript/JS_Context.cpp1
-rw-r--r--fpdfsdk/src/javascript/JS_GlobalData.cpp2
-rw-r--r--fpdfsdk/src/javascript/JS_Object.cpp4
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp74
-rw-r--r--fpdfsdk/src/javascript/app.cpp25
-rw-r--r--fpdfsdk/src/javascript/global.cpp5
-rw-r--r--fpdfsdk/src/jsapi/fxjs_v8.cpp51
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp36
68 files changed, 7240 insertions, 582 deletions
diff --git a/fpdfsdk/include/formfiller/FFL_ComboBox.h b/fpdfsdk/include/formfiller/FFL_ComboBox.h
index 6df8347a76..e3ad8b1c22 100644
--- a/fpdfsdk/include/formfiller/FFL_ComboBox.h
+++ b/fpdfsdk/include/formfiller/FFL_ComboBox.h
@@ -40,6 +40,8 @@ public:
virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue);
virtual void OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag);
+ virtual FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView);
+
public:
virtual void OnSetFocus(CPWL_Wnd* pWnd);
virtual void OnKillFocus(CPWL_Wnd* pWnd);
diff --git a/fpdfsdk/include/formfiller/FFL_FormFiller.h b/fpdfsdk/include/formfiller/FFL_FormFiller.h
index 7a3402a7f9..18426a91ba 100644
--- a/fpdfsdk/include/formfiller/FFL_FormFiller.h
+++ b/fpdfsdk/include/formfiller/FFL_FormFiller.h
@@ -120,6 +120,7 @@ public:
virtual void SaveData(CPDFSDK_PageView* pPageView);
virtual void GetKeyStrokeData(CPDFSDK_PageView* pPageView, FFL_KeyStrokeData& data);
+ virtual FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView);
public:
CPWL_Wnd* GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNew);
diff --git a/fpdfsdk/include/formfiller/FFL_IFormFiller.h b/fpdfsdk/include/formfiller/FFL_IFormFiller.h
index 393f0be331..1b33edd4e8 100644
--- a/fpdfsdk/include/formfiller/FFL_IFormFiller.h
+++ b/fpdfsdk/include/formfiller/FFL_IFormFiller.h
@@ -76,6 +76,8 @@ public:
virtual void OnSetWindowRect(void* pPrivateData, const CPDF_Rect & rcWindow);
virtual void OnKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_INT32 nKeyCode, CFX_WideString & strChange,
const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit);
+ virtual void OnPopupPreOpen(void* pPrivateData, FX_BOOL& bExit, FX_DWORD nFlag);
+ virtual void OnPopupPostOpen(void* pPrivateData, FX_BOOL& bExit, FX_DWORD nFlag);
public:
virtual void BeforeUndo(CPDFSDK_Document* pDocument);
@@ -116,6 +118,10 @@ public:
static int GetCommitKey();
static FX_BOOL GetKeyDown();
+ void OnClick(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag);
+ void OnFull(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag);
+ void OnPreOpen(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag);
+ void OnPostOpen(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag);
public:
// static MSG g_Msg;
diff --git a/fpdfsdk/include/formfiller/FFL_Notify.h b/fpdfsdk/include/formfiller/FFL_Notify.h
index cabc1aa113..c729b7452b 100644
--- a/fpdfsdk/include/formfiller/FFL_Notify.h
+++ b/fpdfsdk/include/formfiller/FFL_Notify.h
@@ -45,6 +45,7 @@ private:
FX_BOOL ExecuteActionTree(CPDF_AAction::AActionType eAAT, CPDF_Action & action, FX_BOOL& bExit);
FX_BOOL ExecuteAction(CPDF_AAction::AActionType eAAT,CPDF_Action & action,FX_BOOL& bExit);
+ CFFL_FormFiller * m_pFormFiller;
FX_BOOL m_bDoActioning;
FX_INT32 m_nNotifyFlag;
};
diff --git a/fpdfsdk/include/formfiller/FFL_TextField.h b/fpdfsdk/include/formfiller/FFL_TextField.h
index 3a5fd688b0..53ddfb7245 100644
--- a/fpdfsdk/include/formfiller/FFL_TextField.h
+++ b/fpdfsdk/include/formfiller/FFL_TextField.h
@@ -60,6 +60,8 @@ public:
virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue);
+ virtual FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView);
+
public:
virtual void OnSetFocus(CPWL_Wnd* pWnd);
virtual void OnKillFocus(CPWL_Wnd* pWnd);
diff --git a/fpdfsdk/include/fpdf_dataavail.h b/fpdfsdk/include/fpdf_dataavail.h
index 971ab2505c..fb061b9bfa 100644
--- a/fpdfsdk/include/fpdf_dataavail.h
+++ b/fpdfsdk/include/fpdf_dataavail.h
@@ -64,6 +64,8 @@ typedef void* FPDF_AVAIL;
* A handle to the document availability provider. NULL for error.
* Comments:
* Application must call FPDFAvail_Destroy when done with the availability provider.
+* Notes:
+* The method can not support to load a document which consists of dynamic XFA fields now.
*/
DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, FPDF_FILEACCESS* file);
diff --git a/fpdfsdk/include/fpdf_flatten.h b/fpdfsdk/include/fpdf_flatten.h
index 2e9e5092f9..0c555138ab 100644
--- a/fpdfsdk/include/fpdf_flatten.h
+++ b/fpdfsdk/include/fpdf_flatten.h
@@ -29,9 +29,12 @@ extern "C" {
//Return value:
// The result flag of the function, See flags above ( FLATTEN_FAIL, FLATTEN_SUCCESS, FLATTEN_NOTINGTODO ).
//
- // Comments: Current version all fails return zero. If necessary we will assign different value
+ //Comments: Current version all fails return zero. If necessary we will assign different value
// to indicate different fail reason.
//
+ //Notes:
+ // The method can not support to flatten the page which the document consists of dynamic XFA fields.
+ //
DLLEXPORT int STDCALL FPDFPage_Flatten( FPDF_PAGE page, int nFlag);
diff --git a/fpdfsdk/include/fpdf_progressive.h b/fpdfsdk/include/fpdf_progressive.h
index 029264eae2..69bbfba4cd 100644
--- a/fpdfsdk/include/fpdf_progressive.h
+++ b/fpdfsdk/include/fpdf_progressive.h
@@ -64,6 +64,8 @@ typedef struct _IFSDK_PAUSE
// pause - The IFSDK_PAUSE interface.A callback mechanism allowing the page rendering process
// Return value:
// Rendering Status. See flags for progressive process status for the details.
+// Notes:
+// The method cannot not support to render page which the document consists of dynamic XFA fields.
//
DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, int size_x,
int size_y, int rotate, int flags,IFSDK_PAUSE * pause);
@@ -76,6 +78,9 @@ DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, FPDF_PAGE
// to be paused before it's finished. This can be NULL if you don't want to pause.
// Return value:
// The rendering status. See flags for progressive process status for the details.
+// Notes:
+// The method cannot not support to render page which the document consists of dynamic XFA fields.
+//
DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page,IFSDK_PAUSE * pause);
// Function: FPDF_RenderPage_Close
@@ -85,6 +90,9 @@ DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page,IFSDK_PAUSE * paus
// page - Handle to the page. Returned by FPDF_LoadPage function.
// Return value:
// NULL
+// Notes:
+// The method cannot not support to render page which the document consists of dynamic XFA fields.
+//
DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page);
#ifdef __cplusplus
diff --git a/fpdfsdk/include/fpdf_transformpage.h b/fpdfsdk/include/fpdf_transformpage.h
index 69ffe24009..32b0ea008c 100644
--- a/fpdfsdk/include/fpdf_transformpage.h
+++ b/fpdfsdk/include/fpdf_transformpage.h
@@ -21,6 +21,7 @@ typedef void* FPDF_PAGEARCLOADER;
* @param[in] right - The right of the rectangle.
* @param[in] top - The top of the rectangle.
* @retval None.
+* @note The method can not support to set this feature for the document which consists of dynamic XFA fields.
*/
DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page, float left, float bottom, float right, float top);
@@ -32,6 +33,7 @@ DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page, float left, float bo
* @param[in] right - The right of the rectangle.
* @param[in] top - The top of the rectangle.
* @retval None.
+* @note The method can not support to set this feature for the document which consists of dynamic XFA fields.
*/
DLLEXPORT void STDCALL FPDFPage_SetCropBox(FPDF_PAGE page, float left, float bottom, float right, float top);
@@ -43,6 +45,7 @@ DLLEXPORT void STDCALL FPDFPage_SetCropBox(FPDF_PAGE page, float left, float bot
* @param[in] right - Pointer to a double value receiving the right of the rectangle.
* @param[in] top - Pointer to a double value receiving the top of the rectangle.
* @retval True if success,else fail.
+* @note The method can not support to get this feature for the document which consists of dynamic XFA fields.
*/
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetMediaBox(FPDF_PAGE page, float* left, float* bottom, float* right, float* top);
@@ -53,6 +56,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetMediaBox(FPDF_PAGE page, float* left, fl
* @param[in] right - Pointer to a double value receiving the right of the rectangle.
* @param[in] top - Pointer to a double value receiving the top of the rectangle.
* @retval True if success,else fail.
+* @note The method can not support to get this feature for the document which consists of dynamic XFA fields.
*/
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetCropBox(FPDF_PAGE page, float* left, float* bottom, float* right, float* top);
@@ -63,6 +67,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetCropBox(FPDF_PAGE page, float* left, flo
* @param[in] matrix - The transform matrix.
* @param[in] clipRect - A rectangle page area to be clipped.
* @Note. This function will transform the whole page, and would take effect to all the objects in the page.
+* The method can not support to get this feature for the document which consists of dynamic XFA fields.
*/
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, FS_MATRIX* matrix, FS_RECTF* clipRect);
@@ -105,7 +110,7 @@ DLLEXPORT void STDCALL FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath);
* @param[in] page - A page handle.
* @param[in] clipPath - A handle to the clip path.
* @Note. A clip path will be inserted before the page content stream or content array. In this way, the page content will be clipped
-* by this clip path.
+* by this clip path. The method can not support this feature for the document consists of dynamic XFA fields.
*/
DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,FPDF_CLIPPATH clipPath);
diff --git a/fpdfsdk/include/fpdfdoc.h b/fpdfsdk/include/fpdfdoc.h
index 54ede4037a..da49ba062a 100644
--- a/fpdfsdk/include/fpdfdoc.h
+++ b/fpdfsdk/include/fpdfdoc.h
@@ -116,6 +116,8 @@ DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FP
// Comments:
// The point coordinates are specified in page coordinate system. You can convert coordinates
// from screen system to page system using FPDF_DeviceToPage functions.
+// Notes:
+// The method can not support this feature for the document consists of dynamic XFA fields.
//
DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y);
@@ -148,6 +150,8 @@ DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK link);
// linkAnnot[out] - Receive the link handle.
// Return value:
// TRUE if succceed, else False;
+// Notes:
+// The method can not support this feature for the document consists of dynamic XFA fields.
//
DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FPDF_LINK* linkAnnot);
diff --git a/fpdfsdk/include/fpdfedit.h b/fpdfsdk/include/fpdfedit.h
index 18b816843a..3be2fd3112 100644
--- a/fpdfsdk/include/fpdfedit.h
+++ b/fpdfsdk/include/fpdfedit.h
@@ -34,6 +34,7 @@ extern "C" {
// None.
// Return value:
// A handle to a document. If failed, NULL is returned.
+//
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument();
//////////////////////////////////////////////////////////////////////
@@ -53,6 +54,9 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument();
// The handle to the page.
// Comments:
// Loaded page can be deleted by FPDFPage_Delete.
+// Notes:
+// The method can not support to create a new page for the document consists of dynamic XFA fields.
+//
DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index, double width, double height);
// Function: FPDFPage_Delete
@@ -62,6 +66,9 @@ DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index,
// page_index - The index of a page.
// Return value:
// None.
+// Notes:
+// The method can not support to delete page for the document consists of dynamic XFA fields.
+//
DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index);
// Function: FPDFPage_GetRotation
@@ -72,6 +79,9 @@ DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index);
// The PDF page rotation.
// Comment:
// The PDF page rotation is rotated clockwise.
+// Notes:
+// The method can not support to get the page rotate for the document consists of dynamic XFA fields.
+//
DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page);
// Function: FPDFPage_SetRotation
@@ -83,6 +93,8 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page);
// None.
// Comment:
// The PDF page rotation is rotated clockwise.
+// Notes:
+// The method can not support to set this feature for the document consists of dynamic XFA fields.
//
DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate);
@@ -94,6 +106,9 @@ DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate);
// FPDFPageObj_NewPathObj.
// Return value:
// None.
+// Notes:
+// The method can not support this feature for the document consists of dynamic XFA fields.
+//
DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj);
// Function: FPDFPage_CountObject
@@ -102,6 +117,9 @@ DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT pag
// page - Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
// Return value:
// The number of the page object.
+// Notes:
+// The method can not support this feature for the document consists of dynamic XFA fields.
+//
DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page);
// Function: FPDFPage_GetObject
@@ -111,6 +129,9 @@ DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page);
// index - The index of a page object.
// Return value:
// The handle of the page object. Null for failed.
+// Notes:
+// The method can not support this feature for the document consists of dynamic XFA fields.
+//
DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index);
// Function: FPDFPage_HasTransparency
@@ -120,6 +141,9 @@ DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index);
// Return value:
// TRUE means that the PDF page does contains transparency.
// Otherwise, returns FALSE.
+// Notes:
+// The method can not support this feature for the document consists of dynamic XFA fields.
+//
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page);
// Function: FPDFPage_GenerateContent
@@ -131,6 +155,9 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page);
// Comment:
// Before you save the page to a file, or reload the page, you must call the FPDFPage_GenerateContent function.
// Or the changed information will be lost.
+// Notes:
+// The method can not support this feature for the document consists of dynamic XFA fields.
+//
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page);
//////////////////////////////////////////////////////////////////////
@@ -175,6 +202,8 @@ DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
// f - The coefficient "f" of the matrix.
// Return value:
// None.
+// Notes:
+// The method can not support this feature for the document consists of dynamic XFA fields.
DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
double a, double b, double c, double d, double e, double f);
@@ -212,6 +241,8 @@ DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document)
// Note:
// The image object might already has an associated image, which is shared and cached by the loaded pages, In this case, we need to clear the cache of image for all the loaded pages.
// Pass pages and count to this API to clear the image cache.
+// The method can not support this feature for the document consists of dynamic XFA fields.
+//
DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, int nCount,FPDF_PAGEOBJECT image_object, FPDF_FILEACCESS* fileAccess);
@@ -239,6 +270,9 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object,
// bitmap - The handle of the bitmap which you want to set it to the image object.
// Return value:
// TRUE if successful, FALSE otherwise.
+// Notes;
+// The method can not support this feature for the document consists of dynamic XFA fields.
+//
DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,int nCount,FPDF_PAGEOBJECT image_object, FPDF_BITMAP bitmap);
#ifdef __cplusplus
diff --git a/fpdfsdk/include/fpdfformfill.h b/fpdfsdk/include/fpdfformfill.h
index b69a8f69b2..a08bfd16b7 100644
--- a/fpdfsdk/include/fpdfformfill.h
+++ b/fpdfsdk/include/fpdfformfill.h
@@ -44,6 +44,8 @@ typedef struct _IPDF_JsPlatform
* 1-Warning;
* 2-Question;
* 3-Status.
+ * 4-Asterisk
+
* Return Value:
* The return value could be the folowing type:
* 1-OK;
@@ -216,7 +218,7 @@ typedef struct _IPDF_JsPlatform
* Comments:
* The filePath shoule be always input in local encoding.
*/
- int (*Field_browse)(struct _IPDF_JsPlatform* pThis,void* filePath, int length);
+ int (*Field_browse)(struct _IPDF_JsPlatform* pThis, void* filePath, int length);
/**
* pointer to FPDF_FORMFILLINFO interface.
@@ -256,6 +258,38 @@ typedef struct _FPDF_SYSTEMTIME
unsigned short wMilliseconds; /* milliseconds after the second - [0,999] */
}FPDF_SYSTEMTIME;
+//XFA
+/**
+ * @name Pageview event flags
+ */
+/*@{*/
+/** @brief After a new pageview is added. */
+#define FXFA_PAGEVIEWEVENT_POSTADDED 1
+/** @brief After a pageview is removed. */
+#define FXFA_PAGEVIEWEVENT_POSTREMOVED 3
+/*@}*/
+
+// menu
+/**
+ * @name Macro Definitions for Right Context Menu Features Of XFA Fields
+ */
+/*@{*/
+#define FXFA_MEMU_COPY 1
+#define FXFA_MEMU_CUT 2
+#define FXFA_MEMU_SELECTALL 4
+#define FXFA_MEMU_UNDO 8
+#define FXFA_MEMU_REDO 16
+#define FXFA_MEMU_PASTE 32
+/*@}*/
+
+// file type
+/**
+ * @name Macro Definitions for File Type.
+ */
+/*@{*/
+#define FXFA_SAVEAS_XML 1
+#define FXFA_SAVEAS_XDP 2
+/*@}*/
typedef struct _FPDF_FORMFILLINFO
{
@@ -526,8 +560,235 @@ typedef struct _FPDF_FORMFILLINFO
**/
void (*FFI_DoGoToAction)(struct _FPDF_FORMFILLINFO* pThis, int nPageIndex, int zoomMode, float* fPosArray, int sizeofArray);
/**
- * pointer to IPDF_JSPLATFORM interface
+ * Method: FFI_DisplayCaret
+ * This method will show the caret at specified position.
+ * Interface Version:
+ * 1
+ * Implementation Required:
+ * yes
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * page - Handle to page. Returned by FPDF_LoadPage function.
+ * left - Left position of the client area in PDF page coordinate.
+ * top - Top position of the client area in PDF page coordinate.
+ * right - Right position of the client area in PDF page coordinate.
+ * bottom - Bottom position of the client area in PDF page coordinate.
+ * Return value:
+ * None.
+ **/
+ void (*FFI_DisplayCaret)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, FPDF_BOOL bVisible, double left, double top, double right, double bottom);
+ /**
+ * Method: FFI_GetCurrentPageIndex
+ * This method will get the current page index.
+ * Interface Version:
+ * 1
+ * Implementation Required:
+ * yes
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * document - Handle to document. Returned by FPDF_LoadDocument function.
+ * Return value:
+ * The index of current page.
**/
+ int (*FFI_GetCurrentPageIndex)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document);
+ /**
+ * Method: FFI_SetCurrentPage
+ * This method will set the current page.
+ * Interface Version:
+ * 1
+ * Implementation Required:
+ * yes
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * document - Handle to document. Returned by FPDF_LoadDocument function.
+ * iCurPage - The index of the PDF page.
+ * Return value:
+ * None.
+ **/
+ void (*FFI_SetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document, int iCurPage);
+ /**
+ * Method: FFI_GotoURL
+ * This method will link to the specified URL.
+ * Interface Version:
+ * 1
+ * Implementation Required:
+ * no
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * document - Handle to document. Returned by FPDF_LoadDocument function.
+ * wsURL - The string value of the URL, in UTF-16LE format.
+ * Return value:
+ * None.
+ **/
+ void (*FFI_GotoURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document, FPDF_WIDESTRING wsURL);
+ /**
+ * Method: FFI_GetPageViewRect
+ * This method will get the current page view rectangle.
+ * Interface Version:
+ * 1
+ * Implementation Required:
+ * yes
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * page - Handle to page. Returned by FPDF_LoadPage function.
+ * left - The pointer to receive left position of the page view area in PDF page coordinate.
+ * top - The pointer to receive top position of the page view area in PDF page coordinate.
+ * right - The pointer to receive right position of the client area in PDF page coordinate.
+ * bottom - The pointer to receive bottom position of the client area in PDF page coordinate.
+ * Return value:
+ * None.
+ **/
+ void (*FFI_GetPageViewRect)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, double* left, double* top, double* right, double* bottom);
+ /**
+ * Method: FFI_PopupMenu
+ * This method will track the right context menu for XFA fields.
+ * Interface Version:
+ * 1
+ * Implementation Required:
+ * yes
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * page - Handle to page. Returned by FPDF_LoadPage function.
+ * hWidget - Handle to XFA fields.
+ * menuFlag - The menu flags. Please refer to macro definition of FXFA_MEMU_XXX and this can be one or a combination of these macros.
+ * x - X position of the client area in PDF page coordinate.
+ * y - Y position of the client area in PDF page coordinate.
+ * Return value:
+ * TRUE indicates success; otherwise false.
+ **/
+ FPDF_BOOL (*FFI_PopupMenu)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, FPDF_WIDGET hWidget, int menuFlag, float x, float y);
+ /**
+ * Method: FFI_OpenFile
+ * This method will open the specified file with the specified mode.
+ * Interface Version
+ * 1
+ * Implementation Required:
+ * yes
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * fileFlag - The file flag.Please refer to macro definition of FXFA_SAVEAS_XXX and this can be one of these macros.
+ * wsURL - The string value of the file URL, in UTF-16LE format.
+ * mode - The mode for open file.
+ * Return value:
+ * The handle to FPDF_FILEHANDLER.
+ **/
+ FPDF_FILEHANDLER* (*FFI_OpenFile)(struct _FPDF_FORMFILLINFO* pThis, int fileFlag, FPDF_WIDESTRING wsURL, const char* mode);
+ /**
+ * Method: FFI_EmailTo
+ * This method will email the specified file stream to the specified contacter.
+ * Interface Version:
+ * 1
+ * Implementation Required:
+ * yes
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * pFileHandler - Handle to the FPDF_FILEHANDLER.
+ * pTo - A semicolon-delimited list of recipients for the message,in UTF-16LE format.
+ * pSubject - The subject of the message,in UTF-16LE format.
+ * pCC - A semicolon-delimited list of CC recipients for the message,in UTF-16LE format.
+ * pBcc - A semicolon-delimited list of BCC recipients for the message,in UTF-16LE format.
+ * pMsg - Pointer to the data buffer to be sent.Can be NULL,in UTF-16LE format.
+ * Return value:
+ * None.
+ **/
+ void (*FFI_EmailTo)(struct _FPDF_FORMFILLINFO* pThis, FPDF_FILEHANDLER* fileHandler, FPDF_WIDESTRING pTo, FPDF_WIDESTRING pSubject, FPDF_WIDESTRING pCC, FPDF_WIDESTRING pBcc, FPDF_WIDESTRING pMsg);
+ /**
+ * Method: FFI_UploadTo
+ * This method will get upload the specified file stream to the specified URL.
+ * Interface Version:
+ * 1
+ * Implementation Required:
+ * yes
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * pFileHandler - Handle to the FPDF_FILEHANDLER.
+ * fileFlag - The file flag.Please refer to macro definition of FXFA_SAVEAS_XXX and this can be one of these macros.
+ * uploadTo - Pointer to the URL path, in UTF-16LE format.
+ * Return value:
+ * None.
+ **/
+ void (*FFI_UploadTo)(struct _FPDF_FORMFILLINFO* pThis, FPDF_FILEHANDLER* fileHandler, int fileFlag, FPDF_WIDESTRING uploadTo);
+
+ /**
+ * Method: FFI_GetPlatform
+ * This method will get the current platform.
+ * Interface Version:
+ * 1
+ * Implementation Required:
+ * yes
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * platform - Pointer to the data buffer to receive the platform.Can be NULL,in UTF-16LE format.
+ * length - The length of the buffer, number of bytes. Can be 0.
+ * Return value:
+ * The length of the buffer, number of bytes.
+ **/
+ int (*FFI_GetPlatform)(struct _FPDF_FORMFILLINFO* pThis, void* platform, int length);
+ /**
+ * Method: FFI_GetLanguage
+ * This method will get the current language.
+ * Interface Version:
+ * 1
+ * Implementation Required:
+ * yes
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * language - Pointer to the data buffer to receive the current language.Can be NULL.
+ * length - The length of the buffer, number of bytes. Can be 0.
+ * Return value:
+ * The length of the buffer, number of bytes.
+ **/
+ int (*FFI_GetLanguage)(struct _FPDF_FORMFILLINFO* pThis, void* language, int length);
+ /**
+ * Method: FFI_DownloadFromURL
+ * This method will download the specified file from the URL.
+ * Interface Version:
+ * 1
+ * Implementation Required:
+ * yes
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * URL - The string value of the file URL, in UTF-16LE format.
+ * Return value:
+ * The handle to FPDF_FILEHANDLER.
+ **/
+ FPDF_LPFILEHANDLER (*FFI_DownloadFromURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING URL);
+ /**
+ * Method: FFI_PostRequestURL
+ * This method will post the request to the server URL.
+ * Interface Version:
+ * 1
+ * Implementation Required:
+ * yes
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * wsURL - The string value of the server URL, in UTF-16LE format.
+ * wsData - The post data,in UTF-16LE format.
+ * wsContentType - The content type of the request data,in UTF-16LE format.
+ * wsEncode - The encode type,in UTF-16LE format.
+ * wsHeader - The request header,in UTF-16LE format.
+ * response - Pointer to the FPDF_BSTR to receive the response data from server,,in UTF-16LE format.
+ * Return value:
+ * TRUE indicates success, otherwise FALSE.
+ **/
+ FPDF_BOOL (*FFI_PostRequestURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING wsURL, FPDF_WIDESTRING wsData, FPDF_WIDESTRING wsContentType, FPDF_WIDESTRING wsEncode, FPDF_WIDESTRING wsHeader, FPDF_BSTR* respone);
+ /**
+ * Method: FFI_PutRequestURL
+ * This method will put the request to the server URL.
+ * Interface Version:
+ * 1
+ * Implementation Required:
+ * yes
+ * Parameters:
+ * pThis - Pointer to the interface structure itself.
+ * wsURL - The string value of the server URL, in UTF-16LE format.
+ * wsData - The put data, in UTF-16LE format.
+ * wsEncode - The encode type, in UTR-16LE format.
+ * Return value:
+ * TRUE indicates success, otherwise FALSE.
+ **/
+ FPDF_BOOL (*FFI_PutRequestURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING wsURL, FPDF_WIDESTRING wsData, FPDF_WIDESTRING wsEncode);
+
IPDF_JSPLATFORM* m_pJsPlatform;
} FPDF_FORMFILLINFO;
@@ -688,6 +949,9 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle,FPDF_PAGE
**/
DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle,FPDF_PAGE page, int modifier, double page_x, double page_y);
+DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y);
+DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y);
+
/**
* Function: FORM_OnKeyDown
* You can call this member function when a nonsystem key is pressed.
@@ -746,7 +1010,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle);
#define FPDF_FORMFIELD_COMBOBOX 4 // combo box type.
#define FPDF_FORMFIELD_LISTBOX 5 // list box type.
#define FPDF_FORMFIELD_TEXTFIELD 6 // text field type.
-
+#define FPDF_FORMFIELD_XFA 7 // text field type.
/**
* Function: FPDPage_HasFormFieldAtPoint
* Check the form filed position by point.
@@ -827,7 +1091,149 @@ DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle);
DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y,
int size_x, int size_y, int rotate, int flags);
+/**
+ * Function: FPDF_LoadXFA
+ * If the document consists of XFA fields, there should call this method to load XFA fields.
+ * Parameters:
+ * document - Handle to document. Returned by FPDF_LoadDocument function.
+ * Return Value:
+ * TRUE indicates success,otherwise FALSE.
+ **/
+DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document);
+/**
+ * Function: FPDF_Widget_Undo
+ * This method will implement the undo feature for the specified xfa field.
+ * Parameters:
+ * document - Handle to document. Returned by FPDF_LoadDocument function.
+ * hWidget - Handle to the xfa field.
+ * Return Value:
+ * None.
+ **/
+DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, FPDF_WIDGET hWidget);
+/**
+ * Function: FPDF_Widget_Redo
+ * This method will implement the redo feature for the specified xfa field.
+ * Parameters:
+ * document - Handle to document. Returned by FPDF_LoadDocument function.
+ * hWidget - Handle to the xfa field.
+ * Return Value:
+ * None.
+ **/
+DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, FPDF_WIDGET hWidget);
+/**
+ * Function: FPDF_Widget_SelectAll
+ * This method will implement the select all feature for the specified xfa field.
+ * Parameters:
+ * document - Handle to document. Returned by FPDF_LoadDocument function.
+ * hWidget - Handle to the xfa field.
+ * Return Value:
+ * None.
+ **/
+DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, FPDF_WIDGET hWidget);
+/**
+ * Function: FPDF_Widget_Copy
+ * This method will implement the copy feature for the specified xfa field.
+ * Parameters:
+ * document - Handle to document. Returned by FPDF_LoadDocument function.
+ * hWidget - Handle to the xfa field.
+ * wsText - Pointer to data buffer to receive the copied data, in UTF-16LE format.
+ * size - The data buffer size.
+ * Return Value:
+ * None.
+ **/
+DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, FPDF_WIDESTRING wsText, FPDF_DWORD* size);
+/**
+ * Function: FPDF_Widget_Cut
+ * This method will implement the cut feature for the specified xfa field.
+ * Parameters:
+ * document - Handle to document. Returned by FPDF_LoadDocument function.
+ * hWidget - Handle to the xfa field.
+ * wsText - Pointer to data buffer to receive the cut data,in UTF-16LE format.
+ * size - The data buffer size,not the byte number.
+ * Return Value:
+ * None.
+ **/
+DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, FPDF_WIDESTRING wsText, FPDF_DWORD* size);
+/**
+ * Function: FPDF_Widget_Paste
+ * This method will implement the paste feature for the specified xfa field.
+ * Parameters:
+ * document - Handle to document. Returned by FPDF_LoadDocument function.
+ * hWidget - Handle to the xfa field.
+ * wsText - The paste text buffer, in UTF-16LE format.
+ * size - The data buffer size,not the byte number.
+ * Return Value:
+ * None.
+ **/
+DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, FPDF_WIDESTRING wsText, FPDF_DWORD size);
+/**
+ * Function: FPDF_Widget_ReplaceSpellCheckWord
+ * This method will implement the spell check feature for the specified xfa field.
+ * Parameters:
+ * document - Handle to document. Returned by FPDF_LoadDocument function.
+ * hWidget - Handle to the xfa field.
+ * x - The x value of the specified point.
+ * y - The y value of the specified point.
+ * bsText - The text buffer needed to be speck check, in UTF-16LE format.
+ * Return Value:
+ * None.
+ **/
+DLLEXPORT void STDCALL FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, float x, float y, FPDF_BYTESTRING bsText);
+/**
+ * Function: FPDF_Widget_GetSpellCheckWords
+ * This method will implement the spell check feature for the specified xfa field.
+ * Parameters:
+ * document - Handle to document. Returned by FPDF_LoadDocument function.
+ * hWidget - Handle to the xfa field.
+ * x - The x value of the specified point.
+ * y - The y value of the specified point.
+ * stringHandle - Pointer to FPDF_STRINGHANDLE to receive the speck check text buffer, in UTF-16LE format.
+ * Return Value:
+ * None.
+ **/
+DLLEXPORT void STDCALL FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, float x, float y, FPDF_STRINGHANDLE* stringHandle);
+/**
+ * Function: FPDF_StringHandleCounts
+ * This method will get the count of the text buffer.
+ * Parameters:
+ * stringHandle - Pointer to FPDF_STRINGHANDLE.
+ * Return Value:
+ * None.
+ **/
+DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE stringHandle);
+/**
+ * Function: FPDF_StringHandleGetStringByIndex
+ * This method will get the specified index of the text buffer.
+ * Parameters:
+ * stringHandle - Pointer to FPDF_STRINGHANDLE.
+ * index - The specified index of text buffer.
+ * bsText - Pointer to data buffer to receive the text buffer, in UTF-16LE format.
+ * size - The byte size of data buffer.
+ * Return Value:
+ * TRUE indicates success, otherwise FALSE.
+ **/
+DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE stringHandle, int index, FPDF_BYTESTRING bsText, FPDF_DWORD* size);
+/**
+ * Function: FPDF_StringHandleRelease
+ * This method will release the FPDF_STRINGHANDLE.
+ * Parameters:
+ * stringHandle - Pointer to FPDF_STRINGHANDLE.
+ * Return Value:
+ * None.
+ **/
+DLLEXPORT void STDCALL FPDF_StringHandleRelease(FPDF_STRINGHANDLE stringHandle);
+/**
+ * Function: FPDF_StringHandleAddString
+ * This method will add the specified text buffer.
+ * Parameters:
+ * stringHandle - Pointer to FPDF_STRINGHANDLE.
+ * bsText - Pointer to data buffer of the text buffer, in UTF-16LE format.
+ * size - The byte size of data buffer.
+ * Return Value:
+ * TRUE indicates success, otherwise FALSE.
+ **/
+DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringHandle, FPDF_BYTESTRING bsText, FPDF_DWORD size);
#ifdef __cplusplus
};
diff --git a/fpdfsdk/include/fpdfppo.h b/fpdfsdk/include/fpdfppo.h
index 3e7e5c9a5e..db78a1942d 100644
--- a/fpdfsdk/include/fpdfppo.h
+++ b/fpdfsdk/include/fpdfppo.h
@@ -23,6 +23,9 @@ extern "C" {
// index - The page index wanted to insert from.
// Return value:
// TRUE for succeed, FALSE for Failed.
+// Notes:
+// The method not support this feature for the document consists of dynamic XFA fields.
+//
DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc,FPDF_DOCUMENT src_doc, FPDF_BYTESTRING pagerange, int index);
diff --git a/fpdfsdk/include/fpdftext.h b/fpdfsdk/include/fpdftext.h
index 8b897798e6..143a6c6a8e 100644
--- a/fpdfsdk/include/fpdftext.h
+++ b/fpdfsdk/include/fpdftext.h
@@ -24,6 +24,8 @@ extern "C" {
// Comments:
// Application must call FPDFText_ClosePage to release the text page information.
// If you don't purchase Text Module , this function will return NULL.
+// Notes:
+// The method can not support to load out FPDF_TEXTPAGE for the document consists of dynamic fields.
//
DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page);
diff --git a/fpdfsdk/include/fpdfview.h b/fpdfsdk/include/fpdfview.h
index 4dcdcf620a..161bca2809 100644
--- a/fpdfsdk/include/fpdfview.h
+++ b/fpdfsdk/include/fpdfview.h
@@ -18,6 +18,8 @@ typedef void* FPDF_MODULEMGR;
// PDF types
typedef void* FPDF_DOCUMENT;
typedef void* FPDF_PAGE;
+typedef void* FPDF_WIDGET;
+typedef void* FPDF_STRINGHANDLE;
typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
typedef void* FPDF_PATH;
typedef void* FPDF_CLIPPATH;
@@ -37,6 +39,9 @@ typedef void* FPDF_LINK;
typedef void* FPDF_PAGERANGE;
// Basic data types
+typedef void* FPDF_LPVOID;
+typedef void const* FPDF_LPCVOID;
+typedef int FPDF_RESULT;
typedef int FPDF_BOOL;
typedef int FPDF_ERROR;
typedef unsigned long FPDF_DWORD;
@@ -54,6 +59,7 @@ typedef enum _FPDF_DUPLEXTYPE_ {
// String types
typedef unsigned short FPDF_WCHAR;
typedef unsigned char const* FPDF_LPCBYTE;
+typedef char const* FPDF_LPCSTR;
// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE encoded), and platform dependent string
typedef const char* FPDF_BYTESTRING;
@@ -61,6 +67,26 @@ typedef const char* FPDF_BYTESTRING;
typedef const unsigned short* FPDF_WIDESTRING; // Foxit PDF SDK always use UTF-16LE encoding wide string,
// each character use 2 bytes (except surrogation), with low byte first.
+#ifndef _FPDF_DEF_STR_
+#define _FPDF_DEF_STR_
+/** @brief Structure for byte string.
+ *
+ * @note In SDK, a byte string commonly means a UTF-16LE format string.
+ */
+typedef struct _FPDF_BSTR
+{
+ /**
+ * @brief String buffer.
+ */
+ char* str;
+ /**
+ * @brief Length of a string, in bytes.
+ */
+ int len;
+} FPDF_BSTR;
+
+#endif
+
// For Windows programmers: for most case it's OK to treat FPDF_WIDESTRING as Windows unicode string,
// however, special care needs to be taken if you expect to process Unicode larger than 0xffff.
// For Linux/Unix programmers: most compiler/library environment uses 4 bytes for a Unicode character,
@@ -166,6 +192,9 @@ DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable
* @note Loaded document can be closed by FPDF_CloseDocument.
* If this function fails, you can use FPDF_GetLastError() to retrieve
* the reason why it fails.
+* The application should call ::FPDF_LoadXFA function after PDF document loaded
+* to support XFA fields in fpdfformfill.h file.
+*
* @retval A handle to the loaded document. If failed, NULL is returned.
*/
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
@@ -185,6 +214,9 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
// Loaded document can be closed by FPDF_CloseDocument.
// If this function fails, you can use FPDF_GetLastError() to retrieve
// the reason why it fails.
+// Notes:
+// The application should call ::FPDF_LoadXFA function after PDF document loaded
+// to support XFA fields in fpdfformfill.h file.
//
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
int size, FPDF_BYTESTRING password);
@@ -206,6 +238,78 @@ typedef struct {
void* m_Param;
} FPDF_FILEACCESS;
+/**
+ * @brief Structure for file reading or writing (I/O).
+ *
+ * @note This is a handler and should be implemented by callers.
+ */
+typedef struct _FPDF_FILEHANDLER
+{
+ /**
+ * @brief User-defined data.
+ * @note Callers can use this field to track controls.
+ */
+ FPDF_LPVOID clientData;
+ /**
+ * @brief Callback function to release the current file stream object.
+ *
+ * @param[in] clientData Pointer to user-defined data.
+ *
+ * @return None.
+ */
+ void (*Release)(FPDF_LPVOID clientData);
+ /**
+ * @brief Callback function to retrieve the current file stream size.
+ *
+ * @param[in] clientData Pointer to user-defined data.
+ *
+ * @return Size of file stream.
+ */
+ FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData);
+ /**
+ * @brief Callback function to read data from the current file stream.
+ *
+ * @param[in] clientData Pointer to user-defined data.
+ * @param[in] offset Offset position starts from the beginning of file stream. This parameter indicates reading position.
+ * @param[in] buffer Memory buffer to store data which are read from file stream. This parameter should not be <b>NULL</b>.
+ * @param[in] size Size of data which should be read from file stream, in bytes. The buffer indicated by the parameter <i>buffer</i> should be enough to store specified data.
+ *
+ * @return 0 for success, other value for failure.
+ */
+ FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPVOID buffer, FPDF_DWORD size);
+ /**
+ * @brief Callback function to write data into the current file stream.
+ *
+ * @param[in] clientData Pointer to user-defined data.
+ * @param[in] offset Offset position starts from the beginning of file stream. This parameter indicates writing position.
+ * @param[in] buffer Memory buffer contains data which is written into file stream. This parameter should not be <b>NULL</b>.
+ * @param[in] size Size of data which should be written into file stream, in bytes.
+ *
+ * @return 0 for success, other value for failure.
+ */
+ FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPCVOID buffer, FPDF_DWORD size);
+ /**
+ * @brief Callback function to flush all internal accessing buffers.
+ *
+ * @param[in] clientData Pointer to user-defined data.
+ *
+ * @return 0 for success, other value for failure.
+ */
+ FPDF_RESULT (*Flush)(FPDF_LPVOID clientData);
+ /**
+ * @brief Callback function to change file size.
+ *
+ * @details This function is called under writing mode usually. Implementer can determine whether to realize it based on application requests.
+ *
+ * @param[in] clientData Pointer to user-defined data.
+ * @param[in] size New size of file stream, in bytes.
+ *
+ * @return 0 for success, other value for failure.
+ */
+ FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size);
+
+} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
+
// Function: FPDF_LoadCustomDocument
// Load PDF document from a custom access descriptor.
// Parameters:
@@ -216,6 +320,10 @@ typedef struct {
// Comments:
// The application should maintain the file resources being valid until the PDF document close.
// Loaded document can be closed by FPDF_CloseDocument.
+// Notes:
+// The application should call ::FPDF_LoadXFA function after PDF document loaded
+// to support XFA fields in fpdfformfill.h file.
+//
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess,
FPDF_BYTESTRING password);
@@ -228,6 +336,7 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAc
// TRUE if this call succeed, If failed, FALSE is returned.
// Comments:
// If the document is created by function ::FPDF_CreateNewDocument, then this function would always fail.
+//
DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVersion);
#define FPDF_ERR_SUCCESS 0 // No error.
@@ -237,6 +346,8 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVers
#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
#define FPDF_ERR_PAGE 6 // Page not found or content error.
+#define FPDF_ERR_XFALOAD 7 // Load XFA error.
+#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
// Function: FPDF_GetLastError
// Get last error code when an SDK function failed.
@@ -354,6 +465,8 @@ DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_i
// flags - 0 for normal display, or combination of flags defined above.
// Return value:
// None.
+// Notes:
+// The method can not support to render the page for the document consists of dynamic XFA fields.
//
DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y,
int rotate, int flags);
@@ -374,6 +487,8 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int
// flags - 0 for normal display, or combination of flags defined above.
// Return value:
// None.
+// Notes:
+// The method can not support to render the page for the document consists of dynamic XFA fields.
//
DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y,
int size_x, int size_y, int rotate, int flags);
@@ -612,6 +727,18 @@ DLLEXPORT FPDF_DUPLEXTYPE STDCALL FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT documen
//
DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,FPDF_BYTESTRING name);
+// Function: FPDF_BStr_Init
+// Helper function to initialize a byte string.
+DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
+
+// Function: FPDF_BStr_Set
+// Helper function to set string data.
+DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str, FPDF_LPCSTR bstr, int length);
+
+// Function: FPDF_BStr_Clear
+// Helper function to clear a byte string.
+DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
+
#ifdef __cplusplus
};
#endif
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
diff --git a/fpdfsdk/include/fsdk_annothandler.h b/fpdfsdk/include/fsdk_annothandler.h
index 9f97c52596..6aa9412f68 100644
--- a/fpdfsdk/include/fsdk_annothandler.h
+++ b/fpdfsdk/include/fsdk_annothandler.h
@@ -7,6 +7,7 @@
#ifndef _FSDK_ANNOTHANDLER_H_
#define _FSDK_ANNOTHANDLER_H_
+#define FSDK_XFAWIDGET_TYPENAME "XFAWidget"
class CPDFDoc_Environment;
class CFFL_IFormFiller;
@@ -26,6 +27,8 @@ public:
virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) = 0;
+ virtual CPDFSDK_Annot* NewAnnot(XFA_HWIDGET hWidget, CPDFSDK_PageView* pPage) = 0;
+
virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) = 0;
virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) = 0;
@@ -78,6 +81,7 @@ public:
virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0;
virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0;
+ virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, CPDFSDK_Annot* pNewAnnot) = 0;
};
@@ -97,6 +101,8 @@ public:
virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage);
+ virtual CPDFSDK_Annot* NewAnnot(XFA_HWIDGET hWidget, CPDFSDK_PageView* pPage);
+
virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) ;
virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) {}
@@ -148,6 +154,7 @@ public:
virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag);
virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag);
+ virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, CPDFSDK_Annot* pNewAnnot){ return TRUE; }
void SetFormFiller(CFFL_IFormFiller* pFiller){m_pFormFiller = pFiller;}
CFFL_IFormFiller* GetFormFiller() {return m_pFormFiller;}
@@ -157,6 +164,86 @@ private:
CFFL_IFormFiller* m_pFormFiller;
};
+class CPDFSDK_XFAAnnotHandler : public IPDFSDK_AnnotHandler
+{
+public:
+ CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp);
+ ~CPDFSDK_XFAAnnotHandler(){}
+
+public:
+ virtual CFX_ByteString GetType() { return FSDK_XFAWIDGET_TYPENAME; }
+
+ virtual CFX_ByteString GetName() { return "XFAWidgetHandler"; }
+
+ virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot);
+
+
+ virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) { return NULL; }
+
+ virtual CPDFSDK_Annot* NewAnnot(XFA_HWIDGET pAnnot, CPDFSDK_PageView* pPage);
+
+ virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot);
+
+ virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) {}
+
+
+ virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot);
+
+ virtual FX_BOOL HitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point);
+
+
+ virtual void OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot,
+ CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+ FX_DWORD dwFlags);
+
+ virtual void OnDrawSleep(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot,
+ CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+ const CPDF_Rect& rcWindow, FX_DWORD dwFlags) {}
+
+
+
+
+ virtual void OnCreate(CPDFSDK_Annot* pAnnot) {}
+
+ virtual void OnLoad(CPDFSDK_Annot* pAnnot) {}
+
+ virtual void OnDelete(CPDFSDK_Annot* pAnnot) {}
+
+ virtual void OnRelease(CPDFSDK_Annot* pAnnot) {}
+
+
+ virtual void OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag);
+ virtual void OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag);
+
+
+ virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point);
+ virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ;
+ virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ;
+ virtual FX_BOOL OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point);
+ virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, short zDelta, const CPDF_Point& point) ;
+ virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point);
+ virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ;
+ virtual FX_BOOL OnRButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ;
+ //by wjm.
+ virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_DWORD nChar, FX_DWORD nFlags);
+ virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag);
+ virtual FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag);
+
+ virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) {}
+ virtual void OnSelected(CPDFSDK_Annot* pAnnot) {}
+
+ virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag);
+ virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) ;
+ virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, CPDFSDK_Annot* pNewAnnot);
+
+private:
+ IXFA_WidgetHandler* GetXFAWidgetHandler(CPDFSDK_Annot* pAnnot);
+ FX_DWORD GetFWLFlags(FX_DWORD dwFlag);
+
+private:
+ CPDFDoc_Environment* m_pApp;
+};
+
#define CBA_AnnotHandlerArray CFX_ArrayTemplate<IPDFSDK_AnnotHandler*>
class CPDFSDK_AnnotHandlerMgr
{
@@ -170,6 +257,7 @@ public:
void UnRegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler);
virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot * pAnnot, CPDFSDK_PageView *pPageView);
+ virtual CPDFSDK_Annot* NewAnnot(XFA_HWIDGET pAnnot, CPDFSDK_PageView* pPageView);
virtual void ReleaseAnnot(CPDFSDK_Annot * pAnnot);
virtual void Annot_OnCreate(CPDFSDK_Annot* pAnnot);
@@ -198,6 +286,7 @@ public:
virtual FX_BOOL Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag);
virtual FX_BOOL Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag);
+ virtual FX_BOOL Annot_OnChangeFocus(CPDFSDK_Annot* pSetAnnot,CPDFSDK_Annot* pKillAnnot);
virtual CPDF_Rect Annot_OnGetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot);
virtual FX_BOOL Annot_OnHitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point);
diff --git a/fpdfsdk/include/fsdk_baseannot.h b/fpdfsdk/include/fsdk_baseannot.h
index 797c3f16d1..5f56fc7000 100644
--- a/fpdfsdk/include/fsdk_baseannot.h
+++ b/fpdfsdk/include/fsdk_baseannot.h
@@ -61,20 +61,33 @@ public:
class CPDFSDK_Annot
{
public:
- CPDFSDK_Annot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
- virtual ~CPDFSDK_Annot();
+ CPDFSDK_Annot(CPDFSDK_PageView* pPageView);
+ virtual ~CPDFSDK_Annot() {};
public:
+ virtual FX_BOOL IsXFAField() { return FALSE; }
+
virtual FX_FLOAT GetMinWidth() const;
virtual FX_FLOAT GetMinHeight() const;
//define layout order to 5.
virtual int GetLayoutOrder() const { return 5; }
+ virtual CPDF_Annot* GetPDFAnnot() { return NULL; }
+ virtual XFA_HWIDGET GetXFAWidget() { return NULL; }
+
+ virtual CFX_ByteString GetType() const { return ""; }
+ virtual CFX_ByteString GetSubType() const { return ""; }
+
+ virtual void SetRect(const CPDF_Rect& rect) {}
+ virtual CPDF_Rect GetRect() const { return CPDF_Rect(); }
+
+ virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions) {}
+
public:
- CPDF_Annot* GetPDFAnnot();
+ CPDF_Page* GetPDFPage();
+ CPDFXFA_Page* GetPDFXFAPage();
- void SetPage(CPDFSDK_PageView* pPageView);
- CPDFSDK_PageView* GetPageView();
- FX_DWORD GetFlags();
+ void SetPage(CPDFSDK_PageView* pPageView) { m_pPageView = pPageView; }
+ CPDFSDK_PageView* GetPageView() { return m_pPageView; }
// Tab Order
int GetTabOrder();
@@ -84,17 +97,35 @@ public:
FX_BOOL IsSelected();
void SetSelected(FX_BOOL bSelected);
- CFX_ByteString GetType() const;
+protected:
+ CPDF_Annot* m_pAnnot;
+ CPDFSDK_PageView* m_pPageView;
+ FX_BOOL m_bSelected;
+ int m_nTabOrder;
+
+};
+
+class CPDFSDK_BAAnnot : public CPDFSDK_Annot
+{
+public:
+ CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
+ virtual ~CPDFSDK_BAAnnot();
+
+public:
+ virtual FX_BOOL IsXFAField();
+
+ virtual CFX_ByteString GetType() const;
virtual CFX_ByteString GetSubType() const;
- CPDF_Page* GetPDFPage();
+ virtual void SetRect(const CPDF_Rect& rect);
+ virtual CPDF_Rect GetRect() const;
+
+ virtual CPDF_Annot* GetPDFAnnot();
+ virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions);
public:
CPDF_Dictionary* GetAnnotDict() const;
- void SetRect(const CPDF_Rect& rect);
- CPDF_Rect GetRect() const;
-
void SetContents(const CFX_WideString& sContents);
CFX_WideString GetContents() const;
@@ -151,32 +182,24 @@ public:
virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT);
public:
- FX_BOOL IsAppearanceValid();
- FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
- void DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
+ virtual FX_BOOL IsAppearanceValid();
+ virtual FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
+ virtual void DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions);
void DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
const CPDF_RenderOptions* pOptions);
void ClearCachedAP();
+ virtual void ResetAppearance();
void WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Rect& rcBBox,
const CPDF_Matrix& matrix, const CFX_ByteString& sContents,
const CFX_ByteString& sAPState = "");
-public:
- virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions);
-public:
-
-
private:
FX_BOOL CreateFormFiller();
protected:
CPDF_Annot* m_pAnnot;
- CPDFSDK_PageView* m_pPageView;
- FX_BOOL m_bSelected;
- int m_nTabOrder;
-
};
diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h
index 073c99f199..0e199c1d90 100644
--- a/fpdfsdk/include/fsdk_baseform.h
+++ b/fpdfsdk/include/fsdk_baseform.h
@@ -20,6 +20,13 @@ class CFFL_FormFiller;
class CPDFSDK_PageView;
class CPDFSDK_InterForm;
+typedef enum _PDFSDK_XFAAActionType
+{
+ PDFSDK_XFA_Click = 0,
+ PDFSDK_XFA_Full,
+ PDFSDK_XFA_PreOpen,
+ PDFSDK_XFA_PostOpen
+}PDFSDK_XFAAActionType;
typedef struct _PDFSDK_FieldAction
{
@@ -48,9 +55,26 @@ typedef struct _PDFSDK_FieldAction
FX_BOOL bFieldFull; //in
FX_BOOL bRC; //in[out]
}PDFSDK_FieldAction;
-class CPDFSDK_Widget:public CPDFSDK_Annot
+class CPDFSDK_Widget:public CPDFSDK_BAAnnot
{
public:
+ XFA_HWIDGET GetMixXFAWidget();
+ XFA_HWIDGET GetGroupMixXFAWidget();
+ IXFA_WidgetHandler* GetXFAWidgetHandler();
+
+ FX_BOOL HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT);
+ FX_BOOL OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, PDFSDK_FieldAction& data, CPDFSDK_PageView* pPageView);
+
+ void Synchronize(FX_BOOL bSynchronizeElse);
+ void SynchronizeXFAValue();
+ void SynchronizeXFAItems();
+
+ static void SynchronizeXFAValue(IXFA_DocView* pXFADocView, XFA_HWIDGET hWidget,
+ CPDF_FormField* pFormField, CPDF_FormControl* pFormControl);
+ static void SynchronizeXFAItems(IXFA_DocView* pXFADocView, XFA_HWIDGET hWidget,
+ CPDF_FormField* pFormField, CPDF_FormControl* pFormControl);
+
+public:
CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm);
virtual ~CPDFSDK_Widget();
@@ -61,6 +85,7 @@ public:
int GetFieldType() const;
//define layout order to 2.
virtual int GetLayoutOrder() const {return 2;}
+ virtual FX_BOOL IsAppearanceValid();
/*
FIELDFLAG_READONLY
FIELDFLAG_REQUIRED
@@ -75,14 +100,14 @@ public:
FX_BOOL GetTextColor(FX_COLORREF& color) const;
FX_FLOAT GetFontSize() const;
- int GetSelectedIndex(int nIndex) const;
- CFX_WideString GetValue() const;
+ int GetSelectedIndex(int nIndex);
+ CFX_WideString GetValue(FX_BOOL bDisplay = TRUE);
CFX_WideString GetDefaultValue() const;
CFX_WideString GetOptionLabel(int nIndex) const;
int CountOptions() const;
- FX_BOOL IsOptionSelected(int nIndex) const;
+ FX_BOOL IsOptionSelected(int nIndex);
int GetTopVisibleIndex() const;
- FX_BOOL IsChecked() const;
+ FX_BOOL IsChecked();
/*
BF_ALIGN_LEFT
BF_ALIGN_MIDDL
@@ -90,6 +115,7 @@ public:
*/
int GetAlignment() const;
int GetMaxLen() const;
+ CFX_WideString GetName();
CFX_WideString GetAlternateName() const;
//Set Properties.
@@ -100,6 +126,7 @@ public:
void ClearSelection(FX_BOOL bNotify);
void SetTopVisibleIndex(int index);
+ void ResetAppearance(FX_BOOL bValueChanged);
void ResetAppearance(FX_LPCWSTR sValue, FX_BOOL bValueChanged);
void ResetFieldAppearance(FX_BOOL bValueChanged);
void UpdateField();
@@ -155,9 +182,37 @@ private:
FX_BOOL m_bAppModified;
FX_INT32 m_nAppAge;
FX_INT32 m_nValueAge;
+
+ XFA_HWIDGET m_hMixXFAWidget;
+ IXFA_WidgetHandler* m_pWidgetHandler;
+};
+
+class CPDFSDK_XFAWidget : public CPDFSDK_Annot
+{
+public:
+ CPDFSDK_XFAWidget(XFA_HWIDGET pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm);
+ virtual ~CPDFSDK_XFAWidget(){}
+
+public:
+ virtual FX_BOOL IsXFAField();
+ virtual XFA_HWIDGET GetXFAWidget() { return m_hXFAWidget; }
+
+ virtual CFX_ByteString GetType() const ;
+ virtual CFX_ByteString GetSubType() const { return ""; }
+
+ virtual CFX_FloatRect GetRect();
+
+public:
+ CPDFSDK_InterForm* GetInterForm() { return m_pInterForm; }
+
+private:
+ CPDFSDK_InterForm* m_pInterForm;
+ XFA_HWIDGET m_hXFAWidget;
};
#define CPDFSDK_WidgetMap CFX_MapPtrTemplate<CPDF_FormControl*, CPDFSDK_Widget*>
+#define CPDFSDK_XFAWidgetMap CFX_MapPtrTemplate<XFA_HWIDGET, CPDFSDK_XFAWidget*>
+#define CPDFSDK_FieldSynchronizeMap CFX_MapPtrTemplate<CPDF_FormField*, int>
class CPDFSDK_InterForm : public CPDF_FormNotify
{
@@ -180,9 +235,19 @@ public:
void AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidget);
void RemoveMap(CPDF_FormControl* pControl);
+ void AddXFAMap(XFA_HWIDGET hWidget, CPDFSDK_XFAWidget* pWidget);
+ void RemoveXFAMap(XFA_HWIDGET hWidget);
+ CPDFSDK_XFAWidget* GetXFAWidget(XFA_HWIDGET hWidget);
+
void EnableCalculate(FX_BOOL bEnabled);
FX_BOOL IsCalculateEnabled() const;
+ void XfaEnableCalculate(FX_BOOL bEnabled);
+ FX_BOOL IsXfaCalculateEnabled() const;
+
+ FX_BOOL IsXfaValidationsEnabled();
+ void XfaSetValidationsEnabled(FX_BOOL bEnabled);
+
#ifdef _WIN32
CPDF_Stream* LoadImageFromFile(const CFX_WideString& sFile);
#endif
@@ -216,6 +281,8 @@ public:
FX_BOOL ImportFormFromTxtFile(const CFX_WideString& sTxtFileName);
CFX_WideString GetTemporaryFileName(const CFX_WideString& sFileExt);
+ void SynchronizeField(CPDF_FormField* pFormField, FX_BOOL bSynchronizeElse);
+
private:
virtual int BeforeValueChange(const CPDF_FormField* pField, CFX_WideString& csValue);
virtual int AfterValueChange(const CPDF_FormField* pField);
@@ -237,7 +304,11 @@ private:
CPDFSDK_Document* m_pDocument;
CPDF_InterForm* m_pInterForm;
CPDFSDK_WidgetMap m_Map;
+ CPDFSDK_XFAWidgetMap m_XFAMap;
+ CPDFSDK_FieldSynchronizeMap m_FieldSynchronizeMap;
FX_BOOL m_bCalculate;
+ FX_BOOL m_bXfaCalculate;
+ FX_BOOL m_bXfaValidationsEnabled;
FX_BOOL m_bBusy;
public:
@@ -248,9 +319,9 @@ public:
void SetHighlightColor(FX_COLORREF clr, int nFieldType);
FX_COLORREF GetHighlightColor(int nFieldType);
private:
- FX_COLORREF m_aHighlightColor[6];
+ FX_COLORREF m_aHighlightColor[7];
FX_BYTE m_iHighlightAlpha;
- FX_BOOL m_bNeedHightlight[6];
+ FX_BOOL m_bNeedHightlight[7];
};
#define BAI_STRUCTURE 0
diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h
index d249f0887f..b95d63eab4 100644
--- a/fpdfsdk/include/fsdk_define.h
+++ b/fpdfsdk/include/fsdk_define.h
@@ -59,7 +59,14 @@
#include "../../core/include/fpdfdoc/fpdf_vt.h"
#include "../../core/include/fxcrt/fx_xml.h"
- // #include "../../core/include/fdrm/fx_crypt.h"
+ #include "../../xfa/include/fxbarcode/BC_BarCode.h"
+ #include "../../xfa/include/fxjse/fxjse.h"
+ #include "../../xfa/include/fxgraphics/fx_graphics.h"
+ #include "../../xfa/include/fxfa/fxfa.h"
+
+ #include "../../xfa/include/fwl/core/fwl_error.h"
+ #include "../../xfa/include/fwl/core/fwl_timer.h"
+ #include "../../xfa/include/fwl/adapter/fwl_adaptertimermgr.h"
#ifdef _LICENSED_BUILD_
#include "../../cryptopp/Cryptlib.h"
#endif
@@ -107,14 +114,41 @@ public:
CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess);
~CPDF_CustomAccess() {}
+ virtual CFX_ByteString GetFullPath() { return ""; }
virtual FX_FILESIZE GetSize() FX_OVERRIDE { return m_FileAccess.m_FileLen; }
+ virtual FX_BOOL GetByte(FX_DWORD pos, FX_BYTE& ch);
+ virtual FX_BOOL GetBlock(FX_DWORD pos, FX_LPBYTE pBuf, FX_DWORD size);
virtual void Release() FX_OVERRIDE { delete this; }
virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) FX_OVERRIDE;
-private:
FPDF_FILEACCESS m_FileAccess;
+ FX_BYTE m_Buffer[512];
+ FX_DWORD m_BufferOffset;
+};
+
+class CFPDF_FileStream : public IFX_FileStream, public CFX_Object
+{
+public:
+ CFPDF_FileStream(FPDF_FILEHANDLER* pFS);
+ virtual ~CFPDF_FileStream() {}
+
+ virtual IFX_FileStream* Retain();
+ virtual void Release();
+
+ virtual FX_FILESIZE GetSize();
+ virtual FX_BOOL IsEOF();
+ virtual FX_FILESIZE GetPosition() {return m_nCurPos;}
+ virtual void SetPosition(FX_FILESIZE pos) {m_nCurPos = pos; }
+ virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size);
+ virtual size_t ReadBlock(void* buffer, size_t size);
+ virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size);
+ virtual FX_BOOL Flush();
+
+protected:
+ FPDF_FILEHANDLER* m_pFS;
+ FX_FILESIZE m_nCurPos;
};
void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable);
diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h
index a6f990c36f..5f82919e49 100644
--- a/fpdfsdk/include/fsdk_mgr.h
+++ b/fpdfsdk/include/fsdk_mgr.h
@@ -10,6 +10,8 @@
#include "fsdk_common.h"
#include "fsdk_define.h"
#include "fx_systemhandler.h"
+#include "fpdfxfa/fpdfxfa_doc.h"
+#include "fpdfxfa/fpdfxfa_page.h"
#include "fsdk_baseannot.h"
#include "fsdk_baseform.h"
#include "fpdfformfill.h"
@@ -34,11 +36,17 @@ class CJS_RuntimeFactory;
class CPDFDoc_Environment FX_FINAL
{
public:
- CPDFDoc_Environment(CPDF_Document * pDoc);
+ CPDFDoc_Environment(CPDFXFA_Document * pDoc);
~CPDFDoc_Environment();
int RegAppHandle(FPDF_FORMFILLINFO* pFFinfo);//{ m_pInfo = pFFinfo; return TRUE;}
+ virtual void Release()
+ {
+ if (m_pInfo && m_pInfo->Release)
+ m_pInfo->Release(m_pInfo);
+ delete this;
+ }
void FFI_Invalidate(FPDF_PAGE page, double left, double top, double right, double bottom)
{
if (m_pInfo && m_pInfo->FFI_Invalidate)
@@ -345,19 +353,359 @@ public:
}
}
+ void FFI_DisplayCaret(FPDF_PAGE page, FPDF_BOOL bVisible, double left, double top, double right, double bottom)
+ {
+ if (m_pInfo && m_pInfo->FFI_DisplayCaret)
+ {
+ m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right, bottom);
+ }
+ }
+ int FFI_GetCurrentPageIndex(FPDF_DOCUMENT document)
+ {
+ if (m_pInfo && m_pInfo->FFI_GetCurrentPageIndex)
+ {
+ m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document);
+ }
+ return -1;
+ }
+ int FFI_SetCurrentPage(FPDF_DOCUMENT document, int iCurPage)
+ {
+ if (m_pInfo && m_pInfo->FFI_SetCurrentPage)
+ {
+ m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage);
+ }
+ return -1;
+ }
+
+ CFX_WideString FFI_GetAppName()
+ {
+ return CFX_WideString(L"Acrobat");
+
+ //if (m_pInfo && m_pInfo->FFI_GetAppName)
+ //{
+ // int nLen = m_pInfo->FFI_GetAppName(m_pInfo, NULL, 0);
+ // if(nLen <= 0)
+ // return L"";
+ // char* pbuff = new char[nLen];
+ // if(pbuff)
+ // memset(pbuff, 0, nLen);
+ // else
+ // return L"";
+ // nLen = m_pInfo->FFI_GetAppName(m_pInfo, pbuff, nLen);
+ // CFX_ByteString bsRet = CFX_ByteString(pbuff, nLen);
+ // CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet);
+ // delete[] pbuff;
+ // return wsRet;
+ //}
+
+ //return L"";
+ }
+
+ CFX_WideString FFI_GetPlatform()
+ {
+ if (m_pInfo && m_pInfo->FFI_GetPlatform)
+ {
+ int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, NULL, 0);
+ if (nRequiredLen <= 0)
+ return L"";
+
+ char* pbuff = new char[nRequiredLen];
+ if (!pbuff)
+ return L"";
+
+ memset(pbuff, 0, nRequiredLen);
+ int nActualLen = m_pInfo->FFI_GetPlatform(m_pInfo, pbuff, nRequiredLen);
+ if (nActualLen <= 0 || nActualLen > nRequiredLen)
+ {
+ delete[] pbuff;
+ return L"";
+ }
+ CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen);
+ CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short));
+ delete[] pbuff;
+ return wsRet;
+ }
+ return L"";
+ }
+
+ void FFI_GotoURL(FPDF_DOCUMENT document, FX_WSTR wsURL, FX_BOOL bAppend)
+ {
+ if (m_pInfo && m_pInfo->FFI_GotoURL)
+ {
+ CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Encode();
+ FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(wsURL.GetLength());
+ m_pInfo->FFI_GotoURL(m_pInfo, document, pTo);
+ bsTo.ReleaseBuffer();
+ }
+ }
+ void FFI_GetURL(FPDF_DOCUMENT document, CFX_WideString& wsURL)
+ {
+ wsURL = CFX_WideString();
+ return;
+ //if (m_pInfo && m_pInfo->FFI_GetURL)
+ //{
+ // FPDF_WIDESTRING url = m_pInfo->FFI_GetURL(m_pInfo, document);
+ // CFX_WideString tmp;
+ // tmp.FromUTF16LE(url);
+ // wsURL = tmp;
+ //}
+ }
+
+ void FFI_AddDoRecord(FPDF_DOCUMENT document, FPDF_WIDGET hWidget)
+ {
+ //if (m_pInfo && m_pInfo->FFI_AddDoRecord)
+ //{
+ // m_pInfo->FFI_AddDoRecord(m_pInfo, document, hWidget);
+ //}
+ }
+ void FFI_PageEvent(FPDF_PAGE page, FPDF_DWORD flag)
+ {
+ //if (m_pInfo && m_pInfo->FFI_PageEvent)
+ //{
+ // m_pInfo->FFI_PageEvent(m_pInfo, page, flag);
+ //}
+ }
+
+ void FFI_GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect)
+ {
+ if (m_pInfo && m_pInfo->FFI_GetPageViewRect)
+ {
+ double left;
+ double top;
+ double right;
+ double bottom;
+ m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom);
+
+ dstRect.left = left;
+ dstRect.top = top < bottom? bottom:top;
+ dstRect.bottom = top < bottom? top:bottom;
+ dstRect.right = right;
+ }
+ }
+
+
+ FX_BOOL FFI_PopupMenu(FPDF_PAGE page, FPDF_WIDGET hWidget, int menuFlag, CFX_PointF ptPopup, const CFX_PointF* pRectExclude)
+ {
+ if (m_pInfo && m_pInfo->FFI_PopupMenu)
+ {
+ return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, ptPopup.x, ptPopup.y);
+ }
+ return FALSE;
+ }
+
+ void FFI_Alert(FPDF_WIDESTRING Msg, FPDF_WIDESTRING Title, int Type, int Icon)
+ {
+ if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert)
+ {
+ m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, Msg, Title, Type, Icon);
+ }
+ }
+ void FFI_EmailTo(FPDF_FILEHANDLER* fileHandler, FPDF_WIDESTRING pTo, FPDF_WIDESTRING pSubject, FPDF_WIDESTRING pCC, FPDF_WIDESTRING pBcc, FPDF_WIDESTRING pMsg)
+ {
+ if(m_pInfo && m_pInfo->FFI_EmailTo)
+ {
+ m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc, pMsg);
+ }
+ }
+ void FFI_UploadTo(FPDF_FILEHANDLER* fileHandler, int fileFlag, FPDF_WIDESTRING uploadTo)
+ {
+ if(m_pInfo && m_pInfo->FFI_UploadTo)
+ {
+ m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo);
+ }
+ }
+ FPDF_FILEHANDLER* FFI_OpenFile(int fileType, FPDF_WIDESTRING wsURL, const char* mode)
+ {
+ if(m_pInfo && m_pInfo->FFI_OpenFile)
+ {
+ return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode);
+ }
+ return NULL;
+ }
+ CFX_WideString FFI_GetFilePath(FPDF_FILEHANDLER* pFileHandler)
+ {
+#if 0
+ if (m_pInfo && m_pInfo->FFI_GetFilePath)
+ {
+ int nRequiredLen = m_pInfo->FFI_GetFilePath(m_pInfo, pFileHandler, NULL, 0);
+ if (nRequiredLen <= 0)
+ return L"";
+
+ char* pbuff = new char[nRequiredLen];
+ if (!pbuff)
+ return L"";
+
+ memset(pbuff, 0, nRequiredLen);
+ int nActualLen = m_pInfo->FFI_GetFilePath(m_pInfo, pFileHandler, pbuff, nRequiredLen);
+ if (nActualLen <= 0 || nActualLen > nRequiredLen)
+ {
+ delete[] pbuff;
+ return L"";
+ }
+ CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen);
+ CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short));
+ delete[] pbuff;
+ return wsRet;
+ }
+ return L"";
+#else
+ return L"";
+#endif
+ }
+ int FFI_GetDocumentCount()
+ {
+ //if (m_pInfo && m_pInfo->FFI_GetDocumentCount)
+ //{
+ //return m_pInfo->FFI_GetDocumentCount(m_pInfo);
+ //}
+ return 0;
+ }
+
+ int FFI_GetCurDocument()
+ {
+ //if (m_pInfo && m_pInfo->FFI_GetCurDocumentIndex)
+ //{
+ // return m_pInfo->FFI_GetCurDocumentIndex(m_pInfo);
+ //}
+ return 0;
+ }
+
+ IFX_FileRead* FFI_DownloadFromURL(FX_LPCWSTR url)
+ {
+ if (m_pInfo && m_pInfo->FFI_DownloadFromURL)
+ {
+ CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Encode();
+ FPDF_WIDESTRING wsURL = (FPDF_WIDESTRING)bstrURL.GetBuffer(bstrURL.GetLength());
+
+ FPDF_LPFILEHANDLER fileHandler = m_pInfo->FFI_DownloadFromURL(m_pInfo, wsURL);
+
+ CFPDF_FileStream* fileStream = FX_NEW CFPDF_FileStream(fileHandler);
+ return fileStream;
+ }
+ return NULL;
+ }
+
+ CFX_WideString FFI_PostRequestURL(FX_LPCWSTR wsURL, FX_LPCWSTR wsData, FX_LPCWSTR wsContentType, FX_LPCWSTR wsEncode, FX_LPCWSTR wsHeader)
+ {
+ if (m_pInfo && m_pInfo->FFI_PostRequestURL)
+ {
+ CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode();
+ FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength());
+
+ CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode();
+ FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength());
+
+ CFX_ByteString bsContentType = CFX_WideString(wsContentType).UTF16LE_Encode();
+ FPDF_WIDESTRING contentType = (FPDF_WIDESTRING)bsContentType.GetBuffer(bsContentType.GetLength());
+
+ CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode();
+ FPDF_WIDESTRING encode = (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength());
+
+ CFX_ByteString bsHeader = CFX_WideString(wsHeader).UTF16LE_Encode();
+ FPDF_WIDESTRING header = (FPDF_WIDESTRING)bsHeader.GetBuffer(bsHeader.GetLength());
+
+ FPDF_BSTR respone;
+ FPDF_BStr_Init(&respone);
+ FPDF_BOOL bRet = m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, header, &respone);
+
+ CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)respone.str, respone.len/sizeof(unsigned short));
+ FPDF_BStr_Clear(&respone);
+
+ return wsRet;
+ }
+ return L"";
+ }
+
+ FPDF_BOOL FFI_PutRequestURL(FX_LPCWSTR wsURL, FX_LPCWSTR wsData, FX_LPCWSTR wsEncode)
+ {
+ if (m_pInfo && m_pInfo->FFI_PutRequestURL)
+ {
+ CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode();
+ FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength());
+
+ CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode();
+ FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength());
+
+ CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode();
+ FPDF_WIDESTRING encode = (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength());
+
+ return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, encode);
+ }
+ return FALSE;
+ }
+
+ FPDF_BOOL FFI_ShowFileDialog(FX_LPCWSTR wsTitle, FX_LPCWSTR wsFilter, CFX_WideStringArray &wsPathArr, FX_BOOL bOpen)
+ {
+ /*CFX_ByteString bsTitle = CFX_WideString(wsTitle).UTF16LE_Encode();
+ FPDF_WIDESTRING title = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength());
+
+ CFX_ByteString bsFilter = CFX_WideString(wsFilter).UTF16LE_Encode();
+ FPDF_WIDESTRING filter = (FPDF_WIDESTRING)bsFilter.GetBuffer(bsFilter.GetLength());
+
+ CFX_ByteStringArray* strPathArr = FX_NEW CFX_ByteStringArray();
+ if (m_pInfo && m_pInfo->FFI_ShowFileDialog)
+ {
+ FPDF_BOOL bRet = m_pInfo->FFI_ShowFileDialog(m_pInfo, title, filter, bOpen, (FPDF_STRINGHANDLE)strPathArr);
+ if (bRet)
+ {
+ int count = strPathArr->GetSize();
+ for (int i=0; i<count; i++)
+ {
+ CFX_ByteString bsPath = *strPathArr->GetDataPtr(i);
+ CFX_WideString wsPath = CFX_WideString::FromUTF16LE((unsigned short*)bsPath.GetBuffer(bsPath.GetLength()), bsPath.GetLength()/sizeof(unsigned short));
+ if (!wsPath.IsEmpty())
+ wsPathArr.Add(wsPath);
+ wsPath = L"";
+ }
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+ */
+
+ return FALSE;
+ }
+ CFX_WideString FFI_GetLanguage()
+ {
+ if (m_pInfo && m_pInfo->FFI_GetLanguage)
+ {
+ int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, NULL, 0);
+ if (nRequiredLen <= 0)
+ return L"";
+
+ char* pbuff = new char[nRequiredLen];
+ if (!pbuff)
+ return L"";
+
+ memset(pbuff, 0, nRequiredLen);
+ int nActualLen = m_pInfo->FFI_GetLanguage(m_pInfo, pbuff, nRequiredLen);
+ if (nActualLen <= 0 || nActualLen > nRequiredLen)
+ {
+ delete[] pbuff;
+ return L"";
+ }
+ CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen);
+ CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short));
+ delete[] pbuff;
+ return wsRet;
+ }
+ return L"";
+ }
+
public:
FX_BOOL IsJSInitiated();
public:
void SetCurrentDoc(CPDFSDK_Document* pFXDoc) {m_pSDKDoc = pFXDoc;}
CPDFSDK_Document* GetCurrentDoc();
- CPDF_Document* GetPDFDocument() {return m_pPDFDoc;}
+ CPDFXFA_Document* GetPDFXFADocument() {return m_pDoc;}
// CPDFSDK_Document* GetDocument(int nIndex);
// int CountDocuments() {return m_docMap.GetCount();}
- CPDFSDK_Document* OpenDocument(CFX_WideString &fileName);
- CPDFSDK_Document* OpenMemPDFDoc(CPDF_Document* pNewDoc, CFX_WideString &fileName);
- FX_BOOL OpenURL(CFX_WideString &filePath);
+ CPDFSDK_Document* OpenDocument(CFX_WideString &fileName){return NULL;}
+ CPDFSDK_Document* OpenMemPDFDoc(CPDF_Document* pNewDoc, CFX_WideString &fileName){return NULL;}
+ FX_BOOL OpenURL(CFX_WideString &filePath){return FALSE;}
CFX_ByteString GetAppName() {return "";}
@@ -379,13 +727,13 @@ private:
FPDF_FORMFILLINFO* m_pInfo;
// CFX_MapPtrTemplate<CPDF_Document*, CPDFSDK_Document*> m_docMap;
CPDFSDK_Document* m_pSDKDoc;
- CPDF_Document* m_pPDFDoc;
+ CPDFXFA_Document* m_pDoc;
CFFL_IFormFiller* m_pIFormFiller;
IFX_SystemHandler* m_pSysHandler;
public:
- CJS_RuntimeFactory* m_pJSRuntimeFactory;
+ //CJS_RuntimeFactory* m_pJSRuntimeFactory;
};
@@ -407,19 +755,20 @@ class CPDFSDK_InterForm;
class CPDFSDK_Document
{
public:
- CPDFSDK_Document(CPDF_Document* pDoc, CPDFDoc_Environment* pEnv);
+ CPDFSDK_Document(CPDFXFA_Document* pDoc, CPDFDoc_Environment* pEnv);
~CPDFSDK_Document();
public:
CPDFSDK_InterForm* GetInterForm() ;
- CPDF_Document* GetDocument() {return m_pDoc;}
+ CPDFXFA_Document* GetDocument() {return m_pDoc;}
public:
void InitPageView();
- void AddPageView(CPDF_Page* pPDFPage, CPDFSDK_PageView* pPageView);
- CPDFSDK_PageView* GetPageView(CPDF_Page* pPDFPage, FX_BOOL ReNew = TRUE);
+ int GetPageViewCount(){return m_pageMap.GetCount();}
+ void AddPageView(CPDFXFA_Page* pPDFXFAPage, CPDFSDK_PageView* pPageView);
+ CPDFSDK_PageView* GetPageView(CPDFXFA_Page* pPDFXFAPage, FX_BOOL ReNew = TRUE);
CPDFSDK_PageView* GetPageView(int nIndex);
CPDFSDK_PageView* GetCurrentView();
- void ReMovePageView(CPDF_Page* pPDFPage);
+ void ReMovePageView(CPDFXFA_Page* pPDFPage);
void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot);
CPDFSDK_Annot* GetFocusAnnot();//{return NULL;}
@@ -444,15 +793,15 @@ public:
// FX_BOOL GetChangeMark(){return FALSE;}//IsAnnotModified()||IsFormModified() || IsWidgetModified()|| m_nChangeMark>0 ;}
// void ClearChangeMark(){}
CFX_WideString GetPath() ;
- CPDF_Page* GetPage(int nIndex);
+ CPDFXFA_Page* GetPage(int nIndex);
CPDFDoc_Environment * GetEnv() {return m_pEnv; }
void ProcJavascriptFun();
FX_BOOL ProcOpenAction();
CPDF_OCContext* GetOCContext();
private:
//CFX_ArrayTemplate<CPDFSDK_PageView*> m_pageArray;
- CFX_MapPtrTemplate<CPDF_Page*, CPDFSDK_PageView*> m_pageMap;
- CPDF_Document* m_pDoc;
+ CFX_MapPtrTemplate<CPDFXFA_Page*, CPDFSDK_PageView*> m_pageMap;
+ CPDFXFA_Document* m_pDoc;
CPDFSDK_InterForm* m_pInterForm;
CPDFSDK_Annot* m_pFocusAnnot;
@@ -460,12 +809,13 @@ private:
CPDF_OCContext * m_pOccontent;
FX_BOOL m_bChangeMask;
};
+
class CPDFSDK_PageView FX_FINAL
{
public:
- CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page);
+ CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDFXFA_Page* page);
~CPDFSDK_PageView();
- void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions) ;
+ void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions, FX_RECT* pClip = NULL) ;
CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
@@ -478,16 +828,21 @@ public:
CPDFSDK_Annot* AddAnnot(CPDF_Dictionary * pDict);
CPDFSDK_Annot* AddAnnot(FX_LPCSTR lpSubType,CPDF_Dictionary * pDict);
CPDFSDK_Annot* AddAnnot(CPDF_Annot * pPDFAnnot);
+ CPDFSDK_Annot* AddAnnot(XFA_HWIDGET pPDFAnnot);
FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot);
int CountAnnots();
CPDFSDK_Annot* GetAnnot(int nIndex);
CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary * pDict);
- CPDF_Page* GetPDFPage(){return m_page;}
+ CPDFSDK_Annot* GetAnnotByXFAWidget(XFA_HWIDGET hWidget);
+ CPDFXFA_Page* GetPDFXFAPage(){return m_page;}
+ CPDF_Page* GetPDFPage();
CPDF_Document* GetPDFDocument();
CPDFSDK_Document* GetSDKDocument() {return m_pSDKDoc;}
FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag);
FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag);
+ FX_BOOL OnRButtonDown(const CPDF_Point & point, FX_UINT nFlag);
+ FX_BOOL OnRButtonUp(const CPDF_Point & point, FX_UINT nFlag);
FX_BOOL OnChar(int nChar, FX_UINT nFlag);
FX_BOOL OnKeyDown(int nKeyCode, int nFlag);
FX_BOOL OnKeyUp(int nKeyCode, int nFlag);
@@ -502,27 +857,26 @@ public:
int GetPageIndex();
void LoadFXAnnots();
-
- void SetValid(FX_BOOL bValid) {m_bValid = bValid;}
- FX_BOOL IsValid() {return m_bValid;}
- void SetLock(FX_BOOL bLocked) {m_bLocked= bLocked;}
- FX_BOOL IsLocked() {return m_bLocked;}
- void TakeOverPage() {m_bTakeOverPage = TRUE;}
+ void SetValid(FX_BOOL bValid) {m_bValid = bValid;}
+ FX_BOOL IsValid() {return m_bValid;}
+ void SetLock(FX_BOOL bLocked) {m_bLocked= bLocked;}
+ FX_BOOL IsLocked() {return m_bLocked;}
+ void TakeOverPage() {m_bTakeOverPage = TRUE;}
private:
void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, CPDFSDK_Widget* pWidget);
- CPDF_Matrix m_curMatrix;
- CPDF_Page* m_page;
+ CPDF_Matrix m_curMatrix;
+ CPDFXFA_Page* m_page;
CPDF_AnnotList* m_pAnnotList;
//CPDFSDK_Annot* m_pFocusAnnot;
CFX_PtrArray m_fxAnnotArray;
CPDFSDK_Document* m_pSDKDoc;
- CPDFSDK_Widget* m_CaptureWidget;
+ CPDFSDK_Annot* m_CaptureWidget;
FX_BOOL m_bEnterWidget;
FX_BOOL m_bExitWidget;
FX_BOOL m_bOnWidget;
FX_BOOL m_bValid;
- FX_BOOL m_bLocked;
- FX_BOOL m_bTakeOverPage;
+ FX_BOOL m_bLocked;
+ FX_BOOL m_bTakeOverPage;
};
diff --git a/fpdfsdk/include/javascript/IJavaScript.h b/fpdfsdk/include/javascript/IJavaScript.h
index 7633bbb486..7754537af2 100644
--- a/fpdfsdk/include/javascript/IJavaScript.h
+++ b/fpdfsdk/include/javascript/IJavaScript.h
@@ -88,6 +88,8 @@ public:
virtual void Exit() = 0;
virtual void Enter() = 0;
virtual FX_BOOL IsEntered() = 0;
+ virtual FX_BOOL GetHValueByName(FX_BSTR utf8Name, FXJSE_HVALUE hValue) = 0;
+ virtual FX_BOOL SetHValueByName(FX_BSTR utf8Name, FXJSE_HVALUE hValue) = 0;
};
class CPDFDoc_Environment;
diff --git a/fpdfsdk/include/javascript/JS_Context.h b/fpdfsdk/include/javascript/JS_Context.h
index 806808651d..adb28cdaed 100644
--- a/fpdfsdk/include/javascript/JS_Context.h
+++ b/fpdfsdk/include/javascript/JS_Context.h
@@ -74,7 +74,7 @@ public:
FX_BOOL IsMsgBoxEnabled() const {return m_bMsgBoxEnable;}
public:
- CPDFDoc_Environment* GetReaderApp();
+ CPDFDoc_Environment* GetReaderApp();
CJS_Runtime* GetJSRuntime(){return m_pRuntime;}
FX_BOOL DoJob(int nMode, const CFX_WideString& script, CFX_WideString& info);
diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h
index 108c1e23ee..1798e01591 100644
--- a/fpdfsdk/include/javascript/JS_Define.h
+++ b/fpdfsdk/include/javascript/JS_Define.h
@@ -93,11 +93,8 @@ typedef CFX_WideString JS_ErrorString;
{\
v8::Isolate* isolate = info.GetIsolate();\
v8::Local<v8::Context> context = isolate->GetCurrentContext();\
- v8::Local<v8::Value> v = context->GetEmbedderData(1);\
- ASSERT(!v.IsEmpty());\
- if(v.IsEmpty()) return;\
- v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\
- IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\
+ IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\
+ if (pRuntime == NULL) return;\
IFXJS_Context* cc = pRuntime->GetCurrentContext();\
CJS_PropValue value(isolate);\
value.StartGetting();\
@@ -129,11 +126,8 @@ typedef CFX_WideString JS_ErrorString;
{\
v8::Isolate* isolate = info.GetIsolate();\
v8::Local<v8::Context> context = isolate->GetCurrentContext();\
- v8::Local<v8::Value> v = context->GetEmbedderData(1);\
- ASSERT(!v.IsEmpty());\
- if(v.IsEmpty()) return;\
- v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\
- IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\
+ IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\
+ if (pRuntime == NULL) return;\
IFXJS_Context* cc = pRuntime->GetCurrentContext();\
CJS_PropValue propValue(CJS_Value(isolate,value,VT_unknown));\
propValue.StartSetting();\
@@ -170,11 +164,8 @@ JS_STATIC_PROP_SET(prop_name, class_name)
{\
v8::Isolate* isolate = info.GetIsolate();\
v8::Local<v8::Context> context = isolate->GetCurrentContext();\
- v8::Local<v8::Value> v = context->GetEmbedderData(1);\
- ASSERT(!v.IsEmpty());\
- if(v.IsEmpty()) return;\
- v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\
- IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\
+ IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\
+ if (pRuntime == NULL) return;\
IFXJS_Context* cc = pRuntime->GetCurrentContext();\
CJS_Parameters parameters;\
for (unsigned int i = 0; i<(unsigned int)info.Length(); i++)\
@@ -359,11 +350,8 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\
{\
v8::Isolate* isolate = info.GetIsolate();\
v8::Local<v8::Context> context = isolate->GetCurrentContext();\
- v8::Local<v8::Value> v = context->GetEmbedderData(1);\
- ASSERT(!v.IsEmpty());\
- if(v.IsEmpty()) return;\
- v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\
- IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\
+ IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\
+ if (pRuntime == NULL) return;\
IFXJS_Context* cc = pRuntime->GetCurrentContext();\
v8::String::Utf8Value utf8_value(property);\
CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());\
@@ -397,11 +385,8 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\
{\
v8::Isolate* isolate = info.GetIsolate();\
v8::Local<v8::Context> context = isolate->GetCurrentContext();\
- v8::Local<v8::Value> v = context->GetEmbedderData(1);\
- ASSERT(!v.IsEmpty());\
- if(v.IsEmpty()) return;\
- v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\
- IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\
+ IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\
+ if (pRuntime == NULL) return;\
IFXJS_Context* cc = pRuntime->GetCurrentContext();\
v8::String::Utf8Value utf8_value(property);\
CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());\
@@ -434,11 +419,8 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\
{\
v8::Isolate* isolate = info.GetIsolate();\
v8::Local<v8::Context> context = isolate->GetCurrentContext();\
- v8::Local<v8::Value> v = context->GetEmbedderData(1);\
- ASSERT(!v.IsEmpty());\
- if(v.IsEmpty()) return;\
- v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\
- IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\
+ IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\
+ if (pRuntime == NULL) return;\
IFXJS_Context* cc = pRuntime->GetCurrentContext();\
v8::String::Utf8Value utf8_value(property);\
CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());\
@@ -525,11 +507,8 @@ void js_class_name::GetMethods(JSMethodSpec*& pMethods, int& nSize)\
{\
v8::Isolate* isolate = info.GetIsolate();\
v8::Local<v8::Context> context = isolate->GetCurrentContext();\
- v8::Local<v8::Value> v = context->GetEmbedderData(1);\
- ASSERT(!v.IsEmpty());\
- if(v.IsEmpty()) return;\
- v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\
- IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\
+ IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\
+ if (pRuntime == NULL) return;\
IFXJS_Context* cc = pRuntime->GetCurrentContext();\
CJS_Parameters parameters;\
for (unsigned int i = 0; i<(unsigned int)info.Length(); i++)\
@@ -568,11 +547,8 @@ static void fun_name##_static(JS_METHOD_ARGS)\
{\
v8::Isolate* isolate = info.GetIsolate();\
v8::Local<v8::Context> context = isolate->GetCurrentContext();\
- v8::Local<v8::Value> v = context->GetEmbedderData(1);\
- ASSERT(!v.IsEmpty());\
- if(v.IsEmpty()) return;\
- v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\
- IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\
+ IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\
+ if (pRuntime == NULL) return;\
IFXJS_Context* cc = pRuntime->GetCurrentContext();\
CJS_Parameters parameters;\
for (unsigned int i = 0; i<(unsigned int)info.Length(); i++)\
diff --git a/fpdfsdk/include/javascript/JS_GlobalData.h b/fpdfsdk/include/javascript/JS_GlobalData.h
index 8eee158a00..c54d7b550d 100644
--- a/fpdfsdk/include/javascript/JS_GlobalData.h
+++ b/fpdfsdk/include/javascript/JS_GlobalData.h
@@ -91,6 +91,7 @@ private:
private:
CFX_ArrayTemplate<CJS_GlobalData_Element*> m_arrayGlobalData;
CFX_WideString m_sFilePath;
+ CPDFDoc_Environment* m_pApp;
};
#endif //_JS_GLOBALDATA_H_
diff --git a/fpdfsdk/include/javascript/JS_Object.h b/fpdfsdk/include/javascript/JS_Object.h
index a6dac5d2a3..ca6f4a1d11 100644
--- a/fpdfsdk/include/javascript/JS_Object.h
+++ b/fpdfsdk/include/javascript/JS_Object.h
@@ -26,7 +26,7 @@ public:
operator CJS_Object* (){return m_pJSObject;};
CPDFSDK_PageView * JSGetPageView(IFXJS_Context* cc);
- int MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swTitle = NULL, FX_UINT nType = 0, FX_UINT nIcon = 0);
+ int MsgBox(CPDFDoc_Environment * pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swTitle = NULL, FX_UINT nType = 0, FX_UINT nIcon = 0);
void Alert(CJS_Context* pContext, FX_LPCWSTR swMsg);
FX_BOOL IsSafeMode(IFXJS_Context* cc);
@@ -56,7 +56,7 @@ public:
CJS_EmbedObj * GetEmbedObject(){return m_pEmbedObj;};
static CPDFSDK_PageView * JSGetPageView(IFXJS_Context* cc);
- static int MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swTitle = NULL, FX_UINT nType = 0,FX_UINT nIcon = 0);
+ static int MsgBox(CPDFDoc_Environment * pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swTitle = NULL, FX_UINT nType = 0,FX_UINT nIcon = 0);
static void Alert(CJS_Context* pContext, FX_LPCWSTR swMsg);
v8::Isolate* GetIsolate() {return m_pIsolate;}
@@ -164,7 +164,7 @@ class CJS_Runtime;
class CJS_Timer
{
public:
- CJS_Timer(CJS_EmbedObj * pObj,CPDFDoc_Environment* pApp):
+ CJS_Timer(CJS_EmbedObj * pObj, CPDFDoc_Environment* pApp):
m_nTimerID(0),
m_pEmbedObj(pObj),
m_bProcessing(FALSE),
@@ -197,6 +197,11 @@ public:
{
if (m_nTimerID)
{
+ if (m_pApp == NULL) {
+ m_sTimeMap.RemoveAt(m_nTimerID);
+ m_nTimerID = 0;
+ return;
+ }
IFX_SystemHandler* pHandler = m_pApp->GetSysHandler();
pHandler->KillTimer(m_nTimerID);
m_sTimeMap.RemoveAt(m_nTimerID);
@@ -277,8 +282,8 @@ private:
FX_BOOL m_bProcessing;
//data
- FX_DWORD m_dwStartTime;
- FX_DWORD m_dwTimeOut;
+ FX_DWORD m_dwStartTime;
+ FX_DWORD m_dwTimeOut;
FX_DWORD m_dwElapse;
CJS_Runtime* m_pRuntime;
CFX_WideString m_swJScript;
diff --git a/fpdfsdk/include/javascript/JS_Runtime.h b/fpdfsdk/include/javascript/JS_Runtime.h
index 0a195f132c..217a985869 100644
--- a/fpdfsdk/include/javascript/JS_Runtime.h
+++ b/fpdfsdk/include/javascript/JS_Runtime.h
@@ -37,7 +37,7 @@ public:
virtual void Enter();
virtual FX_BOOL IsEntered();
- CPDFDoc_Environment * GetReaderApp(){return m_pApp;}
+ CPDFDoc_Environment * GetReaderApp(){return m_pApp;}
FX_BOOL InitJSObjects();
@@ -50,19 +50,23 @@ public:
FX_BOOL IsBlocking(){return m_bBlocking;}
operator IJS_Runtime*() {return (IJS_Runtime*)m_isolate;}
- v8::Isolate* GetIsolate(){return m_isolate;};
+ v8::Isolate* GetIsolate(){return m_isolate;};
void SetIsolate(v8::Isolate* isolate){m_isolate = isolate;}
- v8::Handle<v8::Context> NewJSContext();
+ v8::Handle<v8::Context> NewJSContext();
+
+
+ virtual FX_BOOL GetHValueByName(FX_BSTR utf8Name, FXJSE_HVALUE hValue);
+ virtual FX_BOOL SetHValueByName(FX_BSTR utf8Name, FXJSE_HVALUE hValue);
protected:
CFX_ArrayTemplate<CJS_Context *> m_ContextArray;
- CPDFDoc_Environment * m_pApp;
+ CPDFDoc_Environment * m_pApp;
CPDFSDK_Document * m_pDocument;
FX_BOOL m_bBlocking;
CJS_FieldEvent* m_pFieldEventPath;
- v8::Isolate* m_isolate;
- v8::Persistent<v8::Context> m_context;
+ v8::Isolate* m_isolate;
+ v8::Persistent<v8::Context> m_context;
FX_BOOL m_bRegistered;
};
diff --git a/fpdfsdk/include/javascript/JavaScript.h b/fpdfsdk/include/javascript/JavaScript.h
index 166472b61e..ca5922e074 100644
--- a/fpdfsdk/include/javascript/JavaScript.h
+++ b/fpdfsdk/include/javascript/JavaScript.h
@@ -28,6 +28,7 @@
#include "../fxedit/fx_edit.h"
#include "../pdfwindow/IPDFWindow.h"
#include "../fsdk_mgr.h"
+#include "../fpdfxfa/fpdfxfa_app.h"
#include <string>
diff --git a/fpdfsdk/include/pdfwindow/PWL_Edit.h b/fpdfsdk/include/pdfwindow/PWL_Edit.h
index d86cb77d2c..6af324d5f7 100644
--- a/fpdfsdk/include/pdfwindow/PWL_Edit.h
+++ b/fpdfsdk/include/pdfwindow/PWL_Edit.h
@@ -21,6 +21,9 @@ public:
int nSelStart, int nSelEnd,
FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag) = 0;
virtual void OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit, FX_DWORD nFlag) = 0;
+
+ virtual void OnPopupPreOpen(void* pPrivateData, FX_BOOL& bExit, FX_DWORD nFlag) = 0;
+ virtual void OnPopupPostOpen(void* pPrivateData, FX_BOOL& bExit, FX_DWORD nFlag) = 0;
};
class PWL_CLASS CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify
diff --git a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
index ee6b7bd83a..1c5b49812e 100644
--- a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
+++ b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
@@ -348,6 +348,19 @@ void CFFL_ComboBox::OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag)
}
}
+FX_BOOL CFFL_ComboBox::IsFieldFull(CPDFSDK_PageView* pPageView)
+{
+ if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetPDFWindow(pPageView, FALSE))
+ {
+ if (CPWL_Edit* pEdit = (CPWL_Edit*)*pComboBox)
+ {
+ return pEdit->IsTextFull();
+ }
+ }
+
+ return FALSE;
+}
+
void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd)
{
ASSERT(m_pApp != NULL);
diff --git a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
index 530b80ce6f..c9dd6681d2 100644
--- a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
@@ -292,7 +292,7 @@ FX_BOOL CFFL_FormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag)
{
CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- CPDF_Page * pPage = pWidget->GetPDFPage();
+ CPDFXFA_Page * pPage = pWidget->GetPDFXFAPage();
CPDFSDK_Document * pDoc = m_pApp->GetCurrentDoc();
CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage);
ASSERT(pPageView != NULL);
@@ -567,7 +567,7 @@ CPDF_Rect CFFL_FormFiller::GetPDFWindowRect() const
CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView()
{
- CPDF_Page* pPage = m_pAnnot->GetPDFPage();
+ CPDFXFA_Page* pPage = m_pAnnot->GetPDFXFAPage();
CPDFSDK_Document* pSDKDoc = m_pApp->GetCurrentDoc();
if(pSDKDoc)
{
@@ -713,6 +713,11 @@ void CFFL_FormFiller::GetKeyStrokeData(CPDFSDK_PageView* pPageView, FFL_KeyStrok
{
}
+FX_BOOL CFFL_FormFiller::IsFieldFull(CPDFSDK_PageView* pPageView)
+{
+ return FALSE;
+}
+
void CFFL_FormFiller::SetChangeMark()
{
m_pApp->FFI_OnChange();
@@ -803,7 +808,7 @@ void CFFL_FormFiller::DoPaste(CPDFSDK_Document* pDocument)
void CFFL_FormFiller::InvalidateRect(double left, double top, double right, double bottom)
{
- CPDF_Page * pPage = m_pWidget->GetPDFPage();
+ CPDFXFA_Page * pPage = m_pWidget->GetPDFXFAPage();
m_pApp->FFI_Invalidate(pPage, left, top, right, bottom);
}
diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
index 2b21e13cfc..61cb55f66d 100644
--- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
@@ -335,6 +335,9 @@ FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, CPDFSDK_Annot
FX_BOOL bReset = FALSE;
OnButtonUp(pWidget, pPageView, bReset, bExit,nFlags);
if (bExit) return TRUE;
+
+ OnClick(pWidget, pPageView, bReset, bExit, nFlags);
+ if (bExit) return TRUE;
}
return bRet;
}
@@ -830,7 +833,7 @@ void CFFL_IFormFiller::OnSetWindowRect(void* pPrivateData, const CPDF_Rect & rcW
unRect.right = (FX_FLOAT)(unRect.right + 0.5);
unRect.top = (FX_FLOAT)(unRect.top + 0.5);
unRect.bottom = (FX_FLOAT)(unRect.bottom -0.5);
- m_pApp->FFI_Invalidate(pData->pWidget->GetPDFPage(), unRect.left, unRect.top, unRect.right, unRect.bottom);
+ m_pApp->FFI_Invalidate(pData->pWidget->GetPDFXFAPage(), unRect.left, unRect.top, unRect.right, unRect.bottom);
}
}
@@ -1037,6 +1040,190 @@ FX_BOOL CFFL_IFormFiller::GetKeyDown()
// return msg.message == WM_KEYDOWN || msg.message == WM_CHAR;
}
+void CFFL_IFormFiller::OnClick(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag)
+{
+ ASSERT(pWidget != NULL);
+
+ if (!m_bNotifying)
+ {
+ if (pWidget->HasXFAAAction(PDFSDK_XFA_Click))
+ {
+ m_bNotifying = TRUE;
+ int nAge = pWidget->GetAppearanceAge();
+ int nValueAge = pWidget->GetValueAge();
+
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+
+ pWidget->OnXFAAAction(PDFSDK_XFA_Click, fa, pPageView);
+ m_bNotifying = FALSE;
+
+ if (!IsValidAnnot(pPageView, pWidget))
+ {
+ bExit = TRUE;
+ return;
+ }
+
+ if (nAge != pWidget->GetAppearanceAge())
+ {
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+ {
+ pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
+ }
+
+ bReset = TRUE;
+ }
+ }
+ }
+}
+
+void CFFL_IFormFiller::OnFull(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag)
+{
+ ASSERT(pWidget != NULL);
+
+ if (!m_bNotifying)
+ {
+ if (pWidget->HasXFAAAction(PDFSDK_XFA_Full))
+ {
+ m_bNotifying = TRUE;
+ int nAge = pWidget->GetAppearanceAge();
+ int nValueAge = pWidget->GetValueAge();
+
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+
+ pWidget->OnXFAAAction(PDFSDK_XFA_Full, fa, pPageView);
+ m_bNotifying = FALSE;
+
+ if (!IsValidAnnot(pPageView, pWidget))
+ {
+ bExit = TRUE;
+ return;
+ }
+
+ if (nAge != pWidget->GetAppearanceAge())
+ {
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+ {
+ pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
+ }
+
+ bReset = TRUE;
+ }
+ }
+ }
+}
+
+void CFFL_IFormFiller::OnPopupPreOpen(void* pPrivateData, FX_BOOL& bExit, FX_DWORD nFlag)
+{
+ ASSERT(pPrivateData != NULL);
+ CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
+ ASSERT(pData->pWidget != NULL);
+
+ FX_BOOL bTempReset = FALSE;
+ FX_BOOL bTempExit = FALSE;
+ this->OnPreOpen(pData->pWidget, pData->pPageView, bTempReset, bTempExit, nFlag);
+
+ if (bTempReset || bTempExit)
+ {
+ bExit = TRUE;
+ }
+}
+
+void CFFL_IFormFiller::OnPopupPostOpen(void* pPrivateData, FX_BOOL& bExit, FX_DWORD nFlag)
+{
+ ASSERT(pPrivateData != NULL);
+ CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
+ ASSERT(pData->pWidget != NULL);
+
+ FX_BOOL bTempReset = FALSE;
+ FX_BOOL bTempExit = FALSE;
+ this->OnPostOpen(pData->pWidget, pData->pPageView, bTempReset, bTempExit, nFlag);
+
+ if (bTempReset || bTempExit)
+ {
+ bExit = TRUE;
+ }
+}
+
+void CFFL_IFormFiller::OnPreOpen(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag)
+{
+ ASSERT(pWidget != NULL);
+
+ if (!m_bNotifying)
+ {
+ if (pWidget->HasXFAAAction(PDFSDK_XFA_PreOpen))
+ {
+ m_bNotifying = TRUE;
+ int nAge = pWidget->GetAppearanceAge();
+ int nValueAge = pWidget->GetValueAge();
+
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+
+ pWidget->OnXFAAAction(PDFSDK_XFA_PreOpen, fa, pPageView);
+ m_bNotifying = FALSE;
+
+ if (!IsValidAnnot(pPageView, pWidget))
+ {
+ bExit = TRUE;
+ return;
+ }
+
+ if (nAge != pWidget->GetAppearanceAge())
+ {
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+ {
+ pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
+ }
+
+ bReset = TRUE;
+ }
+ }
+ }
+}
+
+void CFFL_IFormFiller::OnPostOpen(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag)
+{
+ ASSERT(pWidget != NULL);
+
+ if (!m_bNotifying)
+ {
+ if (pWidget->HasXFAAAction(PDFSDK_XFA_PostOpen))
+ {
+ m_bNotifying = TRUE;
+ int nAge = pWidget->GetAppearanceAge();
+ int nValueAge = pWidget->GetValueAge();
+
+ PDFSDK_FieldAction fa;
+ fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag);
+ fa.bShift = m_pApp->FFI_IsSHIFTKeyDown(nFlag);
+
+ pWidget->OnXFAAAction(PDFSDK_XFA_PostOpen, fa, pPageView);
+ m_bNotifying = FALSE;
+
+ if (!IsValidAnnot(pPageView, pWidget))
+ {
+ bExit = TRUE;
+ return;
+ }
+
+ if (nAge != pWidget->GetAppearanceAge())
+ {
+ if (CFFL_FormFiller* pFormFiller = GetFormFiller(pWidget, FALSE))
+ {
+ pFormFiller->ResetPDFWindow(pPageView, nValueAge == pWidget->GetValueAge());
+ }
+
+ bReset = TRUE;
+ }
+ }
+ }
+}
+
FX_BOOL CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot)
{
@@ -1109,6 +1296,19 @@ void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData
CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
ASSERT(pFormFiller != NULL);
+ if (pFormFiller->IsFieldFull(pData->pPageView))
+ {
+ FX_BOOL bFullExit = FALSE;
+ FX_BOOL bFullReset = FALSE;
+ OnFull(pData->pWidget, pData->pPageView, bFullReset, bFullExit, nFlag);
+
+ if (bFullReset || bFullExit)
+ {
+ bExit = TRUE;
+ return;
+ }
+ }
+
if (!m_bNotifying)
{
if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke))
diff --git a/fpdfsdk/src/formfiller/FFL_TextField.cpp b/fpdfsdk/src/formfiller/FFL_TextField.cpp
index 45c716280c..f9c93914a5 100644
--- a/fpdfsdk/src/formfiller/FFL_TextField.cpp
+++ b/fpdfsdk/src/formfiller/FFL_TextField.cpp
@@ -176,7 +176,7 @@ FX_BOOL CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFl
ASSERT(pPageView != NULL);
m_bValid = !m_bValid;
CPDF_Rect rcAnnot = pAnnot->GetRect();
- m_pApp->FFI_Invalidate(pAnnot->GetPDFPage(), rcAnnot.left, rcAnnot.top, rcAnnot.right, rcAnnot.bottom);
+ m_pApp->FFI_Invalidate(pAnnot->GetPDFXFAPage(), rcAnnot.left, rcAnnot.top, rcAnnot.right, rcAnnot.bottom);
if (m_bValid)
{
@@ -348,6 +348,16 @@ CPWL_Wnd* CFFL_TextField::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bR
return pRet;
}
+FX_BOOL CFFL_TextField::IsFieldFull(CPDFSDK_PageView* pPageView)
+{
+ if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE))
+ {
+ return pWnd->IsTextFull();
+ }
+
+ return FALSE;
+}
+
void CFFL_TextField::OnSetFocus(CPWL_Wnd* pWnd)
{
ASSERT(m_pApp != NULL);
diff --git a/fpdfsdk/src/fpdf_dataavail.cpp b/fpdfsdk/src/fpdf_dataavail.cpp
index b5483f9c39..efd12078a4 100644
--- a/fpdfsdk/src/fpdf_dataavail.cpp
+++ b/fpdfsdk/src/fpdf_dataavail.cpp
@@ -6,6 +6,9 @@
#include "../include/fsdk_define.h"
#include "../include/fpdf_dataavail.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../include/fpdfformfill.h"
+#include "../include/fpdfxfa/fpdfxfa_app.h"
extern void ProcessParseError(FX_DWORD err_code);
class CFPDF_FileAvailWrap : public IFX_FileAvail
@@ -133,13 +136,19 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYT
}
((CFPDF_DataAvail*)avail)->m_pDataAvail->SetDocument(pParser->GetDocument());
CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS);
- return pParser->GetDocument();
+ CPDF_Document* pPDFDoc = pParser->GetDocument();
+
+ CPDFXFA_App* pApp = FPDFXFA_GetApp();
+ CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pApp);
+ //pDocument->LoadXFADoc();
+
+ return pDocument;
}
DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc)
{
if (doc == NULL) return 0;
- CPDF_Document* pDoc = (CPDF_Document*)doc;
+ CPDF_Document* pDoc = ((CPDFXFA_Document*)doc)->GetPDFDoc();
return ((CPDF_Parser*)pDoc->GetParser())->GetFirstPageNo();
}
diff --git a/fpdfsdk/src/fpdf_ext.cpp b/fpdfsdk/src/fpdf_ext.cpp
index 93f6e187da..512a617920 100644
--- a/fpdfsdk/src/fpdf_ext.cpp
+++ b/fpdfsdk/src/fpdf_ext.cpp
@@ -6,6 +6,7 @@
#include "../include/fsdk_define.h"
#include "../include/fpdf_ext.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
#define FPDFSDK_UNSUPPORT_CALL 100
@@ -220,7 +221,7 @@ void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code)
DLLEXPORT int FPDFDoc_GetPageMode(FPDF_DOCUMENT document)
{
if (!document) return PAGEMODE_UNKNOWN;
- CPDF_Dictionary *pRoot = ((CPDF_Document*)document)->GetRoot();
+ CPDF_Dictionary *pRoot = (((CPDFXFA_Document*)document)->GetPDFDoc())->GetRoot();
if (!pRoot)
return PAGEMODE_UNKNOWN;
CPDF_Object* pName = pRoot->GetElement("PageMode");
diff --git a/fpdfsdk/src/fpdf_flatten.cpp b/fpdfsdk/src/fpdf_flatten.cpp
index 6d3440f556..e07ccc91b7 100644
--- a/fpdfsdk/src/fpdf_flatten.cpp
+++ b/fpdfsdk/src/fpdf_flatten.cpp
@@ -6,6 +6,8 @@
#include "../include/fsdk_define.h"
#include "../include/fpdf_flatten.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../include/fpdfxfa/fpdfxfa_page.h"
typedef CFX_ArrayTemplate<CPDF_Dictionary*> CPDF_ObjectArray;
typedef CFX_ArrayTemplate<CPDF_Rect> CPDF_RectArray;
@@ -332,7 +334,10 @@ DLLEXPORT int STDCALL FPDFPage_Flatten( FPDF_PAGE page, int nFlag)
return FLATTEN_FAIL;
}
- CPDF_Page * pPage = (CPDF_Page*)( page );
+ CPDF_Page * pPage = ((CPDFXFA_Page*)( page ))->GetPDFPage();
+ if (!pPage)
+ return FLATTEN_FAIL;
+
CPDF_Document * pDocument = pPage->m_pDocument;
CPDF_Dictionary * pPageDict = pPage->m_pFormDict;
diff --git a/fpdfsdk/src/fpdf_progressive.cpp b/fpdfsdk/src/fpdf_progressive.cpp
index 2490df8c2f..5226770d48 100644
--- a/fpdfsdk/src/fpdf_progressive.cpp
+++ b/fpdfsdk/src/fpdf_progressive.cpp
@@ -8,6 +8,8 @@
#include "../include/fsdk_define.h"
#include "../include/fpdfview.h"
#include "../include/fsdk_rendercontext.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../include/fpdfxfa/fpdfxfa_page.h"
extern void (*Func_RenderPage)( CRenderContext*, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y,
int rotate, int flags,FX_BOOL bNeedToRestore, IFSDK_PAUSE_Adapter * pause );
@@ -28,7 +30,9 @@ DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start( FPDF_BITMAP bitmap, FPDF_PAGE
if (pause->version !=1)
return FPDF_RENDER_FAILED;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage)
+ return FPDF_RENDER_FAILED;
// FXMT_CSLOCK_OBJ(&pPage->m_PageLock);
@@ -71,7 +75,9 @@ DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page,IFSDK_PAUSE * paus
if (pause->version !=1)
return FPDF_RENDER_FAILED;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage)
+ return FPDF_RENDER_FAILED;
// FXMT_CSLOCK_OBJ(&pPage->m_PageLock);
@@ -92,7 +98,8 @@ DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page,IFSDK_PAUSE * paus
DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page)
{
if (page == NULL) return;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage) return;
// FXMT_CSLOCK_OBJ(&pPage->m_PageLock);
diff --git a/fpdfsdk/src/fpdf_transformpage.cpp b/fpdfsdk/src/fpdf_transformpage.cpp
index a666666d55..043c02cc27 100644
--- a/fpdfsdk/src/fpdf_transformpage.cpp
+++ b/fpdfsdk/src/fpdf_transformpage.cpp
@@ -6,12 +6,15 @@
#include "../include/fsdk_define.h"
#include "../include/fpdf_transformpage.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../include/fpdfxfa/fpdfxfa_page.h"
DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page, float left, float bottom, float right, float top)
{
if(!page)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage) return;
CPDF_Dictionary* pPageDict = pPage->m_pFormDict;
CPDF_Array* pMediaBoxArray = FX_NEW CPDF_Array;
pMediaBoxArray->Add(FX_NEW CPDF_Number(left));
@@ -27,7 +30,8 @@ DLLEXPORT void STDCALL FPDFPage_SetCropBox(FPDF_PAGE page, float left, float bot
{
if(!page)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage) return;
CPDF_Dictionary* pPageDict = pPage->m_pFormDict;
CPDF_Array* pCropBoxArray = FX_NEW CPDF_Array;
pCropBoxArray->Add(FX_NEW CPDF_Number(left));
@@ -44,7 +48,8 @@ DLLEXPORT FX_BOOL STDCALL FPDFPage_GetMediaBox(FPDF_PAGE page, float* left, floa
{
if(!page)
return FALSE;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage) return FALSE;
CPDF_Dictionary* pPageDict = pPage->m_pFormDict;
CPDF_Array* pArray = pPageDict->GetArray("MediaBox");
if(pArray)
@@ -62,7 +67,8 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetCropBox(FPDF_PAGE page, float* left, flo
{
if(!page)
return FALSE;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage) return FALSE;
CPDF_Dictionary* pPageDict = pPage->m_pFormDict;
CPDF_Array* pArray = pPageDict->GetArray("CropBox");
if(pArray)
@@ -81,6 +87,10 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, FS_MATRIX
if(!page)
return FALSE;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage)
+ return FALSE;
+
CFX_ByteTextBuf textBuf;
textBuf<<"q ";
CFX_FloatRect rect(clipRect->left, clipRect->bottom, clipRect->right, clipRect->top);
@@ -94,7 +104,6 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, FS_MATRIX
textBuf<<bsMatix;
- CPDF_Page* pPage = (CPDF_Page*)page;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj = pPageDic ? pPageDic->GetElement("Contents") : NULL;
if(!pContentObj)
@@ -258,7 +267,8 @@ DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,FPDF_CLIPPATH clip
{
if(!page)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage) return;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj = pPageDic ? pPageDic->GetElement("Contents") : NULL;
if(!pContentObj)
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index e974ffbcf2..643e398cfd 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -6,6 +6,8 @@
#include "../include/fsdk_define.h"
#include "../include/fpdfdoc.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../include/fpdfxfa/fpdfxfa_page.h"
static int this_module = 0;
@@ -33,7 +35,7 @@ DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_W
if (document == NULL) return NULL;
if (title == NULL || title[0] == 0) return NULL;
- CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
CPDF_BookmarkTree tree(pDoc);
FX_STRSIZE len = CFX_WideString::WStringLength(title);
@@ -47,7 +49,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document, FPDF_BO
if (bookmark == NULL) return NULL;
CPDF_Bookmark Bookmark = (CPDF_Dictionary*)bookmark;
- CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
CPDF_Dest dest = Bookmark.GetDest(pDoc);
if (dest != NULL) return dest;
@@ -90,7 +92,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, FPDF_ACTI
{
if (document == NULL) return NULL;
if (action == NULL) return NULL;
- CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
CPDF_Action Action = (CPDF_Dictionary*)action;
return Action.GetDest(pDoc);
@@ -101,7 +103,7 @@ DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, FP
{
if (document == NULL) return 0;
if (action == NULL) return 0;
- CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
CPDF_Action Action = (CPDF_Dictionary*)action;
CFX_ByteString path = Action.GetURI(pDoc);
@@ -115,7 +117,7 @@ DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FP
{
if (document == NULL) return 0;
if (dest == NULL) return 0;
- CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
CPDF_Dest Dest = (CPDF_Array*)dest;
return Dest.GetPageIndex(pDoc);
@@ -129,7 +131,8 @@ static void ReleaseLinkList(FX_LPVOID data)
DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y)
{
if (page == NULL) return NULL;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage) return NULL;
// Link list is stored with the document
CPDF_Document* pDoc = pPage->m_pDocument;
@@ -145,7 +148,7 @@ DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, do
DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, FPDF_LINK link)
{
if (document == NULL) return NULL;
- CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
if (link == NULL) return NULL;
CPDF_Link Link = (CPDF_Dictionary*)link;
@@ -170,7 +173,8 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FP
{
if(!page || !startPos || !linkAnnot)
return FALSE;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage) return FALSE;
if(!pPage->m_pFormDict) return FALSE;
CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots");
if(!pAnnots) return FALSE;
@@ -240,7 +244,7 @@ DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, FPDF_BYTESTR
{
if (doc == NULL || tag == NULL) return 0;
- CPDF_Document* pDoc = (CPDF_Document*)doc;
+ CPDF_Document* pDoc = ((CPDFXFA_Document*)doc)->GetPDFDoc();
// Get info dictionary
CPDF_Dictionary* pInfo = pDoc->GetInfo();
if (pInfo == NULL) return 0;
diff --git a/fpdfsdk/src/fpdfeditimg.cpp b/fpdfsdk/src/fpdfeditimg.cpp
index c29d2b74f8..188b5f070d 100644
--- a/fpdfsdk/src/fpdfeditimg.cpp
+++ b/fpdfsdk/src/fpdfeditimg.cpp
@@ -6,6 +6,8 @@
#include "../include/fsdk_define.h"
#include "../include/fpdfedit.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../include/fpdfxfa/fpdfxfa_page.h"
DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document)
@@ -13,14 +15,14 @@ DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document)
if (!document)
return NULL;
CPDF_ImageObject* pImageObj = FX_NEW CPDF_ImageObject;
- CPDF_Image* pImg = FX_NEW CPDF_Image((CPDF_Document *)document);
+ CPDF_Image* pImg = FX_NEW CPDF_Image(((CPDFXFA_Document *)document)->GetPDFDoc());
pImageObj->m_pImage = pImg;
return pImageObj;
}
DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, int nCount,FPDF_PAGEOBJECT image_object, FPDF_FILEACCESS* fileAccess)
{
- if (!image_object || !fileAccess)
+ if (!image_object || !fileAccess || !pages)
return FALSE;
IFX_FileRead* pFile = FX_NEW CPDF_CustomAccess(fileAccess);
@@ -29,7 +31,9 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, int nCou
pImgObj->m_GeneralState.GetModify();
for (int index=0;index<nCount;index++)
{
- CPDF_Page* pPage = (CPDF_Page*)pages[index];
+ CPDF_Page* pPage = ((CPDFXFA_Page*)pages[index])->GetPDFPage();
+ if (!pPage)
+ continue;
pImgObj->m_pImage->ResetCache(pPage,NULL);
}
pImgObj->m_pImage->SetJpegImage(pFile);
@@ -56,7 +60,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix (FPDF_PAGEOBJECT image_object
DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,int nCount,FPDF_PAGEOBJECT image_object,FPDF_BITMAP bitmap)
{
- if (!image_object || !bitmap)
+ if (!image_object || !bitmap || !pages)
return FALSE;
CFX_DIBitmap* pBmp = NULL;
pBmp = (CFX_DIBitmap*)bitmap;
@@ -64,7 +68,8 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,int nCount,F
pImgObj->m_GeneralState.GetModify();
for (int index=0;index<nCount;index++)
{
- CPDF_Page* pPage = (CPDF_Page*)pages[index];
+ CPDF_Page* pPage = ((CPDFXFA_Page*)pages[index])->GetPDFPage();
+ if (!pPage) continue;
pImgObj->m_pImage->ResetCache(pPage,NULL);
}
pImgObj->m_pImage->SetImage(pBmp,FALSE);
diff --git a/fpdfsdk/src/fpdfeditpage.cpp b/fpdfsdk/src/fpdfeditpage.cpp
index 5c43d4d4b2..68dad9dbfe 100644
--- a/fpdfsdk/src/fpdfeditpage.cpp
+++ b/fpdfsdk/src/fpdfeditpage.cpp
@@ -7,6 +7,10 @@
// #include "x:/pdf/fpdfapi5/include/fpdfapi.h"
#include "../include/fsdk_define.h"
#include "../include/fpdfedit.h"
+#include "../include/fpdfformfill.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../include/fpdfxfa/fpdfxfa_app.h"
+#include "../include/fpdfxfa/fpdfxfa_page.h"
#if _FX_OS_ == _FX_ANDROID_
@@ -51,12 +55,15 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument()
#endif
}
- return pDoc;
+ CPDFXFA_App* pApp = FPDFXFA_GetApp();
+ CPDFXFA_Document* document = FX_NEW CPDFXFA_Document(pDoc, pApp);
+
+ return document;
}
DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index)
{
- CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
if (pDoc == NULL)
return;
if (page_index < 0 || page_index >= pDoc->GetPageCount())
@@ -71,7 +78,7 @@ DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index,
return NULL;
// CPDF_Parser* pParser = (CPDF_Parser*)document;
- CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
if(page_index < 0)
page_index = 0;
if(pDoc->GetPageCount()<page_index)
@@ -92,16 +99,19 @@ DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index,
pPageDict->SetAt("Rotate", FX_NEW CPDF_Number(0));
pPageDict->SetAt("Resources", FX_NEW CPDF_Dictionary);
- CPDF_Page* pPage = FX_NEW CPDF_Page;
- pPage->Load(pDoc,pPageDict);
- pPage->ParseContent();
+// CPDF_Page* pPage = FX_NEW CPDF_Page;
+// pPage->Load(pDoc,pPageDict);
+// pPage->ParseContent();
+
+ CPDFXFA_Page* pPage = FX_NEW CPDFXFA_Page((CPDFXFA_Document*)document, page_index);
+ pPage->LoadPDFPage(pPageDict);
return pPage;
}
DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page)
{
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
|| pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
{
@@ -143,7 +153,7 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page)
DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj)
{
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
|| pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
{
@@ -198,7 +208,7 @@ DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT pag
DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page)
{
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
|| pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
{
@@ -210,7 +220,7 @@ DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page)
DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index)
{
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")
|| pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
{
@@ -223,7 +233,8 @@ DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index)
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page)
{
if(!page) return FALSE;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage) return FALSE;
return pPage->BackgroundAlphaNeeded();
}
@@ -262,7 +273,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObje
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page)
{
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
|| pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
{
@@ -289,7 +300,8 @@ DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
{
if(page == NULL)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage) return;
CPDF_AnnotList AnnotList(pPage);
for (int i=0; i<AnnotList.Count();i++)
{
@@ -317,7 +329,11 @@ DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate)
{
- CPDF_Page* pPage = (CPDF_Page*)page;
+ if (page == NULL)
+ return;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage) return;
+
if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
|| pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
{
diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp
index 2de76033fe..38a71fc6d9 100644
--- a/fpdfsdk/src/fpdfformfill.cpp
+++ b/fpdfsdk/src/fpdfformfill.cpp
@@ -7,7 +7,10 @@
#include "../include/fpdfview.h"
#include "../include/fpdfformfill.h"
#include "../include/fsdk_define.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
#include "../include/fsdk_mgr.h"
+#include "../include/fpdfxfa/fpdfxfa_page.h"
+#include "../include/fpdfxfa/fpdfxfa_app.h"
#include "../include/javascript/IJavaScript.h"
@@ -17,60 +20,109 @@ DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, FPDF_
{
if(!page || !hHandle)
return -1;
- CPDF_Page * pPage = (CPDF_Page*) page;
-
- CPDF_InterForm * pInterForm = NULL;
- pInterForm = new CPDF_InterForm(pPage->m_pDocument,FALSE);
- if (!pInterForm)
- return -1;
- CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y);
- if(!pFormCtrl)
+ CPDF_Page * pPage = ((CPDFXFA_Page*) page)->GetPDFPage();
+ if (pPage)
{
+ CPDF_InterForm * pInterForm = NULL;
+ pInterForm = new CPDF_InterForm(pPage->m_pDocument,FALSE);
+ if (!pInterForm)
+ return -1;
+ CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y);
+ if(!pFormCtrl)
+ {
+ delete pInterForm;
+ return -1;
+ }
+ CPDF_FormField* pFormField = pFormCtrl->GetField();
+ if(!pFormField)
+ {
+ delete pInterForm;
+ return -1;
+ }
+
+ int nType = pFormField->GetFieldType();
delete pInterForm;
- return -1;
+ return nType;
}
- CPDF_FormField* pFormField = pFormCtrl->GetField();
- if(!pFormField)
+
+ IXFA_PageView* pPageView = ((CPDFXFA_Page*)page)->GetXFAPageView();
+ if (pPageView)
{
- delete pInterForm;
- return -1;
+ IXFA_WidgetHandler* pWidgetHandler = NULL;
+ IXFA_DocView* pDocView = pPageView->GetDocView();
+ if (!pDocView)
+ return -1;
+
+ pWidgetHandler = pDocView->GetWidgetHandler();
+ if (!pWidgetHandler)
+ return -1;
+
+ XFA_HWIDGET pXFAAnnot = NULL;
+ IXFA_WidgetIterator* pWidgetIterator = pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Viewable|XFA_WIDGETFILTER_AllType);
+ if (!pWidgetIterator)
+ return -1;
+ pXFAAnnot = pWidgetIterator->MoveToNext();
+ while (pXFAAnnot) {
+ CFX_RectF rcBBox;
+ pWidgetHandler->GetBBox (pXFAAnnot, rcBBox, 0);
+ CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, rcBBox.top+rcBBox.height);
+ rcWidget.left -= 1.0f;
+ rcWidget.right += 1.0f;
+ rcWidget.bottom -= 1.0f;
+ rcWidget.top += 1.0f;
+
+ if (rcWidget.Contains(page_x, page_y)) {
+ pWidgetIterator->Release();
+ return FPDF_FORMFIELD_XFA;
+ }
+ pXFAAnnot = pWidgetIterator->MoveToNext();
+ }
+
+ pWidgetIterator->Release();
}
- int nType = pFormField->GetFieldType();
- delete pInterForm;
- return nType;
+ return -1;
}
DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnviroument(FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo)
{
if(!document || !formInfo || formInfo->version!=1)
return NULL;
- CPDF_Document * pDocument = (CPDF_Document*) document;
+ CPDFXFA_Document * pDocument = (CPDFXFA_Document*) document;
CPDFDoc_Environment * pEnv = NULL;
pEnv = new CPDFDoc_Environment(pDocument);
if (!pEnv)
return NULL;
pEnv->RegAppHandle(formInfo);
- if(pEnv->GetPDFDocument())
+ CPDFXFA_App* pApp = FPDFXFA_GetApp();
+ pApp->AddFormFillEnv(pEnv);
+
+ if(pEnv->GetPDFXFADocument())
{
- CPDFSDK_Document* pSDKDoc = new CPDFSDK_Document(pEnv->GetPDFDocument(), pEnv);
- if(pSDKDoc)
+ //CPDFSDK_Document* pSDKDoc = new CPDFSDK_Document(pEnv->GetPDFXFADocument(), pEnv);
+ CPDFSDK_Document* pSDKDoc = pDocument->GetSDKDocument(pEnv);
+ if(pSDKDoc) {
pEnv->SetCurrentDoc(pSDKDoc);
+ }
}
return pEnv;
}
DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnviroument(FPDF_FORMHANDLE hHandle)
{
- if(!hHandle)
+ if (!hHandle)
return;
- CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- if(pSDKDoc)
- {
- ((CPDFDoc_Environment*)hHandle)->SetCurrentDoc(NULL);
- delete pSDKDoc;
- }
+ //CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
+ //if(pSDKDoc)
+ //{
+ //((CPDFDoc_Environment*)hHandle)->SetCurrentDoc(NULL);
+ //CPDFXFA_Document* pDoc = ((CPDFDoc_Environment*)hHandle)->GetPDFXFADocument();
+ //if (pDoc)
+ // pDoc->ReleaseSDKDoc();
+ //}
+ CPDFXFA_App* pApp = FPDFXFA_GetApp();
+ pApp->RemoveFormFillEnv((CPDFDoc_Environment*)hHandle);
delete (CPDFDoc_Environment*)hHandle;
hHandle = NULL;
}
@@ -85,7 +137,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE
CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
if(!pFXDoc)
return FALSE;
- CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
+ CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page);
if(!pPageView)
return FALSE;
@@ -103,7 +155,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG
CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
if(!pFXDoc)
return FALSE;
- CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
+ CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page);
if(!pPageView)
return FALSE;
// double page_x = 0;
@@ -120,7 +172,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE
CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
if(!pFXDoc)
return FALSE;
- CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
+ CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page);
if(!pPageView)
return FALSE;
// double page_x = 0;
@@ -130,6 +182,38 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE
return pPageView->OnLButtonUp(pt, modifier);
}
+DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)
+{
+ if (!hHandle || !page)
+ return FALSE;
+
+ CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
+ if(!pFXDoc)
+ return FALSE;
+ CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page);
+ if(!pPageView)
+ return FALSE;
+
+ CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
+ return pPageView->OnRButtonDown(pt, modifier);
+}
+
+DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)
+{
+ if (!hHandle || !page)
+ return FALSE;
+
+ CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
+ if(!pFXDoc)
+ return FALSE;
+ CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page);
+ if(!pPageView)
+ return FALSE;
+
+ CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
+ return pPageView->OnRButtonUp(pt, modifier);
+}
+
DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nKeyCode, int modifier)
{
if (!hHandle || !page)
@@ -137,7 +221,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE pa
CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
if(!pFXDoc)
return FALSE;
- CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
+ CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page);
if(!pPageView)
return FALSE;
@@ -152,7 +236,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page
CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
if(!pFXDoc)
return FALSE;
- CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
+ CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page);
if(!pPageView)
return FALSE;
@@ -168,7 +252,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, FPDF_PAGE page,
CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
if(!pFXDoc)
return FALSE;
- CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page);
+ CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page);
if(!pPageView)
return FALSE;
return pPageView->OnChar(nChar, modifier);
@@ -191,27 +275,19 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap,
{
if (!hHandle || !page)
return ;
- CPDF_Page* pPage = (CPDF_Page*)page;
- CPDF_RenderOptions options;
- if (flags & FPDF_LCD_TEXT)
- options.m_Flags |= RENDER_CLEARTYPE;
- else
- options.m_Flags &= ~RENDER_CLEARTYPE;
-
- //Grayscale output
- if (flags & FPDF_GRAYSCALE)
- {
- options.m_ColorMode = RENDER_COLOR_GRAY;
- options.m_ForeColor = 0;
- options.m_BackColor = 0xffffff;
- }
-
- options.m_AddFlags = flags >> 8;
-
- options.m_pOCContext = FX_NEW CPDF_OCContext(pPage->m_pDocument);
+ CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
+ CPDFXFA_Document* pDocument = pPage->GetDocument();
+ if (!pDocument)
+ return;
+ CPDF_Document* pPDFDoc = pDocument->GetPDFDoc();
+ if (!pPDFDoc)
+ return;
- //FXMT_CSLOCK_OBJ(&pPage->m_PageLock);
+ CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
+ CPDFSDK_Document* pFXDoc = pEnv->GetCurrentDoc();
+ if (!pFXDoc)
+ return;
CFX_AffineMatrix matrix;
pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
@@ -235,31 +311,26 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap,
pDevice->SaveState();
pDevice->SetClip_Rect(&clip);
+ CPDF_RenderOptions options;
+ if (flags & FPDF_LCD_TEXT)
+ options.m_Flags |= RENDER_CLEARTYPE;
+ else
+ options.m_Flags &= ~RENDER_CLEARTYPE;
- CPDF_RenderContext* pContext = NULL;
- pContext = FX_NEW CPDF_RenderContext;
- if (!pContext)
+ //Grayscale output
+ if (flags & FPDF_GRAYSCALE)
{
- delete pDevice;
- pDevice = NULL;
- return;
+ options.m_ColorMode = RENDER_COLOR_GRAY;
+ options.m_ForeColor = 0;
+ options.m_BackColor = 0xffffff;
}
+ options.m_AddFlags = flags >> 8;
+ options.m_pOCContext = FX_NEW CPDF_OCContext(pPDFDoc);
-// CPDF_Document* pDoc = pPage->m_pDocument;
- CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
- CPDFSDK_Document* pFXDoc = pEnv->GetCurrentDoc();
- if(!pFXDoc)
+ if(CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page))
{
- delete pContext;
- delete pDevice;
- pContext = NULL;
- pDevice = NULL;
- return;
- }
- if(CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage))
- {
- pPageView->PageView_OnDraw(pDevice, &matrix, &options);
+ pPageView->PageView_OnDraw(pDevice, &matrix, &options, &clip);
}
pDevice->RestoreState();
@@ -268,11 +339,6 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap,
delete options.m_pOCContext;
options.m_pOCContext = NULL;
}
- if(pContext)
- {
- delete pContext;
- pContext = NULL;
- }
if(pDevice)
{
delete pDevice;
@@ -280,6 +346,235 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap,
}
}
+DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, FPDF_WIDGET hWidget)
+{
+ if (NULL == hWidget || NULL == document)
+ return;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+
+ if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
+ return;
+
+ IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
+
+ if (pXFAMenuHander == NULL)
+ return;
+
+ pXFAMenuHander->Undo((XFA_HWIDGET)hWidget);
+
+}
+DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, FPDF_WIDGET hWidget)
+{
+ if (NULL == hWidget || NULL == document)
+ return;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+ if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
+ return;
+
+ IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
+
+ if (pXFAMenuHander == NULL)
+ return;
+
+ pXFAMenuHander->Redo((XFA_HWIDGET)hWidget);
+}
+
+DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, FPDF_WIDGET hWidget)
+{
+ if (NULL == hWidget || NULL == document)
+ return;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+ if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
+ return;
+
+ IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
+
+ if (pXFAMenuHander == NULL)
+ return;
+
+ pXFAMenuHander->SelectAll((XFA_HWIDGET)hWidget);
+}
+DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, FPDF_WIDESTRING wsText, FPDF_DWORD* size)
+{
+ if (NULL == hWidget || NULL == document)
+ return;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+ if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
+ return;
+
+ IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
+
+ if (pXFAMenuHander == NULL)
+ return;
+
+ CFX_WideString wsCpText;
+ pXFAMenuHander->Copy((XFA_HWIDGET)hWidget, wsCpText);
+
+ CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode();
+
+ int len = bsCpText.GetLength()/sizeof(unsigned short);
+
+ if (wsText == NULL) {
+ *size = len;
+ return;
+ }
+
+ int real_size = len < *size ? len : *size;
+ if (real_size > 0)
+ {
+ FXSYS_memcpy((void*)wsText,bsCpText.GetBuffer(real_size*sizeof(unsigned short)),real_size*sizeof(unsigned short));
+ bsCpText.ReleaseBuffer(real_size*sizeof(unsigned short));
+ }
+ *size = real_size;
+}
+DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, FPDF_WIDESTRING wsText, FPDF_DWORD* size)
+{
+ if (NULL == hWidget || NULL == document)
+ return;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+ if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
+ return;
+
+ IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
+
+ if (pXFAMenuHander == NULL)
+ return;
+
+ CFX_WideString wsCpText;
+ pXFAMenuHander->Cut((XFA_HWIDGET)hWidget, wsCpText);
+
+ CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode();
+
+ int len = bsCpText.GetLength()/sizeof(unsigned short);
+
+ if (wsText == NULL) {
+ *size = len;
+ return;
+ }
+
+ int real_size = len < *size ? len : *size;
+ if (real_size > 0)
+ {
+ FXSYS_memcpy((void*)wsText,bsCpText.GetBuffer(real_size*sizeof(unsigned short)),real_size*sizeof(unsigned short));
+ bsCpText.ReleaseBuffer(real_size*sizeof(unsigned short));
+ }
+ *size = real_size;
+}
+DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, FPDF_WIDESTRING wsText, FPDF_DWORD size)
+{
+ if (NULL == hWidget || NULL == document)
+ return;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+ if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
+ return;
+
+ IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
+
+ if (pXFAMenuHander == NULL)
+ return;
+
+ CFX_WideString wstr = CFX_WideString::FromUTF16LE(wsText, size);
+
+ pXFAMenuHander->Paste((XFA_HWIDGET)hWidget, wstr);
+
+}
+DLLEXPORT void STDCALL FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, float x, float y, FPDF_BYTESTRING bsText)
+{
+ if (NULL == hWidget || NULL == document)
+ return;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+ if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
+ return;
+
+ IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
+
+ if (pXFAMenuHander == NULL)
+ return;
+
+ CFX_PointF ptPopup;
+ ptPopup.x = x;
+ ptPopup.y = y;
+ CFX_ByteStringC bs(bsText);
+ pXFAMenuHander->ReplaceSpellCheckWord((XFA_HWIDGET)hWidget,ptPopup,bs);
+
+}
+DLLEXPORT void STDCALL FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, float x, float y, FPDF_STRINGHANDLE* stringHandle)
+{
+ if (NULL == hWidget || NULL == document)
+ return;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+ if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
+ return;
+
+ IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
+
+ if (pXFAMenuHander == NULL)
+ return;
+
+ CFX_ByteStringArray* sSuggestWords = FX_NEW CFX_ByteStringArray;
+ CFX_PointF ptPopup;
+ ptPopup.x = x;
+ ptPopup.y = y;
+ pXFAMenuHander->GetSuggestWords((XFA_HWIDGET)hWidget, ptPopup, *sSuggestWords);
+ *stringHandle = (FPDF_STRINGHANDLE)sSuggestWords;
+}
+DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE stringHandle)
+{
+ if (stringHandle == NULL)
+ return -1;
+ CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle;
+ return sSuggestWords->GetSize();
+}
+DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE stringHandle, int index, FPDF_BYTESTRING bsText, FPDF_DWORD* size)
+{
+ if (stringHandle == NULL || size == NULL)
+ return FALSE;
+ int count = FPDF_StringHandleCounts(stringHandle);
+ if (index < 0|| index >= count)
+ return FALSE;
+
+ CFX_ByteStringArray sSuggestWords = *(CFX_ByteStringArray*)stringHandle;
+ int len = sSuggestWords[index].GetLength();
+
+ if (bsText == NULL) {
+ *size = len;
+ return TRUE;
+ }
+
+ int real_size = len < *size ? len : *size;
+ if (real_size > 0)
+ FXSYS_memcpy((void*)bsText, (FX_LPCSTR)(sSuggestWords[index]), real_size);
+ *size = real_size;
+
+ return TRUE;
+}
+DLLEXPORT void STDCALL FPDF_StringHandleRelease(FPDF_STRINGHANDLE stringHandle)
+{
+ if (stringHandle == NULL)
+ return;
+ CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle;
+ delete sSuggestWords;
+}
+
+DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringHandle, FPDF_BYTESTRING bsText, FPDF_DWORD size)
+{
+ if (stringHandle == NULL || bsText == NULL || size <= 0)
+ return FALSE;
+
+ CFX_ByteStringArray* stringArr = (CFX_ByteStringArray*)stringHandle;
+ CFX_ByteString bsStr(bsText, size);
+
+ stringArr->Add(bsStr);
+ return TRUE;
+}
DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, int fieldType, unsigned long color)
{
@@ -329,7 +624,7 @@ DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHan
CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
if(!pSDKDoc)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, TRUE);
if(pPageView)
{
@@ -342,7 +637,7 @@ DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hH
if(!hHandle || !page)
return;
CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
if(pPageView)
{
@@ -380,7 +675,7 @@ DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, int aaTyp
CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
if(pSDKDoc)
{
- CPDF_Document* pDoc = pSDKDoc->GetDocument();
+ CPDF_Document* pDoc = pSDKDoc->GetDocument()->GetPDFDoc();
CPDF_Dictionary* pDic = pDoc->GetRoot();
if (!pDic)
return;
@@ -400,7 +695,7 @@ DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandl
if(!hHandle || !page)
return;
CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
if(pPageView)
{
@@ -410,7 +705,9 @@ DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandl
CPDFSDK_ActionHandler *pActionHandler = pEnv->GetActionHander();
ASSERT(pActionHandler != NULL);
- CPDF_Dictionary *pPageDict = pPage->m_pFormDict;
+ if (!pPage->GetPDFPage())
+ return;
+ CPDF_Dictionary *pPageDict = pPage->GetPDFPage()->m_pFormDict;
ASSERT(pPageDict != NULL);
CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA"));
diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp
index a5c4275648..ed0c8565c0 100644
--- a/fpdfsdk/src/fpdfppo.cpp
+++ b/fpdfsdk/src/fpdfppo.cpp
@@ -6,6 +6,7 @@
#include "../include/fpdfppo.h"
#include "../include/fsdk_define.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
class CPDF_PageOrganizer
{
@@ -428,8 +429,9 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc,FPDF_DOCUMEN
if(dest_doc == NULL || src_doc == NULL )
return FALSE;
CFX_WordArray pageArray;
- CPDF_Document* pSrcDoc = (CPDF_Document*)src_doc;
- int nCount = pSrcDoc->GetPageCount();
+ CPDFXFA_Document* pSrcDoc = (CPDFXFA_Document*)src_doc;
+ CPDF_Document* pSrcPDFDoc = pSrcDoc->GetPDFDoc();
+ int nCount = pSrcPDFDoc->GetPageCount();
if(pagerange)
{
if(ParserPageRangeString(pagerange,&pageArray,nCount) == FALSE)
@@ -443,12 +445,13 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc,FPDF_DOCUMEN
}
}
- CPDF_Document* pDestDoc = (CPDF_Document*)dest_doc;
+ CPDFXFA_Document* pDestDoc = (CPDFXFA_Document*)dest_doc;
+ CPDF_Document* pDestPDFDoc = pDestDoc->GetPDFDoc();
CPDF_PageOrganizer pageOrg;
- pageOrg.PDFDocInit(pDestDoc,pSrcDoc);
+ pageOrg.PDFDocInit(pDestPDFDoc,pSrcPDFDoc);
- if(pageOrg.ExportPage(pSrcDoc,&pageArray,pDestDoc,index))
+ if(pageOrg.ExportPage(pSrcPDFDoc,&pageArray,pDestPDFDoc,index))
return TRUE;
return FALSE;
}
@@ -457,13 +460,15 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, F
{
if(src_doc == NULL || dest_doc == NULL)
return false;
- CPDF_Document* pSrcDoc = (CPDF_Document*)src_doc;
- CPDF_Dictionary* pSrcDict = pSrcDoc->GetRoot();
- pSrcDict = pSrcDict->GetDict(FX_BSTRC("ViewerPreferences"));;
+ CPDFXFA_Document* pSrcDoc = (CPDFXFA_Document*)src_doc;
+ CPDF_Document* pSrcPDFDoc = pSrcDoc->GetPDFDoc();
+ CPDF_Dictionary* pSrcDict = pSrcPDFDoc->GetRoot();
+ pSrcDict = pSrcDict->GetDict(FX_BSTRC("ViewerPreferences"));
if(!pSrcDict)
return FALSE;
- CPDF_Document* pDstDoc = (CPDF_Document*)dest_doc;
- CPDF_Dictionary* pDstDict = pDstDoc->GetRoot();
+ CPDFXFA_Document* pDstDoc = (CPDFXFA_Document*)dest_doc;
+ CPDF_Document* pDstPDFDoc = pDstDoc->GetPDFDoc();
+ CPDF_Dictionary* pDstDict = pDstPDFDoc->GetRoot();
if(!pDstDict)
return FALSE;
pDstDict->SetAt(FX_BSTRC("ViewerPreferences"), pSrcDict->Clone(TRUE));
diff --git a/fpdfsdk/src/fpdfsave.cpp b/fpdfsdk/src/fpdfsave.cpp
index 45dfbf7214..229e580dec 100644
--- a/fpdfsdk/src/fpdfsave.cpp
+++ b/fpdfsdk/src/fpdfsave.cpp
@@ -7,6 +7,9 @@
#include "../include/fsdk_define.h"
#include "../include/fpdfsave.h"
#include "../include/fpdfedit.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../include/fpdfxfa/fpdfxfa_app.h"
+#include "../include/fpdfxfa/fpdfxfa_util.h"
#if _FX_OS_ == _FX_ANDROID_
#include "time.h"
#else
@@ -53,11 +56,258 @@ FX_BOOL CFX_IFileWrite::WriteBlock(const void* pData, size_t size)
return FALSE;
}
-FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document,FPDF_FILEWRITE * pFileWrite,FPDF_DWORD flags, FPDF_BOOL bSetVersion,
+#define XFA_DATASETS 0
+#define XFA_FORMS 1
+
+FX_BOOL _SaveXFADocumentData(CPDFXFA_Document* pDocument, CFX_PtrArray& fileList)
+{
+ if (!pDocument)
+ return FALSE;
+ if (pDocument->GetDocType() != DOCTYPE_DYNIMIC_XFA && pDocument->GetDocType() != DOCTYPE_STATIC_XFA)
+ return TRUE;
+ if (!FPDFXFA_GetApp()->GetXFAApp())
+ return TRUE;
+
+ IXFA_DocView* pXFADocView = pDocument->GetXFADocView();
+ if (NULL == pXFADocView)
+ return TRUE;
+ IXFA_DocHandler *pXFADocHandler = FPDFXFA_GetApp()->GetXFAApp()->GetDocHandler();
+
+ CPDF_Document * pPDFDocument = pDocument->GetPDFDoc();
+ if (pDocument == NULL)
+ return FALSE;
+ CPDF_Dictionary* pRoot = pPDFDocument->GetRoot();
+ if (pRoot == NULL)
+ return FALSE;
+ CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm");
+ if (NULL == pAcroForm)
+ return FALSE;
+ CPDF_Object* pXFA = pAcroForm->GetElement("XFA");
+ if (pXFA == NULL)
+ return TRUE;
+ if(pXFA->GetType() != PDFOBJ_ARRAY)
+ return FALSE;
+ CPDF_Array* pArray = pXFA->GetArray();
+ if (NULL == pArray)
+ return FALSE;
+ int size = pArray->GetCount();
+ int iFormIndex = -1;
+ int iDataSetsIndex = -1;
+ int iTemplate = -1;
+ int iLast = size - 2;
+ for (int i = 0; i < size - 1; i++)
+ {
+ CPDF_Object* pPDFObj = pArray->GetElement(i);
+ if (pPDFObj->GetType() != PDFOBJ_STRING)
+ continue;
+ if (pPDFObj->GetString() == "form")
+ iFormIndex = i+1;
+ else if (pPDFObj->GetString() == "datasets")
+ iDataSetsIndex = i+1;
+ else if (pPDFObj->GetString() == FX_BSTRC("template"))
+ iTemplate = i + 1;
+ }
+ IXFA_ChecksumContext* pContext = NULL;
+#define XFA_USECKSUM
+#ifdef XFA_USECKSUM
+ //Checksum
+ pContext = XFA_Checksum_Create();
+ FXSYS_assert(pContext);
+ pContext->StartChecksum();
+
+ //template
+ if (iTemplate > -1)
+ {
+ CPDF_Stream *pTemplateStream = pArray->GetStream(iTemplate);
+ CPDF_StreamAcc streamAcc;
+ streamAcc.LoadAllData(pTemplateStream);
+ FX_LPBYTE pData = (FX_LPBYTE)streamAcc.GetData();
+ FX_DWORD dwSize2 = streamAcc.GetSize();
+ IFX_FileStream *pTemplate = FX_CreateMemoryStream(pData, dwSize2);
+ pContext->UpdateChecksum((IFX_FileRead*)pTemplate);
+ pTemplate->Release();
+ }
+#endif
+ CPDF_Stream* pFormStream = NULL;
+ CPDF_Stream* pDataSetsStream = NULL;
+ if (iFormIndex != -1)
+ {
+ //Get form CPDF_Stream
+ CPDF_Object* pFormPDFObj = pArray->GetElement(iFormIndex);
+ if (pFormPDFObj->GetType() == PDFOBJ_REFERENCE)
+ {
+ CPDF_Reference* pFormRefObj = (CPDF_Reference*)pFormPDFObj;
+ CPDF_Object* pFormDircetObj = pFormPDFObj->GetDirect();
+ if (NULL != pFormDircetObj && pFormDircetObj->GetType() == PDFOBJ_STREAM)
+ {
+ pFormStream = (CPDF_Stream*)pFormDircetObj;
+ }
+ }
+ else if (pFormPDFObj->GetType() == PDFOBJ_STREAM)
+ {
+ pFormStream = (CPDF_Stream*)pFormPDFObj;
+ }
+ }
+
+ if (iDataSetsIndex != -1)
+ {
+ //Get datasets CPDF_Stream
+ CPDF_Object* pDataSetsPDFObj = pArray->GetElement(iDataSetsIndex);
+ if (pDataSetsPDFObj->GetType() == PDFOBJ_REFERENCE)
+ {
+ CPDF_Reference* pDataSetsRefObj = (CPDF_Reference*)pDataSetsPDFObj;
+ CPDF_Object* pDataSetsDircetObj = pDataSetsRefObj->GetDirect();
+ if (NULL != pDataSetsDircetObj && pDataSetsDircetObj->GetType() == PDFOBJ_STREAM)
+ {
+ pDataSetsStream = (CPDF_Stream*)pDataSetsDircetObj;
+ }
+ }
+ else if (pDataSetsPDFObj->GetType() == PDFOBJ_STREAM)
+ {
+ pDataSetsStream = (CPDF_Stream*)pDataSetsPDFObj;
+ }
+ }
+ //end
+ //L"datasets"
+ {
+ IFX_FileStream* pDsfileWrite = FX_CreateMemoryStream();
+ if ( NULL == pDsfileWrite )
+ {
+ pContext->Release();
+ pDsfileWrite->Release();
+ return FALSE;
+ }
+ if (pXFADocHandler->SavePackage(pXFADocView->GetDoc(), CFX_WideStringC(L"datasets"), pDsfileWrite) && pDsfileWrite->GetSize()>0)
+ {
+#ifdef XFA_USECKSUM
+ //Datasets
+ pContext->UpdateChecksum((IFX_FileRead*)pDsfileWrite);
+ pContext->FinishChecksum();
+#endif
+ CPDF_Dictionary* pDataDict = FX_NEW CPDF_Dictionary;
+ if (iDataSetsIndex != -1)
+ {
+ if (pDataSetsStream)
+ pDataSetsStream->InitStream(pDsfileWrite, pDataDict);
+ }
+ else
+ {
+ CPDF_Stream* pData = FX_NEW CPDF_Stream(NULL, 0, NULL);
+ pData->InitStream(pDsfileWrite, pDataDict);
+ FX_DWORD AppStreamobjnum = pPDFDocument->AddIndirectObject(pData);
+ CPDF_Reference* pRef = (CPDF_Reference*)pPDFDocument->GetIndirectObject(AppStreamobjnum);
+ {
+ iLast = pArray->GetCount() -2;
+ pArray->InsertAt(iLast,CPDF_String::Create("datasets"));
+ pArray->InsertAt(iLast+1, pData, pPDFDocument);
+ }
+ }
+ fileList.Add(pDsfileWrite);
+ }
+ }
+
+
+ //L"form"
+ {
+
+ IFX_FileStream* pfileWrite = FX_CreateMemoryStream();
+ if (NULL == pfileWrite)
+ {
+ pContext->Release();
+ return FALSE;
+ }
+ if(pXFADocHandler->SavePackage(pXFADocView->GetDoc(), CFX_WideStringC(L"form"), pfileWrite, pContext) && pfileWrite > 0)
+ {
+ CPDF_Dictionary* pDataDict = FX_NEW CPDF_Dictionary;
+ if (iFormIndex != -1)
+ {
+ if (pFormStream)
+ pFormStream->InitStream(pfileWrite, pDataDict);
+ }
+ else
+ {
+ CPDF_Stream* pData = FX_NEW CPDF_Stream(NULL, 0, NULL);
+ pData->InitStream(pfileWrite, pDataDict);
+ FX_DWORD AppStreamobjnum = pPDFDocument->AddIndirectObject(pData);
+ CPDF_Reference* pRef = (CPDF_Reference*)pPDFDocument->GetIndirectObject(AppStreamobjnum);
+ {
+ iLast = pArray->GetCount() -2;
+ pArray->InsertAt(iLast, CPDF_String::Create("form"));
+ pArray->InsertAt(iLast+1, pData, pPDFDocument);
+ }
+ }
+ fileList.Add(pfileWrite);
+ }
+ }
+ pContext->Release();
+ return TRUE;
+}
+
+
+FX_BOOL _SendPostSaveToXFADoc(CPDFXFA_Document* pDocument)
+{
+ if (!pDocument)
+ return FALSE;
+
+ if (pDocument->GetDocType() != DOCTYPE_DYNIMIC_XFA && pDocument->GetDocType() != DOCTYPE_STATIC_XFA)
+ return TRUE;
+
+ IXFA_DocView* pXFADocView = pDocument->GetXFADocView();
+ if (NULL == pXFADocView)
+ return FALSE;
+ IXFA_WidgetHandler* pWidgetHander = pXFADocView->GetWidgetHandler();
+
+ CXFA_WidgetAcc* pWidgetAcc = NULL;
+ IXFA_WidgetAccIterator* pWidgetAccIterator = pXFADocView->CreateWidgetAccIterator();
+ pWidgetAcc = pWidgetAccIterator->MoveToNext();
+ while(pWidgetAcc)
+ {
+ CXFA_EventParam preParam;
+ preParam.m_eType = XFA_EVENT_PostSave;
+ pWidgetHander->ProcessEvent(pWidgetAcc,&preParam);
+ pWidgetAcc = pWidgetAccIterator->MoveToNext();
+ }
+ pWidgetAccIterator->Release();
+ pXFADocView->UpdateDocView();
+ pDocument->_ClearChangeMark();
+ return TRUE;
+}
+
+
+FX_BOOL _SendPreSaveToXFADoc(CPDFXFA_Document* pDocument, CFX_PtrArray& fileList)
+{
+ if (pDocument->GetDocType() != DOCTYPE_DYNIMIC_XFA && pDocument->GetDocType() != DOCTYPE_STATIC_XFA)
+ return TRUE;
+ IXFA_DocView* pXFADocView = pDocument->GetXFADocView();
+ if (NULL == pXFADocView)
+ return TRUE;
+ IXFA_WidgetHandler* pWidgetHander = pXFADocView->GetWidgetHandler();
+ CXFA_WidgetAcc* pWidgetAcc = NULL;
+ IXFA_WidgetAccIterator* pWidgetAccIterator = pXFADocView->CreateWidgetAccIterator();
+ pWidgetAcc = pWidgetAccIterator->MoveToNext();
+ while(pWidgetAcc)
+ {
+ CXFA_EventParam preParam;
+ preParam.m_eType = XFA_EVENT_PreSave;
+ pWidgetHander->ProcessEvent(pWidgetAcc, &preParam);
+ pWidgetAcc = pWidgetAccIterator->MoveToNext();
+ }
+ pWidgetAccIterator->Release();
+ pXFADocView->UpdateDocView();
+ return _SaveXFADocumentData(pDocument, fileList);
+}
+
+FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document, FPDF_FILEWRITE * pFileWrite,FPDF_DWORD flags, FPDF_BOOL bSetVersion,
int fileVerion)
{
- CPDF_Document* pDoc = (CPDF_Document*)document;
- if (!pDoc)
+ CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document;
+
+ CFX_PtrArray fileList;
+
+ _SendPreSaveToXFADoc(pDoc, fileList);
+
+ CPDF_Document* pPDFDoc = pDoc->GetPDFDoc();
+ if (!pPDFDoc)
return 0;
if ( flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY )
@@ -65,10 +315,10 @@ FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document,FPDF_FILEWRITE * pFileWrite,FPDF
flags = 0;
}
- CPDF_Creator FileMaker(pDoc);
- if(bSetVersion)
+ CPDF_Creator FileMaker(pPDFDoc);
+ if (bSetVersion)
FileMaker.SetFileVersion(fileVerion);
- if(flags == FPDF_REMOVE_SECURITY)
+ if (flags == FPDF_REMOVE_SECURITY)
{
flags = 0;
FileMaker.RemoveSecurity();
@@ -78,6 +328,17 @@ FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document,FPDF_FILEWRITE * pFileWrite,FPDF
pStreamWrite = new CFX_IFileWrite;
pStreamWrite->Init( pFileWrite );
bRet = FileMaker.Create(pStreamWrite, flags);
+
+ _SendPostSaveToXFADoc(pDoc);
+ //pDoc->_ClearChangeMark();
+
+ for (int i = 0; i < fileList.GetSize(); i++)
+ {
+ IFX_FileStream* pFile = (IFX_FileStream*)fileList.GetAt(i);
+ pFile->Release();
+ }
+ fileList.RemoveAll();
+
delete pStreamWrite;
return bRet;
}
@@ -88,9 +349,9 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy( FPDF_DOCUMENT document,FPDF_FILEWRI
return _FPDF_Doc_Save(document, pFileWrite, flags, FALSE , 0);
}
-
DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion( FPDF_DOCUMENT document,FPDF_FILEWRITE * pFileWrite,
FPDF_DWORD flags, int fileVersion)
{
return _FPDF_Doc_Save(document, pFileWrite, flags, TRUE , fileVersion);
}
+
diff --git a/fpdfsdk/src/fpdftext.cpp b/fpdfsdk/src/fpdftext.cpp
index 264631b630..002637483d 100644
--- a/fpdfsdk/src/fpdftext.cpp
+++ b/fpdfsdk/src/fpdftext.cpp
@@ -6,6 +6,8 @@
#include "../include/fsdk_define.h"
#include "../include/fpdftext.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../include/fpdfxfa/fpdfxfa_page.h"
#ifdef _WIN32
#include <tchar.h>
@@ -18,9 +20,13 @@ DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page)
{
if (!page) return NULL;
IPDF_TextPage* textpage=NULL;
- CPDF_ViewerPreferences viewRef(((CPDF_Page*)page)->m_pDocument);
- textpage=IPDF_TextPage::CreateTextPage((CPDF_Page*)page,viewRef.IsDirectionR2L());
+ CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
+ if (!pPage->GetPDFPage()) return NULL;
+ CPDFXFA_Document* pDoc = pPage->GetDocument();
+ CPDF_ViewerPreferences viewRef(pDoc->GetPDFDoc());
+ textpage=IPDF_TextPage::CreateTextPage((CPDF_Page*)pPage->GetPDFPage(),viewRef.IsDirectionR2L());
textpage->ParseTextPage();
+
return textpage;
}
DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page)
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index bd49862e1c..ae8f3ccd91 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -11,11 +11,116 @@
#include "../include/fpdf_progressive.h"
#include "../include/fpdf_ext.h"
#include "../../third_party/numerics/safe_conversions_impl.h"
+#include "../include/fpdfformfill.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../include/fpdfxfa/fpdfxfa_app.h"
+#include "../include/fpdfxfa/fpdfxfa_page.h"
+#include "../include/fpdfxfa/fpdfxfa_util.h"
+
+CFPDF_FileStream::CFPDF_FileStream(FPDF_FILEHANDLER* pFS)
+{
+ m_pFS = pFS;
+ m_nCurPos = 0;
+}
+
+IFX_FileStream* CFPDF_FileStream::Retain()
+{
+ return this;
+}
+
+void CFPDF_FileStream::Release()
+{
+ if (m_pFS && m_pFS->Release)
+ m_pFS->Release(m_pFS->clientData);
+ delete this;
+}
+
+FX_FILESIZE CFPDF_FileStream::GetSize()
+{
+ if (m_pFS && m_pFS->GetSize)
+ return (FX_FILESIZE)m_pFS->GetSize(m_pFS->clientData);
+ return 0;
+}
+
+FX_BOOL CFPDF_FileStream::IsEOF()
+{
+ return m_nCurPos >= GetSize();
+}
+
+FX_BOOL CFPDF_FileStream::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size)
+{
+ if (!buffer || !size || !m_pFS->ReadBlock) return FALSE;
+
+ if (m_pFS->ReadBlock(m_pFS->clientData, (FPDF_DWORD)offset, buffer, (FPDF_DWORD)size) == 0)
+ {
+ m_nCurPos = offset + size;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+size_t CFPDF_FileStream::ReadBlock(void* buffer, size_t size)
+{
+ if (!buffer || !size || !m_pFS->ReadBlock) return 0;
+
+ FX_FILESIZE nSize = GetSize();
+ if (m_nCurPos >= nSize) return 0;
+ FX_FILESIZE dwAvail = nSize - m_nCurPos;
+ if (dwAvail < (FX_FILESIZE)size) size = (size_t)dwAvail;
+ if (m_pFS->ReadBlock(m_pFS->clientData, (FPDF_DWORD)m_nCurPos, buffer, (FPDF_DWORD)size) == 0)
+ {
+ m_nCurPos += size;
+ return size;
+ }
+
+ return 0;
+}
+
+FX_BOOL CFPDF_FileStream::WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size)
+{
+ if (!m_pFS || !m_pFS->WriteBlock) return FALSE;
+
+ if(m_pFS->WriteBlock(m_pFS->clientData, (FPDF_DWORD)offset, buffer, (FPDF_DWORD)size) == 0)
+ {
+ m_nCurPos = offset + size;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+FX_BOOL CFPDF_FileStream::Flush()
+{
+ if (!m_pFS || !m_pFS->Flush) return TRUE;
+
+ return m_pFS->Flush(m_pFS->clientData) == 0;
+}
CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess)
{
- if (pFileAccess)
- m_FileAccess = *pFileAccess;
+ m_FileAccess = *pFileAccess;
+ m_BufferOffset = (FX_DWORD)-1;
+}
+
+FX_BOOL CPDF_CustomAccess::GetByte(FX_DWORD pos, FX_BYTE& ch)
+{
+ if (pos >= m_FileAccess.m_FileLen) return FALSE;
+ if (m_BufferOffset == (FX_DWORD)-1 || pos < m_BufferOffset || pos >= m_BufferOffset + 512) {
+ // Need to read from file access
+ m_BufferOffset = pos;
+ int size = 512;
+ if (pos + 512 > m_FileAccess.m_FileLen)
+ size = m_FileAccess.m_FileLen - pos;
+ if (!m_FileAccess.m_GetBlock(m_FileAccess.m_Param, m_BufferOffset, m_Buffer, size))
+ return FALSE;
+ }
+ ch = m_Buffer[pos - m_BufferOffset];
+ return TRUE;
+}
+
+FX_BOOL CPDF_CustomAccess::GetBlock(FX_DWORD pos, FX_LPBYTE pBuf, FX_DWORD size)
+{
+ if (pos + size > m_FileAccess.m_FileLen) return FALSE;
+ return m_FileAccess.m_GetBlock(m_FileAccess.m_Param, pos, pBuf, size);
}
FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size)
@@ -161,6 +266,9 @@ DLLEXPORT void STDCALL FPDF_InitLibrary(FX_LPVOID hInstance)
#endif
#endif
+ CPDFXFA_App* pAppProvider = FPDFXFA_GetApp();
+ pAppProvider->Initialize();
+
#ifdef _WIN32
// Get module path
TCHAR app_path[MAX_PATH];
@@ -187,6 +295,7 @@ DLLEXPORT void STDCALL FPDF_InitLibrary(FX_LPVOID hInstance)
DLLEXPORT void STDCALL FPDF_DestroyLibrary()
{
+ FPDFXFA_ReleaseApp();
#if _FX_OS_ == _FX_LINUX_EMBEDDED_
if (g_pFontMapper) delete g_pFontMapper;
@@ -254,8 +363,26 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BY
ProcessParseError(err_code);
return NULL;
}
- return pParser->GetDocument();
+ CPDF_Document* pPDFDoc = pParser->GetDocument();
+ if (!pPDFDoc)
+ return NULL;
+
+ CPDFXFA_App* pProvider = FPDFXFA_GetApp();
+ CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider);
+ return pDocument;
}
+DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document)
+{
+ if (!document||!((CPDFXFA_Document*)document)->GetPDFDoc())
+ return FALSE;
+
+ int iDocType = DOCTYPE_PDF;
+ FX_BOOL hasXFAField = FPDF_HasXFAField(((CPDFXFA_Document*)document)->GetPDFDoc(), iDocType);
+ if (!hasXFAField)
+ return FALSE;
+ return ((CPDFXFA_Document*)document)->LoadXFADoc();
+}
+
extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code);
@@ -297,7 +424,15 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, int s
CPDF_Document * pDoc = NULL;
pDoc = pParser?pParser->GetDocument():NULL;
CheckUnSupportError(pDoc, err_code);
- return pParser->GetDocument();
+ CPDF_Document* pPDFDoc = pParser->GetDocument();
+ if (!pPDFDoc)
+ return NULL;
+
+ CPDFXFA_App* pProvider = FPDFXFA_GetApp();
+ CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider);
+ //pDocument->LoadXFADoc();
+
+ return pDocument;
}
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password)
@@ -314,15 +449,26 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAc
CPDF_Document * pDoc = NULL;
pDoc = pParser?pParser->GetDocument():NULL;
CheckUnSupportError(pDoc, err_code);
- return pParser->GetDocument();
+ CPDF_Document* pPDFDoc = pParser->GetDocument();
+ if (!pPDFDoc)
+ return NULL;
+
+ CPDFXFA_App* pProvider = FPDFXFA_GetApp();
+ CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider);
+ //pDocument->LoadXFADoc();
+
+ return pDocument;
}
DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVersion)
{
if(!doc||!fileVersion) return FALSE;
*fileVersion = 0;
- CPDF_Document* pDoc = (CPDF_Document*)doc;
- CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser();
+ CPDFXFA_Document* pDoc = (CPDFXFA_Document*)doc;
+ CPDF_Document* pPDFDoc = pDoc->GetPDFDoc();
+ if (!pPDFDoc) return (FX_DWORD)-1;
+ CPDF_Parser* pParser = (CPDF_Parser*)pPDFDoc->GetParser();
+
if(!pParser)
return FALSE;
*fileVersion = pParser->GetFileVersion();
@@ -333,8 +479,10 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVers
DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document)
{
if (document == NULL) return 0;
- CPDF_Document*pDoc = (CPDF_Document*)document;
- CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser();
+ CPDFXFA_Document*pDoc = (CPDFXFA_Document*)document;
+ CPDF_Document* pPDFDoc = pDoc->GetPDFDoc();
+ if (!pPDFDoc) return (FX_DWORD)-1;
+ CPDF_Parser* pParser = (CPDF_Parser*)pPDFDoc->GetParser();
CPDF_Dictionary* pDict = pParser->GetEncryptDict();
if (pDict == NULL) return (FX_DWORD)-1;
@@ -355,38 +503,33 @@ DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document)
DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document)
{
if (document == NULL) return 0;
- return ((CPDF_Document*)document)->GetPageCount();
+ CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document;
+ return pDoc->GetPageCount();
+// return ((CPDF_Document*)document)->GetPageCount();
}
DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, int page_index)
{
if (document == NULL) return NULL;
- if (page_index < 0 || page_index >= FPDF_GetPageCount(document)) return NULL;
+ CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document;
+ if (page_index < 0 || page_index >= pDoc->GetPageCount()) return NULL;
// CPDF_Parser* pParser = (CPDF_Parser*)document;
- CPDF_Document* pDoc = (CPDF_Document*)document;
- if (pDoc == NULL) return NULL;
- CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
- if (pDict == NULL) return NULL;
- CPDF_Page* pPage = FX_NEW CPDF_Page;
- pPage->Load(pDoc, pDict);
- pPage->ParseContent();
-
-// CheckUnSupportError(pDoc, 0);
-
- return pPage;
+ return pDoc->GetPage(page_index);
}
DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page)
{
if (!page)
return 0.0;
- return ((CPDF_Page*)page)->GetPageWidth();
+ return ((CPDFXFA_Page*)page)->GetPageWidth();
+// return ((CPDF_Page*)page)->GetPageWidth();
}
DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page)
{
if (!page) return 0.0;
- return ((CPDF_Page*)page)->GetPageHeight();
+// return ((CPDF_Page*)page)->GetPageHeight();
+ return ((CPDFXFA_Page*)page)->GetPageHeight();
}
void DropContext(void* data)
@@ -408,7 +551,8 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int
int rotate, int flags)
{
if (page==NULL) return;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage) return;
CRenderContext* pContext = FX_NEW CRenderContext;
pPage->SetPrivateData((void*)1, pContext, DropContext);
@@ -562,8 +706,8 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page,
int size_x, int size_y, int rotate, int flags)
{
if (bitmap == NULL || page == NULL) return;
- CPDF_Page* pPage = (CPDF_Page*)page;
-
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ if (!pPage) return;
CRenderContext* pContext = FX_NEW CRenderContext;
pPage->SetPrivateData((void*)1, pContext, DropContext);
@@ -592,12 +736,14 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page,
DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page)
{
if (!page) return;
- CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)(((CPDF_Page*)page))->GetPrivateData((FX_LPVOID)page);
- if (pPageView && pPageView->IsLocked()) {
- pPageView->TakeOverPage();
- return;
- }
- delete (CPDF_Page*)page;
+ CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
+
+ pPage->Release();
+// CPDFXFA_Document* pDoc = pPage->GetDocument();
+// if (pDoc) {
+// pDoc->RemovePage(pPage);
+// }
+// delete (CPDFXFA_Page*)page;
}
@@ -605,14 +751,16 @@ DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document)
{
if (!document)
return;
- CPDF_Document* pDoc = (CPDF_Document*)document;
- CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser();
- if (pParser == NULL)
- {
- delete pDoc;
- return;
- }
- delete pParser;
+ CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document;
+ delete pDoc;
+
+// CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser();
+// if (pParser == NULL)
+// {
+// delete pDoc;
+// return;
+// }
+// delete pParser;
// delete pDoc;
}
@@ -625,34 +773,17 @@ DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, int start_x, int start_
int rotate, int device_x, int device_y, double* page_x, double* page_y)
{
if (page == NULL || page_x == NULL || page_y == NULL) return;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
- CPDF_Matrix page2device;
- pPage->GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, rotate);
- CPDF_Matrix device2page;
- device2page.SetReverse(page2device);
-
- FX_FLOAT page_x_f, page_y_f;
- device2page.Transform((FX_FLOAT)(device_x), (FX_FLOAT)(device_y), page_x_f, page_y_f);
-
- *page_x = (page_x_f);
- *page_y = (page_y_f);
+ pPage->DeviceToPage(start_x, start_y, size_x, size_y, rotate, device_x, device_y, page_x, page_y);
}
DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, 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)
{
if (page == NULL || device_x == NULL || device_y == NULL) return;
- CPDF_Page* pPage = (CPDF_Page*)page;
-
- CPDF_Matrix page2device;
- pPage->GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, rotate);
-
- FX_FLOAT device_x_f, device_y_f;
- page2device.Transform(((FX_FLOAT)page_x), ((FX_FLOAT)page_y), device_x_f, device_y_f);
-
- *device_x = FXSYS_round(device_x_f);
- *device_y = FXSYS_round(device_y_f);
+ CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
+ pPage->PageToDevice(start_x, start_y, size_x, size_y, rotate, page_x, page_y, device_x, device_y);
}
DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, int height, int alpha)
@@ -734,7 +865,7 @@ void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, int start_
int rotate, int flags,FX_BOOL bNeedToRestore, IFSDK_PAUSE_Adapter * pause )
{
//#ifdef _LICENSED_BUILD_
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
if (pPage == NULL) return;
if (!pContext->m_pOptions)
@@ -797,26 +928,43 @@ void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, int start_
DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_index, double* width, double* height)
{
- CPDF_Document* pDoc = (CPDF_Document*)document;
- if(pDoc == NULL)
+// CPDF_Document* pDoc = (CPDF_Document*)document;
+// if(pDoc == NULL)
+// return FALSE;
+//
+// CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
+// if (pDict == NULL) return FALSE;
+//
+// CPDF_Page page;
+// page.Load(pDoc, pDict);
+// *width = page.GetPageWidth();
+// *height = page.GetPageHeight();
+
+ CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document;
+ if (pDoc == NULL)
return FALSE;
- CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
- if (pDict == NULL) return FALSE;
+ int count = pDoc->GetPageCount();
+ if (page_index < 0 || page_index >= count)
+ return FALSE;
- CPDF_Page page;
- page.Load(pDoc, pDict);
- *width = page.GetPageWidth();
- *height = page.GetPageHeight();
+ CPDFXFA_Page* pPage = pDoc->GetPage(page_index);
+ if (!pPage)
+ return FALSE;
+
+ *width = pPage->GetPageWidth();
+ *height = pPage->GetPageHeight();
return TRUE;
}
DLLEXPORT FPDF_BOOL STDCALL FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document)
{
- CPDF_Document* pDoc = (CPDF_Document*)document;
+ CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document;
if (!pDoc) return TRUE;
- CPDF_ViewerPreferences viewRef(pDoc);
+ CPDF_Document* pPDFDoc = pDoc->GetPDFDoc();
+ if (!pPDFDoc) return TRUE;
+ CPDF_ViewerPreferences viewRef(pPDFDoc);
return viewRef.PrintScaling();
}
@@ -858,7 +1006,67 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,FPDF_
if (name == NULL || name[0] == 0)
return NULL;
- CPDF_Document* pDoc = (CPDF_Document*)document;
- CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests"));
- return name_tree.LookupNamedDest(pDoc, name);
+ CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document;
+ CPDF_Document* pPDFDoc = pDoc->GetPDFDoc();
+ if (!pPDFDoc)
+ return NULL;
+ CPDF_NameTree name_tree(pPDFDoc, FX_BSTRC("Dests"));
+ return name_tree.LookupNamedDest(pPDFDoc, name);
+}
+
+FPDF_RESULT FPDF_BStr_Init(FPDF_BSTR* str)
+{
+ if (!str)
+ return -1;
+
+ FXSYS_memset32(str, 0, sizeof(FPDF_BSTR));
+ return 0;
+}
+
+FPDF_RESULT FPDF_BStr_Set(FPDF_BSTR* str, FPDF_LPCSTR bstr, int length)
+{
+ if (!str) return -1;
+ if (!bstr || !length)
+ return -1;
+ if (length == -1)
+ length = FXSYS_strlen(bstr);
+
+ if (length == 0)
+ {
+ if (str->str)
+ {
+ FX_Free(str->str);
+ str->str = NULL;
+ }
+ str->len = 0;
+ return 0;
+ }
+
+ if (str->str && str->len < length)
+ str->str = FX_Realloc(char, str->str, length+1);
+ else if (!str->str)
+ str->str = FX_Alloc(char, length+1);
+
+ str->str[length] = 0;
+ if (str->str == NULL)
+ return -1;
+
+ FXSYS_memcpy(str->str, bstr, length);
+ str->len = length;
+
+ return 0;
+}
+
+FPDF_RESULT FPDF_BStr_Clear(FPDF_BSTR* str)
+{
+ if(!str)
+ return -1;
+
+ if (str->str)
+ {
+ FX_Free(str->str);
+ str->str = NULL;
+ }
+ str->len = 0;
+ return 0;
}
diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp
new file mode 100644
index 0000000000..7abd2741a0
--- /dev/null
+++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp
@@ -0,0 +1,640 @@
+// 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
+
+#include "../../include/fsdk_define.h"
+#include "../../include/fpdfformfill.h"
+#include "../../include/fsdk_mgr.h"
+#include "../../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../../include/fpdfxfa/fpdfxfa_util.h"
+#include "../../include/jsapi/fxjs_v8.h"
+#include "../../include/javascript/IJavaScript.h"
+#include "../../include/fpdfxfa/fpdfxfa_app.h"
+CPDFXFA_App* CPDFXFA_App::m_pApp = NULL;
+
+CPDFXFA_App* FPDFXFA_GetApp()
+{
+ if (!CPDFXFA_App::m_pApp)
+ CPDFXFA_App::m_pApp = FX_NEW CPDFXFA_App();
+
+ return CPDFXFA_App::m_pApp;
+}
+
+void FPDFXFA_ReleaseApp()
+{
+ if (CPDFXFA_App::m_pApp)
+ delete CPDFXFA_App::m_pApp;
+ CPDFXFA_App::m_pApp = NULL;
+}
+
+CJS_RuntimeFactory* g_GetJSRuntimeFactory()
+{
+ static CJS_RuntimeFactory g_JSRuntimeFactory;
+ return &g_JSRuntimeFactory;
+}
+
+CPDFXFA_App::CPDFXFA_App() :
+ m_pXFAApp(NULL),
+ m_pFontMgr(NULL),
+ m_hJSERuntime(NULL),
+ //m_pJSRuntime(NULL),
+ //m_pEnv(NULL),
+ m_csAppType(JS_STR_VIEWERTYPE_STANDARD)
+{
+ m_pJSRuntimeFactory = NULL;
+ m_pJSRuntimeFactory = g_GetJSRuntimeFactory();
+ m_pJSRuntimeFactory->AddRef();
+ m_pEnvList.RemoveAll();
+ m_bInitRuntime = FALSE;
+}
+//IFXJS_Runtime* CPDFXFA_App::GetJSRuntime()
+//{
+// FXSYS_assert(m_pJSRuntimeFactory);
+// if(!m_pJSRuntime)
+// m_pJSRuntime = m_pJSRuntimeFactory->NewJSRuntime(this);
+// return m_pJSRuntime;
+//}
+
+CPDFXFA_App::~CPDFXFA_App()
+{
+ if (m_pFontMgr)
+ {
+ m_pFontMgr->Release();
+ m_pFontMgr = NULL;
+ }
+
+ if (m_pXFAApp)
+ {
+ m_pXFAApp->Release();
+ m_pXFAApp = NULL;
+ }
+
+ //if (m_pJSRuntime && m_pJSRuntimeFactory)
+ // m_pJSRuntimeFactory->DeleteJSRuntime(m_pJSRuntime);
+ m_pJSRuntimeFactory->Release();
+
+
+ if (m_hJSERuntime)
+ {
+ FXJSE_Runtime_Release(m_hJSERuntime);
+ m_hJSERuntime = NULL;
+ }
+
+ FXJSE_Finalize();
+
+ BC_Library_Destory();
+}
+
+FX_BOOL CPDFXFA_App::Initialize()
+{
+ BC_Library_Init();
+
+ FXJSE_Initialize();
+ m_hJSERuntime = FXJSE_Runtime_Create();
+
+ if (!m_hJSERuntime)
+ return FALSE;
+
+ //m_pJSRuntime = m_pJSRuntimeFactory->NewJSRuntime(this);
+
+ m_pXFAApp = IXFA_App::Create(this);
+ if (!m_pXFAApp)
+ return FALSE;
+
+ m_pFontMgr = XFA_GetDefaultFontMgr();
+ if (!m_pFontMgr)
+ return FALSE;
+
+ m_pXFAApp->SetDefaultFontMgr(m_pFontMgr);
+
+ return TRUE;
+}
+
+FX_BOOL CPDFXFA_App::AddFormFillEnv(CPDFDoc_Environment* pEnv)
+{
+ if (!pEnv) return FALSE;
+
+ m_pEnvList.Add(pEnv);
+ return TRUE;
+}
+
+FX_BOOL CPDFXFA_App::RemoveFormFillEnv(CPDFDoc_Environment* pEnv)
+{
+ if (!pEnv) return FALSE;
+
+ int nFind = m_pEnvList.Find(pEnv);
+ if (nFind != -1) {
+ m_pEnvList.RemoveAt(nFind);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+void CPDFXFA_App::ReleaseRuntime()
+{
+ v8::Persistent<v8::Context> context;
+ JS_ReleaseRuntime((IJS_Runtime*)m_hJSERuntime, context);
+}
+
+void CPDFXFA_App::GetAppType(CFX_WideString &wsAppType)
+{
+ wsAppType = m_csAppType;
+}
+
+void CPDFXFA_App::GetAppName(CFX_WideString& wsName)
+{
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ wsName = pEnv->FFI_GetAppName();
+ }
+}
+
+void CPDFXFA_App::SetAppType(FX_WSTR wsAppType)
+{
+ m_csAppType = wsAppType;
+}
+
+void CPDFXFA_App::GetLanguage(CFX_WideString &wsLanguage)
+{
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ wsLanguage = pEnv->FFI_GetLanguage();
+ }
+}
+
+void CPDFXFA_App::GetPlatform(CFX_WideString &wsPlatform)
+{
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ wsPlatform = pEnv->FFI_GetPlatform();
+ }
+}
+
+void CPDFXFA_App::GetVariation(CFX_WideString &wsVariation)
+{
+ wsVariation = JS_STR_VIEWERVARIATION;
+}
+
+void CPDFXFA_App::GetVersion(CFX_WideString &wsVersion)
+{
+ wsVersion = JS_STR_VIEWERVERSION_XFA;
+}
+
+void CPDFXFA_App::Beep(FX_DWORD dwType)
+{
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ pEnv->JS_appBeep(dwType);
+ }
+}
+
+FX_INT32 CPDFXFA_App::MsgBox(FX_WSTR wsMessage, FX_WSTR wsTitle, FX_DWORD dwIconType, FX_DWORD dwButtonType)
+{
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (!pEnv)
+ return -1;
+
+ FX_DWORD iconType = 0;
+ int iButtonType = 0;
+ switch (dwIconType)
+ {
+ case XFA_MBICON_Error:
+ iconType |= 0;
+ break;
+ case XFA_MBICON_Warning:
+ iconType |= 1;
+ break;
+ case XFA_MBICON_Question:
+ iconType |= 2;
+ break;
+ case XFA_MBICON_Status:
+ iconType |= 3;
+ break;
+ }
+ switch (dwButtonType)
+ {
+ case XFA_MB_OK:
+ iButtonType |= 0;
+ break;
+ case XFA_MB_OKCancel:
+ iButtonType |= 1;
+ break;
+ case XFA_MB_YesNo:
+ iButtonType |= 2;
+ break;
+ case XFA_MB_YesNoCancel:
+ iButtonType |= 3;
+ break;
+ }
+ FX_INT32 iRet = pEnv->JS_appAlert(wsMessage.GetPtr(), wsTitle.GetPtr(), iButtonType, iconType);
+ switch (iRet)
+ {
+ case 1:
+ return XFA_IDOK;
+ case 2:
+ return XFA_IDCancel;
+ case 3:
+ return XFA_IDNo;
+ case 4:
+ return XFA_IDYes;
+ }
+ return XFA_IDYes;
+}
+
+void CPDFXFA_App::Response(CFX_WideString &wsAnswer, FX_WSTR wsQuestion, FX_WSTR wsTitle, FX_WSTR wsDefaultAnswer, FX_BOOL bMark)
+{
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ int nLength = 2048;
+ char* pBuff = new char[nLength];
+ nLength = pEnv->JS_appResponse(wsQuestion.GetPtr(), wsTitle.GetPtr(), wsDefaultAnswer.GetPtr(), NULL, bMark, pBuff, nLength);
+ if(nLength > 0)
+ {
+ nLength = nLength>2046?2046:nLength;
+ pBuff[nLength] = 0;
+ pBuff[nLength+1] = 0;
+ wsAnswer = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLength);
+ }
+ delete[] pBuff;
+ }
+}
+
+FX_INT32 CPDFXFA_App::GetCurDocumentInBatch()
+{
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ return pEnv->FFI_GetCurDocument();
+ }
+ return 0;
+}
+
+FX_INT32 CPDFXFA_App::GetDocumentCountInBatch()
+{
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ return pEnv->FFI_GetDocumentCount();
+ }
+
+ return 0;
+}
+
+IFX_FileRead* CPDFXFA_App::DownloadURL(FX_WSTR wsURL)
+{
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ return pEnv->FFI_DownloadFromURL(wsURL.GetPtr());
+ }
+ return NULL;
+}
+
+FX_BOOL CPDFXFA_App::PostRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_WSTR wsContentType,
+ FX_WSTR wsEncode, FX_WSTR wsHeader, CFX_WideString &wsResponse)
+{
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ wsResponse = pEnv->FFI_PostRequestURL(wsURL.GetPtr(), wsData.GetPtr(), wsContentType.GetPtr(), wsEncode.GetPtr(), wsHeader.GetPtr());
+ return TRUE;
+ }
+ return FALSE;
+}
+
+FX_BOOL CPDFXFA_App::PutRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_WSTR wsEncode)
+{
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ return pEnv->FFI_PutRequestURL(wsURL.GetPtr(), wsData.GetPtr(), wsEncode.GetPtr());
+ }
+ return FALSE;
+}
+
+void CPDFXFA_App::LoadString(FX_INT32 iStringID, CFX_WideString &wsString)
+{
+ switch (iStringID)
+ {
+ case XFA_IDS_ValidateFailed:
+ wsString = L"%s validate failed";
+ return;
+ case XFA_IDS_CalcOverride:
+ wsString = L"Calculate Override";
+ return;
+ case XFA_IDS_ModifyField:
+ wsString = L"Are you sure you want to modify this field?";
+ return;
+ case XFA_IDS_NotModifyField:
+ wsString = L"You are not allowed to modify this field.";
+ return;
+ case XFA_IDS_AppName:
+ wsString = L"Foxit";
+ return;
+ case XFA_IDS_ImageFilter:
+ wsString = L"Image Files(*.bmp;*.jpg;*.png;*.gif;*.tif)|*.bmp;*.jpg;*.png;*.gif;*.tif|All Files(*.*)|*.*||";
+ return;
+ case XFA_IDS_UNKNOW_CATCHED:
+ wsString = L"unknown error is catched!";
+ return;
+ case XFA_IDS_Unable_TO_SET:
+ wsString = L"Unable to set ";
+ return;
+ case XFA_IDS_VALUE_EXCALMATORY:
+ wsString = L" value!";
+ return;
+ case XFA_IDS_INVALID_ENUM_VALUE:
+ wsString = L"Invalid enumerated value: ";
+ return;
+ case XFA_IDS_UNSUPPORT_METHOD:
+ wsString = L"unsupport %s method.";
+ return;
+ case XFA_IDS_UNSUPPORT_PROP:
+ wsString = L"unsupport %s property.";
+ return;
+ case XFA_IDS_INVAlID_PROP_SET:
+ wsString = L"Invalid property set operation;";
+ return;
+ case XFA_IDS_NOT_DEFAUL_VALUE:
+ wsString = L" doesn't have a default property";
+ return;
+ case XFA_IDS_UNABLE_SET_LANGUAGE:
+ wsString = L"Unable to set language value!";
+ return;
+ case XFA_IDS_UNABLE_SET_NUMPAGES:
+ wsString = L"Unable to set numPages value!";
+ return;
+ case XFA_IDS_UNABLE_SET_PLATFORM:
+ wsString = L"Unable to set platform value!";
+ return;
+ case XFA_IDS_UNABLE_SET_VALIDATIONENABLE:
+ wsString = L"Unable to set validationsEnabled value!";
+ return;
+ case XFA_IDS_UNABLE_SET_VARIATION:
+ wsString = L"Unable to set variation value!";
+ return;
+ case XFA_IDS_UNABLE_SET_VERSION:
+ wsString = L"Unable to set version value!";
+ return;
+ case XFA_IDS_UNABLE_SET_READY:
+ wsString = L"Unable to set ready value!";
+ return;
+ case XFA_IDS_NUMBER_OF_OCCUR:
+ wsString = L"The element [%s] has violated its allowable number of occurrences";
+ return;
+ case XFA_IDS_UNABLE_SET_CLASS_NAME:
+ wsString = L"Unable to set className value!";
+ return;
+ case XFA_IDS_UNABLE_SET_LENGTH_VALUE:
+ wsString = L"Unable to set length value!";
+ return;
+ case XFA_IDS_UNSUPPORT_CHAR:
+ wsString = L"unsupported char '%c'";
+ return;
+ case XFA_IDS_BAD_SUFFIX:
+ wsString = L"bad suffix on number";
+ return;
+ case XFA_IDS_EXPECTED_IDENT:
+ wsString = L"expected identifier instead of '%s'";
+ return;
+ case XFA_IDS_EXPECTED_STRING:
+ wsString = L"expected '%s' instead of '%s'";
+ return;
+ case XFA_IDS_INVALIDATE_CHAR:
+ wsString = L"invalidate char '%c'";
+ return;
+ case XFA_IDS_REDEFINITION:
+ wsString = L"'%s' redefinition ";
+ return;
+ case XFA_IDS_INVALIDATE_TOKEN:
+ wsString = L"invalidate token '%s'";
+ return;
+ case XFA_IDS_INVALIDATE_EXPRESSION:
+ wsString = L"invalidate expression '%s'";
+ return;
+ case XFA_IDS_UNDEFINE_IDENTIFIER:
+ wsString = L"undefined identifier '%s'";
+ return;
+ case XFA_IDS_INVALIDATE_LEFTVALUE:
+ wsString = L"invalidate left-value '%s'";
+ return;
+ case XFA_IDS_COMPILER_ERROR:
+ wsString = L"compiler error";
+ return;
+ case XFA_IDS_CANNOT_MODIFY_VALUE:
+ wsString = L"can't modify the '%s' value";
+ return;
+ case XFA_IDS_ERROR_PARAMETERS:
+ wsString = L"function '%s' has not %d parameters";
+ return;
+ case XFA_IDS_EXPECT_ENDIF:
+ wsString = L"expected 'endif' instead of '%s'";
+ return;
+ case XFA_IDS_UNEXPECTED_EXPRESSION:
+ wsString = L"unexpected expression '%s'";
+ return;
+ case XFA_IDS_CONDITION_IS_NULL:
+ wsString = L"condition is null";
+ return;
+ case XFA_IDS_ILLEGALBREAK:
+ wsString = L"illegal break";
+ return;
+ case XFA_IDS_ILLEGALCONTINUE:
+ wsString = L"illegal continue";
+ return;
+ case XFA_IDS_EXPECTED_OPERATOR:
+ wsString = L"expected operator '%s' instead of '%s'";
+ return;
+ case XFA_IDS_DIVIDE_ZERO:
+ wsString = L"divide by zero";
+ return;
+ case XFA_IDS_CANNOT_COVERT_OBJECT:
+ wsString = L"%s.%s can not covert to object";
+ return;
+ case XFA_IDS_NOT_FOUND_CONTAINER:
+ wsString = L"can not found container '%s'";
+ return;
+ case XFA_IDS_NOT_FOUND_PROPERTY:
+ wsString = L"can not found property '%s'";
+ return;
+ case XFA_IDS_NOT_FOUND_METHOD:
+ wsString = L"can not found method '%s'";
+ return;
+ case XFA_IDS_NOT_FOUND_CONST:
+ wsString = L"can not found const '%s'";
+ return;
+ case XFA_IDS_NOT_ASSIGN_OBJECT:
+ wsString = L"can not direct assign value to object";
+ return;
+ case XFA_IDS_IVALIDATE_INSTRUCTION:
+ wsString = L"invalidate instruction";
+ return;
+ case XFA_IDS_EXPECT_NUMBER:
+ wsString = L"expected number instead of '%s'";
+ return;
+ case XFA_IDS_VALIDATE_OUT_ARRAY:
+ wsString = L"validate access index '%s' out of array";
+ return;
+ case XFA_IDS_CANNOT_ASSIGN_IDENT:
+ wsString = L"can not assign to %s";
+ return;
+ case XFA_IDS_NOT_FOUNT_FUNCTION:
+ wsString = L"can not found '%s' function";
+ return;
+ case XFA_IDS_NOT_ARRAY:
+ wsString = L"'%s' doesn't an array";
+ return;
+ case XFA_IDS_OUT_ARRAY:
+ wsString = L"out of range of '%s' array";
+ return;
+ case XFA_IDS_NOT_SUPPORT_CALC:
+ wsString = L"'%s' operator can not support array calculate";
+ return;
+ case XFA_IDS_ARGUMENT_NOT_ARRAY:
+ wsString = L"'%s' function's %d argument can not be array";
+ return;
+ case XFA_IDS_ARGUMENT_EXPECT_CONTAINER:
+ wsString = L"'%s' argument expected a container";
+ return;
+ case XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT:
+ wsString = L"an attempt was made to reference property '%s' of a non-object in SOM expression %s";
+ return;
+ case XFA_IDS_FUNCTION_IS_BUILDIN:
+ wsString = L"function '%s' is buildin";
+ return;
+ case XFA_IDS_ERROR_MSG:
+ wsString = L"%s : %s";
+ return;
+ case XFA_IDS_INDEX_OUT_OF_BOUNDS:
+ wsString = L"Index value is out of bounds";
+ return;
+ case XFA_IDS_INCORRECT_NUMBER_OF_METHOD:
+ wsString = L"Incorrect number of parameters calling method '%s'";
+ return;
+ case XFA_IDS_ARGUMENT_MISMATCH:
+ wsString = L"Argument mismatch in property or function argument";
+ return;
+ case XFA_IDS_INVALID_ENUMERATE:
+ wsString = L"Invalid enumerated value: %s";
+ return;
+ case XFA_IDS_INVALID_APPEND:
+ wsString = L"Invalid append operation: %s cannot have a child element of %s";
+ return;
+ case XFA_IDS_SOM_EXPECTED_LIST:
+ wsString = L"SOM expression returned list when single result was expected";
+ return;
+ case XFA_IDS_NOT_HAVE_PROPERTY:
+ wsString = L"'%s' doesn't have property '%s'";
+ return;
+ case XFA_IDS_INVALID_NODE_TYPE:
+ wsString = L"Invalid node type : '%s'";
+ return;
+ case XFA_IDS_VIOLATE_BOUNDARY:
+ wsString = L"The element [%s] has violated its allowable number of occurrences";
+ return;
+ case XFA_IDS_SERVER_DENY:
+ wsString = L"Server does not permit";
+ return;
+ /*case XFA_IDS_StringWeekDay_Sun:
+ wsString = L"?¨¹¨¨?";
+ return;
+ case XFA_IDS_StringWeekDay_Mon:
+ wsString = L"?¨¹¨°?";
+ return;
+ case XFA_IDS_StringWeekDay_Tue:
+ wsString = L"?¨¹?t";
+ return;
+ case XFA_IDS_StringWeekDay_Wed:
+ wsString = L"?¨¹¨¨y";
+ return;
+ case XFA_IDS_StringWeekDay_Thu:
+ wsString = L"?¨¹??";
+ return;
+ case XFA_IDS_StringWeekDay_Fri:
+ wsString = L"?¨¹??";
+ return;
+ case XFA_IDS_StringWeekDay_Sat:
+ wsString = L"?¨¹¨¢¨´";
+ return;
+ case XFA_IDS_StringMonth_Jan:
+ wsString = L"1??";
+ return;
+ case XFA_IDS_StringMonth_Feb:
+ wsString = L"2??";
+ return;
+ case XFA_IDS_StringMonth_March:
+ wsString = L"3??";
+ return;
+ case XFA_IDS_StringMonth_April:
+ wsString = L"4??";
+ return;
+ case XFA_IDS_StringMonth_May:
+ wsString = L"5??";
+ return;
+ case XFA_IDS_StringMonth_June:
+ wsString = L"6??";
+ return;
+ case XFA_IDS_StringMonth_July:
+ wsString = L"7??";
+ return;
+ case XFA_IDS_StringMonth_Aug:
+ wsString = L"8??";
+ return;
+ case XFA_IDS_StringMonth_Sept:
+ wsString = L"9??";
+ return;
+ case XFA_IDS_StringMonth_Oct:
+ wsString = L"10??";
+ return;
+ case XFA_IDS_StringMonth_Nov:
+ wsString = L"11??";
+ return;
+ case XFA_IDS_StringMonth_Dec:
+ wsString = L"12??";
+ return;
+ case XFA_IDS_String_Today:
+ wsString = L"??¨¬¨¬";
+ return;*/
+ case XFA_IDS_ValidateLimit:
+ wsString = FX_WSTRC(L"Message limit exceeded. Remaining %d validation errors not reported.");
+ return;
+ case XFA_IDS_ValidateNullWarning:
+ wsString = FX_WSTRC(L"%s cannot be left blank. To ignore validations for %s, click Ignore.");
+ return;
+ case XFA_IDS_ValidateNullError:
+ wsString = FX_WSTRC(L"%s cannot be left blank.");
+ return;
+ case XFA_IDS_ValidateWarning:
+ wsString = FX_WSTRC(L"The value you entered for %s is invalid. To ignore validations for %s, click Ignore.");
+ return;
+ case XFA_IDS_ValidateError:
+ wsString = FX_WSTRC(L"The value you entered for %s is invalid.");
+ return;
+ }
+
+}
+
+FX_BOOL CPDFXFA_App::ShowFileDialog(FX_WSTR wsTitle, FX_WSTR wsFilter, CFX_WideStringArray &wsPathArr, FX_BOOL bOpen)
+{
+ //if (m_pEnv)
+ //{
+ // return m_pEnv->FFI_ShowFileDialog(wsTitle.GetPtr(), wsFilter.GetPtr(), wsPathArr, bOpen);
+ //}
+ return FALSE;
+}
+
+IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr()
+{
+ CXFA_FWLAdapterTimerMgr* pAdapter = NULL;
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ pAdapter = FX_NEW CXFA_FWLAdapterTimerMgr(pEnv);
+ return pAdapter;
+}
diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp
new file mode 100644
index 0000000000..b416da0abc
--- /dev/null
+++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp
@@ -0,0 +1,1476 @@
+// 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
+
+#include "../../include/fsdk_define.h"
+#include "../../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../../include/fpdfformfill.h"
+#include "../../include/fsdk_mgr.h"
+#include "../../include/fpdfxfa/fpdfxfa_app.h"
+#include "../../include/fpdfxfa/fpdfxfa_util.h"
+#include "../../include/fpdfxfa/fpdfxfa_page.h"
+#include "../../include/javascript/IJavaScript.h"
+
+
+
+#define IDS_XFA_StringMonth_April "April"
+#define IDS_XFA_StringMonth_May "May"
+#define IDS_XFA_StringMonth_June "June"
+#define IDS_XFA_StringMonth_July "July"
+#define IDS_XFA_StringMonth_Aug "August"
+#define IDS_XFA_StringMonth_Sept "September"
+#define IDS_XFA_StringMonth_Oct "October"
+#define IDS_XFA_StringMonth_Nov "November"
+#define IDS_XFA_StringMonth_Dec "December"
+#define IDS_XFA_String_Today "Today"
+#define IDS_XFA_ValidateLimit "Message limit exceeded. Remaining %d validation errors not reported."
+#define IDS_XFA_Validate_Input "At least one required field was empty. Please fill in the required fields\r\n(highlighted) before continuing."
+
+// submit
+#define FXFA_CONFIG 0x00000001
+#define FXFA_TEMPLATE 0x00000010
+#define FXFA_LOCALESET 0x00000100
+#define FXFA_DATASETS 0x00001000
+#define FXFA_XMPMETA 0x00010000
+#define FXFA_XFDF 0x00100000
+#define FXFA_FORM 0x01000000
+#define FXFA_PDF 0x10000000
+
+#ifndef _WIN32
+extern void SetLastError(int err);
+
+extern int GetLastError();
+#endif
+
+CPDFXFA_Document::CPDFXFA_Document(CPDF_Document* pPDFDoc, CPDFXFA_App* pProvider) :
+ m_pPDFDoc(pPDFDoc),
+ m_pApp(pProvider),
+ m_pXFADoc(NULL),
+ m_pXFADocView(NULL),
+ m_iDocType(DOCTYPE_PDF),
+ m_pJSContext(NULL),
+ m_pSDKDoc(NULL)
+{
+ m_XFAPageList.RemoveAll();
+}
+
+CPDFXFA_Document::~CPDFXFA_Document()
+{
+ if (m_pPDFDoc)
+ {
+ CPDF_Parser* pParser = (CPDF_Parser*)m_pPDFDoc->GetParser();
+ if (pParser == NULL)
+ {
+ delete m_pPDFDoc;
+ }else
+ {
+ delete pParser;
+ }
+ m_pPDFDoc = NULL;
+ }
+ if (m_pXFADoc)
+ {
+ IXFA_App* pApp = m_pApp->GetXFAApp();
+ if (pApp)
+ {
+ IXFA_DocHandler* pDocHandler = pApp->GetDocHandler();
+ if (pDocHandler)
+ {
+ pDocHandler->CloseDoc(m_pXFADoc);
+ pDocHandler->ReleaseDoc(m_pXFADoc);
+ m_pXFADoc = NULL;
+ }
+ }
+ }
+
+ if (m_pJSContext)
+ {
+ if (m_pSDKDoc && m_pSDKDoc->GetEnv())
+ {
+ m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext);
+ m_pJSContext = NULL;
+ }
+ }
+
+
+ if (m_pSDKDoc)
+ delete m_pSDKDoc;
+ m_pSDKDoc = NULL;
+}
+
+FX_BOOL CPDFXFA_Document::LoadXFADoc()
+{
+ if (!m_pPDFDoc)
+ return FALSE;
+
+ m_XFAPageList.RemoveAll();
+
+ int iDocType = DOCTYPE_PDF;
+ FX_BOOL hasXFAField = FPDF_HasXFAField(m_pPDFDoc, iDocType);
+
+ if (hasXFAField)
+ {
+ IXFA_App* pApp = m_pApp->GetXFAApp();
+ if (pApp)
+ {
+ m_pXFADoc = pApp->CreateDoc(this, m_pPDFDoc);
+ if (!m_pXFADoc)
+ {
+ SetLastError(FPDF_ERR_XFALOAD);
+ return FALSE;
+ }
+
+ IXFA_DocHandler* pDocHandler = pApp->GetDocHandler();
+ if (pDocHandler)
+ {
+ int iStatus = pDocHandler->StartLoad(m_pXFADoc);
+ iStatus = pDocHandler->DoLoad(m_pXFADoc, NULL);
+ if (iStatus != 100)
+ {
+ pDocHandler->CloseDoc(m_pXFADoc);
+ pDocHandler->ReleaseDoc(m_pXFADoc);
+ m_pXFADoc = NULL;
+
+ SetLastError(FPDF_ERR_XFALOAD);
+ return FALSE;
+ }
+ pDocHandler->StopLoad(m_pXFADoc);
+ pDocHandler->SetJSERuntime(m_pXFADoc, m_pApp->GetJSERuntime());
+
+ if (pDocHandler->GetDocType(m_pXFADoc) == XFA_DOCTYPE_Dynamic)
+ m_iDocType = DOCTYPE_DYNIMIC_XFA;
+ else
+ m_iDocType = DOCTYPE_STATIC_XFA;
+
+ m_pXFADocView = pDocHandler->CreateDocView(m_pXFADoc, XFA_DOCVIEW_View);
+ FXSYS_assert(m_pXFADocView);
+
+ if (m_pXFADocView->StartLayout() < 0)
+ {
+ pDocHandler->CloseDoc(m_pXFADoc);
+ pDocHandler->ReleaseDoc(m_pXFADoc);
+ m_pXFADoc = NULL;
+
+ SetLastError(FPDF_ERR_XFALAYOUT);
+ return FALSE;
+ }
+ else
+ {
+ m_pXFADocView->DoLayout(NULL);
+ m_pXFADocView->StopLayout();
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+int CPDFXFA_Document::GetPageCount()
+{
+ if (!m_pPDFDoc && !m_pXFADoc)
+ return 0;
+
+ switch (m_iDocType)
+ {
+ case DOCTYPE_PDF:
+ case DOCTYPE_STATIC_XFA:
+ if (m_pPDFDoc)
+ return m_pPDFDoc->GetPageCount();
+ case DOCTYPE_DYNIMIC_XFA:
+ if (m_pXFADoc)
+ return m_pXFADocView->CountPageViews();
+ default:
+ return 0;
+ }
+
+ return 0;
+}
+
+CPDFXFA_Page* CPDFXFA_Document::GetPage(int page_index)
+{
+ if (!m_pPDFDoc && !m_pXFADoc)
+ return NULL;
+
+ CPDFXFA_Page* pPage = NULL;
+ if (m_XFAPageList.GetSize())
+ {
+ pPage = m_XFAPageList.GetAt(page_index);
+ if (pPage)
+ pPage->AddRef();
+ }
+ else
+ {
+ m_XFAPageList.SetSize(GetPageCount());
+ }
+
+ if (!pPage)
+ {
+ pPage = FX_NEW CPDFXFA_Page(this, page_index);
+ FX_BOOL bRet = pPage->LoadPage();
+ if (!bRet) {
+ delete pPage;
+ return NULL;
+ }
+
+ m_XFAPageList.SetAt(page_index, pPage);
+ }
+
+ return pPage;
+}
+
+CPDFXFA_Page* CPDFXFA_Document::GetPage(IXFA_PageView* pPage)
+{
+ if (!pPage)
+ return NULL;
+
+ if (!m_pXFADoc)
+ return NULL;
+
+ if (m_iDocType != DOCTYPE_DYNIMIC_XFA)
+ return NULL;
+
+ int nSize = m_XFAPageList.GetSize();
+ for (int i=0; i<nSize; i++)
+ {
+ CPDFXFA_Page* pTempPage = m_XFAPageList.GetAt(i);
+ if (!pTempPage) continue;
+ if (pTempPage->GetXFAPageView() && pTempPage->GetXFAPageView() == pPage)
+ return pTempPage;
+ }
+
+ return NULL;
+}
+
+void CPDFXFA_Document::RemovePage(CPDFXFA_Page* page)
+{
+ m_XFAPageList.SetAt(page->GetPageIndex(), NULL);
+}
+
+CPDFSDK_Document* CPDFXFA_Document::GetSDKDocument(CPDFDoc_Environment* pFormFillEnv)
+{
+ if (!pFormFillEnv)
+ return m_pSDKDoc;
+
+ if (m_pSDKDoc)
+ return m_pSDKDoc;
+
+ m_pSDKDoc = new CPDFSDK_Document(this, pFormFillEnv);
+ if (!m_pSDKDoc)
+ return NULL;
+
+ return m_pSDKDoc;
+}
+
+void CPDFXFA_Document::ReleaseSDKDoc()
+{
+ if (m_pSDKDoc)
+ delete m_pSDKDoc;
+
+ m_pSDKDoc = NULL;
+}
+
+void CPDFXFA_Document::FXRect2PDFRect(const CFX_RectF& fxRectF, CPDF_Rect& pdfRect)
+{
+ pdfRect.left = fxRectF.left;
+ pdfRect.top = fxRectF.bottom();
+ pdfRect.right = fxRectF.right();
+ pdfRect.bottom = fxRectF.top;
+}
+
+//////////////////////////////////////////////////////////////////////////
+void CPDFXFA_Document::SetChangeMark(XFA_HDOC hDoc)
+{
+ if (hDoc == m_pXFADoc && m_pSDKDoc)
+ {
+ m_pSDKDoc->SetChangeMark();
+ }
+}
+
+FX_BOOL CPDFXFA_Document::GetChangeMark(XFA_HDOC hDoc)
+{
+ if (hDoc == m_pXFADoc && m_pSDKDoc)
+ return m_pSDKDoc->GetChangeMark();
+ return FALSE;
+}
+
+void CPDFXFA_Document::InvalidateRect(IXFA_PageView* pPageView, const CFX_RectF& rt, FX_DWORD dwFlags /* = 0 */)
+{
+ if (!m_pXFADoc || !m_pSDKDoc)
+ return;
+
+ if (m_iDocType != DOCTYPE_DYNIMIC_XFA)
+ return;
+
+ CPDF_Rect rcPage;
+ FXRect2PDFRect(rt, rcPage);
+
+ CPDFXFA_Page* pPage = GetPage(pPageView);
+
+ if (pPage == NULL)
+ return;
+
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (!pEnv)
+ return;
+
+ pEnv->FFI_Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, rcPage.right, rcPage.top);
+}
+
+void CPDFXFA_Document::InvalidateRect(XFA_HWIDGET hWidget, FX_DWORD dwFlags /* = 0 */)
+{
+ if (!hWidget)
+ return;
+
+ if (!m_pXFADoc || !m_pSDKDoc || !m_pXFADocView)
+ return;
+
+ if (m_iDocType != DOCTYPE_DYNIMIC_XFA)
+ return;
+
+ IXFA_WidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler();
+ if (!pWidgetHandler)
+ return;
+
+ IXFA_PageView* pPageView = pWidgetHandler->GetPageView(hWidget);
+ if (!pPageView)
+ return;
+
+ CFX_RectF rect;
+ pWidgetHandler->GetRect(hWidget, rect);
+ InvalidateRect(pPageView, rect, dwFlags);
+}
+
+void CPDFXFA_Document::DisplayCaret(XFA_HWIDGET hWidget, FX_BOOL bVisible, const CFX_RectF* pRtAnchor)
+{
+ if (!hWidget || pRtAnchor == NULL)
+ return;
+
+ if (!m_pXFADoc || !m_pSDKDoc || !m_pXFADocView)
+ return;
+
+ if (m_iDocType != DOCTYPE_DYNIMIC_XFA)
+ return;
+
+ IXFA_WidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler();
+ if (!pWidgetHandler)
+ return;
+
+ IXFA_PageView* pPageView = pWidgetHandler->GetPageView(hWidget);
+ if (!pPageView)
+ return;
+
+ CPDFXFA_Page* pPage = GetPage(pPageView);
+
+ if (pPage == NULL)
+ return;
+
+ CPDF_Rect rcCaret;
+ FXRect2PDFRect(*pRtAnchor, rcCaret);
+
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (!pEnv)
+ return;
+
+ pEnv->FFI_DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top, rcCaret.right, rcCaret.bottom);
+
+}
+
+FX_BOOL CPDFXFA_Document::GetPopupPos(XFA_HWIDGET hWidget, FX_FLOAT fMinPopup, FX_FLOAT fMaxPopup, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup)
+{
+ if (NULL == hWidget)
+ {
+ return FALSE;
+ }
+ IXFA_PageView* pXFAPageView = m_pXFADocView->GetWidgetHandler()->GetPageView(hWidget);
+ if (NULL == pXFAPageView)
+ {
+ return FALSE;
+ }
+ CPDFXFA_Page* pPage = GetPage(pXFAPageView);
+ if (pPage == NULL)
+ return FALSE;
+
+ CXFA_WidgetAcc* pWidgetAcc = m_pXFADocView->GetWidgetHandler()->GetDataAcc(hWidget);
+
+ int nRotate = pWidgetAcc->GetRotate();
+
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return FALSE;
+ FS_RECTF pageViewRect;
+ pEnv->FFI_GetPageViewRect(pPage, pageViewRect);
+
+ CPDF_Rect rcAnchor;
+
+ rcAnchor.left = rtAnchor.left;
+ rcAnchor.top = rtAnchor.bottom();
+ rcAnchor.right = rtAnchor.right();
+ rcAnchor.bottom = rtAnchor.top;
+
+ int t1,t2,t;
+ FX_DWORD dwPos; FX_FLOAT fPoupHeight;
+ switch(nRotate)
+ {
+
+ case 90:
+ {
+ t1 = (int)(pageViewRect.right - rcAnchor.right);
+ t2 = (int)(rcAnchor.left - pageViewRect.left);
+ if (rcAnchor.bottom < pageViewRect.bottom)
+ {
+ rtPopup.left += rcAnchor.bottom - pageViewRect.bottom;
+ }
+
+ break;
+ }
+
+ case 180:
+ {
+ t2 = (int)(pageViewRect.top - rcAnchor.top);
+ t1 = (int)(rcAnchor.bottom - pageViewRect.bottom);
+ if (rcAnchor.left < pageViewRect.left)
+ {
+ rtPopup.left += rcAnchor.left - pageViewRect.left;
+ }
+ break;
+ }
+ case 270:
+ {
+ t1 = (int)(rcAnchor.left - pageViewRect.left);
+ t2 = (int)(pageViewRect.right - rcAnchor.right);
+
+ if (rcAnchor.top > pageViewRect.top)
+ {
+ rtPopup.left -= rcAnchor.top - pageViewRect.top;
+ }
+ break;
+ }
+ case 0:
+ default:
+ {
+ t1 = (int)(pageViewRect.top - rcAnchor.top);
+ t2 = (int)(rcAnchor.bottom - pageViewRect.bottom);
+ if (rcAnchor.right > pageViewRect.right)
+ {
+ rtPopup.left -= rcAnchor.right - pageViewRect.right;
+ }
+ break;
+ }
+
+ }
+
+ if (t1 <= 0 && t2 <= 0)
+ {
+ return FALSE;
+ }
+ if (t1 <= 0)
+ {
+ t = t2;
+ dwPos = 1;
+ }
+ else if(t2 <= 0)
+ {
+ t = t1;
+ dwPos = 0;
+ }
+ else if (t1 > t2 )
+ {
+ t = t1;
+ dwPos = 0;
+ }
+ else
+ {
+ t = t2;
+ dwPos = 1;
+ }
+ if (t<fMinPopup)
+ {
+ fPoupHeight = fMinPopup;
+ }
+ else if (t > fMaxPopup)
+ {
+ fPoupHeight = fMaxPopup;
+ }
+ else
+ {
+ fPoupHeight = (FX_FLOAT)t;
+ }
+
+ switch(nRotate)
+ {
+
+ case 0:
+ case 180:
+ {
+ if (dwPos == 0)
+ {
+ rtPopup.top = rtAnchor.height;
+ rtPopup.height = fPoupHeight;
+ }
+ else
+ {
+ rtPopup.top = - fPoupHeight;
+ rtPopup.height = fPoupHeight;
+ }
+ break;
+ }
+ case 90:
+ case 270:
+ {
+ if (dwPos == 0)
+ {
+ rtPopup.top = rtAnchor.width;
+ rtPopup.height = fPoupHeight;
+ }
+ else
+ {
+ rtPopup.top = - fPoupHeight;
+ rtPopup.height = fPoupHeight;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
+FX_BOOL CPDFXFA_Document::PopupMenu(XFA_HWIDGET hWidget, CFX_PointF ptPopup, const CFX_RectF* pRectExclude)
+{
+ if (NULL == hWidget)
+ {
+ return FALSE;
+ }
+ IXFA_PageView* pXFAPageView = m_pXFADocView->GetWidgetHandler()->GetPageView(hWidget);
+ if (pXFAPageView == NULL)
+ return FALSE;
+ CPDFXFA_Page* pPage = GetPage(pXFAPageView);
+
+ if (pPage == NULL)
+ return FALSE;
+
+ int menuFlag = 0;
+
+ IXFA_MenuHandler* pXFAMenuHander = m_pApp->GetXFAApp()->GetMenuHandler();
+ if (pXFAMenuHander->CanUndo(hWidget))
+ menuFlag |= FXFA_MEMU_UNDO;
+ if (pXFAMenuHander->CanRedo(hWidget))
+ menuFlag |= FXFA_MEMU_REDO;
+ if (pXFAMenuHander->CanPaste(hWidget))
+ menuFlag |= FXFA_MEMU_PASTE;
+ if (pXFAMenuHander->CanCopy(hWidget))
+ menuFlag |= FXFA_MEMU_COPY;
+ if (pXFAMenuHander->CanCut(hWidget))
+ menuFlag |= FXFA_MEMU_CUT;
+ if (pXFAMenuHander->CanSelectAll(hWidget))
+ menuFlag |= FXFA_MEMU_SELECTALL;
+
+
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return FALSE;
+
+ return pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, NULL);
+}
+
+void CPDFXFA_Document::PageViewEvent(IXFA_PageView* pPageView, FX_DWORD dwFlags)
+{
+ if (m_iDocType != DOCTYPE_DYNIMIC_XFA)
+ return;
+
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return;
+
+ CPDFXFA_Page* pPage = GetPage(pPageView);
+ if (pPage == NULL)
+ return;
+
+ if (dwFlags == FXFA_PAGEVIEWEVENT_POSTADDED)
+ {
+ //pEnv->FFI_PageEvent(pPage, FXFA_PAGEVIEWEVENT_POSTADDED);
+ }
+ else if (dwFlags == FXFA_PAGEVIEWEVENT_POSTREMOVED)
+ {
+ //pEnv->FFI_PageEvent(pPage, FXFA_PAGEVIEWEVENT_POSTREMOVED);
+ //RemovePage(pPage);
+ //delete pPage;
+ }
+}
+
+void CPDFXFA_Document::WidgetEvent(XFA_HWIDGET hWidget, CXFA_WidgetAcc* pWidgetData, FX_DWORD dwEvent, FX_LPVOID pParam, FX_LPVOID pAdditional)
+{
+ if (m_iDocType != DOCTYPE_DYNIMIC_XFA || NULL == hWidget)
+ return;
+
+ int pageViewCount = m_pSDKDoc->GetPageViewCount();
+
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return;
+
+ if (NULL == hWidget) return;
+
+ IXFA_PageView* pPageView = m_pXFADocView->GetWidgetHandler()->GetPageView(hWidget);
+
+ if (pPageView == NULL)
+ return;
+ CPDFXFA_Page* pXFAPage = GetPage(pPageView);
+ if (pXFAPage == NULL)
+ return;
+
+ CPDFSDK_PageView* pSdkPageView = m_pSDKDoc->GetPageView(pXFAPage);
+
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+
+
+ if (dwEvent == XFA_WIDGETEVENT_PostAdded)
+ {
+// CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(hWidget, pSdkPageView);
+// pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
+
+ //pEnv->FFI_WidgetEvent(hWidget, XFA_WIDGETEVENT_PostAdded);
+// IXFA_PageView* pOldPageView = (IXFA_PageView*)pAdditional;
+// if (pOldPageView)
+// {
+// CPDFXFA_Page* pDestPage = m_pSDKDoc->GetPageView((IXFA_PageView*)pOldPageView);
+// ASSERT(pDestPage);
+// CPDFSDK_Annot* pAnnot = pDestPage->GetAnnotByXFAWidget(hWidget);
+// if (pAnnot)
+// {
+// if (m_pSDKDoc->GetFocusAnnot() == pAnnot)
+// {
+// m_pSDKDoc->SetFocusAnnot(NULL);
+// }
+// pDestPage->DeleteAnnot(pAnnot);
+// }
+// }
+ pSdkPageView->AddAnnot(hWidget);
+
+ }
+ else if (dwEvent == XFA_WIDGETEVENT_PreRemoved)
+ {
+ CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget);
+ if (pAnnot) {
+ pSdkPageView->DeleteAnnot(pAnnot);
+ //pEnv->FFI_WidgetEvent(hWidget, XFA_WIDGETEVENT_PreRemoved);
+ }
+ }
+}
+
+FX_INT32 CPDFXFA_Document::CountPages(XFA_HDOC hDoc)
+{
+ if (hDoc == m_pXFADoc && m_pSDKDoc)
+ {
+ return GetPageCount();
+ }
+ return 0;
+}
+FX_INT32 CPDFXFA_Document::GetCurrentPage(XFA_HDOC hDoc)
+{
+ if (hDoc != m_pXFADoc || !m_pSDKDoc)
+ return -1;
+ if (m_iDocType != DOCTYPE_DYNIMIC_XFA)
+ return -1;
+
+
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return -1;
+
+ return pEnv->FFI_GetCurrentPageIndex(this);
+}
+void CPDFXFA_Document::SetCurrentPage(XFA_HDOC hDoc, FX_INT32 iCurPage)
+{
+ if (hDoc != m_pXFADoc || !m_pSDKDoc)
+ return;
+ if (m_iDocType != DOCTYPE_DYNIMIC_XFA)
+ return;
+
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return;
+
+ pEnv->FFI_SetCurrentPage(this, iCurPage);
+}
+FX_BOOL CPDFXFA_Document::IsCalculationsEnabled(XFA_HDOC hDoc)
+{
+ if (hDoc != m_pXFADoc || !m_pSDKDoc)
+ return FALSE;
+ if (m_pSDKDoc->GetInterForm())
+ return m_pSDKDoc->GetInterForm()->IsXfaCalculateEnabled();
+
+ return FALSE;
+
+}
+void CPDFXFA_Document::SetCalculationsEnabled(XFA_HDOC hDoc, FX_BOOL bEnabled)
+{
+ if (hDoc != m_pXFADoc || !m_pSDKDoc)
+ return;
+ if (m_pSDKDoc->GetInterForm())
+ m_pSDKDoc->GetInterForm()->XfaEnableCalculate(bEnabled);
+}
+
+void CPDFXFA_Document::GetTitle(XFA_HDOC hDoc, CFX_WideString &wsTitle)
+{
+ if (hDoc != m_pXFADoc)
+ return;
+ if (m_pPDFDoc == NULL)
+ return;
+ CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo();
+
+ if (pInfoDict == NULL)
+ return;
+
+ CFX_ByteString csTitle = pInfoDict->GetString("Title");
+ wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength()));
+ csTitle.ReleaseBuffer(csTitle.GetLength());
+}
+void CPDFXFA_Document::SetTitle(XFA_HDOC hDoc, FX_WSTR wsTitle)
+{
+ if (hDoc != m_pXFADoc)
+ return;
+ if (m_pPDFDoc == NULL)
+ return;
+ CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo();
+
+ if (pInfoDict == NULL)
+ return;
+ pInfoDict->SetAt("Title", FX_NEW CPDF_String(wsTitle));
+}
+void CPDFXFA_Document::ExportData(XFA_HDOC hDoc, FX_WSTR wsFilePath, FX_BOOL bXDP)
+{
+ if (hDoc != m_pXFADoc)
+ return;
+ if (m_iDocType != DOCTYPE_DYNIMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA)
+ return;
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return;
+ int fileType = bXDP?FXFA_SAVEAS_XDP:FXFA_SAVEAS_XML;
+ CFX_ByteString bs = CFX_WideString(wsFilePath).UTF16LE_Encode();
+
+ if (wsFilePath.IsEmpty()) {
+ if (!pEnv->GetFormFillInfo() || pEnv->GetFormFillInfo()->m_pJsPlatform == NULL)
+ return;
+ CFX_WideString filepath = pEnv->JS_fieldBrowse();
+ bs = filepath.UTF16LE_Encode();
+ }
+ int len = bs.GetLength()/sizeof(unsigned short);
+ FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile(bXDP?FXFA_SAVEAS_XDP:FXFA_SAVEAS_XML, (FPDF_WIDESTRING)bs.GetBuffer(len*sizeof(unsigned short)), "wb");
+ bs.ReleaseBuffer(len*sizeof(unsigned short));
+
+ if (pFileHandler == NULL)
+ return;
+
+ CFPDF_FileStream fileWrite(pFileHandler);
+
+ IXFA_DocHandler *pXFADocHander = m_pApp->GetXFAApp()->GetDocHandler();
+ CFX_ByteString content;
+ if (fileType == FXFA_SAVEAS_XML)
+ {
+ content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
+ fileWrite.WriteBlock((FX_LPCSTR)content, fileWrite.GetSize(), content.GetLength());
+ CFX_WideStringC data(L"data");
+ if( pXFADocHander->SavePackage(m_pXFADocView->GetDoc(),data, &fileWrite))
+ {
+ NULL;
+ }
+ }
+ /*else if (fileType == FXFA_FILE_STATIC_XDP)
+ {
+ content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
+ fileWrite.WriteBlock((FX_LPCSTR)content, fileWrite.GetSize(), content.GetLength());
+ CFX_WideStringC data(L"data");
+ if( pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), data, &fileWrite))
+ {
+ NULL;
+ }
+ CFX_WideString wPath = pEnv->FFI_GetFilePath(pFileHandler);
+// CFX_WideString wPath;
+// wPath.FromUTF16LE(filePath);
+ CFX_ByteString bPath = wPath.UTF8Encode();
+ CFX_ByteString szFormat = "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>";
+ content.Format(szFormat,(char*)(FX_LPCSTR)bPath);
+ fileWrite.WriteBlock((FX_LPCSTR)content,fileWrite.GetSize(), content.GetLength());
+ }
+ */
+ else if (fileType == FXFA_SAVEAS_XDP)
+ {
+ if (m_pPDFDoc == NULL)
+ return;
+ CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
+ if (pRoot == NULL)
+ return;
+ CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm");
+ if (NULL == pAcroForm)
+ return;
+ CPDF_Object* pXFA = pAcroForm->GetElement("XFA");
+ if (pXFA == NULL)
+ return;
+ if (pXFA->GetType() != PDFOBJ_ARRAY)
+ return;
+ CPDF_Array* pArray = pXFA->GetArray();
+ if (NULL == pArray)
+ return;
+ int size = pArray->GetCount();
+ int iFormIndex = -1;
+ int iDataSetsIndex = -1;
+ for (int i=1; i<size;i+=2)
+ {
+ CPDF_Object* pPDFObj = pArray->GetElement(i);
+ CPDF_Object* pPrePDFObj = pArray->GetElement(i-1);
+ if(pPrePDFObj->GetType() != PDFOBJ_STRING)
+ continue;
+ if (pPDFObj->GetType() != PDFOBJ_REFERENCE)
+ continue;
+ CPDF_Object* pDirectObj = pPDFObj->GetDirect();
+ if(pDirectObj->GetType() != PDFOBJ_STREAM)
+ continue;
+ if (pPrePDFObj->GetString()=="form")
+ {
+ CFX_WideStringC form(L"form");
+ pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), form, &fileWrite);
+ }
+ else if (pPrePDFObj->GetString()=="datasets")
+ {
+ CFX_WideStringC datasets(L"datasets");
+ pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), datasets, &fileWrite);
+ }
+ else
+ {
+ if (i == size-1)
+ {
+ //CFX_WideString wPath = pEnv->FFI_GetFilePath(pFileHandler);
+ CFX_WideString wPath = CFX_WideString::FromUTF16LE((unsigned short*)(FX_LPCSTR)bs, bs.GetLength()/sizeof(unsigned short));
+ CFX_ByteString bPath = wPath.UTF8Encode();
+ CFX_ByteString szFormat = "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>";
+ content.Format(szFormat,(char*)(FX_LPCSTR)bPath);
+ fileWrite.WriteBlock((FX_LPCSTR)content,fileWrite.GetSize(), content.GetLength());
+ }
+
+ CPDF_Stream* pStream = (CPDF_Stream*)pDirectObj;
+ CPDF_StreamAcc* pAcc = FX_NEW CPDF_StreamAcc;
+ pAcc->LoadAllData(pStream);
+ fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), pAcc->GetSize());
+ delete pAcc;
+ }
+ }
+ }
+ FX_BOOL bError= fileWrite.Flush();
+}
+void CPDFXFA_Document::ImportData(XFA_HDOC hDoc, FX_WSTR wsFilePath)
+{
+ //TODO...
+}
+
+void CPDFXFA_Document::GotoURL(XFA_HDOC hDoc, FX_WSTR bsURL, FX_BOOL bAppend)
+{
+ if (hDoc != m_pXFADoc)
+ return;
+
+ if (m_iDocType != DOCTYPE_DYNIMIC_XFA)
+ return;
+
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return;
+
+ CFX_WideStringC str(bsURL.GetPtr());
+
+ pEnv->FFI_GotoURL(this, str, bAppend);
+
+}
+
+FX_BOOL CPDFXFA_Document::IsValidationsEnabled(XFA_HDOC hDoc)
+{
+ if (hDoc != m_pXFADoc || !m_pSDKDoc)
+ return FALSE;
+ if (m_pSDKDoc->GetInterForm())
+ return m_pSDKDoc->GetInterForm()->IsXfaValidationsEnabled();
+
+ return TRUE;
+}
+void CPDFXFA_Document::SetValidationsEnabled(XFA_HDOC hDoc, FX_BOOL bEnabled)
+{
+ if (hDoc != m_pXFADoc || !m_pSDKDoc)
+ return;
+ if (m_pSDKDoc->GetInterForm())
+ m_pSDKDoc->GetInterForm()->XfaSetValidationsEnabled(bEnabled);
+}
+void CPDFXFA_Document::SetFocusWidget(XFA_HDOC hDoc, XFA_HWIDGET hWidget)
+{
+ if (hDoc != m_pXFADoc)
+ return;
+
+ if (NULL == hWidget) {
+ m_pSDKDoc->SetFocusAnnot(NULL);
+ return;
+ }
+
+ int pageViewCount = m_pSDKDoc->GetPageViewCount();
+ for (int i = 0; i < pageViewCount; i++)
+ {
+ CPDFSDK_PageView* pPageView = m_pSDKDoc->GetPageView(i);
+ if (pPageView == NULL)
+ continue;
+ CPDFSDK_Annot* pAnnot = pPageView->GetAnnotByXFAWidget(hWidget);
+ if (pAnnot) {
+ m_pSDKDoc->SetFocusAnnot(pAnnot);
+ break;
+ }
+ }
+}
+void CPDFXFA_Document::Print(XFA_HDOC hDoc, FX_INT32 nStartPage, FX_INT32 nEndPage, FX_DWORD dwOptions)
+{
+ if (hDoc != m_pXFADoc)
+ return;
+
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return;
+
+ if (!pEnv->GetFormFillInfo() || pEnv->GetFormFillInfo()->m_pJsPlatform == NULL)
+ return;
+ if (pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print == NULL)
+ return;
+ pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print(pEnv->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,dwOptions&XFA_PRINTOPT_PrintAnnot);
+}
+
+void CPDFXFA_Document::GetURL(XFA_HDOC hDoc, CFX_WideString &wsDocURL)
+{
+ if (hDoc != m_pXFADoc)
+ return;
+
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return;
+
+ pEnv->FFI_GetURL(this, wsDocURL);
+}
+
+FX_ARGB CPDFXFA_Document::GetHighlightColor(XFA_HDOC hDoc)
+{
+ if (hDoc != m_pXFADoc)
+ return 0;
+ if (m_pSDKDoc)
+ {
+ if(CPDFSDK_InterForm* pInterForm = m_pSDKDoc->GetInterForm())
+ {
+ FX_COLORREF color = pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA);
+ FX_BYTE alpha = pInterForm->GetHighlightAlpha();
+ FX_ARGB argb = ArgbEncode((int)alpha, color);
+ return argb;
+ }
+ }
+ return 0;
+}
+
+void CPDFXFA_Document::AddDoRecord(XFA_HWIDGET hWidget)
+{
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return;
+ return;
+ //pEnv->FFI_AddDoRecord(this, hWidget);
+}
+
+FX_BOOL CPDFXFA_Document::_NotifySubmit(FX_BOOL bPrevOrPost)
+{
+ if (bPrevOrPost)
+ return _OnBeforeNotifySumbit();
+ else
+ _OnAfterNotifySumbit();
+ return TRUE;
+}
+
+FX_BOOL CPDFXFA_Document::_OnBeforeNotifySumbit()
+{
+ if (m_iDocType != DOCTYPE_DYNIMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA)
+ return TRUE;
+ if (m_pXFADocView == NULL)
+ return TRUE;
+ IXFA_WidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler();
+ if (pWidgetHandler == NULL)
+ return TRUE;
+ IXFA_WidgetAccIterator* pWidgetAccIterator = m_pXFADocView->CreateWidgetAccIterator();
+ if (pWidgetAccIterator)
+ {
+ CXFA_EventParam Param;
+ Param.m_eType = XFA_EVENT_PreSubmit;
+ CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
+ while (pWidgetAcc)
+ {
+ pWidgetHandler->ProcessEvent(pWidgetAcc, &Param);
+ pWidgetAcc = pWidgetAccIterator->MoveToNext();
+ }
+ pWidgetAccIterator->Release();
+ }
+ pWidgetAccIterator = m_pXFADocView->CreateWidgetAccIterator();
+ if (pWidgetAccIterator)
+ {
+ CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
+ pWidgetAcc = pWidgetAccIterator->MoveToNext();
+ while (pWidgetAcc)
+ {
+ int fRet = pWidgetAcc->ProcessValidate(-1);
+ if (fRet == XFA_EVENTERROR_Error)
+ {
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return FALSE;
+ CFX_WideString ws;
+ ws.FromLocal(IDS_XFA_Validate_Input);
+ CFX_ByteString bs = ws.UTF16LE_Encode();
+ int len = bs.GetLength()/sizeof(unsigned short);
+ pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len*sizeof(unsigned short)), (FPDF_WIDESTRING)L"", 0, 1);
+ bs.ReleaseBuffer(len*sizeof(unsigned short));
+ pWidgetAccIterator->Release();
+ return FALSE;
+ }
+ pWidgetAcc = pWidgetAccIterator->MoveToNext();
+ }
+ pWidgetAccIterator->Release();
+ m_pXFADocView->UpdateDocView();
+ }
+
+ return TRUE;
+
+}
+void CPDFXFA_Document::_OnAfterNotifySumbit()
+{
+ if (m_iDocType != DOCTYPE_DYNIMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA)
+ return;
+ if (m_pXFADocView == NULL)
+ return;
+ IXFA_WidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler();
+ if (pWidgetHandler == NULL)
+ return;
+ IXFA_WidgetAccIterator* pWidgetAccIterator = m_pXFADocView->CreateWidgetAccIterator();
+ if (pWidgetAccIterator == NULL)
+ return;
+ CXFA_EventParam Param;
+ Param.m_eType = XFA_EVENT_PostSubmit;
+
+ CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
+ while (pWidgetAcc)
+ {
+ pWidgetHandler->ProcessEvent(pWidgetAcc, &Param);
+ pWidgetAcc = pWidgetAccIterator->MoveToNext();
+ }
+ pWidgetAccIterator->Release();
+ m_pXFADocView->UpdateDocView();
+}
+
+FX_BOOL CPDFXFA_Document::SubmitData(XFA_HDOC hDoc, CXFA_Submit submit)
+{
+ if (!_NotifySubmit(TRUE))
+ return FALSE;
+ if (NULL == m_pXFADocView)
+ return FALSE;
+ m_pXFADocView->UpdateDocView();
+
+ FX_BOOL ret = _SubmitData(hDoc, submit);
+ _NotifySubmit(FALSE);
+ return ret;
+}
+
+IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(XFA_HDOC hDoc, const CFX_WideString& wsLink)
+{
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return FALSE;
+ CFX_ByteString bs = wsLink.UTF16LE_Encode();
+ int len = bs.GetLength()/sizeof(unsigned short);
+ FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len*sizeof(unsigned short)), "rb");
+ bs.ReleaseBuffer(len*sizeof(unsigned short));
+
+ if (pFileHandler == NULL)
+ return NULL;
+ CFPDF_FileStream* pFileRead = FX_NEW CFPDF_FileStream(pFileHandler);
+ return pFileRead;
+}
+FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, int fileType, FPDF_DWORD encodeType, FPDF_DWORD flag)
+{
+ if (NULL == m_pXFADocView)
+ return FALSE;
+ IXFA_DocHandler* pDocHandler = m_pApp->GetXFAApp()->GetDocHandler();
+ CFX_ByteString content;
+
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return FALSE;
+
+ CFPDF_FileStream fileStream(pFileHandler);
+
+ if (fileType == FXFA_SAVEAS_XML)
+ {
+ CFX_WideString ws;
+ ws.FromLocal("data");
+ CFX_ByteString content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
+ fileStream.WriteBlock((FX_LPCSTR)content,0,content.GetLength());
+ pDocHandler->SavePackage(m_pXFADoc, ws, &fileStream);
+ }
+ else if (fileType == FXFA_SAVEAS_XDP)
+ {
+ if (flag == 0)
+ flag = FXFA_CONFIG|FXFA_TEMPLATE|FXFA_LOCALESET|FXFA_DATASETS|FXFA_XMPMETA|FXFA_XFDF|FXFA_FORM;
+ if (m_pPDFDoc == NULL)
+ {
+ fileStream.Flush();
+ return FALSE;
+ }
+ CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
+ if (pRoot == NULL)
+ {
+ fileStream.Flush();
+ return FALSE;
+ }
+ CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm");
+ if (NULL == pAcroForm)
+ {
+ fileStream.Flush();
+ return FALSE;
+ }
+ CPDF_Object* pXFA = pAcroForm->GetElement("XFA");
+ if (pXFA == NULL)
+ {
+ fileStream.Flush();
+ return FALSE;
+ }
+ if (pXFA->GetType() != PDFOBJ_ARRAY)
+ {
+ fileStream.Flush();
+ return FALSE;
+ }
+ CPDF_Array* pArray = pXFA->GetArray();
+ if (NULL == pArray)
+ {
+ fileStream.Flush();
+ return FALSE;
+ }
+ int size = pArray->GetCount();
+ int iFormIndex = -1;
+ int iDataSetsIndex = -1;
+ for (int i=1; i<size;i+=2)
+ {
+ CPDF_Object* pPDFObj = pArray->GetElement(i);
+ CPDF_Object* pPrePDFObj = pArray->GetElement(i-1);
+ if(pPrePDFObj->GetType() != PDFOBJ_STRING)
+ continue;
+ if (pPDFObj->GetType() != PDFOBJ_REFERENCE)
+ continue;
+ CPDF_Object* pDirectObj = pPDFObj->GetDirect();
+ if (pDirectObj->GetType() != PDFOBJ_STREAM)
+ continue;
+ if (pPrePDFObj->GetString()=="config" && !(flag & FXFA_CONFIG))
+ continue;
+ if (pPrePDFObj->GetString()=="template" && !(flag & FXFA_TEMPLATE))
+ continue;
+ if (pPrePDFObj->GetString()=="localeSet" && !(flag & FXFA_LOCALESET))
+ continue;
+ if (pPrePDFObj->GetString()=="datasets" && !(flag & FXFA_DATASETS))
+ continue;
+ if (pPrePDFObj->GetString()=="xmpmeta" && !(flag & FXFA_XMPMETA))
+ continue;
+ if (pPrePDFObj->GetString()=="xfdf" && !(flag & FXFA_XFDF))
+ continue;
+ if (pPrePDFObj->GetString()=="form" && !(flag & FXFA_FORM))
+ continue;
+ if (pPrePDFObj->GetString()=="form")
+ {
+ CFX_WideString ws;
+ ws.FromLocal("form");
+ pDocHandler->SavePackage(m_pXFADoc, ws, &fileStream);
+ }
+ else if (pPrePDFObj->GetString()=="datasets")
+ {
+ CFX_WideString ws;
+ ws.FromLocal("datasets");
+ pDocHandler->SavePackage(m_pXFADoc, ws, &fileStream);
+ }
+ else
+ {
+ //PDF,creator.
+ //TODO:
+ }
+ }
+ }
+ return TRUE;
+}
+
+void CPDFXFA_Document::_ClearChangeMark()
+{
+ if (m_pSDKDoc)
+ m_pSDKDoc->ClearChangeMark();
+}
+
+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)
+ flag |= FXFA_TEMPLATE;
+ if (csSrcContent.Find(L" localeSet ", 0) != -1)
+ flag |= FXFA_LOCALESET;
+ if (csSrcContent.Find(L" datasets ", 0) != -1)
+ flag |= FXFA_DATASETS;
+ if (csSrcContent.Find(L" xmpmeta ", 0) != -1)
+ flag |= FXFA_XMPMETA;
+ if (csSrcContent.Find(L" xfdf ", 0) != -1)
+ flag |= FXFA_XFDF;
+ if (csSrcContent.Find(L" form ", 0) != -1)
+ flag |= FXFA_FORM;
+ if (flag == 0)
+ 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)
+{
+ CFX_WideString srcURL = csURL;
+ srcURL.TrimLeft();
+ if (0 != srcURL.Left(7).CompareNoCase(L"mailto:"))
+ return FALSE;
+ int pos = srcURL.Find(L'?',0);
+ CFX_WideString tmp;
+ if (pos == -1) {
+ pos = srcURL.Find(L'@',0);
+ if (pos == -1)
+ return FALSE;
+ else
+ {
+ tmp = srcURL.Right(csURL.GetLength()-7);
+ tmp.TrimLeft();
+ tmp.TrimRight();
+ }
+ } else {
+ tmp = srcURL.Left(pos);
+ tmp = tmp.Right(tmp.GetLength()-7);
+ tmp.TrimLeft();
+ tmp.TrimRight();
+ }
+
+ csToAddress = tmp;
+
+ srcURL = srcURL.Right(srcURL.GetLength()-(pos+1));
+ while ( !srcURL.IsEmpty() )
+ {
+ srcURL.TrimLeft();
+ srcURL.TrimRight();
+ pos = srcURL.Find(L'&',0);
+ if (pos == -1)
+ tmp = srcURL;
+ else
+ tmp = srcURL.Left(pos);
+
+ tmp.TrimLeft();
+ tmp.TrimRight();
+ if (tmp.GetLength() >= 3 && 0 == tmp.Left(3).CompareNoCase(L"cc=") )
+ {
+ tmp = tmp.Right(tmp.GetLength()-3);
+ if (!csCCAddress.IsEmpty())
+ csCCAddress += L';';
+ csCCAddress += tmp;
+
+ }
+ else if (tmp.GetLength() >= 4 && 0 == tmp.Left(4).CompareNoCase(L"bcc="))
+ {
+ tmp = tmp.Right(tmp.GetLength() - 4);
+ if (!csBCCAddress.IsEmpty())
+ csBCCAddress += L';';
+ csBCCAddress += tmp;
+ }
+ else if (tmp.GetLength() >= 8 && 0 ==tmp.Left(8).CompareNoCase(L"subject=") )
+ {
+ tmp=tmp.Right(tmp.GetLength()-8);
+ csSubject += tmp;
+ }
+ else if(tmp.GetLength() >= 5 && 0 ==tmp.Left(5).CompareNoCase(L"body=") )
+ {
+ tmp=tmp.Right(tmp.GetLength() - 5);
+ csMsg += tmp;
+ }
+ if (pos == -1)
+ srcURL = L"";
+ else
+ srcURL = srcURL.Right(csURL.GetLength()-(pos+1));
+ }
+ csToAddress.Replace((FX_LPCWSTR)L",", (FX_LPCWSTR)L";");
+ csCCAddress.Replace((FX_LPCWSTR)L",", (FX_LPCWSTR)L";");
+ csBCCAddress.Replace((FX_LPCWSTR)L",", (FX_LPCWSTR)L";");
+ return TRUE;
+}
+
+FX_BOOL CPDFXFA_Document::_SubmitData(XFA_HDOC hDoc, CXFA_Submit submit)
+{
+ CFX_WideStringC csURLC;
+ submit.GetSubmitTarget(csURLC);
+ CFX_WideString csURL = csURLC;
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ if (pEnv == NULL)
+ return FALSE;
+ if (csURL.IsEmpty()){
+ CFX_WideString ws;
+ ws.FromLocal("Submit cancelled.");
+ CFX_ByteString bs = ws.UTF16LE_Encode();
+ int len = bs.GetLength()/sizeof(unsigned short);
+ pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len*sizeof(unsigned short)), (FPDF_WIDESTRING)L"", 0, 4);
+ bs.ReleaseBuffer(len*sizeof(unsigned short));
+ return FALSE;
+ }
+
+ FPDF_BOOL bRet = TRUE;
+ FPDF_FILEHANDLER* pFileHandler = NULL;
+ int fileFlag = -1;
+
+ if (submit.GetSubmitFormat() == XFA_ATTRIBUTEENUM_Xdp)
+ {
+ CFX_WideStringC csContentC;
+ submit.GetSubmitXDPContent(csContentC);
+ CFX_WideString csContent;
+ csContent = csContentC.GetPtr();
+ csContent.TrimLeft();
+ csContent.TrimRight();
+ CFX_WideString space;
+ space.FromLocal(" ");
+ csContent = space + csContent + space;
+ FPDF_DWORD flag = 0;
+ if (submit.IsSubmitEmbedPDF())
+ flag |= FXFA_PDF;
+ _ToXFAContentFlags(csContent, flag);
+ pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XDP, NULL, "wb");
+ fileFlag = FXFA_SAVEAS_XDP;
+ _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag);
+ }
+ else if (submit.GetSubmitFormat() == XFA_ATTRIBUTEENUM_Xml )
+ {
+ pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, NULL, "wb");
+ fileFlag = FXFA_SAVEAS_XML;
+ _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0);
+ }
+ else if (submit.GetSubmitFormat() == XFA_ATTRIBUTEENUM_Pdf )
+ {
+ //csfilename = csDocName;
+ }
+ else if (submit.GetSubmitFormat() == XFA_ATTRIBUTEENUM_Formdata )
+ {
+ return FALSE;
+ }
+ else if (submit.GetSubmitFormat() == XFA_ATTRIBUTEENUM_Urlencoded )
+ {
+ pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, NULL, "wb");
+ fileFlag = FXFA_SAVEAS_XML;
+ _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0);
+ }
+ else if (submit.GetSubmitFormat() == XFA_ATTRIBUTEENUM_Xfd )
+ {
+ return FALSE;
+ }
+ else
+ {
+ return FALSE;
+ }
+ if (pFileHandler == NULL)
+ return FALSE;
+ if (0 == csURL.Left(7).CompareNoCase(L"mailto:"))
+ {
+ CFX_WideString csToAddress;
+ CFX_WideString csCCAddress;
+ CFX_WideString csBCCAddress;
+ CFX_WideString csSubject;
+ CFX_WideString csMsg;
+
+ bRet = _MailToInfo(csURL, csToAddress, csCCAddress, csBCCAddress, csSubject, csMsg);
+ if (FALSE == bRet)
+ return FALSE;
+
+ CFX_ByteString bsTo = CFX_WideString(csToAddress).UTF16LE_Encode();
+ CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode();
+ CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode();
+ CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode();
+ CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode();
+
+ FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength());
+ FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength());
+ FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength());
+ FPDF_WIDESTRING pSubject = (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength());
+ FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength());
+
+ pEnv->FFI_EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg);
+ bsTo.ReleaseBuffer();
+ bsCC.ReleaseBuffer();
+ bsBcc.ReleaseBuffer();
+ bsSubject.ReleaseBuffer();
+ bsMsg.ReleaseBuffer();
+ }
+ else
+ {
+ //http¡¢ftp
+ CFX_WideString ws;
+ CFX_ByteString bs = csURL.UTF16LE_Encode();
+ int len = bs.GetLength()/sizeof(unsigned short);
+ pEnv->FFI_UploadTo(pFileHandler, fileFlag, (FPDF_WIDESTRING)bs.GetBuffer(len*sizeof(unsigned short)));
+ bs.ReleaseBuffer(len*sizeof(unsigned short));
+ }
+
+ return bRet;
+}
+
+FX_BOOL CPDFXFA_Document::SetGlobalProperty(XFA_HDOC hDoc, FX_BSTR szPropName, FXJSE_HVALUE hValue)
+{
+ if (hDoc != m_pXFADoc)
+ return FALSE;
+
+ if (m_pSDKDoc && m_pSDKDoc->GetEnv()->GetJSRuntime())
+ return m_pSDKDoc->GetEnv()->GetJSRuntime()->SetHValueByName(szPropName, hValue);
+ return FALSE;
+}
+FX_BOOL CPDFXFA_Document::GetPDFScriptObject(XFA_HDOC hDoc, FX_BSTR utf8Name, FXJSE_HVALUE hValue)
+{
+ if (hDoc != m_pXFADoc)
+ return FALSE;
+
+ if (!m_pSDKDoc || !m_pSDKDoc->GetEnv()->GetJSRuntime())
+ return FALSE;
+
+ if (!m_pJSContext)
+ {
+ m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc);
+ m_pJSContext =m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext();
+ }
+
+ return _GetHValueByName(utf8Name, hValue, m_pSDKDoc->GetEnv()->GetJSRuntime());
+
+}
+FX_BOOL CPDFXFA_Document::GetGlobalProperty(XFA_HDOC hDoc, FX_BSTR szPropName, FXJSE_HVALUE hValue)
+{
+ if (hDoc != m_pXFADoc)
+ return FALSE;
+ if (!m_pSDKDoc || !m_pSDKDoc->GetEnv()->GetJSRuntime())
+ return FALSE;
+
+ if (!m_pJSContext)
+ {
+ m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc);
+ m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext();
+ }
+
+ return _GetHValueByName(szPropName, hValue, m_pSDKDoc->GetEnv()->GetJSRuntime());
+
+}
+FX_BOOL CPDFXFA_Document::_GetHValueByName(FX_BSTR utf8Name, FXJSE_HVALUE hValue, IFXJS_Runtime* runTime)
+{
+ return runTime->GetHValueByName(utf8Name, hValue);
+}
+
diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_page.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_page.cpp
new file mode 100644
index 0000000000..cf05d4ced7
--- /dev/null
+++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_page.cpp
@@ -0,0 +1,276 @@
+// 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
+
+#include "../../include/fsdk_define.h"
+#include "../../include/fsdk_mgr.h"
+#include "../../include/fpdfxfa/fpdfxfa_util.h"
+#include "../../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../../include/fpdfxfa/fpdfxfa_page.h"
+
+CPDFXFA_Page::CPDFXFA_Page(CPDFXFA_Document* pDoc, int page_index) :
+ m_pPDFPage(NULL),
+ m_pXFAPageView(NULL),
+ m_iPageIndex(page_index),
+ m_pDocument(pDoc),
+ m_iRef(1)
+{
+
+}
+
+CPDFXFA_Page::~CPDFXFA_Page()
+{
+ if (m_pPDFPage)
+ delete m_pPDFPage;
+ m_pPDFPage = NULL;
+ m_pXFAPageView = NULL;
+}
+
+void CPDFXFA_Page::Release()
+{
+ m_iRef--;
+ if (m_iRef > 0)
+ return;
+
+ if (m_pDocument)
+ m_pDocument->RemovePage(this);
+
+ delete this;
+}
+
+FX_BOOL CPDFXFA_Page::LoadPDFPage()
+{
+ if (!m_pDocument) return FALSE;
+ CPDF_Document* pPDFDoc = m_pDocument->GetPDFDoc();
+ if (pPDFDoc)
+ {
+ CPDF_Dictionary* pDict = pPDFDoc->GetPage(m_iPageIndex);
+ if (pDict == NULL) return FALSE;
+ if (m_pPDFPage) {
+ if (m_pPDFPage->m_pFormDict == pDict)
+ return TRUE;
+
+ delete m_pPDFPage;
+ m_pPDFPage = NULL;
+ }
+
+ m_pPDFPage = FX_NEW CPDF_Page;
+ m_pPDFPage->Load(pPDFDoc, pDict);
+ m_pPDFPage->ParseContent();
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+FX_BOOL CPDFXFA_Page::LoadXFAPageView()
+{
+ if (!m_pDocument)
+ return FALSE;
+ XFA_HDOC pXFADoc = m_pDocument->GetXFADoc();
+ if (pXFADoc)
+ {
+ IXFA_DocView* pXFADocView = m_pDocument->GetXFADocView();
+ if (!pXFADocView)
+ return FALSE;
+
+ IXFA_PageView* pPageView = pXFADocView->GetPageView(m_iPageIndex);
+ if (!pPageView)
+ return FALSE;
+
+ if (m_pXFAPageView)
+ if (m_pXFAPageView == pPageView)
+ return TRUE;
+
+ m_pXFAPageView = pPageView;
+ int iStatus = m_pXFAPageView->LoadPageView(NULL);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+FX_BOOL CPDFXFA_Page::LoadPage()
+{
+ if (!m_pDocument || m_iPageIndex < 0)
+ return FALSE;
+
+ int iDocType = m_pDocument->GetDocType();
+ CPDF_Document* pPDFDoc = m_pDocument->GetPDFDoc();
+ XFA_HDOC pXFADoc = m_pDocument->GetXFADoc();
+
+ switch (iDocType)
+ {
+ case DOCTYPE_PDF:
+ case DOCTYPE_STATIC_XFA:
+ {
+ return LoadPDFPage();
+ }
+ case DOCTYPE_DYNIMIC_XFA:
+ {
+ return LoadXFAPageView();
+ }
+ default:
+ return FALSE;
+ }
+
+ return FALSE;
+}
+
+FX_BOOL CPDFXFA_Page::LoadPDFPage(CPDF_Dictionary* pageDict)
+{
+ if (!m_pDocument || m_iPageIndex < 0 || !pageDict)
+ return FALSE;
+
+ if (m_pPDFPage)
+ delete m_pPDFPage;
+
+ m_pPDFPage = FX_NEW CPDF_Page();
+ m_pPDFPage->Load(m_pDocument->GetPDFDoc(), pageDict);
+ m_pPDFPage->ParseContent();
+
+ return TRUE;
+}
+
+FX_FLOAT CPDFXFA_Page::GetPageWidth()
+{
+ ASSERT(m_pDocument != NULL);
+
+ if (!m_pPDFPage && !m_pXFAPageView)
+ return 0.0f;
+
+ int nDocType = m_pDocument->GetDocType();
+ switch (nDocType)
+ {
+ case DOCTYPE_DYNIMIC_XFA:
+ {
+ if (m_pXFAPageView)
+ {
+ CFX_RectF rect;
+ m_pXFAPageView->GetPageViewRect(rect);
+ return rect.width;
+ }
+ }
+ break;
+ case DOCTYPE_STATIC_XFA:
+ case DOCTYPE_PDF:
+ {
+ if (m_pPDFPage)
+ return m_pPDFPage->GetPageWidth();
+ }
+ break;
+ default:
+ return 0.0f;
+ }
+
+ return 0.0f;
+}
+
+FX_FLOAT CPDFXFA_Page::GetPageHeight()
+{
+ ASSERT(m_pDocument != NULL);
+
+ if (!m_pPDFPage && !m_pXFAPageView)
+ return 0.0f;
+
+ int nDocType = m_pDocument->GetDocType();
+ switch (nDocType)
+ {
+ case DOCTYPE_PDF:
+ case DOCTYPE_STATIC_XFA:
+ {
+ if (m_pPDFPage)
+ return m_pPDFPage->GetPageHeight();
+ }
+ break;
+ case DOCTYPE_DYNIMIC_XFA:
+ {
+ if (m_pXFAPageView)
+ {
+ CFX_RectF rect;
+ m_pXFAPageView->GetPageViewRect(rect);
+ return rect.height;
+ }
+ }
+ break;
+ default:
+ return 0.0f;
+ }
+
+ return 0.0f;
+}
+
+void CPDFXFA_Page::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)
+{
+ ASSERT(m_pDocument != NULL);
+
+ if (!m_pPDFPage && !m_pXFAPageView)
+ return;
+
+ CPDF_Matrix page2device;
+ CPDF_Matrix device2page;
+ FX_FLOAT page_x_f, page_y_f;
+
+ GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, rotate);
+
+ device2page.SetReverse(page2device);
+ device2page.Transform((FX_FLOAT)(device_x), (FX_FLOAT)(device_y), page_x_f, page_y_f);
+
+ *page_x = (page_x_f);
+ *page_y = (page_y_f);
+}
+
+void CPDFXFA_Page::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)
+{
+ if (!m_pPDFPage && !m_pXFAPageView)
+ return;
+
+ CPDF_Matrix page2device;
+ FX_FLOAT device_x_f, device_y_f;
+
+ GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, rotate);
+
+ page2device.Transform(((FX_FLOAT)page_x), ((FX_FLOAT)page_y), device_x_f, device_y_f);
+
+ *device_x = FXSYS_round(device_x_f);
+ *device_y = FXSYS_round(device_y_f);
+}
+
+void CPDFXFA_Page::GetDisplayMatrix(CFX_AffineMatrix& matrix, int xPos, int yPos,
+ int xSize, int ySize, int iRotate) const
+{
+ ASSERT(m_pDocument != NULL);
+
+ if (!m_pPDFPage && !m_pXFAPageView)
+ return;
+
+ int nDocType = m_pDocument->GetDocType();
+ switch (nDocType)
+ {
+ case DOCTYPE_DYNIMIC_XFA:
+ {
+ if (m_pXFAPageView)
+ {
+ CFX_Rect rect;
+ rect.Set(xPos, yPos, xSize, ySize);
+ m_pXFAPageView->GetDisplayMatrix(matrix, rect, iRotate);
+ }
+ }
+ break;
+ case DOCTYPE_PDF:
+ case DOCTYPE_STATIC_XFA:
+ {
+ if (m_pPDFPage)
+ {
+ m_pPDFPage->GetDisplayMatrix(matrix, xPos, yPos, xSize, ySize, iRotate);
+ }
+ }
+ break;
+ default:
+ return;
+ }
+
+}
diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
new file mode 100644
index 0000000000..9bf1b63c8f
--- /dev/null
+++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
@@ -0,0 +1,96 @@
+// 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
+
+#include "../../include/fsdk_define.h"
+#include "../../include/fsdk_mgr.h"
+#include "../../include/fpdfxfa/fpdfxfa_util.h"
+
+FX_BOOL FPDF_HasXFAField(CPDF_Document* pPDFDoc, int& docType)
+{
+ if (!pPDFDoc)
+ return FALSE;
+
+ CPDF_Dictionary* pRoot = pPDFDoc->GetRoot();
+ if (!pRoot)
+ return FALSE;
+
+ CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm");
+ if (!pAcroForm)
+ return FALSE;
+
+ CPDF_Object* pXFA = pAcroForm->GetElement("XFA");
+ if (!pXFA)
+ return FALSE;
+
+ FX_BOOL bDymasticXFA = FALSE;
+ bDymasticXFA = pRoot->GetBoolean("NeedsRendering", FALSE);
+
+ if(bDymasticXFA)
+ docType = DOCTYPE_DYNIMIC_XFA;
+ else
+ docType = DOCTYPE_STATIC_XFA;
+
+ return TRUE;
+}
+
+CFX_PtrArray CXFA_FWLAdapterTimerMgr::ms_timerArray;
+
+FWL_ERR CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer *pTimer, FX_DWORD dwElapse, FWL_HTIMER &hTimer, FX_BOOL bImmediately /* = TRUE */)
+{
+ if (m_pEnv)
+ {
+ FX_UINT32 uIDEvent = m_pEnv->FFI_SetTimer(dwElapse, TimerProc);
+ CFWL_TimerInfo *pInfo = FX_NEW CFWL_TimerInfo;
+ pInfo->uIDEvent = uIDEvent;
+ pInfo->pTimer = pTimer;
+ ms_timerArray.Add(pInfo);
+
+ hTimer = (FWL_HTIMER)pInfo;
+ return FWL_ERR_Succeeded;
+ }
+
+ return FWL_ERR_Indefinite;
+}
+
+FWL_ERR CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer)
+{
+ if (!hTimer) return FWL_ERR_Indefinite;
+
+ if (m_pEnv)
+ {
+ CFWL_TimerInfo *pInfo = (CFWL_TimerInfo*)hTimer;
+
+ m_pEnv->FFI_KillTimer(pInfo->uIDEvent);
+
+ FX_INT32 index = ms_timerArray.Find(pInfo);
+ if (index >= 0)
+ {
+ ms_timerArray.RemoveAt(index);
+ delete pInfo;
+ }
+ return FWL_ERR_Succeeded;
+ }
+
+ return FWL_ERR_Indefinite;
+}
+
+void CXFA_FWLAdapterTimerMgr::TimerProc(FX_INT32 idEvent)
+{
+ CFWL_TimerInfo *pInfo = NULL;
+ FX_INT32 iCount = CXFA_FWLAdapterTimerMgr::ms_timerArray.GetSize();
+ for (FX_INT32 i = 0; i < iCount; i++)
+ {
+ CFWL_TimerInfo *pTemp = (CFWL_TimerInfo*)CXFA_FWLAdapterTimerMgr::ms_timerArray.GetAt(i);
+ if (pTemp->uIDEvent == idEvent)
+ {
+ pInfo = pTemp; break;
+ }
+ }
+ if (pInfo)
+ {
+ pInfo->pTimer->Run((FWL_HTIMER)pInfo);
+ }
+}
diff --git a/fpdfsdk/src/fsdk_actionhandler.cpp b/fpdfsdk/src/fsdk_actionhandler.cpp
index 518abd21f0..494b5298d3 100644
--- a/fpdfsdk/src/fsdk_actionhandler.cpp
+++ b/fpdfsdk/src/fsdk_actionhandler.cpp
@@ -5,6 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../include/fsdk_define.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
#include "../include/fsdk_mgr.h"
#include "../include/fsdk_actionhandler.h"
#include "../include/javascript/IJavaScript.h"
@@ -566,7 +567,7 @@ void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument, /*CReader
// ASSERT(pDocView != NULL);
ASSERT(action != NULL);
- CPDF_Document* pPDFDocument = pDocument->GetDocument();
+ CPDF_Document* pPDFDocument = pDocument->GetDocument()->GetPDFDoc();
ASSERT(pPDFDocument != NULL);
CPDFDoc_Environment* pApp = pDocument->GetEnv();
ASSERT(pApp != NULL);
@@ -610,7 +611,7 @@ void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument, const CPDF
CPDFDoc_Environment* pApp = pDocument->GetEnv();
ASSERT(pApp != NULL);
- CFX_ByteString sURI = action.GetURI(pDocument->GetDocument());
+ CFX_ByteString sURI = action.GetURI(pDocument->GetDocument()->GetPDFDoc());
pApp->FFI_DoURIAction(FX_LPCSTR(sURI));
}
diff --git a/fpdfsdk/src/fsdk_annothandler.cpp b/fpdfsdk/src/fsdk_annothandler.cpp
index 9f208d34e2..fff038b809 100644
--- a/fpdfsdk/src/fsdk_annothandler.cpp
+++ b/fpdfsdk/src/fsdk_annothandler.cpp
@@ -5,6 +5,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../include/fsdk_define.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../include/fpdfxfa/fpdfxfa_util.h"
#include "../include/fsdk_mgr.h"
#include "../include/formfiller/FFL_FormFiller.h"
#include "../include/fsdk_annothandler.h"
@@ -17,6 +19,9 @@ CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp)
CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp);
pHandler->SetFormFiller(m_pApp->GetIFormFiller());
RegisterAnnotHandler(pHandler);
+
+ CPDFSDK_XFAAnnotHandler* pXFAAnnotHandler = new CPDFSDK_XFAAnnotHandler(m_pApp);
+ RegisterAnnotHandler(pXFAAnnotHandler);
}
CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr()
@@ -66,7 +71,20 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot * pAnnot, CPDFSDK_Pa
return pAnnotHandler->NewAnnot(pAnnot, pPageView);
}
- return new CPDFSDK_Annot(pAnnot, pPageView);
+ return new CPDFSDK_BAAnnot(pAnnot, pPageView);
+}
+
+CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(XFA_HWIDGET pAnnot, CPDFSDK_PageView* pPageView)
+{
+ ASSERT(pAnnot != NULL);
+ ASSERT(pPageView != NULL);
+
+ if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME))
+ {
+ return pAnnotHandler->NewAnnot(pAnnot, pPageView);
+ }
+
+ return NULL;
}
void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot)
@@ -119,9 +137,11 @@ IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(CPDFSDK_Annot* pA
ASSERT(pAnnot != NULL);
CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
- ASSERT(pPDFAnnot != NULL);
-
- return GetAnnotHandler(pPDFAnnot->GetSubType());
+ if (pPDFAnnot)
+ return GetAnnotHandler(pPDFAnnot->GetSubType());
+ else if (pAnnot->GetXFAWidget())
+ return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME);
+ return NULL;
}
IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(const CFX_ByteString& sType) const
@@ -141,7 +161,8 @@ void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, CPDFSDK_
}
else
{
- pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ if (!pAnnot->IsXFAField())
+ ((CPDFSDK_BAAnnot*)pAnnot)->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
}
}
@@ -323,6 +344,20 @@ FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_D
return FALSE;
}
+FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus(CPDFSDK_Annot* pSetAnnot,CPDFSDK_Annot* pKillAnnot)
+{
+ FX_BOOL bXFA = (pSetAnnot && pSetAnnot->GetXFAWidget()) ||
+ (pKillAnnot && pKillAnnot->GetXFAWidget());
+
+ if (bXFA)
+ {
+ if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME))
+ return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot);
+ }
+
+ return TRUE;
+}
+
CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot)
{
ASSERT(pAnnot);
@@ -346,13 +381,30 @@ FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView *pPageView, CP
CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,FX_BOOL bNext)
{
- CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", "");
-
- CPDFSDK_Annot* pNext = bNext ?
- ai.GetNextAnnot(pSDKAnnot) :
+ CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView();
+ CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage();
+ if (pPage == NULL)
+ return NULL;
+ if (pPage->GetPDFPage()) { // for pdf annots.
+ CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), pSDKAnnot->GetType(), "");
+ CPDFSDK_Annot* pNext = bNext ?
+ ai.GetNextAnnot(pSDKAnnot) :
ai.GetPrevAnnot(pSDKAnnot);
-
return pNext;
+ }
+ // for xfa annots
+ IXFA_WidgetIterator* pWidgetIterator = pPage->GetXFAPageView()->CreateWidgetIterator(XFA_TRAVERSEWAY_Tranvalse, XFA_WIDGETFILTER_Visible | XFA_WIDGETFILTER_Viewable | XFA_WIDGETFILTER_Field);
+ if (pWidgetIterator == NULL)
+ return NULL;
+ if (pWidgetIterator->GetCurrentWidget() != pSDKAnnot->GetXFAWidget())
+ pWidgetIterator->SetCurrentWidget(pSDKAnnot->GetXFAWidget());
+ XFA_HWIDGET hNextFocus = NULL;
+ hNextFocus = bNext?pWidgetIterator->MoveToNext():pWidgetIterator->MoveToPrevious();
+ if (hNextFocus == NULL && pSDKAnnot != NULL)
+ hNextFocus = pWidgetIterator->MoveToFirst();
+
+ pWidgetIterator->Release();
+ return pPageView->GetAnnotByXFAWidget(hNextFocus);
}
FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot)
@@ -414,6 +466,11 @@ CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_Pag
return pWidget;
}
+CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(XFA_HWIDGET hWidget, CPDFSDK_PageView* pPage)
+{
+ return NULL;
+}
+
void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot)
{
ASSERT(pAnnot != NULL);
@@ -440,7 +497,7 @@ void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
if (sSubType == BFFT_SIGNATURE)
{
- pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ ((CPDFSDK_BAAnnot*)pAnnot)->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
}
else
{
@@ -660,6 +717,15 @@ void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot)
{
ASSERT(pAnnot != NULL);
+ CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
+ ASSERT(pPageView != NULL);
+
+ CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
+ ASSERT(pSDKDoc != NULL);
+
+ CPDFXFA_Document* pDoc = pSDKDoc->GetDocument();
+ ASSERT(pDoc != NULL);
+
CFX_ByteString sSubType = pAnnot->GetSubType();
if (sSubType == BFFT_SIGNATURE)
@@ -685,6 +751,12 @@ void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot)
}
}
+ if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA)
+ {
+ if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty())
+ pWidget->ResetAppearance(FALSE);
+ }
+
if (m_pFormFiller)
m_pFormFiller->OnLoad(pAnnot);
@@ -752,6 +824,406 @@ FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Ann
return rect.Contains(point.x, point.y);
}
+//CPDFSDK_XFAAnnotHandler
+
+#define FWL_WGTHITTEST_Unknown 0
+#define FWL_WGTHITTEST_Client 1 //arrow
+#define FWL_WGTHITTEST_Titlebar 11 //caption
+#define FWL_WGTHITTEST_HScrollBar 15
+#define FWL_WGTHITTEST_VScrollBar 16
+#define FWL_WGTHITTEST_Border 17
+#define FWL_WGTHITTEST_Edit 19
+#define FWL_WGTHITTEST_HyperLink 20
+
+CPDFSDK_XFAAnnotHandler::CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp) :
+ m_pApp(pApp)
+{
+
+}
+
+CPDFSDK_Annot* CPDFSDK_XFAAnnotHandler::NewAnnot(XFA_HWIDGET pAnnot, CPDFSDK_PageView* pPage)
+{
+ ASSERT(pPage != NULL);
+ ASSERT(pAnnot != NULL);
+
+ CPDFSDK_Document* pSDKDoc = m_pApp->GetCurrentDoc();
+ ASSERT(pSDKDoc);
+ CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm();
+ ASSERT(pInterForm != NULL);
+
+ CPDFSDK_XFAWidget* pWidget = NULL;
+ pWidget = new CPDFSDK_XFAWidget(pAnnot, pPage, pInterForm);
+ ASSERT(pWidget != NULL);
+ pInterForm->AddXFAMap(pAnnot, pWidget);
+
+ return pWidget;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot)
+{
+ ASSERT(pAnnot != NULL);
+
+ return pAnnot->GetXFAWidget() != NULL;
+}
+
+void CPDFSDK_XFAAnnotHandler::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, FX_DWORD dwFlags)
+{
+ ASSERT(pPageView != NULL);
+ ASSERT(pAnnot != NULL);
+
+ CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
+ ASSERT(pSDKDoc != NULL);
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ CFX_Graphics gs;
+ gs.Create(pDevice);
+
+ CFX_Matrix mt;
+ mt = *(CFX_Matrix*)pUser2Device;
+
+ XFA_HWIDGET hWidget = pAnnot->GetXFAWidget();
+ ASSERT(hWidget != NULL);
+
+ FX_BOOL bIsHighlight = FALSE;
+ if (pSDKDoc->GetFocusAnnot() != pAnnot)
+ bIsHighlight = TRUE;
+
+ pWidgetHandler->RenderWidget(pAnnot->GetXFAWidget(), &gs, &mt, bIsHighlight);
+
+ // to do highlight and shadow
+
+}
+
+void CPDFSDK_XFAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot)
+{
+ ASSERT(pAnnot != NULL);
+
+ CPDFSDK_XFAWidget* pWidget = (CPDFSDK_XFAWidget*)pAnnot;
+ CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
+ ASSERT(pInterForm != NULL);
+
+ pInterForm->RemoveXFAMap(pWidget->GetXFAWidget());
+
+ delete pWidget;
+}
+
+CPDF_Rect CPDFSDK_XFAAnnotHandler::GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot)
+{
+ ASSERT(pAnnot != NULL);
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ XFA_ELEMENT eType = pWidgetHandler->GetDataAcc(pAnnot->GetXFAWidget())->GetUIType();
+ CFX_RectF rcBBox;
+ if (eType == XFA_ELEMENT_Signature)
+ pWidgetHandler->GetBBox (pAnnot->GetXFAWidget(), rcBBox, XFA_WIDGETSTATUS_Visible, TRUE);
+ else
+ pWidgetHandler->GetBBox (pAnnot->GetXFAWidget(), rcBBox, 0);
+
+ CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, rcBBox.top+rcBBox.height);
+ rcWidget.left -= 1.0f;
+ rcWidget.right += 1.0f;
+ rcWidget.bottom -= 1.0f;
+ rcWidget.top += 1.0f;
+
+ return rcWidget;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::HitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point)
+{
+ if (!pPageView || !pAnnot)
+ return FALSE;
+
+ CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
+ if (!pSDKDoc)
+ return FALSE;
+
+ CPDFXFA_Document* pDoc = pSDKDoc->GetDocument();
+ if (!pDoc)
+ return FALSE;
+
+ IXFA_DocView* pDocView = pDoc->GetXFADocView();
+ if (!pDocView)
+ return FALSE;
+
+ IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler();
+ if (!pWidgetHandler)
+ return FALSE;
+
+ FX_DWORD dwHitTest = pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y);
+ return (dwHitTest != FWL_WGTHITTEST_Unknown);
+}
+
+void CPDFSDK_XFAAnnotHandler::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
+{
+ if (!pPageView || !pAnnot)
+ return;
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ pWidgetHandler->OnMouseEnter(pAnnot->GetXFAWidget());
+}
+
+void CPDFSDK_XFAAnnotHandler::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
+{
+ if (!pPageView || !pAnnot)
+ return;
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ pWidgetHandler->OnMouseExit(pAnnot->GetXFAWidget());
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
+{
+ if (!pPageView || !pAnnot)
+ return FALSE;
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ FX_BOOL bRet = FALSE;
+ bRet = pWidgetHandler->OnLButtonDown(pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), point.x, point.y);
+
+ return bRet;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
+{
+ if (!pPageView || !pAnnot)
+ return FALSE;
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ FX_BOOL bRet = FALSE;
+ bRet = pWidgetHandler->OnLButtonUp(pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), point.x, point.y);
+
+ return bRet;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
+{
+ if (!pPageView || !pAnnot)
+ return FALSE;
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ FX_BOOL bRet = FALSE;
+ bRet = pWidgetHandler->OnLButtonDblClk(pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), point.x, point.y);
+
+ return bRet;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
+{
+ if (!pPageView || !pAnnot)
+ return FALSE;
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ FX_BOOL bRet = FALSE;
+ bRet = pWidgetHandler->OnMouseMove(pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), point.x, point.y);
+
+ return bRet;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, short zDelta, const CPDF_Point& point)
+{
+ if (!pPageView || !pAnnot)
+ return FALSE;
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ FX_BOOL bRet = FALSE;
+ bRet = pWidgetHandler->OnMouseWheel(pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), zDelta, point.x, point.y);
+
+ return bRet;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
+{
+ if (!pPageView || !pAnnot)
+ return FALSE;
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ FX_BOOL bRet = FALSE;
+ bRet = pWidgetHandler->OnRButtonDown(pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), point.x, point.y);
+
+ return bRet;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
+{
+ if (!pPageView || !pAnnot)
+ return FALSE;
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ FX_BOOL bRet = FALSE;
+ bRet = pWidgetHandler->OnRButtonUp(pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), point.x, point.y);
+
+ return bRet;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point)
+{
+ if (!pPageView || !pAnnot)
+ return FALSE;
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ FX_BOOL bRet = FALSE;
+ bRet = pWidgetHandler->OnRButtonDblClk(pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), point.x, point.y);
+
+ return bRet;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot, FX_DWORD nChar, FX_DWORD nFlags)
+{
+ if (!pAnnot)
+ return FALSE;
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ FX_BOOL bRet = FALSE;
+ bRet = pWidgetHandler->OnChar(pAnnot->GetXFAWidget(), nChar, GetFWLFlags(nFlags));
+
+ return bRet;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag)
+{
+ if (!pAnnot)
+ return FALSE;
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ FX_BOOL bRet = FALSE;
+ bRet = pWidgetHandler->OnKeyDown(pAnnot->GetXFAWidget(), nKeyCode, GetFWLFlags(nFlag));
+
+ return bRet;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag)
+{
+ if (!pAnnot)
+ return FALSE;
+
+ IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
+ ASSERT(pWidgetHandler != NULL);
+
+ FX_BOOL bRet = FALSE;
+ bRet = pWidgetHandler->OnKeyUp(pAnnot->GetXFAWidget(), nKeyCode, GetFWLFlags(nFlag));
+
+ return bRet;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
+{
+ return TRUE;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag)
+{
+ return TRUE;
+}
+
+FX_BOOL CPDFSDK_XFAAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, CPDFSDK_Annot* pNewAnnot)
+{
+ IXFA_WidgetHandler* pWidgetHandler = NULL;
+
+ if (pOldAnnot)
+ pWidgetHandler = GetXFAWidgetHandler(pOldAnnot);
+ else if (pNewAnnot)
+ pWidgetHandler = GetXFAWidgetHandler(pNewAnnot);
+
+ if (pWidgetHandler)
+ {
+ FX_BOOL bRet = TRUE; /*pWidgetHandler->OnFocusChange(pNewAnnot ? pNewAnnot->GetXFAWidget() : NULL,
+ pOldAnnot ? pOldAnnot->GetXFAWidget() : NULL); */
+
+ XFA_HWIDGET hWidget = pNewAnnot ? pNewAnnot->GetXFAWidget() : NULL;
+ if (hWidget)
+ {
+ IXFA_PageView* pXFAPageView = pWidgetHandler->GetPageView(hWidget);
+ if (pXFAPageView)
+ {
+ bRet = pXFAPageView->GetDocView()->SetFocus(hWidget);
+ if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget)
+ bRet = TRUE;
+ }
+ }
+ return bRet;
+ }
+
+ return TRUE;
+}
+
+IXFA_WidgetHandler* CPDFSDK_XFAAnnotHandler::GetXFAWidgetHandler(CPDFSDK_Annot* pAnnot)
+{
+ if (!pAnnot)
+ return NULL;
+
+ CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
+ if (!pPageView)
+ return NULL;
+
+ CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
+ if (!pSDKDoc)
+ return NULL;
+
+ CPDFXFA_Document* pDoc = pSDKDoc->GetDocument();
+ if (!pDoc)
+ return NULL;
+
+ IXFA_DocView* pDocView = pDoc->GetXFADocView();
+ if (!pDocView)
+ return NULL;
+
+ return pDocView->GetWidgetHandler();
+}
+
+#define FWL_KEYFLAG_Ctrl (1 << 0)
+#define FWL_KEYFLAG_Alt (1 << 1)
+#define FWL_KEYFLAG_Shift (1 << 2)
+#define FWL_KEYFLAG_LButton (1 << 3)
+#define FWL_KEYFLAG_RButton (1 << 4)
+#define FWL_KEYFLAG_MButton (1 << 5)
+
+FX_DWORD CPDFSDK_XFAAnnotHandler::GetFWLFlags(FX_DWORD dwFlag)
+{
+ FX_DWORD dwFWLFlag = 0;
+
+ if (dwFlag & FWL_EVENTFLAG_ControlKey)
+ dwFWLFlag |= FWL_KEYFLAG_Ctrl;
+ if (dwFlag & FWL_EVENTFLAG_LeftButtonDown)
+ dwFWLFlag |= FWL_KEYFLAG_LButton;
+ if (dwFlag & FWL_EVENTFLAG_MiddleButtonDown)
+ dwFWLFlag |= FWL_KEYFLAG_MButton;
+ if (dwFlag & FWL_EVENTFLAG_RightButtonDown)
+ dwFWLFlag |= FWL_KEYFLAG_RButton;
+ if (dwFlag & FWL_EVENTFLAG_ShiftKey)
+ dwFWLFlag |= FWL_KEYFLAG_Shift;
+ if (dwFlag & FWL_EVENTFLAG_AltKey)
+ dwFWLFlag |= FWL_KEYFLAG_Alt;
+
+ return dwFWLFlag;
+}
+
//CReader_AnnotIteratorEx
CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView * pPageView,FX_BOOL bReverse,
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index ff054c8b20..90e22d32b2 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -5,6 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../include/fsdk_define.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
#include "../include/fsdk_mgr.h"
#include "../include/fsdk_baseannot.h"
@@ -500,40 +501,30 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::AddSeconds(int seconds)
//---------------------------------------------------------------------------
// CPDFSDK_Annot
//---------------------------------------------------------------------------
-CPDFSDK_Annot::CPDFSDK_Annot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView) :
-m_pAnnot(pAnnot),
+CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView) :
m_pPageView(pPageView),
m_bSelected(FALSE),
m_nTabOrder(-1)
{
}
-CPDFSDK_Annot::~CPDFSDK_Annot()
-{
- m_pAnnot = NULL;
- m_pPageView = NULL;
-}
-CPDF_Annot* CPDFSDK_Annot::GetPDFAnnot()
+//CPDFSDK_BAAnnot
+CPDFSDK_BAAnnot::CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView) :
+ CPDFSDK_Annot(pPageView),
+ m_pAnnot(pAnnot)
{
- return m_pAnnot;
-}
-FX_DWORD CPDFSDK_Annot::GetFlags()
-{
- ASSERT(m_pAnnot != NULL);
-
- return m_pAnnot->GetFlags();
}
-void CPDFSDK_Annot::SetPage(CPDFSDK_PageView* pPageView)
+CPDFSDK_BAAnnot::~CPDFSDK_BAAnnot()
{
- m_pPageView = pPageView;
+ m_pAnnot = NULL;
}
-CPDFSDK_PageView* CPDFSDK_Annot::GetPageView()
+CPDF_Annot* CPDFSDK_BAAnnot::GetPDFAnnot()
{
- return m_pPageView;
+ return m_pAnnot;
}
FX_BOOL CPDFSDK_Annot::IsSelected()
@@ -557,14 +548,14 @@ void CPDFSDK_Annot::SetTabOrder(int iTabOrder)
m_nTabOrder = iTabOrder;
}
-CPDF_Dictionary* CPDFSDK_Annot::GetAnnotDict() const
+CPDF_Dictionary* CPDFSDK_BAAnnot::GetAnnotDict() const
{
ASSERT(m_pAnnot != NULL);
return m_pAnnot->m_pAnnotDict;
}
-void CPDFSDK_Annot::SetRect(const CPDF_Rect& rect)
+void CPDFSDK_BAAnnot::SetRect(const CPDF_Rect& rect)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -574,7 +565,7 @@ void CPDFSDK_Annot::SetRect(const CPDF_Rect& rect)
m_pAnnot->m_pAnnotDict->SetAtRect("Rect", rect);
}
-CPDF_Rect CPDFSDK_Annot::GetRect() const
+CPDF_Rect CPDFSDK_BAAnnot::GetRect() const
{
ASSERT(m_pAnnot != NULL);
@@ -584,19 +575,24 @@ CPDF_Rect CPDFSDK_Annot::GetRect() const
return rect;
}
-CFX_ByteString CPDFSDK_Annot::GetType() const
+CFX_ByteString CPDFSDK_BAAnnot::GetType() const
{
ASSERT(m_pAnnot != NULL);
return m_pAnnot->GetSubType();
}
-CFX_ByteString CPDFSDK_Annot::GetSubType() const
+CFX_ByteString CPDFSDK_BAAnnot::GetSubType() const
{
return "";
}
-void CPDFSDK_Annot::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
+void CPDFSDK_BAAnnot::ResetAppearance()
+{
+ ASSERT(FALSE);
+}
+
+void CPDFSDK_BAAnnot::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions)
{
ASSERT(m_pPageView != NULL);
@@ -605,7 +601,7 @@ void CPDFSDK_Annot::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix*
m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, mode, pOptions);
}
-FX_BOOL CPDFSDK_Annot::IsAppearanceValid()
+FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid()
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -613,7 +609,7 @@ FX_BOOL CPDFSDK_Annot::IsAppearanceValid()
return m_pAnnot->m_pAnnotDict->GetDict("AP") != NULL;
}
-FX_BOOL CPDFSDK_Annot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode)
+FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -637,20 +633,20 @@ FX_BOOL CPDFSDK_Annot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode)
return TRUE;
}
-void CPDFSDK_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
+void CPDFSDK_BAAnnot::DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
const CPDF_RenderOptions* pOptions)
{
ASSERT(m_pAnnot != NULL);
m_pAnnot->DrawBorder(pDevice, pUser2Device, pOptions);
}
-void CPDFSDK_Annot::ClearCachedAP()
+void CPDFSDK_BAAnnot::ClearCachedAP()
{
ASSERT(m_pAnnot != NULL);
m_pAnnot->ClearCachedAP();
}
-void CPDFSDK_Annot::SetContents(const CFX_WideString& sContents)
+void CPDFSDK_BAAnnot::SetContents(const CFX_WideString& sContents)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -661,7 +657,7 @@ void CPDFSDK_Annot::SetContents(const CFX_WideString& sContents)
m_pAnnot->m_pAnnotDict->SetAtString("Contents", PDF_EncodeText(sContents));
}
-CFX_WideString CPDFSDK_Annot::GetContents() const
+CFX_WideString CPDFSDK_BAAnnot::GetContents() const
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -669,7 +665,7 @@ CFX_WideString CPDFSDK_Annot::GetContents() const
return m_pAnnot->m_pAnnotDict->GetUnicodeText("Contents");
}
-void CPDFSDK_Annot::SetAnnotName(const CFX_WideString& sName)
+void CPDFSDK_BAAnnot::SetAnnotName(const CFX_WideString& sName)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -680,7 +676,7 @@ void CPDFSDK_Annot::SetAnnotName(const CFX_WideString& sName)
m_pAnnot->m_pAnnotDict->SetAtString("NM", PDF_EncodeText(sName));
}
-CFX_WideString CPDFSDK_Annot::GetAnnotName() const
+CFX_WideString CPDFSDK_BAAnnot::GetAnnotName() const
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -688,7 +684,7 @@ CFX_WideString CPDFSDK_Annot::GetAnnotName() const
return m_pAnnot->m_pAnnotDict->GetUnicodeText("NM");
}
-void CPDFSDK_Annot::SetModifiedDate(const FX_SYSTEMTIME& st)
+void CPDFSDK_BAAnnot::SetModifiedDate(const FX_SYSTEMTIME& st)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -702,7 +698,7 @@ void CPDFSDK_Annot::SetModifiedDate(const FX_SYSTEMTIME& st)
m_pAnnot->m_pAnnotDict->SetAtString("M", str);
}
-FX_SYSTEMTIME CPDFSDK_Annot::GetModifiedDate() const
+FX_SYSTEMTIME CPDFSDK_BAAnnot::GetModifiedDate() const
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -716,7 +712,7 @@ FX_SYSTEMTIME CPDFSDK_Annot::GetModifiedDate() const
return systime;
}
-void CPDFSDK_Annot::SetFlags(int nFlags)
+void CPDFSDK_BAAnnot::SetFlags(int nFlags)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -724,7 +720,7 @@ void CPDFSDK_Annot::SetFlags(int nFlags)
m_pAnnot->m_pAnnotDict->SetAtInteger("F", nFlags);
}
-int CPDFSDK_Annot::GetFlags() const
+int CPDFSDK_BAAnnot::GetFlags() const
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -732,7 +728,7 @@ int CPDFSDK_Annot::GetFlags() const
return m_pAnnot->m_pAnnotDict->GetInteger("F");
}
-void CPDFSDK_Annot::SetAppState(const CFX_ByteString& str)
+void CPDFSDK_BAAnnot::SetAppState(const CFX_ByteString& str)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -743,7 +739,7 @@ void CPDFSDK_Annot::SetAppState(const CFX_ByteString& str)
m_pAnnot->m_pAnnotDict->SetAtString("AS", str);
}
-CFX_ByteString CPDFSDK_Annot::GetAppState() const
+CFX_ByteString CPDFSDK_BAAnnot::GetAppState() const
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -751,7 +747,7 @@ CFX_ByteString CPDFSDK_Annot::GetAppState() const
return m_pAnnot->m_pAnnotDict->GetString("AS");
}
-void CPDFSDK_Annot::SetStructParent(int key)
+void CPDFSDK_BAAnnot::SetStructParent(int key)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -759,7 +755,7 @@ void CPDFSDK_Annot::SetStructParent(int key)
m_pAnnot->m_pAnnotDict->SetAtInteger("StructParent", key);
}
-int CPDFSDK_Annot::GetStructParent() const
+int CPDFSDK_BAAnnot::GetStructParent() const
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -768,7 +764,7 @@ int CPDFSDK_Annot::GetStructParent() const
}
//border
-void CPDFSDK_Annot::SetBorderWidth(int nWidth)
+void CPDFSDK_BAAnnot::SetBorderWidth(int nWidth)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -793,7 +789,7 @@ void CPDFSDK_Annot::SetBorderWidth(int nWidth)
}
}
-int CPDFSDK_Annot::GetBorderWidth() const
+int CPDFSDK_BAAnnot::GetBorderWidth() const
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -816,7 +812,7 @@ int CPDFSDK_Annot::GetBorderWidth() const
return 1;
}
-void CPDFSDK_Annot::SetBorderStyle(int nStyle)
+void CPDFSDK_BAAnnot::SetBorderStyle(int nStyle)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -848,7 +844,7 @@ void CPDFSDK_Annot::SetBorderStyle(int nStyle)
}
}
-int CPDFSDK_Annot::GetBorderStyle() const
+int CPDFSDK_BAAnnot::GetBorderStyle() const
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -878,7 +874,7 @@ int CPDFSDK_Annot::GetBorderStyle() const
return BBS_SOLID;
}
-void CPDFSDK_Annot::SetBorderDash(const CFX_IntArray& array)
+void CPDFSDK_BAAnnot::SetBorderDash(const CFX_IntArray& array)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -899,7 +895,7 @@ void CPDFSDK_Annot::SetBorderDash(const CFX_IntArray& array)
pBSDict->SetAt("D", pArray);
}
-void CPDFSDK_Annot::GetBorderDash(CFX_IntArray& array) const
+void CPDFSDK_BAAnnot::GetBorderDash(CFX_IntArray& array) const
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -929,7 +925,7 @@ void CPDFSDK_Annot::GetBorderDash(CFX_IntArray& array) const
}
}
-void CPDFSDK_Annot::SetColor(FX_COLORREF color)
+void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -941,7 +937,7 @@ void CPDFSDK_Annot::SetColor(FX_COLORREF color)
m_pAnnot->m_pAnnotDict->SetAt("C", pArray);
}
-void CPDFSDK_Annot::RemoveColor()
+void CPDFSDK_BAAnnot::RemoveColor()
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -949,7 +945,7 @@ void CPDFSDK_Annot::RemoveColor()
m_pAnnot->m_pAnnotDict->RemoveAt("C") ;
}
-FX_BOOL CPDFSDK_Annot::GetColor(FX_COLORREF& color) const
+FX_BOOL CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -996,7 +992,7 @@ FX_BOOL CPDFSDK_Annot::GetColor(FX_COLORREF& color) const
}
-void CPDFSDK_Annot::WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Rect& rcBBox,
+void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Rect& rcBBox,
const CPDF_Matrix& matrix, const CFX_ByteString& sContents,
const CFX_ByteString& sAPState)
{
@@ -1078,17 +1074,17 @@ FX_FLOAT CPDFSDK_Annot::GetMinHeight() const
return BA_ANNOT_MINHEIGHT;
}
-FX_BOOL CPDFSDK_Annot::CreateFormFiller()
+FX_BOOL CPDFSDK_BAAnnot::CreateFormFiller()
{
return TRUE;
}
-FX_BOOL CPDFSDK_Annot::IsVisible() const
+FX_BOOL CPDFSDK_BAAnnot::IsVisible() const
{
int nFlags = GetFlags();
return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || (nFlags & ANNOTFLAG_NOVIEW));
}
-CPDF_Action CPDFSDK_Annot::GetAction() const
+CPDF_Action CPDFSDK_BAAnnot::GetAction() const
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -1096,7 +1092,7 @@ CPDF_Action CPDFSDK_Annot::GetAction() const
return m_pAnnot->m_pAnnotDict->GetDict("A");
}
-void CPDFSDK_Annot::SetAction(const CPDF_Action& action)
+void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -1114,7 +1110,7 @@ void CPDFSDK_Annot::SetAction(const CPDF_Action& action)
}
}
-void CPDFSDK_Annot::RemoveAction()
+void CPDFSDK_BAAnnot::RemoveAction()
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -1122,7 +1118,7 @@ void CPDFSDK_Annot::RemoveAction()
m_pAnnot->m_pAnnotDict->RemoveAt("A");
}
-CPDF_AAction CPDFSDK_Annot::GetAAction() const
+CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -1130,7 +1126,7 @@ CPDF_AAction CPDFSDK_Annot::GetAAction() const
return m_pAnnot->m_pAnnotDict->GetDict("AA");
}
-void CPDFSDK_Annot::SetAAction(const CPDF_AAction& aa)
+void CPDFSDK_BAAnnot::SetAAction(const CPDF_AAction& aa)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -1140,7 +1136,7 @@ void CPDFSDK_Annot::SetAAction(const CPDF_AAction& aa)
m_pAnnot->m_pAnnotDict->SetAt("AA", (CPDF_AAction&)aa);
}
-void CPDFSDK_Annot::RemoveAAction()
+void CPDFSDK_BAAnnot::RemoveAAction()
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
@@ -1148,7 +1144,7 @@ void CPDFSDK_Annot::RemoveAAction()
m_pAnnot->m_pAnnotDict->RemoveAt("AA");
}
-CPDF_Action CPDFSDK_Annot::GetAAction(CPDF_AAction::AActionType eAAT)
+CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT)
{
CPDF_AAction AAction = GetAAction();
@@ -1164,7 +1160,12 @@ CPDF_Action CPDFSDK_Annot::GetAAction(CPDF_AAction::AActionType eAAT)
return NULL;
}
-void CPDFSDK_Annot::Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, CPDF_RenderOptions* pOptions)
+FX_BOOL CPDFSDK_BAAnnot::IsXFAField()
+{
+ return FALSE;
+}
+
+void CPDFSDK_BAAnnot::Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, CPDF_RenderOptions* pOptions)
{
m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal);
@@ -1180,3 +1181,10 @@ CPDF_Page* CPDFSDK_Annot::GetPDFPage()
return NULL;
}
+CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage()
+{
+ if (m_pPageView)
+ return m_pPageView->GetPDFXFAPage();
+ return NULL;
+}
+
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index aa87dd56bb..c301a8760a 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -5,6 +5,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../include/fsdk_define.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../include/fpdfxfa/fpdfxfa_util.h"
#include "../include/fsdk_mgr.h"
#include "../include/fsdk_baseannot.h"
#include "../include/fsdk_baseform.h"
@@ -23,10 +25,12 @@
#define IsFloatEqual(fa,fb) IsFloatZero((fa)-(fb))
CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm) :
- CPDFSDK_Annot(pAnnot, pPageView),
+ CPDFSDK_BAAnnot(pAnnot, pPageView),
m_pInterForm(pInterForm),
m_nAppAge(0),
- m_nValueAge(0)
+ m_nValueAge(0),
+ m_hMixXFAWidget(NULL),
+ m_pWidgetHandler(NULL)
{
ASSERT(m_pInterForm != NULL);
}
@@ -36,6 +40,527 @@ CPDFSDK_Widget::~CPDFSDK_Widget()
}
+XFA_HWIDGET CPDFSDK_Widget::GetMixXFAWidget()
+{
+ ASSERT(m_pPageView != NULL);
+
+ CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
+ ASSERT(pSDKDoc != NULL);
+
+ CPDFXFA_Document* pDoc = pSDKDoc->GetDocument();
+ ASSERT(pDoc != NULL);
+
+ if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA)
+ {
+ if (!m_hMixXFAWidget)
+ {
+ if (IXFA_DocView* pDocView = pDoc->GetXFADocView())
+ {
+ CFX_WideString sName;
+ if (this->GetFieldType() == FIELDTYPE_RADIOBUTTON)
+ {
+ sName = this->GetAnnotName();
+ if (sName.IsEmpty())
+ sName = GetName();
+ }
+ else
+ sName = GetName();
+
+ if (!sName.IsEmpty())
+ m_hMixXFAWidget = pDocView->GetWidgetByName(sName);
+ }
+ }
+ return m_hMixXFAWidget;
+ }
+
+ return NULL;
+}
+
+XFA_HWIDGET CPDFSDK_Widget::GetGroupMixXFAWidget()
+{
+ ASSERT(m_pPageView != NULL);
+
+ CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
+ ASSERT(pSDKDoc != NULL);
+
+ CPDFXFA_Document* pDoc = pSDKDoc->GetDocument();
+ ASSERT(pDoc != NULL);
+
+ if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA)
+ {
+ if (IXFA_DocView* pDocView = pDoc->GetXFADocView())
+ {
+ CFX_WideString sName = GetName();
+
+ if (!sName.IsEmpty())
+ return pDocView->GetWidgetByName(sName);
+ }
+ }
+
+ return NULL;
+}
+
+IXFA_WidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler()
+{
+ ASSERT(m_pPageView != NULL);
+
+ CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
+ ASSERT(pSDKDoc != NULL);
+
+ CPDFXFA_Document* pDoc = pSDKDoc->GetDocument();
+ ASSERT(pDoc != NULL);
+
+ if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA)
+ {
+ if (!m_pWidgetHandler)
+ {
+ if (IXFA_DocView* pDocView = pDoc->GetXFADocView())
+ {
+ m_pWidgetHandler = pDocView->GetWidgetHandler();
+ }
+ }
+ return m_pWidgetHandler;
+ }
+
+ return NULL;
+}
+
+static XFA_EVENTTYPE GetXFAEventType(PDFSDK_XFAAActionType eXFAAAT)
+{
+ XFA_EVENTTYPE eEventType = XFA_EVENT_Unknown;
+
+ switch (eXFAAAT)
+ {
+ case PDFSDK_XFA_Click:
+ eEventType = XFA_EVENT_Click;
+ break;
+ case PDFSDK_XFA_Full:
+ eEventType = XFA_EVENT_Full;
+ break;
+ case PDFSDK_XFA_PreOpen:
+ eEventType = XFA_EVENT_PreOpen;
+ break;
+ case PDFSDK_XFA_PostOpen:
+ eEventType = XFA_EVENT_PostOpen;
+ break;
+ }
+
+ return eEventType;
+}
+
+static XFA_EVENTTYPE GetXFAEventType(CPDF_AAction::AActionType eAAT, FX_BOOL bWillCommit)
+{
+ XFA_EVENTTYPE eEventType = XFA_EVENT_Unknown;
+
+ switch (eAAT)
+ {
+ case CPDF_AAction::CursorEnter:
+ eEventType = XFA_EVENT_MouseEnter;
+ break;
+ case CPDF_AAction::CursorExit:
+ eEventType = XFA_EVENT_MouseExit;
+ break;
+ case CPDF_AAction::ButtonDown:
+ eEventType = XFA_EVENT_MouseDown;
+ break;
+ case CPDF_AAction::ButtonUp:
+ eEventType = XFA_EVENT_MouseUp;
+ break;
+ case CPDF_AAction::GetFocus:
+ eEventType = XFA_EVENT_Enter;
+ break;
+ case CPDF_AAction::LoseFocus:
+ eEventType = XFA_EVENT_Exit;
+ break;
+ case CPDF_AAction::PageOpen:
+ break;
+ case CPDF_AAction::PageClose:
+ break;
+ case CPDF_AAction::PageVisible:
+ break;
+ case CPDF_AAction::PageInvisible:
+ break;
+ case CPDF_AAction::KeyStroke:
+ if (!bWillCommit)
+ {
+ eEventType = XFA_EVENT_Change;
+ }
+ break;
+ case CPDF_AAction::Validate:
+ eEventType = XFA_EVENT_Validate;
+ break;
+ case CPDF_AAction::OpenPage:
+ case CPDF_AAction::ClosePage:
+ case CPDF_AAction::Format:
+ case CPDF_AAction::Calculate:
+ case CPDF_AAction::CloseDocument:
+ case CPDF_AAction::SaveDocument:
+ case CPDF_AAction::DocumentSaved:
+ case CPDF_AAction::PrintDocument:
+ case CPDF_AAction::DocumentPrinted:
+ break;
+ }
+
+ return eEventType;
+}
+
+FX_BOOL CPDFSDK_Widget::HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT)
+{
+ if (XFA_HWIDGET hWidget = this->GetMixXFAWidget())
+ {
+ if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler())
+ {
+ XFA_EVENTTYPE eEventType = GetXFAEventType(eXFAAAT);
+
+ if ((eEventType == XFA_EVENT_Click ||
+ eEventType == XFA_EVENT_Change) &&
+ GetFieldType() == FIELDTYPE_RADIOBUTTON)
+ {
+ if (XFA_HWIDGET hGroupWidget = GetGroupMixXFAWidget())
+ {
+ CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hGroupWidget);
+ if (pXFAWidgetHandler->HasEvent(pAcc, eEventType))
+ return TRUE;
+ }
+ }
+
+ {
+ CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget);
+ return pXFAWidgetHandler->HasEvent(pAcc, eEventType);
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+FX_BOOL CPDFSDK_Widget::OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, PDFSDK_FieldAction& data, CPDFSDK_PageView* pPageView)
+{
+ ASSERT(m_pPageView != NULL);
+
+ CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
+ ASSERT(pSDKDoc != NULL);
+
+ CPDFXFA_Document* pDoc = pSDKDoc->GetDocument();
+ ASSERT(pDoc != NULL);
+
+ if (XFA_HWIDGET hWidget = this->GetMixXFAWidget())
+ {
+ XFA_EVENTTYPE eEventType = GetXFAEventType(eXFAAAT);
+
+ if (eEventType != XFA_EVENT_Unknown)
+ {
+ if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler())
+ {
+ CXFA_EventParam param;
+ param.m_eType = eEventType;
+ param.m_wsChange = data.sChange;
+ param.m_iCommitKey = data.nCommitKey;
+ param.m_bShift = data.bShift;
+ param.m_iSelStart = data.nSelStart;
+ param.m_iSelEnd = data.nSelEnd;
+ param.m_wsFullText = data.sValue;
+ param.m_bKeyDown = data.bKeyDown;
+ param.m_bModifier = data.bModifier;
+ param.m_wsNewText = data.sValue;
+ if (data.nSelEnd > data.nSelStart)
+ param.m_wsNewText.Delete(data.nSelStart, data.nSelEnd - data.nSelStart);
+ for (int i=0; i<data.sChange.GetLength(); i++)
+ param.m_wsNewText.Insert(data.nSelStart, data.sChange[i]);
+ param.m_wsPrevText = data.sValue;
+
+ if ((eEventType == XFA_EVENT_Click ||
+ eEventType == XFA_EVENT_Change) &&
+ GetFieldType() == FIELDTYPE_RADIOBUTTON)
+ {
+ if (XFA_HWIDGET hGroupWidget = GetGroupMixXFAWidget())
+ {
+ CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hGroupWidget);
+ param.m_pTarget = pAcc;
+ pXFAWidgetHandler->ProcessEvent(pAcc, &param);
+ }
+
+ {
+ CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget);
+ param.m_pTarget = pAcc;
+ FX_INT32 nRet = pXFAWidgetHandler->ProcessEvent(pAcc, &param);
+ return nRet == XFA_EVENTERROR_Sucess;
+ }
+ }
+ else
+ {
+ CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget);
+ param.m_pTarget = pAcc;
+ FX_INT32 nRet = pXFAWidgetHandler->ProcessEvent(pAcc, &param);
+ return nRet == XFA_EVENTERROR_Sucess;
+ }
+
+ if (IXFA_DocView* pDocView = pDoc->GetXFADocView())
+ {
+ pDocView->UpdateDocView();
+ }
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse)
+{
+ if (XFA_HWIDGET hWidget = this->GetMixXFAWidget())
+ {
+ if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler())
+ {
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
+
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ {
+ switch (GetFieldType())
+ {
+ case FIELDTYPE_CHECKBOX:
+ case FIELDTYPE_RADIOBUTTON:
+ {
+ CPDF_FormControl* pFormCtrl = GetFormControl();
+ ASSERT(pFormCtrl != NULL);
+
+ XFA_CHECKSTATE eCheckState = pFormCtrl->IsChecked() ? XFA_CHECKSTATE_On : XFA_CHECKSTATE_Off;
+ pWidgetAcc->SetCheckState(eCheckState);
+ }
+ break;
+ case FIELDTYPE_TEXTFIELD:
+ pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit);
+ break;
+ case FIELDTYPE_LISTBOX:
+ {
+ pWidgetAcc->ClearAllSelections();
+
+ for (int i=0,sz=pFormField->CountSelectedItems(); i<sz; i++)
+ {
+ int nIndex = pFormField->GetSelectedIndex(i);
+ if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems())
+ pWidgetAcc->SetItemState(nIndex, TRUE, FALSE);
+ }
+ }
+ break;
+ case FIELDTYPE_COMBOBOX:
+ {
+ pWidgetAcc->ClearAllSelections();
+
+ for (int i=0,sz=pFormField->CountSelectedItems(); i<sz; i++)
+ {
+ int nIndex = pFormField->GetSelectedIndex(i);
+ if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems())
+ pWidgetAcc->SetItemState(nIndex, TRUE, FALSE);
+ }
+ }
+
+ pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit);
+ break;
+ }
+
+ if (bSynchronizeElse)
+ pWidgetAcc->ProcessValueChanged();
+ }
+ }
+ }
+}
+
+void CPDFSDK_Widget::SynchronizeXFAValue()
+{
+ ASSERT(m_pPageView != NULL);
+
+ CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
+ ASSERT(pSDKDoc != NULL);
+
+ CPDFXFA_Document* pDoc = pSDKDoc->GetDocument();
+ ASSERT(pDoc != NULL);
+
+ IXFA_DocView* pXFADocView = pDoc->GetXFADocView();
+ if (!pXFADocView) return;
+
+ if (XFA_HWIDGET hWidget = this->GetMixXFAWidget())
+ {
+ if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler())
+ {
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
+
+ CPDF_FormControl* pFormCtrl = GetFormControl();
+ ASSERT(pFormCtrl != NULL);
+
+ CPDFSDK_Widget::SynchronizeXFAValue(pXFADocView, hWidget, pFormField, pFormCtrl);
+ }
+ }
+}
+
+void CPDFSDK_Widget::SynchronizeXFAItems()
+{
+ ASSERT(m_pPageView != NULL);
+
+ CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
+ ASSERT(pSDKDoc != NULL);
+
+ CPDFXFA_Document* pDoc = pSDKDoc->GetDocument();
+ ASSERT(pDoc != NULL);
+
+ IXFA_DocView* pXFADocView = pDoc->GetXFADocView();
+ if (!pXFADocView) return;
+
+ if (XFA_HWIDGET hWidget = this->GetMixXFAWidget())
+ {
+ if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler())
+ {
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
+
+ SynchronizeXFAItems(pXFADocView, hWidget, pFormField, NULL);
+ }
+ }
+}
+
+void CPDFSDK_Widget::SynchronizeXFAValue(IXFA_DocView* pXFADocView, XFA_HWIDGET hWidget,
+ CPDF_FormField* pFormField, CPDF_FormControl* pFormControl)
+{
+ ASSERT(pXFADocView != NULL);
+ ASSERT(hWidget != NULL);
+
+ if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler())
+ {
+ ASSERT(pFormField != NULL);
+ ASSERT(pFormControl != NULL);
+
+ switch (pFormField->GetFieldType())
+ {
+ case FIELDTYPE_CHECKBOX:
+ {
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ {
+ FX_BOOL bChecked = pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On;
+
+ pFormField->CheckControl(pFormField->GetControlIndex(pFormControl),
+ bChecked, TRUE);
+ }
+ }
+ break;
+ case FIELDTYPE_RADIOBUTTON:
+ {
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ {
+ FX_BOOL bChecked = pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On;
+
+ pFormField->CheckControl(pFormField->GetControlIndex(pFormControl),
+ bChecked, TRUE);
+ }
+ }
+ break;
+ case FIELDTYPE_TEXTFIELD:
+ {
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ {
+ CFX_WideString sValue;
+ pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display);
+ pFormField->SetValue(sValue, TRUE);
+ }
+ }
+ break;
+ case FIELDTYPE_LISTBOX:
+ {
+ pFormField->ClearSelection(FALSE);
+
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ {
+ for (int i=0,sz=pWidgetAcc->CountSelectedItems(); i<sz; i++)
+ {
+ int nIndex = pWidgetAcc->GetSelectedItem(i);
+
+ if (nIndex > -1 && nIndex < pFormField->CountOptions())
+ {
+ pFormField->SetItemSelection(nIndex, TRUE, TRUE);
+ }
+ }
+ }
+ }
+ break;
+ case FIELDTYPE_COMBOBOX:
+ {
+ pFormField->ClearSelection(FALSE);
+
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ {
+ for (int i=0,sz=pWidgetAcc->CountSelectedItems(); i<sz; i++)
+ {
+ int nIndex = pWidgetAcc->GetSelectedItem(i);
+
+ if (nIndex > -1 && nIndex < pFormField->CountOptions())
+ {
+ pFormField->SetItemSelection(nIndex, TRUE, TRUE);
+ }
+ }
+
+ CFX_WideString sValue;
+ pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display);
+ pFormField->SetValue(sValue, TRUE);
+ }
+ }
+ break;
+ }
+ }
+}
+
+void CPDFSDK_Widget::SynchronizeXFAItems(IXFA_DocView* pXFADocView, XFA_HWIDGET hWidget,
+ CPDF_FormField* pFormField, CPDF_FormControl* pFormControl)
+{
+ ASSERT(pXFADocView != NULL);
+ ASSERT(hWidget != NULL);
+
+ if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler())
+ {
+ ASSERT(pFormField != NULL);
+
+ switch (pFormField->GetFieldType())
+ {
+ case FIELDTYPE_LISTBOX:
+ {
+ pFormField->ClearSelection(FALSE);
+ pFormField->ClearOptions(TRUE);
+
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ {
+ for (int i=0,sz=pWidgetAcc->CountChoiceListItems(); i<sz; i++)
+ {
+ CFX_WideString swText;
+ pWidgetAcc->GetChoiceListItem(swText, i);
+
+ pFormField->InsertOption(swText, i, TRUE);
+ }
+ }
+ }
+ break;
+ case FIELDTYPE_COMBOBOX:
+ {
+ pFormField->ClearSelection(FALSE);
+ pFormField->ClearOptions(FALSE);
+
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ {
+ for (int i=0,sz=pWidgetAcc->CountChoiceListItems(); i<sz; i++)
+ {
+ CFX_WideString swText;
+ pWidgetAcc->GetChoiceListItem(swText, i);
+
+ pFormField->InsertOption(swText, i, FALSE);
+ }
+ }
+
+ pFormField->SetValue(L"", TRUE);
+ }
+ break;
+ }
+ }
+}
+
FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode)
{
ASSERT(m_pAnnot != NULL);
@@ -90,6 +615,23 @@ int CPDFSDK_Widget::GetFieldType() const
return pField->GetFieldType();
}
+FX_BOOL CPDFSDK_Widget::IsAppearanceValid()
+{
+ ASSERT(m_pPageView != NULL);
+
+ CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
+ ASSERT(pSDKDoc != NULL);
+
+ CPDFXFA_Document* pDoc = pSDKDoc->GetDocument();
+ ASSERT(pDoc != NULL);
+
+ int nDocType = pDoc->GetDocType();
+ if (nDocType == DOCTYPE_PDF || nDocType == DOCTYPE_STATIC_XFA)
+ return CPDFSDK_BAAnnot::IsAppearanceValid();
+
+ return TRUE;
+}
+
int CPDFSDK_Widget::GetFieldFlags() const
{
CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm();
@@ -160,6 +702,16 @@ int CPDFSDK_Widget::GetRotate() const
return pCtrl->GetRotation() % 360;
}
+CFX_WideString CPDFSDK_Widget::GetName()
+{
+ ASSERT(m_pInterForm != NULL);
+
+ CPDF_FormField* pFormField = GetFormField();
+ ASSERT(pFormField != NULL);
+
+ return pFormField->GetFullName();
+}
+
FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const
{
CPDF_FormControl* pFormCtrl = GetFormControl();
@@ -214,16 +766,41 @@ FX_FLOAT CPDFSDK_Widget::GetFontSize() const
return fFontSize;
}
-int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const
+int CPDFSDK_Widget::GetSelectedIndex(int nIndex)
{
+ if (XFA_HWIDGET hWidget = this->GetMixXFAWidget())
+ {
+ if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler())
+ {
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ {
+ if (nIndex < pWidgetAcc->CountSelectedItems())
+ return pWidgetAcc->GetSelectedItem(nIndex);
+ }
+ }
+ }
+
CPDF_FormField* pFormField = GetFormField();
ASSERT(pFormField != NULL);
return pFormField->GetSelectedIndex(nIndex);
}
-CFX_WideString CPDFSDK_Widget::GetValue() const
+CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay)
{
+ if (XFA_HWIDGET hWidget = this->GetMixXFAWidget())
+ {
+ if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler())
+ {
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ {
+ CFX_WideString sValue;
+ pWidgetAcc->GetValue(sValue, bDisplay ? XFA_VALUEPICTURE_Display : XFA_VALUEPICTURE_Edit);
+ return sValue;
+ }
+ }
+ }
+
CPDF_FormField* pFormField = GetFormField();
ASSERT(pFormField != NULL);
@@ -254,8 +831,22 @@ int CPDFSDK_Widget::CountOptions() const
return pFormField->CountOptions();
}
-FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const
+FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex)
{
+ if (XFA_HWIDGET hWidget = this->GetMixXFAWidget())
+ {
+ if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler())
+ {
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ {
+ if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems())
+ return pWidgetAcc->GetItemState(nIndex);
+ else
+ return FALSE;
+ }
+ }
+ }
+
CPDF_FormField* pFormField = GetFormField();
ASSERT(pFormField != NULL);
@@ -270,8 +861,20 @@ int CPDFSDK_Widget::GetTopVisibleIndex() const
return pFormField->GetTopVisibleIndex();
}
-FX_BOOL CPDFSDK_Widget::IsChecked() const
+FX_BOOL CPDFSDK_Widget::IsChecked()
{
+ if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler())
+ {
+ if (XFA_HWIDGET hWidget = this->GetMixXFAWidget())
+ {
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ {
+ FX_BOOL bChecked = pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On;
+ return bChecked;
+ }
+ }
+ }
+
CPDF_FormControl* pFormCtrl = GetFormControl();
ASSERT(pFormCtrl != NULL);
@@ -303,6 +906,10 @@ void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify)
ASSERT(pFormField != NULL);
pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, bNotify);
+ if (!IsWidgetAppearanceValid(CPDF_Annot::Normal))
+ ResetAppearance(TRUE);
+ if (!bNotify)
+ Synchronize(TRUE);
}
void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify)
@@ -311,6 +918,9 @@ void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify)
ASSERT(pFormField != NULL);
pFormField->SetValue(sValue, bNotify);
+
+ if (!bNotify)
+ Synchronize(TRUE);
}
void CPDFSDK_Widget::SetDefaultValue(const CFX_WideString& sValue)
@@ -322,6 +932,9 @@ void CPDFSDK_Widget::SetOptionSelection(int index, FX_BOOL bSelected, FX_BOOL bN
ASSERT(pFormField != NULL);
pFormField->SetItemSelection(index, bSelected, bNotify);
+
+ if (!bNotify)
+ Synchronize(TRUE);
}
void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify)
@@ -330,6 +943,9 @@ void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify)
ASSERT(pFormField != NULL);
pFormField->ClearSelection(bNotify);
+
+ if (!bNotify)
+ Synchronize(TRUE);
}
void CPDFSDK_Widget::SetTopVisibleIndex(int index)
@@ -351,6 +967,27 @@ FX_BOOL CPDFSDK_Widget::IsAppModified() const
return m_bAppModified;
}
+void CPDFSDK_Widget::ResetAppearance(FX_BOOL bValueChanged)
+{
+ switch (GetFieldType())
+ {
+ case FIELDTYPE_TEXTFIELD:
+ case FIELDTYPE_COMBOBOX:
+ {
+ FX_BOOL bFormated = FALSE;
+ CFX_WideString sValue = this->OnFormat(0, bFormated);
+ if (bFormated)
+ this->ResetAppearance(sValue, TRUE);
+ else
+ this->ResetAppearance(NULL, TRUE);
+ }
+ break;
+ default:
+ this->ResetAppearance(NULL, FALSE);
+ break;
+ }
+}
+
void CPDFSDK_Widget::ResetAppearance(FX_LPCWSTR sValue, FX_BOOL bValueChanged)
{
SetAppModified();
@@ -433,7 +1070,7 @@ void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix
}
else
{
- CPDFSDK_Annot::DrawAppearance(pDevice, pUser2Device, mode, pOptions);
+ CPDFSDK_BAAnnot::DrawAppearance(pDevice, pUser2Device, mode, pOptions);
}
}
@@ -1251,6 +1888,13 @@ void CPDFSDK_Widget::ResetAppearance_TextField(FX_LPCWSTR sValue)
FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1;
FX_FLOAT fFontSize = GetFontSize();
+ CFX_WideString sValueTmp;
+ if (!sValue && (NULL != this->GetMixXFAWidget()))
+ {
+ sValueTmp = GetValue(TRUE);
+ sValue = sValueTmp;
+ }
+
if (nMaxLen > 0)
{
if (bCharArray)
@@ -1589,16 +2233,59 @@ void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType)
FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, PDFSDK_FieldAction& data, CPDFSDK_PageView* pPageView)
{
- CPDF_Action action = GetAAction(type);
+ CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
+ ASSERT(pDocument != NULL);
- if (action && action.GetType() != CPDF_Action::Unknown)
+ CPDFXFA_Document* pDoc = pDocument->GetDocument();
+ ASSERT(pDoc != NULL);
+
+ CPDFDoc_Environment* pEnv = pDocument->GetEnv();
+ ASSERT(pEnv != NULL);
+
+ if (XFA_HWIDGET hWidget = this->GetMixXFAWidget())
{
- CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
- ASSERT(pDocument != NULL);
+ XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit);
- CPDFDoc_Environment* pEnv = pDocument->GetEnv();
- ASSERT(pEnv != NULL);
+ if (eEventType != XFA_EVENT_Unknown)
+ {
+ if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler())
+ {
+ CXFA_EventParam param;
+ param.m_eType = eEventType;
+ param.m_wsChange = data.sChange;
+ param.m_iCommitKey = data.nCommitKey;
+ param.m_bShift = data.bShift;
+ param.m_iSelStart = data.nSelStart;
+ param.m_iSelEnd = data.nSelEnd;
+ param.m_wsFullText = data.sValue;
+ param.m_bKeyDown = data.bKeyDown;
+ param.m_bModifier = data.bModifier;
+ param.m_wsNewText = data.sValue;
+ if (data.nSelEnd > data.nSelStart)
+ param.m_wsNewText.Delete(data.nSelStart, data.nSelEnd - data.nSelStart);
+ for (int i=data.sChange.GetLength() - 1; i>=0; i--)
+ param.m_wsNewText.Insert(data.nSelStart, data.sChange[i]);
+ param.m_wsPrevText = data.sValue;
+
+ CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget);
+ param.m_pTarget = pAcc;
+ FX_INT32 nRet = pXFAWidgetHandler->ProcessEvent(pAcc, &param);
+
+ if (IXFA_DocView* pDocView = pDoc->GetXFADocView())
+ {
+ pDocView->UpdateDocView();
+ }
+ if (nRet == XFA_EVENTERROR_Sucess)
+ return TRUE;
+ }
+ }
+ }
+
+ CPDF_Action action = GetAAction(type);
+
+ if (action && action.GetType() != CPDF_Action::Unknown)
+ {
CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();/*(CPDFSDK_ActionHandler*)pApp->GetActionHandler();*/
ASSERT(pActionHandler != NULL);
@@ -1622,7 +2309,7 @@ CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT)
case CPDF_AAction::PageClose:
case CPDF_AAction::PageVisible:
case CPDF_AAction::PageInvisible:
- return CPDFSDK_Annot::GetAAction(eAAT);
+ return CPDFSDK_BAAnnot::GetAAction(eAAT);
case CPDF_AAction::KeyStroke:
case CPDF_AAction::Format:
case CPDF_AAction::Validate:
@@ -1634,7 +2321,7 @@ CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT)
if (CPDF_AAction aa = pField->GetAdditionalAction())
return aa.GetAction(eAAT);
else
- return CPDFSDK_Annot::GetAAction(eAAT);
+ return CPDFSDK_BAAnnot::GetAAction(eAAT);
}
default:
return NULL;
@@ -1681,14 +2368,59 @@ FX_BOOL CPDFSDK_Widget::HitTest(FX_FLOAT pageX, FX_FLOAT pageY)
return FALSE;
}
+//CPDFSDK_XFAWidget
+CPDFSDK_XFAWidget::CPDFSDK_XFAWidget(XFA_HWIDGET pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm) :
+ CPDFSDK_Annot(pPageView),
+ m_hXFAWidget(pAnnot),
+ m_pInterForm(pInterForm)
+{
+
+}
+
+FX_BOOL CPDFSDK_XFAWidget::IsXFAField()
+{
+ return TRUE;
+}
+
+CFX_ByteString CPDFSDK_XFAWidget::GetType() const
+{
+ return FSDK_XFAWIDGET_TYPENAME;
+}
+
+CFX_FloatRect CPDFSDK_XFAWidget::GetRect()
+{
+ CPDFSDK_PageView* pPageView = GetPageView();
+ ASSERT(pPageView != NULL);
+
+ CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
+ ASSERT(pDocument != NULL);
+
+ CPDFXFA_Document* pDoc = pDocument->GetDocument();
+ ASSERT(pDoc != NULL);
+
+ IXFA_DocView* pDocView = pDoc->GetXFADocView();
+ ASSERT(pDocView != NULL);
+
+ IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler();
+ ASSERT(pWidgetHandler != NULL);
+
+ CFX_RectF rcBBox;
+ pWidgetHandler->GetRect(GetXFAWidget(), rcBBox);
+
+ return CFX_FloatRect(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, rcBBox.top+rcBBox.height);
+}
+
+//CPDFSDK_InterForm
CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument)
:m_pDocument(pDocument),
m_pInterForm(NULL),
m_bCalculate(TRUE),
+ m_bXfaCalculate(TRUE),
+ m_bXfaValidationsEnabled(TRUE),
m_bBusy(FALSE)
{
ASSERT(m_pDocument != NULL);
- m_pInterForm = new CPDF_InterForm(m_pDocument->GetDocument(), FALSE);
+ m_pInterForm = new CPDF_InterForm(m_pDocument->GetDocument()->GetPDFDoc(), FALSE);
ASSERT(m_pInterForm != NULL);
m_pInterForm->SetFormNotify(this);
@@ -1704,6 +2436,7 @@ CPDFSDK_InterForm::~CPDFSDK_InterForm()
m_pInterForm = NULL;
m_Map.RemoveAll();
+ m_XFAMap.RemoveAll();
}
void CPDFSDK_InterForm::Destroy()
@@ -1730,7 +2463,7 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL b
{
ASSERT(pWidget != NULL);
- CBA_AnnotIterator* pIterator = new CBA_AnnotIterator(pWidget->GetPageView(), "Widget", "");
+ CBA_AnnotIterator* pIterator = new CBA_AnnotIterator(pWidget->GetPageView(), "Widget", "");//XfA?
ASSERT(pIterator != NULL);
CPDFSDK_Widget* pRet = NULL;
@@ -1759,7 +2492,7 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const
ASSERT(pControlDict != NULL);
ASSERT(m_pDocument != NULL);
- CPDF_Document* pDocument = m_pDocument->GetDocument();
+ CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc();
CPDFSDK_PageView* pPage = NULL;
@@ -1852,6 +2585,24 @@ void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl)
m_Map.RemoveKey(pControl);
}
+void CPDFSDK_InterForm::AddXFAMap(XFA_HWIDGET hWidget, CPDFSDK_XFAWidget* pWidget)
+{
+ m_XFAMap.SetAt(hWidget, pWidget);
+}
+
+void CPDFSDK_InterForm::RemoveXFAMap(XFA_HWIDGET hWidget)
+{
+ m_XFAMap.RemoveKey(hWidget);
+}
+
+CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(XFA_HWIDGET hWidget)
+{
+ CPDFSDK_XFAWidget* pWidget = NULL;
+ m_XFAMap.Lookup(hWidget, pWidget);
+
+ return pWidget;
+}
+
void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled)
{
m_bCalculate = bEnabled;
@@ -1862,11 +2613,29 @@ FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const
return m_bCalculate;
}
+void CPDFSDK_InterForm::XfaEnableCalculate(FX_BOOL bEnabled)
+{
+ m_bXfaCalculate = bEnabled;
+}
+FX_BOOL CPDFSDK_InterForm::IsXfaCalculateEnabled() const
+{
+ return m_bXfaCalculate;
+}
+
+FX_BOOL CPDFSDK_InterForm::IsXfaValidationsEnabled()
+{
+ return m_bXfaValidationsEnabled;
+}
+void CPDFSDK_InterForm::XfaSetValidationsEnabled(FX_BOOL bEnabled)
+{
+ m_bXfaValidationsEnabled = bEnabled;
+}
+
#ifdef _WIN32
CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile)
{
ASSERT(m_pDocument != NULL);
- CPDF_Document* pDocument = m_pDocument->GetDocument();
+ CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc();
ASSERT(pDocument != NULL);
CPDF_Stream* pRetStream = NULL;
@@ -2089,7 +2858,7 @@ void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField)
CPDFDoc_Environment * pEnv = m_pDocument->GetEnv();
CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller();
- CPDF_Page * pPage = pWidget->GetPDFPage();
+ CPDFXFA_Page * pPage = pWidget->GetPDFXFAPage();
CPDFSDK_PageView * pPageView = m_pDocument->GetPageView(pPage,FALSE);
FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget);
@@ -2399,6 +3168,27 @@ FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields,F
return bRet;
}
+void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, FX_BOOL bSynchronizeElse)
+{
+ ASSERT(pFormField != NULL);
+
+ int x = 0;
+ if (m_FieldSynchronizeMap.Lookup(pFormField, x))
+ return;
+
+ for (int i=0,sz=pFormField->CountControls(); i<sz; i++)
+ {
+ CPDF_FormControl* pFormCtrl = pFormField->GetControl(i);
+ ASSERT(pFormCtrl != NULL);
+
+ ASSERT(m_pInterForm != NULL);
+ if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl))
+ {
+ pWidget->Synchronize(bSynchronizeElse);
+ }
+ }
+}
+
CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName(const CFX_WideString& sFileExt)
{
CFX_WideString sFileName;
@@ -2621,6 +3411,9 @@ int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField)
ASSERT(pField != NULL);
CPDF_FormField* pFormField = (CPDF_FormField*)pField;
+
+ SynchronizeField(pFormField, FALSE);
+
int nType = pFormField->GetFieldType();
if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD)
@@ -2724,23 +3517,23 @@ int CPDFSDK_InterForm::AfterFormImportData(const CPDF_InterForm* pForm)
FX_BOOL CPDFSDK_InterForm::IsNeedHighLight(int nFieldType)
{
- if(nFieldType <1 || nFieldType > 6)
+ if(nFieldType <1 || nFieldType > 7)
return FALSE;
return m_bNeedHightlight[nFieldType-1];
}
void CPDFSDK_InterForm::RemoveAllHighLight()
{
- memset((void*)m_bNeedHightlight, 0, 6*sizeof(FX_BOOL));
+ memset((void*)m_bNeedHightlight, 0, 7*sizeof(FX_BOOL));
}
void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, int nFieldType)
{
- if(nFieldType <0 || nFieldType > 6) return;
+ if(nFieldType <0 || nFieldType > 7) return;
switch(nFieldType)
{
case 0:
{
- for(int i=0; i<6; i++)
+ for(int i=0; i<7; i++)
{
m_aHighlightColor[i] = clr;
m_bNeedHightlight[i] = TRUE;
@@ -2759,7 +3552,7 @@ void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, int nFieldType)
FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType)
{
- if(nFieldType <0 || nFieldType >6) return FXSYS_RGB(255,255,255);
+ if(nFieldType <0 || nFieldType >7) return FXSYS_RGB(255,255,255);
if(nFieldType == 0)
return m_aHighlightColor[0];
else
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index efb21a7efc..2340ffa720 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -5,10 +5,14 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../include/fsdk_define.h"
+#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "../include/fpdfxfa/fpdfxfa_page.h"
+#include "../include/fpdfxfa/fpdfxfa_util.h"
#include "../include/fsdk_mgr.h"
#include "../include/fpdf_ext.h"
#include "../include/formfiller/FFL_FormFiller.h"
#include "../include/javascript/IJavaScript.h"
+#include "../include/fpdfxfa/fpdfxfa_app.h"
#if _FX_OS_ == _FX_ANDROID_
#include "time.h"
@@ -81,10 +85,10 @@ void CFX_SystemHandler::InvalidateRect(FX_HWND hWnd, FX_RECT rect)
{
//g_pFormFillApp->FFI_Invalidate();
CPDFSDK_Annot* pSDKAnnot = (CPDFSDK_Annot*)hWnd;
- CPDF_Page* pPage = NULL;
+ CPDFXFA_Page* pPage = NULL;
CPDFSDK_PageView* pPageView = NULL;
pPageView = pSDKAnnot->GetPageView();
- pPage = pSDKAnnot->GetPDFPage();
+ pPage = pSDKAnnot->GetPDFXFAPage();
if(!pPage || !pPageView)
return;
CPDF_Matrix page2device;
@@ -114,7 +118,7 @@ void CFX_SystemHandler::OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect)
CPDFSDK_Annot* pAnnot = pFFL->GetSDKAnnot();
ASSERT(pAnnot);
- CPDF_Page* pPage = pAnnot->GetPDFPage();
+ CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage();
ASSERT(pPage);
m_pEnv->FFI_OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y);
}
@@ -212,29 +216,22 @@ FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime()
}
-CJS_RuntimeFactory* GetJSRuntimeFactory()
-{
- static CJS_RuntimeFactory s_JSRuntimeFactory;
- return &s_JSRuntimeFactory;
-}
-CPDFDoc_Environment::CPDFDoc_Environment(CPDF_Document* pDoc) :
+CPDFDoc_Environment::CPDFDoc_Environment(CPDFXFA_Document* pDoc) :
m_pAnnotHandlerMgr(NULL),
m_pActionHandler(NULL),
m_pJSRuntime(NULL),
m_pInfo(NULL),
m_pSDKDoc(NULL),
- m_pPDFDoc(pDoc),
+ m_pDoc(pDoc),
m_pIFormFiller(NULL)
{
m_pSysHandler = NULL;
m_pSysHandler = new CFX_SystemHandler(this);
+ //m_pJSRuntimeFactory = pDoc->GetApp()->GetRuntimeFactory();
- m_pJSRuntimeFactory = NULL;
- m_pJSRuntimeFactory = GetJSRuntimeFactory();
- m_pJSRuntimeFactory->AddRef();
}
CPDFDoc_Environment::~CPDFDoc_Environment()
@@ -245,9 +242,15 @@ CPDFDoc_Environment::~CPDFDoc_Environment()
delete m_pIFormFiller;
m_pIFormFiller = NULL;
}
- if(m_pJSRuntime && m_pJSRuntimeFactory)
- m_pJSRuntimeFactory->DeleteJSRuntime(m_pJSRuntime);
- m_pJSRuntimeFactory->Release();
+
+ if (m_pJSRuntime && FPDFXFA_GetApp()->GetRuntimeFactory())
+ FPDFXFA_GetApp()->GetRuntimeFactory()->DeleteJSRuntime(m_pJSRuntime);
+
+ if (FPDFXFA_GetApp()->m_pEnvList.GetSize() == 0)
+ {
+ FPDFXFA_GetApp()->ReleaseRuntime();
+ FPDFXFA_GetApp()->InitRuntime(TRUE);
+ }
if(m_pSysHandler)
{
@@ -274,9 +277,8 @@ IFXJS_Runtime* CPDFDoc_Environment::GetJSRuntime()
{
if(!IsJSInitiated())
return NULL;
- assert(m_pJSRuntimeFactory);
if(!m_pJSRuntime)
- m_pJSRuntime = m_pJSRuntimeFactory->NewJSRuntime(this);
+ m_pJSRuntime = FPDFXFA_GetApp()->GetRuntimeFactory()->NewJSRuntime(this);
return m_pJSRuntime;
}
@@ -324,7 +326,7 @@ FX_BOOL CPDFDoc_Environment::IsJSInitiated()
return FALSE;
}
-CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv):m_pDoc(pDoc),
+CPDFSDK_Document::CPDFSDK_Document(CPDFXFA_Document* pDoc,CPDFDoc_Environment* pEnv):m_pDoc(pDoc),
m_pInterForm(NULL),m_pEnv(pEnv),m_pOccontent(NULL),m_bChangeMask(FALSE)
{
m_pFocusAnnot = NULL;
@@ -332,14 +334,7 @@ CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv
CPDFSDK_Document::~CPDFSDK_Document()
{
- FX_POSITION pos = m_pageMap.GetStartPosition();
- while (pos) {
- CPDF_Page* pPage = NULL;
- CPDFSDK_PageView* pPageView = NULL;
- m_pageMap.GetNextAssoc(pos, pPage, pPageView);
- delete pPageView;
- }
- m_pageMap.RemoveAll();
+ m_pageMap.RemoveAll();
if(m_pInterForm)
{
m_pInterForm->Destroy();
@@ -363,20 +358,20 @@ void CPDFSDK_Document::InitPageView()
}
}
-void CPDFSDK_Document::AddPageView(CPDF_Page* pPDFPage, CPDFSDK_PageView* pPageView)
+void CPDFSDK_Document::AddPageView(CPDFXFA_Page* pPDFXFAPage, CPDFSDK_PageView* pPageView)
{
- m_pageMap.SetAt(pPDFPage, pPageView);
+ m_pageMap.SetAt(pPDFXFAPage, pPageView);
}
-CPDFSDK_PageView* CPDFSDK_Document::GetPageView(CPDF_Page* pPDFPage, FX_BOOL ReNew)
+CPDFSDK_PageView* CPDFSDK_Document::GetPageView(CPDFXFA_Page* pPDFXFAPage, FX_BOOL ReNew)
{
- CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)m_pageMap.GetValueAt(pPDFPage);
+ CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)m_pageMap.GetValueAt(pPDFXFAPage);
if(pPageView != NULL)
return pPageView;
if(ReNew)
{
- pPageView = new CPDFSDK_PageView(this,pPDFPage);
- m_pageMap.SetAt(pPDFPage, pPageView);
+ pPageView = new CPDFSDK_PageView(this,pPDFXFAPage);
+ m_pageMap.SetAt(pPDFXFAPage, pPageView);
//Delay to load all the annotations, to avoid endless loop.
pPageView->LoadFXAnnots();
}
@@ -386,7 +381,7 @@ CPDFSDK_PageView* CPDFSDK_Document::GetPageView(CPDF_Page* pPDFPage, FX_BOOL ReN
CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView()
{
- CPDF_Page * pPage = (CPDF_Page *)m_pEnv->FFI_GetCurrentPage(m_pDoc);
+ CPDFXFA_Page * pPage = (CPDFXFA_Page *)m_pEnv->FFI_GetCurrentPage(m_pDoc);
if(pPage)
return this->GetPageView(pPage, TRUE);
return NULL;
@@ -395,7 +390,7 @@ CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView()
CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex)
{
CPDFSDK_PageView * pTempPageView = NULL;
- CPDF_Page * pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc,nIndex);
+ CPDFXFA_Page * pTempPage = (CPDFXFA_Page*)m_pEnv->FFI_GetPage(m_pDoc,nIndex);
if(!pTempPage)
return NULL;
@@ -408,8 +403,8 @@ CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex)
void CPDFSDK_Document:: ProcJavascriptFun()
{
- CPDF_Document* pPDFDoc = this->GetDocument();
- CPDF_DocJSActions docJS(pPDFDoc);
+ CPDFXFA_Document* pPDFDoc = this->GetDocument();
+ CPDF_DocJSActions docJS(pPDFDoc->GetPDFDoc());
int iCount = docJS.CountJSActions();
if (iCount < 1) return;
for (int i = 0; i < iCount; i ++)
@@ -426,7 +421,7 @@ FX_BOOL CPDFSDK_Document::ProcOpenAction()
{
if(!m_pDoc) return FALSE;
- CPDF_Dictionary* pRoot = m_pDoc->GetRoot();
+ CPDF_Dictionary* pRoot = m_pDoc->GetPDFDoc()->GetRoot();
if (!pRoot) return FALSE;
CPDF_Object* pOpenAction = pRoot->GetDict("OpenAction");//
if(!pOpenAction) pOpenAction = pRoot->GetArray("OpenAction");//
@@ -453,23 +448,23 @@ FX_BOOL CPDFSDK_Document::ProcOpenAction()
CPDF_OCContext* CPDFSDK_Document::GetOCContext()
{
if(!m_pOccontent)
- m_pOccontent = new CPDF_OCContext(m_pDoc);
+ m_pOccontent = new CPDF_OCContext(m_pDoc->GetPDFDoc());
return m_pOccontent;
}
-void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage)
+void CPDFSDK_Document::ReMovePageView(CPDFXFA_Page* pPDFXFAPage)
{
- CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)m_pageMap.GetValueAt(pPDFPage);
- if(pPageView && !pPageView->IsLocked())
+ CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)m_pageMap.GetValueAt(pPDFXFAPage);
+ if(pPageView)
{
delete pPageView;
- m_pageMap.RemoveKey(pPDFPage);
+ m_pageMap.RemoveKey(pPDFXFAPage);
}
}
-CPDF_Page * CPDFSDK_Document::GetPage(int nIndex)
+CPDFXFA_Page * CPDFSDK_Document::GetPage(int nIndex)
{
- CPDF_Page * pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc,nIndex);
+ CPDFXFA_Page * pTempPage = (CPDFXFA_Page*)m_pEnv->FFI_GetPage(m_pDoc,nIndex);
if(!pTempPage)
return NULL;
return pTempPage;
@@ -486,7 +481,7 @@ void CPDFSDK_Document::UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot*
{
FX_POSITION pos = m_pageMap.GetStartPosition();
- CPDF_Page * pPage = NULL;
+ CPDFXFA_Page * pPage = NULL;
CPDFSDK_PageView * pPageView = NULL;
while(pos)
{
@@ -509,17 +504,24 @@ FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot,FX_UINT nFlag)
if(m_pFocusAnnot==pAnnot) return TRUE;
+ CPDFSDK_Annot* pLastFocusAnnot = m_pFocusAnnot;
+
if(m_pFocusAnnot)
{
if(!this->KillFocusAnnot(nFlag) ) return FALSE;
}
- CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
+ CPDFSDK_PageView* pPageView = NULL;
+ if (pAnnot)
+ pPageView = pAnnot->GetPageView();
if(pAnnot && pPageView->IsValid())
{
CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr();
if(pAnnotHandler&&!m_pFocusAnnot)
{
+ if (!pAnnotHandler->Annot_OnChangeFocus(pAnnot,pLastFocusAnnot))
+ return FALSE;
+
if (!pAnnotHandler->Annot_OnSetFocus(pAnnot,nFlag))
return FALSE;
if(!m_pFocusAnnot)
@@ -541,6 +543,10 @@ FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag)
{
CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot;
m_pFocusAnnot = NULL;
+
+ if (!pAnnotHandler->Annot_OnChangeFocus(NULL, pFocusAnnot))
+ return FALSE;
+
if(pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag))
{
@@ -571,7 +577,7 @@ FX_BOOL CPDFSDK_Document::DeletePages(int nStart, int nCount)
return FALSE;
}
- CPDF_Page * pTempPage = NULL;
+ CPDFXFA_Page * pTempPage = NULL;
for ( int i = nCount-1; i >= 0; i-- )
{
pTempPage = GetPage(nStart+i);
@@ -590,7 +596,7 @@ void CPDFSDK_Document::OnCloseDocument()
FX_BOOL CPDFSDK_Document::GetPermissions(int nFlag)
{
- FX_DWORD dwPermissions = m_pDoc->GetUserPermissions();
+ FX_DWORD dwPermissions = m_pDoc->GetPDFDoc()->GetUserPermissions();
return dwPermissions&nFlag;
}
@@ -607,15 +613,16 @@ CFX_WideString CPDFSDK_Document::GetPath()
}
-CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_page(page),m_pSDKDoc(pSDKDoc)
+CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDFXFA_Page* page):m_page(page),m_pSDKDoc(pSDKDoc)
{
CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm();
if(pInterForm)
{
CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
- pPDFInterForm->FixPageFields(page);
+ if (page->GetPDFPage())
+ pPDFInterForm->FixPageFields(page->GetPDFPage());
}
- m_page->SetPrivateData((FX_LPVOID)m_page, (FX_LPVOID)this, NULL);
+
m_fxAnnotArray.RemoveAll();
m_bEnterWidget = FALSE;
@@ -623,15 +630,13 @@ CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_
m_bOnWidget = FALSE;
m_CaptureWidget = NULL;
m_bValid = FALSE;
- m_bLocked = FALSE;
- m_bTakeOverPage = FALSE;
+ m_pAnnotList = NULL;
}
CPDFSDK_PageView::~CPDFSDK_PageView()
{
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
int nAnnotCount = m_fxAnnotArray.GetSize();
-
for (int i=0; i<nAnnotCount; i++)
{
CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
@@ -648,30 +653,49 @@ CPDFSDK_PageView::~CPDFSDK_PageView()
delete m_pAnnotList;
m_pAnnotList = NULL;
}
- m_page->RemovePrivateData((FX_LPVOID)m_page);
- if(m_bTakeOverPage) {
- delete m_page;
- }
}
-void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions)
+void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions, FX_RECT* pClip)
{
m_curMatrix = *pUser2Device;
-
// m_pAnnotList->DisplayAnnots(m_page, pDevice, pUser2Device, FALSE, pOptions);
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ CPDFXFA_Page* pPage = GetPDFXFAPage();
+
+ if (pPage == NULL) return;
+
+ if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNIMIC_XFA) {
+ CFX_Graphics gs;
+ gs.Create(pDevice);
+ if (pClip) {
+ CFX_RectF rectClip;
+ rectClip.Set(pClip->left, pClip->top, pClip->Width(), pClip->Height());
+ gs.SetClipRect(rectClip);
+ }
+ IXFA_RenderContext* pRenderContext = XFA_RenderContext_Create();
+ if (!pRenderContext)
+ return;
+ CXFA_RenderOptions renderOptions;
+ renderOptions.m_bHighlight = TRUE;
+ pRenderContext->StartRender(pPage->GetXFAPageView(), &gs, *pUser2Device, renderOptions);
+ pRenderContext->DoRender();
+ pRenderContext->StopRender();
+ pRenderContext->Release();
+ return;
+ }
+ // for pdf/static xfa.
CPDFSDK_AnnotIterator annotIterator(this, TRUE);
CPDFSDK_Annot * pSDKAnnot=NULL;
int index=-1;
- while((pSDKAnnot = annotIterator.Next(index)))
+ pSDKAnnot = annotIterator.Next(index);
+ while(pSDKAnnot)
{
CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
ASSERT(pAnnotHandlerMgr);
pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0);
+ pSDKAnnot = annotIterator.Next(index);
}
-
}
-
CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY)
{
@@ -713,11 +737,13 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT page
CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
CPDFSDK_Annot* pSDKAnnot = NULL;
int index = -1;
- while((pSDKAnnot = annotIterator.Next(index)))
+ pSDKAnnot = annotIterator.Next(index);
+ while(pSDKAnnot)
{
CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
if(rc.Contains(pageX, pageY))
return pSDKAnnot;
+ pSDKAnnot = annotIterator.Next(index);
}
return NULL;
@@ -731,9 +757,10 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pag
CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
CPDFSDK_Annot* pSDKAnnot = NULL;
int index = -1;
- while((pSDKAnnot = annotIterator.Next(index)))
+ pSDKAnnot = annotIterator.Next(index);
+ while(pSDKAnnot)
{
- if(pSDKAnnot->GetType() == "Widget")
+ if(pSDKAnnot->GetType() == "Widget" || pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME)
{
pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
CPDF_Point point(pageX, pageY);
@@ -741,6 +768,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pag
// if(rc.Contains(pageX, pageY))
return pSDKAnnot;
}
+ pSDKAnnot = annotIterator.Next(index);
}
return NULL;
@@ -781,6 +809,32 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot * pPDFAnnot)
return pSDKAnnot;
}
+CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(XFA_HWIDGET pPDFAnnot)
+{
+ if (!pPDFAnnot) return NULL;
+
+ CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot);
+ if (pSDKAnnot)
+ return pSDKAnnot;
+
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ ASSERT(pEnv);
+ CPDFSDK_AnnotHandlerMgr * pAnnotHandler= pEnv->GetAnnotHandlerMgr();
+
+ pSDKAnnot =NULL;
+
+ if(pAnnotHandler)
+ {
+ pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this);
+ }
+ if(!pSDKAnnot)
+ return NULL;
+
+ m_fxAnnotArray.Add(pSDKAnnot);
+
+ return pSDKAnnot;
+}
+
CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary * pDict)
{
if(pDict)
@@ -795,21 +849,42 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(FX_LPCSTR lpSubType,CPDF_Dictionary *
FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot)
{
- return FALSE;
+ if (!pAnnot)
+ return FALSE;
+ CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage();
+ if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && pPage->GetDocument()->GetDocType() != DOCTYPE_DYNIMIC_XFA))
+ return FALSE;
+
+ int index = m_fxAnnotArray.Find(pAnnot);
+ m_fxAnnotArray.RemoveAt(index);
+ if (m_CaptureWidget == pAnnot)
+ m_CaptureWidget = NULL;
+
+ return TRUE;
}
CPDF_Document* CPDFSDK_PageView::GetPDFDocument()
{
if(m_page)
{
- return m_page->m_pDocument;
+ return m_page->GetDocument()->GetPDFDoc();
}
return NULL;
}
+CPDF_Page* CPDFSDK_PageView::GetPDFPage()
+{
+ if (m_page)
+ {
+ return m_page->GetPDFPage();
+ }
+
+ return NULL;
+}
+
int CPDFSDK_PageView::CountAnnots()
{
- return m_pAnnotList->Count();
+ return m_fxAnnotArray.GetSize();
}
CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(int nIndex)
@@ -834,6 +909,20 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary * pDict)
}
return NULL;
}
+CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(XFA_HWIDGET hWidget)
+{
+ if (hWidget == NULL)
+ return NULL;
+ int annotCount = m_fxAnnotArray.GetSize();
+
+ for(int i = 0; i < annotCount; i++)
+ {
+ CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
+ if(pAnnot->GetXFAWidget() == hWidget)
+ return pAnnot;
+ }
+ return NULL;
+}
FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag)
{
@@ -859,6 +948,45 @@ FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag)
return FALSE;
}
+FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CPDF_Point & point, FX_UINT nFlag)
+{
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ ASSERT(pEnv);
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+ ASSERT(pAnnotHandlerMgr);
+
+ CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y);
+
+ if (pFXAnnot == NULL)
+ return FALSE;
+
+ FX_BOOL bRet = pAnnotHandlerMgr->Annot_OnRButtonDown(this, pFXAnnot, nFlag,point);
+ if (bRet)
+ {
+ SetFocusAnnot(pFXAnnot);
+ }
+ return TRUE;
+}
+
+FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CPDF_Point & point, FX_UINT nFlag)
+{
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ ASSERT(pEnv);
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+ ASSERT(pAnnotHandlerMgr);
+
+ CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y);
+
+ if (pFXAnnot == NULL)
+ return FALSE;
+
+ FX_BOOL bRet = pAnnotHandlerMgr->Annot_OnRButtonUp(this, pFXAnnot, nFlag,point);
+ if (bRet)
+ {
+ SetFocusAnnot(pFXAnnot);
+ }
+ return TRUE;
+}
FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag)
{
@@ -978,27 +1106,61 @@ extern void CheckUnSupportAnnot(CPDF_Document * pDoc, CPDF_Annot* pPDFAnnot);
void CPDFSDK_PageView::LoadFXAnnots()
{
+ ASSERT(m_page != NULL);
+
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ ASSERT(pEnv != NULL);
- FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled();
- //Disable the default AP construction.
- CPDF_InterForm::EnableUpdateAP(FALSE);
- m_pAnnotList = new CPDF_AnnotList(m_page);
- CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
- int nCount = m_pAnnotList->Count();
- SetLock(TRUE);
- for(int i=0; i<nCount; i++)
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+ ASSERT(pAnnotHandlerMgr != NULL);
+
+ if (m_pSDKDoc->GetDocument()->GetDocType() == DOCTYPE_DYNIMIC_XFA)
{
- CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
- CPDF_Document * pDoc = this->GetPDFDocument();
+ IXFA_PageView* pageView = NULL;
+ pageView = m_page->GetXFAPageView();
+ ASSERT(pageView != NULL);
+
+ XFA_HWIDGET pXFAAnnot = NULL;
+ IXFA_WidgetIterator* pWidgetHander = pageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Visible|XFA_WIDGETFILTER_Viewable|XFA_WIDGETFILTER_AllType);
+ if (!pWidgetHander)
+ return;
+
+ pXFAAnnot = pWidgetHander->MoveToNext();
+ while (pXFAAnnot) {
+ CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pXFAAnnot, this);
+ if(!pAnnot) {
+ pXFAAnnot = pWidgetHander->MoveToNext();
+ continue;
+ }
+ m_fxAnnotArray.Add(pAnnot);
- CheckUnSupportAnnot(pDoc, pPDFAnnot);
+ pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
- CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
- ASSERT(pAnnotHandlerMgr != NULL);
+ pXFAAnnot = pWidgetHander->MoveToNext();
- if(pAnnotHandlerMgr)
+ }
+
+ pWidgetHander->Release();
+ }
+ else
+ {
+ CPDF_Page* pPage = m_page->GetPDFPage();
+ ASSERT(pPage != NULL);
+
+ FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled();
+ //Disable the default AP construction.
+ CPDF_InterForm::EnableUpdateAP(FALSE);
+ m_pAnnotList = new CPDF_AnnotList(pPage);
+ CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
+
+ int nCount = m_pAnnotList->Count();
+ for(int i=0; i<nCount; i++)
{
+ CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
+ CPDF_Document * pDoc = this->GetPDFDocument();
+
+ CheckUnSupportAnnot(pDoc, pPDFAnnot);
+
CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this);
if(!pAnnot)
continue;
@@ -1008,7 +1170,6 @@ void CPDFSDK_PageView::LoadFXAnnots()
}
}
- SetLock(FALSE);
}
void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects)
@@ -1037,11 +1198,11 @@ int CPDFSDK_PageView::GetPageIndex()
{
if(m_page)
{
- CPDF_Dictionary* pDic = m_page->m_pFormDict;
- CPDF_Document* pDoc = m_pSDKDoc->GetDocument();
+ CPDF_Dictionary* pDic = m_page->GetPDFPage()->m_pFormDict;
+ CPDFXFA_Document* pDoc = m_pSDKDoc->GetDocument();
if(pDoc && pDic)
{
- return pDoc->GetPageIndex(pDic->GetObjNum());
+ return pDoc->GetPDFDoc()->GetPageIndex(pDic->GetObjNum());
}
}
return -1;
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index 229d9770a1..fa3b9de75b 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -605,7 +605,7 @@ FX_BOOL Document::mailForm(OBJ_METHOD_PARAMS)
ASSERT(pRuntime != NULL);
pRuntime->BeginBlock();
- pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, (FX_LPCWSTR)cTo, (FX_LPCWSTR)cSubject, (FX_LPCWSTR)cCc, (FX_LPCWSTR)cBcc, (FX_LPCWSTR)cMsg);
+ pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, (FX_LPCWSTR)cTo, (FX_LPCWSTR)cSubject, (FX_LPCWSTR)cCc, (FX_LPCWSTR)cBcc, (FX_LPCWSTR)cMsg);
pRuntime->EndBlock();
return TRUE;
}
@@ -723,7 +723,7 @@ FX_BOOL Document::removeField(OBJ_METHOD_PARAMS)
CFX_RectArray aRefresh;
aRefresh.Add(rcAnnot);
- CPDF_Page* pPage = pWidget->GetPDFPage();
+ CPDFXFA_Page* pPage = pWidget->GetPDFXFAPage();
ASSERT(pPage != NULL);
CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage);
@@ -1009,7 +1009,7 @@ FX_BOOL Document::author(OBJ_PROP_PARAMS)
{
ASSERT(m_pDocument != NULL);
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->GetInfo();
if (!pDictionary)return FALSE;
if (vp.IsGetting())
@@ -1033,7 +1033,7 @@ FX_BOOL Document::info(OBJ_PROP_PARAMS)
{
ASSERT(m_pDocument != NULL);
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->GetInfo();
if (!pDictionary)return FALSE;
CFX_WideString cwAuthor = pDictionary->GetUnicodeText("Author");
@@ -1092,7 +1092,7 @@ FX_BOOL Document::creationDate(OBJ_PROP_PARAMS)
{
ASSERT(m_pDocument != NULL);
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->GetInfo();
if (!pDictionary)return FALSE;
if (vp.IsGetting())
@@ -1117,7 +1117,7 @@ FX_BOOL Document::creator(OBJ_PROP_PARAMS)
{
ASSERT(m_pDocument != NULL);
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->GetInfo();
if (!pDictionary)return FALSE;
if (vp.IsGetting())
@@ -1183,7 +1183,7 @@ FX_BOOL Document::keywords(OBJ_PROP_PARAMS)
{
ASSERT(m_pDocument != NULL);
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->GetInfo();
if (!pDictionary)return FALSE;
if (vp.IsGetting())
@@ -1207,7 +1207,7 @@ FX_BOOL Document::modDate(OBJ_PROP_PARAMS)
{
ASSERT(m_pDocument != NULL);
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->GetInfo();
if (!pDictionary)return FALSE;
if (vp.IsGetting())
@@ -1231,7 +1231,7 @@ FX_BOOL Document::producer(OBJ_PROP_PARAMS)
{
ASSERT(m_pDocument != NULL);
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->GetInfo();
if (!pDictionary)return FALSE;
if (vp.IsGetting())
@@ -1255,7 +1255,7 @@ FX_BOOL Document::subject(OBJ_PROP_PARAMS)
{
ASSERT(m_pDocument != NULL);
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->GetInfo();
if (!pDictionary)return FALSE;
if (vp.IsGetting())
@@ -1282,7 +1282,7 @@ FX_BOOL Document::title(OBJ_PROP_PARAMS)
if (m_pDocument == NULL || m_pDocument->GetDocument() == NULL)
return FALSE;
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetPDFDoc()->GetInfo();
if (!pDictionary)return FALSE;
if (vp.IsGetting())
@@ -1874,7 +1874,7 @@ FX_BOOL Document::getPageNthWord(OBJ_METHOD_PARAMS)
int nWordNo = params.GetSize() > 1 ? (int)params[1] : 0;
bool bStrip = params.GetSize() > 2 ? (bool)params[2] : true;
- CPDF_Document* pDocument = m_pDocument->GetDocument();
+ CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc();
if (!pDocument) return FALSE;
if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
@@ -1945,7 +1945,7 @@ FX_BOOL Document::getPageNumWords(OBJ_METHOD_PARAMS)
int nPageNo = params.GetSize() > 0 ? (int)params[0] : 0;
- CPDF_Document* pDocument = m_pDocument->GetDocument();
+ CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc();
ASSERT(pDocument != NULL);
if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp
index f5f9bf0539..c484cbb1fd 100644
--- a/fpdfsdk/src/javascript/Field.cpp
+++ b/fpdfsdk/src/javascript/Field.cpp
@@ -3820,7 +3820,7 @@ FX_BOOL Field::setFocus(OBJ_METHOD_PARAMS)
{
CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
ASSERT(pEnv);
- CPDF_Page* pPage = (CPDF_Page*)pEnv->FFI_GetCurrentPage(m_pDocument->GetDocument());
+ CPDFXFA_Page* pPage = (CPDFXFA_Page*)pEnv->FFI_GetCurrentPage(m_pDocument->GetDocument());
if(!pPage)
return FALSE;
if (CPDFSDK_PageView* pCurPageView = m_pDocument->GetPageView(pPage))
diff --git a/fpdfsdk/src/javascript/JS_Context.cpp b/fpdfsdk/src/javascript/JS_Context.cpp
index a83e1e057d..31969e4858 100644
--- a/fpdfsdk/src/javascript/JS_Context.cpp
+++ b/fpdfsdk/src/javascript/JS_Context.cpp
@@ -107,6 +107,7 @@ FX_BOOL CJS_Context::DoJob(int nMode, const CFX_WideString& script, CFX_WideStri
FX_BOOL CJS_Context::RunScript(const CFX_WideString& script, CFX_WideString& info)
{
v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate());
+ v8::Locker locker(m_pRuntime->GetIsolate());
v8::HandleScope handle_scope(m_pRuntime->GetIsolate());
v8::Local<v8::Context> context = m_pRuntime->NewJSContext();
v8::Context::Scope context_scope(context);
diff --git a/fpdfsdk/src/javascript/JS_GlobalData.cpp b/fpdfsdk/src/javascript/JS_GlobalData.cpp
index 83771dfe57..2207726890 100644
--- a/fpdfsdk/src/javascript/JS_GlobalData.cpp
+++ b/fpdfsdk/src/javascript/JS_GlobalData.cpp
@@ -117,7 +117,7 @@ static const FX_BYTE JS_RC4KEY[] = {0x19,0xa8,0xe8,0x01,0xf6,0xa8,0xb6,0x4d,0x82
0x55,0x8b,0x6e,0x6b,0x19,0xa0,0xf8,0x77,0xd5,0xa3
};
-CJS_GlobalData::CJS_GlobalData(CPDFDoc_Environment* pApp)
+CJS_GlobalData::CJS_GlobalData(CPDFDoc_Environment* pApp) : m_pApp(pApp)
{
// IBaseAnnot* pBaseAnnot = IBaseAnnot::GetBaseAnnot(m_pApp);
// ASSERT(pBaseAnnot != NULL);
diff --git a/fpdfsdk/src/javascript/JS_Object.cpp b/fpdfsdk/src/javascript/JS_Object.cpp
index 3b7774d4d8..09150e796b 100644
--- a/fpdfsdk/src/javascript/JS_Object.cpp
+++ b/fpdfsdk/src/javascript/JS_Object.cpp
@@ -16,7 +16,7 @@ int FXJS_MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, FX_LPCWS
{
int nRet = 0;
- if(pApp)
+ if (pApp)
{
CPDFSDK_Document* pDoc = pApp->GetCurrentDoc();
if(pDoc)
@@ -65,7 +65,7 @@ void CJS_EmbedObj::Alert(CJS_Context* pContext, FX_LPCWSTR swMsg)
CJS_Object::Alert(pContext, swMsg);
}
-CJS_Timer* CJS_EmbedObj::BeginTimer(CPDFDoc_Environment * pApp,FX_UINT nElapse)
+CJS_Timer* CJS_EmbedObj::BeginTimer(CPDFDoc_Environment* pApp, FX_UINT nElapse)
{
CJS_Timer* pTimer = new CJS_Timer(this,pApp);
pTimer->SetJSTimer(nElapse);
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index d7802b572e..269f23bbd7 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -26,6 +26,12 @@
#include "../../include/javascript/JS_GlobalData.h"
#include "../../include/javascript/global.h"
#include "../../include/javascript/console.h"
+#include "../../include/fpdfxfa/fpdfxfa_app.h"
+#ifndef FOXIT_CHROME_BUILD
+#include "../../../fxjse/value.h"
+#else
+#include "../../../xfa/src/fxjse/src/value.h"
+#endif
#include <libplatform/libplatform.h>
@@ -101,16 +107,26 @@ void CJS_RuntimeFactory::ReleaseGlobalData()
}
/* ------------------------------ CJS_Runtime ------------------------------ */
-
-CJS_Runtime::CJS_Runtime(CPDFDoc_Environment * pApp) :
+extern v8::Persistent<v8::ObjectTemplate>& _getGlobalObjectTemplate(IJS_Runtime* pJSRuntime);
+CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) :
m_pApp(pApp),
m_pDocument(NULL),
m_bBlocking(FALSE),
m_pFieldEventPath(NULL),
m_bRegistered(FALSE)
{
- m_isolate = v8::Isolate::New();
+ m_isolate = FPDFXFA_GetApp()->GetJSERuntime()?(v8::Isolate*)FPDFXFA_GetApp()->GetJSERuntime():v8::Isolate::New();
//m_isolate->Enter();
+ v8::Isolate* isolate = m_isolate;
+ v8::Isolate::Scope isolate_scope(isolate);
+ v8::Locker locker(isolate);
+ v8::HandleScope handle_scope(isolate);
+ if (FPDFXFA_GetApp()->InitRuntime(FALSE)) {
+ CJS_Context * pContext = (CJS_Context*)NewContext();
+ JS_InitialRuntime(*this, this, pContext, m_context);
+ ReleaseContext(pContext);
+ return;
+ }
InitJSObjects();
@@ -121,12 +137,13 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment * pApp) :
CJS_Runtime::~CJS_Runtime()
{
- for (int i=0, sz=m_ContextArray.GetSize(); i<sz; i++)
+ int size = m_ContextArray.GetSize();
+ for (int i=0;i < size; i++)
delete m_ContextArray.GetAt(i);
m_ContextArray.RemoveAll();
- JS_ReleaseRuntime(*this, m_context);
+ //JS_ReleaseRuntime(*this, m_context);
RemoveEventsInLoop(m_pFieldEventPath);
@@ -136,12 +153,14 @@ CJS_Runtime::~CJS_Runtime()
m_context.Reset();
//m_isolate->Exit();
- m_isolate->Dispose();
+ //m_isolate->Dispose();
+ m_isolate = NULL;
}
FX_BOOL CJS_Runtime::InitJSObjects()
{
v8::Isolate::Scope isolate_scope(GetIsolate());
+ v8::Locker locker(GetIsolate());
v8::HandleScope handle_scope(GetIsolate());
v8::Handle<v8::Context> context = v8::Context::New(GetIsolate());
v8::Context::Scope context_scope(context);
@@ -215,6 +234,7 @@ void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc)
if (m_pDocument != pReaderDoc)
{
v8::Isolate::Scope isolate_scope(m_isolate);
+ v8::Locker locker(m_isolate);
v8::HandleScope handle_scope(m_isolate);
v8::Local<v8::Context> context =v8::Local<v8::Context>::New(m_isolate, m_context);
v8::Context::Scope context_scope(context);
@@ -476,3 +496,45 @@ void CJS_Runtime::Enter()
{
if(m_isolate) m_isolate->Enter();
}
+FX_BOOL CJS_Runtime::GetHValueByName(FX_BSTR utf8Name, FXJSE_HVALUE hValue)
+{
+ FX_LPCSTR name = utf8Name.GetCStr();
+
+ v8::Locker lock(GetIsolate());
+ v8::Isolate::Scope isolate_scope(GetIsolate());
+ v8::HandleScope handle_scope(GetIsolate());
+ v8::Local<v8::Context> context =
+ v8::Local<v8::Context>::New(GetIsolate(), m_context);
+ v8::Context::Scope context_scope(context);
+
+
+ //v8::Local<v8::Context> tmpCotext = v8::Local<v8::Context>::New(GetIsolate(), m_context);
+ v8::Local<v8::Value> propvalue = context->Global()->Get(v8::String::NewFromUtf8(GetIsolate(), name, v8::String::kNormalString, utf8Name.GetLength()));
+
+ if (propvalue.IsEmpty()) {
+ FXJSE_Value_SetUndefined(hValue);
+ return FALSE;
+ }
+ ((CFXJSE_Value*)hValue)->ForceSetValue(propvalue);
+
+ return TRUE;
+}
+FX_BOOL CJS_Runtime::SetHValueByName(FX_BSTR utf8Name, FXJSE_HVALUE hValue)
+{
+ if (utf8Name.IsEmpty() || hValue == NULL)
+ return FALSE;
+ FX_LPCSTR name = utf8Name.GetCStr();
+ v8::Isolate* pIsolate = GetIsolate();
+ v8::Locker lock(pIsolate);
+ v8::Isolate::Scope isolate_scope(pIsolate);
+ v8::HandleScope handle_scope(pIsolate);
+ v8::Local<v8::Context> context =
+ v8::Local<v8::Context>::New(pIsolate, m_context);
+ v8::Context::Scope context_scope(context);
+
+ //v8::Local<v8::Context> tmpCotext = v8::Local<v8::Context>::New(GetIsolate(), m_context);
+ v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New(GetIsolate(),((CFXJSE_Value*)hValue)->DirectGetValue());
+ context->Global()->Set(v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString, utf8Name.GetLength()), propvalue);
+
+ return TRUE;
+}
diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp
index 1c4da08ccb..42692382c8 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -68,6 +68,7 @@ CJS_Timer* TimerObj::GetTimer() const
#define JS_STR_PLATFORM L"WIN"
#define JS_STR_LANGUANGE L"ENU"
#define JS_STR_VIEWERVERSION 8
+#define JS_STR_VIEWERVERSION_XFA 11
#define JS_NUM_FORMSVERSION 7
#define JS_FILEPATH_MAXLEN 2000
@@ -152,8 +153,8 @@ FX_BOOL app::activeDocs(OBJ_PROP_PARAMS)
CJS_Array aDocs(pRuntime->GetIsolate());
// int iNumDocs = pApp->CountDocuments();
-// for(int iIndex = 0; iIndex<iNumDocs; iIndex++)
-// {
+// for(int iIndex = 0; iIndex<iNumDocs; iIndex++)
+// {
CPDFSDK_Document* pDoc = pApp->GetCurrentDoc();
if (pDoc)
{
@@ -209,10 +210,10 @@ FX_BOOL app::calculate(OBJ_PROP_PARAMS)
ASSERT(pRuntime != NULL);
CJS_Array aDocs(pRuntime->GetIsolate());
-// int iNumDocs = pApp->CountDocuments();
+// int iNumDocs = pApp->CountDocuments();
//
-// for (int iIndex = 0;iIndex < iNumDocs; iIndex++)
-// {
+// for (int iIndex = 0;iIndex < iNumDocs; iIndex++)
+// {
if (CPDFSDK_Document* pDoc = pApp->GetCurrentDoc())
{
CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDoc->GetInterForm();
@@ -278,7 +279,19 @@ FX_BOOL app::viewerVersion(OBJ_PROP_PARAMS)
{
if (vp.IsGetting())
{
- vp << JS_STR_VIEWERVERSION;
+ CJS_Context* pContext = (CJS_Context *)cc;
+ ASSERT(pContext != NULL);
+
+ CPDFDoc_Environment* pApp = pContext->GetReaderApp();
+ ASSERT(pApp != NULL);
+
+ CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument();
+
+ CPDFXFA_Document* pDoc = pCurDoc->GetDocument();
+ if (pDoc->GetDocType() == 1 || pDoc->GetDocType() == 2)
+ vp << JS_STR_VIEWERVERSION_XFA;
+ else
+ vp << JS_STR_VIEWERVERSION;
return TRUE;
}
diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp
index 295a8d49af..6bf0861e1a 100644
--- a/fpdfsdk/src/javascript/global.cpp
+++ b/fpdfsdk/src/javascript/global.cpp
@@ -13,6 +13,7 @@
#include "../../include/javascript/global.h"
#include "../../include/javascript/JS_EventHandler.h"
#include "../../include/javascript/JS_Context.h"
+#include "../../include/fpdfxfa/fpdfxfa_app.h"
/* ---------------------------- global ---------------------------- */
@@ -54,7 +55,7 @@ global_alternate::~global_alternate(void)
// CommitGlobalPersisitentVariables();
DestroyGlobalPersisitentVariables();
- CJS_RuntimeFactory* pFactory = m_pApp->m_pJSRuntimeFactory;
+ CJS_RuntimeFactory* pFactory = FPDFXFA_GetApp()->GetRuntimeFactory();
ASSERT(pFactory);
pFactory->ReleaseGlobalData();
@@ -64,7 +65,7 @@ void global_alternate::Initial(CPDFDoc_Environment* pApp)
{
m_pApp = pApp;
- CJS_RuntimeFactory* pFactory = pApp->m_pJSRuntimeFactory;
+ CJS_RuntimeFactory* pFactory = FPDFXFA_GetApp()->GetRuntimeFactory();
ASSERT(pFactory);
m_pGlobalData = pFactory->NewGlobalData(pApp);
UpdateGlobalPersistentVariables();
diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp
index 5eb9873f5c..dcad30edaf 100644
--- a/fpdfsdk/src/jsapi/fxjs_v8.cpp
+++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp
@@ -76,11 +76,11 @@ int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE e
v8::Isolate* isolate = (v8::Isolate*)pJSRuntime;
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1);
if(!pArray)
{
pArray = FX_NEW CFX_PtrArray();
- isolate->SetData(0, pArray);
+ isolate->SetData(1, pArray);
}
CJS_ObjDefintion* pObjDef = FX_NEW CJS_ObjDefintion(isolate, sObjName, eObjType, pConstructor, pDestructor, bApplyNew);
pArray->Add(pObjDef);
@@ -96,7 +96,7 @@ int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* s
CFX_WideString ws = CFX_WideString((FX_LPCWSTR)sMethodName);
CFX_ByteString bsMethodName = ws.UTF8Encode();
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1);
if(!pArray) return 0;
if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return 0;
@@ -116,7 +116,7 @@ int JS_DefineObjProperty(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t*
CFX_WideString ws = CFX_WideString((FX_LPCWSTR)sPropName);
CFX_ByteString bsPropertyName = ws.UTF8Encode();
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1);
if(!pArray) return 0;
if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return 0;
@@ -133,7 +133,7 @@ int JS_DefineObjAllProperties(IJS_Runtime* pJSRuntime, int nObjDefnID, v8::Named
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1);
if(!pArray) return 0;
if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return 0;
@@ -150,7 +150,7 @@ int JS_DefineObjConst(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sC
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1);
if(!pArray) return 0;
CFX_WideString ws = CFX_WideString((FX_LPCWSTR)sConstName);
@@ -170,7 +170,7 @@ static v8::Persistent<v8::ObjectTemplate>& _getGlobalObjectTemplate(IJS_Runtime*
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1);
ASSERT(pArray != NULL);
for(int i=0; i<pArray->GetSize(); i++)
{
@@ -234,16 +234,18 @@ void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_
{
v8::Isolate* isolate = (v8::Isolate*)pJSRuntime;
v8::Isolate::Scope isolate_scope(isolate);
+ v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
v8::Persistent<v8::ObjectTemplate>& globalObjTemp = _getGlobalObjectTemplate(pJSRuntime);
v8::Handle<v8::Context> v8Context = v8::Context::New(isolate, NULL, v8::Local<v8::ObjectTemplate>::New(isolate, globalObjTemp));
v8::Context::Scope context_scope(v8Context);
- v8::Handle<v8::External> ptr = v8::External::New(isolate, pFXRuntime);
- v8Context->SetEmbedderData(1, ptr);
+ //v8::Handle<External> ptr = External::New(isolate, pFXRuntime);
+ //v8Context->SetEmbedderData(1, ptr);
+ isolate->SetData(2, pFXRuntime);
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1);
if(!pArray) return;
for(int i=0; i<pArray->GetSize(); i++)
@@ -257,7 +259,8 @@ void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_
if(pObjDef->objType == JS_DYNAMIC)
{
//Document is set as global object, need to construct it first.
- if(ws.Equal(L"Document"))
+ CFX_WideString wsString(L"Document");
+ if(ws.Equal(wsString))
{
CJS_PrivateData* pPrivateData = FX_NEW CJS_PrivateData;
@@ -284,11 +287,10 @@ void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, v8::Persistent<v8::Context>& v8P
{
v8::Isolate* isolate = (v8::Isolate*)pJSRuntime;
v8::Isolate::Scope isolate_scope(isolate);
+ v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
- v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate, v8PersistentContext);
- v8::Context::Scope context_scope(context);
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1);
if(!pArray) return ;
for(int i=0; i<pArray->GetSize(); i++)
@@ -304,14 +306,15 @@ void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, v8::Persistent<v8::Context>& v8P
delete pObjDef;
}
delete pArray;
- isolate->SetData(0,NULL);
+ isolate->SetData(1,NULL);
+ isolate->SetData(2,NULL);
}
void JS_Initial()
{
-#ifndef FOXIT_CHROME_BUILD
- v8::V8::InitializeICU();
-#endif
+//#ifndef FOXIT_CHROME_BUILD
+// v8::V8::InitializeICU();
+//#endif
}
void JS_Release()
{
@@ -368,7 +371,7 @@ v8::Handle<v8::Object> JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime, IFXJS_Context
return objTempl->NewInstance();
}
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1);
if(!pArray) return v8::Handle<v8::Object>();
@@ -396,7 +399,7 @@ v8::Handle<v8::Object> JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID)
v8::Isolate* isolate = (v8::Isolate*)pJSRuntime;
v8::Isolate::Scope isolate_scope(isolate);
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1);
if(!pArray) return v8::Handle<v8::Object>();
if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return v8::Handle<v8::Object>();
@@ -415,7 +418,7 @@ v8::Handle<v8::Object> JS_GetThisObj(IJS_Runtime * pJSRuntime)
v8::Isolate* isolate = (v8::Isolate*)pJSRuntime;
v8::Isolate::Scope isolate_scope(isolate);
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1);
if(!pArray) return v8::Handle<v8::Object>();
v8::Local<v8::Context> context = isolate->GetCurrentContext();
@@ -445,7 +448,7 @@ int JS_GetObjDefnID(IJS_Runtime * pJSRuntime, const wchar_t* pObjName)
v8::Isolate* isolate = (v8::Isolate*)pJSRuntime;
v8::Isolate::Scope isolate_scope(isolate);
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0);
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1);
if(!pArray) return -1;
for(int i=0; i<pArray->GetSize(); i++)
@@ -464,12 +467,12 @@ void JS_Error(v8::Value * pError,const wchar_t * main,const wchar_t * sub)
unsigned JS_CalcHash(const wchar_t* main, unsigned nLen)
{
- return (unsigned)FX_HashCode_String_GetW(main, nLen);
+ return (unsigned)FX_HashCode_String_GetW((FX_LPCWSTR)main, nLen);
}
unsigned JS_CalcHash(const wchar_t* main)
{
- return (unsigned)FX_HashCode_String_GetW(main, FXSYS_wcslen(main));
+ return (unsigned)FX_HashCode_String_GetW((FX_LPCWSTR)main, FXSYS_wcslen(main));
}
const wchar_t* JS_GetTypeof(v8::Handle<v8::Value> pObj)
{
diff --git a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
index 01810ffd7a..744118fb9c 100644
--- a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
@@ -502,6 +502,10 @@ void CPWL_ComboBox::SetPopup(FX_BOOL bPopup)
{
if (m_pFillerNotify)
{
+ FX_BOOL bExit = FALSE;
+ m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, 0);
+ if (bExit) return;
+
FX_INT32 nWhere = 0;
FX_FLOAT fPopupRet = 0.0f;
FX_FLOAT fPopupMin = 0.0f;
@@ -529,6 +533,10 @@ void CPWL_ComboBox::SetPopup(FX_BOOL bPopup)
m_nPopupWhere = nWhere;
Move(rcWindow, TRUE, TRUE);
+
+ bExit = FALSE;
+ m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, 0);
+ if (bExit) return;
}
}
}
@@ -552,6 +560,15 @@ FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag)
if (m_pList->GetCurSel() > 0)
{
FX_BOOL bExit = FALSE;
+
+ if (m_pFillerNotify)
+ {
+ m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
+ if (bExit) return FALSE;
+ bExit = FALSE;
+ m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
+ if (bExit) return FALSE;
+ }
if (m_pList->OnKeyDownWithExit(nChar,bExit,nFlag))
{
if (bExit) return FALSE;
@@ -563,6 +580,15 @@ FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag)
if (m_pList->GetCurSel() < m_pList->GetCount() - 1)
{
FX_BOOL bExit = FALSE;
+
+ if (m_pFillerNotify)
+ {
+ m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
+ if (bExit) return FALSE;
+ bExit = FALSE;
+ m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
+ if (bExit) return FALSE;
+ }
if (m_pList->OnKeyDownWithExit(nChar,bExit,nFlag))
{
if (bExit) return FALSE;
@@ -592,6 +618,16 @@ FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag)
}
else
{
+ if (m_pFillerNotify)
+ {
+ bExit = FALSE;
+ m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
+ if (bExit) return FALSE;
+
+ bExit = FALSE;
+ m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
+ if (bExit) return FALSE;
+ }
if (m_pList->OnCharWithExit(nChar,bExit,nFlag))
{
return bExit;