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.

203 lines
4.5 KiB

  1. /*++
  2. Copyright (C) 1997-2001 Microsoft Corporation
  3. Module Name:
  4. CPROPSET.H
  5. Abstract:
  6. Purpose: Used by the compound file property set provider. This code was
  7. largly taken from some MSVC sample code which was modified
  8. somewhat in order to support VARIANT type arrays. In general,
  9. a CPropSet object contains a list of CPropSection objects
  10. which each contain a list of CProp objects.
  11. History:
  12. a-davj 04-Mar-97 Created.
  13. --*/
  14. typedef struct tagSECTIONHEADER
  15. {
  16. DWORD cbSection ;
  17. DWORD cProperties ; // Number of props.
  18. } SECTIONHEADER, *LPSECTIONHEADER ;
  19. typedef struct tagPROPERTYIDOFFSET
  20. {
  21. DWORD propertyID;
  22. DWORD dwOffset;
  23. } PROPERTYIDOFFSET, *LPPROPERTYIDOFFSET;
  24. typedef struct tagPROPHEADER
  25. {
  26. WORD wByteOrder ; // Always 0xFFFE
  27. WORD wFormat ; // Always 0
  28. DWORD dwOSVer ; // System version
  29. CLSID clsID ; // Application CLSID
  30. DWORD cSections ; // Number of sections (must be at least 1)
  31. } PROPHEADER, *LPPROPHEADER ;
  32. typedef struct tagFORMATIDOFFSET
  33. {
  34. GUID formatID;
  35. DWORD dwOffset;
  36. } FORMATIDOFFSET, *LPFORMATIDOFFSET;
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CProp
  39. class CProp : public CObject
  40. {
  41. friend class CPropSet ;
  42. friend class CPropSection ;
  43. public:
  44. // Construction
  45. CProp( void ) ;
  46. // Qualifiers
  47. BOOL Set( DWORD dwID, const LPVOID pValue, DWORD dwType, DWORD dwSize ) ;
  48. LPVOID Get( void ) ; // Returns pointer to actual value
  49. DWORD GetType( void ) ; // Returns property type
  50. DWORD GetID( void ) ;
  51. // Operations
  52. BOOL WriteToStream( IStream* pIStream ) ;
  53. BOOL ReadFromStream( IStream* pIStream, DWORD dwSize ) ;
  54. private:
  55. DWORD m_dwPropID ;
  56. DWORD m_dwType ;
  57. LPVOID m_pValue ;
  58. DWORD m_dwSize;
  59. LPVOID AllocValue(ULONG cb);
  60. void FreeValue();
  61. public:
  62. ~CProp() ;
  63. } ;
  64. /////////////////////////////////////////////////////////////////////////////
  65. // CPropSection
  66. class CPropSection : public CObject
  67. {
  68. friend class CPropSet ;
  69. friend class CProp ;
  70. public:
  71. // Construction
  72. CPropSection( void ) ;
  73. CPropSection( CLSID FormatID ) ;
  74. // Qualifiers
  75. void SetFormatID( CLSID FormatID ) ;
  76. void RemoveAll() ;
  77. CProp* GetProperty( DWORD dwPropID ) ;
  78. void AddProperty( CProp* pProp ) ;
  79. DWORD GetSize( void ) ;
  80. DWORD GetCount( void ) ;
  81. CObList* GetList( void ) ;
  82. BOOL SetSectionName( LPCTSTR pszName );
  83. LPCTSTR GetSectionName( void );
  84. // Operations
  85. BOOL WriteToStream( IStream* pIStream ) ;
  86. BOOL ReadFromStream( IStream* pIStream, LARGE_INTEGER liPropSet ) ;
  87. private:
  88. // Implementation
  89. CLSID m_FormatID ;
  90. SECTIONHEADER m_SH ;
  91. // List of properties (CProp)
  92. CObList m_PropList ;
  93. // Dictionary of property names
  94. CMapStringToPtr m_NameDict ;
  95. CString m_strSectionName;
  96. public:
  97. ~CPropSection();
  98. } ;
  99. /////////////////////////////////////////////////////////////////////////////
  100. // CPropSet
  101. class CPropSet : public CObject
  102. {
  103. friend class CPropSection ;
  104. friend class CProp ;
  105. public:
  106. // Construction
  107. CPropSet( void ) ;
  108. // Qualifiers
  109. void RemoveAll( ) ;
  110. CProp* GetProperty( CLSID FormatID, DWORD dwPropID ) ;
  111. void AddProperty( CLSID FormatID, CProp* pProp ) ;
  112. CPropSection* GetSection( CLSID FormatID ) ;
  113. CPropSection* AddSection( CLSID FormatID ) ;
  114. void AddSection( CPropSection* psect ) ;
  115. WORD GetByteOrder( void ) ;
  116. WORD GetFormatVersion( void ) ;
  117. void SetFormatVersion( WORD wFmtVersion ) ;
  118. DWORD GetOSVersion( void ) ;
  119. void SetOSVersion( DWORD dwOSVer ) ;
  120. CLSID GetClassID( void ) ;
  121. void SetClassID( CLSID clsid ) ;
  122. DWORD GetCount( void ) ;
  123. CObList* GetList( void ) ;
  124. // Operations
  125. BOOL WriteToStream( IStream* pIStream ) ;
  126. BOOL ReadFromStream( IStream* pIStream ) ;
  127. // Implementation
  128. private:
  129. PROPHEADER m_PH ;
  130. CObList m_SectionList ;
  131. public:
  132. ~CPropSet();
  133. } ;
  134. /////////////////////////////////////////////////////////////////////////////
  135. // CBuff
  136. class CBuff : public CObject
  137. {
  138. public:
  139. // Construction
  140. CBuff( void ) ;
  141. ~CBuff() ;
  142. // Qualifiers
  143. void Add(void *, DWORD dwAddSize);
  144. void * Get(void){return pBuff;};
  145. DWORD GetSize(void){return dwSize;};
  146. DWORD bOK(void){return !bAllocError;};
  147. void RoundOff(void);
  148. private:
  149. void * pBuff;
  150. DWORD dwSize;
  151. BOOL bAllocError;
  152. public:
  153. } ;