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

  1. /*
  2.     File:        Draft.h
  3.  
  4.     Contains:    definition for XMPDraft
  5.  
  6.     Written by:    Vincent Lo, Tantek I. Celik
  7.  
  8.     Copyright:    ⌐ 1992 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <53>     2/18/94    VL        #1142972, #1144024: Added
  13.                                     GetDragDropStorageUnit to enable importing
  14.                                     data from a foreign source (e.g. the
  15.                                     Finder).
  16.         <52>      2/4/94    VL        Moved to PPC Header and began code cleanup.
  17.         <51>      2/2/94    RR        Added isRoot to CreateFrame
  18.         <50>      2/1/94    CC        Added the enumerated type XMPCloneKind;
  19.                                     Added XMPCloneKind argument to BeginClone;
  20.                                     added internal field fCloneKind and two
  21.                                     private methods.
  22.         <49>     1/28/94    CC        Removed UniqueChangeID(),
  23.                                     ShowLinkBorders(), and SetLinkBorders().
  24.         <48>     1/27/94    VL        Added IsValidDraftKey.
  25.         <47>     1/25/94    CC        Added fShowLinkBorders field.
  26.         <46>     1/21/94    CC        Added CreateLinkSource(), GetLinkSource(),
  27.                                     RemoveLinkSource(),
  28.                                     GetLinkSourceIterator(), and
  29.                                     UniqueChangeID().
  30.         <45>     1/18/94    CC        Added ShowLinkBorders() and
  31.                                     SetLinkBorders().
  32.         <44>    12/21/93    VL        Used new Init strategy. Added support for
  33.                                     persistent link id. Removed friends for
  34.                                     Document and StorageUnit.
  35.         <43>    12/21/93    JBS        CreateFrame with viewType & presentation
  36.         <42>    12/20/93    VL        Removed Window-related calls. XMPWindow is
  37.                                     no longer a persistent object.
  38.         <41>    12/16/93    Té        CreatePart now takes an optional Editor
  39.                                     parameter
  40.         <40>     12/8/93    CC        GetLink: Renamed 2nd parameter from
  41.                                     theLinkSpec to linkSpec
  42.         <39>    11/30/93    VL        Changed frameGroup from XMPUShort to
  43.                                     XMPULong.
  44.         <38>    11/23/93    VL        Added fHeap, GetHeap().
  45.         <37>    11/15/93    CC        Added CreateLinkSpec() method
  46.                                     CreateLink() takes XMPPart* parameter
  47.         <36>    11/12/93    JBS        remove Layout methods
  48.         <35>    11/11/93    PH        Add forward declaration of XMPLinkSpec
  49.         <34>     11/9/93    PH        Added CreateDragDropStorageUnit
  50.         <33>     11/1/93    VL        Added BeginClone, EndClone, AbortClone.
  51.         <32>    10/21/93    RR        CreateWindow takes new window flags (these
  52.                                     are Mac-specific and Draft isn't, but we
  53.                                     need a new Initialize strategy anyway for
  54.                                     SOM. Stay tuned)
  55.         <31>     10/7/93    RR        Added root part to CreateWindow
  56.         <30>     10/7/93    VL        Removed InitSemanticInterface, fIsFinished
  57.                                     and added SetChangedFromPrev.
  58.         <29>     9/30/93    VL        Removed SetFinished.
  59.         <28>     9/23/93    VL        Added GetPermissions.
  60.         <27>     9/21/93    VL        Moved ChangedFromPrev method to private by
  61.                                     convention and added another parameter to
  62.                                     it.
  63.         <26>     9/14/93    VL        Added GetDraftGut to make calls reentrant.
  64.         <25>      9/8/93    VL        Support Flushing.
  65.         <24>      9/3/93    JBS        updated to support new Layout class
  66.         <23>     8/26/93    VL        Added Flush and FlushVersion in preparation
  67.                                     for Bento Flush functionality.
  68.         <22>     8/23/93    VL        Added private fExternalized, private
  69.                                     NeedExternalizing, FailIfNotExclusiveWrite
  70.                                     and changed return value to void for
  71.                                     SetChangedFromPrev.
  72.         <21>     8/20/93    VL        Added private ExternalizeCollections.
  73.         <20>     8/18/93    VL        ReleaseStorageUnit takes an ID now.
  74.         <19>      8/9/93    VL        Removed bogus types.
  75.         <18>      8/9/93    NP        Added class id string.
  76.         <17>      8/6/93    VL        Added CreateCollections and
  77.                                     DeleteCollections.
  78.         <16>      8/6/93    PH        Storage integration
  79.         <15>      8/6/93    VL        Added support for getting
  80.                                     PersistentObjects.
  81.         <14>     7/29/93    VL        Removed getting persistent objects by name.
  82.         <13>     7/14/93    VL        Fixed problem with fStorageUnits defined
  83.                                     twice.
  84.         <12>     7/14/93    VL        Used AEHashTable for fStorageUnits.
  85.         <11>      7/2/93    Té        fix IntlText compile bugs
  86.         <10>      7/1/93    VL        CreateSU should take XMPType, not XMPName.
  87.          <9>     6/30/93    VL        Added Reinitialize, Open, Close, Abort,
  88.                                     IsNewDraft and utility calls like
  89.                                     Create/Open/Close/AbortVersion.
  90.          <8>     6/22/93    VL        Removed fDraftRefCount. Added
  91.                                     fChangedFromPrev, fEmbeddedCotnainer and
  92.                                     SetChangedFromPrev().
  93.          <7>     6/15/93    VL        Added fCMContainer to keep track of the
  94.                                     embedded container.
  95.          <6>     6/10/93    NP        Changed some parameter type for XMPType.
  96.          <5>      6/2/93    VL        Added fDraftRefCount.
  97.          <4>     4/29/93    VL        8.3 Name Change.
  98.          <3>      4/9/93    VL        XMPDraft should be subclassed from
  99.                                     XMPRefCntObject.
  100.          <2>      4/7/93    VL        Moved parameters from Initialize to
  101.                                     constructor.
  102.          <1>      4/6/93    VL        first checked in
  103.  
  104.     To Do:
  105.         1) Take out const names.
  106.         2) Do we need fEmbeddedContainer or fCMContainer? Should we always get it from fDocument?
  107.         3) XMPPositionCode is included only for XMPPositionCode.
  108.         4) XMPDraftKey is defined in StorageU.h.
  109. */
  110.  
  111. #ifndef _DRAFT_
  112. #define _DRAFT_
  113.  
  114. #ifndef _XMPTYPES_
  115. #include "XMPTypes.h"
  116. #endif
  117.  
  118. #ifndef _PSTOBJ_
  119. #include "PstObj.h"
  120. #endif
  121.  
  122. #ifndef _STORAGEU_
  123. #include "StorageU.h"
  124. #endif
  125.  
  126. //==============================================================================
  127. // Constants
  128. //==============================================================================
  129.  
  130. enum {
  131.     kDPNone             = 0,
  132.     kDPTransient        = 1,
  133.     kDPReadOnly            = 2,
  134.     kDPSharedWrite        = 3,
  135.     kDPExclusiveWrite    = 4
  136. };
  137.  
  138. typedef XMPULong XMPDraftPermissions;
  139.  
  140. typedef const enum {
  141.     kInvisibleBlocks    = 1,
  142.     kAllBlocks            = 2,
  143.     kVisibleBlocks        = 3
  144. }    XMPPurgePriority;
  145.  
  146. typedef enum {
  147.     kXMPCloneCopy    = 0,
  148.     kXMPCloneCut,
  149.     kXMPClonePaste,
  150.     kXMPCloneDuplicate,
  151.     kXMPCloneAll                // For private use only
  152. } XMPCloneKind;
  153.  
  154. //==============================================================================
  155. // Scalar Types
  156. //==============================================================================
  157. typedef XMPULong    XMPVersionID;
  158. typedef    XMPID        XMPDraftID;
  159. typedef    XMPID        XMPLinkID;
  160. typedef    XMPISOStr    XMPDraftName;
  161.  
  162. //==============================================================================
  163. // Classes defined in this interface
  164. //==============================================================================
  165. class XMPDraft;
  166.  
  167. //==============================================================================
  168. // Classes used by this interface
  169. //==============================================================================
  170. class    XMPCanvas;
  171. class    XMPDocument;
  172. class    XMPFrame;
  173. class    XMPLink;
  174. class    XMPLinkSource;
  175. class    XMPLinkSpec;
  176. class    XMPPart;
  177. class    XMPPartTable;
  178. class    XMPShape;
  179. class    XMPEmbeddedContainer;
  180. class    XMPAEHashTable;
  181. class    IDList;
  182. class    XMPStorageUnit;
  183. class    VersionList;
  184. class    XMPDragDropStorageUnit;
  185.  
  186. //==============================================================================
  187. // XMPDraft
  188. //==============================================================================
  189.  
  190. #define kXMPDraftID "appl:xmpdraft$class,1.0.0"
  191.  
  192. class XMPDraft : public XMPRefCntObject
  193. {
  194.     friend class XMPLinkIterator;    
  195.     friend class XMPLinkSourceIterator;    
  196.  
  197. public:
  198.  
  199.     XMPMethod    XMPDocument*    GetDocument();
  200.     
  201.     XMPMethod    XMPDraftID        GetID();
  202.  
  203.     XMPMethod    XMPDraftName    GetName();
  204.  
  205.     XMPMethod    void            SetName(XMPDraftName name);
  206.  
  207.     XMPMethod    XMPStorageUnit*    GetDraftProperties();
  208.     
  209.     XMPMethod    void IncrementRefCount();
  210.         
  211.     XMPMethod    void Release();
  212.  
  213.     XMPMethod    XMPDraftPermissions    GetPermissions();
  214.  
  215.     XMPMethod    XMPStorageUnit*    CreateStorageUnit();
  216.     XMPMethod    XMPStorageUnit*    GetStorageUnit(XMPStorageUnitID id);
  217.     XMPMethod    void            RemoveStorageUnit(XMPStorageUnit* storageUnit);
  218.     
  219.     XMPMethod    XMPDraftKey        BeginClone(XMPCloneKind kind);
  220.     
  221.     XMPMethod    void            EndClone(XMPDraftKey key);
  222.     
  223.     XMPMethod    void            AbortClone(XMPDraftKey key);
  224.  
  225.     XMPMethod    XMPBoolean        ChangedFromPrev();    
  226.  
  227.     XMPMethod    void            SetChangedFromPrev();    
  228.  
  229.     XMPMethod    void            RemoveFromDocument();
  230.  
  231.     XMPMethod    XMPDraft*        RemoveChanges();
  232.  
  233.     XMPMethod    XMPDraft*        Externalize();
  234.     
  235.     XMPMethod     XMPDraft*        SaveToAPrevious(XMPDraft* to);
  236.  
  237.     XMPMethod XMPFrame*    CreateFrame(
  238.                             XMPFrame*        containingFrame,
  239.                             XMPShape*         frameShape,
  240.                             XMPPart*         part,
  241.                             XMPTypeToken    viewType,
  242.                             XMPTypeToken    presentation,
  243.                             XMPULong         frameGroup,
  244.                             XMPBoolean        isRoot,
  245.                             XMPBoolean         isOverlaid);
  246.              
  247.     XMPMethod XMPFrame*    GetFrame(XMPStorageUnitID id);
  248.     XMPMethod void        RemoveFrame(XMPFrame* frame);
  249.  
  250.     XMPMethod XMPPart*    CreatePart(XMPType partType,XMPEditor optionalEditor);
  251.     XMPMethod XMPPart*    GetPart(XMPStorageUnitID id);
  252.     XMPMethod void        RemovePart(XMPPart* part);
  253.  
  254.     XMPMethod XMPLinkSpec*        CreateLinkSpec (XMPPart* part, XMPPtr data, XMPULong size);
  255.     XMPMethod XMPLinkSource*    CreateLinkSource(XMPPart* part);
  256.     XMPMethod XMPLinkSource*     GetLinkSource(XMPStorageUnitID id);
  257.     XMPMethod XMPLink*            GetLink(XMPStorageUnitID id,XMPLinkSpec* linkSpec);
  258.     XMPMethod void                RemoveLink(XMPLink* link);
  259.     XMPMethod void                RemoveLinkSource(XMPLinkSource* link);
  260.  
  261. private:
  262.  
  263.     XMPMethod XMPSize Purge(XMPSize size);
  264.  
  265.     XMPMethod XMPStorageUnit* CreateSU(XMPStorageUnitID id, const XMPType suType);
  266.  
  267.     XMPMethod void    CreateVersion();
  268.     XMPMethod void    OpenVersion();
  269.     XMPMethod void    CloseVersion();
  270.     XMPMethod void    DestroyVersion();
  271.     XMPMethod void    FlushVersion();
  272.  
  273.     XMPMethod XMPPersistentObject* GetPersistentObject(XMPStorageUnitID id);
  274.     XMPMethod void    ReleasePersistentObject(XMPPersistentObject* object);
  275.     XMPMethod void    RemovePersistentObject(XMPPersistentObject* object);
  276.     XMPMethod void    CreateCollections();
  277.     XMPMethod void    DeleteCollections();
  278.     XMPMethod void    ExternalizeCollections();
  279.     XMPMethod void    CloseCollections();
  280.     XMPMethod void    OpenCollections();
  281.     XMPMethod XMPBoolean    AreEmptyCollections();
  282.     
  283.     XMPMethod void    FailIfNotExclusiveWrite();
  284.     
  285.     XMPMethod XMPLink*    CreateLink(XMPLinkSource* linkSource);
  286.  
  287.     XMPMethod void    PrepareLinksForClone();
  288.     XMPMethod void    AnnotateLinksForNextClone();
  289.  
  290.     XMPDocument*            fDocument;
  291.     XMPDraftID                fID;
  292.     XMPVersionID            fVersionID;
  293.     XMPVersionID            fPrevVersionID;
  294.         
  295.     XMPDraftPermissions        fPermissions;
  296.     XMPEmbeddedContainer*    fEmbeddedContainer;
  297.     XMPBoolean                fChangedFromPrev;
  298.     XMPBoolean                fIsNewDraft;
  299.     XMPBoolean                fExternalized;
  300.  
  301.     XMPAEHashTable*            fPersistentObjects;
  302.     XMPAEHashTable*            fReleasedPersistentObjects;
  303.     XMPAEHashTable*            fStorageUnits;
  304.     XMPAEHashTable*            fReleasedStorageUnits;
  305.     
  306.     IDList*                    fIDList;
  307.     XMPStorageUnit*            fDraftProperties;
  308.     
  309.     XMPAEHashTable*            fClonedSUIDs;
  310.     XMPDraft*                fDestDraft;
  311.     XMPDraftKey                fCurrentKey;
  312.     XMPULong                fLockCount;
  313.     XMPCloneKind            fCloneKind;
  314.  
  315.     XMPHeap                    fHeap;
  316.     
  317. public:    // private by convention
  318.  
  319.     XMPDraft();
  320.  
  321.     XMPVMethod ~XMPDraft();
  322.  
  323.     XMPMethod void InitDraft(XMPDocument* document, XMPDraftID id, XMPDraftPermissions perms);
  324.  
  325.     XMPMethod void    ReleaseFrame(XMPFrame* frame);
  326.     XMPMethod void    ReleasePart(XMPPart* part);
  327.     XMPMethod void    ReleaseLink(XMPLink* link);
  328.     XMPMethod XMPDraft*        ReleaseStorageUnit(XMPStorageUnitID id);
  329.     
  330.     XMPMethod void     SetChangedFromPrevFlag(XMPBoolean changed);
  331.  
  332.     XMPMethod IDList*        GetIDList();
  333.  
  334.     XMPMethod void Reinitialize(XMPDraftPermissions perms);
  335.     XMPMethod void Open();
  336.     XMPMethod void Close();
  337.     XMPMethod void Abort();
  338.     XMPMethod void Flush();
  339.     XMPMethod XMPBoolean    IsNewDraft();
  340.     XMPMethod XMPEmbeddedContainer*    GetEmbeddedContainer();
  341.     XMPMethod CMContainer    GetCMContainer();
  342.     XMPMethod XMPBoolean    NeedExternalizing();
  343.     XMPMethod XMPBoolean    IsChangedFromPrev(VersionList* versionList);
  344.     XMPMethod XMPAEHashTable* GetClonedSUIDs(XMPDraft* destDraft);
  345.  
  346.     XMPMethod XMPStorageUnit* CreateDragDropStorageUnit();
  347.     XMPMethod XMPStorageUnit* GetDragDropStorageUnit(XMPStorageUnitID id);
  348.     
  349.     XMPMethod    XMPBoolean    IsValidDraftKey(XMPDraftKey key);
  350.     XMPMethod    XMPHeap    GetHeap();
  351.     
  352.     XMPMethod    XMPLinkID                GetPersistentLinkID(XMPLink* link);
  353.     XMPMethod    XMPStorageUnitID        GetLinkID(XMPLinkID linkID);
  354.     XMPMethod    XMPLinkIterator*        GetXMPLinkIterator();
  355.     XMPMethod    XMPLinkSourceIterator*    GetXMPLinkSourceIterator();
  356. };
  357.  
  358. #endif    // _DRAFT_
  359.