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.

244 lines
6.4 KiB

  1. //
  2. // dam.h
  3. //
  4. #ifndef DAM_H
  5. #define DAM_H
  6. #include "private.h"
  7. #include "ptrary.h"
  8. #include "strary.h"
  9. #include "enumguid.h"
  10. #include "sunka.h"
  11. #include "globals.h"
  12. extern const IID IID_CDisplayAttributeMgr; // private iid for CDisplayAttributeMgr pointer
  13. typedef struct tagDISPATTRGUID {
  14. CLSID clsid;
  15. TfGuidAtom gaClsid;
  16. GUID guid;
  17. TfGuidAtom gaGuid;
  18. } DISPATTRGUID;
  19. #define StaticCacheInit() CDispAttrGuidCache::StaticInit()
  20. class CDispAttrGuidCache;
  21. extern CDispAttrGuidCache *g_pDispAttrGuidCache;
  22. //////////////////////////////////////////////////////////////////////////////
  23. //
  24. // CRenderMarkupCollection
  25. //
  26. //////////////////////////////////////////////////////////////////////////////
  27. class CRenderMarkupCollection
  28. {
  29. public:
  30. CRenderMarkupCollection();
  31. void _Advise(ITfTextInputProcessor *tip, TfGuidAtom gaTip);
  32. void _Unadvise(TfGuidAtom gaTip);
  33. int _Count()
  34. {
  35. return _rgGUIDAtom.Count();
  36. }
  37. const TfGuidAtom *_GetAtoms()
  38. {
  39. return _rgGUIDAtom.GetPtr(0);
  40. }
  41. TfGuidAtom _GetAtom(int i)
  42. {
  43. return *_rgGUIDAtom.GetPtr(i);
  44. }
  45. BOOL _IsInCollection(REFGUID rguidProperty);
  46. private:
  47. typedef struct
  48. {
  49. ULONG uPriority;
  50. TfGuidAtom gaTip;
  51. } MARKUP_DATA;
  52. // these are parallel arrays
  53. // they aren't merged because we want to use CalcCicPropertyTrackerAnchors
  54. // which takes a flat array of TfGuidAtoms
  55. CStructArray<TfGuidAtom> _rgGUIDAtom;
  56. CStructArray<MARKUP_DATA> _rgOther;
  57. };
  58. //////////////////////////////////////////////////////////////////////////////
  59. //
  60. // CDispAttrGuidCache
  61. //
  62. //////////////////////////////////////////////////////////////////////////////
  63. class CDispAttrGuidCache
  64. {
  65. public:
  66. CDispAttrGuidCache() {}
  67. static void StaticUnInit();
  68. static void StaticInit();
  69. BOOL Add(REFCLSID clsid, REFGUID guid);
  70. void Remove(TfGuidAtom guidatom);
  71. void RemoveClsid(TfGuidAtom guidatom);
  72. BOOL Get(TfGuidAtom guidatom, DISPATTRGUID *pDisp);
  73. BOOL InternalGet(TfGuidAtom guidatom, DISPATTRGUID *pDisp);
  74. BOOL IsClsid(TfGuidAtom gaClsid);
  75. HRESULT Save();
  76. HRESULT Load();
  77. void Clear() {_rgDispAttrGuid.Clear(); Save();}
  78. private:
  79. CStructArray<DISPATTRGUID> _rgDispAttrGuid;
  80. };
  81. //////////////////////////////////////////////////////////////////////////////
  82. //
  83. // CDisplayAttributeMgr
  84. //
  85. //////////////////////////////////////////////////////////////////////////////
  86. typedef struct tagDAPROVIDERMAP {
  87. TfGuidAtom gaClsid;
  88. ITfDisplayAttributeProvider *pPrv;
  89. } DAPROVIDERMAP;
  90. class CDisplayAttributeMgr :
  91. public ITfDisplayAttributeMgr,
  92. public ITfDisplayAttributeCollectionMgr,
  93. public CComObjectRoot_CreateSingletonInstance<CDisplayAttributeMgr>
  94. {
  95. public:
  96. CDisplayAttributeMgr();
  97. ~CDisplayAttributeMgr();
  98. BEGIN_COM_MAP_IMMX(CDisplayAttributeMgr)
  99. COM_INTERFACE_ENTRY(ITfDisplayAttributeMgr)
  100. COM_INTERFACE_ENTRY(ITfDisplayAttributeCollectionMgr)
  101. COM_INTERFACE_ENTRY_IID(IID_CDisplayAttributeMgr, CDisplayAttributeMgr)
  102. END_COM_MAP_IMMX()
  103. //
  104. // ITfDisplayAttributeMgr
  105. //
  106. STDMETHODIMP OnUpdateInfo();
  107. STDMETHODIMP EnumDisplayAttributeInfo(IEnumTfDisplayAttributeInfo **ppEnum);
  108. STDMETHODIMP GetDisplayAttributeInfo(REFGUID guid, ITfDisplayAttributeInfo **ppInfo, CLSID *pclsid);
  109. // ITfDisplayAttributeCollectionMgr
  110. STDMETHODIMP EnumCollections(IEnumTfCollection **ppEnum);
  111. static HRESULT StaticRegisterProperty(REFGUID guidProp, WCHAR *pszName);
  112. CRenderMarkupCollection *_GetMarkupCollection()
  113. {
  114. return &_rgMarkupCollection;
  115. }
  116. static void _AdviseMarkupCollection(ITfTextInputProcessor *tip, TfGuidAtom gaTip)
  117. {
  118. CDisplayAttributeMgr *pDisplayAttrMgr;
  119. if (CDisplayAttributeMgr::CreateInstance(NULL, IID_CDisplayAttributeMgr, (void **)&pDisplayAttrMgr) != S_OK)
  120. return;
  121. pDisplayAttrMgr->_rgMarkupCollection._Advise(tip, gaTip);
  122. pDisplayAttrMgr->Release();
  123. }
  124. static void _UnadviseMarkupCollection(TfGuidAtom gaTip)
  125. {
  126. CDisplayAttributeMgr *pDisplayAttrMgr;
  127. if (CDisplayAttributeMgr::CreateInstance(NULL, IID_CDisplayAttributeMgr, (void **)&pDisplayAttrMgr) != S_OK)
  128. return;
  129. pDisplayAttrMgr->_rgMarkupCollection._Unadvise(gaTip);
  130. pDisplayAttrMgr->Release();
  131. }
  132. static BOOL _IsInCollection(REFGUID rguidProperty)
  133. {
  134. CDisplayAttributeMgr *pDisplayAttrMgr;
  135. BOOL fRet;
  136. if (CDisplayAttributeMgr::CreateInstance(NULL, IID_CDisplayAttributeMgr, (void **)&pDisplayAttrMgr) != S_OK)
  137. return FALSE;
  138. fRet = pDisplayAttrMgr->_rgMarkupCollection._IsInCollection(rguidProperty);
  139. pDisplayAttrMgr->Release();
  140. return fRet;
  141. }
  142. static CDisplayAttributeMgr *_GetThis()
  143. {
  144. SYSTHREAD *psfn = GetSYSTHREAD();
  145. if (!psfn)
  146. return NULL;
  147. return psfn->pdam;
  148. }
  149. private:
  150. static BOOL _SetThis(CDisplayAttributeMgr *_this)
  151. {
  152. SYSTHREAD *psfn = GetSYSTHREAD();
  153. if (!psfn)
  154. return FALSE;
  155. psfn->pdam = _this;
  156. return TRUE;
  157. }
  158. static HRESULT _RegisterGUID(const TCHAR *pszKey, REFGUID rguid, WCHAR *pszName, ULONG cchName);
  159. static HRESULT _UnregisterGUID(const TCHAR *pszKey, REFGUID rguid);
  160. CStructArray<DAPROVIDERMAP> _rgDaPrv;
  161. CRenderMarkupCollection _rgMarkupCollection;
  162. static BOOL EnumThreadProc(DWORD dwThread, DWORD dwProcessId, void *pv);
  163. DBG_ID_DECLARE;
  164. };
  165. //////////////////////////////////////////////////////////////////////////////
  166. //
  167. // CEnumDisplayAttributeInfo
  168. //
  169. //////////////////////////////////////////////////////////////////////////////
  170. class CEnumDisplayAttributeInfo : public IEnumTfDisplayAttributeInfo,
  171. public CEnumUnknown,
  172. public CComObjectRootImmx
  173. {
  174. public:
  175. CEnumDisplayAttributeInfo();
  176. BEGIN_COM_MAP_IMMX(CEnumDisplayAttributeInfo)
  177. COM_INTERFACE_ENTRY(IEnumTfDisplayAttributeInfo)
  178. END_COM_MAP_IMMX()
  179. IMMX_OBJECT_IUNKNOWN_FOR_ATL()
  180. DECLARE_SUNKA_ENUM(IEnumTfDisplayAttributeInfo, CEnumDisplayAttributeInfo, ITfDisplayAttributeInfo)
  181. BOOL Init();
  182. private:
  183. DBG_ID_DECLARE;
  184. };
  185. #endif //DAM_H