Chromium Code Reviews| 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/include/fsdk_mgr.h" | 7 #include "fpdfsdk/include/fsdk_mgr.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 713 if (m_page) { | 713 if (m_page) { |
| 714 #ifdef PDF_ENABLE_XFA | 714 #ifdef PDF_ENABLE_XFA |
| 715 return m_page->GetDocument()->GetPDFDoc(); | 715 return m_page->GetDocument()->GetPDFDoc(); |
| 716 #else // PDF_ENABLE_XFA | 716 #else // PDF_ENABLE_XFA |
| 717 return m_page->m_pDocument; | 717 return m_page->m_pDocument; |
| 718 #endif // PDF_ENABLE_XFA | 718 #endif // PDF_ENABLE_XFA |
| 719 } | 719 } |
| 720 return nullptr; | 720 return nullptr; |
| 721 } | 721 } |
| 722 | 722 |
| 723 CPDF_Page* CPDFSDK_PageView::GetPDFPage() const { | |
| 724 if (m_page) { | |
| 723 #ifdef PDF_ENABLE_XFA | 725 #ifdef PDF_ENABLE_XFA |
|
Lei Zhang
2016/08/25 22:41:31
A bit weird here. How about:
#ifdef PDF_ENABLE_XF
jaepark
2016/08/25 23:14:14
Done.
| |
| 724 CPDF_Page* CPDFSDK_PageView::GetPDFPage() { | |
| 725 if (m_page) { | |
| 726 return m_page->GetPDFPage(); | 726 return m_page->GetPDFPage(); |
| 727 #else // PDF_ENABLE_XFA | |
| 728 return m_page; | |
| 729 #endif // PDF_ENABLE_XFA | |
| 727 } | 730 } |
| 728 return nullptr; | 731 return nullptr; |
| 729 } | 732 } |
| 730 #endif // PDF_ENABLE_XFA | |
| 731 | 733 |
| 732 size_t CPDFSDK_PageView::CountAnnots() const { | 734 size_t CPDFSDK_PageView::CountAnnots() const { |
| 733 return m_fxAnnotArray.size(); | 735 return m_fxAnnotArray.size(); |
| 734 } | 736 } |
| 735 | 737 |
| 736 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) { | 738 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) { |
| 737 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr; | 739 return nIndex < m_fxAnnotArray.size() ? m_fxAnnotArray[nIndex] : nullptr; |
| 738 } | 740 } |
| 739 | 741 |
| 740 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { | 742 CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 784 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 783 ASSERT(pEnv); | 785 ASSERT(pEnv); |
| 784 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 786 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 785 ASSERT(pAnnotHandlerMgr); | 787 ASSERT(pAnnotHandlerMgr); |
| 786 | 788 |
| 787 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 789 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
| 788 | 790 |
| 789 if (!pFXAnnot) | 791 if (!pFXAnnot) |
| 790 return FALSE; | 792 return FALSE; |
| 791 | 793 |
| 792 FX_BOOL bRet = | 794 if (pAnnotHandlerMgr->Annot_OnRButtonDown(this, pFXAnnot, nFlag, point)) |
| 793 pAnnotHandlerMgr->Annot_OnRButtonDown(this, pFXAnnot, nFlag, point); | |
| 794 if (bRet) { | |
| 795 SetFocusAnnot(pFXAnnot); | 795 SetFocusAnnot(pFXAnnot); |
| 796 } | 796 |
| 797 return TRUE; | 797 return TRUE; |
| 798 } | 798 } |
| 799 | 799 |
| 800 FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point, | 800 FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point, |
| 801 FX_UINT nFlag) { | 801 FX_UINT nFlag) { |
| 802 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 802 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 803 ASSERT(pEnv); | 803 ASSERT(pEnv); |
| 804 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 804 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 805 | 805 |
| 806 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 806 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
| 807 | 807 |
| 808 if (!pFXAnnot) | 808 if (!pFXAnnot) |
| 809 return FALSE; | 809 return FALSE; |
| 810 | 810 |
| 811 FX_BOOL bRet = | 811 if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, pFXAnnot, nFlag, point)) |
| 812 pAnnotHandlerMgr->Annot_OnRButtonUp(this, pFXAnnot, nFlag, point); | |
| 813 if (bRet) { | |
| 814 SetFocusAnnot(pFXAnnot); | 812 SetFocusAnnot(pFXAnnot); |
| 815 } | 813 |
| 816 return TRUE; | 814 return TRUE; |
| 817 } | 815 } |
| 818 #endif // PDF_ENABLE_XFA | 816 #endif // PDF_ENABLE_XFA |
| 819 | 817 |
| 820 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point, | 818 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point, |
| 821 FX_UINT nFlag) { | 819 FX_UINT nFlag) { |
| 822 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 820 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 823 ASSERT(pEnv); | 821 ASSERT(pEnv); |
| 824 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 822 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 825 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 823 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 896 } | 894 } |
| 897 return FALSE; | 895 return FALSE; |
| 898 } | 896 } |
| 899 | 897 |
| 900 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { | 898 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { |
| 901 return FALSE; | 899 return FALSE; |
| 902 } | 900 } |
| 903 | 901 |
| 904 void CPDFSDK_PageView::LoadFXAnnots() { | 902 void CPDFSDK_PageView::LoadFXAnnots() { |
| 905 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 903 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 906 #ifdef PDF_ENABLE_XFA | |
| 907 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 904 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 908 #else | |
| 909 FX_BOOL bUpdateAP = CPDF_InterForm::IsUpdateAPEnabled(); | |
| 910 // Disable the default AP construction. | |
| 911 CPDF_InterForm::SetUpdateAP(FALSE); | |
| 912 m_pAnnotList.reset(new CPDF_AnnotList(m_page)); | |
| 913 CPDF_InterForm::SetUpdateAP(bUpdateAP); | |
| 914 const size_t nCount = m_pAnnotList->Count(); | |
| 915 #endif // PDF_ENABLE_XFA | |
| 916 | 905 |
| 917 SetLock(TRUE); | 906 SetLock(TRUE); |
| 918 | 907 |
| 919 #ifdef PDF_ENABLE_XFA | 908 #ifdef PDF_ENABLE_XFA |
| 920 CFX_RetainPtr<CPDFXFA_Page> protector(m_page); | 909 CFX_RetainPtr<CPDFXFA_Page> protector(m_page); |
| 921 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { | 910 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { |
| 922 CXFA_FFPageView* pageView = m_page->GetXFAPageView(); | 911 CXFA_FFPageView* pageView = m_page->GetXFAPageView(); |
| 923 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( | 912 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( |
| 924 pageView->CreateWidgetIterator( | 913 pageView->CreateWidgetIterator( |
| 925 XFA_TRAVERSEWAY_Form, | 914 XFA_TRAVERSEWAY_Form, |
| 926 XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)); | 915 XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)); |
| 927 if (!pWidgetHander) { | 916 if (!pWidgetHander) { |
| 928 SetLock(FALSE); | 917 SetLock(FALSE); |
| 929 return; | 918 return; |
| 930 } | 919 } |
| 931 | 920 |
| 932 while (CXFA_FFWidget* pXFAAnnot = pWidgetHander->MoveToNext()) { | 921 while (CXFA_FFWidget* pXFAAnnot = pWidgetHander->MoveToNext()) { |
| 933 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pXFAAnnot, this); | 922 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pXFAAnnot, this); |
| 934 if (!pAnnot) | 923 if (!pAnnot) |
| 935 continue; | 924 continue; |
| 936 m_fxAnnotArray.push_back(pAnnot); | 925 m_fxAnnotArray.push_back(pAnnot); |
| 937 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 926 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
| 938 } | 927 } |
| 939 } else { | |
| 940 CPDF_Page* pPage = m_page->GetPDFPage(); | |
| 941 ASSERT(pPage); | |
| 942 FX_BOOL bUpdateAP = CPDF_InterForm::IsUpdateAPEnabled(); | |
| 943 // Disable the default AP construction. | |
| 944 CPDF_InterForm::SetUpdateAP(FALSE); | |
| 945 m_pAnnotList.reset(new CPDF_AnnotList(pPage)); | |
| 946 CPDF_InterForm::SetUpdateAP(bUpdateAP); | |
| 947 | 928 |
| 948 const size_t nCount = m_pAnnotList->Count(); | 929 SetLock(FALSE); |
| 949 for (size_t i = 0; i < nCount; ++i) { | 930 return; |
| 950 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); | 931 } |
| 951 CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot); | 932 #endif // PDF_ENABLE_XFA |
| 952 | 933 |
| 953 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); | 934 CPDF_Page* pPage = GetPDFPage(); |
|
Lei Zhang
2016/08/25 22:41:31
For the non-XFA code path, previously, this code g
jaepark
2016/08/25 23:14:14
I don't think this will be an issue. m_bLocked is
| |
| 954 if (!pAnnot) | 935 ASSERT(pPage); |
| 955 continue; | 936 FX_BOOL bUpdateAP = CPDF_InterForm::IsUpdateAPEnabled(); |
| 956 m_fxAnnotArray.push_back(pAnnot); | 937 // Disable the default AP construction. |
| 957 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 938 CPDF_InterForm::SetUpdateAP(FALSE); |
| 958 } | 939 m_pAnnotList.reset(new CPDF_AnnotList(pPage)); |
| 959 } | 940 CPDF_InterForm::SetUpdateAP(bUpdateAP); |
| 960 #else // PDF_ENABLE_XFA | 941 |
| 942 const size_t nCount = m_pAnnotList->Count(); | |
| 961 for (size_t i = 0; i < nCount; ++i) { | 943 for (size_t i = 0; i < nCount; ++i) { |
| 962 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); | 944 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
| 963 CPDF_Document* pDoc = GetPDFDocument(); | 945 CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot); |
| 964 CheckUnSupportAnnot(pDoc, pPDFAnnot); | |
| 965 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | |
| 966 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); | 946 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); |
| 967 if (!pAnnot) | 947 if (!pAnnot) |
| 968 continue; | 948 continue; |
| 969 m_fxAnnotArray.push_back(pAnnot); | 949 m_fxAnnotArray.push_back(pAnnot); |
| 970 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 950 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
| 971 } | 951 } |
| 972 #endif // PDF_ENABLE_XFA | |
| 973 | 952 |
| 974 SetLock(FALSE); | 953 SetLock(FALSE); |
| 975 } | 954 } |
| 976 | 955 |
| 977 void CPDFSDK_PageView::ClearFXAnnots() { | 956 void CPDFSDK_PageView::ClearFXAnnots() { |
| 978 SetLock(TRUE); | 957 SetLock(TRUE); |
| 979 if (m_pSDKDoc && GetFocusAnnot()) | 958 if (m_pSDKDoc && GetFocusAnnot()) |
| 980 m_pSDKDoc->SetFocusAnnot(nullptr); | 959 m_pSDKDoc->SetFocusAnnot(nullptr); |
| 981 m_CaptureWidget = nullptr; | 960 m_CaptureWidget = nullptr; |
| 982 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) | 961 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1039 return nullptr; | 1018 return nullptr; |
| 1040 | 1019 |
| 1041 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 1020 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
| 1042 if (pAnnot == pFocusAnnot) | 1021 if (pAnnot == pFocusAnnot) |
| 1043 return pAnnot; | 1022 return pAnnot; |
| 1044 } | 1023 } |
| 1045 return nullptr; | 1024 return nullptr; |
| 1046 } | 1025 } |
| 1047 | 1026 |
| 1048 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { | 1027 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { |
| 1049 #ifdef PDF_ENABLE_XFA | 1028 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; |
| 1050 CPDF_Page* pPage = m_page->GetPDFPage(); | |
| 1051 #else // PDF_ENABLE_XFA | |
| 1052 CPDF_Page* pPage = m_page; | |
| 1053 #endif // PDF_ENABLE_XFA | |
| 1054 CPDF_Dictionary* pDict = pPage->m_pFormDict; | |
| 1055 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); | 1029 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); |
| 1056 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; | 1030 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; |
| 1057 } | 1031 } |
| OLD | NEW |