Some support for linking is present in two of the sample parts, ODFDraw and ODFTable. Here are the differences between the two:
ODFDraw
- permits only one link to be created from a given shape
- doesn't support link selection
- doesn't show link borders
ODFTable
- a cell can be the source for multiple links
- a link is automatically selected when its cell is selected
- shows link borders only when the "Show Links" box is checked in the Document Info dialog
The “Paste As” Menu Command
In ODF1 the “Paste As” menu item was enabled by ODF whenever the clipboard contained a link spec. This is no longer the case: individual parts must enable this command as appropriate. The reason this changed is that Paste As may be used for other things besides linking; non-linking parts may wish to enable Paste As to do translation, for example.
ODFDraw: the Paste As command is undoable, and is implemented in CDrawClipboardCommand.
ODFTable: the Paste As command is undoable, and is implemented in CTableEditCommand.
Paste As Via Cmd-dragging
ODFDraw: see the class CDrawDropCommand. Note that it overrides DoDroppedPasteAs, which is called after the drop/PasteAs has already occurred. Another point of interest is that code for undo/redo of the two PasteAs commands is shared in the CDrawLinkManager methods UndoPasteAs and RedoPasteAs.
Show Link Info
ODFTable: The appropriate link info dialog is shown by ODF when a cell containing a link source or destination is selected.
Breaking Links
ODFTable: Links may be broken by clicking on the “Break Link” button in the Link Info dialog. ODF handles creation and execution of the undo-able commands FW_CBreakLinkSourceCommand and FW_CBreakLinkCommand.
Link Borders
ODFTable: Link borders are displayed when the "Show Links" box is checked in the Document Info window. (Note: you may have to move the grid lines to get them to show up.) CTableView::Draw checks the window's ShowLinks flag, and if it's set, iterates through the links and tells them to draw their link borders. See the override methods DoCreateLinkBorderShape and DoDrawLinkBorder in CTableLink and CTableLinkSource for an example of drawing link borders.
Link Selection
ODFTable: Links are automatically selected when their cell is selected. Selecting a link by clicking on its border is not yet implemented.