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.

165 lines
6.0 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. * Copyright (c) 1995-2000, Microsoft Corporation. All rights reserved.
  19. */
  20. #ifndef __RTFWRIT_H
  21. #define __RTFWRIT_H
  22. #include "_rtfconv.h"
  23. extern const KEYWORD rgKeyword[];
  24. #define PUNCT_MAX 1024
  25. class CRTFWrite ;
  26. class RTFWRITEOLESTREAM : public OLESTREAM
  27. {
  28. OLESTREAMVTBL OLEStreamVtbl; // @member - memory for OLESTREAMVTBL
  29. public:
  30. CRTFWrite *Writer; // @cmember CRTFwriter to use
  31. RTFWRITEOLESTREAM::RTFWRITEOLESTREAM ()
  32. {
  33. lpstbl = & OLEStreamVtbl ;
  34. }
  35. };
  36. enum // Control-Word-Format indices
  37. {
  38. CWF_STR, CWF_VAL, CWF_GRP, CWF_AST, CWF_GRV, CWF_SVAL
  39. };
  40. #define chEndGroup RBRACE
  41. /*
  42. * CRTFWrite
  43. *
  44. * @class RTF writer class.
  45. *
  46. * @base public | CRTFConverter
  47. *
  48. */
  49. class CRTFWrite : public CRTFConverter
  50. {
  51. private:
  52. LONG _cchBufferOut; //@cmember # chars in output buffer
  53. LONG _cchOut; //@cmember Total # chars put out
  54. LONG _cbCharLast; //@cmember # bytes in char last written
  55. BYTE _fBullet : 1; //@cmember Currently in a bulleted style
  56. BYTE _fBulletPending : 1; //@cmember Set if next output should bull
  57. BYTE _fNeedDelimeter : 1; //@cmember Set if next char must be nonalphanumeric
  58. BYTE _fIncludeObjects : 1; //@cmember Set if objects should be included in stream
  59. BYTE _fRangeHasEOP : 1; //@cmember Set if _prg has EOP
  60. BYTE _fNCRForNonASCII : 1; //@cmember Put /uN for nonASCII
  61. BYTE _fRowHasNesting : 1; //@cmember Row has nested row(s)
  62. BYTE _fFieldResult : 1; //@cmember Writing out a fldrslt
  63. BYTE _iCell; //@cmember Index of current cell in current row
  64. BYTE _cCell; //@cmember Count of CELLs in current row
  65. char * _pchRTFBuffer; //@cmember Ptr to RTF write buffer
  66. BYTE * _pbAnsiBuffer; //@cmember Ptr to buffer used for conversion
  67. char * _pchRTFEnd; //@cmember Ptr to RTF-write-buffer end
  68. LONG _symbolFont; //@cmember Font number of Symbol used by Bullet style
  69. RTFWRITEOLESTREAM RTFWriteOLEStream;//@cmember RTFWRITEOLESTREAM to use
  70. LONG _nHeadingStyle; //@cmember Deepest heading # found
  71. LONG _nNumber; //@cmember Current number in para (1-based)
  72. LONG _nFont; //@cmember Current number font index
  73. LONG _nFieldFont; //@cmember font change during fieldResult, to make RE30 hyperlink code happy
  74. LONG _cpg; //@cmember Current number code page
  75. const CParaFormat *_pPF; //@cmember Current para format
  76. //@cmember Build font/color tables
  77. EC BuildTables (CRchTxtPtr &rtp, LONG cch, BOOL& fNameIsDBCS);
  78. inline void CheckDelimiter() //@cmember Put ' ' if need delimiter
  79. {
  80. if(_fNeedDelimeter)
  81. {
  82. _fNeedDelimeter = FALSE;
  83. PutChar(' ');
  84. }
  85. };
  86. //@cmember Handle table delimeters
  87. BOOL CheckInTable (CRchTxtPtr *prtp, LONG *pcch);
  88. BOOL FlushBuffer (); //@cmember Stream out output buffer
  89. //@cmember Get index of <p colorref>
  90. LONG LookupColor (COLORREF colorref);
  91. //@cmember Get font index for <p pCF>
  92. LONG LookupFont (CCharFormat const *pCF);
  93. //@cmember Translate backing idx to RTF idx
  94. LONG TranslateColorIndex(LONG icr, const CParaFormat *pPF);
  95. //@cmember "printf" to output buffer
  96. BOOL _cdecl printF (CONST CHAR *szFmt, ...);
  97. //@cmember Put char <p ch> in output buffer
  98. EC PutBorders (BOOL fInTable);
  99. BOOL PutChar (CHAR ch);
  100. //@cmember Put control word <p iCtrl> with value <p iValue> into output buffer
  101. BOOL PutCtrlWord (LONG iFormat, LONG iCtrl, LONG iValue = 0);
  102. //@cmember Put shape control word <p iCtrl> with value <p iValue>
  103. BOOL PutShapeParm (LONG iCtrl, LONG iValue);
  104. //@cmember Put string <p sz> in output buffer
  105. void PutPar(); //@cmember Put \par with appropriate \r\n
  106. BOOL Puts (CHAR const *sz, LONG cb);
  107. //@cmember Write char format <p pCF>
  108. LONG WriteCharFormat (CRchTxtPtr *prtp, LONG cch, LONG nCodePage);
  109. EC WriteColorTable (); //@cmember Write color table
  110. EC WriteFontTable (); //@cmember Write font table
  111. EC WriteInfo (); //@cmember Write document info
  112. //@cmember Write para format <p pPF>
  113. EC WriteParaFormat (CRchTxtPtr *prtp, LONG *pcch);
  114. //@cmember Write PC data <p szData>
  115. EC WritePcData (const WCHAR *szData, INT nCodePage = CP_ACP, BOOL fIsDBCS = FALSE );
  116. //@cmember Write <p cch> chars of text <p pch>
  117. EC WriteText (LONG cwch, LPCWSTR lpcwstr, INT nCodePage, BOOL fIsDBCS,
  118. BOOL fQuadBackSlash);
  119. EC WriteTextChunk (LONG cwch, LPCWSTR lpcwstr, INT nCodePage, BOOL fIsDBCS,
  120. BOOL fQuadBackSlash);
  121. // OBJECT
  122. EC WriteObject (LONG cp, COleObject *pobj);
  123. BOOL GetRtfObjectMetafilePict(HGLOBAL hmfp, RTFOBJECT &rtfobject, SIZEL &sizelGoal);
  124. BOOL GetRtfObject (REOBJECT &reobject, RTFOBJECT &rtfobject);
  125. EC WriteRtfObject (RTFOBJECT & rtfOb, BOOL fPicture);
  126. BOOL ObjectWriteToEditstream(REOBJECT &reObject, RTFOBJECT &rtfobject);
  127. EC WritePicture (RTFOBJECT &rtfObject);
  128. EC WriteDib (RTFOBJECT &rtfObject);
  129. EC WriteBackgroundInfo(CDocInfo *pDocInfo);
  130. enum { MAPTOKWD_ANSI, MAPTOKWD_UNICODE };
  131. inline BOOL MapsToRTFKeywordW(WCHAR wch);
  132. inline BOOL MapsToRTFKeywordA(char ch);
  133. int MapToRTFKeyword (void *pv, int cch, int iCharEncoding, BOOL fQuadBackSlash);
  134. public:
  135. //@cmember Constructor
  136. CRTFWrite(CTxtRange *prg, EDITSTREAM *pes, DWORD dwFlags);
  137. ~CRTFWrite() {FreePv(_pbAnsiBuffer);} //@cmember Destructor
  138. LONG WriteRtf(); //@cmember Main write entry used by
  139. // CLiteDTEngine
  140. LONG WriteData (BYTE * pbBuffer, LONG cbBuffer);
  141. LONG WriteBinData (BYTE * pbBuffer, LONG cbBuffer);
  142. };
  143. #endif // __RTFWRIT_H