From 8b357e7504ea804293983453540ae91c9fc57922 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Thu, 30 Nov 2017 21:02:41 +0000 Subject: Rewrite lower level details of extracting text from page The current implementation of text extraction was difficult to understand, duplicated logic that existed in other methods, and wasn't clear about the units the inputs were in. It also didn't handle control characters correctly. The new implementation leans on the methods for converting indices between the text buffer index and character list index spaces to avoid duplication of code. It also makes it clear to the reader that inputs are in the character list index space. Finally, it fixes issues being seen in Chrome with respect of ranges being slightly off. This CL also adds a test for extracting text that has control characters. BUG=pdfium:942,chromium:654578 Change-Id: Id9d1f360c2d7492c7b5a48d6c9ae29f530892742 Reviewed-on: https://pdfium-review.googlesource.com/20014 Commit-Queue: Ryan Harrison Reviewed-by: dsinclair Reviewed-by: Henrique Nakashima --- core/fpdftext/cpdf_textpagefind.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/fpdftext/cpdf_textpagefind.cpp') diff --git a/core/fpdftext/cpdf_textpagefind.cpp b/core/fpdftext/cpdf_textpagefind.cpp index a874521326..9f243a0aee 100644 --- a/core/fpdftext/cpdf_textpagefind.cpp +++ b/core/fpdftext/cpdf_textpagefind.cpp @@ -41,7 +41,7 @@ CPDF_TextPageFind::CPDF_TextPageFind(const CPDF_TextPage* pTextPage) m_resStart(0), m_resEnd(-1), m_IsFind(false) { - m_strText = m_pTextPage->GetPageText(); + m_strText = m_pTextPage->GetAllPageText(); int nCount = pTextPage->CountChars(); if (nCount) m_CharIndex.push_back(0); @@ -85,7 +85,7 @@ bool CPDF_TextPageFind::FindFirst(const WideString& findwhat, if (!m_pTextPage) return false; if (m_strText.IsEmpty() || m_bMatchCase != (flags & FPDFTEXT_MATCHCASE)) - m_strText = m_pTextPage->GetPageText(); + m_strText = m_pTextPage->GetAllPageText(); WideString findwhatStr = findwhat; m_findWhat = findwhatStr; m_flags = flags; -- cgit v1.2.3