diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-02-21 14:31:41 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-02-21 21:43:40 +0000 |
commit | d476adcab3b1b79b921c0003f8d8caad1bb1d00b (patch) | |
tree | a285cd1b03159e34c1c5ecde897d0a3364cd03b8 | |
parent | b45ea1fce52d93615470bab8b671cba5907fb01e (diff) | |
download | pdfium-d476adcab3b1b79b921c0003f8d8caad1bb1d00b.tar.xz |
Remove non CFX_PointF GetIndexAtPos
This Cl removes the overload that takes a x,y position and uses the CFX_PointF
version in all cases.
Change-Id: Iebd048d91a1e1ed1c90ec0019e19750afe06e745
Reviewed-on: https://pdfium-review.googlesource.com/2812
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
-rw-r--r-- | core/fpdftext/cpdf_textpage.cpp | 21 | ||||
-rw-r--r-- | core/fpdftext/cpdf_textpage.h | 8 | ||||
-rw-r--r-- | fpdfsdk/fpdftext.cpp | 6 |
3 files changed, 11 insertions, 24 deletions
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index b5563bb0c5..bd60435bb1 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -301,8 +301,7 @@ std::vector<CFX_FloatRect> CPDF_TextPage::GetRectArray(int start, } int CPDF_TextPage::GetIndexAtPos(const CFX_PointF& point, - FX_FLOAT xTolerance, - FX_FLOAT yTolerance) const { + const CFX_SizeF& tolerance) const { if (!m_bIsParsed) return -3; @@ -315,13 +314,13 @@ int CPDF_TextPage::GetIndexAtPos(const CFX_PointF& point, CFX_FloatRect charrect = charinfo.m_CharBox; if (charrect.Contains(point)) break; - if (xTolerance > 0 || yTolerance > 0) { + if (tolerance.width > 0 || tolerance.height > 0) { CFX_FloatRect charRectExt; charrect.Normalize(); - charRectExt.left = charrect.left - xTolerance / 2; - charRectExt.right = charrect.right + xTolerance / 2; - charRectExt.top = charrect.top + yTolerance / 2; - charRectExt.bottom = charrect.bottom - yTolerance / 2; + charRectExt.left = charrect.left - tolerance.width / 2; + charRectExt.right = charrect.right + tolerance.width / 2; + charRectExt.top = charrect.top + tolerance.height / 2; + charRectExt.bottom = charrect.bottom - tolerance.height / 2; if (charRectExt.Contains(point)) { double curXdif, curYdif; curXdif = FXSYS_fabs(point.x - charrect.left) < @@ -378,14 +377,6 @@ CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const { return strText; } -int CPDF_TextPage::GetIndexAtPos(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT xTolerance, - FX_FLOAT yTolerance) const { - CFX_PointF point(x, y); - return GetIndexAtPos(point, xTolerance, yTolerance); -} - void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO* info) const { if (!m_bIsParsed) return; diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h index 787715fc51..91942d1bec 100644 --- a/core/fpdftext/cpdf_textpage.h +++ b/core/fpdftext/cpdf_textpage.h @@ -98,13 +98,7 @@ class CPDF_TextPage { int CountChars() const; void GetCharInfo(int index, FPDF_CHAR_INFO* info) const; std::vector<CFX_FloatRect> GetRectArray(int start, int nCount) const; - int GetIndexAtPos(const CFX_PointF& point, - FX_FLOAT xTolerance, - FX_FLOAT yTolerance) const; - int GetIndexAtPos(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT xTolerance, - FX_FLOAT yTolerance) const; + int GetIndexAtPos(const CFX_PointF& point, const CFX_SizeF& tolerance) const; CFX_WideString GetTextByRect(const CFX_FloatRect& rect) const; CFX_WideString GetPageText(int start = 0, int nCount = -1) const; int CountRects(int start, int nCount); diff --git a/fpdfsdk/fpdftext.cpp b/fpdfsdk/fpdftext.cpp index 629e596c8d..0432afd707 100644 --- a/fpdfsdk/fpdftext.cpp +++ b/fpdfsdk/fpdftext.cpp @@ -133,8 +133,10 @@ DLLEXPORT int STDCALL FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page, return -3; CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page); - return textpage->GetIndexAtPos((FX_FLOAT)x, (FX_FLOAT)y, (FX_FLOAT)xTolerance, - (FX_FLOAT)yTolerance); + return textpage->GetIndexAtPos( + CFX_PointF(static_cast<FX_FLOAT>(x), static_cast<FX_FLOAT>(y)), + CFX_SizeF(static_cast<FX_FLOAT>(xTolerance), + static_cast<FX_FLOAT>(yTolerance))); } DLLEXPORT int STDCALL FPDFText_GetText(FPDF_TEXTPAGE text_page, |