home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / Sources / FWClnInf.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  5.3 KB  |  189 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWClnInf.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWCLNINF_H
  13. #include "FWClnInf.h"
  14. #endif
  15.  
  16. #ifndef FWFRAME_H
  17. #include "FWFrame.h"
  18. #endif
  19.  
  20. #ifndef FWPART_H
  21. #include "FWPart.h"
  22. #endif
  23.  
  24. // ----- OpenDoc Includes -----
  25.  
  26. #ifndef SOM_ODDraft_xh
  27. #include <Draft.xh>
  28. #endif
  29.  
  30. #ifndef SOM_ODShape_xh
  31. #include <Shape.xh>
  32. #endif
  33.  
  34. #if defined(__MWERKS__) && GENERATING68K
  35. // A hack to work around a bug
  36. #pragma import list somGetGlobalEnvironment
  37. #endif
  38.  
  39. //========================================================================================
  40. //    Runtime Info
  41. //========================================================================================
  42.  
  43. #ifdef FW_BUILD_MAC
  44. #pragma segment fwclninf
  45. #endif
  46.  
  47. FW_DEFINE_AUTO(FW_CCloneInfo)
  48.  
  49. //========================================================================================
  50. //    struct FW_CCloneInfo
  51. //========================================================================================
  52.  
  53. //----------------------------------------------------------------------------------------
  54. //    FW_CCloneInfo::FW_CCloneInfo
  55. //----------------------------------------------------------------------------------------
  56.  
  57. FW_CCloneInfo::FW_CCloneInfo(Environment* ev, ODDraft* fromDraft, FW_CFrame* scopeFrame, ODCloneKind cloneKind):
  58.     fKey(0),
  59.     fFromDraft(fromDraft),
  60.     fScopeFrame(scopeFrame),
  61.     fCloning(FALSE),
  62.     fBeganClone(FALSE),
  63.     fCloneKind(cloneKind),
  64.     fClonedProxyList(NULL),
  65.     fClonedPartID(kODNULLID),
  66.     fClonedFrameID(kODNULLID),
  67.     fFrameShape(NULL)
  68. {
  69. FW_UNUSED(ev);
  70.     FW_END_CONSTRUCTOR
  71. }
  72.  
  73. //----------------------------------------------------------------------------------------
  74. //    FW_CCloneInfo::FW_CCloneInfo
  75. //----------------------------------------------------------------------------------------
  76.  
  77. FW_CCloneInfo::FW_CCloneInfo(Environment* ev, ODDraftKey key, ODDraft* fromDraft, FW_CFrame* scopeFrame, ODCloneKind cloneKind):
  78.     fKey(key),
  79.     fFromDraft(fromDraft),
  80.     fToDraft(NULL),
  81.     fScopeFrame(scopeFrame),
  82.     fCloning(TRUE),
  83.     fBeganClone(FALSE),
  84.     fCloneKind(cloneKind),
  85.     fClonedProxyList(NULL),
  86.     fClonedPartID(kODNULLID),
  87.     fClonedFrameID(kODNULLID),
  88.     fFrameShape(NULL)
  89. {
  90. FW_UNUSED(ev);
  91.     FW_END_CONSTRUCTOR
  92. }
  93.  
  94. //----------------------------------------------------------------------------------------
  95. //    FW_CCloneInfo::~FW_CCloneInfo
  96. //----------------------------------------------------------------------------------------
  97.  
  98. FW_CCloneInfo::~FW_CCloneInfo()
  99. {
  100.     FW_START_DESTRUCTOR
  101.     
  102.     Environment* ev = somGetGlobalEnvironment();
  103.     
  104.     if (fCloning && fBeganClone)
  105.         fFromDraft->AbortClone(ev, fKey);
  106.  
  107.     if (fFrameShape)
  108.         fFrameShape->Release(ev);
  109.         
  110.     if (fClonedProxyList)
  111.     {
  112.         delete fClonedProxyList;    // will call remove all
  113.         fClonedProxyList = NULL;
  114.     }    
  115. }
  116.  
  117. //----------------------------------------------------------------------------------------
  118. //    FW_CCloneInfo::BeginClone
  119. //----------------------------------------------------------------------------------------
  120.  
  121. void FW_CCloneInfo::BeginClone(Environment* ev, ODDraft* destinationDraft)
  122. {
  123.     FW_ASSERT(!fCloning);
  124.     fToDraft = destinationDraft;
  125.     fKey = fFromDraft->BeginClone(ev, destinationDraft, fScopeFrame ? fScopeFrame->GetODFrame(ev) : NULL, fCloneKind);
  126.     fCloning = TRUE;
  127.     fBeganClone = TRUE;
  128. }
  129.  
  130. //----------------------------------------------------------------------------------------
  131. //    FW_CCloneInfo::EndClone
  132. //----------------------------------------------------------------------------------------
  133.  
  134. void FW_CCloneInfo::EndClone(Environment* ev)
  135. {
  136.     FW_ASSERT(fCloning);
  137.     FW_ASSERT(fBeganClone);
  138.     
  139.     fFromDraft->EndClone(ev, fKey);
  140.     fCloning = FALSE;
  141. }
  142.  
  143. //----------------------------------------------------------------------------------------
  144. //    FW_CCloneInfo::AbortClone
  145. //----------------------------------------------------------------------------------------
  146.  
  147. void FW_CCloneInfo::AbortClone(Environment* ev)
  148. {
  149.     FW_ASSERT(fCloning);
  150.     FW_ASSERT(fBeganClone);
  151.  
  152.     fFromDraft->AbortClone(ev, fKey);
  153.     fCloning = FALSE;
  154. }
  155.  
  156. //----------------------------------------------------------------------------------------
  157. //    FW_CCloneInfo::Clone
  158. //----------------------------------------------------------------------------------------
  159.  
  160. ODID FW_CCloneInfo::Clone(Environment* ev, ODID fromObjectID, ODID toObjectID, ODID scope)
  161. {
  162.     FW_ASSERT(fCloning);
  163.  
  164.     return fFromDraft->Clone(ev, fKey, fromObjectID, toObjectID, scope);
  165. }
  166.  
  167. //----------------------------------------------------------------------------------------
  168. //    FW_CCloneInfo::GetDataInterchange
  169. //----------------------------------------------------------------------------------------
  170.  
  171. FW_CDataInterchange* FW_CCloneInfo::GetDataInterchange(Environment* ev) const
  172. {
  173.     return fScopeFrame->GetPart(ev)->GetDataInterchange(ev);
  174. }
  175.  
  176. //----------------------------------------------------------------------------------------
  177. //    FW_CCloneInfo::GetDraftKey
  178. //----------------------------------------------------------------------------------------
  179.  
  180. ODDraftKey FW_CCloneInfo::GetDraftKey(Environment* ev) const
  181. {
  182. FW_UNUSED(ev);
  183.     // fKey is not valid if not between Begin and end clone
  184.     FW_ASSERT(fCloning);    
  185.     
  186.     return fKey;
  187. }
  188.  
  189.