Aspose::Words::Loading::TxtLoadOptions Class Reference

Detailed Description

Allows to specify additional options when loading Text document into a Document object.

#include <Aspose.Words.Cpp/Loading/TxtLoadOptions.h>

+ Inheritance diagram for Aspose::Words::Loading::TxtLoadOptions:

Public Member Functions

 TxtLoadOptions ()
 Initializes a new instance of this class with default values. More...
 
bool get_DetectNumberingWithWhitespaces () const
 Allows to specify how numbered list items are recognized when document is imported from plain text format. The default value is true. More...
 
DocumentDirection get_DocumentDirection () const
 Gets or sets a document direction. The default value is LeftToRight. More...
 
TxtLeadingSpacesOptions get_LeadingSpacesOptions () const
 Gets or sets preferred option of a leading space handling. Default value is ConvertToIndent. More...
 
TxtTrailingSpacesOptions get_TrailingSpacesOptions () const
 Gets or sets preferred option of a trailing space handling. Default value is Trim. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_DetectNumberingWithWhitespaces (bool value)
 Setter for get_DetectNumberingWithWhitespaces. More...
 
void set_DocumentDirection (DocumentDirection value)
 Setter for get_DocumentDirection. More...
 
void set_LeadingSpacesOptions (TxtLeadingSpacesOptions value)
 Setter for get_LeadingSpacesOptions. More...
 
void set_TrailingSpacesOptions (TxtTrailingSpacesOptions value)
 Setter for get_TrailingSpacesOptions. More...
 
- Public Member Functions inherited from LoadOptions
 LoadOptions ()
 Initializes a new instance of this class with default values. More...
 
 LoadOptions (LoadFormat loadFormat, String password, String baseUri)
 A shortcut to initialize a new instance of this class with properties set to the specified values. More...
 
 LoadOptions (String password)
 A shortcut to initialize a new instance of this class with the specified password to load an encrypted document. More...
 
String get_BaseUri () const
 Gets or sets the string that will be used to resolve relative URIs found in the document into absolute URIs when required. Can be null or empty string. Default is null. More...
 
bool get_ConvertMetafilesToPng () const
 Gets or sets whether to convert metafile (Wmf or Emf) images to Png image format. More...
 
bool get_ConvertShapeToOfficeMath () const
 Gets or sets whether to convert shapes with EquationXML to Office Math objects. More...
 
SharedPtr< Encodingget_Encoding () const
 Gets or sets the encoding that will be used to load an HTML, TXT, or CHM document if the encoding is not specified inside the document. Can be null. Default is null. More...
 
SharedPtr< FontSettingsget_FontSettings () const
 Allows to specify document font settings. More...
 
SharedPtr< LanguagePreferencesget_LanguagePreferences () const
 Gets language preferences that will be used when document is loading. More...
 
LoadFormat get_LoadFormat () const
 Specifies the format of the document to be loaded. Default is Auto. More...
 
MsWordVersion get_MswVersion () const
 Allows to specify that the document loading process should match a specific MS Word version. Default value is Word2007 More...
 
String get_Password () const
 Gets or sets the password for opening an encrypted document. Can be null or empty string. Default is null. More...
 
bool get_PreserveIncludePictureField () const
 Gets or sets whether to preserve the INCLUDEPICTURE field when reading Microsoft Word formats. The default value is false. More...
 
SharedPtr< IResourceLoadingCallbackget_ResourceLoadingCallback () const
 Allows to control how external resources (images, style sheets) are loaded when a document is imported from HTML, MHTML. More...
 
String get_TempFolder () const
 Allows to use temporary files when reading document. By default this property is null and no temporary files are used. More...
 
bool get_UpdateDirtyFields () const
 Specifies whether to update the fields with the dirty attribute. More...
 
SharedPtr< IWarningCallbackget_WarningCallback () const
 Called during a load operation, when an issue is detected that might result in data or formatting fidelity loss. More...
 
void set_BaseUri (String value)
 Setter for get_BaseUri. More...
 
void set_ConvertMetafilesToPng (bool value)
 Setter for get_ConvertMetafilesToPng. More...
 
void set_ConvertShapeToOfficeMath (bool value)
 Setter for get_ConvertShapeToOfficeMath. More...
 
void set_Encoding (SharedPtr< Encoding > value)
 Setter for get_Encoding. More...
 
void set_FontSettings (SharedPtr< FontSettings > value)
 Setter for get_FontSettings. More...
 
void set_LoadFormat (LoadFormat value)
 Setter for get_LoadFormat. More...
 
void set_MswVersion (MsWordVersion value)
 Setter for get_MswVersion. More...
 
void set_Password (String value)
 Setter for get_Password. More...
 
void set_PreserveIncludePictureField (bool value)
 Setter for get_PreserveIncludePictureField. More...
 
void set_ResourceLoadingCallback (SharedPtr< IResourceLoadingCallback > value)
 Setter for get_ResourceLoadingCallback. More...
 
void set_TempFolder (String value)
 Setter for get_TempFolder. More...
 
void set_UpdateDirtyFields (bool value)
 Setter for get_UpdateDirtyFields. More...
 
void set_WarningCallback (SharedPtr< IWarningCallback > value)
 Setter for get_WarningCallback. More...
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from LoadOptions
static const TypeInfoType ()
 

Constructor & Destructor Documentation

◆ TxtLoadOptions()

Aspose::Words::Loading::TxtLoadOptions::TxtLoadOptions ( )

Initializes a new instance of this class with default values.

Member Function Documentation

◆ get_DetectNumberingWithWhitespaces()

bool Aspose::Words::Loading::TxtLoadOptions::get_DetectNumberingWithWhitespaces ( ) const

Allows to specify how numbered list items are recognized when document is imported from plain text format. The default value is true.

If this option is set to false, lists recognition algorithm detects list paragraphs, when list numbers ends with either dot, right bracket or bullet symbols (such as "•", "*", "-" or "o").

If this option is set to true, whitespaces are also used as list number delimeters: list recognition algorithm for Arabic style numbering (1., 1.1.2.) uses both whitespaces and dot (".") symbols.

Examples

Shows how to detect lists when loading plaintext documents.

// Create a plaintext document in a string with four separate parts that we may interpret as lists,
// with different delimiters. Upon loading the plaintext document into a "Document" object,
// Aspose.Words will always detect the first three lists and will add a "List" object
// for each to the document's "Lists" property.
const String textDoc = String(u"Full stop delimiters:\n") + u"1. First list item 1\n" + u"2. First list item 2\n" + u"3. First list item 3\n\n" +
u"Right bracket delimiters:\n" + u"1) Second list item 1\n" + u"2) Second list item 2\n" + u"3) Second list item 3\n\n" +
u"Bullet delimiters:\n" + u"• Third list item 1\n" + u"• Third list item 2\n" + u"• Third list item 3\n\n" +
u"Whitespace delimiters:\n" + u"1 Fourth list item 1\n" + u"2 Fourth list item 2\n" + u"3 Fourth list item 3";
// Create a "TxtLoadOptions" object, which we can pass to a document's constructor
// to modify how we load a plaintext document.
auto loadOptions = MakeObject<TxtLoadOptions>();
// Set the "DetectNumberingWithWhitespaces" property to "true" to detect numbered items
// with whitespace delimiters, such as the fourth list in our document, as lists.
// This may also falsely detect paragraphs that begin with numbers as lists.
// Set the "DetectNumberingWithWhitespaces" property to "false"
// to not create lists from numbered items with whitespace delimiters.
loadOptions->set_DetectNumberingWithWhitespaces(detectNumberingWithWhitespaces);
auto doc = MakeObject<Document>(MakeObject<System::IO::MemoryStream>(System::Text::Encoding::get_UTF8()->GetBytes(textDoc)), loadOptions);
if (detectNumberingWithWhitespaces)
{
ASSERT_EQ(4, doc->get_Lists()->get_Count());
ASSERT_TRUE(doc->get_FirstSection()->get_Body()->get_Paragraphs()->LINQ_Any(
[](SharedPtr<Node> p) { return p->GetText().Contains(u"Fourth list") && (System::DynamicCast<Paragraph>(p))->get_IsListItem(); }));
}
else
{
ASSERT_EQ(3, doc->get_Lists()->get_Count());
ASSERT_FALSE(doc->get_FirstSection()->get_Body()->get_Paragraphs()->LINQ_Any(
[](SharedPtr<Node> p) { return p->GetText().Contains(u"Fourth list") && (System::DynamicCast<Paragraph>(p))->get_IsListItem(); }));
}

◆ get_DocumentDirection()

Aspose::Words::Loading::DocumentDirection Aspose::Words::Loading::TxtLoadOptions::get_DocumentDirection ( ) const

Gets or sets a document direction. The default value is LeftToRight.

Examples

Shows how to detect plaintext document text direction.

// Create a "TxtLoadOptions" object, which we can pass to a document's constructor
// to modify how we load a plaintext document.
auto loadOptions = MakeObject<TxtLoadOptions>();
// Set the "DocumentDirection" property to "DocumentDirection.Auto" automatically detects
// the direction of every paragraph of text that Aspose.Words loads from plaintext.
// Each paragraph's "Bidi" property will store its direction.
loadOptions->set_DocumentDirection(DocumentDirection::Auto);
// Detect Hebrew text as right-to-left.
auto doc = MakeObject<Document>(MyDir + u"Hebrew text.txt", loadOptions);
ASSERT_TRUE(doc->get_FirstSection()->get_Body()->get_FirstParagraph()->get_ParagraphFormat()->get_Bidi());
// Detect English text as right-to-left.
doc = MakeObject<Document>(MyDir + u"English text.txt", loadOptions);
ASSERT_FALSE(doc->get_FirstSection()->get_Body()->get_FirstParagraph()->get_ParagraphFormat()->get_Bidi());

◆ get_LeadingSpacesOptions()

Aspose::Words::Loading::TxtLeadingSpacesOptions Aspose::Words::Loading::TxtLoadOptions::get_LeadingSpacesOptions ( ) const

Gets or sets preferred option of a leading space handling. Default value is ConvertToIndent.

Examples

Shows how to trim whitespace when loading plaintext documents.

String textDoc = String(u" Line 1 \n") + u" Line 2 \n" + u" Line 3 ";
// Create a "TxtLoadOptions" object, which we can pass to a document's constructor
// to modify how we load a plaintext document.
auto loadOptions = MakeObject<TxtLoadOptions>();
// Set the "LeadingSpacesOptions" property to "TxtLeadingSpacesOptions.Preserve"
// to preserve all whitespace characters at the start of every line.
// Set the "LeadingSpacesOptions" property to "TxtLeadingSpacesOptions.ConvertToIndent"
// to remove all whitespace characters from the start of every line,
// and then apply a left first line indent to the paragraph to simulate the effect of the whitespaces.
// Set the "LeadingSpacesOptions" property to "TxtLeadingSpacesOptions.Trim"
// to remove all whitespace characters from every line's start.
loadOptions->set_LeadingSpacesOptions(txtLeadingSpacesOptions);
// Set the "TrailingSpacesOptions" property to "TxtTrailingSpacesOptions.Preserve"
// to preserve all whitespace characters at the end of every line.
// Set the "TrailingSpacesOptions" property to "TxtTrailingSpacesOptions.Trim" to
// remove all whitespace characters from the end of every line.
loadOptions->set_TrailingSpacesOptions(txtTrailingSpacesOptions);
auto doc = MakeObject<Document>(MakeObject<System::IO::MemoryStream>(System::Text::Encoding::get_UTF8()->GetBytes(textDoc)), loadOptions);
SharedPtr<ParagraphCollection> paragraphs = doc->get_FirstSection()->get_Body()->get_Paragraphs();
switch (txtLeadingSpacesOptions)
{
ASPOSE_ASSERT_EQ(37.8, paragraphs->idx_get(0)->get_ParagraphFormat()->get_FirstLineIndent());
ASPOSE_ASSERT_EQ(25.2, paragraphs->idx_get(1)->get_ParagraphFormat()->get_FirstLineIndent());
ASPOSE_ASSERT_EQ(6.3, paragraphs->idx_get(2)->get_ParagraphFormat()->get_FirstLineIndent());
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().StartsWith(u"Line 1"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().StartsWith(u"Line 2"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().StartsWith(u"Line 3"));
break;
ASSERT_TRUE(paragraphs->LINQ_All([](SharedPtr<Node> p)
{ return (System::DynamicCast<Paragraph>(p))->get_ParagraphFormat()->get_FirstLineIndent() == 0.0; }));
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().StartsWith(u" Line 1"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().StartsWith(u" Line 2"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().StartsWith(u" Line 3"));
break;
ASSERT_TRUE(paragraphs->LINQ_All([](SharedPtr<Node> p)
{ return (System::DynamicCast<Paragraph>(p))->get_ParagraphFormat()->get_FirstLineIndent() == 0.0; }));
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().StartsWith(u"Line 1"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().StartsWith(u"Line 2"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().StartsWith(u"Line 3"));
break;
}
switch (txtTrailingSpacesOptions)
{
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().EndsWith(u"Line 1 \r"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().EndsWith(u"Line 2 \r"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().EndsWith(u"Line 3 \f"));
break;
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().EndsWith(u"Line 1\r"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().EndsWith(u"Line 2\r"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().EndsWith(u"Line 3\f"));
break;
}

◆ get_TrailingSpacesOptions()

Aspose::Words::Loading::TxtTrailingSpacesOptions Aspose::Words::Loading::TxtLoadOptions::get_TrailingSpacesOptions ( ) const

Gets or sets preferred option of a trailing space handling. Default value is Trim.

Examples

Shows how to trim whitespace when loading plaintext documents.

String textDoc = String(u" Line 1 \n") + u" Line 2 \n" + u" Line 3 ";
// Create a "TxtLoadOptions" object, which we can pass to a document's constructor
// to modify how we load a plaintext document.
auto loadOptions = MakeObject<TxtLoadOptions>();
// Set the "LeadingSpacesOptions" property to "TxtLeadingSpacesOptions.Preserve"
// to preserve all whitespace characters at the start of every line.
// Set the "LeadingSpacesOptions" property to "TxtLeadingSpacesOptions.ConvertToIndent"
// to remove all whitespace characters from the start of every line,
// and then apply a left first line indent to the paragraph to simulate the effect of the whitespaces.
// Set the "LeadingSpacesOptions" property to "TxtLeadingSpacesOptions.Trim"
// to remove all whitespace characters from every line's start.
loadOptions->set_LeadingSpacesOptions(txtLeadingSpacesOptions);
// Set the "TrailingSpacesOptions" property to "TxtTrailingSpacesOptions.Preserve"
// to preserve all whitespace characters at the end of every line.
// Set the "TrailingSpacesOptions" property to "TxtTrailingSpacesOptions.Trim" to
// remove all whitespace characters from the end of every line.
loadOptions->set_TrailingSpacesOptions(txtTrailingSpacesOptions);
auto doc = MakeObject<Document>(MakeObject<System::IO::MemoryStream>(System::Text::Encoding::get_UTF8()->GetBytes(textDoc)), loadOptions);
SharedPtr<ParagraphCollection> paragraphs = doc->get_FirstSection()->get_Body()->get_Paragraphs();
switch (txtLeadingSpacesOptions)
{
ASPOSE_ASSERT_EQ(37.8, paragraphs->idx_get(0)->get_ParagraphFormat()->get_FirstLineIndent());
ASPOSE_ASSERT_EQ(25.2, paragraphs->idx_get(1)->get_ParagraphFormat()->get_FirstLineIndent());
ASPOSE_ASSERT_EQ(6.3, paragraphs->idx_get(2)->get_ParagraphFormat()->get_FirstLineIndent());
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().StartsWith(u"Line 1"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().StartsWith(u"Line 2"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().StartsWith(u"Line 3"));
break;
ASSERT_TRUE(paragraphs->LINQ_All([](SharedPtr<Node> p)
{ return (System::DynamicCast<Paragraph>(p))->get_ParagraphFormat()->get_FirstLineIndent() == 0.0; }));
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().StartsWith(u" Line 1"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().StartsWith(u" Line 2"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().StartsWith(u" Line 3"));
break;
ASSERT_TRUE(paragraphs->LINQ_All([](SharedPtr<Node> p)
{ return (System::DynamicCast<Paragraph>(p))->get_ParagraphFormat()->get_FirstLineIndent() == 0.0; }));
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().StartsWith(u"Line 1"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().StartsWith(u"Line 2"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().StartsWith(u"Line 3"));
break;
}
switch (txtTrailingSpacesOptions)
{
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().EndsWith(u"Line 1 \r"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().EndsWith(u"Line 2 \r"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().EndsWith(u"Line 3 \f"));
break;
ASSERT_TRUE(paragraphs->idx_get(0)->GetText().EndsWith(u"Line 1\r"));
ASSERT_TRUE(paragraphs->idx_get(1)->GetText().EndsWith(u"Line 2\r"));
ASSERT_TRUE(paragraphs->idx_get(2)->GetText().EndsWith(u"Line 3\f"));
break;
}

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Loading::TxtLoadOptions::GetType ( ) const
overridevirtual

◆ Is()

virtual bool Aspose::Words::Loading::TxtLoadOptions::Is ( const System::TypeInfo target) const
overridevirtual

◆ set_DetectNumberingWithWhitespaces()

void Aspose::Words::Loading::TxtLoadOptions::set_DetectNumberingWithWhitespaces ( bool  value)

◆ set_DocumentDirection()

void Aspose::Words::Loading::TxtLoadOptions::set_DocumentDirection ( Aspose::Words::Loading::DocumentDirection  value)

◆ set_LeadingSpacesOptions()

void Aspose::Words::Loading::TxtLoadOptions::set_LeadingSpacesOptions ( Aspose::Words::Loading::TxtLeadingSpacesOptions  value)

◆ set_TrailingSpacesOptions()

void Aspose::Words::Loading::TxtLoadOptions::set_TrailingSpacesOptions ( Aspose::Words::Loading::TxtTrailingSpacesOptions  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::Loading::TxtLoadOptions::Type ( )
static