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.

143 lines
4.0 KiB

  1. //+--------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: pdffuncs.cxx
  7. //
  8. // Contents: PDocFile static member functions
  9. //
  10. // History: 22-Jun-92 DrewB Created
  11. //
  12. //---------------------------------------------------------------
  13. #include <dfhead.cxx>
  14. #pragma hdrstop
  15. #include <tstream.hxx>
  16. //+---------------------------------------------------------------------------
  17. //
  18. // Member: PDocFile::CreateFromUpdate, public
  19. //
  20. // Synopsis: Creates an object from an update list entry
  21. //
  22. // Arguments: [pud] - Update entry
  23. // [pdf] - Docfile
  24. // [df] - Permissions
  25. //
  26. // Returns: Appropriate status code
  27. //
  28. // History: 02-Nov-92 DrewB Created
  29. //
  30. //----------------------------------------------------------------------------
  31. SCODE PDocFile::CreateFromUpdate(CUpdate *pud,
  32. PDocFile *pdf,
  33. DFLAGS df)
  34. {
  35. PDocFile *pdfChild;
  36. PSStream *pstChild;
  37. SCODE sc;
  38. olDebugOut((DEB_ITRACE, "In PDocFile::CreateFromUpdate(%p, %p, %X)\n",
  39. pud, pdf, df));
  40. olAssert(pud->GetXSM() != NULL);
  41. switch(pud->GetFlags() & (ULF_TYPEFLAGS & STGTY_REAL))
  42. {
  43. case STGTY_STORAGE:
  44. olChk(pdf->CreateDocFile(pud->GetCurrentName(), df, pud->GetLUID(),
  45. pud->GetFlags() & ULF_TYPEFLAGS, &pdfChild));
  46. olChkTo(EH_Create,
  47. ((CWrappedDocFile *)pud->GetXSM())->SetBase(pdfChild));
  48. break;
  49. case STGTY_STREAM:
  50. olChk(pdf->CreateStream(pud->GetCurrentName(), df, pud->GetLUID(),
  51. pud->GetFlags() & ULF_TYPEFLAGS, &pstChild));
  52. olChkTo(EH_Create,
  53. ((CTransactedStream *)pud->GetXSM())->SetBase(pstChild));
  54. break;
  55. default:
  56. olAssert(FALSE && aMsg("Unknown type in update list entry"));
  57. break;
  58. }
  59. olDebugOut((DEB_ITRACE, "Out PDocFile::CreateFromUpdate\n"));
  60. return S_OK;
  61. EH_Create:
  62. if ((pud->GetFlags() & (ULF_TYPEFLAGS & STGTY_REAL)) == STGTY_STORAGE)
  63. pdfChild->Release();
  64. else
  65. {
  66. olAssert((pud->GetFlags() & (ULF_TYPEFLAGS & STGTY_REAL)) ==
  67. STGTY_STREAM);
  68. pstChild->Release();
  69. }
  70. olVerSucc(pdf->DestroyEntry(pud->GetCurrentName(), TRUE));
  71. EH_Err:
  72. return sc;
  73. }
  74. //+--------------------------------------------------------------
  75. //
  76. // Member: PDocFile::ExcludeEntries, public
  77. //
  78. // Synopsis: Excludes the given entries
  79. //
  80. // Arguments: [snbExclude] - Entries to exclude
  81. //
  82. // Returns: Appropriate status code
  83. //
  84. // History: 26-Mar-92 DrewB Created
  85. //
  86. //---------------------------------------------------------------
  87. SCODE PDocFile::ExcludeEntries(PDocFile *pdf,
  88. SNBW snbExclude)
  89. {
  90. PSStream *psstChild;
  91. PDocFile *pdfChild;
  92. SCODE sc;
  93. CDfName dfnKey;
  94. SIterBuffer ib;
  95. olDebugOut((DEB_ITRACE, "In PDocFile::ExcludeEntries(%p)\n",
  96. snbExclude));
  97. for (;;)
  98. {
  99. if (FAILED(pdf->FindGreaterEntry(&dfnKey, &ib, NULL)))
  100. break;
  101. dfnKey.Set(&ib.dfnName);
  102. if (NameInSNB(&ib.dfnName, snbExclude) == S_OK)
  103. {
  104. switch(REAL_STGTY(ib.type))
  105. {
  106. case STGTY_STORAGE:
  107. olChkTo(EH_pwcsName, pdf->GetDocFile(&ib.dfnName, DF_READ |
  108. DF_WRITE, ib.type,
  109. &pdfChild));
  110. olChkTo(EH_Get, pdfChild->DeleteContents());
  111. pdfChild->Release();
  112. break;
  113. case STGTY_STREAM:
  114. olChkTo(EH_pwcsName, pdf->GetStream(&ib.dfnName, DF_WRITE,
  115. ib.type, &psstChild));
  116. olChkTo(EH_Get, psstChild->SetSize(0));
  117. psstChild->Release();
  118. break;
  119. }
  120. }
  121. }
  122. olDebugOut((DEB_ITRACE, "Out ExcludeEntries\n"));
  123. return S_OK;
  124. EH_Get:
  125. if (REAL_STGTY(ib.type) == STGTY_STORAGE)
  126. pdfChild->Release();
  127. else if (REAL_STGTY(ib.type) == STGTY_STREAM)
  128. psstChild->Release();
  129. EH_pwcsName:
  130. return sc;
  131. }