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 #include <cctype> | 8 #include <cctype> |
9 #include <cwctype> | 9 #include <cwctype> |
10 #include <memory> | 10 #include <memory> |
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 break; | 1001 break; |
1002 } | 1002 } |
1003 } | 1003 } |
1004 if (i < 0) { | 1004 if (i < 0) { |
1005 m_LineObj.InsertAt(0, Obj); | 1005 m_LineObj.InsertAt(0, Obj); |
1006 } | 1006 } |
1007 } | 1007 } |
1008 | 1008 |
1009 FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { | 1009 FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { |
1010 CPDF_TextObject* pTextObj = Obj.m_pTextObj; | 1010 CPDF_TextObject* pTextObj = Obj.m_pTextObj; |
1011 CPDF_ContentMarkData* pMarkData = | 1011 const CPDF_ContentMarkData* pMarkData = pTextObj->m_ContentMark.GetObject(); |
1012 (CPDF_ContentMarkData*)pTextObj->m_ContentMark.GetObject(); | |
1013 if (!pMarkData) | 1012 if (!pMarkData) |
1014 return FPDFText_MarkedContent::Pass; | 1013 return FPDFText_MarkedContent::Pass; |
1015 | 1014 |
1016 int nContentMark = pMarkData->CountItems(); | 1015 int nContentMark = pMarkData->CountItems(); |
1017 if (nContentMark < 1) | 1016 if (nContentMark < 1) |
1018 return FPDFText_MarkedContent::Pass; | 1017 return FPDFText_MarkedContent::Pass; |
1019 | 1018 |
1020 CFX_WideString actText; | 1019 CFX_WideString actText; |
1021 FX_BOOL bExist = FALSE; | 1020 FX_BOOL bExist = FALSE; |
1022 CPDF_Dictionary* pDict = nullptr; | 1021 CPDF_Dictionary* pDict = nullptr; |
1023 int n = 0; | 1022 int n = 0; |
1024 for (n = 0; n < nContentMark; n++) { | 1023 for (n = 0; n < nContentMark; n++) { |
1025 CPDF_ContentMarkItem& item = pMarkData->GetItem(n); | 1024 const CPDF_ContentMarkItem& item = pMarkData->GetItem(n); |
1026 if (item.GetParamType() == CPDF_ContentMarkItem::ParamType::None) | 1025 if (item.GetParamType() == CPDF_ContentMarkItem::ParamType::None) |
1027 continue; | 1026 continue; |
1028 pDict = item.GetParam(); | 1027 pDict = item.GetParam(); |
1029 CPDF_String* temp = | 1028 CPDF_String* temp = |
1030 ToString(pDict ? pDict->GetObjectBy("ActualText") : nullptr); | 1029 ToString(pDict ? pDict->GetObjectBy("ActualText") : nullptr); |
1031 if (temp) { | 1030 if (temp) { |
1032 bExist = TRUE; | 1031 bExist = TRUE; |
1033 actText = temp->GetUnicodeText(); | 1032 actText = temp->GetUnicodeText(); |
1034 } | 1033 } |
1035 } | 1034 } |
1036 if (!bExist) | 1035 if (!bExist) |
1037 return FPDFText_MarkedContent::Pass; | 1036 return FPDFText_MarkedContent::Pass; |
1038 | 1037 |
1039 if (m_pPreTextObj) { | 1038 if (m_pPreTextObj) { |
1040 CPDF_ContentMarkData* pPreMarkData = | 1039 const CPDF_ContentMarkData* pPreMarkData = |
1041 (CPDF_ContentMarkData*)m_pPreTextObj->m_ContentMark.GetObject(); | 1040 m_pPreTextObj->m_ContentMark.GetObject(); |
1042 if (pPreMarkData && pPreMarkData->CountItems() == n && | 1041 if (pPreMarkData && pPreMarkData->CountItems() == n && |
1043 pDict == pPreMarkData->GetItem(n - 1).GetParam()) { | 1042 pDict == pPreMarkData->GetItem(n - 1).GetParam()) { |
1044 return FPDFText_MarkedContent::Done; | 1043 return FPDFText_MarkedContent::Done; |
1045 } | 1044 } |
1046 } | 1045 } |
1047 FX_STRSIZE nItems = actText.GetLength(); | 1046 FX_STRSIZE nItems = actText.GetLength(); |
1048 if (nItems < 1) | 1047 if (nItems < 1) |
1049 return FPDFText_MarkedContent::Pass; | 1048 return FPDFText_MarkedContent::Pass; |
1050 | 1049 |
1051 CPDF_Font* pFont = pTextObj->GetFont(); | 1050 CPDF_Font* pFont = pTextObj->GetFont(); |
(...skipping 17 matching lines...) Expand all Loading... |
1069 } | 1068 } |
1070 } | 1069 } |
1071 if (!bExist) | 1070 if (!bExist) |
1072 return FPDFText_MarkedContent::Done; | 1071 return FPDFText_MarkedContent::Done; |
1073 | 1072 |
1074 return FPDFText_MarkedContent::Delay; | 1073 return FPDFText_MarkedContent::Delay; |
1075 } | 1074 } |
1076 | 1075 |
1077 void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { | 1076 void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { |
1078 CPDF_TextObject* pTextObj = Obj.m_pTextObj; | 1077 CPDF_TextObject* pTextObj = Obj.m_pTextObj; |
1079 CPDF_ContentMarkData* pMarkData = | 1078 const CPDF_ContentMarkData* pMarkData = pTextObj->m_ContentMark.GetObject(); |
1080 (CPDF_ContentMarkData*)pTextObj->m_ContentMark.GetObject(); | |
1081 if (!pMarkData) | 1079 if (!pMarkData) |
1082 return; | 1080 return; |
1083 | 1081 |
1084 int nContentMark = pMarkData->CountItems(); | 1082 int nContentMark = pMarkData->CountItems(); |
1085 if (nContentMark < 1) | 1083 if (nContentMark < 1) |
1086 return; | 1084 return; |
1087 CFX_WideString actText; | 1085 CFX_WideString actText; |
1088 CPDF_Dictionary* pDict = nullptr; | 1086 CPDF_Dictionary* pDict = nullptr; |
1089 for (int n = 0; n < nContentMark; n++) { | 1087 for (int n = 0; n < nContentMark; n++) { |
1090 CPDF_ContentMarkItem& item = pMarkData->GetItem(n); | 1088 const CPDF_ContentMarkItem& item = pMarkData->GetItem(n); |
1091 if (item.GetParamType() == CPDF_ContentMarkItem::ParamType::None) | 1089 if (item.GetParamType() == CPDF_ContentMarkItem::ParamType::None) |
1092 continue; | 1090 continue; |
1093 pDict = item.GetParam(); | 1091 pDict = item.GetParam(); |
1094 if (pDict) | 1092 if (pDict) |
1095 actText = pDict->GetUnicodeTextBy("ActualText"); | 1093 actText = pDict->GetUnicodeTextBy("ActualText"); |
1096 } | 1094 } |
1097 FX_STRSIZE nItems = actText.GetLength(); | 1095 FX_STRSIZE nItems = actText.GetLength(); |
1098 if (nItems < 1) | 1096 if (nItems < 1) |
1099 return; | 1097 return; |
1100 | 1098 |
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2338 return index < m_LinkArray.size() ? m_LinkArray[index].m_strUrl : L""; | 2336 return index < m_LinkArray.size() ? m_LinkArray[index].m_strUrl : L""; |
2339 } | 2337 } |
2340 | 2338 |
2341 std::vector<CFX_FloatRect> CPDF_LinkExtract::GetRects(size_t index) const { | 2339 std::vector<CFX_FloatRect> CPDF_LinkExtract::GetRects(size_t index) const { |
2342 if (index >= m_LinkArray.size()) | 2340 if (index >= m_LinkArray.size()) |
2343 return std::vector<CFX_FloatRect>(); | 2341 return std::vector<CFX_FloatRect>(); |
2344 | 2342 |
2345 return m_pTextPage->GetRectArray(m_LinkArray[index].m_Start, | 2343 return m_pTextPage->GetRectArray(m_LinkArray[index].m_Start, |
2346 m_LinkArray[index].m_Count); | 2344 m_LinkArray[index].m_Count); |
2347 } | 2345 } |
OLD | NEW |