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/fpdfapi/fpdf_resource.h" | 7 #include "../../include/fpdfapi/fpdf_resource.h" |
8 #include "../../include/fpdfapi/fpdf_pageobj.h" | 8 #include "../../include/fpdfapi/fpdf_pageobj.h" |
9 #include "../../include/fpdftext/fpdf_text.h" | 9 #include "../../include/fpdftext/fpdf_text.h" |
10 #include "../../include/fpdfapi/fpdf_page.h" | 10 #include "../../include/fpdfapi/fpdf_page.h" |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 { | 932 { |
933 if (!m_pPage) { | 933 if (!m_pPage) { |
934 return -1; | 934 return -1; |
935 } | 935 } |
936 const FX_INT32 nPageWidth = (FX_INT32)((CPDF_Page*)m_pPage)->GetPageWidth(); | 936 const FX_INT32 nPageWidth = (FX_INT32)((CPDF_Page*)m_pPage)->GetPageWidth(); |
937 const FX_INT32 nPageHeight = (FX_INT32)((CPDF_Page*)m_pPage)->GetPageHeight(
); | 937 const FX_INT32 nPageHeight = (FX_INT32)((CPDF_Page*)m_pPage)->GetPageHeight(
); |
938 CFX_ByteArray nHorizontalMask; | 938 CFX_ByteArray nHorizontalMask; |
939 if (!nHorizontalMask.SetSize(nPageWidth)) { | 939 if (!nHorizontalMask.SetSize(nPageWidth)) { |
940 return -1; | 940 return -1; |
941 } | 941 } |
942 » FX_BYTE* pDataH = nHorizontalMask.GetData(); | 942 FX_BYTE* pDataH = nHorizontalMask.GetData(); |
943 CFX_ByteArray nVerticalMask; | 943 CFX_ByteArray nVerticalMask; |
944 if (!nVerticalMask.SetSize(nPageHeight)) { | 944 if (!nVerticalMask.SetSize(nPageHeight)) { |
945 return -1; | 945 return -1; |
946 } | 946 } |
947 » FX_BYTE* pDataV = nVerticalMask.GetData(); | 947 FX_BYTE* pDataV = nVerticalMask.GetData(); |
948 FX_INT32 index = 0; | 948 FX_INT32 index = 0; |
949 FX_FLOAT fLineHeight = 0.0f; | 949 FX_FLOAT fLineHeight = 0.0f; |
950 CPDF_PageObject* pPageObj = NULL; | 950 CPDF_PageObject* pPageObj = NULL; |
951 FX_POSITION pos = NULL; | 951 FX_POSITION pos = NULL; |
952 pos = m_pPage->GetFirstObjectPosition(); | 952 pos = m_pPage->GetFirstObjectPosition(); |
953 if(!pos) { | 953 if(!pos) { |
954 return -1; | 954 return -1; |
955 } | 955 } |
956 while(pos) { | 956 while(pos) { |
957 pPageObj = m_pPage->GetNextObject(pos); | 957 pPageObj = m_pPage->GetNextObject(pos); |
958 if(NULL == pPageObj) { | 958 if(NULL == pPageObj) { |
959 continue; | 959 continue; |
960 } | 960 } |
961 if(PDFPAGE_TEXT != pPageObj->m_Type) { | 961 if(PDFPAGE_TEXT != pPageObj->m_Type) { |
962 continue; | 962 continue; |
963 } | 963 } |
964 » » FX_INT32 minH = (FX_INT32)pPageObj->m_Left < 0 ? 0 : (FX_INT32)p
PageObj->m_Left; | 964 FX_INT32 minH = (FX_INT32)pPageObj->m_Left < 0 ? 0 : (FX_INT32)pPageObj-
>m_Left; |
965 » » FX_INT32 maxH = (FX_INT32)pPageObj->m_Right > nPageWidth ? nPage
Width : (FX_INT32)pPageObj->m_Right; | 965 FX_INT32 maxH = (FX_INT32)pPageObj->m_Right > nPageWidth ? nPageWidth :
(FX_INT32)pPageObj->m_Right; |
966 » » FX_INT32 minV = (FX_INT32)pPageObj->m_Bottom < 0 ? 0 : (FX_INT32
)pPageObj->m_Bottom; | 966 FX_INT32 minV = (FX_INT32)pPageObj->m_Bottom < 0 ? 0 : (FX_INT32)pPageOb
j->m_Bottom; |
967 » » FX_INT32 maxV = (FX_INT32)pPageObj->m_Top > nPageHeight ? nPageH
eight : (FX_INT32)pPageObj->m_Top; | 967 FX_INT32 maxV = (FX_INT32)pPageObj->m_Top > nPageHeight ? nPageHeight :
(FX_INT32)pPageObj->m_Top; |
968 » » if (minH >= maxH || minV >= maxV){ | 968 if (minH >= maxH || minV >= maxV) { |
969 » » » continue; | 969 continue; |
970 » » } | 970 } |
971 | 971 FXSYS_memset8(pDataH + minH, 1, maxH - minH); |
972 » » FXSYS_memset8(pDataH + minH, 1, maxH - minH); | 972 FXSYS_memset8(pDataV + minV, 1, maxV - minV); |
973 » » FXSYS_memset8(pDataV + minV, 1, maxV - minV); | 973 if (fLineHeight <= 0.0f) { |
974 | 974 fLineHeight = pPageObj->m_Top - pPageObj->m_Bottom; |
975 » » if (fLineHeight <= 0.0f) { | 975 } |
976 » » » fLineHeight = pPageObj->m_Top - pPageObj->m_Bottom; | 976 pPageObj = NULL; |
977 » » } | |
978 | |
979 » » pPageObj = NULL; | |
980 } | 977 } |
981 FX_INT32 nStartH = 0; | 978 FX_INT32 nStartH = 0; |
982 FX_INT32 nEndH = 0; | 979 FX_INT32 nEndH = 0; |
983 FX_FLOAT nSumH = 0.0f; | 980 FX_FLOAT nSumH = 0.0f; |
984 for (index = 0; index < nPageWidth; index++) | 981 for (index = 0; index < nPageWidth; index++) |
985 if(1 == nHorizontalMask[index]) { | 982 if(1 == nHorizontalMask[index]) { |
986 break; | 983 break; |
987 } | 984 } |
988 nStartH = index; | 985 nStartH = index; |
989 for (index = nPageWidth; index > 0; index--) | 986 for (index = nPageWidth; index > 0; index--) |
(...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2795 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { | 2792 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { |
2796 return; | 2793 return; |
2797 } | 2794 } |
2798 CPDF_LinkExt* link = NULL; | 2795 CPDF_LinkExt* link = NULL; |
2799 link = m_LinkList.GetAt(index); | 2796 link = m_LinkList.GetAt(index); |
2800 if (!link) { | 2797 if (!link) { |
2801 return ; | 2798 return ; |
2802 } | 2799 } |
2803 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 2800 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |
2804 } | 2801 } |
OLD | NEW |