Foxit PDF SDK

fs_searchreplace.h
Go to the documentation of this file.
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:
47 FindOption(bool is_whole_word, bool is_case_sensitive)
48 : is_whole_word(is_whole_word)
49 , is_case_sensitive(is_case_sensitive) {
50 }
51
53 FindOption()
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
109 void Set(bool is_whole_word, bool is_case_sensitive) {
110 this->is_whole_word = is_whole_word;
111 this->is_case_sensitive = is_case_sensitive;
112 }
113
115 bool is_whole_word;
116
118 bool is_case_sensitive;
119 };
124 class ReplaceCallback {
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:
166 TextSearchReplace(const foxit::pdf::PDFDoc& doc);
167
168 // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
169 explicit TextSearchReplace(FS_HANDLE handle);
170
172 ~TextSearchReplace();
173
179 TextSearchReplace(const TextSearchReplace& other);
180
188 TextSearchReplace& operator=(const TextSearchReplace& other);
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
foxit::addon::pageeditor::TextSearchReplace::IsEmpty
bool IsEmpty() const
Check whether current object is empty or not.
foxit::addon::pageeditor::FindOption::operator=
FindOption & operator=(const FindOption &find_option)
Assign operator.
Definition: fs_searchreplace.h:74
foxit::addon::pageeditor::FindOption::operator==
bool operator==(const FindOption &other) const
Equal operator.
Definition: fs_searchreplace.h:87
foxit::addon::pageeditor::FindOption
Definition: fs_searchreplace.h:39
foxit::FS_HANDLE
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:213
foxit::addon::pageeditor::TextSearchReplace::TextSearchReplace
TextSearchReplace(const foxit::pdf::PDFDoc &doc)
Constructor.
foxit::addon::pageeditor::TextSearchReplace::SetReplaceCallback
void SetReplaceCallback(ReplaceCallback *replace_callback)
Set replacing callback function.
foxit::Object
CFX_Object Object
Object type.
Definition: fs_basictypes.h:220
foxit::addon::pageeditor::TextSearchReplace::SetPattern
void SetPattern(const WString &keywords, int page_index, const FindOption &find_option)
Set keywords and page index to do searching and replacing.
fs_common.h
Header file for common definitions and classes.
CFX_ArrayTemplate< RectF >
foxit::addon::pageeditor::FindOption::FindOption
FindOption(const FindOption &find_option)
Constructor, with another find option object.
Definition: fs_searchreplace.h:62
foxit::addon::pageeditor::TextSearchReplace::operator==
bool operator==(const TextSearchReplace &other) const
Equal operator.
foxit::addon::pageeditor::TextSearchReplace::ReplaceNext
bool ReplaceNext(const WString &replace_text)
Replace next text with replacing text.
foxit::addon::pageeditor::TextSearchReplace::~TextSearchReplace
~TextSearchReplace()
Destructor.
foxit::addon::pageeditor::TextSearchReplace::ReplacePrev
bool ReplacePrev(const WString &replace_text)
Replace previous text with replacing text.
foxit::addon::pageeditor::FindOption::Set
void Set(bool is_whole_word, bool is_case_sensitive)
Set value.
Definition: fs_searchreplace.h:109
foxit::addon::pageeditor::FindOption::is_whole_word
bool is_whole_word
A boolean value specifies that whether to match whole words only. true means to match whole words onl...
Definition: fs_searchreplace.h:115
fs_pdfpage.h
Header file for PDF page related definitions and classes.
foxit::addon::pageeditor::FindOption::FindOption
FindOption()
Constructor.
Definition: fs_searchreplace.h:53
foxit
Foxit namespace.
Definition: fs_taggedpdf.h:27
foxit::addon::pageeditor::ReplaceCallback
Definition: fs_searchreplace.h:124
fs_pdfdoc.h
Header file for PDF document related definitions and classes.
foxit::addon::pageeditor::FindOption::is_case_sensitive
bool is_case_sensitive
A boolean value specifies that whether to match case.true means to match case, otherwise no.
Definition: fs_searchreplace.h:118
foxit::pdf::PDFDoc
Definition: fs_pdfdoc.h:776
foxit::addon::pageeditor::TextSearchReplace::operator!=
bool operator!=(const TextSearchReplace &other) const
Not equal operator.
foxit::addon::pageeditor::ReplaceCallback::NeedToReplace
virtual bool NeedToReplace(const WString &search_text, const WString &replace_text, int current_page_index, const RectFArray &text_rect_array)=0
A callback function to verify whether need to replace text.
foxit::addon::pageeditor::TextSearchReplace
Definition: fs_searchreplace.h:156
foxit::addon::pageeditor::FindOption::operator!=
bool operator!=(const FindOption &other) const
Not equal operator.
Definition: fs_searchreplace.h:97
foxit::addon::pageeditor::TextSearchReplace::operator=
TextSearchReplace & operator=(const TextSearchReplace &other)
Assign operator.
foxit::addon::pageeditor::ReplaceCallback::Release
virtual void Release()=0
A callback function used to release current callback object itself.
CFX_WideString
WIDE STRING CLASS.
Definition: fx_string.h:1461
foxit::Base
Definition: fs_basictypes.h:451
foxit::addon::pageeditor::FindOption::FindOption
FindOption(bool is_whole_word, bool is_case_sensitive)
Constructor, with parameters.
Definition: fs_searchreplace.h:47