Aspose.Slides for C++ 24.6 (Windows) facilitates developers working on presentations in their C++ applications with functionalities such as highlighting and replacing text within presentations, improved handling of corrupted PPTX files, and more.
Text Highlighting and Patterns
Enhance the visual appeal of your slides seamlessly by highlighting specific text and text patterns using text or regular expressions. The ITextFrame::HighlightText
and ITextFrame::HighlightRegex
methods introduced in this release enable highlighting specific 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*
Replace Text and Text Patterns
With this C++ presentations library version, developers can also replace text with alternative content for efficient editing. 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*
Improved Corrupted PPTX Handling
Aspose.Slides for C++ 24.6 offers better resilience while loading the corrupt PPTX files on Windows, minimizing errors and ensuring a refined development experience.
Leveraging Aspose.Slides for .NET Features
Developers can benefit from enhancements made in Aspose.Slides for .NET, incorporated into this C++ version to provide a more comprehensive feature set.
Introducing the ITextSearchOptions
Interface
A new interface, ITextSearchOptions
, has been introduced in the latest C++ PowerPoint presentations API to provide options for text search within presentations, slides, or TextFrames
on the Windows 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*
Fetch Text Search Results
We have added a new IFindResultCallback
interface in Aspose.Slides for C++ 24.6, which offers a callback method for retrieving search results when 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.