Introductions To Programming with Embedded Objects
Introduction
A chunk of data that can be shared between applications is referred to as an OLE object. The data can be shared by linking or it can be embedded. DataFlex supports embedded objects.
Embedded Objects and Compound Documents
Embedded objects can be considered individual pieces of a compound document. For example, embedded objects provide the mechanism to combine spreadsheets and text documents in a single application. Instead of creating a dedicated application for this purpose (a hybrid spreadsheet and word processor), you need only build an application that can "host" compound documents. The applications that host compound documents delegate responsibility for each embedded object to the application that created them.
The applications responsible for handling documents embedded within another application's documents are called OLE Servers. Applications that host embedded documents are called OLE Containers. DataFlex provides the capability for creating OLE Container applications.
Object Linking and Embedding
OLE stands for Object Linking and Embedding. Linking is simply embedding a link to another document. Embedding is embedding an actual document within another document. For example, embedding a spreadsheet within a Word document means that the spreadsheet is physically embedded in the Word document file. The saved document is then referred to as a compound document since it contains both the Word document itself and the embedded spreadsheet.
Since a DataFlex OLE container application is not a document-type application (like MS Word or Excel), an embedded document is not really saved within a host document. This is because, with DataFlex, there really is no host document. Instead, each embedded document is stored in an individual in-memory compound document.
OLE Server Responsibilities
With embedded documents, we are dealing directly with documents via an object-oriented interface. The OLE server application that created an embedded document is responsible for rendering the object and any possible editing. The host application does not need to know anything about the embedded document; it just needs to tell it to draw itself and possibly tell it to enter an in-place editing mode.
So, embedded documents are documents that expose two important features to the host:
- The ability to render themselves on any particular device.
- The ability to enter either in-place or external editing.
These are the only two features that are required in order to conform to document embedding.
Since we are dealing directly with a document, rather than, for example, a control containing a document, there is no notion of document loading. You can't load a document because a document object is a document. When instantiating an embedded object in your application, you must either create a brand new empty document or create a new document that is a copy of another document. See Creating Embedded Documents.
There's no standard interface for saving the document back to the file it was based on. Since you're not editing a file, you can't just easily save the modified document. If the document object supports Automation (e.g., MS Word), it's likely that it will expose a Save function through its Automation interface that you can use for this purpose. See Extended Embedded Objects.