Aspose.Slides for CPP 20.5 Release Notes

Supported platforms

  • Aspose.Slides for C++ for Windows (Microsoft Visual C++).
  • Aspose.Slides for C++ for Linux (Clang).

New Features and Enhancements

Key Summary Category
SLIDESNET-38923 Feature to identify read-protected and write-protected presentations Feature 
SLIDESNET-41786 Add the ability to validate password to modify Feature
SLIDESNET-37280 Support for Mathematical Equations (OMML) Feature
SLIDESNET-40011 Align Multiple shapes in one line Feature
SLIDESNET-38545 Get real table row height, after the long text is added to cell Enhancement
SLIDESNET-41621 Importing Excel EMF image has broken aspect ratio Enhancement

Other Improvements and Changes

Key Summary Category
SLIDESCPP-2209 Use Aspose.Slides for .NET 20.5 features Enhancement 
SLIDESCPP-2129 Add support for document digital signing Enhancement

Public API Changes

Shapes alignment support has been added

Shapes alignment feature is used to change the placement of selected shapes on the slide. You may align shapes to the margins or the edge of the slide or align them relative to each other.

todo:image_alt_text

SlideUtil::AlignShapes()** **method and ShapesAlignmentType** **enum has been added to provide options from the picture above.

ShapesAlignmentType enum

The ShapesAlignmentType determines the type of shapes alignment: AlignLeft, AlignRight, AlignCenter, AlignTop, AlignMiddle, AlignBottom, DistributeHorizontally, DistributeVertically.

SlideUtil::AlignShapes() method

SlideUtil::AlignShapes() method changes the placement of selected shapes on the slide. The method’s input parameters:

  • ShapesAlignmentType alignmentType - determines which type of alignment will be applied.
  • bool alignToSlide- if true, shapes will be aligned relatively to the slide edges, otherwise shapes will be aligned relatively to each other.
  • SharedPtr slide - parent slide.
  • ArrayPtr<int32_t> shapeIndexes - indexes of shapes to be aligned.
  • SharedPtr shapes - collection of shapes to be aligned.

Example 1

Let’s say we want to align shapes with indexes 1, 2 and 4 along the top border of the slide.

todo:image_alt_text

Solution

using namespace System; using namespace Aspose::Slides;

auto pres = MakeObject(u"example.pptx”); auto slide = pres->get_Slides()->idx_get(0); auto shape1 = slide->get_Shapes()->idx_get(1); auto shape2 = slide->get_Shapes()->idx_get(2); auto shape3 = slide->get_Shapes()->idx_get(4); SlideUtil::AlignShapes(Aspose::Slides::ShapesAlignmentType::AlignTop, true, pres->get_Slides()->idx_get(0),     MakeArray<int32_t>({         slide->get_Shapes()->IndexOf(shape1),         slide->get_Shapes()->IndexOf(shape2),         slide->get_Shapes()->IndexOf(shape3)     }));

The result is the following:

todo:image_alt_text

Example 2

Here is another example, showing how to align the entire collection of shapes on the slide:

auto pres = System::MakeObjectAspose::Slides::Presentation(u"example.pptx”); SlideUtil::AlignShapes(Aspose::Slides::ShapesAlignmentType::AlignBottom, false, pres->get_Slides()->idx_get(0)->get_Shapes());

IDigitalSignature interface and DigitalSignature class have been added

DigitalSignature** **class has been added, which implements IDigitalSignature** **interface and stores information about digital signature based on the certificate, which is used or will be used to sign the presentation.

IDigitalSignature interface declaration:

///

/// Digital signature in signed file. /// class IDigitalSignature : public System::Object { public:    ///    /// Certificate object that was used to sign the document.    /// Read-only .    ///    virtual System::SharedPtrSystem::Security::Cryptography::X509Certificates::X509Certificate2 get_Certificate() = 0;    ///    /// If this digital signature is valid and the document has not been tampered with, this value will be true.    /// Read-only .    ///    virtual bool get_IsValid() = 0;    ///    /// The time when the document was signed.    /// Read-only .    ///    virtual System::DateTime get_SignTime() = 0;    ///    /// The purpose of signature.    /// Read .    ///    virtual System::String get_Comments() = 0;    ///    /// The purpose of signature.    /// Write .    ///    virtual void set_Comments(System::String value) = 0; };

IDigitalSignatureCollection interface and DigitalSignatureCollection class have been added

DigitalSignatureCollection class has been added, which implements IDigitalSignatureCollection interface and represents a collection of digital signatures that were used or will be used to sign the presentation.

IDigitalSignatureCollection interface declaration:

///

/// Represents a collection of digital signatures attached to a document. /// class IDigitalSignatureCollection : public Aspose::Slides::IGenericCollection<System::SharedPtrAspose::Slides::IDigitalSignature> { public:    ///    /// Returns the signature by index.    ///    virtual System::SharedPtr idx_get(int32_t index) = 0;    ///    /// Adds the signature at the end of collection.    ///    /// Signature to add.    virtual void Add(System::SharedPtr digitalSignature) = 0;    ///    /// Removes the signature at the specified index.    ///    /// Index of the signature that should be deleted.    virtual void RemoveAt(int32_t index) = 0;    ///    /// Removes all signatures from collection.    ///    virtual void Clear() = 0; };

IPresentation::get_DigitalSignatures() method has been added

get_DigitalSignatures() method has been added to IPresentation interface and Presentation class. It allows accessing a collection of digital signatures that have been used to sign the presentation or add digital signatures that will be used to sign the presentation.

get_DigitalSignatures()** **method declaration:

///

/// Returns the collection of signatures used to sign the presentation. /// Read-only . /// virtual System::SharedPtr get_DigitalSignatures() = 0;

Check a write protection password via IPresentationInfo interface

get_IsWriteProtected() and CheckWriteProtection()** **methods have been added to IPresentationInfo** **interface and PresentationInfo** **class. These methods allow checking whether a presentation is protected by a password to modify. The password to modify is intended to set write protection on the presentation. Write protection restricts the ability to save the presentation to the same path using host applications.

Methods declaration:

///

/// Gets a value that indicates whether a binded presentation is write protected. /// /// /// If the presentation is protected by a password to open, the property value equals NotDefined. /// See enumeration. /// virtual NullableBool get_IsWriteProtected() = 0;

///

/// Checks whether a password to modify is correct for a write protected presentation. /// /// The password to check. /// /// True if the presentation is write protected and the password is correct. False otherwise. /// /// /// 1. You should check the property before calling this method. /// 2. When password is null or empty, this method returns false. /// virtual bool CheckWriteProtection(System::String password) = 0;

Example

The example below demonstrates how to check if there is a password set for protecting presentation from modifying:

auto info = Aspose::Slides::PresentationFactory::get_Instance()->GetPresentationInfo(presentationFilePath); bool isWriteProtectedByPassword = info->get_IsWriteProtected() == Aspose::Slides::NullableBool::True &&                                   info->CheckWriteProtection(u"my_password”);

Check a write protection password via IProtectionManager interface

CheckWriteProtection()** **method has been added to the IProtectionManager** **interface and ProtectionManager** **class. This method allows checking whether a presentation is password protected from modifying. The password against modifying is intended to set write protection on the presentation. Write protection restricts the ability to save the presentation to the same path using host applications.

Method declaration:

///

/// Checks whether a password to modify is correct for a write protected presentation. /// /// The password to check. /// /// True if the presentation is write protected and the password is correct. False otherwise. /// /// /// 1. You should check the property before calling this method. /// 2. When password is null or empty, this method returns false. /// virtual bool CheckWriteProtection(System::String password) = 0;

Example

The example below demonstrates how to check a password protection from modifying:

auto presentation = System::MakeObjectAspose::Slides::Presentation(presentationFilePath); bool isWriteProtected = presentation->get_ProtectionManager()->CheckWriteProtection(u"my_password”);

Check an open protection of the presentation via IPresentationInfo interface

get_IsPasswordProtected() method has been added to IPresentationInfo interface and PresentationInfo** **class. This property allows checking whether a presentation is protected from openning. The presentation has a protection from openning when the password is set to the document.

get_IsPasswordProtected()** **method declaration:

///

/// Gets a value that indicates whether a binded presentation is protected by a password to open. /// virtual bool get_IsPasswordProtected() = 0;

Example

The example below demonstrates how to check the open protection:

auto info = Aspose::Slides::PresentationFactory::get_Instance()->GetPresentationInfo(presentationFilePath); if (info->get_IsPasswordProtected()) {     System::Console::WriteLine(u"The presentation ‘{0}’ is protected by password to open.”, presentationFilePath); }

Digital Signature in PowerPoint

Digital certificate is used to create a password-protected PowerPoint presentation, marked as created by a particular organization or person. Digital certificate can be obtained by contacting an authorized organization - a certificate authority. After installing the digital certificate into the system, it can be used to add a digital signature to the presentation via File -> Info -> Protect Presentation:

todo:image_alt_text

The presentation may contain more than one digital signatures. After the digital signature is added to the presentation, a special message will appear in the PowerPoint:

todo:image_alt_text

To sign a presentation or check the authenticity of presentation signatures, Aspose.Slides API provides IDigitalSignature interface, IDigitalSignatureCollection interface andIPresentation::get_DigitalSignatures method. Currently, digital signatures are supported for PPTX format only.

Add digital signature from PFX Certificate

The code sample below demonstrates how to add a digital signature from a PFX certificate:

\1. Open PFX file and pass the PFX password to DigitalSignature object.

\2. Add a created signature to the presentation object.

using namespace System; using namespace Aspose::Slides;

auto pres = MakeObject();

// Create DigitalSignature object with PFX file and PFX password auto signature = MakeObject(u"testsignature1.pfx”, u"testpass1”);

// Comment new digital signature signature->set_Comments(u"Aspose.Slides digital signing test.");

// Add digital signature to presentation pres->get_DigitalSignatures()->Add(signature);

// Save presentation pres->Save(u"SomePresentationSigned.pptx”, Export::SaveFormat::Pptx);

Now its possible to check if the presentation was digitally signed and has not been modified:

using namespace System; using namespace Aspose::Slides;

// Open presentation auto pres = MakeObject(u"SomePresentationSigned.pptx”); if (pres->get_DigitalSignatures()->get_Count() > 0) {    bool allSignaturesAreValid = true;

    Console::WriteLine(u"Signatures used to sign the presentation: “);

   // Check if all digital signatures are valid    for (int32_t i = 0; i < pres->get_DigitalSignatures()->get_Count(); ++i)     {        auto signature = pres->get_DigitalSignatures()->idx_get(i);         Console::WriteLine(u”{0}, {1} — {2}”,             signature->get_Certificate()->get_SubjectName()->get_Name(),             signature->get_SignTime().ToString(u"yyyy-MM-dd HH:mm”),             (signature->get_IsValid() ? u"VALID” : u"INVALID”));         allSignaturesAreValid &= signature->get_IsValid();     }

   if (allSignaturesAreValid)         Console::WriteLine(u"Presentation is genuine, all signatures are valid.");    else         Console::WriteLine(u"Presentation has been modified since signing."); }