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.

139 lines
4.8 KiB

  1. // HHSYSSRT.H: Definition of CHHSysSort sort object implementation.
  2. #ifndef __HHSYSSRT_H__
  3. #define __HHSYSSRT_H__
  4. #define HHSYSSORT_VERSION 666
  5. #define HHSYSSORT_VERSION_ID_STR "HHCtrl.SystemSort.666"
  6. #define HHSYSSORT_ID_STR "HHCtrl.SystemSort"
  7. // New format
  8. #define IHHSK100_KEYTYPE_ANSI_SZ ((DWORD) 30) // NULL-term. MBCS string + extra data
  9. #define IHHSK100_KEYTYPE_UNICODE_SZ ((DWORD) 31) // NULL-term. Unicode string + extra data
  10. #if 0
  11. // New format
  12. #define IHHSK100_KEYTYPE_ANSI_SZ ((DWORD) 10030) // NULL-term. MBCS string + extra data
  13. #define IHHSK100_KEYTYPE_UNICODE_SZ ((DWORD) 10031) // NULL-term. Unicode string + extra data
  14. #endif
  15. // old format
  16. #define IHHSK666_KEYTYPE_ANSI_SZ ((DWORD) 66630) // NULL-term. MBCS string + extra data
  17. #define IHHSK666_KEYTYPE_UNICODE_SZ ((DWORD) 66631) // NULL-term. Unicode string + extra data
  18. // {4662dab0-d393-11d0-9a56-00c04fb68b66}
  19. // HACKHACK: I simply changed the last value of CLSID_ITSysSort from 0xf7 to 0x66
  20. DEFINE_GUID(CLSID_HHSysSort,
  21. 0x4662dab0, 0xd393, 0x11d0, 0x9a, 0x56, 0x00, 0xc0, 0x4f, 0xb6, 0x8b, 0x66);
  22. #if 0
  23. // {adb880a5-d8ff-11cf-9377-00aa003b7a11}
  24. DEFINE_GUID(CLSID_HHSysSort0,
  25. 0xadb880a5, 0xd8ff, 0x11cf, 0x93, 0x77, 0x00, 0xaa, 0x00, 0x3b, 0x7a, 0x11);
  26. #endif
  27. // the format of our sort key object is as follows:
  28. //
  29. // + Null terminated MBCS string
  30. // + HHKEYINFO structure
  31. // + trailing UIDs (DWORD) or the SeeAlso string
  32. //
  33. // If we overflow the buffer then the UIDs are stored in the occurence data and the
  34. // SeeAlso string stored as a property (STDPROP_USERPROP_BASE+1).
  35. #ifndef HHWW_FONT
  36. #define HHWW_FONT 0x1 // bit 0
  37. #define HHWW_SEEALSO 0x2 // bit 1
  38. #define HHWW_UID_OVERFLOW 0x4 // bit 2
  39. #endif
  40. // Our sort key information struct
  41. #pragma pack(push, 2)
  42. typedef struct _hhkeyinfo
  43. {
  44. WORD wFlags; // indicates what data is stored with this keyword
  45. WORD wLevel;
  46. DWORD dwLevelOffset;
  47. DWORD dwFont;
  48. DWORD dwCount; // number of UIDs that follow this structure in the sortkey
  49. } HHKEYINFO;
  50. #pragma pack(pop)
  51. // Sort control structure that contains all the information that can
  52. // vary how keys are compared.
  53. typedef struct _srtctl
  54. {
  55. DWORD dwCodePageID;
  56. LCID lcid;
  57. DWORD dwKeyType;
  58. DWORD grfSortFlags;
  59. } SRTCTL;
  60. class CHHSysSort :
  61. public IITSortKey,
  62. public IITSortKeyConfig,
  63. public IPersistStreamInit,
  64. public CComObjectRootEx<CComMultiThreadModel>,
  65. public CComCoClass<CHHSysSort,&CLSID_HHSysSort>
  66. {
  67. public:
  68. CHHSysSort();
  69. virtual ~CHHSysSort();
  70. BEGIN_COM_MAP(CHHSysSort)
  71. COM_INTERFACE_ENTRY(IITSortKey)
  72. COM_INTERFACE_ENTRY(IITSortKeyConfig)
  73. COM_INTERFACE_ENTRY(IPersistStreamInit)
  74. END_COM_MAP()
  75. DECLARE_REGISTRY(CLSID_HHSysSort, HHSYSSORT_VERSION_ID_STR, HHSYSSORT_ID_STR, 0, THREADFLAGS_BOTH )
  76. // IHHSortKey methods
  77. STDMETHOD(GetSize)(LPCVOID pvKey, DWORD* pcbSize);
  78. STDMETHOD(Compare)(LPCVOID pvKey1, LPCVOID pvKey2,
  79. LONG* plResult, DWORD* pgrfReason);
  80. STDMETHOD(IsRelated)(LPCVOID pvKey1, LPCVOID pvKey2,
  81. DWORD dwKeyRelation, DWORD* pgrfReason);
  82. STDMETHOD(Convert)(DWORD dwKeyTypeIn, LPCVOID pvKeyIn,
  83. DWORD dwKeyTypeOut, LPVOID pvKeyOut,
  84. DWORD* pcbSizeOut);
  85. STDMETHOD(ResolveDuplicates)(LPCVOID pvKey1, LPCVOID pvKey2,
  86. LPCVOID pvKeyOut, DWORD* pcbSizeOut);
  87. // IHHSortKeyConfig methods
  88. STDMETHOD(SetLocaleInfo)(DWORD dwCodePageID, LCID lcid);
  89. STDMETHOD(GetLocaleInfo)(DWORD* pdwCodePageID, LCID* plcid);
  90. STDMETHOD(SetKeyType)(DWORD dwKeyType);
  91. STDMETHOD(GetKeyType)(DWORD* pdwKeyType);
  92. STDMETHOD(SetControlInfo)(DWORD grfSortFlags, DWORD dwReserved);
  93. STDMETHOD(GetControlInfo)(DWORD* pgrfSortFlags, DWORD* pdwReserved);
  94. STDMETHOD(LoadExternalSortData)(IStream* pStream, DWORD dwExtDataType);
  95. // IPersistStreamInit methods
  96. STDMETHOD(GetClassID)(CLSID* pclsid);
  97. STDMETHOD(IsDirty)(void);
  98. STDMETHOD(Load)(IStream* pStream);
  99. STDMETHOD(Save)(IStream* pStream, BOOL fClearDirty);
  100. STDMETHOD(GetSizeMax)(ULARGE_INTEGER* pcbSizeMax);
  101. STDMETHOD(InitNew)(void);
  102. private:
  103. // Private methods
  104. void Close(void);
  105. HRESULT ReallocBuffer(HGLOBAL* phmemBuf, DWORD* cbBufCur, DWORD cbBufNew);
  106. HRESULT CompareSz(LPCVOID pvSz1, LONG cch1, LPCVOID pvSz2, LONG cch2,
  107. LONG* plResult, BOOL fUnicode);
  108. // Private data members
  109. BOOL m_fInitialized;
  110. BOOL m_fDirty;
  111. BOOL m_fWinNT;
  112. SRTCTL m_srtctl;
  113. HGLOBAL m_hmemAnsi1, m_hmemAnsi2;
  114. DWORD m_cbBufAnsi1Cur, m_cbBufAnsi2Cur;
  115. _ThreadModel::AutoCriticalSection m_cs; // Critical section obj.
  116. };
  117. // Initial size of Ansi string buffers.
  118. #define cbAnsiBufInit 256
  119. #endif // __HHSYSSRT_H__