Aspose::Words::Drawing::OleFormat class

OleFormat class

Provides access to the data of an OLE object or ActiveX control. To learn more, visit the Working with Ole Objects documentation article.

class OleFormat : public System::Object

Methods

MethodDescription
get_AutoUpdate()Specifies whether the link to the OLE object is automatically updated or not in Microsoft Word.
get_Clsid()Gets the CLSID of the OLE object.
get_IconCaption()Gets icon caption of OLE object. In case if the OLE object does not have an icon or a caption cannot be retrieved, returns an empty string.
get_IsLink()Returns true if the OLE object is linked (when SourceFullName is specified).
get_IsLocked()Specifies whether the link to the OLE object is locked from updates.
get_OleControl()Gets OleControl objects if this OLE object is an ActiveX control. Otherwise this property is null.
get_OleIcon()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.
get_OlePackage()Provide access to OlePackage if OLE object is an OLE Package. Returns null otherwise.
get_ProgId()Gets or sets the ProgID of the OLE object.
get_SourceFullName()Gets or sets the path and name of the source file for the linked OLE object.
get_SourceItem()Gets or sets a string that is used to identify the portion of the source file that is being linked.
get_SuggestedExtension()Gets the file extension suggested for the current embedded object if you want to save it into a file.
get_SuggestedFileName()Gets the file name suggested for the current embedded object if you want to save it into a file.
GetOleEntry(const System::String&)Gets OLE object data entry.
GetRawData()Gets OLE object raw data.
GetType() const override
Is(const System::TypeInfo&) const override
Save(const System::SharedPtr<System::IO::Stream>&)Saves the data of the embedded object into the specified stream.
Save(const System::String&)Saves the data of the embedded object into a file with the specified name.
Save(std::basic_ostream<CharType, Traits>&)
set_AutoUpdate(bool)Setter for Aspose::Words::Drawing::OleFormat::get_AutoUpdate.
set_IsLocked(bool)Setter for Aspose::Words::Drawing::OleFormat::get_IsLocked.
set_ProgId(const System::String&)Setter for Aspose::Words::Drawing::OleFormat::get_ProgId.
set_SourceFullName(const System::String&)Setter for Aspose::Words::Drawing::OleFormat::get_SourceFullName.
set_SourceItem(const System::String&)Setter for Aspose::Words::Drawing::OleFormat::get_SourceItem.
static Type()

Remarks

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

Examples

Shows how to extract embedded OLE objects into files.

auto doc = MakeObject<Document>(MyDir + u"OLE spreadsheet.docm");
auto shape = System::ExplicitCast<Shape>(doc->GetChild(NodeType::Shape, 0, true));

// The OLE object in the first shape is a Microsoft Excel spreadsheet.
SharedPtr<OleFormat> oleFormat = shape->get_OleFormat();

ASSERT_EQ(u"Excel.Sheet.12", oleFormat->get_ProgId());

// Our object is neither auto updating nor locked from updates.
ASSERT_FALSE(oleFormat->get_AutoUpdate());
ASPOSE_ASSERT_EQ(false, oleFormat->get_IsLocked());

// If we plan on saving the OLE object to a file in the local file system,
// we can use the "SuggestedExtension" property to determine which file extension to apply to the file.
ASSERT_EQ(u".xlsx", oleFormat->get_SuggestedExtension());

// Below are two ways of saving an OLE object to a file in the local file system.
// 1 -  Save it via a stream:
{
    auto fs = MakeObject<System::IO::FileStream>(ArtifactsDir + u"OLE spreadsheet extracted via stream" + oleFormat->get_SuggestedExtension(),
                                                 System::IO::FileMode::Create);
    oleFormat->Save(fs);
}

// 2 -  Save it directly to a filename:
oleFormat->Save(ArtifactsDir + u"OLE spreadsheet saved directly" + oleFormat->get_SuggestedExtension());

See Also