home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osr1.exe / src / DraftRec.cpp < prev    next >
C/C++ Source or Header  |  1997-03-21  |  4KB  |  145 lines

  1. /* @(#)Z 1.15 com/src/docshell/DraftRec.cpp, odshell, od96os2, odos29712d 97/03/21 17:38:33 (96/12/03 15:32:55) */
  2. //====START_GENERATED_PROLOG======================================
  3. //
  4. //
  5. //   COMPONENT_NAME: odshell
  6. //
  7. //   CLASSES: none
  8. //
  9. //   ORIGINS: 27
  10. //
  11. //
  12. //   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  13. //   All Rights Reserved
  14. //   Licensed Materials - Property of IBM
  15. //   US Government Users Restricted Rights - Use, duplication or
  16. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  17. //       
  18. //   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  19. //   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20. //   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  21. //   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  22. //   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  23. //   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  24. //   OR PERFORMANCE OF THIS SOFTWARE.
  25. //
  26. //====END_GENERATED_PROLOG========================================
  27. //
  28.  
  29. //------------------------------------------------------------------------------
  30. // DraftRec.cpp
  31. //
  32. //    This file provides the implementation of the DraftInfoRec class.
  33. //    An instance of this class is created for each draft listed in
  34. //    the draft history window.
  35. //------------------------------------------------------------------------------
  36. #include "DraftRec.h"
  37. #include "DocShell.h"
  38. #include <ODUtils.h>
  39. #include <IText.h>
  40. #include <StorUtil.h>
  41. #include <StdTypIO.h>
  42. #include <TempObj.h>
  43. #include <StdProps.xh>
  44. #include <StdTypes.xh>
  45. #include <StorageU.xh>
  46. #include <Document.xh>
  47.  
  48. #undef LOGGING
  49. #define LOGGING 1
  50.  
  51. //------------------------------------------------------------------------------
  52. // DraftInfoRec
  53. //------------------------------------------------------------------------------
  54. DraftInfoRec::DraftInfoRec()
  55. {
  56.     fPrev            = kODNULL;
  57.     fNext            = kODNULL;
  58.     fDraft            = kODNULL;
  59.     fDraftID        = kODNULL;
  60.     fDraftNumber        = 0;
  61.     fSavedDate        = kODNULL;
  62.     fComment        = kODNULL;
  63.     fModUser        = kODNULL;
  64. }
  65.  
  66.  
  67. //------------------------------------------------------------------------------
  68. // ~DraftInfoRec
  69. //
  70. //    Delete DraftInfoRec which includes deleting memory allocated for
  71. //      user and comment information and releasing the draft acquired.
  72. //------------------------------------------------------------------------------
  73. DraftInfoRec::~DraftInfoRec()
  74. {
  75.     Environment* ev = somGetGlobalEnvironment();
  76.  
  77.     DisposeIText(fModUser);
  78.     DisposeIText(fComment);
  79.  
  80.         try
  81.         {
  82.        // Release draft
  83.        // Note: it is acquired in InitDraftInfoRec
  84.        ODReleaseObject(ev, fDraft);
  85.         }
  86.         catch (ODException _exception)
  87.         {
  88.            LOG("Exception occured in DraftInfoRec::~DraftInfoRec\n");
  89.            throw;
  90.         }
  91.  
  92. }
  93.  
  94.  
  95. //------------------------------------------------------------------------------
  96. // InitDraftInfoRec
  97. //
  98. //    Retrieve information belonging to this draft from its draft
  99. //    properties
  100. //------------------------------------------------------------------------------
  101. void DraftInfoRec::InitDraftInfoRec(Environment *ev, ODDraft *draft)
  102. {
  103.  
  104.     try
  105.     {
  106.     TempODStorageUnit su = draft->AcquireDraftProperties(ev);
  107.  
  108.     // Acquire reference to draft.
  109.     // Note: reference to be released by the destructor
  110.         fDraft = draft->GetDocument(ev)->AcquireDraft(ev, kODDPReadOnly,
  111.                         kODNULL, draft, kODPosSame,
  112.                         kODFalse);
  113.  
  114.     // Retrieve draft ID
  115.     fDraftID = draft->GetID(ev);
  116.  
  117.     // Retrieve user
  118.         fModUser = ODGetITextProp(ev, su, kODPropModUser, 
  119.                 kODPlatformIText , kODNULL);
  120.  
  121.     // Retrieve comment
  122.         fComment = ODGetITextProp(ev, su, kODPropDraftComment,
  123.                 kODPlatformIText, kODNULL);
  124.  
  125.     // Retrieve creation date
  126.     fSavedDate = ODGetTime_TProp(ev, su, kODPropDraftSavedDate, kODTime_T);
  127.  
  128.     // Retrieve draft number
  129.         fDraftNumber = ODGetULongProp(ev, su, kODPropDraftNumber, kODULong);
  130.  
  131.     }
  132.     catch (ODException _exception)
  133.     {
  134.         LOG("Exception occured in DraftInfoRec::InitDraftInfoRec\n");
  135.     if (fModUser)
  136.         DisposeIText(fModUser);
  137.     if (fComment)
  138.         DisposeIText(fComment);
  139.     if (fDraft)
  140.            SaveAndRestoreEv1(fDraft);
  141.         throw;
  142.     }
  143.  
  144. }
  145.