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.

150 lines
5.3 KiB

  1. /*
  2. * @doc INTERNAL
  3. *
  4. * @module _RTFWRIT.H -- RichEdit RTF Writer Class Definition |
  5. *
  6. * Description:
  7. * This file contains the type declarations used by the RTF writer
  8. * for the RICHEDIT control
  9. *
  10. * Authors: <nl>
  11. * Original RichEdit 1.0 RTF converter: Anthony Francisco <nl>
  12. * Conversion to C++ and RichEdit 2.0: Murray Sargent
  13. *
  14. * @devnote
  15. * All sz's in the RTF*.? files refer to a LPSTRs, not LPTSTRs, unless
  16. * noted as a szUnicode.
  17. */
  18. #ifndef __RTFWRIT_H
  19. #define __RTFWRIT_H
  20. #include "_rtfconv.h"
  21. extern const KEYWORD rgKeyword[];
  22. #define PUNCT_MAX 1024
  23. class CRTFWrite ;
  24. class RTFWRITEOLESTREAM : public OLESTREAM
  25. {
  26. OLESTREAMVTBL OLEStreamVtbl; // @member - memory for OLESTREAMVTBL
  27. public:
  28. CRTFWrite *Writer; // @cmember CRTFwriter to use
  29. RTFWRITEOLESTREAM::RTFWRITEOLESTREAM ()
  30. {
  31. lpstbl = & OLEStreamVtbl ;
  32. }
  33. };
  34. enum // Control-Word-Format indices
  35. {
  36. CWF_STR, CWF_VAL, CWF_GRP, CWF_AST, CWF_GRV
  37. };
  38. #define chEndGroup RBRACE
  39. /*
  40. * CRTFWrite
  41. *
  42. * @class RTF writer class.
  43. *
  44. * @base public | CRTFConverter
  45. *
  46. */
  47. class CRTFWrite : public CRTFConverter
  48. {
  49. private:
  50. LONG _cchBufferOut; //@cmember # chars in output buffer
  51. LONG _cchOut; //@cmember Total # chars put out
  52. LONG _cbCharLast; //@cmember # bytes in char last written
  53. BYTE _fBullet; //@cmember Currently in a bulleted style
  54. BYTE _fBulletPending; //@cmember Set if next output should bull
  55. BYTE _fNeedDelimeter; //@cmember Set if next char must be nonalphanumeric
  56. BYTE _fIncludeObjects; //@cmember Set if objects should be included in stream
  57. BYTE _fCheckInTable; //@cmember If set and in table, output intbl stuff
  58. BYTE _fRangeHasEOP; //@cmember Set if _prg has EOP
  59. BYTE _fNCRForNonASCII; //@cmember Put /uN for nonASCII
  60. char * _pchRTFBuffer; //@cmember Ptr to RTF write buffer
  61. BYTE * _pbAnsiBuffer; //@cmember Ptr to buffer used for conversion
  62. char * _pchRTFEnd; //@cmember Ptr to RTF-write-buffer end
  63. LONG _symbolFont; //@cmember Font number of Symbol used by Bullet style
  64. RTFWRITEOLESTREAM RTFWriteOLEStream;//@cmember RTFWRITEOLESTREAM to use
  65. LONG _nHeadingStyle; //@cmember Deepest heading # found
  66. LONG _nNumber; //@cmember Current number in para (1-based)
  67. LONG _nFont; //@cmember Current number font index
  68. LONG _cpg; //@cmember Current number code page
  69. const CParaFormat *_pPF; //@cmember Current para format
  70. // @cmember Build font/color tables
  71. EC BuildTables (CFormatRunPtr& rpCF, CFormatRunPtr &rpPF,
  72. LONG cch, BOOL& fNameIsDBCS);
  73. inline void CheckDelimeter() // @cmember Put ' ' if need delimeter
  74. {
  75. if(_fNeedDelimeter)
  76. {
  77. _fNeedDelimeter = FALSE;
  78. PutChar(' ');
  79. }
  80. };
  81. BOOL CheckInTable (BOOL fPutIntbl);
  82. // @cmember Stream out output buffer
  83. BOOL FlushBuffer ();
  84. // @cmember Get index of <p colorref>
  85. LONG LookupColor (COLORREF colorref);
  86. // @cmember Get font index for <p pCF>
  87. LONG LookupFont (CCharFormat const * pCF);
  88. // @cmember "printf" to output buffer
  89. BOOL _cdecl printF (CONST CHAR * szFmt, ...);
  90. // @cmember Put char <p ch> in output buffer
  91. EC PutBorders (BOOL fInTable);
  92. BOOL PutChar (CHAR ch);
  93. // @cmember Put control word <p iCtrl> with value <p iValue> into output buffer
  94. BOOL PutCtrlWord (LONG iFormat, LONG iCtrl, LONG iValue = 0);
  95. // @cmember Put string <p sz> in output buffer
  96. BOOL Puts (CHAR const * sz, LONG cb);
  97. // @cmember Write char format <p pCF>
  98. EC WriteCharFormat (const CCharFormat *pCF);
  99. EC WriteColorTable (); // @cmember Write color table
  100. EC WriteFontTable (); // @cmember Write font table
  101. EC WriteInfo (); // @cmember Write document info
  102. // @cmember Write para format <p pPF>
  103. EC WriteParaFormat (const CRchTxtPtr * prtp);
  104. // @cmember Write PC data <p szData>
  105. EC WritePcData (const TCHAR * szData, INT nCodePage = CP_ACP, BOOL fIsDBCS = FALSE );
  106. // @cmember Write <p cch> chars of text <p pch>
  107. EC WriteText(LONG cwch, LPCWSTR lpcwstr, INT nCodePage, BOOL fIsDBCS);
  108. EC WriteTextChunk(LONG cwch, LPCWSTR lpcwstr, INT nCodePage, BOOL fIsDBCS);
  109. // OBJECT
  110. EC WriteObject (LONG cp, COleObject *pobj);
  111. BOOL GetRtfObjectMetafilePict(HGLOBAL hmfp, RTFOBJECT &rtfobject, SIZEL &sizelGoal);
  112. BOOL GetRtfObject(REOBJECT &reobject, RTFOBJECT &rtfobject);
  113. EC WriteRtfObject(RTFOBJECT & rtfOb, BOOL fPicture);
  114. BOOL ObjectWriteToEditstream(REOBJECT &reObject, RTFOBJECT &rtfobject);
  115. EC WritePicture(REOBJECT &reObject,RTFOBJECT &rtfObject);
  116. EC WriteDib(REOBJECT &reObject,RTFOBJECT &rtfObject);
  117. enum { MAPTOKWD_ANSI, MAPTOKWD_UNICODE };
  118. inline BOOL MapsToRTFKeywordW(WCHAR wch);
  119. inline BOOL MapsToRTFKeywordA(char ch);
  120. int MapToRTFKeyword(void *pv, int cch, int iCharEncoding);
  121. public:
  122. // @cmember Constructor
  123. CRTFWrite(CTxtRange *prg, EDITSTREAM *pes, DWORD dwFlags);
  124. ~CRTFWrite() {FreePv(_pbAnsiBuffer);} // @cmember Destructor
  125. LONG WriteRtf(); // @cmember Main write entry used by
  126. // CLiteDTEngine
  127. LONG WriteData (BYTE * pbBuffer, LONG cbBuffer);
  128. LONG WriteBinData (BYTE * pbBuffer, LONG cbBuffer);
  129. };
  130. #endif // __RTFWRIT_H