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.

124 lines
3.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994
  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 <nullfilt.hxx>
  18. #include <txtifilt.hxx>
  19. #include <defbreak.hxx>
  20. #include <classf.hxx>
  21. #include <cicontrl.hxx>
  22. #include "classid.hxx"
  23. long gulcInstances = 0;
  24. //+-------------------------------------------------------------------------
  25. //
  26. // Function: DllGetClassObject
  27. //
  28. // Synopsis: Ole DLL load class routine
  29. //
  30. // Arguments: [cid] -- Class to load
  31. // [iid] -- Interface to bind to on class object
  32. // [ppvObj] -- Interface pointer returned here
  33. //
  34. // Returns: Text filter or a word breaker class factory
  35. //
  36. // History: 23-Feb-1994 KyleP Created
  37. //
  38. //--------------------------------------------------------------------------
  39. extern "C" SCODE STDMETHODCALLTYPE DllGetClassObject( REFCLSID cid,
  40. REFIID iid,
  41. void ** ppvObj )
  42. {
  43. IUnknown * pResult;
  44. SCODE sc = S_OK;
  45. TRY
  46. {
  47. if ( CLSID_CTextIFilter == cid || CLSID_CTextClass == cid ) {
  48. pResult = (IUnknown *)new CTextIFilterCF;
  49. } else if ( CLSID_CNullIFilter == cid ) {
  50. pResult = (IUnknown *)new CNullIFilterCF;
  51. } else if ( CLSID_Neutral_WBreaker == cid ) {
  52. pResult = (IUnknown *)new CDefWordBreakerCF;
  53. } else if ( guidStorageFilterObject == cid) {
  54. pResult = (IUnknown *) new CStorageFilterObjectCF;
  55. } else if ( guidStorageDocStoreLocatorObject == cid) {
  56. pResult = (IUnknown *) new CStorageDocStoreLocatorObjectCF;
  57. } else if ( clsidCiControl == cid) {
  58. pResult = (IUnknown *) new CCiControlObjectCF;
  59. } else {
  60. ciDebugOut(( DEB_ITRACE, "DllGetClassObject: no such interface found\n" ));
  61. pResult = 0;
  62. sc = E_NOINTERFACE;
  63. }
  64. }
  65. CATCH(CException, e)
  66. {
  67. switch( e.GetErrorCode() )
  68. {
  69. case E_OUTOFMEMORY:
  70. sc = (E_OUTOFMEMORY);
  71. break;
  72. default:
  73. sc = (E_UNEXPECTED);
  74. }
  75. }
  76. END_CATCH;
  77. if (0 != pResult) {
  78. sc = pResult->QueryInterface( iid, ppvObj );
  79. pResult->Release( );
  80. }
  81. return (sc);
  82. }
  83. //+-------------------------------------------------------------------------
  84. //
  85. // Method: DllCanUnloadNow
  86. //
  87. // Synopsis: Notifies DLL to unload (cleanup global resources)
  88. //
  89. // Returns: S_OK if it is acceptable for caller to unload DLL.
  90. //
  91. // History: 23-Feb-1994 KyleP Created
  92. //
  93. //--------------------------------------------------------------------------
  94. extern "C" SCODE STDMETHODCALLTYPE DllCanUnloadNow( void )
  95. {
  96. if ( gulcInstances <= 0 )
  97. return( S_OK );
  98. else
  99. return( S_FALSE );
  100. }