com.aspose.words

Class OleFormat

  • java.lang.Object
    • com.aspose.words.OleFormat
public class OleFormat 
extends java.lang.Object

Provides access to the data of an OLE object or ActiveX control.

Use the Shape.OleFormat property to access the data of an OLE object. You do not create instances of the OleFormat class directly.

See Also:
Shape.OleFormat

Property Getters/Setters Summary
booleangetAutoUpdate()
void
setAutoUpdate(booleanvalue)
           Specifies whether the link to the OLE object is automatically updated or not in Microsoft Word.
java.util.UUIDgetClsid()
Gets the CLSID of the OLE object.
java.lang.StringgetIconCaption()
Gets icon caption of OLE object.

In case of OLE object is not embedded as icon or caption couldn't be retrieved returns empty string.

booleanisLink()
Returns true if the OLE object is linked (when SourceFullName is specified).
booleanisLocked()
void
isLocked(booleanvalue)
           Specifies whether the link to the OLE object is locked from updates.
OleControlgetOleControl()
Gets OleControl objects if this OLE object is an ActiveX control. Otherwise this property is null.
booleangetOleIcon()
Gets the draw aspect of the OLE object. When true, the OLE object is displayed as an icon. When false, the OLE object is displayed as content.
OlePackagegetOlePackage()
Provide access to OlePackage if OLE object is an OLE Package. Returns null otherwise.
java.lang.StringgetProgId()
void
setProgId(java.lang.Stringvalue)
           Gets or sets the ProgID of the OLE object.
java.lang.StringgetSourceFullName()
void
setSourceFullName(java.lang.Stringvalue)
           Gets or sets the path and name of the source file for the linked OLE object.
java.lang.StringgetSourceItem()
void
setSourceItem(java.lang.Stringvalue)
           Gets or sets a string that is used to identify the portion of the source file that is being linked.
java.lang.StringgetSuggestedExtension()
Gets the file extension suggested for the current embedded object if you want to save it into a file.
java.lang.StringgetSuggestedFileName()
Gets the file name suggested for the current embedded object if you want to save it into a file.
 
Method Summary
System.IO.MemoryStreamgetOleEntry(java.lang.String oleEntryName)
Gets a named stream from OLE object data.
voidsave(java.io.OutputStream stream)
Saves the data of the embedded object into the specified stream.
voidsave(java.lang.String fileName)
Saves the data of the embedded object into a file with the specified name.
 

    • Property Getters/Setters Detail

      • getAutoUpdate/setAutoUpdate

        public boolean getAutoUpdate() / public void setAutoUpdate(boolean value)
        
        Specifies whether the link to the OLE object is automatically updated or not in Microsoft Word.

        The default value is false.

      • getClsid

        public java.util.UUID getClsid()
        
        Gets the CLSID of the OLE object.
      • getIconCaption

        public java.lang.String getIconCaption()
        
        Gets icon caption of OLE object.

        In case of OLE object is not embedded as icon or caption couldn't be retrieved returns empty string.

      • isLink

        public boolean isLink()
        
        Returns true if the OLE object is linked (when SourceFullName is specified).
      • isLocked/isLocked

        public boolean isLocked() / public void isLocked(boolean value)
        
        Specifies whether the link to the OLE object is locked from updates.

        The default value is false.

      • getOleControl

        public OleControl getOleControl()
        
        Gets OleControl objects if this OLE object is an ActiveX control. Otherwise this property is null.
      • getOleIcon

        public boolean getOleIcon()
        
        Gets the draw aspect of the OLE object. When true, the OLE object is displayed as an icon. When false, the OLE object is displayed as content.

        Aspose.Words does not allow to set this property to avoid confusion. If you were able to change the draw aspect in Aspose.Words, Microsoft Word would still display the OLE object in its original draw aspect until you edit or update the OLE object in Microsoft Word.

      • getOlePackage

        public OlePackage getOlePackage()
        
        Provide access to OlePackage if OLE object is an OLE Package. Returns null otherwise. OLE Package is a legacy technology that allows to wrap any file format not present in the OLE registry of a Windows system into a generic package allowing to embed almost anything into a document. See OlePackage type for more info.

        Example:

        Shows how insert ole object as ole package and set it file name and display name.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        byte[] zipFileBytes = Files.readAllBytes(Paths.get(getDatabaseDir() + "cat001.zip"));
        
        InputStream stream = new ByteArrayInputStream(zipFileBytes);
        try /*JAVA: was using*/
        {
            Shape shape = builder.insertOleObject(stream, "Package", true, null);
        
            OlePackage setOlePackage = shape.getOleFormat().getOlePackage();
            setOlePackage.setFileName("Cat FileName.zip");
            setOlePackage.setDisplayName("Cat DisplayName.zip");
        
            doc.save(getMyDir() + "\\Artifacts\\Shape.InsertOlePackage.docx");
        } finally
        {
            if (stream != null) stream.close();
        }
      • getProgId/setProgId

        public java.lang.String getProgId() / public void setProgId(java.lang.String value)
        
        Gets or sets the ProgID of the OLE object.

        The ProgID property is not always present in Microsoft Word documents and cannot be relied upon.

        Cannot be null.

        The default value is an empty string.

      • getSourceFullName/setSourceFullName

        public java.lang.String getSourceFullName() / public void setSourceFullName(java.lang.String value)
        
        Gets or sets the path and name of the source file for the linked OLE object.

        The default value is an empty string.

        If SourceFullName is not an empty string, the OLE object is linked.

      • getSourceItem/setSourceItem

        public java.lang.String getSourceItem() / public void setSourceItem(java.lang.String value)
        
        Gets or sets a string that is used to identify the portion of the source file that is being linked.

        The default value is an empty string.

        For example, if the source file is a Microsoft Excel workbook, the SourceItem property might return "Workbook1!R3C1:R4C2" if the OLE object contains only a few cells from the worksheet.

      • getSuggestedExtension

        public java.lang.String getSuggestedExtension()
        
        Gets the file extension suggested for the current embedded object if you want to save it into a file.
      • getSuggestedFileName

        public java.lang.String getSuggestedFileName()
        
        Gets the file name suggested for the current embedded object if you want to save it into a file.

        Example:

        Shows how to get suggested file name from the object.
        Document doc = new Document(getMyDir() + "Shape.SuggestedFileName.rtf");
        
        // Gets the file name suggested for the current embedded object if you want to save it into a file
        Shape oleShape = (Shape) doc.getFirstSection().getBody().getChild(NodeType.SHAPE, 0, true);
        String suggestedFileName = oleShape.getOleFormat().getSuggestedFileName();
    • Method Detail

      • getOleEntry

        public System.IO.MemoryStream getOleEntry(java.lang.String oleEntryName)
        Gets a named stream from OLE object data.
        Parameters:
        oleEntryName - Case-sensitive name of the OLE data stream.
        Returns:
        An OLE data stream or null.
      • save

        public void save(java.io.OutputStream stream)
                 throws java.lang.Exception
        Saves the data of the embedded object into the specified stream.

        It is the responsibility of the caller to dispose the stream.

        Parameters:
        stream - Where to save the object data.
      • save

        public void save(java.lang.String fileName)
                 throws java.lang.Exception
        Saves the data of the embedded object into a file with the specified name.
        Parameters:
        fileName - Name of the file to save the OLE object data.