summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/include/fpdfxfa/fpdfxfa_app.h194
-rw-r--r--fpdfsdk/src/fpdf_dataavail.cpp5
-rw-r--r--fpdfsdk/src/fpdfeditpage.cpp5
-rw-r--r--fpdfsdk/src/fpdfformfill.cpp75
-rw-r--r--fpdfsdk/src/fpdfsave.cpp9
-rw-r--r--fpdfsdk/src/fpdfview.cpp45
-rw-r--r--fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp944
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp52
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp6
-rw-r--r--fpdfsdk/src/javascript/global.cpp11
-rw-r--r--xfa/include/fxfa/fxfa.h133
-rw-r--r--xfa/src/fxfa/src/app/xfa_ffapp.cpp7
-rw-r--r--xfa/src/fxfa/src/app/xfa_ffapp.h7
-rw-r--r--xfa/src/fxfa/src/app/xfa_fontmgr.cpp7
-rw-r--r--xfa/src/fxfa/src/app/xfa_fontmgr.h6
15 files changed, 690 insertions, 816 deletions
diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h
index a2bc2cc5a7..37a7ec17a5 100644
--- a/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h
+++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h
@@ -1,140 +1,82 @@
// 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_
+#ifndef FPDFXFA_APP_H_
+#define FPDFXFA_APP_H_
-class CPDFXFA_App;
class IFXJS_Runtime;
class CJS_RuntimeFactory;
class CPDFXFA_App : public IXFA_AppProvider
{
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;
+ static CPDFXFA_App* GetInstance();
+ static void ReleaseInstance();
+
+ CPDFXFA_App();
+ ~CPDFXFA_App() override;
+
+ FX_BOOL Initialize();
+ IXFA_App* GetXFAApp() { return m_pXFAApp; }
+
+ 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);
+
+ CJS_RuntimeFactory* GetRuntimeFactory() { return m_pJSRuntimeFactory; }
+
+ // IFXA_AppProvider:
+ void GetAppType(CFX_WideString &wsAppType) override;
+ void SetAppType(FX_WSTR wsAppType) override;
+
+ void GetLanguage(CFX_WideString &wsLanguage) override;
+ void GetPlatform(CFX_WideString &wsPlatform) override;
+ void GetVariation(CFX_WideString &wsVariation) override;
+ void GetVersion(CFX_WideString &wsVersion) override;
+ void GetFoxitVersion(CFX_WideString &wsFoxitVersion) override {
+ wsFoxitVersion = L"7.0";
+ }
+
+ void GetAppName(CFX_WideString& wsName) override;
+ void GetFoxitAppName(CFX_WideString& wsFoxitName) override {
+ wsFoxitName = L"Foxit";
+ }
+
+ void Beep(FX_DWORD dwType) override;
+ FX_INT32 MsgBox(FX_WSTR wsMessage, FX_WSTR wsTitle, FX_DWORD dwIconType, FX_DWORD dwButtonType) override;
+ void Response(CFX_WideString &wsAnswer, FX_WSTR wsQuestion, FX_WSTR wsTitle,
+ FX_WSTR wsDefaultAnswer, FX_BOOL bMark) override;
+
+ FX_INT32 GetDocumentCountInBatch() override;
+ FX_INT32 GetCurDocumentInBatch() override;
+
+ IFX_FileRead* DownloadURL(FX_WSTR wsURL) override;
+ FX_BOOL PostRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_WSTR wsContentType,
+ FX_WSTR wsEncode, FX_WSTR wsHeader, CFX_WideString &wsResponse) override;
+ FX_BOOL PutRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_WSTR wsEncode) override;
+
+ void LoadString(FX_INT32 iStringID, CFX_WideString &wsString) override;
+ FX_BOOL ShowFileDialog(FX_WSTR wsTitle, FX_WSTR wsFilter, CFX_WideStringArray &wsPathArr, FX_BOOL bOpen) override;
+ IFWL_AdapterTimerMgr* GetTimerMgr() override;
+
+ CFX_ArrayTemplate<CPDFDoc_Environment*> m_pEnvList;
+
+protected:
+ static CPDFXFA_App* g_pApp;
+
+ FX_BOOL m_bInitRuntime;
+ IXFA_App* m_pXFAApp;
+ IXFA_FontMgr* m_pFontMgr;
+ FXJSE_HRUNTIME m_hJSERuntime;
+ IFXJS_Runtime* m_pJSRuntime;
+ CJS_RuntimeFactory* m_pJSRuntimeFactory;
+ CFX_WideString m_csAppType;
};
-CPDFXFA_App* FPDFXFA_GetApp();
-void FPDFXFA_ReleaseApp();
-
-#endif
+#endif // FPDFXFA_APP_H_
diff --git a/fpdfsdk/src/fpdf_dataavail.cpp b/fpdfsdk/src/fpdf_dataavail.cpp
index f3fd42a369..a87ebecf90 100644
--- a/fpdfsdk/src/fpdf_dataavail.cpp
+++ b/fpdfsdk/src/fpdf_dataavail.cpp
@@ -137,11 +137,8 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYT
((CFPDF_DataAvail*)avail)->m_pDataAvail->SetDocument(pParser->GetDocument());
CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS);
CPDF_Document* pPDFDoc = pParser->GetDocument();
-
- CPDFXFA_App* pApp = FPDFXFA_GetApp();
+ CPDFXFA_App* pApp = CPDFXFA_App::GetInstance();
CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pApp);
- //pDocument->LoadXFADoc();
-
return pDocument;
}
diff --git a/fpdfsdk/src/fpdfeditpage.cpp b/fpdfsdk/src/fpdfeditpage.cpp
index f371f82df3..2fdc7de3f5 100644
--- a/fpdfsdk/src/fpdfeditpage.cpp
+++ b/fpdfsdk/src/fpdfeditpage.cpp
@@ -39,7 +39,7 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument()
}
}
}
-
+
CPDF_Dictionary* pInfoDict = NULL;
pInfoDict = pDoc->GetInfo();
if (pInfoDict)
@@ -49,9 +49,8 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument()
pInfoDict->SetAt("Creator",FX_NEW CPDF_String(L"PDFium"));
}
- CPDFXFA_App* pApp = FPDFXFA_GetApp();
+ CPDFXFA_App* pApp = CPDFXFA_App::GetInstance();
CPDFXFA_Document* document = FX_NEW CPDFXFA_Document(pDoc, pApp);
-
return document;
}
diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp
index 7482871527..8cb0de0e6e 100644
--- a/fpdfsdk/src/fpdfformfill.cpp
+++ b/fpdfsdk/src/fpdfformfill.cpp
@@ -96,7 +96,7 @@ DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT
return NULL;
pEnv->RegAppHandle(formInfo);
- CPDFXFA_App* pApp = FPDFXFA_GetApp();
+ CPDFXFA_App* pApp = CPDFXFA_App::GetInstance();
pApp->AddFormFillEnv(pEnv);
if(pEnv->GetPDFXFADocument())
@@ -113,16 +113,8 @@ DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT
DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle)
{
if (!hHandle)
- return;
- //CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc();
- //if(pSDKDoc)
- //{
- //((CPDFDoc_Environment*)hHandle)->SetCurrentDoc(NULL);
- //CPDFXFA_Document* pDoc = ((CPDFDoc_Environment*)hHandle)->GetPDFXFADocument();
- //if (pDoc)
- // pDoc->ReleaseSDKDoc();
- //}
- CPDFXFA_App* pApp = FPDFXFA_GetApp();
+ return;
+ CPDFXFA_App* pApp = CPDFXFA_App::GetInstance();
pApp->RemoveFormFillEnv((CPDFDoc_Environment*)hHandle);
delete (CPDFDoc_Environment*)hHandle;
hHandle = NULL;
@@ -351,14 +343,12 @@ DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, FPDF_WIDGET hWid
{
if (NULL == hWidget || NULL == document)
return;
-
- CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
return;
- IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
-
+ IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler();
if (pXFAMenuHander == NULL)
return;
@@ -369,13 +359,12 @@ DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, FPDF_WIDGET hWid
{
if (NULL == hWidget || NULL == document)
return;
-
- CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
return;
- IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
-
+ IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler();
if (pXFAMenuHander == NULL)
return;
@@ -386,13 +375,12 @@ DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, FPDF_WIDGET
{
if (NULL == hWidget || NULL == document)
return;
-
- CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
return;
- IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
-
+ IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler();
if (pXFAMenuHander == NULL)
return;
@@ -402,13 +390,12 @@ DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, FPDF_WIDGET hWid
{
if (NULL == hWidget || NULL == document)
return;
-
- CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
return;
- IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
-
+ IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler();
if (pXFAMenuHander == NULL)
return;
@@ -416,9 +403,7 @@ DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, FPDF_WIDGET hWid
pXFAMenuHander->Copy((XFA_HWIDGET)hWidget, wsCpText);
CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode();
-
int len = bsCpText.GetLength()/sizeof(unsigned short);
-
if (wsText == NULL) {
*size = len;
return;
@@ -436,13 +421,11 @@ DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, FPDF_WIDGET hWidg
{
if (NULL == hWidget || NULL == document)
return;
-
- CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
return;
- IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
-
+ IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler();
if (pXFAMenuHander == NULL)
return;
@@ -450,9 +433,7 @@ DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, FPDF_WIDGET hWidg
pXFAMenuHander->Cut((XFA_HWIDGET)hWidget, wsCpText);
CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode();
-
int len = bsCpText.GetLength()/sizeof(unsigned short);
-
if (wsText == NULL) {
*size = len;
return;
@@ -470,18 +451,16 @@ DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document, FPDF_WIDGET hWi
{
if (NULL == hWidget || NULL == document)
return;
-
- CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
return;
- IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
-
+ IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler();
if (pXFAMenuHander == NULL)
return;
CFX_WideString wstr = CFX_WideString::FromUTF16LE(wsText, size);
-
pXFAMenuHander->Paste((XFA_HWIDGET)hWidget, wstr);
}
@@ -489,20 +468,19 @@ DLLEXPORT void STDCALL FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document,
{
if (NULL == hWidget || NULL == document)
return;
-
- CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
return;
- IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
-
+ IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler();
if (pXFAMenuHander == NULL)
return;
CFX_PointF ptPopup;
ptPopup.x = x;
ptPopup.y = y;
- CFX_ByteStringC bs(bsText);
+ CFX_ByteStringC bs(bsText);
pXFAMenuHander->ReplaceSpellCheckWord((XFA_HWIDGET)hWidget,ptPopup,bs);
}
@@ -510,13 +488,12 @@ DLLEXPORT void STDCALL FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, FP
{
if (NULL == hWidget || NULL == document)
return;
-
- CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
+
+ CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static)
return;
- IXFA_MenuHandler* pXFAMenuHander = FPDFXFA_GetApp()->GetXFAApp()->GetMenuHandler();
-
+ IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler();
if (pXFAMenuHander == NULL)
return;
diff --git a/fpdfsdk/src/fpdfsave.cpp b/fpdfsdk/src/fpdfsave.cpp
index 0be1709f37..b3ab2f0df9 100644
--- a/fpdfsdk/src/fpdfsave.cpp
+++ b/fpdfsdk/src/fpdfsave.cpp
@@ -67,17 +67,18 @@ FX_BOOL _SaveXFADocumentData(CPDFXFA_Document* pDocument, CFX_PtrArray& fileList
return FALSE;
if (pDocument->GetDocType() != DOCTYPE_DYNIMIC_XFA && pDocument->GetDocType() != DOCTYPE_STATIC_XFA)
return TRUE;
- if (!FPDFXFA_GetApp()->GetXFAApp())
+ if (!CPDFXFA_App::GetInstance()->GetXFAApp())
return TRUE;
IXFA_DocView* pXFADocView = pDocument->GetXFADocView();
if (NULL == pXFADocView)
return TRUE;
- IXFA_DocHandler *pXFADocHandler = FPDFXFA_GetApp()->GetXFAApp()->GetDocHandler();
-
+
+ IXFA_DocHandler *pXFADocHandler = CPDFXFA_App::GetInstance()->GetXFAApp()->GetDocHandler();
CPDF_Document * pPDFDocument = pDocument->GetPDFDoc();
- if (pDocument == NULL)
+ if (pDocument == NULL)
return FALSE;
+
CPDF_Dictionary* pRoot = pPDFDocument->GetRoot();
if (pRoot == NULL)
return FALSE;
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index c5d8f32dca..52e0ccd317 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -176,36 +176,29 @@ FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy)
return FALSE;
}
-
-#ifndef _T
-#define _T(x) x
-#endif
-
CCodec_ModuleMgr* g_pCodecModule = NULL;
DLLEXPORT void STDCALL FPDF_InitLibrary()
{
- g_pCodecModule = CCodec_ModuleMgr::Create();
-
- CFX_GEModule::Create();
- CFX_GEModule::Get()->SetCodecModule(g_pCodecModule);
-
- CPDF_ModuleMgr::Create();
- CPDF_ModuleMgr::Get()->SetCodecModule(g_pCodecModule);
- CPDF_ModuleMgr::Get()->InitPageModule();
- CPDF_ModuleMgr::Get()->InitRenderModule();
+ g_pCodecModule = CCodec_ModuleMgr::Create();
- CPDFXFA_App* pAppProvider = FPDFXFA_GetApp();
- pAppProvider->Initialize();
-}
+ CFX_GEModule::Create();
+ CFX_GEModule::Get()->SetCodecModule(g_pCodecModule);
+
+ CPDF_ModuleMgr::Create();
+ CPDF_ModuleMgr::Get()->SetCodecModule(g_pCodecModule);
+ CPDF_ModuleMgr::Get()->InitPageModule();
+ CPDF_ModuleMgr::Get()->InitRenderModule();
+ CPDFXFA_App::GetInstance()->Initialize();
+}
DLLEXPORT void STDCALL FPDF_DestroyLibrary()
{
- FPDFXFA_ReleaseApp();
- CPDF_ModuleMgr::Destroy();
- CFX_GEModule::Destroy();
- g_pCodecModule->Destroy();
+ CPDFXFA_App::ReleaseInstance();
+ CPDF_ModuleMgr::Destroy();
+ CFX_GEModule::Destroy();
+ g_pCodecModule->Destroy();
}
#ifndef _WIN32
@@ -261,7 +254,7 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BY
if (!pPDFDoc)
return NULL;
- CPDFXFA_App* pProvider = FPDFXFA_GetApp();
+ CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance();
CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider);
return pDocument;
}
@@ -347,10 +340,8 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, int s
if (!pPDFDoc)
return NULL;
- CPDFXFA_App* pProvider = FPDFXFA_GetApp();
+ CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance();
CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider);
- //pDocument->LoadXFADoc();
-
return pDocument;
}
@@ -372,10 +363,8 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAc
if (!pPDFDoc)
return NULL;
- CPDFXFA_App* pProvider = FPDFXFA_GetApp();
+ CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance();
CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider);
- //pDocument->LoadXFADoc();
-
return pDocument;
}
diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp
index e8bd9d0b7e..2c096c7145 100644
--- a/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp
+++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp
@@ -1,7 +1,7 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../public/fpdf_formfill.h"
@@ -12,629 +12,549 @@
#include "../../include/jsapi/fxjs_v8.h"
#include "../../include/javascript/IJavaScript.h"
#include "../../include/fpdfxfa/fpdfxfa_app.h"
-CPDFXFA_App* CPDFXFA_App::m_pApp = NULL;
-CPDFXFA_App* FPDFXFA_GetApp()
-{
- if (!CPDFXFA_App::m_pApp)
- CPDFXFA_App::m_pApp = FX_NEW CPDFXFA_App();
+CPDFXFA_App* CPDFXFA_App::g_pApp = NULL;
- return CPDFXFA_App::m_pApp;
+CPDFXFA_App* CPDFXFA_App::GetInstance()
+{
+ if (!g_pApp) {
+ g_pApp = FX_NEW CPDFXFA_App();
+ }
+ return g_pApp;
}
-void FPDFXFA_ReleaseApp()
+void CPDFXFA_App::ReleaseInstance()
{
- if (CPDFXFA_App::m_pApp)
- delete CPDFXFA_App::m_pApp;
- CPDFXFA_App::m_pApp = NULL;
+ delete g_pApp;
+ g_pApp = NULL;
}
CJS_RuntimeFactory* g_GetJSRuntimeFactory()
{
- static CJS_RuntimeFactory g_JSRuntimeFactory;
- return &g_JSRuntimeFactory;
+ static CJS_RuntimeFactory g_JSRuntimeFactory;
+ return &g_JSRuntimeFactory;
}
-CPDFXFA_App::CPDFXFA_App() :
- m_pXFAApp(NULL),
- m_pFontMgr(NULL),
- m_hJSERuntime(NULL),
- //m_pJSRuntime(NULL),
- //m_pEnv(NULL),
- m_csAppType(JS_STR_VIEWERTYPE_STANDARD)
+CPDFXFA_App::CPDFXFA_App() :
+ m_bInitRuntime(FALSE),
+ m_pXFAApp(NULL),
+ m_pFontMgr(NULL),
+ m_hJSERuntime(NULL),
+ m_csAppType(JS_STR_VIEWERTYPE_STANDARD)
{
- m_pJSRuntimeFactory = NULL;
- m_pJSRuntimeFactory = g_GetJSRuntimeFactory();
- m_pJSRuntimeFactory->AddRef();
- m_pEnvList.RemoveAll();
- m_bInitRuntime = FALSE;
+ m_pJSRuntimeFactory = g_GetJSRuntimeFactory();
+ m_pJSRuntimeFactory->AddRef();
+ m_pEnvList.RemoveAll();
}
-//IFXJS_Runtime* CPDFXFA_App::GetJSRuntime()
-//{
-// FXSYS_assert(m_pJSRuntimeFactory);
-// if(!m_pJSRuntime)
-// m_pJSRuntime = m_pJSRuntimeFactory->NewJSRuntime(this);
-// return m_pJSRuntime;
-//}
CPDFXFA_App::~CPDFXFA_App()
{
- if (m_pFontMgr)
- {
- m_pFontMgr->Release();
- m_pFontMgr = NULL;
- }
-
- if (m_pXFAApp)
- {
- m_pXFAApp->Release();
- m_pXFAApp = NULL;
- }
+ delete m_pFontMgr;
+ m_pFontMgr = NULL;
- //if (m_pJSRuntime && m_pJSRuntimeFactory)
- // m_pJSRuntimeFactory->DeleteJSRuntime(m_pJSRuntime);
- m_pJSRuntimeFactory->Release();
+ delete m_pXFAApp;
+ m_pXFAApp = NULL;
+ m_pJSRuntimeFactory->Release();
+ FXJSE_Runtime_Release(m_hJSERuntime);
+ m_hJSERuntime = NULL;
- if (m_hJSERuntime)
- {
- FXJSE_Runtime_Release(m_hJSERuntime);
- m_hJSERuntime = NULL;
- }
-
- FXJSE_Finalize();
-
- BC_Library_Destory();
+ FXJSE_Finalize();
+ BC_Library_Destory();
}
FX_BOOL CPDFXFA_App::Initialize()
{
- BC_Library_Init();
+ BC_Library_Init();
+ FXJSE_Initialize();
- FXJSE_Initialize();
- m_hJSERuntime = FXJSE_Runtime_Create();
+ m_hJSERuntime = FXJSE_Runtime_Create();
+ if (!m_hJSERuntime)
+ return FALSE;
- if (!m_hJSERuntime)
- return FALSE;
+ m_pXFAApp = IXFA_App::Create(this);
+ if (!m_pXFAApp)
+ return FALSE;
- //m_pJSRuntime = m_pJSRuntimeFactory->NewJSRuntime(this);
-
- m_pXFAApp = IXFA_App::Create(this);
- if (!m_pXFAApp)
- return FALSE;
+ m_pFontMgr = IXFA_FontMgr::CreateDefault();
+ if (!m_pFontMgr)
+ return FALSE;
- m_pFontMgr = XFA_GetDefaultFontMgr();
- if (!m_pFontMgr)
- return FALSE;
-
- m_pXFAApp->SetDefaultFontMgr(m_pFontMgr);
+ m_pXFAApp->SetDefaultFontMgr(m_pFontMgr);
+ return TRUE;
+}
- return TRUE;
+FX_BOOL CPDFXFA_App::InitRuntime(FX_BOOL bReset) {
+ if (bReset) {
+ m_bInitRuntime = FALSE;
+ return TRUE;
+ }
+ if (m_bInitRuntime) {
+ return TRUE;
+ }
+ m_bInitRuntime = TRUE;
+ return FALSE;
}
FX_BOOL CPDFXFA_App::AddFormFillEnv(CPDFDoc_Environment* pEnv)
{
- if (!pEnv) return FALSE;
+ if (!pEnv) return FALSE;
- m_pEnvList.Add(pEnv);
- return TRUE;
+ m_pEnvList.Add(pEnv);
+ return TRUE;
}
FX_BOOL CPDFXFA_App::RemoveFormFillEnv(CPDFDoc_Environment* pEnv)
{
- if (!pEnv) return FALSE;
+ if (!pEnv) return FALSE;
- int nFind = m_pEnvList.Find(pEnv);
- if (nFind != -1) {
- m_pEnvList.RemoveAt(nFind);
- return TRUE;
- }
+ int nFind = m_pEnvList.Find(pEnv);
+ if (nFind != -1) {
+ m_pEnvList.RemoveAt(nFind);
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
-void CPDFXFA_App::ReleaseRuntime()
+void CPDFXFA_App::ReleaseRuntime()
{
- v8::Global<v8::Context> context;
- JS_ReleaseRuntime((IJS_Runtime*)m_hJSERuntime, context);
+ v8::Global<v8::Context> context;
+ JS_ReleaseRuntime((IJS_Runtime*)m_hJSERuntime, context);
}
void CPDFXFA_App::GetAppType(CFX_WideString &wsAppType)
{
- wsAppType = m_csAppType;
+ wsAppType = m_csAppType;
}
void CPDFXFA_App::GetAppName(CFX_WideString& wsName)
{
- CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv)
- {
- wsName = pEnv->FFI_GetAppName();
- }
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ wsName = pEnv->FFI_GetAppName();
+ }
}
void CPDFXFA_App::SetAppType(FX_WSTR wsAppType)
{
- m_csAppType = wsAppType;
+ m_csAppType = wsAppType;
}
void CPDFXFA_App::GetLanguage(CFX_WideString &wsLanguage)
{
- CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv)
- {
- wsLanguage = pEnv->FFI_GetLanguage();
- }
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ wsLanguage = pEnv->FFI_GetLanguage();
+ }
}
void CPDFXFA_App::GetPlatform(CFX_WideString &wsPlatform)
{
- CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv)
- {
- wsPlatform = pEnv->FFI_GetPlatform();
- }
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ wsPlatform = pEnv->FFI_GetPlatform();
+ }
}
void CPDFXFA_App::GetVariation(CFX_WideString &wsVariation)
{
- wsVariation = JS_STR_VIEWERVARIATION;
+ wsVariation = JS_STR_VIEWERVARIATION;
}
void CPDFXFA_App::GetVersion(CFX_WideString &wsVersion)
{
- wsVersion = JS_STR_VIEWERVERSION_XFA;
+ wsVersion = JS_STR_VIEWERVERSION_XFA;
}
void CPDFXFA_App::Beep(FX_DWORD dwType)
{
- CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv)
- {
- pEnv->JS_appBeep(dwType);
- }
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ pEnv->JS_appBeep(dwType);
+ }
}
FX_INT32 CPDFXFA_App::MsgBox(FX_WSTR wsMessage, FX_WSTR wsTitle, FX_DWORD dwIconType, FX_DWORD dwButtonType)
{
- CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (!pEnv)
- return -1;
-
- FX_DWORD iconType = 0;
- int iButtonType = 0;
- switch (dwIconType)
- {
- case XFA_MBICON_Error:
- iconType |= 0;
- break;
- case XFA_MBICON_Warning:
- iconType |= 1;
- break;
- case XFA_MBICON_Question:
- iconType |= 2;
- break;
- case XFA_MBICON_Status:
- iconType |= 3;
- break;
- }
- switch (dwButtonType)
- {
- case XFA_MB_OK:
- iButtonType |= 0;
- break;
- case XFA_MB_OKCancel:
- iButtonType |= 1;
- break;
- case XFA_MB_YesNo:
- iButtonType |= 2;
- break;
- case XFA_MB_YesNoCancel:
- iButtonType |= 3;
- break;
- }
- FX_INT32 iRet = pEnv->JS_appAlert(wsMessage.GetPtr(), wsTitle.GetPtr(), iButtonType, iconType);
- switch (iRet)
- {
- case 1:
- return XFA_IDOK;
- case 2:
- return XFA_IDCancel;
- case 3:
- return XFA_IDNo;
- case 4:
- return XFA_IDYes;
- }
- return XFA_IDYes;
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (!pEnv)
+ return -1;
+
+ FX_DWORD iconType = 0;
+ int iButtonType = 0;
+ switch (dwIconType)
+ {
+ case XFA_MBICON_Error:
+ iconType |= 0;
+ break;
+ case XFA_MBICON_Warning:
+ iconType |= 1;
+ break;
+ case XFA_MBICON_Question:
+ iconType |= 2;
+ break;
+ case XFA_MBICON_Status:
+ iconType |= 3;
+ break;
+ }
+ switch (dwButtonType)
+ {
+ case XFA_MB_OK:
+ iButtonType |= 0;
+ break;
+ case XFA_MB_OKCancel:
+ iButtonType |= 1;
+ break;
+ case XFA_MB_YesNo:
+ iButtonType |= 2;
+ break;
+ case XFA_MB_YesNoCancel:
+ iButtonType |= 3;
+ break;
+ }
+ FX_INT32 iRet = pEnv->JS_appAlert(wsMessage.GetPtr(), wsTitle.GetPtr(), iButtonType, iconType);
+ switch (iRet)
+ {
+ case 1:
+ return XFA_IDOK;
+ case 2:
+ return XFA_IDCancel;
+ case 3:
+ return XFA_IDNo;
+ case 4:
+ return XFA_IDYes;
+ }
+ return XFA_IDYes;
}
void CPDFXFA_App::Response(CFX_WideString &wsAnswer, FX_WSTR wsQuestion, FX_WSTR wsTitle, FX_WSTR wsDefaultAnswer, FX_BOOL bMark)
{
- CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv)
- {
- int nLength = 2048;
- char* pBuff = new char[nLength];
- nLength = pEnv->JS_appResponse(wsQuestion.GetPtr(), wsTitle.GetPtr(), wsDefaultAnswer.GetPtr(), NULL, bMark, pBuff, nLength);
- if(nLength > 0)
- {
- nLength = nLength>2046?2046:nLength;
- pBuff[nLength] = 0;
- pBuff[nLength+1] = 0;
- wsAnswer = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLength);
- }
- delete[] pBuff;
- }
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ int nLength = 2048;
+ char* pBuff = new char[nLength];
+ nLength = pEnv->JS_appResponse(wsQuestion.GetPtr(), wsTitle.GetPtr(), wsDefaultAnswer.GetPtr(), NULL, bMark, pBuff, nLength);
+ if(nLength > 0)
+ {
+ nLength = nLength>2046?2046:nLength;
+ pBuff[nLength] = 0;
+ pBuff[nLength+1] = 0;
+ wsAnswer = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLength);
+ }
+ delete[] pBuff;
+ }
}
FX_INT32 CPDFXFA_App::GetCurDocumentInBatch()
{
- CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv)
- {
- return pEnv->FFI_GetCurDocument();
- }
- return 0;
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ return pEnv->FFI_GetCurDocument();
+ }
+ return 0;
}
FX_INT32 CPDFXFA_App::GetDocumentCountInBatch()
{
- CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv)
- {
- return pEnv->FFI_GetDocumentCount();
- }
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ return pEnv->FFI_GetDocumentCount();
+ }
- return 0;
+ return 0;
}
IFX_FileRead* CPDFXFA_App::DownloadURL(FX_WSTR wsURL)
{
- CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv)
- {
- return pEnv->FFI_DownloadFromURL(wsURL.GetPtr());
- }
- return NULL;
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ return pEnv->FFI_DownloadFromURL(wsURL.GetPtr());
+ }
+ return NULL;
}
-FX_BOOL CPDFXFA_App::PostRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_WSTR wsContentType,
- FX_WSTR wsEncode, FX_WSTR wsHeader, CFX_WideString &wsResponse)
+FX_BOOL CPDFXFA_App::PostRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_WSTR wsContentType,
+ FX_WSTR wsEncode, FX_WSTR wsHeader, CFX_WideString &wsResponse)
{
- CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv)
- {
- wsResponse = pEnv->FFI_PostRequestURL(wsURL.GetPtr(), wsData.GetPtr(), wsContentType.GetPtr(), wsEncode.GetPtr(), wsHeader.GetPtr());
- return TRUE;
- }
- return FALSE;
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ wsResponse = pEnv->FFI_PostRequestURL(wsURL.GetPtr(), wsData.GetPtr(), wsContentType.GetPtr(), wsEncode.GetPtr(), wsHeader.GetPtr());
+ return TRUE;
+ }
+ return FALSE;
}
FX_BOOL CPDFXFA_App::PutRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_WSTR wsEncode)
{
- CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv)
- {
- return pEnv->FFI_PutRequestURL(wsURL.GetPtr(), wsData.GetPtr(), wsEncode.GetPtr());
- }
- return FALSE;
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ {
+ return pEnv->FFI_PutRequestURL(wsURL.GetPtr(), wsData.GetPtr(), wsEncode.GetPtr());
+ }
+ return FALSE;
}
void CPDFXFA_App::LoadString(FX_INT32 iStringID, CFX_WideString &wsString)
{
- switch (iStringID)
- {
- case XFA_IDS_ValidateFailed:
- wsString = L"%s validate failed";
- return;
- case XFA_IDS_CalcOverride:
- wsString = L"Calculate Override";
- return;
- case XFA_IDS_ModifyField:
- wsString = L"Are you sure you want to modify this field?";
- return;
- case XFA_IDS_NotModifyField:
- wsString = L"You are not allowed to modify this field.";
- return;
- case XFA_IDS_AppName:
- wsString = L"Foxit";
- return;
- case XFA_IDS_ImageFilter:
- wsString = L"Image Files(*.bmp;*.jpg;*.png;*.gif;*.tif)|*.bmp;*.jpg;*.png;*.gif;*.tif|All Files(*.*)|*.*||";
- return;
- case XFA_IDS_UNKNOW_CATCHED:
- wsString = L"unknown error is catched!";
- return;
- case XFA_IDS_Unable_TO_SET:
- wsString = L"Unable to set ";
- return;
- case XFA_IDS_VALUE_EXCALMATORY:
- wsString = L" value!";
- return;
- case XFA_IDS_INVALID_ENUM_VALUE:
- wsString = L"Invalid enumerated value: ";
- return;
- case XFA_IDS_UNSUPPORT_METHOD:
- wsString = L"unsupport %s method.";
- return;
- case XFA_IDS_UNSUPPORT_PROP:
- wsString = L"unsupport %s property.";
- return;
- case XFA_IDS_INVAlID_PROP_SET:
- wsString = L"Invalid property set operation;";
- return;
- case XFA_IDS_NOT_DEFAUL_VALUE:
- wsString = L" doesn't have a default property";
- return;
- case XFA_IDS_UNABLE_SET_LANGUAGE:
- wsString = L"Unable to set language value!";
- return;
- case XFA_IDS_UNABLE_SET_NUMPAGES:
- wsString = L"Unable to set numPages value!";
- return;
- case XFA_IDS_UNABLE_SET_PLATFORM:
- wsString = L"Unable to set platform value!";
- return;
- case XFA_IDS_UNABLE_SET_VALIDATIONENABLE:
- wsString = L"Unable to set validationsEnabled value!";
- return;
- case XFA_IDS_UNABLE_SET_VARIATION:
- wsString = L"Unable to set variation value!";
- return;
- case XFA_IDS_UNABLE_SET_VERSION:
- wsString = L"Unable to set version value!";
- return;
- case XFA_IDS_UNABLE_SET_READY:
- wsString = L"Unable to set ready value!";
- return;
- case XFA_IDS_NUMBER_OF_OCCUR:
- wsString = L"The element [%s] has violated its allowable number of occurrences";
- return;
- case XFA_IDS_UNABLE_SET_CLASS_NAME:
- wsString = L"Unable to set className value!";
- return;
- case XFA_IDS_UNABLE_SET_LENGTH_VALUE:
- wsString = L"Unable to set length value!";
- return;
- case XFA_IDS_UNSUPPORT_CHAR:
- wsString = L"unsupported char '%c'";
- return;
- case XFA_IDS_BAD_SUFFIX:
- wsString = L"bad suffix on number";
- return;
- case XFA_IDS_EXPECTED_IDENT:
- wsString = L"expected identifier instead of '%s'";
- return;
- case XFA_IDS_EXPECTED_STRING:
- wsString = L"expected '%s' instead of '%s'";
- return;
- case XFA_IDS_INVALIDATE_CHAR:
- wsString = L"invalidate char '%c'";
- return;
- case XFA_IDS_REDEFINITION:
- wsString = L"'%s' redefinition ";
- return;
- case XFA_IDS_INVALIDATE_TOKEN:
- wsString = L"invalidate token '%s'";
- return;
- case XFA_IDS_INVALIDATE_EXPRESSION:
- wsString = L"invalidate expression '%s'";
- return;
- case XFA_IDS_UNDEFINE_IDENTIFIER:
- wsString = L"undefined identifier '%s'";
- return;
- case XFA_IDS_INVALIDATE_LEFTVALUE:
- wsString = L"invalidate left-value '%s'";
- return;
- case XFA_IDS_COMPILER_ERROR:
- wsString = L"compiler error";
- return;
- case XFA_IDS_CANNOT_MODIFY_VALUE:
- wsString = L"can't modify the '%s' value";
- return;
- case XFA_IDS_ERROR_PARAMETERS:
- wsString = L"function '%s' has not %d parameters";
- return;
- case XFA_IDS_EXPECT_ENDIF:
- wsString = L"expected 'endif' instead of '%s'";
- return;
- case XFA_IDS_UNEXPECTED_EXPRESSION:
- wsString = L"unexpected expression '%s'";
- return;
- case XFA_IDS_CONDITION_IS_NULL:
- wsString = L"condition is null";
- return;
- case XFA_IDS_ILLEGALBREAK:
- wsString = L"illegal break";
- return;
- case XFA_IDS_ILLEGALCONTINUE:
- wsString = L"illegal continue";
- return;
- case XFA_IDS_EXPECTED_OPERATOR:
- wsString = L"expected operator '%s' instead of '%s'";
- return;
- case XFA_IDS_DIVIDE_ZERO:
- wsString = L"divide by zero";
- return;
- case XFA_IDS_CANNOT_COVERT_OBJECT:
- wsString = L"%s.%s can not covert to object";
- return;
- case XFA_IDS_NOT_FOUND_CONTAINER:
- wsString = L"can not found container '%s'";
- return;
- case XFA_IDS_NOT_FOUND_PROPERTY:
- wsString = L"can not found property '%s'";
- return;
- case XFA_IDS_NOT_FOUND_METHOD:
- wsString = L"can not found method '%s'";
- return;
- case XFA_IDS_NOT_FOUND_CONST:
- wsString = L"can not found const '%s'";
- return;
- case XFA_IDS_NOT_ASSIGN_OBJECT:
- wsString = L"can not direct assign value to object";
- return;
- case XFA_IDS_IVALIDATE_INSTRUCTION:
- wsString = L"invalidate instruction";
- return;
- case XFA_IDS_EXPECT_NUMBER:
- wsString = L"expected number instead of '%s'";
- return;
- case XFA_IDS_VALIDATE_OUT_ARRAY:
- wsString = L"validate access index '%s' out of array";
- return;
- case XFA_IDS_CANNOT_ASSIGN_IDENT:
- wsString = L"can not assign to %s";
- return;
- case XFA_IDS_NOT_FOUNT_FUNCTION:
- wsString = L"can not found '%s' function";
- return;
- case XFA_IDS_NOT_ARRAY:
- wsString = L"'%s' doesn't an array";
- return;
- case XFA_IDS_OUT_ARRAY:
- wsString = L"out of range of '%s' array";
- return;
- case XFA_IDS_NOT_SUPPORT_CALC:
- wsString = L"'%s' operator can not support array calculate";
- return;
- case XFA_IDS_ARGUMENT_NOT_ARRAY:
- wsString = L"'%s' function's %d argument can not be array";
- return;
- case XFA_IDS_ARGUMENT_EXPECT_CONTAINER:
- wsString = L"'%s' argument expected a container";
- return;
- case XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT:
- wsString = L"an attempt was made to reference property '%s' of a non-object in SOM expression %s";
- return;
- case XFA_IDS_FUNCTION_IS_BUILDIN:
- wsString = L"function '%s' is buildin";
- return;
- case XFA_IDS_ERROR_MSG:
- wsString = L"%s : %s";
- return;
- case XFA_IDS_INDEX_OUT_OF_BOUNDS:
- wsString = L"Index value is out of bounds";
- return;
- case XFA_IDS_INCORRECT_NUMBER_OF_METHOD:
- wsString = L"Incorrect number of parameters calling method '%s'";
- return;
- case XFA_IDS_ARGUMENT_MISMATCH:
- wsString = L"Argument mismatch in property or function argument";
- return;
- case XFA_IDS_INVALID_ENUMERATE:
- wsString = L"Invalid enumerated value: %s";
- return;
- case XFA_IDS_INVALID_APPEND:
- wsString = L"Invalid append operation: %s cannot have a child element of %s";
- return;
- case XFA_IDS_SOM_EXPECTED_LIST:
- wsString = L"SOM expression returned list when single result was expected";
- return;
- case XFA_IDS_NOT_HAVE_PROPERTY:
- wsString = L"'%s' doesn't have property '%s'";
- return;
- case XFA_IDS_INVALID_NODE_TYPE:
- wsString = L"Invalid node type : '%s'";
- return;
- case XFA_IDS_VIOLATE_BOUNDARY:
- wsString = L"The element [%s] has violated its allowable number of occurrences";
- return;
- case XFA_IDS_SERVER_DENY:
- wsString = L"Server does not permit";
- return;
- /*case XFA_IDS_StringWeekDay_Sun:
- wsString = L"?¨¹¨¨?";
- return;
- case XFA_IDS_StringWeekDay_Mon:
- wsString = L"?¨¹¨°?";
- return;
- case XFA_IDS_StringWeekDay_Tue:
- wsString = L"?¨¹?t";
- return;
- case XFA_IDS_StringWeekDay_Wed:
- wsString = L"?¨¹¨¨y";
- return;
- case XFA_IDS_StringWeekDay_Thu:
- wsString = L"?¨¹??";
- return;
- case XFA_IDS_StringWeekDay_Fri:
- wsString = L"?¨¹??";
- return;
- case XFA_IDS_StringWeekDay_Sat:
- wsString = L"?¨¹¨¢¨´";
- return;
- case XFA_IDS_StringMonth_Jan:
- wsString = L"1??";
- return;
- case XFA_IDS_StringMonth_Feb:
- wsString = L"2??";
- return;
- case XFA_IDS_StringMonth_March:
- wsString = L"3??";
- return;
- case XFA_IDS_StringMonth_April:
- wsString = L"4??";
- return;
- case XFA_IDS_StringMonth_May:
- wsString = L"5??";
- return;
- case XFA_IDS_StringMonth_June:
- wsString = L"6??";
- return;
- case XFA_IDS_StringMonth_July:
- wsString = L"7??";
- return;
- case XFA_IDS_StringMonth_Aug:
- wsString = L"8??";
- return;
- case XFA_IDS_StringMonth_Sept:
- wsString = L"9??";
- return;
- case XFA_IDS_StringMonth_Oct:
- wsString = L"10??";
- return;
- case XFA_IDS_StringMonth_Nov:
- wsString = L"11??";
- return;
- case XFA_IDS_StringMonth_Dec:
- wsString = L"12??";
- return;
- case XFA_IDS_String_Today:
- wsString = L"??¨¬¨¬";
- return;*/
- case XFA_IDS_ValidateLimit:
- wsString = FX_WSTRC(L"Message limit exceeded. Remaining %d validation errors not reported.");
- return;
- case XFA_IDS_ValidateNullWarning:
- wsString = FX_WSTRC(L"%s cannot be left blank. To ignore validations for %s, click Ignore.");
- return;
- case XFA_IDS_ValidateNullError:
- wsString = FX_WSTRC(L"%s cannot be left blank.");
- return;
- case XFA_IDS_ValidateWarning:
- wsString = FX_WSTRC(L"The value you entered for %s is invalid. To ignore validations for %s, click Ignore.");
- return;
- case XFA_IDS_ValidateError:
- wsString = FX_WSTRC(L"The value you entered for %s is invalid.");
- return;
- }
+ switch (iStringID)
+ {
+ case XFA_IDS_ValidateFailed:
+ wsString = L"%s validate failed";
+ return;
+ case XFA_IDS_CalcOverride:
+ wsString = L"Calculate Override";
+ return;
+ case XFA_IDS_ModifyField:
+ wsString = L"Are you sure you want to modify this field?";
+ return;
+ case XFA_IDS_NotModifyField:
+ wsString = L"You are not allowed to modify this field.";
+ return;
+ case XFA_IDS_AppName:
+ wsString = L"Foxit";
+ return;
+ case XFA_IDS_ImageFilter:
+ wsString = L"Image Files(*.bmp;*.jpg;*.png;*.gif;*.tif)|*.bmp;*.jpg;*.png;*.gif;*.tif|All Files(*.*)|*.*||";
+ return;
+ case XFA_IDS_UNKNOW_CATCHED:
+ wsString = L"unknown error is catched!";
+ return;
+ case XFA_IDS_Unable_TO_SET:
+ wsString = L"Unable to set ";
+ return;
+ case XFA_IDS_VALUE_EXCALMATORY:
+ wsString = L" value!";
+ return;
+ case XFA_IDS_INVALID_ENUM_VALUE:
+ wsString = L"Invalid enumerated value: ";
+ return;
+ case XFA_IDS_UNSUPPORT_METHOD:
+ wsString = L"unsupport %s method.";
+ return;
+ case XFA_IDS_UNSUPPORT_PROP:
+ wsString = L"unsupport %s property.";
+ return;
+ case XFA_IDS_INVAlID_PROP_SET:
+ wsString = L"Invalid property set operation;";
+ return;
+ case XFA_IDS_NOT_DEFAUL_VALUE:
+ wsString = L" doesn't have a default property";
+ return;
+ case XFA_IDS_UNABLE_SET_LANGUAGE:
+ wsString = L"Unable to set language value!";
+ return;
+ case XFA_IDS_UNABLE_SET_NUMPAGES:
+ wsString = L"Unable to set numPages value!";
+ return;
+ case XFA_IDS_UNABLE_SET_PLATFORM:
+ wsString = L"Unable to set platform value!";
+ return;
+ case XFA_IDS_UNABLE_SET_VALIDATIONENABLE:
+ wsString = L"Unable to set validationsEnabled value!";
+ return;
+ case XFA_IDS_UNABLE_SET_VARIATION:
+ wsString = L"Unable to set variation value!";
+ return;
+ case XFA_IDS_UNABLE_SET_VERSION:
+ wsString = L"Unable to set version value!";
+ return;
+ case XFA_IDS_UNABLE_SET_READY:
+ wsString = L"Unable to set ready value!";
+ return;
+ case XFA_IDS_NUMBER_OF_OCCUR:
+ wsString = L"The element [%s] has violated its allowable number of occurrences";
+ return;
+ case XFA_IDS_UNABLE_SET_CLASS_NAME:
+ wsString = L"Unable to set className value!";
+ return;
+ case XFA_IDS_UNABLE_SET_LENGTH_VALUE:
+ wsString = L"Unable to set length value!";
+ return;
+ case XFA_IDS_UNSUPPORT_CHAR:
+ wsString = L"unsupported char '%c'";
+ return;
+ case XFA_IDS_BAD_SUFFIX:
+ wsString = L"bad suffix on number";
+ return;
+ case XFA_IDS_EXPECTED_IDENT:
+ wsString = L"expected identifier instead of '%s'";
+ return;
+ case XFA_IDS_EXPECTED_STRING:
+ wsString = L"expected '%s' instead of '%s'";
+ return;
+ case XFA_IDS_INVALIDATE_CHAR:
+ wsString = L"invalidate char '%c'";
+ return;
+ case XFA_IDS_REDEFINITION:
+ wsString = L"'%s' redefinition ";
+ return;
+ case XFA_IDS_INVALIDATE_TOKEN:
+ wsString = L"invalidate token '%s'";
+ return;
+ case XFA_IDS_INVALIDATE_EXPRESSION:
+ wsString = L"invalidate expression '%s'";
+ return;
+ case XFA_IDS_UNDEFINE_IDENTIFIER:
+ wsString = L"undefined identifier '%s'";
+ return;
+ case XFA_IDS_INVALIDATE_LEFTVALUE:
+ wsString = L"invalidate left-value '%s'";
+ return;
+ case XFA_IDS_COMPILER_ERROR:
+ wsString = L"compiler error";
+ return;
+ case XFA_IDS_CANNOT_MODIFY_VALUE:
+ wsString = L"can't modify the '%s' value";
+ return;
+ case XFA_IDS_ERROR_PARAMETERS:
+ wsString = L"function '%s' has not %d parameters";
+ return;
+ case XFA_IDS_EXPECT_ENDIF:
+ wsString = L"expected 'endif' instead of '%s'";
+ return;
+ case XFA_IDS_UNEXPECTED_EXPRESSION:
+ wsString = L"unexpected expression '%s'";
+ return;
+ case XFA_IDS_CONDITION_IS_NULL:
+ wsString = L"condition is null";
+ return;
+ case XFA_IDS_ILLEGALBREAK:
+ wsString = L"illegal break";
+ return;
+ case XFA_IDS_ILLEGALCONTINUE:
+ wsString = L"illegal continue";
+ return;
+ case XFA_IDS_EXPECTED_OPERATOR:
+ wsString = L"expected operator '%s' instead of '%s'";
+ return;
+ case XFA_IDS_DIVIDE_ZERO:
+ wsString = L"divide by zero";
+ return;
+ case XFA_IDS_CANNOT_COVERT_OBJECT:
+ wsString = L"%s.%s can not covert to object";
+ return;
+ case XFA_IDS_NOT_FOUND_CONTAINER:
+ wsString = L"can not found container '%s'";
+ return;
+ case XFA_IDS_NOT_FOUND_PROPERTY:
+ wsString = L"can not found property '%s'";
+ return;
+ case XFA_IDS_NOT_FOUND_METHOD:
+ wsString = L"can not found method '%s'";
+ return;
+ case XFA_IDS_NOT_FOUND_CONST:
+ wsString = L"can not found const '%s'";
+ return;
+ case XFA_IDS_NOT_ASSIGN_OBJECT:
+ wsString = L"can not direct assign value to object";
+ return;
+ case XFA_IDS_IVALIDATE_INSTRUCTION:
+ wsString = L"invalidate instruction";
+ return;
+ case XFA_IDS_EXPECT_NUMBER:
+ wsString = L"expected number instead of '%s'";
+ return;
+ case XFA_IDS_VALIDATE_OUT_ARRAY:
+ wsString = L"validate access index '%s' out of array";
+ return;
+ case XFA_IDS_CANNOT_ASSIGN_IDENT:
+ wsString = L"can not assign to %s";
+ return;
+ case XFA_IDS_NOT_FOUNT_FUNCTION:
+ wsString = L"can not found '%s' function";
+ return;
+ case XFA_IDS_NOT_ARRAY:
+ wsString = L"'%s' doesn't an array";
+ return;
+ case XFA_IDS_OUT_ARRAY:
+ wsString = L"out of range of '%s' array";
+ return;
+ case XFA_IDS_NOT_SUPPORT_CALC:
+ wsString = L"'%s' operator can not support array calculate";
+ return;
+ case XFA_IDS_ARGUMENT_NOT_ARRAY:
+ wsString = L"'%s' function's %d argument can not be array";
+ return;
+ case XFA_IDS_ARGUMENT_EXPECT_CONTAINER:
+ wsString = L"'%s' argument expected a container";
+ return;
+ case XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT:
+ wsString = L"an attempt was made to reference property '%s' of a non-object in SOM expression %s";
+ return;
+ case XFA_IDS_FUNCTION_IS_BUILDIN:
+ wsString = L"function '%s' is buildin";
+ return;
+ case XFA_IDS_ERROR_MSG:
+ wsString = L"%s : %s";
+ return;
+ case XFA_IDS_INDEX_OUT_OF_BOUNDS:
+ wsString = L"Index value is out of bounds";
+ return;
+ case XFA_IDS_INCORRECT_NUMBER_OF_METHOD:
+ wsString = L"Incorrect number of parameters calling method '%s'";
+ return;
+ case XFA_IDS_ARGUMENT_MISMATCH:
+ wsString = L"Argument mismatch in property or function argument";
+ return;
+ case XFA_IDS_INVALID_ENUMERATE:
+ wsString = L"Invalid enumerated value: %s";
+ return;
+ case XFA_IDS_INVALID_APPEND:
+ wsString = L"Invalid append operation: %s cannot have a child element of %s";
+ return;
+ case XFA_IDS_SOM_EXPECTED_LIST:
+ wsString = L"SOM expression returned list when single result was expected";
+ return;
+ case XFA_IDS_NOT_HAVE_PROPERTY:
+ wsString = L"'%s' doesn't have property '%s'";
+ return;
+ case XFA_IDS_INVALID_NODE_TYPE:
+ wsString = L"Invalid node type : '%s'";
+ return;
+ case XFA_IDS_VIOLATE_BOUNDARY:
+ wsString = L"The element [%s] has violated its allowable number of occurrences";
+ return;
+ case XFA_IDS_SERVER_DENY:
+ wsString = L"Server does not permit";
+ return;
+ case XFA_IDS_ValidateLimit:
+ wsString = FX_WSTRC(L"Message limit exceeded. Remaining %d validation errors not reported.");
+ return;
+ case XFA_IDS_ValidateNullWarning:
+ wsString = FX_WSTRC(L"%s cannot be left blank. To ignore validations for %s, click Ignore.");
+ return;
+ case XFA_IDS_ValidateNullError:
+ wsString = FX_WSTRC(L"%s cannot be left blank.");
+ return;
+ case XFA_IDS_ValidateWarning:
+ wsString = FX_WSTRC(L"The value you entered for %s is invalid. To ignore validations for %s, click Ignore.");
+ return;
+ case XFA_IDS_ValidateError:
+ wsString = FX_WSTRC(L"The value you entered for %s is invalid.");
+ return;
+ }
}
FX_BOOL CPDFXFA_App::ShowFileDialog(FX_WSTR wsTitle, FX_WSTR wsFilter, CFX_WideStringArray &wsPathArr, FX_BOOL bOpen)
{
- //if (m_pEnv)
- //{
- // return m_pEnv->FFI_ShowFileDialog(wsTitle.GetPtr(), wsFilter.GetPtr(), wsPathArr, bOpen);
- //}
- return FALSE;
+ return FALSE;
}
IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr()
{
- CXFA_FWLAdapterTimerMgr* pAdapter = NULL;
- CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv)
- pAdapter = FX_NEW CXFA_FWLAdapterTimerMgr(pEnv);
- return pAdapter;
+ CXFA_FWLAdapterTimerMgr* pAdapter = NULL;
+ CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
+ if (pEnv)
+ pAdapter = FX_NEW CXFA_FWLAdapterTimerMgr(pEnv);
+ return pAdapter;
}
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index e783532ca2..ccb1ab6e34 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -215,8 +215,6 @@ FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime()
return m_pEnv->FFI_GetLocalTime();
}
-
-
CPDFDoc_Environment::CPDFDoc_Environment(CPDFXFA_Document* pDoc) :
m_pAnnotHandlerMgr(NULL),
m_pActionHandler(NULL),
@@ -226,50 +224,34 @@ CPDFDoc_Environment::CPDFDoc_Environment(CPDFXFA_Document* pDoc) :
m_pDoc(pDoc),
m_pIFormFiller(NULL)
{
-
m_pSysHandler = NULL;
m_pSysHandler = new CFX_SystemHandler(this);
-
- //m_pJSRuntimeFactory = pDoc->GetApp()->GetRuntimeFactory();
-
}
CPDFDoc_Environment::~CPDFDoc_Environment()
{
- if ( m_pIFormFiller )
- {
- delete m_pIFormFiller;
- m_pIFormFiller = NULL;
- }
-
- if (m_pJSRuntime && FPDFXFA_GetApp()->GetRuntimeFactory())
- FPDFXFA_GetApp()->GetRuntimeFactory()->DeleteJSRuntime(m_pJSRuntime);
+ delete m_pIFormFiller;
+ m_pIFormFiller = NULL;
- if (FPDFXFA_GetApp()->m_pEnvList.GetSize() == 0)
- {
- FPDFXFA_GetApp()->ReleaseRuntime();
- FPDFXFA_GetApp()->InitRuntime(TRUE);
- }
+ CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance();
+ if (m_pJSRuntime && pProvider->GetRuntimeFactory())
+ pProvider->GetRuntimeFactory()->DeleteJSRuntime(m_pJSRuntime);
- if(m_pSysHandler)
- {
- delete m_pSysHandler;
- m_pSysHandler = NULL;
- }
+ if (pProvider->m_pEnvList.GetSize() == 0)
+ {
+ pProvider->ReleaseRuntime();
+ pProvider->InitRuntime(TRUE);
+ }
- if(m_pAnnotHandlerMgr)
- {
- delete m_pAnnotHandlerMgr;
- m_pAnnotHandlerMgr = NULL;
- }
- if(m_pActionHandler)
- {
- delete m_pActionHandler;
- m_pActionHandler = NULL;
- }
+ delete m_pSysHandler;
+ m_pSysHandler = NULL;
+ delete m_pAnnotHandlerMgr;
+ m_pAnnotHandlerMgr = NULL;
+ delete m_pActionHandler;
+ m_pActionHandler = NULL;
}
@@ -278,7 +260,7 @@ IFXJS_Runtime* CPDFDoc_Environment::GetJSRuntime()
if(!IsJSInitiated())
return NULL;
if(!m_pJSRuntime)
- m_pJSRuntime = FPDFXFA_GetApp()->GetRuntimeFactory()->NewJSRuntime(this);
+ m_pJSRuntime = CPDFXFA_App::GetInstance()->GetRuntimeFactory()->NewJSRuntime(this);
return m_pJSRuntime;
}
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index f3d7cf3972..9450a6400a 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -114,8 +114,8 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) :
m_bRegistered(FALSE),
m_pFieldEventPath(NULL)
{
- if (FPDFXFA_GetApp()->GetJSERuntime()) {
- m_isolate = (v8::Isolate*)FPDFXFA_GetApp()->GetJSERuntime();
+ if (CPDFXFA_App::GetInstance()->GetJSERuntime()) {
+ m_isolate = (v8::Isolate*)CPDFXFA_App::GetInstance()->GetJSERuntime();
} else {
m_pArrayBufferAllocator.reset(new CJS_ArrayBufferAllocator());
v8::Isolate::CreateParams params;
@@ -127,7 +127,7 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) :
v8::Isolate::Scope isolate_scope(isolate);
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
- if (FPDFXFA_GetApp()->InitRuntime(FALSE)) {
+ if (CPDFXFA_App::GetInstance()->InitRuntime(FALSE)) {
CJS_Context * pContext = (CJS_Context*)NewContext();
JS_InitialRuntime(*this, this, pContext, m_context);
ReleaseContext(pContext);
diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp
index daf5a85ffe..f139380b20 100644
--- a/fpdfsdk/src/javascript/global.cpp
+++ b/fpdfsdk/src/javascript/global.cpp
@@ -119,22 +119,17 @@ global_alternate::global_alternate(CJS_Object* pJSObject)
global_alternate::~global_alternate(void)
{
ASSERT(m_pApp != NULL);
-
-// CommitGlobalPersisitentVariables();
DestroyGlobalPersisitentVariables();
- CJS_RuntimeFactory* pFactory = FPDFXFA_GetApp()->GetRuntimeFactory();
- ASSERT(pFactory);
-
+ CJS_RuntimeFactory* pFactory = CPDFXFA_App::GetInstance()->GetRuntimeFactory();
pFactory->ReleaseGlobalData();
}
-
+
void global_alternate::Initial(CPDFDoc_Environment* pApp)
{
m_pApp = pApp;
- CJS_RuntimeFactory* pFactory = FPDFXFA_GetApp()->GetRuntimeFactory();
- ASSERT(pFactory);
+ CJS_RuntimeFactory* pFactory = CPDFXFA_App::GetInstance()->GetRuntimeFactory();
m_pGlobalData = pFactory->NewGlobalData(pApp);
UpdateGlobalPersistentVariables();
}
diff --git a/xfa/include/fxfa/fxfa.h b/xfa/include/fxfa/fxfa.h
index ef2a1a837f..e7ddcce8c1 100644
--- a/xfa/include/fxfa/fxfa.h
+++ b/xfa/include/fxfa/fxfa.h
@@ -4,8 +4,9 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef _FXFA
-#define _FXFA
+#ifndef FXFA_H_
+#define FXFA_H_
+
class IFDE_XMLElement;
class CXFA_Node;
class CXFA_NodeList;
@@ -145,66 +146,133 @@ typedef struct _XFA_HWIDGET {
#define XFA_IDS_ValidateWarning 97
#define XFA_IDS_ValidateError 98
#define XFA_IDS_ValidateNumberError 99
+
+// Probably should be called IXFA_AppDelegate.
class IXFA_AppProvider
{
public:
virtual ~IXFA_AppProvider() { }
- virtual void SetAppType(FX_WSTR wsAppType) = 0;
- virtual void GetAppType(CFX_WideString &wsAppType) = 0;
+ /**
+ * Specifies the name of the client application in which a form currently exists. Such as Exchange-Pro.
+ */
+ virtual void SetAppType(const CFX_WideStringC& wsAppType) = 0;
+ virtual void GetAppType(CFX_WideString &wsAppType) = 0;
+ virtual void SetFoxitAppType(const CFX_WideStringC& wsFoxitAppType) { }
+ virtual void GetFoxitAppType(CFX_WideString &wsFoxitAppType) {
+ wsFoxitAppType.Empty();
+ }
+
+ /**
+ * Returns the language of the running host application. Such as zh_CN
+ */
+ virtual void GetLanguage(CFX_WideString &wsLanguage) = 0;
+
+ /**
+ * Returns the platform of the machine running the script. Such as WIN
+ */
+ virtual void GetPlatform(CFX_WideString &wsPlatform) = 0;
- virtual void SetFoxitAppType(FX_WSTR wsFoxitAppType) { }
- virtual void GetFoxitAppType(CFX_WideString &wsFoxitAppType) { }
+ /**
+ * Indicates the packaging of the application that is running the script. Such as Full
+ */
+ virtual void GetVariation(CFX_WideString &wsVariation) = 0;
+
+ /**
+ * Indicates the version number of the current application. Such as 9
+ */
+ virtual void GetVersion(CFX_WideString &wsVersion) = 0;
+ virtual void GetFoxitVersion(CFX_WideString &wsFoxitVersion) {
+ wsFoxitVersion.Empty();
+ }
+
+ /**
+ * Get application name, such as Phantom.
+ */
+ virtual void GetAppName(CFX_WideString& wsName) = 0;
+ virtual void GetFoxitAppName(CFX_WideString& wsFoxitName) {
+ wsFoxitName.Empty();
+ }
- virtual void GetLanguage(CFX_WideString &wsLanguage) = 0;
- virtual void GetPlatform(CFX_WideString &wsPlatform) = 0;
- virtual void GetVariation(CFX_WideString &wsVariation) = 0;
+ /**
+ * 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) = 0;
- virtual void GetVersion(CFX_WideString &wsVersion) = 0;
- virtual void GetFoxitVersion(CFX_WideString &wsFoxitVersion) { }
+ /**
+ * 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) = 0;
- virtual void GetAppName(CFX_WideString& wsName) = 0;
- virtual void GetFoxitAppName(CFX_WideString& wsFoxitName) { }
+ /**
+ * Get a response from the user.
+ * @param[in] bMark - Mask the user input with * (asterisks) when true,
+ */
+ 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) = 0;
- virtual void Beep(FX_DWORD dwType) = 0;
+ virtual FX_INT32 GetDocumentCountInBatch() = 0;
+ virtual FX_INT32 GetCurDocumentInBatch() = 0;
- virtual FX_INT32 MsgBox(FX_WSTR wsMessage, FX_WSTR wsTitle = FX_WSTRC(L""), FX_DWORD dwIconType = 0, FX_DWORD dwButtonType = 0) = 0;
- 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) = 0;
- virtual FX_INT32 GetDocumentCountInBatch() = 0;
- virtual FX_INT32 GetCurDocumentInBatch() = 0;
+ /**
+ * Download something from somewhere.
+ * @param[in] wsURL - http, ftp, such as "http://www.w3.org/TR/REC-xml-names/".
+ */
virtual IFX_FileRead* DownloadURL(FX_WSTR wsURL) = 0;
- virtual FX_BOOL PostRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_WSTR wsContentType,
- FX_WSTR wsEncode, FX_WSTR wsHeader, CFX_WideString &wsResponse) = 0;
+ /**
+ * 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) = 0;
- virtual FX_BOOL PutRequestURL(FX_WSTR wsURL, FX_WSTR wsData, FX_WSTR wsEncode) = 0;
- virtual void LoadString(FX_INT32 iStringID, CFX_WideString &wsString) = 0;
- virtual FX_BOOL ShowFileDialog(FX_WSTR wsTitle, FX_WSTR wsFilter, CFX_WideStringArray &wsPathArr, FX_BOOL bOpen = TRUE) = 0;
+ /**
+ * 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) = 0;
+
+ virtual void LoadString(FX_INT32 iStringID, CFX_WideString &wsString) = 0;
+ virtual FX_BOOL ShowFileDialog(FX_WSTR wsTitle, FX_WSTR wsFilter, CFX_WideStringArray &wsPathArr, FX_BOOL bOpen = TRUE) = 0;
virtual IFWL_AdapterTimerMgr* GetTimerMgr() = 0;
};
class IXFA_FontMgr
{
public:
- virtual void Release() = 0;
+ static IXFA_FontMgr* CreateDefault();
+ virtual ~IXFA_FontMgr();
+
virtual IFX_Font* GetFont(XFA_HDOC hDoc, FX_WSTR wsFontFamily, FX_DWORD dwFontStyles, FX_WORD wCodePage = 0xFFFF) = 0;
virtual IFX_Font* GetDefaultFont(XFA_HDOC hDoc, FX_WSTR wsFontFamily, FX_DWORD dwFontStyles, FX_WORD wCodePage = 0xFFFF) = 0;
-protected:
- ~IXFA_FontMgr() { }
};
-IXFA_FontMgr* XFA_GetDefaultFontMgr();
class IXFA_App
{
public:
- static IXFA_App* Create(IXFA_AppProvider* pProvider);
- virtual void Release() = 0;
+ static IXFA_App* Create(IXFA_AppProvider* pProvider);
+ virtual ~IXFA_App();
+
virtual IXFA_DocHandler* GetDocHandler() = 0;
virtual XFA_HDOC CreateDoc(IXFA_DocProvider* pProvider, IFX_FileRead* pStream, FX_BOOL bTakeOverFile = TRUE) = 0;
virtual XFA_HDOC CreateDoc(IXFA_DocProvider* pProvider, CPDF_Document* pPDFDoc) = 0;
virtual IXFA_AppProvider* GetAppProvider() = 0;
virtual void SetDefaultFontMgr(IXFA_FontMgr* pFontMgr) = 0;
virtual IXFA_MenuHandler* GetMenuHandler() = 0;
-protected:
- ~IXFA_App() { }
};
class IXFA_MenuHandler
{
@@ -627,4 +695,5 @@ protected:
~IXFA_ChecksumContext() { }
};
IXFA_ChecksumContext* XFA_Checksum_Create();
-#endif
+
+#endif // FXFA_H_
diff --git a/xfa/src/fxfa/src/app/xfa_ffapp.cpp b/xfa/src/fxfa/src/app/xfa_ffapp.cpp
index 67ec95b009..abd02460d1 100644
--- a/xfa/src/fxfa/src/app/xfa_ffapp.cpp
+++ b/xfa/src/fxfa/src/app/xfa_ffapp.cpp
@@ -134,9 +134,14 @@ FX_BOOL CXFA_FileRead2::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size)
}
return FALSE;
}
+// static
IXFA_App* IXFA_App::Create(IXFA_AppProvider* pProvider)
{
- return FX_NEW CXFA_FFApp(pProvider);
+ return new CXFA_FFApp(pProvider);
+}
+// virtual
+IXFA_App::~IXFA_App()
+{
}
CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider)
: m_pDocHandler(NULL)
diff --git a/xfa/src/fxfa/src/app/xfa_ffapp.h b/xfa/src/fxfa/src/app/xfa_ffapp.h
index 82d0b95e02..b99f1fe209 100644
--- a/xfa/src/fxfa/src/app/xfa_ffapp.h
+++ b/xfa/src/fxfa/src/app/xfa_ffapp.h
@@ -47,11 +47,8 @@ class CXFA_FFApp : public IXFA_App, public IFWL_AdapterNative
{
public:
CXFA_FFApp(IXFA_AppProvider* pProvider);
- ~CXFA_FFApp();
- virtual void Release()
- {
- delete this;
- }
+ ~CXFA_FFApp() override;
+
virtual IXFA_DocHandler* GetDocHandler();
virtual XFA_HDOC CreateDoc(IXFA_DocProvider* pProvider, IFX_FileRead* pStream, FX_BOOL bTakeOverFile);
virtual XFA_HDOC CreateDoc(IXFA_DocProvider* pProvider, CPDF_Document* pPDFDoc);
diff --git a/xfa/src/fxfa/src/app/xfa_fontmgr.cpp b/xfa/src/fxfa/src/app/xfa_fontmgr.cpp
index ef49911dc1..8138e5870b 100644
--- a/xfa/src/fxfa/src/app/xfa_fontmgr.cpp
+++ b/xfa/src/fxfa/src/app/xfa_fontmgr.cpp
@@ -1010,10 +1010,15 @@ const XFA_FONTINFO* XFA_GetFontINFOByFontName(FX_WSTR wsFontName)
return NULL;
#endif
}
-IXFA_FontMgr* XFA_GetDefaultFontMgr()
+// static
+IXFA_FontMgr* IXFA_FontMgr::CreateDefault()
{
return FX_NEW CXFA_DefFontMgr;
}
+// virtual
+IXFA_FontMgr::~IXFA_FontMgr()
+{
+}
CXFA_DefFontMgr::~CXFA_DefFontMgr()
{
FX_INT32 iCounts = m_CacheFonts.GetSize();
diff --git a/xfa/src/fxfa/src/app/xfa_fontmgr.h b/xfa/src/fxfa/src/app/xfa_fontmgr.h
index 09e0d19096..fd65570115 100644
--- a/xfa/src/fxfa/src/app/xfa_fontmgr.h
+++ b/xfa/src/fxfa/src/app/xfa_fontmgr.h
@@ -17,11 +17,7 @@ class CXFA_DefFontMgr : public IXFA_FontMgr
{
public:
CXFA_DefFontMgr() {}
- virtual ~CXFA_DefFontMgr();
- virtual void Release()
- {
- delete this;
- }
+ ~CXFA_DefFontMgr() override;
virtual IFX_Font* GetFont(XFA_HDOC hDoc, FX_WSTR wsFontFamily, FX_DWORD dwFontStyles, FX_WORD wCodePage = 0xFFFF);
virtual IFX_Font* GetDefaultFont(XFA_HDOC hDoc, FX_WSTR wsFontFamily, FX_DWORD dwFontStyles, FX_WORD wCodePage = 0xFFFF);
protected: