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 <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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 343 } |
344 if (rect.bottom > info_curchar.m_CharBox.bottom) { | 344 if (rect.bottom > info_curchar.m_CharBox.bottom) { |
345 rect.bottom = info_curchar.m_CharBox.bottom; | 345 rect.bottom = info_curchar.m_CharBox.bottom; |
346 } | 346 } |
347 } | 347 } |
348 } | 348 } |
349 rectArray.Add(rect); | 349 rectArray.Add(rect); |
350 return; | 350 return; |
351 } | 351 } |
352 int CPDF_TextPage::GetIndexAtPos(CPDF_Point point, | 352 int CPDF_TextPage::GetIndexAtPos(CPDF_Point point, |
353 FX_FLOAT xTorelance, | 353 FX_FLOAT xTolerance, |
354 FX_FLOAT yTorelance) const { | 354 FX_FLOAT yTolerance) const { |
355 if (m_ParseOptions.m_bGetCharCodeOnly) { | 355 if (m_ParseOptions.m_bGetCharCodeOnly) { |
356 return -3; | 356 return -3; |
357 } | 357 } |
358 if (!m_IsParsered) { | 358 if (!m_IsParsered) { |
359 return -3; | 359 return -3; |
360 } | 360 } |
361 int pos = 0; | 361 int pos = 0; |
362 int NearPos = -1; | 362 int NearPos = -1; |
363 double xdif = 5000, ydif = 5000; | 363 double xdif = 5000, ydif = 5000; |
364 while (pos < m_charList.GetSize()) { | 364 while (pos < m_charList.GetSize()) { |
365 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)(m_charList.GetAt(pos)); | 365 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)(m_charList.GetAt(pos)); |
366 CFX_FloatRect charrect = charinfo.m_CharBox; | 366 CFX_FloatRect charrect = charinfo.m_CharBox; |
367 if (charrect.Contains(point.x, point.y)) { | 367 if (charrect.Contains(point.x, point.y)) { |
368 break; | 368 break; |
369 } | 369 } |
370 if (xTorelance > 0 || yTorelance > 0) { | 370 if (xTolerance > 0 || yTolerance > 0) { |
371 CFX_FloatRect charRectExt; | 371 CFX_FloatRect charRectExt; |
372 charrect.Normalize(); | 372 charrect.Normalize(); |
373 charRectExt.left = charrect.left - xTorelance / 2; | 373 charRectExt.left = charrect.left - xTolerance / 2; |
374 charRectExt.right = charrect.right + xTorelance / 2; | 374 charRectExt.right = charrect.right + xTolerance / 2; |
375 charRectExt.top = charrect.top + yTorelance / 2; | 375 charRectExt.top = charrect.top + yTolerance / 2; |
376 charRectExt.bottom = charrect.bottom - yTorelance / 2; | 376 charRectExt.bottom = charrect.bottom - yTolerance / 2; |
377 if (charRectExt.Contains(point.x, point.y)) { | 377 if (charRectExt.Contains(point.x, point.y)) { |
378 double curXdif, curYdif; | 378 double curXdif, curYdif; |
379 curXdif = FXSYS_fabs(point.x - charrect.left) < | 379 curXdif = FXSYS_fabs(point.x - charrect.left) < |
380 FXSYS_fabs(point.x - charrect.right) | 380 FXSYS_fabs(point.x - charrect.right) |
381 ? FXSYS_fabs(point.x - charrect.left) | 381 ? FXSYS_fabs(point.x - charrect.left) |
382 : FXSYS_fabs(point.x - charrect.right); | 382 : FXSYS_fabs(point.x - charrect.right); |
383 curYdif = FXSYS_fabs(point.y - charrect.bottom) < | 383 curYdif = FXSYS_fabs(point.y - charrect.bottom) < |
384 FXSYS_fabs(point.y - charrect.top) | 384 FXSYS_fabs(point.y - charrect.top) |
385 ? FXSYS_fabs(point.y - charrect.bottom) | 385 ? FXSYS_fabs(point.y - charrect.bottom) |
386 : FXSYS_fabs(point.y - charrect.top); | 386 : FXSYS_fabs(point.y - charrect.top); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 curRect.bottom = info_curchar.m_CharBox.bottom; | 482 curRect.bottom = info_curchar.m_CharBox.bottom; |
483 } | 483 } |
484 } | 484 } |
485 } | 485 } |
486 } | 486 } |
487 resRectArray.Add(curRect); | 487 resRectArray.Add(curRect); |
488 return; | 488 return; |
489 } | 489 } |
490 int CPDF_TextPage::GetIndexAtPos(FX_FLOAT x, | 490 int CPDF_TextPage::GetIndexAtPos(FX_FLOAT x, |
491 FX_FLOAT y, | 491 FX_FLOAT y, |
492 FX_FLOAT xTorelance, | 492 FX_FLOAT xTolerance, |
493 FX_FLOAT yTorelance) const { | 493 FX_FLOAT yTolerance) const { |
494 if (m_ParseOptions.m_bGetCharCodeOnly) { | 494 if (m_ParseOptions.m_bGetCharCodeOnly) { |
495 return -3; | 495 return -3; |
496 } | 496 } |
497 CPDF_Point point(x, y); | 497 CPDF_Point point(x, y); |
498 return GetIndexAtPos(point, xTorelance, yTorelance); | 498 return GetIndexAtPos(point, xTolerance, yTolerance); |
499 } | 499 } |
500 void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO& info) const { | 500 void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO& info) const { |
501 if (m_ParseOptions.m_bGetCharCodeOnly) { | 501 if (m_ParseOptions.m_bGetCharCodeOnly) { |
502 return; | 502 return; |
503 } | 503 } |
504 if (!m_IsParsered) { | 504 if (!m_IsParsered) { |
505 return; | 505 return; |
506 } | 506 } |
507 if (index < 0 || index >= m_charList.GetSize()) { | 507 if (index < 0 || index >= m_charList.GetSize()) { |
508 return; | 508 return; |
(...skipping 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |