ReactOS  r75400
reader.c
Go to the documentation of this file.
1 /*
2  * WINE RTF file reader
3  *
4  * Portions Copyright 2004 Mike McCormack for CodeWeavers
5  * Portions Copyright 2006 by Phil Krylov
6  *
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.
11  *
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.
16  *
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
20  */
21 
22 /*
23  * Derived from RTF Tools by Paul DuBois (dubois@primate.wisc.edu)
24  * Homepage: http://www.snake.net/software/RTF/
25  * Original license follows:
26  */
27 
28 /*
29  * reader.c - RTF file reader. Release 1.10.
30  *
31  * ....
32  *
33  * Author: Paul DuBois dubois@primate.wisc.edu
34  *
35  * This software may be redistributed without restriction and used for
36  * any purpose whatsoever.
37  */
38 
39 #include "editor.h"
40 #include "rtf.h"
41 
43 
44 static int _RTFGetChar(RTF_Info *);
45 static void _RTFGetToken (RTF_Info *);
46 static void _RTFGetToken2 (RTF_Info *);
47 static int GetChar (RTF_Info *);
48 static void ReadFontTbl (RTF_Info *);
49 static void ReadColorTbl (RTF_Info *);
50 static void ReadStyleSheet (RTF_Info *);
51 static void ReadInfoGroup (RTF_Info *);
52 static void ReadPictGroup (RTF_Info *);
53 static void ReadObjGroup (RTF_Info *);
54 static void Lookup (RTF_Info *, char *);
55 static int Hash (const char *);
56 
57 static void CharAttr(RTF_Info *info);
58 static void CharSet(RTF_Info *info);
59 static void DocAttr(RTF_Info *info);
60 
62 static void RTFPutCodePageChar(RTF_Info *info, int c);
63 
64 /* ---------------------------------------------------------------------- */
65 
66 
67 /*
68  * Saves a string on the heap and returns a pointer to it.
69  */
70 static inline char *RTFStrSave(const char *s)
71 {
72  char *p;
73 
74  p = heap_alloc (lstrlenA(s) + 1);
75  if (p == NULL)
76  return NULL;
77  return lstrcpyA (p, s);
78 }
79 
80 
81 /* ---------------------------------------------------------------------- */
82 
83 
85 {
86  int ch;
87  ME_InStream *stream = info->stream;
88 
89  if (stream->dwSize <= stream->dwUsed)
90  {
91  ME_StreamInFill(stream);
92  /* if error, it's EOF */
93  if (stream->editstream->dwError)
94  return EOF;
95  /* if no bytes read, it's EOF */
96  if (stream->dwSize == 0)
97  return EOF;
98  }
99  ch = (unsigned char)stream->buffer[stream->dwUsed++];
100  if (!ch)
101  return EOF;
102  return ch;
103 }
104 
106 {
107  info->stream = stream;
108 }
109 
110 static void
112 {
113  RTFColor *cp;
114  RTFFont *fp;
115  RTFStyle *sp;
116  RTFStyleElt *eltList, *ep;
117 
118  while (info->fontList)
119  {
120  fp = info->fontList->rtfNextFont;
121  heap_free (info->fontList->rtfFName);
122  heap_free (info->fontList);
123  info->fontList = fp;
124  }
125  while (info->colorList)
126  {
127  cp = info->colorList->rtfNextColor;
128  heap_free (info->colorList);
129  info->colorList = cp;
130  }
131  while (info->styleList)
132  {
133  sp = info->styleList->rtfNextStyle;
134  eltList = info->styleList->rtfSSEList;
135  while (eltList)
136  {
137  ep = eltList->rtfNextSE;
138  heap_free (eltList->rtfSEText);
139  heap_free (eltList);
140  eltList = ep;
141  }
142  heap_free (info->styleList->rtfSName);
143  heap_free (info->styleList);
144  info->styleList = sp;
145  }
146 }
147 
148 
149 void
151 {
152  if (info->rtfTextBuf)
153  {
154  heap_free(info->rtfTextBuf);
155  heap_free(info->pushedTextBuf);
156  }
157  RTFDestroyAttrs(info);
158  heap_free(info->cpOutputBuffer);
159  while (info->tableDef)
160  {
161  RTFTable *tableDef = info->tableDef;
162  info->tableDef = tableDef->parent;
163  heap_free(tableDef);
164  }
165 }
166 
167 
168 
169 /* ---------------------------------------------------------------------- */
170 
171 /*
172  * Callback table manipulation routines
173  */
174 
175 
176 /*
177  * Install or return a writer callback for a token class
178  */
179 
181 {
182  if (class >= 0 && class < rtfMaxClass)
183  info->ccb[class] = callback;
184 }
185 
186 
187 static RTFFuncPtr RTFGetClassCallback(const RTF_Info *info, int class)
188 {
189  if (class >= 0 && class < rtfMaxClass)
190  return info->ccb[class];
191  return NULL;
192 }
193 
194 
195 /*
196  * Initialize the reader. This may be called multiple times,
197  * to read multiple files. The only thing not reset is the input
198  * stream; that must be done with RTFSetStream().
199  */
200 
202 {
203  int i;
204 
205  if (info->rtfTextBuf == NULL) /* initialize the text buffers */
206  {
207  info->rtfTextBuf = heap_alloc (rtfBufSiz);
209  if (info->rtfTextBuf == NULL || info->pushedTextBuf == NULL) {
210  ERR ("Cannot allocate text buffers.\n");
211  return;
212  }
213  info->rtfTextBuf[0] = info->pushedTextBuf[0] = '\0';
214  }
215 
216  for (i = 0; i < rtfMaxClass; i++)
217  RTFSetClassCallback (info, i, NULL);
218  for (i = 0; i < rtfMaxDestination; i++)
219  RTFSetDestinationCallback (info, i, NULL);
220 
221  /* install built-in destination readers */
228 
229 
230  RTFSetReadHook (info, NULL);
231 
232  /* dump old lists if necessary */
233 
234  RTFDestroyAttrs(info);
235 
236  info->ansiCodePage = 1252; /* Latin-1; actually unused */
237  info->unicodeLength = 1; /* \uc1 is the default */
238  info->codePage = info->ansiCodePage;
239  info->defFont = 0;
240 
241  info->rtfClass = -1;
242  info->pushedClass = -1;
243  info->pushedChar = EOF;
244 
245  info->rtfLineNum = 0;
246  info->rtfLinePos = 0;
247  info->prevChar = EOF;
248  info->bumpLine = FALSE;
249 
250  info->dwCPOutputCount = 0;
251  if (!info->cpOutputBuffer)
252  {
253  info->dwMaxCPOutputCount = 0x1000;
255  }
256 
257  info->tableDef = NULL;
258  info->nestingLevel = 0;
259  info->canInheritInTbl = FALSE;
260  info->borderType = 0;
261 
262  memset(&info->fmt, 0, sizeof(info->fmt));
263  info->fmt.cbSize = sizeof(info->fmt);
264 }
265 
266 /*
267  * Install or return a writer callback for a destination type
268  */
269 
271 {
272  if (dest >= 0 && dest < rtfMaxDestination)
273  info->dcb[dest] = callback;
274 }
275 
276 
278 {
279  if (dest >= 0 && dest < rtfMaxDestination)
280  return info->dcb[dest];
281  return NULL;
282 }
283 
284 
285 /* ---------------------------------------------------------------------- */
286 
287 /*
288  * Token reading routines
289  */
290 
291 
292 /*
293  * Read the input stream, invoking the writer's callbacks
294  * where appropriate.
295  */
296 
298 {
299  while (RTFGetToken (info) != rtfEOF)
300  RTFRouteToken (info);
301 }
302 
303 
304 /*
305  * Route a token. If it's a destination for which a reader is
306  * installed, process the destination internally, otherwise
307  * pass the token to the writer's class callback.
308  */
309 
311 {
312  RTFFuncPtr p;
313 
314  if (info->rtfClass < 0 || info->rtfClass >= rtfMaxClass) /* watchdog */
315  {
316  ERR( "Unknown class %d: %s (reader malfunction)\n",
317  info->rtfClass, info->rtfTextBuf);
318  }
319  if (RTFCheckCM (info, rtfControl, rtfDestination))
320  {
321  /* invoke destination-specific callback if there is one */
322  p = RTFGetDestinationCallback (info, info->rtfMinor);
323  if (p != NULL)
324  {
325  (*p) (info);
326  return;
327  }
328  }
329  /* invoke class callback if there is one */
330  p = RTFGetClassCallback (info, info->rtfClass);
331  if (p != NULL)
332  (*p) (info);
333 }
334 
335 
336 /*
337  * Skip to the end of the current group. When this returns,
338  * writers that maintain a state stack may want to call their
339  * state unstacker; global vars will still be set to the group's
340  * closing brace.
341  */
342 
344 {
345  int level = 1;
346 
347  while (RTFGetToken (info) != rtfEOF)
348  {
349  if (info->rtfClass == rtfGroup)
350  {
351  if (info->rtfMajor == rtfBeginGroup)
352  ++level;
353  else if (info->rtfMajor == rtfEndGroup)
354  {
355  if (--level < 1)
356  break; /* end of initial group */
357  }
358  }
359  }
360 }
361 
362 /*
363  * Do no special processing on the group.
364  *
365  * This acts as a placeholder for a callback in order to indicate that it
366  * shouldn't be ignored. Instead it will fallback on the loop in RTFRead.
367  */
369 {
370 }
371 
372 
373 /*
374  * Install or return a token reader hook.
375  */
376 
378 {
379  info->readHook = f;
380 }
381 
382 
384 {
385  return (info->readHook);
386 }
387 
388 
389 /*
390  * Read one token. Call the read hook if there is one. The
391  * token class is the return value. Returns rtfEOF when there
392  * are no more tokens.
393  */
394 
396 {
397  RTFFuncPtr p;
398 
399  /* don't try to return anything once EOF is reached */
400  if (info->rtfClass == rtfEOF) {
401  return rtfEOF;
402  }
403 
404  for (;;)
405  {
406  _RTFGetToken (info);
407  p = RTFGetReadHook (info);
408  if (p != NULL)
409  (*p) (info); /* give read hook a look at token */
410 
411  /* Silently discard newlines, carriage returns, nulls. */
412  if (!(info->rtfClass == rtfText && info->rtfFormat != SF_TEXT
413  && (info->rtfMajor == '\r' || info->rtfMajor == '\n' || info->rtfMajor == '\0')))
414  break;
415  }
416  return (info->rtfClass);
417 }
418 
419 
421 {
422  if (info->pushedClass >= 0) /* there's already an ungotten token */
423  ERR ("cannot unget two tokens\n");
424  if (info->rtfClass < 0)
425  ERR ("no token to unget\n");
426  info->pushedClass = info->rtfClass;
427  info->pushedMajor = info->rtfMajor;
428  info->pushedMinor = info->rtfMinor;
429  info->pushedParam = info->rtfParam;
430  lstrcpyA (info->pushedTextBuf, info->rtfTextBuf);
431  /* The read hook decrements stackTop on rtfEndGroup, so
432  * increment the value to compensate for it being decremented
433  * twice due to the RTFUngetToken. */
434  if(RTFCheckCM (info, rtfGroup, rtfEndGroup))
435  {
436  info->stack[info->stackTop].style = info->style;
437  ME_AddRefStyle(info->style);
438  info->stackTop++;
439  }
440 }
441 
442 
444 {
445  if (info->rtfFormat == SF_TEXT)
446  {
447  info->rtfMajor = GetChar (info);
448  info->rtfMinor = 0;
449  info->rtfParam = rtfNoParam;
450  info->rtfTextBuf[info->rtfTextLen = 0] = '\0';
451  if (info->rtfMajor == EOF)
452  info->rtfClass = rtfEOF;
453  else
454  info->rtfClass = rtfText;
455  return;
456  }
457 
458  /* first check for pushed token from RTFUngetToken() */
459 
460  if (info->pushedClass >= 0)
461  {
462  info->rtfClass = info->pushedClass;
463  info->rtfMajor = info->pushedMajor;
464  info->rtfMinor = info->pushedMinor;
465  info->rtfParam = info->pushedParam;
466  lstrcpyA (info->rtfTextBuf, info->pushedTextBuf);
467  info->rtfTextLen = lstrlenA(info->rtfTextBuf);
468  info->pushedClass = -1;
469  return;
470  }
471 
472  /*
473  * Beyond this point, no token is ever seen twice, which is
474  * important, e.g., for making sure no "}" pops the font stack twice.
475  */
476 
477  _RTFGetToken2 (info);
478 }
479 
480 
481 int
483 {
484  switch (charset)
485  {
486  case ANSI_CHARSET:
487  return 1252;
488  case DEFAULT_CHARSET:
489  return CP_ACP;
490  case SYMBOL_CHARSET:
491  return CP_SYMBOL;
492  case MAC_CHARSET:
493  return CP_MACCP;
494  case SHIFTJIS_CHARSET:
495  return 932;
496  case HANGEUL_CHARSET:
497  return 949;
498  case JOHAB_CHARSET:
499  return 1361;
500  case GB2312_CHARSET:
501  return 936;
502  case CHINESEBIG5_CHARSET:
503  return 950;
504  case GREEK_CHARSET:
505  return 1253;
506  case TURKISH_CHARSET:
507  return 1254;
508  case VIETNAMESE_CHARSET:
509  return 1258;
510  case HEBREW_CHARSET:
511  return 1255;
512  case ARABIC_CHARSET:
513  return 1256;
514  case BALTIC_CHARSET:
515  return 1257;
516  case RUSSIAN_CHARSET:
517  return 1251;
518  case THAI_CHARSET:
519  return 874;
520  case EASTEUROPE_CHARSET:
521  return 1250;
522  case OEM_CHARSET:
523  return CP_OEMCP;
524  default:
525  {
526  CHARSETINFO csi;
527  DWORD n = charset;
528 
529  /* FIXME: TranslateCharsetInfo does not work as good as it
530  * should, so let's use it only when all else fails */
531  if (!TranslateCharsetInfo(&n, &csi, TCI_SRCCHARSET))
532  ERR("unknown charset %d\n", charset);
533  else
534  return csi.ciACP;
535  }
536  }
537  return 0;
538 }
539 
540 
541 /* this shouldn't be called anywhere but from _RTFGetToken() */
542 
544 {
545  int sign;
546  int c;
547 
548  /* initialize token vars */
549 
550  info->rtfClass = rtfUnknown;
551  info->rtfParam = rtfNoParam;
552  info->rtfTextBuf[info->rtfTextLen = 0] = '\0';
553 
554  /* get first character, which may be a pushback from previous token */
555 
556  if (info->pushedChar != EOF)
557  {
558  c = info->pushedChar;
559  info->rtfTextBuf[info->rtfTextLen++] = c;
560  info->rtfTextBuf[info->rtfTextLen] = '\0';
561  info->pushedChar = EOF;
562  }
563  else if ((c = GetChar (info)) == EOF)
564  {
565  info->rtfClass = rtfEOF;
566  return;
567  }
568 
569  if (c == '{')
570  {
571  info->rtfClass = rtfGroup;
572  info->rtfMajor = rtfBeginGroup;
573  return;
574  }
575  if (c == '}')
576  {
577  info->rtfClass = rtfGroup;
578  info->rtfMajor = rtfEndGroup;
579  return;
580  }
581  if (c != '\\')
582  {
583  /*
584  * Two possibilities here:
585  * 1) ASCII 9, effectively like \tab control symbol
586  * 2) literal text char
587  */
588  if (c == '\t') /* ASCII 9 */
589  {
590  info->rtfClass = rtfControl;
591  info->rtfMajor = rtfSpecialChar;
592  info->rtfMinor = rtfTab;
593  }
594  else
595  {
596  info->rtfClass = rtfText;
597  info->rtfMajor = c;
598  }
599  return;
600  }
601  if ((c = GetChar (info)) == EOF)
602  {
603  /* early eof, whoops (class is rtfUnknown) */
604  return;
605  }
606  if (!isalpha (c))
607  {
608  /*
609  * Three possibilities here:
610  * 1) hex encoded text char, e.g., \'d5, \'d3
611  * 2) special escaped text char, e.g., \{, \}
612  * 3) control symbol, e.g., \_, \-, \|, <10>
613  */
614  if (c == '\'') /* hex char */
615  {
616  int c2;
617 
618  if ((c = GetChar (info)) != EOF && (c2 = GetChar (info)) != EOF
619  && isxdigit(c) && isxdigit(c2))
620  {
621  info->rtfClass = rtfText;
622  info->rtfMajor = RTFCharToHex (c) * 16 + RTFCharToHex (c2);
623  return;
624  }
625  /* early eof, whoops */
626  info->rtfClass = rtfEOF;
627  info->stream->editstream->dwError = -14;
628  return;
629  }
630 
631  /* escaped char */
632  /*if (index (":{}\\", c) != NULL)*/ /* escaped char */
633  if (c == ':' || c == '{' || c == '}' || c == '\\')
634  {
635  info->rtfClass = rtfText;
636  info->rtfMajor = c;
637  return;
638  }
639 
640  /* control symbol */
641  Lookup (info, info->rtfTextBuf); /* sets class, major, minor */
642  return;
643  }
644  /* control word */
645  while (isalpha (c))
646  {
647  if ((c = GetChar (info)) == EOF)
648  break;
649  }
650 
651  /*
652  * At this point, the control word is all collected, so the
653  * major/minor numbers are determined before the parameter
654  * (if any) is scanned. There will be one too many characters
655  * in the buffer, though, so fix up before and restore after
656  * looking up.
657  */
658 
659  if (c != EOF)
660  info->rtfTextBuf[info->rtfTextLen-1] = '\0';
661  Lookup (info, info->rtfTextBuf); /* sets class, major, minor */
662  if (c != EOF)
663  info->rtfTextBuf[info->rtfTextLen-1] = c;
664 
665  /*
666  * Should be looking at first digit of parameter if there
667  * is one, unless it's negative. In that case, next char
668  * is '-', so need to gobble next char, and remember sign.
669  */
670 
671  sign = 1;
672  if (c == '-')
673  {
674  sign = -1;
675  c = GetChar (info);
676  }
677  if (c != EOF && isdigit (c))
678  {
679  info->rtfParam = 0;
680  while (isdigit (c)) /* gobble parameter */
681  {
682  info->rtfParam = info->rtfParam * 10 + c - '0';
683  if ((c = GetChar (info)) == EOF)
684  break;
685  }
686  info->rtfParam *= sign;
687  }
688  /*
689  * If control symbol delimiter was a blank, gobble it.
690  * Otherwise the character is first char of next token, so
691  * push it back for next call. In either case, delete the
692  * delimiter from the token buffer.
693  */
694  if (c != EOF)
695  {
696  if (c != ' ')
697  info->pushedChar = c;
698  info->rtfTextBuf[--info->rtfTextLen] = '\0';
699  }
700 }
701 
702 
703 /*
704  * Read the next character from the input. This handles setting the
705  * current line and position-within-line variables. Those variables are
706  * set correctly whether lines end with CR, LF, or CRLF (the last being
707  * the tricky case).
708  *
709  * bumpLine indicates whether the line number should be incremented on
710  * the *next* input character.
711  */
712 
713 
714 static int GetChar(RTF_Info *info)
715 {
716  int c;
717  BOOL oldBumpLine;
718 
719  if ((c = _RTFGetChar(info)) != EOF)
720  {
721  info->rtfTextBuf[info->rtfTextLen++] = c;
722  info->rtfTextBuf[info->rtfTextLen] = '\0';
723  }
724  if (info->prevChar == EOF)
725  info->bumpLine = TRUE;
726  oldBumpLine = info->bumpLine; /* TRUE if prev char was line ending */
727  info->bumpLine = FALSE;
728  if (c == '\r')
729  info->bumpLine = TRUE;
730  else if (c == '\n')
731  {
732  info->bumpLine = TRUE;
733  if (info->prevChar == '\r') /* oops, previous \r wasn't */
734  oldBumpLine = FALSE; /* really a line ending */
735  }
736  ++info->rtfLinePos;
737  if (oldBumpLine) /* were we supposed to increment the */
738  { /* line count on this char? */
739  ++info->rtfLineNum;
740  info->rtfLinePos = 1;
741  }
742  info->prevChar = c;
743  return (c);
744 }
745 
746 
747 /* ---------------------------------------------------------------------- */
748 
749 /*
750  * Special destination readers. They gobble the destination so the
751  * writer doesn't have to deal with them. That's wrong for any
752  * translator that wants to process any of these itself. In that
753  * case, these readers should be overridden by installing a different
754  * destination callback.
755  *
756  * NOTE: The last token read by each of these reader will be the
757  * destination's terminating '}', which will then be the current token.
758  * That '}' token is passed to RTFRouteToken() - the writer has already
759  * seen the '{' that began the destination group, and may have pushed a
760  * state; it also needs to know at the end of the group that a state
761  * should be popped.
762  *
763  * It's important that rtf.h and the control token lookup table list
764  * as many symbols as possible, because these destination readers
765  * unfortunately make strict assumptions about the input they expect,
766  * and a token of class rtfUnknown will throw them off easily.
767  */
768 
769 
770 /*
771  * Read { \fonttbl ... } destination. Old font tables don't have
772  * braces around each table entry; try to adjust for that.
773  */
774 
775 static void ReadFontTbl(RTF_Info *info)
776 {
777  RTFFont *fp = NULL;
778  char buf[rtfBufSiz], *bp;
779  int old = -1;
780 
781  for (;;)
782  {
783  RTFGetToken (info);
784  if (info->rtfClass == rtfEOF)
785  break;
786  if (RTFCheckCM (info, rtfGroup, rtfEndGroup))
787  break;
788  if (old < 0) /* first entry - determine tbl type */
789  {
791  old = 1; /* no brace */
792  else if (RTFCheckCM (info, rtfGroup, rtfBeginGroup))
793  old = 0; /* brace */
794  else /* can't tell! */
795  ERR ("cannot determine format\n");
796  }
797  if (old == 0) /* need to find "{" here */
798  {
799  if (!RTFCheckCM (info, rtfGroup, rtfBeginGroup))
800  ERR ("missing \"{\"\n");
801  RTFGetToken (info); /* yes, skip to next token */
802  if (info->rtfClass == rtfEOF)
803  break;
804  }
805  fp = New (RTFFont);
806  if (fp == NULL) {
807  ERR ("cannot allocate font entry\n");
808  break;
809  }
810 
811  fp->rtfNextFont = info->fontList;
812  info->fontList = fp;
813 
814  fp->rtfFName = NULL;
815  fp->rtfFAltName = NULL;
816  fp->rtfFNum = -1;
817  fp->rtfFFamily = FF_DONTCARE;
818  fp->rtfFCharSet = DEFAULT_CHARSET; /* 1 */
819  fp->rtfFPitch = DEFAULT_PITCH;
820  fp->rtfFType = 0;
821  fp->rtfFCodePage = CP_ACP;
822 
823  while (info->rtfClass != rtfEOF
824  && !RTFCheckCM (info, rtfText, ';')
825  && !RTFCheckCM (info, rtfGroup, rtfEndGroup))
826  {
827  if (info->rtfClass == rtfControl)
828  {
829  switch (info->rtfMajor)
830  {
831  default:
832  /* ignore token but announce it */
833  WARN ("unknown token \"%s\"\n",
834  info->rtfTextBuf);
835  break;
836  case rtfFontFamily:
837  fp->rtfFFamily = info->rtfMinor;
838  break;
839  case rtfCharAttr:
840  switch (info->rtfMinor)
841  {
842  default:
843  break; /* ignore unknown? */
844  case rtfFontNum:
845  fp->rtfFNum = info->rtfParam;
846  break;
847  }
848  break;
849  case rtfFontAttr:
850  switch (info->rtfMinor)
851  {
852  default:
853  break; /* ignore unknown? */
854  case rtfFontCharSet:
855  fp->rtfFCharSet = info->rtfParam;
856  if (!fp->rtfFCodePage)
857  fp->rtfFCodePage = RTFCharSetToCodePage(info, info->rtfParam);
858  break;
859  case rtfFontPitch:
860  fp->rtfFPitch = info->rtfParam;
861  break;
862  case rtfFontCodePage:
863  fp->rtfFCodePage = info->rtfParam;
864  break;
865  case rtfFTypeNil:
866  case rtfFTypeTrueType:
867  fp->rtfFType = info->rtfParam;
868  break;
869  }
870  break;
871  }
872  }
873  else if (RTFCheckCM (info, rtfGroup, rtfBeginGroup)) /* dest */
874  {
875  RTFSkipGroup (info); /* ignore for now */
876  }
877  else if (info->rtfClass == rtfText) /* font name */
878  {
879  bp = buf;
880  while (info->rtfClass == rtfText
881  && !RTFCheckCM (info, rtfText, ';'))
882  {
883  *bp++ = info->rtfMajor;
884  RTFGetToken (info);
885  }
886 
887  /* FIX: in some cases the <fontinfo> isn't finished with a semi-column */
888  if(RTFCheckCM (info, rtfGroup, rtfEndGroup))
889  {
890  RTFUngetToken (info);
891  }
892  *bp = '\0';
893  fp->rtfFName = RTFStrSave (buf);
894  if (fp->rtfFName == NULL)
895  ERR ("cannot allocate font name\n");
896  /* already have next token; don't read one */
897  /* at bottom of loop */
898  continue;
899  }
900  else
901  {
902  /* ignore token but announce it */
903  WARN ("unknown token \"%s\"\n", info->rtfTextBuf);
904  }
905  RTFGetToken (info);
906  if (info->rtfClass == rtfEOF)
907  break;
908  }
909  if (info->rtfClass == rtfEOF)
910  break;
911  if (old == 0) /* need to see "}" here */
912  {
913  RTFGetToken (info);
914  if (!RTFCheckCM (info, rtfGroup, rtfEndGroup))
915  ERR ("missing \"}\"\n");
916  if (info->rtfClass == rtfEOF)
917  break;
918  }
919 
920  /* Apply the real properties of the default font */
921  if (fp->rtfFNum == info->defFont)
922  {
923  if (info->ansiCodePage != CP_UTF8)
924  info->codePage = fp->rtfFCodePage;
925  TRACE("default font codepage %d\n", info->codePage);
926  }
927  }
928  if (!fp || (fp->rtfFNum == -1))
929  ERR("missing font number\n");
930 /*
931  * Could check other pieces of structure here, too, I suppose.
932  */
933  RTFRouteToken (info); /* feed "}" back to router */
934 
935  /* Set default font */
936  info->rtfClass = rtfControl;
937  info->rtfMajor = rtfCharAttr;
938  info->rtfMinor = rtfFontNum;
939  info->rtfParam = info->defFont;
940  lstrcpyA(info->rtfTextBuf, "f");
941  RTFUngetToken(info);
942 }
943 
944 
945 /*
946  * The color table entries have color values of -1 if
947  * the default color should be used for the entry (only
948  * a semi-colon is given in the definition, no color values).
949  * There will be a problem if a partial entry (1 or 2 but
950  * not 3 color values) is given. The possibility is ignored
951  * here.
952  */
953 
955 {
956  RTFColor *cp;
957  int cnum = 0;
958  int group_level = 1;
959 
960  for (;;)
961  {
962  RTFGetToken (info);
963  if (info->rtfClass == rtfEOF)
964  break;
965  if (RTFCheckCM (info, rtfGroup, rtfEndGroup))
966  {
967  group_level--;
968  if (!group_level)
969  break;
970  continue;
971  }
972  else if (RTFCheckCM(info, rtfGroup, rtfBeginGroup))
973  {
974  group_level++;
975  continue;
976  }
977 
978  cp = New (RTFColor);
979  if (cp == NULL) {
980  ERR ("cannot allocate color entry\n");
981  break;
982  }
983  cp->rtfCNum = cnum++;
984  cp->rtfNextColor = info->colorList;
985  info->colorList = cp;
986  if (!RTFCheckCM (info, rtfControl, rtfColorName))
987  cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = -1;
988  else {
989  cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = 0;
990  do {
991  switch (info->rtfMinor)
992  {
993  case rtfRed: cp->rtfCRed = info->rtfParam & 0xFF; break;
994  case rtfGreen: cp->rtfCGreen = info->rtfParam & 0xFF; break;
995  case rtfBlue: cp->rtfCBlue = info->rtfParam & 0xFF; break;
996  }
997  RTFGetToken (info);
998  } while (RTFCheckCM (info, rtfControl, rtfColorName));
999  }
1000  if (info->rtfClass == rtfEOF)
1001  break;
1002  if (!RTFCheckCM (info, rtfText, ';'))
1003  ERR ("malformed entry\n");
1004  }
1005  RTFRouteToken (info); /* feed "}" back to router */
1006 }
1007 
1008 
1009 /*
1010  * The "Normal" style definition doesn't contain any style number,
1011  * all others do. Normal style is given style rtfNormalStyleNum.
1012  */
1013 
1015 {
1016  RTFStyle *sp;
1017  RTFStyleElt *sep, *sepLast;
1018  char buf[rtfBufSiz], *bp;
1019  int real_style;
1020 
1021  for (;;)
1022  {
1023  RTFGetToken (info);
1024  if (info->rtfClass == rtfEOF)
1025  break;
1026  if (RTFCheckCM (info, rtfGroup, rtfEndGroup))
1027  break;
1028  sp = New (RTFStyle);
1029  if (sp == NULL) {
1030  ERR ("cannot allocate stylesheet entry\n");
1031  break;
1032  }
1033  sp->rtfSName = NULL;
1034  sp->rtfSNum = -1;
1035  sp->rtfSType = rtfParStyle;
1036  sp->rtfSAdditive = 0;
1037  sp->rtfSBasedOn = rtfNoStyleNum;
1038  sp->rtfSNextPar = -1;
1039  sp->rtfSSEList = sepLast = NULL;
1040  sp->rtfNextStyle = info->styleList;
1041  sp->rtfExpanding = 0;
1042  info->styleList = sp;
1043  if (!RTFCheckCM (info, rtfGroup, rtfBeginGroup))
1044  ERR ("missing \"{\"\n");
1045  real_style = TRUE;
1046  for (;;)
1047  {
1048  RTFGetToken (info);
1049  if (info->rtfClass == rtfEOF
1050  || RTFCheckCM (info, rtfText, ';'))
1051  break;
1052  if (info->rtfClass == rtfControl)
1053  {
1054  if (RTFCheckMM (info, rtfSpecialChar, rtfOptDest)) {
1055  RTFGetToken(info);
1056  ERR("skipping optional destination\n");
1057  RTFSkipGroup(info);
1058  info->rtfClass = rtfGroup;
1059  info->rtfMajor = rtfEndGroup;
1060  real_style = FALSE;
1061  break; /* ignore "\*" */
1062  }
1063  if (RTFCheckMM (info, rtfParAttr, rtfStyleNum))
1064  {
1065  sp->rtfSNum = info->rtfParam;
1066  sp->rtfSType = rtfParStyle;
1067  continue;
1068  }
1069  if (RTFCheckMM (info, rtfCharAttr, rtfCharStyleNum))
1070  {
1071  sp->rtfSNum = info->rtfParam;
1072  sp->rtfSType = rtfCharStyle;
1073  continue;
1074  }
1075  if (RTFCheckMM (info, rtfSectAttr, rtfSectStyleNum))
1076  {
1077  sp->rtfSNum = info->rtfParam;
1078  sp->rtfSType = rtfSectStyle;
1079  continue;
1080  }
1081  if (RTFCheckMM (info, rtfStyleAttr, rtfBasedOn))
1082  {
1083  sp->rtfSBasedOn = info->rtfParam;
1084  continue;
1085  }
1086  if (RTFCheckMM (info, rtfStyleAttr, rtfAdditive))
1087  {
1088  sp->rtfSAdditive = 1;
1089  continue;
1090  }
1091  if (RTFCheckMM (info, rtfStyleAttr, rtfNext))
1092  {
1093  sp->rtfSNextPar = info->rtfParam;
1094  continue;
1095  }
1096  sep = New (RTFStyleElt);
1097  if (sep == NULL)
1098  {
1099  ERR ("cannot allocate style element\n");
1100  break;
1101  }
1102  sep->rtfSEClass = info->rtfClass;
1103  sep->rtfSEMajor = info->rtfMajor;
1104  sep->rtfSEMinor = info->rtfMinor;
1105  sep->rtfSEParam = info->rtfParam;
1106  sep->rtfSEText = RTFStrSave (info->rtfTextBuf);
1107  if (sep->rtfSEText == NULL)
1108  ERR ("cannot allocate style element text\n");
1109  if (sepLast == NULL)
1110  sp->rtfSSEList = sep; /* first element */
1111  else /* add to end */
1112  sepLast->rtfNextSE = sep;
1113  sep->rtfNextSE = NULL;
1114  sepLast = sep;
1115  }
1116  else if (RTFCheckCM (info, rtfGroup, rtfBeginGroup))
1117  {
1118  /*
1119  * This passes over "{\*\keycode ... }, among
1120  * other things. A temporary (perhaps) hack.
1121  */
1122  ERR("skipping begin\n");
1123  RTFSkipGroup (info);
1124  continue;
1125  }
1126  else if (info->rtfClass == rtfText) /* style name */
1127  {
1128  bp = buf;
1129  while (info->rtfClass == rtfText)
1130  {
1131  if (info->rtfMajor == ';')
1132  {
1133  /* put back for "for" loop */
1134  RTFUngetToken (info);
1135  break;
1136  }
1137  *bp++ = info->rtfMajor;
1138  RTFGetToken (info);
1139  }
1140  *bp = '\0';
1141  sp->rtfSName = RTFStrSave (buf);
1142  if (sp->rtfSName == NULL)
1143  ERR ("cannot allocate style name\n");
1144  }
1145  else /* unrecognized */
1146  {
1147  /* ignore token but announce it */
1148  WARN ("unknown token \"%s\"\n", info->rtfTextBuf);
1149  }
1150  }
1151  if (real_style) {
1152  RTFGetToken (info);
1153  if (!RTFCheckCM (info, rtfGroup, rtfEndGroup))
1154  ERR ("missing \"}\"\n");
1155  /*
1156  * Check over the style structure. A name is a must.
1157  * If no style number was specified, check whether it's the
1158  * Normal style (in which case it's given style number
1159  * rtfNormalStyleNum). Note that some "normal" style names
1160  * just begin with "Normal" and can have other stuff following,
1161  * e.g., "Normal,Times 10 point". Ugh.
1162  *
1163  * Some German RTF writers use "Standard" instead of "Normal".
1164  */
1165  if (sp->rtfSName == NULL)
1166  ERR ("missing style name\n");
1167  if (sp->rtfSNum < 0)
1168  {
1169  if (strncmp (buf, "Normal", 6) != 0
1170  && strncmp (buf, "Standard", 8) != 0)
1171  ERR ("missing style number\n");
1172  sp->rtfSNum = rtfNormalStyleNum;
1173  }
1174  if (sp->rtfSNextPar == -1) /* if \snext not given, */
1175  sp->rtfSNextPar = sp->rtfSNum; /* next is itself */
1176  }
1177  /* otherwise we're just dealing with fake end group from skipped group */
1178  }
1179  RTFRouteToken (info); /* feed "}" back to router */
1180 }
1181 
1182 
1184 {
1185  RTFSkipGroup (info);
1186  RTFRouteToken (info); /* feed "}" back to router */
1187 }
1188 
1189 
1191 {
1192  RTFSkipGroup (info);
1193  RTFRouteToken (info); /* feed "}" back to router */
1194 }
1195 
1196 
1198 {
1199  RTFSkipGroup (info);
1200  RTFRouteToken (info); /* feed "}" back to router */
1201 }
1202 
1203 
1204 /* ---------------------------------------------------------------------- */
1205 
1206 /*
1207  * Routines to return pieces of stylesheet, or font or color tables.
1208  * References to style 0 are mapped onto the Normal style.
1209  */
1210 
1212 {
1213  RTFFont *f;
1214 
1215  if (num == -1)
1216  return (info->fontList);
1217  for (f = info->fontList; f != NULL; f = f->rtfNextFont)
1218  {
1219  if (f->rtfFNum == num)
1220  break;
1221  }
1222  return (f); /* NULL if not found */
1223 }
1224 
1225 
1227 {
1228  RTFColor *c;
1229 
1230  if (num == -1)
1231  return (info->colorList);
1232  for (c = info->colorList; c != NULL; c = c->rtfNextColor)
1233  {
1234  if (c->rtfCNum == num)
1235  break;
1236  }
1237  return (c); /* NULL if not found */
1238 }
1239 
1240 
1241 /* ---------------------------------------------------------------------- */
1242 
1243 /*
1244  * Control symbol lookup routines
1245  */
1246 
1247 
1248 typedef struct RTFKey RTFKey;
1249 
1250 struct RTFKey
1251 {
1252  int rtfKMajor; /* major number */
1253  int rtfKMinor; /* minor number */
1254  const char *rtfKStr; /* symbol name */
1255  int rtfKHash; /* symbol name hash value */
1256 };
1257 
1258 /*
1259  * A minor number of -1 means the token has no minor number
1260  * (all valid minor numbers are >= 0).
1261  */
1262 
1263 static RTFKey rtfKey[] =
1264 {
1265  /*
1266  * Special characters
1267  */
1268 
1269  { rtfSpecialChar, rtfIIntVersion, "vern", 0 },
1270  { rtfSpecialChar, rtfICreateTime, "creatim", 0 },
1271  { rtfSpecialChar, rtfIRevisionTime, "revtim", 0 },
1272  { rtfSpecialChar, rtfIPrintTime, "printim", 0 },
1273  { rtfSpecialChar, rtfIBackupTime, "buptim", 0 },
1274  { rtfSpecialChar, rtfIEditTime, "edmins", 0 },
1275  { rtfSpecialChar, rtfIYear, "yr", 0 },
1276  { rtfSpecialChar, rtfIMonth, "mo", 0 },
1277  { rtfSpecialChar, rtfIDay, "dy", 0 },
1278  { rtfSpecialChar, rtfIHour, "hr", 0 },
1279  { rtfSpecialChar, rtfIMinute, "min", 0 },
1280  { rtfSpecialChar, rtfISecond, "sec", 0 },
1281  { rtfSpecialChar, rtfINPages, "nofpages", 0 },
1282  { rtfSpecialChar, rtfINWords, "nofwords", 0 },
1283  { rtfSpecialChar, rtfINChars, "nofchars", 0 },
1284  { rtfSpecialChar, rtfIIntID, "id", 0 },
1285 
1286  { rtfSpecialChar, rtfCurHeadDate, "chdate", 0 },
1287  { rtfSpecialChar, rtfCurHeadDateLong, "chdpl", 0 },
1288  { rtfSpecialChar, rtfCurHeadDateAbbrev, "chdpa", 0 },
1289  { rtfSpecialChar, rtfCurHeadTime, "chtime", 0 },
1290  { rtfSpecialChar, rtfCurHeadPage, "chpgn", 0 },
1291  { rtfSpecialChar, rtfSectNum, "sectnum", 0 },
1292  { rtfSpecialChar, rtfCurFNote, "chftn", 0 },
1293  { rtfSpecialChar, rtfCurAnnotRef, "chatn", 0 },
1294  { rtfSpecialChar, rtfFNoteSep, "chftnsep", 0 },
1295  { rtfSpecialChar, rtfFNoteCont, "chftnsepc", 0 },
1296  { rtfSpecialChar, rtfCell, "cell", 0 },
1297  { rtfSpecialChar, rtfRow, "row", 0 },
1298  { rtfSpecialChar, rtfPar, "par", 0 },
1299  /* newline and carriage return are synonyms for */
1300  /* \par when they are preceded by a \ character */
1301  { rtfSpecialChar, rtfPar, "\n", 0 },
1302  { rtfSpecialChar, rtfPar, "\r", 0 },
1303  { rtfSpecialChar, rtfSect, "sect", 0 },
1304  { rtfSpecialChar, rtfPage, "page", 0 },
1305  { rtfSpecialChar, rtfColumn, "column", 0 },
1306  { rtfSpecialChar, rtfLine, "line", 0 },
1307  { rtfSpecialChar, rtfSoftPage, "softpage", 0 },
1308  { rtfSpecialChar, rtfSoftColumn, "softcol", 0 },
1309  { rtfSpecialChar, rtfSoftLine, "softline", 0 },
1310  { rtfSpecialChar, rtfSoftLineHt, "softlheight", 0 },
1311  { rtfSpecialChar, rtfTab, "tab", 0 },
1312  { rtfSpecialChar, rtfEmDash, "emdash", 0 },
1313  { rtfSpecialChar, rtfEnDash, "endash", 0 },
1314  { rtfSpecialChar, rtfEmSpace, "emspace", 0 },
1315  { rtfSpecialChar, rtfEnSpace, "enspace", 0 },
1316  { rtfSpecialChar, rtfBullet, "bullet", 0 },
1317  { rtfSpecialChar, rtfLQuote, "lquote", 0 },
1318  { rtfSpecialChar, rtfRQuote, "rquote", 0 },
1319  { rtfSpecialChar, rtfLDblQuote, "ldblquote", 0 },
1320  { rtfSpecialChar, rtfRDblQuote, "rdblquote", 0 },
1321  { rtfSpecialChar, rtfFormula, "|", 0 },
1322  { rtfSpecialChar, rtfNoBrkSpace, "~", 0 },
1323  { rtfSpecialChar, rtfNoReqHyphen, "-", 0 },
1324  { rtfSpecialChar, rtfNoBrkHyphen, "_", 0 },
1325  { rtfSpecialChar, rtfOptDest, "*", 0 },
1326  { rtfSpecialChar, rtfLTRMark, "ltrmark", 0 },
1327  { rtfSpecialChar, rtfRTLMark, "rtlmark", 0 },
1328  { rtfSpecialChar, rtfNoWidthJoiner, "zwj", 0 },
1329  { rtfSpecialChar, rtfNoWidthNonJoiner, "zwnj", 0 },
1330  /* is this valid? */
1331  { rtfSpecialChar, rtfCurHeadPict, "chpict", 0 },
1332  { rtfSpecialChar, rtfUnicode, "u", 0 },
1333  { rtfSpecialChar, rtfNestCell, "nestcell", 0 },
1334  { rtfSpecialChar, rtfNestRow, "nestrow", 0 },
1335 
1336  /*
1337  * Character formatting attributes
1338  */
1339 
1340  { rtfCharAttr, rtfPlain, "plain", 0 },
1341  { rtfCharAttr, rtfBold, "b", 0 },
1342  { rtfCharAttr, rtfAllCaps, "caps", 0 },
1343  { rtfCharAttr, rtfDeleted, "deleted", 0 },
1344  { rtfCharAttr, rtfSubScript, "dn", 0 },
1345  { rtfCharAttr, rtfSubScrShrink, "sub", 0 },
1346  { rtfCharAttr, rtfNoSuperSub, "nosupersub", 0 },
1347  { rtfCharAttr, rtfExpand, "expnd", 0 },
1348  { rtfCharAttr, rtfExpandTwips, "expndtw", 0 },
1349  { rtfCharAttr, rtfKerning, "kerning", 0 },
1350  { rtfCharAttr, rtfFontNum, "f", 0 },
1351  { rtfCharAttr, rtfFontSize, "fs", 0 },
1352  { rtfCharAttr, rtfItalic, "i", 0 },
1353  { rtfCharAttr, rtfOutline, "outl", 0 },
1354  { rtfCharAttr, rtfRevised, "revised", 0 },
1355  { rtfCharAttr, rtfRevAuthor, "revauth", 0 },
1356  { rtfCharAttr, rtfRevDTTM, "revdttm", 0 },
1357  { rtfCharAttr, rtfSmallCaps, "scaps", 0 },
1358  { rtfCharAttr, rtfShadow, "shad", 0 },
1359  { rtfCharAttr, rtfStrikeThru, "strike", 0 },
1360  { rtfCharAttr, rtfUnderline, "ul", 0 },
1361  { rtfCharAttr, rtfDotUnderline, "uld", 0 },
1362  { rtfCharAttr, rtfDbUnderline, "uldb", 0 },
1363  { rtfCharAttr, rtfNoUnderline, "ulnone", 0 },
1364  { rtfCharAttr, rtfWordUnderline, "ulw", 0 },
1365  { rtfCharAttr, rtfSuperScript, "up", 0 },
1366  { rtfCharAttr, rtfSuperScrShrink, "super", 0 },
1367  { rtfCharAttr, rtfInvisible, "v", 0 },
1368  { rtfCharAttr, rtfForeColor, "cf", 0 },
1369  { rtfCharAttr, rtfBackColor, "cb", 0 },
1370  { rtfCharAttr, rtfRTLChar, "rtlch", 0 },
1371  { rtfCharAttr, rtfLTRChar, "ltrch", 0 },
1372  { rtfCharAttr, rtfCharStyleNum, "cs", 0 },
1373  { rtfCharAttr, rtfCharCharSet, "cchs", 0 },
1374  { rtfCharAttr, rtfLanguage, "lang", 0 },
1375  /* this has disappeared from spec 1.2 */
1376  { rtfCharAttr, rtfGray, "gray", 0 },
1377  { rtfCharAttr, rtfUnicodeLength, "uc", 0 },
1378 
1379  /*
1380  * Paragraph formatting attributes
1381  */
1382 
1383  { rtfParAttr, rtfParDef, "pard", 0 },
1384  { rtfParAttr, rtfStyleNum, "s", 0 },
1385  { rtfParAttr, rtfHyphenate, "hyphpar", 0 },
1386  { rtfParAttr, rtfInTable, "intbl", 0 },
1387  { rtfParAttr, rtfKeep, "keep", 0 },
1388  { rtfParAttr, rtfNoWidowControl, "nowidctlpar", 0 },
1389  { rtfParAttr, rtfKeepNext, "keepn", 0 },
1390  { rtfParAttr, rtfOutlineLevel, "level", 0 },
1391  { rtfParAttr, rtfNoLineNum, "noline", 0 },
1392  { rtfParAttr, rtfPBBefore, "pagebb", 0 },
1393  { rtfParAttr, rtfSideBySide, "sbys", 0 },
1394  { rtfParAttr, rtfQuadLeft, "ql", 0 },
1395  { rtfParAttr, rtfQuadRight, "qr", 0 },
1396  { rtfParAttr, rtfQuadJust, "qj", 0 },
1397  { rtfParAttr, rtfQuadCenter, "qc", 0 },
1398  { rtfParAttr, rtfFirstIndent, "fi", 0 },
1399  { rtfParAttr, rtfLeftIndent, "li", 0 },
1400  { rtfParAttr, rtfRightIndent, "ri", 0 },
1401  { rtfParAttr, rtfSpaceBefore, "sb", 0 },
1402  { rtfParAttr, rtfSpaceAfter, "sa", 0 },
1403  { rtfParAttr, rtfSpaceBetween, "sl", 0 },
1404  { rtfParAttr, rtfSpaceMultiply, "slmult", 0 },
1405 
1406  { rtfParAttr, rtfSubDocument, "subdocument", 0 },
1407 
1408  { rtfParAttr, rtfRTLPar, "rtlpar", 0 },
1409  { rtfParAttr, rtfLTRPar, "ltrpar", 0 },
1410 
1411  { rtfParAttr, rtfTabPos, "tx", 0 },
1412  /*
1413  * FrameMaker writes \tql (to mean left-justified tab, apparently)
1414  * although it's not in the spec. It's also redundant, since lj
1415  * tabs are the default.
1416  */
1417  { rtfParAttr, rtfTabLeft, "tql", 0 },
1418  { rtfParAttr, rtfTabRight, "tqr", 0 },
1419  { rtfParAttr, rtfTabCenter, "tqc", 0 },
1420  { rtfParAttr, rtfTabDecimal, "tqdec", 0 },
1421  { rtfParAttr, rtfTabBar, "tb", 0 },
1422  { rtfParAttr, rtfLeaderDot, "tldot", 0 },
1423  { rtfParAttr, rtfLeaderHyphen, "tlhyph", 0 },
1424  { rtfParAttr, rtfLeaderUnder, "tlul", 0 },
1425  { rtfParAttr, rtfLeaderThick, "tlth", 0 },
1426  { rtfParAttr, rtfLeaderEqual, "tleq", 0 },
1427 
1428  { rtfParAttr, rtfParLevel, "pnlvl", 0 },
1429  { rtfParAttr, rtfParBullet, "pnlvlblt", 0 },
1430  { rtfParAttr, rtfParSimple, "pnlvlbody", 0 },
1431  { rtfParAttr, rtfParNumCont, "pnlvlcont", 0 },
1432  { rtfParAttr, rtfParNumOnce, "pnnumonce", 0 },
1433  { rtfParAttr, rtfParNumAcross, "pnacross", 0 },
1434  { rtfParAttr, rtfParHangIndent, "pnhang", 0 },
1435  { rtfParAttr, rtfParNumRestart, "pnrestart", 0 },
1436  { rtfParAttr, rtfParNumCardinal, "pncard", 0 },
1437  { rtfParAttr, rtfParNumDecimal, "pndec", 0 },
1438  { rtfParAttr, rtfParNumULetter, "pnucltr", 0 },
1439  { rtfParAttr, rtfParNumURoman, "pnucrm", 0 },
1440  { rtfParAttr, rtfParNumLLetter, "pnlcltr", 0 },
1441  { rtfParAttr, rtfParNumLRoman, "pnlcrm", 0 },
1442  { rtfParAttr, rtfParNumOrdinal, "pnord", 0 },
1443  { rtfParAttr, rtfParNumOrdinalText, "pnordt", 0 },
1444  { rtfParAttr, rtfParNumBold, "pnb", 0 },
1445  { rtfParAttr, rtfParNumItalic, "pni", 0 },
1446  { rtfParAttr, rtfParNumAllCaps, "pncaps", 0 },
1447  { rtfParAttr, rtfParNumSmallCaps, "pnscaps", 0 },
1448  { rtfParAttr, rtfParNumUnder, "pnul", 0 },
1449  { rtfParAttr, rtfParNumDotUnder, "pnuld", 0 },
1450  { rtfParAttr, rtfParNumDbUnder, "pnuldb", 0 },
1451  { rtfParAttr, rtfParNumNoUnder, "pnulnone", 0 },
1452  { rtfParAttr, rtfParNumWordUnder, "pnulw", 0 },
1453  { rtfParAttr, rtfParNumStrikethru, "pnstrike", 0 },
1454  { rtfParAttr, rtfParNumForeColor, "pncf", 0 },
1455  { rtfParAttr, rtfParNumFont, "pnf", 0 },
1456  { rtfParAttr, rtfParNumFontSize, "pnfs", 0 },
1457  { rtfParAttr, rtfParNumIndent, "pnindent", 0 },
1458  { rtfParAttr, rtfParNumSpacing, "pnsp", 0 },
1459  { rtfParAttr, rtfParNumInclPrev, "pnprev", 0 },
1460  { rtfParAttr, rtfParNumCenter, "pnqc", 0 },
1461  { rtfParAttr, rtfParNumLeft, "pnql", 0 },
1462  { rtfParAttr, rtfParNumRight, "pnqr", 0 },
1463  { rtfParAttr, rtfParNumStartAt, "pnstart", 0 },
1464 
1465  { rtfParAttr, rtfBorderTop, "brdrt", 0 },
1466  { rtfParAttr, rtfBorderBottom, "brdrb", 0 },
1467  { rtfParAttr, rtfBorderLeft, "brdrl", 0 },
1468  { rtfParAttr, rtfBorderRight, "brdrr", 0 },
1469  { rtfParAttr, rtfBorderBetween, "brdrbtw", 0 },
1470  { rtfParAttr, rtfBorderBar, "brdrbar", 0 },
1471  { rtfParAttr, rtfBorderBox, "box", 0 },
1472  { rtfParAttr, rtfBorderSingle, "brdrs", 0 },
1473  { rtfParAttr, rtfBorderThick, "brdrth", 0 },
1474  { rtfParAttr, rtfBorderShadow, "brdrsh", 0 },
1475  { rtfParAttr, rtfBorderDouble, "brdrdb", 0 },
1476  { rtfParAttr, rtfBorderDot, "brdrdot", 0 },
1477  { rtfParAttr, rtfBorderDot, "brdrdash", 0 },
1478  { rtfParAttr, rtfBorderHair, "brdrhair", 0 },
1479  { rtfParAttr, rtfBorderWidth, "brdrw", 0 },
1480  { rtfParAttr, rtfBorderColor, "brdrcf", 0 },
1481  { rtfParAttr, rtfBorderSpace, "brsp", 0 },
1482 
1483  { rtfParAttr, rtfShading, "shading", 0 },
1484  { rtfParAttr, rtfBgPatH, "bghoriz", 0 },
1485  { rtfParAttr, rtfBgPatV, "bgvert", 0 },
1486  { rtfParAttr, rtfFwdDiagBgPat, "bgfdiag", 0 },
1487  { rtfParAttr, rtfBwdDiagBgPat, "bgbdiag", 0 },
1488  { rtfParAttr, rtfHatchBgPat, "bgcross", 0 },
1489  { rtfParAttr, rtfDiagHatchBgPat, "bgdcross", 0 },
1490  { rtfParAttr, rtfDarkBgPatH, "bgdkhoriz", 0 },
1491  { rtfParAttr, rtfDarkBgPatV, "bgdkvert", 0 },
1492  { rtfParAttr, rtfFwdDarkBgPat, "bgdkfdiag", 0 },
1493  { rtfParAttr, rtfBwdDarkBgPat, "bgdkbdiag", 0 },
1494  { rtfParAttr, rtfDarkHatchBgPat, "bgdkcross", 0 },
1495  { rtfParAttr, rtfDarkDiagHatchBgPat, "bgdkdcross", 0 },
1496  { rtfParAttr, rtfBgPatLineColor, "cfpat", 0 },
1497  { rtfParAttr, rtfBgPatColor, "cbpat", 0 },
1498  { rtfParAttr, rtfNestLevel, "itap", 0 },
1499 
1500  /*
1501  * Section formatting attributes
1502  */
1503 
1504  { rtfSectAttr, rtfSectDef, "sectd", 0 },
1505  { rtfSectAttr, rtfENoteHere, "endnhere", 0 },
1506  { rtfSectAttr, rtfPrtBinFirst, "binfsxn", 0 },
1507  { rtfSectAttr, rtfPrtBin, "binsxn", 0 },
1508  { rtfSectAttr, rtfSectStyleNum, "ds", 0 },
1509 
1510  { rtfSectAttr, rtfNoBreak, "sbknone", 0 },
1511  { rtfSectAttr, rtfColBreak, "sbkcol", 0 },
1512  { rtfSectAttr, rtfPageBreak, "sbkpage", 0 },
1513  { rtfSectAttr, rtfEvenBreak, "sbkeven", 0 },
1514  { rtfSectAttr, rtfOddBreak, "sbkodd", 0 },
1515 
1516  { rtfSectAttr, rtfColumns, "cols", 0 },
1517  { rtfSectAttr, rtfColumnSpace, "colsx", 0 },
1518  { rtfSectAttr, rtfColumnNumber, "colno", 0 },
1519  { rtfSectAttr, rtfColumnSpRight, "colsr", 0 },
1520  { rtfSectAttr, rtfColumnWidth, "colw", 0 },
1521  { rtfSectAttr, rtfColumnLine, "linebetcol", 0 },
1522 
1523  { rtfSectAttr, rtfLineModulus, "linemod", 0 },
1524  { rtfSectAttr, rtfLineDist, "linex", 0 },
1525  { rtfSectAttr, rtfLineStarts, "linestarts", 0 },
1526  { rtfSectAttr, rtfLineRestart, "linerestart", 0 },
1527  { rtfSectAttr, rtfLineRestartPg, "lineppage", 0 },
1528  { rtfSectAttr, rtfLineCont, "linecont", 0 },
1529 
1530  { rtfSectAttr, rtfSectPageWid, "pgwsxn", 0 },
1531  { rtfSectAttr, rtfSectPageHt, "pghsxn", 0 },
1532  { rtfSectAttr, rtfSectMarginLeft, "marglsxn", 0 },
1533  { rtfSectAttr, rtfSectMarginRight, "margrsxn", 0 },
1534  { rtfSectAttr, rtfSectMarginTop, "margtsxn", 0 },
1535  { rtfSectAttr, rtfSectMarginBottom, "margbsxn", 0 },
1536  { rtfSectAttr, rtfSectMarginGutter, "guttersxn", 0 },
1537  { rtfSectAttr, rtfSectLandscape, "lndscpsxn", 0 },
1538  { rtfSectAttr, rtfTitleSpecial, "titlepg", 0 },
1539  { rtfSectAttr, rtfHeaderY, "headery", 0 },
1540  { rtfSectAttr, rtfFooterY, "footery", 0 },
1541 
1542  { rtfSectAttr, rtfPageStarts, "pgnstarts", 0 },
1543  { rtfSectAttr, rtfPageCont, "pgncont", 0 },
1544  { rtfSectAttr, rtfPageRestart, "pgnrestart", 0 },
1545  { rtfSectAttr, rtfPageNumRight, "pgnx", 0 },
1546  { rtfSectAttr, rtfPageNumTop, "pgny", 0 },
1547  { rtfSectAttr, rtfPageDecimal, "pgndec", 0 },
1548  { rtfSectAttr, rtfPageURoman, "pgnucrm", 0 },
1549  { rtfSectAttr, rtfPageLRoman, "pgnlcrm", 0 },
1550  { rtfSectAttr, rtfPageULetter, "pgnucltr", 0 },
1551  { rtfSectAttr, rtfPageLLetter, "pgnlcltr", 0 },
1552  { rtfSectAttr, rtfPageNumHyphSep, "pgnhnsh", 0 },
1553  { rtfSectAttr, rtfPageNumSpaceSep, "pgnhnsp", 0 },
1554  { rtfSectAttr, rtfPageNumColonSep, "pgnhnsc", 0 },
1555  { rtfSectAttr, rtfPageNumEmdashSep, "pgnhnsm", 0 },
1556  { rtfSectAttr, rtfPageNumEndashSep, "pgnhnsn", 0 },
1557 
1558  { rtfSectAttr, rtfTopVAlign, "vertalt", 0 },
1559  /* misspelled as "vertal" in specification 1.0 */
1560  { rtfSectAttr, rtfBottomVAlign, "vertalb", 0 },
1561  { rtfSectAttr, rtfCenterVAlign, "vertalc", 0 },
1562  { rtfSectAttr, rtfJustVAlign, "vertalj", 0 },
1563 
1564  { rtfSectAttr, rtfRTLSect, "rtlsect", 0 },
1565  { rtfSectAttr, rtfLTRSect, "ltrsect", 0 },
1566 
1567  /* I've seen these in an old spec, but not in real files... */
1568  /*rtfSectAttr, rtfNoBreak, "nobreak", 0,*/
1569  /*rtfSectAttr, rtfColBreak, "colbreak", 0,*/
1570  /*rtfSectAttr, rtfPageBreak, "pagebreak", 0,*/
1571  /*rtfSectAttr, rtfEvenBreak, "evenbreak", 0,*/
1572  /*rtfSectAttr, rtfOddBreak, "oddbreak", 0,*/
1573 
1574  /*
1575  * Document formatting attributes
1576  */
1577 
1578  { rtfDocAttr, rtfDefTab, "deftab", 0 },
1579  { rtfDocAttr, rtfHyphHotZone, "hyphhotz", 0 },
1580  { rtfDocAttr, rtfHyphConsecLines, "hyphconsec", 0 },
1581  { rtfDocAttr, rtfHyphCaps, "hyphcaps", 0 },
1582  { rtfDocAttr, rtfHyphAuto, "hyphauto", 0 },
1583  { rtfDocAttr, rtfLineStart, "linestart", 0 },
1584  { rtfDocAttr, rtfFracWidth, "fracwidth", 0 },
1585  /* \makeback was given in old version of spec, it's now */
1586  /* listed as \makebackup */
1587  { rtfDocAttr, rtfMakeBackup, "makeback", 0 },
1588  { rtfDocAttr, rtfMakeBackup, "makebackup", 0 },
1589  { rtfDocAttr, rtfRTFDefault, "defformat", 0 },
1590  { rtfDocAttr, rtfPSOverlay, "psover", 0 },
1591  { rtfDocAttr, rtfDocTemplate, "doctemp", 0 },
1592  { rtfDocAttr, rtfDefLanguage, "deflang", 0 },
1593 
1594  { rtfDocAttr, rtfFENoteType, "fet", 0 },
1595  { rtfDocAttr, rtfFNoteEndSect, "endnotes", 0 },
1596  { rtfDocAttr, rtfFNoteEndDoc, "enddoc", 0 },
1597  { rtfDocAttr, rtfFNoteText, "ftntj", 0 },
1598  { rtfDocAttr, rtfFNoteBottom, "ftnbj", 0 },
1599  { rtfDocAttr, rtfENoteEndSect, "aendnotes", 0 },
1600  { rtfDocAttr, rtfENoteEndDoc, "aenddoc", 0 },
1601  { rtfDocAttr, rtfENoteText, "aftntj", 0 },
1602  { rtfDocAttr, rtfENoteBottom, "aftnbj", 0 },
1603  { rtfDocAttr, rtfFNoteStart, "ftnstart", 0 },
1604  { rtfDocAttr, rtfENoteStart, "aftnstart", 0 },
1605  { rtfDocAttr, rtfFNoteRestartPage, "ftnrstpg", 0 },
1606  { rtfDocAttr, rtfFNoteRestart, "ftnrestart", 0 },
1607  { rtfDocAttr, rtfFNoteRestartCont, "ftnrstcont", 0 },
1608  { rtfDocAttr, rtfENoteRestart, "aftnrestart", 0 },
1609  { rtfDocAttr, rtfENoteRestartCont, "aftnrstcont", 0 },
1610  { rtfDocAttr, rtfFNoteNumArabic, "ftnnar", 0 },
1611  { rtfDocAttr, rtfFNoteNumLLetter, "ftnnalc", 0 },
1612  { rtfDocAttr, rtfFNoteNumULetter, "ftnnauc", 0 },
1613  { rtfDocAttr, rtfFNoteNumLRoman, "ftnnrlc", 0 },
1614  { rtfDocAttr, rtfFNoteNumURoman, "ftnnruc", 0 },
1615  { rtfDocAttr, rtfFNoteNumChicago, "ftnnchi", 0 },
1616  { rtfDocAttr, rtfENoteNumArabic, "aftnnar", 0 },
1617  { rtfDocAttr, rtfENoteNumLLetter, "aftnnalc", 0 },
1618  { rtfDocAttr, rtfENoteNumULetter, "aftnnauc", 0 },
1619  { rtfDocAttr, rtfENoteNumLRoman, "aftnnrlc", 0 },
1620  { rtfDocAttr, rtfENoteNumURoman, "aftnnruc", 0 },
1621  { rtfDocAttr, rtfENoteNumChicago, "aftnnchi", 0 },
1622 
1623  { rtfDocAttr, rtfPaperWidth, "paperw", 0 },
1624  { rtfDocAttr, rtfPaperHeight, "paperh", 0 },
1625  { rtfDocAttr, rtfPaperSize, "psz", 0 },
1626  { rtfDocAttr, rtfLeftMargin, "margl", 0 },
1627  { rtfDocAttr, rtfRightMargin, "margr", 0 },
1628  { rtfDocAttr, rtfTopMargin, "margt", 0 },
1629  { rtfDocAttr, rtfBottomMargin, "margb", 0 },
1630  { rtfDocAttr, rtfFacingPage, "facingp", 0 },
1631  { rtfDocAttr, rtfGutterWid, "gutter", 0 },
1632  { rtfDocAttr, rtfMirrorMargin, "margmirror", 0 },
1633  { rtfDocAttr, rtfLandscape, "landscape", 0 },
1634  { rtfDocAttr, rtfPageStart, "pgnstart", 0 },
1635  { rtfDocAttr, rtfWidowCtrl, "widowctrl", 0 },
1636 
1637  { rtfDocAttr, rtfLinkStyles, "linkstyles", 0 },
1638 
1639  { rtfDocAttr, rtfNoAutoTabIndent, "notabind", 0 },
1640  { rtfDocAttr, rtfWrapSpaces, "wraptrsp", 0 },
1641  { rtfDocAttr, rtfPrintColorsBlack, "prcolbl", 0 },
1642  { rtfDocAttr, rtfNoExtraSpaceRL, "noextrasprl", 0 },
1643  { rtfDocAttr, rtfNoColumnBalance, "nocolbal", 0 },
1644  { rtfDocAttr, rtfCvtMailMergeQuote, "cvmme", 0 },
1645  { rtfDocAttr, rtfSuppressTopSpace, "sprstsp", 0 },
1646  { rtfDocAttr, rtfSuppressPreParSpace, "sprsspbf", 0 },
1647  { rtfDocAttr, rtfCombineTblBorders, "otblrul", 0 },
1648  { rtfDocAttr, rtfTranspMetafiles, "transmf", 0 },
1649  { rtfDocAttr, rtfSwapBorders, "swpbdr", 0 },
1650  { rtfDocAttr, rtfShowHardBreaks, "brkfrm", 0 },
1651 
1652  { rtfDocAttr, rtfFormProtected, "formprot", 0 },
1653  { rtfDocAttr, rtfAllProtected, "allprot", 0 },
1654  { rtfDocAttr, rtfFormShading, "formshade", 0 },
1655  { rtfDocAttr, rtfFormDisplay, "formdisp", 0 },
1656  { rtfDocAttr, rtfPrintData, "printdata", 0 },
1657 
1658  { rtfDocAttr, rtfRevProtected, "revprot", 0 },
1659  { rtfDocAttr, rtfRevisions, "revisions", 0 },
1660  { rtfDocAttr, rtfRevDisplay, "revprop", 0 },
1661  { rtfDocAttr, rtfRevBar, "revbar", 0 },
1662 
1663  { rtfDocAttr, rtfAnnotProtected, "annotprot", 0 },
1664 
1665  { rtfDocAttr, rtfRTLDoc, "rtldoc", 0 },
1666  { rtfDocAttr, rtfLTRDoc, "ltrdoc", 0 },
1667 
1668  { rtfDocAttr, rtfAnsiCodePage, "ansicpg", 0 },
1669  { rtfDocAttr, rtfUTF8RTF, "urtf", 0 },
1670 
1671  /*
1672  * Style attributes
1673  */
1674 
1675  { rtfStyleAttr, rtfAdditive, "additive", 0 },
1676  { rtfStyleAttr, rtfBasedOn, "sbasedon", 0 },
1677  { rtfStyleAttr, rtfNext, "snext", 0 },
1678 
1679  /*
1680  * Picture attributes
1681  */
1682 
1683  { rtfPictAttr, rtfMacQD, "macpict", 0 },
1684  { rtfPictAttr, rtfPMMetafile, "pmmetafile", 0 },
1685  { rtfPictAttr, rtfWinMetafile, "wmetafile", 0 },
1686  { rtfPictAttr, rtfDevIndBitmap, "dibitmap", 0 },
1687  { rtfPictAttr, rtfWinBitmap, "wbitmap", 0 },
1688  { rtfPictAttr, rtfEmfBlip, "emfblip", 0 },
1689  { rtfPictAttr, rtfPixelBits, "wbmbitspixel", 0 },
1690  { rtfPictAttr, rtfBitmapPlanes, "wbmplanes", 0 },
1691  { rtfPictAttr, rtfBitmapWid, "wbmwidthbytes", 0 },
1692 
1693  { rtfPictAttr, rtfPicWid, "picw", 0 },
1694  { rtfPictAttr, rtfPicHt, "pich", 0 },
1695  { rtfPictAttr, rtfPicGoalWid, "picwgoal", 0 },
1696  { rtfPictAttr, rtfPicGoalHt, "pichgoal", 0 },
1697  /* these two aren't in the spec, but some writers emit them */
1698  { rtfPictAttr, rtfPicGoalWid, "picwGoal", 0 },
1699  { rtfPictAttr, rtfPicGoalHt, "pichGoal", 0 },
1700  { rtfPictAttr, rtfPicScaleX, "picscalex", 0 },
1701  { rtfPictAttr, rtfPicScaleY, "picscaley", 0 },
1702  { rtfPictAttr, rtfPicScaled, "picscaled", 0 },
1703  { rtfPictAttr, rtfPicCropTop, "piccropt", 0 },
1704  { rtfPictAttr, rtfPicCropBottom, "piccropb", 0 },
1705  { rtfPictAttr, rtfPicCropLeft, "piccropl", 0 },
1706  { rtfPictAttr, rtfPicCropRight, "piccropr", 0 },
1707 
1708  { rtfPictAttr, rtfPicMFHasBitmap, "picbmp", 0 },
1709  { rtfPictAttr, rtfPicMFBitsPerPixel, "picbpp", 0 },
1710 
1711  { rtfPictAttr, rtfPicBinary, "bin", 0 },
1712 
1713  /*
1714  * NeXT graphic attributes
1715  */
1716 
1717  { rtfNeXTGrAttr, rtfNeXTGWidth, "width", 0 },
1718  { rtfNeXTGrAttr, rtfNeXTGHeight, "height", 0 },
1719 
1720  /*
1721  * Destinations
1722  */
1723 
1724  { rtfDestination, rtfFontTbl, "fonttbl", 0 },
1725  { rtfDestination, rtfFontAltName, "falt", 0 },
1726  { rtfDestination, rtfEmbeddedFont, "fonteb", 0 },
1727  { rtfDestination, rtfFontFile, "fontfile", 0 },
1728  { rtfDestination, rtfFileTbl, "filetbl", 0 },
1729  { rtfDestination, rtfFileInfo, "file", 0 },
1730  { rtfDestination, rtfColorTbl, "colortbl", 0 },
1731  { rtfDestination, rtfStyleSheet, "stylesheet", 0 },
1732  { rtfDestination, rtfKeyCode, "keycode", 0 },
1733  { rtfDestination, rtfRevisionTbl, "revtbl", 0 },
1734  { rtfDestination, rtfGenerator, "generator", 0 },
1735  { rtfDestination, rtfInfo, "info", 0 },
1736  { rtfDestination, rtfITitle, "title", 0 },
1737  { rtfDestination, rtfISubject, "subject", 0 },
1738  { rtfDestination, rtfIAuthor, "author", 0 },
1739  { rtfDestination, rtfIOperator, "operator", 0 },
1740  { rtfDestination, rtfIKeywords, "keywords", 0 },
1741  { rtfDestination, rtfIComment, "comment", 0 },
1742  { rtfDestination, rtfIVersion, "version", 0 },
1743  { rtfDestination, rtfIDoccomm, "doccomm", 0 },
1744  /* \verscomm may not exist -- was seen in earlier spec version */
1745  { rtfDestination, rtfIVerscomm, "verscomm", 0 },
1746  { rtfDestination, rtfNextFile, "nextfile", 0 },
1747  { rtfDestination, rtfTemplate, "template", 0 },
1748  { rtfDestination, rtfFNSep, "ftnsep", 0 },
1749  { rtfDestination, rtfFNContSep, "ftnsepc", 0 },
1750  { rtfDestination, rtfFNContNotice, "ftncn", 0 },
1751  { rtfDestination, rtfENSep, "aftnsep", 0 },
1752  { rtfDestination, rtfENContSep, "aftnsepc", 0 },
1753  { rtfDestination, rtfENContNotice, "aftncn", 0 },
1754  { rtfDestination, rtfPageNumLevel, "pgnhn", 0 },
1755  { rtfDestination, rtfParNumLevelStyle, "pnseclvl", 0 },
1756  { rtfDestination, rtfHeader, "header", 0 },
1757  { rtfDestination, rtfFooter, "footer", 0 },
1758  { rtfDestination, rtfHeaderLeft, "headerl", 0 },
1759  { rtfDestination, rtfHeaderRight, "headerr", 0 },
1760  { rtfDestination, rtfHeaderFirst, "headerf", 0 },
1761  { rtfDestination, rtfFooterLeft, "footerl", 0 },
1762  { rtfDestination, rtfFooterRight, "footerr", 0 },
1763  { rtfDestination, rtfFooterFirst, "footerf", 0 },
1764  { rtfDestination, rtfParNumText, "pntext", 0 },
1765  { rtfDestination, rtfParNumbering, "pn", 0 },
1766  { rtfDestination, rtfParNumTextAfter, "pntxta", 0 },
1767  { rtfDestination, rtfParNumTextBefore, "pntxtb", 0 },
1768  { rtfDestination, rtfBookmarkStart, "bkmkstart", 0 },
1769  { rtfDestination, rtfBookmarkEnd, "bkmkend", 0 },
1770  { rtfDestination, rtfPict, "pict", 0 },
1771  { rtfDestination, rtfObject, "object", 0 },
1772  { rtfDestination, rtfObjClass, "objclass", 0 },
1773  { rtfDestination, rtfObjName, "objname", 0 },
1774  { rtfObjAttr, rtfObjTime, "objtime", 0 },
1775  { rtfDestination, rtfObjData, "objdata", 0 },
1776  { rtfDestination, rtfObjAlias, "objalias", 0 },
1777  { rtfDestination, rtfObjSection, "objsect", 0 },
1778  /* objitem and objtopic aren't documented in the spec! */
1779  { rtfDestination, rtfObjItem, "objitem", 0 },
1780  { rtfDestination, rtfObjTopic, "objtopic", 0 },
1781  { rtfDestination, rtfObjResult, "result", 0 },
1782  { rtfDestination, rtfDrawObject, "do", 0 },
1783  { rtfDestination, rtfFootnote, "footnote", 0 },
1784  { rtfDestination, rtfAnnotRefStart, "atrfstart", 0 },
1785  { rtfDestination, rtfAnnotRefEnd, "atrfend", 0 },
1786  { rtfDestination, rtfAnnotID, "atnid", 0 },
1787  { rtfDestination, rtfAnnotAuthor, "atnauthor", 0 },
1788  { rtfDestination, rtfAnnotation, "annotation", 0 },
1789  { rtfDestination, rtfAnnotRef, "atnref", 0 },
1790  { rtfDestination, rtfAnnotTime, "atntime", 0 },
1791  { rtfDestination, rtfAnnotIcon, "atnicn", 0 },
1792  { rtfDestination, rtfField, "field", 0 },
1793  { rtfDestination, rtfFieldInst, "fldinst", 0 },
1794  { rtfDestination, rtfFieldResult, "fldrslt", 0 },
1795  { rtfDestination, rtfDataField, "datafield", 0 },
1796  { rtfDestination, rtfIndex, "xe", 0 },
1797  { rtfDestination, rtfIndexText, "txe", 0 },
1798  { rtfDestination, rtfIndexRange, "rxe", 0 },
1799  { rtfDestination, rtfTOC, "tc", 0 },
1800  { rtfDestination, rtfNeXTGraphic, "NeXTGraphic", 0 },
1801  { rtfDestination, rtfNestTableProps, "nesttableprops", 0 },
1802  { rtfDestination, rtfNoNestTables, "nonesttables", 0 },
1803  { rtfDestination, rtfShpPict, "shppict", 0 },
1804  { rtfDestination, rtfNonShpPict, "nonshppict", 0 },
1805 
1806  /*
1807  * Font families
1808  */
1809 
1810  { rtfFontFamily, rtfFFNil, "fnil", 0 },
1811  { rtfFontFamily, rtfFFRoman, "froman", 0 },
1812  { rtfFontFamily, rtfFFSwiss, "fswiss", 0 },
1813  { rtfFontFamily, rtfFFModern, "fmodern", 0 },
1814  { rtfFontFamily, rtfFFScript, "fscript", 0 },
1815  { rtfFontFamily, rtfFFDecor, "fdecor", 0 },
1816  { rtfFontFamily, rtfFFTech, "ftech", 0 },
1817  { rtfFontFamily, rtfFFBidirectional, "fbidi", 0 },
1818 
1819  /*
1820  * Font attributes
1821  */
1822 
1823  { rtfFontAttr, rtfFontCharSet, "fcharset", 0 },
1824  { rtfFontAttr, rtfFontPitch, "fprq", 0 },
1825  { rtfFontAttr, rtfFontCodePage, "cpg", 0 },
1826  { rtfFontAttr, rtfFTypeNil, "ftnil", 0 },
1827  { rtfFontAttr, rtfFTypeTrueType, "fttruetype", 0 },
1828 
1829  /*
1830  * File table attributes
1831  */
1832 
1833  { rtfFileAttr, rtfFileNum, "fid", 0 },
1834  { rtfFileAttr, rtfFileRelPath, "frelative", 0 },
1835  { rtfFileAttr, rtfFileOSNum, "fosnum", 0 },
1836 
1837  /*
1838  * File sources
1839  */
1840 
1841  { rtfFileSource, rtfSrcMacintosh, "fvalidmac", 0 },
1842  { rtfFileSource, rtfSrcDOS, "fvaliddos", 0 },
1843  { rtfFileSource, rtfSrcNTFS, "fvalidntfs", 0 },
1844  { rtfFileSource, rtfSrcHPFS, "fvalidhpfs", 0 },
1845  { rtfFileSource, rtfSrcNetwork, "fnetwork", 0 },
1846 
1847  /*
1848  * Color names
1849  */
1850 
1851  { rtfColorName, rtfRed, "red", 0 },
1852  { rtfColorName, rtfGreen, "green", 0 },
1853  { rtfColorName, rtfBlue, "blue", 0 },
1854 
1855  /*
1856  * Charset names
1857  */
1858 
1859  { rtfCharSet, rtfMacCharSet, "mac", 0 },
1860  { rtfCharSet, rtfAnsiCharSet, "ansi", 0 },
1861  { rtfCharSet, rtfPcCharSet, "pc", 0 },
1862  { rtfCharSet, rtfPcaCharSet, "pca", 0 },
1863 
1864  /*
1865  * Table attributes
1866  */
1867 
1868  { rtfTblAttr, rtfRowDef, "trowd", 0 },
1869  { rtfTblAttr, rtfRowGapH, "trgaph", 0 },
1870  { rtfTblAttr, rtfCellPos, "cellx", 0 },
1871  { rtfTblAttr, rtfMergeRngFirst, "clmgf", 0 },
1872  { rtfTblAttr, rtfMergePrevious, "clmrg", 0 },
1873 
1874  { rtfTblAttr, rtfRowLeft, "trql", 0 },
1875  { rtfTblAttr, rtfRowRight, "trqr", 0 },
1876  { rtfTblAttr, rtfRowCenter, "trqc", 0 },
1877  { rtfTblAttr, rtfRowLeftEdge, "trleft", 0 },
1878  { rtfTblAttr, rtfRowHt, "trrh", 0 },
1879  { rtfTblAttr, rtfRowHeader, "trhdr", 0 },
1880  { rtfTblAttr, rtfRowKeep, "trkeep", 0 },
1881 
1882  { rtfTblAttr, rtfRTLRow, "rtlrow", 0 },
1883  { rtfTblAttr, rtfLTRRow, "ltrrow", 0 },
1884 
1885  { rtfTblAttr, rtfRowBordTop, "trbrdrt", 0 },
1886  { rtfTblAttr, rtfRowBordLeft, "trbrdrl", 0 },
1887  { rtfTblAttr, rtfRowBordBottom, "trbrdrb", 0 },
1888  { rtfTblAttr, rtfRowBordRight, "trbrdrr", 0 },
1889  { rtfTblAttr, rtfRowBordHoriz, "trbrdrh", 0 },
1890  { rtfTblAttr, rtfRowBordVert, "trbrdrv", 0 },
1891 
1892  { rtfTblAttr, rtfCellBordBottom, "clbrdrb", 0 },
1893  { rtfTblAttr, rtfCellBordTop, "clbrdrt", 0 },
1894  { rtfTblAttr, rtfCellBordLeft, "clbrdrl", 0 },
1895  { rtfTblAttr, rtfCellBordRight, "clbrdrr", 0 },
1896 
1897  { rtfTblAttr, rtfCellShading, "clshdng", 0 },
1898  { rtfTblAttr, rtfCellBgPatH, "clbghoriz", 0 },
1899  { rtfTblAttr, rtfCellBgPatV, "clbgvert", 0 },
1900  { rtfTblAttr, rtfCellFwdDiagBgPat, "clbgfdiag", 0 },
1901  { rtfTblAttr, rtfCellBwdDiagBgPat, "clbgbdiag", 0 },
1902  { rtfTblAttr, rtfCellHatchBgPat, "clbgcross", 0 },
1903  { rtfTblAttr, rtfCellDiagHatchBgPat, "clbgdcross", 0 },
1904  /*
1905  * The spec lists "clbgdkhor", but the corresponding non-cell
1906  * control is "bgdkhoriz". At any rate Macintosh Word seems
1907  * to accept both "clbgdkhor" and "clbgdkhoriz".
1908  */
1909  { rtfTblAttr, rtfCellDarkBgPatH, "clbgdkhoriz", 0 },
1910  { rtfTblAttr, rtfCellDarkBgPatH, "clbgdkhor", 0 },
1911  { rtfTblAttr, rtfCellDarkBgPatV, "clbgdkvert", 0 },
1912  { rtfTblAttr, rtfCellFwdDarkBgPat, "clbgdkfdiag", 0 },
1913  { rtfTblAttr, rtfCellBwdDarkBgPat, "clbgdkbdiag", 0 },
1914  { rtfTblAttr, rtfCellDarkHatchBgPat, "clbgdkcross", 0 },
1915  { rtfTblAttr, rtfCellDarkDiagHatchBgPat, "clbgdkdcross", 0 },
1916  { rtfTblAttr, rtfCellBgPatLineColor, "clcfpat", 0 },
1917  { rtfTblAttr, rtfCellBgPatColor, "clcbpat", 0 },
1918 
1919  /*
1920  * Field attributes
1921  */
1922 
1923  { rtfFieldAttr, rtfFieldDirty, "flddirty", 0 },
1924  { rtfFieldAttr, rtfFieldEdited, "fldedit", 0 },
1925  { rtfFieldAttr, rtfFieldLocked, "fldlock", 0 },
1926  { rtfFieldAttr, rtfFieldPrivate, "fldpriv", 0 },
1927  { rtfFieldAttr, rtfFieldAlt, "fldalt", 0 },
1928 
1929  /*
1930  * Positioning attributes
1931  */
1932 
1933  { rtfPosAttr, rtfAbsWid, "absw", 0 },
1934  { rtfPosAttr, rtfAbsHt, "absh", 0 },
1935 
1936  { rtfPosAttr, rtfRPosMargH, "phmrg", 0 },
1937  { rtfPosAttr, rtfRPosPageH, "phpg", 0 },
1938  { rtfPosAttr, rtfRPosColH, "phcol", 0 },
1939  { rtfPosAttr, rtfPosX, "posx", 0 },
1940  { rtfPosAttr, rtfPosNegX, "posnegx", 0 },
1941  { rtfPosAttr, rtfPosXCenter, "posxc", 0 },
1942  { rtfPosAttr, rtfPosXInside, "posxi", 0 },
1943  { rtfPosAttr, rtfPosXOutSide, "posxo", 0 },
1944  { rtfPosAttr, rtfPosXRight, "posxr", 0 },
1945  { rtfPosAttr, rtfPosXLeft, "posxl", 0 },
1946 
1947  { rtfPosAttr, rtfRPosMargV, "pvmrg", 0 },
1948  { rtfPosAttr, rtfRPosPageV, "pvpg", 0 },
1949  { rtfPosAttr, rtfRPosParaV, "pvpara", 0 },
1950  { rtfPosAttr, rtfPosY, "posy", 0 },
1951  { rtfPosAttr, rtfPosNegY, "posnegy", 0 },
1952  { rtfPosAttr, rtfPosYInline, "posyil", 0 },
1953  { rtfPosAttr, rtfPosYTop, "posyt", 0 },
1954  { rtfPosAttr, rtfPosYCenter, "posyc", 0 },
1955  { rtfPosAttr, rtfPosYBottom, "posyb", 0 },
1956 
1957  { rtfPosAttr, rtfNoWrap, "nowrap", 0 },
1958  { rtfPosAttr, rtfDistFromTextAll, "dxfrtext", 0 },
1959  { rtfPosAttr, rtfDistFromTextX, "dfrmtxtx", 0 },
1960  { rtfPosAttr, rtfDistFromTextY, "dfrmtxty", 0 },
1961  /* \dyfrtext no longer exists in spec 1.2, apparently */
1962  /* replaced by \dfrmtextx and \dfrmtexty. */
1963  { rtfPosAttr, rtfTextDistY, "dyfrtext", 0 },
1964 
1965  { rtfPosAttr, rtfDropCapLines, "dropcapli", 0 },
1966  { rtfPosAttr, rtfDropCapType, "dropcapt", 0 },
1967 
1968  /*
1969  * Object controls
1970  */
1971 
1972  { rtfObjAttr, rtfObjEmb, "objemb", 0 },
1973  { rtfObjAttr, rtfObjLink, "objlink", 0 },
1974  { rtfObjAttr, rtfObjAutoLink, "objautlink", 0 },
1975  { rtfObjAttr, rtfObjSubscriber, "objsub", 0 },
1976  { rtfObjAttr, rtfObjPublisher, "objpub", 0 },
1977  { rtfObjAttr, rtfObjICEmb, "objicemb", 0 },
1978 
1979  { rtfObjAttr, rtfObjLinkSelf, "linkself", 0 },
1980  { rtfObjAttr, rtfObjLock, "objupdate", 0 },
1981  { rtfObjAttr, rtfObjUpdate, "objlock", 0 },
1982 
1983  { rtfObjAttr, rtfObjHt, "objh", 0 },
1984  { rtfObjAttr, rtfObjWid, "objw", 0 },
1985  { rtfObjAttr, rtfObjSetSize, "objsetsize", 0 },
1986  { rtfObjAttr, rtfObjAlign, "objalign", 0 },
1987  { rtfObjAttr, rtfObjTransposeY, "objtransy", 0 },
1988  { rtfObjAttr, rtfObjCropTop, "objcropt", 0 },
1989  { rtfObjAttr, rtfObjCropBottom, "objcropb", 0 },
1990  { rtfObjAttr, rtfObjCropLeft, "objcropl", 0 },
1991  { rtfObjAttr, rtfObjCropRight, "objcropr", 0 },
1992  { rtfObjAttr, rtfObjScaleX, "objscalex", 0 },
1993  { rtfObjAttr, rtfObjScaleY, "objscaley", 0 },
1994 
1995  { rtfObjAttr, rtfObjResRTF, "rsltrtf", 0 },
1996  { rtfObjAttr, rtfObjResPict, "rsltpict", 0 },
1997  { rtfObjAttr, rtfObjResBitmap, "rsltbmp", 0 },
1998  { rtfObjAttr, rtfObjResText, "rslttxt", 0 },
1999  { rtfObjAttr, rtfObjResMerge, "rsltmerge", 0 },
2000 
2001  { rtfObjAttr, rtfObjBookmarkPubObj, "bkmkpub", 0 },
2002  { rtfObjAttr, rtfObjPubAutoUpdate, "pubauto", 0 },
2003 
2004  /*
2005  * Associated character formatting attributes
2006  */
2007 
2008  { rtfACharAttr, rtfACBold, "ab", 0 },
2009  { rtfACharAttr, rtfACAllCaps, "caps", 0 },
2010  { rtfACharAttr, rtfACForeColor, "acf", 0 },
2011  { rtfACharAttr, rtfACSubScript, "adn", 0 },
2012  { rtfACharAttr, rtfACExpand, "aexpnd", 0 },
2013  { rtfACharAttr, rtfACFontNum, "af", 0 },
2014  { rtfACharAttr, rtfACFontSize, "afs", 0 },
2015  { rtfACharAttr, rtfACItalic, "ai", 0 },
2016  { rtfACharAttr, rtfACLanguage, "alang", 0 },
2017  { rtfACharAttr, rtfACOutline, "aoutl", 0 },
2018  { rtfACharAttr, rtfACSmallCaps, "ascaps", 0 },
2019  { rtfACharAttr, rtfACShadow, "ashad", 0 },
2020  { rtfACharAttr, rtfACStrikeThru, "astrike", 0 },
2021  { rtfACharAttr, rtfACUnderline, "aul", 0 },
2022  { rtfACharAttr, rtfACDotUnderline, "auld", 0 },
2023  { rtfACharAttr, rtfACDbUnderline, "auldb", 0 },
2024  { rtfACharAttr, rtfACNoUnderline, "aulnone", 0 },
2025  { rtfACharAttr, rtfACWordUnderline, "aulw", 0 },
2026  { rtfACharAttr, rtfACSuperScript, "aup", 0 },
2027 
2028  /*
2029  * Footnote attributes
2030  */
2031 
2032  { rtfFNoteAttr, rtfFNAlt, "ftnalt", 0 },
2033 
2034  /*
2035  * Key code attributes
2036  */
2037 
2038  { rtfKeyCodeAttr, rtfAltKey, "alt", 0 },
2039  { rtfKeyCodeAttr, rtfShiftKey, "shift", 0 },
2040  { rtfKeyCodeAttr, rtfControlKey, "ctrl", 0 },
2041  { rtfKeyCodeAttr, rtfFunctionKey, "fn", 0 },
2042 
2043  /*
2044  * Bookmark attributes
2045  */
2046 
2047  { rtfBookmarkAttr, rtfBookmarkFirstCol, "bkmkcolf", 0 },
2048  { rtfBookmarkAttr, rtfBookmarkLastCol, "bkmkcoll", 0 },
2049 
2050  /*
2051  * Index entry attributes
2052  */
2053 
2054  { rtfIndexAttr, rtfIndexNumber, "xef", 0 },
2055  { rtfIndexAttr, rtfIndexBold, "bxe", 0 },
2056  { rtfIndexAttr, rtfIndexItalic, "ixe", 0 },
2057 
2058  /*
2059  * Table of contents attributes
2060  */
2061 
2062  { rtfTOCAttr, rtfTOCType, "tcf", 0 },
2063  { rtfTOCAttr, rtfTOCLevel, "tcl", 0 },
2064 
2065  /*
2066  * Drawing object attributes
2067  */
2068 
2069  { rtfDrawAttr, rtfDrawLock, "dolock", 0 },
2070  { rtfDrawAttr, rtfDrawPageRelX, "doxpage", 0 },
2071  { rtfDrawAttr, rtfDrawColumnRelX, "dobxcolumn", 0 },
2072  { rtfDrawAttr, rtfDrawMarginRelX, "dobxmargin", 0 },
2073  { rtfDrawAttr, rtfDrawPageRelY, "dobypage", 0 },
2074  { rtfDrawAttr, rtfDrawColumnRelY, "dobycolumn", 0 },
2075  { rtfDrawAttr, rtfDrawMarginRelY, "dobymargin", 0 },
2076  { rtfDrawAttr, rtfDrawHeight, "dobhgt", 0 },
2077 
2078  { rtfDrawAttr, rtfDrawBeginGroup, "dpgroup", 0 },
2079  { rtfDrawAttr, rtfDrawGroupCount, "dpcount", 0 },
2080  { rtfDrawAttr, rtfDrawEndGroup, "dpendgroup", 0 },
2081  { rtfDrawAttr, rtfDrawArc, "dparc", 0 },
2082  { rtfDrawAttr, rtfDrawCallout, "dpcallout", 0 },
2083  { rtfDrawAttr, rtfDrawEllipse, "dpellipse", 0 },
2084  { rtfDrawAttr, rtfDrawLine, "dpline", 0 },
2085  { rtfDrawAttr, rtfDrawPolygon, "dppolygon", 0 },
2086  { rtfDrawAttr, rtfDrawPolyLine, "dppolyline", 0 },
2087  { rtfDrawAttr, rtfDrawRect, "dprect", 0 },
2088  { rtfDrawAttr, rtfDrawTextBox, "dptxbx", 0 },
2089 
2090  { rtfDrawAttr, rtfDrawOffsetX, "dpx", 0 },
2091  { rtfDrawAttr, rtfDrawSizeX, "dpxsize", 0 },
2092  { rtfDrawAttr, rtfDrawOffsetY, "dpy", 0 },
2093  { rtfDrawAttr, rtfDrawSizeY, "dpysize", 0 },
2094 
2095  { rtfDrawAttr, rtfCOAngle, "dpcoa", 0 },
2096  { rtfDrawAttr, rtfCOAccentBar, "dpcoaccent", 0 },
2097  { rtfDrawAttr, rtfCOBestFit, "dpcobestfit", 0 },
2098  { rtfDrawAttr, rtfCOBorder, "dpcoborder", 0 },
2099  { rtfDrawAttr, rtfCOAttachAbsDist, "dpcodabs", 0 },
2100  { rtfDrawAttr, rtfCOAttachBottom, "dpcodbottom", 0 },
2101  { rtfDrawAttr, rtfCOAttachCenter, "dpcodcenter", 0 },
2102  { rtfDrawAttr, rtfCOAttachTop, "dpcodtop", 0 },
2103  { rtfDrawAttr, rtfCOLength, "dpcolength", 0 },
2104  { rtfDrawAttr, rtfCONegXQuadrant, "dpcominusx", 0 },
2105  { rtfDrawAttr, rtfCONegYQuadrant, "dpcominusy", 0 },
2106  { rtfDrawAttr, rtfCOOffset, "dpcooffset", 0 },
2107  { rtfDrawAttr, rtfCOAttachSmart, "dpcosmarta", 0 },
2108  { rtfDrawAttr, rtfCODoubleLine, "dpcotdouble", 0 },
2109  { rtfDrawAttr, rtfCORightAngle, "dpcotright", 0 },
2110  { rtfDrawAttr, rtfCOSingleLine, "dpcotsingle", 0 },
2111  { rtfDrawAttr, rtfCOTripleLine, "dpcottriple", 0 },
2112 
2113  { rtfDrawAttr, rtfDrawTextBoxMargin, "dptxbxmar", 0 },
2114  { rtfDrawAttr, rtfDrawTextBoxText, "dptxbxtext", 0 },
2115  { rtfDrawAttr, rtfDrawRoundRect, "dproundr", 0 },
2116 
2117  { rtfDrawAttr, rtfDrawPointX, "dpptx", 0 },
2118  { rtfDrawAttr, rtfDrawPointY, "dppty", 0 },
2119  { rtfDrawAttr, rtfDrawPolyCount, "dppolycount", 0 },
2120 
2121  { rtfDrawAttr, rtfDrawArcFlipX, "dparcflipx", 0 },
2122  { rtfDrawAttr, rtfDrawArcFlipY, "dparcflipy", 0 },
2123 
2124  { rtfDrawAttr, rtfDrawLineBlue, "dplinecob", 0 },
2125  { rtfDrawAttr, rtfDrawLineGreen, "dplinecog", 0 },
2126  { rtfDrawAttr, rtfDrawLineRed, "dplinecor", 0 },
2127  { rtfDrawAttr, rtfDrawLinePalette, "dplinepal", 0 },
2128  { rtfDrawAttr, rtfDrawLineDashDot, "dplinedado", 0 },
2129  { rtfDrawAttr, rtfDrawLineDashDotDot, "dplinedadodo", 0 },
2130  { rtfDrawAttr, rtfDrawLineDash, "dplinedash", 0 },
2131  { rtfDrawAttr, rtfDrawLineDot, "dplinedot", 0 },
2132  { rtfDrawAttr, rtfDrawLineGray, "dplinegray", 0 },
2133  { rtfDrawAttr, rtfDrawLineHollow, "dplinehollow", 0 },
2134  { rtfDrawAttr, rtfDrawLineSolid, "dplinesolid", 0 },
2135  { rtfDrawAttr, rtfDrawLineWidth, "dplinew", 0 },
2136 
2137  { rtfDrawAttr, rtfDrawHollowEndArrow, "dpaendhol", 0 },
2138  { rtfDrawAttr, rtfDrawEndArrowLength, "dpaendl", 0 },
2139  { rtfDrawAttr, rtfDrawSolidEndArrow, "dpaendsol", 0 },
2140  { rtfDrawAttr, rtfDrawEndArrowWidth, "dpaendw", 0 },
2141  { rtfDrawAttr, rtfDrawHollowStartArrow,"dpastarthol", 0 },
2142  { rtfDrawAttr, rtfDrawStartArrowLength,"dpastartl", 0 },
2143  { rtfDrawAttr, rtfDrawSolidStartArrow, "dpastartsol", 0 },
2144  { rtfDrawAttr, rtfDrawStartArrowWidth, "dpastartw", 0 },
2145 
2146  { rtfDrawAttr, rtfDrawBgFillBlue, "dpfillbgcb", 0 },
2147  { rtfDrawAttr, rtfDrawBgFillGreen, "dpfillbgcg", 0 },
2148  { rtfDrawAttr, rtfDrawBgFillRed, "dpfillbgcr", 0 },
2149  { rtfDrawAttr, rtfDrawBgFillPalette, "dpfillbgpal", 0 },
2150  { rtfDrawAttr, rtfDrawBgFillGray, "dpfillbggray", 0 },
2151  { rtfDrawAttr, rtfDrawFgFillBlue, "dpfillfgcb", 0 },
2152  { rtfDrawAttr, rtfDrawFgFillGreen, "dpfillfgcg", 0 },
2153  { rtfDrawAttr, rtfDrawFgFillRed, "dpfillfgcr", 0 },
2154  { rtfDrawAttr, rtfDrawFgFillPalette, "dpfillfgpal", 0 },
2155  { rtfDrawAttr, rtfDrawFgFillGray, "dpfillfggray", 0 },
2156  { rtfDrawAttr, rtfDrawFillPatIndex, "dpfillpat", 0 },
2157 
2158  { rtfDrawAttr, rtfDrawShadow, "dpshadow", 0 },
2159  { rtfDrawAttr, rtfDrawShadowXOffset, "dpshadx", 0 },
2160  { rtfDrawAttr, rtfDrawShadowYOffset, "dpshady", 0 },
2161 
2162  { rtfVersion, -1, "rtf", 0 },
2163  { rtfDefFont, -1, "deff", 0 },
2164 
2165  { 0, -1, NULL, 0 }
2166 };
2167 #define RTF_KEY_COUNT (sizeof(rtfKey) / sizeof(RTFKey))
2168 
2169 typedef struct tagRTFHashTableEntry {
2170  int count;
2173 
2175 
2176 
2177 /*
2178  * Initialize lookup table hash values. Only need to do this once.
2179  */
2180 
2181 void LookupInit(void)
2182 {
2183  RTFKey *rp;
2184 
2185  memset(rtfHashTable, 0, sizeof rtfHashTable);
2186  for (rp = rtfKey; rp->rtfKStr != NULL; rp++)
2187  {
2188  int index;
2189 
2190  rp->rtfKHash = Hash (rp->rtfKStr);
2191  index = rp->rtfKHash % (RTF_KEY_COUNT * 2);
2192  if (!rtfHashTable[index].count)
2193  rtfHashTable[index].value = heap_alloc(sizeof(RTFKey *));
2194  else
2195  rtfHashTable[index].value = heap_realloc(rtfHashTable[index].value, sizeof(RTFKey *) * (rtfHashTable[index].count + 1));
2196  rtfHashTable[index].value[rtfHashTable[index].count++] = rp;
2197  }
2198 }
2199 
2200 void LookupCleanup(void)
2201 {
2202  unsigned int i;
2203 
2204  for (i=0; i<RTF_KEY_COUNT*2; i++)
2205  {
2206  heap_free( rtfHashTable[i].value );
2207  rtfHashTable[i].value = NULL;
2208  rtfHashTable[i].count = 0;
2209  }
2210 }
2211 
2212 
2213 /*
2214  * Determine major and minor number of control token. If it's
2215  * not found, the class turns into rtfUnknown.
2216  */
2217 
2218 static void Lookup(RTF_Info *info, char *s)
2219 {
2220  RTFKey *rp;
2221  int hash;
2223  int i;
2224 
2225  ++s; /* skip over the leading \ character */
2226  hash = Hash (s);
2227  entry = &rtfHashTable[hash % (RTF_KEY_COUNT * 2)];
2228  for (i = 0; i < entry->count; i++)
2229  {
2230  rp = entry->value[i];
2231  if (hash == rp->rtfKHash && strcmp (s, rp->rtfKStr) == 0)
2232  {
2233  info->rtfClass = rtfControl;
2234  info->rtfMajor = rp->rtfKMajor;
2235  info->rtfMinor = rp->rtfKMinor;
2236  return;
2237  }
2238  }
2239  info->rtfClass = rtfUnknown;
2240 }
2241 
2242 
2243 /*
2244  * Compute hash value of symbol
2245  */
2246 
2247 static int Hash(const char *s)
2248 {
2249  char c;
2250  int val = 0;
2251 
2252  while ((c = *s++) != '\0')
2253  val += c;
2254  return (val);
2255 }
2256 
2257 
2258 
2259 /* ---------------------------------------------------------------------- */
2260 
2261 
2262 /*
2263  * Token comparison routines
2264  */
2265 
2266 int RTFCheckCM(const RTF_Info *info, int class, int major)
2267 {
2268  return (info->rtfClass == class && info->rtfMajor == major);
2269 }
2270 
2271 
2272 int RTFCheckCMM(const RTF_Info *info, int class, int major, int minor)
2273 {
2274  return (info->rtfClass == class && info->rtfMajor == major && info->rtfMinor == minor);
2275 }
2276 
2277 
2278 int RTFCheckMM(const RTF_Info *info, int major, int minor)
2279 {
2280  return (info->rtfMajor == major && info->rtfMinor == minor);
2281 }
2282 
2283 
2284 /* ---------------------------------------------------------------------- */
2285 
2286 
2287 int RTFCharToHex(char c)
2288 {
2289  if (isupper (c))
2290  c = tolower (c);
2291  if (isdigit (c))
2292  return (c - '0'); /* '0'..'9' */
2293  return (c - 'a' + 10); /* 'a'..'f' */
2294 }
2295 
2296 
2297 /* ---------------------------------------------------------------------- */
2298 
2299 /*
2300  * originally from RTF tools' text-writer.c
2301  *
2302  * text-writer -- RTF-to-text translation writer code.
2303  *
2304  * Read RTF input, write text of document (text extraction).
2305  */
2306 
2307 static void TextClass (RTF_Info *info);
2308 static void ControlClass (RTF_Info *info);
2309 static void DefFont(RTF_Info *info);
2310 static void Destination (RTF_Info *info);
2311 static void SpecialChar (RTF_Info *info);
2312 static void RTFPutUnicodeChar (RTF_Info *info, int c);
2313 
2314 /*
2315  * Initialize the writer.
2316  */
2317 
2318 void
2320 {
2321 }
2322 
2323 
2324 int
2326 {
2327  /* install class callbacks */
2328 
2331 
2332  return (1);
2333 }
2334 
2335 /*
2336  * Write out a character.
2337  */
2338 
2339 static void
2341 {
2342  RTFPutCodePageChar(info, info->rtfMajor);
2343 }
2344 
2345 
2346 static void
2348 {
2349  switch (info->rtfMajor)
2350  {
2351  case rtfCharAttr:
2352  CharAttr(info);
2353  ME_RTFCharAttrHook(info);
2354  break;
2355  case rtfParAttr:
2356  ME_RTFParAttrHook(info);
2357  break;
2358  case rtfTblAttr:
2359  ME_RTFTblAttrHook(info);
2360  break;
2361  case rtfCharSet:
2362  CharSet(info);
2363  break;
2364  case rtfDefFont:
2365  DefFont(info);
2366  break;
2367  case rtfDestination:
2368  Destination (info);
2369  break;
2370  case rtfDocAttr:
2371  DocAttr(info);
2372  break;
2373  case rtfSpecialChar:
2374  SpecialChar (info);
2375  ME_RTFSpecialCharHook(info);
2376  break;
2377  }
2378 }
2379 
2380 
2381 static void
2383 {
2384  RTFFont *font;
2385 
2386  switch (info->rtfMinor)
2387  {
2388  case rtfFontNum:
2389  font = RTFGetFont(info, info->rtfParam);
2390  if (font)
2391  {
2392  if (info->ansiCodePage != CP_UTF8 && info->codePage != font->rtfFCodePage)
2393  {
2394  RTFFlushOutputBuffer(info);
2395  info->codePage = font->rtfFCodePage;
2396  }
2397  TRACE("font %d codepage %d\n", info->rtfParam, info->codePage);
2398  }
2399  else
2400  ERR( "unknown font %d\n", info->rtfParam);
2401  break;
2402  case rtfUnicodeLength:
2403  info->unicodeLength = info->rtfParam;
2404  break;
2405  }
2406 }
2407 
2408 
2409 static void
2411 {
2412  if (info->ansiCodePage == CP_UTF8)
2413  return;
2414 
2415  switch (info->rtfMinor)
2416  {
2417  case rtfAnsiCharSet:
2418  info->ansiCodePage = 1252; /* Latin-1 */
2419  break;
2420  case rtfMacCharSet:
2421  info->ansiCodePage = 10000; /* MacRoman */
2422  break;
2423  case rtfPcCharSet:
2424  info->ansiCodePage = 437;
2425  break;
2426  case rtfPcaCharSet:
2427  info->ansiCodePage = 850;
2428  break;
2429  }
2430 }
2431 
2432 /*
2433  * This function notices destinations that aren't explicitly handled
2434  * and skips to their ends. This keeps, for instance, picture
2435  * data from being considered as plain text.
2436  */
2437 
2438 static void
2440 {
2441  if (!RTFGetDestinationCallback(info, info->rtfMinor))
2442  RTFSkipGroup (info);
2443 }
2444 
2445 
2446 static void
2448 {
2449  TRACE("%d\n", info->rtfParam);
2450  info->defFont = info->rtfParam;
2451 }
2452 
2453 
2454 static void
2456 {
2457  TRACE("minor %d, param %d\n", info->rtfMinor, info->rtfParam);
2458 
2459  switch (info->rtfMinor)
2460  {
2461  case rtfAnsiCodePage:
2462  info->codePage = info->ansiCodePage = info->rtfParam;
2463  break;
2464  case rtfUTF8RTF:
2465  info->codePage = info->ansiCodePage = CP_UTF8;
2466  break;
2467  }
2468 }
2469 
2470 
2471 static void SpecialChar (RTF_Info *info)
2472 {
2473  switch (info->rtfMinor)
2474  {
2475  case rtfOptDest:
2476  /* the next token determines destination, if it's unknown, skip the group */
2477  /* this way we filter out the garbage coming from unknown destinations */
2478  RTFGetToken(info);
2479  if (info->rtfClass != rtfDestination)
2480  RTFSkipGroup(info);
2481  else
2482  RTFRouteToken(info); /* "\*" is ignored with known destinations */
2483  break;
2484  case rtfUnicode:
2485  {
2486  int i;
2487 
2488  RTFPutUnicodeChar(info, info->rtfParam);
2489 
2490  /* After \u we must skip number of character tokens set by \ucN */
2491  for (i = 0; i < info->unicodeLength; i++)
2492  {
2493  RTFGetToken(info);
2494  if (info->rtfClass != rtfText)
2495  {
2496  ERR("The token behind \\u is not text, but (%d,%d,%d)\n",
2497  info->rtfClass, info->rtfMajor, info->rtfMinor);
2498  RTFUngetToken(info);
2499  break;
2500  }
2501  }
2502  break;
2503  }
2504  case rtfLine:
2505  RTFFlushOutputBuffer(info);
2507  break;
2508  case rtfPage:
2509  case rtfSect:
2510  case rtfPar:
2511  RTFFlushOutputBuffer(info);
2512  ME_SetSelectionParaFormat(info->editor, &info->fmt);
2513  memset(&info->fmt, 0, sizeof(info->fmt));
2514  info->fmt.cbSize = sizeof(info->fmt);
2515  RTFPutUnicodeChar (info, '\r');
2516  if (info->editor->bEmulateVersion10) RTFPutUnicodeChar (info, '\n');
2517  break;
2518  case rtfNoBrkSpace:
2519  RTFPutUnicodeChar (info, 0x00A0);
2520  break;
2521  case rtfTab:
2522  RTFPutUnicodeChar (info, '\t');
2523  break;
2524  case rtfNoBrkHyphen:
2525  RTFPutUnicodeChar (info, 0x2011);
2526  break;
2527  case rtfBullet:
2528  RTFPutUnicodeChar (info, 0x2022);
2529  break;
2530  case rtfEmDash:
2531  RTFPutUnicodeChar (info, 0x2014);
2532  break;
2533  case rtfEnDash:
2534  RTFPutUnicodeChar (info, 0x2013);
2535  break;
2536  case rtfEmSpace:
2537  RTFPutUnicodeChar (info, ' ');
2538  break;
2539  case rtfEnSpace:
2540  RTFPutUnicodeChar (info, ' ');
2541  break;
2542  case rtfLQuote:
2543  RTFPutUnicodeChar (info, 0x2018);
2544  break;
2545  case rtfRQuote:
2546  RTFPutUnicodeChar (info, 0x2019);
2547  break;
2548  case rtfLDblQuote:
2549  RTFPutUnicodeChar (info, 0x201C);
2550  break;
2551  case rtfRDblQuote:
2552  RTFPutUnicodeChar (info, 0x201D);
2553  break;
2554  case rtfLTRMark:
2555  RTFPutUnicodeChar (info, 0x200E);
2556  break;
2557  case rtfRTLMark:
2558  RTFPutUnicodeChar (info, 0x200F);
2559  break;
2560  case rtfNoWidthJoiner:
2561  RTFPutUnicodeChar (info, 0x200D);
2562  break;
2563  case rtfNoWidthNonJoiner:
2564  RTFPutUnicodeChar (info, 0x200C);
2565  break;
2566  }
2567 }
2568 
2569 
2570 static void
2572 {
2573  if (info->dwOutputCount)
2574  {
2576  info->dwOutputCount, info->style);
2577  info->dwOutputCount = 0;
2578  }
2579 }
2580 
2581 
2582 static void
2584 {
2585  if (info->dwCPOutputCount)
2586  RTFFlushCPOutputBuffer(info);
2587  while (length)
2588  {
2589  int fit = min(length, sizeof(info->OutputBuffer) / sizeof(WCHAR) - info->dwOutputCount);
2590 
2591  memmove(info->OutputBuffer + info->dwOutputCount, string, fit * sizeof(WCHAR));
2592  info->dwOutputCount += fit;
2593  length -= fit;
2594  string += fit;
2595  if (sizeof(info->OutputBuffer) / sizeof(WCHAR) == info->dwOutputCount)
2597  }
2598 }
2599 
2600 static void
2602 {
2603  int bufferMax = info->dwCPOutputCount * 2 * sizeof(WCHAR);
2604  WCHAR *buffer = heap_alloc(bufferMax);
2605  int length;
2606 
2607  length = MultiByteToWideChar(info->codePage, 0, info->cpOutputBuffer,
2608  info->dwCPOutputCount, buffer, bufferMax/sizeof(WCHAR));
2609  info->dwCPOutputCount = 0;
2610 
2611  RTFPutUnicodeString(info, buffer, length);
2612  heap_free(buffer);
2613 }
2614 
2615 void
2617 {
2618  if (info->dwCPOutputCount)
2619  RTFFlushCPOutputBuffer(info);
2621 }
2622 
2623 static void
2625 {
2626  if (info->dwCPOutputCount)
2627  RTFFlushCPOutputBuffer(info);
2628  if (info->dwOutputCount * sizeof(WCHAR) >= ( sizeof info->OutputBuffer - 1 ) )
2630  info->OutputBuffer[info->dwOutputCount++] = c;
2631 }
2632 
2633 static void
2635 {
2636  /* Use dynamic buffer here because it's the best way to handle
2637  * MBCS codepages without having to worry about partial chars */
2638  if (info->dwCPOutputCount >= info->dwMaxCPOutputCount)
2639  {
2640  info->dwMaxCPOutputCount *= 2;
2642  }
2643  info->cpOutputBuffer[info->dwCPOutputCount++] = c;
2644 }
#define rtfMacQD
Definition: rtf.h:592
#define rtfSect
Definition: rtf.h:228
PARAFORMAT2 fmt
Definition: rtf.h:1175
static size_t double int int int * sign
Definition: printf.c:64
#define rtfRowHt
Definition: rtf.h:414
#define rtfPicScaleX
Definition: rtf.h:605
#define rtfTabBar
Definition: rtf.h:476
#define rtfDrawLineHollow
Definition: rtf.h:812
#define rtfFNoteNumLRoman
Definition: rtf.h:298
#define rtfParNumDecimal
Definition: rtf.h:491
#define rtfSrcNetwork
Definition: rtf.h:741
void WriterInit(RTF_Info *info)
Definition: reader.c:2319
#define rtfDrawPointY
Definition: rtf.h:797
static int Hash(const char *)
Definition: reader.c:2247
int pushedParam
Definition: rtf.h:1130
#define rtfLandscape
Definition: rtf.h:317
#define rtfDrawTextBoxMargin
Definition: rtf.h:792
#define rtfINWords
Definition: rtf.h:211
#define rtfENoteBottom
Definition: rtf.h:287
static void RTFDestroyAttrs(RTF_Info *info)
Definition: reader.c:111
#define rtfObjItem
Definition: rtf.h:153
int codePage
Definition: rtf.h:1145
GLint level
Definition: gl.h:1546
#define rtfAnsiCharSet
Definition: rtf.h:91
#define rtfRTLMark
Definition: rtf.h:252
int rtfSEParam
Definition: rtf.h:997
#define rtfShpPict
Definition: rtf.h:177
#define rtfDrawRect
Definition: rtf.h:766
#define rtfPageDecimal
Definition: rtf.h:387
#define rtfParNumTextAfter
Definition: rtf.h:140
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define rtfENoteRestartCont
Definition: rtf.h:294
#define rtfParNumItalic
Definition: rtf.h:499
#define rtfAnsiCodePage
Definition: rtf.h:345
#define rtfRowKeep
Definition: rtf.h:416
#define major(dev)
Definition: device.h:104
Definition: get.c:139
#define rtfParNumFontSize
Definition: rtf.h:510
#define rtfFontSize
Definition: rtf.h:564
Definition: rtf.h:968
#define TRUE
Definition: types.h:120
#define rtfDocTemplate
Definition: rtf.h:277
int rtfFFamily
Definition: rtf.h:954
static void DefFont(RTF_Info *info)
Definition: reader.c:2447
#define rtfSectPageHt
Definition: rtf.h:372
#define rtfFontTbl
Definition: rtf.h:100
#define rtfUnknown
Definition: rtf.h:68
#define rtfTabCenter
Definition: rtf.h:474
#define rtfObjCropBottom
Definition: rtf.h:681
int rtfFCharSet
Definition: rtf.h:955
#define rtfPageStart
Definition: rtf.h:318
#define rtfDarkDiagHatchBgPat
Definition: rtf.h:547
int rtfKMinor
Definition: reader.c:1253
#define MAC_CHARSET
Definition: wingdi.h:401
#define rtfMergePrevious
Definition: rtf.h:409
#define rtfDrawOffsetX
Definition: rtf.h:769
#define rtfBorderColor
Definition: rtf.h:533
#define rtfNextFile
Definition: rtf.h:120
#define rtfObjAttr
Definition: rtf.h:665
#define rtfCurHeadDateAbbrev
Definition: rtf.h:217
RTFKey ** value
Definition: reader.c:2171
#define rtfPicCropLeft
Definition: rtf.h:610
#define rtfNoUnderline
Definition: rtf.h:576
#define rtfRevised
Definition: rtf.h:567
#define rtfHyphHotZone
Definition: rtf.h:268
#define rtfIRevisionTime
Definition: rtf.h:200
#define rtfParNumDotUnder
Definition: rtf.h:503
#define rtfDrawSolidStartArrow
Definition: rtf.h:822
int rtfSEMinor
Definition: rtf.h:996
#define rtfPageNumTop
Definition: rtf.h:386
#define rtfPaperSize
Definition: rtf.h:309
CFF_Charset charset
Definition: cffcmap.c:138
#define rtfCOLength
Definition: rtf.h:782
#define rtfCONegYQuadrant
Definition: rtf.h:784
#define rtfNoColumnBalance
Definition: rtf.h:325
#define rtfColumnSpRight
Definition: rtf.h:362
#define rtfBitmapWid
Definition: rtf.h:600
#define rtfObjICEmb
Definition: rtf.h:671
#define rtfObjSection
Definition: rtf.h:151
#define rtfACharAttr
Definition: rtf.h:703
#define rtfBorderWidth
Definition: rtf.h:532
#define rtfDrawArcFlipY
Definition: rtf.h:801
#define FF_DONTCARE
Definition: wingdi.h:446
#define rtfBgPatH
Definition: rtf.h:536
#define rtfBeginGroup
Definition: rtf.h:79
#define rtfAllProtected
Definition: rtf.h:334
#define rtfRowLeft
Definition: rtf.h:410
#define rtfNoWidthJoiner
Definition: rtf.h:253
#define rtfBackColor
Definition: rtf.h:582
#define rtfPSOverlay
Definition: rtf.h:276
static void Destination(RTF_Info *info)
Definition: reader.c:2439
#define rtfDrawLineDash
Definition: rtf.h:809
#define rtfHeaderFirst
Definition: rtf.h:134
RTFStyle * rtfNextStyle
Definition: rtf.h:988
#define EASTEUROPE_CHARSET
Definition: wingdi.h:397
#define rtfFunctionKey
Definition: rtf.h:701
DWORD dwOutputCount
Definition: rtf.h:1158
static void RTFSetClassCallback(RTF_Info *info, int class, RTFFuncPtr callback)
Definition: reader.c:180
#define rtfFontAltName
Definition: rtf.h:101
#define rtfIndexText
Definition: rtf.h:170
#define rtfACBold
Definition: rtf.h:704
#define rtfColBreak
Definition: rtf.h:355
int rtfExpanding
Definition: rtf.h:987
#define rtfDrawRoundRect
Definition: rtf.h:794
#define rtfHyphConsecLines
Definition: rtf.h:269
#define rtfRightMargin
Definition: rtf.h:311
#define rtfCell
Definition: rtf.h:225
#define rtfFNAlt
Definition: rtf.h:695
#define rtfSuperScript
Definition: rtf.h:578
#define rtfNormalStyleNum
Definition: rtf.h:61
#define rtfRDblQuote
Definition: rtf.h:245
#define rtfFNSep
Definition: rtf.h:122
#define rtfBgPatV
Definition: rtf.h:537
#define rtfTopVAlign
Definition: rtf.h:397
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define rtfDarkBgPatH
Definition: rtf.h:542
#define rtfPosYTop
Definition: rtf.h:654
#define rtfNestTableProps
Definition: rtf.h:175
#define rtfEndGroup
Definition: rtf.h:80
#define rtfNoWrap
Definition: rtf.h:657
#define rtfEnDash
Definition: rtf.h:238
#define rtfRed
Definition: rtf.h:192
#define rtfDotUnderline
Definition: rtf.h:574
#define rtfParNumLevelStyle
Definition: rtf.h:129
#define rtfBorderBetween
Definition: rtf.h:522
#define rtfFileNum
Definition: rtf.h:732
#define rtfFacingPage
Definition: rtf.h:314
#define rtfHeaderRight
Definition: rtf.h:133
ME_TextEditor * editor
Definition: rtf.h:1149
#define rtfFFDecor
Definition: rtf.h:187
static char * RTFStrSave(const char *s)
Definition: reader.c:70
#define rtfFooterLeft
Definition: rtf.h:135
#define rtfPicMFHasBitmap
Definition: rtf.h:612
#define CP_ACP
Definition: compat.h:99
static void _RTFGetToken2(RTF_Info *)
Definition: reader.c:543
RTFStyleElt * rtfNextSE
Definition: rtf.h:999
#define rtfCellHatchBgPat
Definition: rtf.h:434
#define rtfPageLRoman
Definition: rtf.h:389
#define rtfBookmarkStart
Definition: rtf.h:142
#define rtfFFBidirectional
Definition: rtf.h:189
#define rtfFileSource
Definition: rtf.h:736
#define rtfRowBordBottom
Definition: rtf.h:421
#define rtfACSuperScript
Definition: rtf.h:722
#define SYMBOL_CHARSET
Definition: wingdi.h:383
#define rtfCOTripleLine
Definition: rtf.h:790
#define rtfIBackupTime
Definition: rtf.h:202
int pushedMinor
Definition: rtf.h:1129
#define rtfDrawTextBoxText
Definition: rtf.h:793
int pushedClass
Definition: rtf.h:1127
uint8_t entry
Definition: isohybrid.c:63
#define rtfPosXOutSide
Definition: rtf.h:645
RTFColor * RTFGetColor(const RTF_Info *info, int num)
Definition: reader.c:1226
#define WARN(fmt,...)
Definition: debug.h:111
ME_InStream * stream
Definition: rtf.h:1147
#define rtfEmSpace
Definition: rtf.h:239
#define rtfCurHeadDateLong
Definition: rtf.h:216
#define rtfObjResMerge
Definition: rtf.h:690
char * rtfFAltName
Definition: rtf.h:952
char * rtfFName
Definition: rtf.h:951
#define rtfDrawLineWidth
Definition: rtf.h:814
#define rtfUTF8RTF
Definition: rtf.h:346
#define rtfRevisionTbl
Definition: rtf.h:109
#define rtfDistFromTextAll
Definition: rtf.h:658
int rtfFType
Definition: rtf.h:957
#define rtfRPosPageV
Definition: rtf.h:649
#define rtfFieldEdited
Definition: rtf.h:626
#define rtfEmbeddedFont
Definition: rtf.h:102
#define rtfParNumLeft
Definition: rtf.h:515
#define rtfFontCharSet
Definition: rtf.h:725
#define CHINESEBIG5_CHARSET
Definition: wingdi.h:388
#define rtfColumnLine
Definition: rtf.h:364
#define rtfIYear
Definition: rtf.h:204
void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, const WCHAR *str, int len, ME_Style *style)
Definition: caret.c:508
BOOL ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN
Definition: para.c:779
#define New(t)
Definition: rtf.h:1076
#define rtfTabDecimal
Definition: rtf.h:475
#define rtfRevisions
Definition: rtf.h:339
#define rtfFileTbl
Definition: rtf.h:104
RTFTable * tableDef
Definition: rtf.h:1170
static void ReadObjGroup(RTF_Info *)
Definition: reader.c:1197
#define rtfACSubScript
Definition: rtf.h:707
int rtfSNextPar
Definition: rtf.h:985
#define rtfSectAttr
Definition: rtf.h:348
#define rtfBookmarkEnd
Definition: rtf.h:143
#define rtfPosNegY
Definition: rtf.h:652
RTFFont * RTFGetFont(const RTF_Info *info, int num)
Definition: reader.c:1211
GLuint buffer
Definition: glext.h:5915
static void RTFFlushCPOutputBuffer(RTF_Info *info)
Definition: reader.c:2601
#define isalpha(c)
Definition: acclib.h:74
#define rtfDrawTextBox
Definition: rtf.h:767
#define rtfDrawBgFillBlue
Definition: rtf.h:825
#define rtfRPosParaV
Definition: rtf.h:650
#define rtfPosXRight
Definition: rtf.h:646
#define rtfSrcNTFS
Definition: rtf.h:739
#define rtfDrawBgFillGray
Definition: rtf.h:829
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define rtfFFScript
Definition: rtf.h:186
#define rtfDrawEndArrowWidth
Definition: rtf.h:819
int rtfLineNum
Definition: rtf.h:1117
#define rtfACStrikeThru
Definition: rtf.h:716
#define rtfLTRPar
Definition: rtf.h:470
#define rtfCharSet
Definition: rtf.h:90
#define rtfSpecialChar
Definition: rtf.h:196
#define rtfFNoteNumULetter
Definition: rtf.h:297
#define rtfAbsHt
Definition: rtf.h:637
int rtfSBasedOn
Definition: rtf.h:984
#define rtfParNumAcross
Definition: rtf.h:487
#define rtfBookmarkAttr
Definition: rtf.h:616
#define rtfLanguage
Definition: rtf.h:587
#define rtfShadow
Definition: rtf.h:571
#define rtfFormDisplay
Definition: rtf.h:336
#define rtfHeaderY
Definition: rtf.h:380
int rtfParam
Definition: rtf.h:1112
static void RTFFlushUnicodeOutputBuffer(RTF_Info *info)
Definition: reader.c:2571
#define rtfAnnotAuthor
Definition: rtf.h:160
int rtfCRed
Definition: rtf.h:971
#define rtfNoBreak
Definition: rtf.h:354
#define rtfParNumFont
Definition: rtf.h:509
static void RTFPutCodePageChar(RTF_Info *info, int c)
Definition: reader.c:2634
#define rtfWrapSpaces
Definition: rtf.h:322
#define rtfBorderHair
Definition: rtf.h:531
static void ReadColorTbl(RTF_Info *)
Definition: reader.c:954
#define rtfEmDash
Definition: rtf.h:237
int rtfSAdditive
Definition: rtf.h:982
#define rtfENoteRestart
Definition: rtf.h:293
#define rtfTranspMetafiles
Definition: rtf.h:330
int rtfSType
Definition: rtf.h:981
#define rtfACAllCaps
Definition: rtf.h:705
#define rtfIndex
Definition: rtf.h:169
#define rtfSpaceBefore
Definition: rtf.h:464
#define rtfGroup
Definition: rtf.h:69
#define rtfPageNumEndashSep
Definition: rtf.h:396
#define rtfParNumInclPrev
Definition: rtf.h:513
#define rtfFNoteRestartCont
Definition: rtf.h:292
#define rtfPrintData
Definition: rtf.h:337
struct tagRTFHashTableEntry RTFHashTableEntry
#define rtfPicGoalWid
Definition: rtf.h:603
Definition: compobj.c:613
#define rtfSubDocument
Definition: rtf.h:468
#define rtfObjUpdate
Definition: rtf.h:674
#define rtfNestCell
Definition: rtf.h:258
#define rtfSubScript
Definition: rtf.h:557
#define rtfFNoteEndSect
Definition: rtf.h:280
#define rtfCellBgPatH
Definition: rtf.h:430
#define rtfGray
Definition: rtf.h:588
#define rtfCOAttachBottom
Definition: rtf.h:779
static RTFFuncPtr RTFGetReadHook(const RTF_Info *info)
Definition: reader.c:383
#define WCHAR
Definition: msvc.h:43
#define DEFAULT_CHARSET
Definition: wingdi.h:382
#define rtfUnicodeLength
Definition: rtf.h:589
#define rtfSrcHPFS
Definition: rtf.h:740
#define rtfPicCropRight
Definition: rtf.h:611
#define rtfAnnotProtected
Definition: rtf.h:342
#define rtfDefTab
Definition: rtf.h:267
#define CP_SYMBOL
Definition: winnls.h:222
#define rtfLineStarts
Definition: rtf.h:367
#define rtfRowLeftEdge
Definition: rtf.h:413
Definition: rtf.h:949
#define rtfFFNil
Definition: rtf.h:182
void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor)
Definition: caret.c:493
#define rtfCurHeadPict
Definition: rtf.h:255
#define rtfObjResRTF
Definition: rtf.h:686
#define rtfENoteText
Definition: rtf.h:286
#define rtfObjTime
Definition: rtf.h:148
#define rtfENContNotice
Definition: rtf.h:127
#define rtfPicCropTop
Definition: rtf.h:608
#define rtfCellDiagHatchBgPat
Definition: rtf.h:435
#define rtfRPosMargV
Definition: rtf.h:648
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:66
void ME_StreamInFill(ME_InStream *stream)
Definition: editor.c:1567
#define rtfTabLeft
Definition: rtf.h:472
#define rtfPageNumRight
Definition: rtf.h:385
#define rtfLTRDoc
Definition: rtf.h:344
DWORD DWORD
Definition: winlogon.h:75
#define rtfObjWid
Definition: rtf.h:676
#define rtfIndexBold
Definition: rtf.h:847
#define rtfLTRChar
Definition: rtf.h:584
void RTFSkipGroup(RTF_Info *info)
Definition: reader.c:343
static void CharSet(RTF_Info *info)
Definition: reader.c:2410
#define rtfENoteNumChicago
Definition: rtf.h:306
int rtfTextLen
Definition: rtf.h:1115
#define rtfColorTbl
Definition: rtf.h:106
#define rtfFENoteType
Definition: rtf.h:279
#define rtfParNumURoman
Definition: rtf.h:493
#define rtfRowHeader
Definition: rtf.h:415
static void * heap_alloc(size_t len)
Definition: appwiz.h:61
#define rtfRevDTTM
Definition: rtf.h:569
#define rtfPictAttr
Definition: rtf.h:591
GLuint GLuint stream
Definition: glext.h:7522
#define rtfDrawColumnRelY
Definition: rtf.h:753
#define RTF_KEY_COUNT
Definition: reader.c:2167
#define rtfDropCapType
Definition: rtf.h:663
#define rtfPicHt
Definition: rtf.h:602
#define rtfCharCharSet
Definition: rtf.h:586
#define rtfParSimple
Definition: rtf.h:484
#define rtfSpaceMultiply
Definition: rtf.h:467
#define rtfRow
Definition: rtf.h:226
#define rtfTOCAttr
Definition: rtf.h:631
#define rtfLeaderThick
Definition: rtf.h:480
#define rtfAnnotIcon
Definition: rtf.h:164
int rtfSNum
Definition: rtf.h:983
#define rtfObjClass
Definition: rtf.h:146
int RTFCharSetToCodePage(RTF_Info *info, int charset)
Definition: reader.c:482
#define rtfFTypeNil
Definition: rtf.h:728
#define rtfBorderShadow
Definition: rtf.h:527
#define rtfDrawLineDot
Definition: rtf.h:810
ME_Style * style
Definition: rtf.h:1150
RTFColor * colorList
Definition: rtf.h:1138
#define rtfNoNestTables
Definition: rtf.h:176
#define rtfDrawStartArrowLength
Definition: rtf.h:821
#define rtfSectDef
Definition: rtf.h:349
char * rtfTextBuf
Definition: rtf.h:1114
#define rtfSrcMacintosh
Definition: rtf.h:737
static void Lookup(RTF_Info *, char *)
Definition: reader.c:2218
#define rtfCOAccentBar
Definition: rtf.h:775
#define rtfNestLevel
Definition: rtf.h:550
#define rtfParNumCont
Definition: rtf.h:485
GLuint n
Definition: s_context.h:57
#define rtfNoExtraSpaceRL
Definition: rtf.h:324
static RTFFuncPtr RTFGetClassCallback(const RTF_Info *info, int class)
Definition: reader.c:187
#define rtfCOAttachSmart
Definition: rtf.h:786
#define rtfIVersion
Definition: rtf.h:117
#define rtfBookmarkLastCol
Definition: rtf.h:618
#define rtfMergeRngFirst
Definition: rtf.h:408
#define rtfCharStyle
Definition: rtf.h:933
#define rtfSrcDOS
Definition: rtf.h:738
#define rtfPageNumHyphSep
Definition: rtf.h:392
#define rtfParNumCardinal
Definition: rtf.h:490
#define rtfLeaderDot
Definition: rtf.h:477
#define rtfMacCharSet
Definition: rtf.h:92
#define rtfRevAuthor
Definition: rtf.h:568
#define rtfDistFromTextY
Definition: rtf.h:660
#define rtfDrawLineDashDotDot
Definition: rtf.h:808
#define rtfIndexRange
Definition: rtf.h:171
#define rtfNoBrkSpace
Definition: rtf.h:247
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define rtfCurFNote
Definition: rtf.h:221
#define rtfObjResPict
Definition: rtf.h:687
#define rtfENoteNumURoman
Definition: rtf.h:305
#define rtfNoWidowControl
Definition: rtf.h:451
#define rtfObjEmb
Definition: rtf.h:666
#define rtfDrawBgFillGreen
Definition: rtf.h:826
#define rtfDrawSolidEndArrow
Definition: rtf.h:818
#define rtfNonShpPict
Definition: rtf.h:178
#define rtfDrawHollowEndArrow
Definition: rtf.h:816
#define rtfDrawArcFlipX
Definition: rtf.h:800
static void CharAttr(RTF_Info *info)
Definition: reader.c:2382
#define rtfDrawCallout
Definition: rtf.h:761
#define CP_UTF8
Definition: nls.h:21
#define FALSE
Definition: types.h:117
#define rtfACSmallCaps
Definition: rtf.h:714
#define rtfIMonth
Definition: rtf.h:205
void ME_RTFCharAttrHook(RTF_Info *info)
Definition: editor.c:416
#define rtfDrawFgFillBlue
Definition: rtf.h:830
#define rtfSectMarginBottom
Definition: rtf.h:376
WINE_DEFAULT_DEBUG_CHANNEL(richedit)
int hash
Definition: main.c:58
#define rtfDrawLineSolid
Definition: rtf.h:813
#define rtfFNoteStart
Definition: rtf.h:288
static void _RTFGetToken(RTF_Info *)
Definition: reader.c:443
#define rtfCOAngle
Definition: rtf.h:774
#define rtfUnicode
Definition: rtf.h:257
#define rtfSuperScrShrink
Definition: rtf.h:579
#define rtfOutlineLevel
Definition: rtf.h:453
#define rtfRevBar
Definition: rtf.h:341
#define rtfPicWid
Definition: rtf.h:601
#define rtfENoteEndSect
Definition: rtf.h:284
#define rtfPicScaleY
Definition: rtf.h:606
#define rtfAltKey
Definition: rtf.h:698
int pushedMajor
Definition: rtf.h:1128
#define rtfRTLPar
Definition: rtf.h:469
#define rtfPageRestart
Definition: rtf.h:384
#define rtfCOOffset
Definition: rtf.h:785
#define rtfDrawSizeX
Definition: rtf.h:770
#define rtfSectStyle
Definition: rtf.h:934
#define rtfFontFamily
Definition: rtf.h:181
#define rtfDbUnderline
Definition: rtf.h:575
int stackTop
Definition: rtf.h:1166
static int _RTFGetChar(RTF_Info *)
Definition: reader.c:84
#define rtfPcCharSet
Definition: rtf.h:93
#define rtfSmallCaps
Definition: rtf.h:570
#define rtfBgPatLineColor
Definition: rtf.h:548
#define rtfCellBordBottom
Definition: rtf.h:425
#define rtfDrawLineRed
Definition: rtf.h:805
#define rtfObjData
Definition: rtf.h:149
#define rtfObjPubAutoUpdate
Definition: rtf.h:692
#define rtfNoLineNum
Definition: rtf.h:454
#define rtfPixelBits
Definition: rtf.h:598
#define rtfObjScaleY
Definition: rtf.h:685
#define rtfPrtBinFirst
Definition: rtf.h:351
#define rtfObjScaleX
Definition: rtf.h:684
#define rtfFNoteNumArabic
Definition: rtf.h:295
char * rtfSName
Definition: rtf.h:980
#define rtfRightIndent
Definition: rtf.h:463
#define rtfCellFwdDarkBgPat
Definition: rtf.h:438
#define rtfLDblQuote
Definition: rtf.h:244
#define rtfSoftLineHt
Definition: rtf.h:235
#define rtfENoteNumArabic
Definition: rtf.h:301
int RTFCheckCM(const RTF_Info *info, int class, int major)
Definition: reader.c:2266
int rtfCGreen
Definition: rtf.h:972
#define rtfDrawFgFillGreen
Definition: rtf.h:831
#define rtfPage
Definition: rtf.h:229
#define rtfKeyCode
Definition: rtf.h:108
#define rtfCOAttachAbsDist
Definition: rtf.h:778
#define rtfKeep
Definition: rtf.h:450
#define rtfFieldAlt
Definition: rtf.h:629
#define rtfParAttr
Definition: rtf.h:445
#define rtfBorderDot
Definition: rtf.h:529
#define rtfPosYInline
Definition: rtf.h:653
#define rtfDrawLineBlue
Definition: rtf.h:803
#define rtfDrawPageRelX
Definition: rtf.h:749
#define rtfFormProtected
Definition: rtf.h:333
DWORD dwCPOutputCount
Definition: rtf.h:1161
#define rtfICreateTime
Definition: rtf.h:199
void ME_RTFParAttrHook(RTF_Info *info)
Definition: editor.c:547
#define rtfBufSiz
Definition: rtf.h:20
void RTFFlushOutputBuffer(RTF_Info *info)
Definition: reader.c:2616
#define rtfDrawShadowXOffset
Definition: rtf.h:838
smooth NULL
Definition: ftsmooth.c:513
#define rtfSectMarginRight
Definition: rtf.h:374
#define rtfPageURoman
Definition: rtf.h:388
#define rtfINChars
Definition: rtf.h:212
unsigned char
Definition: typeof.h:27
#define rtfDistFromTextX
Definition: rtf.h:659
#define rtfPar
Definition: rtf.h:227
#define rtfObjHt
Definition: rtf.h:675
#define rtfCOSingleLine
Definition: rtf.h:789
static void ReadPictGroup(RTF_Info *)
Definition: reader.c:1190
#define rtfFontPitch
Definition: rtf.h:726
#define rtfACForeColor
Definition: rtf.h:706
DWORD dwSize
Definition: editstr.h:341
#define rtfParBullet
Definition: rtf.h:483
#define rtfRTLDoc
Definition: rtf.h:343
#define rtfBookmarkFirstCol
Definition: rtf.h:617
#define rtfDarkBgPatV
Definition: rtf.h:543
#define rtfFooterY
Definition: rtf.h:381
#define TURKISH_CHARSET
Definition: wingdi.h:390
#define rtfFooterFirst
Definition: rtf.h:137
#define rtfDrawArc
Definition: rtf.h:760
#define rtfObjTopic
Definition: rtf.h:154
#define rtfDrawPolyLine
Definition: rtf.h:765
#define rtfCellBordLeft
Definition: rtf.h:427
#define rtfFormula
Definition: rtf.h:246
#define rtfParNumBold
Definition: rtf.h:498
#define rtfFieldDirty
Definition: rtf.h:625
BOOL bumpLine
Definition: rtf.h:1134
#define rtfACFontNum
Definition: rtf.h:709
#define rtfSpaceAfter
Definition: rtf.h:465
#define rtfParNumRight
Definition: rtf.h:516
#define rtfHyphAuto
Definition: rtf.h:271
#define rtfLineModulus
Definition: rtf.h:365
#define rtfDrawLineGray
Definition: rtf.h:811
#define isdigit(c)
Definition: acclib.h:68
#define rtfParNumLLetter
Definition: rtf.h:494
#define rtfItalic
Definition: rtf.h:565
#define rtfQuadJust
Definition: rtf.h:459
#define rtfRTLRow
Definition: rtf.h:417
#define rtfISubject
Definition: rtf.h:112
#define rtfNoBrkHyphen
Definition: rtf.h:249
#define rtfVersion
Definition: rtf.h:86
#define rtfFNoteNumURoman
Definition: rtf.h:299
#define rtfBottomMargin
Definition: rtf.h:313
#define rtfBold
Definition: rtf.h:554
#define rtfShowHardBreaks
Definition: rtf.h:332
#define rtfACDbUnderline
Definition: rtf.h:719
#define rtfCellBgPatColor
Definition: rtf.h:443
#define minor(dev)
Definition: device.h:105
#define rtfObjResBitmap
Definition: rtf.h:688
#define rtfIKeywords
Definition: rtf.h:115
#define rtfLinkStyles
Definition: rtf.h:320
#define rtfTblAttr
Definition: rtf.h:404
GLuint GLfloat * val
Definition: glext.h:7180
#define rtfLineCont
Definition: rtf.h:370
#define rtfHeaderLeft
Definition: rtf.h:132
int rtfMinor
Definition: rtf.h:1111
#define rtfFNoteRestartPage
Definition: rtf.h:290
#define rtfParHangIndent
Definition: rtf.h:488
RTFFont * fontList
Definition: rtf.h:1137
#define rtfDrawSizeY
Definition: rtf.h:772
#define rtfDrawPointX
Definition: rtf.h:796
#define rtfCellPos
Definition: rtf.h:407
void ME_RTFSpecialCharHook(RTF_Info *info)
Definition: editor.c:943
#define rtfEnSpace
Definition: rtf.h:240
#define SF_TEXT
Definition: richedit.h:718
#define rtfSuppressTopSpace
Definition: rtf.h:327
#define rtfUnderline
Definition: rtf.h:573
#define rtfRowGapH
Definition: rtf.h:406
void RTFInit(RTF_Info *info)
Definition: reader.c:201
RTFFuncPtr readHook
Definition: rtf.h:1156
#define rtfFieldPrivate
Definition: rtf.h:628
#define rtfLTRRow
Definition: rtf.h:418
#define rtfKerning
Definition: rtf.h:562
void ME_RTFTblAttrHook(RTF_Info *info)
Definition: editor.c:869
#define rtfAnnotRefStart
Definition: rtf.h:157
#define rtfCORightAngle
Definition: rtf.h:788
int rtfCBlue
Definition: rtf.h:973
#define rtfIAuthor
Definition: rtf.h:113
#define rtfFieldAttr
Definition: rtf.h:624
BOOL WINAPI TranslateCharsetInfo(_Inout_ PDWORD, _Out_ LPCHARSETINFO, _In_ DWORD)
#define rtfFirstIndent
Definition: rtf.h:461
#define rtfOptDest
Definition: rtf.h:250
#define rtfFwdDarkBgPat
Definition: rtf.h:544
#define rtfAbsWid
Definition: rtf.h:636
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
#define rtfCellBordRight
Definition: rtf.h:428
GLfloat f
Definition: glext.h:7540
#define rtfRowRight
Definition: rtf.h:411
#define rtfRQuote
Definition: rtf.h:243
#define rtfLeftIndent
Definition: rtf.h:462
#define rtfDrawPolyCount
Definition: rtf.h:798
#define rtfCOAttachCenter
Definition: rtf.h:780
#define TRACE(s)
Definition: solgame.cpp:4
#define rtfSuppressPreParSpace
Definition: rtf.h:328
ME_Style * style
Definition: rtf.h:1090
int rtfClass
Definition: rtf.h:1109
#define rtfPageNumEmdashSep
Definition: rtf.h:395
unsigned int BOOL
Definition: ntddk_ex.h:94
#define rtfCellDarkBgPatH
Definition: rtf.h:436
#define rtfACDotUnderline
Definition: rtf.h:718
#define rtfFieldResult
Definition: rtf.h:167
#define DEFAULT_PITCH
Definition: wingdi.h:441
#define rtfLeaderHyphen
Definition: rtf.h:478
#define rtfColumnNumber
Definition: rtf.h:361
void RTFSetDestinationCallback(RTF_Info *info, int dest, RTFFuncPtr callback)
Definition: reader.c:270
int unicodeLength
Definition: rtf.h:1144
#define rtfDrawHeight
Definition: rtf.h:755
#define rtfExpandTwips
Definition: rtf.h:561
#define rtfPosXLeft
Definition: rtf.h:647
int rtfSEClass
Definition: rtf.h:994
RTFTable * parent
Definition: rtf.h:1034
#define isupper(c)
Definition: acclib.h:71
if(!(yy_init))
Definition: macro.lex.yy.c:704
#define rtfFooterRight
Definition: rtf.h:136
#define rtfNeXTGrAttr
Definition: rtf.h:620
int pushedChar
Definition: rtf.h:1125
#define rtfColumn
Definition: rtf.h:230
#define rtfDrawEllipse
Definition: rtf.h:762
int RTFGetToken(RTF_Info *info)
Definition: reader.c:395
#define rtfFieldLocked
Definition: rtf.h:627
#define rtfParNumTextBefore
Definition: rtf.h:141
#define rtfNoReqHyphen
Definition: rtf.h:248
static void ControlClass(RTF_Info *info)
Definition: reader.c:2347
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define rtfPrintColorsBlack
Definition: rtf.h:323
#define rtfOutline
Definition: rtf.h:566
#define rtfLTRSect
Definition: rtf.h:402
#define rtfParNumStartAt
Definition: rtf.h:517
#define rtfINPages
Definition: rtf.h:210
#define THAI_CHARSET
Definition: wingdi.h:395
char * pushedTextBuf
Definition: rtf.h:1131
#define rtfPicMFBitsPerPixel
Definition: rtf.h:613
#define rtfDataField
Definition: rtf.h:168
#define rtfDefFont
Definition: rtf.h:88
#define rtfDrawEndArrowLength
Definition: rtf.h:817
#define rtfDefLanguage
Definition: rtf.h:278
#define rtfParNumOrdinal
Definition: rtf.h:496
#define rtfNeXTGHeight
Definition: rtf.h:622
#define rtfFootnote
Definition: rtf.h:156
#define rtfParNumIndent
Definition: rtf.h:511
#define rtfBwdDarkBgPat
Definition: rtf.h:545
#define rtfCellFwdDiagBgPat
Definition: rtf.h:432
const GLubyte * c
Definition: glext.h:8905
#define rtfTab
Definition: rtf.h:236
#define SHIFTJIS_CHARSET
Definition: wingdi.h:384
#define rtfPrtBin
Definition: rtf.h:352
#define rtfENoteEndDoc
Definition: rtf.h:285
#define rtfForeColor
Definition: rtf.h:581
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
GLfloat CONST GLvector4f CONST GLfloat GLvector4f * dest
Definition: m_xform.h:122
#define rtfDropCapLines
Definition: rtf.h:662
#define rtfIComment
Definition: rtf.h:116
#define rtfIndexItalic
Definition: rtf.h:848
#define rtfWinBitmap
Definition: rtf.h:596
char * cpOutputBuffer
Definition: rtf.h:1163
#define rtfObjAlias
Definition: rtf.h:150
#define rtfParDef
Definition: rtf.h:446
#define rtfFNoteText
Definition: rtf.h:282
#define rtfCOBorder
Definition: rtf.h:777
#define rtfParNumLRoman
Definition: rtf.h:495
GLuint GLuint num
Definition: glext.h:9618
#define rtfCvtMailMergeQuote
Definition: rtf.h:326
int rtfSEMajor
Definition: rtf.h:995
#define rtfIndexAttr
Definition: rtf.h:845
void ME_AddRefStyle(ME_Style *item) DECLSPEC_HIDDEN
Definition: style.c:431
#define rtfBwdDiagBgPat
Definition: rtf.h:539
#define rtfEvenBreak
Definition: rtf.h:357
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define rtfCellBwdDiagBgPat
Definition: rtf.h:433
#define rtfCellDarkBgPatV
Definition: rtf.h:437
#define rtfColumns
Definition: rtf.h:359
#define rtfFooter
Definition: rtf.h:131
#define rtfHyphenate
Definition: rtf.h:448
#define rtfENoteNumULetter
Definition: rtf.h:303
#define rtfWinMetafile
Definition: rtf.h:594
int defFont
Definition: rtf.h:1141
#define rtfIDoccomm
Definition: rtf.h:118
#define rtfBlue
Definition: rtf.h:194
#define rtfTabPos
Definition: rtf.h:471
#define rtfTopMargin
Definition: rtf.h:312
#define rtfCharStyleNum
Definition: rtf.h:585
#define rtfKeyCodeAttr
Definition: rtf.h:697
void(* RTFFuncPtr)(RTF_Info *)
Definition: rtf.h:1085
#define rtfEmfBlip
Definition: rtf.h:597
#define rtfObjResult
Definition: rtf.h:152
#define RUSSIAN_CHARSET
Definition: wingdi.h:394
RTFFuncPtr dcb[rtfMaxDestination]
Definition: rtf.h:1154
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define rtfPicCropBottom
Definition: rtf.h:609
#define rtfIEditTime
Definition: rtf.h:203
#define rtfFFModern
Definition: rtf.h:185
#define rtfSectNum
Definition: rtf.h:220
#define rtfObjName
Definition: rtf.h:147
#define rtfACOutline
Definition: rtf.h:713
#define rtfCOBestFit
Definition: rtf.h:776
#define rtfParNumOrdinalText
Definition: rtf.h:497
#define rtfObjLinkSelf
Definition: rtf.h:672
#define rtfFontFile
Definition: rtf.h:103
#define rtfDrawShadowYOffset
Definition: rtf.h:839
#define rtfTextDistY
Definition: rtf.h:661
#define rtfENoteStart
Definition: rtf.h:289
#define rtfPosXInside
Definition: rtf.h:644
#define rtfParNumSpacing
Definition: rtf.h:512
#define rtfSoftLine
Definition: rtf.h:234
#define rtfCombineTblBorders
Definition: rtf.h:329
#define rtfInfo
Definition: rtf.h:110
#define rtfParNumbering
Definition: rtf.h:139
void RTFRead(RTF_Info *info)
Definition: reader.c:297
#define rtfAnnotRef
Definition: rtf.h:162
#define rtfDrawBgFillRed
Definition: rtf.h:827
#define rtfPageLLetter
Definition: rtf.h:391
#define rtfInvisible
Definition: rtf.h:580
#define rtfACWordUnderline
Definition: rtf.h:721
#define rtfText
Definition: rtf.h:70
#define rtfStyleNum
Definition: rtf.h:447
#define OEM_CHARSET
Definition: wingdi.h:398
#define rtfPosX
Definition: rtf.h:641
#define rtfCharAttr
Definition: rtf.h:552
#define rtfFNoteNumLLetter
Definition: rtf.h:296
#define rtfPageNumColonSep
Definition: rtf.h:394
#define rtfPicBinary
Definition: rtf.h:614
#define rtfDeleted
Definition: rtf.h:556
#define rtfAllCaps
Definition: rtf.h:555
#define index(s, c)
Definition: various.h:29
#define rtfPageNumSpaceSep
Definition: rtf.h:393
static int GetChar(RTF_Info *)
Definition: reader.c:714
#define rtfControl
Definition: rtf.h:71
EDITSTREAM * editstream
Definition: editstr.h:340
static RTFKey rtfKey[]
Definition: reader.c:1263
Definition: parse.h:22
#define rtfIHour
Definition: rtf.h:207
#define rtfLQuote
Definition: rtf.h:242
#define rtfRPosMargH
Definition: rtf.h:638
#define rtfDrawMarginRelX
Definition: rtf.h:751
#define rtfTemplate
Definition: rtf.h:121
#define rtfDrawLock
Definition: rtf.h:748
#define rtfObjCropTop
Definition: rtf.h:680
static void TextClass(RTF_Info *info)
Definition: reader.c:2340
#define rtfNoAutoTabIndent
Definition: rtf.h:321
#define rtfSwapBorders
Definition: rtf.h:331
#define rtfTOCType
Definition: rtf.h:632
#define rtfMaxClass
Definition: rtf.h:73
#define rtfParNumWordUnder
Definition: rtf.h:506
#define rtfFileAttr
Definition: rtf.h:731
static BOOL heap_free(void *mem)
Definition: wscript.h:65
int ansiCodePage
Definition: rtf.h:1140
#define rtfCODoubleLine
Definition: rtf.h:787
#define rtfMaxDestination
Definition: rtf.h:179
#define rtfACNoUnderline
Definition: rtf.h:720
#define rtfWidowCtrl
Definition: rtf.h:319
#define rtfIIntID
Definition: rtf.h:213
#define rtfACExpand
Definition: rtf.h:708
#define rtfFieldInst
Definition: rtf.h:166
#define rtfPageBreak
Definition: rtf.h:356
GLdouble s
Definition: gl.h:2039
static void ReadStyleSheet(RTF_Info *)
Definition: reader.c:1014
int RTFCheckMM(const RTF_Info *info, int major, int minor)
Definition: reader.c:2278
#define GB2312_CHARSET
Definition: wingdi.h:387
#define rtfPosYBottom
Definition: rtf.h:656
#define rtfParNumAllCaps
Definition: rtf.h:500
#define rtfFFRoman
Definition: rtf.h:183
#define rtfGreen
Definition: rtf.h:193
static RTFFuncPtr RTFGetDestinationCallback(const RTF_Info *info, int dest)
Definition: reader.c:277
#define rtfHatchBgPat
Definition: rtf.h:540
#define rtfObjSetSize
Definition: rtf.h:677
#define rtfDrawPageRelY
Definition: rtf.h:752
#define rtfObjLink
Definition: rtf.h:667
#define rtfDrawBgFillPalette
Definition: rtf.h:828
#define rtfDarkHatchBgPat
Definition: rtf.h:546
int prevChar
Definition: rtf.h:1133
#define rtfNoSuperSub
Definition: rtf.h:559
#define rtfSoftColumn
Definition: rtf.h:233
#define rtfFNoteEndDoc
Definition: rtf.h:281
#define rtfParNumForeColor
Definition: rtf.h:508
#define rtfIDay
Definition: rtf.h:206
#define rtfSectMarginGutter
Definition: rtf.h:377
#define rtfDrawLine
Definition: rtf.h:763
#define rtfCellShading
Definition: rtf.h:429
char buffer[STREAMIN_BUFFER_SIZE]
Definition: editstr.h:343
#define rtfMirrorMargin
Definition: rtf.h:316
#define rtfBitmapPlanes
Definition: rtf.h:599
#define rtfDrawLineGreen
Definition: rtf.h:804
#define rtfRevDisplay
Definition: rtf.h:340
int rtfFCodePage
Definition: rtf.h:958
#define rtfAnnotID
Definition: rtf.h:159
#define rtfExpand
Definition: rtf.h:560
#define rtfParStyle
Definition: rtf.h:932
int rtfFormat
Definition: rtf.h:1113
#define rtfITitle
Definition: rtf.h:111
#define rtfShading
Definition: rtf.h:535
#define rtfGenerator
Definition: rtf.h:174
#define rtfObjAutoLink
Definition: rtf.h:668
#define rtfWordUnderline
Definition: rtf.h:577
#define rtfRowDef
Definition: rtf.h:405
#define rtfPict
Definition: rtf.h:144
#define ERR(fmt,...)
Definition: debug.h:109
#define rtfStyleSheet
Definition: rtf.h:107
#define rtfParNumULetter
Definition: rtf.h:492
#define rtfDrawFgFillGray
Definition: rtf.h:834
#define rtfCellBgPatV
Definition: rtf.h:431
#define rtfTitleSpecial
Definition: rtf.h:379
#define rtfCellBwdDarkBgPat
Definition: rtf.h:439
#define rtfBorderSingle
Definition: rtf.h:525
static void ReadInfoGroup(RTF_Info *)
Definition: reader.c:1183
#define rtfPosXCenter
Definition: rtf.h:643
#define rtfFontAttr
Definition: rtf.h:724
int rtfKMajor
Definition: reader.c:1252
#define rtfFracWidth
Definition: rtf.h:273
#define rtfSectLandscape
Definition: rtf.h:378
void RTFReadGroup(RTF_Info *info)
Definition: reader.c:368
#define rtfDrawMarginRelY
Definition: rtf.h:754
#define rtfENoteHere
Definition: rtf.h:350
const XML_Char XML_Encoding * info
Definition: expat.h:530
static void DocAttr(RTF_Info *info)
Definition: reader.c:2455
#define rtfDrawShadow
Definition: rtf.h:837
#define rtfSpaceBetween
Definition: rtf.h:466
#define rtfFNContSep
Definition: rtf.h:123
#define rtfBorderBox
Definition: rtf.h:524
#define rtfParNumUnder
Definition: rtf.h:502
void LookupCleanup(void)
Definition: reader.c:2200
#define rtfRTFDefault
Definition: rtf.h:275
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define rtfAnnotTime
Definition: rtf.h:163
static void RTFUngetToken(RTF_Info *info)
Definition: reader.c:420
#define rtfCellDarkDiagHatchBgPat
Definition: rtf.h:441
#define rtfDestination
Definition: rtf.h:99
int rtfCNum
Definition: rtf.h:970
BOOL bEmulateVersion10
Definition: editstr.h:352
#define rtfNoWidthNonJoiner
Definition: rtf.h:254
int rtfMajor
Definition: rtf.h:1110
#define rtfACShadow
Definition: rtf.h:715
#define rtfObjSubscriber
Definition: rtf.h:669
#define rtfStrikeThru
Definition: rtf.h:572
#define rtfDrawBeginGroup
Definition: rtf.h:757
#define rtfDrawLineDashDot
Definition: rtf.h:807
#define rtfObjBookmarkPubObj
Definition: rtf.h:691
#define VIETNAMESE_CHARSET
Definition: wingdi.h:400
const char * rtfKStr
Definition: reader.c:1254
#define rtfBorderSpace
Definition: rtf.h:534
#define rtfPosYCenter
Definition: rtf.h:655
#define rtfFNoteCont
Definition: rtf.h:224
int RTFCheckCMM(const RTF_Info *info, int class, int major, int minor)
Definition: reader.c:2272
#define HEBREW_CHARSET
Definition: wingdi.h:391
#define rtfObject
Definition: rtf.h:145
#define rtfCellBordTop
Definition: rtf.h:426
#define f
Definition: ke_i.h:83
#define rtfRTLChar
Definition: rtf.h:583
#define rtfDrawHollowStartArrow
Definition: rtf.h:820
#define rtfBorderLeft
Definition: rtf.h:520
void LookupInit(void)
Definition: reader.c:2181
int nestingLevel
Definition: rtf.h:1171
#define rtfFTypeTrueType
Definition: rtf.h:729
DWORD dwError
Definition: richedit.h:521
#define rtfIPrintTime
Definition: rtf.h:201
int rtfFNum
Definition: rtf.h:953
#define rtfBorderRight
Definition: rtf.h:521
#define rtfParNumDbUnder
Definition: rtf.h:504
#define rtfQuadCenter
Definition: rtf.h:460
#define rtfBorderDouble
Definition: rtf.h:528
#define rtfSectPageWid
Definition: rtf.h:371
#define rtfTabRight
Definition: rtf.h:473
#define min(a, b)
Definition: monoChain.cc:55
#define rtfNext
Definition: rtf.h:264
#define rtfParNumNoUnder
Definition: rtf.h:505
#define rtfLeaderEqual
Definition: rtf.h:481
#define rtfAnnotation
Definition: rtf.h:161
#define rtfDocAttr
Definition: rtf.h:266
#define rtfRPosColH
Definition: rtf.h:640
static void ReadFontTbl(RTF_Info *)
Definition: reader.c:775
#define rtfTOC
Definition: rtf.h:172
#define rtfQuadLeft
Definition: rtf.h:457
#define rtfIMinute
Definition: rtf.h:208
#define rtfRowBordVert
Definition: rtf.h:424
#define rtfLine
Definition: rtf.h:231
#define rtfObjPublisher
Definition: rtf.h:670
#define rtfShiftKey
Definition: rtf.h:699
#define rtfPosAttr
Definition: rtf.h:635
RTFFuncPtr ccb[rtfMaxClass]
Definition: rtf.h:1152
static void SpecialChar(RTF_Info *info)
Definition: reader.c:2471
int BeginFile(RTF_Info *info)
Definition: reader.c:2325
DWORD dwUsed
Definition: editstr.h:342
#define rtfDrawFgFillPalette
Definition: rtf.h:833
#define rtfCellDarkHatchBgPat
Definition: rtf.h:440
#define rtfIVerscomm
Definition: rtf.h:119
#define rtfRevProtected
Definition: rtf.h:338
#define rtfJustVAlign
Definition: rtf.h:400
int rtfLinePos
Definition: rtf.h:1118
#define rtfPosY
Definition: rtf.h:651
#define rtfParNumStrikethru
Definition: rtf.h:507
#define rtfParNumSmallCaps
Definition: rtf.h:501
#define rtfDrawLinePalette
Definition: rtf.h:806
#define rtfLineDist
Definition: rtf.h:366
#define MultiByteToWideChar
Definition: compat.h:100
#define rtfFFTech
Definition: rtf.h:188
#define rtfFNoteBottom
Definition: rtf.h:283
#define rtfPageCont
Definition: rtf.h:383
#define rtfFwdDiagBgPat
Definition: rtf.h:538
#define ARABIC_CHARSET
Definition: wingdi.h:392
#define rtfDiagHatchBgPat
Definition: rtf.h:541
#define rtfTOCLevel
Definition: rtf.h:633
#define rtfNoParam
Definition: rtf.h:52
#define rtfParLevel
Definition: rtf.h:482
void RTFSetReadHook(RTF_Info *info, RTFFuncPtr f)
Definition: reader.c:377
#define rtfFileOSNum
Definition: rtf.h:734
#define rtfDrawOffsetY
Definition: rtf.h:771
#define rtfPaperWidth
Definition: rtf.h:307
#define isxdigit(c)
Definition: acclib.h:70
void RTFSetEditStream(RTF_Info *info, ME_InStream *stream)
Definition: reader.c:105
DWORD dwMaxCPOutputCount
Definition: rtf.h:1162
#define rtfSoftPage
Definition: rtf.h:232
#define rtfParNumRestart
Definition: rtf.h:489
#define rtfDevIndBitmap
Definition: rtf.h:595
void RTFDestroy(RTF_Info *info)
Definition: reader.c:150
#define rtfFormShading
Definition: rtf.h:335
#define rtfISecond
Definition: rtf.h:209
char * rtfSEText
Definition: rtf.h:998
#define EOF
Definition: stdio.h:24
#define rtfGutterWid
Definition: rtf.h:315
#define rtfFNContNotice
Definition: rtf.h:124
#define rtfSectMarginLeft
Definition: rtf.h:373
static void RTFPutUnicodeChar(RTF_Info *info, int c)
Definition: reader.c:2624
POINT cp
Definition: magnifier.c:58
#define rtfParNumCenter
Definition: rtf.h:514
#define rtfENSep
Definition: rtf.h:125
#define rtfCurHeadTime
Definition: rtf.h:218
#define rtfLineRestartPg
Definition: rtf.h:369
Definition: rtf.h:1015
#define rtfBottomVAlign
Definition: rtf.h:398
#define rtfNoStyleNum
Definition: rtf.h:60
#define rtfBorderBottom
Definition: rtf.h:519
#define rtfRowBordRight
Definition: rtf.h:422
#define rtfLeftMargin
Definition: rtf.h:310
#define rtfPlain
Definition: rtf.h:553
#define rtfBorderBar
Definition: rtf.h:523
#define c
Definition: ke_i.h:80
#define rtfRTLSect
Definition: rtf.h:401
#define rtfOddBreak
Definition: rtf.h:358
#define rtfFNoteSep
Definition: rtf.h:223
static RTFHashTableEntry rtfHashTable[RTF_KEY_COUNT *2]
Definition: reader.c:2174
#define rtfLTRMark
Definition: rtf.h:251
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define rtfACLanguage
Definition: rtf.h:712
#define HANGEUL_CHARSET
Definition: wingdi.h:385
#define rtfPageULetter
Definition: rtf.h:390
#define rtfField
Definition: rtf.h:165
#define rtfFNoteNumChicago
Definition: rtf.h:300
#define rtfLineStart
Definition: rtf.h:272
#define rtfObjCropRight
Definition: rtf.h:683
UINT cbSize
Definition: richedit.h:664
static const WCHAR sp[]
Definition: suminfo.c:288
RTFFont * rtfNextFont
Definition: rtf.h:959
BOOL canInheritInTbl
Definition: rtf.h:1172
int rtfKHash
Definition: reader.c:1255
#define rtfIndexNumber
Definition: rtf.h:846
#define rtfFileRelPath
Definition: rtf.h:733
#define rtfHeader
Definition: rtf.h:130
#define rtfIOperator
Definition: rtf.h:114
#define rtfDrawEndGroup
Definition: rtf.h:759
#define rtfParNumText
Definition: rtf.h:138
#define rtfDrawColumnRelX
Definition: rtf.h:750
#define rtfPicGoalHt
Definition: rtf.h:604
#define rtfFileInfo
Definition: rtf.h:105
#define rtfACUnderline
Definition: rtf.h:717
#define rtfNestRow
Definition: rtf.h:259
#define rtfRowBordHoriz
Definition: rtf.h:423
#define rtfNeXTGWidth
Definition: rtf.h:621
#define rtfObjCropLeft
Definition: rtf.h:682
#define rtfDrawFgFillRed
Definition: rtf.h:832
#define rtfCenterVAlign
Definition: rtf.h:399
#define rtfAdditive
Definition: rtf.h:262
#define ANSI_CHARSET
Definition: wingdi.h:381
#define rtfRowBordLeft
Definition: rtf.h:420
#define rtfBgPatColor
Definition: rtf.h:549
GLfloat GLfloat p
Definition: glext.h:8902
#define rtfColumnWidth
Definition: rtf.h:363
#define rtfPBBefore
Definition: rtf.h:455
#define JOHAB_CHARSET
Definition: wingdi.h:399
#define rtfParNumOnce
Definition: rtf.h:486
#define rtfCurHeadPage
Definition: rtf.h:219
#define rtfACItalic
Definition: rtf.h:711
int RTFCharToHex(char c)
Definition: reader.c:2287
#define rtfPMMetafile
Definition: rtf.h:593
#define rtfStyleAttr
Definition: rtf.h:261
#define rtfColorName
Definition: rtf.h:191
#define rtfCOAttachTop
Definition: rtf.h:781
#define rtfMakeBackup
Definition: rtf.h:274
void RTFRouteToken(RTF_Info *info)
Definition: reader.c:310
#define BALTIC_CHARSET
Definition: wingdi.h:393
#define GREEK_CHARSET
Definition: wingdi.h:389
#define memset(x, y, z)
Definition: compat.h:39
int tolower(int c)
Definition: utclib.c:902
#define rtfObjLock
Definition: rtf.h:673
RTFStyleElt * rtfSSEList
Definition: rtf.h:986
#define rtfDrawPolygon
Definition: rtf.h:764
#define rtfIIntVersion
Definition: rtf.h:198
#define rtfCurHeadDate
Definition: rtf.h:215
RTFColor * rtfNextColor
Definition: rtf.h:974
#define rtfObjTransposeY
Definition: rtf.h:679
#define rtfLeaderUnder
Definition: rtf.h:479
#define rtfBasedOn
Definition: rtf.h:263
RTFState stack[maxStack]
Definition: rtf.h:1165
static void RTFPutUnicodeString(RTF_Info *info, const WCHAR *string, int length)
Definition: reader.c:2583
#define rtfDrawFillPatIndex
Definition: rtf.h:835
Definition: rtf.h:978
#define rtfACFontSize
Definition: rtf.h:710
#define rtfDrawStartArrowWidth
Definition: rtf.h:823
#define rtfPicScaled
Definition: rtf.h:607
#define rtfKeepNext
Definition: rtf.h:452
#define CP_OEMCP
Definition: winnls.h:219
#define rtfLineRestart
Definition: rtf.h:368
#define rtfInTable
Definition: rtf.h:449
#define rtfRPosPageH
Definition: rtf.h:639
#define rtfENoteNumLRoman
Definition: rtf.h:304
#define rtfPaperHeight
Definition: rtf.h:308
#define rtfFFSwiss
Definition: rtf.h:184
#define rtfDrawAttr
Definition: rtf.h:747
#define rtfObjResText
Definition: rtf.h:689
#define rtfFNoteAttr
Definition: rtf.h:694
#define rtfQuadRight
Definition: rtf.h:458
#define rtfFNoteRestart
Definition: rtf.h:291
#define rtfSubScrShrink
Definition: rtf.h:558
#define rtfSideBySide
Definition: rtf.h:456
#define rtfFontNum
Definition: rtf.h:563
#define rtfHyphCaps
Definition: rtf.h:270
#define rtfControlKey
Definition: rtf.h:700
RTFStyle * styleList
Definition: rtf.h:1139
#define rtfPcaCharSet
Definition: rtf.h:94
#define rtfCurAnnotRef
Definition: rtf.h:222
#define rtfPageNumLevel
Definition: rtf.h:128
#define rtfSectStyleNum
Definition: rtf.h:353
#define rtfBorderTop
Definition: rtf.h:518
#define rtfDrawGroupCount
Definition: rtf.h:758
#define rtfSectMarginTop
Definition: rtf.h:375
#define rtfBorderThick
Definition: rtf.h:526
#define rtfENoteNumLLetter
Definition: rtf.h:302
WCHAR OutputBuffer[0x1000]
Definition: rtf.h:1159
int rtfFPitch
Definition: rtf.h:956
#define rtfCellBgPatLineColor
Definition: rtf.h:442
#define rtfObjAlign
Definition: rtf.h:678
#define rtfRowCenter
Definition: rtf.h:412
#define rtfColumnSpace
Definition: rtf.h:360
#define TCI_SRCCHARSET
Definition: wingdi.h:959
#define CP_MACCP
Definition: winnls.h:220
#define rtfPosNegX
Definition: rtf.h:642
#define rtfAnnotRefEnd
Definition: rtf.h:158
#define rtfDrawObject
Definition: rtf.h:155
#define rtfFontCodePage
Definition: rtf.h:727
#define rtfNeXTGraphic
Definition: rtf.h:173
#define rtfRowBordTop
Definition: rtf.h:419
#define rtfENContSep
Definition: rtf.h:126
int borderType
Definition: rtf.h:1173
#define rtfCONegXQuadrant
Definition: rtf.h:783
#define rtfPageStarts
Definition: rtf.h:382
#define rtfBullet
Definition: rtf.h:241
#define rtfEOF
Definition: rtf.h:72