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

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

Issue 1701883004: Banish CFX_ByteStringArray and CFX_WideStringArray to the XFA side. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Nits Created 4 years, 10 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
« no previous file with comments | « core/src/fpdfdoc/doc_form.cpp ('k') | core/src/fpdftext/text_int.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 findwhatStr.MakeLower(); 1981 findwhatStr.MakeLower();
1982 m_strText.MakeLower(); 1982 m_strText.MakeLower();
1983 } 1983 }
1984 m_bMatchWholeWord = flags & FPDFTEXT_MATCHWHOLEWORD; 1984 m_bMatchWholeWord = flags & FPDFTEXT_MATCHWHOLEWORD;
1985 m_findNextStart = startPos; 1985 m_findNextStart = startPos;
1986 if (startPos == -1) { 1986 if (startPos == -1) {
1987 m_findPreStart = m_strText.GetLength() - 1; 1987 m_findPreStart = m_strText.GetLength() - 1;
1988 } else { 1988 } else {
1989 m_findPreStart = startPos; 1989 m_findPreStart = startPos;
1990 } 1990 }
1991 m_csFindWhatArray.RemoveAll(); 1991 m_csFindWhatArray.clear();
1992 int i = 0; 1992 int i = 0;
1993 while (i < len) { 1993 while (i < len) {
1994 if (findwhatStr.GetAt(i) != ' ') { 1994 if (findwhatStr.GetAt(i) != ' ') {
1995 break; 1995 break;
1996 } 1996 }
1997 i++; 1997 i++;
1998 } 1998 }
1999 if (i < len) { 1999 if (i < len) {
2000 ExtractFindWhat(findwhatStr); 2000 ExtractFindWhat(findwhatStr);
2001 } else { 2001 } else {
2002 m_csFindWhatArray.Add(findwhatStr); 2002 m_csFindWhatArray.push_back(findwhatStr);
2003 } 2003 }
2004 if (m_csFindWhatArray.GetSize() <= 0) { 2004 if (m_csFindWhatArray.empty()) {
2005 return FALSE; 2005 return FALSE;
2006 } 2006 }
2007 m_IsFind = TRUE; 2007 m_IsFind = TRUE;
2008 m_resStart = 0; 2008 m_resStart = 0;
2009 m_resEnd = -1; 2009 m_resEnd = -1;
2010 return TRUE; 2010 return TRUE;
2011 } 2011 }
2012 2012
2013 FX_BOOL CPDF_TextPageFind::FindNext() { 2013 FX_BOOL CPDF_TextPageFind::FindNext() {
2014 if (!m_pTextPage) { 2014 if (!m_pTextPage) {
2015 return FALSE; 2015 return FALSE;
2016 } 2016 }
2017 m_resArray.RemoveAll(); 2017 m_resArray.RemoveAll();
2018 if (m_findNextStart == -1) { 2018 if (m_findNextStart == -1) {
2019 return FALSE; 2019 return FALSE;
2020 } 2020 }
2021 if (m_strText.IsEmpty()) { 2021 if (m_strText.IsEmpty()) {
2022 m_IsFind = FALSE; 2022 m_IsFind = FALSE;
2023 return m_IsFind; 2023 return m_IsFind;
2024 } 2024 }
2025 int strLen = m_strText.GetLength(); 2025 int strLen = m_strText.GetLength();
2026 if (m_findNextStart > strLen - 1) { 2026 if (m_findNextStart > strLen - 1) {
2027 m_IsFind = FALSE; 2027 m_IsFind = FALSE;
2028 return m_IsFind; 2028 return m_IsFind;
2029 } 2029 }
2030 int nCount = m_csFindWhatArray.GetSize(); 2030 int nCount = pdfium::CollectionSize<int>(m_csFindWhatArray);
2031 int nResultPos = 0; 2031 int nResultPos = 0;
2032 int nStartPos = 0; 2032 int nStartPos = 0;
2033 nStartPos = m_findNextStart; 2033 nStartPos = m_findNextStart;
2034 FX_BOOL bSpaceStart = FALSE; 2034 FX_BOOL bSpaceStart = FALSE;
2035 for (int iWord = 0; iWord < nCount; iWord++) { 2035 for (int iWord = 0; iWord < nCount; iWord++) {
2036 CFX_WideString csWord = m_csFindWhatArray[iWord]; 2036 CFX_WideString csWord = m_csFindWhatArray[iWord];
2037 if (csWord.IsEmpty()) { 2037 if (csWord.IsEmpty()) {
2038 if (iWord == nCount - 1) { 2038 if (iWord == nCount - 1) {
2039 FX_WCHAR strInsert = m_strText.GetAt(nStartPos); 2039 FX_WCHAR strInsert = m_strText.GetAt(nStartPos);
2040 if (strInsert == TEXT_LINEFEED_CHAR || strInsert == TEXT_BLANK_CHAR || 2040 if (strInsert == TEXT_LINEFEED_CHAR || strInsert == TEXT_BLANK_CHAR ||
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 nStartPos = endIndex + 1; 2095 nStartPos = endIndex + 1;
2096 if (!bMatch) { 2096 if (!bMatch) {
2097 iWord = -1; 2097 iWord = -1;
2098 if (bSpaceStart) { 2098 if (bSpaceStart) {
2099 nStartPos = m_resStart + m_csFindWhatArray[1].GetLength(); 2099 nStartPos = m_resStart + m_csFindWhatArray[1].GetLength();
2100 } else { 2100 } else {
2101 nStartPos = m_resStart + m_csFindWhatArray[0].GetLength(); 2101 nStartPos = m_resStart + m_csFindWhatArray[0].GetLength();
2102 } 2102 }
2103 } 2103 }
2104 } 2104 }
2105 m_resEnd = nResultPos + 2105 m_resEnd = nResultPos + m_csFindWhatArray.back().GetLength() - 1;
2106 m_csFindWhatArray[m_csFindWhatArray.GetSize() - 1].GetLength() - 1;
2107 m_IsFind = TRUE; 2106 m_IsFind = TRUE;
2108 int resStart = GetCharIndex(m_resStart); 2107 int resStart = GetCharIndex(m_resStart);
2109 int resEnd = GetCharIndex(m_resEnd); 2108 int resEnd = GetCharIndex(m_resEnd);
2110 m_pTextPage->GetRectArray(resStart, resEnd - resStart + 1, m_resArray); 2109 m_pTextPage->GetRectArray(resStart, resEnd - resStart + 1, m_resArray);
2111 if (m_flags & FPDFTEXT_CONSECUTIVE) { 2110 if (m_flags & FPDFTEXT_CONSECUTIVE) {
2112 m_findNextStart = m_resStart + 1; 2111 m_findNextStart = m_resStart + 1;
2113 m_findPreStart = m_resEnd - 1; 2112 m_findPreStart = m_resEnd - 1;
2114 } else { 2113 } else {
2115 m_findNextStart = m_resEnd + 1; 2114 m_findNextStart = m_resEnd + 1;
2116 m_findPreStart = m_resStart - 1; 2115 m_findPreStart = m_resStart - 1;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 if (findwhat.IsEmpty()) { 2167 if (findwhat.IsEmpty()) {
2169 return; 2168 return;
2170 } 2169 }
2171 int index = 0; 2170 int index = 0;
2172 while (1) { 2171 while (1) {
2173 CFX_WideString csWord = TEXT_EMPTY; 2172 CFX_WideString csWord = TEXT_EMPTY;
2174 int ret = 2173 int ret =
2175 ExtractSubString(csWord, findwhat.c_str(), index, TEXT_BLANK_CHAR); 2174 ExtractSubString(csWord, findwhat.c_str(), index, TEXT_BLANK_CHAR);
2176 if (csWord.IsEmpty()) { 2175 if (csWord.IsEmpty()) {
2177 if (ret) { 2176 if (ret) {
2178 m_csFindWhatArray.Add(CFX_WideString(L"")); 2177 m_csFindWhatArray.push_back(L"");
2179 index++; 2178 index++;
2180 continue; 2179 continue;
2181 } else { 2180 } else {
2182 break; 2181 break;
2183 } 2182 }
2184 } 2183 }
2185 int pos = 0; 2184 int pos = 0;
2186 while (pos < csWord.GetLength()) { 2185 while (pos < csWord.GetLength()) {
2187 CFX_WideString curStr = csWord.Mid(pos, 1); 2186 CFX_WideString curStr = csWord.Mid(pos, 1);
2188 FX_WCHAR curChar = csWord.GetAt(pos); 2187 FX_WCHAR curChar = csWord.GetAt(pos);
2189 if (_IsIgnoreSpaceCharacter(curChar)) { 2188 if (_IsIgnoreSpaceCharacter(curChar)) {
2190 if (pos > 0 && curChar == 0x2019) { 2189 if (pos > 0 && curChar == 0x2019) {
2191 pos++; 2190 pos++;
2192 continue; 2191 continue;
2193 } 2192 }
2194 if (pos > 0) { 2193 if (pos > 0) {
2195 CFX_WideString preStr = csWord.Mid(0, pos); 2194 m_csFindWhatArray.push_back(csWord.Mid(0, pos));
2196 m_csFindWhatArray.Add(preStr);
2197 } 2195 }
2198 m_csFindWhatArray.Add(curStr); 2196 m_csFindWhatArray.push_back(curStr);
2199 if (pos == csWord.GetLength() - 1) { 2197 if (pos == csWord.GetLength() - 1) {
2200 csWord.Empty(); 2198 csWord.Empty();
2201 break; 2199 break;
2202 } 2200 }
2203 csWord = csWord.Right(csWord.GetLength() - pos - 1); 2201 csWord = csWord.Right(csWord.GetLength() - pos - 1);
2204 pos = 0; 2202 pos = 0;
2205 continue; 2203 continue;
2206 } 2204 }
2207 pos++; 2205 pos++;
2208 } 2206 }
2209 if (!csWord.IsEmpty()) { 2207 if (!csWord.IsEmpty()) {
2210 m_csFindWhatArray.Add(csWord); 2208 m_csFindWhatArray.push_back(csWord);
2211 } 2209 }
2212 index++; 2210 index++;
2213 } 2211 }
2214 } 2212 }
2215 2213
2216 FX_BOOL CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText, 2214 FX_BOOL CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText,
2217 int startPos, 2215 int startPos,
2218 int endPos) { 2216 int endPos) {
2219 FX_WCHAR char_left = 0; 2217 FX_WCHAR char_left = 0;
2220 FX_WCHAR char_right = 0; 2218 FX_WCHAR char_right = 0;
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
2524 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { 2522 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) {
2525 return; 2523 return;
2526 } 2524 }
2527 CPDF_LinkExt* link = NULL; 2525 CPDF_LinkExt* link = NULL;
2528 link = m_LinkList.GetAt(index); 2526 link = m_LinkList.GetAt(index);
2529 if (!link) { 2527 if (!link) {
2530 return; 2528 return;
2531 } 2529 }
2532 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); 2530 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
2533 } 2531 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_form.cpp ('k') | core/src/fpdftext/text_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698