| 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 <algorithm> |
| 8 |
| 7 #include "../../public/fpdf_ext.h" | 9 #include "../../public/fpdf_ext.h" |
| 8 #include "../../third_party/base/nonstd_unique_ptr.h" | 10 #include "../../third_party/base/nonstd_unique_ptr.h" |
| 9 #include "../include/formfiller/FFL_FormFiller.h" | 11 #include "../include/formfiller/FFL_FormFiller.h" |
| 10 #include "../include/fsdk_define.h" | 12 #include "../include/fsdk_define.h" |
| 11 #include "../include/fsdk_mgr.h" | 13 #include "../include/fsdk_mgr.h" |
| 12 #include "../include/javascript/IJavaScript.h" | 14 #include "../include/javascript/IJavaScript.h" |
| 13 | 15 |
| 14 #if _FX_OS_ == _FX_ANDROID_ | 16 #if _FX_OS_ == _FX_ANDROID_ |
| 15 #include "time.h" | 17 #include "time.h" |
| 16 #else | 18 #else |
| 17 #include <ctime> | 19 #include <ctime> |
| 18 #endif | 20 #endif |
| 19 | 21 |
| 20 class CFX_SystemHandler : public IFX_SystemHandler { | 22 class CFX_SystemHandler : public IFX_SystemHandler { |
| 21 public: | 23 public: |
| 22 CFX_SystemHandler(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv), m_nCharSet(-1) {} | 24 explicit CFX_SystemHandler(CPDFDoc_Environment* pEnv) |
| 25 : m_pEnv(pEnv), m_nCharSet(-1) {} |
| 23 ~CFX_SystemHandler() override {} | 26 ~CFX_SystemHandler() override {} |
| 24 | 27 |
| 25 public: | 28 public: |
| 26 // IFX_SystemHandler | 29 // IFX_SystemHandler |
| 27 void InvalidateRect(FX_HWND hWnd, FX_RECT rect) override; | 30 void InvalidateRect(FX_HWND hWnd, FX_RECT rect) override; |
| 28 void OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect) override; | 31 void OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect) override; |
| 29 FX_BOOL IsSelectionImplemented() override; | 32 FX_BOOL IsSelectionImplemented() override; |
| 30 CFX_WideString GetClipboardText(FX_HWND hWnd) override { return L""; } | 33 CFX_WideString GetClipboardText(FX_HWND hWnd) override { return L""; } |
| 31 FX_BOOL SetClipboardText(FX_HWND hWnd, CFX_WideString string) override { | 34 FX_BOOL SetClipboardText(FX_HWND hWnd, CFX_WideString string) override { |
| 32 return FALSE; | 35 return FALSE; |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 ASSERT(m_pEnv != NULL); | 602 ASSERT(m_pEnv != NULL); |
| 600 return m_pEnv->GetJSRuntime(); | 603 return m_pEnv->GetJSRuntime(); |
| 601 } | 604 } |
| 602 | 605 |
| 603 CFX_WideString CPDFSDK_Document::GetPath() { | 606 CFX_WideString CPDFSDK_Document::GetPath() { |
| 604 ASSERT(m_pEnv != NULL); | 607 ASSERT(m_pEnv != NULL); |
| 605 return m_pEnv->JS_docGetFilePath(); | 608 return m_pEnv->JS_docGetFilePath(); |
| 606 } | 609 } |
| 607 | 610 |
| 608 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, CPDF_Page* page) | 611 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, CPDF_Page* page) |
| 609 : m_page(page), m_pSDKDoc(pSDKDoc) { | 612 : m_page(page), |
| 613 m_pSDKDoc(pSDKDoc), |
| 614 m_CaptureWidget(nullptr), |
| 615 m_bEnterWidget(FALSE), |
| 616 m_bExitWidget(FALSE), |
| 617 m_bOnWidget(FALSE), |
| 618 m_bValid(FALSE), |
| 619 m_bLocked(FALSE), |
| 620 m_bTakeOverPage(FALSE) { |
| 610 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); | 621 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); |
| 611 if (pInterForm) { | 622 if (pInterForm) { |
| 612 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 623 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 613 pPDFInterForm->FixPageFields(page); | 624 pPDFInterForm->FixPageFields(page); |
| 614 } | 625 } |
| 615 m_page->SetPrivateData((void*)m_page, (void*)this, NULL); | 626 m_page->SetPrivateData((void*)m_page, (void*)this, nullptr); |
| 616 m_fxAnnotArray.RemoveAll(); | |
| 617 | |
| 618 m_bEnterWidget = FALSE; | |
| 619 m_bExitWidget = FALSE; | |
| 620 m_bOnWidget = FALSE; | |
| 621 m_CaptureWidget = NULL; | |
| 622 m_bValid = FALSE; | |
| 623 m_bLocked = FALSE; | |
| 624 m_bTakeOverPage = FALSE; | |
| 625 } | 627 } |
| 626 | 628 |
| 627 CPDFSDK_PageView::~CPDFSDK_PageView() { | 629 CPDFSDK_PageView::~CPDFSDK_PageView() { |
| 628 // if there is a focused annot on the page, we should kill the focus first. | 630 // if there is a focused annot on the page, we should kill the focus first. |
| 629 if (CPDFSDK_Annot* focusedAnnot = m_pSDKDoc->GetFocusAnnot()) { | 631 if (CPDFSDK_Annot* focusedAnnot = m_pSDKDoc->GetFocusAnnot()) { |
| 630 for (int i = 0, count = m_fxAnnotArray.GetSize(); i < count; i++) { | 632 auto it = |
| 631 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | 633 std::find(m_fxAnnotArray.begin(), m_fxAnnotArray.end(), focusedAnnot); |
| 632 if (pAnnot == focusedAnnot) { | 634 if (it != m_fxAnnotArray.end()) |
| 633 KillFocusAnnot(); | 635 KillFocusAnnot(); |
| 634 break; | |
| 635 } | |
| 636 } | |
| 637 } | 636 } |
| 638 | 637 |
| 639 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 638 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 640 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 639 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 641 ASSERT(pAnnotHandlerMgr); | 640 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) |
| 642 for (int i = 0, count = m_fxAnnotArray.GetSize(); i < count; i++) { | |
| 643 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | |
| 644 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); | 641 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); |
| 645 } | 642 m_fxAnnotArray.clear(); |
| 646 m_fxAnnotArray.RemoveAll(); | |
| 647 | 643 |
| 648 delete m_pAnnotList; | 644 m_pAnnotList.reset(); |
| 649 m_pAnnotList = NULL; | |
| 650 | 645 |
| 651 m_page->RemovePrivateData((void*)m_page); | 646 m_page->RemovePrivateData((void*)m_page); |
| 652 if (m_bTakeOverPage) { | 647 if (m_bTakeOverPage) { |
| 653 delete m_page; | 648 delete m_page; |
| 654 } | 649 } |
| 655 } | 650 } |
| 656 | 651 |
| 657 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, | 652 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, |
| 658 CPDF_Matrix* pUser2Device, | 653 CPDF_Matrix* pUser2Device, |
| 659 CPDF_RenderOptions* pOptions) { | 654 CPDF_RenderOptions* pOptions) { |
| 660 m_curMatrix = *pUser2Device; | 655 m_curMatrix = *pUser2Device; |
| 661 | 656 |
| 662 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 657 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 663 CPDFSDK_AnnotIterator annotIterator(this, TRUE); | 658 CPDFSDK_AnnotIterator annotIterator(this, true); |
| 664 int index = -1; | 659 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
| 665 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next(index)) { | |
| 666 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 660 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 667 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); | 661 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); |
| 668 } | 662 } |
| 669 } | 663 } |
| 670 | 664 |
| 671 CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, | 665 CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, |
| 672 FX_FLOAT pageY) { | 666 FX_FLOAT pageY) { |
| 673 int nCount = m_pAnnotList->Count(); | 667 int nCount = CountAnnots(); |
| 674 for (int i = 0; i < nCount; i++) { | 668 for (int i = 0; i < nCount; i++) { |
| 675 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); | 669 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); |
| 676 CFX_FloatRect annotRect; | 670 CFX_FloatRect annotRect; |
| 677 pAnnot->GetRect(annotRect); | 671 pAnnot->GetRect(annotRect); |
| 678 if (annotRect.Contains(pageX, pageY)) | 672 if (annotRect.Contains(pageX, pageY)) |
| 679 return pAnnot; | 673 return pAnnot; |
| 680 } | 674 } |
| 681 return NULL; | 675 return nullptr; |
| 682 } | 676 } |
| 683 | 677 |
| 684 CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, | 678 CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, |
| 685 FX_FLOAT pageY) { | 679 FX_FLOAT pageY) { |
| 686 int nCount = m_pAnnotList->Count(); | 680 int nCount = CountAnnots(); |
| 687 for (int i = 0; i < nCount; i++) { | 681 for (int i = 0; i < nCount; ++i) { |
| 688 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); | 682 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); |
| 689 if (pAnnot->GetSubType() == "Widget") { | 683 if (pAnnot->GetSubType() == "Widget") { |
| 690 CFX_FloatRect annotRect; | 684 CFX_FloatRect annotRect; |
| 691 pAnnot->GetRect(annotRect); | 685 pAnnot->GetRect(annotRect); |
| 692 if (annotRect.Contains(pageX, pageY)) | 686 if (annotRect.Contains(pageX, pageY)) |
| 693 return pAnnot; | 687 return pAnnot; |
| 694 } | 688 } |
| 695 } | 689 } |
| 696 return NULL; | 690 return nullptr; |
| 697 } | 691 } |
| 698 | 692 |
| 699 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, | 693 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, |
| 700 FX_FLOAT pageY) { | 694 FX_FLOAT pageY) { |
| 701 CPDFSDK_AnnotIterator annotIterator(this, FALSE); | |
| 702 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 695 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 703 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 696 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
| 704 CPDFSDK_Annot* pSDKAnnot = NULL; | 697 CPDFSDK_AnnotIterator annotIterator(this, false); |
| 705 int index = -1; | 698 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
| 706 while ((pSDKAnnot = annotIterator.Next(index))) { | |
| 707 CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 699 CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
| 708 if (rc.Contains(pageX, pageY)) | 700 if (rc.Contains(pageX, pageY)) |
| 709 return pSDKAnnot; | 701 return pSDKAnnot; |
| 710 } | 702 } |
| 711 | 703 |
| 712 return NULL; | 704 return nullptr; |
| 713 } | 705 } |
| 714 | 706 |
| 715 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, | 707 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, |
| 716 FX_FLOAT pageY) { | 708 FX_FLOAT pageY) { |
| 717 CPDFSDK_AnnotIterator annotIterator(this, FALSE); | |
| 718 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 709 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 719 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 710 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
| 720 CPDFSDK_Annot* pSDKAnnot = NULL; | 711 CPDFSDK_AnnotIterator annotIterator(this, false); |
| 721 int index = -1; | 712 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
| 722 while ((pSDKAnnot = annotIterator.Next(index))) { | |
| 723 if (pSDKAnnot->GetType() == "Widget") { | 713 if (pSDKAnnot->GetType() == "Widget") { |
| 724 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 714 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
| 725 CPDF_Point point(pageX, pageY); | 715 CPDF_Point point(pageX, pageY); |
| 726 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) | 716 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) |
| 727 return pSDKAnnot; | 717 return pSDKAnnot; |
| 728 } | 718 } |
| 729 } | 719 } |
| 730 | 720 |
| 731 return NULL; | 721 return nullptr; |
| 732 } | 722 } |
| 733 | 723 |
| 734 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) { | 724 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) { |
| 735 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); | 725 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); |
| 736 if (pAnnotDic) | 726 if (pAnnotDic) |
| 737 return pAnnotDic->KeyExist("AS"); | 727 return pAnnotDic->KeyExist("AS"); |
| 738 return FALSE; | 728 return FALSE; |
| 739 } | 729 } |
| 740 | 730 |
| 741 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot* pPDFAnnot) { | 731 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot* pPDFAnnot) { |
| 742 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 732 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 743 ASSERT(pEnv); | 733 ASSERT(pEnv); |
| 744 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); | 734 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); |
| 735 if (!pAnnotHandler) |
| 736 return nullptr; |
| 745 | 737 |
| 746 CPDFSDK_Annot* pSDKAnnot = NULL; | 738 CPDFSDK_Annot* pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); |
| 739 if (!pSDKAnnot) |
| 740 return nullptr; |
| 747 | 741 |
| 748 if (pAnnotHandler) { | 742 m_fxAnnotArray.push_back(pSDKAnnot); |
| 749 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); | 743 pAnnotHandler->Annot_OnCreate(pSDKAnnot); |
| 750 } | |
| 751 if (!pSDKAnnot) | |
| 752 return NULL; | |
| 753 | |
| 754 m_fxAnnotArray.Add(pSDKAnnot); | |
| 755 | |
| 756 if (pAnnotHandler) { | |
| 757 pAnnotHandler->Annot_OnCreate(pSDKAnnot); | |
| 758 } | |
| 759 | |
| 760 return pSDKAnnot; | 744 return pSDKAnnot; |
| 761 } | 745 } |
| 762 | 746 |
| 763 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) { | 747 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) { |
| 764 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; | 748 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; |
| 765 } | 749 } |
| 766 | 750 |
| 767 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType, | 751 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType, |
| 768 CPDF_Dictionary* pDict) { | 752 CPDF_Dictionary* pDict) { |
| 769 return NULL; | 753 return NULL; |
| 770 } | 754 } |
| 771 | 755 |
| 772 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { | 756 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { |
| 773 return FALSE; | 757 return FALSE; |
| 774 } | 758 } |
| 775 | 759 |
| 776 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { | 760 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { |
| 777 if (m_page) { | 761 if (m_page) { |
| 778 return m_page->m_pDocument; | 762 return m_page->m_pDocument; |
| 779 } | 763 } |
| 780 return NULL; | 764 return NULL; |
| 781 } | 765 } |
| 782 | 766 |
| 783 int CPDFSDK_PageView::CountAnnots() { | 767 int CPDFSDK_PageView::CountAnnots() const { |
| 784 return m_pAnnotList->Count(); | 768 return m_pAnnotList->Count(); |
| 785 } | 769 } |
| 786 | 770 |
| 787 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(int nIndex) { | 771 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) { |
| 788 int nCount = m_fxAnnotArray.GetSize(); | 772 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr; |
| 789 if (nIndex < 0 || nIndex >= nCount) { | |
| 790 return NULL; | |
| 791 } | |
| 792 | |
| 793 return (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(nIndex); | |
| 794 } | 773 } |
| 795 | 774 |
| 796 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { | 775 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { |
| 797 int nCount = m_fxAnnotArray.GetSize(); | 776 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
| 798 for (int i = 0; i < nCount; i++) { | 777 if (pAnnot->GetPDFAnnot()->GetAnnotDict() == pDict) |
| 799 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | |
| 800 if (pDict == pAnnot->GetPDFAnnot()->GetAnnotDict()) | |
| 801 return pAnnot; | 778 return pAnnot; |
| 802 } | 779 } |
| 803 return NULL; | 780 return nullptr; |
| 804 } | 781 } |
| 805 | 782 |
| 806 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point, | 783 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point, |
| 807 FX_UINT nFlag) { | 784 FX_UINT nFlag) { |
| 808 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 785 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 809 ASSERT(pEnv); | 786 ASSERT(pEnv); |
| 810 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 787 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
| 811 if (!pFXAnnot) { | 788 if (!pFXAnnot) { |
| 812 KillFocusAnnot(nFlag); | 789 KillFocusAnnot(nFlag); |
| 813 } else { | 790 } else { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { | 890 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { |
| 914 return FALSE; | 891 return FALSE; |
| 915 } | 892 } |
| 916 | 893 |
| 917 void CPDFSDK_PageView::LoadFXAnnots() { | 894 void CPDFSDK_PageView::LoadFXAnnots() { |
| 918 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 895 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 919 | 896 |
| 920 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); | 897 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); |
| 921 // Disable the default AP construction. | 898 // Disable the default AP construction. |
| 922 CPDF_InterForm::EnableUpdateAP(FALSE); | 899 CPDF_InterForm::EnableUpdateAP(FALSE); |
| 923 m_pAnnotList = new CPDF_AnnotList(m_page); | 900 m_pAnnotList.reset(new CPDF_AnnotList(m_page)); |
| 924 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); | 901 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); |
| 925 int nCount = m_pAnnotList->Count(); | 902 int nCount = CountAnnots(); |
| 926 SetLock(TRUE); | 903 SetLock(TRUE); |
| 927 for (int i = 0; i < nCount; i++) { | 904 for (int i = 0; i < nCount; ++i) { |
| 928 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); | 905 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
| 929 CPDF_Document* pDoc = GetPDFDocument(); | 906 CPDF_Document* pDoc = GetPDFDocument(); |
| 930 | 907 |
| 931 CheckUnSupportAnnot(pDoc, pPDFAnnot); | 908 CheckUnSupportAnnot(pDoc, pPDFAnnot); |
| 932 | 909 |
| 933 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 910 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 934 ASSERT(pAnnotHandlerMgr != NULL); | 911 ASSERT(pAnnotHandlerMgr != NULL); |
| 935 | 912 |
| 936 if (pAnnotHandlerMgr) { | 913 if (pAnnotHandlerMgr) { |
| 937 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); | 914 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); |
| 938 if (!pAnnot) | 915 if (!pAnnot) |
| 939 continue; | 916 continue; |
| 940 m_fxAnnotArray.Add(pAnnot); | 917 m_fxAnnotArray.push_back(pAnnot); |
| 941 | 918 |
| 942 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 919 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
| 943 } | 920 } |
| 944 } | 921 } |
| 945 SetLock(FALSE); | 922 SetLock(FALSE); |
| 946 } | 923 } |
| 947 | 924 |
| 948 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) { | 925 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) { |
| 949 for (int i = 0; i < rects.GetSize(); i++) { | 926 for (int i = 0; i < rects.GetSize(); i++) { |
| 950 CPDF_Rect rc = rects.GetAt(i); | 927 CPDF_Rect rc = rects.GetAt(i); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 964 if (m_page) { | 941 if (m_page) { |
| 965 CPDF_Dictionary* pDic = m_page->m_pFormDict; | 942 CPDF_Dictionary* pDic = m_page->m_pFormDict; |
| 966 CPDF_Document* pDoc = m_pSDKDoc->GetDocument(); | 943 CPDF_Document* pDoc = m_pSDKDoc->GetDocument(); |
| 967 if (pDoc && pDic) { | 944 if (pDoc && pDic) { |
| 968 return pDoc->GetPageIndex(pDic->GetObjNum()); | 945 return pDoc->GetPageIndex(pDic->GetObjNum()); |
| 969 } | 946 } |
| 970 } | 947 } |
| 971 return -1; | 948 return -1; |
| 972 } | 949 } |
| 973 | 950 |
| 974 FX_BOOL CPDFSDK_PageView::IsValidAnnot(void* p) { | 951 FX_BOOL CPDFSDK_PageView::IsValidAnnot(CPDF_Annot* p) const { |
| 975 if (p == NULL) | 952 if (!p) |
| 976 return FALSE; | 953 return FALSE; |
| 977 int iCount = m_pAnnotList->Count(); | 954 |
| 978 for (int i = 0; i < iCount; i++) { | 955 int nCount = CountAnnots(); |
| 956 for (int i = 0; i < nCount; ++i) { |
| 979 if (m_pAnnotList->GetAt(i) == p) | 957 if (m_pAnnotList->GetAt(i) == p) |
| 980 return TRUE; | 958 return TRUE; |
| 981 } | 959 } |
| 982 return FALSE; | 960 return FALSE; |
| 983 } | 961 } |
| 984 | 962 |
| 985 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { | 963 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { |
| 986 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); | 964 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); |
| 987 if (!pFocusAnnot) | 965 if (!pFocusAnnot) |
| 988 return NULL; | 966 return nullptr; |
| 989 | 967 |
| 990 for (int i = 0; i < m_fxAnnotArray.GetSize(); i++) { | 968 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
| 991 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | |
| 992 if (pAnnot == pFocusAnnot) | 969 if (pAnnot == pFocusAnnot) |
| 993 return pAnnot; | 970 return pAnnot; |
| 994 } | 971 } |
| 995 return NULL; | 972 return nullptr; |
| 996 } | 973 } |
| OLD | NEW |