home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 5.0 KB | 184 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPrmise.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWPRMISE_H
- #include "FWPrmise.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWCLNINF_H
- #include "FWClnInf.h"
- #endif
-
- #ifndef FWINTER_H
- #include "FWInter.h"
- #endif
-
- #ifndef FWLNKSRC_H
- #include "FWLnkSrc.h"
- #endif
-
- #ifndef FWSESION_H
- #include "FWSesion.h"
- #endif
-
- // ----- OS Layer Includes -----
-
- #ifndef FWBARRAY_H
- #include "FWBArray.h"
- #endif
-
- #ifndef FWSUUTIL_H
- #include "FWSUUtil.h"
- #endif
-
- // ----- Foundation Layer Includes -----
-
- #ifndef FWMEMORY_H
- #include "FWMemory.h"
- #endif
-
- #ifndef FWSOMENV_H
- #include "FWSOMEnv.h"
- #endif
-
- #ifndef SLPRISTR_H
- #include "SLPriStr.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODClipboard_xh
- #include <Clipbd.xh>
- #endif
-
- #ifndef SOM_ODStorageUnitView_xh
- #include <SUView.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwpart2
- #endif
-
- //========================================================================================
- // Template Instantiations
- //========================================================================================
-
- FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollectionIterator, FW_CPromise)
- FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollection, FW_CPromise)
-
- #ifdef FW_USE_TEMPLATE_PRAGMAS
-
- #pragma template_access public
- #pragma template FW_TOrderedCollection<FW_CPromise>
- #pragma template FW_TOrderedCollectionIterator<FW_CPromise>
-
- #endif
-
- //========================================================================================
- // class FW_CPromise
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPromise::FW_CPromise
- //----------------------------------------------------------------------------------------
-
- FW_CPromise::FW_CPromise(Environment*ev, FW_StorageKinds storageKind, FW_CCloneInfo* cloneInfo, FW_CLinkSource* linkSrc) :
- fScopeFrame(cloneInfo->GetScopeFrame(ev)),
- fDataInterchange(cloneInfo->GetDataInterchange(ev)),
- fStorageKind(storageKind),
- fUpdateID(0),
- fPromiseCount(0),
- fLinkSource(linkSrc)
- {
- FW_ASSERT(fStorageKind != FW_kPartStorage); // can't promise on the part storage
- FW_ASSERT(fStorageKind != FW_kFileStorage); // can't promise on a file storage
-
- fUpdateID = FW_CSession::GetClipboard(ev)->GetUpdateID(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPromise::~FW_CPromise
- //----------------------------------------------------------------------------------------
-
- FW_CPromise::~FW_CPromise()
- {
- FW_SOMEnvironment ev;
-
- fDataInterchange->PrivPromiseDeleted(ev, this);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPromise::Promise
- //----------------------------------------------------------------------------------------
-
- void FW_CPromise::Promise(Environment* ev, ODStorageUnit* storageUnit, ODPropertyName propertyName, ODValueType valueType)
- {
- fDataInterchange->PrivPromise(ev, this, storageUnit, propertyName, valueType);
- fPromiseCount++;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPromise::PrivHandleFulfillPromise
- //----------------------------------------------------------------------------------------
-
- long FW_CPromise::PrivHandleFulfillPromise(Environment* ev, FW_CPart* part, ODStorageUnitView* promiseSUView)
- {
- ODDraft* fromDraft = fScopeFrame->GetPart(ev)->GetDraft(ev);
- ODDraft* dstDraft = promiseSUView->GetStorageUnit(ev)->GetDraft(ev);
-
- // Get the cloneKind from the kODPropCloneKindUsed property, if it's available
- ODCloneKind cloneKind;
- if (FW_SUExistsThenFocus(ev, promiseSUView->GetStorageUnit(ev), kODPropCloneKindUsed, kODCloneKind) )
- {
- FW_CByteArray byteArray;
- promiseSUView->GetStorageUnit(ev)->GetValue(ev, sizeof(ODCloneKind), byteArray);
- byteArray.CopyBuffer(&cloneKind, sizeof(ODCloneKind));
- }
- else
- cloneKind = (fStorageKind == FW_kLinkStorage) ? kODCloneToLink : kODCloneCopy;
-
- FW_CAcquireODPropertyName propertyName(ev, promiseSUView);
- FW_CAcquireODISOStr valueType = promiseSUView->GetType(ev);
-
- FW_CCloneInfo cloneInfo(ev, fromDraft, fScopeFrame, cloneKind);
- cloneInfo.BeginClone(ev, dstDraft);
-
- FulfillPromise(ev, part, promiseSUView, propertyName, valueType, &cloneInfo);
-
- cloneInfo.EndClone(ev);
-
- return --fPromiseCount;
- }
-