home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osr1.exe / src / Link.cpp < prev    next >
Text File  |  1997-03-21  |  53KB  |  1,197 lines

  1. //====START_GENERATED_PROLOG======================================
  2. //
  3. //
  4. //   COMPONENT_NAME: oddataxfer
  5. //
  6. //   CLASSES: none
  7. //
  8. //   ORIGINS: 82,27
  9. //
  10. //
  11. //   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  12. //   All Rights Reserved
  13. //   Licensed Materials - Property of IBM
  14. //   US Government Users Restricted Rights - Use, duplication or
  15. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  16. //
  17. //   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  18. //   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19. //   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  20. //   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  21. //   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  22. //   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  23. //   OR PERFORMANCE OF THIS SOFTWARE.
  24. //
  25. //====END_GENERATED_PROLOG========================================
  26. //
  27. // @(#) 1.9 com/src/storage/Link.cpp, oddataxfer, od96os2, odos29712d 9/3/96 17:21:19 [ 3/21/97 17:18:35 ]
  28. /*
  29.         File:           Link.cpp
  30.  
  31.         Contains:       Implementation of ODLink class
  32.  
  33.         Owned by:       Craig Carper
  34.  
  35.         Copyright:      ⌐ 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  36.  
  37.         Change History (most recent first):
  38.  
  39.                 <43>     10/8/95        TJ              Fixes Recomended by Refball
  40.                 <42>     10/4/95        jpa             Added missing ODVolatiles [1285799]
  41.                 <41>      9/8/95        Té              1281096 FB2:Many constants in ODTypesB
  42.                                                                         without kOD prefix!
  43.                 <40>     8/12/95        Té              1276807 Opt./Bug: use StdTypIO routines for
  44.                                                                         portable streaming & smaller footprint
  45.                 <39>      8/3/95        RR              #1257260: Collapse B classes. Remove
  46.                                                                         somInit methods. Don't call IsInitialized
  47.                                                                         or SubclassResponsibility
  48.                 <38>     7/28/95        CC              1183569: Externalize only when dirty.
  49.                 <37>     7/27/95        CC              1259986: WriteLinkEdition: Close edition
  50.                                                                         file on failure.
  51.                                                                         CreateLinkEdition: Delete edition file on
  52.                                                                         error writing file.
  53.                 <36>     7/24/95        CC              1154714: Removed ODUpdateID parameter from
  54.                                                                         UpdateDependents.
  55.                 <35>     7/21/95        CC              1153788: Write 'TEXT' & 'PICT' formats to
  56.                                                                         Edition file.
  57.                 <34>     6/30/95        CC              1242642: DeleteLinkEdition: Release after
  58.                                                                         unregistering.
  59.                 <33>     5/26/95        VL              1251403: Multithreading naming support.
  60.                 <32>     5/22/95        CC              1248361: CloneToMemoryContainer:
  61.                                                                         Externalize content SU to  resolve promises
  62.                                                                         before cloning to memory container.
  63.                 <31>     5/18/95        CC              1238898: Add destFrame argument to
  64.                                                                         BeginClone call.
  65.                 <30>     5/16/95        CC              1248090: CloneToMemoryContainer: Clone
  66.                                                                         content frame if present.
  67.                 <29>     4/25/95        CC              1242555:  Removed obsolete $5 comment.
  68.                 <28>     4/14/95        Té              #1235279 BB: InfoUtil & StdTypIO functions
  69.                                                                         should take Environment* and SU* when
  70.                                                                         possible
  71.                 <27>     4/11/95        CC              1236452:  Replaced SOM_CATCH with SOM_TRY
  72.                                                                         in WriteLinkEdition.
  73.                                                                         Added parenthesis to TopDraft (probably not
  74.                                                                         necessary).
  75.                 <26>      4/3/95        CC              1229068: IsTopDraft: Use ODDocument::Exists
  76.                                                                         to test for top draft.
  77.                 <25>      3/9/95        CC              1221471: Added changesAllowed parameter to
  78.                                                                         ShowLinkDestinationInfo().
  79.                 <24>      3/3/95        CC              1223861, 1153949 Override
  80.                                                                         ShowLinkDestinationInfo().
  81.                 <23>      2/7/95        CC              1185113 Externalize: Lock handles during
  82.                                                                         writing.
  83.                                                                         1193560 InitLinkFromStorage: Use ptr
  84.                                                                         returned by ODLockHandle;
  85.                                                                         WASSERTS --> if╔THROW
  86.                 <22>      2/1/95        CC              1153347 Added static function IsTopDraft().
  87.                                                                         Register sections if draft is topmost.
  88.                                                                         Use IsRegisteredSection for robustness.
  89.                 <21>     1/19/95        CC              1212831, 1193556, 1194158 Use creator of
  90.                                                                         document file when creating edition file.
  91.                 <20>    12/22/94        CC              1153926 UpdateDependents() - Update
  92.                                                                         cross-document links immediately if source
  93.                                                                         is manual.
  94.                 <19>    12/22/94        CC              1153759 CreateLinkEdition - call ODDRaft::
  95.                                                                         SetChangedFromPrev().
  96.                                                                         1207987 Added DeleteLinkEdition().
  97.                 <18>    12/20/94        VL              1195012: Make Storage calls be
  98.                                                                         marshallable.
  99.                 <17>    12/16/94        CC              1203516 Removed ODLinkSource parameter from
  100.                                                                         InitLink().
  101.                 <16>     12/8/94        CC              1154711 InitLinkFromStorage(),
  102.                                                                         ReleaseAll(): Only register & unregister
  103.                                                                         with the Edition manager if draft has write
  104.                                                                         permission.
  105.                 <15>    11/30/94        RR              1188078 Use ODTime, not time_t
  106.                 <14>     10/7/94        CC              1191089 - Use change time for mod date of
  107.                                                                         edition file.
  108.                 <13>     10/4/94        CC              1190862 - Added Release().
  109.                 <12>     9/29/94        RA              1189812: Mods for 68K build.
  110.                 <11>     9/23/94        VL              1184272: ContainerID is now a sequence of
  111.                                                                         octets.
  112.                 <10>     9/15/94        CC              1186669 - Implemented CloneInto();
  113.                                                                         CloneToMemoryContainer use draftKey for
  114.                                                                         Clone() call.
  115.                  <9>      9/7/94        CC              #1185114 - Catch throws from KeyValid().
  116.                  <8>     8/26/94        VL              1183174: Use updated cloning APIs.
  117.                  <7>     8/15/94        Té              #1180922 Removed most obsolete types from
  118.                                                                         StdTypes.idl
  119.                  <6>     8/10/94        CC              1179943 - Moved platform-independent
  120.                                                                         implementation into LinkB.cpp.
  121.                  <5>      8/3/94        VL              1153123: Storage to ODStor.
  122.                  <4>     6/24/94        CC              Clean up some easy $5 comments.
  123.                  <3>     6/24/94        CC              Added call to ShowLinkDestinationInfo().
  124.                  <2>     6/24/94        CC              Changed parameters to InitBaseLink().
  125.                  <1>     6/21/94        CC              first checked in
  126.  
  127.                 ------------------- CC ---- Converted to SOM
  128.  
  129.                  <5>      5/9/94        MB              #1162181: Changes necessary to install MMM.
  130.                  <4>     4/12/94        CC              Clients may call UnregisterDependent()
  131.                                                                         after this object's ReleaseAll() method has
  132.                                                                         run. (1155973)
  133.                  <3>     3/28/94        CG              1153547: ODSessn.h renamed to ODSessM.h
  134.                  <2>     3/27/94        Té              #1153523.  Adjust name of
  135.                                                                         kODPropRootPartSU to more clearly indicate
  136.                                                                         what it is supposed to be used for.
  137.                  <1>     3/25/94        CC              first checked in
  138.  
  139.                 ------------------- CC ---- Moved from Core to Storage subsystem
  140.  
  141.                  <7>     3/24/94        CC              Implemented CloneTo() (1153038) and
  142.                                                                         GetChangeTime() (115340).
  143.                  <6>     3/15/94        MB              Changes to support SCpp/ASLM builds,
  144.                                                                         #1150864.
  145.                  <5>      3/2/94        CC              ReleaseAll: Check fLinkSource for NIL
  146.                                                                         before releasing it! (1144936)
  147.                  <4>      3/1/94        JA              Include ODMemory.h. (1147588)
  148.                  <3>      3/1/94        CC              Replaced calls to HLock, HUnlock, and
  149.                                                                         GetHandleSize with OD equivalents.
  150.                  <2>     2/17/94        CC              CloneToMemoryContainer: Re-instate fix lost
  151.                                                                         after 2/2/94    checkin.
  152.                 <12>      2/8/94        Té              Throw -> THROW & some code clean up
  153.                 <11>      2/7/94        Té              more fixes to compile with PPC Headers
  154.                 <10>      2/4/94        Té              fixes to compile with PPC Universal headers
  155.                  <9>      2/3/94        CG              System Session break out.
  156.                  <8>      2/2/94        CC              CloneToMemoryContainer:  Moved code to set
  157.                                                                         kODPropRootSU property after the rootSU
  158.                                                                         has been determined.
  159.                  <7>      2/1/94        CC              Pass ODCloneKind argument to BeginClone.
  160.                  <6>     1/28/94        CC              Added ReleaseAll(); increment and decrement
  161.                                                                         ref count of part in ODPartList::AddPart
  162.                                                                         and ::RemovePart; release parts and delete
  163.                                                                         list entries in ODPartList destructor.
  164.                  <5>     1/27/94        VL              Used ODStorageUnit::CloneInto.
  165.                  <4>     1/25/94        CC              CloneToMemoryContainer: use distinct
  166.                                                                         identifiers for clipboard and draft keys;
  167.                                                                         RegisterDependent: call LinkUpdated only if
  168.                                                                         change id is different; GetTextValue: add
  169.                                                                         Volatile stmt.; UpdateDependents: remove
  170.                                                                         ODUnused().
  171.                  <3>     1/24/94        CC              Added ODUpdateID parameter to call to
  172.                                                                         LinkUpdated().
  173.                  <2>     1/22/94        CC              Don't call release() in destructor.
  174.                  <1>     1/21/94        CC              first checked in
  175.                 <17>     1/18/94        CG              Added include for StorgDef.h
  176.                 <16>     1/18/94        CC              Use kODScrapTypePart; release draft
  177.                                                                         properties on failure in
  178.                                                                         CloneToMemoryContainer and
  179.                                                                         CloneFromMemoryContainer
  180.                 <15>     1/14/94        CC              Added Lock(), Unlock(), GetTimeStamp(),
  181.                                                                         GetStatus(), SetAutoExport(),
  182.                                                                         IsAutoExport(), Export(),
  183.                                                                         ShowSourceContent(), type ODLinkKey; added
  184.                                                                         key parameter to various routines; renamed
  185.                                                                         Edition Manager support routines.
  186.                 <14>     1/11/94        Té              Init... changes
  187.                 <13>    12/22/93        CC              Maintain persistent fields fContentSU and
  188.                                                                         fChangedDate.  Read/write link content
  189.                                                                         from/to edition file by cloning fContentSU
  190.                                                                         into a memory container.  Increment link
  191.                                                                         ref count for registered sections.  Write
  192.                                                                         edition files only on Externalize().
  193.                 <12>    12/21/93        VL              Changed ODStorageUnit::GetValueSize to
  194.                                                                         StorageUnit::GetSize.
  195.                 <11>    12/16/93        CC              Added methods to create, write, and read
  196.                                                                         Edition files.  Save Edition Manager
  197.                                                                         section records and aliases persistently.
  198.                 <10>    12/14/93        Té              InitLink changes.  Internalize, Initialize
  199.                                                                         went away.
  200.                  <9>     12/8/93        CC              ODValueLink -> ODPartListLink to avoid
  201.                                                                         name conflict.  Removed multiple
  202.                                                                         constructors.  Added InitPartListLink
  203.                  <8>    11/18/93        Té              call inherited::InitializePersistent()
  204.                                                                         ::Externalize()
  205.                  <7>    11/17/93        CC              RegisterDependent calls the LinkUpdated
  206.                                                                         method of its part argument.
  207.                  <6>     9/29/93        VL              Added InitializePersistent.
  208.                  <5>      7/1/93        NP              Abstract/Concrete breakout.
  209.                  <4>     6/10/93        NP              Added comments.
  210.                  <3>     4/28/93        NP              File name changes.
  211.                  <2>     4/27/93        NP              Now compilable.
  212.                  <1>     4/21/93        NP              first checked in
  213.  
  214.         To Do:
  215.         In Progress:
  216. */
  217.  
  218. #define VARIABLE_MACROS
  219.  
  220. #ifdef _PLATFORM_OS2_
  221.  #ifndef _ITEXT_
  222.   #include <IText.h>
  223.  #endif
  224. #endif
  225.  
  226. #define ODLink_Class_Source
  227. #include <Link.xih>
  228.  
  229. #ifndef _LINKDLGS_
  230. #include <LinkDlgs.h>
  231. #endif
  232.  
  233. #ifndef _EXCEPT_
  234. #include <Except.h>
  235. #endif
  236.  
  237. #ifdef _PLATFORM_OS2_
  238. #include <ODPagtun.h>
  239. #endif
  240.  
  241. #ifndef _ODMEMORY_
  242. #include <ODMemory.h>
  243. #endif
  244.  
  245. #ifdef _PLATFORM_MACINTOSH_
  246.  #ifndef _CONSTDEF_
  247.   #include <ConstDef.h>
  248.  #endif
  249. #endif
  250.  
  251. #ifndef SOM_ODLinkSource_xh
  252. #include <LinkSrc.xh>
  253. #endif
  254.  
  255. #ifndef SOM_ODLinkManager_xh
  256. #include <LinkMgr.xh>
  257. #endif
  258.  
  259. #ifndef SOM_ODPart_xh
  260. #include <Part.xh>
  261. #endif
  262.  
  263. #ifndef SOM_ODSession_xh
  264. #include <ODSessn.xh>
  265. #endif
  266.  
  267. #ifndef SOM_ODContainer_xh
  268. #include <ODCtr.xh>
  269. #endif
  270.  
  271. #ifndef SOM_ODDocument_xh
  272. #include <Document.xh>
  273. #endif
  274.  
  275. #ifndef SOM_ODDraft_xh
  276. #include <Draft.xh>
  277. #endif
  278.  
  279. #ifndef SOM_ODStorageSystem_xh
  280. #include <ODStor.xh>
  281. #endif
  282.  
  283. #ifndef _PLFMFILE_
  284. #include <PlfmFile.h>
  285. #endif
  286.  
  287. #ifndef SOM_ODStorageUnit_xh
  288. #include <StorageU.xh>
  289. #endif
  290.  
  291. #ifndef SOM_Module_OpenDoc_StdProps_defined
  292. #include <StdProps.xh>
  293. #endif
  294.  
  295. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  296. #include <StdTypes.xh>
  297. #endif
  298.  
  299. #ifdef _PLATFORM_OS2_ // CED
  300.  #include <builtin.h>
  301. #else
  302.  #ifndef __ERRORS__
  303.   #include <Errors.h>
  304.  #endif
  305. #endif // _PLATFORM_OS2_
  306.  
  307. #ifndef _ODDEBUG_
  308. #include <ODDebug.h>
  309. #endif
  310.  
  311. #ifndef _BARRAY_
  312. #include <BArray.h>
  313. #endif
  314.  
  315. #ifndef _STDTYPIO_
  316. #include <StdTypIO.h>
  317. #endif
  318.  
  319. #ifndef _STORUTIL_
  320. #include <StorUtil.h>
  321. #endif
  322.  
  323. #ifndef SOM_ODTranslation_xh
  324. #include <Translt.xh>
  325. #endif
  326.  
  327. #ifndef SOM_Module_OpenDoc_StdDefs_defined
  328. #include <StdDefs.xh>
  329. #endif
  330.  
  331. #if ODDebug
  332. #define ODDebugLink 1
  333. #else
  334. #define ODDebugLink 0
  335. #endif
  336.  
  337. #ifdef _PLATFORM_MACINTOSH_
  338.  #pragma segment ODLink
  339. #endif
  340.  
  341. //==============================================================================
  342. // Local Functions
  343. //==============================================================================
  344.  
  345. static ODBoolean IsTopDraft(Environment* ev, ODDraft* draft);
  346.  
  347. //------------------------------------------------------------------------------
  348. // IsTopDraft
  349. //------------------------------------------------------------------------------
  350.  
  351. static ODBoolean IsTopDraft(Environment* ev, ODDraft* draft)
  352. {
  353. #if ODDebugLink
  354.         somPrintf("IsTopDraft: draft refcount is %d\n", draft->GetRefCount(ev));
  355. #endif
  356.  
  357.         return !(draft->GetDocument(ev)->Exists(ev, kODNULLID, draft, kODPosFirstAbove));
  358. }
  359.  
  360. //==============================================================================
  361. // ODLink
  362. //==============================================================================
  363.  
  364. //------------------------------------------------------------------------------
  365. // ODLink: somUninit
  366. //------------------------------------------------------------------------------
  367.  
  368. SOM_Scope void  SOMLINK ODLinksomUninit(ODLink *somSelf)
  369. {
  370.     /* ODLinkData *somThis = ODLinkGetData(somSelf); */
  371.     ODLinkMethodDebug("ODLink","somUninit");
  372.  
  373.     parent_somUninit(somSelf);
  374. }
  375.  
  376. //------------------------------------------------------------------------------
  377. // ODLink: InitLink
  378. //------------------------------------------------------------------------------
  379.  
  380. SOM_Scope void  SOMLINK ODLinkInitLink(ODLink *somSelf, Environment *ev,
  381.                 ODStorageUnit* storageUnit)
  382. {
  383.     ODLinkData *somThis = ODLinkGetData(somSelf);
  384.     ODLinkMethodDebug("ODLink","InitLink");
  385.  
  386.  
  387. #ifdef _PLATFORM_OS2_ // CED
  388.   _interrupt(3);
  389. #else
  390.         SOM_CATCH return;
  391.  
  392.         /* Moved from somInit. SOM itself sets fields to zero
  393.         _fSection = (SectionHandle) kODNULL;
  394.         _fDirty = kODFalse;
  395.         */
  396.         somSelf->InitBaseLink(ev, storageUnit);
  397.  
  398.         somSelf->SetLinkDirty(ev);
  399. #endif
  400.  
  401. }
  402.  
  403. //------------------------------------------------------------------------------
  404. // ODLink: InitLinkFromStorage
  405. //------------------------------------------------------------------------------
  406.  
  407. SOM_Scope void  SOMLINK ODLinkInitLinkFromStorage(ODLink *somSelf, Environment *ev,
  408.                 ODStorageUnit* storageUnit)
  409. {
  410.     ODLinkData *somThis = ODLinkGetData(somSelf);
  411.     ODLinkMethodDebug("ODLink","InitLinkFromStorage");
  412.  
  413.  
  414. #ifdef _PLATFORM_OS2_ // CED
  415.   _interrupt(3);
  416. #else
  417.  
  418.         SOM_CATCH return;
  419.  
  420.         /* Moved from somInit. SOM itself sets fields to zero
  421.         _fSection = (SectionHandle) kODNULL;
  422.         _fDirty = kODFalse;
  423.         */
  424.         somSelf->InitBaseLinkFromStorage(ev, storageUnit);
  425.  
  426.         if (ODSUExistsThenFocus(ev, storageUnit, kODPropLinkSection, kODApplesect))
  427.         {
  428.                 const int sectionRecordSize = sizeof(SectionRecord);
  429.  
  430.                 if ( storageUnit->GetSize(ev) != sectionRecordSize )
  431.                         THROW(kODErrCorruptLink);
  432.  
  433.                 AliasHandle alias = kODNULL;
  434.                 ODVolatile(alias);
  435.  
  436.                 TRY
  437.                         _fSection = (SectionHandle) ODNewHandle(sectionRecordSize);
  438.                         ODValue theSectionPtr = ODLockHandle((ODHandle) _fSection);
  439.                         StorageUnitGetValue(storageUnit, ev, sectionRecordSize, theSectionPtr);
  440.                         ODUnlockHandle((ODHandle) _fSection);
  441.  
  442.                         if ( (**_fSection).kind != stPublisher )
  443.                                 THROW(kODErrCorruptLink);
  444.  
  445.                         storageUnit->Focus(ev, kODPropEditionAlias, kODPosUndefined, kODApplealis, (ODValueIndex)0, kODPosUndefined);
  446.                         ODULong size = storageUnit->GetSize(ev);
  447.  
  448.                         if ( size < sizeof(AliasRecord) )
  449.                                 THROW(kODErrCorruptLink);
  450.  
  451.                         alias = (AliasHandle) ODNewHandle(size);
  452.                         ODValue theAliasPtr = ODLockHandle((ODHandle) alias);
  453.                         StorageUnitGetValue(storageUnit, ev, size, theAliasPtr);
  454.                         ODUnlockHandle((ODHandle) alias);
  455.                 CATCH_ALL
  456.                         ODDisposeHandle((ODHandle) _fSection);
  457.                         _fSection = (SectionHandle) kODNULL;
  458.                         ODDisposeHandle((ODHandle) alias);
  459.                         RERAISE;
  460.                 ENDTRY
  461.  
  462.                 (**_fSection).alias = alias;
  463.                 (**_fSection).refCon = (long) somSelf;
  464.  
  465.                 if ( IsTopDraft(ev, storageUnit->GetDraft(ev)) )
  466.                 {
  467.                         if ( IsRegisteredSection(_fSection) != noErr )
  468.                         {
  469.                                 ODBoolean aliasWasUpdated;
  470.  
  471.                                 ODContainer* container = storageUnit->GetDraft(ev)->GetDocument(ev)->GetContainer(ev);;
  472.                                 ODFileSpec documentSpec = GetODFileSpecFromContainer(ev, container);
  473.  
  474.                                 OSErr error = RegisterSection(&documentSpec, _fSection, &aliasWasUpdated);
  475.  
  476.                                 // For now, ignore any error returned by RegisterSection.  The most likely errors are:
  477.                                 //      multiplePublisherWrn = -460,            A Publisher is already registered for that container
  478.                                 //      containerNotFoundWrn = -461,            Could not find editionContainer at this time
  479.                                 //      containerAlreadyOpenWrn = -462,         Container already opened by this section
  480.                                 //      notThePublisherWrn = -463,                      Not the first registered publisher for that container
  481.  
  482.                                 if ( IsRegisteredSection(_fSection) == noErr )
  483.                                         somSelf->Acquire(ev);   // Link must not be deleted untill its section is unregistered!
  484.                         }
  485.                 }
  486.         }
  487. #endif
  488. }
  489.  
  490. //------------------------------------------------------------------------------
  491. // ODLink: Release (OVERRIDE)
  492. //------------------------------------------------------------------------------
  493.  
  494. SOM_Scope void  SOMLINK ODLinkRelease(ODLink *somSelf, Environment *ev)
  495. {
  496.     ODLinkData *somThis = ODLinkGetData(somSelf);
  497.     ODLinkMethodDebug("ODLink","Release");
  498.  
  499.  
  500. #ifdef _PLATFORM_OS2_
  501.         SOM_TRY
  502. #else
  503.         SOM_CATCH return;
  504. #endif
  505.  
  506.         parent_Release(somSelf, ev);
  507.  
  508. #if ODDebugLink
  509.         somPrintf("ODLink %d::Release: Ref count is %d\n", somSelf->GetID(ev), somSelf->GetRefCount(ev));
  510. #endif
  511.  
  512.         if (somSelf->GetRefCount(ev) == 0)
  513.                 somSelf->GetStorageUnit(ev)->GetDraft(ev)->ReleaseLink(ev, somSelf);
  514.  
  515. #ifdef _PLATFORM_OS2_
  516.         SOM_CATCH_ALL
  517.         SOM_ENDTRY
  518.         return;
  519. #endif
  520.  
  521. }
  522.  
  523. //------------------------------------------------------------------------------
  524. // ODLink: Externalize (OVERRIDE)
  525. //------------------------------------------------------------------------------
  526.  
  527. SOM_Scope void  SOMLINK ODLinkExternalize(ODLink *somSelf, Environment *ev)
  528. {
  529.     ODLinkData *somThis = ODLinkGetData(somSelf);
  530.     ODLinkMethodDebug("ODLink","Externalize");
  531.  
  532. #ifdef _PLATFORM_OS2_
  533.  
  534.     parent_Externalize(somSelf,ev);
  535.  
  536. #else
  537.  
  538.         SOM_CATCH return;
  539.  
  540.     parent_Externalize(somSelf,ev);
  541.  
  542.         ODStorageUnit* su = somSelf->GetStorageUnit(ev);
  543.  
  544.         if ( _fDirty )
  545.         {
  546.                 if ( _fSection == (SectionHandle) kODNULL )
  547.                 {
  548.                         ODSURemoveProperty(ev, su, kODPropLinkSection);
  549.                         ODSURemoveProperty(ev, su, kODPropEditionAlias);
  550.                 }
  551.                 else
  552.                 {
  553.                         SectionPtr theSectionPtr = (SectionPtr) ODLockHandle((ODHandle) _fSection);
  554.  
  555.                         ODSUForceFocus(ev, su, kODPropLinkSection, kODApplesect);
  556.                         StorageUnitSetValue(su, ev, ODGetHandleSize((ODHandle) _fSection), (ODValue) theSectionPtr);
  557.  
  558.                         ODValue theAliasPtr = ODLockHandle((ODHandle) theSectionPtr->alias);
  559.                         ODSUForceFocus(ev, su, kODPropEditionAlias, kODApplealis);
  560.                         StorageUnitSetValue(su, ev, ODGetHandleSize((ODHandle) theSectionPtr->alias), theAliasPtr);
  561.  
  562.                         ODUnlockHandle((ODHandle) theSectionPtr->alias);
  563.                         ODUnlockHandle((ODHandle) _fSection);
  564.                 }
  565.                 _fDirty = kODFalse;
  566.         }
  567. #endif // _PLATFORM_OS2_
  568. }
  569.  
  570. //------------------------------------------------------------------------------
  571. // ODLink: CloneInto (OVERRIDE)
  572. //------------------------------------------------------------------------------
  573. // We don't clone the cross-document link info, so a second publisher can't be created.
  574. // This depends on this method being called rather than ODStorageUnit::CloneInto().
  575. // Currently, all link objects are internalized when a draft is opened, so this is true.
  576.  
  577. SOM_Scope void  SOMLINK ODLinkCloneInto(ODLink *somSelf, Environment *ev,
  578.                 ODDraftKey key,
  579.                 ODStorageUnit* toSU,
  580.                 ODFrame* scopeFrame)
  581. {
  582.     ODLinkData *somThis = ODLinkGetData(somSelf);
  583.     ODLinkMethodDebug("ODLink","CloneInto");
  584.  
  585. #ifdef _PLATFORM_OS2_
  586.  
  587.     parent_CloneInto(somSelf, ev, key, toSU, scopeFrame);
  588.  
  589. #else
  590.         SOM_CATCH return;
  591.  
  592.         // If one of our properties already exists, this object has been cloned already
  593.         if ( toSU->Exists(ev, kODPropLinkSection, kODApplesect, 0) )
  594.                 return;
  595.  
  596.         parent_CloneInto(somSelf, ev, key, toSU, scopeFrame);
  597.  
  598. #endif // _PLATFORM_OS2_
  599. }
  600.  
  601. //------------------------------------------------------------------------------
  602. // ODLink: ReleaseAll (OVERRIDE)
  603. //------------------------------------------------------------------------------
  604.  
  605. SOM_Scope void  SOMLINK ODLinkReleaseAll(ODLink *somSelf, Environment *ev)
  606. {
  607.     ODLinkData *somThis = ODLinkGetData(somSelf);
  608.     ODLinkMethodDebug("ODLink","ReleaseAll");
  609.  
  610. #ifdef _PLATFORM_OS2_
  611.  
  612.     parent_ReleaseAll(somSelf,ev);
  613.  
  614. #else
  615.         SOM_CATCH return;
  616.  
  617.     parent_ReleaseAll(somSelf,ev);
  618.  
  619.         if ( _fSection != (SectionHandle) kODNULL )
  620.         {
  621.                 if ( IsTopDraft(ev, somSelf->GetStorageUnit(ev)->GetDraft(ev)) )
  622.                 {
  623.                         if ( IsRegisteredSection(_fSection) == noErr )
  624.                         {
  625.                                 OSErr error = UnRegisterSection(_fSection);
  626.                                 somSelf->Release(ev);   // RefCount incremented when section was registered
  627.                         }
  628.                 }
  629.  
  630.                 ODDisposeHandle((ODHandle) (**_fSection).alias);
  631.                 ODDisposeHandle((ODHandle) _fSection);
  632.                 _fSection = (SectionHandle) kODNULL;
  633.         }
  634.  
  635. #endif // _PLATFORM_OS2_
  636. }
  637.  
  638. //------------------------------------------------------------------------------
  639. // ODBaseLink: UpdateDependents (OVERRIDE)
  640. //------------------------------------------------------------------------------
  641. #ifdef _PLATFORM_OS2_
  642. SOM_Scope void
  643. SOMLINK ODLinkUpdateDependents(ODLink *somSelf,
  644.                                Environment *ev,
  645.                                ODUpdateID id)
  646. #else
  647. SOM_Scope void  SOMLINK ODLinkUpdateDependents(ODLink *somSelf, Environment *ev)
  648. #endif
  649. {
  650.     ODLinkData *somThis = ODLinkGetData(somSelf);
  651.     ODLinkMethodDebug("ODLink","UpdateDependents");
  652.  
  653. #ifdef _PLATFORM_OS2_
  654.  
  655.     parent_UpdateDependents(somSelf, ev, id);
  656.  
  657. #else
  658.  
  659.         SOM_CATCH return;
  660.  
  661.     parent_UpdateDependents(somSelf, ev);
  662.  
  663.         if ( (_fSection != (SectionHandle) kODNULL) )
  664.         {
  665.                 ODBoolean autoUpdate = somSelf->GetLinkSource(ev)->IsAutoUpdate(ev);
  666.                 if ( autoUpdate )
  667.                 {
  668.                         ODLinkManager*  linkManager = somSelf->GetStorageUnit(ev)->GetSession(ev)->GetLinkManager(ev);
  669.                         linkManager->ExportOnSave(ev, somSelf, kODTrue);
  670.                 }
  671.                 else
  672.                 {
  673.                         ODLinkKey key;
  674.                         ODVolatile(key);
  675.                         if ( somSelf->Lock(ev, 0, &key) )
  676.                         {
  677.                                 TRY
  678.                                         somSelf->UpdateLinkEdition(ev, key);
  679.                                 CATCH_ALL
  680.                                         somSelf->Unlock(ev, key);
  681.                                         RERAISE;
  682.                                 ENDTRY
  683.                                 somSelf->Unlock(ev, key);
  684.                         }
  685.                 }
  686.         }
  687.  
  688. #endif // _PLATFORM_OS2_
  689. }
  690.  
  691. #ifdef _PLATFORM_MACINTOSH_
  692. //------------------------------------------------------------------------------
  693. // ODLink::ShowLinkDestinationInfo (OVERRIDE)
  694. //------------------------------------------------------------------------------
  695.  
  696. SOM_Scope ODBoolean  SOMLINK ODLinkShowLinkDestinationInfo(ODLink *somSelf, Environment *ev,
  697.                 ODFacet* facet,
  698.                 ODLinkInfo* info,
  699.                 ODBoolean changesAllowed,
  700.                 ODLinkInfoResult* infoResult)
  701. {
  702.     ODLinkData *somThis = ODLinkGetData(somSelf);
  703.     ODLinkMethodDebug("ODLink","ShowLinkDestinationInfo");
  704.  
  705.         SOM_CATCH return kODFalse;
  706.  
  707.         ODLinkSource* linkSource = somSelf->GetLinkSource(ev);
  708.  
  709.         ODError error = linkSource->GetStatus(ev);
  710.  
  711.         if ( error )
  712.                 ShowLinkStatusAlert(error);
  713.  
  714.         return parent_ShowLinkDestinationInfo(somSelf, ev, facet, info, changesAllowed, infoResult);
  715. }
  716. #endif // _PLATFORM_MACINTOSH_
  717.  
  718.  
  719. //------------------------------------------------------------------------------
  720. // ODLink: SetLinkDirty
  721. //------------------------------------------------------------------------------
  722.  
  723. SOM_Scope void  SOMLINK ODLinkSetLinkDirty(ODLink *somSelf, Environment *ev)
  724. {
  725.     ODLinkData *somThis = ODLinkGetData(somSelf);
  726.     ODLinkMethodDebug("ODLink","SetLinkDirty");
  727.  
  728.         SOM_TRY
  729.                 _fDirty = kODTrue;
  730.  
  731.                 ODDraft* draft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  732.                 if ( draft->GetPermissions(ev) != kODDPReadOnly )
  733.                         draft->SetChangedFromPrev(ev);
  734.         SOM_CATCH_ALL
  735.         SOM_ENDTRY
  736. }
  737.  
  738. #ifdef _PLATFORM_MACINTOSH_
  739.  
  740. //------------------------------------------------------------------------------
  741. // ODLink: CreateLinkEdition
  742. //------------------------------------------------------------------------------
  743.  
  744. SOM_Scope AliasHandle  SOMLINK ODLinkCreateLinkEdition(ODLink *somSelf, Environment *ev,
  745.                 EditionContainerSpec editionContainer,
  746.                 ODFileSpec* documentSpec,
  747.                 ODULong sectionID,
  748.                 ODLinkKey key)
  749. {
  750.     ODLinkData *somThis = ODLinkGetData(somSelf);
  751.     ODLinkMethodDebug("ODLink","CreateLinkEdition");
  752.  
  753.         AliasHandle result = (AliasHandle) kODNULL;
  754.  
  755.         OSErr error;
  756.         OSErr createError = mFulErr;    // Anything but noErr
  757.         SectionHandle tempSection = kODNULL;
  758.  
  759.         ODVolatile(createError);
  760.         ODVolatile(tempSection);
  761.         ODVolatile(editionContainer);
  762.  
  763.         SOM_TRY
  764.  
  765.                 somSelf->KeyValid(ev, key);
  766.  
  767.                 // Should throw kODErrCannotCreateLink if linkSource imports
  768.  
  769.                 if ( _fSection != kODNULL)
  770.                         THROW(kODErrLinkAlreadyExported);       // Internal error
  771.  
  772.                 FInfo documentFInfo;
  773.                 error = FSpGetFInfo((FSSpecPtr) documentSpec, &documentFInfo);
  774.                 THROW_IF_ERROR(error);
  775.  
  776.                 createError = CreateEditionContainerFile(&editionContainer.theFile,
  777.                                         documentFInfo.fdCreator, editionContainer.theFileScript);
  778.                 THROW_IF_ERROR(createError);
  779.  
  780.                 error = NewSection(&editionContainer, (FSSpecPtr) documentSpec, stPublisher, sectionID, pumOnSave, &tempSection);
  781.                 if ( (error != noErr) &&
  782.                          (error != multiplePublisherWrn) &&
  783.                          (error != notThePublisherWrn) )
  784.                 {
  785.                         THROW(error);
  786.                 }
  787.  
  788.                 (**tempSection).mdDate = (TimeStamp) somSelf->GetChangeTime(ev);
  789.                 (**tempSection).refCon = (long) somSelf;
  790.  
  791.                 somSelf->WriteLinkEdition(ev, tempSection, (FSSpecPtr) documentSpec, key);
  792.  
  793.                 // Edition file was successfully created and written, so add section to persistent state.
  794.                 // This Link must not be deleted until its section is unregistered!
  795.                 _fSection = tempSection;
  796.                 somSelf->Acquire(ev);
  797.  
  798.                 somSelf->SetLinkDirty(ev);
  799.  
  800.                 result = (**_fSection).alias;
  801.  
  802.         SOM_CATCH_ALL
  803.  
  804.                 if ( createError == noErr )
  805.                         DeleteEditionContainerFile(&editionContainer.theFile);
  806.  
  807.                 if ( tempSection )
  808.                 {
  809.                         UnRegisterSection(tempSection);
  810.                         ODDisposeHandle((ODHandle) (**tempSection).alias);
  811.                         ODDisposeHandle((ODHandle) tempSection);
  812.                 }
  813.  
  814.         SOM_ENDTRY
  815.  
  816.         return result;
  817. }
  818.  
  819. //------------------------------------------------------------------------------
  820. // ODLink: GetLinkEdition
  821. //------------------------------------------------------------------------------
  822.  
  823. SOM_Scope AliasHandle  SOMLINK ODLinkGetLinkEdition(ODLink *somSelf, Environment *ev,
  824.                 ODLinkKey key)
  825. {
  826.     ODLinkData *somThis = ODLinkGetData(somSelf);
  827.     ODLinkMethodDebug("ODLink","GetLinkEdition");
  828.  
  829.         AliasHandle editionAlias = (AliasHandle) kODNULL;
  830.  
  831.         SOM_CATCH return (AliasHandle) kODNULL;
  832.  
  833.         somSelf->KeyValid(ev, key);
  834.  
  835.         if (_fSection != (SectionHandle) kODNULL)
  836.                 editionAlias = (**_fSection).alias;
  837.  
  838.         return editionAlias;
  839. }
  840.  
  841. //------------------------------------------------------------------------------
  842. // ODLink: DeleteLinkEdition
  843. //------------------------------------------------------------------------------
  844.  
  845. SOM_Scope void  SOMLINK ODLinkDeleteLinkEdition(ODLink *somSelf, Environment *ev,
  846.                 ODLinkKey key)
  847. {
  848.     ODLinkData *somThis = ODLinkGetData(somSelf);
  849.     ODLinkMethodDebug("ODLink","DeleteLinkEdition");
  850.  
  851.         SOM_CATCH return;
  852.  
  853.         somSelf->KeyValid(ev, key);
  854.  
  855.         if ( _fSection != (SectionHandle) kODNULL )
  856.         {
  857.                 if ( IsTopDraft(ev, somSelf->GetStorageUnit(ev)->GetDraft(ev)) )
  858.                 {
  859.                         FSSpec editionFile;
  860.                         ODBoolean wasChanged;
  861.  
  862.                         OSErr error = ResolveAlias(nil, (**_fSection).alias, &editionFile, &wasChanged);
  863.                         THROW_IF_ERROR(error);
  864.  
  865.                         if ( IsRegisteredSection(_fSection) == noErr )
  866.                         {
  867.                                 error = UnRegisterSection(_fSection);
  868.                                 if ( error == noErr )
  869.                                         somSelf->Release(ev);   // RefCount incremented when section was registered
  870.                         }
  871.  
  872.                         error = DeleteEditionContainerFile(&editionFile);
  873.                         THROW_IF_ERROR(error);
  874.  
  875.                         ODDisposeHandle((ODHandle) (**_fSection).alias);
  876.                         ODDisposeHandle((ODHandle) _fSection);
  877.                         _fSection = (SectionHandle) kODNULL;
  878.  
  879.                         somSelf->SetLinkDirty(ev);
  880.                 }
  881.         }
  882. }
  883.  
  884. //------------------------------------------------------------------------------
  885. // ODLink: UpdateLinkEdition
  886. //------------------------------------------------------------------------------
  887.  
  888. SOM_Scope void  SOMLINK ODLinkUpdateLinkEdition(ODLink *somSelf, Environment *ev,
  889.                 ODLinkKey key)
  890. {
  891.     ODLinkData *somThis = ODLinkGetData(somSelf);
  892.     ODLinkMethodDebug("ODLink","UpdateLinkEdition");
  893.  
  894.         SOM_CATCH return;
  895.  
  896.         if (_fSection != (SectionHandle) kODNULL)
  897.         {
  898.                 ODTime changeTime = somSelf->GetChangeTime(ev);
  899.                 if ((TimeStamp) changeTime != (**_fSection).mdDate)
  900.                 {
  901.                         ODStorageUnit* storageUnit = somSelf->GetStorageUnit(ev);
  902.                         ODContainer* container = storageUnit->GetDraft(ev)->GetDocument(ev)->GetContainer(ev);;
  903.                         ODFileSpec documentSpec = GetODFileSpecFromContainer(ev, container);
  904.  
  905.                         (**_fSection).mdDate = (TimeStamp) changeTime;
  906.                         somSelf->WriteLinkEdition(ev, _fSection, &documentSpec, key);
  907.                 }
  908.         }
  909. }
  910.  
  911. //------------------------------------------------------------------------------
  912. // ODLink: GetPlatformValue
  913. //------------------------------------------------------------------------------
  914.  
  915. SOM_Scope ODHandle  SOMLINK ODLinkGetPlatformValue(ODLink *somSelf, Environment *ev,
  916.                 ODPlatformType platformType,
  917.                 ODLinkKey key)
  918. {
  919.     ODLinkData *somThis = ODLinkGetData(somSelf);
  920.     ODLinkMethodDebug("ODLink","GetPlatformValue");
  921.  
  922.         ODHandle                dataHandle = (ODHandle) kODNULL;
  923.  
  924.         SOM_TRY
  925.  
  926.         ODULong                 dataSize;
  927.         ODStorageUnit*  contentSU = somSelf->GetContentStorageUnit(ev, key);
  928.         ODValueType             isoType = kODNULL;
  929.  
  930.         ODVolatile(isoType);
  931.         ODVolatile(dataHandle);
  932.         TRY
  933.                 ODTranslation* translation = somSelf->GetStorageUnit(ev)->GetSession(ev)->GetTranslation(ev);
  934.                 isoType = translation->GetISOTypeFromPlatformType(ev, platformType, kODPlatformDataType);
  935.  
  936.                 if ( ODSUExistsThenFocus(ev, contentSU, kODPropContents, isoType) )
  937.                 {
  938.                         dataSize = contentSU->GetSize(ev);
  939.                         dataHandle = ODNewHandle(dataSize);
  940.                         ODValue dataPtr = ODLockHandle(dataHandle);
  941.                         StorageUnitGetValue(contentSU, ev, dataSize, dataPtr);
  942.                         ODUnlockHandle(dataHandle);
  943.                 }
  944.         CATCH_ALL
  945.                 ODDisposeHandle(dataHandle);
  946.                 dataHandle = (ODHandle) kODNULL;
  947.         ENDTRY
  948.  
  949.         ODDisposePtr(isoType);
  950.  
  951.         SOM_CATCH_ALL
  952.                 dataHandle = kODNULL;
  953.         SOM_ENDTRY
  954.  
  955.         return dataHandle;
  956. }
  957.  
  958. #endif // _PLATFORM_MACINTOSH_
  959. //------------------------------------------------------------------------------
  960. // ODLink: CloneToMemoryContainer
  961. //------------------------------------------------------------------------------
  962.  
  963. SOM_Scope ODHandle  SOMLINK ODLinkCloneToMemoryContainer(ODLink *somSelf, Environment *ev,
  964.                 ODLinkKey key)
  965. {
  966.     ODLinkData *somThis = ODLinkGetData(somSelf);
  967.     ODLinkMethodDebug("ODLink","CloneToMemoryContainer");
  968.  
  969.  
  970. #ifdef _PLATFORM_OS2_ // CED
  971.   _interrupt(3);
  972.   return (ODHandle) kODNULL;
  973. #else
  974.         SOM_CATCH return (ODHandle) kODNULL;
  975.  
  976.  
  977.         ODHandle                        containerHandle;
  978.         ODContainer*            container = (ODContainer*) kODNULL;
  979.         ODDocument*                     document = (ODDocument*) kODNULL;
  980.         ODDraft*                        draft = (ODDraft*) kODNULL;
  981.         ODStorageUnit*          draftProperties = (ODStorageUnit*) kODNULL;
  982.         ODStorageUnit*          contentSU = (ODStorageUnit*) kODNULL;
  983.         ODDraft*                        myDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
  984.         ODSession*                      session = somSelf->GetStorageUnit(ev)->GetSession(ev);
  985.         ODStorageUnitID         rootSUID = 0;
  986.  
  987.         ODVolatile(draft);
  988.         ODVolatile(draftProperties);
  989.         ODVolatile(document);
  990.         ODVolatile(container);
  991.         ODVolatile(containerHandle);
  992.         ODVolatile(myDraft);
  993.  
  994.         contentSU = somSelf->GetContentStorageUnit(ev, key);
  995.  
  996.         // Externalize contentSU to force resolution of promises before the
  997.         // clone into the memory container is begun.
  998.         contentSU->Externalize(ev);
  999.  
  1000.         containerHandle = ODNewHandle(0);
  1001.         TRY
  1002.                 container = CreateMemoryContainer(ev, session, containerHandle, kODBentoMemoryContainer);
  1003.  
  1004.                 document = container->AcquireDocument(ev, kODDefaultDocument);
  1005.  
  1006.                 draft = document->AcquireBaseDraft(ev, kODDPExclusiveWrite);
  1007.  
  1008.                 ODDraftKey draftKey = myDraft->BeginClone(ev, draft, kODNULL, kODCloneAll);
  1009.                 ODVolatile(draftKey);
  1010.                 TRY
  1011.                         rootSUID = myDraft->Clone(ev, draftKey, contentSU->GetID(ev), kODNULLID, 0);
  1012.  
  1013.                         if ( ODSUExistsThenFocus(ev, contentSU, kODPropContentFrame, kODWeakStorageUnitRef) )
  1014.                         {
  1015.                                 ODID contentFrameID = ODGetWeakSURefProp(ev, contentSU, kODPropContentFrame, kODWeakStorageUnitRef);
  1016.                                 myDraft->Clone(ev, draftKey, contentFrameID, kODNULLID, 0);
  1017.                         }
  1018.                 CATCH_ALL
  1019.                         myDraft->AbortClone(ev, draftKey);
  1020.                         RERAISE;
  1021.                 ENDTRY
  1022.  
  1023.                 myDraft->EndClone(ev, draftKey);
  1024.  
  1025.                 draftProperties = draft->AcquireDraftProperties(ev);
  1026.                 ODSetStrongSURefProp(ev, draftProperties, kODPropRootPartSU, kODStrongStorageUnitRef, rootSUID);
  1027.                 draftProperties->Release(ev);
  1028.                 draftProperties = kODNULL;
  1029.  
  1030.                 draft->Externalize(ev);
  1031.                 draft->Release(ev);
  1032.                 document->Release(ev);
  1033.                 container->Release(ev);
  1034.  
  1035.         CATCH_ALL
  1036.                 ODReleaseObject(ev, draftProperties);
  1037.                 ODReleaseObject(ev, draft);
  1038.                 ODReleaseObject(ev, document);
  1039.                 ODReleaseObject(ev, container);
  1040.  
  1041.                 ODDisposeHandle(containerHandle);
  1042.                 RERAISE;
  1043.         ENDTRY
  1044.  
  1045.         return containerHandle;
  1046.  
  1047. #endif // _PLATFORM_OS2_
  1048. }
  1049.  
  1050. #ifdef _PLATFORM_MACINTOSH_
  1051. //------------------------------------------------------------------------------
  1052. // ODLink: WriteLinkEdition
  1053. //------------------------------------------------------------------------------
  1054.  
  1055. SOM_Scope void  SOMLINK ODLinkWriteLinkEdition(ODLink *somSelf, Environment *ev,
  1056.                 SectionHandle section,
  1057.                 ODFileSpec* documentSpec,
  1058.                 ODLinkKey key)
  1059. {
  1060.     ODLinkData *somThis = ODLinkGetData(somSelf);
  1061.     ODLinkMethodDebug("ODLink","WriteLinkEdition");
  1062.  
  1063.         OSErr                   infoError;
  1064.         OSErr                   openError;
  1065.         OSErr                   writeError = noErr;
  1066.         EditionRefNum   edRefNum = 0;
  1067.         ODHandle                dataHandle = (ODHandle) kODNULL;
  1068.         ODBoolean               successful = kODTrue;
  1069.  
  1070.         ODVolatile(dataHandle);
  1071.         ODVolatile(successful);
  1072.  
  1073.         SOM_TRY
  1074.  
  1075.                 if ( section == (SectionHandle) kODNULL )
  1076.                         THROW(kODErrNotExportedLink);
  1077.  
  1078.                 FInfo documentFInfo;
  1079.                 infoError = FSpGetFInfo((FSSpecPtr) documentSpec, &documentFInfo);
  1080.                 THROW_IF_ERROR(infoError);
  1081.  
  1082.                 openError = OpenNewEdition(section, documentFInfo.fdCreator, documentSpec, &edRefNum);
  1083.                 THROW_IF_ERROR(openError);
  1084.  
  1085.                 dataHandle = somSelf->CloneToMemoryContainer(ev, key);
  1086.                 if ( dataHandle != (ODHandle) kODNULL )
  1087.                 {
  1088.                         ODPtr dataPtr = ODLockHandle(dataHandle);
  1089.                         writeError = WriteEdition(edRefNum, kODScrapTypeODBentoContainer, dataPtr, ODGetHandleSize(dataHandle));
  1090.                         ODDisposeHandle(dataHandle);
  1091.                         dataHandle = kODNULL;
  1092.                 }
  1093.                 THROW_IF_ERROR(writeError);
  1094.  
  1095.                 // Also write out any text content property (unnecessary for OpenDoc, but allows
  1096.                 // subscribing by non-OpenDoc applications, and allows the Edition Manager to display
  1097.                 // content in the GetInfo dialog.
  1098.                 dataHandle = somSelf->GetPlatformValue(ev, 'TEXT', key);
  1099.                 if ( dataHandle != (ODHandle) kODNULL )
  1100.                 {
  1101.                         ODPtr dataPtr = ODLockHandle(dataHandle);
  1102.                         writeError = WriteEdition(edRefNum, 'TEXT', dataPtr, ODGetHandleSize(dataHandle));
  1103.                         ODUnlockHandle(dataHandle);
  1104.                         ODDisposeHandle(dataHandle);
  1105.                         dataHandle = kODNULL;
  1106.                 }
  1107.                 THROW_IF_ERROR(writeError);
  1108.  
  1109.                 dataHandle = somSelf->GetPlatformValue(ev, 'PICT', key);
  1110.                 if ( dataHandle != (ODHandle) kODNULL )
  1111.                 {
  1112.                         ODPtr dataPtr = ODLockHandle(dataHandle);
  1113.                         writeError = WriteEdition(edRefNum, 'PICT', dataPtr, ODGetHandleSize(dataHandle));
  1114.                         ODUnlockHandle(dataHandle);
  1115.                         ODDisposeHandle(dataHandle);
  1116.                         dataHandle = kODNULL;
  1117.                 }
  1118.                 THROW_IF_ERROR(writeError);
  1119.  
  1120.  
  1121.         SOM_CATCH_ALL
  1122.  
  1123.                 ODDisposeHandle(dataHandle);
  1124.                 successful = kODFalse;
  1125.  
  1126.         SOM_ENDTRY;
  1127.  
  1128.         if ( edRefNum != 0 )
  1129.                 CloseEdition(edRefNum, successful);
  1130. }
  1131. #endif // _PLATFORM_MACINTOSH_
  1132.  
  1133.  
  1134. #ifdef _PLATFORM_OS2_
  1135. //------------------------------------------------------------------------------
  1136. // ODLink: GetLinkSourceConnectionData
  1137. //------------------------------------------------------------------------------
  1138. SOM_Scope void  SOMLINK ODLinkGetLinkSourceConnectionData(ODLink *somSelf, Environment *ev,
  1139.                 ODLinkConnectionData** srcConnData)
  1140. {
  1141.     ODLinkData *somThis = ODLinkGetData(somSelf);
  1142.     ODLinkMethodDebug("ODLink","GetLinkSourceConnectionData");
  1143.     somSelf->SubClassResponsibility(ev);
  1144. }
  1145.  
  1146. //------------------------------------------------------------------------------
  1147. // ODLink: SetDescription
  1148. //------------------------------------------------------------------------------
  1149. SOM_Scope void  SOMLINK ODLinkSetDescription(ODLink *somSelf,
  1150.                                               Environment *ev,
  1151.                                              ODLinkDescription* Desc)
  1152. {
  1153.     ODLinkData *somThis = ODLinkGetData(somSelf);
  1154.     ODLinkMethodDebug("ODLink","SetDescription");
  1155.     somSelf->SubClassResponsibility(ev);
  1156. }
  1157.  
  1158. //------------------------------------------------------------------------------
  1159. // ODLink: GetConnectionData
  1160. //------------------------------------------------------------------------------
  1161. SOM_Scope void  SOMLINK ODLinkGetConnectionData(ODLink *somSelf, Environment *ev,
  1162.                 ODLinkConnectionData** ConnData)
  1163. {
  1164.     ODLinkData *somThis = ODLinkGetData(somSelf);
  1165.     ODLinkMethodDebug("ODLink","GetConnectionData");
  1166.     somSelf->SubClassResponsibility(ev);
  1167. }
  1168.  
  1169. //--------------------------------------------------------------------------------
  1170. //ODLink:GetDescription
  1171. //---------------------------------------------------------------------------------
  1172.  
  1173. SOM_Scope void  SOMLINK ODLinkGetDescription(ODLink *somSelf,
  1174.                                               Environment *ev,
  1175.                                              ODLinkDescription* Desc)
  1176. {
  1177.     /* ODLinkData *somThis = ODLinkGetData(somSelf); */
  1178.     ODLinkMethodDebug("ODLink","ODLinkGetDescription");
  1179.     somSelf->SubClassResponsibility(ev);
  1180.  
  1181. }
  1182.  
  1183. //--------------------------------------------------------------------------------
  1184. //ODLink:IsRegistered
  1185. //---------------------------------------------------------------------------------
  1186.  
  1187. SOM_Scope ODBoolean  SOMLINK ODLinkIsRegistered(ODLink *somSelf,
  1188.                                                  Environment *ev)
  1189. {
  1190.     /* ODLinkData *somThis = ODLinkGetData(somSelf); */
  1191.     ODLinkMethodDebug("ODLink","ODLinkIsRegistered");
  1192.     somSelf->SubClassResponsibility(ev);
  1193. }
  1194.  
  1195. #endif /*_PLATFORM_OS2_*/
  1196.  
  1197.