Chromium Code Reviews| Index: fpdfsdk/src/fsdk_mgr.cpp |
| diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp |
| index 527538cd0936d3e0aa012cbfc367179cb264b8fd..64dcb446204e312b8a2fd31415879a088481f179 100644 |
| --- a/fpdfsdk/src/fsdk_mgr.cpp |
| +++ b/fpdfsdk/src/fsdk_mgr.cpp |
| @@ -219,21 +219,16 @@ CJS_RuntimeFactory* GetJSRuntimeFactory() |
| return &s_JSRuntimeFactory; |
| } |
| -CPDFDoc_Environment::CPDFDoc_Environment(CPDF_Document* pDoc) : |
| +CPDFDoc_Environment::CPDFDoc_Environment(CPDF_Document* pDoc, FPDF_FORMFILLINFO* pFFinfo) : |
| m_pAnnotHandlerMgr(NULL), |
| m_pActionHandler(NULL), |
| m_pJSRuntime(NULL), |
| - m_pInfo(NULL), |
| + m_pInfo(pFFinfo), |
| m_pSDKDoc(NULL), |
| m_pPDFDoc(pDoc), |
| m_pIFormFiller(NULL) |
| { |
| - |
| - m_pSysHandler = NULL; |
| m_pSysHandler = new CFX_SystemHandler(this); |
| - |
| - |
| - m_pJSRuntimeFactory = NULL; |
| m_pJSRuntimeFactory = GetJSRuntimeFactory(); |
| m_pJSRuntimeFactory->AddRef(); |
| } |
| @@ -255,6 +250,46 @@ CPDFDoc_Environment::~CPDFDoc_Environment() |
| m_pActionHandler = NULL; |
| } |
| +int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg, const FX_WCHAR* Title, FX_UINT Type, FX_UINT Icon) |
| +{ |
| + if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) |
| + { |
| + CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); |
| + CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); |
| + FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); |
| + FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength()); |
| + int ret = m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, pMsg, pTitle, Type, Icon); |
| + bsMsg.ReleaseBuffer(); |
| + bsTitle.ReleaseBuffer(); |
| + return ret; |
| + } |
| + return -1; |
| +} |
| + |
| +int CPDFDoc_Environment::JS_appResponse(const FX_WCHAR* Question, const FX_WCHAR* Title, const FX_WCHAR* Default, |
| + const FX_WCHAR* cLabel, FPDF_BOOL bPassword, void* response, int length) |
| +{ |
| + if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_response) |
| + { |
| + CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode(); |
| + CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); |
| + CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode(); |
| + CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode(); |
| + FPDF_WIDESTRING pQuestion = (FPDF_WIDESTRING)bsQuestion.GetBuffer(bsQuestion.GetLength()); |
| + FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength()); |
| + FPDF_WIDESTRING pDefault = (FPDF_WIDESTRING)bsDefault.GetBuffer(bsDefault.GetLength()); |
| + FPDF_WIDESTRING pLabel = (FPDF_WIDESTRING)bsLabel.GetBuffer(bsLabel.GetLength()); |
| + int ret = m_pInfo->m_pJsPlatform->app_response(m_pInfo->m_pJsPlatform, pQuestion, pTitle, |
| + pDefault, pLabel, bPassword, response, length); |
| + bsQuestion.ReleaseBuffer(); |
| + bsTitle.ReleaseBuffer(); |
| + bsDefault.ReleaseBuffer(); |
| + bsLabel.ReleaseBuffer(); |
| + return ret; |
| + } |
| + return -1; |
| +} |
| + |
| CFX_WideString CPDFDoc_Environment::JS_fieldBrowse() |
| { |
| if (!m_pInfo || |
| @@ -305,64 +340,82 @@ CFX_WideString CPDFDoc_Environment::JS_docGetFilePath() |
| return wsRet; |
| } |
| +void CPDFDoc_Environment::JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL) |
| +{ |
| + if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_submitForm) |
| + { |
| + CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode(); |
| + FPDF_WIDESTRING pDestination = (FPDF_WIDESTRING)bsDestination.GetBuffer(bsDestination.GetLength()); |
| + m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, length, pDestination); |
| + bsDestination.ReleaseBuffer(); |
| + } |
| +} |
| + |
| +void CPDFDoc_Environment::JS_docmailForm(void* mailData, int length, FPDF_BOOL bUI, |
| + const FX_WCHAR* To, const FX_WCHAR* Subject, |
| + const FX_WCHAR* CC, const FX_WCHAR* BCC, |
| + const FX_WCHAR* Msg) |
| +{ |
| + if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_mail) |
| + { |
| + CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode(); |
| + CFX_ByteString bsCC = CFX_WideString(Subject).UTF16LE_Encode(); |
| + CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode(); |
| + CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode(); |
| + CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); |
| + FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); |
| + FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); |
| + FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); |
| + FPDF_WIDESTRING pSubject = (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); |
| + FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); |
| + m_pInfo->m_pJsPlatform->Doc_mail(m_pInfo->m_pJsPlatform, mailData, length, bUI, pTo, pSubject, |
| + pCC, pBcc, pMsg); |
| + bsTo.ReleaseBuffer(); |
| + bsCC.ReleaseBuffer(); |
| + bsBcc.ReleaseBuffer(); |
| + bsSubject.ReleaseBuffer(); |
| + bsMsg.ReleaseBuffer(); |
| + } |
| +} |
| + |
| IFXJS_Runtime* CPDFDoc_Environment::GetJSRuntime() |
| { |
| - if(!IsJSInitiated()) |
| + if (!IsJSInitiated()) |
|
Lei Zhang
2015/07/16 17:05:06
kill tabs here and below
Tom Sepez
2015/07/16 18:01:28
Untabified file.
|
| return NULL; |
| - assert(m_pJSRuntimeFactory); |
| - if(!m_pJSRuntime) |
| + if (!m_pJSRuntime) |
| m_pJSRuntime = m_pJSRuntimeFactory->NewJSRuntime(this); |
| return m_pJSRuntime; |
| } |
| CPDFSDK_AnnotHandlerMgr* CPDFDoc_Environment::GetAnnotHandlerMgr() |
| { |
| - if(!m_pAnnotHandlerMgr) |
| + if (!m_pAnnotHandlerMgr) |
| m_pAnnotHandlerMgr = new CPDFSDK_AnnotHandlerMgr(this); |
| return m_pAnnotHandlerMgr; |
| } |
| CPDFSDK_ActionHandler* CPDFDoc_Environment::GetActionHander() |
| { |
| - if(!m_pActionHandler) |
| + if (!m_pActionHandler) |
| m_pActionHandler = new CPDFSDK_ActionHandler(this); |
| return m_pActionHandler; |
| } |
| -int CPDFDoc_Environment::RegAppHandle(FPDF_FORMFILLINFO* pFFinfo) |
| -{ |
| - m_pInfo = pFFinfo; |
| - return TRUE; |
| -} |
| - |
| -CPDFSDK_Document* CPDFDoc_Environment::GetCurrentDoc() |
| -{ |
| - return m_pSDKDoc; |
| -} |
| - |
| CFFL_IFormFiller* CPDFDoc_Environment::GetIFormFiller() |
| { |
| - if(!m_pIFormFiller) |
| + if (!m_pIFormFiller) |
| m_pIFormFiller = new CFFL_IFormFiller(this); |
| return m_pIFormFiller; |
| } |
| -FX_BOOL CPDFDoc_Environment::IsJSInitiated() |
| -{ |
| - if(m_pInfo) |
| - { |
| - if(m_pInfo->m_pJsPlatform) |
| - return TRUE; |
| - else |
| - return FALSE; |
| - } |
| - return FALSE; |
| -} |
| - |
| -CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv):m_pDoc(pDoc), |
| - m_pInterForm(NULL),m_pEnv(pEnv),m_pOccontent(NULL),m_bChangeMask(FALSE) |
| +CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv) : |
| + m_pDoc(pDoc), |
| + m_pInterForm(NULL), |
|
Lei Zhang
2015/07/16 17:05:06
nullptr
|
| + m_pEnv(pEnv), |
| + m_pOccontent(NULL), |
| + m_bChangeMask(FALSE), |
| + m_pFocusAnnot(NULL) |
| { |
| - m_pFocusAnnot = NULL; |
| } |
| CPDFSDK_Document::~CPDFSDK_Document() |