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 / FWInsCmd.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  4.4 KB  |  198 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWInsCmd.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 FWINSCMD_H
  13. #include "FWInsCmd.h"
  14. #endif
  15.  
  16. #ifndef FWPART_H
  17. #include "FWPart.h"
  18. #endif
  19.  
  20. #ifndef FWINTER_H
  21. #include "FWInter.h"
  22. #endif
  23.  
  24. #ifndef FWFRMING_H
  25. #include "FWFrming.h"
  26. #endif
  27.  
  28. #ifndef FWSELECT_H
  29. #include "FWSelect.h"
  30. #endif
  31.  
  32. #ifndef FWLINK_H
  33. #include "FWLink.h"
  34. #endif
  35.  
  36. #ifndef FWLNKMGR_H
  37. #include "FWLnkMgr.h"
  38. #endif
  39.  
  40. #ifndef FWEMBUTL_H
  41. #include "FWEmbUtl.h"
  42. #endif
  43.  
  44. #ifndef FWPRESEN_H
  45. #include "FWPresen.h"
  46. #endif
  47.  
  48. // ----- OS Layer -----
  49.  
  50. #ifndef FWBARRAY_H
  51. #include "FWBArray.h"
  52. #endif
  53.  
  54. #ifndef SLODFSTR_K
  55. #include "SLODFStr.k"
  56. #endif
  57.  
  58. #ifndef SLODFSTR_H
  59. #include "SLODFStr.h"
  60. #endif
  61.  
  62. // ----- OpenDoc Includes -----
  63.  
  64. #ifndef SOM_Module_OpenDoc_Commands_defined
  65. #include <CmdDefs.xh>
  66. #endif
  67.  
  68. #ifndef SOM_ODSession_xh
  69. #include <ODSessn.xh>
  70. #endif
  71.  
  72. #ifndef SOM_ODClipboard_xh
  73. #include <Clipbd.xh>
  74. #endif
  75.  
  76. #ifndef SOM_Module_OpenDoc_StdProps_defined
  77. #include <StdProps.xh>
  78. #endif
  79.  
  80. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  81. #include <StdTypes.xh>
  82. #endif
  83.  
  84. #ifndef SOM_ODStorageUnit_xh
  85. #include <StorageU.xh>
  86. #endif
  87.  
  88. #ifndef SOM_ODLinkSpec_xh
  89. #include <LinkSpec.xh>
  90. #endif
  91.  
  92. //========================================================================================
  93. //    Runtime Info
  94. //========================================================================================
  95.  
  96. #ifdef FW_BUILD_MAC
  97. #pragma segment odfcommands
  98. #endif
  99.  
  100. FW_DEFINE_AUTO(FW_CInsertCommand)
  101.  
  102. //====================================================================
  103. // FW_CInsertCommand class
  104. //====================================================================
  105.  
  106. //--------------------------------------------------------------------
  107. // FW_CInsertCommand constructor
  108. //--------------------------------------------------------------------
  109.  
  110. FW_CInsertCommand::FW_CInsertCommand(Environment* ev,
  111.                                     FW_CEmbeddingFrame* frame,
  112.                                     const FW_PFileSpecification& fileSpec,
  113.                                     FW_Boolean canUndo) :
  114.     FW_CCommand(ev, kODCommandInsert, frame, canUndo),
  115.     fFileSpec(fileSpec),
  116.     fEmbeddingFrame(frame)
  117. {
  118.     if (GetCanUndo(ev))
  119.     {
  120.         FW_CString undoString;
  121.         FW_CString redoString;
  122.         
  123.         ::FW_PrivLoadUndoStrings(ev, FW_kUndoInsertMsg, undoString, redoString);
  124.         SetMenuStrings(ev, undoString, redoString);
  125.     }
  126. }
  127.  
  128. //--------------------------------------------------------------------
  129. // FW_CInsertCommand destructor
  130. //--------------------------------------------------------------------
  131.  
  132. FW_CInsertCommand::~FW_CInsertCommand()
  133. {
  134. }
  135.  
  136. //--------------------------------------------------------------------
  137. // FW_CInsertCommand::DoIt
  138. //--------------------------------------------------------------------
  139.  
  140. void FW_CInsertCommand::DoIt(Environment* ev)    // Override
  141. {
  142.     FW_Boolean result = FALSE;
  143.  
  144.     if (GetCanUndo(ev))
  145.         this->SaveUndoState(ev);    // save current state, for later Undo
  146.  
  147.     if (this->IsOKtoEdit(ev) && this->Insert(ev))
  148.     {
  149.         result = TRUE;
  150.         GetPresentation(ev)->ContentUpdated(ev);
  151.     }
  152.  
  153.  
  154.     if (result == FALSE)
  155.     {
  156.         SetCanUndo(ev, FALSE);
  157.     }
  158.     else if (GetCanUndo(ev))
  159.     {
  160.         this->SaveRedoState(ev);        // save new state, for later Redo
  161.     }
  162. }
  163.     
  164. //----------------------------------------------------------------------------------------
  165. //    FW_CInsertCommand::Insert
  166. //----------------------------------------------------------------------------------------
  167.  
  168. FW_Boolean FW_CInsertCommand::Insert(Environment* ev)
  169. {
  170.     PreCommand(ev);
  171.     
  172.     FW_Boolean result = FW_InsertPartFromFile(ev, fEmbeddingFrame, fFileSpec) != FW_kInternalizeFailed;
  173.     
  174.     if (result)
  175.         CommandDone(ev);
  176.         
  177.     return result;
  178. }
  179.  
  180. //----------------------------------------------------------------------------------------
  181. //    FW_CInsertCommand::PreCommand
  182. //----------------------------------------------------------------------------------------
  183.  
  184. void FW_CInsertCommand::PreCommand(Environment* ev)
  185. {
  186. FW_UNUSED(ev);
  187. }
  188.  
  189. //----------------------------------------------------------------------------------------
  190. //    FW_CInsertCommand::CommandDone
  191. //----------------------------------------------------------------------------------------
  192.  
  193. void FW_CInsertCommand::CommandDone(Environment* ev)
  194. {
  195. FW_UNUSED(ev);
  196.     // User may override; only gets called if the Insert was successful
  197. }
  198.