Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

173 lines
4.9 KiB

  1. //+--------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: wdffuncs.cxx
  7. //
  8. // Contents: CWrappedDocFile support methods
  9. //
  10. // History: 22-Jan-92 DrewB Created
  11. //
  12. //---------------------------------------------------------------
  13. #include <dfhead.cxx>
  14. #pragma hdrstop
  15. //+--------------------------------------------------------------
  16. //
  17. // Member: CWrappedDocFile::DeleteContents, public
  18. //
  19. // Synopsis: Destroys the contents of a docfile
  20. //
  21. // Returns: Appropriate status code
  22. //
  23. // History: 24-Aug-92 DrewB Created
  24. //
  25. //---------------------------------------------------------------
  26. #ifdef CODESEGMENTS
  27. #pragma code_seg(SEG_CWrappedDocFile_DeleteContents) // Wrapdf_TEXT inline?
  28. #endif
  29. SCODE CWrappedDocFile::DeleteContents(void)
  30. {
  31. #ifdef WRAPPED_DELETE_CONTENTS
  32. PDocFileIterator *pdfi;
  33. SCODE sc;
  34. SIterBuffer ib;
  35. olDebugOut((DEB_ITRACE, "In CWrappedDocFile::DeleteContents:%p()\n",
  36. this));
  37. _ulChanged.Empty();
  38. olChk(GetIterator(&pdfi));
  39. for (;;)
  40. {
  41. if (FAILED(pdfi->BufferGetNext(&ib)))
  42. break;
  43. olChkTo(EH_pdfi, DestroyEntry(&ib.dfnName, FALSE));
  44. }
  45. olDebugOut((DEB_ITRACE, "Out CWrappedDocFile::DeleteContents\n"));
  46. // Fall through
  47. EH_pdfi:
  48. pdfi->Release();
  49. EH_Err:
  50. return sc;
  51. #else
  52. olAssert(!aMsg("CWrappedDocFile::DeleteContents called"));
  53. return STG_E_UNIMPLEMENTEDFUNCTION;
  54. #endif
  55. }
  56. //+---------------------------------------------------------------------------
  57. //
  58. // Member: CWrappedDocFile::SetInitialState, private
  59. //
  60. // Synopsis: Sets inital values from a base or defaults
  61. //
  62. // Arguments: [pdfBase] - Base object or NULL
  63. //
  64. // Returns: Appropriate status code
  65. //
  66. // History: 11-Nov-92 DrewB Created
  67. // 05-Sep-95 MikeHill Clear the time bits after CopyTimesFrom(base)
  68. //
  69. //----------------------------------------------------------------------------
  70. #ifdef CODESEGMENTS
  71. #pragma code_seg(SEG_CWrappedDocFile_SetInitialState)
  72. #endif
  73. SCODE CWrappedDocFile::SetInitialState(PDocFile *pdfBase)
  74. {
  75. SCODE sc;
  76. olDebugOut((DEB_ITRACE, "In CWrappedDocFile::SetInitialState:%p(%p)\n",
  77. this, pdfBase));
  78. if (pdfBase == NULL)
  79. {
  80. TIME_T tm;
  81. olChk(DfGetTOD(&tm));
  82. _tten.SetTime(WT_CREATION, tm);
  83. _tten.SetTime(WT_MODIFICATION, tm);
  84. _tten.SetTime(WT_ACCESS, tm);
  85. _clsid = CLSID_NULL;
  86. _grfStateBits = 0;
  87. }
  88. else
  89. {
  90. olChk(CopyTimesFrom(pdfBase));
  91. // There's no need for the time bits to be dirty; they don't need
  92. // to be written to the base because they were just read from the base.
  93. _fDirty &= ~(BOOL)( DIRTY_CREATETIME | DIRTY_MODIFYTIME | DIRTY_ACCESSTIME );
  94. olChk(pdfBase->GetClass(&_clsid));
  95. olChk(pdfBase->GetStateBits(&_grfStateBits));
  96. }
  97. olDebugOut((DEB_ITRACE, "Out CWrappedDocFile::SetInitialState\n"));
  98. // Fall through
  99. EH_Err:
  100. return sc;
  101. }
  102. //+---------------------------------------------------------------------------
  103. //
  104. // Member: CWrappedDocFile::RevertUpdate, private
  105. //
  106. // Synopsis: Reverses an update list entry's effect
  107. //
  108. // Arguments: [pud] - Update entry
  109. //
  110. // Returns: Appropriate status code
  111. //
  112. // History: 25-Jan-93 DrewB Created
  113. //
  114. //----------------------------------------------------------------------------
  115. #ifdef CODESEGMENTS
  116. #pragma code_seg(SEG_CWrappedDocFile_RevertUpdate) // Wrapdf_Revert_TEXT
  117. #endif
  118. void CWrappedDocFile::RevertUpdate(CUpdate *pud)
  119. {
  120. olDebugOut((DEB_ITRACE, "In CWrappedDocFile::RevertUpdate:%p(%p)\n",
  121. this, pud));
  122. if (pud->IsCreate())
  123. {
  124. CDFBasis *pdfb = BP_TO_P(CDFBasis *, _pdfb);
  125. olAssert(pud->GetLUID() != DF_NOLUID);
  126. _ppubdf->DestroyChild(pud->GetLUID());
  127. if ((pud->GetFlags() & (ULF_TYPEFLAGS & STGTY_REAL)) == STGTY_STORAGE)
  128. {
  129. CDocFile::Unreserve(1, pdfb);
  130. CWrappedDocFile::Unreserve(_ppubdf->GetTransactedDepth()-1,
  131. pdfb);
  132. }
  133. else
  134. {
  135. CDirectStream::Unreserve(1, pdfb);
  136. CTransactedStream::Unreserve(_ppubdf->GetTransactedDepth()-1,
  137. pdfb);
  138. }
  139. }
  140. else if (pud->IsRename())
  141. {
  142. // Roll back renames
  143. olAssert(_ppubdf->FindXSMember(pud->GetOriginalName(),
  144. GetName()) == NULL &&
  145. aMsg("Revert rename precondition"));
  146. _ppubdf->RenameChild(pud->GetCurrentName(), GetName(),
  147. pud->GetOriginalName());
  148. olAssert(_ppubdf->FindXSMember(pud->GetCurrentName(),
  149. GetName()) == NULL &&
  150. aMsg("Revert rename postcondition"));
  151. }
  152. olDebugOut((DEB_ITRACE, "Out CWrappedDocFile::RevertUpdate\n"));
  153. }