home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / source / bento / headers / linkmgr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-02  |  8.7 KB  |  264 lines

  1. /*
  2.     File:        LinkMgr.h
  3.  
  4.     Contains:    Class definition for XMPLinkManager.
  5.  
  6.     Written by:    Craig Carper 
  7.  
  8.     Copyright:    ⌐ 1993 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <10>     2/15/94    CC        Bug #1142928 - Added document parameter to
  13.                                     ReserveSectionID.
  14.          <9>      2/4/94    Té        fixes to compile with PPC Universal
  15.                                     headers, don't use Pascal Strings as
  16.                                     parameters
  17.          <8>     1/21/94    CC        Removed RemoveAllLinksInCollection() and
  18.                                     DeleteEditionFiles(); ExportOnSave() takes
  19.                                     doExport parameter.
  20.          <7>     1/18/94    CC        Added AnyLinkImported(); Changed
  21.                                     DraftClosed() to DraftClosing(); added
  22.                                     linksImported field to DraftInfo struct.
  23.          <6>     1/14/94    CC        Added methods UnsavedExportedLinks(),
  24.                                     DraftOpened(), DraftSaved(), DraftClosed(),
  25.                                     and private support routines; added
  26.                                     DraftInfo type and fDraftInfos field.
  27.          <5>     1/11/94    Té        Init... changes
  28.          <4>    12/22/93    CC        Added DraftOpened() method to test
  29.                                     LinkIter.cp.
  30.          <3>    12/22/93    CC        Use document not draft for persistent
  31.                                     globals.
  32.          <2>    12/16/93    CC        Moved code from XMPDraft::GetLink() into
  33.                                     CreateLink.  Added methods to maintain
  34.                                     Edition files for cross-document links.
  35.          <1>     12/8/93    CC        first checked in
  36.     To Do:
  37. */
  38.  
  39. #ifndef _LINKMGR_
  40. #define _LINKMGR_
  41.  
  42. #ifndef _PLFMDEF_
  43. #include "PlfmDef.h"
  44. #endif
  45.  
  46. #ifndef _XMPTYPES_
  47. #include "XMPTypes.h"
  48. #endif
  49.  
  50. #ifndef _STORAGEU_
  51. #include "StorageU.h"
  52. #endif
  53.  
  54. #ifndef _ORDCOLL_
  55. #include "OrdColl.h"
  56. #endif
  57.  
  58. #ifndef __APPLEEVENTS__
  59. #include "AppleEvents.h"
  60. #endif
  61.  
  62. #ifndef __EDITIONS__
  63. #include "Editions.h"
  64. #endif
  65.  
  66. //=====================================================================================
  67. // Theory of Operation
  68. //=====================================================================================
  69.  
  70. /*
  71.     This file describes the Link Manager, an object specific to the Macintosh
  72.     implementation of OpenDoc.
  73.     
  74.     The link manager assists in the maintenance of cross-document (external) links.
  75.     There is one link manager object created for each OpenDoc session.
  76.     
  77.     The link manager is used by link objects, draft objects, and the document shell.
  78.     It is not available to parts.
  79.     
  80.     Link objects use the link manager to register unique ID for sections.
  81.     
  82.     The document shell also uses the link manager to register unique IDs for sections.
  83.  
  84. */
  85.  
  86. //=====================================================================================
  87. // Classes defined in this interface
  88. //=====================================================================================
  89.  
  90. class XMPLinkManager;
  91.  
  92. //=====================================================================================
  93. // Classes used by this interface
  94. //=====================================================================================
  95.  
  96. class XMPSession;
  97. class XMPDocument;
  98. class XMPDraft;
  99. class XMPLink;
  100. class XMPLinkSpec;
  101. class OrderedCollection;
  102.  
  103. //=====================================================================================
  104. // Private struct DraftInfo
  105. //=====================================================================================
  106. typedef struct
  107. {
  108.     XMPDraft*            draft;
  109.     OrderedCollection*    linksToExport;
  110.     OrderedCollection*    newExportedLinks;
  111.     XMPBoolean            linksImported;        // True if any link automatically imported
  112. }
  113. DraftInfo;
  114.  
  115. //=====================================================================================
  116. // XMPLinkManager
  117. //=====================================================================================
  118.  
  119. #define kXMPLinkManagerID "appl:xmplinkmanager$class,1.0.0"
  120.  
  121. class XMPLinkManager
  122. {
  123. public:
  124.     // ----------------------------------------
  125.     // 'structors
  126.     
  127.     XMPLinkManager();
  128.     
  129.     virtual ~XMPLinkManager();
  130.     
  131.     XMPNVMethod void InitLinkManager(XMPSession* session, XMPHeap heap);
  132.  
  133.     XMPVMethod XMPULong NewSectionID(XMPDocument* document);
  134.     
  135.         // Return a new ID guaranteed to be unique for the lifetime of the document.
  136.  
  137.     // ----------------------------------------
  138.     // For use by document shells only
  139.  
  140.     XMPVMethod XMPBoolean ReserveSectionID(XMPULong sectionID, XMPDocument* document);
  141.  
  142.         // Reserves a section ID guaranteed to be unique for the lifetime
  143.         // of the document. ReserveSectionID returns kXMPTrue if the
  144.         // argument sectionID is not already reserved and kXMPFalse otherwise.
  145.         // If kXMPFalse is returned, the caller should request a different ID
  146.         // or call NewSectionID().
  147.  
  148.     XMPVMethod XMPBoolean UnsavedExportedLinks(XMPDraft* draft);
  149.  
  150.         // Returns kXMPTrue if cross-document links have been created since the
  151.         // draft was last saved.  This routine should be called by the document
  152.         // shell prior to reverting or closing the draft without saving.
  153.         // If this method returns kXMPTrue, cross-document links will be broken
  154.         // if the document is not saved.  The document shell should alert the
  155.         // user before proceeding with the rever or close.
  156.  
  157.     XMPVMethod XMPBoolean AnyLinkImported(XMPDraft* draft);
  158.  
  159.         // Returns kXMPTrue if one or more links to content in other documents
  160.         // have automatically updated since the draft was last saved.
  161.         // The document shell should call this method before closing a draft
  162.         // that has not been changed by the user.  If this method returns
  163.         // kXMPTrue, the shell should save the draft without prompting the
  164.         // user.
  165.  
  166.     // ----------------------------------------
  167.     // For use by drafts only
  168.  
  169.     XMPVMethod void DraftOpened(XMPDraft* draft);
  170.  
  171.         // Notifies the link manager that a draft has been opened.  The link manager
  172.         // should internalize all link objects; each link publishing or subscribing
  173.         // to an edition file will register with the edition manager.
  174.         
  175.     XMPVMethod void DraftSaved(XMPDraft* draft);
  176.  
  177.         // Links that automatically update will be called to write their edition file.
  178.         // Cross-document links cannot be established until the first draft in the
  179.         // document has been saved.
  180.  
  181.     XMPVMethod void DraftClosing(XMPDraft* draft);
  182.  
  183.         // Should be called before a draft is reverted or closed.
  184.         // The link manager will delete any editon files created since the last save.
  185.         // The link manager can discard any transient information for the argument draft.
  186.  
  187.     // ----------------------------------------
  188.     // For use by links only
  189.  
  190.     XMPVMethod void ExportOnSave(XMPLink* link, XMPBoolean doExport);
  191.  
  192.         // If doExport is kXMPTrue, call the Export method of the argument link object
  193.         // the next time the draft is saved.  If doExport is kXMPFalse, do not call
  194.         // Export on save.  This method should be called by publishing link objects 
  195.         // that export linked data automatically when the draft is saved.  If the draft 
  196.         // is closed without saving, or is reverted, the Export method will not be called.
  197.         // Once the draft has been saved, the link needs to call this method again when
  198.         // the link is updated.
  199.  
  200.     // ----------------------------------------
  201.     // private by convention
  202.  
  203.     XMPVMethod XMPLink* CreateLink(XMPDraft* draft, XMPLinkSpec* linkSpec);
  204.  
  205.         // Create a link in the argument draft from a linkSpec originating in
  206.         // another document.
  207.  
  208. private:
  209.  
  210.     XMPStatic XMPPascal OSErr GetLinkAEHandler(
  211.             const AppleEvent* theAppleEvent,
  212.             const AppleEvent* reply,
  213.             long refCon);
  214.  
  215.         // Handler for GetLink events, sent from one document to another to
  216.         // resolve a link spec.
  217.  
  218.     // ----------------------------------------
  219.     // Handlers for Edition Manager section events.
  220.  
  221.     XMPStatic XMPPascal OSErr SectionReadAEHandler(
  222.             const AppleEvent *theAppleEvent,
  223.             const AppleEvent *reply,
  224.             long handlerRefcon);
  225.  
  226.     XMPStatic XMPPascal OSErr SectionWriteAEHandler(
  227.             const AppleEvent *theAppleEvent,
  228.             const AppleEvent *reply,
  229.             long handlerRefcon);
  230.  
  231.     XMPStatic XMPPascal OSErr SectionScrollAEHandler(
  232.             const AppleEvent *theAppleEvent,
  233.             const AppleEvent *reply,
  234.             long handlerRefcon);
  235.  
  236.     // ----------------------------------------
  237.     // Methods for supporting Edition files
  238.  
  239.     XMPVMethod void NewEditionFile(
  240.             XMPFileSpec documentSpec,
  241.             EditionContainerSpec* editionContainer,
  242.             XMPDocument* document);
  243.     
  244.     XMPVMethod SectionHandle GetSectionFromEvent(const AppleEvent *theAppleEvent);
  245.  
  246.     XMPVMethod void EditionFileName(char* fileName, XMPUShort numb);
  247.  
  248.     XMPVMethod XMPULong NewEditionID(XMPDocument* document);
  249.  
  250.     XMPVMethod XMPULong NextGlobalID(XMPDocument* document, XMPPropertyName globalProp);
  251.  
  252.     // ----------------------------------------
  253.     // Misc
  254.  
  255.     XMPMethod void NewDraftInfo(XMPDraft* draft);
  256.     XMPMethod DraftInfo* GetDraftInfo(XMPDraft* draft);
  257.     XMPMethod void DeleteDraftInfos();
  258.  
  259.     XMPHeap                fHeap;
  260.     OrderedCollection*    fDraftInfos;    // Info for each open draft
  261. };
  262.  
  263. #endif
  264.