Chromium Code Reviews| 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/fpdftext/include/cpdf_textpage.h" | 7 #include "core/fpdftext/include/cpdf_textpage.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 int nContentMark = pTextObj->m_ContentMark.CountItems(); | 811 int nContentMark = pTextObj->m_ContentMark.CountItems(); |
| 812 if (nContentMark < 1) | 812 if (nContentMark < 1) |
| 813 return FPDFText_MarkedContent::Pass; | 813 return FPDFText_MarkedContent::Pass; |
| 814 | 814 |
| 815 CFX_WideString actText; | 815 CFX_WideString actText; |
| 816 bool bExist = false; | 816 bool bExist = false; |
| 817 CPDF_Dictionary* pDict = nullptr; | 817 CPDF_Dictionary* pDict = nullptr; |
| 818 int n = 0; | 818 int n = 0; |
| 819 for (n = 0; n < nContentMark; n++) { | 819 for (n = 0; n < nContentMark; n++) { |
| 820 const CPDF_ContentMarkItem& item = pTextObj->m_ContentMark.GetItem(n); | 820 const CPDF_ContentMarkItem& item = pTextObj->m_ContentMark.GetItem(n); |
| 821 if (item.GetParamType() == CPDF_ContentMarkItem::ParamType::None) | 821 pDict = item.GetParam(); |
| 822 if (!pDict) | |
| 822 continue; | 823 continue; |
| 823 pDict = item.GetParam(); | 824 CPDF_String* temp = ToString(pDict->GetObjectFor("ActualText")); |
|
dsinclair
2016/09/21 19:34:43
Can't this still, possibly be null, if we called S
Tom Sepez
2016/09/21 20:04:44
Either way, pDict is assigned to nullptr, and we c
| |
| 824 CPDF_String* temp = | |
| 825 ToString(pDict ? pDict->GetObjectFor("ActualText") : nullptr); | |
| 826 if (temp) { | 825 if (temp) { |
| 827 bExist = true; | 826 bExist = true; |
| 828 actText = temp->GetUnicodeText(); | 827 actText = temp->GetUnicodeText(); |
| 829 } | 828 } |
| 830 } | 829 } |
| 831 if (!bExist) | 830 if (!bExist) |
| 832 return FPDFText_MarkedContent::Pass; | 831 return FPDFText_MarkedContent::Pass; |
| 833 | 832 |
| 834 if (m_pPreTextObj && m_pPreTextObj->m_ContentMark && | 833 if (m_pPreTextObj && m_pPreTextObj->m_ContentMark && |
| 835 m_pPreTextObj->m_ContentMark.CountItems() == n && | 834 m_pPreTextObj->m_ContentMark.CountItems() == n && |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 870 void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { | 869 void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { |
| 871 CPDF_TextObject* pTextObj = Obj.m_pTextObj; | 870 CPDF_TextObject* pTextObj = Obj.m_pTextObj; |
| 872 if (!pTextObj->m_ContentMark) | 871 if (!pTextObj->m_ContentMark) |
| 873 return; | 872 return; |
| 874 | 873 |
| 875 int nContentMark = pTextObj->m_ContentMark.CountItems(); | 874 int nContentMark = pTextObj->m_ContentMark.CountItems(); |
| 876 if (nContentMark < 1) | 875 if (nContentMark < 1) |
| 877 return; | 876 return; |
| 878 | 877 |
| 879 CFX_WideString actText; | 878 CFX_WideString actText; |
| 880 CPDF_Dictionary* pDict = nullptr; | |
| 881 for (int n = 0; n < nContentMark; n++) { | 879 for (int n = 0; n < nContentMark; n++) { |
| 882 const CPDF_ContentMarkItem& item = pTextObj->m_ContentMark.GetItem(n); | 880 const CPDF_ContentMarkItem& item = pTextObj->m_ContentMark.GetItem(n); |
| 883 if (item.GetParamType() == CPDF_ContentMarkItem::ParamType::None) | 881 CPDF_Dictionary* pDict = item.GetParam(); |
| 884 continue; | |
| 885 pDict = item.GetParam(); | |
| 886 if (pDict) | 882 if (pDict) |
| 887 actText = pDict->GetUnicodeTextFor("ActualText"); | 883 actText = pDict->GetUnicodeTextFor("ActualText"); |
| 888 } | 884 } |
| 889 FX_STRSIZE nItems = actText.GetLength(); | 885 FX_STRSIZE nItems = actText.GetLength(); |
| 890 if (nItems < 1) | 886 if (nItems < 1) |
| 891 return; | 887 return; |
| 892 | 888 |
| 893 CPDF_Font* pFont = pTextObj->GetFont(); | 889 CPDF_Font* pFont = pTextObj->GetFont(); |
| 894 CFX_Matrix formMatrix = Obj.m_formMatrix; | 890 CFX_Matrix formMatrix = Obj.m_formMatrix; |
| 895 CFX_Matrix matrix; | 891 CFX_Matrix matrix; |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1533 info.m_OriginY); | 1529 info.m_OriginY); |
| 1534 return TRUE; | 1530 return TRUE; |
| 1535 } | 1531 } |
| 1536 | 1532 |
| 1537 FX_BOOL CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1, | 1533 FX_BOOL CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1, |
| 1538 const CFX_FloatRect& rect2) { | 1534 const CFX_FloatRect& rect2) { |
| 1539 CFX_FloatRect rect = rect1; | 1535 CFX_FloatRect rect = rect1; |
| 1540 rect.Intersect(rect2); | 1536 rect.Intersect(rect2); |
| 1541 return !rect.IsEmpty(); | 1537 return !rect.IsEmpty(); |
| 1542 } | 1538 } |
| OLD | NEW |