| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/fpdfxfa/include/cpdfxfa_docenvironment.h" | 7 #include "fpdfsdk/fpdfxfa/include/cpdfxfa_docenvironment.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 CPDFXFA_Page* pPage = m_pDocument->GetPage(pPageView); | 64 CPDFXFA_Page* pPage = m_pDocument->GetPage(pPageView); |
| 65 if (!pPage) | 65 if (!pPage) |
| 66 return; | 66 return; |
| 67 | 67 |
| 68 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 68 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); |
| 69 if (!pEnv) | 69 if (!pEnv) |
| 70 return; | 70 return; |
| 71 | 71 |
| 72 CFX_FloatRect rcPage = CFX_FloatRect::FromCFXRectF(rt); | 72 CFX_FloatRect rcPage = CFX_FloatRect::FromCFXRectF(rt); |
| 73 pEnv->FFI_Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, | 73 pEnv->Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, rcPage.right, |
| 74 rcPage.right, rcPage.top); | 74 rcPage.top); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget, | 77 void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget, |
| 78 FX_BOOL bVisible, | 78 FX_BOOL bVisible, |
| 79 const CFX_RectF* pRtAnchor) { | 79 const CFX_RectF* pRtAnchor) { |
| 80 if (!hWidget || !pRtAnchor || !m_pDocument->GetXFADoc() || | 80 if (!hWidget || !pRtAnchor || !m_pDocument->GetXFADoc() || |
| 81 !m_pDocument->GetSDKDoc() || !m_pDocument->GetXFADocView()) | 81 !m_pDocument->GetSDKDoc() || !m_pDocument->GetXFADocView()) |
| 82 return; | 82 return; |
| 83 | 83 |
| 84 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) | 84 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 95 | 95 |
| 96 CPDFXFA_Page* pPage = m_pDocument->GetPage(pPageView); | 96 CPDFXFA_Page* pPage = m_pDocument->GetPage(pPageView); |
| 97 if (!pPage) | 97 if (!pPage) |
| 98 return; | 98 return; |
| 99 | 99 |
| 100 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 100 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); |
| 101 if (!pEnv) | 101 if (!pEnv) |
| 102 return; | 102 return; |
| 103 | 103 |
| 104 CFX_FloatRect rcCaret = CFX_FloatRect::FromCFXRectF(*pRtAnchor); | 104 CFX_FloatRect rcCaret = CFX_FloatRect::FromCFXRectF(*pRtAnchor); |
| 105 pEnv->FFI_DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top, | 105 pEnv->DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top, |
| 106 rcCaret.right, rcCaret.bottom); | 106 rcCaret.right, rcCaret.bottom); |
| 107 } | 107 } |
| 108 | 108 |
| 109 FX_BOOL CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget, | 109 FX_BOOL CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget, |
| 110 FX_FLOAT fMinPopup, | 110 FX_FLOAT fMinPopup, |
| 111 FX_FLOAT fMaxPopup, | 111 FX_FLOAT fMaxPopup, |
| 112 const CFX_RectF& rtAnchor, | 112 const CFX_RectF& rtAnchor, |
| 113 CFX_RectF& rtPopup) { | 113 CFX_RectF& rtPopup) { |
| 114 if (!hWidget) | 114 if (!hWidget) |
| 115 return FALSE; | 115 return FALSE; |
| 116 | 116 |
| 117 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); | 117 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); |
| 118 if (!pXFAPageView) | 118 if (!pXFAPageView) |
| 119 return FALSE; | 119 return FALSE; |
| 120 | 120 |
| 121 CPDFXFA_Page* pPage = m_pDocument->GetPage(pXFAPageView); | 121 CPDFXFA_Page* pPage = m_pDocument->GetPage(pXFAPageView); |
| 122 if (!pPage) | 122 if (!pPage) |
| 123 return FALSE; | 123 return FALSE; |
| 124 | 124 |
| 125 CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); | 125 CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); |
| 126 int nRotate = pWidgetAcc->GetRotate(); | 126 int nRotate = pWidgetAcc->GetRotate(); |
| 127 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 127 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); |
| 128 if (!pEnv) | 128 if (!pEnv) |
| 129 return FALSE; | 129 return FALSE; |
| 130 | 130 |
| 131 FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f}; | 131 FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f}; |
| 132 pEnv->FFI_GetPageViewRect(pPage, pageViewRect); | 132 pEnv->GetPageViewRect(pPage, pageViewRect); |
| 133 | 133 |
| 134 int t1; | 134 int t1; |
| 135 int t2; | 135 int t2; |
| 136 CFX_FloatRect rcAnchor = CFX_FloatRect::FromCFXRectF(rtAnchor); | 136 CFX_FloatRect rcAnchor = CFX_FloatRect::FromCFXRectF(rtAnchor); |
| 137 switch (nRotate) { | 137 switch (nRotate) { |
| 138 case 90: { | 138 case 90: { |
| 139 t1 = (int)(pageViewRect.right - rcAnchor.right); | 139 t1 = (int)(pageViewRect.right - rcAnchor.right); |
| 140 t2 = (int)(rcAnchor.left - pageViewRect.left); | 140 t2 = (int)(rcAnchor.left - pageViewRect.left); |
| 141 if (rcAnchor.bottom < pageViewRect.bottom) | 141 if (rcAnchor.bottom < pageViewRect.bottom) |
| 142 rtPopup.left += rcAnchor.bottom - pageViewRect.bottom; | 142 rtPopup.left += rcAnchor.bottom - pageViewRect.bottom; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 menuFlag |= FXFA_MENU_REDO; | 246 menuFlag |= FXFA_MENU_REDO; |
| 247 if (hWidget->CanPaste()) | 247 if (hWidget->CanPaste()) |
| 248 menuFlag |= FXFA_MENU_PASTE; | 248 menuFlag |= FXFA_MENU_PASTE; |
| 249 if (hWidget->CanCopy()) | 249 if (hWidget->CanCopy()) |
| 250 menuFlag |= FXFA_MENU_COPY; | 250 menuFlag |= FXFA_MENU_COPY; |
| 251 if (hWidget->CanCut()) | 251 if (hWidget->CanCut()) |
| 252 menuFlag |= FXFA_MENU_CUT; | 252 menuFlag |= FXFA_MENU_CUT; |
| 253 if (hWidget->CanSelectAll()) | 253 if (hWidget->CanSelectAll()) |
| 254 menuFlag |= FXFA_MENU_SELECTALL; | 254 menuFlag |= FXFA_MENU_SELECTALL; |
| 255 | 255 |
| 256 return pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, nullptr); | 256 return pEnv->PopupMenu(pPage, hWidget, menuFlag, ptPopup, nullptr); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView, | 259 void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView, |
| 260 uint32_t dwFlags) { | 260 uint32_t dwFlags) { |
| 261 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 261 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); |
| 262 if (!pEnv) | 262 if (!pEnv) |
| 263 return; | 263 return; |
| 264 | 264 |
| 265 if (m_pDocument->GetLoadStatus() == FXFA_LOADSTATUS_LOADING || | 265 if (m_pDocument->GetLoadStatus() == FXFA_LOADSTATUS_LOADING || |
| 266 m_pDocument->GetLoadStatus() == FXFA_LOADSTATUS_CLOSING || | 266 m_pDocument->GetLoadStatus() == FXFA_LOADSTATUS_CLOSING || |
| (...skipping 16 matching lines...) Expand all Loading... |
| 283 | 283 |
| 284 m_pDocument->GetSDKDoc()->RemovePageView(pPage); | 284 m_pDocument->GetSDKDoc()->RemovePageView(pPage); |
| 285 pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter)); | 285 pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter)); |
| 286 } | 286 } |
| 287 | 287 |
| 288 int flag = (nNewCount < m_pDocument->GetOriginalPageCount()) | 288 int flag = (nNewCount < m_pDocument->GetOriginalPageCount()) |
| 289 ? FXFA_PAGEVIEWEVENT_POSTREMOVED | 289 ? FXFA_PAGEVIEWEVENT_POSTREMOVED |
| 290 : FXFA_PAGEVIEWEVENT_POSTADDED; | 290 : FXFA_PAGEVIEWEVENT_POSTADDED; |
| 291 int count = FXSYS_abs(nNewCount - m_pDocument->GetOriginalPageCount()); | 291 int count = FXSYS_abs(nNewCount - m_pDocument->GetOriginalPageCount()); |
| 292 m_pDocument->SetOriginalPageCount(nNewCount); | 292 m_pDocument->SetOriginalPageCount(nNewCount); |
| 293 pEnv->FFI_PageEvent(count, flag); | 293 pEnv->PageEvent(count, flag); |
| 294 } | 294 } |
| 295 | 295 |
| 296 void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget, | 296 void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget, |
| 297 CXFA_WidgetAcc* pWidgetData) { | 297 CXFA_WidgetAcc* pWidgetData) { |
| 298 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget) | 298 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget) |
| 299 return; | 299 return; |
| 300 | 300 |
| 301 CXFA_FFPageView* pPageView = hWidget->GetPageView(); | 301 CXFA_FFPageView* pPageView = hWidget->GetPageView(); |
| 302 if (!pPageView) | 302 if (!pPageView) |
| 303 return; | 303 return; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 int32_t CPDFXFA_DocEnvironment::GetCurrentPage(CXFA_FFDoc* hDoc) { | 337 int32_t CPDFXFA_DocEnvironment::GetCurrentPage(CXFA_FFDoc* hDoc) { |
| 338 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) | 338 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) |
| 339 return -1; | 339 return -1; |
| 340 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) | 340 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) |
| 341 return -1; | 341 return -1; |
| 342 | 342 |
| 343 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 343 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); |
| 344 if (!pEnv) | 344 if (!pEnv) |
| 345 return -1; | 345 return -1; |
| 346 | 346 |
| 347 return pEnv->FFI_GetCurrentPageIndex(this); | 347 return pEnv->GetCurrentPageIndex(this); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void CPDFXFA_DocEnvironment::SetCurrentPage(CXFA_FFDoc* hDoc, | 350 void CPDFXFA_DocEnvironment::SetCurrentPage(CXFA_FFDoc* hDoc, |
| 351 int32_t iCurPage) { | 351 int32_t iCurPage) { |
| 352 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc() || | 352 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc() || |
| 353 m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || | 353 m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || |
| 354 iCurPage >= m_pDocument->GetSDKDoc()->GetPageCount()) { | 354 iCurPage >= m_pDocument->GetSDKDoc()->GetPageCount()) { |
| 355 return; | 355 return; |
| 356 } | 356 } |
| 357 | 357 |
| 358 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 358 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); |
| 359 if (!pEnv) | 359 if (!pEnv) |
| 360 return; | 360 return; |
| 361 pEnv->FFI_SetCurrentPage(this, iCurPage); | 361 pEnv->SetCurrentPage(this, iCurPage); |
| 362 } | 362 } |
| 363 | 363 |
| 364 FX_BOOL CPDFXFA_DocEnvironment::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { | 364 FX_BOOL CPDFXFA_DocEnvironment::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { |
| 365 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) | 365 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) |
| 366 return FALSE; | 366 return FALSE; |
| 367 if (m_pDocument->GetSDKDoc()->GetInterForm()) | 367 if (m_pDocument->GetSDKDoc()->GetInterForm()) |
| 368 return m_pDocument->GetSDKDoc()->GetInterForm()->IsXfaCalculateEnabled(); | 368 return m_pDocument->GetSDKDoc()->GetInterForm()->IsXfaCalculateEnabled(); |
| 369 return FALSE; | 369 return FALSE; |
| 370 } | 370 } |
| 371 | 371 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); | 418 CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); |
| 419 if (wsFilePath.IsEmpty()) { | 419 if (wsFilePath.IsEmpty()) { |
| 420 if (!pEnv->GetFormFillInfo() || !pEnv->GetFormFillInfo()->m_pJsPlatform) | 420 if (!pEnv->GetFormFillInfo() || !pEnv->GetFormFillInfo()->m_pJsPlatform) |
| 421 return; | 421 return; |
| 422 | 422 |
| 423 CFX_WideString filepath = pEnv->JS_fieldBrowse(); | 423 CFX_WideString filepath = pEnv->JS_fieldBrowse(); |
| 424 bs = filepath.UTF16LE_Encode(); | 424 bs = filepath.UTF16LE_Encode(); |
| 425 } | 425 } |
| 426 int len = bs.GetLength(); | 426 int len = bs.GetLength(); |
| 427 FPDF_FILEHANDLER* pFileHandler = | 427 FPDF_FILEHANDLER* pFileHandler = |
| 428 pEnv->FFI_OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, | 428 pEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, |
| 429 (FPDF_WIDESTRING)bs.GetBuffer(len), "wb"); | 429 (FPDF_WIDESTRING)bs.GetBuffer(len), "wb"); |
| 430 bs.ReleaseBuffer(len); | 430 bs.ReleaseBuffer(len); |
| 431 if (!pFileHandler) | 431 if (!pFileHandler) |
| 432 return; | 432 return; |
| 433 | 433 |
| 434 CFPDF_FileStream fileWrite(pFileHandler); | 434 CFPDF_FileStream fileWrite(pFileHandler); |
| 435 CFX_ByteString content; | 435 CFX_ByteString content; |
| 436 if (fileType == FXFA_SAVEAS_XML) { | 436 if (fileType == FXFA_SAVEAS_XML) { |
| 437 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; | 437 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; |
| 438 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), | 438 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), |
| 439 content.GetLength()); | 439 content.GetLength()); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 | 507 |
| 508 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) | 508 if (m_pDocument->GetDocType() != DOCTYPE_DYNAMIC_XFA) |
| 509 return; | 509 return; |
| 510 | 510 |
| 511 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 511 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); |
| 512 if (!pEnv) | 512 if (!pEnv) |
| 513 return; | 513 return; |
| 514 | 514 |
| 515 CFX_WideStringC str(bsURL.c_str()); | 515 CFX_WideStringC str(bsURL.c_str()); |
| 516 | 516 |
| 517 pEnv->FFI_GotoURL(this, str, bAppend); | 517 pEnv->GotoURL(this, str, bAppend); |
| 518 } | 518 } |
| 519 | 519 |
| 520 FX_BOOL CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) { | 520 FX_BOOL CPDFXFA_DocEnvironment::IsValidationsEnabled(CXFA_FFDoc* hDoc) { |
| 521 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) | 521 if (hDoc != m_pDocument->GetXFADoc() || !m_pDocument->GetSDKDoc()) |
| 522 return FALSE; | 522 return FALSE; |
| 523 if (m_pDocument->GetSDKDoc()->GetInterForm()) | 523 if (m_pDocument->GetSDKDoc()->GetInterForm()) |
| 524 return m_pDocument->GetSDKDoc()->GetInterForm()->IsXfaValidationsEnabled(); | 524 return m_pDocument->GetSDKDoc()->GetInterForm()->IsXfaValidationsEnabled(); |
| 525 return TRUE; | 525 return TRUE; |
| 526 } | 526 } |
| 527 | 527 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 int fRet = pWidgetAcc->ProcessValidate(-1); | 633 int fRet = pWidgetAcc->ProcessValidate(-1); |
| 634 if (fRet == XFA_EVENTERROR_Error) { | 634 if (fRet == XFA_EVENTERROR_Error) { |
| 635 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 635 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); |
| 636 if (!pEnv) | 636 if (!pEnv) |
| 637 return FALSE; | 637 return FALSE; |
| 638 | 638 |
| 639 CFX_WideString ws; | 639 CFX_WideString ws; |
| 640 ws.FromLocal(IDS_XFA_Validate_Input); | 640 ws.FromLocal(IDS_XFA_Validate_Input); |
| 641 CFX_ByteString bs = ws.UTF16LE_Encode(); | 641 CFX_ByteString bs = ws.UTF16LE_Encode(); |
| 642 int len = bs.GetLength(); | 642 int len = bs.GetLength(); |
| 643 pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", | 643 pEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 0, |
| 644 0, 1); | 644 1); |
| 645 bs.ReleaseBuffer(len); | 645 bs.ReleaseBuffer(len); |
| 646 return FALSE; | 646 return FALSE; |
| 647 } | 647 } |
| 648 pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 648 pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
| 649 } | 649 } |
| 650 m_pDocument->GetXFADocView()->UpdateDocView(); | 650 m_pDocument->GetXFADocView()->UpdateDocView(); |
| 651 | 651 |
| 652 return TRUE; | 652 return TRUE; |
| 653 } | 653 } |
| 654 | 654 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 IFX_FileRead* CPDFXFA_DocEnvironment::OpenLinkedFile( | 694 IFX_FileRead* CPDFXFA_DocEnvironment::OpenLinkedFile( |
| 695 CXFA_FFDoc* hDoc, | 695 CXFA_FFDoc* hDoc, |
| 696 const CFX_WideString& wsLink) { | 696 const CFX_WideString& wsLink) { |
| 697 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); | 697 CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv(); |
| 698 if (!pEnv) | 698 if (!pEnv) |
| 699 return FALSE; | 699 return FALSE; |
| 700 | 700 |
| 701 CFX_ByteString bs = wsLink.UTF16LE_Encode(); | 701 CFX_ByteString bs = wsLink.UTF16LE_Encode(); |
| 702 int len = bs.GetLength(); | 702 int len = bs.GetLength(); |
| 703 FPDF_FILEHANDLER* pFileHandler = | 703 FPDF_FILEHANDLER* pFileHandler = |
| 704 pEnv->FFI_OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb"); | 704 pEnv->OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb"); |
| 705 bs.ReleaseBuffer(len); | 705 bs.ReleaseBuffer(len); |
| 706 | 706 |
| 707 if (!pFileHandler) | 707 if (!pFileHandler) |
| 708 return nullptr; | 708 return nullptr; |
| 709 return new CFPDF_FileStream(pFileHandler); | 709 return new CFPDF_FileStream(pFileHandler); |
| 710 } | 710 } |
| 711 | 711 |
| 712 FX_BOOL CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, | 712 FX_BOOL CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, |
| 713 int fileType, | 713 int fileType, |
| 714 FPDF_DWORD encodeType, | 714 FPDF_DWORD encodeType, |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 return FALSE; | 893 return FALSE; |
| 894 | 894 |
| 895 CFX_WideStringC csURLC; | 895 CFX_WideStringC csURLC; |
| 896 submit.GetSubmitTarget(csURLC); | 896 submit.GetSubmitTarget(csURLC); |
| 897 CFX_WideString csURL(csURLC); | 897 CFX_WideString csURL(csURLC); |
| 898 if (csURL.IsEmpty()) { | 898 if (csURL.IsEmpty()) { |
| 899 CFX_WideString ws; | 899 CFX_WideString ws; |
| 900 ws.FromLocal("Submit cancelled."); | 900 ws.FromLocal("Submit cancelled."); |
| 901 CFX_ByteString bs = ws.UTF16LE_Encode(); | 901 CFX_ByteString bs = ws.UTF16LE_Encode(); |
| 902 int len = bs.GetLength(); | 902 int len = bs.GetLength(); |
| 903 pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 0, | 903 pEnv->Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 0, 4); |
| 904 4); | |
| 905 bs.ReleaseBuffer(len); | 904 bs.ReleaseBuffer(len); |
| 906 return FALSE; | 905 return FALSE; |
| 907 } | 906 } |
| 908 | 907 |
| 909 FPDF_BOOL bRet = TRUE; | 908 FPDF_BOOL bRet = TRUE; |
| 910 FPDF_FILEHANDLER* pFileHandler = nullptr; | 909 FPDF_FILEHANDLER* pFileHandler = nullptr; |
| 911 int fileFlag = -1; | 910 int fileFlag = -1; |
| 912 switch (submit.GetSubmitFormat()) { | 911 switch (submit.GetSubmitFormat()) { |
| 913 case XFA_ATTRIBUTEENUM_Xdp: { | 912 case XFA_ATTRIBUTEENUM_Xdp: { |
| 914 CFX_WideStringC csContentC; | 913 CFX_WideStringC csContentC; |
| 915 submit.GetSubmitXDPContent(csContentC); | 914 submit.GetSubmitXDPContent(csContentC); |
| 916 CFX_WideString csContent; | 915 CFX_WideString csContent; |
| 917 csContent = csContentC; | 916 csContent = csContentC; |
| 918 csContent.TrimLeft(); | 917 csContent.TrimLeft(); |
| 919 csContent.TrimRight(); | 918 csContent.TrimRight(); |
| 920 CFX_WideString space; | 919 CFX_WideString space; |
| 921 space.FromLocal(" "); | 920 space.FromLocal(" "); |
| 922 csContent = space + csContent + space; | 921 csContent = space + csContent + space; |
| 923 FPDF_DWORD flag = 0; | 922 FPDF_DWORD flag = 0; |
| 924 if (submit.IsSubmitEmbedPDF()) | 923 if (submit.IsSubmitEmbedPDF()) |
| 925 flag |= FXFA_PDF; | 924 flag |= FXFA_PDF; |
| 926 | 925 |
| 927 ToXFAContentFlags(csContent, flag); | 926 ToXFAContentFlags(csContent, flag); |
| 928 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb"); | 927 pFileHandler = pEnv->OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb"); |
| 929 fileFlag = FXFA_SAVEAS_XDP; | 928 fileFlag = FXFA_SAVEAS_XDP; |
| 930 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag); | 929 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag); |
| 931 break; | 930 break; |
| 932 } | 931 } |
| 933 case XFA_ATTRIBUTEENUM_Xml: | 932 case XFA_ATTRIBUTEENUM_Xml: |
| 934 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); | 933 pFileHandler = pEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); |
| 935 fileFlag = FXFA_SAVEAS_XML; | 934 fileFlag = FXFA_SAVEAS_XML; |
| 936 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); | 935 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); |
| 937 break; | 936 break; |
| 938 case XFA_ATTRIBUTEENUM_Pdf: | 937 case XFA_ATTRIBUTEENUM_Pdf: |
| 939 break; | 938 break; |
| 940 case XFA_ATTRIBUTEENUM_Urlencoded: | 939 case XFA_ATTRIBUTEENUM_Urlencoded: |
| 941 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); | 940 pFileHandler = pEnv->OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); |
| 942 fileFlag = FXFA_SAVEAS_XML; | 941 fileFlag = FXFA_SAVEAS_XML; |
| 943 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); | 942 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); |
| 944 break; | 943 break; |
| 945 default: | 944 default: |
| 946 return false; | 945 return false; |
| 947 } | 946 } |
| 948 if (!pFileHandler) | 947 if (!pFileHandler) |
| 949 return FALSE; | 948 return FALSE; |
| 950 if (csURL.Left(7).CompareNoCase(L"mailto:") == 0) { | 949 if (csURL.Left(7).CompareNoCase(L"mailto:") == 0) { |
| 951 CFX_WideString csToAddress; | 950 CFX_WideString csToAddress; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 962 CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode(); | 961 CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode(); |
| 963 CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode(); | 962 CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode(); |
| 964 CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode(); | 963 CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode(); |
| 965 CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode(); | 964 CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode(); |
| 966 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); | 965 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); |
| 967 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); | 966 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); |
| 968 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); | 967 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); |
| 969 FPDF_WIDESTRING pSubject = | 968 FPDF_WIDESTRING pSubject = |
| 970 (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); | 969 (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); |
| 971 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); | 970 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); |
| 972 pEnv->FFI_EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg); | 971 pEnv->EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg); |
| 973 bsTo.ReleaseBuffer(); | 972 bsTo.ReleaseBuffer(); |
| 974 bsCC.ReleaseBuffer(); | 973 bsCC.ReleaseBuffer(); |
| 975 bsBcc.ReleaseBuffer(); | 974 bsBcc.ReleaseBuffer(); |
| 976 bsSubject.ReleaseBuffer(); | 975 bsSubject.ReleaseBuffer(); |
| 977 bsMsg.ReleaseBuffer(); | 976 bsMsg.ReleaseBuffer(); |
| 978 } else { | 977 } else { |
| 979 // HTTP or FTP | 978 // HTTP or FTP |
| 980 CFX_WideString ws; | 979 CFX_WideString ws; |
| 981 CFX_ByteString bs = csURL.UTF16LE_Encode(); | 980 CFX_ByteString bs = csURL.UTF16LE_Encode(); |
| 982 int len = bs.GetLength(); | 981 int len = bs.GetLength(); |
| 983 pEnv->FFI_UploadTo(pFileHandler, fileFlag, | 982 pEnv->UploadTo(pFileHandler, fileFlag, (FPDF_WIDESTRING)bs.GetBuffer(len)); |
| 984 (FPDF_WIDESTRING)bs.GetBuffer(len)); | |
| 985 bs.ReleaseBuffer(len); | 983 bs.ReleaseBuffer(len); |
| 986 } | 984 } |
| 987 return bRet; | 985 return bRet; |
| 988 } | 986 } |
| 989 | 987 |
| 990 FX_BOOL CPDFXFA_DocEnvironment::SetGlobalProperty( | 988 FX_BOOL CPDFXFA_DocEnvironment::SetGlobalProperty( |
| 991 CXFA_FFDoc* hDoc, | 989 CXFA_FFDoc* hDoc, |
| 992 const CFX_ByteStringC& szPropName, | 990 const CFX_ByteStringC& szPropName, |
| 993 CFXJSE_Value* pValue) { | 991 CFXJSE_Value* pValue) { |
| 994 if (hDoc != m_pDocument->GetXFADoc()) | 992 if (hDoc != m_pDocument->GetXFADoc()) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1014 if (!m_pJSContext) { | 1012 if (!m_pJSContext) { |
| 1015 m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->SetReaderDocument( | 1013 m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->SetReaderDocument( |
| 1016 m_pDocument->GetSDKDoc()); | 1014 m_pDocument->GetSDKDoc()); |
| 1017 m_pJSContext = | 1015 m_pJSContext = |
| 1018 m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->NewContext(); | 1016 m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->NewContext(); |
| 1019 } | 1017 } |
| 1020 | 1018 |
| 1021 return m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->GetValueByName( | 1019 return m_pDocument->GetSDKDoc()->GetEnv()->GetJSRuntime()->GetValueByName( |
| 1022 szPropName, pValue); | 1020 szPropName, pValue); |
| 1023 } | 1021 } |
| OLD | NEW |