| 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 "../../include/fpdfdoc/fpdf_doc.h" | 7 #include "../../include/fpdfdoc/fpdf_doc.h" |
| 8 #include "doc_utils.h" | 8 #include "doc_utils.h" |
| 9 | 9 |
| 10 const int nMaxRecursion = 32; | 10 const int nMaxRecursion = 32; |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 if (!m_ControlMap.Lookup(pAnnot, (void*&)pControl)) { | 859 if (!m_ControlMap.Lookup(pAnnot, (void*&)pControl)) { |
| 860 continue; | 860 continue; |
| 861 } | 861 } |
| 862 if (index == count) { | 862 if (index == count) { |
| 863 return pControl; | 863 return pControl; |
| 864 } | 864 } |
| 865 count++; | 865 count++; |
| 866 } | 866 } |
| 867 return NULL; | 867 return NULL; |
| 868 } | 868 } |
| 869 |
| 869 CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, | 870 CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, |
| 870 FX_FLOAT pdf_x, | 871 FX_FLOAT pdf_x, |
| 871 FX_FLOAT pdf_y) const { | 872 FX_FLOAT pdf_y, |
| 873 int* z_order) const { |
| 872 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArray("Annots"); | 874 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArray("Annots"); |
| 873 if (pAnnotList == NULL) { | 875 if (!pAnnotList) |
| 874 return NULL; | 876 return nullptr; |
| 877 |
| 878 for (FX_DWORD i = pAnnotList->GetCount(); i > 0; --i) { |
| 879 FX_DWORD annot_index = i - 1; |
| 880 CPDF_Dictionary* pAnnot = pAnnotList->GetDict(annot_index); |
| 881 if (!pAnnot) |
| 882 continue; |
| 883 |
| 884 CPDF_FormControl* pControl; |
| 885 if (!m_ControlMap.Lookup(pAnnot, (void*&)pControl)) |
| 886 continue; |
| 887 |
| 888 CFX_FloatRect rect = pControl->GetRect(); |
| 889 if (!rect.Contains(pdf_x, pdf_y)) |
| 890 continue; |
| 891 |
| 892 if (z_order) |
| 893 *z_order = annot_index; |
| 894 return pControl; |
| 875 } | 895 } |
| 876 for (FX_DWORD i = pAnnotList->GetCount(); i > 0; i--) { | 896 return nullptr; |
| 877 CPDF_Dictionary* pAnnot = pAnnotList->GetDict(i - 1); | |
| 878 if (pAnnot == NULL) { | |
| 879 continue; | |
| 880 } | |
| 881 CPDF_FormControl* pControl; | |
| 882 if (!m_ControlMap.Lookup(pAnnot, (void*&)pControl)) { | |
| 883 continue; | |
| 884 } | |
| 885 CFX_FloatRect rect = pControl->GetRect(); | |
| 886 if (rect.Contains(pdf_x, pdf_y)) { | |
| 887 return pControl; | |
| 888 } | |
| 889 } | |
| 890 return NULL; | |
| 891 } | 897 } |
| 898 |
| 892 CPDF_FormControl* CPDF_InterForm::GetControlByDict( | 899 CPDF_FormControl* CPDF_InterForm::GetControlByDict( |
| 893 CPDF_Dictionary* pWidgetDict) const { | 900 CPDF_Dictionary* pWidgetDict) const { |
| 894 CPDF_FormControl* pControl = NULL; | 901 CPDF_FormControl* pControl = NULL; |
| 895 m_ControlMap.Lookup(pWidgetDict, (void*&)pControl); | 902 m_ControlMap.Lookup(pWidgetDict, (void*&)pControl); |
| 896 return pControl; | 903 return pControl; |
| 897 } | 904 } |
| 898 FX_DWORD CPDF_InterForm::CountInternalFields( | 905 FX_DWORD CPDF_InterForm::CountInternalFields( |
| 899 const CFX_WideString& csFieldName) const { | 906 const CFX_WideString& csFieldName) const { |
| 900 if (!m_pFormDict) { | 907 if (!m_pFormDict) { |
| 901 return 0; | 908 return 0; |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1616 continue; | 1623 continue; |
| 1617 } | 1624 } |
| 1618 CPDF_FormControl* pControl = NULL; | 1625 CPDF_FormControl* pControl = NULL; |
| 1619 if (m_ControlMap.Lookup(pAnnotDict, (void*&)pControl)) { | 1626 if (m_ControlMap.Lookup(pAnnotDict, (void*&)pControl)) { |
| 1620 return iNewPage; | 1627 return iNewPage; |
| 1621 } | 1628 } |
| 1622 } | 1629 } |
| 1623 } while (TRUE); | 1630 } while (TRUE); |
| 1624 return -1; | 1631 return -1; |
| 1625 } | 1632 } |
| OLD | NEW |