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.

163 lines
5.5 KiB

  1. /*************************************************************************
  2. * @doc SHROOM EXTERNAL API *
  3. * SVDOC.C *
  4. * *
  5. * Copyright (C) Microsoft Corporation 1997 *
  6. * All Rights reserved. *
  7. * *
  8. * *
  9. * Written By : JohnRush *
  10. * Current Owner: JohnRush *
  11. * *
  12. **************************************************************************/
  13. #ifdef _DEBUG
  14. static char s_aszModule[] = __FILE__; /* For error report */
  15. #endif
  16. #include <windows.h>
  17. #include <mvopsys.h>
  18. #include <_mvutil.h>
  19. #include <assertf.h>
  20. #include "svdoc.h"
  21. CSvDocInternal::CSvDocInternal (void)
  22. {
  23. m_lpbfEntry = NULL;
  24. m_lpbfDoc = NULL;
  25. m_dwUID = UID_INVALID;
  26. } /* SVCreateDocTemplate */
  27. CSvDocInternal::~CSvDocInternal ()
  28. {
  29. if (m_lpbfEntry)
  30. DynBufferFree(m_lpbfEntry);
  31. if (m_lpbfDoc)
  32. DynBufferFree(m_lpbfDoc);
  33. } /* SVFreeDocTemplate */
  34. /********************************************************************
  35. * @method HRESULT WINAPI | CSvDoc | ResetDocTemplate |
  36. * Clears the contents of the document template so that the next document's
  37. * properties can be added.
  38. *
  39. * @rvalue S_OK | Currently always returns this value.
  40. *
  41. * @xref <om.AddObjectEntry>
  42. *
  43. * @comm A document template object is meant to be reused for all documents
  44. * being added to the service manager build.
  45. ********************************************************************/
  46. HRESULT WINAPI CSvDocInternal::ResetDocTemplate (void)
  47. {
  48. m_dwUID = UID_INVALID;
  49. if (m_lpbfEntry)
  50. DynBufferReset (m_lpbfEntry);
  51. if (m_lpbfDoc)
  52. DynBufferReset (m_lpbfDoc);
  53. return S_OK;
  54. } /* ResetDocTemplate */
  55. /********************************************************************
  56. * @method HRESULT WINAPI | CSvDoc | AddObjectEntry |
  57. * Sets properties of an object such as a group or word wheel.
  58. *
  59. * @parm LPCWSTR | lpObjName | The text string identifying a group or word wheel object
  60. * @parm IITPropList * | pPL | The property list you want to add to the object
  61. *
  62. * @rvalue S_OK | The given properties were added to the processing queue for the given object.
  63. * @rvalue E_OUTOFMEMORY | Some resources needed by the service manager could not be allocated
  64. *
  65. * @xref <om IITSvMgr.AddDocument>
  66. *
  67. * @comm Once all the properties for all objects have been added, call the
  68. * <p AddDocument> method to complete the processing for the current document
  69. ********************************************************************/
  70. HRESULT WINAPI CSvDocInternal::AddObjectEntry
  71. (LPCWSTR lpObjName, IITPropList *pPL)
  72. {
  73. return AddObjectEntry (lpObjName, L"", pPL);
  74. } /* AddObjectEntry */
  75. /********************************************************************
  76. * @method HRESULT WINAPI | CSvDoc | AddObjectEntry |
  77. * Sets properties of an object such as a group or word wheel.
  78. *
  79. * @parm LPCWSTR | lpObjName | The text string identifying a group or word wheel object
  80. * @parm LPCWSTR | szPropDest | The text string identifying the
  81. * destination of this property list
  82. * @parm IITPropList * | pPL | The property list you want to add to the object
  83. *
  84. * @rvalue S_OK | The given properties were added to the processing queue for the given object.
  85. * @rvalue E_OUTOFMEMORY | Some resources needed by the service manager could not be allocated
  86. *
  87. * @xref <om IITSvMgr.AddDocument>
  88. *
  89. * @comm Once all the properties for all objects have been added, call the
  90. * <p AddDocument> method to complete the processing for the current document.
  91. ********************************************************************/
  92. HRESULT WINAPI CSvDocInternal::AddObjectEntry
  93. (LPCWSTR lpObjName, LPCWSTR szPropDest, IITPropList *pPL)
  94. {
  95. CProperty prop;
  96. LPBF lpbf;
  97. ULARGE_INTEGER ulSize;
  98. // An empty property list is OK but useless
  99. if (!pPL || FAILED (pPL->GetFirst(prop)))
  100. return S_OK;
  101. // Copy the proplist to the batch execution buffer
  102. if (lpObjName)
  103. {
  104. LONG lcb;
  105. if (!m_lpbfEntry &&
  106. NULL == (m_lpbfEntry = DynBufferAlloc (DYN_BUFFER_INIT_SIZE)))
  107. return SetErrReturn(E_OUTOFMEMORY);
  108. // Write object name
  109. lcb = (LONG) (WSTRLEN(lpObjName) + 1) * sizeof(WCHAR);
  110. if (!DynBufferAppend(m_lpbfEntry, (LPBYTE)lpObjName, lcb))
  111. return SetErrReturn(E_OUTOFMEMORY);
  112. // Write property destination
  113. if(!szPropDest)
  114. szPropDest = L"";
  115. lcb = (LONG) (WSTRLEN(szPropDest) + 1) * sizeof(WCHAR);
  116. if (!DynBufferAppend(m_lpbfEntry, (LPBYTE)szPropDest, lcb))
  117. return SetErrReturn(E_OUTOFMEMORY);
  118. lpbf = m_lpbfEntry;
  119. }
  120. else
  121. {
  122. if (!m_lpbfDoc &&
  123. NULL == (m_lpbfDoc= DynBufferAlloc (DYN_BUFFER_INIT_SIZE)))
  124. return SetErrReturn(E_OUTOFMEMORY);
  125. lpbf = m_lpbfDoc;
  126. }
  127. pPL->GetSizeMax (&ulSize);
  128. // Write the record length
  129. if (!DynBufferAppend (lpbf, (LPBYTE)&ulSize.LowPart, sizeof (DWORD)))
  130. return SetErrReturn(E_OUTOFMEMORY);
  131. // Write all the tags
  132. if (!DynBufferEnsureAdd (lpbf, ulSize.LowPart))
  133. return SetErrReturn(E_OUTOFMEMORY);
  134. pPL->SaveToMem (DynBufferPtr (lpbf) + DynBufferLen (lpbf), ulSize.LowPart);
  135. DynBufferSetLength (lpbf, (DynBufferLen (lpbf) + ulSize.LowPart));
  136. return S_OK;
  137. } /* AddObjectEntry */