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.

193 lines
4.0 KiB

  1. // MSAAStore.h : Declaration of the CAccStore
  2. #ifndef __MSAASTORE_H_
  3. #define __MSAASTORE_H_
  4. #include "resource.h" // main symbols
  5. #include <list>
  6. #if ! defined( _BASETSD_H_ ) || defined( NEED_BASETSD_DEFINES )
  7. // These allow us to compile with the pre-Win64 SDK (eg. using visual studio)
  8. typedef unsigned long UINT_PTR;
  9. typedef DWORD DWORD_PTR;
  10. typedef BOOL BOOL_PTR;
  11. #define PtrToInt (int)
  12. #else
  13. typedef INT_PTR BOOL_PTR;
  14. #endif
  15. struct DocInfo
  16. {
  17. DocInfo(IUnknown * pCanonicalUnk, ITextStoreAnchor * pDoc, IClonableWrapper * pClonableWrapper) :
  18. m_pCanonicalUnk(pCanonicalUnk), m_pDoc(pDoc), m_pClonableWrapper(pClonableWrapper)
  19. {
  20. if ( FAILED( m_pDoc->GetWnd( NULL, &m_hWnd ) ) )
  21. m_hWnd = NULL;
  22. }
  23. ~DocInfo()
  24. {
  25. if (m_pCanonicalUnk)
  26. m_pCanonicalUnk->Release();
  27. if (m_pDoc)
  28. m_pDoc->Release();
  29. if (m_pClonableWrapper)
  30. m_pClonableWrapper->Release();
  31. }
  32. struct predCanonicalUnk
  33. {
  34. predCanonicalUnk (const IUnknown *& punk) : m_punk(punk) { }
  35. bool operator ()(const DocInfo* d)
  36. {
  37. return d->m_pCanonicalUnk == m_punk;
  38. };
  39. const IUnknown *& m_punk;
  40. };
  41. struct predHWND
  42. {
  43. predHWND (const HWND &hwnd ) : m_hWnd(hwnd) { }
  44. bool operator ()(const DocInfo* d)
  45. {
  46. if( m_hWnd == d->m_hWnd )
  47. return true;
  48. else
  49. return false;
  50. }
  51. const HWND &m_hWnd;
  52. };
  53. IUnknown * m_pCanonicalUnk;
  54. ITextStoreAnchor * m_pDoc;
  55. IClonableWrapper * m_pClonableWrapper;
  56. HWND m_hWnd;
  57. };
  58. typedef std::list< DocInfo * > DocList;
  59. // this is my own copy class so I don't have to duplicate the list
  60. template <class T>
  61. class CopyDocs
  62. {
  63. public:
  64. static HRESULT copy(T** p1, DocInfo** p2)
  65. {
  66. *p1 = static_cast<T *>((*p2)->m_pDoc);
  67. if (*p1)
  68. (*p1)->AddRef();
  69. TraceDebug(TEXT("copy"));
  70. return S_OK;
  71. }
  72. static void init(T** )
  73. {
  74. TraceDebug(TEXT("init"));
  75. }
  76. static void destroy(T** p)
  77. {
  78. if (*p) (*p)->Release();
  79. TraceDebug(TEXT("destroy"));
  80. }
  81. };
  82. typedef CComObject< CComEnumOnSTL< IEnumUnknown, &IID_IEnumUnknown, IUnknown *, CopyDocs<IUnknown>, DocList > > EnumDocs;
  83. template <class T>
  84. class CComDllClassFactorySingleton : public CComClassFactorySingleton<T>
  85. {
  86. public :
  87. void FinalRelease()
  88. {
  89. }
  90. };
  91. /////////////////////////////////////////////////////////////////////////////
  92. // CAccStore
  93. class ATL_NO_VTABLE CAccStore :
  94. public CComObjectRootEx<CComSingleThreadModel>,
  95. public CComCoClass<CAccStore, &CLSID_AccStore>,
  96. public IAccStore
  97. {
  98. public:
  99. CAccStore();
  100. ~CAccStore();
  101. DECLARE_CLASSFACTORY_EX(CComDllClassFactorySingleton<CAccStore>)
  102. DECLARE_REGISTRY_RESOURCEID(IDR_MSAASTORE)
  103. DECLARE_PROTECT_FINAL_CONSTRUCT()
  104. BEGIN_COM_MAP(CAccStore)
  105. COM_INTERFACE_ENTRY(IAccStore)
  106. END_COM_MAP()
  107. // IAccStore
  108. public:
  109. HRESULT STDMETHODCALLTYPE Register (
  110. REFIID riid,
  111. IUnknown * punk
  112. );
  113. HRESULT STDMETHODCALLTYPE Unregister (
  114. IUnknown * punk
  115. );
  116. HRESULT STDMETHODCALLTYPE GetDocuments (
  117. IEnumUnknown ** enumUnknown
  118. );
  119. HRESULT STDMETHODCALLTYPE LookupByHWND (
  120. HWND hWnd,
  121. REFIID riid,
  122. IUnknown ** ppunk
  123. );
  124. HRESULT STDMETHODCALLTYPE LookupByPoint (
  125. POINT pt,
  126. REFIID riid,
  127. IUnknown ** ppunk
  128. );
  129. HRESULT STDMETHODCALLTYPE OnDocumentFocus (
  130. IUnknown * punk
  131. );
  132. HRESULT STDMETHODCALLTYPE GetFocused (
  133. REFIID riid,
  134. IUnknown ** ppunk
  135. );
  136. BOOL_PTR DialogProc ( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  137. private:
  138. HWND m_hwndDlg;
  139. HWND m_hList;
  140. DocList m_DocList;
  141. #ifdef DBG
  142. bool m_ShowDialog;
  143. #endif
  144. HANDLE m_hInit;
  145. IUnknown * m_punkFocused;
  146. ITfMSAAControl * m_pCtl;
  147. void DumpInfo( DocInfo * pInfo );
  148. void DumpInfo();
  149. DocInfo * _LookupDoc( IUnknown * pCanonicalUnk );
  150. DocInfo * _LookupDoc( HWND hWnd );
  151. DocInfo * _LookupDoc( POINT pt );
  152. void EraseDeadDocuments();
  153. void Log( LPCTSTR text );
  154. };
  155. #endif //__MSAASTORE_H_