5.8.1 Implementing an Undo Command

A client application can use the OleClone function to support the Edit menu's Undo command. A cloned object is identical to the original except for connections to the server application; the cloned object is not automatically connected to the server application. When the server application is closed and the object is updated, the saved copy gives the user the opportunity to undo all of the changes made in the server. Support for the Undo command is provided by the client application, because the server application cannot maintain a record of the prior states of objects.

The Undo command restores an object to its condition prior to the last update from the server. To support this behavior, the client application must clone the object when it is first activated and then clone the updated object when an update occurs; the client must retain two clones of the object. The clone of the original object must be retained so that an updated object can be restored if the user chooses the Undo command. The clone of the updated object must also be retained to support the Undo command if the updated object is updated again.

Because the client application cannot distinguish between different types of object activation, the client application must clone an object for verbs that do not edit the object, even though no updates can occur in those cases.