The user chooses the Insert command from the Document menu to select a document (or stationery) and embed it as a part within your part.
In order for your part to respond to the Insert menu command it should:
- Create a subclass of FW_CInsertCommand. Like any commands involving embedded frames this command must be undoable.
- Override FW_CEmbeddingFrame::NewInsertCommand and return an instance of your subclass of FW_CInsertCommand.
- Implement SingleEmbeddedFrameInternalized in the subclass of FW_CContent maintained by your selection object.
In response to the Insert menu command, by default ODF opens a file-access dialog box displaying all available OpenDoc documents and stationeries . The filtering is done by installing a file filter proc which tests that the file's creator is 'odtm'. You can change this behavior by overriding FW_CEmbeddingFrame::DoInsert and providing your own FW_COpenFileParameters parameter to FW_CChooseFile::ChooseFileToOpen.
All ODF samples supporting embedding (ODFDraw, ODFContainer, ODFEmbed, ODFTable) currently support the Insert Menu Command.
Embedding an OpenDoc Document
In the case where your part editor needs to embed another OpenDoc document or stationery without intervention by the user, ODF provides the function FW_ClonePartFromFile. This function located in FWEmdUtl.cpp allows you to clone a part from another document or stationery. Your code should look something like: