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
= 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 * Initialize the reader. This may be called multiple times,
183 * to read multiple files. The only thing not reset is the input
184 * stream; that must be done with RTFSetStream().
187 void RTFInit(RTF_Info
*info
)
191 if (info
->rtfTextBuf
== NULL
) /* initialize the text buffers */
193 info
->rtfTextBuf
= heap_alloc (rtfBufSiz
);
194 info
->pushedTextBuf
= heap_alloc (rtfBufSiz
);
195 if (info
->rtfTextBuf
== NULL
|| info
->pushedTextBuf
== NULL
)
196 ERR ("Cannot allocate text buffers.\n");
197 info
->rtfTextBuf
[0] = info
->pushedTextBuf
[0] = '\0';
200 heap_free (info
->inputName
);
201 heap_free (info
->outputName
);
202 info
->inputName
= info
->outputName
= NULL
;
204 for (i
= 0; i
< rtfMaxClass
; i
++)
205 RTFSetClassCallback (info
, i
, NULL
);
206 for (i
= 0; i
< rtfMaxDestination
; i
++)
207 RTFSetDestinationCallback (info
, i
, NULL
);
209 /* install built-in destination readers */
210 RTFSetDestinationCallback (info
, rtfFontTbl
, ReadFontTbl
);
211 RTFSetDestinationCallback (info
, rtfColorTbl
, ReadColorTbl
);
212 RTFSetDestinationCallback (info
, rtfStyleSheet
, ReadStyleSheet
);
213 RTFSetDestinationCallback (info
, rtfInfo
, ReadInfoGroup
);
214 RTFSetDestinationCallback (info
, rtfPict
, ReadPictGroup
);
215 RTFSetDestinationCallback (info
, rtfObject
, ReadObjGroup
);
218 RTFSetReadHook (info
, NULL
);
220 /* dump old lists if necessary */
222 RTFDestroyAttrs(info
);
224 info
->ansiCodePage
= 1252; /* Latin-1; actually unused */
225 info
->unicodeLength
= 1; /* \uc1 is the default */
226 info
->codePage
= info
->ansiCodePage
;
230 info
->pushedClass
= -1;
231 info
->pushedChar
= EOF
;
233 info
->rtfLineNum
= 0;
234 info
->rtfLinePos
= 0;
235 info
->prevChar
= EOF
;
238 info
->dwCPOutputCount
= 0;
239 if (!info
->cpOutputBuffer
)
241 info
->dwMaxCPOutputCount
= 0x1000;
242 info
->cpOutputBuffer
= heap_alloc(info
->dwMaxCPOutputCount
);
246 ZeroMemory(info
->tableDef
, sizeof(info
->tableDef
));
247 info
->tableDef
= NULL
;
248 info
->nestingLevel
= 0;
249 info
->canInheritInTbl
= FALSE
;
250 info
->borderType
= 0;
254 * Set or get the input or output file name. These are never guaranteed
255 * to be accurate, only insofar as the calling program makes them so.
258 void RTFSetInputName(RTF_Info
*info
, const char *name
)
260 info
->inputName
= RTFStrSave (name
);
261 if (info
->inputName
== NULL
)
262 ERR ("RTFSetInputName: out of memory\n");
266 char *RTFGetInputName(const RTF_Info
*info
)
268 return (info
->inputName
);
272 void RTFSetOutputName(RTF_Info
*info
, const char *name
)
274 info
->outputName
= RTFStrSave (name
);
275 if (info
->outputName
== NULL
)
276 ERR ("RTFSetOutputName: out of memory\n");
280 char *RTFGetOutputName(const RTF_Info
*info
)
282 return (info
->outputName
);
287 /* ---------------------------------------------------------------------- */
290 * Callback table manipulation routines
295 * Install or return a writer callback for a token class
298 void RTFSetClassCallback(RTF_Info
*info
, int class, RTFFuncPtr callback
)
300 if (class >= 0 && class < rtfMaxClass
)
301 info
->ccb
[class] = callback
;
305 RTFFuncPtr
RTFGetClassCallback(const RTF_Info
*info
, int class)
307 if (class >= 0 && class < rtfMaxClass
)
308 return info
->ccb
[class];
314 * Install or return a writer callback for a destination type
317 void RTFSetDestinationCallback(RTF_Info
*info
, int dest
, RTFFuncPtr callback
)
319 if (dest
>= 0 && dest
< rtfMaxDestination
)
320 info
->dcb
[dest
] = callback
;
324 RTFFuncPtr
RTFGetDestinationCallback(const RTF_Info
*info
, int dest
)
326 if (dest
>= 0 && dest
< rtfMaxDestination
)
327 return info
->dcb
[dest
];
332 /* ---------------------------------------------------------------------- */
335 * Token reading routines
340 * Read the input stream, invoking the writer's callbacks
344 void RTFRead(RTF_Info
*info
)
346 while (RTFGetToken (info
) != rtfEOF
)
347 RTFRouteToken (info
);
352 * Route a token. If it's a destination for which a reader is
353 * installed, process the destination internally, otherwise
354 * pass the token to the writer's class callback.
357 void RTFRouteToken(RTF_Info
*info
)
361 if (info
->rtfClass
< 0 || info
->rtfClass
>= rtfMaxClass
) /* watchdog */
363 ERR( "Unknown class %d: %s (reader malfunction)\n",
364 info
->rtfClass
, info
->rtfTextBuf
);
366 if (RTFCheckCM (info
, rtfControl
, rtfDestination
))
368 /* invoke destination-specific callback if there is one */
369 p
= RTFGetDestinationCallback (info
, info
->rtfMinor
);
376 /* invoke class callback if there is one */
377 p
= RTFGetClassCallback (info
, info
->rtfClass
);
384 * Skip to the end of the current group. When this returns,
385 * writers that maintain a state stack may want to call their
386 * state unstacker; global vars will still be set to the group's
390 void RTFSkipGroup(RTF_Info
*info
)
394 while (RTFGetToken (info
) != rtfEOF
)
396 if (info
->rtfClass
== rtfGroup
)
398 if (info
->rtfMajor
== rtfBeginGroup
)
400 else if (info
->rtfMajor
== rtfEndGroup
)
403 break; /* end of initial group */
411 * Read one token. Call the read hook if there is one. The
412 * token class is the return value. Returns rtfEOF when there
413 * are no more tokens.
416 int RTFGetToken(RTF_Info
*info
)
420 /* don't try to return anything once EOF is reached */
421 if (info
->rtfClass
== rtfEOF
) {
428 p
= RTFGetReadHook (info
);
430 (*p
) (info
); /* give read hook a look at token */
432 /* Silently discard newlines, carriage returns, nulls. */
433 if (!(info
->rtfClass
== rtfText
&& info
->rtfFormat
!= SF_TEXT
434 && (info
->rtfMajor
== '\r' || info
->rtfMajor
== '\n' || info
->rtfMajor
== '\0')))
437 return (info
->rtfClass
);
442 * Install or return a token reader hook.
445 void RTFSetReadHook(RTF_Info
*info
, RTFFuncPtr f
)
451 RTFFuncPtr
RTFGetReadHook(const RTF_Info
*info
)
453 return (info
->readHook
);
457 void RTFUngetToken(RTF_Info
*info
)
459 if (info
->pushedClass
>= 0) /* there's already an ungotten token */
460 ERR ("cannot unget two tokens\n");
461 if (info
->rtfClass
< 0)
462 ERR ("no token to unget\n");
463 info
->pushedClass
= info
->rtfClass
;
464 info
->pushedMajor
= info
->rtfMajor
;
465 info
->pushedMinor
= info
->rtfMinor
;
466 info
->pushedParam
= info
->rtfParam
;
467 lstrcpyA (info
->pushedTextBuf
, info
->rtfTextBuf
);
471 int RTFPeekToken(RTF_Info
*info
)
474 RTFUngetToken (info
);
475 return (info
->rtfClass
);
479 static void _RTFGetToken(RTF_Info
*info
)
481 if (info
->rtfFormat
== SF_TEXT
)
483 info
->rtfMajor
= GetChar (info
);
485 info
->rtfParam
= rtfNoParam
;
486 info
->rtfTextBuf
[info
->rtfTextLen
= 0] = '\0';
487 if (info
->rtfMajor
== EOF
)
488 info
->rtfClass
= rtfEOF
;
490 info
->rtfClass
= rtfText
;
494 /* first check for pushed token from RTFUngetToken() */
496 if (info
->pushedClass
>= 0)
498 info
->rtfClass
= info
->pushedClass
;
499 info
->rtfMajor
= info
->pushedMajor
;
500 info
->rtfMinor
= info
->pushedMinor
;
501 info
->rtfParam
= info
->pushedParam
;
502 lstrcpyA (info
->rtfTextBuf
, info
->pushedTextBuf
);
503 info
->rtfTextLen
= lstrlenA(info
->rtfTextBuf
);
504 info
->pushedClass
= -1;
509 * Beyond this point, no token is ever seen twice, which is
510 * important, e.g., for making sure no "}" pops the font stack twice.
513 _RTFGetToken2 (info
);
518 RTFCharSetToCodePage(RTF_Info
*info
, int charset
)
524 case DEFAULT_CHARSET
:
530 case SHIFTJIS_CHARSET
:
532 case HANGEUL_CHARSET
:
538 case CHINESEBIG5_CHARSET
:
542 case TURKISH_CHARSET
:
544 case VIETNAMESE_CHARSET
:
552 case RUSSIAN_CHARSET
:
556 case EASTEUROPE_CHARSET
:
565 /* FIXME: TranslateCharsetInfo does not work as good as it
566 * should, so let's use it only when all else fails */
567 if (!TranslateCharsetInfo(&n
, &csi
, TCI_SRCCHARSET
))
568 ERR("unknown charset %d\n", charset
);
577 /* this shouldn't be called anywhere but from _RTFGetToken() */
579 static void _RTFGetToken2(RTF_Info
*info
)
584 /* initialize token vars */
586 info
->rtfClass
= rtfUnknown
;
587 info
->rtfParam
= rtfNoParam
;
588 info
->rtfTextBuf
[info
->rtfTextLen
= 0] = '\0';
590 /* get first character, which may be a pushback from previous token */
592 if (info
->pushedChar
!= EOF
)
594 c
= info
->pushedChar
;
595 info
->rtfTextBuf
[info
->rtfTextLen
++] = c
;
596 info
->rtfTextBuf
[info
->rtfTextLen
] = '\0';
597 info
->pushedChar
= EOF
;
599 else if ((c
= GetChar (info
)) == EOF
)
601 info
->rtfClass
= rtfEOF
;
607 info
->rtfClass
= rtfGroup
;
608 info
->rtfMajor
= rtfBeginGroup
;
613 info
->rtfClass
= rtfGroup
;
614 info
->rtfMajor
= rtfEndGroup
;
620 * Two possibilities here:
621 * 1) ASCII 9, effectively like \tab control symbol
622 * 2) literal text char
624 if (c
== '\t') /* ASCII 9 */
626 info
->rtfClass
= rtfControl
;
627 info
->rtfMajor
= rtfSpecialChar
;
628 info
->rtfMinor
= rtfTab
;
632 info
->rtfClass
= rtfText
;
637 if ((c
= GetChar (info
)) == EOF
)
639 /* early eof, whoops (class is rtfUnknown) */
645 * Three possibilities here:
646 * 1) hex encoded text char, e.g., \'d5, \'d3
647 * 2) special escaped text char, e.g., \{, \}
648 * 3) control symbol, e.g., \_, \-, \|, \<10>
650 if (c
== '\'') /* hex char */
654 if ((c
= GetChar (info
)) != EOF
&& (c2
= GetChar (info
)) != EOF
655 && isxdigit(c
) && isxdigit(c2
))
657 info
->rtfClass
= rtfText
;
658 info
->rtfMajor
= RTFCharToHex (c
) * 16 + RTFCharToHex (c2
);
661 /* early eof, whoops */
662 info
->rtfClass
= rtfEOF
;
663 info
->stream
->editstream
->dwError
= -14;
668 /*if (index (":{}\\", c) != (char *) NULL)*/ /* escaped char */
669 if (c
== ':' || c
== '{' || c
== '}' || c
== '\\')
671 info
->rtfClass
= rtfText
;
677 Lookup (info
, info
->rtfTextBuf
); /* sets class, major, minor */
683 if ((c
= GetChar (info
)) == EOF
)
688 * At this point, the control word is all collected, so the
689 * major/minor numbers are determined before the parameter
690 * (if any) is scanned. There will be one too many characters
691 * in the buffer, though, so fix up before and restore after
696 info
->rtfTextBuf
[info
->rtfTextLen
-1] = '\0';
697 Lookup (info
, info
->rtfTextBuf
); /* sets class, major, minor */
699 info
->rtfTextBuf
[info
->rtfTextLen
-1] = c
;
702 * Should be looking at first digit of parameter if there
703 * is one, unless it's negative. In that case, next char
704 * is '-', so need to gobble next char, and remember sign.
713 if (c
!= EOF
&& isdigit (c
))
716 while (isdigit (c
)) /* gobble parameter */
718 info
->rtfParam
= info
->rtfParam
* 10 + c
- '0';
719 if ((c
= GetChar (info
)) == EOF
)
722 info
->rtfParam
*= sign
;
725 * If control symbol delimiter was a blank, gobble it.
726 * Otherwise the character is first char of next token, so
727 * push it back for next call. In either case, delete the
728 * delimiter from the token buffer.
733 info
->pushedChar
= c
;
734 info
->rtfTextBuf
[--info
->rtfTextLen
] = '\0';
740 * Read the next character from the input. This handles setting the
741 * current line and position-within-line variables. Those variable are
742 * set correctly whether lines end with CR, LF, or CRLF (the last being
745 * bumpLine indicates whether the line number should be incremented on
746 * the *next* input character.
750 static int GetChar(RTF_Info
*info
)
755 if ((c
= _RTFGetChar(info
)) != EOF
)
757 info
->rtfTextBuf
[info
->rtfTextLen
++] = c
;
758 info
->rtfTextBuf
[info
->rtfTextLen
] = '\0';
760 if (info
->prevChar
== EOF
)
762 oldBumpLine
= info
->bumpLine
; /* non-zero if prev char was line ending */
769 if (info
->prevChar
== '\r') /* oops, previous \r wasn't */
770 oldBumpLine
= 0; /* really a line ending */
773 if (oldBumpLine
) /* were we supposed to increment the */
774 { /* line count on this char? */
776 info
->rtfLinePos
= 1;
784 * Synthesize a token by setting the global variables to the
785 * values supplied. Typically this is followed with a call
786 * to RTFRouteToken().
788 * If a param value other than rtfNoParam is passed, it becomes
789 * part of the token text.
792 void RTFSetToken(RTF_Info
*info
, int class, int major
, int minor
, int param
, const char *text
)
794 info
->rtfClass
= class;
795 info
->rtfMajor
= major
;
796 info
->rtfMinor
= minor
;
797 info
->rtfParam
= param
;
798 if (param
== rtfNoParam
)
799 lstrcpyA(info
->rtfTextBuf
, text
);
801 sprintf (info
->rtfTextBuf
, "%s%d", text
, param
);
802 info
->rtfTextLen
= lstrlenA (info
->rtfTextBuf
);
806 /* ---------------------------------------------------------------------- */
809 * Special destination readers. They gobble the destination so the
810 * writer doesn't have to deal with them. That's wrong for any
811 * translator that wants to process any of these itself. In that
812 * case, these readers should be overridden by installing a different
813 * destination callback.
815 * NOTE: The last token read by each of these reader will be the
816 * destination's terminating '}', which will then be the current token.
817 * That '}' token is passed to RTFRouteToken() - the writer has already
818 * seen the '{' that began the destination group, and may have pushed a
819 * state; it also needs to know at the end of the group that a state
822 * It's important that rtf.h and the control token lookup table list
823 * as many symbols as possible, because these destination readers
824 * unfortunately make strict assumptions about the input they expect,
825 * and a token of class rtfUnknown will throw them off easily.
830 * Read { \fonttbl ... } destination. Old font tables don't have
831 * braces around each table entry; try to adjust for that.
834 static void ReadFontTbl(RTF_Info
*info
)
837 char buf
[rtfBufSiz
], *bp
;
839 const char *fn
= "ReadFontTbl";
844 if (info
->rtfClass
== rtfEOF
)
846 if (RTFCheckCM (info
, rtfGroup
, rtfEndGroup
))
848 if (old
< 0) /* first entry - determine tbl type */
850 if (RTFCheckCMM (info
, rtfControl
, rtfCharAttr
, rtfFontNum
))
851 old
= 1; /* no brace */
852 else if (RTFCheckCM (info
, rtfGroup
, rtfBeginGroup
))
854 else /* can't tell! */
855 ERR ( "%s: Cannot determine format\n", fn
);
857 if (old
== 0) /* need to find "{" here */
859 if (!RTFCheckCM (info
, rtfGroup
, rtfBeginGroup
))
860 ERR ( "%s: missing \"{\"\n", fn
);
861 RTFGetToken (info
); /* yes, skip to next token */
862 if (info
->rtfClass
== rtfEOF
)
867 ERR ( "%s: cannot allocate font entry\n", fn
);
869 fp
->rtfNextFont
= info
->fontList
;
873 fp
->rtfFAltName
= NULL
;
875 fp
->rtfFFamily
= FF_DONTCARE
;
876 fp
->rtfFCharSet
= DEFAULT_CHARSET
; /* 1 */
877 fp
->rtfFPitch
= DEFAULT_PITCH
;
879 fp
->rtfFCodePage
= CP_ACP
;
881 while (info
->rtfClass
!= rtfEOF
882 && !RTFCheckCM (info
, rtfText
, ';')
883 && !RTFCheckCM (info
, rtfGroup
, rtfEndGroup
))
885 if (info
->rtfClass
== rtfControl
)
887 switch (info
->rtfMajor
)
890 /* ignore token but announce it */
891 WARN ("%s: unknown token \"%s\"\n",
892 fn
, info
->rtfTextBuf
);
895 fp
->rtfFFamily
= info
->rtfMinor
;
898 switch (info
->rtfMinor
)
901 break; /* ignore unknown? */
903 fp
->rtfFNum
= info
->rtfParam
;
908 switch (info
->rtfMinor
)
911 break; /* ignore unknown? */
913 fp
->rtfFCharSet
= info
->rtfParam
;
914 if (!fp
->rtfFCodePage
)
915 fp
->rtfFCodePage
= RTFCharSetToCodePage(info
, info
->rtfParam
);
918 fp
->rtfFPitch
= info
->rtfParam
;
920 case rtfFontCodePage
:
921 fp
->rtfFCodePage
= info
->rtfParam
;
924 case rtfFTypeTrueType
:
925 fp
->rtfFType
= info
->rtfParam
;
931 else if (RTFCheckCM (info
, rtfGroup
, rtfBeginGroup
)) /* dest */
933 RTFSkipGroup (info
); /* ignore for now */
935 else if (info
->rtfClass
== rtfText
) /* font name */
938 while (info
->rtfClass
== rtfText
939 && !RTFCheckCM (info
, rtfText
, ';'))
941 *bp
++ = info
->rtfMajor
;
945 /* FIX: in some cases the <fontinfo> isn't finished with a semi-column */
946 if(RTFCheckCM (info
, rtfGroup
, rtfEndGroup
))
948 RTFUngetToken (info
);
951 fp
->rtfFName
= RTFStrSave (buf
);
952 if (fp
->rtfFName
== NULL
)
953 ERR ( "%s: cannot allocate font name\n", fn
);
954 /* already have next token; don't read one */
955 /* at bottom of loop */
960 /* ignore token but announce it */
961 WARN ( "%s: unknown token \"%s\"\n",
962 fn
,info
->rtfTextBuf
);
965 if (info
->rtfClass
== rtfEOF
)
968 if (info
->rtfClass
== rtfEOF
)
970 if (old
== 0) /* need to see "}" here */
973 if (!RTFCheckCM (info
, rtfGroup
, rtfEndGroup
))
974 ERR ( "%s: missing \"}\"\n", fn
);
975 if (info
->rtfClass
== rtfEOF
)
979 /* Apply the real properties of the default font */
980 if (fp
->rtfFNum
== info
->defFont
)
982 if (info
->ansiCodePage
!= CP_UTF8
)
983 info
->codePage
= fp
->rtfFCodePage
;
984 TRACE("default font codepage %d\n", info
->codePage
);
987 if (fp
->rtfFNum
== -1)
988 ERR( "%s: missing font number\n", fn
);
990 * Could check other pieces of structure here, too, I suppose.
992 RTFRouteToken (info
); /* feed "}" back to router */
994 /* Set default font */
995 info
->rtfClass
= rtfControl
;
996 info
->rtfMajor
= rtfCharAttr
;
997 info
->rtfMinor
= rtfFontNum
;
998 info
->rtfParam
= info
->defFont
;
999 lstrcpyA(info
->rtfTextBuf
, "f");
1000 RTFUngetToken(info
);
1005 * The color table entries have color values of -1 if
1006 * the default color should be used for the entry (only
1007 * a semi-colon is given in the definition, no color values).
1008 * There will be a problem if a partial entry (1 or 2 but
1009 * not 3 color values) is given. The possibility is ignored
1013 static void ReadColorTbl(RTF_Info
*info
)
1017 const char *fn
= "ReadColorTbl";
1018 int group_level
= 1;
1023 if (info
->rtfClass
== rtfEOF
)
1025 if (RTFCheckCM (info
, rtfGroup
, rtfEndGroup
))
1032 else if (RTFCheckCM(info
, rtfGroup
, rtfBeginGroup
))
1038 cp
= New (RTFColor
);
1040 ERR ( "%s: cannot allocate color entry\n", fn
);
1041 cp
->rtfCNum
= cnum
++;
1042 cp
->rtfCRed
= cp
->rtfCGreen
= cp
->rtfCBlue
= -1;
1043 cp
->rtfNextColor
= info
->colorList
;
1044 info
->colorList
= cp
;
1045 while (RTFCheckCM (info
, rtfControl
, rtfColorName
))
1047 switch (info
->rtfMinor
)
1049 case rtfRed
: cp
->rtfCRed
= info
->rtfParam
; break;
1050 case rtfGreen
: cp
->rtfCGreen
= info
->rtfParam
; break;
1051 case rtfBlue
: cp
->rtfCBlue
= info
->rtfParam
; break;
1055 if (info
->rtfClass
== rtfEOF
)
1057 if (!RTFCheckCM (info
, rtfText
, ';'))
1058 ERR ("%s: malformed entry\n", fn
);
1060 RTFRouteToken (info
); /* feed "}" back to router */
1065 * The "Normal" style definition doesn't contain any style number,
1066 * all others do. Normal style is given style rtfNormalStyleNum.
1069 static void ReadStyleSheet(RTF_Info
*info
)
1072 RTFStyleElt
*sep
, *sepLast
;
1073 char buf
[rtfBufSiz
], *bp
;
1074 const char *fn
= "ReadStyleSheet";
1080 if (info
->rtfClass
== rtfEOF
)
1082 if (RTFCheckCM (info
, rtfGroup
, rtfEndGroup
))
1084 sp
= New (RTFStyle
);
1086 ERR ( "%s: cannot allocate stylesheet entry\n", fn
);
1087 sp
->rtfSName
= NULL
;
1089 sp
->rtfSType
= rtfParStyle
;
1090 sp
->rtfSAdditive
= 0;
1091 sp
->rtfSBasedOn
= rtfNoStyleNum
;
1092 sp
->rtfSNextPar
= -1;
1093 sp
->rtfSSEList
= sepLast
= NULL
;
1094 sp
->rtfNextStyle
= info
->styleList
;
1095 sp
->rtfExpanding
= 0;
1096 info
->styleList
= sp
;
1097 if (!RTFCheckCM (info
, rtfGroup
, rtfBeginGroup
))
1098 ERR ( "%s: missing \"{\"\n", fn
);
1103 if (info
->rtfClass
== rtfEOF
1104 || RTFCheckCM (info
, rtfText
, ';'))
1106 if (info
->rtfClass
== rtfControl
)
1108 if (RTFCheckMM (info
, rtfSpecialChar
, rtfOptDest
)) {
1110 ERR( "%s: skipping optional destination\n", fn
);
1112 info
->rtfClass
= rtfGroup
;
1113 info
->rtfMajor
= rtfEndGroup
;
1115 break; /* ignore "\*" */
1117 if (RTFCheckMM (info
, rtfParAttr
, rtfStyleNum
))
1119 sp
->rtfSNum
= info
->rtfParam
;
1120 sp
->rtfSType
= rtfParStyle
;
1123 if (RTFCheckMM (info
, rtfCharAttr
, rtfCharStyleNum
))
1125 sp
->rtfSNum
= info
->rtfParam
;
1126 sp
->rtfSType
= rtfCharStyle
;
1129 if (RTFCheckMM (info
, rtfSectAttr
, rtfSectStyleNum
))
1131 sp
->rtfSNum
= info
->rtfParam
;
1132 sp
->rtfSType
= rtfSectStyle
;
1135 if (RTFCheckMM (info
, rtfStyleAttr
, rtfBasedOn
))
1137 sp
->rtfSBasedOn
= info
->rtfParam
;
1140 if (RTFCheckMM (info
, rtfStyleAttr
, rtfAdditive
))
1142 sp
->rtfSAdditive
= 1;
1145 if (RTFCheckMM (info
, rtfStyleAttr
, rtfNext
))
1147 sp
->rtfSNextPar
= info
->rtfParam
;
1150 sep
= New (RTFStyleElt
);
1152 ERR ( "%s: cannot allocate style element\n", fn
);
1153 sep
->rtfSEClass
= info
->rtfClass
;
1154 sep
->rtfSEMajor
= info
->rtfMajor
;
1155 sep
->rtfSEMinor
= info
->rtfMinor
;
1156 sep
->rtfSEParam
= info
->rtfParam
;
1157 sep
->rtfSEText
= RTFStrSave (info
->rtfTextBuf
);
1158 if (sep
->rtfSEText
== NULL
)
1159 ERR ( "%s: cannot allocate style element text\n", fn
);
1160 if (sepLast
== NULL
)
1161 sp
->rtfSSEList
= sep
; /* first element */
1162 else /* add to end */
1163 sepLast
->rtfNextSE
= sep
;
1164 sep
->rtfNextSE
= NULL
;
1167 else if (RTFCheckCM (info
, rtfGroup
, rtfBeginGroup
))
1170 * This passes over "{\*\keycode ... }, among
1171 * other things. A temporary (perhaps) hack.
1173 ERR( "%s: skipping begin\n", fn
);
1174 RTFSkipGroup (info
);
1177 else if (info
->rtfClass
== rtfText
) /* style name */
1180 while (info
->rtfClass
== rtfText
)
1182 if (info
->rtfMajor
== ';')
1184 /* put back for "for" loop */
1185 RTFUngetToken (info
);
1188 *bp
++ = info
->rtfMajor
;
1192 sp
->rtfSName
= RTFStrSave (buf
);
1193 if (sp
->rtfSName
== NULL
)
1194 ERR ( "%s: cannot allocate style name\n", fn
);
1196 else /* unrecognized */
1198 /* ignore token but announce it */
1199 WARN ( "%s: unknown token \"%s\"\n",
1200 fn
, info
->rtfTextBuf
);
1205 if (!RTFCheckCM (info
, rtfGroup
, rtfEndGroup
))
1206 ERR ( "%s: missing \"}\"\n", fn
);
1208 * Check over the style structure. A name is a must.
1209 * If no style number was specified, check whether it's the
1210 * Normal style (in which case it's given style number
1211 * rtfNormalStyleNum). Note that some "normal" style names
1212 * just begin with "Normal" and can have other stuff following,
1213 * e.g., "Normal,Times 10 point". Ugh.
1215 * Some German RTF writers use "Standard" instead of "Normal".
1217 if (sp
->rtfSName
== NULL
)
1218 ERR ( "%s: missing style name\n", fn
);
1219 if (sp
->rtfSNum
< 0)
1221 if (strncmp (buf
, "Normal", 6) != 0
1222 && strncmp (buf
, "Standard", 8) != 0)
1223 ERR ( "%s: missing style number\n", fn
);
1224 sp
->rtfSNum
= rtfNormalStyleNum
;
1226 if (sp
->rtfSNextPar
== -1) /* if \snext not given, */
1227 sp
->rtfSNextPar
= sp
->rtfSNum
; /* next is itself */
1229 /* otherwise we're just dealing with fake end group from skipped group */
1231 RTFRouteToken (info
); /* feed "}" back to router */
1235 static void ReadInfoGroup(RTF_Info
*info
)
1237 RTFSkipGroup (info
);
1238 RTFRouteToken (info
); /* feed "}" back to router */
1242 static void ReadPictGroup(RTF_Info
*info
)
1244 RTFSkipGroup (info
);
1245 RTFRouteToken (info
); /* feed "}" back to router */
1249 static void ReadObjGroup(RTF_Info
*info
)
1251 RTFSkipGroup (info
);
1252 RTFRouteToken (info
); /* feed "}" back to router */
1256 /* ---------------------------------------------------------------------- */
1259 * Routines to return pieces of stylesheet, or font or color tables.
1260 * References to style 0 are mapped onto the Normal style.
1264 RTFStyle
*RTFGetStyle(const RTF_Info
*info
, int num
)
1269 return (info
->styleList
);
1270 for (s
= info
->styleList
; s
!= NULL
; s
= s
->rtfNextStyle
)
1272 if (s
->rtfSNum
== num
)
1275 return (s
); /* NULL if not found */
1279 RTFFont
*RTFGetFont(const RTF_Info
*info
, int num
)
1284 return (info
->fontList
);
1285 for (f
= info
->fontList
; f
!= NULL
; f
= f
->rtfNextFont
)
1287 if (f
->rtfFNum
== num
)
1290 return (f
); /* NULL if not found */
1294 RTFColor
*RTFGetColor(const RTF_Info
*info
, int num
)
1299 return (info
->colorList
);
1300 for (c
= info
->colorList
; c
!= NULL
; c
= c
->rtfNextColor
)
1302 if (c
->rtfCNum
== num
)
1305 return (c
); /* NULL if not found */
1309 /* ---------------------------------------------------------------------- */
1313 * Expand style n, if there is such a style.
1316 void RTFExpandStyle(RTF_Info
*info
, int n
)
1323 s
= RTFGetStyle (info
, n
);
1326 if (s
->rtfExpanding
!= 0)
1327 ERR ("Style expansion loop, style %d\n", n
);
1328 s
->rtfExpanding
= 1; /* set expansion flag for loop detection */
1330 * Expand "based-on" style (unless it's the same as the current
1331 * style -- Normal style usually gives itself as its own based-on
1332 * style). Based-on style expansion is done by synthesizing
1333 * the token that the writer needs to see in order to trigger
1334 * another style expansion, and feeding to token back through
1335 * the router so the writer sees it.
1337 if (n
!= s
->rtfSBasedOn
)
1339 RTFSetToken (info
, rtfControl
, rtfParAttr
, rtfStyleNum
,
1340 s
->rtfSBasedOn
, "\\s");
1341 RTFRouteToken (info
);
1344 * Now route the tokens unique to this style. RTFSetToken()
1345 * isn't used because it would add the param value to the end
1346 * of the token text, which already has it in.
1348 for (se
= s
->rtfSSEList
; se
!= NULL
; se
= se
->rtfNextSE
)
1350 info
->rtfClass
= se
->rtfSEClass
;
1351 info
->rtfMajor
= se
->rtfSEMajor
;
1352 info
->rtfMinor
= se
->rtfSEMinor
;
1353 info
->rtfParam
= se
->rtfSEParam
;
1354 lstrcpyA (info
->rtfTextBuf
, se
->rtfSEText
);
1355 info
->rtfTextLen
= lstrlenA (info
->rtfTextBuf
);
1356 RTFRouteToken (info
);
1358 s
->rtfExpanding
= 0; /* done - clear expansion flag */
1362 /* ---------------------------------------------------------------------- */
1365 * Control symbol lookup routines
1369 typedef struct RTFKey RTFKey
;
1373 int rtfKMajor
; /* major number */
1374 int rtfKMinor
; /* minor number */
1375 const char *rtfKStr
; /* symbol name */
1376 int rtfKHash
; /* symbol name hash value */
1380 * A minor number of -1 means the token has no minor number
1381 * (all valid minor numbers are >= 0).
1384 static RTFKey rtfKey
[] =
1387 * Special characters
1390 { rtfSpecialChar
, rtfIIntVersion
, "vern", 0 },
1391 { rtfSpecialChar
, rtfICreateTime
, "creatim", 0 },
1392 { rtfSpecialChar
, rtfIRevisionTime
, "revtim", 0 },
1393 { rtfSpecialChar
, rtfIPrintTime
, "printim", 0 },
1394 { rtfSpecialChar
, rtfIBackupTime
, "buptim", 0 },
1395 { rtfSpecialChar
, rtfIEditTime
, "edmins", 0 },
1396 { rtfSpecialChar
, rtfIYear
, "yr", 0 },
1397 { rtfSpecialChar
, rtfIMonth
, "mo", 0 },
1398 { rtfSpecialChar
, rtfIDay
, "dy", 0 },
1399 { rtfSpecialChar
, rtfIHour
, "hr", 0 },
1400 { rtfSpecialChar
, rtfIMinute
, "min", 0 },
1401 { rtfSpecialChar
, rtfISecond
, "sec", 0 },
1402 { rtfSpecialChar
, rtfINPages
, "nofpages", 0 },
1403 { rtfSpecialChar
, rtfINWords
, "nofwords", 0 },
1404 { rtfSpecialChar
, rtfINChars
, "nofchars", 0 },
1405 { rtfSpecialChar
, rtfIIntID
, "id", 0 },
1407 { rtfSpecialChar
, rtfCurHeadDate
, "chdate", 0 },
1408 { rtfSpecialChar
, rtfCurHeadDateLong
, "chdpl", 0 },
1409 { rtfSpecialChar
, rtfCurHeadDateAbbrev
, "chdpa", 0 },
1410 { rtfSpecialChar
, rtfCurHeadTime
, "chtime", 0 },
1411 { rtfSpecialChar
, rtfCurHeadPage
, "chpgn", 0 },
1412 { rtfSpecialChar
, rtfSectNum
, "sectnum", 0 },
1413 { rtfSpecialChar
, rtfCurFNote
, "chftn", 0 },
1414 { rtfSpecialChar
, rtfCurAnnotRef
, "chatn", 0 },
1415 { rtfSpecialChar
, rtfFNoteSep
, "chftnsep", 0 },
1416 { rtfSpecialChar
, rtfFNoteCont
, "chftnsepc", 0 },
1417 { rtfSpecialChar
, rtfCell
, "cell", 0 },
1418 { rtfSpecialChar
, rtfRow
, "row", 0 },
1419 { rtfSpecialChar
, rtfPar
, "par", 0 },
1420 /* newline and carriage return are synonyms for */
1421 /* \par when they are preceded by a \ character */
1422 { rtfSpecialChar
, rtfPar
, "\n", 0 },
1423 { rtfSpecialChar
, rtfPar
, "\r", 0 },
1424 { rtfSpecialChar
, rtfSect
, "sect", 0 },
1425 { rtfSpecialChar
, rtfPage
, "page", 0 },
1426 { rtfSpecialChar
, rtfColumn
, "column", 0 },
1427 { rtfSpecialChar
, rtfLine
, "line", 0 },
1428 { rtfSpecialChar
, rtfSoftPage
, "softpage", 0 },
1429 { rtfSpecialChar
, rtfSoftColumn
, "softcol", 0 },
1430 { rtfSpecialChar
, rtfSoftLine
, "softline", 0 },
1431 { rtfSpecialChar
, rtfSoftLineHt
, "softlheight", 0 },
1432 { rtfSpecialChar
, rtfTab
, "tab", 0 },
1433 { rtfSpecialChar
, rtfEmDash
, "emdash", 0 },
1434 { rtfSpecialChar
, rtfEnDash
, "endash", 0 },
1435 { rtfSpecialChar
, rtfEmSpace
, "emspace", 0 },
1436 { rtfSpecialChar
, rtfEnSpace
, "enspace", 0 },
1437 { rtfSpecialChar
, rtfBullet
, "bullet", 0 },
1438 { rtfSpecialChar
, rtfLQuote
, "lquote", 0 },
1439 { rtfSpecialChar
, rtfRQuote
, "rquote", 0 },
1440 { rtfSpecialChar
, rtfLDblQuote
, "ldblquote", 0 },
1441 { rtfSpecialChar
, rtfRDblQuote
, "rdblquote", 0 },
1442 { rtfSpecialChar
, rtfFormula
, "|", 0 },
1443 { rtfSpecialChar
, rtfNoBrkSpace
, "~", 0 },
1444 { rtfSpecialChar
, rtfNoReqHyphen
, "-", 0 },
1445 { rtfSpecialChar
, rtfNoBrkHyphen
, "_", 0 },
1446 { rtfSpecialChar
, rtfOptDest
, "*", 0 },
1447 { rtfSpecialChar
, rtfLTRMark
, "ltrmark", 0 },
1448 { rtfSpecialChar
, rtfRTLMark
, "rtlmark", 0 },
1449 { rtfSpecialChar
, rtfNoWidthJoiner
, "zwj", 0 },
1450 { rtfSpecialChar
, rtfNoWidthNonJoiner
, "zwnj", 0 },
1451 /* is this valid? */
1452 { rtfSpecialChar
, rtfCurHeadPict
, "chpict", 0 },
1453 { rtfSpecialChar
, rtfUnicode
, "u", 0 },
1454 { rtfSpecialChar
, rtfNestCell
, "nestcell", 0 },
1455 { rtfSpecialChar
, rtfNestRow
, "nestrow", 0 },
1458 * Character formatting attributes
1461 { rtfCharAttr
, rtfPlain
, "plain", 0 },
1462 { rtfCharAttr
, rtfBold
, "b", 0 },
1463 { rtfCharAttr
, rtfAllCaps
, "caps", 0 },
1464 { rtfCharAttr
, rtfDeleted
, "deleted", 0 },
1465 { rtfCharAttr
, rtfSubScript
, "dn", 0 },
1466 { rtfCharAttr
, rtfSubScrShrink
, "sub", 0 },
1467 { rtfCharAttr
, rtfNoSuperSub
, "nosupersub", 0 },
1468 { rtfCharAttr
, rtfExpand
, "expnd", 0 },
1469 { rtfCharAttr
, rtfExpandTwips
, "expndtw", 0 },
1470 { rtfCharAttr
, rtfKerning
, "kerning", 0 },
1471 { rtfCharAttr
, rtfFontNum
, "f", 0 },
1472 { rtfCharAttr
, rtfFontSize
, "fs", 0 },
1473 { rtfCharAttr
, rtfItalic
, "i", 0 },
1474 { rtfCharAttr
, rtfOutline
, "outl", 0 },
1475 { rtfCharAttr
, rtfRevised
, "revised", 0 },
1476 { rtfCharAttr
, rtfRevAuthor
, "revauth", 0 },
1477 { rtfCharAttr
, rtfRevDTTM
, "revdttm", 0 },
1478 { rtfCharAttr
, rtfSmallCaps
, "scaps", 0 },
1479 { rtfCharAttr
, rtfShadow
, "shad", 0 },
1480 { rtfCharAttr
, rtfStrikeThru
, "strike", 0 },
1481 { rtfCharAttr
, rtfUnderline
, "ul", 0 },
1482 { rtfCharAttr
, rtfDotUnderline
, "uld", 0 },
1483 { rtfCharAttr
, rtfDbUnderline
, "uldb", 0 },
1484 { rtfCharAttr
, rtfNoUnderline
, "ulnone", 0 },
1485 { rtfCharAttr
, rtfWordUnderline
, "ulw", 0 },
1486 { rtfCharAttr
, rtfSuperScript
, "up", 0 },
1487 { rtfCharAttr
, rtfSuperScrShrink
, "super", 0 },
1488 { rtfCharAttr
, rtfInvisible
, "v", 0 },
1489 { rtfCharAttr
, rtfForeColor
, "cf", 0 },
1490 { rtfCharAttr
, rtfBackColor
, "cb", 0 },
1491 { rtfCharAttr
, rtfRTLChar
, "rtlch", 0 },
1492 { rtfCharAttr
, rtfLTRChar
, "ltrch", 0 },
1493 { rtfCharAttr
, rtfCharStyleNum
, "cs", 0 },
1494 { rtfCharAttr
, rtfCharCharSet
, "cchs", 0 },
1495 { rtfCharAttr
, rtfLanguage
, "lang", 0 },
1496 /* this has disappeared from spec 1.2 */
1497 { rtfCharAttr
, rtfGray
, "gray", 0 },
1498 { rtfCharAttr
, rtfUnicodeLength
, "uc", 0 },
1501 * Paragraph formatting attributes
1504 { rtfParAttr
, rtfParDef
, "pard", 0 },
1505 { rtfParAttr
, rtfStyleNum
, "s", 0 },
1506 { rtfParAttr
, rtfHyphenate
, "hyphpar", 0 },
1507 { rtfParAttr
, rtfInTable
, "intbl", 0 },
1508 { rtfParAttr
, rtfKeep
, "keep", 0 },
1509 { rtfParAttr
, rtfNoWidowControl
, "nowidctlpar", 0 },
1510 { rtfParAttr
, rtfKeepNext
, "keepn", 0 },
1511 { rtfParAttr
, rtfOutlineLevel
, "level", 0 },
1512 { rtfParAttr
, rtfNoLineNum
, "noline", 0 },
1513 { rtfParAttr
, rtfPBBefore
, "pagebb", 0 },
1514 { rtfParAttr
, rtfSideBySide
, "sbys", 0 },
1515 { rtfParAttr
, rtfQuadLeft
, "ql", 0 },
1516 { rtfParAttr
, rtfQuadRight
, "qr", 0 },
1517 { rtfParAttr
, rtfQuadJust
, "qj", 0 },
1518 { rtfParAttr
, rtfQuadCenter
, "qc", 0 },
1519 { rtfParAttr
, rtfFirstIndent
, "fi", 0 },
1520 { rtfParAttr
, rtfLeftIndent
, "li", 0 },
1521 { rtfParAttr
, rtfRightIndent
, "ri", 0 },
1522 { rtfParAttr
, rtfSpaceBefore
, "sb", 0 },
1523 { rtfParAttr
, rtfSpaceAfter
, "sa", 0 },
1524 { rtfParAttr
, rtfSpaceBetween
, "sl", 0 },
1525 { rtfParAttr
, rtfSpaceMultiply
, "slmult", 0 },
1527 { rtfParAttr
, rtfSubDocument
, "subdocument", 0 },
1529 { rtfParAttr
, rtfRTLPar
, "rtlpar", 0 },
1530 { rtfParAttr
, rtfLTRPar
, "ltrpar", 0 },
1532 { rtfParAttr
, rtfTabPos
, "tx", 0 },
1534 * FrameMaker writes \tql (to mean left-justified tab, apparently)
1535 * although it's not in the spec. It's also redundant, since lj
1536 * tabs are the default.
1538 { rtfParAttr
, rtfTabLeft
, "tql", 0 },
1539 { rtfParAttr
, rtfTabRight
, "tqr", 0 },
1540 { rtfParAttr
, rtfTabCenter
, "tqc", 0 },
1541 { rtfParAttr
, rtfTabDecimal
, "tqdec", 0 },
1542 { rtfParAttr
, rtfTabBar
, "tb", 0 },
1543 { rtfParAttr
, rtfLeaderDot
, "tldot", 0 },
1544 { rtfParAttr
, rtfLeaderHyphen
, "tlhyph", 0 },
1545 { rtfParAttr
, rtfLeaderUnder
, "tlul", 0 },
1546 { rtfParAttr
, rtfLeaderThick
, "tlth", 0 },
1547 { rtfParAttr
, rtfLeaderEqual
, "tleq", 0 },
1549 { rtfParAttr
, rtfParLevel
, "pnlvl", 0 },
1550 { rtfParAttr
, rtfParBullet
, "pnlvlblt", 0 },
1551 { rtfParAttr
, rtfParSimple
, "pnlvlbody", 0 },
1552 { rtfParAttr
, rtfParNumCont
, "pnlvlcont", 0 },
1553 { rtfParAttr
, rtfParNumOnce
, "pnnumonce", 0 },
1554 { rtfParAttr
, rtfParNumAcross
, "pnacross", 0 },
1555 { rtfParAttr
, rtfParHangIndent
, "pnhang", 0 },
1556 { rtfParAttr
, rtfParNumRestart
, "pnrestart", 0 },
1557 { rtfParAttr
, rtfParNumCardinal
, "pncard", 0 },
1558 { rtfParAttr
, rtfParNumDecimal
, "pndec", 0 },
1559 { rtfParAttr
, rtfParNumULetter
, "pnucltr", 0 },
1560 { rtfParAttr
, rtfParNumURoman
, "pnucrm", 0 },
1561 { rtfParAttr
, rtfParNumLLetter
, "pnlcltr", 0 },
1562 { rtfParAttr
, rtfParNumLRoman
, "pnlcrm", 0 },
1563 { rtfParAttr
, rtfParNumOrdinal
, "pnord", 0 },
1564 { rtfParAttr
, rtfParNumOrdinalText
, "pnordt", 0 },
1565 { rtfParAttr
, rtfParNumBold
, "pnb", 0 },
1566 { rtfParAttr
, rtfParNumItalic
, "pni", 0 },
1567 { rtfParAttr
, rtfParNumAllCaps
, "pncaps", 0 },
1568 { rtfParAttr
, rtfParNumSmallCaps
, "pnscaps", 0 },
1569 { rtfParAttr
, rtfParNumUnder
, "pnul", 0 },
1570 { rtfParAttr
, rtfParNumDotUnder
, "pnuld", 0 },
1571 { rtfParAttr
, rtfParNumDbUnder
, "pnuldb", 0 },
1572 { rtfParAttr
, rtfParNumNoUnder
, "pnulnone", 0 },
1573 { rtfParAttr
, rtfParNumWordUnder
, "pnulw", 0 },
1574 { rtfParAttr
, rtfParNumStrikethru
, "pnstrike", 0 },
1575 { rtfParAttr
, rtfParNumForeColor
, "pncf", 0 },
1576 { rtfParAttr
, rtfParNumFont
, "pnf", 0 },
1577 { rtfParAttr
, rtfParNumFontSize
, "pnfs", 0 },
1578 { rtfParAttr
, rtfParNumIndent
, "pnindent", 0 },
1579 { rtfParAttr
, rtfParNumSpacing
, "pnsp", 0 },
1580 { rtfParAttr
, rtfParNumInclPrev
, "pnprev", 0 },
1581 { rtfParAttr
, rtfParNumCenter
, "pnqc", 0 },
1582 { rtfParAttr
, rtfParNumLeft
, "pnql", 0 },
1583 { rtfParAttr
, rtfParNumRight
, "pnqr", 0 },
1584 { rtfParAttr
, rtfParNumStartAt
, "pnstart", 0 },
1586 { rtfParAttr
, rtfBorderTop
, "brdrt", 0 },
1587 { rtfParAttr
, rtfBorderBottom
, "brdrb", 0 },
1588 { rtfParAttr
, rtfBorderLeft
, "brdrl", 0 },
1589 { rtfParAttr
, rtfBorderRight
, "brdrr", 0 },
1590 { rtfParAttr
, rtfBorderBetween
, "brdrbtw", 0 },
1591 { rtfParAttr
, rtfBorderBar
, "brdrbar", 0 },
1592 { rtfParAttr
, rtfBorderBox
, "box", 0 },
1593 { rtfParAttr
, rtfBorderSingle
, "brdrs", 0 },
1594 { rtfParAttr
, rtfBorderThick
, "brdrth", 0 },
1595 { rtfParAttr
, rtfBorderShadow
, "brdrsh", 0 },
1596 { rtfParAttr
, rtfBorderDouble
, "brdrdb", 0 },
1597 { rtfParAttr
, rtfBorderDot
, "brdrdot", 0 },
1598 { rtfParAttr
, rtfBorderDot
, "brdrdash", 0 },
1599 { rtfParAttr
, rtfBorderHair
, "brdrhair", 0 },
1600 { rtfParAttr
, rtfBorderWidth
, "brdrw", 0 },
1601 { rtfParAttr
, rtfBorderColor
, "brdrcf", 0 },
1602 { rtfParAttr
, rtfBorderSpace
, "brsp", 0 },
1604 { rtfParAttr
, rtfShading
, "shading", 0 },
1605 { rtfParAttr
, rtfBgPatH
, "bghoriz", 0 },
1606 { rtfParAttr
, rtfBgPatV
, "bgvert", 0 },
1607 { rtfParAttr
, rtfFwdDiagBgPat
, "bgfdiag", 0 },
1608 { rtfParAttr
, rtfBwdDiagBgPat
, "bgbdiag", 0 },
1609 { rtfParAttr
, rtfHatchBgPat
, "bgcross", 0 },
1610 { rtfParAttr
, rtfDiagHatchBgPat
, "bgdcross", 0 },
1611 { rtfParAttr
, rtfDarkBgPatH
, "bgdkhoriz", 0 },
1612 { rtfParAttr
, rtfDarkBgPatV
, "bgdkvert", 0 },
1613 { rtfParAttr
, rtfFwdDarkBgPat
, "bgdkfdiag", 0 },
1614 { rtfParAttr
, rtfBwdDarkBgPat
, "bgdkbdiag", 0 },
1615 { rtfParAttr
, rtfDarkHatchBgPat
, "bgdkcross", 0 },
1616 { rtfParAttr
, rtfDarkDiagHatchBgPat
, "bgdkdcross", 0 },
1617 { rtfParAttr
, rtfBgPatLineColor
, "cfpat", 0 },
1618 { rtfParAttr
, rtfBgPatColor
, "cbpat", 0 },
1619 { rtfParAttr
, rtfNestLevel
, "itap", 0 },
1622 * Section formatting attributes
1625 { rtfSectAttr
, rtfSectDef
, "sectd", 0 },
1626 { rtfSectAttr
, rtfENoteHere
, "endnhere", 0 },
1627 { rtfSectAttr
, rtfPrtBinFirst
, "binfsxn", 0 },
1628 { rtfSectAttr
, rtfPrtBin
, "binsxn", 0 },
1629 { rtfSectAttr
, rtfSectStyleNum
, "ds", 0 },
1631 { rtfSectAttr
, rtfNoBreak
, "sbknone", 0 },
1632 { rtfSectAttr
, rtfColBreak
, "sbkcol", 0 },
1633 { rtfSectAttr
, rtfPageBreak
, "sbkpage", 0 },
1634 { rtfSectAttr
, rtfEvenBreak
, "sbkeven", 0 },
1635 { rtfSectAttr
, rtfOddBreak
, "sbkodd", 0 },
1637 { rtfSectAttr
, rtfColumns
, "cols", 0 },
1638 { rtfSectAttr
, rtfColumnSpace
, "colsx", 0 },
1639 { rtfSectAttr
, rtfColumnNumber
, "colno", 0 },
1640 { rtfSectAttr
, rtfColumnSpRight
, "colsr", 0 },
1641 { rtfSectAttr
, rtfColumnWidth
, "colw", 0 },
1642 { rtfSectAttr
, rtfColumnLine
, "linebetcol", 0 },
1644 { rtfSectAttr
, rtfLineModulus
, "linemod", 0 },
1645 { rtfSectAttr
, rtfLineDist
, "linex", 0 },
1646 { rtfSectAttr
, rtfLineStarts
, "linestarts", 0 },
1647 { rtfSectAttr
, rtfLineRestart
, "linerestart", 0 },
1648 { rtfSectAttr
, rtfLineRestartPg
, "lineppage", 0 },
1649 { rtfSectAttr
, rtfLineCont
, "linecont", 0 },
1651 { rtfSectAttr
, rtfSectPageWid
, "pgwsxn", 0 },
1652 { rtfSectAttr
, rtfSectPageHt
, "pghsxn", 0 },
1653 { rtfSectAttr
, rtfSectMarginLeft
, "marglsxn", 0 },
1654 { rtfSectAttr
, rtfSectMarginRight
, "margrsxn", 0 },
1655 { rtfSectAttr
, rtfSectMarginTop
, "margtsxn", 0 },
1656 { rtfSectAttr
, rtfSectMarginBottom
, "margbsxn", 0 },
1657 { rtfSectAttr
, rtfSectMarginGutter
, "guttersxn", 0 },
1658 { rtfSectAttr
, rtfSectLandscape
, "lndscpsxn", 0 },
1659 { rtfSectAttr
, rtfTitleSpecial
, "titlepg", 0 },
1660 { rtfSectAttr
, rtfHeaderY
, "headery", 0 },
1661 { rtfSectAttr
, rtfFooterY
, "footery", 0 },
1663 { rtfSectAttr
, rtfPageStarts
, "pgnstarts", 0 },
1664 { rtfSectAttr
, rtfPageCont
, "pgncont", 0 },
1665 { rtfSectAttr
, rtfPageRestart
, "pgnrestart", 0 },
1666 { rtfSectAttr
, rtfPageNumRight
, "pgnx", 0 },
1667 { rtfSectAttr
, rtfPageNumTop
, "pgny", 0 },
1668 { rtfSectAttr
, rtfPageDecimal
, "pgndec", 0 },
1669 { rtfSectAttr
, rtfPageURoman
, "pgnucrm", 0 },
1670 { rtfSectAttr
, rtfPageLRoman
, "pgnlcrm", 0 },
1671 { rtfSectAttr
, rtfPageULetter
, "pgnucltr", 0 },
1672 { rtfSectAttr
, rtfPageLLetter
, "pgnlcltr", 0 },
1673 { rtfSectAttr
, rtfPageNumHyphSep
, "pgnhnsh", 0 },
1674 { rtfSectAttr
, rtfPageNumSpaceSep
, "pgnhnsp", 0 },
1675 { rtfSectAttr
, rtfPageNumColonSep
, "pgnhnsc", 0 },
1676 { rtfSectAttr
, rtfPageNumEmdashSep
, "pgnhnsm", 0 },
1677 { rtfSectAttr
, rtfPageNumEndashSep
, "pgnhnsn", 0 },
1679 { rtfSectAttr
, rtfTopVAlign
, "vertalt", 0 },
1680 /* misspelled as "vertal" in specification 1.0 */
1681 { rtfSectAttr
, rtfBottomVAlign
, "vertalb", 0 },
1682 { rtfSectAttr
, rtfCenterVAlign
, "vertalc", 0 },
1683 { rtfSectAttr
, rtfJustVAlign
, "vertalj", 0 },
1685 { rtfSectAttr
, rtfRTLSect
, "rtlsect", 0 },
1686 { rtfSectAttr
, rtfLTRSect
, "ltrsect", 0 },
1688 /* I've seen these in an old spec, but not in real files... */
1689 /*rtfSectAttr, rtfNoBreak, "nobreak", 0,*/
1690 /*rtfSectAttr, rtfColBreak, "colbreak", 0,*/
1691 /*rtfSectAttr, rtfPageBreak, "pagebreak", 0,*/
1692 /*rtfSectAttr, rtfEvenBreak, "evenbreak", 0,*/
1693 /*rtfSectAttr, rtfOddBreak, "oddbreak", 0,*/
1696 * Document formatting attributes
1699 { rtfDocAttr
, rtfDefTab
, "deftab", 0 },
1700 { rtfDocAttr
, rtfHyphHotZone
, "hyphhotz", 0 },
1701 { rtfDocAttr
, rtfHyphConsecLines
, "hyphconsec", 0 },
1702 { rtfDocAttr
, rtfHyphCaps
, "hyphcaps", 0 },
1703 { rtfDocAttr
, rtfHyphAuto
, "hyphauto", 0 },
1704 { rtfDocAttr
, rtfLineStart
, "linestart", 0 },
1705 { rtfDocAttr
, rtfFracWidth
, "fracwidth", 0 },
1706 /* \makeback was given in old version of spec, it's now */
1707 /* listed as \makebackup */
1708 { rtfDocAttr
, rtfMakeBackup
, "makeback", 0 },
1709 { rtfDocAttr
, rtfMakeBackup
, "makebackup", 0 },
1710 { rtfDocAttr
, rtfRTFDefault
, "defformat", 0 },
1711 { rtfDocAttr
, rtfPSOverlay
, "psover", 0 },
1712 { rtfDocAttr
, rtfDocTemplate
, "doctemp", 0 },
1713 { rtfDocAttr
, rtfDefLanguage
, "deflang", 0 },
1715 { rtfDocAttr
, rtfFENoteType
, "fet", 0 },
1716 { rtfDocAttr
, rtfFNoteEndSect
, "endnotes", 0 },
1717 { rtfDocAttr
, rtfFNoteEndDoc
, "enddoc", 0 },
1718 { rtfDocAttr
, rtfFNoteText
, "ftntj", 0 },
1719 { rtfDocAttr
, rtfFNoteBottom
, "ftnbj", 0 },
1720 { rtfDocAttr
, rtfENoteEndSect
, "aendnotes", 0 },
1721 { rtfDocAttr
, rtfENoteEndDoc
, "aenddoc", 0 },
1722 { rtfDocAttr
, rtfENoteText
, "aftntj", 0 },
1723 { rtfDocAttr
, rtfENoteBottom
, "aftnbj", 0 },
1724 { rtfDocAttr
, rtfFNoteStart
, "ftnstart", 0 },
1725 { rtfDocAttr
, rtfENoteStart
, "aftnstart", 0 },
1726 { rtfDocAttr
, rtfFNoteRestartPage
, "ftnrstpg", 0 },
1727 { rtfDocAttr
, rtfFNoteRestart
, "ftnrestart", 0 },
1728 { rtfDocAttr
, rtfFNoteRestartCont
, "ftnrstcont", 0 },
1729 { rtfDocAttr
, rtfENoteRestart
, "aftnrestart", 0 },
1730 { rtfDocAttr
, rtfENoteRestartCont
, "aftnrstcont", 0 },
1731 { rtfDocAttr
, rtfFNoteNumArabic
, "ftnnar", 0 },
1732 { rtfDocAttr
, rtfFNoteNumLLetter
, "ftnnalc", 0 },
1733 { rtfDocAttr
, rtfFNoteNumULetter
, "ftnnauc", 0 },
1734 { rtfDocAttr
, rtfFNoteNumLRoman
, "ftnnrlc", 0 },
1735 { rtfDocAttr
, rtfFNoteNumURoman
, "ftnnruc", 0 },
1736 { rtfDocAttr
, rtfFNoteNumChicago
, "ftnnchi", 0 },
1737 { rtfDocAttr
, rtfENoteNumArabic
, "aftnnar", 0 },
1738 { rtfDocAttr
, rtfENoteNumLLetter
, "aftnnalc", 0 },
1739 { rtfDocAttr
, rtfENoteNumULetter
, "aftnnauc", 0 },
1740 { rtfDocAttr
, rtfENoteNumLRoman
, "aftnnrlc", 0 },
1741 { rtfDocAttr
, rtfENoteNumURoman
, "aftnnruc", 0 },
1742 { rtfDocAttr
, rtfENoteNumChicago
, "aftnnchi", 0 },
1744 { rtfDocAttr
, rtfPaperWidth
, "paperw", 0 },
1745 { rtfDocAttr
, rtfPaperHeight
, "paperh", 0 },
1746 { rtfDocAttr
, rtfPaperSize
, "psz", 0 },
1747 { rtfDocAttr
, rtfLeftMargin
, "margl", 0 },
1748 { rtfDocAttr
, rtfRightMargin
, "margr", 0 },
1749 { rtfDocAttr
, rtfTopMargin
, "margt", 0 },
1750 { rtfDocAttr
, rtfBottomMargin
, "margb", 0 },
1751 { rtfDocAttr
, rtfFacingPage
, "facingp", 0 },
1752 { rtfDocAttr
, rtfGutterWid
, "gutter", 0 },
1753 { rtfDocAttr
, rtfMirrorMargin
, "margmirror", 0 },
1754 { rtfDocAttr
, rtfLandscape
, "landscape", 0 },
1755 { rtfDocAttr
, rtfPageStart
, "pgnstart", 0 },
1756 { rtfDocAttr
, rtfWidowCtrl
, "widowctrl", 0 },
1758 { rtfDocAttr
, rtfLinkStyles
, "linkstyles", 0 },
1760 { rtfDocAttr
, rtfNoAutoTabIndent
, "notabind", 0 },
1761 { rtfDocAttr
, rtfWrapSpaces
, "wraptrsp", 0 },
1762 { rtfDocAttr
, rtfPrintColorsBlack
, "prcolbl", 0 },
1763 { rtfDocAttr
, rtfNoExtraSpaceRL
, "noextrasprl", 0 },
1764 { rtfDocAttr
, rtfNoColumnBalance
, "nocolbal", 0 },
1765 { rtfDocAttr
, rtfCvtMailMergeQuote
, "cvmme", 0 },
1766 { rtfDocAttr
, rtfSuppressTopSpace
, "sprstsp", 0 },
1767 { rtfDocAttr
, rtfSuppressPreParSpace
, "sprsspbf", 0 },
1768 { rtfDocAttr
, rtfCombineTblBorders
, "otblrul", 0 },
1769 { rtfDocAttr
, rtfTranspMetafiles
, "transmf", 0 },
1770 { rtfDocAttr
, rtfSwapBorders
, "swpbdr", 0 },
1771 { rtfDocAttr
, rtfShowHardBreaks
, "brkfrm", 0 },
1773 { rtfDocAttr
, rtfFormProtected
, "formprot", 0 },
1774 { rtfDocAttr
, rtfAllProtected
, "allprot", 0 },
1775 { rtfDocAttr
, rtfFormShading
, "formshade", 0 },
1776 { rtfDocAttr
, rtfFormDisplay
, "formdisp", 0 },
1777 { rtfDocAttr
, rtfPrintData
, "printdata", 0 },
1779 { rtfDocAttr
, rtfRevProtected
, "revprot", 0 },
1780 { rtfDocAttr
, rtfRevisions
, "revisions", 0 },
1781 { rtfDocAttr
, rtfRevDisplay
, "revprop", 0 },
1782 { rtfDocAttr
, rtfRevBar
, "revbar", 0 },
1784 { rtfDocAttr
, rtfAnnotProtected
, "annotprot", 0 },
1786 { rtfDocAttr
, rtfRTLDoc
, "rtldoc", 0 },
1787 { rtfDocAttr
, rtfLTRDoc
, "ltrdoc", 0 },
1789 { rtfDocAttr
, rtfAnsiCodePage
, "ansicpg", 0 },
1790 { rtfDocAttr
, rtfUTF8RTF
, "urtf", 0 },
1796 { rtfStyleAttr
, rtfAdditive
, "additive", 0 },
1797 { rtfStyleAttr
, rtfBasedOn
, "sbasedon", 0 },
1798 { rtfStyleAttr
, rtfNext
, "snext", 0 },
1801 * Picture attributes
1804 { rtfPictAttr
, rtfMacQD
, "macpict", 0 },
1805 { rtfPictAttr
, rtfPMMetafile
, "pmmetafile", 0 },
1806 { rtfPictAttr
, rtfWinMetafile
, "wmetafile", 0 },
1807 { rtfPictAttr
, rtfDevIndBitmap
, "dibitmap", 0 },
1808 { rtfPictAttr
, rtfWinBitmap
, "wbitmap", 0 },
1809 { rtfPictAttr
, rtfEmfBlip
, "emfblip", 0 },
1810 { rtfPictAttr
, rtfPixelBits
, "wbmbitspixel", 0 },
1811 { rtfPictAttr
, rtfBitmapPlanes
, "wbmplanes", 0 },
1812 { rtfPictAttr
, rtfBitmapWid
, "wbmwidthbytes", 0 },
1814 { rtfPictAttr
, rtfPicWid
, "picw", 0 },
1815 { rtfPictAttr
, rtfPicHt
, "pich", 0 },
1816 { rtfPictAttr
, rtfPicGoalWid
, "picwgoal", 0 },
1817 { rtfPictAttr
, rtfPicGoalHt
, "pichgoal", 0 },
1818 /* these two aren't in the spec, but some writers emit them */
1819 { rtfPictAttr
, rtfPicGoalWid
, "picwGoal", 0 },
1820 { rtfPictAttr
, rtfPicGoalHt
, "pichGoal", 0 },
1821 { rtfPictAttr
, rtfPicScaleX
, "picscalex", 0 },
1822 { rtfPictAttr
, rtfPicScaleY
, "picscaley", 0 },
1823 { rtfPictAttr
, rtfPicScaled
, "picscaled", 0 },
1824 { rtfPictAttr
, rtfPicCropTop
, "piccropt", 0 },
1825 { rtfPictAttr
, rtfPicCropBottom
, "piccropb", 0 },
1826 { rtfPictAttr
, rtfPicCropLeft
, "piccropl", 0 },
1827 { rtfPictAttr
, rtfPicCropRight
, "piccropr", 0 },
1829 { rtfPictAttr
, rtfPicMFHasBitmap
, "picbmp", 0 },
1830 { rtfPictAttr
, rtfPicMFBitsPerPixel
, "picbpp", 0 },
1832 { rtfPictAttr
, rtfPicBinary
, "bin", 0 },
1835 * NeXT graphic attributes
1838 { rtfNeXTGrAttr
, rtfNeXTGWidth
, "width", 0 },
1839 { rtfNeXTGrAttr
, rtfNeXTGHeight
, "height", 0 },
1845 { rtfDestination
, rtfFontTbl
, "fonttbl", 0 },
1846 { rtfDestination
, rtfFontAltName
, "falt", 0 },
1847 { rtfDestination
, rtfEmbeddedFont
, "fonteb", 0 },
1848 { rtfDestination
, rtfFontFile
, "fontfile", 0 },
1849 { rtfDestination
, rtfFileTbl
, "filetbl", 0 },
1850 { rtfDestination
, rtfFileInfo
, "file", 0 },
1851 { rtfDestination
, rtfColorTbl
, "colortbl", 0 },
1852 { rtfDestination
, rtfStyleSheet
, "stylesheet", 0 },
1853 { rtfDestination
, rtfKeyCode
, "keycode", 0 },
1854 { rtfDestination
, rtfRevisionTbl
, "revtbl", 0 },
1855 { rtfDestination
, rtfGenerator
, "generator", 0 },
1856 { rtfDestination
, rtfInfo
, "info", 0 },
1857 { rtfDestination
, rtfITitle
, "title", 0 },
1858 { rtfDestination
, rtfISubject
, "subject", 0 },
1859 { rtfDestination
, rtfIAuthor
, "author", 0 },
1860 { rtfDestination
, rtfIOperator
, "operator", 0 },
1861 { rtfDestination
, rtfIKeywords
, "keywords", 0 },
1862 { rtfDestination
, rtfIComment
, "comment", 0 },
1863 { rtfDestination
, rtfIVersion
, "version", 0 },
1864 { rtfDestination
, rtfIDoccomm
, "doccomm", 0 },
1865 /* \verscomm may not exist -- was seen in earlier spec version */
1866 { rtfDestination
, rtfIVerscomm
, "verscomm", 0 },
1867 { rtfDestination
, rtfNextFile
, "nextfile", 0 },
1868 { rtfDestination
, rtfTemplate
, "template", 0 },
1869 { rtfDestination
, rtfFNSep
, "ftnsep", 0 },
1870 { rtfDestination
, rtfFNContSep
, "ftnsepc", 0 },
1871 { rtfDestination
, rtfFNContNotice
, "ftncn", 0 },
1872 { rtfDestination
, rtfENSep
, "aftnsep", 0 },
1873 { rtfDestination
, rtfENContSep
, "aftnsepc", 0 },
1874 { rtfDestination
, rtfENContNotice
, "aftncn", 0 },
1875 { rtfDestination
, rtfPageNumLevel
, "pgnhn", 0 },
1876 { rtfDestination
, rtfParNumLevelStyle
, "pnseclvl", 0 },
1877 { rtfDestination
, rtfHeader
, "header", 0 },
1878 { rtfDestination
, rtfFooter
, "footer", 0 },
1879 { rtfDestination
, rtfHeaderLeft
, "headerl", 0 },
1880 { rtfDestination
, rtfHeaderRight
, "headerr", 0 },
1881 { rtfDestination
, rtfHeaderFirst
, "headerf", 0 },
1882 { rtfDestination
, rtfFooterLeft
, "footerl", 0 },
1883 { rtfDestination
, rtfFooterRight
, "footerr", 0 },
1884 { rtfDestination
, rtfFooterFirst
, "footerf", 0 },
1885 { rtfDestination
, rtfParNumText
, "pntext", 0 },
1886 { rtfDestination
, rtfParNumbering
, "pn", 0 },
1887 { rtfDestination
, rtfParNumTextAfter
, "pntexta", 0 },
1888 { rtfDestination
, rtfParNumTextBefore
, "pntextb", 0 },
1889 { rtfDestination
, rtfBookmarkStart
, "bkmkstart", 0 },
1890 { rtfDestination
, rtfBookmarkEnd
, "bkmkend", 0 },
1891 { rtfDestination
, rtfPict
, "pict", 0 },
1892 { rtfDestination
, rtfObject
, "object", 0 },
1893 { rtfDestination
, rtfObjClass
, "objclass", 0 },
1894 { rtfDestination
, rtfObjName
, "objname", 0 },
1895 { rtfObjAttr
, rtfObjTime
, "objtime", 0 },
1896 { rtfDestination
, rtfObjData
, "objdata", 0 },
1897 { rtfDestination
, rtfObjAlias
, "objalias", 0 },
1898 { rtfDestination
, rtfObjSection
, "objsect", 0 },
1899 /* objitem and objtopic aren't documented in the spec! */
1900 { rtfDestination
, rtfObjItem
, "objitem", 0 },
1901 { rtfDestination
, rtfObjTopic
, "objtopic", 0 },
1902 { rtfDestination
, rtfObjResult
, "result", 0 },
1903 { rtfDestination
, rtfDrawObject
, "do", 0 },
1904 { rtfDestination
, rtfFootnote
, "footnote", 0 },
1905 { rtfDestination
, rtfAnnotRefStart
, "atrfstart", 0 },
1906 { rtfDestination
, rtfAnnotRefEnd
, "atrfend", 0 },
1907 { rtfDestination
, rtfAnnotID
, "atnid", 0 },
1908 { rtfDestination
, rtfAnnotAuthor
, "atnauthor", 0 },
1909 { rtfDestination
, rtfAnnotation
, "annotation", 0 },
1910 { rtfDestination
, rtfAnnotRef
, "atnref", 0 },
1911 { rtfDestination
, rtfAnnotTime
, "atntime", 0 },
1912 { rtfDestination
, rtfAnnotIcon
, "atnicn", 0 },
1913 { rtfDestination
, rtfField
, "field", 0 },
1914 { rtfDestination
, rtfFieldInst
, "fldinst", 0 },
1915 { rtfDestination
, rtfFieldResult
, "fldrslt", 0 },
1916 { rtfDestination
, rtfDataField
, "datafield", 0 },
1917 { rtfDestination
, rtfIndex
, "xe", 0 },
1918 { rtfDestination
, rtfIndexText
, "txe", 0 },
1919 { rtfDestination
, rtfIndexRange
, "rxe", 0 },
1920 { rtfDestination
, rtfTOC
, "tc", 0 },
1921 { rtfDestination
, rtfNeXTGraphic
, "NeXTGraphic", 0 },
1922 { rtfDestination
, rtfNestTableProps
, "nesttableprops", 0 },
1923 { rtfDestination
, rtfNoNestTables
, "nonesttables", 0 },
1929 { rtfFontFamily
, rtfFFNil
, "fnil", 0 },
1930 { rtfFontFamily
, rtfFFRoman
, "froman", 0 },
1931 { rtfFontFamily
, rtfFFSwiss
, "fswiss", 0 },
1932 { rtfFontFamily
, rtfFFModern
, "fmodern", 0 },
1933 { rtfFontFamily
, rtfFFScript
, "fscript", 0 },
1934 { rtfFontFamily
, rtfFFDecor
, "fdecor", 0 },
1935 { rtfFontFamily
, rtfFFTech
, "ftech", 0 },
1936 { rtfFontFamily
, rtfFFBidirectional
, "fbidi", 0 },
1942 { rtfFontAttr
, rtfFontCharSet
, "fcharset", 0 },
1943 { rtfFontAttr
, rtfFontPitch
, "fprq", 0 },
1944 { rtfFontAttr
, rtfFontCodePage
, "cpg", 0 },
1945 { rtfFontAttr
, rtfFTypeNil
, "ftnil", 0 },
1946 { rtfFontAttr
, rtfFTypeTrueType
, "fttruetype", 0 },
1949 * File table attributes
1952 { rtfFileAttr
, rtfFileNum
, "fid", 0 },
1953 { rtfFileAttr
, rtfFileRelPath
, "frelative", 0 },
1954 { rtfFileAttr
, rtfFileOSNum
, "fosnum", 0 },
1960 { rtfFileSource
, rtfSrcMacintosh
, "fvalidmac", 0 },
1961 { rtfFileSource
, rtfSrcDOS
, "fvaliddos", 0 },
1962 { rtfFileSource
, rtfSrcNTFS
, "fvalidntfs", 0 },
1963 { rtfFileSource
, rtfSrcHPFS
, "fvalidhpfs", 0 },
1964 { rtfFileSource
, rtfSrcNetwork
, "fnetwork", 0 },
1970 { rtfColorName
, rtfRed
, "red", 0 },
1971 { rtfColorName
, rtfGreen
, "green", 0 },
1972 { rtfColorName
, rtfBlue
, "blue", 0 },
1978 { rtfCharSet
, rtfMacCharSet
, "mac", 0 },
1979 { rtfCharSet
, rtfAnsiCharSet
, "ansi", 0 },
1980 { rtfCharSet
, rtfPcCharSet
, "pc", 0 },
1981 { rtfCharSet
, rtfPcaCharSet
, "pca", 0 },
1987 { rtfTblAttr
, rtfRowDef
, "trowd", 0 },
1988 { rtfTblAttr
, rtfRowGapH
, "trgaph", 0 },
1989 { rtfTblAttr
, rtfCellPos
, "cellx", 0 },
1990 { rtfTblAttr
, rtfMergeRngFirst
, "clmgf", 0 },
1991 { rtfTblAttr
, rtfMergePrevious
, "clmrg", 0 },
1993 { rtfTblAttr
, rtfRowLeft
, "trql", 0 },
1994 { rtfTblAttr
, rtfRowRight
, "trqr", 0 },
1995 { rtfTblAttr
, rtfRowCenter
, "trqc", 0 },
1996 { rtfTblAttr
, rtfRowLeftEdge
, "trleft", 0 },
1997 { rtfTblAttr
, rtfRowHt
, "trrh", 0 },
1998 { rtfTblAttr
, rtfRowHeader
, "trhdr", 0 },
1999 { rtfTblAttr
, rtfRowKeep
, "trkeep", 0 },
2001 { rtfTblAttr
, rtfRTLRow
, "rtlrow", 0 },
2002 { rtfTblAttr
, rtfLTRRow
, "ltrrow", 0 },
2004 { rtfTblAttr
, rtfRowBordTop
, "trbrdrt", 0 },
2005 { rtfTblAttr
, rtfRowBordLeft
, "trbrdrl", 0 },
2006 { rtfTblAttr
, rtfRowBordBottom
, "trbrdrb", 0 },
2007 { rtfTblAttr
, rtfRowBordRight
, "trbrdrr", 0 },
2008 { rtfTblAttr
, rtfRowBordHoriz
, "trbrdrh", 0 },
2009 { rtfTblAttr
, rtfRowBordVert
, "trbrdrv", 0 },
2011 { rtfTblAttr
, rtfCellBordBottom
, "clbrdrb", 0 },
2012 { rtfTblAttr
, rtfCellBordTop
, "clbrdrt", 0 },
2013 { rtfTblAttr
, rtfCellBordLeft
, "clbrdrl", 0 },
2014 { rtfTblAttr
, rtfCellBordRight
, "clbrdrr", 0 },
2016 { rtfTblAttr
, rtfCellShading
, "clshdng", 0 },
2017 { rtfTblAttr
, rtfCellBgPatH
, "clbghoriz", 0 },
2018 { rtfTblAttr
, rtfCellBgPatV
, "clbgvert", 0 },
2019 { rtfTblAttr
, rtfCellFwdDiagBgPat
, "clbgfdiag", 0 },
2020 { rtfTblAttr
, rtfCellBwdDiagBgPat
, "clbgbdiag", 0 },
2021 { rtfTblAttr
, rtfCellHatchBgPat
, "clbgcross", 0 },
2022 { rtfTblAttr
, rtfCellDiagHatchBgPat
, "clbgdcross", 0 },
2024 * The spec lists "clbgdkhor", but the corresponding non-cell
2025 * control is "bgdkhoriz". At any rate Macintosh Word seems
2026 * to accept both "clbgdkhor" and "clbgdkhoriz".
2028 { rtfTblAttr
, rtfCellDarkBgPatH
, "clbgdkhoriz", 0 },
2029 { rtfTblAttr
, rtfCellDarkBgPatH
, "clbgdkhor", 0 },
2030 { rtfTblAttr
, rtfCellDarkBgPatV
, "clbgdkvert", 0 },
2031 { rtfTblAttr
, rtfCellFwdDarkBgPat
, "clbgdkfdiag", 0 },
2032 { rtfTblAttr
, rtfCellBwdDarkBgPat
, "clbgdkbdiag", 0 },
2033 { rtfTblAttr
, rtfCellDarkHatchBgPat
, "clbgdkcross", 0 },
2034 { rtfTblAttr
, rtfCellDarkDiagHatchBgPat
, "clbgdkdcross", 0 },
2035 { rtfTblAttr
, rtfCellBgPatLineColor
, "clcfpat", 0 },
2036 { rtfTblAttr
, rtfCellBgPatColor
, "clcbpat", 0 },
2042 { rtfFieldAttr
, rtfFieldDirty
, "flddirty", 0 },
2043 { rtfFieldAttr
, rtfFieldEdited
, "fldedit", 0 },
2044 { rtfFieldAttr
, rtfFieldLocked
, "fldlock", 0 },
2045 { rtfFieldAttr
, rtfFieldPrivate
, "fldpriv", 0 },
2046 { rtfFieldAttr
, rtfFieldAlt
, "fldalt", 0 },
2049 * Positioning attributes
2052 { rtfPosAttr
, rtfAbsWid
, "absw", 0 },
2053 { rtfPosAttr
, rtfAbsHt
, "absh", 0 },
2055 { rtfPosAttr
, rtfRPosMargH
, "phmrg", 0 },
2056 { rtfPosAttr
, rtfRPosPageH
, "phpg", 0 },
2057 { rtfPosAttr
, rtfRPosColH
, "phcol", 0 },
2058 { rtfPosAttr
, rtfPosX
, "posx", 0 },
2059 { rtfPosAttr
, rtfPosNegX
, "posnegx", 0 },
2060 { rtfPosAttr
, rtfPosXCenter
, "posxc", 0 },
2061 { rtfPosAttr
, rtfPosXInside
, "posxi", 0 },
2062 { rtfPosAttr
, rtfPosXOutSide
, "posxo", 0 },
2063 { rtfPosAttr
, rtfPosXRight
, "posxr", 0 },
2064 { rtfPosAttr
, rtfPosXLeft
, "posxl", 0 },
2066 { rtfPosAttr
, rtfRPosMargV
, "pvmrg", 0 },
2067 { rtfPosAttr
, rtfRPosPageV
, "pvpg", 0 },
2068 { rtfPosAttr
, rtfRPosParaV
, "pvpara", 0 },
2069 { rtfPosAttr
, rtfPosY
, "posy", 0 },
2070 { rtfPosAttr
, rtfPosNegY
, "posnegy", 0 },
2071 { rtfPosAttr
, rtfPosYInline
, "posyil", 0 },
2072 { rtfPosAttr
, rtfPosYTop
, "posyt", 0 },
2073 { rtfPosAttr
, rtfPosYCenter
, "posyc", 0 },
2074 { rtfPosAttr
, rtfPosYBottom
, "posyb", 0 },
2076 { rtfPosAttr
, rtfNoWrap
, "nowrap", 0 },
2077 { rtfPosAttr
, rtfDistFromTextAll
, "dxfrtext", 0 },
2078 { rtfPosAttr
, rtfDistFromTextX
, "dfrmtxtx", 0 },
2079 { rtfPosAttr
, rtfDistFromTextY
, "dfrmtxty", 0 },
2080 /* \dyfrtext no longer exists in spec 1.2, apparently */
2081 /* replaced by \dfrmtextx and \dfrmtexty. */
2082 { rtfPosAttr
, rtfTextDistY
, "dyfrtext", 0 },
2084 { rtfPosAttr
, rtfDropCapLines
, "dropcapli", 0 },
2085 { rtfPosAttr
, rtfDropCapType
, "dropcapt", 0 },
2091 { rtfObjAttr
, rtfObjEmb
, "objemb", 0 },
2092 { rtfObjAttr
, rtfObjLink
, "objlink", 0 },
2093 { rtfObjAttr
, rtfObjAutoLink
, "objautlink", 0 },
2094 { rtfObjAttr
, rtfObjSubscriber
, "objsub", 0 },
2095 { rtfObjAttr
, rtfObjPublisher
, "objpub", 0 },
2096 { rtfObjAttr
, rtfObjICEmb
, "objicemb", 0 },
2098 { rtfObjAttr
, rtfObjLinkSelf
, "linkself", 0 },
2099 { rtfObjAttr
, rtfObjLock
, "objupdate", 0 },
2100 { rtfObjAttr
, rtfObjUpdate
, "objlock", 0 },
2102 { rtfObjAttr
, rtfObjHt
, "objh", 0 },
2103 { rtfObjAttr
, rtfObjWid
, "objw", 0 },
2104 { rtfObjAttr
, rtfObjSetSize
, "objsetsize", 0 },
2105 { rtfObjAttr
, rtfObjAlign
, "objalign", 0 },
2106 { rtfObjAttr
, rtfObjTransposeY
, "objtransy", 0 },
2107 { rtfObjAttr
, rtfObjCropTop
, "objcropt", 0 },
2108 { rtfObjAttr
, rtfObjCropBottom
, "objcropb", 0 },
2109 { rtfObjAttr
, rtfObjCropLeft
, "objcropl", 0 },
2110 { rtfObjAttr
, rtfObjCropRight
, "objcropr", 0 },
2111 { rtfObjAttr
, rtfObjScaleX
, "objscalex", 0 },
2112 { rtfObjAttr
, rtfObjScaleY
, "objscaley", 0 },
2114 { rtfObjAttr
, rtfObjResRTF
, "rsltrtf", 0 },
2115 { rtfObjAttr
, rtfObjResPict
, "rsltpict", 0 },
2116 { rtfObjAttr
, rtfObjResBitmap
, "rsltbmp", 0 },
2117 { rtfObjAttr
, rtfObjResText
, "rslttxt", 0 },
2118 { rtfObjAttr
, rtfObjResMerge
, "rsltmerge", 0 },
2120 { rtfObjAttr
, rtfObjBookmarkPubObj
, "bkmkpub", 0 },
2121 { rtfObjAttr
, rtfObjPubAutoUpdate
, "pubauto", 0 },
2124 * Associated character formatting attributes
2127 { rtfACharAttr
, rtfACBold
, "ab", 0 },
2128 { rtfACharAttr
, rtfACAllCaps
, "caps", 0 },
2129 { rtfACharAttr
, rtfACForeColor
, "acf", 0 },
2130 { rtfACharAttr
, rtfACSubScript
, "adn", 0 },
2131 { rtfACharAttr
, rtfACExpand
, "aexpnd", 0 },
2132 { rtfACharAttr
, rtfACFontNum
, "af", 0 },
2133 { rtfACharAttr
, rtfACFontSize
, "afs", 0 },
2134 { rtfACharAttr
, rtfACItalic
, "ai", 0 },
2135 { rtfACharAttr
, rtfACLanguage
, "alang", 0 },
2136 { rtfACharAttr
, rtfACOutline
, "aoutl", 0 },
2137 { rtfACharAttr
, rtfACSmallCaps
, "ascaps", 0 },
2138 { rtfACharAttr
, rtfACShadow
, "ashad", 0 },
2139 { rtfACharAttr
, rtfACStrikeThru
, "astrike", 0 },
2140 { rtfACharAttr
, rtfACUnderline
, "aul", 0 },
2141 { rtfACharAttr
, rtfACDotUnderline
, "auld", 0 },
2142 { rtfACharAttr
, rtfACDbUnderline
, "auldb", 0 },
2143 { rtfACharAttr
, rtfACNoUnderline
, "aulnone", 0 },
2144 { rtfACharAttr
, rtfACWordUnderline
, "aulw", 0 },
2145 { rtfACharAttr
, rtfACSuperScript
, "aup", 0 },
2148 * Footnote attributes
2151 { rtfFNoteAttr
, rtfFNAlt
, "ftnalt", 0 },
2154 * Key code attributes
2157 { rtfKeyCodeAttr
, rtfAltKey
, "alt", 0 },
2158 { rtfKeyCodeAttr
, rtfShiftKey
, "shift", 0 },
2159 { rtfKeyCodeAttr
, rtfControlKey
, "ctrl", 0 },
2160 { rtfKeyCodeAttr
, rtfFunctionKey
, "fn", 0 },
2163 * Bookmark attributes
2166 { rtfBookmarkAttr
, rtfBookmarkFirstCol
, "bkmkcolf", 0 },
2167 { rtfBookmarkAttr
, rtfBookmarkLastCol
, "bkmkcoll", 0 },
2170 * Index entry attributes
2173 { rtfIndexAttr
, rtfIndexNumber
, "xef", 0 },
2174 { rtfIndexAttr
, rtfIndexBold
, "bxe", 0 },
2175 { rtfIndexAttr
, rtfIndexItalic
, "ixe", 0 },
2178 * Table of contents attributes
2181 { rtfTOCAttr
, rtfTOCType
, "tcf", 0 },
2182 { rtfTOCAttr
, rtfTOCLevel
, "tcl", 0 },
2185 * Drawing object attributes
2188 { rtfDrawAttr
, rtfDrawLock
, "dolock", 0 },
2189 { rtfDrawAttr
, rtfDrawPageRelX
, "doxpage", 0 },
2190 { rtfDrawAttr
, rtfDrawColumnRelX
, "dobxcolumn", 0 },
2191 { rtfDrawAttr
, rtfDrawMarginRelX
, "dobxmargin", 0 },
2192 { rtfDrawAttr
, rtfDrawPageRelY
, "dobypage", 0 },
2193 { rtfDrawAttr
, rtfDrawColumnRelY
, "dobycolumn", 0 },
2194 { rtfDrawAttr
, rtfDrawMarginRelY
, "dobymargin", 0 },
2195 { rtfDrawAttr
, rtfDrawHeight
, "dobhgt", 0 },
2197 { rtfDrawAttr
, rtfDrawBeginGroup
, "dpgroup", 0 },
2198 { rtfDrawAttr
, rtfDrawGroupCount
, "dpcount", 0 },
2199 { rtfDrawAttr
, rtfDrawEndGroup
, "dpendgroup", 0 },
2200 { rtfDrawAttr
, rtfDrawArc
, "dparc", 0 },
2201 { rtfDrawAttr
, rtfDrawCallout
, "dpcallout", 0 },
2202 { rtfDrawAttr
, rtfDrawEllipse
, "dpellipse", 0 },
2203 { rtfDrawAttr
, rtfDrawLine
, "dpline", 0 },
2204 { rtfDrawAttr
, rtfDrawPolygon
, "dppolygon", 0 },
2205 { rtfDrawAttr
, rtfDrawPolyLine
, "dppolyline", 0 },
2206 { rtfDrawAttr
, rtfDrawRect
, "dprect", 0 },
2207 { rtfDrawAttr
, rtfDrawTextBox
, "dptxbx", 0 },
2209 { rtfDrawAttr
, rtfDrawOffsetX
, "dpx", 0 },
2210 { rtfDrawAttr
, rtfDrawSizeX
, "dpxsize", 0 },
2211 { rtfDrawAttr
, rtfDrawOffsetY
, "dpy", 0 },
2212 { rtfDrawAttr
, rtfDrawSizeY
, "dpysize", 0 },
2214 { rtfDrawAttr
, rtfCOAngle
, "dpcoa", 0 },
2215 { rtfDrawAttr
, rtfCOAccentBar
, "dpcoaccent", 0 },
2216 { rtfDrawAttr
, rtfCOBestFit
, "dpcobestfit", 0 },
2217 { rtfDrawAttr
, rtfCOBorder
, "dpcoborder", 0 },
2218 { rtfDrawAttr
, rtfCOAttachAbsDist
, "dpcodabs", 0 },
2219 { rtfDrawAttr
, rtfCOAttachBottom
, "dpcodbottom", 0 },
2220 { rtfDrawAttr
, rtfCOAttachCenter
, "dpcodcenter", 0 },
2221 { rtfDrawAttr
, rtfCOAttachTop
, "dpcodtop", 0 },
2222 { rtfDrawAttr
, rtfCOLength
, "dpcolength", 0 },
2223 { rtfDrawAttr
, rtfCONegXQuadrant
, "dpcominusx", 0 },
2224 { rtfDrawAttr
, rtfCONegYQuadrant
, "dpcominusy", 0 },
2225 { rtfDrawAttr
, rtfCOOffset
, "dpcooffset", 0 },
2226 { rtfDrawAttr
, rtfCOAttachSmart
, "dpcosmarta", 0 },
2227 { rtfDrawAttr
, rtfCODoubleLine
, "dpcotdouble", 0 },
2228 { rtfDrawAttr
, rtfCORightAngle
, "dpcotright", 0 },
2229 { rtfDrawAttr
, rtfCOSingleLine
, "dpcotsingle", 0 },
2230 { rtfDrawAttr
, rtfCOTripleLine
, "dpcottriple", 0 },
2232 { rtfDrawAttr
, rtfDrawTextBoxMargin
, "dptxbxmar", 0 },
2233 { rtfDrawAttr
, rtfDrawTextBoxText
, "dptxbxtext", 0 },
2234 { rtfDrawAttr
, rtfDrawRoundRect
, "dproundr", 0 },
2236 { rtfDrawAttr
, rtfDrawPointX
, "dpptx", 0 },
2237 { rtfDrawAttr
, rtfDrawPointY
, "dppty", 0 },
2238 { rtfDrawAttr
, rtfDrawPolyCount
, "dppolycount", 0 },
2240 { rtfDrawAttr
, rtfDrawArcFlipX
, "dparcflipx", 0 },
2241 { rtfDrawAttr
, rtfDrawArcFlipY
, "dparcflipy", 0 },
2243 { rtfDrawAttr
, rtfDrawLineBlue
, "dplinecob", 0 },
2244 { rtfDrawAttr
, rtfDrawLineGreen
, "dplinecog", 0 },
2245 { rtfDrawAttr
, rtfDrawLineRed
, "dplinecor", 0 },
2246 { rtfDrawAttr
, rtfDrawLinePalette
, "dplinepal", 0 },
2247 { rtfDrawAttr
, rtfDrawLineDashDot
, "dplinedado", 0 },
2248 { rtfDrawAttr
, rtfDrawLineDashDotDot
, "dplinedadodo", 0 },
2249 { rtfDrawAttr
, rtfDrawLineDash
, "dplinedash", 0 },
2250 { rtfDrawAttr
, rtfDrawLineDot
, "dplinedot", 0 },
2251 { rtfDrawAttr
, rtfDrawLineGray
, "dplinegray", 0 },
2252 { rtfDrawAttr
, rtfDrawLineHollow
, "dplinehollow", 0 },
2253 { rtfDrawAttr
, rtfDrawLineSolid
, "dplinesolid", 0 },
2254 { rtfDrawAttr
, rtfDrawLineWidth
, "dplinew", 0 },
2256 { rtfDrawAttr
, rtfDrawHollowEndArrow
, "dpaendhol", 0 },
2257 { rtfDrawAttr
, rtfDrawEndArrowLength
, "dpaendl", 0 },
2258 { rtfDrawAttr
, rtfDrawSolidEndArrow
, "dpaendsol", 0 },
2259 { rtfDrawAttr
, rtfDrawEndArrowWidth
, "dpaendw", 0 },
2260 { rtfDrawAttr
, rtfDrawHollowStartArrow
,"dpastarthol", 0 },
2261 { rtfDrawAttr
, rtfDrawStartArrowLength
,"dpastartl", 0 },
2262 { rtfDrawAttr
, rtfDrawSolidStartArrow
, "dpastartsol", 0 },
2263 { rtfDrawAttr
, rtfDrawStartArrowWidth
, "dpastartw", 0 },
2265 { rtfDrawAttr
, rtfDrawBgFillBlue
, "dpfillbgcb", 0 },
2266 { rtfDrawAttr
, rtfDrawBgFillGreen
, "dpfillbgcg", 0 },
2267 { rtfDrawAttr
, rtfDrawBgFillRed
, "dpfillbgcr", 0 },
2268 { rtfDrawAttr
, rtfDrawBgFillPalette
, "dpfillbgpal", 0 },
2269 { rtfDrawAttr
, rtfDrawBgFillGray
, "dpfillbggray", 0 },
2270 { rtfDrawAttr
, rtfDrawFgFillBlue
, "dpfillfgcb", 0 },
2271 { rtfDrawAttr
, rtfDrawFgFillGreen
, "dpfillfgcg", 0 },
2272 { rtfDrawAttr
, rtfDrawFgFillRed
, "dpfillfgcr", 0 },
2273 { rtfDrawAttr
, rtfDrawFgFillPalette
, "dpfillfgpal", 0 },
2274 { rtfDrawAttr
, rtfDrawFgFillGray
, "dpfillfggray", 0 },
2275 { rtfDrawAttr
, rtfDrawFillPatIndex
, "dpfillpat", 0 },
2277 { rtfDrawAttr
, rtfDrawShadow
, "dpshadow", 0 },
2278 { rtfDrawAttr
, rtfDrawShadowXOffset
, "dpshadx", 0 },
2279 { rtfDrawAttr
, rtfDrawShadowYOffset
, "dpshady", 0 },
2281 { rtfVersion
, -1, "rtf", 0 },
2282 { rtfDefFont
, -1, "deff", 0 },
2284 { 0, -1, (char *) NULL
, 0 }
2286 #define RTF_KEY_COUNT (sizeof(rtfKey) / sizeof(RTFKey))
2288 typedef struct tagRTFHashTableEntry
{
2291 } RTFHashTableEntry
;
2293 static RTFHashTableEntry rtfHashTable
[RTF_KEY_COUNT
* 2];
2297 * Initialize lookup table hash values. Only need to do this once.
2300 void LookupInit(void)
2304 memset(rtfHashTable
, 0, sizeof rtfHashTable
);
2305 for (rp
= rtfKey
; rp
->rtfKStr
!= NULL
; rp
++)
2309 rp
->rtfKHash
= Hash (rp
->rtfKStr
);
2310 index
= rp
->rtfKHash
% (RTF_KEY_COUNT
* 2);
2311 if (!rtfHashTable
[index
].count
)
2312 rtfHashTable
[index
].value
= heap_alloc(sizeof(RTFKey
*));
2314 rtfHashTable
[index
].value
= heap_realloc(rtfHashTable
[index
].value
, sizeof(RTFKey
*) * (rtfHashTable
[index
].count
+ 1));
2315 rtfHashTable
[index
].value
[rtfHashTable
[index
].count
++] = rp
;
2319 void LookupCleanup(void)
2323 for (i
=0; i
<RTF_KEY_COUNT
*2; i
++)
2325 heap_free( rtfHashTable
[i
].value
);
2326 rtfHashTable
[i
].value
= NULL
;
2327 rtfHashTable
[i
].count
= 0;
2333 * Determine major and minor number of control token. If it's
2334 * not found, the class turns into rtfUnknown.
2337 static void Lookup(RTF_Info
*info
, char *s
)
2341 RTFHashTableEntry
*entry
;
2344 ++s
; /* skip over the leading \ character */
2346 entry
= &rtfHashTable
[hash
% (RTF_KEY_COUNT
* 2)];
2347 for (i
= 0; i
< entry
->count
; i
++)
2349 rp
= entry
->value
[i
];
2350 if (hash
== rp
->rtfKHash
&& strcmp (s
, rp
->rtfKStr
) == 0)
2352 info
->rtfClass
= rtfControl
;
2353 info
->rtfMajor
= rp
->rtfKMajor
;
2354 info
->rtfMinor
= rp
->rtfKMinor
;
2358 info
->rtfClass
= rtfUnknown
;
2363 * Compute hash value of symbol
2366 static int Hash(const char *s
)
2371 while ((c
= *s
++) != '\0')
2378 /* ---------------------------------------------------------------------- */
2382 * Token comparison routines
2385 int RTFCheckCM(const RTF_Info
*info
, int class, int major
)
2387 return (info
->rtfClass
== class && info
->rtfMajor
== major
);
2391 int RTFCheckCMM(const RTF_Info
*info
, int class, int major
, int minor
)
2393 return (info
->rtfClass
== class && info
->rtfMajor
== major
&& info
->rtfMinor
== minor
);
2397 int RTFCheckMM(const RTF_Info
*info
, int major
, int minor
)
2399 return (info
->rtfMajor
== major
&& info
->rtfMinor
== minor
);
2403 /* ---------------------------------------------------------------------- */
2406 int RTFCharToHex(char c
)
2411 return (c
- '0'); /* '0'..'9' */
2412 return (c
- 'a' + 10); /* 'a'..'f' */
2416 int RTFHexToChar(int i
)
2420 return (i
- 10 + 'a');
2424 /* ---------------------------------------------------------------------- */
2427 * originally from RTF tools' text-writer.c
2429 * text-writer -- RTF-to-text translation writer code.
2431 * Read RTF input, write text of document (text extraction).
2434 static void TextClass (RTF_Info
*info
);
2435 static void ControlClass (RTF_Info
*info
);
2436 static void DefFont(RTF_Info
*info
);
2437 static void Destination (RTF_Info
*info
);
2438 static void SpecialChar (RTF_Info
*info
);
2439 static void RTFPutUnicodeChar (RTF_Info
*info
, int c
);
2442 * Initialize the writer.
2446 WriterInit (RTF_Info
*info
)
2452 BeginFile (RTF_Info
*info
)
2454 /* install class callbacks */
2456 RTFSetClassCallback (info
, rtfText
, TextClass
);
2457 RTFSetClassCallback (info
, rtfControl
, ControlClass
);
2463 * Write out a character.
2467 TextClass (RTF_Info
*info
)
2469 RTFPutCodePageChar(info
, info
->rtfMajor
);
2474 ControlClass (RTF_Info
*info
)
2476 switch (info
->rtfMajor
)
2487 case rtfDestination
:
2493 case rtfSpecialChar
:
2501 CharAttr(RTF_Info
*info
)
2505 switch (info
->rtfMinor
)
2508 font
= RTFGetFont(info
, info
->rtfParam
);
2511 if (info
->ansiCodePage
!= CP_UTF8
)
2512 info
->codePage
= font
->rtfFCodePage
;
2513 TRACE("font %d codepage %d\n", info
->rtfParam
, info
->codePage
);
2516 ERR( "unknown font %d\n", info
->rtfParam
);
2518 case rtfUnicodeLength
:
2519 info
->unicodeLength
= info
->rtfParam
;
2526 CharSet(RTF_Info
*info
)
2528 if (info
->ansiCodePage
== CP_UTF8
)
2531 switch (info
->rtfMinor
)
2533 case rtfAnsiCharSet
:
2534 info
->ansiCodePage
= 1252; /* Latin-1 */
2537 info
->ansiCodePage
= 10000; /* MacRoman */
2540 info
->ansiCodePage
= 437;
2543 info
->ansiCodePage
= 850;
2549 * This function notices destinations that aren't explicitly handled
2550 * and skips to their ends. This keeps, for instance, picture
2551 * data from being considered as plain text.
2555 Destination (RTF_Info
*info
)
2557 if (!RTFGetDestinationCallback(info
, info
->rtfMinor
))
2558 RTFSkipGroup (info
);
2563 DefFont(RTF_Info
*info
)
2565 TRACE("%d\n", info
->rtfParam
);
2566 info
->defFont
= info
->rtfParam
;
2571 DocAttr(RTF_Info
*info
)
2573 TRACE("minor %d, param %d\n", info
->rtfMinor
, info
->rtfParam
);
2575 switch (info
->rtfMinor
)
2577 case rtfAnsiCodePage
:
2578 info
->codePage
= info
->ansiCodePage
= info
->rtfParam
;
2581 info
->codePage
= info
->ansiCodePage
= CP_UTF8
;
2587 static void SpecialChar (RTF_Info
*info
)
2589 switch (info
->rtfMinor
)
2592 /* the next token determines destination, if it's unknown, skip the group */
2593 /* this way we filter out the garbage coming from unknown destinations */
2595 if (info
->rtfClass
!= rtfDestination
)
2598 RTFRouteToken(info
); /* "\*" is ignored with known destinations */
2604 RTFPutUnicodeChar(info
, info
->rtfParam
);
2606 /* After \u we must skip number of character tokens set by \ucN */
2607 for (i
= 0; i
< info
->unicodeLength
; i
++)
2610 if (info
->rtfClass
!= rtfText
)
2612 ERR("The token behind \\u is not text, but (%d,%d,%d)\n",
2613 info
->rtfClass
, info
->rtfMajor
, info
->rtfMinor
);
2614 RTFUngetToken(info
);
2621 RTFFlushOutputBuffer(info
);
2622 ME_InsertEndRowFromCursor(info
->editor
, 0);
2627 RTFPutUnicodeChar (info
, '\r');
2628 if (info
->editor
->bEmulateVersion10
) RTFPutUnicodeChar (info
, '\n');
2631 RTFPutUnicodeChar (info
, 0x00A0);
2634 RTFPutUnicodeChar (info
, '\t');
2636 case rtfNoBrkHyphen
:
2637 RTFPutUnicodeChar (info
, 0x2011);
2640 RTFPutUnicodeChar (info
, 0x2022);
2643 RTFPutUnicodeChar (info
, 0x2014);
2646 RTFPutUnicodeChar (info
, 0x2013);
2649 RTFPutUnicodeChar (info
, 0x2018);
2652 RTFPutUnicodeChar (info
, 0x2019);
2655 RTFPutUnicodeChar (info
, 0x201C);
2658 RTFPutUnicodeChar (info
, 0x201D);
2665 RTFFlushUnicodeOutputBuffer(RTF_Info
*info
)
2667 if (info
->dwOutputCount
)
2669 ME_InsertTextFromCursor(info
->editor
, 0, info
->OutputBuffer
,
2670 info
->dwOutputCount
, info
->style
);
2671 info
->dwOutputCount
= 0;
2677 RTFPutUnicodeString(RTF_Info
*info
, const WCHAR
*string
, int length
)
2679 if (info
->dwCPOutputCount
)
2680 RTFFlushCPOutputBuffer(info
);
2683 int fit
= min(length
, sizeof(info
->OutputBuffer
) / sizeof(WCHAR
) - info
->dwOutputCount
);
2685 memmove(info
->OutputBuffer
+ info
->dwOutputCount
, string
, fit
* sizeof(WCHAR
));
2686 info
->dwOutputCount
+= fit
;
2689 if (sizeof(info
->OutputBuffer
) / sizeof(WCHAR
) == info
->dwOutputCount
)
2690 RTFFlushUnicodeOutputBuffer(info
);
2695 RTFFlushCPOutputBuffer(RTF_Info
*info
)
2697 int bufferMax
= info
->dwCPOutputCount
* 2 * sizeof(WCHAR
);
2698 WCHAR
*buffer
= heap_alloc(bufferMax
);
2701 length
= MultiByteToWideChar(info
->codePage
, 0, info
->cpOutputBuffer
,
2702 info
->dwCPOutputCount
, buffer
, bufferMax
/sizeof(WCHAR
));
2703 info
->dwCPOutputCount
= 0;
2705 RTFPutUnicodeString(info
, buffer
, length
);
2706 heap_free((char *)buffer
);
2710 RTFFlushOutputBuffer(RTF_Info
*info
)
2712 if (info
->dwCPOutputCount
)
2713 RTFFlushCPOutputBuffer(info
);
2714 RTFFlushUnicodeOutputBuffer(info
);
2718 RTFPutUnicodeChar(RTF_Info
*info
, int c
)
2720 if (info
->dwCPOutputCount
)
2721 RTFFlushCPOutputBuffer(info
);
2722 if (info
->dwOutputCount
* sizeof(WCHAR
) >= ( sizeof info
->OutputBuffer
- 1 ) )
2723 RTFFlushUnicodeOutputBuffer( info
);
2724 info
->OutputBuffer
[info
->dwOutputCount
++] = c
;
2728 RTFPutCodePageChar(RTF_Info
*info
, int c
)
2730 /* Use dynamic buffer here because it's the best way to handle
2731 * MBCS codepages without having to worry about partial chars */
2732 if (info
->dwCPOutputCount
>= info
->dwMaxCPOutputCount
)
2734 info
->dwMaxCPOutputCount
*= 2;
2735 info
->cpOutputBuffer
= heap_realloc(info
->cpOutputBuffer
, info
->dwMaxCPOutputCount
);
2737 info
->cpOutputBuffer
[info
->dwCPOutputCount
++] = c
;