Objective Views : Chapter 15 OLE Document Servers : Server Item Serialization
Server Item Serialization
The OLE document server must provide persistence interfaces to the container item, so the linked or embedded document can be saved and restored by the container. This functionality is mapped by MFC to the COleServerItem::Serialize() method. You must override this method and make sure that it saves and restores the information in the document. If the item is embedded, then the entire document can be serialized using the Serialize() method of your COleServerDoc derived class. If the item is linked, then you must supply application-specific logic for serializing the link information.
Example 23 – Serializing server items
void CMyAppSrvrItem::Serialize(CArchive& ar)
{
if (!IsLinkedItem())
{
CMyAppDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Serialize(ar);
}
else
{
// Serialize information need to link to the
// document. This could be just a filename or
// some other information that points to the
// document.
}
}
Make sure the ColeServerDoc derived class serializes the model.
Example 24 – Serializing the model
void CMyAppDoc::Serialize(CArchive& ar)
{
// Serialize the model.
m_mdlCanvas.Serialize(ar);
}