diff options
author | dsinclair <dsinclair@chromium.org> | 2016-09-22 10:20:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-22 10:20:43 -0700 |
commit | 577ad2c9ea89c721ee1dbb89d1f7e12bb8c333f7 (patch) | |
tree | 7e298b611fd4bf07713c35d01c6bc9b900758191 | |
parent | bb577af2f17467a55c04fbff21a8f0ec1016601a (diff) | |
download | pdfium-577ad2c9ea89c721ee1dbb89d1f7e12bb8c333f7.tar.xz |
Move CPDFSDK_Environment code to cpp file
This CL moves the code from the .h file into the .cpp file.
Review-Url: https://codereview.chromium.org/2354363003
-rw-r--r-- | fpdfsdk/cpdfsdk_document.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_environment.cpp | 326 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_combobox.cpp | 3 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_textfield.cpp | 3 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/include/cpdfxfa_docenvironment.h | 4 | ||||
-rw-r--r-- | fpdfsdk/include/cpdfsdk_environment.h | 311 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_fftext.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/include/fxfa.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_hostpseudomodel.cpp | 2 |
10 files changed, 369 insertions, 296 deletions
diff --git a/fpdfsdk/cpdfsdk_document.cpp b/fpdfsdk/cpdfsdk_document.cpp index 9232da7b45..d4de6d0510 100644 --- a/fpdfsdk/cpdfsdk_document.cpp +++ b/fpdfsdk/cpdfsdk_document.cpp @@ -231,7 +231,7 @@ FX_BOOL CPDFSDK_Document::KillFocusAnnot(uint32_t nFlag) { int nFieldType = pWidget->GetFieldType(); if (FIELDTYPE_TEXTFIELD == nFieldType || FIELDTYPE_COMBOBOX == nFieldType) { - m_pEnv->OnSetFieldInputFocus(nullptr, nullptr, 0, FALSE); + m_pEnv->OnSetFieldInputFocus(nullptr, 0, FALSE); } } diff --git a/fpdfsdk/cpdfsdk_environment.cpp b/fpdfsdk/cpdfsdk_environment.cpp index 21549bc1ab..2d80240366 100644 --- a/fpdfsdk/cpdfsdk_environment.cpp +++ b/fpdfsdk/cpdfsdk_environment.cpp @@ -212,3 +212,329 @@ CFFL_InteractiveFormFiller* CPDFSDK_Environment::GetInteractiveFormFiller() { m_pFormFiller.reset(new CFFL_InteractiveFormFiller(this)); return m_pFormFiller.get(); } + +void CPDFSDK_Environment::Invalidate(FPDF_PAGE page, + double left, + double top, + double right, + double bottom) { + if (m_pInfo && m_pInfo->FFI_Invalidate) + m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); +} + +void CPDFSDK_Environment::OutputSelectedRect(FPDF_PAGE page, + double left, + double top, + double right, + double bottom) { + if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) + m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom); +} + +void CPDFSDK_Environment::SetCursor(int nCursorType) { + if (m_pInfo && m_pInfo->FFI_SetCursor) + m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); +} + +int CPDFSDK_Environment::SetTimer(int uElapse, TimerCallback lpTimerFunc) { + if (m_pInfo && m_pInfo->FFI_SetTimer) + return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc); + return -1; +} + +void CPDFSDK_Environment::KillTimer(int nTimerID) { + if (m_pInfo && m_pInfo->FFI_KillTimer) + m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); +} + +FX_SYSTEMTIME CPDFSDK_Environment::GetLocalTime() const { + FX_SYSTEMTIME fxtime; + if (!m_pInfo || !m_pInfo->FFI_GetLocalTime) + return fxtime; + + FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo); + fxtime.wDay = systime.wDay; + fxtime.wDayOfWeek = systime.wDayOfWeek; + fxtime.wHour = systime.wHour; + fxtime.wMilliseconds = systime.wMilliseconds; + fxtime.wMinute = systime.wMinute; + fxtime.wMonth = systime.wMonth; + fxtime.wSecond = systime.wSecond; + fxtime.wYear = systime.wYear; + return fxtime; +} + +void CPDFSDK_Environment::OnChange() { + if (m_pInfo && m_pInfo->FFI_OnChange) + m_pInfo->FFI_OnChange(m_pInfo); +} + +FX_BOOL CPDFSDK_Environment::IsSHIFTKeyDown(uint32_t nFlag) const { + return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; +} + +FX_BOOL CPDFSDK_Environment::IsCTRLKeyDown(uint32_t nFlag) const { + return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; +} + +FX_BOOL CPDFSDK_Environment::IsALTKeyDown(uint32_t nFlag) const { + return (nFlag & FWL_EVENTFLAG_AltKey) != 0; +} + +FPDF_PAGE CPDFSDK_Environment::GetPage(FPDF_DOCUMENT document, int nPageIndex) { + if (m_pInfo && m_pInfo->FFI_GetPage) + return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex); + return nullptr; +} + +FPDF_PAGE CPDFSDK_Environment::GetCurrentPage(FPDF_DOCUMENT document) { + if (m_pInfo && m_pInfo->FFI_GetCurrentPage) + return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); + return nullptr; +} + +void CPDFSDK_Environment::ExecuteNamedAction(const FX_CHAR* namedAction) { + if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction) + m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); +} + +void CPDFSDK_Environment::OnSetFieldInputFocus(FPDF_WIDESTRING focusText, + FPDF_DWORD nTextLen, + FX_BOOL bFocus) { + if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus) + m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus); +} + +void CPDFSDK_Environment::DoURIAction(const FX_CHAR* bsURI) { + if (m_pInfo && m_pInfo->FFI_DoURIAction) + m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); +} + +void CPDFSDK_Environment::DoGoToAction(int nPageIndex, + int zoomMode, + float* fPosArray, + int sizeOfArray) { + if (m_pInfo && m_pInfo->FFI_DoGoToAction) { + m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, + sizeOfArray); + } +} + +#ifdef PDF_ENABLE_XFA +void CPDFSDK_Environment::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 CPDFSDK_Environment::GetCurrentPageIndex(FPDF_DOCUMENT document) { + if (!m_pInfo || !m_pInfo->FFI_GetCurrentPageIndex) + return -1; + return m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document); +} + +void CPDFSDK_Environment::SetCurrentPage(FPDF_DOCUMENT document, int iCurPage) { + if (m_pInfo && m_pInfo->FFI_SetCurrentPage) + m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage); +} + +CFX_WideString CPDFSDK_Environment::GetPlatform() { + if (!m_pInfo || !m_pInfo->FFI_GetPlatform) + return L""; + + int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, nullptr, 0); + if (nRequiredLen <= 0) + return L""; + + char* pbuff = new char[nRequiredLen]; + 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; +} + +void CPDFSDK_Environment::GotoURL(FPDF_DOCUMENT document, + const CFX_WideStringC& wsURL) { + if (!m_pInfo || !m_pInfo->FFI_GotoURL) + return; + + 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 CPDFSDK_Environment::GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect) { + if (!m_pInfo || !m_pInfo->FFI_GetPageViewRect) + return; + + double left; + double top; + double right; + double bottom; + m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom); + + dstRect.left = static_cast<float>(left); + dstRect.top = static_cast<float>(top < bottom ? bottom : top); + dstRect.bottom = static_cast<float>(top < bottom ? top : bottom); + dstRect.right = static_cast<float>(right); +} + +FX_BOOL CPDFSDK_Environment::PopupMenu(FPDF_PAGE page, + FPDF_WIDGET hWidget, + int menuFlag, + CFX_PointF pt) { + if (!m_pInfo || !m_pInfo->FFI_PopupMenu) + return FALSE; + return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, pt.x, pt.y); +} + +void CPDFSDK_Environment::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 CPDFSDK_Environment::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 CPDFSDK_Environment::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* CPDFSDK_Environment::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 nullptr; +} + +IFX_FileRead* CPDFSDK_Environment::DownloadFromURL(const FX_WCHAR* url) { + if (!m_pInfo || !m_pInfo->FFI_DownloadFromURL) + return nullptr; + + 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); + + return new CFPDF_FileStream(fileHandler); +} + +CFX_WideString CPDFSDK_Environment::PostRequestURL( + const FX_WCHAR* wsURL, + const FX_WCHAR* wsData, + const FX_WCHAR* wsContentType, + const FX_WCHAR* wsEncode, + const FX_WCHAR* wsHeader) { + if (!m_pInfo || !m_pInfo->FFI_PostRequestURL) + return L""; + + 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 response; + FPDF_BStr_Init(&response); + m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, header, + &response); + + CFX_WideString wsRet = CFX_WideString::FromUTF16LE( + (FPDF_WIDESTRING)response.str, response.len / sizeof(FPDF_WIDESTRING)); + FPDF_BStr_Clear(&response); + + return wsRet; +} + +FPDF_BOOL CPDFSDK_Environment::PutRequestURL(const FX_WCHAR* wsURL, + const FX_WCHAR* wsData, + const FX_WCHAR* wsEncode) { + if (!m_pInfo || !m_pInfo->FFI_PutRequestURL) + return FALSE; + + 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); +} + +CFX_WideString CPDFSDK_Environment::GetLanguage() { + if (!m_pInfo || !m_pInfo->FFI_GetLanguage) + return L""; + + int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, nullptr, 0); + if (nRequiredLen <= 0) + return L""; + + char* pbuff = new char[nRequiredLen]; + 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( + (FPDF_WIDESTRING)bsRet.GetBuffer(bsRet.GetLength()), + bsRet.GetLength() / sizeof(FPDF_WIDESTRING)); + delete[] pbuff; + return wsRet; +} + +void CPDFSDK_Environment::PageEvent(int iPageCount, + uint32_t dwEventType) const { + if (m_pInfo && m_pInfo->FFI_PageEvent) + m_pInfo->FFI_PageEvent(m_pInfo, iPageCount, dwEventType); +} +#endif // PDF_ENABLE_XFA diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp index aaddcf5fbc..8c0cb645c5 100644 --- a/fpdfsdk/formfiller/cffl_combobox.cpp +++ b/fpdfsdk/formfiller/cffl_combobox.cpp @@ -271,8 +271,7 @@ void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) { int nCharacters = wsText.GetLength(); CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); - m_pEnv->OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, - nCharacters, TRUE); + m_pEnv->OnSetFieldInputFocus(pBuffer, nCharacters, TRUE); } } diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp index b80bbe4e17..611da7438a 100644 --- a/fpdfsdk/formfiller/cffl_textfield.cpp +++ b/fpdfsdk/formfiller/cffl_textfield.cpp @@ -278,7 +278,6 @@ void CFFL_TextField::OnSetFocus(CPWL_Wnd* pWnd) { int nCharacters = wsText.GetLength(); CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); - m_pEnv->OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, - nCharacters, TRUE); + m_pEnv->OnSetFieldInputFocus(pBuffer, nCharacters, TRUE); } } diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index 7ee3cbb859..106d997e44 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -253,7 +253,7 @@ FX_BOOL CPDFXFA_DocEnvironment::PopupMenu(CXFA_FFWidget* hWidget, if (hWidget->CanSelectAll()) menuFlag |= FXFA_MENU_SELECTALL; - return pEnv->PopupMenu(pPage, hWidget, menuFlag, ptPopup, nullptr); + return pEnv->PopupMenu(pPage, hWidget, menuFlag, ptPopup); } void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView, @@ -500,8 +500,7 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, } void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc, - const CFX_WideString& bsURL, - FX_BOOL bAppend) { + const CFX_WideString& bsURL) { if (hDoc != m_pDocument->GetXFADoc()) return; @@ -513,8 +512,7 @@ void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc, return; CFX_WideStringC str(bsURL.c_str()); - - pEnv->GotoURL(this, str, bAppend); + pEnv->GotoURL(this, str); } FX_BOOL CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) { diff --git a/fpdfsdk/fpdfxfa/include/cpdfxfa_docenvironment.h b/fpdfsdk/fpdfxfa/include/cpdfxfa_docenvironment.h index f6a538f816..26ff86122a 100644 --- a/fpdfsdk/fpdfxfa/include/cpdfxfa_docenvironment.h +++ b/fpdfsdk/fpdfxfa/include/cpdfxfa_docenvironment.h @@ -54,9 +54,7 @@ class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment { void ExportData(CXFA_FFDoc* hDoc, const CFX_WideString& wsFilePath, FX_BOOL bXDP) override; - void GotoURL(CXFA_FFDoc* hDoc, - const CFX_WideString& bsURL, - FX_BOOL bAppend) override; + void GotoURL(CXFA_FFDoc* hDoc, const CFX_WideString& bsURL) override; FX_BOOL IsValidationsEnabled(CXFA_FFDoc* hDoc) override; void SetValidationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) override; void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override; diff --git a/fpdfsdk/include/cpdfsdk_environment.h b/fpdfsdk/include/cpdfsdk_environment.h index 338d70f33b..61916e46ad 100644 --- a/fpdfsdk/include/cpdfsdk_environment.h +++ b/fpdfsdk/include/cpdfsdk_environment.h @@ -34,107 +34,35 @@ class CPDFSDK_Environment final { double left, double top, double right, - double bottom) { - if (m_pInfo && m_pInfo->FFI_Invalidate) - m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); - } - + double bottom); void OutputSelectedRect(FPDF_PAGE page, double left, double top, double right, - double bottom) { - if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) - m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom); - } - - void SetCursor(int nCursorType) { - if (m_pInfo && m_pInfo->FFI_SetCursor) - m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); - } - - int SetTimer(int uElapse, TimerCallback lpTimerFunc) { - if (m_pInfo && m_pInfo->FFI_SetTimer) - return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc); - return -1; - } - - void KillTimer(int nTimerID) { - if (m_pInfo && m_pInfo->FFI_KillTimer) - m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); - } - - FX_SYSTEMTIME GetLocalTime() const { - FX_SYSTEMTIME fxtime; - if (m_pInfo && m_pInfo->FFI_GetLocalTime) { - FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo); - fxtime.wDay = systime.wDay; - fxtime.wDayOfWeek = systime.wDayOfWeek; - fxtime.wHour = systime.wHour; - fxtime.wMilliseconds = systime.wMilliseconds; - fxtime.wMinute = systime.wMinute; - fxtime.wMonth = systime.wMonth; - fxtime.wSecond = systime.wSecond; - fxtime.wYear = systime.wYear; - } - return fxtime; - } - - void OnChange() { - if (m_pInfo && m_pInfo->FFI_OnChange) - m_pInfo->FFI_OnChange(m_pInfo); - } - - FX_BOOL IsSHIFTKeyDown(uint32_t nFlag) const { - return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; - } - - FX_BOOL IsCTRLKeyDown(uint32_t nFlag) const { - return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; - } - - FX_BOOL IsALTKeyDown(uint32_t nFlag) const { - return (nFlag & FWL_EVENTFLAG_AltKey) != 0; - } + double bottom); - FPDF_PAGE GetPage(FPDF_DOCUMENT document, int nPageIndex) { - if (m_pInfo && m_pInfo->FFI_GetPage) - return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex); - return nullptr; - } + void SetCursor(int nCursorType); + int SetTimer(int uElapse, TimerCallback lpTimerFunc); + void KillTimer(int nTimerID); + FX_SYSTEMTIME GetLocalTime() const; - FPDF_PAGE GetCurrentPage(FPDF_DOCUMENT document) { - if (m_pInfo && m_pInfo->FFI_GetCurrentPage) - return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); - return nullptr; - } + void OnChange(); + FX_BOOL IsSHIFTKeyDown(uint32_t nFlag) const; + FX_BOOL IsCTRLKeyDown(uint32_t nFlag) const; + FX_BOOL IsALTKeyDown(uint32_t nFlag) const; - void ExecuteNamedAction(const FX_CHAR* namedAction) { - if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction) - m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); - } + FPDF_PAGE GetPage(FPDF_DOCUMENT document, int nPageIndex); + FPDF_PAGE GetCurrentPage(FPDF_DOCUMENT document); - void OnSetFieldInputFocus(void* field, - FPDF_WIDESTRING focusText, + void ExecuteNamedAction(const FX_CHAR* namedAction); + void OnSetFieldInputFocus(FPDF_WIDESTRING focusText, FPDF_DWORD nTextLen, - FX_BOOL bFocus) { - if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus) - m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus); - } - - void DoURIAction(const FX_CHAR* bsURI) { - if (m_pInfo && m_pInfo->FFI_DoURIAction) - m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); - } - + FX_BOOL bFocus); + void DoURIAction(const FX_CHAR* bsURI); void DoGoToAction(int nPageIndex, int zoomMode, float* fPosArray, - int sizeOfArray) { - if (m_pInfo && m_pInfo->FFI_DoGoToAction) - m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, - sizeOfArray); - } + int sizeOfArray); #ifdef PDF_ENABLE_XFA void DisplayCaret(FPDF_PAGE page, @@ -142,219 +70,46 @@ class CPDFSDK_Environment final { 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 GetCurrentPageIndex(FPDF_DOCUMENT document) { - if (!m_pInfo || !m_pInfo->FFI_GetCurrentPageIndex) - return -1; - return m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document); - } - - void SetCurrentPage(FPDF_DOCUMENT document, int iCurPage) { - if (m_pInfo && m_pInfo->FFI_SetCurrentPage) - m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage); - } + double bottom); + int GetCurrentPageIndex(FPDF_DOCUMENT document); + void SetCurrentPage(FPDF_DOCUMENT document, int iCurPage); // TODO(dsinclair): This should probably change to PDFium? CFX_WideString FFI_GetAppName() const { return CFX_WideString(L"Acrobat"); } - CFX_WideString GetPlatform() { - if (!m_pInfo || !m_pInfo->FFI_GetPlatform) - return L""; - - int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, nullptr, 0); - if (nRequiredLen <= 0) - return L""; - - char* pbuff = new char[nRequiredLen]; - 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; - } - - void GotoURL(FPDF_DOCUMENT document, - const CFX_WideStringC& 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 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 = static_cast<float>(left); - dstRect.top = static_cast<float>(top < bottom ? bottom : top); - dstRect.bottom = static_cast<float>(top < bottom ? top : bottom); - dstRect.right = static_cast<float>(right); - } - } - + CFX_WideString GetPlatform(); + void GotoURL(FPDF_DOCUMENT document, const CFX_WideStringC& wsURL); + void GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect); FX_BOOL 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 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); - } + CFX_PointF pt); + void Alert(FPDF_WIDESTRING Msg, FPDF_WIDESTRING Title, int Type, int Icon); void 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); - } - + FPDF_WIDESTRING pMsg); void 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_WIDESTRING uploadTo); FPDF_FILEHANDLER* 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 nullptr; - } - - IFX_FileRead* DownloadFromURL(const FX_WCHAR* url) { - if (!m_pInfo || !m_pInfo->FFI_DownloadFromURL) - return nullptr; - - 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); - - return new CFPDF_FileStream(fileHandler); - } - + const char* mode); + IFX_FileRead* DownloadFromURL(const FX_WCHAR* url); CFX_WideString PostRequestURL(const FX_WCHAR* wsURL, const FX_WCHAR* wsData, const FX_WCHAR* wsContentType, const FX_WCHAR* wsEncode, - const FX_WCHAR* wsHeader) { - if (!m_pInfo || !m_pInfo->FFI_PostRequestURL) - return L""; - - 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 response; - FPDF_BStr_Init(&response); - m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, header, - &response); - - CFX_WideString wsRet = CFX_WideString::FromUTF16LE( - (unsigned short*)response.str, response.len / sizeof(unsigned short)); - FPDF_BStr_Clear(&response); - - return wsRet; - } - + const FX_WCHAR* wsHeader); FPDF_BOOL PutRequestURL(const FX_WCHAR* wsURL, const FX_WCHAR* wsData, - const FX_WCHAR* wsEncode) { - if (!m_pInfo || !m_pInfo->FFI_PutRequestURL) - return FALSE; - - CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); - FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); + const FX_WCHAR* wsEncode); + CFX_WideString GetLanguage(); - 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); - } - - CFX_WideString GetLanguage() { - if (!m_pInfo || !m_pInfo->FFI_GetLanguage) - return L""; - - int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, nullptr, 0); - if (nRequiredLen <= 0) - return L""; - - char* pbuff = new char[nRequiredLen]; - 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; - } - - void PageEvent(int iPageCount, uint32_t dwEventType) const { - if (m_pInfo && m_pInfo->FFI_PageEvent) - m_pInfo->FFI_PageEvent(m_pInfo, iPageCount, dwEventType); - } + void PageEvent(int iPageCount, uint32_t dwEventType) const; #endif // PDF_ENABLE_XFA int JS_appAlert(const FX_WCHAR* Msg, diff --git a/xfa/fxfa/app/xfa_fftext.cpp b/xfa/fxfa/app/xfa_fftext.cpp index 2e5bb6420d..ad0fdbc42c 100644 --- a/xfa/fxfa/app/xfa_fftext.cpp +++ b/xfa/fxfa/app/xfa_fftext.cpp @@ -135,7 +135,7 @@ FX_BOOL CXFA_FFText::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { return FALSE; } CXFA_FFDoc* pDoc = GetDoc(); - pDoc->GetDocEnvironment()->GotoURL(pDoc, wsURLContent, FALSE); + pDoc->GetDocEnvironment()->GotoURL(pDoc, wsURLContent); return TRUE; } FWL_WidgetHit CXFA_FFText::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { diff --git a/xfa/fxfa/include/fxfa.h b/xfa/fxfa/include/fxfa.h index 04fabeec11..1ffcbf7dbb 100644 --- a/xfa/fxfa/include/fxfa.h +++ b/xfa/fxfa/include/fxfa.h @@ -321,9 +321,7 @@ class IXFA_DocEnvironment { virtual void ExportData(CXFA_FFDoc* hDoc, const CFX_WideString& wsFilePath, FX_BOOL bXDP) = 0; - virtual void GotoURL(CXFA_FFDoc* hDoc, - const CFX_WideString& bsURL, - FX_BOOL bAppend) = 0; + virtual void GotoURL(CXFA_FFDoc* hDoc, const CFX_WideString& bsURL) = 0; virtual FX_BOOL IsValidationsEnabled(CXFA_FFDoc* hDoc) = 0; virtual void SetValidationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) = 0; virtual void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) = 0; diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp index 5ca550aae8..d4fd19e8e0 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp @@ -239,7 +239,7 @@ void CScript_HostPseudoModel::GotoURL(CFXJSE_Arguments* pArguments) { CFX_ByteString bsURL = pArguments->GetUTF8String(0); wsURL = CFX_WideString::FromUTF8(bsURL.AsStringC()); } - pNotify->GetDocEnvironment()->GotoURL(hDoc, wsURL, TRUE); + pNotify->GetDocEnvironment()->GotoURL(hDoc, wsURL); } void CScript_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) { if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |