home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / FWClnInf.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  5.2 KB  |  188 lines  |  [TEXT/MPS ]

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