diff options
Diffstat (limited to 'fpdfsdk/include')
32 files changed, 1675 insertions, 118 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 |