summaryrefslogtreecommitdiff
path: root/core/fpdftext/cpdf_textpagefind.h
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-08-28 13:36:18 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-28 19:17:03 +0000
commit61cb1121729d7e5f53c95077dcc57a61b3f575e8 (patch)
tree8c5dd34af353a53c7e781ed696e6a773a9e55949 /core/fpdftext/cpdf_textpagefind.h
parent2b6e2a7c92a8c2756364a40a22e6f91b910fc514 (diff)
downloadpdfium-61cb1121729d7e5f53c95077dcc57a61b3f575e8.tar.xz
Convert find markers to Optionals in CPDF_TextPageFind
Currently these use -1 as a special value to indicate not set. This creates the same issues that FX_STRNPOS created for converting FX_STRSIZE to size_t, so this code has been rewritten. BUG=pdfium:828 Change-Id: Iaaa96af0dcb2eb8b600f3ea39060a398ac9a3800 Reviewed-on: https://pdfium-review.googlesource.com/12130 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fpdftext/cpdf_textpagefind.h')
-rw-r--r--core/fpdftext/cpdf_textpagefind.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/core/fpdftext/cpdf_textpagefind.h b/core/fpdftext/cpdf_textpagefind.h
index ed0620605a..cf8d3d1702 100644
--- a/core/fpdftext/cpdf_textpagefind.h
+++ b/core/fpdftext/cpdf_textpagefind.h
@@ -13,6 +13,7 @@
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
+#include "third_party/base/optional.h"
class CPDF_TextPage;
@@ -21,7 +22,9 @@ class CPDF_TextPageFind {
explicit CPDF_TextPageFind(const CPDF_TextPage* pTextPage);
~CPDF_TextPageFind();
- bool FindFirst(const CFX_WideString& findwhat, int flags, int startPos = 0);
+ bool FindFirst(const CFX_WideString& findwhat,
+ int flags,
+ pdfium::Optional<FX_STRSIZE> startPos);
bool FindNext();
bool FindPrev();
int GetCurOrder() const;
@@ -30,13 +33,12 @@ class CPDF_TextPageFind {
protected:
void ExtractFindWhat(const CFX_WideString& findwhat);
bool IsMatchWholeWord(const CFX_WideString& csPageText,
- int startPos,
- int endPos);
+ FX_STRSIZE startPos,
+ FX_STRSIZE endPos);
bool ExtractSubString(CFX_WideString& rString,
const wchar_t* lpszFullString,
int iSubString,
wchar_t chSep);
- CFX_WideString MakeReverse(const CFX_WideString& str);
int GetCharIndex(int index) const;
private:
@@ -46,8 +48,8 @@ class CPDF_TextPageFind {
CFX_WideString m_findWhat;
int m_flags;
std::vector<CFX_WideString> m_csFindWhatArray;
- int m_findNextStart;
- int m_findPreStart;
+ pdfium::Optional<FX_STRSIZE> m_findNextStart;
+ pdfium::Optional<FX_STRSIZE> m_findPreStart;
bool m_bMatchCase;
bool m_bMatchWholeWord;
int m_resStart;