From d476adcab3b1b79b921c0003f8d8caad1bb1d00b Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 21 Feb 2017 14:31:41 -0500 Subject: Remove non CFX_PointF GetIndexAtPos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Tom Sepez Reviewed-by: Nicolás Peña --- core/fpdftext/cpdf_textpage.cpp | 21 ++++++--------------- core/fpdftext/cpdf_textpage.h | 8 +------- 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 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 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(x), static_cast(y)), + CFX_SizeF(static_cast(xTolerance), + static_cast(yTolerance))); } DLLEXPORT int STDCALL FPDFText_GetText(FPDF_TEXTPAGE text_page, -- cgit v1.2.3