Moved GUID definitions to their respective dll.
[wine/gsoc_dplay.git] / dlls / richedit / reader.c
blob160bff17f59c73def29ae9775ba045c9d4dbed35
1 /*
2 * - Need to document error code meanings.
3 * - Need to do something with \* on destinations.
4 * - Make the parameter a long?
6 * reader.c - RTF file reader. Release 1.10.
8 * ASCII 10 (\n) and 13 (\r) are ignored and silently discarded.
9 * Nulls are also discarded.
10 * (although the read hook will still get a look at them.)
12 * "\:" is not a ":", it's a control symbol. But some versions of
13 * Word seem to write "\:" for ":". This reader treats "\:" as a
14 * plain text ":"
16 * 19 Mar 93
17 * - Add hack to skip "{\*\keycode ... }" group in stylesheet.
18 * This is probably the wrong thing to do, but it's simple.
19 * 13 Jul 93
20 * - Add THINK C awareness to malloc() declaration. Necessary so
21 * compiler knows the malloc argument is 4 bytes. Ugh.
22 * 07 Sep 93
23 * - Text characters are mapped onto standard codes, which are placed
24 * in rtfMinor.
25 * - Eliminated use of index() function.
26 * 05 Mar 94
27 * - Added zillions of new symbols (those defined in RTF spec 1.2).
28 * 14 Mar 94
29 * - Public functions RTFMsg() and RTFPanic() now take variable arguments.
30 * This means RTFPanic() now is used in place of what was formerly the
31 * internal function Error().
32 * - 8-bit characters are now legal, so they're not converted to \'xx
33 * hex char representation now.
34 * 01 Apr 94
35 * - Added public variables rtfLineNum and rtfLinePos.
36 * - #include string.h or strings.h, avoiding strncmp() problem where
37 * last argument is treated as zero when prototype isn't available.
38 * 04 Apr 94
39 * - Treat style numbers 222 and 0 properly as "no style" and "normal".
41 * Author: Paul DuBois dubois@primate.wisc.edu
43 * This software may be redistributed without restriction and used for
44 * any purpose whatsoever.
47 # ifndef STRING_H
48 # define STRING_H <string.h>
49 # endif
51 # include <stdio.h>
52 # include <ctype.h>
53 # include STRING_H
54 # ifdef STDARG
55 # include <stdarg.h>
56 # else
57 # ifdef VARARGS
58 # include <varargs.h>
59 # endif /* VARARGS */
60 # endif /* STDARG */
62 # define rtfInternal
63 # include "rtf.h"
64 # undef rtfInternal
67 * include hard coded charsets
70 #include "ansi_gen.h"
71 #include "ansi_sym.h"
72 #include "text_map.h"
74 #include <stdlib.h>
75 #include "charlist.h"
76 #include "windows.h"
78 extern HANDLE RICHED32_hHeap;
81 * Return pointer to new element of type t, or NULL
82 * if no memory available.
85 # define New(t) ((t *) RTFAlloc ((int) sizeof (t)))
87 /* maximum number of character values representable in a byte */
89 # define charSetSize 256
91 /* charset stack size */
93 # define maxCSStack 10
95 static int _RTFGetChar();
96 static void _RTFGetToken ();
97 static void _RTFGetToken2 ();
98 static int GetChar ();
99 static void ReadFontTbl ();
100 static void ReadColorTbl ();
101 static void ReadStyleSheet ();
102 static void ReadInfoGroup ();
103 static void ReadPictGroup ();
104 static void ReadObjGroup ();
105 static void LookupInit ();
106 static void Lookup ();
107 static int Hash ();
109 static void CharSetInit ();
110 static void ReadCharSetMaps ();
114 * Public variables (listed in rtf.h)
117 int rtfClass;
118 int rtfMajor;
119 int rtfMinor;
120 int rtfParam;
121 char *rtfTextBuf = (char *) NULL;
122 int rtfTextLen;
124 long rtfLineNum;
125 int rtfLinePos;
129 * Private stuff
132 static int pushedChar; /* pushback char if read too far */
134 static int pushedClass; /* pushed token info for RTFUngetToken() */
135 static int pushedMajor;
136 static int pushedMinor;
137 static int pushedParam;
138 static char *pushedTextBuf = (char *) NULL;
140 static int prevChar;
141 static int bumpLine;
143 static RTFFont *fontList = (RTFFont *) NULL; /* these lists MUST be */
144 static RTFColor *colorList = (RTFColor *) NULL; /* initialized to NULL */
145 static RTFStyle *styleList = (RTFStyle *) NULL;
147 static char *inputName = (char *) NULL;
148 static char *outputName = (char *) NULL;
150 static EDITSTREAM editstream;
151 static CHARLIST inputCharList = {0, NULL, NULL};
154 * This array is used to map standard character names onto their numeric codes.
155 * The position of the name within the array is the code.
156 * stdcharnames.h is generated in the ../h directory.
159 static char *stdCharName[] =
161 # include "stdcharnames.h"
162 (char *) NULL
167 * These arrays are used to map RTF input character values onto the standard
168 * character names represented by the values. Input character values are
169 * used as indices into the arrays to produce standard character codes.
173 static char *genCharSetFile = (char *) NULL;
174 static int genCharCode[charSetSize]; /* general */
175 static int haveGenCharSet = 0;
177 static char *symCharSetFile = (char *) NULL;
178 static int symCharCode[charSetSize]; /* symbol */
179 static int haveSymCharSet = 0;
181 static int curCharSet = rtfCSGeneral;
182 static int *curCharCode = genCharCode;
185 * By default, the reader is configured to handle charset mapping invisibly,
186 * including reading the charset files and switching charset maps as necessary
187 * for Symbol font.
190 static int autoCharSetFlags;
193 * Stack for keeping track of charset map on group begin/end. This is
194 * necessary because group termination reverts the font to the previous
195 * value, which may implicitly change it.
198 static int csStack[maxCSStack];
199 static int csTop = 0;
202 * Get a char from the charlist. The charlist is used to store characters
203 * from the editstream.
207 int
208 _RTFGetChar()
210 char myChar;
211 if(CHARLIST_GetNbItems(&inputCharList) == 0)
213 char buff[10];
214 long pcb;
215 editstream.pfnCallback(editstream.dwCookie, buff, 1, &pcb);
216 if(pcb == 0)
217 return EOF;
218 else
219 CHARLIST_Enqueue(&inputCharList, buff[0]);
221 myChar = CHARLIST_Dequeue(&inputCharList);
222 return (int) myChar;
225 void
226 RTFSetEditStream(EDITSTREAM *es)
228 editstream.dwCookie = es->dwCookie;
229 editstream.dwError = es->dwError;
230 editstream.pfnCallback = es->pfnCallback;
234 * Initialize the reader. This may be called multiple times,
235 * to read multiple files. The only thing not reset is the input
236 * stream; that must be done with RTFSetStream().
239 void
240 RTFInit ()
242 int i;
243 RTFColor *cp;
244 RTFFont *fp;
245 RTFStyle *sp;
246 RTFStyleElt *eltList, *ep;
248 if (rtfTextBuf == (char *) NULL) /* initialize the text buffers */
250 rtfTextBuf = RTFAlloc (rtfBufSiz);
251 pushedTextBuf = RTFAlloc (rtfBufSiz);
252 if (rtfTextBuf == (char *) NULL
253 || pushedTextBuf == (char *) NULL)
254 RTFPanic ("Cannot allocate text buffers.");
255 rtfTextBuf[0] = pushedTextBuf[0] = '\0';
258 RTFFree (inputName);
259 RTFFree (outputName);
260 inputName = outputName = (char *) NULL;
262 /* initialize lookup table */
263 LookupInit ();
265 for (i = 0; i < rtfMaxClass; i++)
266 RTFSetClassCallback (i, (RTFFuncPtr) NULL);
267 for (i = 0; i < rtfMaxDestination; i++)
268 RTFSetDestinationCallback (i, (RTFFuncPtr) NULL);
270 /* install built-in destination readers */
271 RTFSetDestinationCallback (rtfFontTbl, ReadFontTbl);
272 RTFSetDestinationCallback (rtfColorTbl, ReadColorTbl);
273 RTFSetDestinationCallback (rtfStyleSheet, ReadStyleSheet);
274 RTFSetDestinationCallback (rtfInfo, ReadInfoGroup);
275 RTFSetDestinationCallback (rtfPict, ReadPictGroup);
276 RTFSetDestinationCallback (rtfObject, ReadObjGroup);
279 RTFSetReadHook ((RTFFuncPtr) NULL);
281 /* dump old lists if necessary */
283 while (fontList != (RTFFont *) NULL)
285 fp = fontList->rtfNextFont;
286 RTFFree (fontList->rtfFName);
287 RTFFree ((char *) fontList);
288 fontList = fp;
290 while (colorList != (RTFColor *) NULL)
292 cp = colorList->rtfNextColor;
293 RTFFree ((char *) colorList);
294 colorList = cp;
296 while (styleList != (RTFStyle *) NULL)
298 sp = styleList->rtfNextStyle;
299 eltList = styleList->rtfSSEList;
300 while (eltList != (RTFStyleElt *) NULL)
302 ep = eltList->rtfNextSE;
303 RTFFree (eltList->rtfSEText);
304 RTFFree ((char *) eltList);
305 eltList = ep;
307 RTFFree (styleList->rtfSName);
308 RTFFree ((char *) styleList);
309 styleList = sp;
312 rtfClass = -1;
313 pushedClass = -1;
314 pushedChar = EOF;
316 rtfLineNum = 0;
317 rtfLinePos = 0;
318 prevChar = EOF;
319 bumpLine = 0;
321 CharSetInit ();
322 csTop = 0;
326 * Set or get the input or output file name. These are never guaranteed
327 * to be accurate, only insofar as the calling program makes them so.
330 void
331 RTFSetInputName (name)
332 char *name;
334 if ((inputName = RTFStrSave (name)) == (char *) NULL)
335 RTFPanic ("RTFSetInputName: out of memory");
339 char *
340 RTFGetInputName ()
342 return (inputName);
346 void
347 RTFSetOutputName (name)
348 char *name;
350 if ((outputName = RTFStrSave (name)) == (char *) NULL)
351 RTFPanic ("RTFSetOutputName: out of memory");
355 char *
356 RTFGetOutputName ()
358 return (outputName);
363 /* ---------------------------------------------------------------------- */
366 * Callback table manipulation routines
371 * Install or return a writer callback for a token class
375 static RTFFuncPtr ccb[rtfMaxClass]; /* class callbacks */
378 void
379 RTFSetClassCallback (class, callback)
380 int class;
381 RTFFuncPtr callback;
383 if (class >= 0 && class < rtfMaxClass)
384 ccb[class] = callback;
388 RTFFuncPtr
389 RTFGetClassCallback (class)
390 int class;
392 if (class >= 0 && class < rtfMaxClass)
393 return (ccb[class]);
394 return ((RTFFuncPtr) NULL);
399 * Install or return a writer callback for a destination type
402 static RTFFuncPtr dcb[rtfMaxDestination]; /* destination callbacks */
405 void
406 RTFSetDestinationCallback (dest, callback)
407 int dest;
408 RTFFuncPtr callback;
410 if (dest >= 0 && dest < rtfMaxDestination)
411 dcb[dest] = callback;
415 RTFFuncPtr
416 RTFGetDestinationCallback (dest)
417 int dest;
419 if (dest >= 0 && dest < rtfMaxDestination)
420 return (dcb[dest]);
421 return ((RTFFuncPtr) NULL);
425 /* ---------------------------------------------------------------------- */
428 * Token reading routines
433 * Read the input stream, invoking the writer's callbacks
434 * where appropriate.
437 void
438 RTFRead ()
440 while (RTFGetToken () != rtfEOF)
441 RTFRouteToken ();
446 * Route a token. If it's a destination for which a reader is
447 * installed, process the destination internally, otherwise
448 * pass the token to the writer's class callback.
451 void
452 RTFRouteToken ()
454 RTFFuncPtr p;
456 if (rtfClass < 0 || rtfClass >= rtfMaxClass) /* watchdog */
458 RTFPanic ("Unknown class %d: %s (reader malfunction)",
459 rtfClass, rtfTextBuf);
461 if (RTFCheckCM (rtfControl, rtfDestination))
463 /* invoke destination-specific callback if there is one */
464 if ((p = RTFGetDestinationCallback (rtfMinor))
465 != (RTFFuncPtr) NULL)
467 (*p) ();
468 return;
471 /* invoke class callback if there is one */
472 if ((p = RTFGetClassCallback (rtfClass)) != (RTFFuncPtr) NULL)
473 (*p) ();
478 * Skip to the end of the current group. When this returns,
479 * writers that maintain a state stack may want to call their
480 * state unstacker; global vars will still be set to the group's
481 * closing brace.
484 void
485 RTFSkipGroup ()
487 int level = 1;
489 while (RTFGetToken () != rtfEOF)
491 if (rtfClass == rtfGroup)
493 if (rtfMajor == rtfBeginGroup)
494 ++level;
495 else if (rtfMajor == rtfEndGroup)
497 if (--level < 1)
498 break; /* end of initial group */
506 * Read one token. Call the read hook if there is one. The
507 * token class is the return value. Returns rtfEOF when there
508 * are no more tokens.
512 RTFGetToken ()
514 RTFFuncPtr p;
516 for (;;)
518 _RTFGetToken ();
519 if ((p = RTFGetReadHook ()) != (RTFFuncPtr) NULL)
520 (*p) (); /* give read hook a look at token */
522 /* Silently discard newlines, carriage returns, nulls. */
523 if (!(rtfClass == rtfText
524 && (rtfMajor == '\n' || rtfMajor == '\r'
525 || rtfMajor == '\0')))
526 break;
528 return (rtfClass);
533 * Install or return a token reader hook.
536 static RTFFuncPtr readHook;
539 void
540 RTFSetReadHook (f)
541 RTFFuncPtr f;
543 readHook = f;
547 RTFFuncPtr
548 RTFGetReadHook ()
550 return (readHook);
554 void
555 RTFUngetToken ()
557 if (pushedClass >= 0) /* there's already an ungotten token */
558 RTFPanic ("cannot unget two tokens");
559 if (rtfClass < 0)
560 RTFPanic ("no token to unget");
561 pushedClass = rtfClass;
562 pushedMajor = rtfMajor;
563 pushedMinor = rtfMinor;
564 pushedParam = rtfParam;
565 (void) strcpy (pushedTextBuf, rtfTextBuf);
570 RTFPeekToken ()
572 _RTFGetToken ();
573 RTFUngetToken ();
574 return (rtfClass);
578 static void
579 _RTFGetToken ()
581 RTFFont *fp;
583 /* first check for pushed token from RTFUngetToken() */
585 if (pushedClass >= 0)
587 rtfClass = pushedClass;
588 rtfMajor = pushedMajor;
589 rtfMinor = pushedMinor;
590 rtfParam = pushedParam;
591 (void) strcpy (rtfTextBuf, pushedTextBuf);
592 rtfTextLen = strlen (rtfTextBuf);
593 pushedClass = -1;
594 return;
598 * Beyond this point, no token is ever seen twice, which is
599 * important, e.g., for making sure no "}" pops the font stack twice.
602 _RTFGetToken2 ();
603 if (rtfClass == rtfText) /* map RTF char to standard code */
604 rtfMinor = RTFMapChar (rtfMajor);
607 * If auto-charset stuff is activated, see if anything needs doing,
608 * like reading the charset maps or switching between them.
611 if (autoCharSetFlags == 0)
612 return;
614 if ((autoCharSetFlags & rtfReadCharSet)
615 && RTFCheckCM (rtfControl, rtfCharSet))
617 ReadCharSetMaps ();
619 else if ((autoCharSetFlags & rtfSwitchCharSet)
620 && RTFCheckCMM (rtfControl, rtfCharAttr, rtfFontNum))
622 if ((fp = RTFGetFont (rtfParam)) != (RTFFont *) NULL)
624 if (strncmp (fp->rtfFName, "Symbol", 6) == 0)
625 curCharSet = rtfCSSymbol;
626 else
627 curCharSet = rtfCSGeneral;
628 RTFSetCharSet (curCharSet);
631 else if ((autoCharSetFlags & rtfSwitchCharSet) && rtfClass == rtfGroup)
633 switch (rtfMajor)
635 case rtfBeginGroup:
636 if (csTop >= maxCSStack)
637 RTFPanic ("_RTFGetToken: stack overflow");
638 csStack[csTop++] = curCharSet;
639 break;
640 case rtfEndGroup:
641 if (csTop <= 0)
642 RTFPanic ("_RTFGetToken: stack underflow");
643 curCharSet = csStack[--csTop];
644 RTFSetCharSet (curCharSet);
645 break;
651 /* this shouldn't be called anywhere but from _RTFGetToken() */
653 static void
654 _RTFGetToken2 ()
656 int sign;
657 int c;
659 /* initialize token vars */
661 rtfClass = rtfUnknown;
662 rtfParam = rtfNoParam;
663 rtfTextBuf[rtfTextLen = 0] = '\0';
665 /* get first character, which may be a pushback from previous token */
667 if (pushedChar != EOF)
669 c = pushedChar;
670 rtfTextBuf[rtfTextLen++] = c;
671 rtfTextBuf[rtfTextLen] = '\0';
672 pushedChar = EOF;
674 else if ((c = GetChar ()) == EOF)
676 rtfClass = rtfEOF;
677 return;
680 if (c == '{')
682 rtfClass = rtfGroup;
683 rtfMajor = rtfBeginGroup;
684 return;
686 if (c == '}')
688 rtfClass = rtfGroup;
689 rtfMajor = rtfEndGroup;
690 return;
692 if (c != '\\')
695 * Two possibilities here:
696 * 1) ASCII 9, effectively like \tab control symbol
697 * 2) literal text char
699 if (c == '\t') /* ASCII 9 */
701 rtfClass = rtfControl;
702 rtfMajor = rtfSpecialChar;
703 rtfMinor = rtfTab;
705 else
707 rtfClass = rtfText;
708 rtfMajor = c;
710 return;
712 if ((c = GetChar ()) == EOF)
714 /* early eof, whoops (class is rtfUnknown) */
715 return;
717 if (!isalpha (c))
720 * Three possibilities here:
721 * 1) hex encoded text char, e.g., \'d5, \'d3
722 * 2) special escaped text char, e.g., \{, \}
723 * 3) control symbol, e.g., \_, \-, \|, \<10>
725 if (c == '\'') /* hex char */
727 int c2;
729 if ((c = GetChar ()) != EOF && (c2 = GetChar ()) != EOF)
731 /* should do isxdigit check! */
732 rtfClass = rtfText;
733 rtfMajor = RTFCharToHex (c) * 16
734 + RTFCharToHex (c2);
735 return;
737 /* early eof, whoops (class is rtfUnknown) */
738 return;
741 /* escaped char */
742 /*if (index (":{}\\", c) != (char *) NULL)*/ /* escaped char */
743 if (c == ':' || c == '{' || c == '}' || c == '\\')
745 rtfClass = rtfText;
746 rtfMajor = c;
747 return;
750 /* control symbol */
751 Lookup (rtfTextBuf); /* sets class, major, minor */
752 return;
754 /* control word */
755 while (isalpha (c))
757 if ((c = GetChar ()) == EOF)
758 break;
762 * At this point, the control word is all collected, so the
763 * major/minor numbers are determined before the parameter
764 * (if any) is scanned. There will be one too many characters
765 * in the buffer, though, so fix up before and restore after
766 * looking up.
769 if (c != EOF)
770 rtfTextBuf[rtfTextLen-1] = '\0';
771 Lookup (rtfTextBuf); /* sets class, major, minor */
772 if (c != EOF)
773 rtfTextBuf[rtfTextLen-1] = c;
776 * Should be looking at first digit of parameter if there
777 * is one, unless it's negative. In that case, next char
778 * is '-', so need to gobble next char, and remember sign.
781 sign = 1;
782 if (c == '-')
784 sign = -1;
785 c = GetChar ();
787 if (c != EOF && isdigit (c))
789 rtfParam = 0;
790 while (isdigit (c)) /* gobble parameter */
792 rtfParam = rtfParam * 10 + c - '0';
793 if ((c = GetChar ()) == EOF)
794 break;
796 rtfParam *= sign;
799 * If control symbol delimiter was a blank, gobble it.
800 * Otherwise the character is first char of next token, so
801 * push it back for next call. In either case, delete the
802 * delimiter from the token buffer.
804 if (c != EOF)
806 if (c != ' ')
807 pushedChar = c;
808 rtfTextBuf[--rtfTextLen] = '\0';
814 * Read the next character from the input. This handles setting the
815 * current line and position-within-line variables. Those variable are
816 * set correctly whether lines end with CR, LF, or CRLF (the last being
817 * the tricky case).
819 * bumpLine indicates whether the line number should be incremented on
820 * the *next* input character.
824 static int
825 GetChar ()
827 int c;
828 int oldBumpLine;
830 if ((c = _RTFGetChar()) != EOF)
832 rtfTextBuf[rtfTextLen++] = c;
833 rtfTextBuf[rtfTextLen] = '\0';
835 if (prevChar == EOF)
836 bumpLine = 1;
837 oldBumpLine = bumpLine; /* non-zero if prev char was line ending */
838 bumpLine = 0;
839 if (c == '\r')
840 bumpLine = 1;
841 else if (c == '\n')
843 bumpLine = 1;
844 if (prevChar == '\r') /* oops, previous \r wasn't */
845 oldBumpLine = 0; /* really a line ending */
847 ++rtfLinePos;
848 if (oldBumpLine) /* were we supposed to increment the */
849 { /* line count on this char? */
850 ++rtfLineNum;
851 rtfLinePos = 1;
853 prevChar = c;
854 return (c);
859 * Synthesize a token by setting the global variables to the
860 * values supplied. Typically this is followed with a call
861 * to RTFRouteToken().
863 * If a param value other than rtfNoParam is passed, it becomes
864 * part of the token text.
867 void
868 RTFSetToken (class, major, minor, param, text)
869 int class, major, minor, param;
870 char *text;
872 rtfClass = class;
873 rtfMajor = major;
874 rtfMinor = minor;
875 rtfParam = param;
876 if (param == rtfNoParam)
877 (void) strcpy (rtfTextBuf, text);
878 else
879 sprintf (rtfTextBuf, "%s%d", text, param);
880 rtfTextLen = strlen (rtfTextBuf);
884 /* ---------------------------------------------------------------------- */
887 * Routines to handle mapping of RTF character sets
888 * onto standard characters.
890 * RTFStdCharCode(name) given char name, produce numeric code
891 * RTFStdCharName(code) given char code, return name
892 * RTFMapChar(c) map input (RTF) char code to std code
893 * RTFSetCharSet(id) select given charset map
894 * RTFGetCharSet() get current charset map
896 * See ../h/README for more information about charset names and codes.
901 * Initialize charset stuff.
904 static void
905 CharSetInit ()
907 autoCharSetFlags = (rtfReadCharSet | rtfSwitchCharSet);
908 RTFFree (genCharSetFile);
909 genCharSetFile = (char *) NULL;
910 haveGenCharSet = 0;
911 RTFFree (symCharSetFile);
912 symCharSetFile = (char *) NULL;
913 haveSymCharSet = 0;
914 curCharSet = rtfCSGeneral;
915 curCharCode = genCharCode;
920 * Specify the name of a file to be read when auto-charset-file reading is
921 * done.
924 void
925 RTFSetCharSetMap (name, csId)
926 char *name;
927 int csId;
929 if ((name = RTFStrSave (name)) == (char *) NULL) /* make copy */
930 RTFPanic ("RTFSetCharSetMap: out of memory");
931 switch (csId)
933 case rtfCSGeneral:
934 RTFFree (genCharSetFile); /* free any previous value */
935 genCharSetFile = name;
936 break;
937 case rtfCSSymbol:
938 RTFFree (symCharSetFile); /* free any previous value */
939 symCharSetFile = name;
940 break;
946 * Do auto-charset-file reading.
947 * will always use the ansi charset no mater what the value
948 * of the rtfTextBuf is.
950 * TODO: add support for other charset in the future.
954 static void
955 ReadCharSetMaps ()
957 char buf[rtfBufSiz];
959 if (genCharSetFile != (char *) NULL)
960 (void) strcpy (buf, genCharSetFile);
961 else
962 sprintf (buf, "%s-gen", &rtfTextBuf[1]);
963 if (RTFReadCharSetMap (rtfCSGeneral) == 0)
964 RTFPanic ("ReadCharSetMaps: Cannot read charset map %s", buf);
965 if (symCharSetFile != (char *) NULL)
966 (void) strcpy (buf, symCharSetFile);
967 else
968 sprintf (buf, "%s-sym", &rtfTextBuf[1]);
969 if (RTFReadCharSetMap (rtfCSSymbol) == 0)
970 RTFPanic ("ReadCharSetMaps: Cannot read charset map %s", buf);
976 * Convert a CaracterSetMap (caracter_name, caracter) into
977 * this form : array[caracter_ident] = caracter;
981 RTFReadCharSetMap (csId)
982 int csId;
984 int *stdCodeArray;
985 int i;
986 switch (csId)
988 default:
989 return (0); /* illegal charset id */
990 case rtfCSGeneral:
992 haveGenCharSet = 1;
993 stdCodeArray = genCharCode;
994 for (i = 0; i < charSetSize; i++)
996 stdCodeArray[i] = rtfSC_nothing;
999 for ( i = 0 ; i< sizeof(ansi_gen)/(sizeof(int));i+=2)
1001 stdCodeArray[ ansi_gen[i+1] ] = ansi_gen[i];
1003 break;
1005 case rtfCSSymbol:
1007 haveSymCharSet = 1;
1008 stdCodeArray = symCharCode;
1009 for (i = 0; i < charSetSize; i++)
1011 stdCodeArray[i] = rtfSC_nothing;
1014 for ( i = 0 ; i< sizeof(ansi_sym)/(sizeof(int));i+=2)
1016 stdCodeArray[ ansi_sym[i+1] ] = ansi_sym[i];
1018 break;
1021 return (1);
1026 * Given a standard character name (a string), find its code (a number).
1027 * Return -1 if name is unknown.
1031 RTFStdCharCode (name)
1032 char *name;
1034 int i;
1036 for (i = 0; i < rtfSC_MaxChar; i++)
1038 if (strcmp (name, stdCharName[i]) == 0)
1039 return (i);
1041 return (-1);
1046 * Given a standard character code (a number), find its name (a string).
1047 * Return NULL if code is unknown.
1050 char *
1051 RTFStdCharName (code)
1052 int code;
1054 if (code < 0 || code >= rtfSC_MaxChar)
1055 return ((char *) NULL);
1056 return (stdCharName[code]);
1061 * Given an RTF input character code, find standard character code.
1062 * The translator should read the appropriate charset maps when it finds a
1063 * charset control. However, the file might not contain one. In this
1064 * case, no map will be available. When the first attempt is made to
1065 * map a character under these circumstances, RTFMapChar() assumes ANSI
1066 * and reads the map as necessary.
1070 RTFMapChar (c)
1071 int c;
1073 switch (curCharSet)
1075 case rtfCSGeneral:
1076 if (!haveGenCharSet)
1078 if (RTFReadCharSetMap (rtfCSGeneral) == 0)
1079 RTFPanic ("RTFMapChar: cannot read ansi-gen");
1081 break;
1082 case rtfCSSymbol:
1083 if (!haveSymCharSet)
1085 if (RTFReadCharSetMap (rtfCSSymbol) == 0)
1086 RTFPanic ("RTFMapChar: cannot read ansi-sym");
1088 break;
1090 if (c < 0 || c >= charSetSize)
1091 return (rtfSC_nothing);
1092 return (curCharCode[c]);
1097 * Set the current character set. If csId is illegal, uses general charset.
1100 void
1101 RTFSetCharSet (csId)
1102 int csId;
1104 switch (csId)
1106 default: /* use general if csId unknown */
1107 case rtfCSGeneral:
1108 curCharCode = genCharCode;
1109 curCharSet = csId;
1110 break;
1111 case rtfCSSymbol:
1112 curCharCode = symCharCode;
1113 curCharSet = csId;
1114 break;
1120 RTFGetCharSet ()
1122 return (curCharSet);
1126 /* ---------------------------------------------------------------------- */
1129 * Special destination readers. They gobble the destination so the
1130 * writer doesn't have to deal with them. That's wrong for any
1131 * translator that wants to process any of these itself. In that
1132 * case, these readers should be overridden by installing a different
1133 * destination callback.
1135 * NOTE: The last token read by each of these reader will be the
1136 * destination's terminating '}', which will then be the current token.
1137 * That '}' token is passed to RTFRouteToken() - the writer has already
1138 * seen the '{' that began the destination group, and may have pushed a
1139 * state; it also needs to know at the end of the group that a state
1140 * should be popped.
1142 * It's important that rtf.h and the control token lookup table list
1143 * as many symbols as possible, because these destination readers
1144 * unfortunately make strict assumptions about the input they expect,
1145 * and a token of class rtfUnknown will throw them off easily.
1150 * Read { \fonttbl ... } destination. Old font tables don't have
1151 * braces around each table entry; try to adjust for that.
1154 static void
1155 ReadFontTbl ()
1157 RTFFont *fp = NULL;
1158 char buf[rtfBufSiz], *bp;
1159 int old = -1;
1160 char *fn = "ReadFontTbl";
1162 for (;;)
1164 (void) RTFGetToken ();
1165 if (RTFCheckCM (rtfGroup, rtfEndGroup))
1166 break;
1167 if (old < 0) /* first entry - determine tbl type */
1169 if (RTFCheckCMM (rtfControl, rtfCharAttr, rtfFontNum))
1170 old = 1; /* no brace */
1171 else if (RTFCheckCM (rtfGroup, rtfBeginGroup))
1172 old = 0; /* brace */
1173 else /* can't tell! */
1174 RTFPanic ("%s: Cannot determine format", fn);
1176 if (old == 0) /* need to find "{" here */
1178 if (!RTFCheckCM (rtfGroup, rtfBeginGroup))
1179 RTFPanic ("%s: missing \"{\"", fn);
1180 (void) RTFGetToken (); /* yes, skip to next token */
1182 if ((fp = New (RTFFont)) == (RTFFont *) NULL)
1183 RTFPanic ("%s: cannot allocate font entry", fn);
1185 fp->rtfNextFont = fontList;
1186 fontList = fp;
1188 fp->rtfFName = (char *) NULL;
1189 fp->rtfFAltName = (char *) NULL;
1190 fp->rtfFNum = -1;
1191 fp->rtfFFamily = 0;
1192 fp->rtfFCharSet = 0;
1193 fp->rtfFPitch = 0;
1194 fp->rtfFType = 0;
1195 fp->rtfFCodePage = 0;
1197 while (rtfClass != rtfEOF
1198 && !RTFCheckCM (rtfText, ';')
1199 && !RTFCheckCM (rtfGroup, rtfEndGroup))
1201 if (rtfClass == rtfControl)
1203 switch (rtfMajor)
1205 default:
1206 /* ignore token but announce it */
1207 RTFMsg ("%s: unknown token \"%s\"\n",
1208 fn, rtfTextBuf);
1209 case rtfFontFamily:
1210 fp->rtfFFamily = rtfMinor;
1211 break;
1212 case rtfCharAttr:
1213 switch (rtfMinor)
1215 default:
1216 break; /* ignore unknown? */
1217 case rtfFontNum:
1218 fp->rtfFNum = rtfParam;
1219 break;
1221 break;
1222 case rtfFontAttr:
1223 switch (rtfMinor)
1225 default:
1226 break; /* ignore unknown? */
1227 case rtfFontCharSet:
1228 fp->rtfFCharSet = rtfParam;
1229 break;
1230 case rtfFontPitch:
1231 fp->rtfFPitch = rtfParam;
1232 break;
1233 case rtfFontCodePage:
1234 fp->rtfFCodePage = rtfParam;
1235 break;
1236 case rtfFTypeNil:
1237 case rtfFTypeTrueType:
1238 fp->rtfFType = rtfParam;
1239 break;
1241 break;
1244 else if (RTFCheckCM (rtfGroup, rtfBeginGroup)) /* dest */
1246 RTFSkipGroup (); /* ignore for now */
1248 else if (rtfClass == rtfText) /* font name */
1250 bp = buf;
1251 while (rtfClass != rtfEOF
1252 && !RTFCheckCM (rtfText, ';')
1253 && !RTFCheckCM (rtfGroup, rtfEndGroup))
1255 *bp++ = rtfMajor;
1256 (void) RTFGetToken ();
1259 /* FIX: in some cases the <fontinfo> isn't finished with a semi-column */
1260 if(RTFCheckCM (rtfGroup, rtfEndGroup))
1262 RTFUngetToken ();
1264 *bp = '\0';
1265 fp->rtfFName = RTFStrSave (buf);
1266 if (fp->rtfFName == (char *) NULL)
1267 RTFPanic ("%s: cannot allocate font name", fn);
1268 /* already have next token; don't read one */
1269 /* at bottom of loop */
1270 continue;
1272 else
1274 /* ignore token but announce it */
1275 RTFMsg ("%s: unknown token \"%s\"\n",
1276 fn, rtfTextBuf);
1278 (void) RTFGetToken ();
1280 if (old == 0) /* need to see "}" here */
1282 (void) RTFGetToken ();
1283 if (!RTFCheckCM (rtfGroup, rtfEndGroup))
1284 RTFPanic ("%s: missing \"}\"", fn);
1287 if (fp->rtfFNum == -1)
1288 RTFPanic ("%s: missing font number", fn);
1290 * Could check other pieces of structure here, too, I suppose.
1292 RTFRouteToken (); /* feed "}" back to router */
1297 * The color table entries have color values of -1 if
1298 * the default color should be used for the entry (only
1299 * a semi-colon is given in the definition, no color values).
1300 * There will be a problem if a partial entry (1 or 2 but
1301 * not 3 color values) is given. The possibility is ignored
1302 * here.
1305 static void
1306 ReadColorTbl ()
1308 RTFColor *cp;
1309 int cnum = 0;
1310 char *fn = "ReadColorTbl";
1312 for (;;)
1314 (void) RTFGetToken ();
1315 if (RTFCheckCM (rtfGroup, rtfEndGroup))
1316 break;
1317 if ((cp = New (RTFColor)) == (RTFColor *) NULL)
1318 RTFPanic ("%s: cannot allocate color entry", fn);
1319 cp->rtfCNum = cnum++;
1320 cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = -1;
1321 cp->rtfNextColor = colorList;
1322 colorList = cp;
1323 while (RTFCheckCM (rtfControl, rtfColorName))
1325 switch (rtfMinor)
1327 case rtfRed: cp->rtfCRed = rtfParam; break;
1328 case rtfGreen: cp->rtfCGreen = rtfParam; break;
1329 case rtfBlue: cp->rtfCBlue = rtfParam; break;
1331 RTFGetToken ();
1333 if (!RTFCheckCM (rtfText, (int) ';'))
1334 RTFPanic ("%s: malformed entry", fn);
1336 RTFRouteToken (); /* feed "}" back to router */
1341 * The "Normal" style definition doesn't contain any style number,
1342 * all others do. Normal style is given style rtfNormalStyleNum.
1345 static void
1346 ReadStyleSheet ()
1348 RTFStyle *sp;
1349 RTFStyleElt *sep, *sepLast;
1350 char buf[rtfBufSiz], *bp;
1351 char *fn = "ReadStyleSheet";
1353 for (;;)
1355 (void) RTFGetToken ();
1356 if (RTFCheckCM (rtfGroup, rtfEndGroup))
1357 break;
1358 if ((sp = New (RTFStyle)) == (RTFStyle *) NULL)
1359 RTFPanic ("%s: cannot allocate stylesheet entry", fn);
1360 sp->rtfSName = (char *) NULL;
1361 sp->rtfSNum = -1;
1362 sp->rtfSType = rtfParStyle;
1363 sp->rtfSAdditive = 0;
1364 sp->rtfSBasedOn = rtfNoStyleNum;
1365 sp->rtfSNextPar = -1;
1366 sp->rtfSSEList = sepLast = (RTFStyleElt *) NULL;
1367 sp->rtfNextStyle = styleList;
1368 sp->rtfExpanding = 0;
1369 styleList = sp;
1370 if (!RTFCheckCM (rtfGroup, rtfBeginGroup))
1371 RTFPanic ("%s: missing \"{\"", fn);
1372 for (;;)
1374 (void) RTFGetToken ();
1375 if (rtfClass == rtfEOF
1376 || RTFCheckCM (rtfText, ';'))
1377 break;
1378 if (rtfClass == rtfControl)
1380 if (RTFCheckMM (rtfSpecialChar, rtfOptDest))
1381 continue; /* ignore "\*" */
1382 if (RTFCheckMM (rtfParAttr, rtfStyleNum))
1384 sp->rtfSNum = rtfParam;
1385 sp->rtfSType = rtfParStyle;
1386 continue;
1388 if (RTFCheckMM (rtfCharAttr, rtfCharStyleNum))
1390 sp->rtfSNum = rtfParam;
1391 sp->rtfSType = rtfCharStyle;
1392 continue;
1394 if (RTFCheckMM (rtfSectAttr, rtfSectStyleNum))
1396 sp->rtfSNum = rtfParam;
1397 sp->rtfSType = rtfSectStyle;
1398 continue;
1400 if (RTFCheckMM (rtfStyleAttr, rtfBasedOn))
1402 sp->rtfSBasedOn = rtfParam;
1403 continue;
1405 if (RTFCheckMM (rtfStyleAttr, rtfAdditive))
1407 sp->rtfSAdditive = 1;
1408 continue;
1410 if (RTFCheckMM (rtfStyleAttr, rtfNext))
1412 sp->rtfSNextPar = rtfParam;
1413 continue;
1415 if ((sep = New (RTFStyleElt)) == (RTFStyleElt *) NULL)
1416 RTFPanic ("%s: cannot allocate style element", fn);
1417 sep->rtfSEClass = rtfClass;
1418 sep->rtfSEMajor = rtfMajor;
1419 sep->rtfSEMinor = rtfMinor;
1420 sep->rtfSEParam = rtfParam;
1421 if ((sep->rtfSEText = RTFStrSave (rtfTextBuf))
1422 == (char *) NULL)
1423 RTFPanic ("%s: cannot allocate style element text", fn);
1424 if (sepLast == (RTFStyleElt *) NULL)
1425 sp->rtfSSEList = sep; /* first element */
1426 else /* add to end */
1427 sepLast->rtfNextSE = sep;
1428 sep->rtfNextSE = (RTFStyleElt *) NULL;
1429 sepLast = sep;
1431 else if (RTFCheckCM (rtfGroup, rtfBeginGroup))
1434 * This passes over "{\*\keycode ... }, among
1435 * other things. A temporary (perhaps) hack.
1437 RTFSkipGroup ();
1438 continue;
1440 else if (rtfClass == rtfText) /* style name */
1442 bp = buf;
1443 while (rtfClass == rtfText)
1445 if (rtfMajor == ';')
1447 /* put back for "for" loop */
1448 (void) RTFUngetToken ();
1449 break;
1451 *bp++ = rtfMajor;
1452 (void) RTFGetToken ();
1454 *bp = '\0';
1455 if ((sp->rtfSName = RTFStrSave (buf)) == (char *) NULL)
1456 RTFPanic ("%s: cannot allocate style name", fn);
1458 else /* unrecognized */
1460 /* ignore token but announce it */
1461 RTFMsg ("%s: unknown token \"%s\"\n",
1462 fn, rtfTextBuf);
1465 (void) RTFGetToken ();
1466 if (!RTFCheckCM (rtfGroup, rtfEndGroup))
1467 RTFPanic ("%s: missing \"}\"", fn);
1470 * Check over the style structure. A name is a must.
1471 * If no style number was specified, check whether it's the
1472 * Normal style (in which case it's given style number
1473 * rtfNormalStyleNum). Note that some "normal" style names
1474 * just begin with "Normal" and can have other stuff following,
1475 * e.g., "Normal,Times 10 point". Ugh.
1477 * Some German RTF writers use "Standard" instead of "Normal".
1479 if (sp->rtfSName == (char *) NULL)
1480 RTFPanic ("%s: missing style name", fn);
1481 if (sp->rtfSNum < 0)
1483 if (strncmp (buf, "Normal", 6) != 0
1484 && strncmp (buf, "Standard", 8) != 0)
1485 RTFPanic ("%s: missing style number", fn);
1486 sp->rtfSNum = rtfNormalStyleNum;
1488 if (sp->rtfSNextPar == -1) /* if \snext not given, */
1489 sp->rtfSNextPar = sp->rtfSNum; /* next is itself */
1491 RTFRouteToken (); /* feed "}" back to router */
1495 static void
1496 ReadInfoGroup ()
1498 RTFSkipGroup ();
1499 RTFRouteToken (); /* feed "}" back to router */
1503 static void
1504 ReadPictGroup ()
1506 RTFSkipGroup ();
1507 RTFRouteToken (); /* feed "}" back to router */
1511 static void
1512 ReadObjGroup ()
1514 RTFSkipGroup ();
1515 RTFRouteToken (); /* feed "}" back to router */
1519 /* ---------------------------------------------------------------------- */
1522 * Routines to return pieces of stylesheet, or font or color tables.
1523 * References to style 0 are mapped onto the Normal style.
1527 RTFStyle *
1528 RTFGetStyle (num)
1529 int num;
1531 RTFStyle *s;
1533 if (num == -1)
1534 return (styleList);
1535 for (s = styleList; s != (RTFStyle *) NULL; s = s->rtfNextStyle)
1537 if (s->rtfSNum == num)
1538 break;
1540 return (s); /* NULL if not found */
1544 RTFFont *
1545 RTFGetFont (num)
1546 int num;
1548 RTFFont *f;
1550 if (num == -1)
1551 return (fontList);
1552 for (f = fontList; f != (RTFFont *) NULL; f = f->rtfNextFont)
1554 if (f->rtfFNum == num)
1555 break;
1557 return (f); /* NULL if not found */
1561 RTFColor *
1562 RTFGetColor (num)
1563 int num;
1565 RTFColor *c;
1567 if (num == -1)
1568 return (colorList);
1569 for (c = colorList; c != (RTFColor *) NULL; c = c->rtfNextColor)
1571 if (c->rtfCNum == num)
1572 break;
1574 return (c); /* NULL if not found */
1578 /* ---------------------------------------------------------------------- */
1582 * Expand style n, if there is such a style.
1585 void
1586 RTFExpandStyle (n)
1587 int n;
1589 RTFStyle *s;
1590 RTFStyleElt *se;
1592 if (n == -1 || (s = RTFGetStyle (n)) == (RTFStyle *) NULL)
1593 return;
1594 if (s->rtfExpanding != 0)
1595 RTFPanic ("Style expansion loop, style %d", n);
1596 s->rtfExpanding = 1; /* set expansion flag for loop detection */
1598 * Expand "based-on" style (unless it's the same as the current
1599 * style -- Normal style usually gives itself as its own based-on
1600 * style). Based-on style expansion is done by synthesizing
1601 * the token that the writer needs to see in order to trigger
1602 * another style expansion, and feeding to token back through
1603 * the router so the writer sees it.
1605 if (n != s->rtfSBasedOn)
1607 RTFSetToken (rtfControl, rtfParAttr, rtfStyleNum,
1608 s->rtfSBasedOn, "\\s");
1609 RTFRouteToken ();
1612 * Now route the tokens unique to this style. RTFSetToken()
1613 * isn't used because it would add the param value to the end
1614 * of the token text, which already has it in.
1616 for (se = s->rtfSSEList; se != (RTFStyleElt *) NULL; se = se->rtfNextSE)
1618 rtfClass = se->rtfSEClass;
1619 rtfMajor = se->rtfSEMajor;
1620 rtfMinor = se->rtfSEMinor;
1621 rtfParam = se->rtfSEParam;
1622 (void) strcpy (rtfTextBuf, se->rtfSEText);
1623 rtfTextLen = strlen (rtfTextBuf);
1624 RTFRouteToken ();
1626 s->rtfExpanding = 0; /* done - clear expansion flag */
1630 /* ---------------------------------------------------------------------- */
1633 * Control symbol lookup routines
1637 typedef struct RTFKey RTFKey;
1639 struct RTFKey
1641 int rtfKMajor; /* major number */
1642 int rtfKMinor; /* minor number */
1643 char *rtfKStr; /* symbol name */
1644 int rtfKHash; /* symbol name hash value */
1648 * A minor number of -1 means the token has no minor number
1649 * (all valid minor numbers are >= 0).
1652 static RTFKey rtfKey[] =
1655 * Special characters
1658 { rtfSpecialChar, rtfIIntVersion, "vern", 0 },
1659 { rtfSpecialChar, rtfICreateTime, "creatim", 0 },
1660 { rtfSpecialChar, rtfIRevisionTime, "revtim", 0 },
1661 { rtfSpecialChar, rtfIPrintTime, "printim", 0 },
1662 { rtfSpecialChar, rtfIBackupTime, "buptim", 0 },
1663 { rtfSpecialChar, rtfIEditTime, "edmins", 0 },
1664 { rtfSpecialChar, rtfIYear, "yr", 0 },
1665 { rtfSpecialChar, rtfIMonth, "mo", 0 },
1666 { rtfSpecialChar, rtfIDay, "dy", 0 },
1667 { rtfSpecialChar, rtfIHour, "hr", 0 },
1668 { rtfSpecialChar, rtfIMinute, "min", 0 },
1669 { rtfSpecialChar, rtfISecond, "sec", 0 },
1670 { rtfSpecialChar, rtfINPages, "nofpages", 0 },
1671 { rtfSpecialChar, rtfINWords, "nofwords", 0 },
1672 { rtfSpecialChar, rtfINChars, "nofchars", 0 },
1673 { rtfSpecialChar, rtfIIntID, "id", 0 },
1675 { rtfSpecialChar, rtfCurHeadDate, "chdate", 0 },
1676 { rtfSpecialChar, rtfCurHeadDateLong, "chdpl", 0 },
1677 { rtfSpecialChar, rtfCurHeadDateAbbrev, "chdpa", 0 },
1678 { rtfSpecialChar, rtfCurHeadTime, "chtime", 0 },
1679 { rtfSpecialChar, rtfCurHeadPage, "chpgn", 0 },
1680 { rtfSpecialChar, rtfSectNum, "sectnum", 0 },
1681 { rtfSpecialChar, rtfCurFNote, "chftn", 0 },
1682 { rtfSpecialChar, rtfCurAnnotRef, "chatn", 0 },
1683 { rtfSpecialChar, rtfFNoteSep, "chftnsep", 0 },
1684 { rtfSpecialChar, rtfFNoteCont, "chftnsepc", 0 },
1685 { rtfSpecialChar, rtfCell, "cell", 0 },
1686 { rtfSpecialChar, rtfRow, "row", 0 },
1687 { rtfSpecialChar, rtfPar, "par", 0 },
1688 /* newline and carriage return are synonyms for */
1689 /* \par when they are preceded by a \ character */
1690 { rtfSpecialChar, rtfPar, "\n", 0 },
1691 { rtfSpecialChar, rtfPar, "\r", 0 },
1692 { rtfSpecialChar, rtfSect, "sect", 0 },
1693 { rtfSpecialChar, rtfPage, "page", 0 },
1694 { rtfSpecialChar, rtfColumn, "column", 0 },
1695 { rtfSpecialChar, rtfLine, "line", 0 },
1696 { rtfSpecialChar, rtfSoftPage, "softpage", 0 },
1697 { rtfSpecialChar, rtfSoftColumn, "softcol", 0 },
1698 { rtfSpecialChar, rtfSoftLine, "softline", 0 },
1699 { rtfSpecialChar, rtfSoftLineHt, "softlheight", 0 },
1700 { rtfSpecialChar, rtfTab, "tab", 0 },
1701 { rtfSpecialChar, rtfEmDash, "emdash", 0 },
1702 { rtfSpecialChar, rtfEnDash, "endash", 0 },
1703 { rtfSpecialChar, rtfEmSpace, "emspace", 0 },
1704 { rtfSpecialChar, rtfEnSpace, "enspace", 0 },
1705 { rtfSpecialChar, rtfBullet, "bullet", 0 },
1706 { rtfSpecialChar, rtfLQuote, "lquote", 0 },
1707 { rtfSpecialChar, rtfRQuote, "rquote", 0 },
1708 { rtfSpecialChar, rtfLDblQuote, "ldblquote", 0 },
1709 { rtfSpecialChar, rtfRDblQuote, "rdblquote", 0 },
1710 { rtfSpecialChar, rtfFormula, "|", 0 },
1711 { rtfSpecialChar, rtfNoBrkSpace, "~", 0 },
1712 { rtfSpecialChar, rtfNoReqHyphen, "-", 0 },
1713 { rtfSpecialChar, rtfNoBrkHyphen, "_", 0 },
1714 { rtfSpecialChar, rtfOptDest, "*", 0 },
1715 { rtfSpecialChar, rtfLTRMark, "ltrmark", 0 },
1716 { rtfSpecialChar, rtfRTLMark, "rtlmark", 0 },
1717 { rtfSpecialChar, rtfNoWidthJoiner, "zwj", 0 },
1718 { rtfSpecialChar, rtfNoWidthNonJoiner, "zwnj", 0 },
1719 /* is this valid? */
1720 { rtfSpecialChar, rtfCurHeadPict, "chpict", 0 },
1723 * Character formatting attributes
1726 { rtfCharAttr, rtfPlain, "plain", 0 },
1727 { rtfCharAttr, rtfBold, "b", 0 },
1728 { rtfCharAttr, rtfAllCaps, "caps", 0 },
1729 { rtfCharAttr, rtfDeleted, "deleted", 0 },
1730 { rtfCharAttr, rtfSubScript, "dn", 0 },
1731 { rtfCharAttr, rtfSubScrShrink, "sub", 0 },
1732 { rtfCharAttr, rtfNoSuperSub, "nosupersub", 0 },
1733 { rtfCharAttr, rtfExpand, "expnd", 0 },
1734 { rtfCharAttr, rtfExpandTwips, "expndtw", 0 },
1735 { rtfCharAttr, rtfKerning, "kerning", 0 },
1736 { rtfCharAttr, rtfFontNum, "f", 0 },
1737 { rtfCharAttr, rtfFontSize, "fs", 0 },
1738 { rtfCharAttr, rtfItalic, "i", 0 },
1739 { rtfCharAttr, rtfOutline, "outl", 0 },
1740 { rtfCharAttr, rtfRevised, "revised", 0 },
1741 { rtfCharAttr, rtfRevAuthor, "revauth", 0 },
1742 { rtfCharAttr, rtfRevDTTM, "revdttm", 0 },
1743 { rtfCharAttr, rtfSmallCaps, "scaps", 0 },
1744 { rtfCharAttr, rtfShadow, "shad", 0 },
1745 { rtfCharAttr, rtfStrikeThru, "strike", 0 },
1746 { rtfCharAttr, rtfUnderline, "ul", 0 },
1747 { rtfCharAttr, rtfDotUnderline, "uld", 0 },
1748 { rtfCharAttr, rtfDbUnderline, "uldb", 0 },
1749 { rtfCharAttr, rtfNoUnderline, "ulnone", 0 },
1750 { rtfCharAttr, rtfWordUnderline, "ulw", 0 },
1751 { rtfCharAttr, rtfSuperScript, "up", 0 },
1752 { rtfCharAttr, rtfSuperScrShrink, "super", 0 },
1753 { rtfCharAttr, rtfInvisible, "v", 0 },
1754 { rtfCharAttr, rtfForeColor, "cf", 0 },
1755 { rtfCharAttr, rtfBackColor, "cb", 0 },
1756 { rtfCharAttr, rtfRTLChar, "rtlch", 0 },
1757 { rtfCharAttr, rtfLTRChar, "ltrch", 0 },
1758 { rtfCharAttr, rtfCharStyleNum, "cs", 0 },
1759 { rtfCharAttr, rtfCharCharSet, "cchs", 0 },
1760 { rtfCharAttr, rtfLanguage, "lang", 0 },
1761 /* this has disappeared from spec 1.2 */
1762 { rtfCharAttr, rtfGray, "gray", 0 },
1765 * Paragraph formatting attributes
1768 { rtfParAttr, rtfParDef, "pard", 0 },
1769 { rtfParAttr, rtfStyleNum, "s", 0 },
1770 { rtfParAttr, rtfHyphenate, "hyphpar", 0 },
1771 { rtfParAttr, rtfInTable, "intbl", 0 },
1772 { rtfParAttr, rtfKeep, "keep", 0 },
1773 { rtfParAttr, rtfNoWidowControl, "nowidctlpar", 0 },
1774 { rtfParAttr, rtfKeepNext, "keepn", 0 },
1775 { rtfParAttr, rtfOutlineLevel, "level", 0 },
1776 { rtfParAttr, rtfNoLineNum, "noline", 0 },
1777 { rtfParAttr, rtfPBBefore, "pagebb", 0 },
1778 { rtfParAttr, rtfSideBySide, "sbys", 0 },
1779 { rtfParAttr, rtfQuadLeft, "ql", 0 },
1780 { rtfParAttr, rtfQuadRight, "qr", 0 },
1781 { rtfParAttr, rtfQuadJust, "qj", 0 },
1782 { rtfParAttr, rtfQuadCenter, "qc", 0 },
1783 { rtfParAttr, rtfFirstIndent, "fi", 0 },
1784 { rtfParAttr, rtfLeftIndent, "li", 0 },
1785 { rtfParAttr, rtfRightIndent, "ri", 0 },
1786 { rtfParAttr, rtfSpaceBefore, "sb", 0 },
1787 { rtfParAttr, rtfSpaceAfter, "sa", 0 },
1788 { rtfParAttr, rtfSpaceBetween, "sl", 0 },
1789 { rtfParAttr, rtfSpaceMultiply, "slmult", 0 },
1791 { rtfParAttr, rtfSubDocument, "subdocument", 0 },
1793 { rtfParAttr, rtfRTLPar, "rtlpar", 0 },
1794 { rtfParAttr, rtfLTRPar, "ltrpar", 0 },
1796 { rtfParAttr, rtfTabPos, "tx", 0 },
1798 * FrameMaker writes \tql (to mean left-justified tab, apparently)
1799 * although it's not in the spec. It's also redundant, since lj
1800 * tabs are the default.
1802 { rtfParAttr, rtfTabLeft, "tql", 0 },
1803 { rtfParAttr, rtfTabRight, "tqr", 0 },
1804 { rtfParAttr, rtfTabCenter, "tqc", 0 },
1805 { rtfParAttr, rtfTabDecimal, "tqdec", 0 },
1806 { rtfParAttr, rtfTabBar, "tb", 0 },
1807 { rtfParAttr, rtfLeaderDot, "tldot", 0 },
1808 { rtfParAttr, rtfLeaderHyphen, "tlhyph", 0 },
1809 { rtfParAttr, rtfLeaderUnder, "tlul", 0 },
1810 { rtfParAttr, rtfLeaderThick, "tlth", 0 },
1811 { rtfParAttr, rtfLeaderEqual, "tleq", 0 },
1813 { rtfParAttr, rtfParLevel, "pnlvl", 0 },
1814 { rtfParAttr, rtfParBullet, "pnlvlblt", 0 },
1815 { rtfParAttr, rtfParSimple, "pnlvlbody", 0 },
1816 { rtfParAttr, rtfParNumCont, "pnlvlcont", 0 },
1817 { rtfParAttr, rtfParNumOnce, "pnnumonce", 0 },
1818 { rtfParAttr, rtfParNumAcross, "pnacross", 0 },
1819 { rtfParAttr, rtfParHangIndent, "pnhang", 0 },
1820 { rtfParAttr, rtfParNumRestart, "pnrestart", 0 },
1821 { rtfParAttr, rtfParNumCardinal, "pncard", 0 },
1822 { rtfParAttr, rtfParNumDecimal, "pndec", 0 },
1823 { rtfParAttr, rtfParNumULetter, "pnucltr", 0 },
1824 { rtfParAttr, rtfParNumURoman, "pnucrm", 0 },
1825 { rtfParAttr, rtfParNumLLetter, "pnlcltr", 0 },
1826 { rtfParAttr, rtfParNumLRoman, "pnlcrm", 0 },
1827 { rtfParAttr, rtfParNumOrdinal, "pnord", 0 },
1828 { rtfParAttr, rtfParNumOrdinalText, "pnordt", 0 },
1829 { rtfParAttr, rtfParNumBold, "pnb", 0 },
1830 { rtfParAttr, rtfParNumItalic, "pni", 0 },
1831 { rtfParAttr, rtfParNumAllCaps, "pncaps", 0 },
1832 { rtfParAttr, rtfParNumSmallCaps, "pnscaps", 0 },
1833 { rtfParAttr, rtfParNumUnder, "pnul", 0 },
1834 { rtfParAttr, rtfParNumDotUnder, "pnuld", 0 },
1835 { rtfParAttr, rtfParNumDbUnder, "pnuldb", 0 },
1836 { rtfParAttr, rtfParNumNoUnder, "pnulnone", 0 },
1837 { rtfParAttr, rtfParNumWordUnder, "pnulw", 0 },
1838 { rtfParAttr, rtfParNumStrikethru, "pnstrike", 0 },
1839 { rtfParAttr, rtfParNumForeColor, "pncf", 0 },
1840 { rtfParAttr, rtfParNumFont, "pnf", 0 },
1841 { rtfParAttr, rtfParNumFontSize, "pnfs", 0 },
1842 { rtfParAttr, rtfParNumIndent, "pnindent", 0 },
1843 { rtfParAttr, rtfParNumSpacing, "pnsp", 0 },
1844 { rtfParAttr, rtfParNumInclPrev, "pnprev", 0 },
1845 { rtfParAttr, rtfParNumCenter, "pnqc", 0 },
1846 { rtfParAttr, rtfParNumLeft, "pnql", 0 },
1847 { rtfParAttr, rtfParNumRight, "pnqr", 0 },
1848 { rtfParAttr, rtfParNumStartAt, "pnstart", 0 },
1850 { rtfParAttr, rtfBorderTop, "brdrt", 0 },
1851 { rtfParAttr, rtfBorderBottom, "brdrb", 0 },
1852 { rtfParAttr, rtfBorderLeft, "brdrl", 0 },
1853 { rtfParAttr, rtfBorderRight, "brdrr", 0 },
1854 { rtfParAttr, rtfBorderBetween, "brdrbtw", 0 },
1855 { rtfParAttr, rtfBorderBar, "brdrbar", 0 },
1856 { rtfParAttr, rtfBorderBox, "box", 0 },
1857 { rtfParAttr, rtfBorderSingle, "brdrs", 0 },
1858 { rtfParAttr, rtfBorderThick, "brdrth", 0 },
1859 { rtfParAttr, rtfBorderShadow, "brdrsh", 0 },
1860 { rtfParAttr, rtfBorderDouble, "brdrdb", 0 },
1861 { rtfParAttr, rtfBorderDot, "brdrdot", 0 },
1862 { rtfParAttr, rtfBorderDot, "brdrdash", 0 },
1863 { rtfParAttr, rtfBorderHair, "brdrhair", 0 },
1864 { rtfParAttr, rtfBorderWidth, "brdrw", 0 },
1865 { rtfParAttr, rtfBorderColor, "brdrcf", 0 },
1866 { rtfParAttr, rtfBorderSpace, "brsp", 0 },
1868 { rtfParAttr, rtfShading, "shading", 0 },
1869 { rtfParAttr, rtfBgPatH, "bghoriz", 0 },
1870 { rtfParAttr, rtfBgPatV, "bgvert", 0 },
1871 { rtfParAttr, rtfFwdDiagBgPat, "bgfdiag", 0 },
1872 { rtfParAttr, rtfBwdDiagBgPat, "bgbdiag", 0 },
1873 { rtfParAttr, rtfHatchBgPat, "bgcross", 0 },
1874 { rtfParAttr, rtfDiagHatchBgPat, "bgdcross", 0 },
1875 { rtfParAttr, rtfDarkBgPatH, "bgdkhoriz", 0 },
1876 { rtfParAttr, rtfDarkBgPatV, "bgdkvert", 0 },
1877 { rtfParAttr, rtfFwdDarkBgPat, "bgdkfdiag", 0 },
1878 { rtfParAttr, rtfBwdDarkBgPat, "bgdkbdiag", 0 },
1879 { rtfParAttr, rtfDarkHatchBgPat, "bgdkcross", 0 },
1880 { rtfParAttr, rtfDarkDiagHatchBgPat, "bgdkdcross", 0 },
1881 { rtfParAttr, rtfBgPatLineColor, "cfpat", 0 },
1882 { rtfParAttr, rtfBgPatColor, "cbpat", 0 },
1885 * Section formatting attributes
1888 { rtfSectAttr, rtfSectDef, "sectd", 0 },
1889 { rtfSectAttr, rtfENoteHere, "endnhere", 0 },
1890 { rtfSectAttr, rtfPrtBinFirst, "binfsxn", 0 },
1891 { rtfSectAttr, rtfPrtBin, "binsxn", 0 },
1892 { rtfSectAttr, rtfSectStyleNum, "ds", 0 },
1894 { rtfSectAttr, rtfNoBreak, "sbknone", 0 },
1895 { rtfSectAttr, rtfColBreak, "sbkcol", 0 },
1896 { rtfSectAttr, rtfPageBreak, "sbkpage", 0 },
1897 { rtfSectAttr, rtfEvenBreak, "sbkeven", 0 },
1898 { rtfSectAttr, rtfOddBreak, "sbkodd", 0 },
1900 { rtfSectAttr, rtfColumns, "cols", 0 },
1901 { rtfSectAttr, rtfColumnSpace, "colsx", 0 },
1902 { rtfSectAttr, rtfColumnNumber, "colno", 0 },
1903 { rtfSectAttr, rtfColumnSpRight, "colsr", 0 },
1904 { rtfSectAttr, rtfColumnWidth, "colw", 0 },
1905 { rtfSectAttr, rtfColumnLine, "linebetcol", 0 },
1907 { rtfSectAttr, rtfLineModulus, "linemod", 0 },
1908 { rtfSectAttr, rtfLineDist, "linex", 0 },
1909 { rtfSectAttr, rtfLineStarts, "linestarts", 0 },
1910 { rtfSectAttr, rtfLineRestart, "linerestart", 0 },
1911 { rtfSectAttr, rtfLineRestartPg, "lineppage", 0 },
1912 { rtfSectAttr, rtfLineCont, "linecont", 0 },
1914 { rtfSectAttr, rtfSectPageWid, "pgwsxn", 0 },
1915 { rtfSectAttr, rtfSectPageHt, "pghsxn", 0 },
1916 { rtfSectAttr, rtfSectMarginLeft, "marglsxn", 0 },
1917 { rtfSectAttr, rtfSectMarginRight, "margrsxn", 0 },
1918 { rtfSectAttr, rtfSectMarginTop, "margtsxn", 0 },
1919 { rtfSectAttr, rtfSectMarginBottom, "margbsxn", 0 },
1920 { rtfSectAttr, rtfSectMarginGutter, "guttersxn", 0 },
1921 { rtfSectAttr, rtfSectLandscape, "lndscpsxn", 0 },
1922 { rtfSectAttr, rtfTitleSpecial, "titlepg", 0 },
1923 { rtfSectAttr, rtfHeaderY, "headery", 0 },
1924 { rtfSectAttr, rtfFooterY, "footery", 0 },
1926 { rtfSectAttr, rtfPageStarts, "pgnstarts", 0 },
1927 { rtfSectAttr, rtfPageCont, "pgncont", 0 },
1928 { rtfSectAttr, rtfPageRestart, "pgnrestart", 0 },
1929 { rtfSectAttr, rtfPageNumRight, "pgnx", 0 },
1930 { rtfSectAttr, rtfPageNumTop, "pgny", 0 },
1931 { rtfSectAttr, rtfPageDecimal, "pgndec", 0 },
1932 { rtfSectAttr, rtfPageURoman, "pgnucrm", 0 },
1933 { rtfSectAttr, rtfPageLRoman, "pgnlcrm", 0 },
1934 { rtfSectAttr, rtfPageULetter, "pgnucltr", 0 },
1935 { rtfSectAttr, rtfPageLLetter, "pgnlcltr", 0 },
1936 { rtfSectAttr, rtfPageNumHyphSep, "pgnhnsh", 0 },
1937 { rtfSectAttr, rtfPageNumSpaceSep, "pgnhnsp", 0 },
1938 { rtfSectAttr, rtfPageNumColonSep, "pgnhnsc", 0 },
1939 { rtfSectAttr, rtfPageNumEmdashSep, "pgnhnsm", 0 },
1940 { rtfSectAttr, rtfPageNumEndashSep, "pgnhnsn", 0 },
1942 { rtfSectAttr, rtfTopVAlign, "vertalt", 0 },
1943 /* misspelled as "vertal" in specification 1.0 */
1944 { rtfSectAttr, rtfBottomVAlign, "vertalb", 0 },
1945 { rtfSectAttr, rtfCenterVAlign, "vertalc", 0 },
1946 { rtfSectAttr, rtfJustVAlign, "vertalj", 0 },
1948 { rtfSectAttr, rtfRTLSect, "rtlsect", 0 },
1949 { rtfSectAttr, rtfLTRSect, "ltrsect", 0 },
1951 /* I've seen these in an old spec, but not in real files... */
1952 /*rtfSectAttr, rtfNoBreak, "nobreak", 0,*/
1953 /*rtfSectAttr, rtfColBreak, "colbreak", 0,*/
1954 /*rtfSectAttr, rtfPageBreak, "pagebreak", 0,*/
1955 /*rtfSectAttr, rtfEvenBreak, "evenbreak", 0,*/
1956 /*rtfSectAttr, rtfOddBreak, "oddbreak", 0,*/
1959 * Document formatting attributes
1962 { rtfDocAttr, rtfDefTab, "deftab", 0 },
1963 { rtfDocAttr, rtfHyphHotZone, "hyphhotz", 0 },
1964 { rtfDocAttr, rtfHyphConsecLines, "hyphconsec", 0 },
1965 { rtfDocAttr, rtfHyphCaps, "hyphcaps", 0 },
1966 { rtfDocAttr, rtfHyphAuto, "hyphauto", 0 },
1967 { rtfDocAttr, rtfLineStart, "linestart", 0 },
1968 { rtfDocAttr, rtfFracWidth, "fracwidth", 0 },
1969 /* \makeback was given in old version of spec, it's now */
1970 /* listed as \makebackup */
1971 { rtfDocAttr, rtfMakeBackup, "makeback", 0 },
1972 { rtfDocAttr, rtfMakeBackup, "makebackup", 0 },
1973 { rtfDocAttr, rtfRTFDefault, "defformat", 0 },
1974 { rtfDocAttr, rtfPSOverlay, "psover", 0 },
1975 { rtfDocAttr, rtfDocTemplate, "doctemp", 0 },
1976 { rtfDocAttr, rtfDefLanguage, "deflang", 0 },
1978 { rtfDocAttr, rtfFENoteType, "fet", 0 },
1979 { rtfDocAttr, rtfFNoteEndSect, "endnotes", 0 },
1980 { rtfDocAttr, rtfFNoteEndDoc, "enddoc", 0 },
1981 { rtfDocAttr, rtfFNoteText, "ftntj", 0 },
1982 { rtfDocAttr, rtfFNoteBottom, "ftnbj", 0 },
1983 { rtfDocAttr, rtfENoteEndSect, "aendnotes", 0 },
1984 { rtfDocAttr, rtfENoteEndDoc, "aenddoc", 0 },
1985 { rtfDocAttr, rtfENoteText, "aftntj", 0 },
1986 { rtfDocAttr, rtfENoteBottom, "aftnbj", 0 },
1987 { rtfDocAttr, rtfFNoteStart, "ftnstart", 0 },
1988 { rtfDocAttr, rtfENoteStart, "aftnstart", 0 },
1989 { rtfDocAttr, rtfFNoteRestartPage, "ftnrstpg", 0 },
1990 { rtfDocAttr, rtfFNoteRestart, "ftnrestart", 0 },
1991 { rtfDocAttr, rtfFNoteRestartCont, "ftnrstcont", 0 },
1992 { rtfDocAttr, rtfENoteRestart, "aftnrestart", 0 },
1993 { rtfDocAttr, rtfENoteRestartCont, "aftnrstcont", 0 },
1994 { rtfDocAttr, rtfFNoteNumArabic, "ftnnar", 0 },
1995 { rtfDocAttr, rtfFNoteNumLLetter, "ftnnalc", 0 },
1996 { rtfDocAttr, rtfFNoteNumULetter, "ftnnauc", 0 },
1997 { rtfDocAttr, rtfFNoteNumLRoman, "ftnnrlc", 0 },
1998 { rtfDocAttr, rtfFNoteNumURoman, "ftnnruc", 0 },
1999 { rtfDocAttr, rtfFNoteNumChicago, "ftnnchi", 0 },
2000 { rtfDocAttr, rtfENoteNumArabic, "aftnnar", 0 },
2001 { rtfDocAttr, rtfENoteNumLLetter, "aftnnalc", 0 },
2002 { rtfDocAttr, rtfENoteNumULetter, "aftnnauc", 0 },
2003 { rtfDocAttr, rtfENoteNumLRoman, "aftnnrlc", 0 },
2004 { rtfDocAttr, rtfENoteNumURoman, "aftnnruc", 0 },
2005 { rtfDocAttr, rtfENoteNumChicago, "aftnnchi", 0 },
2007 { rtfDocAttr, rtfPaperWidth, "paperw", 0 },
2008 { rtfDocAttr, rtfPaperHeight, "paperh", 0 },
2009 { rtfDocAttr, rtfPaperSize, "psz", 0 },
2010 { rtfDocAttr, rtfLeftMargin, "margl", 0 },
2011 { rtfDocAttr, rtfRightMargin, "margr", 0 },
2012 { rtfDocAttr, rtfTopMargin, "margt", 0 },
2013 { rtfDocAttr, rtfBottomMargin, "margb", 0 },
2014 { rtfDocAttr, rtfFacingPage, "facingp", 0 },
2015 { rtfDocAttr, rtfGutterWid, "gutter", 0 },
2016 { rtfDocAttr, rtfMirrorMargin, "margmirror", 0 },
2017 { rtfDocAttr, rtfLandscape, "landscape", 0 },
2018 { rtfDocAttr, rtfPageStart, "pgnstart", 0 },
2019 { rtfDocAttr, rtfWidowCtrl, "widowctrl", 0 },
2021 { rtfDocAttr, rtfLinkStyles, "linkstyles", 0 },
2023 { rtfDocAttr, rtfNoAutoTabIndent, "notabind", 0 },
2024 { rtfDocAttr, rtfWrapSpaces, "wraptrsp", 0 },
2025 { rtfDocAttr, rtfPrintColorsBlack, "prcolbl", 0 },
2026 { rtfDocAttr, rtfNoExtraSpaceRL, "noextrasprl", 0 },
2027 { rtfDocAttr, rtfNoColumnBalance, "nocolbal", 0 },
2028 { rtfDocAttr, rtfCvtMailMergeQuote, "cvmme", 0 },
2029 { rtfDocAttr, rtfSuppressTopSpace, "sprstsp", 0 },
2030 { rtfDocAttr, rtfSuppressPreParSpace, "sprsspbf", 0 },
2031 { rtfDocAttr, rtfCombineTblBorders, "otblrul", 0 },
2032 { rtfDocAttr, rtfTranspMetafiles, "transmf", 0 },
2033 { rtfDocAttr, rtfSwapBorders, "swpbdr", 0 },
2034 { rtfDocAttr, rtfShowHardBreaks, "brkfrm", 0 },
2036 { rtfDocAttr, rtfFormProtected, "formprot", 0 },
2037 { rtfDocAttr, rtfAllProtected, "allprot", 0 },
2038 { rtfDocAttr, rtfFormShading, "formshade", 0 },
2039 { rtfDocAttr, rtfFormDisplay, "formdisp", 0 },
2040 { rtfDocAttr, rtfPrintData, "printdata", 0 },
2042 { rtfDocAttr, rtfRevProtected, "revprot", 0 },
2043 { rtfDocAttr, rtfRevisions, "revisions", 0 },
2044 { rtfDocAttr, rtfRevDisplay, "revprop", 0 },
2045 { rtfDocAttr, rtfRevBar, "revbar", 0 },
2047 { rtfDocAttr, rtfAnnotProtected, "annotprot", 0 },
2049 { rtfDocAttr, rtfRTLDoc, "rtldoc", 0 },
2050 { rtfDocAttr, rtfLTRDoc, "ltrdoc", 0 },
2053 * Style attributes
2056 { rtfStyleAttr, rtfAdditive, "additive", 0 },
2057 { rtfStyleAttr, rtfBasedOn, "sbasedon", 0 },
2058 { rtfStyleAttr, rtfNext, "snext", 0 },
2061 * Picture attributes
2064 { rtfPictAttr, rtfMacQD, "macpict", 0 },
2065 { rtfPictAttr, rtfPMMetafile, "pmmetafile", 0 },
2066 { rtfPictAttr, rtfWinMetafile, "wmetafile", 0 },
2067 { rtfPictAttr, rtfDevIndBitmap, "dibitmap", 0 },
2068 { rtfPictAttr, rtfWinBitmap, "wbitmap", 0 },
2069 { rtfPictAttr, rtfPixelBits, "wbmbitspixel", 0 },
2070 { rtfPictAttr, rtfBitmapPlanes, "wbmplanes", 0 },
2071 { rtfPictAttr, rtfBitmapWid, "wbmwidthbytes", 0 },
2073 { rtfPictAttr, rtfPicWid, "picw", 0 },
2074 { rtfPictAttr, rtfPicHt, "pich", 0 },
2075 { rtfPictAttr, rtfPicGoalWid, "picwgoal", 0 },
2076 { rtfPictAttr, rtfPicGoalHt, "pichgoal", 0 },
2077 /* these two aren't in the spec, but some writers emit them */
2078 { rtfPictAttr, rtfPicGoalWid, "picwGoal", 0 },
2079 { rtfPictAttr, rtfPicGoalHt, "pichGoal", 0 },
2080 { rtfPictAttr, rtfPicScaleX, "picscalex", 0 },
2081 { rtfPictAttr, rtfPicScaleY, "picscaley", 0 },
2082 { rtfPictAttr, rtfPicScaled, "picscaled", 0 },
2083 { rtfPictAttr, rtfPicCropTop, "piccropt", 0 },
2084 { rtfPictAttr, rtfPicCropBottom, "piccropb", 0 },
2085 { rtfPictAttr, rtfPicCropLeft, "piccropl", 0 },
2086 { rtfPictAttr, rtfPicCropRight, "piccropr", 0 },
2088 { rtfPictAttr, rtfPicMFHasBitmap, "picbmp", 0 },
2089 { rtfPictAttr, rtfPicMFBitsPerPixel, "picbpp", 0 },
2091 { rtfPictAttr, rtfPicBinary, "bin", 0 },
2094 * NeXT graphic attributes
2097 { rtfNeXTGrAttr, rtfNeXTGWidth, "width", 0 },
2098 { rtfNeXTGrAttr, rtfNeXTGHeight, "height", 0 },
2101 * Destinations
2104 { rtfDestination, rtfFontTbl, "fonttbl", 0 },
2105 { rtfDestination, rtfFontAltName, "falt", 0 },
2106 { rtfDestination, rtfEmbeddedFont, "fonteb", 0 },
2107 { rtfDestination, rtfFontFile, "fontfile", 0 },
2108 { rtfDestination, rtfFileTbl, "filetbl", 0 },
2109 { rtfDestination, rtfFileInfo, "file", 0 },
2110 { rtfDestination, rtfColorTbl, "colortbl", 0 },
2111 { rtfDestination, rtfStyleSheet, "stylesheet", 0 },
2112 { rtfDestination, rtfKeyCode, "keycode", 0 },
2113 { rtfDestination, rtfRevisionTbl, "revtbl", 0 },
2114 { rtfDestination, rtfInfo, "info", 0 },
2115 { rtfDestination, rtfITitle, "title", 0 },
2116 { rtfDestination, rtfISubject, "subject", 0 },
2117 { rtfDestination, rtfIAuthor, "author", 0 },
2118 { rtfDestination, rtfIOperator, "operator", 0 },
2119 { rtfDestination, rtfIKeywords, "keywords", 0 },
2120 { rtfDestination, rtfIComment, "comment", 0 },
2121 { rtfDestination, rtfIVersion, "version", 0 },
2122 { rtfDestination, rtfIDoccomm, "doccomm", 0 },
2123 /* \verscomm may not exist -- was seen in earlier spec version */
2124 { rtfDestination, rtfIVerscomm, "verscomm", 0 },
2125 { rtfDestination, rtfNextFile, "nextfile", 0 },
2126 { rtfDestination, rtfTemplate, "template", 0 },
2127 { rtfDestination, rtfFNSep, "ftnsep", 0 },
2128 { rtfDestination, rtfFNContSep, "ftnsepc", 0 },
2129 { rtfDestination, rtfFNContNotice, "ftncn", 0 },
2130 { rtfDestination, rtfENSep, "aftnsep", 0 },
2131 { rtfDestination, rtfENContSep, "aftnsepc", 0 },
2132 { rtfDestination, rtfENContNotice, "aftncn", 0 },
2133 { rtfDestination, rtfPageNumLevel, "pgnhn", 0 },
2134 { rtfDestination, rtfParNumLevelStyle, "pnseclvl", 0 },
2135 { rtfDestination, rtfHeader, "header", 0 },
2136 { rtfDestination, rtfFooter, "footer", 0 },
2137 { rtfDestination, rtfHeaderLeft, "headerl", 0 },
2138 { rtfDestination, rtfHeaderRight, "headerr", 0 },
2139 { rtfDestination, rtfHeaderFirst, "headerf", 0 },
2140 { rtfDestination, rtfFooterLeft, "footerl", 0 },
2141 { rtfDestination, rtfFooterRight, "footerr", 0 },
2142 { rtfDestination, rtfFooterFirst, "footerf", 0 },
2143 { rtfDestination, rtfParNumText, "pntext", 0 },
2144 { rtfDestination, rtfParNumbering, "pn", 0 },
2145 { rtfDestination, rtfParNumTextAfter, "pntexta", 0 },
2146 { rtfDestination, rtfParNumTextBefore, "pntextb", 0 },
2147 { rtfDestination, rtfBookmarkStart, "bkmkstart", 0 },
2148 { rtfDestination, rtfBookmarkEnd, "bkmkend", 0 },
2149 { rtfDestination, rtfPict, "pict", 0 },
2150 { rtfDestination, rtfObject, "object", 0 },
2151 { rtfDestination, rtfObjClass, "objclass", 0 },
2152 { rtfDestination, rtfObjName, "objname", 0 },
2153 { rtfObjAttr, rtfObjTime, "objtime", 0 },
2154 { rtfDestination, rtfObjData, "objdata", 0 },
2155 { rtfDestination, rtfObjAlias, "objalias", 0 },
2156 { rtfDestination, rtfObjSection, "objsect", 0 },
2157 /* objitem and objtopic aren't documented in the spec! */
2158 { rtfDestination, rtfObjItem, "objitem", 0 },
2159 { rtfDestination, rtfObjTopic, "objtopic", 0 },
2160 { rtfDestination, rtfObjResult, "result", 0 },
2161 { rtfDestination, rtfDrawObject, "do", 0 },
2162 { rtfDestination, rtfFootnote, "footnote", 0 },
2163 { rtfDestination, rtfAnnotRefStart, "atrfstart", 0 },
2164 { rtfDestination, rtfAnnotRefEnd, "atrfend", 0 },
2165 { rtfDestination, rtfAnnotID, "atnid", 0 },
2166 { rtfDestination, rtfAnnotAuthor, "atnauthor", 0 },
2167 { rtfDestination, rtfAnnotation, "annotation", 0 },
2168 { rtfDestination, rtfAnnotRef, "atnref", 0 },
2169 { rtfDestination, rtfAnnotTime, "atntime", 0 },
2170 { rtfDestination, rtfAnnotIcon, "atnicn", 0 },
2171 { rtfDestination, rtfField, "field", 0 },
2172 { rtfDestination, rtfFieldInst, "fldinst", 0 },
2173 { rtfDestination, rtfFieldResult, "fldrslt", 0 },
2174 { rtfDestination, rtfDataField, "datafield", 0 },
2175 { rtfDestination, rtfIndex, "xe", 0 },
2176 { rtfDestination, rtfIndexText, "txe", 0 },
2177 { rtfDestination, rtfIndexRange, "rxe", 0 },
2178 { rtfDestination, rtfTOC, "tc", 0 },
2179 { rtfDestination, rtfNeXTGraphic, "NeXTGraphic", 0 },
2182 * Font families
2185 { rtfFontFamily, rtfFFNil, "fnil", 0 },
2186 { rtfFontFamily, rtfFFRoman, "froman", 0 },
2187 { rtfFontFamily, rtfFFSwiss, "fswiss", 0 },
2188 { rtfFontFamily, rtfFFModern, "fmodern", 0 },
2189 { rtfFontFamily, rtfFFScript, "fscript", 0 },
2190 { rtfFontFamily, rtfFFDecor, "fdecor", 0 },
2191 { rtfFontFamily, rtfFFTech, "ftech", 0 },
2192 { rtfFontFamily, rtfFFBidirectional, "fbidi", 0 },
2195 * Font attributes
2198 { rtfFontAttr, rtfFontCharSet, "fcharset", 0 },
2199 { rtfFontAttr, rtfFontPitch, "fprq", 0 },
2200 { rtfFontAttr, rtfFontCodePage, "cpg", 0 },
2201 { rtfFontAttr, rtfFTypeNil, "ftnil", 0 },
2202 { rtfFontAttr, rtfFTypeTrueType, "fttruetype", 0 },
2205 * File table attributes
2208 { rtfFileAttr, rtfFileNum, "fid", 0 },
2209 { rtfFileAttr, rtfFileRelPath, "frelative", 0 },
2210 { rtfFileAttr, rtfFileOSNum, "fosnum", 0 },
2213 * File sources
2216 { rtfFileSource, rtfSrcMacintosh, "fvalidmac", 0 },
2217 { rtfFileSource, rtfSrcDOS, "fvaliddos", 0 },
2218 { rtfFileSource, rtfSrcNTFS, "fvalidntfs", 0 },
2219 { rtfFileSource, rtfSrcHPFS, "fvalidhpfs", 0 },
2220 { rtfFileSource, rtfSrcNetwork, "fnetwork", 0 },
2223 * Color names
2226 { rtfColorName, rtfRed, "red", 0 },
2227 { rtfColorName, rtfGreen, "green", 0 },
2228 { rtfColorName, rtfBlue, "blue", 0 },
2231 * Charset names
2234 { rtfCharSet, rtfMacCharSet, "mac", 0 },
2235 { rtfCharSet, rtfAnsiCharSet, "ansi", 0 },
2236 { rtfCharSet, rtfPcCharSet, "pc", 0 },
2237 { rtfCharSet, rtfPcaCharSet, "pca", 0 },
2240 * Table attributes
2243 { rtfTblAttr, rtfRowDef, "trowd", 0 },
2244 { rtfTblAttr, rtfRowGapH, "trgaph", 0 },
2245 { rtfTblAttr, rtfCellPos, "cellx", 0 },
2246 { rtfTblAttr, rtfMergeRngFirst, "clmgf", 0 },
2247 { rtfTblAttr, rtfMergePrevious, "clmrg", 0 },
2249 { rtfTblAttr, rtfRowLeft, "trql", 0 },
2250 { rtfTblAttr, rtfRowRight, "trqr", 0 },
2251 { rtfTblAttr, rtfRowCenter, "trqc", 0 },
2252 { rtfTblAttr, rtfRowLeftEdge, "trleft", 0 },
2253 { rtfTblAttr, rtfRowHt, "trrh", 0 },
2254 { rtfTblAttr, rtfRowHeader, "trhdr", 0 },
2255 { rtfTblAttr, rtfRowKeep, "trkeep", 0 },
2257 { rtfTblAttr, rtfRTLRow, "rtlrow", 0 },
2258 { rtfTblAttr, rtfLTRRow, "ltrrow", 0 },
2260 { rtfTblAttr, rtfRowBordTop, "trbrdrt", 0 },
2261 { rtfTblAttr, rtfRowBordLeft, "trbrdrl", 0 },
2262 { rtfTblAttr, rtfRowBordBottom, "trbrdrb", 0 },
2263 { rtfTblAttr, rtfRowBordRight, "trbrdrr", 0 },
2264 { rtfTblAttr, rtfRowBordHoriz, "trbrdrh", 0 },
2265 { rtfTblAttr, rtfRowBordVert, "trbrdrv", 0 },
2267 { rtfTblAttr, rtfCellBordBottom, "clbrdrb", 0 },
2268 { rtfTblAttr, rtfCellBordTop, "clbrdrt", 0 },
2269 { rtfTblAttr, rtfCellBordLeft, "clbrdrl", 0 },
2270 { rtfTblAttr, rtfCellBordRight, "clbrdrr", 0 },
2272 { rtfTblAttr, rtfCellShading, "clshdng", 0 },
2273 { rtfTblAttr, rtfCellBgPatH, "clbghoriz", 0 },
2274 { rtfTblAttr, rtfCellBgPatV, "clbgvert", 0 },
2275 { rtfTblAttr, rtfCellFwdDiagBgPat, "clbgfdiag", 0 },
2276 { rtfTblAttr, rtfCellBwdDiagBgPat, "clbgbdiag", 0 },
2277 { rtfTblAttr, rtfCellHatchBgPat, "clbgcross", 0 },
2278 { rtfTblAttr, rtfCellDiagHatchBgPat, "clbgdcross", 0 },
2280 * The spec lists "clbgdkhor", but the corresponding non-cell
2281 * control is "bgdkhoriz". At any rate Macintosh Word seems
2282 * to accept both "clbgdkhor" and "clbgdkhoriz".
2284 { rtfTblAttr, rtfCellDarkBgPatH, "clbgdkhoriz", 0 },
2285 { rtfTblAttr, rtfCellDarkBgPatH, "clbgdkhor", 0 },
2286 { rtfTblAttr, rtfCellDarkBgPatV, "clbgdkvert", 0 },
2287 { rtfTblAttr, rtfCellFwdDarkBgPat, "clbgdkfdiag", 0 },
2288 { rtfTblAttr, rtfCellBwdDarkBgPat, "clbgdkbdiag", 0 },
2289 { rtfTblAttr, rtfCellDarkHatchBgPat, "clbgdkcross", 0 },
2290 { rtfTblAttr, rtfCellDarkDiagHatchBgPat, "clbgdkdcross", 0 },
2291 { rtfTblAttr, rtfCellBgPatLineColor, "clcfpat", 0 },
2292 { rtfTblAttr, rtfCellBgPatColor, "clcbpat", 0 },
2295 * Field attributes
2298 { rtfFieldAttr, rtfFieldDirty, "flddirty", 0 },
2299 { rtfFieldAttr, rtfFieldEdited, "fldedit", 0 },
2300 { rtfFieldAttr, rtfFieldLocked, "fldlock", 0 },
2301 { rtfFieldAttr, rtfFieldPrivate, "fldpriv", 0 },
2302 { rtfFieldAttr, rtfFieldAlt, "fldalt", 0 },
2305 * Positioning attributes
2308 { rtfPosAttr, rtfAbsWid, "absw", 0 },
2309 { rtfPosAttr, rtfAbsHt, "absh", 0 },
2311 { rtfPosAttr, rtfRPosMargH, "phmrg", 0 },
2312 { rtfPosAttr, rtfRPosPageH, "phpg", 0 },
2313 { rtfPosAttr, rtfRPosColH, "phcol", 0 },
2314 { rtfPosAttr, rtfPosX, "posx", 0 },
2315 { rtfPosAttr, rtfPosNegX, "posnegx", 0 },
2316 { rtfPosAttr, rtfPosXCenter, "posxc", 0 },
2317 { rtfPosAttr, rtfPosXInside, "posxi", 0 },
2318 { rtfPosAttr, rtfPosXOutSide, "posxo", 0 },
2319 { rtfPosAttr, rtfPosXRight, "posxr", 0 },
2320 { rtfPosAttr, rtfPosXLeft, "posxl", 0 },
2322 { rtfPosAttr, rtfRPosMargV, "pvmrg", 0 },
2323 { rtfPosAttr, rtfRPosPageV, "pvpg", 0 },
2324 { rtfPosAttr, rtfRPosParaV, "pvpara", 0 },
2325 { rtfPosAttr, rtfPosY, "posy", 0 },
2326 { rtfPosAttr, rtfPosNegY, "posnegy", 0 },
2327 { rtfPosAttr, rtfPosYInline, "posyil", 0 },
2328 { rtfPosAttr, rtfPosYTop, "posyt", 0 },
2329 { rtfPosAttr, rtfPosYCenter, "posyc", 0 },
2330 { rtfPosAttr, rtfPosYBottom, "posyb", 0 },
2332 { rtfPosAttr, rtfNoWrap, "nowrap", 0 },
2333 { rtfPosAttr, rtfDistFromTextAll, "dxfrtext", 0 },
2334 { rtfPosAttr, rtfDistFromTextX, "dfrmtxtx", 0 },
2335 { rtfPosAttr, rtfDistFromTextY, "dfrmtxty", 0 },
2336 /* \dyfrtext no longer exists in spec 1.2, apparently */
2337 /* replaced by \dfrmtextx and \dfrmtexty. */
2338 { rtfPosAttr, rtfTextDistY, "dyfrtext", 0 },
2340 { rtfPosAttr, rtfDropCapLines, "dropcapli", 0 },
2341 { rtfPosAttr, rtfDropCapType, "dropcapt", 0 },
2344 * Object controls
2347 { rtfObjAttr, rtfObjEmb, "objemb", 0 },
2348 { rtfObjAttr, rtfObjLink, "objlink", 0 },
2349 { rtfObjAttr, rtfObjAutoLink, "objautlink", 0 },
2350 { rtfObjAttr, rtfObjSubscriber, "objsub", 0 },
2351 { rtfObjAttr, rtfObjPublisher, "objpub", 0 },
2352 { rtfObjAttr, rtfObjICEmb, "objicemb", 0 },
2354 { rtfObjAttr, rtfObjLinkSelf, "linkself", 0 },
2355 { rtfObjAttr, rtfObjLock, "objupdate", 0 },
2356 { rtfObjAttr, rtfObjUpdate, "objlock", 0 },
2358 { rtfObjAttr, rtfObjHt, "objh", 0 },
2359 { rtfObjAttr, rtfObjWid, "objw", 0 },
2360 { rtfObjAttr, rtfObjSetSize, "objsetsize", 0 },
2361 { rtfObjAttr, rtfObjAlign, "objalign", 0 },
2362 { rtfObjAttr, rtfObjTransposeY, "objtransy", 0 },
2363 { rtfObjAttr, rtfObjCropTop, "objcropt", 0 },
2364 { rtfObjAttr, rtfObjCropBottom, "objcropb", 0 },
2365 { rtfObjAttr, rtfObjCropLeft, "objcropl", 0 },
2366 { rtfObjAttr, rtfObjCropRight, "objcropr", 0 },
2367 { rtfObjAttr, rtfObjScaleX, "objscalex", 0 },
2368 { rtfObjAttr, rtfObjScaleY, "objscaley", 0 },
2370 { rtfObjAttr, rtfObjResRTF, "rsltrtf", 0 },
2371 { rtfObjAttr, rtfObjResPict, "rsltpict", 0 },
2372 { rtfObjAttr, rtfObjResBitmap, "rsltbmp", 0 },
2373 { rtfObjAttr, rtfObjResText, "rslttxt", 0 },
2374 { rtfObjAttr, rtfObjResMerge, "rsltmerge", 0 },
2376 { rtfObjAttr, rtfObjBookmarkPubObj, "bkmkpub", 0 },
2377 { rtfObjAttr, rtfObjPubAutoUpdate, "pubauto", 0 },
2380 * Associated character formatting attributes
2383 { rtfACharAttr, rtfACBold, "ab", 0 },
2384 { rtfACharAttr, rtfACAllCaps, "caps", 0 },
2385 { rtfACharAttr, rtfACForeColor, "acf", 0 },
2386 { rtfACharAttr, rtfACSubScript, "adn", 0 },
2387 { rtfACharAttr, rtfACExpand, "aexpnd", 0 },
2388 { rtfACharAttr, rtfACFontNum, "af", 0 },
2389 { rtfACharAttr, rtfACFontSize, "afs", 0 },
2390 { rtfACharAttr, rtfACItalic, "ai", 0 },
2391 { rtfACharAttr, rtfACLanguage, "alang", 0 },
2392 { rtfACharAttr, rtfACOutline, "aoutl", 0 },
2393 { rtfACharAttr, rtfACSmallCaps, "ascaps", 0 },
2394 { rtfACharAttr, rtfACShadow, "ashad", 0 },
2395 { rtfACharAttr, rtfACStrikeThru, "astrike", 0 },
2396 { rtfACharAttr, rtfACUnderline, "aul", 0 },
2397 { rtfACharAttr, rtfACDotUnderline, "auld", 0 },
2398 { rtfACharAttr, rtfACDbUnderline, "auldb", 0 },
2399 { rtfACharAttr, rtfACNoUnderline, "aulnone", 0 },
2400 { rtfACharAttr, rtfACWordUnderline, "aulw", 0 },
2401 { rtfACharAttr, rtfACSuperScript, "aup", 0 },
2404 * Footnote attributes
2407 { rtfFNoteAttr, rtfFNAlt, "ftnalt", 0 },
2410 * Key code attributes
2413 { rtfKeyCodeAttr, rtfAltKey, "alt", 0 },
2414 { rtfKeyCodeAttr, rtfShiftKey, "shift", 0 },
2415 { rtfKeyCodeAttr, rtfControlKey, "ctrl", 0 },
2416 { rtfKeyCodeAttr, rtfFunctionKey, "fn", 0 },
2419 * Bookmark attributes
2422 { rtfBookmarkAttr, rtfBookmarkFirstCol, "bkmkcolf", 0 },
2423 { rtfBookmarkAttr, rtfBookmarkLastCol, "bkmkcoll", 0 },
2426 * Index entry attributes
2429 { rtfIndexAttr, rtfIndexNumber, "xef", 0 },
2430 { rtfIndexAttr, rtfIndexBold, "bxe", 0 },
2431 { rtfIndexAttr, rtfIndexItalic, "ixe", 0 },
2434 * Table of contents attributes
2437 { rtfTOCAttr, rtfTOCType, "tcf", 0 },
2438 { rtfTOCAttr, rtfTOCLevel, "tcl", 0 },
2441 * Drawing object attributes
2444 { rtfDrawAttr, rtfDrawLock, "dolock", 0 },
2445 { rtfDrawAttr, rtfDrawPageRelX, "doxpage", 0 },
2446 { rtfDrawAttr, rtfDrawColumnRelX, "dobxcolumn", 0 },
2447 { rtfDrawAttr, rtfDrawMarginRelX, "dobxmargin", 0 },
2448 { rtfDrawAttr, rtfDrawPageRelY, "dobypage", 0 },
2449 { rtfDrawAttr, rtfDrawColumnRelY, "dobycolumn", 0 },
2450 { rtfDrawAttr, rtfDrawMarginRelY, "dobymargin", 0 },
2451 { rtfDrawAttr, rtfDrawHeight, "dobhgt", 0 },
2453 { rtfDrawAttr, rtfDrawBeginGroup, "dpgroup", 0 },
2454 { rtfDrawAttr, rtfDrawGroupCount, "dpcount", 0 },
2455 { rtfDrawAttr, rtfDrawEndGroup, "dpendgroup", 0 },
2456 { rtfDrawAttr, rtfDrawArc, "dparc", 0 },
2457 { rtfDrawAttr, rtfDrawCallout, "dpcallout", 0 },
2458 { rtfDrawAttr, rtfDrawEllipse, "dpellipse", 0 },
2459 { rtfDrawAttr, rtfDrawLine, "dpline", 0 },
2460 { rtfDrawAttr, rtfDrawPolygon, "dppolygon", 0 },
2461 { rtfDrawAttr, rtfDrawPolyLine, "dppolyline", 0 },
2462 { rtfDrawAttr, rtfDrawRect, "dprect", 0 },
2463 { rtfDrawAttr, rtfDrawTextBox, "dptxbx", 0 },
2465 { rtfDrawAttr, rtfDrawOffsetX, "dpx", 0 },
2466 { rtfDrawAttr, rtfDrawSizeX, "dpxsize", 0 },
2467 { rtfDrawAttr, rtfDrawOffsetY, "dpy", 0 },
2468 { rtfDrawAttr, rtfDrawSizeY, "dpysize", 0 },
2470 { rtfDrawAttr, rtfCOAngle, "dpcoa", 0 },
2471 { rtfDrawAttr, rtfCOAccentBar, "dpcoaccent", 0 },
2472 { rtfDrawAttr, rtfCOBestFit, "dpcobestfit", 0 },
2473 { rtfDrawAttr, rtfCOBorder, "dpcoborder", 0 },
2474 { rtfDrawAttr, rtfCOAttachAbsDist, "dpcodabs", 0 },
2475 { rtfDrawAttr, rtfCOAttachBottom, "dpcodbottom", 0 },
2476 { rtfDrawAttr, rtfCOAttachCenter, "dpcodcenter", 0 },
2477 { rtfDrawAttr, rtfCOAttachTop, "dpcodtop", 0 },
2478 { rtfDrawAttr, rtfCOLength, "dpcolength", 0 },
2479 { rtfDrawAttr, rtfCONegXQuadrant, "dpcominusx", 0 },
2480 { rtfDrawAttr, rtfCONegYQuadrant, "dpcominusy", 0 },
2481 { rtfDrawAttr, rtfCOOffset, "dpcooffset", 0 },
2482 { rtfDrawAttr, rtfCOAttachSmart, "dpcosmarta", 0 },
2483 { rtfDrawAttr, rtfCODoubleLine, "dpcotdouble", 0 },
2484 { rtfDrawAttr, rtfCORightAngle, "dpcotright", 0 },
2485 { rtfDrawAttr, rtfCOSingleLine, "dpcotsingle", 0 },
2486 { rtfDrawAttr, rtfCOTripleLine, "dpcottriple", 0 },
2488 { rtfDrawAttr, rtfDrawTextBoxMargin, "dptxbxmar", 0 },
2489 { rtfDrawAttr, rtfDrawTextBoxText, "dptxbxtext", 0 },
2490 { rtfDrawAttr, rtfDrawRoundRect, "dproundr", 0 },
2492 { rtfDrawAttr, rtfDrawPointX, "dpptx", 0 },
2493 { rtfDrawAttr, rtfDrawPointY, "dppty", 0 },
2494 { rtfDrawAttr, rtfDrawPolyCount, "dppolycount", 0 },
2496 { rtfDrawAttr, rtfDrawArcFlipX, "dparcflipx", 0 },
2497 { rtfDrawAttr, rtfDrawArcFlipY, "dparcflipy", 0 },
2499 { rtfDrawAttr, rtfDrawLineBlue, "dplinecob", 0 },
2500 { rtfDrawAttr, rtfDrawLineGreen, "dplinecog", 0 },
2501 { rtfDrawAttr, rtfDrawLineRed, "dplinecor", 0 },
2502 { rtfDrawAttr, rtfDrawLinePalette, "dplinepal", 0 },
2503 { rtfDrawAttr, rtfDrawLineDashDot, "dplinedado", 0 },
2504 { rtfDrawAttr, rtfDrawLineDashDotDot, "dplinedadodo", 0 },
2505 { rtfDrawAttr, rtfDrawLineDash, "dplinedash", 0 },
2506 { rtfDrawAttr, rtfDrawLineDot, "dplinedot", 0 },
2507 { rtfDrawAttr, rtfDrawLineGray, "dplinegray", 0 },
2508 { rtfDrawAttr, rtfDrawLineHollow, "dplinehollow", 0 },
2509 { rtfDrawAttr, rtfDrawLineSolid, "dplinesolid", 0 },
2510 { rtfDrawAttr, rtfDrawLineWidth, "dplinew", 0 },
2512 { rtfDrawAttr, rtfDrawHollowEndArrow, "dpaendhol", 0 },
2513 { rtfDrawAttr, rtfDrawEndArrowLength, "dpaendl", 0 },
2514 { rtfDrawAttr, rtfDrawSolidEndArrow, "dpaendsol", 0 },
2515 { rtfDrawAttr, rtfDrawEndArrowWidth, "dpaendw", 0 },
2516 { rtfDrawAttr, rtfDrawHollowStartArrow,"dpastarthol", 0 },
2517 { rtfDrawAttr, rtfDrawStartArrowLength,"dpastartl", 0 },
2518 { rtfDrawAttr, rtfDrawSolidStartArrow, "dpastartsol", 0 },
2519 { rtfDrawAttr, rtfDrawStartArrowWidth, "dpastartw", 0 },
2521 { rtfDrawAttr, rtfDrawBgFillBlue, "dpfillbgcb", 0 },
2522 { rtfDrawAttr, rtfDrawBgFillGreen, "dpfillbgcg", 0 },
2523 { rtfDrawAttr, rtfDrawBgFillRed, "dpfillbgcr", 0 },
2524 { rtfDrawAttr, rtfDrawBgFillPalette, "dpfillbgpal", 0 },
2525 { rtfDrawAttr, rtfDrawBgFillGray, "dpfillbggray", 0 },
2526 { rtfDrawAttr, rtfDrawFgFillBlue, "dpfillfgcb", 0 },
2527 { rtfDrawAttr, rtfDrawFgFillGreen, "dpfillfgcg", 0 },
2528 { rtfDrawAttr, rtfDrawFgFillRed, "dpfillfgcr", 0 },
2529 { rtfDrawAttr, rtfDrawFgFillPalette, "dpfillfgpal", 0 },
2530 { rtfDrawAttr, rtfDrawFgFillGray, "dpfillfggray", 0 },
2531 { rtfDrawAttr, rtfDrawFillPatIndex, "dpfillpat", 0 },
2533 { rtfDrawAttr, rtfDrawShadow, "dpshadow", 0 },
2534 { rtfDrawAttr, rtfDrawShadowXOffset, "dpshadx", 0 },
2535 { rtfDrawAttr, rtfDrawShadowYOffset, "dpshady", 0 },
2537 { rtfVersion, -1, "rtf", 0 },
2538 { rtfDefFont, -1, "deff", 0 },
2540 { 0, -1, (char *) NULL, 0 }
2545 * Initialize lookup table hash values. Only need to do this once.
2548 static void
2549 LookupInit ()
2551 static int inited = 0;
2552 RTFKey *rp;
2554 if (inited == 0)
2556 for (rp = rtfKey; rp->rtfKStr != (char *) NULL; rp++)
2557 rp->rtfKHash = Hash (rp->rtfKStr);
2558 ++inited;
2564 * Determine major and minor number of control token. If it's
2565 * not found, the class turns into rtfUnknown.
2568 static void
2569 Lookup (s)
2570 char *s;
2572 RTFKey *rp;
2573 int hash;
2575 ++s; /* skip over the leading \ character */
2576 hash = Hash (s);
2577 for (rp = rtfKey; rp->rtfKStr != (char *) NULL; rp++)
2579 if (hash == rp->rtfKHash && strcmp (s, rp->rtfKStr) == 0)
2581 rtfClass = rtfControl;
2582 rtfMajor = rp->rtfKMajor;
2583 rtfMinor = rp->rtfKMinor;
2584 return;
2587 rtfClass = rtfUnknown;
2592 * Compute hash value of symbol
2595 static int
2596 Hash (s)
2597 char *s;
2599 char c;
2600 int val = 0;
2602 while ((c = *s++) != '\0')
2603 val += (int) c;
2604 return (val);
2608 /* ---------------------------------------------------------------------- */
2611 * Memory allocation routines
2616 * Return pointer to block of size bytes, or NULL if there's
2617 * not enough memory available.
2619 * This is called through RTFAlloc(), a define which coerces the
2620 * argument to int. This avoids the persistent problem of allocation
2621 * failing under THINK C when a long is passed.
2624 char *
2625 _RTFAlloc (size)
2626 int size;
2628 return HeapAlloc(RICHED32_hHeap, 0, size);
2633 * Saves a string on the heap and returns a pointer to it.
2637 char *
2638 RTFStrSave (s)
2639 char *s;
2641 char *p;
2643 if ((p = RTFAlloc ((int) (strlen (s) + 1))) == (char *) NULL)
2644 return ((char *) NULL);
2645 return (strcpy (p, s));
2649 void
2650 RTFFree (p)
2651 char *p;
2653 if (p != (char *) NULL)
2654 HeapFree(RICHED32_hHeap, 0, p);
2658 /* ---------------------------------------------------------------------- */
2662 * Token comparison routines
2666 RTFCheckCM (class, major)
2667 int class, major;
2669 return (rtfClass == class && rtfMajor == major);
2674 RTFCheckCMM (class, major, minor)
2675 int class, major, minor;
2677 return (rtfClass == class && rtfMajor == major && rtfMinor == minor);
2682 RTFCheckMM (major, minor)
2683 int major, minor;
2685 return (rtfMajor == major && rtfMinor == minor);
2689 /* ---------------------------------------------------------------------- */
2693 RTFCharToHex (c)
2694 char c;
2696 if (isupper (c))
2697 c = tolower (c);
2698 if (isdigit (c))
2699 return (c - '0'); /* '0'..'9' */
2700 return (c - 'a' + 10); /* 'a'..'f' */
2705 RTFHexToChar (i)
2706 int i;
2708 if (i < 10)
2709 return (i + '0');
2710 return (i - 10 + 'a');
2714 /* ---------------------------------------------------------------------- */
2717 * RTFReadOutputMap() -- Read output translation map
2721 * Read in an array describing the relation between the standard character set
2722 * and an RTF translator's corresponding output sequences. Each line consists
2723 * of a standard character name and the output sequence for that character.
2725 * outMap is an array of strings into which the sequences should be placed.
2726 * It should be declared like this in the calling program:
2728 * char *outMap[rtfSC_MaxChar];
2730 * reinit should be non-zero if outMap should be initialized
2731 * zero otherwise.
2736 RTFReadOutputMap (outMap, reinit)
2737 char *outMap[];
2738 int reinit;
2740 int i;
2741 int stdCode;
2742 char *name, *seq;
2744 if (reinit)
2746 for (i = 0; i < rtfSC_MaxChar; i++)
2748 outMap[i] = (char *) NULL;
2752 for (i=0 ;i< sizeof(text_map)/sizeof(char*); i+=2)
2754 name = text_map[i];
2755 seq = text_map[i+1];
2756 stdCode = RTFStdCharCode( name );
2757 outMap[stdCode] = seq;
2760 return (1);
2763 /* ---------------------------------------------------------------------- */
2766 * Open a library file.
2770 static FILE *(*libFileOpen) () = NULL;
2774 void
2775 RTFSetOpenLibFileProc (proc)
2776 FILE *(*proc) ();
2778 libFileOpen = proc;
2782 FILE *
2783 RTFOpenLibFile (file, mode)
2784 char *file;
2785 char *mode;
2787 if (libFileOpen == NULL)
2788 return ((FILE *) NULL);
2789 return ((*libFileOpen) (file, mode));
2793 /* ---------------------------------------------------------------------- */
2796 * Print message. Default is to send message to stderr
2797 * but this may be overridden with RTFSetMsgProc().
2799 * Message should include linefeeds as necessary. If the default
2800 * function is overridden, the overriding function may want to
2801 * map linefeeds to another line ending character or sequence if
2802 * the host system doesn't use linefeeds.
2806 static void
2807 DefaultMsgProc (s)
2808 char *s;
2810 fprintf (stderr, "%s", s);
2814 static RTFFuncPtr msgProc = DefaultMsgProc;
2817 void
2818 RTFSetMsgProc (proc)
2819 RTFFuncPtr proc;
2821 msgProc = proc;
2825 # ifdef STDARG
2828 * This version is for systems with stdarg
2831 void
2832 RTFMsg (char *fmt, ...)
2834 char buf[rtfBufSiz];
2836 va_list args;
2837 va_start (args,fmt);
2838 vsprintf (buf, fmt, args);
2839 va_end (args);
2840 (*msgProc) (buf);
2843 # else /* !STDARG */
2845 # ifdef VARARGS
2849 * This version is for systems that have varargs.
2852 void
2853 RTFMsg (va_alist)
2854 va_dcl
2856 va_list args;
2857 char *fmt;
2858 char buf[rtfBufSiz];
2860 va_start (args);
2861 fmt = va_arg (args, char *);
2862 vsprintf (buf, fmt, args);
2863 va_end (args);
2864 (*msgProc) (buf);
2867 # else /* !VARARGS */
2870 * This version is for systems that don't have varargs.
2873 void
2874 RTFMsg (fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9)
2875 char *fmt;
2876 char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9;
2878 char buf[rtfBufSiz];
2880 sprintf (buf, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9);
2881 (*msgProc) (buf);
2884 # endif /* !VARARGS */
2885 # endif /* !STDARG */
2888 /* ---------------------------------------------------------------------- */
2892 * Process termination. Print error message and exit. Also prints
2893 * current token, and current input line number and position within
2894 * line if any input has been read from the current file. (No input
2895 * has been read if prevChar is EOF).
2898 static void
2899 DefaultPanicProc (s)
2900 char *s;
2902 fprintf (stderr, "%s", s);
2903 /*exit (1);*/
2907 static RTFFuncPtr panicProc = DefaultPanicProc;
2910 void
2911 RTFSetPanicProc (proc)
2912 RTFFuncPtr proc;
2914 panicProc = proc;
2918 # ifdef STDARG
2921 * This version is for systems with stdarg
2924 void
2925 RTFPanic (char *fmt, ...)
2927 char buf[rtfBufSiz];
2929 va_list args;
2930 va_start (args,fmt);
2931 vsprintf (buf, fmt, args);
2932 va_end (args);
2933 (void) strcat (buf, "\n");
2934 if (prevChar != EOF && rtfTextBuf != (char *) NULL)
2936 sprintf (buf + strlen (buf),
2937 "Last token read was \"%s\" near line %ld, position %d.\n",
2938 rtfTextBuf, rtfLineNum, rtfLinePos);
2940 (*panicProc) (buf);
2943 # else /* !STDARG */
2945 # ifdef VARARGS
2949 * This version is for systems that have varargs.
2952 void
2953 RTFPanic (va_alist)
2954 va_dcl
2956 va_list args;
2957 char *fmt;
2958 char buf[rtfBufSiz];
2960 va_start (args);
2961 fmt = va_arg (args, char *);
2962 vsprintf (buf, fmt, args);
2963 va_end (args);
2964 (void) strcat (buf, "\n");
2965 if (prevChar != EOF && rtfTextBuf != (char *) NULL)
2967 sprintf (buf + strlen (buf),
2968 "Last token read was \"%s\" near line %ld, position %d.\n",
2969 rtfTextBuf, rtfLineNum, rtfLinePos);
2971 (*panicProc) (buf);
2974 # else /* !VARARGS */
2977 * This version is for systems that don't have varargs.
2980 void
2981 RTFPanic (fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9)
2982 char *fmt;
2983 char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9;
2985 char buf[rtfBufSiz];
2987 sprintf (buf, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9);
2988 (void) strcat (buf, "\n");
2989 if (prevChar != EOF && rtfTextBuf != (char *) NULL)
2991 sprintf (buf + strlen (buf),
2992 "Last token read was \"%s\" near line %ld, position %d.\n",
2993 rtfTextBuf, rtfLineNum, rtfLinePos);
2995 (*panicProc) (buf);
2998 # endif /* !VARARGS */
2999 # endif /* !STDARG */