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.

479 lines
13 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) Microsoft Corporation, 1996 - 2000.
  4. //
  5. // File: ixsso.hxx
  6. //
  7. // Contents: Query SSO class
  8. //
  9. // History: 29 Oct 1996 Alanw Created
  10. //
  11. //----------------------------------------------------------------------------
  12. #pragma once
  13. //-----------------------------------------------------------------------------
  14. // Include Files
  15. //-----------------------------------------------------------------------------
  16. // Query object interface declarations
  17. #include "ixssoifc.h"
  18. #include "ixserror.hxx"
  19. #include <ciintf.h>
  20. #include <tgrow.hxx>
  21. enum EOptimizeFor {
  22. eOptNone = 0,
  23. eOptPerformance = 1,
  24. eOptRecall = 2,
  25. eOptHitCount = 4,
  26. // eOptPrecision,
  27. };
  28. extern const WCHAR * pwcDefaultDialect;
  29. //
  30. // Private interface definition for use by CixssoUtil.
  31. //
  32. const IID IID_IixssoQueryPrivate = {0x9357bd10,0x2b6f,0x11d0,{0xbf,0xbc,0x00,0x20,0xf8,0x00,0x80,0x24}};
  33. interface DECLSPEC_UUID("9357bd10-2b6f-11d0-bfbc-0020f8008024")
  34. IixssoQueryPrivate : public IixssoQueryEx
  35. {
  36. public:
  37. virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE AddScopeToQuery(
  38. /* [in] */ BSTR pwszScope,
  39. /* [optional][in] */ BSTR pwszDepth) = 0;
  40. };
  41. class CIXSSOPropertyList : public IColumnMapper
  42. {
  43. public:
  44. CIXSSOPropertyList(ULONG ulCodePage = CP_ACP);
  45. void SetDefaultList(IColumnMapper *pDefaultList);
  46. //
  47. // IUnknown methods.
  48. //
  49. STDMETHOD(QueryInterface) (THIS_ REFIID riid, void ** ppvObj);
  50. STDMETHOD_(ULONG, AddRef) (THIS);
  51. STDMETHOD_(ULONG, Release) (THIS);
  52. //
  53. // IColumnMapper methods
  54. //
  55. STDMETHOD(GetPropInfoFromName) (
  56. const WCHAR *wcsPropName,
  57. DBID * *ppPropId,
  58. DBTYPE *pPropType,
  59. unsigned int *puiWidth);
  60. STDMETHOD(GetPropInfoFromId) (
  61. const DBID *pPropId,
  62. WCHAR * *pwcsName,
  63. DBTYPE *pPropType,
  64. unsigned int *puiWidth);
  65. STDMETHOD(EnumPropInfo) (
  66. ULONG iEntry,
  67. const WCHAR * *pwcsName,
  68. DBID * *ppPropId,
  69. DBTYPE *pPropType,
  70. unsigned int *puiWidth);
  71. STDMETHOD(IsMapUpToDate)();
  72. // local methods
  73. SCODE AddEntry( XPtr<CPropEntry> & xPropEntry, int iLine );
  74. private:
  75. XInterface<IColumnMapper> _xDefaultList;
  76. XInterface<CPropertyList> _xOverrideList;
  77. LONG _cRefs; // ref counting
  78. CMutexSem _mtxAdd; // serialize access to AddEntry
  79. ULONG _ulCodePage; // codepage
  80. };
  81. //-----------------------------------------------------------------------------
  82. // CixssoQuery Declaration
  83. //-----------------------------------------------------------------------------
  84. class CixssoQuery : public IixssoQueryPrivate,
  85. public ISupportErrorInfo,
  86. public IObjectWithSite
  87. #if 0
  88. ,public IObjectSafety
  89. #endif
  90. {
  91. friend class CIxssoQueryCF;
  92. friend class CNLssoQueryCF;
  93. public:
  94. // IUnknown methods
  95. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj);
  96. STDMETHOD_(ULONG, AddRef)(THIS);
  97. STDMETHOD_(ULONG, Release)(THIS);
  98. // IDispatch methods
  99. STDMETHOD(GetTypeInfoCount)(THIS_ UINT * pctinfo);
  100. STDMETHOD(GetTypeInfo)( THIS_
  101. UINT itinfo,
  102. LCID lcid,
  103. ITypeInfo * * pptinfo);
  104. STDMETHOD(GetIDsOfNames)( THIS_
  105. REFIID riid,
  106. OLECHAR * * rgszNames,
  107. UINT cNames,
  108. LCID lcid,
  109. DISPID * rgdispid);
  110. STDMETHOD(Invoke)( THIS_
  111. DISPID dispidMember,
  112. REFIID riid,
  113. LCID lcid,
  114. WORD wFlags,
  115. DISPPARAMS * pdispparams,
  116. VARIANT * pvarResult,
  117. EXCEPINFO * pexcepinfo,
  118. UINT * puArgErr);
  119. // ISupportErrorInfo method
  120. STDMETHOD(InterfaceSupportsErrorInfo)( THIS_
  121. REFIID riid);
  122. //
  123. // IixssoQuery property get/put methods
  124. //
  125. HRESULT STDMETHODCALLTYPE get_Query(
  126. /* [retval][out] */ BSTR *val);
  127. HRESULT STDMETHODCALLTYPE put_Query(
  128. /* [in] */ BSTR val);
  129. HRESULT STDMETHODCALLTYPE get_CiScope(
  130. /* [retval][out] */ BSTR *val);
  131. HRESULT STDMETHODCALLTYPE put_CiScope(
  132. /* [in] */ BSTR val);
  133. HRESULT STDMETHODCALLTYPE get_SortBy(
  134. /* [retval][out] */ BSTR *val);
  135. HRESULT STDMETHODCALLTYPE put_SortBy(
  136. /* [in] */ BSTR val);
  137. HRESULT STDMETHODCALLTYPE get_GroupBy(
  138. /* [retval][out] */ BSTR *val);
  139. HRESULT STDMETHODCALLTYPE put_GroupBy(
  140. /* [in] */ BSTR val);
  141. HRESULT STDMETHODCALLTYPE get_CiFlags(
  142. /* [retval][out] */ BSTR *val);
  143. HRESULT STDMETHODCALLTYPE put_CiFlags(
  144. /* [in] */ BSTR val);
  145. HRESULT STDMETHODCALLTYPE get_Columns(
  146. /* [retval][out] */ BSTR *val);
  147. HRESULT STDMETHODCALLTYPE put_Columns(
  148. /* [in] */ BSTR val);
  149. HRESULT STDMETHODCALLTYPE get_LocaleID(
  150. /* [retval][out] */ LONG *val);
  151. HRESULT STDMETHODCALLTYPE put_LocaleID(
  152. /* [in] */ LONG val);
  153. HRESULT STDMETHODCALLTYPE get_CodePage(
  154. /* [retval][out] */ LONG *val);
  155. HRESULT STDMETHODCALLTYPE put_CodePage(
  156. /* [in] */ LONG val);
  157. HRESULT STDMETHODCALLTYPE get_Catalog(
  158. /* [retval][out] */ BSTR *val);
  159. HRESULT STDMETHODCALLTYPE put_Catalog(
  160. /* [in] */ BSTR val);
  161. HRESULT STDMETHODCALLTYPE get_Dialect(
  162. /* [retval][out] */ BSTR *val);
  163. HRESULT STDMETHODCALLTYPE put_Dialect(
  164. /* [in] */ BSTR val);
  165. HRESULT STDMETHODCALLTYPE get_OptimizeFor(
  166. /* [retval][out] */ BSTR *val);
  167. HRESULT STDMETHODCALLTYPE put_OptimizeFor(
  168. /* [in] */ BSTR val);
  169. HRESULT STDMETHODCALLTYPE get_AllowEnumeration(
  170. /* [retval][out] */ VARIANT_BOOL *val);
  171. HRESULT STDMETHODCALLTYPE put_AllowEnumeration(
  172. /* [in] */ VARIANT_BOOL val);
  173. HRESULT STDMETHODCALLTYPE get_MaxRecords(
  174. /* [retval][out] */ LONG *val);
  175. HRESULT STDMETHODCALLTYPE put_MaxRecords(
  176. /* [in] */ LONG val);
  177. HRESULT STDMETHODCALLTYPE get_StartHit(
  178. /* [retval][out] */ VARIANT * pvar);
  179. HRESULT STDMETHODCALLTYPE put_StartHit(
  180. /* [in] */ VARIANT * pvar);
  181. HRESULT STDMETHODCALLTYPE get_ResourceUseFactor(
  182. /* [retval][out] */ LONG *val);
  183. HRESULT STDMETHODCALLTYPE put_ResourceUseFactor(
  184. /* [in] */ LONG val);
  185. HRESULT STDMETHODCALLTYPE get_QueryTimedOut(
  186. /* [retval][out] */ VARIANT_BOOL *val);
  187. HRESULT STDMETHODCALLTYPE get_QueryIncomplete(
  188. /* [retval][out] */ VARIANT_BOOL *val);
  189. HRESULT STDMETHODCALLTYPE get_OutOfDate(
  190. /* [retval][out] */ VARIANT_BOOL *val);
  191. //
  192. // IixssoQueryEx methods
  193. //
  194. HRESULT STDMETHODCALLTYPE get_FirstRows(
  195. /* [retval][out] */ LONG *val);
  196. HRESULT STDMETHODCALLTYPE put_FirstRows(
  197. /* [in] */ LONG val);
  198. //
  199. // IixssoQuery methods
  200. //
  201. HRESULT STDMETHODCALLTYPE SetQueryFromURL(
  202. /* [in] */ BSTR pwszQuery);
  203. HRESULT STDMETHODCALLTYPE QueryToURL(
  204. /* [retval][out] */ BSTR * ppwszQuery);
  205. HRESULT STDMETHODCALLTYPE AddScopeToQuery(
  206. /* [in] */ BSTR pwszScope,
  207. /* [in] */ BSTR pwszDepth);
  208. HRESULT STDMETHODCALLTYPE DefineColumn(
  209. /* [in] */ BSTR pwszColDefinition);
  210. HRESULT STDMETHODCALLTYPE CreateRecordset(
  211. /* [in] */ BSTR pwszSequential,
  212. /* [retval][out] */ IDispatch **ppDisp);
  213. HRESULT STDMETHODCALLTYPE Reset( void );
  214. //
  215. // ASP standard methods
  216. //
  217. HRESULT STDMETHODCALLTYPE OnStartPage( IUnknown * pUnk );
  218. HRESULT STDMETHODCALLTYPE OnEndPage( void );
  219. #if 0
  220. //
  221. // IObjectSafety methods
  222. //
  223. HRESULT STDMETHODCALLTYPE GetInterfaceSafetyOptions(
  224. REFIID riid,
  225. DWORD * pdwSupportedOptions,
  226. DWORD * pdwEnabledOptions );
  227. HRESULT STDMETHODCALLTYPE SetInterfaceSafetyOptions(
  228. REFIID riid,
  229. DWORD dwOptionSetMask,
  230. DWORD dwEnabledOptions );
  231. #endif
  232. //
  233. // IObjectWithSite methods
  234. //
  235. HRESULT STDMETHODCALLTYPE SetSite( IUnknown * pSite );
  236. HRESULT STDMETHODCALLTYPE GetSite( REFIID riid, void ** ppvSite );
  237. private:
  238. CixssoQuery( ITypeLib * pitlb,
  239. IClassFactory * pIAdoRecordsetCF,
  240. BOOL fAdoV1_5,
  241. const CLSID & ssoClsid );
  242. ~CixssoQuery();
  243. // Local methods
  244. void SetError( SCODE sc,
  245. const WCHAR * loc = 0,
  246. unsigned eErrClass = 0
  247. )
  248. {
  249. _err.SetError( sc, 0, 0, loc, eErrClass, _lcid );
  250. }
  251. void SetError( SCODE sc,
  252. const WCHAR * pwszLoc,
  253. const WCHAR * pwszDescription
  254. )
  255. {
  256. _err.SetError( sc, pwszLoc, pwszDescription );
  257. }
  258. void SetErrorWithFile( SCODE sc,
  259. ULONG iLine,
  260. const WCHAR * pwszFile,
  261. const WCHAR * loc = 0,
  262. unsigned eErrClass = 0
  263. )
  264. {
  265. _err.SetError( sc, iLine, pwszFile, loc, eErrClass, _lcid );
  266. }
  267. void ExecuteQuery( void );
  268. void IsSafeForScripting();
  269. void GetDefaultCatalog( void );
  270. LCID GetLCID() const { return _lcid; }
  271. IColumnMapper * GetColumnMapper( )
  272. { return &_PropertyList; }
  273. DWORD GetQueryStatus( );
  274. BOOL IsAVirtualPath( WCHAR * wcsPath );
  275. BOOL IsSequential( void )
  276. { return _fSequential; }
  277. BOOL IsQueryActive( void )
  278. { return _pIRowset != 0; }
  279. SCODE ParseOptimizeFor( WCHAR const * wcsOptString,
  280. DWORD & eChoice );
  281. ULONG ParseCiDepthFlag( BSTR bstrFlags );
  282. ULONG GetDialect();
  283. SCODE SetLocaleString(BSTR str);
  284. // Property get/put helpers
  285. SCODE CopyWstrToBstr( BSTR * pbstr, WCHAR const * pwstr );
  286. SCODE CopyBstrToWstr( BSTR bstr, LPWSTR & pwstr );
  287. SCODE CopyBstrToWstrArray( BSTR bstr,
  288. CDynArray<WCHAR> &apstr,
  289. unsigned i );
  290. SCODE GetBoolProperty( VARIANT_BOOL * pfVal, BOOL fMemberVal );
  291. SCODE PutBoolProperty( VARIANT_BOOL fInputVal, BOOL & fMemberVal );
  292. SCODE CheckQueryStatusBit( VARIANT_BOOL * pfVal, DWORD dwBit );
  293. ULONG _cRef;
  294. CixssoError _err;
  295. IClassFactory * _pIAdoRecordsetCF;
  296. BOOL _fAdoV15;
  297. IRowset * _pIRowset;
  298. IRowsetQueryStatus * _pIRowsetQueryStatus;
  299. BOOL _fSequential; // TRUE if query is sequential
  300. // Settable parameters
  301. LCID _lcid; // Locale ID used for this query
  302. ULONG _ulCodepage; // Codepage used for this query
  303. XInterface<IUnknown> _xSite; // site loading the object
  304. WCHAR * _pwszRestriction; // Query
  305. WCHAR * _pwszSort; // SortBy
  306. WCHAR * _pwszGroup; // GroupBy
  307. WCHAR * _pwszColumns; // Columns
  308. WCHAR * _pwszCatalog; // Catalog
  309. WCHAR * _pwszDialect; // Query Dialect
  310. // Scope related parameters
  311. unsigned _cScopes; // number of active scopes
  312. CDynArray<WCHAR> _apwszScope; // CiScope
  313. CDynArrayInPlace<ULONG> _aulDepth; // CiFlags, DEEP/SHALLOW
  314. BOOL _fAllowEnumeration;
  315. DWORD _dwOptimizeFlags;
  316. LONG _maxResults; // total number of results
  317. LONG _cFirstRows;
  318. LONG _iResourceFactor; // resource use factor
  319. XSafeArray _StartHit; // starting hit(s) in results
  320. ITypeInfo * _ptinfo; // Type info from type lib
  321. // Command creator for this instance
  322. XInterface<ISimpleCommandCreator> _xCmdCreator; // points to cmd creator
  323. CIXSSOPropertyList _PropertyList; // Property list
  324. };
  325. // Global variables.
  326. class CTheGlobalIXSSOVariables;
  327. extern CTheGlobalIXSSOVariables * g_pTheGlobalIXSSOVariables;
  328. class CTheGlobalIXSSOVariables
  329. {
  330. public:
  331. CTheGlobalIXSSOVariables();
  332. ~CTheGlobalIXSSOVariables()
  333. {
  334. VariantClear(&_vtAcceptLanguageHeader);
  335. }
  336. VARIANT _vtAcceptLanguageHeader;
  337. XInterface<ISimpleCommandCreator> xCmdCreator;
  338. XInterface<IColumnMapperCreator> xColumnMapperCreator;
  339. };
  340. #define TheGlobalIXSSOVariables (*g_pTheGlobalIXSSOVariables)
  341. #define g_vtAcceptLanguageHeader TheGlobalIXSSOVariables._vtAcceptLanguageHeader
  342. void ParseNumberVectorString( WCHAR * pwszValue, CDynArrayInPlace<LONG> & aNum );
  343. void FormatLongVector( SAFEARRAY * psa, XGrowable<WCHAR> & awchBuf );