IOpcPartSet::CreatePart method

Creates a part object that represents a part and adds a pointer to the object's IOpcPart interface to the set.

Syntax


HRESULT CreatePart(
  [in]          IOpcPartUri             *name,
  [in]          LPCWSTR                 contentType,
  [in]          OPC_COMPRESSION_OPTIONS compressionOptions,
  [out, retval] IOpcPart                **part
);

Parameters

name [in]

A pointer to the IOpcPartUri interface of a part URI object that represents the part name of the part.

To create a part URI object (which implements the IOpcPartUri interface) to represent the part name of the part, call the IOpcFactory::CreatePartUri method.

contentType [in]

The media type of part content.

compressionOptions [in]

A value that describes the way to compress the part content of the part.

part [out, retval]

A pointer to the new IOpcPart that represents the part.

This parameter cannot be NULL.

Return value

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code/valueDescription
S_OK

The method succeeded.

E_POINTER

The name parameter is NULL.

E_INVALIDARG

The value passed in the compressionOptions parameter is not a valid OPC_COMPRESSION_OPTIONS enumeration value.

OPC_E_DUPLICATE_PART
0x8051000B

A part with the specified part name already exists in the current package.

OPC_E_INVALID_CONTENT_TYPE
0x80510044

A content type does not conform to the rules for a valid media type, specified in RFC 2616: HTTP/1.1 (http://go.microsoft.com/fwlink/p/?linkid=143979) and the OPC.

OPC_E_UNEXPECTED_CONTENT_TYPE
0x80510005

Either the content type of a part differed from the expected content type (specified in the OPC, ECMA-376 Part 2), or the part content did not match the part's content type.

Package Consumption error

An HRESULT error code from the Package Consumption Error Group.

Part URI error

An HRESULT error code from the Part URI Error Group.

 

Remarks

When a part object is created and a pointer to it is added to the set, the part it represents is serialized when the package is serialized.

This method cannot create a part object that represents a Relationships part.

If part content is compressed prior to the creation of the part object, pass the OPC_COMPRESSION_NONE value in the compressionOptions parameter.

Part content that is already compressed will not compress significantly more.

An IOpcPart provides access to the properties of a part. For details about these properties, see the Parts Overview and the IOpcPart topic.

Thread Safety

Packaging objects are not thread-safe.

For more information, see the Getting Started with the Packaging API.

Requirements

Minimum supported client

Windows 7 [desktop apps only]

Minimum supported server

Windows Server 2008 R2 [desktop apps only]

Header

Msopc.h

IDL

Opcobjectmodel.idl

See also

IOpcPartSet
Overviews
Getting Started with the Packaging API
Parts Overview
Reference
IOpcFactory::CreatePartUri
OPC_COMPRESSION_OPTIONS
Packaging Errors
Packaging API Reference
Packaging API Samples
External Resources
ECMA-376 OpenXML
RFC 2616: HTTP/1.1

 

 

Show: