| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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/fpdfxfa_doc.h" | 7 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.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_document.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 #ifndef _WIN32 | 42 #ifndef _WIN32 |
| 43 extern void SetLastError(int err); | 43 extern void SetLastError(int err); |
| 44 extern int GetLastError(); | 44 extern int GetLastError(); |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 CPDFXFA_Document::CPDFXFA_Document(CPDF_Document* pPDFDoc, | 47 CPDFXFA_Document::CPDFXFA_Document(CPDF_Document* pPDFDoc, |
| 48 CPDFXFA_App* pProvider) | 48 CPDFXFA_App* pProvider) |
| 49 : m_iDocType(DOCTYPE_PDF), | 49 : m_iDocType(DOCTYPE_PDF), |
| 50 m_pPDFDoc(pPDFDoc), | 50 m_pPDFDoc(pPDFDoc), |
| 51 m_pSDKDoc(nullptr), | |
| 52 m_pXFADoc(nullptr), | |
| 53 m_pXFADocView(nullptr), | 51 m_pXFADocView(nullptr), |
| 54 m_pApp(pProvider), | 52 m_pApp(pProvider), |
| 55 m_pJSContext(nullptr), | 53 m_pJSContext(nullptr), |
| 56 m_nLoadStatus(FXFA_LOADSTATUS_PRELOAD), | 54 m_nLoadStatus(FXFA_LOADSTATUS_PRELOAD), |
| 57 m_nPageCount(0) {} | 55 m_nPageCount(0) {} |
| 58 | 56 |
| 59 CPDFXFA_Document::~CPDFXFA_Document() { | 57 CPDFXFA_Document::~CPDFXFA_Document() { |
| 60 m_nLoadStatus = FXFA_LOADSTATUS_CLOSING; | 58 m_nLoadStatus = FXFA_LOADSTATUS_CLOSING; |
| 61 | 59 |
| 62 if (m_pXFADoc) { | 60 if (m_pXFADoc) { |
| 63 CXFA_FFApp* pApp = m_pApp->GetXFAApp(); | 61 CXFA_FFApp* pApp = m_pApp->GetXFAApp(); |
| 64 if (pApp) { | 62 if (pApp) { |
| 65 CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler(); | 63 CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler(); |
| 66 if (pDocHandler) { | 64 if (pDocHandler) { |
| 67 CloseXFADoc(pDocHandler); | 65 CloseXFADoc(pDocHandler); |
| 68 } | 66 } |
| 69 } | 67 } |
| 70 delete m_pXFADoc; | 68 m_pXFADoc.reset(); |
| 71 } | 69 } |
| 72 if (m_pJSContext && m_pSDKDoc && m_pSDKDoc->GetEnv()) | 70 if (m_pJSContext && m_pSDKDoc && m_pSDKDoc->GetEnv()) |
| 73 m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext); | 71 m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext); |
| 74 delete m_pSDKDoc; | 72 // |m_pSDKDoc| has to be released before |pParser| and |m_pPDFDoc| since it |
| 73 // needs to access them to kill focused annotations. |
| 74 m_pSDKDoc.reset(); |
| 75 if (m_pPDFDoc) { | 75 if (m_pPDFDoc) { |
| 76 CPDF_Parser* pParser = m_pPDFDoc->GetParser(); | 76 CPDF_Parser* pParser = m_pPDFDoc->GetParser(); |
| 77 if (pParser) | 77 if (pParser) |
| 78 delete pParser; | 78 delete pParser; |
| 79 else | 79 else |
| 80 delete m_pPDFDoc; | 80 delete m_pPDFDoc; |
| 81 } | 81 } |
| 82 | 82 |
| 83 m_nLoadStatus = FXFA_LOADSTATUS_CLOSED; | 83 m_nLoadStatus = FXFA_LOADSTATUS_CLOSED; |
| 84 } | 84 } |
| 85 | 85 |
| 86 FX_BOOL CPDFXFA_Document::LoadXFADoc() { | 86 FX_BOOL CPDFXFA_Document::LoadXFADoc() { |
| 87 m_nLoadStatus = FXFA_LOADSTATUS_LOADING; | 87 m_nLoadStatus = FXFA_LOADSTATUS_LOADING; |
| 88 | 88 |
| 89 if (!m_pPDFDoc) | 89 if (!m_pPDFDoc) |
| 90 return FALSE; | 90 return FALSE; |
| 91 | 91 |
| 92 m_XFAPageList.RemoveAll(); | 92 m_XFAPageList.RemoveAll(); |
| 93 | 93 |
| 94 CXFA_FFApp* pApp = m_pApp->GetXFAApp(); | 94 CXFA_FFApp* pApp = m_pApp->GetXFAApp(); |
| 95 if (!pApp) | 95 if (!pApp) |
| 96 return FALSE; | 96 return FALSE; |
| 97 | 97 |
| 98 m_pXFADoc = pApp->CreateDoc(this, m_pPDFDoc); | 98 m_pXFADoc.reset(pApp->CreateDoc(this, m_pPDFDoc)); |
| 99 if (!m_pXFADoc) { | 99 if (!m_pXFADoc) { |
| 100 SetLastError(FPDF_ERR_XFALOAD); | 100 SetLastError(FPDF_ERR_XFALOAD); |
| 101 return FALSE; | 101 return FALSE; |
| 102 } | 102 } |
| 103 | 103 |
| 104 CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler(); | 104 CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler(); |
| 105 if (!pDocHandler) { | 105 if (!pDocHandler) { |
| 106 SetLastError(FPDF_ERR_XFALOAD); | 106 SetLastError(FPDF_ERR_XFALOAD); |
| 107 return FALSE; | 107 return FALSE; |
| 108 } | 108 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 pPage->Release(); | 215 pPage->Release(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void CPDFXFA_Document::RemovePage(CPDFXFA_Page* page) { | 218 void CPDFXFA_Document::RemovePage(CPDFXFA_Page* page) { |
| 219 m_XFAPageList.SetAt(page->GetPageIndex(), nullptr); | 219 m_XFAPageList.SetAt(page->GetPageIndex(), nullptr); |
| 220 } | 220 } |
| 221 | 221 |
| 222 CPDFSDK_Document* CPDFXFA_Document::GetSDKDocument( | 222 CPDFSDK_Document* CPDFXFA_Document::GetSDKDocument( |
| 223 CPDFDoc_Environment* pFormFillEnv) { | 223 CPDFDoc_Environment* pFormFillEnv) { |
| 224 if (!m_pSDKDoc && pFormFillEnv) | 224 if (!m_pSDKDoc && pFormFillEnv) |
| 225 m_pSDKDoc = new CPDFSDK_Document(this, pFormFillEnv); | 225 m_pSDKDoc.reset(new CPDFSDK_Document(this, pFormFillEnv)); |
| 226 return m_pSDKDoc; | 226 return m_pSDKDoc.get(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void CPDFXFA_Document::FXRect2PDFRect(const CFX_RectF& fxRectF, | 229 void CPDFXFA_Document::FXRect2PDFRect(const CFX_RectF& fxRectF, |
| 230 CFX_FloatRect& pdfRect) { | 230 CFX_FloatRect& pdfRect) { |
| 231 pdfRect.left = fxRectF.left; | 231 pdfRect.left = fxRectF.left; |
| 232 pdfRect.top = fxRectF.bottom(); | 232 pdfRect.top = fxRectF.bottom(); |
| 233 pdfRect.right = fxRectF.right(); | 233 pdfRect.right = fxRectF.right(); |
| 234 pdfRect.bottom = fxRectF.top; | 234 pdfRect.bottom = fxRectF.top; |
| 235 } | 235 } |
| 236 | 236 |
| 237 void CPDFXFA_Document::SetChangeMark(CXFA_FFDoc* hDoc) { | 237 void CPDFXFA_Document::SetChangeMark(CXFA_FFDoc* hDoc) { |
| 238 if (hDoc == m_pXFADoc && m_pSDKDoc) { | 238 if (hDoc == m_pXFADoc.get() && m_pSDKDoc) { |
| 239 m_pSDKDoc->SetChangeMark(); | 239 m_pSDKDoc->SetChangeMark(); |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 | 242 |
| 243 void CPDFXFA_Document::InvalidateRect(CXFA_FFPageView* pPageView, | 243 void CPDFXFA_Document::InvalidateRect(CXFA_FFPageView* pPageView, |
| 244 const CFX_RectF& rt, | 244 const CFX_RectF& rt, |
| 245 uint32_t dwFlags /* = 0 */) { | 245 uint32_t dwFlags /* = 0 */) { |
| 246 if (!m_pXFADoc || !m_pSDKDoc) | 246 if (!m_pXFADoc || !m_pSDKDoc) |
| 247 return; | 247 return; |
| 248 | 248 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 } | 525 } |
| 526 | 526 |
| 527 FX_BOOL CPDFXFA_Document::RenderCustomWidget(CXFA_FFWidget* hWidget, | 527 FX_BOOL CPDFXFA_Document::RenderCustomWidget(CXFA_FFWidget* hWidget, |
| 528 CFX_Graphics* pGS, | 528 CFX_Graphics* pGS, |
| 529 CFX_Matrix* pMatrix, | 529 CFX_Matrix* pMatrix, |
| 530 const CFX_RectF& rtUI) { | 530 const CFX_RectF& rtUI) { |
| 531 return FALSE; | 531 return FALSE; |
| 532 } | 532 } |
| 533 | 533 |
| 534 int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) { | 534 int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) { |
| 535 if (hDoc == m_pXFADoc && m_pSDKDoc) | 535 if (hDoc == m_pXFADoc.get() && m_pSDKDoc) |
| 536 return GetPageCount(); | 536 return GetPageCount(); |
| 537 return 0; | 537 return 0; |
| 538 } | 538 } |
| 539 | 539 |
| 540 int32_t CPDFXFA_Document::GetCurrentPage(CXFA_FFDoc* hDoc) { | 540 int32_t CPDFXFA_Document::GetCurrentPage(CXFA_FFDoc* hDoc) { |
| 541 if (hDoc != m_pXFADoc || !m_pSDKDoc) | 541 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
| 542 return -1; | 542 return -1; |
| 543 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) | 543 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) |
| 544 return -1; | 544 return -1; |
| 545 | 545 |
| 546 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 546 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 547 if (!pEnv) | 547 if (!pEnv) |
| 548 return -1; | 548 return -1; |
| 549 | 549 |
| 550 return pEnv->FFI_GetCurrentPageIndex(this); | 550 return pEnv->FFI_GetCurrentPageIndex(this); |
| 551 } | 551 } |
| 552 | 552 |
| 553 void CPDFXFA_Document::SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) { | 553 void CPDFXFA_Document::SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) { |
| 554 if (hDoc != m_pXFADoc || !m_pSDKDoc || m_iDocType != DOCTYPE_DYNAMIC_XFA || | 554 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc || |
| 555 iCurPage < 0 || iCurPage >= m_pSDKDoc->GetPageCount()) { | 555 m_iDocType != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || |
| 556 iCurPage >= m_pSDKDoc->GetPageCount()) { |
| 556 return; | 557 return; |
| 557 } | 558 } |
| 558 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 559 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 559 if (!pEnv) | 560 if (!pEnv) |
| 560 return; | 561 return; |
| 561 pEnv->FFI_SetCurrentPage(this, iCurPage); | 562 pEnv->FFI_SetCurrentPage(this, iCurPage); |
| 562 } | 563 } |
| 563 FX_BOOL CPDFXFA_Document::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { | 564 FX_BOOL CPDFXFA_Document::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { |
| 564 if (hDoc != m_pXFADoc || !m_pSDKDoc) | 565 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
| 565 return FALSE; | 566 return FALSE; |
| 566 if (m_pSDKDoc->GetInterForm()) | 567 if (m_pSDKDoc->GetInterForm()) |
| 567 return m_pSDKDoc->GetInterForm()->IsXfaCalculateEnabled(); | 568 return m_pSDKDoc->GetInterForm()->IsXfaCalculateEnabled(); |
| 568 | 569 |
| 569 return FALSE; | 570 return FALSE; |
| 570 } | 571 } |
| 571 void CPDFXFA_Document::SetCalculationsEnabled(CXFA_FFDoc* hDoc, | 572 void CPDFXFA_Document::SetCalculationsEnabled(CXFA_FFDoc* hDoc, |
| 572 FX_BOOL bEnabled) { | 573 FX_BOOL bEnabled) { |
| 573 if (hDoc != m_pXFADoc || !m_pSDKDoc) | 574 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
| 574 return; | 575 return; |
| 575 if (m_pSDKDoc->GetInterForm()) | 576 if (m_pSDKDoc->GetInterForm()) |
| 576 m_pSDKDoc->GetInterForm()->XfaEnableCalculate(bEnabled); | 577 m_pSDKDoc->GetInterForm()->XfaEnableCalculate(bEnabled); |
| 577 } | 578 } |
| 578 | 579 |
| 579 void CPDFXFA_Document::GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) { | 580 void CPDFXFA_Document::GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) { |
| 580 if (hDoc != m_pXFADoc || !m_pPDFDoc) | 581 if (hDoc != m_pXFADoc.get() || !m_pPDFDoc) |
| 581 return; | 582 return; |
| 582 | 583 |
| 583 CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo(); | 584 CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo(); |
| 584 if (!pInfoDict) | 585 if (!pInfoDict) |
| 585 return; | 586 return; |
| 586 | 587 |
| 587 CFX_ByteString csTitle = pInfoDict->GetStringBy("Title"); | 588 CFX_ByteString csTitle = pInfoDict->GetStringBy("Title"); |
| 588 wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength())); | 589 wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength())); |
| 589 csTitle.ReleaseBuffer(csTitle.GetLength()); | 590 csTitle.ReleaseBuffer(csTitle.GetLength()); |
| 590 } | 591 } |
| 591 | 592 |
| 592 void CPDFXFA_Document::SetTitle(CXFA_FFDoc* hDoc, | 593 void CPDFXFA_Document::SetTitle(CXFA_FFDoc* hDoc, |
| 593 const CFX_WideString& wsTitle) { | 594 const CFX_WideString& wsTitle) { |
| 594 if (hDoc != m_pXFADoc || !m_pPDFDoc) | 595 if (hDoc != m_pXFADoc.get() || !m_pPDFDoc) |
| 595 return; | 596 return; |
| 596 | 597 |
| 597 if (CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo()) | 598 if (CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo()) |
| 598 pInfoDict->SetAt("Title", new CPDF_String(wsTitle)); | 599 pInfoDict->SetAt("Title", new CPDF_String(wsTitle)); |
| 599 } | 600 } |
| 600 | 601 |
| 601 void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, | 602 void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, |
| 602 const CFX_WideString& wsFilePath, | 603 const CFX_WideString& wsFilePath, |
| 603 FX_BOOL bXDP) { | 604 FX_BOOL bXDP) { |
| 604 if (hDoc != m_pXFADoc) | 605 if (hDoc != m_pXFADoc.get()) |
| 605 return; | 606 return; |
| 606 | 607 |
| 607 if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) | 608 if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) |
| 608 return; | 609 return; |
| 609 | 610 |
| 610 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 611 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 611 if (!pEnv) | 612 if (!pEnv) |
| 612 return; | 613 return; |
| 613 | 614 |
| 614 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; | 615 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 if (!fileWrite.Flush()) { | 688 if (!fileWrite.Flush()) { |
| 688 // Ignoring flush error. | 689 // Ignoring flush error. |
| 689 } | 690 } |
| 690 } | 691 } |
| 691 void CPDFXFA_Document::ImportData(CXFA_FFDoc* hDoc, | 692 void CPDFXFA_Document::ImportData(CXFA_FFDoc* hDoc, |
| 692 const CFX_WideString& wsFilePath) {} | 693 const CFX_WideString& wsFilePath) {} |
| 693 | 694 |
| 694 void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc, | 695 void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc, |
| 695 const CFX_WideString& bsURL, | 696 const CFX_WideString& bsURL, |
| 696 FX_BOOL bAppend) { | 697 FX_BOOL bAppend) { |
| 697 if (hDoc != m_pXFADoc) | 698 if (hDoc != m_pXFADoc.get()) |
| 698 return; | 699 return; |
| 699 | 700 |
| 700 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) | 701 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) |
| 701 return; | 702 return; |
| 702 | 703 |
| 703 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 704 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 704 if (!pEnv) | 705 if (!pEnv) |
| 705 return; | 706 return; |
| 706 | 707 |
| 707 CFX_WideStringC str(bsURL.c_str()); | 708 CFX_WideStringC str(bsURL.c_str()); |
| 708 | 709 |
| 709 pEnv->FFI_GotoURL(this, str, bAppend); | 710 pEnv->FFI_GotoURL(this, str, bAppend); |
| 710 } | 711 } |
| 711 | 712 |
| 712 FX_BOOL CPDFXFA_Document::IsValidationsEnabled(CXFA_FFDoc* hDoc) { | 713 FX_BOOL CPDFXFA_Document::IsValidationsEnabled(CXFA_FFDoc* hDoc) { |
| 713 if (hDoc != m_pXFADoc || !m_pSDKDoc) | 714 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
| 714 return FALSE; | 715 return FALSE; |
| 715 if (m_pSDKDoc->GetInterForm()) | 716 if (m_pSDKDoc->GetInterForm()) |
| 716 return m_pSDKDoc->GetInterForm()->IsXfaValidationsEnabled(); | 717 return m_pSDKDoc->GetInterForm()->IsXfaValidationsEnabled(); |
| 717 | 718 |
| 718 return TRUE; | 719 return TRUE; |
| 719 } | 720 } |
| 720 void CPDFXFA_Document::SetValidationsEnabled(CXFA_FFDoc* hDoc, | 721 void CPDFXFA_Document::SetValidationsEnabled(CXFA_FFDoc* hDoc, |
| 721 FX_BOOL bEnabled) { | 722 FX_BOOL bEnabled) { |
| 722 if (hDoc != m_pXFADoc || !m_pSDKDoc) | 723 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
| 723 return; | 724 return; |
| 724 if (m_pSDKDoc->GetInterForm()) | 725 if (m_pSDKDoc->GetInterForm()) |
| 725 m_pSDKDoc->GetInterForm()->XfaSetValidationsEnabled(bEnabled); | 726 m_pSDKDoc->GetInterForm()->XfaSetValidationsEnabled(bEnabled); |
| 726 } | 727 } |
| 727 void CPDFXFA_Document::SetFocusWidget(CXFA_FFDoc* hDoc, | 728 void CPDFXFA_Document::SetFocusWidget(CXFA_FFDoc* hDoc, |
| 728 CXFA_FFWidget* hWidget) { | 729 CXFA_FFWidget* hWidget) { |
| 729 if (hDoc != m_pXFADoc) | 730 if (hDoc != m_pXFADoc.get()) |
| 730 return; | 731 return; |
| 731 | 732 |
| 732 if (!hWidget) { | 733 if (!hWidget) { |
| 733 m_pSDKDoc->SetFocusAnnot(nullptr); | 734 m_pSDKDoc->SetFocusAnnot(nullptr); |
| 734 return; | 735 return; |
| 735 } | 736 } |
| 736 | 737 |
| 737 int pageViewCount = m_pSDKDoc->GetPageViewCount(); | 738 int pageViewCount = m_pSDKDoc->GetPageViewCount(); |
| 738 for (int i = 0; i < pageViewCount; i++) { | 739 for (int i = 0; i < pageViewCount; i++) { |
| 739 CPDFSDK_PageView* pPageView = m_pSDKDoc->GetPageView(i); | 740 CPDFSDK_PageView* pPageView = m_pSDKDoc->GetPageView(i); |
| 740 if (!pPageView) | 741 if (!pPageView) |
| 741 continue; | 742 continue; |
| 742 CPDFSDK_Annot* pAnnot = pPageView->GetAnnotByXFAWidget(hWidget); | 743 CPDFSDK_Annot* pAnnot = pPageView->GetAnnotByXFAWidget(hWidget); |
| 743 if (pAnnot) { | 744 if (pAnnot) { |
| 744 m_pSDKDoc->SetFocusAnnot(pAnnot); | 745 m_pSDKDoc->SetFocusAnnot(pAnnot); |
| 745 break; | 746 break; |
| 746 } | 747 } |
| 747 } | 748 } |
| 748 } | 749 } |
| 749 void CPDFXFA_Document::Print(CXFA_FFDoc* hDoc, | 750 void CPDFXFA_Document::Print(CXFA_FFDoc* hDoc, |
| 750 int32_t nStartPage, | 751 int32_t nStartPage, |
| 751 int32_t nEndPage, | 752 int32_t nEndPage, |
| 752 uint32_t dwOptions) { | 753 uint32_t dwOptions) { |
| 753 if (hDoc != m_pXFADoc) | 754 if (hDoc != m_pXFADoc.get()) |
| 754 return; | 755 return; |
| 755 | 756 |
| 756 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 757 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 757 if (!pEnv || !pEnv->GetFormFillInfo() || | 758 if (!pEnv || !pEnv->GetFormFillInfo() || |
| 758 !pEnv->GetFormFillInfo()->m_pJsPlatform || | 759 !pEnv->GetFormFillInfo()->m_pJsPlatform || |
| 759 !pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) { | 760 !pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print) { |
| 760 return; | 761 return; |
| 761 } | 762 } |
| 762 | 763 |
| 763 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( | 764 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 return 0; | 806 return 0; |
| 806 } | 807 } |
| 807 | 808 |
| 808 FX_BOOL CPDFXFA_Document::Clear(CXFA_FFDoc* hDoc, | 809 FX_BOOL CPDFXFA_Document::Clear(CXFA_FFDoc* hDoc, |
| 809 CXFA_Node* pSigNode, | 810 CXFA_Node* pSigNode, |
| 810 FX_BOOL bCleared) { | 811 FX_BOOL bCleared) { |
| 811 return 0; | 812 return 0; |
| 812 } | 813 } |
| 813 | 814 |
| 814 void CPDFXFA_Document::GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) { | 815 void CPDFXFA_Document::GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) { |
| 815 if (hDoc != m_pXFADoc) | 816 if (hDoc != m_pXFADoc.get()) |
| 816 return; | 817 return; |
| 817 | 818 |
| 818 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 819 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 819 if (!pEnv) | 820 if (!pEnv) |
| 820 return; | 821 return; |
| 821 | 822 |
| 822 pEnv->FFI_GetURL(this, wsDocURL); | 823 pEnv->FFI_GetURL(this, wsDocURL); |
| 823 } | 824 } |
| 824 | 825 |
| 825 FX_ARGB CPDFXFA_Document::GetHighlightColor(CXFA_FFDoc* hDoc) { | 826 FX_ARGB CPDFXFA_Document::GetHighlightColor(CXFA_FFDoc* hDoc) { |
| 826 if (hDoc != m_pXFADoc) | 827 if (hDoc != m_pXFADoc.get()) |
| 827 return 0; | 828 return 0; |
| 828 if (m_pSDKDoc) { | 829 if (m_pSDKDoc) { |
| 829 if (CPDFSDK_InterForm* pInterForm = m_pSDKDoc->GetInterForm()) { | 830 if (CPDFSDK_InterForm* pInterForm = m_pSDKDoc->GetInterForm()) { |
| 830 FX_COLORREF color = pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA); | 831 FX_COLORREF color = pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA); |
| 831 uint8_t alpha = pInterForm->GetHighlightAlpha(); | 832 uint8_t alpha = pInterForm->GetHighlightAlpha(); |
| 832 FX_ARGB argb = ArgbEncode((int)alpha, color); | 833 FX_ARGB argb = ArgbEncode((int)alpha, color); |
| 833 return argb; | 834 return argb; |
| 834 } | 835 } |
| 835 } | 836 } |
| 836 return 0; | 837 return 0; |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 pFileHandler, fileFlag, | 1230 pFileHandler, fileFlag, |
| 1230 (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short))); | 1231 (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short))); |
| 1231 bs.ReleaseBuffer(len * sizeof(unsigned short)); | 1232 bs.ReleaseBuffer(len * sizeof(unsigned short)); |
| 1232 } | 1233 } |
| 1233 return bRet; | 1234 return bRet; |
| 1234 } | 1235 } |
| 1235 | 1236 |
| 1236 FX_BOOL CPDFXFA_Document::SetGlobalProperty(CXFA_FFDoc* hDoc, | 1237 FX_BOOL CPDFXFA_Document::SetGlobalProperty(CXFA_FFDoc* hDoc, |
| 1237 const CFX_ByteStringC& szPropName, | 1238 const CFX_ByteStringC& szPropName, |
| 1238 CFXJSE_Value* pValue) { | 1239 CFXJSE_Value* pValue) { |
| 1239 if (hDoc != m_pXFADoc) | 1240 if (hDoc != m_pXFADoc.get()) |
| 1240 return FALSE; | 1241 return FALSE; |
| 1241 | 1242 |
| 1242 if (m_pSDKDoc && m_pSDKDoc->GetEnv()->GetJSRuntime()) | 1243 if (m_pSDKDoc && m_pSDKDoc->GetEnv()->GetJSRuntime()) |
| 1243 return m_pSDKDoc->GetEnv()->GetJSRuntime()->SetValueByName(szPropName, | 1244 return m_pSDKDoc->GetEnv()->GetJSRuntime()->SetValueByName(szPropName, |
| 1244 pValue); | 1245 pValue); |
| 1245 return FALSE; | 1246 return FALSE; |
| 1246 } | 1247 } |
| 1247 FX_BOOL CPDFXFA_Document::GetPDFScriptObject(CXFA_FFDoc* hDoc, | 1248 FX_BOOL CPDFXFA_Document::GetPDFScriptObject(CXFA_FFDoc* hDoc, |
| 1248 const CFX_ByteStringC& utf8Name, | 1249 const CFX_ByteStringC& utf8Name, |
| 1249 CFXJSE_Value* pValue) { | 1250 CFXJSE_Value* pValue) { |
| 1250 if (hDoc != m_pXFADoc) | 1251 if (hDoc != m_pXFADoc.get()) |
| 1251 return FALSE; | 1252 return FALSE; |
| 1252 | 1253 |
| 1253 if (!m_pSDKDoc || !m_pSDKDoc->GetEnv()->GetJSRuntime()) | 1254 if (!m_pSDKDoc || !m_pSDKDoc->GetEnv()->GetJSRuntime()) |
| 1254 return FALSE; | 1255 return FALSE; |
| 1255 | 1256 |
| 1256 if (!m_pJSContext) { | 1257 if (!m_pJSContext) { |
| 1257 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc); | 1258 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc.get()); |
| 1258 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); | 1259 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); |
| 1259 } | 1260 } |
| 1260 | 1261 |
| 1261 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(utf8Name, pValue); | 1262 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(utf8Name, pValue); |
| 1262 } | 1263 } |
| 1263 FX_BOOL CPDFXFA_Document::GetGlobalProperty(CXFA_FFDoc* hDoc, | 1264 FX_BOOL CPDFXFA_Document::GetGlobalProperty(CXFA_FFDoc* hDoc, |
| 1264 const CFX_ByteStringC& szPropName, | 1265 const CFX_ByteStringC& szPropName, |
| 1265 CFXJSE_Value* pValue) { | 1266 CFXJSE_Value* pValue) { |
| 1266 if (hDoc != m_pXFADoc) | 1267 if (hDoc != m_pXFADoc.get()) |
| 1267 return FALSE; | 1268 return FALSE; |
| 1268 if (!m_pSDKDoc || !m_pSDKDoc->GetEnv()->GetJSRuntime()) | 1269 if (!m_pSDKDoc || !m_pSDKDoc->GetEnv()->GetJSRuntime()) |
| 1269 return FALSE; | 1270 return FALSE; |
| 1270 | 1271 |
| 1271 if (!m_pJSContext) { | 1272 if (!m_pJSContext) { |
| 1272 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc); | 1273 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc.get()); |
| 1273 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); | 1274 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); |
| 1274 } | 1275 } |
| 1275 | 1276 |
| 1276 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName, | 1277 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName, |
| 1277 pValue); | 1278 pValue); |
| 1278 } | 1279 } |
| 1279 | 1280 |
| 1280 CPDF_Document* CPDFXFA_Document::OpenPDF(CXFA_FFDoc* hDoc, | 1281 CPDF_Document* CPDFXFA_Document::OpenPDF(CXFA_FFDoc* hDoc, |
| 1281 IFX_FileRead* pFile, | 1282 IFX_FileRead* pFile, |
| 1282 FX_BOOL bTakeOverFile) { | 1283 FX_BOOL bTakeOverFile) { |
| 1283 return nullptr; | 1284 return nullptr; |
| 1284 } | 1285 } |
| OLD | NEW |