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.

860 lines
24 KiB

  1. //+=================================================================
  2. //
  3. // File: PropTest.hxx
  4. //
  5. // Description: This file provides macros and constants
  6. // for the Property Test DRT.
  7. //
  8. //+=================================================================
  9. #ifndef _PROPTEST_HXX_
  10. #define _PROPTEST_HXX_
  11. #include "propapi.h"
  12. //+----------------------------------------------------------------------------
  13. //
  14. // M a c r o s
  15. //
  16. //+----------------------------------------------------------------------------
  17. // ------------------------------------------------------------
  18. // PropTest_* macros to abstract OLE2ANSI and _UNICODE handling
  19. // ------------------------------------------------------------
  20. #ifdef _MAC
  21. # define PROPTEST_FILE_HANDLE FILE*
  22. # define PropTest_CreateFile(name) fopen(name, "w+")
  23. # define PropTest_WriteFile(hFile,buf,cbBuf,pcbWritten) \
  24. *pcbWritten = fwrite(buf,1,cbBuf,hFile)
  25. # define PropTest_CloseHandle(handle) fclose(handle)
  26. #else
  27. # define PROPTEST_FILE_HANDLE HANDLE
  28. # define PropTest_CreateDirectory CreateDirectoryA
  29. # define PropTest_CreateFile(name) CreateFileA( name, \
  30. GENERIC_READ|GENERIC_WRITE, \
  31. 0, NULL, CREATE_ALWAYS, \
  32. FILE_ATTRIBUTE_NORMAL, \
  33. NULL )
  34. # define PropTest_WriteFile(hFile,buf,cbBuf,pcbWritten) \
  35. WriteFile(hFile, buf, cbBuf, pcbWritten, NULL)
  36. # define PropTest_CloseHandle(handle) CloseHandle(handle)
  37. #endif
  38. #ifndef ELEMENTS
  39. #define ELEMENTS(x) (sizeof(x)/sizeof(x[0]))
  40. #endif
  41. // CodePage macros:
  42. // We'll set the "good" codepage to 4e5, which is available on
  43. // NT and installable on Win95. But on the Mac, only 4e4 is
  44. // available, so this is what we'll use.
  45. #define CODEPAGE_DEFAULT 0x04e4 // US English
  46. #define CODEPAGE_BAD 0x9999 // Non-existent code page
  47. #ifdef _MAC
  48. #define CODEPAGE_GOOD 0x04e4
  49. #else
  50. #define CODEPAGE_GOOD 0x04e5
  51. #endif
  52. // Defines used by test_CodePage
  53. #define CODEPAGE_TEST_NAMED_PROPERTY OLESTR("Named Property")
  54. #define CODEPAGE_TEST_UNNAMED_BSTR_PROPID 3
  55. #define CODEPAGE_TEST_UNNAMED_I4_PROPID 4
  56. #define CODEPAGE_TEST_VBSTR_PROPID 7
  57. #define CODEPAGE_TEST_VPROPVAR_BSTR_PROPID 9
  58. // --------
  59. // Typedefs
  60. // --------
  61. typedef enum tagOSENUM
  62. {
  63. osenumUnknown, osenumWin95, osenumDCOM95,
  64. osenumNT3, osenumNT4, osenumMac
  65. } OSENUM;
  66. typedef struct tagSYSTEMINFO
  67. {
  68. OSENUM osenum;
  69. BOOL fIPropMarshaling;
  70. } SYSTEMINFO;
  71. //-----------------------------------------------------------------------------
  72. //
  73. // P r o t o t y p e s
  74. //
  75. //-----------------------------------------------------------------------------
  76. HRESULT OpenDir(
  77. WCHAR *path,
  78. BOOL fCreate,
  79. IStorage **ppistg);
  80. HRESULT OpenFile(
  81. WCHAR *path,
  82. BOOL fCreate,
  83. IStorage **ppistg);
  84. HRESULT OpenJP(
  85. WCHAR *path,
  86. BOOL fCreate,
  87. IStorage **ppistg);
  88. HRESULT OpenSC(
  89. WCHAR *path,
  90. BOOL fCreate,
  91. IStorage **ppistg);
  92. HRESULT OpenStg(
  93. WCHAR *path,
  94. BOOL fCreate,
  95. IStorage **ppistg);
  96. FILETIME operator - ( const FILETIME &ft1, const FILETIME &ft2 );
  97. FILETIME operator -= ( FILETIME &ft1, const FILETIME &ft2 );
  98. void DeleteBagExProperties( IPropertyBagEx *pbag, const OLECHAR *poszPrefix );
  99. void CheckTime(const FILETIME &ftStart, const FILETIME &ftPropSet);
  100. void CheckStat( IPropertyStorage *pPropSet, REFFMTID fmtid,
  101. REFCLSID clsid, ULONG PropSetFlag,
  102. const FILETIME & ftStart, DWORD dwOSVersion );
  103. BOOL IsEqualSTATPROPSTG(const STATPROPSTG *p1, const STATPROPSTG *p2);
  104. void CreateCodePageTestFile( LPOLESTR poszFileName, IStorage **ppStg );
  105. void SeekToProperty( IStream *pStm, PROPID propidSearch );
  106. void ModifyPropSetCodePage( IStorage *pStg, const FMTID &fmtid, USHORT usCodePage );
  107. void ModifyPropertyType( IStorage *pStg, const FMTID &fmtid, PROPID propid, VARTYPE vt );
  108. void ModifyOSVersion( IStorage* pStg, DWORD dwOSVersion );
  109. void _Check(HRESULT hrExpected, HRESULT hrActual, LPCSTR szFile, int line);
  110. OLECHAR * GetNextTest();
  111. VOID CleanStat(ULONG celt, STATPROPSTG *psps);
  112. HRESULT PopulateRGPropVar( CPropVariant rgcpropvar[],
  113. CPropSpec rgcpropspec[],
  114. const OLECHAR *rgoszpropnameAll[],
  115. IStorage *pstg );
  116. BOOLEAN PROPSYSAPI PROPAPI
  117. PropTestCompareVariants(
  118. USHORT CodePage,
  119. PROPVARIANT const *pvar1,
  120. PROPVARIANT const *pvar2);
  121. HRESULT ResetRGPropVar( CPropVariant rgcpropvar[] );
  122. void CheckFormatVersion( IPropertyStorage *ppropstg, WORD wExpected );
  123. void CheckLockCount( IUnknown *punk, LONG lExpected );
  124. NTSTATUS GetProcessInfo( PSYSTEM_PROCESS_INFORMATION pspi );
  125. VOID DumpOleStorage( IStorage *pstg, IPropertySetStorage *pIPropStg ,LPOLESTR aocpath );
  126. VOID Status( char *szMessage );
  127. VOID CalcSafeArrayIndices( LONG iLinear, LONG rgIndices[], const SAFEARRAYBOUND rgsaBounds[], ULONG cDims );
  128. ULONG CalcSafeArrayElementCount( const SAFEARRAY *psa );
  129. VOID CompareSafeArrays( SAFEARRAY *psa1, SAFEARRAY *psa2 );
  130. void test_PropsetOnEmptyFile( OLECHAR *poszDir );
  131. void test_ReadOnlyReservedProperties( IStorage *pStg );
  132. void test_PropsetOnHGlobal();
  133. void test_SettingLocalization( IStorage *pstg );
  134. void test_PidIllegal( IStorage *pstg );
  135. void test_StgOnHandle( OLECHAR *poszDir );
  136. void test_IPropertyBag( IStorage *pstg );
  137. void test_BagVtUnknown( IStorage *pstg );
  138. void test_StgOpenOnHandle( LPOLESTR ocsDir );
  139. void test_PropertyLengthAsVariant( );
  140. void test_SafeArray( IStorage *pstg );
  141. void test_ByRef( IStorage *pstg );
  142. void test_ExtendedTypes( IStorage *pstg );
  143. void test_LowMemory( IStorage *pstg );
  144. void test_BagInterfaceTypes( IStorage *pstg );
  145. void test_MultipleReader( LPOLESTR ocsDir );
  146. void test_Robustness(OLECHAR *poszDir);
  147. void test_EmptyBag( OLECHAR *poszDir );
  148. void test_VersionOneNames( IStorage *pstg );
  149. void test_BagOpenMethod( IStorage *pstg );
  150. void test_WriteReadAllProperties( LPOLESTR ocsDir ); // **
  151. void test_BagDelete( IStorage *pstg );
  152. void test_BagEnum( IStorage *pstg );
  153. void test_BagCoercion( IStorage *pstg );
  154. void test_StandaloneAPIs( LPOLESTR ocsDir );
  155. void test_IPropertySetStorage_IUnknown(IStorage *pStorage);
  156. void test_PropVariantValidation( IStorage *pStg );
  157. void test_ParameterValidation(IStorage *pStg);
  158. void test_IPropertySetStorage_CreateOpenDelete(IStorage *pStorage);
  159. void test_IPropertySetStorage_SummaryInformation(IStorage *pStorage);
  160. void test_IPropertySetStorage_FailIfThere(IStorage *pStorage);
  161. void test_IPropertySetStorage_BadThis(IStorage *pIgnored);
  162. void test_IPropertySetStorage_TransactedMode(IStorage *pStorage);
  163. void test_IPropertySetStorage_TransactedMode2(IStorage *pStorage);
  164. void test_IPropertySetStorage_SubPropertySet(IStorage *pStorage);
  165. void test_IPropertySetStorage_CommitAtRoot(IStorage *pStorage);
  166. void test_IPropertySetStorage(IStorage *pStorage);
  167. void test_IEnumSTATPROPSETSTG(IStorage *pStorage);
  168. void test_IPropertyStorage_Access(IStorage *pStorage);
  169. void test_IPropertyStorage_Create(IStorage *pStorage);
  170. void test_IPropertyStorage_Stat(IStorage *pStorage);
  171. void test_IPropertyStorage_ReadMultiple_Normal(IStorage *pStorage);
  172. void test_UnsupportedProperties( IStorage *pStg );
  173. void test_IPropertyStorage_ReadMultiple_Cleanup(IStorage *pStorage);
  174. void test_IPropertyStorage_ReadMultiple_Inconsistent(IStorage *pStorage);
  175. void test_IPropertyStorage_ReadMultiple(IStorage *pStorage);
  176. void test_IPropertyStorage_WriteMultiple_Overwrite1(IStorage *pStgBase);
  177. void test_IPropertyStorage_WriteMultiple_Overwrite2(IStorage *pStorage);
  178. void test_IPropertyStorage_WriteMultiple_Overwrite3(IStorage *pStorage);
  179. void test_IPropertyStorage_Commit(IStorage *pStorage);
  180. void test_IPropertyStorage_WriteMultiple(IStorage *pStorage);
  181. void test_IPropertyStorage_DeleteMultiple(IStorage *pStorage);
  182. void test_IPropertyStorage(IStorage *pStorage);
  183. void test_Word6(IStorage *pStorage, CHAR *szTemporaryDirectory); // **
  184. void test_SimpleLeaks( LPOLESTR poszDir ); // **
  185. void test_IEnumSTATPROPSTG(IStorage *pstgTemp); // **
  186. void test_MaxPropertyName(IStorage *pstgTemp); // **
  187. void test_CodePages( LPOLESTR poszDirectory ); // **
  188. void test_PropertyInterfaces(IStorage *pstgTemp); // **
  189. void test_CopyTo(IStorage *pstgSource, // Source of the CopyTo
  190. IStorage *pstgDestination, // Destination of the CopyTo
  191. ULONG ulBaseStgTransaction, // Transaction bit for the base storage.
  192. ULONG ulPropSetTransaction, // Transaction bit for the property sets.
  193. LPOLESTR oszBaseStorageName );
  194. void test_OLESpecTickerExample( IStorage* pstg );
  195. void test_Office( LPOLESTR wszTestFile ); // **
  196. void test_Office2(IStorage *pStorage);
  197. void test_PropVariantCopy( );
  198. void test_SimpleDocFile(LPOLESTR ocsDir);
  199. void test_ex_api(LPOLESTR ocsDir);
  200. void test_Performance( IStorage *pStg );
  201. void test_CoFileTimeNow();
  202. void test_PROPSETFLAG_UNBUFFERED( IStorage *pStg );
  203. void test_PropStgNameConversion( IStorage *pStg );
  204. void test_PropStgNameConversion2();
  205. extern OLECHAR g_aocMap[];
  206. extern BOOL g_fVerbose;
  207. extern BOOL g_fRegisterLocalServer;
  208. extern CPropVariant g_rgcpropvarAll[];
  209. extern CPropSpec g_rgcpropspecAll[];
  210. extern const OLECHAR *g_rgoszpropnameAll[];
  211. extern char g_szPropHeader[];
  212. extern char g_szEmpty[];
  213. extern LARGE_INTEGER g_li0;
  214. extern IStorage *_pstgTemp;
  215. extern IStorage *_pstgTempCopyTo;
  216. extern SYSTEMINFO g_SystemInfo;
  217. extern BOOL g_stgmDumpFlags;
  218. #ifdef _MAC
  219. extern CDisplay *g_pcDisplay;
  220. #endif
  221. //+----------------------------------------------------------------------------
  222. //
  223. // M a c r o s
  224. //
  225. //+----------------------------------------------------------------------------
  226. #define Check(x,y) _Check((HRESULT)(x),(HRESULT) (y), __FILE__, __LINE__)
  227. // PropTest_towcs: Either copies or converts zero-terminated LPOLESTR
  228. // to an LPWSTR.
  229. #ifndef OLE2ANSI
  230. //#define PropTest_mbstoocs(ocsDest,szSource) mbstowcs(ocsDest, szSource, strlen(szSource)+1)
  231. inline void
  232. PropTest_mbstoocs( OLECHAR *poszDest, ULONG cbDest, CHAR *pszSource )
  233. {
  234. Check( TRUE, 0 != MultiByteToWideChar( GetACP(), 0, pszSource, -1, poszDest, cbDest ));
  235. }
  236. #else
  237. #define PropTest_mbstoocs(ocsDest,szSource) strcpy( ocsDest, szSource)
  238. #endif
  239. #define CCH_MAP (1 << CBIT_CHARMASK) // 32
  240. #define CHARMASK (CCH_MAP - 1) // 0x1f
  241. #define CALPHACHARS ('z' - 'a' + 1)
  242. #define CPROPERTIES 5
  243. // The following macros are used for printf. Both printf
  244. // and oprintf macros are given (oprintf is assumes that
  245. // strings are OLECHARs). And for each, there is a normal
  246. // version, and an "ASYNC" version. The ASYNC version tells the
  247. // receiver that the string need not be displayed immediately
  248. // (this improves performance on the Mac).
  249. //
  250. // On the Mac, we pass the string to the CDisplay object.
  251. // On NT, we simple call the corresponding CRT routine.
  252. #ifdef _MAC
  253. # define PRINTF g_pcDisplay->printf
  254. # define OPRINTF g_pcDisplay->printf
  255. # define ASYNC_PRINTF g_pcDisplay->async_printf
  256. # define ASYNC_OPRINTF g_pcDisplay->async_printf
  257. #else
  258. # define PRINTF printf
  259. # define ASYNC_PRINTF printf
  260. # define OPRINTF oprintf
  261. # define ASYNC_OPRINTF oprintf
  262. #endif
  263. // -------
  264. // Globals
  265. // -------
  266. extern const OLECHAR oszSummaryInformation[];
  267. extern ULONG cboszSummaryInformation;
  268. extern const OLECHAR oszDocSummaryInformation[];
  269. extern ULONG cboszDocSummaryInformation;
  270. extern const OLECHAR oszGlobalInfo[];
  271. extern ULONG cboszGlobalInfo;
  272. extern const OLECHAR oszImageContents[];
  273. extern ULONG cboszImageContents;
  274. extern const OLECHAR oszImageInfo[];
  275. extern ULONG cboszImageInfo;
  276. extern int g_nIndent;
  277. extern const GUID fmtidGlobalInfo;
  278. extern const FMTID fmtidImageContents;
  279. extern const FMTID fmtidImageInfo;
  280. // ---------
  281. // Constants
  282. // ---------
  283. #define NUM_WELL_KNOWN_PROPSETS 6
  284. // Property Id's for Summary Info, as defined in OLE 2 Prog. Ref.
  285. #define PID_TITLE 0x00000002L
  286. #define PID_SUBJECT 0x00000003L
  287. #define PID_AUTHOR 0x00000004L
  288. #define PID_KEYWORDS 0x00000005L
  289. #define PID_COMMENTS 0x00000006L
  290. #define PID_TEMPLATE 0x00000007L
  291. #define PID_LASTAUTHOR 0x00000008L
  292. #define PID_REVNUMBER 0x00000009L
  293. #define PID_EDITTIME 0x0000000aL
  294. #define PID_LASTPRINTED 0x0000000bL
  295. #define PID_CREATE_DTM 0x0000000cL
  296. #define PID_LASTSAVE_DTM 0x0000000dL
  297. #define PID_PAGECOUNT 0x0000000eL
  298. #define PID_WORDCOUNT 0x0000000fL
  299. #define PID_CHARCOUNT 0x00000010L
  300. #define PID_THUMBNAIL 0x00000011L
  301. #define PID_APPNAME 0x00000012L
  302. #define PID_DOC_SECURITY 0x00000013L
  303. // Property Id's for Document Summary Info, as define in OLE Property Exchange spec.
  304. #define PID_CATEGORY 0x00000002L
  305. #define PID_PRESFORMAT 0x00000003L
  306. #define PID_BYTECOUNT 0x00000004L
  307. #define PID_LINECOUNT 0x00000005L
  308. #define PID_PARACOUNT 0x00000006L
  309. #define PID_SLIDECOUNT 0x00000007L
  310. #define PID_NOTECOUNT 0x00000008L
  311. #define PID_HIDDENCOUNT 0x00000009L
  312. #define PID_MMCLIPCOUNT 0x0000000aL
  313. #define PID_SCALE 0x0000000bL
  314. #define PID_HEADINGPAIR 0x0000000cL
  315. #define PID_DOCPARTS 0x0000000dL
  316. #define PID_MANAGER 0x0000000eL
  317. #define PID_COMPANY 0x0000000fL
  318. #define PID_LINKSDIRTY 0x00000010L
  319. #define CPROPERTIES_ALL 38//36
  320. #define CPROPERTIES_ALL_SIMPLE 33
  321. #define TEST_STANDARD 0x02
  322. #define TEST_WORD6 0x04
  323. #define TEST_MARSHALING 0x08
  324. #define TEST_COFILETIMENOW 0x10
  325. #define TEST_PERFORMANCE 0x20
  326. #define TEST_SIMPLE_LEAKS 0x40
  327. //=======================================================
  328. //
  329. // TSafeStorage
  330. //
  331. // This template creates a "safe pointer" to an IStorage,
  332. // IStream, IPropertySetStorage, or IPropertyStorage.
  333. // One constructor receives an IStorage*, which is used
  334. // when creating a pointer to an IPropertySetStorage.
  335. //
  336. // For example:
  337. //
  338. // TSafeStorage<IStorage> pstg;
  339. // StgCreateDocFile( L"Foo", STGM_ ..., 0L, &pstg );
  340. // TSafeStorage<IPropertySetStorage> psetstg( pstg );
  341. // pstg->Release();
  342. // pstg = NULL;
  343. // pssetstg->Open ...
  344. //
  345. //=======================================================
  346. template<class STGTYPE> class TSafeStorage
  347. {
  348. public:
  349. TSafeStorage()
  350. {
  351. _pstg = NULL;
  352. }
  353. // Special case: Receive an IStorage and query for
  354. // an IPropertySetStorage.
  355. TSafeStorage(IStorage *pstg)
  356. {
  357. Check( S_OK, StgToPropSetStg( pstg, (IPropertySetStorage**) &_pstg ));
  358. }
  359. ~TSafeStorage()
  360. {
  361. if (_pstg != NULL)
  362. {
  363. _pstg->Release();
  364. }
  365. }
  366. STGTYPE * operator -> ()
  367. {
  368. Check(TRUE, _pstg != NULL);
  369. return(_pstg);
  370. }
  371. STGTYPE** operator & ()
  372. {
  373. return(&_pstg);
  374. }
  375. STGTYPE* operator=( STGTYPE *pstg )
  376. {
  377. _pstg = pstg;
  378. return _pstg;
  379. }
  380. operator STGTYPE *()
  381. {
  382. return _pstg;
  383. }
  384. private:
  385. STGTYPE *_pstg;
  386. };
  387. //+----------------------------------------------------------------------------
  388. //
  389. // IStream Wrapper
  390. // (Makes a stream read-only)
  391. //
  392. //+----------------------------------------------------------------------------
  393. class CReadOnlyStream : public IStream
  394. {
  395. public:
  396. HRESULT STDMETHODCALLTYPE QueryInterface(
  397. /* [in] */ REFIID riid,
  398. /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
  399. {
  400. if( IID_IStream != riid )
  401. {
  402. *ppvObject = NULL;
  403. return( E_NOINTERFACE );
  404. }
  405. _pstm->AddRef();
  406. *ppvObject = this;
  407. return( S_OK );
  408. }
  409. ULONG STDMETHODCALLTYPE AddRef( void)
  410. {
  411. return( _pstm->AddRef() );
  412. }
  413. ULONG STDMETHODCALLTYPE Release( void)
  414. {
  415. return( _pstm->Release() );
  416. }
  417. public:
  418. /* [local] */ HRESULT STDMETHODCALLTYPE Read(
  419. /* [length_is][size_is][out] */ void __RPC_FAR *pv,
  420. /* [in] */ ULONG cb,
  421. /* [out] */ ULONG __RPC_FAR *pcbRead)
  422. {
  423. return( _pstm->Read( pv, cb, pcbRead ));
  424. }
  425. /* [local] */ HRESULT STDMETHODCALLTYPE Write(
  426. /* [size_is][in] */ const void __RPC_FAR *pv,
  427. /* [in] */ ULONG cb,
  428. /* [out] */ ULONG __RPC_FAR *pcbWritten)
  429. {
  430. return( STG_E_ACCESSDENIED );
  431. }
  432. /* [local] */ HRESULT STDMETHODCALLTYPE Seek(
  433. /* [in] */ LARGE_INTEGER dlibMove,
  434. /* [in] */ DWORD dwOrigin,
  435. /* [out] */ ULARGE_INTEGER __RPC_FAR *plibNewPosition)
  436. {
  437. return( _pstm->Seek( dlibMove, dwOrigin, plibNewPosition ));
  438. }
  439. HRESULT STDMETHODCALLTYPE SetSize(
  440. /* [in] */ ULARGE_INTEGER libNewSize)
  441. {
  442. return( STG_E_ACCESSDENIED );
  443. }
  444. /* [local] */ HRESULT STDMETHODCALLTYPE CopyTo(
  445. /* [unique][in] */ IStream __RPC_FAR *pstm,
  446. /* [in] */ ULARGE_INTEGER cb,
  447. /* [out] */ ULARGE_INTEGER __RPC_FAR *pcbRead,
  448. /* [out] */ ULARGE_INTEGER __RPC_FAR *pcbWritten)
  449. {
  450. return( _pstm->CopyTo( pstm, cb, pcbRead, pcbWritten ));
  451. }
  452. HRESULT STDMETHODCALLTYPE Commit(
  453. /* [in] */ DWORD grfCommitFlags)
  454. {
  455. return( STG_E_ACCESSDENIED );
  456. }
  457. HRESULT STDMETHODCALLTYPE Revert( void)
  458. {
  459. return( STG_E_ACCESSDENIED );
  460. }
  461. HRESULT STDMETHODCALLTYPE LockRegion(
  462. /* [in] */ ULARGE_INTEGER libOffset,
  463. /* [in] */ ULARGE_INTEGER cb,
  464. /* [in] */ DWORD dwLockType)
  465. {
  466. return( _pstm->LockRegion( libOffset, cb, dwLockType ));
  467. }
  468. HRESULT STDMETHODCALLTYPE UnlockRegion(
  469. /* [in] */ ULARGE_INTEGER libOffset,
  470. /* [in] */ ULARGE_INTEGER cb,
  471. /* [in] */ DWORD dwLockType)
  472. {
  473. return( _pstm->UnlockRegion( libOffset, cb, dwLockType ));
  474. }
  475. HRESULT STDMETHODCALLTYPE Stat(
  476. /* [out] */ STATSTG __RPC_FAR *pstatstg,
  477. /* [in] */ DWORD grfStatFlag)
  478. {
  479. HRESULT hr = _pstm->Stat( pstatstg, grfStatFlag );
  480. if( SUCCEEDED(hr) )
  481. pstatstg->grfMode &= STGM_RDWR_MASK;
  482. return( hr );
  483. }
  484. HRESULT STDMETHODCALLTYPE Clone(
  485. /* [out] */ IStream __RPC_FAR *__RPC_FAR *ppstm)
  486. {
  487. return( _pstm->Clone( ppstm ));
  488. }
  489. public:
  490. CReadOnlyStream( IStream *pstm )
  491. {
  492. _pstm = pstm;
  493. }
  494. private:
  495. IStream *_pstm;
  496. };
  497. //+----------------------------------------------------------------------------
  498. //
  499. // I n l i n e s
  500. //
  501. //+----------------------------------------------------------------------------
  502. __inline OLECHAR
  503. MapChar(IN ULONG i)
  504. {
  505. return((OLECHAR) g_aocMap[i & CHARMASK]);
  506. }
  507. inline BOOL operator == ( const FILETIME &ft1, const FILETIME &ft2 )
  508. {
  509. return( ft1.dwHighDateTime == ft2.dwHighDateTime
  510. &&
  511. ft1.dwLowDateTime == ft2.dwLowDateTime );
  512. }
  513. inline BOOL operator != ( const FILETIME &ft1, const FILETIME &ft2 )
  514. {
  515. return( ft1.dwHighDateTime != ft2.dwHighDateTime
  516. ||
  517. ft1.dwLowDateTime != ft2.dwLowDateTime );
  518. }
  519. inline BOOL operator > ( const FILETIME &ft1, const FILETIME &ft2 )
  520. {
  521. return( ft1.dwHighDateTime > ft2.dwHighDateTime
  522. ||
  523. ft1.dwHighDateTime == ft2.dwHighDateTime
  524. &&
  525. ft1.dwLowDateTime > ft2.dwLowDateTime );
  526. }
  527. inline BOOL operator < ( const FILETIME &ft1, const FILETIME &ft2 )
  528. {
  529. return( ft1.dwHighDateTime < ft2.dwHighDateTime
  530. ||
  531. ft1.dwHighDateTime == ft2.dwHighDateTime
  532. &&
  533. ft1.dwLowDateTime < ft2.dwLowDateTime );
  534. }
  535. inline BOOL operator >= ( const FILETIME &ft1, const FILETIME &ft2 )
  536. {
  537. return( ft1 > ft2
  538. ||
  539. ft1 == ft2 );
  540. }
  541. inline BOOL operator <= ( const FILETIME &ft1, const FILETIME &ft2 )
  542. {
  543. return( ft1 < ft2
  544. ||
  545. ft1 == ft2 );
  546. }
  547. //+----------------------------------------------------------------------------
  548. //
  549. // C l a s s e s
  550. //
  551. //+----------------------------------------------------------------------------
  552. enum CreateOpen
  553. {
  554. coCreate, coOpen
  555. };
  556. class CTempStorage
  557. {
  558. public:
  559. CTempStorage(DWORD grfMode = STGM_DIRECT | STGM_CREATE)
  560. {
  561. Check(S_OK, (_pstgTemp->CreateStorage(GetNextTest(), grfMode |
  562. STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0,
  563. &_pstg)));
  564. }
  565. CTempStorage(CreateOpen co, IStorage *pstgParent, OLECHAR *pocsChild, DWORD grfMode = STGM_DIRECT)
  566. {
  567. if (co == coCreate)
  568. Check(S_OK, pstgParent->CreateStorage(pocsChild,
  569. grfMode | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0,
  570. &_pstg));
  571. else
  572. Check(S_OK, pstgParent->OpenStorage(pocsChild, NULL,
  573. grfMode | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, NULL, 0,
  574. &_pstg));
  575. }
  576. ~CTempStorage()
  577. {
  578. if (_pstg != NULL)
  579. _pstg->Release();
  580. }
  581. IStorage * operator -> ()
  582. {
  583. return(_pstg);
  584. }
  585. operator IStorage * ()
  586. {
  587. return(_pstg);
  588. }
  589. void Release()
  590. {
  591. if (_pstg != NULL)
  592. {
  593. _pstg->Release();
  594. _pstg = NULL;
  595. }
  596. }
  597. private:
  598. static unsigned int _iName;
  599. IStorage * _pstg;
  600. };
  601. class CGenProps
  602. {
  603. public:
  604. CGenProps() : _vt((VARENUM)2) {}
  605. PROPVARIANT * GetNext(int HowMany, int *pActual, BOOL fWrapOk = FALSE, BOOL fNoNonSimple = TRUE);
  606. private:
  607. BOOL _GetNext(PROPVARIANT *pVar, BOOL fWrapOk, BOOL fNoNonSimple);
  608. VARENUM _vt;
  609. };
  610. class CObjectWithPersistStorage : public IPersistStorage
  611. {
  612. private:
  613. BOOL _fDirty:1;
  614. LONG _cRefs;
  615. OLECHAR *_poszData;
  616. static CLSID _clsid;
  617. public:
  618. CObjectWithPersistStorage( const OLECHAR *posz );
  619. CObjectWithPersistStorage();
  620. ~CObjectWithPersistStorage();
  621. public:
  622. BOOL operator==( const CObjectWithPersistStorage & Other );
  623. CLSID GetClassID() { return _clsid; }
  624. public:
  625. HRESULT STDMETHODCALLTYPE QueryInterface( REFIID iid, void** ppvObject );
  626. ULONG STDMETHODCALLTYPE AddRef();
  627. ULONG STDMETHODCALLTYPE Release();
  628. public:
  629. HRESULT STDMETHODCALLTYPE GetClassID(
  630. /* [out] */ CLSID __RPC_FAR *pClassID);
  631. HRESULT STDMETHODCALLTYPE IsDirty( void);
  632. HRESULT STDMETHODCALLTYPE InitNew(
  633. /* [unique][in] */ IStorage __RPC_FAR *pStg);
  634. HRESULT STDMETHODCALLTYPE Load(
  635. /* [unique][in] */ IStorage __RPC_FAR *pStg);
  636. HRESULT STDMETHODCALLTYPE Save(
  637. /* [unique][in] */ IStorage __RPC_FAR *pStgSave,
  638. /* [in] */ BOOL fSameAsLoad);
  639. HRESULT STDMETHODCALLTYPE SaveCompleted(
  640. /* [unique][in] */ IStorage __RPC_FAR *pStgNew);
  641. HRESULT STDMETHODCALLTYPE HandsOffStorage( void);
  642. }; // class CObjectWithPersistStorage
  643. class CObjectWithPersistStream : public IPersistStream
  644. {
  645. private:
  646. BOOL _fDirty:1;
  647. LONG _cRefs;
  648. OLECHAR *_poszData;
  649. static CLSID _clsid;
  650. public:
  651. CObjectWithPersistStream( const OLECHAR *posz );
  652. CObjectWithPersistStream();
  653. ~CObjectWithPersistStream();
  654. public:
  655. BOOL operator==( const CObjectWithPersistStream & Other );
  656. CLSID GetClassID() { return _clsid; }
  657. public:
  658. HRESULT STDMETHODCALLTYPE QueryInterface( REFIID iid, void** ppvObject );
  659. ULONG STDMETHODCALLTYPE AddRef();
  660. ULONG STDMETHODCALLTYPE Release();
  661. public:
  662. HRESULT STDMETHODCALLTYPE GetClassID(
  663. /* [out] */ CLSID __RPC_FAR *pClassID);
  664. HRESULT STDMETHODCALLTYPE IsDirty( void);
  665. HRESULT STDMETHODCALLTYPE Load(
  666. /* [unique][in] */ IStream __RPC_FAR *pStm);
  667. HRESULT STDMETHODCALLTYPE Save(
  668. /* [unique][in] */ IStream __RPC_FAR *pStm,
  669. /* [in] */ BOOL fClearDirty);
  670. HRESULT STDMETHODCALLTYPE GetSizeMax(
  671. /* [out] */ ULARGE_INTEGER __RPC_FAR *pcbSize);
  672. }; // class CObjectWithPersistStream
  673. class PropTestMemoryAllocator : public PMemoryAllocator
  674. {
  675. void *Allocate(ULONG cbSize)
  676. {
  677. return( CoTaskMemAlloc( cbSize ));
  678. }
  679. void Free(void *pv)
  680. {
  681. CoTaskMemFree( pv );
  682. }
  683. };
  684. #include "instant.hxx" // Instantiation support
  685. #endif // !_PROPTEST_HXX_