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.

267 lines
6.7 KiB

  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // DocSum.c
  4. //
  5. // Notes:
  6. // To make this file useful for OLE objects, define OLE_PROPS.
  7. //
  8. // The macro lpDocObj must be used for all methods to access the
  9. // object data to ensure that this will compile with OLE_PROPS defined.
  10. //
  11. // Change history:
  12. //
  13. // Date Who What
  14. // --------------------------------------------------------------------------
  15. // 06/01/94 B. Wentz Created file
  16. // 06/25/94 B. Wentz Converted to lean & mean API's
  17. // 07/26/94 B. Wentz Added code to merge DocumentSummary and UserDefined streams.
  18. // 08/03/94 B. Wentz Added Manager & Company Properties
  19. //
  20. ////////////////////////////////////////////////////////////////////////////////
  21. #include "priv.h"
  22. #pragma hdrstop
  23. #ifndef WINNT
  24. #include <windows.h>
  25. #include "offglue.h"
  26. #include <objbase.h>
  27. #include <objerror.h>
  28. #include "proptype.h"
  29. #include "internal.h"
  30. #include "propmisc.h"
  31. #include "debug.h"
  32. #endif
  33. #ifndef _ABBREVIATED_DOCPROP_
  34. // Internal prototypes
  35. static void PASCAL FreeData (LPDSIOBJ lpDSIObj);
  36. static BOOL FFreeHeadPart(LPPLXHEADPART lpplxheadpart, SHORT iPlex);
  37. static SHORT ILookupHeading(LPPLXHEADPART lpplxheadpart, LPTSTR lpsz);
  38. // Do nothing for non-OLE code....
  39. #define lpDocObj lpDSIObj
  40. #define lpData ((LPDSINFO) lpDSIObj->m_lpData)
  41. ////////////////////////////////////////////////////////////////////////////////
  42. //
  43. // OfficeDirtyDSIObj
  44. //
  45. // Purpose:
  46. // Sets object state to dirty or clean.
  47. //
  48. ////////////////////////////////////////////////////////////////////////////////
  49. VOID OfficeDirtyDSIObj
  50. (LPDSIOBJ lpDSIObj, // The object
  51. BOOL fDirty) // Flag indicating if the object is dirty.
  52. {
  53. Assert(lpDSIObj != NULL);
  54. lpDocObj->m_fObjChanged = fDirty;
  55. } // OfficeDirtyDSIObj
  56. ////////////////////////////////////////////////////////////////////////////////
  57. //
  58. // FDocSumCreate
  59. //
  60. // Purpose:
  61. // Create the object and return it.
  62. //
  63. ////////////////////////////////////////////////////////////////////////////////
  64. BOOL
  65. FDocSumCreate
  66. (LPDSIOBJ FAR *lplpDSIObj, // Pointer to pointer to object
  67. void *prglpfn[]) // Pointer to function array
  68. {
  69. LPDSIOBJ lpDSIObj; // Hack - a temp, must call it "lpDSIObj" for macros to work!
  70. if (lplpDSIObj == NULL)
  71. return(TRUE);
  72. // Make sure we get valid args before we start alloc'ing
  73. if ((prglpfn == NULL) || (prglpfn[ifnCPConvert] == NULL))
  74. return FALSE;
  75. if ((*lplpDSIObj = (LPDSIOBJ) PvMemAlloc(sizeof (DOCSUMINFO))) == NULL)
  76. {
  77. // REVIEW: Add alert
  78. return FALSE;
  79. }
  80. lpDSIObj = *lplpDSIObj; // Save us some indirecting & let us use the "LP" macros
  81. // If alloc fails, free the original object too.
  82. if ((lpData =
  83. PvMemAlloc(sizeof (DSINFO))) == NULL)
  84. {
  85. // REVIEW: Add alert
  86. VFreeMemP(*lplpDSIObj, sizeof(DOCSUMINFO));
  87. return FALSE;
  88. }
  89. FillBuf ((void *) lpData, (int) 0, (sizeof (DSINFO) - ifnDSIMax*(sizeof (void *))));
  90. // Save the fnc's for Code Page conversions
  91. lpData->lpfnFCPConvert = (BOOL (*)(LPTSTR, DWORD, DWORD, BOOL)) prglpfn[ifnCPConvert];
  92. OfficeDirtyDSIObj (*lplpDSIObj, FALSE);
  93. (*lplpDSIObj)->m_hPage = NULL;
  94. return TRUE;
  95. } // FDocSumCreate
  96. ////////////////////////////////////////////////////////////////////////////////
  97. //
  98. // FDocSumDestroy
  99. //
  100. // Purpose:
  101. // Destroy the given object.
  102. //
  103. ////////////////////////////////////////////////////////////////////////////////
  104. BOOL
  105. FDocSumDestroy
  106. (LPDSIOBJ FAR *lplpDSIObj) // Pointer to pointer to object
  107. {
  108. if ((lplpDSIObj == NULL) ||
  109. (*lplpDSIObj == NULL))
  110. return TRUE;
  111. if (((LPDSIOBJ) *lplpDSIObj)->m_lpData != NULL)
  112. {
  113. // Free data in the DSINFO structure.
  114. FreeData (*lplpDSIObj);
  115. // Invalidate any OLE Automation DocumentProperty objects we might have
  116. InvalidateVBAObjects(NULL, *lplpDSIObj, NULL);
  117. // Free the DSINFO buffer itself.
  118. VFreeMemP((*lplpDSIObj)->m_lpData, sizeof(DSINFO));
  119. }
  120. // Free the DOCSUMINFO structure.
  121. VFreeMemP(*lplpDSIObj, sizeof(DOCSUMINFO));
  122. *lplpDSIObj = NULL;
  123. return TRUE;
  124. } // FDocSumDestroy
  125. ////////////////////////////////////////////////////////////////////////////////
  126. //
  127. // FreeData
  128. //
  129. // Purpose:
  130. // Deallocates all the member data for the object
  131. //
  132. // Note:
  133. // Assumes object is valid.
  134. //
  135. ////////////////////////////////////////////////////////////////////////////////
  136. static void PASCAL
  137. FreeData
  138. (LPDSIOBJ lpDSIObj) // Pointer to valid object
  139. {
  140. // Free any buffers held by the PropVariants.
  141. FreePropVariantArray (NUM_DSI_PROPERTIES, GETDSINFO(lpDSIObj)->rgpropvar);
  142. } // FreeData
  143. ////////////////////////////////////////////////////////////////////////////////
  144. //
  145. // FDocSumClear
  146. //
  147. // Purpose:
  148. // Clear the data stored in the object, but do not destroy the object
  149. //
  150. ////////////////////////////////////////////////////////////////////////////////
  151. BOOL
  152. FDocSumClear
  153. (LPDSIOBJ lpDSIObj) // Pointer to object
  154. {
  155. if ((lpDocObj == NULL) ||
  156. (lpData == NULL))
  157. return TRUE;
  158. FreeData (lpDocObj);
  159. // Invalidate any OLE Automation DocumentProperty objects we might have
  160. InvalidateVBAObjects(NULL, lpDSIObj, NULL);
  161. // Clear the data, don't blt over the fn's stored at the end.
  162. FillBuf ((void *) lpData, (int) 0, (sizeof (DSINFO) - ifnDSIMax*(sizeof (void *))));
  163. OfficeDirtyDSIObj (lpDSIObj, TRUE);
  164. return TRUE;
  165. } // FDocSumClear
  166. ////////////////////////////////////////////////////////////////////////////////
  167. //
  168. // FDocSumShouldSave
  169. //
  170. // Purpose:
  171. // Indicates if the data has changed, meaning a write is needed.
  172. //
  173. ////////////////////////////////////////////////////////////////////////////////
  174. BOOL
  175. FDocSumShouldSave
  176. (LPDSIOBJ lpDSIObj) // Pointer to object
  177. {
  178. if ((lpDocObj == NULL) ||
  179. (lpData == NULL))
  180. return FALSE;
  181. return lpDocObj->m_fObjChanged;
  182. } // FDocSumShouldSave
  183. ////////////////////////////////////////////////////////////////////////////////
  184. //
  185. // FLinkValsChanged
  186. //
  187. // Purpose:
  188. // Determine if the link values changed
  189. //
  190. ////////////////////////////////////////////////////////////////////////////////
  191. BOOL
  192. FLinkValsChanged
  193. (LPDSIOBJ lpDSIObj) // Pointer to object
  194. {
  195. BOOL f = FALSE;
  196. if ((lpDocObj == NULL) ||
  197. (lpData == NULL))
  198. return FALSE;
  199. // If the PID_LINKSDIRTY property is extant, valid, & true,
  200. // then return TRUE and clear the property.
  201. if (GETDSINFO(lpDSIObj)->rgpropvar[ PID_LINKSDIRTY ].vt == VT_BOOL
  202. &&
  203. GETDSINFO(lpDSIObj)->rgpropvar[ PID_LINKSDIRTY ].boolVal)
  204. {
  205. f = TRUE;
  206. GETDSINFO(lpDSIObj)->rgpropvar[ PID_LINKSDIRTY ].boolVal = VARIANT_FALSE;
  207. }
  208. return(f);
  209. } // FLinkValsChanged
  210. #endif //_ABBREVIATED_DOCPROP_