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.

182 lines
5.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1998
  5. //
  6. // File: exports.cxx
  7. //
  8. // Contents: Code to export filter and word breaker class factories
  9. //
  10. // History: 15-Aug-1994 SitaramR Created
  11. //
  12. // Notes: Copied from txtifilt.hxx and then modified
  13. //
  14. //--------------------------------------------------------------------------
  15. #include <pch.cxx>
  16. #pragma hdrstop
  17. #include <classf.hxx>
  18. #include <vquery.hxx>
  19. #include <ciintf.h>
  20. #include <opendoc.hxx>
  21. #include <ilangres.hxx>
  22. static const GUID clsidISearchCreator = CLSID_ISearchCreator;
  23. //+-------------------------------------------------------------------------
  24. //
  25. // Function: DllGetClassObject
  26. //
  27. // Synopsis: Ole DLL load class routine
  28. //
  29. // Arguments: [cid] -- Class to load
  30. // [iid] -- Interface to bind to on class object
  31. // [ppvObj] -- Interface pointer returned here
  32. //
  33. // Returns: Text filter or a word breaker class factory
  34. //
  35. // History: 23-Feb-1994 KyleP Created
  36. //
  37. //--------------------------------------------------------------------------
  38. extern "C" SCODE STDMETHODCALLTYPE FsciDllGetClassObject(
  39. REFCLSID cid,
  40. REFIID iid,
  41. void ** ppvObj )
  42. {
  43. IUnknown * pResult;
  44. SCODE sc = S_OK;
  45. TRY
  46. {
  47. if ( guidStorageFilterObject == cid)
  48. pResult = (IUnknown *) new CStorageFilterObjectCF;
  49. else if ( guidStorageDocStoreLocatorObject == cid)
  50. pResult = (IUnknown *) new CStorageDocStoreLocatorObjectCF;
  51. else
  52. {
  53. ciDebugOut(( DEB_ITRACE, "DllGetClassObject: no such interface found\n" ));
  54. pResult = 0;
  55. sc = E_NOINTERFACE;
  56. }
  57. }
  58. CATCH(CException, e)
  59. {
  60. switch( e.GetErrorCode() )
  61. {
  62. case E_OUTOFMEMORY:
  63. sc = (E_OUTOFMEMORY);
  64. break;
  65. default:
  66. sc = (E_UNEXPECTED);
  67. }
  68. }
  69. END_CATCH;
  70. if (0 != pResult)
  71. {
  72. sc = pResult->QueryInterface( iid, ppvObj );
  73. pResult->Release();
  74. }
  75. return sc;
  76. }
  77. //+---------------------------------------------------------------------------
  78. //
  79. // Function: MakeISearch
  80. //
  81. // Synopsis: Creates an ISearch interface for highlighting the given
  82. // document.
  83. //
  84. // Arguments: [ppSearch] - [out] Will have the ISearch interface pointer.
  85. // [pRst] - [in] The restriction to apply
  86. // [pwszPath] - [in] The path of the document
  87. //
  88. // History: 2-26-97 srikants Created
  89. //
  90. //----------------------------------------------------------------------------
  91. SCODE MakeISearch(
  92. ISearchQueryHits ** ppSearch,
  93. CDbRestriction * pRst,
  94. WCHAR const * pwszPath )
  95. {
  96. // intentional access violation on bogus params
  97. *ppSearch = 0;
  98. SCODE sc = S_OK;
  99. TRANSLATE_EXCEPTIONS;
  100. TRY
  101. {
  102. //
  103. // Create the language resources.
  104. //
  105. XInterface<CLanguageResourceInterface> xLangRes( new CLanguageResourceInterface );
  106. XInterface<ICiCLangRes> xICiCLangRes;
  107. SCODE sc = xLangRes->QueryInterface( IID_ICiCLangRes,
  108. xICiCLangRes.GetQIPointer() );
  109. if ( FAILED(sc) )
  110. THROW(CException(sc));
  111. //
  112. // Create the OpenDocument.
  113. //
  114. XInterface<ICiCOpenedDoc> xOpenDoc;
  115. if ( 0 != pwszPath )
  116. {
  117. xOpenDoc.Set( new CCiCOpenedDoc( 0, 0, FALSE, FALSE ) );
  118. sc = xOpenDoc->Open( (BYTE *) pwszPath,
  119. ( 1 + wcslen(pwszPath) ) * sizeof WCHAR );
  120. if ( FAILED(sc) )
  121. THROW( CException( sc ) );
  122. }
  123. XInterface<ICiISearchCreator> xSearchCreator;
  124. sc = CoCreateInstance( clsidISearchCreator,
  125. NULL,
  126. CLSCTX_INPROC_SERVER,
  127. IID_ICiISearchCreator,
  128. xSearchCreator.GetQIPointer() );
  129. if ( FAILED(sc) )
  130. THROW( CException(sc) );
  131. sc = xSearchCreator->CreateISearch( pRst->CastToStruct(),
  132. xICiCLangRes.GetPointer(),
  133. xOpenDoc.GetPointer(),
  134. ppSearch );
  135. if ( FAILED(sc) )
  136. THROW( CException(sc) );
  137. }
  138. CATCH ( CException, e )
  139. {
  140. //
  141. // MakeISearch clients must be smart and able to handle real
  142. // errors that actually happen. It's not OLE DB.
  143. //
  144. sc = GetScodeError( e );
  145. vqDebugOut(( DEB_ERROR,
  146. "MakeISearch error 0x%x => 0x%x\n",
  147. e.GetErrorCode(),
  148. sc ));
  149. }
  150. END_CATCH;
  151. UNTRANSLATE_EXCEPTIONS;
  152. return sc;
  153. } //MakeISearch