| 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 "core/src/fpdftext/text_int.h" | 7 #include "core/src/fpdftext/text_int.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cctype> | 10 #include <cctype> |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 FX_POSITION pos = NULL; | 764 FX_POSITION pos = NULL; |
| 765 pos = m_pPage->GetFirstObjectPosition(); | 765 pos = m_pPage->GetFirstObjectPosition(); |
| 766 if (!pos) { | 766 if (!pos) { |
| 767 return -1; | 767 return -1; |
| 768 } | 768 } |
| 769 while (pos) { | 769 while (pos) { |
| 770 pPageObj = m_pPage->GetNextObject(pos); | 770 pPageObj = m_pPage->GetNextObject(pos); |
| 771 if (NULL == pPageObj) { | 771 if (NULL == pPageObj) { |
| 772 continue; | 772 continue; |
| 773 } | 773 } |
| 774 if (PDFPAGE_TEXT != pPageObj->m_Type) { | 774 if (CPDF_PageObject::TEXT != pPageObj->m_Type) { |
| 775 continue; | 775 continue; |
| 776 } | 776 } |
| 777 int32_t minH = | 777 int32_t minH = |
| 778 (int32_t)pPageObj->m_Left < 0 ? 0 : (int32_t)pPageObj->m_Left; | 778 (int32_t)pPageObj->m_Left < 0 ? 0 : (int32_t)pPageObj->m_Left; |
| 779 int32_t maxH = (int32_t)pPageObj->m_Right > nPageWidth | 779 int32_t maxH = (int32_t)pPageObj->m_Right > nPageWidth |
| 780 ? nPageWidth | 780 ? nPageWidth |
| 781 : (int32_t)pPageObj->m_Right; | 781 : (int32_t)pPageObj->m_Right; |
| 782 int32_t minV = | 782 int32_t minV = |
| 783 (int32_t)pPageObj->m_Bottom < 0 ? 0 : (int32_t)pPageObj->m_Bottom; | 783 (int32_t)pPageObj->m_Bottom < 0 ? 0 : (int32_t)pPageObj->m_Bottom; |
| 784 int32_t maxV = (int32_t)pPageObj->m_Top > nPageHeight | 784 int32_t maxV = (int32_t)pPageObj->m_Top > nPageHeight |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 FX_POSITION pos; | 853 FX_POSITION pos; |
| 854 pos = m_pPage->GetFirstObjectPosition(); | 854 pos = m_pPage->GetFirstObjectPosition(); |
| 855 if (!pos) { | 855 if (!pos) { |
| 856 return; | 856 return; |
| 857 } | 857 } |
| 858 m_TextlineDir = FindTextlineFlowDirection(); | 858 m_TextlineDir = FindTextlineFlowDirection(); |
| 859 int nCount = 0; | 859 int nCount = 0; |
| 860 while (pos) { | 860 while (pos) { |
| 861 pPageObj = m_pPage->GetNextObject(pos); | 861 pPageObj = m_pPage->GetNextObject(pos); |
| 862 if (pPageObj) { | 862 if (pPageObj) { |
| 863 if (pPageObj->m_Type == PDFPAGE_TEXT) { | 863 if (pPageObj->m_Type == CPDF_PageObject::TEXT) { |
| 864 CFX_Matrix matrix; | 864 CFX_Matrix matrix; |
| 865 ProcessTextObject((CPDF_TextObject*)pPageObj, matrix, pos); | 865 ProcessTextObject((CPDF_TextObject*)pPageObj, matrix, pos); |
| 866 nCount++; | 866 nCount++; |
| 867 } else if (pPageObj->m_Type == PDFPAGE_FORM) { | 867 } else if (pPageObj->m_Type == CPDF_PageObject::FORM) { |
| 868 CFX_Matrix formMatrix(1, 0, 0, 1, 0, 0); | 868 CFX_Matrix formMatrix(1, 0, 0, 1, 0, 0); |
| 869 ProcessFormObject((CPDF_FormObject*)pPageObj, formMatrix); | 869 ProcessFormObject((CPDF_FormObject*)pPageObj, formMatrix); |
| 870 } | 870 } |
| 871 } | 871 } |
| 872 pPageObj = NULL; | 872 pPageObj = NULL; |
| 873 } | 873 } |
| 874 int count = m_LineObj.GetSize(); | 874 int count = m_LineObj.GetSize(); |
| 875 for (int i = 0; i < count; i++) { | 875 for (int i = 0; i < count; i++) { |
| 876 ProcessTextObject(m_LineObj.GetAt(i)); | 876 ProcessTextObject(m_LineObj.GetAt(i)); |
| 877 } | 877 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 888 pos = pFormObj->m_pForm->GetFirstObjectPosition(); | 888 pos = pFormObj->m_pForm->GetFirstObjectPosition(); |
| 889 if (!pos) { | 889 if (!pos) { |
| 890 return; | 890 return; |
| 891 } | 891 } |
| 892 CFX_Matrix curFormMatrix; | 892 CFX_Matrix curFormMatrix; |
| 893 curFormMatrix.Copy(pFormObj->m_FormMatrix); | 893 curFormMatrix.Copy(pFormObj->m_FormMatrix); |
| 894 curFormMatrix.Concat(formMatrix); | 894 curFormMatrix.Concat(formMatrix); |
| 895 while (pos) { | 895 while (pos) { |
| 896 pPageObj = pFormObj->m_pForm->GetNextObject(pos); | 896 pPageObj = pFormObj->m_pForm->GetNextObject(pos); |
| 897 if (pPageObj) { | 897 if (pPageObj) { |
| 898 if (pPageObj->m_Type == PDFPAGE_TEXT) { | 898 if (pPageObj->m_Type == CPDF_PageObject::TEXT) { |
| 899 ProcessTextObject((CPDF_TextObject*)pPageObj, curFormMatrix, pos); | 899 ProcessTextObject((CPDF_TextObject*)pPageObj, curFormMatrix, pos); |
| 900 } else if (pPageObj->m_Type == PDFPAGE_FORM) { | 900 } else if (pPageObj->m_Type == CPDF_PageObject::FORM) { |
| 901 ProcessFormObject((CPDF_FormObject*)pPageObj, curFormMatrix); | 901 ProcessFormObject((CPDF_FormObject*)pPageObj, curFormMatrix); |
| 902 } | 902 } |
| 903 } | 903 } |
| 904 pPageObj = NULL; | 904 pPageObj = NULL; |
| 905 } | 905 } |
| 906 } | 906 } |
| 907 int CPDF_TextPage::GetCharWidth(FX_DWORD charCode, CPDF_Font* pFont) const { | 907 int CPDF_TextPage::GetCharWidth(FX_DWORD charCode, CPDF_Font* pFont) const { |
| 908 if (charCode == -1) { | 908 if (charCode == -1) { |
| 909 return 0; | 909 return 0; |
| 910 } | 910 } |
| (...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 int i = 0; | 1960 int i = 0; |
| 1961 if (!ObjPos) { | 1961 if (!ObjPos) { |
| 1962 ObjPos = m_pPage->GetLastObjectPosition(); | 1962 ObjPos = m_pPage->GetLastObjectPosition(); |
| 1963 } | 1963 } |
| 1964 CPDF_PageObject* pObj = m_pPage->GetPrevObject(ObjPos); | 1964 CPDF_PageObject* pObj = m_pPage->GetPrevObject(ObjPos); |
| 1965 while (i < 5 && ObjPos) { | 1965 while (i < 5 && ObjPos) { |
| 1966 pObj = m_pPage->GetPrevObject(ObjPos); | 1966 pObj = m_pPage->GetPrevObject(ObjPos); |
| 1967 if (pObj == pTextObj) { | 1967 if (pObj == pTextObj) { |
| 1968 continue; | 1968 continue; |
| 1969 } | 1969 } |
| 1970 if (pObj->m_Type != PDFPAGE_TEXT) { | 1970 if (pObj->m_Type != CPDF_PageObject::TEXT) { |
| 1971 continue; | 1971 continue; |
| 1972 } | 1972 } |
| 1973 if (IsSameTextObject((CPDF_TextObject*)pObj, pTextObj)) { | 1973 if (IsSameTextObject((CPDF_TextObject*)pObj, pTextObj)) { |
| 1974 return TRUE; | 1974 return TRUE; |
| 1975 } | 1975 } |
| 1976 i++; | 1976 i++; |
| 1977 } | 1977 } |
| 1978 return FALSE; | 1978 return FALSE; |
| 1979 } | 1979 } |
| 1980 | 1980 |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2634 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { | 2634 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { |
| 2635 return; | 2635 return; |
| 2636 } | 2636 } |
| 2637 CPDF_LinkExt* link = NULL; | 2637 CPDF_LinkExt* link = NULL; |
| 2638 link = m_LinkList.GetAt(index); | 2638 link = m_LinkList.GetAt(index); |
| 2639 if (!link) { | 2639 if (!link) { |
| 2640 return; | 2640 return; |
| 2641 } | 2641 } |
| 2642 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 2642 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |
| 2643 } | 2643 } |
| OLD | NEW |