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.

157 lines
4.6 KiB

  1. // convert.h : header file
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12. #ifdef CONVERTERS
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CConverter
  15. typedef int (CALLBACK *LPFNOUT)(int cch, int nPercentComplete);
  16. typedef int (CALLBACK *LPFNIN)(int flags, int nPercentComplete);
  17. typedef BOOL (FAR PASCAL *PINITCONVERTER)(HWND hWnd, LPCSTR lpszModuleName);
  18. typedef BOOL (FAR PASCAL *PISFORMATCORRECT)(HANDLE ghszFile, HANDLE ghszClass);
  19. typedef int (FAR PASCAL *PFOREIGNTORTF)(HANDLE ghszFile, LPVOID lpv, HANDLE ghBuff,
  20. HANDLE ghszClass, HANDLE ghszSubset, LPFNOUT lpfnOut);
  21. typedef int (FAR PASCAL *PRTFTOFOREIGN)(HANDLE ghszFile, LPVOID lpv, HANDLE ghBuff,
  22. HANDLE ghszClass, LPFNIN lpfnIn);
  23. typedef HGLOBAL (FAR PASCAL *PREGISTERAPP)(long lFlags, void *lpRegApp);
  24. //
  25. // Some defines taken from the converter group's convapi.h
  26. //
  27. #define fRegAppSupportNonOem 0x00000008 // supports non-Oem filenames
  28. #define RegAppOpcodeCharset 0x03 // for REGAPPRET
  29. #endif
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CTrackFile
  32. class CTrackFile : public CFile
  33. {
  34. public:
  35. //Construction
  36. CTrackFile(CFrameWnd* pWnd);
  37. ~CTrackFile();
  38. //Attributes
  39. int m_nLastPercent;
  40. DWORD m_dwLength;
  41. CFrameWnd* m_pFrameWnd;
  42. CString m_strComplete;
  43. CString m_strWait;
  44. CString m_strSaving;
  45. //Operations
  46. void OutputPercent(int nPercentComplete = 0);
  47. void OutputString(LPCTSTR lpsz);
  48. virtual UINT Read(void FAR* lpBuf, UINT nCount);
  49. virtual void Write(const void FAR* lpBuf, UINT nCount);
  50. };
  51. class COEMFile : public CTrackFile
  52. {
  53. public:
  54. COEMFile(CFrameWnd* pWnd);
  55. virtual UINT Read(void FAR* lpBuf, UINT nCount);
  56. virtual void Write(const void FAR* lpBuf, UINT nCount);
  57. };
  58. #ifdef CONVERTERS
  59. class CConverter : public CTrackFile
  60. {
  61. public:
  62. CConverter(LPCTSTR pszLibName, CFrameWnd* pWnd = NULL);
  63. public:
  64. //Attributes
  65. int m_nPercent;
  66. BOOL m_bDone;
  67. BOOL m_bConvErr;
  68. virtual DWORD GetPosition() const;
  69. // Operations
  70. BOOL IsFormatCorrect(LPCTSTR pszFileName);
  71. BOOL DoConversion();
  72. virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags,
  73. CFileException* pError = NULL);
  74. void WaitForConverter();
  75. void WaitForBuffer();
  76. // Overridables
  77. virtual LONG Seek(LONG lOff, UINT nFrom);
  78. virtual DWORD GetLength() const;
  79. virtual UINT Read(void* lpBuf, UINT nCount);
  80. virtual void Write(const void* lpBuf, UINT nCount);
  81. virtual void Abort();
  82. virtual void Flush();
  83. virtual void Close();
  84. // Unsupported
  85. virtual CFile* Duplicate() const;
  86. virtual void LockRange(DWORD dwPos, DWORD dwCount);
  87. virtual void UnlockRange(DWORD dwPos, DWORD dwCount);
  88. virtual void SetLength(DWORD dwNewLen);
  89. //Implementation
  90. public:
  91. ~CConverter();
  92. protected:
  93. int m_nBytesAvail;
  94. int m_nBytesWritten;
  95. HANDLE m_hEventFile;
  96. HANDLE m_hEventConv;
  97. BOOL m_bForeignToRtf; // True to convert to RTF, else from
  98. HGLOBAL m_hBuff; // Buffer for converter data
  99. BYTE* m_pBuf; // Pointer to m_hBuff data
  100. HGLOBAL m_hFileName; // File to convert
  101. HINSTANCE m_hLibCnv; // The converter dll
  102. BOOL m_bUseOEM; // TRUE to use OEM filenames
  103. // Entry points into the converter dll
  104. PINITCONVERTER m_pInitConverter;
  105. PISFORMATCORRECT m_pIsFormatCorrect;
  106. PFOREIGNTORTF m_pForeignToRtf;
  107. PRTFTOFOREIGN m_pRtfToForeign;
  108. PREGISTERAPP m_pRegisterApp;
  109. int CALLBACK WriteOut(int cch, int nPercentComplete);
  110. int CALLBACK ReadIn(int nPercentComplete);
  111. static HGLOBAL StringToHGLOBAL(LPCSTR pstr);
  112. static int CALLBACK WriteOutStatic(int cch, int nPercentComplete);
  113. static int CALLBACK ReadInStatic(int flags, int nPercentComplete);
  114. static UINT AFX_CDECL ConverterThread(LPVOID pParam);
  115. static CConverter *m_pThis;
  116. void LoadFunctions();
  117. void NegotiateForNonOEM();
  118. #ifndef _X86_
  119. //We need to change the error mode when using the write converter
  120. //to fix some alignment problems caused by the write converter. These
  121. //problems do not affect x86 platforms.
  122. UINT m_uPrevErrMode ;
  123. #endif
  124. };
  125. #endif
  126. /////////////////////////////////////////////////////////////////////////////