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> | 7 #include <algorithm> |
8 | 8 |
9 #include "fpdfsdk/include/fsdk_mgr.h" | 9 #include "fpdfsdk/include/fsdk_mgr.h" |
10 | 10 |
11 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" | 11 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" |
12 #include "fpdfsdk/include/fsdk_define.h" | 12 #include "fpdfsdk/include/fsdk_define.h" |
13 #include "fpdfsdk/include/javascript/IJavaScript.h" | 13 #include "fpdfsdk/include/javascript/IJavaScript.h" |
14 #include "public/fpdf_ext.h" | 14 #include "public/fpdf_ext.h" |
15 #include "third_party/base/nonstd_unique_ptr.h" | 15 #include "third_party/base/nonstd_unique_ptr.h" |
| 16 #include "third_party/base/stl_util.h" |
16 | 17 |
17 #ifdef PDF_ENABLE_XFA | 18 #ifdef PDF_ENABLE_XFA |
18 #include "../include/fpdfxfa/fpdfxfa_app.h" | 19 #include "../include/fpdfxfa/fpdfxfa_app.h" |
19 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 20 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
20 #include "../include/fpdfxfa/fpdfxfa_page.h" | 21 #include "../include/fpdfxfa/fpdfxfa_page.h" |
21 #include "../include/fpdfxfa/fpdfxfa_util.h" | 22 #include "../include/fpdfxfa/fpdfxfa_util.h" |
22 #endif // PDF_ENABLE_XFA | 23 #endif // PDF_ENABLE_XFA |
23 | 24 |
24 #if _FX_OS_ == _FX_ANDROID_ | 25 #if _FX_OS_ == _FX_ANDROID_ |
25 #include "time.h" | 26 #include "time.h" |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 return pSDKAnnot; | 766 return pSDKAnnot; |
766 } | 767 } |
767 } | 768 } |
768 | 769 |
769 return nullptr; | 770 return nullptr; |
770 } | 771 } |
771 | 772 |
772 void CPDFSDK_PageView::KillFocusAnnotIfNeeded() { | 773 void CPDFSDK_PageView::KillFocusAnnotIfNeeded() { |
773 // if there is a focused annot on the page, we should kill the focus first. | 774 // if there is a focused annot on the page, we should kill the focus first. |
774 if (CPDFSDK_Annot* focusedAnnot = m_pSDKDoc->GetFocusAnnot()) { | 775 if (CPDFSDK_Annot* focusedAnnot = m_pSDKDoc->GetFocusAnnot()) { |
775 auto it = | 776 if (pdfium::ContainsValue(m_fxAnnotArray, focusedAnnot)) |
776 std::find(m_fxAnnotArray.begin(), m_fxAnnotArray.end(), focusedAnnot); | |
777 if (it != m_fxAnnotArray.end()) | |
778 KillFocusAnnot(); | 777 KillFocusAnnot(); |
779 } | 778 } |
780 } | 779 } |
781 | 780 |
782 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) { | 781 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) { |
783 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); | 782 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); |
784 if (pAnnotDic) | 783 if (pAnnotDic) |
785 return pAnnotDic->KeyExist("AS"); | 784 return pAnnotDic->KeyExist("AS"); |
786 return FALSE; | 785 return FALSE; |
787 } | 786 } |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 } | 1146 } |
1148 } | 1147 } |
1149 return -1; | 1148 return -1; |
1150 } | 1149 } |
1151 | 1150 |
1152 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { | 1151 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { |
1153 if (!p) | 1152 if (!p) |
1154 return false; | 1153 return false; |
1155 | 1154 |
1156 const auto& annots = m_pAnnotList->All(); | 1155 const auto& annots = m_pAnnotList->All(); |
1157 return std::find(annots.begin(), annots.end(), p) != annots.end(); | 1156 return pdfium::ContainsValue(annots, p); |
1158 } | 1157 } |
1159 | 1158 |
1160 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { | 1159 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { |
1161 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); | 1160 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); |
1162 if (!pFocusAnnot) | 1161 if (!pFocusAnnot) |
1163 return nullptr; | 1162 return nullptr; |
1164 | 1163 |
1165 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 1164 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
1166 if (pAnnot == pFocusAnnot) | 1165 if (pAnnot == pFocusAnnot) |
1167 return pAnnot; | 1166 return pAnnot; |
1168 } | 1167 } |
1169 return nullptr; | 1168 return nullptr; |
1170 } | 1169 } |
OLD | NEW |