| 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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 // for pdf/static xfa. | 557 // for pdf/static xfa. |
| 558 CPDFSDK_AnnotIterator annotIterator(this, true); | 558 CPDFSDK_AnnotIterator annotIterator(this, true); |
| 559 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 559 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
| 560 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 560 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 561 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); | 561 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); |
| 562 } | 562 } |
| 563 } | 563 } |
| 564 | 564 |
| 565 const CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, | 565 const CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, |
| 566 FX_FLOAT pageY) { | 566 FX_FLOAT pageY) { |
| 567 for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) { | 567 for (const auto& pAnnot : m_pAnnotList->All()) { |
| 568 CFX_FloatRect annotRect; | 568 CFX_FloatRect annotRect; |
| 569 pAnnot->GetRect(annotRect); | 569 pAnnot->GetRect(annotRect); |
| 570 if (annotRect.Contains(pageX, pageY)) | 570 if (annotRect.Contains(pageX, pageY)) |
| 571 return pAnnot; | 571 return pAnnot.get(); |
| 572 } | 572 } |
| 573 return nullptr; | 573 return nullptr; |
| 574 } | 574 } |
| 575 | 575 |
| 576 const CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, | 576 const CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, |
| 577 FX_FLOAT pageY) { | 577 FX_FLOAT pageY) { |
| 578 for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) { | 578 for (const auto& pAnnot : m_pAnnotList->All()) { |
| 579 if (pAnnot->GetSubType() == "Widget") { | 579 if (pAnnot->GetSubType() == "Widget") { |
| 580 CFX_FloatRect annotRect; | 580 CFX_FloatRect annotRect; |
| 581 pAnnot->GetRect(annotRect); | 581 pAnnot->GetRect(annotRect); |
| 582 if (annotRect.Contains(pageX, pageY)) | 582 if (annotRect.Contains(pageX, pageY)) |
| 583 return pAnnot; | 583 return pAnnot.get(); |
| 584 } | 584 } |
| 585 } | 585 } |
| 586 return nullptr; | 586 return nullptr; |
| 587 } | 587 } |
| 588 | 588 |
| 589 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, | 589 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, |
| 590 FX_FLOAT pageY) { | 590 FX_FLOAT pageY) { |
| 591 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 591 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 592 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 592 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
| 593 CPDFSDK_AnnotIterator annotIterator(this, false); | 593 CPDFSDK_AnnotIterator annotIterator(this, false); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 #else // PDF_ENABLE_XFA | 1017 #else // PDF_ENABLE_XFA |
| 1018 return GetPageIndexForStaticPDF(); | 1018 return GetPageIndexForStaticPDF(); |
| 1019 #endif // PDF_ENABLE_XFA | 1019 #endif // PDF_ENABLE_XFA |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { | 1022 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { |
| 1023 if (!p) | 1023 if (!p) |
| 1024 return false; | 1024 return false; |
| 1025 | 1025 |
| 1026 const auto& annots = m_pAnnotList->All(); | 1026 const auto& annots = m_pAnnotList->All(); |
| 1027 return pdfium::ContainsValue(annots, p); | 1027 std::unique_ptr<const CPDF_Annot> annot(p); |
| 1028 return pdfium::ContainsValue(annots, annot); |
| 1028 } | 1029 } |
| 1029 | 1030 |
| 1030 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { | 1031 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { |
| 1031 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); | 1032 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); |
| 1032 if (!pFocusAnnot) | 1033 if (!pFocusAnnot) |
| 1033 return nullptr; | 1034 return nullptr; |
| 1034 | 1035 |
| 1035 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 1036 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
| 1036 if (pAnnot == pFocusAnnot) | 1037 if (pAnnot == pFocusAnnot) |
| 1037 return pAnnot; | 1038 return pAnnot; |
| 1038 } | 1039 } |
| 1039 return nullptr; | 1040 return nullptr; |
| 1040 } | 1041 } |
| 1041 | 1042 |
| 1042 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { | 1043 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { |
| 1043 #ifdef PDF_ENABLE_XFA | 1044 #ifdef PDF_ENABLE_XFA |
| 1044 CPDF_Page* pPage = m_page->GetPDFPage(); | 1045 CPDF_Page* pPage = m_page->GetPDFPage(); |
| 1045 #else // PDF_ENABLE_XFA | 1046 #else // PDF_ENABLE_XFA |
| 1046 CPDF_Page* pPage = m_page; | 1047 CPDF_Page* pPage = m_page; |
| 1047 #endif // PDF_ENABLE_XFA | 1048 #endif // PDF_ENABLE_XFA |
| 1048 CPDF_Dictionary* pDict = pPage->m_pFormDict; | 1049 CPDF_Dictionary* pDict = pPage->m_pFormDict; |
| 1049 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); | 1050 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); |
| 1050 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; | 1051 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; |
| 1051 } | 1052 } |
| OLD | NEW |