Aspose::Words::Replacing::FindReplaceOptions Class Reference

Detailed Description

Specifies options for find/replace operations.

Examples

Simple find and replace operation.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello _CustomerName_,");
// Check the document contains what we are about to test
System::Console::WriteLine(doc->get_FirstSection()->get_Body()->get_Paragraphs()->idx_get(0)->GetText());
auto options = MakeObject<FindReplaceOptions>();
options->set_MatchCase(false);
options->set_FindWholeWordsOnly(false);
doc->get_Range()->Replace(u"_CustomerName_", u"James Bond", options);
doc->Save(ArtifactsDir + u"Range.ReplaceSimple.docx");

#include <Aspose.Words.Cpp/Model/FindReplace/FindReplaceOptions.h>

+ Inheritance diagram for Aspose::Words::Replacing::FindReplaceOptions:

Public Member Functions

 FindReplaceOptions ()
 
 FindReplaceOptions (FindReplaceDirection direction)
 
 FindReplaceOptions (FindReplaceDirection direction, SharedPtr< IReplacingCallback > replacingCallback)
 
 FindReplaceOptions (SharedPtr< IReplacingCallback > replacingCallback)
 
SharedPtr< Fontget_ApplyFont () const
 Text formatting applied to new content. More...
 
SharedPtr< ParagraphFormatget_ApplyParagraphFormat () const
 Paragraph formatting applied to new content. More...
 
FindReplaceDirection get_Direction () const
 Selects direction for replace. Default value is Forward. More...
 
bool get_FindWholeWordsOnly () const
 True indicates the oldValue must be a standalone word. More...
 
bool get_IgnoreDeleted () const
 Gets or sets a boolean value indicating either to ignore text inside delete revisions. The default value is false. More...
 
bool get_IgnoreFields () const
 Gets or sets a boolean value indicating either to ignore text inside fields. The default value is false. More...
 
bool get_IgnoreInserted () const
 Gets or sets a boolean value indicating either to ignore text inside insert revisions. The default value is false. More...
 
bool get_LegacyMode () const
 Gets a boolean value indicating that old find/replace algorithm is used. More...
 
bool get_MatchCase () const
 True indicates case-sensitive comparison, false indicates case-insensitive comparison. More...
 
SharedPtr< IReplacingCallbackget_ReplacingCallback () const
 The user-defined method which is called before every replace occurrence. More...
 
bool get_UseLegacyOrder () const
 True indicates that a text search is performed sequentially from top to bottom considering the text boxes. Default value is false. More...
 
bool get_UseSubstitutions () const
 Gets a boolean value indicating whether to recognize and use substitutions within replacement patterns. The default value is false. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_Direction (FindReplaceDirection value)
 Selects direction for replace. Default value is Forward. More...
 
void set_FindWholeWordsOnly (bool value)
 Setter for get_FindWholeWordsOnly. More...
 
void set_IgnoreDeleted (bool value)
 Setter for get_IgnoreDeleted. More...
 
void set_IgnoreFields (bool value)
 Setter for get_IgnoreFields. More...
 
void set_IgnoreInserted (bool value)
 Setter for get_IgnoreInserted. More...
 
void set_LegacyMode (bool value)
 Sets a boolean value indicating that old find/replace algorithm is used. More...
 
void set_MatchCase (bool value)
 Setter for get_MatchCase. More...
 
void set_ReplacingCallback (SharedPtr< IReplacingCallback > value)
 The user-defined method which is called before every replace occurrence. More...
 
void set_UseLegacyOrder (bool value)
 True indicates that a text search is performed sequentially from top to bottom considering the text boxes. Default value is false. More...
 
void set_UseSubstitutions (bool value)
 Sets a boolean value indicating whether to recognize and use substitutions within replacement patterns. The default value is false. More...
 
- Public Member Functions inherited from Object
ASPOSECPP_SHARED_API Object ()
 
ASPOSECPP_SHARED_API Object (Object const &x)
 
virtual ASPOSECPP_SHARED_API ~Object ()
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 
Detail::SmartPtrCounter * GetCounter ()
 
virtual ASPOSECPP_SHARED_API int GetHashCode () const
 
ASPOSECPP_SHARED_API void Lock ()
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 
Objectoperator= (Object const &x)
 
bool ReferenceEquals (String const &str, std::nullptr_t)
 
bool ReferenceEquals (String const &str1, String const &str2)
 
int RemovedSharedRefs (int count)
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (unsigned int argument)
 
int SharedCount () const
 
ObjectSharedRefAdded ()
 
int SharedRefRemovedSafe ()
 
virtual ASPOSECPP_SHARED_API String ToString () const
 
ASPOSECPP_SHARED_API void Unlock ()
 
Detail::SmartPtrCounter * WeakRefAdded ()
 
void WeakRefRemoved ()
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from Object
bool Equals (double const &objA, double const &objB)
 
bool Equals (float const &objA, float const &objB)
 
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 
static const TypeInfoType ()
 

Additional Inherited Members

- Public Types inherited from Object
typedef SmartPtr< Objectptr
 
typedef System::Details::SharedMembersType shared_members_type
 

Constructor & Destructor Documentation

◆ FindReplaceOptions() [1/4]

Aspose::Words::Replacing::FindReplaceOptions::FindReplaceOptions ( )

◆ FindReplaceOptions() [2/4]

Aspose::Words::Replacing::FindReplaceOptions::FindReplaceOptions ( Aspose::Words::FindReplaceDirection  direction)

◆ FindReplaceOptions() [3/4]

Aspose::Words::Replacing::FindReplaceOptions::FindReplaceOptions ( System::SharedPtr< Aspose::Words::Replacing::IReplacingCallback replacingCallback)

◆ FindReplaceOptions() [4/4]

Aspose::Words::Replacing::FindReplaceOptions::FindReplaceOptions ( Aspose::Words::FindReplaceDirection  direction,
System::SharedPtr< Aspose::Words::Replacing::IReplacingCallback replacingCallback 
)

Member Function Documentation

◆ get_ApplyFont()

System::SharedPtr<Aspose::Words::Font> Aspose::Words::Replacing::FindReplaceOptions::get_ApplyFont ( ) const

Text formatting applied to new content.

◆ get_ApplyParagraphFormat()

System::SharedPtr<Aspose::Words::ParagraphFormat> Aspose::Words::Replacing::FindReplaceOptions::get_ApplyParagraphFormat ( ) const

Paragraph formatting applied to new content.

Examples

Shows how to affect the format of paragraphs with successful replacements.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Every paragraph that ends with a full stop like this one will be right aligned.");
builder->Writeln(u"This one will not!");
builder->Writeln(u"And this one will.");
auto options = MakeObject<FindReplaceOptions>();
options->get_ApplyParagraphFormat()->set_Alignment(Aspose::Words::ParagraphAlignment::Right);
int count = doc->get_Range()->Replace(u".&p", u"!&p", options);
ASSERT_EQ(2, count);
doc->Save(ArtifactsDir + u"Range.ApplyParagraphFormat.docx");

◆ get_Direction()

Aspose::Words::FindReplaceDirection Aspose::Words::Replacing::FindReplaceOptions::get_Direction ( ) const

Selects direction for replace. Default value is Forward.

◆ get_FindWholeWordsOnly()

bool Aspose::Words::Replacing::FindReplaceOptions::get_FindWholeWordsOnly ( ) const

True indicates the oldValue must be a standalone word.

Examples

Simple find and replace operation.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello _CustomerName_,");
// Check the document contains what we are about to test
System::Console::WriteLine(doc->get_FirstSection()->get_Body()->get_Paragraphs()->idx_get(0)->GetText());
auto options = MakeObject<FindReplaceOptions>();
options->set_MatchCase(false);
options->set_FindWholeWordsOnly(false);
doc->get_Range()->Replace(u"_CustomerName_", u"James Bond", options);
doc->Save(ArtifactsDir + u"Range.ReplaceSimple.docx");

◆ get_IgnoreDeleted()

bool Aspose::Words::Replacing::FindReplaceOptions::get_IgnoreDeleted ( ) const

Gets or sets a boolean value indicating either to ignore text inside delete revisions. The default value is false.

Examples

Shows how to ignore text inside delete revisions.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert non-revised text
builder->Writeln(u"Deleted");
builder->Write(u"Text");
// Remove first paragraph with tracking revisions
doc->StartTrackRevisions(u"John Doe", System::DateTime::get_Now());
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->Remove();
doc->StopTrackRevisions();
auto regex = MakeObject<System::Text::RegularExpressions::Regex>(u"e");
auto options = MakeObject<FindReplaceOptions>();
// Replace 'e' in document while ignoring/not ignoring deleted text
options->set_IgnoreDeleted(isIgnoreDeleted);
doc->get_Range()->Replace(regex, u"*", options);
ASSERT_EQ(doc->GetText().Trim(), isIgnoreDeleted ? String(u"Deleted\rT*xt") : String(u"D*l*t*d\rT*xt"));

◆ get_IgnoreFields()

bool Aspose::Words::Replacing::FindReplaceOptions::get_IgnoreFields ( ) const

Gets or sets a boolean value indicating either to ignore text inside fields. The default value is false.

Examples

Shows how to ignore text inside fields.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert field with text inside
builder->InsertField(u"INCLUDETEXT", u"Text in field");
auto regex = MakeObject<System::Text::RegularExpressions::Regex>(u"e");
auto options = MakeObject<FindReplaceOptions>();
// Replace 'e' in document ignoring/not ignoring text inside field
options->set_IgnoreFields(isIgnoreFields);
doc->get_Range()->Replace(regex, u"*", options);
ASSERT_EQ(doc->GetText(), isIgnoreFields ? String(u"\u0013INCLUDETEXT\u0014Text in field\u0015\f") : String(u"\u0013INCLUDETEXT\u0014T*xt in fi*ld\u0015\f"));

◆ get_IgnoreInserted()

bool Aspose::Words::Replacing::FindReplaceOptions::get_IgnoreInserted ( ) const

Gets or sets a boolean value indicating either to ignore text inside insert revisions. The default value is false.

Examples

Shows how to ignore text inside insert revisions.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert text with tracking revisions
doc->StartTrackRevisions(u"John Doe", System::DateTime::get_Now());
builder->Writeln(u"Inserted");
doc->StopTrackRevisions();
// Insert non-revised text
builder->Write(u"Text");
auto regex = MakeObject<System::Text::RegularExpressions::Regex>(u"e");
auto options = MakeObject<FindReplaceOptions>();
// Replace 'e' in document while ignoring/not ignoring inserted text
options->set_IgnoreInserted(isIgnoreInserted);
doc->get_Range()->Replace(regex, u"*", options);
ASSERT_EQ(doc->GetText().Trim(), isIgnoreInserted ? String(u"Inserted\rT*xt") : String(u"Ins*rt*d\rT*xt"));

◆ get_LegacyMode()

bool Aspose::Words::Replacing::FindReplaceOptions::get_LegacyMode ( ) const

Gets a boolean value indicating that old find/replace algorithm is used.

◆ get_MatchCase()

bool Aspose::Words::Replacing::FindReplaceOptions::get_MatchCase ( ) const

True indicates case-sensitive comparison, false indicates case-insensitive comparison.

Examples

Simple find and replace operation.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello _CustomerName_,");
// Check the document contains what we are about to test
System::Console::WriteLine(doc->get_FirstSection()->get_Body()->get_Paragraphs()->idx_get(0)->GetText());
auto options = MakeObject<FindReplaceOptions>();
options->set_MatchCase(false);
options->set_FindWholeWordsOnly(false);
doc->get_Range()->Replace(u"_CustomerName_", u"James Bond", options);
doc->Save(ArtifactsDir + u"Range.ReplaceSimple.docx");

◆ get_ReplacingCallback()

System::SharedPtr<Aspose::Words::Replacing::IReplacingCallback> Aspose::Words::Replacing::FindReplaceOptions::get_ReplacingCallback ( ) const

The user-defined method which is called before every replace occurrence.

◆ get_UseLegacyOrder()

bool Aspose::Words::Replacing::FindReplaceOptions::get_UseLegacyOrder ( ) const

True indicates that a text search is performed sequentially from top to bottom considering the text boxes. Default value is false.

◆ get_UseSubstitutions()

bool Aspose::Words::Replacing::FindReplaceOptions::get_UseSubstitutions ( ) const

Gets a boolean value indicating whether to recognize and use substitutions within replacement patterns. The default value is false.

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Replacing::FindReplaceOptions::GetType ( ) const
overridevirtual

Reimplemented from System::Object.

◆ Is()

virtual bool Aspose::Words::Replacing::FindReplaceOptions::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from System::Object.

◆ set_Direction()

void Aspose::Words::Replacing::FindReplaceOptions::set_Direction ( Aspose::Words::FindReplaceDirection  value)

Selects direction for replace. Default value is Forward.

◆ set_FindWholeWordsOnly()

void Aspose::Words::Replacing::FindReplaceOptions::set_FindWholeWordsOnly ( bool  value)

◆ set_IgnoreDeleted()

void Aspose::Words::Replacing::FindReplaceOptions::set_IgnoreDeleted ( bool  value)

◆ set_IgnoreFields()

void Aspose::Words::Replacing::FindReplaceOptions::set_IgnoreFields ( bool  value)

◆ set_IgnoreInserted()

void Aspose::Words::Replacing::FindReplaceOptions::set_IgnoreInserted ( bool  value)

◆ set_LegacyMode()

void Aspose::Words::Replacing::FindReplaceOptions::set_LegacyMode ( bool  value)

Sets a boolean value indicating that old find/replace algorithm is used.

◆ set_MatchCase()

void Aspose::Words::Replacing::FindReplaceOptions::set_MatchCase ( bool  value)

◆ set_ReplacingCallback()

void Aspose::Words::Replacing::FindReplaceOptions::set_ReplacingCallback ( System::SharedPtr< Aspose::Words::Replacing::IReplacingCallback value)

The user-defined method which is called before every replace occurrence.

◆ set_UseLegacyOrder()

void Aspose::Words::Replacing::FindReplaceOptions::set_UseLegacyOrder ( bool  value)

True indicates that a text search is performed sequentially from top to bottom considering the text boxes. Default value is false.

◆ set_UseSubstitutions()

void Aspose::Words::Replacing::FindReplaceOptions::set_UseSubstitutions ( bool  value)

Sets a boolean value indicating whether to recognize and use substitutions within replacement patterns. The default value is false.

◆ Type()

static const System::TypeInfo& Aspose::Words::Replacing::FindReplaceOptions::Type ( )
static
String
static ASPOSECPP_SHARED_API DateTime get_Now()
static ASPOSECPP_SHARED_API void WriteLine()
@ Right
Text is aligned to the right.