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

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

Issue 1285183005: Merge to XFA: Cleanup: s/Torelance/Tolerance/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 4 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/fpdftext/fpdf_text.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 <ctype.h> 7 #include <ctype.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "../../../third_party/base/nonstd_unique_ptr.h" 10 #include "../../../third_party/base/nonstd_unique_ptr.h"
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 346 }
347 if (rect.bottom > info_curchar.m_CharBox.bottom) { 347 if (rect.bottom > info_curchar.m_CharBox.bottom) {
348 rect.bottom = info_curchar.m_CharBox.bottom; 348 rect.bottom = info_curchar.m_CharBox.bottom;
349 } 349 }
350 } 350 }
351 } 351 }
352 rectArray.Add(rect); 352 rectArray.Add(rect);
353 return; 353 return;
354 } 354 }
355 int CPDF_TextPage::GetIndexAtPos(CPDF_Point point, 355 int CPDF_TextPage::GetIndexAtPos(CPDF_Point point,
356 FX_FLOAT xTorelance, 356 FX_FLOAT xTolerance,
357 FX_FLOAT yTorelance) const { 357 FX_FLOAT yTolerance) const {
358 if (m_ParseOptions.m_bGetCharCodeOnly) { 358 if (m_ParseOptions.m_bGetCharCodeOnly) {
359 return -3; 359 return -3;
360 } 360 }
361 if (!m_IsParsered) { 361 if (!m_IsParsered) {
362 return -3; 362 return -3;
363 } 363 }
364 int pos = 0; 364 int pos = 0;
365 int NearPos = -1; 365 int NearPos = -1;
366 double xdif = 5000, ydif = 5000; 366 double xdif = 5000, ydif = 5000;
367 while (pos < m_charList.GetSize()) { 367 while (pos < m_charList.GetSize()) {
368 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)(m_charList.GetAt(pos)); 368 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)(m_charList.GetAt(pos));
369 CFX_FloatRect charrect = charinfo.m_CharBox; 369 CFX_FloatRect charrect = charinfo.m_CharBox;
370 if (charrect.Contains(point.x, point.y)) { 370 if (charrect.Contains(point.x, point.y)) {
371 break; 371 break;
372 } 372 }
373 if (xTorelance > 0 || yTorelance > 0) { 373 if (xTolerance > 0 || yTolerance > 0) {
374 CFX_FloatRect charRectExt; 374 CFX_FloatRect charRectExt;
375 charrect.Normalize(); 375 charrect.Normalize();
376 charRectExt.left = charrect.left - xTorelance / 2; 376 charRectExt.left = charrect.left - xTolerance / 2;
377 charRectExt.right = charrect.right + xTorelance / 2; 377 charRectExt.right = charrect.right + xTolerance / 2;
378 charRectExt.top = charrect.top + yTorelance / 2; 378 charRectExt.top = charrect.top + yTolerance / 2;
379 charRectExt.bottom = charrect.bottom - yTorelance / 2; 379 charRectExt.bottom = charrect.bottom - yTolerance / 2;
380 if (charRectExt.Contains(point.x, point.y)) { 380 if (charRectExt.Contains(point.x, point.y)) {
381 double curXdif, curYdif; 381 double curXdif, curYdif;
382 curXdif = FXSYS_fabs(point.x - charrect.left) < 382 curXdif = FXSYS_fabs(point.x - charrect.left) <
383 FXSYS_fabs(point.x - charrect.right) 383 FXSYS_fabs(point.x - charrect.right)
384 ? FXSYS_fabs(point.x - charrect.left) 384 ? FXSYS_fabs(point.x - charrect.left)
385 : FXSYS_fabs(point.x - charrect.right); 385 : FXSYS_fabs(point.x - charrect.right);
386 curYdif = FXSYS_fabs(point.y - charrect.bottom) < 386 curYdif = FXSYS_fabs(point.y - charrect.bottom) <
387 FXSYS_fabs(point.y - charrect.top) 387 FXSYS_fabs(point.y - charrect.top)
388 ? FXSYS_fabs(point.y - charrect.bottom) 388 ? FXSYS_fabs(point.y - charrect.bottom)
389 : FXSYS_fabs(point.y - charrect.top); 389 : FXSYS_fabs(point.y - charrect.top);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 curRect.bottom = info_curchar.m_CharBox.bottom; 485 curRect.bottom = info_curchar.m_CharBox.bottom;
486 } 486 }
487 } 487 }
488 } 488 }
489 } 489 }
490 resRectArray.Add(curRect); 490 resRectArray.Add(curRect);
491 return; 491 return;
492 } 492 }
493 int CPDF_TextPage::GetIndexAtPos(FX_FLOAT x, 493 int CPDF_TextPage::GetIndexAtPos(FX_FLOAT x,
494 FX_FLOAT y, 494 FX_FLOAT y,
495 FX_FLOAT xTorelance, 495 FX_FLOAT xTolerance,
496 FX_FLOAT yTorelance) const { 496 FX_FLOAT yTolerance) const {
497 if (m_ParseOptions.m_bGetCharCodeOnly) { 497 if (m_ParseOptions.m_bGetCharCodeOnly) {
498 return -3; 498 return -3;
499 } 499 }
500 CPDF_Point point(x, y); 500 CPDF_Point point(x, y);
501 return GetIndexAtPos(point, xTorelance, yTorelance); 501 return GetIndexAtPos(point, xTolerance, yTolerance);
502 } 502 }
503 void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO& info) const { 503 void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO& info) const {
504 if (m_ParseOptions.m_bGetCharCodeOnly) { 504 if (m_ParseOptions.m_bGetCharCodeOnly) {
505 return; 505 return;
506 } 506 }
507 if (!m_IsParsered) { 507 if (!m_IsParsered) {
508 return; 508 return;
509 } 509 }
510 if (index < 0 || index >= m_charList.GetSize()) { 510 if (index < 0 || index >= m_charList.GetSize()) {
511 return; 511 return;
(...skipping 2264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2776 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { 2776 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) {
2777 return; 2777 return;
2778 } 2778 }
2779 CPDF_LinkExt* link = NULL; 2779 CPDF_LinkExt* link = NULL;
2780 link = m_LinkList.GetAt(index); 2780 link = m_LinkList.GetAt(index);
2781 if (!link) { 2781 if (!link) {
2782 return; 2782 return;
2783 } 2783 }
2784 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); 2784 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
2785 } 2785 }
OLDNEW
« no previous file with comments | « core/include/fpdftext/fpdf_text.h ('k') | core/src/fpdftext/text_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698