Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: core/fpdftext/fpdf_text_int.cpp

Issue 2032613003: Get rid of NULLs in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: s/NULL/nullptr/ Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return charInfo.m_Flag != FPDFTEXT_CHAR_HYPHEN; 170 return charInfo.m_Flag != FPDFTEXT_CHAR_HYPHEN;
171 default: 171 default:
172 return false; 172 return false;
173 } 173 }
174 } 174 }
175 175
176 void CPDF_TextPage::ParseTextPage() { 176 void CPDF_TextPage::ParseTextPage() {
177 m_bIsParsed = false; 177 m_bIsParsed = false;
178 m_TextBuf.Clear(); 178 m_TextBuf.Clear();
179 m_CharList.clear(); 179 m_CharList.clear();
180 m_pPreTextObj = NULL; 180 m_pPreTextObj = nullptr;
181 ProcessObject(); 181 ProcessObject();
182 182
183 m_bIsParsed = true; 183 m_bIsParsed = true;
184 m_CharIndex.clear(); 184 m_CharIndex.clear();
185 int nCount = pdfium::CollectionSize<int>(m_CharList); 185 int nCount = pdfium::CollectionSize<int>(m_CharList);
186 if (nCount) { 186 if (nCount) {
187 m_CharIndex.push_back(0); 187 m_CharIndex.push_back(0);
188 } 188 }
189 for (int i = 0; i < nCount; i++) { 189 for (int i = 0; i < nCount; i++) {
190 int indexSize = pdfium::CollectionSize<int>(m_CharIndex); 190 int indexSize = pdfium::CollectionSize<int>(m_CharIndex);
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 return w; 829 return w;
830 830
831 return pFont->GetCharBBox(charCode).Width(); 831 return pFont->GetCharBBox(charCode).Width();
832 } 832 }
833 833
834 void CPDF_TextPage::AddCharInfoByLRDirection(FX_WCHAR wChar, 834 void CPDF_TextPage::AddCharInfoByLRDirection(FX_WCHAR wChar,
835 PAGECHAR_INFO info) { 835 PAGECHAR_INFO info) {
836 if (!IsControlChar(info)) { 836 if (!IsControlChar(info)) {
837 info.m_Index = m_TextBuf.GetLength(); 837 info.m_Index = m_TextBuf.GetLength();
838 if (wChar >= 0xFB00 && wChar <= 0xFB06) { 838 if (wChar >= 0xFB00 && wChar <= 0xFB06) {
839 FX_WCHAR* pDst = NULL; 839 FX_WCHAR* pDst = nullptr;
840 FX_STRSIZE nCount = Unicode_GetNormalization(wChar, pDst); 840 FX_STRSIZE nCount = Unicode_GetNormalization(wChar, pDst);
841 if (nCount >= 1) { 841 if (nCount >= 1) {
842 pDst = FX_Alloc(FX_WCHAR, nCount); 842 pDst = FX_Alloc(FX_WCHAR, nCount);
843 Unicode_GetNormalization(wChar, pDst); 843 Unicode_GetNormalization(wChar, pDst);
844 for (int nIndex = 0; nIndex < nCount; nIndex++) { 844 for (int nIndex = 0; nIndex < nCount; nIndex++) {
845 PAGECHAR_INFO info2 = info; 845 PAGECHAR_INFO info2 = info;
846 info2.m_Unicode = pDst[nIndex]; 846 info2.m_Unicode = pDst[nIndex];
847 info2.m_Flag = FPDFTEXT_CHAR_PIECE; 847 info2.m_Flag = FPDFTEXT_CHAR_PIECE;
848 m_TextBuf.AppendChar(info2.m_Unicode); 848 m_TextBuf.AppendChar(info2.m_Unicode);
849 m_CharList.push_back(info2); 849 m_CharList.push_back(info2);
850 } 850 }
851 FX_Free(pDst); 851 FX_Free(pDst);
852 return; 852 return;
853 } 853 }
854 } 854 }
855 m_TextBuf.AppendChar(wChar); 855 m_TextBuf.AppendChar(wChar);
856 } else { 856 } else {
857 info.m_Index = -1; 857 info.m_Index = -1;
858 } 858 }
859 m_CharList.push_back(info); 859 m_CharList.push_back(info);
860 } 860 }
861 861
862 void CPDF_TextPage::AddCharInfoByRLDirection(FX_WCHAR wChar, 862 void CPDF_TextPage::AddCharInfoByRLDirection(FX_WCHAR wChar,
863 PAGECHAR_INFO info) { 863 PAGECHAR_INFO info) {
864 if (!IsControlChar(info)) { 864 if (!IsControlChar(info)) {
865 info.m_Index = m_TextBuf.GetLength(); 865 info.m_Index = m_TextBuf.GetLength();
866 wChar = FX_GetMirrorChar(wChar, TRUE, FALSE); 866 wChar = FX_GetMirrorChar(wChar, TRUE, FALSE);
867 FX_WCHAR* pDst = NULL; 867 FX_WCHAR* pDst = nullptr;
868 FX_STRSIZE nCount = Unicode_GetNormalization(wChar, pDst); 868 FX_STRSIZE nCount = Unicode_GetNormalization(wChar, pDst);
869 if (nCount >= 1) { 869 if (nCount >= 1) {
870 pDst = FX_Alloc(FX_WCHAR, nCount); 870 pDst = FX_Alloc(FX_WCHAR, nCount);
871 Unicode_GetNormalization(wChar, pDst); 871 Unicode_GetNormalization(wChar, pDst);
872 for (int nIndex = 0; nIndex < nCount; nIndex++) { 872 for (int nIndex = 0; nIndex < nCount; nIndex++) {
873 PAGECHAR_INFO info2 = info; 873 PAGECHAR_INFO info2 = info;
874 info2.m_Unicode = pDst[nIndex]; 874 info2.m_Unicode = pDst[nIndex];
875 info2.m_Flag = FPDFTEXT_CHAR_PIECE; 875 info2.m_Flag = FPDFTEXT_CHAR_PIECE;
876 m_TextBuf.AppendChar(info2.m_Unicode); 876 m_TextBuf.AppendChar(info2.m_Unicode);
877 m_CharList.push_back(info2); 877 m_CharList.push_back(info2);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 (CPDF_ContentMarkData*)pTextObj->m_ContentMark.GetObject(); 1015 (CPDF_ContentMarkData*)pTextObj->m_ContentMark.GetObject();
1016 if (!pMarkData) 1016 if (!pMarkData)
1017 return FPDFText_MarkedContent::Pass; 1017 return FPDFText_MarkedContent::Pass;
1018 1018
1019 int nContentMark = pMarkData->CountItems(); 1019 int nContentMark = pMarkData->CountItems();
1020 if (nContentMark < 1) 1020 if (nContentMark < 1)
1021 return FPDFText_MarkedContent::Pass; 1021 return FPDFText_MarkedContent::Pass;
1022 1022
1023 CFX_WideString actText; 1023 CFX_WideString actText;
1024 FX_BOOL bExist = FALSE; 1024 FX_BOOL bExist = FALSE;
1025 CPDF_Dictionary* pDict = NULL; 1025 CPDF_Dictionary* pDict = nullptr;
1026 int n = 0; 1026 int n = 0;
1027 for (n = 0; n < nContentMark; n++) { 1027 for (n = 0; n < nContentMark; n++) {
1028 CPDF_ContentMarkItem& item = pMarkData->GetItem(n); 1028 CPDF_ContentMarkItem& item = pMarkData->GetItem(n);
1029 if (item.GetParamType() == CPDF_ContentMarkItem::ParamType::None) 1029 if (item.GetParamType() == CPDF_ContentMarkItem::ParamType::None)
1030 continue; 1030 continue;
1031 pDict = item.GetParam(); 1031 pDict = item.GetParam();
1032 CPDF_String* temp = 1032 CPDF_String* temp =
1033 ToString(pDict ? pDict->GetObjectBy("ActualText") : nullptr); 1033 ToString(pDict ? pDict->GetObjectBy("ActualText") : nullptr);
1034 if (temp) { 1034 if (temp) {
1035 bExist = TRUE; 1035 bExist = TRUE;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 CPDF_TextObject* pTextObj = Obj.m_pTextObj; 1081 CPDF_TextObject* pTextObj = Obj.m_pTextObj;
1082 CPDF_ContentMarkData* pMarkData = 1082 CPDF_ContentMarkData* pMarkData =
1083 (CPDF_ContentMarkData*)pTextObj->m_ContentMark.GetObject(); 1083 (CPDF_ContentMarkData*)pTextObj->m_ContentMark.GetObject();
1084 if (!pMarkData) 1084 if (!pMarkData)
1085 return; 1085 return;
1086 1086
1087 int nContentMark = pMarkData->CountItems(); 1087 int nContentMark = pMarkData->CountItems();
1088 if (nContentMark < 1) 1088 if (nContentMark < 1)
1089 return; 1089 return;
1090 CFX_WideString actText; 1090 CFX_WideString actText;
1091 CPDF_Dictionary* pDict = NULL; 1091 CPDF_Dictionary* pDict = nullptr;
1092 for (int n = 0; n < nContentMark; n++) { 1092 for (int n = 0; n < nContentMark; n++) {
1093 CPDF_ContentMarkItem& item = pMarkData->GetItem(n); 1093 CPDF_ContentMarkItem& item = pMarkData->GetItem(n);
1094 if (item.GetParamType() == CPDF_ContentMarkItem::ParamType::None) 1094 if (item.GetParamType() == CPDF_ContentMarkItem::ParamType::None)
1095 continue; 1095 continue;
1096 pDict = item.GetParam(); 1096 pDict = item.GetParam();
1097 if (pDict) 1097 if (pDict)
1098 actText = pDict->GetUnicodeTextBy("ActualText"); 1098 actText = pDict->GetUnicodeTextBy("ActualText");
1099 } 1099 }
1100 FX_STRSIZE nItems = actText.GetLength(); 1100 FX_STRSIZE nItems = actText.GetLength();
1101 if (nItems < 1) 1101 if (nItems < 1)
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 const PAGECHAR_INFO* preChar; 1756 const PAGECHAR_INFO* preChar;
1757 if (!m_TempCharList.empty()) { 1757 if (!m_TempCharList.empty()) {
1758 preChar = &m_TempCharList.back(); 1758 preChar = &m_TempCharList.back();
1759 } else if (!m_CharList.empty()) { 1759 } else if (!m_CharList.empty()) {
1760 preChar = &m_CharList.back(); 1760 preChar = &m_CharList.back();
1761 } else { 1761 } else {
1762 return FALSE; 1762 return FALSE;
1763 } 1763 }
1764 info.m_Index = m_TextBuf.GetLength(); 1764 info.m_Index = m_TextBuf.GetLength();
1765 info.m_Unicode = unicode; 1765 info.m_Unicode = unicode;
1766 info.m_pTextObj = NULL; 1766 info.m_pTextObj = nullptr;
1767 info.m_CharCode = CPDF_Font::kInvalidCharCode; 1767 info.m_CharCode = CPDF_Font::kInvalidCharCode;
1768 info.m_Flag = FPDFTEXT_CHAR_GENERATED; 1768 info.m_Flag = FPDFTEXT_CHAR_GENERATED;
1769 int preWidth = 0; 1769 int preWidth = 0;
1770 if (preChar->m_pTextObj && preChar->m_CharCode != -1) { 1770 if (preChar->m_pTextObj && preChar->m_CharCode != -1) {
1771 preWidth = 1771 preWidth =
1772 GetCharWidth(preChar->m_CharCode, preChar->m_pTextObj->GetFont()); 1772 GetCharWidth(preChar->m_CharCode, preChar->m_pTextObj->GetFont());
1773 } 1773 }
1774 1774
1775 FX_FLOAT fFontSize = preChar->m_pTextObj ? preChar->m_pTextObj->GetFontSize() 1775 FX_FLOAT fFontSize = preChar->m_pTextObj ? preChar->m_pTextObj->GetFontSize()
1776 : preChar->m_CharBox.Height(); 1776 : preChar->m_CharBox.Height();
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 return index < m_LinkArray.size() ? m_LinkArray[index].m_strUrl : L""; 2341 return index < m_LinkArray.size() ? m_LinkArray[index].m_strUrl : L"";
2342 } 2342 }
2343 2343
2344 std::vector<CFX_FloatRect> CPDF_LinkExtract::GetRects(size_t index) const { 2344 std::vector<CFX_FloatRect> CPDF_LinkExtract::GetRects(size_t index) const {
2345 if (index >= m_LinkArray.size()) 2345 if (index >= m_LinkArray.size())
2346 return std::vector<CFX_FloatRect>(); 2346 return std::vector<CFX_FloatRect>();
2347 2347
2348 return m_pTextPage->GetRectArray(m_LinkArray[index].m_Start, 2348 return m_pTextPage->GetRectArray(m_LinkArray[index].m_Start,
2349 m_LinkArray[index].m_Count); 2349 m_LinkArray[index].m_Count);
2350 } 2350 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698