Are you looking to process PowerPoint presentations in C++ applications on Linux? Look no further than Aspose.Slides for C++ 24.6. This release offers text highlighting and replacement within presentations, better handling of corrupted PPTX files, and much more.
Work with Text Highlighting and Patterns
Boost the visual appeal of your slides effortlessly by highlighting particular text or text patterns with and without regular expressions. The ITextFrame::HighlightText
and ITextFrame::HighlightRegex
methods added in the latest release allow highlighting specified text or text patterns within a TextFrame
. This code example showcases how text can be highlighted in a text frame:
auto presentation = System::MakeObject<Presentation>(u"pres.pptx");
// highlighting all words 'important'
(System::ExplicitCast<Aspose::Slides::AutoShape>(presentation->get_Slide(0)->get_Shape(0)))->get_TextFrame()->HighlightText(u"important", System::Drawing::Color::get_LightBlue());
auto textSearchOptions = System::MakeObject<TextSearchOptions>();
textSearchOptions->set_WholeWordsOnly(true);
// highlighting all separate 'the' occurrences
(System::ExplicitCast<Aspose::Slides::AutoShape>(presentation->get_Slide(0)->get_Shape(0)))->get_TextFrame()->HighlightText(u"the", System::Drawing::Color::get_Violet(), textSearchOptions, nullptr);
presentation->Save(u"pres-out2.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
Source*
Similarly, the following coding sample explains how to highlight text using Regex (regular expression) in a text frame:
auto presentation = System::MakeObject<Presentation>(u"pres.pptx");
System::SharedPtr<System::Text::RegularExpressions::Regex> regex = System::MakeObject<System::Text::RegularExpressions::Regex>(u"\\b[^\\s]{10,}\\b");
// highlighting all words with 10 or more characters
(System::ExplicitCast<Aspose::Slides::AutoShape>(presentation->get_Slide(0)->get_Shape(0)))->get_TextFrame()->HighlightRegex(regex, System::Drawing::Color::get_Blue(), nullptr);
presentation->Save(u"SomePresentation-out.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
Source*
Replacing Text and Text Patterns in Linux
Developers can also replace text with alternative content for efficient editing using the latest C++ presentations library version. Please check out the following code example, which illustrates how to replace text in C++:
auto presentation = System::MakeObject<Presentation>(u"pres.pptx");
auto textSearchOptions = System::MakeObject<TextSearchOptions>();
textSearchOptions->set_WholeWordsOnly(true);
// Replace all separate 'the' occurrences with '***'
(System::ExplicitCast<Aspose::Slides::AutoShape>(presentation->get_Slide(0)->get_Shape(0)))->get_TextFrame()->ReplaceText(u"the", u"***", textSearchOptions, nullptr);
presentation->Save(u"SomePresentation-out2.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
Source*
Optimized Handling of Corrupted PPTX Files
Aspose.Slides for C++ 24.6 provides improved flexibility when loading the corrupt PPTX files on Linux, reducing errors and ensuring an enhanced development experience.
Utilize Aspose.Slides for .NET Features
Users can now integrate the enhancements made in Aspose.Slides for .NET into their C++ apps and work with a more comprehensive feature set.
Search Text With the ITextSearchOptions
Interface
The newly added ITextSearchOptions
interface in this C++ PowerPoint presentations API provides options for text search within presentations, slides, or TextFrame
on the Linux platform. This sample code demonstrates the feature usage in C++:
auto presentation = System::MakeObject<Presentation>(u"pres.pptx");
auto textSearchOptions = System::MakeObject<TextSearchOptions>();
textSearchOptions->set_WholeWordsOnly(true);
presentation->ReplaceText(u"the", u"***", textSearchOptions, nullptr);
presentation->Save(u"pres-out.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
Source*
Retrieve Text Search Results Easily
A new IFindResultCallback
interface introduced in Aspose.Slides for C++ 24.6 delivers a callback method for fetching search results while using text search functionalities. The following code example shows how to utilize this feature in C++:
class FindResultCallback : public Aspose::Slides::IFindResultCallback
{
public:
void FoundResult(System::SharedPtr<ITextFrame> textFrame, System::String oldText, System::String foundText, int32_t textPosition) override
{
//Handling the results...
}
};
class Example
{
public:
void Execute()
{
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(u"pres.pptx");
System::SharedPtr<FindResultCallback> callback = System::MakeObject<FindResultCallback>();
// Highlight all words "address".
pres->HighlightText(u"address", System::Drawing::Color::get_Yellow(), System::MakeObject<TextSearchOptions>(), callback);
pres->Save(u"pres-out.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
}
};
Source*
Public API Changes
Obsolete Interfaces and Classes
The following interfaces and classes have been marked as obsolete and will be removed in version 24.10:
- ITextHighlightingOptions class
- TextHighlightingOptions class
Obsolete Methods
Several methods related to text highlighting have been marked as obsolete and will be removed in version 24.10. These include:
- ITextFrame::HighlightText(System::String text, System::Drawing::Color highlightColor, System::SharedPtr options)
- ITextFrame::HighlightRegex(System::String regex, System::Drawing::Color highlightColor, System::SharedPtr options)
- TextFrame::HighlightText(System::String text, System::Drawing::Color highlightColor, System::SharedPtr options)
- TextFrame::HighlightRegex(System::String regex, System::Drawing::Color highlightColor, System::SharedPtr options)
You can view the list of all new features, enhancements, and bug fixes introduced in this release by visiting Aspose.Slides for C++ 24.6 Release Notes.