2.1.2 Placing Data on the Clipboard

The particular data formats and the order in which they are put on the clipboard determine how an OLE object is treated by the clipboard. When the user wants to paste an OLE object from the clipboard, the available data formats and their order determines whether the object can be treated as linked, embedded, or both linked and embedded. For more information on cutting and copying data to the clipboard, see Chapter 4, "Implementing OLE into Server Applications."

2.1.2.1 Clipboard Contents and Available Object Types

The following table lists several possible clipboard states, with varying types and orders of data.

Order of Clipboard Formats Embedded Object Available? Linked Object Available?

1. Native
2. OwnerLink
3. CF_METAFILEPICT
Yes - Native and OwnerLink formats define the object and presentation format is CF_METAFILEPICT. No - ObjectLink format is missing and Native format precedes OwnerLink.
1. Native
2. OwnerLink
3. CF_METAFILEPICT
4. ObjectLink
Yes - Native and OwnerLink formats define the object and presentation format is CF_METAFILEPICT. Yes - ObjectLink format defines the link and presentation format is CF_METAFILEPICT.
1. OwnerLink
2. Native
No - OwnerLink comes before Native. Yes - OwnerLink format defines the link and Native format can be used to render the object's presentation.
1. Native
2. OwnerLink
3. CF_BITMAP
4. CF_DIB
5. CF_METAFILEPICT
6. ObjectLink
Yes - Native and OwnerLink formats define the object and presentation format is CF_BITMAP because it was first on the clipboard. Yes - ObjectLink format defines the link and presentation format is CF_BITMAP.
1. OwnerLink
2. Native
3. CF_METAFILEPICT
No - OwnerLink comes before Native. Yes - OwnerLink format defines the link and presentation format is CF_METAFILEPICT.
1. Native
2. CF_METAFILEPICT
No - OwnerLink format is missing. No - ObjectLink format is missing.

Rules for Inserting Embedded Objects

In order for a client application to embed an object, the server application must put the correct presentation formats on the clipboard. Typically, a server application places Native data, OwnerLink, and at least one presentation data format on the clipboard to support embedding.

Rules for Inserting Linked Objects

In order for a client application to create a link to an object, the server application must put the correct presentation formats on the clipboard. Typically, a server application places ObjectLink and a presentation data format on the clipboard to enable client applications to create links to objects.

2.1.2.2 Order of Clipboard Data Formats

The most common order for clipboard formats is:

1.Preferred server application data formats (for example, BIFF, SYLK, RTF)

2.Native data

3.OwnerLink data

4.Presentation formats (CF_METAFILEPICT, CF_BITMAP, or CF_DIB)

5.ObjectLink data

These formats are in addition to the server application data formats normally placed on the clipboard to support Copy and Paste operations. This is a Microsoft Windows clipboard management convention, and is not specific to OLE. These formats should be provided by the server application in case the container document understands the server's data.

Before placing an object on the clipboard, a server application must put descriptions of the data format on the clipboard. These data formats are listed in order of their fidelity of object description, from most descriptive to least. When a user chooses the Paste command, the client application must query the clipboard for its current formats and use the first format that is compatible with the container document for the object.

Because server applications put data onto the clipboard in order of their fidelity of description, the first acceptable format found by a client application is the best format for it to use for an embedded object. If the client application finds an acceptable format prior to the Native format, it incorporates the data directly into the container document without making it an embedded object. For example, a Microsoft Word document would not embed an object from clipboard data that was in RTF format, it would simply include the text as part of its own document. However, if the client application cannot accept any of the data formats placed on the clipboard prior to Native and OwnerLink, it must use those formats to insert an embedded object and then display the object by using one of the presentation data formats.

Note If a container's preferred format is on the clipboard, it is recommended that the client application choose that format instead of pasting the data as an OLE object. For example, when copying a range of cells to some other portion of a worksheet document, it makes sense to paste the clipboard data as an OLE object since inserting an OLE object would add unnecessary size and complexity to the document.

When a user chooses the Paste Link command, the client application must check to see if the ObjectLink format is on the clipboard, using one of the OLE query functions, and ignore the Native and OwnerLink formats. If the application finds the ObjectLink format and a useful presentation format, it uses them to make an OLE link to the source document for the object.

2.1.2.3 Order of Presentation Data Formats

The order of the presentation formats also determines which of the standard presentation formats the OLE libraries use. For example, if CF_BITMAP is provided before CF_METAFILEPICT, then the OLE library will use the bitmap representation to render the object. This is important, since the OLE libraries only provide simple scaling of objects. Metafiles provide better scaling than bitmaps, so it is preferable for server applications to provide CF_METAFILEPICT before any other graphic representations (such as CF_DIB and CF_BITMAP). Currently, the OLE libraries only support the CF_METAFILEPICT, CF_DIB, and CF_BITMAP presentation formats.

Note Server applications must support CF_METAFILEPICT format. The server application can provide any of the presentation formats when placing an object on the clipboard, but when the OLE libraries request data directly from the server, the server must provide the object in CF_METAFILEPICT format.