Leaked source code of windows server 2003
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.

189 lines
4.7 KiB

  1. #ifndef _PROPTEST_HXX_
  2. #define _PROPTEST_HXX_
  3. //+-----------------------------------------------------------------
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  7. //
  8. // File: proptest.cxx
  9. //
  10. // Description: This file provides macros and constants
  11. // for the Property Test DRT.
  12. //
  13. //+=================================================================
  14. #ifdef _MSC_VER
  15. #define S_IFDIR _S_IFDIR
  16. #include <direct.h>
  17. inline int _mkdir(char *name, int mode)
  18. {
  19. return ( _mkdir(name) ); // no 'mode' parameter in win32
  20. }
  21. #else // #ifdef _MSC_VER
  22. #include <sys/types.h>
  23. #include <sys/stat.h>
  24. inline int _mkdir(char *name, int mode)
  25. {
  26. return (mkdir(name, mode));
  27. }
  28. #endif
  29. // ------------------------------------------------------------
  30. // PropTest_* macros to abstract OLE2ANSI and _UNICODE handling
  31. // ------------------------------------------------------------
  32. // PropTest_CreateDirectory: Calls the appropriate CreateDirectory
  33. // for an OLECHAR input.
  34. #ifdef OLE2ANSI
  35. #define PropTest_CreateDirectory CreateDirectoryA
  36. #else
  37. #define PropTest_CreateDirectory CreateDirectoryW
  38. #endif
  39. // --------------------
  40. // Miscellaneous Macros
  41. // --------------------
  42. #define Check(x,y) _Check(x,y, __LINE__)
  43. #define CCH_MAP (1 << CBIT_CHARMASK) // 32
  44. #define CHARMASK (CCH_MAP - 1) // 0x1f
  45. #define CALPHACHARS ('z' - 'a' + 1)
  46. #define CPROPERTIES 5
  47. // ----------
  48. // Format IDs
  49. // ----------
  50. DEFINE_GUID(MyProp1, 0x63057ed0, 0x3d7b, 0x11ce, 0xa3, 0x54, 0x00, 0xaa, 0x00, 0x53, 0x04, 0x06);
  51. // ---------
  52. // Constants
  53. // ---------
  54. // Property Id's for Summary Info, as defined in OLE 2 Prog. Ref.
  55. #define PID_TITLE 0x00000002L
  56. #define PID_SUBJECT 0x00000003L
  57. #define PID_AUTHOR 0x00000004L
  58. #define PID_KEYWORDS 0x00000005L
  59. #define PID_COMMENTS 0x00000006L
  60. #define PID_TEMPLATE 0x00000007L
  61. #define PID_LASTAUTHOR 0x00000008L
  62. #define PID_REVNUMBER 0x00000009L
  63. #define PID_EDITTIME 0x0000000aL
  64. #define PID_LASTPRINTED 0x0000000bL
  65. #define PID_CREATE_DTM 0x0000000cL
  66. #define PID_LASTSAVE_DTM 0x0000000dL
  67. #define PID_PAGECOUNT 0x0000000eL
  68. #define PID_WORDCOUNT 0x0000000fL
  69. #define PID_CHARCOUNT 0x00000010L
  70. #define PID_THUMBNAIL 0x00000011L
  71. #define PID_APPNAME 0x00000012L
  72. #define PID_DOC_SECURITY 0x00000013L
  73. // Property Id's for Document Summary Info, as define in OLE Property Exchange spec.
  74. #define PID_CATEGORY 0x00000002L
  75. #define PID_PRESFORMAT 0x00000003L
  76. #define PID_BYTECOUNT 0x00000004L
  77. #define PID_LINECOUNT 0x00000005L
  78. #define PID_PARACOUNT 0x00000006L
  79. #define PID_SLIDECOUNT 0x00000007L
  80. #define PID_NOTECOUNT 0x00000008L
  81. #define PID_HIDDENCOUNT 0x00000009L
  82. #define PID_MMCLIPCOUNT 0x0000000aL
  83. #define PID_SCALE 0x0000000bL
  84. #define PID_HEADINGPAIR 0x0000000cL
  85. #define PID_DOCPARTS 0x0000000dL
  86. #define PID_MANAGER 0x0000000eL
  87. #define PID_COMPANY 0x0000000fL
  88. #define PID_LINKSDIRTY 0x00000010L
  89. #define CPROPERTIES_ALL 31
  90. typedef struct tagFULLPROPSPEC
  91. {
  92. GUID guidPropSet;
  93. PROPSPEC psProperty;
  94. } FULLPROPSPEC;
  95. //=======================================================
  96. //
  97. // TSafeStorage
  98. //
  99. // This template creates a "safe pointer" to an IStorage,
  100. // IStream, IPropertySetStorage, or IPropertyStorage.
  101. // One constructor receives an IStorage*, which is used
  102. // when creating a pointer to an IPropertySetStorage.
  103. //
  104. // For example:
  105. //
  106. // TSafeStorage<IStorage> pstg;
  107. // StgCreateDocFile( L"Foo", STGM_ ..., 0L, &pstg );
  108. // TSafeStorage<IPropertySetStorage> psetstg( pstg );
  109. // pstg->Release();
  110. // pstg = NULL;
  111. // pssetstg->Open ...
  112. //
  113. //=======================================================
  114. template<class STGTYPE> class TSafeStorage
  115. {
  116. public:
  117. TSafeStorage()
  118. {
  119. _pstg = NULL;
  120. }
  121. // Special case: Receive an IStorage and query for
  122. // an IPropertySetStorage.
  123. TSafeStorage(IStorage *pstg)
  124. {
  125. Check(S_OK, pstg->QueryInterface(IID_IPropertySetStorage, (void**)&_pstg));
  126. }
  127. ~TSafeStorage()
  128. {
  129. if (_pstg != NULL)
  130. {
  131. _pstg->Release();
  132. }
  133. }
  134. STGTYPE * operator -> ()
  135. {
  136. Check(TRUE, _pstg != NULL);
  137. return(_pstg);
  138. }
  139. STGTYPE** operator & ()
  140. {
  141. return(&_pstg);
  142. }
  143. STGTYPE* operator=( STGTYPE *pstg )
  144. {
  145. _pstg = pstg;
  146. return _pstg;
  147. }
  148. operator STGTYPE *()
  149. {
  150. return _pstg;
  151. }
  152. private:
  153. STGTYPE *_pstg;
  154. };
  155. #endif // !_PROPTEST_HXX_