00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <stdlib.h>
00019 #include <string.h>
00020 #include <rtfhtml.h>
00021
00022
00023 RTFHTML::RTFHTML() {
00024
00025 }
00026
00027
00028 char RTFHTML::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
00029 {
00030 char *to, *from;
00031 int len;
00032 bool center = false;
00033
00034 len = strlen(text) + 1;
00035 if (len < maxlen) {
00036 memmove(&text[maxlen - len], text, len);
00037 from = &text[maxlen - len];
00038 }
00039 else from = text;
00040 for (to = text; *from; from++) {
00041 if (*from == '\\')
00042 {
00043 if ((from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r') && (from[4] == 'd'))
00044 {
00045 if (center)
00046 {
00047 *to++ = '<';
00048 *to++ = '/';
00049 *to++ = 'C';
00050 *to++ = 'E';
00051 *to++ = 'N';
00052 *to++ = 'T';
00053 *to++ = 'E';
00054 *to++ = 'R';
00055 *to++ = '>';
00056 center = false;
00057 }
00058 from += 4;
00059 continue;
00060 }
00061 if ((from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r'))
00062 {
00063 *to++ = '<';
00064 *to++ = 'P';
00065 *to++ = '>';
00066 *to++ = '\n';
00067 from += 3;
00068 continue;
00069 }
00070 if (from[1] == ' ')
00071 {
00072 from += 1;
00073 continue;
00074 }
00075 if ((from[1] == 'q') && (from[2] == 'c'))
00076 {
00077 if (!center)
00078 {
00079 *to++ = '<';
00080 *to++ = 'C';
00081 *to++ = 'E';
00082 *to++ = 'N';
00083 *to++ = 'T';
00084 *to++ = 'E';
00085 *to++ = 'R';
00086 *to++ = '>';
00087 center = true;
00088 }
00089 from += 2;
00090 continue;
00091 }
00092 }
00093
00094 *to++ = *from;
00095 }
00096 *to++ = 0;
00097 *to = 0;
00098 return 0;
00099 }