Summary

To support linked objects in OLE Documents, any server or source of such links must provide a moniker that names the absolute location of the object's data. A source provides this moniker through data transfer mechanisms such as the clipboard and drag and drop. The moniker must name an object that implements the IOleObject and IDataObject interfaces, but this object doesn't actually need to exist until a container wants to bind to it.

As the source of a moniker, a linking server must also implement all the necessary binding support for whatever monikers it gives away, as explained in Chapter 9. This support typically represents the bulk of the implementation of the IPersistFile interface, one or more implementations of IOleItemContainer, and the management of the running object table (potentially with wildcard monikers). Such work is especially apparent when a container wants itself to be a source for the embedded objects and to that end implements a feature called "linking to embeddings." This gives the user the ability to link to data that exists only in an embedded object in some other compound document, a perfectly reasonable thing to do.

This chapter examines the implementation of a simple linking server using the Cosmo sample as a demonstration. Cosmo provides the ability to link to a "figure" that is the contents of an entire file and that requires only a file moniker to name it. This chapter also demonstrates a container that supports linking to embedding using the Patron sample. For this feature, Patron provides a File!Item!Item composite moniker to name an object on a page in a document. This process illustrates both complex binding support as a link source and the necessary steps to implement such linking as a container. Both the Cosmo sample provided here and an update to the in-process Polyline server support linking to embedding as well. Polyline requires an implementation of IExternalConnection to make the relationship with its container work properly, illustrating one of the primary uses for the interface.