From 5c1961dfa0b1828eb2db38dc637548584c5cc704 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Fri, 10 Mar 2017 11:59:17 -0500 Subject: Add public method FPDFText_GetTextIndexFromCharIndex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG=pdfium:676 Change-Id: I46de35a86769dc2f7f73ac3552306356ca3289a5 Reviewed-on: https://pdfium-review.googlesource.com/2955 Reviewed-by: Tom Sepez Commit-Queue: Nicolás Peña --- fpdfsdk/fpdf_searchex.cpp | 8 ++++++++ fpdfsdk/fpdfview_c_api_test.c | 1 + public/fpdf_searchex.h | 9 +++++++++ 3 files changed, 18 insertions(+) diff --git a/fpdfsdk/fpdf_searchex.cpp b/fpdfsdk/fpdf_searchex.cpp index f82db37b5a..13729167ed 100644 --- a/fpdfsdk/fpdf_searchex.cpp +++ b/fpdfsdk/fpdf_searchex.cpp @@ -15,3 +15,11 @@ FPDFText_GetCharIndexFromTextIndex(FPDF_TEXTPAGE text_page, int nTextIndex) { return static_cast(text_page) ->CharIndexFromTextIndex(nTextIndex); } + +DLLEXPORT int STDCALL +FPDFText_GetTextIndexFromCharIndex(FPDF_TEXTPAGE text_page, int nCharIndex) { + if (!text_page) + return -1; + return static_cast(text_page)->TextIndexFromCharIndex( + nCharIndex); +} diff --git a/fpdfsdk/fpdfview_c_api_test.c b/fpdfsdk/fpdfview_c_api_test.c index c603f59acc..df3ef19d64 100644 --- a/fpdfsdk/fpdfview_c_api_test.c +++ b/fpdfsdk/fpdfview_c_api_test.c @@ -168,6 +168,7 @@ int CheckPDFiumCApi() { // fpdf_searchex.h CHK(FPDFText_GetCharIndexFromTextIndex); + CHK(FPDFText_GetTextIndexFromCharIndex); // fpdf_structtree.h CHK(FPDF_StructTree_GetForPage); diff --git a/public/fpdf_searchex.h b/public/fpdf_searchex.h index 7c1b31848e..a795a52394 100644 --- a/public/fpdf_searchex.h +++ b/public/fpdf_searchex.h @@ -23,6 +23,15 @@ extern "C" { DLLEXPORT int STDCALL FPDFText_GetCharIndexFromTextIndex(FPDF_TEXTPAGE text_page, int nTextIndex); +// Get the text index in |text_page| internal character list. +// +// text_page - a text page information structure. +// nCharIndex - index of the character in internal character list. +// +// Returns the index of the text returned from |FPDFText_GetText|. -1 for error. +DLLEXPORT int STDCALL +FPDFText_GetTextIndexFromCharIndex(FPDF_TEXTPAGE text_page, int nCharIndex); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus -- cgit v1.2.3