4 * Portions Copyright 2004 Mike McCormack for CodeWeavers
5 * Portions Copyright 2006 by Phil Krylov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * Derived from RTF Tools by Paul DuBois (dubois@primate.wisc.edu)
24 * Homepage: http://www.snake.net/software/RTF/
25 * Original license follows:
29 * reader.c - RTF file reader. Release 1.10.
33 * Author: Paul DuBois dubois@primate.wisc.edu
35 * This software may be redistributed without restriction and used for
36 * any purpose whatsoever.
48 #include "wine/debug.h"
53 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
55 extern HANDLE me_heap;
57 static int _RTFGetChar(RTF_Info *);
58 static void _RTFGetToken (RTF_Info *);
59 static void _RTFGetToken2 (RTF_Info *);
60 static int GetChar (RTF_Info *);
61 static void ReadFontTbl (RTF_Info *);
62 static void ReadColorTbl (RTF_Info *);
63 static void ReadStyleSheet (RTF_Info *);
64 static void ReadInfoGroup (RTF_Info *);
65 static void ReadPictGroup (RTF_Info *);
66 static void ReadObjGroup (RTF_Info *);
67 static void Lookup (RTF_Info *, char *);
68 static int Hash (const char *);
70 static void CharAttr(RTF_Info *info);
71 static void CharSet(RTF_Info *info);
72 static void DocAttr(RTF_Info *info);
74 static void RTFFlushCPOutputBuffer(RTF_Info *info);
75 static void RTFPutCodePageChar(RTF_Info *info, int c);
77 /* ---------------------------------------------------------------------- */
81 * Saves a string on the heap and returns a pointer to it.
83 static inline char *RTFStrSave(const char *s)
87 p = heap_alloc (lstrlenA(s) + 1);
90 return lstrcpyA (p, s);
94 /* ---------------------------------------------------------------------- */
97 int _RTFGetChar(RTF_Info *info)
100 ME_InStream *stream = info->stream;
102 if (stream->dwSize <= stream->dwUsed)
104 ME_StreamInFill(stream);
105 /* if error, it's EOF */
106 if (stream->editstream->dwError)
108 /* if no bytes read, it's EOF */
109 if (stream->dwSize == 0)
112 ch = (unsigned char)stream->buffer[stream->dwUsed++];
118 void RTFSetEditStream(RTF_Info *info, ME_InStream *stream)
120 info->stream = stream;
124 RTFDestroyAttrs(RTF_Info *info)
129 RTFStyleElt *eltList, *ep;
131 while (info->fontList)
133 fp = info->fontList->rtfNextFont;
134 heap_free (info->fontList->rtfFName);
135 heap_free (info->fontList);
138 while (info->colorList)
140 cp = info->colorList->rtfNextColor;
141 heap_free (info->colorList);
142 info->colorList = cp;
144 while (info->styleList)
146 sp = info->styleList->rtfNextStyle;
147 eltList = info->styleList->rtfSSEList;
150 ep = eltList->rtfNextSE;
151 heap_free (eltList->rtfSEText);
155 heap_free (info->styleList->rtfSName);
156 heap_free (info->styleList);
157 info->styleList = sp;
163 RTFDestroy(RTF_Info *info)
165 if (info->rtfTextBuf)
167 heap_free(info->rtfTextBuf);
168 heap_free(info->pushedTextBuf);
170 RTFDestroyAttrs(info);
171 heap_free(info->cpOutputBuffer);
172 while (info->tableDef)
174 RTFTable *tableDef = info->tableDef;
175 info->tableDef = tableDef->parent;
182 /* ---------------------------------------------------------------------- */
185 * Callback table manipulation routines
190 * Install or return a writer callback for a token class
193 static void RTFSetClassCallback(RTF_Info *info, int class, RTFFuncPtr callback)
195 if (class >= 0 && class < rtfMaxClass)
196 info->ccb[class] = callback;
200 static RTFFuncPtr RTFGetClassCallback(const RTF_Info *info, int class)
202 if (class >= 0 && class < rtfMaxClass)
203 return info->ccb[class];
209 * Initialize the reader. This may be called multiple times,
210 * to read multiple files. The only thing not reset is the input
211 * stream; that must be done with RTFSetStream().
214 void RTFInit(RTF_Info *info)
218 if (info->rtfTextBuf == NULL) /* initialize the text buffers */
220 info->rtfTextBuf = heap_alloc (rtfBufSiz);
221 info->pushedTextBuf = heap_alloc (rtfBufSiz);
222 if (info->rtfTextBuf == NULL || info->pushedTextBuf == NULL) {
223 ERR ("Cannot allocate text buffers.\n");
226 info->rtfTextBuf[0] = info->pushedTextBuf[0] = '\0';
229 for (i = 0; i < rtfMaxClass; i++)
230 RTFSetClassCallback (info, i, NULL);
231 for (i = 0; i < rtfMaxDestination; i++)
232 RTFSetDestinationCallback (info, i, NULL);
234 /* install built-in destination readers */
235 RTFSetDestinationCallback (info, rtfFontTbl, ReadFontTbl);
236 RTFSetDestinationCallback (info, rtfColorTbl, ReadColorTbl);
237 RTFSetDestinationCallback (info, rtfStyleSheet, ReadStyleSheet);
238 RTFSetDestinationCallback (info, rtfInfo, ReadInfoGroup);
239 RTFSetDestinationCallback (info, rtfPict, ReadPictGroup);
240 RTFSetDestinationCallback (info, rtfObject, ReadObjGroup);
243 RTFSetReadHook (info, NULL);
245 /* dump old lists if necessary */
247 RTFDestroyAttrs(info);
249 info->ansiCodePage = 1252; /* Latin-1; actually unused */
250 info->unicodeLength = 1; /* \uc1 is the default */
251 info->codePage = info->ansiCodePage;
255 info->pushedClass = -1;
256 info->pushedChar = EOF;
258 info->rtfLineNum = 0;
259 info->rtfLinePos = 0;
260 info->prevChar = EOF;
263 info->dwCPOutputCount = 0;
264 if (!info->cpOutputBuffer)
266 info->dwMaxCPOutputCount = 0x1000;
267 info->cpOutputBuffer = heap_alloc(info->dwMaxCPOutputCount);
270 info->tableDef = NULL;
271 info->nestingLevel = 0;
272 info->canInheritInTbl = FALSE;
273 info->borderType = 0;
277 * Install or return a writer callback for a destination type
280 void RTFSetDestinationCallback(RTF_Info *info, int dest, RTFFuncPtr callback)
282 if (dest >= 0 && dest < rtfMaxDestination)
283 info->dcb[dest] = callback;
287 static RTFFuncPtr RTFGetDestinationCallback(const RTF_Info *info, int dest)
289 if (dest >= 0 && dest < rtfMaxDestination)
290 return info->dcb[dest];
295 /* ---------------------------------------------------------------------- */
298 * Token reading routines
303 * Read the input stream, invoking the writer's callbacks
307 void RTFRead(RTF_Info *info)
309 while (RTFGetToken (info) != rtfEOF)
310 RTFRouteToken (info);
315 * Route a token. If it's a destination for which a reader is
316 * installed, process the destination internally, otherwise
317 * pass the token to the writer's class callback.
320 void RTFRouteToken(RTF_Info *info)
324 if (info->rtfClass < 0 || info->rtfClass >= rtfMaxClass) /* watchdog */
326 ERR( "Unknown class %d: %s (reader malfunction)\n",
327 info->rtfClass, info->rtfTextBuf);
329 if (RTFCheckCM (info, rtfControl, rtfDestination))
331 /* invoke destination-specific callback if there is one */
332 p = RTFGetDestinationCallback (info, info->rtfMinor);
339 /* invoke class callback if there is one */
340 p = RTFGetClassCallback (info, info->rtfClass);
347 * Skip to the end of the current group. When this returns,
348 * writers that maintain a state stack may want to call their
349 * state unstacker; global vars will still be set to the group's
353 void RTFSkipGroup(RTF_Info *info)
357 while (RTFGetToken (info) != rtfEOF)
359 if (info->rtfClass == rtfGroup)
361 if (info->rtfMajor == rtfBeginGroup)
363 else if (info->rtfMajor == rtfEndGroup)
366 break; /* end of initial group */
373 * Do no special processing on the group.
375 * This acts as a placeholder for a callback in order to indicate that it
376 * shouldn't be ignored. Instead it will fallback on the loop in RTFRead.
378 void RTFReadGroup (RTF_Info *info)
384 * Install or return a token reader hook.
387 void RTFSetReadHook(RTF_Info *info, RTFFuncPtr f)
393 static RTFFuncPtr RTFGetReadHook(const RTF_Info *info)
395 return (info->readHook);
400 * Read one token. Call the read hook if there is one. The
401 * token class is the return value. Returns rtfEOF when there
402 * are no more tokens.
405 int RTFGetToken(RTF_Info *info)
409 /* don't try to return anything once EOF is reached */
410 if (info->rtfClass == rtfEOF) {
417 p = RTFGetReadHook (info);
419 (*p) (info); /* give read hook a look at token */
421 /* Silently discard newlines, carriage returns, nulls. */
422 if (!(info->rtfClass == rtfText && info->rtfFormat != SF_TEXT
423 && (info->rtfMajor == '\r' || info->rtfMajor == '\n' || info->rtfMajor == '\0')))
426 return (info->rtfClass);
430 static void RTFUngetToken(RTF_Info *info)
432 if (info->pushedClass >= 0) /* there's already an ungotten token */
433 ERR ("cannot unget two tokens\n");
434 if (info->rtfClass < 0)
435 ERR ("no token to unget\n");
436 info->pushedClass = info->rtfClass;
437 info->pushedMajor = info->rtfMajor;
438 info->pushedMinor = info->rtfMinor;
439 info->pushedParam = info->rtfParam;
440 lstrcpyA (info->pushedTextBuf, info->rtfTextBuf);
441 /* The read hook decrements stackTop on rtfEndGroup, so
442 * increment the value to compensate for it being decremented
443 * twice due to the RTFUngetToken. */
444 if(RTFCheckCM (info, rtfGroup, rtfEndGroup))
449 static void _RTFGetToken(RTF_Info *info)
451 if (info->rtfFormat == SF_TEXT)
453 info->rtfMajor = GetChar (info);
455 info->rtfParam = rtfNoParam;
456 info->rtfTextBuf[info->rtfTextLen = 0] = '\0';
457 if (info->rtfMajor == EOF)
458 info->rtfClass = rtfEOF;
460 info->rtfClass = rtfText;
464 /* first check for pushed token from RTFUngetToken() */
466 if (info->pushedClass >= 0)
468 info->rtfClass = info->pushedClass;
469 info->rtfMajor = info->pushedMajor;
470 info->rtfMinor = info->pushedMinor;
471 info->rtfParam = info->pushedParam;
472 lstrcpyA (info->rtfTextBuf, info->pushedTextBuf);
473 info->rtfTextLen = lstrlenA(info->rtfTextBuf);
474 info->pushedClass = -1;
479 * Beyond this point, no token is ever seen twice, which is
480 * important, e.g., for making sure no "}" pops the font stack twice.
483 _RTFGetToken2 (info);
488 RTFCharSetToCodePage(RTF_Info *info, int charset)
494 case DEFAULT_CHARSET:
500 case SHIFTJIS_CHARSET:
502 case HANGEUL_CHARSET:
508 case CHINESEBIG5_CHARSET:
512 case TURKISH_CHARSET:
514 case VIETNAMESE_CHARSET:
522 case RUSSIAN_CHARSET:
526 case EASTEUROPE_CHARSET:
535 /* FIXME: TranslateCharsetInfo does not work as good as it
536 * should, so let's use it only when all else fails */
537 if (!TranslateCharsetInfo(&n, &csi, TCI_SRCCHARSET))
538 ERR("unknown charset %d\n", charset);
547 /* this shouldn't be called anywhere but from _RTFGetToken() */
549 static void _RTFGetToken2(RTF_Info *info)
554 /* initialize token vars */
556 info->rtfClass = rtfUnknown;
557 info->rtfParam = rtfNoParam;
558 info->rtfTextBuf[info->rtfTextLen = 0] = '\0';
560 /* get first character, which may be a pushback from previous token */
562 if (info->pushedChar != EOF)
564 c = info->pushedChar;
565 info->rtfTextBuf[info->rtfTextLen++] = c;
566 info->rtfTextBuf[info->rtfTextLen] = '\0';
567 info->pushedChar = EOF;
569 else if ((c = GetChar (info)) == EOF)
571 info->rtfClass = rtfEOF;
577 info->rtfClass = rtfGroup;
578 info->rtfMajor = rtfBeginGroup;
583 info->rtfClass = rtfGroup;
584 info->rtfMajor = rtfEndGroup;
590 * Two possibilities here:
591 * 1) ASCII 9, effectively like \tab control symbol
592 * 2) literal text char
594 if (c == '\t') /* ASCII 9 */
596 info->rtfClass = rtfControl;
597 info->rtfMajor = rtfSpecialChar;
598 info->rtfMinor = rtfTab;
602 info->rtfClass = rtfText;
607 if ((c = GetChar (info)) == EOF)
609 /* early eof, whoops (class is rtfUnknown) */
615 * Three possibilities here:
616 * 1) hex encoded text char, e.g., \'d5, \'d3
617 * 2) special escaped text char, e.g., \{, \}
618 * 3) control symbol, e.g., \_, \-, \|, \<10>
620 if (c == '\'') /* hex char */
624 if ((c = GetChar (info)) != EOF && (c2 = GetChar (info)) != EOF
625 && isxdigit(c) && isxdigit(c2))
627 info->rtfClass = rtfText;
628 info->rtfMajor = RTFCharToHex (c) * 16 + RTFCharToHex (c2);
631 /* early eof, whoops */
632 info->rtfClass = rtfEOF;
633 info->stream->editstream->dwError = -14;
638 /*if (index (":{}\\", c) != NULL)*/ /* escaped char */
639 if (c == ':' || c == '{' || c == '}' || c == '\\')
641 info->rtfClass = rtfText;
647 Lookup (info, info->rtfTextBuf); /* sets class, major, minor */
653 if ((c = GetChar (info)) == EOF)
658 * At this point, the control word is all collected, so the
659 * major/minor numbers are determined before the parameter
660 * (if any) is scanned. There will be one too many characters
661 * in the buffer, though, so fix up before and restore after
666 info->rtfTextBuf[info->rtfTextLen-1] = '\0';
667 Lookup (info, info->rtfTextBuf); /* sets class, major, minor */
669 info->rtfTextBuf[info->rtfTextLen-1] = c;
672 * Should be looking at first digit of parameter if there
673 * is one, unless it's negative. In that case, next char
674 * is '-', so need to gobble next char, and remember sign.
683 if (c != EOF && isdigit (c))
686 while (isdigit (c)) /* gobble parameter */
688 info->rtfParam = info->rtfParam * 10 + c - '0';
689 if ((c = GetChar (info)) == EOF)
692 info->rtfParam *= sign;
695 * If control symbol delimiter was a blank, gobble it.
696 * Otherwise the character is first char of next token, so
697 * push it back for next call. In either case, delete the
698 * delimiter from the token buffer.
703 info->pushedChar = c;
704 info->rtfTextBuf[--info->rtfTextLen] = '\0';
710 * Read the next character from the input. This handles setting the
711 * current line and position-within-line variables. Those variable are
712 * set correctly whether lines end with CR, LF, or CRLF (the last being
715 * bumpLine indicates whether the line number should be incremented on
716 * the *next* input character.
720 static int GetChar(RTF_Info *info)
725 if ((c = _RTFGetChar(info)) != EOF)
727 info->rtfTextBuf[info->rtfTextLen++] = c;
728 info->rtfTextBuf[info->rtfTextLen] = '\0';
730 if (info->prevChar == EOF)
732 oldBumpLine = info->bumpLine; /* non-zero if prev char was line ending */
739 if (info->prevChar == '\r') /* oops, previous \r wasn't */
740 oldBumpLine = 0; /* really a line ending */
743 if (oldBumpLine) /* were we supposed to increment the */
744 { /* line count on this char? */
746 info->rtfLinePos = 1;
753 /* ---------------------------------------------------------------------- */
756 * Special destination readers. They gobble the destination so the
757 * writer doesn't have to deal with them. That's wrong for any
758 * translator that wants to process any of these itself. In that
759 * case, these readers should be overridden by installing a different
760 * destination callback.
762 * NOTE: The last token read by each of these reader will be the
763 * destination's terminating '}', which will then be the current token.
764 * That '}' token is passed to RTFRouteToken() - the writer has already
765 * seen the '{' that began the destination group, and may have pushed a
766 * state; it also needs to know at the end of the group that a state
769 * It's important that rtf.h and the control token lookup table list
770 * as many symbols as possible, because these destination readers
771 * unfortunately make strict assumptions about the input they expect,
772 * and a token of class rtfUnknown will throw them off easily.
777 * Read { \fonttbl ... } destination. Old font tables don't have
778 * braces around each table entry; try to adjust for that.
781 static void ReadFontTbl(RTF_Info *info)
784 char buf[rtfBufSiz], *bp;
786 const char *fn = "ReadFontTbl";
791 if (info->rtfClass == rtfEOF)
793 if (RTFCheckCM (info, rtfGroup, rtfEndGroup))
795 if (old < 0) /* first entry - determine tbl type */
797 if (RTFCheckCMM (info, rtfControl, rtfCharAttr, rtfFontNum))
798 old = 1; /* no brace */
799 else if (RTFCheckCM (info, rtfGroup, rtfBeginGroup))
801 else /* can't tell! */
802 ERR ( "%s: Cannot determine format\n", fn);
804 if (old == 0) /* need to find "{" here */
806 if (!RTFCheckCM (info, rtfGroup, rtfBeginGroup))
807 ERR ( "%s: missing \"{\"\n", fn);
808 RTFGetToken (info); /* yes, skip to next token */
809 if (info->rtfClass == rtfEOF)
814 ERR ( "%s: cannot allocate font entry\n", fn);
818 fp->rtfNextFont = info->fontList;
822 fp->rtfFAltName = NULL;
824 fp->rtfFFamily = FF_DONTCARE;
825 fp->rtfFCharSet = DEFAULT_CHARSET; /* 1 */
826 fp->rtfFPitch = DEFAULT_PITCH;
828 fp->rtfFCodePage = CP_ACP;
830 while (info->rtfClass != rtfEOF
831 && !RTFCheckCM (info, rtfText, ';')
832 && !RTFCheckCM (info, rtfGroup, rtfEndGroup))
834 if (info->rtfClass == rtfControl)
836 switch (info->rtfMajor)
839 /* ignore token but announce it */
840 WARN ("%s: unknown token \"%s\"\n",
841 fn, info->rtfTextBuf);
844 fp->rtfFFamily = info->rtfMinor;
847 switch (info->rtfMinor)
850 break; /* ignore unknown? */
852 fp->rtfFNum = info->rtfParam;
857 switch (info->rtfMinor)
860 break; /* ignore unknown? */
862 fp->rtfFCharSet = info->rtfParam;
863 if (!fp->rtfFCodePage)
864 fp->rtfFCodePage = RTFCharSetToCodePage(info, info->rtfParam);
867 fp->rtfFPitch = info->rtfParam;
869 case rtfFontCodePage:
870 fp->rtfFCodePage = info->rtfParam;
873 case rtfFTypeTrueType:
874 fp->rtfFType = info->rtfParam;
880 else if (RTFCheckCM (info, rtfGroup, rtfBeginGroup)) /* dest */
882 RTFSkipGroup (info); /* ignore for now */
884 else if (info->rtfClass == rtfText) /* font name */
887 while (info->rtfClass == rtfText
888 && !RTFCheckCM (info, rtfText, ';'))
890 *bp++ = info->rtfMajor;
894 /* FIX: in some cases the <fontinfo> isn't finished with a semi-column */
895 if(RTFCheckCM (info, rtfGroup, rtfEndGroup))
897 RTFUngetToken (info);
900 fp->rtfFName = RTFStrSave (buf);
901 if (fp->rtfFName == NULL)
902 ERR ( "%s: cannot allocate font name\n", fn);
903 /* already have next token; don't read one */
904 /* at bottom of loop */
909 /* ignore token but announce it */
910 WARN ( "%s: unknown token \"%s\"\n",
911 fn,info->rtfTextBuf);
914 if (info->rtfClass == rtfEOF)
917 if (info->rtfClass == rtfEOF)
919 if (old == 0) /* need to see "}" here */
922 if (!RTFCheckCM (info, rtfGroup, rtfEndGroup))
923 ERR ( "%s: missing \"}\"\n", fn);
924 if (info->rtfClass == rtfEOF)
928 /* Apply the real properties of the default font */
929 if (fp->rtfFNum == info->defFont)
931 if (info->ansiCodePage != CP_UTF8)
932 info->codePage = fp->rtfFCodePage;
933 TRACE("default font codepage %d\n", info->codePage);
936 if (!fp || (fp->rtfFNum == -1))
937 ERR( "%s: missing font number\n", fn);
939 * Could check other pieces of structure here, too, I suppose.
941 RTFRouteToken (info); /* feed "}" back to router */
943 /* Set default font */
944 info->rtfClass = rtfControl;
945 info->rtfMajor = rtfCharAttr;
946 info->rtfMinor = rtfFontNum;
947 info->rtfParam = info->defFont;
948 lstrcpyA(info->rtfTextBuf, "f");
954 * The color table entries have color values of -1 if
955 * the default color should be used for the entry (only
956 * a semi-colon is given in the definition, no color values).
957 * There will be a problem if a partial entry (1 or 2 but
958 * not 3 color values) is given. The possibility is ignored
962 static void ReadColorTbl(RTF_Info *info)
966 const char *fn = "ReadColorTbl";
972 if (info->rtfClass == rtfEOF)
974 if (RTFCheckCM (info, rtfGroup, rtfEndGroup))
981 else if (RTFCheckCM(info, rtfGroup, rtfBeginGroup))
989 ERR ( "%s: cannot allocate color entry\n", fn);
992 cp->rtfCNum = cnum++;
993 cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = -1;
994 cp->rtfNextColor = info->colorList;
995 info->colorList = cp;
996 while (RTFCheckCM (info, rtfControl, rtfColorName))
998 switch (info->rtfMinor)
1000 case rtfRed: cp->rtfCRed = info->rtfParam; break;
1001 case rtfGreen: cp->rtfCGreen = info->rtfParam; break;
1002 case rtfBlue: cp->rtfCBlue = info->rtfParam; break;
1006 if (info->rtfClass == rtfEOF)
1008 if (!RTFCheckCM (info, rtfText, ';'))
1009 ERR ("%s: malformed entry\n", fn);
1011 RTFRouteToken (info); /* feed "}" back to router */
1016 * The "Normal" style definition doesn't contain any style number,
1017 * all others do. Normal style is given style rtfNormalStyleNum.
1020 static void ReadStyleSheet(RTF_Info *info)
1023 RTFStyleElt *sep, *sepLast;
1024 char buf[rtfBufSiz], *bp;
1025 const char *fn = "ReadStyleSheet";
1031 if (info->rtfClass == rtfEOF)
1033 if (RTFCheckCM (info, rtfGroup, rtfEndGroup))
1035 sp = New (RTFStyle);
1037 ERR ( "%s: cannot allocate stylesheet entry\n", fn);
1040 sp->rtfSName = NULL;
1042 sp->rtfSType = rtfParStyle;
1043 sp->rtfSAdditive = 0;
1044 sp->rtfSBasedOn = rtfNoStyleNum;
1045 sp->rtfSNextPar = -1;
1046 sp->rtfSSEList = sepLast = NULL;
1047 sp->rtfNextStyle = info->styleList;
1048 sp->rtfExpanding = 0;
1049 info->styleList = sp;
1050 if (!RTFCheckCM (info, rtfGroup, rtfBeginGroup))
1051 ERR ( "%s: missing \"{\"\n", fn);
1056 if (info->rtfClass == rtfEOF
1057 || RTFCheckCM (info, rtfText, ';'))
1059 if (info->rtfClass == rtfControl)
1061 if (RTFCheckMM (info, rtfSpecialChar, rtfOptDest)) {
1063 ERR( "%s: skipping optional destination\n", fn);
1065 info->rtfClass = rtfGroup;
1066 info->rtfMajor = rtfEndGroup;
1068 break; /* ignore "\*" */
1070 if (RTFCheckMM (info, rtfParAttr, rtfStyleNum))
1072 sp->rtfSNum = info->rtfParam;
1073 sp->rtfSType = rtfParStyle;
1076 if (RTFCheckMM (info, rtfCharAttr, rtfCharStyleNum))
1078 sp->rtfSNum = info->rtfParam;
1079 sp->rtfSType = rtfCharStyle;
1082 if (RTFCheckMM (info, rtfSectAttr, rtfSectStyleNum))
1084 sp->rtfSNum = info->rtfParam;
1085 sp->rtfSType = rtfSectStyle;
1088 if (RTFCheckMM (info, rtfStyleAttr, rtfBasedOn))
1090 sp->rtfSBasedOn = info->rtfParam;
1093 if (RTFCheckMM (info, rtfStyleAttr, rtfAdditive))
1095 sp->rtfSAdditive = 1;
1098 if (RTFCheckMM (info, rtfStyleAttr, rtfNext))
1100 sp->rtfSNextPar = info->rtfParam;
1103 sep = New (RTFStyleElt);
1105 ERR ( "%s: cannot allocate style element\n", fn);
1106 sep->rtfSEClass = info->rtfClass;
1107 sep->rtfSEMajor = info->rtfMajor;
1108 sep->rtfSEMinor = info->rtfMinor;
1109 sep->rtfSEParam = info->rtfParam;
1110 sep->rtfSEText = RTFStrSave (info->rtfTextBuf);
1111 if (sep->rtfSEText == NULL)
1112 ERR ( "%s: cannot allocate style element text\n", fn);
1113 if (sepLast == NULL)
1114 sp->rtfSSEList = sep; /* first element */
1115 else /* add to end */
1116 sepLast->rtfNextSE = sep;
1117 sep->rtfNextSE = NULL;
1120 else if (RTFCheckCM (info, rtfGroup, rtfBeginGroup))
1123 * This passes over "{\*\keycode ... }, among
1124 * other things. A temporary (perhaps) hack.
1126 ERR( "%s: skipping begin\n", fn);
1127 RTFSkipGroup (info);
1130 else if (info->rtfClass == rtfText) /* style name */
1133 while (info->rtfClass == rtfText)
1135 if (info->rtfMajor == ';')
1137 /* put back for "for" loop */
1138 RTFUngetToken (info);
1141 *bp++ = info->rtfMajor;
1145 sp->rtfSName = RTFStrSave (buf);
1146 if (sp->rtfSName == NULL)
1147 ERR ( "%s: cannot allocate style name\n", fn);
1149 else /* unrecognized */
1151 /* ignore token but announce it */
1152 WARN ( "%s: unknown token \"%s\"\n",
1153 fn, info->rtfTextBuf);
1158 if (!RTFCheckCM (info, rtfGroup, rtfEndGroup))
1159 ERR ( "%s: missing \"}\"\n", fn);
1161 * Check over the style structure. A name is a must.
1162 * If no style number was specified, check whether it's the
1163 * Normal style (in which case it's given style number
1164 * rtfNormalStyleNum). Note that some "normal" style names
1165 * just begin with "Normal" and can have other stuff following,
1166 * e.g., "Normal,Times 10 point". Ugh.
1168 * Some German RTF writers use "Standard" instead of "Normal".
1170 if (sp->rtfSName == NULL)
1171 ERR ( "%s: missing style name\n", fn);
1172 if (sp->rtfSNum < 0)
1174 if (strncmp (buf, "Normal", 6) != 0
1175 && strncmp (buf, "Standard", 8) != 0)
1176 ERR ( "%s: missing style number\n", fn);
1177 sp->rtfSNum = rtfNormalStyleNum;
1179 if (sp->rtfSNextPar == -1) /* if \snext not given, */
1180 sp->rtfSNextPar = sp->rtfSNum; /* next is itself */
1182 /* otherwise we're just dealing with fake end group from skipped group */
1184 RTFRouteToken (info); /* feed "}" back to router */
1188 static void ReadInfoGroup(RTF_Info *info)
1190 RTFSkipGroup (info);
1191 RTFRouteToken (info); /* feed "}" back to router */
1195 static void ReadPictGroup(RTF_Info *info)
1197 RTFSkipGroup (info);
1198 RTFRouteToken (info); /* feed "}" back to router */
1202 static void ReadObjGroup(RTF_Info *info)
1204 RTFSkipGroup (info);
1205 RTFRouteToken (info); /* feed "}" back to router */
1209 /* ---------------------------------------------------------------------- */
1212 * Routines to return pieces of stylesheet, or font or color tables.
1213 * References to style 0 are mapped onto the Normal style.
1216 RTFFont *RTFGetFont(const RTF_Info *info, int num)
1221 return (info->fontList);
1222 for (f = info->fontList; f != NULL; f = f->rtfNextFont)
1224 if (f->rtfFNum == num)
1227 return (f); /* NULL if not found */
1231 RTFColor *RTFGetColor(const RTF_Info *info, int num)
1236 return (info->colorList);
1237 for (c = info->colorList; c != NULL; c = c->rtfNextColor)
1239 if (c->rtfCNum == num)
1242 return (c); /* NULL if not found */
1246 /* ---------------------------------------------------------------------- */
1249 * Control symbol lookup routines
1253 typedef struct RTFKey RTFKey;
1257 int rtfKMajor; /* major number */
1258 int rtfKMinor; /* minor number */
1259 const char *rtfKStr; /* symbol name */
1260 int rtfKHash; /* symbol name hash value */
1264 * A minor number of -1 means the token has no minor number
1265 * (all valid minor numbers are >= 0).
1268 static RTFKey rtfKey[] =
1271 * Special characters
1274 { rtfSpecialChar, rtfIIntVersion, "vern", 0 },
1275 { rtfSpecialChar, rtfICreateTime, "creatim", 0 },
1276 { rtfSpecialChar, rtfIRevisionTime, "revtim", 0 },
1277 { rtfSpecialChar, rtfIPrintTime, "printim", 0 },
1278 { rtfSpecialChar, rtfIBackupTime, "buptim", 0 },
1279 { rtfSpecialChar, rtfIEditTime, "edmins", 0 },
1280 { rtfSpecialChar, rtfIYear, "yr", 0 },
1281 { rtfSpecialChar, rtfIMonth, "mo", 0 },
1282 { rtfSpecialChar, rtfIDay, "dy", 0 },
1283 { rtfSpecialChar, rtfIHour, "hr", 0 },
1284 { rtfSpecialChar, rtfIMinute, "min", 0 },
1285 { rtfSpecialChar, rtfISecond, "sec", 0 },
1286 { rtfSpecialChar, rtfINPages, "nofpages", 0 },
1287 { rtfSpecialChar, rtfINWords, "nofwords", 0 },
1288 { rtfSpecialChar, rtfINChars, "nofchars", 0 },
1289 { rtfSpecialChar, rtfIIntID, "id", 0 },
1291 { rtfSpecialChar, rtfCurHeadDate, "chdate", 0 },
1292 { rtfSpecialChar, rtfCurHeadDateLong, "chdpl", 0 },
1293 { rtfSpecialChar, rtfCurHeadDateAbbrev, "chdpa", 0 },
1294 { rtfSpecialChar, rtfCurHeadTime, "chtime", 0 },
1295 { rtfSpecialChar, rtfCurHeadPage, "chpgn", 0 },
1296 { rtfSpecialChar, rtfSectNum, "sectnum", 0 },
1297 { rtfSpecialChar, rtfCurFNote, "chftn", 0 },
1298 { rtfSpecialChar, rtfCurAnnotRef, "chatn", 0 },
1299 { rtfSpecialChar, rtfFNoteSep, "chftnsep", 0 },
1300 { rtfSpecialChar, rtfFNoteCont, "chftnsepc", 0 },
1301 { rtfSpecialChar, rtfCell, "cell", 0 },
1302 { rtfSpecialChar, rtfRow, "row", 0 },
1303 { rtfSpecialChar, rtfPar, "par", 0 },
1304 /* newline and carriage return are synonyms for */
1305 /* \par when they are preceded by a \ character */
1306 { rtfSpecialChar, rtfPar, "\n", 0 },
1307 { rtfSpecialChar, rtfPar, "\r", 0 },
1308 { rtfSpecialChar, rtfSect, "sect", 0 },
1309 { rtfSpecialChar, rtfPage, "page", 0 },
1310 { rtfSpecialChar, rtfColumn, "column", 0 },
1311 { rtfSpecialChar, rtfLine, "line", 0 },
1312 { rtfSpecialChar, rtfSoftPage, "softpage", 0 },
1313 { rtfSpecialChar, rtfSoftColumn, "softcol", 0 },
1314 { rtfSpecialChar, rtfSoftLine, "softline", 0 },
1315 { rtfSpecialChar, rtfSoftLineHt, "softlheight", 0 },
1316 { rtfSpecialChar, rtfTab, "tab", 0 },
1317 { rtfSpecialChar, rtfEmDash, "emdash", 0 },
1318 { rtfSpecialChar, rtfEnDash, "endash", 0 },
1319 { rtfSpecialChar, rtfEmSpace, "emspace", 0 },
1320 { rtfSpecialChar, rtfEnSpace, "enspace", 0 },
1321 { rtfSpecialChar, rtfBullet, "bullet", 0 },
1322 { rtfSpecialChar, rtfLQuote, "lquote", 0 },
1323 { rtfSpecialChar, rtfRQuote, "rquote", 0 },
1324 { rtfSpecialChar, rtfLDblQuote, "ldblquote", 0 },
1325 { rtfSpecialChar, rtfRDblQuote, "rdblquote", 0 },
1326 { rtfSpecialChar, rtfFormula, "|", 0 },
1327 { rtfSpecialChar, rtfNoBrkSpace, "~", 0 },
1328 { rtfSpecialChar, rtfNoReqHyphen, "-", 0 },
1329 { rtfSpecialChar, rtfNoBrkHyphen, "_", 0 },
1330 { rtfSpecialChar, rtfOptDest, "*", 0 },
1331 { rtfSpecialChar, rtfLTRMark, "ltrmark", 0 },
1332 { rtfSpecialChar, rtfRTLMark, "rtlmark", 0 },
1333 { rtfSpecialChar, rtfNoWidthJoiner, "zwj", 0 },
1334 { rtfSpecialChar, rtfNoWidthNonJoiner, "zwnj", 0 },
1335 /* is this valid? */
1336 { rtfSpecialChar, rtfCurHeadPict, "chpict", 0 },
1337 { rtfSpecialChar, rtfUnicode, "u", 0 },
1338 { rtfSpecialChar, rtfNestCell, "nestcell", 0 },
1339 { rtfSpecialChar, rtfNestRow, "nestrow", 0 },
1342 * Character formatting attributes
1345 { rtfCharAttr, rtfPlain, "plain", 0 },
1346 { rtfCharAttr, rtfBold, "b", 0 },
1347 { rtfCharAttr, rtfAllCaps, "caps", 0 },
1348 { rtfCharAttr, rtfDeleted, "deleted", 0 },
1349 { rtfCharAttr, rtfSubScript, "dn", 0 },
1350 { rtfCharAttr, rtfSubScrShrink, "sub", 0 },
1351 { rtfCharAttr, rtfNoSuperSub, "nosupersub", 0 },
1352 { rtfCharAttr, rtfExpand, "expnd", 0 },
1353 { rtfCharAttr, rtfExpandTwips, "expndtw", 0 },
1354 { rtfCharAttr, rtfKerning, "kerning", 0 },
1355 { rtfCharAttr, rtfFontNum, "f", 0 },
1356 { rtfCharAttr, rtfFontSize, "fs", 0 },
1357 { rtfCharAttr, rtfItalic, "i", 0 },
1358 { rtfCharAttr, rtfOutline, "outl", 0 },
1359 { rtfCharAttr, rtfRevised, "revised", 0 },
1360 { rtfCharAttr, rtfRevAuthor, "revauth", 0 },
1361 { rtfCharAttr, rtfRevDTTM, "revdttm", 0 },
1362 { rtfCharAttr, rtfSmallCaps, "scaps", 0 },
1363 { rtfCharAttr, rtfShadow, "shad", 0 },
1364 { rtfCharAttr, rtfStrikeThru, "strike", 0 },
1365 { rtfCharAttr, rtfUnderline, "ul", 0 },
1366 { rtfCharAttr, rtfDotUnderline, "uld", 0 },
1367 { rtfCharAttr, rtfDbUnderline, "uldb", 0 },
1368 { rtfCharAttr, rtfNoUnderline, "ulnone", 0 },
1369 { rtfCharAttr, rtfWordUnderline, "ulw", 0 },
1370 { rtfCharAttr, rtfSuperScript, "up", 0 },
1371 { rtfCharAttr, rtfSuperScrShrink, "super", 0 },
1372 { rtfCharAttr, rtfInvisible, "v", 0 },
1373 { rtfCharAttr, rtfForeColor, "cf", 0 },
1374 { rtfCharAttr, rtfBackColor, "cb", 0 },
1375 { rtfCharAttr, rtfRTLChar, "rtlch", 0 },
1376 { rtfCharAttr, rtfLTRChar, "ltrch", 0 },
1377 { rtfCharAttr, rtfCharStyleNum, "cs", 0 },
1378 { rtfCharAttr, rtfCharCharSet, "cchs", 0 },
1379 { rtfCharAttr, rtfLanguage, "lang", 0 },
1380 /* this has disappeared from spec 1.2 */
1381 { rtfCharAttr, rtfGray, "gray", 0 },
1382 { rtfCharAttr, rtfUnicodeLength, "uc", 0 },
1385 * Paragraph formatting attributes
1388 { rtfParAttr, rtfParDef, "pard", 0 },
1389 { rtfParAttr, rtfStyleNum, "s", 0 },
1390 { rtfParAttr, rtfHyphenate, "hyphpar", 0 },
1391 { rtfParAttr, rtfInTable, "intbl", 0 },
1392 { rtfParAttr, rtfKeep, "keep", 0 },
1393 { rtfParAttr, rtfNoWidowControl, "nowidctlpar", 0 },
1394 { rtfParAttr, rtfKeepNext, "keepn", 0 },
1395 { rtfParAttr, rtfOutlineLevel, "level", 0 },
1396 { rtfParAttr, rtfNoLineNum, "noline", 0 },
1397 { rtfParAttr, rtfPBBefore, "pagebb", 0 },
1398 { rtfParAttr, rtfSideBySide, "sbys", 0 },
1399 { rtfParAttr, rtfQuadLeft, "ql", 0 },
1400 { rtfParAttr, rtfQuadRight, "qr", 0 },
1401 { rtfParAttr, rtfQuadJust, "qj", 0 },
1402 { rtfParAttr, rtfQuadCenter, "qc", 0 },
1403 { rtfParAttr, rtfFirstIndent, "fi", 0 },
1404 { rtfParAttr, rtfLeftIndent, "li", 0 },
1405 { rtfParAttr, rtfRightIndent, "ri", 0 },
1406 { rtfParAttr, rtfSpaceBefore, "sb", 0 },
1407 { rtfParAttr, rtfSpaceAfter, "sa", 0 },
1408 { rtfParAttr, rtfSpaceBetween, "sl", 0 },
1409 { rtfParAttr, rtfSpaceMultiply, "slmult", 0 },
1411 { rtfParAttr, rtfSubDocument, "subdocument", 0 },
1413 { rtfParAttr, rtfRTLPar, "rtlpar", 0 },
1414 { rtfParAttr, rtfLTRPar, "ltrpar", 0 },
1416 { rtfParAttr, rtfTabPos, "tx", 0 },
1418 * FrameMaker writes \tql (to mean left-justified tab, apparently)
1419 * although it's not in the spec. It's also redundant, since lj
1420 * tabs are the default.
1422 { rtfParAttr, rtfTabLeft, "tql", 0 },
1423 { rtfParAttr, rtfTabRight, "tqr", 0 },
1424 { rtfParAttr, rtfTabCenter, "tqc", 0 },
1425 { rtfParAttr, rtfTabDecimal, "tqdec", 0 },
1426 { rtfParAttr, rtfTabBar, "tb", 0 },
1427 { rtfParAttr, rtfLeaderDot, "tldot", 0 },
1428 { rtfParAttr, rtfLeaderHyphen, "tlhyph", 0 },
1429 { rtfParAttr, rtfLeaderUnder, "tlul", 0 },
1430 { rtfParAttr, rtfLeaderThick, "tlth", 0 },
1431 { rtfParAttr, rtfLeaderEqual, "tleq", 0 },
1433 { rtfParAttr, rtfParLevel, "pnlvl", 0 },
1434 { rtfParAttr, rtfParBullet, "pnlvlblt", 0 },
1435 { rtfParAttr, rtfParSimple, "pnlvlbody", 0 },
1436 { rtfParAttr, rtfParNumCont, "pnlvlcont", 0 },
1437 { rtfParAttr, rtfParNumOnce, "pnnumonce", 0 },
1438 { rtfParAttr, rtfParNumAcross, "pnacross", 0 },
1439 { rtfParAttr, rtfParHangIndent, "pnhang", 0 },
1440 { rtfParAttr, rtfParNumRestart, "pnrestart", 0 },
1441 { rtfParAttr, rtfParNumCardinal, "pncard", 0 },
1442 { rtfParAttr, rtfParNumDecimal, "pndec", 0 },
1443 { rtfParAttr, rtfParNumULetter, "pnucltr", 0 },
1444 { rtfParAttr, rtfParNumURoman, "pnucrm", 0 },
1445 { rtfParAttr, rtfParNumLLetter, "pnlcltr", 0 },
1446 { rtfParAttr, rtfParNumLRoman, "pnlcrm", 0 },
1447 { rtfParAttr, rtfParNumOrdinal, "pnord", 0 },
1448 { rtfParAttr, rtfParNumOrdinalText, "pnordt", 0 },
1449 { rtfParAttr, rtfParNumBold, "pnb", 0 },
1450 { rtfParAttr, rtfParNumItalic, "pni", 0 },
1451 { rtfParAttr, rtfParNumAllCaps, "pncaps", 0 },
1452 { rtfParAttr, rtfParNumSmallCaps, "pnscaps", 0 },
1453 { rtfParAttr, rtfParNumUnder, "pnul", 0 },
1454 { rtfParAttr, rtfParNumDotUnder, "pnuld", 0 },
1455 { rtfParAttr, rtfParNumDbUnder, "pnuldb", 0 },
1456 { rtfParAttr, rtfParNumNoUnder, "pnulnone", 0 },
1457 { rtfParAttr, rtfParNumWordUnder, "pnulw", 0 },
1458 { rtfParAttr, rtfParNumStrikethru, "pnstrike", 0 },
1459 { rtfParAttr, rtfParNumForeColor, "pncf", 0 },
1460 { rtfParAttr, rtfParNumFont, "pnf", 0 },
1461 { rtfParAttr, rtfParNumFontSize, "pnfs", 0 },
1462 { rtfParAttr, rtfParNumIndent, "pnindent", 0 },
1463 { rtfParAttr, rtfParNumSpacing, "pnsp", 0 },
1464 { rtfParAttr, rtfParNumInclPrev, "pnprev", 0 },
1465 { rtfParAttr, rtfParNumCenter, "pnqc", 0 },
1466 { rtfParAttr, rtfParNumLeft, "pnql", 0 },
1467 { rtfParAttr, rtfParNumRight, "pnqr", 0 },
1468 { rtfParAttr, rtfParNumStartAt, "pnstart", 0 },
1470 { rtfParAttr, rtfBorderTop, "brdrt", 0 },
1471 { rtfParAttr, rtfBorderBottom, "brdrb", 0 },
1472 { rtfParAttr, rtfBorderLeft, "brdrl", 0 },
1473 { rtfParAttr, rtfBorderRight, "brdrr", 0 },
1474 { rtfParAttr, rtfBorderBetween, "brdrbtw", 0 },
1475 { rtfParAttr, rtfBorderBar, "brdrbar", 0 },
1476 { rtfParAttr, rtfBorderBox, "box", 0 },
1477 { rtfParAttr, rtfBorderSingle, "brdrs", 0 },
1478 { rtfParAttr, rtfBorderThick, "brdrth", 0 },
1479 { rtfParAttr, rtfBorderShadow, "brdrsh", 0 },
1480 { rtfParAttr, rtfBorderDouble, "brdrdb", 0 },
1481 { rtfParAttr, rtfBorderDot, "brdrdot", 0 },
1482 { rtfParAttr, rtfBorderDot, "brdrdash", 0 },
1483 { rtfParAttr, rtfBorderHair, "brdrhair", 0 },
1484 { rtfParAttr, rtfBorderWidth, "brdrw", 0 },
1485 { rtfParAttr, rtfBorderColor, "brdrcf", 0 },
1486 { rtfParAttr, rtfBorderSpace, "brsp", 0 },
1488 { rtfParAttr, rtfShading, "shading", 0 },
1489 { rtfParAttr, rtfBgPatH, "bghoriz", 0 },
1490 { rtfParAttr, rtfBgPatV, "bgvert", 0 },
1491 { rtfParAttr, rtfFwdDiagBgPat, "bgfdiag", 0 },
1492 { rtfParAttr, rtfBwdDiagBgPat, "bgbdiag", 0 },
1493 { rtfParAttr, rtfHatchBgPat, "bgcross", 0 },
1494 { rtfParAttr, rtfDiagHatchBgPat, "bgdcross", 0 },
1495 { rtfParAttr, rtfDarkBgPatH, "bgdkhoriz", 0 },
1496 { rtfParAttr, rtfDarkBgPatV, "bgdkvert", 0 },
1497 { rtfParAttr, rtfFwdDarkBgPat, "bgdkfdiag", 0 },
1498 { rtfParAttr, rtfBwdDarkBgPat, "bgdkbdiag", 0 },
1499 { rtfParAttr, rtfDarkHatchBgPat, "bgdkcross", 0 },
1500 { rtfParAttr, rtfDarkDiagHatchBgPat, "bgdkdcross", 0 },
1501 { rtfParAttr, rtfBgPatLineColor, "cfpat", 0 },
1502 { rtfParAttr, rtfBgPatColor, "cbpat", 0 },
1503 { rtfParAttr, rtfNestLevel, "itap", 0 },
1506 * Section formatting attributes
1509 { rtfSectAttr, rtfSectDef, "sectd", 0 },
1510 { rtfSectAttr, rtfENoteHere, "endnhere", 0 },
1511 { rtfSectAttr, rtfPrtBinFirst, "binfsxn", 0 },
1512 { rtfSectAttr, rtfPrtBin, "binsxn", 0 },
1513 { rtfSectAttr, rtfSectStyleNum, "ds", 0 },
1515 { rtfSectAttr, rtfNoBreak, "sbknone", 0 },
1516 { rtfSectAttr, rtfColBreak, "sbkcol", 0 },
1517 { rtfSectAttr, rtfPageBreak, "sbkpage", 0 },
1518 { rtfSectAttr, rtfEvenBreak, "sbkeven", 0 },
1519 { rtfSectAttr, rtfOddBreak, "sbkodd", 0 },
1521 { rtfSectAttr, rtfColumns, "cols", 0 },
1522 { rtfSectAttr, rtfColumnSpace, "colsx", 0 },
1523 { rtfSectAttr, rtfColumnNumber, "colno", 0 },
1524 { rtfSectAttr, rtfColumnSpRight, "colsr", 0 },
1525 { rtfSectAttr, rtfColumnWidth, "colw", 0 },
1526 { rtfSectAttr, rtfColumnLine, "linebetcol", 0 },
1528 { rtfSectAttr, rtfLineModulus, "linemod", 0 },
1529 { rtfSectAttr, rtfLineDist, "linex", 0 },
1530 { rtfSectAttr, rtfLineStarts, "linestarts", 0 },
1531 { rtfSectAttr, rtfLineRestart, "linerestart", 0 },
1532 { rtfSectAttr, rtfLineRestartPg, "lineppage", 0 },
1533 { rtfSectAttr, rtfLineCont, "linecont", 0 },
1535 { rtfSectAttr, rtfSectPageWid, "pgwsxn", 0 },
1536 { rtfSectAttr, rtfSectPageHt, "pghsxn", 0 },
1537 { rtfSectAttr, rtfSectMarginLeft, "marglsxn", 0 },
1538 { rtfSectAttr, rtfSectMarginRight, "margrsxn", 0 },
1539 { rtfSectAttr, rtfSectMarginTop, "margtsxn", 0 },
1540 { rtfSectAttr, rtfSectMarginBottom, "margbsxn", 0 },
1541 { rtfSectAttr, rtfSectMarginGutter, "guttersxn", 0 },
1542 { rtfSectAttr, rtfSectLandscape, "lndscpsxn", 0 },
1543 { rtfSectAttr, rtfTitleSpecial, "titlepg", 0 },
1544 { rtfSectAttr, rtfHeaderY, "headery", 0 },
1545 { rtfSectAttr, rtfFooterY, "footery", 0 },
1547 { rtfSectAttr, rtfPageStarts, "pgnstarts", 0 },
1548 { rtfSectAttr, rtfPageCont, "pgncont", 0 },
1549 { rtfSectAttr, rtfPageRestart, "pgnrestart", 0 },
1550 { rtfSectAttr, rtfPageNumRight, "pgnx", 0 },
1551 { rtfSectAttr, rtfPageNumTop, "pgny", 0 },
1552 { rtfSectAttr, rtfPageDecimal, "pgndec", 0 },
1553 { rtfSectAttr, rtfPageURoman, "pgnucrm", 0 },
1554 { rtfSectAttr, rtfPageLRoman, "pgnlcrm", 0 },
1555 { rtfSectAttr, rtfPageULetter, "pgnucltr", 0 },
1556 { rtfSectAttr, rtfPageLLetter, "pgnlcltr", 0 },
1557 { rtfSectAttr, rtfPageNumHyphSep, "pgnhnsh", 0 },
1558 { rtfSectAttr, rtfPageNumSpaceSep, "pgnhnsp", 0 },
1559 { rtfSectAttr, rtfPageNumColonSep, "pgnhnsc", 0 },
1560 { rtfSectAttr, rtfPageNumEmdashSep, "pgnhnsm", 0 },
1561 { rtfSectAttr, rtfPageNumEndashSep, "pgnhnsn", 0 },
1563 { rtfSectAttr, rtfTopVAlign, "vertalt", 0 },
1564 /* misspelled as "vertal" in specification 1.0 */
1565 { rtfSectAttr, rtfBottomVAlign, "vertalb", 0 },
1566 { rtfSectAttr, rtfCenterVAlign, "vertalc", 0 },
1567 { rtfSectAttr, rtfJustVAlign, "vertalj", 0 },
1569 { rtfSectAttr, rtfRTLSect, "rtlsect", 0 },
1570 { rtfSectAttr, rtfLTRSect, "ltrsect", 0 },
1572 /* I've seen these in an old spec, but not in real files... */
1573 /*rtfSectAttr, rtfNoBreak, "nobreak", 0,*/
1574 /*rtfSectAttr, rtfColBreak, "colbreak", 0,*/
1575 /*rtfSectAttr, rtfPageBreak, "pagebreak", 0,*/
1576 /*rtfSectAttr, rtfEvenBreak, "evenbreak", 0,*/
1577 /*rtfSectAttr, rtfOddBreak, "oddbreak", 0,*/
1580 * Document formatting attributes
1583 { rtfDocAttr, rtfDefTab, "deftab", 0 },
1584 { rtfDocAttr, rtfHyphHotZone, "hyphhotz", 0 },
1585 { rtfDocAttr, rtfHyphConsecLines, "hyphconsec", 0 },
1586 { rtfDocAttr, rtfHyphCaps, "hyphcaps", 0 },
1587 { rtfDocAttr, rtfHyphAuto, "hyphauto", 0 },
1588 { rtfDocAttr, rtfLineStart, "linestart", 0 },
1589 { rtfDocAttr, rtfFracWidth, "fracwidth", 0 },
1590 /* \makeback was given in old version of spec, it's now */
1591 /* listed as \makebackup */
1592 { rtfDocAttr, rtfMakeBackup, "makeback", 0 },
1593 { rtfDocAttr, rtfMakeBackup, "makebackup", 0 },
1594 { rtfDocAttr, rtfRTFDefault, "defformat", 0 },
1595 { rtfDocAttr, rtfPSOverlay, "psover", 0 },
1596 { rtfDocAttr, rtfDocTemplate, "doctemp", 0 },
1597 { rtfDocAttr, rtfDefLanguage, "deflang", 0 },
1599 { rtfDocAttr, rtfFENoteType, "fet", 0 },
1600 { rtfDocAttr, rtfFNoteEndSect, "endnotes", 0 },
1601 { rtfDocAttr, rtfFNoteEndDoc, "enddoc", 0 },
1602 { rtfDocAttr, rtfFNoteText, "ftntj", 0 },
1603 { rtfDocAttr, rtfFNoteBottom, "ftnbj", 0 },
1604 { rtfDocAttr, rtfENoteEndSect, "aendnotes", 0 },
1605 { rtfDocAttr, rtfENoteEndDoc, "aenddoc", 0 },
1606 { rtfDocAttr, rtfENoteText, "aftntj", 0 },
1607 { rtfDocAttr, rtfENoteBottom, "aftnbj", 0 },
1608 { rtfDocAttr, rtfFNoteStart, "ftnstart", 0 },
1609 { rtfDocAttr, rtfENoteStart, "aftnstart", 0 },
1610 { rtfDocAttr, rtfFNoteRestartPage, "ftnrstpg", 0 },
1611 { rtfDocAttr, rtfFNoteRestart, "ftnrestart", 0 },
1612 { rtfDocAttr, rtfFNoteRestartCont, "ftnrstcont", 0 },
1613 { rtfDocAttr, rtfENoteRestart, "aftnrestart", 0 },
1614 { rtfDocAttr, rtfENoteRestartCont, "aftnrstcont", 0 },
1615 { rtfDocAttr, rtfFNoteNumArabic, "ftnnar", 0 },
1616 { rtfDocAttr, rtfFNoteNumLLetter, "ftnnalc", 0 },
1617 { rtfDocAttr, rtfFNoteNumULetter, "ftnnauc", 0 },
1618 { rtfDocAttr, rtfFNoteNumLRoman, "ftnnrlc", 0 },
1619 { rtfDocAttr, rtfFNoteNumURoman, "ftnnruc", 0 },
1620 { rtfDocAttr, rtfFNoteNumChicago, "ftnnchi", 0 },
1621 { rtfDocAttr, rtfENoteNumArabic, "aftnnar", 0 },
1622 { rtfDocAttr, rtfENoteNumLLetter, "aftnnalc", 0 },
1623 { rtfDocAttr, rtfENoteNumULetter, "aftnnauc", 0 },
1624 { rtfDocAttr, rtfENoteNumLRoman, "aftnnrlc", 0 },
1625 { rtfDocAttr, rtfENoteNumURoman, "aftnnruc", 0 },
1626 { rtfDocAttr, rtfENoteNumChicago, "aftnnchi", 0 },
1628 { rtfDocAttr, rtfPaperWidth, "paperw", 0 },
1629 { rtfDocAttr, rtfPaperHeight, "paperh", 0 },
1630 { rtfDocAttr, rtfPaperSize, "psz", 0 },
1631 { rtfDocAttr, rtfLeftMargin, "margl", 0 },
1632 { rtfDocAttr, rtfRightMargin, "margr", 0 },
1633 { rtfDocAttr, rtfTopMargin, "margt", 0 },
1634 { rtfDocAttr, rtfBottomMargin, "margb", 0 },
1635 { rtfDocAttr, rtfFacingPage, "facingp", 0 },
1636 { rtfDocAttr, rtfGutterWid, "gutter", 0 },
1637 { rtfDocAttr, rtfMirrorMargin, "margmirror", 0 },
1638 { rtfDocAttr, rtfLandscape, "landscape", 0 },
1639 { rtfDocAttr, rtfPageStart, "pgnstart", 0 },
1640 { rtfDocAttr, rtfWidowCtrl, "widowctrl", 0 },
1642 { rtfDocAttr, rtfLinkStyles, "linkstyles", 0 },
1644 { rtfDocAttr, rtfNoAutoTabIndent, "notabind", 0 },
1645 { rtfDocAttr, rtfWrapSpaces, "wraptrsp", 0 },
1646 { rtfDocAttr, rtfPrintColorsBlack, "prcolbl", 0 },
1647 { rtfDocAttr, rtfNoExtraSpaceRL, "noextrasprl", 0 },
1648 { rtfDocAttr, rtfNoColumnBalance, "nocolbal", 0 },
1649 { rtfDocAttr, rtfCvtMailMergeQuote, "cvmme", 0 },
1650 { rtfDocAttr, rtfSuppressTopSpace, "sprstsp", 0 },
1651 { rtfDocAttr, rtfSuppressPreParSpace, "sprsspbf", 0 },
1652 { rtfDocAttr, rtfCombineTblBorders, "otblrul", 0 },
1653 { rtfDocAttr, rtfTranspMetafiles, "transmf", 0 },
1654 { rtfDocAttr, rtfSwapBorders, "swpbdr", 0 },
1655 { rtfDocAttr, rtfShowHardBreaks, "brkfrm", 0 },
1657 { rtfDocAttr, rtfFormProtected, "formprot", 0 },
1658 { rtfDocAttr, rtfAllProtected, "allprot", 0 },
1659 { rtfDocAttr, rtfFormShading, "formshade", 0 },
1660 { rtfDocAttr, rtfFormDisplay, "formdisp", 0 },
1661 { rtfDocAttr, rtfPrintData, "printdata", 0 },
1663 { rtfDocAttr, rtfRevProtected, "revprot", 0 },
1664 { rtfDocAttr, rtfRevisions, "revisions", 0 },
1665 { rtfDocAttr, rtfRevDisplay, "revprop", 0 },
1666 { rtfDocAttr, rtfRevBar, "revbar", 0 },
1668 { rtfDocAttr, rtfAnnotProtected, "annotprot", 0 },
1670 { rtfDocAttr, rtfRTLDoc, "rtldoc", 0 },
1671 { rtfDocAttr, rtfLTRDoc, "ltrdoc", 0 },
1673 { rtfDocAttr, rtfAnsiCodePage, "ansicpg", 0 },
1674 { rtfDocAttr, rtfUTF8RTF, "urtf", 0 },
1680 { rtfStyleAttr, rtfAdditive, "additive", 0 },
1681 { rtfStyleAttr, rtfBasedOn, "sbasedon", 0 },
1682 { rtfStyleAttr, rtfNext, "snext", 0 },
1685 * Picture attributes
1688 { rtfPictAttr, rtfMacQD, "macpict", 0 },
1689 { rtfPictAttr, rtfPMMetafile, "pmmetafile", 0 },
1690 { rtfPictAttr, rtfWinMetafile, "wmetafile", 0 },
1691 { rtfPictAttr, rtfDevIndBitmap, "dibitmap", 0 },
1692 { rtfPictAttr, rtfWinBitmap, "wbitmap", 0 },
1693 { rtfPictAttr, rtfEmfBlip, "emfblip", 0 },
1694 { rtfPictAttr, rtfPixelBits, "wbmbitspixel", 0 },
1695 { rtfPictAttr, rtfBitmapPlanes, "wbmplanes", 0 },
1696 { rtfPictAttr, rtfBitmapWid, "wbmwidthbytes", 0 },
1698 { rtfPictAttr, rtfPicWid, "picw", 0 },
1699 { rtfPictAttr, rtfPicHt, "pich", 0 },
1700 { rtfPictAttr, rtfPicGoalWid, "picwgoal", 0 },
1701 { rtfPictAttr, rtfPicGoalHt, "pichgoal", 0 },
1702 /* these two aren't in the spec, but some writers emit them */
1703 { rtfPictAttr, rtfPicGoalWid, "picwGoal", 0 },
1704 { rtfPictAttr, rtfPicGoalHt, "pichGoal", 0 },
1705 { rtfPictAttr, rtfPicScaleX, "picscalex", 0 },
1706 { rtfPictAttr, rtfPicScaleY, "picscaley", 0 },
1707 { rtfPictAttr, rtfPicScaled, "picscaled", 0 },
1708 { rtfPictAttr, rtfPicCropTop, "piccropt", 0 },
1709 { rtfPictAttr, rtfPicCropBottom, "piccropb", 0 },
1710 { rtfPictAttr, rtfPicCropLeft, "piccropl", 0 },
1711 { rtfPictAttr, rtfPicCropRight, "piccropr", 0 },
1713 { rtfPictAttr, rtfPicMFHasBitmap, "picbmp", 0 },
1714 { rtfPictAttr, rtfPicMFBitsPerPixel, "picbpp", 0 },
1716 { rtfPictAttr, rtfPicBinary, "bin", 0 },
1719 * NeXT graphic attributes
1722 { rtfNeXTGrAttr, rtfNeXTGWidth, "width", 0 },
1723 { rtfNeXTGrAttr, rtfNeXTGHeight, "height", 0 },
1729 { rtfDestination, rtfFontTbl, "fonttbl", 0 },
1730 { rtfDestination, rtfFontAltName, "falt", 0 },
1731 { rtfDestination, rtfEmbeddedFont, "fonteb", 0 },
1732 { rtfDestination, rtfFontFile, "fontfile", 0 },
1733 { rtfDestination, rtfFileTbl, "filetbl", 0 },
1734 { rtfDestination, rtfFileInfo, "file", 0 },
1735 { rtfDestination, rtfColorTbl, "colortbl", 0 },
1736 { rtfDestination, rtfStyleSheet, "stylesheet", 0 },
1737 { rtfDestination, rtfKeyCode, "keycode", 0 },
1738 { rtfDestination, rtfRevisionTbl, "revtbl", 0 },
1739 { rtfDestination, rtfGenerator, "generator", 0 },
1740 { rtfDestination, rtfInfo, "info", 0 },
1741 { rtfDestination, rtfITitle, "title", 0 },
1742 { rtfDestination, rtfISubject, "subject", 0 },
1743 { rtfDestination, rtfIAuthor, "author", 0 },
1744 { rtfDestination, rtfIOperator, "operator", 0 },
1745 { rtfDestination, rtfIKeywords, "keywords", 0 },
1746 { rtfDestination, rtfIComment, "comment", 0 },
1747 { rtfDestination, rtfIVersion, "version", 0 },
1748 { rtfDestination, rtfIDoccomm, "doccomm", 0 },
1749 /* \verscomm may not exist -- was seen in earlier spec version */
1750 { rtfDestination, rtfIVerscomm, "verscomm", 0 },
1751 { rtfDestination, rtfNextFile, "nextfile", 0 },
1752 { rtfDestination, rtfTemplate, "template", 0 },
1753 { rtfDestination, rtfFNSep, "ftnsep", 0 },
1754 { rtfDestination, rtfFNContSep, "ftnsepc", 0 },
1755 { rtfDestination, rtfFNContNotice, "ftncn", 0 },
1756 { rtfDestination, rtfENSep, "aftnsep", 0 },
1757 { rtfDestination, rtfENContSep, "aftnsepc", 0 },
1758 { rtfDestination, rtfENContNotice, "aftncn", 0 },
1759 { rtfDestination, rtfPageNumLevel, "pgnhn", 0 },
1760 { rtfDestination, rtfParNumLevelStyle, "pnseclvl", 0 },
1761 { rtfDestination, rtfHeader, "header", 0 },
1762 { rtfDestination, rtfFooter, "footer", 0 },
1763 { rtfDestination, rtfHeaderLeft, "headerl", 0 },
1764 { rtfDestination, rtfHeaderRight, "headerr", 0 },
1765 { rtfDestination, rtfHeaderFirst, "headerf", 0 },
1766 { rtfDestination, rtfFooterLeft, "footerl", 0 },
1767 { rtfDestination, rtfFooterRight, "footerr", 0 },
1768 { rtfDestination, rtfFooterFirst, "footerf", 0 },
1769 { rtfDestination, rtfParNumText, "pntext", 0 },
1770 { rtfDestination, rtfParNumbering, "pn", 0 },
1771 { rtfDestination, rtfParNumTextAfter, "pntexta", 0 },
1772 { rtfDestination, rtfParNumTextBefore, "pntextb", 0 },
1773 { rtfDestination, rtfBookmarkStart, "bkmkstart", 0 },
1774 { rtfDestination, rtfBookmarkEnd, "bkmkend", 0 },
1775 { rtfDestination, rtfPict, "pict", 0 },
1776 { rtfDestination, rtfObject, "object", 0 },
1777 { rtfDestination, rtfObjClass, "objclass", 0 },
1778 { rtfDestination, rtfObjName, "objname", 0 },
1779 { rtfObjAttr, rtfObjTime, "objtime", 0 },
1780 { rtfDestination, rtfObjData, "objdata", 0 },
1781 { rtfDestination, rtfObjAlias, "objalias", 0 },
1782 { rtfDestination, rtfObjSection, "objsect", 0 },
1783 /* objitem and objtopic aren't documented in the spec! */
1784 { rtfDestination, rtfObjItem, "objitem", 0 },
1785 { rtfDestination, rtfObjTopic, "objtopic", 0 },
1786 { rtfDestination, rtfObjResult, "result", 0 },
1787 { rtfDestination, rtfDrawObject, "do", 0 },
1788 { rtfDestination, rtfFootnote, "footnote", 0 },
1789 { rtfDestination, rtfAnnotRefStart, "atrfstart", 0 },
1790 { rtfDestination, rtfAnnotRefEnd, "atrfend", 0 },
1791 { rtfDestination, rtfAnnotID, "atnid", 0 },
1792 { rtfDestination, rtfAnnotAuthor, "atnauthor", 0 },
1793 { rtfDestination, rtfAnnotation, "annotation", 0 },
1794 { rtfDestination, rtfAnnotRef, "atnref", 0 },
1795 { rtfDestination, rtfAnnotTime, "atntime", 0 },
1796 { rtfDestination, rtfAnnotIcon, "atnicn", 0 },
1797 { rtfDestination, rtfField, "field", 0 },
1798 { rtfDestination, rtfFieldInst, "fldinst", 0 },
1799 { rtfDestination, rtfFieldResult, "fldrslt", 0 },
1800 { rtfDestination, rtfDataField, "datafield", 0 },
1801 { rtfDestination, rtfIndex, "xe", 0 },
1802 { rtfDestination, rtfIndexText, "txe", 0 },
1803 { rtfDestination, rtfIndexRange, "rxe", 0 },
1804 { rtfDestination, rtfTOC, "tc", 0 },
1805 { rtfDestination, rtfNeXTGraphic, "NeXTGraphic", 0 },
1806 { rtfDestination, rtfNestTableProps, "nesttableprops", 0 },
1807 { rtfDestination, rtfNoNestTables, "nonesttables", 0 },
1813 { rtfFontFamily, rtfFFNil, "fnil", 0 },
1814 { rtfFontFamily, rtfFFRoman, "froman", 0 },
1815 { rtfFontFamily, rtfFFSwiss, "fswiss", 0 },
1816 { rtfFontFamily, rtfFFModern, "fmodern", 0 },
1817 { rtfFontFamily, rtfFFScript, "fscript", 0 },
1818 { rtfFontFamily, rtfFFDecor, "fdecor", 0 },
1819 { rtfFontFamily, rtfFFTech, "ftech", 0 },
1820 { rtfFontFamily, rtfFFBidirectional, "fbidi", 0 },
1826 { rtfFontAttr, rtfFontCharSet, "fcharset", 0 },
1827 { rtfFontAttr, rtfFontPitch, "fprq", 0 },
1828 { rtfFontAttr, rtfFontCodePage, "cpg", 0 },
1829 { rtfFontAttr, rtfFTypeNil, "ftnil", 0 },
1830 { rtfFontAttr, rtfFTypeTrueType, "fttruetype", 0 },
1833 * File table attributes
1836 { rtfFileAttr, rtfFileNum, "fid", 0 },
1837 { rtfFileAttr, rtfFileRelPath, "frelative", 0 },
1838 { rtfFileAttr, rtfFileOSNum, "fosnum", 0 },
1844 { rtfFileSource, rtfSrcMacintosh, "fvalidmac", 0 },
1845 { rtfFileSource, rtfSrcDOS, "fvaliddos", 0 },
1846 { rtfFileSource, rtfSrcNTFS, "fvalidntfs", 0 },
1847 { rtfFileSource, rtfSrcHPFS, "fvalidhpfs", 0 },
1848 { rtfFileSource, rtfSrcNetwork, "fnetwork", 0 },
1854 { rtfColorName, rtfRed, "red", 0 },
1855 { rtfColorName, rtfGreen, "green", 0 },
1856 { rtfColorName, rtfBlue, "blue", 0 },
1862 { rtfCharSet, rtfMacCharSet, "mac", 0 },
1863 { rtfCharSet, rtfAnsiCharSet, "ansi", 0 },
1864 { rtfCharSet, rtfPcCharSet, "pc", 0 },
1865 { rtfCharSet, rtfPcaCharSet, "pca", 0 },
1871 { rtfTblAttr, rtfRowDef, "trowd", 0 },
1872 { rtfTblAttr, rtfRowGapH, "trgaph", 0 },
1873 { rtfTblAttr, rtfCellPos, "cellx", 0 },
1874 { rtfTblAttr, rtfMergeRngFirst, "clmgf", 0 },
1875 { rtfTblAttr, rtfMergePrevious, "clmrg", 0 },
1877 { rtfTblAttr, rtfRowLeft, "trql", 0 },
1878 { rtfTblAttr, rtfRowRight, "trqr", 0 },
1879 { rtfTblAttr, rtfRowCenter, "trqc", 0 },
1880 { rtfTblAttr, rtfRowLeftEdge, "trleft", 0 },
1881 { rtfTblAttr, rtfRowHt, "trrh", 0 },
1882 { rtfTblAttr, rtfRowHeader, "trhdr", 0 },
1883 { rtfTblAttr, rtfRowKeep, "trkeep", 0 },
1885 { rtfTblAttr, rtfRTLRow, "rtlrow", 0 },
1886 { rtfTblAttr, rtfLTRRow, "ltrrow", 0 },
1888 { rtfTblAttr, rtfRowBordTop, "trbrdrt", 0 },
1889 { rtfTblAttr, rtfRowBordLeft, "trbrdrl", 0 },
1890 { rtfTblAttr, rtfRowBordBottom, "trbrdrb", 0 },
1891 { rtfTblAttr, rtfRowBordRight, "trbrdrr", 0 },
1892 { rtfTblAttr, rtfRowBordHoriz, "trbrdrh", 0 },
1893 { rtfTblAttr, rtfRowBordVert, "trbrdrv", 0 },
1895 { rtfTblAttr, rtfCellBordBottom, "clbrdrb", 0 },
1896 { rtfTblAttr, rtfCellBordTop, "clbrdrt", 0 },
1897 { rtfTblAttr, rtfCellBordLeft, "clbrdrl", 0 },
1898 { rtfTblAttr, rtfCellBordRight, "clbrdrr", 0 },
1900 { rtfTblAttr, rtfCellShading, "clshdng", 0 },
1901 { rtfTblAttr, rtfCellBgPatH, "clbghoriz", 0 },
1902 { rtfTblAttr, rtfCellBgPatV, "clbgvert", 0 },
1903 { rtfTblAttr, rtfCellFwdDiagBgPat, "clbgfdiag", 0 },
1904 { rtfTblAttr, rtfCellBwdDiagBgPat, "clbgbdiag", 0 },
1905 { rtfTblAttr, rtfCellHatchBgPat, "clbgcross", 0 },
1906 { rtfTblAttr, rtfCellDiagHatchBgPat, "clbgdcross", 0 },
1908 * The spec lists "clbgdkhor", but the corresponding non-cell
1909 * control is "bgdkhoriz". At any rate Macintosh Word seems
1910 * to accept both "clbgdkhor" and "clbgdkhoriz".
1912 { rtfTblAttr, rtfCellDarkBgPatH, "clbgdkhoriz", 0 },
1913 { rtfTblAttr, rtfCellDarkBgPatH, "clbgdkhor", 0 },
1914 { rtfTblAttr, rtfCellDarkBgPatV, "clbgdkvert", 0 },
1915 { rtfTblAttr, rtfCellFwdDarkBgPat, "clbgdkfdiag", 0 },
1916 { rtfTblAttr, rtfCellBwdDarkBgPat, "clbgdkbdiag", 0 },
1917 { rtfTblAttr, rtfCellDarkHatchBgPat, "clbgdkcross", 0 },
1918 { rtfTblAttr, rtfCellDarkDiagHatchBgPat, "clbgdkdcross", 0 },
1919 { rtfTblAttr, rtfCellBgPatLineColor, "clcfpat", 0 },
1920 { rtfTblAttr, rtfCellBgPatColor, "clcbpat", 0 },
1926 { rtfFieldAttr, rtfFieldDirty, "flddirty", 0 },
1927 { rtfFieldAttr, rtfFieldEdited, "fldedit", 0 },
1928 { rtfFieldAttr, rtfFieldLocked, "fldlock", 0 },
1929 { rtfFieldAttr, rtfFieldPrivate, "fldpriv", 0 },
1930 { rtfFieldAttr, rtfFieldAlt, "fldalt", 0 },
1933 * Positioning attributes
1936 { rtfPosAttr, rtfAbsWid, "absw", 0 },
1937 { rtfPosAttr, rtfAbsHt, "absh", 0 },
1939 { rtfPosAttr, rtfRPosMargH, "phmrg", 0 },
1940 { rtfPosAttr, rtfRPosPageH, "phpg", 0 },
1941 { rtfPosAttr, rtfRPosColH, "phcol", 0 },
1942 { rtfPosAttr, rtfPosX, "posx", 0 },
1943 { rtfPosAttr, rtfPosNegX, "posnegx", 0 },
1944 { rtfPosAttr, rtfPosXCenter, "posxc", 0 },
1945 { rtfPosAttr, rtfPosXInside, "posxi", 0 },
1946 { rtfPosAttr, rtfPosXOutSide, "posxo", 0 },
1947 { rtfPosAttr, rtfPosXRight, "posxr", 0 },
1948 { rtfPosAttr, rtfPosXLeft, "posxl", 0 },
1950 { rtfPosAttr, rtfRPosMargV, "pvmrg", 0 },
1951 { rtfPosAttr, rtfRPosPageV, "pvpg", 0 },
1952 { rtfPosAttr, rtfRPosParaV, "pvpara", 0 },
1953 { rtfPosAttr, rtfPosY, "posy", 0 },
1954 { rtfPosAttr, rtfPosNegY, "posnegy", 0 },
1955 { rtfPosAttr, rtfPosYInline, "posyil", 0 },
1956 { rtfPosAttr, rtfPosYTop, "posyt", 0 },
1957 { rtfPosAttr, rtfPosYCenter, "posyc", 0 },
1958 { rtfPosAttr, rtfPosYBottom, "posyb", 0 },
1960 { rtfPosAttr, rtfNoWrap, "nowrap", 0 },
1961 { rtfPosAttr, rtfDistFromTextAll, "dxfrtext", 0 },
1962 { rtfPosAttr, rtfDistFromTextX, "dfrmtxtx", 0 },
1963 { rtfPosAttr, rtfDistFromTextY, "dfrmtxty", 0 },
1964 /* \dyfrtext no longer exists in spec 1.2, apparently */
1965 /* replaced by \dfrmtextx and \dfrmtexty. */
1966 { rtfPosAttr, rtfTextDistY, "dyfrtext", 0 },
1968 { rtfPosAttr, rtfDropCapLines, "dropcapli", 0 },
1969 { rtfPosAttr, rtfDropCapType, "dropcapt", 0 },
1975 { rtfObjAttr, rtfObjEmb, "objemb", 0 },
1976 { rtfObjAttr, rtfObjLink, "objlink", 0 },
1977 { rtfObjAttr, rtfObjAutoLink, "objautlink", 0 },
1978 { rtfObjAttr, rtfObjSubscriber, "objsub", 0 },
1979 { rtfObjAttr, rtfObjPublisher, "objpub", 0 },
1980 { rtfObjAttr, rtfObjICEmb, "objicemb", 0 },
1982 { rtfObjAttr, rtfObjLinkSelf, "linkself", 0 },
1983 { rtfObjAttr, rtfObjLock, "objupdate", 0 },
1984 { rtfObjAttr, rtfObjUpdate, "objlock", 0 },
1986 { rtfObjAttr, rtfObjHt, "objh", 0 },
1987 { rtfObjAttr, rtfObjWid, "objw", 0 },
1988 { rtfObjAttr, rtfObjSetSize, "objsetsize", 0 },
1989 { rtfObjAttr, rtfObjAlign, "objalign", 0 },
1990 { rtfObjAttr, rtfObjTransposeY, "objtransy", 0 },
1991 { rtfObjAttr, rtfObjCropTop, "objcropt", 0 },
1992 { rtfObjAttr, rtfObjCropBottom, "objcropb", 0 },
1993 { rtfObjAttr, rtfObjCropLeft, "objcropl", 0 },
1994 { rtfObjAttr, rtfObjCropRight, "objcropr", 0 },
1995 { rtfObjAttr, rtfObjScaleX, "objscalex", 0 },
1996 { rtfObjAttr, rtfObjScaleY, "objscaley", 0 },
1998 { rtfObjAttr, rtfObjResRTF, "rsltrtf", 0 },
1999 { rtfObjAttr, rtfObjResPict, "rsltpict", 0 },
2000 { rtfObjAttr, rtfObjResBitmap, "rsltbmp", 0 },
2001 { rtfObjAttr, rtfObjResText, "rslttxt", 0 },
2002 { rtfObjAttr, rtfObjResMerge, "rsltmerge", 0 },
2004 { rtfObjAttr, rtfObjBookmarkPubObj, "bkmkpub", 0 },
2005 { rtfObjAttr, rtfObjPubAutoUpdate, "pubauto", 0 },
2008 * Associated character formatting attributes
2011 { rtfACharAttr, rtfACBold, "ab", 0 },
2012 { rtfACharAttr, rtfACAllCaps, "caps", 0 },
2013 { rtfACharAttr, rtfACForeColor, "acf", 0 },
2014 { rtfACharAttr, rtfACSubScript, "adn", 0 },
2015 { rtfACharAttr, rtfACExpand, "aexpnd", 0 },
2016 { rtfACharAttr, rtfACFontNum, "af", 0 },
2017 { rtfACharAttr, rtfACFontSize, "afs", 0 },
2018 { rtfACharAttr, rtfACItalic, "ai", 0 },
2019 { rtfACharAttr, rtfACLanguage, "alang", 0 },
2020 { rtfACharAttr, rtfACOutline, "aoutl", 0 },
2021 { rtfACharAttr, rtfACSmallCaps, "ascaps", 0 },
2022 { rtfACharAttr, rtfACShadow, "ashad", 0 },
2023 { rtfACharAttr, rtfACStrikeThru, "astrike", 0 },
2024 { rtfACharAttr, rtfACUnderline, "aul", 0 },
2025 { rtfACharAttr, rtfACDotUnderline, "auld", 0 },
2026 { rtfACharAttr, rtfACDbUnderline, "auldb", 0 },
2027 { rtfACharAttr, rtfACNoUnderline, "aulnone", 0 },
2028 { rtfACharAttr, rtfACWordUnderline, "aulw", 0 },
2029 { rtfACharAttr, rtfACSuperScript, "aup", 0 },
2032 * Footnote attributes
2035 { rtfFNoteAttr, rtfFNAlt, "ftnalt", 0 },
2038 * Key code attributes
2041 { rtfKeyCodeAttr, rtfAltKey, "alt", 0 },
2042 { rtfKeyCodeAttr, rtfShiftKey, "shift", 0 },
2043 { rtfKeyCodeAttr, rtfControlKey, "ctrl", 0 },
2044 { rtfKeyCodeAttr, rtfFunctionKey, "fn", 0 },
2047 * Bookmark attributes
2050 { rtfBookmarkAttr, rtfBookmarkFirstCol, "bkmkcolf", 0 },
2051 { rtfBookmarkAttr, rtfBookmarkLastCol, "bkmkcoll", 0 },
2054 * Index entry attributes
2057 { rtfIndexAttr, rtfIndexNumber, "xef", 0 },
2058 { rtfIndexAttr, rtfIndexBold, "bxe", 0 },
2059 { rtfIndexAttr, rtfIndexItalic, "ixe", 0 },
2062 * Table of contents attributes
2065 { rtfTOCAttr, rtfTOCType, "tcf", 0 },
2066 { rtfTOCAttr, rtfTOCLevel, "tcl", 0 },
2069 * Drawing object attributes
2072 { rtfDrawAttr, rtfDrawLock, "dolock", 0 },
2073 { rtfDrawAttr, rtfDrawPageRelX, "doxpage", 0 },
2074 { rtfDrawAttr, rtfDrawColumnRelX, "dobxcolumn", 0 },
2075 { rtfDrawAttr, rtfDrawMarginRelX, "dobxmargin", 0 },
2076 { rtfDrawAttr, rtfDrawPageRelY, "dobypage", 0 },
2077 { rtfDrawAttr, rtfDrawColumnRelY, "dobycolumn", 0 },
2078 { rtfDrawAttr, rtfDrawMarginRelY, "dobymargin", 0 },
2079 { rtfDrawAttr, rtfDrawHeight, "dobhgt", 0 },
2081 { rtfDrawAttr, rtfDrawBeginGroup, "dpgroup", 0 },
2082 { rtfDrawAttr, rtfDrawGroupCount, "dpcount", 0 },
2083 { rtfDrawAttr, rtfDrawEndGroup, "dpendgroup", 0 },
2084 { rtfDrawAttr, rtfDrawArc, "dparc", 0 },
2085 { rtfDrawAttr, rtfDrawCallout, "dpcallout", 0 },
2086 { rtfDrawAttr, rtfDrawEllipse, "dpellipse", 0 },
2087 { rtfDrawAttr, rtfDrawLine, "dpline", 0 },
2088 { rtfDrawAttr, rtfDrawPolygon, "dppolygon", 0 },
2089 { rtfDrawAttr, rtfDrawPolyLine, "dppolyline", 0 },
2090 { rtfDrawAttr, rtfDrawRect, "dprect", 0 },
2091 { rtfDrawAttr, rtfDrawTextBox, "dptxbx", 0 },
2093 { rtfDrawAttr, rtfDrawOffsetX, "dpx", 0 },
2094 { rtfDrawAttr, rtfDrawSizeX, "dpxsize", 0 },
2095 { rtfDrawAttr, rtfDrawOffsetY, "dpy", 0 },
2096 { rtfDrawAttr, rtfDrawSizeY, "dpysize", 0 },
2098 { rtfDrawAttr, rtfCOAngle, "dpcoa", 0 },
2099 { rtfDrawAttr, rtfCOAccentBar, "dpcoaccent", 0 },
2100 { rtfDrawAttr, rtfCOBestFit, "dpcobestfit", 0 },
2101 { rtfDrawAttr, rtfCOBorder, "dpcoborder", 0 },
2102 { rtfDrawAttr, rtfCOAttachAbsDist, "dpcodabs", 0 },
2103 { rtfDrawAttr, rtfCOAttachBottom, "dpcodbottom", 0 },
2104 { rtfDrawAttr, rtfCOAttachCenter, "dpcodcenter", 0 },
2105 { rtfDrawAttr, rtfCOAttachTop, "dpcodtop", 0 },
2106 { rtfDrawAttr, rtfCOLength, "dpcolength", 0 },
2107 { rtfDrawAttr, rtfCONegXQuadrant, "dpcominusx", 0 },
2108 { rtfDrawAttr, rtfCONegYQuadrant, "dpcominusy", 0 },
2109 { rtfDrawAttr, rtfCOOffset, "dpcooffset", 0 },
2110 { rtfDrawAttr, rtfCOAttachSmart, "dpcosmarta", 0 },
2111 { rtfDrawAttr, rtfCODoubleLine, "dpcotdouble", 0 },
2112 { rtfDrawAttr, rtfCORightAngle, "dpcotright", 0 },
2113 { rtfDrawAttr, rtfCOSingleLine, "dpcotsingle", 0 },
2114 { rtfDrawAttr, rtfCOTripleLine, "dpcottriple", 0 },
2116 { rtfDrawAttr, rtfDrawTextBoxMargin, "dptxbxmar", 0 },
2117 { rtfDrawAttr, rtfDrawTextBoxText, "dptxbxtext", 0 },
2118 { rtfDrawAttr, rtfDrawRoundRect, "dproundr", 0 },
2120 { rtfDrawAttr, rtfDrawPointX, "dpptx", 0 },
2121 { rtfDrawAttr, rtfDrawPointY, "dppty", 0 },
2122 { rtfDrawAttr, rtfDrawPolyCount, "dppolycount", 0 },
2124 { rtfDrawAttr, rtfDrawArcFlipX, "dparcflipx", 0 },
2125 { rtfDrawAttr, rtfDrawArcFlipY, "dparcflipy", 0 },
2127 { rtfDrawAttr, rtfDrawLineBlue, "dplinecob", 0 },
2128 { rtfDrawAttr, rtfDrawLineGreen, "dplinecog", 0 },
2129 { rtfDrawAttr, rtfDrawLineRed, "dplinecor", 0 },
2130 { rtfDrawAttr, rtfDrawLinePalette, "dplinepal", 0 },
2131 { rtfDrawAttr, rtfDrawLineDashDot, "dplinedado", 0 },
2132 { rtfDrawAttr, rtfDrawLineDashDotDot, "dplinedadodo", 0 },
2133 { rtfDrawAttr, rtfDrawLineDash, "dplinedash", 0 },
2134 { rtfDrawAttr, rtfDrawLineDot, "dplinedot", 0 },
2135 { rtfDrawAttr, rtfDrawLineGray, "dplinegray", 0 },
2136 { rtfDrawAttr, rtfDrawLineHollow, "dplinehollow", 0 },
2137 { rtfDrawAttr, rtfDrawLineSolid, "dplinesolid", 0 },
2138 { rtfDrawAttr, rtfDrawLineWidth, "dplinew", 0 },
2140 { rtfDrawAttr, rtfDrawHollowEndArrow, "dpaendhol", 0 },
2141 { rtfDrawAttr, rtfDrawEndArrowLength, "dpaendl", 0 },
2142 { rtfDrawAttr, rtfDrawSolidEndArrow, "dpaendsol", 0 },
2143 { rtfDrawAttr, rtfDrawEndArrowWidth, "dpaendw", 0 },
2144 { rtfDrawAttr, rtfDrawHollowStartArrow,"dpastarthol", 0 },
2145 { rtfDrawAttr, rtfDrawStartArrowLength,"dpastartl", 0 },
2146 { rtfDrawAttr, rtfDrawSolidStartArrow, "dpastartsol", 0 },
2147 { rtfDrawAttr, rtfDrawStartArrowWidth, "dpastartw", 0 },
2149 { rtfDrawAttr, rtfDrawBgFillBlue, "dpfillbgcb", 0 },
2150 { rtfDrawAttr, rtfDrawBgFillGreen, "dpfillbgcg", 0 },
2151 { rtfDrawAttr, rtfDrawBgFillRed, "dpfillbgcr", 0 },
2152 { rtfDrawAttr, rtfDrawBgFillPalette, "dpfillbgpal", 0 },
2153 { rtfDrawAttr, rtfDrawBgFillGray, "dpfillbggray", 0 },
2154 { rtfDrawAttr, rtfDrawFgFillBlue, "dpfillfgcb", 0 },
2155 { rtfDrawAttr, rtfDrawFgFillGreen, "dpfillfgcg", 0 },
2156 { rtfDrawAttr, rtfDrawFgFillRed, "dpfillfgcr", 0 },
2157 { rtfDrawAttr, rtfDrawFgFillPalette, "dpfillfgpal", 0 },
2158 { rtfDrawAttr, rtfDrawFgFillGray, "dpfillfggray", 0 },
2159 { rtfDrawAttr, rtfDrawFillPatIndex, "dpfillpat", 0 },
2161 { rtfDrawAttr, rtfDrawShadow, "dpshadow", 0 },
2162 { rtfDrawAttr, rtfDrawShadowXOffset, "dpshadx", 0 },
2163 { rtfDrawAttr, rtfDrawShadowYOffset, "dpshady", 0 },
2165 { rtfVersion, -1, "rtf", 0 },
2166 { rtfDefFont, -1, "deff", 0 },
2170 #define RTF_KEY_COUNT (sizeof(rtfKey) / sizeof(RTFKey))
2172 typedef struct tagRTFHashTableEntry {
2175 } RTFHashTableEntry;
2177 static RTFHashTableEntry rtfHashTable[RTF_KEY_COUNT * 2];
2181 * Initialize lookup table hash values. Only need to do this once.
2184 void LookupInit(void)
2188 memset(rtfHashTable, 0, sizeof rtfHashTable);
2189 for (rp = rtfKey; rp->rtfKStr != NULL; rp++)
2193 rp->rtfKHash = Hash (rp->rtfKStr);
2194 index = rp->rtfKHash % (RTF_KEY_COUNT * 2);
2195 if (!rtfHashTable[index].count)
2196 rtfHashTable[index].value = heap_alloc(sizeof(RTFKey *));
2198 rtfHashTable[index].value = heap_realloc(rtfHashTable[index].value, sizeof(RTFKey *) * (rtfHashTable[index].count + 1));
2199 rtfHashTable[index].value[rtfHashTable[index].count++] = rp;
2203 void LookupCleanup(void)
2207 for (i=0; i<RTF_KEY_COUNT*2; i++)
2209 heap_free( rtfHashTable[i].value );
2210 rtfHashTable[i].value = NULL;
2211 rtfHashTable[i].count = 0;
2217 * Determine major and minor number of control token. If it's
2218 * not found, the class turns into rtfUnknown.
2221 static void Lookup(RTF_Info *info, char *s)
2225 RTFHashTableEntry *entry;
2228 ++s; /* skip over the leading \ character */
2230 entry = &rtfHashTable[hash % (RTF_KEY_COUNT * 2)];
2231 for (i = 0; i < entry->count; i++)
2233 rp = entry->value[i];
2234 if (hash == rp->rtfKHash && strcmp (s, rp->rtfKStr) == 0)
2236 info->rtfClass = rtfControl;
2237 info->rtfMajor = rp->rtfKMajor;
2238 info->rtfMinor = rp->rtfKMinor;
2242 info->rtfClass = rtfUnknown;
2247 * Compute hash value of symbol
2250 static int Hash(const char *s)
2255 while ((c = *s++) != '\0')
2262 /* ---------------------------------------------------------------------- */
2266 * Token comparison routines
2269 int RTFCheckCM(const RTF_Info *info, int class, int major)
2271 return (info->rtfClass == class && info->rtfMajor == major);
2275 int RTFCheckCMM(const RTF_Info *info, int class, int major, int minor)
2277 return (info->rtfClass == class && info->rtfMajor == major && info->rtfMinor == minor);
2281 int RTFCheckMM(const RTF_Info *info, int major, int minor)
2283 return (info->rtfMajor == major && info->rtfMinor == minor);
2287 /* ---------------------------------------------------------------------- */
2290 int RTFCharToHex(char c)
2295 return (c - '0'); /* '0'..'9' */
2296 return (c - 'a' + 10); /* 'a'..'f' */
2300 /* ---------------------------------------------------------------------- */
2303 * originally from RTF tools' text-writer.c
2305 * text-writer -- RTF-to-text translation writer code.
2307 * Read RTF input, write text of document (text extraction).
2310 static void TextClass (RTF_Info *info);
2311 static void ControlClass (RTF_Info *info);
2312 static void DefFont(RTF_Info *info);
2313 static void Destination (RTF_Info *info);
2314 static void SpecialChar (RTF_Info *info);
2315 static void RTFPutUnicodeChar (RTF_Info *info, int c);
2318 * Initialize the writer.
2322 WriterInit (RTF_Info *info )
2328 BeginFile (RTF_Info *info )
2330 /* install class callbacks */
2332 RTFSetClassCallback (info, rtfText, TextClass);
2333 RTFSetClassCallback (info, rtfControl, ControlClass);
2339 * Write out a character.
2343 TextClass (RTF_Info *info)
2345 RTFPutCodePageChar(info, info->rtfMajor);
2350 ControlClass (RTF_Info *info)
2352 switch (info->rtfMajor)
2356 ME_RTFCharAttrHook(info);
2359 ME_RTFParAttrHook(info);
2362 ME_RTFTblAttrHook(info);
2370 case rtfDestination:
2376 case rtfSpecialChar:
2378 ME_RTFSpecialCharHook(info);
2385 CharAttr(RTF_Info *info)
2389 switch (info->rtfMinor)
2392 font = RTFGetFont(info, info->rtfParam);
2395 if (info->ansiCodePage != CP_UTF8)
2396 info->codePage = font->rtfFCodePage;
2397 TRACE("font %d codepage %d\n", info->rtfParam, info->codePage);
2400 ERR( "unknown font %d\n", info->rtfParam);
2402 case rtfUnicodeLength:
2403 info->unicodeLength = info->rtfParam;
2410 CharSet(RTF_Info *info)
2412 if (info->ansiCodePage == CP_UTF8)
2415 switch (info->rtfMinor)
2417 case rtfAnsiCharSet:
2418 info->ansiCodePage = 1252; /* Latin-1 */
2421 info->ansiCodePage = 10000; /* MacRoman */
2424 info->ansiCodePage = 437;
2427 info->ansiCodePage = 850;
2433 * This function notices destinations that aren't explicitly handled
2434 * and skips to their ends. This keeps, for instance, picture
2435 * data from being considered as plain text.
2439 Destination (RTF_Info *info)
2441 if (!RTFGetDestinationCallback(info, info->rtfMinor))
2442 RTFSkipGroup (info);
2447 DefFont(RTF_Info *info)
2449 TRACE("%d\n", info->rtfParam);
2450 info->defFont = info->rtfParam;
2455 DocAttr(RTF_Info *info)
2457 TRACE("minor %d, param %d\n", info->rtfMinor, info->rtfParam);
2459 switch (info->rtfMinor)
2461 case rtfAnsiCodePage:
2462 info->codePage = info->ansiCodePage = info->rtfParam;
2465 info->codePage = info->ansiCodePage = CP_UTF8;
2471 static void SpecialChar (RTF_Info *info)
2473 switch (info->rtfMinor)
2476 /* the next token determines destination, if it's unknown, skip the group */
2477 /* this way we filter out the garbage coming from unknown destinations */
2479 if (info->rtfClass != rtfDestination)
2482 RTFRouteToken(info); /* "\*" is ignored with known destinations */
2488 RTFPutUnicodeChar(info, info->rtfParam);
2490 /* After \u we must skip number of character tokens set by \ucN */
2491 for (i = 0; i < info->unicodeLength; i++)
2494 if (info->rtfClass != rtfText)
2496 ERR("The token behind \\u is not text, but (%d,%d,%d)\n",
2497 info->rtfClass, info->rtfMajor, info->rtfMinor);
2498 RTFUngetToken(info);
2505 RTFFlushOutputBuffer(info);
2506 ME_InsertEndRowFromCursor(info->editor, 0);
2511 RTFPutUnicodeChar (info, '\r');
2512 if (info->editor->bEmulateVersion10) RTFPutUnicodeChar (info, '\n');
2515 RTFPutUnicodeChar (info, 0x00A0);
2518 RTFPutUnicodeChar (info, '\t');
2520 case rtfNoBrkHyphen:
2521 RTFPutUnicodeChar (info, 0x2011);
2524 RTFPutUnicodeChar (info, 0x2022);
2527 RTFPutUnicodeChar (info, 0x2014);
2530 RTFPutUnicodeChar (info, 0x2013);
2533 RTFPutUnicodeChar (info, 0x2018);
2536 RTFPutUnicodeChar (info, 0x2019);
2539 RTFPutUnicodeChar (info, 0x201C);
2542 RTFPutUnicodeChar (info, 0x201D);
2549 RTFFlushUnicodeOutputBuffer(RTF_Info *info)
2551 if (info->dwOutputCount)
2553 ME_InsertTextFromCursor(info->editor, 0, info->OutputBuffer,
2554 info->dwOutputCount, info->style);
2555 info->dwOutputCount = 0;
2561 RTFPutUnicodeString(RTF_Info *info, const WCHAR *string, int length)
2563 if (info->dwCPOutputCount)
2564 RTFFlushCPOutputBuffer(info);
2567 int fit = min(length, sizeof(info->OutputBuffer) / sizeof(WCHAR) - info->dwOutputCount);
2569 memmove(info->OutputBuffer + info->dwOutputCount, string, fit * sizeof(WCHAR));
2570 info->dwOutputCount += fit;
2573 if (sizeof(info->OutputBuffer) / sizeof(WCHAR) == info->dwOutputCount)
2574 RTFFlushUnicodeOutputBuffer(info);
2579 RTFFlushCPOutputBuffer(RTF_Info *info)
2581 int bufferMax = info->dwCPOutputCount * 2 * sizeof(WCHAR);
2582 WCHAR *buffer = heap_alloc(bufferMax);
2585 length = MultiByteToWideChar(info->codePage, 0, info->cpOutputBuffer,
2586 info->dwCPOutputCount, buffer, bufferMax/sizeof(WCHAR));
2587 info->dwCPOutputCount = 0;
2589 RTFPutUnicodeString(info, buffer, length);
2594 RTFFlushOutputBuffer(RTF_Info *info)
2596 if (info->dwCPOutputCount)
2597 RTFFlushCPOutputBuffer(info);
2598 RTFFlushUnicodeOutputBuffer(info);
2602 RTFPutUnicodeChar(RTF_Info *info, int c)
2604 if (info->dwCPOutputCount)
2605 RTFFlushCPOutputBuffer(info);
2606 if (info->dwOutputCount * sizeof(WCHAR) >= ( sizeof info->OutputBuffer - 1 ) )
2607 RTFFlushUnicodeOutputBuffer( info );
2608 info->OutputBuffer[info->dwOutputCount++] = c;
2612 RTFPutCodePageChar(RTF_Info *info, int c)
2614 /* Use dynamic buffer here because it's the best way to handle
2615 * MBCS codepages without having to worry about partial chars */
2616 if (info->dwCPOutputCount >= info->dwMaxCPOutputCount)
2618 info->dwMaxCPOutputCount *= 2;
2619 info->cpOutputBuffer = heap_realloc(info->cpOutputBuffer, info->dwMaxCPOutputCount);
2621 info->cpOutputBuffer[info->dwCPOutputCount++] = c;