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.

331 lines
10 KiB

  1. /*************************************************************************
  2. **
  3. ** OLE 2.0 Property Set Utilities
  4. **
  5. ** suminfo.h
  6. **
  7. ** This file contains file contains data structure defintions,
  8. ** function prototypes, constants, etc. for OLE 2.0 Property Set
  9. ** utilities used to manage the Summary Info property set.
  10. **
  11. ** (c) Copyright Microsoft Corp. 1990 - 1992 All Rights Reserved
  12. **
  13. *************************************************************************/
  14. #ifndef SUMINFO_H
  15. #define SUMINFO_H
  16. #include <ole2.h>
  17. /* A SUMINFO variable is an instance of an abstract data type. Thus,
  18. ** there can be an arbitrary number of SummaryInfo streams open
  19. ** simultaneously (subject to available memory). Each variable must
  20. ** be initialized prior to use by calling Init and freed after its
  21. ** last use by calling Free. The param argument to Init is reserved
  22. ** for future expansion and should be zero initially. Once a SUMINFO
  23. ** variable is allocated (by Init), the user can call the Set
  24. ** procedures to initialize fields. A copy of the arguments is made
  25. ** in every case except SetThumbnail where control of the storage
  26. ** occupied by the METAFILEPICT is merely transferred. When the
  27. ** Free routine is called, all storage will be deallocated including
  28. ** that of the thumbnail. The arguments to SetThumbNail and the
  29. ** return values from GetThumbNail correspond to the OLE2.0 spec.
  30. ** Note that on input, the thumbnail is read on demand but all the
  31. ** other properties are pre-loaded. The thumbnail is manipulated as
  32. ** a windows handle to a METAFILEPICT structure, which in turn
  33. ** contains a handle to the METAFILE. The transferClip argument on
  34. ** GetThumbNail, when set to true, transfers responsibility for
  35. ** storage management of the thumbnail to the caller; that is, after
  36. ** Free has been called, the handle is still valid. Clear can be
  37. ** used to free storage for all the properties but then you must
  38. ** call Read to load them again. All the code is based on FAR
  39. ** pointers.
  40. ** CoInitialize MUST be called PRIOR to calling OleStdInitSummaryInfo.
  41. ** Memory is allocated using the currently active IMalloc*
  42. ** allocator (as is returned by call CoGetMalloc(MEMCTX_TASK) ).
  43. **
  44. ** Common scenarios:
  45. ** Read SummaryInfo
  46. ** ----------------
  47. ** OleStdInitSummaryInfo()
  48. ** OleStdReadSummaryInfo()
  49. ** . . . . .
  50. ** call different Get routines
  51. ** . . . . .
  52. ** OleStdFreeSummaryInfo()
  53. **
  54. ** Create SummaryInfo
  55. ** ------------------
  56. ** OleStdInitSummaryInfo()
  57. ** call different Set routines
  58. ** OleStdWriteSummaryInfo()
  59. ** OleStdFreeSummaryInfo()
  60. **
  61. ** Update SummaryInfo
  62. ** ------------------
  63. ** OleStdInitSummaryInfo()
  64. ** OleStdReadSummaryInfo()
  65. ** OleStdGetThumbNailProperty(necessary only if no SetThumb)
  66. ** call different Set routines
  67. ** OleStdWriteSummaryInfo()
  68. ** OleStdFreeSummaryInfo()
  69. */
  70. #define WORDMAX 256 //current string max for APPS; 255 + null terminator
  71. typedef union {
  72. short iVal; /* VT_I2 */
  73. long lVal; /* VT_I4 */
  74. float fltVal; /* VT_R4 */
  75. double dblVal; /* VT_R8 */
  76. DWORD bool; /* VT_BOOL */
  77. SCODE scodeVal; /* VT_ERROR */
  78. DWORD systimeVal; /* VT_SYSTIME */
  79. #ifdef UNICODE
  80. TCHAR bstrVal[WORDMAX]; /* VT_BSTR */
  81. #else
  82. unsigned char bstrVal[WORDMAX]; /* VT_BSTR */
  83. #endif
  84. } VTUNION;
  85. #if 0
  86. typedef struct _FMTID
  87. {
  88. DWORD dword;
  89. WORD words[2];
  90. BYTE bytes[8];
  91. } FMTID;
  92. #endif
  93. typedef struct _PROPSETLIST
  94. {
  95. FMTID formatID;
  96. DWORD byteOffset;
  97. } PROPSETLIST;
  98. typedef struct _PROPIDLIST
  99. {
  100. DWORD propertyID;
  101. DWORD byteOffset;
  102. } PROPIDLIST;
  103. typedef struct _PROPVALUE
  104. {
  105. DWORD vtType;
  106. VTUNION vtValue;
  107. } PROPVALUE;
  108. typedef struct _SECTION
  109. {
  110. DWORD cBytes;
  111. DWORD cProperties;
  112. PROPIDLIST rgPropId[1/*cProperties*/]; //variable-length array
  113. PROPVALUE rgPropValue[1]; //CANNOT BE ACCESSED BY NAME; ONLY BY POINTER
  114. } SECTION;
  115. typedef struct _SUMMARYINFO
  116. {
  117. WORD byteOrder;
  118. WORD formatVersion;
  119. WORD getOSVersion;
  120. WORD osVersion;
  121. CLSID classId; //from compobj.h
  122. DWORD cSections;
  123. PROPSETLIST rgPropSet[1/*cSections*/]; //variable-length array
  124. SECTION rgSections[1/*cSections*/]; //CANNOT BE ACCESSED BY NAME; ONLY BY POINTER
  125. } SUMMARYINFO;
  126. #define osWinOnDos 0
  127. #define osMac 1
  128. #define osWinNT 2
  129. #define PID_DICTIONARY 0X00000000
  130. #define PID_CODEPAGE 0X00000001
  131. #define PID_TITLE 0X00000002
  132. #define PID_SUBJECT 0X00000003
  133. #define PID_AUTHOR 0X00000004
  134. #define PID_KEYWORDS 0X00000005
  135. #define PID_COMMENTS 0X00000006
  136. #define PID_TEMPLATE 0X00000007
  137. #define PID_LASTAUTHOR 0X00000008
  138. #define PID_REVNUMBER 0X00000009
  139. #define PID_EDITTIME 0X0000000A
  140. #define PID_LASTPRINTED 0X0000000B
  141. #define PID_CREATE_DTM_RO 0X0000000C
  142. #define PID_LASTSAVE_DTM 0X0000000D
  143. #define PID_PAGECOUNT 0X0000000E
  144. #define PID_WORDCOUNT 0X0000000F
  145. #define PID_CHARCOUNT 0X00000010
  146. #define PID_THUMBNAIL 0X00000011
  147. #define PID_APPNAME 0X00000012
  148. #define PID_SECURITY 0X00000013
  149. #define cPID_STANDARD (PID_SECURITY+1-2)
  150. #define MAXWORD 256 //maximum string size for APPS at present
  151. typedef struct _STDZ
  152. {
  153. DWORD vtType;
  154. union {
  155. DWORD vtByteCount;
  156. #ifdef UNICODE
  157. TCHAR fill[4]; //use last byte as byte count for stz requests
  158. #else
  159. unsigned char fill[4]; //use last byte as byte count for stz requests
  160. #endif
  161. };
  162. #ifdef UNICODE
  163. TCHAR rgchars[MAXWORD];
  164. #else
  165. unsigned char rgchars[MAXWORD];
  166. #endif
  167. } STDZ;
  168. #define VTCB fill[3] //used to set/get the count byte when in memory
  169. typedef struct _THUMB
  170. {
  171. DWORD vtType;
  172. DWORD cBytes; //clip size in memory
  173. DWORD selector; //on disk -1,win clip no. -2,mac clip no. -3,ole FMTID 0,bytes nameLength, format name
  174. DWORD clipFormat;
  175. char FAR *lpstzName;
  176. char FAR *lpByte;
  177. } THUMB;
  178. #define VT_CF_BYTES 0
  179. #define VT_CF_WIN ((DWORD)(-1))
  180. #define VT_CF_MAC ((DWORD)(-2))
  181. #define VT_CF_FMTID ((DWORD)(-3))
  182. #define VT_CF_NAME ((DWORD)(-4))
  183. #define VT_CF_EMPTY ((DWORD)(-5))
  184. #define VT_CF_OOM ((DWORD)(-6)) // Out of memory
  185. typedef THUMB FAR *LPTHUMB;
  186. typedef STDZ FAR *LPSTDZ;
  187. typedef struct _TIME
  188. {
  189. DWORD vtType;
  190. FILETIME time;
  191. } TIME;
  192. typedef struct _INTS
  193. {
  194. DWORD vtType;
  195. DWORD value;
  196. } INTS;
  197. #define MAXTIME (PID_LASTSAVE_DTM-PID_EDITTIME+1)
  198. #define MAXINTS (PID_CHARCOUNT-PID_PAGECOUNT+1+1)
  199. #define MAXSTDZ (PID_REVNUMBER-PID_TITLE+1+1)
  200. typedef struct _STANDARDSECINMEM
  201. {
  202. DWORD cBytes;
  203. DWORD cProperties;
  204. PROPIDLIST rgPropId[cPID_STANDARD/*cProperties*/]; //variable-length array
  205. TIME rgTime[MAXTIME];
  206. INTS rgInts[MAXINTS];
  207. LPSTDZ rglpsz[MAXSTDZ];
  208. THUMB thumb;
  209. } STANDARDSECINMEM;
  210. #define OFFSET_NIL 0X00000000
  211. #define AllSecurityFlagsEqNone 0
  212. #define fSecurityPassworded 1
  213. #define fSecurityRORecommended 2
  214. #define fSecurityRO 4
  215. #define fSecurityLockedForAnnotations 8
  216. #define PropStreamNamePrefixByte '\005'
  217. #define PropStreamName "\005SummaryInformation"
  218. #define cbNewSummaryInfo(nSection) (sizeof(SUMMARYINFO)-sizeof(SECTION)+sizeof(PROPSETLIST)*((nSection)-1))
  219. #define cbNewSection(nPropIds) (sizeof(SECTION)-sizeof(PROPVALUE)+sizeof(PROPIDLIST)*((nPropIds)-1))
  220. #define FIntelOrder(prop) ((prop)->byteOrder==0xfffe)
  221. #define SetOs(prop, os) {(prop)->osVersion=os; (prop)->getOSVersion=LOWORD(GetVersion());}
  222. #define SetSumInfFMTID(fmtId) {(fmtId)->Data1=0XF29F85E0; *(long FAR *)&(fmtId)->Data2=0X10684FF9;\
  223. *(long FAR *)&(fmtId)->Data4[0]=0X000891AB; *(long FAR *)&(fmtId)->Data4[4]=0XD9B3272B;}
  224. #define FEqSumInfFMTID(fmtId) ((fmtId)->Data1==0XF29F85E0&&*((long FAR *)&(fmtId)->Data2)==0X10684FF9&&\
  225. *((long FAR *)&(fmtId)->Data4[0])==0X000891AB&&*((long FAR *)&(fmtId)->Data4[4])==0XD9B3272B)
  226. #define FSzEqPropStreamName(sz) _fstricmp(sz, PropStreamName)
  227. #define ClearSumInf(lpsuminf, cb) {_fmemset(lpsuminf,0,cb); (lpsuminf)->byteOrder=0xfffe;\
  228. SetOs(lpsuminf, osWinOnDos);}
  229. typedef void FAR *LPSUMINFO;
  230. typedef LPTSTR LPSTZR;
  231. typedef void FAR *THUMBNAIL; //for VT_CF_WIN this is an unlocked global handle
  232. #define API __far __pascal
  233. /*************************************************************************
  234. ** Public Summary Info Property Set Management API
  235. *************************************************************************/
  236. extern "C" {
  237. STDAPI_(LPSUMINFO) OleStdInitSummaryInfo(int reserved);
  238. STDAPI_(void) OleStdFreeSummaryInfo(LPSUMINFO FAR *lplp);
  239. STDAPI_(void) OleStdClearSummaryInfo(LPSUMINFO lp);
  240. STDAPI_(int) OleStdReadSummaryInfo(LPSTREAM lpStream, LPSUMINFO lp);
  241. STDAPI_(int) OleStdWriteSummaryInfo(LPSTREAM lpStream, LPSUMINFO lp);
  242. STDAPI_(DWORD) OleStdGetSecurityProperty(LPSUMINFO lp);
  243. STDAPI_(int) OleStdSetSecurityProperty(LPSUMINFO lp, DWORD security);
  244. STDAPI_(LPTSTR) OleStdGetStringProperty(LPSUMINFO lp, DWORD pid);
  245. STDAPI_(int) OleStdSetStringProperty(LPSUMINFO lp, DWORD pid, LPTSTR lpsz);
  246. STDAPI_(LPSTZR) OleStdGetStringZProperty(LPSUMINFO lp, DWORD pid);
  247. STDAPI_(void) OleStdGetDocProperty(
  248. LPSUMINFO lp,
  249. DWORD FAR* nPage,
  250. DWORD FAR* nWords,
  251. DWORD FAR* nChars
  252. );
  253. STDAPI_(int) OleStdSetDocProperty(
  254. LPSUMINFO lp,
  255. DWORD nPage,
  256. DWORD nWords,
  257. DWORD nChars
  258. );
  259. STDAPI_(int) OleStdGetThumbNailProperty(
  260. LPSTREAM lps,
  261. LPSUMINFO lp,
  262. DWORD FAR* clipFormatNo,
  263. LPTSTR FAR* lpszName,
  264. THUMBNAIL FAR* clip,
  265. DWORD FAR* byteCount,
  266. BOOL transferClip
  267. );
  268. STDAPI_(int) OleStdSetThumbNailProperty(
  269. LPSTREAM lps,
  270. LPSUMINFO lp,
  271. int vtcfNo,
  272. DWORD clipFormatNo,
  273. LPTSTR lpszName,
  274. THUMBNAIL clip,
  275. DWORD byteCount
  276. );
  277. STDAPI_(void) OleStdGetDateProperty(
  278. LPSUMINFO lp,
  279. DWORD pid,
  280. int FAR* yr,
  281. int FAR* mo,
  282. int FAR* dy,
  283. DWORD FAR* sc
  284. );
  285. STDAPI_(int) OleStdSetDateProperty(
  286. LPSUMINFO lp,
  287. DWORD pid,
  288. int yr,
  289. int mo,
  290. int dy,
  291. int hr,
  292. int mn,
  293. int sc
  294. );
  295. } //END C
  296. #endif // SUMINFO_H