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

KeySummaryCategory
SLIDESNET-38923Feature to identify read-protected and write-protected presentationsFeature 
SLIDESNET-41786Add the ability to validate password to modifyFeature
SLIDESNET-37280Support for Mathematical Equations (OMML)Feature
SLIDESNET-40011Align Multiple shapes in one lineFeature
SLIDESNET-38545Get real table row height, after the long text is added to cellEnhancement
SLIDESNET-41621Importing Excel EMF image has broken aspect ratioEnhancement

Other Improvements and Changes

KeySummaryCategory
SLIDESCPP-2209Use Aspose.Slides for .NET 20.5 featuresEnhancement 
SLIDESCPP-2129Add support for document digital signingEnhancement

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<Presentation>(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::MakeObject<Aspose::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:

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

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

/// <summary>
/// Returns the collection of signatures used to sign the presentation.
/// Read-only <see cref="IDigitalSignatureCollection"></see>.
/// </summary>
virtual System::SharedPtr<IDigitalSignatureCollection> 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:

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

/// <summary>
/// Checks whether a password to modify is correct for a write protected presentation.
/// </summary>
/// <param name="password">The password to check.</param>
/// <returns>
/// True if the presentation is write protected and the password is correct. False otherwise.
/// </returns>
/// <remarks>
/// 1. You should check the <see cref="IsWriteProtected"></see> property before calling this method.
/// 2. When password is null or empty, this method returns false.
/// </remarks>
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:

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

Example

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

auto presentation = System::MakeObject<Aspose::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:

/// <summary>
/// Gets a value that indicates whether a binded presentation is protected by a password to open.
/// </summary>
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<Presentation>();

// Create DigitalSignature object with PFX file and PFX password
auto signature = MakeObject<DigitalSignature>(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<Presentation>(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.");
}