Foxit PDF SDK
fs_searchreplace.h
浏览该文件的文档.
1 
15 #ifndef FS_SEARCHREPLACE_H_
16 #define FS_SEARCHREPLACE_H_
17 
18 #include "common/fs_common.h"
19 #include "pdf/fs_pdfdoc.h"
20 #include "pdf/fs_pdfpage.h"
21 
27 namespace foxit {
31 namespace addon {
35 namespace pageeditor {
39 class FindOption FS_FINAL : public Object{
40  public:
50  }
51 
54  : is_whole_word(false)
55  , is_case_sensitive(false) {}
56 
62  FindOption(const FindOption& find_option) {
63  this->is_whole_word = find_option.is_whole_word;
64  this->is_case_sensitive = find_option.is_case_sensitive;
65  }
66 
74  FindOption& operator=(const FindOption& find_option) {
75  this->is_whole_word = find_option.is_whole_word;
76  this->is_case_sensitive = find_option.is_case_sensitive;
77  return *this;
78  }
79 
87  bool operator == (const FindOption& other) const {
88  return (is_whole_word == other.is_whole_word && is_case_sensitive == other.is_case_sensitive);
89  }
97  bool operator != (const FindOption& other) const {
98  return (is_whole_word != other.is_whole_word || is_case_sensitive != other.is_case_sensitive);
99  }
100 
110  this->is_whole_word = is_whole_word;
111  this->is_case_sensitive = is_case_sensitive;
112  }
113 
116 
119 };
125  public:
137  virtual bool NeedToReplace(const WString& search_text, const WString& replace_text, int current_page_index, const RectFArray& text_rect_array) = 0;
138 
144  virtual void Release() = 0;
145 
146  protected:
147  virtual ~ReplaceCallback() {}
148 };
156 class TextSearchReplace FS_FINAL : public Base {
157  public:
167 
168  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
169  explicit TextSearchReplace(FS_HANDLE handle);
170 
173 
179  TextSearchReplace(const TextSearchReplace& other);
180 
189 
197  bool operator==(const TextSearchReplace& other) const;
198 
206  bool operator!=(const TextSearchReplace& other) const;
207 
215  bool IsEmpty() const;
216 
228  void SetPattern(const WString& keywords, int page_index, const FindOption& find_option);
229 
238  void SetReplaceCallback(ReplaceCallback* replace_callback);
239 
248  bool ReplacePrev(const WString& replace_text);
249 
258  bool ReplaceNext(const WString& replace_text);
259 };
260 }
261 }
262 }
263 #endif
virtual bool NeedToReplace(const WString &search_text, const WString &replace_text, int current_page_index, const RectFArray &text_rect_array)=0
用于验证是否需要替换文本的回调函数。
FindOption(const FindOption &find_option)
拷贝构造函数。
Definition: fs_searchreplace.h:62
void Set(bool is_whole_word, bool is_case_sensitive)
设置值。
Definition: fs_searchreplace.h:109
CFX_Object Object
对象类型。
Definition: fs_basictypes.h:221
Definition: fs_searchreplace.h:156
PDF文档相关定义和类的头文件。
bool ReplaceNext(const WString &replace_text)
用替换文本替换下一个文本。
bool ReplacePrev(const WString &replace_text)
用替换文本替换上一个文本。
宽字符串类
Definition: fx_string.h:1457
FindOption(bool is_whole_word, bool is_case_sensitive)
构造函数,带参数。
Definition: fs_searchreplace.h:47
void SetReplaceCallback(ReplaceCallback *replace_callback)
设置替换回调函数。
bool operator!=(const TextSearchReplace &other) const
不等操作符。
Definition: fs_pdfdoc.h:771
void SetPattern(const WString &keywords, int page_index, const FindOption &find_option)
设置关键字和页面索引以进行搜索和替换。
bool operator !=(const FindOption &other) const
不等操作符。
Definition: fs_searchreplace.h:97
virtual void Release()=0
用于释放当前回调对象本身的回调函数。
TextSearchReplace(const foxit::pdf::PDFDoc &doc)
构造函数。
Definition: fs_searchreplace.h:124
TextSearchReplace & operator=(const TextSearchReplace &other)
赋值操作符。
bool is_whole_word
布尔值,指定是否仅匹配整个单词。true 表示仅匹配整个单词,否则不匹配。
Definition: fs_searchreplace.h:115
bool is_case_sensitive
布尔值,指定是否匹配大小写。true 表示匹配大小写,否则不匹配。
Definition: fs_searchreplace.h:118
Definition: fs_searchreplace.h:39
void * FS_HANDLE
句柄类型。
Definition: fs_basictypes.h:214
通用定义和类的头文件。
FindOption()
构造函数。
Definition: fs_searchreplace.h:53
bool IsEmpty() const
检查当前对象是否为空。
Definition: fs_basictypes.h:449
PDF页面相关定义和类的头文件。
Foxit命名空间。
Definition: fs_taggedpdf.h:27
bool operator==(const TextSearchReplace &other) const
相等操作符。
FindOption & operator=(const FindOption &find_option)
赋值操作符。
Definition: fs_searchreplace.h:74
bool operator==(const FindOption &other) const
相等操作符。
Definition: fs_searchreplace.h:87