home *** CD-ROM | disk | FTP | other *** search
- /*
- File: LinkSrc.cpp
-
- Contains: Implementation of ODLinkSource class
-
- Owned by: Craig Carper
-
- Copyright: © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <2> 5/24/96 jpa 1246074: SOM_CATCH --> SOM_TRY..SOM_ENDTRY
-
- To Do:
- In Progress:
-
- */
-
- #define VARIABLE_MACROS
-
- #define ODLinkSource_Class_Source
- #include <LinkSrc.xih>
-
- #ifndef SOM_ODLink_xh
- #include <Link.xh>
- #endif
-
- #ifndef _EXCEPT_
- #include <Except.h>
- #endif
-
- #ifndef _ODMEMORY_
- #include <ODMemory.h>
- #endif
-
- #ifndef _CONSTDEF_
- #include <ConstDef.h>
- #endif
-
- #ifndef SOM_ODLinkManager_xh
- #include <LinkMgr.xh>
- #endif
-
- #ifndef SOM_ODPart_xh
- #include <Part.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODContainer_xh
- #include <ODCtr.xh>
- #endif
-
- #ifndef SOM_ODDocument_xh
- #include <Document.xh>
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- #ifndef SOM_ODStorageSystem_xh
- #include <ODStor.xh>
- #endif
-
- #ifndef _PLFMFILE_
- #include <PlfmFile.h>
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifndef _ISOSTR_
- #include <ISOStr.h>
- #endif
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- #ifndef _ODUTILS_
- #include <ODUtils.h>
- #endif
-
- #ifndef _DOCUTILS_
- #include <DocUtils.h>
- #endif
-
- #ifndef _ODDEBUG_
- #include <ODDebug.h>
- #endif
-
- #ifndef _BARRAY_
- #include <BArray.h>
- #endif
-
- #ifndef _STDTYPIO_
- #include <StdTypIO.h>
- #endif
-
- #ifndef _STORUTIL_
- #include <StorUtil.h>
- #endif
-
- #ifndef _TEMPOBJ_
- #include "TempObj.h"
- #endif
-
- #pragma segment ODLinkSource
-
- //==============================================================================
- // ODLinkSource
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // ODLinkSource: somUninit
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourcesomUninit(ODLinkSource *somSelf)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","somUninit");
-
- parent_somUninit(somSelf);
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: InitLinkSource
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourceInitLinkSource(ODLinkSource *somSelf, Environment *ev,
- ODStorageUnit* storageUnit,
- ODPart* sourcePart)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","InitLinkSource");
-
- SOM_TRY
-
- /* Moved from somInit. SOM itself sets fields to zero
- _fSection = (SectionHandle) kODNULL;
- _fStatus = 0;
- _fDirty = kODFalse;
- */
- somSelf->InitBaseLinkSource(ev, storageUnit, sourcePart);
-
- somSelf->SetLinkSourceDirty(ev);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: InitLinkSourceFromStorage
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourceInitLinkSourceFromStorage(ODLinkSource *somSelf, Environment *ev,
- ODStorageUnit* storageUnit)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","InitLinkSourceFromStorage");
-
- SOM_TRY
-
- /* Moved from somInit. SOM itself sets fields to zero
- _fSection = (SectionHandle) kODNULL;
- _fStatus = 0;
- _fDirty = kODFalse;
- */
- somSelf->InitBaseLinkSourceFromStorage(ev, storageUnit);
-
- if (ODSUExistsThenFocus(ev, storageUnit, kODPropLinkSection, kODApplesect) )
- {
- const int sectionRecordSize = sizeof(SectionRecord);
-
- ODValue value;
-
- if ( storageUnit->GetSize(ev) != sectionRecordSize )
- THROW(kODErrCorruptLinkSource);
-
- _fSection = (SectionHandle) ODNewHandle(sectionRecordSize);
- value = ODLockHandle((ODHandle) _fSection);
- StorageUnitGetValue(storageUnit, ev, sectionRecordSize, value);
- ODUnlockHandle((ODHandle) _fSection);
-
- if ( (**_fSection).kind != stSubscriber )
- {
- ODDisposeHandle((ODHandle) _fSection);
- _fSection = (SectionHandle) kODNULL;
- THROW(kODErrCorruptLinkSource);
- }
-
- storageUnit->Focus(ev, kODPropEditionAlias, kODPosUndefined, kODApplealis, (ODValueIndex)0, kODPosUndefined);
- ODULong size = storageUnit->GetSize(ev);
-
- if ( size < sizeof(AliasRecord) )
- {
- ODDisposeHandle((ODHandle) _fSection);
- _fSection = (SectionHandle) kODNULL;
- THROW(kODErrCorruptLinkSource);
- }
-
- AliasHandle alias = (AliasHandle) ODNewHandle(size);
- value = ODLockHandle((ODHandle) alias);
- StorageUnitGetValue(storageUnit, ev, size, value);
- ODUnlockHandle((ODHandle) alias);
-
- (**_fSection).alias = alias;
- (**_fSection).refCon = (long) somSelf;
-
- ODDraftPermissions permissions = storageUnit->GetDraft(ev)->GetPermissions(ev);
-
- if (HAS_WRITE_ACCESS(permissions))
- {
- ODBoolean aliasWasUpdated;
-
- ODContainer* container = storageUnit->GetDraft(ev)->GetDocument(ev)->GetContainer(ev);
- ODFileSpec documentSpec = GetODFileSpecFromContainer(ev, container);
-
- _fStatus = RegisterSection(&documentSpec, _fSection, &aliasWasUpdated);
-
- // Remember any error returned by RegisterSection. The most likely errors are:
- // multiplePublisherWrn = -460, A Publisher is already registered for that container
- // containerNotFoundWrn = -461, Could not find editionContainer at this time
- // containerAlreadyOpenWrn = -462, Container already opened by this section
- // notThePublisherWrn = -463, Not the first registered publisher for that container
-
- if ( _fStatus == containerNotFoundWrn )
- _fStatus = kODErrCannotFindLinkSourceEdition;
-
- somSelf->Acquire(ev); // Link must not be deleted untill its section is unregistered!
- }
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: Release (OVERRIDE)
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourceRelease(ODLinkSource *somSelf, Environment *ev)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","Release");
-
- SOM_TRY
-
- parent_Release(somSelf, ev);
-
- #if ODDebug
- somPrintf("ODLinkSource %d::Release: Ref count is %d\n", somSelf->GetID(ev), somSelf->GetRefCount(ev));
- #endif
-
- if ( somSelf->GetRefCount(ev) == 0 )
- somSelf->GetStorageUnit(ev)->GetDraft(ev)->ReleaseLinkSource(ev, somSelf);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: Externalize (OVERRIDE)
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourceExternalize(ODLinkSource *somSelf, Environment *ev)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","Externalize");
-
- SOM_TRY
-
- parent_Externalize(somSelf,ev);
-
- if ( _fDirty )
- {
- ODStorageUnit* su = somSelf->GetStorageUnit(ev);
-
- if ( _fSection == (SectionHandle) kODNULL )
- {
- ODSURemoveProperty(ev, su, kODPropLinkSection);
- ODSURemoveProperty(ev, su, kODPropEditionAlias);
- }
- else
- {
- SectionPtr theSectionPtr = (SectionPtr) ODLockHandle((ODHandle) _fSection);
-
- ODSUForceFocus(ev, su, kODPropLinkSection, kODApplesect);
- StorageUnitSetValue(su, ev, ODGetHandleSize((ODHandle) _fSection), (ODValue) theSectionPtr);
-
- ODValue theAliasPtr = ODLockHandle((ODHandle) theSectionPtr->alias);
- ODSUForceFocus(ev, su, kODPropEditionAlias, kODApplealis);
- StorageUnitSetValue(su, ev, ODGetHandleSize((ODHandle) theSectionPtr->alias), theAliasPtr);
-
- ODUnlockHandle((ODHandle) theSectionPtr->alias);
- ODUnlockHandle((ODHandle) _fSection);
- }
- _fDirty = kODFalse;
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: CloneInto (OVERRIDE)
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourceCloneInto(ODLinkSource *somSelf, Environment *ev,
- ODDraftKey key,
- ODStorageUnit* toSU,
- ODFrame* scopeFrame)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","CloneInto");
-
- SOM_TRY
-
- // If one of our properties already exists, this object has been cloned already
- if ( toSU->Exists(ev, kODPropLinkSection, kODApplesect, 0) )
- return;
-
- parent_CloneInto(somSelf, ev, key, toSU, scopeFrame);
-
- if ( _fSection != (SectionHandle) kODNULL )
- {
- ODSUForceFocus(ev, toSU, kODPropLinkSection, kODApplesect);
- StorageUnitSetValue(toSU, ev, ODGetHandleSize((ODHandle) _fSection), (ODValue) *_fSection);
-
- ODSUForceFocus(ev, toSU, kODPropEditionAlias, kODApplealis);
- StorageUnitSetValue(toSU, ev, ODGetHandleSize((ODHandle) (**_fSection).alias), (ODValue) *((**_fSection).alias));
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: ReleaseAll (OVERRIDE)
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourceReleaseAll(ODLinkSource *somSelf, Environment *ev)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","ReleaseAll");
-
- SOM_TRY
-
- parent_ReleaseAll(somSelf,ev);
-
- if ( _fSection != (SectionHandle) kODNULL )
- {
- ODDraftPermissions permissions = somSelf->GetStorageUnit(ev)->GetDraft(ev)->GetPermissions(ev);
-
- if (HAS_WRITE_ACCESS(permissions))
- {
- OSErr error = UnRegisterSection(_fSection);
- somSelf->Release(ev); // RefCount incremented when section was registered
- }
-
- ODDisposeHandle((ODHandle) (**_fSection).alias);
- ODDisposeHandle((ODHandle) _fSection);
- _fSection = (SectionHandle) kODNULL;
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: SetAutoUpdate (OVERRIDE)
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourceSetAutoUpdate(ODLinkSource *somSelf, Environment *ev,
- ODBoolean automatic)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","SetAutoUpdate");
-
- SOM_TRY
-
- parent_SetAutoUpdate(somSelf, ev, automatic);
-
- if ( automatic == kODFalse )
- {
- ODLinkManager* linkManager = somSelf->GetStorageUnit(ev)->GetSession(ev)->GetLinkManager(ev);
- ODLink* link = kODNULL;
-
- TRY
- link = somSelf->GetLink(ev);
- CATCH_ALL
- ENDTRY
-
- if ( link && linkManager->ExportOnSave(ev, link, kODFalse) )
- {
- // The link source was changed from automatic to manual updating,
- // and the last change was waiting for a save to update the edition file.
- // Update the edition file now, so cross-document destinations are
- // consistent with destinations in the same document. The user will not
- // be able to manually update the link until another change is made
- // to the source of the link.
- ODLinkKey key;
- if ( link->Lock(ev,0,&key) )
- {
- TRY
- link->UpdateLinkEdition(ev, key);
- CATCH_ALL
- ENDTRY
- link->Unlock(ev, key);
- }
- }
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: ShowSourceContent (OVERRIDE)
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourceShowSourceContent(ODLinkSource *somSelf, Environment *ev)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","ShowSourceContent");
-
- SOM_TRY
-
- if ( _fSection != (SectionHandle) kODNULL )
- {
- EditionInfoRecord infoRec;
- OSErr error;
-
- if ( IsRegisteredSection(_fSection) == notRegisteredSectionErr )
- {
- // Temporarily register to get Editon info
- // $$$$$ This may cause an section Apple event to arrive
- ODBoolean aliasWasUpdated;
- ODContainer* container = somSelf->GetStorageUnit(ev)->GetDraft(ev)->GetDocument(ev)->GetContainer(ev);
- ODFileSpec documentSpec = GetODFileSpecFromContainer(ev, container);
- RegisterSection(&documentSpec, _fSection, &aliasWasUpdated);
- error = GetEditionInfo(_fSection, &infoRec);
- UnRegisterSection(_fSection);
- }
- else
- {
- error = GetEditionInfo(_fSection, &infoRec);
- }
- if ( error != noErr )
- THROW(kODErrCannotFindLinkSource);
-
- error = GoToPublisherSection(&infoRec.container);
- if ( error == fnfErr )
- THROW(kODErrCannotFindLinkSourceEdition);
- else if ( error != noErr )
- THROW(kODErrCannotFindLinkSource);
- }
- else
- {
- parent_ShowSourceContent(somSelf, ev);
- }
-
- SOM_CATCH_ALL
- #if ODDebug
- somPrintf("ODLinkSource %d: ShowSourceContent :Error %d caught\n", somSelf->GetID(ev), ErrorCode());
- #endif
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: SetSourcePart (OVERRIDE)
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourceSetSourcePart(ODLinkSource *somSelf, Environment *ev,
- ODStorageUnit* sourcePartSU)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","SetSourcePart");
-
- SOM_TRY
-
- ODLinkManager* linkManager = somSelf->GetStorageUnit(ev)->GetSession(ev)->GetLinkManager(ev);
-
- // If there is no source part for this link, delete the edition file when the
- // draft is saved; is there is a source part, make sure the edition file
- // is still maintained.
- linkManager->DeleteOnSave(ev, somSelf->GetLink(ev), (sourcePartSU == kODNULL));
-
- parent_SetSourcePart(somSelf, ev, sourcePartSU);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: SetLinkSourceDirty
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourceSetLinkSourceDirty(ODLinkSource *somSelf, Environment *ev)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","SetLinkSourceDirty");
-
- SOM_TRY
- _fDirty = kODTrue;
-
- ODDraft* draft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
- if ( draft->GetPermissions(ev) != kODDPReadOnly )
- draft->SetChangedFromPrev(ev);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: UseLinkEdition
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourceUseLinkEdition(ODLinkSource *somSelf, Environment *ev,
- EditionContainerSpec editionContainer,
- ODFileSpec* documentSpec,
- ODULong sectionID,
- ODLinkKey key)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","UseLinkEdition");
-
- SOM_TRY
-
- somSelf->KeyValid(ev, key);
-
- if ( _fSection != (SectionHandle) kODNULL )
- THROW(kODErrAlreadyImportedLink);
-
- OSErr error = NewSection(&editionContainer, documentSpec, stSubscriber, sectionID, sumAutomatic, &_fSection);
- THROW_IF_ERROR(error);
-
- (**_fSection).refCon = (long) somSelf;
- somSelf->Acquire(ev); // Link must not be deleted untill its section is unregistered!
-
- somSelf->SetLinkSourceDirty(ev);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: ReadLinkEdition
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourceReadLinkEdition(ODLinkSource *somSelf, Environment *ev,
- ODLinkKey key)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","ReadLinkEdition");
-
- SOM_TRY
-
- somSelf->KeyValid(ev, key);
-
- OSErr openError;
- OSErr readError = noErr;
- OSErr closeError;
- EditionRefNum edRefNum;
- ODHandle dataHandle = kODNULL; ODVolatile(dataHandle);
- long dataSize;
- ODBoolean successful = kODFalse;
-
- if ( _fSection == (SectionHandle) kODNULL )
- THROW(kODErrNotImportedLink);
-
- openError = OpenEdition(_fSection, &edRefNum);
- if ( openError )
- {
- _fStatus = openError;
- THROW(openError);
- }
- else if ( _fStatus == kODErrCannotFindLinkSourceEdition )
- {
- _fStatus = 0;
- }
-
- readError = EditionHasFormat(edRefNum, kODScrapTypeODBentoContainer, &dataSize);
- if ( readError )
- _fStatus = readError;
- if ( (readError == noErr) && (dataSize > 0) )
- {
- TRY
- dataHandle = ODNewHandle(dataSize);
- void* dataPtr = ODLockHandle(dataHandle);
- readError = ReadEdition (edRefNum, kODScrapTypeODBentoContainer, dataPtr, &dataSize);
- ODUnlockHandle(dataHandle);
- THROW_IF_ERROR(readError);
-
- // Changes originating in another document get a fresh change ID, since
- // OpenDoc is not concerned with cycles across documents.
- // Note that the source document does not mark the edition file with a change ID
- // (one could be kept in the draft properties, I suppose).
- ODUpdateID updateID = somSelf->GetStorageUnit(ev)->GetSession(ev)->UniqueUpdateID(ev);
- somSelf->Clear(ev, updateID, key);
- ODStorageUnit* contentSU = somSelf->GetContentStorageUnit(ev, key);
-
- // Existing properties inhibit cloning in the same property, so remove all properties
- // from the content storage unit before cloning.
- contentSU->Focus(ev, (ODPropertyName) kODNULL, kODPosAll, kODTypeAll, 0, kODPosUndefined);
- ODULong numProperties = contentSU->CountProperties(ev);
- ODULong i;
- for (i = 1; i <= numProperties; i++) {
- contentSU->Focus(ev, (ODPropertyName) kODNULL, kODPosNextSib, kODTypeAll, 0, kODPosUndefined);
- contentSU->Remove(ev);
- }
-
- somSelf->CloneFromMemoryContainer(ev, contentSU, dataHandle);
-
- successful = kODTrue;
-
- ODDisposeHandle(dataHandle);
- CATCH_ALL
- _fStatus = ErrorCode();
- ODDisposeHandle(dataHandle);
- WARN("Throw from ReadEditionFile");
- ENDTRY
- }
-
- closeError = CloseEdition(edRefNum, successful);
- if ( successful )
- somSelf->SetChangeTime(ev, (**_fSection).mdDate, key);
-
- THROW_IF_ERROR(readError);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: SetStatus
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODLinkSourceSetStatus(ODLinkSource *somSelf, Environment *ev,
- ODError error)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","SetStatus");
-
- _fStatus = error;
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: GetStatus
- //------------------------------------------------------------------------------
-
- SOM_Scope ODError SOMLINK ODLinkSourceGetStatus(ODLinkSource *somSelf, Environment *ev)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","GetStatus");
-
- return _fStatus;
- }
-
- //------------------------------------------------------------------------------
- // ODLinkSource: CloneFromMemoryContainer
- //------------------------------------------------------------------------------
- // This method does not call it's draft's SetChangeFromPrev() method so that the
- // user is not prompted to save changes if the only change was to update a link
- // from an edition file.
-
-
- SOM_Scope void SOMLINK ODLinkSourceCloneFromMemoryContainer(ODLinkSource *somSelf, Environment *ev,
- ODStorageUnit* contentSU,
- ODHandle containerHandle)
- {
- ODLinkSourceData *somThis = ODLinkSourceGetData(somSelf);
- ODLinkSourceMethodDebug("ODLinkSource","CloneFromMemoryContainer");
-
- SOM_TRY
-
- ODStorageUnitID rootID;
- ODDraft* myDraft = contentSU->GetDraft(ev);
- ODSession* session = somSelf->GetStorageUnit(ev)->GetSession(ev);
-
- TempODContainer container = GetMemoryContainer(ev, session, containerHandle, kODBentoMemoryContainer);
-
- TempODDocument document = container->AcquireDocument(ev, kODDefaultDocument);
-
- TempODDraft draft = document->AcquireBaseDraft(ev, kODDPExclusiveWrite);
-
- { TempODStorageUnit draftProperties = draft->AcquireDraftProperties(ev);
- rootID = ODGetStrongSURefProp(ev, draftProperties, kODPropRootPartSU, kODStrongStorageUnitRef);
- }
-
- TempODStorageUnit rootSU = draft->AcquireStorageUnit(ev, rootID);
-
- ODDraftKey draftKey = draft->BeginClone(ev, myDraft, kODNULL, kODCloneAll);
- TRY
- draft->Clone(ev, draftKey, rootID, contentSU->GetID(ev), 0);
-
- if ( ODSUExistsThenFocus(ev, rootSU, kODPropContentFrame, kODWeakStorageUnitRef) )
- {
- ODID contentFrameID = ODGetWeakSURefProp(ev, rootSU, kODPropContentFrame, kODWeakStorageUnitRef);
- draft->Clone(ev, draftKey, contentFrameID, kODNULLID, 0);
- }
- CATCH_ALL
- draft->AbortClone(ev, draftKey);
- RERAISE;
- ENDTRY
- draft->EndClone(ev, draftKey);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-