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.

199 lines
6.5 KiB

  1. /*************************************************************************
  2. * @doc SHROOM EXTERNAL API *
  3. * *
  4. * QUERYIMP.CPP *
  5. * *
  6. * Copyright (C) Microsoft Corporation 1997 *
  7. * All Rights reserved. *
  8. * *
  9. * This file contains the implementation of the index object *
  10. * *
  11. * *
  12. **************************************************************************
  13. * *
  14. * Written By : Erin Foxford *
  15. * Current Owner: erinfox *
  16. * *
  17. **************************************************************************/
  18. #include <atlinc.h>
  19. // MediaView (InfoTech) includes
  20. #include <mvopsys.h>
  21. #include <groups.h>
  22. #include <wwheel.h>
  23. #include <itquery.h>
  24. #include "queryimp.h"
  25. CITQuery::CITQuery() : m_dwFlags(0), m_wNear(8), m_pITGroup(NULL), m_cRows(0),
  26. m_lpszCommand(NULL)
  27. {
  28. m_pCommand = BlockInitiate((DWORD)65500, 0, 0, 0);
  29. MEMSET(&m_fcbkmsg, NULL, sizeof(FCALLBACK_MSG));
  30. }
  31. CITQuery::~CITQuery()
  32. {
  33. if (m_pCommand)
  34. BlockFree(m_pCommand);
  35. }
  36. /********************************************************************
  37. * @method STDMETHODIMP | IITQuery | SetResultCallback |
  38. * Sets callback structure containing ERR_FUNC MessageFunc member
  39. * that will be called periodically during query processing.
  40. *
  41. * @parm FCALLBACK_MSG* | pfcbkmsg | Pointer to callback structure.
  42. * @rvalue S_OK | The structure was successfully set.
  43. * @rvalue E_POINTER | pfcbkmsg was NULL
  44. * @rvalue E_BADPARAM | MessageFunc member of *pfcbkmsg was NULL.
  45. *
  46. ********************************************************************/
  47. STDMETHODIMP CITQuery::SetResultCallback(FCALLBACK_MSG *pfcbkmsg)
  48. {
  49. if (pfcbkmsg == NULL)
  50. return (E_POINTER);
  51. if (pfcbkmsg->MessageFunc == NULL)
  52. return (E_BADPARAM);
  53. m_fcbkmsg = *pfcbkmsg;
  54. return (S_OK);
  55. }
  56. /********************************************************************
  57. * @method STDMETHODIMP | IITQuery | SetCommand |
  58. * Sets full-text query to be used when Search method is called.
  59. *
  60. * @parm LPCWSTR | lpszwCommand | Command to carry out
  61. * @rvalue S_OK | The command was successfully set
  62. *
  63. ********************************************************************/
  64. STDMETHODIMP CITQuery::SetCommand(LPCWSTR lpszwCommand)
  65. {
  66. if (NULL == lpszwCommand)
  67. return E_INVALIDARG;
  68. if (m_pCommand)
  69. {
  70. BlockReset(m_pCommand);
  71. int cbData = (int) (2*(WSTRLEN(lpszwCommand)+1));
  72. if (NULL == (m_lpszCommand = (LPCWSTR) BlockCopy(m_pCommand, NULL, cbData, 0)))
  73. return E_OUTOFMEMORY;
  74. MEMCPY((LPVOID) m_lpszCommand, lpszwCommand, cbData);
  75. }
  76. else
  77. return E_OUTOFMEMORY; // something went wrong in ctor
  78. return S_OK;
  79. }
  80. /********************************************************************
  81. * @method STDMETHODIMP | IITQuery | SetOptions |
  82. * Sets options for searching
  83. *
  84. * @parm DWORD | dwFlag | Options, can be one or more of the following:
  85. *
  86. * @flag IMPLICIT_AND | Search terms are AND'd if no operator is specified
  87. * @flag IMPLICIT_OR | Search terms are OR'd if no operator is specified
  88. * @flag COMPOUNDWORD_PHRASE | Use PHRASE operator for compound words
  89. * @flag QUERYRESULT_RANK | Results are returned in ranked order
  90. * @flag QUERYRESULT_UIDSORT | Results are returned in UID order
  91. * @flag QUERYRESULT_SKIPOCCINFO | Only topic-level hit information is returned
  92. * @flag STEMMED_SEARCH | The search returns stemmed results
  93. * @flag RESULT_ASYNC | Results are returned asynchronously
  94. * @flag QUERY_GETTERMS | Return with each set of occurrence data a pointer to
  95. * the term string that the data is associated with.
  96. *
  97. * @rvalue S_OK | The options were successfully set
  98. *
  99. ********************************************************************/
  100. STDMETHODIMP CITQuery::SetOptions(DWORD dwFlags)
  101. {
  102. m_dwFlags = dwFlags;
  103. return S_OK;
  104. }
  105. /********************************************************************
  106. * @method STDMETHODIMP | IITQuery | SetProximity |
  107. * Sets proximity value for searching with NEAR operator.
  108. *
  109. * @parm WORD | wNear | The number of words apart the search terms can
  110. * be to be considered "near". Default value is 8.
  111. *
  112. * @rvalue S_OK | The proximity value was successfully set
  113. *
  114. ********************************************************************/
  115. STDMETHODIMP CITQuery::SetProximity(WORD wNear)
  116. {
  117. m_wNear = wNear;
  118. return S_OK;
  119. }
  120. /********************************************************************
  121. * @method STDMETHODIMP | IITQuery | SetGroup |
  122. * Sets group object to be used in filtering search results
  123. *
  124. * @parm IITGroup* | pITGroup | Pointer to group object
  125. *
  126. * @rvalue S_OK | The group object was successfully set
  127. * @comm If the existing query group is non-null, this method will
  128. * call Release() for the existing group before replacing it with the
  129. * new group object. The caller is responsible for calling AddRef before
  130. * setting the new group.
  131. ********************************************************************/
  132. STDMETHODIMP CITQuery::SetGroup(IITGroup* piitGrp)
  133. {
  134. if (m_pITGroup != NULL)
  135. m_pITGroup->Release();
  136. m_pITGroup = piitGrp;
  137. return S_OK;
  138. }
  139. /********************************************************************
  140. * @method STDMETHODIMP | IITQuery | SetResultCount |
  141. * Sets maximum number of search hits to return
  142. *
  143. * @parm LONG | cRows | Maxium number of hits
  144. *
  145. * @rvalue S_OK | The proximity value was successfully set
  146. *
  147. ********************************************************************/
  148. STDMETHODIMP CITQuery::SetResultCount(LONG cRows)
  149. {
  150. m_cRows = cRows;
  151. return S_OK;
  152. }
  153. /********************************************************************
  154. * @method STDMETHODIMP | IITQuery | ReInit |
  155. * Initializes query object to its default values
  156. *
  157. * @rvalue S_OK | The query object was successfully reinitialized
  158. *
  159. ********************************************************************/
  160. STDMETHODIMP CITQuery::ReInit()
  161. {
  162. m_dwFlags = 0;
  163. m_wNear = 8;
  164. m_cRows = 0; // I use this as number of hits, where 0 means all
  165. if (m_pCommand)
  166. BlockReset(m_pCommand);
  167. SetGroup(NULL);
  168. m_lpszCommand = NULL;
  169. return S_OK;
  170. }