Skip to main content

PresentationSecurityLoadingLimits Class

Specifies limits for presentation loading.

Declaration

public class PresentationSecurityLoadingLimits extends SecurityLoadingLimits

Remarks

Use the LoadOptions.getSecurityLoadingLimits() method to access the PresentationSecurityLoadingLimits object and configure limits before you load the presentation.

The following security loading limits are available:

  • Maximum presentation file size.
  • Maximum number of XML elements.
  • Maximum XML element nesting depth.
  • Maximum number of slides.
  • Maximum number of shapes per slide.

The following code snippet configures loading options, handles security violations, and loads a presentation with the specified security settings. The example throws an exception if the presentation exceeds a configured limit or contains restricted content, and logs the violation to the console:

package presentation;

import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;

import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        // Create load options.
        LoadOptions loadOptions = new LoadOptions();

        // Configure security loading limits.
        PresentationSecurityLoadingLimits limits = new PresentationSecurityLoadingLimits();
        limits.setMaxFileSize(50L * 1024 * 1024);
        limits.setMaxSlideCount(100);
        limits.setMaxShapeCountPerSlide(500);

        loadOptions.setSecurityLoadingLimits(limits);

        // Configure security loading options.
        PresentationSecurityLoadingOptions securityLoadingOptionsOptions = new PresentationSecurityLoadingOptions();
        securityLoadingOptionsOptions.setRemoveMacros(true);
        securityLoadingOptionsOptions.setRemoveOleObjects(true);
        securityLoadingOptionsOptions.setRemoveActiveXContent(true);
        securityLoadingOptionsOptions.setRemoveCustomXMLParts(true);

        loadOptions.setSecurityLoadingOptions(securityLoadingOptionsOptions);

        // Handle security loading violations.
        loadOptions.setSecurityLoadingHandler(new ISecurityLoadingHandler() {
            @Override
            public SecurityLimitAction handleLimitExceeded(
                    SecurityLimitExceededParams parameters) {

                System.out.println("Security limit exceeded: " + parameters.getPropertyName());
                return SecurityLimitAction.THROW;
            }

            @Override
            public SecurityViolationAction handleOptionsViolation(
                    SecurityOptionsViolationParams parameters) {

                System.out.println("Security option violated: " + parameters.getPropertyName());
                return SecurityViolationAction.REMOVE;
            }
        });

        try(FileInputStream inputStream = new FileInputStream("Presentation.pptx");
            Presentation presentation = new Presentation(inputStream, loadOptions)) {

            //...
        }
    }
}

Refer to the following help topic for additional information: Secure Presentation Processing.

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.initFields()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
JavaObject
SecurityLoadingLimits
PresentationSecurityLoadingLimits

PresentationSecurityLoadingLimits()

Initializes a new instance of the PresentationSecurityLoadingLimits class.

Declaration

public PresentationSecurityLoadingLimits()

Methods

getMaxShapeCountPerSlide() Method

Returns the maximum number of shapes that a slide can contain.

Declaration

public @Nullable Integer getMaxShapeCountPerSlide()

Returns

Type Description

The maximum number of shapes that a slide can contain.

getMaxSlideCount() Method

Returns the maximum number of slides that the presentation can contain.

Declaration

public @Nullable Integer getMaxSlideCount()

Returns

Type Description

The maximum number of slides that the presentation can contain.

setMaxShapeCountPerSlide(@Nullable Integer value) Method

Sets the maximum number of shapes that a slide can contain.

Declaration

public void setMaxShapeCountPerSlide(@Nullable Integer value)

Parameters

Name Type Description
value

The maximum number of shapes that a slide can contain.

setMaxSlideCount(@Nullable Integer value) Method

Sets the maximum number of slides that the presentation can contain.

Declaration

public void setMaxSlideCount(@Nullable Integer value)

Parameters

Name Type Description
value

The maximum number of slides that the presentation can contain.