OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Step 9: Loading and saving the server's documents

When a server gives objects to containers, the containers assume the burden of storing the objects in files and reading them back when necessary.

If your server can also run independently and load and save its own documents, it too should make use of the compound file capabilities built into TOleDocument. In its Open method, a server calls TOleDocument::Open. In its Commit method, a server should call TOleDocument::Commit and TOleDocument::CommitTransactedStorage.

// document class declaration derived from TOleDocument
class _DOCVIEWCLASS TMyDocument : public TOleDocument {
// declarations
}
// document class implementation
bool TMyDocument::Commit(bool force) {
TOleDocument::Commit(force); // save linked and embedded objects
.
.
// code to save other document data
TOleDocument::CommitTransactedStorage(); // write to file if transacted mode
}
bool TDrawDocument::Open(int, const char far*
path) {
TOleDocument::Open();
// load linked or embedded objects
.
.
// code to load other document data
}
Note
By default, TOleDocument opens compound files in transacted mode. Transacted mode saves changes in temporary storages until you call CommitTransactedStorage.