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

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

Issue 1618273004: Remove CFX_SegmentedArray use from master (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 11 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/include/fxcrt/fx_basic.h ('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 <algorithm> 7 #include <algorithm>
8 #include <cctype> 8 #include <cctype>
9 #include <cwctype> 9 #include <cwctype>
10 #include <memory> 10 #include <memory>
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 #define TEXT_LINEFEED_CHAR L'\n' 104 #define TEXT_LINEFEED_CHAR L'\n'
105 #define TEXT_RETURN_CHAR L'\r' 105 #define TEXT_RETURN_CHAR L'\r'
106 #define TEXT_EMPTY L"" 106 #define TEXT_EMPTY L""
107 #define TEXT_BLANK L" " 107 #define TEXT_BLANK L" "
108 #define TEXT_RETURN_LINEFEED L"\r\n" 108 #define TEXT_RETURN_LINEFEED L"\r\n"
109 #define TEXT_LINEFEED L"\n" 109 #define TEXT_LINEFEED L"\n"
110 #define TEXT_CHARRATIO_GAPDELTA 0.070 110 #define TEXT_CHARRATIO_GAPDELTA 0.070
111 111
112 CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, int flags) 112 CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, int flags)
113 : m_pPage(pPage), 113 : m_pPage(pPage),
114 m_charList(512),
115 m_TempCharList(50),
116 m_parserflag(flags), 114 m_parserflag(flags),
117 m_pPreTextObj(nullptr), 115 m_pPreTextObj(nullptr),
118 m_bIsParsed(false), 116 m_bIsParsed(false),
119 m_TextlineDir(-1), 117 m_TextlineDir(-1),
120 m_CurlineRect(0, 0, 0, 0) { 118 m_CurlineRect(0, 0, 0, 0) {
121 m_TextBuf.EstimateSize(0, 10240); 119 m_TextBuf.EstimateSize(0, 10240);
122 pPage->GetDisplayMatrix(m_DisplayMatrix, 0, 0, (int)pPage->GetPageWidth(), 120 pPage->GetDisplayMatrix(m_DisplayMatrix, 0, 0, (int)pPage->GetPageWidth(),
123 (int)pPage->GetPageHeight(), 0); 121 (int)pPage->GetPageHeight(), 0);
124 } 122 }
125 123
(...skipping 14 matching lines...) Expand all
140 default: 138 default:
141 return false; 139 return false;
142 } 140 }
143 } 141 }
144 FX_BOOL CPDF_TextPage::ParseTextPage() { 142 FX_BOOL CPDF_TextPage::ParseTextPage() {
145 m_bIsParsed = false; 143 m_bIsParsed = false;
146 if (!m_pPage) 144 if (!m_pPage)
147 return FALSE; 145 return FALSE;
148 146
149 m_TextBuf.Clear(); 147 m_TextBuf.Clear();
150 m_charList.RemoveAll(); 148 m_CharList.clear();
151 m_pPreTextObj = NULL; 149 m_pPreTextObj = NULL;
152 ProcessObject(); 150 ProcessObject();
153 m_bIsParsed = true; 151 m_bIsParsed = true;
154 if (!m_ParseOptions.m_bGetCharCodeOnly) { 152 if (!m_ParseOptions.m_bGetCharCodeOnly) {
155 m_CharIndex.RemoveAll(); 153 m_CharIndex.RemoveAll();
156 int nCount = m_charList.GetSize(); 154 int nCount = m_CharList.size();
157 if (nCount) { 155 if (nCount) {
158 m_CharIndex.Add(0); 156 m_CharIndex.Add(0);
159 } 157 }
160 for (int i = 0; i < nCount; i++) { 158 for (int i = 0; i < nCount; i++) {
161 int indexSize = m_CharIndex.GetSize(); 159 int indexSize = m_CharIndex.GetSize();
162 FX_BOOL bNormal = FALSE; 160 FX_BOOL bNormal = FALSE;
163 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(i); 161 PAGECHAR_INFO charinfo = m_CharList[i];
164 if (charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) { 162 if (charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) {
165 bNormal = TRUE; 163 bNormal = TRUE;
166 } else if (charinfo.m_Unicode == 0 || IsControlChar(charinfo)) { 164 } else if (charinfo.m_Unicode == 0 || IsControlChar(charinfo)) {
167 bNormal = FALSE; 165 bNormal = FALSE;
168 } else { 166 } else {
169 bNormal = TRUE; 167 bNormal = TRUE;
170 } 168 }
171 if (bNormal) { 169 if (bNormal) {
172 if (indexSize % 2) { 170 if (indexSize % 2) {
173 m_CharIndex.Add(1); 171 m_CharIndex.Add(1);
174 } else { 172 } else {
175 if (indexSize <= 0) { 173 if (indexSize <= 0) {
176 continue; 174 continue;
177 } 175 }
178 m_CharIndex.SetAt(indexSize - 1, 176 m_CharIndex.SetAt(indexSize - 1,
179 m_CharIndex.GetAt(indexSize - 1) + 1); 177 m_CharIndex.GetAt(indexSize - 1) + 1);
180 } 178 }
181 } else { 179 } else {
182 if (indexSize % 2) { 180 if (indexSize % 2) {
183 if (indexSize <= 0) { 181 if (indexSize <= 0) {
184 continue; 182 continue;
185 } 183 }
186 m_CharIndex.SetAt(indexSize - 1, i + 1); 184 m_CharIndex.SetAt(indexSize - 1, i + 1);
Tom Sepez 2016/01/22 20:52:05 For instance, m_CharIndex is a "word array" (array
187 } else { 185 } else {
188 m_CharIndex.Add(i + 1); 186 m_CharIndex.Add(i + 1);
189 } 187 }
190 } 188 }
191 } 189 }
192 int indexSize = m_CharIndex.GetSize(); 190 int indexSize = m_CharIndex.GetSize();
193 if (indexSize % 2) { 191 if (indexSize % 2) {
194 m_CharIndex.RemoveAt(indexSize - 1); 192 m_CharIndex.RemoveAt(indexSize - 1);
195 } 193 }
196 } 194 }
197 return TRUE; 195 return TRUE;
198 } 196 }
199 int CPDF_TextPage::CountChars() const { 197 int CPDF_TextPage::CountChars() const {
200 if (m_ParseOptions.m_bGetCharCodeOnly) { 198 if (m_ParseOptions.m_bGetCharCodeOnly) {
201 return m_TextBuf.GetSize(); 199 return m_TextBuf.GetSize();
202 } 200 }
203 return m_charList.GetSize(); 201 return m_CharList.size();
204 } 202 }
205 int CPDF_TextPage::CharIndexFromTextIndex(int TextIndex) const { 203 int CPDF_TextPage::CharIndexFromTextIndex(int TextIndex) const {
206 int indexSize = m_CharIndex.GetSize(); 204 int indexSize = m_CharIndex.GetSize();
207 int count = 0; 205 int count = 0;
208 for (int i = 0; i < indexSize; i += 2) { 206 for (int i = 0; i < indexSize; i += 2) {
209 count += m_CharIndex.GetAt(i + 1); 207 count += m_CharIndex.GetAt(i + 1);
210 if (count > TextIndex) { 208 if (count > TextIndex) {
211 return TextIndex - count + m_CharIndex.GetAt(i + 1) + 209 return TextIndex - count + m_CharIndex.GetAt(i + 1) +
212 m_CharIndex.GetAt(i); 210 m_CharIndex.GetAt(i);
213 } 211 }
(...skipping 20 matching lines...) Expand all
234 CFX_RectArray& rectArray) const { 232 CFX_RectArray& rectArray) const {
235 if (m_ParseOptions.m_bGetCharCodeOnly) { 233 if (m_ParseOptions.m_bGetCharCodeOnly) {
236 return; 234 return;
237 } 235 }
238 if (start < 0 || nCount == 0) { 236 if (start < 0 || nCount == 0) {
239 return; 237 return;
240 } 238 }
241 if (!m_bIsParsed) { 239 if (!m_bIsParsed) {
242 return; 240 return;
243 } 241 }
244 PAGECHAR_INFO info_curchar;
245 CPDF_TextObject* pCurObj = NULL; 242 CPDF_TextObject* pCurObj = NULL;
246 CFX_FloatRect rect; 243 CFX_FloatRect rect;
247 int curPos = start; 244 int curPos = start;
248 FX_BOOL flagNewRect = TRUE; 245 FX_BOOL flagNewRect = TRUE;
249 if (nCount + start > m_charList.GetSize() || nCount == -1) { 246 if (nCount + start > m_CharList.size() || nCount == -1) {
250 nCount = m_charList.GetSize() - start; 247 nCount = m_CharList.size() - start;
251 } 248 }
252 while (nCount--) { 249 while (nCount--) {
253 info_curchar = *(PAGECHAR_INFO*)m_charList.GetAt(curPos++); 250 PAGECHAR_INFO info_curchar = m_CharList[curPos++];
254 if (info_curchar.m_Flag == FPDFTEXT_CHAR_GENERATED) { 251 if (info_curchar.m_Flag == FPDFTEXT_CHAR_GENERATED) {
255 continue; 252 continue;
256 } 253 }
257 if (info_curchar.m_CharBox.Width() < 0.01 || 254 if (info_curchar.m_CharBox.Width() < 0.01 ||
258 info_curchar.m_CharBox.Height() < 0.01) { 255 info_curchar.m_CharBox.Height() < 0.01) {
259 continue; 256 continue;
260 } 257 }
261 if (!pCurObj) { 258 if (!pCurObj) {
262 pCurObj = info_curchar.m_pTextObj; 259 pCurObj = info_curchar.m_pTextObj;
263 } 260 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 317 }
321 int CPDF_TextPage::GetIndexAtPos(CPDF_Point point, 318 int CPDF_TextPage::GetIndexAtPos(CPDF_Point point,
322 FX_FLOAT xTolerance, 319 FX_FLOAT xTolerance,
323 FX_FLOAT yTolerance) const { 320 FX_FLOAT yTolerance) const {
324 if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed) 321 if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed)
325 return -3; 322 return -3;
326 323
327 int pos = 0; 324 int pos = 0;
328 int NearPos = -1; 325 int NearPos = -1;
329 double xdif = 5000, ydif = 5000; 326 double xdif = 5000, ydif = 5000;
330 while (pos < m_charList.GetSize()) { 327 while (pos < m_CharList.size()) {
331 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)(m_charList.GetAt(pos)); 328 PAGECHAR_INFO charinfo = m_CharList[pos];
332 CFX_FloatRect charrect = charinfo.m_CharBox; 329 CFX_FloatRect charrect = charinfo.m_CharBox;
333 if (charrect.Contains(point.x, point.y)) { 330 if (charrect.Contains(point.x, point.y)) {
334 break; 331 break;
335 } 332 }
336 if (xTolerance > 0 || yTolerance > 0) { 333 if (xTolerance > 0 || yTolerance > 0) {
337 CFX_FloatRect charRectExt; 334 CFX_FloatRect charRectExt;
338 charrect.Normalize(); 335 charrect.Normalize();
339 charRectExt.left = charrect.left - xTolerance / 2; 336 charRectExt.left = charrect.left - xTolerance / 2;
340 charRectExt.right = charrect.right + xTolerance / 2; 337 charRectExt.right = charrect.right + xTolerance / 2;
341 charRectExt.top = charrect.top + yTolerance / 2; 338 charRectExt.top = charrect.top + yTolerance / 2;
(...skipping 10 matching lines...) Expand all
352 : FXSYS_fabs(point.y - charrect.top); 349 : FXSYS_fabs(point.y - charrect.top);
353 if (curYdif + curXdif < xdif + ydif) { 350 if (curYdif + curXdif < xdif + ydif) {
354 ydif = curYdif; 351 ydif = curYdif;
355 xdif = curXdif; 352 xdif = curXdif;
356 NearPos = pos; 353 NearPos = pos;
357 } 354 }
358 } 355 }
359 } 356 }
360 ++pos; 357 ++pos;
361 } 358 }
362 if (pos >= m_charList.GetSize()) { 359 if (pos >= m_CharList.size()) {
363 pos = NearPos; 360 pos = NearPos;
364 } 361 }
365 return pos; 362 return pos;
366 } 363 }
367 CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const { 364 CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const {
368 CFX_WideString strText; 365 CFX_WideString strText;
369 if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed) 366 if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed)
370 return strText; 367 return strText;
371 368
372 int nCount = m_charList.GetSize(); 369 int nCount = m_CharList.size();
Oliver Chang 2016/01/22 20:17:56 could we change this to a size_t?
373 int pos = 0; 370 int pos = 0;
374 FX_FLOAT posy = 0; 371 FX_FLOAT posy = 0;
375 FX_BOOL IsContainPreChar = FALSE; 372 FX_BOOL IsContainPreChar = FALSE;
376 FX_BOOL ISAddLineFeed = FALSE; 373 FX_BOOL ISAddLineFeed = FALSE;
377 while (pos < nCount) { 374 while (pos < nCount) {
378 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(pos++); 375 PAGECHAR_INFO charinfo = m_CharList[pos++];
379 if (IsRectIntersect(rect, charinfo.m_CharBox)) { 376 if (IsRectIntersect(rect, charinfo.m_CharBox)) {
380 if (FXSYS_fabs(posy - charinfo.m_OriginY) > 0 && !IsContainPreChar && 377 if (FXSYS_fabs(posy - charinfo.m_OriginY) > 0 && !IsContainPreChar &&
381 ISAddLineFeed) { 378 ISAddLineFeed) {
382 posy = charinfo.m_OriginY; 379 posy = charinfo.m_OriginY;
383 if (strText.GetLength() > 0) { 380 if (strText.GetLength() > 0) {
384 strText += L"\r\n"; 381 strText += L"\r\n";
385 } 382 }
386 } 383 }
387 IsContainPreChar = TRUE; 384 IsContainPreChar = TRUE;
388 ISAddLineFeed = FALSE; 385 ISAddLineFeed = FALSE;
(...skipping 14 matching lines...) Expand all
403 return strText; 400 return strText;
404 } 401 }
405 void CPDF_TextPage::GetRectsArrayByRect(const CFX_FloatRect& rect, 402 void CPDF_TextPage::GetRectsArrayByRect(const CFX_FloatRect& rect,
406 CFX_RectArray& resRectArray) const { 403 CFX_RectArray& resRectArray) const {
407 if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed) 404 if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed)
408 return; 405 return;
409 406
410 CFX_FloatRect curRect; 407 CFX_FloatRect curRect;
411 FX_BOOL flagNewRect = TRUE; 408 FX_BOOL flagNewRect = TRUE;
412 CPDF_TextObject* pCurObj = NULL; 409 CPDF_TextObject* pCurObj = NULL;
413 int nCount = m_charList.GetSize(); 410 int nCount = m_CharList.size();
Oliver Chang 2016/01/22 20:17:56 ditto, many more instances in this file.
414 int pos = 0; 411 int pos = 0;
415 while (pos < nCount) { 412 while (pos < nCount) {
416 PAGECHAR_INFO info_curchar = *(PAGECHAR_INFO*)m_charList.GetAt(pos++); 413 PAGECHAR_INFO info_curchar = m_CharList[pos++];
417 if (info_curchar.m_Flag == FPDFTEXT_CHAR_GENERATED) { 414 if (info_curchar.m_Flag == FPDFTEXT_CHAR_GENERATED) {
418 continue; 415 continue;
419 } 416 }
420 if (IsRectIntersect(rect, info_curchar.m_CharBox)) { 417 if (IsRectIntersect(rect, info_curchar.m_CharBox)) {
421 if (!pCurObj) { 418 if (!pCurObj) {
422 pCurObj = info_curchar.m_pTextObj; 419 pCurObj = info_curchar.m_pTextObj;
423 } 420 }
424 if (pCurObj != info_curchar.m_pTextObj) { 421 if (pCurObj != info_curchar.m_pTextObj) {
425 resRectArray.Add(curRect); 422 resRectArray.Add(curRect);
426 pCurObj = info_curchar.m_pTextObj; 423 pCurObj = info_curchar.m_pTextObj;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 return -3; 455 return -3;
459 } 456 }
460 CPDF_Point point(x, y); 457 CPDF_Point point(x, y);
461 return GetIndexAtPos(point, xTolerance, yTolerance); 458 return GetIndexAtPos(point, xTolerance, yTolerance);
462 } 459 }
463 460
464 void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO* info) const { 461 void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO* info) const {
465 if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed) 462 if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed)
466 return; 463 return;
467 464
468 if (index < 0 || index >= m_charList.GetSize()) 465 if (index < 0 || index >= m_CharList.size())
469 return; 466 return;
470 467
471 const PAGECHAR_INFO* charinfo = 468 const PAGECHAR_INFO* charinfo = &m_CharList[index];
472 static_cast<PAGECHAR_INFO*>(m_charList.GetAt(index));
473 info->m_Charcode = charinfo->m_CharCode; 469 info->m_Charcode = charinfo->m_CharCode;
474 info->m_OriginX = charinfo->m_OriginX; 470 info->m_OriginX = charinfo->m_OriginX;
475 info->m_OriginY = charinfo->m_OriginY; 471 info->m_OriginY = charinfo->m_OriginY;
476 info->m_Unicode = charinfo->m_Unicode; 472 info->m_Unicode = charinfo->m_Unicode;
477 info->m_Flag = charinfo->m_Flag; 473 info->m_Flag = charinfo->m_Flag;
478 info->m_CharBox = charinfo->m_CharBox; 474 info->m_CharBox = charinfo->m_CharBox;
479 info->m_pTextObj = charinfo->m_pTextObj; 475 info->m_pTextObj = charinfo->m_pTextObj;
480 if (charinfo->m_pTextObj && charinfo->m_pTextObj->GetFont()) { 476 if (charinfo->m_pTextObj && charinfo->m_pTextObj->GetFont()) {
481 info->m_FontSize = charinfo->m_pTextObj->GetFontSize(); 477 info->m_FontSize = charinfo->m_pTextObj->GetFontSize();
482 } else { 478 } else {
483 info->m_FontSize = kDefaultFontSize; 479 info->m_FontSize = kDefaultFontSize;
484 } 480 }
485 info->m_Matrix.Copy(charinfo->m_Matrix); 481 info->m_Matrix.Copy(charinfo->m_Matrix);
486 } 482 }
487 483
488 void CPDF_TextPage::CheckMarkedContentObject(int32_t& start, 484 void CPDF_TextPage::CheckMarkedContentObject(int32_t& start,
489 int32_t& nCount) const { 485 int32_t& nCount) const {
490 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(start); 486 PAGECHAR_INFO charinfo = m_CharList[start];
491 PAGECHAR_INFO charinfo2 = 487 PAGECHAR_INFO charinfo2 = m_CharList[start + nCount - 1];
492 *(PAGECHAR_INFO*)m_charList.GetAt(start + nCount - 1);
493 if (FPDFTEXT_CHAR_PIECE != charinfo.m_Flag && 488 if (FPDFTEXT_CHAR_PIECE != charinfo.m_Flag &&
494 FPDFTEXT_CHAR_PIECE != charinfo2.m_Flag) { 489 FPDFTEXT_CHAR_PIECE != charinfo2.m_Flag) {
495 return; 490 return;
496 } 491 }
497 if (FPDFTEXT_CHAR_PIECE == charinfo.m_Flag) { 492 if (FPDFTEXT_CHAR_PIECE == charinfo.m_Flag) {
498 PAGECHAR_INFO charinfo1 = charinfo; 493 PAGECHAR_INFO charinfo1 = charinfo;
499 int startIndex = start; 494 int startIndex = start;
500 while (FPDFTEXT_CHAR_PIECE == charinfo1.m_Flag && 495 while (FPDFTEXT_CHAR_PIECE == charinfo1.m_Flag &&
501 charinfo1.m_Index == charinfo.m_Index) { 496 charinfo1.m_Index == charinfo.m_Index) {
502 startIndex--; 497 startIndex--;
503 if (startIndex < 0) { 498 if (startIndex < 0) {
504 break; 499 break;
505 } 500 }
506 charinfo1 = *(PAGECHAR_INFO*)m_charList.GetAt(startIndex); 501 charinfo1 = m_CharList[startIndex];
507 } 502 }
508 startIndex++; 503 startIndex++;
509 start = startIndex; 504 start = startIndex;
510 } 505 }
511 if (FPDFTEXT_CHAR_PIECE == charinfo2.m_Flag) { 506 if (FPDFTEXT_CHAR_PIECE == charinfo2.m_Flag) {
512 PAGECHAR_INFO charinfo3 = charinfo2; 507 PAGECHAR_INFO charinfo3 = charinfo2;
513 int endIndex = start + nCount - 1; 508 int endIndex = start + nCount - 1;
514 while (FPDFTEXT_CHAR_PIECE == charinfo3.m_Flag && 509 while (FPDFTEXT_CHAR_PIECE == charinfo3.m_Flag &&
515 charinfo3.m_Index == charinfo2.m_Index) { 510 charinfo3.m_Index == charinfo2.m_Index) {
516 endIndex++; 511 endIndex++;
517 if (endIndex >= m_charList.GetSize()) { 512 if (endIndex >= m_CharList.size()) {
518 break; 513 break;
519 } 514 }
520 charinfo3 = *(PAGECHAR_INFO*)m_charList.GetAt(endIndex); 515 charinfo3 = m_CharList[endIndex];
521 } 516 }
522 endIndex--; 517 endIndex--;
523 nCount = endIndex - start + 1; 518 nCount = endIndex - start + 1;
524 } 519 }
525 } 520 }
526 CFX_WideString CPDF_TextPage::GetPageText(int start, int nCount) const { 521 CFX_WideString CPDF_TextPage::GetPageText(int start, int nCount) const {
527 if (!m_bIsParsed || nCount == 0) 522 if (!m_bIsParsed || nCount == 0)
528 return L""; 523 return L"";
529 524
530 if (start < 0) 525 if (start < 0)
531 start = 0; 526 start = 0;
532 527
533 if (nCount == -1) { 528 if (nCount == -1) {
534 nCount = m_charList.GetSize() - start; 529 nCount = m_CharList.size() - start;
535 return m_TextBuf.GetWideString().Mid(start, 530 return m_TextBuf.GetWideString().Mid(start,
536 m_TextBuf.GetWideString().GetLength()); 531 m_TextBuf.GetWideString().GetLength());
537 } 532 }
538 if (nCount <= 0 || m_charList.GetSize() <= 0) { 533 if (nCount <= 0 || m_CharList.empty()) {
539 return L""; 534 return L"";
540 } 535 }
541 if (nCount + start > m_charList.GetSize() - 1) { 536 if (nCount + start > static_cast<int>(m_CharList.size()) - 1) {
542 nCount = m_charList.GetSize() - start; 537 nCount = static_cast<int>(m_CharList.size()) - start;
543 } 538 }
544 if (nCount <= 0) { 539 if (nCount <= 0) {
545 return L""; 540 return L"";
546 } 541 }
547 CheckMarkedContentObject(start, nCount); 542 CheckMarkedContentObject(start, nCount);
548 int startindex = 0; 543 int startindex = 0;
549 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(start); 544 PAGECHAR_INFO charinfo = m_CharList[start];
550 int startOffset = 0; 545 int startOffset = 0;
551 while (charinfo.m_Index == -1) { 546 while (charinfo.m_Index == -1) {
552 startOffset++; 547 startOffset++;
553 if (startOffset > nCount || start + startOffset >= m_charList.GetSize()) { 548 if (startOffset > nCount || start + startOffset >= m_CharList.size()) {
554 return L""; 549 return L"";
555 } 550 }
556 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(start + startOffset); 551 charinfo = m_CharList[start + startOffset];
557 } 552 }
558 startindex = charinfo.m_Index; 553 startindex = charinfo.m_Index;
559 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(start + nCount - 1); 554 charinfo = m_CharList[start + nCount - 1];
560 int nCountOffset = 0; 555 int nCountOffset = 0;
561 while (charinfo.m_Index == -1) { 556 while (charinfo.m_Index == -1) {
562 nCountOffset++; 557 nCountOffset++;
563 if (nCountOffset >= nCount) { 558 if (nCountOffset >= nCount) {
564 return L""; 559 return L"";
565 } 560 }
566 charinfo = 561 charinfo = m_CharList[start + nCount - nCountOffset - 1];
567 *(PAGECHAR_INFO*)m_charList.GetAt(start + nCount - nCountOffset - 1);
568 } 562 }
569 nCount = start + nCount - nCountOffset - startindex; 563 nCount = start + nCount - nCountOffset - startindex;
570 if (nCount <= 0) { 564 if (nCount <= 0) {
571 return L""; 565 return L"";
572 } 566 }
573 return m_TextBuf.GetWideString().Mid(startindex, nCount); 567 return m_TextBuf.GetWideString().Mid(startindex, nCount);
574 } 568 }
575 int CPDF_TextPage::CountRects(int start, int nCount) { 569 int CPDF_TextPage::CountRects(int start, int nCount) {
576 if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed || start < 0) 570 if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed || start < 0)
577 return -1; 571 return -1;
578 572
579 if (nCount == -1 || nCount + start > m_charList.GetSize()) { 573 if (nCount == -1 || nCount + start > static_cast<int>(m_CharList.size())) {
580 nCount = m_charList.GetSize() - start; 574 nCount = static_cast<int>(m_CharList.size()) - start;
581 } 575 }
582 m_SelRects.RemoveAll(); 576 m_SelRects.RemoveAll();
583 GetRectArray(start, nCount, m_SelRects); 577 GetRectArray(start, nCount, m_SelRects);
584 return m_SelRects.GetSize(); 578 return m_SelRects.GetSize();
585 } 579 }
586 void CPDF_TextPage::GetRect(int rectIndex, 580 void CPDF_TextPage::GetRect(int rectIndex,
587 FX_FLOAT& left, 581 FX_FLOAT& left,
588 FX_FLOAT& top, 582 FX_FLOAT& top,
589 FX_FLOAT& right, 583 FX_FLOAT& right,
590 FX_FLOAT& bottom) const { 584 FX_FLOAT& bottom) const {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 return GetBaselineRotate(rect, Rotate); 665 return GetBaselineRotate(rect, Rotate);
672 } 666 }
673 int CPDF_TextPage::CountBoundedSegments(FX_FLOAT left, 667 int CPDF_TextPage::CountBoundedSegments(FX_FLOAT left,
674 FX_FLOAT top, 668 FX_FLOAT top,
675 FX_FLOAT right, 669 FX_FLOAT right,
676 FX_FLOAT bottom, 670 FX_FLOAT bottom,
677 FX_BOOL bContains) { 671 FX_BOOL bContains) {
678 if (m_ParseOptions.m_bGetCharCodeOnly) 672 if (m_ParseOptions.m_bGetCharCodeOnly)
679 return -1; 673 return -1;
680 674
681 m_Segment.RemoveAll(); 675 m_Segments.RemoveAll();
682 if (!m_bIsParsed) 676 if (!m_bIsParsed)
683 return -1; 677 return -1;
684 678
685 CFX_FloatRect rect(left, bottom, right, top); 679 CFX_FloatRect rect(left, bottom, right, top);
686 rect.Normalize(); 680 rect.Normalize();
687 int nCount = m_charList.GetSize(); 681 int nCount = m_CharList.size();
688 int pos = 0; 682 int pos = 0;
689 FPDF_SEGMENT segment; 683 FPDF_SEGMENT segment;
690 segment.m_Start = 0; 684 segment.m_Start = 0;
691 segment.m_nCount = 0; 685 segment.m_nCount = 0;
692 int segmentStatus = 0; 686 int segmentStatus = 0;
693 FX_BOOL IsContainPreChar = FALSE; 687 FX_BOOL IsContainPreChar = FALSE;
694 while (pos < nCount) { 688 while (pos < nCount) {
695 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(pos); 689 PAGECHAR_INFO charinfo = m_CharList[pos];
696 if (bContains && rect.Contains(charinfo.m_CharBox)) { 690 if (bContains && rect.Contains(charinfo.m_CharBox)) {
697 if (segmentStatus == 0 || segmentStatus == 2) { 691 if (segmentStatus == 0 || segmentStatus == 2) {
698 segment.m_Start = pos; 692 segment.m_Start = pos;
699 segment.m_nCount = 1; 693 segment.m_nCount = 1;
700 segmentStatus = 1; 694 segmentStatus = 1;
701 } else if (segmentStatus == 1) { 695 } else if (segmentStatus == 1) {
702 segment.m_nCount++; 696 segment.m_nCount++;
703 } 697 }
704 IsContainPreChar = TRUE; 698 IsContainPreChar = TRUE;
705 } else if (!bContains && 699 } else if (!bContains &&
(...skipping 13 matching lines...) Expand all
719 segment.m_Start = pos; 713 segment.m_Start = pos;
720 segment.m_nCount = 1; 714 segment.m_nCount = 1;
721 segmentStatus = 1; 715 segmentStatus = 1;
722 } else if (segmentStatus == 1) { 716 } else if (segmentStatus == 1) {
723 segment.m_nCount++; 717 segment.m_nCount++;
724 } 718 }
725 IsContainPreChar = FALSE; 719 IsContainPreChar = FALSE;
726 } else { 720 } else {
727 if (segmentStatus == 1) { 721 if (segmentStatus == 1) {
728 segmentStatus = 2; 722 segmentStatus = 2;
729 m_Segment.Add(segment); 723 m_Segments.Add(segment);
730 segment.m_Start = 0; 724 segment.m_Start = 0;
731 segment.m_nCount = 0; 725 segment.m_nCount = 0;
732 } 726 }
733 } 727 }
734 } else { 728 } else {
735 if (segmentStatus == 1) { 729 if (segmentStatus == 1) {
736 segmentStatus = 2; 730 segmentStatus = 2;
737 m_Segment.Add(segment); 731 m_Segments.Add(segment);
738 segment.m_Start = 0; 732 segment.m_Start = 0;
739 segment.m_nCount = 0; 733 segment.m_nCount = 0;
740 } 734 }
741 IsContainPreChar = FALSE; 735 IsContainPreChar = FALSE;
742 } 736 }
743 pos++; 737 pos++;
744 } 738 }
745 if (segmentStatus == 1) { 739 if (segmentStatus == 1) {
746 segmentStatus = 2; 740 segmentStatus = 2;
747 m_Segment.Add(segment); 741 m_Segments.Add(segment);
748 segment.m_Start = 0; 742 segment.m_Start = 0;
749 segment.m_nCount = 0; 743 segment.m_nCount = 0;
750 } 744 }
751 return m_Segment.GetSize(); 745 return m_Segments.GetSize();
752 } 746 }
753 void CPDF_TextPage::GetBoundedSegment(int index, int& start, int& count) const { 747 void CPDF_TextPage::GetBoundedSegment(int index, int& start, int& count) const {
754 if (m_ParseOptions.m_bGetCharCodeOnly) { 748 if (m_ParseOptions.m_bGetCharCodeOnly) {
755 return; 749 return;
756 } 750 }
757 if (index < 0 || index >= m_Segment.GetSize()) { 751 if (index < 0 || index >= m_Segments.GetSize()) {
758 return; 752 return;
759 } 753 }
760 start = m_Segment.GetAt(index).m_Start; 754 start = m_Segments.GetAt(index).m_Start;
761 count = m_Segment.GetAt(index).m_nCount; 755 count = m_Segments.GetAt(index).m_nCount;
762 } 756 }
763 int CPDF_TextPage::GetWordBreak(int index, int direction) const { 757 int CPDF_TextPage::GetWordBreak(int index, int direction) const {
764 if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed) 758 if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed)
765 return -1; 759 return -1;
766 760
767 if (direction != FPDFTEXT_LEFT && direction != FPDFTEXT_RIGHT) 761 if (direction != FPDFTEXT_LEFT && direction != FPDFTEXT_RIGHT)
768 return -1; 762 return -1;
769 763
770 if (index < 0 || index >= m_charList.GetSize()) 764 if (index < 0 || index >= m_CharList.size())
771 return -1; 765 return -1;
772 766
773 PAGECHAR_INFO charinfo; 767 PAGECHAR_INFO charinfo = m_CharList[index];
774 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index);
775 if (charinfo.m_Index == -1 || charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) { 768 if (charinfo.m_Index == -1 || charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) {
776 return index; 769 return index;
777 } 770 }
778 if (!IsLetter(charinfo.m_Unicode)) { 771 if (!IsLetter(charinfo.m_Unicode)) {
779 return index; 772 return index;
780 } 773 }
781 int breakPos = index; 774 int breakPos = index;
782 if (direction == FPDFTEXT_LEFT) { 775 if (direction == FPDFTEXT_LEFT) {
783 while (--breakPos > 0) { 776 while (--breakPos > 0) {
784 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); 777 if (!IsLetter(m_CharList[breakPos].m_Unicode))
785 if (!IsLetter(charinfo.m_Unicode)) { 778 break;
786 return breakPos;
787 }
788 } 779 }
789 } else if (direction == FPDFTEXT_RIGHT) { 780 } else if (direction == FPDFTEXT_RIGHT) {
790 while (++breakPos < m_charList.GetSize()) { 781 while (++breakPos < m_CharList.size()) {
791 charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); 782 if (!IsLetter(m_CharList[breakPos].m_Unicode))
792 if (!IsLetter(charinfo.m_Unicode)) { 783 break;
793 return breakPos;
794 }
795 } 784 }
796 } 785 }
797 return breakPos; 786 return breakPos;
798 } 787 }
799 int32_t CPDF_TextPage::FindTextlineFlowDirection() { 788 int32_t CPDF_TextPage::FindTextlineFlowDirection() {
800 if (!m_pPage) { 789 if (!m_pPage) {
801 return -1; 790 return -1;
802 } 791 }
803 const int32_t nPageWidth = (int32_t)((CPDF_Page*)m_pPage)->GetPageWidth(); 792 const int32_t nPageWidth = (int32_t)((CPDF_Page*)m_pPage)->GetPageWidth();
804 const int32_t nPageHeight = (int32_t)((CPDF_Page*)m_pPage)->GetPageHeight(); 793 const int32_t nPageHeight = (int32_t)((CPDF_Page*)m_pPage)->GetPageHeight();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 } 963 }
975 } 964 }
976 return w; 965 return w;
977 } 966 }
978 void CPDF_TextPage::OnPiece(CFX_BidiChar* pBidi, CFX_WideString& str) { 967 void CPDF_TextPage::OnPiece(CFX_BidiChar* pBidi, CFX_WideString& str) {
979 int32_t start, count; 968 int32_t start, count;
980 CFX_BidiChar::Direction ret = pBidi->GetBidiInfo(&start, &count); 969 CFX_BidiChar::Direction ret = pBidi->GetBidiInfo(&start, &count);
981 if (ret == CFX_BidiChar::RIGHT) { 970 if (ret == CFX_BidiChar::RIGHT) {
982 for (int i = start + count - 1; i >= start; i--) { 971 for (int i = start + count - 1; i >= start; i--) {
983 m_TextBuf.AppendChar(str.GetAt(i)); 972 m_TextBuf.AppendChar(str.GetAt(i));
984 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); 973 m_CharList.push_back(m_TempCharList[i]);
985 } 974 }
986 } else { 975 } else {
987 int end = start + count; 976 int end = start + count;
988 for (int i = start; i < end; i++) { 977 for (int i = start; i < end; i++) {
989 m_TextBuf.AppendChar(str.GetAt(i)); 978 m_TextBuf.AppendChar(str.GetAt(i));
990 m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); 979 m_CharList.push_back(m_TempCharList[i]);
991 } 980 }
992 } 981 }
993 } 982 }
994 void CPDF_TextPage::AddCharInfoByLRDirection(CFX_WideString& str, int i) { 983 void CPDF_TextPage::AddCharInfoByLRDirection(CFX_WideString& str, int i) {
995 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); 984 PAGECHAR_INFO Info = m_TempCharList[i];
996 FX_WCHAR wChar = str.GetAt(i); 985 FX_WCHAR wChar = str.GetAt(i);
997 if (!IsControlChar(Info)) { 986 if (!IsControlChar(Info)) {
998 Info.m_Index = m_TextBuf.GetLength(); 987 Info.m_Index = m_TextBuf.GetLength();
999 if (wChar >= 0xFB00 && wChar <= 0xFB06) { 988 if (wChar >= 0xFB00 && wChar <= 0xFB06) {
1000 FX_WCHAR* pDst = NULL; 989 FX_WCHAR* pDst = NULL;
1001 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); 990 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst);
1002 if (nCount >= 1) { 991 if (nCount >= 1) {
1003 pDst = FX_Alloc(FX_WCHAR, nCount); 992 pDst = FX_Alloc(FX_WCHAR, nCount);
1004 FX_Unicode_GetNormalization(wChar, pDst); 993 FX_Unicode_GetNormalization(wChar, pDst);
1005 for (int nIndex = 0; nIndex < nCount; nIndex++) { 994 for (int nIndex = 0; nIndex < nCount; nIndex++) {
1006 PAGECHAR_INFO Info2 = Info; 995 PAGECHAR_INFO Info2 = Info;
1007 Info2.m_Unicode = pDst[nIndex]; 996 Info2.m_Unicode = pDst[nIndex];
1008 Info2.m_Flag = FPDFTEXT_CHAR_PIECE; 997 Info2.m_Flag = FPDFTEXT_CHAR_PIECE;
1009 m_TextBuf.AppendChar(Info2.m_Unicode); 998 m_TextBuf.AppendChar(Info2.m_Unicode);
1010 if (!m_ParseOptions.m_bGetCharCodeOnly) { 999 if (!m_ParseOptions.m_bGetCharCodeOnly) {
1011 m_charList.Add(Info2); 1000 m_CharList.push_back(Info2);
1012 } 1001 }
1013 } 1002 }
1014 FX_Free(pDst); 1003 FX_Free(pDst);
1015 return; 1004 return;
1016 } 1005 }
1017 } 1006 }
1018 m_TextBuf.AppendChar(wChar); 1007 m_TextBuf.AppendChar(wChar);
1019 } else { 1008 } else {
1020 Info.m_Index = -1; 1009 Info.m_Index = -1;
1021 } 1010 }
1022 if (!m_ParseOptions.m_bGetCharCodeOnly) { 1011 if (!m_ParseOptions.m_bGetCharCodeOnly) {
1023 m_charList.Add(Info); 1012 m_CharList.push_back(Info);
1024 } 1013 }
1025 } 1014 }
1026 void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) { 1015 void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) {
1027 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); 1016 PAGECHAR_INFO Info = m_TempCharList[i];
1028 if (!IsControlChar(Info)) { 1017 if (!IsControlChar(Info)) {
1029 Info.m_Index = m_TextBuf.GetLength(); 1018 Info.m_Index = m_TextBuf.GetLength();
1030 FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE); 1019 FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE);
1031 FX_WCHAR* pDst = NULL; 1020 FX_WCHAR* pDst = NULL;
1032 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); 1021 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst);
1033 if (nCount >= 1) { 1022 if (nCount >= 1) {
1034 pDst = FX_Alloc(FX_WCHAR, nCount); 1023 pDst = FX_Alloc(FX_WCHAR, nCount);
1035 FX_Unicode_GetNormalization(wChar, pDst); 1024 FX_Unicode_GetNormalization(wChar, pDst);
1036 for (int nIndex = 0; nIndex < nCount; nIndex++) { 1025 for (int nIndex = 0; nIndex < nCount; nIndex++) {
1037 PAGECHAR_INFO Info2 = Info; 1026 PAGECHAR_INFO Info2 = Info;
1038 Info2.m_Unicode = pDst[nIndex]; 1027 Info2.m_Unicode = pDst[nIndex];
1039 Info2.m_Flag = FPDFTEXT_CHAR_PIECE; 1028 Info2.m_Flag = FPDFTEXT_CHAR_PIECE;
1040 m_TextBuf.AppendChar(Info2.m_Unicode); 1029 m_TextBuf.AppendChar(Info2.m_Unicode);
1041 if (!m_ParseOptions.m_bGetCharCodeOnly) { 1030 if (!m_ParseOptions.m_bGetCharCodeOnly) {
1042 m_charList.Add(Info2); 1031 m_CharList.push_back(Info2);
1043 } 1032 }
1044 } 1033 }
1045 FX_Free(pDst); 1034 FX_Free(pDst);
1046 return; 1035 return;
1047 } 1036 }
1048 Info.m_Unicode = wChar; 1037 Info.m_Unicode = wChar;
1049 m_TextBuf.AppendChar(Info.m_Unicode); 1038 m_TextBuf.AppendChar(Info.m_Unicode);
1050 } else { 1039 } else {
1051 Info.m_Index = -1; 1040 Info.m_Index = -1;
1052 } 1041 }
1053 if (!m_ParseOptions.m_bGetCharCodeOnly) { 1042 if (!m_ParseOptions.m_bGetCharCodeOnly) {
1054 m_charList.Add(Info); 1043 m_CharList.push_back(Info);
1055 } 1044 }
1056 } 1045 }
1057 void CPDF_TextPage::CloseTempLine() { 1046 void CPDF_TextPage::CloseTempLine() {
1058 int count1 = m_TempCharList.GetSize(); 1047 int count1 = m_TempCharList.size();
1059 if (count1 <= 0) { 1048 if (count1 <= 0) {
1060 return; 1049 return;
1061 } 1050 }
1062 std::unique_ptr<CFX_BidiChar> pBidiChar(new CFX_BidiChar); 1051 std::unique_ptr<CFX_BidiChar> pBidiChar(new CFX_BidiChar);
1063 CFX_WideString str = m_TempTextBuf.GetWideString(); 1052 CFX_WideString str = m_TempTextBuf.GetWideString();
1064 CFX_WordArray order; 1053 CFX_WordArray order;
1065 FX_BOOL bR2L = FALSE; 1054 FX_BOOL bR2L = FALSE;
1066 int32_t start = 0, count = 0; 1055 int32_t start = 0, count = 0;
1067 int nR2L = 0, nL2R = 0; 1056 int nR2L = 0, nL2R = 0;
1068 FX_BOOL bPrevSpace = FALSE; 1057 FX_BOOL bPrevSpace = FALSE;
1069 for (int i = 0; i < str.GetLength(); i++) { 1058 for (int i = 0; i < str.GetLength(); i++) {
1070 if (str.GetAt(i) == 32) { 1059 if (str.GetAt(i) == 32) {
1071 if (bPrevSpace) { 1060 if (bPrevSpace) {
1072 m_TempTextBuf.Delete(i, 1); 1061 m_TempTextBuf.Delete(i, 1);
1073 m_TempCharList.Delete(i); 1062 m_TempCharList.erase(m_TempCharList.begin() + i);
1074 str.Delete(i); 1063 str.Delete(i);
1075 count1--; 1064 count1--;
1076 i--; 1065 i--;
1077 continue; 1066 continue;
1078 } 1067 }
1079 bPrevSpace = TRUE; 1068 bPrevSpace = TRUE;
1080 } else { 1069 } else {
1081 bPrevSpace = FALSE; 1070 bPrevSpace = FALSE;
1082 } 1071 }
1083 if (pBidiChar->AppendChar(str.GetAt(i))) { 1072 if (pBidiChar->AppendChar(str.GetAt(i))) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 break; 1155 break;
1167 } else { 1156 } else {
1168 j += 3; 1157 j += 3;
1169 } 1158 }
1170 } 1159 }
1171 if (j == 3) { 1160 if (j == 3) {
1172 i = -3; 1161 i = -3;
1173 bL2R = TRUE; 1162 bL2R = TRUE;
1174 continue; 1163 continue;
1175 } 1164 }
1176 int end = m_TempCharList.GetSize() - 1; 1165 int end = m_TempCharList.size() - 1;
1177 if (j < count) { 1166 if (j < count) {
1178 end = order.GetAt(j) - 1; 1167 end = order.GetAt(j) - 1;
1179 } 1168 }
1180 i = j - 3; 1169 i = j - 3;
1181 for (int n = end; n >= start; n--) { 1170 for (int n = end; n >= start; n--) {
1182 AddCharInfoByRLDirection(str, n); 1171 AddCharInfoByRLDirection(str, n);
1183 } 1172 }
1184 } else { 1173 } else {
1185 int end = start + count1; 1174 int end = start + count1;
1186 for (int n = start; n < end; n++) { 1175 for (int n = start; n < end; n++) {
1187 AddCharInfoByLRDirection(str, n); 1176 AddCharInfoByLRDirection(str, n);
1188 } 1177 }
1189 } 1178 }
1190 } 1179 }
1191 } 1180 }
1192 order.RemoveAll(); 1181 order.RemoveAll();
1193 m_TempCharList.RemoveAll(); 1182 m_TempCharList.clear();
1194 m_TempTextBuf.Delete(0, m_TempTextBuf.GetLength()); 1183 m_TempTextBuf.Delete(0, m_TempTextBuf.GetLength());
1195 } 1184 }
1196 void CPDF_TextPage::ProcessTextObject(CPDF_TextObject* pTextObj, 1185 void CPDF_TextPage::ProcessTextObject(CPDF_TextObject* pTextObj,
1197 const CFX_Matrix& formMatrix, 1186 const CFX_Matrix& formMatrix,
1198 FX_POSITION ObjPos) { 1187 FX_POSITION ObjPos) {
1199 CFX_FloatRect re(pTextObj->m_Left, pTextObj->m_Bottom, pTextObj->m_Right, 1188 CFX_FloatRect re(pTextObj->m_Left, pTextObj->m_Bottom, pTextObj->m_Right,
1200 pTextObj->m_Top); 1189 pTextObj->m_Top);
1201 if (FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f) { 1190 if (FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f) {
1202 return; 1191 return;
1203 } 1192 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 charinfo.m_Unicode = wChar; 1392 charinfo.m_Unicode = wChar;
1404 charinfo.m_CharCode = pFont->CharCodeFromUnicode(wChar); 1393 charinfo.m_CharCode = pFont->CharCodeFromUnicode(wChar);
1405 charinfo.m_Flag = FPDFTEXT_CHAR_PIECE; 1394 charinfo.m_Flag = FPDFTEXT_CHAR_PIECE;
1406 charinfo.m_pTextObj = pTextObj; 1395 charinfo.m_pTextObj = pTextObj;
1407 charinfo.m_CharBox.top = charBox.top; 1396 charinfo.m_CharBox.top = charBox.top;
1408 charinfo.m_CharBox.left = charBox.left; 1397 charinfo.m_CharBox.left = charBox.left;
1409 charinfo.m_CharBox.right = charBox.right; 1398 charinfo.m_CharBox.right = charBox.right;
1410 charinfo.m_CharBox.bottom = charBox.bottom; 1399 charinfo.m_CharBox.bottom = charBox.bottom;
1411 charinfo.m_Matrix.Copy(matrix); 1400 charinfo.m_Matrix.Copy(matrix);
1412 m_TempTextBuf.AppendChar(wChar); 1401 m_TempTextBuf.AppendChar(wChar);
1413 m_TempCharList.Add(charinfo); 1402 m_TempCharList.push_back(charinfo);
1414 } 1403 }
1415 } 1404 }
1416 void CPDF_TextPage::FindPreviousTextObject(void) { 1405 void CPDF_TextPage::FindPreviousTextObject() {
1417 if (m_TempCharList.GetSize() < 1 && m_charList.GetSize() < 1) { 1406 if (m_TempCharList.empty() && m_CharList.empty())
1418 return; 1407 return;
1419 } 1408
1420 PAGECHAR_INFO preChar; 1409 PAGECHAR_INFO preChar =
1421 if (m_TempCharList.GetSize() >= 1) { 1410 m_TempCharList.empty() ? m_CharList.back() : m_TempCharList.back();
1422 preChar = 1411
1423 *(PAGECHAR_INFO*)m_TempCharList.GetAt(m_TempCharList.GetSize() - 1); 1412 if (preChar.m_pTextObj)
1424 } else {
1425 preChar = *(PAGECHAR_INFO*)m_charList.GetAt(m_charList.GetSize() - 1);
1426 }
1427 if (preChar.m_pTextObj) {
1428 m_pPreTextObj = preChar.m_pTextObj; 1413 m_pPreTextObj = preChar.m_pTextObj;
1429 }
1430 } 1414 }
1431 void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend, 1415 void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend,
1432 int32_t iBufStartAppend) { 1416 int32_t iBufStartAppend) {
1433 int32_t i, j; 1417 int32_t i = iCharListStartAppend;
1434 i = iCharListStartAppend; 1418 int32_t j = m_TempCharList.size() - 1;
1435 j = m_TempCharList.GetSize() - 1;
1436 for (; i < j; i++, j--) { 1419 for (; i < j; i++, j--) {
1437 std::swap(m_TempCharList[i], m_TempCharList[j]); 1420 std::swap(m_TempCharList[i], m_TempCharList[j]);
1438 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index); 1421 std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index);
1439 } 1422 }
1440 FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer(); 1423 FX_WCHAR* pTempBuffer = m_TempTextBuf.GetBuffer();
1441 i = iBufStartAppend; 1424 i = iBufStartAppend;
1442 j = m_TempTextBuf.GetLength() - 1; 1425 j = m_TempTextBuf.GetLength() - 1;
1443 for (; i < j; i++, j--) { 1426 for (; i < j; i++, j--) {
1444 std::swap(pTempBuffer[i], pTempBuffer[j]); 1427 std::swap(pTempBuffer[i], pTempBuffer[j]);
1445 } 1428 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj->m_Bottom, 1495 CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj->m_Bottom,
1513 Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top)); 1496 Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top));
1514 } 1497 }
1515 PAGECHAR_INFO generateChar; 1498 PAGECHAR_INFO generateChar;
1516 if (result == 1) { 1499 if (result == 1) {
1517 if (GenerateCharInfo(TEXT_BLANK_CHAR, generateChar)) { 1500 if (GenerateCharInfo(TEXT_BLANK_CHAR, generateChar)) {
1518 if (!formMatrix.IsIdentity()) { 1501 if (!formMatrix.IsIdentity()) {
1519 generateChar.m_Matrix.Copy(formMatrix); 1502 generateChar.m_Matrix.Copy(formMatrix);
1520 } 1503 }
1521 m_TempTextBuf.AppendChar(TEXT_BLANK_CHAR); 1504 m_TempTextBuf.AppendChar(TEXT_BLANK_CHAR);
1522 m_TempCharList.Add(generateChar); 1505 m_TempCharList.push_back(generateChar);
1523 } 1506 }
1524 } else if (result == 2) { 1507 } else if (result == 2) {
1525 CloseTempLine(); 1508 CloseTempLine();
1526 if (m_TextBuf.GetSize()) { 1509 if (m_TextBuf.GetSize()) {
1527 if (m_ParseOptions.m_bGetCharCodeOnly) { 1510 if (m_ParseOptions.m_bGetCharCodeOnly) {
1528 m_TextBuf.AppendChar(TEXT_RETURN_CHAR); 1511 m_TextBuf.AppendChar(TEXT_RETURN_CHAR);
1529 m_TextBuf.AppendChar(TEXT_LINEFEED_CHAR); 1512 m_TextBuf.AppendChar(TEXT_LINEFEED_CHAR);
1530 } else { 1513 } else {
1531 if (GenerateCharInfo(TEXT_RETURN_CHAR, generateChar)) { 1514 if (GenerateCharInfo(TEXT_RETURN_CHAR, generateChar)) {
1532 m_TextBuf.AppendChar(TEXT_RETURN_CHAR); 1515 m_TextBuf.AppendChar(TEXT_RETURN_CHAR);
1533 if (!formMatrix.IsIdentity()) { 1516 if (!formMatrix.IsIdentity()) {
1534 generateChar.m_Matrix.Copy(formMatrix); 1517 generateChar.m_Matrix.Copy(formMatrix);
1535 } 1518 }
1536 m_charList.Add(generateChar); 1519 m_CharList.push_back(generateChar);
1537 } 1520 }
1538 if (GenerateCharInfo(TEXT_LINEFEED_CHAR, generateChar)) { 1521 if (GenerateCharInfo(TEXT_LINEFEED_CHAR, generateChar)) {
1539 m_TextBuf.AppendChar(TEXT_LINEFEED_CHAR); 1522 m_TextBuf.AppendChar(TEXT_LINEFEED_CHAR);
1540 if (!formMatrix.IsIdentity()) { 1523 if (!formMatrix.IsIdentity()) {
1541 generateChar.m_Matrix.Copy(formMatrix); 1524 generateChar.m_Matrix.Copy(formMatrix);
1542 } 1525 }
1543 m_charList.Add(generateChar); 1526 m_CharList.push_back(generateChar);
1544 } 1527 }
1545 } 1528 }
1546 } 1529 }
1547 } else if (result == 3 && !m_ParseOptions.m_bOutputHyphen) { 1530 } else if (result == 3 && !m_ParseOptions.m_bOutputHyphen) {
1548 int32_t nChars = pTextObj->CountChars(); 1531 int32_t nChars = pTextObj->CountChars();
1549 if (nChars == 1) { 1532 if (nChars == 1) {
1550 CPDF_TextObjectItem item; 1533 CPDF_TextObjectItem item;
1551 pTextObj->GetCharInfo(0, &item); 1534 pTextObj->GetCharInfo(0, &item);
1552 CFX_WideString wstrItem = 1535 CFX_WideString wstrItem =
1553 pTextObj->GetFont()->UnicodeFromCharCode(item.m_CharCode); 1536 pTextObj->GetFont()->UnicodeFromCharCode(item.m_CharCode);
1554 if (wstrItem.IsEmpty()) { 1537 if (wstrItem.IsEmpty()) {
1555 wstrItem += (FX_WCHAR)item.m_CharCode; 1538 wstrItem += (FX_WCHAR)item.m_CharCode;
1556 } 1539 }
1557 FX_WCHAR curChar = wstrItem.GetAt(0); 1540 FX_WCHAR curChar = wstrItem.GetAt(0);
1558 if (0x2D == curChar || 0xAD == curChar) { 1541 if (0x2D == curChar || 0xAD == curChar) {
1559 return; 1542 return;
1560 } 1543 }
1561 } 1544 }
1562 while (m_TempTextBuf.GetSize() > 0 && 1545 while (m_TempTextBuf.GetSize() > 0 &&
1563 m_TempTextBuf.GetWideString().GetAt(m_TempTextBuf.GetLength() - 1546 m_TempTextBuf.GetWideString().GetAt(m_TempTextBuf.GetLength() -
1564 1) == 0x20) { 1547 1) == 0x20) {
1565 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); 1548 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
1566 m_TempCharList.Delete(m_TempCharList.GetSize() - 1); 1549 m_TempCharList.pop_back();
1567 } 1550 }
1568 PAGECHAR_INFO* cha = 1551 PAGECHAR_INFO* cha = &m_TempCharList[m_TempCharList.size() - 1];
1569 (PAGECHAR_INFO*)m_TempCharList.GetAt(m_TempCharList.GetSize() - 1);
1570 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); 1552 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
1571 cha->m_Unicode = 0x2; 1553 cha->m_Unicode = 0x2;
1572 cha->m_Flag = FPDFTEXT_CHAR_HYPHEN; 1554 cha->m_Flag = FPDFTEXT_CHAR_HYPHEN;
1573 m_TempTextBuf.AppendChar(0xfffe); 1555 m_TempTextBuf.AppendChar(0xfffe);
1574 } 1556 }
1575 } else { 1557 } else {
1576 m_CurlineRect = 1558 m_CurlineRect =
1577 CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj->m_Bottom, 1559 CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj->m_Bottom,
1578 Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top); 1560 Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top);
1579 } 1561 }
1580 if (FPDFTEXT_MC_DELAY == bPreMKC) { 1562 if (FPDFTEXT_MC_DELAY == bPreMKC) {
1581 ProcessMarkedContent(Obj); 1563 ProcessMarkedContent(Obj);
1582 m_pPreTextObj = pTextObj; 1564 m_pPreTextObj = pTextObj;
1583 m_perMatrix.Copy(formMatrix); 1565 m_perMatrix.Copy(formMatrix);
1584 return; 1566 return;
1585 } 1567 }
1586 m_pPreTextObj = pTextObj; 1568 m_pPreTextObj = pTextObj;
1587 m_perMatrix.Copy(formMatrix); 1569 m_perMatrix.Copy(formMatrix);
1588 int nItems = pTextObj->CountItems(); 1570 int nItems = pTextObj->CountItems();
1589 FX_FLOAT baseSpace = _CalculateBaseSpace(pTextObj, matrix); 1571 FX_FLOAT baseSpace = _CalculateBaseSpace(pTextObj, matrix);
1590 1572
1591 const FX_BOOL bR2L = IsRightToLeft(pTextObj, pFont, nItems); 1573 const FX_BOOL bR2L = IsRightToLeft(pTextObj, pFont, nItems);
1592 const FX_BOOL bIsBidiAndMirrorInverse = 1574 const FX_BOOL bIsBidiAndMirrorInverse =
1593 bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0; 1575 bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0;
1594 int32_t iBufStartAppend = m_TempTextBuf.GetLength(); 1576 int32_t iBufStartAppend = m_TempTextBuf.GetLength();
1595 int32_t iCharListStartAppend = m_TempCharList.GetSize(); 1577 int32_t iCharListStartAppend = m_TempCharList.size();
1596 1578
1597 FX_FLOAT spacing = 0; 1579 FX_FLOAT spacing = 0;
1598 for (int i = 0; i < nItems; i++) { 1580 for (int i = 0; i < nItems; i++) {
1599 CPDF_TextObjectItem item; 1581 CPDF_TextObjectItem item;
1600 PAGECHAR_INFO charinfo; 1582 PAGECHAR_INFO charinfo;
1601 charinfo.m_OriginX = 0; 1583 charinfo.m_OriginX = 0;
1602 charinfo.m_OriginY = 0; 1584 charinfo.m_OriginY = 0;
1603 pTextObj->GetItemInfo(i, &item); 1585 pTextObj->GetItemInfo(i, &item);
1604 if (item.m_CharCode == (FX_DWORD)-1) { 1586 if (item.m_CharCode == (FX_DWORD)-1) {
1605 CFX_WideString str = m_TempTextBuf.GetWideString(); 1587 CFX_WideString str = m_TempTextBuf.GetWideString();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 charinfo.m_pTextObj = pTextObj; 1629 charinfo.m_pTextObj = pTextObj;
1648 charinfo.m_Index = m_TextBuf.GetLength(); 1630 charinfo.m_Index = m_TextBuf.GetLength();
1649 m_TempTextBuf.AppendChar(TEXT_BLANK_CHAR); 1631 m_TempTextBuf.AppendChar(TEXT_BLANK_CHAR);
1650 charinfo.m_CharCode = -1; 1632 charinfo.m_CharCode = -1;
1651 charinfo.m_Matrix.Copy(formMatrix); 1633 charinfo.m_Matrix.Copy(formMatrix);
1652 matrix.Transform(item.m_OriginX, item.m_OriginY, charinfo.m_OriginX, 1634 matrix.Transform(item.m_OriginX, item.m_OriginY, charinfo.m_OriginX,
1653 charinfo.m_OriginY); 1635 charinfo.m_OriginY);
1654 charinfo.m_CharBox = 1636 charinfo.m_CharBox =
1655 CFX_FloatRect(charinfo.m_OriginX, charinfo.m_OriginY, 1637 CFX_FloatRect(charinfo.m_OriginX, charinfo.m_OriginY,
1656 charinfo.m_OriginX, charinfo.m_OriginY); 1638 charinfo.m_OriginX, charinfo.m_OriginY);
1657 m_TempCharList.Add(charinfo); 1639 m_TempCharList.push_back(charinfo);
1658 } 1640 }
1659 if (item.m_CharCode == (FX_DWORD)-1) { 1641 if (item.m_CharCode == (FX_DWORD)-1) {
1660 continue; 1642 continue;
1661 } 1643 }
1662 } 1644 }
1663 spacing = 0; 1645 spacing = 0;
1664 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode); 1646 CFX_WideString wstrItem = pFont->UnicodeFromCharCode(item.m_CharCode);
1665 FX_BOOL bNoUnicode = FALSE; 1647 FX_BOOL bNoUnicode = FALSE;
1666 FX_WCHAR wChar = wstrItem.GetAt(0); 1648 FX_WCHAR wChar = wstrItem.GetAt(0);
1667 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) { 1649 if ((wstrItem.IsEmpty() || wChar == 0) && item.m_CharCode) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 charinfo.m_CharBox.bottom + pTextObj->GetFontSize(); 1681 charinfo.m_CharBox.bottom + pTextObj->GetFontSize();
1700 } 1682 }
1701 if (fabsf(charinfo.m_CharBox.right - charinfo.m_CharBox.left) < 0.01f) { 1683 if (fabsf(charinfo.m_CharBox.right - charinfo.m_CharBox.left) < 0.01f) {
1702 charinfo.m_CharBox.right = 1684 charinfo.m_CharBox.right =
1703 charinfo.m_CharBox.left + pTextObj->GetCharWidth(charinfo.m_CharCode); 1685 charinfo.m_CharBox.left + pTextObj->GetCharWidth(charinfo.m_CharCode);
1704 } 1686 }
1705 matrix.TransformRect(charinfo.m_CharBox); 1687 matrix.TransformRect(charinfo.m_CharBox);
1706 charinfo.m_Matrix.Copy(matrix); 1688 charinfo.m_Matrix.Copy(matrix);
1707 if (wstrItem.IsEmpty()) { 1689 if (wstrItem.IsEmpty()) {
1708 charinfo.m_Unicode = 0; 1690 charinfo.m_Unicode = 0;
1709 m_TempCharList.Add(charinfo); 1691 m_TempCharList.push_back(charinfo);
1710 m_TempTextBuf.AppendChar(0xfffe); 1692 m_TempTextBuf.AppendChar(0xfffe);
1711 continue; 1693 continue;
1712 } else { 1694 } else {
1713 int nTotal = wstrItem.GetLength(); 1695 int nTotal = wstrItem.GetLength();
1714 FX_BOOL bDel = FALSE; 1696 FX_BOOL bDel = FALSE;
1715 const int count = std::min(m_TempCharList.GetSize(), 7); 1697 const int count = std::min(static_cast<int>(m_TempCharList.size()), 7);
1716 FX_FLOAT threshold = charinfo.m_Matrix.TransformXDistance( 1698 FX_FLOAT threshold = charinfo.m_Matrix.TransformXDistance(
1717 (FX_FLOAT)TEXT_CHARRATIO_GAPDELTA * pTextObj->GetFontSize()); 1699 (FX_FLOAT)TEXT_CHARRATIO_GAPDELTA * pTextObj->GetFontSize());
1718 for (int n = m_TempCharList.GetSize(); 1700 for (int n = m_TempCharList.size(); n > m_TempCharList.size() - count;
1719 n > m_TempCharList.GetSize() - count; n--) { 1701 n--) {
1720 PAGECHAR_INFO* charinfo1 = (PAGECHAR_INFO*)m_TempCharList.GetAt(n - 1); 1702 PAGECHAR_INFO* charinfo1 = &m_TempCharList[n - 1];
1721 if (charinfo1->m_CharCode == charinfo.m_CharCode && 1703 if (charinfo1->m_CharCode == charinfo.m_CharCode &&
1722 charinfo1->m_pTextObj->GetFont() == 1704 charinfo1->m_pTextObj->GetFont() ==
1723 charinfo.m_pTextObj->GetFont() && 1705 charinfo.m_pTextObj->GetFont() &&
1724 FXSYS_fabs(charinfo1->m_OriginX - charinfo.m_OriginX) < threshold && 1706 FXSYS_fabs(charinfo1->m_OriginX - charinfo.m_OriginX) < threshold &&
1725 FXSYS_fabs(charinfo1->m_OriginY - charinfo.m_OriginY) < threshold) { 1707 FXSYS_fabs(charinfo1->m_OriginY - charinfo.m_OriginY) < threshold) {
1726 bDel = TRUE; 1708 bDel = TRUE;
1727 break; 1709 break;
1728 } 1710 }
1729 } 1711 }
1730 if (!bDel) { 1712 if (!bDel) {
1731 for (int nIndex = 0; nIndex < nTotal; nIndex++) { 1713 for (int nIndex = 0; nIndex < nTotal; nIndex++) {
1732 charinfo.m_Unicode = wstrItem.GetAt(nIndex); 1714 charinfo.m_Unicode = wstrItem.GetAt(nIndex);
1733 if (charinfo.m_Unicode) { 1715 if (charinfo.m_Unicode) {
1734 charinfo.m_Index = m_TextBuf.GetLength(); 1716 charinfo.m_Index = m_TextBuf.GetLength();
1735 m_TempTextBuf.AppendChar(charinfo.m_Unicode); 1717 m_TempTextBuf.AppendChar(charinfo.m_Unicode);
1736 } else { 1718 } else {
1737 m_TempTextBuf.AppendChar(0xfffe); 1719 m_TempTextBuf.AppendChar(0xfffe);
1738 } 1720 }
1739 m_TempCharList.Add(charinfo); 1721 m_TempCharList.push_back(charinfo);
1740 } 1722 }
1741 } else if (i == 0) { 1723 } else if (i == 0) {
1742 CFX_WideString str = m_TempTextBuf.GetWideString(); 1724 CFX_WideString str = m_TempTextBuf.GetWideString();
1743 if (!str.IsEmpty() && 1725 if (!str.IsEmpty() &&
1744 str.GetAt(str.GetLength() - 1) == TEXT_BLANK_CHAR) { 1726 str.GetAt(str.GetLength() - 1) == TEXT_BLANK_CHAR) {
1745 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); 1727 m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
1746 m_TempCharList.Delete(m_TempCharList.GetSize() - 1); 1728 m_TempCharList.pop_back();
1747 } 1729 }
1748 } 1730 }
1749 } 1731 }
1750 } 1732 }
1751 if (bIsBidiAndMirrorInverse) { 1733 if (bIsBidiAndMirrorInverse) {
1752 SwapTempTextBuf(iCharListStartAppend, iBufStartAppend); 1734 SwapTempTextBuf(iCharListStartAppend, iBufStartAppend);
1753 } 1735 }
1754 } 1736 }
1755 int32_t CPDF_TextPage::GetTextObjectWritingMode( 1737 int32_t CPDF_TextPage::GetTextObjectWritingMode(
1756 const CPDF_TextObject* pTextObj) { 1738 const CPDF_TextObject* pTextObj) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 if (0x2D == wcTmp || 0xAD == wcTmp) { 1777 if (0x2D == wcTmp || 0xAD == wcTmp) {
1796 if (--nIndex > 0) { 1778 if (--nIndex > 0) {
1797 FX_WCHAR preChar = strCurText.GetAt((nIndex)); 1779 FX_WCHAR preChar = strCurText.GetAt((nIndex));
1798 if (((preChar >= L'A' && preChar <= L'Z') || 1780 if (((preChar >= L'A' && preChar <= L'Z') ||
1799 (preChar >= L'a' && preChar <= L'z')) && 1781 (preChar >= L'a' && preChar <= L'z')) &&
1800 ((curChar >= L'A' && curChar <= L'Z') || 1782 ((curChar >= L'A' && curChar <= L'Z') ||
1801 (curChar >= L'a' && curChar <= L'z'))) { 1783 (curChar >= L'a' && curChar <= L'z'))) {
1802 return TRUE; 1784 return TRUE;
1803 } 1785 }
1804 } 1786 }
1805 int size = m_TempCharList.GetSize(); 1787 int size = m_TempCharList.size();
1806 PAGECHAR_INFO preChar; 1788 PAGECHAR_INFO preChar;
1807 if (size) { 1789 if (size) {
1808 preChar = (PAGECHAR_INFO)m_TempCharList[size - 1]; 1790 preChar = m_TempCharList[size - 1];
1809 } else { 1791 } else {
1810 size = m_charList.GetSize(); 1792 size = m_CharList.size();
1811 if (size == 0) { 1793 if (size == 0) {
1812 return FALSE; 1794 return FALSE;
1813 } 1795 }
1814 preChar = (PAGECHAR_INFO)m_charList[size - 1]; 1796 preChar = m_CharList[size - 1];
1815 } 1797 }
1816 if (FPDFTEXT_CHAR_PIECE == preChar.m_Flag && 1798 if (FPDFTEXT_CHAR_PIECE == preChar.m_Flag &&
1817 (0xAD == preChar.m_Unicode || 0x2D == preChar.m_Unicode)) { 1799 (0xAD == preChar.m_Unicode || 0x2D == preChar.m_Unicode)) {
1818 return TRUE; 1800 return TRUE;
1819 } 1801 }
1820 } 1802 }
1821 return FALSE; 1803 return FALSE;
1822 } 1804 }
1823 int CPDF_TextPage::ProcessInsertObject(const CPDF_TextObject* pObj, 1805 int CPDF_TextPage::ProcessInsertObject(const CPDF_TextObject* pObj,
1824 const CFX_Matrix& formMatrix) { 1806 const CFX_Matrix& formMatrix) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 if (!pTextObj1 || !pTextObj2) { 1963 if (!pTextObj1 || !pTextObj2) {
1982 return FALSE; 1964 return FALSE;
1983 } 1965 }
1984 CFX_FloatRect rcPreObj(pTextObj2->m_Left, pTextObj2->m_Bottom, 1966 CFX_FloatRect rcPreObj(pTextObj2->m_Left, pTextObj2->m_Bottom,
1985 pTextObj2->m_Right, pTextObj2->m_Top); 1967 pTextObj2->m_Right, pTextObj2->m_Top);
1986 CFX_FloatRect rcCurObj(pTextObj1->m_Left, pTextObj1->m_Bottom, 1968 CFX_FloatRect rcCurObj(pTextObj1->m_Left, pTextObj1->m_Bottom,
1987 pTextObj1->m_Right, pTextObj1->m_Top); 1969 pTextObj1->m_Right, pTextObj1->m_Top);
1988 if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty() && 1970 if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty() &&
1989 !m_ParseOptions.m_bGetCharCodeOnly) { 1971 !m_ParseOptions.m_bGetCharCodeOnly) {
1990 FX_FLOAT dbXdif = FXSYS_fabs(rcPreObj.left - rcCurObj.left); 1972 FX_FLOAT dbXdif = FXSYS_fabs(rcPreObj.left - rcCurObj.left);
1991 int nCount = m_charList.GetSize(); 1973 int nCount = m_CharList.size();
Oliver Chang 2016/01/22 21:26:23 this can probably be just a size_t instead of bein
Tom Sepez 2016/01/22 21:41:56 Acknowledged.
1992 if (nCount >= 2) { 1974 if (nCount >= 2) {
1993 PAGECHAR_INFO perCharTemp = (PAGECHAR_INFO)m_charList[nCount - 2]; 1975 PAGECHAR_INFO perCharTemp = m_CharList[nCount - 2];
1994 FX_FLOAT dbSpace = perCharTemp.m_CharBox.Width(); 1976 FX_FLOAT dbSpace = perCharTemp.m_CharBox.Width();
1995 if (dbXdif > dbSpace) { 1977 if (dbXdif > dbSpace) {
1996 return FALSE; 1978 return FALSE;
1997 } 1979 }
1998 } 1980 }
1999 } 1981 }
2000 if (!rcPreObj.IsEmpty() || !rcCurObj.IsEmpty()) { 1982 if (!rcPreObj.IsEmpty() || !rcCurObj.IsEmpty()) {
2001 rcPreObj.Intersect(rcCurObj); 1983 rcPreObj.Intersect(rcCurObj);
2002 if (rcPreObj.IsEmpty()) { 1984 if (rcPreObj.IsEmpty()) {
2003 return FALSE; 1985 return FALSE;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2054 } 2036 }
2055 if (IsSameTextObject((CPDF_TextObject*)pObj, pTextObj)) { 2037 if (IsSameTextObject((CPDF_TextObject*)pObj, pTextObj)) {
2056 return TRUE; 2038 return TRUE;
2057 } 2039 }
2058 i++; 2040 i++;
2059 } 2041 }
2060 return FALSE; 2042 return FALSE;
2061 } 2043 }
2062 2044
2063 FX_BOOL CPDF_TextPage::GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info) { 2045 FX_BOOL CPDF_TextPage::GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info) {
2064 int size = m_TempCharList.GetSize(); 2046 int size = m_TempCharList.size();
Oliver Chang 2016/01/22 21:26:23 this one too
Tom Sepez 2016/01/22 21:41:56 Acknowledged.
2065 PAGECHAR_INFO preChar; 2047 PAGECHAR_INFO preChar;
2066 if (size) { 2048 if (size) {
2067 preChar = (PAGECHAR_INFO)m_TempCharList[size - 1]; 2049 preChar = m_TempCharList[size - 1];
2068 } else { 2050 } else {
2069 size = m_charList.GetSize(); 2051 size = m_CharList.size();
2070 if (size == 0) { 2052 if (size == 0) {
2071 return FALSE; 2053 return FALSE;
2072 } 2054 }
2073 preChar = (PAGECHAR_INFO)m_charList[size - 1]; 2055 preChar = m_CharList[size - 1];
2074 } 2056 }
2075 info.m_Index = m_TextBuf.GetLength(); 2057 info.m_Index = m_TextBuf.GetLength();
2076 info.m_Unicode = unicode; 2058 info.m_Unicode = unicode;
2077 info.m_pTextObj = NULL; 2059 info.m_pTextObj = NULL;
2078 info.m_CharCode = -1; 2060 info.m_CharCode = -1;
2079 info.m_Flag = FPDFTEXT_CHAR_GENERATED; 2061 info.m_Flag = FPDFTEXT_CHAR_GENERATED;
2080 int preWidth = 0; 2062 int preWidth = 0;
2081 if (preChar.m_pTextObj && preChar.m_CharCode != (FX_DWORD)-1) 2063 if (preChar.m_pTextObj && preChar.m_CharCode != (FX_DWORD)-1)
2082 preWidth = GetCharWidth(preChar.m_CharCode, preChar.m_pTextObj->GetFont()); 2064 preWidth = GetCharWidth(preChar.m_CharCode, preChar.m_pTextObj->GetFont());
2083 2065
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
2718 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { 2700 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) {
2719 return; 2701 return;
2720 } 2702 }
2721 CPDF_LinkExt* link = NULL; 2703 CPDF_LinkExt* link = NULL;
2722 link = m_LinkList.GetAt(index); 2704 link = m_LinkList.GetAt(index);
2723 if (!link) { 2705 if (!link) {
2724 return; 2706 return;
2725 } 2707 }
2726 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); 2708 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
2727 } 2709 }
OLDNEW
« no previous file with comments | « core/include/fxcrt/fx_basic.h ('k') | core/src/fpdftext/text_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698