home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 May / PCFMay2001.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / rtflib.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  9.0 KB  |  289 lines

  1. /*
  2.  *    R T F L I B . H
  3.  *
  4.  *    Definitions for RTF library.
  5.  *
  6.  *  Copyright 1986-1996 Microsoft Corporation. All Rights Reserved.
  7.  */
  8.  
  9. #ifndef RTFLIB_H
  10. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  11. #define RTFLIB_H
  12.  
  13. #if defined (WIN32) && !defined (_WIN32)
  14. #define _WIN32
  15. #endif
  16.  
  17. #if defined (_WIN32)
  18. #ifndef _OBJBASE_H_
  19. #include <objbase.h>
  20. #endif
  21. #endif
  22.  
  23. #if defined (WIN16) || defined (DOS) || defined (DOS16)
  24. #ifndef _COMPOBJ_H_
  25. #include <compobj.h>
  26. #endif
  27. #endif
  28.  
  29.  
  30. /*
  31.  * RTFLIB only looks at the first cchBodyTagMax characters of the body tag.
  32.  */
  33. #define cchBodyTagMax    100
  34.  
  35. typedef struct _RTFSYNCINFO
  36. {
  37.     LONG lBodyCRC;
  38.     LONG lBodyCount;
  39.     LONG lPrefixCount;
  40.     LONG lTrailingCount;
  41.     char szBodyTag[cchBodyTagMax + 2];
  42. } RTFSYNCINFO;
  43.  
  44. // header for compressed stream
  45. typedef struct _lzfuhdr
  46. {
  47.     ULONG cbSize;        // total number of bytes following this field
  48.     ULONG cbRawSize;    // size before compression
  49.     DWORD dwMagic;        // identifies this as a compressed stream
  50.     DWORD dwCRC;        // CRC-32 of the compressed data for error checking
  51. } LZFUHDR;
  52.  
  53. // magic number that identifies the stream as a compressed stream
  54. #define dwMagicCompressedRTF 0x75465a4c
  55.  
  56. // magic number that identifies the stream as a uncompressed stream
  57. #define dwMagicUncompressedRTF 0x414c454d
  58.  
  59. // array used for CRC calculations
  60. extern const DWORD rgdwCRC[];
  61.  
  62. /* IMPORTED FUNCTIONS */
  63.  
  64. /* 
  65.  * LogInvalidCpid
  66.  *
  67.  * Imported callback function for logging code page conversion
  68.  * errors. A stub function is provided if a function is
  69.  * not provided by the project linking with RTFLIB
  70.  *
  71.  * The cpid parameter is the unsupported code page ID.
  72.  *
  73.  */
  74.  
  75. STDAPI_(void) LogInvalidCpid( ULONG cpid );
  76.  
  77.  
  78. /* MAIN RTF ROUTINES */
  79.  
  80. /*
  81.  * HrTextFromCompressedRTFStream
  82.  *
  83.  * Takes compressed RTF stream (pstmRTF) and returns a wrapper
  84.  * stream (*ppstmText) giving access to the plain text. The text
  85.  * stream supports Read and CopyTo methods.
  86.  * 
  87.  * The pointer psi must be valid until *ppstmText is released.
  88.  * It is updated as *ppstmText is read and is not accurate until
  89.  * all of the text has been read.
  90.  *
  91.  * cpid is the code page for the text stream. It can be any code page
  92.  * INCLUDING unicode. cpid=0 means current system code page. If    the
  93.  * requested code page is not supported, S_FALSE warning may be
  94.  * returned during Read or CopyTo operation.
  95.  */
  96.  
  97. STDAPI_(HRESULT) HrTextFromCompressedRTFStream(LPSTREAM pstmCompressed,
  98.             LPSTREAM FAR *ppstmText, RTFSYNCINFO FAR *psi, ULONG cpid);
  99.  
  100.  
  101. /*
  102.  * HrTextFromCompressedRTFStreamEx()
  103.  *
  104.  * Takes compressed RTF stream (pstmRTF) and returns a wrapper
  105.  * stream (*ppstmText) giving access to the plain text. The text
  106.  * stream supports Read and CopyTo methods.
  107.  * 
  108.  * The pointer psi must be valid until *ppstmText is released.
  109.  * It is updated as *ppstmText is read and is not accurate until
  110.  * all of the text has been read.
  111.  *
  112.  * rgAttachPos is an array of attachment positions. It must be 
  113.  * initialized to the current attachment positions before 
  114.  * HrTextFromCompressedRTFStreamEx() is called. 
  115.  *
  116.  * cAttach must contain the number of elements in rgAttachPos
  117.  *
  118.  * The pointer to rgAttachPos must be valid until *ppstmText is 
  119.  * released. It is updated as *ppstmText is read with the new 
  120.  * attachment positions and is not accurate until all of the text
  121.  * has been read.
  122.  *
  123.  * cpid is the code page for the text stream. It can be any code page
  124.  * INCLUDING unicode. cpid=0 means current system code page. If    the
  125.  * requested code page is not supported, S_FALSE warning may be
  126.  * returned during Read or CopyTo operation.
  127.  */
  128.  
  129. STDAPI_(HRESULT) HrTextFromCompressedRTFStreamEx( LPSTREAM pstmCompressed,
  130.             LPSTREAM FAR *ppstmText, RTFSYNCINFO FAR *psi, ULONG cpid,
  131.             ULONG cAttach, ULONG FAR *rgAttachPos );
  132.  
  133. /*
  134.  * HrRTFFromTextStream
  135.  *
  136.  * This function takes a text stream and returns a wrapper 
  137.  * stream interface that converts the text to RTF. The 
  138.  * stream wrapper is read only and only supports  
  139.  * a minimum stream interface.
  140.  *
  141.  * The pointer to rgAttachPos must be valid until *ppstmRTF is 
  142.  * released. This array is used to allow the insertion of 
  143.  * attachment tags in the RTF. 
  144.  *
  145.  * cpid is the code page for the text stream. It is used to 
  146.  * set the charset and font in the RTF. No code page conversion
  147.  * is currently done inside this function.
  148.  */
  149.  
  150. STDAPI_(HRESULT) HrRTFFromTextStream( LPSTREAM pstmText,
  151.                                         LPSTREAM *ppstmRTF,                                        
  152.                                         ULONG cpid,
  153.                                         ULONG cAttach,
  154.                                         ULONG FAR *rgAttachPos );
  155.  
  156. /*
  157.  * WrapCompressedRTFStream
  158.  *
  159.  * Takes compressed RTF stream (pstmCompressed) and returns a wrapper
  160.  * stream (*ppstmRTF) giving access to uncompressed RTF. The RTF
  161.  * stream can support both Read and Write operations, but to get
  162.  * write access the flag ulFlags must have MAPI_MODIFY bit set.
  163.  *
  164.  * This function also supports reading and writing uncompressed
  165.  * RTF through the use of the STORE_UNCOMPRESSED_RTF flag. For reading,
  166.  * uncompressed RTF streams are detected automatically and thus the 
  167.  * STORE_UNCOMPRESSED_RTF flag only has meaning if MAPI_MODIFY is set.
  168.  * If this flag is used, the data will be written in uncompressed form.
  169.  */
  170.  
  171. STDAPI_(HRESULT) WrapCompressedRTFStream(LPSTREAM pstmCompressed,
  172.             ULONG ulFlags, LPSTREAM FAR *ppstmRTF);
  173.  
  174. /*
  175.  * RTFSync
  176.  * RTFSyncCpid
  177.  *
  178.  * Perforts body and RTF synchronization.
  179.  * 
  180.  * If synchronization cannot be performed, RTF properties are removed.
  181.  * It is up to the caller to create new RTF from PR_BODY.
  182.  *
  183.  * cpid is the code page for the body property. It can be any code page
  184.  * EXCLUDING unicode. cpid=0 means current system code page. If    the
  185.  * requested code page is not supported, S_FALSE warning is returned.
  186.  * RTFSync is the same as RTFSyncCpid(cpid=0).
  187.  */
  188.  
  189. STDAPI_(HRESULT) RTFSync(LPMESSAGE lpMessage, ULONG ulFlags,
  190.             BOOL FAR *pfMessageUpdated);
  191.  
  192. STDAPI_(HRESULT) RTFSyncCpid(LPMESSAGE lpMessage, ULONG ulFlags,
  193.             BOOL FAR *pfMessageUpdated, ULONG cpid);
  194.  
  195. /* ulFlags for RTFSync */
  196. #define RTF_SYNC_RTF_CHANGED    ((ULONG) 0x00000001)
  197. #define RTF_SYNC_BODY_CHANGED    ((ULONG) 0x00000002)
  198.  
  199. /*
  200.  * ScUpdateRTFAux
  201.  *
  202.  * Calculates and updates RTF auxiliary properties.
  203.  */
  204.  
  205. STDAPI_(SCODE) ScUpdateRTFAux(LPMESSAGE lpMessage,
  206.             BOOL FAR *lpfMessageUpdated);
  207.  
  208. STDAPI_(SCODE) ScUpdateRTFAuxCpid(LPMESSAGE lpMessage,
  209.             BOOL FAR *lpfMessageUpdated, ULONG cpid);
  210.  
  211. /*
  212.  * HrAppendTextToCompressedRTF
  213.  *
  214.  * Takes a text buffer (pbText, cchText) and appends it to the compressed
  215.  * RTF property of the message (lpMessage) appying default text formatting.
  216.  *
  217.  * The text can be added either at the beginning of the message
  218.  * (RTF_APPEND_BEGIN) or at the end (RTF_APPEND_END).
  219.  * The text can be treated as a plain text (RTF_APPEND_PLAIN_TEXT)
  220.  * or as a piece of text with some RTF formatting in it
  221.  * (RTF_APPEND_RTF_TEXT).
  222.  *
  223.  * If case of RTF text, cchText is the number of plain text characters.
  224.  *
  225.  * cpid is the code page for the text stream. It should be one of
  226.  * Windows code pages EXCLUDING unicode. cpid=0 means current system
  227.  * code page. If the requested code page is not supported,
  228.  * S_FALSE warning is returned.
  229.  */
  230.  
  231. STDAPI_(HRESULT) HrAppendTextToCompressedRTF(LPMESSAGE lpMessage,
  232.             LPSTR strText, ULONG cchText, ULONG ulFlags, ULONG cpid);
  233.  
  234. /* ulFlags for HrAppendTextToCompressedRTF */
  235.     /* text properties (mutually exclusive) */
  236. #define RTF_APPEND_RTF_TEXT    ((ULONG) 0x00000001)
  237. #define RTF_APPEND_PLAIN_TEXT ((ULONG) 0x00000000)
  238.     /* append position (mutually exclusive) */
  239. #define RTF_APPEND_BEGIN ((ULONG) 0x00000002)
  240. #define RTF_APPEND_END ((ULONG) 0x00000000)
  241.  
  242. /* ATTACHMENT TABLE HANDLING ROUTINES */
  243.  
  244. /*
  245.  * ScGetAttachTable()
  246.  *
  247.  * Takes a message and returns a pointer to the set of rows in
  248.  * the attachment table (ppRowSet), the number of attachments 
  249.  * (pcAttach), and a pointer to an array of ULONGs containing
  250.  * the PR_RENDERING_POSITIONs for the attachments in sorted
  251.  * order.
  252.  *
  253.  */
  254.  
  255. STDAPI_(SCODE) ScGetAttachTable(LPMESSAGE pmsg, LPSRowSet *ppRowSet,
  256.                 UINT *pcAttach, ULONG **prgAttachPos);
  257.  
  258. /*
  259.  * ScUpdateAttachTable()
  260.  *
  261.  * Takes a message, a rowset for the attachment table, the 
  262.  * number of attachments, and an array of rendering positions
  263.  * to update the attachment table with. This function is 
  264.  * designed to be used in conjunction with ScGetAttachTable().
  265.  * The BOOLEAN pointed to by pfUpdated will be set to TRUE if
  266.  * the attachment table was modified.
  267.  *
  268.  */
  269.  
  270. STDAPI_(SCODE) ScUpdateAttachTable(LPMESSAGE pmsg, LPSRowSet pRowSet,
  271.                 UINT cAttach, ULONG *rgAttachPos, BOOL *pfUpdated);
  272.  
  273.  
  274. /* CPID CONVERSION ROUTINES */
  275.  
  276. /*
  277.  * These functions are in a separate object file (cpmap.obj),
  278.  * since on the store side they are linked into a different DLL.
  279.  */
  280.  
  281. STDAPI_(ULONG) WinCpidFromCpid (ULONG cpid);
  282. STDAPI_(ULONG) CharsetFromCpid (ULONG cpid);
  283. STDAPI_(ULONG) CpidFromCharset (ULONG charset);
  284. STDAPI_(CHAR FAR*) SzDefFontFmtFromCpid (ULONG cpid);
  285.  
  286.  
  287. #pragma option pop /*P_O_Pop*/
  288. #endif /* RTFLIB_H */
  289.